@hatiolab/things-scene 9.0.0-beta.27 → 9.0.0-beta.29
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/db.sqlite +0 -0
- package/package.json +1 -1
- package/things-scene-ie.js +1 -1
- package/things-scene-min.js +1 -1
- package/things-scene.mjs +9 -8
package/things-scene.mjs
CHANGED
|
@@ -3,7 +3,7 @@ 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,s=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},l=o.iterator||"@@iterator",h=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function d(t,e,r,n){var i=e&&e.prototype instanceof b?e:b,a=Object.create(i.prototype),o=new R(n||[]);return s(a,"_invoke",{value:T(t,r,o)}),a}function p(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=d;var f="suspendedStart",g="suspendedYield",v="executing",m="completed",y={};function b(){}function w(){}function x(){}var A={};u(A,l,(function(){return this}));var _=Object.getPrototypeOf,k=_&&_(_(O([])));k&&k!==r&&a.call(k,l)&&(A=k);var S=x.prototype=b.prototype=Object.create(A);function E(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function M(t,e){function r(i,s,o,l){var h=p(t[i],t,s);if("throw"!==h.type){var c=h.arg,u=c.value;return u&&"object"==n(u)&&a.call(u,"__await")?e.resolve(u.__await).then((function(t){r("next",t,o,l)}),(function(t){r("throw",t,o,l)})):e.resolve(u).then((function(t){c.value=t,o(c)}),(function(t){return r("throw",t,o,l)}))}l(h.arg)}var i;s(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=f;return function(a,s){if(i===v)throw new Error("Generator is already running");if(i===m){if("throw"===a)throw s;return{value:t,done:!0}}for(n.method=a,n.arg=s;;){var o=n.delegate;if(o){var l=C(o,n);if(l){if(l===y)continue;return l}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===f)throw i=m,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=v;var h=p(e,r,n);if("normal"===h.type){if(i=n.done?m:g,h.arg===y)continue;return{value:h.arg,done:n.done}}"throw"===h.type&&(i=m,n.method="throw",n.arg=h.arg)}}}function C(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,C(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),y;var a=p(i,e.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,y;var s=a.arg;return s?s.done?(r[e.resultName]=s.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,y):s:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,y)}function P(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 R(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(P,this),this.reset(!0)}function O(e){if(e||""===e){var r=e[l];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,s=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 s.next=s}}throw new TypeError(n(e)+" is not iterable")}return w.prototype=x,s(S,"constructor",{value:x,configurable:!0}),s(x,"constructor",{value:w,configurable:!0}),w.displayName=u(x,c,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===w||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,x):(t.__proto__=x,u(t,c,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},E(M.prototype),u(M.prototype,h,(function(){return this})),e.AsyncIterator=M,e.async=function(t,r,n,i,a){void 0===a&&(a=Promise);var s=new M(d(t,r,n,i),a);return e.isGeneratorFunction(r)?s:s.next().then((function(t){return t.done?t.value:s.next()}))},E(S),u(S,c,"Generator"),u(S,l,(function(){return this})),u(S,"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=O,R.prototype={constructor:R,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 o.type="throw",o.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var i=this.tryEntries.length-1;i>=0;--i){var s=this.tryEntries[i],o=s.completion;if("root"===s.tryLoc)return n("end");if(s.tryLoc<=this.prev){var l=a.call(s,"catchLoc"),h=a.call(s,"finallyLoc");if(l&&h){if(this.prev<s.catchLoc)return n(s.catchLoc,!0);if(this.prev<s.finallyLoc)return n(s.finallyLoc)}else if(l){if(this.prev<s.catchLoc)return n(s.catchLoc,!0)}else{if(!h)throw new Error("try statement without catch or finally");if(this.prev<s.finallyLoc)return n(s.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 s=i?i.completion:{};return s.type=t,s.arg=e,i?(this.method="next",this.next=i.finallyLoc,y):this.complete(s)},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),y},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),y}},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:O(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),y}},e}var a=e("./utils"),s=function(){var e=i().mark(W),r=i().mark(U),s=i().mark(H),o=i().mark(G),l=i().mark(Q),h=i().mark(dt),c=i().mark(pt),u=i().mark(ft),d=i().mark(vt),p=i().mark(kt),f=i().mark(Tt),g=i().mark(It),v=a.isNumeric,m=a.isArrayOfStrings,y=a.isArrayOfNumbers,b=a.createSequence,w=a.isSequence,x=a.isFunction,A=a.isLambda,_=a.isIterable,k=a.getFunctionArity,S=a.isDeepEqual,E=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 C(t){if(void 0!==t&&0!==t.length)return Math.max.apply(Math,t)}function P(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 R(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(x(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&&x(e)?"":e}),n)}return r}}function O(t,e,r){if(void 0!==t){var n=E(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 L(t,e){if(void 0!==t){var r=t.indexOf(e);return r>-1?t.substr(0,r):t}}function D(t,e){if(void 0!==t){var r=t.indexOf(e);return r>-1?t.substr(r+e.length):t}}function F(t){if(void 0!==t)return t.toLowerCase()}function N(t){if(void 0!==t)return t.toUpperCase()}function j(t){if(void 0!==t)return E(t).length}function B(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 z(t,e,r){if(void 0!==t){var n;void 0!==r&&0!==r.length||(r=" ");var i=Math.abs(e)-j(t);if(i>0){var a=new Array(i+1).join(r);r.length>1&&(a=O(a,0,i)),n=e>0?t+a:a+t}else n=t;return n}}function W(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)||x(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 U(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(W(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 H(t,e,r){var 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: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(W(e,t),"t0",8);case 8:if(void 0===(o=i.t0)){i.next=17;break}case 10:if(void 0===o||!(void 0===r||a<r)){i.next=17;break}return n.push({match:o.match,index:o.start,groups:o.groups}),i.delegateYield(W(o.next),"t1",13);case 13:o=i.t1,a++,i.next=10;break;case 17:return i.abrupt("return",n);case 18:case"end":return i.stop()}}),s)}function G(t,e,r,n){var a,s,l,h,c,u,d,p;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(s="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 s;if(s=0===t.groups.length?1:Math.floor(Math.log(t.groups.length)*Math.LOG10E)+1,i=parseInt(r.substring(n,n+s),10),s>1&&i>t.groups.length&&(i=parseInt(r.substring(n,n+s-1),10)),isNaN(i))e+="$";else{if(t.groups.length>0){var o=t.groups[i-1];void 0!==o&&(e+=o)}n+=i.toString().length}}i=r.indexOf("$",n)}return e+=r.substring(n)}:r,l="",h=0,!(void 0===n||n>0)){i.next=44;break}if(c=0,"string"!=typeof e){i.next=18;break}for(u=t.indexOf(e,h);-1!==u&&(void 0===n||c<n);)l+=t.substring(h,u),l+=r,h=u+e.length,c++,u=t.indexOf(e,h);l+=t.substring(h),i.next=42;break;case 18:return i.delegateYield(W(e,t),"t0",19);case 19:if(void 0===(d=i.t0)){i.next=41;break}case 21:if(void 0===d||!(void 0===n||c<n)){i.next=38;break}if(l+=t.substring(h,d.start),p=s.apply(a,[d]),!_(p)){i.next=27;break}return i.delegateYield(p,"t1",26);case 26:p=i.t1;case 27:if("string"!=typeof p){i.next=31;break}l+=p,i.next=32;break;case 31:throw{code:"D3012",stack:(new Error).stack,value:p};case 32:return h=d.start+d.match.length,c++,i.delegateYield(W(d.next),"t2",35);case 35:d=i.t2,i.next=21;break;case 38:l+=t.substring(h),i.next=42;break;case 41:l=t;case 42:i.next=45;break;case 44:l=t;case 45:return i.abrupt("return",l);case 46:case"end":return i.stop()}}),o,this)}function Y(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 V(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 q(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 X(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 $(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 Q(t,e,r){var n,a,s,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: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(W(e,t),"t0",12);case 12:if(void 0===(s=i.t0)){i.next=26;break}o=0;case 15:if(void 0===s||!(void 0===r||a<r)){i.next=23;break}return n.push(t.substring(o,s.start)),o=s.end,i.delegateYield(W(s.next),"t1",19);case 19:s=i.t1,a++,i.next=15;break;case 23:(void 0===r||a<r)&&n.push(t.substring(o)),i.next=27;break;case 26:n.push(t);case 27:return i.abrupt("return",n);case 28:case"end":return i.stop()}}),l)}function J(t,e){if(void 0!==t)return void 0===e&&(e=""),t.join(e)}function Z(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),s=a;s<a+10;s++)i.push(String.fromCharCode(s));var o=i.concat([n["decimal-separator"],n["exponent-separator"],n["grouping-separator"],n.digit,n["pattern-separator"]]),l=e.split(n["pattern-separator"]);if(l.length>2)throw{code:"D3080",stack:(new Error).stack};var h=function(t){var e,r,i,a,s=function(){for(var e,r=0;r<t.length;r++)if(e=t.charAt(r),-1!==o.indexOf(e)&&e!==n["exponent-separator"])return t.substring(0,r)}(),l=function(){for(var e,r=t.length-1;r>=0;r--)if(e=t.charAt(r),-1!==o.indexOf(e)&&e!==n["exponent-separator"])return t.substring(r+1)}(),h=t.substring(s.length,t.length-l.length),c=t.indexOf(n["exponent-separator"],s.length);-1===c||c>t.length-l.length?(e=h,r=void 0):(e=h.substring(0,c),r=h.substring(c+1));var u=e.indexOf(n["decimal-separator"]);return-1===u?(i=e,a=l):(i=e.substring(0,u),a=e.substring(u+1)),{prefix:s,suffix:l,activePart:h,mantissaPart:e,exponentPart:r,integerPart:i,fractionalPart:a,subpicture:t}},c=function(t){var e,r,a=t.subpicture,s=a.indexOf(n["decimal-separator"]);s!==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 l=!1;for(r=0;r<t.mantissaPart.length;r++){var h=t.mantissaPart.charAt(r);if(-1!==i.indexOf(h)||h===n.digit){l=!0;break}}l||(e="D3085"),-1!==t.activePart.split("").map((function(t){return-1===o.indexOf(t)?"p":"a"})).join("").indexOf("p")&&(e="D3086"),-1!==s?a.charAt(s-1)!==n["grouping-separator"]&&a.charAt(s+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 c=t.integerPart.indexOf(n.digit);-1!==c&&t.integerPart.substring(0,c).split("").filter((function(t){return i.indexOf(t)>-1})).length>0&&(e="D3090"),-1!==(c=t.fractionalPart.lastIndexOf(n.digit))&&t.fractionalPart.substring(c).split("").filter((function(t){return i.indexOf(t)>-1})).length>0&&(e="D3091");var u="string"==typeof t.exponentPart;if(u&&t.exponentPart.length>0&&(-1!==a.indexOf(n.percent)||-1!==a.indexOf(n["per-mille"]))&&(e="D3092"),u&&(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}},u=function(t){var e=function(e,r){for(var a=[],s=e.indexOf(n["grouping-separator"]);-1!==s;){var o=(r?e.substring(0,s):e.substring(s)).split("").filter((function(t){return-1!==i.indexOf(t)||t===n.digit})).length;a.push(o),s=t.integerPart.indexOf(n["grouping-separator"],s+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},s=a(r),o=e(t.fractionalPart,!0),l=t.integerPart.split("").filter((function(t){return-1!==i.indexOf(t)})).length,h=l,c=t.fractionalPart.split(""),u=c.filter((function(t){return-1!==i.indexOf(t)})).length,d=c.filter((function(t){return-1!==i.indexOf(t)||t===n.digit})).length,p="string"==typeof t.exponentPart;0===l&&0===d&&(p?(u=1,d=1):l=1),p&&0===l&&-1!==t.integerPart.indexOf(n.digit)&&(l=1),0===l&&0===u&&(u=1);var f=0;return p&&(f=t.exponentPart.split("").filter((function(t){return-1!==i.indexOf(t)})).length),{integerPartGroupingPositions:r,regularGrouping:s,minimumIntegerPartSize:l,scalingFactor:h,prefix:t.prefix,fractionalPartGroupingPositions:o,minimumFactionalPartSize:u,maximumFactionalPartSize:d,minimumExponentSize:f,suffix:t.suffix,picture:t.subpicture}},d=l.map(h);d.forEach(c);var p,f,g,v,m=d.map(u),y=n["minus-sign"],b=n["zero-digit"],w=n["decimal-separator"],x=n["grouping-separator"];if(1===m.length&&(m.push(JSON.parse(JSON.stringify(m[0]))),m[1].prefix=y+m[1].prefix),f=-1!==(p=t>=0?m[0]:m[1]).picture.indexOf(n.percent)?100*t:-1!==p.picture.indexOf(n["per-mille"])?1e3*t:t,0===p.minimumExponentSize)g=f;else{var A=Math.pow(10,p.scalingFactor),_=Math.pow(10,p.scalingFactor-1);for(g=f,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},S=k(at(g,p.maximumFactionalPartSize),p.maximumFactionalPartSize),E=S.indexOf(".");for(-1===E?S+=w:S=S.replace(".",w);S.charAt(0)===b;)S=S.substring(1);for(;S.charAt(S.length-1)===b;)S=S.substring(0,S.length-1);E=S.indexOf(w);var M=p.minimumIntegerPartSize-E,T=p.minimumFactionalPartSize-(S.length-E-1);if(S=(M>0?new Array(M+1).join(b):"")+S,S+=T>0?new Array(T+1).join(b):"",E=S.indexOf(w),p.regularGrouping>0)for(var C=Math.floor((E-1)/p.regularGrouping),P=1;P<=C;P++)S=[S.slice(0,E-P*p.regularGrouping),x,S.slice(E-P*p.regularGrouping)].join("");else p.integerPartGroupingPositions.forEach((function(t){S=[S.slice(0,E-t),x,S.slice(E-t)].join(""),E++}));if(E=S.indexOf(w),p.fractionalPartGroupingPositions.forEach((function(t){S=[S.slice(0,t+E+1),x,S.slice(t+E+1)].join("")})),E=S.indexOf(w),-1!==p.picture.indexOf(w)&&E!==S.length-1||(S=S.substring(0,S.length-1)),void 0!==v){var I=k(v,0);(M=p.minimumExponentSize-I.length)>0&&(I=new Array(M+1).join(b)+I),S=S+n["exponent-separator"]+(v<0?y:"")+I}return S=p.prefix+S+p.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 st(t){if(void 0!==t){if(t<0)throw{stack:(new Error).stack,code:"D3060",index:1,value:t};return Math.sqrt(t)}}function ot(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 lt(){return Math.random()}function ht(t){if(void 0!==t){var e=!1;return Array.isArray(t)?1===t.length?e=ht(t[0]):t.length>1&&(e=t.filter((function(t){return ht(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 ct(t){if(void 0!==t)return!ht(t)}function ut(t,e,r,n){var i=[e],a=k(t);return a>=2&&i.push(r),a>=3&&i.push(n),i}function dt(t,e){var r,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:r=b(),n=0;case 4:if(!(n<t.length)){i.next=12;break}return a=ut(e,t[n],n,t),i.delegateYield(e.apply(this,a),"t0",7);case 7:void 0!==(s=i.t0)&&r.push(s);case 9:n++,i.next=4;break;case 12:return i.abrupt("return",r);case 13:case"end":return i.stop()}}),h,this)}function pt(t,e){var r,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:r=b(),n=0;case 4:if(!(n<t.length)){i.next=13;break}return a=t[n],s=ut(e,a,n,t),i.delegateYield(e.apply(this,s),"t0",8);case 8:ht(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()}}),c,this)}function ft(t,e){var r,n,a,s,o,l,h;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(s=t[a],o=!0,void 0===e){i.next=12;break}return l=ut(e,s,a,t),i.delegateYield(e.apply(this,l),"t0",10);case 10:h=i.t0,o=ht(h);case 12:if(!o){i.next=19;break}if(r){i.next=18;break}n=s,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()}}),u,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,s,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: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],s=1):(n=r,s=0);case 6:if(!(s<t.length)){i.next=15;break}return o=[n,t[s]],a>=3&&o.push(s),a>=4&&o.push(t),i.delegateYield(e.apply(this,o),"t0",11);case 11:n=i.t0,s++,i.next=6;break;case 15:return i.abrupt("return",n);case 16:case"end":return i.stop()}}),d,this)}function mt(t){var e=b();if(Array.isArray(t)){var r={};t.forEach((function(t){mt(t).forEach((function(t){r[t]=!0}))})),e=mt(r)}else null===t||"object"!==n(t)||A(t)||Object.keys(t).forEach((function(t){return e.push(t)}));return e}function yt(t,e){var r;if(Array.isArray(t)){r=b();for(var i=0;i<t.length;i++){var a=yt(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 wt(t){return void 0!==t}function xt(t){var e=b();if(Array.isArray(t))t.forEach((function(t){e=bt(e,xt(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,s;return i().wrap((function(o){for(;;)switch(o.prev=o.next){case 0:r=b(),o.t0=i().keys(t);case 2:if((o.t1=o.t0()).done){o.next=10;break}return n=o.t1.value,a=ut(e,t[n],n,t),o.delegateYield(e.apply(this,a),"t2",6);case 6:void 0!==(s=o.t2)&&r.push(s),o.next=2;break;case 10:return o.abrupt("return",r);case 11:case"end":return o.stop()}}),p,this)}function St(t){throw{code:"D3137",stack:(new Error).stack,message:t||"$error() function evaluated"}}function Et(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":x(t)?"function":"object"}function Tt(t,e){var r,n,a,s;return i().wrap((function(o){for(;;)switch(o.prev=o.next){case 0:if(void 0!==t){o.next=2;break}return o.abrupt("return",void 0);case 2:if(!(t.length<=1)){o.next=4;break}return o.abrupt("return",t);case 4:if(void 0!==e){o.next=10;break}if(y(t)||m(t)){o.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)})),o.next=11;break;case 10:r=e;case 11:return n=i().mark((function t(e,n){var a,s;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)})),s=[],t.delegateYield(a(s,e,n),"t0",3);case 3:return t.abrupt("return",s);case 4:case"end":return t.stop()}}),t)})),a=i().mark((function t(e){var r,a,s;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),s=e.slice(r),i.delegateYield(t(a),"t0",8);case 8:return a=i.t0,i.delegateYield(t(s),"t1",10);case 10:return s=i.t1,i.delegateYield(n(a,s),"t2",12);case 12:return i.abrupt("return",i.t2);case 13:case"end":return i.stop()}}),t)})),o.delegateYield(a(t),"t0",14);case 14:return s=o.t0,o.abrupt("return",s);case 16:case"end":return o.stop()}}),f)}function Ct(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 Pt(t){if(void 0!==t){if(!Array.isArray(t)||t.length<=1)return t;for(var e=w(t)?b():[],r=0;r<t.length;r++){for(var n=t[r],i=!1,a=0;a<e.length;a++)if(S(n,e[a])){i=!0;break}i||e.push(n)}return e}}function It(t,e){var r,n,a,s;return i().wrap((function(o){for(;;)switch(o.prev=o.next){case 0:r={},o.t0=i().keys(t);case 2:if((o.t1=o.t0()).done){o.next=11;break}return n=o.t1.value,a=t[n],s=ut(e,a,n,t),o.delegateYield(e.apply(this,s),"t2",7);case 7:ht(o.t2)&&(r[n]=a),o.next=2;break;case 11:return 0===Object.keys(r).length&&(r=void 0),o.abrupt("return",r);case 13:case"end":return o.stop()}}),g,this)}return{sum:M,count:T,max:C,min:P,average:I,string:R,substring:O,substringBefore:L,substringAfter:D,lowercase:F,uppercase:N,length:j,trim:B,pad:z,match:H,contains:U,replace:G,split:Q,join:J,formatNumber:Z,formatBase:tt,number:et,floor:nt,ceil:it,round:at,abs:rt,sqrt:st,power:ot,random:lt,boolean:ht,not:ct,map:dt,zip:gt,filter:pt,single:ft,foldLeft:vt,sift:It,keys:mt,lookup:yt,append:bt,exists:wt,spread:xt,merge:At,reverse:_t,each:kt,error:St,assert:Et,type:Mt,sort:Tt,shuffle:Ct,distinct:Pt,base64encode:Y,base64decode:V,encodeUrlComponent:q,encodeUrl:X,decodeUrlComponent:$,decodeUrl:K}}();r.exports=s}).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,s=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},l=o.iterator||"@@iterator",h=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function d(t,e,r,n){var i=e&&e.prototype instanceof b?e:b,a=Object.create(i.prototype),o=new R(n||[]);return s(a,"_invoke",{value:T(t,r,o)}),a}function p(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=d;var f="suspendedStart",g="suspendedYield",v="executing",m="completed",y={};function b(){}function w(){}function x(){}var A={};u(A,l,(function(){return this}));var _=Object.getPrototypeOf,k=_&&_(_(O([])));k&&k!==r&&a.call(k,l)&&(A=k);var S=x.prototype=b.prototype=Object.create(A);function E(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function M(t,e){function r(i,s,o,l){var h=p(t[i],t,s);if("throw"!==h.type){var c=h.arg,u=c.value;return u&&"object"==n(u)&&a.call(u,"__await")?e.resolve(u.__await).then((function(t){r("next",t,o,l)}),(function(t){r("throw",t,o,l)})):e.resolve(u).then((function(t){c.value=t,o(c)}),(function(t){return r("throw",t,o,l)}))}l(h.arg)}var i;s(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=f;return function(a,s){if(i===v)throw new Error("Generator is already running");if(i===m){if("throw"===a)throw s;return{value:t,done:!0}}for(n.method=a,n.arg=s;;){var o=n.delegate;if(o){var l=C(o,n);if(l){if(l===y)continue;return l}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===f)throw i=m,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=v;var h=p(e,r,n);if("normal"===h.type){if(i=n.done?m:g,h.arg===y)continue;return{value:h.arg,done:n.done}}"throw"===h.type&&(i=m,n.method="throw",n.arg=h.arg)}}}function C(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,C(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),y;var a=p(i,e.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,y;var s=a.arg;return s?s.done?(r[e.resultName]=s.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,y):s:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,y)}function P(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 R(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(P,this),this.reset(!0)}function O(e){if(e||""===e){var r=e[l];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,s=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 s.next=s}}throw new TypeError(n(e)+" is not iterable")}return w.prototype=x,s(S,"constructor",{value:x,configurable:!0}),s(x,"constructor",{value:w,configurable:!0}),w.displayName=u(x,c,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===w||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,x):(t.__proto__=x,u(t,c,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},E(M.prototype),u(M.prototype,h,(function(){return this})),e.AsyncIterator=M,e.async=function(t,r,n,i,a){void 0===a&&(a=Promise);var s=new M(d(t,r,n,i),a);return e.isGeneratorFunction(r)?s:s.next().then((function(t){return t.done?t.value:s.next()}))},E(S),u(S,c,"Generator"),u(S,l,(function(){return this})),u(S,"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=O,R.prototype={constructor:R,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 o.type="throw",o.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var i=this.tryEntries.length-1;i>=0;--i){var s=this.tryEntries[i],o=s.completion;if("root"===s.tryLoc)return n("end");if(s.tryLoc<=this.prev){var l=a.call(s,"catchLoc"),h=a.call(s,"finallyLoc");if(l&&h){if(this.prev<s.catchLoc)return n(s.catchLoc,!0);if(this.prev<s.finallyLoc)return n(s.finallyLoc)}else if(l){if(this.prev<s.catchLoc)return n(s.catchLoc,!0)}else{if(!h)throw new Error("try statement without catch or finally");if(this.prev<s.finallyLoc)return n(s.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 s=i?i.completion:{};return s.type=t,s.arg=e,i?(this.method="next",this.next=i.finallyLoc,y):this.complete(s)},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),y},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),y}},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:O(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),y}},e}var a=t("./datetime"),s=t("./functions"),o=t("./utils"),l=t("./parser"),h=t("./signature"),c=function(){var t=i().mark(z),e=i().mark(W),r=i().mark(H),c=i().mark(G),u=i().mark(Y),d=i().mark(V),p=i().mark(q),f=i().mark(X),g=i().mark(at),v=i().mark(lt),m=i().mark(ut),y=i().mark(dt),b=i().mark(pt),w=i().mark(vt),x=i().mark(bt),A=i().mark(wt),_=i().mark(xt),k=i().mark(At),S=i().mark(kt),E=i().mark(Et),M=i().mark(Ct),T=i().mark(Rt),C=o.isNumeric,P=o.isArrayOfStrings,I=o.isArrayOfNumbers,R=o.createSequence,O=o.isSequence,L=o.isFunction,D=o.isLambda,F=o.isIterable,N=o.getFunctionArity,j=o.isDeepEqual,B=Lt(null);function z(e,r,n){var a,s,o,l;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:(s=n.lookup("__evaluate_entry"))&&s(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(W(e,r,n),"t1",6);case 6:return a=t.t1,t.abrupt("break",50);case 8:return t.delegateYield(q(e,r,n),"t2",9);case 9:return a=t.t2,t.abrupt("break",50);case 11:return t.delegateYield(X(e,r,n),"t3",12);case 12:return a=t.t3,t.abrupt("break",50);case 14:return a=$(e,r),t.abrupt("break",50);case 16:return a=K(e),t.abrupt("break",50);case 18:return a=Q(e,r),t.abrupt("break",50);case 20:return a=Z(e,r),t.abrupt("break",50);case 22:return a=n.lookup(e.slot.label),t.abrupt("break",50);case 24:return t.delegateYield(dt(e,r,n),"t4",25);case 25:return a=t.t4,t.abrupt("break",50);case 27:return t.delegateYield(pt(e,r,n),"t5",28);case 28:return a=t.t5,t.abrupt("break",50);case 30:return t.delegateYield(ut(e,r,n),"t6",31);case 31:return a=t.t6,t.abrupt("break",50);case 33:return a=ft(e),t.abrupt("break",50);case 35:return t.delegateYield(wt(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=mt(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}o=0;case 59:if(!(o<e.predicate.length)){t.next=65;break}return t.delegateYield(V(e.predicate[o].expr,a,n),"t10",61);case 61:a=t.t10;case 62:o++,t.next=59;break;case 65:if("path"===e.type||!Object.prototype.hasOwnProperty.call(e,"group")){t.next=68;break}return t.delegateYield(lt(e.group,a,n),"t11",67);case 67:a=t.t11;case 68:return(l=n.lookup("__evaluate_exit"))&&l(e,r,n,a),a&&O(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 W(t,r,n){var a,s,o,l,h,c;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=Array.isArray(r)&&"variable"!==t.steps[0].type?r:R(r),o=!1,l=void 0,h=0;case 4:if(!(h<t.steps.length)){e.next=25;break}if((c=t.steps[h]).tuple&&(o=!0),0!==h||!c.consarray){e.next=12;break}return e.delegateYield(z(c,a,n),"t0",9);case 9:s=e.t0,e.next=19;break;case 12:if(!o){e.next=17;break}return e.delegateYield(Y(c,a,l,n),"t1",14);case 14:l=e.t1,e.next=19;break;case 17:return e.delegateYield(H(c,a,n,h===t.steps.length-1),"t2",18);case 18:s=e.t2;case 19:if(o||void 0!==s&&0!==s.length){e.next=21;break}return e.abrupt("break",25);case 21:void 0===c.focus&&(a=s);case 22:h++,e.next=4;break;case 25:if(o)if(t.tuple)s=l;else for(s=R(),h=0;h<l.length;h++)s.push(l[h]["@"]);if(t.keepSingletonArray&&(Array.isArray(s)&&s.cons&&!s.sequence&&(s=R(s)),s.keepSingleton=!0),!t.hasOwnProperty("group")){e.next=30;break}return e.delegateYield(lt(t.group,o?l:s,n),"t3",29);case 29:s=e.t3;case 30:return e.abrupt("return",s);case 31:case"end":return e.stop()}}),e)}function U(t,e){var r=Lt(t);for(var n in e)r.bind(n,e[n]);return r}function H(t,e,n,a){var s,o,l,h,c;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(s=r.t0,!t.stages){r.next=6;break}return r.delegateYield(G(t.stages,s,n),"t1",5);case 5:s=r.t1;case 6:return r.abrupt("return",s);case 7:s=R(),o=0;case 9:if(!(o<e.length)){r.next=24;break}return r.delegateYield(z(t,e[o],n),"t2",11);case 11:if(l=r.t2,!t.stages){r.next=20;break}h=0;case 14:if(!(h<t.stages.length)){r.next=20;break}return r.delegateYield(V(t.stages[h].expr,l,n),"t3",16);case 16:l=r.t3;case 17:h++,r.next=14;break;case 20:void 0!==l&&s.push(l);case 21:o++,r.next=9;break;case 24:return c=R(),a&&1===s.length&&Array.isArray(s[0])&&!O(s[0])?c=s[0]:s.forEach((function(t){!Array.isArray(t)||t.cons?c.push(t):t.forEach((function(t){return c.push(t)}))})),r.abrupt("return",c);case 27:case"end":return r.stop()}}),r)}function G(t,e,r){var n,a,s,o;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}s=t[a],i.t0=s.type,i.next="filter"===i.t0?7:"index"===i.t0?10:12;break;case 7:return i.delegateYield(V(s.expr,n,r),"t1",8);case 8:return n=i.t1,i.abrupt("break",12);case 10:for(o=0;o<n.length;o++)n[o][s.value]=o;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()}}),c)}function Y(t,e,r,n){var a,s,o,l,h,c,d,p;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(s=i.t1,(a=R()).tupleStream=!0,o=0;o<s.length;o++)(l={"@":s[o]})[t.index]=o,a.push(l);case 11:if(!t.stages){i.next=14;break}return i.delegateYield(G(t.stages,a,n),"t2",13);case 13:a=i.t2;case 14:return i.abrupt("return",a);case 15:(a=R()).tupleStream=!0,h=n,void 0===r&&(r=e.map((function(t){return{"@":t}}))),c=0;case 20:if(!(c<r.length)){i.next=28;break}return h=U(n,r[c]),i.delegateYield(z(t,r[c]["@"],h),"t3",23);case 23:if(void 0!==(d=i.t3))for(Array.isArray(d)||(d=[d]),p=0;p<d.length;p++)l={},Object.assign(l,r[c]),d.tupleStream?Object.assign(l,d[p]):(t.focus?(l[t.focus]=d[p],l["@"]=r[c]["@"]):l["@"]=d[p],t.index&&(l[t.index]=p),t.ancestor&&(l[t.ancestor.label]=r[c]["@"])),a.push(l);case 25:c++,i.next=20;break;case 28:if(!t.stages){i.next=31;break}return i.delegateYield(G(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()}}),u)}function V(t,e,r){var n,a,o,l,h,c;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(n=R(),e&&e.tupleStream&&(n.tupleStream=!0),Array.isArray(e)||(e=R(e)),"number"!==t.type){i.next=10;break}(a=Math.floor(t.value))<0&&(a=e.length+a),void 0!==(o=e[a])&&(Array.isArray(o)?n=o:n.push(o)),i.next=23;break;case 10:a=0;case 11:if(!(a<e.length)){i.next=23;break}return o=e[a],l=o,h=r,e.tupleStream&&(l=o["@"],h=U(r,o)),i.delegateYield(z(t,l,h),"t0",17);case 17:c=i.t0,C(c)&&(c=[c]),I(c)?c.forEach((function(t){var r=Math.floor(t);r<0&&(r=e.length+r),r===a&&n.push(o)})):s.boolean(c)&&n.push(o);case 20:a++,i.next=11;break;case 23:return i.abrupt("return",n);case 24:case"end":return i.stop()}}),d)}function q(t,e,r){var n,a,s,o,l;return i().wrap((function(h){for(;;)switch(h.prev=h.next){case 0:return h.delegateYield(z(t.lhs,e,r),"t0",1);case 1:if(a=h.t0,s=t.value,o=i().mark((function n(){return i().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.delegateYield(z(t.rhs,e,r),"t0",1);case 1:return n.abrupt("return",n.t0);case 2:case"end":return n.stop()}}),n)})),"and"!==s&&"or"!==s){h.next=15;break}return h.prev=5,h.delegateYield(at(a,o,s),"t1",7);case 7:return h.abrupt("return",h.t1);case 10:throw h.prev=10,h.t2=h.catch(5),h.t2.position=t.position,h.t2.token=s,h.t2;case 15:return h.delegateYield(o(),"t3",16);case 16:l=h.t3,h.prev=17,h.t4=s,h.next="+"===h.t4||"-"===h.t4||"*"===h.t4||"/"===h.t4||"%"===h.t4?21:"="===h.t4||"!="===h.t4?23:"<"===h.t4||"<="===h.t4||">"===h.t4||">="===h.t4?25:"&"===h.t4?27:".."===h.t4?29:"in"===h.t4?31:33;break;case 21:return n=et(a,l,s),h.abrupt("break",33);case 23:return n=rt(a,l,s),h.abrupt("break",33);case 25:return n=nt(a,l,s),h.abrupt("break",33);case 27:return n=ot(a,l),h.abrupt("break",33);case 29:return n=ct(a,l),h.abrupt("break",33);case 31:return n=it(a,l),h.abrupt("break",33);case 33:h.next=40;break;case 35:throw h.prev=35,h.t5=h.catch(17),h.t5.position=t.position,h.t5.token=s,h.t5;case 40:return h.abrupt("return",n);case 41:case"end":return h.stop()}}),p,null,[[5,10],[17,35]])}function X(t,e,r){var n,a,o,l;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(z(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(!C(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 o=t.expressions[a],i.delegateYield(z(o,e,r),"t2",20);case 20:void 0!==(l=i.t2)&&("["===o.value?n.push(l):n=s.append(n,l));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(lt(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()}}),f)}function $(t,e,r){return s.lookup(e,t.value)}function K(t){return t.value}function Q(t,e){var r=R();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=J(n),r=s.append(r,n)):r.push(n)})),r}function J(t,e){return void 0===e&&(e=[]),Array.isArray(t)?t.forEach((function(t){J(t,e)})):e.push(t),e}function Z(t,e){var r,n=R();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&&!C(t))throw{code:"T2001",stack:(new Error).stack,value:t};if(void 0!==e&&!C(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),s=n(e);if("undefined"===a||"undefined"===s)return!1;switch(r){case"=":i=j(t,e);break;case"!=":i=!j(t,e)}return i}function nt(t,e,r){var i,a=n(t),s=n(e);if("undefined"!==a&&"string"!==a&&"number"!==a||"undefined"!==s&&"string"!==s&&"number"!==s)throw{code:"T2010",stack:(new Error).stack,value:"string"!==a&&"number"!==a?t:e};if("undefined"!==a&&"undefined"!==s){if(a!==s)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=st(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=st,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=st,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 st(t){var e=s.boolean(t);return void 0!==e&&e}function ot(t,e){var r="",n="";return void 0!==t&&(r=s.string(t)),void 0!==e&&(n=s.string(e)),r.concat(n)}function lt(t,e,r){var n,a,o,l,h,c,u,d,p,f,g,m,y;return i().wrap((function(v){for(;;)switch(v.prev=v.next){case 0:n={},a={},o=!(!e||!e.tupleStream),Array.isArray(e)||(e=R(e)),0===e.length&&e.push(void 0),l=0;case 6:if(!(l<e.length)){v.next=31;break}h=e[l],c=o?U(r,h):r,u=0;case 10:if(!(u<t.lhs.length)){v.next=28;break}return d=t.lhs[u],v.delegateYield(z(d[0],o?h["@"]:h,c),"t0",13);case 13:if("string"==typeof(p=v.t0)||void 0===p){v.next=16;break}throw{code:"T1003",stack:(new Error).stack,position:t.position,value:p};case 16:if(void 0===p){v.next=25;break}if(f={data:h,exprIndex:u},!a.hasOwnProperty(p)){v.next=24;break}if(a[p].exprIndex===u){v.next=21;break}throw{code:"D1009",stack:(new Error).stack,position:t.position,value:p};case 21:a[p].data=s.append(a[p].data,h),v.next=25;break;case 24:a[p]=f;case 25:u++,v.next=10;break;case 28:l++,v.next=6;break;case 31:v.t1=i().keys(a);case 32:if((v.t2=v.t1()).done){v.next=43;break}return p=v.t2.value,f=a[p],g=f.data,c=r,o&&(m=ht(f.data),g=m["@"],delete m["@"],c=U(r,m)),v.delegateYield(z(t.lhs[f.exprIndex][1],g,c),"t3",39);case 39:void 0!==(y=v.t3)&&(n[p]=y),v.next=32;break;case 43:return v.abrupt("return",n);case 44:case"end":return v.stop()}}),v)}function ht(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]=s.append(e[n],t[r][n]);return e}function ct(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 ut(t,e,r){var n;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return i.delegateYield(z(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()}}),m)}function dt(t,e,r){var n,a;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return i.delegateYield(z(t.condition,e,r),"t0",1);case 1:if(a=i.t0,!s.boolean(a)){i.next=7;break}return i.delegateYield(z(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(z(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()}}),y)}function pt(t,e,r){var n,a,s;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:a=Lt(r),s=0;case 2:if(!(s<t.expressions.length)){i.next=8;break}return i.delegateYield(z(t.expressions[s],e,a),"t0",4);case 4:n=i.t0;case 5:s++,i.next=2;break;case 8:return i.abrupt("return",n);case 9:case"end":return i.stop()}}),b)}function ft(t){var e=new Nt.RegexEngine(t.value),r=function r(n,i){var a;e.lastIndex=i||0;var s=e.exec(n);if(null!==s){if(a={match:s[0],start:s.index,end:s.index+s[0].length,groups:[]},s.length>1)for(var o=1;o<s.length;o++)a.groups.push(s[o]);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,o,l,h,c;return i().wrap((function(u){for(;;)switch(u.prev=u.next){case 0:return o=e,l=!!e.tupleStream,h=i().mark((function e(a,s){var o,h,c,u,d,p,f,g,v;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:o=0,h=0;case 2:if(!(0===o&&h<t.terms.length)){e.next=35;break}return c=t.terms[h],u=a,d=r,l&&(u=a["@"],d=U(r,a)),e.delegateYield(z(c.expression,u,d),"t0",8);case 8:return p=e.t0,u=s,d=r,l&&(u=s["@"],d=U(r,s)),e.delegateYield(z(c.expression,u,d),"t1",13);case 13:if(f=e.t1,g=n(p),v=n(f),"undefined"!==g){e.next=19;break}return o="undefined"===v?0:1,e.abrupt("continue",32);case 19:if("undefined"!==v){e.next=22;break}return o=-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?p:f};case 24:if(g===v){e.next=26;break}throw{code:"T2007",stack:(new Error).stack,position:t.position,value:p,value2:f};case 26:if(p!==f){e.next=30;break}return e.abrupt("continue",32);case 30:o=p<f?-1:1;case 31:!0===c.descending&&(o=-o);case 32:h++,e.next=2;break;case 35:return e.abrupt("return",1===o);case 36:case"end":return e.stop()}}),e)})),c={environment:r,input:e},u.delegateYield(s.sort.apply(c,[o,h]),"t0",5);case 5:return a=u.t0,u.abrupt("return",a);case 7:case"end":return u.stop()}}),w)}function mt(t,e,r){var a=i().mark((function e(a){var s,o,l,h,c,u,d,p,f,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(s=r.lookup("clone"),L(s)){e.next=5;break}throw{code:"T2013",stack:(new Error).stack,position:t.position};case 5:return e.delegateYield(xt(s,[a],null,r),"t0",6);case 6:return o=e.t0,e.delegateYield(z(t.pattern,o,r),"t1",8);case 8:if(void 0===(l=e.t1)){e.next=35;break}Array.isArray(l)||(l=[l]),h=0;case 12:if(!(h<l.length)){e.next=35;break}if(!(c=l[h])||!(c.isPrototypeOf(o)||c instanceof Object.constructor)){e.next=16;break}throw{code:"D1010",stack:(new Error).stack,position:t.position};case 16:return e.delegateYield(z(t.update,c,r),"t2",17);case 17:if(u=e.t2,"undefined"===(d=n(u))){e.next=23;break}if("object"===d&&null!==u&&!Array.isArray(u)){e.next=22;break}throw{code:"T2011",stack:(new Error).stack,position:t.update.position,value:u};case 22:for(p in u)c[p]=u[p];case 23:if(void 0===t.delete){e.next=32;break}return e.delegateYield(z(t.delete,c,r),"t3",25);case 25:if(void 0===(f=e.t3)){e.next=32;break}if(g=f,Array.isArray(f)||(f=[f]),P(f)){e.next=31;break}throw{code:"T2012",stack:(new Error).stack,position:t.delete.position,value:g};case 31:for(v=0;v<f.length;v++)"object"===n(c)&&null!==c&&delete c[f[v]];case 32:h++,e.next=12;break;case 35:return e.abrupt("return",o);case 36:case"end":return e.stop()}}),e)}));return It(a,"<(oa):o>")}var yt=l("function($f, $g) { function($x){ $g($f($x)) } }");function bt(t,e,r){var n,a,s,o;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return i.delegateYield(z(t.lhs,e,r),"t0",1);case 1:if(a=i.t0,"function"!==t.rhs.type){i.next=7;break}return i.delegateYield(wt(t.rhs,e,r,{context:a}),"t1",4);case 4:n=i.t1,i.next=20;break;case 7:return i.delegateYield(z(t.rhs,e,r),"t2",8);case 8:if(s=i.t2,L(s)){i.next=11;break}throw{code:"T2006",stack:(new Error).stack,position:t.position,value:s};case 11:if(!L(a)){i.next=18;break}return i.delegateYield(z(yt,null,r),"t3",13);case 13:return o=i.t3,i.delegateYield(xt(o,[a,s],null,r),"t4",15);case 15:n=i.t4,i.next=20;break;case 18:return i.delegateYield(xt(s,[a],null,r),"t5",19);case 19:n=i.t5;case 20:return i.abrupt("return",n);case 21:case"end":return i.stop()}}),x)}function wt(t,e,r,a){var s,o,l,h,c,u;return i().wrap((function(d){for(;;)switch(d.prev=d.next){case 0:return d.delegateYield(z(t.procedure,e,r),"t0",1);case 1:if(void 0!==(o=d.t0)||"path"!==t.procedure.type||!r.lookup(t.procedure.steps[0].value)){d.next=4;break}throw{code:"T1005",stack:(new Error).stack,position:t.position,token:t.procedure.steps[0].value};case 4:l=[],void 0!==a&&l.push(a.context),h=i().mark((function n(){var a,s;return i().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.delegateYield(z(t.arguments[c],e,r),"t0",1);case 1:a=n.t0,L(a)?(s=i().mark((function t(){var e,n,s,o=arguments;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:for(e=o.length,n=new Array(e),s=0;s<e;s++)n[s]=o[s];return t.delegateYield(xt(a,n,null,r),"t0",2);case 2:return t.abrupt("return",t.t0);case 3:case"end":return t.stop()}}),t)})),s.arity=N(a),l.push(s)):l.push(a);case 3:case"end":return n.stop()}}),n)})),c=0;case 8:if(!(c<t.arguments.length)){d.next=13;break}return d.delegateYield(h(),"t1",10);case 10:c++,d.next=8;break;case 13:return u="path"===t.procedure.type?t.procedure.steps[0].value:t.procedure.value,d.prev=14,"object"===n(o)&&(o.token=u,o.position=t.position),d.delegateYield(xt(o,l,e,r),"t2",17);case 17:s=d.t2,d.next=25;break;case 20:throw d.prev=20,d.t3=d.catch(14),d.t3.position||(d.t3.position=t.position),d.t3.token||(d.t3.token=u),d.t3;case 25:return d.abrupt("return",s);case 26:case"end":return d.stop()}}),A,null,[[14,20]])}function xt(t,e,r,n){var a,s,o,l;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(!D(a)||!0!==a.thunk){i.next=21;break}return i.delegateYield(z(a.body.procedure,a.input,a.environment),"t1",4);case 4:s=i.t1,"variable"===a.body.procedure.type&&(s.token=a.body.procedure.value),s.position=a.body.procedure.position,o=[],l=0;case 9:if(!(l<a.body.arguments.length)){i.next=17;break}return i.t2=o,i.delegateYield(z(a.body.arguments[l],a.input,a.environment),"t3",12);case 12:i.t4=i.t3,i.t2.push.call(i.t2,i.t4);case 14:l++,i.next=9;break;case 17:return i.delegateYield(At(s,o,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,s,o;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(i.prev=0,s=e,t&&(s=St(t.signature,e,r)),!D(t)){i.next=8;break}return i.delegateYield(Et(t,s),"t0",5);case 5:a=i.t0,i.next=24;break;case 8:if(!t||!0!==t._jsonata_function){i.next=16;break}if(o={environment:n,input:r},a=t.implementation.apply(o,s),!F(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,s),!F(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(xt(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,s,o,l;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:a=[],s=0;case 2:if(!(s<t.arguments.length)){i.next=15;break}if("operator"!==(o=t.arguments[s]).type||"?"!==o.value){i.next=8;break}a.push(o),i.next=12;break;case 8:return i.t0=a,i.delegateYield(z(o,e,r),"t1",10);case 10:i.t2=i.t1,i.t0.push.call(i.t0,i.t2);case 12:s++,i.next=2;break;case 15:return i.delegateYield(z(t.procedure,e,r),"t3",16);case 16:if(void 0!==(l=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(!D(l)){i.next=23;break}n=Mt(l,a),i.next=32;break;case 23:if(!l||!0!==l._jsonata_function){i.next=27;break}n=Tt(l.implementation,a),i.next=32;break;case 27:if("function"!=typeof l){i.next=31;break}n=Tt(l,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()}}),S)}function St(t,e,r){return void 0===t?e:t.validate(e,r)}function Et(t,e){var r,n;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(n=Lt(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(Ct(t.body,n),"t0",4);case 4:r=i.t0,i.next=9;break;case 7:return i.delegateYield(z(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()}}),E)}function Mt(t,e){var r=Lt(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=Pt(t),n="function("+(r=r.map((function(t){return"$"+t.trim()}))).join(", ")+"){ _ }",i=l(n);return i.body=t,Mt(i,e)}function Ct(t,e){var r,n,a,s;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(r=Pt(t),n=r.map((function(t){return e.lookup(t.trim())})),a={environment:e},s=t.apply(a,n),!F(s)){i.next=7;break}return i.delegateYield(s,"t0",6);case 6:s=i.t0;case 7:return i.abrupt("return",s);case 8:case"end":return i.stop()}}),M)}function Pt(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=h(e)),r}function Rt(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)&&!O(r)&&((r=R(r)).outerWrapper=!0)),i.prev=4,n=l(t,!1),i.next=12;break;case 8:throw i.prev=8,i.t0=i.catch(4),Ft(i.t0),{stack:(new Error).stack,code:"D3120",value:i.t0.message,error:i.t0};case 12:return i.prev=12,i.delegateYield(z(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),Ft(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 Ot(t){if(void 0!==t)return JSON.parse(s.string(t))}function Lt(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]}}}B.bind("sum",It(s.sum,"<a<n>:n>")),B.bind("count",It(s.count,"<a:n>")),B.bind("max",It(s.max,"<a<n>:n>")),B.bind("min",It(s.min,"<a<n>:n>")),B.bind("average",It(s.average,"<a<n>:n>")),B.bind("string",It(s.string,"<x-b?:s>")),B.bind("substring",It(s.substring,"<s-nn?:s>")),B.bind("substringBefore",It(s.substringBefore,"<s-s:s>")),B.bind("substringAfter",It(s.substringAfter,"<s-s:s>")),B.bind("lowercase",It(s.lowercase,"<s-:s>")),B.bind("uppercase",It(s.uppercase,"<s-:s>")),B.bind("length",It(s.length,"<s-:n>")),B.bind("trim",It(s.trim,"<s-:s>")),B.bind("pad",It(s.pad,"<s-ns?:s>")),B.bind("match",It(s.match,"<s-f<s:o>n?:a<o>>")),B.bind("contains",It(s.contains,"<s-(sf):b>")),B.bind("replace",It(s.replace,"<s-(sf)(sf)n?:s>")),B.bind("split",It(s.split,"<s-(sf)n?:a<s>>")),B.bind("join",It(s.join,"<a<s>s?:s>")),B.bind("formatNumber",It(s.formatNumber,"<n-so?:s>")),B.bind("formatBase",It(s.formatBase,"<n-n?:s>")),B.bind("formatInteger",It(a.formatInteger,"<n-s:s>")),B.bind("parseInteger",It(a.parseInteger,"<s-s:n>")),B.bind("number",It(s.number,"<(nsb)-:n>")),B.bind("floor",It(s.floor,"<n-:n>")),B.bind("ceil",It(s.ceil,"<n-:n>")),B.bind("round",It(s.round,"<n-n?:n>")),B.bind("abs",It(s.abs,"<n-:n>")),B.bind("sqrt",It(s.sqrt,"<n-:n>")),B.bind("power",It(s.power,"<n-n:n>")),B.bind("random",It(s.random,"<:n>")),B.bind("boolean",It(s.boolean,"<x-:b>")),B.bind("not",It(s.not,"<x-:b>")),B.bind("map",It(s.map,"<af>")),B.bind("zip",It(s.zip,"<a+>")),B.bind("filter",It(s.filter,"<af>")),B.bind("single",It(s.single,"<af?>")),B.bind("reduce",It(s.foldLeft,"<afj?:j>")),B.bind("sift",It(s.sift,"<o-f?:o>")),B.bind("keys",It(s.keys,"<x-:a<s>>")),B.bind("lookup",It(s.lookup,"<x-s:x>")),B.bind("append",It(s.append,"<xx:a>")),B.bind("exists",It(s.exists,"<x:b>")),B.bind("spread",It(s.spread,"<x-:a<o>>")),B.bind("merge",It(s.merge,"<a<o>:o>")),B.bind("reverse",It(s.reverse,"<a:a>")),B.bind("each",It(s.each,"<o-f:a>")),B.bind("error",It(s.error,"<s?:x>")),B.bind("assert",It(s.assert,"<bs?:x>")),B.bind("type",It(s.type,"<x:s>")),B.bind("sort",It(s.sort,"<af?:a>")),B.bind("shuffle",It(s.shuffle,"<a:a>")),B.bind("distinct",It(s.distinct,"<x:x>")),B.bind("base64encode",It(s.base64encode,"<s-:s>")),B.bind("base64decode",It(s.base64decode,"<s-:s>")),B.bind("encodeUrlComponent",It(s.encodeUrlComponent,"<s-:s>")),B.bind("encodeUrl",It(s.encodeUrl,"<s-:s>")),B.bind("decodeUrlComponent",It(s.decodeUrlComponent,"<s-:s>")),B.bind("decodeUrl",It(s.decodeUrl,"<s-:s>")),B.bind("eval",It(Rt,"<sx?:x>")),B.bind("toMillis",It(a.toMillis,"<s-s?:n>")),B.bind("fromMillis",It(a.fromMillis,"<n-s?s?:s>")),B.bind("clone",It(Ot,"<(oa)-:o>"));var Dt={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 Ft(t){var e=Dt[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 Nt(t,e){var r,n;try{r=l(t,e&&e.recover),n=r.errors,delete r.errors}catch(t){throw Ft(t),t}var i=Lt(B),s=new Date;return i.bind("now",It((function(t,e){return a.fromMillis(s.getTime(),t,e)}),"<s?s?:s>")),i.bind("millis",It((function(){return s.getTime()}),"<:n>")),e&&e.RegexEngine?Nt.RegexEngine=e.RegexEngine:Nt.RegexEngine=RegExp,{evaluate:function(t,e,a){if(void 0!==n){var o={code:"S0500",position:0};throw Ft(o),o}var l,h,c;if(void 0!==e)for(var u in l=Lt(i),e)l.bind(u,e[u]);else l=i;if(l.bind("$",t),s=new Date,l.timestamp=s,Array.isArray(t)&&!O(t)&&((t=R(t)).outerWrapper=!0),"function"==typeof a){l.async=!0;var d=function(t){Ft(t),a(t,null)},p=function t(e){(h=c.next(e)).done?a(null,h.value):h.value.then(t).catch(d)};c=z(r,t,l),(h=c.next()).value.then(p).catch(d)}else try{for(c=z(r,t,l),h=c.next();!h.done;)h=c.next(h.value);return h.value}catch(o){throw Ft(o),o}},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 Nt.parser=l,Nt}();e.exports=c},{"./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}},s=function(){for(var t,e,a=n,s=0;n<i;){var o=r.charAt(n);if("/"===o&&"\\"!==r.charAt(n-1)&&0===s){if(""===(t=r.substring(a,n)))throw{code:"S0301",stack:(new Error).stack,position:n};for(n++,o=r.charAt(n),a=n;"i"===o||"m"===o;)n++,o=r.charAt(n);return e=r.substring(a,n)+"g",new RegExp(t,e)}"("!==o&&"["!==o&&"{"!==o||"\\"===r.charAt(n-1)||s++,")"!==o&&"]"!==o&&"}"!==o||"\\"===r.charAt(n-1)||s--,n++}throw{code:"S0302",stack:(new Error).stack,position:n}},o=function o(l){if(n>=i)return null;for(var h=r.charAt(n);n<i&&" \t\n\r\v".indexOf(h)>-1;)n++,h=r.charAt(n);if("/"===h&&"*"===r.charAt(n+1)){var c=n;for(n+=2,h=r.charAt(n);"*"!==h||"/"!==r.charAt(n+1);)if(h=r.charAt(++n),n>=i)throw{code:"S0106",stack:(new Error).stack,position:c};return n+=2,h=r.charAt(n),o(l)}if(!0!==l&&"/"===h)return n++,a("regex",s());if("."===h&&"."===r.charAt(n+1))return n+=2,a("operator","..");if(":"===h&&"="===r.charAt(n+1))return n+=2,a("operator",":=");if("!"===h&&"="===r.charAt(n+1))return n+=2,a("operator","!=");if(">"===h&&"="===r.charAt(n+1))return n+=2,a("operator",">=");if("<"===h&&"="===r.charAt(n+1))return n+=2,a("operator","<=");if("*"===h&&"*"===r.charAt(n+1))return n+=2,a("operator","**");if("~"===h&&">"===r.charAt(n+1))return n+=2,a("operator","~>");if(Object.prototype.hasOwnProperty.call(t,h))return n++,a("operator",h);if('"'===h||"'"===h){var u=h;n++;for(var d="";n<i;){if("\\"===(h=r.charAt(n)))if(n++,h=r.charAt(n),Object.prototype.hasOwnProperty.call(e,h))d+=e[h];else{if("u"!==h)throw{code:"S0103",stack:(new Error).stack,position:n,token:h};var p=r.substr(n+1,4);if(!/^[0-9a-fA-F]+$/.test(p))throw{code:"S0104",stack:(new Error).stack,position:n};var f=parseInt(p,16);d+=String.fromCharCode(f),n+=4}else{if(h===u)return n++,a("string",d);d+=h}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 m=parseFloat(v[0]);if(!isNaN(m)&&isFinite(m))return n+=v[0].length,a("number",m);throw{code:"S0102",stack:(new Error).stack,position:n,token:v[0]}}if("`"===h){n++;var y=r.indexOf("`",n);if(-1!==y)return g=r.substring(n,y),n=y+1,a("name",g);throw n=i,{code:"S0105",stack:(new Error).stack,position:n}}for(var b,w=n;;)if(b=r.charAt(w),w===i||" \t\n\r\v".indexOf(b)>-1||Object.prototype.hasOwnProperty.call(t,b)){if("$"===r.charAt(n))return g=r.substring(n+1,w),n=w,a("variable",g);switch(g=r.substring(n,w),n=w,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 w++};return o},i=function(e,i){var a,s,o={},l=[],h=function(){var t=[];"(end)"!==a.id&&t.push({type:a.type,value:a.value,position:a.position});for(var e=s();null!==e;)t.push(e),e=s();return t},c={nud:function(){var t={code:"S0211",token:this.value,position:this.position};if(i)return t.remaining=h(),t.type="error",l.push(t),t;throw t.stack=(new Error).stack,t}},u=function(t,e){var r=o[t];return e=e||0,r?e>=r.lbp&&(r.lbp=e):((r=Object.create(c)).id=r.value=t,r.lbp=e,o[t]=r),r},d=function(t){if(i){t.remaining=h(),l.push(t);var e=o["(error)"];return(a=Object.create(e)).error=t,a.type="(error)",a}throw t.stack=(new Error).stack,t},p=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 d(n)}var i=s(r);if(null===i)return(a=o["(end)"]).position=e.length,a;var l,h=i.value,c=i.type;switch(c){case"name":case"variable":l=o["(name)"];break;case"operator":if(!(l=o[h]))return d({code:"S0204",stack:(new Error).stack,position:i.position,token:h});break;case"string":case"number":case"value":l=o["(literal)"];break;case"regex":c="regex",l=o["(regex)"];break;default:return d({code:"S0205",stack:(new Error).stack,position:i.position,token:h})}return(a=Object.create(l)).value=h,a.type=c,a.position=i.position,a},f=function(t){var e,r=a;for(p(null,!0),e=r.nud();t<a.lbp;)r=a,p(),e=r.led(e);return e},g=function(t){u(t,0).nud=function(){return this}},v=function(e,r,n){var i=r||t[e],a=u(e,i);return a.led=n||function(t){return this.lhs=t,this.rhs=f(i),this.type="binary",this},a},m=function(t,e,r){var n=u(t,e);return n.led=r,n},y=function(t,e){var r=u(t);return r.nud=e||function(){return this.expression=f(70),this.type="unary",this},r};g("(end)"),g("(name)"),g("(literal)"),g("(regex)"),u(":"),u(";"),u(","),u(")"),u("]"),u("}"),u(".."),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"),y("-"),v("~>"),m("(error)",10,(function(t){return this.lhs=t,this.error=a.error,this.remaining=h(),this.type="error",this})),y("*",(function(){return this.type="wildcard",this})),y("**",(function(){return this.type="descendant",this})),y("%",(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),p("?")):this.arguments.push(f(0)),","===a.id;)p(",");if(p(")",!0),"name"===t.type&&("function"===t.value||"λ"===t.value)){if(this.arguments.forEach((function(t,e){if("variable"!==t.type)return d({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 s=p();">"===s.id?r--:"<"===s.id&&r++,i+=s.value}p(">");try{this.signature=n(i)}catch(t){return t.position=e+t.offset,d(t)}}p("{"),this.body=f(0),p("}")}return this})),y("(",(function(){for(var t=[];")"!==a.id&&(t.push(f(0)),";"===a.id);)p(";");return p(")",!0),this.type="block",this.expressions=t,this})),y("[",(function(){var t=[];if("]"!==a.id)for(;;){var e=f(0);if(".."===a.id){var r={type:"binary",value:"..",position:a.position,lhs:e};p(".."),r.rhs=f(0),e=r}if(t.push(e),","!==a.id)break;p(",")}return p("]",!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,p("]"),e}return this.lhs=e,this.rhs=f(t["]"]),this.type="binary",p("]",!0),this})),v("^",t["^"],(function(t){p("(");for(var e=[];;){var r={descending:!1};if("<"===a.id?p("<"):">"===a.id&&(r.descending=!0,p(">")),r.expression=f(0),e.push(r),","!==a.id)break;p(",")}return p(")"),this.lhs=t,this.rhs=e,this.type="binary",this}));var b=function(t){var e=[];if("}"!==a.id)for(;;){var r=f(0);p(":");var n=f(0);if(e.push([r,n]),","!==a.id)break;p(",")}return p("}",!0),void 0===t?(this.lhs=e,this.type="unary"):(this.lhs=t,this.rhs=e,this.type="binary"),this};y("{",b),v("{",t["{"],b),m(":=",t[":="],(function(e){return"variable"!==e.type?d({code:"S0212",stack:(new Error).stack,position:e.position,token:e.value}):(this.lhs=e,this.rhs=f(t[":="]-1),this.type="binary",this)})),v("@",t["@"],(function(e){return this.lhs=e,this.rhs=f(t["@"]),"variable"!==this.rhs.type?d({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=f(t["#"]),"variable"!==this.rhs.type?d({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=f(0),":"===a.id&&(p(":"),this.else=f(0)),this})),y("|",(function(){return this.type="transform",this.pattern=f(0),p("|"),this.update=f(0),","===a.id&&(p(","),this.delete=f(0)),p("|"),this}));var w=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},x=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},S=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)}},E=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 s=t.steps[e--];e>=0&&s.focus&&t.steps[e].focus;)s=t.steps[e--];a=k(s,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 s=r.steps[0];"unary"===s.type&&"["===s.value&&(s.consarray=!0);var o=r.steps[r.steps.length-1];"unary"===o.type&&"["===o.value&&(o.consarray=!0),E(r);break;case"[":var h=r=t(e.lhs),c="predicate";if("path"===r.type&&(h=r.steps[r.steps.length-1],c="stages"),void 0!==h.group)throw{code:"S0209",stack:(new Error).stack,position:e.position};void 0===h[c]&&(h[c]=[]);var u=t(e.rhs);void 0!==u.seekingParent&&(u.seekingParent.forEach((function(t){1===t.level?k(h,t):t.level--})),S(h,u)),h[c].push({type:"filter",expr:u,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 d={type:"sort",position:e.position};d.terms=e.rhs.map((function(e){var r=t(e.expression);return S(d,r),{descending:e.descending,expression:r}})),r.steps.push(d),E(r);break;case":=":(r={type:"bind",value:e.value,position:e.position}).lhs=t(e.lhs),r.rhs=t(e.rhs),S(r,r.rhs);break;case"@":if(r=t(e.lhs),h=r,"path"===r.type&&(h=r.steps[r.steps.length-1]),void 0!==h.stages||void 0!==h.predicate)throw{code:"S0215",stack:(new Error).stack,position:e.position};if("sort"===h.type)throw{code:"S0216",stack:(new Error).stack,position:e.position};e.keepArray&&(h.keepArray=!0),h.focus=e.rhs.value,h.tuple=!0;break;case"#":r=t(e.lhs),h=r,"path"===r.type?h=r.steps[r.steps.length-1]:(r={type:"path",steps:[r]},void 0!==h.predicate&&(h.stages=h.predicate,delete h.predicate)),void 0===h.stages?h.index=e.rhs.value:h.stages.push({type:"index",value:e.rhs.value,position:e.position}),h.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),S(r,r.lhs),S(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 S(r,n),n})):"{"===e.value?r.lhs=e.lhs.map((function(e){var n=t(e[0]);S(r,n);var i=t(e[1]);return S(r,i),[n,i]})):(r.expression=t(e.expression),"-"===e.value&&"number"===r.expression.type?(r=r.expression).value=-r.value:S(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 S(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 p=t(e.body);r.body=w(p);break;case"condition":(r={type:e.type,position:e.position}).condition=t(e.condition),S(r,r.condition),r.then=t(e.then),S(r,r.then),void 0!==e.else&&(r.else=t(e.else),S(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 S(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:"!"+x++,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 f="S0206";"(end)"===e.id&&(f="S0207");var g={code:f,position:e.position,token:e.value};if(i)return l.push(g),{type:"error",error:g};throw g.stack=(new Error).stack,g}return e.keepArray&&(r.keepArray=!0),r};s=r(e),p();var T=f(0);if("(end)"!==a.id){var C={code:"S0201",position:a.position,token:a.value};d(C)}if("parent"===(T=M(T)).type||void 0!==T.seekingParent)throw{code:"S0217",token:T.type,position:T.position};return l.length>0&&(T.errors=l),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=[],s={},o=s;r<e.length;){var l=e.charAt(r);if(":"===l)break;var h=function(){a.push(s),o=s,s={}},c=function(t,e,r,n){for(var i=1,a=e;a<t.length;)if(a++,(l=t.charAt(a))===n){if(0==--i)break}else l===r&&i++;return a};switch(l){case"s":case"n":case"b":case"l":case"o":s.regex="["+l+"m]",s.type=l,h();break;case"a":s.regex="[asnblfom]",s.type=l,s.array=!0,h();break;case"f":s.regex="f",s.type=l,h();break;case"j":s.regex="[asnblom]",s.type=l,h();break;case"x":s.regex="[asnblfom]",s.type=l,h();break;case"-":o.context=!0,o.contextRegex=new RegExp(o.regex),o.regex+="?";break;case"?":case"+":o.regex+=l;break;case"(":var u=c(e,r,"(",")"),d=e.substring(r+1,u);if(-1!==d.indexOf("<"))throw{code:"S0402",stack:(new Error).stack,value:d,offset:r};s.regex="["+d+"m]",s.type="("+d+")",r=u,h();break;case"<":if("a"!==o.type&&"f"!==o.type)throw{code:"S0401",stack:(new Error).stack,value:o.type,offset:r};var p=c(e,r,"<",">");o.subtype=e.substring(r+1,p),r=p}r++}var f="^"+a.map((function(t){return"("+t.regex+")"})).join("")+"$",g=new RegExp(f),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},m=function(t,e){for(var r="^",n=0,i=0;i<a.length;i++){r+=a[i].regex;var s=e.match(r);if(null===s)throw{code:"T0410",stack:(new Error).stack,value:t[n],index:n+1};n=s[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 s=[],o=0;return a.forEach((function(n,a){var l=e[o],h=i[a+1];if(""===h)if(n.context&&n.contextRegex){var c=v(r);if(!n.contextRegex.test(c))throw{code:"T0411",stack:(new Error).stack,value:r,index:o+1};s.push(r)}else s.push(l),o++;else h.split("").forEach((function(r){if("a"===n.type){if("m"===r)l=void 0;else{l=e[o];var i=!0;if(void 0!==n.subtype)if("a"!==r&&h!==n.subtype)i=!1;else if("a"===r&&l.length>0){var a=v(l[0]);i=a===n.subtype.charAt(0)&&0===l.filter((function(t){return v(t)!==a})).length}if(!i)throw{code:"T0412",stack:(new Error).stack,value:l,index:o+1,type:t[n.subtype]};"a"!==r&&(l=[l])}s.push(l),o++}else s.push(l),o++}))})),s}m(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 s,o=!0,l=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return o=t.done,t},e:function(t){l=!0,s=t},f:function(){try{o||null==r.return||r.return()}finally{if(l)throw s}}}}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 s(t){return s="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},s(t)}var o=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 o(t){return t&&(!0===t._jsonata_function||!0===t._jsonata_lambda)||"function"==typeof t}function l(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 h(t){return t&&!0===t._jsonata_lambda}var c=("function"==typeof Symbol?Symbol:{}).iterator||"@@iterator";function u(t){return"object"===s(t)&&null!==t&&c in t&&"next"in t&&"function"==typeof t.next}function d(t,e){if(t===e)return!0;if("object"===s(t)&&"object"===s(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(!d(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(!d(t[a],e[a]))return!1}return!0}return!1}function p(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:o,isLambda:h,isIterable:u,getFunctionArity:l,isDeepEqual:d,stringToArray:p}}();e.exports=o},{}]},{},[3])(3)}(ttt);var ett=ttt.exports;const rtt=function(t){return t};function ntt(t){if(!t)return rtt;try{var e=ett(t);return function(t){return e.evaluate(t)}}catch(t){return console.error(t),rtt}}function itt(t){var e=g9(t);return null==e?"":String(e)}function att(t){return Number(g9(t))}function stt(t){return t}function ott(t){return itt(t)}function ltt(t){return att(t)}function htt(t){if(this.param)return t=itt(t),this.param.hasOwnProperty(t)?this.param[t]:this.param.default}function ctt(t){var{param:e}=this;if(e){for(let r in e){let[n,i]=r.split("~"),a=!!n,s=!!i;if(n=parseFloat(n),i=parseFloat(i),t=att(t),a&&!s&&t>=n)return e[r];if(!a&&s&&t<n)return e[r];if(t>=n&&t<i)return e[r]}return e.default}}function utt(t){return att(t)*Math.PI/180}function dtt(){}function ptt(t,e,r,n,i){switch(r){case"value":return"text"===i||"string"===i?ott.bind(t):"number"===i?ltt.bind(t):stt.bind(e);case"map":return htt.bind(t);case"range":return ctt.bind(t);case"radian":return utt.bind(t);case"eval":return function(t){try{return new Function("value","targets",t)}catch(t){return M9(t),dtt}}(n).bind(e);default:return stt.bind(e)}}class ftt{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=ptt(this,this.owner,n,i,function(t){switch(t){case"ref":case"fillStyle":case"strokeStyle":return"string";default:return}}(r)),this.accessor=ntt(a);const s=e.match(/\[(.*?)\]/);if(s){var[o,l]=s[1].split(":");this.propAccessor=ntt(o),this.partAccessor=ntt(l)}}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 gtt(t,e,r,n){n?t.forEach((t=>t[e]={...t[e],...r})):t.forEach((t=>t[e]=r))}function vtt(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:s,partAccessor:o,ndnsp:l=!1,partial:h=!1}=t;r&&"(self)"!=r?(r.startsWith("#")&&(r=r.substring(1)),e=this.root.findById(r)?.data||{}):e=this.data;var c=a(e);if("(root)"==(n=n.trim())||"(key)"==n){if(null==c)return;let e=Object.keys(c||{}).map((t=>this.root.findOrCreate(t))).filter(Boolean).flat();e.length>0&&e.forEach((e=>{let r=t.evaluator(c[e.get("id")],[e]);!i||"(action)"===i||l&&!r&&0!==r&&!1!==r||(e[i]=h?{...e[i],...r}:r)}))}else if(n.startsWith("[")){if(null==c)return;if(c instanceof Array)c.forEach((e=>{let r=s(e);if(r){let n=this.root.findOrCreate(r);if(n){let r=t.evaluator(o(e),n);!i||"(action)"===i||l&&!r&&0!==r&&!1!==r||gtt(n,i,r,h)}}}));else{if(!(c instanceof Object))throw String("mapping data should be an object to target property-id.("+c+")");{let e=s(c);if(e){let r=this.root.findOrCreate(e);if(r){let e=t.evaluator(o(c),r);!i||"(action)"===i||l&&!e&&0!==e&&!1!==e||gtt(r,i,e,h)}}}}}else{let e=this.root.findAll(n,this);if(e.length>0){let r=t.evaluator(c,e);!i||"(action)"===i||l&&!r&&0!==r&&!1!==r||gtt(e,i,r,h)}}}catch(e){M9(e,this,t)}}))}var mtt;function ytt(t,e,r,n,i){var{alpha:a=1}=n,s=i.fillStyle;if(t.globalAlpha*=a,s)if("string"==typeof s)t.fillStyle=s,t.fill();else if("object"==typeof s)if("gradient"==s.type){t.translate(r.x,r.y);let n,{width:i,height:a}=e;if("linear"==s.gradientType){let e=3.141592653589793,r=s.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 s=Math.sqrt(Math.pow((i-4)/2,2)+Math.pow((a-4)/2,2));s-=s-(i+a)/3,n=t.createLinearGradient(s*Math.cos(r+e),s*Math.sin(r+e),s*Math.cos(r),s*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"==s.gradientType){let e=.95*Math.sqrt(Math.pow((i-4)/2,2)+Math.pow((a-4)/2,2));switch(s.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)}}s.colorStops.forEach((t=>{if(t.position>=0&&t.position<=1)try{n.addColorStop(t.position,t.color)}catch(e){T9("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"==s.type&&s.image){i.prepareFillIf(!i._pattern_image_origin);var o=i._pattern_image;if(!o)return;let r=0,n=0,a=0,l=0,h=e.left,c=e.top;if(!s.fitPattern){r=s.offsetX,n=s.offsetY;const t=s.width?s.width:o.width,i=s.height?s.height:o.height;switch(s.align){case"center":a=e.width/2-t/2,l=e.height/2-i/2;break;case"left-top":a=0,l=0;break;case"left-bottom":a=0,l=e.height-i;break;case"right-top":a=e.width-t,l=0;break;case"right-bottom":a=e.width-t,l=e.height-i;break;case"left":a=0,l=e.height/2-i/2;break;case"right":a=e.width-t,l=e.height/2-i/2;break;case"top":a=e.width/2-t/2,l=0;break;case"bottom":a=e.width/2-t/2,l=e.height-i}h+=r+a,c+=n+l}t.translate(h,c),s.color&&(t.fillStyle=s.color,t.fill()),s.fitPattern?Math.abs((o.width-e.width)*(o.height-e.height))>1?(delete i._pattern_image,delete i._pattern_image_origin):t.fillStyle=t.createPattern(o,"no-repeat"):t.fillStyle=t.createPattern(o,s.noRepeat?"no-repeat":"repeat"),t.fill(),t.translate(-h,-c)}}function btt(t,e,r){var{strokeStyle:n,lineDash:i,lineWidth:a,lineCap:s,lineJoin:o,alpha:l}=e;if(n&&0!=a){if(s&&(t.lineCap=s),i){var h="round"==s;switch(i){case"solid":i=[0,0];break;case"round-dot":i=h?[0,2*a]:[a,a];break;case"square-dot":i=h?[a,2*a]:[2*a,a];break;case"dash":i=h?[3*a,2.5*a]:[4*a,1.5*a];break;case"dash-dot":i=h?[3*a,3*a,0,3*a]:[4*a,2*a,a,2*a];break;case"long-dash":i=h?[5*a,4*a]:[6*a,3*a];break;case"long-dash-dot":i=h?[5*a,3*a,0,3*a]:[6*a,2*a,a,2*a];break;case"long-dash-dot-dot":i=h?[5*a,2*a,0,2*a,0,2*a]:[6*a,a,a,a,a,a]}t.setLineDash(i)}t.globalAlpha*=l,t.strokeStyle=n,t.lineWidth=a,t.lineJoin=o,t.stroke()}}function wtt(t,e,r,n,i,a=0,s=!1,o=!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(),s&&t.fill(),o&&t.stroke()}function xtt(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 Att(t,e,r,n=0){if(e.text.length<2)return e;let i=2;for(;i<e.text.length;i++){const a=e.text.substring(0,i);if(!(t.measureText(a).width+(i-1)*n<r))break}return{...e,text:e.text.substring(0,i-1)}}function _tt(t,e,r,n,i,a=0){const s=String(e).split("\n");return n?[].concat.apply([],s.map((e=>function(t,e,r,n=0){const i=[];let a=[],s=0;return e.forEach((e=>{let o=e.text;for(;o.length>0;){const l=r-s,h=t.measureText(o).width+(o.length-1)*n;if(h<=l)a.push({...e,text:o}),s+=h,o="";else{const r=Att(t,{...e,text:o},l,n);a.push(r),i.push(a),a=[],s=0,o=o.substring(r.text.length)}}})),a.length>0&&i.push(a),i}(t,i?xtt(e):[{text:e,bold:!1,italic:!1}],r,a)))):s.map((t=>i?xtt(t):[{text:t,bold:!1,italic:!1}]))}function ktt(t,e,r,n,i,a,s=0){if(!n)return[];t.save(),t.font=r;var o=_tt(t,n,e,!!i,a,s);return t.restore(),o}function Stt(t){var{fontFamily:e=H9.FONT_FAMILY,bold:r=H9.BOLD,italic:n=H9.ITALIC,fontSize:i=H9.FONT_SIZE}=t,a=[];return r&&a.push("bold"),n&&a.push("italic"),a.push(i+"px"),a.push(e),a.join(" ")}function Ett(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 Mtt(t,e,r,n){var{alpha:i,fontColor:a=H9.FONT_COLOR,textAlign:s=H9.TEXT_ALIGN,textBaseline:o=H9.TEXT_BASELINE,textBackgroundStyle:l,fontSize:h,lineHeight:c,textWrap:u,textOverflow:d,letterSpacing:p=0}=n;i=void 0!==i?i:1,h||=H9.FONT_SIZE,c||=1.2*h,t.save(),t.beginPath();var{left:f,top:g,width:v,height:m}=e;if(t.font=Stt(n),!u&&d){const e=function(t,e,r,n){const i="ellipsis"===t?"…":"",a=e.measureText(i).width;let s=[],o=0;for(let i of r){let r=[];for(let l of i){let i=e.measureText(l.text).width;if(!(o+i<=n-("ellipsis"===t?a:0))){let i=Ttt(e,l,n-o-("ellipsis"===t?a:0),t);return r.push(i),s.push(r),s}r.push(l),o+=i}s.push(r),o=0}return s}(d,t,r,v);r=e}var y,b=r.length*c;switch(o){case"top":y=g,t.textBaseline="top";break;case"bottom":y=g+m-b+c,t.textBaseline="bottom";break;default:y=g+m/2-b/2+c/2,t.textBaseline="middle"}t.globalAlpha*=i,t.fillStyle=a,r.forEach(((e,i)=>{let o=y+i*c,u=function(t,e,r,n=0){return e.reduce(((e,i)=>(t.font=Ett(r,i),e+t.measureText(i.text).width+n*(i.text.length-1))),0)}(t,e,n,p),d=f;switch(s){case"left":case"justify":d=f;break;case"right":d=f+v-u;break;case"center":d=f+(v-u)/2}if(l&&(t.fillStyle=l,wtt(t,d-4,o-h/2-4,u+8,h+8,4,!0,!1),t.fillStyle=a),"justify"===s&&i<r.length-1&&e.length>1){let r=v-u,i=e.length-1,a=r/i;e.forEach(((e,r)=>{t.font=Ett(n,e),t.fillText(e.text,d,o),d+=t.measureText(e.text).width+(r<i?a:0)}))}else e.forEach((e=>{t.font=Ett(n,e),[...e.text].forEach((e=>{t.fillText(e,d,o),d+=t.measureText(e).width+p}))}))})),t.restore()}function Ttt(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 Ctt(t,e,r={x:0,y:0},n=0,i={x:1,y:1}){const a=Math.cos(-n),s=Math.sin(-n);return{x:((t-=r.x)*a-(e-=r.y)*s+r.x)/i.x,y:(t*s+e*a+r.y)/i.y}}function Ptt(t,e,r={x:0,y:0},n=0,i={x:1,y:1}){const a=Math.cos(n),s=Math.sin(n);return{x:((t-=r.x)*a-(e-=r.y)*s+r.x)*i.x,y:(t*s+e*a+r.y)*i.y}}function Itt(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:s}=r;if(i&&(n.backgroundRepeat="no-repeat"),s&&(n.backgroundColor=s),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"}mtt="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 Rtt={x:1,y:1},Ott={x:0,y:0},Ltt={boxSizing:"border-box",margin:"0px",position:"absolute",outline:"none"};function Dtt(t){var{id:e,scale:r=Rtt,translate:n=Ott,bold:i,italic:a,fontFamily:s="",textAlign:o,textBaseline:l,textOverflow:h,paddingTop:c,paddingBottom:u,paddingLeft:d,paddingRight:p,fontSize:f=H9.FONT_SIZE,lineWidth:g=0,lineHeight:v,lineDash:m}=t.state;u||=0,c||=0,d||=0,p||=0;var y=t.state.class;t.text;var{strokeStyle:b,fillStyle:w,rotation:x=0,fontColor:A,hidden:_}=t,{left:k,top:S,width:E,height:M}=t.bounds,T=t.element;if(T.hidden=_,e&&(T.id=e),y&&(T.className=y),Object.assign(T.style,Ltt,{fontFamily:s,fontSize:f+"px",width:E+"px",height:M+"px",paddingTop:c+"px",paddingRight:p+"px",paddingBottom:u+"px",paddingLeft:d+"px",border:g+"px",borderColor:b,borderStyle:g>0?m||H9.LINE_DASH:"",color:A,fontWeight:i?"bold":"",fontStyle:a?"italic":"",textAlign:"end"==o?"right":"start"==o?"left":o,verticalAlign:l,lineHeight:void 0===v?"":v+"px",whiteSpace:h?"nowrap":"",overflow:h?"hidden":"",textOverflow:h||""},t.isIn3DSpace()?{}:{left:k+"px",top:S+"px"}),Itt(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),!t.isIn3DSpace()){var C=t.delta(),P=(r&&r.x||1)*C.sx,I=(r&&r.y||1)*C.sy,R=(x||0)+C.theta,O=C.tx||0,L=C.ty||0;T.style.transform=`rotate(${R}rad) translate(${O}px, ${L}px) scale(${P}, ${I}) perspective(1px)`}}var Ftt,Ntt=[];function jtt(){Ftt=null;var t=performance.now(),e=(Ntt=Ntt.filter((t=>Btt(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=Ntt.indexOf(t);-1!=e?(Ntt.splice(e,1),t.removeSelf(!0)):M9("Should not be here. Maybe reentrance problem.")})),e.next>0&&(Ftt=setTimeout(ztt,Math.max(e.next,500)))}function Btt(t){return!t.disposed&&t.retention>0&&!t.isTemplate()&&t.app&&t.app.isViewMode}var ztt=o9((function(){requestAnimationFrame(jtt)}),500);var Wtt=new class{add(t){Btt(t)&&-1==Ntt.indexOf(t)&&(Ntt.push(t),t.touch()),this.touch()}remove(t){var e=Ntt.indexOf(t);e>0&&Ntt.splice(e,1),this.touch()}touch(){null!==Ftt&&(clearTimeout(Ftt),Ftt=null),ztt()}get length(){return Ntt.length}};const Utt=function(t){return t};function Htt(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)}:Utt}}function Gtt(t,e,r){if(t){var n=r||g9,i=String(t),a=(i.match(/#{[^}]*}/gi)||[]).map((t=>Htt(t))),s=(i.match(/\${[^}]*}/gi)||[]).map((t=>Htt(t)));if(0!=a.length||0!=s.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)})),s.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 Ytt=210*Math.PI/180,Vtt=150*Math.PI/180;var qtt={"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 s=e.createLinearGradient(i.x,i.y,a.x,a.y);["#FFA50033","#FFA500"].forEach(((t,e)=>s.addColorStop(e,t))),e.strokeStyle=s,e.fillStyle=s,function(t,e,r,n=10){var i=r.x-e.x,a=r.y-e.y,s=Math.atan2(a,i),o=r.x+n*Math.cos(s+Ytt),l=r.y+n*Math.sin(s+Ytt),h=r.x+n*Math.cos(s+Vtt),c=r.y+n*Math.sin(s+Vtt);t.beginPath(),t.moveTo(e.x,e.y),t.lineTo(r.x,r.y),t.moveTo(r.x,r.y),t.lineTo(o,l),t.moveTo(r.x,r.y),t.lineTo(h,c),t.stroke()}(e,i,a),n=!0})))})),n}},"bouncing-arrow":function(t,e,r){let{left:n,top:i,width:a}=t.bounds,s=t.state.id,{x:o,y:l}=t.transcoordS2C(n+a/2,i,t.rootModel);const h=2*function(t){const e=100*(1-t)%10;return e<5?e:10-e}(r||0);if(o=Math.max(o,20),l=Math.max(l,20),e.beginPath(),e.moveTo(o-10,l-16+h),e.lineTo(o+10,l-16+h),e.lineTo(o+10,l-8+h),e.lineTo(o+16,l-8+h),e.lineTo(o,l+h),e.lineTo(o-16,l-8+h),e.lineTo(o-10,l-8+h),e.lineTo(o-10,l-16+h),e.lineTo(o-10,l-16+h),e.fillStyle="#FF0000",e.fill(),s){e.beginPath(),e.font="12px Arial";let t=e.measureText(s);e.fillStyle="#FF0000",e.roundRect(o-t.actualBoundingBoxLeft-3+20,l-t.actualBoundingBoxAscent-3-6+h,t.actualBoundingBoxLeft+t.actualBoundingBoxRight+6,t.actualBoundingBoxAscent+t.actualBoundingBoxDescent+6,3),e.fill(),e.fillStyle="white",e.fillText(s,o+20,l-6+h)}return!0},decotag:function(t,e,r){const n=t.decotag;if(n){let{left:r,top:i}=t.bounds,{x:a,y:s}=t.transcoordS2C(r,i,t.rootModel);a=Math.max(a+3,5),s=Math.max(s-8,15),e.font="12px Arial";let o=e.measureText(n);return e.beginPath(),e.fillStyle="#FF0000",e.roundRect(a-o.actualBoundingBoxLeft-3,s-o.actualBoundingBoxAscent-3,o.actualBoundingBoxLeft+o.actualBoundingBoxRight+6,o.actualBoundingBoxAscent+o.actualBoundingBoxDescent+6,3),e.fill(),e.beginPath(),e.fillStyle="white",e.fillText(n,a,s),!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:s,y:o}=a||{};if(!i)return;var{x:s,y:o}=t.transcoordS2C(s,o,t.rootModel);s+=4,o+=4,e.font="12px Arial";let l=e.measureText(i);e.fillStyle="#FF0000",wtt(e,s,o,l.width+6,16,3,!0,!1),e.fillStyle="white",e.fillText(i,s+3,o+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:s}=i||{};if(!a||!s)return;var{x:o,y:l}=s||{},{x:o,y:l}=r.transcoordS2C(o,l,r.rootModel);o+=8,l+=20,e.font="12px Arial";let h=e.measureText(a);e.fillStyle="#FF0000",wtt(e,o-h.actualBoundingBoxLeft-4,l-h.actualBoundingBoxAscent-4,h.actualBoundingBoxLeft+h.actualBoundingBoxRight+8,h.actualBoundingBoxAscent+h.actualBoundingBoxDescent+8,4,!0,!1),e.fillStyle="white",e.fillText(a,o,l),n=!0})),n}};function Xtt(t){return qtt[t]}var $tt={};const Ktt={mutable:!1,resizable:!0,rotatable:!0,properties:[],"value-property":"text"},Qtt=[],Jtt={theta:0,tx:0,ty:0,sx:1,sy:1,fade:0};var Ztt=0,tet={};const eet=new FinalizationRegistry((t=>{!function(t){Ztt--;var e=tet[t];e||(e=tet[t]={up:0,down:0}),e.down++}(t)}));class ret{static get nature(){return Ktt}static register(t,e){if(!e)return $tt[t];$tt[t]=e}static get residents(){return tet}static get residentsCount(){return Ztt}static registerDecorator(t,e){!function(t,e){qtt[t]=e}(t,e)}constructor(t,e){this._app=e,this._model=t||{},this._state={},this._delta=X7(Jtt),e&&this.animation?.config&&(1==this.animation.config.autoplay||(this.animation.config.autoplay??1))&&(this.animation.started=!0),this.clearCache(),Wtt.add(this),function(t){Ztt++;var e=tet[t];e||(e=tet[t]={up:0,down:0}),e.up++}(t.type),eet.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)}resetAnimation(){this._animation&&(this._animation.dispose(),this._animation=null,this._delta=X7(Jtt))}dispose(){this.resetAnimation(),this.disposeMappings(),this.parent&&this.parent.removeComponent(this),delete this._text_substitutor,delete this._value_substitutor,this._disposed=!0,this.retention&&Wtt.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}isIn3DSpace(){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=X7(this._model);return this.volatile.forEach((e=>{delete t[e]})),t}get volatile(){return Qtt}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=X7(t),this);return Object.getOwnPropertyNames(t).forEach((function(e){let s=a._model[e],o=t[e];p8(s,o)||(n[e]=s,r[e]=o,a._model[e]=o,delete a._state[e],i=!0)})),i&&(this.clearCache(),r.hasOwnProperty("text")&&delete this._text_substitutor,r.hasOwnProperty("retention")&&Wtt.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=X7(t),this),s=this.getState("sensitive");return Object.getOwnPropertyNames(t).forEach((function(e){let o=a.getState(e),l=t[e];!s&&p8(o,l)||(n[e]=o,r[e]=l,a._state[e]=l,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 s=i[a];s.x<t?t=s.x:s.x>e&&(e=s.x),s.y<r?r=s.y:s.y>n&&(n=s.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 M9("이 컴포넌트에 get path 가 구현되어있지 않음.",this),[]}set path(t){M9("이 컴포넌트에 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,s=e.y-t.y;i.push(Math.sqrt(a*a+s*s)),n++}var a=i.reduce((function(t,e){return t+e}),0);n=0;var s=0;do{s+=i[n++]}while(s/a<e);e=(e-(s-=i[--n])/a)*(a/i[n]);var o=r[n%r.length],l=r[(n+1)%r.length],h=o.x+Math.round((l.x-o.x)*e),c=o.y+Math.round((l.y-o.y)*e);return t.transcoordS2T(h,c)}M9("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(g9(t)))}get rotation(){return this.getState("rotation")}set rotation(t){this.setState("rotation",Number(g9(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,s=t.top-e.top;return 0!=a&&0!=s?(s=-i,a=-n):0!=a?a=-n:0!=s&&(s=-i),{left:e.left+a,top:e.top+s,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?J9(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=>{M9(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.prerender(t),this.render(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,s=(r&&r.x||1)*this._delta.sx,o=(r&&r.y||1)*this._delta.sy,l=(n||0)+this._delta.theta,{tx:h=0,ty:c=0}=this._delta,u=(a||1)-this._delta.fade;(h||c)&&t.translate(h,c),(1!=s||1!=o||l)&&(t.translate(e.x,e.y),1==s&&1==o||t.scale(s,o),l&&t.rotate(l),t.translate(-e.x,-e.y)),u&&(t.globalAlpha=u),i&&Y9(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&&Mtt(t,this.textBounds,this.textLines(t),this.state)}drawStroke(t,e){btt(t,e?{...this.state,...e}:this.state)}drawFill(t,e){this.fillStyle&&"transparent"!=this.fillStyle&&(ytt(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=w7(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=X7(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=b7(this,t.oncreate))}return this._animation}}effect(t,e){return function(t,e,r){var n=V9[r.type];n&&n(t,e,r)}(this,t,e)}get started(){return!!this.animation?.started}set started(t){this.animation&&(this.animation.started=t)}invalidate(){this.parent&&this.parent.invalidate()}get font(){return Stt(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=Gtt(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,s,o,l,h,c,u=t.length,d=t.search(/[0-9\-\+#]/),p=d>0?t.substring(0,d):"",f=t.split("").reverse().join(""),g=f.search(/[0-9\-\+#]/),v=u-g,m=t.substring(v,v+1),y=v+("."===m||","===m?1:0),b=g>0?t.substring(y,u):"";if(r=(e="-"===(t=t.substring(d,y)).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))+"",s=t[1]&&t[1].lastIndexOf("0"),(!(l=e.split("."))[1]||l[1]&&l[1].length<=s)&&(e=(+e).toFixed(s+1)),h=t[0].split(i),t[0]=h.join(""),(a=t[0]&&t[0].indexOf("0"))>-1)for(;l[0].length<t[0].length-a;)l[0]="0"+l[0];else 0==+l[0]&&(l[0]="");if((e=e.split("."))[0]=l[0],o=h[1]&&h[h.length-1].length){for(f="",v=(c=e[0]).length%o,u=c.length,y=0;y<u;y++)f+=c.charAt(y),!((y-v+1)%o)&&y<u-o&&(f+=i);e[0]=f}return e[1]=t[1]&&e[1]?"."+e[1]:"","0"!==(n=e.join(""))&&""!==n||(r=!1),p+("+"==t[0].substring(0,1)?r?"-":"+":r?"-":"")+n+b}(t,this.textSubstitutor()):this.textSubstitutor()}set text(t){delete this._text_substitutor;var e=g9(t);this.setState("text",null==e?"":String(e))}textLines(t){const{textWrap:e,supportMarkdown:r}=this.state;return ktt(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:s,height:o}=this.bounds;return{left:i+e,top:a+t,width:Math.max(s-e-r,0),height:Math.max(o-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)}}ret.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}},ret.transcoordR=Ctt,ret.transcoordRR=Ptt,ret.createCanvas=mtt,ret.memoize=P9,ret.mixin=E9,ret.drawText=Mtt,ret.font=Stt,ret.textLines=ktt,ret.drawStroke=btt,ret.drawFill=ytt,ret.reposition=Dtt,ret.RetentionManager=Wtt,ret.template=function(t,e,r){var n=o7.imports._.templateSettings||o7;r&&T8(t,e,r)&&(e=void 0),t=i7(t),e=L8({},e,n,q8);var i,a,s=L8({},e.imports,n.imports,q8),o=U6(s),l=function(t,e){return G8(e,(function(e){return t[e]}))}(s,o),h=0,c=e.interpolate||p7,u="__p += '",d=RegExp((e.escape||p7).source+"|"+c.source+"|"+(c===K8?d7:p7).source+"|"+(e.evaluate||p7).source+"|$","g"),p=g7.call(e,"sourceURL")?"//# sourceURL="+(e.sourceURL+"").replace(/\s/g," ")+"\n":"";t.replace(d,(function(e,r,n,s,o,l){return n||(n=s),u+=t.slice(h,l).replace(f7,$8),r&&(i=!0,u+="' +\n__e("+r+") +\n'"),o&&(a=!0,u+="';\n"+o+";\n__p += '"),n&&(u+="' +\n((__t = ("+n+")) == null ? '' : __t) +\n'"),h=l+e.length,e})),u+="';\n";var f=g7.call(e,"variable")&&e.variable;if(f){if(u7.test(f))throw new Error("Invalid `variable` option passed into `_.template`")}else u="with (obj) {\n"+u+"\n}\n";u=(a?u.replace(l7,""):u).replace(h7,"$1").replace(c7,"$1;"),u="function("+(f||"obj")+") {\n"+(f?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(i?", __e = _.escape":"")+(a?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+u+"return __p\n}";var g=H8((function(){return Function(o,p+"return "+u).apply(void 0,l)}));if(g.source=u,W8(g))throw g;return g},ret.buildSubstitutor=Gtt,Object.assign(ret.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=mtt(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=>{M9(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 s=t.call(e,r);s&&(r=s)}var{left:o,top:l,width:h,height:c}=r,u=[{x:o,y:l},{x:o+h,y:l+c}],d=(u=u.map((t=>Ptt(t.x,t.y,n,i,a))))[0],p=u[1];n={x:(d.x+p.x)/2,y:(d.y+p.y)/2},d=(u=u.map((t=>Ctt(t.x,t.y,n,i,a))))[0],p=u[1],this.bounds={left:d.x,top:d.y,width:p.x-d.x,height:p.y-d.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 s,o,l,h,c={x:0,y:0};s=o=(n=a.map((t=>this.transcoordP2S(t.x,t.y,c))))[0].x,l=h=n[0].y;for(let t=1;t<n.length;t++){let e=n[t];e.x<s?s=e.x:e.x>o&&(o=e.x),e.y<l?l=e.y:e.y>h&&(h=e.y)}i={x:(s+o)/2,y:(l+h)/2},i=this.transcoordS2P(i.x,i.y,c),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=>Htt(t)))[0];if(r)return r.accessor(this.getState(r.target));var n=(e.match(/\${[^}]*}/)||[]).map((t=>Htt(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||g9,i=(r.match(/#{(\S*)}/gi)||[]).map((t=>Htt(t))),a=(r.match(/\${[^}]*}/gi)||[]).map((t=>Htt(t)));if(0==i.length&&0==a.length)return r;var s=r;return i.forEach((t=>{let e=n(t.accessor(this.getState(t.target)));s=s.replace(t.match,void 0===e?"":e)})),a.forEach((t=>{let e=this.root.findById(t.target),r=n(t.accessor(e&&e.data));s=s.replace(t.match,void 0===r?"":r)})),s}},onchangeMappings:function(t,e){this.disposeMappings(),vtt.call(this)},onchangeData:function(t,e){this.state.persistent&&this.app?.isViewMode&&this.app?.dataStorage.save(this,t.data),vtt.call(this,[!0])},buildMappings:function(){if(this._model.mappings)return!this._model.mappings instanceof Array?(M9("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 ftt(t,this))));this._mappings=[]},executeMappings:vtt,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};let{rotation:n=0,scale:i={x:1,y:1}}=this.state;if(this.isLayer()){const r=this.state.translate;let a=Ptt(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:s=0,ty:o=0,sx:l=1,sy:h=1}=this._delta||{};r={x:r.x+s,y:r.y+o},i={x:i.x*l,y:i.y*h};const c=Ptt(t+s,e+o,r,n+a,i);return{x:c.x-(r.x*i.x-r.x),y:c.y-(r.y*i.y-r.y)}},transcoordP2S:function(t,e,r){if(!this.parent)return{x:t,y:e};const{rotation:n=0,scale:i={x:1,y:1}}=this.state;if(this.isLayer()){const r=this.state.translate;let a=Ctt(t,e,r,n,i);return r&&(a.x-=r.x/i.x,a.y-=r.y/i.y),a}const a=Ctt(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;const n=[];for(let t=this.parent;t&&t!==r;t=t.parent)n.push(t);let i=this.transcoordS2P(t,e);return n.forEach((t=>{const{scale:e}=t.model,r=t.bounds;if(e){const 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;const n=[];for(let t=this.parent;t&&t!==r;t=t.parent)n.splice(0,0,t);let i={x:t,y:e};return n.forEach((t=>{const{scale:e}=t.model;i=t.transcoordP2S(i.x,i.y);const r=t.bounds;if(e){const 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){const n=this.transcoordT2P(t,e,r);return this.transcoordP2S(n.x,n.y)},transcoordS2TR:function(t,e,r){r=r||this.rootModel;const n=this.transcoordS2T(t,e,r);return Ptt(n.x,n.y,void 0,(r.get("rotation")||0)+r._delta.theta)},transcoordS2O:function(t,e,r){const 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;const{translate:n={x:0,y:0},scale:i={x:1,y:1},rotation:a=0}=r.model;let s=Ctt(t,e,n,a,i);return n&&(s.x-=n.x/i.x,s.y-=n.y/i.y),r===this?s:this.transcoordT2S(s.x,s.y,r)},transcoordS2C:function(t,e,r){if(!r)for(r=this;r&&!r.isLayer();)r=r.parent;let n;n=r!==this?this.transcoordS2T(t,e,r):{x:t,y:e};const{translate:i={x:0,y:0},rotation:a=0,scale:s={x:1,y:1}}=r.model;return n=Ptt(n.x,n.y,void 0,a+r._delta.theta,s),i&&(n.x+=i.x,n.y+=i.y),n}}),["rotatePoint","font","lineHeight","retention"].forEach((t=>ret.memoize(ret.prototype,t,!1))),["bounds","center","textBounds"].forEach((t=>ret.memoize(ret.prototype,t,!0))),ret.mixin(ret.prototype,x9.withEvent);class net extends ret{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 l=e[(n-1+e.length)%e.length],h=e[(n+e.length)%e.length],c=e[(n+1)%e.length];if(l.x===h.x&&l.y===h.y)continue;var i=0!==(o=Math.sqrt((l.x-h.x)*(l.x-h.x)+(l.y-h.y)*(l.y-h.y)))?Math.atan2(l.x-h.x,l.y-h.y):0,a=Math.sin(i)*Math.min(r,o/2)+h.x,s=Math.cos(i)*Math.min(r,o/2)+h.y;const u=r>0||0!==o?{x:a,y:s}:h;var o;i=0!==(o=Math.sqrt((c.x-h.x)*(c.x-h.x)+(c.y-h.y)*(c.y-h.y)))?Math.atan2(c.x-h.x,c.y-h.y):0,a=Math.sin(i)*Math.min(r,o/2)+h.x,s=Math.cos(i)*Math.min(r,o/2)+h.y;const d=r>0||0!==o?{x:a,y:s}:h;0==n?t.moveTo(u.x,u.y):t.lineTo(u.x,u.y),r>0&&t.quadraticCurveTo(h.x,h.y,d.x,d.y)}t.closePath()}}}function iet(t,e,r){return Math.max(0,Math.min(t,Math.min(r,e)/2))}var aet=t=>{var e=class extends t{contains(t,e){var{left:r,top:n,width:i,height:a,lineWidth:s=0}=this.state,o=s/2;return t<Math.max(r+i,r)+o&&t>Math.min(r+i,r)-o&&e<Math.max(n+a,n)+o&&e>Math.min(n+a,n)-o}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,s=r+i/2;return[{name:"TOP",position:{x:a,y:r}},{name:"RIGHT",position:{x:e+n,y:s}},{name:"BOTTOM",position:{x:a,y:r+i}},{name:"LEFT",position:{x:e,y:s}}]}(this)}get bounds(){const{left:t=0,top:e=0,width:r=0,height:n=0}=this.state;return{left:t,top:e,width:r,height:n}}set bounds(t){this.set({left:0,top:0,width:0,height:0,...t})}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=iet(e,i,a))>0?t.roundRect(0,0,i,a,e):t.rect(0,0,i,a),t.translate(-r,-n)}};return P9(e.prototype,"path",!1),e};const set={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 oet=20;function het(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 cet extends(aet(net)){static get image(){return cet._image||(cet._image=new Image,cet._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=="),cet._image}static toggle(t,e,r,n){if(e){var i=t.root.findById(e);i?i._findInfoWindowByComponent(t)?cet.hide(t,e):cet.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:s=""}=i.model,o=[a,s].filter((t=>String(t).trim()));if(o=o.map((t=>ret.template(function(t,e,r){return(e||r?['<div class="info-window-btns">',e?'<button class="closable">X</button>':"",r?'<button class="flipable">⇌</button>':"","</div>"]:[]).concat(['<div class="info-window-content">',t,"</div>"]).join("")}(t,!r,2==o.length)))),0!=o.length){var l='\n.flip {\n backface-visibility: hidden;\n border-radius: 7px;\n height: auto;\n font: normal 14px helvetica, arial, san serif;\n position: absolute;\n opacity: 0.9;\n transform-origin: 50% 50% 0px;\n transition: all 2s;\n min-width: 100px;\n 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}\n\n.flip:after {\n content: "";\n display: block;\n position: absolute;\n opacity: 0.9;\n width: 0;\n height: 0;\n}\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\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\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\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}\n\n.flip-side-1 {\n transform: rotateY(0deg) !important;\n}\n\n.flip-side-2 {\n transform: rotateY(180deg) !important;\n}\n\n.info-window-btns {\n position: absolute;\n top: -18px;\n right: 5px;\n overflow: hidden;\n}\n\n.info-window-content {\n padding: 10px;\n color: #efefef;\n font-size: 13px;\n line-height: 1.4;\n}\n\n.info-window-btns button {\n width: 40px;\n 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\n.info-window-btns button:hover {\n background-color: #60bb23;\n}\n'+i.get("style"),{left:h,top:c}=t.bounds,{x:u,y:d}=n?t.rootModel.transcoordC2S(n.x,n.y):t.transcoordS2T(h,c);h=u,c=d;var p=document.createElement("span");p.style.position="absolute";var f=document.createElement("style");if(f.type="text/css",f.appendChild(document.createTextNode(l)),p.appendChild(f),o[0]){var g=document.createElement("div");g.id="side-1",g.className="flip",g.style.display="inline-block",g.innerHTML=o[0](t)}if(o[1]){var v=document.createElement("div");v.id="side-2",v.className="flip",v.style.display="inline-block",v.innerHTML=o[1](t)}W9.forEach((function(t){p.addEventListener(t,(function(t){t.stopPropagation()}))})),U9.forEach((function(t){p.addEventListener(t,(function(t){t.stopPropagation()}))}));var m=t.root.model_layer.overlay;if(g&&p.appendChild(g),v&&p.appendChild(v),m.appendChild(p),i._addInfoWindow(t,p,f),g){let r=g.querySelector(".info-window-btns > .flipable");r&&r.addEventListener("click",(function(t){t.preventDefault(),v.className=het(v.className,"flip-side-1"),g.className=het(g.className,"flip-side-2")}),!1);let n=g.querySelector(".info-window-btns > .closable");n&&n.addEventListener("click",(function(r){r.preventDefault(),cet.hide(t,e)}),!1)}if(v){let r=v.querySelector(".info-window-btns > .flipable");r&&r.addEventListener("click",(function(t){t.preventDefault(),v.className=het(v.className,"flip-side-1"),g.className=het(g.className,"flip-side-2")}),!1);let n=v.querySelector(".info-window-btns > .closable");n&&n.addEventListener("click",(function(r){r.preventDefault(),cet.hide(t,e)}),!1)}var y=g.offsetWidth,b=g.offsetHeight;window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight;var w=t.rootModel.target.getBoundingClientRect(),x=[];g&&x.push(g),v&&x.push(v);var A={x:h,y:c},_=t.transcoordS2C(A.x,A.y);if(_.x+y/2+w.left<w.right&&_.x-y/2>w.left){if(b+oet<_.y)return p.style.marginLeft=A.x-y/2+"px",p.style.marginTop=A.y-b-oet+"px",void x.forEach((t=>t.className+=" arrow-bottom"));if(_=t.transcoordS2C(A.x,A.y+b+oet),w.bottom>_.y+w.top)return p.style.marginLeft=A.x-y/2+"px",p.style.marginTop=A.y+oet+"px",void x.forEach((t=>t.className+=" arrow-top"))}if((_=t.transcoordS2C(A.x,A.y)).x-(y+oet)>w.left)return p.style.marginLeft=A.x-y-oet+"px",p.style.marginTop=A.y-b/2+"px",void x.forEach((t=>t.className+=" arrow-right"));p.style.marginLeft=A.x+oet+"px",p.style.marginTop=A.y-b/2+"px",x.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,cet.image,e,r,n,i)}get hasTextProperty(){return!1}get nature(){return set}}ret.register("info-window",cet);var uet={};var det={list:function(){return{...uet}},register:function(t,e){uet[t]=e},unregister:function(t){delete uet[t]},get:function(t){if(t){var e=uet[t];return e||M9("Layout Not Found - ",t),e}}},pet={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};det.register("html-absolute",pet);const fet=["run","goto","goto-playlist","link-open","link-move","route-page","start-scenario","run-scenario","export-data","import-data"],get="auto";const vet=new WeakMap;function met(t){const e=t.root,r=vet.get(e);if(!r)return;if(e===t)return r.forEach((t=>met(t[0]))),void vet.delete(e);const n=r.findIndex((e=>e[0]===t));if(-1===n)return;const i=r[n][1];i.div.parentNode?.removeChild(i.div),i.scene.target=null,i.scene.release?.(),r.splice(n,1)}class yet{static hideAll(t){(vet.get(t)||[]).forEach((([t])=>met(t)))}static hide(t){const e=t.root,r=vet.get(e);if(!r)return;const n=r.findIndex((e=>e[0]===t));if(-1===n)return;const i=r[n][1];i.div.style.backgroundColor="transparent",function(t,e){t.style.opacity=1,t.style.transform="scale(1)";let r=+new Date;const n=()=>{const i=Math.min((new Date-r)/200,1);t.style.opacity=1-i,t.style.transform=`scale(${1-i})`,i<1?requestAnimationFrame(n):(t.style.display="none",e&&e())};n()}(i.div,(()=>{met(t)}))}static show(t,e,r={}){const{data:n,modal:i=!1,closable:a=!0,minimizable:s=!1,draggable:o=!1,output:l=!0,title:h=""}=r,c=t.app.refProvider;c?.get(e,!0).then((e=>{const c=document.createElement("div"),u=c.style;if(c.setAttribute("popup",""),i){const{width:e,height:r}=t.rootModel.bounds;Object.assign(u,{position:"fixed",zIndex:1,left:0,top:0,width:`${e}px`,height:`${r}px`,overflow:"hidden",backgroundColor:"transparent"})}else Object.assign(u,{position:"absolute",display:"inline-block",overflow:"hidden"});c.innerHTML=h?'\n<div class="popup-wrap">\n <div class="popup-title-bar">\n <div class="popup-title"></div>\n <button class="draggable-1945">drag_pan</button>\n <button class="minimizable-1945">minimize</button>\n <button class="closable-1945">close</button>\n </div>\n <div class="popup-content"></div>\n</div>\n':'\n<div class="popup-content">\n <button class="draggable-1945">drag_pan</button>\n <button class="minimizable-1945">minimize</button>\n <button class="closable-1945">close</button>\n</div>\n';const d=c.querySelector(".popup-content"),{width:p,height:f}=e.root.model;Object.assign(d.style,{width:`${p}px`,height:`${f}px`});const g=document.createElement("style");g.type="text/css",g.appendChild(document.createTextNode("\n.popup-title-bar {\n display: flex;\n align-items: center;\n top: 0;\n left: 0;\n width: 100%;\n height: 30px;\n background-color: var(--md-sys-color-primary, #f1f1f1);\n color: var(--md-sys-color-on-primary, black);\n padding: 5px;\n box-sizing: border-box;\n border-bottom: 1px solid #ccc;\n}\n\n.popup-title {\n flex: 1;\n text-align: center;\n}\n\nbutton.closable-1945, button.minimizable-1945, button.draggable-1945 {\n position: absolute;\n display: none;\n color: white; \n background-color: black; \n opacity: .3;\n width: 20px;\n height: 20px;\n top: 5px; \n z-index: 1;\n padding: 0;\n margin: 0;\n border: 0px;\n text-align: center;\n cursor: pointer;\n border-radius: 4px;\n font-family: Material Symbols Outlined;\n font-size: 12px;\n}\n\nbutton.draggable-1945 {\n right: 55px;\n cursor: move;\n}\n\nbutton.minimizable-1945 {\n right: 30px;\n}\n\nbutton.closable-1945 {\n right: 5px;\n}\n\nbutton.closable-1945:hover, button.minimizable-1945:hover, button.draggable-1945:hover {\n opacity: .6; \n}\n")),c.appendChild(g),fet.forEach((r=>{e.on(r,((...e)=>{t.trigger(r,...e)}))}));const v=c.querySelector(".popup-content"),m=c.querySelector(".draggable-1945");[...W9,...U9].forEach((t=>{v.addEventListener(t,(t=>{t.stopPropagation()}))})),[...W9,...U9].forEach((t=>{c.addEventListener(t,(t=>{t.stopPropagation()}))})),i&&a&&c.addEventListener("click",(e=>{e.target===c&&yet.hide(t)}));if(t.root.model_layer.overlay.appendChild(c),function(t,e,r){const n=t.root;if(n===t)return;met(t);let i=vet.get(n)||[];i=[...i,[t,{div:e,scene:r}]],vet.set(n,i)}(t,c,e),h){c.querySelector(".popup-title-bar .popup-title").textContent=h}if(o&&(!function(t,e,r){let n,i,a,s;e.addEventListener("mousedown",(e=>{function o(e){e.preventDefault(),e.stopPropagation();const o=e.clientX-n,l=e.clientY-i,h=r.rootModel.overlay.style.transform.match(/scale\(([^,]+),\s*([^)]+)\)/),c=h?parseFloat(h[1]):1,u=h?parseFloat(h[2]):c;t.style.left=`${a+o/c}px`,t.style.top=`${s+l/u}px`}e.preventDefault(),e.stopPropagation(),n=e.clientX,i=e.clientY,a=parseInt(t.style.left,10)||0,s=parseInt(t.style.top,10)||0,document.addEventListener("mousemove",o,!0),document.addEventListener("mouseup",(function t(e){e.preventDefault(),e.stopPropagation(),document.removeEventListener("mousemove",o,!0),document.removeEventListener("mouseup",t,!0)}),!0)}))}(i?c.querySelector(".popup-wrap"):c,c.querySelector(".popup-title-bar"),t),h?m&&(m.style.display="block"):(v.addEventListener("mouseenter",(()=>{m&&(m.style.display="block")})),v.addEventListener("mouseleave",(()=>{m&&(m.style.display="none")})))),s){const t=c.querySelector(".minimizable-1945");let e=!1;t.addEventListener("click",(t=>{t.preventDefault(),e=!e;const r=c.querySelector(".popup-wrap");!function(t,e){const r=t.querySelector(".minimizable-1945");e?(r.innerHTML="crop_square",t.style.height="30px",t.style.overflow="hidden"):(r.innerHTML="minimize",t.style.height="",t.style.overflow="visible")}(i?r:c,e)})),h?t&&(t.style.display="block"):(v.addEventListener("mouseenter",(()=>{t&&(t.style.display="block")})),v.addEventListener("mouseleave",(()=>{t&&(t.style.display="none")})))}if(a){const t=c.querySelector(".closable-1945");h?t&&(t.style.display="block"):(v.addEventListener("mouseenter",(()=>{t&&(t.style.display="block")})),v.addEventListener("mouseleave",(()=>{t&&(t.style.display="none")})))}c.querySelector(".closable-1945")?.addEventListener("click",(e=>{e.preventDefault(),yet.hide(t)})),c.addEventListener("close-scene",(e=>{e.preventDefault(),e.stopPropagation(),yet.hide(t),l&&(t.data=e.detail)})),e.target=d,e.data=n||t.data,e.fit("both");const{x:y,y:b}=t.center,w=t.transcoordS2T(y,b,t.rootModel),x=function(t,e,r,n){const{location:i=get,title:a=""}=n||{},s=t.bounds;let o=e.bounds;a&&(o.height+=30);const l=Math.max(s.width/4-o.width/2,20),h=Math.min(3*s.width/4+o.width/2,s.width-20)-o.width,c=Math.max(s.height/4-o.height/2,20)+(a?30:0),u=Math.min(3*s.height/4+o.height/2,s.height-20)-o.height+(a?30:0);switch(i){case get:return{x:r.x<s.width/2?Math.min(h,r.x+20):Math.max(l,r.x-(o.width+20)),y:r.y<s.height/2?Math.min(u,r.y+20+(a?30:0)):Math.max(c,r.y-(o.height+20+(a?30:0)))};case"left-top":return{x:l,y:c};case"right-top":return{x:h,y:c};case"left-bottom":return{x:l,y:u};case"right-bottom":return{x:h,y:u};default:return{x:(s.width-o.width)/2,y:(s.height-o.height+(a?30:0))/2}}}(t.rootModel,e.root,w,r);if(i)if(h){const t=c.querySelector(".popup-wrap");Object.assign(t.style,{position:"absolute",left:`${x.x}px`,top:`${x.y}px`,width:`${p}px`,height:`${f}px`})}else Object.assign(d.style,{left:`${x.x}px`,top:`${x.y}px`,width:`${p}px`,height:`${f}px`});else Object.assign(c.style,{left:`${x.x}px`,top:`${x.y}px`,width:`${p}px`,height:`${h?f+30:f}px`});!function(t,e){t.style.opacity=0,t.style.transform="scale(0)",t.style.display="block";let r=+new Date;const n=()=>{const i=Math.min((new Date-r)/200,1);t.style.opacity=i,t.style.transform=`scale(${i})`,i<1?requestAnimationFrame(n):e&&e()};n()}(c,(()=>{i&&(c.style.backgroundColor="rgba(0,0,0,0.3)")}))}),(t=>{console.error("cannot fetch board: "+e,t)}))}}var bet={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 wet(t){var e=t.components.filter((t=>!t.hidden)),r=t.getState("layoutConfig")||{},n=e[r&&r.activeIndex||0];return n&&[n]||[]}det.register("absolute",bet);var xet={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 wet(t)},drawables:function(t){return wet(t)},isStuck:function(t){return!0}};function Aet(t){var e=t.getState("layoutConfig");return e&&e.weight||1}det.register("card",xet);var _et={reflow:function(t){var e=this.drawables(t),r=t.get("padding")||{},n=e.reduce(((t,e)=>t+Aet(e)),0),i=t.bounds,a=n>0?(i.width-((r.left||0)+(r.right||0)))/n:i.width,s=i.height-((r.top||0)+(r.bottom||0)),o=0;e.forEach((t=>{let e=Aet(t),n=t.get("margin")||{};t.bounds={left:a*o+(r.left||0)+(n.left||0),top:0+(r.top||0)+(n.top||0),width:e*a-((n.left||0)+(n.right||0)),height:s-((n.top||0)+(n.bottom||0))},t.setState("rotation",0),o+=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 ket(t){var e=t.getState("layoutConfig");return e&&e.weight||1}det.register("linear-horizontal",_et);var Eet={reflow:function(t){var e=this.drawables(t),r=t.getState("padding")||{},n=e.reduce(((t,e)=>t+ket(e)),0),i=t.bounds,a=n>0?(i.height-((r.top||0)+(r.bottom||0)))/n:i.height,s=i.width-((r.left||0)+(r.right||0)),o=0;e.forEach((t=>{let e=ket(t),n=t.getState("margin")||{};t.bounds={left:0+(r.left||0)+(n.left||0),top:a*o+(r.top||0)+(n.top||0),width:s-((n.left||0)+(n.right||0)),height:e*a-((n.top||0)+(n.bottom||0))},t.setState("rotation",0),o+=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}};det.register("linear-vertical",Eet);var Met={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"),s=i?i.filter(((t,e)=>e<r)).reduce(((t,e)=>t+e),0):r,o=a?a.filter(((t,e)=>e<n)).reduce(((t,e)=>t+e),0):n,l=t.textBounds,h=t.getState("paddingLeft")||0,c=t.getState("paddingTop")||0,u=l.width/s,d=l.height/o,p=0,f=0;t.components.forEach(((t,e)=>{let n=i?i[e%r]:1,s=a?a[Math.floor(e/r)]:1,o=t.colspan||1,l=0;for(;--o>0;)l+=i?i[(e+o)%r]:1;let g=t.rowspan||1,v=0;for(;--g>0;)v+=a?a[Math.floor(e/r)+g]:1;t.bounds={left:h+p,top:c+f,width:u*(n+l),height:d*(s+v)},t.setState("rotation",0),e%r==r-1?(p=0,f+=s*d):p+=n*u}))},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:s,column:o}=t.getRowColumn(e);switch(r.code){case"ArrowUp":if(s>0)return t.getAt((s-1)*i+o);break;case"ArrowDown":if(s<a-1)return t.getAt((s+1)*i+o);break;case"ArrowRight":if(o<i-1)return t.getAt(s*i+o+1);break;case"ArrowLeft":if(o>0)return t.getAt(s*i+o-1);break;default:return e}},joinType:!0};det.register("table",Met);const Tet=new Image;Tet.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAAclBMVEVHcEwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAC0BbqFAAAAJXRSTlMAgAP3VSI6/g9fBk5FavJsMrariSjzPnO1enRRL5SMhmOOWB9keFTE0wAAANxJREFUOMutk9kWgyAMRLFuiLjUtdp9yf//YglVsQXz1HniMPcEMgHGvpX2O0Ypi+EgCL+IAShC+wB7QfubRDT7AFcnUPoLMLiP4PyJbsb55i05AgnR5iaQDsICgtH0cotBWoAP1c7kC6kFxEseCfZfB6gEgbNeBrira2QmH1uVYCXlA3is8UmgUCPIyQJKEmu8QtQJN0e9DPXVpzG2G216c1CqRmcBOdxXk07sWUSPv07zo0amCNQycv+NzmR6cRcwmfbuI7p2nZ/z4be0P83Foz6vIkhfZXr82XgDlZsspIq4peUAAAAASUVORK5CYII=";var Cet=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(Tet,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:s}=this.bounds,o=n+a;this.showMoveHandle&&(r=t<Math.max(o+25,o)&&t>Math.min(o+25,o)&&e<Math.max(i+25,i)&&e>Math.min(i+25,i))}return this._focustd!==r&&(this._focused=r,this.invalidate()),r}};const Pet=[];class Iet extends(Cet(aet(ret))){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 det.get(this.get("layout"))||bet}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||Pet).indexOf(t)}size(){return(this._components||Pet).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 J9(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 J9(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:s}=this.state;r=t<Math.max(n+a,n)&&t>Math.min(n+a,n)&&e<Math.max(i+s,i)&&e>Math.min(i+s,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 s=a[t].capture(n.x,n.y,r);if(s)return s}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:s}=this.bounds;for(let e=0;e<t.length;e++){let o=this.transcoordP2S(t[e].x,t[e].y);if(o.x<n||o.x>n+a||o.y<i||o.y>i+s)return!1;o.x-=n,o.y-=i,r.push(o)}let o=this.layout.capturables(this);for(let t=o.length-1;t>=0;t--){let n=o[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=>ret.memoize(Iet.prototype,t,!1)));class Ret extends Iet{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*z9),t.setAttribute("height",n*z9)),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=ret.createCanvas(1,1);return t.setAttribute("scene",this.state.type),t.style.position="absolute",t.style.pointerEvents=this.pointerEvents,t}get pointerEvents(){return"auto"}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*z9,e.y*z9),t.scale(r.x*z9,r.y*z9),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:s}=t.transcoordP2S(n,i),{x:o,y:l}=t.transcoordS2T(a,s),{x:h,y:c}=t.rootModel.get("translate"),{x:u,y:d}=t.rootModel.get("scale");e?w7({step:function(e){t.rootModel.set({translate:{x:h+(r.x-o)*u*e,y:c+(r.y-l)*d*e}})},duration:1e3,delta:"circ",ease:"in"}).start():t.rootModel.set({translate:{x:h+(r.x-o)*u,y:c+(r.y-l)*d}})}}const Oet={x:1,y:1},Let={x:0,y:0};class Det extends Ret{dispose(){super.dispose(),delete this._canvas,delete this._overlay}contains(t,e){return!0}isRootModel(){return!0}get stuck(){return!0}get layout(){return pet}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.setAttribute("scene",this.state.type),t.style["user-select"]="none",t.style.overflow="hidden",this._canvas=ret.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=Let,scale:r=Oet,rotation:n=0}=this.model,{left:i,top:a,width:s,height:o}=this.bounds;t.style.left=i+"px",t.style.top=a+"px",t.style.transform=`rotate(${n}rad) scale(${r.x}, ${r.y}) perspective(1px)`,t.style.marginLeft=`${e.x}px`,t.style.marginTop=`${e.y}px`}}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 Det)&&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:s,emphasize:o=!1,restore:l=!1,pressed:h=!1,options:c}=t;if(a&&(a=e.access(a)),s&&(s=e.access(s)),o&&(r?function(t){const{hover:e}=t.state.event||{},{emphasize:r}=e||{};if(t.hasOwnProperty("_backupStrokeStyle"))return;if("__backup_emphasize"in t)return;const{strokeStyle:n,lineWidth:i,fillStyle:a}=t.state;t.__backup_emphasize={strokeStyle:n,lineWidth:i,fillStyle:a},t.setState(r)}(e):l&&function(t){"__backup_emphasize"in t&&(t.setState(t.__backup_emphasize),delete t.__backup_emphasize)}(e)),i)switch(i){case"data-toggle":if(!a)return;(r||l)&&this.root.findAll(a,e).forEach((t=>{t.data=!t.data}));break;case"data-tristate":if(!a)return;(r||l)&&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 u=e.access(s);this.root.findAll(a,e).forEach((t=>{t.executeMappings(!0)}))}break;case"data-set":if(!a)return;if(r){u=e.access(s);this.root.findAll(a,e).forEach((t=>{t.data=u}))}break;case"partial-data-set":if(!a)return;if(r){u=e.access(s);this.root.findAll(a,e).forEach((t=>{t.data={...t.data,...u}}))}break;case"value-set":if(!a)return;if(r){u=e.access(s);this.root.findAll(a,e).forEach((t=>{t.value=u}))}break;case"partial-value-set":if(!a)return;if(r){u=e.access(s);this.root.findAll(a,e).forEach((t=>{t.value={...t.value,...u}}))}break;case"infoWindow":case"info-window":if(!a)return;"click"==n.type||r?cet.show(e,a,l,{x:n.offsetX,y:n.offsetY}):l&&cet.hide(e,a);break;case"toggle-info-window":if(!a)return;cet.toggle(e,a,!1,{x:n.offsetX,y:n.offsetY});break;case"popup":case"modal-popup":if(!a)return;let t=c&&"input"in c?c.input:"(self)",o=!c||(!("output"in c)||c.output);yet.show(e,a,{data:t&&this.root.findFirst(t,e)?.data,output:o,modal:"modal-popup"===i});break;case"close-scene":this.closeScene(e.data);break;case"goto":case"goto-playlist":this.trigger(i,a,c,e);break;case"mouse-cursor":r?this.target.style.cursor=a||"auto":l&&(this.target.style.cursor="auto");break;default:this.trigger(i,a,s,e)}}}function Fet(t,e){const r=t.state.refid;return t.root.findAll((t=>t.isLine()&&t.from.component===r&&(!e||t.from.anchor===e)))}function Net(t,e){const r=t.state.refid;return t.root.findAll((t=>t.isLine()&&t.to.component===r&&(!e||t.to.anchor===e)))}Det.Popup=yet,ret.register("model-layer",Det);var jet=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:s,width:o,height:l}=r;var n;if(n=t<Math.max(a+o,a)&&t>Math.min(a+o,a)&&e<Math.max(s+l,s)&&e>Math.min(s+l,s))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 Fet(this,t)}findOutletEnds(t){return function(t,e){return Fet(t,e).map((t=>t.toEnd?.component)).filter(Boolean)}(this,t)}findInletLines(t){return Net(this,t)}findInletEnds(t){return function(t,e){return Net(t,e).map((t=>t.fromEnd?.component)).filter(Boolean)}(this,t)}};const Bet={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"number",label:"round",name:"round",property:{min:0}}],help:"scene/component/rect"};var zet={ondragmove:function(t,e,r){var{left:n,top:i,width:a,height:s}=r.model,o=(r.transcoordP2S(t.x,t.y).x-n)/(a/2)*100;o=iet(o,a,s),r.set({round:o})}};class Wet extends(jet(aet(net))){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:iet(n,r,i))/100),y:e,handler:zet}]}get nature(){return Bet}}ret.register("rect",Wet);const Uet=[1,2,10,20,50,50,50,50,50,50];class Het extends(aet(net)){render(t){const{lineWidth:e=1,fillStyle:r="lightgray",font:n="15px Arial",left:i,top:a,rotation:s,origin:o,margin:l,width:h,height:c,side:u="bottom",strokeStyle:d="#000000",scale:p=1}=this.state;t.translate(i,a),t.beginPath();const f=Math.round(e/2);t.rect(-f,-f,h+2*f,c+2*f),t.clip(),t.beginPath(),t.rect(0,0,h,c),r&&(t.fillStyle=r,t.fill()),t.lineWidth=e,t.strokeStyle=d,t.stroke(),t.beginPath(),t.font=n;var g="bottom"!==u,v=g?0:c,m=4*c/5,y=2*c/3,b=1*c/2,w=3*c/5;g&&(m=c-m,y=c-y,b=c-b,w=c-1.5*c/5);var x=p*this.app.PPM/this.root.unitScale,A=Math.ceil(o/x),_=this.app.PPM/x,k=_<=1.1?1:Uet[Math.round(_)]||100;1!=k&&(A+=(k-A%k)%k);var S=Math.ceil(A*x),E=o+h;for(t.fillStyle=d;S<E;){if(A%10==0){t.moveTo(S-o,b),t.lineTo(S-o,v);let e=(A/10).toString(),r=t.measureText(e);t.fillText(e,S-o-r.width-6,w)}else A%5==0?(t.moveTo(S-o,y),t.lineTo(S-o,v)):(t.moveTo(S-o,m),t.lineTo(S-o,v));A+=k,S=Math.ceil(A*x)}}}ret.register("ruler",Het);const Get=20,Yet=20,Vet=90*Math.PI/180,qet="9px Verdana",Xet=20,$et="#f4f4f4",Ket="#999";function Qet(t,e,r){return{left:-t.x,top:-t.y,width:Get,height:Xet}}function Jet(t,e,r,n){return{left:Get-t.x,top:0-t.y,origin:20-t.x,width:e-Get,height:Xet}}function Zet(t,e,r,n){var i={x:0-t.x+10,y:-t.y+Yet+(r-Yet)/2},a=ret.transcoordRR(0-t.x,-t.y+Yet,i,Vet);return{left:a.x-(r-Yet),top:a.y,origin:20-t.y,width:r-Yet,height:Xet}}function trt(t){var e=t.get("translate");return{left:-e.x,top:-e.y,width:t.canvas.width/z9,height:t.canvas.height/z9}}ret.register("guide-layer",class extends Ret{constructor(t,e){super(t,e),this.appScale={x:1,y:1},"disabled"!==t.ruler&&(this.hruler=new Het({left:Get,top:0,origin:20,margin:0,height:Xet,unit:"m",rotation:0,font:qet,fillStyle:$et,strokeStyle:Ket,capturable:!1}),this.vruler=new Het({left:0,top:0,origin:20,margin:0,height:Xet,unit:"m",rotation:Vet,font:qet,side:"top",fillStyle:$et,strokeStyle:Ket,capturable:!1}),this.origin_rect=new Wet({left:-20,top:-20,width:20,height:20,fillStyle:$et,strokeStyle:Ket,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<Get&&(e.x+=Get),e.y<Yet&&(e.y+=Yet);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=trt(this);var{width:n,height:i}=this.screen_coord;this.hruler.set(Jet(e,n,0,this.hruler)),this.vruler.set(Zet(e,0,i,this.vruler)),this.origin_rect.set(Qet(e))}else this.screen_coord=trt(this)}resize(){super.resize(),this.screen_coord=trt(this);var{width:t,height:e}=this.screen_coord;this.hruler&&(this.hruler.set(Jet(this.model.translate,t,0,this.hruler)),this.vruler.set(Zet(this.model.translate,0,e,this.vruler)),this.origin_rect.set(Qet(this.model.translate)))}render(t){if(this.guide){t.save();var{x:e,y:r}=this.guide,{top:n,left:i,width:a,height:s}=this.screen_coord;t.beginPath(),t.moveTo(e,n),t.lineTo(e,n+s),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 o=this.transcoordS2C(e,r,this.rootModel);t.textBaseline=o.y>200?"bottom":"top",t.textAlign=o.x>200?"right":"left";var l=o.y>200?-5:5,h=o.x>200?-5:5,c=Math.round(e/this.appScale.x),u=Math.round(r/this.appScale.y);t.fillText(` ${c}, ${u} `,e+h,r+l),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=trt(this),this.hruler){var{translate:n}=this.model,{width:i,height:a}=this.screen_coord;this.hruler.set(Jet(n,i,0,this.hruler)),this.vruler.set(Zet(n,0,a,this.vruler)),this.origin_rect.set(Qet(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)}});ret.register("shift-layer",class extends Ret{ready(){super.ready();var t=this.rootModel.get("translate");this.set("translate",t)}render(t){}get pointerEvents(){return"none"}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 ert{constructor(t){this.params=Object.assign({},t)}excute(){}}class rrt extends ert{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 nrt="left",irt="right",art="center",srt="bottom",ort="middle",lrt=[nrt,irt,art,"top",ort,srt];function hrt(t){if(this.hasSameParentForAllSelected&&-1!=lrt.indexOf(t)){var e=this.selected.filter((t=>!t.stuck));if(!(e.length<=1)){var r=this.app.commander;rrt.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 nrt: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 art: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 irt: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"top":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 ort: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 srt: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 crt="VERTICAL",urt=[crt,"HORIZONTAL"];function drt(t){if(this.hasSameParentForAllSelected&&-1!=urt.indexOf(t)){var e=this.selected;if(!(e.length<=1)){var r=this.app.commander;rrt.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===crt?n.y-i.y:n.x-i.x}));var n=r.reduce(((e,r)=>e+(t===crt?r.bounds.height:r.bounds.width)),0),i=r[0].bounds,a=r[r.length-1].bounds,s=((t===crt?a.top+a.height-i.top:a.left+a.width-i.left)-n)/(r.length-1),o=t===crt?i.top+i.height:i.left+i.width;for(let e=1;e<r.length-1;e++){let n=r[e],i=n.bounds;o+=s,t===crt?(i.top=o,o+=i.height):(i.left=o,o+=i.width),n.bounds=i}}(t,e)}))}}}function prt(t){for(var e=0;t&&!t.isRootModel();)e+=t.get("rotation")||0,t=t.parent;return e%(2*Math.PI)}class frt extends ert{execute(){this.params.changes.forEach((t=>{let{component:e,to_container:r,to_index:n,to_left:i,to_top:a,hint:s}=t,o=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),l=prt(e);if(e.removeSelf(!r),e.bounds=o,e.set("rotation",l),r){e.set("rotation",function(t,e){return((t.get("rotation")||0)-prt(e))%(2*Math.PI)}(e,r));let s=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:s.left,t.to_top=void 0!==a?a:s.top,e.bounds={left:t.to_left,top:t.to_top,width:s.width,height:s.height},void 0===n?r.addComponent(e):r.insertComponentAt(e,n)}}))}}function grt(t,e,r){this.app.commander.execute(new frt({changes:[{component:t,to_container:e,to_index:r}]}))}function vrt(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 frt({changes:r});this.app.commander.execute(i)}}function mrt(t,e,r,n){var i=ret.register(t.type);if(!i)return T9("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=mrt(t,e,r,n);i&&a.addComponent(i)})),delete t.components),a.created(),a}function yrt(t,e){var r=X7(t.hierarchy);return delete r.id,mrt(r,t.app,e)}var brt=Object.freeze({__proto__:null,compile:mrt,duplicate:yrt,select:J9,match:$9});function wrt(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 mrt(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:s,width:o,height:l,x:h,y:c,cx:u,cy:d}=e;return t.replaceRefids(i),isNaN(a)||isNaN(s)||isNaN(o)||isNaN(l)||(t.bounds={left:a,top:s,width:o,height:l}),isNaN(h)||isNaN(c)||t.move({x:h,y:c},!1),isNaN(u)||isNaN(d)||(t.center={x:u,y:d}),n.push({component:t,to_container:r}),t})),this.app.commander.execute(new frt({changes:n}))}function xrt(){var t=[],e=new Map;if(this.selected=this.selected.filter((t=>!t.isRootModel())).map((r=>{let n=yrt(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 frt({changes:t});this.app.commander.execute(r)}}function Art(){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 frt({changes:r})),e&&e.calculateBounds&&e.calculateBounds()}function _rt(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 krt(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 Srt(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 Ert(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 Mrt=0;function Trt(){var t=this.selected.filter((t=>!t.isRootModel())).map((t=>t.hierarchy));if(0!=t.length)return Mrt=0,JSON.stringify(t,null,2)}function Crt(){Mrt=0;var t=Trt.call(this);return Art.call(this),t}function Prt(t){if(t)try{Mrt++,wrt.call(this,JSON.parse(t),{x:15*Mrt,y:15*Mrt})}catch(e){M9(e,t)}}var Irt=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;zrt.impl.options.cacheBust&&(t+=(/\?/.test(t)?"&":"?")+(new Date).getTime());return new Promise((function(r){var n,i=new XMLHttpRequest;if(i.onreadystatechange=s,i.ontimeout=o,i.responseType="blob",i.timeout=e,i.open("GET",t,!0),i.send(),zrt.impl.options.imagePlaceholder){var a=zrt.impl.options.imagePlaceholder.split(/,/);a&&a[1]&&(n=a[1])}function s(){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):l("cannot fetch resource: "+t+", status: "+i.status)}function o(){n?r(n):l("timeout of "+e+"ms occured while fetching resource: "+t)}function l(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",""))}}(),Rrt=function(){var t=/url\(['"]?([^'"]+?)['"]?\)/g;return{inlineAll:function(t,i,a){return s()?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 s(){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!Irt.isDataUrl(t)}))}function n(t,e,r,n){return Promise.resolve(e).then((function(t){return r?Irt.resolveUrl(t,r):t})).then(n||Irt.getAndEncode).then((function(t){return Irt.dataAsUrl(t,Irt.mimeType(e))})).then((function(r){return t.replace(function(t){return new RegExp("(url\\(['\"]?)("+Irt.escape(t)+")(['\"]?\\))","g")}(e),"$1"+r+"$3")}))}}(),Ort=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(Irt.asArray(document.styleSheets)).then((function(t){var e=[];return t.forEach((function(t){try{Irt.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 Rrt.shouldProcess(t.style.getPropertyValue("src"))}))})).then((function(e){return e.map(t)}));function t(t){return{resolve:function(){var e=(t.parentStyleSheet||{}).href;return Rrt.inlineAll(t.cssText,e)},src:function(){return t.style.getPropertyValue("src")}}}}}(),Lrt=function(){return{inlineAll:function e(r){return r instanceof Element?n(r).then((function(){return r instanceof HTMLImageElement?t(r).inline():Promise.all(Irt.asArray(r.childNodes).map((function(t){return e(t)})))})):Promise.resolve(r);function n(t){var e=t.style.getPropertyValue("background");return e?Rrt.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 Irt.isDataUrl(t.src)?Promise.resolve():Promise.resolve(t.src).then(e||Irt.getAndEncode).then((function(e){return Irt.dataAsUrl(e,Irt.mimeType(t.src))})).then((function(e){return new Promise((function(r,n){t.onload=r,t.onerror=n,t.src=e}))}))}}}}(),Drt={imagePlaceholder:void 0,cacheBust:!1};function Frt(t,e){return function(t){void 0===t.imagePlaceholder?zrt.impl.options.imagePlaceholder=Drt.imagePlaceholder:zrt.impl.options.imagePlaceholder=t.imagePlaceholder;void 0===t.cacheBust?zrt.impl.options.cacheBust=Drt.cacheBust:zrt.impl.options.cacheBust=t.cacheBust}(e=e||{}),Promise.resolve(t).then((function(t){return jrt(t,e.filter,!0)})).then(Brt).then((function(t){var{bgcolor:r,width:n,height:i,style:a,sx:s=1,sy:o=1}=e,l=t.style;r&&(l.backgroundColor=r);n&&(l.width=n+"px");i&&(l.height=i+"px");l["margin-left"]="0px",l["margin-top"]="0px",l.transform=`rotate(0rad) translate(0px, 0px) scale(${s}, ${o}) perspective(1px)`,a&&Object.keys(a).forEach((function(t){l[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(Irt.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||Irt.width(t),e.height||Irt.height(t))}))}function Nrt(t,e){return Frt(t,e).then(Irt.makeImage).then(Irt.delay(100)).then((function(r){var n=function(t){var r=document.createElement("canvas");if(r.width=e.width||Irt.width(t),r.height=e.height||Irt.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 jrt(t,e,r){return r||!e||e(t)?Promise.resolve(t).then((function(t){if(t instanceof HTMLCanvasElement)try{return Irt.makeImage(t.toDataURL())}catch(t){T9(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,Irt.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 jrt(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){Irt.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=Irt.uid();e.className=e.className+" "+a;var s=document.createElement("style");s.appendChild(o(a,r,n)),e.appendChild(s)}function o(t,e,r){var n="."+t+":"+e,i=r.cssText?a(r):s(r);return document.createTextNode(n+"{"+i+"}");function a(t){var e=t.getPropertyValue("content");return t.cssText+" content: "+e+";"}function s(t){return Irt.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 Brt(t){return Lrt.inlineAll(t).then((function(){return t}))}var zrt={toSvg:Frt,toPng:function(t,e){return Nrt(t,e||{}).then((function(t){return t.toDataURL()}))},toJpeg:function(t,e){return Nrt(t,e=e||{}).then((function(t){return t.toDataURL("image/jpeg",e.quality||1)}))},toBlob:function(t,e){return Nrt(t,e||{}).then(Irt.canvasToBlob)},toPixelData:function(t,e){return Nrt(t,e||{}).then((function(e){return e.getContext("2d").getImageData(0,0,Irt.width(t),Irt.height(t)).data}))},impl:{fontFaces:Ort,images:Lrt,util:Irt,inliner:Rrt,options:{}}};function Wrt(t,e,r,n){var i=this.model_layer,a=i._overlay;return new Promise((function(s,o){if(i){var l=i.get("width"),h=i.get("height");r=r||l,n=n||h;var c=i.get("translate"),u=i.get("scale"),d=Math.min(r/l,n/h);r=l*d,n=h*d,i.set("translate",{x:0,y:0}),i.set("scale",{x:d/z9,y:d/z9});var p=ret.createCanvas(r,n),f=p.getContext("2d");if(i.draw(f),i.set("translate",c),i.set("scale",u),!a)return s(p.toDataURL(t,e)),void(p=null);zrt.toPng(a,{sx:d,sy:d,width:r,height:n}).then((function(i){var a=new Image;a.onload=function(){f.drawImage(a,0,0,r,n),s(p.toDataURL(t,e)),p=null},a.src=i}),(function(r){M9(r),s(p.toDataURL(t,e)),p=null}))}else o("No target model")}))}function Urt(){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=ret.union(r),a=t[0].transcoordP2S(i.left,i.top);a=t[0].transcoordS2T(a.x,a.y);var s=new Map,o=mrt({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&&s.set(t,e),e}));o.replaceRefids(s);var l=[{component:o,to_container:e}];n.forEach((t=>{l.push({component:t,to_container:o})})),this.app.commander.execute(new frt({changes:l})),this.selected=[o]}}}function Hrt(){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 frt({changes:e})),this.selected=t}}function Grt(){var t=this.selected;if(0!=t.length){var e=t.map((t=>t.bounds)),r=ret.union(e),n=r.left+r.width/2;t.map((t=>{t.symmetryX(n)}))}}function Yrt(){var t=this.selected;if(0!=t.length){var e=t.map((t=>t.bounds)),r=ret.union(e),n=r.top+r.height/2;t.map((t=>{t.symmetryY(n)}))}}function Vrt(){rrt.around(this.app.commander,Grt,this)}function qrt(){rrt.around(this.app.commander,Yrt,this)}function Xrt(t,e,r){var n=this.findAll(t,r);return n.forEach((t=>{t.set(e)})),n}function $rt(t){rrt.around(this.app.commander,t)}function Krt(){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 Qrt="left",Jrt="right",Zrt="center",tnt="bottom",ent="middle",rnt=[Qrt,Jrt,Zrt,"top",ent,tnt];function nnt(t){if(this.hasSameParentForAllSelected&&-1!=rnt.indexOf(t)){var e=this.selected.filter((t=>!t.stuck)),r=this.app.commander;rrt.around(r,(function(){!function(t,e){const r=e[0].parent,{width:n,height:i}=r.bounds;switch(t){case Qrt:for(let t=0;t<e.length;t++){let r=e[t].bounds;e[t].bounds={...r,left:0}}break;case Zrt: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 Jrt:for(let t=0;t<e.length;t++){let r=e[t].bounds;e[t].bounds={...r,left:n-r.width}}break;case"top":for(let t=0;t<e.length;t++){let r=e[t].bounds;e[t].bounds={...r,top:0}}break;case ent: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 tnt: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 int(t){t instanceof Array||(t=[t]),this.trigger("addstart",t)}function ant(){this.trigger("stylepastestart")}function snt(){this.trigger("stylepastestop")}function ont(){this.trigger("databindpastestart")}function lnt(){this.trigger("databindpastestop")}function hnt(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 s=e.layout.capturables(e),o=!!e.layout.joinType;if(n&&r.selected.forEach((t=>{a.splice(a.indexOf(t),1)})),r.selected=[],s.forEach((t=>{t.capturable&&function(t,e,r){var n,i,a,s,{sx:o,sy:l,ex:h,ey:c}=e;if(o>h?(n=h,i=o):(n=o,i=h),l>c?(a=c,s=l):(a=l,s=c),r){var u=t.bounds,d=t.transcoordS2TR(u.left,u.top),p=t.transcoordS2TR(u.left+u.width,u.top+u.height),f=d.x,g=p.x,v=d.y,m=p.y,y=Math.min(n,f,i,g),b=Math.max(n,f,i,g),w=Math.min(a,v,s,m),x=Math.max(a,v,s,m);return!(b-y>Math.abs(i-n)+Math.abs(g-f)||x-w>Math.abs(s-a)+Math.abs(m-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||s<r.y)return!1}return!0}(t,r,o)&&-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 cnt(t,e,r,n,i){i||hnt(t,e,r,n)}function unt(t,e){var r=t.components||[];for(let t of r){unt(t,e);let r=e.indexOf(t);-1!=r&&e.splice(r,1)}}ret.register("add-layer",class extends Ret{ready(){super.ready();var t=this.rootModel,e=t.get("translate"),r=t.get("scale");this.set("translate",e),this.set("scale",r)}get pointerEvents(){return"none"}render(t){var e=this.addbox;if(e){let{sx:r,sy:n,ex:i,ey:a}=e,s=this.get("scale")||{x:1,y:1};t.beginPath(),t.rect(r,n,i-r,a-n),t.setLineDash([2/s.x,4/s.y]),t.lineWidth=1/s.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;wrt.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);wrt.call(this.root,this.models,{cx:r,cy:n}),this.root.trigger("addstop")}}});ret.register("selection-layer",class extends Ret{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,s=this.get("scale")||{x:1,y:1};t.beginPath(),t.rect(r,n,i-r,a-n),t.setLineDash([2/s.x,4/s.y]),t.lineWidth=1/s.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],s=a.parent;if(!s||s===n)return!1;if("Tab"===t.code){var o=s.layout.capturables(s),l=o.indexOf(a);if(-1==l){if(!s.indexOf(a))return T9("Container not contains [",a,"] as a component"),!1;l=0}var h=o.length;t.shiftKey?l--:l++,a=o[(l+h)%h]}else{if(!s.layout.keyNavigate)return!1;a=s.layout.keyNavigate(s,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,s=!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 s=!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(s)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),unt(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,cnt(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,cnt(this,null,null,!1,!0),this.invalidate())}});class dnt{constructor(t){this.layer=t}draw(t,e,r){var{left:n,top:i,width:a,height:s}=e.bounds;0!=a&&0!=s&&(t.beginPath(),t.rect(n,i,a,s),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,s),t.stroke(),t.closePath())}}class pnt{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 fnt{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=rrt.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;rrt.after(r,e.app.commander),e.parent&&e.parent.calculateBounds&&e.parent.calculateBounds()}}function gnt(t,e){return Math.atan2(e.y-t.y,e.x-t.x)}const vnt=15*Math.PI/180;class mnt{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=mrt(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=rrt.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,s,o=e.transcoordC2S(n,i);if(o=e.transcoordS2P(o.x,o.y),t.shiftKey){var l=e.path.length,h=e.isLine()&&0==r?e.path[1]:e.path[(r-1+l)%l];h=e.transcoordS2P(h.x,h.y);var c,u=0;if(l>2)e.isLine()?0==r?c=e.path[2]:1!=r&&(c=e.path[r-2]):c=e.path[(r-2+l)%l],c&&(u=gnt(c=e.transcoordS2P(c.x,c.y),h));var d=Math.round((gnt(h,o)-u)/vnt)*vnt+u;o=function(t,e,r){return{x:Math.cos(e)*r+t.x,y:Math.sin(e)*r+t.y}}(h,d,(a=h,s=o,Math.sqrt((s.x-a.x)*(s.x-a.x)+(s.y-a.y)*(s.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:s}=t.transcoordC2S(n,i),l=this.layer.get("scale")||{x:1,y:1},h=this.layer.counterEnd,c=(t.anchors||[]).find((r=>{const{name:n,inout:i,multiplicity:o=1/0,position:c,filter:u}=r;if(h){const{anchor:t,fromto:e}=h;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-c.x)>8/l.x||Math.abs(s-c.y)>8/l.y)return!1;const d=t.findInOutLines(n);return!!d.includes(e)||!(o!==1/0&&d.length>=o)&&(!h||!u||!!u.call(r,h))}));c?0==r?e.from={component:t.get("refid"),anchor:c.name,position:o}:e.to={component:t.get("refid"),anchor:c.name,position:o}:0==r?e.from={position:o}:e.to={position:o}}}e.mutatePath(null,(function(t){t[r]=o}))}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:s,y:o}=a.transcoordC2S(n,i),l=this.layer.get("scale")||{x:1,y:1},h=(a.anchors||[]).find((t=>t&&Math.abs(s-t.position.x)<=8/l.x&&Math.abs(o-t.position.y)<=8/l.y));h&&(0==r?e.from={component:a.get("refid"),anchor:h.name}:e.to={component:a.get("refid"),anchor:h.name}),this.layer.endLinkProcess()}if(this.created){let t=new frt({changes:[{component:this.created,to_container:this.created.parent}]});created.app.commander.execute(t)}else rrt.after(n,e.app.commander);e.parent&&e.parent.calculateBounds&&e.parent.calculateBounds()}}class ynt{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:s}=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)&&(!s||!a||!!s.call(t,a))})).every((a=>{const s=i===a.name?2:1;return a&&a.position&&Math.abs(t-a.position.x)<=4*s/n.x&&Math.abs(e-a.position.y)<=4*s/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:s}=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||!s||!!s.call(t,a))})).forEach((a=>{const{name:s,position:o}=a,l=i===s?2:1;o&&(t.beginPath(),t.ellipse(o.x,o.y,4*l/r.x,4*l/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===s&&(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 bnt(t,e,r){var n,i,{left:a,top:s,width:o,height:l}=t.bounds;switch(e){case 0:n=a,i=s;break;case 1:n=a+o/2,i=s;break;case 2:n=a+o,i=s;break;case 3:n=a+o,i=s+l/2;break;case 4:n=a+o,i=s+l;break;case 5:n=a+o/2,i=s+l;break;case 6:n=a,i=s+l;break;case 7:n=a,i=s+l/2}var h=n,c=i,u=t.transcoordT2S(r.x,r.y);return{dx:u.x-h,dy:u.y-c}}function wnt(t,e,r,n,i,a){var{left:s,top:o,width:l,height:h}=t.bounds,c={left:s,top:o,width:l,height:h};switch(e){case 0:s+=n,o+=i,l-=n,h-=i;break;case 1:o+=i,h-=i;break;case 2:o+=i,l+=n,h-=i;break;case 3:l+=n;break;case 4:l+=n,h+=i;break;case 5:h+=i;break;case 6:s+=n,l-=n,h+=i;break;case 7:s+=n,l-=n}if(t.mutateBounds((function(e){return Math.abs(l)<=.001&&(l=.001),Math.abs(h)<=.001&&(h=.001),t.adjustResize({left:s,top:o,width:l,height:h},c,r)}),this),t.isContainer()&&t.layout.ABSOLUTE&&!t.isGroup()){var u=c.left-s,d=c.top-o;a?t.components.forEach((t=>{t.delta("tx",0),t.delta("ty",0),t.move({x:u,y:d},!1)})):t.components.forEach((t=>{t.delta("tx",u),t.delta("ty",d)}))}else{var p=a&&t.parent;p&&p.isGroup()&&p.calculateBounds()}}function xnt(t,e){var{left:r,top:n,width:i,height:a}=t,s=r+i/2,o=n+a/2,l=r+i,h=n+a;const c=i*e.x>50,u=a*e.y>50;return[{x:r,y:n},c?{x:s,y:n}:null,{x:l,y:n},u?{x:l,y:o}:null,{x:l,y:h},c?{x:s,y:h}:null,{x:r,y:h},u?{x:r,y:o}:null]}class Ant{constructor(t){this.layer=t}reset(){this.active=null}get selected(){return this.layer.selected}contains(t,e,r,n){return!!r.resizable&&(xnt(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:s}=e.bounds;if(t.beginPath(),t.rect(n-4/r.x,i-4/r.y,a+8/r.x,s+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 o=this.active;xnt(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",o&&o.component===e&&o.index===i&&(t.strokeStyle="#fa7703",o.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 s=bnt(e,r,a);this.layer.selected.filter((t=>t.resizable)).forEach(((e,i)=>{e.bounds=n[i],wnt(e,r,t.shiftKey,s.dx,s.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 s=bnt(e,r,a);this.layer.selected.filter((t=>t.resizable)).forEach(((e,i)=>{e.bounds=n[i],wnt(e,r,t.shiftKey,s.dx,s.dy,!0)})),this.active.component.app.commander.execute(null,!1)}}const _nt=2*Math.PI,knt=Math.PI/2;function Snt(t,e){var r=t.bounds;return{x:r.left+r.width/2,y:r.top-20/e.y}}class Ent{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=Snt(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=Snt(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,_nt,!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)),s=(a=n.x>=r.x?a-knt:knt+a)-i;this.layer.selected.filter((t=>t.rotatable)).forEach(((e,r)=>{let n=((e.get("rotation")||0)+s)%_nt;e.set("rotation",e.adjustRotation(n,t.shiftKey))}))}ondragend(t){var{component:e,rotations:r}=this.active;e.app.commander.execute(null,!1)}}ret.register("modeling-layer",class extends Ret{constructor(t,e){super(t,e),this.pathHandler=new mnt(this);var r=this.pathHandler,n=new fnt(this),i=new Ant(this),a=new Ent(this);this._modelers=[r,n,i,a],this._control_mode_modelers=[n,r,i,a],this.focusOutline=new dnt(this),this.groupOutline=new pnt(this),this.anchorHandler=new ynt(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],s=a.transcoordT2S(t,e);for(let t=0;t<this.modelers.length;t++){let e=this.modelers[t];if(e.contains(s.x,s.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 s=e.rotatePoint;t.translate(s.x,s.y);let o=e.get("scale");o&&t.scale(o.x,o.y),t.rotate(e.get("rotation")),t.translate(-s.x,-s.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*z9,e.y*z9),t.scale(r.x*z9,r.y*z9),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 rrt.around(this.app.commander,(()=>{r.ondropfile(n,e)})),void(this.selected=[r]);let s=[],o=e.map(((t,e)=>{let r,o=n[e].type,l=n[e].name;return o.startsWith("image/")?(r=mrt({type:o.startsWith("image/gif")?"gif-view":"image-view",top:0,left:0,width:200,height:200,src:t},a.app),s.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)}})))):o.startsWith("audio/")?r=mrt({type:"audio",top:0,left:0,width:100,height:100,src:t},a.app):o.startsWith("vnd.ms-excel/")||/\.xlsx?$/.test(l)?r=mrt({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})));o.length>0&&Promise.all(s).then((()=>{this.app.commander.execute(new frt({changes:o})),this.selected=o.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;t.altKey?rrt.around(this.app.commander,(()=>{r.selected.forEach((t=>{let e=t.get("letterSpacing")||H9.LETTER_SPACING;e+=n,t.set("letterSpacing",e)}))})):rrt.around(this.app.commander,(()=>{r.selected.forEach((t=>{let e=t.get("fontSize")||H9.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,s=t.offsetY,o=r.transcoordC2S(a,s),l=.1*n,h={x:e.x+l,y:e.y+l};if(n<0&&e.x<.2||n>0&&e.x>10)return;r.set("scale",h);let c=r.transcoordC2S(a,s);r.set("translate",{x:i.x+(c.x-o.x)*h.x,y:i.y+(c.y-o.y)*h.y})}}}});class Mnt extends Ret{constructor(t,e){super(t,e),this._anim_alpha=1}get pointerEvents(){return"none"}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?Xtt(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=[]}}ret.register("decotag-layer",Mnt),ret.register("tag-layer",Mnt);ret.register("reaction-layer",class extends Ret{constructor(t,e){super(t,e),this._anim_alpha=1}get pointerEvents(){return"none"}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?Xtt(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 Tnt(){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 s=r[a];if($9(a,n.origin,0,t))for(let t in s){let r=s[t];t==n.name&&(n.listener=e,r.apply(e,i))}}}(r.deliverer,n.listener,n.cloned_handlers,e,t)}))}ret.register("scroll-layer",class extends Ret{get capturable(){return!0}get pointerEvents(){return"none"}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:s}=this.rootModel.model,{x:o,y:l}={x:t.offsetX,y:t.offsetY},{x:h,y:c}=this._scale,{scrolling:u}=this.state,d=a/n,p=s/i;u&&r.rootModel.move({x:"h"==u?(-o+this.lastPosition.x)*h*d:0,y:"v"==u?(-l+this.lastPosition.y)*c*p: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:s=0,y:o=0}=this._translate||{},l=r/t,h=n/e;var c={left:-s/i/l,top:e-10,width:t/i/l,height:10};this.hscroller=c.left>1||c.width+c.left<t-1?c:null,c={left:t-10,top:-o/a/h,width:10,height:e/a/h},this.vscroller=c.top>1||c.height+c.top<e-1?c: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 Cnt{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)",Tnt,{event_pump:this})}stop(){this.deliverer.off("(all)",Tnt)}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:T9("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 Pnt{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.");J9(r,this.root,t).forEach((r=>{var i=new Cnt(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 Int=0,Rnt=1,Ont=2,Lnt=0,Dnt=1,Fnt=2;var Nnt={},jnt=0;class Bnt{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 Nnt;let r=e.target.getBoundingClientRect();return Nnt={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 s=n-e||0,o=i-r||0;return Math.sqrt(Math.pow(s,2)+Math.pow(o,2))||0}(t);jnt>0&&(this._scale=n/jnt),jnt=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,this.originalEvent&&"function"==typeof this.originalEvent.stopPropagation&&this.originalEvent.stopPropagation()}isPropagationStopped(){return this._stop_}preventDefault(){this._prevented=!0}isDefaultPrevented(){return this._prevented}}function znt(t,e){return t.capture(e.offsetX,e.offsetY)}function Wnt(t,e,r){if(t&&t.app&&(!t.app.isViewMode||!t.hidden)){r instanceof Bnt&&e===r.type||(r=new Bnt(r,e));var n="on"+e;t[n]&&t[n](r),r.isPropagationStopped()||t.trigger(e,r)}}class Unt{constructor(t,e){this.container=t,this.html_element=e,this.status=Int,this.last_target=null,this.gesture_handlers=W9.map((t=>this.gestureHandlerBuilder(t))),this.keyevent_handlers=U9.map((t=>this.keyeventHandlerBuilder(t))),W9.forEach(((t,r)=>e.addEventListener(t,this.gesture_handlers[r])),{passive:!1}),U9.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&&Wnt(this.last_enter_target,"mouseleave",new CustomEvent("mouseleave")),W9.forEach(((t,e)=>this.html_element.removeEventListener(t,this.gesture_handlers[e]))),U9.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=>{const r=new Bnt(t);return e(r),r.isDefaultPrevented()&&t.preventDefault(),!1}}keyeventHandlerBuilder(t){return this[`on${t}`].bind(this)}ondragover(t){return Wnt(znt(this.container,t),t.type,t),!1}ondrop(t){return Wnt(znt(this.container,t),t.type,t),!1}ondblclick(t){return Wnt(znt(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 Rnt:let r=t.offsetX-this.__dragstart_e.offsetX,n=t.offsetY-this.__dragstart_e.offsetY;if(r*r+n*n<16)break;this.status=Ont,Wnt(this.last_target,"dragstart",this.__dragstart_e),this.__dragmove_e=t,Wnt(this.last_target,"dragmove",t);break;case Ont:this.__dragmove_e=t,Wnt(this.last_target,"dragmove",t);break;default:var e=znt(this.container,t);this.last_enter_target!==e&&(this.last_enter_target&&Wnt(this.last_enter_target,"mouseleave",t),e&&Wnt(e,"mouseenter",t),this.last_enter_target=e),Wnt(e,t.type,t),this.last_target=e}return!1}onmousedown(t){if(this.status===Ont)Wnt(this.last_target,"dragend",t),this.last_target=null,this.status=Int;else{var e=znt(this.container,t);this.last_target=e,this.status=Rnt,this.__dragstart_e=t,Wnt(e,t.type,t)}return!1}onmouseup(t){if(this.status===Ont)Wnt(this.last_target,"dragend",t);else{var e=znt(this.container,t);Wnt(e,t.type,t),this.last_target===e&&Wnt(e,"click",t)}return this.last_target=null,this.status=Int,!1}onmouseout(t){var e=znt(this.container,t);if(this.status===Ont)Wnt(this.last_target,"dragend",t);else{if(this.last_target&&this.last_target===e)return;this.last_enter_target&&(Wnt(this.last_enter_target,"mouseleave",t),delete this.last_enter_target)}return this.last_target=null,this.status=Int,!1}ontouchstart(t){var e=znt(this.container,t);return this.last_target=e,this.status=Dnt,this.touchPoints||(this.touchPoints=[]),this.touchPoints.push(t.changedTouches[0]),this.holdTimer=setTimeout((()=>{this.status=Lnt,Wnt(this.last_target,"hold",t),delete this.holdTimer}),500),Wnt(e,t.type,t),!1}ontouchmove(t){if(!t.touches||!t.changedTouches)return Wnt(this.last_target,"dragstart",t),Wnt(this.last_target,"dragmove",t),!1;var e=znt(this.container,t);switch(this.status){case Dnt: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=Fnt,void(this.holdTimer&&(clearTimeout(this.holdTimer),delete this.holdTimer))):void 0}}));break;case Fnt: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 Wnt(this.last_target,"pinch",t),!1;Wnt(this.last_target,"pan",t),e=this.last_target;break;default:this.last_enter_target!==e&&(this.last_enter_target&&Wnt(this.last_enter_target,"mouseleave",t),e&&Wnt(e,"mouseenter",t),this.last_enter_target=e),this.last_target=e}return Wnt(e,"touchmove",t),!1}ontouchend(t){var e=znt(this.container,t);switch(this.status){case Fnt:e=this.last_target;break;case Dnt:var r=performance.now(),n=r-this.touchedAt;this.holdTimer&&(clearTimeout(this.holdTimer),delete this.holdTimer,Wnt(e,n<500?"doubletap":"tap",t),this.touchedAt=r)}Wnt(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=Lnt,!1}onwheel(t){return Wnt(znt(this.container,t),t.type,t),!1}}function Hnt(t,e,r,n=0){if(e.length<2)return e;let i=2;for(;i<e.length;i++){const a=e.substring(0,i);if(!(t.measureText(a).width+(a.length-1)*n<r))break}return e.substring(0,i-1)}function Gnt(t,e,r,n,i=0){const a=String(e).split("\n");return n?[].concat.apply([],a.map((e=>function(t,e,r,n=0){const i=e.split(" "),a=[];let s,o,l=[];for(s=0,o=1;o<=i.length;o++)if(l=i.slice(s,o),t.measureText(l.join(" ")).width+(l.join("").length-1)*n>r){if(o-s==1){const e=Hnt(t,l[0],r,n);a.push([e]),i.splice(s,1,e,l[0].substring(e.length))}else{for(;""==i[o-1];)o++;a.push(i.slice(s,--o))}s=o}return o-s>1&&a.push(l),0==a.length&&a.push([""]),a}(t,e,r,i)))):a.map((t=>t.split(" ")))}var Ynt={},Vnt={};const qnt=()=>{};var Xnt={register:function(t,e,r){Ynt[t]=e,r&&(Vnt[t]=r)},unregister:function(t){delete Ynt[t],delete Vnt[t]},get:function(t){return Ynt[t]},getDisposer:function(t){return Vnt[t]||qnt}};function $nt(t){if(!t.hasTextProperty||t.textHidden)return;var{text:e="",bold:r=H9.BOLD,italic:n=H9.ITALIC,textWrap:i=H9.TEXT_WRAP,letterSpacing:a=0,fontFamily:s=H9.FONT_FAMILY,fontColor:o=H9.FONT_COLOR,textAlign:l=H9.TEXT_ALIGN,textBaseline:h=H9.TEXT_BASELINE,fontSize:c=H9.FONT_SIZE,lineHeight:u=1.2*c}=t.model,{left:d,top:p,width:f,height:g}=t.textBounds;c||=H9.FONT_SIZE,u||=1.2*c,t.textHidden=!0;var v=document.createElement("textarea");W9.forEach((function(t){v.addEventListener(t,(function(t){t.stopPropagation()}),!0)}));const m=t.transcoordS2C(d,p),{rotation:y,scale:b}=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(v.style.position="absolute",v.style.width=f+"px",v.style.height=g+"px",v.style.padding="0",v.value=e,v.style.fontFamily=s,v.style.fontSize=c+"px",v.style.lineHeight=u+"px",v.style.overflow="hidden",v.style.resize="none",v.style.outline="none",v.style.border=0,v.style.backgroundColor="transparent",v.style.display="inline-block",v.style.color=o,r&&(v.style.fontWeight="bold"),n&&(v.style.fontStyle="italic"),l){case"right":case"end":v.style.textAlign="right";break;case"justify":v.style.textAlign="justify";break;case"left":case"start":v.style.textAlign="left";break;default:v.style.textAlign="center"}var w=[r,n,c+"px",s].filter(Boolean).join(" ");function x(e){var r={left:0,top:0},n=u*function(t,e,r,n,i=0){var a,s=t.getContext();return s.save(),s.font=r,a=Gnt(s,e,n,t.get("textWrap"),i).length,s.restore(),a}(t,e,w,f,a);switch(v.style.height=n+"px",h){case"top":case"hanging":break;case"bottom":case"alphabetic":r.top=g-n;break;default:r.top=g/2-n/2}if(!i){var s=function(t,e,r,n){var i=e.split("\n"),a=n;let s=t.getContext();return s.save(),s.font=r,i.forEach((t=>{let e=s.measureText(t).width;e>a&&(a=e)})),s.restore(),a}(t,e,w,f);switch(v.style.width=s+"px",l){case"right":case"end":r.left=f-s;break;case"left":case"start":break;default:r.left=(f-s)/2}}v.style.marginLeft=r.left+"px",v.style.marginTop=r.top+"px",v.style.transform=`translate(${m.x}px, ${m.y}px) scale(${b}) rotate(${y}rad)`,v.style.transformOrigin=`${-r.left}px ${-r.top}px`}x(e);var A=t.root.target_element;A.appendChild(v),v.select();var _,k=!1;v.addEventListener("keydown",(function(t){t.stopPropagation(),"Escape"!=t.code&&(t.shiftKey||"Enter"!=t.code&&"NumpadEnter"!=t.code)?setTimeout((()=>{x(v.value)})):(k=_.skipUpdate="Escape"==t.code,document.createEvent?v.dispatchEvent(_):v.fireEvent(_.eventType,_))})),document.createEvent?(_=document.createEvent("HTMLEvents")).initEvent("blur",!0,!1):(_=document.createEventObject()).eventType="blur";var S=t.root.selected,E=function(r){t.root.selected=S,t.textHidden=!1,v.removeEventListener("blur",E,!1),v.parentElement&&v.parentElement.removeChild(v),A.focus(),r.skipUpdate||k||t.app.commander.execute(new rrt({changes:[{component:t,before:{text:e},after:{text:v.value}}]}))};v.addEventListener("blur",E,!1)}Xnt.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)&&($nt(i[0]),t.preventDefault(),!0))}}},"model-layer":{"(descendant)":{dblclick:function(t,e){$nt(e.origin)}}}});var Knt,Qnt,Jnt,Znt=s9((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);Xnt.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 s=i[0].transcoordC2S(t.offsetX,t.offsetY);if(s=i[0].transcoordS2P(s.x,s.y),this.last_pos=s,this.direction=0,n.focused=i[0].parent,t.altKey){var o=[],l=new Map;n.selected=n.selected.filter((t=>!t.isRootModel())).map((t=>{let e=yrt(t,(t=>{const e=n.root.getNewRefid();return void 0!==t&&l.set(t,e),e}));return o.push({component:e,to_container:t.parent}),e})).map((t=>(t.replaceRefids(l),t))),o.forEach((({component:t,to_container:e})=>{e.addComponent(t)})),this.duplicates=n.selected.map((t=>({component:t})))}else this.changes=rrt.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:s}=i[0].transcoordC2S(t.offsetX,t.offsetY),o=i[0].transcoordS2P(a,s);t.shiftKey?2==this.direction&&(this.direction=0):this.direction=2;var l=o.x-this.last_pos.x,h=o.y-this.last_pos.y;if(0==this.direction){if(l*l+h*h<25)return;Math.abs(l)>Math.abs(h)?this.direction=3:this.direction=4}3==this.direction?h=0:4==this.direction&&(l=0),i.forEach((t=>{t.move({x:l,y:h},1===i.length)})),this.last_pos=o,Znt(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,s=n.focused||e.deliverer;if(this.changes&&!s.isGroup())if(n.hasSameParentForAllSelected&&s&&s!==a){var o=this.changes.map((t=>{let{component:e,before:r}=t;return{component:e,to_container:s}}));n.app.commander.execute(new frt({changes:o}))}else rrt.after(this.changes,n.app.commander);else if(this.duplicates){this.duplicates=this.duplicates.map((t=>(t.to_container=s,t)));let t=new frt({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,Znt(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 s=n.selected;rrt.around(n.app.commander,(function(){s.forEach((t=>{!t.stuck&&t.move(i,!1)}))}))}}}});const tit=o9((()=>{const{x:t,y:e}=Jnt,r=Qnt.deref();r&&(r.rootModel.move({x:t-Knt.x,y:e-Knt.y},!1),Knt={x:t,y:e})}),60,{leading:!0,trailing:!0});Xnt.register("shift-handler",{"model-layer":{"(all)":{dragstart:function(t,e){Knt={x:t.offsetX,y:t.offsetY}},dragmove:function(t,e){Qnt=new WeakRef(e.deliverer),Jnt={x:t.offsetX,y:t.offsetY},tit()}}}}),Xnt.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"),s=t.offsetX,o=t.offsetY,l=r.transcoordC2S(s,o),h=.1*n,c={x:i.x+h,y:i.y+h};if(n<0&&i.x<.2||n>0&&i.x>10)return;r.set("scale",c);let u=r.transcoordC2S(s,o);r.set("translate",{x:a.x+(u.x-l.x)*c.x,y:a.y+(u.y-l.y)*c.y})}},"(self)":{dblclick:function(t,e){const r=e.origin;r?.root.fit()}}}});var eit={},rit={};function nit(t){const e={};for(const r in t)t.hasOwnProperty(r)&&void 0!==t[r]&&(e[r]=t[r]);return e}function iit(t,e,r){if("function"==typeof t?t===e:t.has(e))return arguments.length<3?e:r;throw new TypeError("Private element is not present on this object")}function ait(t,e,r,n,i,a,s){try{var o=t[a](s),l=o.value}catch(t){return void r(t)}o.done?e(l):Promise.resolve(l).then(n,i)}function sit(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var a=t.apply(e,r);function s(t){ait(a,n,i,s,o,"next",t)}function o(t){ait(a,n,i,s,o,"throw",t)}s(void 0)}))}}function oit(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")}function lit(t,e){return t.get(iit(t,e))}function hit(t,e,r){oit(t,e),e.set(t,r)}function cit(t,e,r){return t.set(iit(t,e),r),r}function uit(t,e,r){return r(iit(t,e))}function dit(t,e){oit(t,e),e.add(t)}function pit(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function fit(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function git(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?fit(Object(r),!0).forEach((function(e){pit(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):fit(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function vit(t,e,r){e||(e=[]);var n=e.length++;return Object.defineProperty({},"_",{set:function(i){e[n]=i,t.apply(r,e)}})}Xnt.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:s,lineDash:o,lineCap:l,lineJoin:h,fontColor:c,fontSize:u,fontFamily:d,bold:p,italic:f,textAlign:g,textBaseline:v,textOverflow:m,paddingTop:y,paddingBottom:b,paddingLeft:w,paddingRight:x}=t.state;eit=X7({fillStyle:e,strokeStyle:i,alpha:a,lineWidth:s,lineDash:o,lineCap:l,lineJoin:h,fontColor:c,fontSize:u,fontFamily:d,bold:p,italic:f,textAlign:g,textBaseline:v,textOverflow:m,paddingTop:y,paddingBottom:b,paddingLeft:w,paddingRight:x}),r.mode=4}},stylepastestop:function(t){const{deliverer:e}=t,r=e.app;eit={},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;rit=X7({mappings:e}),r.mode=5}},databindpastestop:function(t){const{deliverer:e}=t,r=e.app;rit={},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&&rrt.around(n.commander,(()=>{const t=nit({...i.model,...eit});i?.set(t)})):i===r?r.root.trigger("databindpastestop"):i&&rrt.around(n.commander,(()=>{const t=nit({...i.model,...rit});i?.set(t)}))}}}});class mit{constructor(t,e,r){pit(this,"_delta",{theta:0,tx:0,ty:0,sx:1,sy:1,fade:0}),pit(this,"_location",null);const{animations:n,...i}=r;this.overlay=t,this.target=e,this.decorator=i||{},this.animations=[],Array.isArray(n)?this.animations=n.map((t=>("theta"in t&&(t={...t,theta:t.theta*(Math.PI/180)}),b7(this,t)))):n&&("theta"in n&&(n={...n,theta:n.theta*(Math.PI/180)}),this.animations=[b7(this,n)])}delta(t,e){if(void 0===e)return t?this._delta[t]:this._delta;this._delta[t]=e;const{tx:r,ty:n,sx:i,sy:a,theta:s,fade:o}=this._delta;Object.assign(this.element.style,{opacity:1-o,transform:`rotate(${s}rad) translate(${r}px, ${n}px) scale(${i}, ${a}) perspective(1px)`})}get location(){if(this._location)return this._location;const{location:t,size:e}=this.decorator,{left:r,top:n,width:i,height:a}=this.target.bounds;let s;switch(t){case"top-left":s={x:r,y:n-e};break;case"top":s={x:r+(i-e)/2,y:n-e};break;case"top-right":s={x:r+i-e,y:n-e};break;case"bottom-left":s={x:r,y:n+a};break;case"bottom":s={x:r+(i-e)/2,y:n+a};break;case"bottom-right":s={x:r+i-e,y:n+a};break;case"left-top":s={x:r-e,y:n};break;case"left":s={x:r-e,y:n+(a-e)/2};break;case"left-bottom":s={x:r-e,y:n+(a-e)};break;case"right-top":s={x:r+i,y:n};break;case"right":s={x:r+i,y:n+(a-e)/2};break;case"right-bottom":s={x:r+i,y:n+(a-e)};break;case"top-left-corner":s={x:r-e/2,y:n-e/2};break;case"top-right-corner":s={x:r+i-e/2,y:n-e/2};break;case"bottom-left-corner":s={x:r-e/2,y:n+a-e/2};break;case"bottom-right-corner":s={x:r+i-e/2,y:n+a-e/2};break;default:s={x:r+i/2-e/2,y:n+a/2-e/2}}return this._location=this.target.transcoordS2T(s.x,s.y),this._location}get element(){if(!this._element){const{icon:t,size:e,color:r}=this.decorator,{x:n,y:i}=this.location,a=document.createElement("div");a.setAttribute("scene","animated-icon"),Object.assign(a.style,{position:"absolute",fontVariationSettings:"'FILL' 1",fontFamily:"Material Symbols Outlined",fontSize:e+"px",width:e+"px",height:e+"px",lineHeight:e+"px",padding:0,margin:0,color:r,textAlign:"center",verticalAlign:"middle",left:n+"px",top:i+"px",pointerEvents:"none"}),a.textContent=t,this._element=a}return this._element}touch(){}invalidate(){}start(){this.overlay.appendChild(this.element),this.animations.forEach((t=>t.start()))}stop(){this.overlay.removeChild(this.element),this.animations.forEach((t=>t.stop())),this._location=null}get root(){return this.target.root}get center(){const{size:t}=this.decorator,{x:e,y:r}=this.location;return{x:e+t/2,y:r+t/2}}transcoordS2T(t,e){const{tx:r,ty:n}=this._delta;return{x:t+r,y:e+n}}}class yit{static getTargetId(t){if(!yit._targetIdMap.has(t)){const e=`target-${Math.random().toString(36).substring(2,9)}`;yit._targetIdMap.set(t,e)}return yit._targetIdMap.get(t)}static getSvgContainer(t){if(!yit._svgMap.has(t)){const e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("class","border-highlighting-container"),e.setAttribute("pointer-events","none"),e.style.overflow="visible",e.style.position="absolute",e.style.top="0",e.style.left="0";const r=document.createElementNS("http://www.w3.org/2000/svg","defs");e.appendChild(r);const n=document.createElementNS("http://www.w3.org/2000/svg","g");n.setAttribute("class","border-highlighting-group"),e.appendChild(n),t.appendChild(e),yit._svgMap.set(t,e)}return yit._svgMap.get(t)}constructor(t,e,r){this.overlayRef=new WeakRef(t),this.target=e,this.decorator=r}get element(){const t=this.overlayRef.deref();if(!t)return null;const{distance:e=10,lineWidth:r=2,color:n="red",animation:i=!1,fillStyle:a}=this.decorator||{},{round:s=0,fillStyle:o}=this.target.state,l=this.target.path.map((t=>this.target.transcoordS2T(t.x,t.y))),h=this.createOffsetPath(l,e),c=this.pointsToPathData(h,s),u=yit.getSvgContainer(t),d=yit.getTargetId(this.target),p=u.querySelector(".border-highlighting-group"),f=p.querySelector(`[data-target-id="${d}"]`);f&&f.remove();const g=document.createElementNS("http://www.w3.org/2000/svg","path");g.setAttribute("d",c),g.setAttribute("fill","none"),g.setAttribute("stroke-width",r),g.setAttribute("stroke-linejoin","round"),g.setAttribute("pointer-events","none"),g.setAttribute("data-target-id",d);const v=a||o||"rgba(0, 0, 0, 0.5)",m=u.querySelector("defs"),y=this.createFilter(d,v);if(m.appendChild(y),g.setAttribute("filter",`url(#${d}-filter)`),i){const t=u.querySelector("defs"),e=this.createGradient(d,n);t.appendChild(e),g.setAttribute("stroke",`url(#${d})`)}else g.setAttribute("stroke",n);return p.appendChild(g),g}createOffsetPath(t,e){const r=[],n=t.length;for(let i=0;i<n;i++){const a=t[(i-1+n)%n],s=t[i],o=t[(i+1)%n],l=s.x-a.x,h=s.y-a.y,c=o.x-s.x,u=o.y-s.y,d=this.normalize({x:h,y:-l}),p=this.normalize({x:u,y:-c}),f=this.normalize({x:(d.x+p.x)/2,y:(d.y+p.y)/2}),g={x:s.x+f.x*e,y:s.y+f.y*e};r.push(g)}return r}normalize(t){const e=Math.sqrt(t.x*t.x+t.y*t.y);return{x:t.x/e,y:t.y/e}}pointsToPathData(t,e=0){if(t.length<2)return"";let r="";const n=t.length,i=(t,e,r)=>{const n=e.x-t.x,i=e.y-t.y,a=Math.sqrt(n*n+i*i);return{x:t.x+n/a*r,y:t.y+i/a*r}};for(let a=0;a<n;a++){const s=t[a],o=t[(a+1)%n],l=t[(a-1+n)%n],h=Math.sqrt((s.x-l.x)**2+(s.y-l.y)**2),c=Math.sqrt((s.x-o.x)**2+(s.y-o.y)**2),u=Math.min(e,h/2,c/2),d=i(s,l,u),p=i(s,o,u);r+=0===a?`M${d.x},${d.y}`:` L${d.x},${d.y}`,r+=` Q${s.x},${s.y} ${p.x},${p.y}`}return r+=" Z",r}createFilter(t,e){const r=document.createElementNS("http://www.w3.org/2000/svg","filter");r.setAttribute("id",`${t}-filter`);const n=document.createElementNS("http://www.w3.org/2000/svg","feFlood");n.setAttribute("flood-color",e),n.setAttribute("result","flood");const i=document.createElementNS("http://www.w3.org/2000/svg","feComposite");i.setAttribute("in","flood"),i.setAttribute("in2","SourceAlpha"),i.setAttribute("operator","in"),i.setAttribute("result","mask");const a=document.createElementNS("http://www.w3.org/2000/svg","feMerge"),s=document.createElementNS("http://www.w3.org/2000/svg","feMergeNode");s.setAttribute("in","mask");const o=document.createElementNS("http://www.w3.org/2000/svg","feMergeNode");return o.setAttribute("in","SourceGraphic"),a.appendChild(s),a.appendChild(o),r.appendChild(n),r.appendChild(i),r.appendChild(a),r}createGradient(t,e){const r=document.createElementNS("http://www.w3.org/2000/svg","linearGradient");r.setAttribute("id",t),r.setAttribute("x1","0%"),r.setAttribute("y1","0%"),r.setAttribute("x2","100%"),r.setAttribute("y2","0%");const n=this.alterColor(e,120),i=this.alterColor(e,240);return r.innerHTML=`\n <stop offset="0%" stop-color="${e}">\n <animate attributeName="stop-color" values="${e};${n};${i};${e}" dur="5s" repeatCount="indefinite" />\n </stop>\n <stop offset="100%" stop-color="${i}">\n <animate attributeName="stop-color" values="${i};${e};${n};${i}" dur="5s" repeatCount="indefinite" />\n </stop>\n `,r}alterColor(t,e){const r=this.convertToHex(t);let n=parseInt(r.substring(1,3),16),i=parseInt(r.substring(3,5),16),a=parseInt(r.substring(5,7),16);const s=this.rgbToHsl(n,i,a);s[0]=(s[0]+e/360)%1;const o=this.hslToRgb(s[0],s[1],s[2]);return`#${o[0].toString(16).padStart(2,"0")}${o[1].toString(16).padStart(2,"0")}${o[2].toString(16).padStart(2,"0")}`}rgbToHsl(t,e,r){t/=255,e/=255,r/=255;let n,i,a=Math.max(t,e,r),s=Math.min(t,e,r),o=(a+s)/2;if(a===s)n=i=0;else{let l=a-s;switch(i=o>.5?l/(2-a-s):l/(a+s),a){case t:n=(e-r)/l+(e<r?6:0);break;case e:n=(r-t)/l+2;break;case r:n=(t-e)/l+4}n/=6}return[n,i,o]}hslToRgb(t,e,r){let n,i,a;if(0===e)n=i=a=r;else{const s=(t,e,r)=>(r<0&&(r+=1),r>1&&(r-=1),r<1/6?t+6*(e-t)*r:r<.5?e:r<2/3?t+(e-t)*(2/3-r)*6:t);let o=r<.5?r*(1+e):r+e-r*e,l=2*r-o;n=s(l,o,t+1/3),i=s(l,o,t),a=s(l,o,t-1/3)}return[Math.round(255*n),Math.round(255*i),Math.round(255*a)]}convertToHex(t){if(/^#([0-9A-F]{6})$/i.test(t))return t;const e=document.createElement("div");e.style.color=t,document.body.appendChild(e);const r=window.getComputedStyle(e).color;document.body.removeChild(e);const n=r.match(/\d+/g);return!n||n.length<3?(console.warn(`Invalid color: ${t}. Defaulting to #FF0000.`),"#FF0000"):`#${n.slice(0,3).map((t=>parseInt(t,10).toString(16).padStart(2,"0"))).join("")}`}start(){const t=this.overlayRef.deref();if(!t)return;const e=yit.getSvgContainer(t);t.contains(e)||t.appendChild(e);const r=this.element;if(r&&this.decorator.animation){const t=r.getAttribute("data-target-id");if(!t)return;const n=e.querySelector("defs");if(!n)return;const i=n.querySelector(`#${t}`);if(!i)return;requestAnimationFrame((()=>{i.querySelectorAll("animate").forEach((t=>{t.beginElement()}))}))}}stop(){if(!this.element)return;const t=this.overlayRef.deref();if(!t)return;const e=yit._svgMap.get(t);if(!e)return;const r=e.querySelector(".border-highlighting-group");if(!r)return;const n=e.querySelector("defs");if(!n)return;const i=yit.getTargetId(this.target),a=r.querySelector(`[data-target-id="${i}"]`);if(a){r.removeChild(a),a.remove();const t=n.querySelector(`#${i}`);t&&(n.removeChild(t),t.remove())}yit._targetIdMap.delete(this.target),0===r.children.length&&(e.remove(),yit._svgMap.delete(t))}}pit(yit,"_svgMap",new WeakMap),pit(yit,"_targetIdMap",new WeakMap);class bit{static getArrowId(t){if(!bit._arrowIdMap.has(t)){const e=`${Math.random().toString(36).substring(2,9)}`;bit._arrowIdMap.set(t,e)}return bit._arrowIdMap.get(t)}static getSvgContainer(t){if(!bit._svgMap.has(t)){const e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("class","bouncing-arrow-container"),e.setAttribute("pointer-events","none"),e.style.overflow="visible",e.style.position="absolute",e.style.top="0",e.style.left="0";const r=document.createElementNS("http://www.w3.org/2000/svg","g");r.setAttribute("class","bouncing-arrow-group"),e.appendChild(r),t.appendChild(e),bit._svgMap.set(t,e)}return bit._svgMap.get(t)}constructor(t,e,r){this.overlayRef=new WeakRef(t),this.target=e,this.decorator=r}get element(){const t=this.overlayRef.deref();if(!t)return null;const e=bit.getSvgContainer(t).querySelector(".bouncing-arrow-group"),r=bit.getArrowId(this.target),n=e.querySelector(`[data-arrow-id="${r}"]`);n&&n.remove();let{left:i,top:a,width:s}=this.target.bounds,{x:o,y:l}=this.target.transcoordS2T(i+s/2,a);o=Math.max(o,20),l=Math.max(l,20);const{color:h="red",duration:c=5e3,repeat:u=!0}=this.decorator||{},d=document.createElementNS("http://www.w3.org/2000/svg","path");d.setAttribute("d",this.createArrowPath(o,l)),d.setAttribute("fill",h),d.setAttribute("data-arrow-id",r),d.appendChild(this.createBounceAnimation(r,c,u)),e.appendChild(d);const p=this.createArrowLabel(o,l,h,this.target.state.id,r);return p&&(p.appendChild(this.createBounceAnimation(r,c,u)),e.appendChild(p)),d}createArrowPath(t,e){return`\n M${t-10},${e-16} \n L${t+10},${e-16} \n L${t+10},${e-8} \n L${t+16},${e-8} \n L${t},${e} \n L${t-16},${e-8} \n L${t-10},${e-8} \n Z\n `}createBounceAnimation(t,e,r){const n=document.createElementNS("http://www.w3.org/2000/svg","animateTransform");n.setAttribute("id",t),n.setAttribute("attributeName","transform"),n.setAttribute("type","translate");const i=e||5e3;let a=["0,-10"],s=[0];for(let t=1;t<=20;t++){const e=t/20;let r=Math.pow(e,.5);if(r=Math.min(r,.99).toFixed(3),parseFloat(s[s.length-1])>=parseFloat(r)&&(r=(parseFloat(s[s.length-1])+.01).toFixed(3)),a.push("0,0"),a.push("0,-10"),r>=1){s.push(1),s.push((parseFloat(1)+.01).toFixed(3));break}s.push(r),s.push((parseFloat(r)+.01).toFixed(3))}return s[s.length-1]="1.000",n.setAttribute("values",a.join(";")),n.setAttribute("keyTimes",s.join(";")),n.setAttribute("dur",`${i}ms`),r?n.setAttribute("repeatCount","indefinite"):(n.setAttribute("repeatCount","1"),n.addEventListener("endEvent",(()=>this.stop()))),n}createArrowLabel(t,e,r,n,i){if(!n)return null;const a=document.createElementNS("http://www.w3.org/2000/svg","g");a.setAttribute("data-arrow-label",i);const s=document.createElementNS("http://www.w3.org/2000/svg","rect");s.setAttribute("x",t+20),s.setAttribute("y",e-20),s.setAttribute("width","40"),s.setAttribute("height","20"),s.setAttribute("rx","3"),s.setAttribute("fill",r);const o=document.createElementNS("http://www.w3.org/2000/svg","text");return o.setAttribute("x",t+40),o.setAttribute("y",e-6),o.setAttribute("fill","white"),o.setAttribute("font-size","12px"),o.setAttribute("text-anchor","middle"),o.textContent=n,a.appendChild(s),a.appendChild(o),a}start(){const t=this.overlayRef.deref();if(!t)return;const e=bit.getSvgContainer(t),r=this.element;if(!r)return;const n=r.querySelector("animateTransform");n&&n.beginElement();const i=e.querySelector(`[data-arrow-label="${bit.getArrowId(this.target)}"]`);if(i){const t=i.querySelector("animateTransform");t&&t.beginElement()}}stop(){const t=this.overlayRef.deref();if(!t)return;const e=bit._svgMap.get(t);if(!e)return;const r=e.querySelector(".bouncing-arrow-group");if(!r)return;const n=bit.getArrowId(this.target),i=r.querySelector(`[data-arrow-id="${n}"]`),a=r.querySelector(`[data-arrow-label="${n}"]`);i&&(r.removeChild(i),i.remove()),a&&(r.removeChild(a),a.remove()),0===r.children.length&&(e.remove(),bit._svgMap.delete(t))}}pit(bit,"_svgMap",new WeakMap),pit(bit,"_arrowIdMap",new WeakMap);class wit{icon(t,e){if(this.targets&&-1!==this.targets.lastIndexOf(t))return;const r=new mit(t.root.model_layer.overlay,t,e);this.targets=(this.targets||[]).concat(t),this.animators=(this.animators||[]).concat(r),r.start()}border(t,e){if(this.targets&&-1!==this.targets.lastIndexOf(t))return;const r=new yit(t.root.model_layer.overlay,t,e);this.targets=(this.targets||[]).concat(t),this.animators=(this.animators||[]).concat(r),r.start()}bouncing(t,e){if(this.targets&&-1!==this.targets.lastIndexOf(t))return;const r=new bit(t.root.model_layer.overlay,t,e);this.targets=(this.targets||[]).concat(t),this.animators=(this.animators||[]).concat(r),r.start()}off(t){if(!this.targets)return;let e=this.targets.slice(),r=this.animators.slice(),n=this.targets.lastIndexOf(t);if(-1==n)return;e.splice(n,1);const i=r.splice(n,1);i[0]?.stop(),this.targets=e,this.animators=r}reset(t){this.animators?.forEach((t=>t.stop())),this.targets=[],this.animators=[]}}function xit(t){const{origin:e}=t,r=e.root,{animatorHandler:n}=r;n?.reset()}Xnt.register("animator-handler",{"model-layer":{"(descendant)":{icon:function(t,e){const{origin:r}=e,n=r.root;let{animatorHandler:i}=n;i||(i=new wit,n.animatorHandler=i),i.icon(r,t)},border:function(t,e){const{origin:r}=e,n=r.root;let{animatorHandler:i}=n;i||(i=new wit,n.animatorHandler=i),i.border(r,t)},bouncing:function(t,e){const{origin:r}=e,n=r.root;let{animatorHandler:i}=n;i||(i=new wit,n.animatorHandler=i),i.bouncing(r,t)},animatoroff:function(t){const{origin:e}=t,r=e.root,{animatorHandler:n}=r;n?n.off(e):console.warn("animator-handler not found")},animatorreset:xit},"(self)":{animatorreset:xit}}},(function(t){const{animatorHandler:e}=t;e?.reset(),delete t.animatorHandler}));var Ait=[],_it=s9((function(){Ait.forEach((t=>{t.resize()}))}),100);"undefined"!=typeof window&&window.addEventListener("resize",_it);class kit extends Iet{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),Ait.push(this)}dispose(){yet.hideAll(this),this._app&&this._app.dispose(),super.dispose(),this._disposeAllResources(),this.target_element=null,delete this._refresh_mapping_debouncer;var t=Ait.indexOf(this);t>=0&&Ait.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.setAttribute("root-element",""),t.style.position="absolute",t.style.cursor="default",t.style.overflow="hidden",this._ua_event_handler=new Unt(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&&M9("Template replaced (duplicated)",t,e,r),this.templateMap[t]=e,delete this.templatePrefixes}removeTemplate(t,e){var r=this.templateMap[t];r!==e?T9("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?T9("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&&M9("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?M9("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(X7(e.hierarchy),{id:t,templatePrefix:""});return component=mrt(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.model.handlers||[]).map((t=>{Xnt.getDisposer(t).call(null,this)})),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 Pnt(this),(t=t||{}).type="model-layer",this.model_layer=mrt(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=mrt(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,Xnt.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=s9((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=f9({},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(kit.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,s=r.clientHeight;e.set("scale",{x:a/n,y:s/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,s=r.clientHeight,o=a/n,l=s/i,h=Math.min(o,l);e.set("scale",{x:h,y:h}),e.set("translate",{x:(a-n*h)/2,y:(s-i*h)/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()}}}),ret.memoize(kit.prototype,"unitScale",!1);var Sit=13.3,Eit=function(t){return void 0!==t&&(Sit=t),Sit};const Mit="$base_url";const Tit=Math.PI/12;class Cit{constructor(t,e){this._mode=t,this.screen=Eit(),this._baseUrl="undefined"!=typeof window?window.location.origin:null,this._refProvider=e,this.isEditMode&&(this._rotateStep=Tit,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 z9}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(Mit)?new URL(t.replace(Mit,this.baseUrl),this.baseUrl):new URL(t,location.origin)).href}catch(e){T9(e,t)}}get rotateStep(){return this._rotateStep}set rotateStep(t){this._rotateStep=Number(t)||Tit}get rotateStepForced(){return this._rotateStepForced}set rotateStepForced(t){this._rotateStepForced=!!t}get dataStorage(){return this._dataStorage}set dataStorage(t){this._dataStorage=t}}E9(Cit.prototype,x9.withEvent);class Pit{constructor(t,e){!(t=Number(t))||t<=0?(M9("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];T9("Not forwardable.")}backward(){if(this.snapshot_taker&&this.snapshot_taker.take(),this.backwardable)return this.q[--this.pos];T9("Not backwardable.")}get current(){if(-1!==this.pos)return this.q[this.pos];T9("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 Iit=s9((t=>{t.brake||t.take()}),1e3,{leading:!0,trailing:!1});function Rit(t){!t.brake&&t.dirty&&Iit(t)}class Oit{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,Rit(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,Rit(this)}}function Lit(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 Dit{constructor(t){this.container=t,this.timecapsule=new Pit(20);var e=this;this.snapshot_taker=new Oit({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&&(Lit(this.timecapsule.backward(),this.container),this.trigger("undo",this.undoable(),this.redoable()))}redo(){this.timecapsule.forwardable&&(Lit(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")}}E9(Dit.prototype,x9.withEvent);var Fit=0;const Nit=new FinalizationRegistry((t=>{Fit--}));class jit{static get residents(){return Fit}static get residentsCount(){return Fit}constructor(t){this._container=t,this.app=t.app,this._commander=new Dit(this._container),this.app.commander=this._commander,Fit++,Nit.register(this,Fit)}add(){return wrt.apply(this._container,arguments)}duplicate(){return xrt.apply(this._container,arguments)}remove(){return Art.apply(this._container,arguments)}animate(){return w7.apply(this,arguments)}fullscreen(){return Ert.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 z9}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 Crt.apply(this._container,arguments)}copy(){return Trt.apply(this._container,arguments)}paste(){return Prt.apply(this._container,arguments)}undoableChange(){return $rt.apply(this._container,arguments)}change(){return Xrt.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)}findAllById(){return this._container.findAllById.apply(this._container,arguments)}serialize(){return this.root.trim(),this.root.serialize.apply(this.root,arguments)}align(){return hrt.apply(this._container,arguments)}place(){return nnt.apply(this._container,arguments)}distribute(){return drt.apply(this._container,arguments)}move(){return grt.apply(this._container,arguments)}zorder(){return vrt.apply(this._container,arguments)}symmetryX(){return Vrt.apply(this._container,arguments)}symmetryY(){return qrt.apply(this._container,arguments)}on(){return _rt.apply(this._container,arguments)}once(){return krt.apply(this._container,arguments)}off(){return this._container&&Srt.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 Wrt.apply(this._container,arguments)}group(){return Urt.apply(this._container,arguments)}ungroup(){return Hrt.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 Krt.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 int.apply(this._container,arguments)}startStylePasteMode(){return ant.apply(this._container,arguments)}stopStylePasteMode(){return snt.apply(this._container,arguments)}startDatabindPasteMode(){return ont.apply(this._container,arguments)}stopDatabindPasteMode(){return lnt.apply(this._container,arguments)}}const Bit=new class{load(t){}save(t,e){}clear(t){}};function zit({target:t,model:e,style:r,layers:n=[],handlers:i=[],mode:a=0,refProvider:s,dataSubscriptionProvider:o,dataStorage:l=Bit,baseUrl:h,fitMode:c}){var u=null;if("string"==typeof t){if(!(u=document.getElementById(t)))throw`target element '${t}' is not exist`;if(u.firstChild)throw`target element '${t}' is not empty`}else u=t;u&&u.style&&(u.style.position="absolute",u.style.cursor="default",u.style.overflow="hidden");var d=new Cit(a,s);return d.baseUrl=h,d.dataSubscriptionProvider=o,d.dataStorage=l,new jit(new kit({target_element:u,model:e,style:r,layers:n,handlers:i,fitMode:c},d))}
|
|
6
|
+
i=function(){return e};var t,e={},r=Object.prototype,a=r.hasOwnProperty,s=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},l=o.iterator||"@@iterator",h=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function d(t,e,r,n){var i=e&&e.prototype instanceof b?e:b,a=Object.create(i.prototype),o=new R(n||[]);return s(a,"_invoke",{value:T(t,r,o)}),a}function p(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=d;var f="suspendedStart",g="suspendedYield",v="executing",m="completed",y={};function b(){}function w(){}function x(){}var A={};u(A,l,(function(){return this}));var _=Object.getPrototypeOf,k=_&&_(_(O([])));k&&k!==r&&a.call(k,l)&&(A=k);var S=x.prototype=b.prototype=Object.create(A);function E(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function M(t,e){function r(i,s,o,l){var h=p(t[i],t,s);if("throw"!==h.type){var c=h.arg,u=c.value;return u&&"object"==n(u)&&a.call(u,"__await")?e.resolve(u.__await).then((function(t){r("next",t,o,l)}),(function(t){r("throw",t,o,l)})):e.resolve(u).then((function(t){c.value=t,o(c)}),(function(t){return r("throw",t,o,l)}))}l(h.arg)}var i;s(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=f;return function(a,s){if(i===v)throw new Error("Generator is already running");if(i===m){if("throw"===a)throw s;return{value:t,done:!0}}for(n.method=a,n.arg=s;;){var o=n.delegate;if(o){var l=C(o,n);if(l){if(l===y)continue;return l}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===f)throw i=m,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=v;var h=p(e,r,n);if("normal"===h.type){if(i=n.done?m:g,h.arg===y)continue;return{value:h.arg,done:n.done}}"throw"===h.type&&(i=m,n.method="throw",n.arg=h.arg)}}}function C(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,C(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),y;var a=p(i,e.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,y;var s=a.arg;return s?s.done?(r[e.resultName]=s.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,y):s:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,y)}function P(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 R(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(P,this),this.reset(!0)}function O(e){if(e||""===e){var r=e[l];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,s=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 s.next=s}}throw new TypeError(n(e)+" is not iterable")}return w.prototype=x,s(S,"constructor",{value:x,configurable:!0}),s(x,"constructor",{value:w,configurable:!0}),w.displayName=u(x,c,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===w||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,x):(t.__proto__=x,u(t,c,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},E(M.prototype),u(M.prototype,h,(function(){return this})),e.AsyncIterator=M,e.async=function(t,r,n,i,a){void 0===a&&(a=Promise);var s=new M(d(t,r,n,i),a);return e.isGeneratorFunction(r)?s:s.next().then((function(t){return t.done?t.value:s.next()}))},E(S),u(S,c,"Generator"),u(S,l,(function(){return this})),u(S,"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=O,R.prototype={constructor:R,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 o.type="throw",o.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var i=this.tryEntries.length-1;i>=0;--i){var s=this.tryEntries[i],o=s.completion;if("root"===s.tryLoc)return n("end");if(s.tryLoc<=this.prev){var l=a.call(s,"catchLoc"),h=a.call(s,"finallyLoc");if(l&&h){if(this.prev<s.catchLoc)return n(s.catchLoc,!0);if(this.prev<s.finallyLoc)return n(s.finallyLoc)}else if(l){if(this.prev<s.catchLoc)return n(s.catchLoc,!0)}else{if(!h)throw new Error("try statement without catch or finally");if(this.prev<s.finallyLoc)return n(s.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 s=i?i.completion:{};return s.type=t,s.arg=e,i?(this.method="next",this.next=i.finallyLoc,y):this.complete(s)},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),y},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),y}},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:O(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),y}},e}var a=t("./datetime"),s=t("./functions"),o=t("./utils"),l=t("./parser"),h=t("./signature"),c=function(){var t=i().mark(z),e=i().mark(W),r=i().mark(H),c=i().mark(G),u=i().mark(Y),d=i().mark(V),p=i().mark(q),f=i().mark(X),g=i().mark(at),v=i().mark(lt),m=i().mark(ut),y=i().mark(dt),b=i().mark(pt),w=i().mark(vt),x=i().mark(bt),A=i().mark(wt),_=i().mark(xt),k=i().mark(At),S=i().mark(kt),E=i().mark(Et),M=i().mark(Ct),T=i().mark(Rt),C=o.isNumeric,P=o.isArrayOfStrings,I=o.isArrayOfNumbers,R=o.createSequence,O=o.isSequence,L=o.isFunction,D=o.isLambda,F=o.isIterable,N=o.getFunctionArity,j=o.isDeepEqual,B=Lt(null);function z(e,r,n){var a,s,o,l;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:(s=n.lookup("__evaluate_entry"))&&s(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(W(e,r,n),"t1",6);case 6:return a=t.t1,t.abrupt("break",50);case 8:return t.delegateYield(q(e,r,n),"t2",9);case 9:return a=t.t2,t.abrupt("break",50);case 11:return t.delegateYield(X(e,r,n),"t3",12);case 12:return a=t.t3,t.abrupt("break",50);case 14:return a=$(e,r),t.abrupt("break",50);case 16:return a=K(e),t.abrupt("break",50);case 18:return a=Q(e,r),t.abrupt("break",50);case 20:return a=Z(e,r),t.abrupt("break",50);case 22:return a=n.lookup(e.slot.label),t.abrupt("break",50);case 24:return t.delegateYield(dt(e,r,n),"t4",25);case 25:return a=t.t4,t.abrupt("break",50);case 27:return t.delegateYield(pt(e,r,n),"t5",28);case 28:return a=t.t5,t.abrupt("break",50);case 30:return t.delegateYield(ut(e,r,n),"t6",31);case 31:return a=t.t6,t.abrupt("break",50);case 33:return a=ft(e),t.abrupt("break",50);case 35:return t.delegateYield(wt(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=mt(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}o=0;case 59:if(!(o<e.predicate.length)){t.next=65;break}return t.delegateYield(V(e.predicate[o].expr,a,n),"t10",61);case 61:a=t.t10;case 62:o++,t.next=59;break;case 65:if("path"===e.type||!Object.prototype.hasOwnProperty.call(e,"group")){t.next=68;break}return t.delegateYield(lt(e.group,a,n),"t11",67);case 67:a=t.t11;case 68:return(l=n.lookup("__evaluate_exit"))&&l(e,r,n,a),a&&O(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 W(t,r,n){var a,s,o,l,h,c;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=Array.isArray(r)&&"variable"!==t.steps[0].type?r:R(r),o=!1,l=void 0,h=0;case 4:if(!(h<t.steps.length)){e.next=25;break}if((c=t.steps[h]).tuple&&(o=!0),0!==h||!c.consarray){e.next=12;break}return e.delegateYield(z(c,a,n),"t0",9);case 9:s=e.t0,e.next=19;break;case 12:if(!o){e.next=17;break}return e.delegateYield(Y(c,a,l,n),"t1",14);case 14:l=e.t1,e.next=19;break;case 17:return e.delegateYield(H(c,a,n,h===t.steps.length-1),"t2",18);case 18:s=e.t2;case 19:if(o||void 0!==s&&0!==s.length){e.next=21;break}return e.abrupt("break",25);case 21:void 0===c.focus&&(a=s);case 22:h++,e.next=4;break;case 25:if(o)if(t.tuple)s=l;else for(s=R(),h=0;h<l.length;h++)s.push(l[h]["@"]);if(t.keepSingletonArray&&(Array.isArray(s)&&s.cons&&!s.sequence&&(s=R(s)),s.keepSingleton=!0),!t.hasOwnProperty("group")){e.next=30;break}return e.delegateYield(lt(t.group,o?l:s,n),"t3",29);case 29:s=e.t3;case 30:return e.abrupt("return",s);case 31:case"end":return e.stop()}}),e)}function U(t,e){var r=Lt(t);for(var n in e)r.bind(n,e[n]);return r}function H(t,e,n,a){var s,o,l,h,c;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(s=r.t0,!t.stages){r.next=6;break}return r.delegateYield(G(t.stages,s,n),"t1",5);case 5:s=r.t1;case 6:return r.abrupt("return",s);case 7:s=R(),o=0;case 9:if(!(o<e.length)){r.next=24;break}return r.delegateYield(z(t,e[o],n),"t2",11);case 11:if(l=r.t2,!t.stages){r.next=20;break}h=0;case 14:if(!(h<t.stages.length)){r.next=20;break}return r.delegateYield(V(t.stages[h].expr,l,n),"t3",16);case 16:l=r.t3;case 17:h++,r.next=14;break;case 20:void 0!==l&&s.push(l);case 21:o++,r.next=9;break;case 24:return c=R(),a&&1===s.length&&Array.isArray(s[0])&&!O(s[0])?c=s[0]:s.forEach((function(t){!Array.isArray(t)||t.cons?c.push(t):t.forEach((function(t){return c.push(t)}))})),r.abrupt("return",c);case 27:case"end":return r.stop()}}),r)}function G(t,e,r){var n,a,s,o;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}s=t[a],i.t0=s.type,i.next="filter"===i.t0?7:"index"===i.t0?10:12;break;case 7:return i.delegateYield(V(s.expr,n,r),"t1",8);case 8:return n=i.t1,i.abrupt("break",12);case 10:for(o=0;o<n.length;o++)n[o][s.value]=o;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()}}),c)}function Y(t,e,r,n){var a,s,o,l,h,c,d,p;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(s=i.t1,(a=R()).tupleStream=!0,o=0;o<s.length;o++)(l={"@":s[o]})[t.index]=o,a.push(l);case 11:if(!t.stages){i.next=14;break}return i.delegateYield(G(t.stages,a,n),"t2",13);case 13:a=i.t2;case 14:return i.abrupt("return",a);case 15:(a=R()).tupleStream=!0,h=n,void 0===r&&(r=e.map((function(t){return{"@":t}}))),c=0;case 20:if(!(c<r.length)){i.next=28;break}return h=U(n,r[c]),i.delegateYield(z(t,r[c]["@"],h),"t3",23);case 23:if(void 0!==(d=i.t3))for(Array.isArray(d)||(d=[d]),p=0;p<d.length;p++)l={},Object.assign(l,r[c]),d.tupleStream?Object.assign(l,d[p]):(t.focus?(l[t.focus]=d[p],l["@"]=r[c]["@"]):l["@"]=d[p],t.index&&(l[t.index]=p),t.ancestor&&(l[t.ancestor.label]=r[c]["@"])),a.push(l);case 25:c++,i.next=20;break;case 28:if(!t.stages){i.next=31;break}return i.delegateYield(G(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()}}),u)}function V(t,e,r){var n,a,o,l,h,c;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(n=R(),e&&e.tupleStream&&(n.tupleStream=!0),Array.isArray(e)||(e=R(e)),"number"!==t.type){i.next=10;break}(a=Math.floor(t.value))<0&&(a=e.length+a),void 0!==(o=e[a])&&(Array.isArray(o)?n=o:n.push(o)),i.next=23;break;case 10:a=0;case 11:if(!(a<e.length)){i.next=23;break}return o=e[a],l=o,h=r,e.tupleStream&&(l=o["@"],h=U(r,o)),i.delegateYield(z(t,l,h),"t0",17);case 17:c=i.t0,C(c)&&(c=[c]),I(c)?c.forEach((function(t){var r=Math.floor(t);r<0&&(r=e.length+r),r===a&&n.push(o)})):s.boolean(c)&&n.push(o);case 20:a++,i.next=11;break;case 23:return i.abrupt("return",n);case 24:case"end":return i.stop()}}),d)}function q(t,e,r){var n,a,s,o,l;return i().wrap((function(h){for(;;)switch(h.prev=h.next){case 0:return h.delegateYield(z(t.lhs,e,r),"t0",1);case 1:if(a=h.t0,s=t.value,o=i().mark((function n(){return i().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.delegateYield(z(t.rhs,e,r),"t0",1);case 1:return n.abrupt("return",n.t0);case 2:case"end":return n.stop()}}),n)})),"and"!==s&&"or"!==s){h.next=15;break}return h.prev=5,h.delegateYield(at(a,o,s),"t1",7);case 7:return h.abrupt("return",h.t1);case 10:throw h.prev=10,h.t2=h.catch(5),h.t2.position=t.position,h.t2.token=s,h.t2;case 15:return h.delegateYield(o(),"t3",16);case 16:l=h.t3,h.prev=17,h.t4=s,h.next="+"===h.t4||"-"===h.t4||"*"===h.t4||"/"===h.t4||"%"===h.t4?21:"="===h.t4||"!="===h.t4?23:"<"===h.t4||"<="===h.t4||">"===h.t4||">="===h.t4?25:"&"===h.t4?27:".."===h.t4?29:"in"===h.t4?31:33;break;case 21:return n=et(a,l,s),h.abrupt("break",33);case 23:return n=rt(a,l,s),h.abrupt("break",33);case 25:return n=nt(a,l,s),h.abrupt("break",33);case 27:return n=ot(a,l),h.abrupt("break",33);case 29:return n=ct(a,l),h.abrupt("break",33);case 31:return n=it(a,l),h.abrupt("break",33);case 33:h.next=40;break;case 35:throw h.prev=35,h.t5=h.catch(17),h.t5.position=t.position,h.t5.token=s,h.t5;case 40:return h.abrupt("return",n);case 41:case"end":return h.stop()}}),p,null,[[5,10],[17,35]])}function X(t,e,r){var n,a,o,l;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(z(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(!C(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 o=t.expressions[a],i.delegateYield(z(o,e,r),"t2",20);case 20:void 0!==(l=i.t2)&&("["===o.value?n.push(l):n=s.append(n,l));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(lt(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()}}),f)}function $(t,e,r){return s.lookup(e,t.value)}function K(t){return t.value}function Q(t,e){var r=R();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=J(n),r=s.append(r,n)):r.push(n)})),r}function J(t,e){return void 0===e&&(e=[]),Array.isArray(t)?t.forEach((function(t){J(t,e)})):e.push(t),e}function Z(t,e){var r,n=R();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&&!C(t))throw{code:"T2001",stack:(new Error).stack,value:t};if(void 0!==e&&!C(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),s=n(e);if("undefined"===a||"undefined"===s)return!1;switch(r){case"=":i=j(t,e);break;case"!=":i=!j(t,e)}return i}function nt(t,e,r){var i,a=n(t),s=n(e);if("undefined"!==a&&"string"!==a&&"number"!==a||"undefined"!==s&&"string"!==s&&"number"!==s)throw{code:"T2010",stack:(new Error).stack,value:"string"!==a&&"number"!==a?t:e};if("undefined"!==a&&"undefined"!==s){if(a!==s)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=st(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=st,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=st,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 st(t){var e=s.boolean(t);return void 0!==e&&e}function ot(t,e){var r="",n="";return void 0!==t&&(r=s.string(t)),void 0!==e&&(n=s.string(e)),r.concat(n)}function lt(t,e,r){var n,a,o,l,h,c,u,d,p,f,g,m,y;return i().wrap((function(v){for(;;)switch(v.prev=v.next){case 0:n={},a={},o=!(!e||!e.tupleStream),Array.isArray(e)||(e=R(e)),0===e.length&&e.push(void 0),l=0;case 6:if(!(l<e.length)){v.next=31;break}h=e[l],c=o?U(r,h):r,u=0;case 10:if(!(u<t.lhs.length)){v.next=28;break}return d=t.lhs[u],v.delegateYield(z(d[0],o?h["@"]:h,c),"t0",13);case 13:if("string"==typeof(p=v.t0)||void 0===p){v.next=16;break}throw{code:"T1003",stack:(new Error).stack,position:t.position,value:p};case 16:if(void 0===p){v.next=25;break}if(f={data:h,exprIndex:u},!a.hasOwnProperty(p)){v.next=24;break}if(a[p].exprIndex===u){v.next=21;break}throw{code:"D1009",stack:(new Error).stack,position:t.position,value:p};case 21:a[p].data=s.append(a[p].data,h),v.next=25;break;case 24:a[p]=f;case 25:u++,v.next=10;break;case 28:l++,v.next=6;break;case 31:v.t1=i().keys(a);case 32:if((v.t2=v.t1()).done){v.next=43;break}return p=v.t2.value,f=a[p],g=f.data,c=r,o&&(m=ht(f.data),g=m["@"],delete m["@"],c=U(r,m)),v.delegateYield(z(t.lhs[f.exprIndex][1],g,c),"t3",39);case 39:void 0!==(y=v.t3)&&(n[p]=y),v.next=32;break;case 43:return v.abrupt("return",n);case 44:case"end":return v.stop()}}),v)}function ht(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]=s.append(e[n],t[r][n]);return e}function ct(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 ut(t,e,r){var n;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return i.delegateYield(z(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()}}),m)}function dt(t,e,r){var n,a;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return i.delegateYield(z(t.condition,e,r),"t0",1);case 1:if(a=i.t0,!s.boolean(a)){i.next=7;break}return i.delegateYield(z(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(z(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()}}),y)}function pt(t,e,r){var n,a,s;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:a=Lt(r),s=0;case 2:if(!(s<t.expressions.length)){i.next=8;break}return i.delegateYield(z(t.expressions[s],e,a),"t0",4);case 4:n=i.t0;case 5:s++,i.next=2;break;case 8:return i.abrupt("return",n);case 9:case"end":return i.stop()}}),b)}function ft(t){var e=new Nt.RegexEngine(t.value),r=function r(n,i){var a;e.lastIndex=i||0;var s=e.exec(n);if(null!==s){if(a={match:s[0],start:s.index,end:s.index+s[0].length,groups:[]},s.length>1)for(var o=1;o<s.length;o++)a.groups.push(s[o]);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,o,l,h,c;return i().wrap((function(u){for(;;)switch(u.prev=u.next){case 0:return o=e,l=!!e.tupleStream,h=i().mark((function e(a,s){var o,h,c,u,d,p,f,g,v;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:o=0,h=0;case 2:if(!(0===o&&h<t.terms.length)){e.next=35;break}return c=t.terms[h],u=a,d=r,l&&(u=a["@"],d=U(r,a)),e.delegateYield(z(c.expression,u,d),"t0",8);case 8:return p=e.t0,u=s,d=r,l&&(u=s["@"],d=U(r,s)),e.delegateYield(z(c.expression,u,d),"t1",13);case 13:if(f=e.t1,g=n(p),v=n(f),"undefined"!==g){e.next=19;break}return o="undefined"===v?0:1,e.abrupt("continue",32);case 19:if("undefined"!==v){e.next=22;break}return o=-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?p:f};case 24:if(g===v){e.next=26;break}throw{code:"T2007",stack:(new Error).stack,position:t.position,value:p,value2:f};case 26:if(p!==f){e.next=30;break}return e.abrupt("continue",32);case 30:o=p<f?-1:1;case 31:!0===c.descending&&(o=-o);case 32:h++,e.next=2;break;case 35:return e.abrupt("return",1===o);case 36:case"end":return e.stop()}}),e)})),c={environment:r,input:e},u.delegateYield(s.sort.apply(c,[o,h]),"t0",5);case 5:return a=u.t0,u.abrupt("return",a);case 7:case"end":return u.stop()}}),w)}function mt(t,e,r){var a=i().mark((function e(a){var s,o,l,h,c,u,d,p,f,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(s=r.lookup("clone"),L(s)){e.next=5;break}throw{code:"T2013",stack:(new Error).stack,position:t.position};case 5:return e.delegateYield(xt(s,[a],null,r),"t0",6);case 6:return o=e.t0,e.delegateYield(z(t.pattern,o,r),"t1",8);case 8:if(void 0===(l=e.t1)){e.next=35;break}Array.isArray(l)||(l=[l]),h=0;case 12:if(!(h<l.length)){e.next=35;break}if(!(c=l[h])||!(c.isPrototypeOf(o)||c instanceof Object.constructor)){e.next=16;break}throw{code:"D1010",stack:(new Error).stack,position:t.position};case 16:return e.delegateYield(z(t.update,c,r),"t2",17);case 17:if(u=e.t2,"undefined"===(d=n(u))){e.next=23;break}if("object"===d&&null!==u&&!Array.isArray(u)){e.next=22;break}throw{code:"T2011",stack:(new Error).stack,position:t.update.position,value:u};case 22:for(p in u)c[p]=u[p];case 23:if(void 0===t.delete){e.next=32;break}return e.delegateYield(z(t.delete,c,r),"t3",25);case 25:if(void 0===(f=e.t3)){e.next=32;break}if(g=f,Array.isArray(f)||(f=[f]),P(f)){e.next=31;break}throw{code:"T2012",stack:(new Error).stack,position:t.delete.position,value:g};case 31:for(v=0;v<f.length;v++)"object"===n(c)&&null!==c&&delete c[f[v]];case 32:h++,e.next=12;break;case 35:return e.abrupt("return",o);case 36:case"end":return e.stop()}}),e)}));return It(a,"<(oa):o>")}var yt=l("function($f, $g) { function($x){ $g($f($x)) } }");function bt(t,e,r){var n,a,s,o;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return i.delegateYield(z(t.lhs,e,r),"t0",1);case 1:if(a=i.t0,"function"!==t.rhs.type){i.next=7;break}return i.delegateYield(wt(t.rhs,e,r,{context:a}),"t1",4);case 4:n=i.t1,i.next=20;break;case 7:return i.delegateYield(z(t.rhs,e,r),"t2",8);case 8:if(s=i.t2,L(s)){i.next=11;break}throw{code:"T2006",stack:(new Error).stack,position:t.position,value:s};case 11:if(!L(a)){i.next=18;break}return i.delegateYield(z(yt,null,r),"t3",13);case 13:return o=i.t3,i.delegateYield(xt(o,[a,s],null,r),"t4",15);case 15:n=i.t4,i.next=20;break;case 18:return i.delegateYield(xt(s,[a],null,r),"t5",19);case 19:n=i.t5;case 20:return i.abrupt("return",n);case 21:case"end":return i.stop()}}),x)}function wt(t,e,r,a){var s,o,l,h,c,u;return i().wrap((function(d){for(;;)switch(d.prev=d.next){case 0:return d.delegateYield(z(t.procedure,e,r),"t0",1);case 1:if(void 0!==(o=d.t0)||"path"!==t.procedure.type||!r.lookup(t.procedure.steps[0].value)){d.next=4;break}throw{code:"T1005",stack:(new Error).stack,position:t.position,token:t.procedure.steps[0].value};case 4:l=[],void 0!==a&&l.push(a.context),h=i().mark((function n(){var a,s;return i().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.delegateYield(z(t.arguments[c],e,r),"t0",1);case 1:a=n.t0,L(a)?(s=i().mark((function t(){var e,n,s,o=arguments;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:for(e=o.length,n=new Array(e),s=0;s<e;s++)n[s]=o[s];return t.delegateYield(xt(a,n,null,r),"t0",2);case 2:return t.abrupt("return",t.t0);case 3:case"end":return t.stop()}}),t)})),s.arity=N(a),l.push(s)):l.push(a);case 3:case"end":return n.stop()}}),n)})),c=0;case 8:if(!(c<t.arguments.length)){d.next=13;break}return d.delegateYield(h(),"t1",10);case 10:c++,d.next=8;break;case 13:return u="path"===t.procedure.type?t.procedure.steps[0].value:t.procedure.value,d.prev=14,"object"===n(o)&&(o.token=u,o.position=t.position),d.delegateYield(xt(o,l,e,r),"t2",17);case 17:s=d.t2,d.next=25;break;case 20:throw d.prev=20,d.t3=d.catch(14),d.t3.position||(d.t3.position=t.position),d.t3.token||(d.t3.token=u),d.t3;case 25:return d.abrupt("return",s);case 26:case"end":return d.stop()}}),A,null,[[14,20]])}function xt(t,e,r,n){var a,s,o,l;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(!D(a)||!0!==a.thunk){i.next=21;break}return i.delegateYield(z(a.body.procedure,a.input,a.environment),"t1",4);case 4:s=i.t1,"variable"===a.body.procedure.type&&(s.token=a.body.procedure.value),s.position=a.body.procedure.position,o=[],l=0;case 9:if(!(l<a.body.arguments.length)){i.next=17;break}return i.t2=o,i.delegateYield(z(a.body.arguments[l],a.input,a.environment),"t3",12);case 12:i.t4=i.t3,i.t2.push.call(i.t2,i.t4);case 14:l++,i.next=9;break;case 17:return i.delegateYield(At(s,o,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,s,o;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(i.prev=0,s=e,t&&(s=St(t.signature,e,r)),!D(t)){i.next=8;break}return i.delegateYield(Et(t,s),"t0",5);case 5:a=i.t0,i.next=24;break;case 8:if(!t||!0!==t._jsonata_function){i.next=16;break}if(o={environment:n,input:r},a=t.implementation.apply(o,s),!F(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,s),!F(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(xt(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,s,o,l;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:a=[],s=0;case 2:if(!(s<t.arguments.length)){i.next=15;break}if("operator"!==(o=t.arguments[s]).type||"?"!==o.value){i.next=8;break}a.push(o),i.next=12;break;case 8:return i.t0=a,i.delegateYield(z(o,e,r),"t1",10);case 10:i.t2=i.t1,i.t0.push.call(i.t0,i.t2);case 12:s++,i.next=2;break;case 15:return i.delegateYield(z(t.procedure,e,r),"t3",16);case 16:if(void 0!==(l=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(!D(l)){i.next=23;break}n=Mt(l,a),i.next=32;break;case 23:if(!l||!0!==l._jsonata_function){i.next=27;break}n=Tt(l.implementation,a),i.next=32;break;case 27:if("function"!=typeof l){i.next=31;break}n=Tt(l,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()}}),S)}function St(t,e,r){return void 0===t?e:t.validate(e,r)}function Et(t,e){var r,n;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(n=Lt(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(Ct(t.body,n),"t0",4);case 4:r=i.t0,i.next=9;break;case 7:return i.delegateYield(z(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()}}),E)}function Mt(t,e){var r=Lt(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=Pt(t),n="function("+(r=r.map((function(t){return"$"+t.trim()}))).join(", ")+"){ _ }",i=l(n);return i.body=t,Mt(i,e)}function Ct(t,e){var r,n,a,s;return i().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(r=Pt(t),n=r.map((function(t){return e.lookup(t.trim())})),a={environment:e},s=t.apply(a,n),!F(s)){i.next=7;break}return i.delegateYield(s,"t0",6);case 6:s=i.t0;case 7:return i.abrupt("return",s);case 8:case"end":return i.stop()}}),M)}function Pt(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=h(e)),r}function Rt(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)&&!O(r)&&((r=R(r)).outerWrapper=!0)),i.prev=4,n=l(t,!1),i.next=12;break;case 8:throw i.prev=8,i.t0=i.catch(4),Ft(i.t0),{stack:(new Error).stack,code:"D3120",value:i.t0.message,error:i.t0};case 12:return i.prev=12,i.delegateYield(z(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),Ft(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 Ot(t){if(void 0!==t)return JSON.parse(s.string(t))}function Lt(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]}}}B.bind("sum",It(s.sum,"<a<n>:n>")),B.bind("count",It(s.count,"<a:n>")),B.bind("max",It(s.max,"<a<n>:n>")),B.bind("min",It(s.min,"<a<n>:n>")),B.bind("average",It(s.average,"<a<n>:n>")),B.bind("string",It(s.string,"<x-b?:s>")),B.bind("substring",It(s.substring,"<s-nn?:s>")),B.bind("substringBefore",It(s.substringBefore,"<s-s:s>")),B.bind("substringAfter",It(s.substringAfter,"<s-s:s>")),B.bind("lowercase",It(s.lowercase,"<s-:s>")),B.bind("uppercase",It(s.uppercase,"<s-:s>")),B.bind("length",It(s.length,"<s-:n>")),B.bind("trim",It(s.trim,"<s-:s>")),B.bind("pad",It(s.pad,"<s-ns?:s>")),B.bind("match",It(s.match,"<s-f<s:o>n?:a<o>>")),B.bind("contains",It(s.contains,"<s-(sf):b>")),B.bind("replace",It(s.replace,"<s-(sf)(sf)n?:s>")),B.bind("split",It(s.split,"<s-(sf)n?:a<s>>")),B.bind("join",It(s.join,"<a<s>s?:s>")),B.bind("formatNumber",It(s.formatNumber,"<n-so?:s>")),B.bind("formatBase",It(s.formatBase,"<n-n?:s>")),B.bind("formatInteger",It(a.formatInteger,"<n-s:s>")),B.bind("parseInteger",It(a.parseInteger,"<s-s:n>")),B.bind("number",It(s.number,"<(nsb)-:n>")),B.bind("floor",It(s.floor,"<n-:n>")),B.bind("ceil",It(s.ceil,"<n-:n>")),B.bind("round",It(s.round,"<n-n?:n>")),B.bind("abs",It(s.abs,"<n-:n>")),B.bind("sqrt",It(s.sqrt,"<n-:n>")),B.bind("power",It(s.power,"<n-n:n>")),B.bind("random",It(s.random,"<:n>")),B.bind("boolean",It(s.boolean,"<x-:b>")),B.bind("not",It(s.not,"<x-:b>")),B.bind("map",It(s.map,"<af>")),B.bind("zip",It(s.zip,"<a+>")),B.bind("filter",It(s.filter,"<af>")),B.bind("single",It(s.single,"<af?>")),B.bind("reduce",It(s.foldLeft,"<afj?:j>")),B.bind("sift",It(s.sift,"<o-f?:o>")),B.bind("keys",It(s.keys,"<x-:a<s>>")),B.bind("lookup",It(s.lookup,"<x-s:x>")),B.bind("append",It(s.append,"<xx:a>")),B.bind("exists",It(s.exists,"<x:b>")),B.bind("spread",It(s.spread,"<x-:a<o>>")),B.bind("merge",It(s.merge,"<a<o>:o>")),B.bind("reverse",It(s.reverse,"<a:a>")),B.bind("each",It(s.each,"<o-f:a>")),B.bind("error",It(s.error,"<s?:x>")),B.bind("assert",It(s.assert,"<bs?:x>")),B.bind("type",It(s.type,"<x:s>")),B.bind("sort",It(s.sort,"<af?:a>")),B.bind("shuffle",It(s.shuffle,"<a:a>")),B.bind("distinct",It(s.distinct,"<x:x>")),B.bind("base64encode",It(s.base64encode,"<s-:s>")),B.bind("base64decode",It(s.base64decode,"<s-:s>")),B.bind("encodeUrlComponent",It(s.encodeUrlComponent,"<s-:s>")),B.bind("encodeUrl",It(s.encodeUrl,"<s-:s>")),B.bind("decodeUrlComponent",It(s.decodeUrlComponent,"<s-:s>")),B.bind("decodeUrl",It(s.decodeUrl,"<s-:s>")),B.bind("eval",It(Rt,"<sx?:x>")),B.bind("toMillis",It(a.toMillis,"<s-s?:n>")),B.bind("fromMillis",It(a.fromMillis,"<n-s?s?:s>")),B.bind("clone",It(Ot,"<(oa)-:o>"));var Dt={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 Ft(t){var e=Dt[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 Nt(t,e){var r,n;try{r=l(t,e&&e.recover),n=r.errors,delete r.errors}catch(t){throw Ft(t),t}var i=Lt(B),s=new Date;return i.bind("now",It((function(t,e){return a.fromMillis(s.getTime(),t,e)}),"<s?s?:s>")),i.bind("millis",It((function(){return s.getTime()}),"<:n>")),e&&e.RegexEngine?Nt.RegexEngine=e.RegexEngine:Nt.RegexEngine=RegExp,{evaluate:function(t,e,a){if(void 0!==n){var o={code:"S0500",position:0};throw Ft(o),o}var l,h,c;if(void 0!==e)for(var u in l=Lt(i),e)l.bind(u,e[u]);else l=i;if(l.bind("$",t),s=new Date,l.timestamp=s,Array.isArray(t)&&!O(t)&&((t=R(t)).outerWrapper=!0),"function"==typeof a){l.async=!0;var d=function(t){Ft(t),a(t,null)},p=function t(e){(h=c.next(e)).done?a(null,h.value):h.value.then(t).catch(d)};c=z(r,t,l),(h=c.next()).value.then(p).catch(d)}else try{for(c=z(r,t,l),h=c.next();!h.done;)h=c.next(h.value);return h.value}catch(o){throw Ft(o),o}},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 Nt.parser=l,Nt}();e.exports=c},{"./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}},s=function(){for(var t,e,a=n,s=0;n<i;){var o=r.charAt(n);if("/"===o&&"\\"!==r.charAt(n-1)&&0===s){if(""===(t=r.substring(a,n)))throw{code:"S0301",stack:(new Error).stack,position:n};for(n++,o=r.charAt(n),a=n;"i"===o||"m"===o;)n++,o=r.charAt(n);return e=r.substring(a,n)+"g",new RegExp(t,e)}"("!==o&&"["!==o&&"{"!==o||"\\"===r.charAt(n-1)||s++,")"!==o&&"]"!==o&&"}"!==o||"\\"===r.charAt(n-1)||s--,n++}throw{code:"S0302",stack:(new Error).stack,position:n}},o=function o(l){if(n>=i)return null;for(var h=r.charAt(n);n<i&&" \t\n\r\v".indexOf(h)>-1;)n++,h=r.charAt(n);if("/"===h&&"*"===r.charAt(n+1)){var c=n;for(n+=2,h=r.charAt(n);"*"!==h||"/"!==r.charAt(n+1);)if(h=r.charAt(++n),n>=i)throw{code:"S0106",stack:(new Error).stack,position:c};return n+=2,h=r.charAt(n),o(l)}if(!0!==l&&"/"===h)return n++,a("regex",s());if("."===h&&"."===r.charAt(n+1))return n+=2,a("operator","..");if(":"===h&&"="===r.charAt(n+1))return n+=2,a("operator",":=");if("!"===h&&"="===r.charAt(n+1))return n+=2,a("operator","!=");if(">"===h&&"="===r.charAt(n+1))return n+=2,a("operator",">=");if("<"===h&&"="===r.charAt(n+1))return n+=2,a("operator","<=");if("*"===h&&"*"===r.charAt(n+1))return n+=2,a("operator","**");if("~"===h&&">"===r.charAt(n+1))return n+=2,a("operator","~>");if(Object.prototype.hasOwnProperty.call(t,h))return n++,a("operator",h);if('"'===h||"'"===h){var u=h;n++;for(var d="";n<i;){if("\\"===(h=r.charAt(n)))if(n++,h=r.charAt(n),Object.prototype.hasOwnProperty.call(e,h))d+=e[h];else{if("u"!==h)throw{code:"S0103",stack:(new Error).stack,position:n,token:h};var p=r.substr(n+1,4);if(!/^[0-9a-fA-F]+$/.test(p))throw{code:"S0104",stack:(new Error).stack,position:n};var f=parseInt(p,16);d+=String.fromCharCode(f),n+=4}else{if(h===u)return n++,a("string",d);d+=h}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 m=parseFloat(v[0]);if(!isNaN(m)&&isFinite(m))return n+=v[0].length,a("number",m);throw{code:"S0102",stack:(new Error).stack,position:n,token:v[0]}}if("`"===h){n++;var y=r.indexOf("`",n);if(-1!==y)return g=r.substring(n,y),n=y+1,a("name",g);throw n=i,{code:"S0105",stack:(new Error).stack,position:n}}for(var b,w=n;;)if(b=r.charAt(w),w===i||" \t\n\r\v".indexOf(b)>-1||Object.prototype.hasOwnProperty.call(t,b)){if("$"===r.charAt(n))return g=r.substring(n+1,w),n=w,a("variable",g);switch(g=r.substring(n,w),n=w,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 w++};return o},i=function(e,i){var a,s,o={},l=[],h=function(){var t=[];"(end)"!==a.id&&t.push({type:a.type,value:a.value,position:a.position});for(var e=s();null!==e;)t.push(e),e=s();return t},c={nud:function(){var t={code:"S0211",token:this.value,position:this.position};if(i)return t.remaining=h(),t.type="error",l.push(t),t;throw t.stack=(new Error).stack,t}},u=function(t,e){var r=o[t];return e=e||0,r?e>=r.lbp&&(r.lbp=e):((r=Object.create(c)).id=r.value=t,r.lbp=e,o[t]=r),r},d=function(t){if(i){t.remaining=h(),l.push(t);var e=o["(error)"];return(a=Object.create(e)).error=t,a.type="(error)",a}throw t.stack=(new Error).stack,t},p=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 d(n)}var i=s(r);if(null===i)return(a=o["(end)"]).position=e.length,a;var l,h=i.value,c=i.type;switch(c){case"name":case"variable":l=o["(name)"];break;case"operator":if(!(l=o[h]))return d({code:"S0204",stack:(new Error).stack,position:i.position,token:h});break;case"string":case"number":case"value":l=o["(literal)"];break;case"regex":c="regex",l=o["(regex)"];break;default:return d({code:"S0205",stack:(new Error).stack,position:i.position,token:h})}return(a=Object.create(l)).value=h,a.type=c,a.position=i.position,a},f=function(t){var e,r=a;for(p(null,!0),e=r.nud();t<a.lbp;)r=a,p(),e=r.led(e);return e},g=function(t){u(t,0).nud=function(){return this}},v=function(e,r,n){var i=r||t[e],a=u(e,i);return a.led=n||function(t){return this.lhs=t,this.rhs=f(i),this.type="binary",this},a},m=function(t,e,r){var n=u(t,e);return n.led=r,n},y=function(t,e){var r=u(t);return r.nud=e||function(){return this.expression=f(70),this.type="unary",this},r};g("(end)"),g("(name)"),g("(literal)"),g("(regex)"),u(":"),u(";"),u(","),u(")"),u("]"),u("}"),u(".."),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"),y("-"),v("~>"),m("(error)",10,(function(t){return this.lhs=t,this.error=a.error,this.remaining=h(),this.type="error",this})),y("*",(function(){return this.type="wildcard",this})),y("**",(function(){return this.type="descendant",this})),y("%",(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),p("?")):this.arguments.push(f(0)),","===a.id;)p(",");if(p(")",!0),"name"===t.type&&("function"===t.value||"λ"===t.value)){if(this.arguments.forEach((function(t,e){if("variable"!==t.type)return d({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 s=p();">"===s.id?r--:"<"===s.id&&r++,i+=s.value}p(">");try{this.signature=n(i)}catch(t){return t.position=e+t.offset,d(t)}}p("{"),this.body=f(0),p("}")}return this})),y("(",(function(){for(var t=[];")"!==a.id&&(t.push(f(0)),";"===a.id);)p(";");return p(")",!0),this.type="block",this.expressions=t,this})),y("[",(function(){var t=[];if("]"!==a.id)for(;;){var e=f(0);if(".."===a.id){var r={type:"binary",value:"..",position:a.position,lhs:e};p(".."),r.rhs=f(0),e=r}if(t.push(e),","!==a.id)break;p(",")}return p("]",!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,p("]"),e}return this.lhs=e,this.rhs=f(t["]"]),this.type="binary",p("]",!0),this})),v("^",t["^"],(function(t){p("(");for(var e=[];;){var r={descending:!1};if("<"===a.id?p("<"):">"===a.id&&(r.descending=!0,p(">")),r.expression=f(0),e.push(r),","!==a.id)break;p(",")}return p(")"),this.lhs=t,this.rhs=e,this.type="binary",this}));var b=function(t){var e=[];if("}"!==a.id)for(;;){var r=f(0);p(":");var n=f(0);if(e.push([r,n]),","!==a.id)break;p(",")}return p("}",!0),void 0===t?(this.lhs=e,this.type="unary"):(this.lhs=t,this.rhs=e,this.type="binary"),this};y("{",b),v("{",t["{"],b),m(":=",t[":="],(function(e){return"variable"!==e.type?d({code:"S0212",stack:(new Error).stack,position:e.position,token:e.value}):(this.lhs=e,this.rhs=f(t[":="]-1),this.type="binary",this)})),v("@",t["@"],(function(e){return this.lhs=e,this.rhs=f(t["@"]),"variable"!==this.rhs.type?d({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=f(t["#"]),"variable"!==this.rhs.type?d({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=f(0),":"===a.id&&(p(":"),this.else=f(0)),this})),y("|",(function(){return this.type="transform",this.pattern=f(0),p("|"),this.update=f(0),","===a.id&&(p(","),this.delete=f(0)),p("|"),this}));var w=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},x=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},S=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)}},E=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 s=t.steps[e--];e>=0&&s.focus&&t.steps[e].focus;)s=t.steps[e--];a=k(s,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 s=r.steps[0];"unary"===s.type&&"["===s.value&&(s.consarray=!0);var o=r.steps[r.steps.length-1];"unary"===o.type&&"["===o.value&&(o.consarray=!0),E(r);break;case"[":var h=r=t(e.lhs),c="predicate";if("path"===r.type&&(h=r.steps[r.steps.length-1],c="stages"),void 0!==h.group)throw{code:"S0209",stack:(new Error).stack,position:e.position};void 0===h[c]&&(h[c]=[]);var u=t(e.rhs);void 0!==u.seekingParent&&(u.seekingParent.forEach((function(t){1===t.level?k(h,t):t.level--})),S(h,u)),h[c].push({type:"filter",expr:u,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 d={type:"sort",position:e.position};d.terms=e.rhs.map((function(e){var r=t(e.expression);return S(d,r),{descending:e.descending,expression:r}})),r.steps.push(d),E(r);break;case":=":(r={type:"bind",value:e.value,position:e.position}).lhs=t(e.lhs),r.rhs=t(e.rhs),S(r,r.rhs);break;case"@":if(r=t(e.lhs),h=r,"path"===r.type&&(h=r.steps[r.steps.length-1]),void 0!==h.stages||void 0!==h.predicate)throw{code:"S0215",stack:(new Error).stack,position:e.position};if("sort"===h.type)throw{code:"S0216",stack:(new Error).stack,position:e.position};e.keepArray&&(h.keepArray=!0),h.focus=e.rhs.value,h.tuple=!0;break;case"#":r=t(e.lhs),h=r,"path"===r.type?h=r.steps[r.steps.length-1]:(r={type:"path",steps:[r]},void 0!==h.predicate&&(h.stages=h.predicate,delete h.predicate)),void 0===h.stages?h.index=e.rhs.value:h.stages.push({type:"index",value:e.rhs.value,position:e.position}),h.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),S(r,r.lhs),S(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 S(r,n),n})):"{"===e.value?r.lhs=e.lhs.map((function(e){var n=t(e[0]);S(r,n);var i=t(e[1]);return S(r,i),[n,i]})):(r.expression=t(e.expression),"-"===e.value&&"number"===r.expression.type?(r=r.expression).value=-r.value:S(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 S(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 p=t(e.body);r.body=w(p);break;case"condition":(r={type:e.type,position:e.position}).condition=t(e.condition),S(r,r.condition),r.then=t(e.then),S(r,r.then),void 0!==e.else&&(r.else=t(e.else),S(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 S(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:"!"+x++,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 f="S0206";"(end)"===e.id&&(f="S0207");var g={code:f,position:e.position,token:e.value};if(i)return l.push(g),{type:"error",error:g};throw g.stack=(new Error).stack,g}return e.keepArray&&(r.keepArray=!0),r};s=r(e),p();var T=f(0);if("(end)"!==a.id){var C={code:"S0201",position:a.position,token:a.value};d(C)}if("parent"===(T=M(T)).type||void 0!==T.seekingParent)throw{code:"S0217",token:T.type,position:T.position};return l.length>0&&(T.errors=l),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=[],s={},o=s;r<e.length;){var l=e.charAt(r);if(":"===l)break;var h=function(){a.push(s),o=s,s={}},c=function(t,e,r,n){for(var i=1,a=e;a<t.length;)if(a++,(l=t.charAt(a))===n){if(0==--i)break}else l===r&&i++;return a};switch(l){case"s":case"n":case"b":case"l":case"o":s.regex="["+l+"m]",s.type=l,h();break;case"a":s.regex="[asnblfom]",s.type=l,s.array=!0,h();break;case"f":s.regex="f",s.type=l,h();break;case"j":s.regex="[asnblom]",s.type=l,h();break;case"x":s.regex="[asnblfom]",s.type=l,h();break;case"-":o.context=!0,o.contextRegex=new RegExp(o.regex),o.regex+="?";break;case"?":case"+":o.regex+=l;break;case"(":var u=c(e,r,"(",")"),d=e.substring(r+1,u);if(-1!==d.indexOf("<"))throw{code:"S0402",stack:(new Error).stack,value:d,offset:r};s.regex="["+d+"m]",s.type="("+d+")",r=u,h();break;case"<":if("a"!==o.type&&"f"!==o.type)throw{code:"S0401",stack:(new Error).stack,value:o.type,offset:r};var p=c(e,r,"<",">");o.subtype=e.substring(r+1,p),r=p}r++}var f="^"+a.map((function(t){return"("+t.regex+")"})).join("")+"$",g=new RegExp(f),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},m=function(t,e){for(var r="^",n=0,i=0;i<a.length;i++){r+=a[i].regex;var s=e.match(r);if(null===s)throw{code:"T0410",stack:(new Error).stack,value:t[n],index:n+1};n=s[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 s=[],o=0;return a.forEach((function(n,a){var l=e[o],h=i[a+1];if(""===h)if(n.context&&n.contextRegex){var c=v(r);if(!n.contextRegex.test(c))throw{code:"T0411",stack:(new Error).stack,value:r,index:o+1};s.push(r)}else s.push(l),o++;else h.split("").forEach((function(r){if("a"===n.type){if("m"===r)l=void 0;else{l=e[o];var i=!0;if(void 0!==n.subtype)if("a"!==r&&h!==n.subtype)i=!1;else if("a"===r&&l.length>0){var a=v(l[0]);i=a===n.subtype.charAt(0)&&0===l.filter((function(t){return v(t)!==a})).length}if(!i)throw{code:"T0412",stack:(new Error).stack,value:l,index:o+1,type:t[n.subtype]};"a"!==r&&(l=[l])}s.push(l),o++}else s.push(l),o++}))})),s}m(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 s,o=!0,l=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return o=t.done,t},e:function(t){l=!0,s=t},f:function(){try{o||null==r.return||r.return()}finally{if(l)throw s}}}}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 s(t){return s="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},s(t)}var o=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 o(t){return t&&(!0===t._jsonata_function||!0===t._jsonata_lambda)||"function"==typeof t}function l(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 h(t){return t&&!0===t._jsonata_lambda}var c=("function"==typeof Symbol?Symbol:{}).iterator||"@@iterator";function u(t){return"object"===s(t)&&null!==t&&c in t&&"next"in t&&"function"==typeof t.next}function d(t,e){if(t===e)return!0;if("object"===s(t)&&"object"===s(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(!d(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(!d(t[a],e[a]))return!1}return!0}return!1}function p(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:o,isLambda:h,isIterable:u,getFunctionArity:l,isDeepEqual:d,stringToArray:p}}();e.exports=o},{}]},{},[3])(3)}(ttt);var ett=ttt.exports;const rtt=function(t){return t};function ntt(t){if(!t)return rtt;try{var e=ett(t);return function(t){return e.evaluate(t)}}catch(t){return console.error(t),rtt}}function itt(t){var e=g9(t);return null==e?"":String(e)}function att(t){return Number(g9(t))}function stt(t){return t}function ott(t){return itt(t)}function ltt(t){return att(t)}function htt(t){if(this.param)return t=itt(t),this.param.hasOwnProperty(t)?this.param[t]:this.param.default}function ctt(t){var{param:e}=this;if(e){for(let r in e){let[n,i]=r.split("~"),a=!!n,s=!!i;if(n=parseFloat(n),i=parseFloat(i),t=att(t),a&&!s&&t>=n)return e[r];if(!a&&s&&t<n)return e[r];if(t>=n&&t<i)return e[r]}return e.default}}function utt(t){return att(t)*Math.PI/180}function dtt(){}function ptt(t,e,r,n,i){switch(r){case"value":return"text"===i||"string"===i?ott.bind(t):"number"===i?ltt.bind(t):stt.bind(e);case"map":return htt.bind(t);case"range":return ctt.bind(t);case"radian":return utt.bind(t);case"eval":return function(t){try{return new Function("value","targets",t)}catch(t){return M9(t),dtt}}(n).bind(e);default:return stt.bind(e)}}class ftt{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=ptt(this,this.owner,n,i,function(t){switch(t){case"ref":case"fillStyle":case"strokeStyle":return"string";default:return}}(r)),this.accessor=ntt(a);const s=e.match(/\[(.*?)\]/);if(s){var[o,l]=s[1].split(":");this.propAccessor=ntt(o),this.partAccessor=ntt(l)}}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 gtt(t,e,r,n){n?t.forEach((t=>t[e]={...t[e],...r})):t.forEach((t=>t[e]=r))}function vtt(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:s,partAccessor:o,ndnsp:l=!1,partial:h=!1}=t;r&&"(self)"!=r?(r.startsWith("#")&&(r=r.substring(1)),e=this.root.findById(r)?.data||{}):e=this.data;var c=a(e);if("(root)"==(n=n.trim())||"(key)"==n){if(null==c)return;let e=Object.keys(c||{}).map((t=>this.root.findOrCreate(t))).filter(Boolean).flat();e.length>0&&e.forEach((e=>{let r=t.evaluator(c[e.get("id")],[e]);!i||"(action)"===i||l&&!r&&0!==r&&!1!==r||(e[i]=h?{...e[i],...r}:r)}))}else if(n.startsWith("[")){if(null==c)return;if(c instanceof Array)c.forEach((e=>{let r=s(e);if(r){let n=this.root.findOrCreate(r);if(n){let r=t.evaluator(o(e),n);!i||"(action)"===i||l&&!r&&0!==r&&!1!==r||gtt(n,i,r,h)}}}));else{if(!(c instanceof Object))throw String("mapping data should be an object to target property-id.("+c+")");{let e=s(c);if(e){let r=this.root.findOrCreate(e);if(r){let e=t.evaluator(o(c),r);!i||"(action)"===i||l&&!e&&0!==e&&!1!==e||gtt(r,i,e,h)}}}}}else{let e=this.root.findAll(n,this);if(e.length>0){let r=t.evaluator(c,e);!i||"(action)"===i||l&&!r&&0!==r&&!1!==r||gtt(e,i,r,h)}}}catch(e){M9(e,this,t)}}))}var mtt;function ytt(t,e,r,n,i){var{alpha:a=1}=n,s=i.fillStyle;if(t.globalAlpha*=a,s)if("string"==typeof s)t.fillStyle=s,t.fill();else if("object"==typeof s)if("gradient"==s.type){t.translate(r.x,r.y);let n,{width:i,height:a}=e;if("linear"==s.gradientType){let e=3.141592653589793,r=s.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 s=Math.sqrt(Math.pow((i-4)/2,2)+Math.pow((a-4)/2,2));s-=s-(i+a)/3,n=t.createLinearGradient(s*Math.cos(r+e),s*Math.sin(r+e),s*Math.cos(r),s*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"==s.gradientType){let e=.95*Math.sqrt(Math.pow((i-4)/2,2)+Math.pow((a-4)/2,2));switch(s.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)}}s.colorStops.forEach((t=>{if(t.position>=0&&t.position<=1)try{n.addColorStop(t.position,t.color)}catch(e){T9("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"==s.type&&s.image)if(s.guideOnly&&1!=i.app.mode)s.color&&(t.fillStyle=s.color,t.fill());else{i.prepareFillIf(!i._pattern_image_origin);var o=i._pattern_image;if(!o)return;let r=0,n=0,a=0,l=0,h=e.left,c=e.top;if(!s.fitPattern){r=s.offsetX,n=s.offsetY;const t=s.width?s.width:o.width,i=s.height?s.height:o.height;switch(s.align){case"center":a=e.width/2-t/2,l=e.height/2-i/2;break;case"left-top":a=0,l=0;break;case"left-bottom":a=0,l=e.height-i;break;case"right-top":a=e.width-t,l=0;break;case"right-bottom":a=e.width-t,l=e.height-i;break;case"left":a=0,l=e.height/2-i/2;break;case"right":a=e.width-t,l=e.height/2-i/2;break;case"top":a=e.width/2-t/2,l=0;break;case"bottom":a=e.width/2-t/2,l=e.height-i}h+=r+a,c+=n+l}t.translate(h,c),s.color&&(t.fillStyle=s.color,t.fill()),s.fitPattern?Math.abs((o.width-e.width)*(o.height-e.height))>1?(delete i._pattern_image,delete i._pattern_image_origin):t.fillStyle=t.createPattern(o,"no-repeat"):t.fillStyle=t.createPattern(o,s.noRepeat?"no-repeat":"repeat"),t.fill(),t.translate(-h,-c)}}function btt(t,e,r){var{strokeStyle:n,lineDash:i,lineWidth:a,lineCap:s,lineJoin:o,alpha:l}=e;if(n&&0!=a){if(s&&(t.lineCap=s),i){var h="round"==s;switch(i){case"solid":i=[0,0];break;case"round-dot":i=h?[0,2*a]:[a,a];break;case"square-dot":i=h?[a,2*a]:[2*a,a];break;case"dash":i=h?[3*a,2.5*a]:[4*a,1.5*a];break;case"dash-dot":i=h?[3*a,3*a,0,3*a]:[4*a,2*a,a,2*a];break;case"long-dash":i=h?[5*a,4*a]:[6*a,3*a];break;case"long-dash-dot":i=h?[5*a,3*a,0,3*a]:[6*a,2*a,a,2*a];break;case"long-dash-dot-dot":i=h?[5*a,2*a,0,2*a,0,2*a]:[6*a,a,a,a,a,a]}t.setLineDash(i)}t.globalAlpha*=l,t.strokeStyle=n,t.lineWidth=a,t.lineJoin=o,t.stroke()}}function wtt(t,e,r,n,i,a=0,s=!1,o=!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(),s&&t.fill(),o&&t.stroke()}function xtt(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 Att(t,e,r,n=0){if(e.text.length<2)return e;let i=2;for(;i<e.text.length;i++){const a=e.text.substring(0,i);if(!(t.measureText(a).width+(i-1)*n<r))break}return{...e,text:e.text.substring(0,i-1)}}function _tt(t,e,r,n,i,a=0){const s=String(e).split("\n");return n?[].concat.apply([],s.map((e=>function(t,e,r,n=0){const i=[];let a=[],s=0;return e.forEach((e=>{let o=e.text;for(;o.length>0;){const l=r-s,h=t.measureText(o).width+(o.length-1)*n;if(h<=l)a.push({...e,text:o}),s+=h,o="";else{const r=Att(t,{...e,text:o},l,n);a.push(r),i.push(a),a=[],s=0,o=o.substring(r.text.length)}}})),a.length>0&&i.push(a),i}(t,i?xtt(e):[{text:e,bold:!1,italic:!1}],r,a)))):s.map((t=>i?xtt(t):[{text:t,bold:!1,italic:!1}]))}function ktt(t,e,r,n,i,a,s=0){if(!n)return[];t.save(),t.font=r;var o=_tt(t,n,e,!!i,a,s);return t.restore(),o}function Stt(t){var{fontFamily:e=H9.FONT_FAMILY,bold:r=H9.BOLD,italic:n=H9.ITALIC,fontSize:i=H9.FONT_SIZE}=t,a=[];return r&&a.push("bold"),n&&a.push("italic"),a.push(i+"px"),a.push(e),a.join(" ")}function Ett(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 Mtt(t,e,r,n){var{alpha:i,fontColor:a=H9.FONT_COLOR,textAlign:s=H9.TEXT_ALIGN,textBaseline:o=H9.TEXT_BASELINE,textBackgroundStyle:l,fontSize:h,lineHeight:c,textWrap:u,textOverflow:d,letterSpacing:p=0}=n;i=void 0!==i?i:1,h||=H9.FONT_SIZE,c||=1.2*h,t.save(),t.beginPath();var{left:f,top:g,width:v,height:m}=e;if(t.font=Stt(n),!u&&d){const e=function(t,e,r,n){const i="ellipsis"===t?"…":"",a=e.measureText(i).width;let s=[],o=0;for(let i of r){let r=[];for(let l of i){let i=e.measureText(l.text).width;if(!(o+i<=n-("ellipsis"===t?a:0))){let i=Ttt(e,l,n-o-("ellipsis"===t?a:0),t);return r.push(i),s.push(r),s}r.push(l),o+=i}s.push(r),o=0}return s}(d,t,r,v);r=e}var y,b=r.length*c;switch(o){case"top":y=g,t.textBaseline="top";break;case"bottom":y=g+m-b+c,t.textBaseline="bottom";break;default:y=g+m/2-b/2+c/2,t.textBaseline="middle"}t.globalAlpha*=i,t.fillStyle=a,r.forEach(((e,i)=>{let o=y+i*c,u=function(t,e,r,n=0){return e.reduce(((e,i)=>(t.font=Ett(r,i),e+t.measureText(i.text).width+n*(i.text.length-1))),0)}(t,e,n,p),d=f;switch(s){case"left":case"justify":d=f;break;case"right":d=f+v-u;break;case"center":d=f+(v-u)/2}if(l&&(t.fillStyle=l,wtt(t,d-4,o-h/2-4,u+8,h+8,4,!0,!1),t.fillStyle=a),"justify"===s&&i<r.length-1&&e.length>1){let r=v-u,i=e.length-1,a=r/i;e.forEach(((e,r)=>{t.font=Ett(n,e),t.fillText(e.text,d,o),d+=t.measureText(e.text).width+(r<i?a:0)}))}else e.forEach((e=>{t.font=Ett(n,e),[...e.text].forEach((e=>{t.fillText(e,d,o),d+=t.measureText(e).width+p}))}))})),t.restore()}function Ttt(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 Ctt(t,e,r={x:0,y:0},n=0,i={x:1,y:1}){const a=Math.cos(-n),s=Math.sin(-n);return{x:((t-=r.x)*a-(e-=r.y)*s+r.x)/i.x,y:(t*s+e*a+r.y)/i.y}}function Ptt(t,e,r={x:0,y:0},n=0,i={x:1,y:1}){const a=Math.cos(n),s=Math.sin(n);return{x:((t-=r.x)*a-(e-=r.y)*s+r.x)*i.x,y:(t*s+e*a+r.y)*i.y}}function Itt(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:s}=r;if(i&&(n.backgroundRepeat="no-repeat"),s&&(n.backgroundColor=s),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"}mtt="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 Rtt={x:1,y:1},Ott={x:0,y:0},Ltt={boxSizing:"border-box",margin:"0px",position:"absolute",outline:"none"};function Dtt(t){var{id:e,scale:r=Rtt,translate:n=Ott,bold:i,italic:a,fontFamily:s="",textAlign:o,textBaseline:l,textOverflow:h,paddingTop:c,paddingBottom:u,paddingLeft:d,paddingRight:p,fontSize:f=H9.FONT_SIZE,lineWidth:g=0,lineHeight:v,lineDash:m}=t.state;u||=0,c||=0,d||=0,p||=0;var y=t.state.class;t.text;var{strokeStyle:b,fillStyle:w,rotation:x=0,fontColor:A,hidden:_}=t,{left:k,top:S,width:E,height:M}=t.bounds,T=t.element;if(T.hidden=_,e&&(T.id=e),y&&(T.className=y),Object.assign(T.style,Ltt,{fontFamily:s,fontSize:f+"px",width:E+"px",height:M+"px",paddingTop:c+"px",paddingRight:p+"px",paddingBottom:u+"px",paddingLeft:d+"px",border:g+"px",borderColor:b,borderStyle:g>0?m||H9.LINE_DASH:"",color:A,fontWeight:i?"bold":"",fontStyle:a?"italic":"",textAlign:"end"==o?"right":"start"==o?"left":o,verticalAlign:l,lineHeight:void 0===v?"":v+"px",whiteSpace:h?"nowrap":"",overflow:h?"hidden":"",textOverflow:h||""},t.isIn3DSpace()?{}:{left:k+"px",top:S+"px"}),Itt(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),!t.isIn3DSpace()){var C=t.delta(),P=(r&&r.x||1)*C.sx,I=(r&&r.y||1)*C.sy,R=(x||0)+C.theta,O=C.tx||0,L=C.ty||0;T.style.transform=`rotate(${R}rad) translate(${O}px, ${L}px) scale(${P}, ${I}) perspective(1px)`}}var Ftt,Ntt=[];function jtt(){Ftt=null;var t=performance.now(),e=(Ntt=Ntt.filter((t=>Btt(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=Ntt.indexOf(t);-1!=e?(Ntt.splice(e,1),t.removeSelf(!0)):M9("Should not be here. Maybe reentrance problem.")})),e.next>0&&(Ftt=setTimeout(ztt,Math.max(e.next,500)))}function Btt(t){return!t.disposed&&t.retention>0&&!t.isTemplate()&&t.app&&t.app.isViewMode}var ztt=o9((function(){requestAnimationFrame(jtt)}),500);var Wtt=new class{add(t){Btt(t)&&-1==Ntt.indexOf(t)&&(Ntt.push(t),t.touch()),this.touch()}remove(t){var e=Ntt.indexOf(t);e>0&&Ntt.splice(e,1),this.touch()}touch(){null!==Ftt&&(clearTimeout(Ftt),Ftt=null),ztt()}get length(){return Ntt.length}};const Utt=function(t){return t};function Htt(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)}:Utt}}function Gtt(t,e,r){if(t){var n=r||g9,i=String(t),a=(i.match(/#{[^}]*}/gi)||[]).map((t=>Htt(t))),s=(i.match(/\${[^}]*}/gi)||[]).map((t=>Htt(t)));if(0!=a.length||0!=s.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)})),s.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 Ytt=210*Math.PI/180,Vtt=150*Math.PI/180;var qtt={"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 s=e.createLinearGradient(i.x,i.y,a.x,a.y);["#FFA50033","#FFA500"].forEach(((t,e)=>s.addColorStop(e,t))),e.strokeStyle=s,e.fillStyle=s,function(t,e,r,n=10){var i=r.x-e.x,a=r.y-e.y,s=Math.atan2(a,i),o=r.x+n*Math.cos(s+Ytt),l=r.y+n*Math.sin(s+Ytt),h=r.x+n*Math.cos(s+Vtt),c=r.y+n*Math.sin(s+Vtt);t.beginPath(),t.moveTo(e.x,e.y),t.lineTo(r.x,r.y),t.moveTo(r.x,r.y),t.lineTo(o,l),t.moveTo(r.x,r.y),t.lineTo(h,c),t.stroke()}(e,i,a),n=!0})))})),n}},"bouncing-arrow":function(t,e,r){let{left:n,top:i,width:a}=t.bounds,s=t.state.id,{x:o,y:l}=t.transcoordS2C(n+a/2,i,t.rootModel);const h=2*function(t){const e=100*(1-t)%10;return e<5?e:10-e}(r||0);if(o=Math.max(o,20),l=Math.max(l,20),e.beginPath(),e.moveTo(o-10,l-16+h),e.lineTo(o+10,l-16+h),e.lineTo(o+10,l-8+h),e.lineTo(o+16,l-8+h),e.lineTo(o,l+h),e.lineTo(o-16,l-8+h),e.lineTo(o-10,l-8+h),e.lineTo(o-10,l-16+h),e.lineTo(o-10,l-16+h),e.fillStyle="#FF0000",e.fill(),s){e.beginPath(),e.font="12px Arial";let t=e.measureText(s);e.fillStyle="#FF0000",e.roundRect(o-t.actualBoundingBoxLeft-3+20,l-t.actualBoundingBoxAscent-3-6+h,t.actualBoundingBoxLeft+t.actualBoundingBoxRight+6,t.actualBoundingBoxAscent+t.actualBoundingBoxDescent+6,3),e.fill(),e.fillStyle="white",e.fillText(s,o+20,l-6+h)}return!0},decotag:function(t,e,r){const n=t.decotag;if(n){let{left:r,top:i}=t.bounds,{x:a,y:s}=t.transcoordS2C(r,i,t.rootModel);a=Math.max(a+3,5),s=Math.max(s-8,15),e.font="12px Arial";let o=e.measureText(n);return e.beginPath(),e.fillStyle="#FF0000",e.roundRect(a-o.actualBoundingBoxLeft-3,s-o.actualBoundingBoxAscent-3,o.actualBoundingBoxLeft+o.actualBoundingBoxRight+6,o.actualBoundingBoxAscent+o.actualBoundingBoxDescent+6,3),e.fill(),e.beginPath(),e.fillStyle="white",e.fillText(n,a,s),!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:s,y:o}=a||{};if(!i)return;var{x:s,y:o}=t.transcoordS2C(s,o,t.rootModel);s+=4,o+=4,e.font="12px Arial";let l=e.measureText(i);e.fillStyle="#FF0000",wtt(e,s,o,l.width+6,16,3,!0,!1),e.fillStyle="white",e.fillText(i,s+3,o+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:s}=i||{};if(!a||!s)return;var{x:o,y:l}=s||{},{x:o,y:l}=r.transcoordS2C(o,l,r.rootModel);o+=8,l+=20,e.font="12px Arial";let h=e.measureText(a);e.fillStyle="#FF0000",wtt(e,o-h.actualBoundingBoxLeft-4,l-h.actualBoundingBoxAscent-4,h.actualBoundingBoxLeft+h.actualBoundingBoxRight+8,h.actualBoundingBoxAscent+h.actualBoundingBoxDescent+8,4,!0,!1),e.fillStyle="white",e.fillText(a,o,l),n=!0})),n}};function Xtt(t){return qtt[t]}var $tt={};const Ktt={mutable:!1,resizable:!0,rotatable:!0,properties:[],"value-property":"text"},Qtt=[],Jtt={theta:0,tx:0,ty:0,sx:1,sy:1,fade:0};var Ztt=0,tet={};const eet=new FinalizationRegistry((t=>{!function(t){Ztt--;var e=tet[t];e||(e=tet[t]={up:0,down:0}),e.down++}(t)}));class ret{static get nature(){return Ktt}static register(t,e){if(!e)return $tt[t];$tt[t]=e}static get residents(){return tet}static get residentsCount(){return Ztt}static registerDecorator(t,e){!function(t,e){qtt[t]=e}(t,e)}constructor(t,e){this._app=e,this._model=t||{},this._state={},this._delta=X7(Jtt),e&&this.animation?.config&&(1==this.animation.config.autoplay||(this.animation.config.autoplay??1))&&(this.animation.started=!0),this.clearCache(),Wtt.add(this),function(t){Ztt++;var e=tet[t];e||(e=tet[t]={up:0,down:0}),e.up++}(t.type),eet.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)}resetAnimation(){this._animation&&(this._animation.dispose(),this._animation=null,this._delta=X7(Jtt))}dispose(){this.resetAnimation(),this.disposeMappings(),this.parent&&this.parent.removeComponent(this),delete this._text_substitutor,delete this._value_substitutor,this._disposed=!0,this.retention&&Wtt.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}isIn3DSpace(){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=X7(this._model);return this.volatile.forEach((e=>{delete t[e]})),t}get volatile(){return Qtt}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=X7(t),this);return Object.getOwnPropertyNames(t).forEach((function(e){let s=a._model[e],o=t[e];p8(s,o)||(n[e]=s,r[e]=o,a._model[e]=o,delete a._state[e],i=!0)})),i&&(this.clearCache(),r.hasOwnProperty("text")&&delete this._text_substitutor,r.hasOwnProperty("retention")&&Wtt.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=X7(t),this),s=this.getState("sensitive");return Object.getOwnPropertyNames(t).forEach((function(e){let o=a.getState(e),l=t[e];!s&&p8(o,l)||(n[e]=o,r[e]=l,a._state[e]=l,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 s=i[a];s.x<t?t=s.x:s.x>e&&(e=s.x),s.y<r?r=s.y:s.y>n&&(n=s.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 M9("이 컴포넌트에 get path 가 구현되어있지 않음.",this),[]}set path(t){M9("이 컴포넌트에 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,s=e.y-t.y;i.push(Math.sqrt(a*a+s*s)),n++}var a=i.reduce((function(t,e){return t+e}),0);n=0;var s=0;do{s+=i[n++]}while(s/a<e);e=(e-(s-=i[--n])/a)*(a/i[n]);var o=r[n%r.length],l=r[(n+1)%r.length],h=o.x+Math.round((l.x-o.x)*e),c=o.y+Math.round((l.y-o.y)*e);return t.transcoordS2T(h,c)}M9("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(g9(t)))}get rotation(){return this.getState("rotation")}set rotation(t){this.setState("rotation",Number(g9(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,s=t.top-e.top;return 0!=a&&0!=s?(s=-i,a=-n):0!=a?a=-n:0!=s&&(s=-i),{left:e.left+a,top:e.top+s,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?J9(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=>{M9(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.prerender(t),this.render(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,s=(r&&r.x||1)*this._delta.sx,o=(r&&r.y||1)*this._delta.sy,l=(n||0)+this._delta.theta,{tx:h=0,ty:c=0}=this._delta,u=(a||1)-this._delta.fade;(h||c)&&t.translate(h,c),(1!=s||1!=o||l)&&(t.translate(e.x,e.y),1==s&&1==o||t.scale(s,o),l&&t.rotate(l),t.translate(-e.x,-e.y)),u&&(t.globalAlpha=u),i&&Y9(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&&Mtt(t,this.textBounds,this.textLines(t),this.state)}drawStroke(t,e){btt(t,e?{...this.state,...e}:this.state)}drawFill(t,e){this.fillStyle&&"transparent"!=this.fillStyle&&(ytt(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=w7(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=X7(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=b7(this,t.oncreate))}return this._animation}}effect(t,e){return function(t,e,r){var n=V9[r.type];n&&n(t,e,r)}(this,t,e)}get started(){return!!this.animation?.started}set started(t){this.animation&&(this.animation.started=t)}invalidate(){this.parent&&this.parent.invalidate()}get font(){return Stt(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=Gtt(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,s,o,l,h,c,u=t.length,d=t.search(/[0-9\-\+#]/),p=d>0?t.substring(0,d):"",f=t.split("").reverse().join(""),g=f.search(/[0-9\-\+#]/),v=u-g,m=t.substring(v,v+1),y=v+("."===m||","===m?1:0),b=g>0?t.substring(y,u):"";if(r=(e="-"===(t=t.substring(d,y)).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))+"",s=t[1]&&t[1].lastIndexOf("0"),(!(l=e.split("."))[1]||l[1]&&l[1].length<=s)&&(e=(+e).toFixed(s+1)),h=t[0].split(i),t[0]=h.join(""),(a=t[0]&&t[0].indexOf("0"))>-1)for(;l[0].length<t[0].length-a;)l[0]="0"+l[0];else 0==+l[0]&&(l[0]="");if((e=e.split("."))[0]=l[0],o=h[1]&&h[h.length-1].length){for(f="",v=(c=e[0]).length%o,u=c.length,y=0;y<u;y++)f+=c.charAt(y),!((y-v+1)%o)&&y<u-o&&(f+=i);e[0]=f}return e[1]=t[1]&&e[1]?"."+e[1]:"","0"!==(n=e.join(""))&&""!==n||(r=!1),p+("+"==t[0].substring(0,1)?r?"-":"+":r?"-":"")+n+b}(t,this.textSubstitutor()):this.textSubstitutor()}set text(t){delete this._text_substitutor;var e=g9(t);this.setState("text",null==e?"":String(e))}textLines(t){const{textWrap:e,supportMarkdown:r}=this.state;return ktt(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:s,height:o}=this.bounds;return{left:i+e,top:a+t,width:Math.max(s-e-r,0),height:Math.max(o-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)}}ret.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}},ret.transcoordR=Ctt,ret.transcoordRR=Ptt,ret.createCanvas=mtt,ret.memoize=P9,ret.mixin=E9,ret.drawText=Mtt,ret.font=Stt,ret.textLines=ktt,ret.drawStroke=btt,ret.drawFill=ytt,ret.reposition=Dtt,ret.RetentionManager=Wtt,ret.template=function(t,e,r){var n=o7.imports._.templateSettings||o7;r&&T8(t,e,r)&&(e=void 0),t=i7(t),e=L8({},e,n,q8);var i,a,s=L8({},e.imports,n.imports,q8),o=U6(s),l=function(t,e){return G8(e,(function(e){return t[e]}))}(s,o),h=0,c=e.interpolate||p7,u="__p += '",d=RegExp((e.escape||p7).source+"|"+c.source+"|"+(c===K8?d7:p7).source+"|"+(e.evaluate||p7).source+"|$","g"),p=g7.call(e,"sourceURL")?"//# sourceURL="+(e.sourceURL+"").replace(/\s/g," ")+"\n":"";t.replace(d,(function(e,r,n,s,o,l){return n||(n=s),u+=t.slice(h,l).replace(f7,$8),r&&(i=!0,u+="' +\n__e("+r+") +\n'"),o&&(a=!0,u+="';\n"+o+";\n__p += '"),n&&(u+="' +\n((__t = ("+n+")) == null ? '' : __t) +\n'"),h=l+e.length,e})),u+="';\n";var f=g7.call(e,"variable")&&e.variable;if(f){if(u7.test(f))throw new Error("Invalid `variable` option passed into `_.template`")}else u="with (obj) {\n"+u+"\n}\n";u=(a?u.replace(l7,""):u).replace(h7,"$1").replace(c7,"$1;"),u="function("+(f||"obj")+") {\n"+(f?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(i?", __e = _.escape":"")+(a?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+u+"return __p\n}";var g=H8((function(){return Function(o,p+"return "+u).apply(void 0,l)}));if(g.source=u,W8(g))throw g;return g},ret.buildSubstitutor=Gtt,Object.assign(ret.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=mtt(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=>{M9(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 s=t.call(e,r);s&&(r=s)}var{left:o,top:l,width:h,height:c}=r,u=[{x:o,y:l},{x:o+h,y:l+c}],d=(u=u.map((t=>Ptt(t.x,t.y,n,i,a))))[0],p=u[1];n={x:(d.x+p.x)/2,y:(d.y+p.y)/2},d=(u=u.map((t=>Ctt(t.x,t.y,n,i,a))))[0],p=u[1],this.bounds={left:d.x,top:d.y,width:p.x-d.x,height:p.y-d.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 s,o,l,h,c={x:0,y:0};s=o=(n=a.map((t=>this.transcoordP2S(t.x,t.y,c))))[0].x,l=h=n[0].y;for(let t=1;t<n.length;t++){let e=n[t];e.x<s?s=e.x:e.x>o&&(o=e.x),e.y<l?l=e.y:e.y>h&&(h=e.y)}i={x:(s+o)/2,y:(l+h)/2},i=this.transcoordS2P(i.x,i.y,c),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=>Htt(t)))[0];if(r)return r.accessor(this.getState(r.target));var n=(e.match(/\${[^}]*}/)||[]).map((t=>Htt(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||g9,i=(r.match(/#{(\S*)}/gi)||[]).map((t=>Htt(t))),a=(r.match(/\${[^}]*}/gi)||[]).map((t=>Htt(t)));if(0==i.length&&0==a.length)return r;var s=r;return i.forEach((t=>{let e=n(t.accessor(this.getState(t.target)));s=s.replace(t.match,void 0===e?"":e)})),a.forEach((t=>{let e=this.root.findById(t.target),r=n(t.accessor(e&&e.data));s=s.replace(t.match,void 0===r?"":r)})),s}},onchangeMappings:function(t,e){this.disposeMappings(),vtt.call(this)},onchangeData:function(t,e){this.state.persistent&&this.app?.isViewMode&&this.app?.dataStorage.save(this,t.data),vtt.call(this,[!0])},buildMappings:function(){if(this._model.mappings)return!this._model.mappings instanceof Array?(M9("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 ftt(t,this))));this._mappings=[]},executeMappings:vtt,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};let{rotation:n=0,scale:i={x:1,y:1}}=this.state;if(this.isLayer()){const r=this.state.translate;let a=Ptt(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:s=0,ty:o=0,sx:l=1,sy:h=1}=this._delta||{};r={x:r.x+s,y:r.y+o},i={x:i.x*l,y:i.y*h};const c=Ptt(t+s,e+o,r,n+a,i);return{x:c.x-(r.x*i.x-r.x),y:c.y-(r.y*i.y-r.y)}},transcoordP2S:function(t,e,r){if(!this.parent)return{x:t,y:e};const{rotation:n=0,scale:i={x:1,y:1}}=this.state;if(this.isLayer()){const r=this.state.translate;let a=Ctt(t,e,r,n,i);return r&&(a.x-=r.x/i.x,a.y-=r.y/i.y),a}const a=Ctt(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;const n=[];for(let t=this.parent;t&&t!==r;t=t.parent)n.push(t);let i=this.transcoordS2P(t,e);return n.forEach((t=>{const{scale:e}=t.model,r=t.bounds;if(e){const 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;const n=[];for(let t=this.parent;t&&t!==r;t=t.parent)n.splice(0,0,t);let i={x:t,y:e};return n.forEach((t=>{const{scale:e}=t.model;i=t.transcoordP2S(i.x,i.y);const r=t.bounds;if(e){const 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){const n=this.transcoordT2P(t,e,r);return this.transcoordP2S(n.x,n.y)},transcoordS2TR:function(t,e,r){r=r||this.rootModel;const n=this.transcoordS2T(t,e,r);return Ptt(n.x,n.y,void 0,(r.get("rotation")||0)+r._delta.theta)},transcoordS2O:function(t,e,r){const 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;const{translate:n={x:0,y:0},scale:i={x:1,y:1},rotation:a=0}=r.model;let s=Ctt(t,e,n,a,i);return n&&(s.x-=n.x/i.x,s.y-=n.y/i.y),r===this?s:this.transcoordT2S(s.x,s.y,r)},transcoordS2C:function(t,e,r){if(!r)for(r=this;r&&!r.isLayer();)r=r.parent;let n;n=r!==this?this.transcoordS2T(t,e,r):{x:t,y:e};const{translate:i={x:0,y:0},rotation:a=0,scale:s={x:1,y:1}}=r.model;return n=Ptt(n.x,n.y,void 0,a+r._delta.theta,s),i&&(n.x+=i.x,n.y+=i.y),n}}),["rotatePoint","font","lineHeight","retention"].forEach((t=>ret.memoize(ret.prototype,t,!1))),["bounds","center","textBounds"].forEach((t=>ret.memoize(ret.prototype,t,!0))),ret.mixin(ret.prototype,x9.withEvent);class net extends ret{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 l=e[(n-1+e.length)%e.length],h=e[(n+e.length)%e.length],c=e[(n+1)%e.length];if(l.x===h.x&&l.y===h.y)continue;var i=0!==(o=Math.sqrt((l.x-h.x)*(l.x-h.x)+(l.y-h.y)*(l.y-h.y)))?Math.atan2(l.x-h.x,l.y-h.y):0,a=Math.sin(i)*Math.min(r,o/2)+h.x,s=Math.cos(i)*Math.min(r,o/2)+h.y;const u=r>0||0!==o?{x:a,y:s}:h;var o;i=0!==(o=Math.sqrt((c.x-h.x)*(c.x-h.x)+(c.y-h.y)*(c.y-h.y)))?Math.atan2(c.x-h.x,c.y-h.y):0,a=Math.sin(i)*Math.min(r,o/2)+h.x,s=Math.cos(i)*Math.min(r,o/2)+h.y;const d=r>0||0!==o?{x:a,y:s}:h;0==n?t.moveTo(u.x,u.y):t.lineTo(u.x,u.y),r>0&&t.quadraticCurveTo(h.x,h.y,d.x,d.y)}t.closePath()}}}function iet(t,e,r){return Math.max(0,Math.min(t,Math.min(r,e)/2))}var aet=t=>{var e=class extends t{contains(t,e){var{left:r,top:n,width:i,height:a,lineWidth:s=0}=this.state,o=s/2;return t<Math.max(r+i,r)+o&&t>Math.min(r+i,r)-o&&e<Math.max(n+a,n)+o&&e>Math.min(n+a,n)-o}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,s=r+i/2;return[{name:"TOP",position:{x:a,y:r}},{name:"RIGHT",position:{x:e+n,y:s}},{name:"BOTTOM",position:{x:a,y:r+i}},{name:"LEFT",position:{x:e,y:s}}]}(this)}get bounds(){const{left:t=0,top:e=0,width:r=0,height:n=0}=this.state;return{left:t,top:e,width:r,height:n}}set bounds(t){this.set({left:0,top:0,width:0,height:0,...t})}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=iet(e,i,a))>0?t.roundRect(0,0,i,a,e):t.rect(0,0,i,a),t.translate(-r,-n)}};return P9(e.prototype,"path",!1),e};const set={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 oet=20;function het(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 cet extends(aet(net)){static get image(){return cet._image||(cet._image=new Image,cet._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=="),cet._image}static toggle(t,e,r,n){if(e){var i=t.root.findById(e);i?i._findInfoWindowByComponent(t)?cet.hide(t,e):cet.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:s=""}=i.model,o=[a,s].filter((t=>String(t).trim()));if(o=o.map((t=>ret.template(function(t,e,r){return(e||r?['<div class="info-window-btns">',e?'<button class="closable">X</button>':"",r?'<button class="flipable">⇌</button>':"","</div>"]:[]).concat(['<div class="info-window-content">',t,"</div>"]).join("")}(t,!r,2==o.length)))),0!=o.length){var l='\n.flip {\n backface-visibility: hidden;\n border-radius: 7px;\n height: auto;\n font: normal 14px helvetica, arial, san serif;\n position: absolute;\n opacity: 0.9;\n transform-origin: 50% 50% 0px;\n transition: all 2s;\n min-width: 100px;\n 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}\n\n.flip:after {\n content: "";\n display: block;\n position: absolute;\n opacity: 0.9;\n width: 0;\n height: 0;\n}\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\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\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\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}\n\n.flip-side-1 {\n transform: rotateY(0deg) !important;\n}\n\n.flip-side-2 {\n transform: rotateY(180deg) !important;\n}\n\n.info-window-btns {\n position: absolute;\n top: -18px;\n right: 5px;\n overflow: hidden;\n}\n\n.info-window-content {\n padding: 10px;\n color: #efefef;\n font-size: 13px;\n line-height: 1.4;\n}\n\n.info-window-btns button {\n width: 40px;\n 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\n.info-window-btns button:hover {\n background-color: #60bb23;\n}\n'+i.get("style"),{left:h,top:c}=t.bounds,{x:u,y:d}=n?t.rootModel.transcoordC2S(n.x,n.y):t.transcoordS2T(h,c);h=u,c=d;var p=document.createElement("span");p.style.position="absolute";var f=document.createElement("style");if(f.type="text/css",f.appendChild(document.createTextNode(l)),p.appendChild(f),o[0]){var g=document.createElement("div");g.id="side-1",g.className="flip",g.style.display="inline-block",g.innerHTML=o[0](t)}if(o[1]){var v=document.createElement("div");v.id="side-2",v.className="flip",v.style.display="inline-block",v.innerHTML=o[1](t)}W9.forEach((function(t){p.addEventListener(t,(function(t){t.stopPropagation()}))})),U9.forEach((function(t){p.addEventListener(t,(function(t){t.stopPropagation()}))}));var m=t.root.model_layer.overlay;if(g&&p.appendChild(g),v&&p.appendChild(v),m.appendChild(p),i._addInfoWindow(t,p,f),g){let r=g.querySelector(".info-window-btns > .flipable");r&&r.addEventListener("click",(function(t){t.preventDefault(),v.className=het(v.className,"flip-side-1"),g.className=het(g.className,"flip-side-2")}),!1);let n=g.querySelector(".info-window-btns > .closable");n&&n.addEventListener("click",(function(r){r.preventDefault(),cet.hide(t,e)}),!1)}if(v){let r=v.querySelector(".info-window-btns > .flipable");r&&r.addEventListener("click",(function(t){t.preventDefault(),v.className=het(v.className,"flip-side-1"),g.className=het(g.className,"flip-side-2")}),!1);let n=v.querySelector(".info-window-btns > .closable");n&&n.addEventListener("click",(function(r){r.preventDefault(),cet.hide(t,e)}),!1)}var y=g.offsetWidth,b=g.offsetHeight;window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight;var w=t.rootModel.target.getBoundingClientRect(),x=[];g&&x.push(g),v&&x.push(v);var A={x:h,y:c},_=t.transcoordS2C(A.x,A.y);if(_.x+y/2+w.left<w.right&&_.x-y/2>w.left){if(b+oet<_.y)return p.style.marginLeft=A.x-y/2+"px",p.style.marginTop=A.y-b-oet+"px",void x.forEach((t=>t.className+=" arrow-bottom"));if(_=t.transcoordS2C(A.x,A.y+b+oet),w.bottom>_.y+w.top)return p.style.marginLeft=A.x-y/2+"px",p.style.marginTop=A.y+oet+"px",void x.forEach((t=>t.className+=" arrow-top"))}if((_=t.transcoordS2C(A.x,A.y)).x-(y+oet)>w.left)return p.style.marginLeft=A.x-y-oet+"px",p.style.marginTop=A.y-b/2+"px",void x.forEach((t=>t.className+=" arrow-right"));p.style.marginLeft=A.x+oet+"px",p.style.marginTop=A.y-b/2+"px",x.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,cet.image,e,r,n,i)}get hasTextProperty(){return!1}get nature(){return set}}ret.register("info-window",cet);var uet={};var det={list:function(){return{...uet}},register:function(t,e){uet[t]=e},unregister:function(t){delete uet[t]},get:function(t){if(t){var e=uet[t];return e||M9("Layout Not Found - ",t),e}}},pet={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};det.register("html-absolute",pet);const fet=["run","goto","goto-playlist","link-open","link-move","route-page","start-scenario","run-scenario","export-data","import-data"],get="auto";const vet=new WeakMap;function met(t){const e=t.root,r=vet.get(e);if(!r)return;if(e===t)return r.forEach((t=>met(t[0]))),void vet.delete(e);const n=r.findIndex((e=>e[0]===t));if(-1===n)return;const i=r[n][1];i.div.parentNode?.removeChild(i.div),i.scene.target=null,i.scene.release?.(),r.splice(n,1)}class yet{static hideAll(t){(vet.get(t)||[]).forEach((([t])=>met(t)))}static hide(t){const e=t.root,r=vet.get(e);if(!r)return;const n=r.findIndex((e=>e[0]===t));if(-1===n)return;const i=r[n][1];i.div.style.backgroundColor="transparent",function(t,e){t.style.opacity=1,t.style.transform="scale(1)";let r=+new Date;const n=()=>{const i=Math.min((new Date-r)/200,1);t.style.opacity=1-i,t.style.transform=`scale(${1-i})`,i<1?requestAnimationFrame(n):(t.style.display="none",e&&e())};n()}(i.div,(()=>{met(t)}))}static show(t,e,r={}){const{data:n,modal:i=!1,closable:a=!0,minimizable:s=!1,draggable:o=!1,output:l=!0,title:h=""}=r,c=t.app.refProvider;c?.get(e,!0).then((e=>{const c=document.createElement("div"),u=c.style;if(c.setAttribute("popup",""),i){const{width:e,height:r}=t.rootModel.bounds;Object.assign(u,{position:"fixed",zIndex:1,left:0,top:0,width:`${e}px`,height:`${r}px`,overflow:"hidden",backgroundColor:"transparent"})}else Object.assign(u,{position:"absolute",display:"inline-block",overflow:"hidden"});c.innerHTML=h?'\n<div class="popup-wrap">\n <div class="popup-title-bar">\n <div class="popup-title"></div>\n <button class="draggable-1945">drag_pan</button>\n <button class="minimizable-1945">minimize</button>\n <button class="closable-1945">close</button>\n </div>\n <div class="popup-content"></div>\n</div>\n':'\n<div class="popup-content">\n <button class="draggable-1945">drag_pan</button>\n <button class="minimizable-1945">minimize</button>\n <button class="closable-1945">close</button>\n</div>\n';const d=c.querySelector(".popup-content"),{width:p,height:f}=e.root.model;Object.assign(d.style,{width:`${p}px`,height:`${f}px`});const g=document.createElement("style");g.type="text/css",g.appendChild(document.createTextNode("\n.popup-title-bar {\n display: flex;\n align-items: center;\n top: 0;\n left: 0;\n width: 100%;\n height: 30px;\n background-color: var(--md-sys-color-primary, #f1f1f1);\n color: var(--md-sys-color-on-primary, black);\n padding: 5px;\n box-sizing: border-box;\n border-bottom: 1px solid #ccc;\n}\n\n.popup-title {\n flex: 1;\n text-align: center;\n}\n\nbutton.closable-1945, button.minimizable-1945, button.draggable-1945 {\n position: absolute;\n display: none;\n color: white; \n background-color: black; \n opacity: .3;\n width: 20px;\n height: 20px;\n top: 5px; \n z-index: 1;\n padding: 0;\n margin: 0;\n border: 0px;\n text-align: center;\n cursor: pointer;\n border-radius: 4px;\n font-family: Material Symbols Outlined;\n font-size: 12px;\n}\n\nbutton.draggable-1945 {\n right: 55px;\n cursor: move;\n}\n\nbutton.minimizable-1945 {\n right: 30px;\n}\n\nbutton.closable-1945 {\n right: 5px;\n}\n\nbutton.closable-1945:hover, button.minimizable-1945:hover, button.draggable-1945:hover {\n opacity: .6; \n}\n")),c.appendChild(g),fet.forEach((r=>{e.on(r,((...e)=>{t.trigger(r,...e)}))}));const v=c.querySelector(".popup-content"),m=c.querySelector(".draggable-1945");[...W9,...U9].forEach((t=>{v.addEventListener(t,(t=>{t.stopPropagation()}))})),[...W9,...U9].forEach((t=>{c.addEventListener(t,(t=>{t.stopPropagation()}))})),i&&a&&c.addEventListener("click",(e=>{e.target===c&&yet.hide(t)}));if(t.root.model_layer.overlay.appendChild(c),function(t,e,r){const n=t.root;if(n===t)return;met(t);let i=vet.get(n)||[];i=[...i,[t,{div:e,scene:r}]],vet.set(n,i)}(t,c,e),h){c.querySelector(".popup-title-bar .popup-title").textContent=h}if(o&&(!function(t,e,r){let n,i,a,s;e.addEventListener("mousedown",(e=>{function o(e){e.preventDefault(),e.stopPropagation();const o=e.clientX-n,l=e.clientY-i,h=r.rootModel.overlay.style.transform.match(/scale\(([^,]+),\s*([^)]+)\)/),c=h?parseFloat(h[1]):1,u=h?parseFloat(h[2]):c;t.style.left=`${a+o/c}px`,t.style.top=`${s+l/u}px`}e.preventDefault(),e.stopPropagation(),n=e.clientX,i=e.clientY,a=parseInt(t.style.left,10)||0,s=parseInt(t.style.top,10)||0,document.addEventListener("mousemove",o,!0),document.addEventListener("mouseup",(function t(e){e.preventDefault(),e.stopPropagation(),document.removeEventListener("mousemove",o,!0),document.removeEventListener("mouseup",t,!0)}),!0)}))}(i?c.querySelector(".popup-wrap"):c,c.querySelector(".popup-title-bar"),t),h?m&&(m.style.display="block"):(v.addEventListener("mouseenter",(()=>{m&&(m.style.display="block")})),v.addEventListener("mouseleave",(()=>{m&&(m.style.display="none")})))),s){const t=c.querySelector(".minimizable-1945");let e=!1;t.addEventListener("click",(t=>{t.preventDefault(),e=!e;const r=c.querySelector(".popup-wrap");!function(t,e){const r=t.querySelector(".minimizable-1945");e?(r.innerHTML="crop_square",t.style.height="30px",t.style.overflow="hidden"):(r.innerHTML="minimize",t.style.height="",t.style.overflow="visible")}(i?r:c,e)})),h?t&&(t.style.display="block"):(v.addEventListener("mouseenter",(()=>{t&&(t.style.display="block")})),v.addEventListener("mouseleave",(()=>{t&&(t.style.display="none")})))}if(a){const t=c.querySelector(".closable-1945");h?t&&(t.style.display="block"):(v.addEventListener("mouseenter",(()=>{t&&(t.style.display="block")})),v.addEventListener("mouseleave",(()=>{t&&(t.style.display="none")})))}c.querySelector(".closable-1945")?.addEventListener("click",(e=>{e.preventDefault(),yet.hide(t)})),c.addEventListener("close-scene",(e=>{e.preventDefault(),e.stopPropagation(),yet.hide(t),l&&(t.data=e.detail)})),e.target=d,e.data=n||t.data,e.fit("both");const{x:y,y:b}=t.center,w=t.transcoordS2T(y,b,t.rootModel),x=function(t,e,r,n){const{location:i=get,title:a=""}=n||{},s=t.bounds;let o=e.bounds;a&&(o.height+=30);const l=Math.max(s.width/4-o.width/2,20),h=Math.min(3*s.width/4+o.width/2,s.width-20)-o.width,c=Math.max(s.height/4-o.height/2,20)+(a?30:0),u=Math.min(3*s.height/4+o.height/2,s.height-20)-o.height+(a?30:0);switch(i){case get:return{x:r.x<s.width/2?Math.min(h,r.x+20):Math.max(l,r.x-(o.width+20)),y:r.y<s.height/2?Math.min(u,r.y+20+(a?30:0)):Math.max(c,r.y-(o.height+20+(a?30:0)))};case"left-top":return{x:l,y:c};case"right-top":return{x:h,y:c};case"left-bottom":return{x:l,y:u};case"right-bottom":return{x:h,y:u};default:return{x:(s.width-o.width)/2,y:(s.height-o.height+(a?30:0))/2}}}(t.rootModel,e.root,w,r);if(i)if(h){const t=c.querySelector(".popup-wrap");Object.assign(t.style,{position:"absolute",left:`${x.x}px`,top:`${x.y}px`,width:`${p}px`,height:`${f}px`})}else Object.assign(d.style,{left:`${x.x}px`,top:`${x.y}px`,width:`${p}px`,height:`${f}px`});else Object.assign(c.style,{left:`${x.x}px`,top:`${x.y}px`,width:`${p}px`,height:`${h?f+30:f}px`});!function(t,e){t.style.opacity=0,t.style.transform="scale(0)",t.style.display="block";let r=+new Date;const n=()=>{const i=Math.min((new Date-r)/200,1);t.style.opacity=i,t.style.transform=`scale(${i})`,i<1?requestAnimationFrame(n):e&&e()};n()}(c,(()=>{i&&(c.style.backgroundColor="rgba(0,0,0,0.3)")}))}),(t=>{console.error("cannot fetch board: "+e,t)}))}}var bet={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 wet(t){var e=t.components.filter((t=>!t.hidden)),r=t.getState("layoutConfig")||{},n=e[r&&r.activeIndex||0];return n&&[n]||[]}det.register("absolute",bet);var xet={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 wet(t)},drawables:function(t){return wet(t)},isStuck:function(t){return!0}};function Aet(t){var e=t.getState("layoutConfig");return e&&e.weight||1}det.register("card",xet);var _et={reflow:function(t){var e=this.drawables(t),r=t.get("padding")||{},n=e.reduce(((t,e)=>t+Aet(e)),0),i=t.bounds,a=n>0?(i.width-((r.left||0)+(r.right||0)))/n:i.width,s=i.height-((r.top||0)+(r.bottom||0)),o=0;e.forEach((t=>{let e=Aet(t),n=t.get("margin")||{};t.bounds={left:a*o+(r.left||0)+(n.left||0),top:0+(r.top||0)+(n.top||0),width:e*a-((n.left||0)+(n.right||0)),height:s-((n.top||0)+(n.bottom||0))},t.setState("rotation",0),o+=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 ket(t){var e=t.getState("layoutConfig");return e&&e.weight||1}det.register("linear-horizontal",_et);var Eet={reflow:function(t){var e=this.drawables(t),r=t.getState("padding")||{},n=e.reduce(((t,e)=>t+ket(e)),0),i=t.bounds,a=n>0?(i.height-((r.top||0)+(r.bottom||0)))/n:i.height,s=i.width-((r.left||0)+(r.right||0)),o=0;e.forEach((t=>{let e=ket(t),n=t.getState("margin")||{};t.bounds={left:0+(r.left||0)+(n.left||0),top:a*o+(r.top||0)+(n.top||0),width:s-((n.left||0)+(n.right||0)),height:e*a-((n.top||0)+(n.bottom||0))},t.setState("rotation",0),o+=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}};det.register("linear-vertical",Eet);var Met={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"),s=i?i.filter(((t,e)=>e<r)).reduce(((t,e)=>t+e),0):r,o=a?a.filter(((t,e)=>e<n)).reduce(((t,e)=>t+e),0):n,l=t.textBounds,h=t.getState("paddingLeft")||0,c=t.getState("paddingTop")||0,u=l.width/s,d=l.height/o,p=0,f=0;t.components.forEach(((t,e)=>{let n=i?i[e%r]:1,s=a?a[Math.floor(e/r)]:1,o=t.colspan||1,l=0;for(;--o>0;)l+=i?i[(e+o)%r]:1;let g=t.rowspan||1,v=0;for(;--g>0;)v+=a?a[Math.floor(e/r)+g]:1;t.bounds={left:h+p,top:c+f,width:u*(n+l),height:d*(s+v)},t.setState("rotation",0),e%r==r-1?(p=0,f+=s*d):p+=n*u}))},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:s,column:o}=t.getRowColumn(e);switch(r.code){case"ArrowUp":if(s>0)return t.getAt((s-1)*i+o);break;case"ArrowDown":if(s<a-1)return t.getAt((s+1)*i+o);break;case"ArrowRight":if(o<i-1)return t.getAt(s*i+o+1);break;case"ArrowLeft":if(o>0)return t.getAt(s*i+o-1);break;default:return e}},joinType:!0};det.register("table",Met);const Tet=new Image;Tet.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAAclBMVEVHcEwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAC0BbqFAAAAJXRSTlMAgAP3VSI6/g9fBk5FavJsMrariSjzPnO1enRRL5SMhmOOWB9keFTE0wAAANxJREFUOMutk9kWgyAMRLFuiLjUtdp9yf//YglVsQXz1HniMPcEMgHGvpX2O0Ypi+EgCL+IAShC+wB7QfubRDT7AFcnUPoLMLiP4PyJbsb55i05AgnR5iaQDsICgtH0cotBWoAP1c7kC6kFxEseCfZfB6gEgbNeBrira2QmH1uVYCXlA3is8UmgUCPIyQJKEmu8QtQJN0e9DPXVpzG2G216c1CqRmcBOdxXk07sWUSPv07zo0amCNQycv+NzmR6cRcwmfbuI7p2nZ/z4be0P83Foz6vIkhfZXr82XgDlZsspIq4peUAAAAASUVORK5CYII=";var Cet=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(Tet,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:s}=this.bounds,o=n+a;this.showMoveHandle&&(r=t<Math.max(o+25,o)&&t>Math.min(o+25,o)&&e<Math.max(i+25,i)&&e>Math.min(i+25,i))}return this._focustd!==r&&(this._focused=r,this.invalidate()),r}};const Pet=[];class Iet extends(Cet(aet(ret))){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 det.get(this.get("layout"))||bet}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||Pet).indexOf(t)}size(){return(this._components||Pet).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 J9(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 J9(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:s}=this.state;r=t<Math.max(n+a,n)&&t>Math.min(n+a,n)&&e<Math.max(i+s,i)&&e>Math.min(i+s,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 s=a[t].capture(n.x,n.y,r);if(s)return s}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:s}=this.bounds;for(let e=0;e<t.length;e++){let o=this.transcoordP2S(t[e].x,t[e].y);if(o.x<n||o.x>n+a||o.y<i||o.y>i+s)return!1;o.x-=n,o.y-=i,r.push(o)}let o=this.layout.capturables(this);for(let t=o.length-1;t>=0;t--){let n=o[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=>ret.memoize(Iet.prototype,t,!1)));class Ret extends Iet{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*z9),t.setAttribute("height",n*z9)),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=ret.createCanvas(1,1);return t.setAttribute("scene",this.state.type),t.style.position="absolute",t.style.pointerEvents=this.pointerEvents,t}get pointerEvents(){return"auto"}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*z9,e.y*z9),t.scale(r.x*z9,r.y*z9),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:s}=t.transcoordP2S(n,i),{x:o,y:l}=t.transcoordS2T(a,s),{x:h,y:c}=t.rootModel.get("translate"),{x:u,y:d}=t.rootModel.get("scale");e?w7({step:function(e){t.rootModel.set({translate:{x:h+(r.x-o)*u*e,y:c+(r.y-l)*d*e}})},duration:1e3,delta:"circ",ease:"in"}).start():t.rootModel.set({translate:{x:h+(r.x-o)*u,y:c+(r.y-l)*d}})}}const Oet={x:1,y:1},Let={x:0,y:0};class Det extends Ret{dispose(){super.dispose(),delete this._canvas,delete this._overlay}contains(t,e){return!0}isRootModel(){return!0}get stuck(){return!0}get layout(){return pet}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.setAttribute("scene",this.state.type),t.style["user-select"]="none",t.style.overflow="hidden",this._canvas=ret.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=Let,scale:r=Oet,rotation:n=0}=this.model,{left:i,top:a,width:s,height:o}=this.bounds;t.style.left=i+"px",t.style.top=a+"px",t.style.transform=`rotate(${n}rad) scale(${r.x}, ${r.y}) perspective(1px)`,t.style.marginLeft=`${e.x}px`,t.style.marginTop=`${e.y}px`}}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 Det)&&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:s,emphasize:o=!1,restore:l=!1,pressed:h=!1,options:c}=t;if(a&&(a=e.access(a)),s&&(s=e.access(s)),o&&(r?function(t){const{hover:e}=t.state.event||{},{emphasize:r}=e||{};if(t.hasOwnProperty("_backupStrokeStyle"))return;if("__backup_emphasize"in t)return;const{strokeStyle:n,lineWidth:i,fillStyle:a}=t.state;t.__backup_emphasize={strokeStyle:n,lineWidth:i,fillStyle:a},t.setState(r)}(e):l&&function(t){"__backup_emphasize"in t&&(t.setState(t.__backup_emphasize),delete t.__backup_emphasize)}(e)),i)switch(i){case"data-toggle":if(!a)return;(r||l)&&this.root.findAll(a,e).forEach((t=>{t.data=!t.data}));break;case"data-tristate":if(!a)return;(r||l)&&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 u=e.access(s);this.root.findAll(a,e).forEach((t=>{t.executeMappings(!0)}))}break;case"data-set":if(!a)return;if(r){u=e.access(s);this.root.findAll(a,e).forEach((t=>{t.data=u}))}break;case"partial-data-set":if(!a)return;if(r){u=e.access(s);this.root.findAll(a,e).forEach((t=>{t.data={...t.data,...u}}))}break;case"value-set":if(!a)return;if(r){u=e.access(s);this.root.findAll(a,e).forEach((t=>{t.value=u}))}break;case"partial-value-set":if(!a)return;if(r){u=e.access(s);this.root.findAll(a,e).forEach((t=>{t.value={...t.value,...u}}))}break;case"infoWindow":case"info-window":if(!a)return;"click"==n.type||r?cet.show(e,a,l,{x:n.offsetX,y:n.offsetY}):l&&cet.hide(e,a);break;case"toggle-info-window":if(!a)return;cet.toggle(e,a,!1,{x:n.offsetX,y:n.offsetY});break;case"popup":case"modal-popup":if(!a)return;let t=c&&"input"in c?c.input:"(self)",o=!c||(!("output"in c)||c.output);yet.show(e,a,{data:t&&this.root.findFirst(t,e)?.data,output:o,modal:"modal-popup"===i});break;case"close-scene":this.closeScene(e.data);break;case"goto":case"goto-playlist":this.trigger(i,a,c,e);break;case"mouse-cursor":r?this.target.style.cursor=a||"auto":l&&(this.target.style.cursor="auto");break;default:this.trigger(i,a,s,e)}}}function Fet(t,e){const r=t.state.refid;return t.root.findAll((t=>t.isLine()&&t.from.component===r&&(!e||t.from.anchor===e)))}function Net(t,e){const r=t.state.refid;return t.root.findAll((t=>t.isLine()&&t.to.component===r&&(!e||t.to.anchor===e)))}Det.Popup=yet,ret.register("model-layer",Det);var jet=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:s,width:o,height:l}=r;var n;if(n=t<Math.max(a+o,a)&&t>Math.min(a+o,a)&&e<Math.max(s+l,s)&&e>Math.min(s+l,s))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 Fet(this,t)}findOutletEnds(t){return function(t,e){return Fet(t,e).map((t=>t.toEnd?.component)).filter(Boolean)}(this,t)}findInletLines(t){return Net(this,t)}findInletEnds(t){return function(t,e){return Net(t,e).map((t=>t.fromEnd?.component)).filter(Boolean)}(this,t)}};const Bet={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"number",label:"round",name:"round",property:{min:0}}],help:"scene/component/rect"};var zet={ondragmove:function(t,e,r){var{left:n,top:i,width:a,height:s}=r.model,o=(r.transcoordP2S(t.x,t.y).x-n)/(a/2)*100;o=iet(o,a,s),r.set({round:o})}};class Wet extends(jet(aet(net))){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:iet(n,r,i))/100),y:e,handler:zet}]}get nature(){return Bet}}ret.register("rect",Wet);const Uet=[1,2,10,20,50,50,50,50,50,50];class Het extends(aet(net)){render(t){const{lineWidth:e=1,fillStyle:r="lightgray",font:n="15px Arial",left:i,top:a,rotation:s,origin:o,margin:l,width:h,height:c,side:u="bottom",strokeStyle:d="#000000",scale:p=1}=this.state;t.translate(i,a),t.beginPath();const f=Math.round(e/2);t.rect(-f,-f,h+2*f,c+2*f),t.clip(),t.beginPath(),t.rect(0,0,h,c),r&&(t.fillStyle=r,t.fill()),t.lineWidth=e,t.strokeStyle=d,t.stroke(),t.beginPath(),t.font=n;var g="bottom"!==u,v=g?0:c,m=4*c/5,y=2*c/3,b=1*c/2,w=3*c/5;g&&(m=c-m,y=c-y,b=c-b,w=c-1.5*c/5);var x=p*this.app.PPM/this.root.unitScale,A=Math.ceil(o/x),_=this.app.PPM/x,k=_<=1.1?1:Uet[Math.round(_)]||100;1!=k&&(A+=(k-A%k)%k);var S=Math.ceil(A*x),E=o+h;for(t.fillStyle=d;S<E;){if(A%10==0){t.moveTo(S-o,b),t.lineTo(S-o,v);let e=(A/10).toString(),r=t.measureText(e);t.fillText(e,S-o-r.width-6,w)}else A%5==0?(t.moveTo(S-o,y),t.lineTo(S-o,v)):(t.moveTo(S-o,m),t.lineTo(S-o,v));A+=k,S=Math.ceil(A*x)}}}ret.register("ruler",Het);const Get=20,Yet=20,Vet=90*Math.PI/180,qet="9px Verdana",Xet=20,$et="#f4f4f4",Ket="#999";function Qet(t,e,r){return{left:-t.x,top:-t.y,width:Get,height:Xet}}function Jet(t,e,r,n){return{left:Get-t.x,top:0-t.y,origin:20-t.x,width:e-Get,height:Xet}}function Zet(t,e,r,n){var i={x:0-t.x+10,y:-t.y+Yet+(r-Yet)/2},a=ret.transcoordRR(0-t.x,-t.y+Yet,i,Vet);return{left:a.x-(r-Yet),top:a.y,origin:20-t.y,width:r-Yet,height:Xet}}function trt(t){var e=t.get("translate");return{left:-e.x,top:-e.y,width:t.canvas.width/z9,height:t.canvas.height/z9}}ret.register("guide-layer",class extends Ret{constructor(t,e){super(t,e),this.appScale={x:1,y:1},"disabled"!==t.ruler&&(this.hruler=new Het({left:Get,top:0,origin:20,margin:0,height:Xet,unit:"m",rotation:0,font:qet,fillStyle:$et,strokeStyle:Ket,capturable:!1}),this.vruler=new Het({left:0,top:0,origin:20,margin:0,height:Xet,unit:"m",rotation:Vet,font:qet,side:"top",fillStyle:$et,strokeStyle:Ket,capturable:!1}),this.origin_rect=new Wet({left:-20,top:-20,width:20,height:20,fillStyle:$et,strokeStyle:Ket,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<Get&&(e.x+=Get),e.y<Yet&&(e.y+=Yet);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=trt(this);var{width:n,height:i}=this.screen_coord;this.hruler.set(Jet(e,n,0,this.hruler)),this.vruler.set(Zet(e,0,i,this.vruler)),this.origin_rect.set(Qet(e))}else this.screen_coord=trt(this)}resize(){super.resize(),this.screen_coord=trt(this);var{width:t,height:e}=this.screen_coord;this.hruler&&(this.hruler.set(Jet(this.model.translate,t,0,this.hruler)),this.vruler.set(Zet(this.model.translate,0,e,this.vruler)),this.origin_rect.set(Qet(this.model.translate)))}render(t){if(this.guide){t.save();var{x:e,y:r}=this.guide,{top:n,left:i,width:a,height:s}=this.screen_coord;t.beginPath(),t.moveTo(e,n),t.lineTo(e,n+s),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 o=this.transcoordS2C(e,r,this.rootModel);t.textBaseline=o.y>200?"bottom":"top",t.textAlign=o.x>200?"right":"left";var l=o.y>200?-5:5,h=o.x>200?-5:5,c=Math.round(e/this.appScale.x),u=Math.round(r/this.appScale.y);t.fillText(` ${c}, ${u} `,e+h,r+l),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=trt(this),this.hruler){var{translate:n}=this.model,{width:i,height:a}=this.screen_coord;this.hruler.set(Jet(n,i,0,this.hruler)),this.vruler.set(Zet(n,0,a,this.vruler)),this.origin_rect.set(Qet(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)}});ret.register("shift-layer",class extends Ret{ready(){super.ready();var t=this.rootModel.get("translate");this.set("translate",t)}render(t){}get pointerEvents(){return"none"}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 ert{constructor(t){this.params=Object.assign({},t)}excute(){}}class rrt extends ert{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 nrt="left",irt="right",art="center",srt="bottom",ort="middle",lrt=[nrt,irt,art,"top",ort,srt];function hrt(t){if(this.hasSameParentForAllSelected&&-1!=lrt.indexOf(t)){var e=this.selected.filter((t=>!t.stuck));if(!(e.length<=1)){var r=this.app.commander;rrt.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 nrt: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 art: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 irt: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"top":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 ort: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 srt: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 crt="VERTICAL",urt=[crt,"HORIZONTAL"];function drt(t){if(this.hasSameParentForAllSelected&&-1!=urt.indexOf(t)){var e=this.selected;if(!(e.length<=1)){var r=this.app.commander;rrt.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===crt?n.y-i.y:n.x-i.x}));var n=r.reduce(((e,r)=>e+(t===crt?r.bounds.height:r.bounds.width)),0),i=r[0].bounds,a=r[r.length-1].bounds,s=((t===crt?a.top+a.height-i.top:a.left+a.width-i.left)-n)/(r.length-1),o=t===crt?i.top+i.height:i.left+i.width;for(let e=1;e<r.length-1;e++){let n=r[e],i=n.bounds;o+=s,t===crt?(i.top=o,o+=i.height):(i.left=o,o+=i.width),n.bounds=i}}(t,e)}))}}}function prt(t){for(var e=0;t&&!t.isRootModel();)e+=t.get("rotation")||0,t=t.parent;return e%(2*Math.PI)}class frt extends ert{execute(){this.params.changes.forEach((t=>{let{component:e,to_container:r,to_index:n,to_left:i,to_top:a,hint:s}=t,o=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),l=prt(e);if(e.removeSelf(!r),e.bounds=o,e.set("rotation",l),r){e.set("rotation",function(t,e){return((t.get("rotation")||0)-prt(e))%(2*Math.PI)}(e,r));let s=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:s.left,t.to_top=void 0!==a?a:s.top,e.bounds={left:t.to_left,top:t.to_top,width:s.width,height:s.height},void 0===n?r.addComponent(e):r.insertComponentAt(e,n)}}))}}function grt(t,e,r){this.app.commander.execute(new frt({changes:[{component:t,to_container:e,to_index:r}]}))}function vrt(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 frt({changes:r});this.app.commander.execute(i)}}function mrt(t,e,r,n){var i=ret.register(t.type);if(!i)return T9("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=mrt(t,e,r,n);i&&a.addComponent(i)})),delete t.components),a.created(),a}function yrt(t,e){var r=X7(t.hierarchy);return delete r.id,mrt(r,t.app,e)}var brt=Object.freeze({__proto__:null,compile:mrt,duplicate:yrt,select:J9,match:$9});function wrt(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 mrt(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:s,width:o,height:l,x:h,y:c,cx:u,cy:d}=e;return t.replaceRefids(i),isNaN(a)||isNaN(s)||isNaN(o)||isNaN(l)||(t.bounds={left:a,top:s,width:o,height:l}),isNaN(h)||isNaN(c)||t.move({x:h,y:c},!1),isNaN(u)||isNaN(d)||(t.center={x:u,y:d}),n.push({component:t,to_container:r}),t})),this.app.commander.execute(new frt({changes:n}))}function xrt(){var t=[],e=new Map;if(this.selected=this.selected.filter((t=>!t.isRootModel())).map((r=>{let n=yrt(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 frt({changes:t});this.app.commander.execute(r)}}function Art(){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 frt({changes:r})),e&&e.calculateBounds&&e.calculateBounds()}function _rt(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 krt(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 Srt(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 Ert(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 Mrt=0;function Trt(){var t=this.selected.filter((t=>!t.isRootModel())).map((t=>t.hierarchy));if(0!=t.length)return Mrt=0,JSON.stringify(t,null,2)}function Crt(){Mrt=0;var t=Trt.call(this);return Art.call(this),t}function Prt(t){if(t)try{Mrt++,wrt.call(this,JSON.parse(t),{x:15*Mrt,y:15*Mrt})}catch(e){M9(e,t)}}var Irt=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;zrt.impl.options.cacheBust&&(t+=(/\?/.test(t)?"&":"?")+(new Date).getTime());return new Promise((function(r){var n,i=new XMLHttpRequest;if(i.onreadystatechange=s,i.ontimeout=o,i.responseType="blob",i.timeout=e,i.open("GET",t,!0),i.send(),zrt.impl.options.imagePlaceholder){var a=zrt.impl.options.imagePlaceholder.split(/,/);a&&a[1]&&(n=a[1])}function s(){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):l("cannot fetch resource: "+t+", status: "+i.status)}function o(){n?r(n):l("timeout of "+e+"ms occured while fetching resource: "+t)}function l(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",""))}}(),Rrt=function(){var t=/url\(['"]?([^'"]+?)['"]?\)/g;return{inlineAll:function(t,i,a){return s()?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 s(){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!Irt.isDataUrl(t)}))}function n(t,e,r,n){return Promise.resolve(e).then((function(t){return r?Irt.resolveUrl(t,r):t})).then(n||Irt.getAndEncode).then((function(t){return Irt.dataAsUrl(t,Irt.mimeType(e))})).then((function(r){return t.replace(function(t){return new RegExp("(url\\(['\"]?)("+Irt.escape(t)+")(['\"]?\\))","g")}(e),"$1"+r+"$3")}))}}(),Ort=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(Irt.asArray(document.styleSheets)).then((function(t){var e=[];return t.forEach((function(t){try{Irt.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 Rrt.shouldProcess(t.style.getPropertyValue("src"))}))})).then((function(e){return e.map(t)}));function t(t){return{resolve:function(){var e=(t.parentStyleSheet||{}).href;return Rrt.inlineAll(t.cssText,e)},src:function(){return t.style.getPropertyValue("src")}}}}}(),Lrt=function(){return{inlineAll:function e(r){return r instanceof Element?n(r).then((function(){return r instanceof HTMLImageElement?t(r).inline():Promise.all(Irt.asArray(r.childNodes).map((function(t){return e(t)})))})):Promise.resolve(r);function n(t){var e=t.style.getPropertyValue("background");return e?Rrt.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 Irt.isDataUrl(t.src)?Promise.resolve():Promise.resolve(t.src).then(e||Irt.getAndEncode).then((function(e){return Irt.dataAsUrl(e,Irt.mimeType(t.src))})).then((function(e){return new Promise((function(r,n){t.onload=r,t.onerror=n,t.src=e}))}))}}}}(),Drt={imagePlaceholder:void 0,cacheBust:!1};function Frt(t,e){return function(t){void 0===t.imagePlaceholder?zrt.impl.options.imagePlaceholder=Drt.imagePlaceholder:zrt.impl.options.imagePlaceholder=t.imagePlaceholder;void 0===t.cacheBust?zrt.impl.options.cacheBust=Drt.cacheBust:zrt.impl.options.cacheBust=t.cacheBust}(e=e||{}),Promise.resolve(t).then((function(t){return jrt(t,e.filter,!0)})).then(Brt).then((function(t){var{bgcolor:r,width:n,height:i,style:a,sx:s=1,sy:o=1}=e,l=t.style;r&&(l.backgroundColor=r);n&&(l.width=n+"px");i&&(l.height=i+"px");l["margin-left"]="0px",l["margin-top"]="0px",l.transform=`rotate(0rad) translate(0px, 0px) scale(${s}, ${o}) perspective(1px)`,a&&Object.keys(a).forEach((function(t){l[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(Irt.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||Irt.width(t),e.height||Irt.height(t))}))}function Nrt(t,e){return Frt(t,e).then(Irt.makeImage).then(Irt.delay(100)).then((function(r){var n=function(t){var r=document.createElement("canvas");if(r.width=e.width||Irt.width(t),r.height=e.height||Irt.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 jrt(t,e,r){return r||!e||e(t)?Promise.resolve(t).then((function(t){if(t instanceof HTMLCanvasElement)try{return Irt.makeImage(t.toDataURL())}catch(t){T9(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,Irt.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 jrt(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){Irt.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=Irt.uid();e.className=e.className+" "+a;var s=document.createElement("style");s.appendChild(o(a,r,n)),e.appendChild(s)}function o(t,e,r){var n="."+t+":"+e,i=r.cssText?a(r):s(r);return document.createTextNode(n+"{"+i+"}");function a(t){var e=t.getPropertyValue("content");return t.cssText+" content: "+e+";"}function s(t){return Irt.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 Brt(t){return Lrt.inlineAll(t).then((function(){return t}))}var zrt={toSvg:Frt,toPng:function(t,e){return Nrt(t,e||{}).then((function(t){return t.toDataURL()}))},toJpeg:function(t,e){return Nrt(t,e=e||{}).then((function(t){return t.toDataURL("image/jpeg",e.quality||1)}))},toBlob:function(t,e){return Nrt(t,e||{}).then(Irt.canvasToBlob)},toPixelData:function(t,e){return Nrt(t,e||{}).then((function(e){return e.getContext("2d").getImageData(0,0,Irt.width(t),Irt.height(t)).data}))},impl:{fontFaces:Ort,images:Lrt,util:Irt,inliner:Rrt,options:{}}};function Wrt(t,e,r,n){var i=this.model_layer,a=i._overlay;return new Promise((function(s,o){if(i){var l=i.get("width"),h=i.get("height");r=r||l,n=n||h;var c=i.get("translate"),u=i.get("scale"),d=Math.min(r/l,n/h);r=l*d,n=h*d,i.set("translate",{x:0,y:0}),i.set("scale",{x:d/z9,y:d/z9});var p=ret.createCanvas(r,n),f=p.getContext("2d");if(i.draw(f),i.set("translate",c),i.set("scale",u),!a)return s(p.toDataURL(t,e)),void(p=null);zrt.toPng(a,{sx:d,sy:d,width:r,height:n}).then((function(i){var a=new Image;a.onload=function(){f.drawImage(a,0,0,r,n),s(p.toDataURL(t,e)),p=null},a.src=i}),(function(r){M9(r),s(p.toDataURL(t,e)),p=null}))}else o("No target model")}))}function Urt(){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=ret.union(r),a=t[0].transcoordP2S(i.left,i.top);a=t[0].transcoordS2T(a.x,a.y);var s=new Map,o=mrt({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&&s.set(t,e),e}));o.replaceRefids(s);var l=[{component:o,to_container:e}];n.forEach((t=>{l.push({component:t,to_container:o})})),this.app.commander.execute(new frt({changes:l})),this.selected=[o]}}}function Hrt(){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 frt({changes:e})),this.selected=t}}function Grt(){var t=this.selected;if(0!=t.length){var e=t.map((t=>t.bounds)),r=ret.union(e),n=r.left+r.width/2;t.map((t=>{t.symmetryX(n)}))}}function Yrt(){var t=this.selected;if(0!=t.length){var e=t.map((t=>t.bounds)),r=ret.union(e),n=r.top+r.height/2;t.map((t=>{t.symmetryY(n)}))}}function Vrt(){rrt.around(this.app.commander,Grt,this)}function qrt(){rrt.around(this.app.commander,Yrt,this)}function Xrt(t,e,r){var n=this.findAll(t,r);return n.forEach((t=>{t.set(e)})),n}function $rt(t){rrt.around(this.app.commander,t)}function Krt(){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 Qrt="left",Jrt="right",Zrt="center",tnt="bottom",ent="middle",rnt=[Qrt,Jrt,Zrt,"top",ent,tnt];function nnt(t){if(this.hasSameParentForAllSelected&&-1!=rnt.indexOf(t)){var e=this.selected.filter((t=>!t.stuck)),r=this.app.commander;rrt.around(r,(function(){!function(t,e){const r=e[0].parent,{width:n,height:i}=r.bounds;switch(t){case Qrt:for(let t=0;t<e.length;t++){let r=e[t].bounds;e[t].bounds={...r,left:0}}break;case Zrt: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 Jrt:for(let t=0;t<e.length;t++){let r=e[t].bounds;e[t].bounds={...r,left:n-r.width}}break;case"top":for(let t=0;t<e.length;t++){let r=e[t].bounds;e[t].bounds={...r,top:0}}break;case ent: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 tnt: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 int(t){t instanceof Array||(t=[t]),this.trigger("addstart",t)}function ant(){this.trigger("stylepastestart")}function snt(){this.trigger("stylepastestop")}function ont(){this.trigger("databindpastestart")}function lnt(){this.trigger("databindpastestop")}function hnt(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 s=e.layout.capturables(e),o=!!e.layout.joinType;if(n&&r.selected.forEach((t=>{a.splice(a.indexOf(t),1)})),r.selected=[],s.forEach((t=>{t.capturable&&function(t,e,r){var n,i,a,s,{sx:o,sy:l,ex:h,ey:c}=e;if(o>h?(n=h,i=o):(n=o,i=h),l>c?(a=c,s=l):(a=l,s=c),r){var u=t.bounds,d=t.transcoordS2TR(u.left,u.top),p=t.transcoordS2TR(u.left+u.width,u.top+u.height),f=d.x,g=p.x,v=d.y,m=p.y,y=Math.min(n,f,i,g),b=Math.max(n,f,i,g),w=Math.min(a,v,s,m),x=Math.max(a,v,s,m);return!(b-y>Math.abs(i-n)+Math.abs(g-f)||x-w>Math.abs(s-a)+Math.abs(m-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||s<r.y)return!1}return!0}(t,r,o)&&-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 cnt(t,e,r,n,i){i||hnt(t,e,r,n)}function unt(t,e){var r=t.components||[];for(let t of r){unt(t,e);let r=e.indexOf(t);-1!=r&&e.splice(r,1)}}ret.register("add-layer",class extends Ret{ready(){super.ready();var t=this.rootModel,e=t.get("translate"),r=t.get("scale");this.set("translate",e),this.set("scale",r)}get pointerEvents(){return"none"}render(t){var e=this.addbox;if(e){let{sx:r,sy:n,ex:i,ey:a}=e,s=this.get("scale")||{x:1,y:1};t.beginPath(),t.rect(r,n,i-r,a-n),t.setLineDash([2/s.x,4/s.y]),t.lineWidth=1/s.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;wrt.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);wrt.call(this.root,this.models,{cx:r,cy:n}),this.root.trigger("addstop")}}});ret.register("selection-layer",class extends Ret{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,s=this.get("scale")||{x:1,y:1};t.beginPath(),t.rect(r,n,i-r,a-n),t.setLineDash([2/s.x,4/s.y]),t.lineWidth=1/s.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],s=a.parent;if(!s||s===n)return!1;if("Tab"===t.code){var o=s.layout.capturables(s),l=o.indexOf(a);if(-1==l){if(!s.indexOf(a))return T9("Container not contains [",a,"] as a component"),!1;l=0}var h=o.length;t.shiftKey?l--:l++,a=o[(l+h)%h]}else{if(!s.layout.keyNavigate)return!1;a=s.layout.keyNavigate(s,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,s=!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 s=!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(s)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),unt(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,cnt(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,cnt(this,null,null,!1,!0),this.invalidate())}});class dnt{constructor(t){this.layer=t}draw(t,e,r){var{left:n,top:i,width:a,height:s}=e.bounds;0!=a&&0!=s&&(t.beginPath(),t.rect(n,i,a,s),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,s),t.stroke(),t.closePath())}}class pnt{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 fnt{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=rrt.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;rrt.after(r,e.app.commander),e.parent&&e.parent.calculateBounds&&e.parent.calculateBounds()}}function gnt(t,e){return Math.atan2(e.y-t.y,e.x-t.x)}const vnt=15*Math.PI/180;class mnt{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=mrt(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=rrt.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,s,o=e.transcoordC2S(n,i);if(o=e.transcoordS2P(o.x,o.y),t.shiftKey){var l=e.path.length,h=e.isLine()&&0==r?e.path[1]:e.path[(r-1+l)%l];h=e.transcoordS2P(h.x,h.y);var c,u=0;if(l>2)e.isLine()?0==r?c=e.path[2]:1!=r&&(c=e.path[r-2]):c=e.path[(r-2+l)%l],c&&(u=gnt(c=e.transcoordS2P(c.x,c.y),h));var d=Math.round((gnt(h,o)-u)/vnt)*vnt+u;o=function(t,e,r){return{x:Math.cos(e)*r+t.x,y:Math.sin(e)*r+t.y}}(h,d,(a=h,s=o,Math.sqrt((s.x-a.x)*(s.x-a.x)+(s.y-a.y)*(s.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:s}=t.transcoordC2S(n,i),l=this.layer.get("scale")||{x:1,y:1},h=this.layer.counterEnd,c=(t.anchors||[]).find((r=>{const{name:n,inout:i,multiplicity:o=1/0,position:c,filter:u}=r;if(h){const{anchor:t,fromto:e}=h;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-c.x)>8/l.x||Math.abs(s-c.y)>8/l.y)return!1;const d=t.findInOutLines(n);return!!d.includes(e)||!(o!==1/0&&d.length>=o)&&(!h||!u||!!u.call(r,h))}));c?0==r?e.from={component:t.get("refid"),anchor:c.name,position:o}:e.to={component:t.get("refid"),anchor:c.name,position:o}:0==r?e.from={position:o}:e.to={position:o}}}e.mutatePath(null,(function(t){t[r]=o}))}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:s,y:o}=a.transcoordC2S(n,i),l=this.layer.get("scale")||{x:1,y:1},h=(a.anchors||[]).find((t=>t&&Math.abs(s-t.position.x)<=8/l.x&&Math.abs(o-t.position.y)<=8/l.y));h&&(0==r?e.from={component:a.get("refid"),anchor:h.name}:e.to={component:a.get("refid"),anchor:h.name}),this.layer.endLinkProcess()}if(this.created){let t=new frt({changes:[{component:this.created,to_container:this.created.parent}]});created.app.commander.execute(t)}else rrt.after(n,e.app.commander);e.parent&&e.parent.calculateBounds&&e.parent.calculateBounds()}}class ynt{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:s}=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)&&(!s||!a||!!s.call(t,a))})).every((a=>{const s=i===a.name?2:1;return a&&a.position&&Math.abs(t-a.position.x)<=4*s/n.x&&Math.abs(e-a.position.y)<=4*s/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:s}=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||!s||!!s.call(t,a))})).forEach((a=>{const{name:s,position:o}=a,l=i===s?2:1;o&&(t.beginPath(),t.ellipse(o.x,o.y,4*l/r.x,4*l/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===s&&(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 bnt(t,e,r){var n,i,{left:a,top:s,width:o,height:l}=t.bounds;switch(e){case 0:n=a,i=s;break;case 1:n=a+o/2,i=s;break;case 2:n=a+o,i=s;break;case 3:n=a+o,i=s+l/2;break;case 4:n=a+o,i=s+l;break;case 5:n=a+o/2,i=s+l;break;case 6:n=a,i=s+l;break;case 7:n=a,i=s+l/2}var h=n,c=i,u=t.transcoordT2S(r.x,r.y);return{dx:u.x-h,dy:u.y-c}}function wnt(t,e,r,n,i,a){var{left:s,top:o,width:l,height:h}=t.bounds,c={left:s,top:o,width:l,height:h};switch(e){case 0:s+=n,o+=i,l-=n,h-=i;break;case 1:o+=i,h-=i;break;case 2:o+=i,l+=n,h-=i;break;case 3:l+=n;break;case 4:l+=n,h+=i;break;case 5:h+=i;break;case 6:s+=n,l-=n,h+=i;break;case 7:s+=n,l-=n}if(t.mutateBounds((function(e){return Math.abs(l)<=.001&&(l=.001),Math.abs(h)<=.001&&(h=.001),t.adjustResize({left:s,top:o,width:l,height:h},c,r)}),this),t.isContainer()&&t.layout.ABSOLUTE&&!t.isGroup()){var u=c.left-s,d=c.top-o;a?t.components.forEach((t=>{t.delta("tx",0),t.delta("ty",0),t.move({x:u,y:d},!1)})):t.components.forEach((t=>{t.delta("tx",u),t.delta("ty",d)}))}else{var p=a&&t.parent;p&&p.isGroup()&&p.calculateBounds()}}function xnt(t,e){var{left:r,top:n,width:i,height:a}=t,s=r+i/2,o=n+a/2,l=r+i,h=n+a;const c=i*e.x>50,u=a*e.y>50;return[{x:r,y:n},c?{x:s,y:n}:null,{x:l,y:n},u?{x:l,y:o}:null,{x:l,y:h},c?{x:s,y:h}:null,{x:r,y:h},u?{x:r,y:o}:null]}class Ant{constructor(t){this.layer=t}reset(){this.active=null}get selected(){return this.layer.selected}contains(t,e,r,n){return!!r.resizable&&(xnt(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:s}=e.bounds;if(t.beginPath(),t.rect(n-4/r.x,i-4/r.y,a+8/r.x,s+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 o=this.active;xnt(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",o&&o.component===e&&o.index===i&&(t.strokeStyle="#fa7703",o.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 s=bnt(e,r,a);this.layer.selected.filter((t=>t.resizable)).forEach(((e,i)=>{e.bounds=n[i],wnt(e,r,t.shiftKey,s.dx,s.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 s=bnt(e,r,a);this.layer.selected.filter((t=>t.resizable)).forEach(((e,i)=>{e.bounds=n[i],wnt(e,r,t.shiftKey,s.dx,s.dy,!0)})),this.active.component.app.commander.execute(null,!1)}}const _nt=2*Math.PI,knt=Math.PI/2;function Snt(t,e){var r=t.bounds;return{x:r.left+r.width/2,y:r.top-20/e.y}}class Ent{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=Snt(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=Snt(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,_nt,!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)),s=(a=n.x>=r.x?a-knt:knt+a)-i;this.layer.selected.filter((t=>t.rotatable)).forEach(((e,r)=>{let n=((e.get("rotation")||0)+s)%_nt;e.set("rotation",e.adjustRotation(n,t.shiftKey))}))}ondragend(t){var{component:e,rotations:r}=this.active;e.app.commander.execute(null,!1)}}ret.register("modeling-layer",class extends Ret{constructor(t,e){super(t,e),this.pathHandler=new mnt(this);var r=this.pathHandler,n=new fnt(this),i=new Ant(this),a=new Ent(this);this._modelers=[r,n,i,a],this._control_mode_modelers=[n,r,i,a],this.focusOutline=new dnt(this),this.groupOutline=new pnt(this),this.anchorHandler=new ynt(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],s=a.transcoordT2S(t,e);for(let t=0;t<this.modelers.length;t++){let e=this.modelers[t];if(e.contains(s.x,s.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 s=e.rotatePoint;t.translate(s.x,s.y);let o=e.get("scale");o&&t.scale(o.x,o.y),t.rotate(e.get("rotation")),t.translate(-s.x,-s.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*z9,e.y*z9),t.scale(r.x*z9,r.y*z9),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 rrt.around(this.app.commander,(()=>{r.ondropfile(n,e)})),void(this.selected=[r]);let s=[],o=e.map(((t,e)=>{let r,o=n[e].type,l=n[e].name;return o.startsWith("image/")?(r=mrt({type:o.startsWith("image/gif")?"gif-view":"image-view",top:0,left:0,width:200,height:200,src:t},a.app),s.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)}})))):o.startsWith("audio/")?r=mrt({type:"audio",top:0,left:0,width:100,height:100,src:t},a.app):o.startsWith("vnd.ms-excel/")||/\.xlsx?$/.test(l)?r=mrt({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})));o.length>0&&Promise.all(s).then((()=>{this.app.commander.execute(new frt({changes:o})),this.selected=o.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;t.altKey?rrt.around(this.app.commander,(()=>{r.selected.forEach((t=>{let e=t.get("letterSpacing")||H9.LETTER_SPACING;e+=n,t.set("letterSpacing",e)}))})):rrt.around(this.app.commander,(()=>{r.selected.forEach((t=>{let e=t.get("fontSize")||H9.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,s=t.offsetY,o=r.transcoordC2S(a,s),l=.1*n,h={x:e.x+l,y:e.y+l};if(n<0&&e.x<.2||n>0&&e.x>10)return;r.set("scale",h);let c=r.transcoordC2S(a,s);r.set("translate",{x:i.x+(c.x-o.x)*h.x,y:i.y+(c.y-o.y)*h.y})}}}});class Mnt extends Ret{constructor(t,e){super(t,e),this._anim_alpha=1}get pointerEvents(){return"none"}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?Xtt(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=[]}}ret.register("decotag-layer",Mnt),ret.register("tag-layer",Mnt);ret.register("reaction-layer",class extends Ret{constructor(t,e){super(t,e),this._anim_alpha=1}get pointerEvents(){return"none"}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?Xtt(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 Tnt(){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 s=r[a];if($9(a,n.origin,0,t))for(let t in s){let r=s[t];t==n.name&&(n.listener=e,r.apply(e,i))}}}(r.deliverer,n.listener,n.cloned_handlers,e,t)}))}ret.register("scroll-layer",class extends Ret{get capturable(){return!0}get pointerEvents(){return"none"}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:s}=this.rootModel.model,{x:o,y:l}={x:t.offsetX,y:t.offsetY},{x:h,y:c}=this._scale,{scrolling:u}=this.state,d=a/n,p=s/i;u&&r.rootModel.move({x:"h"==u?(-o+this.lastPosition.x)*h*d:0,y:"v"==u?(-l+this.lastPosition.y)*c*p: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:s=0,y:o=0}=this._translate||{},l=r/t,h=n/e;var c={left:-s/i/l,top:e-10,width:t/i/l,height:10};this.hscroller=c.left>1||c.width+c.left<t-1?c:null,c={left:t-10,top:-o/a/h,width:10,height:e/a/h},this.vscroller=c.top>1||c.height+c.top<e-1?c: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 Cnt{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)",Tnt,{event_pump:this})}stop(){this.deliverer.off("(all)",Tnt)}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:T9("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 Pnt{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.");J9(r,this.root,t).forEach((r=>{var i=new Cnt(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 Int=0,Rnt=1,Ont=2,Lnt=0,Dnt=1,Fnt=2;var Nnt={},jnt=0;class Bnt{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 Nnt;let r=e.target.getBoundingClientRect();return Nnt={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 s=n-e||0,o=i-r||0;return Math.sqrt(Math.pow(s,2)+Math.pow(o,2))||0}(t);jnt>0&&(this._scale=n/jnt),jnt=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,this.originalEvent&&"function"==typeof this.originalEvent.stopPropagation&&this.originalEvent.stopPropagation()}isPropagationStopped(){return this._stop_}preventDefault(){this._prevented=!0}isDefaultPrevented(){return this._prevented}}function znt(t,e){return t.capture(e.offsetX,e.offsetY)}function Wnt(t,e,r){if(t&&t.app&&(!t.app.isViewMode||!t.hidden)){r instanceof Bnt&&e===r.type||(r=new Bnt(r,e));var n="on"+e;t[n]&&t[n](r),r.isPropagationStopped()||t.trigger(e,r)}}class Unt{constructor(t,e){this.container=t,this.html_element=e,this.status=Int,this.last_target=null,this.gesture_handlers=W9.map((t=>this.gestureHandlerBuilder(t))),this.keyevent_handlers=U9.map((t=>this.keyeventHandlerBuilder(t))),W9.forEach(((t,r)=>e.addEventListener(t,this.gesture_handlers[r])),{passive:!1}),U9.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&&Wnt(this.last_enter_target,"mouseleave",new CustomEvent("mouseleave")),W9.forEach(((t,e)=>this.html_element.removeEventListener(t,this.gesture_handlers[e]))),U9.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=>{const r=new Bnt(t);return e(r),r.isDefaultPrevented()&&t.preventDefault(),!1}}keyeventHandlerBuilder(t){return this[`on${t}`].bind(this)}ondragover(t){return Wnt(znt(this.container,t),t.type,t),!1}ondrop(t){return Wnt(znt(this.container,t),t.type,t),!1}ondblclick(t){return Wnt(znt(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 Rnt:let r=t.offsetX-this.__dragstart_e.offsetX,n=t.offsetY-this.__dragstart_e.offsetY;if(r*r+n*n<16)break;this.status=Ont,Wnt(this.last_target,"dragstart",this.__dragstart_e),this.__dragmove_e=t,Wnt(this.last_target,"dragmove",t);break;case Ont:this.__dragmove_e=t,Wnt(this.last_target,"dragmove",t);break;default:var e=znt(this.container,t);this.last_enter_target!==e&&(this.last_enter_target&&Wnt(this.last_enter_target,"mouseleave",t),e&&Wnt(e,"mouseenter",t),this.last_enter_target=e),Wnt(e,t.type,t),this.last_target=e}return!1}onmousedown(t){if(this.status===Ont)Wnt(this.last_target,"dragend",t),this.last_target=null,this.status=Int;else{var e=znt(this.container,t);this.last_target=e,this.status=Rnt,this.__dragstart_e=t,Wnt(e,t.type,t)}return!1}onmouseup(t){if(this.status===Ont)Wnt(this.last_target,"dragend",t);else{var e=znt(this.container,t);Wnt(e,t.type,t),this.last_target===e&&Wnt(e,"click",t)}return this.last_target=null,this.status=Int,!1}onmouseout(t){var e=znt(this.container,t);if(this.status===Ont)Wnt(this.last_target,"dragend",t);else{if(this.last_target&&this.last_target===e)return;this.last_enter_target&&(Wnt(this.last_enter_target,"mouseleave",t),delete this.last_enter_target)}return this.last_target=null,this.status=Int,!1}ontouchstart(t){var e=znt(this.container,t);return this.last_target=e,this.status=Dnt,this.touchPoints||(this.touchPoints=[]),this.touchPoints.push(t.changedTouches[0]),this.holdTimer=setTimeout((()=>{this.status=Lnt,Wnt(this.last_target,"hold",t),delete this.holdTimer}),500),Wnt(e,t.type,t),!1}ontouchmove(t){if(!t.touches||!t.changedTouches)return Wnt(this.last_target,"dragstart",t),Wnt(this.last_target,"dragmove",t),!1;var e=znt(this.container,t);switch(this.status){case Dnt: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=Fnt,void(this.holdTimer&&(clearTimeout(this.holdTimer),delete this.holdTimer))):void 0}}));break;case Fnt: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 Wnt(this.last_target,"pinch",t),!1;Wnt(this.last_target,"pan",t),e=this.last_target;break;default:this.last_enter_target!==e&&(this.last_enter_target&&Wnt(this.last_enter_target,"mouseleave",t),e&&Wnt(e,"mouseenter",t),this.last_enter_target=e),this.last_target=e}return Wnt(e,"touchmove",t),!1}ontouchend(t){var e=znt(this.container,t);switch(this.status){case Fnt:e=this.last_target;break;case Dnt:var r=performance.now(),n=r-this.touchedAt;this.holdTimer&&(clearTimeout(this.holdTimer),delete this.holdTimer,Wnt(e,n<500?"doubletap":"tap",t),this.touchedAt=r)}Wnt(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=Lnt,!1}onwheel(t){return Wnt(znt(this.container,t),t.type,t),!1}}function Hnt(t,e,r,n=0){if(e.length<2)return e;let i=2;for(;i<e.length;i++){const a=e.substring(0,i);if(!(t.measureText(a).width+(a.length-1)*n<r))break}return e.substring(0,i-1)}function Gnt(t,e,r,n,i=0){const a=String(e).split("\n");return n?[].concat.apply([],a.map((e=>function(t,e,r,n=0){const i=e.split(" "),a=[];let s,o,l=[];for(s=0,o=1;o<=i.length;o++)if(l=i.slice(s,o),t.measureText(l.join(" ")).width+(l.join("").length-1)*n>r){if(o-s==1){const e=Hnt(t,l[0],r,n);a.push([e]),i.splice(s,1,e,l[0].substring(e.length))}else{for(;""==i[o-1];)o++;a.push(i.slice(s,--o))}s=o}return o-s>1&&a.push(l),0==a.length&&a.push([""]),a}(t,e,r,i)))):a.map((t=>t.split(" ")))}var Ynt={},Vnt={};const qnt=()=>{};var Xnt={register:function(t,e,r){Ynt[t]=e,r&&(Vnt[t]=r)},unregister:function(t){delete Ynt[t],delete Vnt[t]},get:function(t){return Ynt[t]},getDisposer:function(t){return Vnt[t]||qnt}};function $nt(t){if(!t.hasTextProperty||t.textHidden)return;var{text:e="",bold:r=H9.BOLD,italic:n=H9.ITALIC,textWrap:i=H9.TEXT_WRAP,letterSpacing:a=0,fontFamily:s=H9.FONT_FAMILY,fontColor:o=H9.FONT_COLOR,textAlign:l=H9.TEXT_ALIGN,textBaseline:h=H9.TEXT_BASELINE,fontSize:c=H9.FONT_SIZE,lineHeight:u=1.2*c}=t.model,{left:d,top:p,width:f,height:g}=t.textBounds;c||=H9.FONT_SIZE,u||=1.2*c,t.textHidden=!0;var v=document.createElement("textarea");W9.forEach((function(t){v.addEventListener(t,(function(t){t.stopPropagation()}),!0)}));const m=t.transcoordS2C(d,p),{rotation:y,scale:b}=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(v.style.position="absolute",v.style.width=f+"px",v.style.height=g+"px",v.style.padding="0",v.value=e,v.style.fontFamily=s,v.style.fontSize=c+"px",v.style.lineHeight=u+"px",v.style.overflow="hidden",v.style.resize="none",v.style.outline="none",v.style.border=0,v.style.backgroundColor="transparent",v.style.display="inline-block",v.style.color=o,r&&(v.style.fontWeight="bold"),n&&(v.style.fontStyle="italic"),l){case"right":case"end":v.style.textAlign="right";break;case"justify":v.style.textAlign="justify";break;case"left":case"start":v.style.textAlign="left";break;default:v.style.textAlign="center"}var w=[r,n,c+"px",s].filter(Boolean).join(" ");function x(e){var r={left:0,top:0},n=u*function(t,e,r,n,i=0){var a,s=t.getContext();return s.save(),s.font=r,a=Gnt(s,e,n,t.get("textWrap"),i).length,s.restore(),a}(t,e,w,f,a);switch(v.style.height=n+"px",h){case"top":case"hanging":break;case"bottom":case"alphabetic":r.top=g-n;break;default:r.top=g/2-n/2}if(!i){var s=function(t,e,r,n){var i=e.split("\n"),a=n;let s=t.getContext();return s.save(),s.font=r,i.forEach((t=>{let e=s.measureText(t).width;e>a&&(a=e)})),s.restore(),a}(t,e,w,f);switch(v.style.width=s+"px",l){case"right":case"end":r.left=f-s;break;case"left":case"start":break;default:r.left=(f-s)/2}}v.style.marginLeft=r.left+"px",v.style.marginTop=r.top+"px",v.style.transform=`translate(${m.x}px, ${m.y}px) scale(${b}) rotate(${y}rad)`,v.style.transformOrigin=`${-r.left}px ${-r.top}px`}x(e);var A=t.root.target_element;A.appendChild(v),v.select();var _,k=!1;v.addEventListener("keydown",(function(t){t.stopPropagation(),"Escape"!=t.code&&(t.shiftKey||"Enter"!=t.code&&"NumpadEnter"!=t.code)?setTimeout((()=>{x(v.value)})):(k=_.skipUpdate="Escape"==t.code,document.createEvent?v.dispatchEvent(_):v.fireEvent(_.eventType,_))})),document.createEvent?(_=document.createEvent("HTMLEvents")).initEvent("blur",!0,!1):(_=document.createEventObject()).eventType="blur";var S=t.root.selected,E=function(r){t.root.selected=S,t.textHidden=!1,v.removeEventListener("blur",E,!1),v.parentElement&&v.parentElement.removeChild(v),A.focus(),r.skipUpdate||k||t.app.commander.execute(new rrt({changes:[{component:t,before:{text:e},after:{text:v.value}}]}))};v.addEventListener("blur",E,!1)}Xnt.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)&&($nt(i[0]),t.preventDefault(),!0))}}},"model-layer":{"(descendant)":{dblclick:function(t,e){$nt(e.origin)}}}});var Knt,Qnt,Jnt,Znt=s9((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);Xnt.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 s=i[0].transcoordC2S(t.offsetX,t.offsetY);if(s=i[0].transcoordS2P(s.x,s.y),this.last_pos=s,this.direction=0,n.focused=i[0].parent,t.altKey){var o=[],l=new Map;n.selected=n.selected.filter((t=>!t.isRootModel())).map((t=>{let e=yrt(t,(t=>{const e=n.root.getNewRefid();return void 0!==t&&l.set(t,e),e}));return o.push({component:e,to_container:t.parent}),e})).map((t=>(t.replaceRefids(l),t))),o.forEach((({component:t,to_container:e})=>{e.addComponent(t)})),this.duplicates=n.selected.map((t=>({component:t})))}else this.changes=rrt.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:s}=i[0].transcoordC2S(t.offsetX,t.offsetY),o=i[0].transcoordS2P(a,s);t.shiftKey?2==this.direction&&(this.direction=0):this.direction=2;var l=o.x-this.last_pos.x,h=o.y-this.last_pos.y;if(0==this.direction){if(l*l+h*h<25)return;Math.abs(l)>Math.abs(h)?this.direction=3:this.direction=4}3==this.direction?h=0:4==this.direction&&(l=0),i.forEach((t=>{t.move({x:l,y:h},1===i.length)})),this.last_pos=o,Znt(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,s=n.focused||e.deliverer;if(this.changes&&!s.isGroup())if(n.hasSameParentForAllSelected&&s&&s!==a){var o=this.changes.map((t=>{let{component:e,before:r}=t;return{component:e,to_container:s}}));n.app.commander.execute(new frt({changes:o}))}else rrt.after(this.changes,n.app.commander);else if(this.duplicates){this.duplicates=this.duplicates.map((t=>(t.to_container=s,t)));let t=new frt({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,Znt(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 s=n.selected;rrt.around(n.app.commander,(function(){s.forEach((t=>{!t.stuck&&t.move(i,!1)}))}))}}}});const tit=o9((()=>{const{x:t,y:e}=Jnt,r=Qnt.deref();r&&(r.rootModel.move({x:t-Knt.x,y:e-Knt.y},!1),Knt={x:t,y:e})}),60,{leading:!0,trailing:!0});Xnt.register("shift-handler",{"model-layer":{"(all)":{dragstart:function(t,e){Knt={x:t.offsetX,y:t.offsetY}},dragmove:function(t,e){Qnt=new WeakRef(e.deliverer),Jnt={x:t.offsetX,y:t.offsetY},tit()}}}}),Xnt.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"),s=t.offsetX,o=t.offsetY,l=r.transcoordC2S(s,o),h=.1*n,c={x:i.x+h,y:i.y+h};if(n<0&&i.x<.2||n>0&&i.x>10)return;r.set("scale",c);let u=r.transcoordC2S(s,o);r.set("translate",{x:a.x+(u.x-l.x)*c.x,y:a.y+(u.y-l.y)*c.y})}},"(self)":{dblclick:function(t,e){const r=e.origin;r?.root.fit()}}}});var eit={},rit={};function nit(t){const e={};for(const r in t)t.hasOwnProperty(r)&&void 0!==t[r]&&(e[r]=t[r]);return e}function iit(t,e,r){if("function"==typeof t?t===e:t.has(e))return arguments.length<3?e:r;throw new TypeError("Private element is not present on this object")}function ait(t,e,r,n,i,a,s){try{var o=t[a](s),l=o.value}catch(t){return void r(t)}o.done?e(l):Promise.resolve(l).then(n,i)}function sit(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var a=t.apply(e,r);function s(t){ait(a,n,i,s,o,"next",t)}function o(t){ait(a,n,i,s,o,"throw",t)}s(void 0)}))}}function oit(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")}function lit(t,e){return t.get(iit(t,e))}function hit(t,e,r){oit(t,e),e.set(t,r)}function cit(t,e,r){return t.set(iit(t,e),r),r}function uit(t,e,r){return r(iit(t,e))}function dit(t,e){oit(t,e),e.add(t)}function pit(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function fit(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function git(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?fit(Object(r),!0).forEach((function(e){pit(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):fit(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function vit(t,e,r){e||(e=[]);var n=e.length++;return Object.defineProperty({},"_",{set:function(i){e[n]=i,t.apply(r,e)}})}Xnt.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:s,lineDash:o,lineCap:l,lineJoin:h,fontColor:c,fontSize:u,fontFamily:d,bold:p,italic:f,textAlign:g,textBaseline:v,textOverflow:m,paddingTop:y,paddingBottom:b,paddingLeft:w,paddingRight:x}=t.state;eit=X7({fillStyle:e,strokeStyle:i,alpha:a,lineWidth:s,lineDash:o,lineCap:l,lineJoin:h,fontColor:c,fontSize:u,fontFamily:d,bold:p,italic:f,textAlign:g,textBaseline:v,textOverflow:m,paddingTop:y,paddingBottom:b,paddingLeft:w,paddingRight:x}),r.mode=4}},stylepastestop:function(t){const{deliverer:e}=t,r=e.app;eit={},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;rit=X7({mappings:e}),r.mode=5}},databindpastestop:function(t){const{deliverer:e}=t,r=e.app;rit={},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&&rrt.around(n.commander,(()=>{const t=nit({...i.model,...eit});i?.set(t)})):i===r?r.root.trigger("databindpastestop"):i&&rrt.around(n.commander,(()=>{const t=nit({...i.model,...rit});i?.set(t)}))}}}});class mit{constructor(t,e,r){pit(this,"_delta",{theta:0,tx:0,ty:0,sx:1,sy:1,fade:0}),pit(this,"_location",null);const{animations:n,...i}=r;this.overlay=t,this.target=e,this.decorator=i||{},this.animations=[],Array.isArray(n)?this.animations=n.map((t=>("theta"in t&&(t={...t,theta:t.theta*(Math.PI/180)}),b7(this,t)))):n&&("theta"in n&&(n={...n,theta:n.theta*(Math.PI/180)}),this.animations=[b7(this,n)])}delta(t,e){if(void 0===e)return t?this._delta[t]:this._delta;this._delta[t]=e;const{tx:r,ty:n,sx:i,sy:a,theta:s,fade:o}=this._delta;Object.assign(this.element.style,{opacity:1-o,transform:`rotate(${s}rad) translate(${r}px, ${n}px) scale(${i}, ${a}) perspective(1px)`})}get location(){if(this._location)return this._location;const{location:t,size:e}=this.decorator,{left:r,top:n,width:i,height:a}=this.target.bounds;let s;switch(t){case"top-left":s={x:r,y:n-e};break;case"top":s={x:r+(i-e)/2,y:n-e};break;case"top-right":s={x:r+i-e,y:n-e};break;case"bottom-left":s={x:r,y:n+a};break;case"bottom":s={x:r+(i-e)/2,y:n+a};break;case"bottom-right":s={x:r+i-e,y:n+a};break;case"left-top":s={x:r-e,y:n};break;case"left":s={x:r-e,y:n+(a-e)/2};break;case"left-bottom":s={x:r-e,y:n+(a-e)};break;case"right-top":s={x:r+i,y:n};break;case"right":s={x:r+i,y:n+(a-e)/2};break;case"right-bottom":s={x:r+i,y:n+(a-e)};break;case"top-left-corner":s={x:r-e/2,y:n-e/2};break;case"top-right-corner":s={x:r+i-e/2,y:n-e/2};break;case"bottom-left-corner":s={x:r-e/2,y:n+a-e/2};break;case"bottom-right-corner":s={x:r+i-e/2,y:n+a-e/2};break;default:s={x:r+i/2-e/2,y:n+a/2-e/2}}return this._location=this.target.transcoordS2T(s.x,s.y),this._location}get element(){if(!this._element){const{icon:t,size:e,color:r}=this.decorator,{x:n,y:i}=this.location,a=document.createElement("div");a.setAttribute("scene","animated-icon"),Object.assign(a.style,{position:"absolute",fontVariationSettings:"'FILL' 1",fontFamily:"Material Symbols Outlined",fontSize:e+"px",width:e+"px",height:e+"px",lineHeight:e+"px",padding:0,margin:0,color:r,textAlign:"center",verticalAlign:"middle",left:n+"px",top:i+"px",pointerEvents:"none"}),a.textContent=t,this._element=a}return this._element}touch(){}invalidate(){}start(){this.overlay.appendChild(this.element),this.animations.forEach((t=>t.start()))}stop(){this.overlay.removeChild(this.element),this.animations.forEach((t=>t.stop())),this._location=null}get root(){return this.target.root}get center(){const{size:t}=this.decorator,{x:e,y:r}=this.location;return{x:e+t/2,y:r+t/2}}transcoordS2T(t,e){const{tx:r,ty:n}=this._delta;return{x:t+r,y:e+n}}}class yit{static getTargetId(t){if(!yit._targetIdMap.has(t)){const e=`target-${Math.random().toString(36).substring(2,9)}`;yit._targetIdMap.set(t,e)}return yit._targetIdMap.get(t)}static getSvgContainer(t){if(!yit._svgMap.has(t)){const e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("class","border-highlighting-container"),e.setAttribute("pointer-events","none"),e.style.overflow="visible",e.style.position="absolute",e.style.top="0",e.style.left="0";const r=document.createElementNS("http://www.w3.org/2000/svg","defs");e.appendChild(r);const n=document.createElementNS("http://www.w3.org/2000/svg","g");n.setAttribute("class","border-highlighting-group"),e.appendChild(n),t.appendChild(e),yit._svgMap.set(t,e)}return yit._svgMap.get(t)}constructor(t,e,r){this.overlayRef=new WeakRef(t),this.target=e,this.decorator=r}get element(){const t=this.overlayRef.deref();if(!t)return null;const{distance:e=10,lineWidth:r=2,color:n="red",animation:i=!1,fillStyle:a}=this.decorator||{},{round:s=0,fillStyle:o}=this.target.state,l=this.target.path.map((t=>this.target.transcoordS2T(t.x,t.y))),h=this.createOffsetPath(l,e),c=this.pointsToPathData(h,s),u=yit.getSvgContainer(t),d=yit.getTargetId(this.target),p=u.querySelector(".border-highlighting-group"),f=p.querySelector(`[data-target-id="${d}"]`);f&&f.remove();const g=document.createElementNS("http://www.w3.org/2000/svg","path");g.setAttribute("d",c),g.setAttribute("fill","none"),g.setAttribute("stroke-width",r),g.setAttribute("stroke-linejoin","round"),g.setAttribute("pointer-events","none"),g.setAttribute("data-target-id",d);const v=a||o||"rgba(0, 0, 0, 0.5)",m=u.querySelector("defs"),y=this.createFilter(d,v);if(m.appendChild(y),g.setAttribute("filter",`url(#${d}-filter)`),i){const t=u.querySelector("defs"),e=this.createGradient(d,n);t.appendChild(e),g.setAttribute("stroke",`url(#${d})`)}else g.setAttribute("stroke",n);return p.appendChild(g),g}createOffsetPath(t,e){const r=[],n=t.length;for(let i=0;i<n;i++){const a=t[(i-1+n)%n],s=t[i],o=t[(i+1)%n],l=s.x-a.x,h=s.y-a.y,c=o.x-s.x,u=o.y-s.y,d=this.normalize({x:h,y:-l}),p=this.normalize({x:u,y:-c}),f=this.normalize({x:(d.x+p.x)/2,y:(d.y+p.y)/2}),g={x:s.x+f.x*e,y:s.y+f.y*e};r.push(g)}return r}normalize(t){const e=Math.sqrt(t.x*t.x+t.y*t.y);return{x:t.x/e,y:t.y/e}}pointsToPathData(t,e=0){if(t.length<2)return"";let r="";const n=t.length,i=(t,e,r)=>{const n=e.x-t.x,i=e.y-t.y,a=Math.sqrt(n*n+i*i);return{x:t.x+n/a*r,y:t.y+i/a*r}};for(let a=0;a<n;a++){const s=t[a],o=t[(a+1)%n],l=t[(a-1+n)%n],h=Math.sqrt((s.x-l.x)**2+(s.y-l.y)**2),c=Math.sqrt((s.x-o.x)**2+(s.y-o.y)**2),u=Math.min(e,h/2,c/2),d=i(s,l,u),p=i(s,o,u);r+=0===a?`M${d.x},${d.y}`:` L${d.x},${d.y}`,r+=` Q${s.x},${s.y} ${p.x},${p.y}`}return r+=" Z",r}createFilter(t,e){const r=document.createElementNS("http://www.w3.org/2000/svg","filter");r.setAttribute("id",`${t}-filter`);const n=document.createElementNS("http://www.w3.org/2000/svg","feFlood");n.setAttribute("flood-color",e),n.setAttribute("result","flood");const i=document.createElementNS("http://www.w3.org/2000/svg","feComposite");i.setAttribute("in","flood"),i.setAttribute("in2","SourceAlpha"),i.setAttribute("operator","in"),i.setAttribute("result","mask");const a=document.createElementNS("http://www.w3.org/2000/svg","feMerge"),s=document.createElementNS("http://www.w3.org/2000/svg","feMergeNode");s.setAttribute("in","mask");const o=document.createElementNS("http://www.w3.org/2000/svg","feMergeNode");return o.setAttribute("in","SourceGraphic"),a.appendChild(s),a.appendChild(o),r.appendChild(n),r.appendChild(i),r.appendChild(a),r}createGradient(t,e){const r=document.createElementNS("http://www.w3.org/2000/svg","linearGradient");r.setAttribute("id",t),r.setAttribute("x1","0%"),r.setAttribute("y1","0%"),r.setAttribute("x2","100%"),r.setAttribute("y2","0%");const n=this.alterColor(e,120),i=this.alterColor(e,240);return r.innerHTML=`\n <stop offset="0%" stop-color="${e}">\n <animate attributeName="stop-color" values="${e};${n};${i};${e}" dur="5s" repeatCount="indefinite" />\n </stop>\n <stop offset="100%" stop-color="${i}">\n <animate attributeName="stop-color" values="${i};${e};${n};${i}" dur="5s" repeatCount="indefinite" />\n </stop>\n `,r}alterColor(t,e){const r=this.convertToHex(t);let n=parseInt(r.substring(1,3),16),i=parseInt(r.substring(3,5),16),a=parseInt(r.substring(5,7),16);const s=this.rgbToHsl(n,i,a);s[0]=(s[0]+e/360)%1;const o=this.hslToRgb(s[0],s[1],s[2]);return`#${o[0].toString(16).padStart(2,"0")}${o[1].toString(16).padStart(2,"0")}${o[2].toString(16).padStart(2,"0")}`}rgbToHsl(t,e,r){t/=255,e/=255,r/=255;let n,i,a=Math.max(t,e,r),s=Math.min(t,e,r),o=(a+s)/2;if(a===s)n=i=0;else{let l=a-s;switch(i=o>.5?l/(2-a-s):l/(a+s),a){case t:n=(e-r)/l+(e<r?6:0);break;case e:n=(r-t)/l+2;break;case r:n=(t-e)/l+4}n/=6}return[n,i,o]}hslToRgb(t,e,r){let n,i,a;if(0===e)n=i=a=r;else{const s=(t,e,r)=>(r<0&&(r+=1),r>1&&(r-=1),r<1/6?t+6*(e-t)*r:r<.5?e:r<2/3?t+(e-t)*(2/3-r)*6:t);let o=r<.5?r*(1+e):r+e-r*e,l=2*r-o;n=s(l,o,t+1/3),i=s(l,o,t),a=s(l,o,t-1/3)}return[Math.round(255*n),Math.round(255*i),Math.round(255*a)]}convertToHex(t){if(/^#([0-9A-F]{6})$/i.test(t))return t;const e=document.createElement("div");e.style.color=t,document.body.appendChild(e);const r=window.getComputedStyle(e).color;document.body.removeChild(e);const n=r.match(/\d+/g);return!n||n.length<3?(console.warn(`Invalid color: ${t}. Defaulting to #FF0000.`),"#FF0000"):`#${n.slice(0,3).map((t=>parseInt(t,10).toString(16).padStart(2,"0"))).join("")}`}start(){const t=this.overlayRef.deref();if(!t)return;const e=yit.getSvgContainer(t);t.contains(e)||t.appendChild(e);const r=this.element;if(r&&this.decorator.animation){const t=r.getAttribute("data-target-id");if(!t)return;const n=e.querySelector("defs");if(!n)return;const i=n.querySelector(`#${t}`);if(!i)return;requestAnimationFrame((()=>{i.querySelectorAll("animate").forEach((t=>{t.beginElement()}))}))}}stop(){if(!this.element)return;const t=this.overlayRef.deref();if(!t)return;const e=yit._svgMap.get(t);if(!e)return;const r=e.querySelector(".border-highlighting-group");if(!r)return;const n=e.querySelector("defs");if(!n)return;const i=yit.getTargetId(this.target),a=r.querySelector(`[data-target-id="${i}"]`);if(a){r.removeChild(a),a.remove();const t=n.querySelector(`#${i}`);t&&(n.removeChild(t),t.remove())}yit._targetIdMap.delete(this.target),0===r.children.length&&(e.remove(),yit._svgMap.delete(t))}}pit(yit,"_svgMap",new WeakMap),pit(yit,"_targetIdMap",new WeakMap);class bit{static getArrowId(t){if(!bit._arrowIdMap.has(t)){const e=`${Math.random().toString(36).substring(2,9)}`;bit._arrowIdMap.set(t,e)}return bit._arrowIdMap.get(t)}static getSvgContainer(t){if(!bit._svgMap.has(t)){const e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("class","bouncing-arrow-container"),e.setAttribute("pointer-events","none"),e.style.overflow="visible",e.style.position="absolute",e.style.top="0",e.style.left="0";const r=document.createElementNS("http://www.w3.org/2000/svg","g");r.setAttribute("class","bouncing-arrow-group"),e.appendChild(r),t.appendChild(e),bit._svgMap.set(t,e)}return bit._svgMap.get(t)}constructor(t,e,r){this.overlayRef=new WeakRef(t),this.target=e,this.decorator=r}get element(){const t=this.overlayRef.deref();if(!t)return null;const e=bit.getSvgContainer(t).querySelector(".bouncing-arrow-group"),r=bit.getArrowId(this.target),n=e.querySelector(`[data-arrow-id="${r}"]`);n&&n.remove();let{left:i,top:a,width:s}=this.target.bounds,{x:o,y:l}=this.target.transcoordS2T(i+s/2,a);o=Math.max(o,20),l=Math.max(l,20);const{color:h="red",duration:c=5e3,repeat:u=!0}=this.decorator||{},d=document.createElementNS("http://www.w3.org/2000/svg","path");d.setAttribute("d",this.createArrowPath(o,l)),d.setAttribute("fill",h),d.setAttribute("data-arrow-id",r),d.appendChild(this.createBounceAnimation(r,c,u)),e.appendChild(d);const p=this.createArrowLabel(o,l,h,this.target.state.id,r);return p&&(p.appendChild(this.createBounceAnimation(r,c,u)),e.appendChild(p)),d}createArrowPath(t,e){return`\n M${t-10},${e-16} \n L${t+10},${e-16} \n L${t+10},${e-8} \n L${t+16},${e-8} \n L${t},${e} \n L${t-16},${e-8} \n L${t-10},${e-8} \n Z\n `}createBounceAnimation(t,e,r){const n=document.createElementNS("http://www.w3.org/2000/svg","animateTransform");n.setAttribute("id",t),n.setAttribute("attributeName","transform"),n.setAttribute("type","translate");const i=e||5e3;let a=["0,-10"],s=[0];for(let t=1;t<=20;t++){const e=t/20;let r=Math.pow(e,.5);if(r=Math.min(r,.99).toFixed(3),parseFloat(s[s.length-1])>=parseFloat(r)&&(r=(parseFloat(s[s.length-1])+.01).toFixed(3)),a.push("0,0"),a.push("0,-10"),r>=1){s.push(1),s.push((parseFloat(1)+.01).toFixed(3));break}s.push(r),s.push((parseFloat(r)+.01).toFixed(3))}return s[s.length-1]="1.000",n.setAttribute("values",a.join(";")),n.setAttribute("keyTimes",s.join(";")),n.setAttribute("dur",`${i}ms`),r?n.setAttribute("repeatCount","indefinite"):(n.setAttribute("repeatCount","1"),n.addEventListener("endEvent",(()=>this.stop()))),n}createArrowLabel(t,e,r,n,i){if(!n)return null;const a=document.createElementNS("http://www.w3.org/2000/svg","g");a.setAttribute("data-arrow-label",i);const s=document.createElementNS("http://www.w3.org/2000/svg","rect");s.setAttribute("x",t+20),s.setAttribute("y",e-20),s.setAttribute("width","40"),s.setAttribute("height","20"),s.setAttribute("rx","3"),s.setAttribute("fill",r);const o=document.createElementNS("http://www.w3.org/2000/svg","text");return o.setAttribute("x",t+40),o.setAttribute("y",e-6),o.setAttribute("fill","white"),o.setAttribute("font-size","12px"),o.setAttribute("text-anchor","middle"),o.textContent=n,a.appendChild(s),a.appendChild(o),a}start(){const t=this.overlayRef.deref();if(!t)return;const e=bit.getSvgContainer(t),r=this.element;if(!r)return;const n=r.querySelector("animateTransform");n&&n.beginElement();const i=e.querySelector(`[data-arrow-label="${bit.getArrowId(this.target)}"]`);if(i){const t=i.querySelector("animateTransform");t&&t.beginElement()}}stop(){const t=this.overlayRef.deref();if(!t)return;const e=bit._svgMap.get(t);if(!e)return;const r=e.querySelector(".bouncing-arrow-group");if(!r)return;const n=bit.getArrowId(this.target),i=r.querySelector(`[data-arrow-id="${n}"]`),a=r.querySelector(`[data-arrow-label="${n}"]`);i&&(r.removeChild(i),i.remove()),a&&(r.removeChild(a),a.remove()),0===r.children.length&&(e.remove(),bit._svgMap.delete(t))}}pit(bit,"_svgMap",new WeakMap),pit(bit,"_arrowIdMap",new WeakMap);class wit{icon(t,e){if(this.targets&&-1!==this.targets.lastIndexOf(t))return;const r=new mit(t.root.model_layer.overlay,t,e);this.targets=(this.targets||[]).concat(t),this.animators=(this.animators||[]).concat(r),r.start()}border(t,e){if(this.targets&&-1!==this.targets.lastIndexOf(t))return;const r=new yit(t.root.model_layer.overlay,t,e);this.targets=(this.targets||[]).concat(t),this.animators=(this.animators||[]).concat(r),r.start()}bouncing(t,e){if(this.targets&&-1!==this.targets.lastIndexOf(t))return;const r=new bit(t.root.model_layer.overlay,t,e);this.targets=(this.targets||[]).concat(t),this.animators=(this.animators||[]).concat(r),r.start()}off(t){if(!this.targets)return;let e=this.targets.slice(),r=this.animators.slice(),n=this.targets.lastIndexOf(t);if(-1==n)return;e.splice(n,1);const i=r.splice(n,1);i[0]?.stop(),this.targets=e,this.animators=r}reset(t){this.animators?.forEach((t=>t.stop())),this.targets=[],this.animators=[]}}function xit(t){const{origin:e}=t,r=e.root,{animatorHandler:n}=r;n?.reset()}Xnt.register("animator-handler",{"model-layer":{"(descendant)":{icon:function(t,e){const{origin:r}=e,n=r.root;let{animatorHandler:i}=n;i||(i=new wit,n.animatorHandler=i),i.icon(r,t)},border:function(t,e){const{origin:r}=e,n=r.root;let{animatorHandler:i}=n;i||(i=new wit,n.animatorHandler=i),i.border(r,t)},bouncing:function(t,e){const{origin:r}=e,n=r.root;let{animatorHandler:i}=n;i||(i=new wit,n.animatorHandler=i),i.bouncing(r,t)},animatoroff:function(t){const{origin:e}=t,r=e.root,{animatorHandler:n}=r;n?n.off(e):console.warn("animator-handler not found")},animatorreset:xit},"(self)":{animatorreset:xit}}},(function(t){const{animatorHandler:e}=t;e?.reset(),delete t.animatorHandler}));var Ait=[],_it=s9((function(){Ait.forEach((t=>{t.resize()}))}),100);"undefined"!=typeof window&&window.addEventListener("resize",_it);class kit extends Iet{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),Ait.push(this)}dispose(){yet.hideAll(this),this._app&&this._app.dispose(),super.dispose(),this._disposeAllResources(),this.target_element=null,delete this._refresh_mapping_debouncer;var t=Ait.indexOf(this);t>=0&&Ait.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.setAttribute("root-element",""),t.style.position="absolute",t.style.cursor="default",t.style.overflow="hidden",this._ua_event_handler=new Unt(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&&M9("Template replaced (duplicated)",t,e,r),this.templateMap[t]=e,delete this.templatePrefixes}removeTemplate(t,e){var r=this.templateMap[t];r!==e?T9("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?T9("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&&M9("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?M9("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(X7(e.hierarchy),{id:t,templatePrefix:""});return component=mrt(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.model.handlers||[]).map((t=>{Xnt.getDisposer(t).call(null,this)})),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 Pnt(this),(t=t||{}).type="model-layer",this.model_layer=mrt(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=mrt(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,Xnt.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=s9((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=f9({},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(kit.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,s=r.clientHeight;e.set("scale",{x:a/n,y:s/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,s=r.clientHeight,o=a/n,l=s/i,h=Math.min(o,l);e.set("scale",{x:h,y:h}),e.set("translate",{x:(a-n*h)/2,y:(s-i*h)/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()}}}),ret.memoize(kit.prototype,"unitScale",!1);var Sit=13.3,Eit=function(t){return void 0!==t&&(Sit=t),Sit};const Mit="$base_url";const Tit=Math.PI/12;class Cit{constructor(t,e){this._mode=t,this.screen=Eit(),this._baseUrl="undefined"!=typeof window?window.location.origin:null,this._refProvider=e,this.isEditMode&&(this._rotateStep=Tit,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 z9}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(Mit)?new URL(t.replace(Mit,this.baseUrl),this.baseUrl):new URL(t,location.origin)).href}catch(e){T9(e,t)}}get rotateStep(){return this._rotateStep}set rotateStep(t){this._rotateStep=Number(t)||Tit}get rotateStepForced(){return this._rotateStepForced}set rotateStepForced(t){this._rotateStepForced=!!t}get dataStorage(){return this._dataStorage}set dataStorage(t){this._dataStorage=t}}E9(Cit.prototype,x9.withEvent);class Pit{constructor(t,e){!(t=Number(t))||t<=0?(M9("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];T9("Not forwardable.")}backward(){if(this.snapshot_taker&&this.snapshot_taker.take(),this.backwardable)return this.q[--this.pos];T9("Not backwardable.")}get current(){if(-1!==this.pos)return this.q[this.pos];T9("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 Iit=s9((t=>{t.brake||t.take()}),1e3,{leading:!0,trailing:!1});function Rit(t){!t.brake&&t.dirty&&Iit(t)}class Oit{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,Rit(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,Rit(this)}}function Lit(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 Dit{constructor(t){this.container=t,this.timecapsule=new Pit(20);var e=this;this.snapshot_taker=new Oit({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&&(Lit(this.timecapsule.backward(),this.container),this.trigger("undo",this.undoable(),this.redoable()))}redo(){this.timecapsule.forwardable&&(Lit(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")}}E9(Dit.prototype,x9.withEvent);var Fit=0;const Nit=new FinalizationRegistry((t=>{Fit--}));class jit{static get residents(){return Fit}static get residentsCount(){return Fit}constructor(t){this._container=t,this.app=t.app,this._commander=new Dit(this._container),this.app.commander=this._commander,Fit++,Nit.register(this,Fit)}add(){return wrt.apply(this._container,arguments)}duplicate(){return xrt.apply(this._container,arguments)}remove(){return Art.apply(this._container,arguments)}animate(){return w7.apply(this,arguments)}fullscreen(){return Ert.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 z9}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 Crt.apply(this._container,arguments)}copy(){return Trt.apply(this._container,arguments)}paste(){return Prt.apply(this._container,arguments)}undoableChange(){return $rt.apply(this._container,arguments)}change(){return Xrt.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)}findAllById(){return this._container.findAllById.apply(this._container,arguments)}serialize(){return this.root.trim(),this.root.serialize.apply(this.root,arguments)}align(){return hrt.apply(this._container,arguments)}place(){return nnt.apply(this._container,arguments)}distribute(){return drt.apply(this._container,arguments)}move(){return grt.apply(this._container,arguments)}zorder(){return vrt.apply(this._container,arguments)}symmetryX(){return Vrt.apply(this._container,arguments)}symmetryY(){return qrt.apply(this._container,arguments)}on(){return _rt.apply(this._container,arguments)}once(){return krt.apply(this._container,arguments)}off(){return this._container&&Srt.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 Wrt.apply(this._container,arguments)}group(){return Urt.apply(this._container,arguments)}ungroup(){return Hrt.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 Krt.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 int.apply(this._container,arguments)}startStylePasteMode(){return ant.apply(this._container,arguments)}stopStylePasteMode(){return snt.apply(this._container,arguments)}startDatabindPasteMode(){return ont.apply(this._container,arguments)}stopDatabindPasteMode(){return lnt.apply(this._container,arguments)}}const Bit=new class{load(t){}save(t,e){}clear(t){}};function zit({target:t,model:e,style:r,layers:n=[],handlers:i=[],mode:a=0,refProvider:s,dataSubscriptionProvider:o,dataStorage:l=Bit,baseUrl:h,fitMode:c}){var u=null;if("string"==typeof t){if(!(u=document.getElementById(t)))throw`target element '${t}' is not exist`;if(u.firstChild)throw`target element '${t}' is not empty`}else u=t;u&&u.style&&(u.style.position="absolute",u.style.cursor="default",u.style.overflow="hidden");var d=new Cit(a,s);return d.baseUrl=h,d.dataSubscriptionProvider=o,d.dataStorage=l,new jit(new kit({target_element:u,model:e,style:r,layers:n,handlers:i,fitMode:c},d))}
|
|
7
7
|
/**
|
|
8
8
|
* @license
|
|
9
9
|
* Copyright 2019 Google LLC
|
|
@@ -20,15 +20,15 @@ var dat=globalThis,pat=dat.trustedTypes,fat=pat?pat.createPolicy("lit-html",{cre
|
|
|
20
20
|
* Copyright 2017 Google LLC
|
|
21
21
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
22
22
|
*/
|
|
23
|
-
class Qat extends uat{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var t,e,r=super.createRenderRoot();return null!==(e=(t=this.renderOptions).renderBefore)&&void 0!==e||(t.renderBefore=r.firstChild),r}update(t){var e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=Kat(e,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),null===(t=this._$Do)||void 0===t||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),null===(t=this._$Do)||void 0===t||t.setConnected(!1)}render(){return Rat}}Qat._$litElement$=!0,Qat.finalized=!0,null===(Xat=globalThis.litElementHydrateSupport)||void 0===Xat||Xat.call(globalThis,{LitElement:Qat});var Jat=globalThis.litElementPolyfillSupport;null==Jat||Jat({LitElement:Qat}),(null!==($at=globalThis.litElementVersions)&&void 0!==$at?$at:globalThis.litElementVersions=[]).push("4.1.1");const Zat=["mousemove","mouseup","mousedown","mouseout","wheel","tap","click","touchstart","touchmove","touchend","mouseenter","mouseleave","dragstart","dragmove","dragend","dblclick"];var tst=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),Zat.forEach((t=>{this.element.addEventListener(t,this.userInputEventHandler.bind(this))})),U9.forEach((t=>{this.element.addEventListener(t,this.userInputEventHandler.bind(this))})),this.oncreate_element&&this.oncreate_element(this.element))}userInputEventHandler(t){Wnt(this,t.type,t),t.stopPropagation()}reposition(){this.element&&Dtt(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}get hidden(){return super.hidden}set hidden(t){super.hidden=t,this.element.style.display=t?"none":"block"}onchange(t,e){this.element&&this.setElementProperties(this.element),this.reposition()}isDescendible(t){return t.isHTMLElement()}};const est={x:1,y:1},rst={boxSizing:"border-box",margin:"0px",position:"absolute",outline:"none"},nst={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"layout",label:"layout",name:"layoutOption"},{type:"checkbox",label:"closable",name:"closable"},{type:"checkbox",label:"draggable",name:"draggable"},{type:"checkbox",label:"minimizable",name:"minimizable"},{type:"checkbox",label:"minimized",name:"minimized"}],help:"scene/component/container"};class ist extends(tst(Iet)){constructor(...t){super(...t),pit(this,"startDragging",(t=>{if(!this.state.draggable)return;t.preventDefault(),t.stopPropagation();let e=t.clientX,r=t.clientY;const{left:n,top:i}=this.bounds,a=this.rootModel.overlay.style.transform.match(/scale\(([^,]+),\s*([^)]+)\)/),s=a?parseFloat(a[1]):1,o=a?parseFloat(a[2]):s,l=t=>{t.preventDefault(),t.stopPropagation();const a=(t.clientX-e)/s,l=(t.clientY-r)/o;this.setState({left:n+a,top:i+l})},h=t=>{t.preventDefault(),t.stopPropagation(),document.removeEventListener("mousemove",l,!0),document.removeEventListener("mouseup",h,!0)};document.addEventListener("mousemove",l,!0),document.addEventListener("mouseup",h,!0)})),pit(this,"toggleMinimizable",(()=>{const{minimized:t}=this.state;this.setState("minimized",!t)})),pit(this,"closeContainer",(()=>{this.setState("hidden",!0)}))}get tagName(){return"div"}get nature(){return nst}setElementProperties(t){}get layout(){return det.get(this.get("layout"))||pet}reposition(){if(this.element){var t=this,{id:e,class:r,scale:n=est}=t.state,{rotation:i=0,hidden:a}=t,{left:s,top:o,width:l,height:h}=t.bounds,c=l/2,u=h/2,d=t.element;d.hidden=a,e&&(d.id=e),r&&(d.className=r),Object.assign(d.style,rst,{left:s+"px",top:o+"px",width:"0px",height:"0px",backgroundColor:"transparent"});var p=t.delta(),f=(n&&n.x||1)*p.sx,g=(n&&n.y||1)*p.sy,v=(i||0)+p.theta,m=p.tx||0,y=p.ty||0;d.style.transform=`translate(${m+c}px, ${y+u}px) rotate(${v}rad) translate(${-c}px, ${-u}px) scale(${f}, ${g}) perspective(1px)`}}set path(t){const{minimized:e}=this.state;var r=t[0],n=t[2];e?this.set({left:r.x,top:r.y,width:n.x-r.x}):this.set({left:r.x,top:r.y,width:n.x-r.x,height:n.y-r.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 bounds(){const{left:t=0,top:e=0,width:r=0,height:n=0}=this.state;return{left:t,top:e,width:r,height:n}}set bounds(t){const{minimized:e}=this.state,{left:r=0,top:n=0,width:i=0,height:a=0}=t;e?this.set({left:r,top:n,width:i}):this.set({left:r,top:n,width:i,height:a})}onchange(t,e){super.onchange(t,e),("draggable"in t||"minimizable"in t||"closable"in t||"minimized"in t||"width"in t||"height"in t)&&this.onchangeButtons(),"minimized"in t&&this.onchangeMinimized()}createElement(){super.createElement(),this.onchangeButtons(),this.onchangeMinimized()}onchangeButtons(){const{draggable:t,minimizable:e,closable:r,minimized:n}=this.state,{width:i}=this.bounds;Kat(Iat`
|
|
23
|
+
class Qat extends uat{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var t,e,r=super.createRenderRoot();return null!==(e=(t=this.renderOptions).renderBefore)&&void 0!==e||(t.renderBefore=r.firstChild),r}update(t){var e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=Kat(e,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),null===(t=this._$Do)||void 0===t||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),null===(t=this._$Do)||void 0===t||t.setConnected(!1)}render(){return Rat}}Qat._$litElement$=!0,Qat.finalized=!0,null===(Xat=globalThis.litElementHydrateSupport)||void 0===Xat||Xat.call(globalThis,{LitElement:Qat});var Jat=globalThis.litElementPolyfillSupport;null==Jat||Jat({LitElement:Qat}),(null!==($at=globalThis.litElementVersions)&&void 0!==$at?$at:globalThis.litElementVersions=[]).push("4.1.1");const Zat=["mousemove","mouseup","mousedown","mouseout","wheel","tap","click","touchstart","touchmove","touchend","mouseenter","mouseleave","dragstart","dragmove","dragend","dblclick"];var tst=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),Zat.forEach((t=>{this.element.addEventListener(t,this.userInputEventHandler.bind(this))})),U9.forEach((t=>{this.element.addEventListener(t,this.userInputEventHandler.bind(this))})),this.oncreate_element&&this.oncreate_element(this.element))}userInputEventHandler(t){Wnt(this,t.type,t),t.stopPropagation()}reposition(){this.element&&Dtt(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}get hidden(){return super.hidden}set hidden(t){super.hidden=t,this.element.style.display=t?"none":"block"}onchange(t,e){this.element&&this.setElementProperties(this.element),this.reposition()}isDescendible(t){return t.isHTMLElement()}};const est={x:1,y:1},rst={boxSizing:"border-box",margin:"0px",position:"absolute",outline:"none"},nst={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"layout",label:"layout",name:"layoutOption"},{type:"checkbox",label:"closable",name:"closable"},{type:"checkbox",label:"draggable",name:"draggable"},{type:"checkbox",label:"minimizable",name:"minimizable"},{type:"checkbox",label:"minimized",name:"minimized"}],help:"scene/component/container"};class ist extends(tst(Iet)){constructor(...t){super(...t),pit(this,"startDragging",(t=>{if(!this.state.draggable)return;t.preventDefault(),t.stopPropagation();let e=t.clientX,r=t.clientY;const{left:n,top:i}=this.bounds,a=this.rootModel.overlay.style.transform.match(/scale\(([^,]+),\s*([^)]+)\)/),s=a?parseFloat(a[1]):1,o=a?parseFloat(a[2]):s,l=t=>{t.preventDefault(),t.stopPropagation();const a=(t.clientX-e)/s,l=(t.clientY-r)/o;this.setState({left:n+a,top:i+l})},h=t=>{t.preventDefault(),t.stopPropagation(),document.removeEventListener("mousemove",l,!0),document.removeEventListener("mouseup",h,!0)};document.addEventListener("mousemove",l,!0),document.addEventListener("mouseup",h,!0)})),pit(this,"toggleMinimizable",(()=>{const{minimized:t}=this.state;this.setState("minimized",!t)})),pit(this,"closeContainer",(()=>{this.setState("hidden",!0)}))}get tagName(){return"div"}get nature(){return nst}setElementProperties(t){}get layout(){return det.get(this.get("layout"))||pet}reposition(){if(this.element){var t=this,{id:e,class:r,scale:n=est}=t.state,{rotation:i=0,hidden:a}=t,{left:s,top:o,width:l,height:h}=t.bounds,c=l/2,u=h/2,d=t.element;d.hidden=a,e&&(d.id=e),r&&(d.className=r),Object.assign(d.style,rst,{left:s+"px",top:o+"px",width:"0px",height:"0px",backgroundColor:"transparent"});var p=t.delta(),f=(n&&n.x||1)*p.sx,g=(n&&n.y||1)*p.sy,v=(i||0)+p.theta,m=p.tx||0,y=p.ty||0;d.style.transform=`translate(${m+c}px, ${y+u}px) rotate(${v}rad) translate(${-c}px, ${-u}px) scale(${f}, ${g}) perspective(1px)`}}set path(t){const{minimized:e}=this.state;var r=t[0],n=t[2];e?this.set({left:r.x,top:r.y,width:n.x-r.x}):this.set({left:r.x,top:r.y,width:n.x-r.x,height:n.y-r.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 bounds(){const{left:t=0,top:e=0,width:r=0,height:n=0}=this.state;return{left:t,top:e,width:r,height:n}}set bounds(t){const{minimized:e}=this.state,{left:r=0,top:n=0,width:i=0,height:a=0}=t;e?this.set({left:r,top:n,width:i}):this.set({left:r,top:n,width:i,height:a})}onchange(t,e){super.onchange(t,e),("draggable"in t||"minimizable"in t||"closable"in t||"minimized"in t||"width"in t||"height"in t)&&this.onchangeButtons(),"minimized"in t&&this.onchangeMinimized()}createElement(){super.createElement(),this.onchangeButtons(),this.onchangeMinimized()}onchangeButtons(){if(!this.element)return;console.log("element",this.getState("id"));const{draggable:t,minimizable:e,closable:r,minimized:n}=this.state,{width:i}=this.bounds;this.element.style.setProperty("--container-width",`${i}px`),Kat(Iat`
|
|
24
24
|
<style>
|
|
25
25
|
.buttons {
|
|
26
26
|
position: absolute;
|
|
27
27
|
display: flex;
|
|
28
28
|
flex-direction: row;
|
|
29
|
-
width: ${i}px;
|
|
30
29
|
top: 0;
|
|
31
30
|
left: 0;
|
|
31
|
+
width: var(--container-width);
|
|
32
32
|
padding: 2px;
|
|
33
33
|
margin: 0;
|
|
34
34
|
gap: 2px;
|
|
@@ -45,13 +45,13 @@ class Qat extends uat{constructor(){super(...arguments),this.renderOptions={host
|
|
|
45
45
|
border: none;
|
|
46
46
|
cursor: pointer;
|
|
47
47
|
font-family: Material Symbols Outlined;
|
|
48
|
-
font-size:
|
|
48
|
+
font-size: 16px;
|
|
49
49
|
border-radius: 4px;
|
|
50
50
|
color: white;
|
|
51
51
|
background-color: black;
|
|
52
52
|
opacity: 0.3;
|
|
53
|
-
width:
|
|
54
|
-
height:
|
|
53
|
+
width: 20px;
|
|
54
|
+
height: 20px;
|
|
55
55
|
z-index: 1;
|
|
56
56
|
padding: 0;
|
|
57
57
|
margin: 0;
|
|
@@ -59,6 +59,7 @@ class Qat extends uat{constructor(){super(...arguments),this.renderOptions={host
|
|
|
59
59
|
text-align: center;
|
|
60
60
|
}
|
|
61
61
|
</style>
|
|
62
|
+
|
|
62
63
|
<div class="buttons" @mousedown=${this.startDragging}>
|
|
63
64
|
<span></span>
|
|
64
65
|
${t?Iat`<button class="draggable">drag_pan</button>`:Oat}
|
|
@@ -67,7 +68,7 @@ class Qat extends uat{constructor(){super(...arguments),this.renderOptions={host
|
|
|
67
68
|
</button>`:Oat}
|
|
68
69
|
${r?Iat`<button class="closable" @click=${this.closeContainer}>close</button>`:Oat}
|
|
69
70
|
</div>
|
|
70
|
-
`,this.element)}onchangeMinimized(){const{minimized:t}=this.state;t?this.setState("height",20):this.setState("height",this.get("height"))}}ret.register("container",ist);const ast=Math.sqrt(3),sst=2;function ost(t,e,r,n,i){var a,s,o,l,h=5+i,c=r.x,u=r.y,d=n.x,p=n.y;if(Math.abs(c-d)>h&&Math.abs(u-p)>h){var f=(p-u)/(d-c),g=u-f*c;if(Math.abs(e-(f*t+g))>h)return!1}return c>d?(s=c,a=d):(s=d,a=c),u>p?(l=u,o=p):(l=p,o=u),!(s+5<t)&&(!(a-5>t)&&(!(l+5<e)&&!(o-5>e)))}function lst(t,e,r,n=2){for(let i=0;i<r.length-1;i++)if(ost(t,e,r[i],r[i+1],n))return!0;return!1}function hst(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 cst(t,e,r){var{lineWidth:n=sst,strokeStyle:i="#000000",lineCap:a=!1,alpha:s=1,begin:o="none",end:l="none",beginSize:h="size5",endSize:c="size5"}=r;if(("none"!=o||"none"!=l)&&(n=Number(n)||sst,t.lineCap=a,t.lineWidth=n,t.strokeStyle=i,t.fillStyle=i,t.globalAlpha*=s,"none"!=o&&ust(t,e[0],e[1],n,o,dst(h,n)),"none"!=l)){let r=e.length;ust(t,e[r-1],e[r-2],n,l,dst(c,n))}}function ust(t,e,r,n,i,a){var{x:s,y:o}=e,l=Math.atan2(r.y-o,r.x-s);switch(t.beginPath(),t.translate(s,o),t.rotate(l),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(ast*a.X,-a.Y),t.lineTo(ast*a.X,a.Y),t.fill();break;case"sharp-arrow":t.moveTo(0,0),t.lineTo(ast*a.X,-a.Y),t.lineTo(-a.X/1.5+ast*a.X,0),t.lineTo(ast*a.X,a.Y),t.fill();break;case"open-arrow":t.moveTo(ast*a.X+n,-a.Y),t.lineTo(n,0),t.lineTo(ast*a.X+n,a.Y),t.stroke()}t.rotate(-l),t.translate(-s,-o),t.closePath()}function dst(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 pst="N",fst="S",gst="E",vst="W";class mst{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 gst;const r=e.position;return r.y<=t.top?pst:r.y>=t.top+t.height?fst:r.x<=t.left?vst:gst}get boundaryPosition(){const t=this.anchor;if(t){var{position:e}=t,r=0,n=0;switch(this.direction){case fst:n=20;break;case pst:n=-20;break;case vst: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 yst extends ret{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 mst({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 mst({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;cst(t,a,this.state),t.beginPath();var s=hst(e,n,a[0],a[1]),o=hst(r,n,a[a.length-1],a[a.length-2]);a=[s,...a.slice(1,-1),o];var l={x:s.x,y:s.y};t.moveTo(s.x,s.y);for(var h=1;h<a.length;h++){const e=l;l=a[h];const r=a[h+1];if(e.x===l.x&&e.y===l.y)continue;if(!r){t.lineTo(l.x,l.y);break}var c=0!==(p=Math.sqrt((e.x-l.x)*(e.x-l.x)+(e.y-l.y)*(e.y-l.y)))?Math.atan2(e.x-l.x,e.y-l.y):0,u=Math.sin(c)*Math.min(i,p/2)+l.x,d=Math.cos(c)*Math.min(i,p/2)+l.y;const n=i>0||0!==p?{x:u,y:d}:l;var p;c=0!==(p=Math.sqrt((r.x-l.x)*(r.x-l.x)+(r.y-l.y)*(r.y-l.y)))?Math.atan2(r.x-l.x,r.y-l.y):0,u=Math.sin(c)*Math.min(i,p/2)+l.x,d=Math.cos(c)*Math.min(i,p/2)+l.y;const s=i>0||0!==p?{x:u,y:d}:l;t.lineTo(n.x,n.y),i>0&&t.quadraticCurveTo(l.x,l.y,s.x,s.y)}this.drawStroke(t)}contains(t,e){var{lineWidth:r}=this.state;return lst(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 o=1;o<r.length;o++){var i=r[o-1],a=r[o],s=(i.x-a.x)*(i.x-a.x)+(i.y-a.y)*(i.y-a.y);s>n&&(n=Math.ceil(s),t=i,e=a)}var{paddingTop:o,paddingLeft:l,paddingRight:h,paddingBottom:c}=this.state;return c||=0,o||=0,l||=0,h||=0,{left:Math.min(t.x,e.x)+l,top:Math.min(t.y,e.y)+o,width:Math.max(Math.abs(t.x-e.x)-l-h,0),height:Math.max(Math.abs(t.y-e.y)-o-c,0)}}get decorators(){return["decotag"]}}yst.getTipNeckPos=hst,yst.containedInPath=lst,yst.drawEndTips=cst,ret.register("line",yst);const bst={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"angle",label:"start-angle",name:"startAngle",property:"startAngle"},{type:"angle",label:"end-angle",name:"endAngle",property:"endAngle"}],"value-property":"text"};class wst extends(jet(net)){is3dish(){return!0}render(t){var{cx:e,cy:r,rx:n,ry:i,startAngle:a,endAngle:s,anticlockwise:o}=this.state;t.beginPath(),t.ellipse(e,r,Math.abs(n),Math.abs(i),0,a||0,s||2*Math.PI,o),void 0!==a&&void 0!==s&&(t.lineTo(e,r),t.closePath())}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,s=(t-r)/(2*i-.5),o=(e-n)/(2*a-.5);return s*s+o*o<.25}outline(t){return function(t,e){var{cx:r,cy:n,rx:i,ry:a}=t.model,s=2*Math.PI*e,o=r+i*Math.cos(s),l=n+a*Math.sin(s);return t.transcoordS2T(o,l)}(this,t)}get anchors(){return function(t){var{left:e,top:r,width:n,height:i}=t.bounds,a=e+n/2,s=r+i/2;return[{name:"TOP",position:{x:a,y:r}},{name:"RIGHT",position:{x:e+n,y:s}},{name:"BOTTOM",position:{x:a,y:r+i}},{name:"LEFT",position:{x:e,y:s}}]}(this)}get nature(){return bst}}ret.memoize(wst.prototype,"path",!1),ret.register("ellipse",wst);var xst={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 Ast={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 _st extends net{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 s=(a+r.length+1)%r.length,o=i.x,l=i.y,h=r[s].x,c=r[s].y;l>e!=c>e&&t<(h-o)*(e-l)/(c-l)+o&&(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:xst}}))}get nature(){return Ast}}ret.memoize(_st.prototype,"controls",!1),ret.register("polygon",_st);var kst={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 Sst={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 Est extends yst{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:kst}),e.push({x:(n.x+i.x)/2,y:(n.y+i.y)/2,handler:kst}),r==t.length-2&&e.push({x:i.x,y:i.y,handler:kst})}return e}get nature(){return Sst}}ret.register("polyline",Est);const Mst={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 Tst extends yst{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:s,boundaryPosition:o=e}=this.toEnd||{};var l=[i,o],h=[];i&&h.push(i);var c=r?.bounds;if(c){var u=r.transcoordS2T(c.left,c.top);u=this.transcoordT2P(u.x,u.y),c={...c,left:u.x,top:u.y}}var d=c?{left:c.left-20,top:c.top-20,width:c.width+40,height:c.height+40}:{left:i.x,top:i.y,width:0,height:0};c=c||d;var p=a?.bounds;if(p){u=a.transcoordS2T(p.left,p.top);u=this.transcoordT2P(u.x,u.y),p={...p,left:u.x,top:u.y}}var f=p?{left:p.left-20,top:p.top-20,width:p.width+40,height:p.height+40}:{left:o.x,top:o.y,width:0,height:0};p=p||f;var g=[d,f];const v=d.left>f.left?f.left:d.left,m=d.top>f.top?f.top:d.top;var y,b,w,x,A,_,k,S,E,M,T={left:v,top:m,width:d.left+d.width>f.left+f.width?d.left+d.width-v:f.left+f.width-v,height:d.top+d.height>f.top+f.height?d.top+d.height-m:f.top+f.height-m},C=0,P=0;c.left+c.width<p.left?(x=0,A=1,E=n,M=s,y=(c.left+c.width+p.left)/2,C=p.left-y):p.left+p.width<c.left&&(x=1,A=0,E=s,M=n,y=(c.left+p.width+p.left)/2,C=c.left-y),c.top+c.height<p.top?(w=0,_=1,k=n,S=s,b=(c.top+c.height+p.top)/2,P=p.top-b):p.top+p.height<c.top&&(w=1,_=0,k=s,S=n,b=(c.top+p.height+p.top)/2,P=c.top-b);var I=[];if(y&&C>P){switch(M){case vst:switch(E){case gst:I.push({x:y,y:l[x].y}),I.push({x:y,y:l[A].y});break;case vst:var R=g[x].top+g[x].height/2>l[A].y?Math.min(g[x].top,l[A].y):Math.max(g[x].top+g[x].height,l[A].y);I.push({x:l[x].x,y:R}),I.push({x:y,y:R}),I.push({x:y,y:l[A].y});break;case pst:case fst:R=E===fst?Math.max(l[x].y,l[A].y):Math.min(l[x].y,l[A].y);I.push({x:l[x].x,y:R}),I.push({x:y,y:R}),I.push({x:y,y:l[A].y});break;default:return this.path}break;case gst:switch(E){case gst:var O=R=l[x].y<l[A].y?Math.min(g[A].top,l[x].y):Math.max(g[A].top+g[A].height,l[x].y);break;case vst:O=R=void 0!==b?b:l[x].y<l[A].y?T.top-.5*C:T.top+T.height+.5*C;break;case fst:O=R=void 0!==b?Math.max(b,l[x].y):T.top+T.height;break;case pst:O=R=b?Math.min(b,g[x].top):T.top;break;default:return this.path}I.push({x:l[x].x,y:R}),I.push({x:y,y:R}),I.push({x:y,y:O}),I.push({x:l[A].x,y:O});break;case fst:switch(E){case gst:R=l[x].y,O=l[x].y>l[A].y?l[x].y:g[A].top+g[A].height;break;case vst:O=R=b?Math.max(b,g[A].top+g[A].height):T.top+T.height;break;case fst:O=R=T.top+T.height;break;case pst:R=b?Math.min(b,g[x].top):g[x].top,O=b?Math.max(b,g[A].top+g[A].height):g[A].top+g[A].height;break;default:return this.path}I.push({x:l[x].x,y:R}),I.push({x:y,y:R}),I.push({x:y,y:O}),I.push({x:l[A].x,y:O});break;case pst:switch(E){case gst:R=l[x].y,O=l[x].y<l[A].y?l[x].y:g[A].top;break;case vst:O=R=b?Math.min(b,g[A].top):T.top;break;case fst:R=void 0!==b?Math.max(b,l[x].y):l[x].y,O=void 0!==b?Math.min(b,l[A].y):l[A].y;break;case pst:O=R=T.top;break;default:return this.path}I.push({x:l[x].x,y:R}),I.push({x:y,y:R}),I.push({x:y,y:O}),I.push({x:l[A].x,y:O});break;default:return this.path}h.push(...0===x?I:I.reverse())}else if(b){switch(S){case pst:switch(k){case fst:I.push({x:l[w].x,y:b}),I.push({x:l[_].x,y:b});break;case pst:var L=g[w].left+g[w].width/2>l[_].x?Math.min(g[w].left,l[_].x):Math.max(g[w].left+g[w].width,l[_].x);I.push({x:L,y:l[w].y}),I.push({x:L,y:b}),I.push({x:l[_].x,y:b});break;case vst:L=Math.min(l[w].x,l[_].x);I.push({x:L,y:l[w].y}),I.push({x:L,y:b}),I.push({x:l[_].x,y:b});break;case gst:L=Math.max(l[w].x,l[_].x);I.push({x:L,y:l[w].y}),I.push({x:L,y:b}),I.push({x:l[_].x,y:b});break;default:return this.path}break;case fst:switch(k){case vst:var D=L=T.left;break;case gst:D=L=void 0!==y?Math.max(y,l[w].x):T.left+T.width;break;case pst:D=L=void 0!==y?y:l[w].x<l[_].x?T.left-.5*P:T.left+T.width+.5*P;break;case fst:L=l[w].x,D=l[w].x<l[_].x?Math.min(g[_].left,l[w].x):Math.max(g[_].left+g[_].width,l[w].x);break;default:return this.path}I.push({x:L,y:l[w].y}),I.push({x:L,y:b}),I.push({x:D,y:b}),I.push({x:D,y:l[_].y});break;case gst:switch(k){case vst:L=void 0!==y?Math.min(y,l[w].x):l[w].x,D=void 0!==y?Math.max(y,l[_].x):l[_].x;break;case gst:D=L=T.left+T.width;break;case pst:D=L=void 0!==y?Math.max(y,l[_].x):T.left+T.width;break;case fst:L=l[w].x,D=Math.max(g[_].left+g[_].width,l[w].x);break;default:return this.path}I.push({x:L,y:l[w].y}),I.push({x:L,y:b}),I.push({x:D,y:b}),I.push({x:D,y:l[_].y});break;case vst:switch(k){case vst:D=L=T.left;break;case gst:L=void 0!==y?Math.max(y,l[w].x):l[w].x,D=void 0!==y?Math.min(y,l[_].x):l[_].x;break;case pst:D=L=T.left;break;case fst:L=l[w].x<l[_].x?Math.min(g[_].left,l[w].x):l[w].x,D=Math.min(L,l[_].x);break;default:return this.path}I.push({x:L,y:l[w].y}),I.push({x:L,y:b}),I.push({x:D,y:b}),I.push({x:D,y:l[_].y});break;default:return this.path}h.push(...0===w?I:I.reverse())}else switch(n){case pst:switch(s){case pst:var F=T.top;h.push({x:l[0].x,y:F}),h.push({x:l[1].x,y:F});break;case fst:var N=T.left+T.width;h.push({x:N,y:l[0].y}),h.push({x:N,y:T.top+T.height}),h.push({x:l[1].x,y:T.top+T.height});break;case gst:N=l[1].y<l[0].y&&l[1].x<l[0].x?l[0].x:T.left+T.width;h.push({x:N,y:l[0].y}),h.push({x:N,y:l[1].y});break;case vst:N=T.left;h.push({x:N,y:l[0].y}),h.push({x:N,y:l[1].y});break;default:return this.path}break;case fst:switch(s){case pst:N=T.left+T.width;h.push({x:N,y:l[0].y}),h.push({x:N,y:T.top}),h.push({x:l[1].x,y:T.top});break;case fst:F=T.top+T.height;h.push({x:l[0].x,y:F}),h.push({x:l[1].x,y:F});break;case gst:F=T.top+T.height;h.push({x:l[0].x,y:F}),h.push({x:l[1].x,y:F});break;case vst:F=T.top+T.height;h.push({x:l[0].x,y:F}),h.push({x:l[1].x,y:F});break;default:return this.path}break;case vst:switch(s){case pst:N=l[0].x>l[1].x&&l[0].y<l[1].y?l[1].x:T.left,F=l[0].x>l[1].x&&l[0].y<l[1].y?l[1].y:Math.min(T.top,l[0].y);h.push({x:N,y:l[0].y}),h.push({x:N,y:F}),h.push({x:l[1].x,y:F});break;case fst:N=T.left,F=Math.max(T.top+T.height,l[0].y);h.push({x:N,y:l[0].y}),h.push({x:N,y:F}),h.push({x:l[1].x,y:F});break;case gst:N=T.left+T.width;h.push({x:l[0].x,y:T.top}),h.push({x:N,y:T.top}),h.push({x:N,y:l[1].y});break;case vst:N=T.left;h.push({x:N,y:l[0].y}),h.push({x:N,y:l[1].y});break;default:return this.path}break;case gst:switch(s){case pst:F=l[0].y<l[1].y&&l[0].x<l[1].x?l[0].y:T.top;h.push({x:l[0].x,y:F}),h.push({x:l[1].x,y:F});break;case fst:F=l[0].y>l[1].y&&l[0].x<l[1].x?l[0].y:T.top+T.height;h.push({x:l[0].x,y:F}),h.push({x:l[1].x,y:F});break;case gst:F=T.top+T.height;h.push({x:l[0].x,y:F}),h.push({x:l[1].x,y:F});break;case vst:F=T.top+T.height;h.push({x:l[0].x,y:F}),h.push({x:l[1].x,y:F});break;default:return this.path}break;default:return this.path}return o&&h.push(o),[t,...h,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 Mst}}ret.register("ortholine",Tst);const Cst={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 Pst extends(aet(net)){static get noimage(){return Pst.NOIMAGE||(Pst.NOIMAGE=new Image,Pst.NOIMAGE.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAABIBAMAAAD7Se1QAAAAIVBMVEUAAABHcEwBAQEREREBAQEEBAQGBgYLCwsDAwMDAwMICAi6HF9tAAAAC3RSTlNNAEAERiMYCS41Eac10lYAAAEgSURBVHhe7dY9asQwEAXgh7DNertNiJy48pIitY3SB7bYdk0ukL1BDDmA9gZecoH4pmFQ3MQayUMguPBrNPD4wD9TCMvJmt3M/AtYwXOlXiWgqADVCUBD46MAnGhMBaCiUQmAm8VA/Eh/eWl9Fn5WcxD+OLuRrUYJDKLluwH2InACUgkoACSdADxQc50Bytadb9RkM0CT13TcvlCT1HFg8UTHvasuUVACCa3El6u2UdD8LFTlKhUFFgA+d3dj10aABkUN72N3jAADCrJq7PIIsPidcxBoTHIIAjMFmyCwmGYIAA1P9gFgfCANAOsDSccCDW+uLDB+kLGg94OkZoAGkwsDDAe2DOg5oPxAg03rBR88OHpBz4N8UVeHFSwma74BTW6Ge4rIRa4AAAAASUVORK5CYII="),Pst.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:s=1,src:o}=this.state;if(this.prepareIf(!this._image&&o),t.beginPath(),t.globalAlpha*=s,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(Pst.noimage,e,r,n,i)}else!this.app.isViewMode&&t.drawImage(Pst.noimage,e,r,n,i)}get nature(){return Cst}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=ret.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 M9("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],s=parseInt((e+r+a)/3);n.data[t]=s,n.data[t+1]=s,n.data[t+2]=s}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])}}ret.register("image-view",Pst);class Ist extends(tst(aet(ret))){is3dish(){return!0}prerender(){}}var Rst={},Ost={},Lst={};Object.defineProperty(Lst,"__esModule",{value:!0});var Dst=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},s=[],o=1<<t,l=o+1,h=t+1,c=[],u=function(){c=[],h=t+1;for(var e=0;e<o;e++)c[e]=[e];c[o]=[],c[l]=null};;)if(n=r,(r=a(h))!==o){if(r===l)break;if(r<c.length)n!==o&&c.push(c[n].concat(c[r][0]));else{if(r!==c.length)throw new Error("Invalid LZW code.");c.push(c[n].concat(c[n][0]))}s.push.apply(s,c[r]),c.length===1<<h&&h<12&&h++}else u();return s},t}();Lst.SuperGifUtils=Dst,Object.defineProperty(Ost,"__esModule",{value:!0});var Fst=Lst,Nst=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=Fst.SuperGifUtils.byteToBitArr(this.stream.readByte());t.gctFlag=e.shift(),t.colorRes=Fst.SuperGifUtils.bitsToNum(e.splice(0,3)),t.sorted=e.shift(),t.gctSize=Fst.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=Fst.SuperGifUtils.byteToBitArr(e.stream.readByte());t.reserved=r.splice(0,3),t.disposalMethod=Fst.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=Fst.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=Fst.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=Fst.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],s=[8,8,4,2],o=0,l=0;l<4;l++)for(var h=a[l];h<n;h+=s[l])i(h,o),o++;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}();Ost.SuperGifParser=Nst;var jst={};Object.defineProperty(jst,"__esModule",{value:!0});var Bst=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}();jst.SuperGifStream=Bst,Object.defineProperty(Rst,"__esModule",{value:!0});var zst=Ost,Wst=jst,Ust=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 zst.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 Wst.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}(),Hst=Rst.SuperGif=Ust;const Gst={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 Yst extends Ist{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 Hst(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 Gst}get tagName(){return"div"}}ret.register("gif-view",Yst);const Vst={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 qst extends(aet(net)){static get image(){return qst.IMAGE||(qst.IMAGE=new Image,qst.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="),qst.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,qst.image,e,r,n,i)}get nature(){return Vst}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])}}ret.register("audio",qst);class Xst extends(aet(ret)){is3dish(){return!0}}ret.register("text",Xst);const $st=["refid","left","top","width","height","rotation","animation"];class Kst extends ist{isGroup(){return!0}get(t){return this._model[t]}set(t,e){if("string"==typeof t)return this.set({[t]:e});var r=$st.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)},s=e.width*(1-r),o=e.height*(1-n),l=-(a.x-s/2),h=-(a.y-o/2);t.bounds={left:e.left+l,top:e.top+h,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=ret.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)}}ret.register("group",Kst);const Qst={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 Jst extends(aet(net)){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 Qst}get hasTextProperty(){return!1}}ret.memoize(Jst.prototype,"ref",!1),ret.memoize(Jst.prototype,"refScale",!1),ret.register("local-ref",Jst);class Zst extends(tst(Iet)){render(t){}is3dish(){return!0}get layout(){return det.get(this.get("layout"))||pet}}const tot={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 eot extends Zst{dispose(){this._releaseRef(),super.dispose()}get nature(){return tot}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){M9(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}))}}ret.register("global-ref",eot);const rot={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:"draggable",name:"draggable"},{type:"checkbox",label:"minimizable",name:"minimizable"},{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:"string",label:"title",name:"text"},{type:"data",label:"value",name:"value"}],help:"scene/component/popup"};class not extends(aet(net)){static get image(){return not._image||(not._image=new Image,not._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"),not._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,not.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?yet.show(this,this.getState("board"),{location:this.getState("location"),modal:this.getState("modal"),closable:this.getState("closable")||!1,draggable:this.getState("draggable")||!1,minimizable:this.getState("minimizable")||!1,title:this.text,data:this.value}):yet.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 rot}}ret.register("popup",not);class iot extends ret{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 s=(a+r.length+1)%r.length,o=i.x,l=i.y,h=r[s].x,c=r[s].y;l>e!=c>e&&t<(h-o)*(e-l)/(c-l)+o&&(n=!n)})),n}}ret.register("path",iot);const aot={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 sot extends net{contains(t,e){var{x1:r,y1:n,x2:i,y2:a,x3:s,y3:o}=this.state,l=[r,n,i,a,s,o],h=!1;for(let r=0;r<l.length;r+=2){let n=(r+2)%l.length,i=l[r],a=l[r+1],s=l[n+1];a>e!=s>e&&t<(l[n]-i)*(e-a)/(s-a)+i&&(h=!h)}return h}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 aot}}ret.memoize(sot.prototype,"path",!1),ret.register("triangle",sot);const oot={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"number",label:"ratio",name:"ratio",property:"ratio"}],help:"scene/component/donut"};var lot={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 hot extends wst{is3dish(){return!1}render(t){var{ratio:e=50,cx:r,cy:n,rx:i,ry:a,startAngle:s,endAngle:o,anticlockwise:l}=this.state;i=Math.abs(i),a=Math.abs(a),t.beginPath(),t.ellipse(r,n,i,a,0,s||0,o||2*Math.PI,l),t.moveTo(r+i/100*e,n),t.ellipse(r,n,i/100*e,a/100*e,0,s||0,o||2*Math.PI,!0)}contains(t,e){var{cx:r,cy:n,rx:i,ry:a,ratio:s}=this.state,o=(t-r)/(2*(i=Math.abs(i))-.5),l=(e-n)/(2*(a=Math.abs(a))-.5),h=(t-r)/(i/100*s*2-.5),c=(e-n)/(a/100*s*2-.5),u=!1;return o*o+l*l<.25&&h*h+c*c>.25&&(u=!u),u}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:lot}]}get nature(){return oot}}ret.memoize(hot.prototype,"controls",!1),ret.register("donut",hot);const cot={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 uot,dot,pot,fot,got,vot,mot,yot,bot,wot,xot,Aot,_ot,kot={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 Sot extends wst{is3dish(){return!1}render(t){var{ratio:e=30,wing:r=5,cx:n,cy:i,rx:a,ry:s,startAngle:o,endAngle:l,anticlockwise:h}=this.state;if(r<3)return;const c=1.5707963267948966;var u=2*Math.PI/r,d=a-e/100*a,p=s-e/100*s;t.save(),t.beginPath(),t.translate(n,i),t.moveTo(a*Math.cos(-c),s*Math.sin(-c)),t.lineTo((a-d)*(Math.cos(u-c)+Math.cos(0-c))/2,(s-p)*(Math.sin(u-c)+Math.sin(0-c))/2);for(var f=1;f<r;f++)t.lineTo(a*Math.cos(u*f-c),s*Math.sin(u*f-c)),t.lineTo((a-d)*(Math.cos(u*(f+1)-c)+Math.cos(u*f-c))/2,(s-p)*(Math.sin(u*(f+1)-c)+Math.sin(u*f-c))/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:kot}]}get nature(){return cot}}ret.memoize(Sot.prototype,"controls",!1),ret.register("star",Sot);
|
|
71
|
+
`,this.element)}onchangeMinimized(){const{minimized:t}=this.state;t?this.setState("height",24):this.setState("height",this.get("height"))}}ret.register("container",ist);const ast=Math.sqrt(3),sst=2;function ost(t,e,r,n,i){var a,s,o,l,h=5+i,c=r.x,u=r.y,d=n.x,p=n.y;if(Math.abs(c-d)>h&&Math.abs(u-p)>h){var f=(p-u)/(d-c),g=u-f*c;if(Math.abs(e-(f*t+g))>h)return!1}return c>d?(s=c,a=d):(s=d,a=c),u>p?(l=u,o=p):(l=p,o=u),!(s+5<t)&&(!(a-5>t)&&(!(l+5<e)&&!(o-5>e)))}function lst(t,e,r,n=2){for(let i=0;i<r.length-1;i++)if(ost(t,e,r[i],r[i+1],n))return!0;return!1}function hst(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 cst(t,e,r){var{lineWidth:n=sst,strokeStyle:i="#000000",lineCap:a=!1,alpha:s=1,begin:o="none",end:l="none",beginSize:h="size5",endSize:c="size5"}=r;if(("none"!=o||"none"!=l)&&(n=Number(n)||sst,t.lineCap=a,t.lineWidth=n,t.strokeStyle=i,t.fillStyle=i,t.globalAlpha*=s,"none"!=o&&ust(t,e[0],e[1],n,o,dst(h,n)),"none"!=l)){let r=e.length;ust(t,e[r-1],e[r-2],n,l,dst(c,n))}}function ust(t,e,r,n,i,a){var{x:s,y:o}=e,l=Math.atan2(r.y-o,r.x-s);switch(t.beginPath(),t.translate(s,o),t.rotate(l),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(ast*a.X,-a.Y),t.lineTo(ast*a.X,a.Y),t.fill();break;case"sharp-arrow":t.moveTo(0,0),t.lineTo(ast*a.X,-a.Y),t.lineTo(-a.X/1.5+ast*a.X,0),t.lineTo(ast*a.X,a.Y),t.fill();break;case"open-arrow":t.moveTo(ast*a.X+n,-a.Y),t.lineTo(n,0),t.lineTo(ast*a.X+n,a.Y),t.stroke()}t.rotate(-l),t.translate(-s,-o),t.closePath()}function dst(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 pst="N",fst="S",gst="E",vst="W";class mst{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 gst;const r=e.position;return r.y<=t.top?pst:r.y>=t.top+t.height?fst:r.x<=t.left?vst:gst}get boundaryPosition(){const t=this.anchor;if(t){var{position:e}=t,r=0,n=0;switch(this.direction){case fst:n=20;break;case pst:n=-20;break;case vst: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 yst extends ret{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 mst({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 mst({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;cst(t,a,this.state),t.beginPath();var s=hst(e,n,a[0],a[1]),o=hst(r,n,a[a.length-1],a[a.length-2]);a=[s,...a.slice(1,-1),o];var l={x:s.x,y:s.y};t.moveTo(s.x,s.y);for(var h=1;h<a.length;h++){const e=l;l=a[h];const r=a[h+1];if(e.x===l.x&&e.y===l.y)continue;if(!r){t.lineTo(l.x,l.y);break}var c=0!==(p=Math.sqrt((e.x-l.x)*(e.x-l.x)+(e.y-l.y)*(e.y-l.y)))?Math.atan2(e.x-l.x,e.y-l.y):0,u=Math.sin(c)*Math.min(i,p/2)+l.x,d=Math.cos(c)*Math.min(i,p/2)+l.y;const n=i>0||0!==p?{x:u,y:d}:l;var p;c=0!==(p=Math.sqrt((r.x-l.x)*(r.x-l.x)+(r.y-l.y)*(r.y-l.y)))?Math.atan2(r.x-l.x,r.y-l.y):0,u=Math.sin(c)*Math.min(i,p/2)+l.x,d=Math.cos(c)*Math.min(i,p/2)+l.y;const s=i>0||0!==p?{x:u,y:d}:l;t.lineTo(n.x,n.y),i>0&&t.quadraticCurveTo(l.x,l.y,s.x,s.y)}this.drawStroke(t)}contains(t,e){var{lineWidth:r}=this.state;return lst(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 o=1;o<r.length;o++){var i=r[o-1],a=r[o],s=(i.x-a.x)*(i.x-a.x)+(i.y-a.y)*(i.y-a.y);s>n&&(n=Math.ceil(s),t=i,e=a)}var{paddingTop:o,paddingLeft:l,paddingRight:h,paddingBottom:c}=this.state;return c||=0,o||=0,l||=0,h||=0,{left:Math.min(t.x,e.x)+l,top:Math.min(t.y,e.y)+o,width:Math.max(Math.abs(t.x-e.x)-l-h,0),height:Math.max(Math.abs(t.y-e.y)-o-c,0)}}get decorators(){return["decotag"]}}yst.getTipNeckPos=hst,yst.containedInPath=lst,yst.drawEndTips=cst,ret.register("line",yst);const bst={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"angle",label:"start-angle",name:"startAngle",property:"startAngle"},{type:"angle",label:"end-angle",name:"endAngle",property:"endAngle"}],"value-property":"text"};class wst extends(jet(net)){is3dish(){return!0}render(t){var{cx:e,cy:r,rx:n,ry:i,startAngle:a,endAngle:s,anticlockwise:o}=this.state;t.beginPath(),t.ellipse(e,r,Math.abs(n),Math.abs(i),0,a||0,s||2*Math.PI,o),void 0!==a&&void 0!==s&&(t.lineTo(e,r),t.closePath())}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,s=(t-r)/(2*i-.5),o=(e-n)/(2*a-.5);return s*s+o*o<.25}outline(t){return function(t,e){var{cx:r,cy:n,rx:i,ry:a}=t.model,s=2*Math.PI*e,o=r+i*Math.cos(s),l=n+a*Math.sin(s);return t.transcoordS2T(o,l)}(this,t)}get anchors(){return function(t){var{left:e,top:r,width:n,height:i}=t.bounds,a=e+n/2,s=r+i/2;return[{name:"TOP",position:{x:a,y:r}},{name:"RIGHT",position:{x:e+n,y:s}},{name:"BOTTOM",position:{x:a,y:r+i}},{name:"LEFT",position:{x:e,y:s}}]}(this)}get nature(){return bst}}ret.memoize(wst.prototype,"path",!1),ret.register("ellipse",wst);var xst={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 Ast={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 _st extends net{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 s=(a+r.length+1)%r.length,o=i.x,l=i.y,h=r[s].x,c=r[s].y;l>e!=c>e&&t<(h-o)*(e-l)/(c-l)+o&&(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:xst}}))}get nature(){return Ast}}ret.memoize(_st.prototype,"controls",!1),ret.register("polygon",_st);var kst={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 Sst={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 Est extends yst{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:kst}),e.push({x:(n.x+i.x)/2,y:(n.y+i.y)/2,handler:kst}),r==t.length-2&&e.push({x:i.x,y:i.y,handler:kst})}return e}get nature(){return Sst}}ret.register("polyline",Est);const Mst={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 Tst extends yst{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:s,boundaryPosition:o=e}=this.toEnd||{};var l=[i,o],h=[];i&&h.push(i);var c=r?.bounds;if(c){var u=r.transcoordS2T(c.left,c.top);u=this.transcoordT2P(u.x,u.y),c={...c,left:u.x,top:u.y}}var d=c?{left:c.left-20,top:c.top-20,width:c.width+40,height:c.height+40}:{left:i.x,top:i.y,width:0,height:0};c=c||d;var p=a?.bounds;if(p){u=a.transcoordS2T(p.left,p.top);u=this.transcoordT2P(u.x,u.y),p={...p,left:u.x,top:u.y}}var f=p?{left:p.left-20,top:p.top-20,width:p.width+40,height:p.height+40}:{left:o.x,top:o.y,width:0,height:0};p=p||f;var g=[d,f];const v=d.left>f.left?f.left:d.left,m=d.top>f.top?f.top:d.top;var y,b,w,x,A,_,k,S,E,M,T={left:v,top:m,width:d.left+d.width>f.left+f.width?d.left+d.width-v:f.left+f.width-v,height:d.top+d.height>f.top+f.height?d.top+d.height-m:f.top+f.height-m},C=0,P=0;c.left+c.width<p.left?(x=0,A=1,E=n,M=s,y=(c.left+c.width+p.left)/2,C=p.left-y):p.left+p.width<c.left&&(x=1,A=0,E=s,M=n,y=(c.left+p.width+p.left)/2,C=c.left-y),c.top+c.height<p.top?(w=0,_=1,k=n,S=s,b=(c.top+c.height+p.top)/2,P=p.top-b):p.top+p.height<c.top&&(w=1,_=0,k=s,S=n,b=(c.top+p.height+p.top)/2,P=c.top-b);var I=[];if(y&&C>P){switch(M){case vst:switch(E){case gst:I.push({x:y,y:l[x].y}),I.push({x:y,y:l[A].y});break;case vst:var R=g[x].top+g[x].height/2>l[A].y?Math.min(g[x].top,l[A].y):Math.max(g[x].top+g[x].height,l[A].y);I.push({x:l[x].x,y:R}),I.push({x:y,y:R}),I.push({x:y,y:l[A].y});break;case pst:case fst:R=E===fst?Math.max(l[x].y,l[A].y):Math.min(l[x].y,l[A].y);I.push({x:l[x].x,y:R}),I.push({x:y,y:R}),I.push({x:y,y:l[A].y});break;default:return this.path}break;case gst:switch(E){case gst:var O=R=l[x].y<l[A].y?Math.min(g[A].top,l[x].y):Math.max(g[A].top+g[A].height,l[x].y);break;case vst:O=R=void 0!==b?b:l[x].y<l[A].y?T.top-.5*C:T.top+T.height+.5*C;break;case fst:O=R=void 0!==b?Math.max(b,l[x].y):T.top+T.height;break;case pst:O=R=b?Math.min(b,g[x].top):T.top;break;default:return this.path}I.push({x:l[x].x,y:R}),I.push({x:y,y:R}),I.push({x:y,y:O}),I.push({x:l[A].x,y:O});break;case fst:switch(E){case gst:R=l[x].y,O=l[x].y>l[A].y?l[x].y:g[A].top+g[A].height;break;case vst:O=R=b?Math.max(b,g[A].top+g[A].height):T.top+T.height;break;case fst:O=R=T.top+T.height;break;case pst:R=b?Math.min(b,g[x].top):g[x].top,O=b?Math.max(b,g[A].top+g[A].height):g[A].top+g[A].height;break;default:return this.path}I.push({x:l[x].x,y:R}),I.push({x:y,y:R}),I.push({x:y,y:O}),I.push({x:l[A].x,y:O});break;case pst:switch(E){case gst:R=l[x].y,O=l[x].y<l[A].y?l[x].y:g[A].top;break;case vst:O=R=b?Math.min(b,g[A].top):T.top;break;case fst:R=void 0!==b?Math.max(b,l[x].y):l[x].y,O=void 0!==b?Math.min(b,l[A].y):l[A].y;break;case pst:O=R=T.top;break;default:return this.path}I.push({x:l[x].x,y:R}),I.push({x:y,y:R}),I.push({x:y,y:O}),I.push({x:l[A].x,y:O});break;default:return this.path}h.push(...0===x?I:I.reverse())}else if(b){switch(S){case pst:switch(k){case fst:I.push({x:l[w].x,y:b}),I.push({x:l[_].x,y:b});break;case pst:var L=g[w].left+g[w].width/2>l[_].x?Math.min(g[w].left,l[_].x):Math.max(g[w].left+g[w].width,l[_].x);I.push({x:L,y:l[w].y}),I.push({x:L,y:b}),I.push({x:l[_].x,y:b});break;case vst:L=Math.min(l[w].x,l[_].x);I.push({x:L,y:l[w].y}),I.push({x:L,y:b}),I.push({x:l[_].x,y:b});break;case gst:L=Math.max(l[w].x,l[_].x);I.push({x:L,y:l[w].y}),I.push({x:L,y:b}),I.push({x:l[_].x,y:b});break;default:return this.path}break;case fst:switch(k){case vst:var D=L=T.left;break;case gst:D=L=void 0!==y?Math.max(y,l[w].x):T.left+T.width;break;case pst:D=L=void 0!==y?y:l[w].x<l[_].x?T.left-.5*P:T.left+T.width+.5*P;break;case fst:L=l[w].x,D=l[w].x<l[_].x?Math.min(g[_].left,l[w].x):Math.max(g[_].left+g[_].width,l[w].x);break;default:return this.path}I.push({x:L,y:l[w].y}),I.push({x:L,y:b}),I.push({x:D,y:b}),I.push({x:D,y:l[_].y});break;case gst:switch(k){case vst:L=void 0!==y?Math.min(y,l[w].x):l[w].x,D=void 0!==y?Math.max(y,l[_].x):l[_].x;break;case gst:D=L=T.left+T.width;break;case pst:D=L=void 0!==y?Math.max(y,l[_].x):T.left+T.width;break;case fst:L=l[w].x,D=Math.max(g[_].left+g[_].width,l[w].x);break;default:return this.path}I.push({x:L,y:l[w].y}),I.push({x:L,y:b}),I.push({x:D,y:b}),I.push({x:D,y:l[_].y});break;case vst:switch(k){case vst:D=L=T.left;break;case gst:L=void 0!==y?Math.max(y,l[w].x):l[w].x,D=void 0!==y?Math.min(y,l[_].x):l[_].x;break;case pst:D=L=T.left;break;case fst:L=l[w].x<l[_].x?Math.min(g[_].left,l[w].x):l[w].x,D=Math.min(L,l[_].x);break;default:return this.path}I.push({x:L,y:l[w].y}),I.push({x:L,y:b}),I.push({x:D,y:b}),I.push({x:D,y:l[_].y});break;default:return this.path}h.push(...0===w?I:I.reverse())}else switch(n){case pst:switch(s){case pst:var F=T.top;h.push({x:l[0].x,y:F}),h.push({x:l[1].x,y:F});break;case fst:var N=T.left+T.width;h.push({x:N,y:l[0].y}),h.push({x:N,y:T.top+T.height}),h.push({x:l[1].x,y:T.top+T.height});break;case gst:N=l[1].y<l[0].y&&l[1].x<l[0].x?l[0].x:T.left+T.width;h.push({x:N,y:l[0].y}),h.push({x:N,y:l[1].y});break;case vst:N=T.left;h.push({x:N,y:l[0].y}),h.push({x:N,y:l[1].y});break;default:return this.path}break;case fst:switch(s){case pst:N=T.left+T.width;h.push({x:N,y:l[0].y}),h.push({x:N,y:T.top}),h.push({x:l[1].x,y:T.top});break;case fst:F=T.top+T.height;h.push({x:l[0].x,y:F}),h.push({x:l[1].x,y:F});break;case gst:F=T.top+T.height;h.push({x:l[0].x,y:F}),h.push({x:l[1].x,y:F});break;case vst:F=T.top+T.height;h.push({x:l[0].x,y:F}),h.push({x:l[1].x,y:F});break;default:return this.path}break;case vst:switch(s){case pst:N=l[0].x>l[1].x&&l[0].y<l[1].y?l[1].x:T.left,F=l[0].x>l[1].x&&l[0].y<l[1].y?l[1].y:Math.min(T.top,l[0].y);h.push({x:N,y:l[0].y}),h.push({x:N,y:F}),h.push({x:l[1].x,y:F});break;case fst:N=T.left,F=Math.max(T.top+T.height,l[0].y);h.push({x:N,y:l[0].y}),h.push({x:N,y:F}),h.push({x:l[1].x,y:F});break;case gst:N=T.left+T.width;h.push({x:l[0].x,y:T.top}),h.push({x:N,y:T.top}),h.push({x:N,y:l[1].y});break;case vst:N=T.left;h.push({x:N,y:l[0].y}),h.push({x:N,y:l[1].y});break;default:return this.path}break;case gst:switch(s){case pst:F=l[0].y<l[1].y&&l[0].x<l[1].x?l[0].y:T.top;h.push({x:l[0].x,y:F}),h.push({x:l[1].x,y:F});break;case fst:F=l[0].y>l[1].y&&l[0].x<l[1].x?l[0].y:T.top+T.height;h.push({x:l[0].x,y:F}),h.push({x:l[1].x,y:F});break;case gst:F=T.top+T.height;h.push({x:l[0].x,y:F}),h.push({x:l[1].x,y:F});break;case vst:F=T.top+T.height;h.push({x:l[0].x,y:F}),h.push({x:l[1].x,y:F});break;default:return this.path}break;default:return this.path}return o&&h.push(o),[t,...h,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 Mst}}ret.register("ortholine",Tst);const Cst={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 Pst extends(aet(net)){static get noimage(){return Pst.NOIMAGE||(Pst.NOIMAGE=new Image,Pst.NOIMAGE.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAABIBAMAAAD7Se1QAAAAIVBMVEUAAABHcEwBAQEREREBAQEEBAQGBgYLCwsDAwMDAwMICAi6HF9tAAAAC3RSTlNNAEAERiMYCS41Eac10lYAAAEgSURBVHhe7dY9asQwEAXgh7DNertNiJy48pIitY3SB7bYdk0ukL1BDDmA9gZecoH4pmFQ3MQayUMguPBrNPD4wD9TCMvJmt3M/AtYwXOlXiWgqADVCUBD46MAnGhMBaCiUQmAm8VA/Eh/eWl9Fn5WcxD+OLuRrUYJDKLluwH2InACUgkoACSdADxQc50Bytadb9RkM0CT13TcvlCT1HFg8UTHvasuUVACCa3El6u2UdD8LFTlKhUFFgA+d3dj10aABkUN72N3jAADCrJq7PIIsPidcxBoTHIIAjMFmyCwmGYIAA1P9gFgfCANAOsDSccCDW+uLDB+kLGg94OkZoAGkwsDDAe2DOg5oPxAg03rBR88OHpBz4N8UVeHFSwma74BTW6Ge4rIRa4AAAAASUVORK5CYII="),Pst.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:s=1,src:o}=this.state;if(this.prepareIf(!this._image&&o),t.beginPath(),t.globalAlpha*=s,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(Pst.noimage,e,r,n,i)}else!this.app.isViewMode&&t.drawImage(Pst.noimage,e,r,n,i)}get nature(){return Cst}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=ret.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 M9("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],s=parseInt((e+r+a)/3);n.data[t]=s,n.data[t+1]=s,n.data[t+2]=s}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])}}ret.register("image-view",Pst);class Ist extends(tst(aet(ret))){is3dish(){return!0}prerender(){}}var Rst={},Ost={},Lst={};Object.defineProperty(Lst,"__esModule",{value:!0});var Dst=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},s=[],o=1<<t,l=o+1,h=t+1,c=[],u=function(){c=[],h=t+1;for(var e=0;e<o;e++)c[e]=[e];c[o]=[],c[l]=null};;)if(n=r,(r=a(h))!==o){if(r===l)break;if(r<c.length)n!==o&&c.push(c[n].concat(c[r][0]));else{if(r!==c.length)throw new Error("Invalid LZW code.");c.push(c[n].concat(c[n][0]))}s.push.apply(s,c[r]),c.length===1<<h&&h<12&&h++}else u();return s},t}();Lst.SuperGifUtils=Dst,Object.defineProperty(Ost,"__esModule",{value:!0});var Fst=Lst,Nst=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=Fst.SuperGifUtils.byteToBitArr(this.stream.readByte());t.gctFlag=e.shift(),t.colorRes=Fst.SuperGifUtils.bitsToNum(e.splice(0,3)),t.sorted=e.shift(),t.gctSize=Fst.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=Fst.SuperGifUtils.byteToBitArr(e.stream.readByte());t.reserved=r.splice(0,3),t.disposalMethod=Fst.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=Fst.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=Fst.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=Fst.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],s=[8,8,4,2],o=0,l=0;l<4;l++)for(var h=a[l];h<n;h+=s[l])i(h,o),o++;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}();Ost.SuperGifParser=Nst;var jst={};Object.defineProperty(jst,"__esModule",{value:!0});var Bst=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}();jst.SuperGifStream=Bst,Object.defineProperty(Rst,"__esModule",{value:!0});var zst=Ost,Wst=jst,Ust=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 zst.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 Wst.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}(),Hst=Rst.SuperGif=Ust;const Gst={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 Yst extends Ist{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 Hst(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 Gst}get tagName(){return"div"}}ret.register("gif-view",Yst);const Vst={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 qst extends(aet(net)){static get image(){return qst.IMAGE||(qst.IMAGE=new Image,qst.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="),qst.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,qst.image,e,r,n,i)}get nature(){return Vst}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])}}ret.register("audio",qst);class Xst extends(aet(ret)){is3dish(){return!0}}ret.register("text",Xst);const $st=["refid","left","top","width","height","rotation","animation"];class Kst extends ist{isGroup(){return!0}get(t){return this._model[t]}set(t,e){if("string"==typeof t)return this.set({[t]:e});var r=$st.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)},s=e.width*(1-r),o=e.height*(1-n),l=-(a.x-s/2),h=-(a.y-o/2);t.bounds={left:e.left+l,top:e.top+h,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=ret.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)}}ret.register("group",Kst);const Qst={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 Jst extends(aet(net)){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 Qst}get hasTextProperty(){return!1}}ret.memoize(Jst.prototype,"ref",!1),ret.memoize(Jst.prototype,"refScale",!1),ret.register("local-ref",Jst);class Zst extends(tst(Iet)){render(t){}is3dish(){return!0}get layout(){return det.get(this.get("layout"))||pet}}const tot={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 eot extends Zst{dispose(){this._releaseRef(),super.dispose()}get nature(){return tot}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){M9(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}))}}ret.register("global-ref",eot);const rot={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:"draggable",name:"draggable"},{type:"checkbox",label:"minimizable",name:"minimizable"},{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:"string",label:"title",name:"text"},{type:"data",label:"value",name:"value"}],help:"scene/component/popup"};class not extends(aet(net)){static get image(){return not._image||(not._image=new Image,not._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"),not._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,not.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?yet.show(this,this.getState("board"),{location:this.getState("location"),modal:this.getState("modal"),closable:this.getState("closable")||!1,draggable:this.getState("draggable")||!1,minimizable:this.getState("minimizable")||!1,title:this.text,data:this.value}):yet.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 rot}}ret.register("popup",not);class iot extends ret{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 s=(a+r.length+1)%r.length,o=i.x,l=i.y,h=r[s].x,c=r[s].y;l>e!=c>e&&t<(h-o)*(e-l)/(c-l)+o&&(n=!n)})),n}}ret.register("path",iot);const aot={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 sot extends net{contains(t,e){var{x1:r,y1:n,x2:i,y2:a,x3:s,y3:o}=this.state,l=[r,n,i,a,s,o],h=!1;for(let r=0;r<l.length;r+=2){let n=(r+2)%l.length,i=l[r],a=l[r+1],s=l[n+1];a>e!=s>e&&t<(l[n]-i)*(e-a)/(s-a)+i&&(h=!h)}return h}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 aot}}ret.memoize(sot.prototype,"path",!1),ret.register("triangle",sot);const oot={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"number",label:"ratio",name:"ratio",property:"ratio"}],help:"scene/component/donut"};var lot={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 hot extends wst{is3dish(){return!1}render(t){var{ratio:e=50,cx:r,cy:n,rx:i,ry:a,startAngle:s,endAngle:o,anticlockwise:l}=this.state;i=Math.abs(i),a=Math.abs(a),t.beginPath(),t.ellipse(r,n,i,a,0,s||0,o||2*Math.PI,l),t.moveTo(r+i/100*e,n),t.ellipse(r,n,i/100*e,a/100*e,0,s||0,o||2*Math.PI,!0)}contains(t,e){var{cx:r,cy:n,rx:i,ry:a,ratio:s}=this.state,o=(t-r)/(2*(i=Math.abs(i))-.5),l=(e-n)/(2*(a=Math.abs(a))-.5),h=(t-r)/(i/100*s*2-.5),c=(e-n)/(a/100*s*2-.5),u=!1;return o*o+l*l<.25&&h*h+c*c>.25&&(u=!u),u}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:lot}]}get nature(){return oot}}ret.memoize(hot.prototype,"controls",!1),ret.register("donut",hot);const cot={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 uot,dot,pot,fot,got,vot,mot,yot,bot,wot,xot,Aot,_ot,kot={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 Sot extends wst{is3dish(){return!1}render(t){var{ratio:e=30,wing:r=5,cx:n,cy:i,rx:a,ry:s,startAngle:o,endAngle:l,anticlockwise:h}=this.state;if(r<3)return;const c=1.5707963267948966;var u=2*Math.PI/r,d=a-e/100*a,p=s-e/100*s;t.save(),t.beginPath(),t.translate(n,i),t.moveTo(a*Math.cos(-c),s*Math.sin(-c)),t.lineTo((a-d)*(Math.cos(u-c)+Math.cos(0-c))/2,(s-p)*(Math.sin(u-c)+Math.sin(0-c))/2);for(var f=1;f<r;f++)t.lineTo(a*Math.cos(u*f-c),s*Math.sin(u*f-c)),t.lineTo((a-d)*(Math.cos(u*(f+1)-c)+Math.cos(u*f-c))/2,(s-p)*(Math.sin(u*(f+1)-c)+Math.sin(u*f-c))/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:kot}]}get nature(){return cot}}ret.memoize(Sot.prototype,"controls",!1),ret.register("star",Sot);
|
|
71
72
|
/**
|
|
72
73
|
* @licstart The following is the entire license notice for the
|
|
73
74
|
* JavaScript code in this page
|
|
@@ -88,4 +89,4 @@ class Qat extends uat{constructor(){super(...arguments),this.renderOptions={host
|
|
|
88
89
|
*
|
|
89
90
|
* @licend The above is the entire license notice for the
|
|
90
91
|
* JavaScript code in this page
|
|
91
|
-
*/var Eot={d:(t,e)=>{for(var r in e)Eot.o(e,r)&&!Eot.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},Mot=globalThis.pdfjsLib={};Eot.d(Mot,{AbortException:()=>Blt,AnnotationEditorLayer:()=>OAt,AnnotationEditorParamsType:()=>Uot,AnnotationEditorType:()=>Wot,AnnotationEditorUIManager:()=>Kct,AnnotationLayer:()=>Iyt,AnnotationMode:()=>zot,ColorPicker:()=>owt,DOMSVGFactory:()=>Zvt,DrawLayer:()=>YAt,FeatureTest:()=>Hlt,GlobalWorkerOptions:()=>Dft,ImageKind:()=>Kot,InvalidPDFException:()=>Dlt,MissingPDFException:()=>Flt,OPS:()=>xlt,OutputScale:()=>bht,PDFDataRangeTransport:()=>uvt,PDFDateString:()=>dht,PDFWorker:()=>_vt,PasswordResponses:()=>Alt,PermissionFlag:()=>Hot,PixelsPerInch:()=>Zlt,RenderingCancelledException:()=>nht,TextLayer:()=>Ugt,TouchManager:()=>$ut,UnexpectedResponseException:()=>Nlt,Util:()=>Ylt,VerbosityLevel:()=>wlt,XfaLayer:()=>tmt,build:()=>Xvt,createValidAbsoluteUrl:()=>Plt,fetchData:()=>tht,getDocument:()=>ovt,getFilenameFromUrl:()=>sht,getPdfFilenameFromUrl:()=>oht,getXfaPageViewport:()=>fht,isDataScheme:()=>iht,isPdfFile:()=>aht,noContextMenu:()=>cht,normalizeUnicode:()=>Klt,setLayerDimensions:()=>yht,shadow:()=>Ilt,stopEvent:()=>uht,version:()=>qvt});var Tot=!("object"!=typeof process||process+""!="[object process]"||process.versions.nw||process.versions.electron&&process.type&&"browser"!==process.type),Cot=[1,0,0,1,0,0],Pot=[.001,0,0,.001,0,0],Iot=1.35,Rot=1,Oot=2,Lot=4,Dot=16,Fot=32,Not=64,jot=128,Bot=256,zot={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},Wot={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15},Uot={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,HIGHLIGHT_COLOR:31,HIGHLIGHT_DEFAULT_COLOR:32,HIGHLIGHT_THICKNESS:33,HIGHLIGHT_FREE:34,HIGHLIGHT_SHOW_ALL:35,DRAW_STEP:41},Hot={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},Got=0,Yot=1,Vot=2,qot=3,Xot=3,$ot=4,Kot={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},Qot=1,Jot=2,Zot=3,tlt=4,elt=5,rlt=6,nlt=7,ilt=8,alt=9,slt=10,olt=11,llt=12,hlt=13,clt=14,ult=15,dlt=16,plt=17,flt=20,glt=1,vlt=2,mlt=3,ylt=4,blt=5,wlt={ERRORS:0,WARNINGS:1,INFOS:5},xlt={dependency:1,setLineWidth:2,setLineCap:3,setLineJoin:4,setMiterLimit:5,setDash:6,setRenderingIntent:7,setFlatness:8,setGState:9,save:10,restore:11,transform:12,moveTo:13,lineTo:14,curveTo:15,curveTo2:16,curveTo3:17,closePath:18,rectangle:19,stroke:20,closeStroke:21,fill:22,eoFill:23,fillStroke:24,eoFillStroke:25,closeFillStroke:26,closeEOFillStroke:27,endPath:28,clip:29,eoClip:30,beginText:31,endText:32,setCharSpacing:33,setWordSpacing:34,setHScale:35,setLeading:36,setFont:37,setTextRenderingMode:38,setTextRise:39,moveText:40,setLeadingMoveText:41,setTextMatrix:42,nextLine:43,showText:44,showSpacedText:45,nextLineShowText:46,nextLineSetSpacingShowText:47,setCharWidth:48,setCharWidthAndBounds:49,setStrokeColorSpace:50,setFillColorSpace:51,setStrokeColor:52,setStrokeColorN:53,setFillColor:54,setFillColorN:55,setStrokeGray:56,setFillGray:57,setStrokeRGBColor:58,setFillRGBColor:59,setStrokeCMYKColor:60,setFillCMYKColor:61,shadingFill:62,beginInlineImage:63,beginImageData:64,endInlineImage:65,paintXObject:66,markPoint:67,markPointProps:68,beginMarkedContent:69,beginMarkedContentProps:70,endMarkedContent:71,beginCompat:72,endCompat:73,paintFormXObjectBegin:74,paintFormXObjectEnd:75,beginGroup:76,endGroup:77,beginAnnotation:80,endAnnotation:81,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageXObject:85,paintInlineImageXObject:86,paintInlineImageXObjectGroup:87,paintImageXObjectRepeat:88,paintImageMaskXObjectRepeat:89,paintSolidColorImageMask:90,constructPath:91,setStrokeTransparent:92,setFillTransparent:93},Alt={NEED_PASSWORD:1,INCORRECT_PASSWORD:2},_lt=wlt.WARNINGS;function klt(t){Number.isInteger(t)&&(_lt=t)}function Slt(){return _lt}function Elt(t){_lt>=wlt.INFOS&&console.log("Info: ".concat(t))}function Mlt(t){_lt>=wlt.WARNINGS&&console.log("Warning: ".concat(t))}function Tlt(t){throw new Error(t)}function Clt(t,e){t||Tlt(e)}function Plt(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;if(!t)return null;try{if(r&&"string"==typeof t){if(r.addDefaultProtocol&&t.startsWith("www.")){var n=t.match(/\./g);(null==n?void 0:n.length)>=2&&(t="http://".concat(t))}if(r.tryConvertEncoding)try{t=decodeURIComponent(escape(t))}catch(t){}}var i=e?new URL(t,e):new URL(t);if(function(t){switch(null==t?void 0:t.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}(i))return i}catch(t){}return null}function Ilt(t,e,r){var n=arguments.length>3&&void 0!==arguments[3]&&arguments[3];return Object.defineProperty(t,e,{value:r,enumerable:!n,configurable:!0,writable:!1}),r}var Rlt=function(){function t(t,e){this.message=t,this.name=e}return t.prototype=new Error,t.constructor=t,t}();class Olt extends Rlt{constructor(t,e){super(t,"PasswordException"),this.code=e}}class Llt extends Rlt{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}class Dlt extends Rlt{constructor(t){super(t,"InvalidPDFException")}}class Flt extends Rlt{constructor(t){super(t,"MissingPDFException")}}class Nlt extends Rlt{constructor(t,e){super(t,"UnexpectedResponseException"),this.status=e}}class jlt extends Rlt{constructor(t){super(t,"FormatError")}}class Blt extends Rlt{constructor(t){super(t,"AbortException")}}function zlt(t){"object"==typeof t&&void 0!==(null==t?void 0:t.length)||Tlt("Invalid argument for bytesToString");var e=t.length,r=8192;if(e<r)return String.fromCharCode.apply(null,t);for(var n=[],i=0;i<e;i+=r){var a=Math.min(i+r,e),s=t.subarray(i,a);n.push(String.fromCharCode.apply(null,s))}return n.join("")}function Wlt(t){"string"!=typeof t&&Tlt("Invalid argument for stringToBytes");for(var e=t.length,r=new Uint8Array(e),n=0;n<e;++n)r[n]=255&t.charCodeAt(n);return r}function Ult(t){var e=Object.create(null);for(var[r,n]of t)e[r]=n;return e}class Hlt{static get isLittleEndian(){return Ilt(this,"isLittleEndian",((t=new Uint8Array(4))[0]=1,1===new Uint32Array(t.buffer,0,1)[0]));var t}static get isEvalSupported(){return Ilt(this,"isEvalSupported",function(){try{return new Function(""),!0}catch(t){return!1}}())}static get isOffscreenCanvasSupported(){return Ilt(this,"isOffscreenCanvasSupported","undefined"!=typeof OffscreenCanvas)}static get isImageDecoderSupported(){return Ilt(this,"isImageDecoderSupported","undefined"!=typeof ImageDecoder)}static get platform(){var t,e;return"undefined"!=typeof navigator&&"string"==typeof(null===(t=navigator)||void 0===t?void 0:t.platform)?Ilt(this,"platform",{isMac:navigator.platform.includes("Mac"),isWindows:navigator.platform.includes("Win"),isFirefox:"string"==typeof(null===(e=navigator)||void 0===e?void 0:e.userAgent)&&navigator.userAgent.includes("Firefox")}):Ilt(this,"platform",{isMac:!1,isWindows:!1,isFirefox:!1})}static get isCSSRoundSupported(){var t,e;return Ilt(this,"isCSSRoundSupported",null===(t=globalThis.CSS)||void 0===t||null===(e=t.supports)||void 0===e?void 0:e.call(t,"width: round(1.5px, 1px)"))}}var Glt=Array.from(Array(256).keys(),(t=>t.toString(16).padStart(2,"0")));class Ylt{static makeHexColor(t,e,r){return"#".concat(Glt[t]).concat(Glt[e]).concat(Glt[r])}static scaleMinMax(t,e){var r;t[0]?(t[0]<0&&(r=e[0],e[0]=e[2],e[2]=r),e[0]*=t[0],e[2]*=t[0],t[3]<0&&(r=e[1],e[1]=e[3],e[3]=r),e[1]*=t[3],e[3]*=t[3]):(r=e[0],e[0]=e[1],e[1]=r,r=e[2],e[2]=e[3],e[3]=r,t[1]<0&&(r=e[1],e[1]=e[3],e[3]=r),e[1]*=t[1],e[3]*=t[1],t[2]<0&&(r=e[0],e[0]=e[2],e[2]=r),e[0]*=t[2],e[2]*=t[2]),e[0]+=t[4],e[1]+=t[5],e[2]+=t[4],e[3]+=t[5]}static transform(t,e){return[t[0]*e[0]+t[2]*e[1],t[1]*e[0]+t[3]*e[1],t[0]*e[2]+t[2]*e[3],t[1]*e[2]+t[3]*e[3],t[0]*e[4]+t[2]*e[5]+t[4],t[1]*e[4]+t[3]*e[5]+t[5]]}static applyTransform(t,e){return[t[0]*e[0]+t[1]*e[2]+e[4],t[0]*e[1]+t[1]*e[3]+e[5]]}static applyInverseTransform(t,e){var r=e[0]*e[3]-e[1]*e[2];return[(t[0]*e[3]-t[1]*e[2]+e[2]*e[5]-e[4]*e[3])/r,(-t[0]*e[1]+t[1]*e[0]+e[4]*e[1]-e[5]*e[0])/r]}static getAxialAlignedBoundingBox(t,e){var r=this.applyTransform(t,e),n=this.applyTransform(t.slice(2,4),e),i=this.applyTransform([t[0],t[3]],e),a=this.applyTransform([t[2],t[1]],e);return[Math.min(r[0],n[0],i[0],a[0]),Math.min(r[1],n[1],i[1],a[1]),Math.max(r[0],n[0],i[0],a[0]),Math.max(r[1],n[1],i[1],a[1])]}static inverseTransform(t){var e=t[0]*t[3]-t[1]*t[2];return[t[3]/e,-t[1]/e,-t[2]/e,t[0]/e,(t[2]*t[5]-t[4]*t[3])/e,(t[4]*t[1]-t[5]*t[0])/e]}static singularValueDecompose2dScale(t){var e=[t[0],t[2],t[1],t[3]],r=t[0]*e[0]+t[1]*e[2],n=t[0]*e[1]+t[1]*e[3],i=t[2]*e[0]+t[3]*e[2],a=t[2]*e[1]+t[3]*e[3],s=(r+a)/2,o=Math.sqrt(Math.pow(r+a,2)-4*(r*a-i*n))/2,l=s+o||1,h=s-o||1;return[Math.sqrt(l),Math.sqrt(h)]}static normalizeRect(t){var e=t.slice(0);return t[0]>t[2]&&(e[0]=t[2],e[2]=t[0]),t[1]>t[3]&&(e[1]=t[3],e[3]=t[1]),e}static intersect(t,e){var r=Math.max(Math.min(t[0],t[2]),Math.min(e[0],e[2])),n=Math.min(Math.max(t[0],t[2]),Math.max(e[0],e[2]));if(r>n)return null;var i=Math.max(Math.min(t[1],t[3]),Math.min(e[1],e[3])),a=Math.min(Math.max(t[1],t[3]),Math.max(e[1],e[3]));return i>a?null:[r,i,n,a]}static bezierBoundingBox(t,e,r,n,i,a,s,o,l){return l?(l[0]=Math.min(l[0],t,s),l[1]=Math.min(l[1],e,o),l[2]=Math.max(l[2],t,s),l[3]=Math.max(l[3],e,o)):l=[Math.min(t,s),Math.min(e,o),Math.max(t,s),Math.max(e,o)],iit(Ylt,this,qlt).call(this,t,r,i,s,e,n,a,o,3*(3*(r-i)-t+s),6*(t-2*r+i),3*(r-t),l),iit(Ylt,this,qlt).call(this,t,r,i,s,e,n,a,o,3*(3*(n-a)-e+o),6*(e-2*n+a),3*(n-e),l),l}}function Vlt(t,e,r,n,i,a,s,o,l,h){if(!(l<=0||l>=1)){var c=1-l,u=l*l,d=u*l,p=c*(c*(c*t+3*l*e)+3*u*r)+d*n,f=c*(c*(c*i+3*l*a)+3*u*s)+d*o;h[0]=Math.min(h[0],p),h[1]=Math.min(h[1],f),h[2]=Math.max(h[2],p),h[3]=Math.max(h[3],f)}}function qlt(t,e,r,n,i,a,s,o,l,h,c,u){if(Math.abs(l)<1e-12)Math.abs(h)>=1e-12&&iit(uot,this,Vlt).call(this,t,e,r,n,i,a,s,o,-c/h,u);else{var d=Math.pow(h,2)-4*c*l;if(!(d<0)){var p=Math.sqrt(d),f=2*l;iit(uot,this,Vlt).call(this,t,e,r,n,i,a,s,o,(-h+p)/f,u),iit(uot,this,Vlt).call(this,t,e,r,n,i,a,s,o,(-h-p)/f,u)}}}uot=Ylt;var Xlt=null,$lt=null;function Klt(t){return Xlt||(Xlt=/([\xA0\xB5\u037E\u0EB3\u2000-\u200A\u202F\u2126\uFB00-\uFB04\uFB06\uFB20-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBA1\uFBA4-\uFBA9\uFBAE-\uFBB1\uFBD3-\uFBDC\uFBDE-\uFBE7\uFBEA-\uFBF8\uFBFC\uFBFD\uFC00-\uFC5D\uFC64-\uFCF1\uFCF5-\uFD3D\uFD88\uFDF4\uFDFA\uFDFB\uFE71\uFE77\uFE79\uFE7B\uFE7D]+)|(\uFB05+)/g,$lt=new Map([["ſt","ſt"]])),t.replaceAll(Xlt,((t,e,r)=>e?e.normalize("NFKC"):$lt.get(r)))}var Qlt="pdfjs_internal_id_";"function"!=typeof Promise.try&&(Promise.try=function(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),n=1;n<e;n++)r[n-1]=arguments[n];return new Promise((e=>{e(t(...r))}))});var Jlt="http://www.w3.org/2000/svg";class Zlt{}function tht(t){return eht.apply(this,arguments)}function eht(){return eht=sit((function*(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"text";if(hht(t,document.baseURI)){var r=yield fetch(t);if(!r.ok)throw new Error(r.statusText);switch(e){case"arraybuffer":return r.arrayBuffer();case"blob":return r.blob();case"json":return r.json()}return r.text()}return new Promise(((r,n)=>{var i=new XMLHttpRequest;i.open("GET",t,!0),i.responseType=e,i.onreadystatechange=()=>{if(i.readyState===XMLHttpRequest.DONE)if(200!==i.status&&0!==i.status)n(new Error(i.statusText));else{switch(e){case"arraybuffer":case"blob":case"json":return void r(i.response)}r(i.responseText)}},i.send(null)}))})),eht.apply(this,arguments)}dot=Zlt,pit(Zlt,"CSS",96),pit(Zlt,"PDF",72),pit(Zlt,"PDF_TO_CSS_UNITS",dot.CSS/dot.PDF);class rht{constructor(t){var{viewBox:e,userUnit:r,scale:n,rotation:i,offsetX:a=0,offsetY:s=0,dontFlip:o=!1}=t;this.viewBox=e,this.userUnit=r,this.scale=n,this.rotation=i,this.offsetX=a,this.offsetY=s,n*=r;var l,h,c,u,d,p,f,g,v=(e[2]+e[0])/2,m=(e[3]+e[1])/2;switch((i%=360)<0&&(i+=360),i){case 180:l=-1,h=0,c=0,u=1;break;case 90:l=0,h=1,c=1,u=0;break;case 270:l=0,h=-1,c=-1,u=0;break;case 0:l=1,h=0,c=0,u=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}o&&(c=-c,u=-u),0===l?(d=Math.abs(m-e[1])*n+a,p=Math.abs(v-e[0])*n+s,f=(e[3]-e[1])*n,g=(e[2]-e[0])*n):(d=Math.abs(v-e[0])*n+a,p=Math.abs(m-e[1])*n+s,f=(e[2]-e[0])*n,g=(e[3]-e[1])*n),this.transform=[l*n,h*n,c*n,u*n,d-l*n*v-c*n*m,p-h*n*v-u*n*m],this.width=f,this.height=g}get rawDims(){var{userUnit:t,viewBox:e}=this,r=e.map((e=>e*t));return Ilt(this,"rawDims",{pageWidth:r[2]-r[0],pageHeight:r[3]-r[1],pageX:r[0],pageY:r[1]})}clone(){var{scale:t=this.scale,rotation:e=this.rotation,offsetX:r=this.offsetX,offsetY:n=this.offsetY,dontFlip:i=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new rht({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:e,offsetX:r,offsetY:n,dontFlip:i})}convertToViewportPoint(t,e){return Ylt.applyTransform([t,e],this.transform)}convertToViewportRectangle(t){var e=Ylt.applyTransform([t[0],t[1]],this.transform),r=Ylt.applyTransform([t[2],t[3]],this.transform);return[e[0],e[1],r[0],r[1]]}convertToPdfPoint(t,e){return Ylt.applyInverseTransform([t,e],this.transform)}}class nht extends Rlt{constructor(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;super(t,"RenderingCancelledException"),this.extraDelay=e}}function iht(t){for(var e=t.length,r=0;r<e&&""===t[r].trim();)r++;return"data:"===t.substring(r,r+5).toLowerCase()}function aht(t){return"string"==typeof t&&/\.pdf$/i.test(t)}function sht(t){return[t]=t.split(/[#?]/,1),t.substring(t.lastIndexOf("/")+1)}function oht(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"document.pdf";if("string"!=typeof t)return e;if(iht(t))return Mlt('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),e;var r=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i,n=/^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/.exec(t),i=r.exec(n[1])||r.exec(n[2])||r.exec(n[3]);if(i&&(i=i[0]).includes("%"))try{i=r.exec(decodeURIComponent(i))[0]}catch(t){}return i||e}class lht{constructor(){pit(this,"started",Object.create(null)),pit(this,"times",[])}time(t){t in this.started&&Mlt("Timer is already running for ".concat(t)),this.started[t]=Date.now()}timeEnd(t){t in this.started||Mlt("Timer has not been started for ".concat(t)),this.times.push({name:t,start:this.started[t],end:Date.now()}),delete this.started[t]}toString(){var t=[],e=0;for(var{name:r}of this.times)e=Math.max(r.length,e);for(var{name:n,start:i,end:a}of this.times)t.push("".concat(n.padEnd(e)," ").concat(a-i,"ms\n"));return t.join("")}}function hht(t,e){try{var{protocol:r}=e?new URL(t,e):new URL(t);return"http:"===r||"https:"===r}catch(t){return!1}}function cht(t){t.preventDefault()}function uht(t){t.preventDefault(),t.stopPropagation()}class dht{static toDateObject(t){if(!t||"string"!=typeof t)return null;iit(dht,this,pht)._||(pht._=iit(dht,this,new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?")));var e=iit(dht,this,pht)._.exec(t);if(!e)return null;var r=parseInt(e[1],10),n=parseInt(e[2],10);n=n>=1&&n<=12?n-1:0;var i=parseInt(e[3],10);i=i>=1&&i<=31?i:1;var a=parseInt(e[4],10);a=a>=0&&a<=23?a:0;var s=parseInt(e[5],10);s=s>=0&&s<=59?s:0;var o=parseInt(e[6],10);o=o>=0&&o<=59?o:0;var l=e[7]||"Z",h=parseInt(e[8],10);h=h>=0&&h<=23?h:0;var c=parseInt(e[9],10)||0;return c=c>=0&&c<=59?c:0,"-"===l?(a+=h,s+=c):"+"===l&&(a-=h,s-=c),new Date(Date.UTC(r,n,i,a,s,o))}}var pht={_:void 0};function fht(t,e){var{scale:r=1,rotation:n=0}=e,{width:i,height:a}=t.attributes.style,s=[0,0,parseInt(i),parseInt(a)];return new rht({viewBox:s,userUnit:1,scale:r,rotation:n})}function ght(t){if(t.startsWith("#")){var e=parseInt(t.slice(1),16);return[(16711680&e)>>16,(65280&e)>>8,255&e]}return t.startsWith("rgb(")?t.slice(4,-1).split(",").map((t=>parseInt(t))):t.startsWith("rgba(")?t.slice(5,-1).split(",").map((t=>parseInt(t))).slice(0,3):(Mlt('Not a valid color format: "'.concat(t,'"')),[0,0,0])}function vht(t){var{a:e,b:r,c:n,d:i,e:a,f:s}=t.getTransform();return[e,r,n,i,a,s]}function mht(t){var{a:e,b:r,c:n,d:i,e:a,f:s}=t.getTransform().invertSelf();return[e,r,n,i,a,s]}function yht(t,e){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];if(e instanceof rht){var{pageWidth:i,pageHeight:a}=e.rawDims,{style:s}=t,o=Hlt.isCSSRoundSupported,l="var(--scale-factor) * ".concat(i,"px"),h="var(--scale-factor) * ".concat(a,"px"),c=o?"round(down, ".concat(l,", var(--scale-round-x, 1px))"):"calc(".concat(l,")"),u=o?"round(down, ".concat(h,", var(--scale-round-y, 1px))"):"calc(".concat(h,")");r&&e.rotation%180!=0?(s.width=u,s.height=c):(s.width=c,s.height=u)}n&&t.setAttribute("data-main-rotation",e.rotation)}class bht{constructor(){var t=window.devicePixelRatio||1;this.sx=t,this.sy=t}get scaled(){return 1!==this.sx||1!==this.sy}get symmetric(){return this.sx===this.sy}}var wht=new WeakMap,xht=new WeakMap,Aht=new WeakMap,_ht=new WeakMap,kht=new WeakMap,Sht=new WeakSet;class Eht{constructor(t){dit(this,Sht),hit(this,wht,null),hit(this,xht,null),hit(this,Aht,void 0),hit(this,_ht,null),hit(this,kht,null),cit(Aht,this,t),Oht._||(Oht._=Object.freeze({freetext:"pdfjs-editor-remove-freetext-button",highlight:"pdfjs-editor-remove-highlight-button",ink:"pdfjs-editor-remove-ink-button",stamp:"pdfjs-editor-remove-stamp-button"}))}render(){var t=cit(wht,this,document.createElement("div"));t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");var e=lit(Aht,this)._uiManager._signal;t.addEventListener("contextmenu",cht,{signal:e}),t.addEventListener("pointerdown",Mht,{signal:e});var r=cit(_ht,this,document.createElement("div"));r.className="buttons",t.append(r);var n=lit(Aht,this).toolbarPosition;if(n){var{style:i}=t,a="ltr"===lit(Aht,this)._uiManager.direction?1-n[0]:n[0];i.insetInlineEnd="".concat(100*a,"%"),i.top="calc(".concat(100*n[1],"% + var(--editor-toolbar-vert-offset))")}return iit(Sht,this,Iht).call(this),t}get div(){return lit(wht,this)}hide(){var t;lit(wht,this).classList.add("hidden"),null===(t=lit(xht,this))||void 0===t||t.hideDropdown()}show(){var t;lit(wht,this).classList.remove("hidden"),null===(t=lit(kht,this))||void 0===t||t.shown()}addAltText(t){var e=this;return sit((function*(){var r=yield t.render();iit(Sht,e,Pht).call(e,r),lit(_ht,e).prepend(r,uit(Sht,e,Rht)),cit(kht,e,t)}))()}addColorPicker(t){cit(xht,this,t);var e=t.renderButton();iit(Sht,this,Pht).call(this,e),lit(_ht,this).prepend(e,uit(Sht,this,Rht))}remove(){var t;lit(wht,this).remove(),null===(t=lit(xht,this))||void 0===t||t.destroy(),cit(xht,this,null)}}function Mht(t){t.stopPropagation()}function Tht(t){lit(Aht,this)._focusEventsAllowed=!1,uht(t)}function Cht(t){lit(Aht,this)._focusEventsAllowed=!0,uht(t)}function Pht(t){var e=lit(Aht,this)._uiManager._signal;t.addEventListener("focusin",iit(Sht,this,Tht).bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",iit(Sht,this,Cht).bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",cht,{signal:e})}function Iht(){var{editorType:t,_uiManager:e}=lit(Aht,this),r=document.createElement("button");r.className="delete",r.tabIndex=0,r.setAttribute("data-l10n-id",Oht._[t]),iit(Sht,this,Pht).call(this,r),r.addEventListener("click",(t=>{e.delete()}),{signal:e._signal}),lit(_ht,this).append(r)}function Rht(t){var e=document.createElement("div");return e.className="divider",e}var Oht={_:null},Lht=new WeakMap,Dht=new WeakMap,Fht=new WeakMap,Nht=new WeakSet;class jht{constructor(t){dit(this,Nht),hit(this,Lht,null),hit(this,Dht,null),hit(this,Fht,void 0),cit(Fht,this,t)}show(t,e,r){var[n,i]=iit(Nht,this,zht).call(this,e,r),{style:a}=lit(Dht,this)||cit(Dht,this,iit(Nht,this,Bht).call(this));t.append(lit(Dht,this)),a.insetInlineEnd="".concat(100*n,"%"),a.top="calc(".concat(100*i,"% + var(--editor-toolbar-vert-offset))")}hide(){lit(Dht,this).remove()}}function Bht(){var t=cit(Dht,this,document.createElement("div"));t.className="editToolbar",t.setAttribute("role","toolbar"),t.addEventListener("contextmenu",cht,{signal:lit(Fht,this)._signal});var e=cit(Lht,this,document.createElement("div"));return e.className="buttons",t.append(e),iit(Nht,this,Wht).call(this),t}function zht(t,e){var r=0,n=0;for(var i of t){var a=i.y+i.height;if(!(a<r)){var s=i.x+(e?i.width:0);a>r?(n=s,r=a):e?s>n&&(n=s):s<n&&(n=s)}}return[e?1-n:n,r]}function Wht(){var t=document.createElement("button");t.className="highlightButton",t.tabIndex=0,t.setAttribute("data-l10n-id","pdfjs-highlight-floating-button1");var e=document.createElement("span");t.append(e),e.className="visuallyHidden",e.setAttribute("data-l10n-id","pdfjs-highlight-floating-button-label");var r=lit(Fht,this)._signal;t.addEventListener("contextmenu",cht,{signal:r}),t.addEventListener("click",(()=>{lit(Fht,this).highlightSelection("floating_button")}),{signal:r}),lit(Lht,this).append(t)}function Uht(t,e,r){for(var n of r)e.addEventListener(n,t[n].bind(t))}var Hht=new WeakMap;class Ght{constructor(){hit(this,Hht,0)}get id(){var t,e;return"".concat("pdfjs_internal_editor_").concat((cit(Hht,this,(t=lit(Hht,this),e=t++,t)),e))}}var Yht=new WeakMap,Vht=new WeakMap,qht=new WeakMap,Xht=new WeakSet;class $ht{constructor(){dit(this,Xht),hit(this,Yht,function(){if("function"==typeof crypto.randomUUID)return crypto.randomUUID();var t=new Uint8Array(32);return crypto.getRandomValues(t),zlt(t)}()),hit(this,Vht,0),hit(this,qht,null)}static get _isSVGFittingCanvas(){var t=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),e=new Image;return e.src='data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="http://www.w3.org/2000/svg"><rect width="1" height="1" style="fill:red;"/></svg>',Ilt(this,"_isSVGFittingCanvas",e.decode().then((()=>(t.drawImage(e,0,0,1,1,0,0,1,3),0===new Uint32Array(t.getImageData(0,0,1,1).data.buffer)[0]))))}getFromFile(t){var e=this;return sit((function*(){var{lastModified:r,name:n,size:i,type:a}=t;return iit(Xht,e,Kht).call(e,"".concat(r,"_").concat(n,"_").concat(i,"_").concat(a),t)}))()}getFromUrl(t){var e=this;return sit((function*(){return iit(Xht,e,Kht).call(e,t,t)}))()}getFromBlob(t,e){var r=this;return sit((function*(){var n=yield e;return iit(Xht,r,Kht).call(r,t,n)}))()}getFromId(t){var e=this;return sit((function*(){lit(qht,e)||cit(qht,e,new Map);var r=lit(qht,e).get(t);if(!r)return null;if(r.bitmap)return r.refCounter+=1,r;if(r.file)return e.getFromFile(r.file);if(r.blobPromise){var{blobPromise:n}=r;return delete r.blobPromise,e.getFromBlob(r.id,n)}return e.getFromUrl(r.url)}))()}getFromCanvas(t,e){var r,n,i;lit(qht,this)||cit(qht,this,new Map);var a=lit(qht,this).get(t);if(null!==(i=a)&&void 0!==i&&i.bitmap)return a.refCounter+=1,a;var s=new OffscreenCanvas(e.width,e.height);return s.getContext("2d").drawImage(e,0,0),a={bitmap:s.transferToImageBitmap(),id:"image_".concat(lit(Yht,this),"_").concat((cit(Vht,this,(r=lit(Vht,this),n=r++,r)),n)),refCounter:1,isSvg:!1},lit(qht,this).set(t,a),lit(qht,this).set(a.id,a),a}getSvgUrl(t){var e=lit(qht,this).get(t);return null!=e&&e.isSvg?e.svgUrl:null}deleteId(t){var e;lit(qht,this)||cit(qht,this,new Map);var r=lit(qht,this).get(t);if(r&&(r.refCounter-=1,0===r.refCounter)){var{bitmap:n}=r;if(!r.url&&!r.file){var i=new OffscreenCanvas(n.width,n.height);i.getContext("bitmaprenderer").transferFromImageBitmap(n),r.blobPromise=i.convertToBlob()}null===(e=n.close)||void 0===e||e.call(n),r.bitmap=null}}isValidId(t){return t.startsWith("image_".concat(lit(Yht,this),"_"))}}function Kht(t,e){return Qht.apply(this,arguments)}function Qht(){return Qht=sit((function*(t,e){var r;lit(qht,this)||cit(qht,this,new Map);var n=lit(qht,this).get(t);if(null===n)return null;if(null!==(r=n)&&void 0!==r&&r.bitmap)return n.refCounter+=1,n;try{var i,a,s;if(n||(n={bitmap:null,id:"image_".concat(lit(Yht,this),"_").concat((cit(Vht,this,(i=lit(Vht,this),a=i++,i)),a)),refCounter:0,isSvg:!1}),"string"==typeof e?(n.url=e,s=yield tht(e,"blob")):e instanceof File?s=n.file=e:e instanceof Blob&&(s=e),"image/svg+xml"===s.type){var o=pot._isSVGFittingCanvas,l=new FileReader,h=new Image,c=new Promise(((t,e)=>{h.onload=()=>{n.bitmap=h,n.isSvg=!0,t()},l.onload=sit((function*(){var t=n.svgUrl=l.result;h.src=(yield o)?"".concat(t,"#svgView(preserveAspectRatio(none))"):t})),h.onerror=l.onerror=e}));l.readAsDataURL(s),yield c}else n.bitmap=yield createImageBitmap(s);n.refCounter=1}catch(t){Mlt(t),n=null}return lit(qht,this).set(t,n),n&&lit(qht,this).set(n.id,n),n})),Qht.apply(this,arguments)}pot=$ht;var Jht=new WeakMap,Zht=new WeakMap,tct=new WeakMap,ect=new WeakMap;class rct{constructor(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:128;hit(this,Jht,[]),hit(this,Zht,!1),hit(this,tct,void 0),hit(this,ect,-1),cit(tct,this,t)}add(t){var{cmd:e,undo:r,post:n,mustExec:i,type:a=NaN,overwriteIfSameType:s=!1,keepUndo:o=!1}=t;if(i&&e(),!lit(Zht,this)){var l={cmd:e,undo:r,post:n,type:a};if(-1===lit(ect,this))return lit(Jht,this).length>0&&(lit(Jht,this).length=0),cit(ect,this,0),void lit(Jht,this).push(l);if(s&&lit(Jht,this)[lit(ect,this)].type===a)return o&&(l.undo=lit(Jht,this)[lit(ect,this)].undo),void(lit(Jht,this)[lit(ect,this)]=l);var h=lit(ect,this)+1;h===lit(tct,this)?lit(Jht,this).splice(0,1):(cit(ect,this,h),h<lit(Jht,this).length&&lit(Jht,this).splice(h)),lit(Jht,this).push(l)}}undo(){if(-1!==lit(ect,this)){cit(Zht,this,!0);var{undo:t,post:e}=lit(Jht,this)[lit(ect,this)];t(),null==e||e(),cit(Zht,this,!1),cit(ect,this,lit(ect,this)-1)}}redo(){if(lit(ect,this)<lit(Jht,this).length-1){cit(ect,this,lit(ect,this)+1),cit(Zht,this,!0);var{cmd:t,post:e}=lit(Jht,this)[lit(ect,this)];t(),null==e||e(),cit(Zht,this,!1)}}hasSomethingToUndo(){return-1!==lit(ect,this)}hasSomethingToRedo(){return lit(ect,this)<lit(Jht,this).length-1}cleanType(t){if(-1!==lit(ect,this)){for(var e=lit(ect,this);e>=0;e--)if(lit(Jht,this)[e].type!==t)return lit(Jht,this).splice(e+1,lit(ect,this)-e),void cit(ect,this,e);lit(Jht,this).length=0,cit(ect,this,-1)}}destroy(){cit(Jht,this,null)}}var nct=new WeakSet;class ict{constructor(t){dit(this,nct),this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;var{isMac:e}=Hlt.platform;for(var[r,n,i={}]of t)for(var a of r){var s=a.startsWith("mac+");e&&s?(this.callbacks.set(a.slice(4),{callback:n,options:i}),this.allKeys.add(a.split("+").at(-1))):e||s||(this.callbacks.set(a,{callback:n,options:i}),this.allKeys.add(a.split("+").at(-1)))}}exec(t,e){if(this.allKeys.has(e.key)){var r=this.callbacks.get(iit(nct,this,act).call(this,e));if(r){var{callback:n,options:{bubbles:i=!1,args:a=[],checker:s=null}}=r;s&&!s(t,e)||(n.bind(t,...a,e)(),i||uht(e))}}}}function act(t){t.altKey&&this.buffer.push("alt"),t.ctrlKey&&this.buffer.push("ctrl"),t.metaKey&&this.buffer.push("meta"),t.shiftKey&&this.buffer.push("shift"),this.buffer.push(t.key);var e=this.buffer.join("+");return this.buffer.length=0,e}class sct{get _colors(){var t=new Map([["CanvasText",null],["Canvas",null]]);return function(t){var e=document.createElement("span");for(var r of(e.style.visibility="hidden",document.body.append(e),t.keys())){e.style.color=r;var n=window.getComputedStyle(e).color;t.set(r,ght(n))}e.remove()}(t),Ilt(this,"_colors",t)}convert(t){var e=ght(t);if(!window.matchMedia("(forced-colors: active)").matches)return e;for(var[r,n]of this._colors)if(n.every(((t,r)=>t===e[r])))return sct._colorsMapping.get(r);return e}getHexCode(t){var e=this._colors.get(t);return e?Ylt.makeHexColor(...e):t}}pit(sct,"_colorsMapping",new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]));var oct=new WeakMap,lct=new WeakMap,hct=new WeakMap,cct=new WeakMap,uct=new WeakMap,dct=new WeakMap,pct=new WeakMap,fct=new WeakMap,gct=new WeakMap,vct=new WeakMap,mct=new WeakMap,yct=new WeakMap,bct=new WeakMap,wct=new WeakMap,xct=new WeakMap,Act=new WeakMap,_ct=new WeakMap,kct=new WeakMap,Sct=new WeakMap,Ect=new WeakMap,Mct=new WeakMap,Tct=new WeakMap,Cct=new WeakMap,Pct=new WeakMap,Ict=new WeakMap,Rct=new WeakMap,Oct=new WeakMap,Lct=new WeakMap,Dct=new WeakMap,Fct=new WeakMap,Nct=new WeakMap,jct=new WeakMap,Bct=new WeakMap,zct=new WeakMap,Wct=new WeakMap,Uct=new WeakMap,Hct=new WeakMap,Gct=new WeakMap,Yct=new WeakMap,Vct=new WeakMap,qct=new WeakMap,Xct=new WeakMap,$ct=new WeakSet;class Kct{static get _keyboardManager(){var t=Kct.prototype,e=t=>lit(Vct,t).contains(document.activeElement)&&"BUTTON"!==document.activeElement.tagName&&t.hasSomethingToControl(),r=(t,e)=>{var{target:r}=e;if(r instanceof HTMLInputElement){var{type:n}=r;return"text"!==n&&"number"!==n}return!0},n=this.TRANSLATE_SMALL,i=this.TRANSLATE_BIG;return Ilt(this,"_keyboardManager",new ict([[["ctrl+a","mac+meta+a"],t.selectAll,{checker:r}],[["ctrl+z","mac+meta+z"],t.undo,{checker:r}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],t.redo,{checker:r}],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete","mac+Delete"],t.delete,{checker:r}],[["Enter","mac+Enter"],t.addNewEditorFromKeyboard,{checker:(t,e)=>{var{target:r}=e;return!(r instanceof HTMLButtonElement)&&lit(Vct,t).contains(r)&&!t.isEnterHandled}}],[[" ","mac+ "],t.addNewEditorFromKeyboard,{checker:(t,e)=>{var{target:r}=e;return!(r instanceof HTMLButtonElement)&&lit(Vct,t).contains(document.activeElement)}}],[["Escape","mac+Escape"],t.unselectAll],[["ArrowLeft","mac+ArrowLeft"],t.translateSelectedEditors,{args:[-n,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t.translateSelectedEditors,{args:[-i,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t.translateSelectedEditors,{args:[n,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t.translateSelectedEditors,{args:[i,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t.translateSelectedEditors,{args:[0,-n],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t.translateSelectedEditors,{args:[0,-i],checker:e}],[["ArrowDown","mac+ArrowDown"],t.translateSelectedEditors,{args:[0,n],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t.translateSelectedEditors,{args:[0,i],checker:e}]]))}constructor(t,e,r,n,i,a,s,o,l,h,c,u,d){dit(this,$ct),hit(this,oct,new AbortController),hit(this,lct,null),hit(this,hct,new Map),hit(this,cct,new Map),hit(this,uct,null),hit(this,dct,null),hit(this,pct,null),hit(this,fct,new rct),hit(this,gct,null),hit(this,vct,null),hit(this,mct,0),hit(this,yct,new Set),hit(this,bct,null),hit(this,wct,null),hit(this,xct,new Set),pit(this,"_editorUndoBar",null),hit(this,Act,!1),hit(this,_ct,!1),hit(this,kct,!1),hit(this,Sct,null),hit(this,Ect,null),hit(this,Mct,null),hit(this,Tct,null),hit(this,Cct,!1),hit(this,Pct,null),hit(this,Ict,new Ght),hit(this,Rct,!1),hit(this,Oct,!1),hit(this,Lct,null),hit(this,Dct,null),hit(this,Fct,null),hit(this,Nct,null),hit(this,jct,Wot.NONE),hit(this,Bct,new Set),hit(this,zct,null),hit(this,Wct,null),hit(this,Uct,null),hit(this,Hct,{isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1}),hit(this,Gct,[0,0]),hit(this,Yct,null),hit(this,Vct,null),hit(this,qct,null),hit(this,Xct,null);var p=this._signal=lit(oct,this).signal;cit(Vct,this,t),cit(qct,this,e),cit(uct,this,r),this._eventBus=n,n._on("editingaction",this.onEditingAction.bind(this),{signal:p}),n._on("pagechanging",this.onPageChanging.bind(this),{signal:p}),n._on("scalechanging",this.onScaleChanging.bind(this),{signal:p}),n._on("rotationchanging",this.onRotationChanging.bind(this),{signal:p}),n._on("setpreference",this.onSetPreference.bind(this),{signal:p}),n._on("switchannotationeditorparams",(t=>this.updateParams(t.type,t.value)),{signal:p}),iit($ct,this,rut).call(this),iit($ct,this,hut).call(this),iit($ct,this,aut).call(this),cit(dct,this,i.annotationStorage),cit(Sct,this,i.filterFactory),cit(Wct,this,a),cit(Tct,this,s||null),cit(Act,this,o),cit(_ct,this,l),cit(kct,this,h),cit(Nct,this,c||null),this.viewParameters={realScale:Zlt.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=u||null,this._supportsPinchToZoom=!1!==d}destroy(){var t,e,r,n,i;for(var a of(null===(t=lit(Xct,this))||void 0===t||t.resolve(),cit(Xct,this,null),null===(e=lit(oct,this))||void 0===e||e.abort(),cit(oct,this,null),this._signal=null,lit(cct,this).values()))a.destroy();lit(cct,this).clear(),lit(hct,this).clear(),lit(xct,this).clear(),cit(lct,this,null),lit(Bct,this).clear(),lit(fct,this).destroy(),null===(r=lit(uct,this))||void 0===r||r.destroy(),null===(n=lit(Pct,this))||void 0===n||n.hide(),cit(Pct,this,null),lit(Ect,this)&&(clearTimeout(lit(Ect,this)),cit(Ect,this,null)),lit(Yct,this)&&(clearTimeout(lit(Yct,this)),cit(Yct,this,null)),null===(i=this._editorUndoBar)||void 0===i||i.destroy()}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return lit(Nct,this)}get useNewAltTextFlow(){return lit(_ct,this)}get useNewAltTextWhenAddingImage(){return lit(kct,this)}get hcmFilter(){return Ilt(this,"hcmFilter",lit(Wct,this)?lit(Sct,this).addHCMFilter(lit(Wct,this).foreground,lit(Wct,this).background):"none")}get direction(){return Ilt(this,"direction",getComputedStyle(lit(Vct,this)).direction)}get highlightColors(){return Ilt(this,"highlightColors",lit(Tct,this)?new Map(lit(Tct,this).split(",").map((t=>t.split("=").map((t=>t.trim()))))):null)}get highlightColorNames(){return Ilt(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,(t=>t.reverse()))):null)}setCurrentDrawingSession(t){t?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),cit(vct,this,t)}setMainHighlightColorPicker(t){cit(Fct,this,t)}editAltText(t){var e,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];null===(e=lit(uct,this))||void 0===e||e.editAltText(this,t,r)}switchToMode(t,e){this._eventBus.on("annotationeditormodechanged",e,{once:!0,signal:this._signal}),this._eventBus.dispatch("showannotationeditorui",{source:this,mode:t})}setPreference(t,e){this._eventBus.dispatch("setpreference",{source:this,name:t,value:e})}onSetPreference(t){var{name:e,value:r}=t;if("enableNewAltTextWhenAddingImage"===e)cit(kct,this,r)}onPageChanging(t){var{pageNumber:e}=t;cit(mct,this,e-1)}focusMainContainer(){lit(Vct,this).focus()}findParent(t,e){for(var r of lit(cct,this).values()){var{x:n,y:i,width:a,height:s}=r.div.getBoundingClientRect();if(t>=n&&t<=n+a&&e>=i&&e<=i+s)return r}return null}disableUserSelect(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];lit(qct,this).classList.toggle("noUserSelect",t)}addShouldRescale(t){lit(xct,this).add(t)}removeShouldRescale(t){lit(xct,this).delete(t)}onScaleChanging(t){var e,{scale:r}=t;for(var n of(this.commitOrRemove(),this.viewParameters.realScale=r*Zlt.PDF_TO_CSS_UNITS,lit(xct,this)))n.onScaleChanging();null===(e=lit(vct,this))||void 0===e||e.onScaleChanging()}onRotationChanging(t){var{pagesRotation:e}=t;this.commitOrRemove(),this.viewParameters.rotation=e}highlightSelection(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",e=document.getSelection();if(e&&!e.isCollapsed){var{anchorNode:r,anchorOffset:n,focusNode:i,focusOffset:a}=e,s=e.toString(),o=iit($ct,this,Qct).call(this,e).closest(".textLayer"),l=this.getSelectionBoxes(o);if(l){e.empty();var h=iit($ct,this,Jct).call(this,o),c=lit(jct,this)===Wot.NONE,u=()=>{null==h||h.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:l,anchorNode:r,anchorOffset:n,focusNode:i,focusOffset:a,text:s}),c&&this.showAllEditors("highlight",!0,!0)};c?this.switchToMode(Wot.HIGHLIGHT,u):u()}}}addToAnnotationStorage(t){t.isEmpty()||!lit(dct,this)||lit(dct,this).has(t.id)||lit(dct,this).setValue(t.id,t)}blur(){if(this.isShiftKeyDown=!1,lit(Cct,this)&&(cit(Cct,this,!1),iit($ct,this,eut).call(this,"main_toolbar")),this.hasSelection){var{activeElement:t}=document;for(var e of lit(Bct,this))if(e.div.contains(t)){cit(Dct,this,[e,t]),e._focusEventsAllowed=!1;break}}}focus(){if(lit(Dct,this)){var[t,e]=lit(Dct,this);cit(Dct,this,null),e.addEventListener("focusin",(()=>{t._focusEventsAllowed=!0}),{once:!0,signal:this._signal}),e.focus()}}addEditListeners(){iit($ct,this,aut).call(this),iit($ct,this,out).call(this)}removeEditListeners(){iit($ct,this,sut).call(this),iit($ct,this,lut).call(this)}dragOver(t){for(var{type:e}of t.dataTransfer.items)for(var r of lit(wct,this))if(r.isHandlingMimeForPasting(e))return t.dataTransfer.dropEffect="copy",void t.preventDefault()}drop(t){for(var e of t.dataTransfer.items)for(var r of lit(wct,this))if(r.isHandlingMimeForPasting(e.type))return r.paste(e,this.currentLayer),void t.preventDefault()}copy(t){var e;if(t.preventDefault(),null===(e=lit(lct,this))||void 0===e||e.commitOrRemove(),this.hasSelection){var r=[];for(var n of lit(Bct,this)){var i=n.serialize(!0);i&&r.push(i)}0!==r.length&&t.clipboardData.setData("application/pdfjs",JSON.stringify(r))}}cut(t){this.copy(t),this.delete()}paste(t){var e=this;return sit((function*(){t.preventDefault();var{clipboardData:r}=t;for(var n of r.items)for(var i of lit(wct,e))if(i.isHandlingMimeForPasting(n.type))return void i.paste(n,e.currentLayer);var a=r.getData("application/pdfjs");if(a){try{a=JSON.parse(a)}catch(t){return void Mlt('paste: "'.concat(t.message,'".'))}if(Array.isArray(a)){e.unselectAll();var s=e.currentLayer;try{var o=[];for(var l of a){var h=yield s.deserialize(l);if(!h)return;o.push(h)}e.addCommands({cmd:()=>{for(var t of o)iit($ct,e,gut).call(e,t);iit($ct,e,yut).call(e,o)},undo:()=>{for(var t of o)t.remove()},mustExec:!0})}catch(t){Mlt('paste: "'.concat(t.message,'".'))}}}}))()}keydown(t){this.isShiftKeyDown||"Shift"!==t.key||(this.isShiftKeyDown=!0),lit(jct,this)===Wot.NONE||this.isEditorHandlingKeyboard||Kct._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&"Shift"===t.key&&(this.isShiftKeyDown=!1,lit(Cct,this)&&(cit(Cct,this,!1),iit($ct,this,eut).call(this,"main_toolbar")))}onEditingAction(t){var{name:e}=t;switch(e){case"undo":case"redo":case"delete":case"selectAll":this[e]();break;case"highlightSelection":this.highlightSelection("context_menu")}}setEditingState(t){t?(iit($ct,this,nut).call(this),iit($ct,this,out).call(this),iit($ct,this,cut).call(this,{isEditing:lit(jct,this)!==Wot.NONE,isEmpty:iit($ct,this,mut).call(this),hasSomethingToUndo:lit(fct,this).hasSomethingToUndo(),hasSomethingToRedo:lit(fct,this).hasSomethingToRedo(),hasSelectedEditor:!1})):(iit($ct,this,iut).call(this),iit($ct,this,lut).call(this),iit($ct,this,cut).call(this,{isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!lit(wct,this))for(var e of(cit(wct,this,t),lit(wct,this)))iit($ct,this,uut).call(this,e.defaultPropertiesToUpdate)}getId(){return lit(Ict,this).id}get currentLayer(){return lit(cct,this).get(lit(mct,this))}getLayer(t){return lit(cct,this).get(t)}get currentPageIndex(){return lit(mct,this)}addLayer(t){lit(cct,this).set(t.pageIndex,t),lit(Rct,this)?t.enable():t.disable()}removeLayer(t){lit(cct,this).delete(t.pageIndex)}updateMode(t){var e=arguments,r=this;return sit((function*(){var n=e.length>1&&void 0!==e[1]?e[1]:null,i=e.length>2&&void 0!==e[2]&&e[2];if(lit(jct,r)!==t&&(!lit(Xct,r)||(yield lit(Xct,r).promise,lit(Xct,r)))){var a;if(cit(Xct,r,Promise.withResolvers()),cit(jct,r,t),t===Wot.NONE)return r.setEditingState(!1),iit($ct,r,fut).call(r),null===(a=r._editorUndoBar)||void 0===a||a.hide(),void lit(Xct,r).resolve();for(var s of(r.setEditingState(!0),yield iit($ct,r,dut).call(r),r.unselectAll(),lit(cct,r).values()))s.updateMode(t);if(!n)return i&&r.addNewEditorFromKeyboard(),void lit(Xct,r).resolve();for(var o of lit(hct,r).values())o.annotationElementId===n?(r.setSelected(o),o.enterInEditMode()):o.unselect();lit(Xct,r).resolve()}}))()}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t!==lit(jct,this)&&this._eventBus.dispatch("switchannotationeditormode",{source:this,mode:t})}updateParams(t,e){var r;if(lit(wct,this)){switch(t){case Uot.CREATE:return void this.currentLayer.addNewEditor();case Uot.HIGHLIGHT_DEFAULT_COLOR:null===(r=lit(Fct,this))||void 0===r||r.updateColor(e);break;case Uot.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(lit(Uct,this)||cit(Uct,this,new Map)).set(t,e),this.showAllEditors("highlight",e)}for(var n of lit(Bct,this))n.updateParams(t,e);for(var i of lit(wct,this))i.updateDefaultParams(t,e)}}showAllEditors(t,e){var r,n;for(var i of lit(hct,this).values())i.editorType===t&&i.show(e);(null===(r=null===(n=lit(Uct,this))||void 0===n?void 0:n.get(Uot.HIGHLIGHT_SHOW_ALL))||void 0===r||r)!==e&&iit($ct,this,uut).call(this,[[Uot.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(lit(Oct,this)!==t)for(var e of(cit(Oct,this,t),lit(cct,this).values()))t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}getEditors(t){var e=[];for(var r of lit(hct,this).values())r.pageIndex===t&&e.push(r);return e}getEditor(t){return lit(hct,this).get(t)}addEditor(t){lit(hct,this).set(t.id,t)}removeEditor(t){var e;(t.div.contains(document.activeElement)&&(lit(Ect,this)&&clearTimeout(lit(Ect,this)),cit(Ect,this,setTimeout((()=>{this.focusMainContainer(),cit(Ect,this,null)}),0))),lit(hct,this).delete(t.id),this.unselect(t),t.annotationElementId&&lit(yct,this).has(t.annotationElementId))||(null===(e=lit(dct,this))||void 0===e||e.remove(t.id))}addDeletedAnnotationElement(t){lit(yct,this).add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return lit(yct,this).has(t)}removeDeletedAnnotationElement(t){lit(yct,this).delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}setActiveEditor(t){lit(lct,this)!==t&&(cit(lct,this,t),t&&iit($ct,this,uut).call(this,t.propertiesToUpdate))}updateUI(t){uit($ct,this,vut)===t&&iit($ct,this,uut).call(this,t.propertiesToUpdate)}updateUIForDefaultProperties(t){iit($ct,this,uut).call(this,t.defaultPropertiesToUpdate)}toggleSelected(t){if(lit(Bct,this).has(t))return lit(Bct,this).delete(t),t.unselect(),void iit($ct,this,cut).call(this,{hasSelectedEditor:this.hasSelection});lit(Bct,this).add(t),t.select(),iit($ct,this,uut).call(this,t.propertiesToUpdate),iit($ct,this,cut).call(this,{hasSelectedEditor:!0})}setSelected(t){var e;for(var r of(null===(e=lit(vct,this))||void 0===e||e.commitOrRemove(),lit(Bct,this)))r!==t&&r.unselect();lit(Bct,this).clear(),lit(Bct,this).add(t),t.select(),iit($ct,this,uut).call(this,t.propertiesToUpdate),iit($ct,this,cut).call(this,{hasSelectedEditor:!0})}isSelected(t){return lit(Bct,this).has(t)}get firstSelectedEditor(){return lit(Bct,this).values().next().value}unselect(t){t.unselect(),lit(Bct,this).delete(t),iit($ct,this,cut).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return 0!==lit(Bct,this).size}get isEnterHandled(){return 1===lit(Bct,this).size&&this.firstSelectedEditor.isEnterHandled}undo(){var t;lit(fct,this).undo(),iit($ct,this,cut).call(this,{hasSomethingToUndo:lit(fct,this).hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:iit($ct,this,mut).call(this)}),null===(t=this._editorUndoBar)||void 0===t||t.hide()}redo(){lit(fct,this).redo(),iit($ct,this,cut).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:lit(fct,this).hasSomethingToRedo(),isEmpty:iit($ct,this,mut).call(this)})}addCommands(t){lit(fct,this).add(t),iit($ct,this,cut).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:iit($ct,this,mut).call(this)})}cleanUndoStack(t){lit(fct,this).cleanType(t)}delete(){var t;this.commitOrRemove();var e=null===(t=this.currentLayer)||void 0===t?void 0:t.endDrawingSession(!0);if(this.hasSelection||e){var r=e?[e]:[...lit(Bct,this)],n=()=>{for(var t of r)iit($ct,this,gut).call(this,t)};this.addCommands({cmd:()=>{var t;for(var e of(null===(t=this._editorUndoBar)||void 0===t||t.show(n,1===r.length?r[0].editorType:r.length),r))e.remove()},undo:n,mustExec:!0})}}commitOrRemove(){var t;null===(t=lit(lct,this))||void 0===t||t.commitOrRemove()}hasSomethingToControl(){return lit(lct,this)||this.hasSelection}selectAll(){for(var t of lit(Bct,this))t.commit();iit($ct,this,yut).call(this,lit(hct,this).values())}unselectAll(){var t;if((!lit(lct,this)||(lit(lct,this).commitOrRemove(),lit(jct,this)===Wot.NONE))&&(null===(t=lit(vct,this))||void 0===t||!t.commitOrRemove())&&this.hasSelection){for(var e of lit(Bct,this))e.unselect();lit(Bct,this).clear(),iit($ct,this,cut).call(this,{hasSelectedEditor:!1})}}translateSelectedEditors(t,e){if(arguments.length>2&&void 0!==arguments[2]&&arguments[2]||this.commitOrRemove(),this.hasSelection){lit(Gct,this)[0]+=t,lit(Gct,this)[1]+=e;var[r,n]=lit(Gct,this),i=[...lit(Bct,this)];for(var a of(lit(Yct,this)&&clearTimeout(lit(Yct,this)),cit(Yct,this,setTimeout((()=>{cit(Yct,this,null),lit(Gct,this)[0]=lit(Gct,this)[1]=0,this.addCommands({cmd:()=>{for(var t of i)lit(hct,this).has(t.id)&&t.translateInPage(r,n)},undo:()=>{for(var t of i)lit(hct,this).has(t.id)&&t.translateInPage(-r,-n)},mustExec:!1})}),1e3)),i))a.translateInPage(t,e)}}setUpDragSession(){if(this.hasSelection)for(var t of(this.disableUserSelect(!0),cit(bct,this,new Map),lit(Bct,this)))lit(bct,this).set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}endDragSession(){if(!lit(bct,this))return!1;this.disableUserSelect(!1);var t=lit(bct,this);cit(bct,this,null);var e=!1;for(var[{x:r,y:n,pageIndex:i},a]of t)a.newX=r,a.newY=n,a.newPageIndex=i,e||(e=r!==a.savedX||n!==a.savedY||i!==a.savedPageIndex);if(!e)return!1;var s=(t,e,r,n)=>{if(lit(hct,this).has(t.id)){var i=lit(cct,this).get(n);i?t._setParentAndPosition(i,e,r):(t.pageIndex=n,t.x=e,t.y=r)}};return this.addCommands({cmd:()=>{for(var[e,{newX:r,newY:n,newPageIndex:i}]of t)s(e,r,n,i)},undo:()=>{for(var[e,{savedX:r,savedY:n,savedPageIndex:i}]of t)s(e,r,n,i)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(lit(bct,this))for(var r of lit(bct,this).keys())r.drag(t,e)}rebuild(t){if(null===t.parent){var e=this.getLayer(t.pageIndex);e?(e.changeParent(t),e.addOrRebuild(t)):(this.addEditor(t),this.addToAnnotationStorage(t),t.rebuild())}else t.parent.addOrRebuild(t)}get isEditorHandlingKeyboard(){var t;return(null===(t=this.getActive())||void 0===t?void 0:t.shouldGetKeyboardEvents())||1===lit(Bct,this).size&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return lit(lct,this)===t}getActive(){return lit(lct,this)}getMode(){return lit(jct,this)}get imageManager(){return Ilt(this,"imageManager",new $ht)}getSelectionBoxes(t){if(!t)return null;for(var e=document.getSelection(),r=0,n=e.rangeCount;r<n;r++)if(!t.contains(e.getRangeAt(r).commonAncestorContainer))return null;var i,{x:a,y:s,width:o,height:l}=t.getBoundingClientRect();switch(t.getAttribute("data-main-rotation")){case"90":i=(t,e,r,n)=>({x:(e-s)/l,y:1-(t+r-a)/o,width:n/l,height:r/o});break;case"180":i=(t,e,r,n)=>({x:1-(t+r-a)/o,y:1-(e+n-s)/l,width:r/o,height:n/l});break;case"270":i=(t,e,r,n)=>({x:1-(e+n-s)/l,y:(t-a)/o,width:n/l,height:r/o});break;default:i=(t,e,r,n)=>({x:(t-a)/o,y:(e-s)/l,width:r/o,height:n/l})}for(var h=[],c=0,u=e.rangeCount;c<u;c++){var d=e.getRangeAt(c);if(!d.collapsed)for(var{x:p,y:f,width:g,height:v}of d.getClientRects())0!==g&&0!==v&&h.push(i(p,f,g,v))}return 0===h.length?null:h}addChangedExistingAnnotation(t){var{annotationElementId:e,id:r}=t;(lit(pct,this)||cit(pct,this,new Map)).set(e,r)}removeChangedExistingAnnotation(t){var e,{annotationElementId:r}=t;null===(e=lit(pct,this))||void 0===e||e.delete(r)}renderAnnotationElement(t){var e,r=null===(e=lit(pct,this))||void 0===e?void 0:e.get(t.data.id);if(r){var n=lit(dct,this).getRawValue(r);n&&(lit(jct,this)!==Wot.NONE||n.hasBeenModified)&&n.renderAnnotationElement(t)}}}function Qct(t){var{anchorNode:e}=t;return e.nodeType===Node.TEXT_NODE?e.parentElement:e}function Jct(t){var{currentLayer:e}=this;if(e.hasTextLayer(t))return e;for(var r of lit(cct,this).values())if(r.hasTextLayer(t))return r;return null}function Zct(){var t=document.getSelection();if(t&&!t.isCollapsed){var e=iit($ct,this,Qct).call(this,t).closest(".textLayer"),r=this.getSelectionBoxes(e);r&&(lit(Pct,this)||cit(Pct,this,new jht(this)),lit(Pct,this).show(e,r,"ltr"===this.direction))}}function tut(){var t,e=document.getSelection();if(e&&!e.isCollapsed){var{anchorNode:r}=e;if(r!==lit(zct,this)){var n,i=iit($ct,this,Qct).call(this,e).closest(".textLayer");if(i){if(null===(t=lit(Pct,this))||void 0===t||t.hide(),cit(zct,this,r),iit($ct,this,cut).call(this,{hasSelectedText:!0}),(lit(jct,this)===Wot.HIGHLIGHT||lit(jct,this)===Wot.NONE)&&(lit(jct,this)===Wot.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),cit(Cct,this,this.isShiftKeyDown),!this.isShiftKeyDown)){var a=lit(jct,this)===Wot.HIGHLIGHT?iit($ct,this,Jct).call(this,i):null;null==a||a.toggleDrawing();var s=new AbortController,o=this.combinedSignal(s),l=t=>{"pointerup"===t.type&&0!==t.button||(s.abort(),null==a||a.toggleDrawing(!0),"pointerup"===t.type&&iit($ct,this,eut).call(this,"main_toolbar"))};window.addEventListener("pointerup",l,{signal:o}),window.addEventListener("blur",l,{signal:o})}}else lit(zct,this)&&(null===(n=lit(Pct,this))||void 0===n||n.hide(),cit(zct,this,null),iit($ct,this,cut).call(this,{hasSelectedText:!1}))}}else{var h;lit(zct,this)&&(null===(h=lit(Pct,this))||void 0===h||h.hide(),cit(zct,this,null),iit($ct,this,cut).call(this,{hasSelectedText:!1}))}}function eut(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";lit(jct,this)===Wot.HIGHLIGHT?this.highlightSelection(t):lit(Act,this)&&iit($ct,this,Zct).call(this)}function rut(){document.addEventListener("selectionchange",iit($ct,this,tut).bind(this),{signal:this._signal})}function nut(){if(!lit(Mct,this)){cit(Mct,this,new AbortController);var t=this.combinedSignal(lit(Mct,this));window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})}}function iut(){var t;null===(t=lit(Mct,this))||void 0===t||t.abort(),cit(Mct,this,null)}function aut(){if(!lit(Lct,this)){cit(Lct,this,new AbortController);var t=this.combinedSignal(lit(Lct,this));window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})}}function sut(){var t;null===(t=lit(Lct,this))||void 0===t||t.abort(),cit(Lct,this,null)}function out(){if(!lit(gct,this)){cit(gct,this,new AbortController);var t=this.combinedSignal(lit(gct,this));document.addEventListener("copy",this.copy.bind(this),{signal:t}),document.addEventListener("cut",this.cut.bind(this),{signal:t}),document.addEventListener("paste",this.paste.bind(this),{signal:t})}}function lut(){var t;null===(t=lit(gct,this))||void 0===t||t.abort(),cit(gct,this,null)}function hut(){var t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})}function cut(t){var e=Object.entries(t).some((t=>{var[e,r]=t;return lit(Hct,this)[e]!==r}));e&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(lit(Hct,this),t)}),lit(jct,this)===Wot.HIGHLIGHT&&!1===t.hasSelectedEditor&&iit($ct,this,uut).call(this,[[Uot.HIGHLIGHT_FREE,!0]]))}function uut(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})}function dut(){return put.apply(this,arguments)}function put(){return(put=sit((function*(){if(!lit(Rct,this)){cit(Rct,this,!0);var t=[];for(var e of lit(cct,this).values())t.push(e.enable());for(var r of(yield Promise.all(t),lit(hct,this).values()))r.enable()}}))).apply(this,arguments)}function fut(){if(this.unselectAll(),lit(Rct,this)){for(var t of(cit(Rct,this,!1),lit(cct,this).values()))t.disable();for(var e of lit(hct,this).values())e.disable()}}function gut(t){var e=lit(cct,this).get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))}function vut(t){var e=null;for(e of lit(Bct,t));return e}function mut(){if(0===lit(hct,this).size)return!0;if(1===lit(hct,this).size)for(var t of lit(hct,this).values())return t.isEmpty();return!1}function yut(t){for(var e of lit(Bct,this))e.unselect();for(var r of(lit(Bct,this).clear(),t))r.isEmpty()||(lit(Bct,this).add(r),r.select());iit($ct,this,cut).call(this,{hasSelectedEditor:this.hasSelection})}pit(Kct,"TRANSLATE_SMALL",1),pit(Kct,"TRANSLATE_BIG",10);var but=new WeakMap,wut=new WeakMap,xut=new WeakMap,Aut=new WeakMap,_ut=new WeakMap,kut=new WeakMap,Sut=new WeakMap,Eut=new WeakMap,Mut=new WeakMap,Tut=new WeakMap,Cut=new WeakMap,Put=new WeakMap,Iut=new WeakSet;class Rut{constructor(t){dit(this,Iut),hit(this,but,null),hit(this,wut,!1),hit(this,xut,null),hit(this,Aut,null),hit(this,_ut,null),hit(this,kut,null),hit(this,Sut,!1),hit(this,Eut,null),hit(this,Mut,null),hit(this,Tut,null),hit(this,Cut,null),hit(this,Put,!1),cit(Mut,this,t),cit(Put,this,t._uiManager.useNewAltTextFlow),Fut._||(Fut._=Object.freeze({added:"pdfjs-editor-new-alt-text-added-button","added-label":"pdfjs-editor-new-alt-text-added-button-label",missing:"pdfjs-editor-new-alt-text-missing-button","missing-label":"pdfjs-editor-new-alt-text-missing-button-label",review:"pdfjs-editor-new-alt-text-to-review-button","review-label":"pdfjs-editor-new-alt-text-to-review-button-label"}))}static initialize(t){var e;null!==(e=Rut._l10n)&&void 0!==e||(Rut._l10n=t)}render(){var t=this;return sit((function*(){var e=cit(xut,t,document.createElement("button"));e.className="altText",e.tabIndex="0";var r=cit(Aut,t,document.createElement("span"));e.append(r),lit(Put,t)?(e.classList.add("new"),e.setAttribute("data-l10n-id",Fut._.missing),r.setAttribute("data-l10n-id",Fut._["missing-label"])):(e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),r.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));var n=lit(Mut,t)._uiManager._signal;e.addEventListener("contextmenu",cht,{signal:n}),e.addEventListener("pointerdown",(t=>t.stopPropagation()),{signal:n});var i=e=>{e.preventDefault(),lit(Mut,t)._uiManager.editAltText(lit(Mut,t)),lit(Put,t)&&lit(Mut,t)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:uit(Iut,t,Out)}})};return e.addEventListener("click",i,{capture:!0,signal:n}),e.addEventListener("keydown",(r=>{r.target===e&&"Enter"===r.key&&(cit(Sut,t,!0),i(r))}),{signal:n}),yield iit(Iut,t,Lut).call(t),e}))()}finish(){lit(xut,this)&&(lit(xut,this).focus({focusVisible:lit(Sut,this)}),cit(Sut,this,!1))}isEmpty(){return lit(Put,this)?null===lit(but,this):!lit(but,this)&&!lit(wut,this)}hasData(){return lit(Put,this)?null!==lit(but,this)||!!lit(Tut,this):this.isEmpty()}get guessedText(){return lit(Tut,this)}setGuessedText(t){var e=this;return sit((function*(){null===lit(but,e)&&(cit(Tut,e,t),cit(Cut,e,yield Rut._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t})),iit(Iut,e,Lut).call(e))}))()}toggleAltTextBadge(){var t,e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(!lit(Put,this)||lit(but,this))return null===(t=lit(Eut,this))||void 0===t||t.remove(),void cit(Eut,this,null);if(!lit(Eut,this)){var r=cit(Eut,this,document.createElement("div"));r.className="noAltTextBadge",lit(Mut,this).div.append(r)}lit(Eut,this).classList.toggle("hidden",!e)}serialize(t){var e=lit(but,this);return t||lit(Tut,this)!==e||(e=lit(Cut,this)),{altText:e,decorative:lit(wut,this),guessedText:lit(Tut,this),textWithDisclaimer:lit(Cut,this)}}get data(){return{altText:lit(but,this),decorative:lit(wut,this)}}set data(t){var{altText:e,decorative:r,guessedText:n,textWithDisclaimer:i,cancel:a=!1}=t;n&&(cit(Tut,this,n),cit(Cut,this,i)),lit(but,this)===e&&lit(wut,this)===r||(a||(cit(but,this,e),cit(wut,this,r)),iit(Iut,this,Lut).call(this))}toggle(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];lit(xut,this)&&(!t&&lit(kut,this)&&(clearTimeout(lit(kut,this)),cit(kut,this,null)),lit(xut,this).disabled=!t)}shown(){lit(Mut,this)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:uit(Iut,this,Out)}})}destroy(){var t,e;null===(t=lit(xut,this))||void 0===t||t.remove(),cit(xut,this,null),cit(Aut,this,null),cit(_ut,this,null),null===(e=lit(Eut,this))||void 0===e||e.remove(),cit(Eut,this,null)}}function Out(t){return(lit(but,t)?"added":null===lit(but,t)&&t.guessedText&&"review")||"missing"}function Lut(){return Dut.apply(this,arguments)}function Dut(){return(Dut=sit((function*(){var t=lit(xut,this);if(t){if(lit(Put,this)){var e,r;if(t.classList.toggle("done",!!lit(but,this)),t.setAttribute("data-l10n-id",Fut._[uit(Iut,this,Out)]),null===(e=lit(Aut,this))||void 0===e||e.setAttribute("data-l10n-id",Fut._["".concat(uit(Iut,this,Out),"-label")]),!lit(but,this))return void(null===(r=lit(_ut,this))||void 0===r||r.remove())}else{var n;if(!lit(but,this)&&!lit(wut,this))return t.classList.remove("done"),void(null===(n=lit(_ut,this))||void 0===n||n.remove());t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}var i=lit(_ut,this);if(!i){cit(_ut,this,i=document.createElement("span")),i.className="tooltip",i.setAttribute("role","tooltip"),i.id="alt-text-tooltip-".concat(lit(Mut,this).id);var a=lit(Mut,this)._uiManager._signal;a.addEventListener("abort",(()=>{clearTimeout(lit(kut,this)),cit(kut,this,null)}),{once:!0}),t.addEventListener("mouseenter",(()=>{cit(kut,this,setTimeout((()=>{cit(kut,this,null),lit(_ut,this).classList.add("show"),lit(Mut,this)._reportTelemetry({action:"alt_text_tooltip"})}),100))}),{signal:a}),t.addEventListener("mouseleave",(()=>{var t;lit(kut,this)&&(clearTimeout(lit(kut,this)),cit(kut,this,null)),null===(t=lit(_ut,this))||void 0===t||t.classList.remove("show")}),{signal:a})}lit(wut,this)?i.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(i.removeAttribute("data-l10n-id"),i.textContent=lit(but,this)),i.parentNode||t.append(i);var s=lit(Mut,this).getImageForAltText();null==s||s.setAttribute("aria-describedby",i.id)}}))).apply(this,arguments)}var Fut={_:null};pit(Rut,"_l10n",null);var Nut=new WeakMap,jut=new WeakMap,But=new WeakMap,zut=new WeakMap,Wut=new WeakMap,Uut=new WeakMap,Hut=new WeakMap,Gut=new WeakMap,Yut=new WeakMap,Vut=new WeakMap,qut=new WeakMap,Xut=new WeakSet;class $ut{constructor(t){var{container:e,isPinchingDisabled:r=null,isPinchingStopped:n=null,onPinchStart:i=null,onPinching:a=null,onPinchEnd:s=null,signal:o}=t;dit(this,Xut),hit(this,Nut,void 0),hit(this,jut,!1),hit(this,But,null),hit(this,zut,void 0),hit(this,Wut,void 0),hit(this,Uut,void 0),hit(this,Hut,void 0),hit(this,Gut,void 0),hit(this,Yut,null),hit(this,Vut,void 0),hit(this,qut,null),cit(Nut,this,e),cit(But,this,n),cit(zut,this,r),cit(Wut,this,i),cit(Uut,this,a),cit(Hut,this,s),cit(Vut,this,new AbortController),cit(Gut,this,AbortSignal.any([o,lit(Vut,this).signal])),e.addEventListener("touchstart",iit(Xut,this,Kut).bind(this),{passive:!1,signal:lit(Gut,this)})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return Ilt(this,"MIN_TOUCH_DISTANCE_TO_PINCH",35/(window.devicePixelRatio||1))}destroy(){var t;null===(t=lit(Vut,this))||void 0===t||t.abort(),cit(Vut,this,null)}}function Kut(t){var e,r;if(!(null!==(e=lit(zut,this))&&void 0!==e&&e.call(this)||t.touches.length<2)){if(!lit(qut,this)){var n;cit(qut,this,new AbortController);var i=AbortSignal.any([lit(Gut,this),lit(qut,this).signal]),a=lit(Nut,this),s={signal:i,passive:!1};a.addEventListener("touchmove",iit(Xut,this,Qut).bind(this),s),a.addEventListener("touchend",iit(Xut,this,Jut).bind(this),s),a.addEventListener("touchcancel",iit(Xut,this,Jut).bind(this),s),null===(n=lit(Wut,this))||void 0===n||n.call(this)}if(uht(t),2!==t.touches.length||null!==(r=lit(But,this))&&void 0!==r&&r.call(this))cit(Yut,this,null);else{var[o,l]=t.touches;o.identifier>l.identifier&&([o,l]=[l,o]),cit(Yut,this,{touch0X:o.screenX,touch0Y:o.screenY,touch1X:l.screenX,touch1Y:l.screenY})}}}function Qut(t){var e;if(lit(Yut,this)&&2===t.touches.length){var[r,n]=t.touches;r.identifier>n.identifier&&([r,n]=[n,r]);var{screenX:i,screenY:a}=r,{screenX:s,screenY:o}=n,l=lit(Yut,this),{touch0X:h,touch0Y:c,touch1X:u,touch1Y:d}=l,p=u-h,f=d-c,g=s-i,v=o-a,m=Math.hypot(g,v)||1,y=Math.hypot(p,f)||1;if(lit(jut,this)||!(Math.abs(y-m)<=fot.MIN_TOUCH_DISTANCE_TO_PINCH))if(l.touch0X=i,l.touch0Y=a,l.touch1X=s,l.touch1Y=o,t.preventDefault(),lit(jut,this)){var b=[(i+s)/2,(a+o)/2];null===(e=lit(Uut,this))||void 0===e||e.call(this,b,y,m)}else cit(jut,this,!0)}}function Jut(t){var e;lit(qut,this).abort(),cit(qut,this,null),null===(e=lit(Hut,this))||void 0===e||e.call(this),lit(Yut,this)&&(t.preventDefault(),cit(Yut,this,null),cit(jut,this,!1))}fot=$ut;var Zut=new WeakMap,tdt=new WeakMap,edt=new WeakMap,rdt=new WeakMap,ndt=new WeakMap,idt=new WeakMap,adt=new WeakMap,sdt=new WeakMap,odt=new WeakMap,ldt=new WeakMap,hdt=new WeakMap,cdt=new WeakMap,udt=new WeakMap,ddt=new WeakMap,pdt=new WeakMap,fdt=new WeakMap,gdt=new WeakMap,vdt=new WeakMap,mdt=new WeakMap,ydt=new WeakMap,bdt=new WeakMap,wdt=new WeakMap,xdt=new WeakMap,Adt=new WeakMap,_dt=new WeakSet;class kdt{static get _resizerKeyboardManager(){var t=kdt.prototype._resizeWithKeyboard,e=Kct.TRANSLATE_SMALL,r=Kct.TRANSLATE_BIG;return Ilt(this,"_resizerKeyboardManager",new ict([[["ArrowLeft","mac+ArrowLeft"],t,{args:[-e,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t,{args:[-r,0]}],[["ArrowRight","mac+ArrowRight"],t,{args:[e,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t,{args:[r,0]}],[["ArrowUp","mac+ArrowUp"],t,{args:[0,-e]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t,{args:[0,-r]}],[["ArrowDown","mac+ArrowDown"],t,{args:[0,e]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t,{args:[0,r]}],[["Escape","mac+Escape"],kdt.prototype._stopResizingWithKeyboard]]))}constructor(t){dit(this,_dt),hit(this,Zut,null),hit(this,tdt,null),hit(this,edt,null),hit(this,rdt,!1),hit(this,ndt,null),hit(this,idt,""),hit(this,adt,!1),hit(this,sdt,null),hit(this,odt,null),hit(this,ldt,null),hit(this,hdt,null),hit(this,cdt,""),hit(this,udt,!1),hit(this,ddt,null),hit(this,pdt,!1),hit(this,fdt,!1),hit(this,gdt,!1),hit(this,vdt,null),hit(this,mdt,0),hit(this,ydt,0),hit(this,bdt,null),hit(this,wdt,null),pit(this,"_editToolbar",null),pit(this,"_initialOptions",Object.create(null)),pit(this,"_initialData",null),pit(this,"_isVisible",!0),pit(this,"_uiManager",null),pit(this,"_focusEventsAllowed",!0),hit(this,xdt,!1),hit(this,Adt,kdt._zIndex++),this.parent=t.parent,this.id=t.id,this.width=this.height=null,this.pageIndex=t.parent.pageIndex,this.name=t.name,this.div=null,this._uiManager=t.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=t.isCentered,this._structTreeParentId=null;var{rotation:e,rawDims:{pageWidth:r,pageHeight:n,pageX:i,pageY:a}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[r,n],this.pageTranslation=[i,a];var[s,o]=this.parentDimensions;this.x=t.x/s,this.y=t.y/o,this.isAttachedToDOM=!1,this.deleted=!1}get editorType(){return Object.getPrototypeOf(this).constructor._type}static get isDrawer(){return!1}static get _defaultLineColor(){return Ilt(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){var e=new Gdt({id:t.parent.getNextId(),parent:t.parent,uiManager:t._uiManager});e.annotationElementId=t.annotationElementId,e.deleted=!0,e._uiManager.addToAnnotationStorage(e)}static initialize(t,e){var r;if(null!==(r=kdt._l10n)&&void 0!==r||(kdt._l10n=t),kdt._l10nResizer||(kdt._l10nResizer=Object.freeze({topLeft:"pdfjs-editor-resizer-top-left",topMiddle:"pdfjs-editor-resizer-top-middle",topRight:"pdfjs-editor-resizer-top-right",middleRight:"pdfjs-editor-resizer-middle-right",bottomRight:"pdfjs-editor-resizer-bottom-right",bottomMiddle:"pdfjs-editor-resizer-bottom-middle",bottomLeft:"pdfjs-editor-resizer-bottom-left",middleLeft:"pdfjs-editor-resizer-middle-left"})),-1===kdt._borderLineWidth){var n=getComputedStyle(document.documentElement);kdt._borderLineWidth=parseFloat(n.getPropertyValue("--outline-width"))||0}}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){Tlt("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return lit(xdt,this)}set _isDraggable(t){var e;cit(xdt,this,t),null===(e=this.div)||void 0===e||e.classList.toggle("draggable",t)}get isEnterHandled(){return!0}center(){var[t,e]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*e/(2*t),this.y+=this.width*t/(2*e);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*e/(2*t),this.y-=this.width*t/(2*e);break;default:this.x-=this.width/2,this.y-=this.height/2}this.fixAndSetPosition()}addCommands(t){this._uiManager.addCommands(t)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=lit(Adt,this)}setParent(t){null!==t?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):iit(_dt,this,Hdt).call(this),this.parent=t}focusin(t){this._focusEventsAllowed&&(lit(udt,this)?cit(udt,this,!1):this.parent.setSelected(this))}focusout(t){var e;if(this._focusEventsAllowed&&this.isAttachedToDOM){var r=t.relatedTarget;null!=r&&r.closest("#".concat(this.id))||(t.preventDefault(),null!==(e=this.parent)&&void 0!==e&&e.isMultipleSelection||this.commitOrRemove())}}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(t,e,r,n){var[i,a]=this.parentDimensions;[r,n]=this.screenToPageTranslation(r,n),this.x=(t+r)/i,this.y=(e+n)/a,this.fixAndSetPosition()}translate(t,e){iit(_dt,this,Sdt).call(this,this.parentDimensions,t,e)}translateInPage(t,e){lit(ddt,this)||cit(ddt,this,[this.x,this.y,this.width,this.height]),iit(_dt,this,Sdt).call(this,this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}drag(t,e){lit(ddt,this)||cit(ddt,this,[this.x,this.y,this.width,this.height]);var{div:r,parentDimensions:[n,i]}=this;if(this.x+=t/n,this.y+=e/i,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){var{x:a,y:s}=this.div.getBoundingClientRect();this.parent.findNewParent(this,a,s)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}var{x:o,y:l}=this,[h,c]=this.getBaseTranslation();o+=h,l+=c;var{style:u}=r;u.left="".concat((100*o).toFixed(2),"%"),u.top="".concat((100*l).toFixed(2),"%"),this._onTranslating(o,l),r.scrollIntoView({block:"nearest"})}_onTranslating(t,e){}_onTranslated(t,e){}get _hasBeenMoved(){return!!lit(ddt,this)&&(lit(ddt,this)[0]!==this.x||lit(ddt,this)[1]!==this.y)}get _hasBeenResized(){return!!lit(ddt,this)&&(lit(ddt,this)[2]!==this.width||lit(ddt,this)[3]!==this.height)}getBaseTranslation(){var[t,e]=this.parentDimensions,{_borderLineWidth:r}=kdt,n=r/t,i=r/e;switch(this.rotation){case 90:return[-n,i];case 180:return[n,i];case 270:return[n,-i];default:return[-n,-i]}}get _mustFixPosition(){return!0}fixAndSetPosition(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.rotation,{div:{style:e},pageDimensions:[r,n]}=this,{x:i,y:a,width:s,height:o}=this;if(s*=r,o*=n,i*=r,a*=n,this._mustFixPosition)switch(t){case 0:i=Math.max(0,Math.min(r-s,i)),a=Math.max(0,Math.min(n-o,a));break;case 90:i=Math.max(0,Math.min(r-o,i)),a=Math.min(n,Math.max(s,a));break;case 180:i=Math.min(r,Math.max(s,i)),a=Math.min(n,Math.max(o,a));break;case 270:i=Math.min(r,Math.max(o,i)),a=Math.max(0,Math.min(n-s,a))}this.x=i/=r,this.y=a/=n;var[l,h]=this.getBaseTranslation();i+=l,a+=h,e.left="".concat((100*i).toFixed(2),"%"),e.top="".concat((100*a).toFixed(2),"%"),this.moveInDOM()}screenToPageTranslation(t,e){return Edt.call(kdt,t,e,this.parentRotation)}pageTranslationToScreen(t,e){return Edt.call(kdt,t,e,360-this.parentRotation)}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){var{parentScale:t,pageDimensions:[e,r]}=this;return[e*t,r*t]}setDims(t,e){var[r,n]=this.parentDimensions,{style:i}=this.div;i.width="".concat((100*t/r).toFixed(2),"%"),lit(adt,this)||(i.height="".concat((100*e/n).toFixed(2),"%"))}fixDims(){var{style:t}=this.div,{height:e,width:r}=t,n=r.endsWith("%"),i=!lit(adt,this)&&e.endsWith("%");if(!n||!i){var[a,s]=this.parentDimensions;n||(t.width="".concat((100*parseFloat(r)/a).toFixed(2),"%")),lit(adt,this)||i||(t.height="".concat((100*parseFloat(e)/s).toFixed(2),"%"))}}getInitialTranslation(){return[0,0]}_onResized(){}static _round(t){return Math.round(1e4*t)/1e4}_onResizing(){}altTextFinish(){var t;null===(t=lit(edt,this))||void 0===t||t.finish()}addEditToolbar(){var t=this;return sit((function*(){return t._editToolbar||lit(fdt,t)||(t._editToolbar=new Eht(t),t.div.append(t._editToolbar.render()),lit(edt,t)&&(yield t._editToolbar.addAltText(lit(edt,t)))),t._editToolbar}))()}removeEditToolbar(){var t;this._editToolbar&&(this._editToolbar.remove(),this._editToolbar=null,null===(t=lit(edt,this))||void 0===t||t.destroy())}addContainer(t){var e,r=null===(e=this._editToolbar)||void 0===e?void 0:e.div;r?r.before(t):this.div.append(t)}getClientDimensions(){return this.div.getBoundingClientRect()}addAltTextButton(){var t=this;return sit((function*(){lit(edt,t)||(Rut.initialize(kdt._l10n),cit(edt,t,new Rut(t)),lit(Zut,t)&&(lit(edt,t).data=lit(Zut,t),cit(Zut,t,null)),yield t.addEditToolbar())}))()}get altTextData(){var t;return null===(t=lit(edt,this))||void 0===t?void 0:t.data}set altTextData(t){lit(edt,this)&&(lit(edt,this).data=t)}get guessedAltText(){var t;return null===(t=lit(edt,this))||void 0===t?void 0:t.guessedText}setGuessedAltText(t){var e=this;return sit((function*(){var r;yield null===(r=lit(edt,e))||void 0===r?void 0:r.setGuessedText(t)}))()}serializeAltText(t){var e;return null===(e=lit(edt,this))||void 0===e?void 0:e.serialize(t)}hasAltText(){return!!lit(edt,this)&&!lit(edt,this).isEmpty()}hasAltTextData(){var t,e;return null!==(t=null===(e=lit(edt,this))||void 0===e?void 0:e.hasData())&&void 0!==t&&t}render(){var t;this.div=document.createElement("div"),this.div.setAttribute("data-editor-rotation",(360-this.rotation)%360),this.div.className=this.name,this.div.setAttribute("id",this.id),this.div.tabIndex=lit(rdt,this)?-1:0,this._isVisible||this.div.classList.add("hidden"),this.setInForeground(),iit(_dt,this,jdt).call(this);var[e,r]=this.parentDimensions;this.parentRotation%180!=0&&(this.div.style.maxWidth="".concat((100*r/e).toFixed(2),"%"),this.div.style.maxHeight="".concat((100*e/r).toFixed(2),"%"));var[n,i]=this.getInitialTranslation();return this.translate(n,i),Uht(this,this.div,["pointerdown"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(lit(wdt,this)||cit(wdt,this,new $ut({container:this.div,isPinchingDisabled:()=>!this.isSelected,onPinchStart:iit(_dt,this,Odt).bind(this),onPinching:iit(_dt,this,Ldt).bind(this),onPinchEnd:iit(_dt,this,Ddt).bind(this),signal:this._uiManager._signal}))),null===(t=this._uiManager._editorUndoBar)||void 0===t||t.hide(),this.div}pointerdown(t){var{isMac:e}=Hlt.platform;0!==t.button||t.ctrlKey&&e?t.preventDefault():(cit(udt,this,!0),this._isDraggable?iit(_dt,this,Ndt).call(this,t):iit(_dt,this,Fdt).call(this,t))}get isSelected(){return this._uiManager.isSelected(this)}_onStartDragging(){}_onStopDragging(){}moveInDOM(){lit(vdt,this)&&clearTimeout(lit(vdt,this)),cit(vdt,this,setTimeout((()=>{var t;cit(vdt,this,null),null===(t=this.parent)||void 0===t||t.moveEditorInDOM(this)}),0))}_setParentAndPosition(t,e,r){t.changeParent(this),this.x=e,this.y=r,this.fixAndSetPosition(),this._onTranslated()}getRect(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.rotation,n=this.parentScale,[i,a]=this.pageDimensions,[s,o]=this.pageTranslation,l=t/n,h=e/n,c=this.x*i,u=this.y*a,d=this.width*i,p=this.height*a;switch(r){case 0:return[c+l+s,a-u-h-p+o,c+l+d+s,a-u-h+o];case 90:return[c+h+s,a-u+l+o,c+h+p+s,a-u+l+d+o];case 180:return[c-l-d+s,a-u+h+o,c-l+s,a-u+h+p+o];case 270:return[c-h-p+s,a-u-l-d+o,c-h+s,a-u-l+o];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(t,e){var[r,n,i,a]=t,s=i-r,o=a-n;switch(this.rotation){case 0:return[r,e-a,s,o];case 90:return[r,e-n,o,s];case 180:return[i,e-n,s,o];case 270:return[i,e-a,o,s];default:throw new Error("Invalid rotation")}}onceAdded(t){}isEmpty(){return!1}enableEditMode(){cit(fdt,this,!0)}disableEditMode(){cit(fdt,this,!1)}isInEditMode(){return lit(fdt,this)}shouldGetKeyboardEvents(){return lit(gdt,this)}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){var{top:t,left:e,bottom:r,right:n}=this.getClientDimensions(),{innerHeight:i,innerWidth:a}=window;return e<a&&n>0&&t<i&&r>0}rebuild(){iit(_dt,this,jdt).call(this)}rotate(t){}resize(){}serializeDeleted(){var t;return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:(null===(t=this._initialData)||void 0===t?void 0:t.popupRef)||""}}serialize(){Tlt("An editor must be serializable")}static deserialize(t,e,r){var n=this;return sit((function*(){var i=new n.prototype.constructor({parent:e,id:e.getNextId(),uiManager:r});i.rotation=t.rotation,cit(Zut,i,t.accessibilityData);var[a,s]=i.pageDimensions,[o,l,h,c]=i.getRectInCurrentCoords(t.rect,s);return i.x=o/a,i.y=l/s,i.width=h/a,i.height=c/s,i}))()}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||null!==this.serialize())}remove(){var t,e;if(null===(t=lit(hdt,this))||void 0===t||t.abort(),cit(hdt,this,null),this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),lit(vdt,this)&&(clearTimeout(lit(vdt,this)),cit(vdt,this,null)),iit(_dt,this,Hdt).call(this),this.removeEditToolbar(),lit(bdt,this)){for(var r of lit(bdt,this).values())clearTimeout(r);cit(bdt,this,null)}this.parent=null,null===(e=lit(wdt,this))||void 0===e||e.destroy(),cit(wdt,this,null)}get isResizable(){return!1}makeResizable(){this.isResizable&&(iit(_dt,this,Tdt).call(this),lit(sdt,this).classList.remove("hidden"),Uht(this,this.div,["keydown"]))}get toolbarPosition(){return null}keydown(t){if(this.isResizable&&t.target===this.div&&"Enter"===t.key){this._uiManager.setSelected(this),cit(ldt,this,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});var e=lit(sdt,this).children;if(!lit(tdt,this)){cit(tdt,this,Array.from(e));var r=iit(_dt,this,Bdt).bind(this),n=iit(_dt,this,zdt).bind(this),i=this._uiManager._signal;for(var a of lit(tdt,this)){var s=a.getAttribute("data-resizer-name");a.setAttribute("role","spinbutton"),a.addEventListener("keydown",r,{signal:i}),a.addEventListener("blur",n,{signal:i}),a.addEventListener("focus",iit(_dt,this,Wdt).bind(this,s),{signal:i}),a.setAttribute("data-l10n-id",kdt._l10nResizer[s])}}var o=lit(tdt,this)[0],l=0;for(var h of e){if(h===o)break;l++}var c=(360-this.rotation+this.parentRotation)%360/90*(lit(tdt,this).length/4);if(c!==l){if(c<l)for(var u=0;u<l-c;u++)lit(sdt,this).append(lit(sdt,this).firstChild);else if(c>l)for(var d=0;d<c-l;d++)lit(sdt,this).firstChild.before(lit(sdt,this).lastChild);var p=0;for(var f of e){var g=lit(tdt,this)[p++].getAttribute("data-resizer-name");f.setAttribute("data-l10n-id",kdt._l10nResizer[g])}}iit(_dt,this,Udt).call(this,0),cit(gdt,this,!0),lit(sdt,this).firstChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}}_resizeWithKeyboard(t,e){lit(gdt,this)&&iit(_dt,this,Rdt).call(this,lit(cdt,this),{deltaX:t,deltaY:e,fromKeyboard:!0})}_stopResizingWithKeyboard(){iit(_dt,this,Hdt).call(this),this.div.focus()}select(){var t,e,r;this.makeResizable(),null===(t=this.div)||void 0===t||t.classList.add("selectedEditor"),this._editToolbar?(null===(e=this._editToolbar)||void 0===e||e.show(),null===(r=lit(edt,this))||void 0===r||r.toggleAltTextBadge(!1)):this.addEditToolbar().then((()=>{var t,e;null!==(t=this.div)&&void 0!==t&&t.classList.contains("selectedEditor")&&(null===(e=this._editToolbar)||void 0===e||e.show())}))}unselect(){var t,e,r,n,i;null===(t=lit(sdt,this))||void 0===t||t.classList.add("hidden"),null===(e=this.div)||void 0===e||e.classList.remove("selectedEditor"),null!==(r=this.div)&&void 0!==r&&r.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),null===(n=this._editToolbar)||void 0===n||n.hide(),null===(i=lit(edt,this))||void 0===i||i.toggleAltTextBadge(!0)}updateParams(t,e){}disableEditing(){}enableEditing(){}enterInEditMode(){}getImageForAltText(){return null}get contentDiv(){return this.div}get isEditing(){return lit(pdt,this)}set isEditing(t){cit(pdt,this,t),this.parent&&(t?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(t,e){cit(adt,this,!0);var r=t/e,{style:n}=this.div;n.aspectRatio=r,n.height="auto"}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:"added"}}get telemetryFinalData(){return null}_reportTelemetry(t){if(arguments.length>1&&void 0!==arguments[1]&&arguments[1]){lit(bdt,this)||cit(bdt,this,new Map);var{action:e}=t,r=lit(bdt,this).get(e);return r&&clearTimeout(r),r=setTimeout((()=>{this._reportTelemetry(t),lit(bdt,this).delete(e),0===lit(bdt,this).size&&cit(bdt,this,null)}),kdt._telemetryTimeout),void lit(bdt,this).set(e,r)}t.type||(t.type=this.editorType),this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:t}})}show(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this._isVisible;this.div.classList.toggle("hidden",!t),this._isVisible=t}enable(){this.div&&(this.div.tabIndex=0),cit(rdt,this,!1)}disable(){this.div&&(this.div.tabIndex=-1),cit(rdt,this,!0)}renderAnnotationElement(t){var e=t.container.querySelector(".annotationContent");if(e){if("CANVAS"===e.nodeName){var r=e;(e=document.createElement("div")).classList.add("annotationContent",this.editorType),r.before(e)}}else(e=document.createElement("div")).classList.add("annotationContent",this.editorType),t.container.prepend(e);return e}resetAnnotationElement(t){var{firstChild:e}=t.container;"DIV"===(null==e?void 0:e.nodeName)&&e.classList.contains("annotationContent")&&e.remove()}}function Sdt(t,e,r){var[n,i]=t;[e,r]=this.screenToPageTranslation(e,r),this.x+=e/n,this.y+=r/i,this._onTranslating(this.x,this.y),this.fixAndSetPosition()}function Edt(t,e,r){switch(r){case 90:return[e,-t];case 180:return[-t,-e];case 270:return[-e,t];default:return[t,e]}}function Mdt(t){switch(t){case 90:var[e,r]=this.pageDimensions;return[0,-e/r,r/e,0];case 180:return[-1,0,0,-1];case 270:var[n,i]=this.pageDimensions;return[0,n/i,-i/n,0];default:return[1,0,0,1]}}function Tdt(){if(!lit(sdt,this)){cit(sdt,this,document.createElement("div")),lit(sdt,this).classList.add("resizers");var t=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],e=this._uiManager._signal;for(var r of t){var n=document.createElement("div");lit(sdt,this).append(n),n.classList.add("resizer",r),n.setAttribute("data-resizer-name",r),n.addEventListener("pointerdown",iit(_dt,this,Cdt).bind(this,r),{signal:e}),n.addEventListener("contextmenu",cht,{signal:e}),n.tabIndex=-1}this.div.prepend(lit(sdt,this))}}function Cdt(t,e){var r;e.preventDefault();var{isMac:n}=Hlt.platform;if(!(0!==e.button||e.ctrlKey&&n)){null===(r=lit(edt,this))||void 0===r||r.toggle(!1);var i=this._isDraggable;this._isDraggable=!1,cit(odt,this,[e.screenX,e.screenY]);var a=new AbortController,s=this._uiManager.combinedSignal(a);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",iit(_dt,this,Rdt).bind(this,t),{passive:!0,capture:!0,signal:s}),window.addEventListener("touchmove",uht,{passive:!1,signal:s}),window.addEventListener("contextmenu",cht,{signal:s}),cit(ldt,this,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});var o=this.parent.div.style.cursor,l=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(e.target).cursor;var h=()=>{var t;a.abort(),this.parent.togglePointerEvents(!0),null===(t=lit(edt,this))||void 0===t||t.toggle(!0),this._isDraggable=i,this.parent.div.style.cursor=o,this.div.style.cursor=l,iit(_dt,this,Idt).call(this)};window.addEventListener("pointerup",h,{signal:s}),window.addEventListener("blur",h,{signal:s})}}function Pdt(t,e,r,n){this.width=r,this.height=n,this.x=t,this.y=e;var[i,a]=this.parentDimensions;this.setDims(i*r,a*n),this.fixAndSetPosition(),this._onResized()}function Idt(){if(lit(ldt,this)){var{savedX:t,savedY:e,savedWidth:r,savedHeight:n}=lit(ldt,this);cit(ldt,this,null);var i=this.x,a=this.y,s=this.width,o=this.height;i===t&&a===e&&s===r&&o===n||this.addCommands({cmd:iit(_dt,this,Pdt).bind(this,i,a,s,o),undo:iit(_dt,this,Pdt).bind(this,t,e,r,n),mustExec:!0})}}function Rdt(t,e){var r,n,[i,a]=this.parentDimensions,s=this.x,o=this.y,l=this.width,h=this.height,c=got.MIN_SIZE/i,u=got.MIN_SIZE/a,d=iit(_dt,this,Mdt).call(this,this.rotation),p=(t,e)=>[d[0]*t+d[2]*e,d[1]*t+d[3]*e],f=iit(_dt,this,Mdt).call(this,360-this.rotation),g=!1,v=!1;switch(t){case"topLeft":g=!0,r=(t,e)=>[0,0],n=(t,e)=>[t,e];break;case"topMiddle":r=(t,e)=>[t/2,0],n=(t,e)=>[t/2,e];break;case"topRight":g=!0,r=(t,e)=>[t,0],n=(t,e)=>[0,e];break;case"middleRight":v=!0,r=(t,e)=>[t,e/2],n=(t,e)=>[0,e/2];break;case"bottomRight":g=!0,r=(t,e)=>[t,e],n=(t,e)=>[0,0];break;case"bottomMiddle":r=(t,e)=>[t/2,e],n=(t,e)=>[t/2,0];break;case"bottomLeft":g=!0,r=(t,e)=>[0,e],n=(t,e)=>[t,0];break;case"middleLeft":v=!0,r=(t,e)=>[0,e/2],n=(t,e)=>[t,e/2]}var m,y,b=r(l,h),w=n(l,h),x=p(...w),A=got._round(s+x[0]),_=got._round(o+x[1]),k=1,S=1;if(e.fromKeyboard)({deltaX:m,deltaY:y}=e);else{var{screenX:E,screenY:M}=e,[T,C]=lit(odt,this);[m,y]=this.screenToPageTranslation(E-T,M-C),lit(odt,this)[0]=E,lit(odt,this)[1]=M}if([m,y]=((t,e)=>[f[0]*t+f[2]*e,f[1]*t+f[3]*e])(m/i,y/a),g){var P=Math.hypot(l,h);k=S=Math.max(Math.min(Math.hypot(w[0]-b[0]-m,w[1]-b[1]-y)/P,1/l,1/h),c/l,u/h)}else v?k=Math.max(c,Math.min(1,Math.abs(w[0]-b[0]-m)))/l:S=Math.max(u,Math.min(1,Math.abs(w[1]-b[1]-y)))/h;var I=got._round(l*k),R=got._round(h*S),O=A-(x=p(...n(I,R)))[0],L=_-x[1];lit(ddt,this)||cit(ddt,this,[this.x,this.y,this.width,this.height]),this.width=I,this.height=R,this.x=O,this.y=L,this.setDims(i*I,a*R),this.fixAndSetPosition(),this._onResizing()}function Odt(){var t;cit(ldt,this,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height}),null===(t=lit(edt,this))||void 0===t||t.toggle(!1),this.parent.togglePointerEvents(!1)}function Ldt(t,e,r){var n=r/e*.7+1-.7;if(1!==n){var i=iit(_dt,this,Mdt).call(this,this.rotation),a=(t,e)=>[i[0]*t+i[2]*e,i[1]*t+i[3]*e],[s,o]=this.parentDimensions,l=this.x,h=this.y,c=this.width,u=this.height,d=got.MIN_SIZE/s,p=got.MIN_SIZE/o;n=Math.max(Math.min(n,1/c,1/u),d/c,p/u);var f=got._round(c*n),g=got._round(u*n);if(f!==c||g!==u){lit(ddt,this)||cit(ddt,this,[l,h,c,u]);var v=a(c/2,u/2),m=got._round(l+v[0]),y=got._round(h+v[1]),b=a(f/2,g/2);this.x=m-b[0],this.y=y-b[1],this.width=f,this.height=g,this.setDims(s*f,o*g),this.fixAndSetPosition(),this._onResizing()}}}function Ddt(){var t;null===(t=lit(edt,this))||void 0===t||t.toggle(!0),this.parent.togglePointerEvents(!0),iit(_dt,this,Idt).call(this)}function Fdt(t){var{isMac:e}=Hlt.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)}function Ndt(t){var{isSelected:e}=this;this._uiManager.setUpDragSession();var r=!1,n=new AbortController,i=this._uiManager.combinedSignal(n),a={capture:!0,passive:!1,signal:i},s=t=>{n.abort(),cit(ndt,this,null),cit(udt,this,!1),this._uiManager.endDragSession()||iit(_dt,this,Fdt).call(this,t),r&&this._onStopDragging()};e&&(cit(mdt,this,t.clientX),cit(ydt,this,t.clientY),cit(ndt,this,t.pointerId),cit(idt,this,t.pointerType),window.addEventListener("pointermove",(t=>{r||(r=!0,this._onStartDragging());var{clientX:e,clientY:n,pointerId:i}=t;if(i===lit(ndt,this)){var[a,s]=this.screenToPageTranslation(e-lit(mdt,this),n-lit(ydt,this));cit(mdt,this,e),cit(ydt,this,n),this._uiManager.dragSelectedEditors(a,s)}else uht(t)}),a),window.addEventListener("touchmove",uht,a),window.addEventListener("pointerdown",(t=>{t.pointerType===lit(idt,this)&&(lit(wdt,this)||t.isPrimary)&&s(t),uht(t)}),a));var o=t=>{lit(ndt,this)&&lit(ndt,this)!==t.pointerId?uht(t):s(t)};window.addEventListener("pointerup",o,{signal:i}),window.addEventListener("blur",o,{signal:i})}function jdt(){if(!lit(hdt,this)&&this.div){cit(hdt,this,new AbortController);var t=this._uiManager.combinedSignal(lit(hdt,this));this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})}}function Bdt(t){got._resizerKeyboardManager.exec(this,t)}function zdt(t){var e;lit(gdt,this)&&(null===(e=t.relatedTarget)||void 0===e?void 0:e.parentNode)!==lit(sdt,this)&&iit(_dt,this,Hdt).call(this)}function Wdt(t){cit(cdt,this,lit(gdt,this)?t:"")}function Udt(t){if(lit(tdt,this))for(var e of lit(tdt,this))e.tabIndex=t}function Hdt(){cit(gdt,this,!1),iit(_dt,this,Udt).call(this,-1),iit(_dt,this,Idt).call(this)}got=kdt,pit(kdt,"_l10n",null),pit(kdt,"_l10nResizer",null),pit(kdt,"_borderLineWidth",-1),pit(kdt,"_colorManager",new sct),pit(kdt,"_zIndex",1),pit(kdt,"_telemetryTimeout",1e3);class Gdt extends kdt{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}var Ydt=3285377520,Vdt=4294901760,qdt=65535;class Xdt{constructor(t){this.h1=t?4294967295&t:Ydt,this.h2=t?4294967295&t:Ydt}update(t){var e,r;if("string"==typeof t){e=new Uint8Array(2*t.length),r=0;for(var n=0,i=t.length;n<i;n++){var a=t.charCodeAt(n);a<=255?e[r++]=a:(e[r++]=a>>>8,e[r++]=255&a)}}else{if(!ArrayBuffer.isView(t))throw new Error("Invalid data format, must be a string or TypedArray.");r=(e=t.slice()).byteLength}for(var s=r>>2,o=r-4*s,l=new Uint32Array(e.buffer,0,s),h=0,c=0,u=this.h1,d=this.h2,p=3432918353,f=461845907,g=11601,v=13715,m=0;m<s;m++)1&m?u=5*(u=(u^=h=(h=(h=(h=l[m])*p&Vdt|h*g&qdt)<<15|h>>>17)*f&Vdt|h*v&qdt)<<13|u>>>19)+3864292196:d=5*(d=(d^=c=(c=(c=(c=l[m])*p&Vdt|c*g&qdt)<<15|c>>>17)*f&Vdt|c*v&qdt)<<13|d>>>19)+3864292196;switch(h=0,o){case 3:h^=e[4*s+2]<<16;case 2:h^=e[4*s+1]<<8;case 1:h=(h=(h=(h^=e[4*s])*p&Vdt|h*g&qdt)<<15|h>>>17)*f&Vdt|h*v&qdt,1&s?u^=h:d^=h}this.h1=u,this.h2=d}hexdigest(){var t=this.h1,e=this.h2;return t=3981806797*(t^=e>>>1)&Vdt|36045*t&qdt,t=444984403*(t^=(e=4283543511*e&Vdt|(2950163797*(e<<16|t>>>16)&Vdt)>>>16)>>>1)&Vdt|60499*t&qdt,((t^=(e=3301882366*e&Vdt|(3120437893*(e<<16|t>>>16)&Vdt)>>>16)>>>1)>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}var $dt=Object.freeze({map:null,hash:"",transfer:void 0}),Kdt=new WeakMap,Qdt=new WeakMap,Jdt=new WeakMap,Zdt=new WeakSet;class tpt{constructor(){dit(this,Zdt),hit(this,Kdt,!1),hit(this,Qdt,null),hit(this,Jdt,new Map),this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(t,e){var r=lit(Jdt,this).get(t);return void 0===r?e:Object.assign(e,r)}getRawValue(t){return lit(Jdt,this).get(t)}remove(t){if(lit(Jdt,this).delete(t),0===lit(Jdt,this).size&&this.resetModified(),"function"==typeof this.onAnnotationEditor){for(var e of lit(Jdt,this).values())if(e instanceof kdt)return;this.onAnnotationEditor(null)}}setValue(t,e){var r=lit(Jdt,this).get(t),n=!1;if(void 0!==r)for(var[i,a]of Object.entries(e))r[i]!==a&&(n=!0,r[i]=a);else n=!0,lit(Jdt,this).set(t,e);n&&iit(Zdt,this,ept).call(this),e instanceof kdt&&"function"==typeof this.onAnnotationEditor&&this.onAnnotationEditor(e.constructor._type)}has(t){return lit(Jdt,this).has(t)}getAll(){return lit(Jdt,this).size>0?Ult(lit(Jdt,this)):null}setAll(t){for(var[e,r]of Object.entries(t))this.setValue(e,r)}get size(){return lit(Jdt,this).size}resetModified(){lit(Kdt,this)&&(cit(Kdt,this,!1),"function"==typeof this.onResetModified&&this.onResetModified())}get print(){return new npt(this)}get serializable(){if(0===lit(Jdt,this).size)return $dt;var t=new Map,e=new Xdt,r=[],n=Object.create(null),i=!1;for(var[a,s]of lit(Jdt,this)){var o=s instanceof kdt?s.serialize(!1,n):s;o&&(t.set(a,o),e.update("".concat(a,":").concat(JSON.stringify(o))),i||(i=!!o.bitmap))}if(i)for(var l of t.values())l.bitmap&&r.push(l.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:r}:$dt}get editorStats(){var t=null,e=new Map;for(var r of lit(Jdt,this).values()){var n;if(r instanceof kdt){var i=r.telemetryFinalData;if(i){var{type:a}=i;e.has(a)||e.set(a,Object.getPrototypeOf(r).constructor),t||(t=Object.create(null));var s=(n=t)[a]||(n[a]=new Map);for(var[o,l]of Object.entries(i)){var h;if("type"!==o){var c=s.get(o);c||(c=new Map,s.set(o,c));var u=null!==(h=c.get(l))&&void 0!==h?h:0;c.set(l,u+1)}}}}}for(var[d,p]of e)t[d]=p.computeTelemetryFinalData(t[d]);return t}resetModifiedIds(){cit(Qdt,this,null)}get modifiedIds(){if(lit(Qdt,this))return lit(Qdt,this);var t=[];for(var e of lit(Jdt,this).values())e instanceof kdt&&e.annotationElementId&&e.serialize()&&t.push(e.annotationElementId);return cit(Qdt,this,{ids:new Set(t),hash:t.join(",")})}}function ept(){lit(Kdt,this)||(cit(Kdt,this,!0),"function"==typeof this.onSetModified&&this.onSetModified())}var rpt=new WeakMap;class npt extends tpt{constructor(t){super(),hit(this,rpt,void 0);var{map:e,hash:r,transfer:n}=t.serializable,i=structuredClone(e,n?{transfer:n}:null);cit(rpt,this,{map:i,hash:r,transfer:n})}get print(){Tlt("Should not call PrintAnnotationStorage.print")}get serializable(){return lit(rpt,this)}get modifiedIds(){return Ilt(this,"modifiedIds",{ids:new Set,hash:""})}}var ipt=new WeakMap;class apt{constructor(t){var{ownerDocument:e=globalThis.document,styleElement:r=null}=t;hit(this,ipt,new Set),this._document=e,this.nativeFontFaces=new Set,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(t){this.nativeFontFaces.add(t),this._document.fonts.add(t)}removeNativeFontFace(t){this.nativeFontFaces.delete(t),this._document.fonts.delete(t)}insertRule(t){this.styleElement||(this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement));var e=this.styleElement.sheet;e.insertRule(t,e.cssRules.length)}clear(){for(var t of this.nativeFontFaces)this._document.fonts.delete(t);this.nativeFontFaces.clear(),lit(ipt,this).clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}loadSystemFont(t){var e=this;return sit((function*(){var{systemFontInfo:r,_inspectFont:n}=t;if(r&&!lit(ipt,e).has(r.loadedName))if(Clt(!e.disableFontFace,"loadSystemFont shouldn't be called when `disableFontFace` is set."),e.isFontLoadingAPISupported){var{loadedName:i,src:a,style:s}=r,o=new FontFace(i,a,s);e.addNativeFontFace(o);try{yield o.load(),lit(ipt,e).add(i),null==n||n(r)}catch(t){Mlt("Cannot load system font: ".concat(r.baseFontName,", installing it could help to improve PDF rendering.")),e.removeNativeFontFace(o)}}else Tlt("Not implemented: loadSystemFont without the Font Loading API.")}))()}bind(t){var e=this;return sit((function*(){if(!(t.attached||t.missingFile&&!t.systemFontInfo))if(t.attached=!0,t.systemFontInfo)yield e.loadSystemFont(t);else if(e.isFontLoadingAPISupported){var r=t.createNativeFontFace();if(r){e.addNativeFontFace(r);try{yield r.loaded}catch(e){throw Mlt("Failed to load font '".concat(r.family,"': '").concat(e,"'.")),t.disableFontFace=!0,e}}}else{var n=t.createFontFaceRule();if(n){if(e.insertRule(n),e.isSyncFontLoadingSupported)return;yield new Promise((r=>{var n=e._queueLoadingCallback(r);e._prepareFontLoadEvent(t,n)}))}}}))()}get isFontLoadingAPISupported(){var t;return Ilt(this,"isFontLoadingAPISupported",!(null===(t=this._document)||void 0===t||!t.fonts))}get isSyncFontLoadingSupported(){var t,e=!1;return(Tot||"undefined"!=typeof navigator&&"string"==typeof(null===(t=navigator)||void 0===t?void 0:t.userAgent)&&/Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent))&&(e=!0),Ilt(this,"isSyncFontLoadingSupported",e)}_queueLoadingCallback(t){var{loadingRequests:e}=this,r={done:!1,complete:function(){for(Clt(!r.done,"completeRequest() cannot be called twice."),r.done=!0;e.length>0&&e[0].done;){var t=e.shift();setTimeout(t.callback,0)}},callback:t};return e.push(r),r}get _loadTestFont(){return Ilt(this,"_loadTestFont",atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA=="))}_prepareFontLoadEvent(t,e){function r(t,e){return t.charCodeAt(e)<<24|t.charCodeAt(e+1)<<16|t.charCodeAt(e+2)<<8|255&t.charCodeAt(e+3)}function n(t,e,r,n){return t.substring(0,e)+n+t.substring(e+r)}var i,a,s=this._document.createElement("canvas");s.width=1,s.height=1;var o=s.getContext("2d"),l=0;var h="lt".concat(Date.now()).concat(this.loadTestFontId++),c=this._loadTestFont,u=1482184792,d=r(c=n(c,976,h.length,h),16);for(i=0,a=h.length-3;i<a;i+=4)d=d-u+r(h,i)|0;i<h.length&&(d=d-u+r(h+"XXX",i)|0),c=n(c,16,4,function(t){return String.fromCharCode(t>>24&255,t>>16&255,t>>8&255,255&t)}(d));var p="url(data:font/opentype;base64,".concat(btoa(c),");"),f='@font-face {font-family:"'.concat(h,'";src:').concat(p,"}");this.insertRule(f);var g=this._document.createElement("div");for(var v of(g.style.visibility="hidden",g.style.width=g.style.height="10px",g.style.position="absolute",g.style.top=g.style.left="0px",[t.loadedName,h])){var m=this._document.createElement("span");m.textContent="Hi",m.style.fontFamily=v,g.append(m)}this._document.body.append(g),function t(e,r){if(++l>30)return Mlt("Load test font never loaded."),void r();o.font="30px "+e,o.fillText(".",0,20),o.getImageData(0,0,1,1).data[3]>0?r():setTimeout(t.bind(null,e,r))}(h,(()=>{g.remove(),e.complete()}))}}class spt{constructor(t,e){var{disableFontFace:r=!1,fontExtraProperties:n=!1,inspectFont:i=null}=e;for(var a in this.compiledGlyphs=Object.create(null),t)this[a]=t[a];this.disableFontFace=!0===r,this.fontExtraProperties=!0===n,this._inspectFont=i}createNativeFontFace(){var t,e;if(!this.data||this.disableFontFace)return null;if(this.cssFontInfo){var r={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(r.style="oblique ".concat(this.cssFontInfo.italicAngle,"deg")),e=new FontFace(this.cssFontInfo.fontFamily,this.data,r)}else e=new FontFace(this.loadedName,this.data,{});return null===(t=this._inspectFont)||void 0===t||t.call(this,this),e}createFontFaceRule(){var t;if(!this.data||this.disableFontFace)return null;var e,r,n="url(data:".concat(this.mimetype,";base64,").concat((e=this.data,Uint8Array.prototype.toBase64?e.toBase64():btoa(zlt(e))),");");if(this.cssFontInfo){var i="font-weight: ".concat(this.cssFontInfo.fontWeight,";");this.cssFontInfo.italicAngle&&(i+="font-style: oblique ".concat(this.cssFontInfo.italicAngle,"deg;")),r='@font-face {font-family:"'.concat(this.cssFontInfo.fontFamily,'";').concat(i,"src:").concat(n,"}")}else r='@font-face {font-family:"'.concat(this.loadedName,'";src:').concat(n,"}");return null===(t=this._inspectFont)||void 0===t||t.call(this,this,n),r}getPathGenerator(t,e){if(void 0!==this.compiledGlyphs[e])return this.compiledGlyphs[e];var r,n=this.loadedName+"_path_"+e;try{r=t.get(n)}catch(t){Mlt('getPathGenerator - ignoring character: "'.concat(t,'".'))}var i=new Path2D(r||"");return this.fontExtraProperties||t.delete(n),this.compiledGlyphs[e]=i}}var opt=1,lpt=2,hpt=1,cpt=2,upt=3,dpt=4,ppt=5,fpt=6,gpt=7,vpt=8;function mpt(){}function ypt(t){if(t instanceof Blt||t instanceof Dlt||t instanceof Flt||t instanceof Olt||t instanceof Nlt||t instanceof Llt)return t;switch(t instanceof Error||"object"==typeof t&&null!==t||Tlt('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),t.name){case"AbortException":return new Blt(t.message);case"InvalidPDFException":return new Dlt(t.message);case"MissingPDFException":return new Flt(t.message);case"PasswordException":return new Olt(t.message,t.code);case"UnexpectedResponseException":return new Nlt(t.message,t.status);case"UnknownErrorException":return new Llt(t.message,t.details)}return new Llt(t.message,t.toString())}var bpt=new WeakMap,wpt=new WeakSet;class xpt{constructor(t,e,r){dit(this,wpt),hit(this,bpt,new AbortController),this.sourceName=t,this.targetName=e,this.comObj=r,this.callbackId=1,this.streamId=1,this.streamSinks=Object.create(null),this.streamControllers=Object.create(null),this.callbackCapabilities=Object.create(null),this.actionHandler=Object.create(null),r.addEventListener("message",iit(wpt,this,Apt).bind(this),{signal:lit(bpt,this).signal})}on(t,e){var r=this.actionHandler;if(r[t])throw new Error('There is already an actionName called "'.concat(t,'"'));r[t]=e}send(t,e,r){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,data:e},r)}sendWithPromise(t,e,r){var n=this.callbackId++,i=Promise.withResolvers();this.callbackCapabilities[n]=i;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:n,data:e},r)}catch(t){i.reject(t)}return i.promise}sendWithStream(t,e,r,n){var i=this.streamId++,a=this.sourceName,s=this.targetName,o=this.comObj;return new ReadableStream({start:r=>{var l=Promise.withResolvers();return this.streamControllers[i]={controller:r,startCall:l,pullCall:null,cancelCall:null,isClosed:!1},o.postMessage({sourceName:a,targetName:s,action:t,streamId:i,data:e,desiredSize:r.desiredSize},n),l.promise},pull:t=>{var e=Promise.withResolvers();return this.streamControllers[i].pullCall=e,o.postMessage({sourceName:a,targetName:s,stream:fpt,streamId:i,desiredSize:t.desiredSize}),e.promise},cancel:t=>{Clt(t instanceof Error,"cancel must have a valid reason");var e=Promise.withResolvers();return this.streamControllers[i].cancelCall=e,this.streamControllers[i].isClosed=!0,o.postMessage({sourceName:a,targetName:s,stream:hpt,streamId:i,reason:ypt(t)}),e.promise}},r)}destroy(){var t;null===(t=lit(bpt,this))||void 0===t||t.abort(),cit(bpt,this,null)}}function Apt(t){var{data:e}=t;if(e.targetName===this.sourceName)if(e.stream)iit(wpt,this,kpt).call(this,e);else if(e.callback){var r=e.callbackId,n=this.callbackCapabilities[r];if(!n)throw new Error("Cannot resolve callback ".concat(r));if(delete this.callbackCapabilities[r],e.callback===opt)n.resolve(e.data);else{if(e.callback!==lpt)throw new Error("Unexpected callback case");n.reject(ypt(e.reason))}}else{var i=this.actionHandler[e.action];if(!i)throw new Error("Unknown action from worker: ".concat(e.action));if(e.callbackId){var a=this.sourceName,s=e.sourceName,o=this.comObj;Promise.try(i,e.data).then((function(t){o.postMessage({sourceName:a,targetName:s,callback:opt,callbackId:e.callbackId,data:t})}),(function(t){o.postMessage({sourceName:a,targetName:s,callback:lpt,callbackId:e.callbackId,reason:ypt(t)})}))}else e.streamId?iit(wpt,this,_pt).call(this,e):i(e.data)}}function _pt(t){var e=t.streamId,r=this.sourceName,n=t.sourceName,i=this.comObj,a=this,s=this.actionHandler[t.action],o={enqueue(t){var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,s=arguments.length>2?arguments[2]:void 0;if(!this.isCancelled){var o=this.desiredSize;this.desiredSize-=a,o>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),i.postMessage({sourceName:r,targetName:n,stream:dpt,streamId:e,chunk:t},s)}},close(){this.isCancelled||(this.isCancelled=!0,i.postMessage({sourceName:r,targetName:n,stream:upt,streamId:e}),delete a.streamSinks[e])},error(t){Clt(t instanceof Error,"error must have a valid reason"),this.isCancelled||(this.isCancelled=!0,i.postMessage({sourceName:r,targetName:n,stream:ppt,streamId:e,reason:ypt(t)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:t.desiredSize,ready:null};o.sinkCapability.resolve(),o.ready=o.sinkCapability.promise,this.streamSinks[e]=o,Promise.try(s,t.data,o).then((function(){i.postMessage({sourceName:r,targetName:n,stream:vpt,streamId:e,success:!0})}),(function(t){i.postMessage({sourceName:r,targetName:n,stream:vpt,streamId:e,reason:ypt(t)})}))}function kpt(t){var e=t.streamId,r=this.sourceName,n=t.sourceName,i=this.comObj,a=this.streamControllers[e],s=this.streamSinks[e];switch(t.stream){case vpt:t.success?a.startCall.resolve():a.startCall.reject(ypt(t.reason));break;case gpt:t.success?a.pullCall.resolve():a.pullCall.reject(ypt(t.reason));break;case fpt:if(!s){i.postMessage({sourceName:r,targetName:n,stream:gpt,streamId:e,success:!0});break}s.desiredSize<=0&&t.desiredSize>0&&s.sinkCapability.resolve(),s.desiredSize=t.desiredSize,Promise.try(s.onPull||mpt).then((function(){i.postMessage({sourceName:r,targetName:n,stream:gpt,streamId:e,success:!0})}),(function(t){i.postMessage({sourceName:r,targetName:n,stream:gpt,streamId:e,reason:ypt(t)})}));break;case dpt:if(Clt(a,"enqueue should have stream controller"),a.isClosed)break;a.controller.enqueue(t.chunk);break;case upt:if(Clt(a,"close should have stream controller"),a.isClosed)break;a.isClosed=!0,a.controller.close(),iit(wpt,this,Spt).call(this,a,e);break;case ppt:Clt(a,"error should have stream controller"),a.controller.error(ypt(t.reason)),iit(wpt,this,Spt).call(this,a,e);break;case cpt:t.success?a.cancelCall.resolve():a.cancelCall.reject(ypt(t.reason)),iit(wpt,this,Spt).call(this,a,e);break;case hpt:if(!s)break;var o=ypt(t.reason);Promise.try(s.onCancel||mpt,o).then((function(){i.postMessage({sourceName:r,targetName:n,stream:cpt,streamId:e,success:!0})}),(function(t){i.postMessage({sourceName:r,targetName:n,stream:cpt,streamId:e,reason:ypt(t)})})),s.sinkCapability.reject(o),s.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}}function Spt(t,e){return Ept.apply(this,arguments)}function Ept(){return(Ept=sit((function*(t,e){var r,n,i;yield Promise.allSettled([null===(r=t.startCall)||void 0===r?void 0:r.promise,null===(n=t.pullCall)||void 0===n?void 0:n.promise,null===(i=t.cancelCall)||void 0===i?void 0:i.promise]),delete this.streamControllers[e]}))).apply(this,arguments)}var Mpt=new WeakMap;class Tpt{constructor(t){var{enableHWA:e=!1}=t;hit(this,Mpt,!1),cit(Mpt,this,e)}create(t,e){if(t<=0||e<=0)throw new Error("Invalid canvas size");var r=this._createCanvas(t,e);return{canvas:r,context:r.getContext("2d",{willReadFrequently:!lit(Mpt,this)})}}reset(t,e,r){if(!t.canvas)throw new Error("Canvas is not specified");if(e<=0||r<=0)throw new Error("Invalid canvas size");t.canvas.width=e,t.canvas.height=r}destroy(t){if(!t.canvas)throw new Error("Canvas is not specified");t.canvas.width=0,t.canvas.height=0,t.canvas=null,t.context=null}_createCanvas(t,e){Tlt("Abstract method `_createCanvas` called.")}}class Cpt{constructor(t){var{baseUrl:e=null,isCompressed:r=!0}=t;this.baseUrl=e,this.isCompressed=r}fetch(t){var e=this;return sit((function*(){var{name:r}=t;if(!e.baseUrl)throw new Error("Ensure that the `cMapUrl` and `cMapPacked` API parameters are provided.");if(!r)throw new Error("CMap name must be specified.");var n=e.baseUrl+r+(e.isCompressed?".bcmap":"");return e._fetch(n).then((t=>({cMapData:t,isCompressed:e.isCompressed}))).catch((t=>{throw new Error("Unable to load ".concat(e.isCompressed?"binary ":"","CMap at: ").concat(n))}))}))()}_fetch(t){return sit((function*(){Tlt("Abstract method `_fetch` called.")}))()}}class Ppt extends Cpt{_fetch(t){var e=this;return sit((function*(){var r=yield tht(t,e.isCompressed?"arraybuffer":"text");return r instanceof ArrayBuffer?new Uint8Array(r):Wlt(r)}))()}}class Ipt{addFilter(t){return"none"}addHCMFilter(t,e){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addHighlightHCMFilter(t,e,r,n,i){return"none"}destroy(){}}var Rpt=new WeakMap,Opt=new WeakMap,Lpt=new WeakMap,Dpt=new WeakMap,Fpt=new WeakMap,Npt=new WeakMap,jpt=new WeakMap,Bpt=new WeakSet;function zpt(t){return lit(Opt,t)||cit(Opt,t,new Map)}function Wpt(t){return lit(Npt,t)||cit(Npt,t,new Map)}function Upt(t){if(!lit(Lpt,t)){var e=lit(Fpt,t).createElement("div"),{style:r}=e;r.visibility="hidden",r.contain="strict",r.width=r.height=0,r.position="absolute",r.top=r.left=0,r.zIndex=-1;var n=lit(Fpt,t).createElementNS(Jlt,"svg");n.setAttribute("width",0),n.setAttribute("height",0),cit(Lpt,t,lit(Fpt,t).createElementNS(Jlt,"defs")),e.append(n),n.append(lit(Lpt,t)),lit(Fpt,t).body.append(e)}return lit(Lpt,t)}function Hpt(t){if(1===t.length){for(var e=t[0],r=new Array(256),n=0;n<256;n++)r[n]=e[n]/255;var i=r.join(",");return[i,i,i]}for(var[a,s,o]=t,l=new Array(256),h=new Array(256),c=new Array(256),u=0;u<256;u++)l[u]=a[u]/255,h[u]=s[u]/255,c[u]=o[u]/255;return[l.join(","),h.join(","),c.join(",")]}function Gpt(t){if(void 0===lit(Rpt,this)){cit(Rpt,this,"");var e=lit(Fpt,this).URL;e!==lit(Fpt,this).baseURI&&(iht(e)?Mlt('#createUrl: ignore "data:"-URL for performance reasons.'):cit(Rpt,this,e.split("#",1)[0]))}return"url(".concat(lit(Rpt,this),"#").concat(t,")")}function Ypt(t){var e=lit(Fpt,this).createElementNS(Jlt,"feColorMatrix");e.setAttribute("type","matrix"),e.setAttribute("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0.59 0.11 0 0"),t.append(e)}function Vpt(t){var e=lit(Fpt,this).createElementNS(Jlt,"feColorMatrix");e.setAttribute("type","matrix"),e.setAttribute("values","0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0"),t.append(e)}function qpt(t){var e=lit(Fpt,this).createElementNS(Jlt,"filter");return e.setAttribute("color-interpolation-filters","sRGB"),e.setAttribute("id",t),uit(Bpt,this,Upt).append(e),e}function Xpt(t,e,r){var n=lit(Fpt,this).createElementNS(Jlt,e);n.setAttribute("type","discrete"),n.setAttribute("tableValues",r),t.append(n)}function $pt(t,e,r,n){var i=lit(Fpt,this).createElementNS(Jlt,"feComponentTransfer");n.append(i),iit(Bpt,this,Xpt).call(this,i,"feFuncR",t),iit(Bpt,this,Xpt).call(this,i,"feFuncG",e),iit(Bpt,this,Xpt).call(this,i,"feFuncB",r)}function Kpt(t,e){var r=lit(Fpt,this).createElementNS(Jlt,"feComponentTransfer");e.append(r),iit(Bpt,this,Xpt).call(this,r,"feFuncA",t)}function Qpt(t){return uit(Bpt,this,Upt).style.color=t,ght(getComputedStyle(uit(Bpt,this,Upt)).getPropertyValue("color"))}class Jpt{constructor(t){var{baseUrl:e=null}=t;this.baseUrl=e}fetch(t){var e=this;return sit((function*(){var{filename:r}=t;if(!e.baseUrl)throw new Error("Ensure that the `standardFontDataUrl` API parameter is provided.");if(!r)throw new Error("Font filename must be specified.");var n="".concat(e.baseUrl).concat(r);return e._fetch(n).catch((t=>{throw new Error("Unable to load font data at: ".concat(n))}))}))()}_fetch(t){return sit((function*(){Tlt("Abstract method `_fetch` called.")}))()}}class Zpt extends Jpt{_fetch(t){return sit((function*(){var e=yield tht(t,"arraybuffer");return new Uint8Array(e)}))()}}function tft(t){return eft.apply(this,arguments)}function eft(){return eft=sit((function*(t){var e=process.getBuiltinModule("fs"),r=yield e.promises.readFile(t);return new Uint8Array(r)})),eft.apply(this,arguments)}Tot&&Mlt("Please use the `legacy` build in Node.js environments.");var rft="Fill",nft="Stroke",ift="Shading";function aft(t,e){if(e){var r=e[2]-e[0],n=e[3]-e[1],i=new Path2D;i.rect(e[0],e[1],r,n),t.clip(i)}}class sft{getPattern(){Tlt("Abstract method `getPattern` called.")}}class oft extends sft{constructor(t){super(),this._type=t[1],this._bbox=t[2],this._colorStops=t[3],this._p0=t[4],this._p1=t[5],this._r0=t[6],this._r1=t[7],this.matrix=null}_createGradient(t){var e;for(var r of("axial"===this._type?e=t.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):"radial"===this._type&&(e=t.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1)),this._colorStops))e.addColorStop(r[0],r[1]);return e}getPattern(t,e,r,n){var i;if(n===nft||n===rft){var a=e.current.getClippedPathBoundingBox(n,vht(t))||[0,0,0,0],s=Math.ceil(a[2]-a[0])||1,o=Math.ceil(a[3]-a[1])||1,l=e.cachedCanvases.getCanvas("pattern",s,o),h=l.context;h.clearRect(0,0,h.canvas.width,h.canvas.height),h.beginPath(),h.rect(0,0,h.canvas.width,h.canvas.height),h.translate(-a[0],-a[1]),r=Ylt.transform(r,[1,0,0,1,a[0],a[1]]),h.transform(...e.baseTransform),this.matrix&&h.transform(...this.matrix),aft(h,this._bbox),h.fillStyle=this._createGradient(h),h.fill(),i=t.createPattern(l.canvas,"no-repeat");var c=new DOMMatrix(r);i.setTransform(c)}else aft(t,this._bbox),i=this._createGradient(t);return i}}function lft(t,e,r,n,i,a,s,o){var l,h=e.coords,c=e.colors,u=t.data,d=4*t.width;h[r+1]>h[n+1]&&(l=r,r=n,n=l,l=a,a=s,s=l),h[n+1]>h[i+1]&&(l=n,n=i,i=l,l=s,s=o,o=l),h[r+1]>h[n+1]&&(l=r,r=n,n=l,l=a,a=s,s=l);var p=(h[r]+e.offsetX)*e.scaleX,f=(h[r+1]+e.offsetY)*e.scaleY,g=(h[n]+e.offsetX)*e.scaleX,v=(h[n+1]+e.offsetY)*e.scaleY,m=(h[i]+e.offsetX)*e.scaleX,y=(h[i+1]+e.offsetY)*e.scaleY;if(!(f>=y))for(var b,w,x,A,_,k,S,E,M=c[a],T=c[a+1],C=c[a+2],P=c[s],I=c[s+1],R=c[s+2],O=c[o],L=c[o+1],D=c[o+2],F=Math.round(f),N=Math.round(y),j=F;j<=N;j++){if(j<v){var B=j<f?0:(f-j)/(f-v);b=p-(p-g)*B,w=M-(M-P)*B,x=T-(T-I)*B,A=C-(C-R)*B}else{var z=void 0;b=g-(g-m)*(z=j>y?1:v===y?0:(v-j)/(v-y)),w=P-(P-O)*z,x=I-(I-L)*z,A=R-(R-D)*z}var W=void 0;_=p-(p-m)*(W=j<f?0:j>y?1:(f-j)/(f-y)),k=M-(M-O)*W,S=T-(T-L)*W,E=C-(C-D)*W;for(var U=Math.round(Math.min(b,_)),H=Math.round(Math.max(b,_)),G=d*j+4*U,Y=U;Y<=H;Y++)(W=(b-Y)/(b-_))<0?W=0:W>1&&(W=1),u[G++]=w-(w-k)*W|0,u[G++]=x-(x-S)*W|0,u[G++]=A-(A-E)*W|0,u[G++]=255}}function hft(t,e,r){var n,i,a=e.coords,s=e.colors;switch(e.type){case"lattice":var o=e.verticesPerRow,l=Math.floor(a.length/o)-1,h=o-1;for(n=0;n<l;n++)for(var c=n*o,u=0;u<h;u++,c++)lft(t,r,a[c],a[c+1],a[c+o],s[c],s[c+1],s[c+o]),lft(t,r,a[c+o+1],a[c+1],a[c+o],s[c+o+1],s[c+1],s[c+o]);break;case"triangles":for(n=0,i=a.length;n<i;n+=3)lft(t,r,a[n],a[n+1],a[n+2],s[n],s[n+1],s[n+2]);break;default:throw new Error("illegal figure")}}class cft extends sft{constructor(t){super(),this._coords=t[2],this._colors=t[3],this._figures=t[4],this._bounds=t[5],this._bbox=t[7],this._background=t[8],this.matrix=null}_createMeshCanvas(t,e,r){var n=Math.floor(this._bounds[0]),i=Math.floor(this._bounds[1]),a=Math.ceil(this._bounds[2])-n,s=Math.ceil(this._bounds[3])-i,o=Math.min(Math.ceil(Math.abs(a*t[0]*1.1)),3e3),l=Math.min(Math.ceil(Math.abs(s*t[1]*1.1)),3e3),h=a/o,c=s/l,u={coords:this._coords,colors:this._colors,offsetX:-n,offsetY:-i,scaleX:1/h,scaleY:1/c},d=o+4,p=l+4,f=r.getCanvas("mesh",d,p),g=f.context,v=g.createImageData(o,l);if(e)for(var m=v.data,y=0,b=m.length;y<b;y+=4)m[y]=e[0],m[y+1]=e[1],m[y+2]=e[2],m[y+3]=255;for(var w of this._figures)hft(v,w,u);return g.putImageData(v,2,2),{canvas:f.canvas,offsetX:n-2*h,offsetY:i-2*c,scaleX:h,scaleY:c}}getPattern(t,e,r,n){var i;if(aft(t,this._bbox),n===ift)i=Ylt.singularValueDecompose2dScale(vht(t));else if(i=Ylt.singularValueDecompose2dScale(e.baseTransform),this.matrix){var a=Ylt.singularValueDecompose2dScale(this.matrix);i=[i[0]*a[0],i[1]*a[1]]}var s=this._createMeshCanvas(i,n===ift?null:this._background,e.cachedCanvases);return n!==ift&&(t.setTransform(...e.baseTransform),this.matrix&&t.transform(...this.matrix)),t.translate(s.offsetX,s.offsetY),t.scale(s.scaleX,s.scaleY),t.createPattern(s.canvas,"no-repeat")}}class uft extends sft{getPattern(){return"hotpink"}}var dft=1,pft=2;class fft{constructor(t,e,r,n,i){this.operatorList=t[2],this.matrix=t[3],this.bbox=t[4],this.xstep=t[5],this.ystep=t[6],this.paintType=t[7],this.tilingType=t[8],this.color=e,this.ctx=r,this.canvasGraphicsFactory=n,this.baseTransform=i}createPatternCanvas(t){var{bbox:e,operatorList:r,paintType:n,tilingType:i,color:a,canvasGraphicsFactory:s}=this,{xstep:o,ystep:l}=this;o=Math.abs(o),l=Math.abs(l),Elt("TilingType: "+i);var h=e[0],c=e[1],u=e[2],d=e[3],p=u-h,f=d-c,g=Ylt.singularValueDecompose2dScale(this.matrix),v=Ylt.singularValueDecompose2dScale(this.baseTransform),m=g[0]*v[0],y=g[1]*v[1],b=p,w=f,x=!1,A=!1,_=Math.ceil(o*m),k=Math.ceil(l*y);_>=Math.ceil(p*m)?b=o:x=!0,k>=Math.ceil(f*y)?w=l:A=!0;var S=this.getSizeAndScale(b,this.ctx.canvas.width,m),E=this.getSizeAndScale(w,this.ctx.canvas.height,y),M=t.cachedCanvases.getCanvas("pattern",S.size,E.size),T=M.context,C=s.createCanvasGraphics(T);if(C.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(C,n,a),T.translate(-S.scale*h,-E.scale*c),C.transform(S.scale,0,0,E.scale,0,0),T.save(),this.clipBbox(C,h,c,u,d),C.baseTransform=vht(C.ctx),C.executeOperatorList(r),C.endDrawing(),T.restore(),x||A){var P=M.canvas;x&&(b=o),A&&(w=l);for(var I=this.getSizeAndScale(b,this.ctx.canvas.width,m),R=this.getSizeAndScale(w,this.ctx.canvas.height,y),O=I.size,L=R.size,D=t.cachedCanvases.getCanvas("pattern-workaround",O,L),F=D.context,N=x?Math.floor(p/o):0,j=A?Math.floor(f/l):0,B=0;B<=N;B++)for(var z=0;z<=j;z++)F.drawImage(P,O*B,L*z,O,L,0,0,O,L);return{canvas:D.canvas,scaleX:I.scale,scaleY:R.scale,offsetX:h,offsetY:c}}return{canvas:M.canvas,scaleX:S.scale,scaleY:E.scale,offsetX:h,offsetY:c}}getSizeAndScale(t,e,r){var n=Math.max(fft.MAX_PATTERN_SIZE,e),i=Math.ceil(t*r);return i>=n?i=n:r=i/t,{scale:r,size:i}}clipBbox(t,e,r,n,i){var a=n-e,s=i-r;t.ctx.rect(e,r,a,s),t.current.updateRectMinMax(vht(t.ctx),[e,r,n,i]),t.clip(),t.endPath()}setFillAndStrokeStyleToContext(t,e,r){var n=t.ctx,i=t.current;switch(e){case dft:var a=this.ctx;n.fillStyle=a.fillStyle,n.strokeStyle=a.strokeStyle,i.fillColor=a.fillStyle,i.strokeColor=a.strokeStyle;break;case pft:var s=Ylt.makeHexColor(r[0],r[1],r[2]);n.fillStyle=s,n.strokeStyle=s,i.fillColor=s,i.strokeColor=s;break;default:throw new jlt("Unsupported paint type: ".concat(e))}}getPattern(t,e,r,n){var i=r;n!==ift&&(i=Ylt.transform(i,e.baseTransform),this.matrix&&(i=Ylt.transform(i,this.matrix)));var a=this.createPatternCanvas(e),s=new DOMMatrix(i);s=(s=s.translate(a.offsetX,a.offsetY)).scale(1/a.scaleX,1/a.scaleY);var o=t.createPattern(a.canvas,"repeat");return o.setTransform(s),o}}function gft(t){var{src:e,srcPos:r=0,dest:n,width:i,height:a,nonBlackColor:s=4294967295,inverseDecode:o=!1}=t,l=Hlt.isLittleEndian?4278190080:255,[h,c]=o?[s,l]:[l,s],u=i>>3,d=7&i,p=e.length;n=new Uint32Array(n.buffer);for(var f=0,g=0;g<a;g++){for(var v=r+u;r<v;r++){var m=r<p?e[r]:255;n[f++]=128&m?c:h,n[f++]=64&m?c:h,n[f++]=32&m?c:h,n[f++]=16&m?c:h,n[f++]=8&m?c:h,n[f++]=4&m?c:h,n[f++]=2&m?c:h,n[f++]=1&m?c:h}if(0!==d)for(var y=r<p?e[r++]:255,b=0;b<d;b++)n[f++]=y&1<<7-b?c:h}return{srcPos:r,destPos:f}}pit(fft,"MAX_PATTERN_SIZE",3e3);var vft=16;class mft{constructor(t){this.canvasFactory=t,this.cache=Object.create(null)}getCanvas(t,e,r){var n;return void 0!==this.cache[t]?(n=this.cache[t],this.canvasFactory.reset(n,e,r)):(n=this.canvasFactory.create(e,r),this.cache[t]=n),n}delete(t){delete this.cache[t]}clear(){for(var t in this.cache){var e=this.cache[t];this.canvasFactory.destroy(e),delete this.cache[t]}}}function yft(t,e,r,n,i,a,s,o,l,h){var[c,u,d,p,f,g]=vht(t);if(0===u&&0===d){var v=s*c+f,m=Math.round(v),y=o*p+g,b=Math.round(y),w=(s+l)*c+f,x=Math.abs(Math.round(w)-m)||1,A=(o+h)*p+g,_=Math.abs(Math.round(A)-b)||1;return t.setTransform(Math.sign(c),0,0,Math.sign(p),m,b),t.drawImage(e,r,n,i,a,0,0,x,_),t.setTransform(c,u,d,p,f,g),[x,_]}if(0===c&&0===p){var k=o*d+f,S=Math.round(k),E=s*u+g,M=Math.round(E),T=(o+h)*d+f,C=Math.abs(Math.round(T)-S)||1,P=(s+l)*u+g,I=Math.abs(Math.round(P)-M)||1;return t.setTransform(0,Math.sign(u),Math.sign(d),0,S,M),t.drawImage(e,r,n,i,a,0,0,I,C),t.setTransform(c,u,d,p,f,g),[I,C]}return t.drawImage(e,r,n,i,a,s,o,l,h),[Math.hypot(c,u)*l,Math.hypot(d,p)*h]}class bft{constructor(t,e){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=Cot,this.textMatrixScale=1,this.fontMatrix=Pot,this.leading=0,this.x=0,this.y=0,this.lineX=0,this.lineY=0,this.charSpacing=0,this.wordSpacing=0,this.textHScale=1,this.textRenderingMode=Got,this.textRise=0,this.fillColor="#000000",this.strokeColor="#000000",this.patternFill=!1,this.patternStroke=!1,this.fillAlpha=1,this.strokeAlpha=1,this.lineWidth=1,this.activeSMask=null,this.transferMaps="none",this.startNewPathAndClipBox([0,0,t,e])}clone(){var t=Object.create(this);return t.clipBox=this.clipBox.slice(),t}setCurrentPoint(t,e){this.x=t,this.y=e}updatePathMinMax(t,e,r){[e,r]=Ylt.applyTransform([e,r],t),this.minX=Math.min(this.minX,e),this.minY=Math.min(this.minY,r),this.maxX=Math.max(this.maxX,e),this.maxY=Math.max(this.maxY,r)}updateRectMinMax(t,e){var r=Ylt.applyTransform(e,t),n=Ylt.applyTransform(e.slice(2),t),i=Ylt.applyTransform([e[0],e[3]],t),a=Ylt.applyTransform([e[2],e[1]],t);this.minX=Math.min(this.minX,r[0],n[0],i[0],a[0]),this.minY=Math.min(this.minY,r[1],n[1],i[1],a[1]),this.maxX=Math.max(this.maxX,r[0],n[0],i[0],a[0]),this.maxY=Math.max(this.maxY,r[1],n[1],i[1],a[1])}updateScalingPathMinMax(t,e){Ylt.scaleMinMax(t,e),this.minX=Math.min(this.minX,e[0]),this.minY=Math.min(this.minY,e[1]),this.maxX=Math.max(this.maxX,e[2]),this.maxY=Math.max(this.maxY,e[3])}updateCurvePathMinMax(t,e,r,n,i,a,s,o,l,h){var c=Ylt.bezierBoundingBox(e,r,n,i,a,s,o,l,h);h||this.updateRectMinMax(t,c)}getPathBoundingBox(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:rft,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=[this.minX,this.minY,this.maxX,this.maxY];if(t===nft){e||Tlt("Stroke bounding box must include transform.");var n=Ylt.singularValueDecompose2dScale(e),i=n[0]*this.lineWidth/2,a=n[1]*this.lineWidth/2;r[0]-=i,r[1]-=a,r[2]+=i,r[3]+=a}return r}updateClipFromPath(){var t=Ylt.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(t||[0,0,0,0])}isEmptyClip(){return this.minX===1/0}startNewPathAndClipBox(t){this.clipBox=t,this.minX=1/0,this.minY=1/0,this.maxX=0,this.maxY=0}getClippedPathBoundingBox(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:rft,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return Ylt.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function wft(t,e){if(e instanceof ImageData)t.putImageData(e,0,0);else{var r,n,i,a,s,o=e.height,l=e.width,h=o%vft,c=(o-h)/vft,u=0===h?c:c+1,d=t.createImageData(l,vft),p=0,f=e.data,g=d.data;if(e.kind===Kot.GRAYSCALE_1BPP){var v=f.byteLength,m=new Uint32Array(g.buffer,0,g.byteLength>>2),y=m.length,b=l+7>>3,w=4294967295,x=Hlt.isLittleEndian?4278190080:255;for(n=0;n<u;n++){for(a=n<c?vft:h,r=0,i=0;i<a;i++){for(var A=v-p,_=0,k=A>b?l:8*A-7,S=-8&k,E=0,M=0;_<S;_+=8)M=f[p++],m[r++]=128&M?w:x,m[r++]=64&M?w:x,m[r++]=32&M?w:x,m[r++]=16&M?w:x,m[r++]=8&M?w:x,m[r++]=4&M?w:x,m[r++]=2&M?w:x,m[r++]=1&M?w:x;for(;_<k;_++)0===E&&(M=f[p++],E=128),m[r++]=M&E?w:x,E>>=1}for(;r<y;)m[r++]=0;t.putImageData(d,0,n*vft)}}else if(e.kind===Kot.RGBA_32BPP){for(i=0,s=l*vft*4,n=0;n<c;n++)g.set(f.subarray(p,p+s)),p+=s,t.putImageData(d,0,i),i+=vft;n<u&&(s=l*h*4,g.set(f.subarray(p,p+s)),t.putImageData(d,0,i))}else{if(e.kind!==Kot.RGB_24BPP)throw new Error("bad image kind: ".concat(e.kind));for(s=l*(a=vft),n=0;n<u;n++){for(n>=c&&(s=l*(a=h)),r=0,i=s;i--;)g[r++]=f[p++],g[r++]=f[p++],g[r++]=f[p++],g[r++]=255;t.putImageData(d,0,n*vft)}}}}function xft(t,e){if(e.bitmap)t.drawImage(e.bitmap,0,0);else for(var r=e.height,n=e.width,i=r%vft,a=(r-i)/vft,s=0===i?a:a+1,o=t.createImageData(n,vft),l=0,h=e.data,c=o.data,u=0;u<s;u++){var d=u<a?vft:i;({srcPos:l}=gft({src:h,srcPos:l,dest:c,width:n,height:d,nonBlackColor:0})),t.putImageData(o,0,u*vft)}}function Aft(t,e){for(var r of["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"])void 0!==t[r]&&(e[r]=t[r]);void 0!==t.setLineDash&&(e.setLineDash(t.getLineDash()),e.lineDashOffset=t.lineDashOffset)}function _ft(t){if(t.strokeStyle=t.fillStyle="#000000",t.fillRule="nonzero",t.globalAlpha=1,t.lineWidth=1,t.lineCap="butt",t.lineJoin="miter",t.miterLimit=10,t.globalCompositeOperation="source-over",t.font="10px sans-serif",void 0!==t.setLineDash&&(t.setLineDash([]),t.lineDashOffset=0),!Tot){var{filter:e}=t;"none"!==e&&""!==e&&(t.filter="none")}}function kft(t,e){if(e)return!0;var r=Ylt.singularValueDecompose2dScale(t);r[0]=Math.fround(r[0]),r[1]=Math.fround(r[1]);var n=Math.fround((globalThis.devicePixelRatio||1)*Zlt.PDF_TO_CSS_UNITS);return r[0]<=n&&r[1]<=n}var Sft=["butt","round","square"],Eft=["miter","round","bevel"],Mft={},Tft={},Cft=new WeakSet;class Pft{constructor(t,e,r,n,i,a,s,o){var{optionalContentConfig:l,markedContentStack:h=null}=a;dit(this,Cft),this.ctx=t,this.current=new bft(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.res=null,this.xobjs=null,this.commonObjs=e,this.objs=r,this.canvasFactory=n,this.filterFactory=i,this.groupStack=[],this.processingType3=null,this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.smaskCounter=0,this.tempSMask=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=h||[],this.optionalContentConfig=l,this.cachedCanvases=new mft(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=s,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=o,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map}getObject(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return"string"==typeof t?t.startsWith("g_")?this.commonObjs.get(t):this.objs.get(t):e}beginDrawing(t){var{transform:e,viewport:r,transparency:n=!1,background:i=null}=t,a=this.ctx.canvas.width,s=this.ctx.canvas.height,o=this.ctx.fillStyle;if(this.ctx.fillStyle=i||"#ffffff",this.ctx.fillRect(0,0,a,s),this.ctx.fillStyle=o,n){var l=this.cachedCanvases.getCanvas("transparent",a,s);this.compositeCtx=this.ctx,this.transparentCanvas=l.canvas,this.ctx=l.context,this.ctx.save(),this.ctx.transform(...vht(this.compositeCtx))}this.ctx.save(),_ft(this.ctx),e&&(this.ctx.transform(...e),this.outputScaleX=e[0],this.outputScaleY=e[0]),this.ctx.transform(...r.transform),this.viewportScale=r.scale,this.baseTransform=vht(this.ctx)}executeOperatorList(t,e,r,n){var i=t.argsArray,a=t.fnArray,s=e||0,o=i.length;if(o===s)return s;for(var l,h=o-s>10&&"function"==typeof r,c=h?Date.now()+15:0,u=0,d=this.commonObjs,p=this.objs;;){if(void 0!==n&&s===n.nextBreakPoint)return n.breakIt(s,r),s;if((l=a[s])!==xlt.dependency)this[l].apply(this,i[s]);else for(var f of i[s]){var g=f.startsWith("g_")?d:p;if(!g.has(f))return g.get(f,r),s}if(++s===o)return s;if(h&&++u>10){if(Date.now()>c)return r(),s;u=0}}}endDrawing(){for(var t of(iit(Cft,this,Ift).call(this),this.cachedCanvases.clear(),this.cachedPatterns.clear(),this._cachedBitmapsMap.values())){for(var e of t.values())"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement&&(e.width=e.height=0);t.clear()}this._cachedBitmapsMap.clear(),iit(Cft,this,Rft).call(this)}_scaleImage(t,e){for(var r,n,i,a,s=null!==(r=t.width)&&void 0!==r?r:t.displayWidth,o=null!==(n=t.height)&&void 0!==n?n:t.displayHeight,l=Math.max(Math.hypot(e[0],e[1]),1),h=Math.max(Math.hypot(e[2],e[3]),1),c=s,u=o,d="prescale1";l>2&&c>1||h>2&&u>1;){var p=c,f=u;l>2&&c>1&&(l/=c/(p=c>=16384?Math.floor(c/2)-1||1:Math.ceil(c/2))),h>2&&u>1&&(h/=u/(f=u>=16384?Math.floor(u/2)-1||1:Math.ceil(u)/2)),(a=(i=this.cachedCanvases.getCanvas(d,p,f)).context).clearRect(0,0,p,f),a.drawImage(t,0,0,c,u,0,0,p,f),t=i.canvas,c=p,u=f,d="prescale1"===d?"prescale2":"prescale1"}return{img:t,paintWidth:c,paintHeight:u}}_createMaskCanvas(t){var e,r,n,i,a=this.ctx,{width:s,height:o}=t,l=this.current.fillColor,h=this.current.patternFill,c=vht(a);if((t.bitmap||t.data)&&t.count>1){var u=t.bitmap||t.data.buffer;r=JSON.stringify(h?c:[c.slice(0,4),l]),(e=this._cachedBitmapsMap.get(u))||(e=new Map,this._cachedBitmapsMap.set(u,e));var d=e.get(r);if(d&&!h)return{canvas:d,offsetX:Math.round(Math.min(c[0],c[2])+c[4]),offsetY:Math.round(Math.min(c[1],c[3])+c[5])};n=d}n||xft((i=this.cachedCanvases.getCanvas("maskCanvas",s,o)).context,t);var p=Ylt.transform(c,[1/s,0,0,-1/o,0,0]);p=Ylt.transform(p,[1,0,0,1,0,-o]);var[f,g,v,m]=Ylt.getAxialAlignedBoundingBox([0,0,s,o],p),y=Math.round(v-f)||1,b=Math.round(m-g)||1,w=this.cachedCanvases.getCanvas("fillCanvas",y,b),x=w.context,A=f,_=g;x.translate(-A,-_),x.transform(...p),n||(n=(n=this._scaleImage(i.canvas,mht(x))).img,e&&h&&e.set(r,n)),x.imageSmoothingEnabled=kft(vht(x),t.interpolate),yft(x,n,0,0,n.width,n.height,0,0,s,o),x.globalCompositeOperation="source-in";var k=Ylt.transform(mht(x),[1,0,0,1,-A,-_]);return x.fillStyle=h?l.getPattern(a,this,k,rft):l,x.fillRect(0,0,s,o),e&&!h&&(this.cachedCanvases.delete("fillCanvas"),e.set(r,w.canvas)),{canvas:w.canvas,offsetX:Math.round(A),offsetY:Math.round(_)}}setLineWidth(t){t!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=t,this.ctx.lineWidth=t}setLineCap(t){this.ctx.lineCap=Sft[t]}setLineJoin(t){this.ctx.lineJoin=Eft[t]}setMiterLimit(t){this.ctx.miterLimit=t}setDash(t,e){var r=this.ctx;void 0!==r.setLineDash&&(r.setLineDash(t),r.lineDashOffset=e)}setRenderingIntent(t){}setFlatness(t){}setGState(t){for(var[e,r]of t)switch(e){case"LW":this.setLineWidth(r);break;case"LC":this.setLineCap(r);break;case"LJ":this.setLineJoin(r);break;case"ML":this.setMiterLimit(r);break;case"D":this.setDash(r[0],r[1]);break;case"RI":this.setRenderingIntent(r);break;case"FL":this.setFlatness(r);break;case"Font":this.setFont(r[0],r[1]);break;case"CA":this.current.strokeAlpha=r;break;case"ca":this.current.fillAlpha=r,this.ctx.globalAlpha=r;break;case"BM":this.ctx.globalCompositeOperation=r;break;case"SMask":this.current.activeSMask=r?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(r)}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){var t=this.inSMaskMode;this.current.activeSMask&&!t?this.beginSMaskMode():!this.current.activeSMask&&t&&this.endSMaskMode()}beginSMaskMode(){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");var t=this.ctx.canvas.width,e=this.ctx.canvas.height,r="smaskGroupAt"+this.groupLevel,n=this.cachedCanvases.getCanvas(r,t,e);this.suspendedCtx=this.ctx,this.ctx=n.context;var i=this.ctx;i.setTransform(...vht(this.suspendedCtx)),Aft(this.suspendedCtx,i),function(t,e){if(t._removeMirroring)throw new Error("Context is already forwarding operations.");t.__originalSave=t.save,t.__originalRestore=t.restore,t.__originalRotate=t.rotate,t.__originalScale=t.scale,t.__originalTranslate=t.translate,t.__originalTransform=t.transform,t.__originalSetTransform=t.setTransform,t.__originalResetTransform=t.resetTransform,t.__originalClip=t.clip,t.__originalMoveTo=t.moveTo,t.__originalLineTo=t.lineTo,t.__originalBezierCurveTo=t.bezierCurveTo,t.__originalRect=t.rect,t.__originalClosePath=t.closePath,t.__originalBeginPath=t.beginPath,t._removeMirroring=()=>{t.save=t.__originalSave,t.restore=t.__originalRestore,t.rotate=t.__originalRotate,t.scale=t.__originalScale,t.translate=t.__originalTranslate,t.transform=t.__originalTransform,t.setTransform=t.__originalSetTransform,t.resetTransform=t.__originalResetTransform,t.clip=t.__originalClip,t.moveTo=t.__originalMoveTo,t.lineTo=t.__originalLineTo,t.bezierCurveTo=t.__originalBezierCurveTo,t.rect=t.__originalRect,t.closePath=t.__originalClosePath,t.beginPath=t.__originalBeginPath,delete t._removeMirroring},t.save=function(){e.save(),this.__originalSave()},t.restore=function(){e.restore(),this.__originalRestore()},t.translate=function(t,r){e.translate(t,r),this.__originalTranslate(t,r)},t.scale=function(t,r){e.scale(t,r),this.__originalScale(t,r)},t.transform=function(t,r,n,i,a,s){e.transform(t,r,n,i,a,s),this.__originalTransform(t,r,n,i,a,s)},t.setTransform=function(t,r,n,i,a,s){e.setTransform(t,r,n,i,a,s),this.__originalSetTransform(t,r,n,i,a,s)},t.resetTransform=function(){e.resetTransform(),this.__originalResetTransform()},t.rotate=function(t){e.rotate(t),this.__originalRotate(t)},t.clip=function(t){e.clip(t),this.__originalClip(t)},t.moveTo=function(t,r){e.moveTo(t,r),this.__originalMoveTo(t,r)},t.lineTo=function(t,r){e.lineTo(t,r),this.__originalLineTo(t,r)},t.bezierCurveTo=function(t,r,n,i,a,s){e.bezierCurveTo(t,r,n,i,a,s),this.__originalBezierCurveTo(t,r,n,i,a,s)},t.rect=function(t,r,n,i){e.rect(t,r,n,i),this.__originalRect(t,r,n,i)},t.closePath=function(){e.closePath(),this.__originalClosePath()},t.beginPath=function(){e.beginPath(),this.__originalBeginPath()}}(i,this.suspendedCtx),this.setGState([["BM","source-over"],["ca",1],["CA",1]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),Aft(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null}compose(t){if(this.current.activeSMask){t?(t[0]=Math.floor(t[0]),t[1]=Math.floor(t[1]),t[2]=Math.ceil(t[2]),t[3]=Math.ceil(t[3])):t=[0,0,this.ctx.canvas.width,this.ctx.canvas.height];var e=this.current.activeSMask,r=this.suspendedCtx;this.composeSMask(r,e,this.ctx,t),this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.ctx.restore()}}composeSMask(t,e,r,n){var i=n[0],a=n[1],s=n[2]-i,o=n[3]-a;0!==s&&0!==o&&(this.genericComposeSMask(e.context,r,s,o,e.subtype,e.backdrop,e.transferMap,i,a,e.offsetX,e.offsetY),t.save(),t.globalAlpha=1,t.globalCompositeOperation="source-over",t.setTransform(1,0,0,1,0,0),t.drawImage(r.canvas,0,0),t.restore())}genericComposeSMask(t,e,r,n,i,a,s,o,l,h,c){var u=t.canvas,d=o-h,p=l-c;if(a){var f=Ylt.makeHexColor(...a);if(d<0||p<0||d+r>u.width||p+n>u.height){var g=this.cachedCanvases.getCanvas("maskExtension",r,n),v=g.context;v.drawImage(u,-d,-p),v.globalCompositeOperation="destination-atop",v.fillStyle=f,v.fillRect(0,0,r,n),v.globalCompositeOperation="source-over",u=g.canvas,d=p=0}else{t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0);var m=new Path2D;m.rect(d,p,r,n),t.clip(m),t.globalCompositeOperation="destination-atop",t.fillStyle=f,t.fillRect(d,p,r,n),t.restore()}}e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0),"Alpha"===i&&s?e.filter=this.filterFactory.addAlphaFilter(s):"Luminosity"===i&&(e.filter=this.filterFactory.addLuminosityFilter(s));var y=new Path2D;y.rect(o,l,r,n),e.clip(y),e.globalCompositeOperation="destination-in",e.drawImage(u,d,p,r,n,o,l,r,n),e.restore()}save(){this.inSMaskMode?(Aft(this.ctx,this.suspendedCtx),this.suspendedCtx.save()):this.ctx.save();var t=this.current;this.stateStack.push(t),this.current=t.clone()}restore(){0===this.stateStack.length&&this.inSMaskMode&&this.endSMaskMode(),0!==this.stateStack.length&&(this.current=this.stateStack.pop(),this.inSMaskMode?(this.suspendedCtx.restore(),Aft(this.suspendedCtx,this.ctx)):this.ctx.restore(),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null)}transform(t,e,r,n,i,a){this.ctx.transform(t,e,r,n,i,a),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,r){for(var n,i,a=this.ctx,s=this.current,o=s.x,l=s.y,h=vht(a),c=0===h[0]&&0===h[3]||0===h[1]&&0===h[2],u=c?r.slice(0):null,d=0,p=0,f=t.length;d<f;d++)switch(0|t[d]){case xlt.rectangle:o=e[p++],l=e[p++];var g=e[p++],v=e[p++],m=o+g,y=l+v;a.moveTo(o,l),0===g||0===v?a.lineTo(m,y):(a.lineTo(m,l),a.lineTo(m,y),a.lineTo(o,y)),c||s.updateRectMinMax(h,[o,l,m,y]),a.closePath();break;case xlt.moveTo:o=e[p++],l=e[p++],a.moveTo(o,l),c||s.updatePathMinMax(h,o,l);break;case xlt.lineTo:o=e[p++],l=e[p++],a.lineTo(o,l),c||s.updatePathMinMax(h,o,l);break;case xlt.curveTo:n=o,i=l,o=e[p+4],l=e[p+5],a.bezierCurveTo(e[p],e[p+1],e[p+2],e[p+3],o,l),s.updateCurvePathMinMax(h,n,i,e[p],e[p+1],e[p+2],e[p+3],o,l,u),p+=6;break;case xlt.curveTo2:n=o,i=l,a.bezierCurveTo(o,l,e[p],e[p+1],e[p+2],e[p+3]),s.updateCurvePathMinMax(h,n,i,o,l,e[p],e[p+1],e[p+2],e[p+3],u),o=e[p+2],l=e[p+3],p+=4;break;case xlt.curveTo3:n=o,i=l,o=e[p+2],l=e[p+3],a.bezierCurveTo(e[p],e[p+1],o,l,o,l),s.updateCurvePathMinMax(h,n,i,e[p],e[p+1],o,l,o,l,u),p+=4;break;case xlt.closePath:a.closePath()}c&&s.updateScalingPathMinMax(h,u),s.setCurrentPoint(o,l)}closePath(){this.ctx.closePath()}stroke(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],e=this.ctx,r=this.current.strokeColor;e.globalAlpha=this.current.strokeAlpha,this.contentVisible&&("object"==typeof r&&null!=r&&r.getPattern?(e.save(),e.strokeStyle=r.getPattern(e,this,mht(e),nft),this.rescaleAndStroke(!1),e.restore()):this.rescaleAndStroke(!0)),t&&this.consumePath(this.current.getClippedPathBoundingBox()),e.globalAlpha=this.current.fillAlpha}closeStroke(){this.closePath(),this.stroke()}fill(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],e=this.ctx,r=this.current.fillColor,n=!1;this.current.patternFill&&(e.save(),e.fillStyle=r.getPattern(e,this,mht(e),rft),n=!0);var i=this.current.getClippedPathBoundingBox();this.contentVisible&&null!==i&&(this.pendingEOFill?(e.fill("evenodd"),this.pendingEOFill=!1):e.fill()),n&&e.restore(),t&&this.consumePath(i)}eoFill(){this.pendingEOFill=!0,this.fill()}fillStroke(){this.fill(!1),this.stroke(!1),this.consumePath()}eoFillStroke(){this.pendingEOFill=!0,this.fillStroke()}closeFillStroke(){this.closePath(),this.fillStroke()}closeEOFillStroke(){this.pendingEOFill=!0,this.closePath(),this.fillStroke()}endPath(){this.consumePath()}clip(){this.pendingClip=Mft}eoClip(){this.pendingClip=Tft}beginText(){this.current.textMatrix=Cot,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}endText(){var t=this.pendingTextPaths,e=this.ctx;if(void 0!==t){var r=new Path2D,n=e.getTransform().invertSelf();for(var{transform:i,x:a,y:s,fontSize:o,path:l}of t)r.addPath(l,new DOMMatrix(i).preMultiplySelf(n).translate(a,s).scale(o,-o));e.clip(r),e.beginPath(),delete this.pendingTextPaths}else e.beginPath()}setCharSpacing(t){this.current.charSpacing=t}setWordSpacing(t){this.current.wordSpacing=t}setHScale(t){this.current.textHScale=t/100}setLeading(t){this.current.leading=-t}setFont(t,e){var r,n=this.commonObjs.get(t),i=this.current;if(!n)throw new Error("Can't find font for ".concat(t));if(i.fontMatrix=n.fontMatrix||Pot,0!==i.fontMatrix[0]&&0!==i.fontMatrix[3]||Mlt("Invalid font matrix for font "+t),e<0?(e=-e,i.fontDirection=-1):i.fontDirection=1,this.current.font=n,this.current.fontSize=e,!n.isType3Font){var a=n.loadedName||"sans-serif",s=(null===(r=n.systemFontInfo)||void 0===r?void 0:r.css)||'"'.concat(a,'", ').concat(n.fallbackName),o="normal";n.black?o="900":n.bold&&(o="bold");var l=n.italic?"italic":"normal",h=e;e<16?h=16:e>100&&(h=100),this.current.fontSizeScale=e/h,this.ctx.font="".concat(l," ").concat(o," ").concat(h,"px ").concat(s)}}setTextRenderingMode(t){this.current.textRenderingMode=t}setTextRise(t){this.current.textRise=t}moveText(t,e){this.current.x=this.current.lineX+=t,this.current.y=this.current.lineY+=e}setLeadingMoveText(t,e){this.setLeading(-e),this.moveText(t,e)}setTextMatrix(t,e,r,n,i,a){this.current.textMatrix=[t,e,r,n,i,a],this.current.textMatrixScale=Math.hypot(t,e),this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}nextLine(){this.moveText(0,this.current.leading)}paintChar(t,e,r,n,i){var a,s=this.ctx,o=this.current,l=o.font,h=o.textRenderingMode,c=o.fontSize/o.fontSizeScale,u=h&Xot,d=!!(h&$ot),p=o.patternFill&&!l.missingFile,f=o.patternStroke&&!l.missingFile;if((l.disableFontFace||d||p||f)&&(a=l.getPathGenerator(this.commonObjs,t)),l.disableFontFace||p||f){if(s.save(),s.translate(e,r),s.scale(c,-c),u===Got||u===Vot)if(n){var g=s.getTransform();s.setTransform(...n),s.fill(iit(Cft,this,Oft).call(this,a,g,n))}else s.fill(a);if(u===Yot||u===Vot)if(i){var v=s.getTransform();s.setTransform(...i),s.stroke(iit(Cft,this,Oft).call(this,a,v,i))}else s.lineWidth/=c,s.stroke(a);s.restore()}else u!==Got&&u!==Vot||s.fillText(t,e,r),u!==Yot&&u!==Vot||s.strokeText(t,e,r);d&&(this.pendingTextPaths||(this.pendingTextPaths=[])).push({transform:vht(s),x:e,y:r,fontSize:c,path:a})}get isFontSubpixelAAEnabled(){var{context:t}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);t.scale(1.5,1),t.fillText("I",0,10);for(var e=t.getImageData(0,0,10,10).data,r=!1,n=3;n<e.length;n+=4)if(e[n]>0&&e[n]<255){r=!0;break}return Ilt(this,"isFontSubpixelAAEnabled",r)}showText(t){var e=this.current,r=e.font;if(r.isType3Font)return this.showType3Text(t);var n=e.fontSize;if(0!==n){var i,a,s=this.ctx,o=e.fontSizeScale,l=e.charSpacing,h=e.wordSpacing,c=e.fontDirection,u=e.textHScale*c,d=t.length,p=r.vertical,f=p?1:-1,g=r.defaultVMetrics,v=n*e.fontMatrix[0],m=e.textRenderingMode===Got&&!r.disableFontFace&&!e.patternFill;if(s.save(),s.transform(...e.textMatrix),s.translate(e.x,e.y+e.textRise),c>0?s.scale(u,-1):s.scale(u,1),e.patternFill){s.save();var y=e.fillColor.getPattern(s,this,mht(s),rft);i=vht(s),s.restore(),s.fillStyle=y}if(e.patternStroke){s.save();var b=e.strokeColor.getPattern(s,this,mht(s),nft);a=vht(s),s.restore(),s.strokeStyle=b}var w=e.lineWidth,x=e.textMatrixScale;if(0===x||0===w){var A=e.textRenderingMode&Xot;A!==Yot&&A!==Vot||(w=this.getSinglePixelWidth())}else w/=x;if(1!==o&&(s.scale(o,o),w/=o),s.lineWidth=w,r.isInvalidPDFjsFont){var _=[],k=0;for(var S of t)_.push(S.unicode),k+=S.width;return s.fillText(_.join(""),0,0),e.x+=k*v*u,s.restore(),void this.compose()}var E,M=0;for(E=0;E<d;++E){var T=t[E];if("number"!=typeof T){var C=!1,P=(T.isSpace?h:0)+l,I=T.fontChar,R=T.accent,O=void 0,L=void 0,D=T.width;if(p){var F=T.vmetric||g,N=-(T.vmetric?F[1]:.5*D)*v,j=F[2]*v;D=F?-F[0]:D,O=N/o,L=(M+j)/o}else O=M/o,L=0;if(r.remeasure&&D>0){var B=1e3*s.measureText(I).width/n*o;if(D<B&&this.isFontSubpixelAAEnabled){var z=D/B;C=!0,s.save(),s.scale(z,1),O/=z}else D!==B&&(O+=(D-B)/2e3*n/o)}if(this.contentVisible&&(T.isInFont||r.missingFile))if(m&&!R)s.fillText(I,O,L);else if(this.paintChar(I,O,L,i,a),R){var W=O+n*R.offset.x/o,U=L-n*R.offset.y/o;this.paintChar(R.fontChar,W,U,i,a)}M+=p?D*v-P*c:D*v+P*c,C&&s.restore()}else M+=f*T*n/1e3}p?e.y-=M:e.x+=M*u,s.restore(),this.compose()}}showType3Text(t){var e,r,n,i,a=this.ctx,s=this.current,o=s.font,l=s.fontSize,h=s.fontDirection,c=o.vertical?1:-1,u=s.charSpacing,d=s.wordSpacing,p=s.textHScale*h,f=s.fontMatrix||Pot,g=t.length;if(!(s.textRenderingMode===qot)&&0!==l){for(this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,a.save(),a.transform(...s.textMatrix),a.translate(s.x,s.y),a.scale(p,h),e=0;e<g;++e)if("number"!=typeof(r=t[e])){var v=(r.isSpace?d:0)+u,m=o.charProcOperatorList[r.operatorListId];if(m)this.contentVisible&&(this.processingType3=r,this.save(),a.scale(l,l),a.transform(...f),this.executeOperatorList(m),this.restore()),n=Ylt.applyTransform([r.width,0],f)[0]*l+v,a.translate(n,0),s.x+=n*p;else Mlt('Type3 character "'.concat(r.operatorListId,'" is not available.'))}else i=c*r*l/1e3,this.ctx.translate(i,0),s.x+=i*p;a.restore(),this.processingType3=null}}setCharWidth(t,e){}setCharWidthAndBounds(t,e,r,n,i,a){this.ctx.rect(r,n,i-r,a-n),this.ctx.clip(),this.endPath()}getColorN_Pattern(t){var e;if("TilingPattern"===t[0]){var r=t[1],n=this.baseTransform||vht(this.ctx),i={createCanvasGraphics:t=>new Pft(t,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};e=new fft(t,r,this.ctx,i,n)}else e=this._getPattern(t[1],t[2]);return e}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments),this.current.patternStroke=!0}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0}setStrokeRGBColor(t,e,r){this.ctx.strokeStyle=this.current.strokeColor=Ylt.makeHexColor(t,e,r),this.current.patternStroke=!1}setStrokeTransparent(){this.ctx.strokeStyle=this.current.strokeColor="transparent",this.current.patternStroke=!1}setFillRGBColor(t,e,r){this.ctx.fillStyle=this.current.fillColor=Ylt.makeHexColor(t,e,r),this.current.patternFill=!1}setFillTransparent(){this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1}_getPattern(t){var e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return this.cachedPatterns.has(t)?e=this.cachedPatterns.get(t):(e=function(t){switch(t[0]){case"RadialAxial":return new oft(t);case"Mesh":return new cft(t);case"Dummy":return new uft}throw new Error("Unknown IR type: ".concat(t[0]))}(this.getObject(t)),this.cachedPatterns.set(t,e)),r&&(e.matrix=r),e}shadingFill(t){if(this.contentVisible){var e=this.ctx;this.save();var r=this._getPattern(t);e.fillStyle=r.getPattern(e,this,mht(e),ift);var n=mht(e);if(n){var{width:i,height:a}=e.canvas,[s,o,l,h]=Ylt.getAxialAlignedBoundingBox([0,0,i,a],n);this.ctx.fillRect(s,o,l-s,h-o)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}}beginInlineImage(){Tlt("Should not call beginInlineImage")}beginImageData(){Tlt("Should not call beginImageData")}paintFormXObjectBegin(t,e){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),t&&this.transform(...t),this.baseTransform=vht(this.ctx),e)){var r=e[2]-e[0],n=e[3]-e[1];this.ctx.rect(e[0],e[1],r,n),this.current.updateRectMinMax(vht(this.ctx),e),this.clip(),this.endPath()}}paintFormXObjectEnd(){this.contentVisible&&(this.restore(),this.baseTransform=this.baseTransformStack.pop())}beginGroup(t){if(this.contentVisible){this.save(),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);var e=this.ctx;t.isolated||Elt("TODO: Support non-isolated groups."),t.knockout&&Mlt("Knockout groups not supported.");var r=vht(e);if(t.matrix&&e.transform(...t.matrix),!t.bbox)throw new Error("Bounding box is required.");var n=Ylt.getAxialAlignedBoundingBox(t.bbox,vht(e)),i=[0,0,e.canvas.width,e.canvas.height];n=Ylt.intersect(n,i)||[0,0,0,0];var a=Math.floor(n[0]),s=Math.floor(n[1]),o=Math.max(Math.ceil(n[2])-a,1),l=Math.max(Math.ceil(n[3])-s,1);this.current.startNewPathAndClipBox([0,0,o,l]);var h="groupAt"+this.groupLevel;t.smask&&(h+="_smask_"+this.smaskCounter++%2);var c=this.cachedCanvases.getCanvas(h,o,l),u=c.context;u.translate(-a,-s),u.transform(...r),t.smask?this.smaskStack.push({canvas:c.canvas,context:u,offsetX:a,offsetY:s,subtype:t.smask.subtype,backdrop:t.smask.backdrop,transferMap:t.smask.transferMap||null,startTransformInverse:null}):(e.setTransform(1,0,0,1,0,0),e.translate(a,s),e.save()),Aft(e,u),this.ctx=u,this.setGState([["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(e),this.groupLevel++}}endGroup(t){if(this.contentVisible){this.groupLevel--;var e=this.ctx,r=this.groupStack.pop();if(this.ctx=r,this.ctx.imageSmoothingEnabled=!1,t.smask)this.tempSMask=this.smaskStack.pop(),this.restore();else{this.ctx.restore();var n=vht(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...n);var i=Ylt.getAxialAlignedBoundingBox([0,0,e.canvas.width,e.canvas.height],n);this.ctx.drawImage(e.canvas,0,0),this.ctx.restore(),this.compose(i)}}}beginAnnotation(t,e,r,n,i){if(iit(Cft,this,Ift).call(this),_ft(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),e){var a=e[2]-e[0],s=e[3]-e[1];if(i&&this.annotationCanvasMap){(r=r.slice())[4]-=e[0],r[5]-=e[1],(e=e.slice())[0]=e[1]=0,e[2]=a,e[3]=s;var[o,l]=Ylt.singularValueDecompose2dScale(vht(this.ctx)),{viewportScale:h}=this,c=Math.ceil(a*this.outputScaleX*h),u=Math.ceil(s*this.outputScaleY*h);this.annotationCanvas=this.canvasFactory.create(c,u);var{canvas:d,context:p}=this.annotationCanvas;this.annotationCanvasMap.set(t,d),this.annotationCanvas.savedCtx=this.ctx,this.ctx=p,this.ctx.save(),this.ctx.setTransform(o,0,0,-l,0,s*l),_ft(this.ctx)}else _ft(this.ctx),this.endPath(),this.ctx.rect(e[0],e[1],a,s),this.ctx.clip(),this.ctx.beginPath()}this.current=new bft(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...r),this.transform(...n)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),iit(Cft,this,Rft).call(this),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(t){if(this.contentVisible){var e=t.count;(t=this.getObject(t.data,t)).count=e;var r=this.ctx,n=this.processingType3;if(n&&(void 0===n.compiled&&(n.compiled=function(t){var{width:e,height:r}=t;if(e>1e3||r>1e3)return null;var n,i,a,s=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]),o=e+1,l=new Uint8Array(o*(r+1)),h=e+7&-8,c=new Uint8Array(h*r),u=0;for(var d of t.data)for(var p=128;p>0;)c[u++]=d&p?0:255,p>>=1;var f=0;for(0!==c[u=0]&&(l[0]=1,++f),i=1;i<e;i++)c[u]!==c[u+1]&&(l[i]=c[u]?2:1,++f),u++;for(0!==c[u]&&(l[i]=2,++f),n=1;n<r;n++){a=n*o,c[(u=n*h)-h]!==c[u]&&(l[a]=c[u]?1:8,++f);var g=(c[u]?4:0)+(c[u-h]?8:0);for(i=1;i<e;i++)s[g=(g>>2)+(c[u+1]?4:0)+(c[u-h+1]?8:0)]&&(l[a+i]=s[g],++f),u++;if(c[u-h]!==c[u]&&(l[a+i]=c[u]?2:4,++f),f>1e3)return null}for(a=n*o,0!==c[u=h*(r-1)]&&(l[a]=8,++f),i=1;i<e;i++)c[u]!==c[u+1]&&(l[a+i]=c[u]?4:8,++f),u++;if(0!==c[u]&&(l[a+i]=4,++f),f>1e3)return null;var v=new Int32Array([0,o,-1,0,-o,0,0,0,1]),m=new Path2D;for(n=0;f&&n<=r;n++){for(var y=n*o,b=y+e;y<b&&!l[y];)y++;if(y!==b){m.moveTo(y%o,n);var w=y,x=l[y];do{var A=v[x];do{y+=A}while(!l[y]);var _=l[y];5!==_&&10!==_?(x=_,l[y]=0):(x=_&51*x>>4,l[y]&=x>>2|x<<2),m.lineTo(y%o,y/o|0),l[y]||--f}while(w!==y);--n}}return c=null,l=null,function(t){t.save(),t.scale(1/e,-1/r),t.translate(0,-r),t.fill(m),t.beginPath(),t.restore()}}(t)),n.compiled))n.compiled(r);else{var i=this._createMaskCanvas(t),a=i.canvas;r.save(),r.setTransform(1,0,0,1,0,0),r.drawImage(a,i.offsetX,i.offsetY),r.restore(),this.compose()}}}paintImageMaskXObjectRepeat(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,i=arguments.length>4?arguments[4]:void 0,a=arguments.length>5?arguments[5]:void 0;if(this.contentVisible){t=this.getObject(t.data,t);var s=this.ctx;s.save();var o=vht(s);s.transform(e,r,n,i,0,0);var l=this._createMaskCanvas(t);s.setTransform(1,0,0,1,l.offsetX-o[4],l.offsetY-o[5]);for(var h=0,c=a.length;h<c;h+=2){var u=Ylt.transform(o,[e,r,n,i,a[h],a[h+1]]),[d,p]=Ylt.applyTransform([0,0],u);s.drawImage(l.canvas,d,p)}s.restore(),this.compose()}}paintImageMaskXObjectGroup(t){if(this.contentVisible){var e=this.ctx,r=this.current.fillColor,n=this.current.patternFill;for(var i of t){var{data:a,width:s,height:o,transform:l}=i,h=this.cachedCanvases.getCanvas("maskCanvas",s,o),c=h.context;c.save(),xft(c,this.getObject(a,i)),c.globalCompositeOperation="source-in",c.fillStyle=n?r.getPattern(c,this,mht(e),rft):r,c.fillRect(0,0,s,o),c.restore(),e.save(),e.transform(...l),e.scale(1,-1),yft(e,h.canvas,0,0,s,o,0,-1,1,1),e.restore()}this.compose()}}paintImageXObject(t){if(this.contentVisible){var e=this.getObject(t);e?this.paintInlineImageXObject(e):Mlt("Dependent image isn't ready yet")}}paintImageXObjectRepeat(t,e,r,n){if(this.contentVisible){var i=this.getObject(t);if(i){for(var a=i.width,s=i.height,o=[],l=0,h=n.length;l<h;l+=2)o.push({transform:[e,0,0,r,n[l],n[l+1]],x:0,y:0,w:a,h:s});this.paintInlineImageXObjectGroup(i,o)}else Mlt("Dependent image isn't ready yet")}}applyTransferMapsToCanvas(t){return"none"!==this.current.transferMaps&&(t.filter=this.current.transferMaps,t.drawImage(t.canvas,0,0),t.filter="none"),t.canvas}applyTransferMapsToBitmap(t){if("none"===this.current.transferMaps)return t.bitmap;var{bitmap:e,width:r,height:n}=t,i=this.cachedCanvases.getCanvas("inlineImage",r,n),a=i.context;return a.filter=this.current.transferMaps,a.drawImage(e,0,0),a.filter="none",i.canvas}paintInlineImageXObject(t){if(this.contentVisible){var e,r=t.width,n=t.height,i=this.ctx;if(this.save(),!Tot){var{filter:a}=i;"none"!==a&&""!==a&&(i.filter="none")}if(i.scale(1/r,-1/n),t.bitmap)e=this.applyTransferMapsToBitmap(t);else if("function"==typeof HTMLElement&&t instanceof HTMLElement||!t.data)e=t;else{var s=this.cachedCanvases.getCanvas("inlineImage",r,n).context;wft(s,t),e=this.applyTransferMapsToCanvas(s)}var o=this._scaleImage(e,mht(i));i.imageSmoothingEnabled=kft(vht(i),t.interpolate),yft(i,o.img,0,0,o.paintWidth,o.paintHeight,0,-n,r,n),this.compose(),this.restore()}}paintInlineImageXObjectGroup(t,e){if(this.contentVisible){var r,n=this.ctx;if(t.bitmap)r=t.bitmap;else{var i=t.width,a=t.height,s=this.cachedCanvases.getCanvas("inlineImage",i,a).context;wft(s,t),r=this.applyTransferMapsToCanvas(s)}for(var o of e)n.save(),n.transform(...o.transform),n.scale(1,-1),yft(n,r,o.x,o.y,o.w,o.h,0,-1,1,1),n.restore();this.compose()}}paintSolidColorImageMask(){this.contentVisible&&(this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(t){}markPointProps(t,e){}beginMarkedContent(t){this.markedContentStack.push({visible:!0})}beginMarkedContentProps(t,e){"OC"===t?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(e)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(){this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(){}endCompat(){}consumePath(t){var e=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(t);var r=this.ctx;this.pendingClip&&(e||(this.pendingClip===Tft?r.clip("evenodd"):r.clip()),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox),r.beginPath()}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){var t=vht(this.ctx);if(0===t[1]&&0===t[2])this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(t[0]),Math.abs(t[3]));else{var e=Math.abs(t[0]*t[3]-t[2]*t[1]),r=Math.hypot(t[0],t[2]),n=Math.hypot(t[1],t[3]);this._cachedGetSinglePixelWidth=Math.max(r,n)/e}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(-1===this._cachedScaleForStroking[0]){var t,e,{lineWidth:r}=this.current,{a:n,b:i,c:a,d:s}=this.ctx.getTransform();if(0===i&&0===a){var o=Math.abs(n),l=Math.abs(s);if(o===l)if(0===r)t=e=1/o;else{var h=o*r;t=e=h<1?1/h:1}else if(0===r)t=1/o,e=1/l;else{var c=o*r,u=l*r;t=c<1?1/c:1,e=u<1?1/u:1}}else{var d=Math.abs(n*s-i*a),p=Math.hypot(n,i),f=Math.hypot(a,s);if(0===r)t=f/d,e=p/d;else{var g=r*d;t=f>g?f/g:1,e=p>g?p/g:1}}this._cachedScaleForStroking[0]=t,this._cachedScaleForStroking[1]=e}return this._cachedScaleForStroking}rescaleAndStroke(t){var{ctx:e}=this,{lineWidth:r}=this.current,[n,i]=this.getScaleForStroking();if(e.lineWidth=r||1,1!==n||1!==i){var a=e.getLineDash();if(t&&e.save(),e.scale(n,i),a.length>0){var s=Math.max(n,i);e.setLineDash(a.map((t=>t/s))),e.lineDashOffset/=s}e.stroke(),t&&e.restore()}else e.stroke()}isContentVisible(){for(var t=this.markedContentStack.length-1;t>=0;t--)if(!this.markedContentStack[t].visible)return!1;return!0}}function Ift(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.current.activeSMask=null,this.ctx.restore(),this.transparentCanvas&&(this.ctx=this.compositeCtx,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.drawImage(this.transparentCanvas,0,0),this.ctx.restore(),this.transparentCanvas=null)}function Rft(){if(this.pageColors){var t=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if("none"!==t){var e=this.ctx.filter;this.ctx.filter=t,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=e}}}function Oft(t,e,r){var n=new Path2D;return n.addPath(t,new DOMMatrix(r).invertSelf().multiplySelf(e)),n}for(var Lft in xlt)void 0!==Pft.prototype[Lft]&&(Pft.prototype[xlt[Lft]]=Pft.prototype[Lft]);class Dft{static get workerPort(){return iit(Dft,this,Fft)._}static set workerPort(t){if(!("undefined"!=typeof Worker&&t instanceof Worker)&&null!==t)throw new Error("Invalid `workerPort` type.");Fft._=iit(Dft,this,t)}static get workerSrc(){return iit(Dft,this,Nft)._}static set workerSrc(t){if("string"!=typeof t)throw new Error("Invalid `workerSrc` type.");Nft._=iit(Dft,this,t)}}var Fft={_:null},Nft={_:""},jft=new WeakMap,Bft=new WeakMap;class zft{constructor(t){var{parsedData:e,rawData:r}=t;hit(this,jft,void 0),hit(this,Bft,void 0),cit(jft,this,e),cit(Bft,this,r)}getRaw(){return lit(Bft,this)}get(t){var e;return null!==(e=lit(jft,this).get(t))&&void 0!==e?e:null}getAll(){return Ult(lit(jft,this))}has(t){return lit(jft,this).has(t)}}var Wft=Symbol("INTERNAL"),Uft=new WeakMap,Hft=new WeakMap,Gft=new WeakMap,Yft=new WeakMap;class Vft{constructor(t,e){var{name:r,intent:n,usage:i,rbGroups:a}=e;hit(this,Uft,!1),hit(this,Hft,!1),hit(this,Gft,!1),hit(this,Yft,!0),cit(Uft,this,!!(t&Oot)),cit(Hft,this,!!(t&Lot)),this.name=r,this.intent=n,this.usage=i,this.rbGroups=a}get visible(){if(lit(Gft,this))return lit(Yft,this);if(!lit(Yft,this))return!1;var{print:t,view:e}=this.usage;return lit(Uft,this)?"OFF"!==(null==e?void 0:e.viewState):!lit(Hft,this)||"OFF"!==(null==t?void 0:t.printState)}_setVisible(t,e){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];t!==Wft&&Tlt("Internal method `_setVisible` called."),cit(Gft,this,r),cit(Yft,this,e)}}var qft=new WeakMap,Xft=new WeakMap,$ft=new WeakMap,Kft=new WeakMap,Qft=new WeakSet;class Jft{constructor(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Oot;if(dit(this,Qft),hit(this,qft,null),hit(this,Xft,new Map),hit(this,$ft,null),hit(this,Kft,null),this.renderingIntent=e,this.name=null,this.creator=null,null!==t){for(var r of(this.name=t.name,this.creator=t.creator,cit(Kft,this,t.order),t.groups))lit(Xft,this).set(r.id,new Vft(e,r));if("OFF"===t.baseState)for(var n of lit(Xft,this).values())n._setVisible(Wft,!1);for(var i of t.on)lit(Xft,this).get(i)._setVisible(Wft,!0);for(var a of t.off)lit(Xft,this).get(a)._setVisible(Wft,!1);cit($ft,this,this.getHash())}}isVisible(t){if(0===lit(Xft,this).size)return!0;if(!t)return Elt("Optional content group not defined."),!0;if("OCG"===t.type)return lit(Xft,this).has(t.id)?lit(Xft,this).get(t.id).visible:(Mlt("Optional content group not found: ".concat(t.id)),!0);if("OCMD"===t.type){if(t.expression)return iit(Qft,this,Zft).call(this,t.expression);if(!t.policy||"AnyOn"===t.policy){for(var e of t.ids){if(!lit(Xft,this).has(e))return Mlt("Optional content group not found: ".concat(e)),!0;if(lit(Xft,this).get(e).visible)return!0}return!1}if("AllOn"===t.policy){for(var r of t.ids){if(!lit(Xft,this).has(r))return Mlt("Optional content group not found: ".concat(r)),!0;if(!lit(Xft,this).get(r).visible)return!1}return!0}if("AnyOff"===t.policy){for(var n of t.ids){if(!lit(Xft,this).has(n))return Mlt("Optional content group not found: ".concat(n)),!0;if(!lit(Xft,this).get(n).visible)return!0}return!1}if("AllOff"===t.policy){for(var i of t.ids){if(!lit(Xft,this).has(i))return Mlt("Optional content group not found: ".concat(i)),!0;if(lit(Xft,this).get(i).visible)return!1}return!0}return Mlt("Unknown optional content policy ".concat(t.policy,".")),!0}return Mlt("Unknown group type ".concat(t.type,".")),!0}setVisibility(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],n=lit(Xft,this).get(t);if(n){if(r&&e&&n.rbGroups.length)for(var i of n.rbGroups)for(var a of i){var s;if(a!==t)null===(s=lit(Xft,this).get(a))||void 0===s||s._setVisible(Wft,!1,!0)}n._setVisible(Wft,!!e,!0),cit(qft,this,null)}else Mlt("Optional content group not found: ".concat(t))}setOCGState(t){var e,{state:r,preserveRB:n}=t;for(var i of r){switch(i){case"ON":case"OFF":case"Toggle":e=i;continue}var a=lit(Xft,this).get(i);if(a)switch(e){case"ON":this.setVisibility(i,!0,n);break;case"OFF":this.setVisibility(i,!1,n);break;case"Toggle":this.setVisibility(i,!a.visible,n)}}cit(qft,this,null)}get hasInitialVisibility(){return null===lit($ft,this)||this.getHash()===lit($ft,this)}getOrder(){return lit(Xft,this).size?lit(Kft,this)?lit(Kft,this).slice():[...lit(Xft,this).keys()]:null}getGroups(){return lit(Xft,this).size>0?Ult(lit(Xft,this)):null}getGroup(t){return lit(Xft,this).get(t)||null}getHash(){if(null!==lit(qft,this))return lit(qft,this);var t=new Xdt;for(var[e,r]of lit(Xft,this))t.update("".concat(e,":").concat(r.visible));return cit(qft,this,t.hexdigest())}}function Zft(t){var e=t.length;if(e<2)return!0;for(var r=t[0],n=1;n<e;n++){var i=t[n],a=void 0;if(Array.isArray(i))a=iit(Qft,this,Zft).call(this,i);else{if(!lit(Xft,this).has(i))return Mlt("Optional content group not found: ".concat(i)),!0;a=lit(Xft,this).get(i).visible}switch(r){case"And":if(!a)return!1;break;case"Or":if(a)return!0;break;case"Not":return!a;default:return!0}}return"And"===r}class tgt{constructor(t,e){var{disableRange:r=!1,disableStream:n=!1}=e;Clt(t,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');var{length:i,initialData:a,progressiveDone:s,contentDispositionFilename:o}=t;if(this._queuedChunks=[],this._progressiveDone=s,this._contentDispositionFilename=o,(null==a?void 0:a.length)>0){var l=a instanceof Uint8Array&&a.byteLength===a.buffer.byteLength?a.buffer:new Uint8Array(a).buffer;this._queuedChunks.push(l)}this._pdfDataRangeTransport=t,this._isStreamingSupported=!n,this._isRangeSupported=!r,this._contentLength=i,this._fullRequestReader=null,this._rangeReaders=[],t.addRangeListener(((t,e)=>{this._onReceiveData({begin:t,chunk:e})})),t.addProgressListener(((t,e)=>{this._onProgress({loaded:t,total:e})})),t.addProgressiveReadListener((t=>{this._onReceiveData({chunk:t})})),t.addProgressiveDoneListener((()=>{this._onProgressiveDone()})),t.transportReady()}_onReceiveData(t){var{begin:e,chunk:r}=t,n=r instanceof Uint8Array&&r.byteLength===r.buffer.byteLength?r.buffer:new Uint8Array(r).buffer;void 0===e?this._fullRequestReader?this._fullRequestReader._enqueue(n):this._queuedChunks.push(n):Clt(this._rangeReaders.some((function(t){return t._begin===e&&(t._enqueue(n),!0)})),"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}get _progressiveDataLength(){var t,e;return null!==(t=null===(e=this._fullRequestReader)||void 0===e?void 0:e._loaded)&&void 0!==t?t:0}_onProgress(t){var e,r,n,i;void 0===t.total?null===(e=this._rangeReaders[0])||void 0===e||null===(r=e.onProgress)||void 0===r||r.call(e,{loaded:t.loaded}):null===(n=this._fullRequestReader)||void 0===n||null===(i=n.onProgress)||void 0===i||i.call(n,{loaded:t.loaded,total:t.total})}_onProgressiveDone(){var t;null===(t=this._fullRequestReader)||void 0===t||t.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(t){var e=this._rangeReaders.indexOf(t);e>=0&&this._rangeReaders.splice(e,1)}getFullReader(){Clt(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");var t=this._queuedChunks;return this._queuedChunks=null,new egt(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;var r=new rgt(this,t,e);return this._pdfDataRangeTransport.requestDataRange(t,e),this._rangeReaders.push(r),r}cancelAllRequests(t){var e;for(var r of(null===(e=this._fullRequestReader)||void 0===e||e.cancel(t),this._rangeReaders.slice(0)))r.cancel(t);this._pdfDataRangeTransport.abort()}}class egt{constructor(t,e){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;for(var i of(this._stream=t,this._done=r||!1,this._filename=aht(n)?n:null,this._queuedChunks=e||[],this._loaded=0,this._queuedChunks))this._loaded+=i.byteLength;this._requests=[],this._headersReady=Promise.resolve(),t._fullRequestReader=this,this.onProgress=null}_enqueue(t){if(!this._done){if(this._requests.length>0)this._requests.shift().resolve({value:t,done:!1});else this._queuedChunks.push(t);this._loaded+=t.byteLength}}get headersReady(){return this._headersReady}get filename(){return this._filename}get isRangeSupported(){return this._stream._isRangeSupported}get isStreamingSupported(){return this._stream._isStreamingSupported}get contentLength(){return this._stream._contentLength}read(){var t=this;return sit((function*(){if(t._queuedChunks.length>0)return{value:t._queuedChunks.shift(),done:!1};if(t._done)return{value:void 0,done:!0};var e=Promise.withResolvers();return t._requests.push(e),e.promise}))()}cancel(t){for(var e of(this._done=!0,this._requests))e.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class rgt{constructor(t,e,r){this._stream=t,this._begin=e,this._end=r,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(t){if(!this._done){if(0===this._requests.length)this._queuedChunk=t;else{var e=this._requests.shift();for(var r of(e.resolve({value:t,done:!1}),this._requests))r.resolve({value:void 0,done:!0});this._requests.length=0}this._done=!0,this._stream._removeRangeReader(this)}}get isStreamingSupported(){return!1}read(){var t=this;return sit((function*(){if(t._queuedChunk){var e=t._queuedChunk;return t._queuedChunk=null,{value:e,done:!1}}if(t._done)return{value:void 0,done:!0};var r=Promise.withResolvers();return t._requests.push(r),r.promise}))()}cancel(t){for(var e of(this._done=!0,this._requests))e.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}function ngt(t,e){var r=new Headers;if(!t||!e||"object"!=typeof e)return r;for(var n in e){var i=e[n];void 0!==i&&r.append(n,i)}return r}function igt(t){try{return new URL(t).origin}catch(t){}return null}function agt(t){var{responseHeaders:e,isHttp:r,rangeChunkSize:n,disableRange:i}=t,a={allowRangeRequests:!1,suggestedLength:void 0},s=parseInt(e.get("Content-Length"),10);return Number.isInteger(s)?(a.suggestedLength=s,s<=2*n||i||!r||"bytes"!==e.get("Accept-Ranges")||"identity"!==(e.get("Content-Encoding")||"identity")||(a.allowRangeRequests=!0),a):a}function sgt(t){var e=t.get("Content-Disposition");if(e){var r=function(t){var e=!0,r=a("filename\\*","i").exec(t);if(r){var n=l(r=r[1]);return o(n=c(n=h(n=unescape(n))))}if(r=function(t){for(var e,r=[],n=a("filename\\*((?!0\\d)\\d+)(\\*?)","ig");null!==(e=n.exec(t));){var[,i,s,o]=e;if((i=parseInt(i,10))in r){if(0===i)break}else r[i]=[s,o]}for(var c=[],u=0;u<r.length&&u in r;++u){var[d,p]=r[u];p=l(p),d&&(p=unescape(p),0===u&&(p=h(p))),c.push(p)}return c.join("")}(t),r)return o(c(r));if(r=a("filename","i").exec(t)){var i=l(r=r[1]);return o(i=c(i))}function a(t,e){return new RegExp("(?:^|;)\\s*"+t+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',e)}function s(t,r){if(t){if(!/^[\x00-\xFF]+$/.test(r))return r;try{var n=new TextDecoder(t,{fatal:!0}),i=Wlt(r);r=n.decode(i),e=!1}catch(t){}}return r}function o(t){return e&&/[\x80-\xff]/.test(t)&&(t=s("utf-8",t),e&&(t=s("iso-8859-1",t))),t}function l(t){if(t.startsWith('"')){for(var e=t.slice(1).split('\\"'),r=0;r<e.length;++r){var n=e[r].indexOf('"');-1!==n&&(e[r]=e[r].slice(0,n),e.length=r+1),e[r]=e[r].replaceAll(/\\(.)/g,"$1")}t=e.join('"')}return t}function h(t){var e=t.indexOf("'");return-1===e?t:s(t.slice(0,e),t.slice(e+1).replace(/^[^']*'/,""))}function c(t){return!t.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(t)?t:t.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,(function(t,e,r,n){if("q"===r||"Q"===r)return n=(n=n.replaceAll("_"," ")).replaceAll(/=([0-9a-fA-F]{2})/g,(function(t,e){return String.fromCharCode(parseInt(e,16))})),s(e,n);try{n=atob(n)}catch(t){}return s(e,n)}))}return""}(e);if(r.includes("%"))try{r=decodeURIComponent(r)}catch(t){}if(aht(r))return r}return null}function ogt(t,e){return 404===t||0===t&&e.startsWith("file:")?new Flt('Missing PDF "'+e+'".'):new Nlt("Unexpected server response (".concat(t,') while retrieving PDF "').concat(e,'".'),t)}function lgt(t){return 200===t||206===t}function hgt(t,e,r){return{method:"GET",headers:t,signal:r.signal,mode:"cors",credentials:e?"include":"same-origin",redirect:"follow"}}function cgt(t){return t instanceof Uint8Array?t.buffer:t instanceof ArrayBuffer?t:(Mlt("getArrayBuffer - unexpected data format: ".concat(t)),new Uint8Array(t).buffer)}class ugt{constructor(t){pit(this,"_responseOrigin",null),this.source=t,this.isHttp=/^https?:/i.test(t.url),this.headers=ngt(this.isHttp,t.httpHeaders),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var t,e;return null!==(t=null===(e=this._fullRequestReader)||void 0===e?void 0:e._loaded)&&void 0!==t?t:0}getFullReader(){return Clt(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new dgt(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;var r=new pgt(this,t,e);return this._rangeRequestReaders.push(r),r}cancelAllRequests(t){var e;for(var r of(null===(e=this._fullRequestReader)||void 0===e||e.cancel(t),this._rangeRequestReaders.slice(0)))r.cancel(t)}}class dgt{constructor(t){this._stream=t,this._reader=null,this._loaded=0,this._filename=null;var e=t.source;this._withCredentials=e.withCredentials||!1,this._contentLength=e.length,this._headersCapability=Promise.withResolvers(),this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._abortController=new AbortController,this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange;var r=new Headers(t.headers),n=e.url;fetch(n,hgt(r,this._withCredentials,this._abortController)).then((e=>{if(t._responseOrigin=igt(e.url),!lgt(e.status))throw ogt(e.status,n);this._reader=e.body.getReader(),this._headersCapability.resolve();var r=e.headers,{allowRangeRequests:i,suggestedLength:a}=agt({responseHeaders:r,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=i,this._contentLength=a||this._contentLength,this._filename=sgt(r),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new Blt("Streaming is disabled."))})).catch(this._headersCapability.reject),this.onProgress=null}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}read(){var t=this;return sit((function*(){var e;yield t._headersCapability.promise;var{value:r,done:n}=yield t._reader.read();return n?{value:r,done:n}:(t._loaded+=r.byteLength,null===(e=t.onProgress)||void 0===e||e.call(t,{loaded:t._loaded,total:t._contentLength}),{value:cgt(r),done:!1})}))()}cancel(t){var e;null===(e=this._reader)||void 0===e||e.cancel(t),this._abortController.abort()}}class pgt{constructor(t,e,r){this._stream=t,this._reader=null,this._loaded=0;var n=t.source;this._withCredentials=n.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!n.disableStream,this._abortController=new AbortController;var i=new Headers(t.headers);i.append("Range","bytes=".concat(e,"-").concat(r-1));var a=n.url;fetch(a,hgt(i,this._withCredentials,this._abortController)).then((e=>{var r=igt(e.url);if(r!==t._responseOrigin)throw new Error('Expected range response-origin "'.concat(r,'" to match "').concat(t._responseOrigin,'".'));if(!lgt(e.status))throw ogt(e.status,a);this._readCapability.resolve(),this._reader=e.body.getReader()})).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}read(){var t=this;return sit((function*(){var e;yield t._readCapability.promise;var{value:r,done:n}=yield t._reader.read();return n?{value:r,done:n}:(t._loaded+=r.byteLength,null===(e=t.onProgress)||void 0===e||e.call(t,{loaded:t._loaded}),{value:cgt(r),done:!1})}))()}cancel(t){var e;null===(e=this._reader)||void 0===e||e.cancel(t),this._abortController.abort()}}class fgt{constructor(t){var{url:e,httpHeaders:r,withCredentials:n}=t;pit(this,"_responseOrigin",null),this.url=e,this.isHttp=/^https?:/i.test(e),this.headers=ngt(this.isHttp,r),this.withCredentials=n||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}request(t){var e=new XMLHttpRequest,r=this.currXhrId++,n=this.pendingRequests[r]={xhr:e};for(var[i,a]of(e.open("GET",this.url),e.withCredentials=this.withCredentials,this.headers))e.setRequestHeader(i,a);return this.isHttp&&"begin"in t&&"end"in t?(e.setRequestHeader("Range","bytes=".concat(t.begin,"-").concat(t.end-1)),n.expectedStatus=206):n.expectedStatus=200,e.responseType="arraybuffer",Clt(t.onError,"Expected `onError` callback to be provided."),e.onerror=()=>{t.onError(e.status)},e.onreadystatechange=this.onStateChange.bind(this,r),e.onprogress=this.onProgress.bind(this,r),n.onHeadersReceived=t.onHeadersReceived,n.onDone=t.onDone,n.onError=t.onError,n.onProgress=t.onProgress,e.send(null),r}onProgress(t,e){var r,n=this.pendingRequests[t];n&&(null===(r=n.onProgress)||void 0===r||r.call(n,e))}onStateChange(t,e){var r=this.pendingRequests[t];if(r){var n=r.xhr;if(n.readyState>=2&&r.onHeadersReceived&&(r.onHeadersReceived(),delete r.onHeadersReceived),4===n.readyState&&t in this.pendingRequests)if(delete this.pendingRequests[t],0===n.status&&this.isHttp)r.onError(n.status);else{var i=n.status||200;if(200===i&&206===r.expectedStatus||i===r.expectedStatus){var a=function(t){var e=t.response;return"string"!=typeof e?e:Wlt(e).buffer}(n);if(206===i){var s=n.getResponseHeader("Content-Range"),o=/bytes (\d+)-(\d+)\/(\d+)/.exec(s);o?r.onDone({begin:parseInt(o[1],10),chunk:a}):(Mlt('Missing or invalid "Content-Range" header.'),r.onError(0))}else a?r.onDone({begin:0,chunk:a}):r.onError(n.status)}else r.onError(n.status)}}}getRequestXhr(t){return this.pendingRequests[t].xhr}isPendingRequest(t){return t in this.pendingRequests}abortRequest(t){var e=this.pendingRequests[t].xhr;delete this.pendingRequests[t],e.abort()}}class ggt{constructor(t){this._source=t,this._manager=new fgt(t),this._rangeChunkSize=t.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(t){var e=this._rangeRequestReaders.indexOf(t);e>=0&&this._rangeRequestReaders.splice(e,1)}getFullReader(){return Clt(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new vgt(this._manager,this._source),this._fullRequestReader}getRangeReader(t,e){var r=new mgt(this._manager,t,e);return r.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(r),r}cancelAllRequests(t){var e;for(var r of(null===(e=this._fullRequestReader)||void 0===e||e.cancel(t),this._rangeRequestReaders.slice(0)))r.cancel(t)}}class vgt{constructor(t,e){this._manager=t,this._url=e.url,this._fullRequestId=t.request({onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._headersCapability=Promise.withResolvers(),this._disableRange=e.disableRange||!1,this._contentLength=e.length,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._isStreamingSupported=!1,this._isRangeSupported=!1,this._cachedChunks=[],this._requests=[],this._done=!1,this._storedError=void 0,this._filename=null,this.onProgress=null}_onHeadersReceived(){var t=this._fullRequestId,e=this._manager.getRequestXhr(t);this._manager._responseOrigin=igt(e.responseURL);var r=e.getAllResponseHeaders(),n=new Headers(r?r.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map((t=>{var[e,...r]=t.split(": ");return[e,r.join(": ")]})):[]),{allowRangeRequests:i,suggestedLength:a}=agt({responseHeaders:n,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});i&&(this._isRangeSupported=!0),this._contentLength=a||this._contentLength,this._filename=sgt(n),this._isRangeSupported&&this._manager.abortRequest(t),this._headersCapability.resolve()}_onDone(t){t&&(this._requests.length>0?this._requests.shift().resolve({value:t.chunk,done:!1}):this._cachedChunks.push(t.chunk));if(this._done=!0,!(this._cachedChunks.length>0)){for(var e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(t){for(var e of(this._storedError=ogt(t,this._url),this._headersCapability.reject(this._storedError),this._requests))e.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(t){var e;null===(e=this.onProgress)||void 0===e||e.call(this,{loaded:t.loaded,total:t.lengthComputable?t.total:this._contentLength})}get filename(){return this._filename}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}get contentLength(){return this._contentLength}get headersReady(){return this._headersCapability.promise}read(){var t=this;return sit((function*(){if(yield t._headersCapability.promise,t._storedError)throw t._storedError;if(t._cachedChunks.length>0)return{value:t._cachedChunks.shift(),done:!1};if(t._done)return{value:void 0,done:!0};var e=Promise.withResolvers();return t._requests.push(e),e.promise}))()}cancel(t){for(var e of(this._done=!0,this._headersCapability.reject(t),this._requests))e.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId),this._fullRequestReader=null}}class mgt{constructor(t,e,r){this._manager=t,this._url=t.url,this._requestId=t.request({begin:e,end:r,onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_onHeadersReceived(){var t,e=igt(null===(t=this._manager.getRequestXhr(this._requestId))||void 0===t?void 0:t.responseURL);e!==this._manager._responseOrigin&&(this._storedError=new Error('Expected range response-origin "'.concat(e,'" to match "').concat(this._manager._responseOrigin,'".')),this._onError(0))}_close(){var t;null===(t=this.onClosed)||void 0===t||t.call(this,this)}_onDone(t){var e=t.chunk;this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunk=e;for(var r of(this._done=!0,this._requests))r.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(t){var e;for(var r of(null!==(e=this._storedError)&&void 0!==e||(this._storedError=ogt(t,this._url)),this._requests))r.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(t){var e;this.isStreamingSupported||(null===(e=this.onProgress)||void 0===e||e.call(this,{loaded:t.loaded}))}get isStreamingSupported(){return!1}read(){var t=this;return sit((function*(){if(t._storedError)throw t._storedError;if(null!==t._queuedChunk){var e=t._queuedChunk;return t._queuedChunk=null,{value:e,done:!1}}if(t._done)return{value:void 0,done:!0};var r=Promise.withResolvers();return t._requests.push(r),r.promise}))()}cancel(t){for(var e of(this._done=!0,this._requests))e.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}}var ygt=/^[a-z][a-z0-9\-+.]+:/i;class bgt{constructor(t){this.source=t,this.url=function(t){if(ygt.test(t))return new URL(t);var e=process.getBuiltinModule("url");return new URL(e.pathToFileURL(t))}(t.url),Clt("file:"===this.url.protocol,"PDFNodeStream only supports file:// URLs."),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var t,e;return null!==(t=null===(e=this._fullRequestReader)||void 0===e?void 0:e._loaded)&&void 0!==t?t:0}getFullReader(){return Clt(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=new wgt(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;var r=new xgt(this,t,e);return this._rangeRequestReaders.push(r),r}cancelAllRequests(t){var e;for(var r of(null===(e=this._fullRequestReader)||void 0===e||e.cancel(t),this._rangeRequestReaders.slice(0)))r.cancel(t)}}class wgt{constructor(t){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null;var e=t.source;this._contentLength=e.length,this._loaded=0,this._filename=null,this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange,this._readableStream=null,this._readCapability=Promise.withResolvers(),this._headersCapability=Promise.withResolvers();var r=process.getBuiltinModule("fs");r.promises.lstat(this._url).then((t=>{this._contentLength=t.size,this._setReadableStream(r.createReadStream(this._url)),this._headersCapability.resolve()}),(t=>{"ENOENT"===t.code&&(t=new Flt('Missing PDF "'.concat(this._url,'".'))),this._storedError=t,this._headersCapability.reject(t)}))}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}read(){var t=this;return sit((function*(){var e;if(yield t._readCapability.promise,t._done)return{value:void 0,done:!0};if(t._storedError)throw t._storedError;var r=t._readableStream.read();return null===r?(t._readCapability=Promise.withResolvers(),t.read()):(t._loaded+=r.length,null===(e=t.onProgress)||void 0===e||e.call(t,{loaded:t._loaded,total:t._contentLength}),{value:new Uint8Array(r).buffer,done:!1})}))()}cancel(t){this._readableStream?this._readableStream.destroy(t):this._error(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",(()=>{this._readCapability.resolve()})),t.on("end",(()=>{t.destroy(),this._done=!0,this._readCapability.resolve()})),t.on("error",(t=>{this._error(t)})),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new Blt("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class xgt{constructor(t,e,r){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers();var n=t.source;this._isStreamingSupported=!n.disableStream;var i=process.getBuiltinModule("fs");this._setReadableStream(i.createReadStream(this._url,{start:e,end:r-1}))}get isStreamingSupported(){return this._isStreamingSupported}read(){var t=this;return sit((function*(){var e;if(yield t._readCapability.promise,t._done)return{value:void 0,done:!0};if(t._storedError)throw t._storedError;var r=t._readableStream.read();return null===r?(t._readCapability=Promise.withResolvers(),t.read()):(t._loaded+=r.length,null===(e=t.onProgress)||void 0===e||e.call(t,{loaded:t._loaded}),{value:new Uint8Array(r).buffer,done:!1})}))()}cancel(t){this._readableStream?this._readableStream.destroy(t):this._error(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",(()=>{this._readCapability.resolve()})),t.on("end",(()=>{t.destroy(),this._done=!0,this._readCapability.resolve()})),t.on("error",(t=>{this._error(t)})),this._storedError&&this._readableStream.destroy(this._storedError)}}var Agt=30,_gt=new WeakMap,kgt=new WeakMap,Sgt=new WeakMap,Egt=new WeakMap,Mgt=new WeakMap,Tgt=new WeakMap,Cgt=new WeakMap,Pgt=new WeakMap,Igt=new WeakMap,Rgt=new WeakMap,Ogt=new WeakMap,Lgt=new WeakMap,Dgt=new WeakMap,Fgt=new WeakMap,Ngt=new WeakMap,jgt=new WeakMap,Bgt=new WeakMap,zgt=new WeakMap,Wgt=new WeakSet;class Ugt{constructor(t){var e,{textContentSource:r,container:n,viewport:i}=t;if(dit(this,Wgt),hit(this,_gt,Promise.withResolvers()),hit(this,kgt,null),hit(this,Sgt,!1),hit(this,Egt,!(null===(e=globalThis.FontInspector)||void 0===e||!e.enabled)),hit(this,Mgt,null),hit(this,Tgt,null),hit(this,Cgt,0),hit(this,Pgt,0),hit(this,Igt,null),hit(this,Rgt,null),hit(this,Ogt,0),hit(this,Lgt,0),hit(this,Dgt,Object.create(null)),hit(this,Fgt,[]),hit(this,Ngt,null),hit(this,jgt,[]),hit(this,Bgt,new WeakMap),hit(this,zgt,null),r instanceof ReadableStream)cit(Ngt,this,r);else{if("object"!=typeof r)throw new Error('No "textContentSource" parameter specified.');cit(Ngt,this,new ReadableStream({start(t){t.enqueue(r),t.close()}}))}cit(kgt,this,cit(Rgt,this,n)),cit(Lgt,this,i.scale*(globalThis.devicePixelRatio||1)),cit(Ogt,this,i.rotation),cit(Tgt,this,{div:null,properties:null,ctx:null});var{pageWidth:a,pageHeight:s,pageX:o,pageY:l}=i.rawDims;cit(zgt,this,[1,0,0,-1,-o,l+s]),cit(Pgt,this,a),cit(Cgt,this,s),Xgt.call(Ugt),yht(n,i),lit(_gt,this).promise.finally((()=>{tvt._.delete(this),cit(Tgt,this,null),cit(Dgt,this,null)})).catch((()=>{}))}static get fontFamilyMap(){var{isWindows:t,isFirefox:e}=Hlt.platform;return Ilt(this,"fontFamilyMap",new Map([["sans-serif","".concat(t&&e?"Calibri, ":"","sans-serif")],["monospace","".concat(t&&e?"Lucida Console, ":"","monospace")]]))}render(){var t=()=>{lit(Igt,this).read().then((e=>{var r,{value:n,done:i}=e;i?lit(_gt,this).resolve():(null!==(r=lit(Mgt,this))&&void 0!==r||cit(Mgt,this,n.lang),Object.assign(lit(Dgt,this),n.styles),iit(Wgt,this,Hgt).call(this,n.items),t())}),lit(_gt,this).reject)};return cit(Igt,this,lit(Ngt,this).getReader()),tvt._.add(this),t(),lit(_gt,this).promise}update(t){var{viewport:e,onBefore:r=null}=t,n=e.scale*(globalThis.devicePixelRatio||1),i=e.rotation;if(i!==lit(Ogt,this)&&(null==r||r(),cit(Ogt,this,i),yht(lit(Rgt,this),{rotation:i})),n!==lit(Lgt,this)){null==r||r(),cit(Lgt,this,n);var a={div:null,properties:null,ctx:Vgt.call(Ugt,lit(Mgt,this))};for(var s of lit(jgt,this))a.properties=lit(Bgt,this).get(s),a.div=s,iit(Wgt,this,Ygt).call(this,a)}}cancel(){var t,e=new Blt("TextLayer task cancelled.");null===(t=lit(Igt,this))||void 0===t||t.cancel(e).catch((()=>{})),cit(Igt,this,null),lit(_gt,this).reject(e)}get textDivs(){return lit(jgt,this)}get textContentItemsStr(){return lit(Fgt,this)}static cleanup(){if(!(iit(Ugt,this,tvt)._.size>0)){for(var{canvas:t}of(iit(Ugt,this,Kgt)._.clear(),iit(Ugt,this,Qgt)._.values()))t.remove();iit(Ugt,this,Qgt)._.clear()}}}function Hgt(t){var e,r;if(!lit(Sgt,this)){null!==(r=(e=lit(Tgt,this)).ctx)&&void 0!==r||(e.ctx=Vgt.call(vot,lit(Mgt,this)));var n=lit(jgt,this),i=lit(Fgt,this);for(var a of t){if(n.length>1e5)return Mlt("Ignoring additional textDivs for performance reasons."),void cit(Sgt,this,!0);if(void 0!==a.str)i.push(a.str),iit(Wgt,this,Ggt).call(this,a);else if("beginMarkedContentProps"===a.type||"beginMarkedContent"===a.type){var s=lit(kgt,this);cit(kgt,this,document.createElement("span")),lit(kgt,this).classList.add("markedContent"),null!==a.id&&lit(kgt,this).setAttribute("id","".concat(a.id)),s.append(lit(kgt,this))}else"endMarkedContent"===a.type&&cit(kgt,this,lit(kgt,this).parentNode)}}}function Ggt(t){var e=document.createElement("span"),r={angle:0,canvasWidth:0,hasText:""!==t.str,hasEOL:t.hasEOL,fontSize:0};lit(jgt,this).push(e);var n=Ylt.transform(lit(zgt,this),t.transform),i=Math.atan2(n[1],n[0]),a=lit(Dgt,this)[t.fontName];a.vertical&&(i+=Math.PI/2);var s=lit(Egt,this)&&a.fontSubstitution||a.fontFamily;s=vot.fontFamilyMap.get(s)||s;var o,l,h=Math.hypot(n[2],n[3]),c=h*$gt.call(vot,s,lit(Mgt,this));0===i?(o=n[4],l=n[5]-c):(o=n[4]+c*Math.sin(i),l=n[5]-c*Math.cos(i));var u="calc(var(--scale-factor)*",d=e.style;lit(kgt,this)===lit(Rgt,this)?(d.left="".concat((100*o/lit(Pgt,this)).toFixed(2),"%"),d.top="".concat((100*l/lit(Cgt,this)).toFixed(2),"%")):(d.left="".concat(u).concat(o.toFixed(2),"px)"),d.top="".concat(u).concat(l.toFixed(2),"px)")),d.fontSize="".concat(u).concat((Zgt._*h).toFixed(2),"px)"),d.fontFamily=s,r.fontSize=h,e.setAttribute("role","presentation"),e.textContent=t.str,e.dir=t.dir,lit(Egt,this)&&(e.dataset.fontName=a.fontSubstitutionLoadedName||t.fontName),0!==i&&(r.angle=i*(180/Math.PI));var p=!1;if(t.str.length>1)p=!0;else if(" "!==t.str&&t.transform[0]!==t.transform[3]){var f=Math.abs(t.transform[0]),g=Math.abs(t.transform[3]);f!==g&&Math.max(f,g)/Math.min(f,g)>1.5&&(p=!0)}if(p&&(r.canvasWidth=a.vertical?t.height:t.width),lit(Bgt,this).set(e,r),lit(Tgt,this).div=e,lit(Tgt,this).properties=r,iit(Wgt,this,Ygt).call(this,lit(Tgt,this)),r.hasText&&lit(kgt,this).append(e),r.hasEOL){var v=document.createElement("br");v.setAttribute("role","presentation"),lit(kgt,this).append(v)}}function Ygt(t){var{div:e,properties:r,ctx:n}=t,{style:i}=e,a="";if(Zgt._>1&&(a="scale(".concat(1/Zgt._,")")),0!==r.canvasWidth&&r.hasText){var{fontFamily:s}=i,{canvasWidth:o,fontSize:l}=r;qgt.call(vot,n,l*lit(Lgt,this),s);var{width:h}=n.measureText(e.textContent);h>0&&(a="scaleX(".concat(o*lit(Lgt,this)/h,") ").concat(a))}0!==r.angle&&(a="rotate(".concat(r.angle,"deg) ").concat(a)),a.length>0&&(i.transform=a)}function Vgt(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,e=iit(vot,this,Qgt)._.get(t||(t=""));if(!e){var r=document.createElement("canvas");r.className="hiddenCanvasElement",r.lang=t,document.body.append(r),e=r.getContext("2d",{alpha:!1,willReadFrequently:!0}),iit(vot,this,Qgt)._.set(t,e),iit(vot,this,Jgt)._.set(e,{size:0,family:""})}return e}function qgt(t,e,r){var n=iit(vot,this,Jgt)._.get(t);e===n.size&&r===n.family||(t.font="".concat(e,"px ").concat(r),n.size=e,n.family=r)}function Xgt(){if(null===iit(vot,this,Zgt)._){var t=document.createElement("div");t.style.opacity=0,t.style.lineHeight=1,t.style.fontSize="1px",t.style.position="absolute",t.textContent="X",document.body.append(t),Zgt._=iit(vot,this,t.getBoundingClientRect().height),t.remove()}}function $gt(t,e){var r=iit(vot,this,Kgt)._.get(t);if(r)return r;var n=iit(vot,this,Vgt).call(this,e);n.canvas.width=n.canvas.height=Agt,iit(vot,this,qgt).call(this,n,Agt,t);var i=n.measureText(""),a=i.fontBoundingBoxAscent,s=Math.abs(i.fontBoundingBoxDescent);if(a){var o=a/(a+s);return iit(vot,this,Kgt)._.set(t,o),n.canvas.width=n.canvas.height=0,o}n.strokeStyle="red",n.clearRect(0,0,Agt,Agt),n.strokeText("g",0,0);var l=n.getImageData(0,0,Agt,Agt).data;s=0;for(var h=l.length-1-3;h>=0;h-=4)if(l[h]>0){s=Math.ceil(h/4/Agt);break}n.clearRect(0,0,Agt,Agt),n.strokeText("A",0,Agt),a=0;for(var c=0,u=(l=n.getImageData(0,0,Agt,Agt).data).length;c<u;c+=4)if(l[c]>0){a=Agt-Math.floor(c/4/Agt);break}n.canvas.width=n.canvas.height=0;var d=a?a/(a+s):.8;return iit(vot,this,Kgt)._.set(t,d),d}vot=Ugt;var Kgt={_:new Map},Qgt={_:new Map},Jgt={_:new WeakMap},Zgt={_:null},tvt={_:new Set};class evt{static textContent(t){var e=[],r={items:e,styles:Object.create(null)};return function t(r){var n;if(r){var i=null,a=r.name;if("#text"===a)i=r.value;else{if(!evt.shouldBuildText(a))return;null!=r&&null!==(n=r.attributes)&&void 0!==n&&n.textContent?i=r.attributes.textContent:r.value&&(i=r.value)}if(null!==i&&e.push({str:i}),r.children)for(var s of r.children)t(s)}}(t),r}static shouldBuildText(t){return!("textarea"===t||"input"===t||"option"===t||"select"===t)}}var rvt=65536,nvt=Tot?class extends Tpt{_createCanvas(t,e){return process.getBuiltinModule("module").createRequire(import.meta.url)("@napi-rs/canvas").createCanvas(t,e)}}:class extends Tpt{constructor(t){var{ownerDocument:e=globalThis.document,enableHWA:r=!1}=t;super({enableHWA:r}),this._document=e}_createCanvas(t,e){var r=this._document.createElement("canvas");return r.width=t,r.height=e,r}},ivt=Tot?class extends Cpt{_fetch(t){return sit((function*(){return tft(t)}))()}}:Ppt,avt=Tot?class extends Ipt{}:class extends Ipt{constructor(t){var{docId:e,ownerDocument:r=globalThis.document}=t;super(),dit(this,Bpt),hit(this,Rpt,void 0),hit(this,Opt,void 0),hit(this,Lpt,void 0),hit(this,Dpt,void 0),hit(this,Fpt,void 0),hit(this,Npt,void 0),hit(this,jpt,0),cit(Dpt,this,e),cit(Fpt,this,r)}addFilter(t){var e,r;if(!t)return"none";var n=uit(Bpt,this,zpt).get(t);if(n)return n;var[i,a,s]=iit(Bpt,this,Hpt).call(this,t),o=1===t.length?i:"".concat(i).concat(a).concat(s);if(n=uit(Bpt,this,zpt).get(o))return uit(Bpt,this,zpt).set(t,n),n;var l="g_".concat(lit(Dpt,this),"_transfer_map_").concat((cit(jpt,this,(e=lit(jpt,this),r=e++,e)),r)),h=iit(Bpt,this,Gpt).call(this,l);uit(Bpt,this,zpt).set(t,h),uit(Bpt,this,zpt).set(o,h);var c=iit(Bpt,this,qpt).call(this,l);return iit(Bpt,this,$pt).call(this,i,a,s,c),h}addHCMFilter(t,e){var r,n,i="".concat(t,"-").concat(e),a="base",s=uit(Bpt,this,Wpt).get(a);if((null===(r=s)||void 0===r?void 0:r.key)===i)return s.url;s?(null===(n=s.filter)||void 0===n||n.remove(),s.key=i,s.url="none",s.filter=null):(s={key:i,url:"none",filter:null},uit(Bpt,this,Wpt).set(a,s));if(!t||!e)return s.url;var o=iit(Bpt,this,Qpt).call(this,t);t=Ylt.makeHexColor(...o);var l=iit(Bpt,this,Qpt).call(this,e);if(e=Ylt.makeHexColor(...l),uit(Bpt,this,Upt).style.color="","#000000"===t&&"#ffffff"===e||t===e)return s.url;for(var h=new Array(256),c=0;c<=255;c++){var u=c/255;h[c]=u<=.03928?u/12.92:Math.pow((u+.055)/1.055,2.4)}var d=h.join(","),p="g_".concat(lit(Dpt,this),"_hcm_filter"),f=s.filter=iit(Bpt,this,qpt).call(this,p);iit(Bpt,this,$pt).call(this,d,d,d,f),iit(Bpt,this,Vpt).call(this,f);var g=(t,e)=>{for(var r=o[t]/255,n=l[t]/255,i=new Array(e+1),a=0;a<=e;a++)i[a]=r+a/e*(n-r);return i.join(",")};return iit(Bpt,this,$pt).call(this,g(0,5),g(1,5),g(2,5),f),s.url=iit(Bpt,this,Gpt).call(this,p),s.url}addAlphaFilter(t){var e,r,n=uit(Bpt,this,zpt).get(t);if(n)return n;var[i]=iit(Bpt,this,Hpt).call(this,[t]),a="alpha_".concat(i);if(n=uit(Bpt,this,zpt).get(a))return uit(Bpt,this,zpt).set(t,n),n;var s="g_".concat(lit(Dpt,this),"_alpha_map_").concat((cit(jpt,this,(e=lit(jpt,this),r=e++,e)),r)),o=iit(Bpt,this,Gpt).call(this,s);uit(Bpt,this,zpt).set(t,o),uit(Bpt,this,zpt).set(a,o);var l=iit(Bpt,this,qpt).call(this,s);return iit(Bpt,this,Kpt).call(this,i,l),o}addLuminosityFilter(t){var e,r,n,i,a=uit(Bpt,this,zpt).get(t||"luminosity");if(a)return a;if(t?([n]=iit(Bpt,this,Hpt).call(this,[t]),i="luminosity_".concat(n)):i="luminosity",a=uit(Bpt,this,zpt).get(i))return uit(Bpt,this,zpt).set(t,a),a;var s="g_".concat(lit(Dpt,this),"_luminosity_map_").concat((cit(jpt,this,(e=lit(jpt,this),r=e++,e)),r)),o=iit(Bpt,this,Gpt).call(this,s);uit(Bpt,this,zpt).set(t,o),uit(Bpt,this,zpt).set(i,o);var l=iit(Bpt,this,qpt).call(this,s);return iit(Bpt,this,Ypt).call(this,l),t&&iit(Bpt,this,Kpt).call(this,n,l),o}addHighlightHCMFilter(t,e,r,n,i){var a,s,o="".concat(e,"-").concat(r,"-").concat(n,"-").concat(i),l=uit(Bpt,this,Wpt).get(t);if((null===(a=l)||void 0===a?void 0:a.key)===o)return l.url;l?(null===(s=l.filter)||void 0===s||s.remove(),l.key=o,l.url="none",l.filter=null):(l={key:o,url:"none",filter:null},uit(Bpt,this,Wpt).set(t,l));if(!e||!r)return l.url;var[h,c]=[e,r].map(iit(Bpt,this,Qpt).bind(this)),u=Math.round(.2126*h[0]+.7152*h[1]+.0722*h[2]),d=Math.round(.2126*c[0]+.7152*c[1]+.0722*c[2]),[p,f]=[n,i].map(iit(Bpt,this,Qpt).bind(this));d<u&&([u,d,p,f]=[d,u,f,p]),uit(Bpt,this,Upt).style.color="";var g=(t,e,r)=>{for(var n=new Array(256),i=(d-u)/r,a=t/255,s=(e-t)/(255*r),o=0,l=0;l<=r;l++){for(var h=Math.round(u+l*i),c=a+l*s,p=o;p<=h;p++)n[p]=c;o=h+1}for(var f=o;f<256;f++)n[f]=n[o-1];return n.join(",")},v="g_".concat(lit(Dpt,this),"_hcm_").concat(t,"_filter"),m=l.filter=iit(Bpt,this,qpt).call(this,v);return iit(Bpt,this,Vpt).call(this,m),iit(Bpt,this,$pt).call(this,g(p[0],f[0],5),g(p[1],f[1],5),g(p[2],f[2],5),m),l.url=iit(Bpt,this,Gpt).call(this,v),l.url}destroy(){var t,e,r,n;arguments.length>0&&void 0!==arguments[0]&&arguments[0]&&null!==(t=lit(Npt,this))&&void 0!==t&&t.size||(null===(e=lit(Lpt,this))||void 0===e||e.parentNode.parentNode.remove(),cit(Lpt,this,null),null===(r=lit(Opt,this))||void 0===r||r.clear(),cit(Opt,this,null),null===(n=lit(Npt,this))||void 0===n||n.clear(),cit(Npt,this,null),cit(jpt,this,0))}},svt=Tot?class extends Jpt{_fetch(t){return sit((function*(){return tft(t)}))()}}:Zpt;function ovt(){var t,e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};"string"==typeof r||r instanceof URL?r={url:r}:(r instanceof ArrayBuffer||ArrayBuffer.isView(r))&&(r={data:r});var n=new hvt,{docId:i}=n,a=r.url?function(t){if(t instanceof URL)return t.href;try{return new URL(t,window.location).href}catch(e){if(Tot&&"string"==typeof t)return t}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}(r.url):null,s=r.data?function(t){if(Tot&&"undefined"!=typeof Buffer&&t instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(t instanceof Uint8Array&&t.byteLength===t.buffer.byteLength)return t;if("string"==typeof t)return Wlt(t);if(t instanceof ArrayBuffer||ArrayBuffer.isView(t)||"object"==typeof t&&!isNaN(null==t?void 0:t.length))return new Uint8Array(t);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}(r.data):null,o=r.httpHeaders||null,l=!0===r.withCredentials,h=null!==(t=r.password)&&void 0!==t?t:null,c=r.range instanceof uvt?r.range:null,u=Number.isInteger(r.rangeChunkSize)&&r.rangeChunkSize>0?r.rangeChunkSize:rvt,d=r.worker instanceof _vt?r.worker:null,p=r.verbosity,f="string"!=typeof r.docBaseUrl||iht(r.docBaseUrl)?null:r.docBaseUrl,g="string"==typeof r.cMapUrl?r.cMapUrl:null,v=!1!==r.cMapPacked,m=r.CMapReaderFactory||ivt,y="string"==typeof r.standardFontDataUrl?r.standardFontDataUrl:null,b=r.StandardFontDataFactory||svt,w=!0!==r.stopAtErrors,x=Number.isInteger(r.maxImageSize)&&r.maxImageSize>-1?r.maxImageSize:-1,A=!1!==r.isEvalSupported,_="boolean"==typeof r.isOffscreenCanvasSupported?r.isOffscreenCanvasSupported:!Tot,k="boolean"==typeof r.isImageDecoderSupported?r.isImageDecoderSupported:!Tot&&(Hlt.platform.isFirefox||!globalThis.chrome),S=Number.isInteger(r.canvasMaxAreaInBytes)?r.canvasMaxAreaInBytes:-1,E="boolean"==typeof r.disableFontFace?r.disableFontFace:Tot,M=!0===r.fontExtraProperties,T=!0===r.enableXfa,C=r.ownerDocument||globalThis.document,P=!0===r.disableRange,I=!0===r.disableStream,R=!0===r.disableAutoFetch,O=!0===r.pdfBug,L=r.CanvasFactory||nvt,D=r.FilterFactory||avt,F=!0===r.enableHWA,N=c?c.length:null!==(e=r.length)&&void 0!==e?e:NaN,j="boolean"==typeof r.useSystemFonts?r.useSystemFonts:!Tot&&!E,B="boolean"==typeof r.useWorkerFetch?r.useWorkerFetch:m===Ppt&&b===Zpt&&g&&y&&hht(g,document.baseURI)&&hht(y,document.baseURI);klt(p);var z={canvasFactory:new L({ownerDocument:C,enableHWA:F}),filterFactory:new D({docId:i,ownerDocument:C}),cMapReaderFactory:B?null:new m({baseUrl:g,isCompressed:v}),standardFontDataFactory:B?null:new b({baseUrl:y})};if(!d){var W={verbosity:p,port:Dft.workerPort};d=W.port?_vt.fromPort(W):new _vt(W),n._worker=d}var U={docId:i,apiVersion:"4.10.38",data:s,password:h,disableAutoFetch:R,rangeChunkSize:u,length:N,docBaseUrl:f,enableXfa:T,evaluatorOptions:{maxImageSize:x,disableFontFace:E,ignoreErrors:w,isEvalSupported:A,isOffscreenCanvasSupported:_,isImageDecoderSupported:k,canvasMaxAreaInBytes:S,fontExtraProperties:M,useSystemFonts:j,cMapUrl:B?g:null,standardFontDataUrl:B?y:null}},H={disableFontFace:E,fontExtraProperties:M,ownerDocument:C,pdfBug:O,styleElement:null,loadingParams:{disableAutoFetch:R,enableXfa:T}};return d.promise.then((function(){if(n.destroyed)throw new Error("Loading aborted");if(d.destroyed)throw new Error("Worker was destroyed");var t,e=d.messageHandler.sendWithPromise("GetDocRequest",U,s?[s.buffer]:null);if(c)t=new tgt(c,{disableRange:P,disableStream:I});else if(!s){if(!a)throw new Error("getDocument - no `url` parameter provided.");var r;if(Tot)if(hht(a)){if("undefined"==typeof fetch||"undefined"==typeof Response||!("body"in Response.prototype))throw new Error("getDocument - the Fetch API was disabled in Node.js, see `--no-experimental-fetch`.");r=ugt}else r=bgt;else r=hht(a)?ugt:ggt;t=new r({url:a,length:N,httpHeaders:o,withCredentials:l,rangeChunkSize:u,disableRange:P,disableStream:I})}return e.then((e=>{if(n.destroyed)throw new Error("Loading aborted");if(d.destroyed)throw new Error("Worker was destroyed");var r=new xpt(i,e,d.port),a=new Dvt(r,n,t,H,z);n._transport=a,r.send("Ready",null)}))})).catch(n._capability.reject),n}function lvt(t){return"object"==typeof t&&Number.isInteger(null==t?void 0:t.num)&&t.num>=0&&Number.isInteger(null==t?void 0:t.gen)&&t.gen>=0}class hvt{constructor(){var t,e;this._capability=Promise.withResolvers(),this._transport=null,this._worker=null,this.docId="d".concat((cvt._=(t=cvt._,e=t++,t),e)),this.destroyed=!1,this.onPassword=null,this.onProgress=null}get promise(){return this._capability.promise}destroy(){var t=this;return sit((function*(){var e;t.destroyed=!0;try{var r,n;null!==(r=t._worker)&&void 0!==r&&r.port&&(t._worker._pendingDestroy=!0),yield null===(n=t._transport)||void 0===n?void 0:n.destroy()}catch(e){var i;throw null!==(i=t._worker)&&void 0!==i&&i.port&&delete t._worker._pendingDestroy,e}t._transport=null,null===(e=t._worker)||void 0===e||e.destroy(),t._worker=null}))()}}var cvt={_:0};class uvt{constructor(t,e){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;this.length=t,this.initialData=e,this.progressiveDone=r,this.contentDispositionFilename=n,this._rangeListeners=[],this._progressListeners=[],this._progressiveReadListeners=[],this._progressiveDoneListeners=[],this._readyCapability=Promise.withResolvers()}addRangeListener(t){this._rangeListeners.push(t)}addProgressListener(t){this._progressListeners.push(t)}addProgressiveReadListener(t){this._progressiveReadListeners.push(t)}addProgressiveDoneListener(t){this._progressiveDoneListeners.push(t)}onDataRange(t,e){for(var r of this._rangeListeners)r(t,e)}onDataProgress(t,e){this._readyCapability.promise.then((()=>{for(var r of this._progressListeners)r(t,e)}))}onDataProgressiveRead(t){this._readyCapability.promise.then((()=>{for(var e of this._progressiveReadListeners)e(t)}))}onDataProgressiveDone(){this._readyCapability.promise.then((()=>{for(var t of this._progressiveDoneListeners)t()}))}transportReady(){this._readyCapability.resolve()}requestDataRange(t,e){Tlt("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}class dvt{constructor(t,e){this._pdfInfo=t,this._transport=e}get annotationStorage(){return this._transport.annotationStorage}get canvasFactory(){return this._transport.canvasFactory}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return Ilt(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(t){return this._transport.getPage(t)}getPageIndex(t){return this._transport.getPageIndex(t)}getDestinations(){return this._transport.getDestinations()}getDestination(t){return this._transport.getDestination(t)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig(){var{intent:t="display"}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getOptionalContentConfig(e)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}cleanup(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this._transport.startCleanup(t||this.isPureXfa)}destroy(){return this.loadingTask.destroy()}cachedPageNumber(t){return this._transport.cachedPageNumber(t)}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}var pvt=new WeakMap,fvt=new WeakMap,gvt=new WeakSet;class vvt{constructor(t,e,r){var n=arguments.length>3&&void 0!==arguments[3]&&arguments[3];dit(this,gvt),hit(this,pvt,null),hit(this,fvt,!1),this._pageIndex=t,this._pageInfo=e,this._transport=r,this._stats=n?new lht:null,this._pdfBug=n,this.commonObjs=r.commonObjs,this.objs=new zvt,this._maybeCleanupAfterRender=!1,this._intentStates=new Map,this.destroyed=!1}get pageNumber(){return this._pageIndex+1}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport(){var{scale:t,rotation:e=this.rotate,offsetX:r=0,offsetY:n=0,dontFlip:i=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new rht({viewBox:this.view,userUnit:this.userUnit,scale:t,rotation:e,offsetX:r,offsetY:n,dontFlip:i})}getAnnotations(){var{intent:t="display"}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getAnnotations(this._pageIndex,e)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return Ilt(this,"isPureXfa",!!this._transport._htmlForXfa)}getXfa(){var t=this;return sit((function*(){var e;return(null===(e=t._transport._htmlForXfa)||void 0===e?void 0:e.children[t._pageIndex])||null}))()}render(t){var e,r,{canvasContext:n,viewport:i,intent:a="display",annotationMode:s=zot.ENABLE,transform:o=null,background:l=null,optionalContentConfigPromise:h=null,annotationCanvasMap:c=null,pageColors:u=null,printAnnotationStorage:d=null,isEditing:p=!1}=t;null===(e=this._stats)||void 0===e||e.time("Overall");var f=this._transport.getRenderingIntent(a,s,d,p),{renderingIntent:g,cacheKey:v}=f;cit(fvt,this,!1),iit(gvt,this,yvt).call(this),h||(h=this._transport.getOptionalContentConfig(g));var m=this._intentStates.get(v);m||(m=Object.create(null),this._intentStates.set(v,m)),m.streamReaderCancelTimeout&&(clearTimeout(m.streamReaderCancelTimeout),m.streamReaderCancelTimeout=null);var y,b=!!(g&Lot);m.displayReadyCapability||(m.displayReadyCapability=Promise.withResolvers(),m.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},null===(y=this._stats)||void 0===y||y.time("Page Request"),this._pumpOperatorList(f));var w=t=>{var e;(m.renderTasks.delete(x),(this._maybeCleanupAfterRender||b)&&cit(fvt,this,!0),iit(gvt,this,mvt).call(this,!b),t?(x.capability.reject(t),this._abortOperatorList({intentState:m,reason:t instanceof Error?t:new Error(t)})):x.capability.resolve(),this._stats)&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),null!==(e=globalThis.Stats)&&void 0!==e&&e.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},x=new Yvt({callback:w,params:{canvasContext:n,viewport:i,transform:o,background:l},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:c,operatorList:m.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!b,pdfBug:this._pdfBug,pageColors:u});((r=m).renderTasks||(r.renderTasks=new Set)).add(x);var A=x.task;return Promise.all([m.displayReadyCapability.promise,h]).then((t=>{var e,[r,n]=t;if(this.destroyed)w();else{if(null===(e=this._stats)||void 0===e||e.time("Rendering"),!(n.renderingIntent&g))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");x.initializeGraphics({transparency:r,optionalContentConfig:n}),x.operatorListChanged()}})).catch(w),A}getOperatorList(){var{intent:t="display",annotationMode:e=zot.ENABLE,printAnnotationStorage:r=null,isEditing:n=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};var i,a,s,o=this._transport.getRenderingIntent(t,e,r,n,!0),l=this._intentStates.get(o.cacheKey);(l||(l=Object.create(null),this._intentStates.set(o.cacheKey,l)),l.opListReadCapability)||((i=Object.create(null)).operatorListChanged=function(){l.operatorList.lastChunk&&(l.opListReadCapability.resolve(l.operatorList),l.renderTasks.delete(i))},l.opListReadCapability=Promise.withResolvers(),((a=l).renderTasks||(a.renderTasks=new Set)).add(i),l.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},null===(s=this._stats)||void 0===s||s.time("Page Request"),this._pumpOperatorList(o));return l.opListReadCapability.promise}streamTextContent(){var{includeMarkedContent:t=!1,disableNormalization:e=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:!0===t,disableNormalization:!0===e},{highWaterMark:100,size:t=>t.items.length})}getTextContent(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(this._transport._htmlForXfa)return this.getXfa().then((t=>evt.textContent(t)));var e=this.streamTextContent(t);return new Promise((function(t,r){var n=e.getReader(),i={items:[],styles:Object.create(null),lang:null};!function e(){n.read().then((function(r){var n,{value:a,done:s}=r;s?t(i):(null!==(n=i.lang)&&void 0!==n||(i.lang=a.lang),Object.assign(i.styles,a.styles),i.items.push(...a.items),e())}),r)}()}))}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;var t=[];for(var e of this._intentStates.values())if(this._abortOperatorList({intentState:e,reason:new Error("Page was destroyed."),force:!0}),!e.opListReadCapability)for(var r of e.renderTasks)t.push(r.completed),r.cancel();return this.objs.clear(),cit(fvt,this,!1),iit(gvt,this,yvt).call(this),Promise.all(t)}cleanup(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];cit(fvt,this,!0);var e=iit(gvt,this,mvt).call(this,!1);return t&&e&&this._stats&&(this._stats=new lht),e}_startRenderPage(t,e){var r,n,i=this._intentStates.get(e);i&&(null===(r=this._stats)||void 0===r||r.timeEnd("Page Request"),null===(n=i.displayReadyCapability)||void 0===n||n.resolve(t))}_renderPageChunk(t,e){for(var r=0,n=t.length;r<n;r++)e.operatorList.fnArray.push(t.fnArray[r]),e.operatorList.argsArray.push(t.argsArray[r]);for(var i of(e.operatorList.lastChunk=t.lastChunk,e.operatorList.separateAnnots=t.separateAnnots,e.renderTasks))i.operatorListChanged();t.lastChunk&&iit(gvt,this,mvt).call(this,!0)}_pumpOperatorList(t){var{renderingIntent:e,cacheKey:r,annotationStorageSerializable:n,modifiedIds:i}=t,{map:a,transfer:s}=n,o=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:e,cacheKey:r,annotationStorage:a,modifiedIds:i},s).getReader(),l=this._intentStates.get(r);l.streamReader=o;var h=()=>{o.read().then((t=>{var{value:e,done:r}=t;r?l.streamReader=null:this._transport.destroyed||(this._renderPageChunk(e,l),h())}),(t=>{if(l.streamReader=null,!this._transport.destroyed){if(l.operatorList){for(var e of(l.operatorList.lastChunk=!0,l.renderTasks))e.operatorListChanged();iit(gvt,this,mvt).call(this,!0)}if(l.displayReadyCapability)l.displayReadyCapability.reject(t);else{if(!l.opListReadCapability)throw t;l.opListReadCapability.reject(t)}}}))};h()}_abortOperatorList(t){var{intentState:e,reason:r,force:n=!1}=t;if(e.streamReader){if(e.streamReaderCancelTimeout&&(clearTimeout(e.streamReaderCancelTimeout),e.streamReaderCancelTimeout=null),!n){if(e.renderTasks.size>0)return;if(r instanceof nht){var i=100;return r.extraDelay>0&&r.extraDelay<1e3&&(i+=r.extraDelay),void(e.streamReaderCancelTimeout=setTimeout((()=>{e.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:e,reason:r,force:!0})}),i))}}if(e.streamReader.cancel(new Blt(r.message)).catch((()=>{})),e.streamReader=null,!this._transport.destroyed){for(var[a,s]of this._intentStates)if(s===e){this._intentStates.delete(a);break}this.cleanup()}}}get stats(){return this._stats}}function mvt(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(iit(gvt,this,yvt).call(this),!lit(fvt,this)||this.destroyed)return!1;if(t)return cit(pvt,this,setTimeout((()=>{cit(pvt,this,null),iit(gvt,this,mvt).call(this,!1)}),5e3)),!1;for(var{renderTasks:e,operatorList:r}of this._intentStates.values())if(e.size>0||!r.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),cit(fvt,this,!1),!0}function yvt(){lit(pvt,this)&&(clearTimeout(lit(pvt,this)),cit(pvt,this,null))}var bvt=new WeakMap,wvt=new WeakMap;class xvt{constructor(){hit(this,bvt,new Map),hit(this,wvt,Promise.resolve())}postMessage(t,e){var r={data:structuredClone(t,e?{transfer:e}:null)};lit(wvt,this).then((()=>{for(var[t]of lit(bvt,this))t.call(this,r)}))}addEventListener(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=null;if((null==r?void 0:r.signal)instanceof AbortSignal){var{signal:i}=r;if(i.aborted)return void Mlt("LoopbackPort - cannot use an `aborted` signal.");var a=()=>this.removeEventListener(t,e);n=()=>i.removeEventListener("abort",a),i.addEventListener("abort",a)}lit(bvt,this).set(e,n)}removeEventListener(t,e){var r=lit(bvt,this).get(e);null==r||r(),lit(bvt,this).delete(e)}terminate(){for(var[,t]of lit(bvt,this))null==t||t();lit(bvt,this).clear()}}var Avt=new WeakSet;class _vt{constructor(){var{name:t=null,port:e=null,verbosity:r=Slt()}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(dit(this,Avt),this.name=t,this.destroyed=!1,this.verbosity=r,this._readyCapability=Promise.withResolvers(),this._port=null,this._webWorker=null,this._messageHandler=null,e){var n;if(null!==(n=Tvt._)&&void 0!==n&&n.has(e))throw new Error("Cannot use more than one PDFWorker per port.");return(Tvt._||(Tvt._=new WeakMap)).set(e,this),void this._initializeFromPort(e)}this._initialize()}get promise(){return this._readyCapability.promise}get port(){return this._port}get messageHandler(){return this._messageHandler}_initializeFromPort(t){this._port=t,this._messageHandler=new xpt("main","worker",t),this._messageHandler.on("ready",(function(){})),iit(Avt,this,kvt).call(this)}_initialize(){if(Mvt._||Svt(_vt))this._setupFakeWorker();else{var{workerSrc:t}=_vt;try{_vt._isSameOrigin(window.location.href,t)||(t=_vt._createCDNWrapper(new URL(t,window.location).href));var e=new Worker(t,{type:"module"}),r=new xpt("main","worker",e),n=()=>{i.abort(),r.destroy(),e.terminate(),this.destroyed?this._readyCapability.reject(new Error("Worker was destroyed")):this._setupFakeWorker()},i=new AbortController;e.addEventListener("error",(()=>{this._webWorker||n()}),{signal:i.signal}),r.on("test",(t=>{i.abort(),!this.destroyed&&t?(this._messageHandler=r,this._port=e,this._webWorker=e,iit(Avt,this,kvt).call(this)):n()})),r.on("ready",(t=>{if(i.abort(),this.destroyed)n();else try{a()}catch(t){this._setupFakeWorker()}}));var a=()=>{var t=new Uint8Array;r.send("test",t,[t.buffer])};return void a()}catch(t){Elt("The worker has been disabled.")}this._setupFakeWorker()}}_setupFakeWorker(){Mvt._||(Mlt("Setting up fake worker."),Mvt._=!0),_vt._setupFakeWorkerGlobal.then((t=>{var e,r;if(this.destroyed)this._readyCapability.reject(new Error("Worker was destroyed"));else{var n=new xvt;this._port=n;var i="fake".concat((Evt._=(e=Evt._,r=e++,e),r)),a=new xpt(i+"_worker",i,n);t.setup(a,n),this._messageHandler=new xpt(i,i+"_worker",n),iit(Avt,this,kvt).call(this)}})).catch((t=>{this._readyCapability.reject(new Error('Setting up fake worker failed: "'.concat(t.message,'".')))}))}destroy(){var t,e,r;this.destroyed=!0,null===(t=this._webWorker)||void 0===t||t.terminate(),this._webWorker=null,null===(e=Tvt._)||void 0===e||e.delete(this._port),this._port=null,null===(r=this._messageHandler)||void 0===r||r.destroy(),this._messageHandler=null}static fromPort(t){var e;if(null==t||!t.port)throw new Error("PDFWorker.fromPort - invalid method signature.");var r=null===(e=iit(_vt,this,Tvt)._)||void 0===e?void 0:e.get(t.port);if(r){if(r._pendingDestroy)throw new Error("PDFWorker.fromPort - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return r}return new _vt(t)}static get workerSrc(){if(Dft.workerSrc)return Dft.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get _setupFakeWorkerGlobal(){var t=this,e=function(){var e=sit((function*(){return uit(_vt,t,Svt)?uit(_vt,t,Svt):(yield import(t.workerSrc)).WorkerMessageHandler}));return function(){return e.apply(this,arguments)}}();return Ilt(this,"_setupFakeWorkerGlobal",e())}}function kvt(){this._readyCapability.resolve(),this._messageHandler.send("configure",{verbosity:this.verbosity})}function Svt(t){try{var e;return(null===(e=globalThis.pdfjsWorker)||void 0===e?void 0:e.WorkerMessageHandler)||null}catch(t){return null}}mot=_vt;var Evt={_:0},Mvt={_:!1},Tvt={_:void 0};Tot&&(Mvt._=iit(mot,mot,!0),Dft.workerSrc||(Dft.workerSrc="./pdf.worker.mjs")),mot._isSameOrigin=(t,e)=>{var r;try{if(!(r=new URL(t)).origin||"null"===r.origin)return!1}catch(t){return!1}var n=new URL(e,r);return r.origin===n.origin},mot._createCDNWrapper=t=>{var e='await import("'.concat(t,'");');return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))};var Cvt=new WeakMap,Pvt=new WeakMap,Ivt=new WeakMap,Rvt=new WeakMap,Ovt=new WeakMap,Lvt=new WeakSet;class Dvt{constructor(t,e,r,n,i){dit(this,Lvt),hit(this,Cvt,new Map),hit(this,Pvt,new Map),hit(this,Ivt,new Map),hit(this,Rvt,new Map),hit(this,Ovt,null),this.messageHandler=t,this.loadingTask=e,this.commonObjs=new zvt,this.fontLoader=new apt({ownerDocument:n.ownerDocument,styleElement:n.styleElement}),this.loadingParams=n.loadingParams,this._params=n,this.canvasFactory=i.canvasFactory,this.filterFactory=i.filterFactory,this.cMapReaderFactory=i.cMapReaderFactory,this.standardFontDataFactory=i.standardFontDataFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=r,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.setupMessageHandler()}get annotationStorage(){return Ilt(this,"annotationStorage",new tpt)}getRenderingIntent(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:zot.ENABLE,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=arguments.length>3&&void 0!==arguments[3]&&arguments[3],i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],a=Oot,s=$dt;switch(t){case"any":a=Rot;break;case"display":break;case"print":a=Lot;break;default:Mlt("getRenderingIntent - invalid intent: ".concat(t))}var o=a&Lot&&r instanceof npt?r:this.annotationStorage;switch(e){case zot.DISABLE:a+=Not;break;case zot.ENABLE:break;case zot.ENABLE_FORMS:a+=Dot;break;case zot.ENABLE_STORAGE:a+=Fot,s=o.serializable;break;default:Mlt("getRenderingIntent - invalid annotationMode: ".concat(e))}n&&(a+=jot),i&&(a+=Bot);var{ids:l,hash:h}=o.modifiedIds;return{renderingIntent:a,cacheKey:[a,s.hash,h].join("_"),annotationStorageSerializable:s,modifiedIds:l}}destroy(){var t;if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),null===(t=lit(Ovt,this))||void 0===t||t.reject(new Error("Worker was destroyed during onPassword callback"));var e=[];for(var r of lit(Pvt,this).values())e.push(r._destroy());lit(Pvt,this).clear(),lit(Ivt,this).clear(),lit(Rvt,this).clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();var n=this.messageHandler.sendWithPromise("Terminate",null);return e.push(n),Promise.all(e).then((()=>{var t,e;this.commonObjs.clear(),this.fontLoader.clear(),lit(Cvt,this).clear(),this.filterFactory.destroy(),Ugt.cleanup(),null===(t=this._networkStream)||void 0===t||t.cancelAllRequests(new Blt("Worker was terminated.")),null===(e=this.messageHandler)||void 0===e||e.destroy(),this.messageHandler=null,this.destroyCapability.resolve()}),this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){var t=this,{messageHandler:e,loadingTask:r}=this;e.on("GetReader",((t,e)=>{Clt(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=t=>{this._lastProgress={loaded:t.loaded,total:t.total}},e.onPull=()=>{this._fullReader.read().then((function(t){var{value:r,done:n}=t;n?e.close():(Clt(r instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),e.enqueue(new Uint8Array(r),1,[r]))})).catch((t=>{e.error(t)}))},e.onCancel=t=>{this._fullReader.cancel(t),e.ready.catch((t=>{if(!this.destroyed)throw t}))}})),e.on("ReaderHeadersReady",function(){var e=sit((function*(e){yield t._fullReader.headersReady;var{isStreamingSupported:n,isRangeSupported:i,contentLength:a}=t._fullReader;if(!n||!i){var s;if(t._lastProgress)null===(s=r.onProgress)||void 0===s||s.call(r,t._lastProgress);t._fullReader.onProgress=t=>{var e;null===(e=r.onProgress)||void 0===e||e.call(r,{loaded:t.loaded,total:t.total})}}return{isStreamingSupported:n,isRangeSupported:i,contentLength:a}}));return function(t){return e.apply(this,arguments)}}()),e.on("GetRangeReader",((t,e)=>{Clt(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");var r=this._networkStream.getRangeReader(t.begin,t.end);r?(e.onPull=()=>{r.read().then((function(t){var{value:r,done:n}=t;n?e.close():(Clt(r instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),e.enqueue(new Uint8Array(r),1,[r]))})).catch((t=>{e.error(t)}))},e.onCancel=t=>{r.cancel(t),e.ready.catch((t=>{if(!this.destroyed)throw t}))}):e.close()})),e.on("GetDoc",(t=>{var{pdfInfo:e}=t;this._numPages=e.numPages,this._htmlForXfa=e.htmlForXfa,delete e.htmlForXfa,r._capability.resolve(new dvt(e,this))})),e.on("DocException",(t=>{r._capability.reject(ypt(t))})),e.on("PasswordRequest",(t=>{cit(Ovt,this,Promise.withResolvers());try{if(!r.onPassword)throw ypt(t);r.onPassword((t=>{t instanceof Error?lit(Ovt,this).reject(t):lit(Ovt,this).resolve({password:t})}),t.code)}catch(t){lit(Ovt,this).reject(t)}return lit(Ovt,this).promise})),e.on("DataLoaded",(t=>{var e;null===(e=r.onProgress)||void 0===e||e.call(r,{loaded:t.length,total:t.length}),this.downloadInfoCapability.resolve(t)})),e.on("StartRenderPage",(t=>{this.destroyed||lit(Pvt,this).get(t.pageIndex)._startRenderPage(t.transparency,t.cacheKey)})),e.on("commonobj",(t=>{var r,[n,i,a]=t;if(this.destroyed)return null;if(this.commonObjs.has(n))return null;switch(i){case"Font":var{disableFontFace:s,fontExtraProperties:o,pdfBug:l}=this._params;if("error"in a){var h=a.error;Mlt("Error during font loading: ".concat(h)),this.commonObjs.resolve(n,h);break}var c=l&&null!==(r=globalThis.FontInspector)&&void 0!==r&&r.enabled?(t,e)=>globalThis.FontInspector.fontAdded(t,e):null,u=new spt(a,{disableFontFace:s,fontExtraProperties:o,inspectFont:c});this.fontLoader.bind(u).catch((()=>e.sendWithPromise("FontFallback",{id:n}))).finally((()=>{!o&&u.data&&(u.data=null),this.commonObjs.resolve(n,u)}));break;case"CopyLocalImage":var{imageRef:d}=a;for(var p of(Clt(d,"The imageRef must be defined."),lit(Pvt,this).values()))for(var[,f]of p.objs)if((null==f?void 0:f.ref)===d)return f.dataLen?(this.commonObjs.resolve(n,structuredClone(f)),f.dataLen):null;break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(n,a);break;default:throw new Error("Got unknown common object type ".concat(i))}return null})),e.on("obj",(t=>{var[e,r,n,i]=t;if(!this.destroyed){var a,s=lit(Pvt,this).get(r);if(!s.objs.has(e))if(0!==s._intentStates.size)switch(n){case"Image":s.objs.resolve(e,i),(null==i?void 0:i.dataLen)>1e7&&(s._maybeCleanupAfterRender=!0);break;case"Pattern":s.objs.resolve(e,i);break;default:throw new Error("Got unknown object type ".concat(n))}else null==i||null===(a=i.bitmap)||void 0===a||a.close()}})),e.on("DocProgress",(t=>{var e;this.destroyed||null===(e=r.onProgress)||void 0===e||e.call(r,{loaded:t.loaded,total:t.total})})),e.on("FetchBuiltInCMap",function(){var e=sit((function*(e){if(t.destroyed)throw new Error("Worker was destroyed.");if(!t.cMapReaderFactory)throw new Error("CMapReaderFactory not initialized, see the `useWorkerFetch` parameter.");return t.cMapReaderFactory.fetch(e)}));return function(t){return e.apply(this,arguments)}}()),e.on("FetchStandardFontData",function(){var e=sit((function*(e){if(t.destroyed)throw new Error("Worker was destroyed.");if(!t.standardFontDataFactory)throw new Error("StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter.");return t.standardFontDataFactory.fetch(e)}));return function(t){return e.apply(this,arguments)}}())}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){var t,e;this.annotationStorage.size<=0&&Mlt("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");var{map:r,transfer:n}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:r,filename:null!==(t=null===(e=this._fullReader)||void 0===e?void 0:e.filename)&&void 0!==t?t:null},n).finally((()=>{this.annotationStorage.resetModified()}))}getPage(t){if(!Number.isInteger(t)||t<=0||t>this._numPages)return Promise.reject(new Error("Invalid page request."));var e=t-1,r=lit(Ivt,this).get(e);if(r)return r;var n=this.messageHandler.sendWithPromise("GetPage",{pageIndex:e}).then((r=>{if(this.destroyed)throw new Error("Transport destroyed");r.refStr&&lit(Rvt,this).set(r.refStr,t);var n=new vvt(e,r,this,this._params.pdfBug);return lit(Pvt,this).set(e,n),n}));return lit(Ivt,this).set(e,n),n}getPageIndex(t){return lvt(t)?this.messageHandler.sendWithPromise("GetPageIndex",{num:t.num,gen:t.gen}):Promise.reject(new Error("Invalid pageIndex request."))}getAnnotations(t,e){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:t,intent:e})}getFieldObjects(){return iit(Lvt,this,Fvt).call(this,"GetFieldObjects")}hasJSActions(){return iit(Lvt,this,Fvt).call(this,"HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(t){return"string"!=typeof t?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:t})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getDocJSActions(){return iit(Lvt,this,Fvt).call(this,"GetDocJSActions")}getPageJSActions(t){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:t})}getStructTree(t){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:t})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(t){return iit(Lvt,this,Fvt).call(this,"GetOptionalContentConfig").then((e=>new Jft(e,t)))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){var t="GetMetadata",e=lit(Cvt,this).get(t);if(e)return e;var r=this.messageHandler.sendWithPromise(t,null).then((t=>{var e,r,n,i;return{info:t[0],metadata:t[1]?new zft(t[1]):null,contentDispositionFilename:null!==(e=null===(r=this._fullReader)||void 0===r?void 0:r.filename)&&void 0!==e?e:null,contentLength:null!==(n=null===(i=this._fullReader)||void 0===i?void 0:i.contentLength)&&void 0!==n?n:null}}));return lit(Cvt,this).set(t,r),r}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}startCleanup(){var t=arguments,e=this;return sit((function*(){var r=t.length>0&&void 0!==t[0]&&t[0];if(!e.destroyed){for(var n of(yield e.messageHandler.sendWithPromise("Cleanup",null),lit(Pvt,e).values())){if(!n.cleanup())throw new Error("startCleanup: Page ".concat(n.pageNumber," is currently rendering."))}e.commonObjs.clear(),r||e.fontLoader.clear(),lit(Cvt,e).clear(),e.filterFactory.destroy(!0),Ugt.cleanup()}}))()}cachedPageNumber(t){var e;if(!lvt(t))return null;var r=0===t.gen?"".concat(t.num,"R"):"".concat(t.num,"R").concat(t.gen);return null!==(e=lit(Rvt,this).get(r))&&void 0!==e?e:null}}function Fvt(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=lit(Cvt,this).get(t);if(r)return r;var n=this.messageHandler.sendWithPromise(t,e);return lit(Cvt,this).set(t,n),n}var Nvt=Symbol("INITIAL_DATA"),jvt=new WeakMap,Bvt=new WeakSet;class zvt{constructor(){dit(this,Bvt),hit(this,jvt,Object.create(null))}get(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(e){var r=iit(Bvt,this,Wvt).call(this,t);return r.promise.then((()=>e(r.data))),null}var n=lit(jvt,this)[t];if(!n||n.data===Nvt)throw new Error("Requesting object that isn't resolved yet ".concat(t,"."));return n.data}has(t){var e=lit(jvt,this)[t];return!!e&&e.data!==Nvt}delete(t){var e=lit(jvt,this)[t];return!(!e||e.data===Nvt)&&(delete lit(jvt,this)[t],!0)}resolve(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=iit(Bvt,this,Wvt).call(this,t);r.data=e,r.resolve()}clear(){for(var t in lit(jvt,this)){var e,{data:r}=lit(jvt,this)[t];null==r||null===(e=r.bitmap)||void 0===e||e.close()}cit(jvt,this,Object.create(null))}*[Symbol.iterator](){for(var t in lit(jvt,this)){var{data:e}=lit(jvt,this)[t];e!==Nvt&&(yield[t,e])}}}function Wvt(t){var e;return(e=lit(jvt,this))[t]||(e[t]=git(git({},Promise.withResolvers()),{},{data:Nvt}))}var Uvt=new WeakMap;class Hvt{constructor(t){hit(this,Uvt,null),cit(Uvt,this,t),this.onContinue=null}get promise(){return lit(Uvt,this).capability.promise}cancel(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;lit(Uvt,this).cancel(null,t)}get separateAnnots(){var{separateAnnots:t}=lit(Uvt,this).operatorList;if(!t)return!1;var{annotationCanvasMap:e}=lit(Uvt,this);return t.form||t.canvas&&(null==e?void 0:e.size)>0}}var Gvt=new WeakMap;class Yvt{constructor(t){var{callback:e,params:r,objs:n,commonObjs:i,annotationCanvasMap:a,operatorList:s,pageIndex:o,canvasFactory:l,filterFactory:h,useRequestAnimationFrame:c=!1,pdfBug:u=!1,pageColors:d=null}=t;hit(this,Gvt,null),this.callback=e,this.params=r,this.objs=n,this.commonObjs=i,this.annotationCanvasMap=a,this.operatorListIdx=null,this.operatorList=s,this._pageIndex=o,this.canvasFactory=l,this.filterFactory=h,this._pdfBug=u,this.pageColors=d,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=!0===c&&"undefined"!=typeof window,this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new Hvt(this),this._cancelBound=this.cancel.bind(this),this._continueBound=this._continue.bind(this),this._scheduleNextBound=this._scheduleNext.bind(this),this._nextBound=this._next.bind(this),this._canvas=r.canvasContext.canvas}get completed(){return this.capability.promise.catch((function(){}))}initializeGraphics(t){var e,r,{transparency:n=!1,optionalContentConfig:i}=t;if(!this.cancelled){if(this._canvas){if(Vvt._.has(this._canvas))throw new Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");Vvt._.add(this._canvas)}this._pdfBug&&null!==(e=globalThis.StepperManager)&&void 0!==e&&e.enabled&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());var{canvasContext:a,viewport:s,transform:o,background:l}=this.params;this.gfx=new Pft(a,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:i},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:o,viewport:s,transparency:n,background:l}),this.operatorListIdx=0,this.graphicsReady=!0,null===(r=this.graphicsReadyCallback)||void 0===r||r.call(this)}}cancel(){var t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;this.running=!1,this.cancelled=!0,null===(t=this.gfx)||void 0===t||t.endDrawing(),lit(Gvt,this)&&(window.cancelAnimationFrame(lit(Gvt,this)),cit(Gvt,this,null)),Vvt._.delete(this._canvas),this.callback(e||new nht("Rendering cancelled, page ".concat(this._pageIndex+1),r))}operatorListChanged(){var t;this.graphicsReady?(null===(t=this.stepper)||void 0===t||t.updateOperatorList(this.operatorList),this.running||this._continue()):this.graphicsReadyCallback||(this.graphicsReadyCallback=this._continueBound)}_continue(){this.running=!0,this.cancelled||(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?cit(Gvt,this,window.requestAnimationFrame((()=>{cit(Gvt,this,null),this._nextBound().catch(this._cancelBound)}))):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}_next(){var t=this;return sit((function*(){t.cancelled||(t.operatorListIdx=t.gfx.executeOperatorList(t.operatorList,t.operatorListIdx,t._continueBound,t.stepper),t.operatorListIdx===t.operatorList.argsArray.length&&(t.running=!1,t.operatorList.lastChunk&&(t.gfx.endDrawing(),Vvt._.delete(t._canvas),t.callback())))}))()}}var Vvt={_:new WeakSet},qvt="4.10.38",Xvt="f9bea397f";function $vt(t){return Math.floor(255*Math.max(0,Math.min(1,t))).toString(16).padStart(2,"0")}function Kvt(t){return Math.max(0,Math.min(255,255*t))}class Qvt{static CMYK_G(t){var[e,r,n,i]=t;return["G",1-Math.min(1,.3*e+.59*n+.11*r+i)]}static G_CMYK(t){var[e]=t;return["CMYK",0,0,0,1-e]}static G_RGB(t){var[e]=t;return["RGB",e,e,e]}static G_rgb(t){var[e]=t;return[e=Kvt(e),e,e]}static G_HTML(t){var[e]=t,r=$vt(e);return"#".concat(r).concat(r).concat(r)}static RGB_G(t){var[e,r,n]=t;return["G",.3*e+.59*r+.11*n]}static RGB_rgb(t){return t.map(Kvt)}static RGB_HTML(t){return"#".concat(t.map($vt).join(""))}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB(t){var[e,r,n,i]=t;return["RGB",1-Math.min(1,e+i),1-Math.min(1,n+i),1-Math.min(1,r+i)]}static CMYK_rgb(t){var[e,r,n,i]=t;return[Kvt(1-Math.min(1,e+i)),Kvt(1-Math.min(1,n+i)),Kvt(1-Math.min(1,r+i))]}static CMYK_HTML(t){var e=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(e)}static RGB_CMYK(t){var[e,r,n]=t,i=1-e,a=1-r,s=1-n;return["CMYK",i,a,s,Math.min(i,a,s)]}}class Jvt{create(t,e){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(t<=0||e<=0)throw new Error("Invalid SVG dimensions");var n=this._createSVG("svg:svg");return n.setAttribute("version","1.1"),r||(n.setAttribute("width","".concat(t,"px")),n.setAttribute("height","".concat(e,"px"))),n.setAttribute("preserveAspectRatio","none"),n.setAttribute("viewBox","0 0 ".concat(t," ").concat(e)),n}createElement(t){if("string"!=typeof t)throw new Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){Tlt("Abstract method `_createSVG` called.")}}class Zvt extends Jvt{_createSVG(t){return document.createElementNS(Jlt,t)}}class tmt{static setupStorage(t,e,r,n,i){var a=n.getValue(e,{value:null});switch(r.name){case"textarea":if(null!==a.value&&(t.textContent=a.value),"print"===i)break;t.addEventListener("input",(t=>{n.setValue(e,{value:t.target.value})}));break;case"input":if("radio"===r.attributes.type||"checkbox"===r.attributes.type){if(a.value===r.attributes.xfaOn?t.setAttribute("checked",!0):a.value===r.attributes.xfaOff&&t.removeAttribute("checked"),"print"===i)break;t.addEventListener("change",(t=>{n.setValue(e,{value:t.target.checked?t.target.getAttribute("xfaOn"):t.target.getAttribute("xfaOff")})}))}else{if(null!==a.value&&t.setAttribute("value",a.value),"print"===i)break;t.addEventListener("input",(t=>{n.setValue(e,{value:t.target.value})}))}break;case"select":if(null!==a.value)for(var s of(t.setAttribute("value",a.value),r.children))s.attributes.value===a.value?s.attributes.selected=!0:s.attributes.hasOwnProperty("selected")&&delete s.attributes.selected;t.addEventListener("input",(t=>{var r=t.target.options,i=-1===r.selectedIndex?"":r[r.selectedIndex].value;n.setValue(e,{value:i})}))}}static setAttributes(t){var{html:e,element:r,storage:n=null,intent:i,linkService:a}=t,{attributes:s}=r,o=e instanceof HTMLAnchorElement;for(var[l,h]of("radio"===s.type&&(s.name="".concat(s.name,"-").concat(i)),Object.entries(s)))if(null!=h)switch(l){case"class":h.length&&e.setAttribute(l,h.join(" "));break;case"dataId":break;case"id":e.setAttribute("data-element-id",h);break;case"style":Object.assign(e.style,h);break;case"textContent":e.textContent=h;break;default:(!o||"href"!==l&&"newWindow"!==l)&&e.setAttribute(l,h)}o&&a.addLinkAttributes(e,s.href,s.newWindow),n&&s.dataId&&this.setupStorage(e,s.dataId,r,n)}static render(t){var e=t.annotationStorage,r=t.linkService,n=t.xfaHtml,i=t.intent||"display",a=document.createElement(n.name);n.attributes&&this.setAttributes({html:a,element:n,intent:i,linkService:r});var s="richText"!==i,o=t.div;if(o.append(a),t.viewport){var l="matrix(".concat(t.viewport.transform.join(","),")");o.style.transform=l}s&&o.setAttribute("class","xfaLayer xfaFont");var h=[];if(0===n.children.length){if(n.value){var c=document.createTextNode(n.value);a.append(c),s&&evt.shouldBuildText(n.name)&&h.push(c)}return{textDivs:h}}for(var u=[[n,-1,a]];u.length>0;){var d,p,[f,g,v]=u.at(-1);if(g+1!==f.children.length){var m=f.children[++u.at(-1)[1]];if(null!==m){var{name:y}=m;if("#text"!==y){var b=null!=m&&null!==(d=m.attributes)&&void 0!==d&&d.xmlns?document.createElementNS(m.attributes.xmlns,y):document.createElement(y);if(v.append(b),m.attributes&&this.setAttributes({html:b,element:m,storage:e,intent:i,linkService:r}),(null===(p=m.children)||void 0===p?void 0:p.length)>0)u.push([m,-1,b]);else if(m.value){var w=document.createTextNode(m.value);s&&evt.shouldBuildText(y)&&h.push(w),b.append(w)}}else{var x=document.createTextNode(m.value);h.push(x),v.append(x)}}}else u.pop()}for(var A of o.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))A.setAttribute("readOnly",!0);return{textDivs:h}}static update(t){var e="matrix(".concat(t.viewport.transform.join(","),")");t.div.style.transform=e,t.div.hidden=!1}}var emt=1e3,rmt=new WeakSet;function nmt(t){return{width:t[2]-t[0],height:t[3]-t[1]}}class imt{static create(t){switch(t.data.annotationType){case Jot:return new dmt(t);case Qot:return new vmt(t);case flt:switch(t.data.fieldType){case"Tx":return new ymt(t);case"Btn":return t.data.radioButton?new xmt(t):t.data.checkBox?new wmt(t):new Amt(t);case"Ch":return new _mt(t);case"Sig":return new bmt(t)}return new mmt(t);case dlt:return new kmt(t);case Zot:return new eyt(t);case tlt:return new nyt(t);case elt:return new ayt(t);case rlt:return new oyt(t);case ilt:return new hyt(t);case clt:return new uyt(t);case ult:return new gyt(t);case nlt:return new cyt(t);case alt:return new myt(t);case slt:return new yyt(t);case olt:return new byt(t);case llt:return new wyt(t);case hlt:return new xyt(t);case plt:return new kyt(t);default:return new hmt(t)}}}var amt=new WeakMap,smt=new WeakMap,omt=new WeakMap,lmt=new WeakSet;class hmt{constructor(t){var{isRenderable:e=!1,ignoreBorder:r=!1,createQuadrilaterals:n=!1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};dit(this,lmt),hit(this,amt,null),hit(this,smt,!1),hit(this,omt,null),this.isRenderable=e,this.data=t.data,this.layer=t.layer,this.linkService=t.linkService,this.downloadManager=t.downloadManager,this.imageResourcesPath=t.imageResourcesPath,this.renderForms=t.renderForms,this.svgFactory=t.svgFactory,this.annotationStorage=t.annotationStorage,this.enableScripting=t.enableScripting,this.hasJSActions=t.hasJSActions,this._fieldObjects=t.fieldObjects,this.parent=t.parent,e&&(this.container=this._createContainer(r)),n&&this._createQuadrilaterals()}static _hasPopupData(t){var{titleObj:e,contentsObj:r,richText:n}=t;return!!(null!=e&&e.str||null!=r&&r.str||null!=n&&n.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return hmt._hasPopupData(this.data)}updateEdited(t){var e;if(this.container){lit(amt,this)||cit(amt,this,{rect:this.data.rect.slice(0)});var{rect:r}=t;r&&iit(lmt,this,cmt).call(this,r),null===(e=lit(omt,this))||void 0===e||e.popup.updateEdited(t)}}resetEdited(){var t;lit(amt,this)&&(iit(lmt,this,cmt).call(this,lit(amt,this).rect),null===(t=lit(omt,this))||void 0===t||t.popup.resetEdited(),cit(amt,this,null))}_createContainer(t){var{data:e,parent:{page:r,viewport:n}}=this,i=document.createElement("section");i.setAttribute("data-annotation-id",e.id),this instanceof mmt||(i.tabIndex=emt);var{style:a}=i;if(a.zIndex=this.parent.zIndex++,e.alternativeText&&(i.title=e.alternativeText),e.noRotate&&i.classList.add("norotate"),!e.rect||this instanceof kmt){var{rotation:s}=e;return e.hasOwnCanvas||0===s||this.setRotation(s,i),i}var{width:o,height:l}=nmt(e.rect);if(!t&&e.borderStyle.width>0){a.borderWidth="".concat(e.borderStyle.width,"px");var h=e.borderStyle.horizontalCornerRadius,c=e.borderStyle.verticalCornerRadius;if(h>0||c>0){var u="calc(".concat(h,"px * var(--scale-factor)) / calc(").concat(c,"px * var(--scale-factor))");a.borderRadius=u}else if(this instanceof xmt){var d="calc(".concat(o,"px * var(--scale-factor)) / calc(").concat(l,"px * var(--scale-factor))");a.borderRadius=d}switch(e.borderStyle.style){case glt:a.borderStyle="solid";break;case vlt:a.borderStyle="dashed";break;case mlt:Mlt("Unimplemented border style: beveled");break;case ylt:Mlt("Unimplemented border style: inset");break;case blt:a.borderBottomStyle="solid"}var p=e.borderColor||null;p?(cit(smt,this,!0),a.borderColor=Ylt.makeHexColor(0|p[0],0|p[1],0|p[2])):a.borderWidth=0}var f=Ylt.normalizeRect([e.rect[0],r.view[3]-e.rect[1]+r.view[1],e.rect[2],r.view[3]-e.rect[3]+r.view[1]]),{pageWidth:g,pageHeight:v,pageX:m,pageY:y}=n.rawDims;a.left="".concat(100*(f[0]-m)/g,"%"),a.top="".concat(100*(f[1]-y)/v,"%");var{rotation:b}=e;return e.hasOwnCanvas||0===b?(a.width="".concat(100*o/g,"%"),a.height="".concat(100*l/v,"%")):this.setRotation(b,i),i}setRotation(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.container;if(this.data.rect){var r,n,{pageWidth:i,pageHeight:a}=this.parent.viewport.rawDims,{width:s,height:o}=nmt(this.data.rect);t%180==0?(r=100*s/i,n=100*o/a):(r=100*o/i,n=100*s/a),e.style.width="".concat(r,"%"),e.style.height="".concat(n,"%"),e.setAttribute("data-main-rotation",(360-t)%360)}}get _commonActions(){var t=(t,e,r)=>{var n=r.detail[t],i=n[0],a=n.slice(1);r.target.style[e]=Qvt["".concat(i,"_HTML")](a),this.annotationStorage.setValue(this.data.id,{[e]:Qvt["".concat(i,"_rgb")](a)})};return Ilt(this,"_commonActions",{display:t=>{var{display:e}=t.detail,r=e%2==1;this.container.style.visibility=r?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:r,noPrint:1===e||2===e})},print:t=>{this.annotationStorage.setValue(this.data.id,{noPrint:!t.detail.print})},hidden:t=>{var{hidden:e}=t.detail;this.container.style.visibility=e?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:e,noView:e})},focus:t=>{setTimeout((()=>t.target.focus({preventScroll:!1})),0)},userName:t=>{t.target.title=t.detail.userName},readonly:t=>{t.target.disabled=t.detail.readonly},required:t=>{this._setRequired(t.target,t.detail.required)},bgColor:e=>{t("bgColor","backgroundColor",e)},fillColor:e=>{t("fillColor","backgroundColor",e)},fgColor:e=>{t("fgColor","color",e)},textColor:e=>{t("textColor","color",e)},borderColor:e=>{t("borderColor","borderColor",e)},strokeColor:e=>{t("strokeColor","borderColor",e)},rotation:t=>{var e=t.detail.rotation;this.setRotation(e),this.annotationStorage.setValue(this.data.id,{rotation:e})}})}_dispatchEventFromSandbox(t,e){var r=this._commonActions;for(var n of Object.keys(e.detail)){var i=t[n]||r[n];null==i||i(e)}}_setDefaultPropertiesFromJS(t){if(this.enableScripting){var e=this.annotationStorage.getRawValue(this.data.id);if(e){var r=this._commonActions;for(var[n,i]of Object.entries(e)){var a=r[n];if(a)a({detail:{[n]:i},target:t}),delete e[n]}}}}_createQuadrilaterals(){if(this.container){var{quadPoints:t}=this.data;if(t){var[e,r,n,i]=this.data.rect.map((t=>Math.fround(t)));if(8===t.length){var[a,s,o,l]=t.subarray(2,6);if(n===a&&i===s&&e===o&&r===l)return}var h,{style:c}=this.container;if(lit(smt,this)){var{borderColor:u,borderWidth:d}=c;c.borderWidth=0,h=["url('data:image/svg+xml;utf8,",'<svg xmlns="http://www.w3.org/2000/svg"',' preserveAspectRatio="none" viewBox="0 0 1 1">','<g fill="transparent" stroke="'.concat(u,'" stroke-width="').concat(d,'">')],this.container.classList.add("hasBorder")}var p=n-e,f=i-r,{svgFactory:g}=this,v=g.createElement("svg");v.classList.add("quadrilateralsContainer"),v.setAttribute("width",0),v.setAttribute("height",0);var m=g.createElement("defs");v.append(m);var y=g.createElement("clipPath"),b="clippath_".concat(this.data.id);y.setAttribute("id",b),y.setAttribute("clipPathUnits","objectBoundingBox"),m.append(y);for(var w=2,x=t.length;w<x;w+=8){var A,_=t[w],k=t[w+1],S=t[w+2],E=t[w+3],M=g.createElement("rect"),T=(S-e)/p,C=(i-k)/f,P=(_-S)/p,I=(k-E)/f;M.setAttribute("x",T),M.setAttribute("y",C),M.setAttribute("width",P),M.setAttribute("height",I),y.append(M),null===(A=h)||void 0===A||A.push('<rect vector-effect="non-scaling-stroke" x="'.concat(T,'" y="').concat(C,'" width="').concat(P,'" height="').concat(I,'"/>'))}lit(smt,this)&&(h.push("</g></svg>')"),c.backgroundImage=h.join("")),this.container.append(v),this.container.style.clipPath="url(#".concat(b,")")}}}_createPopup(){var{data:t}=this,e=cit(omt,this,new kmt({data:{color:t.color,titleObj:t.titleObj,modificationDate:t.modificationDate,contentsObj:t.contentsObj,richText:t.richText,parentRect:t.rect,borderStyle:0,id:"popup_".concat(t.id),rotation:t.rotation},parent:this.parent,elements:[this]}));this.parent.div.append(e.render())}render(){Tlt("Abstract method `AnnotationElement.render` called")}_getElementsByName(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=[];if(this._fieldObjects){var n=this._fieldObjects[t];if(n)for(var{page:i,id:a,exportValues:s}of n)if(-1!==i&&a!==e){var o="string"==typeof s?s:null,l=document.querySelector('[data-element-id="'.concat(a,'"]'));!l||rmt.has(l)?r.push({id:a,exportValue:o,domElement:l}):Mlt("_getElementsByName - element not allowed: ".concat(a))}return r}for(var h of document.getElementsByName(t)){var{exportValue:c}=h,u=h.getAttribute("data-element-id");u!==e&&(rmt.has(h)&&r.push({id:u,exportValue:c,domElement:h}))}return r}show(){var t;this.container&&(this.container.hidden=!1),null===(t=this.popup)||void 0===t||t.maybeShow()}hide(){var t;this.container&&(this.container.hidden=!0),null===(t=this.popup)||void 0===t||t.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){var t=this.getElementsToTriggerPopup();if(Array.isArray(t))for(var e of t)e.classList.add("highlightArea");else t.classList.add("highlightArea")}_editOnDoubleClick(){if(this._isEditable){var{annotationEditorType:t,data:{id:e}}=this;this.container.addEventListener("dblclick",(()=>{var r;null===(r=this.linkService.eventBus)||void 0===r||r.dispatch("switchannotationeditormode",{source:this,mode:t,editId:e})}))}}}function cmt(t){var{container:{style:e},data:{rect:r,rotation:n},parent:{viewport:{rawDims:{pageWidth:i,pageHeight:a,pageX:s,pageY:o}}}}=this;null==r||r.splice(0,4,...t);var{width:l,height:h}=nmt(t);e.left="".concat(100*(t[0]-s)/i,"%"),e.top="".concat(100*(a-t[3]+o)/a,"%"),0===n?(e.width="".concat(100*l/i,"%"),e.height="".concat(100*h/a,"%")):this.setRotation(n)}var umt=new WeakSet;class dmt extends hmt{constructor(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;super(t,{isRenderable:!0,ignoreBorder:!(null==e||!e.ignoreBorder),createQuadrilaterals:!0}),dit(this,umt),this.isTooltipOnly=t.data.isTooltipOnly}render(){var{data:t,linkService:e}=this,r=document.createElement("a");r.setAttribute("data-element-id",t.id);var n=!1;return t.url?(e.addLinkAttributes(r,t.url,t.newWindow),n=!0):t.action?(this._bindNamedAction(r,t.action),n=!0):t.attachment?(iit(umt,this,fmt).call(this,r,t.attachment,t.attachmentDest),n=!0):t.setOCGState?(iit(umt,this,gmt).call(this,r,t.setOCGState),n=!0):t.dest?(this._bindLink(r,t.dest),n=!0):(t.actions&&(t.actions.Action||t.actions["Mouse Up"]||t.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(r,t),n=!0),t.resetForm?(this._bindResetFormAction(r,t.resetForm),n=!0):this.isTooltipOnly&&!n&&(this._bindLink(r,""),n=!0)),this.container.classList.add("linkAnnotation"),n&&this.container.append(r),this.container}_bindLink(t,e){t.href=this.linkService.getDestinationHash(e),t.onclick=()=>(e&&this.linkService.goToDestination(e),!1),(e||""===e)&&iit(umt,this,pmt).call(this)}_bindNamedAction(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeNamedAction(e),!1),iit(umt,this,pmt).call(this)}_bindJSAction(t,e){var r=this;t.href=this.linkService.getAnchorUrl("");var n=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]),i=function(i){var a=n.get(i);if(!a)return 1;t[a]=()=>{var t;return null===(t=r.linkService.eventBus)||void 0===t||t.dispatch("dispatcheventinsandbox",{source:r,detail:{id:e.id,name:i}}),!1}};for(var a of Object.keys(e.actions))i(a);t.onclick||(t.onclick=()=>!1),iit(umt,this,pmt).call(this)}_bindResetFormAction(t,e){var r=t.onclick;if(r||(t.href=this.linkService.getAnchorUrl("")),iit(umt,this,pmt).call(this),!this._fieldObjects)return Mlt('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),void(r||(t.onclick=()=>!1));t.onclick=()=>{null==r||r();var{fields:t,refs:n,include:i}=e,a=[];if(0!==t.length||0!==n.length){var s=new Set(n);for(var o of t){var l=this._fieldObjects[o]||[];for(var{id:h}of l)s.add(h)}for(var c of Object.values(this._fieldObjects))for(var u of c)s.has(u.id)===i&&a.push(u)}else for(var d of Object.values(this._fieldObjects))a.push(...d);var p,f=this.annotationStorage,g=[];for(var v of a){var{id:m}=v;switch(g.push(m),v.type){case"text":var y=v.defaultValue||"";f.setValue(m,{value:y});break;case"checkbox":case"radiobutton":var b=v.defaultValue===v.exportValues;f.setValue(m,{value:b});break;case"combobox":case"listbox":var w=v.defaultValue||"";f.setValue(m,{value:w});break;default:continue}var x=document.querySelector('[data-element-id="'.concat(m,'"]'));x&&(rmt.has(x)?x.dispatchEvent(new Event("resetform")):Mlt("_bindResetFormAction - element not allowed: ".concat(m)))}this.enableScripting&&(null===(p=this.linkService.eventBus)||void 0===p||p.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:g,name:"ResetForm"}}));return!1}}}function pmt(){this.container.setAttribute("data-internal-link","")}function fmt(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;t.href=this.linkService.getAnchorUrl(""),e.description&&(t.title=e.description),t.onclick=()=>{var t;return null===(t=this.downloadManager)||void 0===t||t.openOrDownloadData(e.content,e.filename,r),!1},iit(umt,this,pmt).call(this)}function gmt(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeSetOCGState(e),!1),iit(umt,this,pmt).call(this)}class vmt extends hmt{constructor(t){super(t,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");var t=document.createElement("img");return t.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",t.setAttribute("data-l10n-id","pdfjs-text-annotation-type"),t.setAttribute("data-l10n-args",JSON.stringify({type:this.data.name})),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.append(t),this.container}}class mmt extends hmt{render(){return this.container}showElementAndHideCanvas(t){var e;this.data.hasOwnCanvas&&("CANVAS"===(null===(e=t.previousSibling)||void 0===e?void 0:e.nodeName)&&(t.previousSibling.hidden=!0),t.hidden=!1)}_getKeyModifier(t){return Hlt.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,r,n,i){r.includes("mouse")?t.addEventListener(r,(t=>{var e;null===(e=this.linkService.eventBus)||void 0===e||e.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:n,value:i(t),shift:t.shiftKey,modifier:this._getKeyModifier(t)}})})):t.addEventListener(r,(t=>{var a;if("blur"===r){if(!e.focused||!t.relatedTarget)return;e.focused=!1}else if("focus"===r){if(e.focused)return;e.focused=!0}i&&(null===(a=this.linkService.eventBus)||void 0===a||a.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:n,value:i(t)}}))}))}_setEventListeners(t,e,r,n){for(var[i,a]of r){var s,o,l;if("Action"===a||null!==(s=this.data.actions)&&void 0!==s&&s[a])"Focus"!==a&&"Blur"!==a||e||(e={focused:!1}),this._setEventListener(t,e,i,a,n),"Focus"!==a||null!==(o=this.data.actions)&&void 0!==o&&o.Blur?"Blur"!==a||null!==(l=this.data.actions)&&void 0!==l&&l.Focus||this._setEventListener(t,e,"focus","Focus",null):this._setEventListener(t,e,"blur","Blur",null)}}_setBackgroundColor(t){var e=this.data.backgroundColor||null;t.style.backgroundColor=null===e?"transparent":Ylt.makeHexColor(e[0],e[1],e[2])}_setTextStyle(t){var e,{fontColor:r}=this.data.defaultAppearanceData,n=this.data.defaultAppearanceData.fontSize||9,i=t.style,a=t=>Math.round(10*t)/10;if(this.data.multiLine){var s=Math.abs(this.data.rect[3]-this.data.rect[1]-2),o=s/(Math.round(s/(Iot*n))||1);e=Math.min(n,a(o/Iot))}else{var l=Math.abs(this.data.rect[3]-this.data.rect[1]-2);e=Math.min(n,a(l/Iot))}i.fontSize="calc(".concat(e,"px * var(--scale-factor))"),i.color=Ylt.makeHexColor(r[0],r[1],r[2]),null!==this.data.textAlignment&&(i.textAlign=["left","center","right"][this.data.textAlignment])}_setRequired(t,e){e?t.setAttribute("required",!0):t.removeAttribute("required"),t.setAttribute("aria-required",e)}}class ymt extends mmt{constructor(t){super(t,{isRenderable:t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue})}setPropertyOnSiblings(t,e,r,n){var i=this.annotationStorage;for(var a of this._getElementsByName(t.name,t.id))a.domElement&&(a.domElement[e]=r),i.setValue(a.id,{[n]:r})}render(){var t=this.annotationStorage,e=this.data.id;this.container.classList.add("textWidgetAnnotation");var r=null;if(this.renderForms){var n,i=t.getValue(e,{value:this.data.fieldValue}),a=i.value||"",s=t.getValue(e,{charLimit:this.data.maxLen}).charLimit;s&&a.length>s&&(a=a.slice(0,s));var o=i.formattedValue||(null===(n=this.data.textContent)||void 0===n?void 0:n.join("\n"))||null;o&&this.data.comb&&(o=o.replaceAll(/\s+/g,""));var l={userValue:a,formattedValue:o,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?((r=document.createElement("textarea")).textContent=null!=o?o:a,this.data.doNotScroll&&(r.style.overflowY="hidden")):((r=document.createElement("input")).type="text",r.setAttribute("value",null!=o?o:a),this.data.doNotScroll&&(r.style.overflowX="hidden")),this.data.hasOwnCanvas&&(r.hidden=!0),rmt.add(r),r.setAttribute("data-element-id",e),r.disabled=this.data.readOnly,r.name=this.data.fieldName,r.tabIndex=emt,this._setRequired(r,this.data.required),s&&(r.maxLength=s),r.addEventListener("input",(n=>{t.setValue(e,{value:n.target.value}),this.setPropertyOnSiblings(r,"value",n.target.value,"value"),l.formattedValue=null})),r.addEventListener("resetform",(t=>{var e,n=null!==(e=this.data.defaultFieldValue)&&void 0!==e?e:"";r.value=l.userValue=n,l.formattedValue=null}));var h=t=>{var{formattedValue:e}=l;null!=e&&(t.target.value=e),t.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){var c;r.addEventListener("focus",(t=>{var e;if(!l.focused){var{target:r}=t;l.userValue&&(r.value=l.userValue),l.lastCommittedValue=r.value,l.commitKey=1,null!==(e=this.data.actions)&&void 0!==e&&e.Focus||(l.focused=!0)}})),r.addEventListener("updatefromsandbox",(r=>{this.showElementAndHideCanvas(r.target);var n={value(r){var n;l.userValue=null!==(n=r.detail.value)&&void 0!==n?n:"",t.setValue(e,{value:l.userValue.toString()}),r.target.value=l.userValue},formattedValue(r){var{formattedValue:n}=r.detail;l.formattedValue=n,null!=n&&r.target!==document.activeElement&&(r.target.value=n),t.setValue(e,{formattedValue:n})},selRange(t){t.target.setSelectionRange(...t.detail.selRange)},charLimit:r=>{var n,{charLimit:i}=r.detail,{target:a}=r;if(0!==i){a.setAttribute("maxLength",i);var s=l.userValue;!s||s.length<=i||(s=s.slice(0,i),a.value=l.userValue=s,t.setValue(e,{value:s}),null===(n=this.linkService.eventBus)||void 0===n||n.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:s,willCommit:!0,commitKey:1,selStart:a.selectionStart,selEnd:a.selectionEnd}}))}else a.removeAttribute("maxLength")}};this._dispatchEventFromSandbox(n,r)})),r.addEventListener("keydown",(t=>{var r;l.commitKey=1;var n=-1;if("Escape"===t.key?n=0:"Enter"!==t.key||this.data.multiLine?"Tab"===t.key&&(l.commitKey=3):n=2,-1!==n){var{value:i}=t.target;l.lastCommittedValue!==i&&(l.lastCommittedValue=i,l.userValue=i,null===(r=this.linkService.eventBus)||void 0===r||r.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:i,willCommit:!0,commitKey:n,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}}))}}));var u=h;h=null,r.addEventListener("blur",(t=>{var r;if(l.focused&&t.relatedTarget){null!==(r=this.data.actions)&&void 0!==r&&r.Blur||(l.focused=!1);var n,{value:i}=t.target;if(l.userValue=i,l.lastCommittedValue!==i)null===(n=this.linkService.eventBus)||void 0===n||n.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:i,willCommit:!0,commitKey:l.commitKey,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}});u(t)}})),null!==(c=this.data.actions)&&void 0!==c&&c.Keystroke&&r.addEventListener("beforeinput",(t=>{var r;l.lastCommittedValue=null;var{data:n,target:i}=t,{value:a,selectionStart:s,selectionEnd:o}=i,h=s,c=o;switch(t.inputType){case"deleteWordBackward":var u=a.substring(0,s).match(/\w*[^\w]*$/);u&&(h-=u[0].length);break;case"deleteWordForward":var d=a.substring(s).match(/^[^\w]*\w*/);d&&(c+=d[0].length);break;case"deleteContentBackward":s===o&&(h-=1);break;case"deleteContentForward":s===o&&(c+=1)}t.preventDefault(),null===(r=this.linkService.eventBus)||void 0===r||r.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:a,change:n||"",willCommit:!1,selStart:h,selEnd:c}})})),this._setEventListeners(r,l,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(t=>t.target.value))}if(h&&r.addEventListener("blur",h),this.data.comb){var d=(this.data.rect[2]-this.data.rect[0])/s;r.classList.add("comb"),r.style.letterSpacing="calc(".concat(d,"px * var(--scale-factor) - 1ch)")}}else(r=document.createElement("div")).textContent=this.data.fieldValue,r.style.verticalAlign="middle",r.style.display="table-cell",this.data.hasOwnCanvas&&(r.hidden=!0);return this._setTextStyle(r),this._setBackgroundColor(r),this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}}class bmt extends mmt{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class wmt extends mmt{constructor(t){super(t,{isRenderable:t.renderForms})}render(){var t=this.annotationStorage,e=this.data,r=e.id,n=t.getValue(r,{value:e.exportValue===e.fieldValue}).value;"string"==typeof n&&(n="Off"!==n,t.setValue(r,{value:n})),this.container.classList.add("buttonWidgetAnnotation","checkBox");var i=document.createElement("input");return rmt.add(i),i.setAttribute("data-element-id",r),i.disabled=e.readOnly,this._setRequired(i,this.data.required),i.type="checkbox",i.name=e.fieldName,n&&i.setAttribute("checked",!0),i.setAttribute("exportValue",e.exportValue),i.tabIndex=emt,i.addEventListener("change",(n=>{var{name:i,checked:a}=n.target;for(var s of this._getElementsByName(i,r)){var o=a&&s.exportValue===e.exportValue;s.domElement&&(s.domElement.checked=o),t.setValue(s.id,{value:o})}t.setValue(r,{value:a})})),i.addEventListener("resetform",(t=>{var r=e.defaultFieldValue||"Off";t.target.checked=r===e.exportValue})),this.enableScripting&&this.hasJSActions&&(i.addEventListener("updatefromsandbox",(e=>{var n={value(e){e.target.checked="Off"!==e.detail.value,t.setValue(r,{value:e.target.checked})}};this._dispatchEventFromSandbox(n,e)})),this._setEventListeners(i,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(t=>t.target.checked))),this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}class xmt extends mmt{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");var t=this.annotationStorage,e=this.data,r=e.id,n=t.getValue(r,{value:e.fieldValue===e.buttonValue}).value;if("string"==typeof n&&(n=n!==e.buttonValue,t.setValue(r,{value:n})),n)for(var i of this._getElementsByName(e.fieldName,r))t.setValue(i.id,{value:!1});var a=document.createElement("input");if(rmt.add(a),a.setAttribute("data-element-id",r),a.disabled=e.readOnly,this._setRequired(a,this.data.required),a.type="radio",a.name=e.fieldName,n&&a.setAttribute("checked",!0),a.tabIndex=emt,a.addEventListener("change",(e=>{var{name:n,checked:i}=e.target;for(var a of this._getElementsByName(n,r))t.setValue(a.id,{value:!1});t.setValue(r,{value:i})})),a.addEventListener("resetform",(t=>{var r=e.defaultFieldValue;t.target.checked=null!=r&&r===e.buttonValue})),this.enableScripting&&this.hasJSActions){var s=e.buttonValue;a.addEventListener("updatefromsandbox",(e=>{var n={value:e=>{var n=s===e.detail.value;for(var i of this._getElementsByName(e.target.name)){var a=n&&i.id===r;i.domElement&&(i.domElement.checked=a),t.setValue(i.id,{value:a})}}};this._dispatchEventFromSandbox(n,e)})),this._setEventListeners(a,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(t=>t.target.checked))}return this._setBackgroundColor(a),this._setDefaultPropertiesFromJS(a),this.container.append(a),this.container}}class Amt extends dmt{constructor(t){super(t,{ignoreBorder:t.data.hasAppearance})}render(){var t=super.render();t.classList.add("buttonWidgetAnnotation","pushButton");var e=t.lastChild;return this.enableScripting&&this.hasJSActions&&e&&(this._setDefaultPropertiesFromJS(e),e.addEventListener("updatefromsandbox",(t=>{this._dispatchEventFromSandbox({},t)}))),t}}class _mt extends mmt{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");var t=this.annotationStorage,e=this.data.id,r=t.getValue(e,{value:this.data.fieldValue}),n=document.createElement("select");rmt.add(n),n.setAttribute("data-element-id",e),n.disabled=this.data.readOnly,this._setRequired(n,this.data.required),n.name=this.data.fieldName,n.tabIndex=emt;var i=this.data.combo&&this.data.options.length>0;for(var a of(this.data.combo||(n.size=this.data.options.length,this.data.multiSelect&&(n.multiple=!0)),n.addEventListener("resetform",(t=>{var e=this.data.defaultFieldValue;for(var r of n.options)r.selected=r.value===e})),this.data.options)){var s=document.createElement("option");s.textContent=a.displayValue,s.value=a.exportValue,r.value.includes(a.exportValue)&&(s.setAttribute("selected",!0),i=!1),n.append(s)}var o=null;if(i){var l=document.createElement("option");l.value=" ",l.setAttribute("hidden",!0),l.setAttribute("selected",!0),n.prepend(l),o=()=>{l.remove(),n.removeEventListener("input",o),o=null},n.addEventListener("input",o)}var h=t=>{var e=t?"value":"textContent",{options:r,multiple:i}=n;return i?Array.prototype.filter.call(r,(t=>t.selected)).map((t=>t[e])):-1===r.selectedIndex?null:r[r.selectedIndex][e]},c=h(!1),u=t=>{var e=t.target.options;return Array.prototype.map.call(e,(t=>({displayValue:t.textContent,exportValue:t.value})))};return this.enableScripting&&this.hasJSActions?(n.addEventListener("updatefromsandbox",(r=>{var i={value(r){var i;null===(i=o)||void 0===i||i();var a=r.detail.value,s=new Set(Array.isArray(a)?a:[a]);for(var l of n.options)l.selected=s.has(l.value);t.setValue(e,{value:h(!0)}),c=h(!1)},multipleSelection(t){n.multiple=!0},remove(r){var i=n.options,a=r.detail.remove;if(i[a].selected=!1,n.remove(a),i.length>0){var s=Array.prototype.findIndex.call(i,(t=>t.selected));-1===s&&(i[0].selected=!0)}t.setValue(e,{value:h(!0),items:u(r)}),c=h(!1)},clear(r){for(;0!==n.length;)n.remove(0);t.setValue(e,{value:null,items:[]}),c=h(!1)},insert(r){var{index:i,displayValue:a,exportValue:s}=r.detail.insert,o=n.children[i],l=document.createElement("option");l.textContent=a,l.value=s,o?o.before(l):n.append(l),t.setValue(e,{value:h(!0),items:u(r)}),c=h(!1)},items(r){for(var{items:i}=r.detail;0!==n.length;)n.remove(0);for(var a of i){var{displayValue:s,exportValue:o}=a,l=document.createElement("option");l.textContent=s,l.value=o,n.append(l)}n.options.length>0&&(n.options[0].selected=!0),t.setValue(e,{value:h(!0),items:u(r)}),c=h(!1)},indices(r){var n=new Set(r.detail.indices);for(var i of r.target.options)i.selected=n.has(i.index);t.setValue(e,{value:h(!0)}),c=h(!1)},editable(t){t.target.disabled=!t.detail.editable}};this._dispatchEventFromSandbox(i,r)})),n.addEventListener("input",(r=>{var n,i=h(!0),a=h(!1);t.setValue(e,{value:i}),r.preventDefault(),null===(n=this.linkService.eventBus)||void 0===n||n.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:c,change:a,changeEx:i,willCommit:!1,commitKey:1,keyDown:!1}})})),this._setEventListeners(n,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],(t=>t.target.value))):n.addEventListener("input",(function(r){t.setValue(e,{value:h(!0)})})),this.data.combo&&this._setTextStyle(n),this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class kmt extends hmt{constructor(t){var{data:e,elements:r}=t;super(t,{isRenderable:hmt._hasPopupData(e)}),this.elements=r,this.popup=null}render(){this.container.classList.add("popupAnnotation");var t=this.popup=new Ymt({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate,contentsObj:this.data.contentsObj,richText:this.data.richText,rect:this.data.rect,parentRect:this.data.parentRect||null,parent:this.parent,elements:this.elements,open:this.data.open}),e=[];for(var r of this.elements)r.popup=t,r.container.ariaHasPopup="dialog",e.push(r.data.id),r.addHighlightArea();return this.container.setAttribute("aria-controls",e.map((t=>"".concat(Qlt).concat(t))).join(",")),this.container}}var Smt=new WeakMap,Emt=new WeakMap,Mmt=new WeakMap,Tmt=new WeakMap,Cmt=new WeakMap,Pmt=new WeakMap,Imt=new WeakMap,Rmt=new WeakMap,Omt=new WeakMap,Lmt=new WeakMap,Dmt=new WeakMap,Fmt=new WeakMap,Nmt=new WeakMap,jmt=new WeakMap,Bmt=new WeakMap,zmt=new WeakMap,Wmt=new WeakMap,Umt=new WeakMap,Hmt=new WeakMap,Gmt=new WeakSet;class Ymt{constructor(t){var{container:e,color:r,elements:n,titleObj:i,modificationDate:a,contentsObj:s,richText:o,parent:l,rect:h,parentRect:c,open:u}=t;for(var d of(dit(this,Gmt),hit(this,Smt,iit(Gmt,this,Kmt).bind(this)),hit(this,Emt,iit(Gmt,this,tyt).bind(this)),hit(this,Mmt,iit(Gmt,this,Zmt).bind(this)),hit(this,Tmt,iit(Gmt,this,Jmt).bind(this)),hit(this,Cmt,null),hit(this,Pmt,null),hit(this,Imt,null),hit(this,Rmt,null),hit(this,Omt,null),hit(this,Lmt,null),hit(this,Dmt,null),hit(this,Fmt,!1),hit(this,Nmt,null),hit(this,jmt,null),hit(this,Bmt,null),hit(this,zmt,null),hit(this,Wmt,null),hit(this,Umt,null),hit(this,Hmt,!1),cit(Pmt,this,e),cit(Wmt,this,i),cit(Imt,this,s),cit(zmt,this,o),cit(Lmt,this,l),cit(Cmt,this,r),cit(Bmt,this,h),cit(Dmt,this,c),cit(Omt,this,n),cit(Rmt,this,dht.toDateObject(a)),this.trigger=n.flatMap((t=>t.getElementsToTriggerPopup())),this.trigger))d.addEventListener("click",lit(Tmt,this)),d.addEventListener("mouseenter",lit(Mmt,this)),d.addEventListener("mouseleave",lit(Emt,this)),d.classList.add("popupTriggerArea");for(var p of n){var f;null===(f=p.container)||void 0===f||f.addEventListener("keydown",lit(Smt,this))}lit(Pmt,this).hidden=!0,u&&iit(Gmt,this,Jmt).call(this)}render(){if(!lit(Nmt,this)){var t=cit(Nmt,this,document.createElement("div"));if(t.className="popup",lit(Cmt,this)){var e=t.style.outlineColor=Ylt.makeHexColor(...lit(Cmt,this));if(CSS.supports("background-color","color-mix(in srgb, red 30%, white)"))t.style.backgroundColor="color-mix(in srgb, ".concat(e," 30%, white)");else{t.style.backgroundColor=Ylt.makeHexColor(...lit(Cmt,this).map((t=>Math.floor(.7*(255-t)+t))))}}var r=document.createElement("span");r.className="header";var n=document.createElement("h1");if(r.append(n),({dir:n.dir,str:n.textContent}=lit(Wmt,this)),t.append(r),lit(Rmt,this)){var i=document.createElement("span");i.classList.add("popupDate"),i.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),i.setAttribute("data-l10n-args",JSON.stringify({dateObj:lit(Rmt,this).valueOf()})),r.append(i)}var a=uit(Gmt,this,Vmt);if(a)tmt.render({xfaHtml:a,intent:"richText",div:t}),t.lastChild.classList.add("richText","popupContent");else{var s=this._formatContents(lit(Imt,this));t.append(s)}lit(Pmt,this).append(t)}}_formatContents(t){var{str:e,dir:r}=t,n=document.createElement("p");n.classList.add("popupContent"),n.dir=r;for(var i=e.split(/(?:\r\n?|\n)/),a=0,s=i.length;a<s;++a){var o=i[a];n.append(document.createTextNode(o)),a<s-1&&n.append(document.createElement("br"))}return n}updateEdited(t){var e,{rect:r,popupContent:n}=t;lit(Umt,this)||cit(Umt,this,{contentsObj:lit(Imt,this),richText:lit(zmt,this)}),r&&cit(jmt,this,null),n&&(cit(zmt,this,iit(Gmt,this,$mt).call(this,n)),cit(Imt,this,null)),null===(e=lit(Nmt,this))||void 0===e||e.remove(),cit(Nmt,this,null)}resetEdited(){var t;lit(Umt,this)&&(({contentsObj:vit(cit,[Imt,this])._,richText:vit(cit,[zmt,this])._}=lit(Umt,this)),cit(Umt,this,null),null===(t=lit(Nmt,this))||void 0===t||t.remove(),cit(Nmt,this,null),cit(jmt,this,null))}forceHide(){cit(Hmt,this,this.isVisible),lit(Hmt,this)&&(lit(Pmt,this).hidden=!0)}maybeShow(){lit(Hmt,this)&&(lit(Nmt,this)||iit(Gmt,this,Zmt).call(this),cit(Hmt,this,!1),lit(Pmt,this).hidden=!1)}get isVisible(){return!1===lit(Pmt,this).hidden}}function Vmt(t){var e=lit(zmt,t),r=lit(Imt,t);return null==e||!e.str||null!=r&&r.str&&r.str!==e.str?null:lit(zmt,t).html||null}function qmt(t){var e;return(null===(e=uit(Gmt,t,Vmt))||void 0===e||null===(e=e.attributes)||void 0===e||null===(e=e.style)||void 0===e?void 0:e.fontSize)||0}function Xmt(t){var e;return(null===(e=uit(Gmt,t,Vmt))||void 0===e||null===(e=e.attributes)||void 0===e||null===(e=e.style)||void 0===e?void 0:e.color)||null}function $mt(t){var e=[],r={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}},n={style:{color:uit(Gmt,this,Xmt),fontSize:uit(Gmt,this,qmt)?"calc(".concat(uit(Gmt,this,qmt),"px * var(--scale-factor))"):""}};for(var i of t.split("\n"))e.push({name:"span",value:i,attributes:n});return r}function Kmt(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||("Enter"===t.key||"Escape"===t.key&&lit(Fmt,this))&&iit(Gmt,this,Jmt).call(this)}function Qmt(){if(null===lit(jmt,this)){var{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:r,pageX:n,pageY:i}}}=lit(Lmt,this),a=!!lit(Dmt,this),s=lit(a?Dmt:Bmt,this);for(var o of lit(Omt,this))if(!s||null!==Ylt.intersect(o.data.rect,s)){s=o.data.rect,a=!0;break}var l=Ylt.normalizeRect([s[0],t[3]-s[1]+t[1],s[2],t[3]-s[3]+t[1]]),h=a?s[2]-s[0]+5:0,c=l[0]+h,u=l[1];cit(jmt,this,[100*(c-n)/e,100*(u-i)/r]);var{style:d}=lit(Pmt,this);d.left="".concat(lit(jmt,this)[0],"%"),d.top="".concat(lit(jmt,this)[1],"%")}}function Jmt(){cit(Fmt,this,!lit(Fmt,this)),lit(Fmt,this)?(iit(Gmt,this,Zmt).call(this),lit(Pmt,this).addEventListener("click",lit(Tmt,this)),lit(Pmt,this).addEventListener("keydown",lit(Smt,this))):(iit(Gmt,this,tyt).call(this),lit(Pmt,this).removeEventListener("click",lit(Tmt,this)),lit(Pmt,this).removeEventListener("keydown",lit(Smt,this)))}function Zmt(){lit(Nmt,this)||this.render(),this.isVisible?lit(Fmt,this)&&lit(Pmt,this).classList.add("focused"):(iit(Gmt,this,Qmt).call(this),lit(Pmt,this).hidden=!1,lit(Pmt,this).style.zIndex=parseInt(lit(Pmt,this).style.zIndex)+1e3)}function tyt(){lit(Pmt,this).classList.remove("focused"),!lit(Fmt,this)&&this.isVisible&&(lit(Pmt,this).hidden=!0,lit(Pmt,this).style.zIndex=parseInt(lit(Pmt,this).style.zIndex)-1e3)}class eyt extends hmt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=Wot.FREETEXT}render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){var t=document.createElement("div");for(var e of(t.classList.add("annotationTextContent"),t.setAttribute("role","comment"),this.textContent)){var r=document.createElement("span");r.textContent=e,t.append(r)}this.container.append(t)}return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}var ryt=new WeakMap;class nyt extends hmt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),hit(this,ryt,null)}render(){this.container.classList.add("lineAnnotation");var t=this.data,{width:e,height:r}=nmt(t.rect),n=this.svgFactory.create(e,r,!0),i=cit(ryt,this,this.svgFactory.createElement("svg:line"));return i.setAttribute("x1",t.rect[2]-t.lineCoordinates[0]),i.setAttribute("y1",t.rect[3]-t.lineCoordinates[1]),i.setAttribute("x2",t.rect[2]-t.lineCoordinates[2]),i.setAttribute("y2",t.rect[3]-t.lineCoordinates[3]),i.setAttribute("stroke-width",t.borderStyle.width||1),i.setAttribute("stroke","transparent"),i.setAttribute("fill","transparent"),n.append(i),this.container.append(n),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return lit(ryt,this)}addHighlightArea(){this.container.classList.add("highlightArea")}}var iyt=new WeakMap;class ayt extends hmt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),hit(this,iyt,null)}render(){this.container.classList.add("squareAnnotation");var t=this.data,{width:e,height:r}=nmt(t.rect),n=this.svgFactory.create(e,r,!0),i=t.borderStyle.width,a=cit(iyt,this,this.svgFactory.createElement("svg:rect"));return a.setAttribute("x",i/2),a.setAttribute("y",i/2),a.setAttribute("width",e-i),a.setAttribute("height",r-i),a.setAttribute("stroke-width",i||1),a.setAttribute("stroke","transparent"),a.setAttribute("fill","transparent"),n.append(a),this.container.append(n),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return lit(iyt,this)}addHighlightArea(){this.container.classList.add("highlightArea")}}var syt=new WeakMap;class oyt extends hmt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),hit(this,syt,null)}render(){this.container.classList.add("circleAnnotation");var t=this.data,{width:e,height:r}=nmt(t.rect),n=this.svgFactory.create(e,r,!0),i=t.borderStyle.width,a=cit(syt,this,this.svgFactory.createElement("svg:ellipse"));return a.setAttribute("cx",e/2),a.setAttribute("cy",r/2),a.setAttribute("rx",e/2-i/2),a.setAttribute("ry",r/2-i/2),a.setAttribute("stroke-width",i||1),a.setAttribute("stroke","transparent"),a.setAttribute("fill","transparent"),n.append(a),this.container.append(n),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return lit(syt,this)}addHighlightArea(){this.container.classList.add("highlightArea")}}var lyt=new WeakMap;class hyt extends hmt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),hit(this,lyt,null),this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);var{data:{rect:t,vertices:e,borderStyle:r,popupRef:n}}=this;if(!e)return this.container;for(var{width:i,height:a}=nmt(t),s=this.svgFactory.create(i,a,!0),o=[],l=0,h=e.length;l<h;l+=2){var c=e[l]-t[0],u=t[3]-e[l+1];o.push("".concat(c,",").concat(u))}o=o.join(" ");var d=cit(lyt,this,this.svgFactory.createElement(this.svgElementName));return d.setAttribute("points",o),d.setAttribute("stroke-width",r.width||1),d.setAttribute("stroke","transparent"),d.setAttribute("fill","transparent"),s.append(d),this.container.append(s),!n&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return lit(lyt,this)}addHighlightArea(){this.container.classList.add("highlightArea")}}class cyt extends hyt{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class uyt extends hmt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container}}var dyt=new WeakMap,pyt=new WeakMap,fyt=new WeakSet;class gyt extends hmt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),dit(this,fyt),hit(this,dyt,null),hit(this,pyt,[]),this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType="InkHighlight"===this.data.it?Wot.HIGHLIGHT:Wot.INK}render(){this.container.classList.add(this.containerClassName);var{data:{rect:t,rotation:e,inkLists:r,borderStyle:n,popupRef:i}}=this,{transform:a,width:s,height:o}=iit(fyt,this,vyt).call(this,e,t),l=this.svgFactory.create(s,o,!0),h=cit(dyt,this,this.svgFactory.createElement("svg:g"));l.append(h),h.setAttribute("stroke-width",n.width||1),h.setAttribute("stroke-linecap","round"),h.setAttribute("stroke-linejoin","round"),h.setAttribute("stroke-miterlimit",10),h.setAttribute("stroke","transparent"),h.setAttribute("fill","transparent"),h.setAttribute("transform",a);for(var c=0,u=r.length;c<u;c++){var d=this.svgFactory.createElement(this.svgElementName);lit(pyt,this).push(d),d.setAttribute("points",r[c].join(",")),h.append(d)}return!i&&this.hasPopupData&&this._createPopup(),this.container.append(l),this._editOnDoubleClick(),this.container}updateEdited(t){super.updateEdited(t);var{thickness:e,points:r,rect:n}=t,i=lit(dyt,this);if(e>=0&&i.setAttribute("stroke-width",e||1),r)for(var a=0,s=lit(pyt,this).length;a<s;a++)lit(pyt,this)[a].setAttribute("points",r[a].join(","));if(n){var{transform:o,width:l,height:h}=iit(fyt,this,vyt).call(this,this.data.rotation,n);i.parentElement.setAttribute("viewBox","0 0 ".concat(l," ").concat(h)),i.setAttribute("transform",o)}}getElementsToTriggerPopup(){return lit(pyt,this)}addHighlightArea(){this.container.classList.add("highlightArea")}}function vyt(t,e){switch(t){case 90:return{transform:"rotate(90) translate(".concat(-e[0],",").concat(e[1],") scale(1,-1)"),width:e[3]-e[1],height:e[2]-e[0]};case 180:return{transform:"rotate(180) translate(".concat(-e[2],",").concat(e[1],") scale(1,-1)"),width:e[2]-e[0],height:e[3]-e[1]};case 270:return{transform:"rotate(270) translate(".concat(-e[2],",").concat(e[3],") scale(1,-1)"),width:e[3]-e[1],height:e[2]-e[0]};default:return{transform:"translate(".concat(-e[0],",").concat(e[3],") scale(1,-1)"),width:e[2]-e[0],height:e[3]-e[1]}}}class myt extends hmt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=Wot.HIGHLIGHT}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),this.container}}class yyt extends hmt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("underlineAnnotation"),this.container}}class byt extends hmt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("squigglyAnnotation"),this.container}}class wyt extends hmt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("strikeoutAnnotation"),this.container}}class xyt extends hmt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=Wot.STAMP}render(){return this.container.classList.add("stampAnnotation"),this.container.setAttribute("role","img"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}var Ayt=new WeakMap,_yt=new WeakSet;class kyt extends hmt{constructor(t){var e;super(t,{isRenderable:!0}),dit(this,_yt),hit(this,Ayt,null);var{file:r}=this.data;this.filename=r.filename,this.content=r.content,null===(e=this.linkService.eventBus)||void 0===e||e.dispatch("fileattachmentannotation",git({source:this},r))}render(){this.container.classList.add("fileAttachmentAnnotation");var t,{container:e,data:r}=this;r.hasAppearance||0===r.fillAlpha?t=document.createElement("div"):((t=document.createElement("img")).src="".concat(this.imageResourcesPath,"annotation-").concat(/paperclip/i.test(r.name)?"paperclip":"pushpin",".svg"),r.fillAlpha&&r.fillAlpha<1&&(t.style="filter: opacity(".concat(Math.round(100*r.fillAlpha),"%);"))),t.addEventListener("dblclick",iit(_yt,this,Syt).bind(this)),cit(Ayt,this,t);var{isMac:n}=Hlt.platform;return e.addEventListener("keydown",(t=>{"Enter"===t.key&&(n?t.metaKey:t.ctrlKey)&&iit(_yt,this,Syt).call(this)})),!r.popupRef&&this.hasPopupData?this._createPopup():t.classList.add("popupTriggerArea"),e.append(t),e}getElementsToTriggerPopup(){return lit(Ayt,this)}addHighlightArea(){this.container.classList.add("highlightArea")}}function Syt(){var t;null===(t=this.downloadManager)||void 0===t||t.openOrDownloadData(this.content,this.filename)}var Eyt=new WeakMap,Myt=new WeakMap,Tyt=new WeakMap,Cyt=new WeakMap,Pyt=new WeakSet;class Iyt{constructor(t){var{div:e,accessibilityManager:r,annotationCanvasMap:n,annotationEditorUIManager:i,page:a,viewport:s,structTreeLayer:o}=t;dit(this,Pyt),hit(this,Eyt,null),hit(this,Myt,null),hit(this,Tyt,new Map),hit(this,Cyt,null),this.div=e,cit(Eyt,this,r),cit(Myt,this,n),cit(Cyt,this,o||null),this.page=a,this.viewport=s,this.zIndex=0,this._annotationEditorUIManager=i}hasEditableAnnotations(){return lit(Tyt,this).size>0}render(t){var e=this;return sit((function*(){var{annotations:r}=t,n=e.div;yht(n,e.viewport);var i=new Map,a={data:null,layer:n,linkService:t.linkService,downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:!1!==t.renderForms,svgFactory:new Zvt,annotationStorage:t.annotationStorage||new tpt,enableScripting:!0===t.enableScripting,hasJSActions:t.hasJSActions,fieldObjects:t.fieldObjects,parent:e,elements:null};for(var s of r)if(!s.noHTML){var o=s.annotationType===dlt;if(o){var l=i.get(s.id);if(!l)continue;a.elements=l}else{var{width:h,height:c}=nmt(s.rect);if(h<=0||c<=0)continue}a.data=s;var u=imt.create(a);if(u.isRenderable){if(!o&&s.popupRef){var d=i.get(s.popupRef);d?d.push(u):i.set(s.popupRef,[u])}var p,f=u.render();if(s.hidden&&(f.style.visibility="hidden"),yield iit(Pyt,e,Ryt).call(e,f,s.id),u._isEditable)lit(Tyt,e).set(u.data.id,u),null===(p=e._annotationEditorUIManager)||void 0===p||p.renderAnnotationElement(u)}}iit(Pyt,e,Lyt).call(e)}))()}update(t){var{viewport:e}=t,r=this.div;this.viewport=e,yht(r,{rotation:e.rotation}),iit(Pyt,this,Lyt).call(this),r.hidden=!1}getEditableAnnotations(){return Array.from(lit(Tyt,this).values())}getEditableAnnotation(t){return lit(Tyt,this).get(t)}}function Ryt(t,e){return Oyt.apply(this,arguments)}function Oyt(){return Oyt=sit((function*(t,e){var r,n,i=t.firstChild||t,a=i.id="".concat(Qlt).concat(e),s=yield null===(r=lit(Cyt,this))||void 0===r?void 0:r.getAriaAttributes(a);if(s)for(var[o,l]of s)i.setAttribute(o,l);this.div.append(t),null===(n=lit(Eyt,this))||void 0===n||n.moveElementInDOM(this.div,t,i,!1)})),Oyt.apply(this,arguments)}function Lyt(){if(lit(Myt,this)){var t=this.div;for(var[e,r]of lit(Myt,this)){var n=t.querySelector('[data-annotation-id="'.concat(e,'"]'));if(n){r.className="annotationContent";var{firstChild:i}=n;i?"CANVAS"===i.nodeName?i.replaceWith(r):i.classList.contains("annotationContent")?i.after(r):i.before(r):n.append(r)}}lit(Myt,this).clear()}}var Dyt=/\r\n?|\n/g,Fyt=new WeakMap,Nyt=new WeakMap,jyt=new WeakMap,Byt=new WeakMap,zyt=new WeakMap,Wyt=new WeakSet;class Uyt extends kdt{static get _keyboardManager(){var t=Uyt.prototype,e=t=>t.isEmpty(),r=Kct.TRANSLATE_SMALL,n=Kct.TRANSLATE_BIG;return Ilt(this,"_keyboardManager",new ict([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],t.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter","Escape","mac+Escape"],t.commitOrRemove],[["ArrowLeft","mac+ArrowLeft"],t._translateEmpty,{args:[-r,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t._translateEmpty,{args:[-n,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t._translateEmpty,{args:[r,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t._translateEmpty,{args:[n,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t._translateEmpty,{args:[0,-r],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t._translateEmpty,{args:[0,-n],checker:e}],[["ArrowDown","mac+ArrowDown"],t._translateEmpty,{args:[0,r],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t._translateEmpty,{args:[0,n],checker:e}]]))}constructor(t){super(git(git({},t),{},{name:"freeTextEditor"})),dit(this,Wyt),hit(this,Fyt,void 0),hit(this,Nyt,""),hit(this,jyt,"".concat(this.id,"-editor")),hit(this,Byt,null),hit(this,zyt,void 0),cit(Fyt,this,t.color||Uyt._defaultColor||kdt._defaultLineColor),cit(zyt,this,t.fontSize||Uyt._defaultFontSize)}static initialize(t,e){kdt.initialize(t,e);var r=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(r.getPropertyValue("--freetext-padding"))}static updateDefaultParams(t,e){switch(t){case Uot.FREETEXT_SIZE:Uyt._defaultFontSize=e;break;case Uot.FREETEXT_COLOR:Uyt._defaultColor=e}}updateParams(t,e){switch(t){case Uot.FREETEXT_SIZE:iit(Wyt,this,Hyt).call(this,e);break;case Uot.FREETEXT_COLOR:iit(Wyt,this,Gyt).call(this,e)}}static get defaultPropertiesToUpdate(){return[[Uot.FREETEXT_SIZE,Uyt._defaultFontSize],[Uot.FREETEXT_COLOR,Uyt._defaultColor||kdt._defaultLineColor]]}get propertiesToUpdate(){return[[Uot.FREETEXT_SIZE,lit(zyt,this)],[Uot.FREETEXT_COLOR,lit(Fyt,this)]]}_translateEmpty(t,e){this._uiManager.translateSelectedEditors(t,e,!0)}getInitialTranslation(){var t=this.parentScale;return[-Uyt._internalPadding*t,-(Uyt._internalPadding+lit(zyt,this))*t]}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(!this.isInEditMode()){this.parent.setEditingState(!1),this.parent.updateToolbar(Wot.FREETEXT),super.enableEditMode(),this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),cit(Byt,this,new AbortController);var t=this._uiManager.combinedSignal(lit(Byt,this));this.editorDiv.addEventListener("keydown",this.editorDivKeydown.bind(this),{signal:t}),this.editorDiv.addEventListener("focus",this.editorDivFocus.bind(this),{signal:t}),this.editorDiv.addEventListener("blur",this.editorDivBlur.bind(this),{signal:t}),this.editorDiv.addEventListener("input",this.editorDivInput.bind(this),{signal:t}),this.editorDiv.addEventListener("paste",this.editorDivPaste.bind(this),{signal:t})}}disableEditMode(){var t;this.isInEditMode()&&(this.parent.setEditingState(!0),super.disableEditMode(),this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",lit(jyt,this)),this._isDraggable=!0,null===(t=lit(Byt,this))||void 0===t||t.abort(),cit(Byt,this,null),this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"))}focusin(t){this._focusEventsAllowed&&(super.focusin(t),t.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(t){var e;this.width||(this.enableEditMode(),t&&this.editorDiv.focus(),null!==(e=this._initialOptions)&&void 0!==e&&e.isCentered&&this.center(),this._initialOptions=null)}isEmpty(){return!this.editorDiv||""===this.editorDiv.innerText.trim()}remove(){this.isEditing=!1,this.parent&&(this.parent.setEditingState(!0),this.parent.div.classList.add("freetextEditing")),super.remove()}commit(){if(this.isInEditMode()){super.commit(),this.disableEditMode();var t=lit(Nyt,this),e=cit(Nyt,this,iit(Wyt,this,Yyt).call(this).trimEnd());if(t!==e){var r=t=>{cit(Nyt,this,t),t?(iit(Wyt,this,Xyt).call(this),this._uiManager.rebuild(this),iit(Wyt,this,Vyt).call(this)):this.remove()};this.addCommands({cmd:()=>{r(e)},undo:()=>{r(t)},mustExec:!1}),iit(Wyt,this,Vyt).call(this)}}}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}dblclick(t){this.enterInEditMode()}keydown(t){t.target===this.div&&"Enter"===t.key&&(this.enterInEditMode(),t.preventDefault())}editorDivKeydown(t){Uyt._keyboardManager.exec(this,t)}editorDivFocus(t){this.isEditing=!0}editorDivBlur(t){this.isEditing=!1}editorDivInput(t){this.parent.div.classList.toggle("freetextEditing",this.isEmpty())}disableEditing(){this.editorDiv.setAttribute("role","comment"),this.editorDiv.removeAttribute("aria-multiline")}enableEditing(){this.editorDiv.setAttribute("role","textbox"),this.editorDiv.setAttribute("aria-multiline",!0)}render(){if(this.div)return this.div;var t,e;this.width&&(t=this.x,e=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",lit(jyt,this)),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text2"),this.editorDiv.setAttribute("data-l10n-attrs","default-content"),this.enableEditing(),this.editorDiv.contentEditable=!0;var{style:r}=this.editorDiv;if(r.fontSize="calc(".concat(lit(zyt,this),"px * var(--scale-factor))"),r.color=lit(Fyt,this),this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),Uht(this,this.div,["dblclick","keydown"]),this.width){var[n,i]=this.parentDimensions;if(this.annotationElementId){var{position:a}=this._initialData,[s,o]=this.getInitialTranslation();[s,o]=this.pageTranslationToScreen(s,o);var l,h,[c,u]=this.pageDimensions,[d,p]=this.pageTranslation;switch(this.rotation){case 0:l=t+(a[0]-d)/c,h=e+this.height-(a[1]-p)/u;break;case 90:l=t+(a[0]-d)/c,h=e-(a[1]-p)/u,[s,o]=[o,-s];break;case 180:l=t-this.width+(a[0]-d)/c,h=e-(a[1]-p)/u,[s,o]=[-s,-o];break;case 270:l=t+(a[0]-d-this.height*u)/c,h=e+(a[1]-p-this.width*c)/u,[s,o]=[-o,s]}this.setAt(l*n,h*i,s,o)}else this.setAt(t*n,e*i,this.width*n,this.height*i);iit(Wyt,this,Xyt).call(this),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}editorDivPaste(t){var e=t.clipboardData||window.clipboardData,{types:r}=e;if(1!==r.length||"text/plain"!==r[0]){t.preventDefault();var n=Kyt.call(Uyt,e.getData("text")||"").replaceAll(Dyt,"\n");if(n){var i=window.getSelection();if(i.rangeCount){this.editorDiv.normalize(),i.deleteFromDocument();var a=i.getRangeAt(0);if(!n.includes("\n"))return a.insertNode(document.createTextNode(n)),this.editorDiv.normalize(),void i.collapseToStart();var{startContainer:s,startOffset:o}=a,l=[],h=[];if(s.nodeType===Node.TEXT_NODE){var c=s.parentElement;if(h.push(s.nodeValue.slice(o).replaceAll(Dyt,"")),c!==this.editorDiv){var u=l;for(var d of this.editorDiv.childNodes)d!==c?u.push(qyt.call(Uyt,d)):u=h}l.push(s.nodeValue.slice(0,o).replaceAll(Dyt,""))}else if(s===this.editorDiv){var p=l,f=0;for(var g of this.editorDiv.childNodes)f++===o&&(p=h),p.push(qyt.call(Uyt,g))}cit(Nyt,this,"".concat(l.join("\n")).concat(n).concat(h.join("\n"))),iit(Wyt,this,Xyt).call(this);var v=new Range,m=l.reduce(((t,e)=>t+e.length),0);for(var{firstChild:y}of this.editorDiv.childNodes)if(y.nodeType===Node.TEXT_NODE){var b=y.nodeValue.length;if(m<=b){v.setStart(y,m),v.setEnd(y,m);break}m-=b}i.removeAllRanges(),i.addRange(v)}}}}get contentDiv(){return this.editorDiv}static deserialize(t,e,r){var n=()=>super.deserialize,i=this;return sit((function*(){var a=null;if(t instanceof eyt){var{data:{defaultAppearanceData:{fontSize:s,fontColor:o},rect:l,rotation:h,id:c,popupRef:u},textContent:d,textPosition:p,parent:{page:{pageNumber:f}}}=t;if(!d||0===d.length)return null;a=t={annotationType:Wot.FREETEXT,color:Array.from(o),fontSize:s,value:d.join("\n"),position:p,pageIndex:f-1,rect:l.slice(0),rotation:h,id:c,deleted:!1,popupRef:u}}var g=yield n().call(i,t,e,r);return cit(zyt,g,t.fontSize),cit(Fyt,g,Ylt.makeHexColor(...t.color)),cit(Nyt,g,Kyt.call(Uyt,t.value)),g.annotationElementId=t.id||null,g._initialData=a,g}))()}serialize(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();var e=Uyt._internalPadding*this.parentScale,r=this.getRect(e,e),n=kdt._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:lit(Fyt,this)),i={annotationType:Wot.FREETEXT,color:n,fontSize:lit(zyt,this),value:iit(Wyt,this,$yt).call(this),pageIndex:this.pageIndex,rect:r,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return t?i:this.annotationElementId&&!iit(Wyt,this,Qyt).call(this,i)?null:(i.id=this.annotationElementId,i)}renderAnnotationElement(t){var e=super.renderAnnotationElement(t);if(this.deleted)return e;var{style:r}=e;for(var n of(r.fontSize="calc(".concat(lit(zyt,this),"px * var(--scale-factor))"),r.color=lit(Fyt,this),e.replaceChildren(),lit(Nyt,this).split("\n"))){var i=document.createElement("div");i.append(n?document.createTextNode(n):document.createElement("br")),e.append(i)}var a=Uyt._internalPadding*this.parentScale;return t.updateEdited({rect:this.getRect(a,a),popupContent:lit(Nyt,this)}),e}resetAnnotationElement(t){super.resetAnnotationElement(t),t.resetEdited()}}function Hyt(t){var e=t=>{this.editorDiv.style.fontSize="calc(".concat(t,"px * var(--scale-factor))"),this.translate(0,-(t-lit(zyt,this))*this.parentScale),cit(zyt,this,t),iit(Wyt,this,Vyt).call(this)},r=lit(zyt,this);this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,r),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Uot.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})}function Gyt(t){var e=t=>{cit(Fyt,this,this.editorDiv.style.color=t)},r=lit(Fyt,this);this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,r),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Uot.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})}function Yyt(){var t=[];this.editorDiv.normalize();var e=null;for(var r of this.editorDiv.childNodes){var n;(null===(n=e)||void 0===n?void 0:n.nodeType)===Node.TEXT_NODE&&"BR"===r.nodeName||(t.push(qyt.call(yot,r)),e=r)}return t.join("\n")}function Vyt(){var t,[e,r]=this.parentDimensions;if(this.isAttachedToDOM)t=this.div.getBoundingClientRect();else{var{currentLayer:n,div:i}=this,a=i.style.display,s=i.classList.contains("hidden");i.classList.remove("hidden"),i.style.display="hidden",n.div.append(this.div),t=i.getBoundingClientRect(),i.remove(),i.style.display=a,i.classList.toggle("hidden",s)}this.rotation%180==this.parentRotation%180?(this.width=t.width/e,this.height=t.height/r):(this.width=t.height/e,this.height=t.width/r),this.fixAndSetPosition()}function qyt(t){return(t.nodeType===Node.TEXT_NODE?t.nodeValue:t.innerText).replaceAll(Dyt,"")}function Xyt(){if(this.editorDiv.replaceChildren(),lit(Nyt,this))for(var t of lit(Nyt,this).split("\n")){var e=document.createElement("div");e.append(t?document.createTextNode(t):document.createElement("br")),this.editorDiv.append(e)}}function $yt(){return lit(Nyt,this).replaceAll(" "," ")}function Kyt(t){return t.replaceAll(" "," ")}function Qyt(t){var{value:e,fontSize:r,color:n,pageIndex:i}=this._initialData;return this._hasBeenMoved||t.value!==e||t.fontSize!==r||t.color.some(((t,e)=>t!==n[e]))||t.pageIndex!==i}yot=Uyt,pit(Uyt,"_freeTextDefaultContent",""),pit(Uyt,"_internalPadding",0),pit(Uyt,"_defaultColor",null),pit(Uyt,"_defaultFontSize",10),pit(Uyt,"_type","freetext"),pit(Uyt,"_editorType",Wot.FREETEXT);class Jyt{toSVGPath(){Tlt("Abstract method `toSVGPath` must be implemented.")}get box(){Tlt("Abstract getter `box` must be implemented.")}serialize(t,e){Tlt("Abstract method `serialize` must be implemented.")}static _rescale(t,e,r,n,i,a){a||(a=new Float32Array(t.length));for(var s=0,o=t.length;s<o;s+=2)a[s]=e+t[s]*n,a[s+1]=r+t[s+1]*i;return a}static _rescaleAndSwap(t,e,r,n,i,a){a||(a=new Float32Array(t.length));for(var s=0,o=t.length;s<o;s+=2)a[s]=e+t[s+1]*n,a[s+1]=r+t[s]*i;return a}static _translate(t,e,r,n){n||(n=new Float32Array(t.length));for(var i=0,a=t.length;i<a;i+=2)n[i]=e+t[i],n[i+1]=r+t[i+1];return n}static svgRound(t){return Math.round(1e4*t)}static _normalizePoint(t,e,r,n,i){switch(i){case 90:return[1-e/r,t/n];case 180:return[1-t/r,1-e/n];case 270:return[e/r,1-t/n];default:return[t/r,e/n]}}static _normalizePagePoint(t,e,r){switch(r){case 90:return[1-e,t];case 180:return[1-t,1-e];case 270:return[e,1-t];default:return[t,e]}}static createBezierPoints(t,e,r,n,i,a){return[(t+5*r)/6,(e+5*n)/6,(5*r+i)/6,(5*n+a)/6,(r+i)/2,(n+a)/2]}}pit(Jyt,"PRECISION",1e-4);var Zyt=new WeakMap,tbt=new WeakMap,ebt=new WeakMap,rbt=new WeakMap,nbt=new WeakMap,ibt=new WeakMap,abt=new WeakMap,sbt=new WeakMap,obt=new WeakMap,lbt=new WeakMap,hbt=new WeakMap,cbt=new WeakMap,ubt=new WeakMap,dbt=new WeakSet;class pbt{constructor(t,e,r,n,i){var{x:a,y:s}=t,o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0;dit(this,dbt),hit(this,Zyt,void 0),hit(this,tbt,[]),hit(this,ebt,void 0),hit(this,rbt,void 0),hit(this,nbt,[]),hit(this,ibt,new Float32Array(18)),hit(this,abt,void 0),hit(this,sbt,void 0),hit(this,obt,void 0),hit(this,lbt,void 0),hit(this,hbt,void 0),hit(this,cbt,void 0),hit(this,ubt,[]),cit(Zyt,this,e),cit(cbt,this,n*r),cit(rbt,this,i),lit(ibt,this).set([NaN,NaN,NaN,NaN,a,s],6),cit(ebt,this,o),cit(lbt,this,xbt._*r),cit(obt,this,Abt._*r),cit(hbt,this,r),lit(ubt,this).push(a,s)}isEmpty(){return isNaN(lit(ibt,this)[8])}add(t){var e,{x:r,y:n}=t;cit(abt,this,r),cit(sbt,this,n);var[i,a,s,o]=lit(Zyt,this),[l,h,c,u]=lit(ibt,this).subarray(8,12),d=r-c,p=n-u,f=Math.hypot(d,p);if(f<lit(obt,this))return!1;var g=f-lit(lbt,this),v=g/f,m=v*d,y=v*p,b=l,w=h;l=c,h=u,c+=m,u+=y,null===(e=lit(ubt,this))||void 0===e||e.push(r,n);var x=m/g,A=-y/g*lit(cbt,this),_=x*lit(cbt,this);return lit(ibt,this).set(lit(ibt,this).subarray(2,8),0),lit(ibt,this).set([c+A,u+_],4),lit(ibt,this).set(lit(ibt,this).subarray(14,18),12),lit(ibt,this).set([c-A,u-_],16),isNaN(lit(ibt,this)[6])?(0===lit(nbt,this).length&&(lit(ibt,this).set([l+A,h+_],2),lit(nbt,this).push(NaN,NaN,NaN,NaN,(l+A-i)/s,(h+_-a)/o),lit(ibt,this).set([l-A,h-_],14),lit(tbt,this).push(NaN,NaN,NaN,NaN,(l-A-i)/s,(h-_-a)/o)),lit(ibt,this).set([b,w,l,h,c,u],6),!this.isEmpty()):(lit(ibt,this).set([b,w,l,h,c,u],6),Math.abs(Math.atan2(w-h,b-l)-Math.atan2(y,m))<Math.PI/2?([l,h,c,u]=lit(ibt,this).subarray(2,6),lit(nbt,this).push(NaN,NaN,NaN,NaN,((l+c)/2-i)/s,((h+u)/2-a)/o),[l,h,b,w]=lit(ibt,this).subarray(14,18),lit(tbt,this).push(NaN,NaN,NaN,NaN,((b+l)/2-i)/s,((w+h)/2-a)/o),!0):([b,w,l,h,c,u]=lit(ibt,this).subarray(0,6),lit(nbt,this).push(((b+5*l)/6-i)/s,((w+5*h)/6-a)/o,((5*l+c)/6-i)/s,((5*h+u)/6-a)/o,((l+c)/2-i)/s,((h+u)/2-a)/o),[c,u,l,h,b,w]=lit(ibt,this).subarray(12,18),lit(tbt,this).push(((b+5*l)/6-i)/s,((w+5*h)/6-a)/o,((5*l+c)/6-i)/s,((5*h+u)/6-a)/o,((l+c)/2-i)/s,((h+u)/2-a)/o),!0))}toSVGPath(){if(this.isEmpty())return"";var t=lit(nbt,this),e=lit(tbt,this);if(isNaN(lit(ibt,this)[6])&&!this.isEmpty())return iit(dbt,this,gbt).call(this);var r=[];r.push("M".concat(t[4]," ").concat(t[5]));for(var n=6;n<t.length;n+=6)isNaN(t[n])?r.push("L".concat(t[n+4]," ").concat(t[n+5])):r.push("C".concat(t[n]," ").concat(t[n+1]," ").concat(t[n+2]," ").concat(t[n+3]," ").concat(t[n+4]," ").concat(t[n+5]));iit(dbt,this,mbt).call(this,r);for(var i=e.length-6;i>=6;i-=6)isNaN(e[i])?r.push("L".concat(e[i+4]," ").concat(e[i+5])):r.push("C".concat(e[i]," ").concat(e[i+1]," ").concat(e[i+2]," ").concat(e[i+3]," ").concat(e[i+4]," ").concat(e[i+5]));return iit(dbt,this,vbt).call(this,r),r.join(" ")}newFreeDrawOutline(t,e,r,n,i,a){return new Ibt(t,e,r,n,i,a)}getOutlines(){for(var t,e,r=lit(nbt,this),n=lit(tbt,this),i=lit(ibt,this),[a,s,o,l]=lit(Zyt,this),h=new Float32Array((null!==(t=null===(e=lit(ubt,this))||void 0===e?void 0:e.length)&&void 0!==t?t:0)+2),c=0,u=h.length-2;c<u;c+=2)h[c]=(lit(ubt,this)[c]-a)/o,h[c+1]=(lit(ubt,this)[c+1]-s)/l;if(h[h.length-2]=(lit(abt,this)-a)/o,h[h.length-1]=(lit(sbt,this)-s)/l,isNaN(i[6])&&!this.isEmpty())return iit(dbt,this,ybt).call(this,h);for(var d=new Float32Array(lit(nbt,this).length+24+lit(tbt,this).length),p=r.length,f=0;f<p;f+=2)isNaN(r[f])?d[f]=d[f+1]=NaN:(d[f]=r[f],d[f+1]=r[f+1]);p=iit(dbt,this,wbt).call(this,d,p);for(var g=n.length-6;g>=6;g-=6)for(var v=0;v<6;v+=2)isNaN(n[g+v])?(d[p]=d[p+1]=NaN,p+=2):(d[p]=n[g+v],d[p+1]=n[g+v+1],p+=2);return iit(dbt,this,bbt).call(this,d,p),this.newFreeDrawOutline(d,h,lit(Zyt,this),lit(hbt,this),lit(ebt,this),lit(rbt,this))}}function fbt(){var t=lit(ibt,this).subarray(4,6),e=lit(ibt,this).subarray(16,18),[r,n,i,a]=lit(Zyt,this);return[(lit(abt,this)+(t[0]-e[0])/2-r)/i,(lit(sbt,this)+(t[1]-e[1])/2-n)/a,(lit(abt,this)+(e[0]-t[0])/2-r)/i,(lit(sbt,this)+(e[1]-t[1])/2-n)/a]}function gbt(){var[t,e,r,n]=lit(Zyt,this),[i,a,s,o]=iit(dbt,this,fbt).call(this);return"M".concat((lit(ibt,this)[2]-t)/r," ").concat((lit(ibt,this)[3]-e)/n," L").concat((lit(ibt,this)[4]-t)/r," ").concat((lit(ibt,this)[5]-e)/n," L").concat(i," ").concat(a," L").concat(s," ").concat(o," L").concat((lit(ibt,this)[16]-t)/r," ").concat((lit(ibt,this)[17]-e)/n," L").concat((lit(ibt,this)[14]-t)/r," ").concat((lit(ibt,this)[15]-e)/n," Z")}function vbt(t){var e=lit(tbt,this);t.push("L".concat(e[4]," ").concat(e[5]," Z"))}function mbt(t){var[e,r,n,i]=lit(Zyt,this),a=lit(ibt,this).subarray(4,6),s=lit(ibt,this).subarray(16,18),[o,l,h,c]=iit(dbt,this,fbt).call(this);t.push("L".concat((a[0]-e)/n," ").concat((a[1]-r)/i," L").concat(o," ").concat(l," L").concat(h," ").concat(c," L").concat((s[0]-e)/n," ").concat((s[1]-r)/i))}function ybt(t){var e=lit(ibt,this),[r,n,i,a]=lit(Zyt,this),[s,o,l,h]=iit(dbt,this,fbt).call(this),c=new Float32Array(36);return c.set([NaN,NaN,NaN,NaN,(e[2]-r)/i,(e[3]-n)/a,NaN,NaN,NaN,NaN,(e[4]-r)/i,(e[5]-n)/a,NaN,NaN,NaN,NaN,s,o,NaN,NaN,NaN,NaN,l,h,NaN,NaN,NaN,NaN,(e[16]-r)/i,(e[17]-n)/a,NaN,NaN,NaN,NaN,(e[14]-r)/i,(e[15]-n)/a],0),this.newFreeDrawOutline(c,t,lit(Zyt,this),lit(hbt,this),lit(ebt,this),lit(rbt,this))}function bbt(t,e){var r=lit(tbt,this);return t.set([NaN,NaN,NaN,NaN,r[4],r[5]],e),e+6}function wbt(t,e){var r=lit(ibt,this).subarray(4,6),n=lit(ibt,this).subarray(16,18),[i,a,s,o]=lit(Zyt,this),[l,h,c,u]=iit(dbt,this,fbt).call(this);return t.set([NaN,NaN,NaN,NaN,(r[0]-i)/s,(r[1]-a)/o,NaN,NaN,NaN,NaN,l,h,NaN,NaN,NaN,NaN,c,u,NaN,NaN,NaN,NaN,(n[0]-i)/s,(n[1]-a)/o],e),e+24}var xbt={_:8},Abt={_:xbt._+2},_bt=new WeakMap,kbt=new WeakMap,Sbt=new WeakMap,Ebt=new WeakMap,Mbt=new WeakMap,Tbt=new WeakMap,Cbt=new WeakMap,Pbt=new WeakSet;class Ibt extends Jyt{constructor(t,e,r,n,i,a){super(),dit(this,Pbt),hit(this,_bt,void 0),hit(this,kbt,new Float32Array(4)),hit(this,Sbt,void 0),hit(this,Ebt,void 0),hit(this,Mbt,void 0),hit(this,Tbt,void 0),hit(this,Cbt,void 0),cit(Cbt,this,t),cit(Mbt,this,e),cit(_bt,this,r),cit(Tbt,this,n),cit(Sbt,this,i),cit(Ebt,this,a),this.lastPoint=[NaN,NaN],iit(Pbt,this,Rbt).call(this,a);for(var[s,o,l,h]=lit(kbt,this),c=0,u=t.length;c<u;c+=2)t[c]=(t[c]-s)/l,t[c+1]=(t[c+1]-o)/h;for(var d=0,p=e.length;d<p;d+=2)e[d]=(e[d]-s)/l,e[d+1]=(e[d+1]-o)/h}toSVGPath(){for(var t=["M".concat(lit(Cbt,this)[4]," ").concat(lit(Cbt,this)[5])],e=6,r=lit(Cbt,this).length;e<r;e+=6)isNaN(lit(Cbt,this)[e])?t.push("L".concat(lit(Cbt,this)[e+4]," ").concat(lit(Cbt,this)[e+5])):t.push("C".concat(lit(Cbt,this)[e]," ").concat(lit(Cbt,this)[e+1]," ").concat(lit(Cbt,this)[e+2]," ").concat(lit(Cbt,this)[e+3]," ").concat(lit(Cbt,this)[e+4]," ").concat(lit(Cbt,this)[e+5]));return t.push("Z"),t.join(" ")}serialize(t,e){var r,n,[i,a,s,o]=t,l=s-i,h=o-a;switch(e){case 0:r=Jyt._rescale(lit(Cbt,this),i,o,l,-h),n=Jyt._rescale(lit(Mbt,this),i,o,l,-h);break;case 90:r=Jyt._rescaleAndSwap(lit(Cbt,this),i,a,l,h),n=Jyt._rescaleAndSwap(lit(Mbt,this),i,a,l,h);break;case 180:r=Jyt._rescale(lit(Cbt,this),s,a,-l,h),n=Jyt._rescale(lit(Mbt,this),s,a,-l,h);break;case 270:r=Jyt._rescaleAndSwap(lit(Cbt,this),s,o,-l,-h),n=Jyt._rescaleAndSwap(lit(Mbt,this),s,o,-l,-h)}return{outline:Array.from(r),points:[Array.from(n)]}}get box(){return lit(kbt,this)}newOutliner(t,e,r,n,i){return new pbt(t,e,r,n,i,arguments.length>5&&void 0!==arguments[5]?arguments[5]:0)}getNewOutline(t,e){for(var[r,n,i,a]=lit(kbt,this),[s,o,l,h]=lit(_bt,this),c=i*l,u=a*h,d=r*l+s,p=n*h+o,f=this.newOutliner({x:lit(Mbt,this)[0]*c+d,y:lit(Mbt,this)[1]*u+p},lit(_bt,this),lit(Tbt,this),t,lit(Ebt,this),null!=e?e:lit(Sbt,this)),g=2;g<lit(Mbt,this).length;g+=2)f.add({x:lit(Mbt,this)[g]*c+d,y:lit(Mbt,this)[g+1]*u+p});return f.getOutlines()}}function Rbt(t){for(var e=lit(Cbt,this),r=e[4],n=e[5],i=r,a=n,s=r,o=n,l=r,h=n,c=t?Math.max:Math.min,u=6,d=e.length;u<d;u+=6){if(isNaN(e[u]))i=Math.min(i,e[u+4]),a=Math.min(a,e[u+5]),s=Math.max(s,e[u+4]),o=Math.max(o,e[u+5]),h<e[u+5]?(l=e[u+4],h=e[u+5]):h===e[u+5]&&(l=c(l,e[u+4]));else{var p=Ylt.bezierBoundingBox(r,n,...e.slice(u,u+6));i=Math.min(i,p[0]),a=Math.min(a,p[1]),s=Math.max(s,p[2]),o=Math.max(o,p[3]),h<p[3]?(l=p[2],h=p[3]):h===p[3]&&(l=c(l,p[2]))}r=e[u+4],n=e[u+5]}var f=lit(kbt,this);f[0]=i-lit(Sbt,this),f[1]=a-lit(Sbt,this),f[2]=s-i+2*lit(Sbt,this),f[3]=o-a+2*lit(Sbt,this),this.lastPoint=[l,h]}var Obt=new WeakMap,Lbt=new WeakMap,Dbt=new WeakMap,Fbt=new WeakMap,Nbt=new WeakSet;class jbt{constructor(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];dit(this,Nbt),hit(this,Obt,void 0),hit(this,Lbt,void 0),hit(this,Dbt,[]),hit(this,Fbt,[]);var i=1/0,a=-1/0,s=1/0,o=-1/0,l=Math.pow(10,-4);for(var{x:h,y:c,width:u,height:d}of t){var p=Math.floor((h-e)/l)*l,f=Math.ceil((h+u+e)/l)*l,g=Math.floor((c-e)/l)*l,v=Math.ceil((c+d+e)/l)*l,m=[p,g,v,!0],y=[f,g,v,!1];lit(Dbt,this).push(m,y),i=Math.min(i,p),a=Math.max(a,f),s=Math.min(s,g),o=Math.max(o,v)}var b=a-i+2*r,w=o-s+2*r,x=i-r,A=s-r,_=lit(Dbt,this).at(n?-1:-2),k=[_[0],_[2]];for(var S of lit(Dbt,this)){var[E,M,T]=S;S[0]=(E-x)/b,S[1]=(M-A)/w,S[2]=(T-A)/w}cit(Obt,this,new Float32Array([x,A,b,w])),cit(Lbt,this,k)}getOutlines(){lit(Dbt,this).sort(((t,e)=>t[0]-e[0]||t[1]-e[1]||t[2]-e[2]));var t=[];for(var e of lit(Dbt,this))e[3]?(t.push(...iit(Nbt,this,Hbt).call(this,e)),iit(Nbt,this,Wbt).call(this,e)):(iit(Nbt,this,Ubt).call(this,e),t.push(...iit(Nbt,this,Hbt).call(this,e)));return iit(Nbt,this,Bbt).call(this,t)}}function Bbt(t){var e=[],r=new Set;for(var n of t){var[i,a,s]=n;e.push([i,a,n],[i,s,n])}e.sort(((t,e)=>t[1]-e[1]||t[0]-e[0]));for(var o=0,l=e.length;o<l;o+=2){var h=e[o][2],c=e[o+1][2];h.push(c),c.push(h),r.add(h),r.add(c)}for(var u,d=[];r.size>0;){var p=r.values().next().value,[f,g,v,m,y]=p;r.delete(p);var b=f,w=g;for(u=[f,v],d.push(u);;){var x=void 0;if(r.has(m))x=m;else{if(!r.has(y))break;x=y}r.delete(x),[f,g,v,m,y]=x,b!==f&&(u.push(b,w,f,w===g?g:v),b=f),w=w===g?v:g}u.push(b,w)}return new Vbt(d,lit(Obt,this),lit(Lbt,this))}function zbt(t){for(var e=lit(Fbt,this),r=0,n=e.length-1;r<=n;){var i=r+n>>1,a=e[i][0];if(a===t)return i;a<t?r=i+1:n=i-1}return n+1}function Wbt(t){var[,e,r]=t,n=iit(Nbt,this,zbt).call(this,e);lit(Fbt,this).splice(n,0,[e,r])}function Ubt(t){for(var[,e,r]=t,n=iit(Nbt,this,zbt).call(this,e),i=n;i<lit(Fbt,this).length;i++){var[a,s]=lit(Fbt,this)[i];if(a!==e)break;if(a===e&&s===r)return void lit(Fbt,this).splice(i,1)}for(var o=n-1;o>=0;o--){var[l,h]=lit(Fbt,this)[o];if(l!==e)break;if(l===e&&h===r)return void lit(Fbt,this).splice(o,1)}}function Hbt(t){for(var[e,r,n]=t,i=[[e,r,n]],a=iit(Nbt,this,zbt).call(this,n),s=0;s<a;s++)for(var[o,l]=lit(Fbt,this)[s],h=0,c=i.length;h<c;h++){var[,u,d]=i[h];if(!(l<=u||d<=o))if(u>=o)if(d>l)i[h][1]=l;else{if(1===c)return[];i.splice(h,1),h--,c--}else i[h][2]=o,d>l&&i.push([e,l,d])}return i}var Gbt=new WeakMap,Ybt=new WeakMap;class Vbt extends Jyt{constructor(t,e,r){super(),hit(this,Gbt,void 0),hit(this,Ybt,void 0),cit(Ybt,this,t),cit(Gbt,this,e),this.lastPoint=r}toSVGPath(){var t=[];for(var e of lit(Ybt,this)){var[r,n]=e;t.push("M".concat(r," ").concat(n));for(var i=2;i<e.length;i+=2){var a=e[i],s=e[i+1];a===r?(t.push("V".concat(s)),n=s):s===n&&(t.push("H".concat(a)),r=a)}t.push("Z")}return t.join(" ")}serialize(t,e){var[r,n,i,a]=t,s=[],o=i-r,l=a-n;for(var h of lit(Ybt,this)){for(var c=new Array(h.length),u=0;u<h.length;u+=2)c[u]=r+h[u]*o,c[u+1]=a-h[u+1]*l;s.push(c)}return s}get box(){return lit(Gbt,this)}get classNamesForOutlining(){return["highlightOutline"]}}class qbt extends pbt{newFreeDrawOutline(t,e,r,n,i,a){return new Xbt(t,e,r,n,i,a)}}class Xbt extends Ibt{newOutliner(t,e,r,n,i){return new qbt(t,e,r,n,i,arguments.length>5&&void 0!==arguments[5]?arguments[5]:0)}}var $bt=new WeakMap,Kbt=new WeakMap,Qbt=new WeakMap,Jbt=new WeakMap,Zbt=new WeakMap,twt=new WeakMap,ewt=new WeakMap,rwt=new WeakMap,nwt=new WeakMap,iwt=new WeakMap,awt=new WeakMap,swt=new WeakSet;class owt{static get _keyboardManager(){return Ilt(this,"_keyboardManager",new ict([[["Escape","mac+Escape"],owt.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],owt.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],owt.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],owt.prototype._moveToPrevious],[["Home","mac+Home"],owt.prototype._moveToBeginning],[["End","mac+End"],owt.prototype._moveToEnd]]))}constructor(t){var e,{editor:r=null,uiManager:n=null}=t;dit(this,swt),hit(this,$bt,null),hit(this,Kbt,null),hit(this,Qbt,void 0),hit(this,Jbt,null),hit(this,Zbt,!1),hit(this,twt,!1),hit(this,ewt,null),hit(this,rwt,void 0),hit(this,nwt,null),hit(this,iwt,null),hit(this,awt,void 0),r?(cit(twt,this,!1),cit(awt,this,Uot.HIGHLIGHT_COLOR),cit(ewt,this,r)):(cit(twt,this,!0),cit(awt,this,Uot.HIGHLIGHT_DEFAULT_COLOR)),cit(iwt,this,(null==r?void 0:r._uiManager)||n),cit(rwt,this,lit(iwt,this)._eventBus),cit(Qbt,this,(null==r?void 0:r.color)||(null===(e=lit(iwt,this))||void 0===e?void 0:e.highlightColors.values().next().value)||"#FFFF98"),fwt._||(fwt._=Object.freeze({blue:"pdfjs-editor-colorpicker-blue",green:"pdfjs-editor-colorpicker-green",pink:"pdfjs-editor-colorpicker-pink",red:"pdfjs-editor-colorpicker-red",yellow:"pdfjs-editor-colorpicker-yellow"}))}renderButton(){var t=cit($bt,this,document.createElement("button"));t.className="colorPicker",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),t.setAttribute("aria-haspopup",!0);var e=lit(iwt,this)._signal;t.addEventListener("click",iit(swt,this,uwt).bind(this),{signal:e}),t.addEventListener("keydown",iit(swt,this,cwt).bind(this),{signal:e});var r=cit(Kbt,this,document.createElement("span"));return r.className="swatch",r.setAttribute("aria-hidden",!0),r.style.backgroundColor=lit(Qbt,this),t.append(r),t}renderMainDropdown(){var t=cit(Jbt,this,iit(swt,this,lwt).call(this));return t.setAttribute("aria-orientation","horizontal"),t.setAttribute("aria-labelledby","highlightColorPickerLabel"),t}_colorSelectFromKeyboard(t){if(t.target!==lit($bt,this)){var e=t.target.getAttribute("data-color");e&&iit(swt,this,hwt).call(this,e,t)}else iit(swt,this,uwt).call(this,t)}_moveToNext(t){var e,r;uit(swt,this,pwt)?t.target!==lit($bt,this)?null===(e=t.target.nextSibling)||void 0===e||e.focus():null===(r=lit(Jbt,this).firstChild)||void 0===r||r.focus():iit(swt,this,uwt).call(this,t)}_moveToPrevious(t){var e,r;t.target!==(null===(e=lit(Jbt,this))||void 0===e?void 0:e.firstChild)&&t.target!==lit($bt,this)?(uit(swt,this,pwt)||iit(swt,this,uwt).call(this,t),null===(r=t.target.previousSibling)||void 0===r||r.focus()):uit(swt,this,pwt)&&this._hideDropdownFromKeyboard()}_moveToBeginning(t){var e;uit(swt,this,pwt)?null===(e=lit(Jbt,this).firstChild)||void 0===e||e.focus():iit(swt,this,uwt).call(this,t)}_moveToEnd(t){var e;uit(swt,this,pwt)?null===(e=lit(Jbt,this).lastChild)||void 0===e||e.focus():iit(swt,this,uwt).call(this,t)}hideDropdown(){var t,e;null===(t=lit(Jbt,this))||void 0===t||t.classList.add("hidden"),null===(e=lit(nwt,this))||void 0===e||e.abort(),cit(nwt,this,null)}_hideDropdownFromKeyboard(){var t;lit(twt,this)||(uit(swt,this,pwt)?(this.hideDropdown(),lit($bt,this).focus({preventScroll:!0,focusVisible:lit(Zbt,this)})):null===(t=lit(ewt,this))||void 0===t||t.unselect())}updateColor(t){if(lit(Kbt,this)&&(lit(Kbt,this).style.backgroundColor=t),lit(Jbt,this)){var e=lit(iwt,this).highlightColors.values();for(var r of lit(Jbt,this).children)r.setAttribute("aria-selected",e.next().value===t)}}destroy(){var t,e;null===(t=lit($bt,this))||void 0===t||t.remove(),cit($bt,this,null),cit(Kbt,this,null),null===(e=lit(Jbt,this))||void 0===e||e.remove(),cit(Jbt,this,null)}}function lwt(){var t=document.createElement("div"),e=lit(iwt,this)._signal;for(var[r,n]of(t.addEventListener("contextmenu",cht,{signal:e}),t.className="dropdown",t.role="listbox",t.setAttribute("aria-multiselectable",!1),t.setAttribute("aria-orientation","vertical"),t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown"),lit(iwt,this).highlightColors)){var i=document.createElement("button");i.tabIndex="0",i.role="option",i.setAttribute("data-color",n),i.title=r,i.setAttribute("data-l10n-id",fwt._[r]);var a=document.createElement("span");i.append(a),a.className="swatch",a.style.backgroundColor=n,i.setAttribute("aria-selected",n===lit(Qbt,this)),i.addEventListener("click",iit(swt,this,hwt).bind(this,n),{signal:e}),t.append(i)}return t.addEventListener("keydown",iit(swt,this,cwt).bind(this),{signal:e}),t}function hwt(t,e){e.stopPropagation(),lit(rwt,this).dispatch("switchannotationeditorparams",{source:this,type:lit(awt,this),value:t})}function cwt(t){bot._keyboardManager.exec(this,t)}function uwt(t){if(uit(swt,this,pwt))this.hideDropdown();else if(cit(Zbt,this,0===t.detail),lit(nwt,this)||(cit(nwt,this,new AbortController),window.addEventListener("pointerdown",iit(swt,this,dwt).bind(this),{signal:lit(iwt,this).combinedSignal(lit(nwt,this))})),lit(Jbt,this))lit(Jbt,this).classList.remove("hidden");else{var e=cit(Jbt,this,iit(swt,this,lwt).call(this));lit($bt,this).append(e)}}function dwt(t){var e;null!==(e=lit(Jbt,this))&&void 0!==e&&e.contains(t.target)||this.hideDropdown()}function pwt(t){return lit(Jbt,t)&&!lit(Jbt,t).classList.contains("hidden")}bot=owt;var fwt={_:null},gwt=new WeakMap,vwt=new WeakMap,mwt=new WeakMap,ywt=new WeakMap,bwt=new WeakMap,wwt=new WeakMap,xwt=new WeakMap,Awt=new WeakMap,_wt=new WeakMap,kwt=new WeakMap,Swt=new WeakMap,Ewt=new WeakMap,Mwt=new WeakMap,Twt=new WeakMap,Cwt=new WeakMap,Pwt=new WeakMap,Iwt=new WeakMap,Rwt=new WeakMap,Owt=new WeakSet;class Lwt extends kdt{static get _keyboardManager(){var t=Lwt.prototype;return Ilt(this,"_keyboardManager",new ict([[["ArrowLeft","mac+ArrowLeft"],t._moveCaret,{args:[0]}],[["ArrowRight","mac+ArrowRight"],t._moveCaret,{args:[1]}],[["ArrowUp","mac+ArrowUp"],t._moveCaret,{args:[2]}],[["ArrowDown","mac+ArrowDown"],t._moveCaret,{args:[3]}]]))}constructor(t){super(git(git({},t),{},{name:"highlightEditor"})),dit(this,Owt),hit(this,gwt,null),hit(this,vwt,0),hit(this,mwt,void 0),hit(this,ywt,null),hit(this,bwt,null),hit(this,wwt,null),hit(this,xwt,null),hit(this,Awt,0),hit(this,_wt,null),hit(this,kwt,null),hit(this,Swt,null),hit(this,Ewt,!1),hit(this,Mwt,null),hit(this,Twt,void 0),hit(this,Cwt,null),hit(this,Pwt,""),hit(this,Iwt,void 0),hit(this,Rwt,""),this.color=t.color||Lwt._defaultColor,cit(Iwt,this,t.thickness||Lwt._defaultThickness),cit(Twt,this,t.opacity||Lwt._defaultOpacity),cit(mwt,this,t.boxes||null),cit(Rwt,this,t.methodOfCreation||""),cit(Pwt,this,t.text||""),this._isDraggable=!1,t.highlightId>-1?(cit(Ewt,this,!0),iit(Owt,this,Fwt).call(this,t),iit(Owt,this,Wwt).call(this)):lit(mwt,this)&&(cit(gwt,this,t.anchorNode),cit(vwt,this,t.anchorOffset),cit(xwt,this,t.focusNode),cit(Awt,this,t.focusOffset),iit(Owt,this,Dwt).call(this),iit(Owt,this,Wwt).call(this),this.rotate(this.rotation))}get telemetryInitialData(){return{action:"added",type:lit(Ewt,this)?"free_highlight":"highlight",color:this._uiManager.highlightColorNames.get(this.color),thickness:lit(Iwt,this),methodOfCreation:lit(Rwt,this)}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.highlightColorNames.get(this.color)}}static computeTelemetryFinalData(t){return{numberOfColors:t.get("color").size}}static initialize(t,e){var r;kdt.initialize(t,e),Lwt._defaultColor||(Lwt._defaultColor=(null===(r=e.highlightColors)||void 0===r?void 0:r.values().next().value)||"#fff066")}static updateDefaultParams(t,e){switch(t){case Uot.HIGHLIGHT_DEFAULT_COLOR:Lwt._defaultColor=e;break;case Uot.HIGHLIGHT_THICKNESS:Lwt._defaultThickness=e}}translateInPage(t,e){}get toolbarPosition(){return lit(Mwt,this)}updateParams(t,e){switch(t){case Uot.HIGHLIGHT_COLOR:iit(Owt,this,Nwt).call(this,e);break;case Uot.HIGHLIGHT_THICKNESS:iit(Owt,this,jwt).call(this,e)}}static get defaultPropertiesToUpdate(){return[[Uot.HIGHLIGHT_DEFAULT_COLOR,Lwt._defaultColor],[Uot.HIGHLIGHT_THICKNESS,Lwt._defaultThickness]]}get propertiesToUpdate(){return[[Uot.HIGHLIGHT_COLOR,this.color||Lwt._defaultColor],[Uot.HIGHLIGHT_THICKNESS,lit(Iwt,this)||Lwt._defaultThickness],[Uot.HIGHLIGHT_FREE,lit(Ewt,this)]]}addEditToolbar(){var t=()=>super.addEditToolbar,e=this;return sit((function*(){var r=yield t().call(e);return r?(e._uiManager.highlightColors&&(cit(bwt,e,new owt({editor:e})),r.addColorPicker(lit(bwt,e))),r):null}))()}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(iit(Owt,this,Ywt).call(this))}getBaseTranslation(){return[0,0]}getRect(t,e){return super.getRect(t,e,iit(Owt,this,Ywt).call(this))}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),t&&this.div.focus()}remove(){iit(Owt,this,zwt).call(this),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(iit(Owt,this,Wwt).call(this),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){var e=!1;if(this.parent&&!t)iit(Owt,this,zwt).call(this);else if(t){var r;iit(Owt,this,Wwt).call(this,t),e=!this.parent&&(null===(r=this.div)||void 0===r?void 0:r.classList.contains("selectedEditor"))}super.setParent(t),this.show(this._isVisible),e&&this.select()}rotate(t){var e,{drawLayer:r}=this.parent;lit(Ewt,this)?(t=(t-this.rotation+360)%360,e=Uwt.call(Lwt,lit(kwt,this).box,t)):e=Uwt.call(Lwt,[this.x,this.y,this.width,this.height],t),r.updateProperties(lit(Swt,this),{bbox:e,root:{"data-main-rotation":t}}),r.updateProperties(lit(Cwt,this),{bbox:Uwt.call(Lwt,lit(wwt,this).box,t),root:{"data-main-rotation":t}})}render(){if(this.div)return this.div;var t=super.render();lit(Pwt,this)&&(t.setAttribute("aria-label",lit(Pwt,this)),t.setAttribute("role","mark")),lit(Ewt,this)?t.classList.add("free"):this.div.addEventListener("keydown",iit(Owt,this,Hwt).bind(this),{signal:this._uiManager._signal});var e=cit(_wt,this,document.createElement("div"));t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal",e.style.clipPath=lit(ywt,this);var[r,n]=this.parentDimensions;return this.setDims(this.width*r,this.height*n),Uht(this,lit(_wt,this),["pointerover","pointerleave"]),this.enableEditing(),t}pointerover(){var t;this.isSelected||(null===(t=this.parent)||void 0===t||t.drawLayer.updateProperties(lit(Cwt,this),{rootClass:{hovered:!0}}))}pointerleave(){var t;this.isSelected||(null===(t=this.parent)||void 0===t||t.drawLayer.updateProperties(lit(Cwt,this),{rootClass:{hovered:!1}}))}_moveCaret(t){switch(this.parent.unselect(this),t){case 0:case 2:iit(Owt,this,Gwt).call(this,!0);break;case 1:case 3:iit(Owt,this,Gwt).call(this,!1)}}select(){var t;super.select(),lit(Cwt,this)&&(null===(t=this.parent)||void 0===t||t.drawLayer.updateProperties(lit(Cwt,this),{rootClass:{hovered:!1,selected:!0}}))}unselect(){var t;super.unselect(),lit(Cwt,this)&&(null===(t=this.parent)||void 0===t||t.drawLayer.updateProperties(lit(Cwt,this),{rootClass:{selected:!1}}),lit(Ewt,this)||iit(Owt,this,Gwt).call(this,!1))}get _mustFixPosition(){return!lit(Ewt,this)}show(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this._isVisible;super.show(t),this.parent&&(this.parent.drawLayer.updateProperties(lit(Swt,this),{rootClass:{hidden:!t}}),this.parent.drawLayer.updateProperties(lit(Cwt,this),{rootClass:{hidden:!t}}))}static startHighlighting(t,e,r){var{target:n,x:i,y:a}=r,{x:s,y:o,width:l,height:h}=n.getBoundingClientRect(),c=new AbortController,u=t.combinedSignal(c),d=e=>{c.abort(),iit(Lwt,this,$wt).call(this,t,e)};window.addEventListener("blur",d,{signal:u}),window.addEventListener("pointerup",d,{signal:u}),window.addEventListener("pointerdown",uht,{capture:!0,passive:!1,signal:u}),window.addEventListener("contextmenu",cht,{signal:u}),n.addEventListener("pointermove",iit(Lwt,this,Xwt).bind(this,t),{signal:u}),this._freeHighlight=new qbt({x:i,y:a},[s,o,l,h],t.scale,this._defaultThickness/2,e,.001),({id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=t.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:this._defaultColor,"fill-opacity":this._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:this._freeHighlight.toSVGPath()}},!0,!0))}static deserialize(t,e,r){var n=()=>super.deserialize,i=this;return sit((function*(){var a=null;if(t instanceof myt){var{data:{quadPoints:s,rect:o,rotation:l,id:h,color:c,opacity:u,popupRef:d},parent:{page:{pageNumber:p}}}=t;a=t={annotationType:Wot.HIGHLIGHT,color:Array.from(c),opacity:u,quadPoints:s,boxes:null,pageIndex:p-1,rect:o.slice(0),rotation:l,id:h,deleted:!1,popupRef:d}}else if(t instanceof gyt){var{data:{inkLists:f,rect:g,rotation:v,id:m,color:y,borderStyle:{rawWidth:b},popupRef:w},parent:{page:{pageNumber:x}}}=t;a=t={annotationType:Wot.HIGHLIGHT,color:Array.from(y),thickness:b,inkLists:f,boxes:null,pageIndex:x-1,rect:g.slice(0),rotation:v,id:m,deleted:!1,popupRef:w}}var{color:A,quadPoints:_,inkLists:k,opacity:S}=t,E=yield n().call(i,t,e,r);E.color=Ylt.makeHexColor(...A),cit(Twt,E,S||1),k&&cit(Iwt,E,t.thickness),E.annotationElementId=t.id||null,E._initialData=a;var[M,T]=E.pageDimensions,[C,P]=E.pageTranslation;if(_){for(var I=cit(mwt,E,[]),R=0;R<_.length;R+=8)I.push({x:(_[R]-C)/M,y:1-(_[R+1]-P)/T,width:(_[R+2]-_[R])/M,height:(_[R+1]-_[R+5])/T});iit(Owt,E,Dwt).call(E),iit(Owt,E,Wwt).call(E),E.rotate(E.rotation)}else if(k){cit(Ewt,E,!0);for(var O=k[0],L={x:O[0]-C,y:T-(O[1]-P)},D=new qbt(L,[0,0,M,T],1,lit(Iwt,E)/2,!0,.001),F=0,N=O.length;F<N;F+=2)L.x=O[F]-C,L.y=T-(O[F+1]-P),D.add(L);var{id:j,clipPathId:B}=e.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:E.color,"fill-opacity":E._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:D.toSVGPath()}},!0,!0);iit(Owt,E,Fwt).call(E,{highlightOutlines:D.getOutlines(),highlightId:j,clipPathId:B}),iit(Owt,E,Wwt).call(E)}return E}))()}serialize(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(this.isEmpty()||t)return null;if(this.deleted)return this.serializeDeleted();var e=this.getRect(0,0),r=kdt._colorManager.convert(this.color),n={annotationType:Wot.HIGHLIGHT,color:r,opacity:lit(Twt,this),thickness:lit(Iwt,this),quadPoints:iit(Owt,this,Vwt).call(this),outlines:iit(Owt,this,qwt).call(this,e),pageIndex:this.pageIndex,rect:e,rotation:iit(Owt,this,Ywt).call(this),structTreeParentId:this._structTreeParentId};return this.annotationElementId&&!iit(Owt,this,Kwt).call(this,n)?null:(n.id=this.annotationElementId,n)}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}}function Dwt(){var t=new jbt(lit(mwt,this),.001);cit(kwt,this,t.getOutlines()),[this.x,this.y,this.width,this.height]=lit(kwt,this).box;var e=new jbt(lit(mwt,this),.0025,.001,"ltr"===this._uiManager.direction);cit(wwt,this,e.getOutlines());var{lastPoint:r}=lit(wwt,this);cit(Mwt,this,[(r[0]-this.x)/this.width,(r[1]-this.y)/this.height])}function Fwt(t){var{highlightOutlines:e,highlightId:r,clipPathId:n}=t;cit(kwt,this,e);if(cit(wwt,this,e.getNewOutline(lit(Iwt,this)/2+1.5,.0025)),r>=0)cit(Swt,this,r),cit(ywt,this,n),this.parent.drawLayer.finalizeDraw(r,{bbox:e.box,path:{d:e.toSVGPath()}}),cit(Cwt,this,this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:lit(wwt,this).box,path:{d:lit(wwt,this).toSVGPath()}},!0));else if(this.parent){var i=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(lit(Swt,this),{bbox:Uwt.call(wot,lit(kwt,this).box,(i-this.rotation+360)%360),path:{d:e.toSVGPath()}}),this.parent.drawLayer.updateProperties(lit(Cwt,this),{bbox:Uwt.call(wot,lit(wwt,this).box,i),path:{d:lit(wwt,this).toSVGPath()}})}var[a,s,o,l]=e.box;switch(this.rotation){case 0:this.x=a,this.y=s,this.width=o,this.height=l;break;case 90:var[h,c]=this.parentDimensions;this.x=s,this.y=1-a,this.width=o*c/h,this.height=l*h/c;break;case 180:this.x=1-a,this.y=1-s,this.width=o,this.height=l;break;case 270:var[u,d]=this.parentDimensions;this.x=1-s,this.y=a,this.width=o*d/u,this.height=l*u/d}var{lastPoint:p}=lit(wwt,this);cit(Mwt,this,[(p[0]-a)/o,(p[1]-s)/l])}function Nwt(t){var e=(t,e)=>{var r,n;this.color=t,cit(Twt,this,e),null===(r=this.parent)||void 0===r||r.drawLayer.updateProperties(lit(Swt,this),{root:{fill:t,"fill-opacity":e}}),null===(n=lit(bwt,this))||void 0===n||n.updateColor(t)},r=this.color,n=lit(Twt,this);this.addCommands({cmd:e.bind(this,t,wot._defaultOpacity),undo:e.bind(this,r,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Uot.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.highlightColorNames.get(t)},!0)}function jwt(t){var e=lit(Iwt,this),r=t=>{cit(Iwt,this,t),iit(Owt,this,Bwt).call(this,t)};this.addCommands({cmd:r.bind(this,t),undo:r.bind(this,e),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Uot.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:t},!0)}function Bwt(t){if(lit(Ewt,this)){iit(Owt,this,Fwt).call(this,{highlightOutlines:lit(kwt,this).getNewOutline(t/2)}),this.fixAndSetPosition();var[e,r]=this.parentDimensions;this.setDims(this.width*e,this.height*r)}}function zwt(){null!==lit(Swt,this)&&this.parent&&(this.parent.drawLayer.remove(lit(Swt,this)),cit(Swt,this,null),this.parent.drawLayer.remove(lit(Cwt,this)),cit(Cwt,this,null))}function Wwt(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.parent;null===lit(Swt,this)&&(({id:vit(cit,[Swt,this])._,clipPathId:vit(cit,[ywt,this])._}=t.drawLayer.draw({bbox:lit(kwt,this).box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":lit(Twt,this)},rootClass:{highlight:!0,free:lit(Ewt,this)},path:{d:lit(kwt,this).toSVGPath()}},!1,!0)),cit(Cwt,this,t.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:lit(Ewt,this)},bbox:lit(wwt,this).box,path:{d:lit(wwt,this).toSVGPath()}},lit(Ewt,this))),lit(_wt,this)&&(lit(_wt,this).style.clipPath=lit(ywt,this)))}function Uwt(t,e){var[r,n,i,a]=t;switch(e){case 90:return[1-n-a,r,a,i];case 180:return[1-r-i,1-n-a,i,a];case 270:return[n,1-r-i,a,i]}return[r,n,i,a]}function Hwt(t){wot._keyboardManager.exec(this,t)}function Gwt(t){if(lit(gwt,this)){var e=window.getSelection();t?e.setPosition(lit(gwt,this),lit(vwt,this)):e.setPosition(lit(xwt,this),lit(Awt,this))}}function Ywt(){return lit(Ewt,this)?this.rotation:0}function Vwt(){if(lit(Ewt,this))return null;var[t,e]=this.pageDimensions,[r,n]=this.pageTranslation,i=lit(mwt,this),a=new Float32Array(8*i.length),s=0;for(var{x:o,y:l,width:h,height:c}of i){var u=o*t+r,d=(1-l)*e+n;a[s]=a[s+4]=u,a[s+1]=a[s+3]=d,a[s+2]=a[s+6]=u+h*t,a[s+5]=a[s+7]=d-c*e,s+=8}return a}function qwt(t){return lit(kwt,this).serialize(t,iit(Owt,this,Ywt).call(this))}function Xwt(t,e){this._freeHighlight.add(e)&&t.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})}function $wt(t,e){this._freeHighlight.isEmpty()?t.drawLayer.remove(this._freeHighlightId):t.createAndAddNewEditor(e,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""}function Kwt(t){var{color:e}=this._initialData;return t.color.some(((t,r)=>t!==e[r]))}wot=Lwt,pit(Lwt,"_defaultColor",null),pit(Lwt,"_defaultOpacity",1),pit(Lwt,"_defaultThickness",12),pit(Lwt,"_type","highlight"),pit(Lwt,"_editorType",Wot.HIGHLIGHT),pit(Lwt,"_freeHighlightId",-1),pit(Lwt,"_freeHighlight",null),pit(Lwt,"_freeHighlightClipId","");var Qwt=new WeakMap;class Jwt{constructor(){hit(this,Qwt,Object.create(null))}updateProperty(t,e){this[t]=e,this.updateSVGProperty(t,e)}updateProperties(t){if(t)for(var[e,r]of Object.entries(t))this.updateProperty(e,r)}updateSVGProperty(t,e){lit(Qwt,this)[t]=e}toSVGProperties(){var t=lit(Qwt,this);return cit(Qwt,this,Object.create(null)),{root:t}}reset(){cit(Qwt,this,Object.create(null))}updateAll(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this;this.updateProperties(t)}clone(){Tlt("Not implemented")}}var Zwt=new WeakMap,txt=new WeakMap,ext=new WeakSet;class rxt extends kdt{constructor(t){super(t),dit(this,ext),hit(this,Zwt,null),hit(this,txt,void 0),pit(this,"_drawId",null),cit(txt,this,t.mustBeCommitted||!1),t.drawOutlines&&(iit(ext,this,nxt).call(this,t),iit(ext,this,sxt).call(this))}static _mergeSVGProperties(t,e){var r=new Set(Object.keys(t));for(var[n,i]of Object.entries(e))r.has(n)?Object.assign(t[n],i):t[n]=i;return t}static getDefaultDrawingOptions(t){Tlt("Not implemented")}static get typesMap(){Tlt("Not implemented")}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(t,e){var r=this.typesMap.get(t);r&&this._defaultDrawingOptions.updateProperty(r,e),this._currentParent&&(uxt._.updateProperty(r,e),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(t,e){var r=this.constructor.typesMap.get(t);r&&this._updateProperty(t,r,e)}static get defaultPropertiesToUpdate(){var t=[],e=this._defaultDrawingOptions;for(var[r,n]of this.typesMap)t.push([r,e[n]]);return t}get propertiesToUpdate(){var t=[],{_drawingOptions:e}=this;for(var[r,n]of this.constructor.typesMap)t.push([r,e[n]]);return t}_updateProperty(t,e,r){var n=this._drawingOptions,i=n[e],a=t=>{var r;n.updateProperty(e,t);var i=lit(Zwt,this).updateProperty(e,t);i&&iit(ext,this,hxt).call(this,i),null===(r=this.parent)||void 0===r||r.drawLayer.updateProperties(this._drawId,n.toSVGProperties())};this.addCommands({cmd:a.bind(this,r),undo:a.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:t,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){var t;null===(t=this.parent)||void 0===t||t.drawLayer.updateProperties(this._drawId,rxt._mergeSVGProperties(lit(Zwt,this).getPathResizingSVGProperties(iit(ext,this,lxt).call(this)),{bbox:iit(ext,this,cxt).call(this)}))}_onResized(){var t;null===(t=this.parent)||void 0===t||t.drawLayer.updateProperties(this._drawId,rxt._mergeSVGProperties(lit(Zwt,this).getPathResizedSVGProperties(iit(ext,this,lxt).call(this)),{bbox:iit(ext,this,cxt).call(this)}))}_onTranslating(t,e){var r;null===(r=this.parent)||void 0===r||r.drawLayer.updateProperties(this._drawId,{bbox:iit(ext,this,cxt).call(this,t,e)})}_onTranslated(){var t;null===(t=this.parent)||void 0===t||t.drawLayer.updateProperties(this._drawId,rxt._mergeSVGProperties(lit(Zwt,this).getPathTranslatedSVGProperties(iit(ext,this,lxt).call(this),this.parentDimensions),{bbox:iit(ext,this,cxt).call(this)}))}_onStartDragging(){var t;null===(t=this.parent)||void 0===t||t.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){var t;null===(t=this.parent)||void 0===t||t.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!1}})}commit(){super.commit(),this.disableEditMode(),this.disableEditing()}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}getBaseTranslation(){return[0,0]}get isResizable(){return!0}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),this._isDraggable=!0,lit(txt,this)&&(cit(txt,this,!1),this.commit(),this.parent.setSelected(this),t&&this.isOnScreen&&this.div.focus())}remove(){iit(ext,this,axt).call(this),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(iit(ext,this,sxt).call(this),iit(ext,this,hxt).call(this,lit(Zwt,this).box),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){var e=!1;if(this.parent&&!t)this._uiManager.removeShouldRescale(this),iit(ext,this,axt).call(this);else if(t){var r;this._uiManager.addShouldRescale(this),iit(ext,this,sxt).call(this,t),e=!this.parent&&(null===(r=this.div)||void 0===r?void 0:r.classList.contains("selectedEditor"))}super.setParent(t),e&&this.select()}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,rxt._mergeSVGProperties({bbox:iit(ext,this,cxt).call(this)},lit(Zwt,this).updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&iit(ext,this,hxt).call(this,lit(Zwt,this).updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;var t=super.render();t.classList.add("draw");var e=document.createElement("div");t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal";var[r,n]=this.parentDimensions;return this.setDims(this.width*r,this.height*n),this._uiManager.addShouldRescale(this),this.disableEditing(),t}static createDrawerInstance(t,e,r,n,i){Tlt("Not implemented")}static startDrawing(t,e,r,n){var i,a,{target:s,offsetX:o,offsetY:l,pointerId:h,pointerType:c}=n;if(!gxt._||gxt._===c){var{viewport:{rotation:u}}=t,{width:d,height:p}=s.getBoundingClientRect(),f=dxt._=new AbortController,g=t.combinedSignal(f);fxt._||(fxt._=h),null!==(i=gxt._)&&void 0!==i||(gxt._=c),window.addEventListener("pointerup",(t=>{var e;fxt._===t.pointerId?this._endDraw(t):null===(e=vxt._)||void 0===e||e.delete(t.pointerId)}),{signal:g}),window.addEventListener("pointercancel",(t=>{var e;fxt._===t.pointerId?this._currentParent.endDrawingSession():null===(e=vxt._)||void 0===e||e.delete(t.pointerId)}),{signal:g}),window.addEventListener("pointerdown",(t=>{gxt._===t.pointerType&&((vxt._||(vxt._=new Set)).add(t.pointerId),uxt._.isCancellable()&&(uxt._.removeLastElement(),uxt._.isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))}),{capture:!0,passive:!1,signal:g}),window.addEventListener("contextmenu",cht,{signal:g}),s.addEventListener("pointermove",this._drawMove.bind(this),{signal:g}),s.addEventListener("touchmove",(t=>{t.timeStamp===mxt._&&uht(t)}),{signal:g}),t.toggleDrawing(),null===(a=e._editorUndoBar)||void 0===a||a.hide(),uxt._?t.drawLayer.updateProperties(this._currentDrawId,uxt._.startNew(o,l,d,p,u)):(e.updateUIForDefaultProperties(this),uxt._=this.createDrawerInstance(o,l,d,p,u),pxt._=this.getDefaultDrawingOptions(),this._currentParent=t,({id:this._currentDrawId}=t.drawLayer.draw(this._mergeSVGProperties(pxt._.toSVGProperties(),uxt._.defaultSVGProperties),!0,!1)))}}static _drawMove(t){var e;if(mxt._=-1,uxt._){var{offsetX:r,offsetY:n,pointerId:i}=t;fxt._===i&&((null===(e=vxt._)||void 0===e?void 0:e.size)>=1?this._endDraw(t):(this._currentParent.drawLayer.updateProperties(this._currentDrawId,uxt._.add(r,n)),mxt._=t.timeStamp,uht(t)))}}static _cleanup(t){t&&(this._currentDrawId=-1,this._currentParent=null,uxt._=null,pxt._=null,gxt._=null,mxt._=NaN),dxt._&&(dxt._.abort(),dxt._=null,fxt._=NaN,vxt._=null)}static _endDraw(t){var e=this._currentParent;if(e)if(e.toggleDrawing(!0),this._cleanup(!1),t&&e.drawLayer.updateProperties(this._currentDrawId,uxt._.end(t.offsetX,t.offsetY)),this.supportMultipleDrawings){var r=uxt._,n=this._currentDrawId,i=r.getLastElement();e.addCommands({cmd:()=>{e.drawLayer.updateProperties(n,r.setLastElement(i))},undo:()=>{e.drawLayer.updateProperties(n,r.removeLastElement())},mustExec:!1,type:Uot.DRAW_STEP})}else this.endDrawing(!1)}static endDrawing(t){var e=this._currentParent;if(!e)return null;if(e.toggleDrawing(!0),e.cleanUndoStack(Uot.DRAW_STEP),!uxt._.isEmpty()){var{pageDimensions:[r,n],scale:i}=e,a=e.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:uxt._.getOutlines(r*i,n*i,i,this._INNER_MARGIN),drawingOptions:pxt._,mustBeCommitted:!t});return this._cleanup(!0),a}return e.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(t){}static deserializeDraw(t,e,r,n,i,a){Tlt("Not implemented")}static deserialize(t,e,r){var n=()=>super.deserialize,i=this;return sit((function*(){var{rawDims:{pageWidth:a,pageHeight:s,pageX:o,pageY:l}}=e.viewport,h=i.deserializeDraw(o,l,a,s,i._INNER_MARGIN,t),c=yield n().call(i,t,e,r);return c.createDrawingOptions(t),iit(ext,c,nxt).call(c,{drawOutlines:h}),iit(ext,c,sxt).call(c),c.onScaleChanging(),c.rotate(),c}))()}serializeDraw(t){var[e,r]=this.pageTranslation,[n,i]=this.pageDimensions;return lit(Zwt,this).serialize([e,r,n,i],t)}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}}function nxt(t){var{drawOutlines:e,drawId:r,drawingOptions:n}=t;cit(Zwt,this,e),this._drawingOptions||(this._drawingOptions=n),r>=0?(this._drawId=r,this.parent.drawLayer.finalizeDraw(r,e.defaultProperties)):this._drawId=iit(ext,this,ixt).call(this,e,this.parent),iit(ext,this,hxt).call(this,e.box)}function ixt(t,e){var{id:r}=e.drawLayer.draw(xot._mergeSVGProperties(this._drawingOptions.toSVGProperties(),t.defaultSVGProperties),!1,!1);return r}function axt(){null!==this._drawId&&this.parent&&(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())}function sxt(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.parent;null!==this._drawId&&this.parent===t||(null===this._drawId?(this._drawingOptions.updateAll(),this._drawId=iit(ext,this,ixt).call(this,lit(Zwt,this),t)):this.parent.drawLayer.updateParent(this._drawId,t.drawLayer))}function oxt(t){var[e,r,n,i]=t,{parentDimensions:[a,s],rotation:o}=this;switch(o){case 90:return[r,1-e,n*(s/a),i*(a/s)];case 180:return[1-e,1-r,n,i];case 270:return[1-r,e,n*(s/a),i*(a/s)];default:return[e,r,n,i]}}function lxt(){var{x:t,y:e,width:r,height:n,parentDimensions:[i,a],rotation:s}=this;switch(s){case 90:return[1-e,t,r*(i/a),n*(a/i)];case 180:return[1-t,1-e,r,n];case 270:return[e,1-t,r*(i/a),n*(a/i)];default:return[t,e,r,n]}}function hxt(t){if([this.x,this.y,this.width,this.height]=iit(ext,this,oxt).call(this,t),this.div){this.fixAndSetPosition();var[e,r]=this.parentDimensions;this.setDims(this.width*e,this.height*r)}this._onResized()}function cxt(){var{x:t,y:e,width:r,height:n,rotation:i,parentRotation:a,parentDimensions:[s,o]}=this;switch((4*i+a)/90){case 1:return[1-e-n,t,n,r];case 2:return[1-t-r,1-e-n,r,n];case 3:return[e,1-t-r,n,r];case 4:return[t,e-r*(s/o),n*(o/s),r*(s/o)];case 5:return[1-e,t,r*(s/o),n*(o/s)];case 6:return[1-t-n*(o/s),1-e,n*(o/s),r*(s/o)];case 7:return[e-r*(s/o),1-t-n*(o/s),r*(s/o),n*(o/s)];case 8:return[t-r,e-n,r,n];case 9:return[1-e,t-r,n,r];case 10:return[1-t,1-e,r,n];case 11:return[e-n,1-t,n,r];case 12:return[t-n*(o/s),e,n*(o/s),r*(s/o)];case 13:return[1-e-r*(s/o),t-n*(o/s),r*(s/o),n*(o/s)];case 14:return[1-t,1-e-r*(s/o),n*(o/s),r*(s/o)];case 15:return[e,1-t,r*(s/o),n*(o/s)];default:return[t,e,r,n]}}xot=rxt,pit(rxt,"_currentDrawId",-1),pit(rxt,"_currentParent",null);var uxt={_:null},dxt={_:null},pxt={_:null},fxt={_:NaN},gxt={_:null},vxt={_:null},mxt={_:NaN};pit(rxt,"_INNER_MARGIN",3);var yxt=new WeakMap,bxt=new WeakMap,wxt=new WeakMap,xxt=new WeakMap,Axt=new WeakMap,_xt=new WeakMap,kxt=new WeakMap,Sxt=new WeakMap,Ext=new WeakMap,Mxt=new WeakMap,Txt=new WeakMap,Cxt=new WeakSet;class Pxt{constructor(t,e,r,n,i,a){dit(this,Cxt),hit(this,yxt,new Float64Array(6)),hit(this,bxt,void 0),hit(this,wxt,void 0),hit(this,xxt,void 0),hit(this,Axt,void 0),hit(this,_xt,void 0),hit(this,kxt,""),hit(this,Sxt,0),hit(this,Ext,new Uxt),hit(this,Mxt,void 0),hit(this,Txt,void 0),cit(Mxt,this,r),cit(Txt,this,n),cit(xxt,this,i),cit(Axt,this,a),[t,e]=iit(Cxt,this,Ixt).call(this,t,e);var s=cit(bxt,this,[NaN,NaN,NaN,NaN,t,e]);cit(_xt,this,[t,e]),cit(wxt,this,[{line:s,points:lit(_xt,this)}]),lit(yxt,this).set(s,0)}updateProperty(t,e){"stroke-width"===t&&cit(Axt,this,e)}isEmpty(){return!lit(wxt,this)||0===lit(wxt,this).length}isCancellable(){return lit(_xt,this).length<=10}add(t,e){[t,e]=iit(Cxt,this,Ixt).call(this,t,e);var[r,n,i,a]=lit(yxt,this).subarray(2,6),s=t-i,o=e-a;return Math.hypot(lit(Mxt,this)*s,lit(Txt,this)*o)<=2?null:(lit(_xt,this).push(t,e),isNaN(r)?(lit(yxt,this).set([i,a,t,e],2),lit(bxt,this).push(NaN,NaN,NaN,NaN,t,e),{path:{d:this.toSVGPath()}}):(isNaN(lit(yxt,this)[0])&&lit(bxt,this).splice(6,6),lit(yxt,this).set([r,n,i,a,t,e],0),lit(bxt,this).push(...Jyt.createBezierPoints(r,n,i,a,t,e)),{path:{d:this.toSVGPath()}}))}end(t,e){var r=this.add(t,e);return r||(2===lit(_xt,this).length?{path:{d:this.toSVGPath()}}:null)}startNew(t,e,r,n,i){cit(Mxt,this,r),cit(Txt,this,n),cit(xxt,this,i),[t,e]=iit(Cxt,this,Ixt).call(this,t,e);var a=cit(bxt,this,[NaN,NaN,NaN,NaN,t,e]);cit(_xt,this,[t,e]);var s=lit(wxt,this).at(-1);return s&&(s.line=new Float32Array(s.line),s.points=new Float32Array(s.points)),lit(wxt,this).push({line:a,points:lit(_xt,this)}),lit(yxt,this).set(a,0),cit(Sxt,this,0),this.toSVGPath(),null}getLastElement(){return lit(wxt,this).at(-1)}setLastElement(t){return lit(wxt,this)?(lit(wxt,this).push(t),cit(bxt,this,t.line),cit(_xt,this,t.points),cit(Sxt,this,0),{path:{d:this.toSVGPath()}}):lit(Ext,this).setLastElement(t)}removeLastElement(){if(!lit(wxt,this))return lit(Ext,this).removeLastElement();lit(wxt,this).pop(),cit(kxt,this,"");for(var t=0,e=lit(wxt,this).length;t<e;t++){var{line:r,points:n}=lit(wxt,this)[t];cit(bxt,this,r),cit(_xt,this,n),cit(Sxt,this,0),this.toSVGPath()}return{path:{d:lit(kxt,this)}}}toSVGPath(){var t=Jyt.svgRound(lit(bxt,this)[4]),e=Jyt.svgRound(lit(bxt,this)[5]);if(2===lit(_xt,this).length)return cit(kxt,this,"".concat(lit(kxt,this)," M ").concat(t," ").concat(e," Z")),lit(kxt,this);if(lit(_xt,this).length<=6){var r=lit(kxt,this).lastIndexOf("M");cit(kxt,this,"".concat(lit(kxt,this).slice(0,r)," M ").concat(t," ").concat(e)),cit(Sxt,this,6)}if(4===lit(_xt,this).length){var n=Jyt.svgRound(lit(bxt,this)[10]),i=Jyt.svgRound(lit(bxt,this)[11]);return cit(kxt,this,"".concat(lit(kxt,this)," L ").concat(n," ").concat(i)),cit(Sxt,this,12),lit(kxt,this)}var a=[];0===lit(Sxt,this)&&(a.push("M ".concat(t," ").concat(e)),cit(Sxt,this,6));for(var s=lit(Sxt,this),o=lit(bxt,this).length;s<o;s+=6){var[l,h,c,u,d,p]=lit(bxt,this).slice(s,s+6).map(Jyt.svgRound);a.push("C".concat(l," ").concat(h," ").concat(c," ").concat(u," ").concat(d," ").concat(p))}return cit(kxt,this,lit(kxt,this)+a.join(" ")),cit(Sxt,this,lit(bxt,this).length),lit(kxt,this)}getOutlines(t,e,r,n){var i=lit(wxt,this).at(-1);return i.line=new Float32Array(i.line),i.points=new Float32Array(i.points),lit(Ext,this).build(lit(wxt,this),t,e,r,lit(xxt,this),lit(Axt,this),n),cit(yxt,this,null),cit(bxt,this,null),cit(wxt,this,null),cit(kxt,this,null),lit(Ext,this)}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}function Ixt(t,e){return Jyt._normalizePoint(t,e,lit(Mxt,this),lit(Txt,this),lit(xxt,this))}var Rxt=new WeakMap,Oxt=new WeakMap,Lxt=new WeakMap,Dxt=new WeakMap,Fxt=new WeakMap,Nxt=new WeakMap,jxt=new WeakMap,Bxt=new WeakMap,zxt=new WeakMap,Wxt=new WeakSet;class Uxt extends Jyt{constructor(){super(...arguments),dit(this,Wxt),hit(this,Rxt,void 0),hit(this,Oxt,0),hit(this,Lxt,void 0),hit(this,Dxt,void 0),hit(this,Fxt,void 0),hit(this,Nxt,void 0),hit(this,jxt,void 0),hit(this,Bxt,void 0),hit(this,zxt,void 0)}build(t,e,r,n,i,a,s){cit(Fxt,this,e),cit(Nxt,this,r),cit(jxt,this,n),cit(Bxt,this,i),cit(zxt,this,a),cit(Lxt,this,null!=s?s:0),cit(Dxt,this,t),iit(Wxt,this,Yxt).call(this)}setLastElement(t){return lit(Dxt,this).push(t),{path:{d:this.toSVGPath()}}}removeLastElement(){return lit(Dxt,this).pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){var t=[];for(var{line:e}of lit(Dxt,this))if(t.push("M".concat(Jyt.svgRound(e[4])," ").concat(Jyt.svgRound(e[5]))),6!==e.length)if(12!==e.length)for(var r=6,n=e.length;r<n;r+=6){var[i,a,s,o,l,h]=e.subarray(r,r+6).map(Jyt.svgRound);t.push("C".concat(i," ").concat(a," ").concat(s," ").concat(o," ").concat(l," ").concat(h))}else t.push("L".concat(Jyt.svgRound(e[10])," ").concat(Jyt.svgRound(e[11])));else t.push("Z");return t.join("")}serialize(t,e){var r,n,i,a,s,o,l,h,c,[u,d,p,f]=t,g=[],v=[],[m,y,b,w]=iit(Wxt,this,Gxt).call(this);switch(lit(Bxt,this)){case 0:c=Jyt._rescale,r=u,n=d+f,i=p,a=-f,s=u+m*p,o=d+(1-y-w)*f,l=u+(m+b)*p,h=d+(1-y)*f;break;case 90:c=Jyt._rescaleAndSwap,r=u,n=d,i=p,a=f,s=u+y*p,o=d+m*f,l=u+(y+w)*p,h=d+(m+b)*f;break;case 180:c=Jyt._rescale,r=u+p,n=d,i=-p,a=f,s=u+(1-m-b)*p,o=d+y*f,l=u+(1-m)*p,h=d+(y+w)*f;break;case 270:c=Jyt._rescaleAndSwap,r=u+p,n=d+f,i=-p,a=-f,s=u+(1-y-w)*p,o=d+(1-m-b)*f,l=u+(1-y)*p,h=d+(1-m)*f}for(var{line:x,points:A}of lit(Dxt,this))g.push(c(x,r,n,i,a,e?new Array(x.length):null)),v.push(c(A,r,n,i,a,e?new Array(A.length):null));return{lines:g,points:v,rect:[s,o,l,h]}}static deserialize(t,e,r,n,i,a){var s,o,l,h,c,{paths:{lines:u,points:d},rotation:p,thickness:f}=a,g=[];switch(p){case 0:c=Jyt._rescale,s=-t/r,o=e/n+1,l=1/r,h=-1/n;break;case 90:c=Jyt._rescaleAndSwap,s=-e/n,o=-t/r,l=1/n,h=1/r;break;case 180:c=Jyt._rescale,s=t/r+1,o=-e/n,l=-1/r,h=1/n;break;case 270:c=Jyt._rescaleAndSwap,s=e/n+1,o=t/r+1,l=-1/n,h=-1/r}if(!u)for(var v of(u=[],d)){var m=v.length;if(2!==m)if(4!==m){var y=new Float32Array(3*(m-2));u.push(y);var[b,w,x,A]=v.subarray(0,4);y.set([NaN,NaN,NaN,NaN,b,w],0);for(var _=4;_<m;_+=2){var k=v[_],S=v[_+1];y.set(Jyt.createBezierPoints(b,w,x,A,k,S),3*(_-2)),[b,w,x,A]=[x,A,k,S]}}else u.push(new Float32Array([NaN,NaN,NaN,NaN,v[0],v[1],NaN,NaN,NaN,NaN,v[2],v[3]]));else u.push(new Float32Array([NaN,NaN,NaN,NaN,v[0],v[1]]))}for(var E=0,M=u.length;E<M;E++)g.push({line:c(u[E].map((t=>null!=t?t:NaN)),s,o,l,h),points:c(d[E].map((t=>null!=t?t:NaN)),s,o,l,h)});var T=new Uxt;return T.build(g,r,n,1,p,f,i),T}get box(){return lit(Rxt,this)}updateProperty(t,e){return"stroke-width"===t?iit(Wxt,this,Vxt).call(this,e):null}updateParentDimensions(t,e){var[r,n]=t,[i,a]=iit(Wxt,this,Hxt).call(this);cit(Fxt,this,r),cit(Nxt,this,n),cit(jxt,this,e);var[s,o]=iit(Wxt,this,Hxt).call(this),l=s-i,h=o-a,c=lit(Rxt,this);return c[0]-=l,c[1]-=h,c[2]+=2*l,c[3]+=2*h,c}updateRotation(t){return cit(Oxt,this,t),{path:{transform:this.rotationTransform}}}get viewBox(){return lit(Rxt,this).map(Jyt.svgRound).join(" ")}get defaultProperties(){var[t,e]=lit(Rxt,this);return{root:{viewBox:this.viewBox},path:{"transform-origin":"".concat(Jyt.svgRound(t)," ").concat(Jyt.svgRound(e))}}}get rotationTransform(){var[,,t,e]=lit(Rxt,this),r=0,n=0,i=0,a=0,s=0,o=0;switch(lit(Oxt,this)){case 90:n=e/t,i=-t/e,s=t;break;case 180:r=-1,a=-1,s=t,o=e;break;case 270:n=-e/t,i=t/e,o=e;break;default:return""}return"matrix(".concat(r," ").concat(n," ").concat(i," ").concat(a," ").concat(Jyt.svgRound(s)," ").concat(Jyt.svgRound(o),")")}getPathResizingSVGProperties(t){var[e,r,n,i]=t,[a,s]=iit(Wxt,this,Hxt).call(this),[o,l,h,c]=lit(Rxt,this);if(Math.abs(h-a)<=Jyt.PRECISION||Math.abs(c-s)<=Jyt.PRECISION){var u=e+n/2-(o+h/2),d=r+i/2-(l+c/2);return{path:{"transform-origin":"".concat(Jyt.svgRound(e)," ").concat(Jyt.svgRound(r)),transform:"".concat(this.rotationTransform," translate(").concat(u," ").concat(d,")")}}}var p=(n-2*a)/(h-2*a),f=(i-2*s)/(c-2*s),g=h/n,v=c/i;return{path:{"transform-origin":"".concat(Jyt.svgRound(o)," ").concat(Jyt.svgRound(l)),transform:"".concat(this.rotationTransform," scale(").concat(g," ").concat(v,") ")+"translate(".concat(Jyt.svgRound(a)," ").concat(Jyt.svgRound(s),") scale(").concat(p," ").concat(f,") ")+"translate(".concat(Jyt.svgRound(-a)," ").concat(Jyt.svgRound(-s),")")}}}getPathResizedSVGProperties(t){var[e,r,n,i]=t,[a,s]=iit(Wxt,this,Hxt).call(this),o=lit(Rxt,this),[l,h,c,u]=o;if(o[0]=e,o[1]=r,o[2]=n,o[3]=i,Math.abs(c-a)<=Jyt.PRECISION||Math.abs(u-s)<=Jyt.PRECISION){var d=e+n/2-(l+c/2),p=r+i/2-(h+u/2);for(var{line:f,points:g}of lit(Dxt,this))Jyt._translate(f,d,p,f),Jyt._translate(g,d,p,g);return{root:{viewBox:this.viewBox},path:{"transform-origin":"".concat(Jyt.svgRound(e)," ").concat(Jyt.svgRound(r)),transform:this.rotationTransform||null,d:this.toSVGPath()}}}var v=(n-2*a)/(c-2*a),m=(i-2*s)/(u-2*s),y=-v*(l+a)+e+a,b=-m*(h+s)+r+s;if(1!==v||1!==m||0!==y||0!==b)for(var{line:w,points:x}of lit(Dxt,this))Jyt._rescale(w,y,b,v,m,w),Jyt._rescale(x,y,b,v,m,x);return{root:{viewBox:this.viewBox},path:{"transform-origin":"".concat(Jyt.svgRound(e)," ").concat(Jyt.svgRound(r)),transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties(t,e){var[r,n]=t,[i,a]=e,s=lit(Rxt,this),o=r-s[0],l=n-s[1];if(lit(Fxt,this)===i&&lit(Nxt,this)===a)for(var{line:h,points:c}of lit(Dxt,this))Jyt._translate(h,o,l,h),Jyt._translate(c,o,l,c);else{var u=lit(Fxt,this)/i,d=lit(Nxt,this)/a;for(var{line:p,points:f}of(cit(Fxt,this,i),cit(Nxt,this,a),lit(Dxt,this)))Jyt._rescale(p,o,l,u,d,p),Jyt._rescale(f,o,l,u,d,f);s[2]*=u,s[3]*=d}return s[0]=r,s[1]=n,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":"".concat(Jyt.svgRound(r)," ").concat(Jyt.svgRound(n))}}}get defaultSVGProperties(){var t=lit(Rxt,this);return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":"".concat(Jyt.svgRound(t[0])," ").concat(Jyt.svgRound(t[1])),transform:this.rotationTransform||null},bbox:t}}}function Hxt(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:lit(zxt,this),e=lit(Lxt,this)+t/2*lit(jxt,this);return lit(Bxt,this)%180==0?[e/lit(Fxt,this),e/lit(Nxt,this)]:[e/lit(Nxt,this),e/lit(Fxt,this)]}function Gxt(){var[t,e,r,n]=lit(Rxt,this),[i,a]=iit(Wxt,this,Hxt).call(this,0);return[t+i,e+a,r-2*i,n-2*a]}function Yxt(){var t=cit(Rxt,this,new Float32Array([1/0,1/0,-1/0,-1/0]));for(var{line:e}of lit(Dxt,this))if(e.length<=12)for(var r=4,n=e.length;r<n;r+=6){var[i,a]=e.subarray(r,r+2);t[0]=Math.min(t[0],i),t[1]=Math.min(t[1],a),t[2]=Math.max(t[2],i),t[3]=Math.max(t[3],a)}else for(var s=e[4],o=e[5],l=6,h=e.length;l<h;l+=6){var[c,u,d,p,f,g]=e.subarray(l,l+6);Ylt.bezierBoundingBox(s,o,c,u,d,p,f,g,t),s=f,o=g}var[v,m]=iit(Wxt,this,Hxt).call(this);t[0]=Math.min(1,Math.max(0,t[0]-v)),t[1]=Math.min(1,Math.max(0,t[1]-m)),t[2]=Math.min(1,Math.max(0,t[2]+v)),t[3]=Math.min(1,Math.max(0,t[3]+m)),t[2]-=t[0],t[3]-=t[1]}function Vxt(t){var[e,r]=iit(Wxt,this,Hxt).call(this);cit(zxt,this,t);var[n,i]=iit(Wxt,this,Hxt).call(this),[a,s]=[n-e,i-r],o=lit(Rxt,this);return o[0]-=a,o[1]-=s,o[2]+=2*a,o[3]+=2*s,o}var qxt=new WeakMap;class Xxt extends Jwt{constructor(t){super(),hit(this,qxt,void 0),cit(qxt,this,t),super.updateProperties({fill:"none",stroke:kdt._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(t,e){"stroke-width"===t&&(null!=e||(e=this["stroke-width"]),e*=lit(qxt,this).realScale),super.updateSVGProperty(t,e)}clone(){var t=new Xxt(lit(qxt,this));return t.updateAll(this),t}}var $xt=new WeakSet;class Kxt extends rxt{constructor(t){super(git(git({},t),{},{name:"inkEditor"})),dit(this,$xt),this._willKeepAspectRatio=!0}static initialize(t,e){kdt.initialize(t,e),this._defaultDrawingOptions=new Xxt(e.viewParameters)}static getDefaultDrawingOptions(t){var e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!0}static get typesMap(){return Ilt(this,"typesMap",new Map([[Uot.INK_THICKNESS,"stroke-width"],[Uot.INK_COLOR,"stroke"],[Uot.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(t,e,r,n,i){return new Pxt(t,e,r,n,i,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(t,e,r,n,i,a){return Uxt.deserialize(t,e,r,n,i,a)}static deserialize(t,e,r){var n=()=>super.deserialize,i=this;return sit((function*(){var a=null;if(t instanceof gyt){var{data:{inkLists:s,rect:o,rotation:l,id:h,color:c,opacity:u,borderStyle:{rawWidth:d},popupRef:p},parent:{page:{pageNumber:f}}}=t;a=t={annotationType:Wot.INK,color:Array.from(c),thickness:d,opacity:u,paths:{points:s},boxes:null,pageIndex:f-1,rect:o.slice(0),rotation:l,id:h,deleted:!1,popupRef:p}}var g=yield n().call(i,t,e,r);return g.annotationElementId=t.id||null,g._initialData=a,g}))()}onScaleChanging(){if(this.parent){super.onScaleChanging();var{_drawId:t,_drawingOptions:e,parent:r}=this;e.updateSVGProperty("stroke-width"),r.drawLayer.updateProperties(t,e.toSVGProperties())}}static onScaleChangingWhenDrawing(){var t=this._currentParent;t&&(super.onScaleChangingWhenDrawing(),this._defaultDrawingOptions.updateSVGProperty("stroke-width"),t.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}createDrawingOptions(t){var{color:e,thickness:r,opacity:n}=t;this._drawingOptions=Kxt.getDefaultDrawingOptions({stroke:Ylt.makeHexColor(...e),"stroke-width":r,"stroke-opacity":n})}serialize(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();var{lines:e,points:r,rect:n}=this.serializeDraw(t),{_drawingOptions:{stroke:i,"stroke-opacity":a,"stroke-width":s}}=this,o={annotationType:Wot.INK,color:kdt._colorManager.convert(i),opacity:a,thickness:s,paths:{lines:e,points:r},pageIndex:this.pageIndex,rect:n,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return t?o:this.annotationElementId&&!iit($xt,this,Qxt).call(this,o)?null:(o.id=this.annotationElementId,o)}renderAnnotationElement(t){var{points:e,rect:r}=this.serializeDraw(!1);return t.updateEdited({rect:r,thickness:this._drawingOptions["stroke-width"],points:e}),null}}function Qxt(t){var{color:e,thickness:r,opacity:n,pageIndex:i}=this._initialData;return this._hasBeenMoved||this._hasBeenResized||t.color.some(((t,r)=>t!==e[r]))||t.thickness!==r||t.opacity!==n||t.pageIndex!==i}pit(Kxt,"_type","ink"),pit(Kxt,"_editorType",Wot.INK),pit(Kxt,"_defaultDrawingOptions",null);var Jxt=new WeakMap,Zxt=new WeakMap,tAt=new WeakMap,eAt=new WeakMap,rAt=new WeakMap,nAt=new WeakMap,iAt=new WeakMap,aAt=new WeakMap,sAt=new WeakMap,oAt=new WeakMap,lAt=new WeakSet;class hAt extends kdt{constructor(t){super(git(git({},t),{},{name:"stampEditor"})),dit(this,lAt),hit(this,Jxt,null),hit(this,Zxt,null),hit(this,tAt,null),hit(this,eAt,null),hit(this,rAt,null),hit(this,nAt,""),hit(this,iAt,null),hit(this,aAt,null),hit(this,sAt,!1),hit(this,oAt,!1),cit(eAt,this,t.bitmapUrl),cit(rAt,this,t.bitmapFile)}static initialize(t,e){kdt.initialize(t,e)}static get supportedTypes(){return Ilt(this,"supportedTypes",["apng","avif","bmp","gif","jpeg","png","svg+xml","webp","x-icon"].map((t=>"image/".concat(t))))}static get supportedTypesStr(){return Ilt(this,"supportedTypesStr",this.supportedTypes.join(","))}static isHandlingMimeForPasting(t){return this.supportedTypes.includes(t)}static paste(t,e){e.pasteEditor(Wot.STAMP,{bitmapFile:t.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){var t;return{type:"stamp",hasAltText:!(null===(t=this.altTextData)||void 0===t||!t.altText)}}static computeTelemetryFinalData(t){var e,r,n=t.get("hasAltText");return{hasAltText:null!==(e=n.get(!0))&&void 0!==e?e:0,hasNoAltText:null!==(r=n.get(!1))&&void 0!==r?r:0}}mlGuessAltText(){var t=arguments,e=this;return sit((function*(){var r=t.length>0&&void 0!==t[0]?t[0]:null,n=!(t.length>1&&void 0!==t[1])||t[1];if(e.hasAltTextData())return null;var{mlManager:i}=e._uiManager;if(!i)throw new Error("No ML.");if(!(yield i.isEnabledFor("altText")))throw new Error("ML isn't enabled for alt text.");var{data:a,width:s,height:o}=r||e.copyCanvas(null,null,!0).imageData,l=yield i.guess({name:"altText",request:{data:a,width:s,height:o,channels:a.length/(s*o)}});if(!l)throw new Error("No response from the AI service.");if(l.error)throw new Error("Error from the AI service.");if(l.cancel)return null;if(!l.output)throw new Error("No valid response from the AI service.");var h=l.output;return yield e.setGuessedAltText(h),n&&!e.hasAltTextData()&&(e.altTextData={alt:h,decorative:!1}),h}))()}remove(){var t;lit(Zxt,this)&&(cit(Jxt,this,null),this._uiManager.imageManager.deleteId(lit(Zxt,this)),null===(t=lit(iAt,this))||void 0===t||t.remove(),cit(iAt,this,null),lit(aAt,this)&&(clearTimeout(lit(aAt,this)),cit(aAt,this,null)));super.remove()}rebuild(){this.parent?(super.rebuild(),null!==this.div&&(lit(Zxt,this)&&null===lit(iAt,this)&&iit(lAt,this,dAt).call(this),this.isAttachedToDOM||this.parent.add(this))):lit(Zxt,this)&&iit(lAt,this,dAt).call(this)}onceAdded(t){this._isDraggable=!0,t&&this.div.focus()}isEmpty(){return!(lit(tAt,this)||lit(Jxt,this)||lit(eAt,this)||lit(rAt,this)||lit(Zxt,this))}get isResizable(){return!0}render(){if(this.div)return this.div;var t,e;if(this.width&&(t=this.x,e=this.y),super.render(),this.div.hidden=!0,this.div.setAttribute("role","figure"),this.addAltTextButton(),lit(Jxt,this)?iit(lAt,this,pAt).call(this):iit(lAt,this,dAt).call(this),this.width&&!this.annotationElementId){var[r,n]=this.parentDimensions;this.setAt(t*r,e*n,this.width*r,this.height*n)}return this._uiManager.addShouldRescale(this),this.div}_onResized(){this.onScaleChanging()}onScaleChanging(){if(this.parent){null!==lit(aAt,this)&&clearTimeout(lit(aAt,this));cit(aAt,this,setTimeout((()=>{cit(aAt,this,null),iit(lAt,this,gAt).call(this)}),200))}}copyCanvas(t,e){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];t||(t=224);var{width:n,height:i}=lit(Jxt,this),a=new bht,s=lit(Jxt,this),o=n,l=i,h=null;if(e){var c,u;if(n>e||i>e){var d=Math.min(e/n,e/i);o=Math.floor(n*d),l=Math.floor(i*d)}var p=(h=document.createElement("canvas")).width=Math.ceil(o*a.sx),f=h.height=Math.ceil(l*a.sy);lit(sAt,this)||(s=iit(lAt,this,fAt).call(this,p,f));var g=h.getContext("2d");g.filter=this._uiManager.hcmFilter;var v="white",m="#cfcfd8";"none"!==this._uiManager.hcmFilter?m="black":null!==(c=(u=window).matchMedia)&&void 0!==c&&c.call(u,"(prefers-color-scheme: dark)").matches&&(v="#8f8f9d",m="#42414d");var y=15*a.sx,b=15*a.sy,w=new OffscreenCanvas(2*y,2*b),x=w.getContext("2d");x.fillStyle=v,x.fillRect(0,0,2*y,2*b),x.fillStyle=m,x.fillRect(0,0,y,b),x.fillRect(y,b,y,b),g.fillStyle=g.createPattern(w,"repeat"),g.fillRect(0,0,p,f),g.drawImage(s,0,0,s.width,s.height,0,0,p,f)}var A=null;if(r){var _,k;if(a.symmetric&&s.width<t&&s.height<t)_=s.width,k=s.height;else if(s=lit(Jxt,this),n>t||i>t){var S=Math.min(t/n,t/i);_=Math.floor(n*S),k=Math.floor(i*S),lit(sAt,this)||(s=iit(lAt,this,fAt).call(this,_,k))}var E=new OffscreenCanvas(_,k).getContext("2d",{willReadFrequently:!0});E.drawImage(s,0,0,s.width,s.height,0,0,_,k),A={width:_,height:k,data:E.getImageData(0,0,_,k).data}}return{canvas:h,width:o,height:l,imageData:A}}getImageForAltText(){return lit(iAt,this)}static deserialize(t,e,r){var n=()=>super.deserialize,i=this;return sit((function*(){var a=null;if(t instanceof xyt){var s,{data:{rect:o,rotation:l,id:h,structParent:c,popupRef:u},container:d,parent:{page:{pageNumber:p}}}=t,f=d.querySelector("canvas"),g=r.imageManager.getFromCanvas(d.id,f);f.remove();var v=(null===(s=yield e._structTree.getAriaAttributes("".concat(Qlt).concat(h)))||void 0===s?void 0:s.get("aria-label"))||"";a=t={annotationType:Wot.STAMP,bitmapId:g.id,bitmap:g.bitmap,pageIndex:p-1,rect:o.slice(0),rotation:l,id:h,deleted:!1,accessibilityData:{decorative:!1,altText:v},isSvg:!1,structParent:c,popupRef:u}}var m=yield n().call(i,t,e,r),{rect:y,bitmap:b,bitmapUrl:w,bitmapId:x,isSvg:A,accessibilityData:_}=t;x&&r.imageManager.isValidId(x)?(cit(Zxt,m,x),b&&cit(Jxt,m,b)):cit(eAt,m,w),cit(sAt,m,A);var[k,S]=m.pageDimensions;return m.width=(y[2]-y[0])/k,m.height=(y[3]-y[1])/S,m.annotationElementId=t.id||null,_&&(m.altTextData=_),m._initialData=a,cit(oAt,m,!!a),m}))()}serialize(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();var r={annotationType:Wot.STAMP,bitmapId:lit(Zxt,this),pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:lit(sAt,this),structTreeParentId:this._structTreeParentId};if(t)return r.bitmapUrl=iit(lAt,this,vAt).call(this,!0),r.accessibilityData=this.serializeAltText(!0),r;var{decorative:n,altText:i}=this.serializeAltText(!1);if(!n&&i&&(r.accessibilityData={type:"Figure",alt:i}),this.annotationElementId){var a,s=iit(lAt,this,mAt).call(this,r);if(s.isSame)return null;if(s.isSameAltText)delete r.accessibilityData;else r.accessibilityData.structParent=null!==(a=this._initialData.structParent)&&void 0!==a?a:-1}if(r.id=this.annotationElementId,null===e)return r;e.stamps||(e.stamps=new Map);var o=lit(sAt,this)?(r.rect[2]-r.rect[0])*(r.rect[3]-r.rect[1]):null;if(e.stamps.has(lit(Zxt,this))){if(lit(sAt,this)){var l=e.stamps.get(lit(Zxt,this));o>l.area&&(l.area=o,l.serialized.bitmap.close(),l.serialized.bitmap=iit(lAt,this,vAt).call(this,!1))}}else e.stamps.set(lit(Zxt,this),{area:o,serialized:r}),r.bitmap=iit(lAt,this,vAt).call(this,!1);return r}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}}function cAt(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];t?(cit(Jxt,this,t.bitmap),e||(cit(Zxt,this,t.id),cit(sAt,this,t.isSvg)),t.file&&cit(nAt,this,t.file.name),iit(lAt,this,pAt).call(this)):this.remove()}function uAt(){if(cit(tAt,this,null),this._uiManager.enableWaiting(!1),lit(iAt,this)){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&lit(Jxt,this))return this._editToolbar.hide(),void this._uiManager.editAltText(this,!0);if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&lit(Jxt,this)){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch(t){}}this.div.focus()}}function dAt(){var t=this;if(lit(Zxt,this))return this._uiManager.enableWaiting(!0),void this._uiManager.imageManager.getFromId(lit(Zxt,this)).then((t=>iit(lAt,this,cAt).call(this,t,!0))).finally((()=>iit(lAt,this,uAt).call(this)));if(lit(eAt,this)){var e=lit(eAt,this);return cit(eAt,this,null),this._uiManager.enableWaiting(!0),void cit(tAt,this,this._uiManager.imageManager.getFromUrl(e).then((t=>iit(lAt,this,cAt).call(this,t))).finally((()=>iit(lAt,this,uAt).call(this))))}if(lit(rAt,this)){var r=lit(rAt,this);return cit(rAt,this,null),this._uiManager.enableWaiting(!0),void cit(tAt,this,this._uiManager.imageManager.getFromFile(r).then((t=>iit(lAt,this,cAt).call(this,t))).finally((()=>iit(lAt,this,uAt).call(this))))}var n=document.createElement("input");n.type="file",n.accept=Aot.supportedTypesStr;var i=this._uiManager._signal;cit(tAt,this,new Promise((e=>{n.addEventListener("change",sit((function*(){if(n.files&&0!==n.files.length){t._uiManager.enableWaiting(!0);var r=yield t._uiManager.imageManager.getFromFile(n.files[0]);t._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:t._uiManager.useNewAltTextFlow}}),iit(lAt,t,cAt).call(t,r)}else t.remove();e()})),{signal:i}),n.addEventListener("cancel",(()=>{this.remove(),e()}),{signal:i})})).finally((()=>iit(lAt,this,uAt).call(this)))),n.click()}function pAt(){var t,{div:e}=this,{width:r,height:n}=lit(Jxt,this),[i,a]=this.pageDimensions,s=.75;if(this.width)r=this.width*i,n=this.height*a;else if(r>s*i||n>s*a){var o=Math.min(s*i/r,s*a/n);r*=o,n*=o}var[l,h]=this.parentDimensions;this.setDims(r*l/i,n*h/a),this._uiManager.enableWaiting(!1);var c=cit(iAt,this,document.createElement("canvas"));c.setAttribute("role","img"),this.addContainer(c),this.width=r/i,this.height=n/a,null!==(t=this._initialOptions)&&void 0!==t&&t.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&!this.annotationElementId||(e.hidden=!1),iit(lAt,this,gAt).call(this),lit(oAt,this)||(this.parent.addUndoableEditor(this),cit(oAt,this,!0)),this._reportTelemetry({action:"inserted_image"}),lit(nAt,this)&&c.setAttribute("aria-label",lit(nAt,this))}function fAt(t,e){for(var{width:r,height:n}=lit(Jxt,this),i=r,a=n,s=lit(Jxt,this);i>2*t||a>2*e;){var o=i,l=a;i>2*t&&(i=i>=16384?Math.floor(i/2)-1:Math.ceil(i/2)),a>2*e&&(a=a>=16384?Math.floor(a/2)-1:Math.ceil(a/2));var h=new OffscreenCanvas(i,a);h.getContext("2d").drawImage(s,0,0,o,l,0,0,i,a),s=h.transferToImageBitmap()}return s}function gAt(){var[t,e]=this.parentDimensions,{width:r,height:n}=this,i=new bht,a=Math.ceil(r*t*i.sx),s=Math.ceil(n*e*i.sy),o=lit(iAt,this);if(o&&(o.width!==a||o.height!==s)){o.width=a,o.height=s;var l=lit(sAt,this)?lit(Jxt,this):iit(lAt,this,fAt).call(this,a,s),h=o.getContext("2d");h.filter=this._uiManager.hcmFilter,h.drawImage(l,0,0,l.width,l.height,0,0,a,s)}}function vAt(t){if(t){if(lit(sAt,this)){var e=this._uiManager.imageManager.getSvgUrl(lit(Zxt,this));if(e)return e}var r=document.createElement("canvas");return({width:r.width,height:r.height}=lit(Jxt,this)),r.getContext("2d").drawImage(lit(Jxt,this),0,0),r.toDataURL()}if(lit(sAt,this)){var[n,i]=this.pageDimensions,a=Math.round(this.width*n*Zlt.PDF_TO_CSS_UNITS),s=Math.round(this.height*i*Zlt.PDF_TO_CSS_UNITS),o=new OffscreenCanvas(a,s);return o.getContext("2d").drawImage(lit(Jxt,this),0,0,lit(Jxt,this).width,lit(Jxt,this).height,0,0,a,s),o.transferToImageBitmap()}return structuredClone(lit(Jxt,this))}function mAt(t){var e,{pageIndex:r,accessibilityData:{altText:n}}=this._initialData,i=t.pageIndex===r,a=((null===(e=t.accessibilityData)||void 0===e?void 0:e.alt)||"")===n;return{isSame:!this._hasBeenMoved&&!this._hasBeenResized&&i&&a,isSameAltText:a}}Aot=hAt,pit(hAt,"_type","stamp"),pit(hAt,"_editorType",Wot.STAMP);var yAt=new WeakMap,bAt=new WeakMap,wAt=new WeakMap,xAt=new WeakMap,AAt=new WeakMap,_At=new WeakMap,kAt=new WeakMap,SAt=new WeakMap,EAt=new WeakMap,MAt=new WeakMap,TAt=new WeakMap,CAt=new WeakMap,PAt=new WeakMap,IAt=new WeakMap,RAt=new WeakSet;class OAt{constructor(t){var{uiManager:e,pageIndex:r,div:n,structTreeLayer:i,accessibilityManager:a,annotationLayer:s,drawLayer:o,textLayer:l,viewport:h,l10n:c}=t;dit(this,RAt),hit(this,yAt,void 0),hit(this,bAt,!1),hit(this,wAt,null),hit(this,xAt,null),hit(this,AAt,null),hit(this,_At,new Map),hit(this,kAt,!1),hit(this,SAt,!1),hit(this,EAt,!1),hit(this,MAt,null),hit(this,TAt,null),hit(this,CAt,null),hit(this,PAt,null),hit(this,IAt,void 0);var u=[...BAt._.values()];if(!OAt._initialized)for(var d of(OAt._initialized=!0,u))d.initialize(c,e);e.registerEditorTypes(u),cit(IAt,this,e),this.pageIndex=r,this.div=n,cit(yAt,this,a),cit(wAt,this,s),this.viewport=h,cit(CAt,this,l),this.drawLayer=o,this._structTree=i,lit(IAt,this).addLayer(this)}get isEmpty(){return 0===lit(_At,this).size}get isInvisible(){return this.isEmpty&&lit(IAt,this).getMode()===Wot.NONE}updateToolbar(t){lit(IAt,this).updateToolbar(t)}updateMode(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:lit(IAt,this).getMode();switch(iit(RAt,this,jAt).call(this),t){case Wot.NONE:return this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),void this.disableClick();case Wot.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case Wot.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);var{classList:e}=this.div;for(var r of BAt._.values())e.toggle("".concat(r._type,"Editing"),t===r._editorType);this.div.hidden=!1}hasTextLayer(t){var e;return t===(null===(e=lit(CAt,this))||void 0===e?void 0:e.div)}setEditingState(t){lit(IAt,this).setEditingState(t)}addCommands(t){lit(IAt,this).addCommands(t)}cleanUndoStack(t){lit(IAt,this).cleanUndoStack(t)}toggleDrawing(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.div.classList.toggle("drawing",!t)}togglePointerEvents(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(){var t,e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];null===(t=lit(wAt,this))||void 0===t||t.div.classList.toggle("disabled",!e)}enable(){var t=this;return sit((function*(){cit(EAt,t,!0),t.div.tabIndex=0,t.togglePointerEvents(!0);var e=new Set;for(var r of lit(_At,t).values())r.enableEditing(),r.show(!0),r.annotationElementId&&(lit(IAt,t).removeChangedExistingAnnotation(r),e.add(r.annotationElementId));if(lit(wAt,t)){var n=lit(wAt,t).getEditableAnnotations();for(var i of n)if(i.hide(),!lit(IAt,t).isDeletedAnnotationElement(i.data.id)&&!e.has(i.data.id)){var a=yield t.deserialize(i);a&&(t.addOrRebuild(a),a.enableEditing())}cit(EAt,t,!1)}else cit(EAt,t,!1)}))()}disable(){cit(SAt,this,!0),this.div.tabIndex=-1,this.togglePointerEvents(!1);var t=new Map,e=new Map;for(var r of lit(_At,this).values()){var n;r.disableEditing(),r.annotationElementId&&(null===r.serialize()?(e.set(r.annotationElementId,r),null===(n=this.getEditableAnnotation(r.annotationElementId))||void 0===n||n.show(),r.remove()):t.set(r.annotationElementId,r))}if(lit(wAt,this)){var i=lit(wAt,this).getEditableAnnotations();for(var a of i){var{id:s}=a.data;if(!lit(IAt,this).isDeletedAnnotationElement(s)){var o=e.get(s);o?(o.resetAnnotationElement(a),o.show(!1),a.show()):((o=t.get(s))&&(lit(IAt,this).addChangedExistingAnnotation(o),o.renderAnnotationElement(a)&&o.show(!1)),a.show())}}}iit(RAt,this,jAt).call(this),this.isEmpty&&(this.div.hidden=!0);var{classList:l}=this.div;for(var h of BAt._.values())l.remove("".concat(h._type,"Editing"));this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),cit(SAt,this,!1)}getEditableAnnotation(t){var e;return(null===(e=lit(wAt,this))||void 0===e?void 0:e.getEditableAnnotation(t))||null}setActiveEditor(t){lit(IAt,this).getActive()!==t&&lit(IAt,this).setActiveEditor(t)}enableTextSelection(){var t;if(this.div.tabIndex=-1,null!==(t=lit(CAt,this))&&void 0!==t&&t.div&&!lit(PAt,this)){cit(PAt,this,new AbortController);var e=lit(IAt,this).combinedSignal(lit(PAt,this));lit(CAt,this).div.addEventListener("pointerdown",iit(RAt,this,LAt).bind(this),{signal:e}),lit(CAt,this).div.classList.add("highlighting")}}disableTextSelection(){var t;this.div.tabIndex=0,null!==(t=lit(CAt,this))&&void 0!==t&&t.div&&lit(PAt,this)&&(lit(PAt,this).abort(),cit(PAt,this,null),lit(CAt,this).div.classList.remove("highlighting"))}enableClick(){if(!lit(xAt,this)){cit(xAt,this,new AbortController);var t=lit(IAt,this).combinedSignal(lit(xAt,this));this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:t});var e=this.pointerup.bind(this);this.div.addEventListener("pointerup",e,{signal:t}),this.div.addEventListener("pointercancel",e,{signal:t})}}disableClick(){var t;null===(t=lit(xAt,this))||void 0===t||t.abort(),cit(xAt,this,null)}attach(t){lit(_At,this).set(t.id,t);var{annotationElementId:e}=t;e&&lit(IAt,this).isDeletedAnnotationElement(e)&&lit(IAt,this).removeDeletedAnnotationElement(t)}detach(t){var e;lit(_At,this).delete(t.id),null===(e=lit(yAt,this))||void 0===e||e.removePointerInTextLayer(t.contentDiv),!lit(SAt,this)&&t.annotationElementId&&lit(IAt,this).addDeletedAnnotationElement(t)}remove(t){this.detach(t),lit(IAt,this).removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){var e;t.parent!==this&&(t.parent&&t.annotationElementId&&(lit(IAt,this).addDeletedAnnotationElement(t.annotationElementId),kdt.deleteAnnotationElement(t),t.annotationElementId=null),this.attach(t),null===(e=t.parent)||void 0===e||e.detach(t),t.setParent(this),t.div&&t.isAttachedToDOM&&(t.div.remove(),this.div.append(t.div)))}add(t){if(t.parent!==this||!t.isAttachedToDOM){if(this.changeParent(t),lit(IAt,this).addEditor(t),this.attach(t),!t.isAttachedToDOM){var e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(!lit(EAt,this)),lit(IAt,this).addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){var e;if(t.isAttachedToDOM){var{activeElement:r}=document;t.div.contains(r)&&!lit(AAt,this)&&(t._focusEventsAllowed=!1,cit(AAt,this,setTimeout((()=>{cit(AAt,this,null),t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",(()=>{t._focusEventsAllowed=!0}),{once:!0,signal:lit(IAt,this)._signal}),r.focus())}),0))),t._structTreeParentId=null===(e=lit(yAt,this))||void 0===e?void 0:e.moveElementInDOM(this.div,t.div,t.contentDiv,!0)}}addOrRebuild(t){t.needsToBeRebuilt()?(t.parent||(t.parent=this),t.rebuild(),t.show()):this.add(t)}addUndoableEditor(t){this.addCommands({cmd:()=>t._uiManager.rebuild(t),undo:()=>{t.remove()},mustExec:!1})}getNextId(){return lit(IAt,this).getId()}combinedSignal(t){return lit(IAt,this).combinedSignal(t)}canCreateNewEmptyEditor(){var t;return null===(t=uit(RAt,this,DAt))||void 0===t?void 0:t.canCreateNewEmptyEditor()}pasteEditor(t,e){lit(IAt,this).updateToolbar(t),lit(IAt,this).updateMode(t);var{offsetX:r,offsetY:n}=iit(RAt,this,NAt).call(this),i=this.getNextId(),a=iit(RAt,this,FAt).call(this,git({parent:this,id:i,x:r,y:n,uiManager:lit(IAt,this),isCentered:!0},e));a&&this.add(a)}deserialize(t){var e=this;return sit((function*(){var r,n;return(yield null===(r=BAt._.get(null!==(n=t.annotationType)&&void 0!==n?n:t.annotationEditorType))||void 0===r?void 0:r.deserialize(t,e,lit(IAt,e)))||null}))()}createAndAddNewEditor(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=this.getNextId(),i=iit(RAt,this,FAt).call(this,git({parent:this,id:n,x:t.offsetX,y:t.offsetY,uiManager:lit(IAt,this),isCentered:e},r));return i&&this.add(i),i}addNewEditor(){this.createAndAddNewEditor(iit(RAt,this,NAt).call(this),!0)}setSelected(t){lit(IAt,this).setSelected(t)}toggleSelected(t){lit(IAt,this).toggleSelected(t)}unselect(t){lit(IAt,this).unselect(t)}pointerup(t){var e,{isMac:r}=Hlt.platform;0!==t.button||t.ctrlKey&&r||t.target===this.div&&lit(kAt,this)&&(cit(kAt,this,!1),null!==(e=uit(RAt,this,DAt))&&void 0!==e&&e.isDrawer&&uit(RAt,this,DAt).supportMultipleDrawings||(lit(bAt,this)?lit(IAt,this).getMode()!==Wot.STAMP?this.createAndAddNewEditor(t,!1):lit(IAt,this).unselectAll():cit(bAt,this,!0)))}pointerdown(t){var e;if(lit(IAt,this).getMode()===Wot.HIGHLIGHT&&this.enableTextSelection(),lit(kAt,this))cit(kAt,this,!1);else{var{isMac:r}=Hlt.platform;if(!(0!==t.button||t.ctrlKey&&r)&&t.target===this.div)if(cit(kAt,this,!0),null!==(e=uit(RAt,this,DAt))&&void 0!==e&&e.isDrawer)this.startDrawingSession(t);else{var n=lit(IAt,this).getActive();cit(bAt,this,!n||n.isEmpty())}}}startDrawingSession(t){if(this.div.focus(),lit(MAt,this))uit(RAt,this,DAt).startDrawing(this,lit(IAt,this),!1,t);else{lit(IAt,this).setCurrentDrawingSession(this),cit(MAt,this,new AbortController);var e=lit(IAt,this).combinedSignal(lit(MAt,this));this.div.addEventListener("blur",(t=>{var{relatedTarget:e}=t;e&&!this.div.contains(e)&&(cit(TAt,this,null),this.commitOrRemove())}),{signal:e}),uit(RAt,this,DAt).startDrawing(this,lit(IAt,this),!1,t)}}pause(t){if(t){var{activeElement:e}=document;this.div.contains(e)&&cit(TAt,this,e)}else lit(TAt,this)&&setTimeout((()=>{var t;null===(t=lit(TAt,this))||void 0===t||t.focus(),cit(TAt,this,null)}),0)}endDrawingSession(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return lit(MAt,this)?(lit(IAt,this).setCurrentDrawingSession(null),lit(MAt,this).abort(),cit(MAt,this,null),cit(TAt,this,null),uit(RAt,this,DAt).endDrawing(t)):null}findNewParent(t,e,r){var n=lit(IAt,this).findParent(e,r);return null!==n&&n!==this&&(n.changeParent(t),!0)}commitOrRemove(){return!!lit(MAt,this)&&(this.endDrawingSession(),!0)}onScaleChanging(){lit(MAt,this)&&uit(RAt,this,DAt).onScaleChangingWhenDrawing(this)}destroy(){var t;for(var e of(this.commitOrRemove(),(null===(t=lit(IAt,this).getActive())||void 0===t?void 0:t.parent)===this&&(lit(IAt,this).commitOrRemove(),lit(IAt,this).setActiveEditor(null)),lit(AAt,this)&&(clearTimeout(lit(AAt,this)),cit(AAt,this,null)),lit(_At,this).values())){var r;null===(r=lit(yAt,this))||void 0===r||r.removePointerInTextLayer(e.contentDiv),e.setParent(null),e.isAttachedToDOM=!1,e.div.remove()}this.div=null,lit(_At,this).clear(),lit(IAt,this).removeLayer(this)}render(t){var{viewport:e}=t;for(var r of(this.viewport=e,yht(this.div,e),lit(IAt,this).getEditors(this.pageIndex)))this.add(r),r.rebuild();this.updateMode()}update(t){var{viewport:e}=t;lit(IAt,this).commitOrRemove(),iit(RAt,this,jAt).call(this);var r=this.viewport.rotation,n=e.rotation;if(this.viewport=e,yht(this.div,{rotation:n}),r!==n)for(var i of lit(_At,this).values())i.rotate(n)}get pageDimensions(){var{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return lit(IAt,this).viewParameters.realScale}}function LAt(t){lit(IAt,this).unselectAll();var{target:e}=t;if(e===lit(CAt,this).div||("img"===e.getAttribute("role")||e.classList.contains("endOfContent"))&&lit(CAt,this).div.contains(e)){var{isMac:r}=Hlt.platform;if(0!==t.button||t.ctrlKey&&r)return;lit(IAt,this).showAllEditors("highlight",!0,!0),lit(CAt,this).div.classList.add("free"),this.toggleDrawing(),Lwt.startHighlighting(this,"ltr"===lit(IAt,this).direction,{target:lit(CAt,this).div,x:t.x,y:t.y}),lit(CAt,this).div.addEventListener("pointerup",(()=>{lit(CAt,this).div.classList.remove("free"),this.toggleDrawing(!0)}),{once:!0,signal:lit(IAt,this)._signal}),t.preventDefault()}}function DAt(t){return BAt._.get(lit(IAt,t).getMode())}function FAt(t){var e=uit(RAt,this,DAt);return e?new e.prototype.constructor(t):null}function NAt(){var{x:t,y:e,width:r,height:n}=this.div.getBoundingClientRect(),i=Math.max(0,t),a=Math.max(0,e),s=(i+Math.min(window.innerWidth,t+r))/2-t,o=(a+Math.min(window.innerHeight,e+n))/2-e,[l,h]=this.viewport.rotation%180==0?[s,o]:[o,s];return{offsetX:l,offsetY:h}}function jAt(){for(var t of lit(_At,this).values())t.isEmpty()&&t.remove()}pit(OAt,"_initialized",!1);var BAt={_:new Map([Uyt,Kxt,hAt,Lwt].map((t=>[t._editorType,t])))},zAt=new WeakMap,WAt=new WeakMap,UAt=new WeakMap,HAt=new WeakMap,GAt=new WeakSet;class YAt{constructor(t){var{pageIndex:e}=t;dit(this,GAt),hit(this,zAt,null),hit(this,WAt,0),hit(this,UAt,new Map),hit(this,HAt,new Map),this.pageIndex=e}setParent(t){if(lit(zAt,this)){if(lit(zAt,this)!==t){if(lit(UAt,this).size>0)for(var e of lit(UAt,this).values())e.remove(),t.append(e);cit(zAt,this,t)}}else cit(zAt,this,t)}static get _svgFactory(){return Ilt(this,"_svgFactory",new Zvt)}draw(t){var e,r,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],a=(cit(WAt,this,(e=lit(WAt,this),r=e++,e)),r),s=iit(GAt,this,qAt).call(this),o=YAt._svgFactory.createElement("defs");s.append(o);var l=YAt._svgFactory.createElement("path");o.append(l);var h="path_p".concat(this.pageIndex,"_").concat(a);l.setAttribute("id",h),l.setAttribute("vector-effect","non-scaling-stroke"),n&&lit(HAt,this).set(a,l);var c=i?iit(GAt,this,XAt).call(this,o,h):null,u=YAt._svgFactory.createElement("use");return s.append(u),u.setAttribute("href","#".concat(h)),this.updateProperties(s,t),lit(UAt,this).set(a,s),{id:a,clipPathId:"url(#".concat(c,")")}}drawOutline(t,e){var r,n,i=(cit(WAt,this,(r=lit(WAt,this),n=r++,r)),n),a=iit(GAt,this,qAt).call(this),s=YAt._svgFactory.createElement("defs");a.append(s);var o=YAt._svgFactory.createElement("path");s.append(o);var l,h="path_p".concat(this.pageIndex,"_").concat(i);if(o.setAttribute("id",h),o.setAttribute("vector-effect","non-scaling-stroke"),e){var c=YAt._svgFactory.createElement("mask");s.append(c),l="mask_p".concat(this.pageIndex,"_").concat(i),c.setAttribute("id",l),c.setAttribute("maskUnits","objectBoundingBox");var u=YAt._svgFactory.createElement("rect");c.append(u),u.setAttribute("width","1"),u.setAttribute("height","1"),u.setAttribute("fill","white");var d=YAt._svgFactory.createElement("use");c.append(d),d.setAttribute("href","#".concat(h)),d.setAttribute("stroke","none"),d.setAttribute("fill","black"),d.setAttribute("fill-rule","nonzero"),d.classList.add("mask")}var p=YAt._svgFactory.createElement("use");a.append(p),p.setAttribute("href","#".concat(h)),l&&p.setAttribute("mask","url(#".concat(l,")"));var f=p.cloneNode();return a.append(f),p.classList.add("mainOutline"),f.classList.add("secondaryOutline"),this.updateProperties(a,t),lit(UAt,this).set(i,a),i}finalizeDraw(t,e){lit(HAt,this).delete(t),this.updateProperties(t,e)}updateProperties(t,e){if(e){var{root:r,bbox:n,rootClass:i,path:a}=e,s="number"==typeof t?lit(UAt,this).get(t):t;if(s){if(r&&iit(GAt,this,$At).call(this,s,r),n&&VAt.call(YAt,s,n),i){var{classList:o}=s;for(var[l,h]of Object.entries(i))o.toggle(l,h)}if(a){var c=s.firstChild.firstChild;iit(GAt,this,$At).call(this,c,a)}}}}updateParent(t,e){if(e!==this){var r=lit(UAt,this).get(t);r&&(lit(zAt,e).append(r),lit(UAt,this).delete(t),lit(UAt,e).set(t,r))}}remove(t){lit(HAt,this).delete(t),null!==lit(zAt,this)&&(lit(UAt,this).get(t).remove(),lit(UAt,this).delete(t))}destroy(){for(var t of(cit(zAt,this,null),lit(UAt,this).values()))t.remove();lit(UAt,this).clear(),lit(HAt,this).clear()}}function VAt(t,e){var[r,n,i,a]=e,{style:s}=t;s.top="".concat(100*n,"%"),s.left="".concat(100*r,"%"),s.width="".concat(100*i,"%"),s.height="".concat(100*a,"%")}function qAt(){var t=_ot._svgFactory.create(1,1,!0);return lit(zAt,this).append(t),t.setAttribute("aria-hidden",!0),t}function XAt(t,e){var r=_ot._svgFactory.createElement("clipPath");t.append(r);var n="clip_".concat(e);r.setAttribute("id",n),r.setAttribute("clipPathUnits","objectBoundingBox");var i=_ot._svgFactory.createElement("use");return r.append(i),i.setAttribute("href","#".concat(e)),i.classList.add("clip"),n}function $At(t,e){for(var[r,n]of Object.entries(e))null===n?t.removeAttribute(r):t.setAttribute(r,n)}_ot=YAt,globalThis.pdfjsTestingUtils={HighlightOutliner:jbt};var KAt=Mot.getDocument;Mot.GlobalWorkerOptions.workerSrc="/node_modules/pdfjs-dist/build/pdf.worker.min.mjs";const QAt={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"number",label:"round",name:"round",property:{min:0}},{type:"attachment-selector",label:"file",name:"file",property:{displayField:"fullpath",displayFullUrl:!0,storageFilters:{type:Array,value:[{name:"category",value:"application"}]},useUpload:!0}},{type:"number",label:"page",name:"page"},{type:"select",label:"fit",name:"fit",property:{options:["none","ratio","width","height"]}}],help:"scene/component/pdf-viewer"},JAt=[2,4,8,16,32],ZAt=16e3;class t_t extends(aet(net)){async ready(){this.scaleIndex=0,this.displayScale=1,this.offsetX=0,this.offsetY=0,this.pdfDoc=null,this.canvas=document.createElement("canvas"),this.renderTask=null,this.loadPDF()}dispose(){super.dispose(),this.worker&&(this.worker.terminate(),this.worker=null),this.renderTask&&this.renderTask.cancel(),this.pdfDoc=null,this.canvas=null}async loadPDF(){const{file:t,page:e=1}=this.state;if(t)try{console.log(`📌 Loading PDF: ${t}`),this.pdfDoc=await KAt(t).promise;const r=this.pdfDoc.numPages;this.page=await this.pdfDoc.getPage(e>r?1:e),this.documentSize=this.page.getViewport({scale:1}),this.fit()}catch(t){console.error("🚨 Failed to load PDF:",t)}}onchange(t,e){("file"in t||"fit"in t||"page"in t)&&this.loadPDF()}async fit(){const{fit:t="none"}=this.state,{width:e,height:r}=this.bounds,n=this.documentSize;switch(t){case"none":default:this.displayScale=1;break;case"width":this.displayScale=e/n.width;break;case"height":this.displayScale=r/n.height;break;case"ratio":this.displayScale=Math.min(e/n.width,r/n.height)}this.scaleIndex=JAt.findIndex((t=>this.displayScale<=t)),-1===this.scaleIndex&&(this.scaleIndex=JAt.length-1),"ratio"===t?(this.offsetX=(e-n.width*this.displayScale)/2,this.offsetY=(r-n.height*this.displayScale)/2):(this.offsetX=0,this.offsetY=0),this.renderPDF()}async renderPDF(){if(!this.pdfDoc||!this.page)return;const{width:t,height:e}=this.documentSize;let r=JAt[this.scaleIndex],n=Math.min(t*r,ZAt),i=Math.min(e*r,ZAt);if(n===ZAt||i===ZAt){const a=t/e;a>1&&(i=n/a);const s=i/e;this.scaleIndex=JAt.findIndex((t=>s<=t))-1,r=JAt[this.scaleIndex],n=t*r,i=e*r}const a=document.createElement("canvas");a.width=n,a.height=i;const s={canvasContext:a.getContext("2d"),viewport:this.page.getViewport({scale:r})};if(this.renderTask){this.renderTask.cancel();try{await this.renderTask.promise}catch(t){console.warn("Previous render task was canceled.")}}this.renderTask=this.page.render(s);try{await this.renderTask.promise,this.canvas=a,this.renderTask=null,this.invalidate()}catch(t){"RenderingCancelledException"!==t.name&&console.error("Failed to render PDF:",t)}}render(t){super.render(t);const{left:e,top:r}=this.bounds,{width:n,height:i}=this.canvas;t.clip(),t.drawImage(this.canvas,e+this.offsetX,r+this.offsetY,(this.documentSize?.width||n)*this.displayScale,(this.documentSize?.height||i)*this.displayScale)}onwheel(t){t.preventDefault();var{left:e,top:r}=this.bounds,{x:n,y:i}=this.transcoordC2S(t.offsetX,t.offsetY);n-=e,i-=r;const a=t.deltaY<0?1.05:.95,s=this.displayScale;this.displayScale=Math.min(Math.max(.5,this.displayScale*a),JAt[JAt.length-1]);const o=JAt.findIndex((t=>this.displayScale<=t)),l=-1===o?JAt.length-1:o,h=this.displayScale/s;this.offsetX=n-(n-this.offsetX)*h,this.offsetY=i-(i-this.offsetY)*h,this.invalidate(),l!==this.scaleIndex&&(this.scaleIndex=l,this.renderPDF())}ondragstart(t){this.position=this.transcoordC2S(t.offsetX,t.offsetY)}ondragmove(t){var{x:e,y:r}=this.transcoordC2S(t.offsetX,t.offsetY);const n=e-this.position.x,i=r-this.position.y;this.offsetX+=n,this.offsetY+=i,this.position={x:e,y:r},this.invalidate()}ondblclick(t){this.fit()}get nature(){return QAt}}ret.register("pdf-page",t_t);var e_t=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=Gtt(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(g9(t)))}},r_t=t=>class extends t{_convertDataFormat(t,e){var r;if("json"===e)r=JSON.parse(t);else r=t;return r}isDataSource(){return!0}},n_t=0;const i_t=new FinalizationRegistry((()=>{n_t--}));class a_t{static get residents(){return n_t}static get residentsCount(){return n_t}constructor(t,e){this.counters={},this.references={},this.creator=t,this.disposer=e,n_t++,i_t.register(this,n_t)}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,C9("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 s(e){e.release=function(){r.release(this)},r.references[t]=e,r.counters[t]=1,n(e)}if(e)s(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){s(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,C9("RELEASED",e))):M9("No Referenced ID")}}var s_t={},o_t={},l_t=[];function h_t(t){var e="SCRIPT"==t.target.tagName?s_t:o_t,r=t.target.src||t.target.href;e[r]=!0,l_t.forEach(((t,n)=>{let{resolve:i,scripts:a,styles:s}=t;if(e==s_t){let t=a.indexOf(r);t>-1&&t<a.length-1&&u_t(a[t+1])}for(let t=0;t<a.length;t++)if(!s_t[a[t]])return;if(s)for(let t=0;t<s.length;t++)if(!o_t[s[t]])return;i(),l_t[n]=null})),l_t=l_t.filter(Boolean)}function c_t(t){var e=t.target.src,r="SCRIPT"==t.target.tagName?s_t:o_t;l_t.forEach(((n,i)=>{let{reject:a,scripts:s,styles:o}=n,l=!1;if(r===s_t){for(let t=0;t<s.length;t++)if(s[t]==e){l=!0;break}}else if(o)for(let t=0;t<o.length;t++)if(o[t]==e){l=!0;break}l&&(a(t),l_t[i]=null)})),l_t=l_t.filter(Boolean),delete r[e],document.head.removeChild(t.target)}function u_t(t){s_t[t]=!1;var e=document.createElement("script");e.onload=h_t,e.onerror=c_t,e.type="text/javascript",e.src=t,document.head.appendChild(e)}class d_t{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=>{o_t.hasOwnProperty(t)||function(t){o_t[t]=!1;var e=document.createElement("link");e.onload=h_t,e.onerror=c_t,e.type="text/css",e.rel="stylesheet",e.media="screen,print",e.href=t,document.head.appendChild(e)}(t),o_t[t]||(a=!1)})),t&&t.length>0&&t.forEach((t=>{s_t.hasOwnProperty(t)?s_t[t]||(a=!1):i=i||t})),i)u_t(i);else if(a)return void r();l_t.push({resolve:r,reject:n,scripts:t,styles:e})}else n("invalid sources for load")}))}}const p_t="0.0.0";var f_t=0,g_t=performance.now(),v_t=0;function m_t(){return f_t}requestAnimationFrame((function t(){requestAnimationFrame(t),v_t++;var e=performance.now(),r=e-g_t;r<1e3||(f_t=Math.round(1e3*v_t/r),g_t=e,v_t=0)}));var y_t=brt;function b_t(){}export{bet as AbsoluteLayout,qst as AudioPlayer,xet as CardLayout,ret as Component,jet as Connectable,ist as Container,Iet as ContainerAbstract,H9 as DEFAULT,z9 as DPPX,r_t as DataSource,hot as Donut,wst as Ellipse,Xnt as EventMap,m_t as FPS,W9 as GESTURES,Yst as GifView,eot as GlobalRef,Kst as Group,pet as HTMLAbsoluteLayout,Zst as HTMLOverlayContainer,Ist as HTMLOverlayElement,Pst as ImageView,cet as InfoWindow,U9 as KEYEVENTS,Ret as Layer,det as Layout,yst as Line,_et as LinearHorizontalLayout,Eet as LinearVerticalLayout,Jst as LocalRef,B9 as MAX_UNDO_SIZE,D9 as MODE_ADD,O9 as MODE_EDIT,N9 as MODE_PASTE_DATABIND,F9 as MODE_PASTE_STYLE,L9 as MODE_SHIFT,R9 as MODE_VIEW,y_t as Model,Cet as MoveHandle,I9 as NOTHING,Tst as OrthoLine,t_t as PDFPage,iot as Path,_st as Polygon,Est as Polyline,not as Popup,Wet as Rect,aet as RectPath,a_t as ReferenceMap,kit as RootContainer,Het as Ruler,j9 as SCENE_MODE,jit as Scene,yet as ScenePopup,d_t as ScriptLoader,net as Shape,Sot as Star,Met as TableLayout,Xst as Text,sot as Triangle,e_t as ValueHolder,zit as create,C9 as debug,M9 as error,b_t as license,h4 as polyfill,p_t as version,T9 as warn};console.log("@hatiolab/things-scene@9.0.0-beta.27 is loaded");
|
|
92
|
+
*/var Eot={d:(t,e)=>{for(var r in e)Eot.o(e,r)&&!Eot.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},Mot=globalThis.pdfjsLib={};Eot.d(Mot,{AbortException:()=>Blt,AnnotationEditorLayer:()=>OAt,AnnotationEditorParamsType:()=>Uot,AnnotationEditorType:()=>Wot,AnnotationEditorUIManager:()=>Kct,AnnotationLayer:()=>Iyt,AnnotationMode:()=>zot,ColorPicker:()=>owt,DOMSVGFactory:()=>Zvt,DrawLayer:()=>YAt,FeatureTest:()=>Hlt,GlobalWorkerOptions:()=>Dft,ImageKind:()=>Kot,InvalidPDFException:()=>Dlt,MissingPDFException:()=>Flt,OPS:()=>xlt,OutputScale:()=>bht,PDFDataRangeTransport:()=>uvt,PDFDateString:()=>dht,PDFWorker:()=>_vt,PasswordResponses:()=>Alt,PermissionFlag:()=>Hot,PixelsPerInch:()=>Zlt,RenderingCancelledException:()=>nht,TextLayer:()=>Ugt,TouchManager:()=>$ut,UnexpectedResponseException:()=>Nlt,Util:()=>Ylt,VerbosityLevel:()=>wlt,XfaLayer:()=>tmt,build:()=>Xvt,createValidAbsoluteUrl:()=>Plt,fetchData:()=>tht,getDocument:()=>ovt,getFilenameFromUrl:()=>sht,getPdfFilenameFromUrl:()=>oht,getXfaPageViewport:()=>fht,isDataScheme:()=>iht,isPdfFile:()=>aht,noContextMenu:()=>cht,normalizeUnicode:()=>Klt,setLayerDimensions:()=>yht,shadow:()=>Ilt,stopEvent:()=>uht,version:()=>qvt});var Tot=!("object"!=typeof process||process+""!="[object process]"||process.versions.nw||process.versions.electron&&process.type&&"browser"!==process.type),Cot=[1,0,0,1,0,0],Pot=[.001,0,0,.001,0,0],Iot=1.35,Rot=1,Oot=2,Lot=4,Dot=16,Fot=32,Not=64,jot=128,Bot=256,zot={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},Wot={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15},Uot={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,HIGHLIGHT_COLOR:31,HIGHLIGHT_DEFAULT_COLOR:32,HIGHLIGHT_THICKNESS:33,HIGHLIGHT_FREE:34,HIGHLIGHT_SHOW_ALL:35,DRAW_STEP:41},Hot={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},Got=0,Yot=1,Vot=2,qot=3,Xot=3,$ot=4,Kot={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},Qot=1,Jot=2,Zot=3,tlt=4,elt=5,rlt=6,nlt=7,ilt=8,alt=9,slt=10,olt=11,llt=12,hlt=13,clt=14,ult=15,dlt=16,plt=17,flt=20,glt=1,vlt=2,mlt=3,ylt=4,blt=5,wlt={ERRORS:0,WARNINGS:1,INFOS:5},xlt={dependency:1,setLineWidth:2,setLineCap:3,setLineJoin:4,setMiterLimit:5,setDash:6,setRenderingIntent:7,setFlatness:8,setGState:9,save:10,restore:11,transform:12,moveTo:13,lineTo:14,curveTo:15,curveTo2:16,curveTo3:17,closePath:18,rectangle:19,stroke:20,closeStroke:21,fill:22,eoFill:23,fillStroke:24,eoFillStroke:25,closeFillStroke:26,closeEOFillStroke:27,endPath:28,clip:29,eoClip:30,beginText:31,endText:32,setCharSpacing:33,setWordSpacing:34,setHScale:35,setLeading:36,setFont:37,setTextRenderingMode:38,setTextRise:39,moveText:40,setLeadingMoveText:41,setTextMatrix:42,nextLine:43,showText:44,showSpacedText:45,nextLineShowText:46,nextLineSetSpacingShowText:47,setCharWidth:48,setCharWidthAndBounds:49,setStrokeColorSpace:50,setFillColorSpace:51,setStrokeColor:52,setStrokeColorN:53,setFillColor:54,setFillColorN:55,setStrokeGray:56,setFillGray:57,setStrokeRGBColor:58,setFillRGBColor:59,setStrokeCMYKColor:60,setFillCMYKColor:61,shadingFill:62,beginInlineImage:63,beginImageData:64,endInlineImage:65,paintXObject:66,markPoint:67,markPointProps:68,beginMarkedContent:69,beginMarkedContentProps:70,endMarkedContent:71,beginCompat:72,endCompat:73,paintFormXObjectBegin:74,paintFormXObjectEnd:75,beginGroup:76,endGroup:77,beginAnnotation:80,endAnnotation:81,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageXObject:85,paintInlineImageXObject:86,paintInlineImageXObjectGroup:87,paintImageXObjectRepeat:88,paintImageMaskXObjectRepeat:89,paintSolidColorImageMask:90,constructPath:91,setStrokeTransparent:92,setFillTransparent:93},Alt={NEED_PASSWORD:1,INCORRECT_PASSWORD:2},_lt=wlt.WARNINGS;function klt(t){Number.isInteger(t)&&(_lt=t)}function Slt(){return _lt}function Elt(t){_lt>=wlt.INFOS&&console.log("Info: ".concat(t))}function Mlt(t){_lt>=wlt.WARNINGS&&console.log("Warning: ".concat(t))}function Tlt(t){throw new Error(t)}function Clt(t,e){t||Tlt(e)}function Plt(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;if(!t)return null;try{if(r&&"string"==typeof t){if(r.addDefaultProtocol&&t.startsWith("www.")){var n=t.match(/\./g);(null==n?void 0:n.length)>=2&&(t="http://".concat(t))}if(r.tryConvertEncoding)try{t=decodeURIComponent(escape(t))}catch(t){}}var i=e?new URL(t,e):new URL(t);if(function(t){switch(null==t?void 0:t.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}(i))return i}catch(t){}return null}function Ilt(t,e,r){var n=arguments.length>3&&void 0!==arguments[3]&&arguments[3];return Object.defineProperty(t,e,{value:r,enumerable:!n,configurable:!0,writable:!1}),r}var Rlt=function(){function t(t,e){this.message=t,this.name=e}return t.prototype=new Error,t.constructor=t,t}();class Olt extends Rlt{constructor(t,e){super(t,"PasswordException"),this.code=e}}class Llt extends Rlt{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}class Dlt extends Rlt{constructor(t){super(t,"InvalidPDFException")}}class Flt extends Rlt{constructor(t){super(t,"MissingPDFException")}}class Nlt extends Rlt{constructor(t,e){super(t,"UnexpectedResponseException"),this.status=e}}class jlt extends Rlt{constructor(t){super(t,"FormatError")}}class Blt extends Rlt{constructor(t){super(t,"AbortException")}}function zlt(t){"object"==typeof t&&void 0!==(null==t?void 0:t.length)||Tlt("Invalid argument for bytesToString");var e=t.length,r=8192;if(e<r)return String.fromCharCode.apply(null,t);for(var n=[],i=0;i<e;i+=r){var a=Math.min(i+r,e),s=t.subarray(i,a);n.push(String.fromCharCode.apply(null,s))}return n.join("")}function Wlt(t){"string"!=typeof t&&Tlt("Invalid argument for stringToBytes");for(var e=t.length,r=new Uint8Array(e),n=0;n<e;++n)r[n]=255&t.charCodeAt(n);return r}function Ult(t){var e=Object.create(null);for(var[r,n]of t)e[r]=n;return e}class Hlt{static get isLittleEndian(){return Ilt(this,"isLittleEndian",((t=new Uint8Array(4))[0]=1,1===new Uint32Array(t.buffer,0,1)[0]));var t}static get isEvalSupported(){return Ilt(this,"isEvalSupported",function(){try{return new Function(""),!0}catch(t){return!1}}())}static get isOffscreenCanvasSupported(){return Ilt(this,"isOffscreenCanvasSupported","undefined"!=typeof OffscreenCanvas)}static get isImageDecoderSupported(){return Ilt(this,"isImageDecoderSupported","undefined"!=typeof ImageDecoder)}static get platform(){var t,e;return"undefined"!=typeof navigator&&"string"==typeof(null===(t=navigator)||void 0===t?void 0:t.platform)?Ilt(this,"platform",{isMac:navigator.platform.includes("Mac"),isWindows:navigator.platform.includes("Win"),isFirefox:"string"==typeof(null===(e=navigator)||void 0===e?void 0:e.userAgent)&&navigator.userAgent.includes("Firefox")}):Ilt(this,"platform",{isMac:!1,isWindows:!1,isFirefox:!1})}static get isCSSRoundSupported(){var t,e;return Ilt(this,"isCSSRoundSupported",null===(t=globalThis.CSS)||void 0===t||null===(e=t.supports)||void 0===e?void 0:e.call(t,"width: round(1.5px, 1px)"))}}var Glt=Array.from(Array(256).keys(),(t=>t.toString(16).padStart(2,"0")));class Ylt{static makeHexColor(t,e,r){return"#".concat(Glt[t]).concat(Glt[e]).concat(Glt[r])}static scaleMinMax(t,e){var r;t[0]?(t[0]<0&&(r=e[0],e[0]=e[2],e[2]=r),e[0]*=t[0],e[2]*=t[0],t[3]<0&&(r=e[1],e[1]=e[3],e[3]=r),e[1]*=t[3],e[3]*=t[3]):(r=e[0],e[0]=e[1],e[1]=r,r=e[2],e[2]=e[3],e[3]=r,t[1]<0&&(r=e[1],e[1]=e[3],e[3]=r),e[1]*=t[1],e[3]*=t[1],t[2]<0&&(r=e[0],e[0]=e[2],e[2]=r),e[0]*=t[2],e[2]*=t[2]),e[0]+=t[4],e[1]+=t[5],e[2]+=t[4],e[3]+=t[5]}static transform(t,e){return[t[0]*e[0]+t[2]*e[1],t[1]*e[0]+t[3]*e[1],t[0]*e[2]+t[2]*e[3],t[1]*e[2]+t[3]*e[3],t[0]*e[4]+t[2]*e[5]+t[4],t[1]*e[4]+t[3]*e[5]+t[5]]}static applyTransform(t,e){return[t[0]*e[0]+t[1]*e[2]+e[4],t[0]*e[1]+t[1]*e[3]+e[5]]}static applyInverseTransform(t,e){var r=e[0]*e[3]-e[1]*e[2];return[(t[0]*e[3]-t[1]*e[2]+e[2]*e[5]-e[4]*e[3])/r,(-t[0]*e[1]+t[1]*e[0]+e[4]*e[1]-e[5]*e[0])/r]}static getAxialAlignedBoundingBox(t,e){var r=this.applyTransform(t,e),n=this.applyTransform(t.slice(2,4),e),i=this.applyTransform([t[0],t[3]],e),a=this.applyTransform([t[2],t[1]],e);return[Math.min(r[0],n[0],i[0],a[0]),Math.min(r[1],n[1],i[1],a[1]),Math.max(r[0],n[0],i[0],a[0]),Math.max(r[1],n[1],i[1],a[1])]}static inverseTransform(t){var e=t[0]*t[3]-t[1]*t[2];return[t[3]/e,-t[1]/e,-t[2]/e,t[0]/e,(t[2]*t[5]-t[4]*t[3])/e,(t[4]*t[1]-t[5]*t[0])/e]}static singularValueDecompose2dScale(t){var e=[t[0],t[2],t[1],t[3]],r=t[0]*e[0]+t[1]*e[2],n=t[0]*e[1]+t[1]*e[3],i=t[2]*e[0]+t[3]*e[2],a=t[2]*e[1]+t[3]*e[3],s=(r+a)/2,o=Math.sqrt(Math.pow(r+a,2)-4*(r*a-i*n))/2,l=s+o||1,h=s-o||1;return[Math.sqrt(l),Math.sqrt(h)]}static normalizeRect(t){var e=t.slice(0);return t[0]>t[2]&&(e[0]=t[2],e[2]=t[0]),t[1]>t[3]&&(e[1]=t[3],e[3]=t[1]),e}static intersect(t,e){var r=Math.max(Math.min(t[0],t[2]),Math.min(e[0],e[2])),n=Math.min(Math.max(t[0],t[2]),Math.max(e[0],e[2]));if(r>n)return null;var i=Math.max(Math.min(t[1],t[3]),Math.min(e[1],e[3])),a=Math.min(Math.max(t[1],t[3]),Math.max(e[1],e[3]));return i>a?null:[r,i,n,a]}static bezierBoundingBox(t,e,r,n,i,a,s,o,l){return l?(l[0]=Math.min(l[0],t,s),l[1]=Math.min(l[1],e,o),l[2]=Math.max(l[2],t,s),l[3]=Math.max(l[3],e,o)):l=[Math.min(t,s),Math.min(e,o),Math.max(t,s),Math.max(e,o)],iit(Ylt,this,qlt).call(this,t,r,i,s,e,n,a,o,3*(3*(r-i)-t+s),6*(t-2*r+i),3*(r-t),l),iit(Ylt,this,qlt).call(this,t,r,i,s,e,n,a,o,3*(3*(n-a)-e+o),6*(e-2*n+a),3*(n-e),l),l}}function Vlt(t,e,r,n,i,a,s,o,l,h){if(!(l<=0||l>=1)){var c=1-l,u=l*l,d=u*l,p=c*(c*(c*t+3*l*e)+3*u*r)+d*n,f=c*(c*(c*i+3*l*a)+3*u*s)+d*o;h[0]=Math.min(h[0],p),h[1]=Math.min(h[1],f),h[2]=Math.max(h[2],p),h[3]=Math.max(h[3],f)}}function qlt(t,e,r,n,i,a,s,o,l,h,c,u){if(Math.abs(l)<1e-12)Math.abs(h)>=1e-12&&iit(uot,this,Vlt).call(this,t,e,r,n,i,a,s,o,-c/h,u);else{var d=Math.pow(h,2)-4*c*l;if(!(d<0)){var p=Math.sqrt(d),f=2*l;iit(uot,this,Vlt).call(this,t,e,r,n,i,a,s,o,(-h+p)/f,u),iit(uot,this,Vlt).call(this,t,e,r,n,i,a,s,o,(-h-p)/f,u)}}}uot=Ylt;var Xlt=null,$lt=null;function Klt(t){return Xlt||(Xlt=/([\xA0\xB5\u037E\u0EB3\u2000-\u200A\u202F\u2126\uFB00-\uFB04\uFB06\uFB20-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBA1\uFBA4-\uFBA9\uFBAE-\uFBB1\uFBD3-\uFBDC\uFBDE-\uFBE7\uFBEA-\uFBF8\uFBFC\uFBFD\uFC00-\uFC5D\uFC64-\uFCF1\uFCF5-\uFD3D\uFD88\uFDF4\uFDFA\uFDFB\uFE71\uFE77\uFE79\uFE7B\uFE7D]+)|(\uFB05+)/g,$lt=new Map([["ſt","ſt"]])),t.replaceAll(Xlt,((t,e,r)=>e?e.normalize("NFKC"):$lt.get(r)))}var Qlt="pdfjs_internal_id_";"function"!=typeof Promise.try&&(Promise.try=function(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),n=1;n<e;n++)r[n-1]=arguments[n];return new Promise((e=>{e(t(...r))}))});var Jlt="http://www.w3.org/2000/svg";class Zlt{}function tht(t){return eht.apply(this,arguments)}function eht(){return eht=sit((function*(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"text";if(hht(t,document.baseURI)){var r=yield fetch(t);if(!r.ok)throw new Error(r.statusText);switch(e){case"arraybuffer":return r.arrayBuffer();case"blob":return r.blob();case"json":return r.json()}return r.text()}return new Promise(((r,n)=>{var i=new XMLHttpRequest;i.open("GET",t,!0),i.responseType=e,i.onreadystatechange=()=>{if(i.readyState===XMLHttpRequest.DONE)if(200!==i.status&&0!==i.status)n(new Error(i.statusText));else{switch(e){case"arraybuffer":case"blob":case"json":return void r(i.response)}r(i.responseText)}},i.send(null)}))})),eht.apply(this,arguments)}dot=Zlt,pit(Zlt,"CSS",96),pit(Zlt,"PDF",72),pit(Zlt,"PDF_TO_CSS_UNITS",dot.CSS/dot.PDF);class rht{constructor(t){var{viewBox:e,userUnit:r,scale:n,rotation:i,offsetX:a=0,offsetY:s=0,dontFlip:o=!1}=t;this.viewBox=e,this.userUnit=r,this.scale=n,this.rotation=i,this.offsetX=a,this.offsetY=s,n*=r;var l,h,c,u,d,p,f,g,v=(e[2]+e[0])/2,m=(e[3]+e[1])/2;switch((i%=360)<0&&(i+=360),i){case 180:l=-1,h=0,c=0,u=1;break;case 90:l=0,h=1,c=1,u=0;break;case 270:l=0,h=-1,c=-1,u=0;break;case 0:l=1,h=0,c=0,u=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}o&&(c=-c,u=-u),0===l?(d=Math.abs(m-e[1])*n+a,p=Math.abs(v-e[0])*n+s,f=(e[3]-e[1])*n,g=(e[2]-e[0])*n):(d=Math.abs(v-e[0])*n+a,p=Math.abs(m-e[1])*n+s,f=(e[2]-e[0])*n,g=(e[3]-e[1])*n),this.transform=[l*n,h*n,c*n,u*n,d-l*n*v-c*n*m,p-h*n*v-u*n*m],this.width=f,this.height=g}get rawDims(){var{userUnit:t,viewBox:e}=this,r=e.map((e=>e*t));return Ilt(this,"rawDims",{pageWidth:r[2]-r[0],pageHeight:r[3]-r[1],pageX:r[0],pageY:r[1]})}clone(){var{scale:t=this.scale,rotation:e=this.rotation,offsetX:r=this.offsetX,offsetY:n=this.offsetY,dontFlip:i=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new rht({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:e,offsetX:r,offsetY:n,dontFlip:i})}convertToViewportPoint(t,e){return Ylt.applyTransform([t,e],this.transform)}convertToViewportRectangle(t){var e=Ylt.applyTransform([t[0],t[1]],this.transform),r=Ylt.applyTransform([t[2],t[3]],this.transform);return[e[0],e[1],r[0],r[1]]}convertToPdfPoint(t,e){return Ylt.applyInverseTransform([t,e],this.transform)}}class nht extends Rlt{constructor(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;super(t,"RenderingCancelledException"),this.extraDelay=e}}function iht(t){for(var e=t.length,r=0;r<e&&""===t[r].trim();)r++;return"data:"===t.substring(r,r+5).toLowerCase()}function aht(t){return"string"==typeof t&&/\.pdf$/i.test(t)}function sht(t){return[t]=t.split(/[#?]/,1),t.substring(t.lastIndexOf("/")+1)}function oht(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"document.pdf";if("string"!=typeof t)return e;if(iht(t))return Mlt('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),e;var r=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i,n=/^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/.exec(t),i=r.exec(n[1])||r.exec(n[2])||r.exec(n[3]);if(i&&(i=i[0]).includes("%"))try{i=r.exec(decodeURIComponent(i))[0]}catch(t){}return i||e}class lht{constructor(){pit(this,"started",Object.create(null)),pit(this,"times",[])}time(t){t in this.started&&Mlt("Timer is already running for ".concat(t)),this.started[t]=Date.now()}timeEnd(t){t in this.started||Mlt("Timer has not been started for ".concat(t)),this.times.push({name:t,start:this.started[t],end:Date.now()}),delete this.started[t]}toString(){var t=[],e=0;for(var{name:r}of this.times)e=Math.max(r.length,e);for(var{name:n,start:i,end:a}of this.times)t.push("".concat(n.padEnd(e)," ").concat(a-i,"ms\n"));return t.join("")}}function hht(t,e){try{var{protocol:r}=e?new URL(t,e):new URL(t);return"http:"===r||"https:"===r}catch(t){return!1}}function cht(t){t.preventDefault()}function uht(t){t.preventDefault(),t.stopPropagation()}class dht{static toDateObject(t){if(!t||"string"!=typeof t)return null;iit(dht,this,pht)._||(pht._=iit(dht,this,new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?")));var e=iit(dht,this,pht)._.exec(t);if(!e)return null;var r=parseInt(e[1],10),n=parseInt(e[2],10);n=n>=1&&n<=12?n-1:0;var i=parseInt(e[3],10);i=i>=1&&i<=31?i:1;var a=parseInt(e[4],10);a=a>=0&&a<=23?a:0;var s=parseInt(e[5],10);s=s>=0&&s<=59?s:0;var o=parseInt(e[6],10);o=o>=0&&o<=59?o:0;var l=e[7]||"Z",h=parseInt(e[8],10);h=h>=0&&h<=23?h:0;var c=parseInt(e[9],10)||0;return c=c>=0&&c<=59?c:0,"-"===l?(a+=h,s+=c):"+"===l&&(a-=h,s-=c),new Date(Date.UTC(r,n,i,a,s,o))}}var pht={_:void 0};function fht(t,e){var{scale:r=1,rotation:n=0}=e,{width:i,height:a}=t.attributes.style,s=[0,0,parseInt(i),parseInt(a)];return new rht({viewBox:s,userUnit:1,scale:r,rotation:n})}function ght(t){if(t.startsWith("#")){var e=parseInt(t.slice(1),16);return[(16711680&e)>>16,(65280&e)>>8,255&e]}return t.startsWith("rgb(")?t.slice(4,-1).split(",").map((t=>parseInt(t))):t.startsWith("rgba(")?t.slice(5,-1).split(",").map((t=>parseInt(t))).slice(0,3):(Mlt('Not a valid color format: "'.concat(t,'"')),[0,0,0])}function vht(t){var{a:e,b:r,c:n,d:i,e:a,f:s}=t.getTransform();return[e,r,n,i,a,s]}function mht(t){var{a:e,b:r,c:n,d:i,e:a,f:s}=t.getTransform().invertSelf();return[e,r,n,i,a,s]}function yht(t,e){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];if(e instanceof rht){var{pageWidth:i,pageHeight:a}=e.rawDims,{style:s}=t,o=Hlt.isCSSRoundSupported,l="var(--scale-factor) * ".concat(i,"px"),h="var(--scale-factor) * ".concat(a,"px"),c=o?"round(down, ".concat(l,", var(--scale-round-x, 1px))"):"calc(".concat(l,")"),u=o?"round(down, ".concat(h,", var(--scale-round-y, 1px))"):"calc(".concat(h,")");r&&e.rotation%180!=0?(s.width=u,s.height=c):(s.width=c,s.height=u)}n&&t.setAttribute("data-main-rotation",e.rotation)}class bht{constructor(){var t=window.devicePixelRatio||1;this.sx=t,this.sy=t}get scaled(){return 1!==this.sx||1!==this.sy}get symmetric(){return this.sx===this.sy}}var wht=new WeakMap,xht=new WeakMap,Aht=new WeakMap,_ht=new WeakMap,kht=new WeakMap,Sht=new WeakSet;class Eht{constructor(t){dit(this,Sht),hit(this,wht,null),hit(this,xht,null),hit(this,Aht,void 0),hit(this,_ht,null),hit(this,kht,null),cit(Aht,this,t),Oht._||(Oht._=Object.freeze({freetext:"pdfjs-editor-remove-freetext-button",highlight:"pdfjs-editor-remove-highlight-button",ink:"pdfjs-editor-remove-ink-button",stamp:"pdfjs-editor-remove-stamp-button"}))}render(){var t=cit(wht,this,document.createElement("div"));t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");var e=lit(Aht,this)._uiManager._signal;t.addEventListener("contextmenu",cht,{signal:e}),t.addEventListener("pointerdown",Mht,{signal:e});var r=cit(_ht,this,document.createElement("div"));r.className="buttons",t.append(r);var n=lit(Aht,this).toolbarPosition;if(n){var{style:i}=t,a="ltr"===lit(Aht,this)._uiManager.direction?1-n[0]:n[0];i.insetInlineEnd="".concat(100*a,"%"),i.top="calc(".concat(100*n[1],"% + var(--editor-toolbar-vert-offset))")}return iit(Sht,this,Iht).call(this),t}get div(){return lit(wht,this)}hide(){var t;lit(wht,this).classList.add("hidden"),null===(t=lit(xht,this))||void 0===t||t.hideDropdown()}show(){var t;lit(wht,this).classList.remove("hidden"),null===(t=lit(kht,this))||void 0===t||t.shown()}addAltText(t){var e=this;return sit((function*(){var r=yield t.render();iit(Sht,e,Pht).call(e,r),lit(_ht,e).prepend(r,uit(Sht,e,Rht)),cit(kht,e,t)}))()}addColorPicker(t){cit(xht,this,t);var e=t.renderButton();iit(Sht,this,Pht).call(this,e),lit(_ht,this).prepend(e,uit(Sht,this,Rht))}remove(){var t;lit(wht,this).remove(),null===(t=lit(xht,this))||void 0===t||t.destroy(),cit(xht,this,null)}}function Mht(t){t.stopPropagation()}function Tht(t){lit(Aht,this)._focusEventsAllowed=!1,uht(t)}function Cht(t){lit(Aht,this)._focusEventsAllowed=!0,uht(t)}function Pht(t){var e=lit(Aht,this)._uiManager._signal;t.addEventListener("focusin",iit(Sht,this,Tht).bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",iit(Sht,this,Cht).bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",cht,{signal:e})}function Iht(){var{editorType:t,_uiManager:e}=lit(Aht,this),r=document.createElement("button");r.className="delete",r.tabIndex=0,r.setAttribute("data-l10n-id",Oht._[t]),iit(Sht,this,Pht).call(this,r),r.addEventListener("click",(t=>{e.delete()}),{signal:e._signal}),lit(_ht,this).append(r)}function Rht(t){var e=document.createElement("div");return e.className="divider",e}var Oht={_:null},Lht=new WeakMap,Dht=new WeakMap,Fht=new WeakMap,Nht=new WeakSet;class jht{constructor(t){dit(this,Nht),hit(this,Lht,null),hit(this,Dht,null),hit(this,Fht,void 0),cit(Fht,this,t)}show(t,e,r){var[n,i]=iit(Nht,this,zht).call(this,e,r),{style:a}=lit(Dht,this)||cit(Dht,this,iit(Nht,this,Bht).call(this));t.append(lit(Dht,this)),a.insetInlineEnd="".concat(100*n,"%"),a.top="calc(".concat(100*i,"% + var(--editor-toolbar-vert-offset))")}hide(){lit(Dht,this).remove()}}function Bht(){var t=cit(Dht,this,document.createElement("div"));t.className="editToolbar",t.setAttribute("role","toolbar"),t.addEventListener("contextmenu",cht,{signal:lit(Fht,this)._signal});var e=cit(Lht,this,document.createElement("div"));return e.className="buttons",t.append(e),iit(Nht,this,Wht).call(this),t}function zht(t,e){var r=0,n=0;for(var i of t){var a=i.y+i.height;if(!(a<r)){var s=i.x+(e?i.width:0);a>r?(n=s,r=a):e?s>n&&(n=s):s<n&&(n=s)}}return[e?1-n:n,r]}function Wht(){var t=document.createElement("button");t.className="highlightButton",t.tabIndex=0,t.setAttribute("data-l10n-id","pdfjs-highlight-floating-button1");var e=document.createElement("span");t.append(e),e.className="visuallyHidden",e.setAttribute("data-l10n-id","pdfjs-highlight-floating-button-label");var r=lit(Fht,this)._signal;t.addEventListener("contextmenu",cht,{signal:r}),t.addEventListener("click",(()=>{lit(Fht,this).highlightSelection("floating_button")}),{signal:r}),lit(Lht,this).append(t)}function Uht(t,e,r){for(var n of r)e.addEventListener(n,t[n].bind(t))}var Hht=new WeakMap;class Ght{constructor(){hit(this,Hht,0)}get id(){var t,e;return"".concat("pdfjs_internal_editor_").concat((cit(Hht,this,(t=lit(Hht,this),e=t++,t)),e))}}var Yht=new WeakMap,Vht=new WeakMap,qht=new WeakMap,Xht=new WeakSet;class $ht{constructor(){dit(this,Xht),hit(this,Yht,function(){if("function"==typeof crypto.randomUUID)return crypto.randomUUID();var t=new Uint8Array(32);return crypto.getRandomValues(t),zlt(t)}()),hit(this,Vht,0),hit(this,qht,null)}static get _isSVGFittingCanvas(){var t=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),e=new Image;return e.src='data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="http://www.w3.org/2000/svg"><rect width="1" height="1" style="fill:red;"/></svg>',Ilt(this,"_isSVGFittingCanvas",e.decode().then((()=>(t.drawImage(e,0,0,1,1,0,0,1,3),0===new Uint32Array(t.getImageData(0,0,1,1).data.buffer)[0]))))}getFromFile(t){var e=this;return sit((function*(){var{lastModified:r,name:n,size:i,type:a}=t;return iit(Xht,e,Kht).call(e,"".concat(r,"_").concat(n,"_").concat(i,"_").concat(a),t)}))()}getFromUrl(t){var e=this;return sit((function*(){return iit(Xht,e,Kht).call(e,t,t)}))()}getFromBlob(t,e){var r=this;return sit((function*(){var n=yield e;return iit(Xht,r,Kht).call(r,t,n)}))()}getFromId(t){var e=this;return sit((function*(){lit(qht,e)||cit(qht,e,new Map);var r=lit(qht,e).get(t);if(!r)return null;if(r.bitmap)return r.refCounter+=1,r;if(r.file)return e.getFromFile(r.file);if(r.blobPromise){var{blobPromise:n}=r;return delete r.blobPromise,e.getFromBlob(r.id,n)}return e.getFromUrl(r.url)}))()}getFromCanvas(t,e){var r,n,i;lit(qht,this)||cit(qht,this,new Map);var a=lit(qht,this).get(t);if(null!==(i=a)&&void 0!==i&&i.bitmap)return a.refCounter+=1,a;var s=new OffscreenCanvas(e.width,e.height);return s.getContext("2d").drawImage(e,0,0),a={bitmap:s.transferToImageBitmap(),id:"image_".concat(lit(Yht,this),"_").concat((cit(Vht,this,(r=lit(Vht,this),n=r++,r)),n)),refCounter:1,isSvg:!1},lit(qht,this).set(t,a),lit(qht,this).set(a.id,a),a}getSvgUrl(t){var e=lit(qht,this).get(t);return null!=e&&e.isSvg?e.svgUrl:null}deleteId(t){var e;lit(qht,this)||cit(qht,this,new Map);var r=lit(qht,this).get(t);if(r&&(r.refCounter-=1,0===r.refCounter)){var{bitmap:n}=r;if(!r.url&&!r.file){var i=new OffscreenCanvas(n.width,n.height);i.getContext("bitmaprenderer").transferFromImageBitmap(n),r.blobPromise=i.convertToBlob()}null===(e=n.close)||void 0===e||e.call(n),r.bitmap=null}}isValidId(t){return t.startsWith("image_".concat(lit(Yht,this),"_"))}}function Kht(t,e){return Qht.apply(this,arguments)}function Qht(){return Qht=sit((function*(t,e){var r;lit(qht,this)||cit(qht,this,new Map);var n=lit(qht,this).get(t);if(null===n)return null;if(null!==(r=n)&&void 0!==r&&r.bitmap)return n.refCounter+=1,n;try{var i,a,s;if(n||(n={bitmap:null,id:"image_".concat(lit(Yht,this),"_").concat((cit(Vht,this,(i=lit(Vht,this),a=i++,i)),a)),refCounter:0,isSvg:!1}),"string"==typeof e?(n.url=e,s=yield tht(e,"blob")):e instanceof File?s=n.file=e:e instanceof Blob&&(s=e),"image/svg+xml"===s.type){var o=pot._isSVGFittingCanvas,l=new FileReader,h=new Image,c=new Promise(((t,e)=>{h.onload=()=>{n.bitmap=h,n.isSvg=!0,t()},l.onload=sit((function*(){var t=n.svgUrl=l.result;h.src=(yield o)?"".concat(t,"#svgView(preserveAspectRatio(none))"):t})),h.onerror=l.onerror=e}));l.readAsDataURL(s),yield c}else n.bitmap=yield createImageBitmap(s);n.refCounter=1}catch(t){Mlt(t),n=null}return lit(qht,this).set(t,n),n&&lit(qht,this).set(n.id,n),n})),Qht.apply(this,arguments)}pot=$ht;var Jht=new WeakMap,Zht=new WeakMap,tct=new WeakMap,ect=new WeakMap;class rct{constructor(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:128;hit(this,Jht,[]),hit(this,Zht,!1),hit(this,tct,void 0),hit(this,ect,-1),cit(tct,this,t)}add(t){var{cmd:e,undo:r,post:n,mustExec:i,type:a=NaN,overwriteIfSameType:s=!1,keepUndo:o=!1}=t;if(i&&e(),!lit(Zht,this)){var l={cmd:e,undo:r,post:n,type:a};if(-1===lit(ect,this))return lit(Jht,this).length>0&&(lit(Jht,this).length=0),cit(ect,this,0),void lit(Jht,this).push(l);if(s&&lit(Jht,this)[lit(ect,this)].type===a)return o&&(l.undo=lit(Jht,this)[lit(ect,this)].undo),void(lit(Jht,this)[lit(ect,this)]=l);var h=lit(ect,this)+1;h===lit(tct,this)?lit(Jht,this).splice(0,1):(cit(ect,this,h),h<lit(Jht,this).length&&lit(Jht,this).splice(h)),lit(Jht,this).push(l)}}undo(){if(-1!==lit(ect,this)){cit(Zht,this,!0);var{undo:t,post:e}=lit(Jht,this)[lit(ect,this)];t(),null==e||e(),cit(Zht,this,!1),cit(ect,this,lit(ect,this)-1)}}redo(){if(lit(ect,this)<lit(Jht,this).length-1){cit(ect,this,lit(ect,this)+1),cit(Zht,this,!0);var{cmd:t,post:e}=lit(Jht,this)[lit(ect,this)];t(),null==e||e(),cit(Zht,this,!1)}}hasSomethingToUndo(){return-1!==lit(ect,this)}hasSomethingToRedo(){return lit(ect,this)<lit(Jht,this).length-1}cleanType(t){if(-1!==lit(ect,this)){for(var e=lit(ect,this);e>=0;e--)if(lit(Jht,this)[e].type!==t)return lit(Jht,this).splice(e+1,lit(ect,this)-e),void cit(ect,this,e);lit(Jht,this).length=0,cit(ect,this,-1)}}destroy(){cit(Jht,this,null)}}var nct=new WeakSet;class ict{constructor(t){dit(this,nct),this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;var{isMac:e}=Hlt.platform;for(var[r,n,i={}]of t)for(var a of r){var s=a.startsWith("mac+");e&&s?(this.callbacks.set(a.slice(4),{callback:n,options:i}),this.allKeys.add(a.split("+").at(-1))):e||s||(this.callbacks.set(a,{callback:n,options:i}),this.allKeys.add(a.split("+").at(-1)))}}exec(t,e){if(this.allKeys.has(e.key)){var r=this.callbacks.get(iit(nct,this,act).call(this,e));if(r){var{callback:n,options:{bubbles:i=!1,args:a=[],checker:s=null}}=r;s&&!s(t,e)||(n.bind(t,...a,e)(),i||uht(e))}}}}function act(t){t.altKey&&this.buffer.push("alt"),t.ctrlKey&&this.buffer.push("ctrl"),t.metaKey&&this.buffer.push("meta"),t.shiftKey&&this.buffer.push("shift"),this.buffer.push(t.key);var e=this.buffer.join("+");return this.buffer.length=0,e}class sct{get _colors(){var t=new Map([["CanvasText",null],["Canvas",null]]);return function(t){var e=document.createElement("span");for(var r of(e.style.visibility="hidden",document.body.append(e),t.keys())){e.style.color=r;var n=window.getComputedStyle(e).color;t.set(r,ght(n))}e.remove()}(t),Ilt(this,"_colors",t)}convert(t){var e=ght(t);if(!window.matchMedia("(forced-colors: active)").matches)return e;for(var[r,n]of this._colors)if(n.every(((t,r)=>t===e[r])))return sct._colorsMapping.get(r);return e}getHexCode(t){var e=this._colors.get(t);return e?Ylt.makeHexColor(...e):t}}pit(sct,"_colorsMapping",new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]));var oct=new WeakMap,lct=new WeakMap,hct=new WeakMap,cct=new WeakMap,uct=new WeakMap,dct=new WeakMap,pct=new WeakMap,fct=new WeakMap,gct=new WeakMap,vct=new WeakMap,mct=new WeakMap,yct=new WeakMap,bct=new WeakMap,wct=new WeakMap,xct=new WeakMap,Act=new WeakMap,_ct=new WeakMap,kct=new WeakMap,Sct=new WeakMap,Ect=new WeakMap,Mct=new WeakMap,Tct=new WeakMap,Cct=new WeakMap,Pct=new WeakMap,Ict=new WeakMap,Rct=new WeakMap,Oct=new WeakMap,Lct=new WeakMap,Dct=new WeakMap,Fct=new WeakMap,Nct=new WeakMap,jct=new WeakMap,Bct=new WeakMap,zct=new WeakMap,Wct=new WeakMap,Uct=new WeakMap,Hct=new WeakMap,Gct=new WeakMap,Yct=new WeakMap,Vct=new WeakMap,qct=new WeakMap,Xct=new WeakMap,$ct=new WeakSet;class Kct{static get _keyboardManager(){var t=Kct.prototype,e=t=>lit(Vct,t).contains(document.activeElement)&&"BUTTON"!==document.activeElement.tagName&&t.hasSomethingToControl(),r=(t,e)=>{var{target:r}=e;if(r instanceof HTMLInputElement){var{type:n}=r;return"text"!==n&&"number"!==n}return!0},n=this.TRANSLATE_SMALL,i=this.TRANSLATE_BIG;return Ilt(this,"_keyboardManager",new ict([[["ctrl+a","mac+meta+a"],t.selectAll,{checker:r}],[["ctrl+z","mac+meta+z"],t.undo,{checker:r}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],t.redo,{checker:r}],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete","mac+Delete"],t.delete,{checker:r}],[["Enter","mac+Enter"],t.addNewEditorFromKeyboard,{checker:(t,e)=>{var{target:r}=e;return!(r instanceof HTMLButtonElement)&&lit(Vct,t).contains(r)&&!t.isEnterHandled}}],[[" ","mac+ "],t.addNewEditorFromKeyboard,{checker:(t,e)=>{var{target:r}=e;return!(r instanceof HTMLButtonElement)&&lit(Vct,t).contains(document.activeElement)}}],[["Escape","mac+Escape"],t.unselectAll],[["ArrowLeft","mac+ArrowLeft"],t.translateSelectedEditors,{args:[-n,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t.translateSelectedEditors,{args:[-i,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t.translateSelectedEditors,{args:[n,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t.translateSelectedEditors,{args:[i,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t.translateSelectedEditors,{args:[0,-n],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t.translateSelectedEditors,{args:[0,-i],checker:e}],[["ArrowDown","mac+ArrowDown"],t.translateSelectedEditors,{args:[0,n],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t.translateSelectedEditors,{args:[0,i],checker:e}]]))}constructor(t,e,r,n,i,a,s,o,l,h,c,u,d){dit(this,$ct),hit(this,oct,new AbortController),hit(this,lct,null),hit(this,hct,new Map),hit(this,cct,new Map),hit(this,uct,null),hit(this,dct,null),hit(this,pct,null),hit(this,fct,new rct),hit(this,gct,null),hit(this,vct,null),hit(this,mct,0),hit(this,yct,new Set),hit(this,bct,null),hit(this,wct,null),hit(this,xct,new Set),pit(this,"_editorUndoBar",null),hit(this,Act,!1),hit(this,_ct,!1),hit(this,kct,!1),hit(this,Sct,null),hit(this,Ect,null),hit(this,Mct,null),hit(this,Tct,null),hit(this,Cct,!1),hit(this,Pct,null),hit(this,Ict,new Ght),hit(this,Rct,!1),hit(this,Oct,!1),hit(this,Lct,null),hit(this,Dct,null),hit(this,Fct,null),hit(this,Nct,null),hit(this,jct,Wot.NONE),hit(this,Bct,new Set),hit(this,zct,null),hit(this,Wct,null),hit(this,Uct,null),hit(this,Hct,{isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1}),hit(this,Gct,[0,0]),hit(this,Yct,null),hit(this,Vct,null),hit(this,qct,null),hit(this,Xct,null);var p=this._signal=lit(oct,this).signal;cit(Vct,this,t),cit(qct,this,e),cit(uct,this,r),this._eventBus=n,n._on("editingaction",this.onEditingAction.bind(this),{signal:p}),n._on("pagechanging",this.onPageChanging.bind(this),{signal:p}),n._on("scalechanging",this.onScaleChanging.bind(this),{signal:p}),n._on("rotationchanging",this.onRotationChanging.bind(this),{signal:p}),n._on("setpreference",this.onSetPreference.bind(this),{signal:p}),n._on("switchannotationeditorparams",(t=>this.updateParams(t.type,t.value)),{signal:p}),iit($ct,this,rut).call(this),iit($ct,this,hut).call(this),iit($ct,this,aut).call(this),cit(dct,this,i.annotationStorage),cit(Sct,this,i.filterFactory),cit(Wct,this,a),cit(Tct,this,s||null),cit(Act,this,o),cit(_ct,this,l),cit(kct,this,h),cit(Nct,this,c||null),this.viewParameters={realScale:Zlt.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=u||null,this._supportsPinchToZoom=!1!==d}destroy(){var t,e,r,n,i;for(var a of(null===(t=lit(Xct,this))||void 0===t||t.resolve(),cit(Xct,this,null),null===(e=lit(oct,this))||void 0===e||e.abort(),cit(oct,this,null),this._signal=null,lit(cct,this).values()))a.destroy();lit(cct,this).clear(),lit(hct,this).clear(),lit(xct,this).clear(),cit(lct,this,null),lit(Bct,this).clear(),lit(fct,this).destroy(),null===(r=lit(uct,this))||void 0===r||r.destroy(),null===(n=lit(Pct,this))||void 0===n||n.hide(),cit(Pct,this,null),lit(Ect,this)&&(clearTimeout(lit(Ect,this)),cit(Ect,this,null)),lit(Yct,this)&&(clearTimeout(lit(Yct,this)),cit(Yct,this,null)),null===(i=this._editorUndoBar)||void 0===i||i.destroy()}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return lit(Nct,this)}get useNewAltTextFlow(){return lit(_ct,this)}get useNewAltTextWhenAddingImage(){return lit(kct,this)}get hcmFilter(){return Ilt(this,"hcmFilter",lit(Wct,this)?lit(Sct,this).addHCMFilter(lit(Wct,this).foreground,lit(Wct,this).background):"none")}get direction(){return Ilt(this,"direction",getComputedStyle(lit(Vct,this)).direction)}get highlightColors(){return Ilt(this,"highlightColors",lit(Tct,this)?new Map(lit(Tct,this).split(",").map((t=>t.split("=").map((t=>t.trim()))))):null)}get highlightColorNames(){return Ilt(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,(t=>t.reverse()))):null)}setCurrentDrawingSession(t){t?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),cit(vct,this,t)}setMainHighlightColorPicker(t){cit(Fct,this,t)}editAltText(t){var e,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];null===(e=lit(uct,this))||void 0===e||e.editAltText(this,t,r)}switchToMode(t,e){this._eventBus.on("annotationeditormodechanged",e,{once:!0,signal:this._signal}),this._eventBus.dispatch("showannotationeditorui",{source:this,mode:t})}setPreference(t,e){this._eventBus.dispatch("setpreference",{source:this,name:t,value:e})}onSetPreference(t){var{name:e,value:r}=t;if("enableNewAltTextWhenAddingImage"===e)cit(kct,this,r)}onPageChanging(t){var{pageNumber:e}=t;cit(mct,this,e-1)}focusMainContainer(){lit(Vct,this).focus()}findParent(t,e){for(var r of lit(cct,this).values()){var{x:n,y:i,width:a,height:s}=r.div.getBoundingClientRect();if(t>=n&&t<=n+a&&e>=i&&e<=i+s)return r}return null}disableUserSelect(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];lit(qct,this).classList.toggle("noUserSelect",t)}addShouldRescale(t){lit(xct,this).add(t)}removeShouldRescale(t){lit(xct,this).delete(t)}onScaleChanging(t){var e,{scale:r}=t;for(var n of(this.commitOrRemove(),this.viewParameters.realScale=r*Zlt.PDF_TO_CSS_UNITS,lit(xct,this)))n.onScaleChanging();null===(e=lit(vct,this))||void 0===e||e.onScaleChanging()}onRotationChanging(t){var{pagesRotation:e}=t;this.commitOrRemove(),this.viewParameters.rotation=e}highlightSelection(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",e=document.getSelection();if(e&&!e.isCollapsed){var{anchorNode:r,anchorOffset:n,focusNode:i,focusOffset:a}=e,s=e.toString(),o=iit($ct,this,Qct).call(this,e).closest(".textLayer"),l=this.getSelectionBoxes(o);if(l){e.empty();var h=iit($ct,this,Jct).call(this,o),c=lit(jct,this)===Wot.NONE,u=()=>{null==h||h.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:l,anchorNode:r,anchorOffset:n,focusNode:i,focusOffset:a,text:s}),c&&this.showAllEditors("highlight",!0,!0)};c?this.switchToMode(Wot.HIGHLIGHT,u):u()}}}addToAnnotationStorage(t){t.isEmpty()||!lit(dct,this)||lit(dct,this).has(t.id)||lit(dct,this).setValue(t.id,t)}blur(){if(this.isShiftKeyDown=!1,lit(Cct,this)&&(cit(Cct,this,!1),iit($ct,this,eut).call(this,"main_toolbar")),this.hasSelection){var{activeElement:t}=document;for(var e of lit(Bct,this))if(e.div.contains(t)){cit(Dct,this,[e,t]),e._focusEventsAllowed=!1;break}}}focus(){if(lit(Dct,this)){var[t,e]=lit(Dct,this);cit(Dct,this,null),e.addEventListener("focusin",(()=>{t._focusEventsAllowed=!0}),{once:!0,signal:this._signal}),e.focus()}}addEditListeners(){iit($ct,this,aut).call(this),iit($ct,this,out).call(this)}removeEditListeners(){iit($ct,this,sut).call(this),iit($ct,this,lut).call(this)}dragOver(t){for(var{type:e}of t.dataTransfer.items)for(var r of lit(wct,this))if(r.isHandlingMimeForPasting(e))return t.dataTransfer.dropEffect="copy",void t.preventDefault()}drop(t){for(var e of t.dataTransfer.items)for(var r of lit(wct,this))if(r.isHandlingMimeForPasting(e.type))return r.paste(e,this.currentLayer),void t.preventDefault()}copy(t){var e;if(t.preventDefault(),null===(e=lit(lct,this))||void 0===e||e.commitOrRemove(),this.hasSelection){var r=[];for(var n of lit(Bct,this)){var i=n.serialize(!0);i&&r.push(i)}0!==r.length&&t.clipboardData.setData("application/pdfjs",JSON.stringify(r))}}cut(t){this.copy(t),this.delete()}paste(t){var e=this;return sit((function*(){t.preventDefault();var{clipboardData:r}=t;for(var n of r.items)for(var i of lit(wct,e))if(i.isHandlingMimeForPasting(n.type))return void i.paste(n,e.currentLayer);var a=r.getData("application/pdfjs");if(a){try{a=JSON.parse(a)}catch(t){return void Mlt('paste: "'.concat(t.message,'".'))}if(Array.isArray(a)){e.unselectAll();var s=e.currentLayer;try{var o=[];for(var l of a){var h=yield s.deserialize(l);if(!h)return;o.push(h)}e.addCommands({cmd:()=>{for(var t of o)iit($ct,e,gut).call(e,t);iit($ct,e,yut).call(e,o)},undo:()=>{for(var t of o)t.remove()},mustExec:!0})}catch(t){Mlt('paste: "'.concat(t.message,'".'))}}}}))()}keydown(t){this.isShiftKeyDown||"Shift"!==t.key||(this.isShiftKeyDown=!0),lit(jct,this)===Wot.NONE||this.isEditorHandlingKeyboard||Kct._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&"Shift"===t.key&&(this.isShiftKeyDown=!1,lit(Cct,this)&&(cit(Cct,this,!1),iit($ct,this,eut).call(this,"main_toolbar")))}onEditingAction(t){var{name:e}=t;switch(e){case"undo":case"redo":case"delete":case"selectAll":this[e]();break;case"highlightSelection":this.highlightSelection("context_menu")}}setEditingState(t){t?(iit($ct,this,nut).call(this),iit($ct,this,out).call(this),iit($ct,this,cut).call(this,{isEditing:lit(jct,this)!==Wot.NONE,isEmpty:iit($ct,this,mut).call(this),hasSomethingToUndo:lit(fct,this).hasSomethingToUndo(),hasSomethingToRedo:lit(fct,this).hasSomethingToRedo(),hasSelectedEditor:!1})):(iit($ct,this,iut).call(this),iit($ct,this,lut).call(this),iit($ct,this,cut).call(this,{isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!lit(wct,this))for(var e of(cit(wct,this,t),lit(wct,this)))iit($ct,this,uut).call(this,e.defaultPropertiesToUpdate)}getId(){return lit(Ict,this).id}get currentLayer(){return lit(cct,this).get(lit(mct,this))}getLayer(t){return lit(cct,this).get(t)}get currentPageIndex(){return lit(mct,this)}addLayer(t){lit(cct,this).set(t.pageIndex,t),lit(Rct,this)?t.enable():t.disable()}removeLayer(t){lit(cct,this).delete(t.pageIndex)}updateMode(t){var e=arguments,r=this;return sit((function*(){var n=e.length>1&&void 0!==e[1]?e[1]:null,i=e.length>2&&void 0!==e[2]&&e[2];if(lit(jct,r)!==t&&(!lit(Xct,r)||(yield lit(Xct,r).promise,lit(Xct,r)))){var a;if(cit(Xct,r,Promise.withResolvers()),cit(jct,r,t),t===Wot.NONE)return r.setEditingState(!1),iit($ct,r,fut).call(r),null===(a=r._editorUndoBar)||void 0===a||a.hide(),void lit(Xct,r).resolve();for(var s of(r.setEditingState(!0),yield iit($ct,r,dut).call(r),r.unselectAll(),lit(cct,r).values()))s.updateMode(t);if(!n)return i&&r.addNewEditorFromKeyboard(),void lit(Xct,r).resolve();for(var o of lit(hct,r).values())o.annotationElementId===n?(r.setSelected(o),o.enterInEditMode()):o.unselect();lit(Xct,r).resolve()}}))()}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t!==lit(jct,this)&&this._eventBus.dispatch("switchannotationeditormode",{source:this,mode:t})}updateParams(t,e){var r;if(lit(wct,this)){switch(t){case Uot.CREATE:return void this.currentLayer.addNewEditor();case Uot.HIGHLIGHT_DEFAULT_COLOR:null===(r=lit(Fct,this))||void 0===r||r.updateColor(e);break;case Uot.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(lit(Uct,this)||cit(Uct,this,new Map)).set(t,e),this.showAllEditors("highlight",e)}for(var n of lit(Bct,this))n.updateParams(t,e);for(var i of lit(wct,this))i.updateDefaultParams(t,e)}}showAllEditors(t,e){var r,n;for(var i of lit(hct,this).values())i.editorType===t&&i.show(e);(null===(r=null===(n=lit(Uct,this))||void 0===n?void 0:n.get(Uot.HIGHLIGHT_SHOW_ALL))||void 0===r||r)!==e&&iit($ct,this,uut).call(this,[[Uot.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(lit(Oct,this)!==t)for(var e of(cit(Oct,this,t),lit(cct,this).values()))t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}getEditors(t){var e=[];for(var r of lit(hct,this).values())r.pageIndex===t&&e.push(r);return e}getEditor(t){return lit(hct,this).get(t)}addEditor(t){lit(hct,this).set(t.id,t)}removeEditor(t){var e;(t.div.contains(document.activeElement)&&(lit(Ect,this)&&clearTimeout(lit(Ect,this)),cit(Ect,this,setTimeout((()=>{this.focusMainContainer(),cit(Ect,this,null)}),0))),lit(hct,this).delete(t.id),this.unselect(t),t.annotationElementId&&lit(yct,this).has(t.annotationElementId))||(null===(e=lit(dct,this))||void 0===e||e.remove(t.id))}addDeletedAnnotationElement(t){lit(yct,this).add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return lit(yct,this).has(t)}removeDeletedAnnotationElement(t){lit(yct,this).delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}setActiveEditor(t){lit(lct,this)!==t&&(cit(lct,this,t),t&&iit($ct,this,uut).call(this,t.propertiesToUpdate))}updateUI(t){uit($ct,this,vut)===t&&iit($ct,this,uut).call(this,t.propertiesToUpdate)}updateUIForDefaultProperties(t){iit($ct,this,uut).call(this,t.defaultPropertiesToUpdate)}toggleSelected(t){if(lit(Bct,this).has(t))return lit(Bct,this).delete(t),t.unselect(),void iit($ct,this,cut).call(this,{hasSelectedEditor:this.hasSelection});lit(Bct,this).add(t),t.select(),iit($ct,this,uut).call(this,t.propertiesToUpdate),iit($ct,this,cut).call(this,{hasSelectedEditor:!0})}setSelected(t){var e;for(var r of(null===(e=lit(vct,this))||void 0===e||e.commitOrRemove(),lit(Bct,this)))r!==t&&r.unselect();lit(Bct,this).clear(),lit(Bct,this).add(t),t.select(),iit($ct,this,uut).call(this,t.propertiesToUpdate),iit($ct,this,cut).call(this,{hasSelectedEditor:!0})}isSelected(t){return lit(Bct,this).has(t)}get firstSelectedEditor(){return lit(Bct,this).values().next().value}unselect(t){t.unselect(),lit(Bct,this).delete(t),iit($ct,this,cut).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return 0!==lit(Bct,this).size}get isEnterHandled(){return 1===lit(Bct,this).size&&this.firstSelectedEditor.isEnterHandled}undo(){var t;lit(fct,this).undo(),iit($ct,this,cut).call(this,{hasSomethingToUndo:lit(fct,this).hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:iit($ct,this,mut).call(this)}),null===(t=this._editorUndoBar)||void 0===t||t.hide()}redo(){lit(fct,this).redo(),iit($ct,this,cut).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:lit(fct,this).hasSomethingToRedo(),isEmpty:iit($ct,this,mut).call(this)})}addCommands(t){lit(fct,this).add(t),iit($ct,this,cut).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:iit($ct,this,mut).call(this)})}cleanUndoStack(t){lit(fct,this).cleanType(t)}delete(){var t;this.commitOrRemove();var e=null===(t=this.currentLayer)||void 0===t?void 0:t.endDrawingSession(!0);if(this.hasSelection||e){var r=e?[e]:[...lit(Bct,this)],n=()=>{for(var t of r)iit($ct,this,gut).call(this,t)};this.addCommands({cmd:()=>{var t;for(var e of(null===(t=this._editorUndoBar)||void 0===t||t.show(n,1===r.length?r[0].editorType:r.length),r))e.remove()},undo:n,mustExec:!0})}}commitOrRemove(){var t;null===(t=lit(lct,this))||void 0===t||t.commitOrRemove()}hasSomethingToControl(){return lit(lct,this)||this.hasSelection}selectAll(){for(var t of lit(Bct,this))t.commit();iit($ct,this,yut).call(this,lit(hct,this).values())}unselectAll(){var t;if((!lit(lct,this)||(lit(lct,this).commitOrRemove(),lit(jct,this)===Wot.NONE))&&(null===(t=lit(vct,this))||void 0===t||!t.commitOrRemove())&&this.hasSelection){for(var e of lit(Bct,this))e.unselect();lit(Bct,this).clear(),iit($ct,this,cut).call(this,{hasSelectedEditor:!1})}}translateSelectedEditors(t,e){if(arguments.length>2&&void 0!==arguments[2]&&arguments[2]||this.commitOrRemove(),this.hasSelection){lit(Gct,this)[0]+=t,lit(Gct,this)[1]+=e;var[r,n]=lit(Gct,this),i=[...lit(Bct,this)];for(var a of(lit(Yct,this)&&clearTimeout(lit(Yct,this)),cit(Yct,this,setTimeout((()=>{cit(Yct,this,null),lit(Gct,this)[0]=lit(Gct,this)[1]=0,this.addCommands({cmd:()=>{for(var t of i)lit(hct,this).has(t.id)&&t.translateInPage(r,n)},undo:()=>{for(var t of i)lit(hct,this).has(t.id)&&t.translateInPage(-r,-n)},mustExec:!1})}),1e3)),i))a.translateInPage(t,e)}}setUpDragSession(){if(this.hasSelection)for(var t of(this.disableUserSelect(!0),cit(bct,this,new Map),lit(Bct,this)))lit(bct,this).set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}endDragSession(){if(!lit(bct,this))return!1;this.disableUserSelect(!1);var t=lit(bct,this);cit(bct,this,null);var e=!1;for(var[{x:r,y:n,pageIndex:i},a]of t)a.newX=r,a.newY=n,a.newPageIndex=i,e||(e=r!==a.savedX||n!==a.savedY||i!==a.savedPageIndex);if(!e)return!1;var s=(t,e,r,n)=>{if(lit(hct,this).has(t.id)){var i=lit(cct,this).get(n);i?t._setParentAndPosition(i,e,r):(t.pageIndex=n,t.x=e,t.y=r)}};return this.addCommands({cmd:()=>{for(var[e,{newX:r,newY:n,newPageIndex:i}]of t)s(e,r,n,i)},undo:()=>{for(var[e,{savedX:r,savedY:n,savedPageIndex:i}]of t)s(e,r,n,i)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(lit(bct,this))for(var r of lit(bct,this).keys())r.drag(t,e)}rebuild(t){if(null===t.parent){var e=this.getLayer(t.pageIndex);e?(e.changeParent(t),e.addOrRebuild(t)):(this.addEditor(t),this.addToAnnotationStorage(t),t.rebuild())}else t.parent.addOrRebuild(t)}get isEditorHandlingKeyboard(){var t;return(null===(t=this.getActive())||void 0===t?void 0:t.shouldGetKeyboardEvents())||1===lit(Bct,this).size&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return lit(lct,this)===t}getActive(){return lit(lct,this)}getMode(){return lit(jct,this)}get imageManager(){return Ilt(this,"imageManager",new $ht)}getSelectionBoxes(t){if(!t)return null;for(var e=document.getSelection(),r=0,n=e.rangeCount;r<n;r++)if(!t.contains(e.getRangeAt(r).commonAncestorContainer))return null;var i,{x:a,y:s,width:o,height:l}=t.getBoundingClientRect();switch(t.getAttribute("data-main-rotation")){case"90":i=(t,e,r,n)=>({x:(e-s)/l,y:1-(t+r-a)/o,width:n/l,height:r/o});break;case"180":i=(t,e,r,n)=>({x:1-(t+r-a)/o,y:1-(e+n-s)/l,width:r/o,height:n/l});break;case"270":i=(t,e,r,n)=>({x:1-(e+n-s)/l,y:(t-a)/o,width:n/l,height:r/o});break;default:i=(t,e,r,n)=>({x:(t-a)/o,y:(e-s)/l,width:r/o,height:n/l})}for(var h=[],c=0,u=e.rangeCount;c<u;c++){var d=e.getRangeAt(c);if(!d.collapsed)for(var{x:p,y:f,width:g,height:v}of d.getClientRects())0!==g&&0!==v&&h.push(i(p,f,g,v))}return 0===h.length?null:h}addChangedExistingAnnotation(t){var{annotationElementId:e,id:r}=t;(lit(pct,this)||cit(pct,this,new Map)).set(e,r)}removeChangedExistingAnnotation(t){var e,{annotationElementId:r}=t;null===(e=lit(pct,this))||void 0===e||e.delete(r)}renderAnnotationElement(t){var e,r=null===(e=lit(pct,this))||void 0===e?void 0:e.get(t.data.id);if(r){var n=lit(dct,this).getRawValue(r);n&&(lit(jct,this)!==Wot.NONE||n.hasBeenModified)&&n.renderAnnotationElement(t)}}}function Qct(t){var{anchorNode:e}=t;return e.nodeType===Node.TEXT_NODE?e.parentElement:e}function Jct(t){var{currentLayer:e}=this;if(e.hasTextLayer(t))return e;for(var r of lit(cct,this).values())if(r.hasTextLayer(t))return r;return null}function Zct(){var t=document.getSelection();if(t&&!t.isCollapsed){var e=iit($ct,this,Qct).call(this,t).closest(".textLayer"),r=this.getSelectionBoxes(e);r&&(lit(Pct,this)||cit(Pct,this,new jht(this)),lit(Pct,this).show(e,r,"ltr"===this.direction))}}function tut(){var t,e=document.getSelection();if(e&&!e.isCollapsed){var{anchorNode:r}=e;if(r!==lit(zct,this)){var n,i=iit($ct,this,Qct).call(this,e).closest(".textLayer");if(i){if(null===(t=lit(Pct,this))||void 0===t||t.hide(),cit(zct,this,r),iit($ct,this,cut).call(this,{hasSelectedText:!0}),(lit(jct,this)===Wot.HIGHLIGHT||lit(jct,this)===Wot.NONE)&&(lit(jct,this)===Wot.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),cit(Cct,this,this.isShiftKeyDown),!this.isShiftKeyDown)){var a=lit(jct,this)===Wot.HIGHLIGHT?iit($ct,this,Jct).call(this,i):null;null==a||a.toggleDrawing();var s=new AbortController,o=this.combinedSignal(s),l=t=>{"pointerup"===t.type&&0!==t.button||(s.abort(),null==a||a.toggleDrawing(!0),"pointerup"===t.type&&iit($ct,this,eut).call(this,"main_toolbar"))};window.addEventListener("pointerup",l,{signal:o}),window.addEventListener("blur",l,{signal:o})}}else lit(zct,this)&&(null===(n=lit(Pct,this))||void 0===n||n.hide(),cit(zct,this,null),iit($ct,this,cut).call(this,{hasSelectedText:!1}))}}else{var h;lit(zct,this)&&(null===(h=lit(Pct,this))||void 0===h||h.hide(),cit(zct,this,null),iit($ct,this,cut).call(this,{hasSelectedText:!1}))}}function eut(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";lit(jct,this)===Wot.HIGHLIGHT?this.highlightSelection(t):lit(Act,this)&&iit($ct,this,Zct).call(this)}function rut(){document.addEventListener("selectionchange",iit($ct,this,tut).bind(this),{signal:this._signal})}function nut(){if(!lit(Mct,this)){cit(Mct,this,new AbortController);var t=this.combinedSignal(lit(Mct,this));window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})}}function iut(){var t;null===(t=lit(Mct,this))||void 0===t||t.abort(),cit(Mct,this,null)}function aut(){if(!lit(Lct,this)){cit(Lct,this,new AbortController);var t=this.combinedSignal(lit(Lct,this));window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})}}function sut(){var t;null===(t=lit(Lct,this))||void 0===t||t.abort(),cit(Lct,this,null)}function out(){if(!lit(gct,this)){cit(gct,this,new AbortController);var t=this.combinedSignal(lit(gct,this));document.addEventListener("copy",this.copy.bind(this),{signal:t}),document.addEventListener("cut",this.cut.bind(this),{signal:t}),document.addEventListener("paste",this.paste.bind(this),{signal:t})}}function lut(){var t;null===(t=lit(gct,this))||void 0===t||t.abort(),cit(gct,this,null)}function hut(){var t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})}function cut(t){var e=Object.entries(t).some((t=>{var[e,r]=t;return lit(Hct,this)[e]!==r}));e&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(lit(Hct,this),t)}),lit(jct,this)===Wot.HIGHLIGHT&&!1===t.hasSelectedEditor&&iit($ct,this,uut).call(this,[[Uot.HIGHLIGHT_FREE,!0]]))}function uut(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})}function dut(){return put.apply(this,arguments)}function put(){return(put=sit((function*(){if(!lit(Rct,this)){cit(Rct,this,!0);var t=[];for(var e of lit(cct,this).values())t.push(e.enable());for(var r of(yield Promise.all(t),lit(hct,this).values()))r.enable()}}))).apply(this,arguments)}function fut(){if(this.unselectAll(),lit(Rct,this)){for(var t of(cit(Rct,this,!1),lit(cct,this).values()))t.disable();for(var e of lit(hct,this).values())e.disable()}}function gut(t){var e=lit(cct,this).get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))}function vut(t){var e=null;for(e of lit(Bct,t));return e}function mut(){if(0===lit(hct,this).size)return!0;if(1===lit(hct,this).size)for(var t of lit(hct,this).values())return t.isEmpty();return!1}function yut(t){for(var e of lit(Bct,this))e.unselect();for(var r of(lit(Bct,this).clear(),t))r.isEmpty()||(lit(Bct,this).add(r),r.select());iit($ct,this,cut).call(this,{hasSelectedEditor:this.hasSelection})}pit(Kct,"TRANSLATE_SMALL",1),pit(Kct,"TRANSLATE_BIG",10);var but=new WeakMap,wut=new WeakMap,xut=new WeakMap,Aut=new WeakMap,_ut=new WeakMap,kut=new WeakMap,Sut=new WeakMap,Eut=new WeakMap,Mut=new WeakMap,Tut=new WeakMap,Cut=new WeakMap,Put=new WeakMap,Iut=new WeakSet;class Rut{constructor(t){dit(this,Iut),hit(this,but,null),hit(this,wut,!1),hit(this,xut,null),hit(this,Aut,null),hit(this,_ut,null),hit(this,kut,null),hit(this,Sut,!1),hit(this,Eut,null),hit(this,Mut,null),hit(this,Tut,null),hit(this,Cut,null),hit(this,Put,!1),cit(Mut,this,t),cit(Put,this,t._uiManager.useNewAltTextFlow),Fut._||(Fut._=Object.freeze({added:"pdfjs-editor-new-alt-text-added-button","added-label":"pdfjs-editor-new-alt-text-added-button-label",missing:"pdfjs-editor-new-alt-text-missing-button","missing-label":"pdfjs-editor-new-alt-text-missing-button-label",review:"pdfjs-editor-new-alt-text-to-review-button","review-label":"pdfjs-editor-new-alt-text-to-review-button-label"}))}static initialize(t){var e;null!==(e=Rut._l10n)&&void 0!==e||(Rut._l10n=t)}render(){var t=this;return sit((function*(){var e=cit(xut,t,document.createElement("button"));e.className="altText",e.tabIndex="0";var r=cit(Aut,t,document.createElement("span"));e.append(r),lit(Put,t)?(e.classList.add("new"),e.setAttribute("data-l10n-id",Fut._.missing),r.setAttribute("data-l10n-id",Fut._["missing-label"])):(e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),r.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));var n=lit(Mut,t)._uiManager._signal;e.addEventListener("contextmenu",cht,{signal:n}),e.addEventListener("pointerdown",(t=>t.stopPropagation()),{signal:n});var i=e=>{e.preventDefault(),lit(Mut,t)._uiManager.editAltText(lit(Mut,t)),lit(Put,t)&&lit(Mut,t)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:uit(Iut,t,Out)}})};return e.addEventListener("click",i,{capture:!0,signal:n}),e.addEventListener("keydown",(r=>{r.target===e&&"Enter"===r.key&&(cit(Sut,t,!0),i(r))}),{signal:n}),yield iit(Iut,t,Lut).call(t),e}))()}finish(){lit(xut,this)&&(lit(xut,this).focus({focusVisible:lit(Sut,this)}),cit(Sut,this,!1))}isEmpty(){return lit(Put,this)?null===lit(but,this):!lit(but,this)&&!lit(wut,this)}hasData(){return lit(Put,this)?null!==lit(but,this)||!!lit(Tut,this):this.isEmpty()}get guessedText(){return lit(Tut,this)}setGuessedText(t){var e=this;return sit((function*(){null===lit(but,e)&&(cit(Tut,e,t),cit(Cut,e,yield Rut._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t})),iit(Iut,e,Lut).call(e))}))()}toggleAltTextBadge(){var t,e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(!lit(Put,this)||lit(but,this))return null===(t=lit(Eut,this))||void 0===t||t.remove(),void cit(Eut,this,null);if(!lit(Eut,this)){var r=cit(Eut,this,document.createElement("div"));r.className="noAltTextBadge",lit(Mut,this).div.append(r)}lit(Eut,this).classList.toggle("hidden",!e)}serialize(t){var e=lit(but,this);return t||lit(Tut,this)!==e||(e=lit(Cut,this)),{altText:e,decorative:lit(wut,this),guessedText:lit(Tut,this),textWithDisclaimer:lit(Cut,this)}}get data(){return{altText:lit(but,this),decorative:lit(wut,this)}}set data(t){var{altText:e,decorative:r,guessedText:n,textWithDisclaimer:i,cancel:a=!1}=t;n&&(cit(Tut,this,n),cit(Cut,this,i)),lit(but,this)===e&&lit(wut,this)===r||(a||(cit(but,this,e),cit(wut,this,r)),iit(Iut,this,Lut).call(this))}toggle(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];lit(xut,this)&&(!t&&lit(kut,this)&&(clearTimeout(lit(kut,this)),cit(kut,this,null)),lit(xut,this).disabled=!t)}shown(){lit(Mut,this)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:uit(Iut,this,Out)}})}destroy(){var t,e;null===(t=lit(xut,this))||void 0===t||t.remove(),cit(xut,this,null),cit(Aut,this,null),cit(_ut,this,null),null===(e=lit(Eut,this))||void 0===e||e.remove(),cit(Eut,this,null)}}function Out(t){return(lit(but,t)?"added":null===lit(but,t)&&t.guessedText&&"review")||"missing"}function Lut(){return Dut.apply(this,arguments)}function Dut(){return(Dut=sit((function*(){var t=lit(xut,this);if(t){if(lit(Put,this)){var e,r;if(t.classList.toggle("done",!!lit(but,this)),t.setAttribute("data-l10n-id",Fut._[uit(Iut,this,Out)]),null===(e=lit(Aut,this))||void 0===e||e.setAttribute("data-l10n-id",Fut._["".concat(uit(Iut,this,Out),"-label")]),!lit(but,this))return void(null===(r=lit(_ut,this))||void 0===r||r.remove())}else{var n;if(!lit(but,this)&&!lit(wut,this))return t.classList.remove("done"),void(null===(n=lit(_ut,this))||void 0===n||n.remove());t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}var i=lit(_ut,this);if(!i){cit(_ut,this,i=document.createElement("span")),i.className="tooltip",i.setAttribute("role","tooltip"),i.id="alt-text-tooltip-".concat(lit(Mut,this).id);var a=lit(Mut,this)._uiManager._signal;a.addEventListener("abort",(()=>{clearTimeout(lit(kut,this)),cit(kut,this,null)}),{once:!0}),t.addEventListener("mouseenter",(()=>{cit(kut,this,setTimeout((()=>{cit(kut,this,null),lit(_ut,this).classList.add("show"),lit(Mut,this)._reportTelemetry({action:"alt_text_tooltip"})}),100))}),{signal:a}),t.addEventListener("mouseleave",(()=>{var t;lit(kut,this)&&(clearTimeout(lit(kut,this)),cit(kut,this,null)),null===(t=lit(_ut,this))||void 0===t||t.classList.remove("show")}),{signal:a})}lit(wut,this)?i.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(i.removeAttribute("data-l10n-id"),i.textContent=lit(but,this)),i.parentNode||t.append(i);var s=lit(Mut,this).getImageForAltText();null==s||s.setAttribute("aria-describedby",i.id)}}))).apply(this,arguments)}var Fut={_:null};pit(Rut,"_l10n",null);var Nut=new WeakMap,jut=new WeakMap,But=new WeakMap,zut=new WeakMap,Wut=new WeakMap,Uut=new WeakMap,Hut=new WeakMap,Gut=new WeakMap,Yut=new WeakMap,Vut=new WeakMap,qut=new WeakMap,Xut=new WeakSet;class $ut{constructor(t){var{container:e,isPinchingDisabled:r=null,isPinchingStopped:n=null,onPinchStart:i=null,onPinching:a=null,onPinchEnd:s=null,signal:o}=t;dit(this,Xut),hit(this,Nut,void 0),hit(this,jut,!1),hit(this,But,null),hit(this,zut,void 0),hit(this,Wut,void 0),hit(this,Uut,void 0),hit(this,Hut,void 0),hit(this,Gut,void 0),hit(this,Yut,null),hit(this,Vut,void 0),hit(this,qut,null),cit(Nut,this,e),cit(But,this,n),cit(zut,this,r),cit(Wut,this,i),cit(Uut,this,a),cit(Hut,this,s),cit(Vut,this,new AbortController),cit(Gut,this,AbortSignal.any([o,lit(Vut,this).signal])),e.addEventListener("touchstart",iit(Xut,this,Kut).bind(this),{passive:!1,signal:lit(Gut,this)})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return Ilt(this,"MIN_TOUCH_DISTANCE_TO_PINCH",35/(window.devicePixelRatio||1))}destroy(){var t;null===(t=lit(Vut,this))||void 0===t||t.abort(),cit(Vut,this,null)}}function Kut(t){var e,r;if(!(null!==(e=lit(zut,this))&&void 0!==e&&e.call(this)||t.touches.length<2)){if(!lit(qut,this)){var n;cit(qut,this,new AbortController);var i=AbortSignal.any([lit(Gut,this),lit(qut,this).signal]),a=lit(Nut,this),s={signal:i,passive:!1};a.addEventListener("touchmove",iit(Xut,this,Qut).bind(this),s),a.addEventListener("touchend",iit(Xut,this,Jut).bind(this),s),a.addEventListener("touchcancel",iit(Xut,this,Jut).bind(this),s),null===(n=lit(Wut,this))||void 0===n||n.call(this)}if(uht(t),2!==t.touches.length||null!==(r=lit(But,this))&&void 0!==r&&r.call(this))cit(Yut,this,null);else{var[o,l]=t.touches;o.identifier>l.identifier&&([o,l]=[l,o]),cit(Yut,this,{touch0X:o.screenX,touch0Y:o.screenY,touch1X:l.screenX,touch1Y:l.screenY})}}}function Qut(t){var e;if(lit(Yut,this)&&2===t.touches.length){var[r,n]=t.touches;r.identifier>n.identifier&&([r,n]=[n,r]);var{screenX:i,screenY:a}=r,{screenX:s,screenY:o}=n,l=lit(Yut,this),{touch0X:h,touch0Y:c,touch1X:u,touch1Y:d}=l,p=u-h,f=d-c,g=s-i,v=o-a,m=Math.hypot(g,v)||1,y=Math.hypot(p,f)||1;if(lit(jut,this)||!(Math.abs(y-m)<=fot.MIN_TOUCH_DISTANCE_TO_PINCH))if(l.touch0X=i,l.touch0Y=a,l.touch1X=s,l.touch1Y=o,t.preventDefault(),lit(jut,this)){var b=[(i+s)/2,(a+o)/2];null===(e=lit(Uut,this))||void 0===e||e.call(this,b,y,m)}else cit(jut,this,!0)}}function Jut(t){var e;lit(qut,this).abort(),cit(qut,this,null),null===(e=lit(Hut,this))||void 0===e||e.call(this),lit(Yut,this)&&(t.preventDefault(),cit(Yut,this,null),cit(jut,this,!1))}fot=$ut;var Zut=new WeakMap,tdt=new WeakMap,edt=new WeakMap,rdt=new WeakMap,ndt=new WeakMap,idt=new WeakMap,adt=new WeakMap,sdt=new WeakMap,odt=new WeakMap,ldt=new WeakMap,hdt=new WeakMap,cdt=new WeakMap,udt=new WeakMap,ddt=new WeakMap,pdt=new WeakMap,fdt=new WeakMap,gdt=new WeakMap,vdt=new WeakMap,mdt=new WeakMap,ydt=new WeakMap,bdt=new WeakMap,wdt=new WeakMap,xdt=new WeakMap,Adt=new WeakMap,_dt=new WeakSet;class kdt{static get _resizerKeyboardManager(){var t=kdt.prototype._resizeWithKeyboard,e=Kct.TRANSLATE_SMALL,r=Kct.TRANSLATE_BIG;return Ilt(this,"_resizerKeyboardManager",new ict([[["ArrowLeft","mac+ArrowLeft"],t,{args:[-e,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t,{args:[-r,0]}],[["ArrowRight","mac+ArrowRight"],t,{args:[e,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t,{args:[r,0]}],[["ArrowUp","mac+ArrowUp"],t,{args:[0,-e]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t,{args:[0,-r]}],[["ArrowDown","mac+ArrowDown"],t,{args:[0,e]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t,{args:[0,r]}],[["Escape","mac+Escape"],kdt.prototype._stopResizingWithKeyboard]]))}constructor(t){dit(this,_dt),hit(this,Zut,null),hit(this,tdt,null),hit(this,edt,null),hit(this,rdt,!1),hit(this,ndt,null),hit(this,idt,""),hit(this,adt,!1),hit(this,sdt,null),hit(this,odt,null),hit(this,ldt,null),hit(this,hdt,null),hit(this,cdt,""),hit(this,udt,!1),hit(this,ddt,null),hit(this,pdt,!1),hit(this,fdt,!1),hit(this,gdt,!1),hit(this,vdt,null),hit(this,mdt,0),hit(this,ydt,0),hit(this,bdt,null),hit(this,wdt,null),pit(this,"_editToolbar",null),pit(this,"_initialOptions",Object.create(null)),pit(this,"_initialData",null),pit(this,"_isVisible",!0),pit(this,"_uiManager",null),pit(this,"_focusEventsAllowed",!0),hit(this,xdt,!1),hit(this,Adt,kdt._zIndex++),this.parent=t.parent,this.id=t.id,this.width=this.height=null,this.pageIndex=t.parent.pageIndex,this.name=t.name,this.div=null,this._uiManager=t.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=t.isCentered,this._structTreeParentId=null;var{rotation:e,rawDims:{pageWidth:r,pageHeight:n,pageX:i,pageY:a}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[r,n],this.pageTranslation=[i,a];var[s,o]=this.parentDimensions;this.x=t.x/s,this.y=t.y/o,this.isAttachedToDOM=!1,this.deleted=!1}get editorType(){return Object.getPrototypeOf(this).constructor._type}static get isDrawer(){return!1}static get _defaultLineColor(){return Ilt(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){var e=new Gdt({id:t.parent.getNextId(),parent:t.parent,uiManager:t._uiManager});e.annotationElementId=t.annotationElementId,e.deleted=!0,e._uiManager.addToAnnotationStorage(e)}static initialize(t,e){var r;if(null!==(r=kdt._l10n)&&void 0!==r||(kdt._l10n=t),kdt._l10nResizer||(kdt._l10nResizer=Object.freeze({topLeft:"pdfjs-editor-resizer-top-left",topMiddle:"pdfjs-editor-resizer-top-middle",topRight:"pdfjs-editor-resizer-top-right",middleRight:"pdfjs-editor-resizer-middle-right",bottomRight:"pdfjs-editor-resizer-bottom-right",bottomMiddle:"pdfjs-editor-resizer-bottom-middle",bottomLeft:"pdfjs-editor-resizer-bottom-left",middleLeft:"pdfjs-editor-resizer-middle-left"})),-1===kdt._borderLineWidth){var n=getComputedStyle(document.documentElement);kdt._borderLineWidth=parseFloat(n.getPropertyValue("--outline-width"))||0}}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){Tlt("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return lit(xdt,this)}set _isDraggable(t){var e;cit(xdt,this,t),null===(e=this.div)||void 0===e||e.classList.toggle("draggable",t)}get isEnterHandled(){return!0}center(){var[t,e]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*e/(2*t),this.y+=this.width*t/(2*e);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*e/(2*t),this.y-=this.width*t/(2*e);break;default:this.x-=this.width/2,this.y-=this.height/2}this.fixAndSetPosition()}addCommands(t){this._uiManager.addCommands(t)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=lit(Adt,this)}setParent(t){null!==t?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):iit(_dt,this,Hdt).call(this),this.parent=t}focusin(t){this._focusEventsAllowed&&(lit(udt,this)?cit(udt,this,!1):this.parent.setSelected(this))}focusout(t){var e;if(this._focusEventsAllowed&&this.isAttachedToDOM){var r=t.relatedTarget;null!=r&&r.closest("#".concat(this.id))||(t.preventDefault(),null!==(e=this.parent)&&void 0!==e&&e.isMultipleSelection||this.commitOrRemove())}}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(t,e,r,n){var[i,a]=this.parentDimensions;[r,n]=this.screenToPageTranslation(r,n),this.x=(t+r)/i,this.y=(e+n)/a,this.fixAndSetPosition()}translate(t,e){iit(_dt,this,Sdt).call(this,this.parentDimensions,t,e)}translateInPage(t,e){lit(ddt,this)||cit(ddt,this,[this.x,this.y,this.width,this.height]),iit(_dt,this,Sdt).call(this,this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}drag(t,e){lit(ddt,this)||cit(ddt,this,[this.x,this.y,this.width,this.height]);var{div:r,parentDimensions:[n,i]}=this;if(this.x+=t/n,this.y+=e/i,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){var{x:a,y:s}=this.div.getBoundingClientRect();this.parent.findNewParent(this,a,s)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}var{x:o,y:l}=this,[h,c]=this.getBaseTranslation();o+=h,l+=c;var{style:u}=r;u.left="".concat((100*o).toFixed(2),"%"),u.top="".concat((100*l).toFixed(2),"%"),this._onTranslating(o,l),r.scrollIntoView({block:"nearest"})}_onTranslating(t,e){}_onTranslated(t,e){}get _hasBeenMoved(){return!!lit(ddt,this)&&(lit(ddt,this)[0]!==this.x||lit(ddt,this)[1]!==this.y)}get _hasBeenResized(){return!!lit(ddt,this)&&(lit(ddt,this)[2]!==this.width||lit(ddt,this)[3]!==this.height)}getBaseTranslation(){var[t,e]=this.parentDimensions,{_borderLineWidth:r}=kdt,n=r/t,i=r/e;switch(this.rotation){case 90:return[-n,i];case 180:return[n,i];case 270:return[n,-i];default:return[-n,-i]}}get _mustFixPosition(){return!0}fixAndSetPosition(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.rotation,{div:{style:e},pageDimensions:[r,n]}=this,{x:i,y:a,width:s,height:o}=this;if(s*=r,o*=n,i*=r,a*=n,this._mustFixPosition)switch(t){case 0:i=Math.max(0,Math.min(r-s,i)),a=Math.max(0,Math.min(n-o,a));break;case 90:i=Math.max(0,Math.min(r-o,i)),a=Math.min(n,Math.max(s,a));break;case 180:i=Math.min(r,Math.max(s,i)),a=Math.min(n,Math.max(o,a));break;case 270:i=Math.min(r,Math.max(o,i)),a=Math.max(0,Math.min(n-s,a))}this.x=i/=r,this.y=a/=n;var[l,h]=this.getBaseTranslation();i+=l,a+=h,e.left="".concat((100*i).toFixed(2),"%"),e.top="".concat((100*a).toFixed(2),"%"),this.moveInDOM()}screenToPageTranslation(t,e){return Edt.call(kdt,t,e,this.parentRotation)}pageTranslationToScreen(t,e){return Edt.call(kdt,t,e,360-this.parentRotation)}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){var{parentScale:t,pageDimensions:[e,r]}=this;return[e*t,r*t]}setDims(t,e){var[r,n]=this.parentDimensions,{style:i}=this.div;i.width="".concat((100*t/r).toFixed(2),"%"),lit(adt,this)||(i.height="".concat((100*e/n).toFixed(2),"%"))}fixDims(){var{style:t}=this.div,{height:e,width:r}=t,n=r.endsWith("%"),i=!lit(adt,this)&&e.endsWith("%");if(!n||!i){var[a,s]=this.parentDimensions;n||(t.width="".concat((100*parseFloat(r)/a).toFixed(2),"%")),lit(adt,this)||i||(t.height="".concat((100*parseFloat(e)/s).toFixed(2),"%"))}}getInitialTranslation(){return[0,0]}_onResized(){}static _round(t){return Math.round(1e4*t)/1e4}_onResizing(){}altTextFinish(){var t;null===(t=lit(edt,this))||void 0===t||t.finish()}addEditToolbar(){var t=this;return sit((function*(){return t._editToolbar||lit(fdt,t)||(t._editToolbar=new Eht(t),t.div.append(t._editToolbar.render()),lit(edt,t)&&(yield t._editToolbar.addAltText(lit(edt,t)))),t._editToolbar}))()}removeEditToolbar(){var t;this._editToolbar&&(this._editToolbar.remove(),this._editToolbar=null,null===(t=lit(edt,this))||void 0===t||t.destroy())}addContainer(t){var e,r=null===(e=this._editToolbar)||void 0===e?void 0:e.div;r?r.before(t):this.div.append(t)}getClientDimensions(){return this.div.getBoundingClientRect()}addAltTextButton(){var t=this;return sit((function*(){lit(edt,t)||(Rut.initialize(kdt._l10n),cit(edt,t,new Rut(t)),lit(Zut,t)&&(lit(edt,t).data=lit(Zut,t),cit(Zut,t,null)),yield t.addEditToolbar())}))()}get altTextData(){var t;return null===(t=lit(edt,this))||void 0===t?void 0:t.data}set altTextData(t){lit(edt,this)&&(lit(edt,this).data=t)}get guessedAltText(){var t;return null===(t=lit(edt,this))||void 0===t?void 0:t.guessedText}setGuessedAltText(t){var e=this;return sit((function*(){var r;yield null===(r=lit(edt,e))||void 0===r?void 0:r.setGuessedText(t)}))()}serializeAltText(t){var e;return null===(e=lit(edt,this))||void 0===e?void 0:e.serialize(t)}hasAltText(){return!!lit(edt,this)&&!lit(edt,this).isEmpty()}hasAltTextData(){var t,e;return null!==(t=null===(e=lit(edt,this))||void 0===e?void 0:e.hasData())&&void 0!==t&&t}render(){var t;this.div=document.createElement("div"),this.div.setAttribute("data-editor-rotation",(360-this.rotation)%360),this.div.className=this.name,this.div.setAttribute("id",this.id),this.div.tabIndex=lit(rdt,this)?-1:0,this._isVisible||this.div.classList.add("hidden"),this.setInForeground(),iit(_dt,this,jdt).call(this);var[e,r]=this.parentDimensions;this.parentRotation%180!=0&&(this.div.style.maxWidth="".concat((100*r/e).toFixed(2),"%"),this.div.style.maxHeight="".concat((100*e/r).toFixed(2),"%"));var[n,i]=this.getInitialTranslation();return this.translate(n,i),Uht(this,this.div,["pointerdown"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(lit(wdt,this)||cit(wdt,this,new $ut({container:this.div,isPinchingDisabled:()=>!this.isSelected,onPinchStart:iit(_dt,this,Odt).bind(this),onPinching:iit(_dt,this,Ldt).bind(this),onPinchEnd:iit(_dt,this,Ddt).bind(this),signal:this._uiManager._signal}))),null===(t=this._uiManager._editorUndoBar)||void 0===t||t.hide(),this.div}pointerdown(t){var{isMac:e}=Hlt.platform;0!==t.button||t.ctrlKey&&e?t.preventDefault():(cit(udt,this,!0),this._isDraggable?iit(_dt,this,Ndt).call(this,t):iit(_dt,this,Fdt).call(this,t))}get isSelected(){return this._uiManager.isSelected(this)}_onStartDragging(){}_onStopDragging(){}moveInDOM(){lit(vdt,this)&&clearTimeout(lit(vdt,this)),cit(vdt,this,setTimeout((()=>{var t;cit(vdt,this,null),null===(t=this.parent)||void 0===t||t.moveEditorInDOM(this)}),0))}_setParentAndPosition(t,e,r){t.changeParent(this),this.x=e,this.y=r,this.fixAndSetPosition(),this._onTranslated()}getRect(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.rotation,n=this.parentScale,[i,a]=this.pageDimensions,[s,o]=this.pageTranslation,l=t/n,h=e/n,c=this.x*i,u=this.y*a,d=this.width*i,p=this.height*a;switch(r){case 0:return[c+l+s,a-u-h-p+o,c+l+d+s,a-u-h+o];case 90:return[c+h+s,a-u+l+o,c+h+p+s,a-u+l+d+o];case 180:return[c-l-d+s,a-u+h+o,c-l+s,a-u+h+p+o];case 270:return[c-h-p+s,a-u-l-d+o,c-h+s,a-u-l+o];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(t,e){var[r,n,i,a]=t,s=i-r,o=a-n;switch(this.rotation){case 0:return[r,e-a,s,o];case 90:return[r,e-n,o,s];case 180:return[i,e-n,s,o];case 270:return[i,e-a,o,s];default:throw new Error("Invalid rotation")}}onceAdded(t){}isEmpty(){return!1}enableEditMode(){cit(fdt,this,!0)}disableEditMode(){cit(fdt,this,!1)}isInEditMode(){return lit(fdt,this)}shouldGetKeyboardEvents(){return lit(gdt,this)}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){var{top:t,left:e,bottom:r,right:n}=this.getClientDimensions(),{innerHeight:i,innerWidth:a}=window;return e<a&&n>0&&t<i&&r>0}rebuild(){iit(_dt,this,jdt).call(this)}rotate(t){}resize(){}serializeDeleted(){var t;return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:(null===(t=this._initialData)||void 0===t?void 0:t.popupRef)||""}}serialize(){Tlt("An editor must be serializable")}static deserialize(t,e,r){var n=this;return sit((function*(){var i=new n.prototype.constructor({parent:e,id:e.getNextId(),uiManager:r});i.rotation=t.rotation,cit(Zut,i,t.accessibilityData);var[a,s]=i.pageDimensions,[o,l,h,c]=i.getRectInCurrentCoords(t.rect,s);return i.x=o/a,i.y=l/s,i.width=h/a,i.height=c/s,i}))()}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||null!==this.serialize())}remove(){var t,e;if(null===(t=lit(hdt,this))||void 0===t||t.abort(),cit(hdt,this,null),this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),lit(vdt,this)&&(clearTimeout(lit(vdt,this)),cit(vdt,this,null)),iit(_dt,this,Hdt).call(this),this.removeEditToolbar(),lit(bdt,this)){for(var r of lit(bdt,this).values())clearTimeout(r);cit(bdt,this,null)}this.parent=null,null===(e=lit(wdt,this))||void 0===e||e.destroy(),cit(wdt,this,null)}get isResizable(){return!1}makeResizable(){this.isResizable&&(iit(_dt,this,Tdt).call(this),lit(sdt,this).classList.remove("hidden"),Uht(this,this.div,["keydown"]))}get toolbarPosition(){return null}keydown(t){if(this.isResizable&&t.target===this.div&&"Enter"===t.key){this._uiManager.setSelected(this),cit(ldt,this,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});var e=lit(sdt,this).children;if(!lit(tdt,this)){cit(tdt,this,Array.from(e));var r=iit(_dt,this,Bdt).bind(this),n=iit(_dt,this,zdt).bind(this),i=this._uiManager._signal;for(var a of lit(tdt,this)){var s=a.getAttribute("data-resizer-name");a.setAttribute("role","spinbutton"),a.addEventListener("keydown",r,{signal:i}),a.addEventListener("blur",n,{signal:i}),a.addEventListener("focus",iit(_dt,this,Wdt).bind(this,s),{signal:i}),a.setAttribute("data-l10n-id",kdt._l10nResizer[s])}}var o=lit(tdt,this)[0],l=0;for(var h of e){if(h===o)break;l++}var c=(360-this.rotation+this.parentRotation)%360/90*(lit(tdt,this).length/4);if(c!==l){if(c<l)for(var u=0;u<l-c;u++)lit(sdt,this).append(lit(sdt,this).firstChild);else if(c>l)for(var d=0;d<c-l;d++)lit(sdt,this).firstChild.before(lit(sdt,this).lastChild);var p=0;for(var f of e){var g=lit(tdt,this)[p++].getAttribute("data-resizer-name");f.setAttribute("data-l10n-id",kdt._l10nResizer[g])}}iit(_dt,this,Udt).call(this,0),cit(gdt,this,!0),lit(sdt,this).firstChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}}_resizeWithKeyboard(t,e){lit(gdt,this)&&iit(_dt,this,Rdt).call(this,lit(cdt,this),{deltaX:t,deltaY:e,fromKeyboard:!0})}_stopResizingWithKeyboard(){iit(_dt,this,Hdt).call(this),this.div.focus()}select(){var t,e,r;this.makeResizable(),null===(t=this.div)||void 0===t||t.classList.add("selectedEditor"),this._editToolbar?(null===(e=this._editToolbar)||void 0===e||e.show(),null===(r=lit(edt,this))||void 0===r||r.toggleAltTextBadge(!1)):this.addEditToolbar().then((()=>{var t,e;null!==(t=this.div)&&void 0!==t&&t.classList.contains("selectedEditor")&&(null===(e=this._editToolbar)||void 0===e||e.show())}))}unselect(){var t,e,r,n,i;null===(t=lit(sdt,this))||void 0===t||t.classList.add("hidden"),null===(e=this.div)||void 0===e||e.classList.remove("selectedEditor"),null!==(r=this.div)&&void 0!==r&&r.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),null===(n=this._editToolbar)||void 0===n||n.hide(),null===(i=lit(edt,this))||void 0===i||i.toggleAltTextBadge(!0)}updateParams(t,e){}disableEditing(){}enableEditing(){}enterInEditMode(){}getImageForAltText(){return null}get contentDiv(){return this.div}get isEditing(){return lit(pdt,this)}set isEditing(t){cit(pdt,this,t),this.parent&&(t?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(t,e){cit(adt,this,!0);var r=t/e,{style:n}=this.div;n.aspectRatio=r,n.height="auto"}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:"added"}}get telemetryFinalData(){return null}_reportTelemetry(t){if(arguments.length>1&&void 0!==arguments[1]&&arguments[1]){lit(bdt,this)||cit(bdt,this,new Map);var{action:e}=t,r=lit(bdt,this).get(e);return r&&clearTimeout(r),r=setTimeout((()=>{this._reportTelemetry(t),lit(bdt,this).delete(e),0===lit(bdt,this).size&&cit(bdt,this,null)}),kdt._telemetryTimeout),void lit(bdt,this).set(e,r)}t.type||(t.type=this.editorType),this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:t}})}show(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this._isVisible;this.div.classList.toggle("hidden",!t),this._isVisible=t}enable(){this.div&&(this.div.tabIndex=0),cit(rdt,this,!1)}disable(){this.div&&(this.div.tabIndex=-1),cit(rdt,this,!0)}renderAnnotationElement(t){var e=t.container.querySelector(".annotationContent");if(e){if("CANVAS"===e.nodeName){var r=e;(e=document.createElement("div")).classList.add("annotationContent",this.editorType),r.before(e)}}else(e=document.createElement("div")).classList.add("annotationContent",this.editorType),t.container.prepend(e);return e}resetAnnotationElement(t){var{firstChild:e}=t.container;"DIV"===(null==e?void 0:e.nodeName)&&e.classList.contains("annotationContent")&&e.remove()}}function Sdt(t,e,r){var[n,i]=t;[e,r]=this.screenToPageTranslation(e,r),this.x+=e/n,this.y+=r/i,this._onTranslating(this.x,this.y),this.fixAndSetPosition()}function Edt(t,e,r){switch(r){case 90:return[e,-t];case 180:return[-t,-e];case 270:return[-e,t];default:return[t,e]}}function Mdt(t){switch(t){case 90:var[e,r]=this.pageDimensions;return[0,-e/r,r/e,0];case 180:return[-1,0,0,-1];case 270:var[n,i]=this.pageDimensions;return[0,n/i,-i/n,0];default:return[1,0,0,1]}}function Tdt(){if(!lit(sdt,this)){cit(sdt,this,document.createElement("div")),lit(sdt,this).classList.add("resizers");var t=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],e=this._uiManager._signal;for(var r of t){var n=document.createElement("div");lit(sdt,this).append(n),n.classList.add("resizer",r),n.setAttribute("data-resizer-name",r),n.addEventListener("pointerdown",iit(_dt,this,Cdt).bind(this,r),{signal:e}),n.addEventListener("contextmenu",cht,{signal:e}),n.tabIndex=-1}this.div.prepend(lit(sdt,this))}}function Cdt(t,e){var r;e.preventDefault();var{isMac:n}=Hlt.platform;if(!(0!==e.button||e.ctrlKey&&n)){null===(r=lit(edt,this))||void 0===r||r.toggle(!1);var i=this._isDraggable;this._isDraggable=!1,cit(odt,this,[e.screenX,e.screenY]);var a=new AbortController,s=this._uiManager.combinedSignal(a);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",iit(_dt,this,Rdt).bind(this,t),{passive:!0,capture:!0,signal:s}),window.addEventListener("touchmove",uht,{passive:!1,signal:s}),window.addEventListener("contextmenu",cht,{signal:s}),cit(ldt,this,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});var o=this.parent.div.style.cursor,l=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(e.target).cursor;var h=()=>{var t;a.abort(),this.parent.togglePointerEvents(!0),null===(t=lit(edt,this))||void 0===t||t.toggle(!0),this._isDraggable=i,this.parent.div.style.cursor=o,this.div.style.cursor=l,iit(_dt,this,Idt).call(this)};window.addEventListener("pointerup",h,{signal:s}),window.addEventListener("blur",h,{signal:s})}}function Pdt(t,e,r,n){this.width=r,this.height=n,this.x=t,this.y=e;var[i,a]=this.parentDimensions;this.setDims(i*r,a*n),this.fixAndSetPosition(),this._onResized()}function Idt(){if(lit(ldt,this)){var{savedX:t,savedY:e,savedWidth:r,savedHeight:n}=lit(ldt,this);cit(ldt,this,null);var i=this.x,a=this.y,s=this.width,o=this.height;i===t&&a===e&&s===r&&o===n||this.addCommands({cmd:iit(_dt,this,Pdt).bind(this,i,a,s,o),undo:iit(_dt,this,Pdt).bind(this,t,e,r,n),mustExec:!0})}}function Rdt(t,e){var r,n,[i,a]=this.parentDimensions,s=this.x,o=this.y,l=this.width,h=this.height,c=got.MIN_SIZE/i,u=got.MIN_SIZE/a,d=iit(_dt,this,Mdt).call(this,this.rotation),p=(t,e)=>[d[0]*t+d[2]*e,d[1]*t+d[3]*e],f=iit(_dt,this,Mdt).call(this,360-this.rotation),g=!1,v=!1;switch(t){case"topLeft":g=!0,r=(t,e)=>[0,0],n=(t,e)=>[t,e];break;case"topMiddle":r=(t,e)=>[t/2,0],n=(t,e)=>[t/2,e];break;case"topRight":g=!0,r=(t,e)=>[t,0],n=(t,e)=>[0,e];break;case"middleRight":v=!0,r=(t,e)=>[t,e/2],n=(t,e)=>[0,e/2];break;case"bottomRight":g=!0,r=(t,e)=>[t,e],n=(t,e)=>[0,0];break;case"bottomMiddle":r=(t,e)=>[t/2,e],n=(t,e)=>[t/2,0];break;case"bottomLeft":g=!0,r=(t,e)=>[0,e],n=(t,e)=>[t,0];break;case"middleLeft":v=!0,r=(t,e)=>[0,e/2],n=(t,e)=>[t,e/2]}var m,y,b=r(l,h),w=n(l,h),x=p(...w),A=got._round(s+x[0]),_=got._round(o+x[1]),k=1,S=1;if(e.fromKeyboard)({deltaX:m,deltaY:y}=e);else{var{screenX:E,screenY:M}=e,[T,C]=lit(odt,this);[m,y]=this.screenToPageTranslation(E-T,M-C),lit(odt,this)[0]=E,lit(odt,this)[1]=M}if([m,y]=((t,e)=>[f[0]*t+f[2]*e,f[1]*t+f[3]*e])(m/i,y/a),g){var P=Math.hypot(l,h);k=S=Math.max(Math.min(Math.hypot(w[0]-b[0]-m,w[1]-b[1]-y)/P,1/l,1/h),c/l,u/h)}else v?k=Math.max(c,Math.min(1,Math.abs(w[0]-b[0]-m)))/l:S=Math.max(u,Math.min(1,Math.abs(w[1]-b[1]-y)))/h;var I=got._round(l*k),R=got._round(h*S),O=A-(x=p(...n(I,R)))[0],L=_-x[1];lit(ddt,this)||cit(ddt,this,[this.x,this.y,this.width,this.height]),this.width=I,this.height=R,this.x=O,this.y=L,this.setDims(i*I,a*R),this.fixAndSetPosition(),this._onResizing()}function Odt(){var t;cit(ldt,this,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height}),null===(t=lit(edt,this))||void 0===t||t.toggle(!1),this.parent.togglePointerEvents(!1)}function Ldt(t,e,r){var n=r/e*.7+1-.7;if(1!==n){var i=iit(_dt,this,Mdt).call(this,this.rotation),a=(t,e)=>[i[0]*t+i[2]*e,i[1]*t+i[3]*e],[s,o]=this.parentDimensions,l=this.x,h=this.y,c=this.width,u=this.height,d=got.MIN_SIZE/s,p=got.MIN_SIZE/o;n=Math.max(Math.min(n,1/c,1/u),d/c,p/u);var f=got._round(c*n),g=got._round(u*n);if(f!==c||g!==u){lit(ddt,this)||cit(ddt,this,[l,h,c,u]);var v=a(c/2,u/2),m=got._round(l+v[0]),y=got._round(h+v[1]),b=a(f/2,g/2);this.x=m-b[0],this.y=y-b[1],this.width=f,this.height=g,this.setDims(s*f,o*g),this.fixAndSetPosition(),this._onResizing()}}}function Ddt(){var t;null===(t=lit(edt,this))||void 0===t||t.toggle(!0),this.parent.togglePointerEvents(!0),iit(_dt,this,Idt).call(this)}function Fdt(t){var{isMac:e}=Hlt.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)}function Ndt(t){var{isSelected:e}=this;this._uiManager.setUpDragSession();var r=!1,n=new AbortController,i=this._uiManager.combinedSignal(n),a={capture:!0,passive:!1,signal:i},s=t=>{n.abort(),cit(ndt,this,null),cit(udt,this,!1),this._uiManager.endDragSession()||iit(_dt,this,Fdt).call(this,t),r&&this._onStopDragging()};e&&(cit(mdt,this,t.clientX),cit(ydt,this,t.clientY),cit(ndt,this,t.pointerId),cit(idt,this,t.pointerType),window.addEventListener("pointermove",(t=>{r||(r=!0,this._onStartDragging());var{clientX:e,clientY:n,pointerId:i}=t;if(i===lit(ndt,this)){var[a,s]=this.screenToPageTranslation(e-lit(mdt,this),n-lit(ydt,this));cit(mdt,this,e),cit(ydt,this,n),this._uiManager.dragSelectedEditors(a,s)}else uht(t)}),a),window.addEventListener("touchmove",uht,a),window.addEventListener("pointerdown",(t=>{t.pointerType===lit(idt,this)&&(lit(wdt,this)||t.isPrimary)&&s(t),uht(t)}),a));var o=t=>{lit(ndt,this)&&lit(ndt,this)!==t.pointerId?uht(t):s(t)};window.addEventListener("pointerup",o,{signal:i}),window.addEventListener("blur",o,{signal:i})}function jdt(){if(!lit(hdt,this)&&this.div){cit(hdt,this,new AbortController);var t=this._uiManager.combinedSignal(lit(hdt,this));this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})}}function Bdt(t){got._resizerKeyboardManager.exec(this,t)}function zdt(t){var e;lit(gdt,this)&&(null===(e=t.relatedTarget)||void 0===e?void 0:e.parentNode)!==lit(sdt,this)&&iit(_dt,this,Hdt).call(this)}function Wdt(t){cit(cdt,this,lit(gdt,this)?t:"")}function Udt(t){if(lit(tdt,this))for(var e of lit(tdt,this))e.tabIndex=t}function Hdt(){cit(gdt,this,!1),iit(_dt,this,Udt).call(this,-1),iit(_dt,this,Idt).call(this)}got=kdt,pit(kdt,"_l10n",null),pit(kdt,"_l10nResizer",null),pit(kdt,"_borderLineWidth",-1),pit(kdt,"_colorManager",new sct),pit(kdt,"_zIndex",1),pit(kdt,"_telemetryTimeout",1e3);class Gdt extends kdt{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}var Ydt=3285377520,Vdt=4294901760,qdt=65535;class Xdt{constructor(t){this.h1=t?4294967295&t:Ydt,this.h2=t?4294967295&t:Ydt}update(t){var e,r;if("string"==typeof t){e=new Uint8Array(2*t.length),r=0;for(var n=0,i=t.length;n<i;n++){var a=t.charCodeAt(n);a<=255?e[r++]=a:(e[r++]=a>>>8,e[r++]=255&a)}}else{if(!ArrayBuffer.isView(t))throw new Error("Invalid data format, must be a string or TypedArray.");r=(e=t.slice()).byteLength}for(var s=r>>2,o=r-4*s,l=new Uint32Array(e.buffer,0,s),h=0,c=0,u=this.h1,d=this.h2,p=3432918353,f=461845907,g=11601,v=13715,m=0;m<s;m++)1&m?u=5*(u=(u^=h=(h=(h=(h=l[m])*p&Vdt|h*g&qdt)<<15|h>>>17)*f&Vdt|h*v&qdt)<<13|u>>>19)+3864292196:d=5*(d=(d^=c=(c=(c=(c=l[m])*p&Vdt|c*g&qdt)<<15|c>>>17)*f&Vdt|c*v&qdt)<<13|d>>>19)+3864292196;switch(h=0,o){case 3:h^=e[4*s+2]<<16;case 2:h^=e[4*s+1]<<8;case 1:h=(h=(h=(h^=e[4*s])*p&Vdt|h*g&qdt)<<15|h>>>17)*f&Vdt|h*v&qdt,1&s?u^=h:d^=h}this.h1=u,this.h2=d}hexdigest(){var t=this.h1,e=this.h2;return t=3981806797*(t^=e>>>1)&Vdt|36045*t&qdt,t=444984403*(t^=(e=4283543511*e&Vdt|(2950163797*(e<<16|t>>>16)&Vdt)>>>16)>>>1)&Vdt|60499*t&qdt,((t^=(e=3301882366*e&Vdt|(3120437893*(e<<16|t>>>16)&Vdt)>>>16)>>>1)>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}var $dt=Object.freeze({map:null,hash:"",transfer:void 0}),Kdt=new WeakMap,Qdt=new WeakMap,Jdt=new WeakMap,Zdt=new WeakSet;class tpt{constructor(){dit(this,Zdt),hit(this,Kdt,!1),hit(this,Qdt,null),hit(this,Jdt,new Map),this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(t,e){var r=lit(Jdt,this).get(t);return void 0===r?e:Object.assign(e,r)}getRawValue(t){return lit(Jdt,this).get(t)}remove(t){if(lit(Jdt,this).delete(t),0===lit(Jdt,this).size&&this.resetModified(),"function"==typeof this.onAnnotationEditor){for(var e of lit(Jdt,this).values())if(e instanceof kdt)return;this.onAnnotationEditor(null)}}setValue(t,e){var r=lit(Jdt,this).get(t),n=!1;if(void 0!==r)for(var[i,a]of Object.entries(e))r[i]!==a&&(n=!0,r[i]=a);else n=!0,lit(Jdt,this).set(t,e);n&&iit(Zdt,this,ept).call(this),e instanceof kdt&&"function"==typeof this.onAnnotationEditor&&this.onAnnotationEditor(e.constructor._type)}has(t){return lit(Jdt,this).has(t)}getAll(){return lit(Jdt,this).size>0?Ult(lit(Jdt,this)):null}setAll(t){for(var[e,r]of Object.entries(t))this.setValue(e,r)}get size(){return lit(Jdt,this).size}resetModified(){lit(Kdt,this)&&(cit(Kdt,this,!1),"function"==typeof this.onResetModified&&this.onResetModified())}get print(){return new npt(this)}get serializable(){if(0===lit(Jdt,this).size)return $dt;var t=new Map,e=new Xdt,r=[],n=Object.create(null),i=!1;for(var[a,s]of lit(Jdt,this)){var o=s instanceof kdt?s.serialize(!1,n):s;o&&(t.set(a,o),e.update("".concat(a,":").concat(JSON.stringify(o))),i||(i=!!o.bitmap))}if(i)for(var l of t.values())l.bitmap&&r.push(l.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:r}:$dt}get editorStats(){var t=null,e=new Map;for(var r of lit(Jdt,this).values()){var n;if(r instanceof kdt){var i=r.telemetryFinalData;if(i){var{type:a}=i;e.has(a)||e.set(a,Object.getPrototypeOf(r).constructor),t||(t=Object.create(null));var s=(n=t)[a]||(n[a]=new Map);for(var[o,l]of Object.entries(i)){var h;if("type"!==o){var c=s.get(o);c||(c=new Map,s.set(o,c));var u=null!==(h=c.get(l))&&void 0!==h?h:0;c.set(l,u+1)}}}}}for(var[d,p]of e)t[d]=p.computeTelemetryFinalData(t[d]);return t}resetModifiedIds(){cit(Qdt,this,null)}get modifiedIds(){if(lit(Qdt,this))return lit(Qdt,this);var t=[];for(var e of lit(Jdt,this).values())e instanceof kdt&&e.annotationElementId&&e.serialize()&&t.push(e.annotationElementId);return cit(Qdt,this,{ids:new Set(t),hash:t.join(",")})}}function ept(){lit(Kdt,this)||(cit(Kdt,this,!0),"function"==typeof this.onSetModified&&this.onSetModified())}var rpt=new WeakMap;class npt extends tpt{constructor(t){super(),hit(this,rpt,void 0);var{map:e,hash:r,transfer:n}=t.serializable,i=structuredClone(e,n?{transfer:n}:null);cit(rpt,this,{map:i,hash:r,transfer:n})}get print(){Tlt("Should not call PrintAnnotationStorage.print")}get serializable(){return lit(rpt,this)}get modifiedIds(){return Ilt(this,"modifiedIds",{ids:new Set,hash:""})}}var ipt=new WeakMap;class apt{constructor(t){var{ownerDocument:e=globalThis.document,styleElement:r=null}=t;hit(this,ipt,new Set),this._document=e,this.nativeFontFaces=new Set,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(t){this.nativeFontFaces.add(t),this._document.fonts.add(t)}removeNativeFontFace(t){this.nativeFontFaces.delete(t),this._document.fonts.delete(t)}insertRule(t){this.styleElement||(this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement));var e=this.styleElement.sheet;e.insertRule(t,e.cssRules.length)}clear(){for(var t of this.nativeFontFaces)this._document.fonts.delete(t);this.nativeFontFaces.clear(),lit(ipt,this).clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}loadSystemFont(t){var e=this;return sit((function*(){var{systemFontInfo:r,_inspectFont:n}=t;if(r&&!lit(ipt,e).has(r.loadedName))if(Clt(!e.disableFontFace,"loadSystemFont shouldn't be called when `disableFontFace` is set."),e.isFontLoadingAPISupported){var{loadedName:i,src:a,style:s}=r,o=new FontFace(i,a,s);e.addNativeFontFace(o);try{yield o.load(),lit(ipt,e).add(i),null==n||n(r)}catch(t){Mlt("Cannot load system font: ".concat(r.baseFontName,", installing it could help to improve PDF rendering.")),e.removeNativeFontFace(o)}}else Tlt("Not implemented: loadSystemFont without the Font Loading API.")}))()}bind(t){var e=this;return sit((function*(){if(!(t.attached||t.missingFile&&!t.systemFontInfo))if(t.attached=!0,t.systemFontInfo)yield e.loadSystemFont(t);else if(e.isFontLoadingAPISupported){var r=t.createNativeFontFace();if(r){e.addNativeFontFace(r);try{yield r.loaded}catch(e){throw Mlt("Failed to load font '".concat(r.family,"': '").concat(e,"'.")),t.disableFontFace=!0,e}}}else{var n=t.createFontFaceRule();if(n){if(e.insertRule(n),e.isSyncFontLoadingSupported)return;yield new Promise((r=>{var n=e._queueLoadingCallback(r);e._prepareFontLoadEvent(t,n)}))}}}))()}get isFontLoadingAPISupported(){var t;return Ilt(this,"isFontLoadingAPISupported",!(null===(t=this._document)||void 0===t||!t.fonts))}get isSyncFontLoadingSupported(){var t,e=!1;return(Tot||"undefined"!=typeof navigator&&"string"==typeof(null===(t=navigator)||void 0===t?void 0:t.userAgent)&&/Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent))&&(e=!0),Ilt(this,"isSyncFontLoadingSupported",e)}_queueLoadingCallback(t){var{loadingRequests:e}=this,r={done:!1,complete:function(){for(Clt(!r.done,"completeRequest() cannot be called twice."),r.done=!0;e.length>0&&e[0].done;){var t=e.shift();setTimeout(t.callback,0)}},callback:t};return e.push(r),r}get _loadTestFont(){return Ilt(this,"_loadTestFont",atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA=="))}_prepareFontLoadEvent(t,e){function r(t,e){return t.charCodeAt(e)<<24|t.charCodeAt(e+1)<<16|t.charCodeAt(e+2)<<8|255&t.charCodeAt(e+3)}function n(t,e,r,n){return t.substring(0,e)+n+t.substring(e+r)}var i,a,s=this._document.createElement("canvas");s.width=1,s.height=1;var o=s.getContext("2d"),l=0;var h="lt".concat(Date.now()).concat(this.loadTestFontId++),c=this._loadTestFont,u=1482184792,d=r(c=n(c,976,h.length,h),16);for(i=0,a=h.length-3;i<a;i+=4)d=d-u+r(h,i)|0;i<h.length&&(d=d-u+r(h+"XXX",i)|0),c=n(c,16,4,function(t){return String.fromCharCode(t>>24&255,t>>16&255,t>>8&255,255&t)}(d));var p="url(data:font/opentype;base64,".concat(btoa(c),");"),f='@font-face {font-family:"'.concat(h,'";src:').concat(p,"}");this.insertRule(f);var g=this._document.createElement("div");for(var v of(g.style.visibility="hidden",g.style.width=g.style.height="10px",g.style.position="absolute",g.style.top=g.style.left="0px",[t.loadedName,h])){var m=this._document.createElement("span");m.textContent="Hi",m.style.fontFamily=v,g.append(m)}this._document.body.append(g),function t(e,r){if(++l>30)return Mlt("Load test font never loaded."),void r();o.font="30px "+e,o.fillText(".",0,20),o.getImageData(0,0,1,1).data[3]>0?r():setTimeout(t.bind(null,e,r))}(h,(()=>{g.remove(),e.complete()}))}}class spt{constructor(t,e){var{disableFontFace:r=!1,fontExtraProperties:n=!1,inspectFont:i=null}=e;for(var a in this.compiledGlyphs=Object.create(null),t)this[a]=t[a];this.disableFontFace=!0===r,this.fontExtraProperties=!0===n,this._inspectFont=i}createNativeFontFace(){var t,e;if(!this.data||this.disableFontFace)return null;if(this.cssFontInfo){var r={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(r.style="oblique ".concat(this.cssFontInfo.italicAngle,"deg")),e=new FontFace(this.cssFontInfo.fontFamily,this.data,r)}else e=new FontFace(this.loadedName,this.data,{});return null===(t=this._inspectFont)||void 0===t||t.call(this,this),e}createFontFaceRule(){var t;if(!this.data||this.disableFontFace)return null;var e,r,n="url(data:".concat(this.mimetype,";base64,").concat((e=this.data,Uint8Array.prototype.toBase64?e.toBase64():btoa(zlt(e))),");");if(this.cssFontInfo){var i="font-weight: ".concat(this.cssFontInfo.fontWeight,";");this.cssFontInfo.italicAngle&&(i+="font-style: oblique ".concat(this.cssFontInfo.italicAngle,"deg;")),r='@font-face {font-family:"'.concat(this.cssFontInfo.fontFamily,'";').concat(i,"src:").concat(n,"}")}else r='@font-face {font-family:"'.concat(this.loadedName,'";src:').concat(n,"}");return null===(t=this._inspectFont)||void 0===t||t.call(this,this,n),r}getPathGenerator(t,e){if(void 0!==this.compiledGlyphs[e])return this.compiledGlyphs[e];var r,n=this.loadedName+"_path_"+e;try{r=t.get(n)}catch(t){Mlt('getPathGenerator - ignoring character: "'.concat(t,'".'))}var i=new Path2D(r||"");return this.fontExtraProperties||t.delete(n),this.compiledGlyphs[e]=i}}var opt=1,lpt=2,hpt=1,cpt=2,upt=3,dpt=4,ppt=5,fpt=6,gpt=7,vpt=8;function mpt(){}function ypt(t){if(t instanceof Blt||t instanceof Dlt||t instanceof Flt||t instanceof Olt||t instanceof Nlt||t instanceof Llt)return t;switch(t instanceof Error||"object"==typeof t&&null!==t||Tlt('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),t.name){case"AbortException":return new Blt(t.message);case"InvalidPDFException":return new Dlt(t.message);case"MissingPDFException":return new Flt(t.message);case"PasswordException":return new Olt(t.message,t.code);case"UnexpectedResponseException":return new Nlt(t.message,t.status);case"UnknownErrorException":return new Llt(t.message,t.details)}return new Llt(t.message,t.toString())}var bpt=new WeakMap,wpt=new WeakSet;class xpt{constructor(t,e,r){dit(this,wpt),hit(this,bpt,new AbortController),this.sourceName=t,this.targetName=e,this.comObj=r,this.callbackId=1,this.streamId=1,this.streamSinks=Object.create(null),this.streamControllers=Object.create(null),this.callbackCapabilities=Object.create(null),this.actionHandler=Object.create(null),r.addEventListener("message",iit(wpt,this,Apt).bind(this),{signal:lit(bpt,this).signal})}on(t,e){var r=this.actionHandler;if(r[t])throw new Error('There is already an actionName called "'.concat(t,'"'));r[t]=e}send(t,e,r){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,data:e},r)}sendWithPromise(t,e,r){var n=this.callbackId++,i=Promise.withResolvers();this.callbackCapabilities[n]=i;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:n,data:e},r)}catch(t){i.reject(t)}return i.promise}sendWithStream(t,e,r,n){var i=this.streamId++,a=this.sourceName,s=this.targetName,o=this.comObj;return new ReadableStream({start:r=>{var l=Promise.withResolvers();return this.streamControllers[i]={controller:r,startCall:l,pullCall:null,cancelCall:null,isClosed:!1},o.postMessage({sourceName:a,targetName:s,action:t,streamId:i,data:e,desiredSize:r.desiredSize},n),l.promise},pull:t=>{var e=Promise.withResolvers();return this.streamControllers[i].pullCall=e,o.postMessage({sourceName:a,targetName:s,stream:fpt,streamId:i,desiredSize:t.desiredSize}),e.promise},cancel:t=>{Clt(t instanceof Error,"cancel must have a valid reason");var e=Promise.withResolvers();return this.streamControllers[i].cancelCall=e,this.streamControllers[i].isClosed=!0,o.postMessage({sourceName:a,targetName:s,stream:hpt,streamId:i,reason:ypt(t)}),e.promise}},r)}destroy(){var t;null===(t=lit(bpt,this))||void 0===t||t.abort(),cit(bpt,this,null)}}function Apt(t){var{data:e}=t;if(e.targetName===this.sourceName)if(e.stream)iit(wpt,this,kpt).call(this,e);else if(e.callback){var r=e.callbackId,n=this.callbackCapabilities[r];if(!n)throw new Error("Cannot resolve callback ".concat(r));if(delete this.callbackCapabilities[r],e.callback===opt)n.resolve(e.data);else{if(e.callback!==lpt)throw new Error("Unexpected callback case");n.reject(ypt(e.reason))}}else{var i=this.actionHandler[e.action];if(!i)throw new Error("Unknown action from worker: ".concat(e.action));if(e.callbackId){var a=this.sourceName,s=e.sourceName,o=this.comObj;Promise.try(i,e.data).then((function(t){o.postMessage({sourceName:a,targetName:s,callback:opt,callbackId:e.callbackId,data:t})}),(function(t){o.postMessage({sourceName:a,targetName:s,callback:lpt,callbackId:e.callbackId,reason:ypt(t)})}))}else e.streamId?iit(wpt,this,_pt).call(this,e):i(e.data)}}function _pt(t){var e=t.streamId,r=this.sourceName,n=t.sourceName,i=this.comObj,a=this,s=this.actionHandler[t.action],o={enqueue(t){var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,s=arguments.length>2?arguments[2]:void 0;if(!this.isCancelled){var o=this.desiredSize;this.desiredSize-=a,o>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),i.postMessage({sourceName:r,targetName:n,stream:dpt,streamId:e,chunk:t},s)}},close(){this.isCancelled||(this.isCancelled=!0,i.postMessage({sourceName:r,targetName:n,stream:upt,streamId:e}),delete a.streamSinks[e])},error(t){Clt(t instanceof Error,"error must have a valid reason"),this.isCancelled||(this.isCancelled=!0,i.postMessage({sourceName:r,targetName:n,stream:ppt,streamId:e,reason:ypt(t)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:t.desiredSize,ready:null};o.sinkCapability.resolve(),o.ready=o.sinkCapability.promise,this.streamSinks[e]=o,Promise.try(s,t.data,o).then((function(){i.postMessage({sourceName:r,targetName:n,stream:vpt,streamId:e,success:!0})}),(function(t){i.postMessage({sourceName:r,targetName:n,stream:vpt,streamId:e,reason:ypt(t)})}))}function kpt(t){var e=t.streamId,r=this.sourceName,n=t.sourceName,i=this.comObj,a=this.streamControllers[e],s=this.streamSinks[e];switch(t.stream){case vpt:t.success?a.startCall.resolve():a.startCall.reject(ypt(t.reason));break;case gpt:t.success?a.pullCall.resolve():a.pullCall.reject(ypt(t.reason));break;case fpt:if(!s){i.postMessage({sourceName:r,targetName:n,stream:gpt,streamId:e,success:!0});break}s.desiredSize<=0&&t.desiredSize>0&&s.sinkCapability.resolve(),s.desiredSize=t.desiredSize,Promise.try(s.onPull||mpt).then((function(){i.postMessage({sourceName:r,targetName:n,stream:gpt,streamId:e,success:!0})}),(function(t){i.postMessage({sourceName:r,targetName:n,stream:gpt,streamId:e,reason:ypt(t)})}));break;case dpt:if(Clt(a,"enqueue should have stream controller"),a.isClosed)break;a.controller.enqueue(t.chunk);break;case upt:if(Clt(a,"close should have stream controller"),a.isClosed)break;a.isClosed=!0,a.controller.close(),iit(wpt,this,Spt).call(this,a,e);break;case ppt:Clt(a,"error should have stream controller"),a.controller.error(ypt(t.reason)),iit(wpt,this,Spt).call(this,a,e);break;case cpt:t.success?a.cancelCall.resolve():a.cancelCall.reject(ypt(t.reason)),iit(wpt,this,Spt).call(this,a,e);break;case hpt:if(!s)break;var o=ypt(t.reason);Promise.try(s.onCancel||mpt,o).then((function(){i.postMessage({sourceName:r,targetName:n,stream:cpt,streamId:e,success:!0})}),(function(t){i.postMessage({sourceName:r,targetName:n,stream:cpt,streamId:e,reason:ypt(t)})})),s.sinkCapability.reject(o),s.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}}function Spt(t,e){return Ept.apply(this,arguments)}function Ept(){return(Ept=sit((function*(t,e){var r,n,i;yield Promise.allSettled([null===(r=t.startCall)||void 0===r?void 0:r.promise,null===(n=t.pullCall)||void 0===n?void 0:n.promise,null===(i=t.cancelCall)||void 0===i?void 0:i.promise]),delete this.streamControllers[e]}))).apply(this,arguments)}var Mpt=new WeakMap;class Tpt{constructor(t){var{enableHWA:e=!1}=t;hit(this,Mpt,!1),cit(Mpt,this,e)}create(t,e){if(t<=0||e<=0)throw new Error("Invalid canvas size");var r=this._createCanvas(t,e);return{canvas:r,context:r.getContext("2d",{willReadFrequently:!lit(Mpt,this)})}}reset(t,e,r){if(!t.canvas)throw new Error("Canvas is not specified");if(e<=0||r<=0)throw new Error("Invalid canvas size");t.canvas.width=e,t.canvas.height=r}destroy(t){if(!t.canvas)throw new Error("Canvas is not specified");t.canvas.width=0,t.canvas.height=0,t.canvas=null,t.context=null}_createCanvas(t,e){Tlt("Abstract method `_createCanvas` called.")}}class Cpt{constructor(t){var{baseUrl:e=null,isCompressed:r=!0}=t;this.baseUrl=e,this.isCompressed=r}fetch(t){var e=this;return sit((function*(){var{name:r}=t;if(!e.baseUrl)throw new Error("Ensure that the `cMapUrl` and `cMapPacked` API parameters are provided.");if(!r)throw new Error("CMap name must be specified.");var n=e.baseUrl+r+(e.isCompressed?".bcmap":"");return e._fetch(n).then((t=>({cMapData:t,isCompressed:e.isCompressed}))).catch((t=>{throw new Error("Unable to load ".concat(e.isCompressed?"binary ":"","CMap at: ").concat(n))}))}))()}_fetch(t){return sit((function*(){Tlt("Abstract method `_fetch` called.")}))()}}class Ppt extends Cpt{_fetch(t){var e=this;return sit((function*(){var r=yield tht(t,e.isCompressed?"arraybuffer":"text");return r instanceof ArrayBuffer?new Uint8Array(r):Wlt(r)}))()}}class Ipt{addFilter(t){return"none"}addHCMFilter(t,e){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addHighlightHCMFilter(t,e,r,n,i){return"none"}destroy(){}}var Rpt=new WeakMap,Opt=new WeakMap,Lpt=new WeakMap,Dpt=new WeakMap,Fpt=new WeakMap,Npt=new WeakMap,jpt=new WeakMap,Bpt=new WeakSet;function zpt(t){return lit(Opt,t)||cit(Opt,t,new Map)}function Wpt(t){return lit(Npt,t)||cit(Npt,t,new Map)}function Upt(t){if(!lit(Lpt,t)){var e=lit(Fpt,t).createElement("div"),{style:r}=e;r.visibility="hidden",r.contain="strict",r.width=r.height=0,r.position="absolute",r.top=r.left=0,r.zIndex=-1;var n=lit(Fpt,t).createElementNS(Jlt,"svg");n.setAttribute("width",0),n.setAttribute("height",0),cit(Lpt,t,lit(Fpt,t).createElementNS(Jlt,"defs")),e.append(n),n.append(lit(Lpt,t)),lit(Fpt,t).body.append(e)}return lit(Lpt,t)}function Hpt(t){if(1===t.length){for(var e=t[0],r=new Array(256),n=0;n<256;n++)r[n]=e[n]/255;var i=r.join(",");return[i,i,i]}for(var[a,s,o]=t,l=new Array(256),h=new Array(256),c=new Array(256),u=0;u<256;u++)l[u]=a[u]/255,h[u]=s[u]/255,c[u]=o[u]/255;return[l.join(","),h.join(","),c.join(",")]}function Gpt(t){if(void 0===lit(Rpt,this)){cit(Rpt,this,"");var e=lit(Fpt,this).URL;e!==lit(Fpt,this).baseURI&&(iht(e)?Mlt('#createUrl: ignore "data:"-URL for performance reasons.'):cit(Rpt,this,e.split("#",1)[0]))}return"url(".concat(lit(Rpt,this),"#").concat(t,")")}function Ypt(t){var e=lit(Fpt,this).createElementNS(Jlt,"feColorMatrix");e.setAttribute("type","matrix"),e.setAttribute("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0.59 0.11 0 0"),t.append(e)}function Vpt(t){var e=lit(Fpt,this).createElementNS(Jlt,"feColorMatrix");e.setAttribute("type","matrix"),e.setAttribute("values","0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0"),t.append(e)}function qpt(t){var e=lit(Fpt,this).createElementNS(Jlt,"filter");return e.setAttribute("color-interpolation-filters","sRGB"),e.setAttribute("id",t),uit(Bpt,this,Upt).append(e),e}function Xpt(t,e,r){var n=lit(Fpt,this).createElementNS(Jlt,e);n.setAttribute("type","discrete"),n.setAttribute("tableValues",r),t.append(n)}function $pt(t,e,r,n){var i=lit(Fpt,this).createElementNS(Jlt,"feComponentTransfer");n.append(i),iit(Bpt,this,Xpt).call(this,i,"feFuncR",t),iit(Bpt,this,Xpt).call(this,i,"feFuncG",e),iit(Bpt,this,Xpt).call(this,i,"feFuncB",r)}function Kpt(t,e){var r=lit(Fpt,this).createElementNS(Jlt,"feComponentTransfer");e.append(r),iit(Bpt,this,Xpt).call(this,r,"feFuncA",t)}function Qpt(t){return uit(Bpt,this,Upt).style.color=t,ght(getComputedStyle(uit(Bpt,this,Upt)).getPropertyValue("color"))}class Jpt{constructor(t){var{baseUrl:e=null}=t;this.baseUrl=e}fetch(t){var e=this;return sit((function*(){var{filename:r}=t;if(!e.baseUrl)throw new Error("Ensure that the `standardFontDataUrl` API parameter is provided.");if(!r)throw new Error("Font filename must be specified.");var n="".concat(e.baseUrl).concat(r);return e._fetch(n).catch((t=>{throw new Error("Unable to load font data at: ".concat(n))}))}))()}_fetch(t){return sit((function*(){Tlt("Abstract method `_fetch` called.")}))()}}class Zpt extends Jpt{_fetch(t){return sit((function*(){var e=yield tht(t,"arraybuffer");return new Uint8Array(e)}))()}}function tft(t){return eft.apply(this,arguments)}function eft(){return eft=sit((function*(t){var e=process.getBuiltinModule("fs"),r=yield e.promises.readFile(t);return new Uint8Array(r)})),eft.apply(this,arguments)}Tot&&Mlt("Please use the `legacy` build in Node.js environments.");var rft="Fill",nft="Stroke",ift="Shading";function aft(t,e){if(e){var r=e[2]-e[0],n=e[3]-e[1],i=new Path2D;i.rect(e[0],e[1],r,n),t.clip(i)}}class sft{getPattern(){Tlt("Abstract method `getPattern` called.")}}class oft extends sft{constructor(t){super(),this._type=t[1],this._bbox=t[2],this._colorStops=t[3],this._p0=t[4],this._p1=t[5],this._r0=t[6],this._r1=t[7],this.matrix=null}_createGradient(t){var e;for(var r of("axial"===this._type?e=t.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):"radial"===this._type&&(e=t.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1)),this._colorStops))e.addColorStop(r[0],r[1]);return e}getPattern(t,e,r,n){var i;if(n===nft||n===rft){var a=e.current.getClippedPathBoundingBox(n,vht(t))||[0,0,0,0],s=Math.ceil(a[2]-a[0])||1,o=Math.ceil(a[3]-a[1])||1,l=e.cachedCanvases.getCanvas("pattern",s,o),h=l.context;h.clearRect(0,0,h.canvas.width,h.canvas.height),h.beginPath(),h.rect(0,0,h.canvas.width,h.canvas.height),h.translate(-a[0],-a[1]),r=Ylt.transform(r,[1,0,0,1,a[0],a[1]]),h.transform(...e.baseTransform),this.matrix&&h.transform(...this.matrix),aft(h,this._bbox),h.fillStyle=this._createGradient(h),h.fill(),i=t.createPattern(l.canvas,"no-repeat");var c=new DOMMatrix(r);i.setTransform(c)}else aft(t,this._bbox),i=this._createGradient(t);return i}}function lft(t,e,r,n,i,a,s,o){var l,h=e.coords,c=e.colors,u=t.data,d=4*t.width;h[r+1]>h[n+1]&&(l=r,r=n,n=l,l=a,a=s,s=l),h[n+1]>h[i+1]&&(l=n,n=i,i=l,l=s,s=o,o=l),h[r+1]>h[n+1]&&(l=r,r=n,n=l,l=a,a=s,s=l);var p=(h[r]+e.offsetX)*e.scaleX,f=(h[r+1]+e.offsetY)*e.scaleY,g=(h[n]+e.offsetX)*e.scaleX,v=(h[n+1]+e.offsetY)*e.scaleY,m=(h[i]+e.offsetX)*e.scaleX,y=(h[i+1]+e.offsetY)*e.scaleY;if(!(f>=y))for(var b,w,x,A,_,k,S,E,M=c[a],T=c[a+1],C=c[a+2],P=c[s],I=c[s+1],R=c[s+2],O=c[o],L=c[o+1],D=c[o+2],F=Math.round(f),N=Math.round(y),j=F;j<=N;j++){if(j<v){var B=j<f?0:(f-j)/(f-v);b=p-(p-g)*B,w=M-(M-P)*B,x=T-(T-I)*B,A=C-(C-R)*B}else{var z=void 0;b=g-(g-m)*(z=j>y?1:v===y?0:(v-j)/(v-y)),w=P-(P-O)*z,x=I-(I-L)*z,A=R-(R-D)*z}var W=void 0;_=p-(p-m)*(W=j<f?0:j>y?1:(f-j)/(f-y)),k=M-(M-O)*W,S=T-(T-L)*W,E=C-(C-D)*W;for(var U=Math.round(Math.min(b,_)),H=Math.round(Math.max(b,_)),G=d*j+4*U,Y=U;Y<=H;Y++)(W=(b-Y)/(b-_))<0?W=0:W>1&&(W=1),u[G++]=w-(w-k)*W|0,u[G++]=x-(x-S)*W|0,u[G++]=A-(A-E)*W|0,u[G++]=255}}function hft(t,e,r){var n,i,a=e.coords,s=e.colors;switch(e.type){case"lattice":var o=e.verticesPerRow,l=Math.floor(a.length/o)-1,h=o-1;for(n=0;n<l;n++)for(var c=n*o,u=0;u<h;u++,c++)lft(t,r,a[c],a[c+1],a[c+o],s[c],s[c+1],s[c+o]),lft(t,r,a[c+o+1],a[c+1],a[c+o],s[c+o+1],s[c+1],s[c+o]);break;case"triangles":for(n=0,i=a.length;n<i;n+=3)lft(t,r,a[n],a[n+1],a[n+2],s[n],s[n+1],s[n+2]);break;default:throw new Error("illegal figure")}}class cft extends sft{constructor(t){super(),this._coords=t[2],this._colors=t[3],this._figures=t[4],this._bounds=t[5],this._bbox=t[7],this._background=t[8],this.matrix=null}_createMeshCanvas(t,e,r){var n=Math.floor(this._bounds[0]),i=Math.floor(this._bounds[1]),a=Math.ceil(this._bounds[2])-n,s=Math.ceil(this._bounds[3])-i,o=Math.min(Math.ceil(Math.abs(a*t[0]*1.1)),3e3),l=Math.min(Math.ceil(Math.abs(s*t[1]*1.1)),3e3),h=a/o,c=s/l,u={coords:this._coords,colors:this._colors,offsetX:-n,offsetY:-i,scaleX:1/h,scaleY:1/c},d=o+4,p=l+4,f=r.getCanvas("mesh",d,p),g=f.context,v=g.createImageData(o,l);if(e)for(var m=v.data,y=0,b=m.length;y<b;y+=4)m[y]=e[0],m[y+1]=e[1],m[y+2]=e[2],m[y+3]=255;for(var w of this._figures)hft(v,w,u);return g.putImageData(v,2,2),{canvas:f.canvas,offsetX:n-2*h,offsetY:i-2*c,scaleX:h,scaleY:c}}getPattern(t,e,r,n){var i;if(aft(t,this._bbox),n===ift)i=Ylt.singularValueDecompose2dScale(vht(t));else if(i=Ylt.singularValueDecompose2dScale(e.baseTransform),this.matrix){var a=Ylt.singularValueDecompose2dScale(this.matrix);i=[i[0]*a[0],i[1]*a[1]]}var s=this._createMeshCanvas(i,n===ift?null:this._background,e.cachedCanvases);return n!==ift&&(t.setTransform(...e.baseTransform),this.matrix&&t.transform(...this.matrix)),t.translate(s.offsetX,s.offsetY),t.scale(s.scaleX,s.scaleY),t.createPattern(s.canvas,"no-repeat")}}class uft extends sft{getPattern(){return"hotpink"}}var dft=1,pft=2;class fft{constructor(t,e,r,n,i){this.operatorList=t[2],this.matrix=t[3],this.bbox=t[4],this.xstep=t[5],this.ystep=t[6],this.paintType=t[7],this.tilingType=t[8],this.color=e,this.ctx=r,this.canvasGraphicsFactory=n,this.baseTransform=i}createPatternCanvas(t){var{bbox:e,operatorList:r,paintType:n,tilingType:i,color:a,canvasGraphicsFactory:s}=this,{xstep:o,ystep:l}=this;o=Math.abs(o),l=Math.abs(l),Elt("TilingType: "+i);var h=e[0],c=e[1],u=e[2],d=e[3],p=u-h,f=d-c,g=Ylt.singularValueDecompose2dScale(this.matrix),v=Ylt.singularValueDecompose2dScale(this.baseTransform),m=g[0]*v[0],y=g[1]*v[1],b=p,w=f,x=!1,A=!1,_=Math.ceil(o*m),k=Math.ceil(l*y);_>=Math.ceil(p*m)?b=o:x=!0,k>=Math.ceil(f*y)?w=l:A=!0;var S=this.getSizeAndScale(b,this.ctx.canvas.width,m),E=this.getSizeAndScale(w,this.ctx.canvas.height,y),M=t.cachedCanvases.getCanvas("pattern",S.size,E.size),T=M.context,C=s.createCanvasGraphics(T);if(C.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(C,n,a),T.translate(-S.scale*h,-E.scale*c),C.transform(S.scale,0,0,E.scale,0,0),T.save(),this.clipBbox(C,h,c,u,d),C.baseTransform=vht(C.ctx),C.executeOperatorList(r),C.endDrawing(),T.restore(),x||A){var P=M.canvas;x&&(b=o),A&&(w=l);for(var I=this.getSizeAndScale(b,this.ctx.canvas.width,m),R=this.getSizeAndScale(w,this.ctx.canvas.height,y),O=I.size,L=R.size,D=t.cachedCanvases.getCanvas("pattern-workaround",O,L),F=D.context,N=x?Math.floor(p/o):0,j=A?Math.floor(f/l):0,B=0;B<=N;B++)for(var z=0;z<=j;z++)F.drawImage(P,O*B,L*z,O,L,0,0,O,L);return{canvas:D.canvas,scaleX:I.scale,scaleY:R.scale,offsetX:h,offsetY:c}}return{canvas:M.canvas,scaleX:S.scale,scaleY:E.scale,offsetX:h,offsetY:c}}getSizeAndScale(t,e,r){var n=Math.max(fft.MAX_PATTERN_SIZE,e),i=Math.ceil(t*r);return i>=n?i=n:r=i/t,{scale:r,size:i}}clipBbox(t,e,r,n,i){var a=n-e,s=i-r;t.ctx.rect(e,r,a,s),t.current.updateRectMinMax(vht(t.ctx),[e,r,n,i]),t.clip(),t.endPath()}setFillAndStrokeStyleToContext(t,e,r){var n=t.ctx,i=t.current;switch(e){case dft:var a=this.ctx;n.fillStyle=a.fillStyle,n.strokeStyle=a.strokeStyle,i.fillColor=a.fillStyle,i.strokeColor=a.strokeStyle;break;case pft:var s=Ylt.makeHexColor(r[0],r[1],r[2]);n.fillStyle=s,n.strokeStyle=s,i.fillColor=s,i.strokeColor=s;break;default:throw new jlt("Unsupported paint type: ".concat(e))}}getPattern(t,e,r,n){var i=r;n!==ift&&(i=Ylt.transform(i,e.baseTransform),this.matrix&&(i=Ylt.transform(i,this.matrix)));var a=this.createPatternCanvas(e),s=new DOMMatrix(i);s=(s=s.translate(a.offsetX,a.offsetY)).scale(1/a.scaleX,1/a.scaleY);var o=t.createPattern(a.canvas,"repeat");return o.setTransform(s),o}}function gft(t){var{src:e,srcPos:r=0,dest:n,width:i,height:a,nonBlackColor:s=4294967295,inverseDecode:o=!1}=t,l=Hlt.isLittleEndian?4278190080:255,[h,c]=o?[s,l]:[l,s],u=i>>3,d=7&i,p=e.length;n=new Uint32Array(n.buffer);for(var f=0,g=0;g<a;g++){for(var v=r+u;r<v;r++){var m=r<p?e[r]:255;n[f++]=128&m?c:h,n[f++]=64&m?c:h,n[f++]=32&m?c:h,n[f++]=16&m?c:h,n[f++]=8&m?c:h,n[f++]=4&m?c:h,n[f++]=2&m?c:h,n[f++]=1&m?c:h}if(0!==d)for(var y=r<p?e[r++]:255,b=0;b<d;b++)n[f++]=y&1<<7-b?c:h}return{srcPos:r,destPos:f}}pit(fft,"MAX_PATTERN_SIZE",3e3);var vft=16;class mft{constructor(t){this.canvasFactory=t,this.cache=Object.create(null)}getCanvas(t,e,r){var n;return void 0!==this.cache[t]?(n=this.cache[t],this.canvasFactory.reset(n,e,r)):(n=this.canvasFactory.create(e,r),this.cache[t]=n),n}delete(t){delete this.cache[t]}clear(){for(var t in this.cache){var e=this.cache[t];this.canvasFactory.destroy(e),delete this.cache[t]}}}function yft(t,e,r,n,i,a,s,o,l,h){var[c,u,d,p,f,g]=vht(t);if(0===u&&0===d){var v=s*c+f,m=Math.round(v),y=o*p+g,b=Math.round(y),w=(s+l)*c+f,x=Math.abs(Math.round(w)-m)||1,A=(o+h)*p+g,_=Math.abs(Math.round(A)-b)||1;return t.setTransform(Math.sign(c),0,0,Math.sign(p),m,b),t.drawImage(e,r,n,i,a,0,0,x,_),t.setTransform(c,u,d,p,f,g),[x,_]}if(0===c&&0===p){var k=o*d+f,S=Math.round(k),E=s*u+g,M=Math.round(E),T=(o+h)*d+f,C=Math.abs(Math.round(T)-S)||1,P=(s+l)*u+g,I=Math.abs(Math.round(P)-M)||1;return t.setTransform(0,Math.sign(u),Math.sign(d),0,S,M),t.drawImage(e,r,n,i,a,0,0,I,C),t.setTransform(c,u,d,p,f,g),[I,C]}return t.drawImage(e,r,n,i,a,s,o,l,h),[Math.hypot(c,u)*l,Math.hypot(d,p)*h]}class bft{constructor(t,e){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=Cot,this.textMatrixScale=1,this.fontMatrix=Pot,this.leading=0,this.x=0,this.y=0,this.lineX=0,this.lineY=0,this.charSpacing=0,this.wordSpacing=0,this.textHScale=1,this.textRenderingMode=Got,this.textRise=0,this.fillColor="#000000",this.strokeColor="#000000",this.patternFill=!1,this.patternStroke=!1,this.fillAlpha=1,this.strokeAlpha=1,this.lineWidth=1,this.activeSMask=null,this.transferMaps="none",this.startNewPathAndClipBox([0,0,t,e])}clone(){var t=Object.create(this);return t.clipBox=this.clipBox.slice(),t}setCurrentPoint(t,e){this.x=t,this.y=e}updatePathMinMax(t,e,r){[e,r]=Ylt.applyTransform([e,r],t),this.minX=Math.min(this.minX,e),this.minY=Math.min(this.minY,r),this.maxX=Math.max(this.maxX,e),this.maxY=Math.max(this.maxY,r)}updateRectMinMax(t,e){var r=Ylt.applyTransform(e,t),n=Ylt.applyTransform(e.slice(2),t),i=Ylt.applyTransform([e[0],e[3]],t),a=Ylt.applyTransform([e[2],e[1]],t);this.minX=Math.min(this.minX,r[0],n[0],i[0],a[0]),this.minY=Math.min(this.minY,r[1],n[1],i[1],a[1]),this.maxX=Math.max(this.maxX,r[0],n[0],i[0],a[0]),this.maxY=Math.max(this.maxY,r[1],n[1],i[1],a[1])}updateScalingPathMinMax(t,e){Ylt.scaleMinMax(t,e),this.minX=Math.min(this.minX,e[0]),this.minY=Math.min(this.minY,e[1]),this.maxX=Math.max(this.maxX,e[2]),this.maxY=Math.max(this.maxY,e[3])}updateCurvePathMinMax(t,e,r,n,i,a,s,o,l,h){var c=Ylt.bezierBoundingBox(e,r,n,i,a,s,o,l,h);h||this.updateRectMinMax(t,c)}getPathBoundingBox(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:rft,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=[this.minX,this.minY,this.maxX,this.maxY];if(t===nft){e||Tlt("Stroke bounding box must include transform.");var n=Ylt.singularValueDecompose2dScale(e),i=n[0]*this.lineWidth/2,a=n[1]*this.lineWidth/2;r[0]-=i,r[1]-=a,r[2]+=i,r[3]+=a}return r}updateClipFromPath(){var t=Ylt.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(t||[0,0,0,0])}isEmptyClip(){return this.minX===1/0}startNewPathAndClipBox(t){this.clipBox=t,this.minX=1/0,this.minY=1/0,this.maxX=0,this.maxY=0}getClippedPathBoundingBox(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:rft,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return Ylt.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function wft(t,e){if(e instanceof ImageData)t.putImageData(e,0,0);else{var r,n,i,a,s,o=e.height,l=e.width,h=o%vft,c=(o-h)/vft,u=0===h?c:c+1,d=t.createImageData(l,vft),p=0,f=e.data,g=d.data;if(e.kind===Kot.GRAYSCALE_1BPP){var v=f.byteLength,m=new Uint32Array(g.buffer,0,g.byteLength>>2),y=m.length,b=l+7>>3,w=4294967295,x=Hlt.isLittleEndian?4278190080:255;for(n=0;n<u;n++){for(a=n<c?vft:h,r=0,i=0;i<a;i++){for(var A=v-p,_=0,k=A>b?l:8*A-7,S=-8&k,E=0,M=0;_<S;_+=8)M=f[p++],m[r++]=128&M?w:x,m[r++]=64&M?w:x,m[r++]=32&M?w:x,m[r++]=16&M?w:x,m[r++]=8&M?w:x,m[r++]=4&M?w:x,m[r++]=2&M?w:x,m[r++]=1&M?w:x;for(;_<k;_++)0===E&&(M=f[p++],E=128),m[r++]=M&E?w:x,E>>=1}for(;r<y;)m[r++]=0;t.putImageData(d,0,n*vft)}}else if(e.kind===Kot.RGBA_32BPP){for(i=0,s=l*vft*4,n=0;n<c;n++)g.set(f.subarray(p,p+s)),p+=s,t.putImageData(d,0,i),i+=vft;n<u&&(s=l*h*4,g.set(f.subarray(p,p+s)),t.putImageData(d,0,i))}else{if(e.kind!==Kot.RGB_24BPP)throw new Error("bad image kind: ".concat(e.kind));for(s=l*(a=vft),n=0;n<u;n++){for(n>=c&&(s=l*(a=h)),r=0,i=s;i--;)g[r++]=f[p++],g[r++]=f[p++],g[r++]=f[p++],g[r++]=255;t.putImageData(d,0,n*vft)}}}}function xft(t,e){if(e.bitmap)t.drawImage(e.bitmap,0,0);else for(var r=e.height,n=e.width,i=r%vft,a=(r-i)/vft,s=0===i?a:a+1,o=t.createImageData(n,vft),l=0,h=e.data,c=o.data,u=0;u<s;u++){var d=u<a?vft:i;({srcPos:l}=gft({src:h,srcPos:l,dest:c,width:n,height:d,nonBlackColor:0})),t.putImageData(o,0,u*vft)}}function Aft(t,e){for(var r of["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"])void 0!==t[r]&&(e[r]=t[r]);void 0!==t.setLineDash&&(e.setLineDash(t.getLineDash()),e.lineDashOffset=t.lineDashOffset)}function _ft(t){if(t.strokeStyle=t.fillStyle="#000000",t.fillRule="nonzero",t.globalAlpha=1,t.lineWidth=1,t.lineCap="butt",t.lineJoin="miter",t.miterLimit=10,t.globalCompositeOperation="source-over",t.font="10px sans-serif",void 0!==t.setLineDash&&(t.setLineDash([]),t.lineDashOffset=0),!Tot){var{filter:e}=t;"none"!==e&&""!==e&&(t.filter="none")}}function kft(t,e){if(e)return!0;var r=Ylt.singularValueDecompose2dScale(t);r[0]=Math.fround(r[0]),r[1]=Math.fround(r[1]);var n=Math.fround((globalThis.devicePixelRatio||1)*Zlt.PDF_TO_CSS_UNITS);return r[0]<=n&&r[1]<=n}var Sft=["butt","round","square"],Eft=["miter","round","bevel"],Mft={},Tft={},Cft=new WeakSet;class Pft{constructor(t,e,r,n,i,a,s,o){var{optionalContentConfig:l,markedContentStack:h=null}=a;dit(this,Cft),this.ctx=t,this.current=new bft(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.res=null,this.xobjs=null,this.commonObjs=e,this.objs=r,this.canvasFactory=n,this.filterFactory=i,this.groupStack=[],this.processingType3=null,this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.smaskCounter=0,this.tempSMask=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=h||[],this.optionalContentConfig=l,this.cachedCanvases=new mft(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=s,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=o,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map}getObject(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return"string"==typeof t?t.startsWith("g_")?this.commonObjs.get(t):this.objs.get(t):e}beginDrawing(t){var{transform:e,viewport:r,transparency:n=!1,background:i=null}=t,a=this.ctx.canvas.width,s=this.ctx.canvas.height,o=this.ctx.fillStyle;if(this.ctx.fillStyle=i||"#ffffff",this.ctx.fillRect(0,0,a,s),this.ctx.fillStyle=o,n){var l=this.cachedCanvases.getCanvas("transparent",a,s);this.compositeCtx=this.ctx,this.transparentCanvas=l.canvas,this.ctx=l.context,this.ctx.save(),this.ctx.transform(...vht(this.compositeCtx))}this.ctx.save(),_ft(this.ctx),e&&(this.ctx.transform(...e),this.outputScaleX=e[0],this.outputScaleY=e[0]),this.ctx.transform(...r.transform),this.viewportScale=r.scale,this.baseTransform=vht(this.ctx)}executeOperatorList(t,e,r,n){var i=t.argsArray,a=t.fnArray,s=e||0,o=i.length;if(o===s)return s;for(var l,h=o-s>10&&"function"==typeof r,c=h?Date.now()+15:0,u=0,d=this.commonObjs,p=this.objs;;){if(void 0!==n&&s===n.nextBreakPoint)return n.breakIt(s,r),s;if((l=a[s])!==xlt.dependency)this[l].apply(this,i[s]);else for(var f of i[s]){var g=f.startsWith("g_")?d:p;if(!g.has(f))return g.get(f,r),s}if(++s===o)return s;if(h&&++u>10){if(Date.now()>c)return r(),s;u=0}}}endDrawing(){for(var t of(iit(Cft,this,Ift).call(this),this.cachedCanvases.clear(),this.cachedPatterns.clear(),this._cachedBitmapsMap.values())){for(var e of t.values())"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement&&(e.width=e.height=0);t.clear()}this._cachedBitmapsMap.clear(),iit(Cft,this,Rft).call(this)}_scaleImage(t,e){for(var r,n,i,a,s=null!==(r=t.width)&&void 0!==r?r:t.displayWidth,o=null!==(n=t.height)&&void 0!==n?n:t.displayHeight,l=Math.max(Math.hypot(e[0],e[1]),1),h=Math.max(Math.hypot(e[2],e[3]),1),c=s,u=o,d="prescale1";l>2&&c>1||h>2&&u>1;){var p=c,f=u;l>2&&c>1&&(l/=c/(p=c>=16384?Math.floor(c/2)-1||1:Math.ceil(c/2))),h>2&&u>1&&(h/=u/(f=u>=16384?Math.floor(u/2)-1||1:Math.ceil(u)/2)),(a=(i=this.cachedCanvases.getCanvas(d,p,f)).context).clearRect(0,0,p,f),a.drawImage(t,0,0,c,u,0,0,p,f),t=i.canvas,c=p,u=f,d="prescale1"===d?"prescale2":"prescale1"}return{img:t,paintWidth:c,paintHeight:u}}_createMaskCanvas(t){var e,r,n,i,a=this.ctx,{width:s,height:o}=t,l=this.current.fillColor,h=this.current.patternFill,c=vht(a);if((t.bitmap||t.data)&&t.count>1){var u=t.bitmap||t.data.buffer;r=JSON.stringify(h?c:[c.slice(0,4),l]),(e=this._cachedBitmapsMap.get(u))||(e=new Map,this._cachedBitmapsMap.set(u,e));var d=e.get(r);if(d&&!h)return{canvas:d,offsetX:Math.round(Math.min(c[0],c[2])+c[4]),offsetY:Math.round(Math.min(c[1],c[3])+c[5])};n=d}n||xft((i=this.cachedCanvases.getCanvas("maskCanvas",s,o)).context,t);var p=Ylt.transform(c,[1/s,0,0,-1/o,0,0]);p=Ylt.transform(p,[1,0,0,1,0,-o]);var[f,g,v,m]=Ylt.getAxialAlignedBoundingBox([0,0,s,o],p),y=Math.round(v-f)||1,b=Math.round(m-g)||1,w=this.cachedCanvases.getCanvas("fillCanvas",y,b),x=w.context,A=f,_=g;x.translate(-A,-_),x.transform(...p),n||(n=(n=this._scaleImage(i.canvas,mht(x))).img,e&&h&&e.set(r,n)),x.imageSmoothingEnabled=kft(vht(x),t.interpolate),yft(x,n,0,0,n.width,n.height,0,0,s,o),x.globalCompositeOperation="source-in";var k=Ylt.transform(mht(x),[1,0,0,1,-A,-_]);return x.fillStyle=h?l.getPattern(a,this,k,rft):l,x.fillRect(0,0,s,o),e&&!h&&(this.cachedCanvases.delete("fillCanvas"),e.set(r,w.canvas)),{canvas:w.canvas,offsetX:Math.round(A),offsetY:Math.round(_)}}setLineWidth(t){t!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=t,this.ctx.lineWidth=t}setLineCap(t){this.ctx.lineCap=Sft[t]}setLineJoin(t){this.ctx.lineJoin=Eft[t]}setMiterLimit(t){this.ctx.miterLimit=t}setDash(t,e){var r=this.ctx;void 0!==r.setLineDash&&(r.setLineDash(t),r.lineDashOffset=e)}setRenderingIntent(t){}setFlatness(t){}setGState(t){for(var[e,r]of t)switch(e){case"LW":this.setLineWidth(r);break;case"LC":this.setLineCap(r);break;case"LJ":this.setLineJoin(r);break;case"ML":this.setMiterLimit(r);break;case"D":this.setDash(r[0],r[1]);break;case"RI":this.setRenderingIntent(r);break;case"FL":this.setFlatness(r);break;case"Font":this.setFont(r[0],r[1]);break;case"CA":this.current.strokeAlpha=r;break;case"ca":this.current.fillAlpha=r,this.ctx.globalAlpha=r;break;case"BM":this.ctx.globalCompositeOperation=r;break;case"SMask":this.current.activeSMask=r?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(r)}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){var t=this.inSMaskMode;this.current.activeSMask&&!t?this.beginSMaskMode():!this.current.activeSMask&&t&&this.endSMaskMode()}beginSMaskMode(){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");var t=this.ctx.canvas.width,e=this.ctx.canvas.height,r="smaskGroupAt"+this.groupLevel,n=this.cachedCanvases.getCanvas(r,t,e);this.suspendedCtx=this.ctx,this.ctx=n.context;var i=this.ctx;i.setTransform(...vht(this.suspendedCtx)),Aft(this.suspendedCtx,i),function(t,e){if(t._removeMirroring)throw new Error("Context is already forwarding operations.");t.__originalSave=t.save,t.__originalRestore=t.restore,t.__originalRotate=t.rotate,t.__originalScale=t.scale,t.__originalTranslate=t.translate,t.__originalTransform=t.transform,t.__originalSetTransform=t.setTransform,t.__originalResetTransform=t.resetTransform,t.__originalClip=t.clip,t.__originalMoveTo=t.moveTo,t.__originalLineTo=t.lineTo,t.__originalBezierCurveTo=t.bezierCurveTo,t.__originalRect=t.rect,t.__originalClosePath=t.closePath,t.__originalBeginPath=t.beginPath,t._removeMirroring=()=>{t.save=t.__originalSave,t.restore=t.__originalRestore,t.rotate=t.__originalRotate,t.scale=t.__originalScale,t.translate=t.__originalTranslate,t.transform=t.__originalTransform,t.setTransform=t.__originalSetTransform,t.resetTransform=t.__originalResetTransform,t.clip=t.__originalClip,t.moveTo=t.__originalMoveTo,t.lineTo=t.__originalLineTo,t.bezierCurveTo=t.__originalBezierCurveTo,t.rect=t.__originalRect,t.closePath=t.__originalClosePath,t.beginPath=t.__originalBeginPath,delete t._removeMirroring},t.save=function(){e.save(),this.__originalSave()},t.restore=function(){e.restore(),this.__originalRestore()},t.translate=function(t,r){e.translate(t,r),this.__originalTranslate(t,r)},t.scale=function(t,r){e.scale(t,r),this.__originalScale(t,r)},t.transform=function(t,r,n,i,a,s){e.transform(t,r,n,i,a,s),this.__originalTransform(t,r,n,i,a,s)},t.setTransform=function(t,r,n,i,a,s){e.setTransform(t,r,n,i,a,s),this.__originalSetTransform(t,r,n,i,a,s)},t.resetTransform=function(){e.resetTransform(),this.__originalResetTransform()},t.rotate=function(t){e.rotate(t),this.__originalRotate(t)},t.clip=function(t){e.clip(t),this.__originalClip(t)},t.moveTo=function(t,r){e.moveTo(t,r),this.__originalMoveTo(t,r)},t.lineTo=function(t,r){e.lineTo(t,r),this.__originalLineTo(t,r)},t.bezierCurveTo=function(t,r,n,i,a,s){e.bezierCurveTo(t,r,n,i,a,s),this.__originalBezierCurveTo(t,r,n,i,a,s)},t.rect=function(t,r,n,i){e.rect(t,r,n,i),this.__originalRect(t,r,n,i)},t.closePath=function(){e.closePath(),this.__originalClosePath()},t.beginPath=function(){e.beginPath(),this.__originalBeginPath()}}(i,this.suspendedCtx),this.setGState([["BM","source-over"],["ca",1],["CA",1]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),Aft(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null}compose(t){if(this.current.activeSMask){t?(t[0]=Math.floor(t[0]),t[1]=Math.floor(t[1]),t[2]=Math.ceil(t[2]),t[3]=Math.ceil(t[3])):t=[0,0,this.ctx.canvas.width,this.ctx.canvas.height];var e=this.current.activeSMask,r=this.suspendedCtx;this.composeSMask(r,e,this.ctx,t),this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.ctx.restore()}}composeSMask(t,e,r,n){var i=n[0],a=n[1],s=n[2]-i,o=n[3]-a;0!==s&&0!==o&&(this.genericComposeSMask(e.context,r,s,o,e.subtype,e.backdrop,e.transferMap,i,a,e.offsetX,e.offsetY),t.save(),t.globalAlpha=1,t.globalCompositeOperation="source-over",t.setTransform(1,0,0,1,0,0),t.drawImage(r.canvas,0,0),t.restore())}genericComposeSMask(t,e,r,n,i,a,s,o,l,h,c){var u=t.canvas,d=o-h,p=l-c;if(a){var f=Ylt.makeHexColor(...a);if(d<0||p<0||d+r>u.width||p+n>u.height){var g=this.cachedCanvases.getCanvas("maskExtension",r,n),v=g.context;v.drawImage(u,-d,-p),v.globalCompositeOperation="destination-atop",v.fillStyle=f,v.fillRect(0,0,r,n),v.globalCompositeOperation="source-over",u=g.canvas,d=p=0}else{t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0);var m=new Path2D;m.rect(d,p,r,n),t.clip(m),t.globalCompositeOperation="destination-atop",t.fillStyle=f,t.fillRect(d,p,r,n),t.restore()}}e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0),"Alpha"===i&&s?e.filter=this.filterFactory.addAlphaFilter(s):"Luminosity"===i&&(e.filter=this.filterFactory.addLuminosityFilter(s));var y=new Path2D;y.rect(o,l,r,n),e.clip(y),e.globalCompositeOperation="destination-in",e.drawImage(u,d,p,r,n,o,l,r,n),e.restore()}save(){this.inSMaskMode?(Aft(this.ctx,this.suspendedCtx),this.suspendedCtx.save()):this.ctx.save();var t=this.current;this.stateStack.push(t),this.current=t.clone()}restore(){0===this.stateStack.length&&this.inSMaskMode&&this.endSMaskMode(),0!==this.stateStack.length&&(this.current=this.stateStack.pop(),this.inSMaskMode?(this.suspendedCtx.restore(),Aft(this.suspendedCtx,this.ctx)):this.ctx.restore(),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null)}transform(t,e,r,n,i,a){this.ctx.transform(t,e,r,n,i,a),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,r){for(var n,i,a=this.ctx,s=this.current,o=s.x,l=s.y,h=vht(a),c=0===h[0]&&0===h[3]||0===h[1]&&0===h[2],u=c?r.slice(0):null,d=0,p=0,f=t.length;d<f;d++)switch(0|t[d]){case xlt.rectangle:o=e[p++],l=e[p++];var g=e[p++],v=e[p++],m=o+g,y=l+v;a.moveTo(o,l),0===g||0===v?a.lineTo(m,y):(a.lineTo(m,l),a.lineTo(m,y),a.lineTo(o,y)),c||s.updateRectMinMax(h,[o,l,m,y]),a.closePath();break;case xlt.moveTo:o=e[p++],l=e[p++],a.moveTo(o,l),c||s.updatePathMinMax(h,o,l);break;case xlt.lineTo:o=e[p++],l=e[p++],a.lineTo(o,l),c||s.updatePathMinMax(h,o,l);break;case xlt.curveTo:n=o,i=l,o=e[p+4],l=e[p+5],a.bezierCurveTo(e[p],e[p+1],e[p+2],e[p+3],o,l),s.updateCurvePathMinMax(h,n,i,e[p],e[p+1],e[p+2],e[p+3],o,l,u),p+=6;break;case xlt.curveTo2:n=o,i=l,a.bezierCurveTo(o,l,e[p],e[p+1],e[p+2],e[p+3]),s.updateCurvePathMinMax(h,n,i,o,l,e[p],e[p+1],e[p+2],e[p+3],u),o=e[p+2],l=e[p+3],p+=4;break;case xlt.curveTo3:n=o,i=l,o=e[p+2],l=e[p+3],a.bezierCurveTo(e[p],e[p+1],o,l,o,l),s.updateCurvePathMinMax(h,n,i,e[p],e[p+1],o,l,o,l,u),p+=4;break;case xlt.closePath:a.closePath()}c&&s.updateScalingPathMinMax(h,u),s.setCurrentPoint(o,l)}closePath(){this.ctx.closePath()}stroke(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],e=this.ctx,r=this.current.strokeColor;e.globalAlpha=this.current.strokeAlpha,this.contentVisible&&("object"==typeof r&&null!=r&&r.getPattern?(e.save(),e.strokeStyle=r.getPattern(e,this,mht(e),nft),this.rescaleAndStroke(!1),e.restore()):this.rescaleAndStroke(!0)),t&&this.consumePath(this.current.getClippedPathBoundingBox()),e.globalAlpha=this.current.fillAlpha}closeStroke(){this.closePath(),this.stroke()}fill(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],e=this.ctx,r=this.current.fillColor,n=!1;this.current.patternFill&&(e.save(),e.fillStyle=r.getPattern(e,this,mht(e),rft),n=!0);var i=this.current.getClippedPathBoundingBox();this.contentVisible&&null!==i&&(this.pendingEOFill?(e.fill("evenodd"),this.pendingEOFill=!1):e.fill()),n&&e.restore(),t&&this.consumePath(i)}eoFill(){this.pendingEOFill=!0,this.fill()}fillStroke(){this.fill(!1),this.stroke(!1),this.consumePath()}eoFillStroke(){this.pendingEOFill=!0,this.fillStroke()}closeFillStroke(){this.closePath(),this.fillStroke()}closeEOFillStroke(){this.pendingEOFill=!0,this.closePath(),this.fillStroke()}endPath(){this.consumePath()}clip(){this.pendingClip=Mft}eoClip(){this.pendingClip=Tft}beginText(){this.current.textMatrix=Cot,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}endText(){var t=this.pendingTextPaths,e=this.ctx;if(void 0!==t){var r=new Path2D,n=e.getTransform().invertSelf();for(var{transform:i,x:a,y:s,fontSize:o,path:l}of t)r.addPath(l,new DOMMatrix(i).preMultiplySelf(n).translate(a,s).scale(o,-o));e.clip(r),e.beginPath(),delete this.pendingTextPaths}else e.beginPath()}setCharSpacing(t){this.current.charSpacing=t}setWordSpacing(t){this.current.wordSpacing=t}setHScale(t){this.current.textHScale=t/100}setLeading(t){this.current.leading=-t}setFont(t,e){var r,n=this.commonObjs.get(t),i=this.current;if(!n)throw new Error("Can't find font for ".concat(t));if(i.fontMatrix=n.fontMatrix||Pot,0!==i.fontMatrix[0]&&0!==i.fontMatrix[3]||Mlt("Invalid font matrix for font "+t),e<0?(e=-e,i.fontDirection=-1):i.fontDirection=1,this.current.font=n,this.current.fontSize=e,!n.isType3Font){var a=n.loadedName||"sans-serif",s=(null===(r=n.systemFontInfo)||void 0===r?void 0:r.css)||'"'.concat(a,'", ').concat(n.fallbackName),o="normal";n.black?o="900":n.bold&&(o="bold");var l=n.italic?"italic":"normal",h=e;e<16?h=16:e>100&&(h=100),this.current.fontSizeScale=e/h,this.ctx.font="".concat(l," ").concat(o," ").concat(h,"px ").concat(s)}}setTextRenderingMode(t){this.current.textRenderingMode=t}setTextRise(t){this.current.textRise=t}moveText(t,e){this.current.x=this.current.lineX+=t,this.current.y=this.current.lineY+=e}setLeadingMoveText(t,e){this.setLeading(-e),this.moveText(t,e)}setTextMatrix(t,e,r,n,i,a){this.current.textMatrix=[t,e,r,n,i,a],this.current.textMatrixScale=Math.hypot(t,e),this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}nextLine(){this.moveText(0,this.current.leading)}paintChar(t,e,r,n,i){var a,s=this.ctx,o=this.current,l=o.font,h=o.textRenderingMode,c=o.fontSize/o.fontSizeScale,u=h&Xot,d=!!(h&$ot),p=o.patternFill&&!l.missingFile,f=o.patternStroke&&!l.missingFile;if((l.disableFontFace||d||p||f)&&(a=l.getPathGenerator(this.commonObjs,t)),l.disableFontFace||p||f){if(s.save(),s.translate(e,r),s.scale(c,-c),u===Got||u===Vot)if(n){var g=s.getTransform();s.setTransform(...n),s.fill(iit(Cft,this,Oft).call(this,a,g,n))}else s.fill(a);if(u===Yot||u===Vot)if(i){var v=s.getTransform();s.setTransform(...i),s.stroke(iit(Cft,this,Oft).call(this,a,v,i))}else s.lineWidth/=c,s.stroke(a);s.restore()}else u!==Got&&u!==Vot||s.fillText(t,e,r),u!==Yot&&u!==Vot||s.strokeText(t,e,r);d&&(this.pendingTextPaths||(this.pendingTextPaths=[])).push({transform:vht(s),x:e,y:r,fontSize:c,path:a})}get isFontSubpixelAAEnabled(){var{context:t}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);t.scale(1.5,1),t.fillText("I",0,10);for(var e=t.getImageData(0,0,10,10).data,r=!1,n=3;n<e.length;n+=4)if(e[n]>0&&e[n]<255){r=!0;break}return Ilt(this,"isFontSubpixelAAEnabled",r)}showText(t){var e=this.current,r=e.font;if(r.isType3Font)return this.showType3Text(t);var n=e.fontSize;if(0!==n){var i,a,s=this.ctx,o=e.fontSizeScale,l=e.charSpacing,h=e.wordSpacing,c=e.fontDirection,u=e.textHScale*c,d=t.length,p=r.vertical,f=p?1:-1,g=r.defaultVMetrics,v=n*e.fontMatrix[0],m=e.textRenderingMode===Got&&!r.disableFontFace&&!e.patternFill;if(s.save(),s.transform(...e.textMatrix),s.translate(e.x,e.y+e.textRise),c>0?s.scale(u,-1):s.scale(u,1),e.patternFill){s.save();var y=e.fillColor.getPattern(s,this,mht(s),rft);i=vht(s),s.restore(),s.fillStyle=y}if(e.patternStroke){s.save();var b=e.strokeColor.getPattern(s,this,mht(s),nft);a=vht(s),s.restore(),s.strokeStyle=b}var w=e.lineWidth,x=e.textMatrixScale;if(0===x||0===w){var A=e.textRenderingMode&Xot;A!==Yot&&A!==Vot||(w=this.getSinglePixelWidth())}else w/=x;if(1!==o&&(s.scale(o,o),w/=o),s.lineWidth=w,r.isInvalidPDFjsFont){var _=[],k=0;for(var S of t)_.push(S.unicode),k+=S.width;return s.fillText(_.join(""),0,0),e.x+=k*v*u,s.restore(),void this.compose()}var E,M=0;for(E=0;E<d;++E){var T=t[E];if("number"!=typeof T){var C=!1,P=(T.isSpace?h:0)+l,I=T.fontChar,R=T.accent,O=void 0,L=void 0,D=T.width;if(p){var F=T.vmetric||g,N=-(T.vmetric?F[1]:.5*D)*v,j=F[2]*v;D=F?-F[0]:D,O=N/o,L=(M+j)/o}else O=M/o,L=0;if(r.remeasure&&D>0){var B=1e3*s.measureText(I).width/n*o;if(D<B&&this.isFontSubpixelAAEnabled){var z=D/B;C=!0,s.save(),s.scale(z,1),O/=z}else D!==B&&(O+=(D-B)/2e3*n/o)}if(this.contentVisible&&(T.isInFont||r.missingFile))if(m&&!R)s.fillText(I,O,L);else if(this.paintChar(I,O,L,i,a),R){var W=O+n*R.offset.x/o,U=L-n*R.offset.y/o;this.paintChar(R.fontChar,W,U,i,a)}M+=p?D*v-P*c:D*v+P*c,C&&s.restore()}else M+=f*T*n/1e3}p?e.y-=M:e.x+=M*u,s.restore(),this.compose()}}showType3Text(t){var e,r,n,i,a=this.ctx,s=this.current,o=s.font,l=s.fontSize,h=s.fontDirection,c=o.vertical?1:-1,u=s.charSpacing,d=s.wordSpacing,p=s.textHScale*h,f=s.fontMatrix||Pot,g=t.length;if(!(s.textRenderingMode===qot)&&0!==l){for(this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,a.save(),a.transform(...s.textMatrix),a.translate(s.x,s.y),a.scale(p,h),e=0;e<g;++e)if("number"!=typeof(r=t[e])){var v=(r.isSpace?d:0)+u,m=o.charProcOperatorList[r.operatorListId];if(m)this.contentVisible&&(this.processingType3=r,this.save(),a.scale(l,l),a.transform(...f),this.executeOperatorList(m),this.restore()),n=Ylt.applyTransform([r.width,0],f)[0]*l+v,a.translate(n,0),s.x+=n*p;else Mlt('Type3 character "'.concat(r.operatorListId,'" is not available.'))}else i=c*r*l/1e3,this.ctx.translate(i,0),s.x+=i*p;a.restore(),this.processingType3=null}}setCharWidth(t,e){}setCharWidthAndBounds(t,e,r,n,i,a){this.ctx.rect(r,n,i-r,a-n),this.ctx.clip(),this.endPath()}getColorN_Pattern(t){var e;if("TilingPattern"===t[0]){var r=t[1],n=this.baseTransform||vht(this.ctx),i={createCanvasGraphics:t=>new Pft(t,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};e=new fft(t,r,this.ctx,i,n)}else e=this._getPattern(t[1],t[2]);return e}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments),this.current.patternStroke=!0}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0}setStrokeRGBColor(t,e,r){this.ctx.strokeStyle=this.current.strokeColor=Ylt.makeHexColor(t,e,r),this.current.patternStroke=!1}setStrokeTransparent(){this.ctx.strokeStyle=this.current.strokeColor="transparent",this.current.patternStroke=!1}setFillRGBColor(t,e,r){this.ctx.fillStyle=this.current.fillColor=Ylt.makeHexColor(t,e,r),this.current.patternFill=!1}setFillTransparent(){this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1}_getPattern(t){var e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return this.cachedPatterns.has(t)?e=this.cachedPatterns.get(t):(e=function(t){switch(t[0]){case"RadialAxial":return new oft(t);case"Mesh":return new cft(t);case"Dummy":return new uft}throw new Error("Unknown IR type: ".concat(t[0]))}(this.getObject(t)),this.cachedPatterns.set(t,e)),r&&(e.matrix=r),e}shadingFill(t){if(this.contentVisible){var e=this.ctx;this.save();var r=this._getPattern(t);e.fillStyle=r.getPattern(e,this,mht(e),ift);var n=mht(e);if(n){var{width:i,height:a}=e.canvas,[s,o,l,h]=Ylt.getAxialAlignedBoundingBox([0,0,i,a],n);this.ctx.fillRect(s,o,l-s,h-o)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}}beginInlineImage(){Tlt("Should not call beginInlineImage")}beginImageData(){Tlt("Should not call beginImageData")}paintFormXObjectBegin(t,e){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),t&&this.transform(...t),this.baseTransform=vht(this.ctx),e)){var r=e[2]-e[0],n=e[3]-e[1];this.ctx.rect(e[0],e[1],r,n),this.current.updateRectMinMax(vht(this.ctx),e),this.clip(),this.endPath()}}paintFormXObjectEnd(){this.contentVisible&&(this.restore(),this.baseTransform=this.baseTransformStack.pop())}beginGroup(t){if(this.contentVisible){this.save(),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);var e=this.ctx;t.isolated||Elt("TODO: Support non-isolated groups."),t.knockout&&Mlt("Knockout groups not supported.");var r=vht(e);if(t.matrix&&e.transform(...t.matrix),!t.bbox)throw new Error("Bounding box is required.");var n=Ylt.getAxialAlignedBoundingBox(t.bbox,vht(e)),i=[0,0,e.canvas.width,e.canvas.height];n=Ylt.intersect(n,i)||[0,0,0,0];var a=Math.floor(n[0]),s=Math.floor(n[1]),o=Math.max(Math.ceil(n[2])-a,1),l=Math.max(Math.ceil(n[3])-s,1);this.current.startNewPathAndClipBox([0,0,o,l]);var h="groupAt"+this.groupLevel;t.smask&&(h+="_smask_"+this.smaskCounter++%2);var c=this.cachedCanvases.getCanvas(h,o,l),u=c.context;u.translate(-a,-s),u.transform(...r),t.smask?this.smaskStack.push({canvas:c.canvas,context:u,offsetX:a,offsetY:s,subtype:t.smask.subtype,backdrop:t.smask.backdrop,transferMap:t.smask.transferMap||null,startTransformInverse:null}):(e.setTransform(1,0,0,1,0,0),e.translate(a,s),e.save()),Aft(e,u),this.ctx=u,this.setGState([["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(e),this.groupLevel++}}endGroup(t){if(this.contentVisible){this.groupLevel--;var e=this.ctx,r=this.groupStack.pop();if(this.ctx=r,this.ctx.imageSmoothingEnabled=!1,t.smask)this.tempSMask=this.smaskStack.pop(),this.restore();else{this.ctx.restore();var n=vht(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...n);var i=Ylt.getAxialAlignedBoundingBox([0,0,e.canvas.width,e.canvas.height],n);this.ctx.drawImage(e.canvas,0,0),this.ctx.restore(),this.compose(i)}}}beginAnnotation(t,e,r,n,i){if(iit(Cft,this,Ift).call(this),_ft(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),e){var a=e[2]-e[0],s=e[3]-e[1];if(i&&this.annotationCanvasMap){(r=r.slice())[4]-=e[0],r[5]-=e[1],(e=e.slice())[0]=e[1]=0,e[2]=a,e[3]=s;var[o,l]=Ylt.singularValueDecompose2dScale(vht(this.ctx)),{viewportScale:h}=this,c=Math.ceil(a*this.outputScaleX*h),u=Math.ceil(s*this.outputScaleY*h);this.annotationCanvas=this.canvasFactory.create(c,u);var{canvas:d,context:p}=this.annotationCanvas;this.annotationCanvasMap.set(t,d),this.annotationCanvas.savedCtx=this.ctx,this.ctx=p,this.ctx.save(),this.ctx.setTransform(o,0,0,-l,0,s*l),_ft(this.ctx)}else _ft(this.ctx),this.endPath(),this.ctx.rect(e[0],e[1],a,s),this.ctx.clip(),this.ctx.beginPath()}this.current=new bft(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...r),this.transform(...n)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),iit(Cft,this,Rft).call(this),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(t){if(this.contentVisible){var e=t.count;(t=this.getObject(t.data,t)).count=e;var r=this.ctx,n=this.processingType3;if(n&&(void 0===n.compiled&&(n.compiled=function(t){var{width:e,height:r}=t;if(e>1e3||r>1e3)return null;var n,i,a,s=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]),o=e+1,l=new Uint8Array(o*(r+1)),h=e+7&-8,c=new Uint8Array(h*r),u=0;for(var d of t.data)for(var p=128;p>0;)c[u++]=d&p?0:255,p>>=1;var f=0;for(0!==c[u=0]&&(l[0]=1,++f),i=1;i<e;i++)c[u]!==c[u+1]&&(l[i]=c[u]?2:1,++f),u++;for(0!==c[u]&&(l[i]=2,++f),n=1;n<r;n++){a=n*o,c[(u=n*h)-h]!==c[u]&&(l[a]=c[u]?1:8,++f);var g=(c[u]?4:0)+(c[u-h]?8:0);for(i=1;i<e;i++)s[g=(g>>2)+(c[u+1]?4:0)+(c[u-h+1]?8:0)]&&(l[a+i]=s[g],++f),u++;if(c[u-h]!==c[u]&&(l[a+i]=c[u]?2:4,++f),f>1e3)return null}for(a=n*o,0!==c[u=h*(r-1)]&&(l[a]=8,++f),i=1;i<e;i++)c[u]!==c[u+1]&&(l[a+i]=c[u]?4:8,++f),u++;if(0!==c[u]&&(l[a+i]=4,++f),f>1e3)return null;var v=new Int32Array([0,o,-1,0,-o,0,0,0,1]),m=new Path2D;for(n=0;f&&n<=r;n++){for(var y=n*o,b=y+e;y<b&&!l[y];)y++;if(y!==b){m.moveTo(y%o,n);var w=y,x=l[y];do{var A=v[x];do{y+=A}while(!l[y]);var _=l[y];5!==_&&10!==_?(x=_,l[y]=0):(x=_&51*x>>4,l[y]&=x>>2|x<<2),m.lineTo(y%o,y/o|0),l[y]||--f}while(w!==y);--n}}return c=null,l=null,function(t){t.save(),t.scale(1/e,-1/r),t.translate(0,-r),t.fill(m),t.beginPath(),t.restore()}}(t)),n.compiled))n.compiled(r);else{var i=this._createMaskCanvas(t),a=i.canvas;r.save(),r.setTransform(1,0,0,1,0,0),r.drawImage(a,i.offsetX,i.offsetY),r.restore(),this.compose()}}}paintImageMaskXObjectRepeat(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,i=arguments.length>4?arguments[4]:void 0,a=arguments.length>5?arguments[5]:void 0;if(this.contentVisible){t=this.getObject(t.data,t);var s=this.ctx;s.save();var o=vht(s);s.transform(e,r,n,i,0,0);var l=this._createMaskCanvas(t);s.setTransform(1,0,0,1,l.offsetX-o[4],l.offsetY-o[5]);for(var h=0,c=a.length;h<c;h+=2){var u=Ylt.transform(o,[e,r,n,i,a[h],a[h+1]]),[d,p]=Ylt.applyTransform([0,0],u);s.drawImage(l.canvas,d,p)}s.restore(),this.compose()}}paintImageMaskXObjectGroup(t){if(this.contentVisible){var e=this.ctx,r=this.current.fillColor,n=this.current.patternFill;for(var i of t){var{data:a,width:s,height:o,transform:l}=i,h=this.cachedCanvases.getCanvas("maskCanvas",s,o),c=h.context;c.save(),xft(c,this.getObject(a,i)),c.globalCompositeOperation="source-in",c.fillStyle=n?r.getPattern(c,this,mht(e),rft):r,c.fillRect(0,0,s,o),c.restore(),e.save(),e.transform(...l),e.scale(1,-1),yft(e,h.canvas,0,0,s,o,0,-1,1,1),e.restore()}this.compose()}}paintImageXObject(t){if(this.contentVisible){var e=this.getObject(t);e?this.paintInlineImageXObject(e):Mlt("Dependent image isn't ready yet")}}paintImageXObjectRepeat(t,e,r,n){if(this.contentVisible){var i=this.getObject(t);if(i){for(var a=i.width,s=i.height,o=[],l=0,h=n.length;l<h;l+=2)o.push({transform:[e,0,0,r,n[l],n[l+1]],x:0,y:0,w:a,h:s});this.paintInlineImageXObjectGroup(i,o)}else Mlt("Dependent image isn't ready yet")}}applyTransferMapsToCanvas(t){return"none"!==this.current.transferMaps&&(t.filter=this.current.transferMaps,t.drawImage(t.canvas,0,0),t.filter="none"),t.canvas}applyTransferMapsToBitmap(t){if("none"===this.current.transferMaps)return t.bitmap;var{bitmap:e,width:r,height:n}=t,i=this.cachedCanvases.getCanvas("inlineImage",r,n),a=i.context;return a.filter=this.current.transferMaps,a.drawImage(e,0,0),a.filter="none",i.canvas}paintInlineImageXObject(t){if(this.contentVisible){var e,r=t.width,n=t.height,i=this.ctx;if(this.save(),!Tot){var{filter:a}=i;"none"!==a&&""!==a&&(i.filter="none")}if(i.scale(1/r,-1/n),t.bitmap)e=this.applyTransferMapsToBitmap(t);else if("function"==typeof HTMLElement&&t instanceof HTMLElement||!t.data)e=t;else{var s=this.cachedCanvases.getCanvas("inlineImage",r,n).context;wft(s,t),e=this.applyTransferMapsToCanvas(s)}var o=this._scaleImage(e,mht(i));i.imageSmoothingEnabled=kft(vht(i),t.interpolate),yft(i,o.img,0,0,o.paintWidth,o.paintHeight,0,-n,r,n),this.compose(),this.restore()}}paintInlineImageXObjectGroup(t,e){if(this.contentVisible){var r,n=this.ctx;if(t.bitmap)r=t.bitmap;else{var i=t.width,a=t.height,s=this.cachedCanvases.getCanvas("inlineImage",i,a).context;wft(s,t),r=this.applyTransferMapsToCanvas(s)}for(var o of e)n.save(),n.transform(...o.transform),n.scale(1,-1),yft(n,r,o.x,o.y,o.w,o.h,0,-1,1,1),n.restore();this.compose()}}paintSolidColorImageMask(){this.contentVisible&&(this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(t){}markPointProps(t,e){}beginMarkedContent(t){this.markedContentStack.push({visible:!0})}beginMarkedContentProps(t,e){"OC"===t?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(e)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(){this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(){}endCompat(){}consumePath(t){var e=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(t);var r=this.ctx;this.pendingClip&&(e||(this.pendingClip===Tft?r.clip("evenodd"):r.clip()),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox),r.beginPath()}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){var t=vht(this.ctx);if(0===t[1]&&0===t[2])this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(t[0]),Math.abs(t[3]));else{var e=Math.abs(t[0]*t[3]-t[2]*t[1]),r=Math.hypot(t[0],t[2]),n=Math.hypot(t[1],t[3]);this._cachedGetSinglePixelWidth=Math.max(r,n)/e}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(-1===this._cachedScaleForStroking[0]){var t,e,{lineWidth:r}=this.current,{a:n,b:i,c:a,d:s}=this.ctx.getTransform();if(0===i&&0===a){var o=Math.abs(n),l=Math.abs(s);if(o===l)if(0===r)t=e=1/o;else{var h=o*r;t=e=h<1?1/h:1}else if(0===r)t=1/o,e=1/l;else{var c=o*r,u=l*r;t=c<1?1/c:1,e=u<1?1/u:1}}else{var d=Math.abs(n*s-i*a),p=Math.hypot(n,i),f=Math.hypot(a,s);if(0===r)t=f/d,e=p/d;else{var g=r*d;t=f>g?f/g:1,e=p>g?p/g:1}}this._cachedScaleForStroking[0]=t,this._cachedScaleForStroking[1]=e}return this._cachedScaleForStroking}rescaleAndStroke(t){var{ctx:e}=this,{lineWidth:r}=this.current,[n,i]=this.getScaleForStroking();if(e.lineWidth=r||1,1!==n||1!==i){var a=e.getLineDash();if(t&&e.save(),e.scale(n,i),a.length>0){var s=Math.max(n,i);e.setLineDash(a.map((t=>t/s))),e.lineDashOffset/=s}e.stroke(),t&&e.restore()}else e.stroke()}isContentVisible(){for(var t=this.markedContentStack.length-1;t>=0;t--)if(!this.markedContentStack[t].visible)return!1;return!0}}function Ift(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.current.activeSMask=null,this.ctx.restore(),this.transparentCanvas&&(this.ctx=this.compositeCtx,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.drawImage(this.transparentCanvas,0,0),this.ctx.restore(),this.transparentCanvas=null)}function Rft(){if(this.pageColors){var t=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if("none"!==t){var e=this.ctx.filter;this.ctx.filter=t,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=e}}}function Oft(t,e,r){var n=new Path2D;return n.addPath(t,new DOMMatrix(r).invertSelf().multiplySelf(e)),n}for(var Lft in xlt)void 0!==Pft.prototype[Lft]&&(Pft.prototype[xlt[Lft]]=Pft.prototype[Lft]);class Dft{static get workerPort(){return iit(Dft,this,Fft)._}static set workerPort(t){if(!("undefined"!=typeof Worker&&t instanceof Worker)&&null!==t)throw new Error("Invalid `workerPort` type.");Fft._=iit(Dft,this,t)}static get workerSrc(){return iit(Dft,this,Nft)._}static set workerSrc(t){if("string"!=typeof t)throw new Error("Invalid `workerSrc` type.");Nft._=iit(Dft,this,t)}}var Fft={_:null},Nft={_:""},jft=new WeakMap,Bft=new WeakMap;class zft{constructor(t){var{parsedData:e,rawData:r}=t;hit(this,jft,void 0),hit(this,Bft,void 0),cit(jft,this,e),cit(Bft,this,r)}getRaw(){return lit(Bft,this)}get(t){var e;return null!==(e=lit(jft,this).get(t))&&void 0!==e?e:null}getAll(){return Ult(lit(jft,this))}has(t){return lit(jft,this).has(t)}}var Wft=Symbol("INTERNAL"),Uft=new WeakMap,Hft=new WeakMap,Gft=new WeakMap,Yft=new WeakMap;class Vft{constructor(t,e){var{name:r,intent:n,usage:i,rbGroups:a}=e;hit(this,Uft,!1),hit(this,Hft,!1),hit(this,Gft,!1),hit(this,Yft,!0),cit(Uft,this,!!(t&Oot)),cit(Hft,this,!!(t&Lot)),this.name=r,this.intent=n,this.usage=i,this.rbGroups=a}get visible(){if(lit(Gft,this))return lit(Yft,this);if(!lit(Yft,this))return!1;var{print:t,view:e}=this.usage;return lit(Uft,this)?"OFF"!==(null==e?void 0:e.viewState):!lit(Hft,this)||"OFF"!==(null==t?void 0:t.printState)}_setVisible(t,e){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];t!==Wft&&Tlt("Internal method `_setVisible` called."),cit(Gft,this,r),cit(Yft,this,e)}}var qft=new WeakMap,Xft=new WeakMap,$ft=new WeakMap,Kft=new WeakMap,Qft=new WeakSet;class Jft{constructor(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Oot;if(dit(this,Qft),hit(this,qft,null),hit(this,Xft,new Map),hit(this,$ft,null),hit(this,Kft,null),this.renderingIntent=e,this.name=null,this.creator=null,null!==t){for(var r of(this.name=t.name,this.creator=t.creator,cit(Kft,this,t.order),t.groups))lit(Xft,this).set(r.id,new Vft(e,r));if("OFF"===t.baseState)for(var n of lit(Xft,this).values())n._setVisible(Wft,!1);for(var i of t.on)lit(Xft,this).get(i)._setVisible(Wft,!0);for(var a of t.off)lit(Xft,this).get(a)._setVisible(Wft,!1);cit($ft,this,this.getHash())}}isVisible(t){if(0===lit(Xft,this).size)return!0;if(!t)return Elt("Optional content group not defined."),!0;if("OCG"===t.type)return lit(Xft,this).has(t.id)?lit(Xft,this).get(t.id).visible:(Mlt("Optional content group not found: ".concat(t.id)),!0);if("OCMD"===t.type){if(t.expression)return iit(Qft,this,Zft).call(this,t.expression);if(!t.policy||"AnyOn"===t.policy){for(var e of t.ids){if(!lit(Xft,this).has(e))return Mlt("Optional content group not found: ".concat(e)),!0;if(lit(Xft,this).get(e).visible)return!0}return!1}if("AllOn"===t.policy){for(var r of t.ids){if(!lit(Xft,this).has(r))return Mlt("Optional content group not found: ".concat(r)),!0;if(!lit(Xft,this).get(r).visible)return!1}return!0}if("AnyOff"===t.policy){for(var n of t.ids){if(!lit(Xft,this).has(n))return Mlt("Optional content group not found: ".concat(n)),!0;if(!lit(Xft,this).get(n).visible)return!0}return!1}if("AllOff"===t.policy){for(var i of t.ids){if(!lit(Xft,this).has(i))return Mlt("Optional content group not found: ".concat(i)),!0;if(lit(Xft,this).get(i).visible)return!1}return!0}return Mlt("Unknown optional content policy ".concat(t.policy,".")),!0}return Mlt("Unknown group type ".concat(t.type,".")),!0}setVisibility(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],n=lit(Xft,this).get(t);if(n){if(r&&e&&n.rbGroups.length)for(var i of n.rbGroups)for(var a of i){var s;if(a!==t)null===(s=lit(Xft,this).get(a))||void 0===s||s._setVisible(Wft,!1,!0)}n._setVisible(Wft,!!e,!0),cit(qft,this,null)}else Mlt("Optional content group not found: ".concat(t))}setOCGState(t){var e,{state:r,preserveRB:n}=t;for(var i of r){switch(i){case"ON":case"OFF":case"Toggle":e=i;continue}var a=lit(Xft,this).get(i);if(a)switch(e){case"ON":this.setVisibility(i,!0,n);break;case"OFF":this.setVisibility(i,!1,n);break;case"Toggle":this.setVisibility(i,!a.visible,n)}}cit(qft,this,null)}get hasInitialVisibility(){return null===lit($ft,this)||this.getHash()===lit($ft,this)}getOrder(){return lit(Xft,this).size?lit(Kft,this)?lit(Kft,this).slice():[...lit(Xft,this).keys()]:null}getGroups(){return lit(Xft,this).size>0?Ult(lit(Xft,this)):null}getGroup(t){return lit(Xft,this).get(t)||null}getHash(){if(null!==lit(qft,this))return lit(qft,this);var t=new Xdt;for(var[e,r]of lit(Xft,this))t.update("".concat(e,":").concat(r.visible));return cit(qft,this,t.hexdigest())}}function Zft(t){var e=t.length;if(e<2)return!0;for(var r=t[0],n=1;n<e;n++){var i=t[n],a=void 0;if(Array.isArray(i))a=iit(Qft,this,Zft).call(this,i);else{if(!lit(Xft,this).has(i))return Mlt("Optional content group not found: ".concat(i)),!0;a=lit(Xft,this).get(i).visible}switch(r){case"And":if(!a)return!1;break;case"Or":if(a)return!0;break;case"Not":return!a;default:return!0}}return"And"===r}class tgt{constructor(t,e){var{disableRange:r=!1,disableStream:n=!1}=e;Clt(t,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');var{length:i,initialData:a,progressiveDone:s,contentDispositionFilename:o}=t;if(this._queuedChunks=[],this._progressiveDone=s,this._contentDispositionFilename=o,(null==a?void 0:a.length)>0){var l=a instanceof Uint8Array&&a.byteLength===a.buffer.byteLength?a.buffer:new Uint8Array(a).buffer;this._queuedChunks.push(l)}this._pdfDataRangeTransport=t,this._isStreamingSupported=!n,this._isRangeSupported=!r,this._contentLength=i,this._fullRequestReader=null,this._rangeReaders=[],t.addRangeListener(((t,e)=>{this._onReceiveData({begin:t,chunk:e})})),t.addProgressListener(((t,e)=>{this._onProgress({loaded:t,total:e})})),t.addProgressiveReadListener((t=>{this._onReceiveData({chunk:t})})),t.addProgressiveDoneListener((()=>{this._onProgressiveDone()})),t.transportReady()}_onReceiveData(t){var{begin:e,chunk:r}=t,n=r instanceof Uint8Array&&r.byteLength===r.buffer.byteLength?r.buffer:new Uint8Array(r).buffer;void 0===e?this._fullRequestReader?this._fullRequestReader._enqueue(n):this._queuedChunks.push(n):Clt(this._rangeReaders.some((function(t){return t._begin===e&&(t._enqueue(n),!0)})),"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}get _progressiveDataLength(){var t,e;return null!==(t=null===(e=this._fullRequestReader)||void 0===e?void 0:e._loaded)&&void 0!==t?t:0}_onProgress(t){var e,r,n,i;void 0===t.total?null===(e=this._rangeReaders[0])||void 0===e||null===(r=e.onProgress)||void 0===r||r.call(e,{loaded:t.loaded}):null===(n=this._fullRequestReader)||void 0===n||null===(i=n.onProgress)||void 0===i||i.call(n,{loaded:t.loaded,total:t.total})}_onProgressiveDone(){var t;null===(t=this._fullRequestReader)||void 0===t||t.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(t){var e=this._rangeReaders.indexOf(t);e>=0&&this._rangeReaders.splice(e,1)}getFullReader(){Clt(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");var t=this._queuedChunks;return this._queuedChunks=null,new egt(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;var r=new rgt(this,t,e);return this._pdfDataRangeTransport.requestDataRange(t,e),this._rangeReaders.push(r),r}cancelAllRequests(t){var e;for(var r of(null===(e=this._fullRequestReader)||void 0===e||e.cancel(t),this._rangeReaders.slice(0)))r.cancel(t);this._pdfDataRangeTransport.abort()}}class egt{constructor(t,e){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;for(var i of(this._stream=t,this._done=r||!1,this._filename=aht(n)?n:null,this._queuedChunks=e||[],this._loaded=0,this._queuedChunks))this._loaded+=i.byteLength;this._requests=[],this._headersReady=Promise.resolve(),t._fullRequestReader=this,this.onProgress=null}_enqueue(t){if(!this._done){if(this._requests.length>0)this._requests.shift().resolve({value:t,done:!1});else this._queuedChunks.push(t);this._loaded+=t.byteLength}}get headersReady(){return this._headersReady}get filename(){return this._filename}get isRangeSupported(){return this._stream._isRangeSupported}get isStreamingSupported(){return this._stream._isStreamingSupported}get contentLength(){return this._stream._contentLength}read(){var t=this;return sit((function*(){if(t._queuedChunks.length>0)return{value:t._queuedChunks.shift(),done:!1};if(t._done)return{value:void 0,done:!0};var e=Promise.withResolvers();return t._requests.push(e),e.promise}))()}cancel(t){for(var e of(this._done=!0,this._requests))e.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class rgt{constructor(t,e,r){this._stream=t,this._begin=e,this._end=r,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(t){if(!this._done){if(0===this._requests.length)this._queuedChunk=t;else{var e=this._requests.shift();for(var r of(e.resolve({value:t,done:!1}),this._requests))r.resolve({value:void 0,done:!0});this._requests.length=0}this._done=!0,this._stream._removeRangeReader(this)}}get isStreamingSupported(){return!1}read(){var t=this;return sit((function*(){if(t._queuedChunk){var e=t._queuedChunk;return t._queuedChunk=null,{value:e,done:!1}}if(t._done)return{value:void 0,done:!0};var r=Promise.withResolvers();return t._requests.push(r),r.promise}))()}cancel(t){for(var e of(this._done=!0,this._requests))e.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}function ngt(t,e){var r=new Headers;if(!t||!e||"object"!=typeof e)return r;for(var n in e){var i=e[n];void 0!==i&&r.append(n,i)}return r}function igt(t){try{return new URL(t).origin}catch(t){}return null}function agt(t){var{responseHeaders:e,isHttp:r,rangeChunkSize:n,disableRange:i}=t,a={allowRangeRequests:!1,suggestedLength:void 0},s=parseInt(e.get("Content-Length"),10);return Number.isInteger(s)?(a.suggestedLength=s,s<=2*n||i||!r||"bytes"!==e.get("Accept-Ranges")||"identity"!==(e.get("Content-Encoding")||"identity")||(a.allowRangeRequests=!0),a):a}function sgt(t){var e=t.get("Content-Disposition");if(e){var r=function(t){var e=!0,r=a("filename\\*","i").exec(t);if(r){var n=l(r=r[1]);return o(n=c(n=h(n=unescape(n))))}if(r=function(t){for(var e,r=[],n=a("filename\\*((?!0\\d)\\d+)(\\*?)","ig");null!==(e=n.exec(t));){var[,i,s,o]=e;if((i=parseInt(i,10))in r){if(0===i)break}else r[i]=[s,o]}for(var c=[],u=0;u<r.length&&u in r;++u){var[d,p]=r[u];p=l(p),d&&(p=unescape(p),0===u&&(p=h(p))),c.push(p)}return c.join("")}(t),r)return o(c(r));if(r=a("filename","i").exec(t)){var i=l(r=r[1]);return o(i=c(i))}function a(t,e){return new RegExp("(?:^|;)\\s*"+t+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',e)}function s(t,r){if(t){if(!/^[\x00-\xFF]+$/.test(r))return r;try{var n=new TextDecoder(t,{fatal:!0}),i=Wlt(r);r=n.decode(i),e=!1}catch(t){}}return r}function o(t){return e&&/[\x80-\xff]/.test(t)&&(t=s("utf-8",t),e&&(t=s("iso-8859-1",t))),t}function l(t){if(t.startsWith('"')){for(var e=t.slice(1).split('\\"'),r=0;r<e.length;++r){var n=e[r].indexOf('"');-1!==n&&(e[r]=e[r].slice(0,n),e.length=r+1),e[r]=e[r].replaceAll(/\\(.)/g,"$1")}t=e.join('"')}return t}function h(t){var e=t.indexOf("'");return-1===e?t:s(t.slice(0,e),t.slice(e+1).replace(/^[^']*'/,""))}function c(t){return!t.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(t)?t:t.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,(function(t,e,r,n){if("q"===r||"Q"===r)return n=(n=n.replaceAll("_"," ")).replaceAll(/=([0-9a-fA-F]{2})/g,(function(t,e){return String.fromCharCode(parseInt(e,16))})),s(e,n);try{n=atob(n)}catch(t){}return s(e,n)}))}return""}(e);if(r.includes("%"))try{r=decodeURIComponent(r)}catch(t){}if(aht(r))return r}return null}function ogt(t,e){return 404===t||0===t&&e.startsWith("file:")?new Flt('Missing PDF "'+e+'".'):new Nlt("Unexpected server response (".concat(t,') while retrieving PDF "').concat(e,'".'),t)}function lgt(t){return 200===t||206===t}function hgt(t,e,r){return{method:"GET",headers:t,signal:r.signal,mode:"cors",credentials:e?"include":"same-origin",redirect:"follow"}}function cgt(t){return t instanceof Uint8Array?t.buffer:t instanceof ArrayBuffer?t:(Mlt("getArrayBuffer - unexpected data format: ".concat(t)),new Uint8Array(t).buffer)}class ugt{constructor(t){pit(this,"_responseOrigin",null),this.source=t,this.isHttp=/^https?:/i.test(t.url),this.headers=ngt(this.isHttp,t.httpHeaders),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var t,e;return null!==(t=null===(e=this._fullRequestReader)||void 0===e?void 0:e._loaded)&&void 0!==t?t:0}getFullReader(){return Clt(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new dgt(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;var r=new pgt(this,t,e);return this._rangeRequestReaders.push(r),r}cancelAllRequests(t){var e;for(var r of(null===(e=this._fullRequestReader)||void 0===e||e.cancel(t),this._rangeRequestReaders.slice(0)))r.cancel(t)}}class dgt{constructor(t){this._stream=t,this._reader=null,this._loaded=0,this._filename=null;var e=t.source;this._withCredentials=e.withCredentials||!1,this._contentLength=e.length,this._headersCapability=Promise.withResolvers(),this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._abortController=new AbortController,this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange;var r=new Headers(t.headers),n=e.url;fetch(n,hgt(r,this._withCredentials,this._abortController)).then((e=>{if(t._responseOrigin=igt(e.url),!lgt(e.status))throw ogt(e.status,n);this._reader=e.body.getReader(),this._headersCapability.resolve();var r=e.headers,{allowRangeRequests:i,suggestedLength:a}=agt({responseHeaders:r,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=i,this._contentLength=a||this._contentLength,this._filename=sgt(r),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new Blt("Streaming is disabled."))})).catch(this._headersCapability.reject),this.onProgress=null}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}read(){var t=this;return sit((function*(){var e;yield t._headersCapability.promise;var{value:r,done:n}=yield t._reader.read();return n?{value:r,done:n}:(t._loaded+=r.byteLength,null===(e=t.onProgress)||void 0===e||e.call(t,{loaded:t._loaded,total:t._contentLength}),{value:cgt(r),done:!1})}))()}cancel(t){var e;null===(e=this._reader)||void 0===e||e.cancel(t),this._abortController.abort()}}class pgt{constructor(t,e,r){this._stream=t,this._reader=null,this._loaded=0;var n=t.source;this._withCredentials=n.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!n.disableStream,this._abortController=new AbortController;var i=new Headers(t.headers);i.append("Range","bytes=".concat(e,"-").concat(r-1));var a=n.url;fetch(a,hgt(i,this._withCredentials,this._abortController)).then((e=>{var r=igt(e.url);if(r!==t._responseOrigin)throw new Error('Expected range response-origin "'.concat(r,'" to match "').concat(t._responseOrigin,'".'));if(!lgt(e.status))throw ogt(e.status,a);this._readCapability.resolve(),this._reader=e.body.getReader()})).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}read(){var t=this;return sit((function*(){var e;yield t._readCapability.promise;var{value:r,done:n}=yield t._reader.read();return n?{value:r,done:n}:(t._loaded+=r.byteLength,null===(e=t.onProgress)||void 0===e||e.call(t,{loaded:t._loaded}),{value:cgt(r),done:!1})}))()}cancel(t){var e;null===(e=this._reader)||void 0===e||e.cancel(t),this._abortController.abort()}}class fgt{constructor(t){var{url:e,httpHeaders:r,withCredentials:n}=t;pit(this,"_responseOrigin",null),this.url=e,this.isHttp=/^https?:/i.test(e),this.headers=ngt(this.isHttp,r),this.withCredentials=n||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}request(t){var e=new XMLHttpRequest,r=this.currXhrId++,n=this.pendingRequests[r]={xhr:e};for(var[i,a]of(e.open("GET",this.url),e.withCredentials=this.withCredentials,this.headers))e.setRequestHeader(i,a);return this.isHttp&&"begin"in t&&"end"in t?(e.setRequestHeader("Range","bytes=".concat(t.begin,"-").concat(t.end-1)),n.expectedStatus=206):n.expectedStatus=200,e.responseType="arraybuffer",Clt(t.onError,"Expected `onError` callback to be provided."),e.onerror=()=>{t.onError(e.status)},e.onreadystatechange=this.onStateChange.bind(this,r),e.onprogress=this.onProgress.bind(this,r),n.onHeadersReceived=t.onHeadersReceived,n.onDone=t.onDone,n.onError=t.onError,n.onProgress=t.onProgress,e.send(null),r}onProgress(t,e){var r,n=this.pendingRequests[t];n&&(null===(r=n.onProgress)||void 0===r||r.call(n,e))}onStateChange(t,e){var r=this.pendingRequests[t];if(r){var n=r.xhr;if(n.readyState>=2&&r.onHeadersReceived&&(r.onHeadersReceived(),delete r.onHeadersReceived),4===n.readyState&&t in this.pendingRequests)if(delete this.pendingRequests[t],0===n.status&&this.isHttp)r.onError(n.status);else{var i=n.status||200;if(200===i&&206===r.expectedStatus||i===r.expectedStatus){var a=function(t){var e=t.response;return"string"!=typeof e?e:Wlt(e).buffer}(n);if(206===i){var s=n.getResponseHeader("Content-Range"),o=/bytes (\d+)-(\d+)\/(\d+)/.exec(s);o?r.onDone({begin:parseInt(o[1],10),chunk:a}):(Mlt('Missing or invalid "Content-Range" header.'),r.onError(0))}else a?r.onDone({begin:0,chunk:a}):r.onError(n.status)}else r.onError(n.status)}}}getRequestXhr(t){return this.pendingRequests[t].xhr}isPendingRequest(t){return t in this.pendingRequests}abortRequest(t){var e=this.pendingRequests[t].xhr;delete this.pendingRequests[t],e.abort()}}class ggt{constructor(t){this._source=t,this._manager=new fgt(t),this._rangeChunkSize=t.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(t){var e=this._rangeRequestReaders.indexOf(t);e>=0&&this._rangeRequestReaders.splice(e,1)}getFullReader(){return Clt(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new vgt(this._manager,this._source),this._fullRequestReader}getRangeReader(t,e){var r=new mgt(this._manager,t,e);return r.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(r),r}cancelAllRequests(t){var e;for(var r of(null===(e=this._fullRequestReader)||void 0===e||e.cancel(t),this._rangeRequestReaders.slice(0)))r.cancel(t)}}class vgt{constructor(t,e){this._manager=t,this._url=e.url,this._fullRequestId=t.request({onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._headersCapability=Promise.withResolvers(),this._disableRange=e.disableRange||!1,this._contentLength=e.length,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._isStreamingSupported=!1,this._isRangeSupported=!1,this._cachedChunks=[],this._requests=[],this._done=!1,this._storedError=void 0,this._filename=null,this.onProgress=null}_onHeadersReceived(){var t=this._fullRequestId,e=this._manager.getRequestXhr(t);this._manager._responseOrigin=igt(e.responseURL);var r=e.getAllResponseHeaders(),n=new Headers(r?r.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map((t=>{var[e,...r]=t.split(": ");return[e,r.join(": ")]})):[]),{allowRangeRequests:i,suggestedLength:a}=agt({responseHeaders:n,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});i&&(this._isRangeSupported=!0),this._contentLength=a||this._contentLength,this._filename=sgt(n),this._isRangeSupported&&this._manager.abortRequest(t),this._headersCapability.resolve()}_onDone(t){t&&(this._requests.length>0?this._requests.shift().resolve({value:t.chunk,done:!1}):this._cachedChunks.push(t.chunk));if(this._done=!0,!(this._cachedChunks.length>0)){for(var e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(t){for(var e of(this._storedError=ogt(t,this._url),this._headersCapability.reject(this._storedError),this._requests))e.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(t){var e;null===(e=this.onProgress)||void 0===e||e.call(this,{loaded:t.loaded,total:t.lengthComputable?t.total:this._contentLength})}get filename(){return this._filename}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}get contentLength(){return this._contentLength}get headersReady(){return this._headersCapability.promise}read(){var t=this;return sit((function*(){if(yield t._headersCapability.promise,t._storedError)throw t._storedError;if(t._cachedChunks.length>0)return{value:t._cachedChunks.shift(),done:!1};if(t._done)return{value:void 0,done:!0};var e=Promise.withResolvers();return t._requests.push(e),e.promise}))()}cancel(t){for(var e of(this._done=!0,this._headersCapability.reject(t),this._requests))e.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId),this._fullRequestReader=null}}class mgt{constructor(t,e,r){this._manager=t,this._url=t.url,this._requestId=t.request({begin:e,end:r,onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_onHeadersReceived(){var t,e=igt(null===(t=this._manager.getRequestXhr(this._requestId))||void 0===t?void 0:t.responseURL);e!==this._manager._responseOrigin&&(this._storedError=new Error('Expected range response-origin "'.concat(e,'" to match "').concat(this._manager._responseOrigin,'".')),this._onError(0))}_close(){var t;null===(t=this.onClosed)||void 0===t||t.call(this,this)}_onDone(t){var e=t.chunk;this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunk=e;for(var r of(this._done=!0,this._requests))r.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(t){var e;for(var r of(null!==(e=this._storedError)&&void 0!==e||(this._storedError=ogt(t,this._url)),this._requests))r.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(t){var e;this.isStreamingSupported||(null===(e=this.onProgress)||void 0===e||e.call(this,{loaded:t.loaded}))}get isStreamingSupported(){return!1}read(){var t=this;return sit((function*(){if(t._storedError)throw t._storedError;if(null!==t._queuedChunk){var e=t._queuedChunk;return t._queuedChunk=null,{value:e,done:!1}}if(t._done)return{value:void 0,done:!0};var r=Promise.withResolvers();return t._requests.push(r),r.promise}))()}cancel(t){for(var e of(this._done=!0,this._requests))e.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}}var ygt=/^[a-z][a-z0-9\-+.]+:/i;class bgt{constructor(t){this.source=t,this.url=function(t){if(ygt.test(t))return new URL(t);var e=process.getBuiltinModule("url");return new URL(e.pathToFileURL(t))}(t.url),Clt("file:"===this.url.protocol,"PDFNodeStream only supports file:// URLs."),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var t,e;return null!==(t=null===(e=this._fullRequestReader)||void 0===e?void 0:e._loaded)&&void 0!==t?t:0}getFullReader(){return Clt(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=new wgt(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;var r=new xgt(this,t,e);return this._rangeRequestReaders.push(r),r}cancelAllRequests(t){var e;for(var r of(null===(e=this._fullRequestReader)||void 0===e||e.cancel(t),this._rangeRequestReaders.slice(0)))r.cancel(t)}}class wgt{constructor(t){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null;var e=t.source;this._contentLength=e.length,this._loaded=0,this._filename=null,this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange,this._readableStream=null,this._readCapability=Promise.withResolvers(),this._headersCapability=Promise.withResolvers();var r=process.getBuiltinModule("fs");r.promises.lstat(this._url).then((t=>{this._contentLength=t.size,this._setReadableStream(r.createReadStream(this._url)),this._headersCapability.resolve()}),(t=>{"ENOENT"===t.code&&(t=new Flt('Missing PDF "'.concat(this._url,'".'))),this._storedError=t,this._headersCapability.reject(t)}))}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}read(){var t=this;return sit((function*(){var e;if(yield t._readCapability.promise,t._done)return{value:void 0,done:!0};if(t._storedError)throw t._storedError;var r=t._readableStream.read();return null===r?(t._readCapability=Promise.withResolvers(),t.read()):(t._loaded+=r.length,null===(e=t.onProgress)||void 0===e||e.call(t,{loaded:t._loaded,total:t._contentLength}),{value:new Uint8Array(r).buffer,done:!1})}))()}cancel(t){this._readableStream?this._readableStream.destroy(t):this._error(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",(()=>{this._readCapability.resolve()})),t.on("end",(()=>{t.destroy(),this._done=!0,this._readCapability.resolve()})),t.on("error",(t=>{this._error(t)})),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new Blt("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class xgt{constructor(t,e,r){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers();var n=t.source;this._isStreamingSupported=!n.disableStream;var i=process.getBuiltinModule("fs");this._setReadableStream(i.createReadStream(this._url,{start:e,end:r-1}))}get isStreamingSupported(){return this._isStreamingSupported}read(){var t=this;return sit((function*(){var e;if(yield t._readCapability.promise,t._done)return{value:void 0,done:!0};if(t._storedError)throw t._storedError;var r=t._readableStream.read();return null===r?(t._readCapability=Promise.withResolvers(),t.read()):(t._loaded+=r.length,null===(e=t.onProgress)||void 0===e||e.call(t,{loaded:t._loaded}),{value:new Uint8Array(r).buffer,done:!1})}))()}cancel(t){this._readableStream?this._readableStream.destroy(t):this._error(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",(()=>{this._readCapability.resolve()})),t.on("end",(()=>{t.destroy(),this._done=!0,this._readCapability.resolve()})),t.on("error",(t=>{this._error(t)})),this._storedError&&this._readableStream.destroy(this._storedError)}}var Agt=30,_gt=new WeakMap,kgt=new WeakMap,Sgt=new WeakMap,Egt=new WeakMap,Mgt=new WeakMap,Tgt=new WeakMap,Cgt=new WeakMap,Pgt=new WeakMap,Igt=new WeakMap,Rgt=new WeakMap,Ogt=new WeakMap,Lgt=new WeakMap,Dgt=new WeakMap,Fgt=new WeakMap,Ngt=new WeakMap,jgt=new WeakMap,Bgt=new WeakMap,zgt=new WeakMap,Wgt=new WeakSet;class Ugt{constructor(t){var e,{textContentSource:r,container:n,viewport:i}=t;if(dit(this,Wgt),hit(this,_gt,Promise.withResolvers()),hit(this,kgt,null),hit(this,Sgt,!1),hit(this,Egt,!(null===(e=globalThis.FontInspector)||void 0===e||!e.enabled)),hit(this,Mgt,null),hit(this,Tgt,null),hit(this,Cgt,0),hit(this,Pgt,0),hit(this,Igt,null),hit(this,Rgt,null),hit(this,Ogt,0),hit(this,Lgt,0),hit(this,Dgt,Object.create(null)),hit(this,Fgt,[]),hit(this,Ngt,null),hit(this,jgt,[]),hit(this,Bgt,new WeakMap),hit(this,zgt,null),r instanceof ReadableStream)cit(Ngt,this,r);else{if("object"!=typeof r)throw new Error('No "textContentSource" parameter specified.');cit(Ngt,this,new ReadableStream({start(t){t.enqueue(r),t.close()}}))}cit(kgt,this,cit(Rgt,this,n)),cit(Lgt,this,i.scale*(globalThis.devicePixelRatio||1)),cit(Ogt,this,i.rotation),cit(Tgt,this,{div:null,properties:null,ctx:null});var{pageWidth:a,pageHeight:s,pageX:o,pageY:l}=i.rawDims;cit(zgt,this,[1,0,0,-1,-o,l+s]),cit(Pgt,this,a),cit(Cgt,this,s),Xgt.call(Ugt),yht(n,i),lit(_gt,this).promise.finally((()=>{tvt._.delete(this),cit(Tgt,this,null),cit(Dgt,this,null)})).catch((()=>{}))}static get fontFamilyMap(){var{isWindows:t,isFirefox:e}=Hlt.platform;return Ilt(this,"fontFamilyMap",new Map([["sans-serif","".concat(t&&e?"Calibri, ":"","sans-serif")],["monospace","".concat(t&&e?"Lucida Console, ":"","monospace")]]))}render(){var t=()=>{lit(Igt,this).read().then((e=>{var r,{value:n,done:i}=e;i?lit(_gt,this).resolve():(null!==(r=lit(Mgt,this))&&void 0!==r||cit(Mgt,this,n.lang),Object.assign(lit(Dgt,this),n.styles),iit(Wgt,this,Hgt).call(this,n.items),t())}),lit(_gt,this).reject)};return cit(Igt,this,lit(Ngt,this).getReader()),tvt._.add(this),t(),lit(_gt,this).promise}update(t){var{viewport:e,onBefore:r=null}=t,n=e.scale*(globalThis.devicePixelRatio||1),i=e.rotation;if(i!==lit(Ogt,this)&&(null==r||r(),cit(Ogt,this,i),yht(lit(Rgt,this),{rotation:i})),n!==lit(Lgt,this)){null==r||r(),cit(Lgt,this,n);var a={div:null,properties:null,ctx:Vgt.call(Ugt,lit(Mgt,this))};for(var s of lit(jgt,this))a.properties=lit(Bgt,this).get(s),a.div=s,iit(Wgt,this,Ygt).call(this,a)}}cancel(){var t,e=new Blt("TextLayer task cancelled.");null===(t=lit(Igt,this))||void 0===t||t.cancel(e).catch((()=>{})),cit(Igt,this,null),lit(_gt,this).reject(e)}get textDivs(){return lit(jgt,this)}get textContentItemsStr(){return lit(Fgt,this)}static cleanup(){if(!(iit(Ugt,this,tvt)._.size>0)){for(var{canvas:t}of(iit(Ugt,this,Kgt)._.clear(),iit(Ugt,this,Qgt)._.values()))t.remove();iit(Ugt,this,Qgt)._.clear()}}}function Hgt(t){var e,r;if(!lit(Sgt,this)){null!==(r=(e=lit(Tgt,this)).ctx)&&void 0!==r||(e.ctx=Vgt.call(vot,lit(Mgt,this)));var n=lit(jgt,this),i=lit(Fgt,this);for(var a of t){if(n.length>1e5)return Mlt("Ignoring additional textDivs for performance reasons."),void cit(Sgt,this,!0);if(void 0!==a.str)i.push(a.str),iit(Wgt,this,Ggt).call(this,a);else if("beginMarkedContentProps"===a.type||"beginMarkedContent"===a.type){var s=lit(kgt,this);cit(kgt,this,document.createElement("span")),lit(kgt,this).classList.add("markedContent"),null!==a.id&&lit(kgt,this).setAttribute("id","".concat(a.id)),s.append(lit(kgt,this))}else"endMarkedContent"===a.type&&cit(kgt,this,lit(kgt,this).parentNode)}}}function Ggt(t){var e=document.createElement("span"),r={angle:0,canvasWidth:0,hasText:""!==t.str,hasEOL:t.hasEOL,fontSize:0};lit(jgt,this).push(e);var n=Ylt.transform(lit(zgt,this),t.transform),i=Math.atan2(n[1],n[0]),a=lit(Dgt,this)[t.fontName];a.vertical&&(i+=Math.PI/2);var s=lit(Egt,this)&&a.fontSubstitution||a.fontFamily;s=vot.fontFamilyMap.get(s)||s;var o,l,h=Math.hypot(n[2],n[3]),c=h*$gt.call(vot,s,lit(Mgt,this));0===i?(o=n[4],l=n[5]-c):(o=n[4]+c*Math.sin(i),l=n[5]-c*Math.cos(i));var u="calc(var(--scale-factor)*",d=e.style;lit(kgt,this)===lit(Rgt,this)?(d.left="".concat((100*o/lit(Pgt,this)).toFixed(2),"%"),d.top="".concat((100*l/lit(Cgt,this)).toFixed(2),"%")):(d.left="".concat(u).concat(o.toFixed(2),"px)"),d.top="".concat(u).concat(l.toFixed(2),"px)")),d.fontSize="".concat(u).concat((Zgt._*h).toFixed(2),"px)"),d.fontFamily=s,r.fontSize=h,e.setAttribute("role","presentation"),e.textContent=t.str,e.dir=t.dir,lit(Egt,this)&&(e.dataset.fontName=a.fontSubstitutionLoadedName||t.fontName),0!==i&&(r.angle=i*(180/Math.PI));var p=!1;if(t.str.length>1)p=!0;else if(" "!==t.str&&t.transform[0]!==t.transform[3]){var f=Math.abs(t.transform[0]),g=Math.abs(t.transform[3]);f!==g&&Math.max(f,g)/Math.min(f,g)>1.5&&(p=!0)}if(p&&(r.canvasWidth=a.vertical?t.height:t.width),lit(Bgt,this).set(e,r),lit(Tgt,this).div=e,lit(Tgt,this).properties=r,iit(Wgt,this,Ygt).call(this,lit(Tgt,this)),r.hasText&&lit(kgt,this).append(e),r.hasEOL){var v=document.createElement("br");v.setAttribute("role","presentation"),lit(kgt,this).append(v)}}function Ygt(t){var{div:e,properties:r,ctx:n}=t,{style:i}=e,a="";if(Zgt._>1&&(a="scale(".concat(1/Zgt._,")")),0!==r.canvasWidth&&r.hasText){var{fontFamily:s}=i,{canvasWidth:o,fontSize:l}=r;qgt.call(vot,n,l*lit(Lgt,this),s);var{width:h}=n.measureText(e.textContent);h>0&&(a="scaleX(".concat(o*lit(Lgt,this)/h,") ").concat(a))}0!==r.angle&&(a="rotate(".concat(r.angle,"deg) ").concat(a)),a.length>0&&(i.transform=a)}function Vgt(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,e=iit(vot,this,Qgt)._.get(t||(t=""));if(!e){var r=document.createElement("canvas");r.className="hiddenCanvasElement",r.lang=t,document.body.append(r),e=r.getContext("2d",{alpha:!1,willReadFrequently:!0}),iit(vot,this,Qgt)._.set(t,e),iit(vot,this,Jgt)._.set(e,{size:0,family:""})}return e}function qgt(t,e,r){var n=iit(vot,this,Jgt)._.get(t);e===n.size&&r===n.family||(t.font="".concat(e,"px ").concat(r),n.size=e,n.family=r)}function Xgt(){if(null===iit(vot,this,Zgt)._){var t=document.createElement("div");t.style.opacity=0,t.style.lineHeight=1,t.style.fontSize="1px",t.style.position="absolute",t.textContent="X",document.body.append(t),Zgt._=iit(vot,this,t.getBoundingClientRect().height),t.remove()}}function $gt(t,e){var r=iit(vot,this,Kgt)._.get(t);if(r)return r;var n=iit(vot,this,Vgt).call(this,e);n.canvas.width=n.canvas.height=Agt,iit(vot,this,qgt).call(this,n,Agt,t);var i=n.measureText(""),a=i.fontBoundingBoxAscent,s=Math.abs(i.fontBoundingBoxDescent);if(a){var o=a/(a+s);return iit(vot,this,Kgt)._.set(t,o),n.canvas.width=n.canvas.height=0,o}n.strokeStyle="red",n.clearRect(0,0,Agt,Agt),n.strokeText("g",0,0);var l=n.getImageData(0,0,Agt,Agt).data;s=0;for(var h=l.length-1-3;h>=0;h-=4)if(l[h]>0){s=Math.ceil(h/4/Agt);break}n.clearRect(0,0,Agt,Agt),n.strokeText("A",0,Agt),a=0;for(var c=0,u=(l=n.getImageData(0,0,Agt,Agt).data).length;c<u;c+=4)if(l[c]>0){a=Agt-Math.floor(c/4/Agt);break}n.canvas.width=n.canvas.height=0;var d=a?a/(a+s):.8;return iit(vot,this,Kgt)._.set(t,d),d}vot=Ugt;var Kgt={_:new Map},Qgt={_:new Map},Jgt={_:new WeakMap},Zgt={_:null},tvt={_:new Set};class evt{static textContent(t){var e=[],r={items:e,styles:Object.create(null)};return function t(r){var n;if(r){var i=null,a=r.name;if("#text"===a)i=r.value;else{if(!evt.shouldBuildText(a))return;null!=r&&null!==(n=r.attributes)&&void 0!==n&&n.textContent?i=r.attributes.textContent:r.value&&(i=r.value)}if(null!==i&&e.push({str:i}),r.children)for(var s of r.children)t(s)}}(t),r}static shouldBuildText(t){return!("textarea"===t||"input"===t||"option"===t||"select"===t)}}var rvt=65536,nvt=Tot?class extends Tpt{_createCanvas(t,e){return process.getBuiltinModule("module").createRequire(import.meta.url)("@napi-rs/canvas").createCanvas(t,e)}}:class extends Tpt{constructor(t){var{ownerDocument:e=globalThis.document,enableHWA:r=!1}=t;super({enableHWA:r}),this._document=e}_createCanvas(t,e){var r=this._document.createElement("canvas");return r.width=t,r.height=e,r}},ivt=Tot?class extends Cpt{_fetch(t){return sit((function*(){return tft(t)}))()}}:Ppt,avt=Tot?class extends Ipt{}:class extends Ipt{constructor(t){var{docId:e,ownerDocument:r=globalThis.document}=t;super(),dit(this,Bpt),hit(this,Rpt,void 0),hit(this,Opt,void 0),hit(this,Lpt,void 0),hit(this,Dpt,void 0),hit(this,Fpt,void 0),hit(this,Npt,void 0),hit(this,jpt,0),cit(Dpt,this,e),cit(Fpt,this,r)}addFilter(t){var e,r;if(!t)return"none";var n=uit(Bpt,this,zpt).get(t);if(n)return n;var[i,a,s]=iit(Bpt,this,Hpt).call(this,t),o=1===t.length?i:"".concat(i).concat(a).concat(s);if(n=uit(Bpt,this,zpt).get(o))return uit(Bpt,this,zpt).set(t,n),n;var l="g_".concat(lit(Dpt,this),"_transfer_map_").concat((cit(jpt,this,(e=lit(jpt,this),r=e++,e)),r)),h=iit(Bpt,this,Gpt).call(this,l);uit(Bpt,this,zpt).set(t,h),uit(Bpt,this,zpt).set(o,h);var c=iit(Bpt,this,qpt).call(this,l);return iit(Bpt,this,$pt).call(this,i,a,s,c),h}addHCMFilter(t,e){var r,n,i="".concat(t,"-").concat(e),a="base",s=uit(Bpt,this,Wpt).get(a);if((null===(r=s)||void 0===r?void 0:r.key)===i)return s.url;s?(null===(n=s.filter)||void 0===n||n.remove(),s.key=i,s.url="none",s.filter=null):(s={key:i,url:"none",filter:null},uit(Bpt,this,Wpt).set(a,s));if(!t||!e)return s.url;var o=iit(Bpt,this,Qpt).call(this,t);t=Ylt.makeHexColor(...o);var l=iit(Bpt,this,Qpt).call(this,e);if(e=Ylt.makeHexColor(...l),uit(Bpt,this,Upt).style.color="","#000000"===t&&"#ffffff"===e||t===e)return s.url;for(var h=new Array(256),c=0;c<=255;c++){var u=c/255;h[c]=u<=.03928?u/12.92:Math.pow((u+.055)/1.055,2.4)}var d=h.join(","),p="g_".concat(lit(Dpt,this),"_hcm_filter"),f=s.filter=iit(Bpt,this,qpt).call(this,p);iit(Bpt,this,$pt).call(this,d,d,d,f),iit(Bpt,this,Vpt).call(this,f);var g=(t,e)=>{for(var r=o[t]/255,n=l[t]/255,i=new Array(e+1),a=0;a<=e;a++)i[a]=r+a/e*(n-r);return i.join(",")};return iit(Bpt,this,$pt).call(this,g(0,5),g(1,5),g(2,5),f),s.url=iit(Bpt,this,Gpt).call(this,p),s.url}addAlphaFilter(t){var e,r,n=uit(Bpt,this,zpt).get(t);if(n)return n;var[i]=iit(Bpt,this,Hpt).call(this,[t]),a="alpha_".concat(i);if(n=uit(Bpt,this,zpt).get(a))return uit(Bpt,this,zpt).set(t,n),n;var s="g_".concat(lit(Dpt,this),"_alpha_map_").concat((cit(jpt,this,(e=lit(jpt,this),r=e++,e)),r)),o=iit(Bpt,this,Gpt).call(this,s);uit(Bpt,this,zpt).set(t,o),uit(Bpt,this,zpt).set(a,o);var l=iit(Bpt,this,qpt).call(this,s);return iit(Bpt,this,Kpt).call(this,i,l),o}addLuminosityFilter(t){var e,r,n,i,a=uit(Bpt,this,zpt).get(t||"luminosity");if(a)return a;if(t?([n]=iit(Bpt,this,Hpt).call(this,[t]),i="luminosity_".concat(n)):i="luminosity",a=uit(Bpt,this,zpt).get(i))return uit(Bpt,this,zpt).set(t,a),a;var s="g_".concat(lit(Dpt,this),"_luminosity_map_").concat((cit(jpt,this,(e=lit(jpt,this),r=e++,e)),r)),o=iit(Bpt,this,Gpt).call(this,s);uit(Bpt,this,zpt).set(t,o),uit(Bpt,this,zpt).set(i,o);var l=iit(Bpt,this,qpt).call(this,s);return iit(Bpt,this,Ypt).call(this,l),t&&iit(Bpt,this,Kpt).call(this,n,l),o}addHighlightHCMFilter(t,e,r,n,i){var a,s,o="".concat(e,"-").concat(r,"-").concat(n,"-").concat(i),l=uit(Bpt,this,Wpt).get(t);if((null===(a=l)||void 0===a?void 0:a.key)===o)return l.url;l?(null===(s=l.filter)||void 0===s||s.remove(),l.key=o,l.url="none",l.filter=null):(l={key:o,url:"none",filter:null},uit(Bpt,this,Wpt).set(t,l));if(!e||!r)return l.url;var[h,c]=[e,r].map(iit(Bpt,this,Qpt).bind(this)),u=Math.round(.2126*h[0]+.7152*h[1]+.0722*h[2]),d=Math.round(.2126*c[0]+.7152*c[1]+.0722*c[2]),[p,f]=[n,i].map(iit(Bpt,this,Qpt).bind(this));d<u&&([u,d,p,f]=[d,u,f,p]),uit(Bpt,this,Upt).style.color="";var g=(t,e,r)=>{for(var n=new Array(256),i=(d-u)/r,a=t/255,s=(e-t)/(255*r),o=0,l=0;l<=r;l++){for(var h=Math.round(u+l*i),c=a+l*s,p=o;p<=h;p++)n[p]=c;o=h+1}for(var f=o;f<256;f++)n[f]=n[o-1];return n.join(",")},v="g_".concat(lit(Dpt,this),"_hcm_").concat(t,"_filter"),m=l.filter=iit(Bpt,this,qpt).call(this,v);return iit(Bpt,this,Vpt).call(this,m),iit(Bpt,this,$pt).call(this,g(p[0],f[0],5),g(p[1],f[1],5),g(p[2],f[2],5),m),l.url=iit(Bpt,this,Gpt).call(this,v),l.url}destroy(){var t,e,r,n;arguments.length>0&&void 0!==arguments[0]&&arguments[0]&&null!==(t=lit(Npt,this))&&void 0!==t&&t.size||(null===(e=lit(Lpt,this))||void 0===e||e.parentNode.parentNode.remove(),cit(Lpt,this,null),null===(r=lit(Opt,this))||void 0===r||r.clear(),cit(Opt,this,null),null===(n=lit(Npt,this))||void 0===n||n.clear(),cit(Npt,this,null),cit(jpt,this,0))}},svt=Tot?class extends Jpt{_fetch(t){return sit((function*(){return tft(t)}))()}}:Zpt;function ovt(){var t,e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};"string"==typeof r||r instanceof URL?r={url:r}:(r instanceof ArrayBuffer||ArrayBuffer.isView(r))&&(r={data:r});var n=new hvt,{docId:i}=n,a=r.url?function(t){if(t instanceof URL)return t.href;try{return new URL(t,window.location).href}catch(e){if(Tot&&"string"==typeof t)return t}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}(r.url):null,s=r.data?function(t){if(Tot&&"undefined"!=typeof Buffer&&t instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(t instanceof Uint8Array&&t.byteLength===t.buffer.byteLength)return t;if("string"==typeof t)return Wlt(t);if(t instanceof ArrayBuffer||ArrayBuffer.isView(t)||"object"==typeof t&&!isNaN(null==t?void 0:t.length))return new Uint8Array(t);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}(r.data):null,o=r.httpHeaders||null,l=!0===r.withCredentials,h=null!==(t=r.password)&&void 0!==t?t:null,c=r.range instanceof uvt?r.range:null,u=Number.isInteger(r.rangeChunkSize)&&r.rangeChunkSize>0?r.rangeChunkSize:rvt,d=r.worker instanceof _vt?r.worker:null,p=r.verbosity,f="string"!=typeof r.docBaseUrl||iht(r.docBaseUrl)?null:r.docBaseUrl,g="string"==typeof r.cMapUrl?r.cMapUrl:null,v=!1!==r.cMapPacked,m=r.CMapReaderFactory||ivt,y="string"==typeof r.standardFontDataUrl?r.standardFontDataUrl:null,b=r.StandardFontDataFactory||svt,w=!0!==r.stopAtErrors,x=Number.isInteger(r.maxImageSize)&&r.maxImageSize>-1?r.maxImageSize:-1,A=!1!==r.isEvalSupported,_="boolean"==typeof r.isOffscreenCanvasSupported?r.isOffscreenCanvasSupported:!Tot,k="boolean"==typeof r.isImageDecoderSupported?r.isImageDecoderSupported:!Tot&&(Hlt.platform.isFirefox||!globalThis.chrome),S=Number.isInteger(r.canvasMaxAreaInBytes)?r.canvasMaxAreaInBytes:-1,E="boolean"==typeof r.disableFontFace?r.disableFontFace:Tot,M=!0===r.fontExtraProperties,T=!0===r.enableXfa,C=r.ownerDocument||globalThis.document,P=!0===r.disableRange,I=!0===r.disableStream,R=!0===r.disableAutoFetch,O=!0===r.pdfBug,L=r.CanvasFactory||nvt,D=r.FilterFactory||avt,F=!0===r.enableHWA,N=c?c.length:null!==(e=r.length)&&void 0!==e?e:NaN,j="boolean"==typeof r.useSystemFonts?r.useSystemFonts:!Tot&&!E,B="boolean"==typeof r.useWorkerFetch?r.useWorkerFetch:m===Ppt&&b===Zpt&&g&&y&&hht(g,document.baseURI)&&hht(y,document.baseURI);klt(p);var z={canvasFactory:new L({ownerDocument:C,enableHWA:F}),filterFactory:new D({docId:i,ownerDocument:C}),cMapReaderFactory:B?null:new m({baseUrl:g,isCompressed:v}),standardFontDataFactory:B?null:new b({baseUrl:y})};if(!d){var W={verbosity:p,port:Dft.workerPort};d=W.port?_vt.fromPort(W):new _vt(W),n._worker=d}var U={docId:i,apiVersion:"4.10.38",data:s,password:h,disableAutoFetch:R,rangeChunkSize:u,length:N,docBaseUrl:f,enableXfa:T,evaluatorOptions:{maxImageSize:x,disableFontFace:E,ignoreErrors:w,isEvalSupported:A,isOffscreenCanvasSupported:_,isImageDecoderSupported:k,canvasMaxAreaInBytes:S,fontExtraProperties:M,useSystemFonts:j,cMapUrl:B?g:null,standardFontDataUrl:B?y:null}},H={disableFontFace:E,fontExtraProperties:M,ownerDocument:C,pdfBug:O,styleElement:null,loadingParams:{disableAutoFetch:R,enableXfa:T}};return d.promise.then((function(){if(n.destroyed)throw new Error("Loading aborted");if(d.destroyed)throw new Error("Worker was destroyed");var t,e=d.messageHandler.sendWithPromise("GetDocRequest",U,s?[s.buffer]:null);if(c)t=new tgt(c,{disableRange:P,disableStream:I});else if(!s){if(!a)throw new Error("getDocument - no `url` parameter provided.");var r;if(Tot)if(hht(a)){if("undefined"==typeof fetch||"undefined"==typeof Response||!("body"in Response.prototype))throw new Error("getDocument - the Fetch API was disabled in Node.js, see `--no-experimental-fetch`.");r=ugt}else r=bgt;else r=hht(a)?ugt:ggt;t=new r({url:a,length:N,httpHeaders:o,withCredentials:l,rangeChunkSize:u,disableRange:P,disableStream:I})}return e.then((e=>{if(n.destroyed)throw new Error("Loading aborted");if(d.destroyed)throw new Error("Worker was destroyed");var r=new xpt(i,e,d.port),a=new Dvt(r,n,t,H,z);n._transport=a,r.send("Ready",null)}))})).catch(n._capability.reject),n}function lvt(t){return"object"==typeof t&&Number.isInteger(null==t?void 0:t.num)&&t.num>=0&&Number.isInteger(null==t?void 0:t.gen)&&t.gen>=0}class hvt{constructor(){var t,e;this._capability=Promise.withResolvers(),this._transport=null,this._worker=null,this.docId="d".concat((cvt._=(t=cvt._,e=t++,t),e)),this.destroyed=!1,this.onPassword=null,this.onProgress=null}get promise(){return this._capability.promise}destroy(){var t=this;return sit((function*(){var e;t.destroyed=!0;try{var r,n;null!==(r=t._worker)&&void 0!==r&&r.port&&(t._worker._pendingDestroy=!0),yield null===(n=t._transport)||void 0===n?void 0:n.destroy()}catch(e){var i;throw null!==(i=t._worker)&&void 0!==i&&i.port&&delete t._worker._pendingDestroy,e}t._transport=null,null===(e=t._worker)||void 0===e||e.destroy(),t._worker=null}))()}}var cvt={_:0};class uvt{constructor(t,e){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;this.length=t,this.initialData=e,this.progressiveDone=r,this.contentDispositionFilename=n,this._rangeListeners=[],this._progressListeners=[],this._progressiveReadListeners=[],this._progressiveDoneListeners=[],this._readyCapability=Promise.withResolvers()}addRangeListener(t){this._rangeListeners.push(t)}addProgressListener(t){this._progressListeners.push(t)}addProgressiveReadListener(t){this._progressiveReadListeners.push(t)}addProgressiveDoneListener(t){this._progressiveDoneListeners.push(t)}onDataRange(t,e){for(var r of this._rangeListeners)r(t,e)}onDataProgress(t,e){this._readyCapability.promise.then((()=>{for(var r of this._progressListeners)r(t,e)}))}onDataProgressiveRead(t){this._readyCapability.promise.then((()=>{for(var e of this._progressiveReadListeners)e(t)}))}onDataProgressiveDone(){this._readyCapability.promise.then((()=>{for(var t of this._progressiveDoneListeners)t()}))}transportReady(){this._readyCapability.resolve()}requestDataRange(t,e){Tlt("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}class dvt{constructor(t,e){this._pdfInfo=t,this._transport=e}get annotationStorage(){return this._transport.annotationStorage}get canvasFactory(){return this._transport.canvasFactory}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return Ilt(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(t){return this._transport.getPage(t)}getPageIndex(t){return this._transport.getPageIndex(t)}getDestinations(){return this._transport.getDestinations()}getDestination(t){return this._transport.getDestination(t)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig(){var{intent:t="display"}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getOptionalContentConfig(e)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}cleanup(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this._transport.startCleanup(t||this.isPureXfa)}destroy(){return this.loadingTask.destroy()}cachedPageNumber(t){return this._transport.cachedPageNumber(t)}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}var pvt=new WeakMap,fvt=new WeakMap,gvt=new WeakSet;class vvt{constructor(t,e,r){var n=arguments.length>3&&void 0!==arguments[3]&&arguments[3];dit(this,gvt),hit(this,pvt,null),hit(this,fvt,!1),this._pageIndex=t,this._pageInfo=e,this._transport=r,this._stats=n?new lht:null,this._pdfBug=n,this.commonObjs=r.commonObjs,this.objs=new zvt,this._maybeCleanupAfterRender=!1,this._intentStates=new Map,this.destroyed=!1}get pageNumber(){return this._pageIndex+1}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport(){var{scale:t,rotation:e=this.rotate,offsetX:r=0,offsetY:n=0,dontFlip:i=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new rht({viewBox:this.view,userUnit:this.userUnit,scale:t,rotation:e,offsetX:r,offsetY:n,dontFlip:i})}getAnnotations(){var{intent:t="display"}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getAnnotations(this._pageIndex,e)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return Ilt(this,"isPureXfa",!!this._transport._htmlForXfa)}getXfa(){var t=this;return sit((function*(){var e;return(null===(e=t._transport._htmlForXfa)||void 0===e?void 0:e.children[t._pageIndex])||null}))()}render(t){var e,r,{canvasContext:n,viewport:i,intent:a="display",annotationMode:s=zot.ENABLE,transform:o=null,background:l=null,optionalContentConfigPromise:h=null,annotationCanvasMap:c=null,pageColors:u=null,printAnnotationStorage:d=null,isEditing:p=!1}=t;null===(e=this._stats)||void 0===e||e.time("Overall");var f=this._transport.getRenderingIntent(a,s,d,p),{renderingIntent:g,cacheKey:v}=f;cit(fvt,this,!1),iit(gvt,this,yvt).call(this),h||(h=this._transport.getOptionalContentConfig(g));var m=this._intentStates.get(v);m||(m=Object.create(null),this._intentStates.set(v,m)),m.streamReaderCancelTimeout&&(clearTimeout(m.streamReaderCancelTimeout),m.streamReaderCancelTimeout=null);var y,b=!!(g&Lot);m.displayReadyCapability||(m.displayReadyCapability=Promise.withResolvers(),m.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},null===(y=this._stats)||void 0===y||y.time("Page Request"),this._pumpOperatorList(f));var w=t=>{var e;(m.renderTasks.delete(x),(this._maybeCleanupAfterRender||b)&&cit(fvt,this,!0),iit(gvt,this,mvt).call(this,!b),t?(x.capability.reject(t),this._abortOperatorList({intentState:m,reason:t instanceof Error?t:new Error(t)})):x.capability.resolve(),this._stats)&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),null!==(e=globalThis.Stats)&&void 0!==e&&e.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},x=new Yvt({callback:w,params:{canvasContext:n,viewport:i,transform:o,background:l},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:c,operatorList:m.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!b,pdfBug:this._pdfBug,pageColors:u});((r=m).renderTasks||(r.renderTasks=new Set)).add(x);var A=x.task;return Promise.all([m.displayReadyCapability.promise,h]).then((t=>{var e,[r,n]=t;if(this.destroyed)w();else{if(null===(e=this._stats)||void 0===e||e.time("Rendering"),!(n.renderingIntent&g))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");x.initializeGraphics({transparency:r,optionalContentConfig:n}),x.operatorListChanged()}})).catch(w),A}getOperatorList(){var{intent:t="display",annotationMode:e=zot.ENABLE,printAnnotationStorage:r=null,isEditing:n=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};var i,a,s,o=this._transport.getRenderingIntent(t,e,r,n,!0),l=this._intentStates.get(o.cacheKey);(l||(l=Object.create(null),this._intentStates.set(o.cacheKey,l)),l.opListReadCapability)||((i=Object.create(null)).operatorListChanged=function(){l.operatorList.lastChunk&&(l.opListReadCapability.resolve(l.operatorList),l.renderTasks.delete(i))},l.opListReadCapability=Promise.withResolvers(),((a=l).renderTasks||(a.renderTasks=new Set)).add(i),l.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},null===(s=this._stats)||void 0===s||s.time("Page Request"),this._pumpOperatorList(o));return l.opListReadCapability.promise}streamTextContent(){var{includeMarkedContent:t=!1,disableNormalization:e=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:!0===t,disableNormalization:!0===e},{highWaterMark:100,size:t=>t.items.length})}getTextContent(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(this._transport._htmlForXfa)return this.getXfa().then((t=>evt.textContent(t)));var e=this.streamTextContent(t);return new Promise((function(t,r){var n=e.getReader(),i={items:[],styles:Object.create(null),lang:null};!function e(){n.read().then((function(r){var n,{value:a,done:s}=r;s?t(i):(null!==(n=i.lang)&&void 0!==n||(i.lang=a.lang),Object.assign(i.styles,a.styles),i.items.push(...a.items),e())}),r)}()}))}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;var t=[];for(var e of this._intentStates.values())if(this._abortOperatorList({intentState:e,reason:new Error("Page was destroyed."),force:!0}),!e.opListReadCapability)for(var r of e.renderTasks)t.push(r.completed),r.cancel();return this.objs.clear(),cit(fvt,this,!1),iit(gvt,this,yvt).call(this),Promise.all(t)}cleanup(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];cit(fvt,this,!0);var e=iit(gvt,this,mvt).call(this,!1);return t&&e&&this._stats&&(this._stats=new lht),e}_startRenderPage(t,e){var r,n,i=this._intentStates.get(e);i&&(null===(r=this._stats)||void 0===r||r.timeEnd("Page Request"),null===(n=i.displayReadyCapability)||void 0===n||n.resolve(t))}_renderPageChunk(t,e){for(var r=0,n=t.length;r<n;r++)e.operatorList.fnArray.push(t.fnArray[r]),e.operatorList.argsArray.push(t.argsArray[r]);for(var i of(e.operatorList.lastChunk=t.lastChunk,e.operatorList.separateAnnots=t.separateAnnots,e.renderTasks))i.operatorListChanged();t.lastChunk&&iit(gvt,this,mvt).call(this,!0)}_pumpOperatorList(t){var{renderingIntent:e,cacheKey:r,annotationStorageSerializable:n,modifiedIds:i}=t,{map:a,transfer:s}=n,o=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:e,cacheKey:r,annotationStorage:a,modifiedIds:i},s).getReader(),l=this._intentStates.get(r);l.streamReader=o;var h=()=>{o.read().then((t=>{var{value:e,done:r}=t;r?l.streamReader=null:this._transport.destroyed||(this._renderPageChunk(e,l),h())}),(t=>{if(l.streamReader=null,!this._transport.destroyed){if(l.operatorList){for(var e of(l.operatorList.lastChunk=!0,l.renderTasks))e.operatorListChanged();iit(gvt,this,mvt).call(this,!0)}if(l.displayReadyCapability)l.displayReadyCapability.reject(t);else{if(!l.opListReadCapability)throw t;l.opListReadCapability.reject(t)}}}))};h()}_abortOperatorList(t){var{intentState:e,reason:r,force:n=!1}=t;if(e.streamReader){if(e.streamReaderCancelTimeout&&(clearTimeout(e.streamReaderCancelTimeout),e.streamReaderCancelTimeout=null),!n){if(e.renderTasks.size>0)return;if(r instanceof nht){var i=100;return r.extraDelay>0&&r.extraDelay<1e3&&(i+=r.extraDelay),void(e.streamReaderCancelTimeout=setTimeout((()=>{e.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:e,reason:r,force:!0})}),i))}}if(e.streamReader.cancel(new Blt(r.message)).catch((()=>{})),e.streamReader=null,!this._transport.destroyed){for(var[a,s]of this._intentStates)if(s===e){this._intentStates.delete(a);break}this.cleanup()}}}get stats(){return this._stats}}function mvt(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(iit(gvt,this,yvt).call(this),!lit(fvt,this)||this.destroyed)return!1;if(t)return cit(pvt,this,setTimeout((()=>{cit(pvt,this,null),iit(gvt,this,mvt).call(this,!1)}),5e3)),!1;for(var{renderTasks:e,operatorList:r}of this._intentStates.values())if(e.size>0||!r.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),cit(fvt,this,!1),!0}function yvt(){lit(pvt,this)&&(clearTimeout(lit(pvt,this)),cit(pvt,this,null))}var bvt=new WeakMap,wvt=new WeakMap;class xvt{constructor(){hit(this,bvt,new Map),hit(this,wvt,Promise.resolve())}postMessage(t,e){var r={data:structuredClone(t,e?{transfer:e}:null)};lit(wvt,this).then((()=>{for(var[t]of lit(bvt,this))t.call(this,r)}))}addEventListener(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=null;if((null==r?void 0:r.signal)instanceof AbortSignal){var{signal:i}=r;if(i.aborted)return void Mlt("LoopbackPort - cannot use an `aborted` signal.");var a=()=>this.removeEventListener(t,e);n=()=>i.removeEventListener("abort",a),i.addEventListener("abort",a)}lit(bvt,this).set(e,n)}removeEventListener(t,e){var r=lit(bvt,this).get(e);null==r||r(),lit(bvt,this).delete(e)}terminate(){for(var[,t]of lit(bvt,this))null==t||t();lit(bvt,this).clear()}}var Avt=new WeakSet;class _vt{constructor(){var{name:t=null,port:e=null,verbosity:r=Slt()}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(dit(this,Avt),this.name=t,this.destroyed=!1,this.verbosity=r,this._readyCapability=Promise.withResolvers(),this._port=null,this._webWorker=null,this._messageHandler=null,e){var n;if(null!==(n=Tvt._)&&void 0!==n&&n.has(e))throw new Error("Cannot use more than one PDFWorker per port.");return(Tvt._||(Tvt._=new WeakMap)).set(e,this),void this._initializeFromPort(e)}this._initialize()}get promise(){return this._readyCapability.promise}get port(){return this._port}get messageHandler(){return this._messageHandler}_initializeFromPort(t){this._port=t,this._messageHandler=new xpt("main","worker",t),this._messageHandler.on("ready",(function(){})),iit(Avt,this,kvt).call(this)}_initialize(){if(Mvt._||Svt(_vt))this._setupFakeWorker();else{var{workerSrc:t}=_vt;try{_vt._isSameOrigin(window.location.href,t)||(t=_vt._createCDNWrapper(new URL(t,window.location).href));var e=new Worker(t,{type:"module"}),r=new xpt("main","worker",e),n=()=>{i.abort(),r.destroy(),e.terminate(),this.destroyed?this._readyCapability.reject(new Error("Worker was destroyed")):this._setupFakeWorker()},i=new AbortController;e.addEventListener("error",(()=>{this._webWorker||n()}),{signal:i.signal}),r.on("test",(t=>{i.abort(),!this.destroyed&&t?(this._messageHandler=r,this._port=e,this._webWorker=e,iit(Avt,this,kvt).call(this)):n()})),r.on("ready",(t=>{if(i.abort(),this.destroyed)n();else try{a()}catch(t){this._setupFakeWorker()}}));var a=()=>{var t=new Uint8Array;r.send("test",t,[t.buffer])};return void a()}catch(t){Elt("The worker has been disabled.")}this._setupFakeWorker()}}_setupFakeWorker(){Mvt._||(Mlt("Setting up fake worker."),Mvt._=!0),_vt._setupFakeWorkerGlobal.then((t=>{var e,r;if(this.destroyed)this._readyCapability.reject(new Error("Worker was destroyed"));else{var n=new xvt;this._port=n;var i="fake".concat((Evt._=(e=Evt._,r=e++,e),r)),a=new xpt(i+"_worker",i,n);t.setup(a,n),this._messageHandler=new xpt(i,i+"_worker",n),iit(Avt,this,kvt).call(this)}})).catch((t=>{this._readyCapability.reject(new Error('Setting up fake worker failed: "'.concat(t.message,'".')))}))}destroy(){var t,e,r;this.destroyed=!0,null===(t=this._webWorker)||void 0===t||t.terminate(),this._webWorker=null,null===(e=Tvt._)||void 0===e||e.delete(this._port),this._port=null,null===(r=this._messageHandler)||void 0===r||r.destroy(),this._messageHandler=null}static fromPort(t){var e;if(null==t||!t.port)throw new Error("PDFWorker.fromPort - invalid method signature.");var r=null===(e=iit(_vt,this,Tvt)._)||void 0===e?void 0:e.get(t.port);if(r){if(r._pendingDestroy)throw new Error("PDFWorker.fromPort - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return r}return new _vt(t)}static get workerSrc(){if(Dft.workerSrc)return Dft.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get _setupFakeWorkerGlobal(){var t=this,e=function(){var e=sit((function*(){return uit(_vt,t,Svt)?uit(_vt,t,Svt):(yield import(t.workerSrc)).WorkerMessageHandler}));return function(){return e.apply(this,arguments)}}();return Ilt(this,"_setupFakeWorkerGlobal",e())}}function kvt(){this._readyCapability.resolve(),this._messageHandler.send("configure",{verbosity:this.verbosity})}function Svt(t){try{var e;return(null===(e=globalThis.pdfjsWorker)||void 0===e?void 0:e.WorkerMessageHandler)||null}catch(t){return null}}mot=_vt;var Evt={_:0},Mvt={_:!1},Tvt={_:void 0};Tot&&(Mvt._=iit(mot,mot,!0),Dft.workerSrc||(Dft.workerSrc="./pdf.worker.mjs")),mot._isSameOrigin=(t,e)=>{var r;try{if(!(r=new URL(t)).origin||"null"===r.origin)return!1}catch(t){return!1}var n=new URL(e,r);return r.origin===n.origin},mot._createCDNWrapper=t=>{var e='await import("'.concat(t,'");');return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))};var Cvt=new WeakMap,Pvt=new WeakMap,Ivt=new WeakMap,Rvt=new WeakMap,Ovt=new WeakMap,Lvt=new WeakSet;class Dvt{constructor(t,e,r,n,i){dit(this,Lvt),hit(this,Cvt,new Map),hit(this,Pvt,new Map),hit(this,Ivt,new Map),hit(this,Rvt,new Map),hit(this,Ovt,null),this.messageHandler=t,this.loadingTask=e,this.commonObjs=new zvt,this.fontLoader=new apt({ownerDocument:n.ownerDocument,styleElement:n.styleElement}),this.loadingParams=n.loadingParams,this._params=n,this.canvasFactory=i.canvasFactory,this.filterFactory=i.filterFactory,this.cMapReaderFactory=i.cMapReaderFactory,this.standardFontDataFactory=i.standardFontDataFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=r,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.setupMessageHandler()}get annotationStorage(){return Ilt(this,"annotationStorage",new tpt)}getRenderingIntent(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:zot.ENABLE,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=arguments.length>3&&void 0!==arguments[3]&&arguments[3],i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],a=Oot,s=$dt;switch(t){case"any":a=Rot;break;case"display":break;case"print":a=Lot;break;default:Mlt("getRenderingIntent - invalid intent: ".concat(t))}var o=a&Lot&&r instanceof npt?r:this.annotationStorage;switch(e){case zot.DISABLE:a+=Not;break;case zot.ENABLE:break;case zot.ENABLE_FORMS:a+=Dot;break;case zot.ENABLE_STORAGE:a+=Fot,s=o.serializable;break;default:Mlt("getRenderingIntent - invalid annotationMode: ".concat(e))}n&&(a+=jot),i&&(a+=Bot);var{ids:l,hash:h}=o.modifiedIds;return{renderingIntent:a,cacheKey:[a,s.hash,h].join("_"),annotationStorageSerializable:s,modifiedIds:l}}destroy(){var t;if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),null===(t=lit(Ovt,this))||void 0===t||t.reject(new Error("Worker was destroyed during onPassword callback"));var e=[];for(var r of lit(Pvt,this).values())e.push(r._destroy());lit(Pvt,this).clear(),lit(Ivt,this).clear(),lit(Rvt,this).clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();var n=this.messageHandler.sendWithPromise("Terminate",null);return e.push(n),Promise.all(e).then((()=>{var t,e;this.commonObjs.clear(),this.fontLoader.clear(),lit(Cvt,this).clear(),this.filterFactory.destroy(),Ugt.cleanup(),null===(t=this._networkStream)||void 0===t||t.cancelAllRequests(new Blt("Worker was terminated.")),null===(e=this.messageHandler)||void 0===e||e.destroy(),this.messageHandler=null,this.destroyCapability.resolve()}),this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){var t=this,{messageHandler:e,loadingTask:r}=this;e.on("GetReader",((t,e)=>{Clt(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=t=>{this._lastProgress={loaded:t.loaded,total:t.total}},e.onPull=()=>{this._fullReader.read().then((function(t){var{value:r,done:n}=t;n?e.close():(Clt(r instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),e.enqueue(new Uint8Array(r),1,[r]))})).catch((t=>{e.error(t)}))},e.onCancel=t=>{this._fullReader.cancel(t),e.ready.catch((t=>{if(!this.destroyed)throw t}))}})),e.on("ReaderHeadersReady",function(){var e=sit((function*(e){yield t._fullReader.headersReady;var{isStreamingSupported:n,isRangeSupported:i,contentLength:a}=t._fullReader;if(!n||!i){var s;if(t._lastProgress)null===(s=r.onProgress)||void 0===s||s.call(r,t._lastProgress);t._fullReader.onProgress=t=>{var e;null===(e=r.onProgress)||void 0===e||e.call(r,{loaded:t.loaded,total:t.total})}}return{isStreamingSupported:n,isRangeSupported:i,contentLength:a}}));return function(t){return e.apply(this,arguments)}}()),e.on("GetRangeReader",((t,e)=>{Clt(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");var r=this._networkStream.getRangeReader(t.begin,t.end);r?(e.onPull=()=>{r.read().then((function(t){var{value:r,done:n}=t;n?e.close():(Clt(r instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),e.enqueue(new Uint8Array(r),1,[r]))})).catch((t=>{e.error(t)}))},e.onCancel=t=>{r.cancel(t),e.ready.catch((t=>{if(!this.destroyed)throw t}))}):e.close()})),e.on("GetDoc",(t=>{var{pdfInfo:e}=t;this._numPages=e.numPages,this._htmlForXfa=e.htmlForXfa,delete e.htmlForXfa,r._capability.resolve(new dvt(e,this))})),e.on("DocException",(t=>{r._capability.reject(ypt(t))})),e.on("PasswordRequest",(t=>{cit(Ovt,this,Promise.withResolvers());try{if(!r.onPassword)throw ypt(t);r.onPassword((t=>{t instanceof Error?lit(Ovt,this).reject(t):lit(Ovt,this).resolve({password:t})}),t.code)}catch(t){lit(Ovt,this).reject(t)}return lit(Ovt,this).promise})),e.on("DataLoaded",(t=>{var e;null===(e=r.onProgress)||void 0===e||e.call(r,{loaded:t.length,total:t.length}),this.downloadInfoCapability.resolve(t)})),e.on("StartRenderPage",(t=>{this.destroyed||lit(Pvt,this).get(t.pageIndex)._startRenderPage(t.transparency,t.cacheKey)})),e.on("commonobj",(t=>{var r,[n,i,a]=t;if(this.destroyed)return null;if(this.commonObjs.has(n))return null;switch(i){case"Font":var{disableFontFace:s,fontExtraProperties:o,pdfBug:l}=this._params;if("error"in a){var h=a.error;Mlt("Error during font loading: ".concat(h)),this.commonObjs.resolve(n,h);break}var c=l&&null!==(r=globalThis.FontInspector)&&void 0!==r&&r.enabled?(t,e)=>globalThis.FontInspector.fontAdded(t,e):null,u=new spt(a,{disableFontFace:s,fontExtraProperties:o,inspectFont:c});this.fontLoader.bind(u).catch((()=>e.sendWithPromise("FontFallback",{id:n}))).finally((()=>{!o&&u.data&&(u.data=null),this.commonObjs.resolve(n,u)}));break;case"CopyLocalImage":var{imageRef:d}=a;for(var p of(Clt(d,"The imageRef must be defined."),lit(Pvt,this).values()))for(var[,f]of p.objs)if((null==f?void 0:f.ref)===d)return f.dataLen?(this.commonObjs.resolve(n,structuredClone(f)),f.dataLen):null;break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(n,a);break;default:throw new Error("Got unknown common object type ".concat(i))}return null})),e.on("obj",(t=>{var[e,r,n,i]=t;if(!this.destroyed){var a,s=lit(Pvt,this).get(r);if(!s.objs.has(e))if(0!==s._intentStates.size)switch(n){case"Image":s.objs.resolve(e,i),(null==i?void 0:i.dataLen)>1e7&&(s._maybeCleanupAfterRender=!0);break;case"Pattern":s.objs.resolve(e,i);break;default:throw new Error("Got unknown object type ".concat(n))}else null==i||null===(a=i.bitmap)||void 0===a||a.close()}})),e.on("DocProgress",(t=>{var e;this.destroyed||null===(e=r.onProgress)||void 0===e||e.call(r,{loaded:t.loaded,total:t.total})})),e.on("FetchBuiltInCMap",function(){var e=sit((function*(e){if(t.destroyed)throw new Error("Worker was destroyed.");if(!t.cMapReaderFactory)throw new Error("CMapReaderFactory not initialized, see the `useWorkerFetch` parameter.");return t.cMapReaderFactory.fetch(e)}));return function(t){return e.apply(this,arguments)}}()),e.on("FetchStandardFontData",function(){var e=sit((function*(e){if(t.destroyed)throw new Error("Worker was destroyed.");if(!t.standardFontDataFactory)throw new Error("StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter.");return t.standardFontDataFactory.fetch(e)}));return function(t){return e.apply(this,arguments)}}())}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){var t,e;this.annotationStorage.size<=0&&Mlt("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");var{map:r,transfer:n}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:r,filename:null!==(t=null===(e=this._fullReader)||void 0===e?void 0:e.filename)&&void 0!==t?t:null},n).finally((()=>{this.annotationStorage.resetModified()}))}getPage(t){if(!Number.isInteger(t)||t<=0||t>this._numPages)return Promise.reject(new Error("Invalid page request."));var e=t-1,r=lit(Ivt,this).get(e);if(r)return r;var n=this.messageHandler.sendWithPromise("GetPage",{pageIndex:e}).then((r=>{if(this.destroyed)throw new Error("Transport destroyed");r.refStr&&lit(Rvt,this).set(r.refStr,t);var n=new vvt(e,r,this,this._params.pdfBug);return lit(Pvt,this).set(e,n),n}));return lit(Ivt,this).set(e,n),n}getPageIndex(t){return lvt(t)?this.messageHandler.sendWithPromise("GetPageIndex",{num:t.num,gen:t.gen}):Promise.reject(new Error("Invalid pageIndex request."))}getAnnotations(t,e){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:t,intent:e})}getFieldObjects(){return iit(Lvt,this,Fvt).call(this,"GetFieldObjects")}hasJSActions(){return iit(Lvt,this,Fvt).call(this,"HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(t){return"string"!=typeof t?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:t})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getDocJSActions(){return iit(Lvt,this,Fvt).call(this,"GetDocJSActions")}getPageJSActions(t){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:t})}getStructTree(t){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:t})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(t){return iit(Lvt,this,Fvt).call(this,"GetOptionalContentConfig").then((e=>new Jft(e,t)))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){var t="GetMetadata",e=lit(Cvt,this).get(t);if(e)return e;var r=this.messageHandler.sendWithPromise(t,null).then((t=>{var e,r,n,i;return{info:t[0],metadata:t[1]?new zft(t[1]):null,contentDispositionFilename:null!==(e=null===(r=this._fullReader)||void 0===r?void 0:r.filename)&&void 0!==e?e:null,contentLength:null!==(n=null===(i=this._fullReader)||void 0===i?void 0:i.contentLength)&&void 0!==n?n:null}}));return lit(Cvt,this).set(t,r),r}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}startCleanup(){var t=arguments,e=this;return sit((function*(){var r=t.length>0&&void 0!==t[0]&&t[0];if(!e.destroyed){for(var n of(yield e.messageHandler.sendWithPromise("Cleanup",null),lit(Pvt,e).values())){if(!n.cleanup())throw new Error("startCleanup: Page ".concat(n.pageNumber," is currently rendering."))}e.commonObjs.clear(),r||e.fontLoader.clear(),lit(Cvt,e).clear(),e.filterFactory.destroy(!0),Ugt.cleanup()}}))()}cachedPageNumber(t){var e;if(!lvt(t))return null;var r=0===t.gen?"".concat(t.num,"R"):"".concat(t.num,"R").concat(t.gen);return null!==(e=lit(Rvt,this).get(r))&&void 0!==e?e:null}}function Fvt(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=lit(Cvt,this).get(t);if(r)return r;var n=this.messageHandler.sendWithPromise(t,e);return lit(Cvt,this).set(t,n),n}var Nvt=Symbol("INITIAL_DATA"),jvt=new WeakMap,Bvt=new WeakSet;class zvt{constructor(){dit(this,Bvt),hit(this,jvt,Object.create(null))}get(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(e){var r=iit(Bvt,this,Wvt).call(this,t);return r.promise.then((()=>e(r.data))),null}var n=lit(jvt,this)[t];if(!n||n.data===Nvt)throw new Error("Requesting object that isn't resolved yet ".concat(t,"."));return n.data}has(t){var e=lit(jvt,this)[t];return!!e&&e.data!==Nvt}delete(t){var e=lit(jvt,this)[t];return!(!e||e.data===Nvt)&&(delete lit(jvt,this)[t],!0)}resolve(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=iit(Bvt,this,Wvt).call(this,t);r.data=e,r.resolve()}clear(){for(var t in lit(jvt,this)){var e,{data:r}=lit(jvt,this)[t];null==r||null===(e=r.bitmap)||void 0===e||e.close()}cit(jvt,this,Object.create(null))}*[Symbol.iterator](){for(var t in lit(jvt,this)){var{data:e}=lit(jvt,this)[t];e!==Nvt&&(yield[t,e])}}}function Wvt(t){var e;return(e=lit(jvt,this))[t]||(e[t]=git(git({},Promise.withResolvers()),{},{data:Nvt}))}var Uvt=new WeakMap;class Hvt{constructor(t){hit(this,Uvt,null),cit(Uvt,this,t),this.onContinue=null}get promise(){return lit(Uvt,this).capability.promise}cancel(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;lit(Uvt,this).cancel(null,t)}get separateAnnots(){var{separateAnnots:t}=lit(Uvt,this).operatorList;if(!t)return!1;var{annotationCanvasMap:e}=lit(Uvt,this);return t.form||t.canvas&&(null==e?void 0:e.size)>0}}var Gvt=new WeakMap;class Yvt{constructor(t){var{callback:e,params:r,objs:n,commonObjs:i,annotationCanvasMap:a,operatorList:s,pageIndex:o,canvasFactory:l,filterFactory:h,useRequestAnimationFrame:c=!1,pdfBug:u=!1,pageColors:d=null}=t;hit(this,Gvt,null),this.callback=e,this.params=r,this.objs=n,this.commonObjs=i,this.annotationCanvasMap=a,this.operatorListIdx=null,this.operatorList=s,this._pageIndex=o,this.canvasFactory=l,this.filterFactory=h,this._pdfBug=u,this.pageColors=d,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=!0===c&&"undefined"!=typeof window,this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new Hvt(this),this._cancelBound=this.cancel.bind(this),this._continueBound=this._continue.bind(this),this._scheduleNextBound=this._scheduleNext.bind(this),this._nextBound=this._next.bind(this),this._canvas=r.canvasContext.canvas}get completed(){return this.capability.promise.catch((function(){}))}initializeGraphics(t){var e,r,{transparency:n=!1,optionalContentConfig:i}=t;if(!this.cancelled){if(this._canvas){if(Vvt._.has(this._canvas))throw new Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");Vvt._.add(this._canvas)}this._pdfBug&&null!==(e=globalThis.StepperManager)&&void 0!==e&&e.enabled&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());var{canvasContext:a,viewport:s,transform:o,background:l}=this.params;this.gfx=new Pft(a,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:i},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:o,viewport:s,transparency:n,background:l}),this.operatorListIdx=0,this.graphicsReady=!0,null===(r=this.graphicsReadyCallback)||void 0===r||r.call(this)}}cancel(){var t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;this.running=!1,this.cancelled=!0,null===(t=this.gfx)||void 0===t||t.endDrawing(),lit(Gvt,this)&&(window.cancelAnimationFrame(lit(Gvt,this)),cit(Gvt,this,null)),Vvt._.delete(this._canvas),this.callback(e||new nht("Rendering cancelled, page ".concat(this._pageIndex+1),r))}operatorListChanged(){var t;this.graphicsReady?(null===(t=this.stepper)||void 0===t||t.updateOperatorList(this.operatorList),this.running||this._continue()):this.graphicsReadyCallback||(this.graphicsReadyCallback=this._continueBound)}_continue(){this.running=!0,this.cancelled||(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?cit(Gvt,this,window.requestAnimationFrame((()=>{cit(Gvt,this,null),this._nextBound().catch(this._cancelBound)}))):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}_next(){var t=this;return sit((function*(){t.cancelled||(t.operatorListIdx=t.gfx.executeOperatorList(t.operatorList,t.operatorListIdx,t._continueBound,t.stepper),t.operatorListIdx===t.operatorList.argsArray.length&&(t.running=!1,t.operatorList.lastChunk&&(t.gfx.endDrawing(),Vvt._.delete(t._canvas),t.callback())))}))()}}var Vvt={_:new WeakSet},qvt="4.10.38",Xvt="f9bea397f";function $vt(t){return Math.floor(255*Math.max(0,Math.min(1,t))).toString(16).padStart(2,"0")}function Kvt(t){return Math.max(0,Math.min(255,255*t))}class Qvt{static CMYK_G(t){var[e,r,n,i]=t;return["G",1-Math.min(1,.3*e+.59*n+.11*r+i)]}static G_CMYK(t){var[e]=t;return["CMYK",0,0,0,1-e]}static G_RGB(t){var[e]=t;return["RGB",e,e,e]}static G_rgb(t){var[e]=t;return[e=Kvt(e),e,e]}static G_HTML(t){var[e]=t,r=$vt(e);return"#".concat(r).concat(r).concat(r)}static RGB_G(t){var[e,r,n]=t;return["G",.3*e+.59*r+.11*n]}static RGB_rgb(t){return t.map(Kvt)}static RGB_HTML(t){return"#".concat(t.map($vt).join(""))}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB(t){var[e,r,n,i]=t;return["RGB",1-Math.min(1,e+i),1-Math.min(1,n+i),1-Math.min(1,r+i)]}static CMYK_rgb(t){var[e,r,n,i]=t;return[Kvt(1-Math.min(1,e+i)),Kvt(1-Math.min(1,n+i)),Kvt(1-Math.min(1,r+i))]}static CMYK_HTML(t){var e=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(e)}static RGB_CMYK(t){var[e,r,n]=t,i=1-e,a=1-r,s=1-n;return["CMYK",i,a,s,Math.min(i,a,s)]}}class Jvt{create(t,e){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(t<=0||e<=0)throw new Error("Invalid SVG dimensions");var n=this._createSVG("svg:svg");return n.setAttribute("version","1.1"),r||(n.setAttribute("width","".concat(t,"px")),n.setAttribute("height","".concat(e,"px"))),n.setAttribute("preserveAspectRatio","none"),n.setAttribute("viewBox","0 0 ".concat(t," ").concat(e)),n}createElement(t){if("string"!=typeof t)throw new Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){Tlt("Abstract method `_createSVG` called.")}}class Zvt extends Jvt{_createSVG(t){return document.createElementNS(Jlt,t)}}class tmt{static setupStorage(t,e,r,n,i){var a=n.getValue(e,{value:null});switch(r.name){case"textarea":if(null!==a.value&&(t.textContent=a.value),"print"===i)break;t.addEventListener("input",(t=>{n.setValue(e,{value:t.target.value})}));break;case"input":if("radio"===r.attributes.type||"checkbox"===r.attributes.type){if(a.value===r.attributes.xfaOn?t.setAttribute("checked",!0):a.value===r.attributes.xfaOff&&t.removeAttribute("checked"),"print"===i)break;t.addEventListener("change",(t=>{n.setValue(e,{value:t.target.checked?t.target.getAttribute("xfaOn"):t.target.getAttribute("xfaOff")})}))}else{if(null!==a.value&&t.setAttribute("value",a.value),"print"===i)break;t.addEventListener("input",(t=>{n.setValue(e,{value:t.target.value})}))}break;case"select":if(null!==a.value)for(var s of(t.setAttribute("value",a.value),r.children))s.attributes.value===a.value?s.attributes.selected=!0:s.attributes.hasOwnProperty("selected")&&delete s.attributes.selected;t.addEventListener("input",(t=>{var r=t.target.options,i=-1===r.selectedIndex?"":r[r.selectedIndex].value;n.setValue(e,{value:i})}))}}static setAttributes(t){var{html:e,element:r,storage:n=null,intent:i,linkService:a}=t,{attributes:s}=r,o=e instanceof HTMLAnchorElement;for(var[l,h]of("radio"===s.type&&(s.name="".concat(s.name,"-").concat(i)),Object.entries(s)))if(null!=h)switch(l){case"class":h.length&&e.setAttribute(l,h.join(" "));break;case"dataId":break;case"id":e.setAttribute("data-element-id",h);break;case"style":Object.assign(e.style,h);break;case"textContent":e.textContent=h;break;default:(!o||"href"!==l&&"newWindow"!==l)&&e.setAttribute(l,h)}o&&a.addLinkAttributes(e,s.href,s.newWindow),n&&s.dataId&&this.setupStorage(e,s.dataId,r,n)}static render(t){var e=t.annotationStorage,r=t.linkService,n=t.xfaHtml,i=t.intent||"display",a=document.createElement(n.name);n.attributes&&this.setAttributes({html:a,element:n,intent:i,linkService:r});var s="richText"!==i,o=t.div;if(o.append(a),t.viewport){var l="matrix(".concat(t.viewport.transform.join(","),")");o.style.transform=l}s&&o.setAttribute("class","xfaLayer xfaFont");var h=[];if(0===n.children.length){if(n.value){var c=document.createTextNode(n.value);a.append(c),s&&evt.shouldBuildText(n.name)&&h.push(c)}return{textDivs:h}}for(var u=[[n,-1,a]];u.length>0;){var d,p,[f,g,v]=u.at(-1);if(g+1!==f.children.length){var m=f.children[++u.at(-1)[1]];if(null!==m){var{name:y}=m;if("#text"!==y){var b=null!=m&&null!==(d=m.attributes)&&void 0!==d&&d.xmlns?document.createElementNS(m.attributes.xmlns,y):document.createElement(y);if(v.append(b),m.attributes&&this.setAttributes({html:b,element:m,storage:e,intent:i,linkService:r}),(null===(p=m.children)||void 0===p?void 0:p.length)>0)u.push([m,-1,b]);else if(m.value){var w=document.createTextNode(m.value);s&&evt.shouldBuildText(y)&&h.push(w),b.append(w)}}else{var x=document.createTextNode(m.value);h.push(x),v.append(x)}}}else u.pop()}for(var A of o.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))A.setAttribute("readOnly",!0);return{textDivs:h}}static update(t){var e="matrix(".concat(t.viewport.transform.join(","),")");t.div.style.transform=e,t.div.hidden=!1}}var emt=1e3,rmt=new WeakSet;function nmt(t){return{width:t[2]-t[0],height:t[3]-t[1]}}class imt{static create(t){switch(t.data.annotationType){case Jot:return new dmt(t);case Qot:return new vmt(t);case flt:switch(t.data.fieldType){case"Tx":return new ymt(t);case"Btn":return t.data.radioButton?new xmt(t):t.data.checkBox?new wmt(t):new Amt(t);case"Ch":return new _mt(t);case"Sig":return new bmt(t)}return new mmt(t);case dlt:return new kmt(t);case Zot:return new eyt(t);case tlt:return new nyt(t);case elt:return new ayt(t);case rlt:return new oyt(t);case ilt:return new hyt(t);case clt:return new uyt(t);case ult:return new gyt(t);case nlt:return new cyt(t);case alt:return new myt(t);case slt:return new yyt(t);case olt:return new byt(t);case llt:return new wyt(t);case hlt:return new xyt(t);case plt:return new kyt(t);default:return new hmt(t)}}}var amt=new WeakMap,smt=new WeakMap,omt=new WeakMap,lmt=new WeakSet;class hmt{constructor(t){var{isRenderable:e=!1,ignoreBorder:r=!1,createQuadrilaterals:n=!1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};dit(this,lmt),hit(this,amt,null),hit(this,smt,!1),hit(this,omt,null),this.isRenderable=e,this.data=t.data,this.layer=t.layer,this.linkService=t.linkService,this.downloadManager=t.downloadManager,this.imageResourcesPath=t.imageResourcesPath,this.renderForms=t.renderForms,this.svgFactory=t.svgFactory,this.annotationStorage=t.annotationStorage,this.enableScripting=t.enableScripting,this.hasJSActions=t.hasJSActions,this._fieldObjects=t.fieldObjects,this.parent=t.parent,e&&(this.container=this._createContainer(r)),n&&this._createQuadrilaterals()}static _hasPopupData(t){var{titleObj:e,contentsObj:r,richText:n}=t;return!!(null!=e&&e.str||null!=r&&r.str||null!=n&&n.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return hmt._hasPopupData(this.data)}updateEdited(t){var e;if(this.container){lit(amt,this)||cit(amt,this,{rect:this.data.rect.slice(0)});var{rect:r}=t;r&&iit(lmt,this,cmt).call(this,r),null===(e=lit(omt,this))||void 0===e||e.popup.updateEdited(t)}}resetEdited(){var t;lit(amt,this)&&(iit(lmt,this,cmt).call(this,lit(amt,this).rect),null===(t=lit(omt,this))||void 0===t||t.popup.resetEdited(),cit(amt,this,null))}_createContainer(t){var{data:e,parent:{page:r,viewport:n}}=this,i=document.createElement("section");i.setAttribute("data-annotation-id",e.id),this instanceof mmt||(i.tabIndex=emt);var{style:a}=i;if(a.zIndex=this.parent.zIndex++,e.alternativeText&&(i.title=e.alternativeText),e.noRotate&&i.classList.add("norotate"),!e.rect||this instanceof kmt){var{rotation:s}=e;return e.hasOwnCanvas||0===s||this.setRotation(s,i),i}var{width:o,height:l}=nmt(e.rect);if(!t&&e.borderStyle.width>0){a.borderWidth="".concat(e.borderStyle.width,"px");var h=e.borderStyle.horizontalCornerRadius,c=e.borderStyle.verticalCornerRadius;if(h>0||c>0){var u="calc(".concat(h,"px * var(--scale-factor)) / calc(").concat(c,"px * var(--scale-factor))");a.borderRadius=u}else if(this instanceof xmt){var d="calc(".concat(o,"px * var(--scale-factor)) / calc(").concat(l,"px * var(--scale-factor))");a.borderRadius=d}switch(e.borderStyle.style){case glt:a.borderStyle="solid";break;case vlt:a.borderStyle="dashed";break;case mlt:Mlt("Unimplemented border style: beveled");break;case ylt:Mlt("Unimplemented border style: inset");break;case blt:a.borderBottomStyle="solid"}var p=e.borderColor||null;p?(cit(smt,this,!0),a.borderColor=Ylt.makeHexColor(0|p[0],0|p[1],0|p[2])):a.borderWidth=0}var f=Ylt.normalizeRect([e.rect[0],r.view[3]-e.rect[1]+r.view[1],e.rect[2],r.view[3]-e.rect[3]+r.view[1]]),{pageWidth:g,pageHeight:v,pageX:m,pageY:y}=n.rawDims;a.left="".concat(100*(f[0]-m)/g,"%"),a.top="".concat(100*(f[1]-y)/v,"%");var{rotation:b}=e;return e.hasOwnCanvas||0===b?(a.width="".concat(100*o/g,"%"),a.height="".concat(100*l/v,"%")):this.setRotation(b,i),i}setRotation(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.container;if(this.data.rect){var r,n,{pageWidth:i,pageHeight:a}=this.parent.viewport.rawDims,{width:s,height:o}=nmt(this.data.rect);t%180==0?(r=100*s/i,n=100*o/a):(r=100*o/i,n=100*s/a),e.style.width="".concat(r,"%"),e.style.height="".concat(n,"%"),e.setAttribute("data-main-rotation",(360-t)%360)}}get _commonActions(){var t=(t,e,r)=>{var n=r.detail[t],i=n[0],a=n.slice(1);r.target.style[e]=Qvt["".concat(i,"_HTML")](a),this.annotationStorage.setValue(this.data.id,{[e]:Qvt["".concat(i,"_rgb")](a)})};return Ilt(this,"_commonActions",{display:t=>{var{display:e}=t.detail,r=e%2==1;this.container.style.visibility=r?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:r,noPrint:1===e||2===e})},print:t=>{this.annotationStorage.setValue(this.data.id,{noPrint:!t.detail.print})},hidden:t=>{var{hidden:e}=t.detail;this.container.style.visibility=e?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:e,noView:e})},focus:t=>{setTimeout((()=>t.target.focus({preventScroll:!1})),0)},userName:t=>{t.target.title=t.detail.userName},readonly:t=>{t.target.disabled=t.detail.readonly},required:t=>{this._setRequired(t.target,t.detail.required)},bgColor:e=>{t("bgColor","backgroundColor",e)},fillColor:e=>{t("fillColor","backgroundColor",e)},fgColor:e=>{t("fgColor","color",e)},textColor:e=>{t("textColor","color",e)},borderColor:e=>{t("borderColor","borderColor",e)},strokeColor:e=>{t("strokeColor","borderColor",e)},rotation:t=>{var e=t.detail.rotation;this.setRotation(e),this.annotationStorage.setValue(this.data.id,{rotation:e})}})}_dispatchEventFromSandbox(t,e){var r=this._commonActions;for(var n of Object.keys(e.detail)){var i=t[n]||r[n];null==i||i(e)}}_setDefaultPropertiesFromJS(t){if(this.enableScripting){var e=this.annotationStorage.getRawValue(this.data.id);if(e){var r=this._commonActions;for(var[n,i]of Object.entries(e)){var a=r[n];if(a)a({detail:{[n]:i},target:t}),delete e[n]}}}}_createQuadrilaterals(){if(this.container){var{quadPoints:t}=this.data;if(t){var[e,r,n,i]=this.data.rect.map((t=>Math.fround(t)));if(8===t.length){var[a,s,o,l]=t.subarray(2,6);if(n===a&&i===s&&e===o&&r===l)return}var h,{style:c}=this.container;if(lit(smt,this)){var{borderColor:u,borderWidth:d}=c;c.borderWidth=0,h=["url('data:image/svg+xml;utf8,",'<svg xmlns="http://www.w3.org/2000/svg"',' preserveAspectRatio="none" viewBox="0 0 1 1">','<g fill="transparent" stroke="'.concat(u,'" stroke-width="').concat(d,'">')],this.container.classList.add("hasBorder")}var p=n-e,f=i-r,{svgFactory:g}=this,v=g.createElement("svg");v.classList.add("quadrilateralsContainer"),v.setAttribute("width",0),v.setAttribute("height",0);var m=g.createElement("defs");v.append(m);var y=g.createElement("clipPath"),b="clippath_".concat(this.data.id);y.setAttribute("id",b),y.setAttribute("clipPathUnits","objectBoundingBox"),m.append(y);for(var w=2,x=t.length;w<x;w+=8){var A,_=t[w],k=t[w+1],S=t[w+2],E=t[w+3],M=g.createElement("rect"),T=(S-e)/p,C=(i-k)/f,P=(_-S)/p,I=(k-E)/f;M.setAttribute("x",T),M.setAttribute("y",C),M.setAttribute("width",P),M.setAttribute("height",I),y.append(M),null===(A=h)||void 0===A||A.push('<rect vector-effect="non-scaling-stroke" x="'.concat(T,'" y="').concat(C,'" width="').concat(P,'" height="').concat(I,'"/>'))}lit(smt,this)&&(h.push("</g></svg>')"),c.backgroundImage=h.join("")),this.container.append(v),this.container.style.clipPath="url(#".concat(b,")")}}}_createPopup(){var{data:t}=this,e=cit(omt,this,new kmt({data:{color:t.color,titleObj:t.titleObj,modificationDate:t.modificationDate,contentsObj:t.contentsObj,richText:t.richText,parentRect:t.rect,borderStyle:0,id:"popup_".concat(t.id),rotation:t.rotation},parent:this.parent,elements:[this]}));this.parent.div.append(e.render())}render(){Tlt("Abstract method `AnnotationElement.render` called")}_getElementsByName(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=[];if(this._fieldObjects){var n=this._fieldObjects[t];if(n)for(var{page:i,id:a,exportValues:s}of n)if(-1!==i&&a!==e){var o="string"==typeof s?s:null,l=document.querySelector('[data-element-id="'.concat(a,'"]'));!l||rmt.has(l)?r.push({id:a,exportValue:o,domElement:l}):Mlt("_getElementsByName - element not allowed: ".concat(a))}return r}for(var h of document.getElementsByName(t)){var{exportValue:c}=h,u=h.getAttribute("data-element-id");u!==e&&(rmt.has(h)&&r.push({id:u,exportValue:c,domElement:h}))}return r}show(){var t;this.container&&(this.container.hidden=!1),null===(t=this.popup)||void 0===t||t.maybeShow()}hide(){var t;this.container&&(this.container.hidden=!0),null===(t=this.popup)||void 0===t||t.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){var t=this.getElementsToTriggerPopup();if(Array.isArray(t))for(var e of t)e.classList.add("highlightArea");else t.classList.add("highlightArea")}_editOnDoubleClick(){if(this._isEditable){var{annotationEditorType:t,data:{id:e}}=this;this.container.addEventListener("dblclick",(()=>{var r;null===(r=this.linkService.eventBus)||void 0===r||r.dispatch("switchannotationeditormode",{source:this,mode:t,editId:e})}))}}}function cmt(t){var{container:{style:e},data:{rect:r,rotation:n},parent:{viewport:{rawDims:{pageWidth:i,pageHeight:a,pageX:s,pageY:o}}}}=this;null==r||r.splice(0,4,...t);var{width:l,height:h}=nmt(t);e.left="".concat(100*(t[0]-s)/i,"%"),e.top="".concat(100*(a-t[3]+o)/a,"%"),0===n?(e.width="".concat(100*l/i,"%"),e.height="".concat(100*h/a,"%")):this.setRotation(n)}var umt=new WeakSet;class dmt extends hmt{constructor(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;super(t,{isRenderable:!0,ignoreBorder:!(null==e||!e.ignoreBorder),createQuadrilaterals:!0}),dit(this,umt),this.isTooltipOnly=t.data.isTooltipOnly}render(){var{data:t,linkService:e}=this,r=document.createElement("a");r.setAttribute("data-element-id",t.id);var n=!1;return t.url?(e.addLinkAttributes(r,t.url,t.newWindow),n=!0):t.action?(this._bindNamedAction(r,t.action),n=!0):t.attachment?(iit(umt,this,fmt).call(this,r,t.attachment,t.attachmentDest),n=!0):t.setOCGState?(iit(umt,this,gmt).call(this,r,t.setOCGState),n=!0):t.dest?(this._bindLink(r,t.dest),n=!0):(t.actions&&(t.actions.Action||t.actions["Mouse Up"]||t.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(r,t),n=!0),t.resetForm?(this._bindResetFormAction(r,t.resetForm),n=!0):this.isTooltipOnly&&!n&&(this._bindLink(r,""),n=!0)),this.container.classList.add("linkAnnotation"),n&&this.container.append(r),this.container}_bindLink(t,e){t.href=this.linkService.getDestinationHash(e),t.onclick=()=>(e&&this.linkService.goToDestination(e),!1),(e||""===e)&&iit(umt,this,pmt).call(this)}_bindNamedAction(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeNamedAction(e),!1),iit(umt,this,pmt).call(this)}_bindJSAction(t,e){var r=this;t.href=this.linkService.getAnchorUrl("");var n=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]),i=function(i){var a=n.get(i);if(!a)return 1;t[a]=()=>{var t;return null===(t=r.linkService.eventBus)||void 0===t||t.dispatch("dispatcheventinsandbox",{source:r,detail:{id:e.id,name:i}}),!1}};for(var a of Object.keys(e.actions))i(a);t.onclick||(t.onclick=()=>!1),iit(umt,this,pmt).call(this)}_bindResetFormAction(t,e){var r=t.onclick;if(r||(t.href=this.linkService.getAnchorUrl("")),iit(umt,this,pmt).call(this),!this._fieldObjects)return Mlt('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),void(r||(t.onclick=()=>!1));t.onclick=()=>{null==r||r();var{fields:t,refs:n,include:i}=e,a=[];if(0!==t.length||0!==n.length){var s=new Set(n);for(var o of t){var l=this._fieldObjects[o]||[];for(var{id:h}of l)s.add(h)}for(var c of Object.values(this._fieldObjects))for(var u of c)s.has(u.id)===i&&a.push(u)}else for(var d of Object.values(this._fieldObjects))a.push(...d);var p,f=this.annotationStorage,g=[];for(var v of a){var{id:m}=v;switch(g.push(m),v.type){case"text":var y=v.defaultValue||"";f.setValue(m,{value:y});break;case"checkbox":case"radiobutton":var b=v.defaultValue===v.exportValues;f.setValue(m,{value:b});break;case"combobox":case"listbox":var w=v.defaultValue||"";f.setValue(m,{value:w});break;default:continue}var x=document.querySelector('[data-element-id="'.concat(m,'"]'));x&&(rmt.has(x)?x.dispatchEvent(new Event("resetform")):Mlt("_bindResetFormAction - element not allowed: ".concat(m)))}this.enableScripting&&(null===(p=this.linkService.eventBus)||void 0===p||p.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:g,name:"ResetForm"}}));return!1}}}function pmt(){this.container.setAttribute("data-internal-link","")}function fmt(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;t.href=this.linkService.getAnchorUrl(""),e.description&&(t.title=e.description),t.onclick=()=>{var t;return null===(t=this.downloadManager)||void 0===t||t.openOrDownloadData(e.content,e.filename,r),!1},iit(umt,this,pmt).call(this)}function gmt(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeSetOCGState(e),!1),iit(umt,this,pmt).call(this)}class vmt extends hmt{constructor(t){super(t,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");var t=document.createElement("img");return t.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",t.setAttribute("data-l10n-id","pdfjs-text-annotation-type"),t.setAttribute("data-l10n-args",JSON.stringify({type:this.data.name})),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.append(t),this.container}}class mmt extends hmt{render(){return this.container}showElementAndHideCanvas(t){var e;this.data.hasOwnCanvas&&("CANVAS"===(null===(e=t.previousSibling)||void 0===e?void 0:e.nodeName)&&(t.previousSibling.hidden=!0),t.hidden=!1)}_getKeyModifier(t){return Hlt.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,r,n,i){r.includes("mouse")?t.addEventListener(r,(t=>{var e;null===(e=this.linkService.eventBus)||void 0===e||e.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:n,value:i(t),shift:t.shiftKey,modifier:this._getKeyModifier(t)}})})):t.addEventListener(r,(t=>{var a;if("blur"===r){if(!e.focused||!t.relatedTarget)return;e.focused=!1}else if("focus"===r){if(e.focused)return;e.focused=!0}i&&(null===(a=this.linkService.eventBus)||void 0===a||a.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:n,value:i(t)}}))}))}_setEventListeners(t,e,r,n){for(var[i,a]of r){var s,o,l;if("Action"===a||null!==(s=this.data.actions)&&void 0!==s&&s[a])"Focus"!==a&&"Blur"!==a||e||(e={focused:!1}),this._setEventListener(t,e,i,a,n),"Focus"!==a||null!==(o=this.data.actions)&&void 0!==o&&o.Blur?"Blur"!==a||null!==(l=this.data.actions)&&void 0!==l&&l.Focus||this._setEventListener(t,e,"focus","Focus",null):this._setEventListener(t,e,"blur","Blur",null)}}_setBackgroundColor(t){var e=this.data.backgroundColor||null;t.style.backgroundColor=null===e?"transparent":Ylt.makeHexColor(e[0],e[1],e[2])}_setTextStyle(t){var e,{fontColor:r}=this.data.defaultAppearanceData,n=this.data.defaultAppearanceData.fontSize||9,i=t.style,a=t=>Math.round(10*t)/10;if(this.data.multiLine){var s=Math.abs(this.data.rect[3]-this.data.rect[1]-2),o=s/(Math.round(s/(Iot*n))||1);e=Math.min(n,a(o/Iot))}else{var l=Math.abs(this.data.rect[3]-this.data.rect[1]-2);e=Math.min(n,a(l/Iot))}i.fontSize="calc(".concat(e,"px * var(--scale-factor))"),i.color=Ylt.makeHexColor(r[0],r[1],r[2]),null!==this.data.textAlignment&&(i.textAlign=["left","center","right"][this.data.textAlignment])}_setRequired(t,e){e?t.setAttribute("required",!0):t.removeAttribute("required"),t.setAttribute("aria-required",e)}}class ymt extends mmt{constructor(t){super(t,{isRenderable:t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue})}setPropertyOnSiblings(t,e,r,n){var i=this.annotationStorage;for(var a of this._getElementsByName(t.name,t.id))a.domElement&&(a.domElement[e]=r),i.setValue(a.id,{[n]:r})}render(){var t=this.annotationStorage,e=this.data.id;this.container.classList.add("textWidgetAnnotation");var r=null;if(this.renderForms){var n,i=t.getValue(e,{value:this.data.fieldValue}),a=i.value||"",s=t.getValue(e,{charLimit:this.data.maxLen}).charLimit;s&&a.length>s&&(a=a.slice(0,s));var o=i.formattedValue||(null===(n=this.data.textContent)||void 0===n?void 0:n.join("\n"))||null;o&&this.data.comb&&(o=o.replaceAll(/\s+/g,""));var l={userValue:a,formattedValue:o,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?((r=document.createElement("textarea")).textContent=null!=o?o:a,this.data.doNotScroll&&(r.style.overflowY="hidden")):((r=document.createElement("input")).type="text",r.setAttribute("value",null!=o?o:a),this.data.doNotScroll&&(r.style.overflowX="hidden")),this.data.hasOwnCanvas&&(r.hidden=!0),rmt.add(r),r.setAttribute("data-element-id",e),r.disabled=this.data.readOnly,r.name=this.data.fieldName,r.tabIndex=emt,this._setRequired(r,this.data.required),s&&(r.maxLength=s),r.addEventListener("input",(n=>{t.setValue(e,{value:n.target.value}),this.setPropertyOnSiblings(r,"value",n.target.value,"value"),l.formattedValue=null})),r.addEventListener("resetform",(t=>{var e,n=null!==(e=this.data.defaultFieldValue)&&void 0!==e?e:"";r.value=l.userValue=n,l.formattedValue=null}));var h=t=>{var{formattedValue:e}=l;null!=e&&(t.target.value=e),t.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){var c;r.addEventListener("focus",(t=>{var e;if(!l.focused){var{target:r}=t;l.userValue&&(r.value=l.userValue),l.lastCommittedValue=r.value,l.commitKey=1,null!==(e=this.data.actions)&&void 0!==e&&e.Focus||(l.focused=!0)}})),r.addEventListener("updatefromsandbox",(r=>{this.showElementAndHideCanvas(r.target);var n={value(r){var n;l.userValue=null!==(n=r.detail.value)&&void 0!==n?n:"",t.setValue(e,{value:l.userValue.toString()}),r.target.value=l.userValue},formattedValue(r){var{formattedValue:n}=r.detail;l.formattedValue=n,null!=n&&r.target!==document.activeElement&&(r.target.value=n),t.setValue(e,{formattedValue:n})},selRange(t){t.target.setSelectionRange(...t.detail.selRange)},charLimit:r=>{var n,{charLimit:i}=r.detail,{target:a}=r;if(0!==i){a.setAttribute("maxLength",i);var s=l.userValue;!s||s.length<=i||(s=s.slice(0,i),a.value=l.userValue=s,t.setValue(e,{value:s}),null===(n=this.linkService.eventBus)||void 0===n||n.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:s,willCommit:!0,commitKey:1,selStart:a.selectionStart,selEnd:a.selectionEnd}}))}else a.removeAttribute("maxLength")}};this._dispatchEventFromSandbox(n,r)})),r.addEventListener("keydown",(t=>{var r;l.commitKey=1;var n=-1;if("Escape"===t.key?n=0:"Enter"!==t.key||this.data.multiLine?"Tab"===t.key&&(l.commitKey=3):n=2,-1!==n){var{value:i}=t.target;l.lastCommittedValue!==i&&(l.lastCommittedValue=i,l.userValue=i,null===(r=this.linkService.eventBus)||void 0===r||r.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:i,willCommit:!0,commitKey:n,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}}))}}));var u=h;h=null,r.addEventListener("blur",(t=>{var r;if(l.focused&&t.relatedTarget){null!==(r=this.data.actions)&&void 0!==r&&r.Blur||(l.focused=!1);var n,{value:i}=t.target;if(l.userValue=i,l.lastCommittedValue!==i)null===(n=this.linkService.eventBus)||void 0===n||n.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:i,willCommit:!0,commitKey:l.commitKey,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}});u(t)}})),null!==(c=this.data.actions)&&void 0!==c&&c.Keystroke&&r.addEventListener("beforeinput",(t=>{var r;l.lastCommittedValue=null;var{data:n,target:i}=t,{value:a,selectionStart:s,selectionEnd:o}=i,h=s,c=o;switch(t.inputType){case"deleteWordBackward":var u=a.substring(0,s).match(/\w*[^\w]*$/);u&&(h-=u[0].length);break;case"deleteWordForward":var d=a.substring(s).match(/^[^\w]*\w*/);d&&(c+=d[0].length);break;case"deleteContentBackward":s===o&&(h-=1);break;case"deleteContentForward":s===o&&(c+=1)}t.preventDefault(),null===(r=this.linkService.eventBus)||void 0===r||r.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:a,change:n||"",willCommit:!1,selStart:h,selEnd:c}})})),this._setEventListeners(r,l,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(t=>t.target.value))}if(h&&r.addEventListener("blur",h),this.data.comb){var d=(this.data.rect[2]-this.data.rect[0])/s;r.classList.add("comb"),r.style.letterSpacing="calc(".concat(d,"px * var(--scale-factor) - 1ch)")}}else(r=document.createElement("div")).textContent=this.data.fieldValue,r.style.verticalAlign="middle",r.style.display="table-cell",this.data.hasOwnCanvas&&(r.hidden=!0);return this._setTextStyle(r),this._setBackgroundColor(r),this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}}class bmt extends mmt{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class wmt extends mmt{constructor(t){super(t,{isRenderable:t.renderForms})}render(){var t=this.annotationStorage,e=this.data,r=e.id,n=t.getValue(r,{value:e.exportValue===e.fieldValue}).value;"string"==typeof n&&(n="Off"!==n,t.setValue(r,{value:n})),this.container.classList.add("buttonWidgetAnnotation","checkBox");var i=document.createElement("input");return rmt.add(i),i.setAttribute("data-element-id",r),i.disabled=e.readOnly,this._setRequired(i,this.data.required),i.type="checkbox",i.name=e.fieldName,n&&i.setAttribute("checked",!0),i.setAttribute("exportValue",e.exportValue),i.tabIndex=emt,i.addEventListener("change",(n=>{var{name:i,checked:a}=n.target;for(var s of this._getElementsByName(i,r)){var o=a&&s.exportValue===e.exportValue;s.domElement&&(s.domElement.checked=o),t.setValue(s.id,{value:o})}t.setValue(r,{value:a})})),i.addEventListener("resetform",(t=>{var r=e.defaultFieldValue||"Off";t.target.checked=r===e.exportValue})),this.enableScripting&&this.hasJSActions&&(i.addEventListener("updatefromsandbox",(e=>{var n={value(e){e.target.checked="Off"!==e.detail.value,t.setValue(r,{value:e.target.checked})}};this._dispatchEventFromSandbox(n,e)})),this._setEventListeners(i,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(t=>t.target.checked))),this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}class xmt extends mmt{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");var t=this.annotationStorage,e=this.data,r=e.id,n=t.getValue(r,{value:e.fieldValue===e.buttonValue}).value;if("string"==typeof n&&(n=n!==e.buttonValue,t.setValue(r,{value:n})),n)for(var i of this._getElementsByName(e.fieldName,r))t.setValue(i.id,{value:!1});var a=document.createElement("input");if(rmt.add(a),a.setAttribute("data-element-id",r),a.disabled=e.readOnly,this._setRequired(a,this.data.required),a.type="radio",a.name=e.fieldName,n&&a.setAttribute("checked",!0),a.tabIndex=emt,a.addEventListener("change",(e=>{var{name:n,checked:i}=e.target;for(var a of this._getElementsByName(n,r))t.setValue(a.id,{value:!1});t.setValue(r,{value:i})})),a.addEventListener("resetform",(t=>{var r=e.defaultFieldValue;t.target.checked=null!=r&&r===e.buttonValue})),this.enableScripting&&this.hasJSActions){var s=e.buttonValue;a.addEventListener("updatefromsandbox",(e=>{var n={value:e=>{var n=s===e.detail.value;for(var i of this._getElementsByName(e.target.name)){var a=n&&i.id===r;i.domElement&&(i.domElement.checked=a),t.setValue(i.id,{value:a})}}};this._dispatchEventFromSandbox(n,e)})),this._setEventListeners(a,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(t=>t.target.checked))}return this._setBackgroundColor(a),this._setDefaultPropertiesFromJS(a),this.container.append(a),this.container}}class Amt extends dmt{constructor(t){super(t,{ignoreBorder:t.data.hasAppearance})}render(){var t=super.render();t.classList.add("buttonWidgetAnnotation","pushButton");var e=t.lastChild;return this.enableScripting&&this.hasJSActions&&e&&(this._setDefaultPropertiesFromJS(e),e.addEventListener("updatefromsandbox",(t=>{this._dispatchEventFromSandbox({},t)}))),t}}class _mt extends mmt{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");var t=this.annotationStorage,e=this.data.id,r=t.getValue(e,{value:this.data.fieldValue}),n=document.createElement("select");rmt.add(n),n.setAttribute("data-element-id",e),n.disabled=this.data.readOnly,this._setRequired(n,this.data.required),n.name=this.data.fieldName,n.tabIndex=emt;var i=this.data.combo&&this.data.options.length>0;for(var a of(this.data.combo||(n.size=this.data.options.length,this.data.multiSelect&&(n.multiple=!0)),n.addEventListener("resetform",(t=>{var e=this.data.defaultFieldValue;for(var r of n.options)r.selected=r.value===e})),this.data.options)){var s=document.createElement("option");s.textContent=a.displayValue,s.value=a.exportValue,r.value.includes(a.exportValue)&&(s.setAttribute("selected",!0),i=!1),n.append(s)}var o=null;if(i){var l=document.createElement("option");l.value=" ",l.setAttribute("hidden",!0),l.setAttribute("selected",!0),n.prepend(l),o=()=>{l.remove(),n.removeEventListener("input",o),o=null},n.addEventListener("input",o)}var h=t=>{var e=t?"value":"textContent",{options:r,multiple:i}=n;return i?Array.prototype.filter.call(r,(t=>t.selected)).map((t=>t[e])):-1===r.selectedIndex?null:r[r.selectedIndex][e]},c=h(!1),u=t=>{var e=t.target.options;return Array.prototype.map.call(e,(t=>({displayValue:t.textContent,exportValue:t.value})))};return this.enableScripting&&this.hasJSActions?(n.addEventListener("updatefromsandbox",(r=>{var i={value(r){var i;null===(i=o)||void 0===i||i();var a=r.detail.value,s=new Set(Array.isArray(a)?a:[a]);for(var l of n.options)l.selected=s.has(l.value);t.setValue(e,{value:h(!0)}),c=h(!1)},multipleSelection(t){n.multiple=!0},remove(r){var i=n.options,a=r.detail.remove;if(i[a].selected=!1,n.remove(a),i.length>0){var s=Array.prototype.findIndex.call(i,(t=>t.selected));-1===s&&(i[0].selected=!0)}t.setValue(e,{value:h(!0),items:u(r)}),c=h(!1)},clear(r){for(;0!==n.length;)n.remove(0);t.setValue(e,{value:null,items:[]}),c=h(!1)},insert(r){var{index:i,displayValue:a,exportValue:s}=r.detail.insert,o=n.children[i],l=document.createElement("option");l.textContent=a,l.value=s,o?o.before(l):n.append(l),t.setValue(e,{value:h(!0),items:u(r)}),c=h(!1)},items(r){for(var{items:i}=r.detail;0!==n.length;)n.remove(0);for(var a of i){var{displayValue:s,exportValue:o}=a,l=document.createElement("option");l.textContent=s,l.value=o,n.append(l)}n.options.length>0&&(n.options[0].selected=!0),t.setValue(e,{value:h(!0),items:u(r)}),c=h(!1)},indices(r){var n=new Set(r.detail.indices);for(var i of r.target.options)i.selected=n.has(i.index);t.setValue(e,{value:h(!0)}),c=h(!1)},editable(t){t.target.disabled=!t.detail.editable}};this._dispatchEventFromSandbox(i,r)})),n.addEventListener("input",(r=>{var n,i=h(!0),a=h(!1);t.setValue(e,{value:i}),r.preventDefault(),null===(n=this.linkService.eventBus)||void 0===n||n.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:c,change:a,changeEx:i,willCommit:!1,commitKey:1,keyDown:!1}})})),this._setEventListeners(n,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],(t=>t.target.value))):n.addEventListener("input",(function(r){t.setValue(e,{value:h(!0)})})),this.data.combo&&this._setTextStyle(n),this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class kmt extends hmt{constructor(t){var{data:e,elements:r}=t;super(t,{isRenderable:hmt._hasPopupData(e)}),this.elements=r,this.popup=null}render(){this.container.classList.add("popupAnnotation");var t=this.popup=new Ymt({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate,contentsObj:this.data.contentsObj,richText:this.data.richText,rect:this.data.rect,parentRect:this.data.parentRect||null,parent:this.parent,elements:this.elements,open:this.data.open}),e=[];for(var r of this.elements)r.popup=t,r.container.ariaHasPopup="dialog",e.push(r.data.id),r.addHighlightArea();return this.container.setAttribute("aria-controls",e.map((t=>"".concat(Qlt).concat(t))).join(",")),this.container}}var Smt=new WeakMap,Emt=new WeakMap,Mmt=new WeakMap,Tmt=new WeakMap,Cmt=new WeakMap,Pmt=new WeakMap,Imt=new WeakMap,Rmt=new WeakMap,Omt=new WeakMap,Lmt=new WeakMap,Dmt=new WeakMap,Fmt=new WeakMap,Nmt=new WeakMap,jmt=new WeakMap,Bmt=new WeakMap,zmt=new WeakMap,Wmt=new WeakMap,Umt=new WeakMap,Hmt=new WeakMap,Gmt=new WeakSet;class Ymt{constructor(t){var{container:e,color:r,elements:n,titleObj:i,modificationDate:a,contentsObj:s,richText:o,parent:l,rect:h,parentRect:c,open:u}=t;for(var d of(dit(this,Gmt),hit(this,Smt,iit(Gmt,this,Kmt).bind(this)),hit(this,Emt,iit(Gmt,this,tyt).bind(this)),hit(this,Mmt,iit(Gmt,this,Zmt).bind(this)),hit(this,Tmt,iit(Gmt,this,Jmt).bind(this)),hit(this,Cmt,null),hit(this,Pmt,null),hit(this,Imt,null),hit(this,Rmt,null),hit(this,Omt,null),hit(this,Lmt,null),hit(this,Dmt,null),hit(this,Fmt,!1),hit(this,Nmt,null),hit(this,jmt,null),hit(this,Bmt,null),hit(this,zmt,null),hit(this,Wmt,null),hit(this,Umt,null),hit(this,Hmt,!1),cit(Pmt,this,e),cit(Wmt,this,i),cit(Imt,this,s),cit(zmt,this,o),cit(Lmt,this,l),cit(Cmt,this,r),cit(Bmt,this,h),cit(Dmt,this,c),cit(Omt,this,n),cit(Rmt,this,dht.toDateObject(a)),this.trigger=n.flatMap((t=>t.getElementsToTriggerPopup())),this.trigger))d.addEventListener("click",lit(Tmt,this)),d.addEventListener("mouseenter",lit(Mmt,this)),d.addEventListener("mouseleave",lit(Emt,this)),d.classList.add("popupTriggerArea");for(var p of n){var f;null===(f=p.container)||void 0===f||f.addEventListener("keydown",lit(Smt,this))}lit(Pmt,this).hidden=!0,u&&iit(Gmt,this,Jmt).call(this)}render(){if(!lit(Nmt,this)){var t=cit(Nmt,this,document.createElement("div"));if(t.className="popup",lit(Cmt,this)){var e=t.style.outlineColor=Ylt.makeHexColor(...lit(Cmt,this));if(CSS.supports("background-color","color-mix(in srgb, red 30%, white)"))t.style.backgroundColor="color-mix(in srgb, ".concat(e," 30%, white)");else{t.style.backgroundColor=Ylt.makeHexColor(...lit(Cmt,this).map((t=>Math.floor(.7*(255-t)+t))))}}var r=document.createElement("span");r.className="header";var n=document.createElement("h1");if(r.append(n),({dir:n.dir,str:n.textContent}=lit(Wmt,this)),t.append(r),lit(Rmt,this)){var i=document.createElement("span");i.classList.add("popupDate"),i.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),i.setAttribute("data-l10n-args",JSON.stringify({dateObj:lit(Rmt,this).valueOf()})),r.append(i)}var a=uit(Gmt,this,Vmt);if(a)tmt.render({xfaHtml:a,intent:"richText",div:t}),t.lastChild.classList.add("richText","popupContent");else{var s=this._formatContents(lit(Imt,this));t.append(s)}lit(Pmt,this).append(t)}}_formatContents(t){var{str:e,dir:r}=t,n=document.createElement("p");n.classList.add("popupContent"),n.dir=r;for(var i=e.split(/(?:\r\n?|\n)/),a=0,s=i.length;a<s;++a){var o=i[a];n.append(document.createTextNode(o)),a<s-1&&n.append(document.createElement("br"))}return n}updateEdited(t){var e,{rect:r,popupContent:n}=t;lit(Umt,this)||cit(Umt,this,{contentsObj:lit(Imt,this),richText:lit(zmt,this)}),r&&cit(jmt,this,null),n&&(cit(zmt,this,iit(Gmt,this,$mt).call(this,n)),cit(Imt,this,null)),null===(e=lit(Nmt,this))||void 0===e||e.remove(),cit(Nmt,this,null)}resetEdited(){var t;lit(Umt,this)&&(({contentsObj:vit(cit,[Imt,this])._,richText:vit(cit,[zmt,this])._}=lit(Umt,this)),cit(Umt,this,null),null===(t=lit(Nmt,this))||void 0===t||t.remove(),cit(Nmt,this,null),cit(jmt,this,null))}forceHide(){cit(Hmt,this,this.isVisible),lit(Hmt,this)&&(lit(Pmt,this).hidden=!0)}maybeShow(){lit(Hmt,this)&&(lit(Nmt,this)||iit(Gmt,this,Zmt).call(this),cit(Hmt,this,!1),lit(Pmt,this).hidden=!1)}get isVisible(){return!1===lit(Pmt,this).hidden}}function Vmt(t){var e=lit(zmt,t),r=lit(Imt,t);return null==e||!e.str||null!=r&&r.str&&r.str!==e.str?null:lit(zmt,t).html||null}function qmt(t){var e;return(null===(e=uit(Gmt,t,Vmt))||void 0===e||null===(e=e.attributes)||void 0===e||null===(e=e.style)||void 0===e?void 0:e.fontSize)||0}function Xmt(t){var e;return(null===(e=uit(Gmt,t,Vmt))||void 0===e||null===(e=e.attributes)||void 0===e||null===(e=e.style)||void 0===e?void 0:e.color)||null}function $mt(t){var e=[],r={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}},n={style:{color:uit(Gmt,this,Xmt),fontSize:uit(Gmt,this,qmt)?"calc(".concat(uit(Gmt,this,qmt),"px * var(--scale-factor))"):""}};for(var i of t.split("\n"))e.push({name:"span",value:i,attributes:n});return r}function Kmt(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||("Enter"===t.key||"Escape"===t.key&&lit(Fmt,this))&&iit(Gmt,this,Jmt).call(this)}function Qmt(){if(null===lit(jmt,this)){var{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:r,pageX:n,pageY:i}}}=lit(Lmt,this),a=!!lit(Dmt,this),s=lit(a?Dmt:Bmt,this);for(var o of lit(Omt,this))if(!s||null!==Ylt.intersect(o.data.rect,s)){s=o.data.rect,a=!0;break}var l=Ylt.normalizeRect([s[0],t[3]-s[1]+t[1],s[2],t[3]-s[3]+t[1]]),h=a?s[2]-s[0]+5:0,c=l[0]+h,u=l[1];cit(jmt,this,[100*(c-n)/e,100*(u-i)/r]);var{style:d}=lit(Pmt,this);d.left="".concat(lit(jmt,this)[0],"%"),d.top="".concat(lit(jmt,this)[1],"%")}}function Jmt(){cit(Fmt,this,!lit(Fmt,this)),lit(Fmt,this)?(iit(Gmt,this,Zmt).call(this),lit(Pmt,this).addEventListener("click",lit(Tmt,this)),lit(Pmt,this).addEventListener("keydown",lit(Smt,this))):(iit(Gmt,this,tyt).call(this),lit(Pmt,this).removeEventListener("click",lit(Tmt,this)),lit(Pmt,this).removeEventListener("keydown",lit(Smt,this)))}function Zmt(){lit(Nmt,this)||this.render(),this.isVisible?lit(Fmt,this)&&lit(Pmt,this).classList.add("focused"):(iit(Gmt,this,Qmt).call(this),lit(Pmt,this).hidden=!1,lit(Pmt,this).style.zIndex=parseInt(lit(Pmt,this).style.zIndex)+1e3)}function tyt(){lit(Pmt,this).classList.remove("focused"),!lit(Fmt,this)&&this.isVisible&&(lit(Pmt,this).hidden=!0,lit(Pmt,this).style.zIndex=parseInt(lit(Pmt,this).style.zIndex)-1e3)}class eyt extends hmt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=Wot.FREETEXT}render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){var t=document.createElement("div");for(var e of(t.classList.add("annotationTextContent"),t.setAttribute("role","comment"),this.textContent)){var r=document.createElement("span");r.textContent=e,t.append(r)}this.container.append(t)}return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}var ryt=new WeakMap;class nyt extends hmt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),hit(this,ryt,null)}render(){this.container.classList.add("lineAnnotation");var t=this.data,{width:e,height:r}=nmt(t.rect),n=this.svgFactory.create(e,r,!0),i=cit(ryt,this,this.svgFactory.createElement("svg:line"));return i.setAttribute("x1",t.rect[2]-t.lineCoordinates[0]),i.setAttribute("y1",t.rect[3]-t.lineCoordinates[1]),i.setAttribute("x2",t.rect[2]-t.lineCoordinates[2]),i.setAttribute("y2",t.rect[3]-t.lineCoordinates[3]),i.setAttribute("stroke-width",t.borderStyle.width||1),i.setAttribute("stroke","transparent"),i.setAttribute("fill","transparent"),n.append(i),this.container.append(n),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return lit(ryt,this)}addHighlightArea(){this.container.classList.add("highlightArea")}}var iyt=new WeakMap;class ayt extends hmt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),hit(this,iyt,null)}render(){this.container.classList.add("squareAnnotation");var t=this.data,{width:e,height:r}=nmt(t.rect),n=this.svgFactory.create(e,r,!0),i=t.borderStyle.width,a=cit(iyt,this,this.svgFactory.createElement("svg:rect"));return a.setAttribute("x",i/2),a.setAttribute("y",i/2),a.setAttribute("width",e-i),a.setAttribute("height",r-i),a.setAttribute("stroke-width",i||1),a.setAttribute("stroke","transparent"),a.setAttribute("fill","transparent"),n.append(a),this.container.append(n),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return lit(iyt,this)}addHighlightArea(){this.container.classList.add("highlightArea")}}var syt=new WeakMap;class oyt extends hmt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),hit(this,syt,null)}render(){this.container.classList.add("circleAnnotation");var t=this.data,{width:e,height:r}=nmt(t.rect),n=this.svgFactory.create(e,r,!0),i=t.borderStyle.width,a=cit(syt,this,this.svgFactory.createElement("svg:ellipse"));return a.setAttribute("cx",e/2),a.setAttribute("cy",r/2),a.setAttribute("rx",e/2-i/2),a.setAttribute("ry",r/2-i/2),a.setAttribute("stroke-width",i||1),a.setAttribute("stroke","transparent"),a.setAttribute("fill","transparent"),n.append(a),this.container.append(n),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return lit(syt,this)}addHighlightArea(){this.container.classList.add("highlightArea")}}var lyt=new WeakMap;class hyt extends hmt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),hit(this,lyt,null),this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);var{data:{rect:t,vertices:e,borderStyle:r,popupRef:n}}=this;if(!e)return this.container;for(var{width:i,height:a}=nmt(t),s=this.svgFactory.create(i,a,!0),o=[],l=0,h=e.length;l<h;l+=2){var c=e[l]-t[0],u=t[3]-e[l+1];o.push("".concat(c,",").concat(u))}o=o.join(" ");var d=cit(lyt,this,this.svgFactory.createElement(this.svgElementName));return d.setAttribute("points",o),d.setAttribute("stroke-width",r.width||1),d.setAttribute("stroke","transparent"),d.setAttribute("fill","transparent"),s.append(d),this.container.append(s),!n&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return lit(lyt,this)}addHighlightArea(){this.container.classList.add("highlightArea")}}class cyt extends hyt{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class uyt extends hmt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container}}var dyt=new WeakMap,pyt=new WeakMap,fyt=new WeakSet;class gyt extends hmt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),dit(this,fyt),hit(this,dyt,null),hit(this,pyt,[]),this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType="InkHighlight"===this.data.it?Wot.HIGHLIGHT:Wot.INK}render(){this.container.classList.add(this.containerClassName);var{data:{rect:t,rotation:e,inkLists:r,borderStyle:n,popupRef:i}}=this,{transform:a,width:s,height:o}=iit(fyt,this,vyt).call(this,e,t),l=this.svgFactory.create(s,o,!0),h=cit(dyt,this,this.svgFactory.createElement("svg:g"));l.append(h),h.setAttribute("stroke-width",n.width||1),h.setAttribute("stroke-linecap","round"),h.setAttribute("stroke-linejoin","round"),h.setAttribute("stroke-miterlimit",10),h.setAttribute("stroke","transparent"),h.setAttribute("fill","transparent"),h.setAttribute("transform",a);for(var c=0,u=r.length;c<u;c++){var d=this.svgFactory.createElement(this.svgElementName);lit(pyt,this).push(d),d.setAttribute("points",r[c].join(",")),h.append(d)}return!i&&this.hasPopupData&&this._createPopup(),this.container.append(l),this._editOnDoubleClick(),this.container}updateEdited(t){super.updateEdited(t);var{thickness:e,points:r,rect:n}=t,i=lit(dyt,this);if(e>=0&&i.setAttribute("stroke-width",e||1),r)for(var a=0,s=lit(pyt,this).length;a<s;a++)lit(pyt,this)[a].setAttribute("points",r[a].join(","));if(n){var{transform:o,width:l,height:h}=iit(fyt,this,vyt).call(this,this.data.rotation,n);i.parentElement.setAttribute("viewBox","0 0 ".concat(l," ").concat(h)),i.setAttribute("transform",o)}}getElementsToTriggerPopup(){return lit(pyt,this)}addHighlightArea(){this.container.classList.add("highlightArea")}}function vyt(t,e){switch(t){case 90:return{transform:"rotate(90) translate(".concat(-e[0],",").concat(e[1],") scale(1,-1)"),width:e[3]-e[1],height:e[2]-e[0]};case 180:return{transform:"rotate(180) translate(".concat(-e[2],",").concat(e[1],") scale(1,-1)"),width:e[2]-e[0],height:e[3]-e[1]};case 270:return{transform:"rotate(270) translate(".concat(-e[2],",").concat(e[3],") scale(1,-1)"),width:e[3]-e[1],height:e[2]-e[0]};default:return{transform:"translate(".concat(-e[0],",").concat(e[3],") scale(1,-1)"),width:e[2]-e[0],height:e[3]-e[1]}}}class myt extends hmt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=Wot.HIGHLIGHT}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),this.container}}class yyt extends hmt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("underlineAnnotation"),this.container}}class byt extends hmt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("squigglyAnnotation"),this.container}}class wyt extends hmt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("strikeoutAnnotation"),this.container}}class xyt extends hmt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=Wot.STAMP}render(){return this.container.classList.add("stampAnnotation"),this.container.setAttribute("role","img"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}var Ayt=new WeakMap,_yt=new WeakSet;class kyt extends hmt{constructor(t){var e;super(t,{isRenderable:!0}),dit(this,_yt),hit(this,Ayt,null);var{file:r}=this.data;this.filename=r.filename,this.content=r.content,null===(e=this.linkService.eventBus)||void 0===e||e.dispatch("fileattachmentannotation",git({source:this},r))}render(){this.container.classList.add("fileAttachmentAnnotation");var t,{container:e,data:r}=this;r.hasAppearance||0===r.fillAlpha?t=document.createElement("div"):((t=document.createElement("img")).src="".concat(this.imageResourcesPath,"annotation-").concat(/paperclip/i.test(r.name)?"paperclip":"pushpin",".svg"),r.fillAlpha&&r.fillAlpha<1&&(t.style="filter: opacity(".concat(Math.round(100*r.fillAlpha),"%);"))),t.addEventListener("dblclick",iit(_yt,this,Syt).bind(this)),cit(Ayt,this,t);var{isMac:n}=Hlt.platform;return e.addEventListener("keydown",(t=>{"Enter"===t.key&&(n?t.metaKey:t.ctrlKey)&&iit(_yt,this,Syt).call(this)})),!r.popupRef&&this.hasPopupData?this._createPopup():t.classList.add("popupTriggerArea"),e.append(t),e}getElementsToTriggerPopup(){return lit(Ayt,this)}addHighlightArea(){this.container.classList.add("highlightArea")}}function Syt(){var t;null===(t=this.downloadManager)||void 0===t||t.openOrDownloadData(this.content,this.filename)}var Eyt=new WeakMap,Myt=new WeakMap,Tyt=new WeakMap,Cyt=new WeakMap,Pyt=new WeakSet;class Iyt{constructor(t){var{div:e,accessibilityManager:r,annotationCanvasMap:n,annotationEditorUIManager:i,page:a,viewport:s,structTreeLayer:o}=t;dit(this,Pyt),hit(this,Eyt,null),hit(this,Myt,null),hit(this,Tyt,new Map),hit(this,Cyt,null),this.div=e,cit(Eyt,this,r),cit(Myt,this,n),cit(Cyt,this,o||null),this.page=a,this.viewport=s,this.zIndex=0,this._annotationEditorUIManager=i}hasEditableAnnotations(){return lit(Tyt,this).size>0}render(t){var e=this;return sit((function*(){var{annotations:r}=t,n=e.div;yht(n,e.viewport);var i=new Map,a={data:null,layer:n,linkService:t.linkService,downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:!1!==t.renderForms,svgFactory:new Zvt,annotationStorage:t.annotationStorage||new tpt,enableScripting:!0===t.enableScripting,hasJSActions:t.hasJSActions,fieldObjects:t.fieldObjects,parent:e,elements:null};for(var s of r)if(!s.noHTML){var o=s.annotationType===dlt;if(o){var l=i.get(s.id);if(!l)continue;a.elements=l}else{var{width:h,height:c}=nmt(s.rect);if(h<=0||c<=0)continue}a.data=s;var u=imt.create(a);if(u.isRenderable){if(!o&&s.popupRef){var d=i.get(s.popupRef);d?d.push(u):i.set(s.popupRef,[u])}var p,f=u.render();if(s.hidden&&(f.style.visibility="hidden"),yield iit(Pyt,e,Ryt).call(e,f,s.id),u._isEditable)lit(Tyt,e).set(u.data.id,u),null===(p=e._annotationEditorUIManager)||void 0===p||p.renderAnnotationElement(u)}}iit(Pyt,e,Lyt).call(e)}))()}update(t){var{viewport:e}=t,r=this.div;this.viewport=e,yht(r,{rotation:e.rotation}),iit(Pyt,this,Lyt).call(this),r.hidden=!1}getEditableAnnotations(){return Array.from(lit(Tyt,this).values())}getEditableAnnotation(t){return lit(Tyt,this).get(t)}}function Ryt(t,e){return Oyt.apply(this,arguments)}function Oyt(){return Oyt=sit((function*(t,e){var r,n,i=t.firstChild||t,a=i.id="".concat(Qlt).concat(e),s=yield null===(r=lit(Cyt,this))||void 0===r?void 0:r.getAriaAttributes(a);if(s)for(var[o,l]of s)i.setAttribute(o,l);this.div.append(t),null===(n=lit(Eyt,this))||void 0===n||n.moveElementInDOM(this.div,t,i,!1)})),Oyt.apply(this,arguments)}function Lyt(){if(lit(Myt,this)){var t=this.div;for(var[e,r]of lit(Myt,this)){var n=t.querySelector('[data-annotation-id="'.concat(e,'"]'));if(n){r.className="annotationContent";var{firstChild:i}=n;i?"CANVAS"===i.nodeName?i.replaceWith(r):i.classList.contains("annotationContent")?i.after(r):i.before(r):n.append(r)}}lit(Myt,this).clear()}}var Dyt=/\r\n?|\n/g,Fyt=new WeakMap,Nyt=new WeakMap,jyt=new WeakMap,Byt=new WeakMap,zyt=new WeakMap,Wyt=new WeakSet;class Uyt extends kdt{static get _keyboardManager(){var t=Uyt.prototype,e=t=>t.isEmpty(),r=Kct.TRANSLATE_SMALL,n=Kct.TRANSLATE_BIG;return Ilt(this,"_keyboardManager",new ict([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],t.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter","Escape","mac+Escape"],t.commitOrRemove],[["ArrowLeft","mac+ArrowLeft"],t._translateEmpty,{args:[-r,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t._translateEmpty,{args:[-n,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t._translateEmpty,{args:[r,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t._translateEmpty,{args:[n,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t._translateEmpty,{args:[0,-r],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t._translateEmpty,{args:[0,-n],checker:e}],[["ArrowDown","mac+ArrowDown"],t._translateEmpty,{args:[0,r],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t._translateEmpty,{args:[0,n],checker:e}]]))}constructor(t){super(git(git({},t),{},{name:"freeTextEditor"})),dit(this,Wyt),hit(this,Fyt,void 0),hit(this,Nyt,""),hit(this,jyt,"".concat(this.id,"-editor")),hit(this,Byt,null),hit(this,zyt,void 0),cit(Fyt,this,t.color||Uyt._defaultColor||kdt._defaultLineColor),cit(zyt,this,t.fontSize||Uyt._defaultFontSize)}static initialize(t,e){kdt.initialize(t,e);var r=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(r.getPropertyValue("--freetext-padding"))}static updateDefaultParams(t,e){switch(t){case Uot.FREETEXT_SIZE:Uyt._defaultFontSize=e;break;case Uot.FREETEXT_COLOR:Uyt._defaultColor=e}}updateParams(t,e){switch(t){case Uot.FREETEXT_SIZE:iit(Wyt,this,Hyt).call(this,e);break;case Uot.FREETEXT_COLOR:iit(Wyt,this,Gyt).call(this,e)}}static get defaultPropertiesToUpdate(){return[[Uot.FREETEXT_SIZE,Uyt._defaultFontSize],[Uot.FREETEXT_COLOR,Uyt._defaultColor||kdt._defaultLineColor]]}get propertiesToUpdate(){return[[Uot.FREETEXT_SIZE,lit(zyt,this)],[Uot.FREETEXT_COLOR,lit(Fyt,this)]]}_translateEmpty(t,e){this._uiManager.translateSelectedEditors(t,e,!0)}getInitialTranslation(){var t=this.parentScale;return[-Uyt._internalPadding*t,-(Uyt._internalPadding+lit(zyt,this))*t]}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(!this.isInEditMode()){this.parent.setEditingState(!1),this.parent.updateToolbar(Wot.FREETEXT),super.enableEditMode(),this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),cit(Byt,this,new AbortController);var t=this._uiManager.combinedSignal(lit(Byt,this));this.editorDiv.addEventListener("keydown",this.editorDivKeydown.bind(this),{signal:t}),this.editorDiv.addEventListener("focus",this.editorDivFocus.bind(this),{signal:t}),this.editorDiv.addEventListener("blur",this.editorDivBlur.bind(this),{signal:t}),this.editorDiv.addEventListener("input",this.editorDivInput.bind(this),{signal:t}),this.editorDiv.addEventListener("paste",this.editorDivPaste.bind(this),{signal:t})}}disableEditMode(){var t;this.isInEditMode()&&(this.parent.setEditingState(!0),super.disableEditMode(),this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",lit(jyt,this)),this._isDraggable=!0,null===(t=lit(Byt,this))||void 0===t||t.abort(),cit(Byt,this,null),this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"))}focusin(t){this._focusEventsAllowed&&(super.focusin(t),t.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(t){var e;this.width||(this.enableEditMode(),t&&this.editorDiv.focus(),null!==(e=this._initialOptions)&&void 0!==e&&e.isCentered&&this.center(),this._initialOptions=null)}isEmpty(){return!this.editorDiv||""===this.editorDiv.innerText.trim()}remove(){this.isEditing=!1,this.parent&&(this.parent.setEditingState(!0),this.parent.div.classList.add("freetextEditing")),super.remove()}commit(){if(this.isInEditMode()){super.commit(),this.disableEditMode();var t=lit(Nyt,this),e=cit(Nyt,this,iit(Wyt,this,Yyt).call(this).trimEnd());if(t!==e){var r=t=>{cit(Nyt,this,t),t?(iit(Wyt,this,Xyt).call(this),this._uiManager.rebuild(this),iit(Wyt,this,Vyt).call(this)):this.remove()};this.addCommands({cmd:()=>{r(e)},undo:()=>{r(t)},mustExec:!1}),iit(Wyt,this,Vyt).call(this)}}}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}dblclick(t){this.enterInEditMode()}keydown(t){t.target===this.div&&"Enter"===t.key&&(this.enterInEditMode(),t.preventDefault())}editorDivKeydown(t){Uyt._keyboardManager.exec(this,t)}editorDivFocus(t){this.isEditing=!0}editorDivBlur(t){this.isEditing=!1}editorDivInput(t){this.parent.div.classList.toggle("freetextEditing",this.isEmpty())}disableEditing(){this.editorDiv.setAttribute("role","comment"),this.editorDiv.removeAttribute("aria-multiline")}enableEditing(){this.editorDiv.setAttribute("role","textbox"),this.editorDiv.setAttribute("aria-multiline",!0)}render(){if(this.div)return this.div;var t,e;this.width&&(t=this.x,e=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",lit(jyt,this)),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text2"),this.editorDiv.setAttribute("data-l10n-attrs","default-content"),this.enableEditing(),this.editorDiv.contentEditable=!0;var{style:r}=this.editorDiv;if(r.fontSize="calc(".concat(lit(zyt,this),"px * var(--scale-factor))"),r.color=lit(Fyt,this),this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),Uht(this,this.div,["dblclick","keydown"]),this.width){var[n,i]=this.parentDimensions;if(this.annotationElementId){var{position:a}=this._initialData,[s,o]=this.getInitialTranslation();[s,o]=this.pageTranslationToScreen(s,o);var l,h,[c,u]=this.pageDimensions,[d,p]=this.pageTranslation;switch(this.rotation){case 0:l=t+(a[0]-d)/c,h=e+this.height-(a[1]-p)/u;break;case 90:l=t+(a[0]-d)/c,h=e-(a[1]-p)/u,[s,o]=[o,-s];break;case 180:l=t-this.width+(a[0]-d)/c,h=e-(a[1]-p)/u,[s,o]=[-s,-o];break;case 270:l=t+(a[0]-d-this.height*u)/c,h=e+(a[1]-p-this.width*c)/u,[s,o]=[-o,s]}this.setAt(l*n,h*i,s,o)}else this.setAt(t*n,e*i,this.width*n,this.height*i);iit(Wyt,this,Xyt).call(this),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}editorDivPaste(t){var e=t.clipboardData||window.clipboardData,{types:r}=e;if(1!==r.length||"text/plain"!==r[0]){t.preventDefault();var n=Kyt.call(Uyt,e.getData("text")||"").replaceAll(Dyt,"\n");if(n){var i=window.getSelection();if(i.rangeCount){this.editorDiv.normalize(),i.deleteFromDocument();var a=i.getRangeAt(0);if(!n.includes("\n"))return a.insertNode(document.createTextNode(n)),this.editorDiv.normalize(),void i.collapseToStart();var{startContainer:s,startOffset:o}=a,l=[],h=[];if(s.nodeType===Node.TEXT_NODE){var c=s.parentElement;if(h.push(s.nodeValue.slice(o).replaceAll(Dyt,"")),c!==this.editorDiv){var u=l;for(var d of this.editorDiv.childNodes)d!==c?u.push(qyt.call(Uyt,d)):u=h}l.push(s.nodeValue.slice(0,o).replaceAll(Dyt,""))}else if(s===this.editorDiv){var p=l,f=0;for(var g of this.editorDiv.childNodes)f++===o&&(p=h),p.push(qyt.call(Uyt,g))}cit(Nyt,this,"".concat(l.join("\n")).concat(n).concat(h.join("\n"))),iit(Wyt,this,Xyt).call(this);var v=new Range,m=l.reduce(((t,e)=>t+e.length),0);for(var{firstChild:y}of this.editorDiv.childNodes)if(y.nodeType===Node.TEXT_NODE){var b=y.nodeValue.length;if(m<=b){v.setStart(y,m),v.setEnd(y,m);break}m-=b}i.removeAllRanges(),i.addRange(v)}}}}get contentDiv(){return this.editorDiv}static deserialize(t,e,r){var n=()=>super.deserialize,i=this;return sit((function*(){var a=null;if(t instanceof eyt){var{data:{defaultAppearanceData:{fontSize:s,fontColor:o},rect:l,rotation:h,id:c,popupRef:u},textContent:d,textPosition:p,parent:{page:{pageNumber:f}}}=t;if(!d||0===d.length)return null;a=t={annotationType:Wot.FREETEXT,color:Array.from(o),fontSize:s,value:d.join("\n"),position:p,pageIndex:f-1,rect:l.slice(0),rotation:h,id:c,deleted:!1,popupRef:u}}var g=yield n().call(i,t,e,r);return cit(zyt,g,t.fontSize),cit(Fyt,g,Ylt.makeHexColor(...t.color)),cit(Nyt,g,Kyt.call(Uyt,t.value)),g.annotationElementId=t.id||null,g._initialData=a,g}))()}serialize(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();var e=Uyt._internalPadding*this.parentScale,r=this.getRect(e,e),n=kdt._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:lit(Fyt,this)),i={annotationType:Wot.FREETEXT,color:n,fontSize:lit(zyt,this),value:iit(Wyt,this,$yt).call(this),pageIndex:this.pageIndex,rect:r,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return t?i:this.annotationElementId&&!iit(Wyt,this,Qyt).call(this,i)?null:(i.id=this.annotationElementId,i)}renderAnnotationElement(t){var e=super.renderAnnotationElement(t);if(this.deleted)return e;var{style:r}=e;for(var n of(r.fontSize="calc(".concat(lit(zyt,this),"px * var(--scale-factor))"),r.color=lit(Fyt,this),e.replaceChildren(),lit(Nyt,this).split("\n"))){var i=document.createElement("div");i.append(n?document.createTextNode(n):document.createElement("br")),e.append(i)}var a=Uyt._internalPadding*this.parentScale;return t.updateEdited({rect:this.getRect(a,a),popupContent:lit(Nyt,this)}),e}resetAnnotationElement(t){super.resetAnnotationElement(t),t.resetEdited()}}function Hyt(t){var e=t=>{this.editorDiv.style.fontSize="calc(".concat(t,"px * var(--scale-factor))"),this.translate(0,-(t-lit(zyt,this))*this.parentScale),cit(zyt,this,t),iit(Wyt,this,Vyt).call(this)},r=lit(zyt,this);this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,r),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Uot.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})}function Gyt(t){var e=t=>{cit(Fyt,this,this.editorDiv.style.color=t)},r=lit(Fyt,this);this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,r),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Uot.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})}function Yyt(){var t=[];this.editorDiv.normalize();var e=null;for(var r of this.editorDiv.childNodes){var n;(null===(n=e)||void 0===n?void 0:n.nodeType)===Node.TEXT_NODE&&"BR"===r.nodeName||(t.push(qyt.call(yot,r)),e=r)}return t.join("\n")}function Vyt(){var t,[e,r]=this.parentDimensions;if(this.isAttachedToDOM)t=this.div.getBoundingClientRect();else{var{currentLayer:n,div:i}=this,a=i.style.display,s=i.classList.contains("hidden");i.classList.remove("hidden"),i.style.display="hidden",n.div.append(this.div),t=i.getBoundingClientRect(),i.remove(),i.style.display=a,i.classList.toggle("hidden",s)}this.rotation%180==this.parentRotation%180?(this.width=t.width/e,this.height=t.height/r):(this.width=t.height/e,this.height=t.width/r),this.fixAndSetPosition()}function qyt(t){return(t.nodeType===Node.TEXT_NODE?t.nodeValue:t.innerText).replaceAll(Dyt,"")}function Xyt(){if(this.editorDiv.replaceChildren(),lit(Nyt,this))for(var t of lit(Nyt,this).split("\n")){var e=document.createElement("div");e.append(t?document.createTextNode(t):document.createElement("br")),this.editorDiv.append(e)}}function $yt(){return lit(Nyt,this).replaceAll(" "," ")}function Kyt(t){return t.replaceAll(" "," ")}function Qyt(t){var{value:e,fontSize:r,color:n,pageIndex:i}=this._initialData;return this._hasBeenMoved||t.value!==e||t.fontSize!==r||t.color.some(((t,e)=>t!==n[e]))||t.pageIndex!==i}yot=Uyt,pit(Uyt,"_freeTextDefaultContent",""),pit(Uyt,"_internalPadding",0),pit(Uyt,"_defaultColor",null),pit(Uyt,"_defaultFontSize",10),pit(Uyt,"_type","freetext"),pit(Uyt,"_editorType",Wot.FREETEXT);class Jyt{toSVGPath(){Tlt("Abstract method `toSVGPath` must be implemented.")}get box(){Tlt("Abstract getter `box` must be implemented.")}serialize(t,e){Tlt("Abstract method `serialize` must be implemented.")}static _rescale(t,e,r,n,i,a){a||(a=new Float32Array(t.length));for(var s=0,o=t.length;s<o;s+=2)a[s]=e+t[s]*n,a[s+1]=r+t[s+1]*i;return a}static _rescaleAndSwap(t,e,r,n,i,a){a||(a=new Float32Array(t.length));for(var s=0,o=t.length;s<o;s+=2)a[s]=e+t[s+1]*n,a[s+1]=r+t[s]*i;return a}static _translate(t,e,r,n){n||(n=new Float32Array(t.length));for(var i=0,a=t.length;i<a;i+=2)n[i]=e+t[i],n[i+1]=r+t[i+1];return n}static svgRound(t){return Math.round(1e4*t)}static _normalizePoint(t,e,r,n,i){switch(i){case 90:return[1-e/r,t/n];case 180:return[1-t/r,1-e/n];case 270:return[e/r,1-t/n];default:return[t/r,e/n]}}static _normalizePagePoint(t,e,r){switch(r){case 90:return[1-e,t];case 180:return[1-t,1-e];case 270:return[e,1-t];default:return[t,e]}}static createBezierPoints(t,e,r,n,i,a){return[(t+5*r)/6,(e+5*n)/6,(5*r+i)/6,(5*n+a)/6,(r+i)/2,(n+a)/2]}}pit(Jyt,"PRECISION",1e-4);var Zyt=new WeakMap,tbt=new WeakMap,ebt=new WeakMap,rbt=new WeakMap,nbt=new WeakMap,ibt=new WeakMap,abt=new WeakMap,sbt=new WeakMap,obt=new WeakMap,lbt=new WeakMap,hbt=new WeakMap,cbt=new WeakMap,ubt=new WeakMap,dbt=new WeakSet;class pbt{constructor(t,e,r,n,i){var{x:a,y:s}=t,o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0;dit(this,dbt),hit(this,Zyt,void 0),hit(this,tbt,[]),hit(this,ebt,void 0),hit(this,rbt,void 0),hit(this,nbt,[]),hit(this,ibt,new Float32Array(18)),hit(this,abt,void 0),hit(this,sbt,void 0),hit(this,obt,void 0),hit(this,lbt,void 0),hit(this,hbt,void 0),hit(this,cbt,void 0),hit(this,ubt,[]),cit(Zyt,this,e),cit(cbt,this,n*r),cit(rbt,this,i),lit(ibt,this).set([NaN,NaN,NaN,NaN,a,s],6),cit(ebt,this,o),cit(lbt,this,xbt._*r),cit(obt,this,Abt._*r),cit(hbt,this,r),lit(ubt,this).push(a,s)}isEmpty(){return isNaN(lit(ibt,this)[8])}add(t){var e,{x:r,y:n}=t;cit(abt,this,r),cit(sbt,this,n);var[i,a,s,o]=lit(Zyt,this),[l,h,c,u]=lit(ibt,this).subarray(8,12),d=r-c,p=n-u,f=Math.hypot(d,p);if(f<lit(obt,this))return!1;var g=f-lit(lbt,this),v=g/f,m=v*d,y=v*p,b=l,w=h;l=c,h=u,c+=m,u+=y,null===(e=lit(ubt,this))||void 0===e||e.push(r,n);var x=m/g,A=-y/g*lit(cbt,this),_=x*lit(cbt,this);return lit(ibt,this).set(lit(ibt,this).subarray(2,8),0),lit(ibt,this).set([c+A,u+_],4),lit(ibt,this).set(lit(ibt,this).subarray(14,18),12),lit(ibt,this).set([c-A,u-_],16),isNaN(lit(ibt,this)[6])?(0===lit(nbt,this).length&&(lit(ibt,this).set([l+A,h+_],2),lit(nbt,this).push(NaN,NaN,NaN,NaN,(l+A-i)/s,(h+_-a)/o),lit(ibt,this).set([l-A,h-_],14),lit(tbt,this).push(NaN,NaN,NaN,NaN,(l-A-i)/s,(h-_-a)/o)),lit(ibt,this).set([b,w,l,h,c,u],6),!this.isEmpty()):(lit(ibt,this).set([b,w,l,h,c,u],6),Math.abs(Math.atan2(w-h,b-l)-Math.atan2(y,m))<Math.PI/2?([l,h,c,u]=lit(ibt,this).subarray(2,6),lit(nbt,this).push(NaN,NaN,NaN,NaN,((l+c)/2-i)/s,((h+u)/2-a)/o),[l,h,b,w]=lit(ibt,this).subarray(14,18),lit(tbt,this).push(NaN,NaN,NaN,NaN,((b+l)/2-i)/s,((w+h)/2-a)/o),!0):([b,w,l,h,c,u]=lit(ibt,this).subarray(0,6),lit(nbt,this).push(((b+5*l)/6-i)/s,((w+5*h)/6-a)/o,((5*l+c)/6-i)/s,((5*h+u)/6-a)/o,((l+c)/2-i)/s,((h+u)/2-a)/o),[c,u,l,h,b,w]=lit(ibt,this).subarray(12,18),lit(tbt,this).push(((b+5*l)/6-i)/s,((w+5*h)/6-a)/o,((5*l+c)/6-i)/s,((5*h+u)/6-a)/o,((l+c)/2-i)/s,((h+u)/2-a)/o),!0))}toSVGPath(){if(this.isEmpty())return"";var t=lit(nbt,this),e=lit(tbt,this);if(isNaN(lit(ibt,this)[6])&&!this.isEmpty())return iit(dbt,this,gbt).call(this);var r=[];r.push("M".concat(t[4]," ").concat(t[5]));for(var n=6;n<t.length;n+=6)isNaN(t[n])?r.push("L".concat(t[n+4]," ").concat(t[n+5])):r.push("C".concat(t[n]," ").concat(t[n+1]," ").concat(t[n+2]," ").concat(t[n+3]," ").concat(t[n+4]," ").concat(t[n+5]));iit(dbt,this,mbt).call(this,r);for(var i=e.length-6;i>=6;i-=6)isNaN(e[i])?r.push("L".concat(e[i+4]," ").concat(e[i+5])):r.push("C".concat(e[i]," ").concat(e[i+1]," ").concat(e[i+2]," ").concat(e[i+3]," ").concat(e[i+4]," ").concat(e[i+5]));return iit(dbt,this,vbt).call(this,r),r.join(" ")}newFreeDrawOutline(t,e,r,n,i,a){return new Ibt(t,e,r,n,i,a)}getOutlines(){for(var t,e,r=lit(nbt,this),n=lit(tbt,this),i=lit(ibt,this),[a,s,o,l]=lit(Zyt,this),h=new Float32Array((null!==(t=null===(e=lit(ubt,this))||void 0===e?void 0:e.length)&&void 0!==t?t:0)+2),c=0,u=h.length-2;c<u;c+=2)h[c]=(lit(ubt,this)[c]-a)/o,h[c+1]=(lit(ubt,this)[c+1]-s)/l;if(h[h.length-2]=(lit(abt,this)-a)/o,h[h.length-1]=(lit(sbt,this)-s)/l,isNaN(i[6])&&!this.isEmpty())return iit(dbt,this,ybt).call(this,h);for(var d=new Float32Array(lit(nbt,this).length+24+lit(tbt,this).length),p=r.length,f=0;f<p;f+=2)isNaN(r[f])?d[f]=d[f+1]=NaN:(d[f]=r[f],d[f+1]=r[f+1]);p=iit(dbt,this,wbt).call(this,d,p);for(var g=n.length-6;g>=6;g-=6)for(var v=0;v<6;v+=2)isNaN(n[g+v])?(d[p]=d[p+1]=NaN,p+=2):(d[p]=n[g+v],d[p+1]=n[g+v+1],p+=2);return iit(dbt,this,bbt).call(this,d,p),this.newFreeDrawOutline(d,h,lit(Zyt,this),lit(hbt,this),lit(ebt,this),lit(rbt,this))}}function fbt(){var t=lit(ibt,this).subarray(4,6),e=lit(ibt,this).subarray(16,18),[r,n,i,a]=lit(Zyt,this);return[(lit(abt,this)+(t[0]-e[0])/2-r)/i,(lit(sbt,this)+(t[1]-e[1])/2-n)/a,(lit(abt,this)+(e[0]-t[0])/2-r)/i,(lit(sbt,this)+(e[1]-t[1])/2-n)/a]}function gbt(){var[t,e,r,n]=lit(Zyt,this),[i,a,s,o]=iit(dbt,this,fbt).call(this);return"M".concat((lit(ibt,this)[2]-t)/r," ").concat((lit(ibt,this)[3]-e)/n," L").concat((lit(ibt,this)[4]-t)/r," ").concat((lit(ibt,this)[5]-e)/n," L").concat(i," ").concat(a," L").concat(s," ").concat(o," L").concat((lit(ibt,this)[16]-t)/r," ").concat((lit(ibt,this)[17]-e)/n," L").concat((lit(ibt,this)[14]-t)/r," ").concat((lit(ibt,this)[15]-e)/n," Z")}function vbt(t){var e=lit(tbt,this);t.push("L".concat(e[4]," ").concat(e[5]," Z"))}function mbt(t){var[e,r,n,i]=lit(Zyt,this),a=lit(ibt,this).subarray(4,6),s=lit(ibt,this).subarray(16,18),[o,l,h,c]=iit(dbt,this,fbt).call(this);t.push("L".concat((a[0]-e)/n," ").concat((a[1]-r)/i," L").concat(o," ").concat(l," L").concat(h," ").concat(c," L").concat((s[0]-e)/n," ").concat((s[1]-r)/i))}function ybt(t){var e=lit(ibt,this),[r,n,i,a]=lit(Zyt,this),[s,o,l,h]=iit(dbt,this,fbt).call(this),c=new Float32Array(36);return c.set([NaN,NaN,NaN,NaN,(e[2]-r)/i,(e[3]-n)/a,NaN,NaN,NaN,NaN,(e[4]-r)/i,(e[5]-n)/a,NaN,NaN,NaN,NaN,s,o,NaN,NaN,NaN,NaN,l,h,NaN,NaN,NaN,NaN,(e[16]-r)/i,(e[17]-n)/a,NaN,NaN,NaN,NaN,(e[14]-r)/i,(e[15]-n)/a],0),this.newFreeDrawOutline(c,t,lit(Zyt,this),lit(hbt,this),lit(ebt,this),lit(rbt,this))}function bbt(t,e){var r=lit(tbt,this);return t.set([NaN,NaN,NaN,NaN,r[4],r[5]],e),e+6}function wbt(t,e){var r=lit(ibt,this).subarray(4,6),n=lit(ibt,this).subarray(16,18),[i,a,s,o]=lit(Zyt,this),[l,h,c,u]=iit(dbt,this,fbt).call(this);return t.set([NaN,NaN,NaN,NaN,(r[0]-i)/s,(r[1]-a)/o,NaN,NaN,NaN,NaN,l,h,NaN,NaN,NaN,NaN,c,u,NaN,NaN,NaN,NaN,(n[0]-i)/s,(n[1]-a)/o],e),e+24}var xbt={_:8},Abt={_:xbt._+2},_bt=new WeakMap,kbt=new WeakMap,Sbt=new WeakMap,Ebt=new WeakMap,Mbt=new WeakMap,Tbt=new WeakMap,Cbt=new WeakMap,Pbt=new WeakSet;class Ibt extends Jyt{constructor(t,e,r,n,i,a){super(),dit(this,Pbt),hit(this,_bt,void 0),hit(this,kbt,new Float32Array(4)),hit(this,Sbt,void 0),hit(this,Ebt,void 0),hit(this,Mbt,void 0),hit(this,Tbt,void 0),hit(this,Cbt,void 0),cit(Cbt,this,t),cit(Mbt,this,e),cit(_bt,this,r),cit(Tbt,this,n),cit(Sbt,this,i),cit(Ebt,this,a),this.lastPoint=[NaN,NaN],iit(Pbt,this,Rbt).call(this,a);for(var[s,o,l,h]=lit(kbt,this),c=0,u=t.length;c<u;c+=2)t[c]=(t[c]-s)/l,t[c+1]=(t[c+1]-o)/h;for(var d=0,p=e.length;d<p;d+=2)e[d]=(e[d]-s)/l,e[d+1]=(e[d+1]-o)/h}toSVGPath(){for(var t=["M".concat(lit(Cbt,this)[4]," ").concat(lit(Cbt,this)[5])],e=6,r=lit(Cbt,this).length;e<r;e+=6)isNaN(lit(Cbt,this)[e])?t.push("L".concat(lit(Cbt,this)[e+4]," ").concat(lit(Cbt,this)[e+5])):t.push("C".concat(lit(Cbt,this)[e]," ").concat(lit(Cbt,this)[e+1]," ").concat(lit(Cbt,this)[e+2]," ").concat(lit(Cbt,this)[e+3]," ").concat(lit(Cbt,this)[e+4]," ").concat(lit(Cbt,this)[e+5]));return t.push("Z"),t.join(" ")}serialize(t,e){var r,n,[i,a,s,o]=t,l=s-i,h=o-a;switch(e){case 0:r=Jyt._rescale(lit(Cbt,this),i,o,l,-h),n=Jyt._rescale(lit(Mbt,this),i,o,l,-h);break;case 90:r=Jyt._rescaleAndSwap(lit(Cbt,this),i,a,l,h),n=Jyt._rescaleAndSwap(lit(Mbt,this),i,a,l,h);break;case 180:r=Jyt._rescale(lit(Cbt,this),s,a,-l,h),n=Jyt._rescale(lit(Mbt,this),s,a,-l,h);break;case 270:r=Jyt._rescaleAndSwap(lit(Cbt,this),s,o,-l,-h),n=Jyt._rescaleAndSwap(lit(Mbt,this),s,o,-l,-h)}return{outline:Array.from(r),points:[Array.from(n)]}}get box(){return lit(kbt,this)}newOutliner(t,e,r,n,i){return new pbt(t,e,r,n,i,arguments.length>5&&void 0!==arguments[5]?arguments[5]:0)}getNewOutline(t,e){for(var[r,n,i,a]=lit(kbt,this),[s,o,l,h]=lit(_bt,this),c=i*l,u=a*h,d=r*l+s,p=n*h+o,f=this.newOutliner({x:lit(Mbt,this)[0]*c+d,y:lit(Mbt,this)[1]*u+p},lit(_bt,this),lit(Tbt,this),t,lit(Ebt,this),null!=e?e:lit(Sbt,this)),g=2;g<lit(Mbt,this).length;g+=2)f.add({x:lit(Mbt,this)[g]*c+d,y:lit(Mbt,this)[g+1]*u+p});return f.getOutlines()}}function Rbt(t){for(var e=lit(Cbt,this),r=e[4],n=e[5],i=r,a=n,s=r,o=n,l=r,h=n,c=t?Math.max:Math.min,u=6,d=e.length;u<d;u+=6){if(isNaN(e[u]))i=Math.min(i,e[u+4]),a=Math.min(a,e[u+5]),s=Math.max(s,e[u+4]),o=Math.max(o,e[u+5]),h<e[u+5]?(l=e[u+4],h=e[u+5]):h===e[u+5]&&(l=c(l,e[u+4]));else{var p=Ylt.bezierBoundingBox(r,n,...e.slice(u,u+6));i=Math.min(i,p[0]),a=Math.min(a,p[1]),s=Math.max(s,p[2]),o=Math.max(o,p[3]),h<p[3]?(l=p[2],h=p[3]):h===p[3]&&(l=c(l,p[2]))}r=e[u+4],n=e[u+5]}var f=lit(kbt,this);f[0]=i-lit(Sbt,this),f[1]=a-lit(Sbt,this),f[2]=s-i+2*lit(Sbt,this),f[3]=o-a+2*lit(Sbt,this),this.lastPoint=[l,h]}var Obt=new WeakMap,Lbt=new WeakMap,Dbt=new WeakMap,Fbt=new WeakMap,Nbt=new WeakSet;class jbt{constructor(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];dit(this,Nbt),hit(this,Obt,void 0),hit(this,Lbt,void 0),hit(this,Dbt,[]),hit(this,Fbt,[]);var i=1/0,a=-1/0,s=1/0,o=-1/0,l=Math.pow(10,-4);for(var{x:h,y:c,width:u,height:d}of t){var p=Math.floor((h-e)/l)*l,f=Math.ceil((h+u+e)/l)*l,g=Math.floor((c-e)/l)*l,v=Math.ceil((c+d+e)/l)*l,m=[p,g,v,!0],y=[f,g,v,!1];lit(Dbt,this).push(m,y),i=Math.min(i,p),a=Math.max(a,f),s=Math.min(s,g),o=Math.max(o,v)}var b=a-i+2*r,w=o-s+2*r,x=i-r,A=s-r,_=lit(Dbt,this).at(n?-1:-2),k=[_[0],_[2]];for(var S of lit(Dbt,this)){var[E,M,T]=S;S[0]=(E-x)/b,S[1]=(M-A)/w,S[2]=(T-A)/w}cit(Obt,this,new Float32Array([x,A,b,w])),cit(Lbt,this,k)}getOutlines(){lit(Dbt,this).sort(((t,e)=>t[0]-e[0]||t[1]-e[1]||t[2]-e[2]));var t=[];for(var e of lit(Dbt,this))e[3]?(t.push(...iit(Nbt,this,Hbt).call(this,e)),iit(Nbt,this,Wbt).call(this,e)):(iit(Nbt,this,Ubt).call(this,e),t.push(...iit(Nbt,this,Hbt).call(this,e)));return iit(Nbt,this,Bbt).call(this,t)}}function Bbt(t){var e=[],r=new Set;for(var n of t){var[i,a,s]=n;e.push([i,a,n],[i,s,n])}e.sort(((t,e)=>t[1]-e[1]||t[0]-e[0]));for(var o=0,l=e.length;o<l;o+=2){var h=e[o][2],c=e[o+1][2];h.push(c),c.push(h),r.add(h),r.add(c)}for(var u,d=[];r.size>0;){var p=r.values().next().value,[f,g,v,m,y]=p;r.delete(p);var b=f,w=g;for(u=[f,v],d.push(u);;){var x=void 0;if(r.has(m))x=m;else{if(!r.has(y))break;x=y}r.delete(x),[f,g,v,m,y]=x,b!==f&&(u.push(b,w,f,w===g?g:v),b=f),w=w===g?v:g}u.push(b,w)}return new Vbt(d,lit(Obt,this),lit(Lbt,this))}function zbt(t){for(var e=lit(Fbt,this),r=0,n=e.length-1;r<=n;){var i=r+n>>1,a=e[i][0];if(a===t)return i;a<t?r=i+1:n=i-1}return n+1}function Wbt(t){var[,e,r]=t,n=iit(Nbt,this,zbt).call(this,e);lit(Fbt,this).splice(n,0,[e,r])}function Ubt(t){for(var[,e,r]=t,n=iit(Nbt,this,zbt).call(this,e),i=n;i<lit(Fbt,this).length;i++){var[a,s]=lit(Fbt,this)[i];if(a!==e)break;if(a===e&&s===r)return void lit(Fbt,this).splice(i,1)}for(var o=n-1;o>=0;o--){var[l,h]=lit(Fbt,this)[o];if(l!==e)break;if(l===e&&h===r)return void lit(Fbt,this).splice(o,1)}}function Hbt(t){for(var[e,r,n]=t,i=[[e,r,n]],a=iit(Nbt,this,zbt).call(this,n),s=0;s<a;s++)for(var[o,l]=lit(Fbt,this)[s],h=0,c=i.length;h<c;h++){var[,u,d]=i[h];if(!(l<=u||d<=o))if(u>=o)if(d>l)i[h][1]=l;else{if(1===c)return[];i.splice(h,1),h--,c--}else i[h][2]=o,d>l&&i.push([e,l,d])}return i}var Gbt=new WeakMap,Ybt=new WeakMap;class Vbt extends Jyt{constructor(t,e,r){super(),hit(this,Gbt,void 0),hit(this,Ybt,void 0),cit(Ybt,this,t),cit(Gbt,this,e),this.lastPoint=r}toSVGPath(){var t=[];for(var e of lit(Ybt,this)){var[r,n]=e;t.push("M".concat(r," ").concat(n));for(var i=2;i<e.length;i+=2){var a=e[i],s=e[i+1];a===r?(t.push("V".concat(s)),n=s):s===n&&(t.push("H".concat(a)),r=a)}t.push("Z")}return t.join(" ")}serialize(t,e){var[r,n,i,a]=t,s=[],o=i-r,l=a-n;for(var h of lit(Ybt,this)){for(var c=new Array(h.length),u=0;u<h.length;u+=2)c[u]=r+h[u]*o,c[u+1]=a-h[u+1]*l;s.push(c)}return s}get box(){return lit(Gbt,this)}get classNamesForOutlining(){return["highlightOutline"]}}class qbt extends pbt{newFreeDrawOutline(t,e,r,n,i,a){return new Xbt(t,e,r,n,i,a)}}class Xbt extends Ibt{newOutliner(t,e,r,n,i){return new qbt(t,e,r,n,i,arguments.length>5&&void 0!==arguments[5]?arguments[5]:0)}}var $bt=new WeakMap,Kbt=new WeakMap,Qbt=new WeakMap,Jbt=new WeakMap,Zbt=new WeakMap,twt=new WeakMap,ewt=new WeakMap,rwt=new WeakMap,nwt=new WeakMap,iwt=new WeakMap,awt=new WeakMap,swt=new WeakSet;class owt{static get _keyboardManager(){return Ilt(this,"_keyboardManager",new ict([[["Escape","mac+Escape"],owt.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],owt.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],owt.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],owt.prototype._moveToPrevious],[["Home","mac+Home"],owt.prototype._moveToBeginning],[["End","mac+End"],owt.prototype._moveToEnd]]))}constructor(t){var e,{editor:r=null,uiManager:n=null}=t;dit(this,swt),hit(this,$bt,null),hit(this,Kbt,null),hit(this,Qbt,void 0),hit(this,Jbt,null),hit(this,Zbt,!1),hit(this,twt,!1),hit(this,ewt,null),hit(this,rwt,void 0),hit(this,nwt,null),hit(this,iwt,null),hit(this,awt,void 0),r?(cit(twt,this,!1),cit(awt,this,Uot.HIGHLIGHT_COLOR),cit(ewt,this,r)):(cit(twt,this,!0),cit(awt,this,Uot.HIGHLIGHT_DEFAULT_COLOR)),cit(iwt,this,(null==r?void 0:r._uiManager)||n),cit(rwt,this,lit(iwt,this)._eventBus),cit(Qbt,this,(null==r?void 0:r.color)||(null===(e=lit(iwt,this))||void 0===e?void 0:e.highlightColors.values().next().value)||"#FFFF98"),fwt._||(fwt._=Object.freeze({blue:"pdfjs-editor-colorpicker-blue",green:"pdfjs-editor-colorpicker-green",pink:"pdfjs-editor-colorpicker-pink",red:"pdfjs-editor-colorpicker-red",yellow:"pdfjs-editor-colorpicker-yellow"}))}renderButton(){var t=cit($bt,this,document.createElement("button"));t.className="colorPicker",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),t.setAttribute("aria-haspopup",!0);var e=lit(iwt,this)._signal;t.addEventListener("click",iit(swt,this,uwt).bind(this),{signal:e}),t.addEventListener("keydown",iit(swt,this,cwt).bind(this),{signal:e});var r=cit(Kbt,this,document.createElement("span"));return r.className="swatch",r.setAttribute("aria-hidden",!0),r.style.backgroundColor=lit(Qbt,this),t.append(r),t}renderMainDropdown(){var t=cit(Jbt,this,iit(swt,this,lwt).call(this));return t.setAttribute("aria-orientation","horizontal"),t.setAttribute("aria-labelledby","highlightColorPickerLabel"),t}_colorSelectFromKeyboard(t){if(t.target!==lit($bt,this)){var e=t.target.getAttribute("data-color");e&&iit(swt,this,hwt).call(this,e,t)}else iit(swt,this,uwt).call(this,t)}_moveToNext(t){var e,r;uit(swt,this,pwt)?t.target!==lit($bt,this)?null===(e=t.target.nextSibling)||void 0===e||e.focus():null===(r=lit(Jbt,this).firstChild)||void 0===r||r.focus():iit(swt,this,uwt).call(this,t)}_moveToPrevious(t){var e,r;t.target!==(null===(e=lit(Jbt,this))||void 0===e?void 0:e.firstChild)&&t.target!==lit($bt,this)?(uit(swt,this,pwt)||iit(swt,this,uwt).call(this,t),null===(r=t.target.previousSibling)||void 0===r||r.focus()):uit(swt,this,pwt)&&this._hideDropdownFromKeyboard()}_moveToBeginning(t){var e;uit(swt,this,pwt)?null===(e=lit(Jbt,this).firstChild)||void 0===e||e.focus():iit(swt,this,uwt).call(this,t)}_moveToEnd(t){var e;uit(swt,this,pwt)?null===(e=lit(Jbt,this).lastChild)||void 0===e||e.focus():iit(swt,this,uwt).call(this,t)}hideDropdown(){var t,e;null===(t=lit(Jbt,this))||void 0===t||t.classList.add("hidden"),null===(e=lit(nwt,this))||void 0===e||e.abort(),cit(nwt,this,null)}_hideDropdownFromKeyboard(){var t;lit(twt,this)||(uit(swt,this,pwt)?(this.hideDropdown(),lit($bt,this).focus({preventScroll:!0,focusVisible:lit(Zbt,this)})):null===(t=lit(ewt,this))||void 0===t||t.unselect())}updateColor(t){if(lit(Kbt,this)&&(lit(Kbt,this).style.backgroundColor=t),lit(Jbt,this)){var e=lit(iwt,this).highlightColors.values();for(var r of lit(Jbt,this).children)r.setAttribute("aria-selected",e.next().value===t)}}destroy(){var t,e;null===(t=lit($bt,this))||void 0===t||t.remove(),cit($bt,this,null),cit(Kbt,this,null),null===(e=lit(Jbt,this))||void 0===e||e.remove(),cit(Jbt,this,null)}}function lwt(){var t=document.createElement("div"),e=lit(iwt,this)._signal;for(var[r,n]of(t.addEventListener("contextmenu",cht,{signal:e}),t.className="dropdown",t.role="listbox",t.setAttribute("aria-multiselectable",!1),t.setAttribute("aria-orientation","vertical"),t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown"),lit(iwt,this).highlightColors)){var i=document.createElement("button");i.tabIndex="0",i.role="option",i.setAttribute("data-color",n),i.title=r,i.setAttribute("data-l10n-id",fwt._[r]);var a=document.createElement("span");i.append(a),a.className="swatch",a.style.backgroundColor=n,i.setAttribute("aria-selected",n===lit(Qbt,this)),i.addEventListener("click",iit(swt,this,hwt).bind(this,n),{signal:e}),t.append(i)}return t.addEventListener("keydown",iit(swt,this,cwt).bind(this),{signal:e}),t}function hwt(t,e){e.stopPropagation(),lit(rwt,this).dispatch("switchannotationeditorparams",{source:this,type:lit(awt,this),value:t})}function cwt(t){bot._keyboardManager.exec(this,t)}function uwt(t){if(uit(swt,this,pwt))this.hideDropdown();else if(cit(Zbt,this,0===t.detail),lit(nwt,this)||(cit(nwt,this,new AbortController),window.addEventListener("pointerdown",iit(swt,this,dwt).bind(this),{signal:lit(iwt,this).combinedSignal(lit(nwt,this))})),lit(Jbt,this))lit(Jbt,this).classList.remove("hidden");else{var e=cit(Jbt,this,iit(swt,this,lwt).call(this));lit($bt,this).append(e)}}function dwt(t){var e;null!==(e=lit(Jbt,this))&&void 0!==e&&e.contains(t.target)||this.hideDropdown()}function pwt(t){return lit(Jbt,t)&&!lit(Jbt,t).classList.contains("hidden")}bot=owt;var fwt={_:null},gwt=new WeakMap,vwt=new WeakMap,mwt=new WeakMap,ywt=new WeakMap,bwt=new WeakMap,wwt=new WeakMap,xwt=new WeakMap,Awt=new WeakMap,_wt=new WeakMap,kwt=new WeakMap,Swt=new WeakMap,Ewt=new WeakMap,Mwt=new WeakMap,Twt=new WeakMap,Cwt=new WeakMap,Pwt=new WeakMap,Iwt=new WeakMap,Rwt=new WeakMap,Owt=new WeakSet;class Lwt extends kdt{static get _keyboardManager(){var t=Lwt.prototype;return Ilt(this,"_keyboardManager",new ict([[["ArrowLeft","mac+ArrowLeft"],t._moveCaret,{args:[0]}],[["ArrowRight","mac+ArrowRight"],t._moveCaret,{args:[1]}],[["ArrowUp","mac+ArrowUp"],t._moveCaret,{args:[2]}],[["ArrowDown","mac+ArrowDown"],t._moveCaret,{args:[3]}]]))}constructor(t){super(git(git({},t),{},{name:"highlightEditor"})),dit(this,Owt),hit(this,gwt,null),hit(this,vwt,0),hit(this,mwt,void 0),hit(this,ywt,null),hit(this,bwt,null),hit(this,wwt,null),hit(this,xwt,null),hit(this,Awt,0),hit(this,_wt,null),hit(this,kwt,null),hit(this,Swt,null),hit(this,Ewt,!1),hit(this,Mwt,null),hit(this,Twt,void 0),hit(this,Cwt,null),hit(this,Pwt,""),hit(this,Iwt,void 0),hit(this,Rwt,""),this.color=t.color||Lwt._defaultColor,cit(Iwt,this,t.thickness||Lwt._defaultThickness),cit(Twt,this,t.opacity||Lwt._defaultOpacity),cit(mwt,this,t.boxes||null),cit(Rwt,this,t.methodOfCreation||""),cit(Pwt,this,t.text||""),this._isDraggable=!1,t.highlightId>-1?(cit(Ewt,this,!0),iit(Owt,this,Fwt).call(this,t),iit(Owt,this,Wwt).call(this)):lit(mwt,this)&&(cit(gwt,this,t.anchorNode),cit(vwt,this,t.anchorOffset),cit(xwt,this,t.focusNode),cit(Awt,this,t.focusOffset),iit(Owt,this,Dwt).call(this),iit(Owt,this,Wwt).call(this),this.rotate(this.rotation))}get telemetryInitialData(){return{action:"added",type:lit(Ewt,this)?"free_highlight":"highlight",color:this._uiManager.highlightColorNames.get(this.color),thickness:lit(Iwt,this),methodOfCreation:lit(Rwt,this)}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.highlightColorNames.get(this.color)}}static computeTelemetryFinalData(t){return{numberOfColors:t.get("color").size}}static initialize(t,e){var r;kdt.initialize(t,e),Lwt._defaultColor||(Lwt._defaultColor=(null===(r=e.highlightColors)||void 0===r?void 0:r.values().next().value)||"#fff066")}static updateDefaultParams(t,e){switch(t){case Uot.HIGHLIGHT_DEFAULT_COLOR:Lwt._defaultColor=e;break;case Uot.HIGHLIGHT_THICKNESS:Lwt._defaultThickness=e}}translateInPage(t,e){}get toolbarPosition(){return lit(Mwt,this)}updateParams(t,e){switch(t){case Uot.HIGHLIGHT_COLOR:iit(Owt,this,Nwt).call(this,e);break;case Uot.HIGHLIGHT_THICKNESS:iit(Owt,this,jwt).call(this,e)}}static get defaultPropertiesToUpdate(){return[[Uot.HIGHLIGHT_DEFAULT_COLOR,Lwt._defaultColor],[Uot.HIGHLIGHT_THICKNESS,Lwt._defaultThickness]]}get propertiesToUpdate(){return[[Uot.HIGHLIGHT_COLOR,this.color||Lwt._defaultColor],[Uot.HIGHLIGHT_THICKNESS,lit(Iwt,this)||Lwt._defaultThickness],[Uot.HIGHLIGHT_FREE,lit(Ewt,this)]]}addEditToolbar(){var t=()=>super.addEditToolbar,e=this;return sit((function*(){var r=yield t().call(e);return r?(e._uiManager.highlightColors&&(cit(bwt,e,new owt({editor:e})),r.addColorPicker(lit(bwt,e))),r):null}))()}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(iit(Owt,this,Ywt).call(this))}getBaseTranslation(){return[0,0]}getRect(t,e){return super.getRect(t,e,iit(Owt,this,Ywt).call(this))}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),t&&this.div.focus()}remove(){iit(Owt,this,zwt).call(this),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(iit(Owt,this,Wwt).call(this),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){var e=!1;if(this.parent&&!t)iit(Owt,this,zwt).call(this);else if(t){var r;iit(Owt,this,Wwt).call(this,t),e=!this.parent&&(null===(r=this.div)||void 0===r?void 0:r.classList.contains("selectedEditor"))}super.setParent(t),this.show(this._isVisible),e&&this.select()}rotate(t){var e,{drawLayer:r}=this.parent;lit(Ewt,this)?(t=(t-this.rotation+360)%360,e=Uwt.call(Lwt,lit(kwt,this).box,t)):e=Uwt.call(Lwt,[this.x,this.y,this.width,this.height],t),r.updateProperties(lit(Swt,this),{bbox:e,root:{"data-main-rotation":t}}),r.updateProperties(lit(Cwt,this),{bbox:Uwt.call(Lwt,lit(wwt,this).box,t),root:{"data-main-rotation":t}})}render(){if(this.div)return this.div;var t=super.render();lit(Pwt,this)&&(t.setAttribute("aria-label",lit(Pwt,this)),t.setAttribute("role","mark")),lit(Ewt,this)?t.classList.add("free"):this.div.addEventListener("keydown",iit(Owt,this,Hwt).bind(this),{signal:this._uiManager._signal});var e=cit(_wt,this,document.createElement("div"));t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal",e.style.clipPath=lit(ywt,this);var[r,n]=this.parentDimensions;return this.setDims(this.width*r,this.height*n),Uht(this,lit(_wt,this),["pointerover","pointerleave"]),this.enableEditing(),t}pointerover(){var t;this.isSelected||(null===(t=this.parent)||void 0===t||t.drawLayer.updateProperties(lit(Cwt,this),{rootClass:{hovered:!0}}))}pointerleave(){var t;this.isSelected||(null===(t=this.parent)||void 0===t||t.drawLayer.updateProperties(lit(Cwt,this),{rootClass:{hovered:!1}}))}_moveCaret(t){switch(this.parent.unselect(this),t){case 0:case 2:iit(Owt,this,Gwt).call(this,!0);break;case 1:case 3:iit(Owt,this,Gwt).call(this,!1)}}select(){var t;super.select(),lit(Cwt,this)&&(null===(t=this.parent)||void 0===t||t.drawLayer.updateProperties(lit(Cwt,this),{rootClass:{hovered:!1,selected:!0}}))}unselect(){var t;super.unselect(),lit(Cwt,this)&&(null===(t=this.parent)||void 0===t||t.drawLayer.updateProperties(lit(Cwt,this),{rootClass:{selected:!1}}),lit(Ewt,this)||iit(Owt,this,Gwt).call(this,!1))}get _mustFixPosition(){return!lit(Ewt,this)}show(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this._isVisible;super.show(t),this.parent&&(this.parent.drawLayer.updateProperties(lit(Swt,this),{rootClass:{hidden:!t}}),this.parent.drawLayer.updateProperties(lit(Cwt,this),{rootClass:{hidden:!t}}))}static startHighlighting(t,e,r){var{target:n,x:i,y:a}=r,{x:s,y:o,width:l,height:h}=n.getBoundingClientRect(),c=new AbortController,u=t.combinedSignal(c),d=e=>{c.abort(),iit(Lwt,this,$wt).call(this,t,e)};window.addEventListener("blur",d,{signal:u}),window.addEventListener("pointerup",d,{signal:u}),window.addEventListener("pointerdown",uht,{capture:!0,passive:!1,signal:u}),window.addEventListener("contextmenu",cht,{signal:u}),n.addEventListener("pointermove",iit(Lwt,this,Xwt).bind(this,t),{signal:u}),this._freeHighlight=new qbt({x:i,y:a},[s,o,l,h],t.scale,this._defaultThickness/2,e,.001),({id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=t.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:this._defaultColor,"fill-opacity":this._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:this._freeHighlight.toSVGPath()}},!0,!0))}static deserialize(t,e,r){var n=()=>super.deserialize,i=this;return sit((function*(){var a=null;if(t instanceof myt){var{data:{quadPoints:s,rect:o,rotation:l,id:h,color:c,opacity:u,popupRef:d},parent:{page:{pageNumber:p}}}=t;a=t={annotationType:Wot.HIGHLIGHT,color:Array.from(c),opacity:u,quadPoints:s,boxes:null,pageIndex:p-1,rect:o.slice(0),rotation:l,id:h,deleted:!1,popupRef:d}}else if(t instanceof gyt){var{data:{inkLists:f,rect:g,rotation:v,id:m,color:y,borderStyle:{rawWidth:b},popupRef:w},parent:{page:{pageNumber:x}}}=t;a=t={annotationType:Wot.HIGHLIGHT,color:Array.from(y),thickness:b,inkLists:f,boxes:null,pageIndex:x-1,rect:g.slice(0),rotation:v,id:m,deleted:!1,popupRef:w}}var{color:A,quadPoints:_,inkLists:k,opacity:S}=t,E=yield n().call(i,t,e,r);E.color=Ylt.makeHexColor(...A),cit(Twt,E,S||1),k&&cit(Iwt,E,t.thickness),E.annotationElementId=t.id||null,E._initialData=a;var[M,T]=E.pageDimensions,[C,P]=E.pageTranslation;if(_){for(var I=cit(mwt,E,[]),R=0;R<_.length;R+=8)I.push({x:(_[R]-C)/M,y:1-(_[R+1]-P)/T,width:(_[R+2]-_[R])/M,height:(_[R+1]-_[R+5])/T});iit(Owt,E,Dwt).call(E),iit(Owt,E,Wwt).call(E),E.rotate(E.rotation)}else if(k){cit(Ewt,E,!0);for(var O=k[0],L={x:O[0]-C,y:T-(O[1]-P)},D=new qbt(L,[0,0,M,T],1,lit(Iwt,E)/2,!0,.001),F=0,N=O.length;F<N;F+=2)L.x=O[F]-C,L.y=T-(O[F+1]-P),D.add(L);var{id:j,clipPathId:B}=e.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:E.color,"fill-opacity":E._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:D.toSVGPath()}},!0,!0);iit(Owt,E,Fwt).call(E,{highlightOutlines:D.getOutlines(),highlightId:j,clipPathId:B}),iit(Owt,E,Wwt).call(E)}return E}))()}serialize(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(this.isEmpty()||t)return null;if(this.deleted)return this.serializeDeleted();var e=this.getRect(0,0),r=kdt._colorManager.convert(this.color),n={annotationType:Wot.HIGHLIGHT,color:r,opacity:lit(Twt,this),thickness:lit(Iwt,this),quadPoints:iit(Owt,this,Vwt).call(this),outlines:iit(Owt,this,qwt).call(this,e),pageIndex:this.pageIndex,rect:e,rotation:iit(Owt,this,Ywt).call(this),structTreeParentId:this._structTreeParentId};return this.annotationElementId&&!iit(Owt,this,Kwt).call(this,n)?null:(n.id=this.annotationElementId,n)}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}}function Dwt(){var t=new jbt(lit(mwt,this),.001);cit(kwt,this,t.getOutlines()),[this.x,this.y,this.width,this.height]=lit(kwt,this).box;var e=new jbt(lit(mwt,this),.0025,.001,"ltr"===this._uiManager.direction);cit(wwt,this,e.getOutlines());var{lastPoint:r}=lit(wwt,this);cit(Mwt,this,[(r[0]-this.x)/this.width,(r[1]-this.y)/this.height])}function Fwt(t){var{highlightOutlines:e,highlightId:r,clipPathId:n}=t;cit(kwt,this,e);if(cit(wwt,this,e.getNewOutline(lit(Iwt,this)/2+1.5,.0025)),r>=0)cit(Swt,this,r),cit(ywt,this,n),this.parent.drawLayer.finalizeDraw(r,{bbox:e.box,path:{d:e.toSVGPath()}}),cit(Cwt,this,this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:lit(wwt,this).box,path:{d:lit(wwt,this).toSVGPath()}},!0));else if(this.parent){var i=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(lit(Swt,this),{bbox:Uwt.call(wot,lit(kwt,this).box,(i-this.rotation+360)%360),path:{d:e.toSVGPath()}}),this.parent.drawLayer.updateProperties(lit(Cwt,this),{bbox:Uwt.call(wot,lit(wwt,this).box,i),path:{d:lit(wwt,this).toSVGPath()}})}var[a,s,o,l]=e.box;switch(this.rotation){case 0:this.x=a,this.y=s,this.width=o,this.height=l;break;case 90:var[h,c]=this.parentDimensions;this.x=s,this.y=1-a,this.width=o*c/h,this.height=l*h/c;break;case 180:this.x=1-a,this.y=1-s,this.width=o,this.height=l;break;case 270:var[u,d]=this.parentDimensions;this.x=1-s,this.y=a,this.width=o*d/u,this.height=l*u/d}var{lastPoint:p}=lit(wwt,this);cit(Mwt,this,[(p[0]-a)/o,(p[1]-s)/l])}function Nwt(t){var e=(t,e)=>{var r,n;this.color=t,cit(Twt,this,e),null===(r=this.parent)||void 0===r||r.drawLayer.updateProperties(lit(Swt,this),{root:{fill:t,"fill-opacity":e}}),null===(n=lit(bwt,this))||void 0===n||n.updateColor(t)},r=this.color,n=lit(Twt,this);this.addCommands({cmd:e.bind(this,t,wot._defaultOpacity),undo:e.bind(this,r,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Uot.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.highlightColorNames.get(t)},!0)}function jwt(t){var e=lit(Iwt,this),r=t=>{cit(Iwt,this,t),iit(Owt,this,Bwt).call(this,t)};this.addCommands({cmd:r.bind(this,t),undo:r.bind(this,e),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Uot.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:t},!0)}function Bwt(t){if(lit(Ewt,this)){iit(Owt,this,Fwt).call(this,{highlightOutlines:lit(kwt,this).getNewOutline(t/2)}),this.fixAndSetPosition();var[e,r]=this.parentDimensions;this.setDims(this.width*e,this.height*r)}}function zwt(){null!==lit(Swt,this)&&this.parent&&(this.parent.drawLayer.remove(lit(Swt,this)),cit(Swt,this,null),this.parent.drawLayer.remove(lit(Cwt,this)),cit(Cwt,this,null))}function Wwt(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.parent;null===lit(Swt,this)&&(({id:vit(cit,[Swt,this])._,clipPathId:vit(cit,[ywt,this])._}=t.drawLayer.draw({bbox:lit(kwt,this).box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":lit(Twt,this)},rootClass:{highlight:!0,free:lit(Ewt,this)},path:{d:lit(kwt,this).toSVGPath()}},!1,!0)),cit(Cwt,this,t.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:lit(Ewt,this)},bbox:lit(wwt,this).box,path:{d:lit(wwt,this).toSVGPath()}},lit(Ewt,this))),lit(_wt,this)&&(lit(_wt,this).style.clipPath=lit(ywt,this)))}function Uwt(t,e){var[r,n,i,a]=t;switch(e){case 90:return[1-n-a,r,a,i];case 180:return[1-r-i,1-n-a,i,a];case 270:return[n,1-r-i,a,i]}return[r,n,i,a]}function Hwt(t){wot._keyboardManager.exec(this,t)}function Gwt(t){if(lit(gwt,this)){var e=window.getSelection();t?e.setPosition(lit(gwt,this),lit(vwt,this)):e.setPosition(lit(xwt,this),lit(Awt,this))}}function Ywt(){return lit(Ewt,this)?this.rotation:0}function Vwt(){if(lit(Ewt,this))return null;var[t,e]=this.pageDimensions,[r,n]=this.pageTranslation,i=lit(mwt,this),a=new Float32Array(8*i.length),s=0;for(var{x:o,y:l,width:h,height:c}of i){var u=o*t+r,d=(1-l)*e+n;a[s]=a[s+4]=u,a[s+1]=a[s+3]=d,a[s+2]=a[s+6]=u+h*t,a[s+5]=a[s+7]=d-c*e,s+=8}return a}function qwt(t){return lit(kwt,this).serialize(t,iit(Owt,this,Ywt).call(this))}function Xwt(t,e){this._freeHighlight.add(e)&&t.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})}function $wt(t,e){this._freeHighlight.isEmpty()?t.drawLayer.remove(this._freeHighlightId):t.createAndAddNewEditor(e,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""}function Kwt(t){var{color:e}=this._initialData;return t.color.some(((t,r)=>t!==e[r]))}wot=Lwt,pit(Lwt,"_defaultColor",null),pit(Lwt,"_defaultOpacity",1),pit(Lwt,"_defaultThickness",12),pit(Lwt,"_type","highlight"),pit(Lwt,"_editorType",Wot.HIGHLIGHT),pit(Lwt,"_freeHighlightId",-1),pit(Lwt,"_freeHighlight",null),pit(Lwt,"_freeHighlightClipId","");var Qwt=new WeakMap;class Jwt{constructor(){hit(this,Qwt,Object.create(null))}updateProperty(t,e){this[t]=e,this.updateSVGProperty(t,e)}updateProperties(t){if(t)for(var[e,r]of Object.entries(t))this.updateProperty(e,r)}updateSVGProperty(t,e){lit(Qwt,this)[t]=e}toSVGProperties(){var t=lit(Qwt,this);return cit(Qwt,this,Object.create(null)),{root:t}}reset(){cit(Qwt,this,Object.create(null))}updateAll(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this;this.updateProperties(t)}clone(){Tlt("Not implemented")}}var Zwt=new WeakMap,txt=new WeakMap,ext=new WeakSet;class rxt extends kdt{constructor(t){super(t),dit(this,ext),hit(this,Zwt,null),hit(this,txt,void 0),pit(this,"_drawId",null),cit(txt,this,t.mustBeCommitted||!1),t.drawOutlines&&(iit(ext,this,nxt).call(this,t),iit(ext,this,sxt).call(this))}static _mergeSVGProperties(t,e){var r=new Set(Object.keys(t));for(var[n,i]of Object.entries(e))r.has(n)?Object.assign(t[n],i):t[n]=i;return t}static getDefaultDrawingOptions(t){Tlt("Not implemented")}static get typesMap(){Tlt("Not implemented")}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(t,e){var r=this.typesMap.get(t);r&&this._defaultDrawingOptions.updateProperty(r,e),this._currentParent&&(uxt._.updateProperty(r,e),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(t,e){var r=this.constructor.typesMap.get(t);r&&this._updateProperty(t,r,e)}static get defaultPropertiesToUpdate(){var t=[],e=this._defaultDrawingOptions;for(var[r,n]of this.typesMap)t.push([r,e[n]]);return t}get propertiesToUpdate(){var t=[],{_drawingOptions:e}=this;for(var[r,n]of this.constructor.typesMap)t.push([r,e[n]]);return t}_updateProperty(t,e,r){var n=this._drawingOptions,i=n[e],a=t=>{var r;n.updateProperty(e,t);var i=lit(Zwt,this).updateProperty(e,t);i&&iit(ext,this,hxt).call(this,i),null===(r=this.parent)||void 0===r||r.drawLayer.updateProperties(this._drawId,n.toSVGProperties())};this.addCommands({cmd:a.bind(this,r),undo:a.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:t,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){var t;null===(t=this.parent)||void 0===t||t.drawLayer.updateProperties(this._drawId,rxt._mergeSVGProperties(lit(Zwt,this).getPathResizingSVGProperties(iit(ext,this,lxt).call(this)),{bbox:iit(ext,this,cxt).call(this)}))}_onResized(){var t;null===(t=this.parent)||void 0===t||t.drawLayer.updateProperties(this._drawId,rxt._mergeSVGProperties(lit(Zwt,this).getPathResizedSVGProperties(iit(ext,this,lxt).call(this)),{bbox:iit(ext,this,cxt).call(this)}))}_onTranslating(t,e){var r;null===(r=this.parent)||void 0===r||r.drawLayer.updateProperties(this._drawId,{bbox:iit(ext,this,cxt).call(this,t,e)})}_onTranslated(){var t;null===(t=this.parent)||void 0===t||t.drawLayer.updateProperties(this._drawId,rxt._mergeSVGProperties(lit(Zwt,this).getPathTranslatedSVGProperties(iit(ext,this,lxt).call(this),this.parentDimensions),{bbox:iit(ext,this,cxt).call(this)}))}_onStartDragging(){var t;null===(t=this.parent)||void 0===t||t.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){var t;null===(t=this.parent)||void 0===t||t.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!1}})}commit(){super.commit(),this.disableEditMode(),this.disableEditing()}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}getBaseTranslation(){return[0,0]}get isResizable(){return!0}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),this._isDraggable=!0,lit(txt,this)&&(cit(txt,this,!1),this.commit(),this.parent.setSelected(this),t&&this.isOnScreen&&this.div.focus())}remove(){iit(ext,this,axt).call(this),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(iit(ext,this,sxt).call(this),iit(ext,this,hxt).call(this,lit(Zwt,this).box),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){var e=!1;if(this.parent&&!t)this._uiManager.removeShouldRescale(this),iit(ext,this,axt).call(this);else if(t){var r;this._uiManager.addShouldRescale(this),iit(ext,this,sxt).call(this,t),e=!this.parent&&(null===(r=this.div)||void 0===r?void 0:r.classList.contains("selectedEditor"))}super.setParent(t),e&&this.select()}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,rxt._mergeSVGProperties({bbox:iit(ext,this,cxt).call(this)},lit(Zwt,this).updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&iit(ext,this,hxt).call(this,lit(Zwt,this).updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;var t=super.render();t.classList.add("draw");var e=document.createElement("div");t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal";var[r,n]=this.parentDimensions;return this.setDims(this.width*r,this.height*n),this._uiManager.addShouldRescale(this),this.disableEditing(),t}static createDrawerInstance(t,e,r,n,i){Tlt("Not implemented")}static startDrawing(t,e,r,n){var i,a,{target:s,offsetX:o,offsetY:l,pointerId:h,pointerType:c}=n;if(!gxt._||gxt._===c){var{viewport:{rotation:u}}=t,{width:d,height:p}=s.getBoundingClientRect(),f=dxt._=new AbortController,g=t.combinedSignal(f);fxt._||(fxt._=h),null!==(i=gxt._)&&void 0!==i||(gxt._=c),window.addEventListener("pointerup",(t=>{var e;fxt._===t.pointerId?this._endDraw(t):null===(e=vxt._)||void 0===e||e.delete(t.pointerId)}),{signal:g}),window.addEventListener("pointercancel",(t=>{var e;fxt._===t.pointerId?this._currentParent.endDrawingSession():null===(e=vxt._)||void 0===e||e.delete(t.pointerId)}),{signal:g}),window.addEventListener("pointerdown",(t=>{gxt._===t.pointerType&&((vxt._||(vxt._=new Set)).add(t.pointerId),uxt._.isCancellable()&&(uxt._.removeLastElement(),uxt._.isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))}),{capture:!0,passive:!1,signal:g}),window.addEventListener("contextmenu",cht,{signal:g}),s.addEventListener("pointermove",this._drawMove.bind(this),{signal:g}),s.addEventListener("touchmove",(t=>{t.timeStamp===mxt._&&uht(t)}),{signal:g}),t.toggleDrawing(),null===(a=e._editorUndoBar)||void 0===a||a.hide(),uxt._?t.drawLayer.updateProperties(this._currentDrawId,uxt._.startNew(o,l,d,p,u)):(e.updateUIForDefaultProperties(this),uxt._=this.createDrawerInstance(o,l,d,p,u),pxt._=this.getDefaultDrawingOptions(),this._currentParent=t,({id:this._currentDrawId}=t.drawLayer.draw(this._mergeSVGProperties(pxt._.toSVGProperties(),uxt._.defaultSVGProperties),!0,!1)))}}static _drawMove(t){var e;if(mxt._=-1,uxt._){var{offsetX:r,offsetY:n,pointerId:i}=t;fxt._===i&&((null===(e=vxt._)||void 0===e?void 0:e.size)>=1?this._endDraw(t):(this._currentParent.drawLayer.updateProperties(this._currentDrawId,uxt._.add(r,n)),mxt._=t.timeStamp,uht(t)))}}static _cleanup(t){t&&(this._currentDrawId=-1,this._currentParent=null,uxt._=null,pxt._=null,gxt._=null,mxt._=NaN),dxt._&&(dxt._.abort(),dxt._=null,fxt._=NaN,vxt._=null)}static _endDraw(t){var e=this._currentParent;if(e)if(e.toggleDrawing(!0),this._cleanup(!1),t&&e.drawLayer.updateProperties(this._currentDrawId,uxt._.end(t.offsetX,t.offsetY)),this.supportMultipleDrawings){var r=uxt._,n=this._currentDrawId,i=r.getLastElement();e.addCommands({cmd:()=>{e.drawLayer.updateProperties(n,r.setLastElement(i))},undo:()=>{e.drawLayer.updateProperties(n,r.removeLastElement())},mustExec:!1,type:Uot.DRAW_STEP})}else this.endDrawing(!1)}static endDrawing(t){var e=this._currentParent;if(!e)return null;if(e.toggleDrawing(!0),e.cleanUndoStack(Uot.DRAW_STEP),!uxt._.isEmpty()){var{pageDimensions:[r,n],scale:i}=e,a=e.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:uxt._.getOutlines(r*i,n*i,i,this._INNER_MARGIN),drawingOptions:pxt._,mustBeCommitted:!t});return this._cleanup(!0),a}return e.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(t){}static deserializeDraw(t,e,r,n,i,a){Tlt("Not implemented")}static deserialize(t,e,r){var n=()=>super.deserialize,i=this;return sit((function*(){var{rawDims:{pageWidth:a,pageHeight:s,pageX:o,pageY:l}}=e.viewport,h=i.deserializeDraw(o,l,a,s,i._INNER_MARGIN,t),c=yield n().call(i,t,e,r);return c.createDrawingOptions(t),iit(ext,c,nxt).call(c,{drawOutlines:h}),iit(ext,c,sxt).call(c),c.onScaleChanging(),c.rotate(),c}))()}serializeDraw(t){var[e,r]=this.pageTranslation,[n,i]=this.pageDimensions;return lit(Zwt,this).serialize([e,r,n,i],t)}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}}function nxt(t){var{drawOutlines:e,drawId:r,drawingOptions:n}=t;cit(Zwt,this,e),this._drawingOptions||(this._drawingOptions=n),r>=0?(this._drawId=r,this.parent.drawLayer.finalizeDraw(r,e.defaultProperties)):this._drawId=iit(ext,this,ixt).call(this,e,this.parent),iit(ext,this,hxt).call(this,e.box)}function ixt(t,e){var{id:r}=e.drawLayer.draw(xot._mergeSVGProperties(this._drawingOptions.toSVGProperties(),t.defaultSVGProperties),!1,!1);return r}function axt(){null!==this._drawId&&this.parent&&(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())}function sxt(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.parent;null!==this._drawId&&this.parent===t||(null===this._drawId?(this._drawingOptions.updateAll(),this._drawId=iit(ext,this,ixt).call(this,lit(Zwt,this),t)):this.parent.drawLayer.updateParent(this._drawId,t.drawLayer))}function oxt(t){var[e,r,n,i]=t,{parentDimensions:[a,s],rotation:o}=this;switch(o){case 90:return[r,1-e,n*(s/a),i*(a/s)];case 180:return[1-e,1-r,n,i];case 270:return[1-r,e,n*(s/a),i*(a/s)];default:return[e,r,n,i]}}function lxt(){var{x:t,y:e,width:r,height:n,parentDimensions:[i,a],rotation:s}=this;switch(s){case 90:return[1-e,t,r*(i/a),n*(a/i)];case 180:return[1-t,1-e,r,n];case 270:return[e,1-t,r*(i/a),n*(a/i)];default:return[t,e,r,n]}}function hxt(t){if([this.x,this.y,this.width,this.height]=iit(ext,this,oxt).call(this,t),this.div){this.fixAndSetPosition();var[e,r]=this.parentDimensions;this.setDims(this.width*e,this.height*r)}this._onResized()}function cxt(){var{x:t,y:e,width:r,height:n,rotation:i,parentRotation:a,parentDimensions:[s,o]}=this;switch((4*i+a)/90){case 1:return[1-e-n,t,n,r];case 2:return[1-t-r,1-e-n,r,n];case 3:return[e,1-t-r,n,r];case 4:return[t,e-r*(s/o),n*(o/s),r*(s/o)];case 5:return[1-e,t,r*(s/o),n*(o/s)];case 6:return[1-t-n*(o/s),1-e,n*(o/s),r*(s/o)];case 7:return[e-r*(s/o),1-t-n*(o/s),r*(s/o),n*(o/s)];case 8:return[t-r,e-n,r,n];case 9:return[1-e,t-r,n,r];case 10:return[1-t,1-e,r,n];case 11:return[e-n,1-t,n,r];case 12:return[t-n*(o/s),e,n*(o/s),r*(s/o)];case 13:return[1-e-r*(s/o),t-n*(o/s),r*(s/o),n*(o/s)];case 14:return[1-t,1-e-r*(s/o),n*(o/s),r*(s/o)];case 15:return[e,1-t,r*(s/o),n*(o/s)];default:return[t,e,r,n]}}xot=rxt,pit(rxt,"_currentDrawId",-1),pit(rxt,"_currentParent",null);var uxt={_:null},dxt={_:null},pxt={_:null},fxt={_:NaN},gxt={_:null},vxt={_:null},mxt={_:NaN};pit(rxt,"_INNER_MARGIN",3);var yxt=new WeakMap,bxt=new WeakMap,wxt=new WeakMap,xxt=new WeakMap,Axt=new WeakMap,_xt=new WeakMap,kxt=new WeakMap,Sxt=new WeakMap,Ext=new WeakMap,Mxt=new WeakMap,Txt=new WeakMap,Cxt=new WeakSet;class Pxt{constructor(t,e,r,n,i,a){dit(this,Cxt),hit(this,yxt,new Float64Array(6)),hit(this,bxt,void 0),hit(this,wxt,void 0),hit(this,xxt,void 0),hit(this,Axt,void 0),hit(this,_xt,void 0),hit(this,kxt,""),hit(this,Sxt,0),hit(this,Ext,new Uxt),hit(this,Mxt,void 0),hit(this,Txt,void 0),cit(Mxt,this,r),cit(Txt,this,n),cit(xxt,this,i),cit(Axt,this,a),[t,e]=iit(Cxt,this,Ixt).call(this,t,e);var s=cit(bxt,this,[NaN,NaN,NaN,NaN,t,e]);cit(_xt,this,[t,e]),cit(wxt,this,[{line:s,points:lit(_xt,this)}]),lit(yxt,this).set(s,0)}updateProperty(t,e){"stroke-width"===t&&cit(Axt,this,e)}isEmpty(){return!lit(wxt,this)||0===lit(wxt,this).length}isCancellable(){return lit(_xt,this).length<=10}add(t,e){[t,e]=iit(Cxt,this,Ixt).call(this,t,e);var[r,n,i,a]=lit(yxt,this).subarray(2,6),s=t-i,o=e-a;return Math.hypot(lit(Mxt,this)*s,lit(Txt,this)*o)<=2?null:(lit(_xt,this).push(t,e),isNaN(r)?(lit(yxt,this).set([i,a,t,e],2),lit(bxt,this).push(NaN,NaN,NaN,NaN,t,e),{path:{d:this.toSVGPath()}}):(isNaN(lit(yxt,this)[0])&&lit(bxt,this).splice(6,6),lit(yxt,this).set([r,n,i,a,t,e],0),lit(bxt,this).push(...Jyt.createBezierPoints(r,n,i,a,t,e)),{path:{d:this.toSVGPath()}}))}end(t,e){var r=this.add(t,e);return r||(2===lit(_xt,this).length?{path:{d:this.toSVGPath()}}:null)}startNew(t,e,r,n,i){cit(Mxt,this,r),cit(Txt,this,n),cit(xxt,this,i),[t,e]=iit(Cxt,this,Ixt).call(this,t,e);var a=cit(bxt,this,[NaN,NaN,NaN,NaN,t,e]);cit(_xt,this,[t,e]);var s=lit(wxt,this).at(-1);return s&&(s.line=new Float32Array(s.line),s.points=new Float32Array(s.points)),lit(wxt,this).push({line:a,points:lit(_xt,this)}),lit(yxt,this).set(a,0),cit(Sxt,this,0),this.toSVGPath(),null}getLastElement(){return lit(wxt,this).at(-1)}setLastElement(t){return lit(wxt,this)?(lit(wxt,this).push(t),cit(bxt,this,t.line),cit(_xt,this,t.points),cit(Sxt,this,0),{path:{d:this.toSVGPath()}}):lit(Ext,this).setLastElement(t)}removeLastElement(){if(!lit(wxt,this))return lit(Ext,this).removeLastElement();lit(wxt,this).pop(),cit(kxt,this,"");for(var t=0,e=lit(wxt,this).length;t<e;t++){var{line:r,points:n}=lit(wxt,this)[t];cit(bxt,this,r),cit(_xt,this,n),cit(Sxt,this,0),this.toSVGPath()}return{path:{d:lit(kxt,this)}}}toSVGPath(){var t=Jyt.svgRound(lit(bxt,this)[4]),e=Jyt.svgRound(lit(bxt,this)[5]);if(2===lit(_xt,this).length)return cit(kxt,this,"".concat(lit(kxt,this)," M ").concat(t," ").concat(e," Z")),lit(kxt,this);if(lit(_xt,this).length<=6){var r=lit(kxt,this).lastIndexOf("M");cit(kxt,this,"".concat(lit(kxt,this).slice(0,r)," M ").concat(t," ").concat(e)),cit(Sxt,this,6)}if(4===lit(_xt,this).length){var n=Jyt.svgRound(lit(bxt,this)[10]),i=Jyt.svgRound(lit(bxt,this)[11]);return cit(kxt,this,"".concat(lit(kxt,this)," L ").concat(n," ").concat(i)),cit(Sxt,this,12),lit(kxt,this)}var a=[];0===lit(Sxt,this)&&(a.push("M ".concat(t," ").concat(e)),cit(Sxt,this,6));for(var s=lit(Sxt,this),o=lit(bxt,this).length;s<o;s+=6){var[l,h,c,u,d,p]=lit(bxt,this).slice(s,s+6).map(Jyt.svgRound);a.push("C".concat(l," ").concat(h," ").concat(c," ").concat(u," ").concat(d," ").concat(p))}return cit(kxt,this,lit(kxt,this)+a.join(" ")),cit(Sxt,this,lit(bxt,this).length),lit(kxt,this)}getOutlines(t,e,r,n){var i=lit(wxt,this).at(-1);return i.line=new Float32Array(i.line),i.points=new Float32Array(i.points),lit(Ext,this).build(lit(wxt,this),t,e,r,lit(xxt,this),lit(Axt,this),n),cit(yxt,this,null),cit(bxt,this,null),cit(wxt,this,null),cit(kxt,this,null),lit(Ext,this)}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}function Ixt(t,e){return Jyt._normalizePoint(t,e,lit(Mxt,this),lit(Txt,this),lit(xxt,this))}var Rxt=new WeakMap,Oxt=new WeakMap,Lxt=new WeakMap,Dxt=new WeakMap,Fxt=new WeakMap,Nxt=new WeakMap,jxt=new WeakMap,Bxt=new WeakMap,zxt=new WeakMap,Wxt=new WeakSet;class Uxt extends Jyt{constructor(){super(...arguments),dit(this,Wxt),hit(this,Rxt,void 0),hit(this,Oxt,0),hit(this,Lxt,void 0),hit(this,Dxt,void 0),hit(this,Fxt,void 0),hit(this,Nxt,void 0),hit(this,jxt,void 0),hit(this,Bxt,void 0),hit(this,zxt,void 0)}build(t,e,r,n,i,a,s){cit(Fxt,this,e),cit(Nxt,this,r),cit(jxt,this,n),cit(Bxt,this,i),cit(zxt,this,a),cit(Lxt,this,null!=s?s:0),cit(Dxt,this,t),iit(Wxt,this,Yxt).call(this)}setLastElement(t){return lit(Dxt,this).push(t),{path:{d:this.toSVGPath()}}}removeLastElement(){return lit(Dxt,this).pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){var t=[];for(var{line:e}of lit(Dxt,this))if(t.push("M".concat(Jyt.svgRound(e[4])," ").concat(Jyt.svgRound(e[5]))),6!==e.length)if(12!==e.length)for(var r=6,n=e.length;r<n;r+=6){var[i,a,s,o,l,h]=e.subarray(r,r+6).map(Jyt.svgRound);t.push("C".concat(i," ").concat(a," ").concat(s," ").concat(o," ").concat(l," ").concat(h))}else t.push("L".concat(Jyt.svgRound(e[10])," ").concat(Jyt.svgRound(e[11])));else t.push("Z");return t.join("")}serialize(t,e){var r,n,i,a,s,o,l,h,c,[u,d,p,f]=t,g=[],v=[],[m,y,b,w]=iit(Wxt,this,Gxt).call(this);switch(lit(Bxt,this)){case 0:c=Jyt._rescale,r=u,n=d+f,i=p,a=-f,s=u+m*p,o=d+(1-y-w)*f,l=u+(m+b)*p,h=d+(1-y)*f;break;case 90:c=Jyt._rescaleAndSwap,r=u,n=d,i=p,a=f,s=u+y*p,o=d+m*f,l=u+(y+w)*p,h=d+(m+b)*f;break;case 180:c=Jyt._rescale,r=u+p,n=d,i=-p,a=f,s=u+(1-m-b)*p,o=d+y*f,l=u+(1-m)*p,h=d+(y+w)*f;break;case 270:c=Jyt._rescaleAndSwap,r=u+p,n=d+f,i=-p,a=-f,s=u+(1-y-w)*p,o=d+(1-m-b)*f,l=u+(1-y)*p,h=d+(1-m)*f}for(var{line:x,points:A}of lit(Dxt,this))g.push(c(x,r,n,i,a,e?new Array(x.length):null)),v.push(c(A,r,n,i,a,e?new Array(A.length):null));return{lines:g,points:v,rect:[s,o,l,h]}}static deserialize(t,e,r,n,i,a){var s,o,l,h,c,{paths:{lines:u,points:d},rotation:p,thickness:f}=a,g=[];switch(p){case 0:c=Jyt._rescale,s=-t/r,o=e/n+1,l=1/r,h=-1/n;break;case 90:c=Jyt._rescaleAndSwap,s=-e/n,o=-t/r,l=1/n,h=1/r;break;case 180:c=Jyt._rescale,s=t/r+1,o=-e/n,l=-1/r,h=1/n;break;case 270:c=Jyt._rescaleAndSwap,s=e/n+1,o=t/r+1,l=-1/n,h=-1/r}if(!u)for(var v of(u=[],d)){var m=v.length;if(2!==m)if(4!==m){var y=new Float32Array(3*(m-2));u.push(y);var[b,w,x,A]=v.subarray(0,4);y.set([NaN,NaN,NaN,NaN,b,w],0);for(var _=4;_<m;_+=2){var k=v[_],S=v[_+1];y.set(Jyt.createBezierPoints(b,w,x,A,k,S),3*(_-2)),[b,w,x,A]=[x,A,k,S]}}else u.push(new Float32Array([NaN,NaN,NaN,NaN,v[0],v[1],NaN,NaN,NaN,NaN,v[2],v[3]]));else u.push(new Float32Array([NaN,NaN,NaN,NaN,v[0],v[1]]))}for(var E=0,M=u.length;E<M;E++)g.push({line:c(u[E].map((t=>null!=t?t:NaN)),s,o,l,h),points:c(d[E].map((t=>null!=t?t:NaN)),s,o,l,h)});var T=new Uxt;return T.build(g,r,n,1,p,f,i),T}get box(){return lit(Rxt,this)}updateProperty(t,e){return"stroke-width"===t?iit(Wxt,this,Vxt).call(this,e):null}updateParentDimensions(t,e){var[r,n]=t,[i,a]=iit(Wxt,this,Hxt).call(this);cit(Fxt,this,r),cit(Nxt,this,n),cit(jxt,this,e);var[s,o]=iit(Wxt,this,Hxt).call(this),l=s-i,h=o-a,c=lit(Rxt,this);return c[0]-=l,c[1]-=h,c[2]+=2*l,c[3]+=2*h,c}updateRotation(t){return cit(Oxt,this,t),{path:{transform:this.rotationTransform}}}get viewBox(){return lit(Rxt,this).map(Jyt.svgRound).join(" ")}get defaultProperties(){var[t,e]=lit(Rxt,this);return{root:{viewBox:this.viewBox},path:{"transform-origin":"".concat(Jyt.svgRound(t)," ").concat(Jyt.svgRound(e))}}}get rotationTransform(){var[,,t,e]=lit(Rxt,this),r=0,n=0,i=0,a=0,s=0,o=0;switch(lit(Oxt,this)){case 90:n=e/t,i=-t/e,s=t;break;case 180:r=-1,a=-1,s=t,o=e;break;case 270:n=-e/t,i=t/e,o=e;break;default:return""}return"matrix(".concat(r," ").concat(n," ").concat(i," ").concat(a," ").concat(Jyt.svgRound(s)," ").concat(Jyt.svgRound(o),")")}getPathResizingSVGProperties(t){var[e,r,n,i]=t,[a,s]=iit(Wxt,this,Hxt).call(this),[o,l,h,c]=lit(Rxt,this);if(Math.abs(h-a)<=Jyt.PRECISION||Math.abs(c-s)<=Jyt.PRECISION){var u=e+n/2-(o+h/2),d=r+i/2-(l+c/2);return{path:{"transform-origin":"".concat(Jyt.svgRound(e)," ").concat(Jyt.svgRound(r)),transform:"".concat(this.rotationTransform," translate(").concat(u," ").concat(d,")")}}}var p=(n-2*a)/(h-2*a),f=(i-2*s)/(c-2*s),g=h/n,v=c/i;return{path:{"transform-origin":"".concat(Jyt.svgRound(o)," ").concat(Jyt.svgRound(l)),transform:"".concat(this.rotationTransform," scale(").concat(g," ").concat(v,") ")+"translate(".concat(Jyt.svgRound(a)," ").concat(Jyt.svgRound(s),") scale(").concat(p," ").concat(f,") ")+"translate(".concat(Jyt.svgRound(-a)," ").concat(Jyt.svgRound(-s),")")}}}getPathResizedSVGProperties(t){var[e,r,n,i]=t,[a,s]=iit(Wxt,this,Hxt).call(this),o=lit(Rxt,this),[l,h,c,u]=o;if(o[0]=e,o[1]=r,o[2]=n,o[3]=i,Math.abs(c-a)<=Jyt.PRECISION||Math.abs(u-s)<=Jyt.PRECISION){var d=e+n/2-(l+c/2),p=r+i/2-(h+u/2);for(var{line:f,points:g}of lit(Dxt,this))Jyt._translate(f,d,p,f),Jyt._translate(g,d,p,g);return{root:{viewBox:this.viewBox},path:{"transform-origin":"".concat(Jyt.svgRound(e)," ").concat(Jyt.svgRound(r)),transform:this.rotationTransform||null,d:this.toSVGPath()}}}var v=(n-2*a)/(c-2*a),m=(i-2*s)/(u-2*s),y=-v*(l+a)+e+a,b=-m*(h+s)+r+s;if(1!==v||1!==m||0!==y||0!==b)for(var{line:w,points:x}of lit(Dxt,this))Jyt._rescale(w,y,b,v,m,w),Jyt._rescale(x,y,b,v,m,x);return{root:{viewBox:this.viewBox},path:{"transform-origin":"".concat(Jyt.svgRound(e)," ").concat(Jyt.svgRound(r)),transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties(t,e){var[r,n]=t,[i,a]=e,s=lit(Rxt,this),o=r-s[0],l=n-s[1];if(lit(Fxt,this)===i&&lit(Nxt,this)===a)for(var{line:h,points:c}of lit(Dxt,this))Jyt._translate(h,o,l,h),Jyt._translate(c,o,l,c);else{var u=lit(Fxt,this)/i,d=lit(Nxt,this)/a;for(var{line:p,points:f}of(cit(Fxt,this,i),cit(Nxt,this,a),lit(Dxt,this)))Jyt._rescale(p,o,l,u,d,p),Jyt._rescale(f,o,l,u,d,f);s[2]*=u,s[3]*=d}return s[0]=r,s[1]=n,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":"".concat(Jyt.svgRound(r)," ").concat(Jyt.svgRound(n))}}}get defaultSVGProperties(){var t=lit(Rxt,this);return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":"".concat(Jyt.svgRound(t[0])," ").concat(Jyt.svgRound(t[1])),transform:this.rotationTransform||null},bbox:t}}}function Hxt(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:lit(zxt,this),e=lit(Lxt,this)+t/2*lit(jxt,this);return lit(Bxt,this)%180==0?[e/lit(Fxt,this),e/lit(Nxt,this)]:[e/lit(Nxt,this),e/lit(Fxt,this)]}function Gxt(){var[t,e,r,n]=lit(Rxt,this),[i,a]=iit(Wxt,this,Hxt).call(this,0);return[t+i,e+a,r-2*i,n-2*a]}function Yxt(){var t=cit(Rxt,this,new Float32Array([1/0,1/0,-1/0,-1/0]));for(var{line:e}of lit(Dxt,this))if(e.length<=12)for(var r=4,n=e.length;r<n;r+=6){var[i,a]=e.subarray(r,r+2);t[0]=Math.min(t[0],i),t[1]=Math.min(t[1],a),t[2]=Math.max(t[2],i),t[3]=Math.max(t[3],a)}else for(var s=e[4],o=e[5],l=6,h=e.length;l<h;l+=6){var[c,u,d,p,f,g]=e.subarray(l,l+6);Ylt.bezierBoundingBox(s,o,c,u,d,p,f,g,t),s=f,o=g}var[v,m]=iit(Wxt,this,Hxt).call(this);t[0]=Math.min(1,Math.max(0,t[0]-v)),t[1]=Math.min(1,Math.max(0,t[1]-m)),t[2]=Math.min(1,Math.max(0,t[2]+v)),t[3]=Math.min(1,Math.max(0,t[3]+m)),t[2]-=t[0],t[3]-=t[1]}function Vxt(t){var[e,r]=iit(Wxt,this,Hxt).call(this);cit(zxt,this,t);var[n,i]=iit(Wxt,this,Hxt).call(this),[a,s]=[n-e,i-r],o=lit(Rxt,this);return o[0]-=a,o[1]-=s,o[2]+=2*a,o[3]+=2*s,o}var qxt=new WeakMap;class Xxt extends Jwt{constructor(t){super(),hit(this,qxt,void 0),cit(qxt,this,t),super.updateProperties({fill:"none",stroke:kdt._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(t,e){"stroke-width"===t&&(null!=e||(e=this["stroke-width"]),e*=lit(qxt,this).realScale),super.updateSVGProperty(t,e)}clone(){var t=new Xxt(lit(qxt,this));return t.updateAll(this),t}}var $xt=new WeakSet;class Kxt extends rxt{constructor(t){super(git(git({},t),{},{name:"inkEditor"})),dit(this,$xt),this._willKeepAspectRatio=!0}static initialize(t,e){kdt.initialize(t,e),this._defaultDrawingOptions=new Xxt(e.viewParameters)}static getDefaultDrawingOptions(t){var e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!0}static get typesMap(){return Ilt(this,"typesMap",new Map([[Uot.INK_THICKNESS,"stroke-width"],[Uot.INK_COLOR,"stroke"],[Uot.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(t,e,r,n,i){return new Pxt(t,e,r,n,i,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(t,e,r,n,i,a){return Uxt.deserialize(t,e,r,n,i,a)}static deserialize(t,e,r){var n=()=>super.deserialize,i=this;return sit((function*(){var a=null;if(t instanceof gyt){var{data:{inkLists:s,rect:o,rotation:l,id:h,color:c,opacity:u,borderStyle:{rawWidth:d},popupRef:p},parent:{page:{pageNumber:f}}}=t;a=t={annotationType:Wot.INK,color:Array.from(c),thickness:d,opacity:u,paths:{points:s},boxes:null,pageIndex:f-1,rect:o.slice(0),rotation:l,id:h,deleted:!1,popupRef:p}}var g=yield n().call(i,t,e,r);return g.annotationElementId=t.id||null,g._initialData=a,g}))()}onScaleChanging(){if(this.parent){super.onScaleChanging();var{_drawId:t,_drawingOptions:e,parent:r}=this;e.updateSVGProperty("stroke-width"),r.drawLayer.updateProperties(t,e.toSVGProperties())}}static onScaleChangingWhenDrawing(){var t=this._currentParent;t&&(super.onScaleChangingWhenDrawing(),this._defaultDrawingOptions.updateSVGProperty("stroke-width"),t.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}createDrawingOptions(t){var{color:e,thickness:r,opacity:n}=t;this._drawingOptions=Kxt.getDefaultDrawingOptions({stroke:Ylt.makeHexColor(...e),"stroke-width":r,"stroke-opacity":n})}serialize(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();var{lines:e,points:r,rect:n}=this.serializeDraw(t),{_drawingOptions:{stroke:i,"stroke-opacity":a,"stroke-width":s}}=this,o={annotationType:Wot.INK,color:kdt._colorManager.convert(i),opacity:a,thickness:s,paths:{lines:e,points:r},pageIndex:this.pageIndex,rect:n,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return t?o:this.annotationElementId&&!iit($xt,this,Qxt).call(this,o)?null:(o.id=this.annotationElementId,o)}renderAnnotationElement(t){var{points:e,rect:r}=this.serializeDraw(!1);return t.updateEdited({rect:r,thickness:this._drawingOptions["stroke-width"],points:e}),null}}function Qxt(t){var{color:e,thickness:r,opacity:n,pageIndex:i}=this._initialData;return this._hasBeenMoved||this._hasBeenResized||t.color.some(((t,r)=>t!==e[r]))||t.thickness!==r||t.opacity!==n||t.pageIndex!==i}pit(Kxt,"_type","ink"),pit(Kxt,"_editorType",Wot.INK),pit(Kxt,"_defaultDrawingOptions",null);var Jxt=new WeakMap,Zxt=new WeakMap,tAt=new WeakMap,eAt=new WeakMap,rAt=new WeakMap,nAt=new WeakMap,iAt=new WeakMap,aAt=new WeakMap,sAt=new WeakMap,oAt=new WeakMap,lAt=new WeakSet;class hAt extends kdt{constructor(t){super(git(git({},t),{},{name:"stampEditor"})),dit(this,lAt),hit(this,Jxt,null),hit(this,Zxt,null),hit(this,tAt,null),hit(this,eAt,null),hit(this,rAt,null),hit(this,nAt,""),hit(this,iAt,null),hit(this,aAt,null),hit(this,sAt,!1),hit(this,oAt,!1),cit(eAt,this,t.bitmapUrl),cit(rAt,this,t.bitmapFile)}static initialize(t,e){kdt.initialize(t,e)}static get supportedTypes(){return Ilt(this,"supportedTypes",["apng","avif","bmp","gif","jpeg","png","svg+xml","webp","x-icon"].map((t=>"image/".concat(t))))}static get supportedTypesStr(){return Ilt(this,"supportedTypesStr",this.supportedTypes.join(","))}static isHandlingMimeForPasting(t){return this.supportedTypes.includes(t)}static paste(t,e){e.pasteEditor(Wot.STAMP,{bitmapFile:t.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){var t;return{type:"stamp",hasAltText:!(null===(t=this.altTextData)||void 0===t||!t.altText)}}static computeTelemetryFinalData(t){var e,r,n=t.get("hasAltText");return{hasAltText:null!==(e=n.get(!0))&&void 0!==e?e:0,hasNoAltText:null!==(r=n.get(!1))&&void 0!==r?r:0}}mlGuessAltText(){var t=arguments,e=this;return sit((function*(){var r=t.length>0&&void 0!==t[0]?t[0]:null,n=!(t.length>1&&void 0!==t[1])||t[1];if(e.hasAltTextData())return null;var{mlManager:i}=e._uiManager;if(!i)throw new Error("No ML.");if(!(yield i.isEnabledFor("altText")))throw new Error("ML isn't enabled for alt text.");var{data:a,width:s,height:o}=r||e.copyCanvas(null,null,!0).imageData,l=yield i.guess({name:"altText",request:{data:a,width:s,height:o,channels:a.length/(s*o)}});if(!l)throw new Error("No response from the AI service.");if(l.error)throw new Error("Error from the AI service.");if(l.cancel)return null;if(!l.output)throw new Error("No valid response from the AI service.");var h=l.output;return yield e.setGuessedAltText(h),n&&!e.hasAltTextData()&&(e.altTextData={alt:h,decorative:!1}),h}))()}remove(){var t;lit(Zxt,this)&&(cit(Jxt,this,null),this._uiManager.imageManager.deleteId(lit(Zxt,this)),null===(t=lit(iAt,this))||void 0===t||t.remove(),cit(iAt,this,null),lit(aAt,this)&&(clearTimeout(lit(aAt,this)),cit(aAt,this,null)));super.remove()}rebuild(){this.parent?(super.rebuild(),null!==this.div&&(lit(Zxt,this)&&null===lit(iAt,this)&&iit(lAt,this,dAt).call(this),this.isAttachedToDOM||this.parent.add(this))):lit(Zxt,this)&&iit(lAt,this,dAt).call(this)}onceAdded(t){this._isDraggable=!0,t&&this.div.focus()}isEmpty(){return!(lit(tAt,this)||lit(Jxt,this)||lit(eAt,this)||lit(rAt,this)||lit(Zxt,this))}get isResizable(){return!0}render(){if(this.div)return this.div;var t,e;if(this.width&&(t=this.x,e=this.y),super.render(),this.div.hidden=!0,this.div.setAttribute("role","figure"),this.addAltTextButton(),lit(Jxt,this)?iit(lAt,this,pAt).call(this):iit(lAt,this,dAt).call(this),this.width&&!this.annotationElementId){var[r,n]=this.parentDimensions;this.setAt(t*r,e*n,this.width*r,this.height*n)}return this._uiManager.addShouldRescale(this),this.div}_onResized(){this.onScaleChanging()}onScaleChanging(){if(this.parent){null!==lit(aAt,this)&&clearTimeout(lit(aAt,this));cit(aAt,this,setTimeout((()=>{cit(aAt,this,null),iit(lAt,this,gAt).call(this)}),200))}}copyCanvas(t,e){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];t||(t=224);var{width:n,height:i}=lit(Jxt,this),a=new bht,s=lit(Jxt,this),o=n,l=i,h=null;if(e){var c,u;if(n>e||i>e){var d=Math.min(e/n,e/i);o=Math.floor(n*d),l=Math.floor(i*d)}var p=(h=document.createElement("canvas")).width=Math.ceil(o*a.sx),f=h.height=Math.ceil(l*a.sy);lit(sAt,this)||(s=iit(lAt,this,fAt).call(this,p,f));var g=h.getContext("2d");g.filter=this._uiManager.hcmFilter;var v="white",m="#cfcfd8";"none"!==this._uiManager.hcmFilter?m="black":null!==(c=(u=window).matchMedia)&&void 0!==c&&c.call(u,"(prefers-color-scheme: dark)").matches&&(v="#8f8f9d",m="#42414d");var y=15*a.sx,b=15*a.sy,w=new OffscreenCanvas(2*y,2*b),x=w.getContext("2d");x.fillStyle=v,x.fillRect(0,0,2*y,2*b),x.fillStyle=m,x.fillRect(0,0,y,b),x.fillRect(y,b,y,b),g.fillStyle=g.createPattern(w,"repeat"),g.fillRect(0,0,p,f),g.drawImage(s,0,0,s.width,s.height,0,0,p,f)}var A=null;if(r){var _,k;if(a.symmetric&&s.width<t&&s.height<t)_=s.width,k=s.height;else if(s=lit(Jxt,this),n>t||i>t){var S=Math.min(t/n,t/i);_=Math.floor(n*S),k=Math.floor(i*S),lit(sAt,this)||(s=iit(lAt,this,fAt).call(this,_,k))}var E=new OffscreenCanvas(_,k).getContext("2d",{willReadFrequently:!0});E.drawImage(s,0,0,s.width,s.height,0,0,_,k),A={width:_,height:k,data:E.getImageData(0,0,_,k).data}}return{canvas:h,width:o,height:l,imageData:A}}getImageForAltText(){return lit(iAt,this)}static deserialize(t,e,r){var n=()=>super.deserialize,i=this;return sit((function*(){var a=null;if(t instanceof xyt){var s,{data:{rect:o,rotation:l,id:h,structParent:c,popupRef:u},container:d,parent:{page:{pageNumber:p}}}=t,f=d.querySelector("canvas"),g=r.imageManager.getFromCanvas(d.id,f);f.remove();var v=(null===(s=yield e._structTree.getAriaAttributes("".concat(Qlt).concat(h)))||void 0===s?void 0:s.get("aria-label"))||"";a=t={annotationType:Wot.STAMP,bitmapId:g.id,bitmap:g.bitmap,pageIndex:p-1,rect:o.slice(0),rotation:l,id:h,deleted:!1,accessibilityData:{decorative:!1,altText:v},isSvg:!1,structParent:c,popupRef:u}}var m=yield n().call(i,t,e,r),{rect:y,bitmap:b,bitmapUrl:w,bitmapId:x,isSvg:A,accessibilityData:_}=t;x&&r.imageManager.isValidId(x)?(cit(Zxt,m,x),b&&cit(Jxt,m,b)):cit(eAt,m,w),cit(sAt,m,A);var[k,S]=m.pageDimensions;return m.width=(y[2]-y[0])/k,m.height=(y[3]-y[1])/S,m.annotationElementId=t.id||null,_&&(m.altTextData=_),m._initialData=a,cit(oAt,m,!!a),m}))()}serialize(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();var r={annotationType:Wot.STAMP,bitmapId:lit(Zxt,this),pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:lit(sAt,this),structTreeParentId:this._structTreeParentId};if(t)return r.bitmapUrl=iit(lAt,this,vAt).call(this,!0),r.accessibilityData=this.serializeAltText(!0),r;var{decorative:n,altText:i}=this.serializeAltText(!1);if(!n&&i&&(r.accessibilityData={type:"Figure",alt:i}),this.annotationElementId){var a,s=iit(lAt,this,mAt).call(this,r);if(s.isSame)return null;if(s.isSameAltText)delete r.accessibilityData;else r.accessibilityData.structParent=null!==(a=this._initialData.structParent)&&void 0!==a?a:-1}if(r.id=this.annotationElementId,null===e)return r;e.stamps||(e.stamps=new Map);var o=lit(sAt,this)?(r.rect[2]-r.rect[0])*(r.rect[3]-r.rect[1]):null;if(e.stamps.has(lit(Zxt,this))){if(lit(sAt,this)){var l=e.stamps.get(lit(Zxt,this));o>l.area&&(l.area=o,l.serialized.bitmap.close(),l.serialized.bitmap=iit(lAt,this,vAt).call(this,!1))}}else e.stamps.set(lit(Zxt,this),{area:o,serialized:r}),r.bitmap=iit(lAt,this,vAt).call(this,!1);return r}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}}function cAt(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];t?(cit(Jxt,this,t.bitmap),e||(cit(Zxt,this,t.id),cit(sAt,this,t.isSvg)),t.file&&cit(nAt,this,t.file.name),iit(lAt,this,pAt).call(this)):this.remove()}function uAt(){if(cit(tAt,this,null),this._uiManager.enableWaiting(!1),lit(iAt,this)){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&lit(Jxt,this))return this._editToolbar.hide(),void this._uiManager.editAltText(this,!0);if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&lit(Jxt,this)){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch(t){}}this.div.focus()}}function dAt(){var t=this;if(lit(Zxt,this))return this._uiManager.enableWaiting(!0),void this._uiManager.imageManager.getFromId(lit(Zxt,this)).then((t=>iit(lAt,this,cAt).call(this,t,!0))).finally((()=>iit(lAt,this,uAt).call(this)));if(lit(eAt,this)){var e=lit(eAt,this);return cit(eAt,this,null),this._uiManager.enableWaiting(!0),void cit(tAt,this,this._uiManager.imageManager.getFromUrl(e).then((t=>iit(lAt,this,cAt).call(this,t))).finally((()=>iit(lAt,this,uAt).call(this))))}if(lit(rAt,this)){var r=lit(rAt,this);return cit(rAt,this,null),this._uiManager.enableWaiting(!0),void cit(tAt,this,this._uiManager.imageManager.getFromFile(r).then((t=>iit(lAt,this,cAt).call(this,t))).finally((()=>iit(lAt,this,uAt).call(this))))}var n=document.createElement("input");n.type="file",n.accept=Aot.supportedTypesStr;var i=this._uiManager._signal;cit(tAt,this,new Promise((e=>{n.addEventListener("change",sit((function*(){if(n.files&&0!==n.files.length){t._uiManager.enableWaiting(!0);var r=yield t._uiManager.imageManager.getFromFile(n.files[0]);t._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:t._uiManager.useNewAltTextFlow}}),iit(lAt,t,cAt).call(t,r)}else t.remove();e()})),{signal:i}),n.addEventListener("cancel",(()=>{this.remove(),e()}),{signal:i})})).finally((()=>iit(lAt,this,uAt).call(this)))),n.click()}function pAt(){var t,{div:e}=this,{width:r,height:n}=lit(Jxt,this),[i,a]=this.pageDimensions,s=.75;if(this.width)r=this.width*i,n=this.height*a;else if(r>s*i||n>s*a){var o=Math.min(s*i/r,s*a/n);r*=o,n*=o}var[l,h]=this.parentDimensions;this.setDims(r*l/i,n*h/a),this._uiManager.enableWaiting(!1);var c=cit(iAt,this,document.createElement("canvas"));c.setAttribute("role","img"),this.addContainer(c),this.width=r/i,this.height=n/a,null!==(t=this._initialOptions)&&void 0!==t&&t.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&!this.annotationElementId||(e.hidden=!1),iit(lAt,this,gAt).call(this),lit(oAt,this)||(this.parent.addUndoableEditor(this),cit(oAt,this,!0)),this._reportTelemetry({action:"inserted_image"}),lit(nAt,this)&&c.setAttribute("aria-label",lit(nAt,this))}function fAt(t,e){for(var{width:r,height:n}=lit(Jxt,this),i=r,a=n,s=lit(Jxt,this);i>2*t||a>2*e;){var o=i,l=a;i>2*t&&(i=i>=16384?Math.floor(i/2)-1:Math.ceil(i/2)),a>2*e&&(a=a>=16384?Math.floor(a/2)-1:Math.ceil(a/2));var h=new OffscreenCanvas(i,a);h.getContext("2d").drawImage(s,0,0,o,l,0,0,i,a),s=h.transferToImageBitmap()}return s}function gAt(){var[t,e]=this.parentDimensions,{width:r,height:n}=this,i=new bht,a=Math.ceil(r*t*i.sx),s=Math.ceil(n*e*i.sy),o=lit(iAt,this);if(o&&(o.width!==a||o.height!==s)){o.width=a,o.height=s;var l=lit(sAt,this)?lit(Jxt,this):iit(lAt,this,fAt).call(this,a,s),h=o.getContext("2d");h.filter=this._uiManager.hcmFilter,h.drawImage(l,0,0,l.width,l.height,0,0,a,s)}}function vAt(t){if(t){if(lit(sAt,this)){var e=this._uiManager.imageManager.getSvgUrl(lit(Zxt,this));if(e)return e}var r=document.createElement("canvas");return({width:r.width,height:r.height}=lit(Jxt,this)),r.getContext("2d").drawImage(lit(Jxt,this),0,0),r.toDataURL()}if(lit(sAt,this)){var[n,i]=this.pageDimensions,a=Math.round(this.width*n*Zlt.PDF_TO_CSS_UNITS),s=Math.round(this.height*i*Zlt.PDF_TO_CSS_UNITS),o=new OffscreenCanvas(a,s);return o.getContext("2d").drawImage(lit(Jxt,this),0,0,lit(Jxt,this).width,lit(Jxt,this).height,0,0,a,s),o.transferToImageBitmap()}return structuredClone(lit(Jxt,this))}function mAt(t){var e,{pageIndex:r,accessibilityData:{altText:n}}=this._initialData,i=t.pageIndex===r,a=((null===(e=t.accessibilityData)||void 0===e?void 0:e.alt)||"")===n;return{isSame:!this._hasBeenMoved&&!this._hasBeenResized&&i&&a,isSameAltText:a}}Aot=hAt,pit(hAt,"_type","stamp"),pit(hAt,"_editorType",Wot.STAMP);var yAt=new WeakMap,bAt=new WeakMap,wAt=new WeakMap,xAt=new WeakMap,AAt=new WeakMap,_At=new WeakMap,kAt=new WeakMap,SAt=new WeakMap,EAt=new WeakMap,MAt=new WeakMap,TAt=new WeakMap,CAt=new WeakMap,PAt=new WeakMap,IAt=new WeakMap,RAt=new WeakSet;class OAt{constructor(t){var{uiManager:e,pageIndex:r,div:n,structTreeLayer:i,accessibilityManager:a,annotationLayer:s,drawLayer:o,textLayer:l,viewport:h,l10n:c}=t;dit(this,RAt),hit(this,yAt,void 0),hit(this,bAt,!1),hit(this,wAt,null),hit(this,xAt,null),hit(this,AAt,null),hit(this,_At,new Map),hit(this,kAt,!1),hit(this,SAt,!1),hit(this,EAt,!1),hit(this,MAt,null),hit(this,TAt,null),hit(this,CAt,null),hit(this,PAt,null),hit(this,IAt,void 0);var u=[...BAt._.values()];if(!OAt._initialized)for(var d of(OAt._initialized=!0,u))d.initialize(c,e);e.registerEditorTypes(u),cit(IAt,this,e),this.pageIndex=r,this.div=n,cit(yAt,this,a),cit(wAt,this,s),this.viewport=h,cit(CAt,this,l),this.drawLayer=o,this._structTree=i,lit(IAt,this).addLayer(this)}get isEmpty(){return 0===lit(_At,this).size}get isInvisible(){return this.isEmpty&&lit(IAt,this).getMode()===Wot.NONE}updateToolbar(t){lit(IAt,this).updateToolbar(t)}updateMode(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:lit(IAt,this).getMode();switch(iit(RAt,this,jAt).call(this),t){case Wot.NONE:return this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),void this.disableClick();case Wot.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case Wot.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);var{classList:e}=this.div;for(var r of BAt._.values())e.toggle("".concat(r._type,"Editing"),t===r._editorType);this.div.hidden=!1}hasTextLayer(t){var e;return t===(null===(e=lit(CAt,this))||void 0===e?void 0:e.div)}setEditingState(t){lit(IAt,this).setEditingState(t)}addCommands(t){lit(IAt,this).addCommands(t)}cleanUndoStack(t){lit(IAt,this).cleanUndoStack(t)}toggleDrawing(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.div.classList.toggle("drawing",!t)}togglePointerEvents(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(){var t,e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];null===(t=lit(wAt,this))||void 0===t||t.div.classList.toggle("disabled",!e)}enable(){var t=this;return sit((function*(){cit(EAt,t,!0),t.div.tabIndex=0,t.togglePointerEvents(!0);var e=new Set;for(var r of lit(_At,t).values())r.enableEditing(),r.show(!0),r.annotationElementId&&(lit(IAt,t).removeChangedExistingAnnotation(r),e.add(r.annotationElementId));if(lit(wAt,t)){var n=lit(wAt,t).getEditableAnnotations();for(var i of n)if(i.hide(),!lit(IAt,t).isDeletedAnnotationElement(i.data.id)&&!e.has(i.data.id)){var a=yield t.deserialize(i);a&&(t.addOrRebuild(a),a.enableEditing())}cit(EAt,t,!1)}else cit(EAt,t,!1)}))()}disable(){cit(SAt,this,!0),this.div.tabIndex=-1,this.togglePointerEvents(!1);var t=new Map,e=new Map;for(var r of lit(_At,this).values()){var n;r.disableEditing(),r.annotationElementId&&(null===r.serialize()?(e.set(r.annotationElementId,r),null===(n=this.getEditableAnnotation(r.annotationElementId))||void 0===n||n.show(),r.remove()):t.set(r.annotationElementId,r))}if(lit(wAt,this)){var i=lit(wAt,this).getEditableAnnotations();for(var a of i){var{id:s}=a.data;if(!lit(IAt,this).isDeletedAnnotationElement(s)){var o=e.get(s);o?(o.resetAnnotationElement(a),o.show(!1),a.show()):((o=t.get(s))&&(lit(IAt,this).addChangedExistingAnnotation(o),o.renderAnnotationElement(a)&&o.show(!1)),a.show())}}}iit(RAt,this,jAt).call(this),this.isEmpty&&(this.div.hidden=!0);var{classList:l}=this.div;for(var h of BAt._.values())l.remove("".concat(h._type,"Editing"));this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),cit(SAt,this,!1)}getEditableAnnotation(t){var e;return(null===(e=lit(wAt,this))||void 0===e?void 0:e.getEditableAnnotation(t))||null}setActiveEditor(t){lit(IAt,this).getActive()!==t&&lit(IAt,this).setActiveEditor(t)}enableTextSelection(){var t;if(this.div.tabIndex=-1,null!==(t=lit(CAt,this))&&void 0!==t&&t.div&&!lit(PAt,this)){cit(PAt,this,new AbortController);var e=lit(IAt,this).combinedSignal(lit(PAt,this));lit(CAt,this).div.addEventListener("pointerdown",iit(RAt,this,LAt).bind(this),{signal:e}),lit(CAt,this).div.classList.add("highlighting")}}disableTextSelection(){var t;this.div.tabIndex=0,null!==(t=lit(CAt,this))&&void 0!==t&&t.div&&lit(PAt,this)&&(lit(PAt,this).abort(),cit(PAt,this,null),lit(CAt,this).div.classList.remove("highlighting"))}enableClick(){if(!lit(xAt,this)){cit(xAt,this,new AbortController);var t=lit(IAt,this).combinedSignal(lit(xAt,this));this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:t});var e=this.pointerup.bind(this);this.div.addEventListener("pointerup",e,{signal:t}),this.div.addEventListener("pointercancel",e,{signal:t})}}disableClick(){var t;null===(t=lit(xAt,this))||void 0===t||t.abort(),cit(xAt,this,null)}attach(t){lit(_At,this).set(t.id,t);var{annotationElementId:e}=t;e&&lit(IAt,this).isDeletedAnnotationElement(e)&&lit(IAt,this).removeDeletedAnnotationElement(t)}detach(t){var e;lit(_At,this).delete(t.id),null===(e=lit(yAt,this))||void 0===e||e.removePointerInTextLayer(t.contentDiv),!lit(SAt,this)&&t.annotationElementId&&lit(IAt,this).addDeletedAnnotationElement(t)}remove(t){this.detach(t),lit(IAt,this).removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){var e;t.parent!==this&&(t.parent&&t.annotationElementId&&(lit(IAt,this).addDeletedAnnotationElement(t.annotationElementId),kdt.deleteAnnotationElement(t),t.annotationElementId=null),this.attach(t),null===(e=t.parent)||void 0===e||e.detach(t),t.setParent(this),t.div&&t.isAttachedToDOM&&(t.div.remove(),this.div.append(t.div)))}add(t){if(t.parent!==this||!t.isAttachedToDOM){if(this.changeParent(t),lit(IAt,this).addEditor(t),this.attach(t),!t.isAttachedToDOM){var e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(!lit(EAt,this)),lit(IAt,this).addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){var e;if(t.isAttachedToDOM){var{activeElement:r}=document;t.div.contains(r)&&!lit(AAt,this)&&(t._focusEventsAllowed=!1,cit(AAt,this,setTimeout((()=>{cit(AAt,this,null),t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",(()=>{t._focusEventsAllowed=!0}),{once:!0,signal:lit(IAt,this)._signal}),r.focus())}),0))),t._structTreeParentId=null===(e=lit(yAt,this))||void 0===e?void 0:e.moveElementInDOM(this.div,t.div,t.contentDiv,!0)}}addOrRebuild(t){t.needsToBeRebuilt()?(t.parent||(t.parent=this),t.rebuild(),t.show()):this.add(t)}addUndoableEditor(t){this.addCommands({cmd:()=>t._uiManager.rebuild(t),undo:()=>{t.remove()},mustExec:!1})}getNextId(){return lit(IAt,this).getId()}combinedSignal(t){return lit(IAt,this).combinedSignal(t)}canCreateNewEmptyEditor(){var t;return null===(t=uit(RAt,this,DAt))||void 0===t?void 0:t.canCreateNewEmptyEditor()}pasteEditor(t,e){lit(IAt,this).updateToolbar(t),lit(IAt,this).updateMode(t);var{offsetX:r,offsetY:n}=iit(RAt,this,NAt).call(this),i=this.getNextId(),a=iit(RAt,this,FAt).call(this,git({parent:this,id:i,x:r,y:n,uiManager:lit(IAt,this),isCentered:!0},e));a&&this.add(a)}deserialize(t){var e=this;return sit((function*(){var r,n;return(yield null===(r=BAt._.get(null!==(n=t.annotationType)&&void 0!==n?n:t.annotationEditorType))||void 0===r?void 0:r.deserialize(t,e,lit(IAt,e)))||null}))()}createAndAddNewEditor(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=this.getNextId(),i=iit(RAt,this,FAt).call(this,git({parent:this,id:n,x:t.offsetX,y:t.offsetY,uiManager:lit(IAt,this),isCentered:e},r));return i&&this.add(i),i}addNewEditor(){this.createAndAddNewEditor(iit(RAt,this,NAt).call(this),!0)}setSelected(t){lit(IAt,this).setSelected(t)}toggleSelected(t){lit(IAt,this).toggleSelected(t)}unselect(t){lit(IAt,this).unselect(t)}pointerup(t){var e,{isMac:r}=Hlt.platform;0!==t.button||t.ctrlKey&&r||t.target===this.div&&lit(kAt,this)&&(cit(kAt,this,!1),null!==(e=uit(RAt,this,DAt))&&void 0!==e&&e.isDrawer&&uit(RAt,this,DAt).supportMultipleDrawings||(lit(bAt,this)?lit(IAt,this).getMode()!==Wot.STAMP?this.createAndAddNewEditor(t,!1):lit(IAt,this).unselectAll():cit(bAt,this,!0)))}pointerdown(t){var e;if(lit(IAt,this).getMode()===Wot.HIGHLIGHT&&this.enableTextSelection(),lit(kAt,this))cit(kAt,this,!1);else{var{isMac:r}=Hlt.platform;if(!(0!==t.button||t.ctrlKey&&r)&&t.target===this.div)if(cit(kAt,this,!0),null!==(e=uit(RAt,this,DAt))&&void 0!==e&&e.isDrawer)this.startDrawingSession(t);else{var n=lit(IAt,this).getActive();cit(bAt,this,!n||n.isEmpty())}}}startDrawingSession(t){if(this.div.focus(),lit(MAt,this))uit(RAt,this,DAt).startDrawing(this,lit(IAt,this),!1,t);else{lit(IAt,this).setCurrentDrawingSession(this),cit(MAt,this,new AbortController);var e=lit(IAt,this).combinedSignal(lit(MAt,this));this.div.addEventListener("blur",(t=>{var{relatedTarget:e}=t;e&&!this.div.contains(e)&&(cit(TAt,this,null),this.commitOrRemove())}),{signal:e}),uit(RAt,this,DAt).startDrawing(this,lit(IAt,this),!1,t)}}pause(t){if(t){var{activeElement:e}=document;this.div.contains(e)&&cit(TAt,this,e)}else lit(TAt,this)&&setTimeout((()=>{var t;null===(t=lit(TAt,this))||void 0===t||t.focus(),cit(TAt,this,null)}),0)}endDrawingSession(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return lit(MAt,this)?(lit(IAt,this).setCurrentDrawingSession(null),lit(MAt,this).abort(),cit(MAt,this,null),cit(TAt,this,null),uit(RAt,this,DAt).endDrawing(t)):null}findNewParent(t,e,r){var n=lit(IAt,this).findParent(e,r);return null!==n&&n!==this&&(n.changeParent(t),!0)}commitOrRemove(){return!!lit(MAt,this)&&(this.endDrawingSession(),!0)}onScaleChanging(){lit(MAt,this)&&uit(RAt,this,DAt).onScaleChangingWhenDrawing(this)}destroy(){var t;for(var e of(this.commitOrRemove(),(null===(t=lit(IAt,this).getActive())||void 0===t?void 0:t.parent)===this&&(lit(IAt,this).commitOrRemove(),lit(IAt,this).setActiveEditor(null)),lit(AAt,this)&&(clearTimeout(lit(AAt,this)),cit(AAt,this,null)),lit(_At,this).values())){var r;null===(r=lit(yAt,this))||void 0===r||r.removePointerInTextLayer(e.contentDiv),e.setParent(null),e.isAttachedToDOM=!1,e.div.remove()}this.div=null,lit(_At,this).clear(),lit(IAt,this).removeLayer(this)}render(t){var{viewport:e}=t;for(var r of(this.viewport=e,yht(this.div,e),lit(IAt,this).getEditors(this.pageIndex)))this.add(r),r.rebuild();this.updateMode()}update(t){var{viewport:e}=t;lit(IAt,this).commitOrRemove(),iit(RAt,this,jAt).call(this);var r=this.viewport.rotation,n=e.rotation;if(this.viewport=e,yht(this.div,{rotation:n}),r!==n)for(var i of lit(_At,this).values())i.rotate(n)}get pageDimensions(){var{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return lit(IAt,this).viewParameters.realScale}}function LAt(t){lit(IAt,this).unselectAll();var{target:e}=t;if(e===lit(CAt,this).div||("img"===e.getAttribute("role")||e.classList.contains("endOfContent"))&&lit(CAt,this).div.contains(e)){var{isMac:r}=Hlt.platform;if(0!==t.button||t.ctrlKey&&r)return;lit(IAt,this).showAllEditors("highlight",!0,!0),lit(CAt,this).div.classList.add("free"),this.toggleDrawing(),Lwt.startHighlighting(this,"ltr"===lit(IAt,this).direction,{target:lit(CAt,this).div,x:t.x,y:t.y}),lit(CAt,this).div.addEventListener("pointerup",(()=>{lit(CAt,this).div.classList.remove("free"),this.toggleDrawing(!0)}),{once:!0,signal:lit(IAt,this)._signal}),t.preventDefault()}}function DAt(t){return BAt._.get(lit(IAt,t).getMode())}function FAt(t){var e=uit(RAt,this,DAt);return e?new e.prototype.constructor(t):null}function NAt(){var{x:t,y:e,width:r,height:n}=this.div.getBoundingClientRect(),i=Math.max(0,t),a=Math.max(0,e),s=(i+Math.min(window.innerWidth,t+r))/2-t,o=(a+Math.min(window.innerHeight,e+n))/2-e,[l,h]=this.viewport.rotation%180==0?[s,o]:[o,s];return{offsetX:l,offsetY:h}}function jAt(){for(var t of lit(_At,this).values())t.isEmpty()&&t.remove()}pit(OAt,"_initialized",!1);var BAt={_:new Map([Uyt,Kxt,hAt,Lwt].map((t=>[t._editorType,t])))},zAt=new WeakMap,WAt=new WeakMap,UAt=new WeakMap,HAt=new WeakMap,GAt=new WeakSet;class YAt{constructor(t){var{pageIndex:e}=t;dit(this,GAt),hit(this,zAt,null),hit(this,WAt,0),hit(this,UAt,new Map),hit(this,HAt,new Map),this.pageIndex=e}setParent(t){if(lit(zAt,this)){if(lit(zAt,this)!==t){if(lit(UAt,this).size>0)for(var e of lit(UAt,this).values())e.remove(),t.append(e);cit(zAt,this,t)}}else cit(zAt,this,t)}static get _svgFactory(){return Ilt(this,"_svgFactory",new Zvt)}draw(t){var e,r,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],a=(cit(WAt,this,(e=lit(WAt,this),r=e++,e)),r),s=iit(GAt,this,qAt).call(this),o=YAt._svgFactory.createElement("defs");s.append(o);var l=YAt._svgFactory.createElement("path");o.append(l);var h="path_p".concat(this.pageIndex,"_").concat(a);l.setAttribute("id",h),l.setAttribute("vector-effect","non-scaling-stroke"),n&&lit(HAt,this).set(a,l);var c=i?iit(GAt,this,XAt).call(this,o,h):null,u=YAt._svgFactory.createElement("use");return s.append(u),u.setAttribute("href","#".concat(h)),this.updateProperties(s,t),lit(UAt,this).set(a,s),{id:a,clipPathId:"url(#".concat(c,")")}}drawOutline(t,e){var r,n,i=(cit(WAt,this,(r=lit(WAt,this),n=r++,r)),n),a=iit(GAt,this,qAt).call(this),s=YAt._svgFactory.createElement("defs");a.append(s);var o=YAt._svgFactory.createElement("path");s.append(o);var l,h="path_p".concat(this.pageIndex,"_").concat(i);if(o.setAttribute("id",h),o.setAttribute("vector-effect","non-scaling-stroke"),e){var c=YAt._svgFactory.createElement("mask");s.append(c),l="mask_p".concat(this.pageIndex,"_").concat(i),c.setAttribute("id",l),c.setAttribute("maskUnits","objectBoundingBox");var u=YAt._svgFactory.createElement("rect");c.append(u),u.setAttribute("width","1"),u.setAttribute("height","1"),u.setAttribute("fill","white");var d=YAt._svgFactory.createElement("use");c.append(d),d.setAttribute("href","#".concat(h)),d.setAttribute("stroke","none"),d.setAttribute("fill","black"),d.setAttribute("fill-rule","nonzero"),d.classList.add("mask")}var p=YAt._svgFactory.createElement("use");a.append(p),p.setAttribute("href","#".concat(h)),l&&p.setAttribute("mask","url(#".concat(l,")"));var f=p.cloneNode();return a.append(f),p.classList.add("mainOutline"),f.classList.add("secondaryOutline"),this.updateProperties(a,t),lit(UAt,this).set(i,a),i}finalizeDraw(t,e){lit(HAt,this).delete(t),this.updateProperties(t,e)}updateProperties(t,e){if(e){var{root:r,bbox:n,rootClass:i,path:a}=e,s="number"==typeof t?lit(UAt,this).get(t):t;if(s){if(r&&iit(GAt,this,$At).call(this,s,r),n&&VAt.call(YAt,s,n),i){var{classList:o}=s;for(var[l,h]of Object.entries(i))o.toggle(l,h)}if(a){var c=s.firstChild.firstChild;iit(GAt,this,$At).call(this,c,a)}}}}updateParent(t,e){if(e!==this){var r=lit(UAt,this).get(t);r&&(lit(zAt,e).append(r),lit(UAt,this).delete(t),lit(UAt,e).set(t,r))}}remove(t){lit(HAt,this).delete(t),null!==lit(zAt,this)&&(lit(UAt,this).get(t).remove(),lit(UAt,this).delete(t))}destroy(){for(var t of(cit(zAt,this,null),lit(UAt,this).values()))t.remove();lit(UAt,this).clear(),lit(HAt,this).clear()}}function VAt(t,e){var[r,n,i,a]=e,{style:s}=t;s.top="".concat(100*n,"%"),s.left="".concat(100*r,"%"),s.width="".concat(100*i,"%"),s.height="".concat(100*a,"%")}function qAt(){var t=_ot._svgFactory.create(1,1,!0);return lit(zAt,this).append(t),t.setAttribute("aria-hidden",!0),t}function XAt(t,e){var r=_ot._svgFactory.createElement("clipPath");t.append(r);var n="clip_".concat(e);r.setAttribute("id",n),r.setAttribute("clipPathUnits","objectBoundingBox");var i=_ot._svgFactory.createElement("use");return r.append(i),i.setAttribute("href","#".concat(e)),i.classList.add("clip"),n}function $At(t,e){for(var[r,n]of Object.entries(e))null===n?t.removeAttribute(r):t.setAttribute(r,n)}_ot=YAt,globalThis.pdfjsTestingUtils={HighlightOutliner:jbt};var KAt=Mot.getDocument;Mot.GlobalWorkerOptions.workerSrc="/node_modules/pdfjs-dist/build/pdf.worker.min.mjs";const QAt={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"number",label:"round",name:"round",property:{min:0}},{type:"attachment-selector",label:"file",name:"file",property:{displayField:"fullpath",displayFullUrl:!0,storageFilters:{type:Array,value:[{name:"category",value:"application"}]},useUpload:!0}},{type:"number",label:"page",name:"page"},{type:"select",label:"fit",name:"fit",property:{options:["none","ratio","width","height"]}}],help:"scene/component/pdf-viewer"},JAt=[2,4,8,16,32],ZAt=16e3;class t_t extends(aet(net)){async ready(){this.scaleIndex=0,this.displayScale=1,this.offsetX=0,this.offsetY=0,this.pdfDoc=null,this.canvas=document.createElement("canvas"),this.renderTask=null,this.loadPDF()}dispose(){super.dispose(),this.worker&&(this.worker.terminate(),this.worker=null),this.renderTask&&this.renderTask.cancel(),this.pdfDoc=null,this.canvas=null}async loadPDF(){const{file:t,page:e=1}=this.state;if(t)try{console.log(`📌 Loading PDF: ${t}`),this.pdfDoc=await KAt(t).promise;const r=this.pdfDoc.numPages;this.page=await this.pdfDoc.getPage(e>r?1:e),this.documentSize=this.page.getViewport({scale:1}),this.fit()}catch(t){console.error("🚨 Failed to load PDF:",t)}}onchange(t,e){("file"in t||"fit"in t||"page"in t)&&this.loadPDF()}async fit(){const{fit:t="none"}=this.state,{width:e,height:r}=this.bounds,n=this.documentSize;switch(t){case"none":default:this.displayScale=1;break;case"width":this.displayScale=e/n.width;break;case"height":this.displayScale=r/n.height;break;case"ratio":this.displayScale=Math.min(e/n.width,r/n.height)}this.scaleIndex=JAt.findIndex((t=>this.displayScale<=t)),-1===this.scaleIndex&&(this.scaleIndex=JAt.length-1),"ratio"===t?(this.offsetX=(e-n.width*this.displayScale)/2,this.offsetY=(r-n.height*this.displayScale)/2):(this.offsetX=0,this.offsetY=0),this.renderPDF()}async renderPDF(){if(!this.pdfDoc||!this.page)return;const{width:t,height:e}=this.documentSize;let r=JAt[this.scaleIndex],n=Math.min(t*r,ZAt),i=Math.min(e*r,ZAt);if(n===ZAt||i===ZAt){const a=t/e;a>1&&(i=n/a);const s=i/e;this.scaleIndex=JAt.findIndex((t=>s<=t))-1,r=JAt[this.scaleIndex],n=t*r,i=e*r}const a=document.createElement("canvas");a.width=n,a.height=i;const s={canvasContext:a.getContext("2d"),viewport:this.page.getViewport({scale:r})};if(this.renderTask){this.renderTask.cancel();try{await this.renderTask.promise}catch(t){console.warn("Previous render task was canceled.")}}this.renderTask=this.page.render(s);try{await this.renderTask.promise,this.canvas=a,this.renderTask=null,this.invalidate()}catch(t){"RenderingCancelledException"!==t.name&&console.error("Failed to render PDF:",t)}}render(t){super.render(t);const{left:e,top:r}=this.bounds,{width:n,height:i}=this.canvas;t.clip(),t.drawImage(this.canvas,e+this.offsetX,r+this.offsetY,(this.documentSize?.width||n)*this.displayScale,(this.documentSize?.height||i)*this.displayScale)}onwheel(t){t.preventDefault();var{left:e,top:r}=this.bounds,{x:n,y:i}=this.transcoordC2S(t.offsetX,t.offsetY);n-=e,i-=r;const a=t.deltaY<0?1.05:.95,s=this.displayScale;this.displayScale=Math.min(Math.max(.5,this.displayScale*a),JAt[JAt.length-1]);const o=JAt.findIndex((t=>this.displayScale<=t)),l=-1===o?JAt.length-1:o,h=this.displayScale/s;this.offsetX=n-(n-this.offsetX)*h,this.offsetY=i-(i-this.offsetY)*h,this.invalidate(),l!==this.scaleIndex&&(this.scaleIndex=l,this.renderPDF())}ondragstart(t){this.position=this.transcoordC2S(t.offsetX,t.offsetY)}ondragmove(t){var{x:e,y:r}=this.transcoordC2S(t.offsetX,t.offsetY);const n=e-this.position.x,i=r-this.position.y;this.offsetX+=n,this.offsetY+=i,this.position={x:e,y:r},this.invalidate()}ondblclick(t){this.fit()}get nature(){return QAt}}ret.register("pdf-page",t_t);var e_t=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=Gtt(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(g9(t)))}},r_t=t=>class extends t{_convertDataFormat(t,e){var r;if("json"===e)r=JSON.parse(t);else r=t;return r}isDataSource(){return!0}},n_t=0;const i_t=new FinalizationRegistry((()=>{n_t--}));class a_t{static get residents(){return n_t}static get residentsCount(){return n_t}constructor(t,e){this.counters={},this.references={},this.creator=t,this.disposer=e,n_t++,i_t.register(this,n_t)}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,C9("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 s(e){e.release=function(){r.release(this)},r.references[t]=e,r.counters[t]=1,n(e)}if(e)s(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){s(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,C9("RELEASED",e))):M9("No Referenced ID")}}var s_t={},o_t={},l_t=[];function h_t(t){var e="SCRIPT"==t.target.tagName?s_t:o_t,r=t.target.src||t.target.href;e[r]=!0,l_t.forEach(((t,n)=>{let{resolve:i,scripts:a,styles:s}=t;if(e==s_t){let t=a.indexOf(r);t>-1&&t<a.length-1&&u_t(a[t+1])}for(let t=0;t<a.length;t++)if(!s_t[a[t]])return;if(s)for(let t=0;t<s.length;t++)if(!o_t[s[t]])return;i(),l_t[n]=null})),l_t=l_t.filter(Boolean)}function c_t(t){var e=t.target.src,r="SCRIPT"==t.target.tagName?s_t:o_t;l_t.forEach(((n,i)=>{let{reject:a,scripts:s,styles:o}=n,l=!1;if(r===s_t){for(let t=0;t<s.length;t++)if(s[t]==e){l=!0;break}}else if(o)for(let t=0;t<o.length;t++)if(o[t]==e){l=!0;break}l&&(a(t),l_t[i]=null)})),l_t=l_t.filter(Boolean),delete r[e],document.head.removeChild(t.target)}function u_t(t){s_t[t]=!1;var e=document.createElement("script");e.onload=h_t,e.onerror=c_t,e.type="text/javascript",e.src=t,document.head.appendChild(e)}class d_t{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=>{o_t.hasOwnProperty(t)||function(t){o_t[t]=!1;var e=document.createElement("link");e.onload=h_t,e.onerror=c_t,e.type="text/css",e.rel="stylesheet",e.media="screen,print",e.href=t,document.head.appendChild(e)}(t),o_t[t]||(a=!1)})),t&&t.length>0&&t.forEach((t=>{s_t.hasOwnProperty(t)?s_t[t]||(a=!1):i=i||t})),i)u_t(i);else if(a)return void r();l_t.push({resolve:r,reject:n,scripts:t,styles:e})}else n("invalid sources for load")}))}}const p_t="0.0.0";var f_t=0,g_t=performance.now(),v_t=0;function m_t(){return f_t}requestAnimationFrame((function t(){requestAnimationFrame(t),v_t++;var e=performance.now(),r=e-g_t;r<1e3||(f_t=Math.round(1e3*v_t/r),g_t=e,v_t=0)}));var y_t=brt;function b_t(){}export{bet as AbsoluteLayout,qst as AudioPlayer,xet as CardLayout,ret as Component,jet as Connectable,ist as Container,Iet as ContainerAbstract,H9 as DEFAULT,z9 as DPPX,r_t as DataSource,hot as Donut,wst as Ellipse,Xnt as EventMap,m_t as FPS,W9 as GESTURES,Yst as GifView,eot as GlobalRef,Kst as Group,pet as HTMLAbsoluteLayout,Zst as HTMLOverlayContainer,Ist as HTMLOverlayElement,Pst as ImageView,cet as InfoWindow,U9 as KEYEVENTS,Ret as Layer,det as Layout,yst as Line,_et as LinearHorizontalLayout,Eet as LinearVerticalLayout,Jst as LocalRef,B9 as MAX_UNDO_SIZE,D9 as MODE_ADD,O9 as MODE_EDIT,N9 as MODE_PASTE_DATABIND,F9 as MODE_PASTE_STYLE,L9 as MODE_SHIFT,R9 as MODE_VIEW,y_t as Model,Cet as MoveHandle,I9 as NOTHING,Tst as OrthoLine,t_t as PDFPage,iot as Path,_st as Polygon,Est as Polyline,not as Popup,Wet as Rect,aet as RectPath,a_t as ReferenceMap,kit as RootContainer,Het as Ruler,j9 as SCENE_MODE,jit as Scene,yet as ScenePopup,d_t as ScriptLoader,net as Shape,Sot as Star,Met as TableLayout,Xst as Text,sot as Triangle,e_t as ValueHolder,zit as create,C9 as debug,M9 as error,b_t as license,h4 as polyfill,p_t as version,T9 as warn};console.log("@hatiolab/things-scene@9.0.0-beta.29 is loaded");
|