@hatiolab/things-scene 3.4.47 → 3.4.48

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/things-scene.mjs CHANGED
@@ -3,4 +3,4 @@ var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?windo
3
3
  /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
4
4
  i=function(){return e};var t,e={},r=Object.prototype,a=r.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},s="function"==typeof Symbol?Symbol:{},c=s.iterator||"@@iterator",u=s.asyncIterator||"@@asyncIterator",l=s.toStringTag||"@@toStringTag";function h(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{h({},"")}catch(t){h=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var i=e&&e.prototype instanceof b?e:b,a=Object.create(i.prototype),s=new C(n||[]);return o(a,"_invoke",{value:T(t,r,s)}),a}function d(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var p="suspendedStart",g="suspendedYield",v="executing",y="completed",m={};function b(){}function x(){}function w(){}var A={};h(A,c,(function(){return this}));var _=Object.getPrototypeOf,k=_&&_(_(R([])));k&&k!==r&&a.call(k,c)&&(A=k);var E=w.prototype=b.prototype=Object.create(A);function S(t){["next","throw","return"].forEach((function(e){h(t,e,(function(t){return this._invoke(e,t)}))}))}function M(t,e){function r(i,o,s,c){var u=d(t[i],t,o);if("throw"!==u.type){var l=u.arg,h=l.value;return h&&"object"==n(h)&&a.call(h,"__await")?e.resolve(h.__await).then((function(t){r("next",t,s,c)}),(function(t){r("throw",t,s,c)})):e.resolve(h).then((function(t){l.value=t,s(l)}),(function(t){return r("throw",t,s,c)}))}c(u.arg)}var i;o(this,"_invoke",{value:function(t,n){function a(){return new e((function(e,i){r(t,n,e,i)}))}return i=i?i.then(a,a):a()}})}function T(e,r,n){var i=p;return function(a,o){if(i===v)throw new Error("Generator is already running");if(i===y){if("throw"===a)throw o;return{value:t,done:!0}}for(n.method=a,n.arg=o;;){var s=n.delegate;if(s){var c=P(s,n);if(c){if(c===m)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===p)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=v;var u=d(e,r,n);if("normal"===u.type){if(i=n.done?y:g,u.arg===m)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(i=y,n.method="throw",n.arg=u.arg)}}}function P(e,r){var n=r.method,i=e.iterator[n];if(i===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,P(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),m;var a=d(i,e.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,m;var o=a.arg;return o?o.done?(r[e.resultName]=o.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,m):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,m)}function O(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function I(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function C(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(O,this),this.reset(!0)}function R(e){if(e||""===e){var r=e[c];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,o=function r(){for(;++i<e.length;)if(a.call(e,i))return r.value=e[i],r.done=!1,r;return r.value=t,r.done=!0,r};return o.next=o}}throw new TypeError(n(e)+" is not iterable")}return x.prototype=w,o(E,"constructor",{value:w,configurable:!0}),o(w,"constructor",{value:x,configurable:!0}),x.displayName=h(w,l,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===x||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,h(t,l,"GeneratorFunction")),t.prototype=Object.create(E),t},e.awrap=function(t){return{__await:t}},S(M.prototype),h(M.prototype,u,(function(){return this})),e.AsyncIterator=M,e.async=function(t,r,n,i,a){void 0===a&&(a=Promise);var o=new M(f(t,r,n,i),a);return e.isGeneratorFunction(r)?o:o.next().then((function(t){return t.done?t.value:o.next()}))},S(E),h(E,l,"Generator"),h(E,c,(function(){return this})),h(E,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=R,C.prototype={constructor:C,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(I),!e)for(var r in this)"t"===r.charAt(0)&&a.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function n(n,i){return s.type="throw",s.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],s=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var c=a.call(o,"catchLoc"),u=a.call(o,"finallyLoc");if(c&&u){if(this.prev<o.catchLoc)return n(o.catchLoc,!0);if(this.prev<o.finallyLoc)return n(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return n(o.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return n(o.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&a.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var o=i?i.completion:{};return o.type=t,o.arg=e,i?(this.method="next",this.next=i.finallyLoc,m):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),m},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),I(r),m}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;I(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:R(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),m}},e}var a=e("./utils"),o=function(){var e=i().mark(U),r=i().mark(Y),o=i().mark(G),s=i().mark(W),c=i().mark(J),u=i().mark(ft),l=i().mark(dt),h=i().mark(pt),f=i().mark(vt),d=i().mark(kt),p=i().mark(Tt),g=i().mark(It),v=a.isNumeric,y=a.isArrayOfStrings,m=a.isArrayOfNumbers,b=a.createSequence,x=a.isSequence,w=a.isFunction,A=a.isLambda,_=a.isIterable,k=a.getFunctionArity,E=a.isDeepEqual,S=a.stringToArray;function M(t){if(void 0!==t){var e=0;return t.forEach((function(t){e+=t})),e}}function T(t){return void 0===t?0:t.length}function P(t){if(void 0!==t&&0!==t.length)return Math.max.apply(Math,t)}function O(t){if(void 0!==t&&0!==t.length)return Math.min.apply(Math,t)}function I(t){if(void 0!==t&&0!==t.length){var e=0;return t.forEach((function(t){e+=t})),e/t.length}}function C(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(void 0!==t){var r;if("string"==typeof t)r=t;else if(w(t))r="";else{if("number"==typeof t&&!isFinite(t))throw{code:"D3001",value:t,stack:(new Error).stack};var n=e?2:0;Array.isArray(t)&&t.outerWrapper&&(t=t[0]),r=JSON.stringify(t,(function(t,e){return null!=e&&e.toPrecision&&v(e)?Number(e.toPrecision(15)):e&&w(e)?"":e}),n)}return r}}function R(t,e,r){if(void 0!==t){var n=S(t),i=n.length;if(i+e<0&&(e=0),void 0!==r){if(r<=0)return"";var a=e>=0?e+r:i+e+r;return n.slice(e,a).join("")}return n.slice(e).join("")}}function j(t,e){if(void 0!==t){var r=t.indexOf(e);return r>-1?t.substr(0,r):t}}function L(t,e){if(void 0!==t){var r=t.indexOf(e);return r>-1?t.substr(r+e.length):t}}function D(t){if(void 0!==t)return t.toLowerCase()}function z(t){if(void 0!==t)return t.toUpperCase()}function F(t){if(void 0!==t)return S(t).length}function N(t){if(void 0!==t){var e=t.replace(/[ \t\n\r]+/gm," ");return" "===e.charAt(0)&&(e=e.substring(1))," "===e.charAt(e.length-1)&&(e=e.substring(0,e.length-1)),e}}function B(t,e,r){if(void 0!==t){var n;void 0!==r&&0!==r.length||(r=" ");var i=Math.abs(e)-F(t);if(i>0){var a=new Array(i+1).join(r);r.length>1&&(a=R(a,0,i)),n=e>0?t+a:a+t}else n=t;return n}}function U(t,r){var n;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.apply(this,[r]),!_(n)){e.next=4;break}return e.delegateYield(n,"t0",3);case 3:n=e.t0;case 4:if(!n||"number"==typeof n.start||"number"===n.end||Array.isArray(n.groups)||w(n.next)){e.next=6;break}throw{code:"T1010",stack:(new Error).stack};case 6:return e.abrupt("return",n);case 7:case"end":return e.stop()}}),e,this)}function Y(t,e){var n,a;return i().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(void 0!==t){r.next=2;break}return r.abrupt("return",void 0);case 2:if("string"!=typeof e){r.next=6;break}n=-1!==t.indexOf(e),r.next=9;break;case 6:return r.delegateYield(U(e,t),"t0",7);case 7:a=r.t0,n=void 0!==a;case 9:return r.abrupt("return",n);case 10:case"end":return r.stop()}}),r)}function G(t,e,r){var n,a,s;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(void 0!==t){i.next=2;break}return i.abrupt("return",void 0);case 2:if(!(r<0)){i.next=4;break}throw{stack:(new Error).stack,value:r,code:"D3040",index:3};case 4:if(n=b(),!(void 0===r||r>0)){i.next=17;break}return a=0,i.delegateYield(U(e,t),"t0",8);case 8:if(void 0===(s=i.t0)){i.next=17;break}case 10:if(void 0===s||!(void 0===r||a<r)){i.next=17;break}return n.push({match:s.match,index:s.start,groups:s.groups}),i.delegateYield(U(s.next),"t1",13);case 13:s=i.t1,a++,i.next=10;break;case 17:return i.abrupt("return",n);case 18:case"end":return i.stop()}}),o)}function W(t,e,r,n){var a,o,c,u,l,h,f,d;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(void 0!==t){i.next=2;break}return i.abrupt("return",void 0);case 2:if(a=this,""!==e){i.next=5;break}throw{code:"D3010",stack:(new Error).stack,value:e,index:2};case 5:if(!(n<0)){i.next=7;break}throw{code:"D3011",stack:(new Error).stack,value:n,index:4};case 7:if(o="string"==typeof r?function(t){for(var e="",n=0,i=r.indexOf("$",n);-1!==i&&n<r.length;){e+=r.substring(n,i),n=i+1;var a=r.charAt(n);if("$"===a)e+="$",n++;else if("0"===a)e+=t.match,n++;else{var o;if(o=0===t.groups.length?1:Math.floor(Math.log(t.groups.length)*Math.LOG10E)+1,i=parseInt(r.substring(n,n+o),10),o>1&&i>t.groups.length&&(i=parseInt(r.substring(n,n+o-1),10)),isNaN(i))e+="$";else{if(t.groups.length>0){var s=t.groups[i-1];void 0!==s&&(e+=s)}n+=i.toString().length}}i=r.indexOf("$",n)}return e+=r.substring(n)}:r,c="",u=0,!(void 0===n||n>0)){i.next=44;break}if(l=0,"string"!=typeof e){i.next=18;break}for(h=t.indexOf(e,u);-1!==h&&(void 0===n||l<n);)c+=t.substring(u,h),c+=r,u=h+e.length,l++,h=t.indexOf(e,u);c+=t.substring(u),i.next=42;break;case 18:return i.delegateYield(U(e,t),"t0",19);case 19:if(void 0===(f=i.t0)){i.next=41;break}case 21:if(void 0===f||!(void 0===n||l<n)){i.next=38;break}if(c+=t.substring(u,f.start),d=o.apply(a,[f]),!_(d)){i.next=27;break}return i.delegateYield(d,"t1",26);case 26:d=i.t1;case 27:if("string"!=typeof d){i.next=31;break}c+=d,i.next=32;break;case 31:throw{code:"D3012",stack:(new Error).stack,value:d};case 32:return u=f.start+f.match.length,l++,i.delegateYield(U(f.next),"t2",35);case 35:f=i.t2,i.next=21;break;case 38:c+=t.substring(u),i.next=42;break;case 41:c=t;case 42:i.next=45;break;case 44:c=t;case 45:return i.abrupt("return",c);case 46:case"end":return i.stop()}}),s,this)}function H(e){if(void 0!==e){var r="undefined"!=typeof window?window.btoa:function(e){return new t.Buffer.from(e,"binary").toString("base64")};return r(e)}}function q(e){if(void 0!==e){var r="undefined"!=typeof window?window.atob:function(e){return new t.Buffer.from(e,"base64").toString("binary")};return r(e)}}function X(t){if(void 0!==t){var e;try{e=encodeURIComponent(t)}catch(e){throw{code:"D3140",stack:(new Error).stack,value:t,functionName:"encodeUrlComponent"}}return e}}function V(t){if(void 0!==t){var e;try{e=encodeURI(t)}catch(e){throw{code:"D3140",stack:(new Error).stack,value:t,functionName:"encodeUrl"}}return e}}function Q(t){if(void 0!==t){var e;try{e=decodeURIComponent(t)}catch(e){throw{code:"D3140",stack:(new Error).stack,value:t,functionName:"decodeUrlComponent"}}return e}}function K(t){if(void 0!==t){var e;try{e=decodeURI(t)}catch(e){throw{code:"D3140",stack:(new Error).stack,value:t,functionName:"decodeUrl"}}return e}}function J(t,e,r){var n,a,o,s;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(void 0!==t){i.next=2;break}return i.abrupt("return",void 0);case 2:if(!(r<0)){i.next=4;break}throw{code:"D3020",stack:(new Error).stack,value:r,index:3};case 4:if(n=[],!(void 0===r||r>0)){i.next=27;break}if("string"!=typeof e){i.next=10;break}n=t.split(e,r),i.next=27;break;case 10:return a=0,i.delegateYield(U(e,t),"t0",12);case 12:if(void 0===(o=i.t0)){i.next=26;break}s=0;case 15:if(void 0===o||!(void 0===r||a<r)){i.next=23;break}return n.push(t.substring(s,o.start)),s=o.end,i.delegateYield(U(o.next),"t1",19);case 19:o=i.t1,a++,i.next=15;break;case 23:(void 0===r||a<r)&&n.push(t.substring(s)),i.next=27;break;case 26:n.push(t);case 27:return i.abrupt("return",n);case 28:case"end":return i.stop()}}),c)}function Z(t,e){if(void 0!==t)return void 0===e&&(e=""),t.join(e)}function $(t,e,r){if(void 0!==t){var n={"decimal-separator":".","grouping-separator":",","exponent-separator":"e",infinity:"Infinity","minus-sign":"-",NaN:"NaN",percent:"%","per-mille":"‰","zero-digit":"0",digit:"#","pattern-separator":";"};void 0!==r&&Object.keys(r).forEach((function(t){n[t]=r[t]}));for(var i=[],a=n["zero-digit"].charCodeAt(0),o=a;o<a+10;o++)i.push(String.fromCharCode(o));var s=i.concat([n["decimal-separator"],n["exponent-separator"],n["grouping-separator"],n.digit,n["pattern-separator"]]),c=e.split(n["pattern-separator"]);if(c.length>2)throw{code:"D3080",stack:(new Error).stack};var u=function(t){var e,r,i,a,o=function(){for(var e,r=0;r<t.length;r++)if(e=t.charAt(r),-1!==s.indexOf(e)&&e!==n["exponent-separator"])return t.substring(0,r)}(),c=function(){for(var e,r=t.length-1;r>=0;r--)if(e=t.charAt(r),-1!==s.indexOf(e)&&e!==n["exponent-separator"])return t.substring(r+1)}(),u=t.substring(o.length,t.length-c.length),l=t.indexOf(n["exponent-separator"],o.length);-1===l||l>t.length-c.length?(e=u,r=void 0):(e=u.substring(0,l),r=u.substring(l+1));var h=e.indexOf(n["decimal-separator"]);return-1===h?(i=e,a=c):(i=e.substring(0,h),a=e.substring(h+1)),{prefix:o,suffix:c,activePart:u,mantissaPart:e,exponentPart:r,integerPart:i,fractionalPart:a,subpicture:t}},l=function(t){var e,r,a=t.subpicture,o=a.indexOf(n["decimal-separator"]);o!==a.lastIndexOf(n["decimal-separator"])&&(e="D3081"),a.indexOf(n.percent)!==a.lastIndexOf(n.percent)&&(e="D3082"),a.indexOf(n["per-mille"])!==a.lastIndexOf(n["per-mille"])&&(e="D3083"),-1!==a.indexOf(n.percent)&&-1!==a.indexOf(n["per-mille"])&&(e="D3084");var c=!1;for(r=0;r<t.mantissaPart.length;r++){var u=t.mantissaPart.charAt(r);if(-1!==i.indexOf(u)||u===n.digit){c=!0;break}}c||(e="D3085"),-1!==t.activePart.split("").map((function(t){return-1===s.indexOf(t)?"p":"a"})).join("").indexOf("p")&&(e="D3086"),-1!==o?a.charAt(o-1)!==n["grouping-separator"]&&a.charAt(o+1)!==n["grouping-separator"]||(e="D3087"):t.integerPart.charAt(t.integerPart.length-1)===n["grouping-separator"]&&(e="D3088"),-1!==a.indexOf(n["grouping-separator"]+n["grouping-separator"])&&(e="D3089");var l=t.integerPart.indexOf(n.digit);-1!==l&&t.integerPart.substring(0,l).split("").filter((function(t){return i.indexOf(t)>-1})).length>0&&(e="D3090"),-1!==(l=t.fractionalPart.lastIndexOf(n.digit))&&t.fractionalPart.substring(l).split("").filter((function(t){return i.indexOf(t)>-1})).length>0&&(e="D3091");var h="string"==typeof t.exponentPart;if(h&&t.exponentPart.length>0&&(-1!==a.indexOf(n.percent)||-1!==a.indexOf(n["per-mille"]))&&(e="D3092"),h&&(0===t.exponentPart.length||t.exponentPart.split("").filter((function(t){return-1===i.indexOf(t)})).length>0)&&(e="D3093"),e)throw{code:e,stack:(new Error).stack}},h=function(t){var e=function(e,r){for(var a=[],o=e.indexOf(n["grouping-separator"]);-1!==o;){var s=(r?e.substring(0,o):e.substring(o)).split("").filter((function(t){return-1!==i.indexOf(t)||t===n.digit})).length;a.push(s),o=t.integerPart.indexOf(n["grouping-separator"],o+1)}return a},r=e(t.integerPart),a=function(t){if(0===t.length)return 0;for(var e=function t(e,r){return 0===r?e:t(r,e%r)},r=t.reduce(e),n=1;n<=t.length;n++)if(-1===t.indexOf(n*r))return 0;return r},o=a(r),s=e(t.fractionalPart,!0),c=t.integerPart.split("").filter((function(t){return-1!==i.indexOf(t)})).length,u=c,l=t.fractionalPart.split(""),h=l.filter((function(t){return-1!==i.indexOf(t)})).length,f=l.filter((function(t){return-1!==i.indexOf(t)||t===n.digit})).length,d="string"==typeof t.exponentPart;0===c&&0===f&&(d?(h=1,f=1):c=1),d&&0===c&&-1!==t.integerPart.indexOf(n.digit)&&(c=1),0===c&&0===h&&(h=1);var p=0;return d&&(p=t.exponentPart.split("").filter((function(t){return-1!==i.indexOf(t)})).length),{integerPartGroupingPositions:r,regularGrouping:o,minimumIntegerPartSize:c,scalingFactor:u,prefix:t.prefix,fractionalPartGroupingPositions:s,minimumFactionalPartSize:h,maximumFactionalPartSize:f,minimumExponentSize:p,suffix:t.suffix,picture:t.subpicture}},f=c.map(u);f.forEach(l);var d,p,g,v,y=f.map(h),m=n["minus-sign"],b=n["zero-digit"],x=n["decimal-separator"],w=n["grouping-separator"];if(1===y.length&&(y.push(JSON.parse(JSON.stringify(y[0]))),y[1].prefix=m+y[1].prefix),p=-1!==(d=t>=0?y[0]:y[1]).picture.indexOf(n.percent)?100*t:-1!==d.picture.indexOf(n["per-mille"])?1e3*t:t,0===d.minimumExponentSize)g=p;else{var A=Math.pow(10,d.scalingFactor),_=Math.pow(10,d.scalingFactor-1);for(g=p,v=0;g<_;)g*=10,v-=1;for(;g>A;)g/=10,v+=1}var k=function(t,e){var r=Math.abs(t).toFixed(e);return"0"!==b&&(r=r.split("").map((function(t){return t>="0"&&t<="9"?i[t.charCodeAt(0)-48]:t})).join("")),r},E=k(at(g,d.maximumFactionalPartSize),d.maximumFactionalPartSize),S=E.indexOf(".");for(-1===S?E+=x:E=E.replace(".",x);E.charAt(0)===b;)E=E.substring(1);for(;E.charAt(E.length-1)===b;)E=E.substring(0,E.length-1);S=E.indexOf(x);var M=d.minimumIntegerPartSize-S,T=d.minimumFactionalPartSize-(E.length-S-1);if(E=(M>0?new Array(M+1).join(b):"")+E,E+=T>0?new Array(T+1).join(b):"",S=E.indexOf(x),d.regularGrouping>0)for(var P=Math.floor((S-1)/d.regularGrouping),O=1;O<=P;O++)E=[E.slice(0,S-O*d.regularGrouping),w,E.slice(S-O*d.regularGrouping)].join("");else d.integerPartGroupingPositions.forEach((function(t){E=[E.slice(0,S-t),w,E.slice(S-t)].join(""),S++}));if(S=E.indexOf(x),d.fractionalPartGroupingPositions.forEach((function(t){E=[E.slice(0,t+S+1),w,E.slice(t+S+1)].join("")})),S=E.indexOf(x),-1!==d.picture.indexOf(x)&&S!==E.length-1||(E=E.substring(0,E.length-1)),void 0!==v){var I=k(v,0);(M=d.minimumExponentSize-I.length)>0&&(I=new Array(M+1).join(b)+I),E=E+n["exponent-separator"]+(v<0?m:"")+I}return E=d.prefix+E+d.suffix}}function tt(t,e){if(void 0!==t){if(t=at(t),(e=void 0===e?10:at(e))<2||e>36)throw{code:"D3100",stack:(new Error).stack,value:e};return t.toString(e)}}function et(t){var e;if(void 0!==t){if("number"==typeof t)e=t;else if("string"==typeof t&&/^-?[0-9]+(\.[0-9]+)?([Ee][-+]?[0-9]+)?$/.test(t)&&!isNaN(parseFloat(t))&&isFinite(t))e=parseFloat(t);else if(!0===t)e=1;else{if(!1!==t)throw{code:"D3030",value:t,stack:(new Error).stack,index:1};e=0}return e}}function rt(t){if(void 0!==t)return Math.abs(t)}function nt(t){if(void 0!==t)return Math.floor(t)}function it(t){if(void 0!==t)return Math.ceil(t)}function at(t,e){var r;if(void 0!==t){if(e){var n=t.toString().split("e");t=+(n[0]+"e"+(n[1]?+n[1]+e:e))}var i=(r=Math.round(t))-t;return.5===Math.abs(i)&&1===Math.abs(r%2)&&(r-=1),e&&(n=r.toString().split("e"),r=+(n[0]+"e"+(n[1]?+n[1]-e:-e))),Object.is(r,-0)&&(r=0),r}}function ot(t){if(void 0!==t){if(t<0)throw{stack:(new Error).stack,code:"D3060",index:1,value:t};return Math.sqrt(t)}}function st(t,e){var r;if(void 0!==t){if(r=Math.pow(t,e),!isFinite(r))throw{stack:(new Error).stack,code:"D3061",index:1,value:t,exp:e};return r}}function ct(){return Math.random()}function ut(t){if(void 0!==t){var e=!1;return Array.isArray(t)?1===t.length?e=ut(t[0]):t.length>1&&(e=t.filter((function(t){return ut(t)})).length>0):"string"==typeof t?t.length>0&&(e=!0):v(t)?0!==t&&(e=!0):null!==t&&"object"===n(t)?Object.keys(t).length>0&&(e=!0):"boolean"==typeof t&&!0===t&&(e=!0),e}}function lt(t){if(void 0!==t)return!ut(t)}function ht(t,e,r,n){var i=[e],a=k(t);return a>=2&&i.push(r),a>=3&&i.push(n),i}function ft(t,e){var r,n,a,o;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(void 0!==t){i.next=2;break}return i.abrupt("return",void 0);case 2:r=b(),n=0;case 4:if(!(n<t.length)){i.next=12;break}return a=ht(e,t[n],n,t),i.delegateYield(e.apply(this,a),"t0",7);case 7:void 0!==(o=i.t0)&&r.push(o);case 9:n++,i.next=4;break;case 12:return i.abrupt("return",r);case 13:case"end":return i.stop()}}),u,this)}function dt(t,e){var r,n,a,o;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(void 0!==t){i.next=2;break}return i.abrupt("return",void 0);case 2:r=b(),n=0;case 4:if(!(n<t.length)){i.next=13;break}return a=t[n],o=ht(e,a,n,t),i.delegateYield(e.apply(this,o),"t0",8);case 8:ut(i.t0)&&r.push(a);case 10:n++,i.next=4;break;case 13:return i.abrupt("return",r);case 14:case"end":return i.stop()}}),l,this)}function pt(t,e){var r,n,a,o,s,c,u;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(void 0!==t){i.next=2;break}return i.abrupt("return",void 0);case 2:r=!1,a=0;case 4:if(!(a<t.length)){i.next=22;break}if(o=t[a],s=!0,void 0===e){i.next=12;break}return c=ht(e,o,a,t),i.delegateYield(e.apply(this,c),"t0",10);case 10:u=i.t0,s=ut(u);case 12:if(!s){i.next=19;break}if(r){i.next=18;break}n=o,r=!0,i.next=19;break;case 18:throw{stack:(new Error).stack,code:"D3138",index:a};case 19:a++,i.next=4;break;case 22:if(r){i.next=24;break}throw{stack:(new Error).stack,code:"D3139"};case 24:return i.abrupt("return",n);case 25:case"end":return i.stop()}}),h,this)}function gt(){for(var t=[],e=Array.prototype.slice.call(arguments),r=Math.min.apply(Math,e.map((function(t){return Array.isArray(t)?t.length:0}))),n=0;n<r;n++){var i=e.map((function(t){return t[n]}));t.push(i)}return t}function vt(t,e,r){var n,a,o,s;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(void 0!==t){i.next=2;break}return i.abrupt("return",void 0);case 2:if(!((a=k(e))<2)){i.next=5;break}throw{stack:(new Error).stack,code:"D3050",index:1};case 5:void 0===r&&t.length>0?(n=t[0],o=1):(n=r,o=0);case 6:if(!(o<t.length)){i.next=15;break}return s=[n,t[o]],a>=3&&s.push(o),a>=4&&s.push(t),i.delegateYield(e.apply(this,s),"t0",11);case 11:n=i.t0,o++,i.next=6;break;case 15:return i.abrupt("return",n);case 16:case"end":return i.stop()}}),f,this)}function yt(t){var e=b();if(Array.isArray(t)){var r={};t.forEach((function(t){yt(t).forEach((function(t){r[t]=!0}))})),e=yt(r)}else null===t||"object"!==n(t)||A(t)||Object.keys(t).forEach((function(t){return e.push(t)}));return e}function mt(t,e){var r;if(Array.isArray(t)){r=b();for(var i=0;i<t.length;i++){var a=mt(t[i],e);void 0!==a&&(Array.isArray(a)?a.forEach((function(t){return r.push(t)})):r.push(a))}}else null!==t&&"object"===n(t)&&(r=t[e]);return r}function bt(t,e){return void 0===t?e:void 0===e?t:(Array.isArray(t)||(t=b(t)),Array.isArray(e)||(e=[e]),t.concat(e))}function xt(t){return void 0!==t}function wt(t){var e=b();if(Array.isArray(t))t.forEach((function(t){e=bt(e,wt(t))}));else if(null===t||"object"!==n(t)||A(t))e=t;else for(var r in t){var i={};i[r]=t[r],e.push(i)}return e}function At(t){if(void 0!==t){var e={};return t.forEach((function(t){for(var r in t)e[r]=t[r]})),e}}function _t(t){if(void 0!==t){if(t.length<=1)return t;for(var e=t.length,r=new Array(e),n=0;n<e;n++)r[e-n-1]=t[n];return r}}function kt(t,e){var r,n,a,o;return i().wrap((function(s){for(;;)switch(s.prev=s.next){case 0:r=b(),s.t0=i().keys(t);case 2:if((s.t1=s.t0()).done){s.next=10;break}return n=s.t1.value,a=ht(e,t[n],n,t),s.delegateYield(e.apply(this,a),"t2",6);case 6:void 0!==(o=s.t2)&&r.push(o),s.next=2;break;case 10:return s.abrupt("return",r);case 11:case"end":return s.stop()}}),d,this)}function Et(t){throw{code:"D3137",stack:(new Error).stack,message:t||"$error() function evaluated"}}function St(t,e){if(!t)throw{code:"D3141",stack:(new Error).stack,message:e||"$assert() statement failed"}}function Mt(t){if(void 0!==t)return null===t?"null":v(t)?"number":"string"==typeof t?"string":"boolean"==typeof t?"boolean":Array.isArray(t)?"array":w(t)?"function":"object"}function Tt(t,e){var r,n,a,o;return i().wrap((function(s){for(;;)switch(s.prev=s.next){case 0:if(void 0!==t){s.next=2;break}return s.abrupt("return",void 0);case 2:if(!(t.length<=1)){s.next=4;break}return s.abrupt("return",t);case 4:if(void 0!==e){s.next=10;break}if(m(t)||y(t)){s.next=7;break}throw{stack:(new Error).stack,code:"D3070",index:1};case 7:r=i().mark((function t(e,r){return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",e>r);case 1:case"end":return t.stop()}}),t)})),s.next=11;break;case 10:r=e;case 11:return n=i().mark((function t(e,n){var a,o;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=i().mark((function t(e,n,a){return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(0!==n.length){i.next=4;break}Array.prototype.push.apply(e,a),i.next=16;break;case 4:if(0!==a.length){i.next=8;break}Array.prototype.push.apply(e,n),i.next=16;break;case 8:return i.delegateYield(r(n[0],a[0]),"t0",9);case 9:if(!i.t0){i.next=14;break}return e.push(a[0]),i.delegateYield(t(e,n,a.slice(1)),"t1",12);case 12:i.next=16;break;case 14:return e.push(n[0]),i.delegateYield(t(e,n.slice(1),a),"t2",16);case 16:case"end":return i.stop()}}),t)})),o=[],t.delegateYield(a(o,e,n),"t0",3);case 3:return t.abrupt("return",o);case 4:case"end":return t.stop()}}),t)})),a=i().mark((function t(e){var r,a,o;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(Array.isArray(e)&&!(e.length<=1)){i.next=4;break}return i.abrupt("return",e);case 4:return r=Math.floor(e.length/2),a=e.slice(0,r),o=e.slice(r),i.delegateYield(t(a),"t0",8);case 8:return a=i.t0,i.delegateYield(t(o),"t1",10);case 10:return o=i.t1,i.delegateYield(n(a,o),"t2",12);case 12:return i.abrupt("return",i.t2);case 13:case"end":return i.stop()}}),t)})),s.delegateYield(a(t),"t0",14);case 14:return o=s.t0,s.abrupt("return",o);case 16:case"end":return s.stop()}}),p)}function Pt(t){if(void 0!==t){if(t.length<=1)return t;for(var e=new Array(t.length),r=0;r<t.length;r++){var n=Math.floor(Math.random()*(r+1));r!==n&&(e[r]=e[n]),e[n]=t[r]}return e}}function Ot(t){if(void 0!==t){if(!Array.isArray(t)||t.length<=1)return t;for(var e=x(t)?b():[],r=0;r<t.length;r++){for(var n=t[r],i=!1,a=0;a<e.length;a++)if(E(n,e[a])){i=!0;break}i||e.push(n)}return e}}function It(t,e){var r,n,a,o;return i().wrap((function(s){for(;;)switch(s.prev=s.next){case 0:r={},s.t0=i().keys(t);case 2:if((s.t1=s.t0()).done){s.next=11;break}return n=s.t1.value,a=t[n],o=ht(e,a,n,t),s.delegateYield(e.apply(this,o),"t2",7);case 7:ut(s.t2)&&(r[n]=a),s.next=2;break;case 11:return 0===Object.keys(r).length&&(r=void 0),s.abrupt("return",r);case 13:case"end":return s.stop()}}),g,this)}return{sum:M,count:T,max:P,min:O,average:I,string:C,substring:R,substringBefore:j,substringAfter:L,lowercase:D,uppercase:z,length:F,trim:N,pad:B,match:G,contains:Y,replace:W,split:J,join:Z,formatNumber:$,formatBase:tt,number:et,floor:nt,ceil:it,round:at,abs:rt,sqrt:ot,power:st,random:ct,boolean:ut,not:lt,map:ft,zip:gt,filter:dt,single:pt,foldLeft:vt,sift:It,keys:yt,lookup:mt,append:bt,exists:xt,spread:wt,merge:At,reverse:_t,each:kt,error:Et,assert:St,type:Mt,sort:Tt,shuffle:Pt,distinct:Ot,base64encode:H,base64decode:q,encodeUrlComponent:X,encodeUrl:V,decodeUrlComponent:Q,decodeUrl:K}}();r.exports=o}).call(this)}).call(this,void 0!==t?t:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./utils":6}],3:[function(t,e,r){function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}function i(){
5
5
  /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
6
- i=function(){return e};var t,e={},r=Object.prototype,a=r.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},s="function"==typeof Symbol?Symbol:{},c=s.iterator||"@@iterator",u=s.asyncIterator||"@@asyncIterator",l=s.toStringTag||"@@toStringTag";function h(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{h({},"")}catch(t){h=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var i=e&&e.prototype instanceof b?e:b,a=Object.create(i.prototype),s=new C(n||[]);return o(a,"_invoke",{value:T(t,r,s)}),a}function d(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var p="suspendedStart",g="suspendedYield",v="executing",y="completed",m={};function b(){}function x(){}function w(){}var A={};h(A,c,(function(){return this}));var _=Object.getPrototypeOf,k=_&&_(_(R([])));k&&k!==r&&a.call(k,c)&&(A=k);var E=w.prototype=b.prototype=Object.create(A);function S(t){["next","throw","return"].forEach((function(e){h(t,e,(function(t){return this._invoke(e,t)}))}))}function M(t,e){function r(i,o,s,c){var u=d(t[i],t,o);if("throw"!==u.type){var l=u.arg,h=l.value;return h&&"object"==n(h)&&a.call(h,"__await")?e.resolve(h.__await).then((function(t){r("next",t,s,c)}),(function(t){r("throw",t,s,c)})):e.resolve(h).then((function(t){l.value=t,s(l)}),(function(t){return r("throw",t,s,c)}))}c(u.arg)}var i;o(this,"_invoke",{value:function(t,n){function a(){return new e((function(e,i){r(t,n,e,i)}))}return i=i?i.then(a,a):a()}})}function T(e,r,n){var i=p;return function(a,o){if(i===v)throw new Error("Generator is already running");if(i===y){if("throw"===a)throw o;return{value:t,done:!0}}for(n.method=a,n.arg=o;;){var s=n.delegate;if(s){var c=P(s,n);if(c){if(c===m)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===p)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=v;var u=d(e,r,n);if("normal"===u.type){if(i=n.done?y:g,u.arg===m)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(i=y,n.method="throw",n.arg=u.arg)}}}function P(e,r){var n=r.method,i=e.iterator[n];if(i===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,P(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),m;var a=d(i,e.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,m;var o=a.arg;return o?o.done?(r[e.resultName]=o.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,m):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,m)}function O(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function I(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function C(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(O,this),this.reset(!0)}function R(e){if(e||""===e){var r=e[c];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,o=function r(){for(;++i<e.length;)if(a.call(e,i))return r.value=e[i],r.done=!1,r;return r.value=t,r.done=!0,r};return o.next=o}}throw new TypeError(n(e)+" is not iterable")}return x.prototype=w,o(E,"constructor",{value:w,configurable:!0}),o(w,"constructor",{value:x,configurable:!0}),x.displayName=h(w,l,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===x||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,h(t,l,"GeneratorFunction")),t.prototype=Object.create(E),t},e.awrap=function(t){return{__await:t}},S(M.prototype),h(M.prototype,u,(function(){return this})),e.AsyncIterator=M,e.async=function(t,r,n,i,a){void 0===a&&(a=Promise);var o=new M(f(t,r,n,i),a);return e.isGeneratorFunction(r)?o:o.next().then((function(t){return t.done?t.value:o.next()}))},S(E),h(E,l,"Generator"),h(E,c,(function(){return this})),h(E,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=R,C.prototype={constructor:C,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(I),!e)for(var r in this)"t"===r.charAt(0)&&a.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function n(n,i){return s.type="throw",s.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],s=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var c=a.call(o,"catchLoc"),u=a.call(o,"finallyLoc");if(c&&u){if(this.prev<o.catchLoc)return n(o.catchLoc,!0);if(this.prev<o.finallyLoc)return n(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return n(o.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return n(o.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&a.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var o=i?i.completion:{};return o.type=t,o.arg=e,i?(this.method="next",this.next=i.finallyLoc,m):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),m},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),I(r),m}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;I(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:R(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),m}},e}var a=t("./datetime"),o=t("./functions"),s=t("./utils"),c=t("./parser"),u=t("./signature"),l=function(){var t=i().mark(B),e=i().mark(U),r=i().mark(G),l=i().mark(W),h=i().mark(H),f=i().mark(q),d=i().mark(X),p=i().mark(V),g=i().mark(at),v=i().mark(ct),y=i().mark(ht),m=i().mark(ft),b=i().mark(dt),x=i().mark(vt),w=i().mark(bt),A=i().mark(xt),_=i().mark(wt),k=i().mark(At),E=i().mark(kt),S=i().mark(St),M=i().mark(Pt),T=i().mark(Ct),P=s.isNumeric,O=s.isArrayOfStrings,I=s.isArrayOfNumbers,C=s.createSequence,R=s.isSequence,j=s.isFunction,L=s.isLambda,D=s.isIterable,z=s.getFunctionArity,F=s.isDeepEqual,N=jt(null);function B(e,r,n){var a,o,s,c;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:(o=n.lookup("__evaluate_entry"))&&o(e,r,n),t.t0=e.type,t.next="path"===t.t0?5:"binary"===t.t0?8:"unary"===t.t0?11:"name"===t.t0?14:"string"===t.t0||"number"===t.t0||"value"===t.t0?16:"wildcard"===t.t0?18:"descendant"===t.t0?20:"parent"===t.t0?22:"condition"===t.t0?24:"block"===t.t0?27:"bind"===t.t0?30:"regex"===t.t0?33:"function"===t.t0?35:"variable"===t.t0?38:"lambda"===t.t0?40:"partial"===t.t0?42:"apply"===t.t0?45:"transform"===t.t0?48:50;break;case 5:return t.delegateYield(U(e,r,n),"t1",6);case 6:return a=t.t1,t.abrupt("break",50);case 8:return t.delegateYield(X(e,r,n),"t2",9);case 9:return a=t.t2,t.abrupt("break",50);case 11:return t.delegateYield(V(e,r,n),"t3",12);case 12:return a=t.t3,t.abrupt("break",50);case 14:return a=Q(e,r),t.abrupt("break",50);case 16:return a=K(e),t.abrupt("break",50);case 18:return a=J(e,r),t.abrupt("break",50);case 20:return a=$(e,r),t.abrupt("break",50);case 22:return a=n.lookup(e.slot.label),t.abrupt("break",50);case 24:return t.delegateYield(ft(e,r,n),"t4",25);case 25:return a=t.t4,t.abrupt("break",50);case 27:return t.delegateYield(dt(e,r,n),"t5",28);case 28:return a=t.t5,t.abrupt("break",50);case 30:return t.delegateYield(ht(e,r,n),"t6",31);case 31:return a=t.t6,t.abrupt("break",50);case 33:return a=pt(e),t.abrupt("break",50);case 35:return t.delegateYield(xt(e,r,n),"t7",36);case 36:return a=t.t7,t.abrupt("break",50);case 38:return a=gt(e,r,n),t.abrupt("break",50);case 40:return a=_t(e,r,n),t.abrupt("break",50);case 42:return t.delegateYield(kt(e,r,n),"t8",43);case 43:return a=t.t8,t.abrupt("break",50);case 45:return t.delegateYield(bt(e,r,n),"t9",46);case 46:return a=t.t9,t.abrupt("break",50);case 48:return a=yt(e,r,n),t.abrupt("break",50);case 50:if(!n.async||null!=a&&"function"==typeof a.then||(a=Promise.resolve(a)),!n.async||"function"!=typeof a.then||!e.nextFunction||"function"!=typeof a[e.nextFunction]){t.next=54;break}t.next=57;break;case 54:return t.next=56,a;case 56:a=t.sent;case 57:if(!Object.prototype.hasOwnProperty.call(e,"predicate")){t.next=65;break}s=0;case 59:if(!(s<e.predicate.length)){t.next=65;break}return t.delegateYield(q(e.predicate[s].expr,a,n),"t10",61);case 61:a=t.t10;case 62:s++,t.next=59;break;case 65:if("path"===e.type||!Object.prototype.hasOwnProperty.call(e,"group")){t.next=68;break}return t.delegateYield(ct(e.group,a,n),"t11",67);case 67:a=t.t11;case 68:return(c=n.lookup("__evaluate_exit"))&&c(e,r,n,a),a&&R(a)&&!a.tupleStream&&(e.keepArray&&(a.keepSingleton=!0),0===a.length?a=void 0:1===a.length&&(a=a.keepSingleton?a:a[0])),t.abrupt("return",a);case 72:case"end":return t.stop()}}),t)}function U(t,r,n){var a,o,s,c,u,l;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=Array.isArray(r)&&"variable"!==t.steps[0].type?r:C(r),s=!1,c=void 0,u=0;case 4:if(!(u<t.steps.length)){e.next=25;break}if((l=t.steps[u]).tuple&&(s=!0),0!==u||!l.consarray){e.next=12;break}return e.delegateYield(B(l,a,n),"t0",9);case 9:o=e.t0,e.next=19;break;case 12:if(!s){e.next=17;break}return e.delegateYield(H(l,a,c,n),"t1",14);case 14:c=e.t1,e.next=19;break;case 17:return e.delegateYield(G(l,a,n,u===t.steps.length-1),"t2",18);case 18:o=e.t2;case 19:if(s||void 0!==o&&0!==o.length){e.next=21;break}return e.abrupt("break",25);case 21:void 0===l.focus&&(a=o);case 22:u++,e.next=4;break;case 25:if(s)if(t.tuple)o=c;else for(o=C(),u=0;u<c.length;u++)o.push(c[u]["@"]);if(t.keepSingletonArray&&(Array.isArray(o)&&o.cons&&!o.sequence&&(o=C(o)),o.keepSingleton=!0),!t.hasOwnProperty("group")){e.next=30;break}return e.delegateYield(ct(t.group,s?c:o,n),"t3",29);case 29:o=e.t3;case 30:return e.abrupt("return",o);case 31:case"end":return e.stop()}}),e)}function Y(t,e){var r=jt(t);for(var n in e)r.bind(n,e[n]);return r}function G(t,e,n,a){var o,s,c,u,l;return i().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if("sort"!==t.type){r.next=7;break}return r.delegateYield(vt(t,e,n),"t0",2);case 2:if(o=r.t0,!t.stages){r.next=6;break}return r.delegateYield(W(t.stages,o,n),"t1",5);case 5:o=r.t1;case 6:return r.abrupt("return",o);case 7:o=C(),s=0;case 9:if(!(s<e.length)){r.next=24;break}return r.delegateYield(B(t,e[s],n),"t2",11);case 11:if(c=r.t2,!t.stages){r.next=20;break}u=0;case 14:if(!(u<t.stages.length)){r.next=20;break}return r.delegateYield(q(t.stages[u].expr,c,n),"t3",16);case 16:c=r.t3;case 17:u++,r.next=14;break;case 20:void 0!==c&&o.push(c);case 21:s++,r.next=9;break;case 24:return l=C(),a&&1===o.length&&Array.isArray(o[0])&&!R(o[0])?l=o[0]:o.forEach((function(t){!Array.isArray(t)||t.cons?l.push(t):t.forEach((function(t){return l.push(t)}))})),r.abrupt("return",l);case 27:case"end":return r.stop()}}),r)}function W(t,e,r){var n,a,o,s;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:n=e,a=0;case 2:if(!(a<t.length)){i.next=15;break}o=t[a],i.t0=o.type,i.next="filter"===i.t0?7:"index"===i.t0?10:12;break;case 7:return i.delegateYield(q(o.expr,n,r),"t1",8);case 8:return n=i.t1,i.abrupt("break",12);case 10:for(s=0;s<n.length;s++)n[s][o.value]=s;return i.abrupt("break",12);case 12:a++,i.next=2;break;case 15:return i.abrupt("return",n);case 16:case"end":return i.stop()}}),l)}function H(t,e,r,n){var a,o,s,c,u,l,f,d;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if("sort"!==t.type){i.next=15;break}if(!r){i.next=6;break}return i.delegateYield(vt(t,r,n),"t0",3);case 3:a=i.t0,i.next=11;break;case 6:return i.delegateYield(vt(t,e,n),"t1",7);case 7:for(o=i.t1,(a=C()).tupleStream=!0,s=0;s<o.length;s++)(c={"@":o[s]})[t.index]=s,a.push(c);case 11:if(!t.stages){i.next=14;break}return i.delegateYield(W(t.stages,a,n),"t2",13);case 13:a=i.t2;case 14:return i.abrupt("return",a);case 15:(a=C()).tupleStream=!0,u=n,void 0===r&&(r=e.map((function(t){return{"@":t}}))),l=0;case 20:if(!(l<r.length)){i.next=28;break}return u=Y(n,r[l]),i.delegateYield(B(t,r[l]["@"],u),"t3",23);case 23:if(void 0!==(f=i.t3))for(Array.isArray(f)||(f=[f]),d=0;d<f.length;d++)c={},Object.assign(c,r[l]),f.tupleStream?Object.assign(c,f[d]):(t.focus?(c[t.focus]=f[d],c["@"]=r[l]["@"]):c["@"]=f[d],t.index&&(c[t.index]=d),t.ancestor&&(c[t.ancestor.label]=r[l]["@"])),a.push(c);case 25:l++,i.next=20;break;case 28:if(!t.stages){i.next=31;break}return i.delegateYield(W(t.stages,a,n),"t4",30);case 30:a=i.t4;case 31:return i.abrupt("return",a);case 32:case"end":return i.stop()}}),h)}function q(t,e,r){var n,a,s,c,u,l;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(n=C(),e&&e.tupleStream&&(n.tupleStream=!0),Array.isArray(e)||(e=C(e)),"number"!==t.type){i.next=10;break}(a=Math.floor(t.value))<0&&(a=e.length+a),void 0!==(s=e[a])&&(Array.isArray(s)?n=s:n.push(s)),i.next=23;break;case 10:a=0;case 11:if(!(a<e.length)){i.next=23;break}return s=e[a],c=s,u=r,e.tupleStream&&(c=s["@"],u=Y(r,s)),i.delegateYield(B(t,c,u),"t0",17);case 17:l=i.t0,P(l)&&(l=[l]),I(l)?l.forEach((function(t){var r=Math.floor(t);r<0&&(r=e.length+r),r===a&&n.push(s)})):o.boolean(l)&&n.push(s);case 20:a++,i.next=11;break;case 23:return i.abrupt("return",n);case 24:case"end":return i.stop()}}),f)}function X(t,e,r){var n,a,o,s,c;return i().wrap((function(u){for(;;)switch(u.prev=u.next){case 0:return u.delegateYield(B(t.lhs,e,r),"t0",1);case 1:if(a=u.t0,o=t.value,s=i().mark((function n(){return i().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.delegateYield(B(t.rhs,e,r),"t0",1);case 1:return n.abrupt("return",n.t0);case 2:case"end":return n.stop()}}),n)})),"and"!==o&&"or"!==o){u.next=15;break}return u.prev=5,u.delegateYield(at(a,s,o),"t1",7);case 7:return u.abrupt("return",u.t1);case 10:throw u.prev=10,u.t2=u.catch(5),u.t2.position=t.position,u.t2.token=o,u.t2;case 15:return u.delegateYield(s(),"t3",16);case 16:c=u.t3,u.prev=17,u.t4=o,u.next="+"===u.t4||"-"===u.t4||"*"===u.t4||"/"===u.t4||"%"===u.t4?21:"="===u.t4||"!="===u.t4?23:"<"===u.t4||"<="===u.t4||">"===u.t4||">="===u.t4?25:"&"===u.t4?27:".."===u.t4?29:"in"===u.t4?31:33;break;case 21:return n=et(a,c,o),u.abrupt("break",33);case 23:return n=rt(a,c,o),u.abrupt("break",33);case 25:return n=nt(a,c,o),u.abrupt("break",33);case 27:return n=st(a,c),u.abrupt("break",33);case 29:return n=lt(a,c),u.abrupt("break",33);case 31:return n=it(a,c),u.abrupt("break",33);case 33:u.next=40;break;case 35:throw u.prev=35,u.t5=u.catch(17),u.t5.position=t.position,u.t5.token=o,u.t5;case 40:return u.abrupt("return",n);case 41:case"end":return u.stop()}}),d,null,[[5,10],[17,35]])}function V(t,e,r){var n,a,s,c;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:i.t0=t.value,i.next="-"===i.t0?3:"["===i.t0?15:"{"===i.t0?27:30;break;case 3:return i.delegateYield(B(t.expression,e,r),"t1",4);case 4:if(void 0!==(n=i.t1)){i.next=9;break}n=void 0,i.next=14;break;case 9:if(!P(n)){i.next=13;break}n=-n,i.next=14;break;case 13:throw{code:"D1002",stack:(new Error).stack,position:t.position,token:t.value,value:n};case 14:return i.abrupt("break",30);case 15:n=[],a=0;case 17:if(!(a<t.expressions.length)){i.next=25;break}return s=t.expressions[a],i.delegateYield(B(s,e,r),"t2",20);case 20:void 0!==(c=i.t2)&&("["===s.value?n.push(c):n=o.append(n,c));case 22:a++,i.next=17;break;case 25:return t.consarray&&Object.defineProperty(n,"cons",{enumerable:!1,configurable:!1,value:!0}),i.abrupt("break",30);case 27:return i.delegateYield(ct(t,e,r),"t3",28);case 28:return n=i.t3,i.abrupt("break",30);case 30:return i.abrupt("return",n);case 31:case"end":return i.stop()}}),p)}function Q(t,e,r){return o.lookup(e,t.value)}function K(t){return t.value}function J(t,e){var r=C();return Array.isArray(e)&&e.outerWrapper&&e.length>0&&(e=e[0]),null!==e&&"object"===n(e)&&Object.keys(e).forEach((function(t){var n=e[t];Array.isArray(n)?(n=Z(n),r=o.append(r,n)):r.push(n)})),r}function Z(t,e){return void 0===e&&(e=[]),Array.isArray(t)?t.forEach((function(t){Z(t,e)})):e.push(t),e}function $(t,e){var r,n=C();return void 0!==e&&(tt(e,n),r=1===n.length?n[0]:n),r}function tt(t,e){Array.isArray(t)||e.push(t),Array.isArray(t)?t.forEach((function(t){tt(t,e)})):null!==t&&"object"===n(t)&&Object.keys(t).forEach((function(r){tt(t[r],e)}))}function et(t,e,r){var n;if(void 0!==t&&!P(t))throw{code:"T2001",stack:(new Error).stack,value:t};if(void 0!==e&&!P(e))throw{code:"T2002",stack:(new Error).stack,value:e};if(void 0===t||void 0===e)return n;switch(r){case"+":n=t+e;break;case"-":n=t-e;break;case"*":n=t*e;break;case"/":n=t/e;break;case"%":n=t%e}return n}function rt(t,e,r){var i,a=n(t),o=n(e);if("undefined"===a||"undefined"===o)return!1;switch(r){case"=":i=F(t,e);break;case"!=":i=!F(t,e)}return i}function nt(t,e,r){var i,a=n(t),o=n(e);if("undefined"!==a&&"string"!==a&&"number"!==a||"undefined"!==o&&"string"!==o&&"number"!==o)throw{code:"T2010",stack:(new Error).stack,value:"string"!==a&&"number"!==a?t:e};if("undefined"!==a&&"undefined"!==o){if(a!==o)throw{code:"T2009",stack:(new Error).stack,value:t,value2:e};switch(r){case"<":i=t<e;break;case"<=":i=t<=e;break;case">":i=t>e;break;case">=":i=t>=e}return i}}function it(t,e){var r=!1;if(void 0===t||void 0===e)return!1;Array.isArray(e)||(e=[e]);for(var n=0;n<e.length;n++)if(e[n]===t){r=!0;break}return r}function at(t,e,r){var n,a;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:a=ot(t),i.t0=r,i.next="and"===i.t0?4:"or"===i.t0?12:20;break;case 4:if(i.t1=a,!i.t1){i.next=10;break}return i.t2=ot,i.delegateYield(e(),"t3",8);case 8:i.t4=i.t3,i.t1=(0,i.t2)(i.t4);case 10:return n=i.t1,i.abrupt("break",20);case 12:if(i.t5=a,i.t5){i.next=18;break}return i.t6=ot,i.delegateYield(e(),"t7",16);case 16:i.t8=i.t7,i.t5=(0,i.t6)(i.t8);case 18:return n=i.t5,i.abrupt("break",20);case 20:return i.abrupt("return",n);case 21:case"end":return i.stop()}}),g)}function ot(t){var e=o.boolean(t);return void 0!==e&&e}function st(t,e){var r="",n="";return void 0!==t&&(r=o.string(t)),void 0!==e&&(n=o.string(e)),r.concat(n)}function ct(t,e,r){var n,a,s,c,u,l,h,f,d,p,g,y,m;return i().wrap((function(v){for(;;)switch(v.prev=v.next){case 0:n={},a={},s=!(!e||!e.tupleStream),Array.isArray(e)||(e=C(e)),0===e.length&&e.push(void 0),c=0;case 6:if(!(c<e.length)){v.next=31;break}u=e[c],l=s?Y(r,u):r,h=0;case 10:if(!(h<t.lhs.length)){v.next=28;break}return f=t.lhs[h],v.delegateYield(B(f[0],s?u["@"]:u,l),"t0",13);case 13:if("string"==typeof(d=v.t0)||void 0===d){v.next=16;break}throw{code:"T1003",stack:(new Error).stack,position:t.position,value:d};case 16:if(void 0===d){v.next=25;break}if(p={data:u,exprIndex:h},!a.hasOwnProperty(d)){v.next=24;break}if(a[d].exprIndex===h){v.next=21;break}throw{code:"D1009",stack:(new Error).stack,position:t.position,value:d};case 21:a[d].data=o.append(a[d].data,u),v.next=25;break;case 24:a[d]=p;case 25:h++,v.next=10;break;case 28:c++,v.next=6;break;case 31:v.t1=i().keys(a);case 32:if((v.t2=v.t1()).done){v.next=43;break}return d=v.t2.value,p=a[d],g=p.data,l=r,s&&(y=ut(p.data),g=y["@"],delete y["@"],l=Y(r,y)),v.delegateYield(B(t.lhs[p.exprIndex][1],g,l),"t3",39);case 39:void 0!==(m=v.t3)&&(n[d]=m),v.next=32;break;case 43:return v.abrupt("return",n);case 44:case"end":return v.stop()}}),v)}function ut(t){if(!Array.isArray(t))return t;var e={};Object.assign(e,t[0]);for(var r=1;r<t.length;r++)for(var n in t[r])e[n]=o.append(e[n],t[r][n]);return e}function lt(t,e){var r;if(void 0!==t&&!Number.isInteger(t))throw{code:"T2003",stack:(new Error).stack,value:t};if(void 0!==e&&!Number.isInteger(e))throw{code:"T2004",stack:(new Error).stack,value:e};if(void 0===t||void 0===e)return r;if(t>e)return r;var n=e-t+1;if(n>1e7)throw{code:"D2014",stack:(new Error).stack,value:n};r=new Array(n);for(var i=t,a=0;i<=e;i++,a++)r[a]=i;return r.sequence=!0,r}function ht(t,e,r){var n;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return i.delegateYield(B(t.rhs,e,r),"t0",1);case 1:return n=i.t0,r.bind(t.lhs.value,n),i.abrupt("return",n);case 4:case"end":return i.stop()}}),y)}function ft(t,e,r){var n,a;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return i.delegateYield(B(t.condition,e,r),"t0",1);case 1:if(a=i.t0,!o.boolean(a)){i.next=7;break}return i.delegateYield(B(t.then,e,r),"t1",4);case 4:n=i.t1,i.next=10;break;case 7:if(void 0===t.else){i.next=10;break}return i.delegateYield(B(t.else,e,r),"t2",9);case 9:n=i.t2;case 10:return i.abrupt("return",n);case 11:case"end":return i.stop()}}),m)}function dt(t,e,r){var n,a,o;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:a=jt(r),o=0;case 2:if(!(o<t.expressions.length)){i.next=8;break}return i.delegateYield(B(t.expressions[o],e,a),"t0",4);case 4:n=i.t0;case 5:o++,i.next=2;break;case 8:return i.abrupt("return",n);case 9:case"end":return i.stop()}}),b)}function pt(t){var e=new zt.RegexEngine(t.value),r=function r(n,i){var a;e.lastIndex=i||0;var o=e.exec(n);if(null!==o){if(a={match:o[0],start:o.index,end:o.index+o[0].length,groups:[]},o.length>1)for(var s=1;s<o.length;s++)a.groups.push(o[s]);a.next=function(){if(!(e.lastIndex>=n.length)){var i=r(n,e.lastIndex);if(i&&""===i.match)throw{code:"D1004",stack:(new Error).stack,position:t.position,value:t.value.source};return i}}}return a};return r}function gt(t,e,r){return""===t.value?e&&e.outerWrapper?e[0]:e:r.lookup(t.value)}function vt(t,e,r){var a,s,c,u,l;return i().wrap((function(h){for(;;)switch(h.prev=h.next){case 0:return s=e,c=!!e.tupleStream,u=i().mark((function e(a,o){var s,u,l,h,f,d,p,g,v;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:s=0,u=0;case 2:if(!(0===s&&u<t.terms.length)){e.next=35;break}return l=t.terms[u],h=a,f=r,c&&(h=a["@"],f=Y(r,a)),e.delegateYield(B(l.expression,h,f),"t0",8);case 8:return d=e.t0,h=o,f=r,c&&(h=o["@"],f=Y(r,o)),e.delegateYield(B(l.expression,h,f),"t1",13);case 13:if(p=e.t1,g=n(d),v=n(p),"undefined"!==g){e.next=19;break}return s="undefined"===v?0:1,e.abrupt("continue",32);case 19:if("undefined"!==v){e.next=22;break}return s=-1,e.abrupt("continue",32);case 22:if(!("string"!==g&&"number"!==g||"string"!==v&&"number"!==v)){e.next=24;break}throw{code:"T2008",stack:(new Error).stack,position:t.position,value:"string"!==g&&"number"!==g?d:p};case 24:if(g===v){e.next=26;break}throw{code:"T2007",stack:(new Error).stack,position:t.position,value:d,value2:p};case 26:if(d!==p){e.next=30;break}return e.abrupt("continue",32);case 30:s=d<p?-1:1;case 31:!0===l.descending&&(s=-s);case 32:u++,e.next=2;break;case 35:return e.abrupt("return",1===s);case 36:case"end":return e.stop()}}),e)})),l={environment:r,input:e},h.delegateYield(o.sort.apply(l,[s,u]),"t0",5);case 5:return a=h.t0,h.abrupt("return",a);case 7:case"end":return h.stop()}}),x)}function yt(t,e,r){var a=i().mark((function e(a){var o,s,c,u,l,h,f,d,p,g,v;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==a){e.next=2;break}return e.abrupt("return",void 0);case 2:if(o=r.lookup("clone"),j(o)){e.next=5;break}throw{code:"T2013",stack:(new Error).stack,position:t.position};case 5:return e.delegateYield(wt(o,[a],null,r),"t0",6);case 6:return s=e.t0,e.delegateYield(B(t.pattern,s,r),"t1",8);case 8:if(void 0===(c=e.t1)){e.next=35;break}Array.isArray(c)||(c=[c]),u=0;case 12:if(!(u<c.length)){e.next=35;break}if(!(l=c[u])||!(l.isPrototypeOf(s)||l instanceof Object.constructor)){e.next=16;break}throw{code:"D1010",stack:(new Error).stack,position:t.position};case 16:return e.delegateYield(B(t.update,l,r),"t2",17);case 17:if(h=e.t2,"undefined"===(f=n(h))){e.next=23;break}if("object"===f&&null!==h&&!Array.isArray(h)){e.next=22;break}throw{code:"T2011",stack:(new Error).stack,position:t.update.position,value:h};case 22:for(d in h)l[d]=h[d];case 23:if(void 0===t.delete){e.next=32;break}return e.delegateYield(B(t.delete,l,r),"t3",25);case 25:if(void 0===(p=e.t3)){e.next=32;break}if(g=p,Array.isArray(p)||(p=[p]),O(p)){e.next=31;break}throw{code:"T2012",stack:(new Error).stack,position:t.delete.position,value:g};case 31:for(v=0;v<p.length;v++)"object"===n(l)&&null!==l&&delete l[p[v]];case 32:u++,e.next=12;break;case 35:return e.abrupt("return",s);case 36:case"end":return e.stop()}}),e)}));return It(a,"<(oa):o>")}var mt=c("function($f, $g) { function($x){ $g($f($x)) } }");function bt(t,e,r){var n,a,o,s;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return i.delegateYield(B(t.lhs,e,r),"t0",1);case 1:if(a=i.t0,"function"!==t.rhs.type){i.next=7;break}return i.delegateYield(xt(t.rhs,e,r,{context:a}),"t1",4);case 4:n=i.t1,i.next=20;break;case 7:return i.delegateYield(B(t.rhs,e,r),"t2",8);case 8:if(o=i.t2,j(o)){i.next=11;break}throw{code:"T2006",stack:(new Error).stack,position:t.position,value:o};case 11:if(!j(a)){i.next=18;break}return i.delegateYield(B(mt,null,r),"t3",13);case 13:return s=i.t3,i.delegateYield(wt(s,[a,o],null,r),"t4",15);case 15:n=i.t4,i.next=20;break;case 18:return i.delegateYield(wt(o,[a],null,r),"t5",19);case 19:n=i.t5;case 20:return i.abrupt("return",n);case 21:case"end":return i.stop()}}),w)}function xt(t,e,r,a){var o,s,c,u,l,h;return i().wrap((function(f){for(;;)switch(f.prev=f.next){case 0:return f.delegateYield(B(t.procedure,e,r),"t0",1);case 1:if(void 0!==(s=f.t0)||"path"!==t.procedure.type||!r.lookup(t.procedure.steps[0].value)){f.next=4;break}throw{code:"T1005",stack:(new Error).stack,position:t.position,token:t.procedure.steps[0].value};case 4:c=[],void 0!==a&&c.push(a.context),u=i().mark((function n(){var a,o;return i().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.delegateYield(B(t.arguments[l],e,r),"t0",1);case 1:a=n.t0,j(a)?(o=i().mark((function t(){var e,n,o,s=arguments;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:for(e=s.length,n=new Array(e),o=0;o<e;o++)n[o]=s[o];return t.delegateYield(wt(a,n,null,r),"t0",2);case 2:return t.abrupt("return",t.t0);case 3:case"end":return t.stop()}}),t)})),o.arity=z(a),c.push(o)):c.push(a);case 3:case"end":return n.stop()}}),n)})),l=0;case 8:if(!(l<t.arguments.length)){f.next=13;break}return f.delegateYield(u(),"t1",10);case 10:l++,f.next=8;break;case 13:return h="path"===t.procedure.type?t.procedure.steps[0].value:t.procedure.value,f.prev=14,"object"===n(s)&&(s.token=h,s.position=t.position),f.delegateYield(wt(s,c,e,r),"t2",17);case 17:o=f.t2,f.next=25;break;case 20:throw f.prev=20,f.t3=f.catch(14),f.t3.position||(f.t3.position=t.position),f.t3.token||(f.t3.token=h),f.t3;case 25:return f.abrupt("return",o);case 26:case"end":return f.stop()}}),A,null,[[14,20]])}function wt(t,e,r,n){var a,o,s,c;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return i.delegateYield(At(t,e,r,n),"t0",1);case 1:a=i.t0;case 2:if(!L(a)||!0!==a.thunk){i.next=21;break}return i.delegateYield(B(a.body.procedure,a.input,a.environment),"t1",4);case 4:o=i.t1,"variable"===a.body.procedure.type&&(o.token=a.body.procedure.value),o.position=a.body.procedure.position,s=[],c=0;case 9:if(!(c<a.body.arguments.length)){i.next=17;break}return i.t2=s,i.delegateYield(B(a.body.arguments[c],a.input,a.environment),"t3",12);case 12:i.t4=i.t3,i.t2.push.call(i.t2,i.t4);case 14:c++,i.next=9;break;case 17:return i.delegateYield(At(o,s,r,n),"t5",18);case 18:a=i.t5,i.next=2;break;case 21:return i.abrupt("return",a);case 22:case"end":return i.stop()}}),_)}function At(t,e,r,n){var a,o,s;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(i.prev=0,o=e,t&&(o=Et(t.signature,e,r)),!L(t)){i.next=8;break}return i.delegateYield(St(t,o),"t0",5);case 5:a=i.t0,i.next=24;break;case 8:if(!t||!0!==t._jsonata_function){i.next=16;break}if(s={environment:n,input:r},a=t.implementation.apply(s,o),!D(a)){i.next=14;break}return i.delegateYield(a,"t1",13);case 13:a=i.t1;case 14:i.next=24;break;case 16:if("function"!=typeof t){i.next=23;break}if(a=t.apply(r,o),!D(a)){i.next=21;break}return i.delegateYield(a,"t2",20);case 20:a=i.t2;case 21:i.next=24;break;case 23:throw{code:"T1006",stack:(new Error).stack};case 24:i.next=30;break;case 26:throw i.prev=26,i.t3=i.catch(0),t&&(void 0===i.t3.token&&void 0!==t.token&&(i.t3.token=t.token),i.t3.position=t.position||i.t3.position),i.t3;case 30:return i.abrupt("return",a);case 31:case"end":return i.stop()}}),k,null,[[0,26]])}function _t(t,e,r){var n={_jsonata_lambda:!0,input:e,environment:r,arguments:t.arguments,signature:t.signature,body:t.body};return!0===t.thunk&&(n.thunk=!0),n.apply=i().mark((function t(r,a){return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.delegateYield(wt(n,a,e,r.environment),"t0",1);case 1:return t.abrupt("return",t.t0);case 2:case"end":return t.stop()}}),t)})),n}function kt(t,e,r){var n,a,o,s,c;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:a=[],o=0;case 2:if(!(o<t.arguments.length)){i.next=15;break}if("operator"!==(s=t.arguments[o]).type||"?"!==s.value){i.next=8;break}a.push(s),i.next=12;break;case 8:return i.t0=a,i.delegateYield(B(s,e,r),"t1",10);case 10:i.t2=i.t1,i.t0.push.call(i.t0,i.t2);case 12:o++,i.next=2;break;case 15:return i.delegateYield(B(t.procedure,e,r),"t3",16);case 16:if(void 0!==(c=i.t3)||"path"!==t.procedure.type||!r.lookup(t.procedure.steps[0].value)){i.next=19;break}throw{code:"T1007",stack:(new Error).stack,position:t.position,token:t.procedure.steps[0].value};case 19:if(!L(c)){i.next=23;break}n=Mt(c,a),i.next=32;break;case 23:if(!c||!0!==c._jsonata_function){i.next=27;break}n=Tt(c.implementation,a),i.next=32;break;case 27:if("function"!=typeof c){i.next=31;break}n=Tt(c,a),i.next=32;break;case 31:throw{code:"T1008",stack:(new Error).stack,position:t.position,token:"path"===t.procedure.type?t.procedure.steps[0].value:t.procedure.value};case 32:return i.abrupt("return",n);case 33:case"end":return i.stop()}}),E)}function Et(t,e,r){return void 0===t?e:t.validate(e,r)}function St(t,e){var r,n;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(n=jt(t.environment),t.arguments.forEach((function(t,r){n.bind(t.value,e[r])})),"function"!=typeof t.body){i.next=7;break}return i.delegateYield(Pt(t.body,n),"t0",4);case 4:r=i.t0,i.next=9;break;case 7:return i.delegateYield(B(t.body,t.input,n),"t1",8);case 8:r=i.t1;case 9:return i.abrupt("return",r);case 10:case"end":return i.stop()}}),S)}function Mt(t,e){var r=jt(t.environment),n=[];return t.arguments.forEach((function(t,i){var a=e[i];a&&"operator"===a.type&&"?"===a.value?n.push(t):r.bind(t.value,a)})),{_jsonata_lambda:!0,input:t.input,environment:r,arguments:n,body:t.body}}function Tt(t,e){var r=Ot(t),n="function("+(r=r.map((function(t){return"$"+t.trim()}))).join(", ")+"){ _ }",i=c(n);return i.body=t,Mt(i,e)}function Pt(t,e){var r,n,a,o;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(r=Ot(t),n=r.map((function(t){return e.lookup(t.trim())})),a={environment:e},o=t.apply(a,n),!D(o)){i.next=7;break}return i.delegateYield(o,"t0",6);case 6:o=i.t0;case 7:return i.abrupt("return",o);case 8:case"end":return i.stop()}}),M)}function Ot(t){var e=t.toString();return/\(([^)]*)\)/.exec(e)[1].split(",")}function It(t,e){var r={_jsonata_function:!0,implementation:t};return void 0!==e&&(r.signature=u(e)),r}function Ct(t,e){var r,n,a;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(void 0!==t){i.next=2;break}return i.abrupt("return",void 0);case 2:r=this.input,void 0!==e&&(r=e,Array.isArray(r)&&!R(r)&&((r=C(r)).outerWrapper=!0)),i.prev=4,n=c(t,!1),i.next=12;break;case 8:throw i.prev=8,i.t0=i.catch(4),Dt(i.t0),{stack:(new Error).stack,code:"D3120",value:i.t0.message,error:i.t0};case 12:return i.prev=12,i.delegateYield(B(n,r,this.environment),"t1",14);case 14:a=i.t1,i.next=21;break;case 17:throw i.prev=17,i.t2=i.catch(12),Dt(i.t2),{stack:(new Error).stack,code:"D3121",value:i.t2.message,error:i.t2};case 21:return i.abrupt("return",a);case 22:case"end":return i.stop()}}),T,this,[[4,8],[12,17]])}function Rt(t){if(void 0!==t)return JSON.parse(o.string(t))}function jt(t){var e={};return{bind:function(t,r){e[t]=r},lookup:function(r){var n;return e.hasOwnProperty(r)?n=e[r]:t&&(n=t.lookup(r)),n},timestamp:t?t.timestamp:null,async:!!t&&t.async,global:t?t.global:{ancestry:[null]}}}N.bind("sum",It(o.sum,"<a<n>:n>")),N.bind("count",It(o.count,"<a:n>")),N.bind("max",It(o.max,"<a<n>:n>")),N.bind("min",It(o.min,"<a<n>:n>")),N.bind("average",It(o.average,"<a<n>:n>")),N.bind("string",It(o.string,"<x-b?:s>")),N.bind("substring",It(o.substring,"<s-nn?:s>")),N.bind("substringBefore",It(o.substringBefore,"<s-s:s>")),N.bind("substringAfter",It(o.substringAfter,"<s-s:s>")),N.bind("lowercase",It(o.lowercase,"<s-:s>")),N.bind("uppercase",It(o.uppercase,"<s-:s>")),N.bind("length",It(o.length,"<s-:n>")),N.bind("trim",It(o.trim,"<s-:s>")),N.bind("pad",It(o.pad,"<s-ns?:s>")),N.bind("match",It(o.match,"<s-f<s:o>n?:a<o>>")),N.bind("contains",It(o.contains,"<s-(sf):b>")),N.bind("replace",It(o.replace,"<s-(sf)(sf)n?:s>")),N.bind("split",It(o.split,"<s-(sf)n?:a<s>>")),N.bind("join",It(o.join,"<a<s>s?:s>")),N.bind("formatNumber",It(o.formatNumber,"<n-so?:s>")),N.bind("formatBase",It(o.formatBase,"<n-n?:s>")),N.bind("formatInteger",It(a.formatInteger,"<n-s:s>")),N.bind("parseInteger",It(a.parseInteger,"<s-s:n>")),N.bind("number",It(o.number,"<(nsb)-:n>")),N.bind("floor",It(o.floor,"<n-:n>")),N.bind("ceil",It(o.ceil,"<n-:n>")),N.bind("round",It(o.round,"<n-n?:n>")),N.bind("abs",It(o.abs,"<n-:n>")),N.bind("sqrt",It(o.sqrt,"<n-:n>")),N.bind("power",It(o.power,"<n-n:n>")),N.bind("random",It(o.random,"<:n>")),N.bind("boolean",It(o.boolean,"<x-:b>")),N.bind("not",It(o.not,"<x-:b>")),N.bind("map",It(o.map,"<af>")),N.bind("zip",It(o.zip,"<a+>")),N.bind("filter",It(o.filter,"<af>")),N.bind("single",It(o.single,"<af?>")),N.bind("reduce",It(o.foldLeft,"<afj?:j>")),N.bind("sift",It(o.sift,"<o-f?:o>")),N.bind("keys",It(o.keys,"<x-:a<s>>")),N.bind("lookup",It(o.lookup,"<x-s:x>")),N.bind("append",It(o.append,"<xx:a>")),N.bind("exists",It(o.exists,"<x:b>")),N.bind("spread",It(o.spread,"<x-:a<o>>")),N.bind("merge",It(o.merge,"<a<o>:o>")),N.bind("reverse",It(o.reverse,"<a:a>")),N.bind("each",It(o.each,"<o-f:a>")),N.bind("error",It(o.error,"<s?:x>")),N.bind("assert",It(o.assert,"<bs?:x>")),N.bind("type",It(o.type,"<x:s>")),N.bind("sort",It(o.sort,"<af?:a>")),N.bind("shuffle",It(o.shuffle,"<a:a>")),N.bind("distinct",It(o.distinct,"<x:x>")),N.bind("base64encode",It(o.base64encode,"<s-:s>")),N.bind("base64decode",It(o.base64decode,"<s-:s>")),N.bind("encodeUrlComponent",It(o.encodeUrlComponent,"<s-:s>")),N.bind("encodeUrl",It(o.encodeUrl,"<s-:s>")),N.bind("decodeUrlComponent",It(o.decodeUrlComponent,"<s-:s>")),N.bind("decodeUrl",It(o.decodeUrl,"<s-:s>")),N.bind("eval",It(Ct,"<sx?:x>")),N.bind("toMillis",It(a.toMillis,"<s-s?:n>")),N.bind("fromMillis",It(a.fromMillis,"<n-s?s?:s>")),N.bind("clone",It(Rt,"<(oa)-:o>"));var Lt={S0101:"String literal must be terminated by a matching quote",S0102:"Number out of range: {{token}}",S0103:"Unsupported escape sequence: \\{{token}}",S0104:"The escape sequence \\u must be followed by 4 hex digits",S0105:"Quoted property name must be terminated with a backquote (`)",S0106:"Comment has no closing tag",S0201:"Syntax error: {{token}}",S0202:"Expected {{value}}, got {{token}}",S0203:"Expected {{value}} before end of expression",S0204:"Unknown operator: {{token}}",S0205:"Unexpected token: {{token}}",S0206:"Unknown expression type: {{token}}",S0207:"Unexpected end of expression",S0208:"Parameter {{value}} of function definition must be a variable name (start with $)",S0209:"A predicate cannot follow a grouping expression in a step",S0210:"Each step can only have one grouping expression",S0211:"The symbol {{token}} cannot be used as a unary operator",S0212:"The left side of := must be a variable name (start with $)",S0213:"The literal value {{value}} cannot be used as a step within a path expression",S0214:"The right side of {{token}} must be a variable name (start with $)",S0215:"A context variable binding must precede any predicates on a step",S0216:"A context variable binding must precede the 'order-by' clause on a step",S0217:"The object representing the 'parent' cannot be derived from this expression",S0301:"Empty regular expressions are not allowed",S0302:"No terminating / in regular expression",S0402:"Choice groups containing parameterized types are not supported",S0401:"Type parameters can only be applied to functions and arrays",S0500:"Attempted to evaluate an expression containing syntax error(s)",T0410:"Argument {{index}} of function {{token}} does not match function signature",T0411:"Context value is not a compatible type with argument {{index}} of function {{token}}",T0412:"Argument {{index}} of function {{token}} must be an array of {{type}}",D1001:"Number out of range: {{value}}",D1002:"Cannot negate a non-numeric value: {{value}}",T1003:"Key in object structure must evaluate to a string; got: {{value}}",D1004:"Regular expression matches zero length string",T1005:"Attempted to invoke a non-function. Did you mean ${{{token}}}?",T1006:"Attempted to invoke a non-function",T1007:"Attempted to partially apply a non-function. Did you mean ${{{token}}}?",T1008:"Attempted to partially apply a non-function",D1009:"Multiple key definitions evaluate to same key: {{value}}",D1010:"Attempted to access the Javascript object prototype",T1010:"The matcher function argument passed to function {{token}} does not return the correct object structure",T2001:"The left side of the {{token}} operator must evaluate to a number",T2002:"The right side of the {{token}} operator must evaluate to a number",T2003:"The left side of the range operator (..) must evaluate to an integer",T2004:"The right side of the range operator (..) must evaluate to an integer",D2005:"The left side of := must be a variable name (start with $)",T2006:"The right side of the function application operator ~> must be a function",T2007:"Type mismatch when comparing values {{value}} and {{value2}} in order-by clause",T2008:"The expressions within an order-by clause must evaluate to numeric or string values",T2009:"The values {{value}} and {{value2}} either side of operator {{token}} must be of the same data type",T2010:"The expressions either side of operator {{token}} must evaluate to numeric or string values",T2011:"The insert/update clause of the transform expression must evaluate to an object: {{value}}",T2012:"The delete clause of the transform expression must evaluate to a string or array of strings: {{value}}",T2013:"The transform expression clones the input object using the $clone() function. This has been overridden in the current scope by a non-function.",D2014:"The size of the sequence allocated by the range operator (..) must not exceed 1e6. Attempted to allocate {{value}}.",D3001:"Attempting to invoke string function on Infinity or NaN",D3010:"Second argument of replace function cannot be an empty string",D3011:"Fourth argument of replace function must evaluate to a positive number",D3012:"Attempted to replace a matched string with a non-string value",D3020:"Third argument of split function must evaluate to a positive number",D3030:"Unable to cast value to a number: {{value}}",D3040:"Third argument of match function must evaluate to a positive number",D3050:"The second argument of reduce function must be a function with at least two arguments",D3060:"The sqrt function cannot be applied to a negative number: {{value}}",D3061:"The power function has resulted in a value that cannot be represented as a JSON number: base={{value}}, exponent={{exp}}",D3070:"The single argument form of the sort function can only be applied to an array of strings or an array of numbers. Use the second argument to specify a comparison function",D3080:"The picture string must only contain a maximum of two sub-pictures",D3081:"The sub-picture must not contain more than one instance of the 'decimal-separator' character",D3082:"The sub-picture must not contain more than one instance of the 'percent' character",D3083:"The sub-picture must not contain more than one instance of the 'per-mille' character",D3084:"The sub-picture must not contain both a 'percent' and a 'per-mille' character",D3085:"The mantissa part of a sub-picture must contain at least one character that is either an 'optional digit character' or a member of the 'decimal digit family'",D3086:"The sub-picture must not contain a passive character that is preceded by an active character and that is followed by another active character",D3087:"The sub-picture must not contain a 'grouping-separator' character that appears adjacent to a 'decimal-separator' character",D3088:"The sub-picture must not contain a 'grouping-separator' at the end of the integer part",D3089:"The sub-picture must not contain two adjacent instances of the 'grouping-separator' character",D3090:"The integer part of the sub-picture must not contain a member of the 'decimal digit family' that is followed by an instance of the 'optional digit character'",D3091:"The fractional part of the sub-picture must not contain an instance of the 'optional digit character' that is followed by a member of the 'decimal digit family'",D3092:"A sub-picture that contains a 'percent' or 'per-mille' character must not contain a character treated as an 'exponent-separator'",D3093:"The exponent part of the sub-picture must comprise only of one or more characters that are members of the 'decimal digit family'",D3100:"The radix of the formatBase function must be between 2 and 36. It was given {{value}}",D3110:"The argument of the toMillis function must be an ISO 8601 formatted timestamp. Given {{value}}",D3120:"Syntax error in expression passed to function eval: {{value}}",D3121:"Dynamic error evaluating the expression passed to function eval: {{value}}",D3130:"Formatting or parsing an integer as a sequence starting with {{value}} is not supported by this implementation",D3131:"In a decimal digit pattern, all digits must be from the same decimal group",D3132:"Unknown component specifier {{value}} in date/time picture string",D3133:"The 'name' modifier can only be applied to months and days in the date/time picture string, not {{value}}",D3134:"The timezone integer format specifier cannot have more than four digits",D3135:"No matching closing bracket ']' in date/time picture string",D3136:"The date/time picture string is missing specifiers required to parse the timestamp",D3137:"{{{message}}}",D3138:"The $single() function expected exactly 1 matching result. Instead it matched more.",D3139:"The $single() function expected exactly 1 matching result. Instead it matched 0.",D3140:"Malformed URL passed to ${{{functionName}}}(): {{value}}",D3141:"{{{message}}}"};function Dt(t){var e=Lt[t.code];if(void 0!==e){var r=e.replace(/\{\{\{([^}]+)}}}/g,(function(){return t[arguments[1]]}));r=r.replace(/\{\{([^}]+)}}/g,(function(){return JSON.stringify(t[arguments[1]])})),t.message=r}}function zt(t,e){var r,n;try{r=c(t,e&&e.recover),n=r.errors,delete r.errors}catch(t){throw Dt(t),t}var i=jt(N),o=new Date;return i.bind("now",It((function(t,e){return a.fromMillis(o.getTime(),t,e)}),"<s?s?:s>")),i.bind("millis",It((function(){return o.getTime()}),"<:n>")),e&&e.RegexEngine?zt.RegexEngine=e.RegexEngine:zt.RegexEngine=RegExp,{evaluate:function(t,e,a){if(void 0!==n){var s={code:"S0500",position:0};throw Dt(s),s}var c,u,l;if(void 0!==e)for(var h in c=jt(i),e)c.bind(h,e[h]);else c=i;if(c.bind("$",t),o=new Date,c.timestamp=o,Array.isArray(t)&&!R(t)&&((t=C(t)).outerWrapper=!0),"function"==typeof a){c.async=!0;var f=function(t){Dt(t),a(t,null)},d=function t(e){(u=l.next(e)).done?a(null,u.value):u.value.then(t).catch(f)};l=B(r,t,c),(u=l.next()).value.then(d).catch(f)}else try{for(l=B(r,t,c),u=l.next();!u.done;)u=l.next(u.value);return u.value}catch(s){throw Dt(s),s}},assign:function(t,e){i.bind(t,e)},registerFunction:function(t,e,r){var n=It(e,r);i.bind(t,n)},ast:function(){return r},errors:function(){return n}}}return zt.parser=c,zt}();e.exports=l},{"./datetime":1,"./functions":2,"./parser":4,"./signature":5,"./utils":6}],4:[function(t,e,r){var n=t("./signature"),i=function(){var t={".":75,"[":80,"]":0,"{":70,"}":0,"(":80,")":0,",":0,"@":80,"#":80,";":80,":":80,"?":20,"+":50,"-":50,"*":60,"/":60,"%":60,"|":20,"=":40,"<":40,">":40,"^":40,"**":60,"..":20,":=":10,"!=":40,"<=":40,">=":40,"~>":40,and:30,or:25,in:40,"&":50,"!":0,"~":0},e={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"},r=function(r){var n=0,i=r.length,a=function(t,e){return{type:t,value:e,position:n}},o=function(){for(var t,e,a=n,o=0;n<i;){var s=r.charAt(n);if("/"===s&&"\\"!==r.charAt(n-1)&&0===o){if(""===(t=r.substring(a,n)))throw{code:"S0301",stack:(new Error).stack,position:n};for(n++,s=r.charAt(n),a=n;"i"===s||"m"===s;)n++,s=r.charAt(n);return e=r.substring(a,n)+"g",new RegExp(t,e)}"("!==s&&"["!==s&&"{"!==s||"\\"===r.charAt(n-1)||o++,")"!==s&&"]"!==s&&"}"!==s||"\\"===r.charAt(n-1)||o--,n++}throw{code:"S0302",stack:(new Error).stack,position:n}},s=function s(c){if(n>=i)return null;for(var u=r.charAt(n);n<i&&" \t\n\r\v".indexOf(u)>-1;)n++,u=r.charAt(n);if("/"===u&&"*"===r.charAt(n+1)){var l=n;for(n+=2,u=r.charAt(n);"*"!==u||"/"!==r.charAt(n+1);)if(u=r.charAt(++n),n>=i)throw{code:"S0106",stack:(new Error).stack,position:l};return n+=2,u=r.charAt(n),s(c)}if(!0!==c&&"/"===u)return n++,a("regex",o());if("."===u&&"."===r.charAt(n+1))return n+=2,a("operator","..");if(":"===u&&"="===r.charAt(n+1))return n+=2,a("operator",":=");if("!"===u&&"="===r.charAt(n+1))return n+=2,a("operator","!=");if(">"===u&&"="===r.charAt(n+1))return n+=2,a("operator",">=");if("<"===u&&"="===r.charAt(n+1))return n+=2,a("operator","<=");if("*"===u&&"*"===r.charAt(n+1))return n+=2,a("operator","**");if("~"===u&&">"===r.charAt(n+1))return n+=2,a("operator","~>");if(Object.prototype.hasOwnProperty.call(t,u))return n++,a("operator",u);if('"'===u||"'"===u){var h=u;n++;for(var f="";n<i;){if("\\"===(u=r.charAt(n)))if(n++,u=r.charAt(n),Object.prototype.hasOwnProperty.call(e,u))f+=e[u];else{if("u"!==u)throw{code:"S0103",stack:(new Error).stack,position:n,token:u};var d=r.substr(n+1,4);if(!/^[0-9a-fA-F]+$/.test(d))throw{code:"S0104",stack:(new Error).stack,position:n};var p=parseInt(d,16);f+=String.fromCharCode(p),n+=4}else{if(u===h)return n++,a("string",f);f+=u}n++}throw{code:"S0101",stack:(new Error).stack,position:n}}var g,v=/^-?(0|([1-9][0-9]*))(\.[0-9]+)?([Ee][-+]?[0-9]+)?/.exec(r.substring(n));if(null!==v){var y=parseFloat(v[0]);if(!isNaN(y)&&isFinite(y))return n+=v[0].length,a("number",y);throw{code:"S0102",stack:(new Error).stack,position:n,token:v[0]}}if("`"===u){n++;var m=r.indexOf("`",n);if(-1!==m)return g=r.substring(n,m),n=m+1,a("name",g);throw n=i,{code:"S0105",stack:(new Error).stack,position:n}}for(var b,x=n;;)if(b=r.charAt(x),x===i||" \t\n\r\v".indexOf(b)>-1||Object.prototype.hasOwnProperty.call(t,b)){if("$"===r.charAt(n))return g=r.substring(n+1,x),n=x,a("variable",g);switch(g=r.substring(n,x),n=x,g){case"or":case"in":case"and":return a("operator",g);case"true":return a("value",!0);case"false":return a("value",!1);case"null":return a("value",null);default:return n===i&&""===g?null:a("name",g)}}else x++};return s},i=function(e,i){var a,o,s={},c=[],u=function(){var t=[];"(end)"!==a.id&&t.push({type:a.type,value:a.value,position:a.position});for(var e=o();null!==e;)t.push(e),e=o();return t},l={nud:function(){var t={code:"S0211",token:this.value,position:this.position};if(i)return t.remaining=u(),t.type="error",c.push(t),t;throw t.stack=(new Error).stack,t}},h=function(t,e){var r=s[t];return e=e||0,r?e>=r.lbp&&(r.lbp=e):((r=Object.create(l)).id=r.value=t,r.lbp=e,s[t]=r),r},f=function(t){if(i){t.remaining=u(),c.push(t);var e=s["(error)"];return(a=Object.create(e)).error=t,a.type="(error)",a}throw t.stack=(new Error).stack,t},d=function(t,r){if(t&&a.id!==t){var n={code:"(end)"===a.id?"S0203":"S0202",position:a.position,token:a.value,value:t};return f(n)}var i=o(r);if(null===i)return(a=s["(end)"]).position=e.length,a;var c,u=i.value,l=i.type;switch(l){case"name":case"variable":c=s["(name)"];break;case"operator":if(!(c=s[u]))return f({code:"S0204",stack:(new Error).stack,position:i.position,token:u});break;case"string":case"number":case"value":c=s["(literal)"];break;case"regex":l="regex",c=s["(regex)"];break;default:return f({code:"S0205",stack:(new Error).stack,position:i.position,token:u})}return(a=Object.create(c)).value=u,a.type=l,a.position=i.position,a},p=function(t){var e,r=a;for(d(null,!0),e=r.nud();t<a.lbp;)r=a,d(),e=r.led(e);return e},g=function(t){h(t,0).nud=function(){return this}},v=function(e,r,n){var i=r||t[e],a=h(e,i);return a.led=n||function(t){return this.lhs=t,this.rhs=p(i),this.type="binary",this},a},y=function(t,e,r){var n=h(t,e);return n.led=r,n},m=function(t,e){var r=h(t);return r.nud=e||function(){return this.expression=p(70),this.type="unary",this},r};g("(end)"),g("(name)"),g("(literal)"),g("(regex)"),h(":"),h(";"),h(","),h(")"),h("]"),h("}"),h(".."),v("."),v("+"),v("-"),v("*"),v("/"),v("%"),v("="),v("<"),v(">"),v("!="),v("<="),v(">="),v("&"),v("and"),v("or"),v("in"),g("and"),g("or"),g("in"),m("-"),v("~>"),y("(error)",10,(function(t){return this.lhs=t,this.error=a.error,this.remaining=u(),this.type="error",this})),m("*",(function(){return this.type="wildcard",this})),m("**",(function(){return this.type="descendant",this})),m("%",(function(){return this.type="parent",this})),v("(",t["("],(function(t){if(this.procedure=t,this.type="function",this.arguments=[],")"!==a.id)for(;"operator"===a.type&&"?"===a.id?(this.type="partial",this.arguments.push(a),d("?")):this.arguments.push(p(0)),","===a.id;)d(",");if(d(")",!0),"name"===t.type&&("function"===t.value||"λ"===t.value)){if(this.arguments.forEach((function(t,e){if("variable"!==t.type)return f({code:"S0208",stack:(new Error).stack,position:t.position,token:t.value,value:e+1})})),this.type="lambda","<"===a.id){for(var e=a.position,r=1,i="<";r>0&&"{"!==a.id&&"(end)"!==a.id;){var o=d();">"===o.id?r--:"<"===o.id&&r++,i+=o.value}d(">");try{this.signature=n(i)}catch(t){return t.position=e+t.offset,f(t)}}d("{"),this.body=p(0),d("}")}return this})),m("(",(function(){for(var t=[];")"!==a.id&&(t.push(p(0)),";"===a.id);)d(";");return d(")",!0),this.type="block",this.expressions=t,this})),m("[",(function(){var t=[];if("]"!==a.id)for(;;){var e=p(0);if(".."===a.id){var r={type:"binary",value:"..",position:a.position,lhs:e};d(".."),r.rhs=p(0),e=r}if(t.push(e),","!==a.id)break;d(",")}return d("]",!0),this.expressions=t,this.type="unary",this})),v("[",t["["],(function(e){if("]"===a.id){for(var r=e;r&&"binary"===r.type&&"["===r.value;)r=r.lhs;return r.keepArray=!0,d("]"),e}return this.lhs=e,this.rhs=p(t["]"]),this.type="binary",d("]",!0),this})),v("^",t["^"],(function(t){d("(");for(var e=[];;){var r={descending:!1};if("<"===a.id?d("<"):">"===a.id&&(r.descending=!0,d(">")),r.expression=p(0),e.push(r),","!==a.id)break;d(",")}return d(")"),this.lhs=t,this.rhs=e,this.type="binary",this}));var b=function(t){var e=[];if("}"!==a.id)for(;;){var r=p(0);d(":");var n=p(0);if(e.push([r,n]),","!==a.id)break;d(",")}return d("}",!0),void 0===t?(this.lhs=e,this.type="unary"):(this.lhs=t,this.rhs=e,this.type="binary"),this};m("{",b),v("{",t["{"],b),y(":=",t[":="],(function(e){return"variable"!==e.type?f({code:"S0212",stack:(new Error).stack,position:e.position,token:e.value}):(this.lhs=e,this.rhs=p(t[":="]-1),this.type="binary",this)})),v("@",t["@"],(function(e){return this.lhs=e,this.rhs=p(t["@"]),"variable"!==this.rhs.type?f({code:"S0214",stack:(new Error).stack,position:this.rhs.position,token:"@"}):(this.type="binary",this)})),v("#",t["#"],(function(e){return this.lhs=e,this.rhs=p(t["#"]),"variable"!==this.rhs.type?f({code:"S0214",stack:(new Error).stack,position:this.rhs.position,token:"#"}):(this.type="binary",this)})),v("?",t["?"],(function(t){return this.type="condition",this.condition=t,this.then=p(0),":"===a.id&&(d(":"),this.else=p(0)),this})),m("|",(function(){return this.type="transform",this.pattern=p(0),d("|"),this.update=p(0),","===a.id&&(d(","),this.delete=p(0)),d("|"),this}));var x=function t(e){var r;if("function"!==e.type||e.predicate)if("condition"===e.type)e.then=t(e.then),void 0!==e.else&&(e.else=t(e.else)),r=e;else if("block"===e.type){var n=e.expressions.length;n>0&&(e.expressions[n-1]=t(e.expressions[n-1])),r=e}else r=e;else{var i={type:"lambda",thunk:!0,arguments:[],position:e.position};i.body=e,r=i}return r},w=0,A=0,_=[],k=function t(e,r){switch(e.type){case"name":case"wildcard":r.level--,0===r.level&&(void 0===e.ancestor||(_[r.index].slot.label=e.ancestor.label),e.ancestor=r,e.tuple=!0);break;case"parent":r.level++;break;case"block":e.expressions.length>0&&(e.tuple=!0,r=t(e.expressions[e.expressions.length-1],r));break;case"path":e.tuple=!0;var n=e.steps.length-1;for(r=t(e.steps[n--],r);r.level>0&&n>=0;)r=t(e.steps[n--],r);break;default:throw{code:"S0217",token:e.type,position:e.position}}return r},E=function(t,e){if(void 0!==e.seekingParent||"parent"===e.type){var r=void 0!==e.seekingParent?e.seekingParent:[];"parent"===e.type&&r.push(e.slot),void 0===t.seekingParent?t.seekingParent=r:Array.prototype.push.apply(t.seekingParent,r)}},S=function(t){var e=t.steps.length-1,r=t.steps[e],n=void 0!==r.seekingParent?r.seekingParent:[];"parent"===r.type&&n.push(r.slot);for(var i=0;i<n.length;i++){var a=n[i];for(e=t.steps.length-2;a.level>0;){if(e<0){void 0===t.seekingParent?t.seekingParent=[a]:t.seekingParent.push(a);break}for(var o=t.steps[e--];e>=0&&o.focus&&t.steps[e].focus;)o=t.steps[e--];a=k(o,a)}}},M=function t(e){var r;switch(e.type){case"binary":switch(e.value){case".":var n=t(e.lhs);r="path"===n.type?n:{type:"path",steps:[n]},"parent"===n.type&&(r.seekingParent=[n.slot]);var a=t(e.rhs);"function"===a.type&&"path"===a.procedure.type&&1===a.procedure.steps.length&&"name"===a.procedure.steps[0].type&&"function"===r.steps[r.steps.length-1].type&&(r.steps[r.steps.length-1].nextFunction=a.procedure.steps[0].value),"path"===a.type?Array.prototype.push.apply(r.steps,a.steps):(void 0!==a.predicate&&(a.stages=a.predicate,delete a.predicate),r.steps.push(a)),r.steps.filter((function(t){if("number"===t.type||"value"===t.type)throw{code:"S0213",stack:(new Error).stack,position:t.position,value:t.value};return"string"===t.type})).forEach((function(t){t.type="name"})),r.steps.filter((function(t){return!0===t.keepArray})).length>0&&(r.keepSingletonArray=!0);var o=r.steps[0];"unary"===o.type&&"["===o.value&&(o.consarray=!0);var s=r.steps[r.steps.length-1];"unary"===s.type&&"["===s.value&&(s.consarray=!0),S(r);break;case"[":var u=r=t(e.lhs),l="predicate";if("path"===r.type&&(u=r.steps[r.steps.length-1],l="stages"),void 0!==u.group)throw{code:"S0209",stack:(new Error).stack,position:e.position};void 0===u[l]&&(u[l]=[]);var h=t(e.rhs);void 0!==h.seekingParent&&(h.seekingParent.forEach((function(t){1===t.level?k(u,t):t.level--})),E(u,h)),u[l].push({type:"filter",expr:h,position:e.position});break;case"{":if(void 0!==(r=t(e.lhs)).group)throw{code:"S0210",stack:(new Error).stack,position:e.position};r.group={lhs:e.rhs.map((function(e){return[t(e[0]),t(e[1])]})),position:e.position};break;case"^":"path"!==(r=t(e.lhs)).type&&(r={type:"path",steps:[r]});var f={type:"sort",position:e.position};f.terms=e.rhs.map((function(e){var r=t(e.expression);return E(f,r),{descending:e.descending,expression:r}})),r.steps.push(f),S(r);break;case":=":(r={type:"bind",value:e.value,position:e.position}).lhs=t(e.lhs),r.rhs=t(e.rhs),E(r,r.rhs);break;case"@":if(r=t(e.lhs),u=r,"path"===r.type&&(u=r.steps[r.steps.length-1]),void 0!==u.stages||void 0!==u.predicate)throw{code:"S0215",stack:(new Error).stack,position:e.position};if("sort"===u.type)throw{code:"S0216",stack:(new Error).stack,position:e.position};e.keepArray&&(u.keepArray=!0),u.focus=e.rhs.value,u.tuple=!0;break;case"#":r=t(e.lhs),u=r,"path"===r.type?u=r.steps[r.steps.length-1]:(r={type:"path",steps:[r]},void 0!==u.predicate&&(u.stages=u.predicate,delete u.predicate)),void 0===u.stages?u.index=e.rhs.value:u.stages.push({type:"index",value:e.rhs.value,position:e.position}),u.tuple=!0;break;case"~>":(r={type:"apply",value:e.value,position:e.position}).lhs=t(e.lhs),r.rhs=t(e.rhs);break;default:(r={type:e.type,value:e.value,position:e.position}).lhs=t(e.lhs),r.rhs=t(e.rhs),E(r,r.lhs),E(r,r.rhs)}break;case"unary":r={type:e.type,value:e.value,position:e.position},"["===e.value?r.expressions=e.expressions.map((function(e){var n=t(e);return E(r,n),n})):"{"===e.value?r.lhs=e.lhs.map((function(e){var n=t(e[0]);E(r,n);var i=t(e[1]);return E(r,i),[n,i]})):(r.expression=t(e.expression),"-"===e.value&&"number"===r.expression.type?(r=r.expression).value=-r.value:E(r,r.expression));break;case"function":case"partial":(r={type:e.type,name:e.name,value:e.value,position:e.position}).arguments=e.arguments.map((function(e){var n=t(e);return E(r,n),n})),r.procedure=t(e.procedure);break;case"lambda":r={type:e.type,arguments:e.arguments,signature:e.signature,position:e.position};var d=t(e.body);r.body=x(d);break;case"condition":(r={type:e.type,position:e.position}).condition=t(e.condition),E(r,r.condition),r.then=t(e.then),E(r,r.then),void 0!==e.else&&(r.else=t(e.else),E(r,r.else));break;case"transform":(r={type:e.type,position:e.position}).pattern=t(e.pattern),r.update=t(e.update),void 0!==e.delete&&(r.delete=t(e.delete));break;case"block":(r={type:e.type,position:e.position}).expressions=e.expressions.map((function(e){var n=t(e);return E(r,n),(n.consarray||"path"===n.type&&n.steps[0].consarray)&&(r.consarray=!0),n}));break;case"name":r={type:"path",steps:[e]},e.keepArray&&(r.keepSingletonArray=!0);break;case"parent":r={type:"parent",slot:{label:"!"+w++,level:1,index:A++}},_.push(r);break;case"string":case"number":case"value":case"wildcard":case"descendant":case"variable":case"regex":r=e;break;case"operator":if("and"===e.value||"or"===e.value||"in"===e.value)e.type="name",r=t(e);else{if("?"!==e.value)throw{code:"S0201",stack:(new Error).stack,position:e.position,token:e.value};r=e}break;case"error":r=e,e.lhs&&(r=t(e.lhs));break;default:var p="S0206";"(end)"===e.id&&(p="S0207");var g={code:p,position:e.position,token:e.value};if(i)return c.push(g),{type:"error",error:g};throw g.stack=(new Error).stack,g}return e.keepArray&&(r.keepArray=!0),r};o=r(e),d();var T=p(0);if("(end)"!==a.id){var P={code:"S0201",position:a.position,token:a.value};f(P)}if("parent"===(T=M(T)).type||void 0!==T.seekingParent)throw{code:"S0217",token:T.type,position:T.position};return c.length>0&&(T.errors=c),T};return i}();e.exports=i},{"./signature":5}],5:[function(t,e,r){function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}var i=t("./utils"),a=function(){var t={a:"arrays",b:"booleans",f:"functions",n:"numbers",o:"objects",s:"strings"};function e(e){for(var r=1,a=[],o={},s=o;r<e.length;){var c=e.charAt(r);if(":"===c)break;var u=function(){a.push(o),s=o,o={}},l=function(t,e,r,n){for(var i=1,a=e;a<t.length;)if(a++,(c=t.charAt(a))===n){if(0==--i)break}else c===r&&i++;return a};switch(c){case"s":case"n":case"b":case"l":case"o":o.regex="["+c+"m]",o.type=c,u();break;case"a":o.regex="[asnblfom]",o.type=c,o.array=!0,u();break;case"f":o.regex="f",o.type=c,u();break;case"j":o.regex="[asnblom]",o.type=c,u();break;case"x":o.regex="[asnblfom]",o.type=c,u();break;case"-":s.context=!0,s.contextRegex=new RegExp(s.regex),s.regex+="?";break;case"?":case"+":s.regex+=c;break;case"(":var h=l(e,r,"(",")"),f=e.substring(r+1,h);if(-1!==f.indexOf("<"))throw{code:"S0402",stack:(new Error).stack,value:f,offset:r};o.regex="["+f+"m]",o.type="("+f+")",r=h,u();break;case"<":if("a"!==s.type&&"f"!==s.type)throw{code:"S0401",stack:(new Error).stack,value:s.type,offset:r};var d=l(e,r,"<",">");s.subtype=e.substring(r+1,d),r=d}r++}var p="^"+a.map((function(t){return"("+t.regex+")"})).join("")+"$",g=new RegExp(p),v=function(t){var e;if(i.isFunction(t))e="f";else switch(n(t)){case"string":e="s";break;case"number":e="n";break;case"boolean":e="b";break;case"object":e=null===t?"l":Array.isArray(t)?"a":"o";break;default:e="m"}return e},y=function(t,e){for(var r="^",n=0,i=0;i<a.length;i++){r+=a[i].regex;var o=e.match(r);if(null===o)throw{code:"T0410",stack:(new Error).stack,value:t[n],index:n+1};n=o[0].length}throw{code:"T0410",stack:(new Error).stack,value:t[n],index:n+1}};return{definition:e,validate:function(e,r){var n="";e.forEach((function(t){n+=v(t)}));var i=g.exec(n);if(i){var o=[],s=0;return a.forEach((function(n,a){var c=e[s],u=i[a+1];if(""===u)if(n.context&&n.contextRegex){var l=v(r);if(!n.contextRegex.test(l))throw{code:"T0411",stack:(new Error).stack,value:r,index:s+1};o.push(r)}else o.push(c),s++;else u.split("").forEach((function(r){if("a"===n.type){if("m"===r)c=void 0;else{c=e[s];var i=!0;if(void 0!==n.subtype)if("a"!==r&&u!==n.subtype)i=!1;else if("a"===r&&c.length>0){var a=v(c[0]);i=a===n.subtype.charAt(0)&&0===c.filter((function(t){return v(t)!==a})).length}if(!i)throw{code:"T0412",stack:(new Error).stack,value:c,index:s+1,type:t[n.subtype]};"a"!==r&&(c=[c])}o.push(c),s++}else o.push(c),s++}))})),o}y(e,n)}}}return e}();e.exports=a},{"./utils":6}],6:[function(t,e,r){function n(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=i(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,a=function(){};return{s:a,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){c=!0,o=t},f:function(){try{s||null==r.return||r.return()}finally{if(c)throw o}}}}function i(t,e){if(t){if("string"==typeof t)return a(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?a(t,e):void 0}}function a(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function o(t){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},o(t)}var s=function(){function t(t){var e=!1;if("number"==typeof t&&(e=!isNaN(t))&&!isFinite(t))throw{code:"D1001",value:t,stack:(new Error).stack};return e}function e(t){var e=!1;return Array.isArray(t)&&(e=0===t.filter((function(t){return"string"!=typeof t})).length),e}function r(e){var r=!1;return Array.isArray(e)&&(r=0===e.filter((function(e){return!t(e)})).length),r}function i(){var t=[];return t.sequence=!0,1===arguments.length&&t.push(arguments[0]),t}function a(t){return!0===t.sequence&&Array.isArray(t)}function s(t){return t&&(!0===t._jsonata_function||!0===t._jsonata_lambda)||"function"==typeof t}function c(t){return"number"==typeof t.arity?t.arity:"function"==typeof t.implementation?t.implementation.length:"number"==typeof t.length?t.length:t.arguments.length}function u(t){return t&&!0===t._jsonata_lambda}var l=("function"==typeof Symbol?Symbol:{}).iterator||"@@iterator";function h(t){return"object"===o(t)&&null!==t&&l in t&&"next"in t&&"function"==typeof t.next}function f(t,e){if(t===e)return!0;if("object"===o(t)&&"object"===o(e)&&null!==t&&null!==e){if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return!1;for(var r=0;r<t.length;r++)if(!f(t[r],e[r]))return!1;return!0}var n=Object.getOwnPropertyNames(t),i=Object.getOwnPropertyNames(e);if(n.length!==i.length)return!1;for(n=n.sort(),i=i.sort(),r=0;r<n.length;r++)if(n[r]!==i[r])return!1;for(r=0;r<n.length;r++){var a=n[r];if(!f(t[a],e[a]))return!1}return!0}return!1}function d(t){var e,r=[],i=n(t);try{for(i.s();!(e=i.n()).done;){var a=e.value;r.push(a)}}catch(t){i.e(t)}finally{i.f()}return r}return{isNumeric:t,isArrayOfStrings:e,isArrayOfNumbers:r,createSequence:i,isSequence:a,isFunction:s,isLambda:u,isIterable:h,getFunctionArity:c,isDeepEqual:f,stringToArray:d}}();e.exports=s},{}]},{},[3])(3)}(c7);var u7=c7.exports;const l7=function(t){return t};function h7(t){if(!t)return l7;try{var e=u7(t);return function(t){return e.evaluate(t)}}catch(t){return console.error(t),l7}}function f7(t){var e=_8(t);return null==e?"":String(e)}function d7(t){return Number(_8(t))}function p7(t){return t}function g7(t){return f7(t)}function v7(t){return d7(t)}function y7(t){if(this.param)return t=f7(t),this.param.hasOwnProperty(t)?this.param[t]:this.param.default}function m7(t){var{param:e}=this;if(e){for(let r in e){let[n,i]=r.split("~"),a=!!n,o=!!i;if(n=parseFloat(n),i=parseFloat(i),t=d7(t),a&&!o&&t>=n)return e[r];if(!a&&o&&t<n)return e[r];if(t>=n&&t<i)return e[r]}return e.default}}function b7(t){return d7(t)*Math.PI/180}function x7(){}function w7(t,e,r,n,i){switch(r){case"value":return"text"===i||"string"===i?g7.bind(t):"number"===i?v7.bind(t):p7.bind(e);case"map":return y7.bind(t);case"range":return m7.bind(t);case"radian":return b7.bind(t);case"eval":return function(t){try{return new Function("value","targets",t)}catch(t){return L8(t),x7}}(n).bind(e);default:return p7.bind(e)}}class A7{constructor(t,e){this.owner=e,this.model=t}dispose(){delete this._model,delete this.owner,delete this.evaluator,delete this.accessor,delete this.source}get model(){return this._model}set model(t){var{target:e,property:r,rule:n,param:i,accessor:a}=t;this._model=t,this.evaluator=w7(this,this.owner,n,i,function(t){switch(t){case"ref":case"fillStyle":case"strokeStyle":return"string";default:return}}(r)),this.accessor=h7(a);const o=e.match(/\[(.*?)\]/);if(o){var[s,c]=o[1].split(":");this.propAccessor=h7(s),this.partAccessor=h7(c)}}get target(){return this.model.target}get property(){return this.model.property}get source(){return this.model.source}get param(){return this.model.param}get ndnsp(){return!!this.model.ndnsp}get partial(){return!!this.model.partial}}function _7(t,e,r,n){n?t.forEach((t=>t[e]={...t[e],...r})):t.forEach((t=>t[e]=r))}function k7(t=!1){(t||void 0!==this.data)&&this.mappings&&this.mappings.forEach((t=>{try{var e,{source:r,target:n,property:i,accessor:a,propAccessor:o,partAccessor:s,ndnsp:c=!1,partial:u=!1}=t;r&&"(self)"!=r?(r.startsWith("#")&&(r=r.substring(1)),e=this.root.findById(r)?.data||{}):e=this.data;var l=a(e);if("(root)"==(n=n.trim())||"(key)"==n){if(null==l)return;let e=Object.keys(l||{}).map((t=>this.root.findOrCreate(t))).filter(Boolean).flat();e.length>0&&e.forEach((e=>{let r=t.evaluator(l[e.get("id")],[e]);!i||"(action)"===i||c&&!r&&0!==r&&!1!==r||(e[i]=u?{...e[i],...r}:r)}))}else if(n.startsWith("[")){if(null==l)return;if(l instanceof Array)l.forEach((e=>{let r=o(e);if(r){let n=this.root.findOrCreate(r);if(n){let r=t.evaluator(s(e),n);!i||"(action)"===i||c&&!r&&0!==r&&!1!==r||_7(n,i,r,u)}}}));else{if(!(l instanceof Object))throw String("mapping data should be an object to target property-id.("+l+")");{let e=o(l);if(e){let r=this.root.findOrCreate(e);if(r){let e=t.evaluator(s(l),r);!i||"(action)"===i||c&&!e&&0!==e&&!1!==e||_7(r,i,e,u)}}}}}else{let e=this.root.findAll(n,this);if(e.length>0){let r=t.evaluator(l,e);!i||"(action)"===i||c&&!r&&0!==r&&!1!==r||_7(e,i,r,u)}}}catch(e){L8(e,this,t)}}))}var E7;function S7(t,e,r,n,i){var{alpha:a=1}=n,o=i.fillStyle;if(t.globalAlpha*=a,o)if("string"==typeof o)t.fillStyle=o,t.fill();else if("object"==typeof o)if("gradient"==o.type){t.translate(r.x,r.y);let n,{width:i,height:a}=e;if("linear"==o.gradientType){let e=3.141592653589793,r=o.rotation;if(r>=.436332&&r<=1.13446||r>=2.00713&&r<=2.70526||r>=3.57792&&r<=4.27606||r>=5.14872&&r<=5.84685){let o=Math.sqrt(Math.pow((i-4)/2,2)+Math.pow((a-4)/2,2));o-=o-(i+a)/3,n=t.createLinearGradient(o*Math.cos(r+e),o*Math.sin(r+e),o*Math.cos(r),o*Math.sin(r))}else n=t.createLinearGradient((i-4)/2*Math.cos(r+e),(a-4)/2*Math.sin(r+e),(i-4)/2*Math.cos(r),(a-4)/2*Math.sin(r))}else if("radial"==o.gradientType){let e=.95*Math.sqrt(Math.pow((i-4)/2,2)+Math.pow((a-4)/2,2));switch(o.center){case"center":default:n=t.createRadialGradient(0,0,0,0,0,e);break;case"left-top":n=t.createRadialGradient(-i/2,-a/2,0,-i/2,-a/2,2*e);break;case"right-top":n=t.createRadialGradient(i/2,-a/2,0,i/2,-a/2,2*e);break;case"left-bottom":n=t.createRadialGradient(-i/2,a/2,0,-i/2,a/2,2*e);break;case"right-bottom":n=t.createRadialGradient(i/2,a/2,0,i/2,a/2,2*e)}}o.colorStops.forEach((t=>{if(t.position>=0&&t.position<=1)try{n.addColorStop(t.position,t.color)}catch(e){D8("Invalid Color for colorstop : ",t.color),n.addColorStop(t.position,"#fff")}})),t.fillStyle=n,t.fill(),t.translate(-r.x,-r.y)}else if("pattern"==o.type&&o.image){i.prepareFillIf(!i._pattern_image_origin);var s=i._pattern_image;if(!s)return;let r=0,n=0,a=0,c=0,u=e.left,l=e.top;if(!o.fitPattern){r=o.offsetX,n=o.offsetY;const t=o.width?o.width:s.width,i=o.height?o.height:s.height;switch(o.align){case"center":a=e.width/2-t/2,c=e.height/2-i/2;break;case"left-top":a=0,c=0;break;case"left-bottom":a=0,c=e.height-i;break;case"right-top":a=e.width-t,c=0;break;case"right-bottom":a=e.width-t,c=e.height-i;break;case"left":a=0,c=e.height/2-i/2;break;case"right":a=e.width-t,c=e.height/2-i/2;break;case"top":a=e.width/2-t/2,c=0;break;case"bottom":a=e.width/2-t/2,c=e.height-i}u+=r+a,l+=n+c}t.translate(u,l),o.color&&(t.fillStyle=o.color,t.fill()),o.fitPattern?Math.abs((s.width-e.width)*(s.height-e.height))>1?(delete i._pattern_image,delete i._pattern_image_origin):t.fillStyle=t.createPattern(s,"no-repeat"):t.fillStyle=t.createPattern(s,o.noRepeat?"no-repeat":"repeat"),t.fill(),t.translate(-u,-l)}}function M7(t,e,r){var{strokeStyle:n,lineDash:i,lineWidth:a,lineCap:o,lineJoin:s,alpha:c}=e;if(n&&0!=a){if(o&&(t.lineCap=o),i){var u="round"==o;switch(i){case"solid":i=[0,0];break;case"round-dot":i=u?[0,2*a]:[a,a];break;case"square-dot":i=u?[a,2*a]:[2*a,a];break;case"dash":i=u?[3*a,2.5*a]:[4*a,1.5*a];break;case"dash-dot":i=u?[3*a,3*a,0,3*a]:[4*a,2*a,a,2*a];break;case"long-dash":i=u?[5*a,4*a]:[6*a,3*a];break;case"long-dash-dot":i=u?[5*a,3*a,0,3*a]:[6*a,2*a,a,2*a];break;case"long-dash-dot-dot":i=u?[5*a,2*a,0,2*a,0,2*a]:[6*a,a,a,a,a,a]}t.setLineDash(i)}t.globalAlpha*=c,t.strokeStyle=n,t.lineWidth=a,t.lineJoin=s,t.stroke()}}function T7(t,e,r,n,i,a=0,o=!1,s=!0){a="number"==typeof a?{tl:a,tr:a,br:a,bl:a}:{tl:0,tr:0,br:0,bl:0,...a},t.beginPath(),t.moveTo(e+a.tl,r),t.lineTo(e+n-a.tr,r),t.quadraticCurveTo(e+n,r,e+n,r+a.tr),t.lineTo(e+n,r+i-a.br),t.quadraticCurveTo(e+n,r+i,e+n-a.br,r+i),t.lineTo(e+a.bl,r+i),t.quadraticCurveTo(e,r+i,e,r+i-a.bl),t.lineTo(e,r+a.tl),t.quadraticCurveTo(e,r,e+a.tl,r),t.closePath(),o&&t.fill(),s&&t.stroke()}function P7(t){const e=/(\*\*|__)(.*?)\1|(\*|_)(.*?)\3|([^\*_]+)/g;let r,n=[];for(;null!==(r=e.exec(t));)r[1]?n.push({text:r[2],bold:!0,italic:!1}):r[3]?n.push({text:r[4],bold:!1,italic:!0}):r[5]&&n.push({text:r[5],bold:!1,italic:!1});return n}function O7(t,e,r){if(e.text.length<2)return e;for(var n=2;n<e.text.length;n++){var i=e.text.substring(0,n);if(!(t.measureText(i).width<r))break}return{...e,text:e.text.substring(0,n-1)}}function I7(t,e,r,n,i){var a=String(e).split("\n");return n?[].concat.apply([],a.map((e=>function(t,e,r){var n=[],i=[],a=0;return e.forEach((e=>{for(var o=e.text;o.length>0;){var s=r-a,c=t.measureText(o).width;if(c<=s)i.push({...e,text:o}),a+=c,o="";else{var u=O7(t,{...e,text:o},s);i.push(u),n.push(i),i=[],a=0,o=o.substring(u.text.length)}}})),i.length>0&&n.push(i),n}(t,i?P7(e):[{text:e,bold:!1,italic:!1}],r)))):a.map((t=>i?P7(t):[{text:t,bold:!1,italic:!1}]))}function C7(t,e,r,n,i,a){if(!n)return[];t.save(),t.font=r;var o=I7(t,n,e,!!i,a);return t.restore(),o}function R7(t){var{fontFamily:e=J8.FONT_FAMILY,bold:r=J8.BOLD,italic:n=J8.ITALIC,fontSize:i=J8.FONT_SIZE}=t,a=[];return r&&a.push("bold"),n&&a.push("italic"),a.push(i+"px"),a.push(e),a.join(" ")}function j7(t,e){let r=t.bold||e.bold,n=t.italic||e.italic,i=[];return r&&i.push("bold"),n&&i.push("italic"),i.push(t.fontSize+"px"),i.push(t.fontFamily),i.join(" ")}function L7(t,e,r,n){var{alpha:i,fontColor:a=J8.FONT_COLOR,textAlign:o=J8.TEXT_ALIGN,textBaseline:s=J8.TEXT_BASELINE,textBackgroundStyle:c,fontSize:u,lineHeight:l,textWrap:h,supportMarkdown:f=!0,textOverflow:d,bold:p=J8.BOLD,italic:g=J8.ITALIC}=n;i=void 0!==i?i:1,u||=J8.FONT_SIZE,l||=1.2*u,t.save(),t.beginPath();var{left:v,top:y,width:m,height:b}=e;if(t.font=R7(n),!h&&d){const e=function(t,e,r,n){const i="ellipsis"===t?"…":"",a=e.measureText(i).width;let o=[],s=0;for(let i of r){let r=[];for(let c of i){let i=e.measureText(c.text).width;if(!(s+i<=n-("ellipsis"===t?a:0))){let i=D7(e,c,n-s-("ellipsis"===t?a:0),t);return r.push(i),o.push(r),o}r.push(c),s+=i}o.push(r),s=0}return o}(d,t,r,m);r=e}var x,w=r.length*l;switch(s){case"top":x=y,t.textBaseline="top";break;case"bottom":x=y+b-w+l,t.textBaseline="bottom";break;default:x=y+b/2-w/2+l/2,t.textBaseline="middle"}t.globalAlpha*=i,t.fillStyle=a,r.forEach(((e,i)=>{let s=x+i*l,h=function(t,e,r){return e.reduce(((e,n)=>(t.font=j7(r,n),e+t.measureText(n.text).width)),0)}(t,e,n),f=v;switch(o){case"left":case"justify":f=v;break;case"right":f=v+m-h;break;case"center":f=v+(m-h)/2}if(c&&(t.fillStyle=c,T7(t,f-4,s-u/2-4,h+8,u+8,4,!0,!1),t.fillStyle=a),"justify"===o&&i<r.length-1&&e.length>1){let r=m-h,i=e.length-1,a=r/i;e.forEach(((e,r)=>{t.font=j7(n,e),t.fillText(e.text,f,s),f+=t.measureText(e.text).width+(r<i?a:0)}))}else e.forEach((e=>{t.font=j7(n,e),t.fillText(e.text,f,s),f+=t.measureText(e.text).width}))})),t.restore()}function D7(t,e,r,n){let i="";for(let n=0;n<e.text.length;n++){let a=i+e.text[n];if(t.measureText(a).width>r)break;i=a}return{...e,text:i+("ellipsis"===n?"…":"")}}function z7(t,e,r={x:0,y:0},n=0,i={x:1,y:1}){return t-=r.x,e-=r.y,{x:(t*Math.cos(-n)-e*Math.sin(-n)+r.x)/i.x,y:(t*Math.sin(-n)+e*Math.cos(-n)+r.y)/i.y}}function F7(t,e,r={x:0,y:0},n=0,i={x:1,y:1}){return t-=r.x,e-=r.y,{x:(t*Math.cos(n)-e*Math.sin(n)+r.x)*i.x,y:(t*Math.sin(n)+e*Math.cos(n)+r.y)*i.y}}function N7(t){var e=t.element,r=t.fillStyle,n=e.style;if(r)if("string"==typeof r)n.backgroundColor=r;else switch(r.type){case"pattern":if(n.backgroundImage="url("+r.image+")",n.backgroundColor="transparent",r.fitPattern?n.backgroundSize="100% 100%":r.width||r.height?n.backgroundSize=`${r.width?r.width+"px":"auto"} ${r.height?r.height+"px":"auto"}`:n.backgroundSize="contain",r.fitPattern)n.backgroundRepeat="no-repeat";else{const{offsetX:t,offsetY:e,noRepeat:i,align:a,color:o}=r;if(i&&(n.backgroundRepeat="no-repeat"),o&&(n.backgroundColor=o),a)switch(a){case"center":n.backgroundPosition="center center";break;case"left-top":n.backgroundPosition="left top";break;case"left-bottom":n.backgroundPosition="left bottom";break;case"right-top":n.backgroundPosition="right top";break;case"right-bottom":n.backgroundPosition="right bottom";break;case"left":n.backgroundPosition="left center";break;case"right":n.backgroundPosition="right center";break;case"top":n.backgroundPosition="center top";break;case"bottom":n.backgroundPosition="center bottom"}else t||e?n.backgroundPosition=`${Number(t)||0}px ${Number(e)||0}px`:delete n.backgroundPosition}break;case"gradient":n.background=function(t,e){var r=e.colorStops,n=e.gradientType;if(r instanceof Array&&r.length>0)switch(n){case"radial":return"radial-gradient(farthest-corner at "+function(t,e){var{width:r,height:n}=t.bounds;switch(e){case"center":return[r/2,n/2];case"left-top":return[0,0];case"right-top":return[r,0];case"left-bottom":return[0,n];default:return[r,n]}}(t,e.center||"center").map((t=>t+"px")).join(" ")+","+r.map((t=>`${t.color} ${100*t.position}%`)).join(",")+")";case"linear":return"linear-gradient("+(180*(e.rotation||0)/3.141592653589793+90+"deg")+", "+r.map((t=>`${t.color} ${100*t.position}%`)).join(",")+")"}return""}(t,r)}else n.background="transparent"}E7="undefined"==typeof document?function(t,e){return new Canvas(t,e)}:function(t,e){var r=document.createElement("canvas");return r.width=t,r.height=e,r};const B7={x:1,y:1},U7={x:0,y:0},Y7={boxSizing:"border-box",margin:"0px",position:"absolute",outline:"none"};function G7(t){var{id:e,scale:r=B7,translate:n=U7,bold:i,italic:a,fontFamily:o="",textAlign:s,textBaseline:c,textOverflow:u,paddingTop:l,paddingBottom:h,paddingLeft:f,paddingRight:d,fontSize:p=J8.FONT_SIZE,lineWidth:g=0,lineDash:v}=t.state;h||=0,l||=0,f||=0,d||=0;var y=t.state.class;t.text;var{strokeStyle:m,fillStyle:b,rotation:x=0,fontColor:w,hidden:A}=t,{left:_,top:k,width:E,height:S}=t.bounds,M=t.element;M.hidden=A,e&&(M.id=e),y&&(M.className=y),Object.assign(M.style,Y7,{fontFamily:o,fontSize:p+"px",left:_+"px",top:k+"px",width:E+"px",height:S+"px",paddingTop:l+"px",paddingRight:d+"px",paddingBottom:h+"px",paddingLeft:f+"px",border:g+"px",borderColor:m,borderStyle:g>0?v||J8.LINE_DASH:"",color:w,fontWeight:i?"bold":"",fontStyle:a?"italic":"",textAlign:"end"==s?"right":"start"==s?"left":s,verticalAlign:c}),N7(t),function(t){if(t.isShadowable()&&t.state.shadow){var e=t.element,{left:r=0,top:n=0,blurSize:i=0,color:a="transparent"}=t.state.shadow;e.style.boxShadow=`${r}px ${n}px ${i}px ${a}`}}(t);var T=t.delta(),P=(r&&r.x||1)*T.sx,O=(r&&r.y||1)*T.sy,I=(x||0)+T.theta,C=T.tx||0,R=T.ty||0;["-webkit-","-moz-","-ms-","-o-",""].forEach((t=>{M.style[t+"transform"]=`rotate(${I}rad) translate(${C}px, ${R}px) scale(${P}, ${O}) perspective(1px)`}))}var W7,H7=[];function q7(){W7=null;var t=performance.now(),e=(H7=H7.filter((t=>X7(t)))).reduce(((e,r)=>{let n=t-r.updatedAt;return n>=r.retention?e.kills.push(r):e.next=0==e.next?r.retention-n:Math.min(e.next,r.retention-n),e}),{next:0,kills:[]});e.kills.forEach((t=>{let e=H7.indexOf(t);-1!=e?(H7.splice(e,1),t.removeSelf(!0)):L8("Should not be here. Maybe reentrance problem.")})),e.next>0&&(W7=setTimeout(V7,Math.max(e.next,500)))}function X7(t){return!t.disposed&&t.retention>0&&!t.isTemplate()&&t.app&&t.app.isViewMode}var V7=d8((function(){requestAnimationFrame(q7)}),500);var Q7=new class{add(t){X7(t)&&-1==H7.indexOf(t)&&(H7.push(t),t.touch()),this.touch()}remove(t){var e=H7.indexOf(t);e>0&&H7.splice(e,1),this.touch()}touch(){null!==W7&&(clearTimeout(W7),W7=null),V7()}get length(){return H7.length}};const K7=function(t){return t};function J7(t){var e=t.indexOf("||"),r="",n="";-1!=e&&(r=t,n=t.substring(e+2,t.length-1).trim(),t=t.replace(t.substring(e,t.length-1),"").trim());var i=t.substr(2,t.length-3).trim().replace(/\[(\w+)\]/g,".$1").replace(/^\./,"").split(".").filter((t=>!!t.trim())),a=i.slice(1);return{defaultValue:n,match:t,originText:r||t,target:i[0],accessor:a.length>0?function(t){return a.reduce(((t,e)=>t?t[e]:void 0),t)}:K7}}function Z7(t,e,r){if(t){var n=r||_8,i=String(t),a=(i.match(/#{[^}]*}/gi)||[]).map((t=>J7(t))),o=(i.match(/\${[^}]*}/gi)||[]).map((t=>J7(t)));if(0!=a.length||0!=o.length)return function(){var t=i;return a.forEach((r=>{let i=n(r.accessor(e.getState(r.target)));t=t.replace(r.originText,void 0===i?r.defaultValue||"":i)})),o.forEach((r=>{let i=e.root.findById(r.target),a=n(r.accessor(i&&i.data));t=t.replace(r.originText,void 0===a?r.defaultValue||"":a)})),t}}}const $7=210*Math.PI/180,t9=150*Math.PI/180;var e9={"data-spread":function(t,e,r){if(t.app.isEditMode){var n=!1;return t.mappings&&t.mappings.forEach((r=>{let i=t.root.findAll(r.target,t);i&&(e.lineWidth=2,i.forEach((r=>{let i=t.center,a=r.center;i=t.transcoordS2C(i.x,i.y,t.rootModel),a=r.transcoordS2C(a.x,a.y,r.rootModel),e.beginPath();const o=e.createLinearGradient(i.x,i.y,a.x,a.y);["#FFA50033","#FFA500"].forEach(((t,e)=>o.addColorStop(e,t))),e.strokeStyle=o,e.fillStyle=o,function(t,e,r,n=10){var i=r.x-e.x,a=r.y-e.y,o=Math.atan2(a,i),s=r.x+n*Math.cos(o+$7),c=r.y+n*Math.sin(o+$7),u=r.x+n*Math.cos(o+t9),l=r.y+n*Math.sin(o+t9);t.beginPath(),t.moveTo(e.x,e.y),t.lineTo(r.x,r.y),t.moveTo(r.x,r.y),t.lineTo(s,c),t.moveTo(r.x,r.y),t.lineTo(u,l),t.stroke()}(e,i,a),n=!0})))})),n}},"bouncing-arrow":function(t,e,r){let{left:n,top:i,width:a}=t.bounds,o=t.state.id,{x:s,y:c}=t.transcoordS2C(n+a/2,i,t.rootModel);const u=2*function(t){const e=100*(1-t)%10;return e<5?e:10-e}(r||0);if(s=Math.max(s,20),c=Math.max(c,20),e.beginPath(),e.moveTo(s-10,c-16+u),e.lineTo(s+10,c-16+u),e.lineTo(s+10,c-8+u),e.lineTo(s+16,c-8+u),e.lineTo(s,c+u),e.lineTo(s-16,c-8+u),e.lineTo(s-10,c-8+u),e.lineTo(s-10,c-16+u),e.lineTo(s-10,c-16+u),e.fillStyle="#FF0000",e.fill(),o){e.beginPath(),e.font="12px Arial";let t=e.measureText(o);e.fillStyle="#FF0000",e.roundRect(s-t.actualBoundingBoxLeft-3+20,c-t.actualBoundingBoxAscent-3-6+u,t.actualBoundingBoxLeft+t.actualBoundingBoxRight+6,t.actualBoundingBoxAscent+t.actualBoundingBoxDescent+6,3),e.fill(),e.fillStyle="white",e.fillText(o,s+20,c-6+u)}return!0},decotag:function(t,e,r){const n=t.decotag;if(n){let{left:r,top:i}=t.bounds,{x:a,y:o}=t.transcoordS2C(r,i,t.rootModel);a=Math.max(a+3,5),o=Math.max(o-8,15),e.font="12px Arial";let s=e.measureText(n);return e.beginPath(),e.fillStyle="#FF0000",e.roundRect(a-s.actualBoundingBoxLeft-3,o-s.actualBoundingBoxAscent-3,s.actualBoundingBoxLeft+s.actualBoundingBoxRight+6,s.actualBoundingBoxAscent+s.actualBoundingBoxDescent+6,3),e.fill(),e.beginPath(),e.fillStyle="white",e.fillText(n,a,o),!0}return!1},anchors:function(t,e,r){if(t.app.isEditMode){var n=!1;return t.anchors&&t.anchors.forEach((r=>{const{name:i,position:a}=r;var{x:o,y:s}=a||{};if(!i)return;var{x:o,y:s}=t.transcoordS2C(o,s,t.rootModel);o+=4,s+=4,e.font="12px Arial";let c=e.measureText(i);e.fillStyle="#FF0000",T7(e,o,s,c.width+6,16,3,!0,!1),e.fillStyle="white",e.fillText(i,o+3,s+13),n=!0})),n}},link:function(t,e,r){var n=!1;if(!t.isLine())return;const{fromEnd:i,toEnd:a}=t;return[i,a].filter(Boolean).forEach((t=>{const{component:r,anchor:i}=t;if(!i)return;const{name:a,position:o}=i||{};if(!a||!o)return;var{x:s,y:c}=o||{},{x:s,y:c}=r.transcoordS2C(s,c,r.rootModel);s+=8,c+=20,e.font="12px Arial";let u=e.measureText(a);e.fillStyle="#FF0000",T7(e,s-u.actualBoundingBoxLeft-4,c-u.actualBoundingBoxAscent-4,u.actualBoundingBoxLeft+u.actualBoundingBoxRight+8,u.actualBoundingBoxAscent+u.actualBoundingBoxDescent+8,4,!0,!1),e.fillStyle="white",e.fillText(a,s,c),n=!0})),n}};function r9(t){return e9[t]}var n9={};const i9={mutable:!1,resizable:!0,rotatable:!0,properties:[],"value-property":"text"},a9=[],o9={theta:0,tx:0,ty:0,sx:1,sy:1,fade:0};var s9=0;const c9=new FinalizationRegistry((()=>{s9--}));class u9{static get nature(){return i9}static register(t,e){if(!e)return n9[t];n9[t]=e}static get residents(){return s9}static get residentsCount(){return s9}static registerDecorator(t,e){!function(t,e){e9[t]=e}(t,e)}constructor(t,e){this._app=e,this._model=t||{},this._state={},this._delta=Z6(o9),e&&this.animation?.config&&(1==this.animation.config.autoplay||(this.animation.config.autoplay??1))&&(this.animation.started=!0),this.clearCache(),Q7.add(this),s9++,c9.register(this,s9)}created(){}added(t){}removed(t){}async ready(){if(this.state.persistent){const{isViewMode:t,dataStorage:e}=this.app;t&&(this.data=await e.load(this))}}touch(){this.updatedAt=performance.now()}clearCache(...t){!function(t,...e){0==e.length?t.__cache__={}:e.forEach((e=>delete t.__cache__[e]))}(this,...t)}removeSelf(t){t?this.dispose():this.parent&&this.parent.removeComponent(this)}dispose(){this._animation&&(this._animation.dispose(),delete this._animation),this.disposeMappings(),this.parent&&this.parent.removeComponent(this),delete this._text_substitutor,delete this._value_substitutor,this._disposed=!0,this.retention&&Q7.touch(),this.clearCache(),delete this._app}get nature(){return this.constructor.nature}get disposed(){return!!this._disposed}isLayer(){return!1}isGroup(){return!1}isContainer(){return!1}isLine(){return!1}isRoot(){return!1}isRootModel(){return!1}is3dish(){return!1}isTemplate(){return!!this.get("templatePrefix")}isHTMLElement(){return!1}isConnectable(){return!1}isIdentifiable(){return!0}replaceRefids(t){}get retention(){return Number(this.get("retention"))||0}get hasTextProperty(){return!0}get app(){return!this._app&&this.parent&&(this._app=this.parent.app),this._app}get model(){return this._model}get state(){return Object.assign({},this._model,this._state)}get hierarchy(){var t=Z6(this._model);return this.volatile.forEach((e=>{delete t[e]})),t}get volatile(){return a9}get textHidden(){return!!this._textHidden}set textHidden(t){this._textHidden=!!t,this.invalidate()}get(t){return this._model[t]}set(t,e){if("string"==typeof t)return this.set({[t]:e});var r={},n={},i=!1,a=(t=Z6(t),this);return Object.getOwnPropertyNames(t).forEach((function(e){let o=a._model[e],s=t[e];W4(o,s)||(n[e]=o,r[e]=s,a._model[e]=s,delete a._state[e],i=!0)})),i&&(this.clearCache(),r.hasOwnProperty("text")&&delete this._text_substitutor,r.hasOwnProperty("retention")&&Q7.add(this),r.hasOwnProperty("fillStyle")&&this.onchangeFill(r,n),r.hasOwnProperty("mappings")&&this.onchangeMappings(r,n),r.hasOwnProperty("data")&&this.onchangeData(r,n),this.onchange&&this.onchange(r,n),this.trigger("change",r,n)),this}getState(t){return this._state.hasOwnProperty(t)?this._state[t]:this.get(t)}setState(t,e){if("string"==typeof t)return this.setState({[t]:e});var r={},n={},i=!1,a=(t=Z6(t),this),o=this.getState("sensitive");return Object.getOwnPropertyNames(t).forEach((function(e){let s=a.getState(e),c=t[e];!o&&W4(s,c)||(n[e]=s,r[e]=c,a._state[e]=c,i=!0)})),i&&(this.clearCache(),r.hasOwnProperty("text")&&delete this._text_substitutor,r.hasOwnProperty("fillStyle")&&this.onchangeFill(r,n),r.hasOwnProperty("data")&&this.onchangeData(r,n),this.onchange&&this.onchange(r,n),this.trigger("change",r,n)),this}get root(){return this.isRoot()?this:this.parent&&this.parent.root}get rootModel(){return this.isRootModel()?this:this.parent&&this.parent.rootModel}get parent(){return this._parent}set parent(t){this._parent=t}get anchors(){return this.nature.anchors||[]}findAnchor(t){return this.anchors.find((e=>e.name===t))}isDescendible(t){return!0}getContext(){return this._parent.getContext()}get center(){var t=this.bounds;return{x:t.left+t.width/2,y:t.top+t.height/2}}set center(t){if(t&&!isNaN(t.x)&&!isNaN(t.y)){var e=this.center;if(Math.round(100*t.x)/100!=Math.round(100*e.x)/100||Math.round(100*t.y)/100!=Math.round(100*e.y)/100){var r=t.x-e.x,n=t.y-e.y;this.path=this.path.map((t=>({x:t.x+r,y:t.y+n})))}}}get location(){const{x:t,y:e}=this.center;return{x:t,y:e,z:this.state.zPos}}set location(t){const{x:e,y:r,z:n}=t||{};this.center={x:e,y:r},isNaN(n)||this.setState("zPos",Number(n))}get rotate(){const{rotationX:t,rotationY:e,rotation:r}=this.state;return{x:t,y:e,z:-r}}set rotate(t){const{x:e,y:r,z:n}=t;this.setState({rotationX:e,rotationY:r,rotation:-n})}get dimension(){const{width:t,height:e}=this.bounds,{depth:r}=this.state;return{width:t,height:e,depth:r}}set dimension(t){const{width:e,height:r,depth:n}=t,{top:i,left:a}=this.bounds;this.bounds={top:i,left:a,width:e,height:r},this.setState("depth",n)}get bounds(){var t,e,r,n,i=this.path;t=e=i[0].x,r=n=i[0].y;for(let a=1;a<i.length;a++){let o=i[a];o.x<t?t=o.x:o.x>e&&(e=o.x),o.y<r?r=o.y:o.y>n&&(n=o.y)}return{left:t,top:r,width:e-t,height:n-r}}set bounds(t){var e=this.bounds;if(Math.round(100*t.width)/100!=Math.round(100*e.width)/100||Math.round(100*t.height)/100!=Math.round(100*e.height)/100||Math.round(100*t.left)/100!=Math.round(100*e.left)/100||Math.round(100*t.top)/100!=Math.round(100*e.top)/100){var r=0==e.width?1:t.width/e.width,n=0==e.height?1:t.height/e.height;this.path=this.path.map((i=>({x:t.left+(i.x-e.left)*r,y:t.top+(i.y-e.top)*n})))}}get path(){return L8("이 컴포넌트에 get path 가 구현되어있지 않음.",this),[]}set path(t){L8("이 컴포넌트에 get path 가 구현되어있지 않음.",this)}get drawPath(){return this.path}outline(t){return function(t,e){var r=t.path.slice();if(r&&r.length){var n=1,i=[];if(t.isLine()||r.push(r[0]),e<=0)return t.transcoordS2T(r[0].x,r[0].y);if(e>=1)return t.transcoordS2T(r[r.length-1].x,r[r.length-1].y);for(;r[n];){let t=r[n-1],e=r[n],a=e.x-t.x,o=e.y-t.y;i.push(Math.sqrt(a*a+o*o)),n++}var a=i.reduce((function(t,e){return t+e}),0);n=0;var o=0;do{o+=i[n++]}while(o/a<e);e=(e-(o-=i[--n])/a)*(a/i[n]);var s=r[n%r.length],c=r[(n+1)%r.length],u=s.x+Math.round((c.x-s.x)*e),l=s.y+Math.round((c.y-s.y)*e);return t.transcoordS2T(u,l)}L8("path should not be empty")}(this,t||0)}get strokeStyle(){return this.get("strokeStyle")}set strokeStyle(t){this.set("strokeStyle",t)}get fillStyle(){return this.getState("fillStyle")}set fillStyle(t){this.setState("fillStyle",t)}get fontColor(){return this.get("fontColor")}set fontColor(t){this.set("fontColor",String(_8(t)))}get rotation(){return this.getState("rotation")}set rotation(t){this.setState("rotation",Number(_8(t)))}contains(t,e){return!1}get mutable(){return this.nature.mutable}get resizable(){return this.nature.resizable&&!this.stuck}adjustResize(t,e,r){if(r){let e=this.bounds,r=e.height/e.width,n=t.width-e.width,i=t.height-e.height;n*r>i?i=n*r:n=i/r;let a=t.left-e.left,o=t.top-e.top;return 0!=a&&0!=o?(o=-i,a=-n):0!=a?a=-n:0!=o&&(o=-i),{left:e.left+a,top:e.top+o,width:e.width+n,height:e.height+i}}return t}get rotatable(){return this.nature.rotatable&&!this.stuck}adjustRotation(t,e){if(e||this.app.rotateStepForced){let e=this.app.rotateStep;return Math.floor((t+e/2)/e)*e}return t}get capturable(){return!1!==this.get("capturable")&&(this.app.isEditMode||!this.hidden)}get stuck(){return!!(this.parent&&this.parent.layout.isStuck(this)||this.get("locked"))}findFirst(t,...e){if(t(this,...e))return this}findAll(t,...e){return"string"==typeof t?o7(t,this,e[0]||this):"function"==typeof t&&t(this,...e)?[this]:void 0}capture(t,e,r){if(!this.capturable||r?.(this))return!1;var n=this.transcoordP2S(t,e);return this.contains(n.x,n.y)?this:void 0}prepare(t,e){t(this)}prepareIf(t){t&&this.prepare&&this.prepare((t=>{this.invalidate()}),(t=>{L8(t)}))}get decotag(){const{id:t,tag:e}=this.state;return(t?`#${t}`:"")+(e?`@${e}`:"")}get decorators(){return["decotag","data-spread"]}get reactionDecorators(){return["bouncing-arrow"]}get hidden(){return this.getState("hidden")||!this.data&&0!==this.data&&this.getState("ndns")||this.isTemplate()}set hidden(t){this.setState("hidden",t)}draw(t){t.save(),this.__proto__.hasOwnProperty("_pre_draw")?this._pre_draw(t):this.prerender(t),this.__proto__.hasOwnProperty("_draw")?this._draw(t):this.render(t),this.__proto__.hasOwnProperty("_post_draw")?this._post_draw(t):this.postrender(t),t.restore()}delta(t,e){if(void 0===e)return t?this._delta[t]:this._delta;this._delta[t]=e}prerender(t){var e=this.rotatePoint,{scale:r,rotation:n,shadow:i,alpha:a}=this.state,o=(r&&r.x||1)*this._delta.sx,s=(r&&r.y||1)*this._delta.sy,c=(n||0)+this._delta.theta,{tx:u=0,ty:l=0}=this._delta,h=(a||1)-this._delta.fade;(u||l)&&t.translate(u,l),(1!=o||1!=s||c)&&(t.translate(e.x,e.y),1==o&&1==s||t.scale(o,s),c&&t.rotate(c),t.translate(-e.x,-e.y)),h&&(t.globalAlpha=h),i&&$8(t,i,this),this.app.isEditMode&&this.hidden&&(t.globalAlpha*=.5)}render(t){}postrender(t){this.drawText(t)}drawText(t){!this.textHidden&&this.text&&this.hasTextProperty&&L7(t,this.textBounds,this.textLines(t),this.state)}drawStroke(t,e){M7(t,e?{...this.state,...e}:this.state)}drawFill(t,e){this.fillStyle&&"transparent"!=this.fillStyle&&(S7(t,this.bounds,this.center,e?{...this.state,...e}:this.state,this),function(t){t.shadowColor="transparent"}(t))}animate(t){return this._animate&&this._animate.stop(),this._animate=t6(t),this._animate}move({x:t,y:e}){var r=this.path,n=t,i=e;this.path=r.map((t=>({x:t.x+n,y:t.y+i})))}symmetryX(t){"number"!=typeof t&&(t=this.center.x);var{rotation:e}=this.state,r=this.fillStyle;if(this.set("rotation",2*Math.PI-e),r&&"gradient"===r.type&&"linear"===r.gradientType){var n=Z6(r);n.rotation=(Math.PI-parseFloat(r.rotation||0))%(2*Math.PI),this.set("fillStyle",n)}this.path=this.path.map((e=>({x:2*t-e.x,y:e.y})))}symmetryY(t){this.symmetryX(),this.set("rotation",(Math.PI+this.model.rotation)%(2*Math.PI)),t&&this.move({x:0,y:2*(t-this.center.y)},!1)}get animation(){if(this.app.isViewMode&&!this.isTemplate()){if(!this._animation){var t=this.state.animation;t&&t.oncreate&&(this._animation=(e=this,r=t.oncreate,(n=$5[r.type])?new n(e,r):null))}var e,r,n;return this._animation}}effect(t,e){return function(t,e,r){var n=t7[r.type];n&&n(t,e,r)}(this,t,e)}set started(t){this.animation&&(this.animation.started=t)}invalidate(){this.parent&&this.parent.invalidate()}get font(){return R7(this.model)}get lineHeight(){var t=this.get("lineHeight");return t||1.2*this.fontSize}defaultTextSubstitutor(){var t=this.getState("text");return null==t?"":String(t)}get textSubstitutor(){return this._text_substitutor||(this._text_substitutor=Z7(this.getState("text"),this)||this.defaultTextSubstitutor),this._text_substitutor}get text(){var t=this.get("textFormat");return t?function(t,e){if(!t||isNaN(+e))return e;var r,n,i,a,o,s,c,u,l,h=t.length,f=t.search(/[0-9\-\+#]/),d=f>0?t.substring(0,f):"",p=t.split("").reverse().join(""),g=p.search(/[0-9\-\+#]/),v=h-g,y=t.substring(v,v+1),m=v+("."===y||","===y?1:0),b=g>0?t.substring(m,h):"";if(r=(e="-"===(t=t.substring(f,m)).charAt(0)?-e:+e)<0?e=-e:0,i=(n=t.match(/[^\d\-\+#]/g))&&n[1]&&n[0]||",",t=t.split("."),e=+(e=e.toFixed(t[1]&&t[1].length))+"",o=t[1]&&t[1].lastIndexOf("0"),(!(c=e.split("."))[1]||c[1]&&c[1].length<=o)&&(e=(+e).toFixed(o+1)),u=t[0].split(i),t[0]=u.join(""),(a=t[0]&&t[0].indexOf("0"))>-1)for(;c[0].length<t[0].length-a;)c[0]="0"+c[0];else 0==+c[0]&&(c[0]="");if((e=e.split("."))[0]=c[0],s=u[1]&&u[u.length-1].length){for(p="",v=(l=e[0]).length%s,h=l.length,m=0;m<h;m++)p+=l.charAt(m),!((m-v+1)%s)&&m<h-s&&(p+=i);e[0]=p}return e[1]=t[1]&&e[1]?"."+e[1]:"","0"!==(n=e.join(""))&&""!==n||(r=!1),d+("+"==t[0].substring(0,1)?r?"-":"+":r?"-":"")+n+b}(t,this.textSubstitutor()):this.textSubstitutor()}set text(t){delete this._text_substitutor;var e=_8(t);this.setState("text",null==e?"":String(e))}textLines(t){const{textWrap:e,supportMarkdown:r}=this.state;return C7(t||this.getContext(),this.textBounds.width,this.font,this.text,e,r)}get textBounds(){var{paddingTop:t,paddingLeft:e,paddingRight:r,paddingBottom:n}=this.state;n||=0,t||=0,e||=0,r||=0;var{left:i,top:a,width:o,height:s}=this.bounds;return{left:i+e,top:a+t,width:Math.max(o-e-r,0),height:Math.max(s-t-n,0)}}get textRotation(){return 0}get rotatePoint(){return this.center}trim(){delete this._model[""],"chartjs"!==this._model.type&&delete this._model.chart}get value(){var t=this.nature["value-property"]||"text";return"value"==t?this.getState("value"):this[t]}set value(t){var e=this.nature["value-property"]||"text";"value"==e?this.setState("value",t):this[e]=t}get data(){return this.getState("data")}set data(t){this.setState("data",t),this.touch()}set tap(t){var e=this.model.event?.tap;if(e){const{cx:t,cy:r}=this.center;this.rootModel?._doEventAction(e,this,!0,new CustomEvent("click",{offsetX:t,offsetY:r}))}}get mappings(){return!this._mappings&&this.parent&&this.buildMappings(),this._mappings}serialize(...t){return JSON.stringify(this.hierarchy,...t)}get controls(){}closeScene(t){this.rootModel.closeScene(t)}}u9.union=function(t){var e,r,n,i;return t.forEach((t=>{void 0===e?(e=t.left,r=t.top,n=t.left+t.width,i=t.top+t.height):(e=Math.min(t.left,e),r=Math.min(t.top,r),n=Math.max(t.left+t.width,n),i=Math.max(t.top+t.height,i))})),{left:e,top:r,width:n-e,height:i-r}},u9.transcoordR=z7,u9.transcoordRR=F7,u9.createCanvas=E7,u9.memoize=F8,u9.mixin=j8,u9.drawText=L7,u9.font=R7,u9.textLines=C7,u9.drawStroke=M7,u9.drawFill=S7,u9.reposition=G7,u9.RetentionManager=Q7,u9.template=function(t,e,r){var n=Y5.imports._.templateSettings||Y5;r&&a5(t,e,r)&&(e=void 0),t=N5(t),e=h5({},e,n,S5);var i,a,o=h5({},e.imports,n.imports,S5),s=y4(o),c=function(t,e){return _5(e,(function(e){return t[e]}))}(o,s),u=0,l=e.interpolate||V5,h="__p += '",f=RegExp((e.escape||V5).source+"|"+l.source+"|"+(l===P5?X5:V5).source+"|"+(e.evaluate||V5).source+"|$","g"),d=K5.call(e,"sourceURL")?"//# sourceURL="+(e.sourceURL+"").replace(/\s/g," ")+"\n":"";t.replace(f,(function(e,r,n,o,s,c){return n||(n=o),h+=t.slice(u,c).replace(Q5,T5),r&&(i=!0,h+="' +\n__e("+r+") +\n'"),s&&(a=!0,h+="';\n"+s+";\n__p += '"),n&&(h+="' +\n((__t = ("+n+")) == null ? '' : __t) +\n'"),u=c+e.length,e})),h+="';\n";var p=K5.call(e,"variable")&&e.variable;if(p){if(q5.test(p))throw new Error("Invalid `variable` option passed into `_.template`")}else h="with (obj) {\n"+h+"\n}\n";h=(a?h.replace(G5,""):h).replace(W5,"$1").replace(H5,"$1;"),h="function("+(p||"obj")+") {\n"+(p?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(i?", __e = _.escape":"")+(a?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+h+"return __p\n}";var g=A5((function(){return Function(s,d+"return "+h).apply(void 0,c)}));if(g.source=h,w5(g))throw g;return g},u9.buildSubstitutor=Z7,Object.assign(u9.prototype,{drawEffect:function(t){const{effects:e}=this.state;(e||[]).forEach((e=>{this.effect(t,e)}))},prepareFill:function(t,e){var r=this.fillStyle;if(r&&"pattern"==r.type&&r.image){if("string"!=typeof r.image)return this._pattern_image_origin=this._pattern_image=r.image,void t(this);this._pattern_image=null,this._pattern_image_origin=new Image;var n=this;this._pattern_image_origin.onload=function(){if(!r.fitPattern&&!r.width&&!r.height)return n._pattern_image=n._pattern_image_origin,void t(this);let e=r.width||this.width,i=r.height||this.height;r.fitPattern&&(e=n.bounds.width,i=n.bounds.height);let a=E7(e,i);a.getContext("2d").drawImage(this,0,0,this.width,this.height,0,0,e,i),n._pattern_image=a,t(this)},this._pattern_image_origin.onerror=function(t){e(t)};try{"data"!==String(r.image).substring(0,4)?this._pattern_image_origin.crossOrigin="use-credentials":this._pattern_image_origin.crossOrigin=null,this._pattern_image_origin.src=this.app.url(r.image)}catch(t){e(t)}}else t(this)},prepareFillIf:function(t){t&&this.prepareFill((t=>{this.invalidate()}),(t=>{L8(t)}))},onchangeFill:function(t,e){var r=this.fillStyle;r&&"pattern"!==r.type?this._pattern_image&&(this._pattern_image=null,this._pattern_image_origin=null):r?.image&&this.prepareFillIf(r.image)},drawImage:function(t,e,r,n,i,a){e.complete?t.drawImage(e,r,n,i,a):e.addEventListener("load",(()=>{this.invalidate()}))},mutateBounds:function(t,e){var r=this.bounds,n=this.rotatePoint,i=this.get("rotation"),a=this.get("scale");if(t){var o=t.call(e,r);o&&(r=o)}var{left:s,top:c,width:u,height:l}=r,h=[{x:s,y:c},{x:s+u,y:c+l}],f=(h=h.map((t=>F7(t.x,t.y,n,i,a))))[0],d=h[1];n={x:(f.x+d.x)/2,y:(f.y+d.y)/2},f=(h=h.map((t=>z7(t.x,t.y,n,i,a))))[0],d=h[1],this.bounds={left:f.x,top:f.y,width:d.x-f.x,height:d.y-f.y}},mutatePath:function(t,e,r){var n=this.path,i=this.rotatePoint;this.get("rotation"),this.get("scale"),t&&(n=t.call(r,n));var a=n.map((t=>this.transcoordS2P(t.x,t.y)));e&&(n=e.call(r,a))&&(a=n);var o,s,c,u,l={x:0,y:0};o=s=(n=a.map((t=>this.transcoordP2S(t.x,t.y,l))))[0].x,c=u=n[0].y;for(let t=1;t<n.length;t++){let e=n[t];e.x<o?o=e.x:e.x>s&&(s=e.x),e.y<c?c=e.y:e.y>u&&(u=e.y)}i={x:(o+s)/2,y:(c+u)/2},i=this.transcoordS2P(i.x,i.y,l),this.path=a.map((t=>this.transcoordP2S(t.x,t.y,i)))},access:function(t){if(t){var e=String(t),r=(e.match(/#{(\S*)}/)||[]).map((t=>J7(t)))[0];if(r)return r.accessor(this.getState(r.target));var n=(e.match(/\${[^}]*}/)||[]).map((t=>J7(t)))[0];if(n){let t=this.root.findById(n.target);return n.accessor(this.getState(t))}return t}},substitute:function(t,e){if(t){var r=String(t),n=e||_8,i=(r.match(/#{(\S*)}/gi)||[]).map((t=>J7(t))),a=(r.match(/\${[^}]*}/gi)||[]).map((t=>J7(t)));if(0==i.length&&0==a.length)return r;var o=r;return i.forEach((t=>{let e=n(t.accessor(this.getState(t.target)));o=o.replace(t.match,void 0===e?"":e)})),a.forEach((t=>{let e=this.root.findById(t.target),r=n(t.accessor(e&&e.data));o=o.replace(t.match,void 0===r?"":r)})),o}},onchangeMappings:function(t,e){this.disposeMappings(),k7.call(this)},onchangeData:function(t,e){this.state.persistent&&this.app?.isViewMode&&this.app?.dataStorage.save(this,t.data),k7.call(this,[!0])},buildMappings:function(){if(this._model.mappings)return!this._model.mappings instanceof Array?(L8("Mappings model is invalid (should be a Array) ..",this._model.mappings),void(this._mappings=[])):void(this._mappings=(this._model.mappings||[]).filter((t=>t.rule&&t.target)).map((t=>new A7(t,this))));this._mappings=[]},executeMappings:k7,disposeMappings:function(){this._mappings&&this._mappings.forEach((t=>t.dispose())),delete this._mappings},ondropfile:function(t,e){for(let r=0;r<t.length;r++)if(t[r].type.startsWith("image/"))return void this.set("fillStyle",{type:"pattern",image:e[r],fitPattern:!0})},transcoordS2P:function(t,e,r){if(!this.parent)return{x:t,y:e};var{rotation:n=0,scale:i={x:1,y:1}}=this.state;if(this.isLayer()){let r=this.state.translate,a=F7(t,e,void 0,n+this._delta.theta,i);return r&&(a.x+=r.x,a.y+=r.y),a}r=r||this.rotatePoint;const{theta:a=0,tx:o=0,ty:s=0,sx:c=1,sy:u=1}=this._delta||{},l=F7(t+o,e+s,r={x:r.x+o,y:r.y+s},n+a,i={x:i.x*c,y:i.y*u});return{x:l.x-(r.x*i.x-r.x),y:l.y-(r.y*i.y-r.y)}},transcoordP2S:function(t,e,r){if(!this.parent)return{x:t,y:e};var{rotation:n=0,scale:i={x:1,y:1}}=this.state;if(this.isLayer()){let r=this.state.translate,a=z7(t,e,r,n,i);return r&&(a.x-=r.x/(i?i.x:1),a.y-=r.y/(i?i.y:1)),a}var a=z7(t,e,r=r||this.rotatePoint,n,i);return{x:a.x+(r.x-r.x/i.x),y:a.y+(r.y-r.y/i.y)}},transcoordS2T:function(t,e,r){r=r||this.rootModel;var n=[];for(let t=this.parent;t&&t!==r;t=t.parent)n.push(t);var i=this.transcoordS2P(t,e);return n.forEach((t=>{let{scale:e}=t.model,r=t.bounds;if(e){let n=t.rotatePoint;i.x+=(n.x-r.left)*e.x,i.y+=(n.y-r.top)*e.y}else i.x+=r.left,i.y+=r.top;i=t.transcoordS2P(i.x,i.y)})),i},transcoordT2P:function(t,e,r){r=r||this.rootModel;var n=[];for(let t=this.parent;t&&t!==r;t=t.parent)n.splice(0,0,t);var i={x:t,y:e};return n.forEach((t=>{let{scale:e}=t.model;i=t.transcoordP2S(i.x,i.y);let r=t.bounds;if(e){let n=t.rotatePoint;i.x-=(n.x-r.left)/e.x,i.y-=(n.y-r.top)/e.y}else i.x-=r.left,i.y-=r.top})),i},transcoordT2S:function(t,e,r){var n=this.transcoordT2P(t,e,r);return this.transcoordP2S(n.x,n.y)},transcoordS2TR:function(t,e,r){r=r||this.rootModel;var n=this.transcoordS2T(t,e,r);return F7(n.x,n.y,void 0,(r.get("rotation")||0)+r._delta.theta)},transcoordS2O:function(t,e,r){var n=this.rootModel,i=this.transcoordS2T(t,e,n);return r.transcoordT2S(i.x,i.y,n)},transcoordC2S:function(t,e,r){if(!r)for(r=this;r&&!r.isLayer();)r=r.parent;var{translate:n={x:0,y:0},scale:i={x:1,y:1},rotation:a=0}=r.model,o=z7(t,e,n,a,i);return n&&(o.x-=n.x/(i?i.x:1),o.y-=n.y/(i?i.y:1)),r===this?o:this.transcoordT2S(o.x,o.y,r)},transcoordS2C:function(t,e,r){if(!r)for(r=this;r&&!r.isLayer();)r=r.parent;if(r!==this)var n=this.transcoordS2T(t,e,r);else n={x:t,y:e};var{translate:i={x:0,y:0},rotation:a=0,scale:o={x:1,y:1}}=r.model;return n=F7(n.x,n.y,void 0,a+r._delta.theta,o),i&&(n.x+=i.x,n.y+=i.y),n},_pre_draw:u9.prototype.prerender,_draw:u9.prototype.render,_post_draw:u9.prototype.postrender}),["rotatePoint","font","lineHeight","retention"].forEach((t=>u9.memoize(u9.prototype,t,!1))),["bounds","center","textBounds"].forEach((t=>u9.memoize(u9.prototype,t,!0))),u9.mixin(u9.prototype,P8.withEvent);class l9 extends u9{set rotationX(t){this.setState("rotationX",t)}get rotationX(){return this.getState("rotationX")}set rotationY(t){this.setState("rotationY",t)}get rotationY(){return this.getState("rotationY")}set rotationZ(t){this.setState("rotation",t)}get rotationZ(){return this.getState("rotation")}set zPos(t){this.setState("zPos",t)}get zPos(){return this.getState("zPos")}set depth(t){this.setState("depth",t)}get depth(){return this.getState("depth")}postrender(t){this.drawFill(t),this.drawStroke(t),super.postrender(t)}render(t){var e=this.drawPath,{round:r=0}=this.state;if(!(e.length<=1)){t.beginPath();for(var n=0;n<e.length;n++){const c=e[(n-1+e.length)%e.length],u=e[(n+e.length)%e.length],l=e[(n+1)%e.length];if(c.x===u.x&&c.y===u.y)continue;var i=0!==(s=Math.sqrt((c.x-u.x)*(c.x-u.x)+(c.y-u.y)*(c.y-u.y)))?Math.atan2(c.x-u.x,c.y-u.y):0,a=Math.sin(i)*Math.min(r,s/2)+u.x,o=Math.cos(i)*Math.min(r,s/2)+u.y;const h=r>0||0!==s?{x:a,y:o}:u;var s;i=0!==(s=Math.sqrt((l.x-u.x)*(l.x-u.x)+(l.y-u.y)*(l.y-u.y)))?Math.atan2(l.x-u.x,l.y-u.y):0,a=Math.sin(i)*Math.min(r,s/2)+u.x,o=Math.cos(i)*Math.min(r,s/2)+u.y;const f=r>0||0!==s?{x:a,y:o}:u;0==n?t.moveTo(h.x,h.y):t.lineTo(h.x,h.y),r>0&&t.quadraticCurveTo(u.x,u.y,f.x,f.y)}t.closePath()}}}function h9(t,e,r){return Math.max(0,Math.min(t,Math.min(r,e)/2))}var f9=t=>{var e=class extends t{contains(t,e){var{left:r,top:n,width:i,height:a,lineWidth:o=0}=this.state,s=o/2;return t<Math.max(r+i,r)+s&&t>Math.min(r+i,r)-s&&e<Math.max(n+a,n)+s&&e>Math.min(n+a,n)-s}set path(t){var e=t[0],r=t[2];this.set({left:e.x,top:e.y,width:r.x-e.x,height:r.y-e.y})}get path(){var{left:t=0,top:e=0,width:r=0,height:n=0}=this.state;return[{x:t,y:e},{x:t+r,y:e},{x:t+r,y:e+n},{x:t,y:e+n}]}get anchors(){return function(t){var{left:e,top:r,width:n,height:i}=t.bounds,a=e+n/2,o=r+i/2;return[{name:"TOP",position:{x:a,y:r}},{name:"RIGHT",position:{x:e+n,y:o}},{name:"BOTTOM",position:{x:a,y:r+i}},{name:"LEFT",position:{x:e,y:o}}]}(this)}render(t){var{round:e=0}=this.model,{left:r,top:n,width:i,height:a}=this.bounds;t.translate(r,n),t.beginPath(),(e=h9(e,i,a))>0?t.roundRect(0,0,i,a,e):t.rect(0,0,i,a),t.translate(-r,-n)}};return F8(e.prototype,"path",!1),e};const d9={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"textarea",label:"front-side-template",name:"frontSideTemplate",property:{language:"html"}},{type:"textarea",label:"back-side-template",name:"backSideTemplate",property:{language:"html"}},{type:"textarea",label:"style",name:"style",property:{language:"css"}}],help:"scene/component/info-window"};const p9=20;function g9(t,e){var r=t.split(/\s+/),n=r.indexOf(e);return-1!=n?r.splice(n,1):r.splice(-1,0,e),r.join(" ")}class v9 extends(f9(l9)){static get image(){return v9._image||(v9._image=new Image,v9._image.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAMAAACahl6sAAAAY1BMVEVHcEwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADIAbxiAAAAIHRSTlMA+gPshCwwWFzYCeLRm7QRG6rLeDZI9JOJJDtjb1HAf1sAT80AAAQQSURBVHhe7MCBAAAAAMKw/KkzOMG2BAAAAKeu3lUohIEggO7jQi5qHqpgwML5/6+0F0y02z31FlvMMLKt86QMQ1ined2Evih1hFFjLfRWjgzDOGZ6JSiM00B9EuHALtQxJLiQBmqSBCeSUEuEGzs1BDjSaHxWOKK5Eyz/4SoMV/hp4+vtcPkdwZD/udwevNg7t1xXYRiKmkB7C+ENlPLq8fxHeX+RGjWQ1D45ldcIulBIvCvYJGBEadyTzxAcfY57NBjpLScOO/bzugcTHe7IMwiSLMcdHZhocMcMgTLjjgZM7F1bCJZ2v27ARGzYDwIk2Z+JYGJ/iiwQLMv+JAEThjkmRG64Q0Q+gIiIiIiIiIiIyFy0KRFt0bOJZAWSUigmkQaJaXhENiRnYBEpkZySRSRGcmIWEaQnYhHRSI5mESmQnIJFZIqQmGhiEYEbEnPjGlEGjYTogW/WUkOXENENSqZfEXmDiIiIiIiIiIiIiIiIiIiImq5ETIpRpBpjJCMeKy6Ri0ZS9MQjkmkkJs1YRDokp2MRyZGclkUkQnIiEQltaX3Lzb6yiGTpl2y/avqSAxGgelCOKI+Kc2isL0TUSsZ4EREREREREREREREREREREfnIQzXrNWSRTeNxnlOwIgueIr6AAyE+CpiqMEUK71IDO4E+LluEKYKnKcMUifEsTZgiJZ5lDVNkwJPcqzBFoPF/HplfxL/w6b4EPGv1h18Weya1TL8iIiIeiIiIiIiIiEjkPefxV+5YA9PPHylB+u5aqgZ39H+jKOxrqtu+pkzvr9YbzoZ6w2OFkzcrA3yE4WZlSSyFk54VoA/wR43+FaD+r9w32QdWvgvjp2ty2xq8qHPHmtyPFxfrK3hw1ejERlAlfR/Ame2OTow05d4rOLLSlHtDVhI0uRO01JeZ405op6zgNNXT+bIRfpIgn+AkU4pOxBscohojdCHu4RRzjC5EYwVHqRONDkSnEvK/CB3QSU32IRW3ZPnj9iEVoGCNTLVrh8ia1x+6wq8xvB5mz8pxu7oPwIn9lcR0AiuX1+1KX+BXqdvXzWsAC0NsGjzZsS/2Bd6yRA5RgIHkXNhSD3whASZ8rrB9mItuEAizac0fDlHxDMEwpQfD1tW4y3Hjfy5s9nOHH3uwWA+EqEJBWCjoTL/S5toBB/7hu6zer74NgqSP39zJU+qQX3ix763mHTqvIVRUVprCljlElRkEjBqNYevH8veBJ2xhiyhE8YctmhDFH7ZoQhR/2KIJUfxhiyRE8YctmhDFH7ZoQhR/2OIJUfxhC9Ppf/t1jgJACERRsHGyYRZB0Ujvf0xD8w6kP7y6RZmgf/oTFTtbbzJVxZWo2Nlqw6TVy5GowNl6ssm7v50obamfSxQAAAAAAAsKLM15fb3vpQAAAABJRU5ErkJggg=="),v9._image}static toggle(t,e,r,n){if(e){var i=t.root.findById(e);i?i._findInfoWindowByComponent(t)?v9.hide(t,e):v9.show(t,e,r,n):console.warn("InfoWindow Not Found.",e)}else console.warn("InfoWindow not defined.")}static hide(t,e){if(e){var r=t.root.findById(e);r?r._removeInfoWindow(t):console.warn("InfoWindow Not Found.",e)}}static show(t,e,r,n){if(e){var i=t.root.findById(e);if(i){if(!i._findInfoWindowByComponent(t)){var{frontSideTemplate:a="",backSideTemplate:o=""}=i.model,s=[a,o].filter((t=>String(t).trim()));if(s=s.map((t=>u9.template(function(t,e,r){return(e||r?['<div class="info-window-btns">',e?'<button class="closable">&#88</button>':"",r?'<button class="flipable">&#8652</button>':"","</div>"]:[]).concat(['<div class="info-window-content">',t,"</div>"]).join("")}(t,!r,2==s.length)))),0!=s.length){var c='\n.flip {\n backface-visibility: hidden;\n -moz-backface-visibility: hidden;\n -ms-backface-visibility: hidden;\n -o-backface-visibility: hidden;\n -webkit-backface-visibility: hidden;\n border-radius: 7px;\n height: auto;\n font: normal 14px helvetica, arial, san serif;\n position: absolute;\n opacity:.9;\n transform-origin: 50% 50% 0px;\n -moz-transform-origin: 50% 50% 0px;\n -ms-transform-origin: 50% 50% 0px;\n -o-transform-origin: 50% 50% 0px;\n -webkit-transform-origin: 50% 50% 0px;\n transition: all 2s;\n -moz-transition: all 2s;\n -ms-transition: all 2s;\n -o-transition: all 2s;\n -webkit-transition: all 2s;\n min-width: 100px;min-height:50px;\n background-color:#3e424e;\n box-shadow: 2px 3px 2px 0px rgba(0,0,0,0.15);\n}\n\n#side-1 {\n transform: rotateY( 0deg );\n -moz-transform: rotateY( 0deg );\n -ms-transform: rotateY( 0deg );\n -o-transform: rotateY( 0deg );\n -webkit-transform: rotateY( 0deg );\n}\n.flip:after{\n content:"";\n display:block;\n position: absolute;\n opacity:.9;\n width: 0;\n height: 0;\n}\n.flip.arrow-top:after{\n left:45%;\n top:-17px;\n border-left:10px solid transparent;\n border-bottom:18px solid #323b44;\n border-right:10px solid transparent;\n}\n.flip.arrow-right:after{\n left:100%;\n top:48%;\n border-top:10px solid transparent;\n border-left:18px solid #323b44;\n border-bottom:10px solid transparent;\n}\n.flip.arrow-bottom:after{\n left:45%;\n top:100%;\n border-left:10px solid transparent;\n border-top:18px solid #323b44;\n border-right:10px solid transparent;\n}\n.flip.arrow-left:after{\n right:100%;\n top:48%;\n border-top:10px solid transparent;\n border-right:18px solid #323b44;\n border-bottom:10px solid transparent;\n}\n\n#side-2 {\n transform: rotateY( 180deg );\n -moz-transform: rotateY( 180deg );\n -ms-transform: rotateY( 180deg );\n -o-transform: rotateY( 180deg );\n -webkit-transform: rotateY( 180deg );\n}\n\n.flip-side-1 {\n transform: rotateY( 0deg ) !important;\n -moz-transform: rotateY( 0deg ) !important;\n -ms-transform: rotateY( 0deg ) !important;\n -o-transform: rotateY( 0deg ) !important;\n -webkit-transform: rotateY( 0deg ) !important;\n}\n\n.flip-side-2 {\n transform: rotateY( 180deg ) !important;\n -moz-transform: rotateY( 180deg ) !important;\n -ms-transform: rotateY( 180deg ) !important;\n -o-transform: rotateY( 180deg ) !important;\n -webkit-transform: rotateY( 180deg ) !important;\n}\n\n.info-window-btns{\n position:absolute;\n top:-18px;\n right:5px;\n overflow:hidden;\n}\n.info-window-content{\n padding:10px;\n color:#efefef;\n font-size:13px;\n line-height:1.4;\n}\n.info-window-btns button{\n width:40px;height:40px;\n float:right;\n border:0;\n border-radius:50%;\n background-color:#2a7da1;\n margin-right:3px;\n text-align:center;\n cursor:pointer;\n font-size:35px;\n color:#fff;\n line-height:0;\n}\n.info-window-btns button:hover{\n background-color:#60bb23;\n}\n'+i.get("style"),{left:u,top:l}=t.bounds,{x:h,y:f}=n?t.rootModel.transcoordC2S(n.x,n.y):t.transcoordS2T(u,l);u=h,l=f;var d=document.createElement("span");d.style.position="absolute";var p=document.createElement("style");if(p.type="text/css",p.appendChild(document.createTextNode(c)),d.appendChild(p),s[0]){var g=document.createElement("div");g.id="side-1",g.className="flip",g.style.display="inline-block",g.innerHTML=s[0](t)}if(s[1]){var v=document.createElement("div");v.id="side-2",v.className="flip",v.style.display="inline-block",v.innerHTML=s[1](t)}Q8.forEach((function(t){d.addEventListener(t,(function(t){t.stopPropagation()}))})),K8.forEach((function(t){d.addEventListener(t,(function(t){t.stopPropagation()}))}));var y=t.root.model_layer.overlay;if(g&&d.appendChild(g),v&&d.appendChild(v),y.appendChild(d),i._addInfoWindow(t,d,p),g){let r=g.querySelector(".info-window-btns > .flipable");r&&r.addEventListener("click",(function(t){t.preventDefault(),v.className=g9(v.className,"flip-side-1"),g.className=g9(g.className,"flip-side-2")}),!1);let n=g.querySelector(".info-window-btns > .closable");n&&n.addEventListener("click",(function(r){r.preventDefault(),v9.hide(t,e)}),!1)}if(v){let r=v.querySelector(".info-window-btns > .flipable");r&&r.addEventListener("click",(function(t){t.preventDefault(),v.className=g9(v.className,"flip-side-1"),g.className=g9(g.className,"flip-side-2")}),!1);let n=v.querySelector(".info-window-btns > .closable");n&&n.addEventListener("click",(function(r){r.preventDefault(),v9.hide(t,e)}),!1)}var m=g.offsetWidth,b=g.offsetHeight;window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight;var x=t.rootModel.target.getBoundingClientRect(),w=[];g&&w.push(g),v&&w.push(v);var A={x:u,y:l},_=t.transcoordS2C(A.x,A.y);if(_.x+m/2+x.left<x.right&&_.x-m/2>x.left){if(b+p9<_.y)return d.style.marginLeft=A.x-m/2+"px",d.style.marginTop=A.y-b-p9+"px",void w.forEach((t=>t.className+=" arrow-bottom"));if(_=t.transcoordS2C(A.x,A.y+b+p9),x.bottom>_.y+x.top)return d.style.marginLeft=A.x-m/2+"px",d.style.marginTop=A.y+p9+"px",void w.forEach((t=>t.className+=" arrow-top"))}if((_=t.transcoordS2C(A.x,A.y)).x-(m+p9)>x.left)return d.style.marginLeft=A.x-m-p9+"px",d.style.marginTop=A.y-b/2+"px",void w.forEach((t=>t.className+=" arrow-right"));d.style.marginLeft=A.x+p9+"px",d.style.marginTop=A.y-b/2+"px",w.forEach((t=>t.className+=" arrow-left"))}}}else console.warn("InfoWindow Not Found.",e)}else console.warn("InfoWindow not defined.")}dispose(){this.infoWindows.map((t=>t.component)).forEach((t=>this._removeInfoWindow(t))),super.dispose()}get infoWindows(){return this._windows||(this._windows=[]),this._windows}_findInfoWindowByComponent(t){return this.infoWindows.find((e=>e.component===t))}_addInfoWindow(t,e,r){this._findInfoWindowByComponent(t)||this._windows.push({component:t,window:e,styleElement:r})}_removeInfoWindow(t){var e=this._findInfoWindowByComponent(t);if(!e)return;let r=e.window;r&&r.parentNode.removeChild(r);var n=this.infoWindows.lastIndexOf(e);this.infoWindows.splice(n,1)}render(t){var{left:e,top:r,width:n,height:i}=this.bounds;t.beginPath(),this.drawImage(t,v9.image,e,r,n,i)}get hasTextProperty(){return!1}get nature(){return d9}}u9.register("info-window",v9);var y9={};var m9={list:function(){return{...y9}},register:function(t,e){y9[t]=e},unregister:function(t){delete y9[t]},get:function(t){if(t){var e=y9[t];return e||L8("Layout Not Found - ",t),e}}},b9={reflow:function(t,e){this.drawables(t).filter((t=>t.isHTMLElement())).forEach((t=>t.reposition()))},capturables:function(t){return t.components},drawables:function(t){return t.app&&!t.app.isViewMode?t.components:t.components.filter((t=>!t.hidden))},isStuck:function(t){return!1},ABSOLUTE:!0};m9.register("html-absolute",b9);const x9=["run","goto","goto-playlist","goto-playlist","link-open","link-move","route-page","start-scenario","run-scenario","export-data","import-data"],w9="center",A9=new WeakMap;function _9(t){const e=t.root;var r=A9.get(e);if(!r)return;if(e===t){for(var n in r)_9(n[0]);return void A9.delete(e)}const i=r.findIndex((e=>e[0]===t));if(-1===i)return;const a=r[i][1];var o=a.div.parentNode;o&&o.removeChild(a.div);var s=a.scene;s.target=null,s.release&&s.release(),r.splice(i,1)}class k9{static hideAll(t){(A9.get(t)||[]).forEach((([t,e])=>_9(t)))}static hide(t){_9(t)}static show(t,e,r={}){var{data:n,location:i=w9,modal:a=!1,closable:o=!0,output:s=!0}=r,c=t.app.refProvider;c&&c.get(e,!0).then((e=>{var r=document.createElement("div"),c=r.style;if(a){var{width:u,height:l}=t.rootModel.bounds;c.position="fixed",c.zIndex=1,c.left=0,c.top=0,c.width=u+"px",c.height=l+"px",c.overflow="auto",c.backgroundColor="rgba(0,0,0,0.3)"}else c.position="absolute",c.display="inline-block";r.innerHTML=!a&&o?'\n<div class="popup-content">\n</div>\n<button class="closable-1945">&#88</button>\n':'\n<div class="popup-content">\n</div>\n';var h=r.querySelector(".popup-content"),{width:u,height:l}=e.root.model;h.style.width=u+"px",h.style.height=l+"px";var f=document.createElement("style");f.type="text/css",f.appendChild(document.createTextNode("\nbutton.closable-1945 {\n width: 20px;\n height: 20px;\n right: 0px;\n top: 0px;\n padding: 0;\n margin: 0;\n border: 0px;\n text-align: center;\n cursor: pointer;\n font-size: 12px;\n color: black;\n position: absolute;\n background-color: transparent;\n}\n\nbutton.closable-1945:hover {\n background-color:#60bb23;\n}\n")),r.appendChild(f),x9.forEach((r=>{e.on(r,((...e)=>{t.trigger(r,...e)}))}));var d=r.querySelector(".popup-content");Q8.forEach((function(t){d.addEventListener(t,(function(t){t.stopPropagation()}))})),K8.forEach((function(t){d.addEventListener(t,(function(t){t.stopPropagation()}))})),r.addEventListener("click",(e=>{e.target===r&&o&&k9.hide(t)})),Q8.forEach((function(t){r.addEventListener(t,(function(t){t.stopPropagation()}))})),K8.forEach((function(t){r.addEventListener(t,(function(t){t.stopPropagation()}))})),t.root.model_layer.overlay.appendChild(r),function(t,e,r){const n=t.root;if(n!==t){_9(t);var i=A9.get(n)||[];i=[...i,[t,{div:e,scene:r}]],A9.set(n,i)}}(t,r,e),r.querySelector(".closable-1945")?.addEventListener("click",(function(e){e.preventDefault(),k9.hide(t)}),!1),r.addEventListener("close-scene",(e=>{e.preventDefault(),e.stopPropagation(),k9.hide(t),s&&(t.data=e.detail)}),!1),e.target=h,e.data=n||t.data,e.fit("both");var p=function(t,e,r,n=w9){var i=t.bounds,a=e.bounds,o=Math.max(i.width/4-a.width/2,20),s=Math.min(3*i.width/4+a.width/2,i.width-20)-a.width,c=Math.max(i.height/4-a.height/2,20),u=Math.min(3*i.height/4+a.height/2,i.height-20)-a.height;switch(n){case"auto":return{x:r.x<i.width/2?s:o,y:r.y<i.height/2?u:c};case"left-top":return{x:o,y:c};case"right-top":return{x:s,y:c};case"left-bottom":return{x:o,y:u};case"right-bottom":return{x:s,y:u};default:return{x:(i.width-a.width)/2,y:(i.height-a.height)/2}}}(t.rootModel,e.root,t.center,i);a?(h.style.left=p.x+"px",h.style.top=p.y+"px",h.style.width=u+"px",h.style.height=l+"px"):(r.style.left=p.x+"px",r.style.top=p.y+"px",r.style.width=u+"px",r.style.height=l+"px")}),(function(t){console.error("cannot fetch board: "+e,t)}))}}var E9={reflow:function(t,e){},capturables:function(t){return t.components},drawables:function(t){return t.app.isViewMode?t.components.filter((t=>!t.hidden)):t.components},isStuck:function(t){return!1},ABSOLUTE:!0};function S9(t){var e=t.components.filter((t=>!t.hidden)),r=t.getState("layoutConfig")||{},n=e[r&&r.activeIndex||0];return n&&[n]||[]}m9.register("absolute",E9);var M9={reflow:function(t){var e=t.bounds,r=t.getState("layoutConfig")||{},n={left:0,top:0,width:e.width,height:e.height};t.forEach(((t,e)=>{let i=e!=(r.activeIndex||0);t.bounds=n,t.setState("rotation",0),t.element&&(t.element.style.visibility=i?"hidden":"visible")}))},capturables:function(t){return S9(t)},drawables:function(t){return S9(t)},isStuck:function(t){return!0}};function T9(t){var e=t.getState("layoutConfig");return e&&e.weight||1}m9.register("card",M9);var P9={reflow:function(t){var e=this.drawables(t),r=t.get("padding")||{},n=e.reduce(((t,e)=>t+T9(e)),0),i=t.bounds,a=n>0?(i.width-((r.left||0)+(r.right||0)))/n:i.width,o=i.height-((r.top||0)+(r.bottom||0)),s=0;e.forEach((t=>{let e=T9(t),n=t.get("margin")||{};t.bounds={left:a*s+(r.left||0)+(n.left||0),top:0+(r.top||0)+(n.top||0),width:e*a-((n.left||0)+(n.right||0)),height:o-((n.top||0)+(n.bottom||0))},t.setState("rotation",0),s+=e}))},capturables:function(t){return t.components},drawables:function(t){return t.app.isViewMode?t.components.filter((t=>!t.hidden)):t.components},isStuck:function(t){return!0}};function O9(t){var e=t.getState("layoutConfig");return e&&e.weight||1}m9.register("linear-horizontal",P9);var I9={reflow:function(t){var e=this.drawables(t),r=t.getState("padding")||{},n=e.reduce(((t,e)=>t+O9(e)),0),i=t.bounds,a=n>0?(i.height-((r.top||0)+(r.bottom||0)))/n:i.height,o=i.width-((r.left||0)+(r.right||0)),s=0;e.forEach((t=>{let e=O9(t),n=t.getState("margin")||{};t.bounds={left:0+(r.left||0)+(n.left||0),top:a*s+(r.top||0)+(n.top||0),width:o-((n.left||0)+(n.right||0)),height:e*a-((n.top||0)+(n.bottom||0))},t.setState("rotation",0),s+=e}))},capturables:function(t){return t.components},drawables:function(t){return t.app.isViewMode?t.components.filter((t=>!t.hidden)):t.components},isStuck:function(t){return!0}};m9.register("linear-vertical",I9);var C9={reflow:function(t){var e=t.getState("layoutConfig"),r=e&&e.columns||t.getState("columns"),n=e&&e.rows||t.getState("rows"),i=e&&e.widths||t.getState("widths"),a=e&&e.heights||t.getState("heights"),o=i?i.filter(((t,e)=>e<r)).reduce(((t,e)=>t+e),0):r,s=a?a.filter(((t,e)=>e<n)).reduce(((t,e)=>t+e),0):n,c=t.textBounds,u=t.getState("paddingLeft")||0,l=t.getState("paddingTop")||0,h=c.width/o,f=c.height/s,d=0,p=0;t.components.forEach(((t,e)=>{let n=i?i[e%r]:1,o=a?a[Math.floor(e/r)]:1,s=t.colspan||1,c=0;for(;--s>0;)c+=i?i[(e+s)%r]:1;let g=t.rowspan||1,v=0;for(;--g>0;)v+=a?a[Math.floor(e/r)+g]:1;t.bounds={left:u+d,top:l+p,width:h*(n+c),height:f*(o+v)},t.setState("rotation",0),e%r==r-1?(d=0,p+=o*f):d+=n*h}))},capturables:function(t){return t.components.filter((t=>!t.merged))},drawables:function(t){return t.components.filter((t=>!t.merged&&!t.hidden))},isStuck:function(t){return!0},keyNavigate:function(t,e,r){var n=t.getState("layoutConfig"),i=n&&n.columns||t.getState("columns"),a=n&&n.rows||t.getState("rows"),{row:o,column:s}=t.getRowColumn(e);switch(r.code){case"ArrowUp":if(o>0)return t.getAt((o-1)*i+s);break;case"ArrowDown":if(o<a-1)return t.getAt((o+1)*i+s);break;case"ArrowRight":if(s<i-1)return t.getAt(o*i+s+1);break;case"ArrowLeft":if(s>0)return t.getAt(o*i+s-1);break;default:return e}},joinType:!0};m9.register("table",C9);const R9=new Image;R9.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAAclBMVEVHcEwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAC0BbqFAAAAJXRSTlMAgAP3VSI6/g9fBk5FavJsMrariSjzPnO1enRRL5SMhmOOWB9keFTE0wAAANxJREFUOMutk9kWgyAMRLFuiLjUtdp9yf//YglVsQXz1HniMPcEMgHGvpX2O0Ypi+EgCL+IAShC+wB7QfubRDT7AFcnUPoLMLiP4PyJbsb55i05AgnR5iaQDsICgtH0cotBWoAP1c7kC6kFxEseCfZfB6gEgbNeBrira2QmH1uVYCXlA3is8UmgUCPIyQJKEmu8QtQJN0e9DPXVpzG2G216c1CqRmcBOdxXk07sWUSPv07zo0amCNQycv+NzmR6cRcwmfbuI7p2nZ/z4be0P83Foz6vIkhfZXr82XgDlZsspIq4peUAAAAASUVORK5CYII=";var j9=t=>class extends t{postrender(t){super.postrender(t),this.app.isEditMode&&this._focused&&this.showMoveHandle&&this._draw_move_handle(t)}_draw_move_handle(t){var{left:e,top:r,width:n}=this.bounds;t.save(),t.beginPath(),t.globalAlpha=1,t.rect(e+n,r,25,25);t.fillStyle="rgba(235, 235, 235, 1)",t.fill(),t.drawImage(R9,e+n+3.75,r+3.75,17.5,17.5),t.closePath(),t.restore()}contains(t,e){var r=super.contains(t,e);if(this.app.isViewMode)return r;if(!r){var{left:n,top:i,width:a,height:o}=this.bounds,s=n+a;this.showMoveHandle&&(r=t<Math.max(s+25,s)&&t>Math.min(s+25,s)&&e<Math.max(i+25,i)&&e>Math.min(i+25,i))}return this._focustd!==r&&(this._focused=r,this.invalidate()),r}};const L9=[];class D9 extends(j9(f9(u9))){constructor(t,e){super(t,e),this._components=[]}replaceRefids(t){this.components.forEach((e=>e.replaceRefids(t)))}get showMoveHandle(){return!0}get showOverflow(){return!1}dispose(){this.components.slice().forEach((t=>t.dispose())),super.dispose()}isContainer(){return!0}containable(t){return t.isDescendible(this)}get hasTextProperty(){return!1}get components(){return this._components}get focusible(){return!0}get layout(){return m9.get(this.get("layout"))||E9}reflow(){this.layout.reflow(this),this.components&&this.components.forEach((t=>{t.isContainer()&&t.reflow()}))}get hierarchy(){var t=super.hierarchy;return this.components&&(t.components=this.components.map((t=>t.hierarchy))),t}addComponent(t,e=!1){var r=t.parent;if(r){if(this===r)return;r.removeComponent(t,e)}var n=this._components.push(t)-1;t.parent=this,t.added(this),e||this.trigger("add",this,t,n),t.delegate_on(this),e||t.trigger("added",this,t,n),this.root&&this.root.isReady&&t.ready()}removeComponent(t,e=!1){var r=this._components.indexOf(t);-1!=r&&(this._components.splice(r,1),t.parent=null,t.removed(this),e||(this.trigger("remove",this,t),t.trigger("removed",this,t)),t.delegate_off(this))}insertComponentAt(t,e,r=!1){var n=t.parent;n&&n.removeComponent(t,r);var i=this._components.splice(0,e);this._components=i.concat(t,this._components),e=this._components.indexOf(t),t.parent=this,t.added(this),r||this.trigger("add",this,t,e),t.delegate_on(this),r||t.trigger("added",this,t,e)}add(t,e=!1){return t instanceof Array?(t.forEach((t=>{-1==this._components.indexOf(t)&&this.addComponent(t,e)})),this):this.add.call(this,[t],e)}remove(t,e=!1){return t instanceof Array?this._components?(t.forEach((t=>{this.removeComponent(t,e)})),this):this:this.remove.call(this,[t],e)}getAt(t){if(this._components)return this._components[t]}forEach(t,e){this._components&&this._components.forEach(t,e)}traverse(t,e){t.call(e,this),this._components&&this._components.forEach((r=>{r.isContainer()?r.traverse(t,e):t.call(e,r)}))}indexOf(t){return(this._components||L9).indexOf(t)}size(){return(this._components||L9).length}moveChildAt(t,e){var r=this.indexOf(e);if(-1!=r){var n=this._components.splice(0,r),i=this._components.splice(1);this._components=n.concat(i),t=Math.max(0,t),t=Math.min(t,this._components.length),n=this._components.splice(0,t),this._components=n.concat(e,this._components)}}moveChildForward(t){var e=this.indexOf(t);-1!=e&&e!=this.size()-1&&(this._components[e]=this._components[e+1],this._components[e+1]=t)}moveChildBackward(t){var e=this.indexOf(t);-1!=e&&0!=e&&(this._components[e]=this._components[e-1],this._components[e-1]=t)}moveChildToFront(t){var e=this.indexOf(t);if(-1!=e&&e!=this.size()-1){var r=this._components.splice(0,e),n=this._components.splice(1);this._components=r.concat(n,this._components)}}moveChildToBack(t){var e=this.indexOf(t);if(-1!=e&&0!=e){var r=this._components.splice(0,e),n=this._components.splice(0);this._components=this._components.concat(r,n)}}symmetryX(t){super.symmetryX(t),this.components.map((t=>{t.symmetryX(0)}))}findAll(t,...e){if("string"==typeof t)return o7(t,this,e[0]||this);if("function"==typeof t){var r=[];for(let n=this.components.length-1;n>=0;n--){let i=this.components[n].findAll(t,...e);i&&(r=r.concat(i))}return t(this,...e)&&r.push(this),r}}findFirst(t,...e){if("string"==typeof t)return o7(t,this,e[0])[0];if("function"==typeof t){for(let n=this.components.length-1;n>=0;n--){var r=this.components[n].findFirst(t,...e);if(null!=r)return r}return t(this,...e)?this:null}}findById(t){return this.root.findById(t)}findByRefid(t){return this.root.findByRefid(t)}contains(t,e){var r=super.contains(t,e);if(!r){var{left:n,top:i,width:a,height:o}=this.state;r=t<Math.max(n+a,n)&&t>Math.min(n+a,n)&&e<Math.max(i+o,i)&&e>Math.min(i+o,i)}return r}capture(t,e,r){var n=this.transcoordP2S(t,e);if(!this.contains(n.x,n.y))return!1;var i=this.bounds;n.x-=i.left,n.y-=i.top;var a=this.layout.capturables(this);for(let t=a.length-1;t>=0;t--){var o=a[t].capture(n.x,n.y,r);if(o)return o}return this.capturable&&!r?.(this)&&this}capturePath(t,e){if(e){if(e.indexOf(this)>-1)return!1;for(let t=0;t<e.length;t++)if(!this.containable(e[t]))return!1}var r=[],{left:n,top:i,width:a,height:o}=this.bounds;for(let e=0;e<t.length;e++){let s=this.transcoordP2S(t[e].x,t[e].y);if(s.x<n||s.x>n+a||s.y<i||s.y>i+o)return!1;s.x-=n,s.y-=i,r.push(s)}let s=this.layout.capturables(this);for(let t=s.length-1;t>=0;t--){let n=s[t];if(!n.isContainer())continue;let i=n.capturePath(r,e);if(i)return i}return this.focusible&&this}render(t){var{left:e=0,top:r=0,width:n,height:i}=this.bounds;t.beginPath(),t.rect(e,r,n,i),t.closePath(),this.drawFill(t),this.drawStroke(t)}postrender(t){const e=this.layout.drawables(this);if(e.length>0){var{left:r=0,top:n=0,width:i,height:a}=this.bounds;t.save(),this.showOverflow||(t.beginPath(),t.rect(r,n,i,a),t.clip(),t.closePath());var{top:n,left:r}=this.state;t.translate(r,n),e.forEach((e=>{e.draw(t)})),t.translate(-r,-n),t.restore()}super.postrender(t)}trim(){this.components.forEach((t=>{t.trim()})),super.trim()}}["layout"].forEach((t=>u9.memoize(D9.prototype,t,!1)));class z9 extends D9{constructor(t,e){super(t,e),t.translate=t.translate||{x:0,y:0},this._draw_reserved=!1,this.__draw__=()=>{this._draw_reserved=!1,this.trigger("redraw"),this.reflow(),this.draw()},this.throttle_render=()=>{this._draw_reserved||requestAnimationFrame(this.__draw__),this._draw_reserved=!0}}fitSize(t,e,r,n){if(this.target){if(e){let t=getComputedStyle(this.target);r=r||(t?parseFloat(t.getPropertyValue("width")):this.target.clientWidth),n=n||(t?parseFloat(t.getPropertyValue("height")):this.target.clientHeight)}else r=this.model.width,n=this.model.height;"CANVAS"==t.tagName&&(t.setAttribute("width",r*V8),t.setAttribute("height",n*V8)),t.style.width=r+"px",t.style.height=n+"px"}}resize(){this.fitSize(this.element,!0)}isLayer(){return!0}get showOverflow(){return this.app.isEditMode}get anchors(){}createElement(){var t=u9.createCanvas(1,1);return t.style.position="absolute",t}get target(){return this._target}set target(t){this._target&&this.element&&this._target.removeChild(this.element),this._target=t,t&&(this.element||(this.element=this.createElement()),this.resize(),t.appendChild(this.element))}get canvas(){return this.element}dispose(){super.dispose(),this.target=null,this.element=null}get selected(){return this.root.selected}set selected(t){this.root.selected=t}get hasSameParentForAllSelected(){return this.root.hasSameParentForAllSelected}get focused(){return this.root.focused}set focused(t){this.root.focused=t}getContext(){return this._context2D||(this._context2D=this.canvas&&this.canvas.getContext("2d")),this._context2D}draw(t){this.canvas&&(t=t||this.getContext())&&super.draw(t)}prerender(t){var{translate:e,scale:r={x:1,y:1},rotation:n}=this.model;t.clearRect(0,0,t.canvas.width,t.canvas.height),e&&t.translate(e.x*V8,e.y*V8),t.scale(r.x*V8,r.y*V8),n&&t.rotate(n)}get rotatePoint(){return{x:0,y:0}}contains(t,e){return!1}invalidate(){this.throttle_render()}move(t){var e=this.get("translate")||{x:0,y:0};this.set({translate:{x:e.x+t.x,y:e.y+t.y}})}centerTo(t,e){const r=t.rootModel.transcoordC2S(this.canvas.clientWidth/2,this.canvas.clientHeight/2),{x:n,y:i}=t.center,{x:a,y:o}=t.transcoordP2S(n,i),{x:s,y:c}=t.transcoordS2T(a,o),{x:u,y:l}=t.rootModel.get("translate"),{x:h,y:f}=t.rootModel.get("scale");e?t6({step:function(e){t.rootModel.set({translate:{x:u+(r.x-s)*h*e,y:l+(r.y-c)*f*e}})},duration:1e3,delta:"circ",ease:"in"}).start():t.rootModel.set({translate:{x:u+(r.x-s)*h,y:l+(r.y-c)*f}})}}const F9={x:1,y:1},N9={x:0,y:0};class B9 extends z9{constructor(t,e){super(t,e)}dispose(){super.dispose(),delete this._canvas,delete this._overlay}contains(t,e){return!0}isRootModel(){return!0}get stuck(){return!0}get layout(){return b9}get overlay(){if(!this._overlay){var t=document.createElement("div");t.style.position="absolute",t.style.width=0,t.style.height=0,t.style.overflow="initial",t.style["user-select"]="none",t.style["transform-origin"]="top left",this.element&&this.element.appendChild(t),this._overlay=t,this._repositionOverlay()}return this._overlay}createElement(){var t=document.createElement("div");return t.style.position="absolute",t.style["user-select"]="none",t.style.overflow="hidden",this._canvas=u9.createCanvas(1,1),this._canvas.style.position="absolute",t.appendChild(this._canvas),this._overlay&&t.appendChild(this._overlay),t}resize(){if(this.target){var{width:t,height:e,fitMode:r}=this.model;this.root.fitMode?r=this.root.fitMode:r||(r="ratio");try{var n=getComputedStyle(this.target)}catch(t){return void console.error(t,this.target)}var i=n?parseFloat(n.getPropertyValue("width")):this.target.clientWidth,a=n?parseFloat(n.getPropertyValue("height")):this.target.clientHeight;switch(r){case"both":case"ratio":break;case"width":a=e*i/t;break;case"height":i=t*a/e;break;default:i=Math.max(t,i),a=Math.max(e,a)}switch(this.fitSize(this.canvas,!0,i,a),r){case"ratio":case"both":break;case"width":this.element.style.overflowX="hidden",this.element.style.overflowY="auto";break;case"height":this.element.style.overflowX="auto",this.element.style.overflowY="hidden";break;default:this.element.style.overflowX=i>t?"hidden":"auto",this.element.style.overflowY=a>e?"hidden":"auto"}this.fitSize(this.element,!0)}}get canvas(){return this._canvas}get MPP(){var{scale:t={x:1,y:1},unit:e}=this.model;switch(e){case"mm":case"cm":return 1/this.app.PPM/t.x;case"in":return 1/this.app.PPI/t.x;default:return 1/t.x}}capturePath(t,e){var r=this.layout.capturables(this);for(let n=r.length-1;n>=0;n--){let i=r[n];if(!i.isContainer())continue;let a=i.capturePath(t,e);if(a)return a}return!1}get eventMap(){return{"(self)":{"(all)":{change:this._onchanged_all,mouseenter:this._onmouseenter_all,mouseleave:this._onmouseleave_all,click:this._onclick,mousedown:this._onmousedownup,mouseup:this._onmousedownup,touchstart:this._onmousedownup,touchend:this._onmousedownup}}}}closeScene(t){requestAnimationFrame((()=>this.overlay.dispatchEvent(new CustomEvent("close-scene",{bubbles:!0,composed:!0,detail:t}))))}_repositionOverlay(){var t=this._overlay;if(t){var{translate:e=N9,scale:r=F9,rotation:n=0}=this.model,{left:i,top:a,width:o,height:s}=this.bounds;t.style.left=i+"px",t.style.top=a+"px";var c=`rotate(${n}rad) scale(${r.x}, ${r.y}) perspective(1px)`;t.style["margin-left"]=e.x+"px",t.style["margin-top"]=e.y+"px",["-webkit-","-moz-","-ms-","-o-",""].forEach((e=>{t.style[e+"transform"]=c}))}}onchange(t){var e=this._model;delete e.id,delete e.text,delete e.class,this._repositionOverlay()}_onchanged_all(t,e,r){this.invalidate()}_onmouseenter_all(t,e){if(t.stopPropagation(),this.app&&!this.app.isEditMode&&e){var r=e.origin;if(!(r instanceof B9)&&r.model.event&&r.model.event.hover&&!r.hidden){var n=r.model.event.hover;n&&this._doEventAction(n,r,!0,t)}}}_onmouseleave_all(t,e){if(t.stopPropagation(),e){var r=e.origin;if(this.app&&!this.app.isEditMode){var n=r.model.event&&r.model.event.hover;n&&this._doEventAction(n,r,!1,t)}}}_onclick(t,e){if(t.stopPropagation(),!this.app.isEditMode&&e){var r=e.origin,n=r.model.event?.tap;n&&this._doEventAction(n,r,!0,t)}}_onmousedownup(t,e){if(t.stopPropagation(),!this.app.isEditMode&&e){var r=e.origin,n=r.model.event?.tap;n&&n.pressed&&this._doMouseDownUpEventAction(n,r,"mousedown"==t.type||"touchstart"==t.type,t)}}_doMouseDownUpEventAction(t,e,r,n){var{pressed:i=!1}=t;i&&(r?function(t){if(!t.hasOwnProperty("_backupShadow")){var e=t.get("shadow");t._backupShadow=e;var{left:r=0,top:n=0}=e||{};t.delta("tx",r),t.delta("ty",n),t.set("shadow",{})}}(e):function(t){t.hasOwnProperty("_backupShadow")&&(t.delta("tx",0),t.delta("ty",0),t.set("shadow",t._backupShadow),delete t._backupShadow)}(e))}_doEventAction(t,e,r,n){var{action:i,target:a,value:o,emphasize:s=!1,restore:c=!1,pressed:u=!1,options:l}=t;if(a&&(a=e.access(a)),o&&(o=e.access(o)),s&&(r?function(t){t.hasOwnProperty("_backupStrokeStyle")||(t._backupStrokeStyle=t.model.strokeStyle,t.set("strokeStyle","#f26522"),t.hasOwnProperty("_backupLineWidth")||(t._backupLineWidth=t.model.lineWidth,t.set("lineWidth",t.model.lineWidth+5)))}(e):c&&function(t){t.hasOwnProperty("_backupStrokeStyle")&&(t.set("strokeStyle",t._backupStrokeStyle),delete t._backupStrokeStyle,t.hasOwnProperty("_backupLineWidth")&&(t.set("lineWidth",t._backupLineWidth),delete t._backupLineWidth))}(e)),i)switch(i){case"data-toggle":if(!a)return;(r||c)&&this.root.findAll(a,e).forEach((t=>{t.data=!t.data}));break;case"data-tristate":if(!a)return;(r||c)&&this.root.findAll(a,e).forEach((t=>{let e=Math.round(Math.max(Number(t.data)||0,0));t.data=(e+(r?1:2))%3}));break;case"data-spreading":if(!a)return;if(r){var h=e.access(o);this.root.findAll(a,e).forEach((t=>{t.executeMappings(!0)}))}break;case"data-set":if(!a)return;if(r){h=e.access(o);this.root.findAll(a,e).forEach((t=>{t.data=h}))}break;case"partial-data-set":if(!a)return;if(r){h=e.access(o);this.root.findAll(a,e).forEach((t=>{t.data={...t.data,...h}}))}break;case"value-set":if(!a)return;if(r){h=e.access(o);this.root.findAll(a,e).forEach((t=>{t.value=h}))}break;case"partial-value-set":if(!a)return;if(r){h=e.access(o);this.root.findAll(a,e).forEach((t=>{t.value={...t.value,...h}}))}break;case"infoWindow":case"info-window":if(!a)return;"click"==n.type||r?v9.show(e,a,c,{x:n.offsetX,y:n.offsetY}):c&&v9.hide(e,a);break;case"toggle-info-window":if(!a)return;v9.toggle(e,a,!1,{x:n.offsetX,y:n.offsetY});break;case"popup":case"modal-popup":if(!a)return;let t=l&&"input"in l?l.input:"(self)",s=!l||(!("output"in l)||l.output);k9.show(e,a,{data:t&&this.root.findFirst(t,e)?.data,output:s,modal:"modal-popup"===i});break;case"close-scene":this.closeScene(e.data);break;case"goto":case"goto-playlist":this.trigger(i,a,l,e);break;case"mouse-cursor":r?this.target.style.cursor=a||"auto":c&&(this.target.style.cursor="auto");break;default:this.trigger(i,a,o,e)}}}function U9(t,e){const r=t.state.refid;return t.root.findAll((t=>t.isLine()&&t.from.component===r&&(!e||t.from.anchor===e)))}function Y9(t,e){const r=t.state.refid;return t.root.findAll((t=>t.isLine()&&t.to.component===r&&(!e||t.to.anchor===e)))}B9.Popup=k9,u9.register("model-layer",B9);var G9=t=>class extends t{isConnectable(){return!0}postrender(t){super.postrender(t),this._draw_anchors(t)}_draw_anchors(t){var e=this.anchors||[];t.save(),e.forEach((e=>{var{position:{x:r,y:n},draw:i}=e;if(i){t.beginPath();try{i.call(e,t,this)}catch(t){console.error(t)}t.closePath()}})),t.restore()}contains(t,e){if(n=super.contains(t,e))return n;var r=this.anchors||[];for(let i of r){const r=i.bounds;if(!r)continue;const{left:a,top:o,width:s,height:c}=r;var n;if(n=t<Math.max(a+s,a)&&t>Math.min(a+s,a)&&e<Math.max(o+c,o)&&e>Math.min(o+c,o))return n}return!1}findInOutLines(t){return function(t,e){const r=t.state.refid;return t.root.findAll((t=>!(!t.isLine()||(t.from.component!==r||e&&t.from.anchor!==e)&&(t.to.component!==r||e&&t.to.anchor!==e))))}(this,t)}findOutletLines(t){return U9(this,t)}findOutletEnds(t){return function(t,e){return U9(t,e).map((t=>t.toEnd?.component)).filter(Boolean)}(this,t)}findInletLines(t){return Y9(this,t)}findInletEnds(t){return function(t,e){return Y9(t,e).map((t=>t.fromEnd?.component)).filter(Boolean)}(this,t)}};const W9={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"number",label:"round",name:"round",property:{min:0}}],help:"scene/component/rect"};var H9={ondragmove:function(t,e,r){var{left:n,top:i,width:a,height:o}=r.model,s=(r.transcoordP2S(t.x,t.y).x-n)/(a/2)*100;s=h9(s,a,o),r.set({round:s})}};class q9 extends(G9(f9(l9))){is3dish(){return!0}get controls(){var{left:t,top:e,width:r,round:n,height:i}=this.state;return[{x:t+r/2*((n=null==n?0:h9(n,r,i))/100),y:e,handler:H9}]}get nature(){return W9}}u9.register("rect",q9);const X9=[1,2,10,20,50,50,50,50,50,50];class V9 extends(f9(l9)){render(t){const{lineWidth:e=1,fillStyle:r="lightgray",font:n="15px Arial",left:i,top:a,rotation:o,origin:s,margin:c,width:u,height:l,side:h="bottom",strokeStyle:f="#000000",scale:d=1}=this.state;t.translate(i,a),t.beginPath();const p=Math.round(e/2);t.rect(-p,-p,u+2*p,l+2*p),t.clip(),t.beginPath(),t.rect(0,0,u,l),r&&(t.fillStyle=r,t.fill()),t.lineWidth=e,t.strokeStyle=f,t.stroke(),t.beginPath(),t.font=n;var g="bottom"!==h,v=g?0:l,y=4*l/5,m=2*l/3,b=1*l/2,x=3*l/5;g&&(y=l-y,m=l-m,b=l-b,x=l-1.5*l/5);var w=d*this.app.PPM/this.root.unitScale,A=Math.ceil(s/w),_=this.app.PPM/w,k=_<=1.1?1:X9[Math.round(_)]||100;1!=k&&(A+=(k-A%k)%k);var E=Math.ceil(A*w),S=s+u;for(t.fillStyle=f;E<S;){if(A%10==0){t.moveTo(E-s,b),t.lineTo(E-s,v);let e=(A/10).toString(),r=t.measureText(e);t.fillText(e,E-s-r.width-6,x)}else A%5==0?(t.moveTo(E-s,m),t.lineTo(E-s,v)):(t.moveTo(E-s,y),t.lineTo(E-s,v));A+=k,E=Math.ceil(A*w)}}}u9.register("ruler",V9);const Q9=20,K9=20,J9=90*Math.PI/180,Z9="9px Verdana",$9=20,ttt="#f4f4f4",ett="#999";function rtt(t,e,r){return{left:-t.x,top:-t.y,width:Q9,height:$9}}function ntt(t,e,r,n){return{left:Q9-t.x,top:0-t.y,origin:20-t.x,width:e-Q9,height:$9}}function itt(t,e,r,n){var i={x:0-t.x+10,y:-t.y+K9+(r-K9)/2},a=u9.transcoordRR(0-t.x,-t.y+K9,i,J9);return{left:a.x-(r-K9),top:a.y,origin:20-t.y,width:r-K9,height:$9}}function att(t){var e=t.get("translate");return{left:-e.x,top:-e.y,width:t.canvas.width/V8,height:t.canvas.height/V8}}u9.register("guide-layer",class extends z9{constructor(t,e){super(t,e),this.appScale={x:1,y:1},"disabled"!==t.ruler&&(this.hruler=new V9({left:Q9,top:0,origin:20,margin:0,height:$9,unit:"m",rotation:0,font:Z9,fillStyle:ttt,strokeStyle:ett,capturable:!1}),this.vruler=new V9({left:0,top:0,origin:20,margin:0,height:$9,unit:"m",rotation:J9,font:Z9,side:"top",fillStyle:ttt,strokeStyle:ett,capturable:!1}),this.origin_rect=new q9({left:-20,top:-20,width:20,height:20,fillStyle:ttt,strokeStyle:ett,lineWidth:1}),this.addComponent(this.hruler),this.addComponent(this.vruler),this.addComponent(this.origin_rect)),this.invalidate()}get capturable(){return!1}ready(){if(super.ready(),this.hruler){var t=this.rootModel,e=Object.assign({},t.get("translate"));e.x<Q9&&(e.x+=Q9),e.y<K9&&(e.y+=K9);var r=t.get("scale")||{x:1,y:1};this.appScale=r,this.hruler.set("scale",r.x),this.vruler.set("scale",r.y),t.set("translate",e),this.set("translate",e),this.screen_coord=att(this);var{width:n,height:i}=this.screen_coord;this.hruler.set(ntt(e,n,0,this.hruler)),this.vruler.set(itt(e,0,i,this.vruler)),this.origin_rect.set(rtt(e))}else this.screen_coord=att(this)}resize(){super.resize(),this.screen_coord=att(this);var{width:t,height:e}=this.screen_coord;this.hruler&&(this.hruler.set(ntt(this.model.translate,t,0,this.hruler)),this.vruler.set(itt(this.model.translate,0,e,this.vruler)),this.origin_rect.set(rtt(this.model.translate)))}render(t){if(this.guide){t.save();var{x:e,y:r}=this.guide,{top:n,left:i,width:a,height:o}=this.screen_coord;t.beginPath(),t.moveTo(e,n),t.lineTo(e,n+o),t.moveTo(i,r),t.lineTo(i+a,r),t.lineWidth=1,t.strokeStyle="tomato",t.setLineDash([2,3]),t.font="10px tahoma",t.fillStyle="#333";var s=this.transcoordS2C(e,r,this.rootModel);t.textBaseline=s.y>200?"bottom":"top",t.textAlign=s.x>200?"right":"left";var c=s.y>200?-5:5,u=s.x>200?-5:5,l=Math.round(e/this.appScale.x),h=Math.round(r/this.appScale.y);t.fillText(` ${l}, ${h} `,e+u,r+c),t.stroke(),t.restore()}}get guide(){return this._guide}set guide(t){this._guide=t,this.invalidate()}contains(t,e){return!0}get eventMap(){return{"(root)":{"(descendant)":{mousemove:this.onmousemove_child,mouseout:this.onmouseout_child,dragmove:this.onmousemove_child},"model-layer":{change:this.onchange_root_model}},"(self)":{"(descendant)":{mousedown:this.onmousedown_origin}}}}onmousedown_origin(t,e){this.rootModel.set("translate",{x:20,y:20})}onchange_root_model(t,e,r){if(t.scale&&(this.appScale=t.scale,this.hruler&&(this.hruler.set("scale",t.scale.x),this.vruler.set("scale",t.scale.y))),t.translate&&this.set({translate:{x:t.translate.x,y:t.translate.y}}),t.scale||t.translate){if(this.screen_coord=att(this),this.hruler){var{translate:n}=this.model,{width:i,height:a}=this.screen_coord;this.hruler.set(ntt(n,i,0,this.hruler)),this.vruler.set(itt(n,0,a,this.vruler)),this.origin_rect.set(rtt(n))}this._guide=null}this.invalidate()}onmouseout_child(t){this._guide=null,this.invalidate()}onmousemove_child(t,e){t.target&&"CANVAS"!==t.target.tagName?this.guide=null:this.guide=this.transcoordC2S(t.offsetX,t.offsetY)}});u9.register("shift-layer",class extends z9{ready(){super.ready();var t=this.rootModel.get("translate");this.set("translate",t)}render(t){}contains(t,e){return!(2!=this.app.mode)}get eventMap(){return{"(root)":{"(self)":{keydown:this.onkeydown,keyup:this.onkeyup}}}}onkeydown(t){"Space"===t.code&&void 0===this.before_mode&&(this.before_mode=this.app.mode,this.app.mode=2)}onkeyup(t){"Space"===t.code&&(void 0!==this.before_mode&&(this.app.mode=this.before_mode),delete this.before_mode)}ondragstart(t){this.last_position=this.transcoordC2S(t.offsetX,t.offsetY)}ondragmove(t){var{x:e,y:r}=this.transcoordC2S(t.offsetX,t.offsetY);this.rootModel.move({x:e-this.last_position.x,y:r-this.last_position.y},!1),this.last_position=this.transcoordC2S(t.offsetX,t.offsetY)}});class ott{constructor(t){this.params=Object.assign({},t)}excute(){}}class stt extends ott{execute(){this.params.changes.forEach((t=>t.component.set(t.after)))}static before(t){return t.map((t=>({component:t})))}static after(t,e){e.execute(null,!1)}static around(t,e,r){e.call(r),t.execute(null,!1)}}const ctt="left",utt="right",ltt="center",htt="top",ftt="bottom",dtt="middle",ptt=[ctt,utt,ltt,htt,dtt,ftt];function gtt(t){if(this.hasSameParentForAllSelected&&-1!=ptt.indexOf(t)){var e=this.selected.filter((t=>!t.stuck));if(!(e.length<=1)){var r=this.app.commander;stt.around(r,(function(){!function(t,e){var r=JSON.parse(JSON.stringify(e[0].bounds)),n=r.left+r.width,i=r.top+r.height;for(let t=0;t<e.length;t++){let a=e[t].bounds;r.left=a.left>r.left?r.left:a.left,r.top=a.top>r.top?r.top:a.top,n=a.left+a.width>n?a.left+a.width:n,i=a.top+a.height>i?a.top+a.height:i}switch(r.width=n-r.left,r.height=i-r.top,t){case ctt:for(let t=0;t<e.length;t++){let n=e[t].bounds;e[t].bounds={left:r.left,top:n.top,width:n.width,height:n.height}}break;case ltt:for(let t=0;t<e.length;t++){let n=e[t].bounds;e[t].bounds={left:r.left+r.width/2-n.width/2,top:n.top,width:n.width,height:n.height}}break;case utt:for(let t=0;t<e.length;t++){let r=e[t].bounds;e[t].bounds={left:n-r.width,top:r.top,width:r.width,height:r.height}}break;case htt:for(let t=0;t<e.length;t++){let n=e[t].bounds;e[t].bounds={left:n.left,top:r.top,width:n.width,height:n.height}}break;case dtt:for(let t=0;t<e.length;t++){let n=e[t].bounds;e[t].bounds={left:n.left,top:r.top+r.height/2-n.height/2,width:n.width,height:n.height}}break;case ftt:for(let t=0;t<e.length;t++){let r=e[t].bounds;e[t].bounds={left:r.left,top:i-r.height,width:r.width,height:r.height}}break;default:;}}(t,e)}))}}}const vtt="VERTICAL",ytt=[vtt,"HORIZONTAL"];function mtt(t){if(this.hasSameParentForAllSelected&&-1!=ytt.indexOf(t)){var e=this.selected;if(!(e.length<=1)){var r=this.app.commander;stt.around(r,(function(){!function(t,e){var r=e.filter((t=>!t.stuck)).slice(0);r.sort((function(e,r){let n=e.center,i=r.center;return t===vtt?n.y-i.y:n.x-i.x}));var n=r.reduce(((e,r)=>e+(t===vtt?r.bounds.height:r.bounds.width)),0),i=r[0].bounds,a=r[r.length-1].bounds,o=((t===vtt?a.top+a.height-i.top:a.left+a.width-i.left)-n)/(r.length-1),s=t===vtt?i.top+i.height:i.left+i.width;for(let e=1;e<r.length-1;e++){let n=r[e],i=n.bounds;s+=o,t===vtt?(i.top=s,s+=i.height):(i.left=s,s+=i.width),n.bounds=i}}(t,e)}))}}}function btt(t){for(var e=0;t&&!t.isRootModel();)e+=t.get("rotation")||0,t=t.parent;return e%(2*Math.PI)}class xtt extends ott{execute(){this.params.changes.forEach((t=>{let{component:e,to_container:r,to_index:n,to_left:i,to_top:a,hint:o}=t,s=function(t){if(t.isRootModel())return t.bounds;var{bounds:e,rotatePoint:r}=t,n=r;return{left:(n=t.transcoordS2T(n.x,n.y)).x-(r.x-e.left),top:n.y-(r.y-e.top),width:e.width,height:e.height}}(e),c=btt(e);if(e.removeSelf(!r),e.bounds=s,e.set("rotation",c),r){e.set("rotation",function(t,e){return((t.get("rotation")||0)-btt(e))%(2*Math.PI)}(e,r));let o=function(t,e){if(e.isRootModel())return t.bounds;var{bounds:r,rotatePoint:n}=t,i=e.transcoordT2S(n.x,n.y),a=e.bounds;return{left:i.x-(n.x-r.left)-a.left,top:i.y-(n.y-r.top)-a.top,width:r.width,height:r.height}}(e,r);t.to_left=void 0!==i?i:o.left,t.to_top=void 0!==a?a:o.top,e.bounds={left:t.to_left,top:t.to_top,width:o.width,height:o.height},void 0===n?r.addComponent(e):r.insertComponentAt(e,n)}}))}}function wtt(t,e,r){this.app.commander.execute(new xtt({changes:[{component:t,to_container:e,to_index:r}]}))}function Att(t){var e=this.selected.filter((t=>!t.stuck));if(!(0==e.length||e[0].isRootModel()||e.length>1&&("forward"==t||"backward"==t))){var r,n=e[0].parent;if("forward"==t){let t=n.indexOf(e[0]);r=[{component:e[0],from_container:n,to_container:n,from_index:t,to_index:t+1}]}else if("backward"==t){let t=n.indexOf(e[0]);r=[{component:e[0],from_container:n,to_container:n,from_index:t,to_index:t-1}]}else r=e.filter((t=>t.parent===n)).sort(((e,r)=>{let i=n.indexOf(e)<n.indexOf(r);return"front"==t?i:!i})).map(((e,r)=>(n.indexOf(e),{component:e,to_container:n,to_index:"front"==t?n.components.length-r-1:r})));var i=new xtt({changes:r});this.app.commander.execute(i)}}function _tt(t,e,r,n){var i=u9.register(t.type);if(!i)return D8("Class not found",t.type),null;r&&(t.refid=r(t.refid)),t.id&&n&&n(t.id)&&delete t.id;var a=new i(t,e);return t.components&&a.isContainer()&&(t.components.forEach((t=>{var i=_tt(t,e,r,n);i&&a.addComponent(i)})),delete t.components),a.created(),a}function ktt(t,e){var r=Z6(t.hierarchy);return delete r.id,_tt(r,t.app,e)}var Ett=Object.freeze({__proto__:null,compile:_tt,duplicate:ktt,select:o7,match:n7});function Stt(t,e,r){t instanceof Array||(t=[t]),r||(r=this.model_layer);var n=[],i=new Map;this.selected=t.map((t=>{try{return _tt(t,r.app,(t=>{const e=this.getNewRefid();return void 0!==t&&i.set(t,e),e}),(t=>(this.indexMap[t]||[])[0]))}catch(t){return console.warn(t),!1}})).filter(Boolean).map((t=>{let{left:a,top:o,width:s,height:c,x:u,y:l,cx:h,cy:f}=e;return t.replaceRefids(i),isNaN(a)||isNaN(o)||isNaN(s)||isNaN(c)||(t.bounds={left:a,top:o,width:s,height:c}),isNaN(u)||isNaN(l)||t.move({x:u,y:l},!1),isNaN(h)||isNaN(f)||(t.center={x:h,y:f}),n.push({component:t,to_container:r}),t})),this.app.commander.execute(new xtt({changes:n}))}function Mtt(){var t=[],e=new Map;if(this.selected=this.selected.filter((t=>!t.isRootModel())).map((r=>{let n=ktt(r,(t=>{const r=this.getNewRefid();return void 0!==t&&e.set(t,r),r}));return n.move({x:20,y:20},!1),t.push({component:n,to_container:r.parent}),n})).map((t=>(t.replaceRefids(e),t))),0!=t.length){var r=new xtt({changes:t});this.app.commander.execute(r)}}function Ttt(){var t=this.selected;this.selected=[];for(var e=null,r=t.filter((t=>!t.isRootModel()&&(t.parent.focusible||t.parent.isGroup()))).map((t=>(e||(e=t.parent),{component:t,to_container:null})));e&&e.isGroup();){let t=[];if(e.components.filter((t=>!r.find((e=>e.component===t)))).forEach((e=>t.push(e))),t.length>1)break;let n=e.parent;t.forEach((t=>r.push({component:t,to_container:n}))),r.push({component:e,to_container:null}),e=n}r.length>0&&this.app.commander.execute(new xtt({changes:r})),e&&e.calculateBounds&&e.calculateBounds()}function Ptt(t,e,r){switch(t){case"execute":case"redo":case"undo":case"command-reset":this.app?.commander.on(t,e,r);break;case"mode":this.app?.on(t,e,r);break;default:this.on(t,e,r)}}function Ott(t,e,r){switch(t){case"execute":case"redo":case"undo":case"command-reset":this.app?.commander.once(t,e,r);break;case"mode":this.app.once(t,e,r);break;default:this.once(t,e,r)}}function Itt(t,e,r){switch(t){case"execute":case"redo":case"undo":case"command-reset":this.app?.commander.off(t,e,r);break;case"mode":this.app?.off(t,e,r);break;default:this.off(t,e,r)}}function Ctt(t){var e=this.target_element,r=t||this.fitMode,n=this;function i(t){n.fit(r),document.fullscreen||document.mozFullScreen||document.webkitIsFullScreen||document.msFullscreenElement||["fullscreenchange","mozfullscreenchange","webkitfullscreenchange","MSFullscreenChange"].forEach((t=>document.removeEventListener(t,i)))}["fullscreenchange","mozfullscreenchange","webkitfullscreenchange","MSFullscreenChange"].forEach((t=>document.addEventListener(t,i))),e.requestFullScreen?e.requestFullScreen():e.webkitRequestFullScreen?e.webkitRequestFullScreen():e.mozRequestFullScreen?e.mozRequestFullScreen():e.msRequestFullscreen&&e.msRequestFullscreen()}var Rtt=0;function jtt(){var t=this.selected.filter((t=>!t.isRootModel())).map((t=>t.hierarchy));if(0!=t.length)return Rtt=0,JSON.stringify(t,null,2)}function Ltt(){Rtt=0;var t=jtt.call(this);return Ttt.call(this),t}function Dtt(t){if(t)try{Rtt++,Stt.call(this,JSON.parse(t),{x:15*Rtt,y:15*Rtt})}catch(e){L8(e,t)}}var ztt=function(){return{escape:function(t){return t.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1")},parseExtension:t,mimeType:function(e){var r=t(e).toLowerCase();return(n="application/font-woff",i="image/jpeg",{woff:n,woff2:n,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:i,jpeg:i,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml"})[r]||"";var n,i},dataAsUrl:function(t,e){return"data:"+e+";base64,"+t},isDataUrl:function(t){return-1!==t.search(/^(data:)/)},canvasToBlob:function(t){return t.toBlob?new Promise((function(e){t.toBlob(e)})):function(t){return new Promise((function(e){for(var r=window.atob(t.toDataURL().split(",")[1]),n=r.length,i=new Uint8Array(n),a=0;a<n;a++)i[a]=r.charCodeAt(a);e(new Blob([i],{type:"image/png"}))}))}(t)},resolveUrl:function(t,e){var r=document.implementation.createHTMLDocument(),n=r.createElement("base");r.head.appendChild(n);var i=r.createElement("a");return r.body.appendChild(i),n.href=e,i.href=t,i.href},getAndEncode:function(t){var e=3e4;qtt.impl.options.cacheBust&&(t+=(/\?/.test(t)?"&":"?")+(new Date).getTime());return new Promise((function(r){var n,i=new XMLHttpRequest;if(i.onreadystatechange=o,i.ontimeout=s,i.responseType="blob",i.timeout=e,i.open("GET",t,!0),i.send(),qtt.impl.options.imagePlaceholder){var a=qtt.impl.options.imagePlaceholder.split(/,/);a&&a[1]&&(n=a[1])}function o(){if(4===i.readyState)if(200===i.status){var e=new FileReader;e.onloadend=function(){var t=e.result.split(/,/)[1];r(t)},e.readAsDataURL(i.response)}else n?r(n):c("cannot fetch resource: "+t+", status: "+i.status)}function s(){n?r(n):c("timeout of "+e+"ms occured while fetching resource: "+t)}function c(t){console.error(t),r("")}}))},uid:function(){var t=0;return function(){return"u"+e()+t++;function e(){return("0000"+(Math.random()*Math.pow(36,4)|0).toString(36)).slice(-4)}}}(),delay:function(t){return function(e){return new Promise((function(r){setTimeout((function(){r(e)}),t)}))}},asArray:function(t){for(var e=[],r=t.length,n=0;n<r;n++)e.push(t[n]);return e},escapeXhtml:function(t){return t.replace(/#/g,"%23").replace(/\n/g,"%0A")},makeImage:function(t){return new Promise((function(e,r){var n=new Image;n.onload=function(){e(n)},n.onerror=r,n.src=t}))},width:function(t){var r=e(t,"border-left-width"),n=e(t,"border-right-width");return t.scrollWidth+r+n},height:function(t){var r=e(t,"border-top-width"),n=e(t,"border-bottom-width");return t.scrollHeight+r+n}};function t(t){var e=/\.([^\.\/]*?)$/g.exec(t);return e?e[1]:""}function e(t,e){var r=window.getComputedStyle(t).getPropertyValue(e);return parseFloat(r.replace("px",""))}}(),Ftt=function(){var t=/url\(['"]?([^'"]+?)['"]?\)/g;return{inlineAll:function(t,i,a){return o()?Promise.resolve(t):Promise.resolve(t).then(r).then((function(e){var r=Promise.resolve(t);return e.forEach((function(t){r=r.then((function(e){return n(e,t,i,a)}))})),r}));function o(){return!e(t)}},shouldProcess:e,impl:{readUrls:r,inline:n}};function e(e){return-1!==e.search(t)}function r(e){for(var r,n=[];null!==(r=t.exec(e));)n.push(r[1]);return n.filter((function(t){return!ztt.isDataUrl(t)}))}function n(t,e,r,n){return Promise.resolve(e).then((function(t){return r?ztt.resolveUrl(t,r):t})).then(n||ztt.getAndEncode).then((function(t){return ztt.dataAsUrl(t,ztt.mimeType(e))})).then((function(r){return t.replace(function(t){return new RegExp("(url\\(['\"]?)("+ztt.escape(t)+")(['\"]?\\))","g")}(e),"$1"+r+"$3")}))}}(),Ntt=function(){return{resolveAll:function(){return t().then((function(t){return Promise.all(t.map((function(t){return t.resolve()})))})).then((function(t){return t.join("\n")}))},impl:{readAll:t}};function t(){return Promise.resolve(ztt.asArray(document.styleSheets)).then((function(t){var e=[];return t.forEach((function(t){try{ztt.asArray(t.cssRules||[]).forEach(e.push.bind(e))}catch(e){console.log("Error while reading CSS rules from "+t.href,e.toString())}})),e})).then((function(t){return t.filter((function(t){return t.type===CSSRule.FONT_FACE_RULE})).filter((function(t){return Ftt.shouldProcess(t.style.getPropertyValue("src"))}))})).then((function(e){return e.map(t)}));function t(t){return{resolve:function(){var e=(t.parentStyleSheet||{}).href;return Ftt.inlineAll(t.cssText,e)},src:function(){return t.style.getPropertyValue("src")}}}}}(),Btt=function(){return{inlineAll:function e(r){return r instanceof Element?n(r).then((function(){return r instanceof HTMLImageElement?t(r).inline():Promise.all(ztt.asArray(r.childNodes).map((function(t){return e(t)})))})):Promise.resolve(r);function n(t){var e=t.style.getPropertyValue("background");return e?Ftt.inlineAll(e).then((function(e){t.style.setProperty("background",e,t.style.getPropertyPriority("background"))})).then((function(){return t})):Promise.resolve(t)}},impl:{newImage:t}};function t(t){return{inline:function(e){return ztt.isDataUrl(t.src)?Promise.resolve():Promise.resolve(t.src).then(e||ztt.getAndEncode).then((function(e){return ztt.dataAsUrl(e,ztt.mimeType(t.src))})).then((function(e){return new Promise((function(r,n){t.onload=r,t.onerror=n,t.src=e}))}))}}}}(),Utt={imagePlaceholder:void 0,cacheBust:!1};function Ytt(t,e){return function(t){void 0===t.imagePlaceholder?qtt.impl.options.imagePlaceholder=Utt.imagePlaceholder:qtt.impl.options.imagePlaceholder=t.imagePlaceholder;void 0===t.cacheBust?qtt.impl.options.cacheBust=Utt.cacheBust:qtt.impl.options.cacheBust=t.cacheBust}(e=e||{}),Promise.resolve(t).then((function(t){return Wtt(t,e.filter,!0)})).then(Htt).then((function(t){var{bgcolor:r,width:n,height:i,style:a,sx:o=1,sy:s=1}=e,c=t.style;r&&(c.backgroundColor=r);n&&(c.width=n+"px");i&&(c.height=i+"px");c["margin-left"]="0px",c["margin-top"]="0px",["-webkit-","-moz-","-ms-","-o-",""].forEach((t=>{c[t+"transform"]=`rotate(0rad) translate(0px, 0px) scale(${o}, ${s}) perspective(1px)`})),a&&Object.keys(a).forEach((function(t){c[t]=a[t]}));return t})).then((function(r){return function(t,e,r){return Promise.resolve(t).then((function(t){return t.setAttribute("xmlns","http://www.w3.org/1999/xhtml"),(new XMLSerializer).serializeToString(t)})).then(ztt.escapeXhtml).then((function(t){return'<foreignObject x="0" y="0" width="100%" height="100%">'+t+"</foreignObject>"})).then((function(t){return'<svg xmlns="http://www.w3.org/2000/svg" width="'+e+'" height="'+r+'">'+t+"</svg>"})).then((function(t){return"data:image/svg+xml;charset=utf-8,"+t}))}(r,e.width||ztt.width(t),e.height||ztt.height(t))}))}function Gtt(t,e){return Ytt(t,e).then(ztt.makeImage).then(ztt.delay(100)).then((function(r){var n=function(t){var r=document.createElement("canvas");if(r.width=e.width||ztt.width(t),r.height=e.height||ztt.height(t),e.bgcolor){var n=r.getContext("2d");n.fillStyle=e.bgcolor,n.fillRect(0,0,r.width,r.height)}return r}(t);return n.getContext("2d").drawImage(r,0,0),n}))}function Wtt(t,e,r){return r||!e||e(t)?Promise.resolve(t).then((function(t){if(t instanceof HTMLCanvasElement)try{return ztt.makeImage(t.toDataURL())}catch(t){D8(t)}return t.cloneNode(!1)})).then((function(r){return function(t,e,r){var n=t.childNodes;return 0===n.length?Promise.resolve(e):i(e,ztt.asArray(n),r).then((function(){return e}));function i(t,e,r){var n=Promise.resolve();return e.forEach((function(e){n=n.then((function(){return Wtt(e,r)})).then((function(e){e&&t.appendChild(e)}))})),n}}(t,r,e)})).then((function(e){return function(t,e){return e instanceof Element?Promise.resolve().then(r).then(n).then(i).then(a).then((function(){return e})):e;function r(){function r(t,e){function r(t,e){ztt.asArray(t).forEach((function(r){e.setProperty(r,t.getPropertyValue(r),t.getPropertyPriority(r))}))}t.cssText?e.cssText=t.cssText:r(t,e)}r(window.getComputedStyle(t),e.style)}function n(){function r(r){var n=window.getComputedStyle(t,r),i=n.getPropertyValue("content");if(""!==i&&"none"!==i){var a=ztt.uid();e.className=e.className+" "+a;var o=document.createElement("style");o.appendChild(s(a,r,n)),e.appendChild(o)}function s(t,e,r){var n="."+t+":"+e,i=r.cssText?a(r):o(r);return document.createTextNode(n+"{"+i+"}");function a(t){var e=t.getPropertyValue("content");return t.cssText+" content: "+e+";"}function o(t){return ztt.asArray(t).map(e).join("; ")+";";function e(e){return e+": "+t.getPropertyValue(e)+(t.getPropertyPriority(e)?" !important":"")}}}}[":before",":after"].forEach((function(t){r(t)}))}function i(){t instanceof HTMLTextAreaElement&&(e.innerHTML=t.value),t instanceof HTMLInputElement&&e.setAttribute("value",t.value)}function a(){e instanceof SVGElement&&(e.setAttribute("xmlns","http://www.w3.org/2000/svg"),e instanceof SVGRectElement&&["width","height"].forEach((function(t){var r=e.getAttribute(t);r&&e.style.setProperty(t,r)})))}}(t,e)})):Promise.resolve()}function Htt(t){return Btt.inlineAll(t).then((function(){return t}))}var qtt={toSvg:Ytt,toPng:function(t,e){return Gtt(t,e||{}).then((function(t){return t.toDataURL()}))},toJpeg:function(t,e){return Gtt(t,e=e||{}).then((function(t){return t.toDataURL("image/jpeg",e.quality||1)}))},toBlob:function(t,e){return Gtt(t,e||{}).then(ztt.canvasToBlob)},toPixelData:function(t,e){return Gtt(t,e||{}).then((function(e){return e.getContext("2d").getImageData(0,0,ztt.width(t),ztt.height(t)).data}))},impl:{fontFaces:Ntt,images:Btt,util:ztt,inliner:Ftt,options:{}}};function Xtt(t,e,r,n){var i=this.model_layer,a=i._overlay;return new Promise((function(o,s){if(i){var c=i.get("width"),u=i.get("height");r=r||c,n=n||u;var l=i.get("translate"),h=i.get("scale"),f=Math.min(r/c,n/u);r=c*f,n=u*f,i.set("translate",{x:0,y:0}),i.set("scale",{x:f/V8,y:f/V8});var d=u9.createCanvas(r,n),p=d.getContext("2d");if(i.draw(p),i.set("translate",l),i.set("scale",h),!a)return o(d.toDataURL(t,e)),void(d=null);qtt.toPng(a,{sx:f,sy:f,width:r,height:n}).then((function(i){var a=new Image;a.onload=function(){p.drawImage(a,0,0,r,n),o(d.toDataURL(t,e)),d=null},a.src=i}),(function(r){L8(r),o(d.toDataURL(t,e)),d=null}))}else s("No target model")}))}function Vtt(){if(this.hasSameParentForAllSelected){var t=this.selected.filter((t=>!!t.parent&&!t.stuck));if(!(t.length<2)){var e=t[0].parent,r=[],n=t.sort(((t,r)=>e.components.indexOf(t)-e.components.indexOf(r)));n.forEach((t=>{r.push(t.bounds)}));var i=u9.union(r),a=t[0].transcoordP2S(i.left,i.top);a=t[0].transcoordS2T(a.x,a.y);var o=new Map,s=_tt({type:"group",left:a.x,top:a.y,width:i.width,height:i.height},e.app,(t=>{const e=this.getNewRefid();return void 0!==t&&o.set(t,e),e}));s.replaceRefids(o);var c=[{component:s,to_container:e}];n.forEach((t=>{c.push({component:t,to_container:s})})),this.app.commander.execute(new xtt({changes:c})),this.selected=[s]}}}function Qtt(){if(0!==this.selected.length){var t=[],e=[];this.selected.forEach((r=>{if(r.isGroup()){var n=r.parent;r.components.forEach((r=>{t.push(r),e.push({component:r,to_container:n})})),e.push({component:r,to_container:null})}})),this.app.commander.execute(new xtt({changes:e})),this.selected=t}}function Ktt(){var t=this.selected;if(0!=t.length){var e=t.map((t=>t.bounds)),r=u9.union(e),n=r.left+r.width/2;t.map((t=>{t.symmetryX(n)}))}}function Jtt(){var t=this.selected;if(0!=t.length){var e=t.map((t=>t.bounds)),r=u9.union(e),n=r.top+r.height/2;t.map((t=>{t.symmetryY(n)}))}}function Ztt(){stt.around(this.app.commander,Ktt,this)}function $tt(){stt.around(this.app.commander,Jtt,this)}function tet(t,e,r){var n=this.findAll(t,r);return n.forEach((t=>{t.set(e)})),n}function eet(t){stt.around(this.app.commander,t)}function ret(){return Object.values(this.indexMap).map((t=>t.map((t=>{let{id:e,data:r}=t.model;return{key:e,value:r}})))).flat().sort(((t,e)=>t.key>e.key?1:-1))}const net="left",iet="right",aet="center",oet="top",set="bottom",cet="middle",uet=[net,iet,aet,oet,cet,set];function het(t){if(this.hasSameParentForAllSelected&&-1!=uet.indexOf(t)){var e=this.selected.filter((t=>!t.stuck)),r=this.app.commander;stt.around(r,(function(){!function(t,e){const r=e[0].parent,{width:n,height:i}=r.bounds;switch(t){case net:for(let t=0;t<e.length;t++){let r=e[t].bounds;e[t].bounds={...r,left:0}}break;case aet:for(let t=0;t<e.length;t++){let r=e[t].bounds;e[t].bounds={...r,left:n/2-r.width/2}}break;case iet:for(let t=0;t<e.length;t++){let r=e[t].bounds;e[t].bounds={...r,left:n-r.width}}break;case oet:for(let t=0;t<e.length;t++){let r=e[t].bounds;e[t].bounds={...r,top:0}}break;case cet:for(let t=0;t<e.length;t++){let r=e[t].bounds;e[t].bounds={...r,top:i/2-r.height/2}}break;case set:for(let t=0;t<e.length;t++){let r=e[t].bounds;e[t].bounds={...r,top:i-r.height}}break;default:;}}(t,e)}))}}function fet(t){t instanceof Array||(t=[t]),this.trigger("addstart",t)}function det(){this.trigger("stylepastestart")}function pet(){this.trigger("stylepastestop")}function get(){this.trigger("databindpastestart")}function vet(){this.trigger("databindpastestop")}function yet(t,e,r,n){var i=t.selected,a=n?i.slice(0):[];n&&a.length>0?e=a[0].parent:e.isContainer()||(e=e.parent);var o=e.layout.capturables(e),s=!!e.layout.joinType;if(n&&r.selected.forEach((t=>{a.splice(a.indexOf(t),1)})),r.selected=[],o.forEach((t=>{t.capturable&&function(t,e,r){var n,i,a,o,{sx:s,sy:c,ex:u,ey:l}=e;if(s>u?(n=u,i=s):(n=s,i=u),c>l?(a=l,o=c):(a=c,o=l),r){var h=t.bounds,f=t.transcoordS2TR(h.left,h.top),d=t.transcoordS2TR(h.left+h.width,h.top+h.height),p=f.x,g=d.x,v=f.y,y=d.y,m=Math.min(n,p,i,g),b=Math.max(n,p,i,g),x=Math.min(a,v,o,y),w=Math.max(a,v,o,y);return!(b-m>Math.abs(i-n)+Math.abs(g-p)||w-x>Math.abs(o-a)+Math.abs(y-v))}var A=t.path;if(!A)return error("컴포넌트에 get path가 잘못 구현되어있음.",t),!1;for(let e=0;e<A.length;e++){let r=t.transcoordS2TR(A[e].x,A[e].y);if(n>r.x||i<r.x||a>r.y||o<r.y)return!1}return!0}(t,r,s)&&-1==a.indexOf(t)&&r.selected.push(t)})),a=a.concat(r.selected),i.length!==a.length)t.selected=a;else for(let e=0;e<a.length;e++)if(i[e]!=a[e]){t.selected=a;break}}function met(t,e,r,n,i){i||yet(t,e,r,n)}function bet(t,e){var r=t.components||[];for(let t of r){bet(t,e);let r=e.indexOf(t);-1!=r&&e.splice(r,1)}}u9.register("add-layer",class extends z9{ready(){super.ready();var t=this.rootModel,e=t.get("translate"),r=t.get("scale");this.set("translate",e),this.set("scale",r)}render(t){var e=this.addbox;if(e){let{sx:r,sy:n,ex:i,ey:a}=e,o=this.get("scale")||{x:1,y:1};t.beginPath(),t.rect(r,n,i-r,a-n),t.setLineDash([2/o.x,4/o.y]),t.lineWidth=1/o.x,t.strokeStyle="black",t.stroke()}}contains(t,e){return!(3!=this.app.mode)}get eventMap(){return{"(root)":{"(self)":{addstart:this.onaddstart,addstop:this.onaddstop,keydown:this.onkeydown,dragstart:this.ondragstart,dragmove:this.ondragmove,dragend:this.ondragend,mousedown:this.onmousedown,mouseup:this.onmouseup}},"model-layer":{"(self)":{change:this.onchange_root_model}}}}onchange_root_model(t,e,r){t.translate&&this.set("translate",t.translate),t.scale&&this.set("scale",t.scale)}onaddstart(t,e){void 0===this.before_mode&&(this.before_mode=this.app.mode,this.models=t,this.app.mode=3)}onaddstop(){void 0!==this.before_mode&&(this.app.mode=this.before_mode),delete this.before_mode,delete this.addbox,this.invalidate()}onkeydown(t){3!==this.app.mode||"Esc"!=t.code&&"Escape"!=t.code||this.root.trigger("addstop")}ondragstart(t){var{x:e,y:r}=this.transcoordC2S(t.offsetX,t.offsetY);this.addbox={sx:e,sy:r}}ondragmove(t){if(3===this.app.mode){var{x:e,y:r}=this.transcoordC2S(t.offsetX,t.offsetY);this.addbox&&(this.addbox.ex=e,this.addbox.ey=r,this.invalidate())}}ondragend(t,e){if(3!==this.app.mode)return;const{sx:r,sy:n,ex:i,ey:a}=this.addbox;Stt.call(this.root,this.models,{left:Math.min(r,i),top:Math.min(n,a),width:Math.abs(i-r),height:Math.abs(a-n)}),this.root.trigger("addstop")}onmousedown(t,e){3===this.app.mode&&(this.downpoint={x:t.offsetX,y:t.offsetY})}onmouseup(t,e){if(this.downpoint.x===t.offsetX&&this.downpoint.y===t.offsetY){var{x:r,y:n}=this.transcoordC2S(t.offsetX,t.offsetY);Stt.call(this.root,this.models,{cx:r,cy:n}),this.root.trigger("addstop")}}});u9.register("selection-layer",class extends z9{ready(){super.ready();var t=this.rootModel,e=t.get("translate"),r=t.get("scale");this.set("translate",e),this.set("scale",r)}contains(t,e){return!1}render(t){var e=this.selbox;if(e){let{sx:r,sy:n,ex:i,ey:a}=e,o=this.get("scale")||{x:1,y:1};t.beginPath(),t.rect(r,n,i-r,a-n),t.setLineDash([2/o.x,4/o.y]),t.lineWidth=1/o.x,t.strokeStyle="black",t.stroke()}}get eventMap(){return{"(root)":{"(self)":{keydown:this.onkeydown}},"model-layer":{"(self)":{change:this.onchange_root_model},"(all)":{dragstart:this.ondragstart_selbox,dragmove:this.ondragmove_selbox,dragend:this.ondragend_selbox,mousedown:this.onmousedown_comp,mouseup:this.onmouseup_comp}}}}onkeydown(t,e){var{origin:r,deliverer:n}=e,i=n.selected;if(1!==i.length)return!1;var a=i[0],o=a.parent;if(!o||o===n)return!1;if("Tab"===t.code){var s=o.layout.capturables(o),c=s.indexOf(a);if(-1==c){if(!o.indexOf(a))return D8("Container not contains [",a,"] as a component"),!1;c=0}var u=s.length;t.shiftKey?c--:c++,a=s[(c+u)%u]}else{if(!o.layout.keyNavigate)return!1;a=o.layout.keyNavigate(o,a,t)||a}n.selected=[a],t.preventDefault()}onchange_root_model(t,e,r){t.translate&&this.set("translate",t.translate),t.scale&&this.set("scale",t.scale)}_pendingDecision(t){this.downpoint={x:t.offsetX,y:t.offsetY}}_selectGroupItem(t,e){var r=this.selected.indexOf(t);let n=t.parent;for(;n.parent.isGroup();)n=n.parent;let i=[],a=!1,o=!1;if(this.selected.forEach((t=>{let e=t.parent;if(t!==n){for(;e.parent&&e.parent.isGroup();)e=e.parent;e===n&&(i.push(t),a=!0)}else o=!0})),a)if(e.shiftKey){if(-1!=r)return void this._pendingDecision(e);i.push(t)}else{if(-1!=r)return void this._pendingDecision(e);i=[t]}else{if(o)return void this._pendingDecision(e);if(e.shiftKey)if(this.selected.length>0){if(-1!=this.selected.indexOf(n))return;i=[...this.selected,n]}else i=[n];else i=[n]}this.selected=i}onmousedown_comp(t,e){var{origin:r}=e;if(this.downpoint=null,t.shiftKey){if(r.parent.isGroup())return void this._selectGroupItem(r,t);if(-1!=this.selected.indexOf(r))return void this._pendingDecision(t);{let t=this.selected.filter((t=>!t.isRootModel()&&!!t.parent)),e=t.length>0&&t[0].parent;e&&e!==r.parent&&(!function(t,e){for(var r=t.parent;r;){let t=e.indexOf(r);-1!=t&&e.splice(t,1),r=r.parent}}(r,t),bet(r,t)),t.push(r),this.selected=t}}else{if(r.parent.isGroup())return void this._selectGroupItem(r,t);if(-1!=this.selected.indexOf(r))return;this.selected=[r],this.sameParent=!0}}onmouseup_comp(t,e){if(!this.downpoint)return;if(this.downpoint.x!==t.offsetX||this.downpoint.y!==t.offsetY)return;var{origin:r}=e;let n=this.selected.indexOf(r);if(-1==n&&r.parent.isGroup()&&(n=this.selected.indexOf(r.parent)),-1!==n&&t.shiftKey){let t=this.selected.slice();return n>-1&&t.splice(n,1),void(this.selected=t)}r.parent.isGroup()&&(this.selected=[r])}ondragstart_selbox(t,e){var{origin:r}=e;if(r.stuck){var{x:n,y:i}=this.transcoordC2S(t.offsetX,t.offsetY);this.selbox={sx:n,sy:i,selected:[]}}}ondragmove_selbox(t,e){var{origin:r}=e;if(r.stuck){var{x:n,y:i}=this.transcoordC2S(t.offsetX,t.offsetY);this.selbox&&(this.selbox.ex=n,this.selbox.ey=i,met(this,r,this.selbox,t.shiftKey),this.invalidate())}}ondragend_selbox(t,e){var{origin:r}=e;r.stuck&&(this.last_pos=null,this.selbox=null,met(this,null,null,!1,!0),this.invalidate())}});class xet{constructor(t){this.layer=t}draw(t,e,r){var{left:n,top:i,width:a,height:o}=e.bounds;0!=a&&0!=o&&(t.beginPath(),t.rect(n,i,a,o),t.clip(),t.beginPath(),t.strokeStyle="#f26522",t.lineWidth=4,t.shadowBlur=10,t.shadowColor="black",t.shadowOffsetX=0,t.shadowOffsetY=0,t.rect(n,i,a,o),t.stroke(),t.closePath())}}class wet{constructor(t){this.layer=t}draw(t,e,r){var n=e.bounds;t.beginPath(),t.rect(n.left-4/r.x,n.top-4/r.y,n.width+8/r.x,n.height+8/r.y),t.setLineDash([3/r.x,4/r.y]),t.lineWidth=1/r.x,t.strokeStyle="black",t.stroke(),t.setLineDash([]),t.closePath()}}class Aet{constructor(t){this.layer=t}reset(){this.active=null}get selected(){return this.layer.selected}contains(t,e,r,n){let i=r.controls;return!!i&&(i.every(((i,a)=>(Math.abs(t-i.x)<=4/n.x&&Math.abs(e-i.y)<=4/n.y&&(this.active={component:r,index:a,handler:i.handler}),!this.active))),!!this.active)}draw(t,e,r){var n=e.controls;n&&n.forEach(((e,n)=>{t.beginPath(),t.lineWidth=1/r.x,t.ellipse(e.x,e.y,4/r.x,4/r.y,0,0,2*Math.PI,!0),t.fillStyle="#ff5d72",t.fill(),t.strokeStyle="#fff",t.stroke()}))}onevent(t,e){var{handler:r,component:n,index:i}=this.active,a=n.transcoordC2S(e.offsetX,e.offsetY);a=n.transcoordS2P(a.x,a.y),r&&"function"==typeof r[t]&&r[t](a,i,n)}onmousedown(t){this.onevent("onmousedown",t)}ondragstart(t){var e=this.active;e.changes=stt.before([e.component]),this.onevent("ondragstart",t)}ondragmove(t){this.onevent("ondragmove",t)}ondragend(t){this.onevent("ondragend",t);var{component:e,changes:r}=this.active;stt.after(r,e.app.commander),e.parent&&e.parent.calculateBounds&&e.parent.calculateBounds()}}function _et(t,e){return Math.atan2(e.y-t.y,e.x-t.x)}const ket=15*Math.PI/180;class Eet{constructor(t){this.layer=t}reset(){this.active=null,this.created=null}get selected(){return this.layer.selected}contains(t,e,r,n){return!!r.mutable&&(r.path.every(((i,a)=>(Math.abs(t-i.x)<=4/n.x&&Math.abs(e-i.y)<=4/n.y&&(this.active={component:r,index:a}),!this.active))),!!this.active)}startLinkProcess(t,e,r){try{var n=_tt(e,t.app);return t.rootModel.addComponent(n),this.layer.selected=[n],this.active={component:n,index:1},this.ondragstart(r),n}catch(t){console.warn(r)}}draw(t,e,r){if(e.mutable&&!e.stuck){var n=e.path,i=this.active;n.forEach(((n,a)=>{t.beginPath(),t.ellipse(n.x,n.y,4/r.x,4/r.y,0,0,2*Math.PI,!0),t.lineWidth=1/r.x,t.strokeStyle="#656565",t.fillStyle="#fff",i&&i.component===e&&i.index===a&&(t.strokeStyle="#fa7703",i.toFill&&(t.fillStyle="#ffb80c")),t.fill(),t.stroke()}))}}ondblclick(t){var e=this.active.component;if(e.pathExtendable){var r=e.path.slice();r.length<3||(r.splice(this.active.index,1),e.path=r)}}onmousedown(t){this.active.toFill=!0}ondragstart(t){var{index:e,component:r}=this.active;this.created||(this.active.changes=stt.before([r])),0!==e&&e!==r.path.length-1||(this.layer.counterEnd=0===e?r.toEnd||{fromto:"to"}:r.fromEnd||{fromto:"from"})}ondragmove(t){var{component:e,index:r}=this.active||{};const{offsetX:n,offsetY:i}=t;var a,o,s=e.transcoordC2S(n,i);if(s=e.transcoordS2P(s.x,s.y),t.shiftKey){var c=e.path.length,u=e.isLine()&&0==r?e.path[1]:e.path[(r-1+c)%c];u=e.transcoordS2P(u.x,u.y);var l,h=0;if(c>2)e.isLine()?0==r?l=e.path[2]:1!=r&&(l=e.path[r-2]):l=e.path[(r-2+c)%c],l&&(h=_et(l=e.transcoordS2P(l.x,l.y),u));var f=Math.round((_et(u,s)-h)/ket)*ket+h;s=function(t,e,r){return{x:Math.cos(e)*r+t.x,y:Math.sin(e)*r+t.y}}(u,f,(a=u,o=s,Math.sqrt((o.x-a.x)*(o.x-a.x)+(o.y-a.y)*(o.y-a.y))))}if(0===r||r===e.path.length-1){const t=this.layer.anchorTarget=e.rootModel.capture(n,i,(t=>!t.isConnectable()));if(t){const{x:a,y:o}=t.transcoordC2S(n,i),c=this.layer.get("scale")||{x:1,y:1},u=this.layer.counterEnd,l=(t.anchors||[]).find((r=>{const{name:n,inout:i,multiplicity:s=1/0,position:l,filter:h}=r;if(u){const{anchor:t,fromto:e}=u;if(t&&("out"===t.inout&&"out"===i||"in"===t.inout&&"in"===i))return!1;if("from"===e&&"out"===i||"to"===e&&"in"===i)return!1}else console.error("should not be here.");if(Math.abs(a-l.x)>8/c.x||Math.abs(o-l.y)>8/c.y)return!1;const f=t.findInOutLines(n);return!!f.includes(e)||!(s!==1/0&&f.length>=s)&&(!u||!h||!!h.call(r,u))}));l?0==r?e.from={component:t.get("refid"),anchor:l.name,position:s}:e.to={component:t.get("refid"),anchor:l.name,position:s}:0==r?e.from={position:s}:e.to={position:s}}}e.mutatePath(null,(function(t){t[r]=s}))}ondragend(t){var{component:e,index:r,changes:n}=this.active;if(0===r||r===e.path.length-1){const{offsetX:n,offsetY:i}=t,a=e.rootModel.capture(n,i,(t=>t===e||t.isLine())),{x:o,y:s}=a.transcoordC2S(n,i),c=this.layer.get("scale")||{x:1,y:1},u=(a.anchors||[]).find((t=>t&&Math.abs(o-t.position.x)<=8/c.x&&Math.abs(s-t.position.y)<=8/c.y));u&&(0==r?e.from={component:a.get("refid"),anchor:u.name}:e.to={component:a.get("refid"),anchor:u.name}),this.layer.endLinkProcess()}if(this.created){let t=new xtt({changes:[{component:this.created,to_container:this.created.parent}]});created.app.commander.execute(t)}else stt.after(n,e.app.commander);e.parent&&e.parent.calculateBounds&&e.parent.calculateBounds()}}class Met{constructor(t){this.layer=t}get active(){return this._active?.component.disposed&&(this._active=null),this._active}set active(t){this._active=t}reset(){this.active=null}contains(t,e,r,n){const i=this.active?.component===r&&this.active?.anchor;this.active=null;const a=this.layer.counterEnd;return(r.isConnectable()&&!r.disposed&&r.anchors||[]).filter((t=>{const{name:e,inout:n,multiplicity:i=1/0,filter:o}=t;if(a){const{anchor:t,fromto:e}=a;if(t&&("out"===t.inout&&"out"===n||"in"===t.inout&&"in"===n))return!1;if("from"===e&&"out"===n||"to"===e&&"in"===n)return!1}else if("in"===n)return!1;return!(i!==1/0&&r.findInOutLines(e).length>=i)&&(!o||!a||!!o.call(t,a))})).every((a=>{const o=i===a.name?2:1;return a&&a.position&&Math.abs(t-a.position.x)<=4*o/n.x&&Math.abs(e-a.position.y)<=4*o/n.y&&(this.active={component:r,anchor:a.name,template:a.template}),!this.active})),!!this.active}draw(t,e,r){if(!e.get("refid")||e.isLine())return;var n=this.active;const i=this.active?.component===e&&this.active?.anchor,a=this.layer.counterEnd;(e.isConnectable()&&!e.disposed&&e.anchors||[]).filter((t=>{const{name:r,inout:n,multiplicity:i=1/0,filter:o}=t;if(a){const{anchor:t,fromto:e}=a;if(t&&("out"===t.inout&&"out"===n||"in"===t.inout&&"in"===n))return!1;if("from"===e&&"out"===n||"to"===e&&"in"===n)return!1}else if("in"===n)return!1;return!(i!==1/0&&e.findInOutLines(r).length>=i)&&(!a||!o||!!o.call(t,a))})).forEach((a=>{const{name:o,position:s}=a,c=i===o?2:1;s&&(t.beginPath(),t.ellipse(s.x,s.y,4*c/r.x,4*c/r.y,0,0,2*Math.PI),t.setLineDash([0,0]),t.lineWidth=1/r.x,t.strokeStyle="#656565",t.stroke(),t.fillStyle="#fff",n&&n.component===e&&n.anchor===o&&(t.strokeStyle="#fa7703",n.focus&&(t.fillStyle="#ffb80c")),t.fill(),t.stroke())}))}onmousedown(t){this.active.focus=!0}ondragstart(t){const{component:e,anchor:r,template:n}=this.active,i=this.layer.transcoordC2S(t.offsetX,t.offsetY);this.layer.startLinkProcess(e,{type:"ortholine",lineWidth:1,strokeStyle:"black",begin:"oval",beginSize:"size9",end:"arrow",endSize:"size9",lineDash:"solid",lineCap:"butt",round:10,...n,from:{component:e.get("refid"),anchor:r,position:i},to:{position:i}},t)}ondragmove(t){}ondragend(t){}}function Tet(t,e,r){var n,i,{left:a,top:o,width:s,height:c}=t.bounds;switch(e){case 0:n=a,i=o;break;case 1:n=a+s/2,i=o;break;case 2:n=a+s,i=o;break;case 3:n=a+s,i=o+c/2;break;case 4:n=a+s,i=o+c;break;case 5:n=a+s/2,i=o+c;break;case 6:n=a,i=o+c;break;case 7:n=a,i=o+c/2}var u=n,l=i,h=t.transcoordT2S(r.x,r.y);return{dx:h.x-u,dy:h.y-l}}function Pet(t,e,r,n,i,a){var{left:o,top:s,width:c,height:u}=t.bounds,l={left:o,top:s,width:c,height:u};switch(e){case 0:o+=n,s+=i,c-=n,u-=i;break;case 1:s+=i,u-=i;break;case 2:s+=i,c+=n,u-=i;break;case 3:c+=n;break;case 4:c+=n,u+=i;break;case 5:u+=i;break;case 6:o+=n,c-=n,u+=i;break;case 7:o+=n,c-=n}if(t.mutateBounds((function(e){return Math.abs(c)<=.001&&(c=.001),Math.abs(u)<=.001&&(u=.001),t.adjustResize({left:o,top:s,width:c,height:u},l,r)}),this),t.isContainer()&&t.layout.ABSOLUTE&&!t.isGroup()){var h=l.left-o,f=l.top-s;a?t.components.forEach((t=>{t.delta("tx",0),t.delta("ty",0),t.move({x:h,y:f},!1)})):t.components.forEach((t=>{t.delta("tx",h),t.delta("ty",f)}))}else{var d=a&&t.parent;d&&d.isGroup()&&d.calculateBounds()}}function Oet(t,e){var{left:r,top:n,width:i,height:a}=t,o=r+i/2,s=n+a/2,c=r+i,u=n+a;const l=i*e.x>50,h=a*e.y>50;return[{x:r,y:n},l?{x:o,y:n}:null,{x:c,y:n},h?{x:c,y:s}:null,{x:c,y:u},l?{x:o,y:u}:null,{x:r,y:u},h?{x:r,y:s}:null]}class Iet{constructor(t){this.layer=t}reset(){this.active=null}get selected(){return this.layer.selected}contains(t,e,r,n){return!!r.resizable&&(Oet(r.bounds,n).every(((i,a)=>(i&&Math.abs(t-i.x)<=4/n.x&&Math.abs(e-i.y)<=4/n.y&&(this.active={component:r,index:a}),!this.active))),!!this.active)}draw(t,e,r){if(!e.isLine()){var{left:n,top:i,width:a,height:o}=e.bounds;if(t.beginPath(),t.rect(n-4/r.x,i-4/r.y,a+8/r.x,o+8/r.y),t.setLineDash([3/r.x,4/r.y]),t.lineWidth=1/r.x,t.strokeStyle="black",t.stroke(),t.setLineDash([]),e.resizable){var s=this.active;Oet(e.bounds,r).forEach(((n,i)=>{n&&(t.beginPath(),t.rect(n.x-4/r.x,n.y-4/r.y,8/r.x,8/r.y),t.setLineDash([0,0]),t.strokeStyle="#656565",t.stroke(),t.fillStyle="#fff",s&&s.component===e&&s.index===i&&(t.strokeStyle="#fa7703",s.focus&&(t.fillStyle="#ffb80c")),t.fill(),t.stroke())}))}}}onmousedown(t){this.active.focus=!0}ondragstart(t){var{component:e}=this.active;this.active.bounds=e.bounds,this.active.boundsList=this.layer.selected.filter((t=>t.resizable)).map((t=>t.bounds))}ondragmove(t){var{component:e,index:r,boundsList:n,bounds:i}=this.active,a=this.layer.transcoordC2S(t.offsetX,t.offsetY);e.bounds=i;var o=Tet(e,r,a);this.layer.selected.filter((t=>t.resizable)).forEach(((e,i)=>{e.bounds=n[i],Pet(e,r,t.shiftKey,o.dx,o.dy,!1)}))}ondragend(t){var{component:e,index:r,boundsList:n,bounds:i}=this.active,a=this.layer.transcoordC2S(t.offsetX,t.offsetY);e.bounds=i;var o=Tet(e,r,a);this.layer.selected.filter((t=>t.resizable)).forEach(((e,i)=>{e.bounds=n[i],Pet(e,r,t.shiftKey,o.dx,o.dy,!0)})),this.active.component.app.commander.execute(null,!1)}}const Cet=2*Math.PI,Ret=Math.PI/2;function jet(t,e){var r=t.bounds;return{x:r.left+r.width/2,y:r.top-20/e.y}}class Let{constructor(t){this.layer=t}reset(){this.active=null}get selected(){return this.layer.selected}contains(t,e,r,n){if(!r.rotatable)return!1;var i=jet(r,n);return Math.abs(t-i.x)<=4/n.x&&Math.abs(e-i.y)<=4/n.y&&(this.active={component:r},!0)}draw(t,e,r){if(e.rotatable){t.beginPath();var n=jet(e,r);t.lineWidth=1.5/r.x,t.moveTo(n.x,n.y+20/r.y),t.lineTo(n.x,n.y),t.strokeStyle="#656565",t.stroke(),t.beginPath(),t.ellipse(n.x,n.y,4/r.x,4/r.y,0,0,Cet,!0),t.stroke(),t.fillStyle="#fff",t.fill();var i=this.active;i&&i.component===e&&(t.strokeStyle="#fa7703",t.stroke(),i.toFill&&(t.fillStyle="#ffb80c",t.fill()))}}onmousedown(t){this.active.toFill=!0}ondragstart(t){var e=this.active;e.component,e.start_rotation=e.component.get("rotation"),e.rotations=this.layer.selected.filter((t=>t.rotatable)).map((t=>t.get("rotation")))}ondragmove(t){var{component:e}=this.active,r=e.transcoordC2S(t.offsetX,t.offsetY);r=e.transcoordS2P(r.x,r.y);var n=e.rotatePoint,i=e.get("rotation")||0,a=Math.atan((n.y-r.y)/(n.x-r.x)),o=(a=n.x>=r.x?a-Ret:Ret+a)-i;this.layer.selected.filter((t=>t.rotatable)).forEach(((e,r)=>{let n=((e.get("rotation")||0)+o)%Cet;e.set("rotation",e.adjustRotation(n,t.shiftKey))}))}ondragend(t){var{component:e,rotations:r}=this.active;e.app.commander.execute(null,!1)}}u9.register("modeling-layer",class extends z9{constructor(t,e){super(t,e),this.pathHandler=new Eet(this);var r=this.pathHandler,n=new Aet(this),i=new Iet(this),a=new Let(this);this._modelers=[r,n,i,a],this._control_mode_modelers=[n,r,i,a],this.focusOutline=new xet(this),this.groupOutline=new wet(this),this.anchorHandler=new Met(this),this._reversed_modelers=this._modelers.slice().reverse(),this._control_mode_reverse_modelers=this._control_mode_modelers.slice().reverse(),this.hovered=null,this.hoveredDest=null}get modelers(){return this._control_mode?this._control_mode_modelers:this._modelers}get reversedModelers(){return this._control_mode?this._control_mode_reverse_modelers:this._reversed_modelers}ready(){super.ready();var t=this.rootModel,e=t.get("translate"),r=t.get("scale");this.set("translate",e),this.set("scale",r)}contains(t,e){var r=this.selected.filter((t=>!!t.parent)),n=this.get("scale")||{x:1,y:1};if(this._state_dragging){if(this._counter_end){let r=this.anchorTarget.transcoordT2S(t,e);if(this.anchorHandler.contains(r.x,r.y,this.anchorTarget,n))return!0}return!0}this.modelers.forEach((t=>t.reset()));r=this.selected.filter((t=>!!t.parent));for(let i=0;i<r.length;i++){let a=r[i],o=a.transcoordT2S(t,e);for(let t=0;t<this.modelers.length;t++){let e=this.modelers[t];if(e.contains(o.x,o.y,a,n))return this.currentModeler=e,!0}}if(this.anchorTarget){let r=this.anchorTarget.transcoordT2S(t,e);if(this.anchorHandler.contains(r.x,r.y,this.anchorTarget,n))return this.currentModeler=this.anchorHandler,!0}else this.anchorHandler.reset();return this.currentModeler=null,!1}_componentDrawer(t,e,r,n){let i=[],a=e.parent;if(e.isRootModel())return t.save(),n(t,e,r),void t.restore();for(;a&&!a.isRootModel();)i.push(a),a=a.parent;t.save(),i.reverse().forEach((function(e){let r=e.rotatePoint;t.translate(r.x,r.y);let n=e.get("scale");n&&t.scale(n.x,n.y),t.rotate(e.get("rotation")),t.translate(-r.x,-r.y);let i=e.bounds;t.translate(i.left,i.top)}));let o=e.rotatePoint;t.translate(o.x,o.y);let s=e.get("scale");s&&t.scale(s.x,s.y),t.rotate(e.get("rotation")),t.translate(-o.x,-o.y),n(t,e,r),t.restore()}prerender(t){var{translate:e,scale:r={x:1,y:1},rotation:n}=this.model;t.save(),t.beginPath(),t.clearRect(0,0,t.canvas.width,t.canvas.height),t.rect(0,0,t.canvas.width,t.canvas.height),t.fillStyle="black",t.globalAlpha=.5,t.fill(),t.restore(),e&&t.translate(e.x*V8,e.y*V8),t.scale(r.x*V8,r.y*V8),n&&t.rotate(n),t.clearRect(0,0,this.rootModel.get("width"),this.rootModel.get("height"))}render(t){t.beginPath();var e=this.get("scale")||{x:1,y:1},r=this.selected.filter((t=>!!t.parent));if(this.focused&&this._componentDrawer(t,this.focused,e,((t,e,r)=>{this.focusOutline.draw(t,e,r)})),r.length>0&&r[0].parent.isGroup()){let n=r[0].parent;for(;n.parent.isGroup();)n=n.parent;this._componentDrawer(t,n,e,((t,e,r)=>{this.groupOutline.draw(t,e,r)}))}r.forEach((r=>{this._componentDrawer(t,r,e,((t,e,r)=>{this.reversedModelers.forEach((n=>n.draw(t,e,r)))}))})),this.anchorTarget&&this._componentDrawer(t,this.anchorTarget,e,((t,e,r)=>{this.anchorHandler.draw(t,e,r)}))}get anchorTarget(){return this.currentModeler===this.anchorHandler||this.currentModeler===this.pathHandler||this.hovered?.isLine()||(this._anchorTarget=this.hovered),this._anchorTarget}set anchorTarget(t){this._anchorTarget=t}get hovered(){return this._hovered}set hovered(t){this._hovered=t,this.invalidate()}startLinkProcess(t,e,r){this.currentModeler=this.pathHandler,this.processingLink=this.pathHandler.startLinkProcess(t,e,r),this.counterEnd=this.processingLink.fromEnd,this.processingLink.trigger("tag")}set counterEnd(t){this.currentModeler=this.pathHandler,this._counter_end=t}get counterEnd(){return this._counter_end}endLinkProcess(){this.processingLink?.trigger("tagreset"),this.processingLink=null,this._counter_end=null}get eventMap(){return{"model-layer":{"(all)":{change:this.onchange_model,wheel:this.onwheel_scale,drop:this.ondrop},"(descendant)":{mouseenter:this.onmouseenter,mouseleave:this.onmouseleave},"(self)":{dblclick:this.ondblclick_model}},"(root)":{"(self)":{selected:this.onselected,keydown:this.onkeydown,keyup:this.onkeyup}}}}onmouseenter(t,e){this.hovered=e?.origin}onmouseleave(t,e){this.hovered=null}onkeydown(t){"Alt"==t.key&&(this._control_mode=!0,this.invalidate())}onkeyup(t){"Alt"==t.key&&(this._control_mode=!1,this.invalidate())}onselected(t,e){this.invalidate()}onchange_model(t,e,r){var{origin:n,deliverer:i}=r;n===i&&(t.translate&&this.set("translate",t.translate),void 0!==t.rotation&&this.set("rotation",t.rotation),t.scale&&this.set("scale",t.scale)),this.invalidate()}ondblclick_model(t,e){const r=e.origin;r?.root.fit()}ondblclick(t){"function"==typeof this.currentModeler.ondblclick&&this.currentModeler.ondblclick(t),this.invalidate()}onmousedown(t){this.currentModeler.onmousedown(t),this.invalidate()}onmouseup(t){"function"==typeof this.currentModeler.onmouseup&&this.currentModeler.onmouseup(t),this.invalidate()}ondragstart(t){this.currentModeler.ondragstart(t),this._state_dragging=!0}ondragmove(t){this.currentModeler.ondragmove(t),this.invalidate()}ondragend(t){this._state_dragging=!1,this.currentModeler.ondragend(t),this.invalidate()}ondrop(t,e){var{origin:r}=e,n=t.dataTransfer.files;if(n.length<1)return;let i=this.rootModel.transcoordC2S(t.offsetX,t.offsetY),a=this.rootModel;Promise.all(Array.from(n).map((t=>new Promise(((e,r)=>{let n=new FileReader;n.addEventListener("loadend",(t=>{e(n.result)})),["error","abort"].forEach((t=>n.addEventListener(t,(t=>{r(t)})))),n.readAsDataURL(t)}))))).then((e=>{if(t.altKey)return stt.around(this.app.commander,(()=>{r.ondropfile(n,e)})),void(this.selected=[r]);let o=[],s=e.map(((t,e)=>{let r,s=n[e].type,c=n[e].name;return s.startsWith("image/")?(r=_tt({type:s.startsWith("image/gif")?"gif-view":"image-view",top:0,left:0,width:200,height:200,src:t},a.app),o.push(new Promise(((e,n)=>{let i=new Image;i.src=t,i.onload=()=>{r.set({width:i.width,height:i.height}),e()},i.onerror=t=>{n(t)}})))):s.startsWith("audio/")?r=_tt({type:"audio",top:0,left:0,width:100,height:100,src:t},a.app):s.startsWith("vnd.ms-excel/")||/\.xlsx?$/.test(c)?r=_tt({type:"excel",top:0,left:0,width:100,height:100,src:t},a.app):console.log("droped file",n[e]),r&&(r.center=i,i.x+=50,i.y+=50),r})).filter(Boolean).map((t=>({component:t,to_container:a})));s.length>0&&Promise.all(o).then((()=>{this.app.commander.execute(new xtt({changes:s})),this.selected=s.map((t=>t.component))}),(t=>{console.error(t)}))}),(t=>{console.error(t)}))}onwheel_scale(t,e){if(0!=t.deltaY||0!=t.deltaX){var r=e.deliverer;if(t.shiftKey){if(-1!=navigator.userAgent.indexOf("Win"))var n=t.deltaY<0?1:-1;else n=t.deltaX<0?1:-1;stt.around(this.app.commander,(()=>{r.selected.forEach((t=>{let e=t.get("fontSize")||J8.FONT_SIZE;e<1&&(e=1),e+=n,t.set("fontSize",e)}))}))}else{n=t.deltaY<0?1:-1;let e=r.get("scale")||{x:1,y:1},i=r.get("translate"),a=t.offsetX,o=t.offsetY,s=r.transcoordC2S(a,o),c=.1*n,u={x:e.x+c,y:e.y+c};if(n<0&&e.x<.2||n>0&&e.x>10)return;r.set("scale",u);let l=r.transcoordC2S(a,o);r.set("translate",{x:i.x+(l.x-s.x)*u.x,y:i.y+(l.y-s.y)*u.y})}}}});class Det extends z9{constructor(t,e){super(t,e),this._anim_alpha=1}animOnTargetChange(t){t!==this._lastTargets&&(this._lastTargets=t,this._anim_alpha=1,this.animate({step:t=>{this._anim_alpha=1-t,this.invalidate()},duration:5e3,delta:"circ",ease:"in"}).start())}decorate(t,e,r){const n=t.decorators;var i=!1;return n.map((t=>"string"==typeof t?r9(t):t)).filter((t=>t&&"function"==typeof t)).map((n=>{const a=n(t,e,1-r);i||=a})),i}render(t){var e=this.decoTargets&&this.decoTargets.filter((t=>t.rootModel));if(!e||0==e.length)return this._animate&&this._animate.stop(),void delete this._animate;t.globalAlpha*=this._anim_alpha;var r=!1;e.forEach((e=>{this.decorate(e,t,1-this._anim_alpha)&&(r=!0)})),r&&this.animOnTargetChange(this.decoTargets)}get decoTargets(){return this._decoTargets}set decoTargets(t){this._decoTargets=t&&t.filter((t=>!t.isLayer())),this.invalidate()}get eventMap(){return{"model-layer":{"(descendant)":{tag:this.ondecotag,tagreset:this.ondecotagreset,mouseenter:this.onmouseenter,mouseleave:this.onmouseleave}}}}onmouseenter(t,e){this._decotagreset(),this._ondecotag(e.origin)}onmouseleave(t,e){this._decotagreset()}ondecotagreset(t){this._decotagreset()}ondecotag(t){this._ondecotag(t.origin)}offdecotag(t,e){this._offdecotag(e.origin)}_ondecotag(t){this.decoTargets&&-1!==this.decoTargets.lastIndexOf(t)||(this.decoTargets=(this.decoTargets||[]).concat(t))}_offdecotag(t){if(this.decoTargets){var e=this.decoTargets.slice();e.splice(this.decoTargets.lastIndexOf(t),1),this.decoTargets=e}}_decotagreset(){this.decoTargets=[]}}u9.register("decotag-layer",Det),u9.register("tag-layer",Det);u9.register("reaction-layer",class extends z9{constructor(t,e){super(t,e),this._anim_alpha=1}animOnTargetChange(t){t!==this._lastTargets&&(this._lastTargets=t,this._anim_alpha=1,this.animate({step:t=>{this._anim_alpha=1-t,this.invalidate()},duration:1e4,delta:"circ",ease:"inout"}).start())}decorate(t,e,r){const n=t.reactionDecorators;var i=!1;return n.map((t=>"string"==typeof t?r9(t):t)).filter((t=>t&&"function"==typeof t)).map((n=>{const a=n(t,e,1-r);i||=a})),i}render(t){var e=this.targets&&this.targets.filter((t=>t.rootModel));if(!e||0==e.length)return this._animate&&this._animate.stop(),void delete this._animate;t.globalAlpha*=this._anim_alpha;var r=!1;e.forEach((e=>{this.decorate(e,t,1-this._anim_alpha)&&(r=!0)})),r&&this.animOnTargetChange(this.targets)}get targets(){return this._targets}set targets(t){this._targets=t&&t.filter((t=>!t.isLayer())),this.invalidate()}get eventMap(){return{"model-layer":{"(descendant)":{reaction:this.onreaction,reactionreset:this.onreactionreset}}}}onreactionreset(t){this._reactionreset()}onreaction(t){this._onreaction(t.origin)}offreaction(t,e){this._offreaction(e.origin)}_onreaction(t){this.targets&&-1!==this.targets.lastIndexOf(t)||(this.targets=(this.targets||[]).concat(t))}_offreaction(t){if(this.targets){var e=this.targets.slice();e.splice(this.targets.lastIndexOf(t),1),this.targets=e}}_reactionreset(){this.targets=[]}});function zet(){var t=arguments,e=t[t.length-1],r=this.event_pump;r.listeners.forEach((n=>{!function(t,e,r,n,i){for(let a in r){let o=r[a];if(n7(a,n.origin,0,t))for(let t in o){let r=o[t];t==n.name&&(n.listener=e,r.apply(e,i))}}}(r.deliverer,n.listener,n.cloned_handlers,e,t)}))}u9.register("scroll-layer",class extends z9{get capturable(){return!0}render(t){const{scrolling:e}=this.state;if(t.save(),t.beginPath(),t.fillStyle="#777",this.vscroller){const{left:r,top:n,width:i,height:a}=this.vscroller;t.globalAlpha="v"==e?1:.3,t.fillRect(r,n,i,a)}if(this.hscroller){const{left:r,top:n,width:i,height:a}=this.hscroller;t.globalAlpha="h"==e?1:.3,t.fillRect(r,n,i,a)}t.stroke(),t.restore()}resize(){super.resize(),this.calcScrollerBounds()}contains(t,e){const r=this.vscroller,n=this.hscroller;return this.setState("scrolling",r&&t>=r.left&&t<=r.left+r.width&&e>=r.top&&e<=r.top+r.height?"v":n&&t>=n.left&&t<=n.left+n.width&&e>=n.top&&e<=n.top+n.height?"h":null),!!this.getState("scrolling")}get eventMap(){return{"(root)":{"model-layer":{change:this.onchangeModelLayer}}}}onchange(t){"scrolling"in t&&this.invalidate()}ondragstart(t,e){this.lastPosition={x:t.offsetX,y:t.offsetY}}ondragmove(t,e){const r=this.root,{clientWidth:n,clientHeight:i}=this.canvas,{width:a,height:o}=this.rootModel.model,{x:s,y:c}={x:t.offsetX,y:t.offsetY},{x:u,y:l}=this._scale,{scrolling:h}=this.state,f=a/n,d=o/i;h&&r.rootModel.move({x:"h"==h?(-s+this.lastPosition.x)*u*f:0,y:"v"==h?(-c+this.lastPosition.y)*l*d:0},!1),this.lastPosition={x:t.offsetX,y:t.offsetY}}ondragend(){delete this.lastPosition,this.setState({scrolling:null})}calcScrollerBounds(){var{clientWidth:t,clientHeight:e}=this.canvas;const{width:r,height:n}=this.rootModel.model,{x:i=1,y:a=1}=this._scale||{},{x:o=0,y:s=0}=this._translate||{},c=r/t,u=n/e;var l={left:-o/i/c,top:e-10,width:t/i/c,height:10};this.hscroller=l.left>1||l.width+l.left<t-1?l:null,l={left:t-10,top:-s/a/u,width:10,height:e/a/u},this.vscroller=l.top>1||l.height+l.top<e-1?l:null,this.invalidate()}onchangeModelLayer(t,e,r){if(t.scale){const{x:e=1,y:r=1}=t?.scale||{};this._scale={x:e,y:r},this.calcScrollerBounds()}if(t.translate){const{x:e=0,y:r=0}=t.translate||{};this._translate={x:e,y:r},this.calcScrollerBounds()}}});class Fet{constructor(t){if(void 0===t.on)throw new Error("Deliverer should be a event handlable object.");this.deliverer=t,this.listeners=[]}start(){this.deliverer.on("(all)",zet,{event_pump:this})}stop(){this.deliverer.off("(all)",zet)}on(t,e){var r=Object.assign({},e);Object.keys(r).forEach((e=>{if(0==e.indexOf("?")){let n=r[e],i=e.substr(1),a=t.get(i);delete r[e],a?r[a]=n:D8("EventPump#on","variable #{selector} is not evaluated on listener")}})),this.listeners.push({listener:t,handlers:e,cloned_handlers:r})}off(t,e){for(let r=0;r<this.listeners.length;r++){let n=this.listeners[r];n.listener!==t||e&&n.handlers!==e||this.listeners.splice(r,1)}}clear(){this.listeners=[]}dispose(){this.stop(),this.clear()}}class Net{constructor(t){this.eventMaps=[],this.root=t,t.eventMap&&this.add(t,t.eventMap)}set root(t){this._root=t}get root(){return this._root}stop(){this.eventMaps.forEach((t=>t.eventPump.stop()))}add(t,e){if(this.root)for(let r in e){let n=e[r];if("(self)"===r&&void 0===t.on)throw new Error("(self) selector not available when deliverer is not a event handlable object.");o7(r,this.root,t).forEach((r=>{var i=new Fet(r);i.on(t,n),i.start(),this.eventMaps.push({eventPump:i,listener:t,handlerMap:e,deliverer:r})}))}}remove(t,e){var r=this.eventMaps.slice(0);for(let n=0;n<r.length;n++){let i=r[n];i.listener!==t||e&&i.handlerMap!==e||(this.eventMaps.splice(n,1),i.eventPump.dispose())}}clear(){this.eventMaps.slice(0).forEach((t=>t.eventPump.dispose())),this.eventMaps=[]}dispose(){this.stop(),this.clear()}}const Bet=0,Uet=1,Yet=2,Get=0,Wet=1,Het=2;var qet={},Xet=0;class Vet{constructor(t,e){this._type=e||t.type,this._ctrlKey=t.ctrlKey,this._altKey=t.altKey,this._shiftKey=t.shiftKey,this._metaKey=t.metaKey;var r=function(t){if(t.touches){let e=t.touches[0];if(!e)return qet;let r=e.target.getBoundingClientRect();return qet={x:t.offsetX||e.clientX-(r.x||r.left),y:t.offsetY||e.clientY-(r.y||r.top)}}return{x:t.offsetX,y:t.offsetY}}(t);if(this._offsetX=r.x,this._offsetY=r.y,"wheel"==t.type)this.deltaX=t.deltaX,this.deltaY=t.deltaY,this.deltaZ=t.deltaZ;else if("drop"==t.type)this.dataTransfer=t.dataTransfer;else if(t.type.match(/^touch/)&&(this._scale=t.scale,this._touches=t.touches,this._changedTouches=t.changedTouches,null==this._scale)){var n=function(t){var e,r,n=0,i=0,a=0;if(1===t.touches.length)return a;Array.from(t.touches).forEach((t=>{e=null!=e?Math.min(t.screenX,e):t.screenX,n=Math.max(t.screenX,n),r=null!=r?Math.min(t.screenY,r):t.screenY,i=Math.max(t.screenY,i)}));var o=n-e||0,s=i-r||0;return Math.sqrt(Math.pow(o,2)+Math.pow(s,2))||0}(t);Xet>0&&(this._scale=n/Xet),Xet=n}}get type(){return this._type}set type(t){this._type=t}get offsetX(){return this._offsetX}get offsetY(){return this._offsetY}get altKey(){return this._altKey}get ctrlKey(){return this._ctrlKey}get shiftKey(){return this._shiftKey}get metaKey(){return this._metaKey}get touches(){return this._touches}get changedTouches(){return this._changedTouches}get scale(){return this._scale}stopPropagation(){this._stop_=!0}isPropagationStopped(){return this._stop_}}function Qet(t,e){return t.capture(e.offsetX,e.offsetY)}function Ket(t,e,r){if(t&&t.app&&(!t.app.isViewMode||!t.hidden)){r instanceof Vet&&e===r.type||(r=new Vet(r,e));var n="on"+e;t[n]&&t[n](r),r.isPropagationStopped()||t.trigger(e,r)}}class Jet{constructor(t,e){this.container=t,this.html_element=e,this.status=Bet,this.last_target=null,this.gesture_handlers=Q8.map((t=>this.gestureHandlerBuilder(t))),this.keyevent_handlers=K8.map((t=>this.keyeventHandlerBuilder(t))),Q8.forEach(((t,r)=>e.addEventListener(t,this.gesture_handlers[r]))),K8.forEach(((t,r)=>e.addEventListener(t,this.keyevent_handlers[r]))),e.ondragover=this.gestureHandlerBuilder("dragover"),e.ondrop=this.gestureHandlerBuilder("drop"),e.tabIndex=1}dispose(){this.last_enter_target&&Ket(this.last_enter_target,"mouseleave",new CustomEvent("mouseleave")),Q8.forEach(((t,e)=>this.html_element.removeEventListener(t,this.gesture_handlers[e]))),K8.forEach(((t,e)=>this.html_element.removeEventListener(t,this.keyevent_handlers[e]))),delete this.gesture_handlers,delete this.keyevent_handlers,delete this.last_target}gestureHandlerBuilder(t){var e=this[`on${t}`].bind(this);return t=>(e(new Vet(t))&&t.preventDefault(),!1)}keyeventHandlerBuilder(t){return this[`on${t}`].bind(this)}ondragover(t){return Ket(Qet(this.container,t),t.type,t),!1}ondrop(t){return Ket(Qet(this.container,t),t.type,t),!1}ondblclick(t){return Ket(Qet(this.container,t),t.type,t),this.last_target=null,!1}onkeydown(t){return this.container.trigger(t.type,t),!1}onkeyup(t){return this.container.trigger(t.type,t),!1}onmousemove(t){switch(this.status){case Uet:let r=t.offsetX-this.__dragstart_e.offsetX,n=t.offsetY-this.__dragstart_e.offsetY;if(r*r+n*n<16)break;this.status=Yet,Ket(this.last_target,"dragstart",this.__dragstart_e),this.__dragmove_e=t,Ket(this.last_target,"dragmove",t);break;case Yet:this.__dragmove_e=t,Ket(this.last_target,"dragmove",t);break;default:var e=Qet(this.container,t);this.last_enter_target!==e&&(this.last_enter_target&&Ket(this.last_enter_target,"mouseleave",t),e&&Ket(e,"mouseenter",t),this.last_enter_target=e),Ket(e,t.type,t),this.last_target=e}return!1}onmousedown(t){if(this.status===Yet)Ket(this.last_target,"dragend",t),this.last_target=null,this.status=Bet;else{var e=Qet(this.container,t);this.last_target=e,this.status=Uet,this.__dragstart_e=t,Ket(e,t.type,t)}return!1}onmouseup(t){if(this.status===Yet)Ket(this.last_target,"dragend",t);else{var e=Qet(this.container,t);Ket(e,t.type,t),this.last_target===e&&Ket(e,"click",t)}return this.last_target=null,this.status=Bet,!1}onmouseout(t){var e=Qet(this.container,t);if(this.status===Yet)Ket(this.last_target,"dragend",t);else{if(this.last_target&&this.last_target===e)return;this.last_enter_target&&(Ket(this.last_enter_target,"mouseleave",t),delete this.last_enter_target)}return this.last_target=null,this.status=Bet,!1}ontouchstart(t){var e=Qet(this.container,t);return this.last_target=e,this.status=Wet,this.touchPoints||(this.touchPoints=[]),this.touchPoints.push(t.changedTouches[0]),this.holdTimer=setTimeout((()=>{this.status=Get,Ket(this.last_target,"hold",t),delete this.holdTimer}),500),Ket(e,t.type,t),!1}ontouchmove(t){if(!t.touches||!t.changedTouches)return Ket(this.last_target,"dragstart",t),Ket(this.last_target,"dragmove",t),!1;var e=Qet(this.container,t);switch(this.status){case Wet:Array.from(t.changedTouches).forEach((t=>{var e=this.touchPoints.find((e=>e.identifier===t.identifier));if(e){var r=e.clientX-t.clientX,n=e.clientY-t.clientY;return Math.sqrt(Math.pow(r,2)+Math.pow(n,2))>=16?(this.status=Het,void(this.holdTimer&&(clearTimeout(this.holdTimer),delete this.holdTimer))):void 0}}));break;case Het:if(this.holdTimer&&(clearTimeout(this.holdTimer),delete this.holdTimer),2===t.changedTouches.length&&null!=t.scale&&1!==t.scale&&(t.scale<.9||t.scale>1.1))return Ket(this.last_target,"pinch",t),!1;Ket(this.last_target,"pan",t),e=this.last_target;break;default:this.last_enter_target!==e&&(this.last_enter_target&&Ket(this.last_enter_target,"mouseleave",t),e&&Ket(e,"mouseenter",t),this.last_enter_target=e),this.last_target=e}return Ket(e,"touchmove",t),!1}ontouchend(t){var e=Qet(this.container,t);switch(this.status){case Het:e=this.last_target;break;case Wet:var r=performance.now(),n=r-this.touchedAt;this.holdTimer&&(clearTimeout(this.holdTimer),delete this.holdTimer,Ket(e,n<500?"doubletap":"tap",t),this.touchedAt=r)}Ket(e,"touchend",t);var i=this.touchPoints.findIndex((e=>e.identifier===t.changedTouches[0].identifier));return this.touchPoints.splice(i,1),this.last_target=null,this.status=Get,!1}onwheel(t){return Ket(Qet(this.container,t),t.type,t),!1}}function Zet(t,e,r){if(e.length<2)return e;for(var n=2;n<e.length;n++){var i=e.substring(0,n);if(!(t.measureText(i).width<r))break}return e.substring(0,n-1)}function $et(t,e,r,n){var i=String(e).split("\n");return n?[].concat.apply([],i.map((e=>function(t,e,r){var n,i,a=e.split(" "),o=[],s=[];for(n=0,i=1;i<=a.length;i++)if(s=a.slice(n,i),t.measureText(s.join(" ")).width>r){if(i-n==1){let e=Zet(t,s[0],r);o.push([e]),a.splice(n,1,e,s[0].substring(e.length))}else{for(;""==a[i-1];)i++;o.push(a.slice(n,--i))}n=i}return i-n>1&&o.push(s),0==o.length&&o.push([""]),o}(t,e,r)))):i.map((t=>t.split(" ")))}var trt={};var ert={register:function(t,e){trt[t]=e},unregister:function(t){delete trt[t]},get:function(t){return trt[t]}};function rrt(t){if(!t.hasTextProperty||t.textHidden)return;var{text:e="",bold:r=J8.BOLD,italic:n=J8.ITALIC,textWrap:i=J8.TEXT_WRAP,fontFamily:a=J8.FONT_FAMILY,fontColor:o=J8.FONT_COLOR,textAlign:s=J8.TEXT_ALIGN,textBaseline:c=J8.TEXT_BASELINE,fontSize:u=J8.FONT_SIZE,lineHeight:l=1.2*u}=t.model,{left:h,top:f,width:d,height:p}=t.textBounds;u||=J8.FONT_SIZE,l||=1.2*u,t.textHidden=!0;var g=document.createElement("textarea");Q8.forEach((function(t){g.addEventListener(t,(function(t){t.stopPropagation()}),!0)}));const v=t.transcoordS2C(h,f),{rotation:y,scale:m}=function(t){for(var e=0,r=1,n=t;n;){e+=n.get("rotation")||0;let{x:t,y:i}=n.get("scale")||{x:1,y:1};r*=Math.max(t,i)||1,n=n.parent}return{rotation:e,scale:r}}(t);switch(g.style.position="absolute",g.style.width=d+"px",g.style.height=p+"px",g.style.padding="0",g.value=e,g.style.fontFamily=a,g.style.fontSize=u+"px",g.style.lineHeight=l+"px",g.style.overflow="hidden",g.style.resize="none",g.style.outline="none",g.style.border=0,g.style.backgroundColor="transparent",g.style.display="inline-block",g.style.color=o,r&&(g.style.fontWeight="bold"),n&&(g.style.fontStyle="italic"),s){case"right":case"end":g.style.textAlign="right";break;case"justify":g.style.textAlign="justify";break;case"left":case"start":g.style.textAlign="left";break;default:g.style.textAlign="center"}var b=[r,n,u+"px",a].filter(Boolean).join(" ");function x(e){var r={left:0,top:0},n=l*function(t,e,r,n){var i,a=t.getContext();return a.save(),a.font=r,i=$et(a,e,n,t.get("textWrap")).length,a.restore(),i}(t,e,b,d);switch(g.style.height=n+"px",c){case"top":case"hanging":break;case"bottom":case"alphabetic":r.top=p-n;break;default:r.top=p/2-n/2}if(!i){var a=function(t,e,r,n){var i=e.split("\n"),a=n;let o=t.getContext();return o.save(),o.font=r,i.forEach((t=>{let e=o.measureText(t).width;e>a&&(a=e)})),o.restore(),a}(t,e,b,d);switch(g.style.width=a+"px",s){case"right":case"end":r.left=d-a;break;case"left":case"start":break;default:r.left=(d-a)/2}}g.style.marginLeft=r.left+"px",g.style.marginTop=r.top+"px";var o=`translate(${v.x}px, ${v.y}px) scale(${m}) rotate(${y}rad)`;["-webkit-","-moz-","-ms-","-o-",""].forEach((t=>{g.style[t+"transform"]=o,g.style[t+"transform-origin"]=`${-r.left}px ${-r.top}px`}))}x(e);var w=t.root.target_element;w.appendChild(g),g.select();var A,_=!1;g.addEventListener("keydown",(function(t){t.stopPropagation(),"Escape"!=t.code&&(t.shiftKey||"Enter"!=t.code&&"NumpadEnter"!=t.code)?setTimeout((()=>{x(g.value)})):(_=A.skipUpdate="Escape"==t.code,document.createEvent?g.dispatchEvent(A):g.fireEvent(A.eventType,A))})),document.createEvent?(A=document.createEvent("HTMLEvents")).initEvent("blur",!0,!1):(A=document.createEventObject()).eventType="blur";var k=t.root.selected,E=function(r){t.root.selected=k,t.textHidden=!1,g.removeEventListener("blur",E,!1),g.parentElement&&g.parentElement.removeChild(g),w.focus(),r.skipUpdate||_||t.app.commander.execute(new stt({changes:[{component:t,before:{text:e},after:{text:g.value}}]}))};g.addEventListener("blur",E,!1)}ert.register("text-editor",{"(root)":{"(self)":{keydown:function(t,e){var{origin:r,deliverer:n}=e,i=n.selected;return!(1!==i.length||!i[0].hasTextProperty)&&(("Enter"==t.code||"NumpadEnter"==t.code)&&(rrt(i[0]),t.preventDefault(),!0))}}},"model-layer":{"(descendant)":{dblclick:function(t,e){rrt(e.origin)}}}});var nrt,irt,art,ort=f8((function(t,e,r){if(t.hasSameParentForAllSelected&&!r){var n=[];e[0].parent.isGroup()?t.focused=e[0].parent:(e.forEach((t=>{t.path.forEach((e=>{n.push(t.transcoordS2T(e.x,e.y))}))})),t.focused=t.capturePath(n,e))}else t.focused=null}),300);ert.register("move-handler",{"model-layer":{"(descendant)":{dragstart:function(t,e){var{origin:r,deliverer:n}=e;if(!r.stuck){var i=n.selected,a=n.selected.filter((t=>!t.stuck));if(i.length!==a.length&&(i=n.selected=a),0!=i.length){var o=i[0].transcoordC2S(t.offsetX,t.offsetY);if(o=i[0].transcoordS2P(o.x,o.y),this.last_pos=o,this.direction=0,n.focused=i[0].parent,t.altKey){var s=[],c=new Map;n.selected=n.selected.filter((t=>!t.isRootModel())).map((t=>{let e=ktt(t,(t=>{const e=n.root.getNewRefid();return void 0!==t&&c.set(t,e),e}));return s.push({component:e,to_container:t.parent}),e})).map((t=>(t.replaceRefids(c),t))),s.forEach((({component:t,to_container:e})=>{e.addComponent(t)})),this.duplicates=n.selected.map((t=>({component:t})))}else this.changes=stt.before(i)}}},dragmove:function(t,e){var{origin:r,deliverer:n}=e;if(!r.stuck){var i=n.selected;if(0!=i.length){var{x:a,y:o}=i[0].transcoordC2S(t.offsetX,t.offsetY),s=i[0].transcoordS2P(a,o);t.shiftKey?2==this.direction&&(this.direction=0):this.direction=2;var c=s.x-this.last_pos.x,u=s.y-this.last_pos.y;if(0==this.direction){if(c*c+u*u<25)return;Math.abs(c)>Math.abs(u)?this.direction=3:this.direction=4}3==this.direction?u=0:4==this.direction&&(c=0),i.forEach((t=>{t.move({x:c,y:u},1===i.length)})),this.last_pos=s,ort(n,i)}}},dragend:function(t,e){var{origin:r,deliverer:n}=e;if(!r.stuck){var i=n.selected;if(0!=i.length){var a=i[0].parent,o=n.focused||e.deliverer;if(this.changes&&!o.isGroup())if(n.hasSameParentForAllSelected&&o&&o!==a){var s=this.changes.map((t=>{let{component:e,before:r}=t;return{component:e,to_container:o}}));n.app.commander.execute(new xtt({changes:s}))}else stt.after(this.changes,n.app.commander);else if(this.duplicates){this.duplicates=this.duplicates.map((t=>(t.to_container=o,t)));let t=new xtt({changes:this.duplicates});n.app.commander.execute(t)}i.forEach((t=>{t.parent&&t.parent.calculateBounds&&t.parent.calculateBounds()})),this.last_pos=null,this.changes=null,this.duplicates=null,ort(n,i,!0)}}}}},"(root)":{"(self)":{keydown:function(t,e){var{origin:r,deliverer:n}=e,i={},a=t.shiftKey?r.rootModel.MPP:1;switch(t.which){case 37:i.x=-a,i.y=0;break;case 38:i.x=0,i.y=-a;break;case 39:i.x=a,i.y=0;break;case 40:i.x=0,i.y=a;break;default:return}var o=n.selected;stt.around(n.app.commander,(function(){o.forEach((t=>{!t.stuck&&t.move(i,!1)}))}))}}}});const srt=d8((()=>{const{x:t,y:e}=art,r=irt.deref();r&&(r.rootModel.move({x:t-nrt.x,y:e-nrt.y},!1),nrt={x:t,y:e})}),60,{leading:!0,trailing:!0});ert.register("shift-handler",{"model-layer":{"(all)":{dragstart:function(t,e){nrt={x:t.offsetX,y:t.offsetY}},dragmove:function(t,e){irt=new WeakRef(e.deliverer),art={x:t.offsetX,y:t.offsetY},srt()}}}}),ert.register("zoom-handler",{"model-layer":{"(all)":{wheel:function(t,e){if(0==t.deltaY&&0==t.deltaX)return;var r=e.deliverer,n=t.deltaY<0?1:-1;let i=r.get("scale")||{x:1,y:1},a=r.get("translate"),o=t.offsetX,s=t.offsetY,c=r.transcoordC2S(o,s),u=.1*n,l={x:i.x+u,y:i.y+u};if(n<0&&i.x<.2||n>0&&i.x>10)return;r.set("scale",l);let h=r.transcoordC2S(o,s);r.set("translate",{x:a.x+(h.x-c.x)*l.x,y:a.y+(h.y-c.y)*l.y})}},"(self)":{dblclick:function(t,e){const r=e.origin;r?.root.fit()}}}});var crt={},urt={};function lrt(t){const e={};for(const r in t)t.hasOwnProperty(r)&&void 0!==t[r]&&(e[r]=t[r]);return e}ert.register("paste-handler",{"(root)":{"(self)":{stylepastestart:function(t){const{deliverer:e}=t,r=e.app;var n=e.selected;if(n&&n[0]&&n!==e.rootModel){const t=n[0],{fillStyle:e,strokeStyle:i,alpha:a,lineWidth:o,lineDash:s,lineCap:c,lineJoin:u,fontColor:l,fontSize:h,fontFamily:f,bold:d,italic:p,textAlign:g,textBaseline:v,textOverflow:y,paddingTop:m,paddingBottom:b,paddingLeft:x,paddingRight:w}=t.state;crt=Z6({fillStyle:e,strokeStyle:i,alpha:a,lineWidth:o,lineDash:s,lineCap:c,lineJoin:u,fontColor:l,fontSize:h,fontFamily:f,bold:d,italic:p,textAlign:g,textBaseline:v,textOverflow:y,paddingTop:m,paddingBottom:b,paddingLeft:x,paddingRight:w}),r.mode=4}},stylepastestop:function(t){const{deliverer:e}=t,r=e.app;crt={},4==r.mode&&(r.mode=1)},databindpastestart:function(t){const{deliverer:e}=t,r=e.app;var n=e.selected;if(n&&n[0]&&n!==e.rootModel){const t=n[0],{mappings:e}=t.state;urt=Z6({mappings:e}),r.mode=5}},databindpastestop:function(t){const{deliverer:e}=t,r=e.app;urt={},5==r.mode&&(r.mode=1)},keydown:function(t,e){const{deliverer:r}=e;"Esc"!=t.code&&"Escape"!=t.code||(4==r.app.mode?r.trigger("stylepastestop"):5==r.app.mode&&r.trigger("databindpastestop"))}}},"model-layer":{"(all)":{click:function(t,e){const{deliverer:r}=e,n=r.app;if(4!=n.mode&&5!=n.mode)return;const i=e.origin;4==n.mode?i===r?r.root.trigger("stylepastestop"):i&&stt.around(n.commander,(()=>{const t=lrt({...i.model,...crt});i?.set(t)})):i===r?r.root.trigger("databindpastestop"):i&&stt.around(n.commander,(()=>{const t=lrt({...i.model,...urt});i?.set(t)}))}}}});var hrt=[],frt=f8((function(){hrt.forEach((t=>{t.resize()}))}),100);"undefined"!=typeof window&&window.addEventListener("resize",frt);class drt extends D9{constructor(t,e){super(Object.assign({type:"root",scale:{x:1,y:1}},t||{}),e),this._maxRefid=e.isViewMode?1e6:0,t=t||{},this.fitMode=t.model&&t.model.fitMode,this._app=e,this.style=t.style,this.target_element=t.target_element,this.rebuildContentModel(this.model.model),hrt.push(this)}dispose(){k9.hideAll(this),this._app&&this._app.dispose(),super.dispose(),this._disposeAllResources(),this.target_element=null,delete this._refresh_mapping_debouncer;var t=hrt.indexOf(this);t>=0&&hrt.splice(t,1),this.refidIndexMap.clear(),this._maxRefid=0}isRoot(){return!0}get app(){return this._app}get target_element(){return this._target_element}set target_element(t){this._ua_event_handler&&(this._ua_event_handler.dispose(),delete this._ua_event_handler),t&&(t.style.position="absolute",t.style.cursor="default",t.style.overflow="hidden",this._ua_event_handler=new Jet(this,t)),this.forEach((e=>e.target=t)),this._target_element=t}get unitScale(){switch(this.model_layer&&this.model_layer.get("unit")){case"mm":case"cm":case"in":return this.app.PPM/10;default:return 1}}addTemplate(t,e){var r=this.templateMap[t];r&&L8("Template replaced (duplicated)",t,e,r),this.templateMap[t]=e,delete this.templatePrefixes}removeTemplate(t,e){var r=this.templateMap[t];r!==e?D8("Removing template failed (different)",t,e,r):delete this.templateMap[t],delete this.templatePrefixes}findTemplateFor(t){this.templatePrefixes||(this.templatePrefixes=Object.keys(this.templateMap).sort().reverse());var e=this.templatePrefixes.find((e=>t.startsWith(e)));if(e)return this.templateMap[e]}addIndex(t,e){var r=this.indexMap[t]||[];this.indexMap[t]=[...r,e]}removeIndex(t,e){const r=this.indexMap[t]||[],n=r.indexOf(e);-1==n?D8("Removing index failed (not found)",t,e):(r.splice(n,1),0==r.length&&delete this.indexMap[t])}addRefidIndex(t,e){null==t&&(t=this.getNewRefid(),e.set("refid",t)),this._maxRefid=Math.max(t,this._maxRefid);var r=this.refidIndexMap.get(t);r&&L8("Refid Index replaced (has not to be)",t,e,r),this.refidIndexMap.set(t,e)}removeRefidIndex(t,e){if(null!=t){var r=this.refidIndexMap.get(t);r!==e?L8("Refid Removing index failed (has not to be)",t,e,r):this.refidIndexMap.delete(t)}}getNewRefid(){return this._maxRefid=(this._maxRefid||0)+1,this._maxRefid}async subscribe(t,e){this._app.isViewMode&&t&&this._app&&(e._subscription=await this._app.subscribe(t,e))}async unsubscribe(t,e){e._subscription&&(await e._subscription.unsubscribe(),delete e._subscription)}findById(t){return(this.indexMap[t.replace(/^#/,"")]||[])[0]}findAllById(t){return this.indexMap[t.replace(/^#/,"")]||[]}findByRefid(t){return this.refidIndexMap.get(t)}findOrCreate(t){var e=this.findAllById(t);if(!e&&this.app&&!this.app.isEditMode){let e=this.findTemplateFor(t);if(e){let r=Object.assign(Z6(e.hierarchy),{id:t,templatePrefix:""});return component=_tt(r,this.app),this.model_layer.addComponent(component),[component]}}return e}resize(){this.components.forEach((t=>{t.resize&&t.resize()})),this.invalidate()}_disposeAllResources(){this.selected=[],this._focused=null,this._ready=!1,this.eventEngine&&(this.assist_handlers&&this.assist_handlers.forEach((t=>{this.eventEngine.remove(t)})),this.eventEngine.dispose(),delete this.eventEngine),this.assist_layers&&this.assist_layers.forEach((t=>{t.dispose(),this.removeComponent(t)})),delete this.assist_layers,this.model_layer&&this.model_layer.dispose(),this.model_layer&&this.removeComponent(this.model_layer),delete this.model_layer,this.indexMap={},this.refidIndexMap=new Map,this.templateMap={}}rebuildContentModel(t){this._disposeAllResources(),this.eventEngine=new Net(this),(t=t||{}).type="model-layer",this.model_layer=_tt(t,this.app),this.addComponent(this.model_layer),this.model_layer.target=this.target_element,this.assist_layers=(this.model.layers||[]).map((t=>{var e=_tt(t,this.app);return this.addComponent(e),e.target=this.target_element,e})),this.assist_handlers=(this.model.handlers||[]).map((t=>{var e={};return this.eventEngine.add(e,ert.get(t)),e})),this._ready=!0,this.traverse((t=>t.ready()))}get root(){return this}get anchors(){}get isReady(){return this._ready}get rootModel(){return this.model_layer}get stuck(){return!0}get data(){return Object.values(this.indexMap).reduce(((t,[e])=>(t[e.model.id]=e.data,t)),{})}set data(t){for(var e in t){var r=this.findOrCreate(e);r&&r.forEach((r=>r.data=t[e]))}}get dataByRefid(){var t={};for(let[e,r]of this.refidIndexMap.entries())t[e]=r.data;return t}set dataByRefid(t){for(var e in t){var r=this.findByRefid(Number(e));r&&(r.data=t[e])}}get values(){return Object.values(this.indexMap).reduce(((t,[e])=>(t[e.model.id]=e.value,t)),{})}set values(t){for(var e in t){var r=this.findOrCreate(e);r&&r.forEach((r=>r.value=t[e]))}}get valuesByRefid(){var t={};for(let[e,r]of this.refidIndexMap.entries())t[e]=r.value;return t}set valuesByRefid(t){for(var e in t){var r=this.findByRefid(Number(e));r&&(r.value=t[e])}}get selected(){return(this._selected||[]).filter((t=>t.parent))}set selected(t){var e=this._selected;if(this._selected=t,!t||t.length<=1)this.hasSameParentForAllSelected=!0;else{let e=t[0].parent;this.hasSameParentForAllSelected=!t.find((t=>t.parent!=e))}this.trigger("selected",t,e)}get focused(){return this._focused}set focused(t){this._focused!==t&&(this._focused=t,this.invalidate())}get style(){return this._style}set style(t){this._style=t,this._compiled_style=t}get hasTextProperty(){return!1}render(){this.components.forEach((t=>t.draw()))}contains(t,e){return!0}capturePath(t,e){return this.model_layer.capturePath(t,e)}invalidate(){this.components.forEach((t=>t.invalidate()))}get eventMap(){return{"(root)":{"(descendant)":{added:this.onadded,removed:this.onremoved,change:this.onchanged}}}}refreshMappings(){if(!this._refresh_mapping_debouncer){if(this.disposed)return;this._refresh_mapping_debouncer=f8((function t(e){e.executeMappings(),e.components&&e.components.forEach((e=>t(e)))}),1e3)}this._refresh_mapping_debouncer(this.model_layer)}_addTraverse(t){t.components&&t.components.forEach((t=>this._addTraverse(t)));var{id:e,refid:r,tag:n,templatePrefix:i}=t.model;this.addRefidIndex(r,t),e&&this.addIndex(e,t),n&&this.subscribe(n,t),i&&this.addTemplate(i,t);var a=A8({},t.eventMap,t.model.eventMap);this.eventEngine.add(t,a)}_removeTraverse(t){t.components&&t.components.forEach((t=>this._removeTraverse(t)));var{id:e,refid:r,tag:n,templatePrefix:i}=t.model;this.removeRefidIndex(r,t),e&&this.removeIndex(e,t),n&&this.unsubscribe(n,t),i&&this.removeTemplate(i,t),this.eventEngine.remove(t)}onadded(t,e){this._addTraverse(e),this.refreshMappings(),this.invalidate()}onremoved(t,e){this._removeTraverse(e),this.invalidate()}onchanged(t,e,r){e.templatePrefix&&this.removeTemplate(e.templatePrefix,r.origin),t.templatePrefix&&this.addTemplate(t.templatePrefix,r.origin),e.id&&this.removeIndex(e.id,r.origin),t.id&&this.addIndex(t.id,r.origin),e.tag&&this.unsubscribe(e.tag,r.origin),t.tag&&this.subscribe(t.tag,r.origin),e.id==t.id&&e.class==t.class||this.refreshMappings()}}Object.assign(drt.prototype,{fit:function(t){var{width:e,height:r,fitMode:n}=this.model_layer.model,i=this.target_element,a=this.model_layer;if(this.fitMode=t||this.fitMode||n||"ratio",e&&r&&i&&i.clientWidth&&i.clientHeight){switch(this.fitMode){case"center":!function(t,e,r){var n=t.unitScale,{width:i,height:a}=e.model;e.set("scale",{x:n,y:n}),e.set("translate",{x:Math.max((r.clientWidth-i*n)/2,0),y:Math.max((r.clientHeight-a*n)/2,0)})}(this,a,i);break;case"both":!function(t,e,r){var{width:n,height:i}=e.model,a=r.clientWidth,o=r.clientHeight;e.set("scale",{x:a/n,y:o/i}),e.set("translate",{x:0,y:0})}(0,a,i);break;case"width":!function(t,e,r){var n=r.clientWidth/e.get("width");e.set("scale",{x:n,y:n}),e.set("translate",{x:0,y:0})}(0,a,i);break;case"height":!function(t,e,r){var n=r.clientHeight/e.get("height");e.set("scale",{x:n,y:n}),e.set("translate",{x:0,y:0})}(0,a,i);break;case"ratio":!function(t,e,r){var{width:n,height:i}=e.model,a=r.clientWidth,o=r.clientHeight,s=a/n,c=o/i,u=Math.min(s,c);e.set("scale",{x:u,y:u}),e.set("translate",{x:(a-n*u)/2,y:(o-i*u)/2})}(0,a,i);break;default:!function(t,e){var r=t.unitScale;e.set("scale",{x:r,y:r}),e.set("translate",{x:0,y:0})}(this,a)}this.resize()}}}),u9.memoize(drt.prototype,"unitScale",!1);var prt=13.3,grt=function(t){return void 0!==t&&(prt=t),prt};const vrt="$base_url";const yrt=Math.PI/12;class mrt{constructor(t,e){this._mode=t,this.screen=grt(),this._baseUrl="undefined"!=typeof window?window.location.origin:null,this._refProvider=e,this.isEditMode&&(this._rotateStep=yrt,this._rotateStepForced=!1)}dispose(){this._dataSubscriptionProvider&&this._dataSubscriptionProvider.dispose(),delete this._dataStorage}_calcScreen(){var t={width:screen.width,height:screen.height};this._PPI=function(t,e,r,n){t>0||(t=1),e>0||(e=1),n||(n="d");var i=("d"==n?Math.sqrt(t*t+e*e):"w"==n?t:e)/r;return i>0?Math.round(i):0}(t.width,t.height,this.screen),this._PPM=this._PPI/25.4}subscribe(t,e){return this._dataSubscriptionProvider?.subscribe(t,e)}get refProvider(){return this._refProvider}set dataSubscriptionProvider(t){this._dataSubscriptionProvider=t}get dataSubscriptionProvider(){return this._dataSubscriptionProvider}set commander(t){this._commander=t}get commander(){return this._commander}get screen(){return this._screen}set screen(t){this._screen=t,this._calcScreen()}get DPPX(){return V8}get PPI(){return this._PPI}get PPM(){return this._PPM}get mode(){return this._mode}set mode(t){var e=this._mode;e!==t&&(this._mode=t,this.trigger("mode",t,e))}get isViewMode(){return 0==this._mode}get isEditMode(){return 1==this._mode}get baseUrl(){return this._baseUrl}set baseUrl(t){t&&this._baseUrl!=t&&(this._baseUrl=t)}url(t){try{return(t.includes(vrt)?new URL(t.replace(vrt,this.baseUrl),this.baseUrl):new URL(t,location.origin)).href}catch(e){D8(e,t)}}get rotateStep(){return this._rotateStep}set rotateStep(t){this._rotateStep=Number(t)||yrt}get rotateStepForced(){return this._rotateStepForced}set rotateStepForced(t){this._rotateStepForced=!!t}get dataStorage(){return this._dataStorage}set dataStorage(t){this._dataStorage=t}}j8(mrt.prototype,P8.withEvent);class brt{constructor(t,e){!(t=Number(t))||t<=0?(L8("TimeCapsule maxsize should be greater than 0.",t),this.maxsize=10):this.maxsize=t,this.reset(),e&&(this.snapshot(e),this.preserve())}preserve(){this.checkPoint=this.pos}hasUnpreservedChanges(){return this.checkPoint!=this.pos}dispose(){this.reset()}snapshot(t){if(this.q.splice(this.pos+1,this.q.length-(this.pos+1),t),this.q.length>this.maxsize){const t=this.q.splice(0,this.q.length-this.maxsize);this.checkPoint=Math.max(-1,this.checkPoint-t.length)}this.pos=this.q.length-1}forward(){if(this.snapshot_taker&&this.snapshot_taker.take(),this.forwardable)return this.q[++this.pos];D8("Not forwardable.")}backward(){if(this.snapshot_taker&&this.snapshot_taker.take(),this.backwardable)return this.q[--this.pos];D8("Not backwardable.")}get current(){if(-1!==this.pos)return this.q[this.pos];D8("Non state has been recorded.")}get length(){return this.q.length}get forwardable(){return this.pos<this.q.length-1}get backwardable(){return this.pos>0}get snapshot_taker(){return this._snapshot_taker}set snapshot_taker(t){this._snapshot_taker=t}reset(){this.q=[],this.pos=-1,this.checkPoint=-1}}var xrt=f8((t=>{t.brake||t.take()}),1e3,{leading:!0,trailing:!1});function wrt(t){!t.brake&&t.dirty&&xrt(t)}class Art{constructor(t,e){this.brake=!1,this.dirty=!1,this.state_holder=t,this.timecapsule=e,this.timecapsule.snapshot_taker=this}dispose(){delete this.state_holder,delete this.timecapsule}touch(){this.dirty=!0,wrt(this)}take(t){(this.dirty||t)&&(this.timecapsule.snapshot(this.state_holder.state),this.dirty=!1)}get brake(){return this._brake}set brake(t){this._brake=!!t,wrt(this)}}function _rt(t,e){var r=e.model_layer.get("scale"),n=e.model_layer.get("translate");if(t){let i=JSON.parse(t);i.scale=r,i.translate=n,e.rebuildContentModel(i)}}class krt{constructor(t){this.container=t,this.timecapsule=new brt(20);var e=this;this.snapshot_taker=new Art({get state(){let t=e.container.model_layer.hierarchy;return JSON.stringify(t)}},this.timecapsule),this.snapshot_taker.take(!0),this.timecapsule.preserve()}dispose(){this.reset(),this.timecapsule&&this.timecapsule.dispose(),this.snapshot_taker&&this.snapshot_taker.dispose(),delete this.container,delete this.timecapsule,delete this.snapshot_taker}preserve(){this.timecapsule.preserve()}hasUnpreservedChanges(){return this.timecapsule.hasUnpreservedChanges()}execute(t,e){!1!==e&&t&&t.execute(),this.snapshot_taker.touch(),this.trigger("execute",t,!0,!1)}undo(){this.timecapsule.backwardable&&(_rt(this.timecapsule.backward(),this.container),this.trigger("undo",this.undoable(),this.redoable()))}redo(){this.timecapsule.forwardable&&(_rt(this.timecapsule.forward(),this.container),this.trigger("redo",this.undoable(),this.redoable()))}undoable(){return this.timecapsule.backwardable}redoable(){return this.timecapsule.forwardable}reset(){this.timecapsule&&this.timecapsule.reset(),this.trigger("command-reset")}}j8(krt.prototype,P8.withEvent);var Ert=0;const Srt=new FinalizationRegistry((t=>{Ert--}));class Mrt{static get residents(){return Ert}static get residentsCount(){return Ert}constructor(t){this._container=t,this.app=t.app,this._commander=new krt(this._container),this.app.commander=this._commander,Ert++,Srt.register(this,Ert)}add(){return Stt.apply(this._container,arguments)}duplicate(){return Mtt.apply(this._container,arguments)}remove(){return Ttt.apply(this._container,arguments)}animate(){return t6.apply(this,arguments)}fullscreen(){return Ctt.apply(this._container,arguments)}get target(){return this._container.target_element}set target(t){var e;if("string"==typeof t){if(!(e=document.getElementById(t)))throw`target element '${t}' is not exist`;if(e.firstChild)throw`target element '${t}' already has children`}else e=t;e&&e.style&&(e.style.cursor="default"),this._container.target_element=e,this._container.invalidate()}get scale(){return this.root.get("scale")}set scale(t){this.root.set("scale",t)}get translate(){return this.root.get("translate")}set translate(t){this.root.set("translate",t)}get unit(){return this.root.get("unit")||"px"}get PPM(){return this.app.PPM}get PPI(){return this.app.PPI}get DPPX(){return this.app.DPPX}static get DPPX(){return V8}get unitScale(){return this._container.unitScale}get screen(){return this.app.screen}set screen(t){this.app.screen=t,this._container.resize()}resize(){this._container.resize()}release(){this.dispose()}dispose(){this._commander&&this._commander.dispose(),this._container&&this._container.dispose()}get selected(){return this._container.selected.slice()}set selected(t){this._container.selected=t}select(t,...e){return this._container.selected=this.root?.findAll(t,...e),this.selected}get commander(){return this._commander}undo(){this.commander.undo()}undoable(){return this.commander.undoable()}redo(){this.commander.redo()}redoable(){return this.commander.redoable()}preserve(){this.commander.preserve()}hasUnpreservedChanges(){return this.commander.hasUnpreservedChanges()}cut(){return Ltt.apply(this._container,arguments)}copy(){return jtt.apply(this._container,arguments)}paste(){return Dtt.apply(this._container,arguments)}undoableChange(){return eet.apply(this._container,arguments)}change(){return tet.apply(this.root,arguments)}get model(){return this.root.hierarchy}set model(t){this._container.rebuildContentModel(t)}get rootContainer(){return this._container}get root(){return this._container?.model_layer}findAll(){return this.root.findAll.apply(this.root,arguments)}findFirst(){return this.root.findFirst.apply(this.root,arguments)}findById(){return this._container.findById.apply(this._container,arguments)}serialize(){return this.root.trim(),this.root.serialize.apply(this.root,arguments)}align(){return gtt.apply(this._container,arguments)}place(){return het.apply(this._container,arguments)}distribute(){return mtt.apply(this._container,arguments)}move(){return wtt.apply(this._container,arguments)}zorder(){return Att.apply(this._container,arguments)}symmetryX(){return Ztt.apply(this._container,arguments)}symmetryY(){return $tt.apply(this._container,arguments)}on(){return Ptt.apply(this._container,arguments)}once(){return Ott.apply(this._container,arguments)}off(){return this._container&&Itt.apply(this._container,arguments)}centerTo(t,e){return this.root.centerTo(t,e)}get mode(){return this.app.mode}set mode(t){void 0!==t&&(this.app.mode=t)}toDataURL(){return Xtt.apply(this._container,arguments)}group(){return Vtt.apply(this._container,arguments)}ungroup(){return Qtt.apply(this._container,arguments)}fit(t){this._container.once("redraw",(()=>this._container.fit(t))),this._container.invalidate()}get fitMode(){return this._container.fitMode}get ids(){return ret.apply(this._container)}get data(){return this._container.data}set data(t){this._container.data=t}get dataByRefid(){return this._container.dataByRefid}set dataByRefid(t){this._container.dataByRefid=t}get values(){return this._container.values}set values(t){this._container.values=t}get valuesByRefid(){return this._container.valuesByRefid}set valuesByRefid(t){this._container.valuesByRefid=t}get baseUrl(){return this.app.baseUrl}set baseUrl(t){this.app.baseUrl=t}startAddMode(){return fet.apply(this._container,arguments)}startStylePasteMode(){return det.apply(this._container,arguments)}stopStylePasteMode(){return pet.apply(this._container,arguments)}startDatabindPasteMode(){return get.apply(this._container,arguments)}stopDatabindPasteMode(){return vet.apply(this._container,arguments)}}const Trt=new class{load(t){}save(t,e){}clear(t){}};function Prt({target:t,model:e,style:r,layers:n=[],handlers:i=[],mode:a=0,refProvider:o,dataSubscriptionProvider:s,dataStorage:c=Trt,baseUrl:u,fitMode:l}){var h=null;if("string"==typeof t){if(!(h=document.getElementById(t)))throw`target element '${t}' is not exist`;if(h.firstChild)throw`target element '${t}' is not empty`}else h=t;h&&h.style&&(h.style.position="absolute",h.style.cursor="default",h.style.overflow="hidden");var f=new mrt(a,o);return f.baseUrl=u,f.dataSubscriptionProvider=s,f.dataStorage=c,new Mrt(new drt({target_element:h,model:e,style:r,layers:n,handlers:i,fitMode:l},f))}const Ort=["mousemove","mouseup","mousedown","mouseout","wheel","tap","click","touchstart","touchmove","touchend","mouseenter","mouseleave","dragstart","dragmove","dragend","dblclick"];var Irt=t=>class extends t{isHTMLElement(){return!0}isShadowable(){return!0}get element(){return this._element}set element(t){this._element=t}get tagName(){return this.get("type")}setElementProperties(t){throw new Error("Not Implemented Yet")}createElement(){this.element=document.createElement(this.tagName),this.element&&(this.parent.isHTMLElement()?this.parent.element.appendChild(this.element):this.root.model_layer.overlay.appendChild(this.element),Ort.forEach((t=>{this.element.addEventListener(t,this.userInputEventHandler.bind(this))})),K8.forEach((t=>{this.element.addEventListener(t,this.userInputEventHandler.bind(this))})),this.oncreate_element&&this.oncreate_element(this.element))}userInputEventHandler(t){Ket(this,t.type,t),t.stopPropagation()}reposition(){this.element&&G7(this)}disposeElement(){var t=this.element;t&&t.parentElement&&t.parentElement.removeChild(t),delete this.element}ready(){super.ready(),!this.element&&this.createElement(),this.parent.isHTMLElement()?this.parent.element.appendChild(this.element):this.root.model_layer.overlay.appendChild(this.element),this.setElementProperties(this.element),this.reposition()}dispose(){this.disposeElement(this),super.dispose()}get hasTextProperty(){return!0}get textHidden(){return!0}onchange(t,e){this.element&&this.setElementProperties(this.element),this.reposition()}isDescendible(t){return t.isHTMLElement()}};const Crt={x:1,y:1},Rrt={boxSizing:"border-box",margin:"0px",position:"absolute",outline:"none"},jrt={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"layout",label:"layout",name:"layoutOption"}],help:"scene/component/container"};class Lrt extends(Irt(D9)){get tagName(){return"div"}get nature(){return jrt}setElementProperties(t){}get layout(){return m9.get(this.get("layout"))||b9}reposition(){if(this.element){var t=this,{id:e,class:r,scale:n=Crt}=t.state,{rotation:i=0,hidden:a}=t,{left:o,top:s,width:c,height:u}=t.bounds,l=c/2,h=u/2,f=t.element;f.hidden=a,e&&(f.id=e),r&&(f.className=r),Object.assign(f.style,Rrt,{left:o+"px",top:s+"px",width:"0px",height:"0px",backgroundColor:"transparent"});var d=t.delta(),p=(n&&n.x||1)*d.sx,g=(n&&n.y||1)*d.sy,v=(i||0)+d.theta,y=d.tx||0,m=d.ty||0;["-webkit-","-moz-","-ms-","-o-",""].forEach((t=>{f.style[t+"transform"]=`translate(${y+l}px, ${m+h}px) rotate(${v}rad) translate(${-l}px, ${-h}px) scale(${p}, ${g}) perspective(1px)`}))}}}u9.register("container",Lrt);const Drt=5,zrt=Math.sqrt(3),Frt=2;function Nrt(t,e,r,n,i){var a,o,s,c,u=Drt+i,l=r.x,h=r.y,f=n.x,d=n.y;if(Math.abs(l-f)>u&&Math.abs(h-d)>u){var p=(d-h)/(f-l),g=h-p*l;if(Math.abs(e-(p*t+g))>u)return!1}return l>f?(o=l,a=f):(o=f,a=l),h>d?(c=h,s=d):(c=d,s=h),!(o+Drt<t)&&(!(a-Drt>t)&&(!(c+Drt<e)&&!(s-Drt>e)))}function Brt(t,e,r,n=2){for(let i=0;i<r.length-1;i++)if(Nrt(t,e,r[i],r[i+1],n))return!0;return!1}function Urt(t,e,r,n){if("arrow"!=t.slice(-5))return r;var i=Math.atan2(n.y-r.y,n.x-r.x),a=1.5*e;return{x:r.x+Math.cos(i)*a,y:r.y+Math.sin(i)*a}}function Yrt(t,e,r){var{lineWidth:n=Frt,strokeStyle:i="#000000",lineCap:a=!1,alpha:o=1,begin:s="none",end:c="none",beginSize:u="size5",endSize:l="size5"}=r;if(("none"!=s||"none"!=c)&&(n=Number(n)||Frt,t.lineCap=a,t.lineWidth=n,t.strokeStyle=i,t.fillStyle=i,t.globalAlpha*=o,"none"!=s&&Grt(t,e[0],e[1],n,s,Wrt(u,n)),"none"!=c)){let r=e.length;Grt(t,e[r-1],e[r-2],n,c,Wrt(l,n))}}function Grt(t,e,r,n,i,a){var{x:o,y:s}=e,c=Math.atan2(r.y-s,r.x-o);switch(t.beginPath(),t.translate(o,s),t.rotate(c),i){case"oval":t.ellipse(0,0,a.X,a.Y,0,0,2*Math.PI),t.fill();break;case"diamond":t.moveTo(-a.X,0),t.lineTo(0,-a.Y),t.lineTo(a.X,0),t.lineTo(0,a.Y),t.fill();break;case"arrow":t.moveTo(0,0),t.lineTo(zrt*a.X,-a.Y),t.lineTo(zrt*a.X,a.Y),t.fill();break;case"sharp-arrow":t.moveTo(0,0),t.lineTo(zrt*a.X,-a.Y),t.lineTo(-a.X/1.5+zrt*a.X,0),t.lineTo(zrt*a.X,a.Y),t.fill();break;case"open-arrow":t.moveTo(zrt*a.X+n,-a.Y),t.lineTo(n,0),t.lineTo(zrt*a.X+n,a.Y),t.stroke()}t.rotate(-c),t.translate(-o,-s),t.closePath()}function Wrt(t,e){let r={};switch(e*=1.2,t){case"size1":r.X=e,r.Y=e;break;case"size2":r.X=1.5*e,r.Y=e;break;case"size3":r.X=2*e,r.Y=e;break;case"size4":r.X=e,r.Y=1.5*e;break;case"size5":default:r.X=1.5*e,r.Y=1.5*e;break;case"size6":r.X=2*e,r.Y=1.5*e;break;case"size7":r.X=e,r.Y=2*e;break;case"size8":r.X=1.5*e,r.Y=2*e;break;case"size9":r.X=2*e,r.Y=2*e}return r}const Hrt="N",qrt="S",Xrt="E",Vrt="W";class Qrt{constructor({component:t,anchor:e,position:r,self:n}){this.component=t,this._anchorName=e,this._position=r,this.self=n}get position(){const t=this.anchor;if(t){var{position:e}=t;const r=this.component.transcoordS2T(e.x,e.y);return this.self.transcoordT2P(r.x,r.y)}return this._position}set position({x:t,y:e}){this._position={x:t,y:e}}get anchor(){return this.component?.findAnchor(this._anchorName)}get direction(){const t=this.component.bounds,e=this.anchor;if(!e)return Xrt;const r=e.position;return r.y<=t.top?Hrt:r.y>=t.top+t.height?qrt:r.x<=t.left?Vrt:Xrt}get boundaryPosition(){const t=this.anchor;if(t){var{position:e}=t,r=0,n=0;switch(this.direction){case qrt:n=20;break;case Hrt:n=-20;break;case Vrt:r=-20;break;default:r=20}e={x:e.x+r,y:e.y+n};const i=this.component.transcoordS2T(e.x,e.y);return this.self.transcoordT2P(i.x,i.y)}}}class Krt extends u9{isLine(){return!0}replaceRefids(t){["from","to"].forEach((e=>{const r=this.get(e);if(r?.component){const n=t.get(r.component)||r.component;this.set(e,{...r,component:n})}}))}get fromEnd(){if(this.parent&&!this._fromEnd){const{component:t,anchor:e,position:r}=this.getState("from")||{};if(!t)return;const n=this.root?.findByRefid(t);if(!n)return;this._fromEnd=new Qrt({component:n,fromto:"from",anchor:e,position:r,self:this})}return this._fromEnd}get from(){return this.getState("from")}set from(t){delete this._fromEnd,this.set("from",t)}get toEnd(){if(this.parent&&!this._toEnd){const{component:t,anchor:e,position:r}=this.getState("to")||{};if(!t)return;const n=this.root?.findByRefid(t);if(!n)return;this._toEnd=new Qrt({component:n,fromto:"to",anchor:e,position:r,self:this})}return this._toEnd}get to(){return this.getState("to")}set to(t){delete this._toEnd,this.set("to",t)}move({x:t,y:e},r){r&&(this.from={position:this._fromEnd?.position||this.getState("from")?.position||{x:0,y:0}},this.to={position:this._toEnd?.position||this.getState("to")?.position||{x:0,y:0}}),super.move({x:t,y:e},r)}render(t){var{begin:e="none",end:r="none",lineWidth:n,round:i=0}=this.state,a=this.drawPath;Yrt(t,a,this.state),t.beginPath();var o=Urt(e,n,a[0],a[1]),s=Urt(r,n,a[a.length-1],a[a.length-2]);a=[o,...a.slice(1,-1),s];var c={x:o.x,y:o.y};t.moveTo(o.x,o.y);for(var u=1;u<a.length;u++){const e=c;c=a[u];const r=a[u+1];if(e.x===c.x&&e.y===c.y)continue;if(!r){t.lineTo(c.x,c.y);break}var l=0!==(d=Math.sqrt((e.x-c.x)*(e.x-c.x)+(e.y-c.y)*(e.y-c.y)))?Math.atan2(e.x-c.x,e.y-c.y):0,h=Math.sin(l)*Math.min(i,d/2)+c.x,f=Math.cos(l)*Math.min(i,d/2)+c.y;const n=i>0||0!==d?{x:h,y:f}:c;var d;l=0!==(d=Math.sqrt((r.x-c.x)*(r.x-c.x)+(r.y-c.y)*(r.y-c.y)))?Math.atan2(r.x-c.x,r.y-c.y):0,h=Math.sin(l)*Math.min(i,d/2)+c.x,f=Math.cos(l)*Math.min(i,d/2)+c.y;const o=i>0||0!==d?{x:h,y:f}:c;t.lineTo(n.x,n.y),i>0&&t.quadraticCurveTo(c.x,c.y,o.x,o.y)}this.drawStroke(t)}contains(t,e){var{lineWidth:r}=this.state;return Brt(t,e,this.drawPath,r)}get resizable(){return!1}get mutable(){return!0}get rotatable(){return!1}get path(){const{from:t,to:e}=this.state;var{x1:r,y1:n,x2:i,y2:a}=this.state;return[this.fromEnd?.position||t?.position||{x:r,y:n},this.toEnd?.position||e?.position||{x:i,y:a}]}set path(t){const[e,r]=t,{from:n,to:i}=this.state;delete this._fromEnd,delete this._toEnd,this.set({from:{...n,position:e},to:{...i,position:r}})}get textBounds(){var t,e,r=this.drawPath,n=0;for(let s=1;s<r.length;s++){var i=r[s-1],a=r[s],o=(i.x-a.x)*(i.x-a.x)+(i.y-a.y)*(i.y-a.y);o>n&&(n=Math.ceil(o),t=i,e=a)}var{paddingTop:s,paddingLeft:c,paddingRight:u,paddingBottom:l}=this.state;return l||=0,s||=0,c||=0,u||=0,{left:Math.min(t.x,e.x)+c,top:Math.min(t.y,e.y)+s,width:Math.max(Math.abs(t.x-e.x)-c-u,0),height:Math.max(Math.abs(t.y-e.y)-s-l,0)}}get decorators(){return["decotag"]}}Krt.getTipNeckPos=Urt,Krt.containedInPath=Brt,Krt.drawEndTips=Yrt,u9.register("line",Krt);const Jrt={mutable:!1,resizable:!0,rotatable:!0,properties:[],"value-property":"text"};class Zrt extends(G9(l9)){is3dish(){return!0}render(t){var{cx:e,cy:r,rx:n,ry:i,startAngle:a,endAngle:o,anticlockwise:s}=this.state;t.beginPath(),t.ellipse(e,r,Math.abs(n),Math.abs(i),0,a||0,o||2*Math.PI,s)}get path(){var{cx:t,cy:e,rx:r,ry:n}=this.state;return[{x:t-r,y:e-n},{x:t+r,y:e-n},{x:t+r,y:e+n},{x:t-r,y:e+n}]}set path(t){var e=t[0],r=t[2];this.set({cx:e.x+(r.x-e.x)/2,cy:e.y+(r.y-e.y)/2,rx:(r.x-e.x)/2,ry:(r.y-e.y)/2})}contains(t,e){var{cx:r,cy:n,rx:i,ry:a}=this.state,o=(t-r)/(2*i-.5),s=(e-n)/(2*a-.5);return o*o+s*s<.25}outline(t){return function(t,e){var{cx:r,cy:n,rx:i,ry:a}=t.model,o=2*Math.PI*e,s=r+i*Math.cos(o),c=n+a*Math.sin(o);return t.transcoordS2T(s,c)}(this,t)}get anchors(){return function(t){var{left:e,top:r,width:n,height:i}=t.bounds,a=e+n/2,o=r+i/2;return[{name:"TOP",position:{x:a,y:r}},{name:"RIGHT",position:{x:e+n,y:o}},{name:"BOTTOM",position:{x:a,y:r+i}},{name:"LEFT",position:{x:e,y:o}}]}(this)}get nature(){return Jrt}}u9.memoize(Zrt.prototype,"path",!1),u9.register("ellipse",Zrt);var $rt={ondragstart:function(t,e,r){r.mutatePath(null,(function(r){r.splice(e+1,0,t)}))},ondragmove:function(t,e,r){r.mutatePath(null,(function(r){r[e+1]=t}))},ondragend:function(t,e,r){}};const tnt={mutable:!0,resizable:!1,rotatable:!0,properties:[{type:"number",label:"round",name:"round",property:{min:0,max:100,step:1}}],help:"scene/component/polygon"};class ent extends l9{is3dish(){return!0}get mutable(){return!0}get pathExtendable(){return!0}get path(){return this.state.path}set path(t){this.set("path",t)}contains(t,e){var r=this.state.path,n=!1;return r.forEach(((i,a)=>{let o=(a+r.length+1)%r.length,s=i.x,c=i.y,u=r[o].x,l=r[o].y;c>e!=l>e&&t<(u-s)*(e-c)/(l-c)+s&&(n=!n)})),n}get controls(){var t=this.path;return t.map(((e,r)=>{let n=t[r+1>=t.length?0:r+1];return{x:(e.x+n.x)/2,y:(e.y+n.y)/2,handler:$rt}}))}get nature(){return tnt}}u9.memoize(ent.prototype,"controls",!1),u9.register("polygon",ent);var rnt={ondragstart:function(t,e,r){r.mutatePath(null,(function(r){r.splice(e,0,t)}))},ondragmove:function(t,e,r){r.mutatePath(null,(function(r){r[e]=t}))},ondragend:function(t,e,r){}};const nnt={mutable:!1,resizable:!1,rotatable:!1,properties:[{type:"number",label:"round",name:"round",property:{min:0,max:100,step:1}}],help:"scene/component/polyline"};class int extends Krt{get pathExtendable(){return!0}get path(){const{from:t,to:e}=this.state,{path:r}=this.state;return[this.fromEnd?.position||t?.position||r[0],...r.slice(1,-1),this.toEnd?.position||e?.position||r[r.length-1]]}set path(t){const{from:e,to:r}=this.state;delete this._fromEnd,delete this._toEnd,this.set({from:{...e,position:t[0]},to:{...r,position:t[t.length-1]},path:t})}get controls(){var t=this.path,e=[];for(let r=0;r<t.length-1;r++){let n=t[r],i=t[r+1];0==r&&e.push({x:n.x,y:n.y,handler:rnt}),e.push({x:(n.x+i.x)/2,y:(n.y+i.y)/2,handler:rnt}),r==t.length-2&&e.push({x:i.x,y:i.y,handler:rnt})}return e}get nature(){return nnt}}u9.register("polyline",int);const ant={mutable:!1,resizable:!1,rotatable:!1,properties:[{type:"number",label:"round",name:"round",property:{min:0,max:100,step:1}}],help:"scene/component/ortholine"};class ont extends Krt{get pathExtendable(){return!1}get drawPath(){const t=this.path[0],e=this.path[1],{component:r,direction:n,boundaryPosition:i=t}=this.fromEnd||{},{component:a,direction:o,boundaryPosition:s=e}=this.toEnd||{};var c=[i,s],u=[];i&&u.push(i);var l=r?.bounds;if(l){var h=r.transcoordS2T(l.left,l.top);h=this.transcoordT2P(h.x,h.y),l={...l,left:h.x,top:h.y}}var f=l?{left:l.left-20,top:l.top-20,width:l.width+40,height:l.height+40}:{left:i.x,top:i.y,width:0,height:0};l=l||f;var d=a?.bounds;if(d){h=a.transcoordS2T(d.left,d.top);h=this.transcoordT2P(h.x,h.y),d={...d,left:h.x,top:h.y}}var p=d?{left:d.left-20,top:d.top-20,width:d.width+40,height:d.height+40}:{left:s.x,top:s.y,width:0,height:0};d=d||p;var g=[f,p];const v=f.left>p.left?p.left:f.left,y=f.top>p.top?p.top:f.top;var m,b,x,w,A,_,k,E,S,M,T={left:v,top:y,width:f.left+f.width>p.left+p.width?f.left+f.width-v:p.left+p.width-v,height:f.top+f.height>p.top+p.height?f.top+f.height-y:p.top+p.height-y},P=0,O=0;l.left+l.width<d.left?(w=0,A=1,S=n,M=o,m=(l.left+l.width+d.left)/2,P=d.left-m):d.left+d.width<l.left&&(w=1,A=0,S=o,M=n,m=(l.left+d.width+d.left)/2,P=l.left-m),l.top+l.height<d.top?(x=0,_=1,k=n,E=o,b=(l.top+l.height+d.top)/2,O=d.top-b):d.top+d.height<l.top&&(x=1,_=0,k=o,E=n,b=(l.top+d.height+d.top)/2,O=l.top-b);var I=[];if(m&&P>O){switch(M){case Vrt:switch(S){case Xrt:I.push({x:m,y:c[w].y}),I.push({x:m,y:c[A].y});break;case Vrt:var C=g[w].top+g[w].height/2>c[A].y?Math.min(g[w].top,c[A].y):Math.max(g[w].top+g[w].height,c[A].y);I.push({x:c[w].x,y:C}),I.push({x:m,y:C}),I.push({x:m,y:c[A].y});break;case Hrt:case qrt:C=S===qrt?Math.max(c[w].y,c[A].y):Math.min(c[w].y,c[A].y);I.push({x:c[w].x,y:C}),I.push({x:m,y:C}),I.push({x:m,y:c[A].y});break;default:return this.path}break;case Xrt:switch(S){case Xrt:var R=C=c[w].y<c[A].y?Math.min(g[A].top,c[w].y):Math.max(g[A].top+g[A].height,c[w].y);break;case Vrt:R=C=void 0!==b?b:c[w].y<c[A].y?T.top-.5*P:T.top+T.height+.5*P;break;case qrt:R=C=void 0!==b?Math.max(b,c[w].y):T.top+T.height;break;case Hrt:R=C=b?Math.min(b,g[w].top):T.top;break;default:return this.path}I.push({x:c[w].x,y:C}),I.push({x:m,y:C}),I.push({x:m,y:R}),I.push({x:c[A].x,y:R});break;case qrt:switch(S){case Xrt:C=c[w].y,R=c[w].y>c[A].y?c[w].y:g[A].top+g[A].height;break;case Vrt:R=C=b?Math.max(b,g[A].top+g[A].height):T.top+T.height;break;case qrt:R=C=T.top+T.height;break;case Hrt:C=b?Math.min(b,g[w].top):g[w].top,R=b?Math.max(b,g[A].top+g[A].height):g[A].top+g[A].height;break;default:return this.path}I.push({x:c[w].x,y:C}),I.push({x:m,y:C}),I.push({x:m,y:R}),I.push({x:c[A].x,y:R});break;case Hrt:switch(S){case Xrt:C=c[w].y,R=c[w].y<c[A].y?c[w].y:g[A].top;break;case Vrt:R=C=b?Math.min(b,g[A].top):T.top;break;case qrt:C=void 0!==b?Math.max(b,c[w].y):c[w].y,R=void 0!==b?Math.min(b,c[A].y):c[A].y;break;case Hrt:R=C=T.top;break;default:return this.path}I.push({x:c[w].x,y:C}),I.push({x:m,y:C}),I.push({x:m,y:R}),I.push({x:c[A].x,y:R});break;default:return this.path}u.push(...0===w?I:I.reverse())}else if(b){switch(E){case Hrt:switch(k){case qrt:I.push({x:c[x].x,y:b}),I.push({x:c[_].x,y:b});break;case Hrt:var j=g[x].left+g[x].width/2>c[_].x?Math.min(g[x].left,c[_].x):Math.max(g[x].left+g[x].width,c[_].x);I.push({x:j,y:c[x].y}),I.push({x:j,y:b}),I.push({x:c[_].x,y:b});break;case Vrt:j=Math.min(c[x].x,c[_].x);I.push({x:j,y:c[x].y}),I.push({x:j,y:b}),I.push({x:c[_].x,y:b});break;case Xrt:j=Math.max(c[x].x,c[_].x);I.push({x:j,y:c[x].y}),I.push({x:j,y:b}),I.push({x:c[_].x,y:b});break;default:return this.path}break;case qrt:switch(k){case Vrt:var L=j=T.left;break;case Xrt:L=j=void 0!==m?Math.max(m,c[x].x):T.left+T.width;break;case Hrt:L=j=void 0!==m?m:c[x].x<c[_].x?T.left-.5*O:T.left+T.width+.5*O;break;case qrt:j=c[x].x,L=c[x].x<c[_].x?Math.min(g[_].left,c[x].x):Math.max(g[_].left+g[_].width,c[x].x);break;default:return this.path}I.push({x:j,y:c[x].y}),I.push({x:j,y:b}),I.push({x:L,y:b}),I.push({x:L,y:c[_].y});break;case Xrt:switch(k){case Vrt:j=void 0!==m?Math.min(m,c[x].x):c[x].x,L=void 0!==m?Math.max(m,c[_].x):c[_].x;break;case Xrt:L=j=T.left+T.width;break;case Hrt:L=j=void 0!==m?Math.max(m,c[_].x):T.left+T.width;break;case qrt:j=c[x].x,L=Math.max(g[_].left+g[_].width,c[x].x);break;default:return this.path}I.push({x:j,y:c[x].y}),I.push({x:j,y:b}),I.push({x:L,y:b}),I.push({x:L,y:c[_].y});break;case Vrt:switch(k){case Vrt:L=j=T.left;break;case Xrt:j=void 0!==m?Math.max(m,c[x].x):c[x].x,L=void 0!==m?Math.min(m,c[_].x):c[_].x;break;case Hrt:L=j=T.left;break;case qrt:j=c[x].x<c[_].x?Math.min(g[_].left,c[x].x):c[x].x,L=Math.min(j,c[_].x);break;default:return this.path}I.push({x:j,y:c[x].y}),I.push({x:j,y:b}),I.push({x:L,y:b}),I.push({x:L,y:c[_].y});break;default:return this.path}u.push(...0===x?I:I.reverse())}else switch(n){case Hrt:switch(o){case Hrt:var D=T.top;u.push({x:c[0].x,y:D}),u.push({x:c[1].x,y:D});break;case qrt:var z=T.left+T.width;u.push({x:z,y:c[0].y}),u.push({x:z,y:T.top+T.height}),u.push({x:c[1].x,y:T.top+T.height});break;case Xrt:z=c[1].y<c[0].y&&c[1].x<c[0].x?c[0].x:T.left+T.width;u.push({x:z,y:c[0].y}),u.push({x:z,y:c[1].y});break;case Vrt:z=T.left;u.push({x:z,y:c[0].y}),u.push({x:z,y:c[1].y});break;default:return this.path}break;case qrt:switch(o){case Hrt:z=T.left+T.width;u.push({x:z,y:c[0].y}),u.push({x:z,y:T.top}),u.push({x:c[1].x,y:T.top});break;case qrt:D=T.top+T.height;u.push({x:c[0].x,y:D}),u.push({x:c[1].x,y:D});break;case Xrt:D=T.top+T.height;u.push({x:c[0].x,y:D}),u.push({x:c[1].x,y:D});break;case Vrt:D=T.top+T.height;u.push({x:c[0].x,y:D}),u.push({x:c[1].x,y:D});break;default:return this.path}break;case Vrt:switch(o){case Hrt:z=c[0].x>c[1].x&&c[0].y<c[1].y?c[1].x:T.left,D=c[0].x>c[1].x&&c[0].y<c[1].y?c[1].y:Math.min(T.top,c[0].y);u.push({x:z,y:c[0].y}),u.push({x:z,y:D}),u.push({x:c[1].x,y:D});break;case qrt:z=T.left,D=Math.max(T.top+T.height,c[0].y);u.push({x:z,y:c[0].y}),u.push({x:z,y:D}),u.push({x:c[1].x,y:D});break;case Xrt:z=T.left+T.width;u.push({x:c[0].x,y:T.top}),u.push({x:z,y:T.top}),u.push({x:z,y:c[1].y});break;case Vrt:z=T.left;u.push({x:z,y:c[0].y}),u.push({x:z,y:c[1].y});break;default:return this.path}break;case Xrt:switch(o){case Hrt:D=c[0].y<c[1].y&&c[0].x<c[1].x?c[0].y:T.top;u.push({x:c[0].x,y:D}),u.push({x:c[1].x,y:D});break;case qrt:D=c[0].y>c[1].y&&c[0].x<c[1].x?c[0].y:T.top+T.height;u.push({x:c[0].x,y:D}),u.push({x:c[1].x,y:D});break;case Xrt:D=T.top+T.height;u.push({x:c[0].x,y:D}),u.push({x:c[1].x,y:D});break;case Vrt:D=T.top+T.height;u.push({x:c[0].x,y:D}),u.push({x:c[1].x,y:D});break;default:return this.path}break;default:return this.path}return s&&u.push(s),[t,...u,e].filter(((t,e,r)=>{if(0===e)return!0;const n=r[e-1];return t.x!==n.x||t.y!==n.y})).filter(((t,e,r)=>{if(0===e||e>=r.length-1)return!0;const n=r[e-1],i=r[e+1];return!(t.x===n.x&&t.x===i.x||t.y===n.y&&t.y===i.y)}))}get nature(){return ant}}u9.register("ortholine",ont);const snt={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"image-selector",label:"image-src",name:"src",property:{displayField:"id",displayFullUrl:!0,baseUrlAlias:"$base_url",defaultStorage:"scene-image",storageFilters:{type:Array,value:[{name:"category",value:"image"}]},useUpload:!0}},{type:"select",label:"cross-origin",name:"crossOrigin",property:{options:["","anonymous","use-credentials"]}}],"value-property":"src",help:"scene/component/image-view"};class cnt extends(f9(l9)){static get noimage(){return cnt.NOIMAGE||(cnt.NOIMAGE=new Image,cnt.NOIMAGE.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAABIBAMAAAD7Se1QAAAAIVBMVEUAAABHcEwBAQEREREBAQEEBAQGBgYLCwsDAwMDAwMICAi6HF9tAAAAC3RSTlNNAEAERiMYCS41Eac10lYAAAEgSURBVHhe7dY9asQwEAXgh7DNertNiJy48pIitY3SB7bYdk0ukL1BDDmA9gZecoH4pmFQ3MQayUMguPBrNPD4wD9TCMvJmt3M/AtYwXOlXiWgqADVCUBD46MAnGhMBaCiUQmAm8VA/Eh/eWl9Fn5WcxD+OLuRrUYJDKLluwH2InACUgkoACSdADxQc50Bytadb9RkM0CT13TcvlCT1HFg8UTHvasuUVACCa3El6u2UdD8LFTlKhUFFgA+d3dj10aABkUN72N3jAADCrJq7PIIsPidcxBoTHIIAjMFmyCwmGYIAA1P9gFgfCANAOsDSccCDW+uLDB+kLGg94OkZoAGkwsDDAe2DOg5oPxAg03rBR88OHpBz4N8UVeHFSwma74BTW6Ge4rIRa4AAAAASUVORK5CYII="),cnt.NOIMAGE}dispose(){super.dispose(),this._offcanvas=null,this._image=null}render(t){var{left:e,top:r,width:n,height:i,isGray:a=!1,alpha:o=1,src:s}=this.state;if(this.prepareIf(!this._image&&s),t.beginPath(),t.globalAlpha*=o,this._image&&this._image.complete)if(a&&this._offcanvas)t.drawImage(this._offcanvas,e,r,n,i);else try{t.drawImage(this._image,e,r,n,i)}catch(a){t.drawImage(cnt.noimage,e,r,n,i)}else!this.app.isViewMode&&t.drawImage(cnt.noimage,e,r,n,i)}get nature(){return snt}get hasTextProperty(){return!1}ready(){super.ready(),this.prepareIf(!this._image&&this.state.src)}prepare(t,e){var{src:r,crossOrigin:n}=this.state;if(r){this._image=new Image;try{n&&(this._image.crossOrigin=n),this._image.src=this.app.url(r)||""}catch(t){return void e(t)}this._image.onload=()=>{if(this.get("isGray")){let t=this._image.width,e=this._image.height;this._offcanvas=u9.createCanvas(t,e);let r=this._offcanvas.getContext("2d");r.drawImage(this._image,0,0);let n=function(t,e,r){try{var n=t.getImageData(0,0,e,r)}catch(t){return L8("Get Image Data Error: "+t.message),null}var i=n.data;for(let t=0;t<e*r*4;t+=4){let e=i[t],r=i[t+1],a=i[t+2],o=parseInt((e+r+a)/3);n.data[t]=o,n.data[t+1]=o,n.data[t+2]=o}return n}(r,t,e);r.putImageData(n,0,0)}t(this)},this._image.onerror=t=>{this._image&&!this._image.currentSrc&&(this._image=null),e(t)}}else t(this)}get src(){return this.get("src")}set src(t){this.set("src",t)}onchange(t,e){(t.hasOwnProperty("src")||t.hasOwnProperty("isGray"))&&(this._offcanvas=null,this._image=null,this.prepareIf(t.src))}ondropfile(t,e){for(let r=0;r<t.length;r++)if(t[r].type.startsWith("image/"))return void(this.src=e[r])}}u9.register("image-view",cnt);class unt extends(Irt(f9(u9))){}var lnt={},hnt={},fnt={};Object.defineProperty(fnt,"__esModule",{value:!0});var dnt=function(){function t(){}return t.bitsToNum=function(t){return t.reduce((function(t,e){return 2*t+e}),0)},t.byteToBitArr=function(t){for(var e=[],r=7;r>=0;r--)e.push(!!(t&1<<r));return e},t.lzwDecode=function(t,e){for(var r,n,i=0,a=function(t){for(var r=0,n=0;n<t;n++)e.charCodeAt(i>>3)&1<<(7&i)&&(r|=1<<n),i++;return r},o=[],s=1<<t,c=s+1,u=t+1,l=[],h=function(){l=[],u=t+1;for(var e=0;e<s;e++)l[e]=[e];l[s]=[],l[c]=null};;)if(n=r,(r=a(u))!==s){if(r===c)break;if(r<l.length)n!==s&&l.push(l[n].concat(l[r][0]));else{if(r!==l.length)throw new Error("Invalid LZW code.");l.push(l[n].concat(l[n][0]))}o.push.apply(o,l[r]),l.length===1<<u&&u<12&&u++}else h();return o},t}();fnt.SuperGifUtils=dnt,Object.defineProperty(hnt,"__esModule",{value:!0});var pnt=fnt,gnt=function(){function t(t,e){this.stream=t,this.handler=e}return t.prototype.parseCT=function(t){for(var e=[],r=0;r<t;r++)e.push(this.stream.readBytes(3));return e},t.prototype.readSubBlocks=function(){var t,e;e="";do{t=this.stream.readByte(),e+=this.stream.read(t)}while(0!==t);return e},t.prototype.parseHeader=function(){var t={};if(t.sig=this.stream.read(3),t.ver=this.stream.read(3),"GIF"!==t.sig)throw new Error("Not a GIF file.");t.width=this.stream.readUnsigned(),t.height=this.stream.readUnsigned();var e=pnt.SuperGifUtils.byteToBitArr(this.stream.readByte());t.gctFlag=e.shift(),t.colorRes=pnt.SuperGifUtils.bitsToNum(e.splice(0,3)),t.sorted=e.shift(),t.gctSize=pnt.SuperGifUtils.bitsToNum(e.splice(0,3)),t.bgColor=this.stream.readByte(),t.pixelAspectRatio=this.stream.readByte(),t.gctFlag&&(t.gct=this.parseCT(1<<t.gctSize+1)),this.handler.hdr&&this.handler.hdr(t)},t.prototype.parseExt=function(t){var e=this;switch(t.label=this.stream.readByte(),t.label){case 249:t.extType="gce",function(t){e.stream.readByte();var r=pnt.SuperGifUtils.byteToBitArr(e.stream.readByte());t.reserved=r.splice(0,3),t.disposalMethod=pnt.SuperGifUtils.bitsToNum(r.splice(0,3)),t.userInput=r.shift(),t.transparencyGiven=r.shift(),t.delayTime=e.stream.readUnsigned(),t.transparencyIndex=e.stream.readByte(),t.terminator=e.stream.readByte(),e.handler.gce&&e.handler.gce(t)}(t);break;case 254:t.extType="com",function(t){t.comment=e.readSubBlocks(),e.handler.com&&e.handler.com(t)}(t);break;case 1:t.extType="pte",function(t){e.stream.readByte(),t.ptHeader=e.stream.readBytes(12),t.ptData=e.readSubBlocks(),e.handler.pte&&e.handler.pte(t)}(t);break;case 255:t.extType="app",function(t){e.stream.readByte(),t.identifier=e.stream.read(8),t.authCode=e.stream.read(3),"NETSCAPE"===t.identifier?function(t){e.stream.readByte(),t.unknown=e.stream.readByte(),t.iterations=e.stream.readUnsigned(),t.terminator=e.stream.readByte(),e.handler.app&&e.handler.app.NETSCAPE&&e.handler.app.NETSCAPE(t)}(t):function(t){t.appData=e.readSubBlocks(),e.handler.app&&e.handler.app[t.identifier]&&e.handler.app[t.identifier](t)}(t)}(t);break;default:t.extType="unknown",function(t){t.data=e.readSubBlocks(),e.handler.unknown&&e.handler.unknown(t)}(t)}},t.prototype.parseImg=function(t){t.leftPos=this.stream.readUnsigned(),t.topPos=this.stream.readUnsigned(),t.width=this.stream.readUnsigned(),t.height=this.stream.readUnsigned();var e=pnt.SuperGifUtils.byteToBitArr(this.stream.readByte());t.lctFlag=e.shift(),t.interlaced=e.shift(),t.sorted=e.shift(),t.reserved=e.splice(0,2),t.lctSize=pnt.SuperGifUtils.bitsToNum(e.splice(0,3)),t.lctFlag&&(t.lct=this.parseCT(1<<t.lctSize+1)),t.lzwMinCodeSize=this.stream.readByte();var r=this.readSubBlocks();t.pixels=pnt.SuperGifUtils.lzwDecode(t.lzwMinCodeSize,r),t.interlaced&&(t.pixels=function(t,e){for(var r=new Array(t.length),n=t.length/e,i=function(n,i){var a=t.slice(i*e,(i+1)*e);r.splice.apply(r,[n*e,e].concat(a))},a=[0,4,2,1],o=[8,8,4,2],s=0,c=0;c<4;c++)for(var u=a[c];u<n;u+=o[c])i(u,s),s++;return r}(t.pixels,t.width)),this.handler.img&&this.handler.img(t)},t.prototype.parseBlock=function(){var t={};switch(t.sentinel=this.stream.readByte(),String.fromCharCode(t.sentinel)){case"!":t.type="ext",this.parseExt(t);break;case",":t.type="img",this.parseImg(t);break;case";":t.type="eof",this.handler.eof&&this.handler.eof(t);break;default:throw new Error("Unknown block: 0x"+t.sentinel.toString(16))}"eof"!==t.type&&setTimeout(this.parseBlock.bind(this),0)},t.prototype.parse=function(){this.parseHeader(),setTimeout(this.parseBlock.bind(this),0)},t}();hnt.SuperGifParser=gnt;var vnt={};Object.defineProperty(vnt,"__esModule",{value:!0});var ynt=function(){function t(t){this.data=t,this.position=0}return t.prototype.readByte=function(){if(this.position>=this.data.length)throw new Error("Attempted to read past end of stream.");return this.data instanceof Uint8Array?this.data[this.position++]:255&this.data.charCodeAt(this.position++)},t.prototype.readBytes=function(t){for(var e=[],r=0;r<t;r++)e.push(this.readByte());return e},t.prototype.read=function(t){for(var e="",r=0;r<t;r++)e+=String.fromCharCode(this.readByte());return e},t.prototype.readUnsigned=function(){var t=this.readBytes(2);return(t[1]<<8)+t[0]},t}();vnt.SuperGifStream=ynt,Object.defineProperty(lnt,"__esModule",{value:!0});var mnt=hnt,bnt=vnt,xnt=function(){function t(t,e){var r=this;for(var n in this.gifImgElement=t,this.options={autoPlay:!0},this.loading=!1,this.ready=!1,this.transparency=null,this.delay=null,this.disposalMethod=null,this.disposalRestoreFromIdx=null,this.lastDisposalMethod=null,this.frame=null,this.lastImg=null,this.playing=!0,this.forward=!0,this.ctxScaled=!1,this.frames=[],this.frameOffsets=[],this.initialized=!1,this.currentFrameIndex=-1,this.iterationCount=0,this.stepping=!1,this.handler={hdr:this.withProgress(this.doHdr.bind(this)),gce:this.withProgress(this.doGCE.bind(this)),com:this.withProgress(this.doNothing.bind(this)),app:{NETSCAPE:this.withProgress(this.doNothing.bind(this))},img:this.withProgress(this.doImg.bind(this)),eof:function(){r.pushFrame(),r.canvas.width=r.hdr.width*r.getCanvasScale(),r.canvas.height=r.hdr.height*r.getCanvasScale(),r.playerInit(),r.loading=!1,r.ready=!0,r.loadCallback&&r.loadCallback(r.gifImgElement)}},e)this.options[n]=e[n];this.onEndListener=e.onEnd,this.loopDelay=e.loopDelay||0,this.overrideLoopMode=null!=e.loopMode?e.loopMode:"auto",this.drawWhileLoading=null==e.drawWhileLoading||e.drawWhileLoading}return t.prototype.init=function(){var t=this.gifImgElement.parentNode,e=document.createElement("div");this.canvas=document.createElement("canvas"),this.canvasContext=this.canvas.getContext("2d"),this.tmpCanvas=document.createElement("canvas"),e.className=this.options.enclosingClass||"super-gif",e.appendChild(this.canvas),t&&(t.insertBefore(e,this.gifImgElement),t.removeChild(this.gifImgElement)),this.initialized=!0},t.prototype.loadSetup=function(t){return!this.loading&&(t&&(this.loadCallback=t),this.loading=!0,this.frames=[],this.clear(),this.disposalRestoreFromIdx=null,this.lastDisposalMethod=null,this.frame=null,this.lastImg=null,!0)},t.prototype.completeLoop=function(){this.onEndListener&&this.onEndListener(this.gifImgElement),this.iterationCount++,!1!==this.overrideLoopMode||this.iterationCount<0?this.doStep():(this.stepping=!1,this.playing=!1)},t.prototype.doStep=function(){if(this.stepping=this.playing,this.stepping){this.stepFrame(1);var t=10*this.frames[this.currentFrameIndex].delay;t||(t=100),0===this.getNextFrameNo()?(t+=this.loopDelay,setTimeout(this.completeLoop.bind(this),t)):setTimeout(this.doStep.bind(this),t)}},t.prototype.step=function(){this.stepping||setTimeout(this.doStep.bind(this),0)},t.prototype.putFrame=function(){var t;this.currentFrameIndex=parseInt(this.currentFrameIndex.toString(),10),this.currentFrameIndex>this.frames.length-1&&(this.currentFrameIndex=0),this.currentFrameIndex<0&&(this.currentFrameIndex=0),t=this.frameOffsets[this.currentFrameIndex],this.tmpCanvas.getContext("2d").putImageData(this.frames[this.currentFrameIndex].data,t.x,t.y),this.canvasContext.globalCompositeOperation="copy",this.canvasContext.drawImage(this.tmpCanvas,0,0)},t.prototype.playerInit=function(){this.loadErrorCause||(this.canvasContext.scale(this.getCanvasScale(),this.getCanvasScale()),this.options.autoPlay?this.step():(this.currentFrameIndex=0,this.putFrame()))},t.prototype.clear=function(){this.transparency=null,this.delay=null,this.lastDisposalMethod=this.disposalMethod,this.disposalMethod=null,this.frame=null},t.prototype.parseStream=function(t){try{new mnt.SuperGifParser(t,this.handler).parse()}catch(t){this.handleError("parse")}},t.prototype.setSizes=function(t,e){this.canvas.width=t*this.getCanvasScale(),this.canvas.height=e*this.getCanvasScale(),this.tmpCanvas.width=t,this.tmpCanvas.height=e,this.tmpCanvas.style.width=t+"px",this.tmpCanvas.style.height=e+"px",this.tmpCanvas.getContext("2d").setTransform(1,0,0,1,0,0)},t.prototype.drawError=function(){this.canvasContext.fillStyle="black",this.canvasContext.fillRect(0,0,this.hdr.width,this.hdr.height),this.canvasContext.strokeStyle="red",this.canvasContext.lineWidth=3,this.canvasContext.moveTo(0,0),this.canvasContext.lineTo(this.hdr.width,this.hdr.height),this.canvasContext.moveTo(0,this.hdr.height),this.canvasContext.lineTo(this.hdr.width,0),this.canvasContext.stroke()},t.prototype.handleError=function(t){this.loadErrorCause=t,this.hdr={width:this.gifImgElement.width,height:this.gifImgElement.height},this.frames=[],this.drawError()},t.prototype.doHdr=function(t){this.hdr=t,this.setSizes(this.hdr.width,this.hdr.height)},t.prototype.doGCE=function(t){this.pushFrame(),this.clear(),this.transparency=t.transparencyGiven?t.transparencyIndex:null,this.delay=t.delayTime,this.disposalMethod=t.disposalMethod},t.prototype.pushFrame=function(){this.frame&&(this.frames.push({data:this.frame.getImageData(0,0,this.hdr.width,this.hdr.height),delay:this.delay}),this.frameOffsets.push({x:0,y:0}))},t.prototype.doImg=function(t){var e=this;this.frame||(this.frame=this.tmpCanvas.getContext("2d"));var r=this.frames.length,n=t.lctFlag?t.lct:this.hdr.gct;r>0&&(3===this.lastDisposalMethod?null!==this.disposalRestoreFromIdx?this.frame.putImageData(frames[this.disposalRestoreFromIdx].data,0,0):this.frame.clearRect(this.lastImg.leftPos,this.lastImg.topPos,this.lastImg.width,this.lastImg.height):this.disposalRestoreFromIdx=r-1,2===this.lastDisposalMethod&&this.frame.clearRect(this.lastImg.leftPos,this.lastImg.topPos,this.lastImg.width,this.lastImg.height));var i=this.frame.getImageData(t.leftPos,t.topPos,t.width,t.height);t.pixels.forEach((function(t,r){t!==e.transparency&&(i.data[4*r+0]=n[t][0],i.data[4*r+1]=n[t][1],i.data[4*r+2]=n[t][2],i.data[4*r+3]=255)})),this.frame.putImageData(i,t.leftPos,t.topPos),this.ctxScaled||(this.canvasContext.scale(this.getCanvasScale(),this.getCanvasScale()),this.ctxScaled=!0),this.drawWhileLoading&&(this.canvasContext.drawImage(this.tmpCanvas,0,0),this.drawWhileLoading=this.options.autoPlay),this.lastImg=t},t.prototype.doNothing=function(){},t.prototype.withProgress=function(t){return function(e){t(e)}},t.prototype.getNextFrameNo=function(){var t=this.forward?1:-1;return(this.currentFrameIndex+t+this.frames.length)%this.frames.length},t.prototype.stepFrame=function(t){this.currentFrameIndex=this.currentFrameIndex+t,this.putFrame()},t.prototype.getCanvasScale=function(){return this.options.maxWidth&&this.hdr&&this.hdr.width>this.options.maxWidth?this.options.maxWidth/this.hdr.width:window.devicePixelRatio||1},t.prototype.play=function(){this.playing=!0,this.step()},t.prototype.pause=function(){this.playing=!1},t.prototype.isPlaying=function(){return this.playing},t.prototype.getCanvas=function(){return this.canvas},t.prototype.isLoading=function(){return this.loading},t.prototype.isReady=function(){return this.ready},t.prototype.isAutoPlay=function(){return this.options.autoPlay},t.prototype.getLength=function(){return this.frames.length},t.prototype.getCurrentFrame=function(){return this.currentFrameIndex},t.prototype.moveTo=function(t){this.currentFrameIndex=t,this.putFrame()},t.prototype.loadURL=function(t,e){var r=this;if(this.loadSetup(e)){var n=new XMLHttpRequest;n.open("GET",t,!0),"overrideMimeType"in n?n.overrideMimeType("text/plain; charset=x-user-defined"):"responseType"in n?n.responseType="arraybuffer":n.setRequestHeader("Accept-Charset","x-user-defined"),n.onloadstart=function(){r.initialized||r.init()},n.onload=function(){if(200===n.status){var t=n.response;t.toString().indexOf("ArrayBuffer")>0&&(t=new Uint8Array(t));var e=new bnt.SuperGifStream(t);setTimeout((function(){r.parseStream(e)}),0)}else r.handleError("xhr - response")},n.onerror=function(){r.handleError("xhr")},n.send()}},t.prototype.load=function(t){this.loadURL(this.gifImgElement.src,t)},t}(),wnt=lnt.SuperGif=xnt;const Ant={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"image-selector",label:"src",name:"src"},{type:"checkbox",label:"play",name:"play"}],"value-property":"src",help:"scene/component/gif-view"};class _nt extends unt{async oncreate_element(t){var{src:e,play:r}=this.state;this.onchangesrc(e),this.onchangeplay(r)}buildImg(){var t=this.element;t.innerHTML="";var e=document.createElement("img");return e.style.width="100%",e.style.height="100%",t.appendChild(e),e}onchange(t,e){super.onchange(t,e),"src"in t&&this.onchangesrc(t.src),"play"in t&&this.onchangeplay(t.play)}setElementProperties(t){}onchangeplay(t){var e=this._superGif;e&&e.isReady()&&(t?e.play():e.pause())}onchangesrc(t){var e=this.buildImg();t||(t="data:image/gif;base64,R0lGODlhYABIAPcAAAAAAAEBAQICAgMDAwQEBAUFBQYGBgcHBwgICAkJCQoKCgsLCwwMDA0NDQ4ODg8PDxAQEBERERISEhMTExQUFBUVFRYWFhcXFxgYGBkZGRoaGhsbGxwcHB0dHR4eHh8fHyAgICEhISIiIiMjIyQkJCUlJSYmJicnJygoKCkpKSoqKisrKywsLC0tLS4uLi8vLzAwMDExMTIyMjMzMzQ0NDU1NTY2Njc3Nzg4ODk5OTo6Ojs7Ozw8PD09PT4+Pj8/P0BAQEFBQUJCQkNDQ0REREVFRUZGRkdHR0hISElJSUpKSktLS0xMTE1NTU5OTk9PT1BQUFFRUVJSUlNTU1RUVFVVVVZWVldXV1hYWFlZWVpaWltbW1xcXF1dXV5eXl9fX2BgYGFhYWJiYmNjY2RkZGVlZWZmZmdnZ2hoaGlpaWpqamtra2xsbG1tbW5ubm9vb3BwcHFxcXJycnNzc3R0dHV1dXZ2dnd3d3h4eHl5eXp6ent7e3x8fH19fX5+fn9/f4CAgIGBgYKCgoODg4SEhIWFhYaGhoeHh4iIiImJiYqKio+Pj5iYmKCgoKampqurq66urrCwsLGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrOzs7S0tLa2tre3t7m5ubu7u7+/v8DAwMHBwcPDw8XFxcfHx8vLy8/Pz9LS0tXV1dfX193d3eTk5Onp6fj4+Pz8/P7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v///////////////////////////////////////////////////////////////////////////////yH5BAkAAPUAIf47R2VuZXJhdGVkIGJ5IGpzZ2lmIChodHRwczovL2dpdGh1Yi5jb20vYW50aW1hdHRlcjE1L2pzZ2lmLykALAAAAABgAEgAAAj+AGcJHEiwoMGDCBMqXMiwocOHECNKnEixosWLGDNq3Mixo8ePIEOKHEmypMmR9VKqXMmypcuXMGPKnJkSIs2bOHPqZGlzp8+fQOv1DEq0KMyhRpMmRaq0KVCmTqPmhCq1qkyqLrFRSyYwGTVsVo1iZXmNa8Fk18ISHasSm1mDycCq/ck2JTWF1ObSfTjz7cFken3WFbow8M7BDA3rHOwXruKpfGXeTZg3qDVrUge7RRg3KLZjx+Q2HVyvLNy0QaMJjBaVdD2tZr2K/mmNIObRkR+n9AsYt0Pddg1WXppb8bWDx1CLLW74GcJnSl3TtDY8Zu2Et4tKl7n52eyWnxXvhl7+26jqrspbnlfIWjtz2gWPZV95neH8veU9NxZYfbfD3kFt99J6Bnmn0mQO9XfYezrVxxlmx0GUXIAM4hSeffsxBN1TFd5E4Ef3QZbfTg6CNJ5gHXJ3TEntLThiTh+KFCJNAqZU4kgAitjQTheepOBMNcZI0oQ6JpbTjSZtiNN2PZ400IxHpdiSc07G911M0iFZZYtAStnWilUeBGVLrlEZpmM0elmPlmfO8iOZXl4DZpsGEYmll2bSWWCXLwJXVY1+urhjoGEBSuiSah6K36CKtpZoo4s9CimielZq6aWYZqrpppx26umnoIZ6UkAAOw=="),e.src=t,e.setAttribute("rel:animated_src",t),e.setAttribute("rel:auto_play",0),this._superGif=new wnt(e,{autoPlay:!1}),this._superGif.init();for(const t of this.element.children)t.style.width="100%",t.style.height="100%";var r=this._superGif.getCanvas();r.style.width="100%",r.style.height="100%",this._superGif.load((()=>{setTimeout((()=>{this._superGif.moveTo(0),this.play&&this._superGif.play()}),100)}))}ondropfile(t,e){for(let r=0;r<t.length;r++)if(/\.gif$/.test(t[r].name))return void(this.src=e[r])}get src(){return this.getState("src")}set src(t){this.set("src",t)}get play(){return this.getState("play")}set play(t){this.setState("play",t)}get nature(){return Ant}get tagName(){return"div"}}u9.register("gif-view",_nt);const knt={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"attachment-selector",label:"src",name:"src",property:{category:"audio"}},{type:"checkbox",label:"started",name:"started"},{type:"checkbox",label:"loop",name:"loop"}],"value-property":"src",help:"scene/component/audio"};class Ent extends(f9(l9)){static get image(){return Ent.IMAGE||(Ent.IMAGE=new Image,Ent.IMAGE.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZAAAAGQCAMAAAC3Ycb+AAAAP1BMVEUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACzJYIvAAAAFHRSTlMA8BAwgNBgQKB/wCBwUJDg37CvXyUlBK8AABFYSURBVHja7NsBkqIwFIThTiAQgyBq3/+sm6p1tnamZkaTMhJJf1f4S/JeEIiIiIiIiIiIiIiIiEhD7Hg4BH84TpAKjJ4f3NFCtjVd+InXz2RTs+FXlxGylYHfcVfIJmb+YFWSLUyGVJKKBJJKUo+Rd6w63l/qzLuCkryO5fe0l2xk5mMWbe+v0fNBRqf7S3je6CipQ2ACr+dWcYEpzBFS1plpguatsnomMgdIQSOTuQ5SjmE6/UgK8szgdJIUM/FG41YlFmYJ2kkKsY5ZzAwBurHDk3WGeRY0bvYrGa1+rqNI22f7dS32ZnUK1GMr0eSK3mEc9dhKMxp+ZTo8kT2emOXS5LQ1kCxbJBocSd2k5PaIjMVzjWcdJPk9ooBnmzx1t5XbIxqBKpJ4NGTgzwKiGpK4do72gb+ZUMIYtCPm9WCPMsYTE5k2hq2ZvzujlCE1iRmwf3dvmRyKsT0T7b9I7HEPCpqCiqT2IIqaT1pI0noQZdlFC8l/PbYPAnRORT56VBEE6FXkb49agmByKhJ71BME6FsvEntUFQTdqekisUdlQWCXhovEHtUFAWbTapHYo8YgmFybO3vsUWcQYGmxSOxRbRAMprkisUfFQVKmrX18sxt7VB0ENjT1xir2qDxIwkFi3v89e+xRfxAMzfzzIfZ4hyAYDR9zwVuLPd4jCDrTwoLYGb5LEFi3/+E3rweR6urX20c/Fvls2Pvwm9mDSGIPhv8YPyGf3/eo9Ye7O8B2FIShAAooakEttex/rbODad5/yTHIAjqn505IQPv+Xz06dz+4VXORHEZcgAcB8updM8F6e25jBzwIkE07l+x8amMnPDp6nsNJ+BoZ7Q6F8egqAda9VEuRNlZjBzwYkMskdXR73okd8GBAJiKYjBcZKKqG9OiKDbgdfxJ5VhsBPDiQZhaouD3p4hfw4EAmwxisz3MSHwAPEmQ1TB1N+SmXWoAHC7JbZsWl/IxLLcCDBplNo3lrfMLsmwAPGmShAxX5/1vOEzjEz3iyfQ/hI36W4TctsUesOAifPdrQg8M++KYl95iCBkjI1r8634betBAPHZDTPFAmD3zLiHgogVTziMsahz0eIh5aIGHGRSJ2mFtHPR4iHhQIP2UvWGMf8wk74qEIEib7rLjPiBfxiAcCwp8V+Nae3uMdRhAPDIR/J5f/Q2DTcC+hIB7qIGEq3Ti9bx+sryMeAAgS70OK8G2kBD8L8QBAoLWU3g3vUVIc6D0txAMAsY+4jBWowXHO64gHBGKfYJ2T5qY1BxcL98BB+PQ+XiS9xxh9EQ8ChA6C5UXWIUoE9MBB8LVHQoS7ib8/dRn3sAcJ6bQRSdH96RDxIEH4QEX+AHF4LxHEAwUh12xyr1V8lwjiQYDYF8kuf1jluUQQDwrEvkhW8Wc6LhHUgwfhi4QPlHm7LRHawx4kpE191Dq8lgjhAYDQa1cftYrPEiE8OJDb40uqyzdQCA8WhAzL4G/PT4c3WrgHD2IfllGl53V37zsgHg5ApPNvVvq4Fn4spx4oiH1W3CwtEV+PDhEPJyBSkVX4aa7emkM83ICEKWpGM7wdvYCCeDgCEYpcwhLxczhEPFyBCEUWnRL5T6X59SBASBF+9l28TL5F7uEORCZyCUvEx+S7yT0cgoRVb9JaXLR1qUdfgksQ0fTbgmhFB20d8HAKEha14+F8f1sHPNyCiL6EqK+n20/rgIdjkFC0Ho1s6Gndvcc9ICkr/ey8/rHO6vp9KawL8DAFOV6l9Fyub7IbflsCag1qRfVsXWvxHjxIejU+BHZV6uvHD1XiEb++Bw8i+dNd+Wv0eCQmhcPhRPwUUt2DB5G1sfa1aeyzAuyJj9x2HjyIdKzIKw5SI14ieFtvo3kIQERj3lVhkUOnRD7AnjV5369QkAOJZeCH+Jh41xOLs73dQwAifY6dpxCCbjTDzLf1Bm1Y93tAIDOWXcLPvrHyr2hVoEAceEAgDQzB4jetk0/c2OXRHB48EJCpa4dgpYh2ETxtrshz7zx4ICCzfuTSDn8p/EOS9OTjwgMB+cABP3yWYuOPIofs33LigYCULlpZNXJppVU30Vf14kGAUCLijf1D71lN9FW9eFiA9KgZ8FPpPUsSnufGA+8hvAg2Kpz0nrX//qp+PIgpC3i6xJRITOye9fn1VT15ICCrVlQG5rywo0H8x965bVkNwmCYQ2kR6Gmb939WXV65dFnI/tPdjPBfO7XMN4EkTUJtqZp4sCJ1+8jwkhMu0KpMxFXFA8hlVfQSMxGH5mDK1VKV8QCyvTVtUiYyo7V358VStfGoAEFMhGYhEwloxZy9WKo2Hjwg5iSOvFDXeUYd33+PuVfHgwnEBWLocDJp+IIa2fyvperjwQRiXCKGosyXqoA+YfsIELuYu4HAt+msMknfDK4jfQJIzOZ2IPAQWJtFOhQKivR2IDZ6Awis7V0iLxqBI7uEZo19dakTogLSwKvf8yk8Jq6CGK0GKvWlatG7b7kkUU/Lo1gdXWn7/4E0j0qeJDpqN/ABqQcgJgdqURb4chjQktIugDS6wFFiz3JgaJj7AGJmholAe9YKhoZLJ0Ca6smjwJ4VwVN96gVIE5GM71kHaGKxGyAtRDaB2NBhLVmpHyANRKzDO28W7FS3HQFpaIWa8TrfCXQwegJSL5k+8M9UJ+pm9QTEnCIZrR0MDQeQ9ua0iCcYQaBTV0CqNXQW/yiyYG7W1heQanPaCkciBXuH1BkQJzHcDQxmpgGkPatl4WkbCXO/bW9AqlNg4H0PPMi6A1IxkQmOZ8D0ousNSMVEEuyreTAQ6Q7IRJeCX2YZQHhv6SrBOmpkM+YUzN0BqSRQCupmTeCP9wdkhiOREwtEzgGEsWcF9BhK9R8fQDiN7A8DiR0CKXQlj/q9IM8OgXjIzcKBlAHkD6FulgNzJwPIHwpo8mQAkX3LiPq9dKUMAQk9AqmcqmjuBAJCPQIpA4guIAsKJA0gnwNy3A4kDyBIHCEPxAwgf8gPILqA5AFEF5CxZX0lIHYc6rqADLf380BmFMgxgIzUyf8MJKLTRelKHgKy9wgkjfS7LiA0gKgC8vQn3HUA4RQ5LKPIAQciWbqIEg0YkLNDIHYUyqkCsmKN5vg3+W0AYTRATaPY+uu1IwS6UMGAlO6AFPjSCQMStaNh53cdcPG7Hx1Uupo+rx+Bltn1BuTAj5BptEV/bHAAwbnJMICwRmtUDOSEA8s4Rmtw3nITGD6TwUNoG0Ca7xi2YKSPj2eKXQFxQWKA2QbGMWEMMGseOb7C7T47uJS1JyAzVbTjqZdU3zbHzMXWS+qp4Fgn8Ahy/QCRGqQcwU1vGnN7fylboWn8Bzg//hyjxltvdcl45bwFfYKzFyBy11UU9BnjuoqfWizVlQXulpzBTNbaB5Aid+VRrkBFB630AMS9BC8FK2ggE7u/FGy1kvfcB9TKQufX5uUXNWl3EjvWCi4k/u9A3Ddq1CpTIQGe6VN1qd8ArcvDQNw3S41Kn6qQmOq5e7pRr+8fAYLiIJtFrrvYRMYL0q06vj8EZLXUriJzRY8H1xEagOCK7gkghRg6RQYO0I6aWPwIEAru80AiMWSdzAeuDXUKyr+WqpAID8hMHC1Ct8F4mUsQ6W8pJMICki0JHCBczAFdBl38G3VE6ErQhhWlih4LWrCSLpaqjggHiGe9mVjRY0YPoelyqcqIcIDEe97rqJFFH7FcLlUZEQ6Qg5plvZiBFNhtri1VFREGEC/Eg4nZoU5vqi1VFREGkIXDQ8xAIhzoT/WlKiLCAFIYPOQMxOPdjfWlKiLCADJRm3YGj+pDE2xktmmpaogwgMz8d8GrumZ4xzpbvinqISJ+hiTWm7wEqoJdI9JEV9JChAEkS3xCZzKecLcgN6YwlRBhAGmweTsblg6qKMM7Vmh321UQ4QAp1VfwhqVJIh+Wm03W0qV0EOEAybXtivkCmWrKeH2EZ/xBaSBCV2L9Re+LYSqJJIxDu1ew07U0EGEBcTtmHty4JuPtQhvLh1BAhK7Uvvq0GK484QZST0GvvFDqeSJ1IA0r2mfDljvqBoJ//rVsq7yZCA6kXgVkJ2f4ijIGMjOfMVsCBBORB2Jy+sM6ijNvaBUqmw/cStZ8EiKciHwp6Rp++88qmxXQeTUxDiJWJ9wSISvBicgXW+dypn1PqWTznlwgwdZdfiLHr5OELEAEASKvJFRE5JCPKbh8OxHdQKJU0crEzRXrJ/IEkFms6tGyrUw9kQeALFRXvK2iSzsRAAi6BLxM+60xdsqJAEBuXMAMxDLVp+gmAgC57/UT4qvVj3TVRCAgSAYL91aXtyNLzUQAIFhAiP8m0/NHOp+ILiBtPFKrs6bgSOcT0QTEB8nO3QR1yKslggKRf+m11UB0HOl8IlqAeCvauXuo8HnfIqIDyCw6G8XMcGiplMingMzCnbuHFp/3LSLPA4nUpqm5YkWNzwsQeQxIDsKjH5wVSU5qJPIJIIt4jjpqNBAekQeBfJOeHWS81FQoo4/I7UDcS3wUh0liTzLqiEgDqddx4ZHDrNZAACIAEMw88HPYWb0GAhABgEDmgf9Vb5oNBCByOxD3uqWYbCHVBgIQuRlIsbfwMEG5gQBE7gSyHMDsOayrxJvHBRC5B0hOxJH1nK4SlUE6QOR+IG6ju3iYQEqDdIDIzUDyZu/jMRHpS/OiRG4FkiPRfTw8kbrvIAJEACAIDpyHC1/GQHhEbgKSXwTyqIeEur6kixEBgABHOTr7YSX1MSFAhA0E307wUU76Y0KACAsI/tvCRzkF+iIuL0AEAYLbR2QOfvhKJ/obRESBxNt5rPSFXN4f7dyNdqMgEIbhAXWwJErT/e7/Wreb5HTT07QVgWSAeW5g7b4n8qOSUCRPEId4HP93SXp5dDNGRJFcQTxihSH+NW1Bb1cXKpIryJAwnG/zhl8ZcSP6jiKZghwRaaWLnP/AkcSKKJIniEcUs8QfjFLdEmRvkSxB4lfn0QN6DY+lshQpHiT96Dlr6r5hxRUpHST9ZEY71X7DOmOZQVZLsd5Q8wzrPxYYJDiKNqOBG1ZCkZKzrNXu6lHvkjChSFqQsdTPg45ApXtYaUXKr9TNuPcvqO2pVMkitFXAL2a79/qr3HQvVSTXUtofCl79RDXh5CDpw3pwu6+9kRlvtiI5VtPhmHLltT4EKVQkfb8pcOHrXqk6nBAksUjgpKtuYsskaxGKYT0+84uYgziE4YQgMdx0m8PRfis2MbL33PMXoVjD6PEunI4HSjDjStiJP08vQk9hZzQ7oH/geoLYCUBDW4rf4FqCDFt7THUO6B+4jiDn2XNTW7zf4hqCMND4BOsGyw+yAmh0x+QeFh7EeqD5Ce8nLDrI8NpbDyIWHIQNruo4GyAPlhrEzuixBxHLDDJMnfYgYolBricHNfjIdgMWF+Qyu+pkgX4HCwuymL57ELGkIHZG7z2IWE6Q5VV7vGMhQewbtMcZiwhyHj26ne9+xs8PcvDQHnFFqCD7Au0RW4TK+fOKqw4eoOcqYqgU53HR3/5uShFPCfKey9hFDyJO/vAi7RDZnp7X5igyUH72xSDW1E2Pn4tMRCQgR8vLwbgii4gcmLvqQcSPGtIPX3M08wn6I4qYQ94cM/Yw9Xxhmw+X/59wHrtMlX1AmIkzdyaaAnLg1Nnw8WGYSk40X/BOh4+El6LMSBnN2Cd0tPq4w/LJXGrMbCX06PZ2dcM65yzlNertShSHf3SzRAyPM332IcSAHUKPi8EHmXU0l8Uglmni0yipDoi16s+jJKejhywLooz68yiMEcHr2qM4h81CJ++VPJfTu5UwBpv4Pp9DJSi6MJx0bvUwiw4ewgT8zNR0LHUL+OccOpY/3ElzyGKD5pBlMJpDlsOkMythRoNbXh95PJsdA67MrMtAEYbjeDqNo+7oKqWUUkoppZRSSimllFJKFfMXp4vmSjB8n6sAAAAASUVORK5CYII="),Ent.IMAGE}dispose(){super.dispose(),this.started=!1,delete this._audio}ready(){super.ready(),this._audio=new Audio,this._audio.addEventListener("canplay",(()=>{this.started&&this._audio.play()}));var{src:t="",loop:e=!1,started:r=!1}=this.state;this.onchangeSrc(t),this.onchangeLoop(e),this.onchangeStarted(r)}render(t){var{left:e,top:r,width:n,height:i,src:a}=this.state;t.beginPath(),this.drawImage(t,Ent.image,e,r,n,i)}get nature(){return knt}get hasTextProperty(){return!1}get src(){return this.get("src")}set src(t){this.set("src",t)}get started(){return!!this.get("started")}set started(t){this.set("started",t)}start(){this._audio&&(this._audio.classList.add("active"),this._audio.play())}pause(){this._audio&&(this._audio.classList.remove("active"),this._audio.pause())}onchangeSrc(t){try{"data"!==String(t).substring(0,4)?this._audio.crossOrigin="use-credentials":this._audio.crossOrigin=null,this._audio.src="string"==typeof t?this.app.url(t):t}catch(t){return void console.error(t)}}onchangeStarted(t){const e=this._audio;t?4==e.readyState&&e.play():e.pause()}onchangeLoop(t){this._audio.loop=t}onchange(t,e){"src"in t&&this.onchangeSrc(t.src),"started"in t&&this.onchangeStarted(t.started),"loop"in t&&this.onchangeLoop(t.loop)}ondblclick(t){this.started=!this.started}ondropfile(t,e){for(let r=0;r<t.length;r++)if(t[r].type.startsWith("audio/"))return void(this.src=e[r])}}u9.register("audio",Ent);class Snt extends(f9(u9)){is3dish(){return!0}}u9.register("text",Snt);const Mnt=["refid","left","top","width","height","rotation","animation"];class Tnt extends Lrt{isGroup(){return!0}get(t){return this._model[t]}set(t,e){if("string"==typeof t)return this.set({[t]:e});var r=Mnt.reduce(((e,r)=>(t.hasOwnProperty(r)&&(e[r]=t[r]),e)),{});return super.set(r)}capture(t,e,r){var n=super.capture(t,e,r);if(n!==this)return n}set bounds(t){if(this.__MUTATING__)super.bounds=t;else{var e=this.bounds,r=t.width/e.width,n=t.height/e.height;this.path=this.path.map((i=>({x:t.left+(i.x-e.left)*r,y:t.top+(i.y-e.top)*n}))),this.components&&this.components.forEach((t=>{if(t.mutable)t.mutatePath(null,(function(t){return t.map((function(t){return{x:t.x*r,y:t.y*n}}))}));else{let e=t.bounds,i=t.center,a={x:i.x*(1-r),y:i.y*(1-n)},o=e.width*(1-r),s=e.height*(1-n),c=-(a.x-o/2),u=-(a.y-s/2);t.bounds={left:e.left+c,top:e.top+u,width:e.width*r,height:e.height*n}}}))}}get focusible(){return!1}get bounds(){return super.bounds}get hasTextProperty(){return!1}isIdentifiable(){return!1}calculateBounds(){this.clearCache(),this.__MUTATING__=!0,this.mutateBounds((function(t){var e=u9.union(this.components.map((t=>t.bounds)));return this.components.forEach((t=>{let r=t.bounds;t.bounds={left:r.left-e.left,top:r.top-e.top,width:r.width,height:r.height}})),{left:t.left+e.left,top:t.top+e.top,width:e.width,height:e.height}}),this),this.__MUTATING__=!1,this.parent.isGroup()&&this.parent.calculateBounds()}render(t){}postrender(t){var{top:e,left:r,scale:n}=this.state;t.translate(r,e),this.layout.drawables(this).forEach((e=>{e.draw(t)})),t.translate(-r,-e)}}u9.register("group",Tnt);const Pnt={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"id-input",label:"ref",name:"ref"},{type:"select",label:"fit",name:"fit",property:{options:["","both","ratio"]}}],"value-property":"ref",help:"scene/component/local-ref"};class Ont extends(f9(l9)){get ref(){var t=this.getState("ref");return t&&"string"==typeof t?this.root.findById(t):null}set ref(t){this.setState("ref",t)}get refScale(){let t=this.ref.bounds,e=this.bounds,r=e.width/t.width,n=e.height/t.height;return"both"===this.model.fit?{x:r,y:n}:{x:Math.min(r,n),y:Math.min(r,n)}}draw(t){this._drawing||(this._drawing=!0,super.draw(t),this._drawing=!1)}prerender(t){if(super.prerender(t),this.ref){let e=this.ref.center,r=this.center,n=this.refScale;t.translate(r.x,r.y),t.scale(n.x,n.y),t.translate(-e.x,-e.y)}}postrender(t){if(this.ref)return this.ref.postrender(t);super.postrender(t)}render(t){if(this.ref)return this.ref.render(t);this.state;var{left:e,top:r,width:n,height:i}=this.bounds;t.beginPath(),t.rect(e,r,n,i)}get nature(){return Pnt}get hasTextProperty(){return!1}}u9.memoize(Ont.prototype,"ref",!1),u9.memoize(Ont.prototype,"refScale",!1),u9.register("local-ref",Ont);class Int extends(Irt(D9)){render(t){}get layout(){return m9.get(this.get("layout"))||b9}}const Cnt={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"board-selector",label:"scene-number",name:"ref",placeholder:"SCENE-1"},{type:"number",label:"round",name:"round",property:{min:0}},{type:"select",label:"fit",name:"fit",property:{options:["","both","ratio","width","height","none"]}},{type:"select",label:"mode",name:"mode",property:{options:["view","interaction"]}}],"value-property":"ref",help:"scene/component/global-ref"};class Rnt extends Int{dispose(){this._releaseRef(),super.dispose()}get nature(){return Cnt}get hasTextProperty(){return!1}get tagName(){return"div"}setElementProperties(t){var{mode:e="view",round:r=0}=this.state;t.style.pointerEvents="view"==e?"none":"inherit",t.style.borderRadius=r+"px"}ready(){super.ready(),this.fetchRef()}reposition(){if(!this.element)return;super.reposition();let t=this._element_bounds,{offsetWidth:e,offsetHeight:r}=this.element;if(this._element_bounds={offsetWidth:e,offsetHeight:r},(!t||t.offsetWidth!=e||t.offsetHeight!=r)&&this.ref&&this.root.target_element){let{fit:t="ratio"}=this.state;this.ref.fit(t)}}async fetchRef(){this._releaseRef();var{ref:t,fit:e="ratio"}=this.state;if(t){var r=this.app.refProvider;if(r&&t)try{this.__ref=await r.get(t,!0),this.__ref.target=this.element,this.__ref.fit(e),this.__ref.data=this.data}catch(t){L8(t)}}}get ref(){return this.__ref}set ref(t){this.setState("ref",t)}_releaseRef(){this.__ref&&this.__ref.release&&this.__ref.release(),delete this.__ref}onchange(t,e,r){super.onchange(t,e,r),"ref"in t&&this.fetchRef(),"fit"in t&&this.ref&&requestAnimationFrame((()=>{let{fit:t}=this.state;this.ref.fit(t)})),"data"in t&&this.ref&&requestAnimationFrame((()=>{this.ref.data=t.data}))}}u9.register("global-ref",Rnt);const jnt={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"board-selector",label:"board",name:"board"},{type:"checkbox",label:"modal",name:"modal"},{type:"checkbox",label:"closable",name:"closable"},{type:"checkbox",label:"show",name:"show"},{type:"select",label:"location",name:"location",property:{options:["center","left-top","right-top","left-bottom","right-bottom","auto"]}},{type:"data",label:"value",name:"value"}],help:"scene/component/popup"};class Lnt extends(f9(l9)){static get image(){return Lnt._image||(Lnt._image=new Image,Lnt._image.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEYAAABGCAMAAABG8BK2AAADJmlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNy4xLWMwMDAgNzkuZGFiYWNiYiwgMjAyMS8wNC8xNC0wMDozOTo0NCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIDIzLjAgKE1hY2ludG9zaCkiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6RkM4QzQxNUMzMzBEMTFFQ0JEMzZDMDUwQUI4MEI3QTAiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6RkM4QzQxNUQzMzBEMTFFQ0JEMzZDMDUwQUI4MEI3QTAiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDpENjlENTQ3RjMzMDkxMUVDQkQzNkMwNTBBQjgwQjdBMCIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDpENjlENTQ4MDMzMDkxMUVDQkQzNkMwNTBBQjgwQjdBMCIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PsiUYSQAAAAZdEVYdFNvZnR3YXJlAEFkb2JlIEltYWdlUmVhZHlxyWU8AAAA51BMVEVHcEwzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzOguTm2AAAATHRSTlMARhB73r9B7YLrsqdE+0cq9Avzeg31eQx4aQ+Ks6aUd5DsYKixEX1w8vyT2VjoZ3YezY/cCEDvl+QTvRwJ0ifwK/5T/aw6+IuFuCImAcS6MQAAAeJJREFUWMPt2FlX2zAQhuHJYmOSFhIggbC0QNn3rS1dKXSH9///Hi58CJLxKIpEWi6YO8c5z4lG/nxGEXmu/1OVLGnhrFaSVQYg1SZetTTvUibqeFZ9QlfmvRWoV1VmCaCRzroXPpsuAjTV7gLUfPahBqD1OQMW/fazAWTKvQRI/ZgUSJR7U8CM/dHZ+/2VcatWdvdEZAaYUhiAwkerJXt0rnzXwdRKmHfDM0fHD5kxjTFyVLzVfvvirn7+cDJWjhy7c7XlYuwc6Urvu2tRhRypyhwAf1sKY+TIxfQA+H39q5wxc+RgVrcBduTmZTlj5khnDgH4IzKpMGaOVCbvyyvRGTNHGtPrKypjXirM5jb910I4k69oQeKY+77EMAcALEsck/+W6f71tyCma/ZFROTrJVwMy7wmf3bv6/MX+Dgkkysblvxps/dhOKZb6IvrTakzXXuPApnpYneDGOeKvJlaSXcDmA7AicQyW84VeTOnY+NdiWcG1uiZksFEHdyAlsJEjEkmkwGNsKHNZCJGSKtVTYC1tO022mnjwUBrMdXg8dreuOBhv7D/62/8lGZ1wLxXyZKOm+iUHIQintyny0TkaATHjYgcjeAoFpEje9R/nGPqIx2aw3NU9odCQI6e6x/VLY32cKQXVBnkAAAAAElFTkSuQmCC"),Lnt._image}ready(){super.ready(),this.show&&this.onchangeShow(!0)}render(t){var{left:e,top:r,width:n,height:i}=this.bounds;t.beginPath(),this.drawImage(t,Lnt.image,e,r,n,i)}onchange(t,e){"value"in t?this.show?this.onchangeShow(!0):this.show=!0:"show"in t&&this.onchangeShow(this.show)}onchangeShow(t){!this.app.isEditMode&&this.getState("board")&&(t?k9.show(this,this.board,{location:this.getState("location"),modal:this.getState("modal"),closable:this.getState("closable")||!1,data:this.value}):k9.hide(this))}get board(){return this.getState("board")}set board(t){this.set("board",t)}get show(){return this.getState("show")}set show(t){this.setState("show",t)}get started(){return this.getState("show")}set started(t){this.setState("show",t)}get value(){return this.getState("value")}set value(t){this.setState("value",t)}get hasTextProperty(){return!1}get nature(){return jnt}}u9.register("popup",Lnt);class Dnt extends u9{render(t){var{path:e=[]}=this.state;if(!(e.length<=1)){t.beginPath(),t.moveTo(e[0].x,e[0].y);for(let r=1;r<e.length;r++)t.lineTo(e[r].x,e[r].y);t.closePath(),this.drawStroke(t)}}get path(){return this.model.path}set path(t){this.set("path",t)}contains(t,e){var r=this.state.path,n=!1;return r.forEach(((i,a)=>{let o=(a+r.length+1)%r.length,s=i.x,c=i.y,u=r[o].x,l=r[o].y;c>e!=l>e&&t<(u-s)*(e-c)/(l-c)+s&&(n=!n)})),n}}u9.register("path",Dnt);const znt={mutable:!0,resizable:!1,rotatable:!0,properties:[{type:"number",label:"round",name:"round",property:{min:0,max:100,step:1}}],help:"scene/component/triangle"};class Fnt extends l9{contains(t,e){var{x1:r,y1:n,x2:i,y2:a,x3:o,y3:s}=this.state,c=[r,n,i,a,o,s],u=!1;for(let r=0;r<c.length;r+=2){let n=(r+2)%c.length,i=c[r],a=c[r+1],o=c[n+1];a>e!=o>e&&t<(c[n]-i)*(e-a)/(o-a)+i&&(u=!u)}return u}get mutable(){return!0}get path(){var{x1:t,y1:e,x2:r,y2:n,x3:i,y3:a}=this.state;return[{x:t,y:e},{x:r,y:n},{x:i,y:a}]}set path(t){this.set({x1:t[0].x,y1:t[0].y,x2:t[1].x,y2:t[1].y,x3:t[2].x,y3:t[2].y})}get nature(){return znt}}u9.memoize(Fnt.prototype,"path",!1),u9.register("triangle",Fnt);const Nnt={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"number",label:"ratio",name:"ratio",property:"ratio"}],help:"scene/component/donut"};var Bnt={ondragmove:function(t,e,r){r.controls;var{cx:n,rx:i}=r.model;i=Math.abs(i);var a=(r.transcoordP2S(t.x,t.y).x-n)/i*100;a=a>=100||a<=-100?100:Math.abs(a),r.set({ratio:a})}};class Unt extends Zrt{is3dish(){return!1}render(t){var{ratio:e=50,cx:r,cy:n,rx:i,ry:a,startAngle:o,endAngle:s,anticlockwise:c}=this.state;i=Math.abs(i),a=Math.abs(a),t.beginPath(),t.ellipse(r,n,i,a,0,o||0,s||2*Math.PI,c),t.moveTo(r+i/100*e,n),t.ellipse(r,n,i/100*e,a/100*e,0,o||0,s||2*Math.PI,!0)}contains(t,e){var{cx:r,cy:n,rx:i,ry:a,ratio:o}=this.state,s=(t-r)/(2*(i=Math.abs(i))-.5),c=(e-n)/(2*(a=Math.abs(a))-.5),u=(t-r)/(i/100*o*2-.5),l=(e-n)/(a/100*o*2-.5),h=!1;return s*s+c*c<.25&&u*u+l*l>.25&&(h=!h),h}get controls(){var{cx:t,cy:e,rx:r,ratio:n}=this.state;return[{x:t+(r=Math.abs(r))/100*n,y:e,handler:Bnt}]}get nature(){return Nnt}}u9.memoize(Unt.prototype,"controls",!1),u9.register("donut",Unt);const Ynt={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"number",label:"ratio",name:"ratio",property:"ratio"},{type:"number",label:"wing",name:"wing",property:"wing"}],help:"scene/component/star"};var Gnt={ondragmove:function(t,e,r){r.controls;var{cy:n,ry:i}=r.model,a=(r.transcoordP2S(t.x,t.y).y-n)/i*100+100;a>=100?a=100:a<=0&&(a=0),r.set({ratio:a})}};class Wnt extends Zrt{is3dish(){return!1}render(t){var{ratio:e=30,wing:r=5,cx:n,cy:i,rx:a,ry:o,startAngle:s,endAngle:c,anticlockwise:u}=this.state;if(r<3)return;const l=1.5707963267948966;var h=2*Math.PI/r,f=a-e/100*a,d=o-e/100*o;t.save(),t.beginPath(),t.translate(n,i),t.moveTo(a*Math.cos(-l),o*Math.sin(-l)),t.lineTo((a-f)*(Math.cos(h-l)+Math.cos(0-l))/2,(o-d)*(Math.sin(h-l)+Math.sin(0-l))/2);for(var p=1;p<r;p++)t.lineTo(a*Math.cos(h*p-l),o*Math.sin(h*p-l)),t.lineTo((a-f)*(Math.cos(h*(p+1)-l)+Math.cos(h*p-l))/2,(o-d)*(Math.sin(h*(p+1)-l)+Math.sin(h*p-l))/2);t.closePath(),t.restore()}get controls(){var{cx:t,cy:e,ry:r,ratio:n}=this.state;return[{x:t,y:e-r+r*(n/100),handler:Gnt}]}get nature(){return Ynt}}u9.memoize(Wnt.prototype,"controls",!1),u9.register("star",Wnt);var Hnt=t=>class extends t{animOnValueChange(t,e=!1,r){if(t!=this._lastValue){if(e)var n=t-(Number(r)||0);else n=t-(this._lastValue||0);this._lastValue=t,this._anim_alpha=-n,this.animate({step:t=>{this._anim_alpha=n*(t-1),this.invalidate()},duration:1e3,delta:"circ",options:{x:1},ease:"out"}).start()}}dispose(){super.dispose(),delete this._value_substitutor}onchange(t,e){t.hasOwnProperty("value")&&delete this._value_substitutor}get animAlpha(){return this._anim_alpha||0}get animValue(){return(this._lastValue||0)+(this._anim_alpha||0)}defaultValueSubstitutor(){return this.getState("value")}get valueSubstitutor(){return this._value_substitutor||(this._value_substitutor=Z7(this.getState("value"),this)||this.defaultValueSubstitutor),this._value_substitutor}get value(){return Number(this.valueSubstitutor())||0}set value(t){delete this._value_substitutor,this.setState("value",Number(_8(t)))}},qnt=t=>class extends t{_convertDataFormat(t,e){var r;if("json"===e)r=JSON.parse(t);else r=t;return r}isDataSource(){return!0}},Xnt=0;const Vnt=new FinalizationRegistry((()=>{Xnt--}));class Qnt{static get residents(){return Xnt}static get residentsCount(){return Xnt}constructor(t,e){this.counters={},this.references={},this.creator=t,this.disposer=e,Xnt++,Vnt.register(this,Xnt)}dispose(){if(this.disposer)for(let t in this.references)this.disposer.call(null,t,this.references[t]);delete this.references,delete this.counters}get ids(){return Object.keys(this.references)}create(t){var e=this;return new Promise((function(r,n){e.creator?e.creator.call(null,t,(function(e){!function(e){e.release=function(){this.disposer&&this.disposer.call(null,t,e),delete e.release,z8("RELEASED",t)},r(e)}(e)}),(function(t){n(t)})):n(Error("Reference id("+t+") could not be created. Reference creator should be defined."))}))}add(t,e){var r=this,n=new Promise((function(n,i){var a=r.references[t];if(a)a===e?i(Error("Reference ID and target duplicate")):e?i(Error("Reference ID duplicate")):n(a);else{function o(e){e.release=function(){r.release(this)},r.references[t]=e,r.counters[t]=1,n(e)}if(e)o(e);else{if(!r.creator)return void i(Error("Reference id("+t+") is not allowed. Reference creator should be defined."));r.creator.call(null,t,(function(t){o(t)}),(function(t){i(t)}))}}}));return this.references[t]||(this.references[t]=n),n}async get(t,e){var r=this.references[t];if(r){if(!(r instanceof Promise)){if(!(t in this.counters))throw new Error("No Reference Count");return this.counters[t]++,r}if(e)return r=await r,this.counters[t]++,r}if(e)return await this.add(t);throw new Error("No References for "+t)}_id(t){for(let e in this.references){if(this.references[e]===t)return e}return-1}release(t){var e=this._id(t),r=this.references[e];r?(this.counters[e]--,0==this.counters[e]&&(this.disposer&&this.disposer.call(null,e,r),delete this.references[e],delete this.counters[e],delete t.release,z8("RELEASED",e))):L8("No Referenced ID")}}var Knt={},Jnt={},Znt=[];function $nt(t){var e="SCRIPT"==t.target.tagName?Knt:Jnt,r=t.target.src||t.target.href;e[r]=!0,Znt.forEach(((t,n)=>{let{resolve:i,scripts:a,styles:o}=t;if(e==Knt){let t=a.indexOf(r);t>-1&&t<a.length-1&&eit(a[t+1])}for(let t=0;t<a.length;t++)if(!Knt[a[t]])return;if(o)for(let t=0;t<o.length;t++)if(!Jnt[o[t]])return;i(),Znt[n]=null})),Znt=Znt.filter(Boolean)}function tit(t){var e=t.target.src,r="SCRIPT"==t.target.tagName?Knt:Jnt;Znt.forEach(((n,i)=>{let{reject:a,scripts:o,styles:s}=n,c=!1;if(r===Knt){for(let t=0;t<o.length;t++)if(o[t]==e){c=!0;break}}else if(s)for(let t=0;t<s.length;t++)if(s[t]==e){c=!0;break}c&&(a(t),Znt[i]=null)})),Znt=Znt.filter(Boolean),delete r[e],document.head.removeChild(t.target)}function eit(t){Knt[t]=!1;var e=document.createElement("script");e.onload=$nt,e.onerror=tit,e.type="text/javascript",e.src=t,document.head.appendChild(e)}class rit{static load(t,e){return"string"==typeof t&&(t=[t]),"string"==typeof e&&(e=[e]),new Promise((function(r,n){if((!t||t instanceof Array)&&(!e||e instanceof Array)){var i,a=!0;if(e&&e.forEach((t=>{Jnt.hasOwnProperty(t)||function(t){Jnt[t]=!1;var e=document.createElement("link");e.onload=$nt,e.onerror=tit,e.type="text/css",e.rel="stylesheet",e.media="screen,print",e.href=t,document.head.appendChild(e)}(t),Jnt[t]||(a=!1)})),t&&t.length>0&&t.forEach((t=>{Knt.hasOwnProperty(t)?Knt[t]||(a=!1):i=i||t})),i)eit(i);else if(a)return void r();Znt.push({resolve:r,reject:n,scripts:t,styles:e})}else n("invalid sources for load")}))}}const nit="0.0.0";var iit=0,ait=performance.now(),oit=0;function sit(){return iit}requestAnimationFrame((function t(){requestAnimationFrame(t),oit++;var e=performance.now(),r=e-ait;r<1e3||(iit=Math.round(1e3*oit/r),ait=e,oit=0)}));var cit=Ett;function uit(){}export{E9 as AbsoluteLayout,Ent as AudioPlayer,M9 as CardLayout,u9 as Component,G9 as Connectable,Lrt as Container,D9 as ContainerAbstract,J8 as DEFAULT,V8 as DPPX,qnt as DataSource,Unt as Donut,Zrt as Ellipse,ert as EventMap,sit as FPS,Q8 as GESTURES,_nt as GifView,Rnt as GlobalRef,Tnt as Group,b9 as HTMLAbsoluteLayout,Int as HTMLOverlayContainer,unt as HTMLOverlayElement,cnt as ImageView,v9 as InfoWindow,K8 as KEYEVENTS,z9 as Layer,m9 as Layout,Krt as Line,P9 as LinearHorizontalLayout,I9 as LinearVerticalLayout,Ont as LocalRef,X8 as MAX_UNDO_SIZE,G8 as MODE_ADD,U8 as MODE_EDIT,H8 as MODE_PASTE_DATABIND,W8 as MODE_PASTE_STYLE,Y8 as MODE_SHIFT,B8 as MODE_VIEW,cit as Model,j9 as MoveHandle,N8 as NOTHING,ont as OrthoLine,Dnt as Path,ent as Polygon,int as Polyline,Lnt as Popup,q9 as Rect,f9 as RectPath,Qnt as ReferenceMap,drt as RootContainer,V9 as Ruler,q8 as SCENE_MODE,Mrt as Scene,k9 as ScenePopup,rit as ScriptLoader,l9 as Shape,Wnt as Star,C9 as TableLayout,Snt as Text,Fnt as Triangle,Hnt as ValueHolder,Prt as create,z8 as debug,L8 as error,uit as license,g2 as polyfill,nit as version,D8 as warn};console.log("@hatiolab/things-scene@3.4.47 is loaded");
6
+ i=function(){return e};var t,e={},r=Object.prototype,a=r.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},s="function"==typeof Symbol?Symbol:{},c=s.iterator||"@@iterator",u=s.asyncIterator||"@@asyncIterator",l=s.toStringTag||"@@toStringTag";function h(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{h({},"")}catch(t){h=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var i=e&&e.prototype instanceof b?e:b,a=Object.create(i.prototype),s=new C(n||[]);return o(a,"_invoke",{value:T(t,r,s)}),a}function d(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var p="suspendedStart",g="suspendedYield",v="executing",y="completed",m={};function b(){}function x(){}function w(){}var A={};h(A,c,(function(){return this}));var _=Object.getPrototypeOf,k=_&&_(_(R([])));k&&k!==r&&a.call(k,c)&&(A=k);var E=w.prototype=b.prototype=Object.create(A);function S(t){["next","throw","return"].forEach((function(e){h(t,e,(function(t){return this._invoke(e,t)}))}))}function M(t,e){function r(i,o,s,c){var u=d(t[i],t,o);if("throw"!==u.type){var l=u.arg,h=l.value;return h&&"object"==n(h)&&a.call(h,"__await")?e.resolve(h.__await).then((function(t){r("next",t,s,c)}),(function(t){r("throw",t,s,c)})):e.resolve(h).then((function(t){l.value=t,s(l)}),(function(t){return r("throw",t,s,c)}))}c(u.arg)}var i;o(this,"_invoke",{value:function(t,n){function a(){return new e((function(e,i){r(t,n,e,i)}))}return i=i?i.then(a,a):a()}})}function T(e,r,n){var i=p;return function(a,o){if(i===v)throw new Error("Generator is already running");if(i===y){if("throw"===a)throw o;return{value:t,done:!0}}for(n.method=a,n.arg=o;;){var s=n.delegate;if(s){var c=P(s,n);if(c){if(c===m)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===p)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=v;var u=d(e,r,n);if("normal"===u.type){if(i=n.done?y:g,u.arg===m)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(i=y,n.method="throw",n.arg=u.arg)}}}function P(e,r){var n=r.method,i=e.iterator[n];if(i===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,P(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),m;var a=d(i,e.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,m;var o=a.arg;return o?o.done?(r[e.resultName]=o.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,m):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,m)}function O(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function I(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function C(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(O,this),this.reset(!0)}function R(e){if(e||""===e){var r=e[c];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,o=function r(){for(;++i<e.length;)if(a.call(e,i))return r.value=e[i],r.done=!1,r;return r.value=t,r.done=!0,r};return o.next=o}}throw new TypeError(n(e)+" is not iterable")}return x.prototype=w,o(E,"constructor",{value:w,configurable:!0}),o(w,"constructor",{value:x,configurable:!0}),x.displayName=h(w,l,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===x||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,h(t,l,"GeneratorFunction")),t.prototype=Object.create(E),t},e.awrap=function(t){return{__await:t}},S(M.prototype),h(M.prototype,u,(function(){return this})),e.AsyncIterator=M,e.async=function(t,r,n,i,a){void 0===a&&(a=Promise);var o=new M(f(t,r,n,i),a);return e.isGeneratorFunction(r)?o:o.next().then((function(t){return t.done?t.value:o.next()}))},S(E),h(E,l,"Generator"),h(E,c,(function(){return this})),h(E,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=R,C.prototype={constructor:C,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(I),!e)for(var r in this)"t"===r.charAt(0)&&a.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function n(n,i){return s.type="throw",s.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],s=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var c=a.call(o,"catchLoc"),u=a.call(o,"finallyLoc");if(c&&u){if(this.prev<o.catchLoc)return n(o.catchLoc,!0);if(this.prev<o.finallyLoc)return n(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return n(o.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return n(o.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&a.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var o=i?i.completion:{};return o.type=t,o.arg=e,i?(this.method="next",this.next=i.finallyLoc,m):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),m},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),I(r),m}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;I(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:R(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),m}},e}var a=t("./datetime"),o=t("./functions"),s=t("./utils"),c=t("./parser"),u=t("./signature"),l=function(){var t=i().mark(B),e=i().mark(U),r=i().mark(G),l=i().mark(W),h=i().mark(H),f=i().mark(q),d=i().mark(X),p=i().mark(V),g=i().mark(at),v=i().mark(ct),y=i().mark(ht),m=i().mark(ft),b=i().mark(dt),x=i().mark(vt),w=i().mark(bt),A=i().mark(xt),_=i().mark(wt),k=i().mark(At),E=i().mark(kt),S=i().mark(St),M=i().mark(Pt),T=i().mark(Ct),P=s.isNumeric,O=s.isArrayOfStrings,I=s.isArrayOfNumbers,C=s.createSequence,R=s.isSequence,j=s.isFunction,L=s.isLambda,D=s.isIterable,z=s.getFunctionArity,F=s.isDeepEqual,N=jt(null);function B(e,r,n){var a,o,s,c;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:(o=n.lookup("__evaluate_entry"))&&o(e,r,n),t.t0=e.type,t.next="path"===t.t0?5:"binary"===t.t0?8:"unary"===t.t0?11:"name"===t.t0?14:"string"===t.t0||"number"===t.t0||"value"===t.t0?16:"wildcard"===t.t0?18:"descendant"===t.t0?20:"parent"===t.t0?22:"condition"===t.t0?24:"block"===t.t0?27:"bind"===t.t0?30:"regex"===t.t0?33:"function"===t.t0?35:"variable"===t.t0?38:"lambda"===t.t0?40:"partial"===t.t0?42:"apply"===t.t0?45:"transform"===t.t0?48:50;break;case 5:return t.delegateYield(U(e,r,n),"t1",6);case 6:return a=t.t1,t.abrupt("break",50);case 8:return t.delegateYield(X(e,r,n),"t2",9);case 9:return a=t.t2,t.abrupt("break",50);case 11:return t.delegateYield(V(e,r,n),"t3",12);case 12:return a=t.t3,t.abrupt("break",50);case 14:return a=Q(e,r),t.abrupt("break",50);case 16:return a=K(e),t.abrupt("break",50);case 18:return a=J(e,r),t.abrupt("break",50);case 20:return a=$(e,r),t.abrupt("break",50);case 22:return a=n.lookup(e.slot.label),t.abrupt("break",50);case 24:return t.delegateYield(ft(e,r,n),"t4",25);case 25:return a=t.t4,t.abrupt("break",50);case 27:return t.delegateYield(dt(e,r,n),"t5",28);case 28:return a=t.t5,t.abrupt("break",50);case 30:return t.delegateYield(ht(e,r,n),"t6",31);case 31:return a=t.t6,t.abrupt("break",50);case 33:return a=pt(e),t.abrupt("break",50);case 35:return t.delegateYield(xt(e,r,n),"t7",36);case 36:return a=t.t7,t.abrupt("break",50);case 38:return a=gt(e,r,n),t.abrupt("break",50);case 40:return a=_t(e,r,n),t.abrupt("break",50);case 42:return t.delegateYield(kt(e,r,n),"t8",43);case 43:return a=t.t8,t.abrupt("break",50);case 45:return t.delegateYield(bt(e,r,n),"t9",46);case 46:return a=t.t9,t.abrupt("break",50);case 48:return a=yt(e,r,n),t.abrupt("break",50);case 50:if(!n.async||null!=a&&"function"==typeof a.then||(a=Promise.resolve(a)),!n.async||"function"!=typeof a.then||!e.nextFunction||"function"!=typeof a[e.nextFunction]){t.next=54;break}t.next=57;break;case 54:return t.next=56,a;case 56:a=t.sent;case 57:if(!Object.prototype.hasOwnProperty.call(e,"predicate")){t.next=65;break}s=0;case 59:if(!(s<e.predicate.length)){t.next=65;break}return t.delegateYield(q(e.predicate[s].expr,a,n),"t10",61);case 61:a=t.t10;case 62:s++,t.next=59;break;case 65:if("path"===e.type||!Object.prototype.hasOwnProperty.call(e,"group")){t.next=68;break}return t.delegateYield(ct(e.group,a,n),"t11",67);case 67:a=t.t11;case 68:return(c=n.lookup("__evaluate_exit"))&&c(e,r,n,a),a&&R(a)&&!a.tupleStream&&(e.keepArray&&(a.keepSingleton=!0),0===a.length?a=void 0:1===a.length&&(a=a.keepSingleton?a:a[0])),t.abrupt("return",a);case 72:case"end":return t.stop()}}),t)}function U(t,r,n){var a,o,s,c,u,l;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=Array.isArray(r)&&"variable"!==t.steps[0].type?r:C(r),s=!1,c=void 0,u=0;case 4:if(!(u<t.steps.length)){e.next=25;break}if((l=t.steps[u]).tuple&&(s=!0),0!==u||!l.consarray){e.next=12;break}return e.delegateYield(B(l,a,n),"t0",9);case 9:o=e.t0,e.next=19;break;case 12:if(!s){e.next=17;break}return e.delegateYield(H(l,a,c,n),"t1",14);case 14:c=e.t1,e.next=19;break;case 17:return e.delegateYield(G(l,a,n,u===t.steps.length-1),"t2",18);case 18:o=e.t2;case 19:if(s||void 0!==o&&0!==o.length){e.next=21;break}return e.abrupt("break",25);case 21:void 0===l.focus&&(a=o);case 22:u++,e.next=4;break;case 25:if(s)if(t.tuple)o=c;else for(o=C(),u=0;u<c.length;u++)o.push(c[u]["@"]);if(t.keepSingletonArray&&(Array.isArray(o)&&o.cons&&!o.sequence&&(o=C(o)),o.keepSingleton=!0),!t.hasOwnProperty("group")){e.next=30;break}return e.delegateYield(ct(t.group,s?c:o,n),"t3",29);case 29:o=e.t3;case 30:return e.abrupt("return",o);case 31:case"end":return e.stop()}}),e)}function Y(t,e){var r=jt(t);for(var n in e)r.bind(n,e[n]);return r}function G(t,e,n,a){var o,s,c,u,l;return i().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if("sort"!==t.type){r.next=7;break}return r.delegateYield(vt(t,e,n),"t0",2);case 2:if(o=r.t0,!t.stages){r.next=6;break}return r.delegateYield(W(t.stages,o,n),"t1",5);case 5:o=r.t1;case 6:return r.abrupt("return",o);case 7:o=C(),s=0;case 9:if(!(s<e.length)){r.next=24;break}return r.delegateYield(B(t,e[s],n),"t2",11);case 11:if(c=r.t2,!t.stages){r.next=20;break}u=0;case 14:if(!(u<t.stages.length)){r.next=20;break}return r.delegateYield(q(t.stages[u].expr,c,n),"t3",16);case 16:c=r.t3;case 17:u++,r.next=14;break;case 20:void 0!==c&&o.push(c);case 21:s++,r.next=9;break;case 24:return l=C(),a&&1===o.length&&Array.isArray(o[0])&&!R(o[0])?l=o[0]:o.forEach((function(t){!Array.isArray(t)||t.cons?l.push(t):t.forEach((function(t){return l.push(t)}))})),r.abrupt("return",l);case 27:case"end":return r.stop()}}),r)}function W(t,e,r){var n,a,o,s;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:n=e,a=0;case 2:if(!(a<t.length)){i.next=15;break}o=t[a],i.t0=o.type,i.next="filter"===i.t0?7:"index"===i.t0?10:12;break;case 7:return i.delegateYield(q(o.expr,n,r),"t1",8);case 8:return n=i.t1,i.abrupt("break",12);case 10:for(s=0;s<n.length;s++)n[s][o.value]=s;return i.abrupt("break",12);case 12:a++,i.next=2;break;case 15:return i.abrupt("return",n);case 16:case"end":return i.stop()}}),l)}function H(t,e,r,n){var a,o,s,c,u,l,f,d;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if("sort"!==t.type){i.next=15;break}if(!r){i.next=6;break}return i.delegateYield(vt(t,r,n),"t0",3);case 3:a=i.t0,i.next=11;break;case 6:return i.delegateYield(vt(t,e,n),"t1",7);case 7:for(o=i.t1,(a=C()).tupleStream=!0,s=0;s<o.length;s++)(c={"@":o[s]})[t.index]=s,a.push(c);case 11:if(!t.stages){i.next=14;break}return i.delegateYield(W(t.stages,a,n),"t2",13);case 13:a=i.t2;case 14:return i.abrupt("return",a);case 15:(a=C()).tupleStream=!0,u=n,void 0===r&&(r=e.map((function(t){return{"@":t}}))),l=0;case 20:if(!(l<r.length)){i.next=28;break}return u=Y(n,r[l]),i.delegateYield(B(t,r[l]["@"],u),"t3",23);case 23:if(void 0!==(f=i.t3))for(Array.isArray(f)||(f=[f]),d=0;d<f.length;d++)c={},Object.assign(c,r[l]),f.tupleStream?Object.assign(c,f[d]):(t.focus?(c[t.focus]=f[d],c["@"]=r[l]["@"]):c["@"]=f[d],t.index&&(c[t.index]=d),t.ancestor&&(c[t.ancestor.label]=r[l]["@"])),a.push(c);case 25:l++,i.next=20;break;case 28:if(!t.stages){i.next=31;break}return i.delegateYield(W(t.stages,a,n),"t4",30);case 30:a=i.t4;case 31:return i.abrupt("return",a);case 32:case"end":return i.stop()}}),h)}function q(t,e,r){var n,a,s,c,u,l;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(n=C(),e&&e.tupleStream&&(n.tupleStream=!0),Array.isArray(e)||(e=C(e)),"number"!==t.type){i.next=10;break}(a=Math.floor(t.value))<0&&(a=e.length+a),void 0!==(s=e[a])&&(Array.isArray(s)?n=s:n.push(s)),i.next=23;break;case 10:a=0;case 11:if(!(a<e.length)){i.next=23;break}return s=e[a],c=s,u=r,e.tupleStream&&(c=s["@"],u=Y(r,s)),i.delegateYield(B(t,c,u),"t0",17);case 17:l=i.t0,P(l)&&(l=[l]),I(l)?l.forEach((function(t){var r=Math.floor(t);r<0&&(r=e.length+r),r===a&&n.push(s)})):o.boolean(l)&&n.push(s);case 20:a++,i.next=11;break;case 23:return i.abrupt("return",n);case 24:case"end":return i.stop()}}),f)}function X(t,e,r){var n,a,o,s,c;return i().wrap((function(u){for(;;)switch(u.prev=u.next){case 0:return u.delegateYield(B(t.lhs,e,r),"t0",1);case 1:if(a=u.t0,o=t.value,s=i().mark((function n(){return i().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.delegateYield(B(t.rhs,e,r),"t0",1);case 1:return n.abrupt("return",n.t0);case 2:case"end":return n.stop()}}),n)})),"and"!==o&&"or"!==o){u.next=15;break}return u.prev=5,u.delegateYield(at(a,s,o),"t1",7);case 7:return u.abrupt("return",u.t1);case 10:throw u.prev=10,u.t2=u.catch(5),u.t2.position=t.position,u.t2.token=o,u.t2;case 15:return u.delegateYield(s(),"t3",16);case 16:c=u.t3,u.prev=17,u.t4=o,u.next="+"===u.t4||"-"===u.t4||"*"===u.t4||"/"===u.t4||"%"===u.t4?21:"="===u.t4||"!="===u.t4?23:"<"===u.t4||"<="===u.t4||">"===u.t4||">="===u.t4?25:"&"===u.t4?27:".."===u.t4?29:"in"===u.t4?31:33;break;case 21:return n=et(a,c,o),u.abrupt("break",33);case 23:return n=rt(a,c,o),u.abrupt("break",33);case 25:return n=nt(a,c,o),u.abrupt("break",33);case 27:return n=st(a,c),u.abrupt("break",33);case 29:return n=lt(a,c),u.abrupt("break",33);case 31:return n=it(a,c),u.abrupt("break",33);case 33:u.next=40;break;case 35:throw u.prev=35,u.t5=u.catch(17),u.t5.position=t.position,u.t5.token=o,u.t5;case 40:return u.abrupt("return",n);case 41:case"end":return u.stop()}}),d,null,[[5,10],[17,35]])}function V(t,e,r){var n,a,s,c;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:i.t0=t.value,i.next="-"===i.t0?3:"["===i.t0?15:"{"===i.t0?27:30;break;case 3:return i.delegateYield(B(t.expression,e,r),"t1",4);case 4:if(void 0!==(n=i.t1)){i.next=9;break}n=void 0,i.next=14;break;case 9:if(!P(n)){i.next=13;break}n=-n,i.next=14;break;case 13:throw{code:"D1002",stack:(new Error).stack,position:t.position,token:t.value,value:n};case 14:return i.abrupt("break",30);case 15:n=[],a=0;case 17:if(!(a<t.expressions.length)){i.next=25;break}return s=t.expressions[a],i.delegateYield(B(s,e,r),"t2",20);case 20:void 0!==(c=i.t2)&&("["===s.value?n.push(c):n=o.append(n,c));case 22:a++,i.next=17;break;case 25:return t.consarray&&Object.defineProperty(n,"cons",{enumerable:!1,configurable:!1,value:!0}),i.abrupt("break",30);case 27:return i.delegateYield(ct(t,e,r),"t3",28);case 28:return n=i.t3,i.abrupt("break",30);case 30:return i.abrupt("return",n);case 31:case"end":return i.stop()}}),p)}function Q(t,e,r){return o.lookup(e,t.value)}function K(t){return t.value}function J(t,e){var r=C();return Array.isArray(e)&&e.outerWrapper&&e.length>0&&(e=e[0]),null!==e&&"object"===n(e)&&Object.keys(e).forEach((function(t){var n=e[t];Array.isArray(n)?(n=Z(n),r=o.append(r,n)):r.push(n)})),r}function Z(t,e){return void 0===e&&(e=[]),Array.isArray(t)?t.forEach((function(t){Z(t,e)})):e.push(t),e}function $(t,e){var r,n=C();return void 0!==e&&(tt(e,n),r=1===n.length?n[0]:n),r}function tt(t,e){Array.isArray(t)||e.push(t),Array.isArray(t)?t.forEach((function(t){tt(t,e)})):null!==t&&"object"===n(t)&&Object.keys(t).forEach((function(r){tt(t[r],e)}))}function et(t,e,r){var n;if(void 0!==t&&!P(t))throw{code:"T2001",stack:(new Error).stack,value:t};if(void 0!==e&&!P(e))throw{code:"T2002",stack:(new Error).stack,value:e};if(void 0===t||void 0===e)return n;switch(r){case"+":n=t+e;break;case"-":n=t-e;break;case"*":n=t*e;break;case"/":n=t/e;break;case"%":n=t%e}return n}function rt(t,e,r){var i,a=n(t),o=n(e);if("undefined"===a||"undefined"===o)return!1;switch(r){case"=":i=F(t,e);break;case"!=":i=!F(t,e)}return i}function nt(t,e,r){var i,a=n(t),o=n(e);if("undefined"!==a&&"string"!==a&&"number"!==a||"undefined"!==o&&"string"!==o&&"number"!==o)throw{code:"T2010",stack:(new Error).stack,value:"string"!==a&&"number"!==a?t:e};if("undefined"!==a&&"undefined"!==o){if(a!==o)throw{code:"T2009",stack:(new Error).stack,value:t,value2:e};switch(r){case"<":i=t<e;break;case"<=":i=t<=e;break;case">":i=t>e;break;case">=":i=t>=e}return i}}function it(t,e){var r=!1;if(void 0===t||void 0===e)return!1;Array.isArray(e)||(e=[e]);for(var n=0;n<e.length;n++)if(e[n]===t){r=!0;break}return r}function at(t,e,r){var n,a;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:a=ot(t),i.t0=r,i.next="and"===i.t0?4:"or"===i.t0?12:20;break;case 4:if(i.t1=a,!i.t1){i.next=10;break}return i.t2=ot,i.delegateYield(e(),"t3",8);case 8:i.t4=i.t3,i.t1=(0,i.t2)(i.t4);case 10:return n=i.t1,i.abrupt("break",20);case 12:if(i.t5=a,i.t5){i.next=18;break}return i.t6=ot,i.delegateYield(e(),"t7",16);case 16:i.t8=i.t7,i.t5=(0,i.t6)(i.t8);case 18:return n=i.t5,i.abrupt("break",20);case 20:return i.abrupt("return",n);case 21:case"end":return i.stop()}}),g)}function ot(t){var e=o.boolean(t);return void 0!==e&&e}function st(t,e){var r="",n="";return void 0!==t&&(r=o.string(t)),void 0!==e&&(n=o.string(e)),r.concat(n)}function ct(t,e,r){var n,a,s,c,u,l,h,f,d,p,g,y,m;return i().wrap((function(v){for(;;)switch(v.prev=v.next){case 0:n={},a={},s=!(!e||!e.tupleStream),Array.isArray(e)||(e=C(e)),0===e.length&&e.push(void 0),c=0;case 6:if(!(c<e.length)){v.next=31;break}u=e[c],l=s?Y(r,u):r,h=0;case 10:if(!(h<t.lhs.length)){v.next=28;break}return f=t.lhs[h],v.delegateYield(B(f[0],s?u["@"]:u,l),"t0",13);case 13:if("string"==typeof(d=v.t0)||void 0===d){v.next=16;break}throw{code:"T1003",stack:(new Error).stack,position:t.position,value:d};case 16:if(void 0===d){v.next=25;break}if(p={data:u,exprIndex:h},!a.hasOwnProperty(d)){v.next=24;break}if(a[d].exprIndex===h){v.next=21;break}throw{code:"D1009",stack:(new Error).stack,position:t.position,value:d};case 21:a[d].data=o.append(a[d].data,u),v.next=25;break;case 24:a[d]=p;case 25:h++,v.next=10;break;case 28:c++,v.next=6;break;case 31:v.t1=i().keys(a);case 32:if((v.t2=v.t1()).done){v.next=43;break}return d=v.t2.value,p=a[d],g=p.data,l=r,s&&(y=ut(p.data),g=y["@"],delete y["@"],l=Y(r,y)),v.delegateYield(B(t.lhs[p.exprIndex][1],g,l),"t3",39);case 39:void 0!==(m=v.t3)&&(n[d]=m),v.next=32;break;case 43:return v.abrupt("return",n);case 44:case"end":return v.stop()}}),v)}function ut(t){if(!Array.isArray(t))return t;var e={};Object.assign(e,t[0]);for(var r=1;r<t.length;r++)for(var n in t[r])e[n]=o.append(e[n],t[r][n]);return e}function lt(t,e){var r;if(void 0!==t&&!Number.isInteger(t))throw{code:"T2003",stack:(new Error).stack,value:t};if(void 0!==e&&!Number.isInteger(e))throw{code:"T2004",stack:(new Error).stack,value:e};if(void 0===t||void 0===e)return r;if(t>e)return r;var n=e-t+1;if(n>1e7)throw{code:"D2014",stack:(new Error).stack,value:n};r=new Array(n);for(var i=t,a=0;i<=e;i++,a++)r[a]=i;return r.sequence=!0,r}function ht(t,e,r){var n;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return i.delegateYield(B(t.rhs,e,r),"t0",1);case 1:return n=i.t0,r.bind(t.lhs.value,n),i.abrupt("return",n);case 4:case"end":return i.stop()}}),y)}function ft(t,e,r){var n,a;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return i.delegateYield(B(t.condition,e,r),"t0",1);case 1:if(a=i.t0,!o.boolean(a)){i.next=7;break}return i.delegateYield(B(t.then,e,r),"t1",4);case 4:n=i.t1,i.next=10;break;case 7:if(void 0===t.else){i.next=10;break}return i.delegateYield(B(t.else,e,r),"t2",9);case 9:n=i.t2;case 10:return i.abrupt("return",n);case 11:case"end":return i.stop()}}),m)}function dt(t,e,r){var n,a,o;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:a=jt(r),o=0;case 2:if(!(o<t.expressions.length)){i.next=8;break}return i.delegateYield(B(t.expressions[o],e,a),"t0",4);case 4:n=i.t0;case 5:o++,i.next=2;break;case 8:return i.abrupt("return",n);case 9:case"end":return i.stop()}}),b)}function pt(t){var e=new zt.RegexEngine(t.value),r=function r(n,i){var a;e.lastIndex=i||0;var o=e.exec(n);if(null!==o){if(a={match:o[0],start:o.index,end:o.index+o[0].length,groups:[]},o.length>1)for(var s=1;s<o.length;s++)a.groups.push(o[s]);a.next=function(){if(!(e.lastIndex>=n.length)){var i=r(n,e.lastIndex);if(i&&""===i.match)throw{code:"D1004",stack:(new Error).stack,position:t.position,value:t.value.source};return i}}}return a};return r}function gt(t,e,r){return""===t.value?e&&e.outerWrapper?e[0]:e:r.lookup(t.value)}function vt(t,e,r){var a,s,c,u,l;return i().wrap((function(h){for(;;)switch(h.prev=h.next){case 0:return s=e,c=!!e.tupleStream,u=i().mark((function e(a,o){var s,u,l,h,f,d,p,g,v;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:s=0,u=0;case 2:if(!(0===s&&u<t.terms.length)){e.next=35;break}return l=t.terms[u],h=a,f=r,c&&(h=a["@"],f=Y(r,a)),e.delegateYield(B(l.expression,h,f),"t0",8);case 8:return d=e.t0,h=o,f=r,c&&(h=o["@"],f=Y(r,o)),e.delegateYield(B(l.expression,h,f),"t1",13);case 13:if(p=e.t1,g=n(d),v=n(p),"undefined"!==g){e.next=19;break}return s="undefined"===v?0:1,e.abrupt("continue",32);case 19:if("undefined"!==v){e.next=22;break}return s=-1,e.abrupt("continue",32);case 22:if(!("string"!==g&&"number"!==g||"string"!==v&&"number"!==v)){e.next=24;break}throw{code:"T2008",stack:(new Error).stack,position:t.position,value:"string"!==g&&"number"!==g?d:p};case 24:if(g===v){e.next=26;break}throw{code:"T2007",stack:(new Error).stack,position:t.position,value:d,value2:p};case 26:if(d!==p){e.next=30;break}return e.abrupt("continue",32);case 30:s=d<p?-1:1;case 31:!0===l.descending&&(s=-s);case 32:u++,e.next=2;break;case 35:return e.abrupt("return",1===s);case 36:case"end":return e.stop()}}),e)})),l={environment:r,input:e},h.delegateYield(o.sort.apply(l,[s,u]),"t0",5);case 5:return a=h.t0,h.abrupt("return",a);case 7:case"end":return h.stop()}}),x)}function yt(t,e,r){var a=i().mark((function e(a){var o,s,c,u,l,h,f,d,p,g,v;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==a){e.next=2;break}return e.abrupt("return",void 0);case 2:if(o=r.lookup("clone"),j(o)){e.next=5;break}throw{code:"T2013",stack:(new Error).stack,position:t.position};case 5:return e.delegateYield(wt(o,[a],null,r),"t0",6);case 6:return s=e.t0,e.delegateYield(B(t.pattern,s,r),"t1",8);case 8:if(void 0===(c=e.t1)){e.next=35;break}Array.isArray(c)||(c=[c]),u=0;case 12:if(!(u<c.length)){e.next=35;break}if(!(l=c[u])||!(l.isPrototypeOf(s)||l instanceof Object.constructor)){e.next=16;break}throw{code:"D1010",stack:(new Error).stack,position:t.position};case 16:return e.delegateYield(B(t.update,l,r),"t2",17);case 17:if(h=e.t2,"undefined"===(f=n(h))){e.next=23;break}if("object"===f&&null!==h&&!Array.isArray(h)){e.next=22;break}throw{code:"T2011",stack:(new Error).stack,position:t.update.position,value:h};case 22:for(d in h)l[d]=h[d];case 23:if(void 0===t.delete){e.next=32;break}return e.delegateYield(B(t.delete,l,r),"t3",25);case 25:if(void 0===(p=e.t3)){e.next=32;break}if(g=p,Array.isArray(p)||(p=[p]),O(p)){e.next=31;break}throw{code:"T2012",stack:(new Error).stack,position:t.delete.position,value:g};case 31:for(v=0;v<p.length;v++)"object"===n(l)&&null!==l&&delete l[p[v]];case 32:u++,e.next=12;break;case 35:return e.abrupt("return",s);case 36:case"end":return e.stop()}}),e)}));return It(a,"<(oa):o>")}var mt=c("function($f, $g) { function($x){ $g($f($x)) } }");function bt(t,e,r){var n,a,o,s;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return i.delegateYield(B(t.lhs,e,r),"t0",1);case 1:if(a=i.t0,"function"!==t.rhs.type){i.next=7;break}return i.delegateYield(xt(t.rhs,e,r,{context:a}),"t1",4);case 4:n=i.t1,i.next=20;break;case 7:return i.delegateYield(B(t.rhs,e,r),"t2",8);case 8:if(o=i.t2,j(o)){i.next=11;break}throw{code:"T2006",stack:(new Error).stack,position:t.position,value:o};case 11:if(!j(a)){i.next=18;break}return i.delegateYield(B(mt,null,r),"t3",13);case 13:return s=i.t3,i.delegateYield(wt(s,[a,o],null,r),"t4",15);case 15:n=i.t4,i.next=20;break;case 18:return i.delegateYield(wt(o,[a],null,r),"t5",19);case 19:n=i.t5;case 20:return i.abrupt("return",n);case 21:case"end":return i.stop()}}),w)}function xt(t,e,r,a){var o,s,c,u,l,h;return i().wrap((function(f){for(;;)switch(f.prev=f.next){case 0:return f.delegateYield(B(t.procedure,e,r),"t0",1);case 1:if(void 0!==(s=f.t0)||"path"!==t.procedure.type||!r.lookup(t.procedure.steps[0].value)){f.next=4;break}throw{code:"T1005",stack:(new Error).stack,position:t.position,token:t.procedure.steps[0].value};case 4:c=[],void 0!==a&&c.push(a.context),u=i().mark((function n(){var a,o;return i().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.delegateYield(B(t.arguments[l],e,r),"t0",1);case 1:a=n.t0,j(a)?(o=i().mark((function t(){var e,n,o,s=arguments;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:for(e=s.length,n=new Array(e),o=0;o<e;o++)n[o]=s[o];return t.delegateYield(wt(a,n,null,r),"t0",2);case 2:return t.abrupt("return",t.t0);case 3:case"end":return t.stop()}}),t)})),o.arity=z(a),c.push(o)):c.push(a);case 3:case"end":return n.stop()}}),n)})),l=0;case 8:if(!(l<t.arguments.length)){f.next=13;break}return f.delegateYield(u(),"t1",10);case 10:l++,f.next=8;break;case 13:return h="path"===t.procedure.type?t.procedure.steps[0].value:t.procedure.value,f.prev=14,"object"===n(s)&&(s.token=h,s.position=t.position),f.delegateYield(wt(s,c,e,r),"t2",17);case 17:o=f.t2,f.next=25;break;case 20:throw f.prev=20,f.t3=f.catch(14),f.t3.position||(f.t3.position=t.position),f.t3.token||(f.t3.token=h),f.t3;case 25:return f.abrupt("return",o);case 26:case"end":return f.stop()}}),A,null,[[14,20]])}function wt(t,e,r,n){var a,o,s,c;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return i.delegateYield(At(t,e,r,n),"t0",1);case 1:a=i.t0;case 2:if(!L(a)||!0!==a.thunk){i.next=21;break}return i.delegateYield(B(a.body.procedure,a.input,a.environment),"t1",4);case 4:o=i.t1,"variable"===a.body.procedure.type&&(o.token=a.body.procedure.value),o.position=a.body.procedure.position,s=[],c=0;case 9:if(!(c<a.body.arguments.length)){i.next=17;break}return i.t2=s,i.delegateYield(B(a.body.arguments[c],a.input,a.environment),"t3",12);case 12:i.t4=i.t3,i.t2.push.call(i.t2,i.t4);case 14:c++,i.next=9;break;case 17:return i.delegateYield(At(o,s,r,n),"t5",18);case 18:a=i.t5,i.next=2;break;case 21:return i.abrupt("return",a);case 22:case"end":return i.stop()}}),_)}function At(t,e,r,n){var a,o,s;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(i.prev=0,o=e,t&&(o=Et(t.signature,e,r)),!L(t)){i.next=8;break}return i.delegateYield(St(t,o),"t0",5);case 5:a=i.t0,i.next=24;break;case 8:if(!t||!0!==t._jsonata_function){i.next=16;break}if(s={environment:n,input:r},a=t.implementation.apply(s,o),!D(a)){i.next=14;break}return i.delegateYield(a,"t1",13);case 13:a=i.t1;case 14:i.next=24;break;case 16:if("function"!=typeof t){i.next=23;break}if(a=t.apply(r,o),!D(a)){i.next=21;break}return i.delegateYield(a,"t2",20);case 20:a=i.t2;case 21:i.next=24;break;case 23:throw{code:"T1006",stack:(new Error).stack};case 24:i.next=30;break;case 26:throw i.prev=26,i.t3=i.catch(0),t&&(void 0===i.t3.token&&void 0!==t.token&&(i.t3.token=t.token),i.t3.position=t.position||i.t3.position),i.t3;case 30:return i.abrupt("return",a);case 31:case"end":return i.stop()}}),k,null,[[0,26]])}function _t(t,e,r){var n={_jsonata_lambda:!0,input:e,environment:r,arguments:t.arguments,signature:t.signature,body:t.body};return!0===t.thunk&&(n.thunk=!0),n.apply=i().mark((function t(r,a){return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.delegateYield(wt(n,a,e,r.environment),"t0",1);case 1:return t.abrupt("return",t.t0);case 2:case"end":return t.stop()}}),t)})),n}function kt(t,e,r){var n,a,o,s,c;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:a=[],o=0;case 2:if(!(o<t.arguments.length)){i.next=15;break}if("operator"!==(s=t.arguments[o]).type||"?"!==s.value){i.next=8;break}a.push(s),i.next=12;break;case 8:return i.t0=a,i.delegateYield(B(s,e,r),"t1",10);case 10:i.t2=i.t1,i.t0.push.call(i.t0,i.t2);case 12:o++,i.next=2;break;case 15:return i.delegateYield(B(t.procedure,e,r),"t3",16);case 16:if(void 0!==(c=i.t3)||"path"!==t.procedure.type||!r.lookup(t.procedure.steps[0].value)){i.next=19;break}throw{code:"T1007",stack:(new Error).stack,position:t.position,token:t.procedure.steps[0].value};case 19:if(!L(c)){i.next=23;break}n=Mt(c,a),i.next=32;break;case 23:if(!c||!0!==c._jsonata_function){i.next=27;break}n=Tt(c.implementation,a),i.next=32;break;case 27:if("function"!=typeof c){i.next=31;break}n=Tt(c,a),i.next=32;break;case 31:throw{code:"T1008",stack:(new Error).stack,position:t.position,token:"path"===t.procedure.type?t.procedure.steps[0].value:t.procedure.value};case 32:return i.abrupt("return",n);case 33:case"end":return i.stop()}}),E)}function Et(t,e,r){return void 0===t?e:t.validate(e,r)}function St(t,e){var r,n;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(n=jt(t.environment),t.arguments.forEach((function(t,r){n.bind(t.value,e[r])})),"function"!=typeof t.body){i.next=7;break}return i.delegateYield(Pt(t.body,n),"t0",4);case 4:r=i.t0,i.next=9;break;case 7:return i.delegateYield(B(t.body,t.input,n),"t1",8);case 8:r=i.t1;case 9:return i.abrupt("return",r);case 10:case"end":return i.stop()}}),S)}function Mt(t,e){var r=jt(t.environment),n=[];return t.arguments.forEach((function(t,i){var a=e[i];a&&"operator"===a.type&&"?"===a.value?n.push(t):r.bind(t.value,a)})),{_jsonata_lambda:!0,input:t.input,environment:r,arguments:n,body:t.body}}function Tt(t,e){var r=Ot(t),n="function("+(r=r.map((function(t){return"$"+t.trim()}))).join(", ")+"){ _ }",i=c(n);return i.body=t,Mt(i,e)}function Pt(t,e){var r,n,a,o;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(r=Ot(t),n=r.map((function(t){return e.lookup(t.trim())})),a={environment:e},o=t.apply(a,n),!D(o)){i.next=7;break}return i.delegateYield(o,"t0",6);case 6:o=i.t0;case 7:return i.abrupt("return",o);case 8:case"end":return i.stop()}}),M)}function Ot(t){var e=t.toString();return/\(([^)]*)\)/.exec(e)[1].split(",")}function It(t,e){var r={_jsonata_function:!0,implementation:t};return void 0!==e&&(r.signature=u(e)),r}function Ct(t,e){var r,n,a;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(void 0!==t){i.next=2;break}return i.abrupt("return",void 0);case 2:r=this.input,void 0!==e&&(r=e,Array.isArray(r)&&!R(r)&&((r=C(r)).outerWrapper=!0)),i.prev=4,n=c(t,!1),i.next=12;break;case 8:throw i.prev=8,i.t0=i.catch(4),Dt(i.t0),{stack:(new Error).stack,code:"D3120",value:i.t0.message,error:i.t0};case 12:return i.prev=12,i.delegateYield(B(n,r,this.environment),"t1",14);case 14:a=i.t1,i.next=21;break;case 17:throw i.prev=17,i.t2=i.catch(12),Dt(i.t2),{stack:(new Error).stack,code:"D3121",value:i.t2.message,error:i.t2};case 21:return i.abrupt("return",a);case 22:case"end":return i.stop()}}),T,this,[[4,8],[12,17]])}function Rt(t){if(void 0!==t)return JSON.parse(o.string(t))}function jt(t){var e={};return{bind:function(t,r){e[t]=r},lookup:function(r){var n;return e.hasOwnProperty(r)?n=e[r]:t&&(n=t.lookup(r)),n},timestamp:t?t.timestamp:null,async:!!t&&t.async,global:t?t.global:{ancestry:[null]}}}N.bind("sum",It(o.sum,"<a<n>:n>")),N.bind("count",It(o.count,"<a:n>")),N.bind("max",It(o.max,"<a<n>:n>")),N.bind("min",It(o.min,"<a<n>:n>")),N.bind("average",It(o.average,"<a<n>:n>")),N.bind("string",It(o.string,"<x-b?:s>")),N.bind("substring",It(o.substring,"<s-nn?:s>")),N.bind("substringBefore",It(o.substringBefore,"<s-s:s>")),N.bind("substringAfter",It(o.substringAfter,"<s-s:s>")),N.bind("lowercase",It(o.lowercase,"<s-:s>")),N.bind("uppercase",It(o.uppercase,"<s-:s>")),N.bind("length",It(o.length,"<s-:n>")),N.bind("trim",It(o.trim,"<s-:s>")),N.bind("pad",It(o.pad,"<s-ns?:s>")),N.bind("match",It(o.match,"<s-f<s:o>n?:a<o>>")),N.bind("contains",It(o.contains,"<s-(sf):b>")),N.bind("replace",It(o.replace,"<s-(sf)(sf)n?:s>")),N.bind("split",It(o.split,"<s-(sf)n?:a<s>>")),N.bind("join",It(o.join,"<a<s>s?:s>")),N.bind("formatNumber",It(o.formatNumber,"<n-so?:s>")),N.bind("formatBase",It(o.formatBase,"<n-n?:s>")),N.bind("formatInteger",It(a.formatInteger,"<n-s:s>")),N.bind("parseInteger",It(a.parseInteger,"<s-s:n>")),N.bind("number",It(o.number,"<(nsb)-:n>")),N.bind("floor",It(o.floor,"<n-:n>")),N.bind("ceil",It(o.ceil,"<n-:n>")),N.bind("round",It(o.round,"<n-n?:n>")),N.bind("abs",It(o.abs,"<n-:n>")),N.bind("sqrt",It(o.sqrt,"<n-:n>")),N.bind("power",It(o.power,"<n-n:n>")),N.bind("random",It(o.random,"<:n>")),N.bind("boolean",It(o.boolean,"<x-:b>")),N.bind("not",It(o.not,"<x-:b>")),N.bind("map",It(o.map,"<af>")),N.bind("zip",It(o.zip,"<a+>")),N.bind("filter",It(o.filter,"<af>")),N.bind("single",It(o.single,"<af?>")),N.bind("reduce",It(o.foldLeft,"<afj?:j>")),N.bind("sift",It(o.sift,"<o-f?:o>")),N.bind("keys",It(o.keys,"<x-:a<s>>")),N.bind("lookup",It(o.lookup,"<x-s:x>")),N.bind("append",It(o.append,"<xx:a>")),N.bind("exists",It(o.exists,"<x:b>")),N.bind("spread",It(o.spread,"<x-:a<o>>")),N.bind("merge",It(o.merge,"<a<o>:o>")),N.bind("reverse",It(o.reverse,"<a:a>")),N.bind("each",It(o.each,"<o-f:a>")),N.bind("error",It(o.error,"<s?:x>")),N.bind("assert",It(o.assert,"<bs?:x>")),N.bind("type",It(o.type,"<x:s>")),N.bind("sort",It(o.sort,"<af?:a>")),N.bind("shuffle",It(o.shuffle,"<a:a>")),N.bind("distinct",It(o.distinct,"<x:x>")),N.bind("base64encode",It(o.base64encode,"<s-:s>")),N.bind("base64decode",It(o.base64decode,"<s-:s>")),N.bind("encodeUrlComponent",It(o.encodeUrlComponent,"<s-:s>")),N.bind("encodeUrl",It(o.encodeUrl,"<s-:s>")),N.bind("decodeUrlComponent",It(o.decodeUrlComponent,"<s-:s>")),N.bind("decodeUrl",It(o.decodeUrl,"<s-:s>")),N.bind("eval",It(Ct,"<sx?:x>")),N.bind("toMillis",It(a.toMillis,"<s-s?:n>")),N.bind("fromMillis",It(a.fromMillis,"<n-s?s?:s>")),N.bind("clone",It(Rt,"<(oa)-:o>"));var Lt={S0101:"String literal must be terminated by a matching quote",S0102:"Number out of range: {{token}}",S0103:"Unsupported escape sequence: \\{{token}}",S0104:"The escape sequence \\u must be followed by 4 hex digits",S0105:"Quoted property name must be terminated with a backquote (`)",S0106:"Comment has no closing tag",S0201:"Syntax error: {{token}}",S0202:"Expected {{value}}, got {{token}}",S0203:"Expected {{value}} before end of expression",S0204:"Unknown operator: {{token}}",S0205:"Unexpected token: {{token}}",S0206:"Unknown expression type: {{token}}",S0207:"Unexpected end of expression",S0208:"Parameter {{value}} of function definition must be a variable name (start with $)",S0209:"A predicate cannot follow a grouping expression in a step",S0210:"Each step can only have one grouping expression",S0211:"The symbol {{token}} cannot be used as a unary operator",S0212:"The left side of := must be a variable name (start with $)",S0213:"The literal value {{value}} cannot be used as a step within a path expression",S0214:"The right side of {{token}} must be a variable name (start with $)",S0215:"A context variable binding must precede any predicates on a step",S0216:"A context variable binding must precede the 'order-by' clause on a step",S0217:"The object representing the 'parent' cannot be derived from this expression",S0301:"Empty regular expressions are not allowed",S0302:"No terminating / in regular expression",S0402:"Choice groups containing parameterized types are not supported",S0401:"Type parameters can only be applied to functions and arrays",S0500:"Attempted to evaluate an expression containing syntax error(s)",T0410:"Argument {{index}} of function {{token}} does not match function signature",T0411:"Context value is not a compatible type with argument {{index}} of function {{token}}",T0412:"Argument {{index}} of function {{token}} must be an array of {{type}}",D1001:"Number out of range: {{value}}",D1002:"Cannot negate a non-numeric value: {{value}}",T1003:"Key in object structure must evaluate to a string; got: {{value}}",D1004:"Regular expression matches zero length string",T1005:"Attempted to invoke a non-function. Did you mean ${{{token}}}?",T1006:"Attempted to invoke a non-function",T1007:"Attempted to partially apply a non-function. Did you mean ${{{token}}}?",T1008:"Attempted to partially apply a non-function",D1009:"Multiple key definitions evaluate to same key: {{value}}",D1010:"Attempted to access the Javascript object prototype",T1010:"The matcher function argument passed to function {{token}} does not return the correct object structure",T2001:"The left side of the {{token}} operator must evaluate to a number",T2002:"The right side of the {{token}} operator must evaluate to a number",T2003:"The left side of the range operator (..) must evaluate to an integer",T2004:"The right side of the range operator (..) must evaluate to an integer",D2005:"The left side of := must be a variable name (start with $)",T2006:"The right side of the function application operator ~> must be a function",T2007:"Type mismatch when comparing values {{value}} and {{value2}} in order-by clause",T2008:"The expressions within an order-by clause must evaluate to numeric or string values",T2009:"The values {{value}} and {{value2}} either side of operator {{token}} must be of the same data type",T2010:"The expressions either side of operator {{token}} must evaluate to numeric or string values",T2011:"The insert/update clause of the transform expression must evaluate to an object: {{value}}",T2012:"The delete clause of the transform expression must evaluate to a string or array of strings: {{value}}",T2013:"The transform expression clones the input object using the $clone() function. This has been overridden in the current scope by a non-function.",D2014:"The size of the sequence allocated by the range operator (..) must not exceed 1e6. Attempted to allocate {{value}}.",D3001:"Attempting to invoke string function on Infinity or NaN",D3010:"Second argument of replace function cannot be an empty string",D3011:"Fourth argument of replace function must evaluate to a positive number",D3012:"Attempted to replace a matched string with a non-string value",D3020:"Third argument of split function must evaluate to a positive number",D3030:"Unable to cast value to a number: {{value}}",D3040:"Third argument of match function must evaluate to a positive number",D3050:"The second argument of reduce function must be a function with at least two arguments",D3060:"The sqrt function cannot be applied to a negative number: {{value}}",D3061:"The power function has resulted in a value that cannot be represented as a JSON number: base={{value}}, exponent={{exp}}",D3070:"The single argument form of the sort function can only be applied to an array of strings or an array of numbers. Use the second argument to specify a comparison function",D3080:"The picture string must only contain a maximum of two sub-pictures",D3081:"The sub-picture must not contain more than one instance of the 'decimal-separator' character",D3082:"The sub-picture must not contain more than one instance of the 'percent' character",D3083:"The sub-picture must not contain more than one instance of the 'per-mille' character",D3084:"The sub-picture must not contain both a 'percent' and a 'per-mille' character",D3085:"The mantissa part of a sub-picture must contain at least one character that is either an 'optional digit character' or a member of the 'decimal digit family'",D3086:"The sub-picture must not contain a passive character that is preceded by an active character and that is followed by another active character",D3087:"The sub-picture must not contain a 'grouping-separator' character that appears adjacent to a 'decimal-separator' character",D3088:"The sub-picture must not contain a 'grouping-separator' at the end of the integer part",D3089:"The sub-picture must not contain two adjacent instances of the 'grouping-separator' character",D3090:"The integer part of the sub-picture must not contain a member of the 'decimal digit family' that is followed by an instance of the 'optional digit character'",D3091:"The fractional part of the sub-picture must not contain an instance of the 'optional digit character' that is followed by a member of the 'decimal digit family'",D3092:"A sub-picture that contains a 'percent' or 'per-mille' character must not contain a character treated as an 'exponent-separator'",D3093:"The exponent part of the sub-picture must comprise only of one or more characters that are members of the 'decimal digit family'",D3100:"The radix of the formatBase function must be between 2 and 36. It was given {{value}}",D3110:"The argument of the toMillis function must be an ISO 8601 formatted timestamp. Given {{value}}",D3120:"Syntax error in expression passed to function eval: {{value}}",D3121:"Dynamic error evaluating the expression passed to function eval: {{value}}",D3130:"Formatting or parsing an integer as a sequence starting with {{value}} is not supported by this implementation",D3131:"In a decimal digit pattern, all digits must be from the same decimal group",D3132:"Unknown component specifier {{value}} in date/time picture string",D3133:"The 'name' modifier can only be applied to months and days in the date/time picture string, not {{value}}",D3134:"The timezone integer format specifier cannot have more than four digits",D3135:"No matching closing bracket ']' in date/time picture string",D3136:"The date/time picture string is missing specifiers required to parse the timestamp",D3137:"{{{message}}}",D3138:"The $single() function expected exactly 1 matching result. Instead it matched more.",D3139:"The $single() function expected exactly 1 matching result. Instead it matched 0.",D3140:"Malformed URL passed to ${{{functionName}}}(): {{value}}",D3141:"{{{message}}}"};function Dt(t){var e=Lt[t.code];if(void 0!==e){var r=e.replace(/\{\{\{([^}]+)}}}/g,(function(){return t[arguments[1]]}));r=r.replace(/\{\{([^}]+)}}/g,(function(){return JSON.stringify(t[arguments[1]])})),t.message=r}}function zt(t,e){var r,n;try{r=c(t,e&&e.recover),n=r.errors,delete r.errors}catch(t){throw Dt(t),t}var i=jt(N),o=new Date;return i.bind("now",It((function(t,e){return a.fromMillis(o.getTime(),t,e)}),"<s?s?:s>")),i.bind("millis",It((function(){return o.getTime()}),"<:n>")),e&&e.RegexEngine?zt.RegexEngine=e.RegexEngine:zt.RegexEngine=RegExp,{evaluate:function(t,e,a){if(void 0!==n){var s={code:"S0500",position:0};throw Dt(s),s}var c,u,l;if(void 0!==e)for(var h in c=jt(i),e)c.bind(h,e[h]);else c=i;if(c.bind("$",t),o=new Date,c.timestamp=o,Array.isArray(t)&&!R(t)&&((t=C(t)).outerWrapper=!0),"function"==typeof a){c.async=!0;var f=function(t){Dt(t),a(t,null)},d=function t(e){(u=l.next(e)).done?a(null,u.value):u.value.then(t).catch(f)};l=B(r,t,c),(u=l.next()).value.then(d).catch(f)}else try{for(l=B(r,t,c),u=l.next();!u.done;)u=l.next(u.value);return u.value}catch(s){throw Dt(s),s}},assign:function(t,e){i.bind(t,e)},registerFunction:function(t,e,r){var n=It(e,r);i.bind(t,n)},ast:function(){return r},errors:function(){return n}}}return zt.parser=c,zt}();e.exports=l},{"./datetime":1,"./functions":2,"./parser":4,"./signature":5,"./utils":6}],4:[function(t,e,r){var n=t("./signature"),i=function(){var t={".":75,"[":80,"]":0,"{":70,"}":0,"(":80,")":0,",":0,"@":80,"#":80,";":80,":":80,"?":20,"+":50,"-":50,"*":60,"/":60,"%":60,"|":20,"=":40,"<":40,">":40,"^":40,"**":60,"..":20,":=":10,"!=":40,"<=":40,">=":40,"~>":40,and:30,or:25,in:40,"&":50,"!":0,"~":0},e={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"},r=function(r){var n=0,i=r.length,a=function(t,e){return{type:t,value:e,position:n}},o=function(){for(var t,e,a=n,o=0;n<i;){var s=r.charAt(n);if("/"===s&&"\\"!==r.charAt(n-1)&&0===o){if(""===(t=r.substring(a,n)))throw{code:"S0301",stack:(new Error).stack,position:n};for(n++,s=r.charAt(n),a=n;"i"===s||"m"===s;)n++,s=r.charAt(n);return e=r.substring(a,n)+"g",new RegExp(t,e)}"("!==s&&"["!==s&&"{"!==s||"\\"===r.charAt(n-1)||o++,")"!==s&&"]"!==s&&"}"!==s||"\\"===r.charAt(n-1)||o--,n++}throw{code:"S0302",stack:(new Error).stack,position:n}},s=function s(c){if(n>=i)return null;for(var u=r.charAt(n);n<i&&" \t\n\r\v".indexOf(u)>-1;)n++,u=r.charAt(n);if("/"===u&&"*"===r.charAt(n+1)){var l=n;for(n+=2,u=r.charAt(n);"*"!==u||"/"!==r.charAt(n+1);)if(u=r.charAt(++n),n>=i)throw{code:"S0106",stack:(new Error).stack,position:l};return n+=2,u=r.charAt(n),s(c)}if(!0!==c&&"/"===u)return n++,a("regex",o());if("."===u&&"."===r.charAt(n+1))return n+=2,a("operator","..");if(":"===u&&"="===r.charAt(n+1))return n+=2,a("operator",":=");if("!"===u&&"="===r.charAt(n+1))return n+=2,a("operator","!=");if(">"===u&&"="===r.charAt(n+1))return n+=2,a("operator",">=");if("<"===u&&"="===r.charAt(n+1))return n+=2,a("operator","<=");if("*"===u&&"*"===r.charAt(n+1))return n+=2,a("operator","**");if("~"===u&&">"===r.charAt(n+1))return n+=2,a("operator","~>");if(Object.prototype.hasOwnProperty.call(t,u))return n++,a("operator",u);if('"'===u||"'"===u){var h=u;n++;for(var f="";n<i;){if("\\"===(u=r.charAt(n)))if(n++,u=r.charAt(n),Object.prototype.hasOwnProperty.call(e,u))f+=e[u];else{if("u"!==u)throw{code:"S0103",stack:(new Error).stack,position:n,token:u};var d=r.substr(n+1,4);if(!/^[0-9a-fA-F]+$/.test(d))throw{code:"S0104",stack:(new Error).stack,position:n};var p=parseInt(d,16);f+=String.fromCharCode(p),n+=4}else{if(u===h)return n++,a("string",f);f+=u}n++}throw{code:"S0101",stack:(new Error).stack,position:n}}var g,v=/^-?(0|([1-9][0-9]*))(\.[0-9]+)?([Ee][-+]?[0-9]+)?/.exec(r.substring(n));if(null!==v){var y=parseFloat(v[0]);if(!isNaN(y)&&isFinite(y))return n+=v[0].length,a("number",y);throw{code:"S0102",stack:(new Error).stack,position:n,token:v[0]}}if("`"===u){n++;var m=r.indexOf("`",n);if(-1!==m)return g=r.substring(n,m),n=m+1,a("name",g);throw n=i,{code:"S0105",stack:(new Error).stack,position:n}}for(var b,x=n;;)if(b=r.charAt(x),x===i||" \t\n\r\v".indexOf(b)>-1||Object.prototype.hasOwnProperty.call(t,b)){if("$"===r.charAt(n))return g=r.substring(n+1,x),n=x,a("variable",g);switch(g=r.substring(n,x),n=x,g){case"or":case"in":case"and":return a("operator",g);case"true":return a("value",!0);case"false":return a("value",!1);case"null":return a("value",null);default:return n===i&&""===g?null:a("name",g)}}else x++};return s},i=function(e,i){var a,o,s={},c=[],u=function(){var t=[];"(end)"!==a.id&&t.push({type:a.type,value:a.value,position:a.position});for(var e=o();null!==e;)t.push(e),e=o();return t},l={nud:function(){var t={code:"S0211",token:this.value,position:this.position};if(i)return t.remaining=u(),t.type="error",c.push(t),t;throw t.stack=(new Error).stack,t}},h=function(t,e){var r=s[t];return e=e||0,r?e>=r.lbp&&(r.lbp=e):((r=Object.create(l)).id=r.value=t,r.lbp=e,s[t]=r),r},f=function(t){if(i){t.remaining=u(),c.push(t);var e=s["(error)"];return(a=Object.create(e)).error=t,a.type="(error)",a}throw t.stack=(new Error).stack,t},d=function(t,r){if(t&&a.id!==t){var n={code:"(end)"===a.id?"S0203":"S0202",position:a.position,token:a.value,value:t};return f(n)}var i=o(r);if(null===i)return(a=s["(end)"]).position=e.length,a;var c,u=i.value,l=i.type;switch(l){case"name":case"variable":c=s["(name)"];break;case"operator":if(!(c=s[u]))return f({code:"S0204",stack:(new Error).stack,position:i.position,token:u});break;case"string":case"number":case"value":c=s["(literal)"];break;case"regex":l="regex",c=s["(regex)"];break;default:return f({code:"S0205",stack:(new Error).stack,position:i.position,token:u})}return(a=Object.create(c)).value=u,a.type=l,a.position=i.position,a},p=function(t){var e,r=a;for(d(null,!0),e=r.nud();t<a.lbp;)r=a,d(),e=r.led(e);return e},g=function(t){h(t,0).nud=function(){return this}},v=function(e,r,n){var i=r||t[e],a=h(e,i);return a.led=n||function(t){return this.lhs=t,this.rhs=p(i),this.type="binary",this},a},y=function(t,e,r){var n=h(t,e);return n.led=r,n},m=function(t,e){var r=h(t);return r.nud=e||function(){return this.expression=p(70),this.type="unary",this},r};g("(end)"),g("(name)"),g("(literal)"),g("(regex)"),h(":"),h(";"),h(","),h(")"),h("]"),h("}"),h(".."),v("."),v("+"),v("-"),v("*"),v("/"),v("%"),v("="),v("<"),v(">"),v("!="),v("<="),v(">="),v("&"),v("and"),v("or"),v("in"),g("and"),g("or"),g("in"),m("-"),v("~>"),y("(error)",10,(function(t){return this.lhs=t,this.error=a.error,this.remaining=u(),this.type="error",this})),m("*",(function(){return this.type="wildcard",this})),m("**",(function(){return this.type="descendant",this})),m("%",(function(){return this.type="parent",this})),v("(",t["("],(function(t){if(this.procedure=t,this.type="function",this.arguments=[],")"!==a.id)for(;"operator"===a.type&&"?"===a.id?(this.type="partial",this.arguments.push(a),d("?")):this.arguments.push(p(0)),","===a.id;)d(",");if(d(")",!0),"name"===t.type&&("function"===t.value||"λ"===t.value)){if(this.arguments.forEach((function(t,e){if("variable"!==t.type)return f({code:"S0208",stack:(new Error).stack,position:t.position,token:t.value,value:e+1})})),this.type="lambda","<"===a.id){for(var e=a.position,r=1,i="<";r>0&&"{"!==a.id&&"(end)"!==a.id;){var o=d();">"===o.id?r--:"<"===o.id&&r++,i+=o.value}d(">");try{this.signature=n(i)}catch(t){return t.position=e+t.offset,f(t)}}d("{"),this.body=p(0),d("}")}return this})),m("(",(function(){for(var t=[];")"!==a.id&&(t.push(p(0)),";"===a.id);)d(";");return d(")",!0),this.type="block",this.expressions=t,this})),m("[",(function(){var t=[];if("]"!==a.id)for(;;){var e=p(0);if(".."===a.id){var r={type:"binary",value:"..",position:a.position,lhs:e};d(".."),r.rhs=p(0),e=r}if(t.push(e),","!==a.id)break;d(",")}return d("]",!0),this.expressions=t,this.type="unary",this})),v("[",t["["],(function(e){if("]"===a.id){for(var r=e;r&&"binary"===r.type&&"["===r.value;)r=r.lhs;return r.keepArray=!0,d("]"),e}return this.lhs=e,this.rhs=p(t["]"]),this.type="binary",d("]",!0),this})),v("^",t["^"],(function(t){d("(");for(var e=[];;){var r={descending:!1};if("<"===a.id?d("<"):">"===a.id&&(r.descending=!0,d(">")),r.expression=p(0),e.push(r),","!==a.id)break;d(",")}return d(")"),this.lhs=t,this.rhs=e,this.type="binary",this}));var b=function(t){var e=[];if("}"!==a.id)for(;;){var r=p(0);d(":");var n=p(0);if(e.push([r,n]),","!==a.id)break;d(",")}return d("}",!0),void 0===t?(this.lhs=e,this.type="unary"):(this.lhs=t,this.rhs=e,this.type="binary"),this};m("{",b),v("{",t["{"],b),y(":=",t[":="],(function(e){return"variable"!==e.type?f({code:"S0212",stack:(new Error).stack,position:e.position,token:e.value}):(this.lhs=e,this.rhs=p(t[":="]-1),this.type="binary",this)})),v("@",t["@"],(function(e){return this.lhs=e,this.rhs=p(t["@"]),"variable"!==this.rhs.type?f({code:"S0214",stack:(new Error).stack,position:this.rhs.position,token:"@"}):(this.type="binary",this)})),v("#",t["#"],(function(e){return this.lhs=e,this.rhs=p(t["#"]),"variable"!==this.rhs.type?f({code:"S0214",stack:(new Error).stack,position:this.rhs.position,token:"#"}):(this.type="binary",this)})),v("?",t["?"],(function(t){return this.type="condition",this.condition=t,this.then=p(0),":"===a.id&&(d(":"),this.else=p(0)),this})),m("|",(function(){return this.type="transform",this.pattern=p(0),d("|"),this.update=p(0),","===a.id&&(d(","),this.delete=p(0)),d("|"),this}));var x=function t(e){var r;if("function"!==e.type||e.predicate)if("condition"===e.type)e.then=t(e.then),void 0!==e.else&&(e.else=t(e.else)),r=e;else if("block"===e.type){var n=e.expressions.length;n>0&&(e.expressions[n-1]=t(e.expressions[n-1])),r=e}else r=e;else{var i={type:"lambda",thunk:!0,arguments:[],position:e.position};i.body=e,r=i}return r},w=0,A=0,_=[],k=function t(e,r){switch(e.type){case"name":case"wildcard":r.level--,0===r.level&&(void 0===e.ancestor||(_[r.index].slot.label=e.ancestor.label),e.ancestor=r,e.tuple=!0);break;case"parent":r.level++;break;case"block":e.expressions.length>0&&(e.tuple=!0,r=t(e.expressions[e.expressions.length-1],r));break;case"path":e.tuple=!0;var n=e.steps.length-1;for(r=t(e.steps[n--],r);r.level>0&&n>=0;)r=t(e.steps[n--],r);break;default:throw{code:"S0217",token:e.type,position:e.position}}return r},E=function(t,e){if(void 0!==e.seekingParent||"parent"===e.type){var r=void 0!==e.seekingParent?e.seekingParent:[];"parent"===e.type&&r.push(e.slot),void 0===t.seekingParent?t.seekingParent=r:Array.prototype.push.apply(t.seekingParent,r)}},S=function(t){var e=t.steps.length-1,r=t.steps[e],n=void 0!==r.seekingParent?r.seekingParent:[];"parent"===r.type&&n.push(r.slot);for(var i=0;i<n.length;i++){var a=n[i];for(e=t.steps.length-2;a.level>0;){if(e<0){void 0===t.seekingParent?t.seekingParent=[a]:t.seekingParent.push(a);break}for(var o=t.steps[e--];e>=0&&o.focus&&t.steps[e].focus;)o=t.steps[e--];a=k(o,a)}}},M=function t(e){var r;switch(e.type){case"binary":switch(e.value){case".":var n=t(e.lhs);r="path"===n.type?n:{type:"path",steps:[n]},"parent"===n.type&&(r.seekingParent=[n.slot]);var a=t(e.rhs);"function"===a.type&&"path"===a.procedure.type&&1===a.procedure.steps.length&&"name"===a.procedure.steps[0].type&&"function"===r.steps[r.steps.length-1].type&&(r.steps[r.steps.length-1].nextFunction=a.procedure.steps[0].value),"path"===a.type?Array.prototype.push.apply(r.steps,a.steps):(void 0!==a.predicate&&(a.stages=a.predicate,delete a.predicate),r.steps.push(a)),r.steps.filter((function(t){if("number"===t.type||"value"===t.type)throw{code:"S0213",stack:(new Error).stack,position:t.position,value:t.value};return"string"===t.type})).forEach((function(t){t.type="name"})),r.steps.filter((function(t){return!0===t.keepArray})).length>0&&(r.keepSingletonArray=!0);var o=r.steps[0];"unary"===o.type&&"["===o.value&&(o.consarray=!0);var s=r.steps[r.steps.length-1];"unary"===s.type&&"["===s.value&&(s.consarray=!0),S(r);break;case"[":var u=r=t(e.lhs),l="predicate";if("path"===r.type&&(u=r.steps[r.steps.length-1],l="stages"),void 0!==u.group)throw{code:"S0209",stack:(new Error).stack,position:e.position};void 0===u[l]&&(u[l]=[]);var h=t(e.rhs);void 0!==h.seekingParent&&(h.seekingParent.forEach((function(t){1===t.level?k(u,t):t.level--})),E(u,h)),u[l].push({type:"filter",expr:h,position:e.position});break;case"{":if(void 0!==(r=t(e.lhs)).group)throw{code:"S0210",stack:(new Error).stack,position:e.position};r.group={lhs:e.rhs.map((function(e){return[t(e[0]),t(e[1])]})),position:e.position};break;case"^":"path"!==(r=t(e.lhs)).type&&(r={type:"path",steps:[r]});var f={type:"sort",position:e.position};f.terms=e.rhs.map((function(e){var r=t(e.expression);return E(f,r),{descending:e.descending,expression:r}})),r.steps.push(f),S(r);break;case":=":(r={type:"bind",value:e.value,position:e.position}).lhs=t(e.lhs),r.rhs=t(e.rhs),E(r,r.rhs);break;case"@":if(r=t(e.lhs),u=r,"path"===r.type&&(u=r.steps[r.steps.length-1]),void 0!==u.stages||void 0!==u.predicate)throw{code:"S0215",stack:(new Error).stack,position:e.position};if("sort"===u.type)throw{code:"S0216",stack:(new Error).stack,position:e.position};e.keepArray&&(u.keepArray=!0),u.focus=e.rhs.value,u.tuple=!0;break;case"#":r=t(e.lhs),u=r,"path"===r.type?u=r.steps[r.steps.length-1]:(r={type:"path",steps:[r]},void 0!==u.predicate&&(u.stages=u.predicate,delete u.predicate)),void 0===u.stages?u.index=e.rhs.value:u.stages.push({type:"index",value:e.rhs.value,position:e.position}),u.tuple=!0;break;case"~>":(r={type:"apply",value:e.value,position:e.position}).lhs=t(e.lhs),r.rhs=t(e.rhs);break;default:(r={type:e.type,value:e.value,position:e.position}).lhs=t(e.lhs),r.rhs=t(e.rhs),E(r,r.lhs),E(r,r.rhs)}break;case"unary":r={type:e.type,value:e.value,position:e.position},"["===e.value?r.expressions=e.expressions.map((function(e){var n=t(e);return E(r,n),n})):"{"===e.value?r.lhs=e.lhs.map((function(e){var n=t(e[0]);E(r,n);var i=t(e[1]);return E(r,i),[n,i]})):(r.expression=t(e.expression),"-"===e.value&&"number"===r.expression.type?(r=r.expression).value=-r.value:E(r,r.expression));break;case"function":case"partial":(r={type:e.type,name:e.name,value:e.value,position:e.position}).arguments=e.arguments.map((function(e){var n=t(e);return E(r,n),n})),r.procedure=t(e.procedure);break;case"lambda":r={type:e.type,arguments:e.arguments,signature:e.signature,position:e.position};var d=t(e.body);r.body=x(d);break;case"condition":(r={type:e.type,position:e.position}).condition=t(e.condition),E(r,r.condition),r.then=t(e.then),E(r,r.then),void 0!==e.else&&(r.else=t(e.else),E(r,r.else));break;case"transform":(r={type:e.type,position:e.position}).pattern=t(e.pattern),r.update=t(e.update),void 0!==e.delete&&(r.delete=t(e.delete));break;case"block":(r={type:e.type,position:e.position}).expressions=e.expressions.map((function(e){var n=t(e);return E(r,n),(n.consarray||"path"===n.type&&n.steps[0].consarray)&&(r.consarray=!0),n}));break;case"name":r={type:"path",steps:[e]},e.keepArray&&(r.keepSingletonArray=!0);break;case"parent":r={type:"parent",slot:{label:"!"+w++,level:1,index:A++}},_.push(r);break;case"string":case"number":case"value":case"wildcard":case"descendant":case"variable":case"regex":r=e;break;case"operator":if("and"===e.value||"or"===e.value||"in"===e.value)e.type="name",r=t(e);else{if("?"!==e.value)throw{code:"S0201",stack:(new Error).stack,position:e.position,token:e.value};r=e}break;case"error":r=e,e.lhs&&(r=t(e.lhs));break;default:var p="S0206";"(end)"===e.id&&(p="S0207");var g={code:p,position:e.position,token:e.value};if(i)return c.push(g),{type:"error",error:g};throw g.stack=(new Error).stack,g}return e.keepArray&&(r.keepArray=!0),r};o=r(e),d();var T=p(0);if("(end)"!==a.id){var P={code:"S0201",position:a.position,token:a.value};f(P)}if("parent"===(T=M(T)).type||void 0!==T.seekingParent)throw{code:"S0217",token:T.type,position:T.position};return c.length>0&&(T.errors=c),T};return i}();e.exports=i},{"./signature":5}],5:[function(t,e,r){function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}var i=t("./utils"),a=function(){var t={a:"arrays",b:"booleans",f:"functions",n:"numbers",o:"objects",s:"strings"};function e(e){for(var r=1,a=[],o={},s=o;r<e.length;){var c=e.charAt(r);if(":"===c)break;var u=function(){a.push(o),s=o,o={}},l=function(t,e,r,n){for(var i=1,a=e;a<t.length;)if(a++,(c=t.charAt(a))===n){if(0==--i)break}else c===r&&i++;return a};switch(c){case"s":case"n":case"b":case"l":case"o":o.regex="["+c+"m]",o.type=c,u();break;case"a":o.regex="[asnblfom]",o.type=c,o.array=!0,u();break;case"f":o.regex="f",o.type=c,u();break;case"j":o.regex="[asnblom]",o.type=c,u();break;case"x":o.regex="[asnblfom]",o.type=c,u();break;case"-":s.context=!0,s.contextRegex=new RegExp(s.regex),s.regex+="?";break;case"?":case"+":s.regex+=c;break;case"(":var h=l(e,r,"(",")"),f=e.substring(r+1,h);if(-1!==f.indexOf("<"))throw{code:"S0402",stack:(new Error).stack,value:f,offset:r};o.regex="["+f+"m]",o.type="("+f+")",r=h,u();break;case"<":if("a"!==s.type&&"f"!==s.type)throw{code:"S0401",stack:(new Error).stack,value:s.type,offset:r};var d=l(e,r,"<",">");s.subtype=e.substring(r+1,d),r=d}r++}var p="^"+a.map((function(t){return"("+t.regex+")"})).join("")+"$",g=new RegExp(p),v=function(t){var e;if(i.isFunction(t))e="f";else switch(n(t)){case"string":e="s";break;case"number":e="n";break;case"boolean":e="b";break;case"object":e=null===t?"l":Array.isArray(t)?"a":"o";break;default:e="m"}return e},y=function(t,e){for(var r="^",n=0,i=0;i<a.length;i++){r+=a[i].regex;var o=e.match(r);if(null===o)throw{code:"T0410",stack:(new Error).stack,value:t[n],index:n+1};n=o[0].length}throw{code:"T0410",stack:(new Error).stack,value:t[n],index:n+1}};return{definition:e,validate:function(e,r){var n="";e.forEach((function(t){n+=v(t)}));var i=g.exec(n);if(i){var o=[],s=0;return a.forEach((function(n,a){var c=e[s],u=i[a+1];if(""===u)if(n.context&&n.contextRegex){var l=v(r);if(!n.contextRegex.test(l))throw{code:"T0411",stack:(new Error).stack,value:r,index:s+1};o.push(r)}else o.push(c),s++;else u.split("").forEach((function(r){if("a"===n.type){if("m"===r)c=void 0;else{c=e[s];var i=!0;if(void 0!==n.subtype)if("a"!==r&&u!==n.subtype)i=!1;else if("a"===r&&c.length>0){var a=v(c[0]);i=a===n.subtype.charAt(0)&&0===c.filter((function(t){return v(t)!==a})).length}if(!i)throw{code:"T0412",stack:(new Error).stack,value:c,index:s+1,type:t[n.subtype]};"a"!==r&&(c=[c])}o.push(c),s++}else o.push(c),s++}))})),o}y(e,n)}}}return e}();e.exports=a},{"./utils":6}],6:[function(t,e,r){function n(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=i(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,a=function(){};return{s:a,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){c=!0,o=t},f:function(){try{s||null==r.return||r.return()}finally{if(c)throw o}}}}function i(t,e){if(t){if("string"==typeof t)return a(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?a(t,e):void 0}}function a(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function o(t){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},o(t)}var s=function(){function t(t){var e=!1;if("number"==typeof t&&(e=!isNaN(t))&&!isFinite(t))throw{code:"D1001",value:t,stack:(new Error).stack};return e}function e(t){var e=!1;return Array.isArray(t)&&(e=0===t.filter((function(t){return"string"!=typeof t})).length),e}function r(e){var r=!1;return Array.isArray(e)&&(r=0===e.filter((function(e){return!t(e)})).length),r}function i(){var t=[];return t.sequence=!0,1===arguments.length&&t.push(arguments[0]),t}function a(t){return!0===t.sequence&&Array.isArray(t)}function s(t){return t&&(!0===t._jsonata_function||!0===t._jsonata_lambda)||"function"==typeof t}function c(t){return"number"==typeof t.arity?t.arity:"function"==typeof t.implementation?t.implementation.length:"number"==typeof t.length?t.length:t.arguments.length}function u(t){return t&&!0===t._jsonata_lambda}var l=("function"==typeof Symbol?Symbol:{}).iterator||"@@iterator";function h(t){return"object"===o(t)&&null!==t&&l in t&&"next"in t&&"function"==typeof t.next}function f(t,e){if(t===e)return!0;if("object"===o(t)&&"object"===o(e)&&null!==t&&null!==e){if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return!1;for(var r=0;r<t.length;r++)if(!f(t[r],e[r]))return!1;return!0}var n=Object.getOwnPropertyNames(t),i=Object.getOwnPropertyNames(e);if(n.length!==i.length)return!1;for(n=n.sort(),i=i.sort(),r=0;r<n.length;r++)if(n[r]!==i[r])return!1;for(r=0;r<n.length;r++){var a=n[r];if(!f(t[a],e[a]))return!1}return!0}return!1}function d(t){var e,r=[],i=n(t);try{for(i.s();!(e=i.n()).done;){var a=e.value;r.push(a)}}catch(t){i.e(t)}finally{i.f()}return r}return{isNumeric:t,isArrayOfStrings:e,isArrayOfNumbers:r,createSequence:i,isSequence:a,isFunction:s,isLambda:u,isIterable:h,getFunctionArity:c,isDeepEqual:f,stringToArray:d}}();e.exports=s},{}]},{},[3])(3)}(c7);var u7=c7.exports;const l7=function(t){return t};function h7(t){if(!t)return l7;try{var e=u7(t);return function(t){return e.evaluate(t)}}catch(t){return console.error(t),l7}}function f7(t){var e=_8(t);return null==e?"":String(e)}function d7(t){return Number(_8(t))}function p7(t){return t}function g7(t){return f7(t)}function v7(t){return d7(t)}function y7(t){if(this.param)return t=f7(t),this.param.hasOwnProperty(t)?this.param[t]:this.param.default}function m7(t){var{param:e}=this;if(e){for(let r in e){let[n,i]=r.split("~"),a=!!n,o=!!i;if(n=parseFloat(n),i=parseFloat(i),t=d7(t),a&&!o&&t>=n)return e[r];if(!a&&o&&t<n)return e[r];if(t>=n&&t<i)return e[r]}return e.default}}function b7(t){return d7(t)*Math.PI/180}function x7(){}function w7(t,e,r,n,i){switch(r){case"value":return"text"===i||"string"===i?g7.bind(t):"number"===i?v7.bind(t):p7.bind(e);case"map":return y7.bind(t);case"range":return m7.bind(t);case"radian":return b7.bind(t);case"eval":return function(t){try{return new Function("value","targets",t)}catch(t){return L8(t),x7}}(n).bind(e);default:return p7.bind(e)}}class A7{constructor(t,e){this.owner=e,this.model=t}dispose(){delete this._model,delete this.owner,delete this.evaluator,delete this.accessor,delete this.source}get model(){return this._model}set model(t){var{target:e,property:r,rule:n,param:i,accessor:a}=t;this._model=t,this.evaluator=w7(this,this.owner,n,i,function(t){switch(t){case"ref":case"fillStyle":case"strokeStyle":return"string";default:return}}(r)),this.accessor=h7(a);const o=e.match(/\[(.*?)\]/);if(o){var[s,c]=o[1].split(":");this.propAccessor=h7(s),this.partAccessor=h7(c)}}get target(){return this.model.target}get property(){return this.model.property}get source(){return this.model.source}get param(){return this.model.param}get ndnsp(){return!!this.model.ndnsp}get partial(){return!!this.model.partial}}function _7(t,e,r,n){n?t.forEach((t=>t[e]={...t[e],...r})):t.forEach((t=>t[e]=r))}function k7(t=!1){(t||void 0!==this.data)&&this.mappings&&this.mappings.forEach((t=>{try{var e,{source:r,target:n,property:i,accessor:a,propAccessor:o,partAccessor:s,ndnsp:c=!1,partial:u=!1}=t;r&&"(self)"!=r?(r.startsWith("#")&&(r=r.substring(1)),e=this.root.findById(r)?.data||{}):e=this.data;var l=a(e);if("(root)"==(n=n.trim())||"(key)"==n){if(null==l)return;let e=Object.keys(l||{}).map((t=>this.root.findOrCreate(t))).filter(Boolean).flat();e.length>0&&e.forEach((e=>{let r=t.evaluator(l[e.get("id")],[e]);!i||"(action)"===i||c&&!r&&0!==r&&!1!==r||(e[i]=u?{...e[i],...r}:r)}))}else if(n.startsWith("[")){if(null==l)return;if(l instanceof Array)l.forEach((e=>{let r=o(e);if(r){let n=this.root.findOrCreate(r);if(n){let r=t.evaluator(s(e),n);!i||"(action)"===i||c&&!r&&0!==r&&!1!==r||_7(n,i,r,u)}}}));else{if(!(l instanceof Object))throw String("mapping data should be an object to target property-id.("+l+")");{let e=o(l);if(e){let r=this.root.findOrCreate(e);if(r){let e=t.evaluator(s(l),r);!i||"(action)"===i||c&&!e&&0!==e&&!1!==e||_7(r,i,e,u)}}}}}else{let e=this.root.findAll(n,this);if(e.length>0){let r=t.evaluator(l,e);!i||"(action)"===i||c&&!r&&0!==r&&!1!==r||_7(e,i,r,u)}}}catch(e){L8(e,this,t)}}))}var E7;function S7(t,e,r,n,i){var{alpha:a=1}=n,o=i.fillStyle;if(t.globalAlpha*=a,o)if("string"==typeof o)t.fillStyle=o,t.fill();else if("object"==typeof o)if("gradient"==o.type){t.translate(r.x,r.y);let n,{width:i,height:a}=e;if("linear"==o.gradientType){let e=3.141592653589793,r=o.rotation;if(r>=.436332&&r<=1.13446||r>=2.00713&&r<=2.70526||r>=3.57792&&r<=4.27606||r>=5.14872&&r<=5.84685){let o=Math.sqrt(Math.pow((i-4)/2,2)+Math.pow((a-4)/2,2));o-=o-(i+a)/3,n=t.createLinearGradient(o*Math.cos(r+e),o*Math.sin(r+e),o*Math.cos(r),o*Math.sin(r))}else n=t.createLinearGradient((i-4)/2*Math.cos(r+e),(a-4)/2*Math.sin(r+e),(i-4)/2*Math.cos(r),(a-4)/2*Math.sin(r))}else if("radial"==o.gradientType){let e=.95*Math.sqrt(Math.pow((i-4)/2,2)+Math.pow((a-4)/2,2));switch(o.center){case"center":default:n=t.createRadialGradient(0,0,0,0,0,e);break;case"left-top":n=t.createRadialGradient(-i/2,-a/2,0,-i/2,-a/2,2*e);break;case"right-top":n=t.createRadialGradient(i/2,-a/2,0,i/2,-a/2,2*e);break;case"left-bottom":n=t.createRadialGradient(-i/2,a/2,0,-i/2,a/2,2*e);break;case"right-bottom":n=t.createRadialGradient(i/2,a/2,0,i/2,a/2,2*e)}}o.colorStops.forEach((t=>{if(t.position>=0&&t.position<=1)try{n.addColorStop(t.position,t.color)}catch(e){D8("Invalid Color for colorstop : ",t.color),n.addColorStop(t.position,"#fff")}})),t.fillStyle=n,t.fill(),t.translate(-r.x,-r.y)}else if("pattern"==o.type&&o.image){i.prepareFillIf(!i._pattern_image_origin);var s=i._pattern_image;if(!s)return;let r=0,n=0,a=0,c=0,u=e.left,l=e.top;if(!o.fitPattern){r=o.offsetX,n=o.offsetY;const t=o.width?o.width:s.width,i=o.height?o.height:s.height;switch(o.align){case"center":a=e.width/2-t/2,c=e.height/2-i/2;break;case"left-top":a=0,c=0;break;case"left-bottom":a=0,c=e.height-i;break;case"right-top":a=e.width-t,c=0;break;case"right-bottom":a=e.width-t,c=e.height-i;break;case"left":a=0,c=e.height/2-i/2;break;case"right":a=e.width-t,c=e.height/2-i/2;break;case"top":a=e.width/2-t/2,c=0;break;case"bottom":a=e.width/2-t/2,c=e.height-i}u+=r+a,l+=n+c}t.translate(u,l),o.color&&(t.fillStyle=o.color,t.fill()),o.fitPattern?Math.abs((s.width-e.width)*(s.height-e.height))>1?(delete i._pattern_image,delete i._pattern_image_origin):t.fillStyle=t.createPattern(s,"no-repeat"):t.fillStyle=t.createPattern(s,o.noRepeat?"no-repeat":"repeat"),t.fill(),t.translate(-u,-l)}}function M7(t,e,r){var{strokeStyle:n,lineDash:i,lineWidth:a,lineCap:o,lineJoin:s,alpha:c}=e;if(n&&0!=a){if(o&&(t.lineCap=o),i){var u="round"==o;switch(i){case"solid":i=[0,0];break;case"round-dot":i=u?[0,2*a]:[a,a];break;case"square-dot":i=u?[a,2*a]:[2*a,a];break;case"dash":i=u?[3*a,2.5*a]:[4*a,1.5*a];break;case"dash-dot":i=u?[3*a,3*a,0,3*a]:[4*a,2*a,a,2*a];break;case"long-dash":i=u?[5*a,4*a]:[6*a,3*a];break;case"long-dash-dot":i=u?[5*a,3*a,0,3*a]:[6*a,2*a,a,2*a];break;case"long-dash-dot-dot":i=u?[5*a,2*a,0,2*a,0,2*a]:[6*a,a,a,a,a,a]}t.setLineDash(i)}t.globalAlpha*=c,t.strokeStyle=n,t.lineWidth=a,t.lineJoin=s,t.stroke()}}function T7(t,e,r,n,i,a=0,o=!1,s=!0){a="number"==typeof a?{tl:a,tr:a,br:a,bl:a}:{tl:0,tr:0,br:0,bl:0,...a},t.beginPath(),t.moveTo(e+a.tl,r),t.lineTo(e+n-a.tr,r),t.quadraticCurveTo(e+n,r,e+n,r+a.tr),t.lineTo(e+n,r+i-a.br),t.quadraticCurveTo(e+n,r+i,e+n-a.br,r+i),t.lineTo(e+a.bl,r+i),t.quadraticCurveTo(e,r+i,e,r+i-a.bl),t.lineTo(e,r+a.tl),t.quadraticCurveTo(e,r,e+a.tl,r),t.closePath(),o&&t.fill(),s&&t.stroke()}function P7(t){const e=/(\*\*|__)(.*?)\1|(\*|_)(.*?)\3|([^\*_]+)/g;let r,n=[];for(;null!==(r=e.exec(t));)r[1]?n.push({text:r[2],bold:!0,italic:!1}):r[3]?n.push({text:r[4],bold:!1,italic:!0}):r[5]&&n.push({text:r[5],bold:!1,italic:!1});return n}function O7(t,e,r){if(e.text.length<2)return e;for(var n=2;n<e.text.length;n++){var i=e.text.substring(0,n);if(!(t.measureText(i).width<r))break}return{...e,text:e.text.substring(0,n-1)}}function I7(t,e,r,n,i){var a=String(e).split("\n");return n?[].concat.apply([],a.map((e=>function(t,e,r){var n=[],i=[],a=0;return e.forEach((e=>{for(var o=e.text;o.length>0;){var s=r-a,c=t.measureText(o).width;if(c<=s)i.push({...e,text:o}),a+=c,o="";else{var u=O7(t,{...e,text:o},s);i.push(u),n.push(i),i=[],a=0,o=o.substring(u.text.length)}}})),i.length>0&&n.push(i),n}(t,i?P7(e):[{text:e,bold:!1,italic:!1}],r)))):a.map((t=>i?P7(t):[{text:t,bold:!1,italic:!1}]))}function C7(t,e,r,n,i,a){if(!n)return[];t.save(),t.font=r;var o=I7(t,n,e,!!i,a);return t.restore(),o}function R7(t){var{fontFamily:e=J8.FONT_FAMILY,bold:r=J8.BOLD,italic:n=J8.ITALIC,fontSize:i=J8.FONT_SIZE}=t,a=[];return r&&a.push("bold"),n&&a.push("italic"),a.push(i+"px"),a.push(e),a.join(" ")}function j7(t,e){let r=t.bold||e.bold,n=t.italic||e.italic,i=[];return r&&i.push("bold"),n&&i.push("italic"),i.push(t.fontSize+"px"),i.push(t.fontFamily),i.join(" ")}function L7(t,e,r,n){var{alpha:i,fontColor:a=J8.FONT_COLOR,textAlign:o=J8.TEXT_ALIGN,textBaseline:s=J8.TEXT_BASELINE,textBackgroundStyle:c,fontSize:u,lineHeight:l,textWrap:h,supportMarkdown:f=!0,textOverflow:d,bold:p=J8.BOLD,italic:g=J8.ITALIC}=n;i=void 0!==i?i:1,u||=J8.FONT_SIZE,l||=1.2*u,t.save(),t.beginPath();var{left:v,top:y,width:m,height:b}=e;if(t.font=R7(n),!h&&d){const e=function(t,e,r,n){const i="ellipsis"===t?"…":"",a=e.measureText(i).width;let o=[],s=0;for(let i of r){let r=[];for(let c of i){let i=e.measureText(c.text).width;if(!(s+i<=n-("ellipsis"===t?a:0))){let i=D7(e,c,n-s-("ellipsis"===t?a:0),t);return r.push(i),o.push(r),o}r.push(c),s+=i}o.push(r),s=0}return o}(d,t,r,m);r=e}var x,w=r.length*l;switch(s){case"top":x=y,t.textBaseline="top";break;case"bottom":x=y+b-w+l,t.textBaseline="bottom";break;default:x=y+b/2-w/2+l/2,t.textBaseline="middle"}t.globalAlpha*=i,t.fillStyle=a,r.forEach(((e,i)=>{let s=x+i*l,h=function(t,e,r){return e.reduce(((e,n)=>(t.font=j7(r,n),e+t.measureText(n.text).width)),0)}(t,e,n),f=v;switch(o){case"left":case"justify":f=v;break;case"right":f=v+m-h;break;case"center":f=v+(m-h)/2}if(c&&(t.fillStyle=c,T7(t,f-4,s-u/2-4,h+8,u+8,4,!0,!1),t.fillStyle=a),"justify"===o&&i<r.length-1&&e.length>1){let r=m-h,i=e.length-1,a=r/i;e.forEach(((e,r)=>{t.font=j7(n,e),t.fillText(e.text,f,s),f+=t.measureText(e.text).width+(r<i?a:0)}))}else e.forEach((e=>{t.font=j7(n,e),t.fillText(e.text,f,s),f+=t.measureText(e.text).width}))})),t.restore()}function D7(t,e,r,n){let i="";for(let n=0;n<e.text.length;n++){let a=i+e.text[n];if(t.measureText(a).width>r)break;i=a}return{...e,text:i+("ellipsis"===n?"…":"")}}function z7(t,e,r={x:0,y:0},n=0,i={x:1,y:1}){return t-=r.x,e-=r.y,{x:(t*Math.cos(-n)-e*Math.sin(-n)+r.x)/i.x,y:(t*Math.sin(-n)+e*Math.cos(-n)+r.y)/i.y}}function F7(t,e,r={x:0,y:0},n=0,i={x:1,y:1}){return t-=r.x,e-=r.y,{x:(t*Math.cos(n)-e*Math.sin(n)+r.x)*i.x,y:(t*Math.sin(n)+e*Math.cos(n)+r.y)*i.y}}function N7(t){var e=t.element,r=t.fillStyle,n=e.style;if(r)if("string"==typeof r)n.backgroundColor=r;else switch(r.type){case"pattern":if(n.backgroundImage="url("+r.image+")",n.backgroundColor="transparent",r.fitPattern?n.backgroundSize="100% 100%":r.width||r.height?n.backgroundSize=`${r.width?r.width+"px":"auto"} ${r.height?r.height+"px":"auto"}`:n.backgroundSize="contain",r.fitPattern)n.backgroundRepeat="no-repeat";else{const{offsetX:t,offsetY:e,noRepeat:i,align:a,color:o}=r;if(i&&(n.backgroundRepeat="no-repeat"),o&&(n.backgroundColor=o),a)switch(a){case"center":n.backgroundPosition="center center";break;case"left-top":n.backgroundPosition="left top";break;case"left-bottom":n.backgroundPosition="left bottom";break;case"right-top":n.backgroundPosition="right top";break;case"right-bottom":n.backgroundPosition="right bottom";break;case"left":n.backgroundPosition="left center";break;case"right":n.backgroundPosition="right center";break;case"top":n.backgroundPosition="center top";break;case"bottom":n.backgroundPosition="center bottom"}else t||e?n.backgroundPosition=`${Number(t)||0}px ${Number(e)||0}px`:delete n.backgroundPosition}break;case"gradient":n.background=function(t,e){var r=e.colorStops,n=e.gradientType;if(r instanceof Array&&r.length>0)switch(n){case"radial":return"radial-gradient(farthest-corner at "+function(t,e){var{width:r,height:n}=t.bounds;switch(e){case"center":return[r/2,n/2];case"left-top":return[0,0];case"right-top":return[r,0];case"left-bottom":return[0,n];default:return[r,n]}}(t,e.center||"center").map((t=>t+"px")).join(" ")+","+r.map((t=>`${t.color} ${100*t.position}%`)).join(",")+")";case"linear":return"linear-gradient("+(180*(e.rotation||0)/3.141592653589793+90+"deg")+", "+r.map((t=>`${t.color} ${100*t.position}%`)).join(",")+")"}return""}(t,r)}else n.background="transparent"}E7="undefined"==typeof document?function(t,e){return new Canvas(t,e)}:function(t,e){var r=document.createElement("canvas");return r.width=t,r.height=e,r};const B7={x:1,y:1},U7={x:0,y:0},Y7={boxSizing:"border-box",margin:"0px",position:"absolute",outline:"none"};function G7(t){var{id:e,scale:r=B7,translate:n=U7,bold:i,italic:a,fontFamily:o="",textAlign:s,textBaseline:c,textOverflow:u,paddingTop:l,paddingBottom:h,paddingLeft:f,paddingRight:d,fontSize:p=J8.FONT_SIZE,lineWidth:g=0,lineDash:v}=t.state;h||=0,l||=0,f||=0,d||=0;var y=t.state.class;t.text;var{strokeStyle:m,fillStyle:b,rotation:x=0,fontColor:w,hidden:A}=t,{left:_,top:k,width:E,height:S}=t.bounds,M=t.element;M.hidden=A,e&&(M.id=e),y&&(M.className=y),Object.assign(M.style,Y7,{fontFamily:o,fontSize:p+"px",left:_+"px",top:k+"px",width:E+"px",height:S+"px",paddingTop:l+"px",paddingRight:d+"px",paddingBottom:h+"px",paddingLeft:f+"px",border:g+"px",borderColor:m,borderStyle:g>0?v||J8.LINE_DASH:"",color:w,fontWeight:i?"bold":"",fontStyle:a?"italic":"",textAlign:"end"==s?"right":"start"==s?"left":s,verticalAlign:c}),N7(t),function(t){if(t.isShadowable()&&t.state.shadow){var e=t.element,{left:r=0,top:n=0,blurSize:i=0,color:a="transparent"}=t.state.shadow;e.style.boxShadow=`${r}px ${n}px ${i}px ${a}`}}(t);var T=t.delta(),P=(r&&r.x||1)*T.sx,O=(r&&r.y||1)*T.sy,I=(x||0)+T.theta,C=T.tx||0,R=T.ty||0;["-webkit-","-moz-","-ms-","-o-",""].forEach((t=>{M.style[t+"transform"]=`rotate(${I}rad) translate(${C}px, ${R}px) scale(${P}, ${O}) perspective(1px)`}))}var W7,H7=[];function q7(){W7=null;var t=performance.now(),e=(H7=H7.filter((t=>X7(t)))).reduce(((e,r)=>{let n=t-r.updatedAt;return n>=r.retention?e.kills.push(r):e.next=0==e.next?r.retention-n:Math.min(e.next,r.retention-n),e}),{next:0,kills:[]});e.kills.forEach((t=>{let e=H7.indexOf(t);-1!=e?(H7.splice(e,1),t.removeSelf(!0)):L8("Should not be here. Maybe reentrance problem.")})),e.next>0&&(W7=setTimeout(V7,Math.max(e.next,500)))}function X7(t){return!t.disposed&&t.retention>0&&!t.isTemplate()&&t.app&&t.app.isViewMode}var V7=d8((function(){requestAnimationFrame(q7)}),500);var Q7=new class{add(t){X7(t)&&-1==H7.indexOf(t)&&(H7.push(t),t.touch()),this.touch()}remove(t){var e=H7.indexOf(t);e>0&&H7.splice(e,1),this.touch()}touch(){null!==W7&&(clearTimeout(W7),W7=null),V7()}get length(){return H7.length}};const K7=function(t){return t};function J7(t){var e=t.indexOf("||"),r="",n="";-1!=e&&(r=t,n=t.substring(e+2,t.length-1).trim(),t=t.replace(t.substring(e,t.length-1),"").trim());var i=t.substr(2,t.length-3).trim().replace(/\[(\w+)\]/g,".$1").replace(/^\./,"").split(".").filter((t=>!!t.trim())),a=i.slice(1);return{defaultValue:n,match:t,originText:r||t,target:i[0],accessor:a.length>0?function(t){return a.reduce(((t,e)=>t?t[e]:void 0),t)}:K7}}function Z7(t,e,r){if(t){var n=r||_8,i=String(t),a=(i.match(/#{[^}]*}/gi)||[]).map((t=>J7(t))),o=(i.match(/\${[^}]*}/gi)||[]).map((t=>J7(t)));if(0!=a.length||0!=o.length)return function(){var t=i;return a.forEach((r=>{let i=n(r.accessor(e.getState(r.target)));t=t.replace(r.originText,void 0===i?r.defaultValue||"":i)})),o.forEach((r=>{let i=e.root.findById(r.target),a=n(r.accessor(i&&i.data));t=t.replace(r.originText,void 0===a?r.defaultValue||"":a)})),t}}}const $7=210*Math.PI/180,t9=150*Math.PI/180;var e9={"data-spread":function(t,e,r){if(t.app.isEditMode){var n=!1;return t.mappings&&t.mappings.forEach((r=>{let i=t.root.findAll(r.target,t);i&&(e.lineWidth=2,i.forEach((r=>{let i=t.center,a=r.center;i=t.transcoordS2C(i.x,i.y,t.rootModel),a=r.transcoordS2C(a.x,a.y,r.rootModel),e.beginPath();const o=e.createLinearGradient(i.x,i.y,a.x,a.y);["#FFA50033","#FFA500"].forEach(((t,e)=>o.addColorStop(e,t))),e.strokeStyle=o,e.fillStyle=o,function(t,e,r,n=10){var i=r.x-e.x,a=r.y-e.y,o=Math.atan2(a,i),s=r.x+n*Math.cos(o+$7),c=r.y+n*Math.sin(o+$7),u=r.x+n*Math.cos(o+t9),l=r.y+n*Math.sin(o+t9);t.beginPath(),t.moveTo(e.x,e.y),t.lineTo(r.x,r.y),t.moveTo(r.x,r.y),t.lineTo(s,c),t.moveTo(r.x,r.y),t.lineTo(u,l),t.stroke()}(e,i,a),n=!0})))})),n}},"bouncing-arrow":function(t,e,r){let{left:n,top:i,width:a}=t.bounds,o=t.state.id,{x:s,y:c}=t.transcoordS2C(n+a/2,i,t.rootModel);const u=2*function(t){const e=100*(1-t)%10;return e<5?e:10-e}(r||0);if(s=Math.max(s,20),c=Math.max(c,20),e.beginPath(),e.moveTo(s-10,c-16+u),e.lineTo(s+10,c-16+u),e.lineTo(s+10,c-8+u),e.lineTo(s+16,c-8+u),e.lineTo(s,c+u),e.lineTo(s-16,c-8+u),e.lineTo(s-10,c-8+u),e.lineTo(s-10,c-16+u),e.lineTo(s-10,c-16+u),e.fillStyle="#FF0000",e.fill(),o){e.beginPath(),e.font="12px Arial";let t=e.measureText(o);e.fillStyle="#FF0000",e.roundRect(s-t.actualBoundingBoxLeft-3+20,c-t.actualBoundingBoxAscent-3-6+u,t.actualBoundingBoxLeft+t.actualBoundingBoxRight+6,t.actualBoundingBoxAscent+t.actualBoundingBoxDescent+6,3),e.fill(),e.fillStyle="white",e.fillText(o,s+20,c-6+u)}return!0},decotag:function(t,e,r){const n=t.decotag;if(n){let{left:r,top:i}=t.bounds,{x:a,y:o}=t.transcoordS2C(r,i,t.rootModel);a=Math.max(a+3,5),o=Math.max(o-8,15),e.font="12px Arial";let s=e.measureText(n);return e.beginPath(),e.fillStyle="#FF0000",e.roundRect(a-s.actualBoundingBoxLeft-3,o-s.actualBoundingBoxAscent-3,s.actualBoundingBoxLeft+s.actualBoundingBoxRight+6,s.actualBoundingBoxAscent+s.actualBoundingBoxDescent+6,3),e.fill(),e.beginPath(),e.fillStyle="white",e.fillText(n,a,o),!0}return!1},anchors:function(t,e,r){if(t.app.isEditMode){var n=!1;return t.anchors&&t.anchors.forEach((r=>{const{name:i,position:a}=r;var{x:o,y:s}=a||{};if(!i)return;var{x:o,y:s}=t.transcoordS2C(o,s,t.rootModel);o+=4,s+=4,e.font="12px Arial";let c=e.measureText(i);e.fillStyle="#FF0000",T7(e,o,s,c.width+6,16,3,!0,!1),e.fillStyle="white",e.fillText(i,o+3,s+13),n=!0})),n}},link:function(t,e,r){var n=!1;if(!t.isLine())return;const{fromEnd:i,toEnd:a}=t;return[i,a].filter(Boolean).forEach((t=>{const{component:r,anchor:i}=t;if(!i)return;const{name:a,position:o}=i||{};if(!a||!o)return;var{x:s,y:c}=o||{},{x:s,y:c}=r.transcoordS2C(s,c,r.rootModel);s+=8,c+=20,e.font="12px Arial";let u=e.measureText(a);e.fillStyle="#FF0000",T7(e,s-u.actualBoundingBoxLeft-4,c-u.actualBoundingBoxAscent-4,u.actualBoundingBoxLeft+u.actualBoundingBoxRight+8,u.actualBoundingBoxAscent+u.actualBoundingBoxDescent+8,4,!0,!1),e.fillStyle="white",e.fillText(a,s,c),n=!0})),n}};function r9(t){return e9[t]}var n9={};const i9={mutable:!1,resizable:!0,rotatable:!0,properties:[],"value-property":"text"},a9=[],o9={theta:0,tx:0,ty:0,sx:1,sy:1,fade:0};var s9=0,c9={};const u9=new FinalizationRegistry((t=>{!function(t){s9--;var e=c9[t];e||(e=c9[t]={up:0,down:0}),e.down++}(t)}));class l9{static get nature(){return i9}static register(t,e){if(!e)return n9[t];n9[t]=e}static get residents(){return c9}static get residentsCount(){return s9}static registerDecorator(t,e){!function(t,e){e9[t]=e}(t,e)}constructor(t,e){this._app=e,this._model=t||{},this._state={},this._delta=Z6(o9),e&&this.animation?.config&&(1==this.animation.config.autoplay||(this.animation.config.autoplay??1))&&(this.animation.started=!0),this.clearCache(),Q7.add(this),function(t){s9++;var e=c9[t];e||(e=c9[t]={up:0,down:0}),e.up++}(t.type),u9.register(this,t.type)}created(){}added(t){}removed(t){}async ready(){if(this.state.persistent){const{isViewMode:t,dataStorage:e}=this.app;t&&(this.data=await e.load(this))}}touch(){this.updatedAt=performance.now()}clearCache(...t){!function(t,...e){0==e.length?t.__cache__={}:e.forEach((e=>delete t.__cache__[e]))}(this,...t)}removeSelf(t){t?this.dispose():this.parent&&this.parent.removeComponent(this)}dispose(){this._animation&&(this._animation.dispose(),delete this._animation),this.disposeMappings(),this.parent&&this.parent.removeComponent(this),delete this._text_substitutor,delete this._value_substitutor,this._disposed=!0,this.retention&&Q7.touch(),this.clearCache(),delete this._app}get nature(){return this.constructor.nature}get disposed(){return!!this._disposed}isLayer(){return!1}isGroup(){return!1}isContainer(){return!1}isLine(){return!1}isRoot(){return!1}isRootModel(){return!1}is3dish(){return!1}isTemplate(){return!!this.get("templatePrefix")}isHTMLElement(){return!1}isConnectable(){return!1}isIdentifiable(){return!0}replaceRefids(t){}get retention(){return Number(this.get("retention"))||0}get hasTextProperty(){return!0}get app(){return!this._app&&this.parent&&(this._app=this.parent.app),this._app}get model(){return this._model}get state(){return Object.assign({},this._model,this._state)}get hierarchy(){var t=Z6(this._model);return this.volatile.forEach((e=>{delete t[e]})),t}get volatile(){return a9}get textHidden(){return!!this._textHidden}set textHidden(t){this._textHidden=!!t,this.invalidate()}get(t){return this._model[t]}set(t,e){if("string"==typeof t)return this.set({[t]:e});var r={},n={},i=!1,a=(t=Z6(t),this);return Object.getOwnPropertyNames(t).forEach((function(e){let o=a._model[e],s=t[e];W4(o,s)||(n[e]=o,r[e]=s,a._model[e]=s,delete a._state[e],i=!0)})),i&&(this.clearCache(),r.hasOwnProperty("text")&&delete this._text_substitutor,r.hasOwnProperty("retention")&&Q7.add(this),r.hasOwnProperty("fillStyle")&&this.onchangeFill(r,n),r.hasOwnProperty("mappings")&&this.onchangeMappings(r,n),r.hasOwnProperty("data")&&this.onchangeData(r,n),this.onchange&&this.onchange(r,n),this.trigger("change",r,n)),this}getState(t){return this._state.hasOwnProperty(t)?this._state[t]:this.get(t)}setState(t,e){if("string"==typeof t)return this.setState({[t]:e});var r={},n={},i=!1,a=(t=Z6(t),this),o=this.getState("sensitive");return Object.getOwnPropertyNames(t).forEach((function(e){let s=a.getState(e),c=t[e];!o&&W4(s,c)||(n[e]=s,r[e]=c,a._state[e]=c,i=!0)})),i&&(this.clearCache(),r.hasOwnProperty("text")&&delete this._text_substitutor,r.hasOwnProperty("fillStyle")&&this.onchangeFill(r,n),r.hasOwnProperty("data")&&this.onchangeData(r,n),this.onchange&&this.onchange(r,n),this.trigger("change",r,n)),this}get root(){return this.isRoot()?this:this.parent&&this.parent.root}get rootModel(){return this.isRootModel()?this:this.parent&&this.parent.rootModel}get parent(){return this._parent}set parent(t){this._parent=t}get anchors(){return this.nature.anchors||[]}findAnchor(t){return this.anchors.find((e=>e.name===t))}isDescendible(t){return!0}getContext(){return this._parent.getContext()}get center(){var t=this.bounds;return{x:t.left+t.width/2,y:t.top+t.height/2}}set center(t){if(t&&!isNaN(t.x)&&!isNaN(t.y)){var e=this.center;if(Math.round(100*t.x)/100!=Math.round(100*e.x)/100||Math.round(100*t.y)/100!=Math.round(100*e.y)/100){var r=t.x-e.x,n=t.y-e.y;this.path=this.path.map((t=>({x:t.x+r,y:t.y+n})))}}}get location(){const{x:t,y:e}=this.center;return{x:t,y:e,z:this.state.zPos}}set location(t){const{x:e,y:r,z:n}=t||{};this.center={x:e,y:r},isNaN(n)||this.setState("zPos",Number(n))}get rotate(){const{rotationX:t,rotationY:e,rotation:r}=this.state;return{x:t,y:e,z:-r}}set rotate(t){const{x:e,y:r,z:n}=t;this.setState({rotationX:e,rotationY:r,rotation:-n})}get dimension(){const{width:t,height:e}=this.bounds,{depth:r}=this.state;return{width:t,height:e,depth:r}}set dimension(t){const{width:e,height:r,depth:n}=t,{top:i,left:a}=this.bounds;this.bounds={top:i,left:a,width:e,height:r},this.setState("depth",n)}get bounds(){var t,e,r,n,i=this.path;t=e=i[0].x,r=n=i[0].y;for(let a=1;a<i.length;a++){let o=i[a];o.x<t?t=o.x:o.x>e&&(e=o.x),o.y<r?r=o.y:o.y>n&&(n=o.y)}return{left:t,top:r,width:e-t,height:n-r}}set bounds(t){var e=this.bounds;if(Math.round(100*t.width)/100!=Math.round(100*e.width)/100||Math.round(100*t.height)/100!=Math.round(100*e.height)/100||Math.round(100*t.left)/100!=Math.round(100*e.left)/100||Math.round(100*t.top)/100!=Math.round(100*e.top)/100){var r=0==e.width?1:t.width/e.width,n=0==e.height?1:t.height/e.height;this.path=this.path.map((i=>({x:t.left+(i.x-e.left)*r,y:t.top+(i.y-e.top)*n})))}}get path(){return L8("이 컴포넌트에 get path 가 구현되어있지 않음.",this),[]}set path(t){L8("이 컴포넌트에 get path 가 구현되어있지 않음.",this)}get drawPath(){return this.path}outline(t){return function(t,e){var r=t.path.slice();if(r&&r.length){var n=1,i=[];if(t.isLine()||r.push(r[0]),e<=0)return t.transcoordS2T(r[0].x,r[0].y);if(e>=1)return t.transcoordS2T(r[r.length-1].x,r[r.length-1].y);for(;r[n];){let t=r[n-1],e=r[n],a=e.x-t.x,o=e.y-t.y;i.push(Math.sqrt(a*a+o*o)),n++}var a=i.reduce((function(t,e){return t+e}),0);n=0;var o=0;do{o+=i[n++]}while(o/a<e);e=(e-(o-=i[--n])/a)*(a/i[n]);var s=r[n%r.length],c=r[(n+1)%r.length],u=s.x+Math.round((c.x-s.x)*e),l=s.y+Math.round((c.y-s.y)*e);return t.transcoordS2T(u,l)}L8("path should not be empty")}(this,t||0)}get strokeStyle(){return this.get("strokeStyle")}set strokeStyle(t){this.set("strokeStyle",t)}get fillStyle(){return this.getState("fillStyle")}set fillStyle(t){this.setState("fillStyle",t)}get fontColor(){return this.get("fontColor")}set fontColor(t){this.set("fontColor",String(_8(t)))}get rotation(){return this.getState("rotation")}set rotation(t){this.setState("rotation",Number(_8(t)))}contains(t,e){return!1}get mutable(){return this.nature.mutable}get resizable(){return this.nature.resizable&&!this.stuck}adjustResize(t,e,r){if(r){let e=this.bounds,r=e.height/e.width,n=t.width-e.width,i=t.height-e.height;n*r>i?i=n*r:n=i/r;let a=t.left-e.left,o=t.top-e.top;return 0!=a&&0!=o?(o=-i,a=-n):0!=a?a=-n:0!=o&&(o=-i),{left:e.left+a,top:e.top+o,width:e.width+n,height:e.height+i}}return t}get rotatable(){return this.nature.rotatable&&!this.stuck}adjustRotation(t,e){if(e||this.app.rotateStepForced){let e=this.app.rotateStep;return Math.floor((t+e/2)/e)*e}return t}get capturable(){return!1!==this.get("capturable")&&(this.app.isEditMode||!this.hidden)}get stuck(){return!!(this.parent&&this.parent.layout.isStuck(this)||this.get("locked"))}findFirst(t,...e){if(t(this,...e))return this}findAll(t,...e){return"string"==typeof t?o7(t,this,e[0]||this):"function"==typeof t&&t(this,...e)?[this]:void 0}capture(t,e,r){if(!this.capturable||r?.(this))return!1;var n=this.transcoordP2S(t,e);return this.contains(n.x,n.y)?this:void 0}prepare(t,e){t(this)}prepareIf(t){t&&this.prepare&&this.prepare((t=>{this.invalidate()}),(t=>{L8(t)}))}get decotag(){const{id:t,tag:e}=this.state;return(t?`#${t}`:"")+(e?`@${e}`:"")}get decorators(){return["decotag","data-spread"]}get reactionDecorators(){return["bouncing-arrow"]}get hidden(){return this.getState("hidden")||!this.data&&0!==this.data&&this.getState("ndns")||this.isTemplate()}set hidden(t){this.setState("hidden",t)}draw(t){t.save(),this.__proto__.hasOwnProperty("_pre_draw")?this._pre_draw(t):this.prerender(t),this.__proto__.hasOwnProperty("_draw")?this._draw(t):this.render(t),this.__proto__.hasOwnProperty("_post_draw")?this._post_draw(t):this.postrender(t),t.restore()}delta(t,e){if(void 0===e)return t?this._delta[t]:this._delta;this._delta[t]=e}prerender(t){var e=this.rotatePoint,{scale:r,rotation:n,shadow:i,alpha:a}=this.state,o=(r&&r.x||1)*this._delta.sx,s=(r&&r.y||1)*this._delta.sy,c=(n||0)+this._delta.theta,{tx:u=0,ty:l=0}=this._delta,h=(a||1)-this._delta.fade;(u||l)&&t.translate(u,l),(1!=o||1!=s||c)&&(t.translate(e.x,e.y),1==o&&1==s||t.scale(o,s),c&&t.rotate(c),t.translate(-e.x,-e.y)),h&&(t.globalAlpha=h),i&&$8(t,i,this),this.app.isEditMode&&this.hidden&&(t.globalAlpha*=.5)}render(t){}postrender(t){this.drawText(t)}drawText(t){!this.textHidden&&this.text&&this.hasTextProperty&&L7(t,this.textBounds,this.textLines(t),this.state)}drawStroke(t,e){M7(t,e?{...this.state,...e}:this.state)}drawFill(t,e){this.fillStyle&&"transparent"!=this.fillStyle&&(S7(t,this.bounds,this.center,e?{...this.state,...e}:this.state,this),function(t){t.shadowColor="transparent"}(t))}animate(t){return this._animate&&this._animate.stop(),this._animate=t6(t),this._animate}move({x:t,y:e}){var r=this.path,n=t,i=e;this.path=r.map((t=>({x:t.x+n,y:t.y+i})))}symmetryX(t){"number"!=typeof t&&(t=this.center.x);var{rotation:e}=this.state,r=this.fillStyle;if(this.set("rotation",2*Math.PI-e),r&&"gradient"===r.type&&"linear"===r.gradientType){var n=Z6(r);n.rotation=(Math.PI-parseFloat(r.rotation||0))%(2*Math.PI),this.set("fillStyle",n)}this.path=this.path.map((e=>({x:2*t-e.x,y:e.y})))}symmetryY(t){this.symmetryX(),this.set("rotation",(Math.PI+this.model.rotation)%(2*Math.PI)),t&&this.move({x:0,y:2*(t-this.center.y)},!1)}get animation(){if(this.app.isViewMode&&!this.isTemplate()){if(!this._animation){var t=this.state.animation;t&&t.oncreate&&(this._animation=(e=this,r=t.oncreate,(n=$5[r.type])?new n(e,r):null))}var e,r,n;return this._animation}}effect(t,e){return function(t,e,r){var n=t7[r.type];n&&n(t,e,r)}(this,t,e)}set started(t){this.animation&&(this.animation.started=t)}invalidate(){this.parent&&this.parent.invalidate()}get font(){return R7(this.model)}get lineHeight(){var t=this.get("lineHeight");return t||1.2*this.fontSize}defaultTextSubstitutor(){var t=this.getState("text");return null==t?"":String(t)}get textSubstitutor(){return this._text_substitutor||(this._text_substitutor=Z7(this.getState("text"),this)||this.defaultTextSubstitutor),this._text_substitutor}get text(){var t=this.get("textFormat");return t?function(t,e){if(!t||isNaN(+e))return e;var r,n,i,a,o,s,c,u,l,h=t.length,f=t.search(/[0-9\-\+#]/),d=f>0?t.substring(0,f):"",p=t.split("").reverse().join(""),g=p.search(/[0-9\-\+#]/),v=h-g,y=t.substring(v,v+1),m=v+("."===y||","===y?1:0),b=g>0?t.substring(m,h):"";if(r=(e="-"===(t=t.substring(f,m)).charAt(0)?-e:+e)<0?e=-e:0,i=(n=t.match(/[^\d\-\+#]/g))&&n[1]&&n[0]||",",t=t.split("."),e=+(e=e.toFixed(t[1]&&t[1].length))+"",o=t[1]&&t[1].lastIndexOf("0"),(!(c=e.split("."))[1]||c[1]&&c[1].length<=o)&&(e=(+e).toFixed(o+1)),u=t[0].split(i),t[0]=u.join(""),(a=t[0]&&t[0].indexOf("0"))>-1)for(;c[0].length<t[0].length-a;)c[0]="0"+c[0];else 0==+c[0]&&(c[0]="");if((e=e.split("."))[0]=c[0],s=u[1]&&u[u.length-1].length){for(p="",v=(l=e[0]).length%s,h=l.length,m=0;m<h;m++)p+=l.charAt(m),!((m-v+1)%s)&&m<h-s&&(p+=i);e[0]=p}return e[1]=t[1]&&e[1]?"."+e[1]:"","0"!==(n=e.join(""))&&""!==n||(r=!1),d+("+"==t[0].substring(0,1)?r?"-":"+":r?"-":"")+n+b}(t,this.textSubstitutor()):this.textSubstitutor()}set text(t){delete this._text_substitutor;var e=_8(t);this.setState("text",null==e?"":String(e))}textLines(t){const{textWrap:e,supportMarkdown:r}=this.state;return C7(t||this.getContext(),this.textBounds.width,this.font,this.text,e,r)}get textBounds(){var{paddingTop:t,paddingLeft:e,paddingRight:r,paddingBottom:n}=this.state;n||=0,t||=0,e||=0,r||=0;var{left:i,top:a,width:o,height:s}=this.bounds;return{left:i+e,top:a+t,width:Math.max(o-e-r,0),height:Math.max(s-t-n,0)}}get textRotation(){return 0}get rotatePoint(){return this.center}trim(){delete this._model[""],"chartjs"!==this._model.type&&delete this._model.chart}get value(){var t=this.nature["value-property"]||"text";return"value"==t?this.getState("value"):this[t]}set value(t){var e=this.nature["value-property"]||"text";"value"==e?this.setState("value",t):this[e]=t}get data(){return this.getState("data")}set data(t){this.setState("data",t),this.touch()}set tap(t){var e=this.model.event?.tap;if(e){const{cx:t,cy:r}=this.center;this.rootModel?._doEventAction(e,this,!0,new CustomEvent("click",{offsetX:t,offsetY:r}))}}get mappings(){return!this._mappings&&this.parent&&this.buildMappings(),this._mappings}serialize(...t){return JSON.stringify(this.hierarchy,...t)}get controls(){}closeScene(t){this.rootModel.closeScene(t)}}l9.union=function(t){var e,r,n,i;return t.forEach((t=>{void 0===e?(e=t.left,r=t.top,n=t.left+t.width,i=t.top+t.height):(e=Math.min(t.left,e),r=Math.min(t.top,r),n=Math.max(t.left+t.width,n),i=Math.max(t.top+t.height,i))})),{left:e,top:r,width:n-e,height:i-r}},l9.transcoordR=z7,l9.transcoordRR=F7,l9.createCanvas=E7,l9.memoize=F8,l9.mixin=j8,l9.drawText=L7,l9.font=R7,l9.textLines=C7,l9.drawStroke=M7,l9.drawFill=S7,l9.reposition=G7,l9.RetentionManager=Q7,l9.template=function(t,e,r){var n=Y5.imports._.templateSettings||Y5;r&&a5(t,e,r)&&(e=void 0),t=N5(t),e=h5({},e,n,S5);var i,a,o=h5({},e.imports,n.imports,S5),s=y4(o),c=function(t,e){return _5(e,(function(e){return t[e]}))}(o,s),u=0,l=e.interpolate||V5,h="__p += '",f=RegExp((e.escape||V5).source+"|"+l.source+"|"+(l===P5?X5:V5).source+"|"+(e.evaluate||V5).source+"|$","g"),d=K5.call(e,"sourceURL")?"//# sourceURL="+(e.sourceURL+"").replace(/\s/g," ")+"\n":"";t.replace(f,(function(e,r,n,o,s,c){return n||(n=o),h+=t.slice(u,c).replace(Q5,T5),r&&(i=!0,h+="' +\n__e("+r+") +\n'"),s&&(a=!0,h+="';\n"+s+";\n__p += '"),n&&(h+="' +\n((__t = ("+n+")) == null ? '' : __t) +\n'"),u=c+e.length,e})),h+="';\n";var p=K5.call(e,"variable")&&e.variable;if(p){if(q5.test(p))throw new Error("Invalid `variable` option passed into `_.template`")}else h="with (obj) {\n"+h+"\n}\n";h=(a?h.replace(G5,""):h).replace(W5,"$1").replace(H5,"$1;"),h="function("+(p||"obj")+") {\n"+(p?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(i?", __e = _.escape":"")+(a?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+h+"return __p\n}";var g=A5((function(){return Function(s,d+"return "+h).apply(void 0,c)}));if(g.source=h,w5(g))throw g;return g},l9.buildSubstitutor=Z7,Object.assign(l9.prototype,{drawEffect:function(t){const{effects:e}=this.state;(e||[]).forEach((e=>{this.effect(t,e)}))},prepareFill:function(t,e){var r=this.fillStyle;if(r&&"pattern"==r.type&&r.image){if("string"!=typeof r.image)return this._pattern_image_origin=this._pattern_image=r.image,void t(this);this._pattern_image=null,this._pattern_image_origin=new Image;var n=this;this._pattern_image_origin.onload=function(){if(!r.fitPattern&&!r.width&&!r.height)return n._pattern_image=n._pattern_image_origin,void t(this);let e=r.width||this.width,i=r.height||this.height;r.fitPattern&&(e=n.bounds.width,i=n.bounds.height);let a=E7(e,i);a.getContext("2d").drawImage(this,0,0,this.width,this.height,0,0,e,i),n._pattern_image=a,t(this)},this._pattern_image_origin.onerror=function(t){e(t)};try{"data"!==String(r.image).substring(0,4)?this._pattern_image_origin.crossOrigin="use-credentials":this._pattern_image_origin.crossOrigin=null,this._pattern_image_origin.src=this.app.url(r.image)}catch(t){e(t)}}else t(this)},prepareFillIf:function(t){t&&this.prepareFill((t=>{this.invalidate()}),(t=>{L8(t)}))},onchangeFill:function(t,e){var r=this.fillStyle;r&&"pattern"!==r.type?this._pattern_image&&(this._pattern_image=null,this._pattern_image_origin=null):r?.image&&this.prepareFillIf(r.image)},drawImage:function(t,e,r,n,i,a){e.complete?t.drawImage(e,r,n,i,a):e.addEventListener("load",(()=>{this.invalidate()}))},mutateBounds:function(t,e){var r=this.bounds,n=this.rotatePoint,i=this.get("rotation"),a=this.get("scale");if(t){var o=t.call(e,r);o&&(r=o)}var{left:s,top:c,width:u,height:l}=r,h=[{x:s,y:c},{x:s+u,y:c+l}],f=(h=h.map((t=>F7(t.x,t.y,n,i,a))))[0],d=h[1];n={x:(f.x+d.x)/2,y:(f.y+d.y)/2},f=(h=h.map((t=>z7(t.x,t.y,n,i,a))))[0],d=h[1],this.bounds={left:f.x,top:f.y,width:d.x-f.x,height:d.y-f.y}},mutatePath:function(t,e,r){var n=this.path,i=this.rotatePoint;this.get("rotation"),this.get("scale"),t&&(n=t.call(r,n));var a=n.map((t=>this.transcoordS2P(t.x,t.y)));e&&(n=e.call(r,a))&&(a=n);var o,s,c,u,l={x:0,y:0};o=s=(n=a.map((t=>this.transcoordP2S(t.x,t.y,l))))[0].x,c=u=n[0].y;for(let t=1;t<n.length;t++){let e=n[t];e.x<o?o=e.x:e.x>s&&(s=e.x),e.y<c?c=e.y:e.y>u&&(u=e.y)}i={x:(o+s)/2,y:(c+u)/2},i=this.transcoordS2P(i.x,i.y,l),this.path=a.map((t=>this.transcoordP2S(t.x,t.y,i)))},access:function(t){if(t){var e=String(t),r=(e.match(/#{(\S*)}/)||[]).map((t=>J7(t)))[0];if(r)return r.accessor(this.getState(r.target));var n=(e.match(/\${[^}]*}/)||[]).map((t=>J7(t)))[0];if(n){let t=this.root.findById(n.target);return n.accessor(this.getState(t))}return t}},substitute:function(t,e){if(t){var r=String(t),n=e||_8,i=(r.match(/#{(\S*)}/gi)||[]).map((t=>J7(t))),a=(r.match(/\${[^}]*}/gi)||[]).map((t=>J7(t)));if(0==i.length&&0==a.length)return r;var o=r;return i.forEach((t=>{let e=n(t.accessor(this.getState(t.target)));o=o.replace(t.match,void 0===e?"":e)})),a.forEach((t=>{let e=this.root.findById(t.target),r=n(t.accessor(e&&e.data));o=o.replace(t.match,void 0===r?"":r)})),o}},onchangeMappings:function(t,e){this.disposeMappings(),k7.call(this)},onchangeData:function(t,e){this.state.persistent&&this.app?.isViewMode&&this.app?.dataStorage.save(this,t.data),k7.call(this,[!0])},buildMappings:function(){if(this._model.mappings)return!this._model.mappings instanceof Array?(L8("Mappings model is invalid (should be a Array) ..",this._model.mappings),void(this._mappings=[])):void(this._mappings=(this._model.mappings||[]).filter((t=>t.rule&&t.target)).map((t=>new A7(t,this))));this._mappings=[]},executeMappings:k7,disposeMappings:function(){this._mappings&&this._mappings.forEach((t=>t.dispose())),delete this._mappings},ondropfile:function(t,e){for(let r=0;r<t.length;r++)if(t[r].type.startsWith("image/"))return void this.set("fillStyle",{type:"pattern",image:e[r],fitPattern:!0})},transcoordS2P:function(t,e,r){if(!this.parent)return{x:t,y:e};var{rotation:n=0,scale:i={x:1,y:1}}=this.state;if(this.isLayer()){let r=this.state.translate,a=F7(t,e,void 0,n+this._delta.theta,i);return r&&(a.x+=r.x,a.y+=r.y),a}r=r||this.rotatePoint;const{theta:a=0,tx:o=0,ty:s=0,sx:c=1,sy:u=1}=this._delta||{},l=F7(t+o,e+s,r={x:r.x+o,y:r.y+s},n+a,i={x:i.x*c,y:i.y*u});return{x:l.x-(r.x*i.x-r.x),y:l.y-(r.y*i.y-r.y)}},transcoordP2S:function(t,e,r){if(!this.parent)return{x:t,y:e};var{rotation:n=0,scale:i={x:1,y:1}}=this.state;if(this.isLayer()){let r=this.state.translate,a=z7(t,e,r,n,i);return r&&(a.x-=r.x/(i?i.x:1),a.y-=r.y/(i?i.y:1)),a}var a=z7(t,e,r=r||this.rotatePoint,n,i);return{x:a.x+(r.x-r.x/i.x),y:a.y+(r.y-r.y/i.y)}},transcoordS2T:function(t,e,r){r=r||this.rootModel;var n=[];for(let t=this.parent;t&&t!==r;t=t.parent)n.push(t);var i=this.transcoordS2P(t,e);return n.forEach((t=>{let{scale:e}=t.model,r=t.bounds;if(e){let n=t.rotatePoint;i.x+=(n.x-r.left)*e.x,i.y+=(n.y-r.top)*e.y}else i.x+=r.left,i.y+=r.top;i=t.transcoordS2P(i.x,i.y)})),i},transcoordT2P:function(t,e,r){r=r||this.rootModel;var n=[];for(let t=this.parent;t&&t!==r;t=t.parent)n.splice(0,0,t);var i={x:t,y:e};return n.forEach((t=>{let{scale:e}=t.model;i=t.transcoordP2S(i.x,i.y);let r=t.bounds;if(e){let n=t.rotatePoint;i.x-=(n.x-r.left)/e.x,i.y-=(n.y-r.top)/e.y}else i.x-=r.left,i.y-=r.top})),i},transcoordT2S:function(t,e,r){var n=this.transcoordT2P(t,e,r);return this.transcoordP2S(n.x,n.y)},transcoordS2TR:function(t,e,r){r=r||this.rootModel;var n=this.transcoordS2T(t,e,r);return F7(n.x,n.y,void 0,(r.get("rotation")||0)+r._delta.theta)},transcoordS2O:function(t,e,r){var n=this.rootModel,i=this.transcoordS2T(t,e,n);return r.transcoordT2S(i.x,i.y,n)},transcoordC2S:function(t,e,r){if(!r)for(r=this;r&&!r.isLayer();)r=r.parent;var{translate:n={x:0,y:0},scale:i={x:1,y:1},rotation:a=0}=r.model,o=z7(t,e,n,a,i);return n&&(o.x-=n.x/(i?i.x:1),o.y-=n.y/(i?i.y:1)),r===this?o:this.transcoordT2S(o.x,o.y,r)},transcoordS2C:function(t,e,r){if(!r)for(r=this;r&&!r.isLayer();)r=r.parent;if(r!==this)var n=this.transcoordS2T(t,e,r);else n={x:t,y:e};var{translate:i={x:0,y:0},rotation:a=0,scale:o={x:1,y:1}}=r.model;return n=F7(n.x,n.y,void 0,a+r._delta.theta,o),i&&(n.x+=i.x,n.y+=i.y),n},_pre_draw:l9.prototype.prerender,_draw:l9.prototype.render,_post_draw:l9.prototype.postrender}),["rotatePoint","font","lineHeight","retention"].forEach((t=>l9.memoize(l9.prototype,t,!1))),["bounds","center","textBounds"].forEach((t=>l9.memoize(l9.prototype,t,!0))),l9.mixin(l9.prototype,P8.withEvent);class h9 extends l9{set rotationX(t){this.setState("rotationX",t)}get rotationX(){return this.getState("rotationX")}set rotationY(t){this.setState("rotationY",t)}get rotationY(){return this.getState("rotationY")}set rotationZ(t){this.setState("rotation",t)}get rotationZ(){return this.getState("rotation")}set zPos(t){this.setState("zPos",t)}get zPos(){return this.getState("zPos")}set depth(t){this.setState("depth",t)}get depth(){return this.getState("depth")}postrender(t){this.drawFill(t),this.drawStroke(t),super.postrender(t)}render(t){var e=this.drawPath,{round:r=0}=this.state;if(!(e.length<=1)){t.beginPath();for(var n=0;n<e.length;n++){const c=e[(n-1+e.length)%e.length],u=e[(n+e.length)%e.length],l=e[(n+1)%e.length];if(c.x===u.x&&c.y===u.y)continue;var i=0!==(s=Math.sqrt((c.x-u.x)*(c.x-u.x)+(c.y-u.y)*(c.y-u.y)))?Math.atan2(c.x-u.x,c.y-u.y):0,a=Math.sin(i)*Math.min(r,s/2)+u.x,o=Math.cos(i)*Math.min(r,s/2)+u.y;const h=r>0||0!==s?{x:a,y:o}:u;var s;i=0!==(s=Math.sqrt((l.x-u.x)*(l.x-u.x)+(l.y-u.y)*(l.y-u.y)))?Math.atan2(l.x-u.x,l.y-u.y):0,a=Math.sin(i)*Math.min(r,s/2)+u.x,o=Math.cos(i)*Math.min(r,s/2)+u.y;const f=r>0||0!==s?{x:a,y:o}:u;0==n?t.moveTo(h.x,h.y):t.lineTo(h.x,h.y),r>0&&t.quadraticCurveTo(u.x,u.y,f.x,f.y)}t.closePath()}}}function f9(t,e,r){return Math.max(0,Math.min(t,Math.min(r,e)/2))}var d9=t=>{var e=class extends t{contains(t,e){var{left:r,top:n,width:i,height:a,lineWidth:o=0}=this.state,s=o/2;return t<Math.max(r+i,r)+s&&t>Math.min(r+i,r)-s&&e<Math.max(n+a,n)+s&&e>Math.min(n+a,n)-s}set path(t){var e=t[0],r=t[2];this.set({left:e.x,top:e.y,width:r.x-e.x,height:r.y-e.y})}get path(){var{left:t=0,top:e=0,width:r=0,height:n=0}=this.state;return[{x:t,y:e},{x:t+r,y:e},{x:t+r,y:e+n},{x:t,y:e+n}]}get anchors(){return function(t){var{left:e,top:r,width:n,height:i}=t.bounds,a=e+n/2,o=r+i/2;return[{name:"TOP",position:{x:a,y:r}},{name:"RIGHT",position:{x:e+n,y:o}},{name:"BOTTOM",position:{x:a,y:r+i}},{name:"LEFT",position:{x:e,y:o}}]}(this)}render(t){var{round:e=0}=this.model,{left:r,top:n,width:i,height:a}=this.bounds;t.translate(r,n),t.beginPath(),(e=f9(e,i,a))>0?t.roundRect(0,0,i,a,e):t.rect(0,0,i,a),t.translate(-r,-n)}};return F8(e.prototype,"path",!1),e};const p9={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"textarea",label:"front-side-template",name:"frontSideTemplate",property:{language:"html"}},{type:"textarea",label:"back-side-template",name:"backSideTemplate",property:{language:"html"}},{type:"textarea",label:"style",name:"style",property:{language:"css"}}],help:"scene/component/info-window"};const g9=20;function v9(t,e){var r=t.split(/\s+/),n=r.indexOf(e);return-1!=n?r.splice(n,1):r.splice(-1,0,e),r.join(" ")}class y9 extends(d9(h9)){static get image(){return y9._image||(y9._image=new Image,y9._image.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAMAAACahl6sAAAAY1BMVEVHcEwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADIAbxiAAAAIHRSTlMA+gPshCwwWFzYCeLRm7QRG6rLeDZI9JOJJDtjb1HAf1sAT80AAAQQSURBVHhe7MCBAAAAAMKw/KkzOMG2BAAAAKeu3lUohIEggO7jQi5qHqpgwML5/6+0F0y02z31FlvMMLKt86QMQ1ined2Evih1hFFjLfRWjgzDOGZ6JSiM00B9EuHALtQxJLiQBmqSBCeSUEuEGzs1BDjSaHxWOKK5Eyz/4SoMV/hp4+vtcPkdwZD/udwevNg7t1xXYRiKmkB7C+ENlPLq8fxHeX+RGjWQ1D45ldcIulBIvCvYJGBEadyTzxAcfY57NBjpLScOO/bzugcTHe7IMwiSLMcdHZhocMcMgTLjjgZM7F1bCJZ2v27ARGzYDwIk2Z+JYGJ/iiwQLMv+JAEThjkmRG64Q0Q+gIiIiIiIiIiIyFy0KRFt0bOJZAWSUigmkQaJaXhENiRnYBEpkZySRSRGcmIWEaQnYhHRSI5mESmQnIJFZIqQmGhiEYEbEnPjGlEGjYTogW/WUkOXENENSqZfEXmDiIiIiIiIiIiIiIiIiIiImq5ETIpRpBpjJCMeKy6Ri0ZS9MQjkmkkJs1YRDokp2MRyZGclkUkQnIiEQltaX3Lzb6yiGTpl2y/avqSAxGgelCOKI+Kc2isL0TUSsZ4EREREREREREREREREREREfnIQzXrNWSRTeNxnlOwIgueIr6AAyE+CpiqMEUK71IDO4E+LluEKYKnKcMUifEsTZgiJZ5lDVNkwJPcqzBFoPF/HplfxL/w6b4EPGv1h18Weya1TL8iIiIeiIiIiIiIiEjkPefxV+5YA9PPHylB+u5aqgZ39H+jKOxrqtu+pkzvr9YbzoZ6w2OFkzcrA3yE4WZlSSyFk54VoA/wR43+FaD+r9w32QdWvgvjp2ty2xq8qHPHmtyPFxfrK3hw1ejERlAlfR/Ame2OTow05d4rOLLSlHtDVhI0uRO01JeZ405op6zgNNXT+bIRfpIgn+AkU4pOxBscohojdCHu4RRzjC5EYwVHqRONDkSnEvK/CB3QSU32IRW3ZPnj9iEVoGCNTLVrh8ia1x+6wq8xvB5mz8pxu7oPwIn9lcR0AiuX1+1KX+BXqdvXzWsAC0NsGjzZsS/2Bd6yRA5RgIHkXNhSD3whASZ8rrB9mItuEAizac0fDlHxDMEwpQfD1tW4y3Hjfy5s9nOHH3uwWA+EqEJBWCjoTL/S5toBB/7hu6zer74NgqSP39zJU+qQX3ix763mHTqvIVRUVprCljlElRkEjBqNYevH8veBJ2xhiyhE8YctmhDFH7ZoQhR/2KIJUfxhiyRE8YctmhDFH7ZoQhR/2OIJUfxhC9Ppf/t1jgJACERRsHGyYRZB0Ujvf0xD8w6kP7y6RZmgf/oTFTtbbzJVxZWo2Nlqw6TVy5GowNl6ssm7v50obamfSxQAAAAAAAsKLM15fb3vpQAAAABJRU5ErkJggg=="),y9._image}static toggle(t,e,r,n){if(e){var i=t.root.findById(e);i?i._findInfoWindowByComponent(t)?y9.hide(t,e):y9.show(t,e,r,n):console.warn("InfoWindow Not Found.",e)}else console.warn("InfoWindow not defined.")}static hide(t,e){if(e){var r=t.root.findById(e);r?r._removeInfoWindow(t):console.warn("InfoWindow Not Found.",e)}}static show(t,e,r,n){if(e){var i=t.root.findById(e);if(i){if(!i._findInfoWindowByComponent(t)){var{frontSideTemplate:a="",backSideTemplate:o=""}=i.model,s=[a,o].filter((t=>String(t).trim()));if(s=s.map((t=>l9.template(function(t,e,r){return(e||r?['<div class="info-window-btns">',e?'<button class="closable">&#88</button>':"",r?'<button class="flipable">&#8652</button>':"","</div>"]:[]).concat(['<div class="info-window-content">',t,"</div>"]).join("")}(t,!r,2==s.length)))),0!=s.length){var c='\n.flip {\n backface-visibility: hidden;\n -moz-backface-visibility: hidden;\n -ms-backface-visibility: hidden;\n -o-backface-visibility: hidden;\n -webkit-backface-visibility: hidden;\n border-radius: 7px;\n height: auto;\n font: normal 14px helvetica, arial, san serif;\n position: absolute;\n opacity:.9;\n transform-origin: 50% 50% 0px;\n -moz-transform-origin: 50% 50% 0px;\n -ms-transform-origin: 50% 50% 0px;\n -o-transform-origin: 50% 50% 0px;\n -webkit-transform-origin: 50% 50% 0px;\n transition: all 2s;\n -moz-transition: all 2s;\n -ms-transition: all 2s;\n -o-transition: all 2s;\n -webkit-transition: all 2s;\n min-width: 100px;min-height:50px;\n background-color:#3e424e;\n box-shadow: 2px 3px 2px 0px rgba(0,0,0,0.15);\n}\n\n#side-1 {\n transform: rotateY( 0deg );\n -moz-transform: rotateY( 0deg );\n -ms-transform: rotateY( 0deg );\n -o-transform: rotateY( 0deg );\n -webkit-transform: rotateY( 0deg );\n}\n.flip:after{\n content:"";\n display:block;\n position: absolute;\n opacity:.9;\n width: 0;\n height: 0;\n}\n.flip.arrow-top:after{\n left:45%;\n top:-17px;\n border-left:10px solid transparent;\n border-bottom:18px solid #323b44;\n border-right:10px solid transparent;\n}\n.flip.arrow-right:after{\n left:100%;\n top:48%;\n border-top:10px solid transparent;\n border-left:18px solid #323b44;\n border-bottom:10px solid transparent;\n}\n.flip.arrow-bottom:after{\n left:45%;\n top:100%;\n border-left:10px solid transparent;\n border-top:18px solid #323b44;\n border-right:10px solid transparent;\n}\n.flip.arrow-left:after{\n right:100%;\n top:48%;\n border-top:10px solid transparent;\n border-right:18px solid #323b44;\n border-bottom:10px solid transparent;\n}\n\n#side-2 {\n transform: rotateY( 180deg );\n -moz-transform: rotateY( 180deg );\n -ms-transform: rotateY( 180deg );\n -o-transform: rotateY( 180deg );\n -webkit-transform: rotateY( 180deg );\n}\n\n.flip-side-1 {\n transform: rotateY( 0deg ) !important;\n -moz-transform: rotateY( 0deg ) !important;\n -ms-transform: rotateY( 0deg ) !important;\n -o-transform: rotateY( 0deg ) !important;\n -webkit-transform: rotateY( 0deg ) !important;\n}\n\n.flip-side-2 {\n transform: rotateY( 180deg ) !important;\n -moz-transform: rotateY( 180deg ) !important;\n -ms-transform: rotateY( 180deg ) !important;\n -o-transform: rotateY( 180deg ) !important;\n -webkit-transform: rotateY( 180deg ) !important;\n}\n\n.info-window-btns{\n position:absolute;\n top:-18px;\n right:5px;\n overflow:hidden;\n}\n.info-window-content{\n padding:10px;\n color:#efefef;\n font-size:13px;\n line-height:1.4;\n}\n.info-window-btns button{\n width:40px;height:40px;\n float:right;\n border:0;\n border-radius:50%;\n background-color:#2a7da1;\n margin-right:3px;\n text-align:center;\n cursor:pointer;\n font-size:35px;\n color:#fff;\n line-height:0;\n}\n.info-window-btns button:hover{\n background-color:#60bb23;\n}\n'+i.get("style"),{left:u,top:l}=t.bounds,{x:h,y:f}=n?t.rootModel.transcoordC2S(n.x,n.y):t.transcoordS2T(u,l);u=h,l=f;var d=document.createElement("span");d.style.position="absolute";var p=document.createElement("style");if(p.type="text/css",p.appendChild(document.createTextNode(c)),d.appendChild(p),s[0]){var g=document.createElement("div");g.id="side-1",g.className="flip",g.style.display="inline-block",g.innerHTML=s[0](t)}if(s[1]){var v=document.createElement("div");v.id="side-2",v.className="flip",v.style.display="inline-block",v.innerHTML=s[1](t)}Q8.forEach((function(t){d.addEventListener(t,(function(t){t.stopPropagation()}))})),K8.forEach((function(t){d.addEventListener(t,(function(t){t.stopPropagation()}))}));var y=t.root.model_layer.overlay;if(g&&d.appendChild(g),v&&d.appendChild(v),y.appendChild(d),i._addInfoWindow(t,d,p),g){let r=g.querySelector(".info-window-btns > .flipable");r&&r.addEventListener("click",(function(t){t.preventDefault(),v.className=v9(v.className,"flip-side-1"),g.className=v9(g.className,"flip-side-2")}),!1);let n=g.querySelector(".info-window-btns > .closable");n&&n.addEventListener("click",(function(r){r.preventDefault(),y9.hide(t,e)}),!1)}if(v){let r=v.querySelector(".info-window-btns > .flipable");r&&r.addEventListener("click",(function(t){t.preventDefault(),v.className=v9(v.className,"flip-side-1"),g.className=v9(g.className,"flip-side-2")}),!1);let n=v.querySelector(".info-window-btns > .closable");n&&n.addEventListener("click",(function(r){r.preventDefault(),y9.hide(t,e)}),!1)}var m=g.offsetWidth,b=g.offsetHeight;window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight;var x=t.rootModel.target.getBoundingClientRect(),w=[];g&&w.push(g),v&&w.push(v);var A={x:u,y:l},_=t.transcoordS2C(A.x,A.y);if(_.x+m/2+x.left<x.right&&_.x-m/2>x.left){if(b+g9<_.y)return d.style.marginLeft=A.x-m/2+"px",d.style.marginTop=A.y-b-g9+"px",void w.forEach((t=>t.className+=" arrow-bottom"));if(_=t.transcoordS2C(A.x,A.y+b+g9),x.bottom>_.y+x.top)return d.style.marginLeft=A.x-m/2+"px",d.style.marginTop=A.y+g9+"px",void w.forEach((t=>t.className+=" arrow-top"))}if((_=t.transcoordS2C(A.x,A.y)).x-(m+g9)>x.left)return d.style.marginLeft=A.x-m-g9+"px",d.style.marginTop=A.y-b/2+"px",void w.forEach((t=>t.className+=" arrow-right"));d.style.marginLeft=A.x+g9+"px",d.style.marginTop=A.y-b/2+"px",w.forEach((t=>t.className+=" arrow-left"))}}}else console.warn("InfoWindow Not Found.",e)}else console.warn("InfoWindow not defined.")}dispose(){this.infoWindows.map((t=>t.component)).forEach((t=>this._removeInfoWindow(t))),super.dispose()}get infoWindows(){return this._windows||(this._windows=[]),this._windows}_findInfoWindowByComponent(t){return this.infoWindows.find((e=>e.component===t))}_addInfoWindow(t,e,r){this._findInfoWindowByComponent(t)||this._windows.push({component:t,window:e,styleElement:r})}_removeInfoWindow(t){var e=this._findInfoWindowByComponent(t);if(!e)return;let r=e.window;r&&r.parentNode.removeChild(r);var n=this.infoWindows.lastIndexOf(e);this.infoWindows.splice(n,1)}render(t){var{left:e,top:r,width:n,height:i}=this.bounds;t.beginPath(),this.drawImage(t,y9.image,e,r,n,i)}get hasTextProperty(){return!1}get nature(){return p9}}l9.register("info-window",y9);var m9={};var b9={list:function(){return{...m9}},register:function(t,e){m9[t]=e},unregister:function(t){delete m9[t]},get:function(t){if(t){var e=m9[t];return e||L8("Layout Not Found - ",t),e}}},x9={reflow:function(t,e){this.drawables(t).filter((t=>t.isHTMLElement())).forEach((t=>t.reposition()))},capturables:function(t){return t.components},drawables:function(t){return t.app&&!t.app.isViewMode?t.components:t.components.filter((t=>!t.hidden))},isStuck:function(t){return!1},ABSOLUTE:!0};b9.register("html-absolute",x9);const w9=["run","goto","goto-playlist","goto-playlist","link-open","link-move","route-page","start-scenario","run-scenario","export-data","import-data"],A9="center",_9=new WeakMap;function k9(t){const e=t.root;var r=_9.get(e);if(!r)return;if(e===t){for(var n in r)k9(n[0]);return void _9.delete(e)}const i=r.findIndex((e=>e[0]===t));if(-1===i)return;const a=r[i][1];var o=a.div.parentNode;o&&o.removeChild(a.div);var s=a.scene;s.target=null,s.release&&s.release(),r.splice(i,1)}class E9{static hideAll(t){(_9.get(t)||[]).forEach((([t,e])=>k9(t)))}static hide(t){k9(t)}static show(t,e,r={}){var{data:n,location:i=A9,modal:a=!1,closable:o=!0,output:s=!0}=r,c=t.app.refProvider;c&&c.get(e,!0).then((e=>{var r=document.createElement("div"),c=r.style;if(a){var{width:u,height:l}=t.rootModel.bounds;c.position="fixed",c.zIndex=1,c.left=0,c.top=0,c.width=u+"px",c.height=l+"px",c.overflow="auto",c.backgroundColor="rgba(0,0,0,0.3)"}else c.position="absolute",c.display="inline-block";r.innerHTML=!a&&o?'\n<div class="popup-content">\n</div>\n<button class="closable-1945">&#88</button>\n':'\n<div class="popup-content">\n</div>\n';var h=r.querySelector(".popup-content"),{width:u,height:l}=e.root.model;h.style.width=u+"px",h.style.height=l+"px";var f=document.createElement("style");f.type="text/css",f.appendChild(document.createTextNode("\nbutton.closable-1945 {\n width: 20px;\n height: 20px;\n right: 0px;\n top: 0px;\n padding: 0;\n margin: 0;\n border: 0px;\n text-align: center;\n cursor: pointer;\n font-size: 12px;\n color: black;\n position: absolute;\n background-color: transparent;\n}\n\nbutton.closable-1945:hover {\n background-color:#60bb23;\n}\n")),r.appendChild(f),w9.forEach((r=>{e.on(r,((...e)=>{t.trigger(r,...e)}))}));var d=r.querySelector(".popup-content");Q8.forEach((function(t){d.addEventListener(t,(function(t){t.stopPropagation()}))})),K8.forEach((function(t){d.addEventListener(t,(function(t){t.stopPropagation()}))})),r.addEventListener("click",(e=>{e.target===r&&o&&E9.hide(t)})),Q8.forEach((function(t){r.addEventListener(t,(function(t){t.stopPropagation()}))})),K8.forEach((function(t){r.addEventListener(t,(function(t){t.stopPropagation()}))})),t.root.model_layer.overlay.appendChild(r),function(t,e,r){const n=t.root;if(n!==t){k9(t);var i=_9.get(n)||[];i=[...i,[t,{div:e,scene:r}]],_9.set(n,i)}}(t,r,e),r.querySelector(".closable-1945")?.addEventListener("click",(function(e){e.preventDefault(),E9.hide(t)}),!1),r.addEventListener("close-scene",(e=>{e.preventDefault(),e.stopPropagation(),E9.hide(t),s&&(t.data=e.detail)}),!1),e.target=h,e.data=n||t.data,e.fit("both");var p=function(t,e,r,n=A9){var i=t.bounds,a=e.bounds,o=Math.max(i.width/4-a.width/2,20),s=Math.min(3*i.width/4+a.width/2,i.width-20)-a.width,c=Math.max(i.height/4-a.height/2,20),u=Math.min(3*i.height/4+a.height/2,i.height-20)-a.height;switch(n){case"auto":return{x:r.x<i.width/2?s:o,y:r.y<i.height/2?u:c};case"left-top":return{x:o,y:c};case"right-top":return{x:s,y:c};case"left-bottom":return{x:o,y:u};case"right-bottom":return{x:s,y:u};default:return{x:(i.width-a.width)/2,y:(i.height-a.height)/2}}}(t.rootModel,e.root,t.center,i);a?(h.style.left=p.x+"px",h.style.top=p.y+"px",h.style.width=u+"px",h.style.height=l+"px"):(r.style.left=p.x+"px",r.style.top=p.y+"px",r.style.width=u+"px",r.style.height=l+"px")}),(function(t){console.error("cannot fetch board: "+e,t)}))}}var S9={reflow:function(t,e){},capturables:function(t){return t.components},drawables:function(t){return t.app.isViewMode?t.components.filter((t=>!t.hidden)):t.components},isStuck:function(t){return!1},ABSOLUTE:!0};function M9(t){var e=t.components.filter((t=>!t.hidden)),r=t.getState("layoutConfig")||{},n=e[r&&r.activeIndex||0];return n&&[n]||[]}b9.register("absolute",S9);var T9={reflow:function(t){var e=t.bounds,r=t.getState("layoutConfig")||{},n={left:0,top:0,width:e.width,height:e.height};t.forEach(((t,e)=>{let i=e!=(r.activeIndex||0);t.bounds=n,t.setState("rotation",0),t.element&&(t.element.style.visibility=i?"hidden":"visible")}))},capturables:function(t){return M9(t)},drawables:function(t){return M9(t)},isStuck:function(t){return!0}};function P9(t){var e=t.getState("layoutConfig");return e&&e.weight||1}b9.register("card",T9);var O9={reflow:function(t){var e=this.drawables(t),r=t.get("padding")||{},n=e.reduce(((t,e)=>t+P9(e)),0),i=t.bounds,a=n>0?(i.width-((r.left||0)+(r.right||0)))/n:i.width,o=i.height-((r.top||0)+(r.bottom||0)),s=0;e.forEach((t=>{let e=P9(t),n=t.get("margin")||{};t.bounds={left:a*s+(r.left||0)+(n.left||0),top:0+(r.top||0)+(n.top||0),width:e*a-((n.left||0)+(n.right||0)),height:o-((n.top||0)+(n.bottom||0))},t.setState("rotation",0),s+=e}))},capturables:function(t){return t.components},drawables:function(t){return t.app.isViewMode?t.components.filter((t=>!t.hidden)):t.components},isStuck:function(t){return!0}};function I9(t){var e=t.getState("layoutConfig");return e&&e.weight||1}b9.register("linear-horizontal",O9);var C9={reflow:function(t){var e=this.drawables(t),r=t.getState("padding")||{},n=e.reduce(((t,e)=>t+I9(e)),0),i=t.bounds,a=n>0?(i.height-((r.top||0)+(r.bottom||0)))/n:i.height,o=i.width-((r.left||0)+(r.right||0)),s=0;e.forEach((t=>{let e=I9(t),n=t.getState("margin")||{};t.bounds={left:0+(r.left||0)+(n.left||0),top:a*s+(r.top||0)+(n.top||0),width:o-((n.left||0)+(n.right||0)),height:e*a-((n.top||0)+(n.bottom||0))},t.setState("rotation",0),s+=e}))},capturables:function(t){return t.components},drawables:function(t){return t.app.isViewMode?t.components.filter((t=>!t.hidden)):t.components},isStuck:function(t){return!0}};b9.register("linear-vertical",C9);var R9={reflow:function(t){var e=t.getState("layoutConfig"),r=e&&e.columns||t.getState("columns"),n=e&&e.rows||t.getState("rows"),i=e&&e.widths||t.getState("widths"),a=e&&e.heights||t.getState("heights"),o=i?i.filter(((t,e)=>e<r)).reduce(((t,e)=>t+e),0):r,s=a?a.filter(((t,e)=>e<n)).reduce(((t,e)=>t+e),0):n,c=t.textBounds,u=t.getState("paddingLeft")||0,l=t.getState("paddingTop")||0,h=c.width/o,f=c.height/s,d=0,p=0;t.components.forEach(((t,e)=>{let n=i?i[e%r]:1,o=a?a[Math.floor(e/r)]:1,s=t.colspan||1,c=0;for(;--s>0;)c+=i?i[(e+s)%r]:1;let g=t.rowspan||1,v=0;for(;--g>0;)v+=a?a[Math.floor(e/r)+g]:1;t.bounds={left:u+d,top:l+p,width:h*(n+c),height:f*(o+v)},t.setState("rotation",0),e%r==r-1?(d=0,p+=o*f):d+=n*h}))},capturables:function(t){return t.components.filter((t=>!t.merged))},drawables:function(t){return t.components.filter((t=>!t.merged&&!t.hidden))},isStuck:function(t){return!0},keyNavigate:function(t,e,r){var n=t.getState("layoutConfig"),i=n&&n.columns||t.getState("columns"),a=n&&n.rows||t.getState("rows"),{row:o,column:s}=t.getRowColumn(e);switch(r.code){case"ArrowUp":if(o>0)return t.getAt((o-1)*i+s);break;case"ArrowDown":if(o<a-1)return t.getAt((o+1)*i+s);break;case"ArrowRight":if(s<i-1)return t.getAt(o*i+s+1);break;case"ArrowLeft":if(s>0)return t.getAt(o*i+s-1);break;default:return e}},joinType:!0};b9.register("table",R9);const j9=new Image;j9.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAAclBMVEVHcEwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAC0BbqFAAAAJXRSTlMAgAP3VSI6/g9fBk5FavJsMrariSjzPnO1enRRL5SMhmOOWB9keFTE0wAAANxJREFUOMutk9kWgyAMRLFuiLjUtdp9yf//YglVsQXz1HniMPcEMgHGvpX2O0Ypi+EgCL+IAShC+wB7QfubRDT7AFcnUPoLMLiP4PyJbsb55i05AgnR5iaQDsICgtH0cotBWoAP1c7kC6kFxEseCfZfB6gEgbNeBrira2QmH1uVYCXlA3is8UmgUCPIyQJKEmu8QtQJN0e9DPXVpzG2G216c1CqRmcBOdxXk07sWUSPv07zo0amCNQycv+NzmR6cRcwmfbuI7p2nZ/z4be0P83Foz6vIkhfZXr82XgDlZsspIq4peUAAAAASUVORK5CYII=";var L9=t=>class extends t{postrender(t){super.postrender(t),this.app.isEditMode&&this._focused&&this.showMoveHandle&&this._draw_move_handle(t)}_draw_move_handle(t){var{left:e,top:r,width:n}=this.bounds;t.save(),t.beginPath(),t.globalAlpha=1,t.rect(e+n,r,25,25);t.fillStyle="rgba(235, 235, 235, 1)",t.fill(),t.drawImage(j9,e+n+3.75,r+3.75,17.5,17.5),t.closePath(),t.restore()}contains(t,e){var r=super.contains(t,e);if(this.app.isViewMode)return r;if(!r){var{left:n,top:i,width:a,height:o}=this.bounds,s=n+a;this.showMoveHandle&&(r=t<Math.max(s+25,s)&&t>Math.min(s+25,s)&&e<Math.max(i+25,i)&&e>Math.min(i+25,i))}return this._focustd!==r&&(this._focused=r,this.invalidate()),r}};const D9=[];class z9 extends(L9(d9(l9))){constructor(t,e){super(t,e),this._components=[]}replaceRefids(t){this.components.forEach((e=>e.replaceRefids(t)))}get showMoveHandle(){return!0}get showOverflow(){return!1}dispose(){this.components.slice().forEach((t=>t.dispose())),super.dispose()}isContainer(){return!0}containable(t){return t.isDescendible(this)}get hasTextProperty(){return!1}get components(){return this._components}get focusible(){return!0}get layout(){return b9.get(this.get("layout"))||S9}reflow(){this.layout.reflow(this),this.components&&this.components.forEach((t=>{t.isContainer()&&t.reflow()}))}get hierarchy(){var t=super.hierarchy;return this.components&&(t.components=this.components.map((t=>t.hierarchy))),t}addComponent(t,e=!1){var r=t.parent;if(r){if(this===r)return;r.removeComponent(t,e)}var n=this._components.push(t)-1;t.parent=this,t.added(this),e||this.trigger("add",this,t,n),t.delegate_on(this),e||t.trigger("added",this,t,n),this.root&&this.root.isReady&&t.ready()}removeComponent(t,e=!1){var r=this._components.indexOf(t);-1!=r&&(this._components.splice(r,1),t.parent=null,t.removed(this),e||(this.trigger("remove",this,t),t.trigger("removed",this,t)),t.delegate_off(this))}insertComponentAt(t,e,r=!1){var n=t.parent;n&&n.removeComponent(t,r);var i=this._components.splice(0,e);this._components=i.concat(t,this._components),e=this._components.indexOf(t),t.parent=this,t.added(this),r||this.trigger("add",this,t,e),t.delegate_on(this),r||t.trigger("added",this,t,e)}add(t,e=!1){return t instanceof Array?(t.forEach((t=>{-1==this._components.indexOf(t)&&this.addComponent(t,e)})),this):this.add.call(this,[t],e)}remove(t,e=!1){return t instanceof Array?this._components?(t.forEach((t=>{this.removeComponent(t,e)})),this):this:this.remove.call(this,[t],e)}getAt(t){if(this._components)return this._components[t]}forEach(t,e){this._components&&this._components.forEach(t,e)}traverse(t,e){t.call(e,this),this._components&&this._components.forEach((r=>{r.isContainer()?r.traverse(t,e):t.call(e,r)}))}indexOf(t){return(this._components||D9).indexOf(t)}size(){return(this._components||D9).length}moveChildAt(t,e){var r=this.indexOf(e);if(-1!=r){var n=this._components.splice(0,r),i=this._components.splice(1);this._components=n.concat(i),t=Math.max(0,t),t=Math.min(t,this._components.length),n=this._components.splice(0,t),this._components=n.concat(e,this._components)}}moveChildForward(t){var e=this.indexOf(t);-1!=e&&e!=this.size()-1&&(this._components[e]=this._components[e+1],this._components[e+1]=t)}moveChildBackward(t){var e=this.indexOf(t);-1!=e&&0!=e&&(this._components[e]=this._components[e-1],this._components[e-1]=t)}moveChildToFront(t){var e=this.indexOf(t);if(-1!=e&&e!=this.size()-1){var r=this._components.splice(0,e),n=this._components.splice(1);this._components=r.concat(n,this._components)}}moveChildToBack(t){var e=this.indexOf(t);if(-1!=e&&0!=e){var r=this._components.splice(0,e),n=this._components.splice(0);this._components=this._components.concat(r,n)}}symmetryX(t){super.symmetryX(t),this.components.map((t=>{t.symmetryX(0)}))}findAll(t,...e){if("string"==typeof t)return o7(t,this,e[0]||this);if("function"==typeof t){var r=[];for(let n=this.components.length-1;n>=0;n--){let i=this.components[n].findAll(t,...e);i&&(r=r.concat(i))}return t(this,...e)&&r.push(this),r}}findFirst(t,...e){if("string"==typeof t)return o7(t,this,e[0])[0];if("function"==typeof t){for(let n=this.components.length-1;n>=0;n--){var r=this.components[n].findFirst(t,...e);if(null!=r)return r}return t(this,...e)?this:null}}findById(t){return this.root.findById(t)}findByRefid(t){return this.root.findByRefid(t)}contains(t,e){var r=super.contains(t,e);if(!r){var{left:n,top:i,width:a,height:o}=this.state;r=t<Math.max(n+a,n)&&t>Math.min(n+a,n)&&e<Math.max(i+o,i)&&e>Math.min(i+o,i)}return r}capture(t,e,r){var n=this.transcoordP2S(t,e);if(!this.contains(n.x,n.y))return!1;var i=this.bounds;n.x-=i.left,n.y-=i.top;var a=this.layout.capturables(this);for(let t=a.length-1;t>=0;t--){var o=a[t].capture(n.x,n.y,r);if(o)return o}return this.capturable&&!r?.(this)&&this}capturePath(t,e){if(e){if(e.indexOf(this)>-1)return!1;for(let t=0;t<e.length;t++)if(!this.containable(e[t]))return!1}var r=[],{left:n,top:i,width:a,height:o}=this.bounds;for(let e=0;e<t.length;e++){let s=this.transcoordP2S(t[e].x,t[e].y);if(s.x<n||s.x>n+a||s.y<i||s.y>i+o)return!1;s.x-=n,s.y-=i,r.push(s)}let s=this.layout.capturables(this);for(let t=s.length-1;t>=0;t--){let n=s[t];if(!n.isContainer())continue;let i=n.capturePath(r,e);if(i)return i}return this.focusible&&this}render(t){var{left:e=0,top:r=0,width:n,height:i}=this.bounds;t.beginPath(),t.rect(e,r,n,i),t.closePath(),this.drawFill(t),this.drawStroke(t)}postrender(t){const e=this.layout.drawables(this);if(e.length>0){var{left:r=0,top:n=0,width:i,height:a}=this.bounds;t.save(),this.showOverflow||(t.beginPath(),t.rect(r,n,i,a),t.clip(),t.closePath());var{top:n,left:r}=this.state;t.translate(r,n),e.forEach((e=>{e.draw(t)})),t.translate(-r,-n),t.restore()}super.postrender(t)}trim(){this.components.forEach((t=>{t.trim()})),super.trim()}}["layout"].forEach((t=>l9.memoize(z9.prototype,t,!1)));class F9 extends z9{constructor(t,e){super(t,e),t.translate=t.translate||{x:0,y:0},this._draw_reserved=!1,this.__draw__=()=>{this._draw_reserved=!1,this.trigger("redraw"),this.reflow(),this.draw()},this.throttle_render=()=>{this._draw_reserved||requestAnimationFrame(this.__draw__),this._draw_reserved=!0}}fitSize(t,e,r,n){if(this.target){if(e){let t=getComputedStyle(this.target);r=r||(t?parseFloat(t.getPropertyValue("width")):this.target.clientWidth),n=n||(t?parseFloat(t.getPropertyValue("height")):this.target.clientHeight)}else r=this.model.width,n=this.model.height;"CANVAS"==t.tagName&&(t.setAttribute("width",r*V8),t.setAttribute("height",n*V8)),t.style.width=r+"px",t.style.height=n+"px"}}resize(){this.fitSize(this.element,!0)}isLayer(){return!0}get showOverflow(){return this.app.isEditMode}get anchors(){}createElement(){var t=l9.createCanvas(1,1);return t.style.position="absolute",t}get target(){return this._target}set target(t){this._target&&this.element&&this._target.removeChild(this.element),this._target=t,t&&(this.element||(this.element=this.createElement()),this.resize(),t.appendChild(this.element))}get canvas(){return this.element}dispose(){super.dispose(),this.target=null,this.element=null}get selected(){return this.root.selected}set selected(t){this.root.selected=t}get hasSameParentForAllSelected(){return this.root.hasSameParentForAllSelected}get focused(){return this.root.focused}set focused(t){this.root.focused=t}getContext(){return this._context2D||(this._context2D=this.canvas&&this.canvas.getContext("2d")),this._context2D}draw(t){this.canvas&&(t=t||this.getContext())&&super.draw(t)}prerender(t){var{translate:e,scale:r={x:1,y:1},rotation:n}=this.model;t.clearRect(0,0,t.canvas.width,t.canvas.height),e&&t.translate(e.x*V8,e.y*V8),t.scale(r.x*V8,r.y*V8),n&&t.rotate(n)}get rotatePoint(){return{x:0,y:0}}contains(t,e){return!1}invalidate(){this.throttle_render()}move(t){var e=this.get("translate")||{x:0,y:0};this.set({translate:{x:e.x+t.x,y:e.y+t.y}})}centerTo(t,e){const r=t.rootModel.transcoordC2S(this.canvas.clientWidth/2,this.canvas.clientHeight/2),{x:n,y:i}=t.center,{x:a,y:o}=t.transcoordP2S(n,i),{x:s,y:c}=t.transcoordS2T(a,o),{x:u,y:l}=t.rootModel.get("translate"),{x:h,y:f}=t.rootModel.get("scale");e?t6({step:function(e){t.rootModel.set({translate:{x:u+(r.x-s)*h*e,y:l+(r.y-c)*f*e}})},duration:1e3,delta:"circ",ease:"in"}).start():t.rootModel.set({translate:{x:u+(r.x-s)*h,y:l+(r.y-c)*f}})}}const N9={x:1,y:1},B9={x:0,y:0};class U9 extends F9{constructor(t,e){super(t,e)}dispose(){super.dispose(),delete this._canvas,delete this._overlay}contains(t,e){return!0}isRootModel(){return!0}get stuck(){return!0}get layout(){return x9}get overlay(){if(!this._overlay){var t=document.createElement("div");t.style.position="absolute",t.style.width=0,t.style.height=0,t.style.overflow="initial",t.style["user-select"]="none",t.style["transform-origin"]="top left",this.element&&this.element.appendChild(t),this._overlay=t,this._repositionOverlay()}return this._overlay}createElement(){var t=document.createElement("div");return t.style.position="absolute",t.style["user-select"]="none",t.style.overflow="hidden",this._canvas=l9.createCanvas(1,1),this._canvas.style.position="absolute",t.appendChild(this._canvas),this._overlay&&t.appendChild(this._overlay),t}resize(){if(this.target){var{width:t,height:e,fitMode:r}=this.model;this.root.fitMode?r=this.root.fitMode:r||(r="ratio");try{var n=getComputedStyle(this.target)}catch(t){return void console.error(t,this.target)}var i=n?parseFloat(n.getPropertyValue("width")):this.target.clientWidth,a=n?parseFloat(n.getPropertyValue("height")):this.target.clientHeight;switch(r){case"both":case"ratio":break;case"width":a=e*i/t;break;case"height":i=t*a/e;break;default:i=Math.max(t,i),a=Math.max(e,a)}switch(this.fitSize(this.canvas,!0,i,a),r){case"ratio":case"both":break;case"width":this.element.style.overflowX="hidden",this.element.style.overflowY="auto";break;case"height":this.element.style.overflowX="auto",this.element.style.overflowY="hidden";break;default:this.element.style.overflowX=i>t?"hidden":"auto",this.element.style.overflowY=a>e?"hidden":"auto"}this.fitSize(this.element,!0)}}get canvas(){return this._canvas}get MPP(){var{scale:t={x:1,y:1},unit:e}=this.model;switch(e){case"mm":case"cm":return 1/this.app.PPM/t.x;case"in":return 1/this.app.PPI/t.x;default:return 1/t.x}}capturePath(t,e){var r=this.layout.capturables(this);for(let n=r.length-1;n>=0;n--){let i=r[n];if(!i.isContainer())continue;let a=i.capturePath(t,e);if(a)return a}return!1}get eventMap(){return{"(self)":{"(all)":{change:this._onchanged_all,mouseenter:this._onmouseenter_all,mouseleave:this._onmouseleave_all,click:this._onclick,mousedown:this._onmousedownup,mouseup:this._onmousedownup,touchstart:this._onmousedownup,touchend:this._onmousedownup}}}}closeScene(t){requestAnimationFrame((()=>this.overlay.dispatchEvent(new CustomEvent("close-scene",{bubbles:!0,composed:!0,detail:t}))))}_repositionOverlay(){var t=this._overlay;if(t){var{translate:e=B9,scale:r=N9,rotation:n=0}=this.model,{left:i,top:a,width:o,height:s}=this.bounds;t.style.left=i+"px",t.style.top=a+"px";var c=`rotate(${n}rad) scale(${r.x}, ${r.y}) perspective(1px)`;t.style["margin-left"]=e.x+"px",t.style["margin-top"]=e.y+"px",["-webkit-","-moz-","-ms-","-o-",""].forEach((e=>{t.style[e+"transform"]=c}))}}onchange(t){var e=this._model;delete e.id,delete e.text,delete e.class,this._repositionOverlay()}_onchanged_all(t,e,r){this.invalidate()}_onmouseenter_all(t,e){if(t.stopPropagation(),this.app&&!this.app.isEditMode&&e){var r=e.origin;if(!(r instanceof U9)&&r.model.event&&r.model.event.hover&&!r.hidden){var n=r.model.event.hover;n&&this._doEventAction(n,r,!0,t)}}}_onmouseleave_all(t,e){if(t.stopPropagation(),e){var r=e.origin;if(this.app&&!this.app.isEditMode){var n=r.model.event&&r.model.event.hover;n&&this._doEventAction(n,r,!1,t)}}}_onclick(t,e){if(t.stopPropagation(),!this.app.isEditMode&&e){var r=e.origin,n=r.model.event?.tap;n&&this._doEventAction(n,r,!0,t)}}_onmousedownup(t,e){if(t.stopPropagation(),!this.app.isEditMode&&e){var r=e.origin,n=r.model.event?.tap;n&&n.pressed&&this._doMouseDownUpEventAction(n,r,"mousedown"==t.type||"touchstart"==t.type,t)}}_doMouseDownUpEventAction(t,e,r,n){var{pressed:i=!1}=t;i&&(r?function(t){if(!t.hasOwnProperty("_backupShadow")){var e=t.get("shadow");t._backupShadow=e;var{left:r=0,top:n=0}=e||{};t.delta("tx",r),t.delta("ty",n),t.set("shadow",{})}}(e):function(t){t.hasOwnProperty("_backupShadow")&&(t.delta("tx",0),t.delta("ty",0),t.set("shadow",t._backupShadow),delete t._backupShadow)}(e))}_doEventAction(t,e,r,n){var{action:i,target:a,value:o,emphasize:s=!1,restore:c=!1,pressed:u=!1,options:l}=t;if(a&&(a=e.access(a)),o&&(o=e.access(o)),s&&(r?function(t){t.hasOwnProperty("_backupStrokeStyle")||(t._backupStrokeStyle=t.model.strokeStyle,t.set("strokeStyle","#f26522"),t.hasOwnProperty("_backupLineWidth")||(t._backupLineWidth=t.model.lineWidth,t.set("lineWidth",t.model.lineWidth+5)))}(e):c&&function(t){t.hasOwnProperty("_backupStrokeStyle")&&(t.set("strokeStyle",t._backupStrokeStyle),delete t._backupStrokeStyle,t.hasOwnProperty("_backupLineWidth")&&(t.set("lineWidth",t._backupLineWidth),delete t._backupLineWidth))}(e)),i)switch(i){case"data-toggle":if(!a)return;(r||c)&&this.root.findAll(a,e).forEach((t=>{t.data=!t.data}));break;case"data-tristate":if(!a)return;(r||c)&&this.root.findAll(a,e).forEach((t=>{let e=Math.round(Math.max(Number(t.data)||0,0));t.data=(e+(r?1:2))%3}));break;case"data-spreading":if(!a)return;if(r){var h=e.access(o);this.root.findAll(a,e).forEach((t=>{t.executeMappings(!0)}))}break;case"data-set":if(!a)return;if(r){h=e.access(o);this.root.findAll(a,e).forEach((t=>{t.data=h}))}break;case"partial-data-set":if(!a)return;if(r){h=e.access(o);this.root.findAll(a,e).forEach((t=>{t.data={...t.data,...h}}))}break;case"value-set":if(!a)return;if(r){h=e.access(o);this.root.findAll(a,e).forEach((t=>{t.value=h}))}break;case"partial-value-set":if(!a)return;if(r){h=e.access(o);this.root.findAll(a,e).forEach((t=>{t.value={...t.value,...h}}))}break;case"infoWindow":case"info-window":if(!a)return;"click"==n.type||r?y9.show(e,a,c,{x:n.offsetX,y:n.offsetY}):c&&y9.hide(e,a);break;case"toggle-info-window":if(!a)return;y9.toggle(e,a,!1,{x:n.offsetX,y:n.offsetY});break;case"popup":case"modal-popup":if(!a)return;let t=l&&"input"in l?l.input:"(self)",s=!l||(!("output"in l)||l.output);E9.show(e,a,{data:t&&this.root.findFirst(t,e)?.data,output:s,modal:"modal-popup"===i});break;case"close-scene":this.closeScene(e.data);break;case"goto":case"goto-playlist":this.trigger(i,a,l,e);break;case"mouse-cursor":r?this.target.style.cursor=a||"auto":c&&(this.target.style.cursor="auto");break;default:this.trigger(i,a,o,e)}}}function Y9(t,e){const r=t.state.refid;return t.root.findAll((t=>t.isLine()&&t.from.component===r&&(!e||t.from.anchor===e)))}function G9(t,e){const r=t.state.refid;return t.root.findAll((t=>t.isLine()&&t.to.component===r&&(!e||t.to.anchor===e)))}U9.Popup=E9,l9.register("model-layer",U9);var W9=t=>class extends t{isConnectable(){return!0}postrender(t){super.postrender(t),this._draw_anchors(t)}_draw_anchors(t){var e=this.anchors||[];t.save(),e.forEach((e=>{var{position:{x:r,y:n},draw:i}=e;if(i){t.beginPath();try{i.call(e,t,this)}catch(t){console.error(t)}t.closePath()}})),t.restore()}contains(t,e){if(n=super.contains(t,e))return n;var r=this.anchors||[];for(let i of r){const r=i.bounds;if(!r)continue;const{left:a,top:o,width:s,height:c}=r;var n;if(n=t<Math.max(a+s,a)&&t>Math.min(a+s,a)&&e<Math.max(o+c,o)&&e>Math.min(o+c,o))return n}return!1}findInOutLines(t){return function(t,e){const r=t.state.refid;return t.root.findAll((t=>!(!t.isLine()||(t.from.component!==r||e&&t.from.anchor!==e)&&(t.to.component!==r||e&&t.to.anchor!==e))))}(this,t)}findOutletLines(t){return Y9(this,t)}findOutletEnds(t){return function(t,e){return Y9(t,e).map((t=>t.toEnd?.component)).filter(Boolean)}(this,t)}findInletLines(t){return G9(this,t)}findInletEnds(t){return function(t,e){return G9(t,e).map((t=>t.fromEnd?.component)).filter(Boolean)}(this,t)}};const H9={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"number",label:"round",name:"round",property:{min:0}}],help:"scene/component/rect"};var q9={ondragmove:function(t,e,r){var{left:n,top:i,width:a,height:o}=r.model,s=(r.transcoordP2S(t.x,t.y).x-n)/(a/2)*100;s=f9(s,a,o),r.set({round:s})}};class X9 extends(W9(d9(h9))){is3dish(){return!0}get controls(){var{left:t,top:e,width:r,round:n,height:i}=this.state;return[{x:t+r/2*((n=null==n?0:f9(n,r,i))/100),y:e,handler:q9}]}get nature(){return H9}}l9.register("rect",X9);const V9=[1,2,10,20,50,50,50,50,50,50];class Q9 extends(d9(h9)){render(t){const{lineWidth:e=1,fillStyle:r="lightgray",font:n="15px Arial",left:i,top:a,rotation:o,origin:s,margin:c,width:u,height:l,side:h="bottom",strokeStyle:f="#000000",scale:d=1}=this.state;t.translate(i,a),t.beginPath();const p=Math.round(e/2);t.rect(-p,-p,u+2*p,l+2*p),t.clip(),t.beginPath(),t.rect(0,0,u,l),r&&(t.fillStyle=r,t.fill()),t.lineWidth=e,t.strokeStyle=f,t.stroke(),t.beginPath(),t.font=n;var g="bottom"!==h,v=g?0:l,y=4*l/5,m=2*l/3,b=1*l/2,x=3*l/5;g&&(y=l-y,m=l-m,b=l-b,x=l-1.5*l/5);var w=d*this.app.PPM/this.root.unitScale,A=Math.ceil(s/w),_=this.app.PPM/w,k=_<=1.1?1:V9[Math.round(_)]||100;1!=k&&(A+=(k-A%k)%k);var E=Math.ceil(A*w),S=s+u;for(t.fillStyle=f;E<S;){if(A%10==0){t.moveTo(E-s,b),t.lineTo(E-s,v);let e=(A/10).toString(),r=t.measureText(e);t.fillText(e,E-s-r.width-6,x)}else A%5==0?(t.moveTo(E-s,m),t.lineTo(E-s,v)):(t.moveTo(E-s,y),t.lineTo(E-s,v));A+=k,E=Math.ceil(A*w)}}}l9.register("ruler",Q9);const K9=20,J9=20,Z9=90*Math.PI/180,$9="9px Verdana",ttt=20,ett="#f4f4f4",rtt="#999";function ntt(t,e,r){return{left:-t.x,top:-t.y,width:K9,height:ttt}}function itt(t,e,r,n){return{left:K9-t.x,top:0-t.y,origin:20-t.x,width:e-K9,height:ttt}}function att(t,e,r,n){var i={x:0-t.x+10,y:-t.y+J9+(r-J9)/2},a=l9.transcoordRR(0-t.x,-t.y+J9,i,Z9);return{left:a.x-(r-J9),top:a.y,origin:20-t.y,width:r-J9,height:ttt}}function ott(t){var e=t.get("translate");return{left:-e.x,top:-e.y,width:t.canvas.width/V8,height:t.canvas.height/V8}}l9.register("guide-layer",class extends F9{constructor(t,e){super(t,e),this.appScale={x:1,y:1},"disabled"!==t.ruler&&(this.hruler=new Q9({left:K9,top:0,origin:20,margin:0,height:ttt,unit:"m",rotation:0,font:$9,fillStyle:ett,strokeStyle:rtt,capturable:!1}),this.vruler=new Q9({left:0,top:0,origin:20,margin:0,height:ttt,unit:"m",rotation:Z9,font:$9,side:"top",fillStyle:ett,strokeStyle:rtt,capturable:!1}),this.origin_rect=new X9({left:-20,top:-20,width:20,height:20,fillStyle:ett,strokeStyle:rtt,lineWidth:1}),this.addComponent(this.hruler),this.addComponent(this.vruler),this.addComponent(this.origin_rect)),this.invalidate()}get capturable(){return!1}ready(){if(super.ready(),this.hruler){var t=this.rootModel,e=Object.assign({},t.get("translate"));e.x<K9&&(e.x+=K9),e.y<J9&&(e.y+=J9);var r=t.get("scale")||{x:1,y:1};this.appScale=r,this.hruler.set("scale",r.x),this.vruler.set("scale",r.y),t.set("translate",e),this.set("translate",e),this.screen_coord=ott(this);var{width:n,height:i}=this.screen_coord;this.hruler.set(itt(e,n,0,this.hruler)),this.vruler.set(att(e,0,i,this.vruler)),this.origin_rect.set(ntt(e))}else this.screen_coord=ott(this)}resize(){super.resize(),this.screen_coord=ott(this);var{width:t,height:e}=this.screen_coord;this.hruler&&(this.hruler.set(itt(this.model.translate,t,0,this.hruler)),this.vruler.set(att(this.model.translate,0,e,this.vruler)),this.origin_rect.set(ntt(this.model.translate)))}render(t){if(this.guide){t.save();var{x:e,y:r}=this.guide,{top:n,left:i,width:a,height:o}=this.screen_coord;t.beginPath(),t.moveTo(e,n),t.lineTo(e,n+o),t.moveTo(i,r),t.lineTo(i+a,r),t.lineWidth=1,t.strokeStyle="tomato",t.setLineDash([2,3]),t.font="10px tahoma",t.fillStyle="#333";var s=this.transcoordS2C(e,r,this.rootModel);t.textBaseline=s.y>200?"bottom":"top",t.textAlign=s.x>200?"right":"left";var c=s.y>200?-5:5,u=s.x>200?-5:5,l=Math.round(e/this.appScale.x),h=Math.round(r/this.appScale.y);t.fillText(` ${l}, ${h} `,e+u,r+c),t.stroke(),t.restore()}}get guide(){return this._guide}set guide(t){this._guide=t,this.invalidate()}contains(t,e){return!0}get eventMap(){return{"(root)":{"(descendant)":{mousemove:this.onmousemove_child,mouseout:this.onmouseout_child,dragmove:this.onmousemove_child},"model-layer":{change:this.onchange_root_model}},"(self)":{"(descendant)":{mousedown:this.onmousedown_origin}}}}onmousedown_origin(t,e){this.rootModel.set("translate",{x:20,y:20})}onchange_root_model(t,e,r){if(t.scale&&(this.appScale=t.scale,this.hruler&&(this.hruler.set("scale",t.scale.x),this.vruler.set("scale",t.scale.y))),t.translate&&this.set({translate:{x:t.translate.x,y:t.translate.y}}),t.scale||t.translate){if(this.screen_coord=ott(this),this.hruler){var{translate:n}=this.model,{width:i,height:a}=this.screen_coord;this.hruler.set(itt(n,i,0,this.hruler)),this.vruler.set(att(n,0,a,this.vruler)),this.origin_rect.set(ntt(n))}this._guide=null}this.invalidate()}onmouseout_child(t){this._guide=null,this.invalidate()}onmousemove_child(t,e){t.target&&"CANVAS"!==t.target.tagName?this.guide=null:this.guide=this.transcoordC2S(t.offsetX,t.offsetY)}});l9.register("shift-layer",class extends F9{ready(){super.ready();var t=this.rootModel.get("translate");this.set("translate",t)}render(t){}contains(t,e){return!(2!=this.app.mode)}get eventMap(){return{"(root)":{"(self)":{keydown:this.onkeydown,keyup:this.onkeyup}}}}onkeydown(t){"Space"===t.code&&void 0===this.before_mode&&(this.before_mode=this.app.mode,this.app.mode=2)}onkeyup(t){"Space"===t.code&&(void 0!==this.before_mode&&(this.app.mode=this.before_mode),delete this.before_mode)}ondragstart(t){this.last_position=this.transcoordC2S(t.offsetX,t.offsetY)}ondragmove(t){var{x:e,y:r}=this.transcoordC2S(t.offsetX,t.offsetY);this.rootModel.move({x:e-this.last_position.x,y:r-this.last_position.y},!1),this.last_position=this.transcoordC2S(t.offsetX,t.offsetY)}});class stt{constructor(t){this.params=Object.assign({},t)}excute(){}}class ctt extends stt{execute(){this.params.changes.forEach((t=>t.component.set(t.after)))}static before(t){return t.map((t=>({component:t})))}static after(t,e){e.execute(null,!1)}static around(t,e,r){e.call(r),t.execute(null,!1)}}const utt="left",ltt="right",htt="center",ftt="top",dtt="bottom",ptt="middle",gtt=[utt,ltt,htt,ftt,ptt,dtt];function vtt(t){if(this.hasSameParentForAllSelected&&-1!=gtt.indexOf(t)){var e=this.selected.filter((t=>!t.stuck));if(!(e.length<=1)){var r=this.app.commander;ctt.around(r,(function(){!function(t,e){var r=JSON.parse(JSON.stringify(e[0].bounds)),n=r.left+r.width,i=r.top+r.height;for(let t=0;t<e.length;t++){let a=e[t].bounds;r.left=a.left>r.left?r.left:a.left,r.top=a.top>r.top?r.top:a.top,n=a.left+a.width>n?a.left+a.width:n,i=a.top+a.height>i?a.top+a.height:i}switch(r.width=n-r.left,r.height=i-r.top,t){case utt:for(let t=0;t<e.length;t++){let n=e[t].bounds;e[t].bounds={left:r.left,top:n.top,width:n.width,height:n.height}}break;case htt:for(let t=0;t<e.length;t++){let n=e[t].bounds;e[t].bounds={left:r.left+r.width/2-n.width/2,top:n.top,width:n.width,height:n.height}}break;case ltt:for(let t=0;t<e.length;t++){let r=e[t].bounds;e[t].bounds={left:n-r.width,top:r.top,width:r.width,height:r.height}}break;case ftt:for(let t=0;t<e.length;t++){let n=e[t].bounds;e[t].bounds={left:n.left,top:r.top,width:n.width,height:n.height}}break;case ptt:for(let t=0;t<e.length;t++){let n=e[t].bounds;e[t].bounds={left:n.left,top:r.top+r.height/2-n.height/2,width:n.width,height:n.height}}break;case dtt:for(let t=0;t<e.length;t++){let r=e[t].bounds;e[t].bounds={left:r.left,top:i-r.height,width:r.width,height:r.height}}break;default:;}}(t,e)}))}}}const ytt="VERTICAL",mtt=[ytt,"HORIZONTAL"];function btt(t){if(this.hasSameParentForAllSelected&&-1!=mtt.indexOf(t)){var e=this.selected;if(!(e.length<=1)){var r=this.app.commander;ctt.around(r,(function(){!function(t,e){var r=e.filter((t=>!t.stuck)).slice(0);r.sort((function(e,r){let n=e.center,i=r.center;return t===ytt?n.y-i.y:n.x-i.x}));var n=r.reduce(((e,r)=>e+(t===ytt?r.bounds.height:r.bounds.width)),0),i=r[0].bounds,a=r[r.length-1].bounds,o=((t===ytt?a.top+a.height-i.top:a.left+a.width-i.left)-n)/(r.length-1),s=t===ytt?i.top+i.height:i.left+i.width;for(let e=1;e<r.length-1;e++){let n=r[e],i=n.bounds;s+=o,t===ytt?(i.top=s,s+=i.height):(i.left=s,s+=i.width),n.bounds=i}}(t,e)}))}}}function xtt(t){for(var e=0;t&&!t.isRootModel();)e+=t.get("rotation")||0,t=t.parent;return e%(2*Math.PI)}class wtt extends stt{execute(){this.params.changes.forEach((t=>{let{component:e,to_container:r,to_index:n,to_left:i,to_top:a,hint:o}=t,s=function(t){if(t.isRootModel())return t.bounds;var{bounds:e,rotatePoint:r}=t,n=r;return{left:(n=t.transcoordS2T(n.x,n.y)).x-(r.x-e.left),top:n.y-(r.y-e.top),width:e.width,height:e.height}}(e),c=xtt(e);if(e.removeSelf(!r),e.bounds=s,e.set("rotation",c),r){e.set("rotation",function(t,e){return((t.get("rotation")||0)-xtt(e))%(2*Math.PI)}(e,r));let o=function(t,e){if(e.isRootModel())return t.bounds;var{bounds:r,rotatePoint:n}=t,i=e.transcoordT2S(n.x,n.y),a=e.bounds;return{left:i.x-(n.x-r.left)-a.left,top:i.y-(n.y-r.top)-a.top,width:r.width,height:r.height}}(e,r);t.to_left=void 0!==i?i:o.left,t.to_top=void 0!==a?a:o.top,e.bounds={left:t.to_left,top:t.to_top,width:o.width,height:o.height},void 0===n?r.addComponent(e):r.insertComponentAt(e,n)}}))}}function Att(t,e,r){this.app.commander.execute(new wtt({changes:[{component:t,to_container:e,to_index:r}]}))}function _tt(t){var e=this.selected.filter((t=>!t.stuck));if(!(0==e.length||e[0].isRootModel()||e.length>1&&("forward"==t||"backward"==t))){var r,n=e[0].parent;if("forward"==t){let t=n.indexOf(e[0]);r=[{component:e[0],from_container:n,to_container:n,from_index:t,to_index:t+1}]}else if("backward"==t){let t=n.indexOf(e[0]);r=[{component:e[0],from_container:n,to_container:n,from_index:t,to_index:t-1}]}else r=e.filter((t=>t.parent===n)).sort(((e,r)=>{let i=n.indexOf(e)<n.indexOf(r);return"front"==t?i:!i})).map(((e,r)=>(n.indexOf(e),{component:e,to_container:n,to_index:"front"==t?n.components.length-r-1:r})));var i=new wtt({changes:r});this.app.commander.execute(i)}}function ktt(t,e,r,n){var i=l9.register(t.type);if(!i)return D8("Class not found",t.type),null;r&&(t.refid=r(t.refid)),t.id&&n&&n(t.id)&&delete t.id;var a=new i(t,e);return t.components&&a.isContainer()&&(t.components.forEach((t=>{var i=ktt(t,e,r,n);i&&a.addComponent(i)})),delete t.components),a.created(),a}function Ett(t,e){var r=Z6(t.hierarchy);return delete r.id,ktt(r,t.app,e)}var Stt=Object.freeze({__proto__:null,compile:ktt,duplicate:Ett,select:o7,match:n7});function Mtt(t,e,r){t instanceof Array||(t=[t]),r||(r=this.model_layer);var n=[],i=new Map;this.selected=t.map((t=>{try{return ktt(t,r.app,(t=>{const e=this.getNewRefid();return void 0!==t&&i.set(t,e),e}),(t=>(this.indexMap[t]||[])[0]))}catch(t){return console.warn(t),!1}})).filter(Boolean).map((t=>{let{left:a,top:o,width:s,height:c,x:u,y:l,cx:h,cy:f}=e;return t.replaceRefids(i),isNaN(a)||isNaN(o)||isNaN(s)||isNaN(c)||(t.bounds={left:a,top:o,width:s,height:c}),isNaN(u)||isNaN(l)||t.move({x:u,y:l},!1),isNaN(h)||isNaN(f)||(t.center={x:h,y:f}),n.push({component:t,to_container:r}),t})),this.app.commander.execute(new wtt({changes:n}))}function Ttt(){var t=[],e=new Map;if(this.selected=this.selected.filter((t=>!t.isRootModel())).map((r=>{let n=Ett(r,(t=>{const r=this.getNewRefid();return void 0!==t&&e.set(t,r),r}));return n.move({x:20,y:20},!1),t.push({component:n,to_container:r.parent}),n})).map((t=>(t.replaceRefids(e),t))),0!=t.length){var r=new wtt({changes:t});this.app.commander.execute(r)}}function Ptt(){var t=this.selected;this.selected=[];for(var e=null,r=t.filter((t=>!t.isRootModel()&&(t.parent.focusible||t.parent.isGroup()))).map((t=>(e||(e=t.parent),{component:t,to_container:null})));e&&e.isGroup();){let t=[];if(e.components.filter((t=>!r.find((e=>e.component===t)))).forEach((e=>t.push(e))),t.length>1)break;let n=e.parent;t.forEach((t=>r.push({component:t,to_container:n}))),r.push({component:e,to_container:null}),e=n}r.length>0&&this.app.commander.execute(new wtt({changes:r})),e&&e.calculateBounds&&e.calculateBounds()}function Ott(t,e,r){switch(t){case"execute":case"redo":case"undo":case"command-reset":this.app?.commander.on(t,e,r);break;case"mode":this.app?.on(t,e,r);break;default:this.on(t,e,r)}}function Itt(t,e,r){switch(t){case"execute":case"redo":case"undo":case"command-reset":this.app?.commander.once(t,e,r);break;case"mode":this.app.once(t,e,r);break;default:this.once(t,e,r)}}function Ctt(t,e,r){switch(t){case"execute":case"redo":case"undo":case"command-reset":this.app?.commander.off(t,e,r);break;case"mode":this.app?.off(t,e,r);break;default:this.off(t,e,r)}}function Rtt(t){var e=this.target_element,r=t||this.fitMode,n=this;function i(t){n.fit(r),document.fullscreen||document.mozFullScreen||document.webkitIsFullScreen||document.msFullscreenElement||["fullscreenchange","mozfullscreenchange","webkitfullscreenchange","MSFullscreenChange"].forEach((t=>document.removeEventListener(t,i)))}["fullscreenchange","mozfullscreenchange","webkitfullscreenchange","MSFullscreenChange"].forEach((t=>document.addEventListener(t,i))),e.requestFullScreen?e.requestFullScreen():e.webkitRequestFullScreen?e.webkitRequestFullScreen():e.mozRequestFullScreen?e.mozRequestFullScreen():e.msRequestFullscreen&&e.msRequestFullscreen()}var jtt=0;function Ltt(){var t=this.selected.filter((t=>!t.isRootModel())).map((t=>t.hierarchy));if(0!=t.length)return jtt=0,JSON.stringify(t,null,2)}function Dtt(){jtt=0;var t=Ltt.call(this);return Ptt.call(this),t}function ztt(t){if(t)try{jtt++,Mtt.call(this,JSON.parse(t),{x:15*jtt,y:15*jtt})}catch(e){L8(e,t)}}var Ftt=function(){return{escape:function(t){return t.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1")},parseExtension:t,mimeType:function(e){var r=t(e).toLowerCase();return(n="application/font-woff",i="image/jpeg",{woff:n,woff2:n,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:i,jpeg:i,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml"})[r]||"";var n,i},dataAsUrl:function(t,e){return"data:"+e+";base64,"+t},isDataUrl:function(t){return-1!==t.search(/^(data:)/)},canvasToBlob:function(t){return t.toBlob?new Promise((function(e){t.toBlob(e)})):function(t){return new Promise((function(e){for(var r=window.atob(t.toDataURL().split(",")[1]),n=r.length,i=new Uint8Array(n),a=0;a<n;a++)i[a]=r.charCodeAt(a);e(new Blob([i],{type:"image/png"}))}))}(t)},resolveUrl:function(t,e){var r=document.implementation.createHTMLDocument(),n=r.createElement("base");r.head.appendChild(n);var i=r.createElement("a");return r.body.appendChild(i),n.href=e,i.href=t,i.href},getAndEncode:function(t){var e=3e4;Xtt.impl.options.cacheBust&&(t+=(/\?/.test(t)?"&":"?")+(new Date).getTime());return new Promise((function(r){var n,i=new XMLHttpRequest;if(i.onreadystatechange=o,i.ontimeout=s,i.responseType="blob",i.timeout=e,i.open("GET",t,!0),i.send(),Xtt.impl.options.imagePlaceholder){var a=Xtt.impl.options.imagePlaceholder.split(/,/);a&&a[1]&&(n=a[1])}function o(){if(4===i.readyState)if(200===i.status){var e=new FileReader;e.onloadend=function(){var t=e.result.split(/,/)[1];r(t)},e.readAsDataURL(i.response)}else n?r(n):c("cannot fetch resource: "+t+", status: "+i.status)}function s(){n?r(n):c("timeout of "+e+"ms occured while fetching resource: "+t)}function c(t){console.error(t),r("")}}))},uid:function(){var t=0;return function(){return"u"+e()+t++;function e(){return("0000"+(Math.random()*Math.pow(36,4)|0).toString(36)).slice(-4)}}}(),delay:function(t){return function(e){return new Promise((function(r){setTimeout((function(){r(e)}),t)}))}},asArray:function(t){for(var e=[],r=t.length,n=0;n<r;n++)e.push(t[n]);return e},escapeXhtml:function(t){return t.replace(/#/g,"%23").replace(/\n/g,"%0A")},makeImage:function(t){return new Promise((function(e,r){var n=new Image;n.onload=function(){e(n)},n.onerror=r,n.src=t}))},width:function(t){var r=e(t,"border-left-width"),n=e(t,"border-right-width");return t.scrollWidth+r+n},height:function(t){var r=e(t,"border-top-width"),n=e(t,"border-bottom-width");return t.scrollHeight+r+n}};function t(t){var e=/\.([^\.\/]*?)$/g.exec(t);return e?e[1]:""}function e(t,e){var r=window.getComputedStyle(t).getPropertyValue(e);return parseFloat(r.replace("px",""))}}(),Ntt=function(){var t=/url\(['"]?([^'"]+?)['"]?\)/g;return{inlineAll:function(t,i,a){return o()?Promise.resolve(t):Promise.resolve(t).then(r).then((function(e){var r=Promise.resolve(t);return e.forEach((function(t){r=r.then((function(e){return n(e,t,i,a)}))})),r}));function o(){return!e(t)}},shouldProcess:e,impl:{readUrls:r,inline:n}};function e(e){return-1!==e.search(t)}function r(e){for(var r,n=[];null!==(r=t.exec(e));)n.push(r[1]);return n.filter((function(t){return!Ftt.isDataUrl(t)}))}function n(t,e,r,n){return Promise.resolve(e).then((function(t){return r?Ftt.resolveUrl(t,r):t})).then(n||Ftt.getAndEncode).then((function(t){return Ftt.dataAsUrl(t,Ftt.mimeType(e))})).then((function(r){return t.replace(function(t){return new RegExp("(url\\(['\"]?)("+Ftt.escape(t)+")(['\"]?\\))","g")}(e),"$1"+r+"$3")}))}}(),Btt=function(){return{resolveAll:function(){return t().then((function(t){return Promise.all(t.map((function(t){return t.resolve()})))})).then((function(t){return t.join("\n")}))},impl:{readAll:t}};function t(){return Promise.resolve(Ftt.asArray(document.styleSheets)).then((function(t){var e=[];return t.forEach((function(t){try{Ftt.asArray(t.cssRules||[]).forEach(e.push.bind(e))}catch(e){console.log("Error while reading CSS rules from "+t.href,e.toString())}})),e})).then((function(t){return t.filter((function(t){return t.type===CSSRule.FONT_FACE_RULE})).filter((function(t){return Ntt.shouldProcess(t.style.getPropertyValue("src"))}))})).then((function(e){return e.map(t)}));function t(t){return{resolve:function(){var e=(t.parentStyleSheet||{}).href;return Ntt.inlineAll(t.cssText,e)},src:function(){return t.style.getPropertyValue("src")}}}}}(),Utt=function(){return{inlineAll:function e(r){return r instanceof Element?n(r).then((function(){return r instanceof HTMLImageElement?t(r).inline():Promise.all(Ftt.asArray(r.childNodes).map((function(t){return e(t)})))})):Promise.resolve(r);function n(t){var e=t.style.getPropertyValue("background");return e?Ntt.inlineAll(e).then((function(e){t.style.setProperty("background",e,t.style.getPropertyPriority("background"))})).then((function(){return t})):Promise.resolve(t)}},impl:{newImage:t}};function t(t){return{inline:function(e){return Ftt.isDataUrl(t.src)?Promise.resolve():Promise.resolve(t.src).then(e||Ftt.getAndEncode).then((function(e){return Ftt.dataAsUrl(e,Ftt.mimeType(t.src))})).then((function(e){return new Promise((function(r,n){t.onload=r,t.onerror=n,t.src=e}))}))}}}}(),Ytt={imagePlaceholder:void 0,cacheBust:!1};function Gtt(t,e){return function(t){void 0===t.imagePlaceholder?Xtt.impl.options.imagePlaceholder=Ytt.imagePlaceholder:Xtt.impl.options.imagePlaceholder=t.imagePlaceholder;void 0===t.cacheBust?Xtt.impl.options.cacheBust=Ytt.cacheBust:Xtt.impl.options.cacheBust=t.cacheBust}(e=e||{}),Promise.resolve(t).then((function(t){return Htt(t,e.filter,!0)})).then(qtt).then((function(t){var{bgcolor:r,width:n,height:i,style:a,sx:o=1,sy:s=1}=e,c=t.style;r&&(c.backgroundColor=r);n&&(c.width=n+"px");i&&(c.height=i+"px");c["margin-left"]="0px",c["margin-top"]="0px",["-webkit-","-moz-","-ms-","-o-",""].forEach((t=>{c[t+"transform"]=`rotate(0rad) translate(0px, 0px) scale(${o}, ${s}) perspective(1px)`})),a&&Object.keys(a).forEach((function(t){c[t]=a[t]}));return t})).then((function(r){return function(t,e,r){return Promise.resolve(t).then((function(t){return t.setAttribute("xmlns","http://www.w3.org/1999/xhtml"),(new XMLSerializer).serializeToString(t)})).then(Ftt.escapeXhtml).then((function(t){return'<foreignObject x="0" y="0" width="100%" height="100%">'+t+"</foreignObject>"})).then((function(t){return'<svg xmlns="http://www.w3.org/2000/svg" width="'+e+'" height="'+r+'">'+t+"</svg>"})).then((function(t){return"data:image/svg+xml;charset=utf-8,"+t}))}(r,e.width||Ftt.width(t),e.height||Ftt.height(t))}))}function Wtt(t,e){return Gtt(t,e).then(Ftt.makeImage).then(Ftt.delay(100)).then((function(r){var n=function(t){var r=document.createElement("canvas");if(r.width=e.width||Ftt.width(t),r.height=e.height||Ftt.height(t),e.bgcolor){var n=r.getContext("2d");n.fillStyle=e.bgcolor,n.fillRect(0,0,r.width,r.height)}return r}(t);return n.getContext("2d").drawImage(r,0,0),n}))}function Htt(t,e,r){return r||!e||e(t)?Promise.resolve(t).then((function(t){if(t instanceof HTMLCanvasElement)try{return Ftt.makeImage(t.toDataURL())}catch(t){D8(t)}return t.cloneNode(!1)})).then((function(r){return function(t,e,r){var n=t.childNodes;return 0===n.length?Promise.resolve(e):i(e,Ftt.asArray(n),r).then((function(){return e}));function i(t,e,r){var n=Promise.resolve();return e.forEach((function(e){n=n.then((function(){return Htt(e,r)})).then((function(e){e&&t.appendChild(e)}))})),n}}(t,r,e)})).then((function(e){return function(t,e){return e instanceof Element?Promise.resolve().then(r).then(n).then(i).then(a).then((function(){return e})):e;function r(){function r(t,e){function r(t,e){Ftt.asArray(t).forEach((function(r){e.setProperty(r,t.getPropertyValue(r),t.getPropertyPriority(r))}))}t.cssText?e.cssText=t.cssText:r(t,e)}r(window.getComputedStyle(t),e.style)}function n(){function r(r){var n=window.getComputedStyle(t,r),i=n.getPropertyValue("content");if(""!==i&&"none"!==i){var a=Ftt.uid();e.className=e.className+" "+a;var o=document.createElement("style");o.appendChild(s(a,r,n)),e.appendChild(o)}function s(t,e,r){var n="."+t+":"+e,i=r.cssText?a(r):o(r);return document.createTextNode(n+"{"+i+"}");function a(t){var e=t.getPropertyValue("content");return t.cssText+" content: "+e+";"}function o(t){return Ftt.asArray(t).map(e).join("; ")+";";function e(e){return e+": "+t.getPropertyValue(e)+(t.getPropertyPriority(e)?" !important":"")}}}}[":before",":after"].forEach((function(t){r(t)}))}function i(){t instanceof HTMLTextAreaElement&&(e.innerHTML=t.value),t instanceof HTMLInputElement&&e.setAttribute("value",t.value)}function a(){e instanceof SVGElement&&(e.setAttribute("xmlns","http://www.w3.org/2000/svg"),e instanceof SVGRectElement&&["width","height"].forEach((function(t){var r=e.getAttribute(t);r&&e.style.setProperty(t,r)})))}}(t,e)})):Promise.resolve()}function qtt(t){return Utt.inlineAll(t).then((function(){return t}))}var Xtt={toSvg:Gtt,toPng:function(t,e){return Wtt(t,e||{}).then((function(t){return t.toDataURL()}))},toJpeg:function(t,e){return Wtt(t,e=e||{}).then((function(t){return t.toDataURL("image/jpeg",e.quality||1)}))},toBlob:function(t,e){return Wtt(t,e||{}).then(Ftt.canvasToBlob)},toPixelData:function(t,e){return Wtt(t,e||{}).then((function(e){return e.getContext("2d").getImageData(0,0,Ftt.width(t),Ftt.height(t)).data}))},impl:{fontFaces:Btt,images:Utt,util:Ftt,inliner:Ntt,options:{}}};function Vtt(t,e,r,n){var i=this.model_layer,a=i._overlay;return new Promise((function(o,s){if(i){var c=i.get("width"),u=i.get("height");r=r||c,n=n||u;var l=i.get("translate"),h=i.get("scale"),f=Math.min(r/c,n/u);r=c*f,n=u*f,i.set("translate",{x:0,y:0}),i.set("scale",{x:f/V8,y:f/V8});var d=l9.createCanvas(r,n),p=d.getContext("2d");if(i.draw(p),i.set("translate",l),i.set("scale",h),!a)return o(d.toDataURL(t,e)),void(d=null);Xtt.toPng(a,{sx:f,sy:f,width:r,height:n}).then((function(i){var a=new Image;a.onload=function(){p.drawImage(a,0,0,r,n),o(d.toDataURL(t,e)),d=null},a.src=i}),(function(r){L8(r),o(d.toDataURL(t,e)),d=null}))}else s("No target model")}))}function Qtt(){if(this.hasSameParentForAllSelected){var t=this.selected.filter((t=>!!t.parent&&!t.stuck));if(!(t.length<2)){var e=t[0].parent,r=[],n=t.sort(((t,r)=>e.components.indexOf(t)-e.components.indexOf(r)));n.forEach((t=>{r.push(t.bounds)}));var i=l9.union(r),a=t[0].transcoordP2S(i.left,i.top);a=t[0].transcoordS2T(a.x,a.y);var o=new Map,s=ktt({type:"group",left:a.x,top:a.y,width:i.width,height:i.height},e.app,(t=>{const e=this.getNewRefid();return void 0!==t&&o.set(t,e),e}));s.replaceRefids(o);var c=[{component:s,to_container:e}];n.forEach((t=>{c.push({component:t,to_container:s})})),this.app.commander.execute(new wtt({changes:c})),this.selected=[s]}}}function Ktt(){if(0!==this.selected.length){var t=[],e=[];this.selected.forEach((r=>{if(r.isGroup()){var n=r.parent;r.components.forEach((r=>{t.push(r),e.push({component:r,to_container:n})})),e.push({component:r,to_container:null})}})),this.app.commander.execute(new wtt({changes:e})),this.selected=t}}function Jtt(){var t=this.selected;if(0!=t.length){var e=t.map((t=>t.bounds)),r=l9.union(e),n=r.left+r.width/2;t.map((t=>{t.symmetryX(n)}))}}function Ztt(){var t=this.selected;if(0!=t.length){var e=t.map((t=>t.bounds)),r=l9.union(e),n=r.top+r.height/2;t.map((t=>{t.symmetryY(n)}))}}function $tt(){ctt.around(this.app.commander,Jtt,this)}function tet(){ctt.around(this.app.commander,Ztt,this)}function eet(t,e,r){var n=this.findAll(t,r);return n.forEach((t=>{t.set(e)})),n}function ret(t){ctt.around(this.app.commander,t)}function net(){return Object.values(this.indexMap).map((t=>t.map((t=>{let{id:e,data:r}=t.model;return{key:e,value:r}})))).flat().sort(((t,e)=>t.key>e.key?1:-1))}const iet="left",aet="right",oet="center",set="top",cet="bottom",uet="middle",het=[iet,aet,oet,set,uet,cet];function fet(t){if(this.hasSameParentForAllSelected&&-1!=het.indexOf(t)){var e=this.selected.filter((t=>!t.stuck)),r=this.app.commander;ctt.around(r,(function(){!function(t,e){const r=e[0].parent,{width:n,height:i}=r.bounds;switch(t){case iet:for(let t=0;t<e.length;t++){let r=e[t].bounds;e[t].bounds={...r,left:0}}break;case oet:for(let t=0;t<e.length;t++){let r=e[t].bounds;e[t].bounds={...r,left:n/2-r.width/2}}break;case aet:for(let t=0;t<e.length;t++){let r=e[t].bounds;e[t].bounds={...r,left:n-r.width}}break;case set:for(let t=0;t<e.length;t++){let r=e[t].bounds;e[t].bounds={...r,top:0}}break;case uet:for(let t=0;t<e.length;t++){let r=e[t].bounds;e[t].bounds={...r,top:i/2-r.height/2}}break;case cet:for(let t=0;t<e.length;t++){let r=e[t].bounds;e[t].bounds={...r,top:i-r.height}}break;default:;}}(t,e)}))}}function det(t){t instanceof Array||(t=[t]),this.trigger("addstart",t)}function pet(){this.trigger("stylepastestart")}function get(){this.trigger("stylepastestop")}function vet(){this.trigger("databindpastestart")}function yet(){this.trigger("databindpastestop")}function met(t,e,r,n){var i=t.selected,a=n?i.slice(0):[];n&&a.length>0?e=a[0].parent:e.isContainer()||(e=e.parent);var o=e.layout.capturables(e),s=!!e.layout.joinType;if(n&&r.selected.forEach((t=>{a.splice(a.indexOf(t),1)})),r.selected=[],o.forEach((t=>{t.capturable&&function(t,e,r){var n,i,a,o,{sx:s,sy:c,ex:u,ey:l}=e;if(s>u?(n=u,i=s):(n=s,i=u),c>l?(a=l,o=c):(a=c,o=l),r){var h=t.bounds,f=t.transcoordS2TR(h.left,h.top),d=t.transcoordS2TR(h.left+h.width,h.top+h.height),p=f.x,g=d.x,v=f.y,y=d.y,m=Math.min(n,p,i,g),b=Math.max(n,p,i,g),x=Math.min(a,v,o,y),w=Math.max(a,v,o,y);return!(b-m>Math.abs(i-n)+Math.abs(g-p)||w-x>Math.abs(o-a)+Math.abs(y-v))}var A=t.path;if(!A)return error("컴포넌트에 get path가 잘못 구현되어있음.",t),!1;for(let e=0;e<A.length;e++){let r=t.transcoordS2TR(A[e].x,A[e].y);if(n>r.x||i<r.x||a>r.y||o<r.y)return!1}return!0}(t,r,s)&&-1==a.indexOf(t)&&r.selected.push(t)})),a=a.concat(r.selected),i.length!==a.length)t.selected=a;else for(let e=0;e<a.length;e++)if(i[e]!=a[e]){t.selected=a;break}}function bet(t,e,r,n,i){i||met(t,e,r,n)}function xet(t,e){var r=t.components||[];for(let t of r){xet(t,e);let r=e.indexOf(t);-1!=r&&e.splice(r,1)}}l9.register("add-layer",class extends F9{ready(){super.ready();var t=this.rootModel,e=t.get("translate"),r=t.get("scale");this.set("translate",e),this.set("scale",r)}render(t){var e=this.addbox;if(e){let{sx:r,sy:n,ex:i,ey:a}=e,o=this.get("scale")||{x:1,y:1};t.beginPath(),t.rect(r,n,i-r,a-n),t.setLineDash([2/o.x,4/o.y]),t.lineWidth=1/o.x,t.strokeStyle="black",t.stroke()}}contains(t,e){return!(3!=this.app.mode)}get eventMap(){return{"(root)":{"(self)":{addstart:this.onaddstart,addstop:this.onaddstop,keydown:this.onkeydown,dragstart:this.ondragstart,dragmove:this.ondragmove,dragend:this.ondragend,mousedown:this.onmousedown,mouseup:this.onmouseup}},"model-layer":{"(self)":{change:this.onchange_root_model}}}}onchange_root_model(t,e,r){t.translate&&this.set("translate",t.translate),t.scale&&this.set("scale",t.scale)}onaddstart(t,e){void 0===this.before_mode&&(this.before_mode=this.app.mode,this.models=t,this.app.mode=3)}onaddstop(){void 0!==this.before_mode&&(this.app.mode=this.before_mode),delete this.before_mode,delete this.addbox,this.invalidate()}onkeydown(t){3!==this.app.mode||"Esc"!=t.code&&"Escape"!=t.code||this.root.trigger("addstop")}ondragstart(t){var{x:e,y:r}=this.transcoordC2S(t.offsetX,t.offsetY);this.addbox={sx:e,sy:r}}ondragmove(t){if(3===this.app.mode){var{x:e,y:r}=this.transcoordC2S(t.offsetX,t.offsetY);this.addbox&&(this.addbox.ex=e,this.addbox.ey=r,this.invalidate())}}ondragend(t,e){if(3!==this.app.mode)return;const{sx:r,sy:n,ex:i,ey:a}=this.addbox;Mtt.call(this.root,this.models,{left:Math.min(r,i),top:Math.min(n,a),width:Math.abs(i-r),height:Math.abs(a-n)}),this.root.trigger("addstop")}onmousedown(t,e){3===this.app.mode&&(this.downpoint={x:t.offsetX,y:t.offsetY})}onmouseup(t,e){if(this.downpoint.x===t.offsetX&&this.downpoint.y===t.offsetY){var{x:r,y:n}=this.transcoordC2S(t.offsetX,t.offsetY);Mtt.call(this.root,this.models,{cx:r,cy:n}),this.root.trigger("addstop")}}});l9.register("selection-layer",class extends F9{ready(){super.ready();var t=this.rootModel,e=t.get("translate"),r=t.get("scale");this.set("translate",e),this.set("scale",r)}contains(t,e){return!1}render(t){var e=this.selbox;if(e){let{sx:r,sy:n,ex:i,ey:a}=e,o=this.get("scale")||{x:1,y:1};t.beginPath(),t.rect(r,n,i-r,a-n),t.setLineDash([2/o.x,4/o.y]),t.lineWidth=1/o.x,t.strokeStyle="black",t.stroke()}}get eventMap(){return{"(root)":{"(self)":{keydown:this.onkeydown}},"model-layer":{"(self)":{change:this.onchange_root_model},"(all)":{dragstart:this.ondragstart_selbox,dragmove:this.ondragmove_selbox,dragend:this.ondragend_selbox,mousedown:this.onmousedown_comp,mouseup:this.onmouseup_comp}}}}onkeydown(t,e){var{origin:r,deliverer:n}=e,i=n.selected;if(1!==i.length)return!1;var a=i[0],o=a.parent;if(!o||o===n)return!1;if("Tab"===t.code){var s=o.layout.capturables(o),c=s.indexOf(a);if(-1==c){if(!o.indexOf(a))return D8("Container not contains [",a,"] as a component"),!1;c=0}var u=s.length;t.shiftKey?c--:c++,a=s[(c+u)%u]}else{if(!o.layout.keyNavigate)return!1;a=o.layout.keyNavigate(o,a,t)||a}n.selected=[a],t.preventDefault()}onchange_root_model(t,e,r){t.translate&&this.set("translate",t.translate),t.scale&&this.set("scale",t.scale)}_pendingDecision(t){this.downpoint={x:t.offsetX,y:t.offsetY}}_selectGroupItem(t,e){var r=this.selected.indexOf(t);let n=t.parent;for(;n.parent.isGroup();)n=n.parent;let i=[],a=!1,o=!1;if(this.selected.forEach((t=>{let e=t.parent;if(t!==n){for(;e.parent&&e.parent.isGroup();)e=e.parent;e===n&&(i.push(t),a=!0)}else o=!0})),a)if(e.shiftKey){if(-1!=r)return void this._pendingDecision(e);i.push(t)}else{if(-1!=r)return void this._pendingDecision(e);i=[t]}else{if(o)return void this._pendingDecision(e);if(e.shiftKey)if(this.selected.length>0){if(-1!=this.selected.indexOf(n))return;i=[...this.selected,n]}else i=[n];else i=[n]}this.selected=i}onmousedown_comp(t,e){var{origin:r}=e;if(this.downpoint=null,t.shiftKey){if(r.parent.isGroup())return void this._selectGroupItem(r,t);if(-1!=this.selected.indexOf(r))return void this._pendingDecision(t);{let t=this.selected.filter((t=>!t.isRootModel()&&!!t.parent)),e=t.length>0&&t[0].parent;e&&e!==r.parent&&(!function(t,e){for(var r=t.parent;r;){let t=e.indexOf(r);-1!=t&&e.splice(t,1),r=r.parent}}(r,t),xet(r,t)),t.push(r),this.selected=t}}else{if(r.parent.isGroup())return void this._selectGroupItem(r,t);if(-1!=this.selected.indexOf(r))return;this.selected=[r],this.sameParent=!0}}onmouseup_comp(t,e){if(!this.downpoint)return;if(this.downpoint.x!==t.offsetX||this.downpoint.y!==t.offsetY)return;var{origin:r}=e;let n=this.selected.indexOf(r);if(-1==n&&r.parent.isGroup()&&(n=this.selected.indexOf(r.parent)),-1!==n&&t.shiftKey){let t=this.selected.slice();return n>-1&&t.splice(n,1),void(this.selected=t)}r.parent.isGroup()&&(this.selected=[r])}ondragstart_selbox(t,e){var{origin:r}=e;if(r.stuck){var{x:n,y:i}=this.transcoordC2S(t.offsetX,t.offsetY);this.selbox={sx:n,sy:i,selected:[]}}}ondragmove_selbox(t,e){var{origin:r}=e;if(r.stuck){var{x:n,y:i}=this.transcoordC2S(t.offsetX,t.offsetY);this.selbox&&(this.selbox.ex=n,this.selbox.ey=i,bet(this,r,this.selbox,t.shiftKey),this.invalidate())}}ondragend_selbox(t,e){var{origin:r}=e;r.stuck&&(this.last_pos=null,this.selbox=null,bet(this,null,null,!1,!0),this.invalidate())}});class wet{constructor(t){this.layer=t}draw(t,e,r){var{left:n,top:i,width:a,height:o}=e.bounds;0!=a&&0!=o&&(t.beginPath(),t.rect(n,i,a,o),t.clip(),t.beginPath(),t.strokeStyle="#f26522",t.lineWidth=4,t.shadowBlur=10,t.shadowColor="black",t.shadowOffsetX=0,t.shadowOffsetY=0,t.rect(n,i,a,o),t.stroke(),t.closePath())}}class Aet{constructor(t){this.layer=t}draw(t,e,r){var n=e.bounds;t.beginPath(),t.rect(n.left-4/r.x,n.top-4/r.y,n.width+8/r.x,n.height+8/r.y),t.setLineDash([3/r.x,4/r.y]),t.lineWidth=1/r.x,t.strokeStyle="black",t.stroke(),t.setLineDash([]),t.closePath()}}class _et{constructor(t){this.layer=t}reset(){this.active=null}get selected(){return this.layer.selected}contains(t,e,r,n){let i=r.controls;return!!i&&(i.every(((i,a)=>(Math.abs(t-i.x)<=4/n.x&&Math.abs(e-i.y)<=4/n.y&&(this.active={component:r,index:a,handler:i.handler}),!this.active))),!!this.active)}draw(t,e,r){var n=e.controls;n&&n.forEach(((e,n)=>{t.beginPath(),t.lineWidth=1/r.x,t.ellipse(e.x,e.y,4/r.x,4/r.y,0,0,2*Math.PI,!0),t.fillStyle="#ff5d72",t.fill(),t.strokeStyle="#fff",t.stroke()}))}onevent(t,e){var{handler:r,component:n,index:i}=this.active,a=n.transcoordC2S(e.offsetX,e.offsetY);a=n.transcoordS2P(a.x,a.y),r&&"function"==typeof r[t]&&r[t](a,i,n)}onmousedown(t){this.onevent("onmousedown",t)}ondragstart(t){var e=this.active;e.changes=ctt.before([e.component]),this.onevent("ondragstart",t)}ondragmove(t){this.onevent("ondragmove",t)}ondragend(t){this.onevent("ondragend",t);var{component:e,changes:r}=this.active;ctt.after(r,e.app.commander),e.parent&&e.parent.calculateBounds&&e.parent.calculateBounds()}}function ket(t,e){return Math.atan2(e.y-t.y,e.x-t.x)}const Eet=15*Math.PI/180;class Met{constructor(t){this.layer=t}reset(){this.active=null,this.created=null}get selected(){return this.layer.selected}contains(t,e,r,n){return!!r.mutable&&(r.path.every(((i,a)=>(Math.abs(t-i.x)<=4/n.x&&Math.abs(e-i.y)<=4/n.y&&(this.active={component:r,index:a}),!this.active))),!!this.active)}startLinkProcess(t,e,r){try{var n=ktt(e,t.app);return t.rootModel.addComponent(n),this.layer.selected=[n],this.active={component:n,index:1},this.ondragstart(r),n}catch(t){console.warn(r)}}draw(t,e,r){if(e.mutable&&!e.stuck){var n=e.path,i=this.active;n.forEach(((n,a)=>{t.beginPath(),t.ellipse(n.x,n.y,4/r.x,4/r.y,0,0,2*Math.PI,!0),t.lineWidth=1/r.x,t.strokeStyle="#656565",t.fillStyle="#fff",i&&i.component===e&&i.index===a&&(t.strokeStyle="#fa7703",i.toFill&&(t.fillStyle="#ffb80c")),t.fill(),t.stroke()}))}}ondblclick(t){var e=this.active.component;if(e.pathExtendable){var r=e.path.slice();r.length<3||(r.splice(this.active.index,1),e.path=r)}}onmousedown(t){this.active.toFill=!0}ondragstart(t){var{index:e,component:r}=this.active;this.created||(this.active.changes=ctt.before([r])),0!==e&&e!==r.path.length-1||(this.layer.counterEnd=0===e?r.toEnd||{fromto:"to"}:r.fromEnd||{fromto:"from"})}ondragmove(t){var{component:e,index:r}=this.active||{};const{offsetX:n,offsetY:i}=t;var a,o,s=e.transcoordC2S(n,i);if(s=e.transcoordS2P(s.x,s.y),t.shiftKey){var c=e.path.length,u=e.isLine()&&0==r?e.path[1]:e.path[(r-1+c)%c];u=e.transcoordS2P(u.x,u.y);var l,h=0;if(c>2)e.isLine()?0==r?l=e.path[2]:1!=r&&(l=e.path[r-2]):l=e.path[(r-2+c)%c],l&&(h=ket(l=e.transcoordS2P(l.x,l.y),u));var f=Math.round((ket(u,s)-h)/Eet)*Eet+h;s=function(t,e,r){return{x:Math.cos(e)*r+t.x,y:Math.sin(e)*r+t.y}}(u,f,(a=u,o=s,Math.sqrt((o.x-a.x)*(o.x-a.x)+(o.y-a.y)*(o.y-a.y))))}if(0===r||r===e.path.length-1){const t=this.layer.anchorTarget=e.rootModel.capture(n,i,(t=>!t.isConnectable()));if(t){const{x:a,y:o}=t.transcoordC2S(n,i),c=this.layer.get("scale")||{x:1,y:1},u=this.layer.counterEnd,l=(t.anchors||[]).find((r=>{const{name:n,inout:i,multiplicity:s=1/0,position:l,filter:h}=r;if(u){const{anchor:t,fromto:e}=u;if(t&&("out"===t.inout&&"out"===i||"in"===t.inout&&"in"===i))return!1;if("from"===e&&"out"===i||"to"===e&&"in"===i)return!1}else console.error("should not be here.");if(Math.abs(a-l.x)>8/c.x||Math.abs(o-l.y)>8/c.y)return!1;const f=t.findInOutLines(n);return!!f.includes(e)||!(s!==1/0&&f.length>=s)&&(!u||!h||!!h.call(r,u))}));l?0==r?e.from={component:t.get("refid"),anchor:l.name,position:s}:e.to={component:t.get("refid"),anchor:l.name,position:s}:0==r?e.from={position:s}:e.to={position:s}}}e.mutatePath(null,(function(t){t[r]=s}))}ondragend(t){var{component:e,index:r,changes:n}=this.active;if(0===r||r===e.path.length-1){const{offsetX:n,offsetY:i}=t,a=e.rootModel.capture(n,i,(t=>t===e||t.isLine())),{x:o,y:s}=a.transcoordC2S(n,i),c=this.layer.get("scale")||{x:1,y:1},u=(a.anchors||[]).find((t=>t&&Math.abs(o-t.position.x)<=8/c.x&&Math.abs(s-t.position.y)<=8/c.y));u&&(0==r?e.from={component:a.get("refid"),anchor:u.name}:e.to={component:a.get("refid"),anchor:u.name}),this.layer.endLinkProcess()}if(this.created){let t=new wtt({changes:[{component:this.created,to_container:this.created.parent}]});created.app.commander.execute(t)}else ctt.after(n,e.app.commander);e.parent&&e.parent.calculateBounds&&e.parent.calculateBounds()}}class Tet{constructor(t){this.layer=t}get active(){return this._active?.component.disposed&&(this._active=null),this._active}set active(t){this._active=t}reset(){this.active=null}contains(t,e,r,n){const i=this.active?.component===r&&this.active?.anchor;this.active=null;const a=this.layer.counterEnd;return(r.isConnectable()&&!r.disposed&&r.anchors||[]).filter((t=>{const{name:e,inout:n,multiplicity:i=1/0,filter:o}=t;if(a){const{anchor:t,fromto:e}=a;if(t&&("out"===t.inout&&"out"===n||"in"===t.inout&&"in"===n))return!1;if("from"===e&&"out"===n||"to"===e&&"in"===n)return!1}else if("in"===n)return!1;return!(i!==1/0&&r.findInOutLines(e).length>=i)&&(!o||!a||!!o.call(t,a))})).every((a=>{const o=i===a.name?2:1;return a&&a.position&&Math.abs(t-a.position.x)<=4*o/n.x&&Math.abs(e-a.position.y)<=4*o/n.y&&(this.active={component:r,anchor:a.name,template:a.template}),!this.active})),!!this.active}draw(t,e,r){if(!e.get("refid")||e.isLine())return;var n=this.active;const i=this.active?.component===e&&this.active?.anchor,a=this.layer.counterEnd;(e.isConnectable()&&!e.disposed&&e.anchors||[]).filter((t=>{const{name:r,inout:n,multiplicity:i=1/0,filter:o}=t;if(a){const{anchor:t,fromto:e}=a;if(t&&("out"===t.inout&&"out"===n||"in"===t.inout&&"in"===n))return!1;if("from"===e&&"out"===n||"to"===e&&"in"===n)return!1}else if("in"===n)return!1;return!(i!==1/0&&e.findInOutLines(r).length>=i)&&(!a||!o||!!o.call(t,a))})).forEach((a=>{const{name:o,position:s}=a,c=i===o?2:1;s&&(t.beginPath(),t.ellipse(s.x,s.y,4*c/r.x,4*c/r.y,0,0,2*Math.PI),t.setLineDash([0,0]),t.lineWidth=1/r.x,t.strokeStyle="#656565",t.stroke(),t.fillStyle="#fff",n&&n.component===e&&n.anchor===o&&(t.strokeStyle="#fa7703",n.focus&&(t.fillStyle="#ffb80c")),t.fill(),t.stroke())}))}onmousedown(t){this.active.focus=!0}ondragstart(t){const{component:e,anchor:r,template:n}=this.active,i=this.layer.transcoordC2S(t.offsetX,t.offsetY);this.layer.startLinkProcess(e,{type:"ortholine",lineWidth:1,strokeStyle:"black",begin:"oval",beginSize:"size9",end:"arrow",endSize:"size9",lineDash:"solid",lineCap:"butt",round:10,...n,from:{component:e.get("refid"),anchor:r,position:i},to:{position:i}},t)}ondragmove(t){}ondragend(t){}}function Pet(t,e,r){var n,i,{left:a,top:o,width:s,height:c}=t.bounds;switch(e){case 0:n=a,i=o;break;case 1:n=a+s/2,i=o;break;case 2:n=a+s,i=o;break;case 3:n=a+s,i=o+c/2;break;case 4:n=a+s,i=o+c;break;case 5:n=a+s/2,i=o+c;break;case 6:n=a,i=o+c;break;case 7:n=a,i=o+c/2}var u=n,l=i,h=t.transcoordT2S(r.x,r.y);return{dx:h.x-u,dy:h.y-l}}function Oet(t,e,r,n,i,a){var{left:o,top:s,width:c,height:u}=t.bounds,l={left:o,top:s,width:c,height:u};switch(e){case 0:o+=n,s+=i,c-=n,u-=i;break;case 1:s+=i,u-=i;break;case 2:s+=i,c+=n,u-=i;break;case 3:c+=n;break;case 4:c+=n,u+=i;break;case 5:u+=i;break;case 6:o+=n,c-=n,u+=i;break;case 7:o+=n,c-=n}if(t.mutateBounds((function(e){return Math.abs(c)<=.001&&(c=.001),Math.abs(u)<=.001&&(u=.001),t.adjustResize({left:o,top:s,width:c,height:u},l,r)}),this),t.isContainer()&&t.layout.ABSOLUTE&&!t.isGroup()){var h=l.left-o,f=l.top-s;a?t.components.forEach((t=>{t.delta("tx",0),t.delta("ty",0),t.move({x:h,y:f},!1)})):t.components.forEach((t=>{t.delta("tx",h),t.delta("ty",f)}))}else{var d=a&&t.parent;d&&d.isGroup()&&d.calculateBounds()}}function Iet(t,e){var{left:r,top:n,width:i,height:a}=t,o=r+i/2,s=n+a/2,c=r+i,u=n+a;const l=i*e.x>50,h=a*e.y>50;return[{x:r,y:n},l?{x:o,y:n}:null,{x:c,y:n},h?{x:c,y:s}:null,{x:c,y:u},l?{x:o,y:u}:null,{x:r,y:u},h?{x:r,y:s}:null]}class Cet{constructor(t){this.layer=t}reset(){this.active=null}get selected(){return this.layer.selected}contains(t,e,r,n){return!!r.resizable&&(Iet(r.bounds,n).every(((i,a)=>(i&&Math.abs(t-i.x)<=4/n.x&&Math.abs(e-i.y)<=4/n.y&&(this.active={component:r,index:a}),!this.active))),!!this.active)}draw(t,e,r){if(!e.isLine()){var{left:n,top:i,width:a,height:o}=e.bounds;if(t.beginPath(),t.rect(n-4/r.x,i-4/r.y,a+8/r.x,o+8/r.y),t.setLineDash([3/r.x,4/r.y]),t.lineWidth=1/r.x,t.strokeStyle="black",t.stroke(),t.setLineDash([]),e.resizable){var s=this.active;Iet(e.bounds,r).forEach(((n,i)=>{n&&(t.beginPath(),t.rect(n.x-4/r.x,n.y-4/r.y,8/r.x,8/r.y),t.setLineDash([0,0]),t.strokeStyle="#656565",t.stroke(),t.fillStyle="#fff",s&&s.component===e&&s.index===i&&(t.strokeStyle="#fa7703",s.focus&&(t.fillStyle="#ffb80c")),t.fill(),t.stroke())}))}}}onmousedown(t){this.active.focus=!0}ondragstart(t){var{component:e}=this.active;this.active.bounds=e.bounds,this.active.boundsList=this.layer.selected.filter((t=>t.resizable)).map((t=>t.bounds))}ondragmove(t){var{component:e,index:r,boundsList:n,bounds:i}=this.active,a=this.layer.transcoordC2S(t.offsetX,t.offsetY);e.bounds=i;var o=Pet(e,r,a);this.layer.selected.filter((t=>t.resizable)).forEach(((e,i)=>{e.bounds=n[i],Oet(e,r,t.shiftKey,o.dx,o.dy,!1)}))}ondragend(t){var{component:e,index:r,boundsList:n,bounds:i}=this.active,a=this.layer.transcoordC2S(t.offsetX,t.offsetY);e.bounds=i;var o=Pet(e,r,a);this.layer.selected.filter((t=>t.resizable)).forEach(((e,i)=>{e.bounds=n[i],Oet(e,r,t.shiftKey,o.dx,o.dy,!0)})),this.active.component.app.commander.execute(null,!1)}}const Ret=2*Math.PI,jet=Math.PI/2;function Let(t,e){var r=t.bounds;return{x:r.left+r.width/2,y:r.top-20/e.y}}class Det{constructor(t){this.layer=t}reset(){this.active=null}get selected(){return this.layer.selected}contains(t,e,r,n){if(!r.rotatable)return!1;var i=Let(r,n);return Math.abs(t-i.x)<=4/n.x&&Math.abs(e-i.y)<=4/n.y&&(this.active={component:r},!0)}draw(t,e,r){if(e.rotatable){t.beginPath();var n=Let(e,r);t.lineWidth=1.5/r.x,t.moveTo(n.x,n.y+20/r.y),t.lineTo(n.x,n.y),t.strokeStyle="#656565",t.stroke(),t.beginPath(),t.ellipse(n.x,n.y,4/r.x,4/r.y,0,0,Ret,!0),t.stroke(),t.fillStyle="#fff",t.fill();var i=this.active;i&&i.component===e&&(t.strokeStyle="#fa7703",t.stroke(),i.toFill&&(t.fillStyle="#ffb80c",t.fill()))}}onmousedown(t){this.active.toFill=!0}ondragstart(t){var e=this.active;e.component,e.start_rotation=e.component.get("rotation"),e.rotations=this.layer.selected.filter((t=>t.rotatable)).map((t=>t.get("rotation")))}ondragmove(t){var{component:e}=this.active,r=e.transcoordC2S(t.offsetX,t.offsetY);r=e.transcoordS2P(r.x,r.y);var n=e.rotatePoint,i=e.get("rotation")||0,a=Math.atan((n.y-r.y)/(n.x-r.x)),o=(a=n.x>=r.x?a-jet:jet+a)-i;this.layer.selected.filter((t=>t.rotatable)).forEach(((e,r)=>{let n=((e.get("rotation")||0)+o)%Ret;e.set("rotation",e.adjustRotation(n,t.shiftKey))}))}ondragend(t){var{component:e,rotations:r}=this.active;e.app.commander.execute(null,!1)}}l9.register("modeling-layer",class extends F9{constructor(t,e){super(t,e),this.pathHandler=new Met(this);var r=this.pathHandler,n=new _et(this),i=new Cet(this),a=new Det(this);this._modelers=[r,n,i,a],this._control_mode_modelers=[n,r,i,a],this.focusOutline=new wet(this),this.groupOutline=new Aet(this),this.anchorHandler=new Tet(this),this._reversed_modelers=this._modelers.slice().reverse(),this._control_mode_reverse_modelers=this._control_mode_modelers.slice().reverse(),this.hovered=null,this.hoveredDest=null}get modelers(){return this._control_mode?this._control_mode_modelers:this._modelers}get reversedModelers(){return this._control_mode?this._control_mode_reverse_modelers:this._reversed_modelers}ready(){super.ready();var t=this.rootModel,e=t.get("translate"),r=t.get("scale");this.set("translate",e),this.set("scale",r)}contains(t,e){var r=this.selected.filter((t=>!!t.parent)),n=this.get("scale")||{x:1,y:1};if(this._state_dragging){if(this._counter_end){let r=this.anchorTarget.transcoordT2S(t,e);if(this.anchorHandler.contains(r.x,r.y,this.anchorTarget,n))return!0}return!0}this.modelers.forEach((t=>t.reset()));r=this.selected.filter((t=>!!t.parent));for(let i=0;i<r.length;i++){let a=r[i],o=a.transcoordT2S(t,e);for(let t=0;t<this.modelers.length;t++){let e=this.modelers[t];if(e.contains(o.x,o.y,a,n))return this.currentModeler=e,!0}}if(this.anchorTarget){let r=this.anchorTarget.transcoordT2S(t,e);if(this.anchorHandler.contains(r.x,r.y,this.anchorTarget,n))return this.currentModeler=this.anchorHandler,!0}else this.anchorHandler.reset();return this.currentModeler=null,!1}_componentDrawer(t,e,r,n){let i=[],a=e.parent;if(e.isRootModel())return t.save(),n(t,e,r),void t.restore();for(;a&&!a.isRootModel();)i.push(a),a=a.parent;t.save(),i.reverse().forEach((function(e){let r=e.rotatePoint;t.translate(r.x,r.y);let n=e.get("scale");n&&t.scale(n.x,n.y),t.rotate(e.get("rotation")),t.translate(-r.x,-r.y);let i=e.bounds;t.translate(i.left,i.top)}));let o=e.rotatePoint;t.translate(o.x,o.y);let s=e.get("scale");s&&t.scale(s.x,s.y),t.rotate(e.get("rotation")),t.translate(-o.x,-o.y),n(t,e,r),t.restore()}prerender(t){var{translate:e,scale:r={x:1,y:1},rotation:n}=this.model;t.save(),t.beginPath(),t.clearRect(0,0,t.canvas.width,t.canvas.height),t.rect(0,0,t.canvas.width,t.canvas.height),t.fillStyle="black",t.globalAlpha=.5,t.fill(),t.restore(),e&&t.translate(e.x*V8,e.y*V8),t.scale(r.x*V8,r.y*V8),n&&t.rotate(n),t.clearRect(0,0,this.rootModel.get("width"),this.rootModel.get("height"))}render(t){t.beginPath();var e=this.get("scale")||{x:1,y:1},r=this.selected.filter((t=>!!t.parent));if(this.focused&&this._componentDrawer(t,this.focused,e,((t,e,r)=>{this.focusOutline.draw(t,e,r)})),r.length>0&&r[0].parent.isGroup()){let n=r[0].parent;for(;n.parent.isGroup();)n=n.parent;this._componentDrawer(t,n,e,((t,e,r)=>{this.groupOutline.draw(t,e,r)}))}r.forEach((r=>{this._componentDrawer(t,r,e,((t,e,r)=>{this.reversedModelers.forEach((n=>n.draw(t,e,r)))}))})),this.anchorTarget&&this._componentDrawer(t,this.anchorTarget,e,((t,e,r)=>{this.anchorHandler.draw(t,e,r)}))}get anchorTarget(){return this.currentModeler===this.anchorHandler||this.currentModeler===this.pathHandler||this.hovered?.isLine()||(this._anchorTarget=this.hovered),this._anchorTarget}set anchorTarget(t){this._anchorTarget=t}get hovered(){return this._hovered}set hovered(t){this._hovered=t,this.invalidate()}startLinkProcess(t,e,r){this.currentModeler=this.pathHandler,this.processingLink=this.pathHandler.startLinkProcess(t,e,r),this.counterEnd=this.processingLink.fromEnd,this.processingLink.trigger("tag")}set counterEnd(t){this.currentModeler=this.pathHandler,this._counter_end=t}get counterEnd(){return this._counter_end}endLinkProcess(){this.processingLink?.trigger("tagreset"),this.processingLink=null,this._counter_end=null}get eventMap(){return{"model-layer":{"(all)":{change:this.onchange_model,wheel:this.onwheel_scale,drop:this.ondrop},"(descendant)":{mouseenter:this.onmouseenter,mouseleave:this.onmouseleave},"(self)":{dblclick:this.ondblclick_model}},"(root)":{"(self)":{selected:this.onselected,keydown:this.onkeydown,keyup:this.onkeyup}}}}onmouseenter(t,e){this.hovered=e?.origin}onmouseleave(t,e){this.hovered=null}onkeydown(t){"Alt"==t.key&&(this._control_mode=!0,this.invalidate())}onkeyup(t){"Alt"==t.key&&(this._control_mode=!1,this.invalidate())}onselected(t,e){this.invalidate()}onchange_model(t,e,r){var{origin:n,deliverer:i}=r;n===i&&(t.translate&&this.set("translate",t.translate),void 0!==t.rotation&&this.set("rotation",t.rotation),t.scale&&this.set("scale",t.scale)),this.invalidate()}ondblclick_model(t,e){const r=e.origin;r?.root.fit()}ondblclick(t){"function"==typeof this.currentModeler.ondblclick&&this.currentModeler.ondblclick(t),this.invalidate()}onmousedown(t){this.currentModeler.onmousedown(t),this.invalidate()}onmouseup(t){"function"==typeof this.currentModeler.onmouseup&&this.currentModeler.onmouseup(t),this.invalidate()}ondragstart(t){this.currentModeler.ondragstart(t),this._state_dragging=!0}ondragmove(t){this.currentModeler.ondragmove(t),this.invalidate()}ondragend(t){this._state_dragging=!1,this.currentModeler.ondragend(t),this.invalidate()}ondrop(t,e){var{origin:r}=e,n=t.dataTransfer.files;if(n.length<1)return;let i=this.rootModel.transcoordC2S(t.offsetX,t.offsetY),a=this.rootModel;Promise.all(Array.from(n).map((t=>new Promise(((e,r)=>{let n=new FileReader;n.addEventListener("loadend",(t=>{e(n.result)})),["error","abort"].forEach((t=>n.addEventListener(t,(t=>{r(t)})))),n.readAsDataURL(t)}))))).then((e=>{if(t.altKey)return ctt.around(this.app.commander,(()=>{r.ondropfile(n,e)})),void(this.selected=[r]);let o=[],s=e.map(((t,e)=>{let r,s=n[e].type,c=n[e].name;return s.startsWith("image/")?(r=ktt({type:s.startsWith("image/gif")?"gif-view":"image-view",top:0,left:0,width:200,height:200,src:t},a.app),o.push(new Promise(((e,n)=>{let i=new Image;i.src=t,i.onload=()=>{r.set({width:i.width,height:i.height}),e()},i.onerror=t=>{n(t)}})))):s.startsWith("audio/")?r=ktt({type:"audio",top:0,left:0,width:100,height:100,src:t},a.app):s.startsWith("vnd.ms-excel/")||/\.xlsx?$/.test(c)?r=ktt({type:"excel",top:0,left:0,width:100,height:100,src:t},a.app):console.log("droped file",n[e]),r&&(r.center=i,i.x+=50,i.y+=50),r})).filter(Boolean).map((t=>({component:t,to_container:a})));s.length>0&&Promise.all(o).then((()=>{this.app.commander.execute(new wtt({changes:s})),this.selected=s.map((t=>t.component))}),(t=>{console.error(t)}))}),(t=>{console.error(t)}))}onwheel_scale(t,e){if(0!=t.deltaY||0!=t.deltaX){var r=e.deliverer;if(t.shiftKey){if(-1!=navigator.userAgent.indexOf("Win"))var n=t.deltaY<0?1:-1;else n=t.deltaX<0?1:-1;ctt.around(this.app.commander,(()=>{r.selected.forEach((t=>{let e=t.get("fontSize")||J8.FONT_SIZE;e<1&&(e=1),e+=n,t.set("fontSize",e)}))}))}else{n=t.deltaY<0?1:-1;let e=r.get("scale")||{x:1,y:1},i=r.get("translate"),a=t.offsetX,o=t.offsetY,s=r.transcoordC2S(a,o),c=.1*n,u={x:e.x+c,y:e.y+c};if(n<0&&e.x<.2||n>0&&e.x>10)return;r.set("scale",u);let l=r.transcoordC2S(a,o);r.set("translate",{x:i.x+(l.x-s.x)*u.x,y:i.y+(l.y-s.y)*u.y})}}}});class zet extends F9{constructor(t,e){super(t,e),this._anim_alpha=1}animOnTargetChange(t){t!==this._lastTargets&&(this._lastTargets=t,this._anim_alpha=1,this.animate({step:t=>{this._anim_alpha=1-t,this.invalidate()},duration:5e3,delta:"circ",ease:"in"}).start())}decorate(t,e,r){const n=t.decorators;var i=!1;return n.map((t=>"string"==typeof t?r9(t):t)).filter((t=>t&&"function"==typeof t)).map((n=>{const a=n(t,e,1-r);i||=a})),i}render(t){var e=this.decoTargets&&this.decoTargets.filter((t=>t.rootModel));if(!e||0==e.length)return this._animate&&this._animate.stop(),void delete this._animate;t.globalAlpha*=this._anim_alpha;var r=!1;e.forEach((e=>{this.decorate(e,t,1-this._anim_alpha)&&(r=!0)})),r&&this.animOnTargetChange(this.decoTargets)}get decoTargets(){return this._decoTargets}set decoTargets(t){this._decoTargets=t&&t.filter((t=>!t.isLayer())),this.invalidate()}get eventMap(){return{"model-layer":{"(descendant)":{tag:this.ondecotag,tagreset:this.ondecotagreset,mouseenter:this.onmouseenter,mouseleave:this.onmouseleave}}}}onmouseenter(t,e){this._decotagreset(),this._ondecotag(e.origin)}onmouseleave(t,e){this._decotagreset()}ondecotagreset(t){this._decotagreset()}ondecotag(t){this._ondecotag(t.origin)}offdecotag(t,e){this._offdecotag(e.origin)}_ondecotag(t){this.decoTargets&&-1!==this.decoTargets.lastIndexOf(t)||(this.decoTargets=(this.decoTargets||[]).concat(t))}_offdecotag(t){if(this.decoTargets){var e=this.decoTargets.slice();e.splice(this.decoTargets.lastIndexOf(t),1),this.decoTargets=e}}_decotagreset(){this.decoTargets=[]}}l9.register("decotag-layer",zet),l9.register("tag-layer",zet);l9.register("reaction-layer",class extends F9{constructor(t,e){super(t,e),this._anim_alpha=1}animOnTargetChange(t){t!==this._lastTargets&&(this._lastTargets=t,this._anim_alpha=1,this.animate({step:t=>{this._anim_alpha=1-t,this.invalidate()},duration:1e4,delta:"circ",ease:"inout"}).start())}decorate(t,e,r){const n=t.reactionDecorators;var i=!1;return n.map((t=>"string"==typeof t?r9(t):t)).filter((t=>t&&"function"==typeof t)).map((n=>{const a=n(t,e,1-r);i||=a})),i}render(t){var e=this.targets&&this.targets.filter((t=>t.rootModel));if(!e||0==e.length)return this._animate&&this._animate.stop(),void delete this._animate;t.globalAlpha*=this._anim_alpha;var r=!1;e.forEach((e=>{this.decorate(e,t,1-this._anim_alpha)&&(r=!0)})),r&&this.animOnTargetChange(this.targets)}get targets(){return this._targets}set targets(t){this._targets=t&&t.filter((t=>!t.isLayer())),this.invalidate()}get eventMap(){return{"model-layer":{"(descendant)":{reaction:this.onreaction,reactionreset:this.onreactionreset}}}}onreactionreset(t){this._reactionreset()}onreaction(t){this._onreaction(t.origin)}offreaction(t,e){this._offreaction(e.origin)}_onreaction(t){this.targets&&-1!==this.targets.lastIndexOf(t)||(this.targets=(this.targets||[]).concat(t))}_offreaction(t){if(this.targets){var e=this.targets.slice();e.splice(this.targets.lastIndexOf(t),1),this.targets=e}}_reactionreset(){this.targets=[]}});function Fet(){var t=arguments,e=t[t.length-1],r=this.event_pump;r.listeners.forEach((n=>{!function(t,e,r,n,i){for(let a in r){let o=r[a];if(n7(a,n.origin,0,t))for(let t in o){let r=o[t];t==n.name&&(n.listener=e,r.apply(e,i))}}}(r.deliverer,n.listener,n.cloned_handlers,e,t)}))}l9.register("scroll-layer",class extends F9{get capturable(){return!0}render(t){const{scrolling:e}=this.state;if(t.save(),t.beginPath(),t.fillStyle="#777",this.vscroller){const{left:r,top:n,width:i,height:a}=this.vscroller;t.globalAlpha="v"==e?1:.3,t.fillRect(r,n,i,a)}if(this.hscroller){const{left:r,top:n,width:i,height:a}=this.hscroller;t.globalAlpha="h"==e?1:.3,t.fillRect(r,n,i,a)}t.stroke(),t.restore()}resize(){super.resize(),this.calcScrollerBounds()}contains(t,e){const r=this.vscroller,n=this.hscroller;return this.setState("scrolling",r&&t>=r.left&&t<=r.left+r.width&&e>=r.top&&e<=r.top+r.height?"v":n&&t>=n.left&&t<=n.left+n.width&&e>=n.top&&e<=n.top+n.height?"h":null),!!this.getState("scrolling")}get eventMap(){return{"(root)":{"model-layer":{change:this.onchangeModelLayer}}}}onchange(t){"scrolling"in t&&this.invalidate()}ondragstart(t,e){this.lastPosition={x:t.offsetX,y:t.offsetY}}ondragmove(t,e){const r=this.root,{clientWidth:n,clientHeight:i}=this.canvas,{width:a,height:o}=this.rootModel.model,{x:s,y:c}={x:t.offsetX,y:t.offsetY},{x:u,y:l}=this._scale,{scrolling:h}=this.state,f=a/n,d=o/i;h&&r.rootModel.move({x:"h"==h?(-s+this.lastPosition.x)*u*f:0,y:"v"==h?(-c+this.lastPosition.y)*l*d:0},!1),this.lastPosition={x:t.offsetX,y:t.offsetY}}ondragend(){delete this.lastPosition,this.setState({scrolling:null})}calcScrollerBounds(){var{clientWidth:t,clientHeight:e}=this.canvas;const{width:r,height:n}=this.rootModel.model,{x:i=1,y:a=1}=this._scale||{},{x:o=0,y:s=0}=this._translate||{},c=r/t,u=n/e;var l={left:-o/i/c,top:e-10,width:t/i/c,height:10};this.hscroller=l.left>1||l.width+l.left<t-1?l:null,l={left:t-10,top:-s/a/u,width:10,height:e/a/u},this.vscroller=l.top>1||l.height+l.top<e-1?l:null,this.invalidate()}onchangeModelLayer(t,e,r){if(t.scale){const{x:e=1,y:r=1}=t?.scale||{};this._scale={x:e,y:r},this.calcScrollerBounds()}if(t.translate){const{x:e=0,y:r=0}=t.translate||{};this._translate={x:e,y:r},this.calcScrollerBounds()}}});class Net{constructor(t){if(void 0===t.on)throw new Error("Deliverer should be a event handlable object.");this.deliverer=t,this.listeners=[]}start(){this.deliverer.on("(all)",Fet,{event_pump:this})}stop(){this.deliverer.off("(all)",Fet)}on(t,e){var r=Object.assign({},e);Object.keys(r).forEach((e=>{if(0==e.indexOf("?")){let n=r[e],i=e.substr(1),a=t.get(i);delete r[e],a?r[a]=n:D8("EventPump#on","variable #{selector} is not evaluated on listener")}})),this.listeners.push({listener:t,handlers:e,cloned_handlers:r})}off(t,e){for(let r=0;r<this.listeners.length;r++){let n=this.listeners[r];n.listener!==t||e&&n.handlers!==e||this.listeners.splice(r,1)}}clear(){this.listeners=[]}dispose(){this.stop(),this.clear()}}class Bet{constructor(t){this.eventMaps=[],this.root=t,t.eventMap&&this.add(t,t.eventMap)}set root(t){this._root=t}get root(){return this._root}stop(){this.eventMaps.forEach((t=>t.eventPump.stop()))}add(t,e){if(this.root)for(let r in e){let n=e[r];if("(self)"===r&&void 0===t.on)throw new Error("(self) selector not available when deliverer is not a event handlable object.");o7(r,this.root,t).forEach((r=>{var i=new Net(r);i.on(t,n),i.start(),this.eventMaps.push({eventPump:i,listener:t,handlerMap:e,deliverer:r})}))}}remove(t,e){var r=this.eventMaps.slice(0);for(let n=0;n<r.length;n++){let i=r[n];i.listener!==t||e&&i.handlerMap!==e||(this.eventMaps.splice(n,1),i.eventPump.dispose())}}clear(){this.eventMaps.slice(0).forEach((t=>t.eventPump.dispose())),this.eventMaps=[]}dispose(){this.stop(),this.clear()}}const Uet=0,Yet=1,Get=2,Wet=0,Het=1,qet=2;var Xet={},Vet=0;class Qet{constructor(t,e){this._type=e||t.type,this._ctrlKey=t.ctrlKey,this._altKey=t.altKey,this._shiftKey=t.shiftKey,this._metaKey=t.metaKey;var r=function(t){if(t.touches){let e=t.touches[0];if(!e)return Xet;let r=e.target.getBoundingClientRect();return Xet={x:t.offsetX||e.clientX-(r.x||r.left),y:t.offsetY||e.clientY-(r.y||r.top)}}return{x:t.offsetX,y:t.offsetY}}(t);if(this._offsetX=r.x,this._offsetY=r.y,"wheel"==t.type)this.deltaX=t.deltaX,this.deltaY=t.deltaY,this.deltaZ=t.deltaZ;else if("drop"==t.type)this.dataTransfer=t.dataTransfer;else if(t.type.match(/^touch/)&&(this._scale=t.scale,this._touches=t.touches,this._changedTouches=t.changedTouches,null==this._scale)){var n=function(t){var e,r,n=0,i=0,a=0;if(1===t.touches.length)return a;Array.from(t.touches).forEach((t=>{e=null!=e?Math.min(t.screenX,e):t.screenX,n=Math.max(t.screenX,n),r=null!=r?Math.min(t.screenY,r):t.screenY,i=Math.max(t.screenY,i)}));var o=n-e||0,s=i-r||0;return Math.sqrt(Math.pow(o,2)+Math.pow(s,2))||0}(t);Vet>0&&(this._scale=n/Vet),Vet=n}}get type(){return this._type}set type(t){this._type=t}get offsetX(){return this._offsetX}get offsetY(){return this._offsetY}get altKey(){return this._altKey}get ctrlKey(){return this._ctrlKey}get shiftKey(){return this._shiftKey}get metaKey(){return this._metaKey}get touches(){return this._touches}get changedTouches(){return this._changedTouches}get scale(){return this._scale}stopPropagation(){this._stop_=!0}isPropagationStopped(){return this._stop_}}function Ket(t,e){return t.capture(e.offsetX,e.offsetY)}function Jet(t,e,r){if(t&&t.app&&(!t.app.isViewMode||!t.hidden)){r instanceof Qet&&e===r.type||(r=new Qet(r,e));var n="on"+e;t[n]&&t[n](r),r.isPropagationStopped()||t.trigger(e,r)}}class Zet{constructor(t,e){this.container=t,this.html_element=e,this.status=Uet,this.last_target=null,this.gesture_handlers=Q8.map((t=>this.gestureHandlerBuilder(t))),this.keyevent_handlers=K8.map((t=>this.keyeventHandlerBuilder(t))),Q8.forEach(((t,r)=>e.addEventListener(t,this.gesture_handlers[r]))),K8.forEach(((t,r)=>e.addEventListener(t,this.keyevent_handlers[r]))),e.ondragover=this.gestureHandlerBuilder("dragover"),e.ondrop=this.gestureHandlerBuilder("drop"),e.tabIndex=1}dispose(){this.last_enter_target&&Jet(this.last_enter_target,"mouseleave",new CustomEvent("mouseleave")),Q8.forEach(((t,e)=>this.html_element.removeEventListener(t,this.gesture_handlers[e]))),K8.forEach(((t,e)=>this.html_element.removeEventListener(t,this.keyevent_handlers[e]))),delete this.gesture_handlers,delete this.keyevent_handlers,delete this.last_target}gestureHandlerBuilder(t){var e=this[`on${t}`].bind(this);return t=>(e(new Qet(t))&&t.preventDefault(),!1)}keyeventHandlerBuilder(t){return this[`on${t}`].bind(this)}ondragover(t){return Jet(Ket(this.container,t),t.type,t),!1}ondrop(t){return Jet(Ket(this.container,t),t.type,t),!1}ondblclick(t){return Jet(Ket(this.container,t),t.type,t),this.last_target=null,!1}onkeydown(t){return this.container.trigger(t.type,t),!1}onkeyup(t){return this.container.trigger(t.type,t),!1}onmousemove(t){switch(this.status){case Yet:let r=t.offsetX-this.__dragstart_e.offsetX,n=t.offsetY-this.__dragstart_e.offsetY;if(r*r+n*n<16)break;this.status=Get,Jet(this.last_target,"dragstart",this.__dragstart_e),this.__dragmove_e=t,Jet(this.last_target,"dragmove",t);break;case Get:this.__dragmove_e=t,Jet(this.last_target,"dragmove",t);break;default:var e=Ket(this.container,t);this.last_enter_target!==e&&(this.last_enter_target&&Jet(this.last_enter_target,"mouseleave",t),e&&Jet(e,"mouseenter",t),this.last_enter_target=e),Jet(e,t.type,t),this.last_target=e}return!1}onmousedown(t){if(this.status===Get)Jet(this.last_target,"dragend",t),this.last_target=null,this.status=Uet;else{var e=Ket(this.container,t);this.last_target=e,this.status=Yet,this.__dragstart_e=t,Jet(e,t.type,t)}return!1}onmouseup(t){if(this.status===Get)Jet(this.last_target,"dragend",t);else{var e=Ket(this.container,t);Jet(e,t.type,t),this.last_target===e&&Jet(e,"click",t)}return this.last_target=null,this.status=Uet,!1}onmouseout(t){var e=Ket(this.container,t);if(this.status===Get)Jet(this.last_target,"dragend",t);else{if(this.last_target&&this.last_target===e)return;this.last_enter_target&&(Jet(this.last_enter_target,"mouseleave",t),delete this.last_enter_target)}return this.last_target=null,this.status=Uet,!1}ontouchstart(t){var e=Ket(this.container,t);return this.last_target=e,this.status=Het,this.touchPoints||(this.touchPoints=[]),this.touchPoints.push(t.changedTouches[0]),this.holdTimer=setTimeout((()=>{this.status=Wet,Jet(this.last_target,"hold",t),delete this.holdTimer}),500),Jet(e,t.type,t),!1}ontouchmove(t){if(!t.touches||!t.changedTouches)return Jet(this.last_target,"dragstart",t),Jet(this.last_target,"dragmove",t),!1;var e=Ket(this.container,t);switch(this.status){case Het:Array.from(t.changedTouches).forEach((t=>{var e=this.touchPoints.find((e=>e.identifier===t.identifier));if(e){var r=e.clientX-t.clientX,n=e.clientY-t.clientY;return Math.sqrt(Math.pow(r,2)+Math.pow(n,2))>=16?(this.status=qet,void(this.holdTimer&&(clearTimeout(this.holdTimer),delete this.holdTimer))):void 0}}));break;case qet:if(this.holdTimer&&(clearTimeout(this.holdTimer),delete this.holdTimer),2===t.changedTouches.length&&null!=t.scale&&1!==t.scale&&(t.scale<.9||t.scale>1.1))return Jet(this.last_target,"pinch",t),!1;Jet(this.last_target,"pan",t),e=this.last_target;break;default:this.last_enter_target!==e&&(this.last_enter_target&&Jet(this.last_enter_target,"mouseleave",t),e&&Jet(e,"mouseenter",t),this.last_enter_target=e),this.last_target=e}return Jet(e,"touchmove",t),!1}ontouchend(t){var e=Ket(this.container,t);switch(this.status){case qet:e=this.last_target;break;case Het:var r=performance.now(),n=r-this.touchedAt;this.holdTimer&&(clearTimeout(this.holdTimer),delete this.holdTimer,Jet(e,n<500?"doubletap":"tap",t),this.touchedAt=r)}Jet(e,"touchend",t);var i=this.touchPoints.findIndex((e=>e.identifier===t.changedTouches[0].identifier));return this.touchPoints.splice(i,1),this.last_target=null,this.status=Wet,!1}onwheel(t){return Jet(Ket(this.container,t),t.type,t),!1}}function $et(t,e,r){if(e.length<2)return e;for(var n=2;n<e.length;n++){var i=e.substring(0,n);if(!(t.measureText(i).width<r))break}return e.substring(0,n-1)}function trt(t,e,r,n){var i=String(e).split("\n");return n?[].concat.apply([],i.map((e=>function(t,e,r){var n,i,a=e.split(" "),o=[],s=[];for(n=0,i=1;i<=a.length;i++)if(s=a.slice(n,i),t.measureText(s.join(" ")).width>r){if(i-n==1){let e=$et(t,s[0],r);o.push([e]),a.splice(n,1,e,s[0].substring(e.length))}else{for(;""==a[i-1];)i++;o.push(a.slice(n,--i))}n=i}return i-n>1&&o.push(s),0==o.length&&o.push([""]),o}(t,e,r)))):i.map((t=>t.split(" ")))}var ert={};var rrt={register:function(t,e){ert[t]=e},unregister:function(t){delete ert[t]},get:function(t){return ert[t]}};function nrt(t){if(!t.hasTextProperty||t.textHidden)return;var{text:e="",bold:r=J8.BOLD,italic:n=J8.ITALIC,textWrap:i=J8.TEXT_WRAP,fontFamily:a=J8.FONT_FAMILY,fontColor:o=J8.FONT_COLOR,textAlign:s=J8.TEXT_ALIGN,textBaseline:c=J8.TEXT_BASELINE,fontSize:u=J8.FONT_SIZE,lineHeight:l=1.2*u}=t.model,{left:h,top:f,width:d,height:p}=t.textBounds;u||=J8.FONT_SIZE,l||=1.2*u,t.textHidden=!0;var g=document.createElement("textarea");Q8.forEach((function(t){g.addEventListener(t,(function(t){t.stopPropagation()}),!0)}));const v=t.transcoordS2C(h,f),{rotation:y,scale:m}=function(t){for(var e=0,r=1,n=t;n;){e+=n.get("rotation")||0;let{x:t,y:i}=n.get("scale")||{x:1,y:1};r*=Math.max(t,i)||1,n=n.parent}return{rotation:e,scale:r}}(t);switch(g.style.position="absolute",g.style.width=d+"px",g.style.height=p+"px",g.style.padding="0",g.value=e,g.style.fontFamily=a,g.style.fontSize=u+"px",g.style.lineHeight=l+"px",g.style.overflow="hidden",g.style.resize="none",g.style.outline="none",g.style.border=0,g.style.backgroundColor="transparent",g.style.display="inline-block",g.style.color=o,r&&(g.style.fontWeight="bold"),n&&(g.style.fontStyle="italic"),s){case"right":case"end":g.style.textAlign="right";break;case"justify":g.style.textAlign="justify";break;case"left":case"start":g.style.textAlign="left";break;default:g.style.textAlign="center"}var b=[r,n,u+"px",a].filter(Boolean).join(" ");function x(e){var r={left:0,top:0},n=l*function(t,e,r,n){var i,a=t.getContext();return a.save(),a.font=r,i=trt(a,e,n,t.get("textWrap")).length,a.restore(),i}(t,e,b,d);switch(g.style.height=n+"px",c){case"top":case"hanging":break;case"bottom":case"alphabetic":r.top=p-n;break;default:r.top=p/2-n/2}if(!i){var a=function(t,e,r,n){var i=e.split("\n"),a=n;let o=t.getContext();return o.save(),o.font=r,i.forEach((t=>{let e=o.measureText(t).width;e>a&&(a=e)})),o.restore(),a}(t,e,b,d);switch(g.style.width=a+"px",s){case"right":case"end":r.left=d-a;break;case"left":case"start":break;default:r.left=(d-a)/2}}g.style.marginLeft=r.left+"px",g.style.marginTop=r.top+"px";var o=`translate(${v.x}px, ${v.y}px) scale(${m}) rotate(${y}rad)`;["-webkit-","-moz-","-ms-","-o-",""].forEach((t=>{g.style[t+"transform"]=o,g.style[t+"transform-origin"]=`${-r.left}px ${-r.top}px`}))}x(e);var w=t.root.target_element;w.appendChild(g),g.select();var A,_=!1;g.addEventListener("keydown",(function(t){t.stopPropagation(),"Escape"!=t.code&&(t.shiftKey||"Enter"!=t.code&&"NumpadEnter"!=t.code)?setTimeout((()=>{x(g.value)})):(_=A.skipUpdate="Escape"==t.code,document.createEvent?g.dispatchEvent(A):g.fireEvent(A.eventType,A))})),document.createEvent?(A=document.createEvent("HTMLEvents")).initEvent("blur",!0,!1):(A=document.createEventObject()).eventType="blur";var k=t.root.selected,E=function(r){t.root.selected=k,t.textHidden=!1,g.removeEventListener("blur",E,!1),g.parentElement&&g.parentElement.removeChild(g),w.focus(),r.skipUpdate||_||t.app.commander.execute(new ctt({changes:[{component:t,before:{text:e},after:{text:g.value}}]}))};g.addEventListener("blur",E,!1)}rrt.register("text-editor",{"(root)":{"(self)":{keydown:function(t,e){var{origin:r,deliverer:n}=e,i=n.selected;return!(1!==i.length||!i[0].hasTextProperty)&&(("Enter"==t.code||"NumpadEnter"==t.code)&&(nrt(i[0]),t.preventDefault(),!0))}}},"model-layer":{"(descendant)":{dblclick:function(t,e){nrt(e.origin)}}}});var irt,art,ort,srt=f8((function(t,e,r){if(t.hasSameParentForAllSelected&&!r){var n=[];e[0].parent.isGroup()?t.focused=e[0].parent:(e.forEach((t=>{t.path.forEach((e=>{n.push(t.transcoordS2T(e.x,e.y))}))})),t.focused=t.capturePath(n,e))}else t.focused=null}),300);rrt.register("move-handler",{"model-layer":{"(descendant)":{dragstart:function(t,e){var{origin:r,deliverer:n}=e;if(!r.stuck){var i=n.selected,a=n.selected.filter((t=>!t.stuck));if(i.length!==a.length&&(i=n.selected=a),0!=i.length){var o=i[0].transcoordC2S(t.offsetX,t.offsetY);if(o=i[0].transcoordS2P(o.x,o.y),this.last_pos=o,this.direction=0,n.focused=i[0].parent,t.altKey){var s=[],c=new Map;n.selected=n.selected.filter((t=>!t.isRootModel())).map((t=>{let e=Ett(t,(t=>{const e=n.root.getNewRefid();return void 0!==t&&c.set(t,e),e}));return s.push({component:e,to_container:t.parent}),e})).map((t=>(t.replaceRefids(c),t))),s.forEach((({component:t,to_container:e})=>{e.addComponent(t)})),this.duplicates=n.selected.map((t=>({component:t})))}else this.changes=ctt.before(i)}}},dragmove:function(t,e){var{origin:r,deliverer:n}=e;if(!r.stuck){var i=n.selected;if(0!=i.length){var{x:a,y:o}=i[0].transcoordC2S(t.offsetX,t.offsetY),s=i[0].transcoordS2P(a,o);t.shiftKey?2==this.direction&&(this.direction=0):this.direction=2;var c=s.x-this.last_pos.x,u=s.y-this.last_pos.y;if(0==this.direction){if(c*c+u*u<25)return;Math.abs(c)>Math.abs(u)?this.direction=3:this.direction=4}3==this.direction?u=0:4==this.direction&&(c=0),i.forEach((t=>{t.move({x:c,y:u},1===i.length)})),this.last_pos=s,srt(n,i)}}},dragend:function(t,e){var{origin:r,deliverer:n}=e;if(!r.stuck){var i=n.selected;if(0!=i.length){var a=i[0].parent,o=n.focused||e.deliverer;if(this.changes&&!o.isGroup())if(n.hasSameParentForAllSelected&&o&&o!==a){var s=this.changes.map((t=>{let{component:e,before:r}=t;return{component:e,to_container:o}}));n.app.commander.execute(new wtt({changes:s}))}else ctt.after(this.changes,n.app.commander);else if(this.duplicates){this.duplicates=this.duplicates.map((t=>(t.to_container=o,t)));let t=new wtt({changes:this.duplicates});n.app.commander.execute(t)}i.forEach((t=>{t.parent&&t.parent.calculateBounds&&t.parent.calculateBounds()})),this.last_pos=null,this.changes=null,this.duplicates=null,srt(n,i,!0)}}}}},"(root)":{"(self)":{keydown:function(t,e){var{origin:r,deliverer:n}=e,i={},a=t.shiftKey?r.rootModel.MPP:1;switch(t.which){case 37:i.x=-a,i.y=0;break;case 38:i.x=0,i.y=-a;break;case 39:i.x=a,i.y=0;break;case 40:i.x=0,i.y=a;break;default:return}var o=n.selected;ctt.around(n.app.commander,(function(){o.forEach((t=>{!t.stuck&&t.move(i,!1)}))}))}}}});const crt=d8((()=>{const{x:t,y:e}=ort,r=art.deref();r&&(r.rootModel.move({x:t-irt.x,y:e-irt.y},!1),irt={x:t,y:e})}),60,{leading:!0,trailing:!0});rrt.register("shift-handler",{"model-layer":{"(all)":{dragstart:function(t,e){irt={x:t.offsetX,y:t.offsetY}},dragmove:function(t,e){art=new WeakRef(e.deliverer),ort={x:t.offsetX,y:t.offsetY},crt()}}}}),rrt.register("zoom-handler",{"model-layer":{"(all)":{wheel:function(t,e){if(0==t.deltaY&&0==t.deltaX)return;var r=e.deliverer,n=t.deltaY<0?1:-1;let i=r.get("scale")||{x:1,y:1},a=r.get("translate"),o=t.offsetX,s=t.offsetY,c=r.transcoordC2S(o,s),u=.1*n,l={x:i.x+u,y:i.y+u};if(n<0&&i.x<.2||n>0&&i.x>10)return;r.set("scale",l);let h=r.transcoordC2S(o,s);r.set("translate",{x:a.x+(h.x-c.x)*l.x,y:a.y+(h.y-c.y)*l.y})}},"(self)":{dblclick:function(t,e){const r=e.origin;r?.root.fit()}}}});var urt={},lrt={};function hrt(t){const e={};for(const r in t)t.hasOwnProperty(r)&&void 0!==t[r]&&(e[r]=t[r]);return e}rrt.register("paste-handler",{"(root)":{"(self)":{stylepastestart:function(t){const{deliverer:e}=t,r=e.app;var n=e.selected;if(n&&n[0]&&n!==e.rootModel){const t=n[0],{fillStyle:e,strokeStyle:i,alpha:a,lineWidth:o,lineDash:s,lineCap:c,lineJoin:u,fontColor:l,fontSize:h,fontFamily:f,bold:d,italic:p,textAlign:g,textBaseline:v,textOverflow:y,paddingTop:m,paddingBottom:b,paddingLeft:x,paddingRight:w}=t.state;urt=Z6({fillStyle:e,strokeStyle:i,alpha:a,lineWidth:o,lineDash:s,lineCap:c,lineJoin:u,fontColor:l,fontSize:h,fontFamily:f,bold:d,italic:p,textAlign:g,textBaseline:v,textOverflow:y,paddingTop:m,paddingBottom:b,paddingLeft:x,paddingRight:w}),r.mode=4}},stylepastestop:function(t){const{deliverer:e}=t,r=e.app;urt={},4==r.mode&&(r.mode=1)},databindpastestart:function(t){const{deliverer:e}=t,r=e.app;var n=e.selected;if(n&&n[0]&&n!==e.rootModel){const t=n[0],{mappings:e}=t.state;lrt=Z6({mappings:e}),r.mode=5}},databindpastestop:function(t){const{deliverer:e}=t,r=e.app;lrt={},5==r.mode&&(r.mode=1)},keydown:function(t,e){const{deliverer:r}=e;"Esc"!=t.code&&"Escape"!=t.code||(4==r.app.mode?r.trigger("stylepastestop"):5==r.app.mode&&r.trigger("databindpastestop"))}}},"model-layer":{"(all)":{click:function(t,e){const{deliverer:r}=e,n=r.app;if(4!=n.mode&&5!=n.mode)return;const i=e.origin;4==n.mode?i===r?r.root.trigger("stylepastestop"):i&&ctt.around(n.commander,(()=>{const t=hrt({...i.model,...urt});i?.set(t)})):i===r?r.root.trigger("databindpastestop"):i&&ctt.around(n.commander,(()=>{const t=hrt({...i.model,...lrt});i?.set(t)}))}}}});var frt=[],drt=f8((function(){frt.forEach((t=>{t.resize()}))}),100);"undefined"!=typeof window&&window.addEventListener("resize",drt);class prt extends z9{constructor(t,e){super(Object.assign({type:"root",scale:{x:1,y:1}},t||{}),e),this._maxRefid=e.isViewMode?1e6:0,t=t||{},this.fitMode=t.model&&t.model.fitMode,this._app=e,this.style=t.style,this.target_element=t.target_element,this.rebuildContentModel(this.model.model),frt.push(this)}dispose(){E9.hideAll(this),this._app&&this._app.dispose(),super.dispose(),this._disposeAllResources(),this.target_element=null,delete this._refresh_mapping_debouncer;var t=frt.indexOf(this);t>=0&&frt.splice(t,1),this.refidIndexMap.clear(),this._maxRefid=0}isRoot(){return!0}get app(){return this._app}get target_element(){return this._target_element}set target_element(t){this._ua_event_handler&&(this._ua_event_handler.dispose(),delete this._ua_event_handler),t&&(t.style.position="absolute",t.style.cursor="default",t.style.overflow="hidden",this._ua_event_handler=new Zet(this,t)),this.forEach((e=>e.target=t)),this._target_element=t}get unitScale(){switch(this.model_layer&&this.model_layer.get("unit")){case"mm":case"cm":case"in":return this.app.PPM/10;default:return 1}}addTemplate(t,e){var r=this.templateMap[t];r&&L8("Template replaced (duplicated)",t,e,r),this.templateMap[t]=e,delete this.templatePrefixes}removeTemplate(t,e){var r=this.templateMap[t];r!==e?D8("Removing template failed (different)",t,e,r):delete this.templateMap[t],delete this.templatePrefixes}findTemplateFor(t){this.templatePrefixes||(this.templatePrefixes=Object.keys(this.templateMap).sort().reverse());var e=this.templatePrefixes.find((e=>t.startsWith(e)));if(e)return this.templateMap[e]}addIndex(t,e){var r=this.indexMap[t]||[];this.indexMap[t]=[...r,e]}removeIndex(t,e){const r=this.indexMap[t]||[],n=r.indexOf(e);-1==n?D8("Removing index failed (not found)",t,e):(r.splice(n,1),0==r.length&&delete this.indexMap[t])}addRefidIndex(t,e){null==t&&(t=this.getNewRefid(),e.set("refid",t)),this._maxRefid=Math.max(t,this._maxRefid);var r=this.refidIndexMap.get(t);r&&L8("Refid Index replaced (has not to be)",t,e,r),this.refidIndexMap.set(t,e)}removeRefidIndex(t,e){if(null!=t){var r=this.refidIndexMap.get(t);r!==e?L8("Refid Removing index failed (has not to be)",t,e,r):this.refidIndexMap.delete(t)}}getNewRefid(){return this._maxRefid=(this._maxRefid||0)+1,this._maxRefid}async subscribe(t,e){this._app.isViewMode&&t&&this._app&&(e._subscription=await this._app.subscribe(t,e))}async unsubscribe(t,e){e._subscription&&(await e._subscription.unsubscribe(),delete e._subscription)}findById(t){return(this.indexMap[t.replace(/^#/,"")]||[])[0]}findAllById(t){return this.indexMap[t.replace(/^#/,"")]||[]}findByRefid(t){return this.refidIndexMap.get(t)}findOrCreate(t){var e=this.findAllById(t);if(!e&&this.app&&!this.app.isEditMode){let e=this.findTemplateFor(t);if(e){let r=Object.assign(Z6(e.hierarchy),{id:t,templatePrefix:""});return component=ktt(r,this.app),this.model_layer.addComponent(component),[component]}}return e}resize(){this.components.forEach((t=>{t.resize&&t.resize()})),this.invalidate()}_disposeAllResources(){this.selected=[],this._focused=null,this._ready=!1,this.eventEngine&&(this.assist_handlers&&this.assist_handlers.forEach((t=>{this.eventEngine.remove(t)})),this.eventEngine.dispose(),delete this.eventEngine),this.assist_layers&&this.assist_layers.forEach((t=>{t.dispose(),this.removeComponent(t)})),delete this.assist_layers,this.model_layer&&this.model_layer.dispose(),this.model_layer&&this.removeComponent(this.model_layer),delete this.model_layer,this.indexMap={},this.refidIndexMap=new Map,this.templateMap={}}rebuildContentModel(t){this._disposeAllResources(),this.eventEngine=new Bet(this),(t=t||{}).type="model-layer",this.model_layer=ktt(t,this.app),this.addComponent(this.model_layer),this.model_layer.target=this.target_element,this.assist_layers=(this.model.layers||[]).map((t=>{var e=ktt(t,this.app);return this.addComponent(e),e.target=this.target_element,e})),this.assist_handlers=(this.model.handlers||[]).map((t=>{var e={};return this.eventEngine.add(e,rrt.get(t)),e})),this._ready=!0,this.traverse((t=>t.ready()))}get root(){return this}get anchors(){}get isReady(){return this._ready}get rootModel(){return this.model_layer}get stuck(){return!0}get data(){return Object.values(this.indexMap).reduce(((t,[e])=>(t[e.model.id]=e.data,t)),{})}set data(t){for(var e in t){var r=this.findOrCreate(e);r&&r.forEach((r=>r.data=t[e]))}}get dataByRefid(){var t={};for(let[e,r]of this.refidIndexMap.entries())t[e]=r.data;return t}set dataByRefid(t){for(var e in t){var r=this.findByRefid(Number(e));r&&(r.data=t[e])}}get values(){return Object.values(this.indexMap).reduce(((t,[e])=>(t[e.model.id]=e.value,t)),{})}set values(t){for(var e in t){var r=this.findOrCreate(e);r&&r.forEach((r=>r.value=t[e]))}}get valuesByRefid(){var t={};for(let[e,r]of this.refidIndexMap.entries())t[e]=r.value;return t}set valuesByRefid(t){for(var e in t){var r=this.findByRefid(Number(e));r&&(r.value=t[e])}}get selected(){return(this._selected||[]).filter((t=>t.parent))}set selected(t){var e=this._selected;if(this._selected=t,!t||t.length<=1)this.hasSameParentForAllSelected=!0;else{let e=t[0].parent;this.hasSameParentForAllSelected=!t.find((t=>t.parent!=e))}this.trigger("selected",t,e)}get focused(){return this._focused}set focused(t){this._focused!==t&&(this._focused=t,this.invalidate())}get style(){return this._style}set style(t){this._style=t,this._compiled_style=t}get hasTextProperty(){return!1}render(){this.components.forEach((t=>t.draw()))}contains(t,e){return!0}capturePath(t,e){return this.model_layer.capturePath(t,e)}invalidate(){this.components.forEach((t=>t.invalidate()))}get eventMap(){return{"(root)":{"(descendant)":{added:this.onadded,removed:this.onremoved,change:this.onchanged}}}}refreshMappings(){if(!this._refresh_mapping_debouncer){if(this.disposed)return;this._refresh_mapping_debouncer=f8((function t(e){e.executeMappings(),e.components&&e.components.forEach((e=>t(e)))}),1e3)}this._refresh_mapping_debouncer(this.model_layer)}_addTraverse(t){t.components&&t.components.forEach((t=>this._addTraverse(t)));var{id:e,refid:r,tag:n,templatePrefix:i}=t.model;this.addRefidIndex(r,t),e&&this.addIndex(e,t),n&&this.subscribe(n,t),i&&this.addTemplate(i,t);var a=A8({},t.eventMap,t.model.eventMap);this.eventEngine.add(t,a)}_removeTraverse(t){t.components&&t.components.forEach((t=>this._removeTraverse(t)));var{id:e,refid:r,tag:n,templatePrefix:i}=t.model;this.removeRefidIndex(r,t),e&&this.removeIndex(e,t),n&&this.unsubscribe(n,t),i&&this.removeTemplate(i,t),this.eventEngine.remove(t)}onadded(t,e){this._addTraverse(e),this.refreshMappings(),this.invalidate()}onremoved(t,e){this._removeTraverse(e),this.invalidate()}onchanged(t,e,r){e.templatePrefix&&this.removeTemplate(e.templatePrefix,r.origin),t.templatePrefix&&this.addTemplate(t.templatePrefix,r.origin),e.id&&this.removeIndex(e.id,r.origin),t.id&&this.addIndex(t.id,r.origin),e.tag&&this.unsubscribe(e.tag,r.origin),t.tag&&this.subscribe(t.tag,r.origin),e.id==t.id&&e.class==t.class||this.refreshMappings()}}Object.assign(prt.prototype,{fit:function(t){var{width:e,height:r,fitMode:n}=this.model_layer.model,i=this.target_element,a=this.model_layer;if(this.fitMode=t||this.fitMode||n||"ratio",e&&r&&i&&i.clientWidth&&i.clientHeight){switch(this.fitMode){case"center":!function(t,e,r){var n=t.unitScale,{width:i,height:a}=e.model;e.set("scale",{x:n,y:n}),e.set("translate",{x:Math.max((r.clientWidth-i*n)/2,0),y:Math.max((r.clientHeight-a*n)/2,0)})}(this,a,i);break;case"both":!function(t,e,r){var{width:n,height:i}=e.model,a=r.clientWidth,o=r.clientHeight;e.set("scale",{x:a/n,y:o/i}),e.set("translate",{x:0,y:0})}(0,a,i);break;case"width":!function(t,e,r){var n=r.clientWidth/e.get("width");e.set("scale",{x:n,y:n}),e.set("translate",{x:0,y:0})}(0,a,i);break;case"height":!function(t,e,r){var n=r.clientHeight/e.get("height");e.set("scale",{x:n,y:n}),e.set("translate",{x:0,y:0})}(0,a,i);break;case"ratio":!function(t,e,r){var{width:n,height:i}=e.model,a=r.clientWidth,o=r.clientHeight,s=a/n,c=o/i,u=Math.min(s,c);e.set("scale",{x:u,y:u}),e.set("translate",{x:(a-n*u)/2,y:(o-i*u)/2})}(0,a,i);break;default:!function(t,e){var r=t.unitScale;e.set("scale",{x:r,y:r}),e.set("translate",{x:0,y:0})}(this,a)}this.resize()}}}),l9.memoize(prt.prototype,"unitScale",!1);var grt=13.3,vrt=function(t){return void 0!==t&&(grt=t),grt};const yrt="$base_url";const mrt=Math.PI/12;class brt{constructor(t,e){this._mode=t,this.screen=vrt(),this._baseUrl="undefined"!=typeof window?window.location.origin:null,this._refProvider=e,this.isEditMode&&(this._rotateStep=mrt,this._rotateStepForced=!1)}dispose(){this._dataSubscriptionProvider&&this._dataSubscriptionProvider.dispose(),delete this._dataStorage}_calcScreen(){var t={width:screen.width,height:screen.height};this._PPI=function(t,e,r,n){t>0||(t=1),e>0||(e=1),n||(n="d");var i=("d"==n?Math.sqrt(t*t+e*e):"w"==n?t:e)/r;return i>0?Math.round(i):0}(t.width,t.height,this.screen),this._PPM=this._PPI/25.4}subscribe(t,e){return this._dataSubscriptionProvider?.subscribe(t,e)}get refProvider(){return this._refProvider}set dataSubscriptionProvider(t){this._dataSubscriptionProvider=t}get dataSubscriptionProvider(){return this._dataSubscriptionProvider}set commander(t){this._commander=t}get commander(){return this._commander}get screen(){return this._screen}set screen(t){this._screen=t,this._calcScreen()}get DPPX(){return V8}get PPI(){return this._PPI}get PPM(){return this._PPM}get mode(){return this._mode}set mode(t){var e=this._mode;e!==t&&(this._mode=t,this.trigger("mode",t,e))}get isViewMode(){return 0==this._mode}get isEditMode(){return 1==this._mode}get baseUrl(){return this._baseUrl}set baseUrl(t){t&&this._baseUrl!=t&&(this._baseUrl=t)}url(t){try{return(t.includes(yrt)?new URL(t.replace(yrt,this.baseUrl),this.baseUrl):new URL(t,location.origin)).href}catch(e){D8(e,t)}}get rotateStep(){return this._rotateStep}set rotateStep(t){this._rotateStep=Number(t)||mrt}get rotateStepForced(){return this._rotateStepForced}set rotateStepForced(t){this._rotateStepForced=!!t}get dataStorage(){return this._dataStorage}set dataStorage(t){this._dataStorage=t}}j8(brt.prototype,P8.withEvent);class xrt{constructor(t,e){!(t=Number(t))||t<=0?(L8("TimeCapsule maxsize should be greater than 0.",t),this.maxsize=10):this.maxsize=t,this.reset(),e&&(this.snapshot(e),this.preserve())}preserve(){this.checkPoint=this.pos}hasUnpreservedChanges(){return this.checkPoint!=this.pos}dispose(){this.reset()}snapshot(t){if(this.q.splice(this.pos+1,this.q.length-(this.pos+1),t),this.q.length>this.maxsize){const t=this.q.splice(0,this.q.length-this.maxsize);this.checkPoint=Math.max(-1,this.checkPoint-t.length)}this.pos=this.q.length-1}forward(){if(this.snapshot_taker&&this.snapshot_taker.take(),this.forwardable)return this.q[++this.pos];D8("Not forwardable.")}backward(){if(this.snapshot_taker&&this.snapshot_taker.take(),this.backwardable)return this.q[--this.pos];D8("Not backwardable.")}get current(){if(-1!==this.pos)return this.q[this.pos];D8("Non state has been recorded.")}get length(){return this.q.length}get forwardable(){return this.pos<this.q.length-1}get backwardable(){return this.pos>0}get snapshot_taker(){return this._snapshot_taker}set snapshot_taker(t){this._snapshot_taker=t}reset(){this.q=[],this.pos=-1,this.checkPoint=-1}}var wrt=f8((t=>{t.brake||t.take()}),1e3,{leading:!0,trailing:!1});function Art(t){!t.brake&&t.dirty&&wrt(t)}class _rt{constructor(t,e){this.brake=!1,this.dirty=!1,this.state_holder=t,this.timecapsule=e,this.timecapsule.snapshot_taker=this}dispose(){delete this.state_holder,delete this.timecapsule}touch(){this.dirty=!0,Art(this)}take(t){(this.dirty||t)&&(this.timecapsule.snapshot(this.state_holder.state),this.dirty=!1)}get brake(){return this._brake}set brake(t){this._brake=!!t,Art(this)}}function krt(t,e){var r=e.model_layer.get("scale"),n=e.model_layer.get("translate");if(t){let i=JSON.parse(t);i.scale=r,i.translate=n,e.rebuildContentModel(i)}}class Ert{constructor(t){this.container=t,this.timecapsule=new xrt(20);var e=this;this.snapshot_taker=new _rt({get state(){let t=e.container.model_layer.hierarchy;return JSON.stringify(t)}},this.timecapsule),this.snapshot_taker.take(!0),this.timecapsule.preserve()}dispose(){this.reset(),this.timecapsule&&this.timecapsule.dispose(),this.snapshot_taker&&this.snapshot_taker.dispose(),delete this.container,delete this.timecapsule,delete this.snapshot_taker}preserve(){this.timecapsule.preserve()}hasUnpreservedChanges(){return this.timecapsule.hasUnpreservedChanges()}execute(t,e){!1!==e&&t&&t.execute(),this.snapshot_taker.touch(),this.trigger("execute",t,!0,!1)}undo(){this.timecapsule.backwardable&&(krt(this.timecapsule.backward(),this.container),this.trigger("undo",this.undoable(),this.redoable()))}redo(){this.timecapsule.forwardable&&(krt(this.timecapsule.forward(),this.container),this.trigger("redo",this.undoable(),this.redoable()))}undoable(){return this.timecapsule.backwardable}redoable(){return this.timecapsule.forwardable}reset(){this.timecapsule&&this.timecapsule.reset(),this.trigger("command-reset")}}j8(Ert.prototype,P8.withEvent);var Srt=0;const Mrt=new FinalizationRegistry((t=>{Srt--}));class Trt{static get residents(){return Srt}static get residentsCount(){return Srt}constructor(t){this._container=t,this.app=t.app,this._commander=new Ert(this._container),this.app.commander=this._commander,Srt++,Mrt.register(this,Srt)}add(){return Mtt.apply(this._container,arguments)}duplicate(){return Ttt.apply(this._container,arguments)}remove(){return Ptt.apply(this._container,arguments)}animate(){return t6.apply(this,arguments)}fullscreen(){return Rtt.apply(this._container,arguments)}get target(){return this._container.target_element}set target(t){var e;if("string"==typeof t){if(!(e=document.getElementById(t)))throw`target element '${t}' is not exist`;if(e.firstChild)throw`target element '${t}' already has children`}else e=t;e&&e.style&&(e.style.cursor="default"),this._container.target_element=e,this._container.invalidate()}get scale(){return this.root.get("scale")}set scale(t){this.root.set("scale",t)}get translate(){return this.root.get("translate")}set translate(t){this.root.set("translate",t)}get unit(){return this.root.get("unit")||"px"}get PPM(){return this.app.PPM}get PPI(){return this.app.PPI}get DPPX(){return this.app.DPPX}static get DPPX(){return V8}get unitScale(){return this._container.unitScale}get screen(){return this.app.screen}set screen(t){this.app.screen=t,this._container.resize()}resize(){this._container.resize()}release(){this.dispose()}dispose(){this._commander&&this._commander.dispose(),this._container&&this._container.dispose()}get selected(){return this._container.selected.slice()}set selected(t){this._container.selected=t}select(t,...e){return this._container.selected=this.root?.findAll(t,...e),this.selected}get commander(){return this._commander}undo(){this.commander.undo()}undoable(){return this.commander.undoable()}redo(){this.commander.redo()}redoable(){return this.commander.redoable()}preserve(){this.commander.preserve()}hasUnpreservedChanges(){return this.commander.hasUnpreservedChanges()}cut(){return Dtt.apply(this._container,arguments)}copy(){return Ltt.apply(this._container,arguments)}paste(){return ztt.apply(this._container,arguments)}undoableChange(){return ret.apply(this._container,arguments)}change(){return eet.apply(this.root,arguments)}get model(){return this.root.hierarchy}set model(t){this._container.rebuildContentModel(t)}get rootContainer(){return this._container}get root(){return this._container?.model_layer}findAll(){return this.root.findAll.apply(this.root,arguments)}findFirst(){return this.root.findFirst.apply(this.root,arguments)}findById(){return this._container.findById.apply(this._container,arguments)}serialize(){return this.root.trim(),this.root.serialize.apply(this.root,arguments)}align(){return vtt.apply(this._container,arguments)}place(){return fet.apply(this._container,arguments)}distribute(){return btt.apply(this._container,arguments)}move(){return Att.apply(this._container,arguments)}zorder(){return _tt.apply(this._container,arguments)}symmetryX(){return $tt.apply(this._container,arguments)}symmetryY(){return tet.apply(this._container,arguments)}on(){return Ott.apply(this._container,arguments)}once(){return Itt.apply(this._container,arguments)}off(){return this._container&&Ctt.apply(this._container,arguments)}centerTo(t,e){return this.root.centerTo(t,e)}get mode(){return this.app.mode}set mode(t){void 0!==t&&(this.app.mode=t)}toDataURL(){return Vtt.apply(this._container,arguments)}group(){return Qtt.apply(this._container,arguments)}ungroup(){return Ktt.apply(this._container,arguments)}fit(t){this._container.once("redraw",(()=>this._container.fit(t))),this._container.invalidate()}get fitMode(){return this._container.fitMode}get ids(){return net.apply(this._container)}get data(){return this._container.data}set data(t){this._container.data=t}get dataByRefid(){return this._container.dataByRefid}set dataByRefid(t){this._container.dataByRefid=t}get values(){return this._container.values}set values(t){this._container.values=t}get valuesByRefid(){return this._container.valuesByRefid}set valuesByRefid(t){this._container.valuesByRefid=t}get baseUrl(){return this.app.baseUrl}set baseUrl(t){this.app.baseUrl=t}startAddMode(){return det.apply(this._container,arguments)}startStylePasteMode(){return pet.apply(this._container,arguments)}stopStylePasteMode(){return get.apply(this._container,arguments)}startDatabindPasteMode(){return vet.apply(this._container,arguments)}stopDatabindPasteMode(){return yet.apply(this._container,arguments)}}const Prt=new class{load(t){}save(t,e){}clear(t){}};function Ort({target:t,model:e,style:r,layers:n=[],handlers:i=[],mode:a=0,refProvider:o,dataSubscriptionProvider:s,dataStorage:c=Prt,baseUrl:u,fitMode:l}){var h=null;if("string"==typeof t){if(!(h=document.getElementById(t)))throw`target element '${t}' is not exist`;if(h.firstChild)throw`target element '${t}' is not empty`}else h=t;h&&h.style&&(h.style.position="absolute",h.style.cursor="default",h.style.overflow="hidden");var f=new brt(a,o);return f.baseUrl=u,f.dataSubscriptionProvider=s,f.dataStorage=c,new Trt(new prt({target_element:h,model:e,style:r,layers:n,handlers:i,fitMode:l},f))}const Irt=["mousemove","mouseup","mousedown","mouseout","wheel","tap","click","touchstart","touchmove","touchend","mouseenter","mouseleave","dragstart","dragmove","dragend","dblclick"];var Crt=t=>class extends t{isHTMLElement(){return!0}isShadowable(){return!0}get element(){return this._element}set element(t){this._element=t}get tagName(){return this.get("type")}setElementProperties(t){throw new Error("Not Implemented Yet")}createElement(){this.element=document.createElement(this.tagName),this.element&&(this.parent.isHTMLElement()?this.parent.element.appendChild(this.element):this.root.model_layer.overlay.appendChild(this.element),Irt.forEach((t=>{this.element.addEventListener(t,this.userInputEventHandler.bind(this))})),K8.forEach((t=>{this.element.addEventListener(t,this.userInputEventHandler.bind(this))})),this.oncreate_element&&this.oncreate_element(this.element))}userInputEventHandler(t){Jet(this,t.type,t),t.stopPropagation()}reposition(){this.element&&G7(this)}disposeElement(){var t=this.element;t&&t.parentElement&&t.parentElement.removeChild(t),delete this.element}ready(){super.ready(),!this.element&&this.createElement(),this.parent.isHTMLElement()?this.parent.element.appendChild(this.element):this.root.model_layer.overlay.appendChild(this.element),this.setElementProperties(this.element),this.reposition()}dispose(){this.disposeElement(this),super.dispose()}get hasTextProperty(){return!0}get textHidden(){return!0}onchange(t,e){this.element&&this.setElementProperties(this.element),this.reposition()}isDescendible(t){return t.isHTMLElement()}};const Rrt={x:1,y:1},jrt={boxSizing:"border-box",margin:"0px",position:"absolute",outline:"none"},Lrt={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"layout",label:"layout",name:"layoutOption"}],help:"scene/component/container"};class Drt extends(Crt(z9)){get tagName(){return"div"}get nature(){return Lrt}setElementProperties(t){}get layout(){return b9.get(this.get("layout"))||x9}reposition(){if(this.element){var t=this,{id:e,class:r,scale:n=Rrt}=t.state,{rotation:i=0,hidden:a}=t,{left:o,top:s,width:c,height:u}=t.bounds,l=c/2,h=u/2,f=t.element;f.hidden=a,e&&(f.id=e),r&&(f.className=r),Object.assign(f.style,jrt,{left:o+"px",top:s+"px",width:"0px",height:"0px",backgroundColor:"transparent"});var d=t.delta(),p=(n&&n.x||1)*d.sx,g=(n&&n.y||1)*d.sy,v=(i||0)+d.theta,y=d.tx||0,m=d.ty||0;["-webkit-","-moz-","-ms-","-o-",""].forEach((t=>{f.style[t+"transform"]=`translate(${y+l}px, ${m+h}px) rotate(${v}rad) translate(${-l}px, ${-h}px) scale(${p}, ${g}) perspective(1px)`}))}}}l9.register("container",Drt);const zrt=5,Frt=Math.sqrt(3),Nrt=2;function Brt(t,e,r,n,i){var a,o,s,c,u=zrt+i,l=r.x,h=r.y,f=n.x,d=n.y;if(Math.abs(l-f)>u&&Math.abs(h-d)>u){var p=(d-h)/(f-l),g=h-p*l;if(Math.abs(e-(p*t+g))>u)return!1}return l>f?(o=l,a=f):(o=f,a=l),h>d?(c=h,s=d):(c=d,s=h),!(o+zrt<t)&&(!(a-zrt>t)&&(!(c+zrt<e)&&!(s-zrt>e)))}function Urt(t,e,r,n=2){for(let i=0;i<r.length-1;i++)if(Brt(t,e,r[i],r[i+1],n))return!0;return!1}function Yrt(t,e,r,n){if("arrow"!=t.slice(-5))return r;var i=Math.atan2(n.y-r.y,n.x-r.x),a=1.5*e;return{x:r.x+Math.cos(i)*a,y:r.y+Math.sin(i)*a}}function Grt(t,e,r){var{lineWidth:n=Nrt,strokeStyle:i="#000000",lineCap:a=!1,alpha:o=1,begin:s="none",end:c="none",beginSize:u="size5",endSize:l="size5"}=r;if(("none"!=s||"none"!=c)&&(n=Number(n)||Nrt,t.lineCap=a,t.lineWidth=n,t.strokeStyle=i,t.fillStyle=i,t.globalAlpha*=o,"none"!=s&&Wrt(t,e[0],e[1],n,s,Hrt(u,n)),"none"!=c)){let r=e.length;Wrt(t,e[r-1],e[r-2],n,c,Hrt(l,n))}}function Wrt(t,e,r,n,i,a){var{x:o,y:s}=e,c=Math.atan2(r.y-s,r.x-o);switch(t.beginPath(),t.translate(o,s),t.rotate(c),i){case"oval":t.ellipse(0,0,a.X,a.Y,0,0,2*Math.PI),t.fill();break;case"diamond":t.moveTo(-a.X,0),t.lineTo(0,-a.Y),t.lineTo(a.X,0),t.lineTo(0,a.Y),t.fill();break;case"arrow":t.moveTo(0,0),t.lineTo(Frt*a.X,-a.Y),t.lineTo(Frt*a.X,a.Y),t.fill();break;case"sharp-arrow":t.moveTo(0,0),t.lineTo(Frt*a.X,-a.Y),t.lineTo(-a.X/1.5+Frt*a.X,0),t.lineTo(Frt*a.X,a.Y),t.fill();break;case"open-arrow":t.moveTo(Frt*a.X+n,-a.Y),t.lineTo(n,0),t.lineTo(Frt*a.X+n,a.Y),t.stroke()}t.rotate(-c),t.translate(-o,-s),t.closePath()}function Hrt(t,e){let r={};switch(e*=1.2,t){case"size1":r.X=e,r.Y=e;break;case"size2":r.X=1.5*e,r.Y=e;break;case"size3":r.X=2*e,r.Y=e;break;case"size4":r.X=e,r.Y=1.5*e;break;case"size5":default:r.X=1.5*e,r.Y=1.5*e;break;case"size6":r.X=2*e,r.Y=1.5*e;break;case"size7":r.X=e,r.Y=2*e;break;case"size8":r.X=1.5*e,r.Y=2*e;break;case"size9":r.X=2*e,r.Y=2*e}return r}const qrt="N",Xrt="S",Vrt="E",Qrt="W";class Krt{constructor({component:t,anchor:e,position:r,self:n}){this.component=t,this._anchorName=e,this._position=r,this.self=n}get position(){const t=this.anchor;if(t){var{position:e}=t;const r=this.component.transcoordS2T(e.x,e.y);return this.self.transcoordT2P(r.x,r.y)}return this._position}set position({x:t,y:e}){this._position={x:t,y:e}}get anchor(){return this.component?.findAnchor(this._anchorName)}get direction(){const t=this.component.bounds,e=this.anchor;if(!e)return Vrt;const r=e.position;return r.y<=t.top?qrt:r.y>=t.top+t.height?Xrt:r.x<=t.left?Qrt:Vrt}get boundaryPosition(){const t=this.anchor;if(t){var{position:e}=t,r=0,n=0;switch(this.direction){case Xrt:n=20;break;case qrt:n=-20;break;case Qrt:r=-20;break;default:r=20}e={x:e.x+r,y:e.y+n};const i=this.component.transcoordS2T(e.x,e.y);return this.self.transcoordT2P(i.x,i.y)}}}class Jrt extends l9{isLine(){return!0}replaceRefids(t){["from","to"].forEach((e=>{const r=this.get(e);if(r?.component){const n=t.get(r.component)||r.component;this.set(e,{...r,component:n})}}))}get fromEnd(){if(this.parent&&!this._fromEnd){const{component:t,anchor:e,position:r}=this.getState("from")||{};if(!t)return;const n=this.root?.findByRefid(t);if(!n)return;this._fromEnd=new Krt({component:n,fromto:"from",anchor:e,position:r,self:this})}return this._fromEnd}get from(){return this.getState("from")}set from(t){delete this._fromEnd,this.set("from",t)}get toEnd(){if(this.parent&&!this._toEnd){const{component:t,anchor:e,position:r}=this.getState("to")||{};if(!t)return;const n=this.root?.findByRefid(t);if(!n)return;this._toEnd=new Krt({component:n,fromto:"to",anchor:e,position:r,self:this})}return this._toEnd}get to(){return this.getState("to")}set to(t){delete this._toEnd,this.set("to",t)}move({x:t,y:e},r){r&&(this.from={position:this._fromEnd?.position||this.getState("from")?.position||{x:0,y:0}},this.to={position:this._toEnd?.position||this.getState("to")?.position||{x:0,y:0}}),super.move({x:t,y:e},r)}render(t){var{begin:e="none",end:r="none",lineWidth:n,round:i=0}=this.state,a=this.drawPath;Grt(t,a,this.state),t.beginPath();var o=Yrt(e,n,a[0],a[1]),s=Yrt(r,n,a[a.length-1],a[a.length-2]);a=[o,...a.slice(1,-1),s];var c={x:o.x,y:o.y};t.moveTo(o.x,o.y);for(var u=1;u<a.length;u++){const e=c;c=a[u];const r=a[u+1];if(e.x===c.x&&e.y===c.y)continue;if(!r){t.lineTo(c.x,c.y);break}var l=0!==(d=Math.sqrt((e.x-c.x)*(e.x-c.x)+(e.y-c.y)*(e.y-c.y)))?Math.atan2(e.x-c.x,e.y-c.y):0,h=Math.sin(l)*Math.min(i,d/2)+c.x,f=Math.cos(l)*Math.min(i,d/2)+c.y;const n=i>0||0!==d?{x:h,y:f}:c;var d;l=0!==(d=Math.sqrt((r.x-c.x)*(r.x-c.x)+(r.y-c.y)*(r.y-c.y)))?Math.atan2(r.x-c.x,r.y-c.y):0,h=Math.sin(l)*Math.min(i,d/2)+c.x,f=Math.cos(l)*Math.min(i,d/2)+c.y;const o=i>0||0!==d?{x:h,y:f}:c;t.lineTo(n.x,n.y),i>0&&t.quadraticCurveTo(c.x,c.y,o.x,o.y)}this.drawStroke(t)}contains(t,e){var{lineWidth:r}=this.state;return Urt(t,e,this.drawPath,r)}get resizable(){return!1}get mutable(){return!0}get rotatable(){return!1}get path(){const{from:t,to:e}=this.state;var{x1:r,y1:n,x2:i,y2:a}=this.state;return[this.fromEnd?.position||t?.position||{x:r,y:n},this.toEnd?.position||e?.position||{x:i,y:a}]}set path(t){const[e,r]=t,{from:n,to:i}=this.state;delete this._fromEnd,delete this._toEnd,this.set({from:{...n,position:e},to:{...i,position:r}})}get textBounds(){var t,e,r=this.drawPath,n=0;for(let s=1;s<r.length;s++){var i=r[s-1],a=r[s],o=(i.x-a.x)*(i.x-a.x)+(i.y-a.y)*(i.y-a.y);o>n&&(n=Math.ceil(o),t=i,e=a)}var{paddingTop:s,paddingLeft:c,paddingRight:u,paddingBottom:l}=this.state;return l||=0,s||=0,c||=0,u||=0,{left:Math.min(t.x,e.x)+c,top:Math.min(t.y,e.y)+s,width:Math.max(Math.abs(t.x-e.x)-c-u,0),height:Math.max(Math.abs(t.y-e.y)-s-l,0)}}get decorators(){return["decotag"]}}Jrt.getTipNeckPos=Yrt,Jrt.containedInPath=Urt,Jrt.drawEndTips=Grt,l9.register("line",Jrt);const Zrt={mutable:!1,resizable:!0,rotatable:!0,properties:[],"value-property":"text"};class $rt extends(W9(h9)){is3dish(){return!0}render(t){var{cx:e,cy:r,rx:n,ry:i,startAngle:a,endAngle:o,anticlockwise:s}=this.state;t.beginPath(),t.ellipse(e,r,Math.abs(n),Math.abs(i),0,a||0,o||2*Math.PI,s)}get path(){var{cx:t,cy:e,rx:r,ry:n}=this.state;return[{x:t-r,y:e-n},{x:t+r,y:e-n},{x:t+r,y:e+n},{x:t-r,y:e+n}]}set path(t){var e=t[0],r=t[2];this.set({cx:e.x+(r.x-e.x)/2,cy:e.y+(r.y-e.y)/2,rx:(r.x-e.x)/2,ry:(r.y-e.y)/2})}contains(t,e){var{cx:r,cy:n,rx:i,ry:a}=this.state,o=(t-r)/(2*i-.5),s=(e-n)/(2*a-.5);return o*o+s*s<.25}outline(t){return function(t,e){var{cx:r,cy:n,rx:i,ry:a}=t.model,o=2*Math.PI*e,s=r+i*Math.cos(o),c=n+a*Math.sin(o);return t.transcoordS2T(s,c)}(this,t)}get anchors(){return function(t){var{left:e,top:r,width:n,height:i}=t.bounds,a=e+n/2,o=r+i/2;return[{name:"TOP",position:{x:a,y:r}},{name:"RIGHT",position:{x:e+n,y:o}},{name:"BOTTOM",position:{x:a,y:r+i}},{name:"LEFT",position:{x:e,y:o}}]}(this)}get nature(){return Zrt}}l9.memoize($rt.prototype,"path",!1),l9.register("ellipse",$rt);var tnt={ondragstart:function(t,e,r){r.mutatePath(null,(function(r){r.splice(e+1,0,t)}))},ondragmove:function(t,e,r){r.mutatePath(null,(function(r){r[e+1]=t}))},ondragend:function(t,e,r){}};const ent={mutable:!0,resizable:!1,rotatable:!0,properties:[{type:"number",label:"round",name:"round",property:{min:0,max:100,step:1}}],help:"scene/component/polygon"};class rnt extends h9{is3dish(){return!0}get mutable(){return!0}get pathExtendable(){return!0}get path(){return this.state.path}set path(t){this.set("path",t)}contains(t,e){var r=this.state.path,n=!1;return r.forEach(((i,a)=>{let o=(a+r.length+1)%r.length,s=i.x,c=i.y,u=r[o].x,l=r[o].y;c>e!=l>e&&t<(u-s)*(e-c)/(l-c)+s&&(n=!n)})),n}get controls(){var t=this.path;return t.map(((e,r)=>{let n=t[r+1>=t.length?0:r+1];return{x:(e.x+n.x)/2,y:(e.y+n.y)/2,handler:tnt}}))}get nature(){return ent}}l9.memoize(rnt.prototype,"controls",!1),l9.register("polygon",rnt);var nnt={ondragstart:function(t,e,r){r.mutatePath(null,(function(r){r.splice(e,0,t)}))},ondragmove:function(t,e,r){r.mutatePath(null,(function(r){r[e]=t}))},ondragend:function(t,e,r){}};const int={mutable:!1,resizable:!1,rotatable:!1,properties:[{type:"number",label:"round",name:"round",property:{min:0,max:100,step:1}}],help:"scene/component/polyline"};class ant extends Jrt{get pathExtendable(){return!0}get path(){const{from:t,to:e}=this.state,{path:r}=this.state;return[this.fromEnd?.position||t?.position||r[0],...r.slice(1,-1),this.toEnd?.position||e?.position||r[r.length-1]]}set path(t){const{from:e,to:r}=this.state;delete this._fromEnd,delete this._toEnd,this.set({from:{...e,position:t[0]},to:{...r,position:t[t.length-1]},path:t})}get controls(){var t=this.path,e=[];for(let r=0;r<t.length-1;r++){let n=t[r],i=t[r+1];0==r&&e.push({x:n.x,y:n.y,handler:nnt}),e.push({x:(n.x+i.x)/2,y:(n.y+i.y)/2,handler:nnt}),r==t.length-2&&e.push({x:i.x,y:i.y,handler:nnt})}return e}get nature(){return int}}l9.register("polyline",ant);const ont={mutable:!1,resizable:!1,rotatable:!1,properties:[{type:"number",label:"round",name:"round",property:{min:0,max:100,step:1}}],help:"scene/component/ortholine"};class snt extends Jrt{get pathExtendable(){return!1}get drawPath(){const t=this.path[0],e=this.path[1],{component:r,direction:n,boundaryPosition:i=t}=this.fromEnd||{},{component:a,direction:o,boundaryPosition:s=e}=this.toEnd||{};var c=[i,s],u=[];i&&u.push(i);var l=r?.bounds;if(l){var h=r.transcoordS2T(l.left,l.top);h=this.transcoordT2P(h.x,h.y),l={...l,left:h.x,top:h.y}}var f=l?{left:l.left-20,top:l.top-20,width:l.width+40,height:l.height+40}:{left:i.x,top:i.y,width:0,height:0};l=l||f;var d=a?.bounds;if(d){h=a.transcoordS2T(d.left,d.top);h=this.transcoordT2P(h.x,h.y),d={...d,left:h.x,top:h.y}}var p=d?{left:d.left-20,top:d.top-20,width:d.width+40,height:d.height+40}:{left:s.x,top:s.y,width:0,height:0};d=d||p;var g=[f,p];const v=f.left>p.left?p.left:f.left,y=f.top>p.top?p.top:f.top;var m,b,x,w,A,_,k,E,S,M,T={left:v,top:y,width:f.left+f.width>p.left+p.width?f.left+f.width-v:p.left+p.width-v,height:f.top+f.height>p.top+p.height?f.top+f.height-y:p.top+p.height-y},P=0,O=0;l.left+l.width<d.left?(w=0,A=1,S=n,M=o,m=(l.left+l.width+d.left)/2,P=d.left-m):d.left+d.width<l.left&&(w=1,A=0,S=o,M=n,m=(l.left+d.width+d.left)/2,P=l.left-m),l.top+l.height<d.top?(x=0,_=1,k=n,E=o,b=(l.top+l.height+d.top)/2,O=d.top-b):d.top+d.height<l.top&&(x=1,_=0,k=o,E=n,b=(l.top+d.height+d.top)/2,O=l.top-b);var I=[];if(m&&P>O){switch(M){case Qrt:switch(S){case Vrt:I.push({x:m,y:c[w].y}),I.push({x:m,y:c[A].y});break;case Qrt:var C=g[w].top+g[w].height/2>c[A].y?Math.min(g[w].top,c[A].y):Math.max(g[w].top+g[w].height,c[A].y);I.push({x:c[w].x,y:C}),I.push({x:m,y:C}),I.push({x:m,y:c[A].y});break;case qrt:case Xrt:C=S===Xrt?Math.max(c[w].y,c[A].y):Math.min(c[w].y,c[A].y);I.push({x:c[w].x,y:C}),I.push({x:m,y:C}),I.push({x:m,y:c[A].y});break;default:return this.path}break;case Vrt:switch(S){case Vrt:var R=C=c[w].y<c[A].y?Math.min(g[A].top,c[w].y):Math.max(g[A].top+g[A].height,c[w].y);break;case Qrt:R=C=void 0!==b?b:c[w].y<c[A].y?T.top-.5*P:T.top+T.height+.5*P;break;case Xrt:R=C=void 0!==b?Math.max(b,c[w].y):T.top+T.height;break;case qrt:R=C=b?Math.min(b,g[w].top):T.top;break;default:return this.path}I.push({x:c[w].x,y:C}),I.push({x:m,y:C}),I.push({x:m,y:R}),I.push({x:c[A].x,y:R});break;case Xrt:switch(S){case Vrt:C=c[w].y,R=c[w].y>c[A].y?c[w].y:g[A].top+g[A].height;break;case Qrt:R=C=b?Math.max(b,g[A].top+g[A].height):T.top+T.height;break;case Xrt:R=C=T.top+T.height;break;case qrt:C=b?Math.min(b,g[w].top):g[w].top,R=b?Math.max(b,g[A].top+g[A].height):g[A].top+g[A].height;break;default:return this.path}I.push({x:c[w].x,y:C}),I.push({x:m,y:C}),I.push({x:m,y:R}),I.push({x:c[A].x,y:R});break;case qrt:switch(S){case Vrt:C=c[w].y,R=c[w].y<c[A].y?c[w].y:g[A].top;break;case Qrt:R=C=b?Math.min(b,g[A].top):T.top;break;case Xrt:C=void 0!==b?Math.max(b,c[w].y):c[w].y,R=void 0!==b?Math.min(b,c[A].y):c[A].y;break;case qrt:R=C=T.top;break;default:return this.path}I.push({x:c[w].x,y:C}),I.push({x:m,y:C}),I.push({x:m,y:R}),I.push({x:c[A].x,y:R});break;default:return this.path}u.push(...0===w?I:I.reverse())}else if(b){switch(E){case qrt:switch(k){case Xrt:I.push({x:c[x].x,y:b}),I.push({x:c[_].x,y:b});break;case qrt:var j=g[x].left+g[x].width/2>c[_].x?Math.min(g[x].left,c[_].x):Math.max(g[x].left+g[x].width,c[_].x);I.push({x:j,y:c[x].y}),I.push({x:j,y:b}),I.push({x:c[_].x,y:b});break;case Qrt:j=Math.min(c[x].x,c[_].x);I.push({x:j,y:c[x].y}),I.push({x:j,y:b}),I.push({x:c[_].x,y:b});break;case Vrt:j=Math.max(c[x].x,c[_].x);I.push({x:j,y:c[x].y}),I.push({x:j,y:b}),I.push({x:c[_].x,y:b});break;default:return this.path}break;case Xrt:switch(k){case Qrt:var L=j=T.left;break;case Vrt:L=j=void 0!==m?Math.max(m,c[x].x):T.left+T.width;break;case qrt:L=j=void 0!==m?m:c[x].x<c[_].x?T.left-.5*O:T.left+T.width+.5*O;break;case Xrt:j=c[x].x,L=c[x].x<c[_].x?Math.min(g[_].left,c[x].x):Math.max(g[_].left+g[_].width,c[x].x);break;default:return this.path}I.push({x:j,y:c[x].y}),I.push({x:j,y:b}),I.push({x:L,y:b}),I.push({x:L,y:c[_].y});break;case Vrt:switch(k){case Qrt:j=void 0!==m?Math.min(m,c[x].x):c[x].x,L=void 0!==m?Math.max(m,c[_].x):c[_].x;break;case Vrt:L=j=T.left+T.width;break;case qrt:L=j=void 0!==m?Math.max(m,c[_].x):T.left+T.width;break;case Xrt:j=c[x].x,L=Math.max(g[_].left+g[_].width,c[x].x);break;default:return this.path}I.push({x:j,y:c[x].y}),I.push({x:j,y:b}),I.push({x:L,y:b}),I.push({x:L,y:c[_].y});break;case Qrt:switch(k){case Qrt:L=j=T.left;break;case Vrt:j=void 0!==m?Math.max(m,c[x].x):c[x].x,L=void 0!==m?Math.min(m,c[_].x):c[_].x;break;case qrt:L=j=T.left;break;case Xrt:j=c[x].x<c[_].x?Math.min(g[_].left,c[x].x):c[x].x,L=Math.min(j,c[_].x);break;default:return this.path}I.push({x:j,y:c[x].y}),I.push({x:j,y:b}),I.push({x:L,y:b}),I.push({x:L,y:c[_].y});break;default:return this.path}u.push(...0===x?I:I.reverse())}else switch(n){case qrt:switch(o){case qrt:var D=T.top;u.push({x:c[0].x,y:D}),u.push({x:c[1].x,y:D});break;case Xrt:var z=T.left+T.width;u.push({x:z,y:c[0].y}),u.push({x:z,y:T.top+T.height}),u.push({x:c[1].x,y:T.top+T.height});break;case Vrt:z=c[1].y<c[0].y&&c[1].x<c[0].x?c[0].x:T.left+T.width;u.push({x:z,y:c[0].y}),u.push({x:z,y:c[1].y});break;case Qrt:z=T.left;u.push({x:z,y:c[0].y}),u.push({x:z,y:c[1].y});break;default:return this.path}break;case Xrt:switch(o){case qrt:z=T.left+T.width;u.push({x:z,y:c[0].y}),u.push({x:z,y:T.top}),u.push({x:c[1].x,y:T.top});break;case Xrt:D=T.top+T.height;u.push({x:c[0].x,y:D}),u.push({x:c[1].x,y:D});break;case Vrt:D=T.top+T.height;u.push({x:c[0].x,y:D}),u.push({x:c[1].x,y:D});break;case Qrt:D=T.top+T.height;u.push({x:c[0].x,y:D}),u.push({x:c[1].x,y:D});break;default:return this.path}break;case Qrt:switch(o){case qrt:z=c[0].x>c[1].x&&c[0].y<c[1].y?c[1].x:T.left,D=c[0].x>c[1].x&&c[0].y<c[1].y?c[1].y:Math.min(T.top,c[0].y);u.push({x:z,y:c[0].y}),u.push({x:z,y:D}),u.push({x:c[1].x,y:D});break;case Xrt:z=T.left,D=Math.max(T.top+T.height,c[0].y);u.push({x:z,y:c[0].y}),u.push({x:z,y:D}),u.push({x:c[1].x,y:D});break;case Vrt:z=T.left+T.width;u.push({x:c[0].x,y:T.top}),u.push({x:z,y:T.top}),u.push({x:z,y:c[1].y});break;case Qrt:z=T.left;u.push({x:z,y:c[0].y}),u.push({x:z,y:c[1].y});break;default:return this.path}break;case Vrt:switch(o){case qrt:D=c[0].y<c[1].y&&c[0].x<c[1].x?c[0].y:T.top;u.push({x:c[0].x,y:D}),u.push({x:c[1].x,y:D});break;case Xrt:D=c[0].y>c[1].y&&c[0].x<c[1].x?c[0].y:T.top+T.height;u.push({x:c[0].x,y:D}),u.push({x:c[1].x,y:D});break;case Vrt:D=T.top+T.height;u.push({x:c[0].x,y:D}),u.push({x:c[1].x,y:D});break;case Qrt:D=T.top+T.height;u.push({x:c[0].x,y:D}),u.push({x:c[1].x,y:D});break;default:return this.path}break;default:return this.path}return s&&u.push(s),[t,...u,e].filter(((t,e,r)=>{if(0===e)return!0;const n=r[e-1];return t.x!==n.x||t.y!==n.y})).filter(((t,e,r)=>{if(0===e||e>=r.length-1)return!0;const n=r[e-1],i=r[e+1];return!(t.x===n.x&&t.x===i.x||t.y===n.y&&t.y===i.y)}))}get nature(){return ont}}l9.register("ortholine",snt);const cnt={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"image-selector",label:"image-src",name:"src",property:{displayField:"id",displayFullUrl:!0,baseUrlAlias:"$base_url",defaultStorage:"scene-image",storageFilters:{type:Array,value:[{name:"category",value:"image"}]},useUpload:!0}},{type:"select",label:"cross-origin",name:"crossOrigin",property:{options:["","anonymous","use-credentials"]}}],"value-property":"src",help:"scene/component/image-view"};class unt extends(d9(h9)){static get noimage(){return unt.NOIMAGE||(unt.NOIMAGE=new Image,unt.NOIMAGE.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAABIBAMAAAD7Se1QAAAAIVBMVEUAAABHcEwBAQEREREBAQEEBAQGBgYLCwsDAwMDAwMICAi6HF9tAAAAC3RSTlNNAEAERiMYCS41Eac10lYAAAEgSURBVHhe7dY9asQwEAXgh7DNertNiJy48pIitY3SB7bYdk0ukL1BDDmA9gZecoH4pmFQ3MQayUMguPBrNPD4wD9TCMvJmt3M/AtYwXOlXiWgqADVCUBD46MAnGhMBaCiUQmAm8VA/Eh/eWl9Fn5WcxD+OLuRrUYJDKLluwH2InACUgkoACSdADxQc50Bytadb9RkM0CT13TcvlCT1HFg8UTHvasuUVACCa3El6u2UdD8LFTlKhUFFgA+d3dj10aABkUN72N3jAADCrJq7PIIsPidcxBoTHIIAjMFmyCwmGYIAA1P9gFgfCANAOsDSccCDW+uLDB+kLGg94OkZoAGkwsDDAe2DOg5oPxAg03rBR88OHpBz4N8UVeHFSwma74BTW6Ge4rIRa4AAAAASUVORK5CYII="),unt.NOIMAGE}dispose(){super.dispose(),this._offcanvas=null,this._image=null}render(t){var{left:e,top:r,width:n,height:i,isGray:a=!1,alpha:o=1,src:s}=this.state;if(this.prepareIf(!this._image&&s),t.beginPath(),t.globalAlpha*=o,this._image&&this._image.complete)if(a&&this._offcanvas)t.drawImage(this._offcanvas,e,r,n,i);else try{t.drawImage(this._image,e,r,n,i)}catch(a){t.drawImage(unt.noimage,e,r,n,i)}else!this.app.isViewMode&&t.drawImage(unt.noimage,e,r,n,i)}get nature(){return cnt}get hasTextProperty(){return!1}ready(){super.ready(),this.prepareIf(!this._image&&this.state.src)}prepare(t,e){var{src:r,crossOrigin:n}=this.state;if(r){this._image=new Image;try{n&&(this._image.crossOrigin=n),this._image.src=this.app.url(r)||""}catch(t){return void e(t)}this._image.onload=()=>{if(this.get("isGray")){let t=this._image.width,e=this._image.height;this._offcanvas=l9.createCanvas(t,e);let r=this._offcanvas.getContext("2d");r.drawImage(this._image,0,0);let n=function(t,e,r){try{var n=t.getImageData(0,0,e,r)}catch(t){return L8("Get Image Data Error: "+t.message),null}var i=n.data;for(let t=0;t<e*r*4;t+=4){let e=i[t],r=i[t+1],a=i[t+2],o=parseInt((e+r+a)/3);n.data[t]=o,n.data[t+1]=o,n.data[t+2]=o}return n}(r,t,e);r.putImageData(n,0,0)}t(this)},this._image.onerror=t=>{this._image&&!this._image.currentSrc&&(this._image=null),e(t)}}else t(this)}get src(){return this.get("src")}set src(t){this.set("src",t)}onchange(t,e){(t.hasOwnProperty("src")||t.hasOwnProperty("isGray"))&&(this._offcanvas=null,this._image=null,this.prepareIf(t.src))}ondropfile(t,e){for(let r=0;r<t.length;r++)if(t[r].type.startsWith("image/"))return void(this.src=e[r])}}l9.register("image-view",unt);class lnt extends(Crt(d9(l9))){}var hnt={},fnt={},dnt={};Object.defineProperty(dnt,"__esModule",{value:!0});var pnt=function(){function t(){}return t.bitsToNum=function(t){return t.reduce((function(t,e){return 2*t+e}),0)},t.byteToBitArr=function(t){for(var e=[],r=7;r>=0;r--)e.push(!!(t&1<<r));return e},t.lzwDecode=function(t,e){for(var r,n,i=0,a=function(t){for(var r=0,n=0;n<t;n++)e.charCodeAt(i>>3)&1<<(7&i)&&(r|=1<<n),i++;return r},o=[],s=1<<t,c=s+1,u=t+1,l=[],h=function(){l=[],u=t+1;for(var e=0;e<s;e++)l[e]=[e];l[s]=[],l[c]=null};;)if(n=r,(r=a(u))!==s){if(r===c)break;if(r<l.length)n!==s&&l.push(l[n].concat(l[r][0]));else{if(r!==l.length)throw new Error("Invalid LZW code.");l.push(l[n].concat(l[n][0]))}o.push.apply(o,l[r]),l.length===1<<u&&u<12&&u++}else h();return o},t}();dnt.SuperGifUtils=pnt,Object.defineProperty(fnt,"__esModule",{value:!0});var gnt=dnt,vnt=function(){function t(t,e){this.stream=t,this.handler=e}return t.prototype.parseCT=function(t){for(var e=[],r=0;r<t;r++)e.push(this.stream.readBytes(3));return e},t.prototype.readSubBlocks=function(){var t,e;e="";do{t=this.stream.readByte(),e+=this.stream.read(t)}while(0!==t);return e},t.prototype.parseHeader=function(){var t={};if(t.sig=this.stream.read(3),t.ver=this.stream.read(3),"GIF"!==t.sig)throw new Error("Not a GIF file.");t.width=this.stream.readUnsigned(),t.height=this.stream.readUnsigned();var e=gnt.SuperGifUtils.byteToBitArr(this.stream.readByte());t.gctFlag=e.shift(),t.colorRes=gnt.SuperGifUtils.bitsToNum(e.splice(0,3)),t.sorted=e.shift(),t.gctSize=gnt.SuperGifUtils.bitsToNum(e.splice(0,3)),t.bgColor=this.stream.readByte(),t.pixelAspectRatio=this.stream.readByte(),t.gctFlag&&(t.gct=this.parseCT(1<<t.gctSize+1)),this.handler.hdr&&this.handler.hdr(t)},t.prototype.parseExt=function(t){var e=this;switch(t.label=this.stream.readByte(),t.label){case 249:t.extType="gce",function(t){e.stream.readByte();var r=gnt.SuperGifUtils.byteToBitArr(e.stream.readByte());t.reserved=r.splice(0,3),t.disposalMethod=gnt.SuperGifUtils.bitsToNum(r.splice(0,3)),t.userInput=r.shift(),t.transparencyGiven=r.shift(),t.delayTime=e.stream.readUnsigned(),t.transparencyIndex=e.stream.readByte(),t.terminator=e.stream.readByte(),e.handler.gce&&e.handler.gce(t)}(t);break;case 254:t.extType="com",function(t){t.comment=e.readSubBlocks(),e.handler.com&&e.handler.com(t)}(t);break;case 1:t.extType="pte",function(t){e.stream.readByte(),t.ptHeader=e.stream.readBytes(12),t.ptData=e.readSubBlocks(),e.handler.pte&&e.handler.pte(t)}(t);break;case 255:t.extType="app",function(t){e.stream.readByte(),t.identifier=e.stream.read(8),t.authCode=e.stream.read(3),"NETSCAPE"===t.identifier?function(t){e.stream.readByte(),t.unknown=e.stream.readByte(),t.iterations=e.stream.readUnsigned(),t.terminator=e.stream.readByte(),e.handler.app&&e.handler.app.NETSCAPE&&e.handler.app.NETSCAPE(t)}(t):function(t){t.appData=e.readSubBlocks(),e.handler.app&&e.handler.app[t.identifier]&&e.handler.app[t.identifier](t)}(t)}(t);break;default:t.extType="unknown",function(t){t.data=e.readSubBlocks(),e.handler.unknown&&e.handler.unknown(t)}(t)}},t.prototype.parseImg=function(t){t.leftPos=this.stream.readUnsigned(),t.topPos=this.stream.readUnsigned(),t.width=this.stream.readUnsigned(),t.height=this.stream.readUnsigned();var e=gnt.SuperGifUtils.byteToBitArr(this.stream.readByte());t.lctFlag=e.shift(),t.interlaced=e.shift(),t.sorted=e.shift(),t.reserved=e.splice(0,2),t.lctSize=gnt.SuperGifUtils.bitsToNum(e.splice(0,3)),t.lctFlag&&(t.lct=this.parseCT(1<<t.lctSize+1)),t.lzwMinCodeSize=this.stream.readByte();var r=this.readSubBlocks();t.pixels=gnt.SuperGifUtils.lzwDecode(t.lzwMinCodeSize,r),t.interlaced&&(t.pixels=function(t,e){for(var r=new Array(t.length),n=t.length/e,i=function(n,i){var a=t.slice(i*e,(i+1)*e);r.splice.apply(r,[n*e,e].concat(a))},a=[0,4,2,1],o=[8,8,4,2],s=0,c=0;c<4;c++)for(var u=a[c];u<n;u+=o[c])i(u,s),s++;return r}(t.pixels,t.width)),this.handler.img&&this.handler.img(t)},t.prototype.parseBlock=function(){var t={};switch(t.sentinel=this.stream.readByte(),String.fromCharCode(t.sentinel)){case"!":t.type="ext",this.parseExt(t);break;case",":t.type="img",this.parseImg(t);break;case";":t.type="eof",this.handler.eof&&this.handler.eof(t);break;default:throw new Error("Unknown block: 0x"+t.sentinel.toString(16))}"eof"!==t.type&&setTimeout(this.parseBlock.bind(this),0)},t.prototype.parse=function(){this.parseHeader(),setTimeout(this.parseBlock.bind(this),0)},t}();fnt.SuperGifParser=vnt;var ynt={};Object.defineProperty(ynt,"__esModule",{value:!0});var mnt=function(){function t(t){this.data=t,this.position=0}return t.prototype.readByte=function(){if(this.position>=this.data.length)throw new Error("Attempted to read past end of stream.");return this.data instanceof Uint8Array?this.data[this.position++]:255&this.data.charCodeAt(this.position++)},t.prototype.readBytes=function(t){for(var e=[],r=0;r<t;r++)e.push(this.readByte());return e},t.prototype.read=function(t){for(var e="",r=0;r<t;r++)e+=String.fromCharCode(this.readByte());return e},t.prototype.readUnsigned=function(){var t=this.readBytes(2);return(t[1]<<8)+t[0]},t}();ynt.SuperGifStream=mnt,Object.defineProperty(hnt,"__esModule",{value:!0});var bnt=fnt,xnt=ynt,wnt=function(){function t(t,e){var r=this;for(var n in this.gifImgElement=t,this.options={autoPlay:!0},this.loading=!1,this.ready=!1,this.transparency=null,this.delay=null,this.disposalMethod=null,this.disposalRestoreFromIdx=null,this.lastDisposalMethod=null,this.frame=null,this.lastImg=null,this.playing=!0,this.forward=!0,this.ctxScaled=!1,this.frames=[],this.frameOffsets=[],this.initialized=!1,this.currentFrameIndex=-1,this.iterationCount=0,this.stepping=!1,this.handler={hdr:this.withProgress(this.doHdr.bind(this)),gce:this.withProgress(this.doGCE.bind(this)),com:this.withProgress(this.doNothing.bind(this)),app:{NETSCAPE:this.withProgress(this.doNothing.bind(this))},img:this.withProgress(this.doImg.bind(this)),eof:function(){r.pushFrame(),r.canvas.width=r.hdr.width*r.getCanvasScale(),r.canvas.height=r.hdr.height*r.getCanvasScale(),r.playerInit(),r.loading=!1,r.ready=!0,r.loadCallback&&r.loadCallback(r.gifImgElement)}},e)this.options[n]=e[n];this.onEndListener=e.onEnd,this.loopDelay=e.loopDelay||0,this.overrideLoopMode=null!=e.loopMode?e.loopMode:"auto",this.drawWhileLoading=null==e.drawWhileLoading||e.drawWhileLoading}return t.prototype.init=function(){var t=this.gifImgElement.parentNode,e=document.createElement("div");this.canvas=document.createElement("canvas"),this.canvasContext=this.canvas.getContext("2d"),this.tmpCanvas=document.createElement("canvas"),e.className=this.options.enclosingClass||"super-gif",e.appendChild(this.canvas),t&&(t.insertBefore(e,this.gifImgElement),t.removeChild(this.gifImgElement)),this.initialized=!0},t.prototype.loadSetup=function(t){return!this.loading&&(t&&(this.loadCallback=t),this.loading=!0,this.frames=[],this.clear(),this.disposalRestoreFromIdx=null,this.lastDisposalMethod=null,this.frame=null,this.lastImg=null,!0)},t.prototype.completeLoop=function(){this.onEndListener&&this.onEndListener(this.gifImgElement),this.iterationCount++,!1!==this.overrideLoopMode||this.iterationCount<0?this.doStep():(this.stepping=!1,this.playing=!1)},t.prototype.doStep=function(){if(this.stepping=this.playing,this.stepping){this.stepFrame(1);var t=10*this.frames[this.currentFrameIndex].delay;t||(t=100),0===this.getNextFrameNo()?(t+=this.loopDelay,setTimeout(this.completeLoop.bind(this),t)):setTimeout(this.doStep.bind(this),t)}},t.prototype.step=function(){this.stepping||setTimeout(this.doStep.bind(this),0)},t.prototype.putFrame=function(){var t;this.currentFrameIndex=parseInt(this.currentFrameIndex.toString(),10),this.currentFrameIndex>this.frames.length-1&&(this.currentFrameIndex=0),this.currentFrameIndex<0&&(this.currentFrameIndex=0),t=this.frameOffsets[this.currentFrameIndex],this.tmpCanvas.getContext("2d").putImageData(this.frames[this.currentFrameIndex].data,t.x,t.y),this.canvasContext.globalCompositeOperation="copy",this.canvasContext.drawImage(this.tmpCanvas,0,0)},t.prototype.playerInit=function(){this.loadErrorCause||(this.canvasContext.scale(this.getCanvasScale(),this.getCanvasScale()),this.options.autoPlay?this.step():(this.currentFrameIndex=0,this.putFrame()))},t.prototype.clear=function(){this.transparency=null,this.delay=null,this.lastDisposalMethod=this.disposalMethod,this.disposalMethod=null,this.frame=null},t.prototype.parseStream=function(t){try{new bnt.SuperGifParser(t,this.handler).parse()}catch(t){this.handleError("parse")}},t.prototype.setSizes=function(t,e){this.canvas.width=t*this.getCanvasScale(),this.canvas.height=e*this.getCanvasScale(),this.tmpCanvas.width=t,this.tmpCanvas.height=e,this.tmpCanvas.style.width=t+"px",this.tmpCanvas.style.height=e+"px",this.tmpCanvas.getContext("2d").setTransform(1,0,0,1,0,0)},t.prototype.drawError=function(){this.canvasContext.fillStyle="black",this.canvasContext.fillRect(0,0,this.hdr.width,this.hdr.height),this.canvasContext.strokeStyle="red",this.canvasContext.lineWidth=3,this.canvasContext.moveTo(0,0),this.canvasContext.lineTo(this.hdr.width,this.hdr.height),this.canvasContext.moveTo(0,this.hdr.height),this.canvasContext.lineTo(this.hdr.width,0),this.canvasContext.stroke()},t.prototype.handleError=function(t){this.loadErrorCause=t,this.hdr={width:this.gifImgElement.width,height:this.gifImgElement.height},this.frames=[],this.drawError()},t.prototype.doHdr=function(t){this.hdr=t,this.setSizes(this.hdr.width,this.hdr.height)},t.prototype.doGCE=function(t){this.pushFrame(),this.clear(),this.transparency=t.transparencyGiven?t.transparencyIndex:null,this.delay=t.delayTime,this.disposalMethod=t.disposalMethod},t.prototype.pushFrame=function(){this.frame&&(this.frames.push({data:this.frame.getImageData(0,0,this.hdr.width,this.hdr.height),delay:this.delay}),this.frameOffsets.push({x:0,y:0}))},t.prototype.doImg=function(t){var e=this;this.frame||(this.frame=this.tmpCanvas.getContext("2d"));var r=this.frames.length,n=t.lctFlag?t.lct:this.hdr.gct;r>0&&(3===this.lastDisposalMethod?null!==this.disposalRestoreFromIdx?this.frame.putImageData(frames[this.disposalRestoreFromIdx].data,0,0):this.frame.clearRect(this.lastImg.leftPos,this.lastImg.topPos,this.lastImg.width,this.lastImg.height):this.disposalRestoreFromIdx=r-1,2===this.lastDisposalMethod&&this.frame.clearRect(this.lastImg.leftPos,this.lastImg.topPos,this.lastImg.width,this.lastImg.height));var i=this.frame.getImageData(t.leftPos,t.topPos,t.width,t.height);t.pixels.forEach((function(t,r){t!==e.transparency&&(i.data[4*r+0]=n[t][0],i.data[4*r+1]=n[t][1],i.data[4*r+2]=n[t][2],i.data[4*r+3]=255)})),this.frame.putImageData(i,t.leftPos,t.topPos),this.ctxScaled||(this.canvasContext.scale(this.getCanvasScale(),this.getCanvasScale()),this.ctxScaled=!0),this.drawWhileLoading&&(this.canvasContext.drawImage(this.tmpCanvas,0,0),this.drawWhileLoading=this.options.autoPlay),this.lastImg=t},t.prototype.doNothing=function(){},t.prototype.withProgress=function(t){return function(e){t(e)}},t.prototype.getNextFrameNo=function(){var t=this.forward?1:-1;return(this.currentFrameIndex+t+this.frames.length)%this.frames.length},t.prototype.stepFrame=function(t){this.currentFrameIndex=this.currentFrameIndex+t,this.putFrame()},t.prototype.getCanvasScale=function(){return this.options.maxWidth&&this.hdr&&this.hdr.width>this.options.maxWidth?this.options.maxWidth/this.hdr.width:window.devicePixelRatio||1},t.prototype.play=function(){this.playing=!0,this.step()},t.prototype.pause=function(){this.playing=!1},t.prototype.isPlaying=function(){return this.playing},t.prototype.getCanvas=function(){return this.canvas},t.prototype.isLoading=function(){return this.loading},t.prototype.isReady=function(){return this.ready},t.prototype.isAutoPlay=function(){return this.options.autoPlay},t.prototype.getLength=function(){return this.frames.length},t.prototype.getCurrentFrame=function(){return this.currentFrameIndex},t.prototype.moveTo=function(t){this.currentFrameIndex=t,this.putFrame()},t.prototype.loadURL=function(t,e){var r=this;if(this.loadSetup(e)){var n=new XMLHttpRequest;n.open("GET",t,!0),"overrideMimeType"in n?n.overrideMimeType("text/plain; charset=x-user-defined"):"responseType"in n?n.responseType="arraybuffer":n.setRequestHeader("Accept-Charset","x-user-defined"),n.onloadstart=function(){r.initialized||r.init()},n.onload=function(){if(200===n.status){var t=n.response;t.toString().indexOf("ArrayBuffer")>0&&(t=new Uint8Array(t));var e=new xnt.SuperGifStream(t);setTimeout((function(){r.parseStream(e)}),0)}else r.handleError("xhr - response")},n.onerror=function(){r.handleError("xhr")},n.send()}},t.prototype.load=function(t){this.loadURL(this.gifImgElement.src,t)},t}(),Ant=hnt.SuperGif=wnt;const _nt={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"image-selector",label:"src",name:"src"},{type:"checkbox",label:"play",name:"play"}],"value-property":"src",help:"scene/component/gif-view"};class knt extends lnt{async oncreate_element(t){var{src:e,play:r}=this.state;this.onchangesrc(e),this.onchangeplay(r)}buildImg(){var t=this.element;t.innerHTML="";var e=document.createElement("img");return e.style.width="100%",e.style.height="100%",t.appendChild(e),e}onchange(t,e){super.onchange(t,e),"src"in t&&this.onchangesrc(t.src),"play"in t&&this.onchangeplay(t.play)}setElementProperties(t){}onchangeplay(t){var e=this._superGif;e&&e.isReady()&&(t?e.play():e.pause())}onchangesrc(t){var e=this.buildImg();t||(t="data:image/gif;base64,R0lGODlhYABIAPcAAAAAAAEBAQICAgMDAwQEBAUFBQYGBgcHBwgICAkJCQoKCgsLCwwMDA0NDQ4ODg8PDxAQEBERERISEhMTExQUFBUVFRYWFhcXFxgYGBkZGRoaGhsbGxwcHB0dHR4eHh8fHyAgICEhISIiIiMjIyQkJCUlJSYmJicnJygoKCkpKSoqKisrKywsLC0tLS4uLi8vLzAwMDExMTIyMjMzMzQ0NDU1NTY2Njc3Nzg4ODk5OTo6Ojs7Ozw8PD09PT4+Pj8/P0BAQEFBQUJCQkNDQ0REREVFRUZGRkdHR0hISElJSUpKSktLS0xMTE1NTU5OTk9PT1BQUFFRUVJSUlNTU1RUVFVVVVZWVldXV1hYWFlZWVpaWltbW1xcXF1dXV5eXl9fX2BgYGFhYWJiYmNjY2RkZGVlZWZmZmdnZ2hoaGlpaWpqamtra2xsbG1tbW5ubm9vb3BwcHFxcXJycnNzc3R0dHV1dXZ2dnd3d3h4eHl5eXp6ent7e3x8fH19fX5+fn9/f4CAgIGBgYKCgoODg4SEhIWFhYaGhoeHh4iIiImJiYqKio+Pj5iYmKCgoKampqurq66urrCwsLGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbGxsbKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrOzs7S0tLa2tre3t7m5ubu7u7+/v8DAwMHBwcPDw8XFxcfHx8vLy8/Pz9LS0tXV1dfX193d3eTk5Onp6fj4+Pz8/P7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v///////////////////////////////////////////////////////////////////////////////yH5BAkAAPUAIf47R2VuZXJhdGVkIGJ5IGpzZ2lmIChodHRwczovL2dpdGh1Yi5jb20vYW50aW1hdHRlcjE1L2pzZ2lmLykALAAAAABgAEgAAAj+AGcJHEiwoMGDCBMqXMiwocOHECNKnEixosWLGDNq3Mixo8ePIEOKHEmypMmR9VKqXMmypcuXMGPKnJkSIs2bOHPqZGlzp8+fQOv1DEq0KMyhRpMmRaq0KVCmTqPmhCq1qkyqLrFRSyYwGTVsVo1iZXmNa8Fk18ISHasSm1mDycCq/ck2JTWF1ObSfTjz7cFken3WFbow8M7BDA3rHOwXruKpfGXeTZg3qDVrUge7RRg3KLZjx+Q2HVyvLNy0QaMJjBaVdD2tZr2K/mmNIObRkR+n9AsYt0Pddg1WXppb8bWDx1CLLW74GcJnSl3TtDY8Zu2Et4tKl7n52eyWnxXvhl7+26jqrspbnlfIWjtz2gWPZV95neH8veU9NxZYfbfD3kFt99J6Bnmn0mQO9XfYezrVxxlmx0GUXIAM4hSeffsxBN1TFd5E4Ef3QZbfTg6CNJ5gHXJ3TEntLThiTh+KFCJNAqZU4kgAitjQTheepOBMNcZI0oQ6JpbTjSZtiNN2PZ400IxHpdiSc07G911M0iFZZYtAStnWilUeBGVLrlEZpmM0elmPlmfO8iOZXl4DZpsGEYmll2bSWWCXLwJXVY1+urhjoGEBSuiSah6K36CKtpZoo4s9CimielZq6aWYZqrpppx26umnoIZ6UkAAOw=="),e.src=t,e.setAttribute("rel:animated_src",t),e.setAttribute("rel:auto_play",0),this._superGif=new Ant(e,{autoPlay:!1}),this._superGif.init();for(const t of this.element.children)t.style.width="100%",t.style.height="100%";var r=this._superGif.getCanvas();r.style.width="100%",r.style.height="100%",this._superGif.load((()=>{setTimeout((()=>{this._superGif.moveTo(0),this.play&&this._superGif.play()}),100)}))}ondropfile(t,e){for(let r=0;r<t.length;r++)if(/\.gif$/.test(t[r].name))return void(this.src=e[r])}get src(){return this.getState("src")}set src(t){this.set("src",t)}get play(){return this.getState("play")}set play(t){this.setState("play",t)}get nature(){return _nt}get tagName(){return"div"}}l9.register("gif-view",knt);const Ent={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"attachment-selector",label:"src",name:"src",property:{category:"audio"}},{type:"checkbox",label:"started",name:"started"},{type:"checkbox",label:"loop",name:"loop"}],"value-property":"src",help:"scene/component/audio"};class Snt extends(d9(h9)){static get image(){return Snt.IMAGE||(Snt.IMAGE=new Image,Snt.IMAGE.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZAAAAGQCAMAAAC3Ycb+AAAAP1BMVEUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACzJYIvAAAAFHRSTlMA8BAwgNBgQKB/wCBwUJDg37CvXyUlBK8AABFYSURBVHja7NsBkqIwFIThTiAQgyBq3/+sm6p1tnamZkaTMhJJf1f4S/JeEIiIiIiIiIiIiIiIiEhD7Hg4BH84TpAKjJ4f3NFCtjVd+InXz2RTs+FXlxGylYHfcVfIJmb+YFWSLUyGVJKKBJJKUo+Rd6w63l/qzLuCkryO5fe0l2xk5mMWbe+v0fNBRqf7S3je6CipQ2ACr+dWcYEpzBFS1plpguatsnomMgdIQSOTuQ5SjmE6/UgK8szgdJIUM/FG41YlFmYJ2kkKsY5ZzAwBurHDk3WGeRY0bvYrGa1+rqNI22f7dS32ZnUK1GMr0eSK3mEc9dhKMxp+ZTo8kT2emOXS5LQ1kCxbJBocSd2k5PaIjMVzjWcdJPk9ooBnmzx1t5XbIxqBKpJ4NGTgzwKiGpK4do72gb+ZUMIYtCPm9WCPMsYTE5k2hq2ZvzujlCE1iRmwf3dvmRyKsT0T7b9I7HEPCpqCiqT2IIqaT1pI0noQZdlFC8l/PbYPAnRORT56VBEE6FXkb49agmByKhJ71BME6FsvEntUFQTdqekisUdlQWCXhovEHtUFAWbTapHYo8YgmFybO3vsUWcQYGmxSOxRbRAMprkisUfFQVKmrX18sxt7VB0ENjT1xir2qDxIwkFi3v89e+xRfxAMzfzzIfZ4hyAYDR9zwVuLPd4jCDrTwoLYGb5LEFi3/+E3rweR6urX20c/Fvls2Pvwm9mDSGIPhv8YPyGf3/eo9Ye7O8B2FIShAAooakEttex/rbODad5/yTHIAjqn505IQPv+Xz06dz+4VXORHEZcgAcB8updM8F6e25jBzwIkE07l+x8amMnPDp6nsNJ+BoZ7Q6F8egqAda9VEuRNlZjBzwYkMskdXR73okd8GBAJiKYjBcZKKqG9OiKDbgdfxJ5VhsBPDiQZhaouD3p4hfw4EAmwxisz3MSHwAPEmQ1TB1N+SmXWoAHC7JbZsWl/IxLLcCDBplNo3lrfMLsmwAPGmShAxX5/1vOEzjEz3iyfQ/hI36W4TctsUesOAifPdrQg8M++KYl95iCBkjI1r8634betBAPHZDTPFAmD3zLiHgogVTziMsahz0eIh5aIGHGRSJ2mFtHPR4iHhQIP2UvWGMf8wk74qEIEib7rLjPiBfxiAcCwp8V+Nae3uMdRhAPDIR/J5f/Q2DTcC+hIB7qIGEq3Ti9bx+sryMeAAgS70OK8G2kBD8L8QBAoLWU3g3vUVIc6D0txAMAsY+4jBWowXHO64gHBGKfYJ2T5qY1BxcL98BB+PQ+XiS9xxh9EQ8ChA6C5UXWIUoE9MBB8LVHQoS7ib8/dRn3sAcJ6bQRSdH96RDxIEH4QEX+AHF4LxHEAwUh12xyr1V8lwjiQYDYF8kuf1jluUQQDwrEvkhW8Wc6LhHUgwfhi4QPlHm7LRHawx4kpE191Dq8lgjhAYDQa1cftYrPEiE8OJDb40uqyzdQCA8WhAzL4G/PT4c3WrgHD2IfllGl53V37zsgHg5ApPNvVvq4Fn4spx4oiH1W3CwtEV+PDhEPJyBSkVX4aa7emkM83ICEKWpGM7wdvYCCeDgCEYpcwhLxczhEPFyBCEUWnRL5T6X59SBASBF+9l28TL5F7uEORCZyCUvEx+S7yT0cgoRVb9JaXLR1qUdfgksQ0fTbgmhFB20d8HAKEha14+F8f1sHPNyCiL6EqK+n20/rgIdjkFC0Ho1s6Gndvcc9ICkr/ey8/rHO6vp9KawL8DAFOV6l9Fyub7IbflsCag1qRfVsXWvxHjxIejU+BHZV6uvHD1XiEb++Bw8i+dNd+Wv0eCQmhcPhRPwUUt2DB5G1sfa1aeyzAuyJj9x2HjyIdKzIKw5SI14ieFtvo3kIQERj3lVhkUOnRD7AnjV5369QkAOJZeCH+Jh41xOLs73dQwAifY6dpxCCbjTDzLf1Bm1Y93tAIDOWXcLPvrHyr2hVoEAceEAgDQzB4jetk0/c2OXRHB48EJCpa4dgpYh2ETxtrshz7zx4ICCzfuTSDn8p/EOS9OTjwgMB+cABP3yWYuOPIofs33LigYCULlpZNXJppVU30Vf14kGAUCLijf1D71lN9FW9eFiA9KgZ8FPpPUsSnufGA+8hvAg2Kpz0nrX//qp+PIgpC3i6xJRITOye9fn1VT15ICCrVlQG5rywo0H8x965bVkNwmCYQ2kR6Gmb939WXV65dFnI/tPdjPBfO7XMN4EkTUJtqZp4sCJ1+8jwkhMu0KpMxFXFA8hlVfQSMxGH5mDK1VKV8QCyvTVtUiYyo7V358VStfGoAEFMhGYhEwloxZy9WKo2Hjwg5iSOvFDXeUYd33+PuVfHgwnEBWLocDJp+IIa2fyvperjwQRiXCKGosyXqoA+YfsIELuYu4HAt+msMknfDK4jfQJIzOZ2IPAQWJtFOhQKivR2IDZ6Awis7V0iLxqBI7uEZo19dakTogLSwKvf8yk8Jq6CGK0GKvWlatG7b7kkUU/Lo1gdXWn7/4E0j0qeJDpqN/ABqQcgJgdqURb4chjQktIugDS6wFFiz3JgaJj7AGJmholAe9YKhoZLJ0Ca6smjwJ4VwVN96gVIE5GM71kHaGKxGyAtRDaB2NBhLVmpHyANRKzDO28W7FS3HQFpaIWa8TrfCXQwegJSL5k+8M9UJ+pm9QTEnCIZrR0MDQeQ9ua0iCcYQaBTV0CqNXQW/yiyYG7W1heQanPaCkciBXuH1BkQJzHcDQxmpgGkPatl4WkbCXO/bW9AqlNg4H0PPMi6A1IxkQmOZ8D0ousNSMVEEuyreTAQ6Q7IRJeCX2YZQHhv6SrBOmpkM+YUzN0BqSRQCupmTeCP9wdkhiOREwtEzgGEsWcF9BhK9R8fQDiN7A8DiR0CKXQlj/q9IM8OgXjIzcKBlAHkD6FulgNzJwPIHwpo8mQAkX3LiPq9dKUMAQk9AqmcqmjuBAJCPQIpA4guIAsKJA0gnwNy3A4kDyBIHCEPxAwgf8gPILqA5AFEF5CxZX0lIHYc6rqADLf380BmFMgxgIzUyf8MJKLTRelKHgKy9wgkjfS7LiA0gKgC8vQn3HUA4RQ5LKPIAQciWbqIEg0YkLNDIHYUyqkCsmKN5vg3+W0AYTRATaPY+uu1IwS6UMGAlO6AFPjSCQMStaNh53cdcPG7Hx1Uupo+rx+Bltn1BuTAj5BptEV/bHAAwbnJMICwRmtUDOSEA8s4Rmtw3nITGD6TwUNoG0Ca7xi2YKSPj2eKXQFxQWKA2QbGMWEMMGseOb7C7T47uJS1JyAzVbTjqZdU3zbHzMXWS+qp4Fgn8Ahy/QCRGqQcwU1vGnN7fylboWn8Bzg//hyjxltvdcl45bwFfYKzFyBy11UU9BnjuoqfWizVlQXulpzBTNbaB5Aid+VRrkBFB630AMS9BC8FK2ggE7u/FGy1kvfcB9TKQufX5uUXNWl3EjvWCi4k/u9A3Ddq1CpTIQGe6VN1qd8ArcvDQNw3S41Kn6qQmOq5e7pRr+8fAYLiIJtFrrvYRMYL0q06vj8EZLXUriJzRY8H1xEagOCK7gkghRg6RQYO0I6aWPwIEAru80AiMWSdzAeuDXUKyr+WqpAID8hMHC1Ct8F4mUsQ6W8pJMICki0JHCBczAFdBl38G3VE6ErQhhWlih4LWrCSLpaqjggHiGe9mVjRY0YPoelyqcqIcIDEe97rqJFFH7FcLlUZEQ6Qg5plvZiBFNhtri1VFREGEC/Eg4nZoU5vqi1VFREGkIXDQ8xAIhzoT/WlKiLCAFIYPOQMxOPdjfWlKiLCADJRm3YGj+pDE2xktmmpaogwgMz8d8GrumZ4xzpbvinqISJ+hiTWm7wEqoJdI9JEV9JChAEkS3xCZzKecLcgN6YwlRBhAGmweTsblg6qKMM7Vmh321UQ4QAp1VfwhqVJIh+Wm03W0qV0EOEAybXtivkCmWrKeH2EZ/xBaSBCV2L9Re+LYSqJJIxDu1ew07U0EGEBcTtmHty4JuPtQhvLh1BAhK7Uvvq0GK484QZST0GvvFDqeSJ1IA0r2mfDljvqBoJ//rVsq7yZCA6kXgVkJ2f4ijIGMjOfMVsCBBORB2Jy+sM6ijNvaBUqmw/cStZ8EiKciHwp6Rp++88qmxXQeTUxDiJWJ9wSISvBicgXW+dypn1PqWTznlwgwdZdfiLHr5OELEAEASKvJFRE5JCPKbh8OxHdQKJU0crEzRXrJ/IEkFms6tGyrUw9kQeALFRXvK2iSzsRAAi6BLxM+60xdsqJAEBuXMAMxDLVp+gmAgC57/UT4qvVj3TVRCAgSAYL91aXtyNLzUQAIFhAiP8m0/NHOp+ILiBtPFKrs6bgSOcT0QTEB8nO3QR1yKslggKRf+m11UB0HOl8IlqAeCvauXuo8HnfIqIDyCw6G8XMcGiplMingMzCnbuHFp/3LSLPA4nUpqm5YkWNzwsQeQxIDsKjH5wVSU5qJPIJIIt4jjpqNBAekQeBfJOeHWS81FQoo4/I7UDcS3wUh0liTzLqiEgDqddx4ZHDrNZAACIAEMw88HPYWb0GAhABgEDmgf9Vb5oNBCByOxD3uqWYbCHVBgIQuRlIsbfwMEG5gQBE7gSyHMDsOayrxJvHBRC5B0hOxJH1nK4SlUE6QOR+IG6ju3iYQEqDdIDIzUDyZu/jMRHpS/OiRG4FkiPRfTw8kbrvIAJEACAIDpyHC1/GQHhEbgKSXwTyqIeEur6kixEBgABHOTr7YSX1MSFAhA0E307wUU76Y0KACAsI/tvCRzkF+iIuL0AEAYLbR2QOfvhKJ/obRESBxNt5rPSFXN4f7dyNdqMgEIbhAXWwJErT/e7/Wreb5HTT07QVgWSAeW5g7b4n8qOSUCRPEId4HP93SXp5dDNGRJFcQTxihSH+NW1Bb1cXKpIryJAwnG/zhl8ZcSP6jiKZghwRaaWLnP/AkcSKKJIniEcUs8QfjFLdEmRvkSxB4lfn0QN6DY+lshQpHiT96Dlr6r5hxRUpHST9ZEY71X7DOmOZQVZLsd5Q8wzrPxYYJDiKNqOBG1ZCkZKzrNXu6lHvkjChSFqQsdTPg45ApXtYaUXKr9TNuPcvqO2pVMkitFXAL2a79/qr3HQvVSTXUtofCl79RDXh5CDpw3pwu6+9kRlvtiI5VtPhmHLltT4EKVQkfb8pcOHrXqk6nBAksUjgpKtuYsskaxGKYT0+84uYgziE4YQgMdx0m8PRfis2MbL33PMXoVjD6PEunI4HSjDjStiJP08vQk9hZzQ7oH/geoLYCUBDW4rf4FqCDFt7THUO6B+4jiDn2XNTW7zf4hqCMND4BOsGyw+yAmh0x+QeFh7EeqD5Ce8nLDrI8NpbDyIWHIQNruo4GyAPlhrEzuixBxHLDDJMnfYgYolBricHNfjIdgMWF+Qyu+pkgX4HCwuymL57ELGkIHZG7z2IWE6Q5VV7vGMhQewbtMcZiwhyHj26ne9+xs8PcvDQHnFFqCD7Au0RW4TK+fOKqw4eoOcqYqgU53HR3/5uShFPCfKey9hFDyJO/vAi7RDZnp7X5igyUH72xSDW1E2Pn4tMRCQgR8vLwbgii4gcmLvqQcSPGtIPX3M08wn6I4qYQ94cM/Yw9Xxhmw+X/59wHrtMlX1AmIkzdyaaAnLg1Nnw8WGYSk40X/BOh4+El6LMSBnN2Cd0tPq4w/LJXGrMbCX06PZ2dcM65yzlNertShSHf3SzRAyPM332IcSAHUKPi8EHmXU0l8Uglmni0yipDoi16s+jJKejhywLooz68yiMEcHr2qM4h81CJ++VPJfTu5UwBpv4Pp9DJSi6MJx0bvUwiw4ewgT8zNR0LHUL+OccOpY/3ElzyGKD5pBlMJpDlsOkMythRoNbXh95PJsdA67MrMtAEYbjeDqNo+7oKqWUUkoppZRSSimllFJKFfMXp4vmSjB8n6sAAAAASUVORK5CYII="),Snt.IMAGE}dispose(){super.dispose(),this.started=!1,delete this._audio}ready(){super.ready(),this._audio=new Audio,this._audio.addEventListener("canplay",(()=>{this.started&&this._audio.play()}));var{src:t="",loop:e=!1,started:r=!1}=this.state;this.onchangeSrc(t),this.onchangeLoop(e),this.onchangeStarted(r)}render(t){var{left:e,top:r,width:n,height:i,src:a}=this.state;t.beginPath(),this.drawImage(t,Snt.image,e,r,n,i)}get nature(){return Ent}get hasTextProperty(){return!1}get src(){return this.get("src")}set src(t){this.set("src",t)}get started(){return!!this.get("started")}set started(t){this.set("started",t)}start(){this._audio&&(this._audio.classList.add("active"),this._audio.play())}pause(){this._audio&&(this._audio.classList.remove("active"),this._audio.pause())}onchangeSrc(t){try{"data"!==String(t).substring(0,4)?this._audio.crossOrigin="use-credentials":this._audio.crossOrigin=null,this._audio.src="string"==typeof t?this.app.url(t):t}catch(t){return void console.error(t)}}onchangeStarted(t){const e=this._audio;t?4==e.readyState&&e.play():e.pause()}onchangeLoop(t){this._audio.loop=t}onchange(t,e){"src"in t&&this.onchangeSrc(t.src),"started"in t&&this.onchangeStarted(t.started),"loop"in t&&this.onchangeLoop(t.loop)}ondblclick(t){this.started=!this.started}ondropfile(t,e){for(let r=0;r<t.length;r++)if(t[r].type.startsWith("audio/"))return void(this.src=e[r])}}l9.register("audio",Snt);class Mnt extends(d9(l9)){is3dish(){return!0}}l9.register("text",Mnt);const Tnt=["refid","left","top","width","height","rotation","animation"];class Pnt extends Drt{isGroup(){return!0}get(t){return this._model[t]}set(t,e){if("string"==typeof t)return this.set({[t]:e});var r=Tnt.reduce(((e,r)=>(t.hasOwnProperty(r)&&(e[r]=t[r]),e)),{});return super.set(r)}capture(t,e,r){var n=super.capture(t,e,r);if(n!==this)return n}set bounds(t){if(this.__MUTATING__)super.bounds=t;else{var e=this.bounds,r=t.width/e.width,n=t.height/e.height;this.path=this.path.map((i=>({x:t.left+(i.x-e.left)*r,y:t.top+(i.y-e.top)*n}))),this.components&&this.components.forEach((t=>{if(t.mutable)t.mutatePath(null,(function(t){return t.map((function(t){return{x:t.x*r,y:t.y*n}}))}));else{let e=t.bounds,i=t.center,a={x:i.x*(1-r),y:i.y*(1-n)},o=e.width*(1-r),s=e.height*(1-n),c=-(a.x-o/2),u=-(a.y-s/2);t.bounds={left:e.left+c,top:e.top+u,width:e.width*r,height:e.height*n}}}))}}get focusible(){return!1}get bounds(){return super.bounds}get hasTextProperty(){return!1}isIdentifiable(){return!1}calculateBounds(){this.clearCache(),this.__MUTATING__=!0,this.mutateBounds((function(t){var e=l9.union(this.components.map((t=>t.bounds)));return this.components.forEach((t=>{let r=t.bounds;t.bounds={left:r.left-e.left,top:r.top-e.top,width:r.width,height:r.height}})),{left:t.left+e.left,top:t.top+e.top,width:e.width,height:e.height}}),this),this.__MUTATING__=!1,this.parent.isGroup()&&this.parent.calculateBounds()}render(t){}postrender(t){var{top:e,left:r,scale:n}=this.state;t.translate(r,e),this.layout.drawables(this).forEach((e=>{e.draw(t)})),t.translate(-r,-e)}}l9.register("group",Pnt);const Ont={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"id-input",label:"ref",name:"ref"},{type:"select",label:"fit",name:"fit",property:{options:["","both","ratio"]}}],"value-property":"ref",help:"scene/component/local-ref"};class Int extends(d9(h9)){get ref(){var t=this.getState("ref");return t&&"string"==typeof t?this.root.findById(t):null}set ref(t){this.setState("ref",t)}get refScale(){let t=this.ref.bounds,e=this.bounds,r=e.width/t.width,n=e.height/t.height;return"both"===this.model.fit?{x:r,y:n}:{x:Math.min(r,n),y:Math.min(r,n)}}draw(t){this._drawing||(this._drawing=!0,super.draw(t),this._drawing=!1)}prerender(t){if(super.prerender(t),this.ref){let e=this.ref.center,r=this.center,n=this.refScale;t.translate(r.x,r.y),t.scale(n.x,n.y),t.translate(-e.x,-e.y)}}postrender(t){if(this.ref)return this.ref.postrender(t);super.postrender(t)}render(t){if(this.ref)return this.ref.render(t);this.state;var{left:e,top:r,width:n,height:i}=this.bounds;t.beginPath(),t.rect(e,r,n,i)}get nature(){return Ont}get hasTextProperty(){return!1}}l9.memoize(Int.prototype,"ref",!1),l9.memoize(Int.prototype,"refScale",!1),l9.register("local-ref",Int);class Cnt extends(Crt(z9)){render(t){}get layout(){return b9.get(this.get("layout"))||x9}}const Rnt={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"board-selector",label:"scene-number",name:"ref",placeholder:"SCENE-1"},{type:"number",label:"round",name:"round",property:{min:0}},{type:"select",label:"fit",name:"fit",property:{options:["","both","ratio","width","height","none"]}},{type:"select",label:"mode",name:"mode",property:{options:["view","interaction"]}}],"value-property":"ref",help:"scene/component/global-ref"};class jnt extends Cnt{dispose(){this._releaseRef(),super.dispose()}get nature(){return Rnt}get hasTextProperty(){return!1}get tagName(){return"div"}setElementProperties(t){var{mode:e="view",round:r=0}=this.state;t.style.pointerEvents="view"==e?"none":"inherit",t.style.borderRadius=r+"px"}ready(){super.ready(),this.fetchRef()}reposition(){if(!this.element)return;super.reposition();let t=this._element_bounds,{offsetWidth:e,offsetHeight:r}=this.element;if(this._element_bounds={offsetWidth:e,offsetHeight:r},(!t||t.offsetWidth!=e||t.offsetHeight!=r)&&this.ref&&this.root.target_element){let{fit:t="ratio"}=this.state;this.ref.fit(t)}}async fetchRef(){this._releaseRef();var{ref:t,fit:e="ratio"}=this.state;if(t){var r=this.app.refProvider;if(r&&t)try{this.__ref=await r.get(t,!0),this.__ref.target=this.element,this.__ref.fit(e),this.__ref.data=this.data}catch(t){L8(t)}}}get ref(){return this.__ref}set ref(t){this.setState("ref",t)}_releaseRef(){this.__ref&&this.__ref.release&&this.__ref.release(),delete this.__ref}onchange(t,e,r){super.onchange(t,e,r),"ref"in t&&this.fetchRef(),"fit"in t&&this.ref&&requestAnimationFrame((()=>{let{fit:t}=this.state;this.ref.fit(t)})),"data"in t&&this.ref&&requestAnimationFrame((()=>{this.ref.data=t.data}))}}l9.register("global-ref",jnt);const Lnt={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"board-selector",label:"board",name:"board"},{type:"checkbox",label:"modal",name:"modal"},{type:"checkbox",label:"closable",name:"closable"},{type:"checkbox",label:"show",name:"show"},{type:"select",label:"location",name:"location",property:{options:["center","left-top","right-top","left-bottom","right-bottom","auto"]}},{type:"data",label:"value",name:"value"}],help:"scene/component/popup"};class Dnt extends(d9(h9)){static get image(){return Dnt._image||(Dnt._image=new Image,Dnt._image.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEYAAABGCAMAAABG8BK2AAADJmlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNy4xLWMwMDAgNzkuZGFiYWNiYiwgMjAyMS8wNC8xNC0wMDozOTo0NCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIDIzLjAgKE1hY2ludG9zaCkiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6RkM4QzQxNUMzMzBEMTFFQ0JEMzZDMDUwQUI4MEI3QTAiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6RkM4QzQxNUQzMzBEMTFFQ0JEMzZDMDUwQUI4MEI3QTAiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDpENjlENTQ3RjMzMDkxMUVDQkQzNkMwNTBBQjgwQjdBMCIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDpENjlENTQ4MDMzMDkxMUVDQkQzNkMwNTBBQjgwQjdBMCIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PsiUYSQAAAAZdEVYdFNvZnR3YXJlAEFkb2JlIEltYWdlUmVhZHlxyWU8AAAA51BMVEVHcEwzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzOguTm2AAAATHRSTlMARhB73r9B7YLrsqdE+0cq9Avzeg31eQx4aQ+Ks6aUd5DsYKixEX1w8vyT2VjoZ3YezY/cCEDvl+QTvRwJ0ifwK/5T/aw6+IuFuCImAcS6MQAAAeJJREFUWMPt2FlX2zAQhuHJYmOSFhIggbC0QNn3rS1dKXSH9///Hi58CJLxKIpEWi6YO8c5z4lG/nxGEXmu/1OVLGnhrFaSVQYg1SZetTTvUibqeFZ9QlfmvRWoV1VmCaCRzroXPpsuAjTV7gLUfPahBqD1OQMW/fazAWTKvQRI/ZgUSJR7U8CM/dHZ+/2VcatWdvdEZAaYUhiAwkerJXt0rnzXwdRKmHfDM0fHD5kxjTFyVLzVfvvirn7+cDJWjhy7c7XlYuwc6Urvu2tRhRypyhwAf1sKY+TIxfQA+H39q5wxc+RgVrcBduTmZTlj5khnDgH4IzKpMGaOVCbvyyvRGTNHGtPrKypjXirM5jb910I4k69oQeKY+77EMAcALEsck/+W6f71tyCma/ZFROTrJVwMy7wmf3bv6/MX+Dgkkysblvxps/dhOKZb6IvrTakzXXuPApnpYneDGOeKvJlaSXcDmA7AicQyW84VeTOnY+NdiWcG1uiZksFEHdyAlsJEjEkmkwGNsKHNZCJGSKtVTYC1tO022mnjwUBrMdXg8dreuOBhv7D/62/8lGZ1wLxXyZKOm+iUHIQintyny0TkaATHjYgcjeAoFpEje9R/nGPqIx2aw3NU9odCQI6e6x/VLY32cKQXVBnkAAAAAElFTkSuQmCC"),Dnt._image}ready(){super.ready(),this.show&&this.onchangeShow(!0)}render(t){var{left:e,top:r,width:n,height:i}=this.bounds;t.beginPath(),this.drawImage(t,Dnt.image,e,r,n,i)}onchange(t,e){"value"in t?this.show?this.onchangeShow(!0):this.show=!0:"show"in t&&this.onchangeShow(this.show)}onchangeShow(t){!this.app.isEditMode&&this.getState("board")&&(t?E9.show(this,this.board,{location:this.getState("location"),modal:this.getState("modal"),closable:this.getState("closable")||!1,data:this.value}):E9.hide(this))}get board(){return this.getState("board")}set board(t){this.set("board",t)}get show(){return this.getState("show")}set show(t){this.setState("show",t)}get started(){return this.getState("show")}set started(t){this.setState("show",t)}get value(){return this.getState("value")}set value(t){this.setState("value",t)}get hasTextProperty(){return!1}get nature(){return Lnt}}l9.register("popup",Dnt);class znt extends l9{render(t){var{path:e=[]}=this.state;if(!(e.length<=1)){t.beginPath(),t.moveTo(e[0].x,e[0].y);for(let r=1;r<e.length;r++)t.lineTo(e[r].x,e[r].y);t.closePath(),this.drawStroke(t)}}get path(){return this.model.path}set path(t){this.set("path",t)}contains(t,e){var r=this.state.path,n=!1;return r.forEach(((i,a)=>{let o=(a+r.length+1)%r.length,s=i.x,c=i.y,u=r[o].x,l=r[o].y;c>e!=l>e&&t<(u-s)*(e-c)/(l-c)+s&&(n=!n)})),n}}l9.register("path",znt);const Fnt={mutable:!0,resizable:!1,rotatable:!0,properties:[{type:"number",label:"round",name:"round",property:{min:0,max:100,step:1}}],help:"scene/component/triangle"};class Nnt extends h9{contains(t,e){var{x1:r,y1:n,x2:i,y2:a,x3:o,y3:s}=this.state,c=[r,n,i,a,o,s],u=!1;for(let r=0;r<c.length;r+=2){let n=(r+2)%c.length,i=c[r],a=c[r+1],o=c[n+1];a>e!=o>e&&t<(c[n]-i)*(e-a)/(o-a)+i&&(u=!u)}return u}get mutable(){return!0}get path(){var{x1:t,y1:e,x2:r,y2:n,x3:i,y3:a}=this.state;return[{x:t,y:e},{x:r,y:n},{x:i,y:a}]}set path(t){this.set({x1:t[0].x,y1:t[0].y,x2:t[1].x,y2:t[1].y,x3:t[2].x,y3:t[2].y})}get nature(){return Fnt}}l9.memoize(Nnt.prototype,"path",!1),l9.register("triangle",Nnt);const Bnt={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"number",label:"ratio",name:"ratio",property:"ratio"}],help:"scene/component/donut"};var Unt={ondragmove:function(t,e,r){r.controls;var{cx:n,rx:i}=r.model;i=Math.abs(i);var a=(r.transcoordP2S(t.x,t.y).x-n)/i*100;a=a>=100||a<=-100?100:Math.abs(a),r.set({ratio:a})}};class Ynt extends $rt{is3dish(){return!1}render(t){var{ratio:e=50,cx:r,cy:n,rx:i,ry:a,startAngle:o,endAngle:s,anticlockwise:c}=this.state;i=Math.abs(i),a=Math.abs(a),t.beginPath(),t.ellipse(r,n,i,a,0,o||0,s||2*Math.PI,c),t.moveTo(r+i/100*e,n),t.ellipse(r,n,i/100*e,a/100*e,0,o||0,s||2*Math.PI,!0)}contains(t,e){var{cx:r,cy:n,rx:i,ry:a,ratio:o}=this.state,s=(t-r)/(2*(i=Math.abs(i))-.5),c=(e-n)/(2*(a=Math.abs(a))-.5),u=(t-r)/(i/100*o*2-.5),l=(e-n)/(a/100*o*2-.5),h=!1;return s*s+c*c<.25&&u*u+l*l>.25&&(h=!h),h}get controls(){var{cx:t,cy:e,rx:r,ratio:n}=this.state;return[{x:t+(r=Math.abs(r))/100*n,y:e,handler:Unt}]}get nature(){return Bnt}}l9.memoize(Ynt.prototype,"controls",!1),l9.register("donut",Ynt);const Gnt={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"number",label:"ratio",name:"ratio",property:"ratio"},{type:"number",label:"wing",name:"wing",property:"wing"}],help:"scene/component/star"};var Wnt={ondragmove:function(t,e,r){r.controls;var{cy:n,ry:i}=r.model,a=(r.transcoordP2S(t.x,t.y).y-n)/i*100+100;a>=100?a=100:a<=0&&(a=0),r.set({ratio:a})}};class Hnt extends $rt{is3dish(){return!1}render(t){var{ratio:e=30,wing:r=5,cx:n,cy:i,rx:a,ry:o,startAngle:s,endAngle:c,anticlockwise:u}=this.state;if(r<3)return;const l=1.5707963267948966;var h=2*Math.PI/r,f=a-e/100*a,d=o-e/100*o;t.save(),t.beginPath(),t.translate(n,i),t.moveTo(a*Math.cos(-l),o*Math.sin(-l)),t.lineTo((a-f)*(Math.cos(h-l)+Math.cos(0-l))/2,(o-d)*(Math.sin(h-l)+Math.sin(0-l))/2);for(var p=1;p<r;p++)t.lineTo(a*Math.cos(h*p-l),o*Math.sin(h*p-l)),t.lineTo((a-f)*(Math.cos(h*(p+1)-l)+Math.cos(h*p-l))/2,(o-d)*(Math.sin(h*(p+1)-l)+Math.sin(h*p-l))/2);t.closePath(),t.restore()}get controls(){var{cx:t,cy:e,ry:r,ratio:n}=this.state;return[{x:t,y:e-r+r*(n/100),handler:Wnt}]}get nature(){return Gnt}}l9.memoize(Hnt.prototype,"controls",!1),l9.register("star",Hnt);var qnt=t=>class extends t{animOnValueChange(t,e=!1,r){if(t!=this._lastValue){if(e)var n=t-(Number(r)||0);else n=t-(this._lastValue||0);this._lastValue=t,this._anim_alpha=-n,this.animate({step:t=>{this._anim_alpha=n*(t-1),this.invalidate()},duration:1e3,delta:"circ",options:{x:1},ease:"out"}).start()}}dispose(){super.dispose(),delete this._value_substitutor}onchange(t,e){t.hasOwnProperty("value")&&delete this._value_substitutor}get animAlpha(){return this._anim_alpha||0}get animValue(){return(this._lastValue||0)+(this._anim_alpha||0)}defaultValueSubstitutor(){return this.getState("value")}get valueSubstitutor(){return this._value_substitutor||(this._value_substitutor=Z7(this.getState("value"),this)||this.defaultValueSubstitutor),this._value_substitutor}get value(){return Number(this.valueSubstitutor())||0}set value(t){delete this._value_substitutor,this.setState("value",Number(_8(t)))}},Xnt=t=>class extends t{_convertDataFormat(t,e){var r;if("json"===e)r=JSON.parse(t);else r=t;return r}isDataSource(){return!0}},Vnt=0;const Qnt=new FinalizationRegistry((()=>{Vnt--}));class Knt{static get residents(){return Vnt}static get residentsCount(){return Vnt}constructor(t,e){this.counters={},this.references={},this.creator=t,this.disposer=e,Vnt++,Qnt.register(this,Vnt)}dispose(){if(this.disposer)for(let t in this.references)this.disposer.call(null,t,this.references[t]);delete this.references,delete this.counters}get ids(){return Object.keys(this.references)}create(t){var e=this;return new Promise((function(r,n){e.creator?e.creator.call(null,t,(function(e){!function(e){e.release=function(){this.disposer&&this.disposer.call(null,t,e),delete e.release,z8("RELEASED",t)},r(e)}(e)}),(function(t){n(t)})):n(Error("Reference id("+t+") could not be created. Reference creator should be defined."))}))}add(t,e){var r=this,n=new Promise((function(n,i){var a=r.references[t];if(a)a===e?i(Error("Reference ID and target duplicate")):e?i(Error("Reference ID duplicate")):n(a);else{function o(e){e.release=function(){r.release(this)},r.references[t]=e,r.counters[t]=1,n(e)}if(e)o(e);else{if(!r.creator)return void i(Error("Reference id("+t+") is not allowed. Reference creator should be defined."));r.creator.call(null,t,(function(t){o(t)}),(function(t){i(t)}))}}}));return this.references[t]||(this.references[t]=n),n}async get(t,e){var r=this.references[t];if(r){if(!(r instanceof Promise)){if(!(t in this.counters))throw new Error("No Reference Count");return this.counters[t]++,r}if(e)return r=await r,this.counters[t]++,r}if(e)return await this.add(t);throw new Error("No References for "+t)}_id(t){for(let e in this.references){if(this.references[e]===t)return e}return-1}release(t){var e=this._id(t),r=this.references[e];r?(this.counters[e]--,0==this.counters[e]&&(this.disposer&&this.disposer.call(null,e,r),delete this.references[e],delete this.counters[e],delete t.release,z8("RELEASED",e))):L8("No Referenced ID")}}var Jnt={},Znt={},$nt=[];function tit(t){var e="SCRIPT"==t.target.tagName?Jnt:Znt,r=t.target.src||t.target.href;e[r]=!0,$nt.forEach(((t,n)=>{let{resolve:i,scripts:a,styles:o}=t;if(e==Jnt){let t=a.indexOf(r);t>-1&&t<a.length-1&&rit(a[t+1])}for(let t=0;t<a.length;t++)if(!Jnt[a[t]])return;if(o)for(let t=0;t<o.length;t++)if(!Znt[o[t]])return;i(),$nt[n]=null})),$nt=$nt.filter(Boolean)}function eit(t){var e=t.target.src,r="SCRIPT"==t.target.tagName?Jnt:Znt;$nt.forEach(((n,i)=>{let{reject:a,scripts:o,styles:s}=n,c=!1;if(r===Jnt){for(let t=0;t<o.length;t++)if(o[t]==e){c=!0;break}}else if(s)for(let t=0;t<s.length;t++)if(s[t]==e){c=!0;break}c&&(a(t),$nt[i]=null)})),$nt=$nt.filter(Boolean),delete r[e],document.head.removeChild(t.target)}function rit(t){Jnt[t]=!1;var e=document.createElement("script");e.onload=tit,e.onerror=eit,e.type="text/javascript",e.src=t,document.head.appendChild(e)}class nit{static load(t,e){return"string"==typeof t&&(t=[t]),"string"==typeof e&&(e=[e]),new Promise((function(r,n){if((!t||t instanceof Array)&&(!e||e instanceof Array)){var i,a=!0;if(e&&e.forEach((t=>{Znt.hasOwnProperty(t)||function(t){Znt[t]=!1;var e=document.createElement("link");e.onload=tit,e.onerror=eit,e.type="text/css",e.rel="stylesheet",e.media="screen,print",e.href=t,document.head.appendChild(e)}(t),Znt[t]||(a=!1)})),t&&t.length>0&&t.forEach((t=>{Jnt.hasOwnProperty(t)?Jnt[t]||(a=!1):i=i||t})),i)rit(i);else if(a)return void r();$nt.push({resolve:r,reject:n,scripts:t,styles:e})}else n("invalid sources for load")}))}}const iit="0.0.0";var ait=0,oit=performance.now(),sit=0;function cit(){return ait}requestAnimationFrame((function t(){requestAnimationFrame(t),sit++;var e=performance.now(),r=e-oit;r<1e3||(ait=Math.round(1e3*sit/r),oit=e,sit=0)}));var uit=Stt;function lit(){}export{S9 as AbsoluteLayout,Snt as AudioPlayer,T9 as CardLayout,l9 as Component,W9 as Connectable,Drt as Container,z9 as ContainerAbstract,J8 as DEFAULT,V8 as DPPX,Xnt as DataSource,Ynt as Donut,$rt as Ellipse,rrt as EventMap,cit as FPS,Q8 as GESTURES,knt as GifView,jnt as GlobalRef,Pnt as Group,x9 as HTMLAbsoluteLayout,Cnt as HTMLOverlayContainer,lnt as HTMLOverlayElement,unt as ImageView,y9 as InfoWindow,K8 as KEYEVENTS,F9 as Layer,b9 as Layout,Jrt as Line,O9 as LinearHorizontalLayout,C9 as LinearVerticalLayout,Int as LocalRef,X8 as MAX_UNDO_SIZE,G8 as MODE_ADD,U8 as MODE_EDIT,H8 as MODE_PASTE_DATABIND,W8 as MODE_PASTE_STYLE,Y8 as MODE_SHIFT,B8 as MODE_VIEW,uit as Model,L9 as MoveHandle,N8 as NOTHING,snt as OrthoLine,znt as Path,rnt as Polygon,ant as Polyline,Dnt as Popup,X9 as Rect,d9 as RectPath,Knt as ReferenceMap,prt as RootContainer,Q9 as Ruler,q8 as SCENE_MODE,Trt as Scene,E9 as ScenePopup,nit as ScriptLoader,h9 as Shape,Hnt as Star,R9 as TableLayout,Mnt as Text,Nnt as Triangle,qnt as ValueHolder,Ort as create,z8 as debug,L8 as error,lit as license,g2 as polyfill,iit as version,D8 as warn};console.log("@hatiolab/things-scene@3.4.48 is loaded");