-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlayman.min.js
More file actions
15 lines (15 loc) · 309 KB
/
layman.min.js
File metadata and controls
15 lines (15 loc) · 309 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
let BODY_ID="sys_main",GUIDE_CLASS="guideline",MIN_BIAS=1e-10;const styleSheet=document.createElement("style");let page,projectURL,scriptURL;function isScriptLoaded(t){let e=document.getElementsByTagName("script");for(let i=0;i<e.length;i++){if(e[i].src===t)return!0}return null}function docReady(t){"complete"===document.readyState||"interactive"===document.readyState?t():document.addEventListener("DOMContentLoaded",t)}styleSheet.setAttribute("type","text/css"),getUrls(),console.log("projectURL: ",projectURL," , scriptURL: ",scriptURL),Number.isNaN||(Number.isNaN=Number.isNaN||function(t){return"number"==typeof t&&t!=t}),Number.isInteger||(Number.isInteger=function(t){return+t===+t-+t%1}),Object.constructor.prototype.hasOwnProperty("name")||Object.defineProperty(Object.constructor.prototype,"name",{get:function(){return this.toString().trim().replace(/^\S+\s+(\w+)[\S\s]+$/,"$1")}}),[Element.prototype,CharacterData.prototype,DocumentType.prototype].filter(Boolean).forEach(function(t){t.hasOwnProperty("remove")||Object.defineProperty(t,"remove",{configurable:!0,enumerable:!0,writable:!0,value:function(){this.parentNode&&this.parentNode.removeChild(this)}})});let onLayoutComplete=function(){},onSourcesLoaded=function(){},layoutCode=function(){return null};function RemoteLayoutData(t){this.path=t,this.rect=[],this.consumed=!1,this.currentForInclude=new Map}function Page(t){if(this.rootElement=t,this.viewMap=new Map,this.nodeWrappers=new Map,this.hideRoot(),this.layoutObj=layoutCode(),this.sourcesLoaded=!0,this.subPages=new Map,this.sources=new Map,this.srcPaths=[],this.popups=new Map,this.sidemenus=new Map,this.leftMenus=[],this.rightMenus=[],this.includes=new Map,!t){let t=new Style("html,body",[]);t.addFromOptions({width:"100%",height:"100%",padding:"0",margin:"0"});let e=new Style("*",[]);e.addFromOptions({margin:"0",padding:"0","box-sizing":"border-box","-webkit-box-sizing":"border-box","-moz-box-sizing":"border-box","overscroll-behavior":"none"});let i=new Style(".abs",[]);i.addStyleElement("position","absolute"),i.addStyleElement("padding","0"),i.addStyleElement("margin","0"),updateOrCreateSelectorInStyleSheet(styleSheet,t),updateOrCreateSelectorInStyleSheet(styleSheet,e),updateOrCreateSelectorInStyleSheet(styleSheet,i);let r=document.body.getAttribute(attrKeys.layout_constraintGuideColor);r||this.layoutObj&&this.layoutObj.body&&(r=this.layoutObj.body["data-guide-color"]);let n=new Style("."+GUIDE_CLASS,[]);n.addFromOptions({"background-color":r||"transparent",visibility:r?"visible":"hidden"}),updateOrCreateSelectorInStyleSheet(styleSheet,n)}}function shouldIgnoreNonLayoutNode(t){let e=t.nodeName.toLowerCase();return"meta"===e||"title"===e||"head"===e||"script"===e||"link"===e||"style"===e}function isWhiteSpaceOrCommentNode(t){let e=t.nodeName.toLowerCase();return"#text"===e||"#comment"===e}function isWhiteSpaceCommentStyleOrScriptNode(t){let e=t.nodeName.toLowerCase();return"#text"===e||"#comment"===e||"script"===e||"style"===e}function shouldIgnoreSpecialChildElement(t){let e=t.nodeName.toLowerCase();return"li"===e||"tr"===e||"td"===e||"th"===e||"tbody"===e||"thead"===e||"tfoot"===e||"col"===e||"colgroup"===e||"option"===e||"optgroup"===e||"b"===e||"i"===e||"strong"===e||"u"===e||"caption"===e}function enforceIdOnChildElements(t){let e=null;return shouldIgnoreSpecialChildElement(t)&&(e=t.getAttribute(attrKeys.id),e||(e=ULID.ulid(),t.setAttribute(attrKeys.id,e))),e}var loadAll,loadSingleFile;docReady(function(){page=new Page(null),page.layout()}),RemoteLayoutData.prototype.setCurrent=function(t,e){if("string"!=typeof t||"boolean"!=typeof e)throw new Error("Bad arguments for RemoteLayoutData.setCurrent method: includeID must be a string and current must be a boolean.");this.currentForInclude.set(t,e)},RemoteLayoutData.prototype.getCurrent=function(t){return"string"==typeof t&&this.currentForInclude.get(t)},Page.prototype.setCurrentLayoutForInclude=function(t,e){var i=this.includes.get(t);if(i&&i.length>0)for(var r=0;r<i.length;r++)i[r].setCurrent(t,e===r)},Page.prototype.findViewById=function(t){return this.viewMap.get(t)},Page.prototype.getNodeWrapperById=function(t){return this.nodeWrappers.get(t)},Page.prototype.layout=function(){if(this===page){layoutCode()?this.layoutFromSheet(this.rootElement):this.layoutFromTags(this.rootElement)}else this.layoutFromTags(this.rootElement)},Page.prototype.layoutFromSheet=function(t){let e=this,i=t||document.body;if(i===document.body&&(i.id=BODY_ID),t){let e=t.nodeName.toLowerCase();if("script"===e)return;if(!t.id&&!shouldIgnoreSpecialChildElement(t))throw"Please supply the id for node: "+e+", around:\n"+t.outerHTML+". The layout engine needs it."}if(!isWhiteSpaceOrCommentNode(i)){let n=i===document.body?this.layoutObj.body:this.layoutObj.elements[i.id];n?i===document.body&&(n.w="match_parent",n.h="match_parent",n.ss="parent",n.ee="parent",n.tt="parent",n.bb="parent"):n=(document.body,{w:"match_parent",h:"match_parent",ss:"parent",ee:"parent",tt:"parent",bb:"parent"});let o=null,s=new Map;Object.keys(n).forEach(function(r){let a=n[r];if(s.set(r,a),r===attrKeys.layout_src){o=new Scanner(a,!1,[","]).scan(),Array.prototype.push.apply(e.srcPaths,o),e.sourcesLoaded=!1;for(var l=0;l<o.length;l++){let r=new RemoteLayoutData(o[l]),s=n[attrKeys.layout_popup],a=n[attrKeys.layout_menuLeft],p=n[attrKeys.layout_menuRight];if(!0===a&&!0===p)throw`Each html element can only take one of ${attrKeys.layout_menuLeft} or ${attrKeys.layout_menuRight} at once...`;if(!0===a||"true"===a)e.leftMenus.push(i.id),e.sidemenus.set(i.id,r);else if(!0===p||"true"===p)e.rightMenus.push(i.id),e.sidemenus.set(i.id,r);else if(!0===s||"true"===s)e.popups.set(i.id,r);else{var u=o?o.length:0;if(u>0){for(var h=[],c=0;c<u;c++)h.push(new RemoteLayoutData(o[c]));e.includes.set(t.id,h);break}}}}if(r===attrKeys.customType&&"canvas"!==i.nodeName.toLowerCase())throw"Error: the `customType` attribute can only be defined on canvas elements"});var r=this.findViewById(i.id);if(!r){let t=n[attrKeys.layout_constraintGuide];if(t){if("true"!==t&&!0!==t)throw"Invalid value for guide";s.set(attrKeys.layout_width,sizes.WRAP_CONTENT),s.set(attrKeys.layout_height,sizes.WRAP_CONTENT),r=new Guideline(this,i,s,i.parentNode.id)}else enforceIdOnChildElements(i),r=i===document.body?new View(this,i,s,void 0):new View(this,i,s,i.parentNode.id);if(i.hasChildNodes()){let t=i.children;for(let e=0;e<t.length;e++){let i=t[e];if(!isWhiteSpaceCommentStyleOrScriptNode(i)){if(!shouldIgnoreSpecialChildElement(i)){let t=i.getAttribute(attrKeys.id);r.childrenIds.push(t)}this.layoutFromSheet(i)}}}}if(r)if(!0===r.topLevel)if(this.buildUI(r),this.showRoot(),e.srcPaths.length>0)BuildBridgedWorker(workerCode,["loadAll"],["layoutLoaded","layoutError"],[layoutLoaded,layoutError]).loadAll(projectURL,e.srcPaths);else e.sourcesLoaded=!0,onLayoutComplete()}},Page.prototype.layoutFromTags=function(t){let e=this,i=t||document.body;if(i===document.body&&(i.id=BODY_ID),t){let e=t.nodeName.toLowerCase();if("script"===e)return;if(!t.id&&!shouldIgnoreSpecialChildElement(t))throw"Please supply the id for node: "+e+", around:\n"+t.outerHTML+". The layout engine needs it."}if(!isWhiteSpaceOrCommentNode(i)){let t=i.getAttribute(attrKeys.layout_constraint);i.removeAttribute(attrKeys.layout_constraint),t||(t=(document.body,"w:match_parent;h:match_parent;ss:parent;ee:parent;tt:parent;bb:parent")),t=t.trim(),endsWith(t,";")&&(t=t.substring(0,t.length-1)),t=t.replace(/\s*?(;)\s*/g,";"),t=t.replace(/\s*?(:)\s*/g,":"),t=t.split(";");let l=new Map,u=!1,h=!1,c=!1,p=null;for(let r=0;r<t.length;r++){let n,o=t[r];if(-1===(n=o.indexOf(":")))throw"invalid constraint definition... no colon found in "+o+" on "+i.id;{let t=o.substring(0,n),r=o.substring(n+1);switch(l.set(t,r),t===attrKeys.layout_src&&(p=new Scanner(r,!1,[","]).scan(),Array.prototype.push.apply(e.srcPaths,p),e.sourcesLoaded=!1),t){case attrKeys.layout_popup:u=!0===r||"true"===r;break;case attrKeys.layout_menuLeft:h=!0===r||"true"===r;break;case attrKeys.layout_menuRight:c=!0===r||"true"===r}if(h&&c)throw`Each html element can only take one of ${attrKeys.layout_menuLeft} or ${attrKeys.layout_menuRight} at once...`;if(t===attrKeys.customType&&"canvas"!==i.nodeName.toLowerCase())throw"Error: the `customType` attribute can only be defined on canvas elements"}}if(p)for(var r=0;r<p.length;r++){let t=new RemoteLayoutData(p[r]);if(!0===h&&!0===c)throw`Each html element can only take one of ${attrKeys.layout_menuLeft} or ${attrKeys.layout_menuRight} at once...`;if(!0===h)e.leftMenus.push(i.id),e.sidemenus.set(i.id,t);else if(!0===c)e.rightMenus.push(i.id),e.sidemenus.set(i.id,t);else if(!0===u)e.popups.set(i.id,t);else{var n=p?p.length:0;if(n>0){for(var o=[],s=0;s<n;s++)o.push(new RemoteLayoutData(p[s]));e.includes.set(i.id,o);break}}}var a=this.findViewById(i.id);if(!a){let t=i.getAttribute(attrKeys.layout_constraintGuide);if(t){if("true"!==t)throw"Invalid value for data-guide";l.set(attrKeys.layout_width,sizes.WRAP_CONTENT),l.set(attrKeys.layout_height,sizes.WRAP_CONTENT),a=new Guideline(this,i,l,i.parentNode.id)}else enforceIdOnChildElements(i),a=i===document.body?new View(this,i,l,void 0):new View(this,i,l,i.parentNode.id);if(i.hasChildNodes()){let t=i.children;for(let e=0;e<t.length;e++){let i=t[e];if(!isWhiteSpaceCommentStyleOrScriptNode(i)){if(!shouldIgnoreSpecialChildElement(i)){let t=i.getAttribute(attrKeys.id);a.childrenIds.push(t)}this.layoutFromTags(i)}}}}if(a)if(!0===a.topLevel)if(this.buildUI(a),this.showRoot(),e.srcPaths.length>0)BuildBridgedWorker(workerCode,["loadAll"],["layoutLoaded","layoutError"],[layoutLoaded,layoutError]).loadAll(projectURL,e.srcPaths);else e.sourcesLoaded=!0,onLayoutComplete()}},Page.prototype.buildUI=function(t){let e=[],i=[],r=[],n=function(t,o){t.childrenIds.length>0&&(autoLayout(t.htmlNode===document.body?void 0:t.htmlNode,t.layoutChildren(o)),t.childrenIds.forEach(function(t){let s=o.viewMap.get(t);s.isPopup()&&i.push(s),s.isSideMenu()&&r.push(s),s.hasBgImage&&e.push(s),s.childrenIds.length>0&&n(s,o)}))};n(t,this),e.forEach(function(t){t.makeBgImage()});let o=this;i.forEach(function(t){let e=o.popups.get(t.id);e.rect=t.htmlNode.getBoundingClientRect(),o.popups.set(t.id,e),t.htmlNode.remove()}),r.forEach(function(t){let e=o.sidemenus.get(t.id);e.rect=t.htmlNode.getBoundingClientRect(),o.sidemenus.set(t.id,e),t.htmlNode.remove()})},Page.prototype.showRoot=function(){this.rootElement&&this.rootElement!==document.body?this.rootElement.style.visibility="visible":document.body.style.visibility="visible"},Page.prototype.hideRoot=function(){this.rootElement&&this.rootElement!==document.body?this.rootElement.style.visibility="hidden":document.body.style.visibility="hidden"},Page.prototype.openSideMenu=function(t,e,i,r,n){if(5!==arguments.length)throw"`Page.openSideMenu` function requires 4 arguments";if("string"!=typeof t)throw"`menuId` must be a string";if("boolean"!=typeof e)throw"`closeOnClickOutSide` must be a boolean";if("function"!=typeof i)throw"onOpen must be a function";if("function"!=typeof r)throw"onClose must be a function";if("function"!=typeof n)throw"onBind must be a function";let o=this.sidemenus.get(t),s=-1!==this.leftMenus.indexOf(t),a=-1!==this.rightMenus.indexOf(t),l=s?SideMenuTypes.LEFT:a?SideMenuTypes.RIGHT:null;if(!l)throw"Invalid menutype found";let u=this.sources.get(o.path),h=o.rect;if(!h||!h.width||!h.height)throw"specify width or height on popup: "+t;return new SideMenuX({id:t,layout:u,width:h.width,onOpen:i,onClose:r,onBind:n,menuType:l,closeOnClickOutside:e,bg:"#fff"}).open()},Page.prototype.initSideMenu=function(t,e,i,r,n){if(5!==arguments.length)throw"`Page.openSideMenu` function requires 4 arguments";if("string"!=typeof t)throw"`menuId` must be a string";if("boolean"!=typeof e)throw"`closeOnClickOutSide` must be a boolean";if("function"!=typeof i)throw"onOpen must be a function";if("function"!=typeof r)throw"onClose must be a function";if("function"!=typeof n)throw"onBind must be a function";let o=this.sidemenus.get(t),s=-1!==this.leftMenus.indexOf(t),a=-1!==this.rightMenus.indexOf(t),l=s?SideMenuTypes.LEFT:a?SideMenuTypes.RIGHT:null;if(!l)throw"Invalid menutype found";let u=this.sources.get(o.path),h=o.rect;if(!h||!h.width||!h.height)throw"specify width or height on popup: "+popupId;return new SideMenuX({id:t,layout:u,width:h.width,onOpen:i,onClose:r,onBind:n,menuType:l,closeOnClickOutside:"boolean"==typeof e&&e,bg:"#fff"}).build()},Page.prototype.openPopup=function(t,e,i,r){if(4!==arguments.length)throw"`Page.openPopup` function requires 4 arguments";if("string"!=typeof t)throw"`popupId` must be a string";if("boolean"!=typeof e)throw"`closeOnClickOutSide` must be a boolean";if("function"!=typeof i)throw"onOpen must be a function";if("function"!=typeof r)throw"onClose must be a function";let n=this.popups.get(t),o=this.sources.get(n.path),s=n.rect;if(!s||!s.width||!s.height)throw"specify width or height on popup: "+t;return new Popup({id:t,layout:o,width:s.width,height:s.height,closeOnClickOutside:"boolean"==typeof e&&e,bg:"#fff",onOpen:i,onClose:r}).open()},Page.prototype.closePopup=function(t){t.hide()},Page.prototype.renderInclude=function(t,e,i){i||(i=0);const r=(this.includes.get(t)||[])[i],n=document.getElementById(t);let o=e;if(!o&&r&&(o=this.sources.get(r.path),page.setCurrentLayoutForInclude(t,i)),!o)throw new Error("Bad error! HTML content is missing. Neither htmlContent was supplied nor layoutData was available to fetch it.");n.innerHTML=o;const s=new Page(n);s.layout(),this.subPages.set(t,s)},Page.prototype.loadRemote=function(t,e,i,r){if("function"!=typeof i)throw new Error("`loadSucc` must be a function");if("function"!=typeof r)throw new Error("`loadErr` must be a function");var n=page.sources.get(t);if(n)i(n);else{BuildBridgedWorker(workerCode,["loadSingleFile"],["loadSucc","loadErr"],[function(r,n){page.srcPaths.push(t),page.sources.set(t,r);var o=[];o.push(new RemoteLayoutData(t)),page.includes.set(e,o),i(r)},function(t,e){r(t)}]).loadSingleFile(projectURL,t,e)}},Page.prototype.loadRemoteAndShow=function(t,e,i,r){if("function"!=typeof i)throw new Error("`loadSucc` must be a function");if("function"!=typeof r)throw new Error("`loadErr` must be a function");var n=page.sources.get(t);if(n)return page.renderInclude(e,n),void i(n);BuildBridgedWorker(workerCode,["loadSingleFile"],["loadSucc","loadErr"],[function(e,r){page.srcPaths.push(t),page.sources.set(t,e);var n=[];n.push(new RemoteLayoutData(t)),page.includes.set(r,n),page.renderInclude(r,e),i(e)},function(t,e){r(t)}]).loadSingleFile(projectURL,t,e)};var workerCode=function(){function loadFiles(t,e,i){if(Array.isArray(e))if(i<e.length){var r=e[i];loadFile(t,r,function(n){main.layoutLoaded(r,n,!1),loadFiles(t,e,i+1)},function(t){main.layoutError(t)})}else main.layoutLoaded(null,"",!0);else main.layoutError(new Error("Pass an array of filepaths here"))}loadAll=function(t,e){loadFiles(t,e,0)};var t,loadFile=function(t,e,i,r){const n=new URL(e,t);fetch(n,{credentials:"same-origin"}).then(function(t){return t}).then(function(t){return t.text()}).then(function(t){i(t)}).catch(function(t){setTimeout(function(){throw r(t),t})})};loadSingleFile=function(t,e,i){const r=new URL(e,t);fetch(r,{credentials:"same-origin"}).then(function(t){if(!t.ok)throw new Error(`HTTP error! status: ${t.status} for file: ${e}`);return t.text()}).then(function(t){main.loadSucc(t,i)}).catch(function(t){main.loadErr(t.message||String(t),i)})},t=function(){"use strict";function t(t){var e=this.constructor;return this.then(function(i){return e.resolve(t()).then(function(){return i})},function(i){return e.resolve(t()).then(function(){return e.reject(i)})})}function e(t){return new this(function(e,i){function r(t,i){if(i&&("object"==typeof i||"function"==typeof i)){var s=i.then;if("function"==typeof s)return void s.call(i,function(e){r(t,e)},function(i){n[t]={status:"rejected",reason:i},0==--o&&e(n)})}n[t]={status:"fulfilled",value:i},0==--o&&e(n)}if(!t||void 0===t.length)return i(new TypeError(typeof t+" "+t+" is not iterable(cannot read property Symbol(Symbol.iterator))"));var n=Array.prototype.slice.call(t);if(0===n.length)return e([]);for(var o=n.length,s=0;n.length>s;s++)r(s,n[s])})}function i(t){return!(!t||void 0===t.length)}function r(){}function n(t){if(!(this instanceof n))throw new TypeError("Promises must be constructed via new");if("function"!=typeof t)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=void 0,this._deferreds=[],u(t,this)}function o(t,e){for(;3===t._state;)t=t._value;0!==t._state?(t._handled=!0,n._immediateFn(function(){var i=1===t._state?e.onFulfilled:e.onRejected;if(null!==i){var r;try{r=i(t._value)}catch(t){return void a(e.promise,t)}s(e.promise,r)}else(1===t._state?s:a)(e.promise,t._value)})):t._deferreds.push(e)}function s(t,e){try{if(e===t)throw new TypeError("A promise cannot be resolved with itself.");if(e&&("object"==typeof e||"function"==typeof e)){var i=e.then;if(e instanceof n)return t._state=3,t._value=e,void l(t);if("function"==typeof i)return void u(function(t,e){return function(){t.apply(e,arguments)}}(i,e),t)}t._state=1,t._value=e,l(t)}catch(e){a(t,e)}}function a(t,e){t._state=2,t._value=e,l(t)}function l(t){2===t._state&&0===t._deferreds.length&&n._immediateFn(function(){t._handled||n._unhandledRejectionFn(t._value)});for(var e=0,i=t._deferreds.length;i>e;e++)o(t,t._deferreds[e]);t._deferreds=null}function u(t,e){var i=!1;try{t(function(t){i||(i=!0,s(e,t))},function(t){i||(i=!0,a(e,t))})}catch(t){if(i)return;i=!0,a(e,t)}}var h=setTimeout;n.prototype.catch=function(t){return this.then(null,t)},n.prototype.then=function(t,e){var i=new this.constructor(r);return o(this,new function(t,e,i){this.onFulfilled="function"==typeof t?t:null,this.onRejected="function"==typeof e?e:null,this.promise=i}(t,e,i)),i},n.prototype.finally=t,n.all=function(t){return new n(function(e,r){function n(t,i){try{if(i&&("object"==typeof i||"function"==typeof i)){var a=i.then;if("function"==typeof a)return void a.call(i,function(e){n(t,e)},r)}o[t]=i,0==--s&&e(o)}catch(t){r(t)}}if(!i(t))return r(new TypeError("Promise.all accepts an array"));var o=Array.prototype.slice.call(t);if(0===o.length)return e([]);for(var s=o.length,a=0;o.length>a;a++)n(a,o[a])})},n.allSettled=e,n.resolve=function(t){return t&&"object"==typeof t&&t.constructor===n?t:new n(function(e){e(t)})},n.reject=function(t){return new n(function(e,i){i(t)})},n.race=function(t){return new n(function(e,r){if(!i(t))return r(new TypeError("Promise.race accepts an array"));for(var o=0,s=t.length;s>o;o++)n.resolve(t[o]).then(e,r)})},n._immediateFn="function"==typeof setImmediate&&function(t){setImmediate(t)}||function(t){h(t,0)},n._unhandledRejectionFn=function(t){void 0!==console&&console&&console.warn("Possible Unhandled Promise Rejection:",t)};var c=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof global)return global;throw Error("unable to locate global object")}();"function"!=typeof c.Promise?c.Promise=n:(c.Promise.prototype.finally||(c.Promise.prototype.finally=t),c.Promise.allSettled||(c.Promise.allSettled=e))},"object"==typeof exports&&"undefined"!=typeof module?t():"function"==typeof define&&define.amd?define(t):t(),function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.WHATWGFetch={})}(this,function(t){"use strict";var e="undefined"!=typeof self&&self||void 0!==e&&e,i="URLSearchParams"in e,r="Symbol"in e&&"iterator"in Symbol,n="FileReader"in e&&"Blob"in e&&function(){try{return new Blob,!0}catch(t){return!1}}(),o="FormData"in e,s="ArrayBuffer"in e;if(s)var a=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],l=ArrayBuffer.isView||function(t){return t&&a.indexOf(Object.prototype.toString.call(t))>-1};function u(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(t)||""===t)throw new TypeError("Invalid character in header field name");return t.toLowerCase()}function h(t){return"string"!=typeof t&&(t=String(t)),t}function c(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return r&&(e[Symbol.iterator]=function(){return e}),e}function p(t){this.map={},t instanceof p?t.forEach(function(t,e){this.append(e,t)},this):Array.isArray(t)?t.forEach(function(t){this.append(t[0],t[1])},this):t&&Object.getOwnPropertyNames(t).forEach(function(e){this.append(e,t[e])},this)}function d(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function f(t){return new Promise(function(e,i){t.onload=function(){e(t.result)},t.onerror=function(){i(t.error)}})}function y(t){var e=new FileReader,i=f(e);return e.readAsArrayBuffer(t),i}function g(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function m(){return this.bodyUsed=!1,this._initBody=function(t){var e;this.bodyUsed=this.bodyUsed,this._bodyInit=t,t?"string"==typeof t?this._bodyText=t:n&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:o&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:i&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():s&&n&&((e=t)&&DataView.prototype.isPrototypeOf(e))?(this._bodyArrayBuffer=g(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):s&&(ArrayBuffer.prototype.isPrototypeOf(t)||l(t))?this._bodyArrayBuffer=g(t):this._bodyText=t=Object.prototype.toString.call(t):this._bodyText="",this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):i&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},n&&(this.blob=function(){var t=d(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){if(this._bodyArrayBuffer){var t=d(this);return t||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}return this.blob().then(y)}),this.text=function(){var t,e,i,r=d(this);if(r)return r;if(this._bodyBlob)return t=this._bodyBlob,e=new FileReader,i=f(e),e.readAsText(t),i;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),i=new Array(e.length),r=0;r<e.length;r++)i[r]=String.fromCharCode(e[r]);return i.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},o&&(this.formData=function(){return this.text().then(b)}),this.json=function(){return this.text().then(JSON.parse)},this}p.prototype.append=function(t,e){t=u(t),e=h(e);var i=this.map[t];this.map[t]=i?i+", "+e:e},p.prototype.delete=function(t){delete this.map[u(t)]},p.prototype.get=function(t){return t=u(t),this.has(t)?this.map[t]:null},p.prototype.has=function(t){return this.map.hasOwnProperty(u(t))},p.prototype.set=function(t,e){this.map[u(t)]=h(e)},p.prototype.forEach=function(t,e){for(var i in this.map)this.map.hasOwnProperty(i)&&t.call(e,this.map[i],i,this)},p.prototype.keys=function(){var t=[];return this.forEach(function(e,i){t.push(i)}),c(t)},p.prototype.values=function(){var t=[];return this.forEach(function(e){t.push(e)}),c(t)},p.prototype.entries=function(){var t=[];return this.forEach(function(e,i){t.push([i,e])}),c(t)},r&&(p.prototype[Symbol.iterator]=p.prototype.entries);var w=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function v(t,e){if(!(this instanceof v))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');var i,r,n=(e=e||{}).body;if(t instanceof v){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new p(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,n||null==t._bodyInit||(n=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=e.credentials||this.credentials||"same-origin",!e.headers&&this.headers||(this.headers=new p(e.headers)),this.method=(i=e.method||this.method||"GET",r=i.toUpperCase(),w.indexOf(r)>-1?r:i),this.mode=e.mode||this.mode||null,this.signal=e.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&n)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(n),!("GET"!==this.method&&"HEAD"!==this.method||"no-store"!==e.cache&&"no-cache"!==e.cache)){var o=/([?&])_=[^&]*/;if(o.test(this.url))this.url=this.url.replace(o,"$1_="+(new Date).getTime());else{this.url+=(/\?/.test(this.url)?"&":"?")+"_="+(new Date).getTime()}}}function b(t){var e=new FormData;return t.trim().split("&").forEach(function(t){if(t){var i=t.split("="),r=i.shift().replace(/\+/g," "),n=i.join("=").replace(/\+/g," ");e.append(decodeURIComponent(r),decodeURIComponent(n))}}),e}function A(t,e){if(!(this instanceof A))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');e||(e={}),this.type="default",this.status=void 0===e.status?200:e.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in e?e.statusText:"",this.headers=new p(e.headers),this.url=e.url||"",this._initBody(t)}v.prototype.clone=function(){return new v(this,{body:this._bodyInit})},m.call(v.prototype),m.call(A.prototype),A.prototype.clone=function(){return new A(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new p(this.headers),url:this.url})},A.error=function(){var t=new A(null,{status:0,statusText:""});return t.type="error",t};var _=[301,302,303,307,308];A.redirect=function(t,e){if(-1===_.indexOf(e))throw new RangeError("Invalid status code");return new A(null,{status:e,headers:{location:t}})},t.DOMException=e.DOMException;try{new t.DOMException}catch(e){t.DOMException=function(t,e){this.message=t,this.name=e;var i=Error(t);this.stack=i.stack},t.DOMException.prototype=Object.create(Error.prototype),t.DOMException.prototype.constructor=t.DOMException}function E(i,r){return new Promise(function(o,a){var l=new v(i,r);if(l.signal&&l.signal.aborted)return a(new t.DOMException("Aborted","AbortError"));var u=new XMLHttpRequest;function c(){u.abort()}u.onload=function(){var t,e,i={status:u.status,statusText:u.statusText,headers:(t=u.getAllResponseHeaders()||"",e=new p,t.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach(function(t){var i=t.split(":"),r=i.shift().trim();if(r){var n=i.join(":").trim();e.append(r,n)}}),e)};i.url="responseURL"in u?u.responseURL:i.headers.get("X-Request-URL");var r="response"in u?u.response:u.responseText;setTimeout(function(){o(new A(r,i))},0)},u.onerror=function(){setTimeout(function(){a(new TypeError("Network request failed"))},0)},u.ontimeout=function(){setTimeout(function(){a(new TypeError("Network request failed"))},0)},u.onabort=function(){setTimeout(function(){a(new t.DOMException("Aborted","AbortError"))},0)},u.open(l.method,function(t){try{return""===t&&e.location.href?e.location.href:t}catch(e){return t}}(l.url),!0),"include"===l.credentials?u.withCredentials=!0:"omit"===l.credentials&&(u.withCredentials=!1),"responseType"in u&&(n?u.responseType="blob":s&&l.headers.get("Content-Type")&&-1!==l.headers.get("Content-Type").indexOf("application/octet-stream")&&(u.responseType="arraybuffer")),!r||"object"!=typeof r.headers||r.headers instanceof p?l.headers.forEach(function(t,e){u.setRequestHeader(e,t)}):Object.getOwnPropertyNames(r.headers).forEach(function(t){u.setRequestHeader(t,h(r.headers[t]))}),l.signal&&(l.signal.addEventListener("abort",c),u.onreadystatechange=function(){4===u.readyState&&l.signal.removeEventListener("abort",c)}),u.send(void 0===l._bodyInit?null:l._bodyInit)})}E.polyfill=!0,e.fetch||(e.fetch=E,e.Headers=p,e.Request=v,e.Response=A),t.Headers=p,t.Request=v,t.Response=A,t.fetch=E,Object.defineProperty(t,"__esModule",{value:!0})})},layoutLoaded=function(t,e,i){page.sources.set(t,e),i&&(page.sourcesLoaded=i,onSourcesLoaded()),page.includes.forEach(function(i,r){for(var n=null,o=0;o<i.length;o++){var s=i[o];s.setCurrent(r,!1),n=null===n?s:n,!1===s.consumed&&s.path===t&&(page.renderInclude(r,e,o),s.consumed=!0)}n&&n.setCurrent(r,!0)}),i&&onLayoutComplete()},layoutError=function(t){throw t};function layoutRootOnBindingElement(t,e){if("string"!=typeof t&&t)throw"Invalid bindingElemId...bindingElemId: "+t;if("string"!=typeof e||0===e.length)throw"Invalid rootChildId";return[{view1:e,attr1:"centerX",relation:"equ",view2:t,attr2:"centerX",constant:0,multiplier:1,priority:AutoLayout.Priority.REQUIRED},{view1:e,attr1:"centerY",relation:"equ",view2:t,attr2:"centerY",constant:0,multiplier:1,priority:AutoLayout.Priority.REQUIRED},{view1:e,attr1:"width",relation:"equ",view2:t,attr2:"width",constant:0,multiplier:1,priority:AutoLayout.Priority.REQUIRED},{view1:e,attr1:"height",relation:"equ",view2:t,attr2:"height",constant:0,multiplier:1,priority:AutoLayout.Priority.REQUIRED}]}function autoLayout(t,e){let i=e&&isOneDimArray(e)&&e.length>0&&"string"==typeof e[0],r=e&&isOneDimArray(e)&&(e.length>0&&"object"==typeof e[0]||0===e.length),n=window.AutoLayout,o=new n.View;if(!0===i)o.addConstraints(n.VisualFormat.parse(e,{extended:!0}));else{if(!r)throw"Invalid parameters passed to autoLayout! no layout constraints specified";o.addConstraints(e)}let s={};for(let t in o.subViews){let e=document.getElementById(t);e&&(addClass(e,"abs"),s[t]=e)}var a=function(){if(t){let e=t.scrollWidth>t.clientWidth,i=t.scrollHeight>t.clientHeight?window.innerWidth-getScrollBarWidth():window.innerWidth,r=e?window.innerHeight-getScrollBarWidth():window.innerHeight;o.setSize(t?t.clientWidth:i,t?t.clientHeight:r-1)}else o.setSize(t?t.clientWidth:window.innerWidth,t?t.clientHeight:window.innerHeight-1);for(let t in o.subViews){var e=o.subViews[t];let i=s[t];i&&setAbsoluteSizeAndPosition(i,e.left,e.top,e.width,e.height)}};if(window.addEventListener("resize",a),!t){let t=document.body.children;for(let e=0;e<t.length;e++){let i=t[e];new ResizeSensor(i,function(){i&&(i.scrollHeight>i.clientHeight||i.scrollWidth>i.clientWidth)&&a()})}}return a(),a}let transformAttr="transform"in document.documentElement.style?"transform":void 0;function setAbsoluteSizeAndPosition(t,e,i,r,n){t.setAttribute("style","width: "+r+"px; height: "+n+"px; "+transformAttr+": translate3d("+e+"px, "+i+"px, 0px);")}function View(t,e,i,r){const n=e.id;if(null==n||""===n)throw"Please specify the view id properly";if(void 0!==t.findViewById(n))throw"A view with this id(`"+n+"`) exists already";if(-1!==n.indexOf("-"))throw"troublesome id here: layman does not support hyphens(-) in ids for now id=("+n+")";if(this.htmlNode=e,this.topLevel=0===t.viewMap.size||!r,this.id=n,this.parentId=r,this.childrenIds=[],this.hasBgImage=!!i.get(attrKeys.mi_useAutoBg),i&&i.size>0){let t=i.get(attrKeys.layout_margin),e=i.get(attrKeys.layout_marginHorizontal),r=i.get(attrKeys.layout_marginVertical);if(this.margins={top:i.get(attrKeys.layout_marginTop),bottom:i.get(attrKeys.layout_marginBottom),start:i.get(attrKeys.layout_marginStart),end:i.get(attrKeys.layout_marginEnd),horUnitsSame:!0,verUnitsSame:!0,horMarginDiff:function(){let t=parseNumberAndUnitsNoValidation(this.start,!0),e=parseNumberAndUnitsNoValidation(this.end,!0);if(!this.horUnitsSame)throw"start and end margins must be same when using `cx, scx, cxs` etc.";return parseFloat(t.number)-parseFloat(e.number)+t.units},verMarginDiff:function(){let t=parseNumberAndUnitsNoValidation(this.top,!0),e=parseNumberAndUnitsNoValidation(this.bottom,!0);if(!this.verUnitsSame)throw"top and bottom margins must be same when using `cy, tcy, cyt` etc.";return parseFloat(t.number)-parseFloat(e.number)+t.units}},r){if(!isNumber(parseInt(r)))throw new Error("Invalid value specified for the vertical margin on "+this.constructor.name+"("+this.id+")");this.margins.top=r,this.margins.bottom=r}if(e){if(!isNumber(parseInt(e)))throw new Error("Invalid value specified for the horizontal margin on "+this.constructor.name+"("+this.id+")");this.margins.start=e,this.margins.end=e}if(t){if(!isNumber(parseInt(t)))throw new Error("Invalid value specified for the margins on "+this.constructor.name+"("+this.id+")");this.margins.top=t,this.margins.bottom=t,this.margins.start=t,this.margins.end=t}this.margins.top&&startsWith(this.margins.top,"+")&&(this.margins.top=this.margins.top.substr(1)),this.margins.bottom&&startsWith(this.margins.bottom,"+")&&(this.margins.bottom=this.margins.bottom.substr(1)),this.margins.start&&startsWith(this.margins.start,"+")&&(this.margins.start=this.margins.start.substr(1)),this.margins.end&&startsWith(this.margins.end,"+")&&(this.margins.end=this.margins.end.substr(1)),this.margins.start&&"0"!==this.margins.start||(this.margins.start=0),this.margins.end&&"0"!==this.margins.end||(this.margins.end=0),this.margins.top&&"0"!==this.margins.top||(this.margins.top=0),this.margins.bottom&&"0"!==this.margins.bottom||(this.margins.bottom=0);{let t=parseNumberAndUnitsNoValidation(this.margins.start,!0),e=parseNumberAndUnitsNoValidation(this.margins.end,!0),r=parseNumberAndUnitsNoValidation(this.margins.top,!0),n=parseNumberAndUnitsNoValidation(this.margins.bottom,!0),o=i.get(attrKeys.layout_marginStart),s=i.get(attrKeys.layout_marginEnd),a=i.get(attrKeys.layout_marginTop),l=i.get(attrKeys.layout_marginBottom);o&&s&&t.units!==e.units&&0!==parseInt(t.number)&&0!==parseInt(e.number)&&(this.margins.horUnitsSame=!1),a&&l&&r.units!==n.units&&0!==parseInt(r.number)&&0!==parseInt(n.number)&&(this.margins.verUnitsSame=!1),o&&!s&&(this.margins.end="0"+t.units),s&&!o&&(this.margins.start="0"+e.units),a&&!l&&(this.margins.bottom="0"+r.units),l&&!a&&(this.margins.top="0"+n.units)}this.width=i.get(attrKeys.layout_width),this.height=i.get(attrKeys.layout_height),this.width===sizes.MATCH_PARENT&&(this.width="100%"),this.height===sizes.MATCH_PARENT&&(this.height="100%"),endsWith(this.width,"px")&&(this.width=parseFloat(this.width)),endsWith(this.height,"px")&&(this.height=parseFloat(this.height)),this.dimRatio=-1,this.wrapWidth=-1,this.wrapHeight=-1;const n=new Error;if(void 0===this.width||null===this.width||""===this.width)throw n.name="UnspecifiedWidthError",n.message="Please specify the width for '"+this.id+"'",n;if(void 0===this.height||null===this.height||""===this.height)throw n.name="UnspecifiedHeightError",n.message="Please specify the height for '"+this.id+"'",n;let o=this;i.forEach(function(t,e,r){switch(e){case attrKeys.layout:i.set(attrKeys.layout,t);break;case attrKeys.layout_width:isNaN(parseInt(e))&&i.set(attrKeys.layout_width,t);break;case attrKeys.layout_height:isNaN(parseInt(e))&&i.set(attrKeys.layout_height,t);break;case attrKeys.layout_maxWidth:isNaN(parseInt(e))&&i.set(attrKeys.layout_maxWidth,t);break;case attrKeys.layout_maxHeight:isNaN(parseInt(e))&&i.set(attrKeys.layout_maxHeight,t);break;case attrKeys.layout_minWidth:isNaN(parseInt(e))&&i.set(attrKeys.layout_minWidth,t);break;case attrKeys.layout_minHeight:isNaN(parseInt(e))&&i.set(attrKeys.layout_minHeight,t);break;case attrKeys.dimension_ratio:if(isNumber(t))this.dimRatio=parseFloat(t),i.set(attrKeys.dimension_ratio,o.dimRatio);else{if(!0!==isDimensionRatio(t))throw new Error("Invalid dimension ratio specified on view with id: "+o.id);{let e=t.split(":"),r=parseFloat(e[0]),n=parseFloat(e[1]);if(r<=0)throw new Error("Bad ratio specified! LHS can neither be 0 nor less than 0");if(n<=0)throw new Error("Bad ratio specified! RHS can neither be 0 nor less than 0");o.dimRatio=r/n,i.set(attrKeys.dimension_ratio,o.dimRatio)}}}})}if(this.refIds=i,!this.id)throw"Your view must have an id!";if("string"!=typeof this.id)throw"The view id must be a string!";if(0===this.id.trim().length)throw"The view id cannot be an empty string!";customRenderer(t,this);let o=e.getBoundingClientRect();this.width===sizes.WRAP_CONTENT&&(this.width=this.wrapWidth=o.width),this.height===sizes.WRAP_CONTENT&&(this.height=this.wrapHeight=o.height),t.viewMap.set(this.id,this)}function customRenderer(t,e){if("Page"===t.constructor.name&&"View"===e.constructor.name&&"canvas"===e.htmlNode.nodeName.toLowerCase()){if(e.refIds.get(attrKeys.customType)===attrKeys.customTypeLabel)renderTextBox(t,e)}}function renderTextBox(t,e){if("canvas"===e.htmlNode.nodeName.toLowerCase()){if(e.refIds.get(attrKeys.customType)===attrKeys.customTypeLabel){let i=e.refIds.get(attrKeys.layout_width),r=parseNumberAndUnits(i,!0),n=e.refIds.get(attrKeys.mi_text);n||(n=e.htmlNode.textContent,n=n.trim()),n||(n="LABEL");let o=e.refIds.get(attrKeys.mi_singleLine);if(null==o)o=!1;else if("true"===o||"false"===o)o="true"===o;else if(!0!==o&&!1!==o)throw"Invalid type specified for singleLine on view: "+e.id;i=r.number;let s=e.refIds.get(attrKeys.mi_gravity);s||(s=Gravity.LEFT);let a=e.refIds.get(attrKeys.mi_fontName);a||(a="Arial");let l=e.refIds.get(attrKeys.mi_fontSize);l||(l="13px");let u=e.refIds.get(attrKeys.mi_fontStyle);u||(u=FontStyle.REGULAR);let h=e.refIds.get(attrKeys.mi_fontWeight);h||(h=FontStyle.REGULAR),u=h+" "+u;let c=e.refIds.get(attrKeys.mi_border_radius);c||(c="2px");let p=parseNumberAndUnits(l,!0),d=parseNumberAndUnits(c,!0),f=e.refIds.get(attrKeys.mi_fg);f||(f="#000");let y=e.refIds.get(attrKeys.mi_bg);y||(y="white");let g=e.refIds.get(attrKeys.mi_padding);g||(g="4px");let m=e.refIds.get(attrKeys.mi_line_spacing);m||(m=8);let w=new TextBox({width:i,text:n,gravity:s,fontName:a,singleLine:o,fontSize:p.number,sizeUnits:p.units,fontStyle:u,backgroundColor:y,textColor:f,borderRadius:d.number,padding:g,lineSpacing:m},e.htmlNode);t.nodeWrappers.set(e.id,w),e.refIds.set(attrKeys.layout_width,w.width+"px"),e.refIds.set(attrKeys.layout_height,w.height+"px"),e.width=w.width,e.height=w.height}}}function isDimensionRatio(t){if(!isNaN(t))return t+=":1",!0;let e=0;for(let i=0;i<t.length;i++)if(":"===t.substring(i,i+1)&&(e++,e>1))return!1;if(0===e||e>1)return!1;let i=t.split(":");return 2===i.length&&!isNaN(i[0])&&!isNaN(i[1])}function quickScan(t,e){let i=t+"";i=i.replace(".width","#width"),i=i.replace(".height","#height");let r=new Scanner(i,!0,["*","+","#","-"]).scan();if(e&&!0===e)return r;let n=r.indexOf("#");return-1!==n&&(r[n]="."),r}function isHTMLTagName(t){if("string"==typeof t){return"a b u i body head header h1 h2 h3 h4 h5 h6 style title div p span button checkbox radio input label textarea select legend ul ol li link table tbody thead tfoot tr td th option optgroup video meta img hr picture pre script section small strong noscript object canvas caption blockquote article audio time var cite code iframe nav noframes menu br".split(" ").indexOf(t.trim().toLowerCase())>-1}return!1}function getSignedValue(t){if(void 0===t)return"+0.0";if("string"==typeof t){let e=parseInt(t);return isNaN(e)?"+0.0":e>=0?"+"+e:""+e}return"number"==typeof t?t>0?"+"+t:"-"+t:void 0}function Guideline(t,e,i,r){View.call(this,t,e,i,r);let n=i.get(attrKeys.layout_width),o=i.get(attrKeys.layout_height);n!==sizes.WRAP_CONTENT&&this.refIds.set(attrKeys.layout_width,sizes.WRAP_CONTENT),o!==sizes.WRAP_CONTENT&&this.refIds.set(attrKeys.layout_height,sizes.WRAP_CONTENT),addClass(e,GUIDE_CLASS)}function IncludedView(t,e,i,r){View.call(this,t,e,i,r);let n=e.getAttribute(attrKeys.layout);if(!n||"string"!=typeof n)throw"An included layout must be the name of a valid xml file in the `"+PATH_TO_LAYOUTS_FOLDER+"` folder";let o=n.length;".xml"!==n.substring(o-4)&&(n+=".xml");new Parser(t,n,this.id)}function is2DArray(t){if("[object Array]"===Object.prototype.toString.call(t)){for(let e=0;e<t.length;e++)if("[object Array]"!==Object.prototype.toString.call(t[e]))return!1;return!0}return!1}function attributeNotEmpty(t){return!!(t&&t.trim().length>0)}function attributeEmpty(t){return!t||0===t.trim().length}function ScannerOld(t,e,i){this.input=t,this.includeTokensInOutput=e,this.tokens=i}function Scanner(t,e,i){this.input=t,this.includeTokensInOutput=e,this.tokens=i.filter(t=>t&&t.length>0).sort((t,e)=>e.length-t.length)}function StringBuffer(t){this.dataArray=new Array(t)}transformAttr=transformAttr||("-webkit-transform"in document.documentElement.style?"-webkit-transform":"undefined"),transformAttr=transformAttr||("-moz-transform"in document.documentElement.style?"-moz-transform":"undefined"),transformAttr=transformAttr||("-ms-transform"in document.documentElement.style?"-ms-transform":"undefined"),transformAttr=transformAttr||("-o-transform"in document.documentElement.style?"-o-transform":"undefined"),View.prototype.isPopup=function(){let t=this.refIds.get(attrKeys.layout_popup);return void 0!==t&&(!0===t||"true"===t)},View.prototype.isLeftSideMenu=function(){let t=this.refIds.get(attrKeys.layout_menuLeft);return void 0!==t&&(!0===t||"true"===t)},View.prototype.isRightSideMenu=function(){let t=this.refIds.get(attrKeys.layout_menuRight);return void 0!==t&&(!0===t||"true"===t)},View.prototype.isSideMenu=function(){return this.isLeftSideMenu()||this.isRightSideMenu()},View.prototype.makeBgImage=function(){let t=this.refIds,e=t.get(attrKeys.mi_useAutoBg);if(!e||"false"===e)return;let i=t.get(attrKeys.mi_fg),r=t.get(attrKeys.mi_bg),n=t.get(attrKeys.mi_strokeWidth),o=t.get(attrKeys.mi_minSize),s=t.get(attrKeys.mi_textArray),a=t.get(attrKeys.mi_fontName),l=t.get(attrKeys.mi_fontWeight),u=t.get(attrKeys.mi_fontStyle),h=t.get(attrKeys.mi_fontSize),c=t.get(attrKeys.mi_numShapes),p=t.get(attrKeys.mi_shapesDensity),d=t.get(attrKeys.mi_opacity),f=t.get(attrKeys.mi_cacheAfterDraw),y=t.get(attrKeys.mi_opaqueBg),g=t.get(attrKeys.mi_mode),m=t.get(attrKeys.mi_textOnly),w=null;if(u?(w=u,l&&(w+=" "+l)):l&&(w=l),s&&"string"==typeof s)try{s=JSON.parse(s)}catch(t){throw t}f=!0===f||"true"===f,m=!0===m||"true"===m,y=!0===y||"true"===y;let v=this.htmlNode.getBoundingClientRect(),b={width:v.width,height:v.height,fontName:a,fontSize:h,fontStyle:w,fgColor:i,bgColor:r,mode:g,numShapes:c,shapesDensity:p,strokeWidth:n,minSize:o,opacity:d,bgOpacityEnabled:y,textArray:s,textOnly:m,cacheAfterDraw:f};b.width=v.width,b.height=v.height;let A=new MysteryImage(b);A.draw();let _=new Style("#"+this.id,[]);_.addFromOptions({"background-image":"url('"+A.getImage()+"')","background-position":"0% 0%"}),updateOrCreateSelectorInStyleSheet(styleSheet,_),A.cleanup()},View.prototype.getValueAndPriority=function(t){if(void 0===t)return t;if(isNumber(t))return{id:t+"",defaultUsed:!0,priority:AutoLayout.Priority.REQUIRED};let e=t.indexOf("@");if(-1===e)return{id:t,defaultUsed:!0,priority:AutoLayout.Priority.REQUIRED};if(0===e)throw"Bad value for id";return{id:t.substring(0,e),defaultUsed:!1,priority:parseInt(t.substring(e+1))}},View.prototype.layoutSelf=function(t){let e=this.width,i=this.height,r=this.id,n=this.refIds.get(attrKeys.layout_maxWidth),o=this.refIds.get(attrKeys.layout_maxHeight),s=this.refIds.get(attrKeys.layout_minWidth),a=this.refIds.get(attrKeys.layout_minHeight),l=this.refIds.get(attrKeys.layout_constraintStart_toStartOf),u=this.refIds.get(attrKeys.layout_constraintEnd_toEndOf),h=this.refIds.get(attrKeys.layout_constraintTop_toTopOf),c=this.refIds.get(attrKeys.layout_constraintBottom_toBottomOf),p=this.refIds.get(attrKeys.layout_constraintCenterXAlign),d=this.refIds.get(attrKeys.layout_constraintCenterYAlign),f=[],y=this.getValueAndPriority(e);e=y.id;let g=y.priority;this.setWidthConstraints(t,f,this.id,e,g);let m=this.getValueAndPriority(i);i=m.id;let w=m.priority;if(this.setHeightConstraints(t,f,this.id,i,w),n){let t=this.getValueAndPriority(n);n=t.id;let e=t.priority;f.push({view1:r,attr1:"width",relation:"leq",constant:parseFloat(n),multiplier:1,priority:e})}if(s){let t=this.getValueAndPriority(s);s=t.id;let e=t.priority;f.push({view1:r,attr1:"width",relation:"geq",constant:parseFloat(s),multiplier:1,priority:e})}if(o){let t=this.getValueAndPriority(o);o=t.id;let e=t.priority;f.push({view1:r,attr1:"height",relation:"leq",constant:parseFloat(o),multiplier:1,priority:e})}if(a){let t=this.getValueAndPriority(a);a=t.id;let e=t.priority;f.push({view1:r,attr1:"height",relation:"geq",constant:parseFloat(a),multiplier:1,priority:e})}let v=this;if(l){let t=this.getValueAndPriority(l);l=t.id;let e=t.priority;this.setLeftAlignSS(r,v.margins.start,"parent",e,f)}if(h){let t=this.getValueAndPriority(h);h=t.id;let e=t.priority;this.setTopAlignTT(r,v.margins.top,"parent",e,f)}if(u){let t=this.getValueAndPriority(u);u=t.id;let e=t.priority;this.setRightAlignEE(r,v.margins.end,"parent",e,f)}if(c){let t=this.getValueAndPriority(c);c=t.id;let e=t.priority;this.setBottomAlignBB(r,v.margins.bottom,"parent",e,f)}if(p){let t=this.getValueAndPriority(p);p=t.id;let e=t.priority;f.push({view1:r,attr1:"centerX",relation:"equ",view2:null,attr2:"centerX",constant:v.margins.start-v.margins.end,multiplier:1,priority:e})}if(d){let t=this.getValueAndPriority(d);d=t.id;let e=t.priority;f.push({view1:r,attr1:"centerY",relation:"equ",view2:null,attr2:"centerY",constant:v.margins.top-v.margins.bottom,multiplier:1,priority:e})}return f},View.prototype.layoutChildren=function(t){this.width,this.height;let e=[];for(let i=0;i<this.childrenIds.length;i++){let r=this.childrenIds[i],n=t.viewMap.get(r),o=n.refIds.get(attrKeys.layout_constraintStart_toStartOf),s=n.refIds.get(attrKeys.layout_constraintStart_toEndOf),a=n.refIds.get(attrKeys.layout_constraintEnd_toStartOf),l=n.refIds.get(attrKeys.layout_constraintEnd_toEndOf),u=n.refIds.get(attrKeys.layout_constraintTop_toTopOf),h=n.refIds.get(attrKeys.layout_constraintTop_toBottomOf),c=n.refIds.get(attrKeys.layout_constraintBottom_toTopOf),p=n.refIds.get(attrKeys.layout_constraintBottom_toBottomOf),d=n.refIds.get(attrKeys.layout_constraintCenterXAlign),f=n.refIds.get(attrKeys.layout_constraintCenterYAlign),y=n.refIds.get(attrKeys.layout_constraintStart_toCenterX),g=n.refIds.get(attrKeys.layout_constraintEnd_toCenterX),m=n.refIds.get(attrKeys.layout_constraintCenterX_toStart),w=n.refIds.get(attrKeys.layout_constraintCenterX_toEnd),v=n.refIds.get(attrKeys.layout_constraintTop_toCenterY),b=n.refIds.get(attrKeys.layout_constraintCenterY_toTop),A=n.refIds.get(attrKeys.layout_constraintBottom_toCenterY),_=n.refIds.get(attrKeys.layout_constraintCenterY_toBottom),E=n.refIds.get(attrKeys.layout_horizontalBias),x=n.refIds.get(attrKeys.layout_verticalBias);if("Guideline"===n.constructor.name){n.layoutGuide(e);continue}if(E){if(!isNumber(E))throw"Invalid type set for horBias... should be a number between 0 and 1 view.id="+r;if(E=2*parseFloat(E),E<0||E>2)throw"Invalid value set for horBias... should be between 0 and 1 on view.id="+r;0===E&&(E=MIN_BIAS)}else E=1;if(x){if(!isNumber(x))throw"Invalid type set for verBias... should be between 0 and 1 view.id="+r;if(x=2*parseFloat(x),x<0||x>2)throw"Invalid value set for verBias... should be between 0 and 1 on view.id="+r;0===x&&(x=MIN_BIAS)}else x=1;let T=n.refIds.get(attrKeys.layout_maxWidth),S=n.refIds.get(attrKeys.layout_maxHeight),I=n.refIds.get(attrKeys.layout_minWidth),C=n.refIds.get(attrKeys.layout_minHeight),R=n.width,L=n.height;R===sizes.WRAP_CONTENT&&(R=n.wrapWidth),L===sizes.WRAP_CONTENT&&(L=n.wrapHeight);let O=this.getValueAndPriority(R);R=O.id;let P,N,M=O.priority;O.defaultUsed&&(o&&l||o&&a||o&&g||s&&l||s&&a||s&&g||y&&l||y&&a||y&&g)&&(0===parseInt(R)?M=AutoLayout.Priority.DEFAULTLOW:(P=r+"_dummywid_"+ULID.ulid(),o?this.setLeftAlignSS(P,n.margins.start,o,AutoLayout.Priority.REQUIRED,e):s?this.setLeftAlignSE(P,n.margins.start,s,AutoLayout.Priority.REQUIRED,e):y&&this.setLeftAlignCX(P,n.margins.start,y,AutoLayout.Priority.REQUIRED,e),l?this.setRightAlignEE(P,n.margins.end,l,AutoLayout.Priority.REQUIRED,e):a?this.setRightAlignES(P,n.margins.end,a,AutoLayout.Priority.REQUIRED,e):g&&this.setRightAlignCX(P,n.margins.end,g,AutoLayout.Priority.REQUIRED,e),e.push({view1:P,attr1:"width",relation:"equ",view2:null,attr2:AutoLayout.Attribute.NOTANATTRIBUTE,constant:0,multiplier:1,priority:249}),e.push({view1:r,attr1:"centerX",relation:"equ",view2:P,attr2:"centerX",constant:n.margins.horMarginDiff(),multiplier:E,priority:AutoLayout.Priority.REQUIRED}))),this.setWidthConstraints(t,e,r,R,M);let B=this.getValueAndPriority(L);L=B.id;let V=B.priority;if(B.defaultUsed&&(u&&p||u&&c||u&&A||h&&p||h&&c||h&&A||v&&p||v&&c||v&&A)&&(0===parseInt(L)?V=AutoLayout.Priority.DEFAULTLOW:(V=AutoLayout.Priority.REQUIRED,N=r+"_dummyhei_"+ULID.ulid(),u?this.setTopAlignTT(N,n.margins.top,u,AutoLayout.Priority.REQUIRED,e):h?this.setTopAlignTB(N,n.margins.top,h,AutoLayout.Priority.REQUIRED,e):v&&this.setTopAlignCY(N,n.margins.top,v,AutoLayout.Priority.REQUIRED,e),p?this.setBottomAlignBB(N,n.margins.bottom,p,AutoLayout.Priority.REQUIRED,e):c?this.setBottomAlignBT(N,n.margins.bottom,c,AutoLayout.Priority.REQUIRED,e):A&&this.setBottomAlignCY(N,n.margins.bottom,A,AutoLayout.Priority.REQUIRED,e),e.push({view1:N,attr1:"height",relation:"equ",view2:null,attr2:AutoLayout.Attribute.NOTANATTRIBUTE,constant:0,multiplier:1,priority:249}),e.push({view1:r,attr1:"centerY",relation:"equ",view2:N,attr2:"centerY",constant:n.margins.verMarginDiff(),multiplier:x,priority:AutoLayout.Priority.REQUIRED}))),this.setHeightConstraints(t,e,r,L,V),this.setSizeBoundariesConstraints(t,e,r,T,I,S,C),o&&!P){let t=this.getValueAndPriority(o);o=t.id;let i=t.priority;this.setLeftAlignSS(r,n.margins.start,o,i,e)}if(u&&!N){let t=this.getValueAndPriority(u);u=t.id;let i=t.priority;this.setTopAlignTT(r,n.margins.top,u,i,e)}if(l&&!P){let t=this.getValueAndPriority(l);l=t.id;let i=t.priority;this.setRightAlignEE(r,n.margins.end,l,i,e)}if(p&&!N){let t=this.getValueAndPriority(p);p=t.id;let i=t.priority;this.setBottomAlignBB(r,n.margins.bottom,p,i,e)}if(s&&!P){let t=this.getValueAndPriority(s);s=t.id;let i=t.priority;this.setLeftAlignSE(r,n.margins.start,s,i,e)}if(a&&!P){let t=this.getValueAndPriority(a);a=t.id;let i=t.priority;this.setRightAlignES(r,n.margins.end,a,i,e)}if(h&&!N){let t=this.getValueAndPriority(h);h=t.id;let i=t.priority;this.setTopAlignTB(r,n.margins.top,h,i,e)}if(c&&!N){let t=this.getValueAndPriority(c);c=t.id;let i=t.priority;this.setBottomAlignBT(r,n.margins.bottom,c,i,e)}if(d){let t=this.getValueAndPriority(d);d=t.id;let i=t.priority;if(!n.margins.horUnitsSame)throw"`cx` needs margin-start and margin-end to have same units!";e.push({view1:r,attr1:"centerX",relation:"equ",view2:"parent"===d?null:d,attr2:"centerX",constant:n.margins.horMarginDiff(),multiplier:E,priority:i})}if(f){let t=this.getValueAndPriority(f);f=t.id;let i=t.priority;if(!n.margins.verUnitsSame)throw"`cy` needs margin-top and margin-bottom to have same units!";e.push({view1:r,attr1:"centerY",relation:"equ",view2:"parent"===f?null:f,attr2:"centerY",constant:n.margins.verMarginDiff(),multiplier:x,priority:i})}if(y&&!P){let t=this.getValueAndPriority(y);y=t.id;let i=t.priority;this.setLeftAlignCX(r,n.margins.start,y,i,e)}if(g&&!P){let t=this.getValueAndPriority(g);g=t.id;let i=t.priority;this.setRightAlignCX(r,n.margins.end,g,i,e)}if(m&&!P){let t=this.getValueAndPriority(m);m=t.id;let i=t.priority;if(!n.margins.horUnitsSame)throw"`cxs` needs margin-start and margin-end to have same units!";this.setCXAlignLeft(r,n.margins.horMarginDiff(),m,i,e)}if(w&&!P){let t=this.getValueAndPriority(w);w=t.id;let i=t.priority;if(!n.margins.horUnitsSame)throw"`cxe` needs margin-start and margin-end to have same units!";this.setCXAlignRight(r,n.margins.horMarginDiff(),w,i,e)}if(v&&!P){let t=this.getValueAndPriority(v);v=t.id;let i=t.priority;this.setTopAlignCY(r,n.margins.top,v,i,e)}if(A&&!P){let t=this.getValueAndPriority(A);A=t.id;let i=t.priority;this.setBottomAlignCY(r,n.margins.bottom,A,i,e)}if(b&&!P){let t=this.getValueAndPriority(b);b=t.id;let i=t.priority;if(!n.margins.verUnitsSame)throw"`bcy` needs margin-top and margin-bottom to have same units!";this.setCYAlignTop(r,n.margins.verMarginDiff(),b,i,e)}if(_&&!P){let t=this.getValueAndPriority(_);_=t.id;let i=t.priority;if(!n.margins.verUnitsSame)throw"`cyb` needs margin-top and margin-bottom to have same units!";this.setCYAlignBottom(r,n.margins.verMarginDiff(),_,i,e)}}return e},View.prototype.setLeftAlignSS=function(t,e,i,r,n){if("number"==typeof(e="0%"===e?0:e))n.push({view1:t,attr1:"left",relation:"equ",view2:"parent"===i?null:i,attr2:"left",constant:e,multiplier:1,priority:r});else if(isNumber(e))n.push({view1:t,attr1:"left",relation:"equ",view2:"parent"===i?null:i,attr2:"left",constant:parseFloat(e),multiplier:1,priority:r});else if(endsWith(e,"px"))n.push({view1:t,attr1:"left",relation:"equ",view2:"parent"===i?null:i,attr2:"left",constant:parseFloat(e),multiplier:1,priority:r});else{if(!endsWith(e,"%"))throw"margin-left can only be expressed in pixels, in percentage(%) or without units, on id: "+t;let r=parseFloat(e)/100,o=t+"_dummy_"+ULID.ulid();"parent"===i?(n.push({view1:o,attr1:"left",relation:"equ",view2:null,attr2:"left",constant:0,multiplier:1,priority:1e3}),n.push({view1:o,attr1:"width",relation:"equ",view2:null,attr2:"width",constant:1,multiplier:r,priority:1e3}),n.push({view1:t,attr1:"left",relation:"equ",view2:o,attr2:"right",constant:1,multiplier:1,priority:1e3})):(n.push({view1:o,attr1:"left",relation:"equ",view2:i,attr2:"left",constant:0,multiplier:1,priority:1e3}),n.push({view1:o,attr1:"width",relation:"equ",view2:null,attr2:"width",constant:1,multiplier:r,priority:1e3}),n.push({view1:t,attr1:"left",relation:"equ",view2:o,attr2:"right",constant:1,multiplier:1,priority:1e3}))}},View.prototype.setLeftAlignSE=function(t,e,i,r,n){if("number"==typeof(e="0%"===e?0:e))n.push({view1:t,attr1:"left",relation:"equ",view2:"parent"===i?null:i,attr2:"right",constant:e,multiplier:1,priority:r});else if(isNumber(e))n.push({view1:t,attr1:"left",relation:"equ",view2:"parent"===i?null:i,attr2:"right",constant:parseFloat(e),multiplier:1,priority:r});else if(endsWith(e,"px"))n.push({view1:t,attr1:"left",relation:"equ",view2:"parent"===i?null:i,attr2:"right",constant:parseFloat(e),multiplier:1,priority:r});else{if(!endsWith(e,"%"))throw"margin-left can only be expressed in pixels, in percentage(%) or without units, on id: "+t;let r=parseFloat(e)/100,o=t+"_dummy_"+ULID.ulid();"parent"===i?(n.push({view1:o,attr1:"left",relation:"equ",view2:null,attr2:"right",constant:0,multiplier:1,priority:1e3}),n.push({view1:o,attr1:"width",relation:"equ",view2:null,attr2:"width",constant:1,multiplier:r,priority:1e3}),n.push({view1:t,attr1:"left",relation:"equ",view2:o,attr2:"right",constant:1,multiplier:1,priority:1e3})):(n.push({view1:o,attr1:"left",relation:"equ",view2:i,attr2:"right",constant:0,multiplier:1,priority:1e3}),n.push({view1:o,attr1:"width",relation:"equ",view2:null,attr2:"width",constant:1,multiplier:r,priority:1e3}),n.push({view1:t,attr1:"left",relation:"equ",view2:o,attr2:"right",constant:1,multiplier:1,priority:1e3}))}},View.prototype.setRightAlignEE=function(t,e,i,r,n){if("number"==typeof(e="0%"===e?0:e))n.push({view1:t,attr1:"right",relation:"equ",view2:"parent"===i?null:i,attr2:"right",constant:-1*e,multiplier:1,priority:r});else if(isNumber(e))n.push({view1:t,attr1:"right",relation:"equ",view2:"parent"===i?null:i,attr2:"right",constant:-1*parseFloat(e),multiplier:1,priority:r});else if(endsWith(e,"px"))n.push({view1:t,attr1:"right",relation:"equ",view2:"parent"===i?null:i,attr2:"right",constant:-1*parseFloat(e),multiplier:1,priority:r});else{if(!endsWith(e,"%"))throw"margin-right can only be expressed in pixels, in percentage(%) or without units, on id: "+t;let r=parseFloat(e)/100,o=t+"_dummy_"+ULID.ulid();"parent"===i?(n.push({view1:o,attr1:"right",relation:"equ",view2:null,attr2:"right",constant:0,multiplier:1,priority:1e3}),n.push({view1:o,attr1:"width",relation:"equ",view2:null,attr2:"width",constant:1,multiplier:r,priority:1e3}),n.push({view1:t,attr1:"right",relation:"equ",view2:o,attr2:"left",constant:1,multiplier:1,priority:1e3})):(n.push({view1:o,attr1:"right",relation:"equ",view2:i,attr2:"right",constant:0,multiplier:1,priority:1e3}),n.push({view1:o,attr1:"width",relation:"equ",view2:null,attr2:"width",constant:1,multiplier:r,priority:1e3}),n.push({view1:t,attr1:"right",relation:"equ",view2:o,attr2:"left",constant:1,multiplier:1,priority:1e3}))}},View.prototype.setRightAlignES=function(t,e,i,r,n){if("number"==typeof(e="0%"===e?0:e))n.push({view1:t,attr1:"right",relation:"equ",view2:"parent"===i?null:i,attr2:"left",constant:-1*e,multiplier:1,priority:r});else if(isNumber(e))n.push({view1:t,attr1:"right",relation:"equ",view2:"parent"===i?null:i,attr2:"left",constant:-1*parseFloat(e),multiplier:1,priority:r});else if(endsWith(e,"px"))n.push({view1:t,attr1:"right",relation:"equ",view2:"parent"===i?null:i,attr2:"left",constant:-1*parseFloat(e),multiplier:1,priority:r});else{if(!endsWith(e,"%"))throw"margin-right can only be expressed in pixels, in percentage(%) or without units, on id: "+t;let r=parseFloat(e)/100,o=t+"_dummy_"+ULID.ulid();"parent"===i?(n.push({view1:o,attr1:"right",relation:"equ",view2:null,attr2:"left",constant:0,multiplier:1,priority:1e3}),n.push({view1:o,attr1:"width",relation:"equ",view2:null,attr2:"width",constant:1,multiplier:r,priority:1e3}),n.push({view1:t,attr1:"right",relation:"equ",view2:o,attr2:"left",constant:1,multiplier:1,priority:1e3})):(n.push({view1:o,attr1:"right",relation:"equ",view2:i,attr2:"left",constant:0,multiplier:1,priority:1e3}),n.push({view1:o,attr1:"width",relation:"equ",view2:null,attr2:"width",constant:1,multiplier:r,priority:1e3}),n.push({view1:t,attr1:"right",relation:"equ",view2:o,attr2:"left",constant:1,multiplier:1,priority:1e3}))}},View.prototype.setLeftAlignCX=function(t,e,i,r,n){if("number"==typeof(e="0%"===e?0:e))n.push({view1:t,attr1:AutoLayout.Attribute.LEFT,relation:"equ",view2:"parent"===i?null:i,attr2:AutoLayout.Attribute.CENTERX,constant:e,multiplier:1,priority:r});else if(isNumber(e))n.push({view1:t,attr1:AutoLayout.Attribute.LEFT,relation:"equ",view2:"parent"===i?null:i,attr2:AutoLayout.Attribute.CENTERX,constant:parseFloat(e),multiplier:1,priority:r});else if(endsWith(e,"px"))n.push({view1:t,attr1:AutoLayout.Attribute.LEFT,relation:"equ",view2:"parent"===i?null:i,attr2:AutoLayout.Attribute.CENTERX,constant:parseFloat(e),multiplier:1,priority:r});else{if(!endsWith(e,"%"))throw"margin-left can only be expressed in pixels, in percentage(%) or without units, on id: "+t;let r=parseFloat(e)/100,o=t+"_dummy_"+ULID.ulid();"parent"===i?(n.push({view1:o,attr1:AutoLayout.Attribute.LEFT,relation:"equ",view2:null,attr2:AutoLayout.Attribute.CENTERX,constant:0,multiplier:1,priority:1e3}),n.push({view1:o,attr1:"width",relation:"equ",view2:null,attr2:"width",constant:1,multiplier:r,priority:1e3}),n.push({view1:t,attr1:"left",relation:"equ",view2:o,attr2:"right",constant:1,multiplier:1,priority:1e3})):(n.push({view1:o,attr1:AutoLayout.Attribute.LEFT,relation:"equ",view2:i,attr2:AutoLayout.Attribute.CENTERX,constant:0,multiplier:1,priority:1e3}),n.push({view1:o,attr1:"width",relation:"equ",view2:null,attr2:"width",constant:1,multiplier:r,priority:1e3}),n.push({view1:t,attr1:"left",relation:"equ",view2:o,attr2:"right",constant:1,multiplier:1,priority:1e3}))}},View.prototype.setCXAlignLeft=function(t,e,i,r,n){if("number"==typeof(e="0%"===e?0:e))n.push({view1:t,attr1:AutoLayout.Attribute.CENTERX,relation:"equ",view2:"parent"===i?null:i,attr2:AutoLayout.Attribute.LEFT,constant:e,multiplier:1,priority:r});else if(isNumber(e))n.push({view1:t,attr1:AutoLayout.Attribute.CENTERX,relation:"equ",view2:"parent"===i?null:i,attr2:AutoLayout.Attribute.LEFT,constant:parseFloat(e),multiplier:1,priority:r});else if(endsWith(e,"px"))n.push({view1:t,attr1:AutoLayout.Attribute.CENTERX,relation:"equ",view2:"parent"===i?null:i,attr2:AutoLayout.Attribute.LEFT,constant:parseFloat(e),multiplier:1,priority:r});else{if(!endsWith(e,"%"))throw"margin-left can only be expressed in pixels, in percentage(%) or without units, on id: "+t;let r=parseFloat(e)/100,o=t+"_dummy_"+ULID.ulid();"parent"===i?(n.push({view1:o,attr1:AutoLayout.Attribute.LEFT,relation:"equ",view2:null,attr2:AutoLayout.Attribute.LEFT,constant:0,multiplier:1,priority:1e3}),n.push({view1:o,attr1:"width",relation:"equ",view2:null,attr2:"width",constant:1,multiplier:r,priority:1e3}),n.push({view1:t,attr1:AutoLayout.Attribute.CENTERX,relation:"equ",view2:o,attr2:AutoLayout.Attribute.RIGHT,constant:1,multiplier:1,priority:1e3})):(n.push({view1:o,attr1:AutoLayout.Attribute.LEFT,relation:"equ",view2:i,attr2:AutoLayout.Attribute.LEFT,constant:0,multiplier:1,priority:1e3}),n.push({view1:o,attr1:"width",relation:"equ",view2:null,attr2:"width",constant:1,multiplier:r,priority:1e3}),n.push({view1:t,attr1:AutoLayout.Attribute.CENTERX,relation:"equ",view2:o,attr2:AutoLayout.Attribute.RIGHT,constant:1,multiplier:1,priority:1e3}))}},View.prototype.setCXAlignRight=function(t,e,i,r,n){if("number"==typeof(e="0%"===e?0:e))n.push({view1:t,attr1:AutoLayout.Attribute.CENTERX,relation:"equ",view2:"parent"===i?null:i,attr2:AutoLayout.Attribute.RIGHT,constant:e,multiplier:1,priority:r});else if(isNumber(e))n.push({view1:t,attr1:AutoLayout.Attribute.CENTERX,relation:"equ",view2:"parent"===i?null:i,attr2:AutoLayout.Attribute.RIGHT,constant:parseFloat(e),multiplier:1,priority:r});else if(endsWith(e,"px"))n.push({view1:t,attr1:AutoLayout.Attribute.CENTERX,relation:"equ",view2:"parent"===i?null:i,attr2:AutoLayout.Attribute.RIGHT,constant:parseFloat(e),multiplier:1,priority:r});else{if(!endsWith(e,"%"))throw"margins can only be expressed in pixels, in percentage(%) or without units, on id: "+t;let r=parseFloat(e)/100,o=t+"_dummy_"+ULID.ulid();"parent"===i?(n.push({view1:o,attr1:AutoLayout.Attribute.LEFT,relation:"equ",view2:null,attr2:AutoLayout.Attribute.RIGHT,constant:0,multiplier:1,priority:1e3}),n.push({view1:o,attr1:"width",relation:"equ",view2:null,attr2:"width",constant:1,multiplier:r,priority:1e3}),n.push({view1:t,attr1:AutoLayout.Attribute.CENTERX,relation:"equ",view2:o,attr2:AutoLayout.Attribute.RIGHT,constant:1,multiplier:1,priority:1e3})):(n.push({view1:o,attr1:AutoLayout.Attribute.LEFT,relation:"equ",view2:i,attr2:AutoLayout.Attribute.RIGHT,constant:1,multiplier:1,priority:1e3}),n.push({view1:o,attr1:"width",relation:"equ",view2:null,attr2:"width",constant:1,multiplier:r,priority:1e3}),n.push({view1:t,attr1:AutoLayout.Attribute.CENTERX,relation:"equ",view2:o,attr2:AutoLayout.Attribute.RIGHT,constant:1,multiplier:1,priority:1e3}))}},View.prototype.setRightAlignCX=function(t,e,i,r,n){if("number"==typeof(e="0%"===e?0:e))n.push({view1:t,attr1:AutoLayout.Attribute.RIGHT,relation:"equ",view2:"parent"===i?null:i,attr2:AutoLayout.Attribute.CENTERX,constant:-e,multiplier:1,priority:r});else if(isNumber(e))n.push({view1:t,attr1:AutoLayout.Attribute.RIGHT,relation:"equ",view2:"parent"===i?null:i,attr2:AutoLayout.Attribute.CENTERX,constant:-parseFloat(e),multiplier:1,priority:r});else if(endsWith(e,"px"))n.push({view1:t,attr1:AutoLayout.Attribute.RIGHT,relation:"equ",view2:"parent"===i?null:i,attr2:AutoLayout.Attribute.CENTERX,constant:-parseFloat(e),multiplier:1,priority:r});else{if(!endsWith(e,"%"))throw"margin-left can only be expressed in pixels, in percentage(%) or without units, on id: "+t;let r=parseFloat(e)/100,o=t+"_dummy_"+ULID.ulid();"parent"===i?(n.push({view1:o,attr1:AutoLayout.Attribute.RIGHT,relation:"equ",view2:null,attr2:AutoLayout.Attribute.CENTERX,constant:0,multiplier:1,priority:1e3}),n.push({view1:o,attr1:"width",relation:"equ",view2:null,attr2:"width",constant:1,multiplier:r,priority:1e3}),n.push({view1:t,attr1:"left",relation:"equ",view2:o,attr2:"left",constant:1,multiplier:1,priority:1e3})):(n.push({view1:o,attr1:AutoLayout.Attribute.RIGHT,relation:"equ",view2:i,attr2:AutoLayout.Attribute.CENTERX,constant:0,multiplier:1,priority:1e3}),n.push({view1:o,attr1:"width",relation:"equ",view2:null,attr2:"width",constant:1,multiplier:r,priority:1e3}),n.push({view1:t,attr1:"left",relation:"equ",view2:o,attr2:"left",constant:1,multiplier:1,priority:1e3}))}},View.prototype.setTopAlignCY=function(t,e,i,r,n){if("number"==typeof(e="0%"===e?0:e))n.push({view1:t,attr1:AutoLayout.Attribute.TOP,relation:"equ",view2:"parent"===i?null:i,attr2:AutoLayout.Attribute.CENTERY,constant:e,multiplier:1,priority:r});else if(isNumber(e))n.push({view1:t,attr1:AutoLayout.Attribute.TOP,relation:"equ",view2:"parent"===i?null:i,attr2:AutoLayout.Attribute.CENTERY,constant:parseFloat(e),multiplier:1,priority:r});else if(endsWith(e,"px"))n.push({view1:t,attr1:AutoLayout.Attribute.TOP,relation:"equ",view2:"parent"===i?null:i,attr2:AutoLayout.Attribute.CENTERY,constant:parseFloat(e),multiplier:1,priority:r});else{if(!endsWith(e,"%"))throw"margin-left can only be expressed in pixels, in percentage(%) or without units, on id: "+t;let r=parseFloat(e)/100,o=t+"_dummy_"+ULID.ulid();"parent"===i?(n.push({view1:o,attr1:AutoLayout.Attribute.TOP,relation:"equ",view2:null,attr2:AutoLayout.Attribute.CENTERY,constant:0,multiplier:1,priority:1e3}),n.push({view1:o,attr1:"height",relation:"equ",view2:null,attr2:"height",constant:1,multiplier:r,priority:1e3}),n.push({view1:t,attr1:"top",relation:"equ",view2:o,attr2:"bottom",constant:1,multiplier:1,priority:1e3})):(n.push({view1:o,attr1:AutoLayout.Attribute.TOP,relation:"equ",view2:i,attr2:AutoLayout.Attribute.CENTERY,constant:0,multiplier:1,priority:1e3}),n.push({view1:o,attr1:"height",relation:"equ",view2:null,attr2:"width",constant:1,multiplier:r,priority:1e3}),n.push({view1:t,attr1:"top",relation:"equ",view2:o,attr2:"bottom",constant:1,multiplier:1,priority:1e3}))}},View.prototype.setCYAlignTop=function(t,e,i,r,n){if("number"==typeof(e="0%"===e?0:e))n.push({view1:t,attr1:AutoLayout.Attribute.CENTERY,relation:"equ",view2:"parent"===i?null:i,attr2:AutoLayout.Attribute.TOP,constant:e,multiplier:1,priority:r});else if(isNumber(e))n.push({view1:t,attr1:AutoLayout.Attribute.CENTERY,relation:"equ",view2:"parent"===i?null:i,attr2:AutoLayout.Attribute.TOP,constant:parseFloat(e),multiplier:1,priority:r});else if(endsWith(e,"px"))n.push({view1:t,attr1:AutoLayout.Attribute.CENTERY,relation:"equ",view2:"parent"===i?null:i,attr2:AutoLayout.Attribute.TOP,constant:parseFloat(e),multiplier:1,priority:r});else{if(!endsWith(e,"%"))throw"margin-left can only be expressed in pixels, in percentage(%) or without units, on id: "+t;let r=parseFloat(e)/100,o=t+"_dummy_"+ULID.ulid();"parent"===i?(n.push({view1:o,attr1:AutoLayout.Attribute.TOP,relation:"equ",view2:null,attr2:AutoLayout.Attribute.TOP,constant:0,multiplier:1,priority:1e3}),n.push({view1:o,attr1:"height",relation:"equ",view2:null,attr2:"width",constant:1,multiplier:r,priority:1e3}),n.push({view1:t,attr1:AutoLayout.Attribute.CENTERY,relation:"equ",view2:o,attr2:AutoLayout.Attribute.BOTTOM,constant:1,multiplier:1,priority:1e3})):(n.push({view1:o,attr1:AutoLayout.Attribute.TOP,relation:"equ",view2:i,attr2:AutoLayout.Attribute.TOP,constant:0,multiplier:1,priority:1e3}),n.push({view1:o,attr1:"height",relation:"equ",view2:null,attr2:"width",constant:1,multiplier:r,priority:1e3}),n.push({view1:t,attr1:AutoLayout.Attribute.CENTERY,relation:"equ",view2:o,attr2:AutoLayout.Attribute.BOTTOM,constant:1,multiplier:1,priority:1e3}))}},View.prototype.setCYAlignBottom=function(t,e,i,r,n){if("number"==typeof(e="0%"===e?0:e))n.push({view1:t,attr1:AutoLayout.Attribute.CENTERY,relation:"equ",view2:"parent"===i?null:i,attr2:AutoLayout.Attribute.BOTTOM,constant:e,multiplier:1,priority:r});else if(isNumber(e))n.push({view1:t,attr1:AutoLayout.Attribute.CENTERY,relation:"equ",view2:"parent"===i?null:i,attr2:AutoLayout.Attribute.BOTTOM,constant:parseFloat(e),multiplier:1,priority:r});else if(endsWith(e,"px"))n.push({view1:t,attr1:AutoLayout.Attribute.CENTERY,relation:"equ",view2:"parent"===i?null:i,attr2:AutoLayout.Attribute.BOTTOM,constant:parseFloat(e),multiplier:1,priority:r});else{if(!endsWith(e,"%"))throw"margins can only be expressed in pixels, in percentage(%) or without units, on id: "+t;let r=parseFloat(e)/100,o=t+"_dummy_"+ULID.ulid();"parent"===i?(n.push({view1:o,attr1:AutoLayout.Attribute.TOP,relation:"equ",view2:null,attr2:AutoLayout.Attribute.BOTTOM,constant:0,multiplier:1,priority:1e3}),n.push({view1:o,attr1:"height",relation:"equ",view2:null,attr2:"width",constant:1,multiplier:r,priority:1e3}),n.push({view1:t,attr1:AutoLayout.Attribute.CENTERY,relation:"equ",view2:o,attr2:AutoLayout.Attribute.BOTTOM,constant:1,multiplier:1,priority:1e3})):(n.push({view1:o,attr1:AutoLayout.Attribute.TOP,relation:"equ",view2:i,attr2:AutoLayout.Attribute.BOTTOM,constant:1,multiplier:1,priority:1e3}),n.push({view1:o,attr1:"height",relation:"equ",view2:null,attr2:"width",constant:1,multiplier:r,priority:1e3}),n.push({view1:t,attr1:AutoLayout.Attribute.CENTERY,relation:"equ",view2:o,attr2:AutoLayout.Attribute.BOTTOM,constant:1,multiplier:1,priority:1e3}))}},View.prototype.setBottomAlignCY=function(t,e,i,r,n){if("number"==typeof(e="0%"===e?0:e))n.push({view1:t,attr1:AutoLayout.Attribute.BOTTOM,relation:"equ",view2:"parent"===i?null:i,attr2:AutoLayout.Attribute.CENTERY,constant:-e,multiplier:1,priority:r});else if(isNumber(e))n.push({view1:t,attr1:AutoLayout.Attribute.BOTTOM,relation:"equ",view2:"parent"===i?null:i,attr2:AutoLayout.Attribute.CENTERY,constant:-parseFloat(e),multiplier:1,priority:r});else if(endsWith(e,"px"))n.push({view1:t,attr1:AutoLayout.Attribute.BOTTOM,relation:"equ",view2:"parent"===i?null:i,attr2:AutoLayout.Attribute.CENTERY,constant:-parseFloat(e),multiplier:1,priority:r});else{if(!endsWith(e,"%"))throw"margin-left can only be expressed in pixels, in percentage(%) or without units, on id: "+t;let r=parseFloat(e)/100,o=t+"_dummy_"+ULID.ulid();"parent"===i?(n.push({view1:o,attr1:AutoLayout.Attribute.BOTTOM,relation:"equ",view2:null,attr2:AutoLayout.Attribute.CENTERY,constant:0,multiplier:1,priority:1e3}),n.push({view1:o,attr1:"height",relation:"equ",view2:null,attr2:"width",constant:1,multiplier:r,priority:1e3}),n.push({view1:t,attr1:"top",relation:"equ",view2:o,attr2:"top",constant:1,multiplier:1,priority:1e3})):(n.push({view1:o,attr1:AutoLayout.Attribute.BOTTOM,relation:"equ",view2:i,attr2:AutoLayout.Attribute.CENTERY,constant:0,multiplier:1,priority:1e3}),n.push({view1:o,attr1:"height",relation:"equ",view2:null,attr2:"width",constant:1,multiplier:r,priority:1e3}),n.push({view1:t,attr1:"top",relation:"equ",view2:o,attr2:"top",constant:1,multiplier:1,priority:1e3}))}},View.prototype.setTopAlignTT=function(t,e,i,r,n){if("number"==typeof(e="0%"===e?0:e))n.push({view1:t,attr1:"top",relation:"equ",view2:"parent"===i?null:i,attr2:"top",constant:e,multiplier:1,priority:r});else if(isNumber(e))n.push({view1:t,attr1:"top",relation:"equ",view2:"parent"===i?null:i,attr2:"top",constant:parseFloat(e),multiplier:1,priority:r});else if(endsWith(e,"px"))n.push({view1:t,attr1:"top",relation:"equ",view2:"parent"===i?null:i,attr2:"top",constant:parseFloat(e),multiplier:1,priority:r});else{if(!endsWith(e,"%"))throw"margin-top can only be expressed in pixels, in percentage(%) or without units, on id: "+t;let r=parseFloat(e)/100;if(!r)throw"Invalid expression found for margin-top on id: "+t;let o=t+"_dummy_"+ULID.ulid();"parent"===i?(n.push({view1:o,attr1:"top",relation:"equ",view2:null,attr2:"top",constant:0,multiplier:1,priority:1e3}),n.push({view1:o,attr1:"height",relation:"equ",view2:null,attr2:"width",constant:1,multiplier:r,priority:1e3}),n.push({view1:t,attr1:"top",relation:"equ",view2:o,attr2:"bottom",constant:1,multiplier:1,priority:1e3})):(n.push({view1:o,attr1:"top",relation:"equ",view2:i,attr2:"top",constant:0,multiplier:1,priority:1e3}),n.push({view1:o,attr1:"height",relation:"equ",view2:null,attr2:"width",constant:1,multiplier:r,priority:1e3}),n.push({view1:t,attr1:"top",relation:"equ",view2:o,attr2:"bottom",constant:1,multiplier:1,priority:1e3}))}},View.prototype.setTopAlignTB=function(t,e,i,r,n){if("number"==typeof(e="0%"===e?0:e))n.push({view1:t,attr1:"top",relation:"equ",view2:"parent"===i?null:i,attr2:"bottom",constant:e,multiplier:1,priority:r});else if(isNumber(e))n.push({view1:t,attr1:"top",relation:"equ",view2:"parent"===i?null:i,attr2:"bottom",constant:parseFloat(e),multiplier:1,priority:r});else if(endsWith(e,"px"))n.push({view1:t,attr1:"top",relation:"equ",view2:"parent"===i?null:i,attr2:"bottom",constant:parseFloat(e),multiplier:1,priority:r});else{if(!endsWith(e,"%"))throw"margin-top can only be expressed in pixels, in percentage(%) or without units, on id: "+t;let r=parseFloat(e)/100;if(!r)throw"Invalid expression found for margin-top on id: "+t;let o=t+"_dummy_"+ULID.ulid();"parent"===i?(n.push({view1:o,attr1:"top",relation:"equ",view2:null,attr2:"bottom",constant:0,multiplier:1,priority:1e3}),n.push({view1:o,attr1:"height",relation:"equ",view2:null,attr2:"width",constant:1,multiplier:r,priority:1e3}),n.push({view1:t,attr1:"top",relation:"equ",view2:o,attr2:"bottom",constant:1,multiplier:1,priority:1e3})):(n.push({view1:o,attr1:"top",relation:"equ",view2:i,attr2:"bottom",constant:0,multiplier:1,priority:1e3}),n.push({view1:o,attr1:"height",relation:"equ",view2:null,attr2:"width",constant:1,multiplier:r,priority:1e3}),n.push({view1:t,attr1:"top",relation:"equ",view2:o,attr2:"bottom",constant:1,multiplier:1,priority:1e3}))}},View.prototype.setBottomAlignBB=function(t,e,i,r,n){if("number"==typeof e)n.push({view1:t,attr1:"bottom",relation:"equ",view2:"parent"===i?null:i,attr2:"bottom",constant:-1*e,multiplier:1,priority:r});else if(isNumber(e))n.push({view1:t,attr1:"bottom",relation:"equ",view2:"parent"===i?null:i,attr2:"bottom",constant:-1*parseFloat(e),multiplier:1,priority:r});else if(endsWith(e,"px"))n.push({view1:t,attr1:"bottom",relation:"equ",view2:"parent"===i?null:i,attr2:"bottom",constant:-1*parseFloat(e),multiplier:1,priority:r});else{if(!endsWith(e,"%"))throw"margin-bottom can only be expressed in pixels, in percentage(%) or without units, on id: "+t;let r=parseFloat(e)/100,o=t+"_dummy_"+ULID.ulid();"parent"===i?(n.push({view1:o,attr1:"bottom",relation:"equ",view2:null,attr2:"bottom",constant:0,multiplier:1,priority:1e3}),n.push({view1:o,attr1:"height",relation:"equ",view2:null,attr2:"width",constant:1,multiplier:r,priority:1e3}),n.push({view1:t,attr1:"bottom",relation:"equ",view2:o,attr2:"top",constant:1,multiplier:1,priority:1e3})):(n.push({view1:o,attr1:"bottom",relation:"equ",view2:i,attr2:"bottom",constant:0,multiplier:1,priority:1e3}),n.push({view1:o,attr1:"height",relation:"equ",view2:null,attr2:"width",constant:1,multiplier:r,priority:1e3}),n.push({view1:t,attr1:"bottom",relation:"equ",view2:o,attr2:"top",constant:1,multiplier:1,priority:1e3}))}},View.prototype.setBottomAlignBT=function(t,e,i,r,n){if("number"==typeof(e="0%"===e?0:e))n.push({view1:t,attr1:"bottom",relation:"equ",view2:"parent"===i?null:i,attr2:"top",constant:-1*e,multiplier:1,priority:r});else if(isNumber(e))n.push({view1:t,attr1:"bottom",relation:"equ",view2:"parent"===i?null:i,attr2:"top",constant:-1*parseFloat(e),multiplier:1,priority:r});else if(endsWith(e,"px"))n.push({view1:t,attr1:"bottom",relation:"equ",view2:"parent"===i?null:i,attr2:"top",constant:-1*parseFloat(e),multiplier:1,priority:r});else{if(!endsWith(e,"%"))throw"margin-bottom can only be expressed in pixels, in percentage(%) or without units, on id: "+t;let r=parseFloat(e)/100,o=t+"_dummy_"+ULID.ulid();"parent"===i?(n.push({view1:o,attr1:"bottom",relation:"equ",view2:null,attr2:"top",constant:0,multiplier:1,priority:1e3}),n.push({view1:o,attr1:"height",relation:"equ",view2:null,attr2:"width",constant:1,multiplier:r,priority:1e3}),n.push({view1:t,attr1:"bottom",relation:"equ",view2:o,attr2:"top",constant:1,multiplier:1,priority:1e3})):(n.push({view1:o,attr1:"bottom",relation:"equ",view2:i,attr2:"top",constant:0,multiplier:1,priority:1e3}),n.push({view1:o,attr1:"height",relation:"equ",view2:null,attr2:"width",constant:1,multiplier:r,priority:1e3}),n.push({view1:t,attr1:"bottom",relation:"equ",view2:o,attr2:"top",constant:1,multiplier:1,priority:1e3}))}},View.prototype.setSizeBoundariesConstraints=function(t,e,i,r,n,o,s){if(r){let t=this.getValueAndPriority(r);r=t.id;let n=t.priority,o=-1,s="";if(isNumber(r))e.push({view1:i,attr1:"width",relation:"leq",view2:null,attr2:AutoLayout.Attribute.NOTANATTRIBUTE,constant:parseFloat(r),multiplier:1,priority:n});else if("parent"===r||-1!==this.childrenIds.indexOf(r))e.push({view1:i,attr1:"width",relation:"leq",view2:"parent"===r?null:r,attr2:"width",constant:0,multiplier:1,priority:n});else if(-1!==(o=r.indexOf("."))&&-1!==this.childrenIds.indexOf(s=r.substring(0,o)))"width"===r.substring(o+1)?e.push({view1:i,attr1:"width",relation:"leq",view2:"parent"===s?null:s,attr2:"width",constant:0,multiplier:1,priority:n}):"height"===r.substring(o+1)&&e.push({view1:i,attr1:"width",relation:"leq",view2:"parent"===s?null:s,attr2:"height",constant:0,multiplier:1,priority:n});else{let t=parseNumberAndUnitsNoValidation(r,!0);if(!t.number)throw"Bad value specified for the max-width units on view.id="+i+", value="+r;if("px"===t.units)e.push({view1:i,attr1:"width",relation:"leq",constant:parseFloat(t.number),view2:null,attr2:AutoLayout.Attribute.NOTANATTRIBUTE,multiplier:1,priority:n});else if("%"===t.units)e.push({view1:i,attr1:"width",relation:"leq",view2:null,attr2:"width",constant:0,multiplier:parseFloat(t.number)/100,priority:n});else{if("em"!==t.units)throw"Invalid values specified for the max-width units on view.id="+i;e.push({view1:i,attr1:"width",relation:"leq",view2:null,attr2:"width",constant:0,multiplier:parseFloat(t.number),priority:n})}}}if(n){let t=this.getValueAndPriority(n);n=t.id;let r=t.priority,o=-1,s="";if(isNumber(n))e.push({view1:i,attr1:"width",relation:"geq",view2:null,attr2:AutoLayout.Attribute.NOTANATTRIBUTE,constant:parseFloat(n),multiplier:1,priority:r});else if("parent"===n||-1!==this.childrenIds.indexOf(n))e.push({view1:i,attr1:"width",relation:"geq",view2:"parent"===n?null:n,attr2:"width",constant:0,multiplier:1,priority:r});else if(-1!==(o=n.indexOf("."))&&-1!==this.childrenIds.indexOf(s=n.substring(0,o)))"width"===n.substring(o+1)?e.push({view1:i,attr1:"width",relation:"geq",view2:"parent"===s?null:s,attr2:"width",constant:0,multiplier:1,priority:r}):"height"===n.substring(o+1)&&e.push({view1:i,attr1:"width",relation:"geq",view2:"parent"===s?null:s,attr2:"height",constant:0,multiplier:1,priority:r});else{let t=parseNumberAndUnitsNoValidation(n,!0);if(!t.number)throw"Bad value specified for the min-width units on view.id="+i+", value="+n;if("px"===t.units)e.push({view1:i,attr1:"width",relation:"geq",view2:null,attr2:AutoLayout.Attribute.NOTANATTRIBUTE,constant:parseFloat(t.number),multiplier:1,priority:r});else if("%"===t.units)e.push({view1:i,attr1:"width",relation:"geq",view2:null,attr2:"width",constant:0,multiplier:parseFloat(t.number)/100,priority:r});else{if("em"!==t.units)throw"Invalid values specified for the min-width units on view.id="+i;e.push({view1:i,attr1:"width",relation:"geq",view2:null,attr2:"width",constant:0,multiplier:parseFloat(t.number),priority:r})}}}if(o){let t=this.getValueAndPriority(o);o=t.id;let r=t.priority,n=-1,s="";if(isNumber(o))e.push({view1:i,attr1:"height",relation:"leq",view2:null,attr2:AutoLayout.Attribute.NOTANATTRIBUTE,constant:parseFloat(o),multiplier:1,priority:r});else if("parent"===o||-1!==this.childrenIds.indexOf(o))e.push({view1:i,attr1:"height",relation:"leq",view2:"parent"===o?null:o,attr2:"height",constant:0,multiplier:1,priority:r});else if(-1!==(n=o.indexOf("."))&&-1!==this.childrenIds.indexOf(s=o.substring(0,n)))"width"===o.substring(n+1)?e.push({view1:i,attr1:"height",relation:"leq",view2:"parent"===s?null:s,attr2:"width",constant:0,multiplier:1,priority:r}):"height"===o.substring(n+1)&&e.push({view1:i,attr1:"height",relation:"leq",view2:"parent"===s?null:s,attr2:"height",constant:0,multiplier:1,priority:r});else{let t=parseNumberAndUnitsNoValidation(o,!0);if(!t.number)throw"Bad value specified for the max-height units on view.id="+i+", value="+o;if("px"===t.units)e.push({view1:i,attr1:"height",relation:"leq",view2:null,attr2:AutoLayout.Attribute.NOTANATTRIBUTE,constant:parseFloat(t.number),multiplier:1,priority:r});else if("%"===t.units)e.push({view1:i,attr1:"height",relation:"leq",view2:null,attr2:"height",constant:0,multiplier:parseFloat(t.number)/100,priority:r});else{if("em"!==t.units)throw"Invalid values specified for the max-height units on view.id="+i;e.push({view1:i,attr1:"height",relation:"leq",view2:null,attr2:"height",constant:0,multiplier:parseFloat(t.number),priority:r})}}}if(s){let t=this.getValueAndPriority(s);s=t.id;let r=t.priority,n=-1,a="";if(isNumber(s))e.push({view1:i,attr1:"height",relation:"geq",view2:null,attr2:AutoLayout.Attribute.NOTANATTRIBUTE,constant:parseFloat(s),multiplier:1,priority:r});else if("parent"===s||-1!==this.childrenIds.indexOf(o))e.push({view1:i,attr1:"height",relation:"geq",view2:"parent"===s?null:s,attr2:"height",constant:0,multiplier:1,priority:r});else if(-1!==(n=s.indexOf("."))&&-1!==this.childrenIds.indexOf(a=s.substring(0,n)))"width"===s.substring(n+1)?e.push({view1:i,attr1:"height",relation:"geq",view2:"parent"===a?null:a,attr2:"width",constant:0,multiplier:1,priority:r}):"height"===s.substring(n+1)&&e.push({view1:i,attr1:"height",relation:"geq",view2:"parent"===a?null:a,attr2:"height",constant:0,multiplier:1,priority:r});else{let t=parseNumberAndUnitsNoValidation(s,!0);if(!t.number)throw"Bad value specified for the min-height units on view.id="+i+", value="+s;if("px"===t.units)e.push({view1:i,attr1:"height",relation:"geq",view2:null,attr2:AutoLayout.Attribute.NOTANATTRIBUTE,constant:parseFloat(t.number),multiplier:1,priority:r});else if("%"===t.units)e.push({view1:i,attr1:"height",relation:"geq",view2:null,attr2:"height",constant:0,multiplier:parseFloat(t.number)/100,priority:r});else{if("em"!==t.units)throw"Invalid values specified for the min-height units on view.id="+i;e.push({view1:i,attr1:"height",relation:"geq",view2:null,attr2:"height",constant:0,multiplier:parseFloat(t.number),priority:r})}}}},View.prototype.setWidthConstraints=function(t,e,i,r,n){let o,s,a=r.indexOf("*"),l=r.indexOf("+"),u=r.indexOf("-"),h=r.indexOf(".");if(-1!==u&&r.lastIndexOf("-")!==u)throw"troublesome id here: conflicts with - "+r;if(isNumber(r)){if(0===(r="string"==typeof r?parseFloat(r):r)){let r=t.viewMap.get(i);if(-1!==r.dimRatio)return void e.push({view1:i,attr1:"width",relation:"equ",view2:i,attr2:AutoLayout.Attribute.HEIGHT,constant:0,multiplier:r.dimRatio,priority:n})}e.push({view1:i,attr1:"width",relation:"equ",view2:null,attr2:AutoLayout.Attribute.NOTANATTRIBUTE,constant:r,multiplier:1,priority:n})}else if((o=parseNumberAndUnitsNoValidation(r,!0)).number){let s=parseFloat(o.number);if(0===s){let r=t.viewMap.get(i);if(-1!==r.dimRatio)return void e.push({view1:i,attr1:"width",relation:"equ",view2:i,attr2:AutoLayout.Attribute.HEIGHT,constant:0,multiplier:r.dimRatio,priority:n})}switch(o.units){case CssSizeUnits.PX:e.push({view1:i,attr1:"width",relation:"equ",view2:null,attr2:AutoLayout.Attribute.NOTANATTRIBUTE,constant:s,multiplier:1,priority:n});break;case CssSizeUnits.PCT:e.push({view1:i,attr1:"width",relation:"equ",view2:null,attr2:"width",constant:0,multiplier:s/100,priority:n});break;default:throw"width value is bad on id: "+i+", bad value is: "+r}}else if("height"===r)e.push({view1:i,attr1:"width",relation:"equ",view2:i,attr2:"height",constant:0,multiplier:1,priority:n});else if("parent"===r||-1!==this.childrenIds.indexOf(r))e.push({view1:i,attr1:"width",relation:"equ",view2:"parent"===r?null:r,attr2:"width",constant:0,multiplier:1,priority:n});else{if(-1!==a&&-1!==l||-1!==l&&-1!==u||-1!==a&&-1!==u)throw"width can only compare using one of `*` or `+` or `-`";if(-1!==a||-1!==l||-1!==u){let t=quickScan(r,!0);if(3!==t.length&&5!==t.length)throw"invalid expression for width found on view.id="+i+", expression: "+r;let o=t.indexOf("*"),a=t.indexOf("+"),l=t.indexOf("-"),u=!1;for(let e=0;e<t.length&&(u=endsWith(t[e],"%"),!u);e++);if(-1!==o){let o,a;if(isNumber(a=t[0])){if(o="height"===t[2]?i:t[2],"width"===o)throw"the width is not yet initialized";if(3===t.length)s="height"!==t[2];else{if(5!==t.length)throw"error in value specified for width on view.id="+i+"... expression "+r;s="width"===t[4]}}else if(isNumber(a=t[t.length-1])){if(o="height"===t[0]?i:t[0],"width"===o)throw"the width is not yet initialized";if(3===t.length)s="height"!==t[0];else{if(5!==t.length)throw"error in value specified for width on view.id="+i+"... expression "+r;s="width"===t[2]}}e.push({view1:i,attr1:"width",relation:"equ",view2:"parent"===o?null:o,attr2:s?"width":"height",constant:0,multiplier:parseFloat(a),priority:n})}else if(-1!==a){let o,l;if(u){if(3===t.length){var c=t[a-1],p="parent"===(d=t[a+1])?"100%":d;return isNumber(f="parent"===c?"100%":c)&&endsWith(p,"%")?(g=parseFloat(p.substring(0,p.length-1))/100,y=parseFloat(f)):endsWith(f,"%")&&isNumber(p)&&(g=parseFloat(f.substring(0,f.length-1))/100,y=parseFloat(p)),void(void 0!==y&&void 0!==g&&e.push({view1:i,attr1:"width",relation:"equ",view2:null,attr2:"width",constant:y,multiplier:g,priority:n}))}}else if(isNumber(l=t[0])){if(o="height"===t[2]?i:t[2],"width"===o)throw"the width is not yet initialized";if(3===t.length)s="height"!==t[2];else{if(5!==t.length)throw"error in value specified for width on view.id="+i+"... expression "+r;s="width"===t[4]}}else if(isNumber(l=t[t.length-1])){if(o="height"===t[0]?i:t[0],"width"===o)throw"the width is not yet initialized";if(3===t.length)s="height"!==t[0];else{if(5!==t.length)throw"error in value specified for width on view.id="+i+"... expression "+r;s="width"===t[2]}}e.push({view1:i,attr1:"width",relation:"equ",view2:"parent"===o?null:o,attr2:s?"width":"height",constant:parseFloat(l),multiplier:1,priority:n})}else if(-1!==l){let o,a;if(u){if(3===t.length){var d,f,y,g;c=t[l-1],p="parent"===(d=t[l+1])?"100%":d;return isNumber(f="parent"===c?"100%":c)&&endsWith(p,"%")?(y=parseFloat(f),g=-1*parseFloat(p.substring(0,p.length-1))/100):endsWith(f,"%")&&isNumber(p)&&(g=parseFloat(f.substring(0,f.length-1))/100,y=-1*parseFloat(p)),void(void 0!==y&&void 0!==g&&e.push({view1:i,attr1:"width",relation:"equ",view2:null,attr2:"width",constant:y,multiplier:g,priority:n}))}}else{if(isNumber(a=t[0]))throw"`value-elem[.width|height]` is not allowed, but `elem[.width|height]-value is allowed on ` view.id="+cid+"... expression "+r;if(isNumber(a=t[t.length-1])){if(o="height"===t[0]?i:t[0],"width"===o)throw"the width is not yet initialized";if(3===t.length)s="height"!==t[0];else{if(5!==t.length)throw"error in value specified for width on view.id="+i+"... expression "+r;s="width"===t[2]}}}e.push({view1:i,attr1:"width",relation:"equ",view2:"parent"===o?null:o,attr2:s?"width":"height",constant:-1*parseFloat(a),multiplier:1,priority:n})}}else{if(-1!==a||-1!==l||-1!==u||-1===h)throw"invalid value for width on id: "+i+", bad value is: "+r;{let t,o=r.substring(0,h),a=r.substring(h+1);if("width"===a)s=!0;else{if("height"!==a)throw"Strange expression found for width on id: "+i+", expression is: "+r;s=!1}if("parent"===o||"parent"===a)t=null;else{if(-1===this.childrenIds.indexOf(o))throw"Bad expression found for width on id: "+i+", expression is: "+r;t=o}e.push({view1:i,attr1:"width",relation:"equ",view2:t,attr2:s?"width":"height",constant:0,multiplier:1,priority:n})}}}},View.prototype.setHeightConstraints=function(t,e,i,r,n){let o,s,a=r.indexOf("*"),l=r.indexOf("+"),u=r.indexOf("-"),h=r.indexOf(".");if(isNumber(r)){if(0===(r="string"==typeof r?parseFloat(r):r)){let r=t.viewMap.get(i);if(-1!==r.dimRatio)return void e.push({view1:i,attr1:AutoLayout.Attribute.HEIGHT,relation:"equ",view2:i,attr2:AutoLayout.Attribute.WIDTH,constant:0,multiplier:1/r.dimRatio,priority:n})}e.push({view1:i,attr1:"height",relation:"equ",view2:null,attr2:AutoLayout.Attribute.NOTANATTRIBUTE,constant:r,multiplier:1,priority:n})}else if((o=parseNumberAndUnitsNoValidation(r,!0)).number){let s=parseFloat(o.number);if(0===s){let r=t.viewMap.get(i);if(-1!==r.dimRatio)return void e.push({view1:i,attr1:AutoLayout.Attribute.HEIGHT,relation:"equ",view2:i,attr2:AutoLayout.Attribute.WIDTH,constant:0,multiplier:1/r.dimRatio,priority:n})}switch(o.units){case CssSizeUnits.PX:e.push({view1:i,attr1:"height",relation:"equ",view2:null,attr2:AutoLayout.Attribute.NOTANATTRIBUTE,constant:s,multiplier:1,priority:n});break;case CssSizeUnits.PCT:e.push({view1:i,attr1:"height",relation:"equ",view2:null,attr2:"height",constant:0,multiplier:s/100,priority:n});break;default:throw"height value is bad on id: "+i+", bad value is: "+r}}else if("width"===r)e.push({view1:i,attr1:"height",relation:"equ",view2:i,attr2:"width",constant:0,multiplier:1,priority:n});else if("parent"===r||-1!==this.childrenIds.indexOf(r))e.push({view1:i,attr1:"height",relation:"equ",view2:"parent"===r?null:r,attr2:"height",constant:0,multiplier:1,priority:n});else{if(-1!==a&&-1!==l||-1!==l&&-1!==u||-1!==a&&-1!==u)throw"width can only compare using one of `*` or `+` or `-`";if(-1!==a||-1!==l||-1!==u){let t=quickScan(r,!0);if(3!==t.length&&5!==t.length)throw"invalid expression for height found on view.id="+i+",... "+t;let o=t.indexOf("*"),a=t.indexOf("+"),l=t.indexOf("-"),u=!1;for(let e=0;e<t.length&&(u=endsWith(t[e],"%"),!u);e++);if(-1!==o){let o,a;if(isNumber(a=t[0])){if(o="width"===t[2]?i:t[2],"height"===o)throw"the height is not yet initialized";if(3===t.length)s="width"!==t[2];else{if(5!==t.length)throw"error in value specified for height on view.id="+i+"... expression "+r;s="height"===t[4]}}else if(isNumber(a=t[t.length-1])){if(o="width"===t[0]?i:t[0],"height"===o)throw"the height is not yet initialized";if(3===t.length)s="width"!==t[0];else{if(5!==t.length)throw"error in value specified for height on view.id="+i+"... expression "+r;s="height"===t[2]}}e.push({view1:i,attr1:"height",relation:"equ",view2:"parent"===o?null:o,attr2:s?"height":"width",constant:0,multiplier:parseFloat(a),priority:n})}else if(-1!==a){let o,l;if(u){if(3===t.length){var c=t[a-1],p="parent"===(d=t[a+1])?"100%":d;return isNumber(f="parent"===c?"100%":c)&&endsWith(p,"%")?(g=parseFloat(p.substring(0,p.length-1))/100,y=parseFloat(f)):endsWith(f,"%")&&isNumber(p)&&(g=parseFloat(f.substring(0,f.length-1))/100,y=parseFloat(p)),void(void 0!==y&&void 0!==g&&e.push({view1:i,attr1:"height",relation:"equ",view2:null,attr2:"height",constant:y,multiplier:g,priority:n}))}}else if(isNumber(l=t[0])){if(o="width"===t[2]?i:t[2],"height"===o)throw"the height is not yet initialized";if(3===t.length)s="width"!==t[2];else{if(5!==t.length)throw"error in value specified for height on view.id="+i+"... expression "+r;s="height"===t[4]}}else if(isNumber(l=t[t.length-1])){if(o="width"===t[0]?i:t[0],"height"===o)throw"the height is not yet initialized";if(3===t.length)s="width"!==t[0];else{if(5!==t.length)throw"error in value specified for height on view.id="+i+"... expression "+r;s="height"===t[2]}}e.push({view1:i,attr1:"height",relation:"equ",view2:"parent"===o?null:o,attr2:s?"height":"width",constant:parseFloat(l),multiplier:1,priority:n})}else if(-1!==l){let o,a;if(u){if(3===t.length){var d,f,y,g;c=t[l-1],p="parent"===(d=t[l+1])?"100%":d;return isNumber(f="parent"===c?"100%":c)&&endsWith(p,"%")?(y=parseFloat(f),g=-1*parseFloat(p.substring(0,p.length-1))/100):endsWith(f,"%")&&isNumber(p)&&(g=parseFloat(f.substring(0,f.length-1))/100,y=-1*parseFloat(p)),void(void 0!==y&&void 0!==g&&e.push({view1:i,attr1:"height",relation:"equ",view2:null,attr2:"height",constant:y,multiplier:g,priority:n}))}}else{if(isNumber(a=t[0]))throw"`value-elem[.width|height]` is not allowed, but `elem[.width|height]-value is allowed on ` view.id="+i+"... expression "+w;if(isNumber(a=t[t.length-1])){if(o="width"===t[0]?i:t[0],"height"===o)throw"the height is not yet initialized";if(3===t.length)s="width"!==t[0];else{if(5!==t.length)throw"error in value specified for height on view.id="+i+"... expression "+r;s="height"===t[2]}}}e.push({view1:i,attr1:"height",relation:"equ",view2:"parent"===o?null:o,attr2:s?"height":"width",constant:-1*parseFloat(a),multiplier:1,priority:n})}}else{if(-1!==a||-1!==l||-1===h)throw"invalid value for height on id: "+i+", bad value is: "+r;{let t,o=r.substring(0,h),a=r.substring(h+1);if("height"===a)s=!0;else{if("width"!==a)throw"Strange expression found for height on id: "+i+", expression is: "+r;s=!1}if("parent"===o||"parent"===a)t=null;else{if(-1===this.childrenIds.indexOf(o))throw"Bad expression found for height on id: "+i+", expression is: "+r;t=o}e.push({view1:i,attr1:"height",relation:"equ",view2:t,attr2:s?"height":"width",constant:0,multiplier:1,priority:n})}}}},View.prototype.toHTML=function(){let t=null;const e=this.htmlNode.nodeName.toLowerCase();if(isHTMLTagName(e))return t="li"===e?document.createElement("ul"):"tbody"===e||"thead"===e||"tfoot"===e||"tr"===e?document.createElement("table"):"td"===e||"th"===e?document.createElement("tr"):"option"===e?document.createElement("select"):document.createElement("div"),t.appendChild(this.htmlNode),t.innerHTML;throw"Invalid HTML element!"},View.prototype.calculateWrapContentSizes=function(t){let e=this.refIds.get(attrKeys.layout_width),i=this.refIds.get(attrKeys.layout_height);if(e===sizes.WRAP_CONTENT&&i===sizes.WRAP_CONTENT){let e=t.getBoundingClientRect();this.wrapWidth=.813*e.width+"px",this.wrapHeight=.825*e.height+"px"}else if(e!==sizes.WRAP_CONTENT&&i===sizes.WRAP_CONTENT){t.style.width=e;let i=t.getBoundingClientRect();this.wrapHeight=.825*i.height+"px"}else if(e===sizes.WRAP_CONTENT&&i!==sizes.WRAP_CONTENT){t.style.height=i;let e=t.getBoundingClientRect();this.wrapWidth=.813*e.width+"px"}},Guideline.prototype=Object.create(View.prototype),Guideline.prototype.constructor=Guideline,IncludedView.prototype=Object.create(View.prototype),IncludedView.prototype.constructor=IncludedView,Guideline.prototype.calculateWrapContentSizes=function(t){const e=this.refIds.get(attrKeys.orientation);if(null==e||""===e)throw"Please specify the orientation of the Guideline whose id is `"+this.id+"`";e===orientations.VERTICAL?(this.wrapWidth="1",this.wrapHeight=sizes.MATCH_PARENT):(this.wrapWidth=sizes.MATCH_PARENT,this.wrapHeight="1")},Guideline.prototype.layoutGuide=function(t){const e=this.refIds.get(attrKeys.orientation);if(!e||""===e)throw"Please specify the orientation of the Guideline whose id is `"+this.id+"`";let i=this.id,r=this.refIds.get(attrKeys.layout_constraintGuide_percent),n=this.refIds.get(attrKeys.layout_constraintGuide_begin),o=this.refIds.get(attrKeys.layout_constraintGuide_end);if(isEmpty(r)&&isEmpty(n)&&isEmpty(o))throw"Please specify either constraint-guide-(percentage|begin|end) for the Guideline whose id is `"+this.id+"`";let s=0;if(!isEmpty(r)){if(!isEmpty(n)||!isEmpty(o))throw"Conflicting guide constraints! only one of guide_percent, guide_begin and guide_end hould be set!";if(endsWith(r,"%")){if(isNaN(s=parseFloat(r)))throw"Please specify a floating point number between 0 and 1 to signify 0 - 100% of width";s=s>1?s/100:s}else{if(isNaN(s=parseFloat(r)))throw"Please specify a floating point number between 0 and 1 to signify 0 - 100% of width";if(s>1)throw"The guide percentage may not be greater than 1";if(s<0)throw"The guide percentage may not be less than 0"}if(e===orientations.VERTICAL){t.push({view1:i,attr1:"height",relation:"equ",view2:null,attr2:"height",constant:0,multiplier:1,priority:AutoLayout.Priority.REQUIRED}),t.push({view1:i,attr1:"width",relation:"equ",view2:null,attr2:AutoLayout.Attribute.NOTANATTRIBUTE,constant:.1,multiplier:1,priority:AutoLayout.Priority.REQUIRED});let e=i+"_dummy_"+ULID.ulid();t.push({view1:e,attr1:"left",relation:"equ",view2:null,attr2:"left",constant:0,multiplier:1,priority:AutoLayout.Priority.REQUIRED}),t.push({view1:e,attr1:"width",relation:"equ",view2:null,attr2:"width",constant:1,multiplier:s,priority:AutoLayout.Priority.REQUIRED}),t.push({view1:i,attr1:"left",relation:"equ",view2:e,attr2:"right",constant:1,multiplier:1,priority:AutoLayout.Priority.REQUIRED})}else if(e===orientations.HORIZONTAL){t.push({view1:i,attr1:"width",relation:"equ",view2:null,attr2:"width",constant:0,multiplier:1,priority:AutoLayout.Priority.REQUIRED}),t.push({view1:i,attr1:"height",relation:"equ",view2:null,attr2:AutoLayout.Attribute.NOTANATTRIBUTE,constant:.1,multiplier:1,priority:AutoLayout.Priority.REQUIRED});let e=i+"_dummy_"+ULID.ulid();t.push({view1:e,attr1:"top",relation:"equ",view2:null,attr2:"top",constant:0,multiplier:1,priority:AutoLayout.Priority.REQUIRED}),t.push({view1:e,attr1:"height",relation:"equ",view2:null,attr2:"height",constant:1,multiplier:s,priority:AutoLayout.Priority.REQUIRED}),t.push({view1:i,attr1:"top",relation:"equ",view2:e,attr2:"bottom",constant:0,multiplier:1,priority:AutoLayout.Priority.REQUIRED})}}if(!isEmpty(n)){if(!isEmpty(r)||!isEmpty(o))throw"Conflicting guide constraints! only one of `guide_percent`, `guide_begin` and `guide_end` should be set!";if(!(isNumber(n)||endsWith(n,"px")&&isNumber(parseInt(n))))throw"`guide_begin` must be a unitless number or be specified in pixels";if(n=parseFloat(n),isNaN(n))throw"please specify a number for `guide_begin`";s=n,e===orientations.VERTICAL?(t.push({view1:i,attr1:"height",relation:"equ",view2:null,attr2:"height",constant:0,multiplier:1,priority:1e3}),t.push({view1:i,attr1:"width",relation:"equ",view2:null,attr2:AutoLayout.Attribute.NOTANATTRIBUTE,constant:.1,multiplier:1,priority:1e3}),t.push({view1:i,attr1:"left",relation:"equ",view2:null,attr2:"left",constant:s,multiplier:1,priority:1e3})):e===orientations.HORIZONTAL&&(t.push({view1:i,attr1:"width",relation:"equ",view2:null,attr2:"width",constant:0,multiplier:1,priority:1e3}),t.push({view1:i,attr1:"height",relation:"equ",view2:null,attr2:AutoLayout.Attribute.NOTANATTRIBUTE,constant:.1,multiplier:1,priority:1e3}),t.push({view1:i,attr1:"top",relation:"equ",view2:null,attr2:"top",constant:s,multiplier:1,priority:1e3}))}if(!isEmpty(o)){if(!isEmpty(r)||!isEmpty(n))throw"Conflicting guide constraints! only one of `guide_percent`, `guide_begin` and `guide_end` should be set!";if(!(isNumber(o)||endsWith(o,"px")&&isNumber(parseInt(o))))throw"`guide_end` must be a unitless number or be specified in pixels";if(o=parseFloat(o),isNaN(o))throw"please specify a number for `guide_end`";s=o,e===orientations.VERTICAL?(t.push({view1:i,attr1:"height",relation:"equ",view2:null,attr2:"height",constant:0,multiplier:1,priority:1e3}),t.push({view1:i,attr1:"width",relation:"equ",view2:null,attr2:AutoLayout.Attribute.NOTANATTRIBUTE,constant:.1,multiplier:1,priority:1e3}),t.push({view1:i,attr1:"right",relation:"equ",view2:null,attr2:"right",constant:-s,multiplier:1,priority:1e3})):e===orientations.HORIZONTAL&&(t.push({view1:i,attr1:"width",relation:"equ",view2:null,attr2:"width",constant:0,multiplier:1,priority:1e3}),t.push({view1:i,attr1:"height",relation:"equ",view2:null,attr2:AutoLayout.Attribute.NOTANATTRIBUTE,constant:.1,multiplier:1,priority:1e3}),t.push({view1:i,attr1:"bottom",relation:"equ",view2:null,attr2:"bottom",constant:-s,multiplier:1,priority:1e3}))}},IncludedView.prototype.calculateWrapContentSizes=function(t){this.wrapWidth=300,this.wrapHeight=320},ScannerOld.prototype.scan=function(){let t=this.input,e=[];this.tokens.sort(function(t,e){return e.length-t.length});for(let i=0;i<t.length;i++)for(let r=0;r<this.tokens.length;r++){let n=this.tokens[r],o=n.length;if(o>0&&i+o<=t.length){if(t.substring(i,i+o)===n){0!==i&&(e[e.length]=t.substring(0,i)),this.includeTokensInOutput&&(e[e.length]=n),t=t.substring(i+o),i=-1;break}}}return 0!==t.length&&(e[e.length]=t),e},Scanner.prototype.scan=function(){const t=this.input,e=this.tokens,i=[];let r=0,n=0;for(;r<t.length;){let o=null;for(let s of e){const e=s.length;if(e>0&&r+e<=t.length&&t.substring(r,r+e)===s){o=s,r>n&&i.push(t.substring(n,r)),this.includeTokensInOutput&&i.push(o),r+=e,n=r;break}}null===o&&r++}return n<t.length&&i.push(t.substring(n,t.length)),i},StringBuffer.prototype.append=function(t){return this.dataArray.push(t),this},StringBuffer.prototype.toString=function(){return this.dataArray.join("")},StringBuffer.prototype.length=function(){return this.dataArray.length},StringBuffer.prototype.reset=function(){return this.dataArray.length=0,this};let cloneText=function(t){if(t&&"string"==typeof t)return(" "+t).slice(1);throw new Error("Invalid text supplied.")};function startsWith(t,e){if("string"==typeof t&&"string"==typeof e){const i=t.length,r=e.length;return i===r?t===e:!(i<r)&&0===t.indexOf(e,0)}return!1}function endsWith(t,e){if("string"==typeof t&&"string"==typeof e){const i=t.length,r=e.length;return i===r?t===e:!(i<r)&&t.lastIndexOf(e)===i-r}return!1}function contain(t,e){if("string"==typeof t&&"string"==typeof e){let i=t.length,r=e.length;return i===r?t===e:!(i<r)&&-1!==t.indexOf(e,0)}return!1}function endsWithAnyOf(t,e){for(var i=e.length,r=0;r<i;r++)if(endsWith(t,e[r]))return!0;return!1}function indexOfEnder(t,e){for(var i=e.length,r=0;r<i;r++)if(endsWith(t,e[r]))return r;return-1}function startsWithAnyOf(t,e){for(var i=e.length,r=0;r<i;r++)if(startsWith(t,e[r]))return!0;return!1}function indexOfStarter(t,e){for(var i=e.length,r=0;r<i;r++)if(startsWith(t,e[r]))return r;return-1}function containsAnyOf(t,e){const i=e.length;for(let r=0;r<i;r++)if(contain(t,e[r]))return!0;return!1}function reverse(t){for(var e="",i=t.length-1;i>=0;i--)e+=t.charAt(i);return e}function isWhiteSpacesOnly(t){return null===t||(!t||!/\S/.test(t))}function isEmpty(t){return!t||!/\S/.test(t)}let isNumber=function(t){return null!==t&&""!==t&&!1===isNaN(t)};function isOneDimArray(t){return"[object Array]"===Object.prototype.toString.call(t)}function addClass(t,e){t&&e&&t.classList.add(e)}function removeClass(t,e){t&&e&&t.classList.remove(e)}function isDomEntity(t){return"object"==typeof t&&void 0!==t.nodeType}const attrKeys={id:"id",layout:"layout",layout_width:"w",layout_height:"h",layout_maxWidth:"maxW",layout_maxHeight:"maxH",layout_minWidth:"minW",layout_minHeight:"minH",layout_margin:"m",layout_marginStart:"ms",layout_marginEnd:"me",layout_marginTop:"mt",layout_marginBottom:"mb",layout_marginHorizontal:"mh",layout_marginVertical:"mv",layout_constraintTop_toTopOf:"tt",layout_constraintBottom_toBottomOf:"bb",layout_constraintStart_toStartOf:"ss",layout_constraintEnd_toEndOf:"ee",layout_constraintTop_toBottomOf:"tb",layout_constraintStart_toEndOf:"se",layout_constraintEnd_toStartOf:"es",layout_constraintBottom_toTopOf:"bt",layout_constraintCenterXAlign:"cx",layout_constraintCenterYAlign:"cy",layout_constraintStart_toCenterX:"scx",layout_constraintCenterX_toStart:"cxs",layout_constraintEnd_toCenterX:"ecx",layout_constraintCenterX_toEnd:"cxe",layout_constraintTop_toCenterY:"tcy",layout_constraintCenterY_toTop:"cyt",layout_constraintBottom_toCenterY:"bcy",layout_constraintCenterY_toBottom:"cyb",layout_constraint:"data-const",layout_constraintGuide:"data-guide",layout_constraintGuideColor:"data-guide-color",layout_popup:"popup",layout_menuLeft:"menu-left",layout_menuRight:"menu-right",layout_src:"src",layout_constraintGuide_percent:"guide-pct",layout_constraintGuide_begin:"guide-begin",layout_constraintGuide_end:"guide-end",layout_horizontalBias:"hor-bias",layout_verticalBias:"ver-bias",dimension_ratio:"dim-ratio",orientation:"orient",customType:"custom-widget",customTypeLabel:"label",customTypeTabView:"tabview",mi_gravity:"mi-gravity",mi_border_radius:"mi-border-radius",mi_padding:"mi-padding",mi_line_spacing:"mi-line-spacing",mi_text:"mi-text",mi_useAutoBg:"mi-use-bg",mi_mode:"mi-mode",mi_fontStyle:"mi-font-st",mi_fontName:"mi-font-nm",mi_fontWeight:"mi-font-wt",mi_fontSize:"mi-font-sz",mi_shapesDensity:"mi-shapes-density",mi_singleLine:"mi-single-line",mi_opacity:"mi-opacity",mi_fg:"mi-fg",mi_bg:"mi-bg",mi_opaqueBg:"mi-opq-bg",mi_strokeWidth:"mi-sw",mi_minSize:"mi-min-sz",mi_numShapes:"mi-num-shapes",mi_textOnly:"mi-text-only",mi_textArray:"mi-text-arr",mi_cacheAfterDraw:"mi-cache-image"},sizes={MATCH_PARENT:"match_parent",WRAP_CONTENT:"wrap_content"},orientations={VERTICAL:"vertical",HORIZONTAL:"horizontal",GRID:"grid"},CssSizeUnits={VMAX:"vmax",VMIN:"vmin",REM:"rem",EM:"em",PT:"pt",PX:"px",CM:"cm",IN:"in",MM:"mm",VM:"vm",VH:"vh",VW:"vw",PC:"pc",EX:"ex",CH:"ch",GD:"gd",PCT:"%",Q:"q"},CssSizeUnitsValues=getObjectValues(CssSizeUnits).sort(function(t,e){return e.length-t.length});function getObjectValues(t){var e=[];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.push(t[i]);return e}function StyleElement(t,e){if("string"!=typeof t||"string"!=typeof e)throw new Error("attr or value must be string...`attr` = "+t+", `value` = "+e);this.attr=t.trim(),this.value=e.trim()}function Style(t,e){if(e||(e=[]),!isOneDimArray(e))throw new Error("One dimensional array of style elements expected");this.name=t.trim(),this.styleElements=e}function injectStyleSheets(t,e){if("[object Array]"!==Object.prototype.toString.call(e))throw new Error("Please supply an array of styles");{let i=new StringBuffer("");i.append(t.innerHTML);for(let t=0;t<e.length;t++){let r=e[t];if("Style"!==r.constructor.name)throw new Error("Please put only styles in the supplied array");if(void 0===r.name||null===r.name||""===r.name)throw"Please define the name of this style!... e.g #name or .name";i.append(r.styleSheetEntry(r.name)),i.append("\n")}t.innerHTML=i.toString(),document.getElementsByTagName("head")[0].appendChild(t)}}function indexOfSelector(t,e){let i=new Scanner(t.innerHTML,!0,["{","}"]).scan();for(let t=0;t<i.length;t++)if("{"===i[t]&&t-1>=0&&e.trim()===i[t-1].trim())return t-1;return-1}function sheetContainsSelector(t,e){return-1!==indexOfSelector(t.innerHTML,e)}function getAllStyles(t){let e=new Scanner(t.innerHTML,!0,["{","}",";"]).scan();for(let t=0;t<e.length;t++)";"===e[t]&&t+1<e.length&&!1===startsWith(e[t+1],"\n")&&(e[t-1]=e[t-1]+e[t]+e[t+1],e.splice(t,1),e.splice(t,1));let i=[];for(let t=0;t<e.length;t++){if("{"===e[t]&&t-1>=0){let r=new Style(e[t-1].trim(),[]);i.push(r)}if(";"===e[t]){i[i.length-1].addStyleElementCss(e[t-1]+";")}}return i}function getStyle(t,e){if(!e)throw new Error("No selector supplied!");e=e.trim();let i,r=new Scanner(t.innerHTML,!0,[e,"{","}",";"]).scan(),n=!1;for(let t=0;t<r.length;t++){if(r[t].trim()===e&&t+1<r.length){let o=t+1;for(;"{"!==r[o]&&o<r.length;){if(""!==r[o].trim())throw new Error("Invalid token found in browser style sheet! File a bug report with browser manufacturer!! Description:\n No token like: ``"+r[o]+"`` should exist between ``"+e+"`` and a ``{``");o++}i=new Style(e,[]),n=!0,t=o}if(!0===n)if(";"===r[t])i.addStyleElementCss(r[t-1]+";");else if("}"===r[t])return i}return null}function editSelectorInStyleSheet(t,e){if("Style"===e.constructor.name){let i=e.name,r=getAllStyles(t),n=!1;for(let t=0;t<r.length;t++){let o=r[t];if(o.name.trim()===i){n=!0;for(let t=0;t<e.styleElements.length;t++){let i=e.styleElements[t];o.addStyleElement(i.attr,i.value,!1)}break}}return n||r.push(e),t.innerHTML="",injectStyleSheets(t,r),!0}throw new Error("Invalid style object supplied")}function updateOrCreateSelectorInStyleSheet(t,e){if("Style"===e.constructor.name){let i=e.name,r=getAllStyles(t),n=!1;for(let t=0;t<r.length;t++){let o=r[t];o.name.trim()===i&&(n=!0,o.styleElements=e.styleElements)}return n||r.push(e),t.innerHTML="",injectStyleSheets(t,r),!0}throw new Error("Invalid style object supplied")}function updateOrCreateSelectorsInStyleSheet(t,e){if(!isOneDimArray(e))throw new Error("A one dimensional array expected for `newStyles`");let i=getAllStyles(t);for(let t=0;t<e.length;t++){let r=e[t];if("Style"!==r.constructor.name)throw new Error("Invalid style object supplied");{let t=r.name,e=!1;for(let n=0;n<i.length;n++){let o=i[n];o.name.trim()===t&&(e=!0,o.styleElements=r.styleElements)}e||i.push(r)}}t.innerHTML="",injectStyleSheets(t,i)}function getScrollBarWidth(){var t=document.createElement("div");t.style.visibility="hidden",t.style.overflow="scroll",t.style.msOverflowStyle="scrollbar",document.body.appendChild(t);var e=document.createElement("div");t.appendChild(e);var i=t.offsetWidth-e.offsetWidth;return t.parentNode.removeChild(t),i}function parseNumberAndUnitsNoValidation(t,e){if("number"==typeof t&&(t+=""),"string"!=typeof t)return{number:null,units:null};if(isNumber(t))return e&&!0===e?{number:t,units:"px"}:{number:null,units:null};let i="",r=t.length-1;for(;r>=0;r--){let e=t.substring(r,r+1);if("0"===e||"1"===e||"2"===e||"3"===e||"4"===e||"5"===e||"6"===e||"7"===e||"8"===e||"9"===e){i=t.substring(0,r+1);break}}let n=t.substring(r+1);return-1===CssSizeUnitsValues.indexOf(n)?{number:null,units:null}:isNumber(i)?{number:i,units:n}:{number:null,units:null}}function parseNumberAndUnits(t,e){if("string"!=typeof t)throw new Error("parses only string input");if(e&&!0===e&&isNumber(t)&&(t+="px"),isNumber(t)){if(e&&!0===e)return{number:t,units:"px"};throw"No units specified for number: "+t}let i="",r=t.length-1;for(;r>=0;r--){let e=t.substring(r,r+1);if("0"===e||"1"===e||"2"===e||"3"===e||"4"===e||"5"===e||"6"===e||"7"===e||"8"===e||"9"===e){i=t.substring(0,r+1);break}}let n=t.substring(r+1);if(-1===CssSizeUnitsValues.indexOf(n))throw new Error("This unit is not a valid css unit.. Use one of:\n "+CssSizeUnitsValues);if(!isNumber(i))throw new Error("The number is not a valid number!..."+i);return{number:i,units:n}}function getScriptFileName(){let t=null;if(document.currentScript&&document.currentScript.src)t=document.currentScript.src;else{const e=document.getElementsByTagName("script"),i=e[e.length-1];i&&i.src&&(t=i.src)}if(t){const e=new URL(t,document.location.origin).pathname;return e.substring(e.lastIndexOf("/")+1)}return null}function getUrls(){let t=document.getElementsByTagName("script");for(let e=0;e<t.length;e++){let i=t[e].src,r=getScriptFileName();console.log("layout-file-name: ",r);let n=i.length,o=r.length;if(i.lastIndexOf(r)===n-o){scriptURL=i.substring(0,n-o),projectURL=window.location.href;let t=0;for(;projectURL.charAt(t)===scriptURL.charAt(t);)t+=1;return projectURL=projectURL.substring(0,t),[projectURL,scriptURL]}}return null}StyleElement.prototype.setAttr=function(t){this.attr=t},StyleElement.prototype.getAttr=function(){return this.attr},StyleElement.prototype.setValue=function(t){this.value=t},StyleElement.prototype.getValue=function(){return this.value},StyleElement.prototype.getCss=function(){return this.attr+":"+this.value+";"},Style.prototype.setName=function(t){this.name=t},Style.prototype.getName=function(){return this.name},Style.prototype.setStyleElements=function(t){this.styleElements=t},Style.prototype.getStyleElements=function(){return this.styleElements},Style.prototype.isEmpty=function(){return 0===this.styleElements.length},Style.prototype.styleSheetEntry=function(t){this.name=t;let e=new StringBuffer;if(0===this.styleElements.length)return"";e.append(t).append(" { \n");for(let t=0;t<this.styleElements.length;t++){let i=this.styleElements[t];e.append(i.getCss()).append("\n")}return e.append("} \n"),e.toString()},Style.prototype.injectStyleSheet=function(){if(void 0===this.name||null===this.name||""===this.name)throw"Please define the name of this style!... e.g #name or .name";let t=document.createElement("style");this.styleElements.length>0&&(t.setAttribute("type","text/css"),t.innerHTML=this.styleSheetEntry(this.name),document.getElementsByTagName("head")[0].appendChild(t))},Style.prototype.toOptions=function(){let t={};for(let e=0;e<this.styleElements.length;e++){let i=getObjectValues(this.styleElements[e]);t[i[0]]=i[1]}return t},Style.prototype.addFromOptions=function(t){for(let e in t)this.addStyleElement(e,t[e])},Style.prototype.getCss=function(){let t=new StringBuffer;if(0===this.styleElements.length)return"";t.append(" style = '");for(let e=0;e<this.styleElements.length;e++){let i=this.styleElements[e];t.append(i.getCss())}return t.append("' "),t.toString()},Style.prototype.rawCss=function(){let t=new StringBuffer;if(0===this.styleElements.length)return"";t.append(" ");for(let e=0;e<this.styleElements.length;e++){let i=this.styleElements[e];t.append(i.getCss())}return t.append(" "),t.toString()},Style.prototype.applyInline=function(t){if(!t)throw new Error("Please specify an html element.");if(!isDomEntity(t))throw new Error("Invalid html element: "+t);for(let e=0;e<this.styleElements.length;e++){let i=this.styleElements[e];t.style[i.attr]=i.value}},Style.prototype.removeStyleElementObj=function(t){if(StyleElement.prototype.isPrototypeOf(t)){let e=t.getAttr();for(let t=0;t<this.styleElements.length;t++){if(this.styleElements[t].getAttr()===e)return void this.styleElements.splice(t,1)}}},Style.prototype.removeStyleElementByAttr=function(t){for(let e=0;e<this.styleElements.length;e++){if(this.styleElements[e].getAttr()===t)return void this.styleElements.splice(e,1)}},Style.prototype.addStyleElement=function(t,e,i){if(i)this.styleElements.push(new StyleElement(t,e));else{for(let i=0;i<this.styleElements.length;i++){if(this.styleElements[i].getAttr()===t)return void(this.styleElements[i]=new StyleElement(t,e))}this.styleElements.push(new StyleElement(t,e))}},Style.prototype.addStyleElementsArray=function(t,e){for(let i=0;i<t.length;i++){let r=t[i];this.addStyleElementObj(r,e)}},Style.prototype.addStyleElementObj=function(t,e){if(!StyleElement.prototype.isPrototypeOf(t))throw new Error("Invalid Style specified.");if(e)this.styleElements.push(t);else{let e=t.getAttr();for(let i=0;i<this.styleElements.length;i++){if(this.styleElements[i].getAttr()===e)return void(this.styleElements[i]=t)}this.styleElements.push(t)}},Style.prototype.clone=function(t){let e=[];for(let t=0;t<this.styleElements.length;t++){let i=this.styleElements[t];e.push(new StyleElement(i.attr,i.value))}return t||(t=this.name),new Style(t,e)},Style.prototype.addStyleElementCss=function(t,e){if(!t)throw new Error("No css line supplied!");{let i=!0===contain(t=t.trim(),"url"),r=t.indexOf(":"),n=i?t.lastIndexOf(";"):t.indexOf(";");if(-1===n||n!==t.length-1||-1===r)throw new Error("Invalid css line expression!..."+t);{let i=t.substring(0,r),o=t.substring(r+1,n);if(-1!==i.indexOf(":")||-1!==i.indexOf(";")||(-1!==o.indexOf("url")||-1!==o.indexOf(":")||-1!==o.indexOf(";"))&&"-1"===o.indexOf("url"))throw new Error("Weird css line expression____!"+t);{let t=new StyleElement(i,o);if(e)this.styleElements.push(t);else{for(let e=0;e<this.styleElements.length;e++){if(this.styleElements[e].getAttr()===i)return void(this.styleElements[e]=t)}this.styleElements.push(t)}}}}},Style.prototype.getValue=function(t){for(let e=0;e<this.styleElements.length;e++){let i=this.styleElements[e];if(i.attr===t)return i.value}return null};const SideMenuTypes={LEFT:"left",RIGHT:"right"};function SideMenuX(t){if(!t)throw new Error("Please supply the options for creating the menu.");if(this.id="","string"!=typeof t.id)throw new Error("Please supply the id of the menu");if(this.id=t.id,this.width=-1,this.parsedWidth=-1,"number"==typeof t.width)this.width=t.width+"px";else{if("string"!=typeof t.width)throw new Error('Please supply the width of the menu.. e.g. `width:"300px"` or `width:"30%"`');if(!isNumber(parseInt(t.width)))throw"invalid value specified for width!";this.width=t.width}if(this.menuType=SideMenuTypes.LEFT,t.menuType){if(t.menuType!==SideMenuTypes.LEFT&&t.menuType!==SideMenuTypes.RIGHT)throw new Error("Invalid menu type specified! Use either of `"+SideMenuTypes.PUSH+"` or `"+SideMenuTypes.OVERLAY+"`");this.menuType=t.menuType}if(this.layout="","string"!=typeof t.layout)throw new Error("Please supply the name of the xml layout");this.layout=t.layout,this.background="#fff",t.background&&(this.background=t.background),this.registry={};var e=document.body,i=document.documentElement;Math.max(e.scrollWidth,e.offsetWidth,i.clientWidth,i.scrollWidth,i.offsetWidth);let r=Math.max(e.scrollHeight,e.offsetHeight,i.clientHeight,i.scrollHeight,i.offsetHeight);this.overlayStyle=new Style("."+this.overlayClass(),[]),this.frameStyle=new Style("."+this.containerClass(),[]),this.closeBtnStyle=new Style("."+this.closeBtnClass(),[]),this.noScrollStyle=new Style(".noscroll",[]);let n=2e3;this.overlayStyle.addFromOptions({display:"block",visibility:"visible",opacity:"0.8",position:"fixed","background-color":"black",top:"0",left:"0",bottom:"0",right:"0","z-index":n+""}),this.noScrollStyle.addFromOptions({overflow:"hidden"});{n+=10;let t={width:this.width,height:r+"px",position:"fixed",top:"0",left:"0",padding:"0","z-index":n+"","background-color":this.background,"overflow-x":"hidden","overflow-y":"auto",transition:"0.5s"};t[this.menuType]="0",this.frameStyle.addFromOptions(t)}{let t={top:"12px",position:"fixed","font-size":"8em","font-weight":"bold","font-family":"monospace",cursor:"pointer",color:"white","background-color":"transparent",border:"none",padding:"none"};this.menuType===SideMenuTypes.LEFT?t[SideMenuTypes.RIGHT]="18px":t[SideMenuTypes.LEFT]="18px",this.closeBtnStyle.addFromOptions(t)}this.onOpen=function(){},t.onOpen&&"[object Function]"==={}.toString.call(t.onOpen)?this.onOpen=t.onOpen:this.onOpen=function(){},this.onClose=function(){},t.onClose&&"[object Function]"==={}.toString.call(t.onClose)?this.onClose=t.onClose:this.onClose=function(){},this.onBind=function(){},t.onBind&&"[object Function]"==={}.toString.call(t.onBind)?this.onBind=t.onBind:this.onBind=function(){},this.registerStyle(this.overlayStyle),this.registerStyle(this.noScrollStyle),this.registerStyle(this.frameStyle),this.registerStyle(this.closeBtnStyle),this.rootView=null,this.shouldOpen=!1}function debounce(t,e){var i;return e=e||150,function(){var r=this,n=arguments;!1===r.isResizing&&(r.isResizing=!0),clearTimeout(i),i=setTimeout(function(){t.apply(r,n),r.isResizing=!1},e)}}SideMenuX.prototype.registerStyle=function(t){this.registry[t.name]=t},SideMenuX.prototype.hide=function(){var t=document.getElementById(this.overlayId()),e=document.getElementById(this.containerId());return t&&(t.style.display="none"),e&&this.closeMenu(),removeClass(document.body,this.noScrollStyle.name.substring(1)),this.onClose(),this},SideMenuX.prototype.open=function(){return this.shouldOpen=!0,this.build(),this.openMenu(),this},SideMenuX.prototype.build=function(){var t=this;let e=!1;var i=document.getElementById(this.overlayId()),r=document.getElementById(this.containerId());i||(e=!0,(i=document.createElement("div")).setAttribute("id",this.overlayId()),addClass(i,this.overlayClass()),document.body.appendChild(i)),i.style.display="block",i.onclick=function(){t.hide()},r||((r=document.createElement("div")).setAttribute("id",this.containerId()),addClass(r,this.containerClass()),r.innerHTML=this.layout.trim(),document.body.appendChild(r));let n=document.getElementById(this.closeBtnId());if(n||(n=document.createElement("input"),n.setAttribute("id",this.closeBtnId()),addClass(n,this.closeBtnClass()),n.setAttribute("type","button"),n.value="˟",i.appendChild(n),this.onBind()),n.onclick=function(){t.hide()},e){let e=document.createElement("style");e.setAttribute("type","text/css");let n=new StringBuffer;for(var o in this.registry)n.append(this.registry[o].styleSheetEntry(o));e.innerHTML=n.toString(),document.getElementsByTagName("head")[0].appendChild(e);let s=new Page(r);s.layout(),page.subPages.set(r.id,s),t.openMenu(),t.rootView=r,t.parsedWidth=parseInt(window.getComputedStyle(r).width),this.shouldOpen||(r.style.visibility="hidden",i.style.visibility="hidden",this.hide(),setTimeout(function(){r.style.visibility="visible",i.style.visibility="visible"},200))}return this.addDragEvents(i,r),this},SideMenuX.prototype.reflow=function(){var t=document.body,e=document.documentElement,i=Math.max(t.scrollHeight,t.offsetHeight,e.clientHeight,e.scrollHeight,e.offsetWidth),r=document.getElementById(this.containerId());r&&(r.style.height=i+"px",this.parsedWidth=parseInt(window.getComputedStyle(r).width))},SideMenuX.prototype.addDragEvents=function(t,e){let i=this,r=!0;e.onmousemove=function(t){},e.onmousedown=function(t){(t=window.event||t).target!==this&&t.target!==i.rootView||(r=!0,e.onmousemove=function(t){(t=window.event||t).target!==this&&t.target!==i.rootView||!0===r&&t.pageX<i.parsedWidth&&(e.style.width=t.pageX+2+"px",e.style.transition="0.5s")},e.onmouseup=function(t){(t=window.event||t).target!==this&&t.target!==i.rootView||(r=!1,e.style.transition="0.5s",e.onmousemove=function(t){},t.pageX<i.parsedWidth/3?i.hide():i.openMenu())})},t.onmouseup=function(t){t.preventDefault(),r=!1},t.onmousemove=function(t){ev=window.event||ev,ev.target!==this&&ev.target!==i.rootView||!0===r&&(ev.pageX<i.parsedWidth?(e.style.width=ev.pageX+2+"px",e.style.transition="0.5s"):ev.pageX>=i.parsedWidth+80&&(e.style.width=i.parsedWidth+"px"))}},SideMenuX.prototype.containerClass=function(){return this.id+"_side_menux_frame_class"},SideMenuX.prototype.overlayClass=function(){return this.id+"_side_menux_overlay_class"},SideMenuX.prototype.overlayId=function(){return this.id+"_side_menux_overlay_id"},SideMenuX.prototype.closeBtnClass=function(){return this.id+"_side_menux_close_btn_class"},SideMenuX.prototype.closeBtnId=function(){return this.id+"_side_menux_close_btn_class"},SideMenuX.prototype.containerId=function(){return this.id},SideMenuX.prototype.openMenu=function(){var t=document.getElementById(this.containerId());t.style.width=this.width;var e=function(){var i=page.subPages.get(t.id);i&&i.layout&&(i.layout(),console.log("menuPage.layout() called")),console.log("transitionend or transitioncancel called"),t.removeEventListener("transitionend",e),t.removeEventListener("transitioncancel",e)},i=function(){var e=page.subPages.get(t.id);e&&e.layout&&(e.layout(),console.log("menuPage.layout() called")),window.setTimeout(function(){t.removeEventListener("transitionstart",i)},500)};t.addEventListener("transitionstart",i),t.addEventListener("transitionend",e),t.addEventListener("transitioncancel",e),addClass(document.body,this.noScrollStyle.name.substring(1)),this.onOpen()},SideMenuX.prototype.closeMenu=function(){document.getElementById(this.containerId()).style.width="0"};var popupZIndex=1e3;function Popup(t){if(!t)throw new Error("No options specified for creating this popup");if(!t.id||"string"!=typeof t.id)throw new Error("Hi! You have not specified a value for options.layitId! Popup cannot be created");if(this.id=t.id,"string"!=typeof t.width&&(console.log("Hi! options.width must be a valid css dimension! Defaulting to 90%"),t.width="90%"),t.width||(t.width="90%"),"string"!=typeof t.height&&(console.log("Hi! options.height must be a valid css dimension! Defaulting to 90%"),t.height="90%"),t.height||(t.height="90%"),t.bg&&"string"==typeof t.bg?this.background=t.bg:(console.log("Hi! options.bg must be a valid html color! defaulting to white"),this.background="#ffffff"),this.layout="","string"!=typeof t.layout)throw new Error("Please supply the name of the xml layout");this.layout=t.layout,this.closeOnClickOutside=!0,"boolean"==typeof t.closeOnClickOutside&&(this.closeOnClickOutside=t.closeOnClickOutside),t.onOpen&&"[object Function]"==={}.toString.call(t.onOpen)?this.onOpen=t.onOpen:this.onOpen=function(){},t.onClose&&"[object Function]"==={}.toString.call(t.onClose)?this.onClose=t.onClose:this.onClose=function(){},this.registry={};var e=document.body,i=document.documentElement;let r=Math.max(e.scrollWidth,e.offsetWidth,i.clientWidth,i.scrollWidth,i.offsetWidth),n=Math.max(e.scrollHeight,e.offsetHeight,i.clientHeight,i.scrollHeight,i.offsetHeight);this.opaqueBgStyle=new Style("#"+this.overlayId(),[]),this.containerStyle=new Style("#"+this.containerId(),[]),this.noScrollStyle=new Style(".noscroll",[]),this.closeBtnStyle=new Style("#"+this.closeBtnId(),[]),popupZIndex+=10,this.opaqueBgStyle.addFromOptions({display:"block",visibility:"visible",opacity:"0.8",position:"fixed","background-color":"black",top:"0",left:"0",bottom:"0",right:"0","z-index":popupZIndex+"",width:r+"px",height:n+"px"}),this.noScrollStyle.addFromOptions({overflow:"hidden"}),this.width=t.width,this.height=t.height;var o=this.width,s=this.height,a=this.background;if(this.containerStyle.addFromOptions({position:"absolute",left:"calc(50% - "+o+" / 2 )",top:"calc(50% - "+s+" / 2 )",visibility:"visible",display:"block",padding:"0px",margin:"0px",overflow:"auto",width:o,height:s,"background-color":a,"z-index":popupZIndex+1+"","border-radius":"0.3em"}),"object"==typeof t.containerStyle){var l=t.containerStyle;for(var u in l)this.containerStyle.addStyleElement(u,l[u])}this.closeBtnStyle.addFromOptions({top:"0.1em",right:"0.1em",position:"fixed","font-size":"6rem","font-weight":"bold","font-family":"monospace",cursor:"pointer",color:"white","background-color":"transparent",border:"none",padding:"none"}),this.registerStyle(this.opaqueBgStyle),this.registerStyle(this.containerStyle),this.registerStyle(this.closeBtnStyle),this.registerStyle(this.noScrollStyle)}function Point(t,e){this.x=t,this.y=e}function FloatPoint(t,e,i){Point.call(this,t,e),this.z=i}function midPoint(t,e){return t&&"Point"===t.constructor.name&&e&&"Point"===e.constructor.name?new Point(.5*(t.x+e.x),.5*(t.y+e.y)):null}function midPointF(t,e){return t&&"FloatPoint"===t.constructor.name&&e&&"FloatPoint"===e.constructor.name?new FloatPoint(.5*(t.x+e.x),.5*(t.y+e.y),.5*(t.z+e.z)):null}function Line(t,e){return t&&"FloatPoint"===t.constructor.name&&e&&"FloatPoint"===e.constructor.name&&(this.m=t.findXYGrad(e),this.c=t.y-this.m*t.x),null}function approxEquals(t,e,i){return i||(i=1e-14),"number"==typeof t&&"number"==typeof e&&"number"==typeof i&&Math.abs(Math.abs(t)-Math.abs(e))<=Math.abs(i)}function Dimension(t,e){"number"==typeof t&&"number"==typeof e?(this.width=t,this.height=e):(this.width=0,this.height=0)}function Quadratic(t,e,i){"number"==typeof t&&"number"==typeof e&&"number"==typeof i&&(this.a=t,this.b=e,this.c=i)}function Rectangle(t,e,i,r){this.width=this.height=this.left=this.top=0,"number"==typeof t&&"number"==typeof e&&"number"==typeof i&&"number"==typeof r&&(this.left=t,this.top=e,this.width=i-t,this.height=r-e)}function EllipseModel(t,e,i){t&&"FloatPoint"===t.constructor.name&&"number"==typeof e&&"number"==typeof i?(this.center=t,this.size=new Dimension(e,i)):(this.center=new FloatPoint(0,0,0),this.size=new Dimension(0,0));new Rect}function componentToHex(t){var e=t.toString(16);return 1===e.length?"0"+e:e}function rgbToHEX(t,e,i){return"#"+componentToHex(t)+componentToHex(e)+componentToHex(i)}function hexToRGB(t){t=t.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i,function(t,e,i,r){return e+e+i+i+r+r});var e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return e?{r:parseInt(e[1],16),g:parseInt(e[2],16),b:parseInt(e[3],16),a:1}:null}function getRGB(t){if(!t)throw"supply a color";if(0===(t=t.toLowerCase().trim()).indexOf("rgb")){var e=t.indexOf("("),i=t.indexOf(")");if(-1===e||-1===i)throw"invalid rgb|rgba color";return 3===(t=t.substring(e+1,i).split(",")).length?{r:parseInt(t[0]),g:parseInt(t[1]),b:parseInt(t[2]),a:1}:{r:parseInt(t[0]),g:parseInt(t[1]),b:parseInt(t[2]),a:parseFloat(t[3])}}return hexToRGB(t)}function randomInt(t,e){return Math.floor(Math.random()*(e-t+1))+t}function Random(){}function oneDegInRads(){return Math.PI/180}function angDegToRads(t){return t*Math.PI/180}function angRadToDegs(t){return 180*t/Math.PI}function equals(t,e){return Math.abs(Math.abs(t)-Math.abs(e))<=1e-10}function dragElement(t){var e=0,i=0,r=0,n=0;function o(t){(t=t||window.event).preventDefault(),r=t.clientX,n=t.clientY,document.onmouseup=a,document.onmousemove=s}function s(o){(o=o||window.event).preventDefault(),e=r-o.clientX,i=n-o.clientY,r=o.clientX,n=o.clientY,t.style.top=t.offsetTop-i+"px",t.style.left=t.offsetLeft-e+"px"}function a(){document.onmouseup=null,document.onmousemove=null}document.getElementById(t.id+"header")?document.getElementById(t.id+"header").onmousedown=o:t.onmousedown=o}Popup.prototype.registerStyle=function(t){this.registry[t.name]=t},Popup.prototype.hide=function(){var t=document.getElementById(this.overlayId()),e=document.getElementById(this.containerId());return t&&(t.style.display="none"),e&&(e.style.display="none"),removeClass(document.body,this.noScrollStyle.name.substring(1)),this.onClose(),this},Popup.prototype.open=function(){return this.build(),this},Popup.prototype.build=function(){var t=this;let e=!1;var i=document.getElementById(this.overlayId()),r=document.getElementById(this.containerId());i||(e=!0,(i=document.createElement("div")).setAttribute("id",this.overlayId()),addClass(i,this.overlayClass()),document.body.appendChild(i)),i.style.display="block",i.onclick=function(){t.closeOnClickOutside&&t.hide()},r?r.style.display="block":((r=document.createElement("div")).setAttribute("id",this.containerId()),addClass(r,this.containerClass()),r.innerHTML=this.layout,document.body.appendChild(r));let n=document.getElementById(this.closeBtnId());if(n||(n=document.createElement("input"),n.setAttribute("id",this.closeBtnId()),addClass(n,this.closeBtnClass()),n.type="button",n.value="˟",i.appendChild(n)),n.onclick=function(){t.hide()},e){var o=document.createElement("style");o.setAttribute("type","text/css");var s=new StringBuffer;for(var a in this.registry)s.append(this.registry[a].styleSheetEntry(a));o.innerHTML=s.toString(),document.getElementsByTagName("head")[0].appendChild(o);let t=new Page(r);t.layout(),page.subPages.set(r.id,t)}return addClass(document.body,this.noScrollStyle.name.substring(1)),t.onOpen(),this},Popup.prototype.overlayId=function(){return this.id+"_main_overlay"},Popup.prototype.overlayClass=function(){return this.id+"_main_overlay_class"},Popup.prototype.containerId=function(){return this.id},Popup.prototype.containerClass=function(){return this.id+"_container_class"},Popup.prototype.closeBtnClass=function(){return this.id+"_close_btn_class"},Popup.prototype.closeBtnId=function(){return this.id+"_close_btn_class"},function(t,e){"function"==typeof define&&define.amd?define(e):"object"==typeof exports?module.exports=e():t.ResizeSensor=e()}("undefined"!=typeof window?window:this,function(){if("undefined"==typeof window)return null;var t="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")(),e=t.requestAnimationFrame||t.mozRequestAnimationFrame||t.webkitRequestAnimationFrame||function(e){return t.setTimeout(e,20)},i=t.cancelAnimationFrame||t.mozCancelAnimationFrame||t.webkitCancelAnimationFrame||function(e){t.clearTimeout(e)};function r(t,e){var i=Object.prototype.toString.call(t),r="[object Array]"===i||"[object NodeList]"===i||"[object HTMLCollection]"===i||"[object Object]"===i||"undefined"!=typeof jQuery&&t instanceof jQuery||"undefined"!=typeof Elements&&t instanceof Elements,n=0,o=t.length;if(r)for(;n<o;n++)e(t[n]);else e(t)}function n(t){if(!t.getBoundingClientRect)return{width:t.offsetWidth,height:t.offsetHeight};var e=t.getBoundingClientRect();return{width:Math.round(e.width),height:Math.round(e.height)}}function o(t,e){Object.keys(e).forEach(function(i){t.style[i]=e[i]})}var s=function(t,a){var l=0;function u(){var t,e,i=[];this.add=function(t){i.push(t)},this.call=function(r){for(t=0,e=i.length;t<e;t++)i[t].call(this,r)},this.remove=function(r){var n=[];for(t=0,e=i.length;t<e;t++)i[t]!==r&&n.push(i[t]);i=n},this.length=function(){return i.length}}function h(t,i){if(t)if(t.resizedAttached)t.resizedAttached.add(i);else{t.resizedAttached=new u,t.resizedAttached.add(i),t.resizeSensor=document.createElement("div"),t.resizeSensor.dir="ltr",t.resizeSensor.className="resize-sensor";var r={pointerEvents:"none",position:"absolute",left:"0px",top:"0px",right:"0px",bottom:"0px",overflow:"hidden",zIndex:"-1",visibility:"hidden",maxWidth:"100%"},s={position:"absolute",left:"0px",top:"0px",transition:"0s"};o(t.resizeSensor,r);var a=document.createElement("div");a.className="resize-sensor-expand",o(a,r);var h=document.createElement("div");o(h,s),a.appendChild(h);var c=document.createElement("div");c.className="resize-sensor-shrink",o(c,r);var p=document.createElement("div");o(p,s),o(p,{width:"200%",height:"200%"}),c.appendChild(p),t.resizeSensor.appendChild(a),t.resizeSensor.appendChild(c),t.appendChild(t.resizeSensor);var d=window.getComputedStyle(t),f=d?d.getPropertyValue("position"):null;"absolute"!==f&&"relative"!==f&&"fixed"!==f&&"sticky"!==f&&(t.style.position="relative");var y=!1,g=0,m=n(t),w=0,v=0,b=!0;l=0;var A=function(){if(b){if(0===t.offsetWidth&&0===t.offsetHeight)return void(l||(l=e(function(){l=0,A()})));b=!1}var i,r;i=t.offsetWidth,r=t.offsetHeight,h.style.width=i+10+"px",h.style.height=r+10+"px",a.scrollLeft=i+10,a.scrollTop=r+10,c.scrollLeft=i+10,c.scrollTop=r+10};t.resizeSensor.resetSensor=A;var _=function(){g=0,y&&(w=m.width,v=m.height,t.resizedAttached&&t.resizedAttached.call(m))},E=function(){m=n(t),(y=m.width!==w||m.height!==v)&&!g&&(g=e(_)),A()},x=function(t,e,i){t.attachEvent?t.attachEvent("on"+e,i):t.addEventListener(e,i)};x(a,"scroll",E),x(c,"scroll",E),l=e(function(){l=0,A()})}}r(t,function(t){h(t,a)}),this.detach=function(e){l&&(i(l),l=0),s.detach(t,e)},this.reset=function(){t.resizeSensor.resetSensor&&t.resizeSensor.resetSensor()}};if(s.reset=function(t){r(t,function(e){t.resizeSensor.resetSensor&&e.resizeSensor.resetSensor()})},s.detach=function(t,e){r(t,function(t){t&&(t.resizedAttached&&"function"==typeof e&&(t.resizedAttached.remove(e),t.resizedAttached.length())||t.resizeSensor&&(t.contains(t.resizeSensor)&&t.removeChild(t.resizeSensor),delete t.resizeSensor,delete t.resizedAttached))})},"undefined"!=typeof MutationObserver){var a=new MutationObserver(function(t){for(var e in t)if(t.hasOwnProperty(e))for(var i=t[e].addedNodes,r=0;r<i.length;r++)i[r].resizeSensor&&s.reset(i[r])});document.addEventListener("DOMContentLoaded",function(t){a.observe(document.body,{childList:!0,subtree:!0})})}return s}),function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.ULID={})}(this,function(t){"use strict";function e(t){var e=new Error(t);return e.source="ulid",e}var i="0123456789ABCDEFGHJKMNPQRSTVWXYZ",r=32,n=Math.pow(2,48)-1;function o(t,e,i){return e>t.length-1?t:t.substr(0,e)+i+t.substr(e+1)}function s(t){for(var r=void 0,n=t.length,s=void 0,a=void 0;!r&&n-- >=0;){if(s=t[n],-1===(a=i.indexOf(s)))throw e("incorrectly encoded string");31!==a?r=o(t,n,i[a+1]):t=o(t,n,i[0])}if("string"==typeof r)return r;throw e("cannot increment this string")}function a(t){var e=Math.floor(t()*r);return e===r&&(e=31),i.charAt(e)}function l(t,o){if(isNaN(t))throw new Error(t+" must be a number");if(t>n)throw e("cannot encode time greater than "+n);if(t<0)throw e("time must be positive");if(!1===Number.isInteger(t))throw e("time must be an integer");for(var s=void 0,a="";o>0;o--)a=i.charAt(s=t%r)+a,t=(t-s)/r;return a}function u(t,e){for(var i="";t>0;t--)i=a(e)+i;return i}function h(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],i=arguments[1];i||(i="undefined"!=typeof window?window:null);var r=i&&(i.crypto||i.msCrypto);if(r)return function(){var t=new Uint8Array(1);return r.getRandomValues(t),t[0]/255};try{var n=require("crypto");return function(){return n.randomBytes(1).readUInt8()/255}}catch(t){}if(t){try{console.error("secure crypto unusable, falling back to insecure Math.random()!")}catch(t){}return function(){return Math.random()}}throw e("secure crypto unusable, insecure Math.random not allowed")}function c(t){return t||(t=h()),function(e){return isNaN(e)&&(e=Date.now()),l(e,10)+u(16,t)}}var p=c();t.replaceCharAt=o,t.incrementBase32=s,t.randomChar=a,t.encodeTime=l,t.encodeRandom=u,t.decodeTime=function(t){if(26!==t.length)throw e("malformed ulid");var o=t.substr(0,10).split("").reverse().reduce(function(t,n,o){var s=i.indexOf(n);if(-1===s)throw e("invalid character found: "+n);return t+s*Math.pow(r,o)},0);if(o>n)throw e("malformed ulid, timestamp too large");return o},t.detectPrng=h,t.factory=c,t.monotonicFactory=function(t){t||(t=h());var e=0,i=void 0;return function(r){if(isNaN(r)&&(r=Date.now()),r<=e){var n=i=s(i);return l(e,10)+n}e=r;var o=i=u(16,t);return l(r,10)+o}},t.ulid=p,Object.defineProperty(t,"__esModule",{value:!0})}),
/**
* AutoLayout.js is licensed under the MIT license. If a copy of the
* MIT-license was not distributed with this file, You can obtain one at:
* http://opensource.org/licenses/mit-license.html.
* @link https://github.com/lume/autolayout
*
* @author: Hein Rutjes (IjzerenHein)
* @license MIT
* @copyright Gloey Apps, 2017
*
* @library autolayout.js
* @version 0.7.0
*/
function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).AutoLayout=t()}}(function(){return function t(e,i,r){function n(s,a){if(!i[s]){if(!e[s]){var l="function"==typeof require&&require;if(!a&&l)return l(s,!0);if(o)return o(s,!0);var u=new Error("Cannot find module '"+s+"'");throw u.code="MODULE_NOT_FOUND",u}var h=i[s]={exports:{}};e[s][0].call(h.exports,function(t){var i=e[s][1][t];return n(i||t)},h,h.exports,t,e,i,r)}return i[s].exports}for(var o="function"==typeof require&&require,s=0;s<r.length;s++)n(r[s]);return n}({1:[function(t,e,i){"use strict";var r=function(){function t(t,e){for(var i=0;i<e.length;i++){var r=e[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,i,r){return i&&t(e.prototype,i),r&&t(e,r),e}}();function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var o=t("cassowary/bin/c"),s={CONST:"const",NOTANATTRIBUTE:"const",VARIABLE:"var",LEFT:"left",RIGHT:"right",TOP:"top",BOTTOM:"bottom",WIDTH:"width",HEIGHT:"height",CENTERX:"centerX",CENTERY:"centerY",ZINDEX:"zIndex"},a={LEQ:"leq",EQU:"equ",GEQ:"geq"},l=function(){function t(t,e,i,r,n,o){this.message=t,this.expected=e,this.found=i,this.offset=r,this.line=n,this.column=o,this.name="SyntaxError"}return function(t,e){function i(){this.constructor=t}i.prototype=e.prototype,t.prototype=new i}(t,Error),{SyntaxError:t,parse:function(e){var i,r=arguments.length>1?arguments[1]:{},n={},o={visualFormatString:At},s=At,a=n,l=null,u=":",h={type:"literal",value:":",description:'":"'},c=function(t,e,i,r,n){return{orientation:t?t[0]:"horizontal",cascade:(e||[]).concat([i],[].concat.apply([],r),n||[])}},p="H",d={type:"literal",value:"H",description:'"H"'},f="V",y={type:"literal",value:"V",description:'"V"'},g=function(t){return"H"==t?"horizontal":"vertical"},m="|",w={type:"literal",value:"|",description:'"|"'},v=function(){return{view:null}},b="[",A={type:"literal",value:"[",description:'"["'},_="]",E={type:"literal",value:"]",description:'"]"'},x=function(t,e){return Rt(t,e?{constraints:e}:{})},T="-",S={type:"literal",value:"-",description:'"-"'},I=function(t){return t},C=function(){return[{relation:"equ",constant:"default",$parserOffset:mt()}]},R="",L=function(){return[{relation:"equ",constant:0,$parserOffset:mt()}]},O=function(t){return[{relation:"equ",constant:t,$parserOffset:mt()}]},P="(",N={type:"literal",value:"(",description:'"("'},M=",",B={type:"literal",value:",",description:'","'},V=")",D={type:"literal",value:")",description:'")"'},F=function(t,e){return[t].concat(e.map(function(t){return t[1]}))},W="@",q={type:"literal",value:"@",description:'"@"'},k=function(t,e,i){return Rt({relation:"equ"},t||{},e,i?i[1]:{})},z="==",U={type:"literal",value:"==",description:'"=="'},H=function(){return{relation:"equ",$parserOffset:mt()}},G="<=",j={type:"literal",value:"<=",description:'"<="'},X=function(){return{relation:"leq",$parserOffset:mt()}},K=">=",Y={type:"literal",value:">=",description:'">="'},Q=function(){return{relation:"geq",$parserOffset:mt()}},Z=/^[0-9]/,$={type:"class",value:"[0-9]",description:"[0-9]"},J=function(t){return{priority:parseInt(t.join(""),10)}},tt=function(t){return{constant:t}},et=/^[a-zA-Z_]/,it={type:"class",value:"[a-zA-Z_]",description:"[a-zA-Z_]"},rt=/^[a-zA-Z0-9_]/,nt={type:"class",value:"[a-zA-Z0-9_]",description:"[a-zA-Z0-9_]"},ot=function(t,e){return{view:t+e}},st=".",at={type:"literal",value:".",description:'"."'},lt=function(t,e){return parseFloat(t.concat(".").concat(e).join(""),10)},ut=function(t){return parseInt(t.join(""),10)},ht=0,ct=0,pt=0,dt={line:1,column:1,seenCR:!1},ft=0,yt=[],gt=0;if("startRule"in r){if(!(r.startRule in o))throw new Error("Can't start parsing from rule \""+r.startRule+'".');s=o[r.startRule]}function mt(){return ct}function wt(t){return pt!==t&&(pt>t&&(pt=0,dt={line:1,column:1,seenCR:!1}),function(t,i,r){var n,o;for(n=i;n<r;n++)"\n"===(o=e.charAt(n))?(t.seenCR||t.line++,t.column=1,t.seenCR=!1):"\r"===o||"\u2028"===o||"\u2029"===o?(t.line++,t.column=1,t.seenCR=!0):(t.column++,t.seenCR=!1)}(dt,pt,t),pt=t),dt}function vt(t){ht<ft||(ht>ft&&(ft=ht,yt=[]),yt.push(t))}function bt(i,r,n){var o=wt(n),s=n<e.length?e.charAt(n):null;return null!==r&&function(t){var e=1;for(t.sort(function(t,e){return t.description<e.description?-1:t.description>e.description?1:0});e<t.length;)t[e-1]===t[e]?t.splice(e,1):e++}(r),new t(null!==i?i:function(t,e){var i,r=new Array(t.length);for(i=0;i<t.length;i++)r[i]=t[i].description;return"Expected "+(t.length>1?r.slice(0,-1).join(", ")+" or "+r[t.length-1]:r[0])+" but "+(e?'"'+function(t){function e(t){return t.charCodeAt(0).toString(16).toUpperCase()}return t.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\x08/g,"\\b").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\f/g,"\\f").replace(/\r/g,"\\r").replace(/[\x00-\x07\x0B\x0E\x0F]/g,function(t){return"\\x0"+e(t)}).replace(/[\x10-\x1F\x80-\xFF]/g,function(t){return"\\x"+e(t)}).replace(/[\u0180-\u0FFF]/g,function(t){return"\\u0"+e(t)}).replace(/[\u1080-\uFFFF]/g,function(t){return"\\u"+e(t)})}(e)+'"':"end of input")+" found."}(r,s),r,s,n,o.line,o.column)}function At(){var t,i,r,o,s,m,w,v;if(t=ht,i=ht,r=function(){var t,i;t=ht,72===e.charCodeAt(ht)?(i=p,ht++):(i=n,0===gt&&vt(d));i===n&&(86===e.charCodeAt(ht)?(i=f,ht++):(i=n,0===gt&&vt(y)));i!==n&&(ct=t,i=g(i));return t=i,t}(),r!==n?(58===e.charCodeAt(ht)?(o=u,ht++):(o=n,0===gt&&vt(h)),o!==n?i=r=[r,o]:(ht=i,i=a)):(ht=i,i=a),i===n&&(i=l),i!==n)if(r=ht,(o=_t())!==n&&(s=xt())!==n?r=o=[o,s]:(ht=r,r=a),r===n&&(r=l),r!==n)if((o=Et())!==n){for(s=[],m=ht,(w=xt())!==n&&(v=Et())!==n?m=w=[w,v]:(ht=m,m=a);m!==n;)s.push(m),m=ht,(w=xt())!==n&&(v=Et())!==n?m=w=[w,v]:(ht=m,m=a);s!==n?(m=ht,(w=xt())!==n&&(v=_t())!==n?m=w=[w,v]:(ht=m,m=a),m===n&&(m=l),m!==n?(ct=t,t=i=c(i,r,o,s,m)):(ht=t,t=a)):(ht=t,t=a)}else ht=t,t=a;else ht=t,t=a;else ht=t,t=a;return t}function _t(){var t,i;return t=ht,124===e.charCodeAt(ht)?(i=m,ht++):(i=n,0===gt&&vt(w)),i!==n&&(ct=t,i=v()),t=i}function Et(){var t,i,r,o,s;return t=ht,91===e.charCodeAt(ht)?(i=b,ht++):(i=n,0===gt&&vt(A)),i!==n&&(r=It())!==n?((o=Tt())===n&&(o=l),o!==n?(93===e.charCodeAt(ht)?(s=_,ht++):(s=n,0===gt&&vt(E)),s!==n?(ct=t,t=i=x(r,o)):(ht=t,t=a)):(ht=t,t=a)):(ht=t,t=a),t}function xt(){var t,i,r,o;return t=ht,45===e.charCodeAt(ht)?(i=T,ht++):(i=n,0===gt&&vt(S)),i!==n?(r=function(){var t;t=function(){var t,e;t=ht,e=Ct(),e!==n&&(ct=t,e=O(e));return t=e,t}(),t===n&&(t=Tt());return t}(),r!==n?(45===e.charCodeAt(ht)?(o=T,ht++):(o=n,0===gt&&vt(S)),o!==n?(ct=t,t=i=I(r)):(ht=t,t=a)):(ht=t,t=a)):(ht=t,t=a),t===n&&(t=ht,45===e.charCodeAt(ht)?(i=T,ht++):(i=n,0===gt&&vt(S)),i!==n&&(ct=t,i=C()),(t=i)===n&&(t=ht,(i=R)!==n&&(ct=t,i=L()),t=i)),t}function Tt(){var t,i,r,o,s,l,u;if(t=ht,40===e.charCodeAt(ht)?(i=P,ht++):(i=n,0===gt&&vt(N)),i!==n)if((r=St())!==n){for(o=[],s=ht,44===e.charCodeAt(ht)?(l=M,ht++):(l=n,0===gt&&vt(B)),l!==n&&(u=St())!==n?s=l=[l,u]:(ht=s,s=a);s!==n;)o.push(s),s=ht,44===e.charCodeAt(ht)?(l=M,ht++):(l=n,0===gt&&vt(B)),l!==n&&(u=St())!==n?s=l=[l,u]:(ht=s,s=a);o!==n?(41===e.charCodeAt(ht)?(s=V,ht++):(s=n,0===gt&&vt(D)),s!==n?(ct=t,t=i=F(r,o)):(ht=t,t=a)):(ht=t,t=a)}else ht=t,t=a;else ht=t,t=a;return t}function St(){var t,i,r,o,s,u;return t=ht,i=function(){var t,i;t=ht,e.substr(ht,2)===z?(i=z,ht+=2):(i=n,0===gt&&vt(U));i!==n&&(ct=t,i=H());t=i,t===n&&(t=ht,e.substr(ht,2)===G?(i=G,ht+=2):(i=n,0===gt&&vt(j)),i!==n&&(ct=t,i=X()),(t=i)===n&&(t=ht,e.substr(ht,2)===K?(i=K,ht+=2):(i=n,0===gt&&vt(Y)),i!==n&&(ct=t,i=Q()),t=i));return t}(),i===n&&(i=l),i!==n?(r=function(){var t;t=function(){var t,e;t=ht,e=Ct(),e!==n&&(ct=t,e=tt(e));return t=e,t}(),t===n&&(t=It());return t}(),r!==n?(o=ht,64===e.charCodeAt(ht)?(s=W,ht++):(s=n,0===gt&&vt(q)),s!==n?(u=function(){var t,i,r;t=ht,i=[],Z.test(e.charAt(ht))?(r=e.charAt(ht),ht++):(r=n,0===gt&&vt($));if(r!==n)for(;r!==n;)i.push(r),Z.test(e.charAt(ht))?(r=e.charAt(ht),ht++):(r=n,0===gt&&vt($));else i=a;i!==n&&(ct=t,i=J(i));return t=i,t}(),u!==n?o=s=[s,u]:(ht=o,o=a)):(ht=o,o=a),o===n&&(o=l),o!==n?(ct=t,t=i=k(i,r,o)):(ht=t,t=a)):(ht=t,t=a)):(ht=t,t=a),t}function It(){var t,i,r,o,s;if(t=ht,i=ht,r=[],et.test(e.charAt(ht))?(o=e.charAt(ht),ht++):(o=n,0===gt&&vt(it)),o!==n)for(;o!==n;)r.push(o),et.test(e.charAt(ht))?(o=e.charAt(ht),ht++):(o=n,0===gt&&vt(it));else r=a;if(r!==n&&(r=e.substring(i,ht)),(i=r)!==n){for(r=ht,o=[],rt.test(e.charAt(ht))?(s=e.charAt(ht),ht++):(s=n,0===gt&&vt(nt));s!==n;)o.push(s),rt.test(e.charAt(ht))?(s=e.charAt(ht),ht++):(s=n,0===gt&&vt(nt));o!==n&&(o=e.substring(r,ht)),(r=o)!==n?(ct=t,t=i=ot(i,r)):(ht=t,t=a)}else ht=t,t=a;return t}function Ct(){var t,i,r,o,s;if(t=ht,i=[],Z.test(e.charAt(ht))?(r=e.charAt(ht),ht++):(r=n,0===gt&&vt($)),r!==n)for(;r!==n;)i.push(r),Z.test(e.charAt(ht))?(r=e.charAt(ht),ht++):(r=n,0===gt&&vt($));else i=a;if(i!==n)if(46===e.charCodeAt(ht)?(r=st,ht++):(r=n,0===gt&&vt(at)),r!==n){if(o=[],Z.test(e.charAt(ht))?(s=e.charAt(ht),ht++):(s=n,0===gt&&vt($)),s!==n)for(;s!==n;)o.push(s),Z.test(e.charAt(ht))?(s=e.charAt(ht),ht++):(s=n,0===gt&&vt($));else o=a;o!==n?(ct=t,t=i=lt(i,o)):(ht=t,t=a)}else ht=t,t=a;else ht=t,t=a;if(t===n){if(t=ht,i=[],Z.test(e.charAt(ht))?(r=e.charAt(ht),ht++):(r=n,0===gt&&vt($)),r!==n)for(;r!==n;)i.push(r),Z.test(e.charAt(ht))?(r=e.charAt(ht),ht++):(r=n,0===gt&&vt($));else i=a;i!==n&&(ct=t,i=ut(i)),t=i}return t}function Rt(t){for(var e=1;e<arguments.length;e++)for(var i in arguments[e])t[i]=arguments[e][i];return t}if((i=s())!==n&&ht===e.length)return i;throw i!==n&&ht<e.length&&vt({type:"end",description:"end of input"}),bt(null,yt,ft)}}}(),u=function(){function t(t,e,i,r,n,o){this.message=t,this.expected=e,this.found=i,this.offset=r,this.line=n,this.column=o,this.name="SyntaxError"}return function(t,e){function i(){this.constructor=t}i.prototype=e.prototype,t.prototype=new i}(t,Error),{SyntaxError:t,parse:function(e){var i,r=arguments.length>1?arguments[1]:{},n={},o={visualFormatStringExt:Ge},s=Ge,a=n,l="C:",u={type:"literal",value:"C:",description:'"C:"'},h=null,c=function(t,e,i,r){return{type:"attribute",view:t.view,attributes:[e].concat(i)}},p=function(t,e){return{attr:t,predicates:e}},d=":",f={type:"literal",value:":",description:'":"'},y=function(t,e,i,r,n,o){return{type:"vfl",orientation:t?t[0]:"horizontal",cascade:(e||[]).concat(i,[].concat.apply([],r),n||[])}},g="HV",m={type:"literal",value:"HV",description:'"HV"'},w=function(){return"horzvert"},v="H",b={type:"literal",value:"H",description:'"H"'},A=function(){return"horizontal"},_="V",E={type:"literal",value:"V",description:'"V"'},x=function(){return"vertical"},T="Z",S={type:"literal",value:"Z",description:'"Z"'},I=function(){return"zIndex"},C=" ",R={type:"literal",value:" ",description:'" "'},L="//",O={type:"literal",value:"//",description:'"//"'},P={type:"any",description:"any character"},N="|",M={type:"literal",value:"|",description:'"|"'},B=function(){return{view:null}},V="[",D={type:"literal",value:"[",description:'"["'},F=",",W={type:"literal",value:",",description:'","'},q="]",k={type:"literal",value:"]",description:'"]"'},z=function(t,e){return e.length?[t].concat([].concat.apply([],e)):t},U=function(t,e,i){return li(li(t,e?{constraints:e}:{}),i?{cascade:i}:{})},H=function(t,e){return[].concat([].concat.apply([],t),[e])},G="->",j={type:"literal",value:"->",description:'"->"'},X=function(){return[{relation:"none"}]},K="-",Y={type:"literal",value:"-",description:'"-"'},Q=function(t){return t},Z=function(){return[{relation:"equ",constant:"default"}]},$="~",J={type:"literal",value:"~",description:'"~"'},tt=function(){return[{relation:"equ",equalSpacing:!0}]},et="",it=function(){return[{relation:"equ",constant:0}]},rt=function(t){return[{relation:"equ",multiplier:t.multiplier}]},nt=function(t){return[{relation:"equ",constant:t}]},ot="(",st={type:"literal",value:"(",description:'"("'},at=")",lt={type:"literal",value:")",description:'")"'},ut=function(t,e){return[t].concat(e.map(function(t){return t[1]}))},ht="@",ct={type:"literal",value:"@",description:'"@"'},pt=function(t,e,i){return li({relation:"equ"},t||{},e,i?i[1]:{})},dt=function(t,e,i){return li({relation:"equ",equalSpacing:!0},t||{},e,i?i[1]:{})},ft="==",yt={type:"literal",value:"==",description:'"=="'},gt=function(){return{relation:"equ"}},mt="<=",wt={type:"literal",value:"<=",description:'"<="'},vt=function(){return{relation:"leq"}},bt=">=",At={type:"literal",value:">=",description:'">="'},_t=function(){return{relation:"geq"}},Et=/^[0-9]/,xt={type:"class",value:"[0-9]",description:"[0-9]"},Tt=function(t){return{priority:parseInt(t.join(""),10)}},St=function(t){return{constant:t}},It=function(t){return{constant:-t}},Ct="+",Rt={type:"literal",value:"+",description:'"+"'},Lt="%",Ot={type:"literal",value:"%",description:'"%"'},Pt=function(t){return{view:null,multiplier:t/100}},Nt=function(t){return{view:null,multiplier:t/-100}},Mt=function(t,e,i,r){return{view:t.view,attribute:e||void 0,multiplier:i||1,constant:r||void 0}},Bt=".left",Vt={type:"literal",value:".left",description:'".left"'},Dt=function(){return"left"},Ft=".right",Wt={type:"literal",value:".right",description:'".right"'},qt=function(){return"right"},kt=".top",zt={type:"literal",value:".top",description:'".top"'},Ut=function(){return"top"},Ht=".bottom",Gt={type:"literal",value:".bottom",description:'".bottom"'},jt=function(){return"bottom"},Xt=".width",Kt={type:"literal",value:".width",description:'".width"'},Yt=function(){return"width"},Qt=".height",Zt={type:"literal",value:".height",description:'".height"'},$t=function(){return"height"},Jt=".centerX",te={type:"literal",value:".centerX",description:'".centerX"'},ee=function(){return"centerX"},ie=".centerY",re={type:"literal",value:".centerY",description:'".centerY"'},ne=function(){return"centerY"},oe="/",se={type:"literal",value:"/",description:'"/"'},ae=function(t){return 1/t},le="/+",ue={type:"literal",value:"/+",description:'"/+"'},he="/-",ce={type:"literal",value:"/-",description:'"/-"'},pe=function(t){return-1/t},de="*",fe={type:"literal",value:"*",description:'"*"'},ye=function(t){return t},ge="*+",me={type:"literal",value:"*+",description:'"*+"'},we="*-",ve={type:"literal",value:"*-",description:'"*-"'},be=function(t){return-t},Ae=/^[a-zA-Z_]/,_e={type:"class",value:"[a-zA-Z_]",description:"[a-zA-Z_]"},Ee=/^[a-zA-Z0-9_]/,xe={type:"class",value:"[a-zA-Z0-9_]",description:"[a-zA-Z0-9_]"},Te=function(t,e,i){return{view:t+e,range:i,$parserOffset:ke()}},Se=function(t,e){return{view:t+e,$parserOffset:ke()}},Ie="..",Ce={type:"literal",value:"..",description:'".."'},Re=function(t){return parseInt(t)},Le=".",Oe={type:"literal",value:".",description:'"."'},Pe=function(t,e){return parseFloat(t.concat(".").concat(e).join(""),10)},Ne=function(t){return parseInt(t.join(""),10)},Me=0,Be=0,Ve=0,De={line:1,column:1,seenCR:!1},Fe=0,We=[],qe=0;if("startRule"in r){if(!(r.startRule in o))throw new Error("Can't start parsing from rule \""+r.startRule+'".');s=o[r.startRule]}function ke(){return Be}function ze(t){return Ve!==t&&(Ve>t&&(Ve=0,De={line:1,column:1,seenCR:!1}),function(t,i,r){var n,o;for(n=i;n<r;n++)"\n"===(o=e.charAt(n))?(t.seenCR||t.line++,t.column=1,t.seenCR=!1):"\r"===o||"\u2028"===o||"\u2029"===o?(t.line++,t.column=1,t.seenCR=!0):(t.column++,t.seenCR=!1)}(De,Ve,t),Ve=t),De}function Ue(t){Me<Fe||(Me>Fe&&(Fe=Me,We=[]),We.push(t))}function He(i,r,n){var o=ze(n),s=n<e.length?e.charAt(n):null;return null!==r&&function(t){var e=1;for(t.sort(function(t,e){return t.description<e.description?-1:t.description>e.description?1:0});e<t.length;)t[e-1]===t[e]?t.splice(e,1):e++}(r),new t(null!==i?i:function(t,e){var i,r=new Array(t.length);for(i=0;i<t.length;i++)r[i]=t[i].description;return"Expected "+(t.length>1?r.slice(0,-1).join(", ")+" or "+r[t.length-1]:r[0])+" but "+(e?'"'+function(t){function e(t){return t.charCodeAt(0).toString(16).toUpperCase()}return t.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\x08/g,"\\b").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\f/g,"\\f").replace(/\r/g,"\\r").replace(/[\x00-\x07\x0B\x0E\x0F]/g,function(t){return"\\x0"+e(t)}).replace(/[\x10-\x1F\x80-\xFF]/g,function(t){return"\\x"+e(t)}).replace(/[\u0180-\u0FFF]/g,function(t){return"\\u0"+e(t)}).replace(/[\u1080-\uFFFF]/g,function(t){return"\\u"+e(t)})}(e)+'"':"end of input")+" found."}(r,s),r,s,n,o.line,o.column)}function Ge(){var t;return(t=function(){var t,i,r,o,s,l,u,c;t=Me,i=Me,r=function(){var t,i;t=Me,e.substr(Me,2)===g?(i=g,Me+=2):(i=n,0===qe&&Ue(m));i!==n&&(Be=t,i=w());t=i,t===n&&(t=Me,72===e.charCodeAt(Me)?(i=v,Me++):(i=n,0===qe&&Ue(b)),i!==n&&(Be=t,i=A()),(t=i)===n&&(t=Me,86===e.charCodeAt(Me)?(i=_,Me++):(i=n,0===qe&&Ue(E)),i!==n&&(Be=t,i=x()),(t=i)===n&&(t=Me,90===e.charCodeAt(Me)?(i=T,Me++):(i=n,0===qe&&Ue(S)),i!==n&&(Be=t,i=I()),t=i)));return t}(),r!==n?(58===e.charCodeAt(Me)?(o=d,Me++):(o=n,0===qe&&Ue(f)),o!==n?i=r=[r,o]:(Me=i,i=a)):(Me=i,i=a);i===n&&(i=h);if(i!==n)if(r=Me,(o=Ke())!==n&&(s=Ze())!==n?r=o=[o,s]:(Me=r,r=a),r===n&&(r=h),r!==n)if((o=Ye())!==n){for(s=[],l=Me,(u=Ze())!==n&&(c=Ye())!==n?l=u=[u,c]:(Me=l,l=a);l!==n;)s.push(l),l=Me,(u=Ze())!==n&&(c=Ye())!==n?l=u=[u,c]:(Me=l,l=a);s!==n?(l=Me,(u=Ze())!==n&&(c=Ke())!==n?l=u=[u,c]:(Me=l,l=a),l===n&&(l=h),l!==n?((u=Xe())===n&&(u=h),u!==n?(Be=t,t=i=y(i,r,o,s,l,u)):(Me=t,t=a)):(Me=t,t=a)):(Me=t,t=a)}else Me=t,t=a;else Me=t,t=a;else Me=t,t=a;return t}())===n&&(t=function(){var t,i,r,o,s,p;t=Me,e.substr(Me,2)===l?(i=l,Me+=2):(i=n,0===qe&&Ue(u));if(i!==n)if((r=si())!==n)if((o=je())!==n){for(s=[],p=je();p!==n;)s.push(p),p=je();s!==n?((p=Xe())===n&&(p=h),p!==n?(Be=t,t=i=c(r,o,s,p)):(Me=t,t=a)):(Me=t,t=a)}else Me=t,t=a;else Me=t,t=a;else Me=t,t=a;return t}()),t}function je(){var t,e,i;return t=Me,(e=oi())!==n&&(i=$e())!==n?(Be=t,t=e=p(e,i)):(Me=t,t=a),t}function Xe(){var t,i,r,o,s;for(t=Me,i=[],32===e.charCodeAt(Me)?(r=C,Me++):(r=n,0===qe&&Ue(R));r!==n;)i.push(r),32===e.charCodeAt(Me)?(r=C,Me++):(r=n,0===qe&&Ue(R));if(i!==n)if(e.substr(Me,2)===L?(r=L,Me+=2):(r=n,0===qe&&Ue(O)),r!==n){for(o=[],e.length>Me?(s=e.charAt(Me),Me++):(s=n,0===qe&&Ue(P));s!==n;)o.push(s),e.length>Me?(s=e.charAt(Me),Me++):(s=n,0===qe&&Ue(P));o!==n?t=i=[i,r,o]:(Me=t,t=a)}else Me=t,t=a;else Me=t,t=a;return t}function Ke(){var t,i;return t=Me,124===e.charCodeAt(Me)?(i=N,Me++):(i=n,0===qe&&Ue(M)),i!==n&&(Be=t,i=B()),t=i}function Ye(){var t,i,r,o,s,l,u;if(t=Me,91===e.charCodeAt(Me)?(i=V,Me++):(i=n,0===qe&&Ue(D)),i!==n)if((r=Qe())!==n){for(o=[],s=Me,44===e.charCodeAt(Me)?(l=F,Me++):(l=n,0===qe&&Ue(W)),l!==n&&(u=Qe())!==n?s=l=[l,u]:(Me=s,s=a);s!==n;)o.push(s),s=Me,44===e.charCodeAt(Me)?(l=F,Me++):(l=n,0===qe&&Ue(W)),l!==n&&(u=Qe())!==n?s=l=[l,u]:(Me=s,s=a);o!==n?(93===e.charCodeAt(Me)?(s=q,Me++):(s=n,0===qe&&Ue(k)),s!==n?(Be=t,t=i=z(r,o)):(Me=t,t=a)):(Me=t,t=a)}else Me=t,t=a;else Me=t,t=a;return t}function Qe(){var t,i,r,o;return t=Me,i=function(){var t,i,r,o,s;t=Me,i=Me,r=[],Ae.test(e.charAt(Me))?(o=e.charAt(Me),Me++):(o=n,0===qe&&Ue(_e));if(o!==n)for(;o!==n;)r.push(o),Ae.test(e.charAt(Me))?(o=e.charAt(Me),Me++):(o=n,0===qe&&Ue(_e));else r=a;r!==n&&(r=e.substring(i,Me));if(i=r,i!==n){for(r=Me,o=[],Ee.test(e.charAt(Me))?(s=e.charAt(Me),Me++):(s=n,0===qe&&Ue(xe));s!==n;)o.push(s),Ee.test(e.charAt(Me))?(s=e.charAt(Me),Me++):(s=n,0===qe&&Ue(xe));o!==n&&(o=e.substring(r,Me)),(r=o)!==n?(o=function(){var t,i,r,o;t=Me,e.substr(Me,2)===Ie?(i=Ie,Me+=2):(i=n,0===qe&&Ue(Ce));if(i!==n){if(r=[],Et.test(e.charAt(Me))?(o=e.charAt(Me),Me++):(o=n,0===qe&&Ue(xt)),o!==n)for(;o!==n;)r.push(o),Et.test(e.charAt(Me))?(o=e.charAt(Me),Me++):(o=n,0===qe&&Ue(xt));else r=a;r!==n?(Be=t,t=i=Re(r)):(Me=t,t=a)}else Me=t,t=a;return t}(),o!==n?(Be=t,t=i=Te(i,r,o)):(Me=t,t=a)):(Me=t,t=a)}else Me=t,t=a;if(t===n){if(t=Me,i=Me,r=[],Ae.test(e.charAt(Me))?(o=e.charAt(Me),Me++):(o=n,0===qe&&Ue(_e)),o!==n)for(;o!==n;)r.push(o),Ae.test(e.charAt(Me))?(o=e.charAt(Me),Me++):(o=n,0===qe&&Ue(_e));else r=a;if(r!==n&&(r=e.substring(i,Me)),(i=r)!==n){for(r=Me,o=[],Ee.test(e.charAt(Me))?(s=e.charAt(Me),Me++):(s=n,0===qe&&Ue(xe));s!==n;)o.push(s),Ee.test(e.charAt(Me))?(s=e.charAt(Me),Me++):(s=n,0===qe&&Ue(xe));o!==n&&(o=e.substring(r,Me)),(r=o)!==n?(Be=t,t=i=Se(i,r)):(Me=t,t=a)}else Me=t,t=a}return t}(),i!==n?((r=$e())===n&&(r=h),r!==n?(o=function(){var t,i,r,o,s,l;t=Me,58===e.charCodeAt(Me)?(i=d,Me++):(i=n,0===qe&&Ue(f));if(i!==n){if(r=[],o=Me,(s=Ze())!==n&&(l=Ye())!==n?o=s=[s,l]:(Me=o,o=a),o!==n)for(;o!==n;)r.push(o),o=Me,(s=Ze())!==n&&(l=Ye())!==n?o=s=[s,l]:(Me=o,o=a);else r=a;r!==n&&(o=Ze())!==n?(Be=t,t=i=H(r,o)):(Me=t,t=a)}else Me=t,t=a;return t}(),o===n&&(o=h),o!==n?(Be=t,t=i=U(i,r,o)):(Me=t,t=a)):(Me=t,t=a)):(Me=t,t=a),t}function Ze(){var t,i,r,o;return t=Me,e.substr(Me,2)===G?(i=G,Me+=2):(i=n,0===qe&&Ue(j)),i!==n&&(Be=t,i=X()),(t=i)===n&&(t=Me,45===e.charCodeAt(Me)?(i=K,Me++):(i=n,0===qe&&Ue(Y)),i!==n?(r=function(){var t;t=function(){var t,e;t=Me,e=ni(),e!==n&&(Be=t,e=rt(e));t=e,t===n&&(t=Me,(e=ai())!==n&&(Be=t,e=nt(e)),t=e);return t}(),t===n&&(t=$e());return t}(),r!==n?(45===e.charCodeAt(Me)?(o=K,Me++):(o=n,0===qe&&Ue(Y)),o!==n?(Be=t,t=i=Q(r)):(Me=t,t=a)):(Me=t,t=a)):(Me=t,t=a),t===n&&(t=Me,45===e.charCodeAt(Me)?(i=K,Me++):(i=n,0===qe&&Ue(Y)),i!==n&&(Be=t,i=Z()),(t=i)===n&&(t=Me,126===e.charCodeAt(Me)?(i=$,Me++):(i=n,0===qe&&Ue(J)),i!==n?(r=function(){var t,i,r,o,s,l,u;t=Me,40===e.charCodeAt(Me)?(i=ot,Me++):(i=n,0===qe&&Ue(st));if(i!==n)if((r=ti())!==n){for(o=[],s=Me,44===e.charCodeAt(Me)?(l=F,Me++):(l=n,0===qe&&Ue(W)),l!==n&&(u=ti())!==n?s=l=[l,u]:(Me=s,s=a);s!==n;)o.push(s),s=Me,44===e.charCodeAt(Me)?(l=F,Me++):(l=n,0===qe&&Ue(W)),l!==n&&(u=ti())!==n?s=l=[l,u]:(Me=s,s=a);o!==n?(41===e.charCodeAt(Me)?(s=at,Me++):(s=n,0===qe&&Ue(lt)),s!==n?(Be=t,t=i=ut(r,o)):(Me=t,t=a)):(Me=t,t=a)}else Me=t,t=a;else Me=t,t=a;return t}(),r!==n?(126===e.charCodeAt(Me)?(o=$,Me++):(o=n,0===qe&&Ue(J)),o!==n?(Be=t,t=i=Q(r)):(Me=t,t=a)):(Me=t,t=a)):(Me=t,t=a),t===n&&(t=Me,126===e.charCodeAt(Me)?(i=$,Me++):(i=n,0===qe&&Ue(J)),i!==n&&(Be=t,i=tt()),(t=i)===n&&(t=Me,(i=et)!==n&&(Be=t,i=it()),t=i))))),t}function $e(){var t,i,r,o,s,l,u;if(t=Me,40===e.charCodeAt(Me)?(i=ot,Me++):(i=n,0===qe&&Ue(st)),i!==n)if((r=Je())!==n){for(o=[],s=Me,44===e.charCodeAt(Me)?(l=F,Me++):(l=n,0===qe&&Ue(W)),l!==n&&(u=Je())!==n?s=l=[l,u]:(Me=s,s=a);s!==n;)o.push(s),s=Me,44===e.charCodeAt(Me)?(l=F,Me++):(l=n,0===qe&&Ue(W)),l!==n&&(u=Je())!==n?s=l=[l,u]:(Me=s,s=a);o!==n?(41===e.charCodeAt(Me)?(s=at,Me++):(s=n,0===qe&&Ue(lt)),s!==n?(Be=t,t=i=ut(r,o)):(Me=t,t=a)):(Me=t,t=a)}else Me=t,t=a;else Me=t,t=a;return t}function Je(){var t,i,r,o,s,l;return t=Me,(i=ei())===n&&(i=h),i!==n&&(r=ii())!==n?(o=Me,64===e.charCodeAt(Me)?(s=ht,Me++):(s=n,0===qe&&Ue(ct)),s!==n&&(l=ri())!==n?o=s=[s,l]:(Me=o,o=a),o===n&&(o=h),o!==n?(Be=t,t=i=pt(i,r,o)):(Me=t,t=a)):(Me=t,t=a),t}function ti(){var t,i,r,o,s,l;return t=Me,(i=ei())===n&&(i=h),i!==n&&(r=ii())!==n?(o=Me,64===e.charCodeAt(Me)?(s=ht,Me++):(s=n,0===qe&&Ue(ct)),s!==n&&(l=ri())!==n?o=s=[s,l]:(Me=o,o=a),o===n&&(o=h),o!==n?(Be=t,t=i=dt(i,r,o)):(Me=t,t=a)):(Me=t,t=a),t}function ei(){var t,i;return t=Me,e.substr(Me,2)===ft?(i=ft,Me+=2):(i=n,0===qe&&Ue(yt)),i!==n&&(Be=t,i=gt()),(t=i)===n&&(t=Me,e.substr(Me,2)===mt?(i=mt,Me+=2):(i=n,0===qe&&Ue(wt)),i!==n&&(Be=t,i=vt()),(t=i)===n&&(t=Me,e.substr(Me,2)===bt?(i=bt,Me+=2):(i=n,0===qe&&Ue(At)),i!==n&&(Be=t,i=_t()),t=i)),t}function ii(){var t;return(t=ni())===n&&(t=function(){var t,i,r;t=Me,(i=ai())!==n&&(Be=t,i=St(i));t=i,t===n&&(t=Me,45===e.charCodeAt(Me)?(i=K,Me++):(i=n,0===qe&&Ue(Y)),i!==n&&(r=ai())!==n?(Be=t,t=i=It(r)):(Me=t,t=a),t===n&&(t=Me,43===e.charCodeAt(Me)?(i=Ct,Me++):(i=n,0===qe&&Ue(Rt)),i!==n&&(r=ai())!==n?(Be=t,t=i=St(r)):(Me=t,t=a)));return t}())===n&&(t=function(){var t,i,r,o,s;t=Me,(i=si())!==n?((r=oi())===n&&(r=h),r!==n?(o=function(){var t,i,r;t=Me,47===e.charCodeAt(Me)?(i=oe,Me++):(i=n,0===qe&&Ue(se));i!==n&&(r=ai())!==n?(Be=t,t=i=ae(r)):(Me=t,t=a);t===n&&(t=Me,e.substr(Me,2)===le?(i=le,Me+=2):(i=n,0===qe&&Ue(ue)),i!==n&&(r=ai())!==n?(Be=t,t=i=ae(r)):(Me=t,t=a),t===n&&(t=Me,e.substr(Me,2)===he?(i=he,Me+=2):(i=n,0===qe&&Ue(ce)),i!==n&&(r=ai())!==n?(Be=t,t=i=pe(r)):(Me=t,t=a),t===n&&(t=Me,42===e.charCodeAt(Me)?(i=de,Me++):(i=n,0===qe&&Ue(fe)),i!==n&&(r=ai())!==n?(Be=t,t=i=ye(r)):(Me=t,t=a),t===n&&(t=Me,e.substr(Me,2)===ge?(i=ge,Me+=2):(i=n,0===qe&&Ue(me)),i!==n&&(r=ai())!==n?(Be=t,t=i=ye(r)):(Me=t,t=a),t===n&&(t=Me,e.substr(Me,2)===we?(i=we,Me+=2):(i=n,0===qe&&Ue(ve)),i!==n&&(r=ai())!==n?(Be=t,t=i=be(r)):(Me=t,t=a))))));return t}(),o===n&&(o=h),o!==n?(s=function(){var t,i,r;t=Me,45===e.charCodeAt(Me)?(i=K,Me++):(i=n,0===qe&&Ue(Y));i!==n&&(r=ai())!==n?(Be=t,t=i=be(r)):(Me=t,t=a);t===n&&(t=Me,43===e.charCodeAt(Me)?(i=Ct,Me++):(i=n,0===qe&&Ue(Rt)),i!==n&&(r=ai())!==n?(Be=t,t=i=ye(r)):(Me=t,t=a));return t}(),s===n&&(s=h),s!==n?(Be=t,t=i=Mt(i,r,o,s)):(Me=t,t=a)):(Me=t,t=a)):(Me=t,t=a)):(Me=t,t=a);return t}()),t}function ri(){var t,i,r;if(t=Me,i=[],Et.test(e.charAt(Me))?(r=e.charAt(Me),Me++):(r=n,0===qe&&Ue(xt)),r!==n)for(;r!==n;)i.push(r),Et.test(e.charAt(Me))?(r=e.charAt(Me),Me++):(r=n,0===qe&&Ue(xt));else i=a;return i!==n&&(Be=t,i=Tt(i)),t=i}function ni(){var t,i,r,o;return t=Me,(i=ai())!==n?(37===e.charCodeAt(Me)?(r=Lt,Me++):(r=n,0===qe&&Ue(Ot)),r!==n?(Be=t,t=i=Pt(i)):(Me=t,t=a)):(Me=t,t=a),t===n&&(t=Me,45===e.charCodeAt(Me)?(i=K,Me++):(i=n,0===qe&&Ue(Y)),i!==n&&(r=ai())!==n?(37===e.charCodeAt(Me)?(o=Lt,Me++):(o=n,0===qe&&Ue(Ot)),o!==n?(Be=t,t=i=Nt(r)):(Me=t,t=a)):(Me=t,t=a),t===n&&(t=Me,43===e.charCodeAt(Me)?(i=Ct,Me++):(i=n,0===qe&&Ue(Rt)),i!==n&&(r=ai())!==n?(37===e.charCodeAt(Me)?(o=Lt,Me++):(o=n,0===qe&&Ue(Ot)),o!==n?(Be=t,t=i=Pt(r)):(Me=t,t=a)):(Me=t,t=a))),t}function oi(){var t,i;return t=Me,e.substr(Me,5)===Bt?(i=Bt,Me+=5):(i=n,0===qe&&Ue(Vt)),i!==n&&(Be=t,i=Dt()),(t=i)===n&&(t=Me,e.substr(Me,6)===Ft?(i=Ft,Me+=6):(i=n,0===qe&&Ue(Wt)),i!==n&&(Be=t,i=qt()),(t=i)===n&&(t=Me,e.substr(Me,4)===kt?(i=kt,Me+=4):(i=n,0===qe&&Ue(zt)),i!==n&&(Be=t,i=Ut()),(t=i)===n&&(t=Me,e.substr(Me,7)===Ht?(i=Ht,Me+=7):(i=n,0===qe&&Ue(Gt)),i!==n&&(Be=t,i=jt()),(t=i)===n&&(t=Me,e.substr(Me,6)===Xt?(i=Xt,Me+=6):(i=n,0===qe&&Ue(Kt)),i!==n&&(Be=t,i=Yt()),(t=i)===n&&(t=Me,e.substr(Me,7)===Qt?(i=Qt,Me+=7):(i=n,0===qe&&Ue(Zt)),i!==n&&(Be=t,i=$t()),(t=i)===n&&(t=Me,e.substr(Me,8)===Jt?(i=Jt,Me+=8):(i=n,0===qe&&Ue(te)),i!==n&&(Be=t,i=ee()),(t=i)===n&&(t=Me,e.substr(Me,8)===ie?(i=ie,Me+=8):(i=n,0===qe&&Ue(re)),i!==n&&(Be=t,i=ne()),t=i))))))),t}function si(){var t,i,r,o,s;if(t=Me,i=Me,r=[],Ae.test(e.charAt(Me))?(o=e.charAt(Me),Me++):(o=n,0===qe&&Ue(_e)),o!==n)for(;o!==n;)r.push(o),Ae.test(e.charAt(Me))?(o=e.charAt(Me),Me++):(o=n,0===qe&&Ue(_e));else r=a;if(r!==n&&(r=e.substring(i,Me)),(i=r)!==n){for(r=Me,o=[],Ee.test(e.charAt(Me))?(s=e.charAt(Me),Me++):(s=n,0===qe&&Ue(xe));s!==n;)o.push(s),Ee.test(e.charAt(Me))?(s=e.charAt(Me),Me++):(s=n,0===qe&&Ue(xe));o!==n&&(o=e.substring(r,Me)),(r=o)!==n?(Be=t,t=i=Se(i,r)):(Me=t,t=a)}else Me=t,t=a;return t}function ai(){var t,i,r,o,s;if(t=Me,i=[],Et.test(e.charAt(Me))?(r=e.charAt(Me),Me++):(r=n,0===qe&&Ue(xt)),r!==n)for(;r!==n;)i.push(r),Et.test(e.charAt(Me))?(r=e.charAt(Me),Me++):(r=n,0===qe&&Ue(xt));else i=a;if(i!==n)if(46===e.charCodeAt(Me)?(r=Le,Me++):(r=n,0===qe&&Ue(Oe)),r!==n){if(o=[],Et.test(e.charAt(Me))?(s=e.charAt(Me),Me++):(s=n,0===qe&&Ue(xt)),s!==n)for(;s!==n;)o.push(s),Et.test(e.charAt(Me))?(s=e.charAt(Me),Me++):(s=n,0===qe&&Ue(xt));else o=a;o!==n?(Be=t,t=i=Pe(i,o)):(Me=t,t=a)}else Me=t,t=a;else Me=t,t=a;if(t===n){if(t=Me,i=[],Et.test(e.charAt(Me))?(r=e.charAt(Me),Me++):(r=n,0===qe&&Ue(xt)),r!==n)for(;r!==n;)i.push(r),Et.test(e.charAt(Me))?(r=e.charAt(Me),Me++):(r=n,0===qe&&Ue(xt));else i=a;i!==n&&(Be=t,i=Ne(i)),t=i}return t}function li(t){for(var e=1;e<arguments.length;e++)for(var i in arguments[e])t[i]=arguments[e][i];return t}if((i=s())!==n&&Me===e.length)return i;throw i!==n&&Me<e.length&&Ue({type:"end",description:"end of input"}),He(null,We,Fe)}}}(),h=1,c=2,p=4;function d(t,e){t.equalSpacerIndex=t.equalSpacerIndex||1;var i="_~"+t.lineIndex+":"+t.equalSpacerIndex+"~";t.equalSpacerIndex>1&&t.constraints.push({view1:"_~"+t.lineIndex+":1~",attr1:t.horizontal?s.WIDTH:s.HEIGHT,relation:t.relation.relation||a.EQU,view2:i,attr2:t.horizontal?s.WIDTH:s.HEIGHT,priority:t.relation.priority}),t.equalSpacerIndex++,t.relation.view||t.relation.multiplier&&1!==t.relation.multiplier?(t.constraints.push({view1:i,attr1:t.horizontal?s.WIDTH:s.HEIGHT,relation:t.relation.relation||a.EQU,view2:t.relation.view,attr2:t.horizontal?s.WIDTH:s.HEIGHT,priority:t.relation.priority,multiplier:t.relation.multiplier}),t.relation.multiplier=void 0):t.relation.constant&&(t.constraints.push({view1:i,attr1:t.horizontal?s.WIDTH:s.HEIGHT,relation:a.EQU,view2:null,attr2:s.CONST,priority:t.relation.priority,constant:t.relation.constant}),t.relation.constant=void 0);for(var r=0;r<t.prevViews.length;r++){var n=t.prevViews[r];switch(t.orientation){case h:t.prevAttr=n!==e?s.RIGHT:s.LEFT,t.curAttr=s.LEFT;break;case c:t.prevAttr=n!==e?s.BOTTOM:s.TOP,t.curAttr=s.TOP;break;case p:t.prevAttr=s.ZINDEX,t.curAttr=s.ZINDEX,t.relation.constant=n!==e?"default":0}t.constraints.push({view1:n,attr1:t.prevAttr,relation:t.relation.relation,view2:i,attr2:t.curAttr,priority:t.relation.priority})}t.prevViews=[i]}function f(t,e){t.proportionalSpacerIndex=t.proportionalSpacerIndex||1;var i="_-"+t.lineIndex+":"+t.proportionalSpacerIndex+"-";t.proportionalSpacerIndex++,t.constraints.push({view1:i,attr1:t.horizontal?s.WIDTH:s.HEIGHT,relation:t.relation.relation||a.EQU,view2:t.relation.view,attr2:t.horizontal?s.WIDTH:s.HEIGHT,priority:t.relation.priority,multiplier:t.relation.multiplier}),t.relation.multiplier=void 0;for(var r=0;r<t.prevViews.length;r++){var n=t.prevViews[r];switch(t.orientation){case h:t.prevAttr=n!==e?s.RIGHT:s.LEFT,t.curAttr=s.LEFT;break;case c:t.prevAttr=n!==e?s.BOTTOM:s.TOP,t.curAttr=s.TOP;break;case p:t.prevAttr=s.ZINDEX,t.curAttr=s.ZINDEX,t.relation.constant=n!==e?"default":0}t.constraints.push({view1:n,attr1:t.prevAttr,relation:t.relation.relation,view2:i,attr2:t.curAttr,priority:t.relation.priority})}t.prevViews=[i]}function y(t,e,i){for(var r=void 0,n=1;n<=4;n*=2)if(i.orientations&n&&i.stack.orientation!==n&&!(i.stack.processedOrientations&n)){i.stack.processedOrientations=i.stack.processedOrientations|n,r=r||{name:e,type:"stack"};for(var o=0,l=i.stack.subViews.length;o<l;o++)n===p?t.constraints.push({view1:r,attr1:s.ZINDEX,relation:a.EQU,view2:i.stack.subViews[o],attr2:s.ZINDEX}):(t.constraints.push({view1:r,attr1:n===c?s.HEIGHT:s.WIDTH,relation:a.EQU,view2:i.stack.subViews[o],attr2:n===c?s.HEIGHT:s.WIDTH}),t.constraints.push({view1:r,attr1:n===c?s.TOP:s.LEFT,relation:a.EQU,view2:i.stack.subViews[o],attr2:n===c?s.TOP:s.LEFT}))}}function g(t,e){if(!0===e&&(e=t.match(/\.\.\d+$/))&&(t=t.substring(0,t.length-e[0].length),e=parseInt(e[0].substring(2))),!e)return[t];var i,r=t.match(/\d+$/),n=[];if(r)for(t=t.substring(0,t.length-r[0].length),i=parseInt(r);i<=e;i++)n.push(t+i);else for(n.push(t),i=2;i<=e;i++)n.push(t+i);return n}function m(t,e,i){var r=i?i.view:null,n=[],o=[],a=void 0;r&&(e.push({view:r}),o.push(r));for(var l=0;l<e.length;l++){var u=e[l];if(!Array.isArray(u)&&u.hasOwnProperty("view")||Array.isArray(u)&&u[0].view&&!u[0].relation)for(var w=Array.isArray(u)?u:[u],v=0;v<w.length;v++)for(var b=","===(u=w[v])?[]:u.view?g(u.view,u.range):[null],A=0;A<b.length;A++){var _=b[A];if(o.push(_),_!==r&&(n.push(_),(a=t.subViews[_])||(a={orientations:0},t.subViews[_]=a),a.orientations=a.orientations|t.orientation,a.stack&&y(t,_,a)),void 0!==t.prevViews&&void 0!==_&&t.relation&&"none"!==t.relation.relation)for(var E=0;E<t.prevViews.length;E++){var x=t.prevViews[E];switch(t.orientation){case h:t.prevAttr=x!==r?s.RIGHT:s.LEFT,t.curAttr=_!==r?s.LEFT:s.RIGHT;break;case c:t.prevAttr=x!==r?s.BOTTOM:s.TOP,t.curAttr=_!==r?s.TOP:s.BOTTOM;break;case p:t.prevAttr=s.ZINDEX,t.curAttr=s.ZINDEX,t.relation.constant=x?t.relation.constant||"default":0}t.constraints.push({view1:x,attr1:t.prevAttr,relation:t.relation.relation,view2:_,attr2:t.curAttr,multiplier:t.relation.multiplier,constant:"default"!==t.relation.constant&&t.relation.constant?-t.relation.constant:t.relation.constant,priority:t.relation.priority})}var T=u.constraints;if(T)for(var S=0;S<T.length;S++)t.prevAttr=t.horizontal?s.WIDTH:s.HEIGHT,t.curAttr=T[S].view||T[S].multiplier?T[S].attribute||t.prevAttr:T[S].variable?s.VARIABLE:s.CONST,t.constraints.push({view1:_,attr1:t.prevAttr,relation:T[S].relation,view2:T[S].view,attr2:t.curAttr,multiplier:T[S].multiplier,constant:T[S].constant,priority:T[S].priority});u.cascade&&m(t,u.cascade,u)}else","!==u&&(t.prevViews=o,o=[],t.relation=u[0],void 0!==t.prevViews&&(t.relation.equalSpacing&&d(t,r),t.relation.multiplier&&f(t,r)))}if(r){if(a=t.subViews[r]){if(a.stack){var I=new Error('A stack named "'+r+'" has already been created');throw I.column=i.$parserOffset+1,I}}else a={orientations:t.orientation},t.subViews[r]=a;a.stack={orientation:t.orientation,processedOrientations:t.orientation,subViews:n},y(t,r,a)}}var w=["viewport","spacing","colors","shapes","widths","heights"],v=function(){function t(){n(this,t)}return r(t,null,[{key:"parseLine",value:function(t,e){if(0===t.length||e&&e.extended&&0===t.indexOf("//"))return[];var i=e&&e.extended?u.parse(t):l.parse(t);if(e&&"raw"===e.outFormat)return[i];var r={constraints:[],lineIndex:(e?e.lineIndex:void 0)||1,subViews:(e?e.subViews:void 0)||{}};if("attribute"===i.type)for(var n=0;n<i.attributes.length;n++)for(var o=i.attributes[n],s=0;s<o.predicates.length;s++){var a=o.predicates[s];r.constraints.push({view1:i.view,attr1:o.attr,relation:a.relation,view2:a.view,attr2:a.attribute||o.attr,multiplier:a.multiplier,constant:a.constant,priority:a.priority})}else switch(i.orientation){case"horizontal":r.orientation=h,r.horizontal=!0,m(r,i.cascade,null);break;case"vertical":r.orientation=c,m(r,i.cascade,null);break;case"horzvert":r.orientation=h,r.horizontal=!0,m(r,i.cascade,null),m(r={constraints:r.constraints,lineIndex:r.lineIndex,subViews:r.subViews,orientation:c},i.cascade,null);break;case"zIndex":r.orientation=p,m(r,i.cascade,null)}return r.constraints}},{key:"parse",value:function(t,e){var i=e&&e.lineSeparator?e.lineSeparator:"\n";if(!Array.isArray(t)&&t.indexOf(i)<0)try{return this.parseLine(t,e)}catch(e){throw e.source=t,e}t=Array.isArray(t)?t:[t];var r=void 0,n=[],o=0,s=void 0,a={lineIndex:o,extended:e&&e.extended,strict:!e||void 0===e.strict||e.strict,outFormat:e?e.outFormat:void 0,subViews:{}};try{for(var l=0;l<t.length;l++){r=t[l].split(i);for(var u=0;u<r.length;u++)s=r[u],o++,a.lineIndex=o,a.strict||(s=s.trim()),(a.strict||s.length)&&(n=n.concat(this.parseLine(s,a)))}}catch(t){throw t.source=s,t.line=o,t}return n}},{key:"parseMetaInfo",value:function(t,e){var i=e&&e.lineSeparator?e.lineSeparator:"\n",r=e?e.prefix:void 0;t=Array.isArray(t)?t:[t];for(var n,o={},s=0;s<t.length;s++)for(var a=t[s].split(i),l=0;l<a.length;l++)for(var u=a[l],h=0;h<w.length;h++)for(var c=0;c<(r?2:1);c++){var p=w[h],d=(0===c?"":r)+p;if(0===u.indexOf("//"+d+" "))for(var f=u.substring(3+d.length).split(" "),y=0;y<f.length;y++){o[p]=o[p]||{};for(var m=f[y].split(":"),v=g(m[0],!0),b=0;b<v.length;b++)o[p][v[b]]=m.length>1?m[1]:""}else 0===u.indexOf("//"+d+":")&&(o[p]=u.substring(3+d.length))}if(o.viewport){var A=o.viewport,_=A["aspect-ratio"];_&&(_=_.split("/"),A["aspect-ratio"]=parseInt(_[0])/parseInt(_[1])),void 0!==A.height&&(A.height="intrinsic"===A.height||parseInt(A.height)),void 0!==A.width&&(A.width="intrinsic"===A.width||parseInt(A.width)),void 0!==A["max-height"]&&(A["max-height"]=parseInt(A["max-height"])),void 0!==A["max-width"]&&(A["max-width"]=parseInt(A["max-width"])),void 0!==A["min-height"]&&(A["min-height"]=parseInt(A["min-height"])),void 0!==A["min-width"]&&(A["min-width"]=parseInt(A["min-width"]))}if(o.widths)for(n in o.widths){var E="intrinsic"===o.widths[n]||parseInt(o.widths[n]);o.widths[n]=E,(void 0===E||isNaN(E))&&delete o.widths[n]}if(o.heights)for(n in o.heights){var x="intrinsic"===o.heights[n]||parseInt(o.heights[n]);o.heights[n]=x,(void 0===x||isNaN(x))&&delete o.heights[n]}if(o.spacing){var T=JSON.parse(o.spacing);if(o.spacing=T,Array.isArray(T)){for(var S=0,I=T.length;S<I;S++)if(isNaN(T[S])){delete o.spacing;break}}else(void 0===T||isNaN(T))&&delete o.spacing}return o}}]),t}(),b=function(){function t(e){n(this,t),this._name=e.name,this._type=e.type,this._solver=e.solver,this._attr={},e.name||(this._attr[s.LEFT]=new o.Variable,this._solver.addConstraint(new o.StayConstraint(this._attr[s.LEFT],o.Strength.required)),this._attr[s.TOP]=new o.Variable,this._solver.addConstraint(new o.StayConstraint(this._attr[s.TOP],o.Strength.required)),this._attr[s.ZINDEX]=new o.Variable,this._solver.addConstraint(new o.StayConstraint(this._attr[s.ZINDEX],o.Strength.required)))}return r(t,[{key:"toJSON",value:function(){return{name:this.name,left:this.left,top:this.top,width:this.width,height:this.height}}},{key:"toString",value:function(){JSON.stringify(this.toJSON(),void 0,2)}},{key:"getValue",value:function(t){return this._attr[t]?this._attr[t].value():void 0}},{key:"_getAttr",value:function(t){if(this._attr[t])return this._attr[t];switch(this._attr[t]=new o.Variable,t){case s.RIGHT:this._getAttr(s.LEFT),this._getAttr(s.WIDTH),this._solver.addConstraint(new o.Equation(this._attr[t],o.plus(this._attr[s.LEFT],this._attr[s.WIDTH])));break;case s.BOTTOM:this._getAttr(s.TOP),this._getAttr(s.HEIGHT),this._solver.addConstraint(new o.Equation(this._attr[t],o.plus(this._attr[s.TOP],this._attr[s.HEIGHT])));break;case s.CENTERX:this._getAttr(s.LEFT),this._getAttr(s.WIDTH),this._solver.addConstraint(new o.Equation(this._attr[t],o.plus(this._attr[s.LEFT],o.divide(this._attr[s.WIDTH],2))));break;case s.CENTERY:this._getAttr(s.TOP),this._getAttr(s.HEIGHT),this._solver.addConstraint(new o.Equation(this._attr[t],o.plus(this._attr[s.TOP],o.divide(this._attr[s.HEIGHT],2))))}return this._attr[t]}},{key:"_getAttrValue",value:function(t){return this._getAttr(t).value}},{key:"name",get:function(){return this._name}},{key:"left",get:function(){return this._getAttrValue(s.LEFT)}},{key:"right",get:function(){return this._getAttrValue(s.RIGHT)}},{key:"width",get:function(){return this._getAttrValue(s.WIDTH)}},{key:"height",get:function(){return this._getAttrValue(s.HEIGHT)}},{key:"intrinsicWidth",get:function(){return this._intrinsicWidth},set:function(t){if(void 0!==t&&t!==this._intrinsicWidth){var e=this._getAttr(s.WIDTH);void 0===this._intrinsicWidth&&this._solver.addEditVar(e,new o.Strength("required",this._name?998:999,1e3,1e3)),this._intrinsicWidth=t,this._solver.suggestValue(e,t),this._solver.resolve()}}},{key:"intrinsicHeight",get:function(){return this._intrinsicHeight},set:function(t){if(void 0!==t&&t!==this._intrinsicHeight){var e=this._getAttr(s.HEIGHT);void 0===this._intrinsicHeight&&this._solver.addEditVar(e,new o.Strength("required",this._name?998:999,1e3,1e3)),this._intrinsicHeight=t,this._solver.suggestValue(e,t),this._solver.resolve()}}},{key:"top",get:function(){return this._getAttrValue(s.TOP)}},{key:"bottom",get:function(){return this._getAttrValue(s.BOTTOM)}},{key:"centerX",get:function(){return this._getAttrValue(s.CENTERX)}},{key:"centerY",get:function(){return this._getAttrValue(s.CENTERY)}},{key:"zIndex",get:function(){return this._getAttrValue(s.ZINDEX)}},{key:"type",get:function(){return this._type}}]),t}(),A=new o.Strength("defaultPriority",0,1e3,1e3);function _(t,e){var i=new o.Variable({value:e});return this._solver.addConstraint(new o.StayConstraint(i,o.Strength.required,0)),i}function E(t){return t?t.name?(this._subViews[t.name]=this._subViews[t.name]||new b({name:t.name,solver:this._solver}),this._subViews[t.name]._type=this._subViews[t.name]._type||t.type,this._subViews[t.name]):(this._subViews[t]=this._subViews[t]||new b({name:t,solver:this._solver}),this._subViews[t]):this._parentSubView}function x(t){var e=4;if(t.view1||"left"!==t.attr1)if(t.view1||"top"!==t.attr1)if(t.view2||"right"!==t.attr2)if(t.view2||"bottom"!==t.attr2)switch(t.attr1){case"left":case"right":case"centerX":case"leading":case"trailing":e=4;break;case"zIndex":e=6;break;default:e=5}else e=2;else e=1;else e=0;else e=3;return this._spacingVars=this._spacingVars||new Array(7),this._spacingExpr=this._spacingExpr||new Array(7),this._spacingVars[e]||(this._spacingVars[e]=new o.Variable,this._solver.addEditVar(this._spacingVars[e]),this._spacingExpr[e]=o.minus(0,this._spacingVars[e]),this._solver.suggestValue(this._spacingVars[e],this._spacing[e])),this._spacingExpr[e]}function T(t){var e=void 0,i=void 0!==t.multiplier?t.multiplier:1,r=void 0!==t.constant?t.constant:0;"default"===r&&(r=x.call(this,t));var n=E.call(this,t.view1)._getAttr(t.attr1),l=void 0;t.attr2===s.CONST?l=_.call(this,void 0,t.constant):(l=E.call(this,t.view2)._getAttr(t.attr2),1!==i&&r?l=o.plus(o.times(l,i),r):r?l=o.plus(l,r):1!==i&&(l=o.times(l,i)));var u=void 0!==t.priority&&t.priority<1e3?new o.Strength("priority",0,t.priority,1e3):A;switch(t.relation){case a.EQU:e=new o.Equation(n,l,u);break;case a.GEQ:e=new o.Inequality(n,o.GEQ,l,u);break;case a.LEQ:e=new o.Inequality(n,o.LEQ,l,u);break;default:throw"Invalid relation specified: "+t.relation}this._solver.addConstraint(e)}var S=function(){function t(e){n(this,t),this._solver=new o.SimplexSolver,this._subViews={},this._parentSubView=new b({solver:this._solver}),this.setSpacing(e&&void 0!==e.spacing?e.spacing:8),e&&(void 0===e.width&&void 0===e.height||this.setSize(e.width,e.height),e.constraints&&this.addConstraints(e.constraints))}return r(t,[{key:"setSize",value:function(t,e){return this._parentSubView.intrinsicWidth=t,this._parentSubView.intrinsicHeight=e,this}},{key:"setSpacing",value:function(t){switch(Array.isArray(t)?t.length:-1){case-1:t=[t,t,t,t,t,t,1];break;case 1:t=[t[0],t[0],t[0],t[0],t[0],t[0],1];break;case 2:t=[t[1],t[0],t[1],t[0],t[0],t[1],1];break;case 3:t=[t[1],t[0],t[1],t[0],t[0],t[1],t[2]];break;case 6:t=[t[0],t[1],t[2],t[3],t[4],t[5],1];break;case 7:break;default:throw"Invalid spacing syntax"}if(!function(t,e){if(t===e)return!0;if(!t||!e)return!1;for(var i=0;i<7;i++)if(t[i]!==e[i])return!1;return!0}(this._spacing,t)&&(this._spacing=t,this._spacingVars)){for(var e=0;e<this._spacingVars.length;e++)this._spacingVars[e]&&this._solver.suggestValue(this._spacingVars[e],this._spacing[e]);this._solver.resolve()}return this}},{key:"addConstraint",value:function(t){return T.call(this,t),this}},{key:"addConstraints",value:function(t){for(var e=0;e<t.length;e++)T.call(this,t[e]);return this}},{key:"width",get:function(){return this._parentSubView.intrinsicWidth}},{key:"height",get:function(){return this._parentSubView.intrinsicHeight}},{key:"fittingWidth",get:function(){return this._parentSubView.width}},{key:"fittingHeight",get:function(){return this._parentSubView.height}},{key:"subViews",get:function(){return this._subViews}}]),t}(),I={Attribute:s,Relation:a,Priority:{REQUIRED:1e3,DEFAULTHIGH:750,DEFAULTLOW:250},VisualFormat:v,View:S,SubView:b};e.exports=I},{"cassowary/bin/c":2}],2:[function(t,e,i){(function(){var i;(function(i){"use strict";try{(function(){}).bind(i)}catch(t){Object.defineProperty(Function.prototype,"bind",{value:function(t){var e=this;return function(){return e.apply(t,arguments)}},enumerable:!1,configurable:!0,writable:!0})}var r=void 0!==i.HTMLElement,n=1e-8,o={},s=function(t,e){if(t&&e){if("function"==typeof t[e])return t[e];var i=t.prototype;if(i&&"function"==typeof i[e])return i[e];if(i!==Object.prototype&&i!==Function.prototype)return"function"==typeof t.__super__?s(t.__super__,e):void 0}},a=i.c={debug:!1,trace:!1,verbose:!1,traceAdded:!1,GC:!1,GEQ:1,LEQ:2,inherit:function(t){var e=null,n=null;t.extends&&(n=t.extends,delete t.extends),t.initialize&&(e=t.initialize,delete t.initialize);var s=e||function(){};Object.defineProperty(s,"__super__",{value:n||Object,enumerable:!1,configurable:!0,writable:!1}),t._t&&(o[t._t]=s);var a=s.prototype=Object.create(n?n.prototype:Object.prototype);if(this.extend(a,t),r&&n&&n.prototype instanceof i.HTMLElement){var l=s,u=function(t){for(var e=null;t&&t!=Object.prototype;){if(t.tagName){e=t.tagName;break}t=t.prototype}return e||"div"}(a),h=function(t){return t.__proto__=a,l.apply(t,arguments),a.created&&t.created(),a.decorate&&t.decorate(),t};this.extend(a,{upgrade:h}),(s=function(){return h(i.document.createElement(u))}).prototype=a,this.extend(s,{ctor:l})}return s},extend:function(t,e){return this.own(e,function(i){var r=Object.getOwnPropertyDescriptor(e,i);try{"function"==typeof r.get||"function"==typeof r.set?Object.defineProperty(t,i,r):"function"==typeof r.value||"_"===i.charAt(0)?(r.writable=!0,r.configurable=!0,r.enumerable=!1,Object.defineProperty(t,i,r)):t[i]=e[i]}catch(t){}}),t},own:function(t,e,r){return Object.getOwnPropertyNames(t).forEach(e,r||i),t},traceprint:function(t){a.verbose&&console.log(t)},fnenterprint:function(t){console.log("* "+t)},fnexitprint:function(t){console.log("- "+t)},assert:function(t,e){if(!t)throw new a.InternalError("Assertion failed: "+e)},plus:function(t,e){return t instanceof a.Expression||(t=new a.Expression(t)),e instanceof a.Expression||(e=new a.Expression(e)),t.plus(e)},minus:function(t,e){return t instanceof a.Expression||(t=new a.Expression(t)),e instanceof a.Expression||(e=new a.Expression(e)),t.minus(e)},times:function(t,e){return("number"==typeof t||t instanceof a.Variable)&&(t=new a.Expression(t)),("number"==typeof e||e instanceof a.Variable)&&(e=new a.Expression(e)),t.times(e)},divide:function(t,e){return("number"==typeof t||t instanceof a.Variable)&&(t=new a.Expression(t)),("number"==typeof e||e instanceof a.Variable)&&(e=new a.Expression(e)),t.divide(e)},approx:function(t,e){return t===e||(i=t instanceof a.Variable?t.value:t,r=e instanceof a.Variable?e.value:e,0==i?n>Math.abs(r):0==r?n>Math.abs(i):Math.abs(i-r)<Math.abs(i)*n);var i,r},_inc:function(t){return function(){return t++}}(0),parseJSON:function(t){return JSON.parse(t,function(t,e){if("object"!=typeof e||"string"!=typeof e._t)return e;var i=e._t,r=o[i];if(i&&r){var n=s(r,"fromJSON");if(n)return n(e,r)}return e})}};"function"==typeof t&&void 0!==e&&"undefined"==typeof load&&(i.exports=a)})(this),function(t){"use strict";var e=function(t){return t.hashCode?t.hashCode:""+t},i=function(t,e){Object.keys(t).forEach(function(i){e[i]=t[i]})},r={};t.HashTable=t.inherit({initialize:function(){this.size=0,this._store={},this._keyStrMap={},this._deleted=0},set:function(t,i){var r=e(t);this._store.hasOwnProperty(r)||this.size++,this._store[r]=i,this._keyStrMap[r]=t},get:function(t){return this.size?(t=e(t),void 0!==this._store[t]?this._store[t]:null):null},clear:function(){this.size=0,this._store={},this._keyStrMap={}},_compact:function(){var t={};i(this._store,t),this._store=t},_compactThreshold:100,_perhapsCompact:function(){this._size>64||this._deleted>this._compactThreshold&&(this._compact(),this._deleted=0)},delete:function(t){t=e(t),this._store.hasOwnProperty(t)&&(this._deleted++,delete this._store[t],this.size>0&&this.size--)},each:function(t,e){if(this.size){this._perhapsCompact();var i=this._store,r=this._keyStrMap;Object.keys(this._store).forEach(function(n){t.call(e||null,r[n],i[n])},this)}},escapingEach:function(t,e){if(this.size){this._perhapsCompact();for(var i=this,n=this._store,o=this._keyStrMap,s=r,a=Object.keys(n),l=0;a.length>l;l++)if(function(r){i._store.hasOwnProperty(r)&&(s=t.call(e||null,o[r],n[r]))}(a[l]),s){if(void 0!==s.retval)return s;if(s.brk)break}}},clone:function(){var e=new t.HashTable;return this.size&&(e.size=this.size,i(this._store,e._store),i(this._keyStrMap,e._keyStrMap)),e},equals:function(e){if(e===this)return!0;if(!(e instanceof t.HashTable)||e._size!==this._size)return!1;for(var i=Object.keys(this._store),r=0;i.length>r;r++){var n=i[r];if(this._keyStrMap[n]!==e._keyStrMap[n]||this._store[n]!==e._store[n])return!1}return!0},toString:function(){var t="";return this.each(function(e,i){t+=e+" => "+i+"\n"}),t}})}(this.c||e.parent.exports||{}),function(t){"use strict";t.HashSet=t.inherit({_t:"c.HashSet",initialize:function(){this.storage=[],this.size=0},add:function(t){var e=this.storage;e.indexOf(t),-1==e.indexOf(t)&&e.push(t),this.size=this.storage.length},values:function(){return this.storage},has:function(t){return-1!=this.storage.indexOf(t)},delete:function(t){var e=this.storage.indexOf(t);return-1==e?null:(this.storage.splice(e,1)[0],void(this.size=this.storage.length))},clear:function(){this.storage.length=0},each:function(t,e){this.size&&this.storage.forEach(t,e)},escapingEach:function(t,e){this.size&&this.storage.forEach(t,e)},toString:function(){var t=this.size+" {",e=!0;return this.each(function(i){e?e=!1:t+=", ",t+=i}),t+="}\n"},toJSON:function(){var t=[];return this.each(function(e){t.push(e.toJSON())}),{_t:"c.HashSet",data:t}},fromJSON:function(e){var i=new t.HashSet;return e.data&&(i.size=e.data.length,i.storage=e.data),i}})}(this.c||e.parent.exports||{}),function(t){"use strict";t.Error=t.inherit({initialize:function(t){t&&(this._description=t)},_name:"c.Error",_description:"An error has occured in Cassowary",set description(t){this._description=t},get description(){return"("+this._name+") "+this._description},get message(){return this.description},toString:function(){return this.description}});var e=function(e,i){return t.inherit({extends:t.Error,initialize:function(){t.Error.apply(this,arguments)},_name:e||"",_description:i||""})};t.ConstraintNotFound=e("c.ConstraintNotFound","Tried to remove a constraint never added to the tableu"),t.InternalError=e("c.InternalError"),t.NonExpression=e("c.NonExpression","The resulting expression would be non"),t.NotEnoughStays=e("c.NotEnoughStays","There are not enough stays to give specific values to every variable"),t.RequiredFailure=e("c.RequiredFailure","A required constraint cannot be satisfied"),t.TooDifficult=e("c.TooDifficult","The constraints are too difficult to solve")}(this.c||e.parent.exports||{}),function(t){"use strict";t.SymbolicWeight=t.inherit({_t:"c.SymbolicWeight",initialize:function(){this.value=0;for(var t=1,e=arguments.length-1;e>=0;--e)this.value+=arguments[e]*t,t*=1e3},toJSON:function(){return{_t:this._t,value:this.value}}})}(this.c||e.parent.exports||{}),(i=this.c||(void 0!==e?e.parent.exports.c:{})).Strength=i.inherit({initialize:function(t,e,r,n){this.name=t,this.symbolicWeight=e instanceof i.SymbolicWeight?e:new i.SymbolicWeight(e,r,n)},get required(){return this===i.Strength.required},toString:function(){return this.name+(this.isRequired?"":":"+this.symbolicWeight)}}),i.Strength.required=new i.Strength("<Required>",1e3,1e3,1e3),i.Strength.strong=new i.Strength("strong",1,0,0),i.Strength.medium=new i.Strength("medium",0,1,0),i.Strength.weak=new i.Strength("weak",0,0,1),function(t){"use strict";t.AbstractVariable=t.inherit({isDummy:!1,isExternal:!1,isPivotable:!1,isRestricted:!1,_init:function(e,i){this.hashCode=t._inc(),this.name=(i||"")+this.hashCode,e&&(void 0!==e.name&&(this.name=e.name),void 0!==e.value&&(this.value=e.value),void 0!==e.prefix&&(this._prefix=e.prefix))},_prefix:"",name:"",value:0,toJSON:function(){var t={};return this._t&&(t._t=this._t),this.name&&(t.name=this.name),void 0!==this.value&&(t.value=this.value),this._prefix&&(t._prefix=this._prefix),this._t&&(t._t=this._t),t},fromJSON:function(e,i){var r=new i;return t.extend(r,e),r},toString:function(){return this._prefix+"["+this.name+":"+this.value+"]"}}),t.Variable=t.inherit({_t:"c.Variable",extends:t.AbstractVariable,initialize:function(e){this._init(e,"v");var i=t.Variable._map;i&&(i[this.name]=this)},isExternal:!0}),t.DummyVariable=t.inherit({_t:"c.DummyVariable",extends:t.AbstractVariable,initialize:function(t){this._init(t,"d")},isDummy:!0,isRestricted:!0,value:"dummy"}),t.ObjectiveVariable=t.inherit({_t:"c.ObjectiveVariable",extends:t.AbstractVariable,initialize:function(t){this._init(t,"o")},value:"obj"}),t.SlackVariable=t.inherit({_t:"c.SlackVariable",extends:t.AbstractVariable,initialize:function(t){this._init(t,"s")},isPivotable:!0,isRestricted:!0,value:"slack"})}(this.c||e.parent.exports||{}),function(t){"use strict";t.Point=t.inherit({initialize:function(e,i,r){if(e instanceof t.Variable)this._x=e;else{var n={value:e};r&&(n.name="x"+r),this._x=new t.Variable(n)}if(i instanceof t.Variable)this._y=i;else{var o={value:i};r&&(o.name="y"+r),this._y=new t.Variable(o)}},get x(){return this._x},set x(e){e instanceof t.Variable?this._x=e:this._x.value=e},get y(){return this._y},set y(e){e instanceof t.Variable?this._y=e:this._y.value=e},toString:function(){return"("+this.x+", "+this.y+")"}})}(this.c||e.parent.exports||{}),function(t){"use strict";t.Expression=t.inherit({initialize:function(e,i,r){t.GC&&console.log("new c.Expression"),this.constant="number"!=typeof r||isNaN(r)?0:r,this.terms=new t.HashTable,e instanceof t.AbstractVariable?this.setVariable(e,"number"==typeof i?i:1):"number"==typeof e&&(isNaN(e)?console.trace():this.constant=e)},initializeFromHash:function(e,i){return t.verbose&&(console.log("*******************************"),console.log("clone c.initializeFromHash"),console.log("*******************************")),t.GC&&console.log("clone c.Expression"),this.constant=e,this.terms=i.clone(),this},multiplyMe:function(t){this.constant*=t;var e=this.terms;return e.each(function(i,r){e.set(i,r*t)}),this},clone:function(){t.verbose&&(console.log("*******************************"),console.log("clone c.Expression"),console.log("*******************************"));var e=new t.Expression;return e.initializeFromHash(this.constant,this.terms),e},times:function(e){if("number"==typeof e)return this.clone().multiplyMe(e);if(this.isConstant)return e.times(this.constant);if(e.isConstant)return this.times(e.constant);throw new t.NonExpression},plus:function(e){return e instanceof t.Expression?this.clone().addExpression(e,1):e instanceof t.Variable?this.clone().addVariable(e,1):void 0},minus:function(e){return e instanceof t.Expression?this.clone().addExpression(e,-1):e instanceof t.Variable?this.clone().addVariable(e,-1):void 0},divide:function(e){if("number"==typeof e){if(t.approx(e,0))throw new t.NonExpression;return this.times(1/e)}if(e instanceof t.Expression){if(!e.isConstant)throw new t.NonExpression;return this.times(1/e.constant)}},addExpression:function(e,i,r,n){return e instanceof t.AbstractVariable&&(e=new t.Expression(e),t.trace&&console.log("addExpression: Had to cast a var to an expression")),i=i||1,this.constant+=i*e.constant,e.terms.each(function(t,e){this.addVariable(t,e*i,r,n)},this),this},addVariable:function(e,i,r,n){null==i&&(i=1),t.trace&&console.log("c.Expression::addVariable():",e,i);var o=this.terms.get(e);if(o){var s=o+i;0==s||t.approx(s,0)?(n&&n.noteRemovedVariable(e,r),this.terms.delete(e)):this.setVariable(e,s)}else t.approx(i,0)||(this.setVariable(e,i),n&&n.noteAddedVariable(e,r));return this},setVariable:function(t,e){return this.terms.set(t,e),this},anyPivotableVariable:function(){if(this.isConstant)throw new t.InternalError("anyPivotableVariable called on a constant");var e=this.terms.escapingEach(function(t){return t.isPivotable?{retval:t}:void 0});return e&&void 0!==e.retval?e.retval:null},substituteOut:function(e,i,r,n){t.trace&&(t.fnenterprint("CLE:substituteOut: "+e+", "+i+", "+r+", ..."),t.traceprint("this = "+this));var o=this.setVariable.bind(this),s=this.terms,a=s.get(e);s.delete(e),this.constant+=a*i.constant,i.terms.each(function(e,i){var l=s.get(e);if(l){var u=l+a*i;t.approx(u,0)?(n.noteRemovedVariable(e,r),s.delete(e)):o(e,u)}else o(e,a*i),n&&n.noteAddedVariable(e,r)}),t.trace&&t.traceprint("Now this is "+this)},changeSubject:function(t,e){this.setVariable(t,this.newSubject(e))},newSubject:function(e){t.trace&&t.fnenterprint("newSubject:"+e);var i=1/this.terms.get(e);return this.terms.delete(e),this.multiplyMe(-i),i},coefficientFor:function(t){return this.terms.get(t)||0},get isConstant(){return 0==this.terms.size},toString:function(){var e="",i=!1;if(!t.approx(this.constant,0)||this.isConstant){if(e+=this.constant,this.isConstant)return e;i=!0}return this.terms.each(function(t,r){i&&(e+=" + "),e+=r+"*"+t,i=!0}),e},equals:function(e){return e===this||e instanceof t.Expression&&e.constant===this.constant&&e.terms.equals(this.terms)},Plus:function(t,e){return t.plus(e)},Minus:function(t,e){return t.minus(e)},Times:function(t,e){return t.times(e)},Divide:function(t,e){return t.divide(e)}})}(this.c||e.parent.exports||{}),function(t){"use strict";t.AbstractConstraint=t.inherit({initialize:function(e,i){this.hashCode=t._inc(),this.strength=e||t.Strength.required,this.weight=i||1},isEditConstraint:!1,isInequality:!1,isStayConstraint:!1,get required(){return this.strength===t.Strength.required},toString:function(){return this.strength+" {"+this.weight+"} ("+this.expression+")"}});var e=t.AbstractConstraint.prototype.toString,i=function(e,i,r){t.AbstractConstraint.call(this,i||t.Strength.strong,r),this.variable=e,this.expression=new t.Expression(e,-1,e.value)};t.EditConstraint=t.inherit({extends:t.AbstractConstraint,initialize:function(){i.apply(this,arguments)},isEditConstraint:!0,toString:function(){return"edit:"+e.call(this)}}),t.StayConstraint=t.inherit({extends:t.AbstractConstraint,initialize:function(){i.apply(this,arguments)},isStayConstraint:!0,toString:function(){return"stay:"+e.call(this)}});var r=t.Constraint=t.inherit({extends:t.AbstractConstraint,initialize:function(e,i,r){t.AbstractConstraint.call(this,i,r),this.expression=e}});t.Inequality=t.inherit({extends:t.Constraint,_cloneOrNewCle:function(e){return e.clone?e.clone():new t.Expression(e)},initialize:function(e,i,n,o,s){var a=e instanceof t.Expression,l=n instanceof t.Expression,u=e instanceof t.AbstractVariable,h=n instanceof t.AbstractVariable,c="number"==typeof e,p="number"==typeof n;if((a||c)&&h){var d=e,f=i,y=n,g=o,m=s;if(r.call(this,this._cloneOrNewCle(d),g,m),f==t.LEQ)this.expression.multiplyMe(-1),this.expression.addVariable(y);else{if(f!=t.GEQ)throw new t.InternalError("Invalid operator in c.Inequality constructor");this.expression.addVariable(y,-1)}}else if(u&&(l||p)){d=n,f=i,y=e,g=o,m=s;if(r.call(this,this._cloneOrNewCle(d),g,m),f==t.GEQ)this.expression.multiplyMe(-1),this.expression.addVariable(y);else{if(f!=t.LEQ)throw new t.InternalError("Invalid operator in c.Inequality constructor");this.expression.addVariable(y,-1)}}else{if(a&&p){var w=e,v=(f=i,n);g=o,m=s;if(r.call(this,this._cloneOrNewCle(w),g,m),f==t.LEQ)this.expression.multiplyMe(-1),this.expression.addExpression(this._cloneOrNewCle(v));else{if(f!=t.GEQ)throw new t.InternalError("Invalid operator in c.Inequality constructor");this.expression.addExpression(this._cloneOrNewCle(v),-1)}return this}if(c&&l){w=n,f=i,v=e,g=o,m=s;if(r.call(this,this._cloneOrNewCle(w),g,m),f==t.GEQ)this.expression.multiplyMe(-1),this.expression.addExpression(this._cloneOrNewCle(v));else{if(f!=t.LEQ)throw new t.InternalError("Invalid operator in c.Inequality constructor");this.expression.addExpression(this._cloneOrNewCle(v),-1)}return this}if(a&&l){w=e,f=i,v=n,g=o,m=s;if(r.call(this,this._cloneOrNewCle(v),g,m),f==t.GEQ)this.expression.multiplyMe(-1),this.expression.addExpression(this._cloneOrNewCle(w));else{if(f!=t.LEQ)throw new t.InternalError("Invalid operator in c.Inequality constructor");this.expression.addExpression(this._cloneOrNewCle(w),-1)}}else{if(a)return r.call(this,e,i,n);if(i==t.GEQ)r.call(this,new t.Expression(n),o,s),this.expression.multiplyMe(-1),this.expression.addVariable(e);else{if(i!=t.LEQ)throw new t.InternalError("Invalid operator in c.Inequality constructor");r.call(this,new t.Expression(n),o,s),this.expression.addVariable(e,-1)}}}},isInequality:!0,toString:function(){return r.prototype.toString.call(this)+" >= 0) id: "+this.hashCode}}),t.Equation=t.inherit({extends:t.Constraint,initialize:function(e,i,n,o){if(e instanceof t.Expression&&!i||i instanceof t.Strength)r.call(this,e,i,n);else if(e instanceof t.AbstractVariable&&i instanceof t.Expression){var s=e,a=i,l=n,u=o;r.call(this,a.clone(),l,u),this.expression.addVariable(s,-1)}else if(e instanceof t.AbstractVariable&&"number"==typeof i){s=e;var h=i;l=n,u=o;r.call(this,new t.Expression(h),l,u),this.expression.addVariable(s,-1)}else if(e instanceof t.Expression&&i instanceof t.AbstractVariable){a=e,s=i,l=n,u=o;r.call(this,a.clone(),l,u),this.expression.addVariable(s,-1)}else{if(!(e instanceof t.Expression||e instanceof t.AbstractVariable||"number"==typeof e)||!(i instanceof t.Expression||i instanceof t.AbstractVariable||"number"==typeof i))throw"Bad initializer to c.Equation";e=e instanceof t.Expression?e.clone():new t.Expression(e),i=i instanceof t.Expression?i.clone():new t.Expression(i),r.call(this,e,n,o),this.expression.addExpression(i,-1)}t.assert(this.strength instanceof t.Strength,"_strength not set")},toString:function(){return r.prototype.toString.call(this)+" = 0)"}})}(this.c||e.parent.exports||{}),function(t){"use strict";t.EditInfo=t.inherit({initialize:function(t,e,i,r,n){this.constraint=t,this.editPlus=e,this.editMinus=i,this.prevEditConstant=r,this.index=n},toString:function(){return"<cn="+this.constraint+", ep="+this.editPlus+", em="+this.editMinus+", pec="+this.prevEditConstant+", index="+this.index+">"}})}(this.c||e.parent.exports||{}),function(t){"use strict";t.Tableau=t.inherit({initialize:function(){this.columns=new t.HashTable,this.rows=new t.HashTable,this._infeasibleRows=new t.HashSet,this._externalRows=new t.HashSet,this._externalParametricVars=new t.HashSet},noteRemovedVariable:function(e,i){t.trace&&console.log("c.Tableau::noteRemovedVariable: ",e,i);var r=this.columns.get(e);i&&r&&r.delete(i)},noteAddedVariable:function(t,e){e&&this.insertColVar(t,e)},getInternalInfo:function(){var t="Tableau Information:\n";return t+="Rows: "+this.rows.size,t+=" (= "+(this.rows.size-1)+" constraints)",t+="\nColumns: "+this.columns.size,t+="\nInfeasible Rows: "+this._infeasibleRows.size,t+="\nExternal basic variables: "+this._externalRows.size,t+="\nExternal parametric variables: ",(t+=this._externalParametricVars.size)+"\n"},toString:function(){var t="Tableau:\n";return this.rows.each(function(e,i){t+=e,t+=" <==> ",t+=i,t+="\n"}),t+="\nColumns:\n",t+=this.columns,t+="\nInfeasible rows: ",t+=this._infeasibleRows,t+="External basic variables: ",t+=this._externalRows,t+="External parametric variables: ",t+=this._externalParametricVars},insertColVar:function(e,i){var r=this.columns.get(e);r||(r=new t.HashSet,this.columns.set(e,r)),r.add(i)},addRow:function(e,i){t.trace&&t.fnenterprint("addRow: "+e+", "+i),this.rows.set(e,i),i.terms.each(function(t){this.insertColVar(t,e),t.isExternal&&this._externalParametricVars.add(t)},this),e.isExternal&&this._externalRows.add(e),t.trace&&t.traceprint(""+this)},removeColumn:function(e){t.trace&&t.fnenterprint("removeColumn:"+e);var i=this.columns.get(e);i?(this.columns.delete(e),i.each(function(t){this.rows.get(t).terms.delete(e)},this)):t.trace&&console.log("Could not find var",e,"in columns"),e.isExternal&&(this._externalRows.delete(e),this._externalParametricVars.delete(e))},removeRow:function(e){t.trace&&t.fnenterprint("removeRow:"+e);var i=this.rows.get(e);return t.assert(null!=i),i.terms.each(function(i){var r=this.columns.get(i);null!=r&&(t.trace&&console.log("removing from varset:",e),r.delete(e))},this),this._infeasibleRows.delete(e),e.isExternal&&this._externalRows.delete(e),this.rows.delete(e),t.trace&&t.fnexitprint("returning "+i),i},substituteOut:function(e,i){t.trace&&t.fnenterprint("substituteOut:"+e+", "+i),t.trace&&t.traceprint(""+this),this.columns.get(e).each(function(t){var r=this.rows.get(t);r.substituteOut(e,i,t,this),t.isRestricted&&0>r.constant&&this._infeasibleRows.add(t)},this),e.isExternal&&(this._externalRows.add(e),this._externalParametricVars.delete(e)),this.columns.delete(e)},columnsHasKey:function(t){return!!this.columns.get(t)}})}(this.c||e.parent.exports||{}),function(t){var e=t.Tableau.prototype,i=t.Strength.weak;t.SimplexSolver=t.inherit({extends:t.Tableau,initialize:function(){t.Tableau.call(this),this._stayMinusErrorVars=[],this._stayPlusErrorVars=[],this._errorVars=new t.HashTable,this._markerVars=new t.HashTable,this._objective=new t.ObjectiveVariable({name:"Z"}),this._editVarMap=new t.HashTable,this._editVarList=[],this._slackCounter=0,this._artificialCounter=0,this._dummyCounter=0,this.autoSolve=!0,this._fNeedsSolving=!1,this._optimizeCount=0,this.rows.set(this._objective,new t.Expression),this._stkCedcns=[0],t.trace&&t.traceprint("objective expr == "+this.rows.get(this._objective))},addLowerBound:function(e,i){var r=new t.Inequality(e,t.GEQ,new t.Expression(i));return this.addConstraint(r)},addUpperBound:function(e,i){var r=new t.Inequality(e,t.LEQ,new t.Expression(i));return this.addConstraint(r)},addBounds:function(t,e,i){return this.addLowerBound(t,e),this.addUpperBound(t,i),this},add:function(){for(var t=0;arguments.length>t;t++)this.addConstraint(arguments[t]);return this},addConstraint:function(e){t.trace&&t.fnenterprint("addConstraint: "+e);var i=Array(2),r=Array(1),n=this.newExpression(e,i,r);if(r=r[0],this.tryAddingDirectly(n)||this.addWithArtificialVariable(n),this._fNeedsSolving=!0,e.isEditConstraint){var o=this._editVarMap.size,s=i[0],a=i[1];!s instanceof t.SlackVariable&&console.warn("cvEplus not a slack variable =",s),!a instanceof t.SlackVariable&&console.warn("cvEminus not a slack variable =",a),t.debug&&console.log("new c.EditInfo("+e+", "+s+", "+a+", "+r+", "+o+")");var l=new t.EditInfo(e,s,a,r,o);this._editVarMap.set(e.variable,l),this._editVarList[o]={v:e.variable,info:l}}return this.autoSolve&&(this.optimize(this._objective),this._setExternalVariables()),this},addConstraintNoException:function(e){t.trace&&t.fnenterprint("addConstraintNoException: "+e);try{return this.addConstraint(e),!0}catch(t){return!1}},addEditVar:function(e,i){return t.trace&&t.fnenterprint("addEditVar: "+e+" @ "+i),this.addConstraint(new t.EditConstraint(e,i||t.Strength.strong))},beginEdit:function(){return t.assert(this._editVarMap.size>0,"_editVarMap.size > 0"),this._infeasibleRows.clear(),this._resetStayConstants(),this._stkCedcns.push(this._editVarMap.size),this},endEdit:function(){return t.assert(this._editVarMap.size>0,"_editVarMap.size > 0"),this.resolve(),this._stkCedcns.pop(),this.removeEditVarsTo(this._stkCedcns[this._stkCedcns.length-1]),this},removeAllEditVars:function(){return this.removeEditVarsTo(0)},removeEditVarsTo:function(e){try{for(var i=this._editVarList.length,r=e;i>r;r++)this._editVarList[r]&&this.removeConstraint(this._editVarMap.get(this._editVarList[r].v).constraint);return this._editVarList.length=e,t.assert(this._editVarMap.size==e,"_editVarMap.size == n"),this}catch(e){throw new t.InternalError("Constraint not found in removeEditVarsTo")}},addPointStays:function(e){return t.trace&&console.log("addPointStays",e),e.forEach(function(t,e){this.addStay(t.x,i,Math.pow(2,e)),this.addStay(t.y,i,Math.pow(2,e))},this),this},addStay:function(e,r,n){var o=new t.StayConstraint(e,r||i,n||1);return this.addConstraint(o)},removeConstraint:function(t){return this.removeConstraintInternal(t),this},removeConstraintInternal:function(e){t.trace&&t.fnenterprint("removeConstraintInternal: "+e),t.trace&&t.traceprint(""+this),this._fNeedsSolving=!0,this._resetStayConstants();var i=this.rows.get(this._objective),r=this._errorVars.get(e);t.trace&&t.traceprint("eVars == "+r),null!=r&&r.each(function(n){var o=this.rows.get(n);null==o?i.addVariable(n,-e.weight*e.strength.symbolicWeight.value,this._objective,this):i.addExpression(o,-e.weight*e.strength.symbolicWeight.value,this._objective,this),t.trace&&t.traceprint("now eVars == "+r)},this);var n=this._markerVars.get(e);if(this._markerVars.delete(e),null==n)throw new t.InternalError("Constraint not found in removeConstraintInternal");if(t.trace&&t.traceprint("Looking to remove var "+n),null==this.rows.get(n)){var o=this.columns.get(n);t.trace&&t.traceprint("Must pivot -- columns are "+o);var s=null,a=0;o.each(function(e){if(e.isRestricted){var i=this.rows.get(e),r=i.coefficientFor(n);if(t.trace&&t.traceprint("Marker "+n+"'s coefficient in "+i+" is "+r),0>r){var o=-i.constant/r;(null==s||a>o||t.approx(o,a)&&e.hashCode<s.hashCode)&&(a=o,s=e)}}},this),null==s&&(t.trace&&t.traceprint("exitVar is still null"),o.each(function(t){if(t.isRestricted){var e=this.rows.get(t),i=e.coefficientFor(n),r=e.constant/i;(null==s||a>r)&&(a=r,s=t)}},this)),null==s&&(0==o.size?this.removeColumn(n):o.escapingEach(function(t){return t!=this._objective?(s=t,{brk:!0}):void 0},this)),null!=s&&this.pivot(n,s)}if(null!=this.rows.get(n)&&this.removeRow(n),null!=r&&r.each(function(t){t!=n&&this.removeColumn(t)},this),e.isStayConstraint){if(null!=r)for(var l=0;this._stayPlusErrorVars.length>l;l++)r.delete(this._stayPlusErrorVars[l]),r.delete(this._stayMinusErrorVars[l])}else if(e.isEditConstraint){t.assert(null!=r,"eVars != null");var u=this._editVarMap.get(e.variable);this.removeColumn(u.editMinus),this._editVarMap.delete(e.variable)}return null!=r&&this._errorVars.delete(r),this.autoSolve&&(this.optimize(this._objective),this._setExternalVariables()),this},reset:function(){throw t.trace&&t.fnenterprint("reset"),new t.InternalError("reset not implemented")},resolveArray:function(e){t.trace&&t.fnenterprint("resolveArray"+e);var i=e.length;this._editVarMap.each(function(t,r){var n=r.index;i>n&&this.suggestValue(t,e[n])},this),this.resolve()},resolvePair:function(t,e){this.suggestValue(this._editVarList[0].v,t),this.suggestValue(this._editVarList[1].v,e),this.resolve()},resolve:function(){t.trace&&t.fnenterprint("resolve()"),this.dualOptimize(),this._setExternalVariables(),this._infeasibleRows.clear(),this._resetStayConstants()},suggestValue:function(e,i){t.trace&&console.log("suggestValue("+e+", "+i+")");var r=this._editVarMap.get(e);if(!r)throw new t.Error("suggestValue for variable "+e+", but var is not an edit variable");var n=i-r.prevEditConstant;return r.prevEditConstant=i,this.deltaEditConstant(n,r.editPlus,r.editMinus),this},solve:function(){return this._fNeedsSolving&&(this.optimize(this._objective),this._setExternalVariables()),this},setEditedValue:function(e,i){if(!this.columnsHasKey(e)&&null==this.rows.get(e))return e.value=i,this;if(!t.approx(i,e.value)){this.addEditVar(e),this.beginEdit();try{this.suggestValue(e,i)}catch(e){throw new t.InternalError("Error in setEditedValue")}this.endEdit()}return this},addVar:function(e){if(!this.columnsHasKey(e)&&null==this.rows.get(e)){try{this.addStay(e)}catch(e){throw new t.InternalError("Error in addVar -- required failure is impossible")}t.trace&&t.traceprint("added initial stay on "+e)}return this},getInternalInfo:function(){var t=e.getInternalInfo.call(this);return t+="\nSolver info:\n",t+="Stay Error Variables: ",t+=this._stayPlusErrorVars.length+this._stayMinusErrorVars.length,t+=" ("+this._stayPlusErrorVars.length+" +, ",t+=this._stayMinusErrorVars.length+" -)\n",(t+="Edit Variables: "+this._editVarMap.size)+"\n"},getDebugInfo:function(){return""+this+this.getInternalInfo()+"\n"},toString:function(){var t=e.getInternalInfo.call(this);return t+="\n_stayPlusErrorVars: ",t+="["+this._stayPlusErrorVars+"]",t+="\n_stayMinusErrorVars: ",t+="["+this._stayMinusErrorVars+"]",t+="\n",(t+="_editVarMap:\n"+this._editVarMap)+"\n"},getConstraintMap:function(){return this._markerVars},addWithArtificialVariable:function(e){t.trace&&t.fnenterprint("addWithArtificialVariable: "+e);var i=new t.SlackVariable({value:++this._artificialCounter,prefix:"a"}),r=new t.ObjectiveVariable({name:"az"}),n=e.clone();t.trace&&t.traceprint("before addRows:\n"+this),this.addRow(r,n),this.addRow(i,e),t.trace&&t.traceprint("after addRows:\n"+this),this.optimize(r);var o=this.rows.get(r);if(t.trace&&t.traceprint("azTableauRow.constant == "+o.constant),!t.approx(o.constant,0))throw this.removeRow(r),this.removeColumn(i),new t.RequiredFailure;var s=this.rows.get(i);if(null!=s){if(s.isConstant)return this.removeRow(i),void this.removeRow(r);var a=s.anyPivotableVariable();this.pivot(a,i)}t.assert(null==this.rows.get(i),"rowExpression(av) == null"),this.removeColumn(i),this.removeRow(r)},tryAddingDirectly:function(e){t.trace&&t.fnenterprint("tryAddingDirectly: "+e);var i=this.chooseSubject(e);return null==i?(t.trace&&t.fnexitprint("returning false"),!1):(e.newSubject(i),this.columnsHasKey(i)&&this.substituteOut(i,e),this.addRow(i,e),t.trace&&t.fnexitprint("returning true"),!0)},chooseSubject:function(e){t.trace&&t.fnenterprint("chooseSubject: "+e);var i=null,r=!1,n=!1,o=e.terms,s=o.escapingEach(function(t,e){if(r){if(!t.isRestricted&&!this.columnsHasKey(t))return{retval:t}}else if(t.isRestricted){if(!n&&!t.isDummy&&0>e){var o=this.columns.get(t);(null==o||1==o.size&&this.columnsHasKey(this._objective))&&(i=t,n=!0)}}else i=t,r=!0},this);if(s&&void 0!==s.retval)return s.retval;if(null!=i)return i;var a=0;s=o.escapingEach(function(t,e){return t.isDummy?void(this.columnsHasKey(t)||(i=t,a=e)):{retval:null}},this);if(s&&void 0!==s.retval)return s.retval;if(!t.approx(e.constant,0))throw new t.RequiredFailure;return a>0&&e.multiplyMe(-1),i},deltaEditConstant:function(e,i,r){t.trace&&t.fnenterprint("deltaEditConstant :"+e+", "+i+", "+r);var n=this.rows.get(i);if(null!=n)return n.constant+=e,void(0>n.constant&&this._infeasibleRows.add(i));var o=this.rows.get(r);if(null!=o)return o.constant+=-e,void(0>o.constant&&this._infeasibleRows.add(r));var s=this.columns.get(r);s||console.log("columnVars is null -- tableau is:\n"+this),s.each(function(t){var i=this.rows.get(t),n=i.coefficientFor(r);i.constant+=n*e,t.isRestricted&&0>i.constant&&this._infeasibleRows.add(t)},this)},dualOptimize:function(){t.trace&&t.fnenterprint("dualOptimize:");for(var e=this.rows.get(this._objective);this._infeasibleRows.size;){var i=this._infeasibleRows.values()[0];this._infeasibleRows.delete(i);var r=null,n=this.rows.get(i);if(n&&0>n.constant){var o,s=Number.MAX_VALUE;if(n.terms.each(function(i,n){if(n>0&&i.isPivotable){var a=e.coefficientFor(i);(s>(o=a/n)||t.approx(o,s)&&i.hashCode<r.hashCode)&&(r=i,s=o)}}),s==Number.MAX_VALUE)throw new t.InternalError("ratio == nil (MAX_VALUE) in dualOptimize");this.pivot(r,i)}}},newExpression:function(e,i,r){t.trace&&(t.fnenterprint("newExpression: "+e),t.traceprint("cn.isInequality == "+e.isInequality),t.traceprint("cn.required == "+e.required));var n=e.expression,o=new t.Expression(n.constant),s=new t.SlackVariable,a=new t.DummyVariable,l=new t.SlackVariable,u=new t.SlackVariable;if(n.terms.each(function(t,e){var i=this.rows.get(t);i?o.addExpression(i,e):o.addVariable(t,e)},this),e.isInequality)t.trace&&t.traceprint("Inequality, adding slack"),++this._slackCounter,s=new t.SlackVariable({value:this._slackCounter,prefix:"s"}),o.setVariable(s,-1),this._markerVars.set(e,s),e.required||(++this._slackCounter,l=new t.SlackVariable({value:this._slackCounter,prefix:"em"}),o.setVariable(l,1),(h=this.rows.get(this._objective)).setVariable(l,e.strength.symbolicWeight.value*e.weight),this.insertErrorVar(e,l),this.noteAddedVariable(l,this._objective));else if(e.required)t.trace&&t.traceprint("Equality, required"),++this._dummyCounter,a=new t.DummyVariable({value:this._dummyCounter,prefix:"d"}),o.setVariable(a,1),this._markerVars.set(e,a),t.trace&&t.traceprint("Adding dummyVar == d"+this._dummyCounter);else{t.trace&&t.traceprint("Equality, not required"),++this._slackCounter,u=new t.SlackVariable({value:this._slackCounter,prefix:"ep"}),l=new t.SlackVariable({value:this._slackCounter,prefix:"em"}),o.setVariable(u,-1),o.setVariable(l,1),this._markerVars.set(e,u);var h=this.rows.get(this._objective);t.trace&&console.log(h);var c=e.strength.symbolicWeight.value*e.weight;0==c&&(t.trace&&t.traceprint("cn == "+e),t.trace&&t.traceprint("adding "+u+" and "+l+" with swCoeff == "+c)),h.setVariable(u,c),this.noteAddedVariable(u,this._objective),h.setVariable(l,c),this.noteAddedVariable(l,this._objective),this.insertErrorVar(e,l),this.insertErrorVar(e,u),e.isStayConstraint?(this._stayPlusErrorVars.push(u),this._stayMinusErrorVars.push(l)):e.isEditConstraint&&(i[0]=u,i[1]=l,r[0]=n.constant)}return 0>o.constant&&o.multiplyMe(-1),t.trace&&t.fnexitprint("returning "+o),o},optimize:function(e){t.trace&&t.fnenterprint("optimize: "+e),t.trace&&t.traceprint(""+this),this._optimizeCount++;var i=this.rows.get(e);t.assert(null!=i,"zRow != null");for(var r,n=null,o=null;;){if(r=0,i.terms.escapingEach(function(t,e){return t.isPivotable&&r>e?(r=e,n=t,{brk:1}):void 0},this),r>=-1e-8)return;t.trace&&console.log("entryVar:",n,"objectiveCoeff:",r);var s=Number.MAX_VALUE,a=this.columns.get(n),l=0;if(a.each(function(e){if(t.trace&&t.traceprint("Checking "+e),e.isPivotable){var i=this.rows.get(e),r=i.coefficientFor(n);t.trace&&t.traceprint("pivotable, coeff = "+r),0>r&&(l=-i.constant/r,(s>l||t.approx(l,s)&&e.hashCode<o.hashCode)&&(s=l,o=e))}},this),s==Number.MAX_VALUE)throw new t.InternalError("Objective function is unbounded in optimize");this.pivot(n,o),t.trace&&t.traceprint(""+this)}},pivot:function(e,i){t.trace&&console.log("pivot: ",e,i);null==e&&console.warn("pivot: entryVar == null"),null==i&&console.warn("pivot: exitVar == null");var r=this.removeRow(i);r.changeSubject(i,e),this.substituteOut(e,r),this.addRow(e,r)},_resetStayConstants:function(){t.trace&&console.log("_resetStayConstants");for(var e=0;this._stayPlusErrorVars.length>e;e++){var i=this.rows.get(this._stayPlusErrorVars[e]);null==i&&(i=this.rows.get(this._stayMinusErrorVars[e])),null!=i&&(i.constant=0)}},_setExternalVariables:function(){t.trace&&t.fnenterprint("_setExternalVariables:"),t.trace&&t.traceprint(""+this),this._externalParametricVars.each(function(e){null!=this.rows.get(e)?t.trace&&console.log("Error: variable"+e+" in _externalParametricVars is basic"):e.value=0},this),this._externalRows.each(function(t){var e=this.rows.get(t);t.value!=e.constant&&(t.value=e.constant)},this),this._fNeedsSolving=!1,this.onsolved()},onsolved:function(){},insertErrorVar:function(e,i){t.trace&&t.fnenterprint("insertErrorVar:"+e+", "+i);var r=this._errorVars.get(i);r||(r=new t.HashSet,this._errorVars.set(e,r)),r.add(i)}})}(this.c||e.parent.exports||{}),function(t){"use strict";t.Timer=t.inherit({initialize:function(){this.isRunning=!1,this._elapsedMs=0},start:function(){return this.isRunning=!0,this._startReading=new Date,this},stop:function(){return this.isRunning=!1,this._elapsedMs+=new Date-this._startReading,this},reset:function(){return this.isRunning=!1,this._elapsedMs=0,this},elapsedTime:function(){return this.isRunning?(this._elapsedMs+(new Date-this._startReading))/1e3:this._elapsedMs/1e3}})}(this.c||e.parent.exports||{}),__cassowary_parser=function(){function t(t){return'"'+t.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\x08/g,"\\b").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\f/g,"\\f").replace(/\r/g,"\\r").replace(/[\x00-\x07\x0B\x0E-\x1F\x80-\uFFFF]/g,escape)+'"'}var e={parse:function(e,i){function r(t){V>M||(M>V&&(V=M,D=[]),D.push(t))}function n(){var t,e,i,r;return i=M,r=M,null!==(t=P())?null!==(e=h())?t=[t,e]:(t=null,M=r):(t=null,M=r),null!==t&&(t=function(t,e){return e}(0,t[0])),null===t&&(M=i),t}function o(){var t;return e.length>M?(t=e.charAt(M),M++):(t=null,0===B&&r("any character")),t}function s(){var t;return/^[a-zA-Z]/.test(e.charAt(M))?(t=e.charAt(M),M++):(t=null,0===B&&r("[a-zA-Z]")),null===t&&(36===e.charCodeAt(M)?(t="$",M++):(t=null,0===B&&r('"$"')),null===t&&(95===e.charCodeAt(M)?(t="_",M++):(t=null,0===B&&r('"_"')))),t}function a(){var t;return B++,/^[\t\x0B\f \xA0\uFEFF]/.test(e.charAt(M))?(t=e.charAt(M),M++):(t=null,0===B&&r("[\\t\\x0B\\f \\xA0\\uFEFF]")),0===--B&&null===t&&r("whitespace"),t}function l(){var t;return/^[\n\r\u2028\u2029]/.test(e.charAt(M))?(t=e.charAt(M),M++):(t=null,0===B&&r("[\\n\\r\\u2028\\u2029]")),t}function u(){var t;return B++,10===e.charCodeAt(M)?(t="\n",M++):(t=null,0===B&&r('"\\n"')),null===t&&("\r\n"===e.substr(M,2)?(t="\r\n",M+=2):(t=null,0===B&&r('"\\r\\n"')),null===t&&(13===e.charCodeAt(M)?(t="\r",M++):(t=null,0===B&&r('"\\r"')),null===t&&(8232===e.charCodeAt(M)?(t="\u2028",M++):(t=null,0===B&&r('"\\u2028"')),null===t&&(8233===e.charCodeAt(M)?(t="\u2029",M++):(t=null,0===B&&r('"\\u2029"')))))),0===--B&&null===t&&r("end of line"),t}function h(){var t,i,n;return n=M,null!==(t=m())?(59===e.charCodeAt(M)?(i=";",M++):(i=null,0===B&&r('";"')),null!==i?t=[t,i]:(t=null,M=n)):(t=null,M=n),null===t&&(n=M,null!==(t=g())?null!==(i=u())?t=[t,i]:(t=null,M=n):(t=null,M=n),null===t&&(n=M,null!==(t=m())?null!==(i=c())?t=[t,i]:(t=null,M=n):(t=null,M=n))),t}function c(){var t,i;return i=M,B++,e.length>M?(t=e.charAt(M),M++):(t=null,0===B&&r("any character")),B--,null===t?t="":(t=null,M=i),t}function p(){var t;return B++,null===(t=d())&&(t=y()),0===--B&&null===t&&r("comment"),t}function d(){var t,i,n,s,a,l,u;if(a=M,"/*"===e.substr(M,2)?(t="/*",M+=2):(t=null,0===B&&r('"/*"')),null!==t){for(i=[],l=M,u=M,B++,"*/"===e.substr(M,2)?(n="*/",M+=2):(n=null,0===B&&r('"*/"')),B--,null===n?n="":(n=null,M=u),null!==n?null!==(s=o())?n=[n,s]:(n=null,M=l):(n=null,M=l);null!==n;)i.push(n),l=M,u=M,B++,"*/"===e.substr(M,2)?(n="*/",M+=2):(n=null,0===B&&r('"*/"')),B--,null===n?n="":(n=null,M=u),null!==n?null!==(s=o())?n=[n,s]:(n=null,M=l):(n=null,M=l);null!==i?("*/"===e.substr(M,2)?(n="*/",M+=2):(n=null,0===B&&r('"*/"')),null!==n?t=[t,i,n]:(t=null,M=a)):(t=null,M=a)}else t=null,M=a;return t}function f(){var t,i,n,s,a,u,h;if(a=M,"/*"===e.substr(M,2)?(t="/*",M+=2):(t=null,0===B&&r('"/*"')),null!==t){for(i=[],u=M,h=M,B++,"*/"===e.substr(M,2)?(n="*/",M+=2):(n=null,0===B&&r('"*/"')),null===n&&(n=l()),B--,null===n?n="":(n=null,M=h),null!==n?null!==(s=o())?n=[n,s]:(n=null,M=u):(n=null,M=u);null!==n;)i.push(n),u=M,h=M,B++,"*/"===e.substr(M,2)?(n="*/",M+=2):(n=null,0===B&&r('"*/"')),null===n&&(n=l()),B--,null===n?n="":(n=null,M=h),null!==n?null!==(s=o())?n=[n,s]:(n=null,M=u):(n=null,M=u);null!==i?("*/"===e.substr(M,2)?(n="*/",M+=2):(n=null,0===B&&r('"*/"')),null!==n?t=[t,i,n]:(t=null,M=a)):(t=null,M=a)}else t=null,M=a;return t}function y(){var t,i,n,s,a,u,h;if(a=M,"//"===e.substr(M,2)?(t="//",M+=2):(t=null,0===B&&r('"//"')),null!==t){for(i=[],u=M,h=M,B++,n=l(),B--,null===n?n="":(n=null,M=h),null!==n?null!==(s=o())?n=[n,s]:(n=null,M=u):(n=null,M=u);null!==n;)i.push(n),u=M,h=M,B++,n=l(),B--,null===n?n="":(n=null,M=h),null!==n?null!==(s=o())?n=[n,s]:(n=null,M=u):(n=null,M=u);null!==i?t=[t,i]:(t=null,M=a)}else t=null,M=a;return t}function g(){var t,e;for(t=[],null===(e=a())&&(null===(e=f())&&(e=y()));null!==e;)t.push(e),null===(e=a())&&(null===(e=f())&&(e=y()));return t}function m(){var t,e;for(t=[],null===(e=a())&&(null===(e=u())&&(e=p()));null!==e;)t.push(e),null===(e=a())&&(null===(e=u())&&(e=p()));return t}function w(){var t,e;return e=M,null===(t=b())&&(t=v()),null!==t&&(t=function(t,e){return{type:"NumericLiteral",value:e}}(0,t)),null===t&&(M=e),t}function v(){var t,i,n;if(n=M,/^[0-9]/.test(e.charAt(M))?(i=e.charAt(M),M++):(i=null,0===B&&r("[0-9]")),null!==i)for(t=[];null!==i;)t.push(i),/^[0-9]/.test(e.charAt(M))?(i=e.charAt(M),M++):(i=null,0===B&&r("[0-9]"));else t=null;return null!==t&&(t=function(t,e){return parseInt(e.join(""))}(0,t)),null===t&&(M=n),t}function b(){var t,i,n,o,s;return o=M,s=M,null!==(t=v())?(46===e.charCodeAt(M)?(i=".",M++):(i=null,0===B&&r('"."')),null!==i?null!==(n=v())?t=[t,i,n]:(t=null,M=s):(t=null,M=s)):(t=null,M=s),null!==t&&(t=function(t,e){return parseFloat(e.join(""))}(0,t)),null===t&&(M=o),t}function A(){var t,e;return B++,e=M,null!==(t=_())&&(t=function(t,e){return e}(0,t)),null===t&&(M=e),0===--B&&null===t&&r("identifier"),t}function _(){var t,e,i,n,o;if(B++,n=M,o=M,null!==(t=s())){for(e=[],i=s();null!==i;)e.push(i),i=s();null!==e?t=[t,e]:(t=null,M=o)}else t=null,M=o;return null!==t&&(t=function(t,e,i){return e+i.join("")}(0,t[0],t[1])),null===t&&(M=n),0===--B&&null===t&&r("identifier"),t}function E(){var t,i,n,o,s,a,l;return a=M,null!==(t=A())&&(t=function(t,e){return{type:"Variable",name:e}}(0,t)),null===t&&(M=a),null===t&&(null===(t=w())&&(a=M,l=M,40===e.charCodeAt(M)?(t="(",M++):(t=null,0===B&&r('"("')),null!==t?null!==(i=m())?null!==(n=P())?null!==(o=m())?(41===e.charCodeAt(M)?(s=")",M++):(s=null,0===B&&r('")"')),null!==s?t=[t,i,n,o,s]:(t=null,M=l)):(t=null,M=l):(t=null,M=l):(t=null,M=l):(t=null,M=l),null!==t&&(t=function(t,e){return e}(0,t[2])),null===t&&(M=a))),t}function x(){var t,e,i,r,n;return null===(t=E())&&(r=M,n=M,null!==(t=T())?null!==(e=m())?null!==(i=x())?t=[t,e,i]:(t=null,M=n):(t=null,M=n):(t=null,M=n),null!==t&&(t=function(t,e,i){return{type:"UnaryExpression",operator:e,expression:i}}(0,t[0],t[2])),null===t&&(M=r)),t}function T(){var t;return 43===e.charCodeAt(M)?(t="+",M++):(t=null,0===B&&r('"+"')),null===t&&(45===e.charCodeAt(M)?(t="-",M++):(t=null,0===B&&r('"-"')),null===t&&(33===e.charCodeAt(M)?(t="!",M++):(t=null,0===B&&r('"!"')))),t}function S(){var t,e,i,r,n,o,s,a,l;if(s=M,a=M,null!==(t=x())){for(e=[],l=M,null!==(i=m())?null!==(r=I())?null!==(n=m())?null!==(o=x())?i=[i,r,n,o]:(i=null,M=l):(i=null,M=l):(i=null,M=l):(i=null,M=l);null!==i;)e.push(i),l=M,null!==(i=m())?null!==(r=I())?null!==(n=m())?null!==(o=x())?i=[i,r,n,o]:(i=null,M=l):(i=null,M=l):(i=null,M=l):(i=null,M=l);null!==e?t=[t,e]:(t=null,M=a)}else t=null,M=a;return null!==t&&(t=function(t,e,i){for(var r=e,n=0;i.length>n;n++)r={type:"MultiplicativeExpression",operator:i[n][1],left:r,right:i[n][3]};return r}(0,t[0],t[1])),null===t&&(M=s),t}function I(){var t;return 42===e.charCodeAt(M)?(t="*",M++):(t=null,0===B&&r('"*"')),null===t&&(47===e.charCodeAt(M)?(t="/",M++):(t=null,0===B&&r('"/"'))),t}function C(){var t,e,i,r,n,o,s,a,l;if(s=M,a=M,null!==(t=S())){for(e=[],l=M,null!==(i=m())?null!==(r=R())?null!==(n=m())?null!==(o=S())?i=[i,r,n,o]:(i=null,M=l):(i=null,M=l):(i=null,M=l):(i=null,M=l);null!==i;)e.push(i),l=M,null!==(i=m())?null!==(r=R())?null!==(n=m())?null!==(o=S())?i=[i,r,n,o]:(i=null,M=l):(i=null,M=l):(i=null,M=l):(i=null,M=l);null!==e?t=[t,e]:(t=null,M=a)}else t=null,M=a;return null!==t&&(t=function(t,e,i){for(var r=e,n=0;i.length>n;n++)r={type:"AdditiveExpression",operator:i[n][1],left:r,right:i[n][3]};return r}(0,t[0],t[1])),null===t&&(M=s),t}function R(){var t;return 43===e.charCodeAt(M)?(t="+",M++):(t=null,0===B&&r('"+"')),null===t&&(45===e.charCodeAt(M)?(t="-",M++):(t=null,0===B&&r('"-"'))),t}function L(){var t,e,i,r,n,o,s,a,l;if(s=M,a=M,null!==(t=C())){for(e=[],l=M,null!==(i=m())?null!==(r=O())?null!==(n=m())?null!==(o=C())?i=[i,r,n,o]:(i=null,M=l):(i=null,M=l):(i=null,M=l):(i=null,M=l);null!==i;)e.push(i),l=M,null!==(i=m())?null!==(r=O())?null!==(n=m())?null!==(o=C())?i=[i,r,n,o]:(i=null,M=l):(i=null,M=l):(i=null,M=l):(i=null,M=l);null!==e?t=[t,e]:(t=null,M=a)}else t=null,M=a;return null!==t&&(t=function(t,e,i){for(var r=e,n=0;i.length>n;n++)r={type:"Inequality",operator:i[n][1],left:r,right:i[n][3]};return r}(0,t[0],t[1])),null===t&&(M=s),t}function O(){var t;return"<="===e.substr(M,2)?(t="<=",M+=2):(t=null,0===B&&r('"<="')),null===t&&(">="===e.substr(M,2)?(t=">=",M+=2):(t=null,0===B&&r('">="')),null===t&&(60===e.charCodeAt(M)?(t="<",M++):(t=null,0===B&&r('"<"')),null===t&&(62===e.charCodeAt(M)?(t=">",M++):(t=null,0===B&&r('">"'))))),t}function P(){var t,i,n,o,s,a,l,u,h;if(l=M,u=M,null!==(t=L())){for(i=[],h=M,null!==(n=m())?("=="===e.substr(M,2)?(o="==",M+=2):(o=null,0===B&&r('"=="')),null!==o?null!==(s=m())?null!==(a=L())?n=[n,o,s,a]:(n=null,M=h):(n=null,M=h):(n=null,M=h)):(n=null,M=h);null!==n;)i.push(n),h=M,null!==(n=m())?("=="===e.substr(M,2)?(o="==",M+=2):(o=null,0===B&&r('"=="')),null!==o?null!==(s=m())?null!==(a=L())?n=[n,o,s,a]:(n=null,M=h):(n=null,M=h):(n=null,M=h)):(n=null,M=h);null!==i?t=[t,i]:(t=null,M=u)}else t=null,M=u;return null!==t&&(t=function(t,e,i){for(var r=e,n=0;i.length>n;n++)r={type:"Equality",operator:i[n][1],left:r,right:i[n][3]};return r}(0,t[0],t[1])),null===t&&(M=l),t}var N={start:function(){var t,e,i,r,o;if(r=M,o=M,null!==(t=m())){if(null!==(i=n()))for(e=[];null!==i;)e.push(i),i=n();else e=null;null!==e?null!==(i=m())?t=[t,e,i]:(t=null,M=o):(t=null,M=o)}else t=null,M=o;return null!==t&&(t=function(t,e){return e}(0,t[1])),null===t&&(M=r),t},Statement:n,SourceCharacter:o,IdentifierStart:s,WhiteSpace:a,LineTerminator:l,LineTerminatorSequence:u,EOS:h,EOF:c,Comment:p,MultiLineComment:d,MultiLineCommentNoLineTerminator:f,SingleLineComment:y,_:g,__:m,Literal:w,Integer:v,Real:b,SignedInteger:function(){var t,i,n,o;if(o=M,/^[\-+]/.test(e.charAt(M))?(t=e.charAt(M),M++):(t=null,0===B&&r("[\\-+]")),null!==(t=null!==t?t:"")){if(/^[0-9]/.test(e.charAt(M))?(n=e.charAt(M),M++):(n=null,0===B&&r("[0-9]")),null!==n)for(i=[];null!==n;)i.push(n),/^[0-9]/.test(e.charAt(M))?(n=e.charAt(M),M++):(n=null,0===B&&r("[0-9]"));else i=null;null!==i?t=[t,i]:(t=null,M=o)}else t=null,M=o;return t},Identifier:A,IdentifierName:_,PrimaryExpression:E,UnaryExpression:x,UnaryOperator:T,MultiplicativeExpression:S,MultiplicativeOperator:I,AdditiveExpression:C,AdditiveOperator:R,InequalityExpression:L,InequalityOperator:O,LinearExpression:P};if(void 0!==i){if(void 0===N[i])throw Error("Invalid rule name: "+t(i)+".")}else i="start";var M=0,B=0,V=0,D=[],F=N[i]();if(null===F||M!==e.length){var W=Math.max(M,V),q=e.length>W?e.charAt(W):null,k=function(){for(var t=1,i=1,r=!1,n=0;Math.max(M,V)>n;n++){var o=e.charAt(n);"\n"===o?(r||t++,i=1,r=!1):"\r"===o||"\u2028"===o||"\u2029"===o?(t++,i=1,r=!0):(i++,r=!1)}return{line:t,column:i}}();throw new this.SyntaxError(function(t){t.sort();for(var e=null,i=[],r=0;t.length>r;r++)t[r]!==e&&(i.push(t[r]),e=t[r]);return i}(D),q,W,k.line,k.column)}return F},toSource:function(){return this._source},SyntaxError:function(e,i,r,n,o){this.name="SyntaxError",this.expected=e,this.found=i,this.message=function(e,i){var r;switch(e.length){case 0:r="end of input";break;case 1:r=e[0];break;default:r=e.slice(0,e.length-1).join(", ")+" or "+e[e.length-1]}return"Expected "+r+" but "+(i?t(i):"end of input")+" found."}(e,i),this.offset=r,this.line=n,this.column=o}};return e.SyntaxError.prototype=Error.prototype,e}()}).call(void 0!==e?e.compiled=e:this)},{}]},{},[1])(1)}),"undefined"!=typeof Map&&Map.prototype.keys&&"undefined"!=typeof Set&&Set.prototype.keys||function(){function t(t,e){if(e==e)return t.indexOf(e);for(i=0,r=t.length;t[i]==t[i]&&++i!==r;);return i}var e,i,r,n,o,s,a={delete:function(i){return!!~(e=t(this.k,i))&&(this.k.splice(e,1),this.v.splice(e,1),--this.size,!0)},get:function(e){return this.v[t(this.k,e)]},set:function(i,r){return~(e=t(this.k,i))||(this.k[e=this.size++]=i),this.v[e]=r,this},has:function(e){return t(this.k,e)>-1},clear:function(){this.k.length=this.v.length=this.size=0},forEach:function(t,e){e&&(t=t.bind(e));for(var i=-1,r=this.size;++i!==r;)t(this.v[i],this.k[i],this)},entries:function(){var t=0,e=this;return{next:function(){return t!==e.size?{value:[e.k[t++],e.v[t]],done:!1}:{done:!0}}}},keys:function(){var t=0,e=this;return{next:function(){return t!==e.size?{value:e.k[t++],done:!1}:{done:!0}}}},values:function(){var t=0,e=this;return{next:function(){return t!==e.size?{value:e.v[t++],done:!1}:{done:!0}}}},toString:function(){return"[object Map]"}};WeakMap=Map=function(e){if(n=this.k=[],o=this.v=[],r=0,null!=e){if(s=Object(e),(i=+s.length)!=i)throw new TypeError("("+(e.toString||s.toString)()+") is not iterable");for(;i--;){if(!(s[i]instanceof Object))throw new TypeError("Iterator value "+s[i]+" is not an entry object");~t(n,s[i][0])||(n[r]=s[i][0],o[r++]=s[i][1])}n.reverse(),o.reverse()}this.size=r},Map.prototype=a,WeakSet=Set=function(e){if(n=this.k=this.v=[],r=0,null!=e){if(s=Object(e),(i=+s.length)!=i)throw new TypeError("("+(e.toString||s.toString)()+") is not iterable");for(;i--;)~t(n,s[i])||(n[r++]=s[i]);n.reverse()}this.size=r},Set.prototype={delete:function(i){return!!~(e=t(this.k,i))&&(this.k.splice(e,1),--this.size,!0)},add:function(i){return~(e=t(this.k,i))||(e=this.size++),this.k[e]=i,this},has:a.has,clear:a.clear,forEach:a.forEach,entries:a.entries,keys:a.keys,values:a.keys,toString:function(){return"[object Set]"}}}(),function(t,e){null==t&&(t=e("canvas").Context2d),null==t.prototype.ellipse&&(t.prototype.ellipse=function(t,e,i,r,n,o,s,a){this.save(),this.translate(t,e),this.rotate(n),this.scale(i,r),this.arc(0,0,1,o,s,a),this.restore()}),"function"==typeof Path2D&&"function"==typeof(new Path2D).addPath||function(){function e(t){if(this.ops_=[],null!=t)if("string"==typeof t)try{this.ops_=parser.parse(t)}catch(t){}else{if(!t.hasOwnProperty("ops_"))throw"Error: "+typeof t+"is not a valid argument to Path";this.ops_=t.ops_.slice(0)}}parser=function(){function t(t,e,i,r,n,o){this.message=t,this.expected=e,this.found=i,this.offset=r,this.line=n,this.column=o,this.name="SyntaxError"}return function(t,e){function i(){this.constructor=t}i.prototype=e.prototype,t.prototype=new i}(t,Error),{SyntaxError:t,parse:function(e){var i,r=arguments.length>1?arguments[1]:{},n={},o={svg_path:bt},s=bt,a=n,l=null,u=function(t){return Ht},h=/^[Mm]/,c={type:"class",value:"[Mm]",description:"[Mm]"},p=function(t,e){var i=t;Gt&&(i="M",Gt=!1),Ht.push({type:"moveTo",args:Kt(i,e[0])});for(var r=1;r<e.length;r++)Ht.push({type:"lineTo",args:Kt(t,e[r])})},d=function(t,e){return function(t,e){var i=[t];if(e&&e.length>1)for(var r=e[1],n=0;n<r.length;n++)i.push(r[n]);return i}(t,e)},f=/^[Zz]/,y={type:"class",value:"[Zz]",description:"[Zz]"},g=function(){Ht.push({type:"closePath",args:[]})},m=/^[Ll]/,w={type:"class",value:"[Ll]",description:"[Ll]"},v=function(t,e){for(var i=0;i<e.length;i++)Ht.push({type:"lineTo",args:Kt(t,e[i])})},b=/^[Hh]/,A={type:"class",value:"[Hh]",description:"[Hh]"},_=function(t,e){for(var i=0;i<e.length;i++)Ht.push({type:"lineTo",args:Zt(t,e[i])})},E=/^[Vv]/,x={type:"class",value:"[Vv]",description:"[Vv]"},T=function(t,e){for(var i=0;i<e.length;i++)Ht.push({type:"lineTo",args:$t(t,e[i])})},S=/^[Cc]/,I={type:"class",value:"[Cc]",description:"[Cc]"},C=function(t,e){for(var i=0;i<e.length;i++)Ht.push({type:"bezierCurveTo",args:Yt(t,e[i])})},R=function(t,e,i){return t.concat(e,i)},L=/^[Ss]/,O={type:"class",value:"[Ss]",description:"[Ss]"},P=function(t,e){for(var i=0;i<e.length;i++)Ht.push({type:"bezierCurveTo",args:Qt().concat(Yt(t,e[i]))})},N=function(t,e){return t.concat(e)},M=/^[Qq]/,B={type:"class",value:"[Qq]",description:"[Qq]"},V=function(t,e){for(var i=0;i<e.length;i++)Ht.push({type:"quadraticCurveTo",args:Yt(t,e[i])})},D=/^[Tt]/,F={type:"class",value:"[Tt]",description:"[Tt]"},W=function(t,e){for(var i=0;i<e.length;i++){var r=Qt();Ht.push({type:"quadraticCurveTo",args:r.concat(Yt(t,e[i]))}),Ut=r.slice(0)}},q=/^[Aa]/,k={type:"class",value:"[Aa]",description:"[Aa]"},z=function(t,e){for(var i=0;i<e.length;i++){var r=[zt.slice()],n=[Kt(t,e[i].slice(-2))];absArgs=r.concat(e[i].slice(0,-2),n),ee.apply(this,absArgs)}},U=function(t,e,i,r,n,o){return[parseFloat(t),parseFloat(e),parseFloat(Xt(i).join("")),parseInt(r),parseInt(n),o[0],o[1]]},H=function(t,e){return[t,e]},G=function(t){return parseFloat(Xt(t).join(""))},j="0",X={type:"literal",value:"0",description:'"0"'},K="1",Y={type:"literal",value:"1",description:'"1"'},Q=",",Z={type:"literal",value:",",description:'","'},$=".",J={type:"literal",value:".",description:'"."'},tt=/^[eE]/,et={type:"class",value:"[eE]",description:"[eE]"},it="+",rt={type:"literal",value:"+",description:'"+"'},nt="-",ot={type:"literal",value:"-",description:'"-"'},st=/^[0-9]/,at={type:"class",value:"[0-9]",description:"[0-9]"},lt=function(t){return t.join("")},ut=/^[ \t\n\r]/,ht={type:"class",value:"[ \\t\\n\\r]",description:"[ \\t\\n\\r]"},ct=0,pt=0,dt={line:1,column:1,seenCR:!1},ft=0,yt=[],gt=0;if("startRule"in r){if(!(r.startRule in o))throw new Error("Can't start parsing from rule \""+r.startRule+'".');s=o[r.startRule]}function mt(t){return pt!==t&&(pt>t&&(pt=0,dt={line:1,column:1,seenCR:!1}),function(t,i,r){var n,o;for(n=i;n<r;n++)"\n"===(o=e.charAt(n))?(t.seenCR||t.line++,t.column=1,t.seenCR=!1):"\r"===o||"\u2028"===o||"\u2029"===o?(t.line++,t.column=1,t.seenCR=!0):(t.column++,t.seenCR=!1)}(dt,pt,t),pt=t),dt}function wt(t){ct<ft||(ct>ft&&(ft=ct,yt=[]),yt.push(t))}function vt(i,r,n){var o=mt(n),s=n<e.length?e.charAt(n):null;return null!==r&&function(t){var e=1;for(t.sort(function(t,e){return t.description<e.description?-1:t.description>e.description?1:0});e<t.length;)t[e-1]===t[e]?t.splice(e,1):e++}(r),new t(null!==i?i:function(t,e){var i,r=new Array(t.length);for(i=0;i<t.length;i++)r[i]=t[i].description;return"Expected "+(t.length>1?r.slice(0,-1).join(", ")+" or "+r[t.length-1]:r[0])+" but "+(e?'"'+function(t){function e(t){return t.charCodeAt(0).toString(16).toUpperCase()}return t.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\x08/g,"\\b").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\f/g,"\\f").replace(/\r/g,"\\r").replace(/[\x00-\x07\x0B\x0E\x0F]/g,function(t){return"\\x0"+e(t)}).replace(/[\x10-\x1F\x80-\xFF]/g,function(t){return"\\x"+e(t)}).replace(/[\u0180-\u0FFF]/g,function(t){return"\\u0"+e(t)}).replace(/[\u1080-\uFFFF]/g,function(t){return"\\u"+e(t)})}(e)+'"':"end of input")+" found."}(r,s),r,s,n,o.line,o.column)}function bt(){var t,e,i,r,o;for(t=ct,e=[],i=kt();i!==n;)e.push(i),i=kt();if(e!==n)if((i=At())===n&&(i=l),i!==n){for(r=[],o=kt();o!==n;)r.push(o),o=kt();r!==n?t=e=u(i):(ct=t,t=a)}else ct=t,t=a;else ct=t,t=a;return t}function At(){var t,i,r,o,s;if(t=ct,i=function(){var t,i,r,o,s;if(t=ct,i=function(){var t,i,r,o;t=ct,h.test(e.charAt(ct))?(i=e.charAt(ct),ct++):(i=n,0===gt&&wt(c));if(i!==n){for(r=[],o=kt();o!==n;)r.push(o),o=kt();r!==n?(o=function(){var t,e,i,r,o;t=ct,e=Lt(),e!==n?(i=ct,(r=Bt())===n&&(r=l),r!==n&&(o=Et())!==n?i=r=[r,o]:(ct=i,i=a),i===n&&(i=l),i!==n?t=e=d(e,i):(ct=t,t=a)):(ct=t,t=a);return t}(),o!==n?t=i=p(i,o):(ct=t,t=a)):(ct=t,t=a)}else ct=t,t=a;return t}(),i!==n){for(r=ct,o=[],s=kt();s!==n;)o.push(s),s=kt();o!==n&&(s=_t())!==n?r=o=[o,s]:(ct=r,r=a),r===n&&(r=l),r!==n?t=i=[i,r]:(ct=t,t=a)}else ct=t,t=a;return t}(),i!==n){for(r=ct,o=[],s=kt();s!==n;)o.push(s),s=kt();o!==n&&(s=At())!==n?r=o=[o,s]:(ct=r,r=a),r===n&&(r=l),r!==n?t=i=[i,r]:(ct=t,t=a)}else ct=t,t=a;return t}function _t(){var t,i,r,o,s;if(t=ct,i=function(){var t;t=function(){var t,i;t=ct,f.test(e.charAt(ct))?(i=e.charAt(ct),ct++):(i=n,0===gt&&wt(y));i!==n&&(i=g());return t=i,t}(),t===n&&(t=function(){var t,i,r,o;t=ct,m.test(e.charAt(ct))?(i=e.charAt(ct),ct++):(i=n,0===gt&&wt(w));if(i!==n){for(r=[],o=kt();o!==n;)r.push(o),o=kt();r!==n&&(o=Et())!==n?t=i=v(i,o):(ct=t,t=a)}else ct=t,t=a;return t}(),t===n&&(t=function(){var t,i,r,o;t=ct,b.test(e.charAt(ct))?(i=e.charAt(ct),ct++):(i=n,0===gt&&wt(A));if(i!==n){for(r=[],o=kt();o!==n;)r.push(o),o=kt();r!==n&&(o=xt())!==n?t=i=_(i,o):(ct=t,t=a)}else ct=t,t=a;return t}(),t===n&&(t=function(){var t,i,r,o;t=ct,E.test(e.charAt(ct))?(i=e.charAt(ct),ct++):(i=n,0===gt&&wt(x));if(i!==n){for(r=[],o=kt();o!==n;)r.push(o),o=kt();r!==n&&(o=xt())!==n?t=i=T(i,o):(ct=t,t=a)}else ct=t,t=a;return t}(),t===n&&(t=function(){var t,i,r,o;t=ct,S.test(e.charAt(ct))?(i=e.charAt(ct),ct++):(i=n,0===gt&&wt(I));if(i!==n){for(r=[],o=kt();o!==n;)r.push(o),o=kt();r!==n&&(o=Tt())!==n?t=i=C(i,o):(ct=t,t=a)}else ct=t,t=a;return t}(),t===n&&(t=function(){var t,i,r,o;t=ct,L.test(e.charAt(ct))?(i=e.charAt(ct),ct++):(i=n,0===gt&&wt(O));if(i!==n){for(r=[],o=kt();o!==n;)r.push(o),o=kt();r!==n&&(o=St())!==n?t=i=P(i,o):(ct=t,t=a)}else ct=t,t=a;return t}(),t===n&&(t=function(){var t,i,r,o;t=ct,M.test(e.charAt(ct))?(i=e.charAt(ct),ct++):(i=n,0===gt&&wt(B));if(i!==n){for(r=[],o=kt();o!==n;)r.push(o),o=kt();r!==n&&(o=It())!==n?t=i=V(i,o):(ct=t,t=a)}else ct=t,t=a;return t}(),t===n&&(t=function(){var t,i,r,o;t=ct,D.test(e.charAt(ct))?(i=e.charAt(ct),ct++):(i=n,0===gt&&wt(F));if(i!==n){for(r=[],o=kt();o!==n;)r.push(o),o=kt();r!==n&&(o=Ct())!==n?t=i=W(i,o):(ct=t,t=a)}else ct=t,t=a;return t}(),t===n&&(t=function(){var t,i,r,o;t=ct,q.test(e.charAt(ct))?(i=e.charAt(ct),ct++):(i=n,0===gt&&wt(k));if(i!==n){for(r=[],o=kt();o!==n;)r.push(o),o=kt();r!==n&&(o=Rt())!==n?t=i=z(i,o):(ct=t,t=a)}else ct=t,t=a;return t}()))))))));return t}(),i!==n){for(r=ct,o=[],s=kt();s!==n;)o.push(s),s=kt();o!==n&&(s=_t())!==n?r=o=[o,s]:(ct=r,r=a),r===n&&(r=l),r!==n?t=i=[i,r]:(ct=t,t=a)}else ct=t,t=a;return t}function Et(){var t,e,i,r,o;return t=ct,(e=Lt())!==n?(i=ct,(r=Bt())===n&&(r=l),r!==n&&(o=Et())!==n?i=r=[r,o]:(ct=i,i=a),i===n&&(i=l),i!==n?t=e=d(e,i):(ct=t,t=a)):(ct=t,t=a),t}function xt(){var t,e,i,r,o;return t=ct,(e=Ot())!==n?(i=ct,(r=Bt())===n&&(r=l),r!==n&&(o=xt())!==n?i=r=[r,o]:(ct=i,i=a),i===n&&(i=l),i!==n?t=e=d(e,i):(ct=t,t=a)):(ct=t,t=a),t}function Tt(){var t,e,i,r,o;return t=ct,e=function(){var t,e,i,r,o,s;t=ct,e=Lt(),e!==n?((i=Bt())===n&&(i=l),i!==n&&(r=Lt())!==n?((o=Bt())===n&&(o=l),o!==n&&(s=Lt())!==n?t=e=R(e,r,s):(ct=t,t=a)):(ct=t,t=a)):(ct=t,t=a);return t}(),e!==n?(i=ct,(r=Bt())===n&&(r=l),r!==n&&(o=Tt())!==n?i=r=[r,o]:(ct=i,i=a),i===n&&(i=l),i!==n?t=e=d(e,i):(ct=t,t=a)):(ct=t,t=a),t}function St(){var t,e,i,r,o;return t=ct,e=function(){var t,e,i,r;t=ct,e=Lt(),e!==n?((i=Bt())===n&&(i=l),i!==n&&(r=Lt())!==n?t=e=N(e,r):(ct=t,t=a)):(ct=t,t=a);return t}(),e!==n?(i=ct,(r=Bt())===n&&(r=l),r!==n&&(o=St())!==n?i=r=[r,o]:(ct=i,i=a),i===n&&(i=l),i!==n?t=e=d(e,i):(ct=t,t=a)):(ct=t,t=a),t}function It(){var t,e,i,r,o;return t=ct,e=function(){var t,e,i,r;t=ct,e=Lt(),e!==n?((i=Bt())===n&&(i=l),i!==n&&(r=Lt())!==n?t=e=N(e,r):(ct=t,t=a)):(ct=t,t=a);return t}(),e!==n?(i=ct,(r=Bt())===n&&(r=l),r!==n&&(o=It())!==n?i=r=[r,o]:(ct=i,i=a),i===n&&(i=l),i!==n?t=e=d(e,i):(ct=t,t=a)):(ct=t,t=a),t}function Ct(){var t,e,i,r,o;return t=ct,(e=Lt())!==n?(i=ct,(r=Bt())===n&&(r=l),r!==n&&(o=Ct())!==n?i=r=[r,o]:(ct=i,i=a),i===n&&(i=l),i!==n?t=e=d(e,i):(ct=t,t=a)):(ct=t,t=a),t}function Rt(){var t,e,i,r,o;return t=ct,e=function(){var t,e,i,r,o,s,u,h,c,p,d;t=ct,e=Pt(),e!==n?((i=Bt())===n&&(i=l),i!==n&&(r=Pt())!==n?((o=Bt())===n&&(o=l),o!==n&&(s=Nt())!==n&&Bt()!==n&&(u=Mt())!==n?((h=Bt())===n&&(h=l),h!==n&&(c=Mt())!==n?((p=Bt())===n&&(p=l),p!==n&&(d=Lt())!==n?t=e=U(e,r,s,u,c,d):(ct=t,t=a)):(ct=t,t=a)):(ct=t,t=a)):(ct=t,t=a)):(ct=t,t=a);return t}(),e!==n?(i=ct,(r=Bt())===n&&(r=l),r!==n&&(o=Rt())!==n?i=r=[r,o]:(ct=i,i=a),i===n&&(i=l),i!==n?t=e=d(e,i):(ct=t,t=a)):(ct=t,t=a),t}function Lt(){var t,e,i,r;return t=ct,(e=Ot())!==n?((i=Bt())===n&&(i=l),i!==n&&(r=Ot())!==n?t=e=H(e,r):(ct=t,t=a)):(ct=t,t=a),t}function Ot(){var t,e;return t=ct,(e=Nt())!==n&&(e=G(e)),t=e}function Pt(){var t;return(t=Dt())===n&&(t=qt()),t}function Nt(){var t,e,i;return t=ct,(e=Wt())===n&&(e=l),e!==n&&(i=Dt())!==n?t=e=[e,i]:(ct=t,t=a),t===n&&(t=ct,(e=Wt())===n&&(e=l),e!==n&&(i=qt())!==n?t=e=[e,i]:(ct=t,t=a)),t}function Mt(){var t;return 48===e.charCodeAt(ct)?(t=j,ct++):(t=n,0===gt&&wt(X)),t===n&&(49===e.charCodeAt(ct)?(t=K,ct++):(t=n,0===gt&&wt(Y))),t}function Bt(){var t,e,i,r,o;if(t=ct,e=[],(i=kt())!==n)for(;i!==n;)e.push(i),i=kt();else e=a;if(e!==n)if((i=Vt())===n&&(i=l),i!==n){for(r=[],o=kt();o!==n;)r.push(o),o=kt();r!==n?t=e=[e,i,r]:(ct=t,t=a)}else ct=t,t=a;else ct=t,t=a;if(t===n)if(t=ct,(e=Vt())!==n){for(i=[],r=kt();r!==n;)i.push(r),r=kt();i!==n?t=e=[e,i]:(ct=t,t=a)}else ct=t,t=a;return t}function Vt(){var t;return 44===e.charCodeAt(ct)?(t=Q,ct++):(t=n,0===gt&&wt(Z)),t}function Dt(){var t,i,r;return t=ct,i=function(){var t,i,r,o;t=ct,i=qt(),i===n&&(i=l);i!==n?(46===e.charCodeAt(ct)?(r=$,ct++):(r=n,0===gt&&wt(J)),r!==n&&(o=qt())!==n?t=i=[i,r,o]:(ct=t,t=a)):(ct=t,t=a);t===n&&(t=ct,(i=qt())!==n?(46===e.charCodeAt(ct)?(r=$,ct++):(r=n,0===gt&&wt(J)),r!==n?t=i=[i,r]:(ct=t,t=a)):(ct=t,t=a));return t}(),i!==n?((r=Ft())===n&&(r=l),r!==n?t=i=[i,r]:(ct=t,t=a)):(ct=t,t=a),t===n&&(t=ct,(i=qt())!==n&&(r=Ft())!==n?t=i=[i,r]:(ct=t,t=a)),t}function Ft(){var t,i,r,o;return t=ct,tt.test(e.charAt(ct))?(i=e.charAt(ct),ct++):(i=n,0===gt&&wt(et)),i!==n?((r=Wt())===n&&(r=l),r!==n&&(o=qt())!==n?t=i=[i,r,o]:(ct=t,t=a)):(ct=t,t=a),t}function Wt(){var t;return 43===e.charCodeAt(ct)?(t=it,ct++):(t=n,0===gt&&wt(rt)),t===n&&(45===e.charCodeAt(ct)?(t=nt,ct++):(t=n,0===gt&&wt(ot))),t}function qt(){var t,i,r;if(t=ct,i=[],st.test(e.charAt(ct))?(r=e.charAt(ct),ct++):(r=n,0===gt&&wt(at)),r!==n)for(;r!==n;)i.push(r),st.test(e.charAt(ct))?(r=e.charAt(ct),ct++):(r=n,0===gt&&wt(at));else i=a;return i!==n&&(i=lt(i)),t=i}function kt(){var t;return ut.test(e.charAt(ct))?(t=e.charAt(ct),ct++):(t=n,0===gt&&wt(ht)),t}var zt=[0,0],Ut=[0,0],Ht=[],Gt=!0,jt="";function Xt(t){for(var e=[],i=0;i<t.length;i++)t[i]instanceof Array?e.push.apply(e,Xt(t[i])):e.push(t[i]);return e}function Kt(t,e){return-1==="mlazhvcsqt".indexOf(t)?zt=e:(zt[0]+=e[0],zt[1]+=e[1]),jt=t,zt.slice(0)}function Yt(t,e){for(var i=[],r=zt.slice(0),n=0;n<e.length;n+=2){zt=r.slice(0);var o=Kt(t,e.slice(n,n+2));i=i.concat(o),n==e.length-4&&(Ut=o.slice(0))}return i}function Qt(){-1=="CcSsQqTt".indexOf(jt)&&(Ut=zt.slice(0));var t=[0,0];return t[0]=2*zt[0]-Ut[0],t[1]=2*zt[1]-Ut[1],t}function Zt(t,e){var i=[e,0];return"H"==t&&(i[1]=zt[1]),Kt(t,i)}function $t(t,e){var i=[0,e];return"V"==t&&(i[0]=zt[0]),Kt(t,i)}function Jt(t){return Math.sqrt(Math.pow(t[0],2)+Math.pow(t[1],2))}function te(t,e){var i,r,n=1;return t[0]*e[1]-t[1]*e[0]<0&&(n=-1),n*Math.acos((function(t,e){(function(t,e){t[0],e[0],t[1],e[1]})(t,e),Jt(t),Jt(e)}(t,e),Math.min(Math.max(val,i),r)),-1,1)}function ee(t,e,i,r,n,o,s){if(0!=e&&0!=i){r=r*(Math.PI/180);e=Math.abs(e),i=Math.abs(i);var a,l,u=function(t,e){var i=Math.cos(e),r=Math.sin(e);return[i*t[0]+r*t[1],-1*r*t[0]+i*t[1]]}((l=s,[((a=t)[0]-l[0])/2,(a[1]-l[1])/2]),r),h=function(t,e){return[t[0]*e[0],t[1]*e[1]]}(u,u),c=Math.pow(e,2),p=Math.pow(i,2),d=Math.sqrt(h[0]/c+h[1]/p);d>1&&(e*=d,i*=d,c=Math.pow(e,2),p=Math.pow(i,2));var f=Math.sqrt(Math.abs(c*p-c*h[1]-p*h[0])/(c*h[1]+p*h[0]));n==o&&(f*=-1);var y=function(t,e){return[t*e[0],t*e[1]]}(f,[e*u[1]/i,-i*u[0]/e]),g=function(t,e){return[t[0]+e[0],t[1]+e[1]]}(function(t,e){var i=Math.cos(e),r=Math.sin(e);return[i*t[0]-r*t[1],r*t[0]+i*t[1]]}(y,r),function(t,e){return[(t[0]+e[0])/2,(t[1]+e[1])/2]}(t,s)),m=[(u[0]-y[0])/e,(u[1]-y[1])/i],w=[(-1*u[0]-y[0])/e,(-1*u[1]-y[1])/i],v=te([1,0],m),b=v,A=v+te(m,w);Ht.push({type:"save",args:[]},{type:"translate",args:[g[0],g[1]]},{type:"rotate",args:[r]},{type:"scale",args:[e,i]},{type:"arc",args:[0,0,1,b,A,1-o]},{type:"restore",args:[]})}else Ht.push({type:"lineTo",args:s})}if((i=s())!==n&&ct===e.length)return i;throw i!==n&&ct<e.length&&wt({type:"end",description:"end of input"}),vt(null,yt,ft)}}}();var i=["closePath","moveTo","lineTo","quadraticCurveTo","bezierCurveTo","rect","arc","arcTo","ellipse","isPointInPath","isPointInStroke"];function r(t){return function(){this.ops_.push({type:t,args:Array.prototype.slice.call(arguments,0)})}}for(var n=0;n<i.length;n++){var o=i[n];e.prototype[o]=r(o)}e.prototype.addPath=function(t,e){var i=!1;e&&null!=e.a&&null!=e.b&&null!=e.c&&null!=e.d&&null!=e.e&&null!=e.f&&(i=!0,this.ops_.push({type:"save",args:[]}),this.ops_.push({type:"transform",args:[e.a,e.b,e.c,e.d,e.e,e.f]})),this.ops_=this.ops_.concat(t.ops_),i&&this.ops_.push({type:"restore",args:[]})},original_fill=t.prototype.fill,original_stroke=t.prototype.stroke,original_clip=t.prototype.clip,original_is_point_in_path=t.prototype.isPointInPath,original_is_point_in_stroke=t.prototype.isPointInStroke,t.prototype.fill=function(i){if(i instanceof e){this.beginPath();for(var r=0,n=i.ops_.length;r<n;r++){var o=i.ops_[r];t.prototype[o.type].apply(this,o.args)}original_fill.apply(this,Array.prototype.slice.call(arguments,1))}else original_fill.apply(this,arguments)},t.prototype.stroke=function(i){if(i instanceof e){this.beginPath();for(var r=0,n=i.ops_.length;r<n;r++){var o=i.ops_[r];t.prototype[o.type].apply(this,o.args)}original_stroke.call(this)}else original_stroke.call(this)},t.prototype.clip=function(i){if(i instanceof e){this.beginPath();for(var r=0,n=i.ops_.length;r<n;r++){var o=i.ops_[r];t.prototype[o.type].apply(this,o.args)}original_clip.apply(this,Array.prototype.slice.call(arguments,1))}else original_clip.apply(this,arguments)},t.prototype.isPointInPath=function(i){if(i instanceof e){this.beginPath();for(var r=0,n=i.ops_.length;r<n;r++){var o=i.ops_[r];t.prototype[o.type].apply(this,o.args)}return original_is_point_in_path.apply(this,Array.prototype.slice.call(arguments,1))}return original_is_point_in_path.apply(this,arguments)},t.prototype.isPointInStroke=function(i){if(i instanceof e){this.beginPath();for(var r=0,n=i.ops_.length;r<n;r++){var o=i.ops_[r];t.prototype[o.type].apply(this,o.args)}return original_is_point_in_stroke.apply(this,Array.prototype.slice.call(arguments,1))}return original_is_point_in_stroke.apply(this,arguments)},Path2D=e}()}("undefined"==typeof CanvasRenderingContext2D?void 0:CanvasRenderingContext2D,"undefined"==typeof require?void 0:require),function(t){"use strict";var e=t.HTMLCanvasElement&&t.HTMLCanvasElement.prototype,i=t.Blob&&function(){try{return Boolean(new Blob)}catch(t){return!1}}(),r=i&&t.Uint8Array&&function(){try{return 100===new Blob([new Uint8Array(100)]).size}catch(t){return!1}}(),n=t.BlobBuilder||t.WebKitBlobBuilder||t.MozBlobBuilder||t.MSBlobBuilder,o=/^data:((.*?)(;charset=.*?)?)(;base64)?,/,s=(i||n)&&t.atob&&t.ArrayBuffer&&t.Uint8Array&&function(t){var e,s,a,l,u,h,c,p,d;if(!(e=t.match(o)))throw new Error("invalid data URI");for(s=e[2]?e[1]:"text/plain"+(e[3]||";charset=US-ASCII"),a=!!e[4],l=t.slice(e[0].length),u=a?atob(l):decodeURIComponent(l),h=new ArrayBuffer(u.length),c=new Uint8Array(h),p=0;p<u.length;p+=1)c[p]=u.charCodeAt(p);return i?new Blob([r?c:h],{type:s}):((d=new n).append(h),d.getBlob(s))};t.HTMLCanvasElement&&!e.toBlob&&(e.mozGetAsFile?e.toBlob=function(t,i,r){var n=this;setTimeout(function(){r&&e.toDataURL&&s?t(s(n.toDataURL(i,r))):t(n.mozGetAsFile("blob",i))})}:e.toDataURL&&s&&(e.msToBlob?e.toBlob=function(t,i,r){var n=this;setTimeout(function(){(i&&"image/png"!==i||r)&&e.toDataURL&&s?t(s(n.toDataURL(i,r))):t(n.msToBlob(i))})}:e.toBlob=function(t,e,i){var r=this;setTimeout(function(){t(s(r.toDataURL(e,i)))})})),"function"==typeof define&&define.amd?define(function(){return s}):"object"==typeof module&&module.exports?module.exports=s:t.dataURLtoBlob=s}(window),Point.prototype.move=function(t,e){this.x=t,this.y=e},Point.prototype.translate=function(t,e){this.x+=t,this.y+=e},Point.prototype.calcDistanceTo=function(t){return t&&"Point"===t.constructor.name?Math.sqrt(Math.pow(this.x-t.x,2)+Math.pow(this.y-t.y,2)):Number.NaN},Point.prototype.equals=function(t){return!(!t||"Point"!==t.constructor.name)&&(t.x===this.x&&t.y===this.y)},FloatPoint.prototype.constructor=FloatPoint,FloatPoint.prototype=Object.create(Point.prototype),FloatPoint.prototype.move=function(t,e,i){Object.getPrototypeOf(FloatPoint.prototype).move.call(this,t,e),this.z=i},FloatPoint.prototype.translate=function(t,e,i){Object.getPrototypeOf(FloatPoint.prototype).translate.call(this,t,e),this.z+=i},FloatPoint.prototype.calcDistanceTo=function(t){return t&&"FloatPoint"===t.constructor.name?Math.sqrt(pow(this.x-t.x,2)+Math.pow(this.y-t.y,2)+Math.pow(this.z-t.z,2)):Number.NaN},FloatPoint.prototype.toPoint=function(){return new Point(this.x,this.y)},FloatPoint.prototype.equals=function(t){return!(!t||"FloatPoint"!==t.constructor.name)&&(t.x===this.x&&t.y===this.y&&t.z===this.z)},FloatPoint.prototype.findXYGrad=function(t){return t&&"FloatPoint"===t.constructor.name?(this.y-t.y)/(this.x-t.x):Number.NaN},FloatPoint.prototype.findXZGrad=function(t){return t&&"FloatPoint"===t.constructor.name?(this.z-t.z)/(this.x-t.x):Number.NaN},FloatPoint.prototype.findYZGrad=function(t){return t&&"FloatPoint"===t.constructor.name?(this.z-t.z)/(this.y-t.y):Number.NaN},FloatPoint.prototype.liesBetween=function(t,e){if(t&&"FloatPoint"===t.constructor.name&&e&&"FloatPoint"===e.constructor.name){var i=t.x<=x&&e.x>=this.x||e.x<=x&&t.x>=this.x,r=t.y<=y&&e.y>=this.y||e.y<=y&&t.y>=this.y,n=t.z<=z&&e.z>=this.z||e.z<=z&&t.z>=this.z;return i&&r&&n&&isCollinearWith(t,e)}return!1},Line.prototype.getX=function(t){return"number"==typeof t?(t-this.c)/this.m:Number.NaN},Line.prototype.getY=function(t){return"number"==typeof t?this.m*t+this.c:Number.NaN},Line.prototype.distance=function(t,e){return t&&"Point"===t.constructor.name&&e&&"Point"===e.constructor.name&&this.passesThroughPoint(t)&&this.passesThroughPoint(e)?e.calcDistanceTo(t):Number.NaN},Line.prototype.distanceF=function(t,e){return t&&"FloatPoint"===t.constructor.name&&e&&"FloatPoint"===e.constructor.name&&this.passesThroughPoint(t)&&this.passesThroughPoint(e)?e.calcDistanceTo(t):Number.NaN},Line.prototype.distanceSquared=function(t,e){if(t&&"FloatPoint"===t.constructor.name&&e&&"FloatPoint"===e.constructor.name&&this.passesThroughPoint(t)&&this.passesThroughPoint(e)){var i=e.calcDistanceTo(t);return i*i}return Number.NaN},Line.prototype.intersectsLine=function(t){return!this.isParallelTo(t)},Line.prototype.isParallelTo=function(t){return approxEquals(this.m,t.m)},Line.prototype.passesThroughPoint=function(t){return!(!t||"Point"!==t.constructor.name)&&approxEquals(t.y,this.m*t.x+this.c)},Line.prototype.passesThroughPointF=function(t){if(t&&"FloatPoint"===t.constructor.name)return approxEquals(t.y,this.m*t.x+this.c)},Line.prototype.intersectionWithLine=function(t){if(t&&"Line"===t.constructor.name){var e=-1*(this.c-t.c)/(this.m-t.m);return new FloatPoint(e,this.m*e+this.c)}return null},Line.prototype.draw=function(t,e,i,r,n){if("string"==typeof t&&"number"==typeof e&&"number"==typeof i&&"string"==typeof r&&"number"==typeof n){var o=document.getElementById(t),s=o.getContext("2d");o.width,o.height;let a=this.getY(e),l=this.getY(i);s.beginPath(),s.strokeStyle=r,s.lineWidth=n,s.moveTo(e,a),s.lineTo(i,l),s.stroke()}else logger("Invalid Line draw args")},Dimension.prototype.scale=function(t){"number"==typeof t&&(this.width*=t,this.height*=t)},Dimension.prototype.getScaledInstance=function(t){return"number"==typeof t?new Dimension(this.width*t,this.height*t):null},Quadratic.prototype.solve=function(){var t=this.a,e=this.b,i=this.c;return Math.pow(e,2)-4*t*i>=0?-e/(2*t)+Math.sqrt(Math.pow(e,2)-4*t*i)/(2*t)+" , "+(-e/(2*t)-Math.sqrt(Math.pow(e,2)-4*t*i)/(2*t)):pow(e,2)-4*t*i<0?-e/(2*t)+" + "+Math.sqrt(4*t*i-Math.pow(e,2))/(2*t)+" i , "+-e/(2*t)+" - "+Math.sqrt(4*t*i-Math.pow(e,2))/(2*t)+" i":void 0},Quadratic.prototype.solutionArray=function(){var t=this.a,e=this.b,i=this.c,r=[];if(Math.pow(e,2)-4*t*i>=0){var n=-e/(2*t)+Math.sqrt(Math.pow(e,2)-4*t*i)/(2*t),o=-e/(2*t)-Math.sqrt(Math.pow(e,2)-4*t*i)/(2*t);r.push(n),r.push(o)}else if(pow(e,2)-4*t*i<0){var s=-e/(2*t),a=Math.sqrt(4*t*i-Math.pow(e,2))/(2*t),l=-e/(2*t),u=Math.sqrt(4*t*i-Math.pow(e,2))/(2*t);r.push(s+" + "+a+" i"),r.push(l+" - "+u+" i")}return r},Rectangle.prototype.right=function(){return this.left+this.width},Rectangle.prototype.bottom=function(){return this.top+this.height},Rectangle.prototype.centerX=function(){return this.left+this.width/2},Rectangle.prototype.centerY=function(){return this.top+this.height/2},Rectangle.prototype.setLocation=function(t,e){"number"==typeof t&&"number"==typeof e&&(this.left=t,this.top=e)},Rectangle.prototype.getLocation=function(){return new Point(this.left,this.top)},Rectangle.prototype.translate=function(t,e){var i=this.left,r=i+t;t<0?r>i&&(this.width>=0&&(this.width+=r-Number.MIN_VALUE),r=Number.MIN_VALUE):r<i&&(this.width>=0&&(this.width+=r-Number.MAX_VALUE,this.width<0&&(this.width=Number.MAX_VALUE)),r=Number.MAX_VALUE),this.left=r,r=(i=this.top)+e,e<0?r>i&&(this.height>=0&&(this.height+=r-Number.MIN_VALUE),r=Number.MIN_VALUE):r<i&&(this.height>=0&&(this.height+=r-Number.MAX_VALUE,this.height<0&&(this.height=Number.MAX_VALUE)),r=Number.MAX_VALUE),this.top=r},Rectangle.prototype.getSize=function(){return new Dimension(this.width,this.height)},Rectangle.prototype.setSize=function(t){"Dimension"===t.constructor.name&&(this.width=t.width,this.height=t.height)},Rectangle.prototype.containsPoint=function(t,e){if("number"==typeof t&&"number"==typeof e){var i=this.width,r=this.height;if((i|r)<0)return!1;var n=this.left,o=this.top;return!(t<n||e<o)&&(r+=o,((i+=n)<n||i>t)&&(r<o||r>e))}return!1},Rectangle.prototype.contains=function(t){if("Rectangle"===t.constructor.name){var e=t.left,i=t.top,r=t.width,n=t.height,o=this.width,s=this.height;if((o|s|r|n)<0)return!1;var a=this.left,l=this.top;if(e<a||i<l)return!1;if(o+=a,(r+=e)<=e){if(o>=a||r>o)return!1}else if(o>=a&&r>o)return!1;if(s+=l,(n+=i)<=i){if(s>=l||n>s)return!1}else if(s>=l&&n>s)return!1;return!0}return!1},Rectangle.prototype.intersects=function(t){if("Rectangle"===t.constructor.name){let e=t.left,i=t.right(),r=t.top,n=t.bottom();return this.left<i&&e<this.right&&this.top<n&&r<this.bottom&&(this.left<e&&(this.left=e),this.top<r&&(this.top=r),this.right>i&&(this.right=i),this.bottom>n&&(this.bottom=n),!0)}return!1},Rectangle.prototype.intersection=function(t){if("Rectangle"===t.constructor.name){var e=this.left,i=this.top,r=t.left,n=t.top,o=e;o+=this.width;var s=i;s+=this.height;var a=r,l=n;return e<r&&(e=r),i<n&&(i=n),o>(a+=t.width)&&(o=a),s>(l+=t.height)&&(s=l),s-=i,(o-=e)<Number.MIN_VALUE&&(o=Number.MIN_VALUE),s<Number.MIN_VALUE&&(s=Number.MIN_VALUE),new Rectangle(e,i,o,s)}return null},Rectangle.prototype.union=function(t){if("Rectangle"===t.constructor.name){var e=this.width,i=this.height;if((e|i)<0)return new Rectangle(t);var r=t.width,n=t.height;if((r|n)<0)return new Rectangle(this);var o=this.left,s=this.top;e+=o,i+=s;var a=t.left,l=t.top;return o>a&&(o=a),s>l&&(s=l),e<(r+=a)&&(e=r),i<(n+=l)&&(i=n),i-=s,(e-=o)>Number.MAX_VALUE&&(e=Number.MAX_VALUE),i>Number.MAX_VALUE&&(i=Number.MAX_VALUE),new Rectangle(o,s,e,i)}return null},Rectangle.prototype.draw=function(t,e,i){if("string"==typeof t&&"string"==typeof e&&"number"==typeof i){var r=document.getElementById(t).getContext("2d");r.beginPath(),r.lineWidth=i,r.strokeStyle=e,r.rect(this.left,this.top,this.width,this.height),r.stroke()}else logger("Invalid Rectangle draw args")},Rectangle.prototype.fill=function(t,e,i){if("string"==typeof t&&"string"==typeof e&&"number"==typeof i){var r=document.getElementById(t).getContext("2d");r.beginPath(),r.lineWidth=i,r.strokeStyle=e,r.fillRect(this.left,this.top,this.width,this.height),r.stroke()}else logger("Invalid Rectangle draw args")},EllipseModel.prototype.getBiggestRectangle=function(){var t=new Rectangle;return t.x=this.center.x-.5*this.size.width*Math.sqrt(2),t.y=this.center.y-.5*this.size.height*Math.sqrt(2),t.width=this.size.width*Math.sqrt(2),t.height=this.size.height*Math.sqrt(2),t},EllipseModel.prototype.area=function(){return Math.PI*this.size.width*this.size.height},EllipseModel.prototype.getX=function(t){var e=[],i=Math.pow((t-this.center.y)/this.size.height,2);return e.push(this.center.x+this.size.width*sqrt(1-i)),e.push(this.center.x-this.size.width*sqrt(1-i)),e},EllipseModel.prototype.getY=function(t){var e=[],i=pow((t-this.center.x)/this.size.width,2);return e.push(this.center.y+this.size.height*sqrt(1-i)),e.push(this.center.y-this.size.height*sqrt(1-i)),e},EllipseModel.prototype.isOnEllipse=function(t){return approxEquals(Math.pow((t.x-this.center.x)/this.size.width,2)+Math.pow((t.y-this.center.y)/this.size.height,2),1)},EllipseModel.prototype.contains=function(t){if("FloatPoint"===t.constructor.name){var e,i,r,n,o=new Line(t,this.center),s=lineIntersection(o);e=parseFloat(s[0]),i=parseFloat(s[1]),r=parseFloat(s[2]),n=parseFloat(s[3]);var a=e<=t.x&&r>=t.x||r<=t.x&&e>=t.x,l=i<=t.y&&n>=t.y||n<=t.y&&i>=t.y;return a&&l}return!1},EllipseModel.prototype.lineIntersection=function(t){if("Line"===t.constructor.name){var e=[],i=t.m,r=t.c,n=new Quadratic(pow(this.size.height,2)+pow(this.size.width*i,2),2*(pow(this.size.width,2)*i*(r-this.center.y)-pow(this.size.height,2)*this.center.x),pow(this.center.x*this.size.height,2)+pow(this.size.width,2)*(pow(r-this.center.y,2)-pow(this.size.height,2))).solutionArray();try{e[0]=n[0],e[1]=n[1],e[2]=String.valueOf(i*parseFloat(n[0])+r),e[3]=String.valueOf(i*parseFloat(n[1])+r),(n=[])[0].push(e[0]),n[1].push(e[2]),n[2].push(e[1]),n[3].push(e[3])}catch(t){n=null,e=null}return n}return null},EllipseModel.prototype.intersectsWithLine=function(t){if("Line"===t.constructor.name){var e=!1;try{for(var i=lineIntersection(t),r=0;r<i.length;r++){i[r];e=!0}}catch(t){e=!1}return e}return!1},EllipseModel.prototype.isBiggerThan=function(t){return this.area()>t.area()},EllipseModel.prototype.isSmallerThan=function(t){return this.area()<t.area()},EllipseModel.prototype.hasAlmostSameSizeAs=function(t){return approxEquals(this.area(),t.area())},EllipseModel.prototype.hasSameSizeAs=function(t){return this.area()===t.area()},EllipseModel.prototype.intersection=function(t){var e=new FloatPoint(t.x,t.y),i=t.getSize(),r=e.x,n=e.y,o=this.center.x,s=this.center.y,a=i.width,l=i.height,u=getWidth(),h=getHeight(),c=[],p=[new FloatPoint,new FloatPoint],d=[new FloatPoint,new FloatPoint],f=[new FloatPoint,new FloatPoint],y=[new FloatPoint,new FloatPoint],g=0;try{g=u*sqrt(1-pow((n-s)/h,2)),p[0].x=o+g,p[0].y=n,p[1].x=o-g,p[1].y=n,null===p[0]||Number.isNaN(p[0].x)||Number.isNaN(p[0].y)||c.add(p[0]),null===p[1]||Number.isNaN(p[1].x)||Number.isNaN(p[1].y)||c.add(p[1])}catch(t){}try{g=u*Math.sqrt(1-pow((n+l-s)/h,2)),d[0].x=o+g,d[0].y=n+l,d[1].x=o-g,d[1].y=n+l,null===d[0]||Number.isNaN(d[0].x)||Number.isNaN(d[0].y)||c.add(d[0]),null===d[1]||Number.isNaN(d[1].x)||Number.isNaN(d[1].y)||c.add(d[1])}catch(t){}try{g=h*Math.sqrt(1-pow((r-o)/u,2)),f[0].x=r,f[0].y=s+g,f[1].x=r,f[1].y=s-g,null===f[0]||Number.isNaN(f[0].x)||Number.isNaN(f[0].y)||c.add(f[0]),null===f[1]||Number.isNaN(f[1].x)||Number.isNaN(f[1].y)||c.add(f[1])}catch(t){}try{g=h*sqrt(1-pow((r+a-o)/u,2)),y[0].x=r+a,y[0].y=s+g,y[1].x=r+a,y[1].y=s-g,null===y[0]||Number.isNaN(y[0].x)||Number.isNaN(y[0].y)||c.add(y[0]),null===y[1]||Number.isNaN(y[1].x)||Number.isNaN(y[1].y)||c.add(y[1])}catch(t){}return c},EllipseModel.prototype.intersectsWithRect=function(t){var e=new FloatPoint(t.x,t.y),i=t.getSize(),r=e.x,n=e.y,o=getXCenter(),s=getYCenter(),a=i.getWidth(),l=i.height,u=getWidth(),h=getHeight(),c=[new FloatPoint,new FloatPoint],p=[new FloatPoint,new FloatPoint],d=[new FloatPoint,new FloatPoint],f=[new FloatPoint,new FloatPoint],y=0,g=!1,m=!1,w=!1,v=!1;try{y=u*Math.sqrt(1-pow((n-s)/h,2)),c[0].x=o+y,c[0].y=n,c[1].x=o-y,c[1].y=n,(t.containsPoint(c[0].x,c[0].y)&&this.contains(c[0])||t.containsPoint(c[1].x,c[1].y)&&this.contains(c[1]))&&(g=!0)}catch(t){}try{y=u*Math.sqrt(1-pow((n+l-s)/h,2)),p[0].x=o+y,p[0].y=n+l,p[1].x=o-y,p[1].y=n+l,(t.containsPoint(p[0].x,p[0].y)&&this.contains(p[0])||t.containsPoint(p[1].x,p[1].y)&&this.contains(p[1]))&&(m=!0)}catch(t){}try{y=h*Math.sqrt(1-pow((r-o)/u,2)),d[0].x=r,d[0].y=s+y,d[1].x=r,d[1].y=s-y,(t.containsPoint(d[0].x,d[0].y)&&this.contains(d[0])||t.containsPoint(d[1].x,d[1].y)&&this.contains(d[1]))&&(w=!0)}catch(t){}try{y=h*Math.sqrt(1-pow((r+a-o)/u,2)),f[0].x=r+a,f[0].y=s+y,f[1].x=r+a,f[1].y=s-y,(t.containsPoint(f[0].x,f[0].y)&&this.contains(f[0])||t.containsPoint(f[1].x,f[1].y)&&this.contains(f[1]))&&(v=!0)}catch(t){}return g||m||w||v},EllipseModel.prototype.intersectsWith=function(t){var e=new Line(this.center,t.center);if(this.center.equals(t.center))return!0;var i=t.lineIntersection(e);try{var r=new FloatPoint(parseFloat(i[0]),parseFloat(i[1])),n=new FloatPoint(parseFloat(i[2]),parseFloat(i[3]));return!(!this.contains(r)&&!this.contains(n))}catch(t){return!1}},Random.prototype.nextInt=function(t){return randomInt(0,t-1)},Random.prototype.nextBool=function(){return 1===randomInt(0,1)},Random.prototype.generateUUID=function(){var t=(new Date).getTime(),e=performance&&performance.now&&1e3*performance.now()||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(i){var r=16*Math.random();return t>0?(r=(t+r)%16|0,t=Math.floor(t/16)):(r=(e+r)%16|0,e=Math.floor(e/16)),("x"===i?r:3&r|8).toString(16)})};const PIXEL_RATIO=function(){let t=document.createElement("canvas").getContext("2d");return(window.devicePixelRatio||window.webkitDevicePixelRatio||window.mozDevicePixelRatio||1)/(t.webkitBackingStorePixelRatio||t.mozBackingStorePixelRatio||t.msBackingStorePixelRatio||t.oBackingStorePixelRatio||t.backingStorePixelRatio||1)}(),Gravity={LEFT:"left",RIGHT:"right",CENTER:"center"},FontStyle={REGULAR:"normal",OBLIQUE:"oblique",ITALIC:"italic",BOLD:"bold",BOLDER:"bolder",LIGHTER:"lighter",REGULAR_100:"100",REGULAR_200:"200",REGULAR_300:"300",REGULAR_400:"400",REGULAR_500:"500",REGULAR_600:"600",REGULAR_700:"700",REGULAR_800:"800",REGULAR_900:"900",ITALIC_100:"italic 100",ITALIC_200:"italic 200",ITALIC_300:"italic 300",ITALIC_400:"italic 400",ITALIC_500:"italic 500",ITALIC_600:"italic 600",ITALIC_700:"italic 700",ITALIC_800:"italic 800",ITALIC_900:"italic 900",OBLIQUE_100:"oblique 100",OBLIQUE_200:"oblique 200",OBLIQUE_300:"oblique 300",OBLIQUE_400:"oblique 400",OBLIQUE_500:"oblique 500",OBLIQUE_600:"oblique 600",OBLIQUE_700:"oblique 700",OBLIQUE_800:"oblique 800",OBLIQUE_900:"oblique 900",BOLD_ITALIC:"italic bold",BOLDER_ITALIC:"italic bolder",LIGHTER_ITALIC:"italic lighter",BOLD_OBLIQUE:"oblique bold",BOLDER_OBLIQUE:"oblique bolder",LIGHTER_OBLIQUE:"oblique lighter"},FontStyleValues=getObjectValues(FontStyle).sort(function(t,e){return e.length-t.length});function Polygon(t,e,i){this.bounds=new Rectangle,t&&e&&t.length!==e.length?logger("xpoints and ypoints must have the same size."):("[object Array]"!==Object.prototype.toString.call(t)?(logger("xpoints must be an array of integer numbers"),this.xpoints=[]):this.xpoints=t,"[object Array]"!==Object.prototype.toString.call(e)?(logger("ypoints must be an array of integer numbers"),this.ypoints=[]):this.ypoints=e,"number"!=typeof i?(logger("npoints must be an integer number"),i=this.xpoints.length):this.npoints=i)}function Font(t,e,i,r,n){this.style=t,this.size=e,this.name=i,this.variant=n||null,this.sizeUnits=void 0===r?CssSizeUnits.EM:r}function Graphics(t,e){let i,r=PIXEL_RATIO;if(2===arguments.length){if(("number"!=typeof t||"number"!=typeof e)&&("string"!=typeof t||"string"!=typeof e||isNaN(t=parseInt(t))||isNaN(t=parseInt(e))))throw"Supply the width and height in css pixels!";i=document.createElement("canvas"),i.style.width=t+"px",i.style.height=e+"px",i.width=t*r,i.height=e*r,i.style.visibility="hidden",i.setAttribute("id","canvas-"+ULID.ulid()),document.body.appendChild(i)}else{if("canvas"!==t.nodeName.toLowerCase())throw"Supply either the width and height(in css pixels), or supply a canvas element to build the graphics on!";{i=t;let e=i.getBoundingClientRect();i.width=Math.round(e.right*r)-Math.round(e.left*r),i.height=Math.round(e.bottom*r)-Math.round(e.top*r),i.style.width=e.width+"px",i.style.height=e.height+"px"}}this.ctx=i.getContext("2d"),this.ctx.scale(r,r),this.ctx.strokeStyle="#000",this.ctx.lineWidth=1,this.ctx.globalAlpha=1,this.ctx.fillStyle="#FFF",this.ctx.font="bold 0.9em Arial",this.width=i.width,this.height=i.height,this.imageCacheUnitPx=this.createImageData(1,1),this.imageCacheQuadPx=this.createImageData(2,2)}function LineAndWidth(t,e){if("string"!=typeof t||"number"!=typeof e)return this.text="",void(this.width=0);this.text=t,this.width=e}Polygon.prototype.addPoint=function(t,e){if("number"!=typeof t)throw"x must be an integer number";if("number"!=typeof e)throw"y must be an integer number";this.xpoints.push(t),this.ypoints.push(e),this.npoints+=1},Polygon.prototype.addPoints=function(t,e){"[object Array]"===Object.prototype.toString.call(t)?"[object Array]"===Object.prototype.toString.call(e)?t.length===e.length?(Array.prototype.push.apply(this.xpoints,t),Array.prototype.push.apply(this.ypoints,e),this.npoints+=t.length):logger("xpts and ypts must have the same length"):logger("ypts must be an array of integer numbers"):logger("xpts must be an array of integer numbers")},Polygon.prototype.contains=function(t,e){if(this.npoints<=2||!this.getBoundingBox().contains(t,e))return!1;for(var i,r,n=0,o=xpoints[npoints-1],s=ypoints[npoints-1],a=0;a<npoints;a++)if(i=xpoints[a],(r=ypoints[a])!==s){var l,u,h;if(i<o){if(t>=o)continue;l=i}else{if(t>=i)continue;l=o}if(r<s){if(e<r||e>=s)continue;if(t<l){n++;continue}u=t-i,h=e-r}else{if(e<s||e>=r)continue;if(t<l){n++;continue}u=t-o,h=e-s}u<h/(s-r)*(o-i)&&n++}return o=i,s=r,!!(1&n)},Polygon.prototype.getBoundingBox=function(){return 0===this.npoints?new Rectangle:(null===bounds&&this.calculateBounds(this.xpoints,this.ypoints,this.npoints),this.bounds.getBounds())},Polygon.prototype.calculateBounds=function(t,e,i){if("[object Array]"===Object.prototype.toString.call(t))if("[object Array]"===Object.prototype.toString.call(e)){"number"!=typeof i&&logger("npts must be an integer number");for(var r=Number.MAX_VALUE,n=Number.MAX_VALUE,o=Number.MIN_VALUE,s=Number.MIN_VALUE,a=0;a<npoints;a++){var l=t[a];r=Math.min(r,l),o=Math.max(o,l);var u=e[a];n=Math.min(n,u),s=Math.max(s,u)}this.bounds=new Rectangle(r,n,o,s)}else logger("ypts must be an array of integer numbers");else logger("xpts must be an array of integer numbers")},Polygon.prototype.updateBounds=function(t,e){t<this.bounds.x?(this.bounds.width=this.bounds.width+(this.bounds.x-t),this.bounds.x=t):this.bounds.width=Math.max(this.bounds.width,t-this.bounds.x),e<this.bounds.y?(this.bounds.height=this.bounds.height+(this.bounds.y-e),this.bounds.y=e):this.bounds.height=Math.max(this.bounds.height,e-this.bounds.y)},Font.prototype.string=function(){return this.variant&&"normal"!==this.variant?this.variant+" "+this.style+" "+this.size*PIXEL_RATIO+this.sizeUnits+" "+this.name:this.style+" "+this.size*PIXEL_RATIO+this.sizeUnits+" "+this.name},Font.prototype.getSize=function(){return this.size},createHiDPICanvas=function(t,e,i,r){return r||(r=PIXEL_RATIO),t.width=e*r,t.height=i*r,t.style.width=e+"px",t.style.height=i+"px",t.getContext("2d").setTransform(r,0,0,r,0,0),t},Graphics.prototype.destroy=function(){this.ctx.canvas=null,this.ctx=null,this.width=this.height=null},Graphics.prototype.clear=function(){this.ctx.clearRect(0,0,this.width,this.height)},Graphics.prototype.getCanvas=function(){return this.ctx.canvas},Graphics.prototype.reloadCanvas=function(t,e){this.ctx.scale(1/PIXEL_RATIO,1/PIXEL_RATIO);let i=this.getCanvas();if(t){if("number"!=typeof t)throw"The width must be a number in pixels";i.style.width=t+"px"}else{t=i.getBoundingClientRect().width}if(e){if("number"!=typeof e)throw"The height must be a number in pixels";i.style.height=e+"px"}else{e=i.getBoundingClientRect().height}i.width=t*PIXEL_RATIO,i.height=e*PIXEL_RATIO,this.width=i.width,this.height=i.height,this.ctx.scale(PIXEL_RATIO,PIXEL_RATIO)},Graphics.prototype.scale=function(t,e){this.ctx.scale(t,e)},Graphics.prototype.setFont=function(t){"Font"===t.constructor.name&&(this.ctx.font=t.string())},Graphics.prototype.getFont=function(){return this.ctx.font},Graphics.prototype.scaleFontUpByDPR=function(){this.ctx.font=this.ctx.font.replace(/(\d+)(px|em|rem|pt)/g,function(t,e,i){return e*PIXEL_RATIO+i})},Graphics.prototype.scaleFontDownByDPR=function(){this.ctx.font=this.ctx.font.replace(/(\d+)(px|em|rem|pt)/g,function(t,e,i){return e/PIXEL_RATIO+i})},Graphics.prototype.rotate=function(t){if(!t)throw"No angle specified!";if("number"!=typeof t)throw"Invalid angle specified!";this.ctx.rotate(t)},Graphics.prototype.rotateDegs=function(t){this.rotate(t*Math.PI/180)},Graphics.prototype.rotateAt=function(t,e,i,r){if("number"!=typeof t)throw"Invalid angle specified!";if(this.ctx.save(),this.ctx.translate(e,i),this.ctx.rotate(t),"function"==typeof r&&r(),this.ctx.restore(),"function"!=typeof r)throw"`task` should be a function!"},Graphics.prototype.rotateDegsAt=function(t,e,i,r){0!==t?this.rotateAt(t*Math.PI/180,e,i,r):r()},Graphics.prototype.setColor=function(t){"string"==typeof t&&(this.ctx.strokeStyle=t)},Graphics.prototype.setBackground=function(t){"string"==typeof t&&(this.ctx.fillStyle=t)},Graphics.prototype.setTextBaseLine=function(t){this.ctx.textBaseline=t},Graphics.prototype.setTextAlign=function(t){this.ctx.textAlign=t},Graphics.prototype.setStrokeWidth=function(t){"number"==typeof t&&(this.ctx.lineWidth=t)},Graphics.prototype.getStrokeWidth=function(){return this.ctx.lineWidth},Graphics.prototype.getStrokeColor=function(){return this.ctx.strokeStyle},Graphics.prototype.getFillColor=function(){return this.ctx.fillStyle},Graphics.prototype.setAlpha=function(t){"number"==typeof t&&(this.ctx.globalAlpha=t)},Graphics.prototype.getAlpha=function(){return this.ctx.globalAlpha},Graphics.prototype.lineJoinStyle=function(t){"string"==typeof t&&(this.ctx.lineJoin=t)},Graphics.prototype.lineCapStyle=function(t){"string"==typeof t&&(this.ctx.lineCap=t)},Graphics.prototype.normalizeQuantity=function(t){if("number"==typeof t)return t*PIXEL_RATIO;throw new Error("Only numbers can be normalized")},Graphics.prototype.drawRect=function(t,e,i,r){"number"==typeof t&&"number"==typeof e&&"number"==typeof i&&"number"==typeof r&&this.ctx.strokeRect(t,e,PIXEL_RATIO*i,PIXEL_RATIO*r)},Graphics.prototype.fillRect=function(t,e,i,r){"number"==typeof t&&"number"==typeof e&&"number"==typeof i&&"number"==typeof r&&this.ctx.fillRect(t,e,PIXEL_RATIO*i,PIXEL_RATIO*r)},Graphics.prototype.drawPoint=function(t,e){"number"==typeof t&&"number"==typeof e&&(this.ctx.beginPath(),this.ctx.moveTo(t,e),this.ctx.lineTo(t+.1,e),this.ctx.closePath(),this.ctx.stroke())},Graphics.prototype.beginPath=function(){this.ctx.beginPath()},Graphics.prototype.moveTo=function(t,e){"number"==typeof t&&"number"==typeof e&&this.ctx.moveTo(t,e)},Graphics.prototype.lineTo=function(t,e){"number"==typeof t&&"number"==typeof e&&this.ctx.lineTo(t,e)},Graphics.prototype.closePath=function(){this.ctx.closePath()},Graphics.prototype.stroke=function(){this.ctx.stroke()},Graphics.prototype.fill=function(){this.ctx.fill()},Graphics.prototype.drawRoundRect=function(t,e,i,r,n){if("number"==typeof t&&"number"==typeof e&&"number"==typeof i&&"number"==typeof r&&"number"==typeof n){if(void 0===n&&(n=5),"number"==typeof n)n={tl:n,tr:n,br:n,bl:n};else{var o={tl:0,tr:0,br:0,bl:0};for(var s in o)n[s]=n[s]||o[s]}this.ctx.beginPath(),this.ctx.moveTo(t+n.tl,e),this.ctx.lineTo(t+i-n.tr,e),this.ctx.quadraticCurveTo(t+i,e,t+i,e+n.tr),this.ctx.lineTo(t+i,e+r-n.br),this.ctx.quadraticCurveTo(t+i,e+r,t+i-n.br,e+r),this.ctx.lineTo(t+n.bl,e+r),this.ctx.quadraticCurveTo(t,e+r,t,e+r-n.bl),this.ctx.lineTo(t,e+n.tl),this.ctx.quadraticCurveTo(t,e,t+n.tl,e),this.ctx.closePath(),this.ctx.stroke()}},Graphics.prototype.fillRoundRect=function(t,e,i,r,n){if("number"==typeof t&&"number"==typeof e&&"number"==typeof i&&"number"==typeof r&&"number"==typeof n){if("undefined"==typeof stroke&&(stroke=!0),void 0===n&&(n=5),"number"==typeof n)n={tl:n,tr:n,br:n,bl:n};else{var o={tl:0,tr:0,br:0,bl:0};for(var s in o)n[s]=n[s]||o[s]}this.ctx.beginPath(),this.ctx.moveTo(t+n.tl,e),this.ctx.lineTo(t+i-n.tr,e),this.ctx.quadraticCurveTo(t+i,e,t+i,e+n.tr),this.ctx.lineTo(t+i,e+r-n.br),this.ctx.quadraticCurveTo(t+i,e+r,t+i-n.br,e+r),this.ctx.lineTo(t+n.bl,e+r),this.ctx.quadraticCurveTo(t,e+r,t,e+r-n.bl),this.ctx.lineTo(t,e+n.tl),this.ctx.quadraticCurveTo(t,e,t+n.tl,e),this.ctx.fill()}},Graphics.prototype.fillRoundRectLeftSide=function(t,e,i,r,n){if("number"==typeof t&&"number"==typeof e&&"number"==typeof i&&"number"==typeof r&&"number"==typeof n){if("undefined"==typeof stroke&&(stroke=!0),void 0===n&&(n=5),"number"==typeof n)n={tl:n,tr:0,br:0,bl:n};else{var o={tl:0,tr:0,br:0,bl:0};for(var s in o)n[s]=n[s]||o[s]}this.ctx.beginPath(),this.ctx.moveTo(t+n.tl,e),this.ctx.lineTo(t+i-n.tr,e),this.ctx.quadraticCurveTo(t+i,e,t+i,e+n.tr),this.ctx.lineTo(t+i,e+r-n.br),this.ctx.quadraticCurveTo(t+i,e+r,t+i-n.br,e+r),this.ctx.lineTo(t+n.bl,e+r),this.ctx.quadraticCurveTo(t,e+r,t,e+r-n.bl),this.ctx.lineTo(t,e+n.tl),this.ctx.quadraticCurveTo(t,e,t+n.tl,e),this.ctx.fill()}},Graphics.prototype.fillRoundRectRightSide=function(t,e,i,r,n){if("number"==typeof t&&"number"==typeof e&&"number"==typeof i&&"number"==typeof r&&"number"==typeof n){if("undefined"==typeof stroke&&(stroke=!0),void 0===n&&(n=5),"number"==typeof n)n={tl:0,tr:n,br:n,bl:0};else{var o={tl:0,tr:0,br:0,bl:0};for(var s in o)n[s]=n[s]||o[s]}this.ctx.beginPath(),this.ctx.moveTo(t+n.tl,e),this.ctx.lineTo(t+i-n.tr,e),this.ctx.quadraticCurveTo(t+i,e,t+i,e+n.tr),this.ctx.lineTo(t+i,e+r-n.br),this.ctx.quadraticCurveTo(t+i,e+r,t+i-n.br,e+r),this.ctx.lineTo(t+n.bl,e+r),this.ctx.quadraticCurveTo(t,e+r,t,e+r-n.bl),this.ctx.lineTo(t,e+n.tl),this.ctx.quadraticCurveTo(t,e,t+n.tl,e),this.ctx.fill()}},Graphics.prototype.fillRoundRectTopSide=function(t,e,i,r,n){if("number"==typeof t&&"number"==typeof e&&"number"==typeof i&&"number"==typeof r&&"number"==typeof n){if("undefined"==typeof stroke&&(stroke=!0),void 0===n&&(n=5),"number"==typeof n)n={tl:n,tr:n,br:0,bl:0};else{var o={tl:0,tr:0,br:0,bl:0};for(var s in o)n[s]=n[s]||o[s]}this.ctx.beginPath(),this.ctx.moveTo(t+n.tl,e),this.ctx.lineTo(t+i-n.tr,e),this.ctx.quadraticCurveTo(t+i,e,t+i,e+n.tr),this.ctx.lineTo(t+i,e+r-n.br),this.ctx.quadraticCurveTo(t+i,e+r,t+i-n.br,e+r),this.ctx.lineTo(t+n.bl,e+r),this.ctx.quadraticCurveTo(t,e+r,t,e+r-n.bl),this.ctx.lineTo(t,e+n.tl),this.ctx.quadraticCurveTo(t,e,t+n.tl,e),this.ctx.fill()}},Graphics.prototype.fillRoundRectBottomSide=function(t,e,i,r,n){if("number"==typeof t&&"number"==typeof e&&"number"==typeof i&&"number"==typeof r&&"number"==typeof n){if("undefined"==typeof stroke&&(stroke=!0),void 0===n&&(n=5),"number"==typeof n)n={tl:0,tr:0,br:n,bl:n};else{var o={tl:0,tr:0,br:0,bl:0};for(var s in o)n[s]=n[s]||o[s]}this.ctx.beginPath(),this.ctx.moveTo(t+n.tl,e),this.ctx.lineTo(t+i-n.tr,e),this.ctx.quadraticCurveTo(t+i,e,t+i,e+n.tr),this.ctx.lineTo(t+i,e+r-n.br),this.ctx.quadraticCurveTo(t+i,e+r,t+i-n.br,e+r),this.ctx.lineTo(t+n.bl,e+r),this.ctx.quadraticCurveTo(t,e+r,t,e+r-n.bl),this.ctx.lineTo(t,e+n.tl),this.ctx.quadraticCurveTo(t,e,t+n.tl,e),this.ctx.fill()}},Graphics.prototype.drawEllipse=function(t,e,i,r,n,o,s,a){"number"==typeof t&&"number"==typeof e&&"number"==typeof i&&"number"==typeof r&&"number"==typeof n&&"number"==typeof o&&"number"==typeof s&&"boolean"==typeof a&&(this.ctx.beginPath(),this.ctx.ellipse(t,e,i,r,n,o,s,a),this.ctx.closePath(),this.ctx.stroke())},Graphics.prototype.fillEllipse=function(t,e,i,r,n,o,s,a){"number"==typeof t&&"number"==typeof e&&"number"==typeof i&&"number"==typeof r&&"number"==typeof n&&"number"==typeof o&&"number"==typeof s&&"boolean"==typeof a&&(this.ctx.beginPath(),this.ctx.ellipse(t,e,i,r,n,o,s,a),this.ctx.fill())},Graphics.prototype.drawOval=function(t,e,i,r){"number"==typeof t&&"number"==typeof e&&"number"==typeof i&&"number"==typeof r&&(this.ctx.beginPath(),this.ctx.ellipse(t,e,i,r,0,0,2*Math.PI,!1),this.ctx.closePath(),this.ctx.stroke())},Graphics.prototype.drawOvalFromTopLeft=function(t,e,i,r){if("number"==typeof t&&"number"==typeof e&&"number"==typeof i&&"number"==typeof r){let n=t+i,o=e+r;this.ctx.beginPath(),this.ctx.ellipse(n,o,i,r,0,0,2*Math.PI,!1),this.ctx.closePath(),this.ctx.stroke()}},Graphics.prototype.fillOval=function(t,e,i,r){"number"==typeof t&&"number"==typeof e&&"number"==typeof i&&"number"==typeof r&&(this.ctx.beginPath(),this.ctx.ellipse(t,e,i,r,0,0,2*Math.PI,!1),this.ctx.fill())},Graphics.prototype.fillOvalFromTopLeft=function(t,e,i,r){if("number"==typeof t&&"number"==typeof e&&"number"==typeof i&&"number"==typeof r){let n=t+i,o=e+r;this.ctx.beginPath(),this.ctx.ellipse(n,o,i,r,0,0,2*Math.PI,!1),this.ctx.fill()}},Graphics.prototype.drawCircle=function(t,e,i){"number"==typeof t&&"number"==typeof e&&"number"==typeof i&&this.drawOval(t,e,i,i)},Graphics.prototype.drawCircleFromTopLeft=function(t,e,i){"number"==typeof cenX&&"number"==typeof cenY&&"number"==typeof i&&this.drawOvalFromTopLeft(t,e,i,i)},Graphics.prototype.fillCircle=function(t,e,i){"number"==typeof t&&"number"==typeof e&&"number"==typeof i&&this.fillOval(t,e,i,i)},Graphics.prototype.fillCircleFromTopLeft=function(t,e,i){"number"==typeof t&&"number"==typeof e&&"number"==typeof i&&this.fillOvalFromTopLeft(t,e,i,i)},Graphics.prototype.drawArc=function(t,e,i,r,n,o){"number"==typeof t&&"number"==typeof e&&"number"==typeof i&&"number"==typeof r&&"number"==typeof n&&"boolean"==typeof o&&(this.ctx.beginPath(),this.ctx.arc(t,e,i,r,n,o),this.ctx.stroke())},Graphics.prototype.drawArcFromTopLeft=function(t,e,i,r,n,o){if("number"==typeof t&&"number"==typeof e&&"number"==typeof i&&"number"==typeof r&&"number"==typeof n&&"boolean"==typeof o){let s=t+i,a=e+i;this.ctx.beginPath(),this.ctx.arc(s,a,i,r,n,o),this.ctx.stroke()}},Graphics.prototype.drawLine=function(t,e,i,r){"number"==typeof t&&"number"==typeof e&&"number"==typeof i&&"number"==typeof r&&(this.ctx.beginPath(),this.ctx.moveTo(t,e),this.ctx.lineTo(i,r),this.ctx.stroke())},Graphics.prototype.drawPolygon=function(t){if("Polygon"===t.constructor.name){var e=0,i=0;this.ctx.beginPath();for(var r=0;r<t.xpoints.length;r++)e=t.xpoints[r],i=t.ypoints[r],0===r?this.ctx.moveTo(e,i):this.ctx.lineTo(e,i);this.ctx.lineTo(e,i),this.ctx.closePath(),this.ctx.stroke()}},Graphics.prototype.fillPolygon=function(t){if(t&&"Polygon"===t.constructor.name){let e=0,i=0;this.ctx.beginPath();for(let r=0;r<t.xpoints.length;r++)e=t.xpoints[r],i=t.ypoints[r],0===r?this.ctx.moveTo(e,i):this.ctx.lineTo(e,i);this.ctx.lineTo(e,i),this.ctx.closePath(),this.ctx.fill()}},Graphics.prototype.drawPolygonFromVertices=function(t,e,i){if("[object Array]"===Object.prototype.toString.call(t))if("[object Array]"===Object.prototype.toString.call(e))if("number"==typeof i)if(t.length===e.length){var r=0,n=0;this.ctx.beginPath();for(var o=0;o<t.length;o++){r=t[o],n=e[o];0===o?this.ctx.moveTo(r,n):this.ctx.lineTo(r,n)}this.ctx.lineTo(r,n),this.ctx.closePath(),this.ctx.stroke()}else logger("xpoints and ypoints must have the same size.");else logger("npoints must be an integer number");else logger("ypoints must be an array of integer numbers");else logger("xpoints must be an array of integer numbers")},Graphics.prototype.fillPolygonFromVertices=function(t,e,i){if("[object Array]"===Object.prototype.toString.call(t))if("[object Array]"===Object.prototype.toString.call(e))if("number"==typeof i)if(t.length===e.length){var r=0,n=0;this.ctx.beginPath();for(var o=0;o<t.length;o++){r=t[o],n=e[o];0===o?this.ctx.moveTo(r,n):this.ctx.lineTo(r,n)}this.ctx.lineTo(r,n),this.ctx.closePath(),this.fill()}else logger("xpoints and ypoints must have the same size.");else logger("npoints must be an integer number");else logger("ypoints must be an array of integer numbers");else logger("xpoints must be an array of integer numbers")},Graphics.prototype.save=function(){this.ctx.save()},Graphics.prototype.getBlobFromCanvas=function(t,e,i){t.toBlob(function(t){i(t)},e)},Graphics.prototype.getHorizontalExtent=function(){let t={left:0,top:0,right:0,bottom:0,width:0,height:0},e=this.getImageData(0,0,this.width,this.height).data,i=!1,r=!1,n=this.width,o=this.height,s=o,a=n;for(a=n;!i&&a;)for(a--,s=0;s<o;s++)if(e[s*n*4+4*a+3]){i=a+1,t.right=a+1;break}for(a=0;!r&&a<i;){for(s=0;s<o;s++)if(e[s*n*4+4*a+3]){r=a,t.left=a,t.width=i-r-1;break}if(a++,r)return{left:t.left,right:t.right}}return null},Graphics.prototype.getVerticalExtent=function(){let t={left:0,top:0,right:0,bottom:0,width:0,height:0},e=this.getImageData(0,0,this.width,this.height).data,i=!1,r=!1,n=this.width,o=this.height,s=0;for(;!r&&o;)for(o--,s=0;s<n;s++)if(e[o*n*4+4*s+3]){r=o+1,t.bottom=o+1;break}for(o=0;!i&&o<r;){for(s=0;s<n;s++)if(e[o*n*4+4*s+3]){i=o-1,t.top=o-1,t.height=r-i-1;break}if(o++,i)return{top:t.top,bottom:t.bottom}}return null},Graphics.prototype.getBoundingBox=function(){let t={left:0,top:0,right:0,bottom:0,width:0,height:0},e=this.getImageData(0,0,this.width,this.height).data,i=!1,r=!1,n=!1,o=!1,s=this.width,a=this.height,l=a,u=0;for(;!r&&l;)for(l--,u=0;u<s;u++)if(e[l*s*4+4*u+3]){r=l+1,t.bottom=l+1;break}for(l=0;!i&&l<r;){for(u=0;u<s;u++)if(e[l*s*4+4*u+3]){i=l-1,t.top=l-1,t.height=r-i-1;break}l++}for(u=s;!n&&u;)for(u--,l=0;l<a;l++)if(e[l*s*4+4*u+3]){n=u+1,t.right=u+1;break}for(u=0;!o&&u<n;){for(l=0;l<a;l++)if(e[l*s*4+4*u+3]){o=u,t.left=u,t.width=n-o-1;break}if(u++,o)return new Rectangle(t.left,t.top,t.right,t.bottom)}return null},Graphics.prototype.getFittedPNG=function(t,e){if(e){if("function"!=typeof e)throw new Error("If you are supplying a callback, then it has to be a function!");if(1!==e.length)throw new Error("Your callback function should have only 1 parameter, this is a blob that contains the fitted PNG image")}t=this.normalizeQuantity(t);let i=this.getBoundingBox(),r=i.left,n=i.top,o=i.right,s=i.bottom,a=document.createElement("canvas");return a.width=o-r,a.height=s-n,a.width+=2*t,a.height+=2*t,a.getContext("2d").drawImage(this.getCanvas(),r-t,n-t,a.width,a.height,0,0,a.width,a.height),this.getBlobFromCanvas(a,"image/png",e)},Graphics.prototype.drawHollowString=function(t,e,i){this.ctx.strokeText(t,e,i)},Graphics.prototype.drawString=function(t,e,i){this.ctx.fillText(t,e,i)},Graphics.prototype.drawImageAt=function(t,e,i){"number"==typeof e&&"number"==typeof i&&this.ctx.drawImage(t,e,i)},Graphics.prototype.drawImageAtLocWithSize=function(t,e,i,r,n){"number"==typeof e&&"number"==typeof i&&"number"==typeof r&&"number"==typeof n&&this.ctx.drawImage(t,e,i,r,n)},Graphics.prototype.drawImage=function(t,e,i,r,n,o,s,a,l){"number"==typeof e&&"number"==typeof i&&"number"==typeof r&&"number"==typeof n&&"number"==typeof o&&"number"==typeof s&&"number"==typeof a&&"number"==typeof l&&this.ctx.drawImage(t,e,i,r,n,o,s,a,l)},Graphics.prototype.createImageData=function(t,e){return"number"==typeof t&&"number"==typeof e?this.ctx.createImageData(t,e):1===arguments.length?this.ctx.createImageData(t):void 0},Graphics.prototype.getImageData=function(t,e,i,r){if("number"==typeof t&&"number"==typeof e&&"number"==typeof i&&"number"==typeof r)return this.ctx.getImageData(t,e,i,r)},Graphics.prototype.putImageData=function(t,e,i,r,n,o,s){if("number"==typeof e&&"number"==typeof i)return this.ctx.putImageData(t,e,i,r,n,o,s)},Graphics.prototype.drawPixel=function(t,e,i,r,n,o){if("number"==typeof t&&"number"==typeof e){i="number"==typeof i&&i>=0&&i<256?i:0,r="number"==typeof r&&r>=0&&r<256?r:0,n="number"==typeof n&&n>=0&&n<256?n:0,o="number"==typeof o&&o>=0&&o<256?o:255;let s=this.imageCacheUnitPx.data;s[0]=i,s[1]=r,s[2]=n,s[3]=o,this.ctx.putImageData(this.imageCacheUnitPx,t,e)}},Graphics.prototype.drawDoublePixel=function(t,e,i,r,n,o){if("number"==typeof t&&"number"==typeof e){i="number"==typeof i&&i>=0&&i<256?i:0,r="number"==typeof r&&r>=0&&r<256?r:0,n="number"==typeof n&&n>=0&&n<256?n:0,o="number"==typeof o&&o>=0&&o<256?o:255;let s=this.imageCacheQuadPx.data;s[0]=i,s[1]=r,s[2]=n,s[3]=o,s[4]=i,s[5]=r,s[6]=n,s[7]=o,s[8]=i,s[9]=r,s[10]=n,s[11]=o,s[12]=i,s[13]=r,s[14]=n,s[15]=o,this.ctx.putImageData(this.imageCacheQuadPx,t,e)}},Graphics.prototype.stringWidth=function(t){return"string"==typeof t?this.ctx.measureText(t).width:0},Graphics.prototype.getTextWidth=function(t){if("string"==typeof t){if(0===t.length)return 0;let e=document.createElement("canvas");e.width=this.width,e.height=this.height,e.style.width=this.width+"px",e.style.height=this.height+"px",document.body.appendChild(e);let i=new Graphics(e);i.ctx.font=this.ctx.font,i.setBackground("#000"),i.drawString(t,10,e.height/2);let r=i.getHorizontalExtent();if(e.remove(),i.clear(),i.destroy(),i=null,r)return r.right-r.left}return null},Graphics.prototype.getTextHeight=function(t){if("string"==typeof t){if(0===t.length)return 0;let e=document.createElement("canvas");e.width=this.width,e.height=this.height,e.style.width=this.width+"px",e.style.height=this.height+"px",document.body.appendChild(e);let i=new Graphics(e);i.ctx.font=this.ctx.font,i.setBackground("#000"),i.drawString(t,10,e.height/2);let r=i.getVerticalExtent();if(e.remove(),i.clear(),i.destroy(),i=null,r)return r.bottom-r.top}return null},Graphics.prototype.getTextSize=function(t){if("string"==typeof t){if(0===t.length)return new Rectangle(0,0,0,0);let e=document.createElement("canvas");e.width=this.width,e.height=this.height,e.style.width=this.width+"px",e.style.height=this.height+"px",document.body.appendChild(e);let i=new Graphics(e);i.ctx.font=this.ctx.font,i.setBackground("#000"),i.drawString(t,10,e.height/2);let r=i.getBoundingBox();return e.remove(),i.clear(),i.destroy(),i=null,r}return null},Graphics.prototype.getTextSizes=function(t){if(isOneDimArray(t)){if(0===t.length)return new Rectangle(0,0,0,0);let e=document.createElement("canvas");e.width=this.width,e.height=this.height,e.style.width=this.width+"px",e.style.height=this.height+"px",document.body.appendChild(e);let i=new Graphics(e);i.ctx.font=this.ctx.font,i.setBackground("#000");let r=[];for(let n=0;n<t.length;n++){i.drawString(t[n],10,e.height/2);let o=i.getBoundingBox();i.clear(),r.push(o)}return e.remove(),i.destroy(),i=null,rect}return null},Graphics.prototype.textHeight=function(t){return"string"==typeof t?this.ctx.measureText("M").width:0},Graphics.prototype.scanLines=function(t,e){let i=[],r=this.ctx,n=new StringBuffer;for(var o=0;o<t.length;o++)if(r.measureText(n.toString()).width<e)n.append(t.substring(o,o+1));else{let e=n.toString(),s={width:r.measureText(e).width,text:e};i.push(s),n=new StringBuffer,n.append(t.substring(o,o+1))}if(n.toString().length>0){let t=n.toString(),e={width:r.measureText(t).width,text:t};i.push(e)}return i},Graphics.prototype.draw3DRect=function(t,e,i,r,n,o,s,a){let l=this.ctx;if("string"!=typeof n)throw"The shadow color must be a string and a valid color";if("number"!=typeof o)throw"The shadow blur must be a number, say 5";if("number"!=typeof s)throw"The shadow offset along x must be a number, say 2";if("number"!=typeof a)throw"The shadow offset along y must be a number, say 2";l.shadowColor=n,l.shadowBlur=o,l.shadowOffsetX=s,l.shadowOffsetY=a,this.drawRect(t,e,i,r)},Graphics.prototype.fill3DRect=function(t,e,i,r,n,o,s,a){let l=this.ctx;if("string"!=typeof n)throw"The shadow color must be a string and a valid color";if("number"!=typeof o)throw"The shadow blur must be a number, say 5";if("number"!=typeof s)throw"The shadow offset along x must be a number, say 2";if("number"!=typeof a)throw"The shadow offset along y must be a number, say 2";l.shadowColor=n,l.shadowBlur=o,l.shadowOffsetX=s,l.shadowOffsetY=a,this.fillRect(t,e,i,r)},Graphics.prototype.getLinesByMaxWidthAlgorithm=function(t,e){let i=[],r=this.ctx,n=new Scanner(t,!0,["\r\n","\t","\r"," ","\n"]).scan(),o=n.length,s=new StringBuffer,a=0;for(let t=0;t<o;t++){let o=n[t],l=r.measureText(s.toString()+o).width;l<e?s.append(o):l===e||"\r\n"===o||"\r"===o||"\n"===o?(s.append(o),i.push(new LineAndWidth(s.toString(),l)),s.reset()):l>e&&(""!==s.toString()&&i.push(new LineAndWidth(s.toString(),a)),s.reset(),s.append(o)),a=l}let l=s.toString();return l.length>0&&i.push(new LineAndWidth(l,r.measureText(l).width)),i};const MysteryConstants={DRAW_SQUARE:1,DRAW_RECT:2,DRAW_CIRCLE:3,DRAW_OVAL:4,DRAW_DOT:5,DRAW_DOT2:6,DRAW_LINE:7,DRAW_STAR:8,DRAW_LETTER:9,DRAW_TRIANGLE:10,DRAW_TEXT:11,DRAW_ROTATED_SQUARE:12,DRAW_ROTATED_RECT:13,DRAW_ROTATED_TRIANGLE:14,DRAW_ROTATED_STAR:15,DRAW_ROTATED_OVAL:16,DRAW_POLYGON:17,DRAW_ROTATED_TEXT:18,DENSITY_SCALE:1e-5,DEF_ALPHA:1},MysteryModes={ALL:"all",STAR:"star",LINE:"line",DOT:"dot",DOT2:"dot2",TEXT:"text",TRIANGLE:"triangle",SQUARE:"square",OVAL:"oval",CIRCLE:"circle",POLYGON:"polygon",COMBO:"combo"};function MysteryImage(t){if(!t)throw"No initializing options specified!";if(this.rnd=new Random,this.mode=MysteryModes.ALL,this.comboArray=[],this.state=MysteryConstants.DRAW_ROTATED_TEXT,this.id="mystery_"+this.rnd.generateUUID(),this.width=100,t.width)if("number"==typeof t.width)this.width=t.width;else{if("string"!=typeof t.width)throw"Invalid value specified for `width`";try{this.width=parseInt(t.width)}catch(t){throw t}}if(this.height=100,t.height)if("number"==typeof t.height)this.height=t.height;else{if("string"!=typeof t.height)throw"Invalid value specified for `height`";try{this.height=parseInt(t.height)}catch(t){throw t}}if(t.mode){if("string"!=typeof t.mode)throw"Invalid value specified for `mode`";{let e=this;if(-1===t.mode.indexOf(",")){let i=!1;if(Object.keys(MysteryModes).forEach(function(r){t.mode===r.toLowerCase()&&(e.mode=r,i=!0)}),!i)throw"invalid mi-mode: `"+t.mode+"`"}else{let i=t.mode.replace(/\s/g,"").split(",");for(let r=0;r<i.length;r++){let n=!1,o=i[r];if(Object.keys(MysteryModes).forEach(function(t){o===t.toLowerCase()&&(e.comboArray.push(t),n=!0)}),!n)throw"invalid mi-mode: `"+t.mode+"`"}this.mode=MysteryModes.COMBO}}}if(this.numShapes=20,t.numShapes)if("number"==typeof t.numShapes)this.numShapes=t.numShapes;else{if("string"!=typeof t.numShapes)throw"Invalid value specified for `numShapes`";try{this.numShapes=parseInt(t.numShapes)}catch(t){throw t}}if(this.fontName="Segoe UI",t.fontName){if("string"!=typeof t.fontName)throw"Bad value specified for `fontName`";this.fontName=t.fontName}if(this.strokeWidth=1,t.strokeWidth)if("number"==typeof t.strokeWidth)this.strokeWidth=t.strokeWidth;else{if("string"!=typeof t.strokeWidth)throw"Invalid value specified for `strokeWidth`";try{this.strokeWidth=parseInt(t.strokeWidth)}catch(t){throw t}}if(this.fontSize=12,t.fontSize)if("number"==typeof t.fontSize)this.fontSize=t.fontSize;else{if("string"!=typeof t.fontSize)throw"Invalid value specified for `fontSize`";this.fontSize=parseInt(t.fontSize)}if(this.fontStyle=FontStyle.REGULAR,t.fontStyle){if("string"!=typeof t.fontStyle)throw"Invalid value specified for `fontStyle`";if(-1===FontStyleValues.indexOf(t.fontStyle))throw"Invalid value specified for font size";this.fontStyle=t.fontStyle}if(this.sizeUnits=CssSizeUnits.PX,t.sizeUnits)if("string"==typeof t.sizeUnits){if(-1===CssSizeUnitsValues.indexOf(t.sizeUnits))throw"Invalid size unit specified for font size";this.sizeUnits=t.sizeUnits}else this.sizeUnits=CssSizeUnits.PX;if(this.minSize=12,t.minSize)if("number"==typeof t.minSize)this.minSize=t.minSize;else{if("string"!=typeof t.minSize)throw"Invalid value specified for `minSize`";try{this.minSize=parseInt(t.minSize)}catch(t){throw t}}if(this.shapesDensity=0,t.shapesDensity)if("number"==typeof t.shapesDensity)this.shapesDensity=t.shapesDensity;else{if("string"!=typeof t.shapesDensity)throw"Invalid value specified for `shapesDensity`";try{this.shapesDensity=parseInt(t.shapesDensity)}catch(t){throw t}}if(this.opacity=MysteryConstants.DEF_ALPHA,t.opacity)if("number"==typeof t.opacity)this.opacity=t.opacity;else{if("string"!=typeof t.opacity)throw"Invalid value specified for `opacity`";try{this.opacity=parseFloat(t.opacity)}catch(t){throw t}}if(this.fgColor="#000",t.fgColor){if("string"!=typeof t.fgColor)throw"Invalid value specified for `fgColor`";this.fgColor=t.fgColor}if(this.bgColor="#FFF",t.bgColor){if("string"!=typeof t.bgColor)throw"Invalid value specified for `bgColor`";this.bgColor=t.bgColor}if(this.cacheAfterDraw=!0,"boolean"==typeof t.cacheAfterDraw&&(this.cacheAfterDraw=t.cacheAfterDraw),this.bgOpacityEnabled=!1,"boolean"==typeof t.bgOpacityEnabled&&(this.bgOpacityEnabled=t.bgOpacityEnabled),this.textOnly=!1,t.textOnly){if("boolean"!=typeof t.textOnly)throw"Invalid value specified for `textOnly`";this.textOnly=t.textOnly}if(this.textArray=[],t.textArray){if(!isOneDimArray(t.textArray))throw"Invalid value specified for `textArray`";this.textArray=t.textArray}this.imageCache=null,this.g=new Graphics(this.width,this.height),this.font=new Font(this.fontStyle,this.fontSize,this.fontName,this.sizeUnits),this.g.setFont(this.font),this.g.setStrokeWidth(this.strokeWidth),this.g.setBackground(this.bgColor),this.g.setColor(this.fgColor),this.g.setAlpha(this.opacity),this.fgColor=this.g.ctx.strokeStyle,this.bgColor=this.g.ctx.fillStyle}function makeCanvas(t,e,i){let r=document.createElement("canvas");return t&&(r.id=t),r.width=e,r.height=i,r.style.border="0px solid",document.body.appendChild(r),r}function invertColor(t){if(0===t.indexOf("#")&&(t=t.slice(1)),3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6!==t.length)throw new Error("Invalid HEX color.");var e=(255-parseInt(t.slice(0,2),16)).toString(16),i=(255-parseInt(t.slice(2,4),16)).toString(16),r=(255-parseInt(t.slice(4,6),16)).toString(16);return"#"+padZero(e)+padZero(i)+padZero(r)}function padZero(t,e){return e=e||2,(new Array(e).join("0")+t).slice(-e)}function calibrate(t,e,i,r){let n=t.getAlpha();t.setAlpha(1),t.setColor("pink"),t.setBackground("white");let o=new Font(FontStyle.REGULAR,8,"Kartika",CssSizeUnits.PX,"normal");for(let i=0;i<e;i+=50)t.drawLine(i,0,i,20),t.setFont(o),t.drawString(""+i,i,30),t.setFont(r);t.setColor("pink"),t.setBackground("white");for(let e=0;e<i;e+=50)t.setFont(r),t.drawLine(0,e,20,e),t.setFont(o),t.drawString(""+e,30,e);t.setAlpha(n)}function drawBus(t,e,i){let r=new BusView(sz,e,i,t);r.draw();let n=r.imageCache;return r.cleanup(),n}function drawStar(t,e,i){let r=new Graphics(t,t);r.setBackground(e);let n=.5*thickness,o=.5*size,s=new Point(x+o,y+o),a=s.x-n,l=s.y-n,u=new Rectangle(a,l,a+thickness,l+thickness),h=[x,u.left,x+o,u.right(),x+size,u.right(),x+o,u.left,x],c=[y+o,u.top,y,u.top,y+o,u.bottom(),y+size,u.bottom(),y+o];i?r.fillPolygonFromVertices(h,c,9):r.drawPolygonFromVertices(h,c,9);r.getCanvas();r.clear(),r.getCanvas().remove()}function BusView(t,e,i,r){this.mainColor=e,this.minorColor=i,this.busRadius=r,this.imageCache=null;let n=this.makeCanvas(t,t);this.g=new Graphics(n),this.alphaRange={MIN_ALPHA:80,MAX_ALPHA:255},this.opacityValue=this.alphaRange.MIN_ALPHA,this.busArchitecture=new BusArchitecture(t)}function BusArchitecture(t){if(!t||"number"!=typeof t)throw"invalid argument for bus width";this.busWidth=t,this.busHeight=0,this.busWheelWidth=0,this.busWheelsSpan=0,this.busWheelsY=0,this.busSemiCircularHollowForWheelWidth=0,this.busSemiCircularHollowForWheelY=0,this.busSemiCircularHollowSpan=0,this.busRimWidth=0,this.busLowerRectWidth=0,this.busLowerRectHeight=0,this.busLowerRectX=0,this.busLowerRectY=0,this.busWindowX=0,this.busWindowY=0,this.busWindowWidth=0,this.busWindowHeight=0,this.busWindowGap=0,this.busLowerRodBetweenTiresWidth=0,this.busLowerRodBetweenTiresHeight=0,this.busLowerRodBetweenTiresX=0,this.busLowerRodBetweenTiresY=0,this.busFenderWidth=0,this.busFenderHeight=0,this.fenderDisplacementBehindBus=0,this.fenderY=0,this.structure={STD_BUS_WIDTH:920,STD_BUS_HEIGHT:572,STD_BUS_WHEEL_WIDTH:176,STD_BUS_WHEEL_Y:490,STD_BUS_SEMI_CIRCLE_HOLLOW_FOR_WHEEL_Y:485,STD_BUS_SEMI_CIRCLE_HOLLOW_FOR_WHEEL_WIDTH:188,STD_BUS_SEMI_CIRCLE_HOLLOW_SPAN:690,STD_BUS_RIM_WIDTH:90,STD_BUS_LOWER_RECT_WIDTH:665,STD_BUS_LOWER_RECT_HEIGHT:203,STD_BUS_LOWER_RECT_X:124,STD_BUS_LOWER_RECT_Y:266,STD_BUS_LOWER_ROD_BETWEEN_TIRES_WIDTH:320,STD_BUS_LOWER_ROD_BETWEEN_TIRES_HEIGHT:20,STD_BUS_LOWER_ROD_BETWEEN_TIRES_X:296,STD_BUS_LOWER_ROD_BETWEEN_TIRES_Y:508,STD_BUS_WINDOW_X:123,STD_BUS_WINDOW_Y:100,STD_BUS_WHEELS_SPAN:682,STD_BUS_WINDOW_WIDTH:160,STD_BUS_WINDOW_HEIGHT:130,STD_BUS_WINDOW_GAP:92.5,STD_BUS_FENDER_WIDTH:969,STD_BUS_FENDER_HEIGHT:85,STD_BUS_FENDER_DISPLACEMENT_BEHIND_BUS:12,STD_BUS_FENDER_Y:485},this.init()}MysteryImage.prototype.cleanup=function(){this.imageCache=null,this.g.clear(),this.g.getCanvas().remove()},MysteryImage.prototype.getImage=function(){return this.g.getCanvas().toDataURL()},MysteryImage.prototype.drawSquare=function(t,e,i,r){let n=this.g;r?n.fillRect(t,e,i,i):n.drawRect(t,e,i,i)},MysteryImage.prototype.drawDot=function(t,e,i){let r=this.g,n=i/2,o=getRGB(this.fgColor),s=o.r,a=o.g,l=o.b,u=255*o.a;r.drawPixel(t+n,e+n,s,a,l,u)},MysteryImage.prototype.drawDoubleDot=function(t,e,i){let r=this.g,n=i/2,o=getRGB(this.fgColor),s=o.r,a=o.g,l=o.b,u=255*o.a;r.drawDoublePixel(t+n,e+n,s,a,l,u)},MysteryImage.prototype.drawRotatedSquare=function(t,e,i,r,n){let o=this.g;o.rotateDegsAt(r,t+i/2,e+i/2,function(){n?o.fillRect(-i/2,-i/2,i,i):o.drawRect(-i/2,-i/2,i,i)})},MysteryImage.prototype.drawRect=function(t,e,i,r){let n=this.g,o=i,s=i/2,a=s+this.rnd.nextInt(s+1);o=this.rnd.nextBool()?a:o;let l=[o,a],u=this.rnd.nextInt(2);o=l[u],a=0===u?l[1]:l[0],r?n.fillRect(t,e,o,a):n.drawRect(t,e,o,a)},MysteryImage.prototype.drawPolygon=function(t,e,i,r){let n=this.g,o=this;let s=[function(){let r=new Polygon([],[],0);return r.addPoint(t,e),r.addPoint(t+i/4,e),r.addPoint(t+i/4,e+3*i/4),r.addPoint(t+i,e+3*i/4),r.addPoint(t+i,e+i),r.addPoint(t,e+i),r.addPoint(t,e),r},function(){let r=new Polygon([],[],0);return r.addPoint(t+3*i/4,e),r.addPoint(t+i,e),r.addPoint(t+i,e+i),r.addPoint(t,e+i),r.addPoint(t,e+3*i/4),r.addPoint(t+3*i/4,e+3*i/4),r.addPoint(t+3*i/4,e),r},function(){let r=new Polygon([],[],0);return r.addPoint(t,e),r.addPoint(t+i,e),r.addPoint(t+i,e+i/4),r.addPoint(t+i/4,e+i/4),r.addPoint(t+i/4,e+i),r.addPoint(t,e+i),r.addPoint(t,e),r},function(){let r=new Polygon([],[],0);return r.addPoint(t,e),r.addPoint(t+i,e),r.addPoint(t+i,e+i),r.addPoint(t+3*i/4,e+i),r.addPoint(t+3*i/4,e+i/4),r.addPoint(t,e+i/4),r.addPoint(t,e),r},function(){let r=new Polygon([],[],0);return r.addPoint(t,e),r.addPoint(t+i/4,e),r.addPoint(t+i/4,e+3*i/4),r.addPoint(t+3*i/4,e+3*i/4),r.addPoint(t+3*i/4,e),r.addPoint(t+i,e),r.addPoint(t+i,e+i),r.addPoint(t,e+i),r.addPoint(t,e),r},function(){let r=new Polygon([],[],0);return r.addPoint(t,e),r.addPoint(t+i,e),r.addPoint(t+i,e+i),r.addPoint(t+3*i/4,e+i),r.addPoint(t+3*i/4,e+i/4),r.addPoint(t+i/4,e+i/4),r.addPoint(t+i/4,e+i),r.addPoint(t,e+i),r.addPoint(t,e),r},function(){let r=new Polygon([],[],0);return r.addPoint(t+3*i/8,e),r.addPoint(t+3*i/8,e+3*i/8),r.addPoint(t,e+3*i/8),r.addPoint(t,e+5*i/8),r.addPoint(t+3*i/8,e+5*i/8),r.addPoint(t+3*i/8,e+i),r.addPoint(t+5*i/8,e+i),r.addPoint(t+5*i/8,e+5*i/8),r.addPoint(t+i,e+5*i/8),r.addPoint(t+i,e+3*i/8),r.addPoint(t+5*i/8,e+3*i/8),r.addPoint(t+5*i/8,e),r},function(){let r=new Polygon([],[],0);return r.addPoint(t+i/4,e),r.addPoint(t+3*i/4,e),r.addPoint(t+i,e+i/2),r.addPoint(t+3*i/4,e+i),r.addPoint(t+i/4,e+i),r.addPoint(t,e+i/2),r.addPoint(t+i/4,e),r},function(){let r=new Polygon([],[],0),n=[],s=4+o.rnd.nextInt(5),a=[e,e+i/4,e+3*i/4,e+i];for(let e=0;e<s;e++){let e=t+o.rnd.nextInt(i),r=a[o.rnd.nextInt(a.length)];n.push(new Point(e,r))}n.sort(function(t,e){return t.x-e.x});for(let t=0;t<n.length;t++)r.addPoint(n[t].x,n[t].y);return r}],a=s[this.rnd.nextInt(s.length)]();r||(r=this.rnd.nextInt(4)>0),r?n.fillPolygon(a):n.drawPolygon(a)},MysteryImage.prototype.drawRotatedRect=function(t,e,i,r,n){let o=this.g,s=i,a=i/2,l=a+this.rnd.nextInt(a+1);s=this.rnd.nextBool()?l:s;let u=[s,l],h=this.rnd.nextInt(2);s=u[h],l=0===h?u[1]:u[0],o.rotateDegsAt(r,t+s/2,e+l/2,function(){n?o.fillRect(-s/2,-l/2,s,l):o.drawRect(-s/2,-l/2,s,l)})},MysteryImage.prototype.drawCircle=function(t,e,i,r){let n=this.g,o=i/2;r?n.fillCircle(t,e,o):n.drawCircle(t,e,o)},MysteryImage.prototype.drawOval=function(t,e,i,r){let n=this.g,o=i,s=i/2,a=s+this.rnd.nextInt(s+1);o=this.rnd.nextBool()?a:o;let l=[o,a],u=this.rnd.nextInt(2);o=l[u],a=0===u?l[1]:l[0],r?n.fillOval(t,e,o,a):n.drawOval(t,e,o,a)},MysteryImage.prototype.drawRotatedOval=function(t,e,i,r,n){let o=this.g,s=i,a=i/2,l=a+this.rnd.nextInt(a+1);s=this.rnd.nextBool()?l:s;let u=[s,l],h=this.rnd.nextInt(2);s=u[h],l=0===h?u[1]:u[0],o.rotateDegsAt(r,t,e,function(){n?o.fillOval(0,0,s,l):o.drawOval(0,0,s,l)})},MysteryImage.prototype.drawLine=function(t,e,i,r){let n=this.g,o=i/2;n.rotateDegsAt(r,t+o,e+o,function(){n.drawLine(-o,-o,-o+i,-o)})},MysteryImage.prototype.drawStar=function(t,e,i,r,n){let o=this.g,s=.5*r,a=.5*i,l=new Point(t+a,e+a),u=l.x-s,h=l.y-s,c=new Rectangle(u,h,u+r,h+r),p=[t,c.left,t+a,c.right(),t+i,c.right(),t+a,c.left,t],d=[e+a,c.top,e,c.top,e+a,c.bottom(),e+i,c.bottom(),e+a];n?o.fillPolygonFromVertices(p,d,9):o.drawPolygonFromVertices(p,d,9)},MysteryImage.prototype.drawRotatedStar=function(t,e,i,r,n,o){let s=this.g,a=this,l=i/2;s.rotateDegsAt(n,t+l,e+l,function(){a.drawStar(-l,-l,i,r,o)})},MysteryImage.prototype.drawTriangle=function(t,e,i,r){let n=this.g,o=.5*i,s=[t+o,t,t+i,t+o],a=[e,e+i,e+i,e];r?n.fillPolygonFromVertices(s,a,s.length):n.drawPolygonFromVertices(s,a,s.length)},MysteryImage.prototype.drawRotatedTriangle=function(t,e,i,r,n){let o=this.g,s=this,a=i/2;o.rotateDegsAt(r,t+a,e+a,function(){s.drawTriangle(-a,-a,i,n)})},MysteryImage.prototype.drawText=function(t,e){if(this.textArray&&this.textArray.length>0){let i=this.g,r=this.textArray.length,n=this.rnd.nextInt(r),o=this.textArray[n],s=i.stringWidth(o),a=i.textHeight(o);return i.drawString(o,t,e+a),{width:s,height:a}}},MysteryImage.prototype.drawRotatedText=function(t,e,i,r){if(this.textArray&&this.textArray.length>0){let n=this.g,o=this,s=this.rnd.nextInt(this.textArray.length),a=this.textArray[s],l=i/2,u=n.textHeight(a);n.rotateDegsAt(r,t+l,e+l,function(){o.drawText(-l,u-l)})}},MysteryImage.prototype.drawBus=function(t,e,i){let r=this.g,n=new BusView(i,this.fgColor,invertColor(this.fgColor),16);n.draw(),r.drawImageAtLocWithSize(n.imageCache,t,e,i,i),n.cleanup()},MysteryImage.prototype.drawRotatedBus=function(t,e,i,r){let n=this.g,o=new BusView(i,this.fgColor,invertColor(this.fgColor),16);o.draw();let s=o.imageCache,a=i/2;n.rotateDegsAt(r,t+a,e+a,function(){n.drawImage(s,-a,-a),o.cleanup()})},MysteryImage.prototype.generateRect=function(t,e){let i=t/PIXEL_RATIO,r=e/PIXEL_RATIO,n=this.minSize/PIXEL_RATIO,o=n+this.rnd.nextInt(n+1),s=this.rnd.nextInt(i),a=this.rnd.nextInt(r);return s+o>=i&&(s=i-2*o),a+o>=r&&(a=r-2*o),new Rectangle(s,a,s+o,a+o)},MysteryImage.prototype.maxIterations=function(){return 12*this.numShapes},MysteryImage.prototype.baseDraw=function(t,e){let i=this.g,r=t*e,n=this.rnd;i.setAlpha(!0===this.bgOpacityEnabled?this.opacity:1),i.setBackground(this.bgColor),i.fillRect(0,0,t,e);let o=this.maxIterations();i.setAlpha(this.opacity),this.shapesDensity>0&&(this.numShapes=this.shapesDensity*r*MysteryConstants.DENSITY_SCALE);let s=0,a=[];for(;a.length<this.numShapes&&s<o;){this.mode.toLowerCase()===MysteryModes.ALL.toLowerCase()?this.textOnly?this.state=n.nextBool()?MysteryConstants.DRAW_TEXT:MysteryConstants.DRAW_ROTATED_TEXT:this.state=1+n.nextInt(0===this.textArray.length?MysteryConstants.DRAW_POLYGON:MysteryConstants.DRAW_ROTATED_TEXT):this.selectStateFromMode(this.mode);let r=n.nextBool(),o=1+n.nextInt(360),l=this.generateRect(t,e);l.angle=o;let u=!1;for(let t=0;t<a.length;t++){let e=a[t];if(l.intersects(e)){u=!0;break}}if(i.setBackground(this.fgColor),u)s++;else{switch(a.push(l),i.setColor(this.fgColor),i.setBackground(this.fgColor),this.state){case MysteryConstants.DRAW_SQUARE:this.drawSquare(l.left,l.top,l.width,r);break;case MysteryConstants.DRAW_RECT:this.drawRect(l.left,l.top,l.width,r);break;case MysteryConstants.DRAW_CIRCLE:this.drawCircle(l.left,l.top,l.width,this.mode.toLowerCase()===MysteryModes.CIRCLE||r);break;case MysteryConstants.DRAW_OVAL:this.drawOval(l.left,l.top,l.width,r);break;case MysteryConstants.DRAW_LINE:this.drawLine(l.left,l.top,l.width,o);break;case MysteryConstants.DRAW_STAR:this.drawStar(l.left,l.top,l.width,l.width/4,r);break;case MysteryConstants.DRAW_ROTATED_STAR:this.drawRotatedStar(l.left,l.top,l.width,l.width/4,o,r);break;case MysteryConstants.DRAW_TRIANGLE:this.drawTriangle(l.left,l.top,l.width,r);break;case MysteryConstants.DRAW_ROTATED_SQUARE:this.drawRotatedSquare(l.left,l.top,l.width,o,r);break;case MysteryConstants.DRAW_ROTATED_RECT:this.drawRotatedRect(l.left,l.top,l.width,o,r);break;case MysteryConstants.DRAW_ROTATED_TRIANGLE:this.drawRotatedTriangle(l.left,l.top,l.width,o,r);break;case MysteryConstants.DRAW_TEXT:this.drawText(l.left,l.top,l.width);break;case MysteryConstants.DRAW_ROTATED_TEXT:this.drawRotatedText(l.left,l.top,l.width,o);break;case MysteryConstants.DRAW_ROTATED_OVAL:this.drawRotatedOval(l.centerX(),l.centerY(),l.width,o);break;case MysteryConstants.DRAW_POLYGON:this.drawPolygon(l.left,l.top,l.width,r);break;case MysteryConstants.DRAW_DOT:this.drawDot(l.left,l.top,4);break;case MysteryConstants.DRAW_DOT2:this.drawDoubleDot(l.left,l.top,8)}l.state=this.state}}},MysteryImage.prototype.selectStateFromMode=function(t){let e=this.rnd;switch(t.toLowerCase()){case MysteryModes.OVAL:this.state=e.nextBool()?MysteryConstants.DRAW_OVAL:MysteryConstants.DRAW_ROTATED_OVAL;break;case MysteryModes.DOT:this.state=MysteryConstants.DRAW_DOT;break;case MysteryModes.DOT2:this.state=MysteryConstants.DRAW_DOT2;break;case MysteryModes.CIRCLE:this.state=MysteryConstants.DRAW_CIRCLE;break;case MysteryModes.TEXT:this.state=e.nextBool()?MysteryConstants.DRAW_TEXT:MysteryConstants.DRAW_ROTATED_TEXT;break;case MysteryModes.TRIANGLE:this.state=e.nextBool()?MysteryConstants.DRAW_TRIANGLE:MysteryConstants.DRAW_ROTATED_TRIANGLE;break;case MysteryModes.STAR:this.state=e.nextBool()?MysteryConstants.DRAW_STAR:MysteryConstants.DRAW_ROTATED_STAR;break;case MysteryModes.LINE:this.state=MysteryConstants.DRAW_LINE;break;case MysteryModes.SQUARE:this.state=e.nextBool()?MysteryConstants.DRAW_SQUARE:MysteryConstants.DRAW_ROTATED_SQUARE;break;case MysteryModes.POLYGON:this.state=MysteryConstants.DRAW_POLYGON;break;case MysteryModes.COMBO:let t=this.comboArray[e.nextInt(this.comboArray.length)];this.selectStateFromMode(t)}},MysteryImage.prototype.draw=function(){let t=this.g,e=t.width,i=t.height;return this.cacheAfterDraw&&null!==this.imageCache?t.drawImageAtLocWithSize(this.imageCache,0,0,e,i):(this.baseDraw(e,i),this.imageCache=t.getImageData(0,0,e,i)),this.imageCache},BusView.prototype.makeCanvas=function(t,e){let i=document.createElement("canvas");return i.id="bus-canv-"+(new Date).getTime(),i.width=t,i.height=e,i.style.border="0px solid",document.body.appendChild(i),i},BusView.prototype.cleanup=function(){this.imageCache=null,this.g.clear(),this.g.getCanvas().remove()},BusArchitecture.prototype.init=function(){let t=this.busWidth/this.structure.STD_BUS_WIDTH;this.busHeight=t*this.structure.STD_BUS_HEIGHT,this.busWheelWidth=t*this.structure.STD_BUS_WHEEL_WIDTH,this.busWheelsY=t*this.structure.STD_BUS_WHEEL_Y,this.busSemiCircularHollowForWheelWidth=t*this.structure.STD_BUS_SEMI_CIRCLE_HOLLOW_FOR_WHEEL_WIDTH,this.busSemiCircularHollowForWheelY=t*this.structure.STD_BUS_SEMI_CIRCLE_HOLLOW_FOR_WHEEL_Y,this.busSemiCircularHollowSpan=t*this.structure.STD_BUS_SEMI_CIRCLE_HOLLOW_SPAN,this.busRimWidth=t*this.structure.STD_BUS_RIM_WIDTH,this.busLowerRectWidth=t*this.structure.STD_BUS_LOWER_RECT_WIDTH,this.busLowerRectHeight=t*this.structure.STD_BUS_LOWER_RECT_HEIGHT,this.busLowerRectX=t*this.structure.STD_BUS_LOWER_RECT_X,this.busLowerRectY=t*this.structure.STD_BUS_LOWER_RECT_Y,this.busWheelsSpan=t*this.structure.STD_BUS_WHEELS_SPAN,this.busLowerRodBetweenTiresWidth=t*this.structure.STD_BUS_LOWER_ROD_BETWEEN_TIRES_WIDTH,this.busLowerRodBetweenTiresHeight=t*this.structure.STD_BUS_LOWER_ROD_BETWEEN_TIRES_HEIGHT,this.busLowerRodBetweenTiresX=t*this.structure.STD_BUS_LOWER_ROD_BETWEEN_TIRES_X,this.busLowerRodBetweenTiresY=t*this.structure.STD_BUS_LOWER_ROD_BETWEEN_TIRES_Y,this.busWindowX=t*this.structure.STD_BUS_WINDOW_X,this.busWindowY=t*this.structure.STD_BUS_WINDOW_Y,this.busWindowWidth=t*this.structure.STD_BUS_WINDOW_WIDTH,this.busWindowHeight=t*this.structure.STD_BUS_WINDOW_HEIGHT,this.busWindowGap=t*this.structure.STD_BUS_WINDOW_GAP,this.busFenderWidth=t*this.structure.STD_BUS_FENDER_WIDTH,this.busFenderHeight=t*this.structure.STD_BUS_FENDER_HEIGHT,this.fenderDisplacementBehindBus=t*this.structure.STD_BUS_FENDER_DISPLACEMENT_BEHIND_BUS,this.fenderY=t*this.structure.STD_BUS_FENDER_Y},BusView.prototype.drawBus=function(){let t=this.g,e=this.busRadius<=0?16:this.busRadius,i=this.busArchitecture.busWidth,r=this.busArchitecture.busHeight,n=.5*(t.width-i),o=.5*(t.height-r);t.setBackground(this.mainColor),t.fillRoundRect(n,o,i,r,e);let s=n-this.busArchitecture.fenderDisplacementBehindBus,a=o+this.busArchitecture.fenderY;t.fillRoundRect(s,a,this.busArchitecture.busFenderWidth,this.busArchitecture.busFenderHeight,e),t.setBackground(this.minorColor);let l=n+this.busArchitecture.busWindowX,u=o+this.busArchitecture.busWindowY;t.fillRoundRect(l,u,this.busArchitecture.busWindowWidth,this.busArchitecture.busWindowHeight,4),l+=this.busArchitecture.busWindowWidth+this.busArchitecture.busWindowGap,t.fillRoundRect(l,u,this.busArchitecture.busWindowWidth,this.busArchitecture.busWindowHeight,4),l+=this.busArchitecture.busWindowWidth+this.busArchitecture.busWindowGap,t.fillRoundRect(l,u,this.busArchitecture.busWindowWidth,this.busArchitecture.busWindowHeight,4);let h=o+this.busArchitecture.busSemiCircularHollowForWheelY,c=this.busArchitecture.busSemiCircularHollowForWheelWidth,p=.5*(i-this.busArchitecture.busSemiCircularHollowSpan),d=n+p;t.drawArcFromTopLeft(d,h,d+c,h+c,-180,180,!0),d=n+(i-p-c),t.drawArcFromTopLeft(d,h,d+c,h+c,-180,180,!0),t.setBackground(this.mainColor);let f=.5*(i-this.busArchitecture.busWheelsSpan),y=.5*this.busArchitecture.busWheelWidth,g=n+f+y,m=n+(i-f-y),w=o+this.busArchitecture.busWheelsY;t.fillCircle(g,w+y,y),t.fillCircle(m,w+y,y),t.setColor(this.minorColor),t.drawCircle(g,w+y,y),t.drawCircle(m,w+y,y);let v=.5*this.busArchitecture.busRimWidth;t.setBackground(this.minorColor),t.fillCircle(g,w+y,v),t.fillCircle(m,w+y,v),t.setColor(this.minorColor),t.setStrokeWidth(1.5),t.setAlpha(this.opacityValue);let b=n+this.busArchitecture.busLowerRectX,A=o+this.busArchitecture.busLowerRectY;t.drawRoundRect(b,A,this.busArchitecture.busLowerRectWidth,this.busArchitecture.busLowerRectHeight,4),b=n+this.busArchitecture.busLowerRodBetweenTiresX,A=o+this.busArchitecture.busLowerRodBetweenTiresY;this.busArchitecture.busLowerRodBetweenTiresWidth,this.busArchitecture.busLowerRodBetweenTiresHeight;t.setBackground(this.minorColor),t.setAlpha(this.alphaRange.MAX_ALPHA),t.fillRoundRect(b,A,this.busArchitecture.busLowerRodBetweenTiresWidth,this.busArchitecture.busLowerRodBetweenTiresHeight,4)},BusView.prototype.draw=function(){let t=this.g,e=t.width,i=t.height;null!==this.imageCache?t.drawImageAtLocWithSize(this.imageCache,0,0,e,i):(this.drawBus(),this.imageCache=t.getCanvas())};let getTextSize=function(t,e){if("string"==typeof t){if(0===t.length)return new Rectangle(0,0,0,0);let i=document.createElement("canvas");i.width=1024,i.height=190,i.style.width=i.width+"px",i.style.height=i.height+"px",document.body.appendChild(i);let r=new Graphics(i);r.ctx.font=e,r.setBackground("#000"),r.drawString(t,10,i.height/2);let n=r.getBoundingBox();return i.remove(),r.clear(),r.destroy(),r=null,n}return null};function TextBox(t,e){if(!t||"object"!=typeof t)throw new Error("Invalid parameters for "+this.constructor.name);if(void 0===t.singleLine)this.singleLine=!1;else{if("boolean"!=typeof t.singleLine)throw"invalid type for options.singleLine... should be `boolean`";this.singleLine=t.singleLine}"number"==typeof t.width?this.width=t.width:"string"==typeof t.width?this.width=parseInt(t.width):this.width=100,"string"==typeof t.text?this.text=t.text:this.text="LABEL","string"==typeof t.gravity?this.gravity=t.gravity:this.gravity=Gravity.LEFT,"string"==typeof t.sizeUnits?this.sizeUnits=t.sizeUnits:this.sizeUnits=CssSizeUnits.PX,"number"==typeof t.lineSpacing?this.lineSpacing=t.lineSpacing:"string"==typeof t.lineSpacing?this.lineSpacing=parseInt(t.lineSpacing):this.lineSpacing=8,"string"==typeof t.fontName?this.fontName=t.fontName:this.fontName="Segoe UI","number"==typeof t.fontSize?this.fontSize=t.fontSize:"string"==typeof t.fontSize?this.fontSize=parseFloat(t.fontSize):this.fontSize=15,"string"==typeof t.fontStyle?this.fontStyle=t.fontStyle:this.fontStyle=FontStyle.REGULAR,"number"==typeof t.borderRadius?this.borderRadius=t.borderRadius:"string"==typeof t.borderRadius?this.borderRadius=parseInt(t.borderRadius):this.borderRadius=2,"string"==typeof t.backgroundColor?this.backgroundColor=t.backgroundColor:this.backgroundColor="#DDDDDD","string"==typeof t.textColor?this.textColor=t.textColor:this.textColor="#000000","number"==typeof t.padding?this.padding=t.padding:"string"==typeof t.padding?isNaN(this.padding=parseFloat(t.padding))&&(this.padding=0):this.padding=0,this.height=12,this.id=e.id,this.g=new Graphics(this.width,this.height),this.font=new Font(this.fontStyle,this.fontSize,this.fontName,this.sizeUnits),this.g.setFont(this.font),this.lines=[],this.textHeight=this.g.textHeight("x"),this.doMetrics(),this.render(),this.transfer(e)}TextBox.prototype.doMetrics=function(){let t,e=this.g,i=e.width,r=(e.height,this.text.trim()),n=this.padding*PIXEL_RATIO,o=this.lineSpacing*PIXEL_RATIO,s=this.singleLine,a=this.textHeight;if(s){let e=this.g.ctx.measureText(r).width+2*n;this.width=e/PIXEL_RATIO,this.lines=[],this.lines.push(new LineAndWidth(r,e)),t=1}else{let o=i-2*n;this.lines=e.getLinesByMaxWidthAlgorithm(r,o),t=this.lines.length;let s=0;if(this.lines.forEach(function(t,e,i){s<t.width&&(s=t.width)}),s>=i&&(this.width=(2*n+s)/PIXEL_RATIO,t>1)){let i=this.width*PIXEL_RATIO-2*n;this.lines=e.getLinesByMaxWidthAlgorithm(r,i),t=this.lines.length}}let l=t*a+(t-1)*o+2*n+2+.4*a;this.height=l/PIXEL_RATIO,this.remove(),this.g=new Graphics(this.width*PIXEL_RATIO,l),this.g.setFont(this.font)},TextBox.prototype.render=function(){let t=this.g,e=this.width*PIXEL_RATIO,i=this.height*PIXEL_RATIO,r=this.backgroundColor,n=this.textColor,o=this.borderRadius,s=this.gravity,a=this.padding*PIXEL_RATIO,l=this.lineSpacing*PIXEL_RATIO,u=this.textHeight,h=this.lines;if(lineCount=h.length,t.setBackground(r),t.fillRoundRect(0,0,e,i,o),t.setBackground(n),lineCount>0){let i=u+a;for(let r=0;r<lineCount;r++){let n=h[r];switch(s){case Gravity.LEFT:t.drawString(n.text,a,i);break;case Gravity.RIGHT:t.drawString(n.text,e-a-n.width,i);break;case Gravity.CENTER:t.drawString(n.text,(e-n.width)/2,i);break;default:t.drawString(n.text,a,i)}i+=u+l}}},TextBox.prototype.transfer=function(t){let e=this.g.getCanvas();t.width=e.width,t.height=e.height,t.getContext("2d").drawImage(e,0,0,e.width,e.height);const{width:i,height:r}=window.getComputedStyle(e);t.style.width=i,t.style.height=r,e.remove()},TextBox.prototype.getImage=function(){return this.g.getCanvas().toDataURL("image/png")},TextBox.prototype.getSize=function(){return{width:this.g.width,height:this.g.height}},TextBox.prototype.remove=function(){this.g.clear(),this.g.getCanvas().remove(),this.g.destroy()},TextBox.prototype.setText=function(t){const e=page.findViewById(this.id).htmlNode;this.g.clear(),this.text=t,this.doMetrics(),this.render();e.getContext("2d").clearRect(0,0,this.g.width,this.g.height),this.transfer(e)};var BuildBridgedWorker=function(t,e,i,r){var n=t.toString().match(/^\s*function\s*\(\s*\)\s*\{(([\s\S](?!\}$))*[\s\S])/)[1],o=[];o.push("var main = {};\n");for(var s=0;s<i.length;s++){"*"===(f=i[s]).charAt(f.length-1)?(f=f.substr(0,f.length-1),i[s]=f,o.push("main."+f+" = function(/* arguments */){\n var args = Array.prototype.slice.call(arguments); var buffers = args.pop(); \n self.postMessage({foo:'"+f+"', args:args},buffers)\n}; \n")):o.push("main."+f+" = function(/* arguments */){\n var args = Array.prototype.slice.call(arguments); \n self.postMessage({foo:'"+f+"', args:args})\n}; \n")}var a=[];for(s=0;s<e.length;s++){f="*"===(f=e[s]).charAt(f.length-1)?f.substr(0,f.length-1):f,a.push(f+": "+f)}o.push("var foos={"+a.join(",")+"};\n"),o.push("self.onmessage = function(e){\n"),o.push("if(e.data.foo in foos) \n foos[e.data.foo].apply(null, e.data.args); \n else \n throw(new Error('Main thread requested function ' + e.data.foo + '. But it is not available.'));\n"),o.push("\n};\n");var l,u=n+"\n\n/*==== AUTO-GENERATED-CODE ==== */\n\n"+o.join("");try{l=new Blob([u],{type:"text/javascript"})}catch(t){window.BlobBuilder=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder,(l=new BlobBuilder).append(u),l=l.getBlob()}var h=(window.URL?URL:webkitURL).createObjectURL(l),c=new Worker(h);c.onmessage=function(t){var e=i.indexOf(t.data.foo);if(-1===e)throw new Error("Worker requested function "+t.data.foo+". But it is not available.");r[e].apply(null,t.data.args)};var p={blobURL:h},d=function(t,e){return e?function(){var e=Array.prototype.slice.call(arguments),i=e.pop();c.postMessage({foo:t,args:e},i)}:function(){var e=Array.prototype.slice.call(arguments);c.postMessage({foo:t,args:e})}};for(s=0;s<e.length;s++){var f;"*"===(f=e[s]).charAt(f.length-1)?p[f=f.substr(0,f.length-1)]=d(f,!0):p[f]=d(f,!1)}return p};