@hatiolab/things-scene 10.0.0-beta.87 → 10.0.0-beta.88
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/things-scene-min.js
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("dompurify"),require("three"),require("tinycolor2"),require("three/examples/jsm/loaders/GLTFLoader.js"),require("three/examples/jsm/loaders/DRACOLoader.js"),require("three/examples/jsm/loaders/KTX2Loader.js"),require("three/examples/jsm/libs/meshopt_decoder.module.js"),require("three/examples/jsm/utils/SkeletonUtils.js"),require("three/examples/jsm/renderers/CSS3DRenderer.js"),require("three/examples/jsm/lines/Line2.js"),require("three/examples/jsm/lines/LineMaterial.js"),require("three/examples/jsm/lines/LineGeometry.js"),require("three/examples/jsm/objects/Sky.js"),require("three/examples/jsm/postprocessing/EffectComposer.js"),require("three/examples/jsm/postprocessing/RenderPass.js"),require("three/examples/jsm/postprocessing/OutlinePass.js"),require("three/examples/jsm/postprocessing/OutputPass.js"),require("three/examples/jsm/postprocessing/SMAAPass.js"),require("three/examples/jsm/controls/TransformControls.js"),require("three/examples/jsm/geometries/RoundedBoxGeometry.js")):"function"==typeof define&&define.amd?define(["exports","dompurify","three","tinycolor2","three/examples/jsm/loaders/GLTFLoader.js","three/examples/jsm/loaders/DRACOLoader.js","three/examples/jsm/loaders/KTX2Loader.js","three/examples/jsm/libs/meshopt_decoder.module.js","three/examples/jsm/utils/SkeletonUtils.js","three/examples/jsm/renderers/CSS3DRenderer.js","three/examples/jsm/lines/Line2.js","three/examples/jsm/lines/LineMaterial.js","three/examples/jsm/lines/LineGeometry.js","three/examples/jsm/objects/Sky.js","three/examples/jsm/postprocessing/EffectComposer.js","three/examples/jsm/postprocessing/RenderPass.js","three/examples/jsm/postprocessing/OutlinePass.js","three/examples/jsm/postprocessing/OutputPass.js","three/examples/jsm/postprocessing/SMAAPass.js","three/examples/jsm/controls/TransformControls.js","three/examples/jsm/geometries/RoundedBoxGeometry.js"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).scene={},t.DOMPurify,t.THREE,t.tinycolor,t.THREE,t.THREE,t.THREE,t.THREE,t.SkeletonUtils_js,t.THREE,t.THREE,t.THREE,t.THREE,t.Sky_js,t.THREE,t.THREE,t.THREE,t.THREE,t.THREE,t.THREE,t.THREE)}(this,function(t,e,n,i,r,s,o,a,c,l,h,d,u,p,f,g,m,y,b,_,v){"use strict";function x(t){var e=Object.create(null);return t&&Object.keys(t).forEach(function(n){if("default"!==n){var i=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,i.get?i:{enumerable:!0,get:function(){return t[n]}})}}),e.default=t,Object.freeze(e)}var w=x(n);function M(t,e){return t===e||t!=t&&e!=e}function S(t,e){for(var n=t.length;n--;)if(M(t[n][0],e))return n;return-1}var A=Array.prototype.splice;function E(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var i=t[e];this.set(i[0],i[1])}}E.prototype.clear=function(){this.__data__=[],this.size=0},E.prototype.delete=function(t){var e=this.__data__,n=S(e,t);return!(n<0)&&(n==e.length-1?e.pop():A.call(e,n,1),--this.size,!0)},E.prototype.get=function(t){var e=this.__data__,n=S(e,t);return n<0?void 0:e[n][1]},E.prototype.has=function(t){return S(this.__data__,t)>-1},E.prototype.set=function(t,e){var n=this.__data__,i=S(n,t);return i<0?(++this.size,n.push([t,e])):n[i][1]=e,this};var k="object"==typeof global&&global&&global.Object===Object&&global,C="object"==typeof self&&self&&self.Object===Object&&self,T=k||C||Function("return this")(),P=T.Symbol,D=Object.prototype,O=D.hasOwnProperty,z=D.toString,L=P?P.toStringTag:void 0;var I=Object.prototype.toString;var R=P?P.toStringTag:void 0;function j(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":R&&R in Object(t)?function(t){var e=O.call(t,L),n=t[L];try{t[L]=void 0;var i=!0}catch(t){}var r=z.call(t);return i&&(e?t[L]=n:delete t[L]),r}(t):function(t){return I.call(t)}(t)}function F(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function B(t){if(!F(t))return!1;var e=j(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e}var N,H=T["__core-js_shared__"],Y=(N=/[^.]+$/.exec(H&&H.keys&&H.keys.IE_PROTO||""))?"Symbol(src)_1."+N:"";var G=Function.prototype.toString;function V(t){if(null!=t){try{return G.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var U=/^\[object .+?Constructor\]$/,$=Function.prototype,W=Object.prototype,X=$.toString,q=W.hasOwnProperty,K=RegExp("^"+X.call(q).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Q(t){return!(!F(t)||(e=t,Y&&Y in e))&&(B(t)?K:U).test(V(t));var e}function Z(t,e){var n=function(t,e){return null==t?void 0:t[e]}(t,e);return Q(n)?n:void 0}var J=Z(T,"Map"),tt=Z(Object,"create");var et=Object.prototype.hasOwnProperty;var nt=Object.prototype.hasOwnProperty;function it(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var i=t[e];this.set(i[0],i[1])}}function rt(t,e){var n=t.__data__;return function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t}(e)?n["string"==typeof e?"string":"hash"]:n.map}function st(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var i=t[e];this.set(i[0],i[1])}}it.prototype.clear=function(){this.__data__=tt?tt(null):{},this.size=0},it.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},it.prototype.get=function(t){var e=this.__data__;if(tt){var n=e[t];return"__lodash_hash_undefined__"===n?void 0:n}return et.call(e,t)?e[t]:void 0},it.prototype.has=function(t){var e=this.__data__;return tt?void 0!==e[t]:nt.call(e,t)},it.prototype.set=function(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=tt&&void 0===e?"__lodash_hash_undefined__":e,this},st.prototype.clear=function(){this.size=0,this.__data__={hash:new it,map:new(J||E),string:new it}},st.prototype.delete=function(t){var e=rt(this,t).delete(t);return this.size-=e?1:0,e},st.prototype.get=function(t){return rt(this,t).get(t)},st.prototype.has=function(t){return rt(this,t).has(t)},st.prototype.set=function(t,e){var n=rt(this,t),i=n.size;return n.set(t,e),this.size+=n.size==i?0:1,this};function ot(t){var e=this.__data__=new E(t);this.size=e.size}ot.prototype.clear=function(){this.__data__=new E,this.size=0},ot.prototype.delete=function(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n},ot.prototype.get=function(t){return this.__data__.get(t)},ot.prototype.has=function(t){return this.__data__.has(t)},ot.prototype.set=function(t,e){var n=this.__data__;if(n instanceof E){var i=n.__data__;if(!J||i.length<199)return i.push([t,e]),this.size=++n.size,this;n=this.__data__=new st(i)}return n.set(t,e),this.size=n.size,this};function at(t){var e=-1,n=null==t?0:t.length;for(this.__data__=new st;++e<n;)this.add(t[e])}function ct(t,e){for(var n=-1,i=null==t?0:t.length;++n<i;)if(e(t[n],n,t))return!0;return!1}at.prototype.add=at.prototype.push=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this},at.prototype.has=function(t){return this.__data__.has(t)};function lt(t,e,n,i,r,s){var o=1&n,a=t.length,c=e.length;if(a!=c&&!(o&&c>a))return!1;var l=s.get(t),h=s.get(e);if(l&&h)return l==e&&h==t;var d=-1,u=!0,p=2&n?new at:void 0;for(s.set(t,e),s.set(e,t);++d<a;){var f=t[d],g=e[d];if(i)var m=o?i(g,f,d,e,t,s):i(f,g,d,t,e,s);if(void 0!==m){if(m)continue;u=!1;break}if(p){if(!ct(e,function(t,e){if(o=e,!p.has(o)&&(f===t||r(f,t,n,i,s)))return p.push(e);var o})){u=!1;break}}else if(f!==g&&!r(f,g,n,i,s)){u=!1;break}}return s.delete(t),s.delete(e),u}var ht=T.Uint8Array;function dt(t){var e=-1,n=Array(t.size);return t.forEach(function(t,i){n[++e]=[i,t]}),n}function ut(t){var e=-1,n=Array(t.size);return t.forEach(function(t){n[++e]=t}),n}var pt=P?P.prototype:void 0,ft=pt?pt.valueOf:void 0;function gt(t,e){for(var n=-1,i=e.length,r=t.length;++n<i;)t[r+n]=e[n];return t}var mt=Array.isArray;function yt(){return[]}var bt=Object.prototype.propertyIsEnumerable,_t=Object.getOwnPropertySymbols,vt=_t?function(t){return null==t?[]:(t=Object(t),function(t,e){for(var n=-1,i=null==t?0:t.length,r=0,s=[];++n<i;){var o=t[n];e(o,n,t)&&(s[r++]=o)}return s}(_t(t),function(e){return bt.call(t,e)}))}:yt;function xt(t){return null!=t&&"object"==typeof t}function wt(t){return xt(t)&&"[object Arguments]"==j(t)}var Mt=Object.prototype,St=Mt.hasOwnProperty,At=Mt.propertyIsEnumerable,Et=wt(function(){return arguments}())?wt:function(t){return xt(t)&&St.call(t,"callee")&&!At.call(t,"callee")};var kt="object"==typeof t&&t&&!t.nodeType&&t,Ct=kt&&"object"==typeof module&&module&&!module.nodeType&&module,Tt=Ct&&Ct.exports===kt?T.Buffer:void 0,Pt=(Tt?Tt.isBuffer:void 0)||function(){return!1},Dt=/^(?:0|[1-9]\d*)$/;function Ot(t,e){var n=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==n||"symbol"!=n&&Dt.test(t))&&t>-1&&t%1==0&&t<e}function zt(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}var Lt={};function It(t){return function(e){return t(e)}}Lt["[object Float32Array]"]=Lt["[object Float64Array]"]=Lt["[object Int8Array]"]=Lt["[object Int16Array]"]=Lt["[object Int32Array]"]=Lt["[object Uint8Array]"]=Lt["[object Uint8ClampedArray]"]=Lt["[object Uint16Array]"]=Lt["[object Uint32Array]"]=!0,Lt["[object Arguments]"]=Lt["[object Array]"]=Lt["[object ArrayBuffer]"]=Lt["[object Boolean]"]=Lt["[object DataView]"]=Lt["[object Date]"]=Lt["[object Error]"]=Lt["[object Function]"]=Lt["[object Map]"]=Lt["[object Number]"]=Lt["[object Object]"]=Lt["[object RegExp]"]=Lt["[object Set]"]=Lt["[object String]"]=Lt["[object WeakMap]"]=!1;var Rt="object"==typeof t&&t&&!t.nodeType&&t,jt=Rt&&"object"==typeof module&&module&&!module.nodeType&&module,Ft=jt&&jt.exports===Rt&&k.process,Bt=function(){try{var t=jt&&jt.require&&jt.require("util").types;return t||Ft&&Ft.binding&&Ft.binding("util")}catch(t){}}(),Nt=Bt&&Bt.isTypedArray,Ht=Nt?It(Nt):function(t){return xt(t)&&zt(t.length)&&!!Lt[j(t)]},Yt=Object.prototype.hasOwnProperty;function Gt(t,e){var n=mt(t),i=!n&&Et(t),r=!n&&!i&&Pt(t),s=!n&&!i&&!r&&Ht(t),o=n||i||r||s,a=o?function(t,e){for(var n=-1,i=Array(t);++n<t;)i[n]=e(n);return i}(t.length,String):[],c=a.length;for(var l in t)!e&&!Yt.call(t,l)||o&&("length"==l||r&&("offset"==l||"parent"==l)||s&&("buffer"==l||"byteLength"==l||"byteOffset"==l)||Ot(l,c))||a.push(l);return a}var Vt=Object.prototype;function Ut(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||Vt)}function $t(t,e){return function(n){return t(e(n))}}var Wt=$t(Object.keys,Object),Xt=Object.prototype.hasOwnProperty;function qt(t){if(!Ut(t))return Wt(t);var e=[];for(var n in Object(t))Xt.call(t,n)&&"constructor"!=n&&e.push(n);return e}function Kt(t){return null!=t&&zt(t.length)&&!B(t)}function Qt(t){return Kt(t)?Gt(t):qt(t)}function Zt(t){return function(t,e,n){var i=e(t);return mt(t)?i:gt(i,n(t))}(t,Qt,vt)}var Jt=Object.prototype.hasOwnProperty;var te=Z(T,"DataView"),ee=Z(T,"Promise"),ne=Z(T,"Set"),ie=Z(T,"WeakMap"),re="[object Map]",se="[object Promise]",oe="[object Set]",ae="[object WeakMap]",ce="[object DataView]",le=V(te),he=V(J),de=V(ee),ue=V(ne),pe=V(ie),fe=j;(te&&fe(new te(new ArrayBuffer(1)))!=ce||J&&fe(new J)!=re||ee&&fe(ee.resolve())!=se||ne&&fe(new ne)!=oe||ie&&fe(new ie)!=ae)&&(fe=function(t){var e=j(t),n="[object Object]"==e?t.constructor:void 0,i=n?V(n):"";if(i)switch(i){case le:return ce;case he:return re;case de:return se;case ue:return oe;case pe:return ae}return e});var ge="[object Arguments]",me="[object Array]",ye="[object Object]",be=Object.prototype.hasOwnProperty;function _e(t,e,n,i,r,s){var o=mt(t),a=mt(e),c=o?me:fe(t),l=a?me:fe(e),h=(c=c==ge?ye:c)==ye,d=(l=l==ge?ye:l)==ye,u=c==l;if(u&&Pt(t)){if(!Pt(e))return!1;o=!0,h=!1}if(u&&!h)return s||(s=new ot),o||Ht(t)?lt(t,e,n,i,r,s):function(t,e,n,i,r,s,o){switch(n){case"[object DataView]":if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case"[object ArrayBuffer]":return!(t.byteLength!=e.byteLength||!s(new ht(t),new ht(e)));case"[object Boolean]":case"[object Date]":case"[object Number]":return M(+t,+e);case"[object Error]":return t.name==e.name&&t.message==e.message;case"[object RegExp]":case"[object String]":return t==e+"";case"[object Map]":var a=dt;case"[object Set]":var c=1&i;if(a||(a=ut),t.size!=e.size&&!c)return!1;var l=o.get(t);if(l)return l==e;i|=2,o.set(t,e);var h=lt(a(t),a(e),i,r,s,o);return o.delete(t),h;case"[object Symbol]":if(ft)return ft.call(t)==ft.call(e)}return!1}(t,e,c,n,i,r,s);if(!(1&n)){var p=h&&be.call(t,"__wrapped__"),f=d&&be.call(e,"__wrapped__");if(p||f){var g=p?t.value():t,m=f?e.value():e;return s||(s=new ot),r(g,m,n,i,s)}}return!!u&&(s||(s=new ot),function(t,e,n,i,r,s){var o=1&n,a=Zt(t),c=a.length;if(c!=Zt(e).length&&!o)return!1;for(var l=c;l--;){var h=a[l];if(!(o?h in e:Jt.call(e,h)))return!1}var d=s.get(t),u=s.get(e);if(d&&u)return d==e&&u==t;var p=!0;s.set(t,e),s.set(e,t);for(var f=o;++l<c;){var g=t[h=a[l]],m=e[h];if(i)var y=o?i(m,g,h,e,t,s):i(g,m,h,t,e,s);if(!(void 0===y?g===m||r(g,m,n,i,s):y)){p=!1;break}f||(f="constructor"==h)}if(p&&!f){var b=t.constructor,_=e.constructor;b==_||!("constructor"in t)||!("constructor"in e)||"function"==typeof b&&b instanceof b&&"function"==typeof _&&_ instanceof _||(p=!1)}return s.delete(t),s.delete(e),p}(t,e,n,i,r,s))}function ve(t,e,n,i,r){return t===e||(null==t||null==e||!xt(t)&&!xt(e)?t!=t&&e!=e:_e(t,e,n,i,ve,r))}var xe=function(){try{var t=Z(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();function we(t,e,n){"__proto__"==e&&xe?xe(t,e,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[e]=n}var Me=Object.prototype.hasOwnProperty;function Se(t,e,n){var i=t[e];Me.call(t,e)&&M(i,n)&&(void 0!==n||e in t)||we(t,e,n)}function Ae(t,e,n,i){var r=!n;n||(n={});for(var s=-1,o=e.length;++s<o;){var a=e[s],c=i?i(n[a],t[a],a,n,t):void 0;void 0===c&&(c=t[a]),r?we(n,a,c):Se(n,a,c)}return n}function Ee(t){return t}function ke(t,e,n){switch(n.length){case 0:return t.call(e);case 1:return t.call(e,n[0]);case 2:return t.call(e,n[0],n[1]);case 3:return t.call(e,n[0],n[1],n[2])}return t.apply(e,n)}var Ce=Math.max;function Te(t){return function(){return t}}var Pe=xe?function(t,e){return xe(t,"toString",{configurable:!0,enumerable:!1,value:Te(e),writable:!0})}:Ee,De=Date.now;var Oe=function(t){var e=0,n=0;return function(){var i=De(),r=16-(i-n);if(n=i,r>0){if(++e>=800)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(Pe);function ze(t,e){return Oe(function(t,e,n){return e=Ce(void 0===e?t.length-1:e,0),function(){for(var i=arguments,r=-1,s=Ce(i.length-e,0),o=Array(s);++r<s;)o[r]=i[e+r];r=-1;for(var a=Array(e+1);++r<e;)a[r]=i[r];return a[e]=n(o),ke(t,this,a)}}(t,e,Ee),t+"")}function Le(t,e,n){if(!F(n))return!1;var i=typeof e;return!!("number"==i?Kt(n)&&Ot(e,n.length):"string"==i&&e in n)&&M(n[e],t)}var Ie=Object.prototype.hasOwnProperty;function Re(t){if(!F(t))return function(t){var e=[];if(null!=t)for(var n in Object(t))e.push(n);return e}(t);var e=Ut(t),n=[];for(var i in t)("constructor"!=i||!e&&Ie.call(t,i))&&n.push(i);return n}function je(t){return Kt(t)?Gt(t,!0):Re(t)}var Fe,Be=(Fe=function(t,e,n,i){Ae(e,je(e),t,i)},ze(function(t,e){var n=-1,i=e.length,r=i>1?e[i-1]:void 0,s=i>2?e[2]:void 0;for(r=Fe.length>3&&"function"==typeof r?(i--,r):void 0,s&&Le(e[0],e[1],s)&&(r=i<3?void 0:r,i=1),t=Object(t);++n<i;){var o=e[n];o&&Fe(t,o,n,r)}return t})),Ne=$t(Object.getPrototypeOf,Object),He=Function.prototype,Ye=Object.prototype,Ge=He.toString,Ve=Ye.hasOwnProperty,Ue=Ge.call(Object);function $e(t){if(!xt(t))return!1;var e=j(t);return"[object Error]"==e||"[object DOMException]"==e||"string"==typeof t.message&&"string"==typeof t.name&&!function(t){if(!xt(t)||"[object Object]"!=j(t))return!1;var e=Ne(t);if(null===e)return!0;var n=Ve.call(e,"constructor")&&e.constructor;return"function"==typeof n&&n instanceof n&&Ge.call(n)==Ue}(t)}var We=ze(function(t,e){try{return ke(t,void 0,e)}catch(t){return $e(t)?t:new Error(t)}});function Xe(t,e){for(var n=-1,i=null==t?0:t.length,r=Array(i);++n<i;)r[n]=e(t[n],n,t);return r}var qe=Object.prototype,Ke=qe.hasOwnProperty;function Qe(t,e,n,i){return void 0===t||M(t,qe[n])&&!Ke.call(i,n)?e:t}var Ze={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"};function Je(t){return"\\"+Ze[t]}var tn=/<%=([\s\S]+?)%>/g;var en,nn=(en={"&":"&","<":"<",">":">",'"':""","'":"'"},function(t){return null==en?void 0:en[t]});function rn(t){return"symbol"==typeof t||xt(t)&&"[object Symbol]"==j(t)}var sn=P?P.prototype:void 0,on=sn?sn.toString:void 0;function an(t){if("string"==typeof t)return t;if(mt(t))return Xe(t,an)+"";if(rn(t))return on?on.call(t):"";var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}function cn(t){return null==t?"":an(t)}var ln=/[&<>"']/g,hn=RegExp(ln.source);var dn={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:tn,variable:"",imports:{_:{escape:function(t){return(t=cn(t))&&hn.test(t)?t.replace(ln,nn):t}}}},un=/\b__p \+= '';/g,pn=/\b(__p \+=) '' \+/g,fn=/(__e\(.*?\)|\b__t\)) \+\n'';/g,gn=/[()=,{}\[\]\/\s]/,mn=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,yn=/($^)/,bn=/['\n\r\u2028\u2029\\]/g,_n=Object.prototype.hasOwnProperty;var vn="object"==typeof t&&t&&!t.nodeType&&t,xn=vn&&"object"==typeof module&&module&&!module.nodeType&&module,wn=xn&&xn.exports===vn?T.Buffer:void 0,Mn=wn?wn.allocUnsafe:void 0;var Sn=Object.getOwnPropertySymbols?function(t){for(var e=[];t;)gt(e,vt(t)),t=Ne(t);return e}:yt;var An=Object.prototype.hasOwnProperty;var En=/\w*$/;var kn=P?P.prototype:void 0,Cn=kn?kn.valueOf:void 0;function Tn(t,e,n){var i,r,s,o,a,c=t.constructor;switch(e){case"[object ArrayBuffer]":return a=new(o=t).constructor(o.byteLength),new ht(a).set(new ht(o)),a;case"[object Boolean]":case"[object Date]":return new c(+t);case"[object DataView]":return s=(r=t).buffer,new r.constructor(s,r.byteOffset,r.byteLength);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return function(t){var e=t.buffer;return new t.constructor(e,t.byteOffset,t.length)}(t);case"[object Map]":case"[object Set]":return new c;case"[object Number]":case"[object String]":return new c(t);case"[object RegExp]":return function(t){var e=new t.constructor(t.source,En.exec(t));return e.lastIndex=t.lastIndex,e}(t);case"[object Symbol]":return i=t,Cn?Object(Cn.call(i)):{}}}var Pn=Object.create,Dn=function(){function t(){}return function(e){if(!F(e))return{};if(Pn)return Pn(e);t.prototype=e;var n=new t;return t.prototype=void 0,n}}();var On=Bt&&Bt.isMap,zn=On?It(On):function(t){return xt(t)&&"[object Map]"==fe(t)};var Ln=Bt&&Bt.isSet,In=Ln?It(Ln):function(t){return xt(t)&&"[object Set]"==fe(t)},Rn="[object Arguments]",jn="[object Function]",Fn="[object Object]",Bn={};function Nn(t,e,n,i,r,s){var o,a=2&e;if(void 0!==o)return o;if(!F(t))return t;var c=mt(t);if(c)return o=function(t){var e=t.length,n=new t.constructor(e);return e&&"string"==typeof t[0]&&An.call(t,"index")&&(n.index=t.index,n.input=t.input),n}(t),function(t,e){var n=-1,i=t.length;for(e||(e=Array(i));++n<i;)e[n]=t[n];return e}(t,o);var l=fe(t),h=l==jn||"[object GeneratorFunction]"==l;if(Pt(t))return function(t){var e=t.length,n=Mn?Mn(e):new t.constructor(e);return t.copy(n),n}(t);if(l==Fn||l==Rn||h&&!r)return o=h?{}:function(t){return"function"!=typeof t.constructor||Ut(t)?{}:Dn(Ne(t))}(t),a?function(t,e){return Ae(t,Sn(t),e)}(t,function(t,e){return t&&Ae(e,je(e),t)}(o,t)):function(t,e){return Ae(t,vt(t),e)}(t,function(t,e){return t&&Ae(e,Qt(e),t)}(o,t));if(!Bn[l])return r?t:{};o=Tn(t,l),s||(s=new ot);var d=s.get(t);if(d)return d;s.set(t,o),In(t)?t.forEach(function(i){o.add(Nn(i,e,n,i,t,s))}):zn(t)&&t.forEach(function(i,r){o.set(r,Nn(i,e,n,r,t,s))});var u=c?void 0:Zt(t);return function(t,e){for(var n=-1,i=null==t?0:t.length;++n<i&&!1!==e(t[n],n,t););}(u||t,function(i,r){u&&(i=t[r=i]),Se(o,r,Nn(i,e,n,r,t,s))}),o}Bn[Rn]=Bn["[object Array]"]=Bn["[object ArrayBuffer]"]=Bn["[object DataView]"]=Bn["[object Boolean]"]=Bn["[object Date]"]=Bn["[object Float32Array]"]=Bn["[object Float64Array]"]=Bn["[object Int8Array]"]=Bn["[object Int16Array]"]=Bn["[object Int32Array]"]=Bn["[object Map]"]=Bn["[object Number]"]=Bn[Fn]=Bn["[object RegExp]"]=Bn["[object Set]"]=Bn["[object String]"]=Bn["[object Symbol]"]=Bn["[object Uint8Array]"]=Bn["[object Uint8ClampedArray]"]=Bn["[object Uint16Array]"]=Bn["[object Uint32Array]"]=!0,Bn["[object Error]"]=Bn[jn]=Bn["[object WeakMap]"]=!1;function Hn(t){return Nn(t,4)}var Yn=function(){return T.Date.now()},Gn=/\s/;var Vn=/^\s+/;function Un(t){return t?t.slice(0,function(t){for(var e=t.length;e--&&Gn.test(t.charAt(e)););return e}(t)+1).replace(Vn,""):t}var $n=/^[-+]0x[0-9a-f]+$/i,Wn=/^0b[01]+$/i,Xn=/^0o[0-7]+$/i,qn=parseInt;function Kn(t){if("number"==typeof t)return t;if(rn(t))return NaN;if(F(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=F(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=Un(t);var n=Wn.test(t);return n||Xn.test(t)?qn(t.slice(2),n?2:8):$n.test(t)?NaN:+t}var Qn=Math.max,Zn=Math.min;function Jn(t,e,n){var i,r,s,o,a,c,l=0,h=!1,d=!1,u=!0;if("function"!=typeof t)throw new TypeError("Expected a function");function p(e){var n=i,s=r;return i=r=void 0,l=e,o=t.apply(s,n)}function f(t){var n=t-c;return void 0===c||n>=e||n<0||d&&t-l>=s}function g(){var t=Yn();if(f(t))return m(t);a=setTimeout(g,function(t){var n=e-(t-c);return d?Zn(n,s-(t-l)):n}(t))}function m(t){return a=void 0,u&&i?p(t):(i=r=void 0,o)}function y(){var t=Yn(),n=f(t);if(i=arguments,r=this,c=t,n){if(void 0===a)return function(t){return l=t,a=setTimeout(g,e),h?p(t):o}(c);if(d)return clearTimeout(a),a=setTimeout(g,e),p(c)}return void 0===a&&(a=setTimeout(g,e)),o}return e=Kn(e)||0,F(n)&&(h=!!n.leading,s=(d="maxWait"in n)?Qn(Kn(n.maxWait)||0,e):s,u="trailing"in n?!!n.trailing:u),y.cancel=function(){void 0!==a&&clearTimeout(a),l=0,i=c=r=a=void 0},y.flush=function(){return void 0===a?o:m(Yn())},y}var ti=1/0;function ei(t){var e=function(t){return t?(t=Kn(t))===ti||t===-1/0?17976931348623157e292*(t<0?-1:1):t==t?t:0:0===t?t:0}(t),n=e%1;return e==e?n?e-n:e:0}function ni(t){return function(t,e){var n;if("function"!=typeof e)throw new TypeError("Expected a function");return t=ei(t),function(){return--t>0&&(n=e.apply(this,arguments)),t<=1&&(e=void 0),n}}(2,t)}var ii=Object.prototype.hasOwnProperty;function ri(t){if(null==t)return!0;if(Kt(t)&&(mt(t)||"string"==typeof t||"function"==typeof t.splice||Pt(t)||Ht(t)||Et(t)))return!t.length;var e=fe(t);if("[object Map]"==e||"[object Set]"==e)return!t.size;if(Ut(t))return!qt(t).length;for(var n in t)if(ii.call(t,n))return!1;return!0}let si=0;function oi(t={},...e){return"object"!=typeof t&&(t={}),e.forEach(e=>{for(const n in e)"object"!=typeof e[n]?t[n]=e[n]:e[n].length>0?t[n]=e[n].map(t=>{let i;return i="object"!=typeof e[n]?t:oi({},t),i}):t[n]=oi(t[n],e[n])}),t}function ai(t){for(;t&&"object"==typeof t;){const e=t;for(const e in t){t=t[e];break}if(t===e){t=void 0;break}}return t}function ci(t,e){if(!this.__collection__)return this;return-1==this.__collection__.indexOf(e)&&this.__collection__.splice(t,0,e),this}function li(t){return this.__collection__||(this.__collection__=[]),-1==this.__collection__.indexOf(t)&&this.__collection__.push(t),this}function hi(t){return this.__collection__||(this.__collection__=[]),-1==this.__collection__.indexOf(t)&&this.__collection__.unshift(t),this}function di(t){if(!this.__collection__)return this;const e=this.__collection__.indexOf(t);return e>=0&&this.__collection__.splice(e,1),this}function ui(t){if(this.__collection__)return this.__collection__[t]}function pi(t,e){this.__collection__&&this.__collection__.forEach(t,e)}function fi(t){return this.__collection__?this.__collection__.indexOf(t):-1}function gi(){return this.__collection__?this.__collection__.length:0}function mi(){this.__collection__=[]}function yi(t){const e=this.indexOf(t);-1!=e&&0!=e&&(this.__collection__[e]=this.__collection__[e-1],this.__collection__[e-1]=t)}function bi(t){const e=this.indexOf(t);-1!=e&&e!=this.size()-1&&(this.__collection__[e]=this.__collection__[e+1],this.__collection__[e+1]=t)}function _i(t){const e=this.indexOf(t);if(-1==e||0==e)return;const n=this.__collection__.splice(0,e),i=this.__collection__.splice(1);this.__collection__=this.__collection__.concat(n,i)}function vi(t){const e=this.indexOf(t);if(-1==e||e==this.size()-1)return;const n=this.__collection__.splice(0,e),i=this.__collection__.splice(1);this.__collection__=n.concat(i,this.__collection__)}class xi{constructor(){this.__collection__=[],this.insertAt=ci,this.append=li,this.prepend=hi,this.remove=di,this.getAt=ui,this.forEach=pi,this.indexOf=fi,this.size=gi,this.clear=mi,this.moveForward=yi,this.moveBackward=bi,this.moveToHead=_i,this.moveToTail=vi}}const wi=new class{constructor(){this.drawCount=0,this.drawTimeSum=0,this.drawTimeLast=0,this.invalidateCount=0,this.triggerCount=0,this.cacheHit=0,this.cacheMiss=0,this._lastSnapshotTime=0,this._frameCount=0,this._getResidents=null}registerResidents(t){this._getResidents=t}countFrame(){this._frameCount++}snapshot(){const t=performance.now(),e=this.drawCount,n=this.cacheHit+this.cacheMiss,i=this._getResidents?.()??null;let r=0;if(this._lastSnapshotTime>0){const e=t-this._lastSnapshotTime;e>0&&(r=Math.round(1e3*this._frameCount/e))}this._lastSnapshotTime=t,this._frameCount=0;const s={fps:r,drawCount:e,drawTimeAvg:e>0?Math.round(this.drawTimeSum/e*100)/100:0,drawTimeLast:Math.round(100*this.drawTimeLast)/100,invalidateCount:this.invalidateCount,triggerCount:this.triggerCount,cacheHitRate:n>0?Math.round(this.cacheHit/n*1e3)/10:0,...i??{}};return this.drawCount=0,this.drawTimeSum=0,this.invalidateCount=0,this.triggerCount=0,this.cacheHit=0,this.cacheMiss=0,s}},Mi=/\s+/;function Si(t,e,n,i){if(!n)return!0;if("object"==typeof n){for(const i in n){const r=n[i];t[e].apply(t,[i,r])}return!1}if(Mi.test(n)){return n.split(Mi).forEach(n=>t[e].apply(t,[n].concat(i))),!1}return!0}const Ai=["on","off","once","delegate_on","delegate_off","trigger","listenTo"],Ei={withEvent(){Ai.forEach(t=>this[t]=Ei[t])},on(t,e,n){if(!Si(this,"on",t,[e,n])||!e)return this;this._listeners||(this._listeners={});return(this._listeners[t]||(this._listeners[t]=[])).push({callback:e,context:n,ctx:n||this}),this},once(t,e,n){if(!Si(this,"once",t,[e,n])||!e)return this;const i=this,r=ni(function(){i.off(t,r,n),e.apply(i,arguments)});return r._callback=e,this.on(t,r,n),this},off(t,e,n){if(!this._listeners||!Si(this,"off",t,[e,n]))return this;if(!t&&!e&&!n)return this._listeners=void 0,this;let i;i=t&&"string"==typeof t?[t]:Object.keys(this._listeners||{});for(let t=0;t<i.length;t++){const r=i[t],s=this._listeners?.[r];if(s){const t=[];if(this._listeners[r]=t,e||n)for(let i=0;i<s.length;i++){const r=s[i];(e&&e!==r.callback&&e!==r.callback._callback||n&&n!==r.context)&&t.push(r)}t.length||delete this._listeners[r]}}return this},delegate_on(t){return this._delegators||(this._delegators=new xi),this._delegators.append(t),this},delegate_off(t){return this._delegators?(this._delegators.remove(t),this):this},delegate(){if(this._delegators&&this._delegators.size()>0&&Ci(this._delegators,arguments),!this._listeners)return this;const t=arguments.length-1,e=arguments[t];arguments[t]={origin:e.origin,name:e.name,deliverer:this};const n=this._listeners[e.name],i=this._listeners["(all)"];return n&&ki(n,arguments),i&&ki(i,arguments),this},trigger(t){wi.triggerCount++;const e=[].slice.call(arguments,1);if(e.push({origin:this,name:t,deliverer:this}),this._delegators&&this._delegators.size()>0&&Ci(this._delegators,e),!this._listeners)return this;if(!Si(this,"trigger",t,e))return this;const n=this._listeners[t],i=this._listeners["(all)"];return n&&ki(n,e),i&&ki(i,e),this},stopListening(t,e,n){let i=this._listeningTo;if(!i)return this;const r=!e&&!n;n||"object"!=typeof e||(n=this),t&&(i={},i[t._listenId]=t);for(const t in i){const s=i[t];s.off(e,n,this),(r||ri(s._events))&&delete this._listeningTo[t]}return this}};function ki(t,e){t.forEach(t=>t.callback.apply(t.ctx,e))}function Ci(t,e){t.forEach(t=>Ei.delegate.apply(t,e))}const Ti={listenTo:"on",listenToOnce:"once"};for(const t in Ti){const e=Ti[t];Ei[t]=function(t,n,i){this._listeningTo||(this._listeningTo={});const r=this._listeningTo;t._listenId||(t._listenId=`${"l"}${++si}`);return r[t._listenId]=t,i||"object"!=typeof n||(i=this),t[e](n,i,this),this}}const Pi=Ei.on,Di=Ei.off,Oi=Ei.once,zi=Ei.trigger,Li=Ei.delegate_on,Ii=Ei.delegate_off;function Ri(t,e){if(e instanceof Array)e.forEach(e=>Ri(t,e));else{if(t.mixedIn=t.hasOwnProperty("mixedIn")?t.mixedIn:[],t.mixingIn=t.hasOwnProperty("mixingIn")?t.mixingIn:[],t.mixedIn.indexOf(e)>=0)return t;if(t.mixingIn.indexOf(e)>=0)throw new Error(`found cyclic dependencies between ${t.mixingIn}`);t.mixingIn.push(e),e.call(t),t.mixingIn.pop(),t.mixedIn.push(e)}return t}const ji=(...t)=>{const e=[];t.forEach(t=>t&&t.stack&&e.push(t.stack)),console.error("[ERROR]",...t,e.join(" "))},Fi=(...t)=>{const e=[];t.forEach(t=>t&&t.stack&&e.push(t.stack)),console.warn("[WARN]",...t,e.join(" "))},Bi=(...t)=>console.log("[DEBUG]",...t);function Ni(t,e,n){const i=function(t,e){let n=t;for(;n;){const t=Object.getOwnPropertyDescriptor(n,e);if(t?.get)return t;n=Object.getPrototypeOf(n)}}(t,e);if(!i?.get)return void ji(`${String(e)} is not defined in ${t.constructor.name}`);const r=i.get,s={get:n?function(){return e in this.__cache__?wi.cacheHit++:(wi.cacheMiss++,this.__cache__[e]=Object.freeze(r.call(this))),this.__cache__[e]}:function(){return e in this.__cache__?wi.cacheHit++:(wi.cacheMiss++,this.__cache__[e]=r.call(this)),this.__cache__[e]},configurable:!0};i.set&&(s.set=i.set),Object.defineProperty(t,e,s)}var Hi="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Yi(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function Gi(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Vi,Ui={exports:{}};var $i=(Vi||(Vi=1,function(t){var e=function(t){var e,n=Object.prototype,i=n.hasOwnProperty,r=Object.defineProperty||function(t,e,n){t[e]=n.value},s="function"==typeof Symbol?Symbol:{},o=s.iterator||"@@iterator",a=s.asyncIterator||"@@asyncIterator",c=s.toStringTag||"@@toStringTag";function l(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{l({},"")}catch(t){l=function(t,e,n){return t[e]=n}}function h(t,e,n,i){var s=e&&e.prototype instanceof y?e:y,o=Object.create(s.prototype),a=new P(i||[]);return r(o,"_invoke",{value:E(t,n,a)}),o}function d(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}t.wrap=h;var u="suspendedStart",p="suspendedYield",f="executing",g="completed",m={};function y(){}function b(){}function _(){}var v={};l(v,o,function(){return this});var x=Object.getPrototypeOf,w=x&&x(x(D([])));w&&w!==n&&i.call(w,o)&&(v=w);var M=_.prototype=y.prototype=Object.create(v);function S(t){["next","throw","return"].forEach(function(e){l(t,e,function(t){return this._invoke(e,t)})})}function A(t,e){function n(r,s,o,a){var c=d(t[r],t,s);if("throw"!==c.type){var l=c.arg,h=l.value;return h&&"object"==typeof h&&i.call(h,"__await")?e.resolve(h.__await).then(function(t){n("next",t,o,a)},function(t){n("throw",t,o,a)}):e.resolve(h).then(function(t){l.value=t,o(l)},function(t){return n("throw",t,o,a)})}a(c.arg)}var s;r(this,"_invoke",{value:function(t,i){function r(){return new e(function(e,r){n(t,i,e,r)})}return s=s?s.then(r,r):r()}})}function E(t,n,i){var r=u;return function(s,o){if(r===f)throw new Error("Generator is already running");if(r===g){if("throw"===s)throw o;return{value:e,done:!0}}for(i.method=s,i.arg=o;;){var a=i.delegate;if(a){var c=k(a,i);if(c){if(c===m)continue;return c}}if("next"===i.method)i.sent=i._sent=i.arg;else if("throw"===i.method){if(r===u)throw r=g,i.arg;i.dispatchException(i.arg)}else"return"===i.method&&i.abrupt("return",i.arg);r=f;var l=d(t,n,i);if("normal"===l.type){if(r=i.done?g:p,l.arg===m)continue;return{value:l.arg,done:i.done}}"throw"===l.type&&(r=g,i.method="throw",i.arg=l.arg)}}}function k(t,n){var i=n.method,r=t.iterator[i];if(r===e)return n.delegate=null,"throw"===i&&t.iterator.return&&(n.method="return",n.arg=e,k(t,n),"throw"===n.method)||"return"!==i&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+i+"' method")),m;var s=d(r,t.iterator,n.arg);if("throw"===s.type)return n.method="throw",n.arg=s.arg,n.delegate=null,m;var o=s.arg;return o?o.done?(n[t.resultName]=o.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,m):o:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,m)}function C(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 T(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function P(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(C,this),this.reset(!0)}function D(t){if(null!=t){var n=t[o];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,s=function n(){for(;++r<t.length;)if(i.call(t,r))return n.value=t[r],n.done=!1,n;return n.value=e,n.done=!0,n};return s.next=s}}throw new TypeError(typeof t+" is not iterable")}return b.prototype=_,r(M,"constructor",{value:_,configurable:!0}),r(_,"constructor",{value:b,configurable:!0}),b.displayName=l(_,c,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===b||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,_):(t.__proto__=_,l(t,c,"GeneratorFunction")),t.prototype=Object.create(M),t},t.awrap=function(t){return{__await:t}},S(A.prototype),l(A.prototype,a,function(){return this}),t.AsyncIterator=A,t.async=function(e,n,i,r,s){void 0===s&&(s=Promise);var o=new A(h(e,n,i,r),s);return t.isGeneratorFunction(n)?o:o.next().then(function(t){return t.done?t.value:o.next()})},S(M),l(M,c,"Generator"),l(M,o,function(){return this}),l(M,"toString",function(){return"[object Generator]"}),t.keys=function(t){var e=Object(t),n=[];for(var i in e)n.push(i);return n.reverse(),function t(){for(;n.length;){var i=n.pop();if(i in e)return t.value=i,t.done=!1,t}return t.done=!0,t}},t.values=D,P.prototype={constructor:P,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(T),!t)for(var n in this)"t"===n.charAt(0)&&i.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function r(i,r){return a.type="throw",a.arg=t,n.next=i,r&&(n.method="next",n.arg=e),!!r}for(var s=this.tryEntries.length-1;s>=0;--s){var o=this.tryEntries[s],a=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var c=i.call(o,"catchLoc"),l=i.call(o,"finallyLoc");if(c&&l){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!l)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&i.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var s=r;break}}s&&("break"===t||"continue"===t)&&s.tryLoc<=e&&e<=s.finallyLoc&&(s=null);var o=s?s.completion:{};return o.type=t,o.arg=e,s?(this.method="next",this.next=s.finallyLoc,m):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),m},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),T(n),m}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var i=n.completion;if("throw"===i.type){var r=i.arg;T(n)}return r}}throw new Error("illegal catch attempt")},delegateYield:function(t,n,i){return this.delegate={iterator:D(t),resultName:n,nextLoc:i},"next"===this.method&&(this.arg=e),m}},t}(t.exports);try{regeneratorRuntime=e}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=e:Function("r","regeneratorRuntime = r")(e)}Number.isInteger=Number.isInteger||function(t){return"number"==typeof t&&isFinite(t)&&Math.floor(t)===t},String.fromCodePoint||function(t){var e=function(e){for(var n=[],i=0,r="",s=0,o=arguments.length;s!==o;++s){var a=+arguments[s];if(!(a<1114111&&a>>>0===a))throw RangeError("Invalid code point: "+a);a<=65535?i=n.push(a):(a-=65536,i=n.push(55296+(a>>10),a%1024+56320)),i>=16383&&(r+=t.apply(null,n),n.length=0)}return r+t.apply(null,n)};try{Object.defineProperty(String,"fromCodePoint",{value:e,configurable:!0,writable:!0})}catch(t){String.fromCodePoint=e}}(String.fromCharCode),Object.is||(Object.is=function(t,e){return t===e?0!==t||1/t==1/e:t!=t&&e!=e})
|
|
2
|
-
/*! https://mths.be/codepointat v0.2.0 by @mathias */,String.prototype.codePointAt||function(){var t=function(){try{var t={},e=Object.defineProperty,n=e(t,t,t)&&e}catch(t){}return n}(),e=function(t){if(null==this)throw TypeError();var e=String(this),n=e.length,i=t?Number(t):0;if(i!=i&&(i=0),!(i<0||i>=n)){var r,s=e.charCodeAt(i);return s>=55296&&s<=56319&&n>i+1&&(r=e.charCodeAt(i+1))>=56320&&r<=57343?1024*(s-55296)+r-56320+65536:s}};t?t(String.prototype,"codePointAt",{value:e,configurable:!0,writable:!0}):String.prototype.codePointAt=e}(),Math.log10=Math.log10||function(t){return Math.log(t)*Math.LOG10E},t.exports=function(){function t(e,n,i){function r(o,a){if(!n[o]){if(!e[o]){if(!a&&Gi)return Gi(o);if(s)return s(o,!0);var c=new Error("Cannot find module '"+o+"'");throw c.code="MODULE_NOT_FOUND",c}var l=n[o]={exports:{}};e[o][0].call(l.exports,function(t){return r(e[o][1][t]||t)},l,l.exports,t,e,n,i)}return n[o].exports}for(var s=Gi,o=0;o<i.length;o++)r(i[o]);return r}return t}()({1:[function(t,e,n){var i=t("./utils"),r=function(){var t=i.stringToArray,e=["Zero","One","Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten","Eleven","Twelve","Thirteen","Fourteen","Fifteen","Sixteen","Seventeen","Eighteen","Nineteen"],n=["Zeroth","First","Second","Third","Fourth","Fifth","Sixth","Seventh","Eighth","Ninth","Tenth","Eleventh","Twelfth","Thirteenth","Fourteenth","Fifteenth","Sixteenth","Seventeenth","Eighteenth","Nineteenth"],r=["Twenty","Thirty","Forty","Fifty","Sixty","Seventy","Eighty","Ninety","Hundred"],s=["Thousand","Million","Billion","Trillion"];function o(t,i){var o=function t(i,o,a){var c="";if(i<=19)c=(o?" and ":"")+(a?n[i]:e[i]);else if(i<100){var l=Math.floor(i/10),h=i%10;c=(o?" and ":"")+r[l-2],h>0?c+="-"+t(h,!1,a):a&&(c=c.substring(0,c.length-1)+"ieth")}else if(i<1e3){var d=Math.floor(i/100),u=i%100;c=(o?", ":"")+e[d]+" Hundred",u>0?c+=t(u,!0,a):a&&(c+="th")}else{var p=Math.floor(Math.log10(i)/3);p>s.length&&(p=s.length);var f=Math.pow(10,3*p),g=Math.floor(i/f),m=i-g*f;c=(o?", ":"")+t(g,!1,!1)+" "+s[p-1],m>0?c+=t(m,!0,a):a&&(c+="th")}return c};return o(t,!1,i)}var a={};function c(t){var e=t.split(/,\s|\sand\s|[\s\\-]/).map(function(t){return a[t]}),n=[0];e.forEach(function(t){if(t<100){var e=n.pop();e>=1e3&&(n.push(e),e=0),n.push(e+t)}else n.push(n.pop()*t)});var i=n.reduce(function(t,e){return t+e},0);return i}e.forEach(function(t,e){a[t.toLowerCase()]=e}),n.forEach(function(t,e){a[t.toLowerCase()]=e}),r.forEach(function(t,e){var n=t.toLowerCase();a[n]=10*(e+2),a[n.substring(0,t.length-1)+"ieth"]=a[n]}),a.hundredth=100,s.forEach(function(t,e){var n=t.toLowerCase(),i=Math.pow(10,3*(e+1));a[n]=i,a[n+"th"]=i});var l=[[1e3,"m"],[900,"cm"],[500,"d"],[400,"cd"],[100,"c"],[90,"xc"],[50,"l"],[40,"xl"],[10,"x"],[9,"ix"],[5,"v"],[4,"iv"],[1,"i"]],h={M:1e3,D:500,C:100,L:50,X:10,V:5,I:1};function d(t){for(var e=0;e<l.length;e++){var n=l[e];if(t>=n[0])return n[1]+d(t-n[0])}return""}function u(t){for(var e=0,n=1,i=t.length-1;i>=0;i--){var r=t[i],s=h[r];s<n?e-=s:(n=s,e+=s)}return e}function p(t,e){for(var n=[],i=e.charCodeAt(0);t>0;)n.unshift(String.fromCharCode((t-1)%26+i)),t=Math.floor((t-1)/26);return n.join("")}function f(t,e){for(var n=e.charCodeAt(0),i=0,r=0;r<t.length;r++)i+=(t.charCodeAt(t.length-r-1)-n+1)*Math.pow(26,r);return i}function g(t,e){if(void 0!==t)return b(t=Math.floor(t),v(e))}var m={DECIMAL:"decimal",LETTERS:"letters",ROMAN:"roman",WORDS:"words",SEQUENCE:"sequence"},y={UPPER:"upper",LOWER:"lower",TITLE:"title"};function b(e,n){var i,r=e<0;switch(e=Math.abs(e),n.primary){case m.LETTERS:i=p(e,n.case===y.UPPER?"A":"a");break;case m.ROMAN:i=d(e),n.case===y.UPPER&&(i=i.toUpperCase());break;case m.WORDS:i=o(e,n.ordinal),n.case===y.UPPER?i=i.toUpperCase():n.case===y.LOWER&&(i=i.toLowerCase());break;case m.DECIMAL:i=""+e;var s=n.mandatoryDigits-i.length;if(s>0){var a=new Array(s+1).join("0");i=a+i}if(48!==n.zeroCode&&(i=t(i).map(function(t){return String.fromCodePoint(t.codePointAt(0)+n.zeroCode-48)}).join("")),n.regular)for(var c=Math.floor((i.length-1)/n.groupingSeparators.position);c>0;c--){var l=i.length-c*n.groupingSeparators.position;i=i.substr(0,l)+n.groupingSeparators.character+i.substr(l)}else n.groupingSeparators.reverse().forEach(function(t){var e=i.length-t.position;i=i.substr(0,e)+t.character+i.substr(e)});if(n.ordinal){var h={1:"st",2:"nd",3:"rd"}[i[i.length-1]];(!h||i.length>1&&"1"===i[i.length-2])&&(h="th"),i+=h}break;case m.SEQUENCE:throw{code:"D3130",value:n.token}}return r&&(i="-"+i),i}var _=[48,1632,1776,1984,2406,2534,2662,2790,2918,3046,3174,3302,3430,3558,3664,3792,3872,4160,4240,6112,6160,6470,6608,6784,6800,6992,7088,7232,7248,42528,43216,43264,43472,43504,43600,44016,65296];function v(e){var n,i={type:"integer",primary:m.DECIMAL,case:y.LOWER,ordinal:!1},r=e.lastIndexOf(";");switch(-1===r?n=e:(n=e.substring(0,r),"o"===e.substring(r+1)[0]&&(i.ordinal=!0)),n){case"A":i.case=y.UPPER;case"a":i.primary=m.LETTERS;break;case"I":i.case=y.UPPER;case"i":i.primary=m.ROMAN;break;case"W":i.case=y.UPPER,i.primary=m.WORDS;break;case"Ww":i.case=y.TITLE,i.primary=m.WORDS;break;case"w":i.primary=m.WORDS;break;default:var s=null,o=0,a=0,c=[],l=0,h=t(n).map(function(t){return t.codePointAt(0)}).reverse();if(h.forEach(function(t){for(var e=!1,n=0;n<_.length;n++){var i=_[n];if(t>=i&&t<=i+9){if(e=!0,o++,l++,null===s)s=i;else if(i!==s)throw{code:"D3131"};break}}e||(35===t?(l++,a++):c.push({position:l,character:String.fromCodePoint(t)}))}),o>0){i.primary=m.DECIMAL,i.zeroCode=s,i.mandatoryDigits=o,i.optionalDigits=a;var d=function(t){if(0===t.length)return 0;for(var e=t[0].character,n=1;n<t.length;n++)if(t[n].character!==e)return 0;for(var i=t.map(function(t){return t.position}),r=function t(e,n){return 0===n?e:t(n,e%n)},s=i.reduce(r),o=1;o<=i.length;o++)if(-1===i.indexOf(o*s))return 0;return s},u=d(c);u>0?(i.regular=!0,i.groupingSeparators={position:u,character:c[0].character}):(i.regular=!1,i.groupingSeparators=c)}else i.primary=m.SEQUENCE,i.token=n}return i}var x={Y:"1",M:"1",D:"1",d:"1",F:"n",W:"1",w:"1",X:"1",x:"1",H:"1",h:"1",P:"n",m:"01",s:"01",f:"1",Z:"01:01",z:"01:01",C:"n",E:"n"};function w(t){for(var e=[],n={type:"datetime",parts:e},i=function(n,i){if(i>n){var r=t.substring(n,i);r=r.split("]]").join("]"),e.push({type:"literal",value:r})}},r=0,s=0;s<t.length;){if("["===t.charAt(s)){if("["===t.charAt(s+1)){i(r,s),e.push({type:"literal",value:"["}),r=s+=2;continue}if(i(r,s),r=s,-1===(s=t.indexOf("]",r)))throw{code:"D3135"};var o,a=t.substring(r+1,s),c={type:"marker",component:(a=a.split(/\s+/).join("")).charAt(0)},l=a.lastIndexOf(",");if(-1!==l){var h=a.substring(l+1),d=h.indexOf("-"),u=void 0,p=void 0,f=function(t){return void 0===t||"*"===t?void 0:parseInt(t)};-1===d?u=h:(u=h.substring(0,d),p=h.substring(d+1));var g={min:f(u),max:f(p)};c.width=g,o=a.substring(1,l)}else o=a.substring(1);if(1===o.length)c.presentation1=o;else if(o.length>1){var m=o.charAt(o.length-1);-1!=="atco".indexOf(m)?(c.presentation2=m,"o"===m&&(c.ordinal=!0),c.presentation1=o.substring(0,o.length-1)):c.presentation1=o}else c.presentation1=x[c.component];if(void 0===c.presentation1)throw{code:"D3132",value:c.component};if("n"===c.presentation1[0])c.names=y.LOWER;else if("N"===c.presentation1[0])"n"===c.presentation1[1]?c.names=y.TITLE:c.names=y.UPPER;else if(-1!=="YMDdFWwXxHhmsf".indexOf(c.component)){var b=c.presentation1;if(c.presentation2&&(b+=";"+c.presentation2),c.integerFormat=v(b),c.width&&void 0!==c.width.min&&c.integerFormat.mandatoryDigits<c.width.min&&(c.integerFormat.mandatoryDigits=c.width.min),-1!=="YMD".indexOf(c.component))if(c.n=-1,c.width&&void 0!==c.width.max)c.n=c.width.max,c.integerFormat.mandatoryDigits=c.n;else{var _=c.integerFormat.mandatoryDigits+c.integerFormat.optionalDigits;_>=2&&(c.n=_)}}"Z"!==c.component&&"z"!==c.component||(c.integerFormat=v(c.presentation1)),e.push(c),r=s+1}s++}return i(r,s),n}var M=["","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],S=["January","February","March","April","May","June","July","August","September","October","November","December"],A=864e5,E=function(t){var e=Date.UTC(t.year,t.month),n=new Date(e).getUTCDay();return 0===n&&(n=7),n>4?e+(8-n)*A:e-(n-1)*A},k=function t(e,n){return{year:e,month:n,nextMonth:function(){return 11===n?t(e+1,0):t(e,n+1)},previousMonth:function(){return 0===n?t(e-1,11):t(e,n-1)},nextYear:function(){return t(e+1,n)},previousYear:function(){return t(e-1,n)}}},C=function(t,e){return(e-t)/(7*A)+1},T=function(t,e){var n;switch(e){case"Y":n=t.getUTCFullYear();break;case"M":n=t.getUTCMonth()+1;break;case"D":n=t.getUTCDate();break;case"d":n=(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate())-Date.UTC(t.getUTCFullYear(),0))/A+1;break;case"F":0===(n=t.getUTCDay())&&(n=7);break;case"W":var i=k(t.getUTCFullYear(),0),r=E(i),s=Date.UTC(i.year,t.getUTCMonth(),t.getUTCDate()),o=C(r,s);if(o>52)s>=E(i.nextYear())&&(o=1);else if(o<1){var a=E(i.previousYear());o=C(a,s)}n=Math.floor(o);break;case"w":var c=k(t.getUTCFullYear(),t.getUTCMonth()),l=E(c),h=Date.UTC(c.year,c.month,t.getUTCDate()),d=C(l,h);if(d>4)h>=E(c.nextMonth())&&(d=1);else if(d<1){var u=E(c.previousMonth());d=C(u,h)}n=Math.floor(d);break;case"X":var p=k(t.getUTCFullYear(),0),f=E(p),g=E(p.nextYear()),m=t.getTime();n=m<f?p.year-1:m>=g?p.year+1:p.year;break;case"x":var y=k(t.getUTCFullYear(),t.getUTCMonth()),b=E(y),_=y.nextMonth(),v=E(_),x=t.getTime();n=x<b?y.previousMonth().month+1:x>=v?_.month+1:y.month+1;break;case"H":n=t.getUTCHours();break;case"h":n=t.getUTCHours(),0==(n%=12)&&(n=12);break;case"P":n=t.getUTCHours()>=12?"pm":"am";break;case"m":n=t.getUTCMinutes();break;case"s":n=t.getUTCSeconds();break;case"f":n=t.getUTCMilliseconds();break;case"Z":case"z":break;case"C":case"E":n="ISO"}return n},P=null;function D(t,e,n){var i=0,r=0;if(void 0!==n){var s=parseInt(n);i=Math.floor(s/100),r=s%100}var o,a=function(t,e){var n=T(t,e.component);if(-1!=="YMDdFWwXxHhms".indexOf(e.component))if("Y"===e.component&&-1!==e.n&&(n%=Math.pow(10,e.n)),e.names){if("M"===e.component||"x"===e.component)n=S[n-1];else{if("F"!==e.component)throw{code:"D3133",value:e.component};n=M[n]}e.names===y.UPPER?n=n.toUpperCase():e.names===y.LOWER&&(n=n.toLowerCase()),e.width&&n.length>e.width.max&&(n=n.substring(0,e.width.max))}else n=b(n,e.integerFormat);else if("f"===e.component)n=b(n,e.integerFormat);else if("Z"===e.component||"z"===e.component){var s=100*i+r;if(e.integerFormat.regular)n=b(s,e.integerFormat);else{var o=e.integerFormat.mandatoryDigits;if(1===o||2===o)n=b(i,e.integerFormat),0!==r&&(n+=":"+g(r,"00"));else{if(3!==o&&4!==o)throw{code:"D3134",value:o};n=b(s,e.integerFormat)}}s>=0&&(n="+"+n),"z"===e.component&&(n="GMT"+n),0===s&&"t"===e.presentation2&&(n="Z")}return n};void 0===e?(null===P&&(P=w("[Y0001]-[M01]-[D01]T[H01]:[m01]:[s01].[f001][Z01:01t]")),o=P):o=w(e);var c=new Date(t+60*(60*i+r)*1e3),l="";return o.parts.forEach(function(t){"literal"===t.type?l+=t.value:l+=a(c,t)}),l}function O(t){var e={};if("datetime"===t.type)e.type="datetime",e.parts=t.parts.map(function(t){var e={};if("literal"===t.type)e.regex=t.value.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");else if("Z"===t.component||"z"===t.component){var n;Array.isArray(t.integerFormat.groupingSeparators)||(n=t.integerFormat.groupingSeparators),e.regex="","z"===t.component&&(e.regex="GMT"),e.regex+="[-+][0-9]+",n&&(e.regex+=n.character+"[0-9]+"),e.parse=function(e){"z"===t.component&&(e=e.substring(3));var i=0,r=0;return n?(i=Number.parseInt(e.substring(0,e.indexOf(n.character))),r=Number.parseInt(e.substring(e.indexOf(n.character)+1))):e.length-1<=2?i=Number.parseInt(e):(i=Number.parseInt(e.substring(0,3)),r=Number.parseInt(e.substring(3))),60*i+r}}else if(t.integerFormat)t.integerFormat.n=t.n,e=O(t.integerFormat);else{e.regex="[a-zA-Z]+";var i={};if("M"===t.component||"x"===t.component)S.forEach(function(e,n){t.width&&t.width.max?i[e.substring(0,t.width.max)]=n+1:i[e]=n+1});else if("F"===t.component)M.forEach(function(e,n){n>0&&(t.width&&t.width.max?i[e.substring(0,t.width.max)]=n:i[e]=n)});else{if("P"!==t.component)throw{code:"D3133",value:t.component};i={am:0,AM:0,pm:1,PM:1}}e.parse=function(t){return i[t]}}return e.component=t.component,e});else{e.type="integer";var n,i=t.case===y.UPPER;switch(n=t.n&&t.n>0?0===t.optionalDigits?"{".concat(t.n,"}"):"{".concat(t.n-t.optionalDigits,",").concat(t.n,"}"):"+",t.primary){case m.LETTERS:e.regex=i?"[A-Z]+":"[a-z]+",e.parse=function(t){return f(t,i?"A":"a")};break;case m.ROMAN:e.regex=i?"[MDCLXVI]+":"[mdclxvi]+",e.parse=function(t){return u(i?t:t.toUpperCase())};break;case m.WORDS:e.regex="(?:"+Object.keys(a).concat("and","[\\-, ]").join("|")+")+",e.parse=function(t){return c(t.toLowerCase())};break;case m.DECIMAL:e.regex="[0-9]".concat(n),t.ordinal&&(e.regex+="(?:th|st|nd|rd)"),e.parse=function(e){var n=e;return t.ordinal&&(n=e.substring(0,e.length-2)),t.regular?n=n.split(",").join(""):t.groupingSeparators.forEach(function(t){n=n.split(t.character).join("")}),48!==t.zeroCode&&(n=n.split("").map(function(e){return String.fromCodePoint(e.codePointAt(0)-t.zeroCode+48)}).join("")),parseInt(n)};break;case m.SEQUENCE:throw{code:"D3130",value:t.token}}}return e}function z(t,e){if(void 0!==t)return O(v(e)).parse(t)}function L(t,e){var n=O(w(e)),i="^"+n.parts.map(function(t){return"("+t.regex+")"}).join("")+"$",r=new RegExp(i,"i").exec(t);if(null!==r){for(var s=161,o=130,a=84,c=72,l=23,h=47,d={},u=1;u<r.length;u++){var p=n.parts[u-1];p.parse&&(d[p.component]=p.parse(r[u]))}if(0===Object.getOwnPropertyNames(d).length)return;var f=0,g=function(t){f<<=1,f+=t?1:0},m=function(t){return!(~t&f||!(t&f))};"YXMxWwdD".split("").forEach(function(t){return g(d[t])});var y=!m(s)&&m(o),b=m(a),_=!b&&m(c);f=0,"PHhmsf".split("").forEach(function(t){return g(d[t])});var v=!m(l)&&m(h),x=(y?"YD":b?"XxwF":_?"XWF":"YMD")+(v?"Phmsf":"Hmsf"),M=this.environment.timestamp,S=!1,A=!1;if(x.split("").forEach(function(t){if(void 0===d[t])S?(d[t]=-1!=="MDd".indexOf(t)?1:0,A=!0):d[t]=T(M,t);else if(S=!0,A)throw{code:"D3136"}}),d.M>0?d.M-=1:d.M=0,y){var E=Date.UTC(d.Y,0),k=1e3*(d.d-1)*60*60*24,C=new Date(E+k);d.M=C.getUTCMonth(),d.D=C.getUTCDate()}if(b)throw{code:"D3136"};if(_)throw{code:"D3136"};v&&(d.H=12===d.h?0:d.h,1===d.P&&(d.H+=12));var P=Date.UTC(d.Y,d.M,d.D,d.H,d.m,d.s,d.f);return(d.Z||d.z)&&(P-=60*(d.Z||d.z)*1e3),P}}var I=new RegExp("^\\d{4}(-[01]\\d)*(-[0-3]\\d)*(T[0-2]\\d:[0-5]\\d:[0-5]\\d)*(\\.\\d+)?([+-][0-2]\\d:?[0-5]\\d|Z)?$");function R(t,e){if(void 0!==t){if(void 0===e){if(!I.test(t))throw{stack:(new Error).stack,code:"D3110",value:t};return Date.parse(t)}return L.call(this,t,e)}}function j(t,e,n){if(void 0!==t)return D.call(this,t,e,n)}return{formatInteger:g,parseInteger:z,fromMillis:j,toMillis:R}}();e.exports=r},{"./utils":6}],2:[function(t,e,n){(function(n){(function(){function i(t){return i="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},i(t)}function r(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */r=function(){return e};var t,e={},n=Object.prototype,s=n.hasOwnProperty,o=Object.defineProperty||function(t,e,n){t[e]=n.value},a="function"==typeof Symbol?Symbol:{},c=a.iterator||"@@iterator",l=a.asyncIterator||"@@asyncIterator",h=a.toStringTag||"@@toStringTag";function d(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{d({},"")}catch(t){d=function(t,e,n){return t[e]=n}}function u(t,e,n,i){var r=e&&e.prototype instanceof _?e:_,s=Object.create(r.prototype),a=new O(i||[]);return o(s,"_invoke",{value:C(t,n,a)}),s}function p(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}e.wrap=u;var f="suspendedStart",g="suspendedYield",m="executing",y="completed",b={};function _(){}function v(){}function x(){}var w={};d(w,c,function(){return this});var M=Object.getPrototypeOf,S=M&&M(M(z([])));S&&S!==n&&s.call(S,c)&&(w=S);var A=x.prototype=_.prototype=Object.create(w);function E(t){["next","throw","return"].forEach(function(e){d(t,e,function(t){return this._invoke(e,t)})})}function k(t,e){function n(r,o,a,c){var l=p(t[r],t,o);if("throw"!==l.type){var h=l.arg,d=h.value;return d&&"object"==i(d)&&s.call(d,"__await")?e.resolve(d.__await).then(function(t){n("next",t,a,c)},function(t){n("throw",t,a,c)}):e.resolve(d).then(function(t){h.value=t,a(h)},function(t){return n("throw",t,a,c)})}c(l.arg)}var r;o(this,"_invoke",{value:function(t,i){function s(){return new e(function(e,r){n(t,i,e,r)})}return r=r?r.then(s,s):s()}})}function C(e,n,i){var r=f;return function(s,o){if(r===m)throw new Error("Generator is already running");if(r===y){if("throw"===s)throw o;return{value:t,done:!0}}for(i.method=s,i.arg=o;;){var a=i.delegate;if(a){var c=T(a,i);if(c){if(c===b)continue;return c}}if("next"===i.method)i.sent=i._sent=i.arg;else if("throw"===i.method){if(r===f)throw r=y,i.arg;i.dispatchException(i.arg)}else"return"===i.method&&i.abrupt("return",i.arg);r=m;var l=p(e,n,i);if("normal"===l.type){if(r=i.done?y:g,l.arg===b)continue;return{value:l.arg,done:i.done}}"throw"===l.type&&(r=y,i.method="throw",i.arg=l.arg)}}}function T(e,n){var i=n.method,r=e.iterator[i];if(r===t)return n.delegate=null,"throw"===i&&e.iterator.return&&(n.method="return",n.arg=t,T(e,n),"throw"===n.method)||"return"!==i&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+i+"' method")),b;var s=p(r,e.iterator,n.arg);if("throw"===s.type)return n.method="throw",n.arg=s.arg,n.delegate=null,b;var o=s.arg;return o?o.done?(n[e.resultName]=o.value,n.next=e.nextLoc,"return"!==n.method&&(n.method="next",n.arg=t),n.delegate=null,b):o:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,b)}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 D(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function O(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(P,this),this.reset(!0)}function z(e){if(e||""===e){var n=e[c];if(n)return n.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,o=function n(){for(;++r<e.length;)if(s.call(e,r))return n.value=e[r],n.done=!1,n;return n.value=t,n.done=!0,n};return o.next=o}}throw new TypeError(i(e)+" is not iterable")}return v.prototype=x,o(A,"constructor",{value:x,configurable:!0}),o(x,"constructor",{value:v,configurable:!0}),v.displayName=d(x,h,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,x):(t.__proto__=x,d(t,h,"GeneratorFunction")),t.prototype=Object.create(A),t},e.awrap=function(t){return{__await:t}},E(k.prototype),d(k.prototype,l,function(){return this}),e.AsyncIterator=k,e.async=function(t,n,i,r,s){void 0===s&&(s=Promise);var o=new k(u(t,n,i,r),s);return e.isGeneratorFunction(n)?o:o.next().then(function(t){return t.done?t.value:o.next()})},E(A),d(A,h,"Generator"),d(A,c,function(){return this}),d(A,"toString",function(){return"[object Generator]"}),e.keys=function(t){var e=Object(t),n=[];for(var i in e)n.push(i);return n.reverse(),function t(){for(;n.length;){var i=n.pop();if(i in e)return t.value=i,t.done=!1,t}return t.done=!0,t}},e.values=z,O.prototype={constructor:O,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(D),!e)for(var n in this)"t"===n.charAt(0)&&s.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=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 n=this;function i(i,r){return a.type="throw",a.arg=e,n.next=i,r&&(n.method="next",n.arg=t),!!r}for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r],a=o.completion;if("root"===o.tryLoc)return i("end");if(o.tryLoc<=this.prev){var c=s.call(o,"catchLoc"),l=s.call(o,"finallyLoc");if(c&&l){if(this.prev<o.catchLoc)return i(o.catchLoc,!0);if(this.prev<o.finallyLoc)return i(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return i(o.catchLoc,!0)}else{if(!l)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return i(o.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&s.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var r=i;break}}r&&("break"===t||"continue"===t)&&r.tryLoc<=e&&e<=r.finallyLoc&&(r=null);var o=r?r.completion:{};return o.type=t,o.arg=e,r?(this.method="next",this.next=r.finallyLoc,b):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),b},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),D(n),b}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var i=n.completion;if("throw"===i.type){var r=i.arg;D(n)}return r}}throw new Error("illegal catch attempt")},delegateYield:function(e,n,i){return this.delegate={iterator:z(e),resultName:n,nextLoc:i},"next"===this.method&&(this.arg=t),b}},e}var s=t("./utils"),o=function(){var t=r().mark(H),e=r().mark(Y),o=r().mark(G),a=r().mark(V),c=r().mark(Q),l=r().mark(ut),h=r().mark(pt),d=r().mark(ft),u=r().mark(mt),p=r().mark(St),f=r().mark(Ct),g=r().mark(Dt),m=s.isNumeric,y=s.isArrayOfStrings,b=s.isArrayOfNumbers,_=s.createSequence,v=s.isSequence,x=s.isFunction,w=s.isLambda,M=s.isIterable,S=s.getFunctionArity,A=s.isDeepEqual,E=s.stringToArray;function k(t){if(void 0!==t){var e=0;return t.forEach(function(t){e+=t}),e}}function C(t){return void 0===t?0:t.length}function T(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 D(t){if(void 0!==t&&0!==t.length){var e=0;return t.forEach(function(t){e+=t}),e/t.length}}function O(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(void 0!==t){var n;if("string"==typeof t)n=t;else if(x(t))n="";else{if("number"==typeof t&&!isFinite(t))throw{code:"D3001",value:t,stack:(new Error).stack};var i=e?2:0;Array.isArray(t)&&t.outerWrapper&&(t=t[0]),n=JSON.stringify(t,function(t,e){return null!=e&&e.toPrecision&&m(e)?Number(e.toPrecision(15)):e&&x(e)?"":e},i)}return n}}function z(t,e,n){if(void 0!==t){var i=E(t),r=i.length;if(r+e<0&&(e=0),void 0!==n){if(n<=0)return"";var s=e>=0?e+n:r+e+n;return i.slice(e,s).join("")}return i.slice(e).join("")}}function L(t,e){if(void 0!==t){var n=t.indexOf(e);return n>-1?t.substr(0,n):t}}function I(t,e){if(void 0!==t){var n=t.indexOf(e);return n>-1?t.substr(n+e.length):t}}function R(t){if(void 0!==t)return t.toLowerCase()}function j(t){if(void 0!==t)return t.toUpperCase()}function F(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 N(t,e,n){if(void 0!==t){var i;void 0!==n&&0!==n.length||(n=" ");var r=Math.abs(e)-F(t);if(r>0){var s=new Array(r+1).join(n);n.length>1&&(s=z(s,0,r)),i=e>0?t+s:s+t}else i=t;return i}}function H(e,n){var i;return r().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(i=e.apply(this,[n]),!M(i)){t.next=4;break}return t.delegateYield(i,"t0",3);case 3:i=t.t0;case 4:if(!i||"number"==typeof i.start||"number"===i.end||Array.isArray(i.groups)||x(i.next)){t.next=6;break}throw{code:"T1010",stack:(new Error).stack};case 6:return t.abrupt("return",i);case 7:case"end":return t.stop()}},t,this)}function Y(t,n){var i,s;return r().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==t){e.next=2;break}return e.abrupt("return",void 0);case 2:if("string"!=typeof n){e.next=6;break}i=-1!==t.indexOf(n),e.next=9;break;case 6:return e.delegateYield(H(n,t),"t0",7);case 7:s=e.t0,i=void 0!==s;case 9:return e.abrupt("return",i);case 10:case"end":return e.stop()}},e)}function G(t,e,n){var i,s,a;return r().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(!(n<0)){r.next=4;break}throw{stack:(new Error).stack,value:n,code:"D3040",index:3};case 4:if(i=_(),!(void 0===n||n>0)){r.next=17;break}return s=0,r.delegateYield(H(e,t),"t0",8);case 8:if(void 0===(a=r.t0)){r.next=17;break}case 10:if(void 0===a||!(void 0===n||s<n)){r.next=17;break}return i.push({match:a.match,index:a.start,groups:a.groups}),r.delegateYield(H(a.next),"t1",13);case 13:a=r.t1,s++,r.next=10;break;case 17:return r.abrupt("return",i);case 18:case"end":return r.stop()}},o)}function V(t,e,n,i){var s,o,c,l,h,d,u,p;return r().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(s=this,""!==e){r.next=5;break}throw{code:"D3010",stack:(new Error).stack,value:e,index:2};case 5:if(!(i<0)){r.next=7;break}throw{code:"D3011",stack:(new Error).stack,value:i,index:4};case 7:if(o="string"==typeof n?function(t){for(var e="",i=0,r=n.indexOf("$",i);-1!==r&&i<n.length;){e+=n.substring(i,r),i=r+1;var s=n.charAt(i);if("$"===s)e+="$",i++;else if("0"===s)e+=t.match,i++;else{var o;if(o=0===t.groups.length?1:Math.floor(Math.log(t.groups.length)*Math.LOG10E)+1,r=parseInt(n.substring(i,i+o),10),o>1&&r>t.groups.length&&(r=parseInt(n.substring(i,i+o-1),10)),isNaN(r))e+="$";else{if(t.groups.length>0){var a=t.groups[r-1];void 0!==a&&(e+=a)}i+=r.toString().length}}r=n.indexOf("$",i)}return e+=n.substring(i)}:n,c="",l=0,!(void 0===i||i>0)){r.next=44;break}if(h=0,"string"!=typeof e){r.next=18;break}for(d=t.indexOf(e,l);-1!==d&&(void 0===i||h<i);)c+=t.substring(l,d),c+=n,l=d+e.length,h++,d=t.indexOf(e,l);c+=t.substring(l),r.next=42;break;case 18:return r.delegateYield(H(e,t),"t0",19);case 19:if(void 0===(u=r.t0)){r.next=41;break}case 21:if(void 0===u||!(void 0===i||h<i)){r.next=38;break}if(c+=t.substring(l,u.start),p=o.apply(s,[u]),!M(p)){r.next=27;break}return r.delegateYield(p,"t1",26);case 26:p=r.t1;case 27:if("string"!=typeof p){r.next=31;break}c+=p,r.next=32;break;case 31:throw{code:"D3012",stack:(new Error).stack,value:p};case 32:return l=u.start+u.match.length,h++,r.delegateYield(H(u.next),"t2",35);case 35:u=r.t2,r.next=21;break;case 38:c+=t.substring(l),r.next=42;break;case 41:c=t;case 42:r.next=45;break;case 44:c=t;case 45:return r.abrupt("return",c);case 46:case"end":return r.stop()}},a,this)}function U(t){if(void 0!==t){var e="undefined"!=typeof window?window.btoa:function(t){return new n.Buffer.from(t,"binary").toString("base64")};return e(t)}}function $(t){if(void 0!==t){var e="undefined"!=typeof window?window.atob:function(t){return new n.Buffer.from(t,"base64").toString("binary")};return e(t)}}function W(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 q(t){if(void 0!==t){var e;try{e=decodeURIComponent(t)}catch(e){throw{code:"D3140",stack:(new Error).stack,value:t,functionName:"decodeUrlComponent"}}return e}}function K(t){if(void 0!==t){var e;try{e=decodeURI(t)}catch(e){throw{code:"D3140",stack:(new Error).stack,value:t,functionName:"decodeUrl"}}return e}}function Q(t,e,n){var i,s,o,a;return r().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(!(n<0)){r.next=4;break}throw{code:"D3020",stack:(new Error).stack,value:n,index:3};case 4:if(i=[],!(void 0===n||n>0)){r.next=27;break}if("string"!=typeof e){r.next=10;break}i=t.split(e,n),r.next=27;break;case 10:return s=0,r.delegateYield(H(e,t),"t0",12);case 12:if(void 0===(o=r.t0)){r.next=26;break}a=0;case 15:if(void 0===o||!(void 0===n||s<n)){r.next=23;break}return i.push(t.substring(a,o.start)),a=o.end,r.delegateYield(H(o.next),"t1",19);case 19:o=r.t1,s++,r.next=15;break;case 23:(void 0===n||s<n)&&i.push(t.substring(a)),r.next=27;break;case 26:i.push(t);case 27:return r.abrupt("return",i);case 28:case"end":return r.stop()}},c)}function Z(t,e){if(void 0!==t)return void 0===e&&(e=""),t.join(e)}function J(t,e,n){if(void 0!==t){var i={"decimal-separator":".","grouping-separator":",","exponent-separator":"e",infinity:"Infinity","minus-sign":"-",NaN:"NaN",percent:"%","per-mille":"‰","zero-digit":"0",digit:"#","pattern-separator":";"};void 0!==n&&Object.keys(n).forEach(function(t){i[t]=n[t]});for(var r=[],s=i["zero-digit"].charCodeAt(0),o=s;o<s+10;o++)r.push(String.fromCharCode(o));var a=r.concat([i["decimal-separator"],i["exponent-separator"],i["grouping-separator"],i.digit,i["pattern-separator"]]),c=e.split(i["pattern-separator"]);if(c.length>2)throw{code:"D3080",stack:(new Error).stack};var l=function(t){var e,n,r,s,o=function(){for(var e,n=0;n<t.length;n++)if(e=t.charAt(n),-1!==a.indexOf(e)&&e!==i["exponent-separator"])return t.substring(0,n)}(),c=function(){for(var e,n=t.length-1;n>=0;n--)if(e=t.charAt(n),-1!==a.indexOf(e)&&e!==i["exponent-separator"])return t.substring(n+1)}(),l=t.substring(o.length,t.length-c.length),h=t.indexOf(i["exponent-separator"],o.length);-1===h||h>t.length-c.length?(e=l,n=void 0):(e=l.substring(0,h),n=l.substring(h+1));var d=e.indexOf(i["decimal-separator"]);return-1===d?(r=e,s=c):(r=e.substring(0,d),s=e.substring(d+1)),{prefix:o,suffix:c,activePart:l,mantissaPart:e,exponentPart:n,integerPart:r,fractionalPart:s,subpicture:t}},h=function(t){var e,n,s=t.subpicture,o=s.indexOf(i["decimal-separator"]);o!==s.lastIndexOf(i["decimal-separator"])&&(e="D3081"),s.indexOf(i.percent)!==s.lastIndexOf(i.percent)&&(e="D3082"),s.indexOf(i["per-mille"])!==s.lastIndexOf(i["per-mille"])&&(e="D3083"),-1!==s.indexOf(i.percent)&&-1!==s.indexOf(i["per-mille"])&&(e="D3084");var c=!1;for(n=0;n<t.mantissaPart.length;n++){var l=t.mantissaPart.charAt(n);if(-1!==r.indexOf(l)||l===i.digit){c=!0;break}}c||(e="D3085"),-1!==t.activePart.split("").map(function(t){return-1===a.indexOf(t)?"p":"a"}).join("").indexOf("p")&&(e="D3086"),-1!==o?s.charAt(o-1)!==i["grouping-separator"]&&s.charAt(o+1)!==i["grouping-separator"]||(e="D3087"):t.integerPart.charAt(t.integerPart.length-1)===i["grouping-separator"]&&(e="D3088"),-1!==s.indexOf(i["grouping-separator"]+i["grouping-separator"])&&(e="D3089");var h=t.integerPart.indexOf(i.digit);-1!==h&&t.integerPart.substring(0,h).split("").filter(function(t){return r.indexOf(t)>-1}).length>0&&(e="D3090"),-1!==(h=t.fractionalPart.lastIndexOf(i.digit))&&t.fractionalPart.substring(h).split("").filter(function(t){return r.indexOf(t)>-1}).length>0&&(e="D3091");var d="string"==typeof t.exponentPart;if(d&&t.exponentPart.length>0&&(-1!==s.indexOf(i.percent)||-1!==s.indexOf(i["per-mille"]))&&(e="D3092"),d&&(0===t.exponentPart.length||t.exponentPart.split("").filter(function(t){return-1===r.indexOf(t)}).length>0)&&(e="D3093"),e)throw{code:e,stack:(new Error).stack}},d=function(t){var e=function(e,n){for(var s=[],o=e.indexOf(i["grouping-separator"]);-1!==o;){var a=(n?e.substring(0,o):e.substring(o)).split("").filter(function(t){return-1!==r.indexOf(t)||t===i.digit}).length;s.push(a),o=t.integerPart.indexOf(i["grouping-separator"],o+1)}return s},n=e(t.integerPart),s=function(t){if(0===t.length)return 0;for(var e=function t(e,n){return 0===n?e:t(n,e%n)},n=t.reduce(e),i=1;i<=t.length;i++)if(-1===t.indexOf(i*n))return 0;return n},o=s(n),a=e(t.fractionalPart,!0),c=t.integerPart.split("").filter(function(t){return-1!==r.indexOf(t)}).length,l=c,h=t.fractionalPart.split(""),d=h.filter(function(t){return-1!==r.indexOf(t)}).length,u=h.filter(function(t){return-1!==r.indexOf(t)||t===i.digit}).length,p="string"==typeof t.exponentPart;0===c&&0===u&&(p?(d=1,u=1):c=1),p&&0===c&&-1!==t.integerPart.indexOf(i.digit)&&(c=1),0===c&&0===d&&(d=1);var f=0;return p&&(f=t.exponentPart.split("").filter(function(t){return-1!==r.indexOf(t)}).length),{integerPartGroupingPositions:n,regularGrouping:o,minimumIntegerPartSize:c,scalingFactor:l,prefix:t.prefix,fractionalPartGroupingPositions:a,minimumFactionalPartSize:d,maximumFactionalPartSize:u,minimumExponentSize:f,suffix:t.suffix,picture:t.subpicture}},u=c.map(l);u.forEach(h);var p,f,g,m,y=u.map(d),b=i["minus-sign"],_=i["zero-digit"],v=i["decimal-separator"],x=i["grouping-separator"];if(1===y.length&&(y.push(JSON.parse(JSON.stringify(y[0]))),y[1].prefix=b+y[1].prefix),f=-1!==(p=t>=0?y[0]:y[1]).picture.indexOf(i.percent)?100*t:-1!==p.picture.indexOf(i["per-mille"])?1e3*t:t,0===p.minimumExponentSize)g=f;else{var w=Math.pow(10,p.scalingFactor),M=Math.pow(10,p.scalingFactor-1);for(g=f,m=0;g<M;)g*=10,m-=1;for(;g>w;)g/=10,m+=1}var S=function(t,e){var n=Math.abs(t).toFixed(e);return"0"!==_&&(n=n.split("").map(function(t){return t>="0"&&t<="9"?r[t.charCodeAt(0)-48]:t}).join("")),n},A=S(st(g,p.maximumFactionalPartSize),p.maximumFactionalPartSize),E=A.indexOf(".");for(-1===E?A+=v:A=A.replace(".",v);A.charAt(0)===_;)A=A.substring(1);for(;A.charAt(A.length-1)===_;)A=A.substring(0,A.length-1);E=A.indexOf(v);var k=p.minimumIntegerPartSize-E,C=p.minimumFactionalPartSize-(A.length-E-1);if(A=(k>0?new Array(k+1).join(_):"")+A,A+=C>0?new Array(C+1).join(_):"",E=A.indexOf(v),p.regularGrouping>0)for(var T=Math.floor((E-1)/p.regularGrouping),P=1;P<=T;P++)A=[A.slice(0,E-P*p.regularGrouping),x,A.slice(E-P*p.regularGrouping)].join("");else p.integerPartGroupingPositions.forEach(function(t){A=[A.slice(0,E-t),x,A.slice(E-t)].join(""),E++});if(E=A.indexOf(v),p.fractionalPartGroupingPositions.forEach(function(t){A=[A.slice(0,t+E+1),x,A.slice(t+E+1)].join("")}),E=A.indexOf(v),-1!==p.picture.indexOf(v)&&E!==A.length-1||(A=A.substring(0,A.length-1)),void 0!==m){var D=S(m,0);(k=p.minimumExponentSize-D.length)>0&&(D=new Array(k+1).join(_)+D),A=A+i["exponent-separator"]+(m<0?b:"")+D}return A=p.prefix+A+p.suffix}}function tt(t,e){if(void 0!==t){if(t=st(t),(e=void 0===e?10:st(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 nt(t){if(void 0!==t)return Math.abs(t)}function it(t){if(void 0!==t)return Math.floor(t)}function rt(t){if(void 0!==t)return Math.ceil(t)}function st(t,e){var n;if(void 0!==t){if(e){var i=t.toString().split("e");t=+(i[0]+"e"+(i[1]?+i[1]+e:e))}var r=(n=Math.round(t))-t;return.5===Math.abs(r)&&1===Math.abs(n%2)&&(n-=1),e&&(i=n.toString().split("e"),n=+(i[0]+"e"+(i[1]?+i[1]-e:-e))),Object.is(n,-0)&&(n=0),n}}function ot(t){if(void 0!==t){if(t<0)throw{stack:(new Error).stack,code:"D3060",index:1,value:t};return Math.sqrt(t)}}function at(t,e){var n;if(void 0!==t){if(n=Math.pow(t,e),!isFinite(n))throw{stack:(new Error).stack,code:"D3061",index:1,value:t,exp:e};return n}}function ct(){return Math.random()}function lt(t){if(void 0!==t){var e=!1;return Array.isArray(t)?1===t.length?e=lt(t[0]):t.length>1&&(e=t.filter(function(t){return lt(t)}).length>0):"string"==typeof t?t.length>0&&(e=!0):m(t)?0!==t&&(e=!0):null!==t&&"object"===i(t)?Object.keys(t).length>0&&(e=!0):"boolean"==typeof t&&!0===t&&(e=!0),e}}function ht(t){if(void 0!==t)return!lt(t)}function dt(t,e,n,i){var r=[e],s=S(t);return s>=2&&r.push(n),s>=3&&r.push(i),r}function ut(t,e){var n,i,s,o;return r().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:n=_(),i=0;case 4:if(!(i<t.length)){r.next=12;break}return s=dt(e,t[i],i,t),r.delegateYield(e.apply(this,s),"t0",7);case 7:void 0!==(o=r.t0)&&n.push(o);case 9:i++,r.next=4;break;case 12:return r.abrupt("return",n);case 13:case"end":return r.stop()}},l,this)}function pt(t,e){var n,i,s,o;return r().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:n=_(),i=0;case 4:if(!(i<t.length)){r.next=13;break}return s=t[i],o=dt(e,s,i,t),r.delegateYield(e.apply(this,o),"t0",8);case 8:lt(r.t0)&&n.push(s);case 10:i++,r.next=4;break;case 13:return r.abrupt("return",n);case 14:case"end":return r.stop()}},h,this)}function ft(t,e){var n,i,s,o,a,c,l;return r().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:n=!1,s=0;case 4:if(!(s<t.length)){r.next=22;break}if(o=t[s],a=!0,void 0===e){r.next=12;break}return c=dt(e,o,s,t),r.delegateYield(e.apply(this,c),"t0",10);case 10:l=r.t0,a=lt(l);case 12:if(!a){r.next=19;break}if(n){r.next=18;break}i=o,n=!0,r.next=19;break;case 18:throw{stack:(new Error).stack,code:"D3138",index:s};case 19:s++,r.next=4;break;case 22:if(n){r.next=24;break}throw{stack:(new Error).stack,code:"D3139"};case 24:return r.abrupt("return",i);case 25:case"end":return r.stop()}},d,this)}function gt(){for(var t=[],e=Array.prototype.slice.call(arguments),n=Math.min.apply(Math,e.map(function(t){return Array.isArray(t)?t.length:0})),i=0;i<n;i++){var r=e.map(function(t){return t[i]});t.push(r)}return t}function mt(t,e,n){var i,s,o,a;return r().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(!((s=S(e))<2)){r.next=5;break}throw{stack:(new Error).stack,code:"D3050",index:1};case 5:void 0===n&&t.length>0?(i=t[0],o=1):(i=n,o=0);case 6:if(!(o<t.length)){r.next=15;break}return a=[i,t[o]],s>=3&&a.push(o),s>=4&&a.push(t),r.delegateYield(e.apply(this,a),"t0",11);case 11:i=r.t0,o++,r.next=6;break;case 15:return r.abrupt("return",i);case 16:case"end":return r.stop()}},u,this)}function yt(t){var e=_();if(Array.isArray(t)){var n={};t.forEach(function(t){yt(t).forEach(function(t){n[t]=!0})}),e=yt(n)}else null===t||"object"!==i(t)||w(t)||Object.keys(t).forEach(function(t){return e.push(t)});return e}function bt(t,e){var n;if(Array.isArray(t)){n=_();for(var r=0;r<t.length;r++){var s=bt(t[r],e);void 0!==s&&(Array.isArray(s)?s.forEach(function(t){return n.push(t)}):n.push(s))}}else null!==t&&"object"===i(t)&&(n=t[e]);return n}function _t(t,e){return void 0===t?e:void 0===e?t:(Array.isArray(t)||(t=_(t)),Array.isArray(e)||(e=[e]),t.concat(e))}function vt(t){return void 0!==t}function xt(t){var e=_();if(Array.isArray(t))t.forEach(function(t){e=_t(e,xt(t))});else if(null===t||"object"!==i(t)||w(t))e=t;else for(var n in t){var r={};r[n]=t[n],e.push(r)}return e}function wt(t){if(void 0!==t){var e={};return t.forEach(function(t){for(var n in t)e[n]=t[n]}),e}}function Mt(t){if(void 0!==t){if(t.length<=1)return t;for(var e=t.length,n=new Array(e),i=0;i<e;i++)n[e-i-1]=t[i];return n}}function St(t,e){var n,i,s,o;return r().wrap(function(a){for(;;)switch(a.prev=a.next){case 0:n=_(),a.t0=r().keys(t);case 2:if((a.t1=a.t0()).done){a.next=10;break}return i=a.t1.value,s=dt(e,t[i],i,t),a.delegateYield(e.apply(this,s),"t2",6);case 6:void 0!==(o=a.t2)&&n.push(o),a.next=2;break;case 10:return a.abrupt("return",n);case 11:case"end":return a.stop()}},p,this)}function At(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 kt(t){if(void 0!==t)return null===t?"null":m(t)?"number":"string"==typeof t?"string":"boolean"==typeof t?"boolean":Array.isArray(t)?"array":x(t)?"function":"object"}function Ct(t,e){var n,i,s,o;return r().wrap(function(a){for(;;)switch(a.prev=a.next){case 0:if(void 0!==t){a.next=2;break}return a.abrupt("return",void 0);case 2:if(!(t.length<=1)){a.next=4;break}return a.abrupt("return",t);case 4:if(void 0!==e){a.next=10;break}if(b(t)||y(t)){a.next=7;break}throw{stack:(new Error).stack,code:"D3070",index:1};case 7:n=r().mark(function t(e,n){return r().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",e>n);case 1:case"end":return t.stop()}},t)}),a.next=11;break;case 10:n=e;case 11:return i=r().mark(function t(e,i){var s,o;return r().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return s=r().mark(function t(e,i,s){return r().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:if(0!==i.length){r.next=4;break}Array.prototype.push.apply(e,s),r.next=16;break;case 4:if(0!==s.length){r.next=8;break}Array.prototype.push.apply(e,i),r.next=16;break;case 8:return r.delegateYield(n(i[0],s[0]),"t0",9);case 9:if(!r.t0){r.next=14;break}return e.push(s[0]),r.delegateYield(t(e,i,s.slice(1)),"t1",12);case 12:r.next=16;break;case 14:return e.push(i[0]),r.delegateYield(t(e,i.slice(1),s),"t2",16);case 16:case"end":return r.stop()}},t)}),o=[],t.delegateYield(s(o,e,i),"t0",3);case 3:return t.abrupt("return",o);case 4:case"end":return t.stop()}},t)}),s=r().mark(function t(e){var n,s,o;return r().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:if(Array.isArray(e)&&!(e.length<=1)){r.next=4;break}return r.abrupt("return",e);case 4:return n=Math.floor(e.length/2),s=e.slice(0,n),o=e.slice(n),r.delegateYield(t(s),"t0",8);case 8:return s=r.t0,r.delegateYield(t(o),"t1",10);case 10:return o=r.t1,r.delegateYield(i(s,o),"t2",12);case 12:return r.abrupt("return",r.t2);case 13:case"end":return r.stop()}},t)}),a.delegateYield(s(t),"t0",14);case 14:return o=a.t0,a.abrupt("return",o);case 16:case"end":return a.stop()}},f)}function Tt(t){if(void 0!==t){if(t.length<=1)return t;for(var e=new Array(t.length),n=0;n<t.length;n++){var i=Math.floor(Math.random()*(n+1));n!==i&&(e[n]=e[i]),e[i]=t[n]}return e}}function Pt(t){if(void 0!==t){if(!Array.isArray(t)||t.length<=1)return t;for(var e=v(t)?_():[],n=0;n<t.length;n++){for(var i=t[n],r=!1,s=0;s<e.length;s++)if(A(i,e[s])){r=!0;break}r||e.push(i)}return e}}function Dt(t,e){var n,i,s,o;return r().wrap(function(a){for(;;)switch(a.prev=a.next){case 0:n={},a.t0=r().keys(t);case 2:if((a.t1=a.t0()).done){a.next=11;break}return i=a.t1.value,s=t[i],o=dt(e,s,i,t),a.delegateYield(e.apply(this,o),"t2",7);case 7:lt(a.t2)&&(n[i]=s),a.next=2;break;case 11:return 0===Object.keys(n).length&&(n=void 0),a.abrupt("return",n);case 13:case"end":return a.stop()}},g,this)}return{sum:k,count:C,max:T,min:P,average:D,string:O,substring:z,substringBefore:L,substringAfter:I,lowercase:R,uppercase:j,length:F,trim:B,pad:N,match:G,contains:Y,replace:V,split:Q,join:Z,formatNumber:J,formatBase:tt,number:et,floor:it,ceil:rt,round:st,abs:nt,sqrt:ot,power:at,random:ct,boolean:lt,not:ht,map:ut,zip:gt,filter:pt,single:ft,foldLeft:mt,sift:Dt,keys:yt,lookup:bt,append:_t,exists:vt,spread:xt,merge:wt,reverse:Mt,each:St,error:At,assert:Et,type:kt,sort:Ct,shuffle:Tt,distinct:Pt,base64encode:U,base64decode:$,encodeUrlComponent:W,encodeUrl:X,decodeUrlComponent:q,decodeUrl:K}}();e.exports=o}).call(this)}).call(this,void 0!==Hi?Hi:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./utils":6}],3:[function(t,e,n){function i(t){return i="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},i(t)}function r(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */r=function(){return e};var t,e={},n=Object.prototype,s=n.hasOwnProperty,o=Object.defineProperty||function(t,e,n){t[e]=n.value},a="function"==typeof Symbol?Symbol:{},c=a.iterator||"@@iterator",l=a.asyncIterator||"@@asyncIterator",h=a.toStringTag||"@@toStringTag";function d(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{d({},"")}catch(t){d=function(t,e,n){return t[e]=n}}function u(t,e,n,i){var r=e&&e.prototype instanceof _?e:_,s=Object.create(r.prototype),a=new O(i||[]);return o(s,"_invoke",{value:C(t,n,a)}),s}function p(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}e.wrap=u;var f="suspendedStart",g="suspendedYield",m="executing",y="completed",b={};function _(){}function v(){}function x(){}var w={};d(w,c,function(){return this});var M=Object.getPrototypeOf,S=M&&M(M(z([])));S&&S!==n&&s.call(S,c)&&(w=S);var A=x.prototype=_.prototype=Object.create(w);function E(t){["next","throw","return"].forEach(function(e){d(t,e,function(t){return this._invoke(e,t)})})}function k(t,e){function n(r,o,a,c){var l=p(t[r],t,o);if("throw"!==l.type){var h=l.arg,d=h.value;return d&&"object"==i(d)&&s.call(d,"__await")?e.resolve(d.__await).then(function(t){n("next",t,a,c)},function(t){n("throw",t,a,c)}):e.resolve(d).then(function(t){h.value=t,a(h)},function(t){return n("throw",t,a,c)})}c(l.arg)}var r;o(this,"_invoke",{value:function(t,i){function s(){return new e(function(e,r){n(t,i,e,r)})}return r=r?r.then(s,s):s()}})}function C(e,n,i){var r=f;return function(s,o){if(r===m)throw new Error("Generator is already running");if(r===y){if("throw"===s)throw o;return{value:t,done:!0}}for(i.method=s,i.arg=o;;){var a=i.delegate;if(a){var c=T(a,i);if(c){if(c===b)continue;return c}}if("next"===i.method)i.sent=i._sent=i.arg;else if("throw"===i.method){if(r===f)throw r=y,i.arg;i.dispatchException(i.arg)}else"return"===i.method&&i.abrupt("return",i.arg);r=m;var l=p(e,n,i);if("normal"===l.type){if(r=i.done?y:g,l.arg===b)continue;return{value:l.arg,done:i.done}}"throw"===l.type&&(r=y,i.method="throw",i.arg=l.arg)}}}function T(e,n){var i=n.method,r=e.iterator[i];if(r===t)return n.delegate=null,"throw"===i&&e.iterator.return&&(n.method="return",n.arg=t,T(e,n),"throw"===n.method)||"return"!==i&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+i+"' method")),b;var s=p(r,e.iterator,n.arg);if("throw"===s.type)return n.method="throw",n.arg=s.arg,n.delegate=null,b;var o=s.arg;return o?o.done?(n[e.resultName]=o.value,n.next=e.nextLoc,"return"!==n.method&&(n.method="next",n.arg=t),n.delegate=null,b):o:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,b)}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 D(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function O(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(P,this),this.reset(!0)}function z(e){if(e||""===e){var n=e[c];if(n)return n.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,o=function n(){for(;++r<e.length;)if(s.call(e,r))return n.value=e[r],n.done=!1,n;return n.value=t,n.done=!0,n};return o.next=o}}throw new TypeError(i(e)+" is not iterable")}return v.prototype=x,o(A,"constructor",{value:x,configurable:!0}),o(x,"constructor",{value:v,configurable:!0}),v.displayName=d(x,h,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,x):(t.__proto__=x,d(t,h,"GeneratorFunction")),t.prototype=Object.create(A),t},e.awrap=function(t){return{__await:t}},E(k.prototype),d(k.prototype,l,function(){return this}),e.AsyncIterator=k,e.async=function(t,n,i,r,s){void 0===s&&(s=Promise);var o=new k(u(t,n,i,r),s);return e.isGeneratorFunction(n)?o:o.next().then(function(t){return t.done?t.value:o.next()})},E(A),d(A,h,"Generator"),d(A,c,function(){return this}),d(A,"toString",function(){return"[object Generator]"}),e.keys=function(t){var e=Object(t),n=[];for(var i in e)n.push(i);return n.reverse(),function t(){for(;n.length;){var i=n.pop();if(i in e)return t.value=i,t.done=!1,t}return t.done=!0,t}},e.values=z,O.prototype={constructor:O,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(D),!e)for(var n in this)"t"===n.charAt(0)&&s.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=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 n=this;function i(i,r){return a.type="throw",a.arg=e,n.next=i,r&&(n.method="next",n.arg=t),!!r}for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r],a=o.completion;if("root"===o.tryLoc)return i("end");if(o.tryLoc<=this.prev){var c=s.call(o,"catchLoc"),l=s.call(o,"finallyLoc");if(c&&l){if(this.prev<o.catchLoc)return i(o.catchLoc,!0);if(this.prev<o.finallyLoc)return i(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return i(o.catchLoc,!0)}else{if(!l)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return i(o.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&s.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var r=i;break}}r&&("break"===t||"continue"===t)&&r.tryLoc<=e&&e<=r.finallyLoc&&(r=null);var o=r?r.completion:{};return o.type=t,o.arg=e,r?(this.method="next",this.next=r.finallyLoc,b):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),b},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),D(n),b}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var i=n.completion;if("throw"===i.type){var r=i.arg;D(n)}return r}}throw new Error("illegal catch attempt")},delegateYield:function(e,n,i){return this.delegate={iterator:z(e),resultName:n,nextLoc:i},"next"===this.method&&(this.arg=t),b}},e}var s=t("./datetime"),o=t("./functions"),a=t("./utils"),c=t("./parser"),l=t("./signature"),h=function(){var t=r().mark(N),e=r().mark(H),n=r().mark(G),h=r().mark(V),d=r().mark(U),u=r().mark($),p=r().mark(W),f=r().mark(X),g=r().mark(st),m=r().mark(ct),y=r().mark(dt),b=r().mark(ut),_=r().mark(pt),v=r().mark(mt),x=r().mark(_t),w=r().mark(vt),M=r().mark(xt),S=r().mark(wt),A=r().mark(St),E=r().mark(Et),k=r().mark(Tt),C=r().mark(Ot),T=a.isNumeric,P=a.isArrayOfStrings,D=a.isArrayOfNumbers,O=a.createSequence,z=a.isSequence,L=a.isFunction,I=a.isLambda,R=a.isIterable,j=a.getFunctionArity,F=a.isDeepEqual,B=Lt(null);function N(e,n,i){var s,o,a,c;return r().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:(o=i.lookup("__evaluate_entry"))&&o(e,n,i),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(H(e,n,i),"t1",6);case 6:return s=t.t1,t.abrupt("break",50);case 8:return t.delegateYield(W(e,n,i),"t2",9);case 9:return s=t.t2,t.abrupt("break",50);case 11:return t.delegateYield(X(e,n,i),"t3",12);case 12:return s=t.t3,t.abrupt("break",50);case 14:return s=q(e,n),t.abrupt("break",50);case 16:return s=K(e),t.abrupt("break",50);case 18:return s=Q(e,n),t.abrupt("break",50);case 20:return s=J(e,n),t.abrupt("break",50);case 22:return s=i.lookup(e.slot.label),t.abrupt("break",50);case 24:return t.delegateYield(ut(e,n,i),"t4",25);case 25:return s=t.t4,t.abrupt("break",50);case 27:return t.delegateYield(pt(e,n,i),"t5",28);case 28:return s=t.t5,t.abrupt("break",50);case 30:return t.delegateYield(dt(e,n,i),"t6",31);case 31:return s=t.t6,t.abrupt("break",50);case 33:return s=ft(e),t.abrupt("break",50);case 35:return t.delegateYield(vt(e,n,i),"t7",36);case 36:return s=t.t7,t.abrupt("break",50);case 38:return s=gt(e,n,i),t.abrupt("break",50);case 40:return s=Mt(e,n,i),t.abrupt("break",50);case 42:return t.delegateYield(St(e,n,i),"t8",43);case 43:return s=t.t8,t.abrupt("break",50);case 45:return t.delegateYield(_t(e,n,i),"t9",46);case 46:return s=t.t9,t.abrupt("break",50);case 48:return s=yt(e,n,i),t.abrupt("break",50);case 50:if(!i.async||null!=s&&"function"==typeof s.then||(s=Promise.resolve(s)),!i.async||"function"!=typeof s.then||!e.nextFunction||"function"!=typeof s[e.nextFunction]){t.next=54;break}t.next=57;break;case 54:return t.next=56,s;case 56:s=t.sent;case 57:if(!Object.prototype.hasOwnProperty.call(e,"predicate")){t.next=65;break}a=0;case 59:if(!(a<e.predicate.length)){t.next=65;break}return t.delegateYield($(e.predicate[a].expr,s,i),"t10",61);case 61:s=t.t10;case 62:a++,t.next=59;break;case 65:if("path"===e.type||!Object.prototype.hasOwnProperty.call(e,"group")){t.next=68;break}return t.delegateYield(ct(e.group,s,i),"t11",67);case 67:s=t.t11;case 68:return(c=i.lookup("__evaluate_exit"))&&c(e,n,i,s),s&&z(s)&&!s.tupleStream&&(e.keepArray&&(s.keepSingleton=!0),0===s.length?s=void 0:1===s.length&&(s=s.keepSingleton?s:s[0])),t.abrupt("return",s);case 72:case"end":return t.stop()}},t)}function H(t,n,i){var s,o,a,c,l,h;return r().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:s=Array.isArray(n)&&"variable"!==t.steps[0].type?n:O(n),a=!1,c=void 0,l=0;case 4:if(!(l<t.steps.length)){e.next=25;break}if((h=t.steps[l]).tuple&&(a=!0),0!==l||!h.consarray){e.next=12;break}return e.delegateYield(N(h,s,i),"t0",9);case 9:o=e.t0,e.next=19;break;case 12:if(!a){e.next=17;break}return e.delegateYield(U(h,s,c,i),"t1",14);case 14:c=e.t1,e.next=19;break;case 17:return e.delegateYield(G(h,s,i,l===t.steps.length-1),"t2",18);case 18:o=e.t2;case 19:if(a||void 0!==o&&0!==o.length){e.next=21;break}return e.abrupt("break",25);case 21:void 0===h.focus&&(s=o);case 22:l++,e.next=4;break;case 25:if(a)if(t.tuple)o=c;else for(o=O(),l=0;l<c.length;l++)o.push(c[l]["@"]);if(t.keepSingletonArray&&(Array.isArray(o)&&o.cons&&!o.sequence&&(o=O(o)),o.keepSingleton=!0),!t.hasOwnProperty("group")){e.next=30;break}return e.delegateYield(ct(t.group,a?c:o,i),"t3",29);case 29:o=e.t3;case 30:return e.abrupt("return",o);case 31:case"end":return e.stop()}},e)}function Y(t,e){var n=Lt(t);for(var i in e)n.bind(i,e[i]);return n}function G(t,e,i,s){var o,a,c,l,h;return r().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:if("sort"!==t.type){n.next=7;break}return n.delegateYield(mt(t,e,i),"t0",2);case 2:if(o=n.t0,!t.stages){n.next=6;break}return n.delegateYield(V(t.stages,o,i),"t1",5);case 5:o=n.t1;case 6:return n.abrupt("return",o);case 7:o=O(),a=0;case 9:if(!(a<e.length)){n.next=24;break}return n.delegateYield(N(t,e[a],i),"t2",11);case 11:if(c=n.t2,!t.stages){n.next=20;break}l=0;case 14:if(!(l<t.stages.length)){n.next=20;break}return n.delegateYield($(t.stages[l].expr,c,i),"t3",16);case 16:c=n.t3;case 17:l++,n.next=14;break;case 20:void 0!==c&&o.push(c);case 21:a++,n.next=9;break;case 24:return h=O(),s&&1===o.length&&Array.isArray(o[0])&&!z(o[0])?h=o[0]:o.forEach(function(t){!Array.isArray(t)||t.cons?h.push(t):t.forEach(function(t){return h.push(t)})}),n.abrupt("return",h);case 27:case"end":return n.stop()}},n)}function V(t,e,n){var i,s,o,a;return r().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:i=e,s=0;case 2:if(!(s<t.length)){r.next=15;break}o=t[s],r.t0=o.type,r.next="filter"===r.t0?7:"index"===r.t0?10:12;break;case 7:return r.delegateYield($(o.expr,i,n),"t1",8);case 8:return i=r.t1,r.abrupt("break",12);case 10:for(a=0;a<i.length;a++)i[a][o.value]=a;return r.abrupt("break",12);case 12:s++,r.next=2;break;case 15:return r.abrupt("return",i);case 16:case"end":return r.stop()}},h)}function U(t,e,n,i){var s,o,a,c,l,h,u,p;return r().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:if("sort"!==t.type){r.next=15;break}if(!n){r.next=6;break}return r.delegateYield(mt(t,n,i),"t0",3);case 3:s=r.t0,r.next=11;break;case 6:return r.delegateYield(mt(t,e,i),"t1",7);case 7:for(o=r.t1,(s=O()).tupleStream=!0,a=0;a<o.length;a++)(c={"@":o[a]})[t.index]=a,s.push(c);case 11:if(!t.stages){r.next=14;break}return r.delegateYield(V(t.stages,s,i),"t2",13);case 13:s=r.t2;case 14:return r.abrupt("return",s);case 15:(s=O()).tupleStream=!0,l=i,void 0===n&&(n=e.map(function(t){return{"@":t}})),h=0;case 20:if(!(h<n.length)){r.next=28;break}return l=Y(i,n[h]),r.delegateYield(N(t,n[h]["@"],l),"t3",23);case 23:if(void 0!==(u=r.t3))for(Array.isArray(u)||(u=[u]),p=0;p<u.length;p++)c={},Object.assign(c,n[h]),u.tupleStream?Object.assign(c,u[p]):(t.focus?(c[t.focus]=u[p],c["@"]=n[h]["@"]):c["@"]=u[p],t.index&&(c[t.index]=p),t.ancestor&&(c[t.ancestor.label]=n[h]["@"])),s.push(c);case 25:h++,r.next=20;break;case 28:if(!t.stages){r.next=31;break}return r.delegateYield(V(t.stages,s,i),"t4",30);case 30:s=r.t4;case 31:return r.abrupt("return",s);case 32:case"end":return r.stop()}},d)}function $(t,e,n){var i,s,a,c,l,h;return r().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:if(i=O(),e&&e.tupleStream&&(i.tupleStream=!0),Array.isArray(e)||(e=O(e)),"number"!==t.type){r.next=10;break}(s=Math.floor(t.value))<0&&(s=e.length+s),void 0!==(a=e[s])&&(Array.isArray(a)?i=a:i.push(a)),r.next=23;break;case 10:s=0;case 11:if(!(s<e.length)){r.next=23;break}return a=e[s],c=a,l=n,e.tupleStream&&(c=a["@"],l=Y(n,a)),r.delegateYield(N(t,c,l),"t0",17);case 17:h=r.t0,T(h)&&(h=[h]),D(h)?h.forEach(function(t){var n=Math.floor(t);n<0&&(n=e.length+n),n===s&&i.push(a)}):o.boolean(h)&&i.push(a);case 20:s++,r.next=11;break;case 23:return r.abrupt("return",i);case 24:case"end":return r.stop()}},u)}function W(t,e,n){var i,s,o,a,c;return r().wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return l.delegateYield(N(t.lhs,e,n),"t0",1);case 1:if(s=l.t0,o=t.value,a=r().mark(function i(){return r().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:return i.delegateYield(N(t.rhs,e,n),"t0",1);case 1:return i.abrupt("return",i.t0);case 2:case"end":return i.stop()}},i)}),"and"!==o&&"or"!==o){l.next=15;break}return l.prev=5,l.delegateYield(st(s,a,o),"t1",7);case 7:return l.abrupt("return",l.t1);case 10:throw l.prev=10,l.t2=l.catch(5),l.t2.position=t.position,l.t2.token=o,l.t2;case 15:return l.delegateYield(a(),"t3",16);case 16:c=l.t3,l.prev=17,l.t4=o,l.next="+"===l.t4||"-"===l.t4||"*"===l.t4||"/"===l.t4||"%"===l.t4?21:"="===l.t4||"!="===l.t4?23:"<"===l.t4||"<="===l.t4||">"===l.t4||">="===l.t4?25:"&"===l.t4?27:".."===l.t4?29:"in"===l.t4?31:33;break;case 21:return i=et(s,c,o),l.abrupt("break",33);case 23:return i=nt(s,c,o),l.abrupt("break",33);case 25:return i=it(s,c,o),l.abrupt("break",33);case 27:return i=at(s,c),l.abrupt("break",33);case 29:return i=ht(s,c),l.abrupt("break",33);case 31:return i=rt(s,c),l.abrupt("break",33);case 33:l.next=40;break;case 35:throw l.prev=35,l.t5=l.catch(17),l.t5.position=t.position,l.t5.token=o,l.t5;case 40:return l.abrupt("return",i);case 41:case"end":return l.stop()}},p,null,[[5,10],[17,35]])}function X(t,e,n){var i,s,a,c;return r().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:r.t0=t.value,r.next="-"===r.t0?3:"["===r.t0?15:"{"===r.t0?27:30;break;case 3:return r.delegateYield(N(t.expression,e,n),"t1",4);case 4:if(void 0!==(i=r.t1)){r.next=9;break}i=void 0,r.next=14;break;case 9:if(!T(i)){r.next=13;break}i=-i,r.next=14;break;case 13:throw{code:"D1002",stack:(new Error).stack,position:t.position,token:t.value,value:i};case 14:return r.abrupt("break",30);case 15:i=[],s=0;case 17:if(!(s<t.expressions.length)){r.next=25;break}return a=t.expressions[s],r.delegateYield(N(a,e,n),"t2",20);case 20:void 0!==(c=r.t2)&&("["===a.value?i.push(c):i=o.append(i,c));case 22:s++,r.next=17;break;case 25:return t.consarray&&Object.defineProperty(i,"cons",{enumerable:!1,configurable:!1,value:!0}),r.abrupt("break",30);case 27:return r.delegateYield(ct(t,e,n),"t3",28);case 28:return i=r.t3,r.abrupt("break",30);case 30:return r.abrupt("return",i);case 31:case"end":return r.stop()}},f)}function q(t,e,n){return o.lookup(e,t.value)}function K(t){return t.value}function Q(t,e){var n=O();return Array.isArray(e)&&e.outerWrapper&&e.length>0&&(e=e[0]),null!==e&&"object"===i(e)&&Object.keys(e).forEach(function(t){var i=e[t];Array.isArray(i)?(i=Z(i),n=o.append(n,i)):n.push(i)}),n}function Z(t,e){return void 0===e&&(e=[]),Array.isArray(t)?t.forEach(function(t){Z(t,e)}):e.push(t),e}function J(t,e){var n,i=O();return void 0!==e&&(tt(e,i),n=1===i.length?i[0]:i),n}function tt(t,e){Array.isArray(t)||e.push(t),Array.isArray(t)?t.forEach(function(t){tt(t,e)}):null!==t&&"object"===i(t)&&Object.keys(t).forEach(function(n){tt(t[n],e)})}function et(t,e,n){var i;if(void 0!==t&&!T(t))throw{code:"T2001",stack:(new Error).stack,value:t};if(void 0!==e&&!T(e))throw{code:"T2002",stack:(new Error).stack,value:e};if(void 0===t||void 0===e)return i;switch(n){case"+":i=t+e;break;case"-":i=t-e;break;case"*":i=t*e;break;case"/":i=t/e;break;case"%":i=t%e}return i}function nt(t,e,n){var r,s=i(t),o=i(e);if("undefined"===s||"undefined"===o)return!1;switch(n){case"=":r=F(t,e);break;case"!=":r=!F(t,e)}return r}function it(t,e,n){var r,s=i(t),o=i(e);if("undefined"!==s&&"string"!==s&&"number"!==s||"undefined"!==o&&"string"!==o&&"number"!==o)throw{code:"T2010",stack:(new Error).stack,value:"string"!==s&&"number"!==s?t:e};if("undefined"!==s&&"undefined"!==o){if(s!==o)throw{code:"T2009",stack:(new Error).stack,value:t,value2:e};switch(n){case"<":r=t<e;break;case"<=":r=t<=e;break;case">":r=t>e;break;case">=":r=t>=e}return r}}function rt(t,e){var n=!1;if(void 0===t||void 0===e)return!1;Array.isArray(e)||(e=[e]);for(var i=0;i<e.length;i++)if(e[i]===t){n=!0;break}return n}function st(t,e,n){var i,s;return r().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:s=ot(t),r.t0=n,r.next="and"===r.t0?4:"or"===r.t0?12:20;break;case 4:if(r.t1=s,!r.t1){r.next=10;break}return r.t2=ot,r.delegateYield(e(),"t3",8);case 8:r.t4=r.t3,r.t1=(0,r.t2)(r.t4);case 10:return i=r.t1,r.abrupt("break",20);case 12:if(r.t5=s,r.t5){r.next=18;break}return r.t6=ot,r.delegateYield(e(),"t7",16);case 16:r.t8=r.t7,r.t5=(0,r.t6)(r.t8);case 18:return i=r.t5,r.abrupt("break",20);case 20:return r.abrupt("return",i);case 21:case"end":return r.stop()}},g)}function ot(t){var e=o.boolean(t);return void 0!==e&&e}function at(t,e){var n="",i="";return void 0!==t&&(n=o.string(t)),void 0!==e&&(i=o.string(e)),n.concat(i)}function ct(t,e,n){var i,s,a,c,l,h,d,u,p,f,g,y,b;return r().wrap(function(m){for(;;)switch(m.prev=m.next){case 0:i={},s={},a=!(!e||!e.tupleStream),Array.isArray(e)||(e=O(e)),0===e.length&&e.push(void 0),c=0;case 6:if(!(c<e.length)){m.next=31;break}l=e[c],h=a?Y(n,l):n,d=0;case 10:if(!(d<t.lhs.length)){m.next=28;break}return u=t.lhs[d],m.delegateYield(N(u[0],a?l["@"]:l,h),"t0",13);case 13:if("string"==typeof(p=m.t0)||void 0===p){m.next=16;break}throw{code:"T1003",stack:(new Error).stack,position:t.position,value:p};case 16:if(void 0===p){m.next=25;break}if(f={data:l,exprIndex:d},!s.hasOwnProperty(p)){m.next=24;break}if(s[p].exprIndex===d){m.next=21;break}throw{code:"D1009",stack:(new Error).stack,position:t.position,value:p};case 21:s[p].data=o.append(s[p].data,l),m.next=25;break;case 24:s[p]=f;case 25:d++,m.next=10;break;case 28:c++,m.next=6;break;case 31:m.t1=r().keys(s);case 32:if((m.t2=m.t1()).done){m.next=43;break}return p=m.t2.value,f=s[p],g=f.data,h=n,a&&(y=lt(f.data),g=y["@"],delete y["@"],h=Y(n,y)),m.delegateYield(N(t.lhs[f.exprIndex][1],g,h),"t3",39);case 39:void 0!==(b=m.t3)&&(i[p]=b),m.next=32;break;case 43:return m.abrupt("return",i);case 44:case"end":return m.stop()}},m)}function lt(t){if(!Array.isArray(t))return t;var e={};Object.assign(e,t[0]);for(var n=1;n<t.length;n++)for(var i in t[n])e[i]=o.append(e[i],t[n][i]);return e}function ht(t,e){var n;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 n;if(t>e)return n;var i=e-t+1;if(i>1e7)throw{code:"D2014",stack:(new Error).stack,value:i};n=new Array(i);for(var r=t,s=0;r<=e;r++,s++)n[s]=r;return n.sequence=!0,n}function dt(t,e,n){var i;return r().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:return r.delegateYield(N(t.rhs,e,n),"t0",1);case 1:return i=r.t0,n.bind(t.lhs.value,i),r.abrupt("return",i);case 4:case"end":return r.stop()}},y)}function ut(t,e,n){var i,s;return r().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:return r.delegateYield(N(t.condition,e,n),"t0",1);case 1:if(s=r.t0,!o.boolean(s)){r.next=7;break}return r.delegateYield(N(t.then,e,n),"t1",4);case 4:i=r.t1,r.next=10;break;case 7:if(void 0===t.else){r.next=10;break}return r.delegateYield(N(t.else,e,n),"t2",9);case 9:i=r.t2;case 10:return r.abrupt("return",i);case 11:case"end":return r.stop()}},b)}function pt(t,e,n){var i,s,o;return r().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:s=Lt(n),o=0;case 2:if(!(o<t.expressions.length)){r.next=8;break}return r.delegateYield(N(t.expressions[o],e,s),"t0",4);case 4:i=r.t0;case 5:o++,r.next=2;break;case 8:return r.abrupt("return",i);case 9:case"end":return r.stop()}},_)}function ft(t){var e=new jt.RegexEngine(t.value),n=function n(i,r){var s;e.lastIndex=r||0;var o=e.exec(i);if(null!==o){if(s={match:o[0],start:o.index,end:o.index+o[0].length,groups:[]},o.length>1)for(var a=1;a<o.length;a++)s.groups.push(o[a]);s.next=function(){if(!(e.lastIndex>=i.length)){var r=n(i,e.lastIndex);if(r&&""===r.match)throw{code:"D1004",stack:(new Error).stack,position:t.position,value:t.value.source};return r}}}return s};return n}function gt(t,e,n){return""===t.value?e&&e.outerWrapper?e[0]:e:n.lookup(t.value)}function mt(t,e,n){var s,a,c,l,h;return r().wrap(function(d){for(;;)switch(d.prev=d.next){case 0:return a=e,c=!!e.tupleStream,l=r().mark(function e(s,o){var a,l,h,d,u,p,f,g,m;return r().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:a=0,l=0;case 2:if(!(0===a&&l<t.terms.length)){e.next=35;break}return h=t.terms[l],d=s,u=n,c&&(d=s["@"],u=Y(n,s)),e.delegateYield(N(h.expression,d,u),"t0",8);case 8:return p=e.t0,d=o,u=n,c&&(d=o["@"],u=Y(n,o)),e.delegateYield(N(h.expression,d,u),"t1",13);case 13:if(f=e.t1,g=i(p),m=i(f),"undefined"!==g){e.next=19;break}return a="undefined"===m?0:1,e.abrupt("continue",32);case 19:if("undefined"!==m){e.next=22;break}return a=-1,e.abrupt("continue",32);case 22:if(!("string"!==g&&"number"!==g||"string"!==m&&"number"!==m)){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===m){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:a=p<f?-1:1;case 31:!0===h.descending&&(a=-a);case 32:l++,e.next=2;break;case 35:return e.abrupt("return",1===a);case 36:case"end":return e.stop()}},e)}),h={environment:n,input:e},d.delegateYield(o.sort.apply(h,[a,l]),"t0",5);case 5:return s=d.t0,d.abrupt("return",s);case 7:case"end":return d.stop()}},v)}function yt(t,e,n){var s=r().mark(function e(s){var o,a,c,l,h,d,u,p,f,g,m;return r().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==s){e.next=2;break}return e.abrupt("return",void 0);case 2:if(o=n.lookup("clone"),L(o)){e.next=5;break}throw{code:"T2013",stack:(new Error).stack,position:t.position};case 5:return e.delegateYield(xt(o,[s],null,n),"t0",6);case 6:return a=e.t0,e.delegateYield(N(t.pattern,a,n),"t1",8);case 8:if(void 0===(c=e.t1)){e.next=35;break}Array.isArray(c)||(c=[c]),l=0;case 12:if(!(l<c.length)){e.next=35;break}if(!(h=c[l])||!(h.isPrototypeOf(a)||h instanceof Object.constructor)){e.next=16;break}throw{code:"D1010",stack:(new Error).stack,position:t.position};case 16:return e.delegateYield(N(t.update,h,n),"t2",17);case 17:if(d=e.t2,"undefined"===(u=i(d))){e.next=23;break}if("object"===u&&null!==d&&!Array.isArray(d)){e.next=22;break}throw{code:"T2011",stack:(new Error).stack,position:t.update.position,value:d};case 22:for(p in d)h[p]=d[p];case 23:if(void 0===t.delete){e.next=32;break}return e.delegateYield(N(t.delete,h,n),"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(m=0;m<f.length;m++)"object"===i(h)&&null!==h&&delete h[f[m]];case 32:l++,e.next=12;break;case 35:return e.abrupt("return",a);case 36:case"end":return e.stop()}},e)});return Dt(s,"<(oa):o>")}var bt=c("function($f, $g) { function($x){ $g($f($x)) } }");function _t(t,e,n){var i,s,o,a;return r().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:return r.delegateYield(N(t.lhs,e,n),"t0",1);case 1:if(s=r.t0,"function"!==t.rhs.type){r.next=7;break}return r.delegateYield(vt(t.rhs,e,n,{context:s}),"t1",4);case 4:i=r.t1,r.next=20;break;case 7:return r.delegateYield(N(t.rhs,e,n),"t2",8);case 8:if(o=r.t2,L(o)){r.next=11;break}throw{code:"T2006",stack:(new Error).stack,position:t.position,value:o};case 11:if(!L(s)){r.next=18;break}return r.delegateYield(N(bt,null,n),"t3",13);case 13:return a=r.t3,r.delegateYield(xt(a,[s,o],null,n),"t4",15);case 15:i=r.t4,r.next=20;break;case 18:return r.delegateYield(xt(o,[s],null,n),"t5",19);case 19:i=r.t5;case 20:return r.abrupt("return",i);case 21:case"end":return r.stop()}},x)}function vt(t,e,n,s){var o,a,c,l,h,d;return r().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.delegateYield(N(t.procedure,e,n),"t0",1);case 1:if(void 0!==(a=u.t0)||"path"!==t.procedure.type||!n.lookup(t.procedure.steps[0].value)){u.next=4;break}throw{code:"T1005",stack:(new Error).stack,position:t.position,token:t.procedure.steps[0].value};case 4:c=[],void 0!==s&&c.push(s.context),l=r().mark(function i(){var s,o;return r().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:return i.delegateYield(N(t.arguments[h],e,n),"t0",1);case 1:s=i.t0,L(s)?(o=r().mark(function t(){var e,i,o,a=arguments;return r().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:for(e=a.length,i=new Array(e),o=0;o<e;o++)i[o]=a[o];return t.delegateYield(xt(s,i,null,n),"t0",2);case 2:return t.abrupt("return",t.t0);case 3:case"end":return t.stop()}},t)}),o.arity=j(s),c.push(o)):c.push(s);case 3:case"end":return i.stop()}},i)}),h=0;case 8:if(!(h<t.arguments.length)){u.next=13;break}return u.delegateYield(l(),"t1",10);case 10:h++,u.next=8;break;case 13:return d="path"===t.procedure.type?t.procedure.steps[0].value:t.procedure.value,u.prev=14,"object"===i(a)&&(a.token=d,a.position=t.position),u.delegateYield(xt(a,c,e,n),"t2",17);case 17:o=u.t2,u.next=25;break;case 20:throw u.prev=20,u.t3=u.catch(14),u.t3.position||(u.t3.position=t.position),u.t3.token||(u.t3.token=d),u.t3;case 25:return u.abrupt("return",o);case 26:case"end":return u.stop()}},w,null,[[14,20]])}function xt(t,e,n,i){var s,o,a,c;return r().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:return r.delegateYield(wt(t,e,n,i),"t0",1);case 1:s=r.t0;case 2:if(!I(s)||!0!==s.thunk){r.next=21;break}return r.delegateYield(N(s.body.procedure,s.input,s.environment),"t1",4);case 4:o=r.t1,"variable"===s.body.procedure.type&&(o.token=s.body.procedure.value),o.position=s.body.procedure.position,a=[],c=0;case 9:if(!(c<s.body.arguments.length)){r.next=17;break}return r.t2=a,r.delegateYield(N(s.body.arguments[c],s.input,s.environment),"t3",12);case 12:r.t4=r.t3,r.t2.push.call(r.t2,r.t4);case 14:c++,r.next=9;break;case 17:return r.delegateYield(wt(o,a,n,i),"t5",18);case 18:s=r.t5,r.next=2;break;case 21:return r.abrupt("return",s);case 22:case"end":return r.stop()}},M)}function wt(t,e,n,i){var s,o,a;return r().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:if(r.prev=0,o=e,t&&(o=At(t.signature,e,n)),!I(t)){r.next=8;break}return r.delegateYield(Et(t,o),"t0",5);case 5:s=r.t0,r.next=24;break;case 8:if(!t||!0!==t._jsonata_function){r.next=16;break}if(a={environment:i,input:n},s=t.implementation.apply(a,o),!R(s)){r.next=14;break}return r.delegateYield(s,"t1",13);case 13:s=r.t1;case 14:r.next=24;break;case 16:if("function"!=typeof t){r.next=23;break}if(s=t.apply(n,o),!R(s)){r.next=21;break}return r.delegateYield(s,"t2",20);case 20:s=r.t2;case 21:r.next=24;break;case 23:throw{code:"T1006",stack:(new Error).stack};case 24:r.next=30;break;case 26:throw r.prev=26,r.t3=r.catch(0),t&&(void 0===r.t3.token&&void 0!==t.token&&(r.t3.token=t.token),r.t3.position=t.position||r.t3.position),r.t3;case 30:return r.abrupt("return",s);case 31:case"end":return r.stop()}},S,null,[[0,26]])}function Mt(t,e,n){var i={_jsonata_lambda:!0,input:e,environment:n,arguments:t.arguments,signature:t.signature,body:t.body};return!0===t.thunk&&(i.thunk=!0),i.apply=r().mark(function t(n,s){return r().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.delegateYield(xt(i,s,e,n.environment),"t0",1);case 1:return t.abrupt("return",t.t0);case 2:case"end":return t.stop()}},t)}),i}function St(t,e,n){var i,s,o,a,c;return r().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:s=[],o=0;case 2:if(!(o<t.arguments.length)){r.next=15;break}if("operator"!==(a=t.arguments[o]).type||"?"!==a.value){r.next=8;break}s.push(a),r.next=12;break;case 8:return r.t0=s,r.delegateYield(N(a,e,n),"t1",10);case 10:r.t2=r.t1,r.t0.push.call(r.t0,r.t2);case 12:o++,r.next=2;break;case 15:return r.delegateYield(N(t.procedure,e,n),"t3",16);case 16:if(void 0!==(c=r.t3)||"path"!==t.procedure.type||!n.lookup(t.procedure.steps[0].value)){r.next=19;break}throw{code:"T1007",stack:(new Error).stack,position:t.position,token:t.procedure.steps[0].value};case 19:if(!I(c)){r.next=23;break}i=kt(c,s),r.next=32;break;case 23:if(!c||!0!==c._jsonata_function){r.next=27;break}i=Ct(c.implementation,s),r.next=32;break;case 27:if("function"!=typeof c){r.next=31;break}i=Ct(c,s),r.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 r.abrupt("return",i);case 33:case"end":return r.stop()}},A)}function At(t,e,n){return void 0===t?e:t.validate(e,n)}function Et(t,e){var n,i;return r().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:if(i=Lt(t.environment),t.arguments.forEach(function(t,n){i.bind(t.value,e[n])}),"function"!=typeof t.body){r.next=7;break}return r.delegateYield(Tt(t.body,i),"t0",4);case 4:n=r.t0,r.next=9;break;case 7:return r.delegateYield(N(t.body,t.input,i),"t1",8);case 8:n=r.t1;case 9:return r.abrupt("return",n);case 10:case"end":return r.stop()}},E)}function kt(t,e){var n=Lt(t.environment),i=[];return t.arguments.forEach(function(t,r){var s=e[r];s&&"operator"===s.type&&"?"===s.value?i.push(t):n.bind(t.value,s)}),{_jsonata_lambda:!0,input:t.input,environment:n,arguments:i,body:t.body}}function Ct(t,e){var n=Pt(t),i="function("+(n=n.map(function(t){return"$"+t.trim()})).join(", ")+"){ _ }",r=c(i);return r.body=t,kt(r,e)}function Tt(t,e){var n,i,s,o;return r().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:if(n=Pt(t),i=n.map(function(t){return e.lookup(t.trim())}),s={environment:e},o=t.apply(s,i),!R(o)){r.next=7;break}return r.delegateYield(o,"t0",6);case 6:o=r.t0;case 7:return r.abrupt("return",o);case 8:case"end":return r.stop()}},k)}function Pt(t){var e=t.toString();return/\(([^)]*)\)/.exec(e)[1].split(",")}function Dt(t,e){var n={_jsonata_function:!0,implementation:t};return void 0!==e&&(n.signature=l(e)),n}function Ot(t,e){var n,i,s;return r().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:n=this.input,void 0!==e&&(n=e,Array.isArray(n)&&!z(n)&&((n=O(n)).outerWrapper=!0)),r.prev=4,i=c(t,!1),r.next=12;break;case 8:throw r.prev=8,r.t0=r.catch(4),Rt(r.t0),{stack:(new Error).stack,code:"D3120",value:r.t0.message,error:r.t0};case 12:return r.prev=12,r.delegateYield(N(i,n,this.environment),"t1",14);case 14:s=r.t1,r.next=21;break;case 17:throw r.prev=17,r.t2=r.catch(12),Rt(r.t2),{stack:(new Error).stack,code:"D3121",value:r.t2.message,error:r.t2};case 21:return r.abrupt("return",s);case 22:case"end":return r.stop()}},C,this,[[4,8],[12,17]])}function zt(t){if(void 0!==t)return JSON.parse(o.string(t))}function Lt(t){var e={};return{bind:function(t,n){e[t]=n},lookup:function(n){var i;return e.hasOwnProperty(n)?i=e[n]:t&&(i=t.lookup(n)),i},timestamp:t?t.timestamp:null,async:!!t&&t.async,global:t?t.global:{ancestry:[null]}}}B.bind("sum",Dt(o.sum,"<a<n>:n>")),B.bind("count",Dt(o.count,"<a:n>")),B.bind("max",Dt(o.max,"<a<n>:n>")),B.bind("min",Dt(o.min,"<a<n>:n>")),B.bind("average",Dt(o.average,"<a<n>:n>")),B.bind("string",Dt(o.string,"<x-b?:s>")),B.bind("substring",Dt(o.substring,"<s-nn?:s>")),B.bind("substringBefore",Dt(o.substringBefore,"<s-s:s>")),B.bind("substringAfter",Dt(o.substringAfter,"<s-s:s>")),B.bind("lowercase",Dt(o.lowercase,"<s-:s>")),B.bind("uppercase",Dt(o.uppercase,"<s-:s>")),B.bind("length",Dt(o.length,"<s-:n>")),B.bind("trim",Dt(o.trim,"<s-:s>")),B.bind("pad",Dt(o.pad,"<s-ns?:s>")),B.bind("match",Dt(o.match,"<s-f<s:o>n?:a<o>>")),B.bind("contains",Dt(o.contains,"<s-(sf):b>")),B.bind("replace",Dt(o.replace,"<s-(sf)(sf)n?:s>")),B.bind("split",Dt(o.split,"<s-(sf)n?:a<s>>")),B.bind("join",Dt(o.join,"<a<s>s?:s>")),B.bind("formatNumber",Dt(o.formatNumber,"<n-so?:s>")),B.bind("formatBase",Dt(o.formatBase,"<n-n?:s>")),B.bind("formatInteger",Dt(s.formatInteger,"<n-s:s>")),B.bind("parseInteger",Dt(s.parseInteger,"<s-s:n>")),B.bind("number",Dt(o.number,"<(nsb)-:n>")),B.bind("floor",Dt(o.floor,"<n-:n>")),B.bind("ceil",Dt(o.ceil,"<n-:n>")),B.bind("round",Dt(o.round,"<n-n?:n>")),B.bind("abs",Dt(o.abs,"<n-:n>")),B.bind("sqrt",Dt(o.sqrt,"<n-:n>")),B.bind("power",Dt(o.power,"<n-n:n>")),B.bind("random",Dt(o.random,"<:n>")),B.bind("boolean",Dt(o.boolean,"<x-:b>")),B.bind("not",Dt(o.not,"<x-:b>")),B.bind("map",Dt(o.map,"<af>")),B.bind("zip",Dt(o.zip,"<a+>")),B.bind("filter",Dt(o.filter,"<af>")),B.bind("single",Dt(o.single,"<af?>")),B.bind("reduce",Dt(o.foldLeft,"<afj?:j>")),B.bind("sift",Dt(o.sift,"<o-f?:o>")),B.bind("keys",Dt(o.keys,"<x-:a<s>>")),B.bind("lookup",Dt(o.lookup,"<x-s:x>")),B.bind("append",Dt(o.append,"<xx:a>")),B.bind("exists",Dt(o.exists,"<x:b>")),B.bind("spread",Dt(o.spread,"<x-:a<o>>")),B.bind("merge",Dt(o.merge,"<a<o>:o>")),B.bind("reverse",Dt(o.reverse,"<a:a>")),B.bind("each",Dt(o.each,"<o-f:a>")),B.bind("error",Dt(o.error,"<s?:x>")),B.bind("assert",Dt(o.assert,"<bs?:x>")),B.bind("type",Dt(o.type,"<x:s>")),B.bind("sort",Dt(o.sort,"<af?:a>")),B.bind("shuffle",Dt(o.shuffle,"<a:a>")),B.bind("distinct",Dt(o.distinct,"<x:x>")),B.bind("base64encode",Dt(o.base64encode,"<s-:s>")),B.bind("base64decode",Dt(o.base64decode,"<s-:s>")),B.bind("encodeUrlComponent",Dt(o.encodeUrlComponent,"<s-:s>")),B.bind("encodeUrl",Dt(o.encodeUrl,"<s-:s>")),B.bind("decodeUrlComponent",Dt(o.decodeUrlComponent,"<s-:s>")),B.bind("decodeUrl",Dt(o.decodeUrl,"<s-:s>")),B.bind("eval",Dt(Ot,"<sx?:x>")),B.bind("toMillis",Dt(s.toMillis,"<s-s?:n>")),B.bind("fromMillis",Dt(s.fromMillis,"<n-s?s?:s>")),B.bind("clone",Dt(zt,"<(oa)-:o>"));var It={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 Rt(t){var e=It[t.code];if(void 0!==e){var n=e.replace(/\{\{\{([^}]+)}}}/g,function(){return t[arguments[1]]});n=n.replace(/\{\{([^}]+)}}/g,function(){return JSON.stringify(t[arguments[1]])}),t.message=n}}function jt(t,e){var n,i;try{n=c(t,e&&e.recover),i=n.errors,delete n.errors}catch(t){throw Rt(t),t}var r=Lt(B),o=new Date;return r.bind("now",Dt(function(t,e){return s.fromMillis(o.getTime(),t,e)},"<s?s?:s>")),r.bind("millis",Dt(function(){return o.getTime()},"<:n>")),e&&e.RegexEngine?jt.RegexEngine=e.RegexEngine:jt.RegexEngine=RegExp,{evaluate:function(t,e,s){if(void 0!==i){var a={code:"S0500",position:0};throw Rt(a),a}var c,l,h;if(void 0!==e)for(var d in c=Lt(r),e)c.bind(d,e[d]);else c=r;if(c.bind("$",t),o=new Date,c.timestamp=o,Array.isArray(t)&&!z(t)&&((t=O(t)).outerWrapper=!0),"function"==typeof s){c.async=!0;var u=function(t){Rt(t),s(t,null)},p=function t(e){(l=h.next(e)).done?s(null,l.value):l.value.then(t).catch(u)};h=N(n,t,c),(l=h.next()).value.then(p).catch(u)}else try{for(h=N(n,t,c),l=h.next();!l.done;)l=h.next(l.value);return l.value}catch(a){throw Rt(a),a}},assign:function(t,e){r.bind(t,e)},registerFunction:function(t,e,n){var i=Dt(e,n);r.bind(t,i)},ast:function(){return n},errors:function(){return i}}}return jt.parser=c,jt}();e.exports=h},{"./datetime":1,"./functions":2,"./parser":4,"./signature":5,"./utils":6}],4:[function(t,e,n){var i=t("./signature"),r=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"},n=function(n){var i=0,r=n.length,s=function(t,e){return{type:t,value:e,position:i}},o=function(){for(var t,e,s=i,o=0;i<r;){var a=n.charAt(i);if("/"===a&&"\\"!==n.charAt(i-1)&&0===o){if(""===(t=n.substring(s,i)))throw{code:"S0301",stack:(new Error).stack,position:i};for(i++,a=n.charAt(i),s=i;"i"===a||"m"===a;)i++,a=n.charAt(i);return e=n.substring(s,i)+"g",new RegExp(t,e)}"("!==a&&"["!==a&&"{"!==a||"\\"===n.charAt(i-1)||o++,")"!==a&&"]"!==a&&"}"!==a||"\\"===n.charAt(i-1)||o--,i++}throw{code:"S0302",stack:(new Error).stack,position:i}},a=function a(c){if(i>=r)return null;for(var l=n.charAt(i);i<r&&" \t\n\r\v".indexOf(l)>-1;)i++,l=n.charAt(i);if("/"===l&&"*"===n.charAt(i+1)){var h=i;for(i+=2,l=n.charAt(i);"*"!==l||"/"!==n.charAt(i+1);)if(l=n.charAt(++i),i>=r)throw{code:"S0106",stack:(new Error).stack,position:h};return i+=2,l=n.charAt(i),a(c)}if(!0!==c&&"/"===l)return i++,s("regex",o());if("."===l&&"."===n.charAt(i+1))return i+=2,s("operator","..");if(":"===l&&"="===n.charAt(i+1))return i+=2,s("operator",":=");if("!"===l&&"="===n.charAt(i+1))return i+=2,s("operator","!=");if(">"===l&&"="===n.charAt(i+1))return i+=2,s("operator",">=");if("<"===l&&"="===n.charAt(i+1))return i+=2,s("operator","<=");if("*"===l&&"*"===n.charAt(i+1))return i+=2,s("operator","**");if("~"===l&&">"===n.charAt(i+1))return i+=2,s("operator","~>");if(Object.prototype.hasOwnProperty.call(t,l))return i++,s("operator",l);if('"'===l||"'"===l){var d=l;i++;for(var u="";i<r;){if("\\"===(l=n.charAt(i)))if(i++,l=n.charAt(i),Object.prototype.hasOwnProperty.call(e,l))u+=e[l];else{if("u"!==l)throw{code:"S0103",stack:(new Error).stack,position:i,token:l};var p=n.substr(i+1,4);if(!/^[0-9a-fA-F]+$/.test(p))throw{code:"S0104",stack:(new Error).stack,position:i};var f=parseInt(p,16);u+=String.fromCharCode(f),i+=4}else{if(l===d)return i++,s("string",u);u+=l}i++}throw{code:"S0101",stack:(new Error).stack,position:i}}var g,m=/^-?(0|([1-9][0-9]*))(\.[0-9]+)?([Ee][-+]?[0-9]+)?/.exec(n.substring(i));if(null!==m){var y=parseFloat(m[0]);if(!isNaN(y)&&isFinite(y))return i+=m[0].length,s("number",y);throw{code:"S0102",stack:(new Error).stack,position:i,token:m[0]}}if("`"===l){i++;var b=n.indexOf("`",i);if(-1!==b)return g=n.substring(i,b),i=b+1,s("name",g);throw i=r,{code:"S0105",stack:(new Error).stack,position:i}}for(var _,v=i;;)if(_=n.charAt(v),v===r||" \t\n\r\v".indexOf(_)>-1||Object.prototype.hasOwnProperty.call(t,_)){if("$"===n.charAt(i))return g=n.substring(i+1,v),i=v,s("variable",g);switch(g=n.substring(i,v),i=v,g){case"or":case"in":case"and":return s("operator",g);case"true":return s("value",!0);case"false":return s("value",!1);case"null":return s("value",null);default:return i===r&&""===g?null:s("name",g)}}else v++};return a},r=function(e,r){var s,o,a={},c=[],l=function(){var t=[];"(end)"!==s.id&&t.push({type:s.type,value:s.value,position:s.position});for(var e=o();null!==e;)t.push(e),e=o();return t},h={nud:function(){var t={code:"S0211",token:this.value,position:this.position};if(r)return t.remaining=l(),t.type="error",c.push(t),t;throw t.stack=(new Error).stack,t}},d=function(t,e){var n=a[t];return e=e||0,n?e>=n.lbp&&(n.lbp=e):((n=Object.create(h)).id=n.value=t,n.lbp=e,a[t]=n),n},u=function(t){if(r){t.remaining=l(),c.push(t);var e=a["(error)"];return(s=Object.create(e)).error=t,s.type="(error)",s}throw t.stack=(new Error).stack,t},p=function(t,n){if(t&&s.id!==t){var i={code:"(end)"===s.id?"S0203":"S0202",position:s.position,token:s.value,value:t};return u(i)}var r=o(n);if(null===r)return(s=a["(end)"]).position=e.length,s;var c,l=r.value,h=r.type;switch(h){case"name":case"variable":c=a["(name)"];break;case"operator":if(!(c=a[l]))return u({code:"S0204",stack:(new Error).stack,position:r.position,token:l});break;case"string":case"number":case"value":c=a["(literal)"];break;case"regex":h="regex",c=a["(regex)"];break;default:return u({code:"S0205",stack:(new Error).stack,position:r.position,token:l})}return(s=Object.create(c)).value=l,s.type=h,s.position=r.position,s},f=function(t){var e,n=s;for(p(null,!0),e=n.nud();t<s.lbp;)n=s,p(),e=n.led(e);return e},g=function(t){d(t,0).nud=function(){return this}},m=function(e,n,i){var r=n||t[e],s=d(e,r);return s.led=i||function(t){return this.lhs=t,this.rhs=f(r),this.type="binary",this},s},y=function(t,e,n){var i=d(t,e);return i.led=n,i},b=function(t,e){var n=d(t);return n.nud=e||function(){return this.expression=f(70),this.type="unary",this},n};g("(end)"),g("(name)"),g("(literal)"),g("(regex)"),d(":"),d(";"),d(","),d(")"),d("]"),d("}"),d(".."),m("."),m("+"),m("-"),m("*"),m("/"),m("%"),m("="),m("<"),m(">"),m("!="),m("<="),m(">="),m("&"),m("and"),m("or"),m("in"),g("and"),g("or"),g("in"),b("-"),m("~>"),y("(error)",10,function(t){return this.lhs=t,this.error=s.error,this.remaining=l(),this.type="error",this}),b("*",function(){return this.type="wildcard",this}),b("**",function(){return this.type="descendant",this}),b("%",function(){return this.type="parent",this}),m("(",t["("],function(t){if(this.procedure=t,this.type="function",this.arguments=[],")"!==s.id)for(;"operator"===s.type&&"?"===s.id?(this.type="partial",this.arguments.push(s),p("?")):this.arguments.push(f(0)),","===s.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 u({code:"S0208",stack:(new Error).stack,position:t.position,token:t.value,value:e+1})}),this.type="lambda","<"===s.id){for(var e=s.position,n=1,r="<";n>0&&"{"!==s.id&&"(end)"!==s.id;){var o=p();">"===o.id?n--:"<"===o.id&&n++,r+=o.value}p(">");try{this.signature=i(r)}catch(t){return t.position=e+t.offset,u(t)}}p("{"),this.body=f(0),p("}")}return this}),b("(",function(){for(var t=[];")"!==s.id&&(t.push(f(0)),";"===s.id);)p(";");return p(")",!0),this.type="block",this.expressions=t,this}),b("[",function(){var t=[];if("]"!==s.id)for(;;){var e=f(0);if(".."===s.id){var n={type:"binary",value:"..",position:s.position,lhs:e};p(".."),n.rhs=f(0),e=n}if(t.push(e),","!==s.id)break;p(",")}return p("]",!0),this.expressions=t,this.type="unary",this}),m("[",t["["],function(e){if("]"===s.id){for(var n=e;n&&"binary"===n.type&&"["===n.value;)n=n.lhs;return n.keepArray=!0,p("]"),e}return this.lhs=e,this.rhs=f(t["]"]),this.type="binary",p("]",!0),this}),m("^",t["^"],function(t){p("(");for(var e=[];;){var n={descending:!1};if("<"===s.id?p("<"):">"===s.id&&(n.descending=!0,p(">")),n.expression=f(0),e.push(n),","!==s.id)break;p(",")}return p(")"),this.lhs=t,this.rhs=e,this.type="binary",this});var _=function(t){var e=[];if("}"!==s.id)for(;;){var n=f(0);p(":");var i=f(0);if(e.push([n,i]),","!==s.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};b("{",_),m("{",t["{"],_),y(":=",t[":="],function(e){return"variable"!==e.type?u({code:"S0212",stack:(new Error).stack,position:e.position,token:e.value}):(this.lhs=e,this.rhs=f(t[":="]-1),this.type="binary",this)}),m("@",t["@"],function(e){return this.lhs=e,this.rhs=f(t["@"]),"variable"!==this.rhs.type?u({code:"S0214",stack:(new Error).stack,position:this.rhs.position,token:"@"}):(this.type="binary",this)}),m("#",t["#"],function(e){return this.lhs=e,this.rhs=f(t["#"]),"variable"!==this.rhs.type?u({code:"S0214",stack:(new Error).stack,position:this.rhs.position,token:"#"}):(this.type="binary",this)}),m("?",t["?"],function(t){return this.type="condition",this.condition=t,this.then=f(0),":"===s.id&&(p(":"),this.else=f(0)),this}),b("|",function(){return this.type="transform",this.pattern=f(0),p("|"),this.update=f(0),","===s.id&&(p(","),this.delete=f(0)),p("|"),this});var v=function t(e){var n;if("function"!==e.type||e.predicate)if("condition"===e.type)e.then=t(e.then),void 0!==e.else&&(e.else=t(e.else)),n=e;else if("block"===e.type){var i=e.expressions.length;i>0&&(e.expressions[i-1]=t(e.expressions[i-1])),n=e}else n=e;else{var r={type:"lambda",thunk:!0,arguments:[],position:e.position};r.body=e,n=r}return n},x=0,w=0,M=[],S=function t(e,n){switch(e.type){case"name":case"wildcard":n.level--,0===n.level&&(void 0===e.ancestor||(M[n.index].slot.label=e.ancestor.label),e.ancestor=n,e.tuple=!0);break;case"parent":n.level++;break;case"block":e.expressions.length>0&&(e.tuple=!0,n=t(e.expressions[e.expressions.length-1],n));break;case"path":e.tuple=!0;var i=e.steps.length-1;for(n=t(e.steps[i--],n);n.level>0&&i>=0;)n=t(e.steps[i--],n);break;default:throw{code:"S0217",token:e.type,position:e.position}}return n},A=function(t,e){if(void 0!==e.seekingParent||"parent"===e.type){var n=void 0!==e.seekingParent?e.seekingParent:[];"parent"===e.type&&n.push(e.slot),void 0===t.seekingParent?t.seekingParent=n:Array.prototype.push.apply(t.seekingParent,n)}},E=function(t){var e=t.steps.length-1,n=t.steps[e],i=void 0!==n.seekingParent?n.seekingParent:[];"parent"===n.type&&i.push(n.slot);for(var r=0;r<i.length;r++){var s=i[r];for(e=t.steps.length-2;s.level>0;){if(e<0){void 0===t.seekingParent?t.seekingParent=[s]:t.seekingParent.push(s);break}for(var o=t.steps[e--];e>=0&&o.focus&&t.steps[e].focus;)o=t.steps[e--];s=S(o,s)}}},k=function t(e){var n;switch(e.type){case"binary":switch(e.value){case".":var i=t(e.lhs);n="path"===i.type?i:{type:"path",steps:[i]},"parent"===i.type&&(n.seekingParent=[i.slot]);var s=t(e.rhs);"function"===s.type&&"path"===s.procedure.type&&1===s.procedure.steps.length&&"name"===s.procedure.steps[0].type&&"function"===n.steps[n.steps.length-1].type&&(n.steps[n.steps.length-1].nextFunction=s.procedure.steps[0].value),"path"===s.type?Array.prototype.push.apply(n.steps,s.steps):(void 0!==s.predicate&&(s.stages=s.predicate,delete s.predicate),n.steps.push(s)),n.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"}),n.steps.filter(function(t){return!0===t.keepArray}).length>0&&(n.keepSingletonArray=!0);var o=n.steps[0];"unary"===o.type&&"["===o.value&&(o.consarray=!0);var a=n.steps[n.steps.length-1];"unary"===a.type&&"["===a.value&&(a.consarray=!0),E(n);break;case"[":var l=n=t(e.lhs),h="predicate";if("path"===n.type&&(l=n.steps[n.steps.length-1],h="stages"),void 0!==l.group)throw{code:"S0209",stack:(new Error).stack,position:e.position};void 0===l[h]&&(l[h]=[]);var d=t(e.rhs);void 0!==d.seekingParent&&(d.seekingParent.forEach(function(t){1===t.level?S(l,t):t.level--}),A(l,d)),l[h].push({type:"filter",expr:d,position:e.position});break;case"{":if(void 0!==(n=t(e.lhs)).group)throw{code:"S0210",stack:(new Error).stack,position:e.position};n.group={lhs:e.rhs.map(function(e){return[t(e[0]),t(e[1])]}),position:e.position};break;case"^":"path"!==(n=t(e.lhs)).type&&(n={type:"path",steps:[n]});var u={type:"sort",position:e.position};u.terms=e.rhs.map(function(e){var n=t(e.expression);return A(u,n),{descending:e.descending,expression:n}}),n.steps.push(u),E(n);break;case":=":(n={type:"bind",value:e.value,position:e.position}).lhs=t(e.lhs),n.rhs=t(e.rhs),A(n,n.rhs);break;case"@":if(n=t(e.lhs),l=n,"path"===n.type&&(l=n.steps[n.steps.length-1]),void 0!==l.stages||void 0!==l.predicate)throw{code:"S0215",stack:(new Error).stack,position:e.position};if("sort"===l.type)throw{code:"S0216",stack:(new Error).stack,position:e.position};e.keepArray&&(l.keepArray=!0),l.focus=e.rhs.value,l.tuple=!0;break;case"#":n=t(e.lhs),l=n,"path"===n.type?l=n.steps[n.steps.length-1]:(n={type:"path",steps:[n]},void 0!==l.predicate&&(l.stages=l.predicate,delete l.predicate)),void 0===l.stages?l.index=e.rhs.value:l.stages.push({type:"index",value:e.rhs.value,position:e.position}),l.tuple=!0;break;case"~>":(n={type:"apply",value:e.value,position:e.position}).lhs=t(e.lhs),n.rhs=t(e.rhs);break;default:(n={type:e.type,value:e.value,position:e.position}).lhs=t(e.lhs),n.rhs=t(e.rhs),A(n,n.lhs),A(n,n.rhs)}break;case"unary":n={type:e.type,value:e.value,position:e.position},"["===e.value?n.expressions=e.expressions.map(function(e){var i=t(e);return A(n,i),i}):"{"===e.value?n.lhs=e.lhs.map(function(e){var i=t(e[0]);A(n,i);var r=t(e[1]);return A(n,r),[i,r]}):(n.expression=t(e.expression),"-"===e.value&&"number"===n.expression.type?(n=n.expression).value=-n.value:A(n,n.expression));break;case"function":case"partial":(n={type:e.type,name:e.name,value:e.value,position:e.position}).arguments=e.arguments.map(function(e){var i=t(e);return A(n,i),i}),n.procedure=t(e.procedure);break;case"lambda":n={type:e.type,arguments:e.arguments,signature:e.signature,position:e.position};var p=t(e.body);n.body=v(p);break;case"condition":(n={type:e.type,position:e.position}).condition=t(e.condition),A(n,n.condition),n.then=t(e.then),A(n,n.then),void 0!==e.else&&(n.else=t(e.else),A(n,n.else));break;case"transform":(n={type:e.type,position:e.position}).pattern=t(e.pattern),n.update=t(e.update),void 0!==e.delete&&(n.delete=t(e.delete));break;case"block":(n={type:e.type,position:e.position}).expressions=e.expressions.map(function(e){var i=t(e);return A(n,i),(i.consarray||"path"===i.type&&i.steps[0].consarray)&&(n.consarray=!0),i});break;case"name":n={type:"path",steps:[e]},e.keepArray&&(n.keepSingletonArray=!0);break;case"parent":n={type:"parent",slot:{label:"!"+x++,level:1,index:w++}},M.push(n);break;case"string":case"number":case"value":case"wildcard":case"descendant":case"variable":case"regex":n=e;break;case"operator":if("and"===e.value||"or"===e.value||"in"===e.value)e.type="name",n=t(e);else{if("?"!==e.value)throw{code:"S0201",stack:(new Error).stack,position:e.position,token:e.value};n=e}break;case"error":n=e,e.lhs&&(n=t(e.lhs));break;default:var f="S0206";"(end)"===e.id&&(f="S0207");var g={code:f,position:e.position,token:e.value};if(r)return c.push(g),{type:"error",error:g};throw g.stack=(new Error).stack,g}return e.keepArray&&(n.keepArray=!0),n};o=n(e),p();var C=f(0);if("(end)"!==s.id){var T={code:"S0201",position:s.position,token:s.value};u(T)}if("parent"===(C=k(C)).type||void 0!==C.seekingParent)throw{code:"S0217",token:C.type,position:C.position};return c.length>0&&(C.errors=c),C};return r}();e.exports=r},{"./signature":5}],5:[function(t,e,n){function i(t){return i="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},i(t)}var r=t("./utils"),s=function(){var t={a:"arrays",b:"booleans",f:"functions",n:"numbers",o:"objects",s:"strings"};function e(e){for(var n=1,s=[],o={},a=o;n<e.length;){var c=e.charAt(n);if(":"===c)break;var l=function(){s.push(o),a=o,o={}},h=function(t,e,n,i){for(var r=1,s=e;s<t.length;)if(s++,(c=t.charAt(s))===i){if(0===--r)break}else c===n&&r++;return s};switch(c){case"s":case"n":case"b":case"l":case"o":o.regex="["+c+"m]",o.type=c,l();break;case"a":o.regex="[asnblfom]",o.type=c,o.array=!0,l();break;case"f":o.regex="f",o.type=c,l();break;case"j":o.regex="[asnblom]",o.type=c,l();break;case"x":o.regex="[asnblfom]",o.type=c,l();break;case"-":a.context=!0,a.contextRegex=new RegExp(a.regex),a.regex+="?";break;case"?":case"+":a.regex+=c;break;case"(":var d=h(e,n,"(",")"),u=e.substring(n+1,d);if(-1!==u.indexOf("<"))throw{code:"S0402",stack:(new Error).stack,value:u,offset:n};o.regex="["+u+"m]",o.type="("+u+")",n=d,l();break;case"<":if("a"!==a.type&&"f"!==a.type)throw{code:"S0401",stack:(new Error).stack,value:a.type,offset:n};var p=h(e,n,"<",">");a.subtype=e.substring(n+1,p),n=p}n++}var f="^"+s.map(function(t){return"("+t.regex+")"}).join("")+"$",g=new RegExp(f),m=function(t){var e;if(r.isFunction(t))e="f";else switch(i(t)){case"string":e="s";break;case"number":e="n";break;case"boolean":e="b";break;case"object":e=null===t?"l":Array.isArray(t)?"a":"o";break;default:e="m"}return e},y=function(t,e){for(var n="^",i=0,r=0;r<s.length;r++){n+=s[r].regex;var o=e.match(n);if(null===o)throw{code:"T0410",stack:(new Error).stack,value:t[i],index:i+1};i=o[0].length}throw{code:"T0410",stack:(new Error).stack,value:t[i],index:i+1}};return{definition:e,validate:function(e,n){var i="";e.forEach(function(t){i+=m(t)});var r=g.exec(i);if(r){var o=[],a=0;return s.forEach(function(i,s){var c=e[a],l=r[s+1];if(""===l)if(i.context&&i.contextRegex){var h=m(n);if(!i.contextRegex.test(h))throw{code:"T0411",stack:(new Error).stack,value:n,index:a+1};o.push(n)}else o.push(c),a++;else l.split("").forEach(function(n){if("a"===i.type){if("m"===n)c=void 0;else{c=e[a];var r=!0;if(void 0!==i.subtype)if("a"!==n&&l!==i.subtype)r=!1;else if("a"===n&&c.length>0){var s=m(c[0]);r=s===i.subtype.charAt(0)&&0===c.filter(function(t){return m(t)!==s}).length}if(!r)throw{code:"T0412",stack:(new Error).stack,value:c,index:a+1,type:t[i.subtype]};"a"!==n&&(c=[c])}o.push(c),a++}else o.push(c),a++})}),o}y(e,i)}}}return e}();e.exports=s},{"./utils":6}],6:[function(t,e,n){function i(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=r(t))||e){n&&(t=n);var i=0,s=function(){};return{s:s,n:function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:s}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,c=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){c=!0,o=t},f:function(){try{a||null==n.return||n.return()}finally{if(c)throw o}}}}function r(t,e){if(t){if("string"==typeof t)return s(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?s(t,e):void 0}}function s(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function o(t){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},o(t)}var a=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 n(e){var n=!1;return Array.isArray(e)&&(n=0===e.filter(function(e){return!t(e)}).length),n}function r(){var t=[];return t.sequence=!0,1===arguments.length&&t.push(arguments[0]),t}function s(t){return!0===t.sequence&&Array.isArray(t)}function a(t){return t&&(!0===t._jsonata_function||!0===t._jsonata_lambda)||"function"==typeof t}function c(t){return"number"==typeof t.arity?t.arity:"function"==typeof t.implementation?t.implementation.length:"number"==typeof t.length?t.length:t.arguments.length}function l(t){return t&&!0===t._jsonata_lambda}var h=("function"==typeof Symbol?Symbol:{}).iterator||"@@iterator";function d(t){return"object"===o(t)&&null!==t&&h in t&&"next"in t&&"function"==typeof t.next}function u(t,e){if(t===e)return!0;if("object"===o(t)&&"object"===o(e)&&null!==t&&null!==e){if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return!1;for(var n=0;n<t.length;n++)if(!u(t[n],e[n]))return!1;return!0}var i=Object.getOwnPropertyNames(t),r=Object.getOwnPropertyNames(e);if(i.length!==r.length)return!1;for(i=i.sort(),r=r.sort(),n=0;n<i.length;n++)if(i[n]!==r[n])return!1;for(n=0;n<i.length;n++){var s=i[n];if(!u(t[s],e[s]))return!1}return!0}return!1}function p(t){var e,n=[],r=i(t);try{for(r.s();!(e=r.n()).done;){var s=e.value;n.push(s)}}catch(t){r.e(t)}finally{r.f()}return n}return{isNumeric:t,isArrayOfStrings:e,isArrayOfNumbers:n,createSequence:r,isSequence:s,isFunction:a,isLambda:l,isIterable:d,getFunctionArity:c,isDeepEqual:u,stringToArray:p}}();e.exports=a},{}]},{},[3])(3)}(Ui)),Ui.exports),Wi=Yi($i);const Xi=function(t){return t};function qi(t){if(!t)return Xi;try{const e=Wi(function(t){return t.replace(/(?<=^|\.|\[)([a-zA-Z_][\w]*-[\w-]*)(?=\.|$|\[|])/g,"`$1`")}(t));return function(t){return e.evaluate(t)}}catch(t){return ji(t),Xi}}function Ki(t){const e=ai(t);return null==e?"":String(e)}function Qi(t){return Number(ai(t))}function Zi(t){return t}function Ji(t){return Ki(t)}function tr(t){return Qi(t)}function er(t){if(this.param)return t=Ki(t),this.param.hasOwnProperty(t)?this.param[t]:this.param.default}function nr(t){const{param:e}=this;if(e){for(const n in e){let[i,r]=n.split("~");const s=!!i,o=!!r,a=parseFloat(i),c=parseFloat(r);if(t=Qi(t),s&&!o&&t>=a)return e[n];if(!s&&o&&t<a)return e[n];if(t>=a&&t<c)return e[n]}return e.default}}function ir(t){return Qi(t)*Math.PI/180}function rr(){}const sr=[/\bimport\b/,/\brequire\b/,/\b__proto__\b/,/\bconstructor\s*\[/,/\bprototype\b/];const or=["globalThis","self","top","parent","frames","fetch","XMLHttpRequest","eval","Function","require","importScripts","process"],ar=new Array(or.length).fill(void 0);function cr(t){try{!function(t){for(const e of sr)if(e.test(t))throw new Error(`Blocked pattern detected: ${e}`)}(t);const e=new Function("value","targets","scene",...or,t);return function(t,n){try{return e.call(this,t,n,globalThis.scene,...ar)}catch(t){return void ji(t)}}}catch(t){return ji(t),rr}}function lr(t,e,n,i,r){switch(n){case"value":return"text"===r||"string"===r?Ji.bind(t):"number"===r?tr.bind(t):Zi.bind(e);case"map":return er.bind(t);case"range":return nr.bind(t);case"radian":return ir.bind(t);case"eval":return cr(i).bind(e);default:return Zi.bind(e)}}class hr{constructor(t,e){this.owner=e,this.model=t}dispose(){this._model=null,this.owner=null,this.evaluator=null,this.accessor=null}get model(){return this._model}set model(t){const{target:e,property:n,rule:i,param:r,accessor:s}=t;this._model=t,this.evaluator=lr(this,this.owner,i,r,function(t){switch(t){case"ref":case"fillStyle":case"strokeStyle":return"string";default:return}}(n)),this.accessor=qi(s);const o=e.match(/\[(.*?)\]/);if(o){const[t,e]=o[1].split(":");this.propAccessor=qi(t),this.partAccessor=qi(e)}}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 dr(t,e,n,i){const r=e.split(".");if(1===r.length)return void(t[e]=i?{...t[e],...n}:n);const s=r[0],o=void 0!==t[s]?t[s]:"function"==typeof t.get?t.get(s):void 0,a=o?{...o}:{};let c=a;for(let t=1;t<r.length-1;t++)c[r[t]]=c[r[t]]?{...c[r[t]]}:{},c=c[r[t]];const l=r[r.length-1];c[l]=i?{...c[l],...n}:n,t[s]=a}function ur(t,e,n,i){t.forEach(t=>dr(t,e,n,i))}function pr(t=!1){(t||void 0!==this.data)&&this.mappings&&this.mappings.forEach(t=>{try{let e,{source:n,target:i,property:r,accessor:s,propAccessor:o,partAccessor:a,ndnsp:c=!1,partial:l=!1}=t;i=(i||"(self)").trim(),t.rule||(t.rule="value"),n&&"(self)"!=n?(n.startsWith("#")&&(n=n.substring(1)),e=this.root.findById(n)?.data||{}):e=this.data;const h=s(e);if("(root)"==i||"(key)"==i){if(null==h)return;const e=Object.keys(h||{}).map(t=>this.root.findOrCreate(t)).filter(Boolean).flat();e.length>0&&e.forEach(e=>{const n=t.evaluator(h[e.get("id")],[e]);!r||"(action)"===r||c&&!n&&0!==n&&!1!==n||dr(e,r,n,l)})}else if(i.startsWith("[")){if(null==h)return;if(h instanceof Array)h.forEach(e=>{const n=o(e);if(n){const i=this.root.findOrCreate(n);if(i){const n=t.evaluator(a(e),i);!r||"(action)"===r||c&&!n&&0!==n&&!1!==n||ur(i,r,n,l)}}});else{if(!(h instanceof Object))throw String("mapping data should be an object to target property-id.("+h+")");{const e=o(h);if(e){const n=this.root.findOrCreate(e);if(n){const e=t.evaluator(a(h),n);!r||"(action)"===r||c&&!e&&0!==e&&!1!==e||ur(n,r,e,l)}}}}}else{const e=this.root.findAll(i,this);if(e.length>0){const n=t.evaluator(h,e);!r||"(action)"===r||c&&!n&&0!==n&&!1!==n||ur(e,r,n,l)}}}catch(e){ji(e,this,t)}})}function fr(t,e){this.state.persistent&&this.app?.isViewMode&&this.app?.dataStorage.save(this,t.data),this.app?.lagTracker?.recordIfMonitored(this.state.tag,t.data),pr.call(this,!0)}function gr(){if(this._model.mappings)return this._model.mappings instanceof Array?void(this._mappings=(this._model.mappings||[]).filter(t=>t.property).map(t=>new hr({target:"(self)",rule:"value",...t},this))):(ji("Mappings model is invalid (should be a Array) ..",this._model.mappings),void(this._mappings=[]));this._mappings=[]}function mr(){this._mappings&&this._mappings.forEach(t=>t.dispose()),delete this._mappings}function yr(t,e){this.disposeMappings(),pr.call(this)}function br(t,e,n,i,r,s){e.complete?t.drawImage(e,n,i,r,s):e.addEventListener("load",()=>{this.invalidate()})}function _r(t){const{effects:e}=this.state;(e||[]).forEach(e=>{this.effect(t,e)})}const vr={},xr={VIEW:0,EDIT:1,SHIFT:2,ADD:3},wr="undefined"==typeof window?1:window.devicePixelRatio||(window.matchMedia&&window.matchMedia("(min-resolution: 2dppx), (-webkit-min-device-pixel-ratio: 1.5),(-moz-min-device-pixel-ratio: 1.5),(min-device-pixel-ratio: 1.5)").matches?2:1),Mr=["mousemove","mouseup","mousedown","mouseout","wheel","touchstart","touchmove","touchend","dblclick"],Sr=["keydown","keyup"],Ar={ALPHA:1,FONT_SIZE:15,FONT_FAMILY:"Roboto, sans-serif",FONT_COLOR:"black",TEXT_ALIGN:"center",TEXT_BASELINE:"middle",TEXT_WRAP:!1,BOLD:!1,ITALIC:!1,STROKE_STYLE:"#999",LINE_DASH:"solid",LETTER_SPACING:0},Er=()=>{if("undefined"==typeof document||"function"!=typeof getComputedStyle||!document.documentElement)return;const t=getComputedStyle(document.documentElement);if(!t)return;const e=t.getPropertyValue?.("--scene-theme-font-family")?.trim(),n=t.fontFamily||"sans-serif";Ar.FONT_FAMILY=e||n},kr=()=>{if("undefined"!=typeof window&&"undefined"!=typeof document&&(window.addEventListener("load",()=>{Er()}),"fonts"in document&&"ready"in document.fonts&&document.fonts.ready.then(Er),"undefined"!=typeof MutationObserver&&document.documentElement)){new MutationObserver(()=>{Er()}).observe(document.documentElement,{attributes:!0,attributeFilter:["style","class"]})}};let Cr;function Tr(t,e,n,i,r){const{alpha:s=1}=i,o=r.fillStyle;if(t.globalAlpha*=s,o)if("string"==typeof o)t.fillStyle=o,t.fill();else if("object"==typeof o)if("gradient"==o.type){t.translate(n.x,n.y);let i,{width:r,height:s}=e;if("linear"==o.gradientType){const e=3.141592653589793,n="number"==typeof o.rotation&&Number.isFinite(o.rotation)?o.rotation:0;if(n>=.436332&&n<=1.13446||n>=2.00713&&n<=2.70526||n>=3.57792&&n<=4.27606||n>=5.14872&&n<=5.84685){let o=Math.sqrt(Math.pow((r-4)/2,2)+Math.pow((s-4)/2,2));o-=o-(r+s)/3,i=t.createLinearGradient(o*Math.cos(n+e),o*Math.sin(n+e),o*Math.cos(n),o*Math.sin(n))}else i=t.createLinearGradient((r-4)/2*Math.cos(n+e),(s-4)/2*Math.sin(n+e),(r-4)/2*Math.cos(n),(s-4)/2*Math.sin(n))}else if("radial"==o.gradientType){const e=.95*Math.sqrt(Math.pow((r-4)/2,2)+Math.pow((s-4)/2,2));switch(o.center){case"center":default:i=t.createRadialGradient(0,0,0,0,0,e);break;case"left-top":i=t.createRadialGradient(-r/2,-s/2,0,-r/2,-s/2,2*e);break;case"right-top":i=t.createRadialGradient(r/2,-s/2,0,r/2,-s/2,2*e);break;case"left-bottom":i=t.createRadialGradient(-r/2,s/2,0,-r/2,s/2,2*e);break;case"right-bottom":i=t.createRadialGradient(r/2,s/2,0,r/2,s/2,2*e)}}(Array.isArray(o.colorStops)?o.colorStops:Array.isArray(o.gradientStops)?o.gradientStops:[]).forEach(t=>{if(t.position>=0&&t.position<=1)try{i.addColorStop(t.position,t.color)}catch(e){Fi("Invalid Color for colorstop : ",t.color),i.addColorStop(t.position,"#fff")}}),t.fillStyle=i,t.fill(),t.translate(-n.x,-n.y)}else if("pattern"==o.type&&o.image)if(o.guideOnly&&1!=r.app.mode)o.color&&(t.fillStyle=o.color,t.fill());else{r.prepareFillIf(!r._pattern_image_origin);const n=r._pattern_image;if(!n||!n.width||!n.height)return;let i=0,s=0,a=0,c=0,l=e.left,h=e.top;if(!o.fitPattern){i=o.offsetX,s=o.offsetY;const t=o.width?o.width:n.width,r=o.height?o.height:n.height;switch(o.align){case"center":a=e.width/2-t/2,c=e.height/2-r/2;break;case"left-top":a=0,c=0;break;case"left-bottom":a=0,c=e.height-r;break;case"right-top":a=e.width-t,c=0;break;case"right-bottom":a=e.width-t,c=e.height-r;break;case"left":a=0,c=e.height/2-r/2;break;case"right":a=e.width-t,c=e.height/2-r/2;break;case"top":a=e.width/2-t/2,c=0;break;case"bottom":a=e.width/2-t/2,c=e.height-r}l+=i+a,h+=s+c}t.translate(l,h),o.color&&(t.fillStyle=o.color,t.fill()),o.fitPattern?Math.abs((n.width-e.width)*(n.height-e.height))>1?(delete r._pattern_image,delete r._pattern_image_origin):t.fillStyle=t.createPattern(n,"no-repeat"):t.fillStyle=t.createPattern(n,o.noRepeat?"no-repeat":"repeat"),t.fill(),t.translate(-l,-h)}}function Pr(t,e){const n=this.fillStyle;if(!n||"pattern"!=n.type||!n.image)return void t(this);if("string"!=typeof n.image)return this._pattern_image_origin=this._pattern_image=n.image,void t(this);this._pattern_image=null,this._pattern_image_origin=new Image;const i=this;this._pattern_image_origin.onload=function(){if(!n.fitPattern&&!n.width&&!n.height)return i._pattern_image=i._pattern_image_origin,void t(this);let e=n.width||this.width,r=n.height||this.height;n.fitPattern&&(e=i.bounds.width,r=i.bounds.height);const s=Cr(e,r);s.getContext("2d").drawImage(this,0,0,this.width,this.height,0,0,e,r),i._pattern_image=s,t(this)},this._pattern_image_origin.onerror=function(t){e(t)};try{"data"!==String(n.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(n.image)}catch(t){e(t)}}function Dr(t){t&&this.prepareFill(t=>{this.invalidate()},t=>{ji(t)})}function Or(t,e){const n=this.fillStyle;n&&"pattern"!==n.type?this._pattern_image&&(this._pattern_image=null,this._pattern_image_origin=null):n?.image&&this.prepareFillIf(n.image)}function zr(t,e,n){let{strokeStyle:i,lineDash:r,lineWidth:s,lineCap:o,lineJoin:a,alpha:c}=e;if(i&&0!=s){if(o&&(t.lineCap=o),r){const e="round"==o;switch(r){case"solid":r=[0,0];break;case"round-dot":r=e?[0,2*s]:[s,s];break;case"square-dot":r=e?[s,2*s]:[2*s,s];break;case"dash":r=e?[3*s,2.5*s]:[4*s,1.5*s];break;case"dash-dot":r=e?[3*s,3*s,0,3*s]:[4*s,2*s,s,2*s];break;case"long-dash":r=e?[5*s,4*s]:[6*s,3*s];break;case"long-dash-dot":r=e?[5*s,3*s,0,3*s]:[6*s,2*s,s,2*s];break;case"long-dash-dot-dot":r=e?[5*s,2*s,0,2*s,0,2*s]:[6*s,s,s,s,s,s]}Array.isArray(r)||(r=[]),t.setLineDash(r)}t.globalAlpha*=c,t.strokeStyle=i,t.lineWidth=s,t.lineJoin=a,t.stroke()}}function Lr(t){const e=/(\*\*|__)(.*?)\1|(\*|_)(.*?)\3|([^\*_]+)/g,n=[];let i;for(;null!==(i=e.exec(t));)i[1]?n.push({text:i[2],bold:!0,italic:!1}):i[3]?n.push({text:i[4],bold:!1,italic:!0}):i[5]&&n.push({text:i[5],bold:!1,italic:!1});return n}function Ir(t,e,n,i=0){if(e.text.length<2)return e;let r=2;for(;r<e.text.length;r++){const s=e.text.substring(0,r);if(!(t.measureText(s).width+(r-1)*i<n))break}return{...e,text:e.text.substring(0,r-1)}}function Rr(t,e,n,i,r,s=0){const o=String(e).split("\n");return i?[].concat(...o.map(e=>function(t,e,n,i=0){const r=[];let s=[],o=0;return e.forEach(e=>{let a=e.text;for(;a.length>0;){const c=n-o,l=t.measureText(a).width+(a.length-1)*i;if(l<=c)s.push({...e,text:a}),o+=l,a="";else{const n=Ir(t,{...e,text:a},c,i);s.push(n),r.push(s),s=[],o=0,a=a.substring(n.text.length)}}}),s.length>0&&r.push(s),r}(t,r?Lr(e):[{text:e,bold:!1,italic:!1}],n,s))):o.map(t=>r?Lr(t):[{text:t,bold:!1,italic:!1}])}function jr(t,e,n,i,r,s,o=0){if(!i)return[];t.save(),t.font=n;const a=Rr(t,i,e,!!r,s,o);return t.restore(),a}function Fr(t){const{fontFamily:e=Ar.FONT_FAMILY,bold:n=Ar.BOLD,italic:i=Ar.ITALIC,fontSize:r=Ar.FONT_SIZE}=t,s=[];return n&&s.push("bold"),i&&s.push("italic"),s.push(r+"px"),s.push(e),s.join(" ")}function Br(t,e){const n=t.bold||e.bold,i=t.italic||e.italic;return Fr({...t,bold:n,italic:i})}function Nr(t,e,n,i){let{alpha:r,rotation:s,keepTextAngle:o=!1,fontColor:a=Ar.FONT_COLOR,textAlign:c=Ar.TEXT_ALIGN,textBaseline:l=Ar.TEXT_BASELINE,textBackgroundStyle:h,fontSize:d,lineHeight:u,textWrap:p,textOverflow:f,letterSpacing:g=0}=i;r=void 0!==r?r:1,d||=Ar.FONT_SIZE,u||=1.2*d,t.save();const{left:m,top:y,width:b,height:_}=e;if(s&&o&&(t.translate(m+b/2,y+_/2),t.rotate(-s),t.translate(-(m+b/2),-(y+_/2))),t.beginPath(),t.font=Fr(i),!p&&f){const e=function(t,e,n,i){const r="ellipsis"===t?"…":"",s=e.measureText(r).width,o=[];let a=0;for(const r of n){const n=[];for(const c of r){const r=e.measureText(c.text).width;if(!(a+r<=i-("ellipsis"===t?s:0))){const r=Hr(e,c,i-a-("ellipsis"===t?s:0),t);return n.push(r),o.push(n),o}n.push(c),a+=r}o.push(n),a=0}return o}(f,t,n,b);n=e}const v=n.length*u;let x;switch(l){case"top":x=y,t.textBaseline="top";break;case"bottom":x=y+_-v+u,t.textBaseline="bottom";break;default:x=y+_/2-v/2+u/2,t.textBaseline="middle"}t.globalAlpha*=r,t.fillStyle=a,n.forEach((e,r)=>{const s=x+r*u,o=function(t,e,n,i=0){return e.reduce((e,r)=>(t.font=Br(n,r),e+t.measureText(r.text).width+i*(r.text.length-1)),0)}(t,e,i,g);let l=m;switch(c){case"left":case"justify":l=m;break;case"right":l=m+b-o;break;case"center":l=m+(b-o)/2}if(h&&(t.fillStyle=h,function(t,e,n,i,r,s=0,o=!1,a=!0){s="number"==typeof s?{tl:s,tr:s,br:s,bl:s}:{tl:0,tr:0,br:0,bl:0,...s},t.beginPath(),t.moveTo(e+s.tl,n),t.lineTo(e+i-s.tr,n),t.quadraticCurveTo(e+i,n,e+i,n+s.tr),t.lineTo(e+i,n+r-s.br),t.quadraticCurveTo(e+i,n+r,e+i-s.br,n+r),t.lineTo(e+s.bl,n+r),t.quadraticCurveTo(e,n+r,e,n+r-s.bl),t.lineTo(e,n+s.tl),t.quadraticCurveTo(e,n,e+s.tl,n),t.closePath(),o&&t.fill(),a&&t.stroke()}(t,l-4,s-d/2-4,o+8,d+8,4,!0,!1),t.fillStyle=a),"justify"===c&&r<n.length-1&&e.length>1){const n=b-o,r=e.length-1,a=n/r;e.forEach((e,n)=>{t.font=Br(i,e),t.fillText(e.text,l,s),l+=t.measureText(e.text).width+(n<r?a:0)})}else e.forEach(e=>{t.font=Br(i,e),[...e.text].forEach(e=>{t.fillText(e,l,s),l+=t.measureText(e).width+g})})}),t.restore()}function Hr(t,e,n,i){let r="";for(let i=0;i<e.text.length;i++){const s=r+e.text[i];if(t.measureText(s).width>n)break;r=s}return{...e,text:r+("ellipsis"===i?"…":"")}}function Yr(t,e){for(let n=0;n<t.length;n++)if(t[n].type.startsWith("image/"))return void this.set("fillStyle",{type:"pattern",image:e[n],fitPattern:!0})}kr(),Er(),Cr="undefined"==typeof document?function(t,e){return new Canvas(t,e)}:function(t,e){const n=document.createElement("canvas");return n.width=t,n.height=e,n};const Gr=[];function Vr(t,e,n={x:0,y:0},i=0,r={x:1,y:1}){if(1!==r.x||1!==r.y?(t=(t-n.x)/r.x,e=(e-n.y)/r.y):(t-=n.x,e-=n.y),0!==i){const n=Math.cos(-i),r=Math.sin(-i),s=t*r+e*n;t=t*n-e*r,e=s}return{x:t+n.x,y:e+n.y}}function Ur(t,e,n={x:0,y:0},i=0,r={x:1,y:1}){if(t-=n.x,e-=n.y,0!==i){const n=Math.cos(i),r=Math.sin(i),s=t*r+e*n;t=t*n-e*r,e=s}return 1!==r.x||1!==r.y?{x:t*r.x+n.x,y:e*r.y+n.y}:{x:t+n.x,y:e+n.y}}function $r(t,e,n){if(!this.parent)return{x:t,y:e};const{rotation:i=0,scale:r={x:1,y:1}}=this.state;if(this.isLayer()){const n=this.state.translate,s=Vr(t,e,n,i,r);return n&&(s.x-=n.x,s.y-=n.y),s}return Vr(t,e,n=n||this.rotatePoint,i,r)}function Wr(t,e,n){if(!this.parent)return{x:t,y:e};let{rotation:i=0,scale:r={x:1,y:1}}=this.state;if(this.isLayer()){const n=this.state.translate,s=Ur(t,e,void 0,i+(this._delta?.theta??0),r);return n&&(s.x+=n.x,s.y+=n.y),s}n=n||this.rotatePoint;const{theta:s=0,tx:o=0,ty:a=0,sx:c=1,sy:l=1}=this._delta||{};if(0===s&&0===o&&0===a&&1===c&&1===l)return Ur(t,e,n,i,r);return Ur(t+o,e+a,{x:n.x+o,y:n.y+a},i+s,{x:r.x*c,y:r.y*l})}function Xr(t,e,n){n=n||this.rootModel;const i=this.transcoordS2T(t,e,n);return Ur(i.x,i.y,void 0,(n.get("rotation")||0)+n._delta.theta)}function qr(t,e,n){n=n||this.rootModel,Gr.length=0;for(let t=this.parent;t&&t!==n;t=t.parent)Gr.push(t);let i=this.transcoordS2P(t,e);for(let t=0;t<Gr.length;t++){const e=Gr[t],n=e.bounds;i.x+=n.left,i.y+=n.top,i=e.transcoordS2P(i.x,i.y)}return i}function Kr(t,e,n){n=n||this.rootModel,Gr.length=0;for(let t=this.parent;t&&t!==n;t=t.parent)Gr.push(t);let i={x:t,y:e};for(let t=Gr.length-1;t>=0;t--){const e=Gr[t];i=e.transcoordP2S(i.x,i.y);const n=e.bounds;i.x-=n.left,i.y-=n.top}return i}function Qr(t,e,n){const i=this.transcoordT2P(t,e,n);return this.transcoordP2S(i.x,i.y)}function Zr(t,e,n){const i=this.rootModel,r=this.transcoordS2T(t,e,i);return n.transcoordT2S(r.x,r.y,i)}function Jr(t,e,n){if(!n)for(n=this;n&&!n.isLayer();)n=n.parent;const{translate:i={x:0,y:0},scale:r={x:1,y:1},rotation:s=0}=n.model,o=Vr(t,e,i,s,r);return i&&(o.x-=i.x,o.y-=i.y),n===this?o:this.transcoordT2S(o.x,o.y,n)}function ts(t,e,n){if(!n)for(n=this;n&&!n.isLayer();)n=n.parent;let i;if(i=n!==this?this.transcoordS2T(t,e,n):{x:t,y:e},!this.scalable)return i;const{translate:r={x:0,y:0},rotation:s=0,scale:o={x:1,y:1}}=n.model;return i=Ur(i.x,i.y,void 0,s+n._delta.theta,o),r&&(i.x+=r.x,i.y+=r.y),i}function es(t){let e=0,n=0,i=0,r=0,s=!1;return t.forEach(t=>{s?(e=Math.min(t.left,e),n=Math.min(t.top,n),i=Math.max(t.left+t.width,i),r=Math.max(t.top+t.height,r)):(e=t.left,n=t.top,i=t.left+t.width,r=t.top+t.height,s=!0)}),{left:e,top:n,width:i-e,height:r-n}}function ns(t){const e=t.element,n=t.fillStyle,i=e.style;if(n)if("string"==typeof n)i.backgroundColor=n;else switch(n.type){case"pattern":if(i.backgroundImage="url("+n.image+")",i.backgroundColor="transparent",n.fitPattern?i.backgroundSize="100% 100%":n.width||n.height?i.backgroundSize=`${n.width?n.width+"px":"auto"} ${n.height?n.height+"px":"auto"}`:i.backgroundSize="contain",n.fitPattern)i.backgroundRepeat="no-repeat";else{const{offsetX:t,offsetY:e,noRepeat:r,align:s,color:o}=n;if(r&&(i.backgroundRepeat="no-repeat"),o&&(i.backgroundColor=o),s)switch(s){case"center":i.backgroundPosition="center center";break;case"left-top":i.backgroundPosition="left top";break;case"left-bottom":i.backgroundPosition="left bottom";break;case"right-top":i.backgroundPosition="right top";break;case"right-bottom":i.backgroundPosition="right bottom";break;case"left":i.backgroundPosition="left center";break;case"right":i.backgroundPosition="right center";break;case"top":i.backgroundPosition="center top";break;case"bottom":i.backgroundPosition="center bottom"}else t||e?i.backgroundPosition=`${Number(t)||0}px ${Number(e)||0}px`:delete i.backgroundPosition}break;case"gradient":i.background=function(t,e){const n=e.colorStops,i=e.gradientType;if(n instanceof Array&&n.length>0)switch(i){case"radial":return"radial-gradient(farthest-corner at "+function(t,e){const{width:n,height:i}=t.bounds;switch(e){case"center":return[n/2,i/2];case"left-top":return[0,0];case"right-top":return[n,0];case"left-bottom":return[0,i];default:return[n,i]}}(t,e.center||"center").map(t=>t+"px").join(" ")+","+n.map(t=>`${t.color} ${100*t.position}%`).join(",")+")";case"linear":return"linear-gradient("+(180*(e.rotation||0)/3.141592653589793+90+"deg")+", "+n.map(t=>`${t.color} ${100*t.position}%`).join(",")+")"}return""}(t,n)}else i.background="transparent"}const is={x:1,y:1},rs={boxSizing:"border-box",margin:"0px",position:"absolute",outline:"none"};function ss(t){let{id:e,scale:n=is,bold:i,italic:r,fontFamily:s="",textAlign:o,textBaseline:a,textOverflow:c,paddingTop:l,paddingBottom:h,paddingLeft:d,paddingRight:u,fontSize:p=Ar.FONT_SIZE,lineWidth:f=0,lineHeight:g,lineDash:m}=t.state;h||=0,l||=0,d||=0,u||=0;const y=t.state.class,{strokeStyle:b,rotation:_=0,fontColor:v,hidden:x}=t,{left:w,top:M,width:S,height:A}=t.bounds,E=t.element;if(E.hidden=x,e&&(E.id=e),y&&(E.className=y),Object.assign(E.style,rs,{fontFamily:s,fontSize:p+"px",width:S+"px",height:A+"px",paddingTop:l+"px",paddingRight:u+"px",paddingBottom:h+"px",paddingLeft:d+"px",border:f+"px",borderColor:b,borderStyle:f>0?m||Ar.LINE_DASH:"",color:v,fontWeight:i?"bold":"",fontStyle:r?"italic":"",textAlign:"end"==o?"right":"start"==o?"left":o,verticalAlign:a,lineHeight:void 0===g?"":g+"px",whiteSpace:c?"nowrap":"",overflow:c?"hidden":"",textOverflow:c||""},t.isIn3DSpace()?{}:{left:w+"px",top:M+"px"}),ns(t),function(t){if(!t.isShadowable()||!t.state.shadow)return;const e=t.state.shadow,n=e.offsetX??e.left??0,i=e.offsetY??e.top??0,r=e.blur??e.blurSize??0,s=e.color??"transparent";t.element.style.boxShadow=`${n}px ${i}px ${r}px ${s}`}(t),t.isIn3DSpace())return;const k=t.delta(),C=(n&&n.x||1)*k.sx,T=(n&&n.y||1)*k.sy,P=(_||0)+k.theta,D=k.tx||0,O=k.ty||0;E.style.transform=`rotate(${P}rad) translate(${D}px, ${O}px) scale(${C}, ${T}) perspective(1px)`}function os(t,e){let n=this.bounds,i=this.rotatePoint;const r=this.get("rotation"),s=this.get("scale");if(t){const i=t.call(e,n);i&&(n=i)}const{left:o,top:a,width:c,height:l}=n;let h=[{x:o,y:a},{x:o+c,y:a+l}];h=h.map(t=>Ur(t.x,t.y,i,r,s));let d=h[0],u=h[1];i={x:(d.x+u.x)/2,y:(d.y+u.y)/2},h=h.map(t=>Vr(t.x,t.y,i,r,s)),d=h[0],u=h[1],this.bounds={left:d.x,top:d.y,width:u.x-d.x,height:u.y-d.y}}function as(t,e,n){let i=this.path,r=this.rotatePoint;this.get("rotation"),this.get("scale"),t&&(i=t.call(n,i));let s=i.map(t=>{const e=this.toParent(t.x,t.y);return void 0!==t.z&&(e.z=t.z),e});if(e){const t=e.call(n,s);t&&(s=t)}const o={x:0,y:0};let a,c,l,h;i=s.map(t=>this.fromParent(t.x,t.y,o)),a=c=i[0].x,l=h=i[0].y;for(let t=1;t<i.length;t++){const e=i[t];e.x<a?a=e.x:e.x>c&&(c=e.x),e.y<l?l=e.y:e.y>h&&(h=e.y)}r={x:(a+c)/2,y:(l+h)/2},r=this.toParent(r.x,r.y,o),this.path=s.map(t=>{const e=this.fromParent(t.x,t.y,r);return void 0!==t.z&&(e.z=t.z),e})}let cs,ls=[];function hs(){cs=null;const t=performance.now();ls=ls.filter(t=>ds(t));const e=ls.reduce((e,n)=>{const i=t-n.updatedAt;return i>=n.retention?e.kills.push(n):e.next=0==e.next?n.retention-i:Math.min(e.next,n.retention-i),e},{next:0,kills:[]});e.kills.forEach(t=>{const e=ls.indexOf(t);-1!=e?(ls.splice(e,1),t.removeSelf(!0)):ji("Should not be here. Maybe reentrance problem.")}),e.next>0&&(cs=setTimeout(us,Math.max(e.next,500)))}function ds(t){return!t.disposed&&t.retention>0&&!t.isTemplate()&&t.app&&t.app.isViewMode}const us=function(t,e,n){var i=!0,r=!0;if("function"!=typeof t)throw new TypeError("Expected a function");return F(n)&&(i="leading"in n?!!n.leading:i,r="trailing"in n?!!n.trailing:r),Jn(t,e,{leading:i,maxWait:e,trailing:r})}(function(){requestAnimationFrame(hs)},500);var ps=new class{add(t){ds(t)&&-1==ls.indexOf(t)&&(ls.push(t),t.touch()),this.touch()}remove(t){const e=ls.indexOf(t);e>0&&ls.splice(e,1),this.touch()}touch(){null!==cs&&(clearTimeout(cs),cs=null),us()}dispose(){us.cancel(),null!==cs&&(clearTimeout(cs),cs=null),ls=[]}get length(){return ls.length}};const fs=function(t){return t};function gs(t){const e=t.indexOf("||");let n="",i="";-1!=e&&(n=t,i=t.substring(e+2,t.length-1).trim(),t=t.replace(t.substring(e,t.length-1),"").trim());const r=t.substr(2,t.length-3).trim().replace(/\[(\w+)\]/g,".$1").replace(/^\./,"").split(".").filter(t=>!!t.trim()),s=r.slice(1);return{defaultValue:i,match:t,originText:n||t,target:r[0],accessor:s.length>0?function(t){return s.reduce((t,e)=>t?t[e]:void 0,t)}:fs}}function ms(t){if(!t)return;const e=String(t),n=(e.match(/#{(\S*)}/)||[]).map(t=>gs(t))[0];if(n)return n.accessor(this.getState(n.target));const i=(e.match(/\${[^}]*}/)||[]).map(t=>gs(t))[0];if(i){const t=this.root.findById(i.target);return i.accessor(this.getState(t))}return t}function ys(t,e){if(!t)return;const n=String(t),i=e||ai,r=(n.match(/#{(\S*)}/gi)||[]).map(t=>gs(t)),s=(n.match(/\${[^}]*}/gi)||[]).map(t=>gs(t));if(0==r.length&&0==s.length)return n;let o=n;return r.forEach(t=>{const e=i(t.accessor(this.getState(t.target)));o=o.replace(t.match,void 0===e?"":e)}),s.forEach(t=>{const e=this.root.findById(t.target),n=i(t.accessor(e&&e.data));o=o.replace(t.match,void 0===n?"":n)}),o}function bs(t,e,n){if(!t)return;const i=n||ai,r=String(t),s=(r.match(/#{[^}]*}/gi)||[]).map(t=>gs(t)),o=(r.match(/\${[^}]*}/gi)||[]).map(t=>gs(t));return 0!=s.length||0!=o.length?function(){let t=r;return s.forEach(n=>{const r=i(n.accessor(e.getState(n.target)));t=t.replace(n.originText,void 0===r?n.defaultValue||"":r)}),o.forEach(n=>{const r=e.root.findById(n.target),s=i(n.accessor(r&&r.data));t=t.replace(n.originText,void 0===s?n.defaultValue||"":s)}),t}:void 0}class _s{constructor(){}static registerDecorator(t,e){_s.constructors.set(t,e)}static create(t,e,n={},i){const r=_s.constructors.get(t);if(!r)throw new Error(`unknown decorator type: ${t}`);return new r(i,e,n)}}_s.constructors=new Map;class vs{constructor(){this.overlays=new WeakMap}static getInstance(){return vs.instance||(vs.instance=new vs),vs.instance}addOverlay(t){if(this.overlays.has(t))return!1;const e={element:t,registry:new Map};return this.overlays.set(t,e),!0}removeOverlay(t){if(!this.overlays.has(t))return!1;const e=this.overlays.get(t);for(const[n]of e.registry)this.removeFromOverlay(t,n);return this.overlays.delete(t),!0}addToOverlay(t,e,n,i={}){this.overlays.has(t)||this.addOverlay(t);const r=this.overlays.get(t);r.registry.has(e)||r.registry.set(e,new Map);const s=r.registry.get(e);s.has(n)&&s.get(n).stop();const o=_s.create(n,e,i,t);return s.set(n,o),e?.root?.app?.suppressAnimations||o.start(),o}removeFromOverlay(t,e,n){if(!this.overlays.has(t))return;const i=this.overlays.get(t);if(!i.registry.has(e))return;const r=i.registry.get(e);let s=null;if(n){if(r.has(n))try{const t=r.get(n);s=n,t&&"function"==typeof t.stop&&t.stop(),r.delete(n)}catch(t){ji(`데코레이터(${n}) 제거 중 오류:`,t)}}else{const t=Array.from(r.keys());for(const e of t)try{const t=r.get(e);t&&"function"==typeof t.stop&&t.stop(),r.delete(e)}catch(t){ji(`데코레이터(${e}) 제거 중 오류:`,t)}s="_all_"}0===r.size&&i.registry.delete(e),!s||"data-spread"!==s&&"_all_"!==s||this.restartBorderAnimations(t,e)}restartBorderAnimations(t,e){if(!this.overlays.has(t))return;const n=this.overlays.get(t);for(const[t,i]of n.registry.entries()){if(e&&t===e)continue;const n=i.get("border-highlighting");if(n)try{"function"==typeof n.invalidate&&n.invalidate();const t=n;"function"==typeof t.startAnimations&&t.options&&t.options.animation&&t.startAnimations()}catch(t){ji("애니메이션 재시작 중 오류:",t)}}}removeAllFromOverlay(t,e){if(!this.overlays.has(t))return;const n=this.overlays.get(t);if(e)for(const[i]of n.registry)this.removeFromOverlay(t,i,e);else{for(const[t,e]of n.registry)for(const t of e.values())t.stop();n.registry.clear()}}getDecoratorFromOverlay(t,e,n){const i=this.overlays.get(t);return i?.registry.get(e)?.get(n)}getDecoratorsFromOverlay(t,e){const n=this.overlays.get(t);return n&&n.registry.has(e)?Array.from(n.registry.get(e).values()):[]}getTargetsWithType(t,e){const n=this.overlays.get(t);if(!n)return[];const i=[];for(const[t,r]of n.registry)r.has(e)&&i.push(t);return i}updateInOverlay(t,e,n,i){const r=this.getDecoratorFromOverlay(t,e,n);r&&r.update(i)}invalidateOverlay(t){if(!this.overlays.has(t))return;const e=this.overlays.get(t),n=Array.from(e.registry.entries());for(const[e,i]of n){if(e.disposed){this.removeFromOverlay(t,e);continue}this.getDecoratorsFromOverlay(t,e).forEach(t=>{t.invalidate()})}}}function xs(t,e){return!1}function ws({x:t,y:e},...n){const i=this.path,r=t,s=e;this.path=i.map(t=>({x:t.x+r,y:t.y+s}))}function Ms(t){const e=t??this.center.x,{rotation:n}=this.state,i=this.fillStyle;if(this.set("rotation",2*Math.PI-n),i&&"gradient"===i.type&&"linear"===i.gradientType){const t=Hn(i);t.rotation=(Math.PI-parseFloat(i.rotation||0))%(2*Math.PI),this.set("fillStyle",t)}this.path=this.path.map(t=>({x:2*e-t.x,y:t.y}))}function Ss(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)}function As(t,e,n){if(n){const e=this.bounds,n=e.height/e.width;let i=t.width-e.width,r=t.height-e.height;i*n>r?r=i*n:i=r/n;let s=t.left-e.left,o=t.top-e.top;return 0!=s&&0!=o?(o=-r,s=-i):0!=s?s=-i:0!=o&&(o=-r),{left:e.left+s,top:e.top+o,width:e.width+i,height:e.height+r}}return t}function Es(t,e){if(e||this.app.rotateStepForced){const e=this.app.rotateStep;return Math.floor((t+e/2)/e)*e}return t}function ks(t){return function(t,e){const n=t.path.slice();if(!n||!n.length)return void ji("path should not be empty");let i=1;const r=[];if(t.isLine()||n.push(n[0]),e<=0)return t.toScene(n[0].x,n[0].y);if(e>=1)return t.toScene(n[n.length-1].x,n[n.length-1].y);for(;n[i];){const t=n[i-1],e=n[i],s=e.x-t.x,o=e.y-t.y;r.push(Math.sqrt(s*s+o*o)),i++}const s=r.reduce(function(t,e){return t+e},0);i=0;let o=0;do{o+=r[i++]}while(o/s<e);o-=r[--i],e=(e-o/s)*(s/r[i]);const a=n[i%n.length],c=n[(i+1)%n.length],l=a.x+Math.round((c.x-a.x)*e),h=a.y+Math.round((c.y-a.y)*e);return t.toScene(l,h)}(this,t||0)}function Cs(){const t=this.path;let e,n,i,r;e=n=t[0].x,i=r=t[0].y;for(let s=1;s<t.length;s++){const o=t[s];o.x<e?e=o.x:o.x>n&&(n=o.x),o.y<i?i=o.y:o.y>r&&(r=o.y)}return{left:e,top:i,width:n-e,height:r-i}}function Ts(t){const 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)return;const n=0==e.width?1:t.width/e.width,i=0==e.height?1:t.height/e.height;this.path=this.path.map(r=>({x:t.left+(r.x-e.left)*n,y:t.top+(r.y-e.top)*i}))}function Ps(){const t=this.bounds;return{x:t.left+t.width/2,y:t.top+t.height/2}}function Ds(t){if(!t||isNaN(t.x)||isNaN(t.y))return;const 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)return;const n=t.x-e.x,i=t.y-e.y;this.path=this.path.map(t=>({x:t.x+n,y:t.y+i}))}function Os(){const{x:t,y:e}=this.center;return{x:t,y:e,z:this.state.zPos}}function zs(t){const{x:e,y:n,z:i}=t||{};this.center={x:e,y:n},isNaN(i)||this.setState("zPos",Number(i))}function Ls(){const{rotationX:t,rotationY:e,rotation:n}=this.state;return{x:t,y:e,z:-n}}function Is(t){const{x:e,y:n,z:i}=t;this.setState({rotationX:e,rotationY:n,rotation:-i})}function Rs(){const{width:t,height:e}=this.bounds,{depth:n}=this.state;return{width:t,height:e,depth:n}}function js(t){const{width:e,height:n,depth:i}=t,{top:r,left:s}=this.bounds;this.bounds={top:r,left:s,width:e,height:n},this.setState("depth",i)}function Fs(){return ji("이 컴포넌트에 get path 가 구현되어있지 않음.",this),[]}function Bs(t){ji("이 컴포넌트에 get path 가 구현되어있지 않음.",this)}function Ns(){return this.path}function Hs(){return this.center}function Ys(){return this.nature.mutable}function Gs(){return this.nature.resizable&&!this.stuck}function Vs(){return this.nature.rotatable&&!this.stuck}const Us={x:1,y:1};function $s(t,e,n){const{offsetX:i,offsetY:r,blur:s,color:o}=function(t){return{offsetX:t.offsetX??t.left??0,offsetY:t.offsetY??t.top??0,blur:t.blur??t.blurSize??0,color:t.color??"transparent"}}(e),a=n.rootModel.get("scale")??Us;t.shadowOffsetX=i*a.x*wr,t.shadowOffsetY=r*a.y*wr,t.shadowBlur=s*a.x*wr,t.shadowColor=o}function Ws(t){t.save(),this.prerender(t),this.render(t),this.postrender(t),t.restore()}function Xs(t){const e=this.rotatePoint,{scale:n,rotation:i,shadow:r,alpha:s}=this.state,o=(n&&n.x||1)*this._delta.sx,a=(n&&n.y||1)*this._delta.sy,c=(i||0)+this._delta.theta,{tx:l=0,ty:h=0}=this._delta,d=(s||1)-this._delta.fade;(l||h)&&t.translate(l,h),(1!=o||1!=a||c)&&(t.translate(e.x,e.y),1==o&&1==a||t.scale(o,a),c&&t.rotate(c),t.translate(-e.x,-e.y)),d&&(t.globalAlpha=d),r&&$s(t,r,this),this.app.isEditMode&&this.hidden&&(t.globalAlpha*=.5)}function qs(t){}function Ks(t){this.drawText(t)}function Qs(t,e){t(this)}function Zs(t){t&&this.prepare&&this.prepare(t=>{this.invalidate()},t=>{ji(t)})}function Js(t){!this.textHidden&&this.text&&this.hasTextProperty&&Nr(t,this.textBounds,this.textLines(t),this.state)}function to(t,e){zr(t,e?{...this.state,...e}:this.state)}function eo(t,e){this.fillStyle&&"transparent"!=this.fillStyle&&(Tr(t,this.bounds,this.center,e?{...this.state,...e}:this.state,this),function(t){t.shadowColor="transparent"}(t))}function no(){return this.get("strokeStyle")}function io(t){this.set("strokeStyle",t)}function ro(){return this.getState("fillStyle")}function so(t){this.setState("fillStyle",t)}function oo(){return this.get("fontColor")}function ao(t){this.set("fontColor",String(ai(t)))}function co(){return this.getState("rotation")}function lo(t){this.setState("rotation",Number(ai(t)))}function ho(){return this.app.isEditMode?["decotag","data-spread"]:[]}function uo(){const{id:t,tag:e}=this.state;return(t?`#${t}`:"")+(e?`@${e}`:"")}function po(){return this.getState("hidden")||!this.data&&0!==this.data&&this.getState("ndns")||this.isTemplate()}function fo(t){this.setState("hidden",t)}function go(){return this.state.tag}function mo(t){this.setState("tag",t)}function yo(){}function bo(t){this.data instanceof Array?this.data=this.data.concat(t):this.data instanceof Object?this.data={...this.data,...t}:this.data??=t}function _o(){const t=this.getState("text");return null==t?"":String(t)}function vo(t){const{textWrap:e,supportMarkdown:n}=this.state;return jr(t||this.getContext(),this.textBounds.width,this.font,this.text,e,n)}function xo(){return Fr(this.model)}function wo(){const t=this.get("lineHeight");return t||1.2*this.fontSize}function Mo(){return this._text_substitutor||(this._text_substitutor=bs(this.getState("text"),this,void 0)||this.defaultTextSubstitutor),this._text_substitutor}function So(){const t=this.get("textFormat");return t?function(t,e){if(!t||isNaN(+e))return e;let n,i,r,s,o,a,c,l,h,d,u,p=t.length,f=t.search(/[0-9\-\+#]/),g=f>0?t.substring(0,f):"",m=t.split("").reverse().join(""),y=m.search(/[0-9\-\+#]/),b=p-y,_=t.substring(b,b+1),v=b+("."===_||","===_?1:0),x=y>0?t.substring(v,p):"";if(n=(e="-"===(t=t.substring(f,v)).charAt(0)?-e:+e)<0?e=-e:0,i=t.match(/[^\d\-\+#]/g),r=".",s=i&&i[1]&&i[0]||",",t=t.split("."),e=+(e=e.toFixed(t[1]&&t[1].length))+"",a=t[1]&&t[1].lastIndexOf("0"),l=e.split("."),(!l[1]||l[1]&&l[1].length<=a)&&(e=(+e).toFixed(a+1)),h=t[0].split(s),t[0]=h.join(""),o=t[0]&&t[0].indexOf("0"),o>-1)for(;l[0].length<t[0].length-o;)l[0]="0"+l[0];else 0===+l[0]&&(l[0]="");if((e=e.split("."))[0]=l[0],c=h[1]&&h[h.length-1].length,c){for(d=e[0],m="",b=d.length%c,p=d.length,v=0;v<p;v++)m+=d.charAt(v),!((v-b+1)%c)&&v<p-c&&(m+=s);e[0]=m}return e[1]=t[1]&&e[1]?"."+e[1]:"",i=e.join(""),"0"!==i&&""!==i||(n=!1),u="+"==t[0].substring(0,1)?n?"-":"+":n?"-":"",g+(u+i)+x}(t,this.textSubstitutor()):this.textSubstitutor()}function Ao(t){delete this._text_substitutor;const e=ai(t);this.setState("text",null==e?"":String(e))}function Eo(){let{paddingTop:t,paddingLeft:e,paddingRight:n,paddingBottom:i}=this.state;i||=0,t||=0,e||=0,n||=0;const{left:r,top:s,width:o,height:a}=this.bounds;return{left:r+e,top:s+t,width:Math.max(o-e-n,0),height:Math.max(a-t-i,0)}}function ko(){return 0}function Co(){return!!this._textHidden}function To(t){this._textHidden=!!t,this.invalidate()}function Po(){return!0}function Do(t){return t}function Oo(t){return Math.pow(t,2)}function zo(t){return 1-Math.sin(Math.acos(t))}function Lo(t,e={x:1.5}){return Math.pow(t,2)*((e.x+1)*t-e.x)}function Io(t){for(let e=0,n=1;;e+=n,n/=2)if(t>=(7-4*e)/11)return-Math.pow((11-6*e-11*t)/4,2)+Math.pow(n,2)}function Ro(t,e={x:1.5}){return Math.pow(2,10*(t-1))*Math.cos(20*Math.PI*e.x/3*t)}var jo={linear:Do,quad:Oo,circ:zo,back:Lo,bounce:Io,elastic:Ro},Fo=Object.freeze({__proto__:null,back:Lo,bounce:Io,circ:zo,default:jo,elastic:Ro,linear:Do,quad:Oo});function Bo(t){const{duration:e=1e3,easing:n,component:i,step:r=()=>{},onStart:s,onProgress:o,onComplete:a,options:c,repeat:l=!1,delta:h}=t;let d;d="string"==typeof h?Fo[h]:h||Do,"out"===n?d=function(t,e){return function(n){return 1-t(1-n,e)}}(d,c):"inout"===n&&(d=function(t,e){return function(n){return n<.5?t(2*n,e)/2:(2-t(2*(1-n),e))/2}}(d,c));let u=!1,p=null;return{start:function(){if(u)return this;if(i?.root?.app?.suppressAnimations)return this;u=!0,s&&s();let t=0;const n=()=>{if(!u)return;if(i?.root?.app?.suppressAnimations)return this.stop(),void(t=0);0===t&&(t=performance.now());const s=(performance.now()-t)/e,a=l?s%1:Math.min(s,1);r(d(a,c)),o&&o(a),!(s>=1)||l&&u||(this.stop(),t=0),u&&(p=requestAnimationFrame(n))};return p=requestAnimationFrame(n),this},stop:function(){return u=!1,null!==p&&(cancelAnimationFrame(p),p=null),a&&a(),this}}}class No{constructor(t,e){this._started=!1,this._raf=null,this._timeout=null,this.client=t,this.config=e,this._started=!1;const{delta:n="linear",options:i,ease:r}=this.config;let s;s="string"==typeof n?jo[n]:n,this.delta="out"===r?function(t,e){return function(n){return 1-t(1-n,e)}}(s,i):"inout"===r?function(t,e){return function(n){return n<.5?t(2*n,e)/2:(2-t(2*(1-n),e))/2}}(s,i):s,this.init()}dispose(){this.stop(),delete this.client}init(){}start(){if(this._started)return;if(this.client?.root?.app?.suppressAnimations)return;const{duration:t=2e3,delay:e=0,repeat:n=!1,interval:i=0,onComplete:r}=this.config;this._started=!0;let s=0,o=0;const a=()=>{if(this._raf=null,this._timeout=null,!this._started)return;if(this.client?.root?.app?.suppressAnimations)return void this.stop(r);0==s&&(s=performance.now(),this.client?.touch?.());const c=performance.now()-s,l=Math.max((c-e)%(t+i),0)/t,h=i<=0&&o>l;if(o=l,l>=1||h){if(this.step(1),this.client&&this.client.invalidate?.(),!n||!this._started)return this.stop(r),void(s=0);if(i>0)return void(this._timeout=setTimeout(()=>{this.step(0),this.client&&this.client.invalidate?.(),this._timeout=setTimeout(a,i/2)},i/2))}else this.step(this.delta(l)),this.client&&this.client.invalidate?.();this._raf=requestAnimationFrame(a)};this._raf=requestAnimationFrame(a)}stop(t){this._raf&&cancelAnimationFrame(this._raf),this._timeout&&clearTimeout(this._timeout),this._raf=null,this._timeout=null,this._started=!1,t?.()}step(t){}get started(){return this._started}set started(t){this.started!=!!t&&(t?this.start():this.stop())}}const Ho={rotation:class extends No{step(t){const{theta:e=6.28}=this.config;this.client.delta?.("theta",t*e)}},vibration:class extends No{step(t){const{theta:e=.2617993877991494}=this.config,n=4*e;let i=t*n;t<1/4?i*=-1:t<3/4?i-=2*e:i=n-i,this.client.delta?.("theta",i)}},heartbeat:class extends No{step(t){const{scale:e=1.3}=this.config,n=2*(e-1);let i;i=t<.5?1+n*t:1+(1-t)*n,this.client.delta?.({sx:i,sy:i,sz:i})}},moving:class extends No{step(t){const{x:e=0,y:n=0}=this.config;this.client.delta?.({tx:t*e,ty:t*n})}},outline:class extends No{step(t){const{rideOn:e}=this.config;if(!e||!this.client)return;const n=this.client.root.findById(e);if(!n)return;let i={tx:0,ty:0};const r=this.client.delta("");r&&"object"==typeof r&&"tx"in r&&"ty"in r&&(i=r);const{tx:s,ty:o}=i,a=n.outline(t),{x:c,y:l}=this.client.center,h=this.client.toScene(c,l);this.client.delta({tx:a.x-h.x+s,ty:a.y-h.y+o})}},fade:class extends No{step(t){const{startAlpha:e=1,endAlpha:n=0}=this.config,i=Math.max(Math.min(e,n,1),0),r=2*(Math.min(Math.max(e,n,1),1)-i);let s;s=t<.5?r*t:(1-t)*r,this.client.delta?.("fade",s)}},waypoint:class extends No{constructor(){super(...arguments),this._startX=0,this._startY=0,this._endX=0,this._endY=0}start(){let{toComponent:t,fromComponent:e}=this.config;e||(e=t);const n=e.center,i=t.center,{x:r,y:s}=e.toScene(n.x,n.y),{x:o,y:a}=t.toScene(i.x,i.y);this._startX=r,this._startY=s,this._endX=o,this._endY=a;const c=this.config.yawOffset??Math.PI/2,l=Math.atan2(a-s,o-r)+c;this.client.location={x:r,y:s},this.client.setState("rotation",l),super.start()}stop(t){const{toComponent:e,finalize:n="snap"}=this.config;if(super.stop(t),"snap"===n&&e){const t=e.center,n=e.toScene(t.x,t.y);this.client.delta({tx:0,ty:0}),this.client.location=n}}step(t){const e=(this._endX-this._startX)*t,n=(this._endY-this._startY)*t;this.client.location={x:this._startX+e,y:this._startY+n}}}};function Yo(t,e){const n=e.type?Ho[e.type]:void 0;return n?new n(t,e):null}const Go={gradation:function(t,e,n){const{subType:i,from:r,to:s,colors:o}=n;let a;switch(i){case"linear":default:a=e.createLinearGradient(r.x,r.y,s.x,s.y);break;case"radial":a=e.createRadialGradient(r.x,r.y,r.r,s.x,s.y,s.r)}o&&(o.forEach(function(t){a.addColorStop(t.endPoint,t.color)}),e.fillStyle=a,e.fill())},shadow:$s};function Vo(t){return this._animate&&this._animate.stop(),this._animate=Bo(t),this._animate}function Uo(t,e){return function(t,e,n){const i=Go[n.type];i&&i(t,e,n)}(this,t,e)}const $o=100;function Wo(t,e){if(null!==e){if("number"==typeof e){if(!Number.isFinite(e))return;if(!Number.isInteger(e))return Math.round(e*$o)/$o}return e}}function Xo(t){if(null==t||"object"!=typeof t)return t;for(const e in t){const n=t[e];null===n?delete t[e]:"number"==typeof n?Number.isFinite(n)?Number.isInteger(n)||(t[e]=Math.round(n*$o)/$o):delete t[e]:"object"==typeof n&&Xo(n)}return t}function qo(...t){return JSON.stringify(this.hierarchy,Wo,...t)}function Ko(){delete this._model[""],"chartjs"!==this._model.type&&delete this._model.chart}function Qo(t){this.rootModel.closeScene(t)}function Zo(t,e){return t?"object"==typeof t?(this._delta={...this._delta,...t},this._delta):void 0!==e?(this._delta[t]=e,this._delta[t]):void 0:this._delta}function Jo(){this.parent&&this.parent.invalidate()}function ta(){const t=this.nature["value-property"]||"text";return"value"==t?this.getState("value"):this[t]}function ea(t){const e=this.nature["value-property"]||"text";"value"==e?this.setState("value",t):this[e]=t}function na(){return this.getState("data")}function ia(t){this.setState("data",t),this.touch()}function ra(t){const e=this.model.event?.tap;if(e){const{x:t,y:n}=this.center;this.rootModel?._doEventAction(e,this,!0,new MouseEvent("click",{clientX:t,clientY:n}))}}function sa(){return!this._mappings&&this.parent&&this.buildMappings(),this._mappings}function oa(){return Number(this.get("retention"))||0}function aa(){if(this.app.isViewMode&&!this.isTemplate()){if(!this._animation){const t=this.state.animation;t&&t.oncreate&&(this._animation=Yo(this,t.oncreate))}return this._animation}}function ca(){return!!this.animation?.started}function la(t){this.animation&&(this.animation.started=t)}function ha(){}function da(t,e,n,i){const r=e.get("class");if(!r)return!1;return(r.split(" ")||[]).indexOf(t.substr(1))>=0}function ua(t,e,n,i){return t==e.get("type")}function pa(t,e,n,i){if("(all)"==t)return!0;switch(t.charAt(0)){case"#":return function(t,e){return t.substring(1)==e.get("id")}(t,e);case".":return da(t,e);case"(":return function(t,e,n,i){switch(t){case"(all)":return!0;case"(self)":return i===e;case"(root)":return!i.parent&&i===e;case"(descendant)":return i!==e;case"(child)":return i===e.parent;default:return!1}}(t,e,0,i);default:return ua(t,e)}}function fa(t,e,n,i,r,s){return t(e,n,i,r)&&s.push(n),n.components&&n.components.forEach(n=>{fa(t,e,n,i,r,s)}),s}function ga(t,e,n,i){switch(t){case"(all)":return!0;case"(parent)":return n&&n.parent===e;case"(child)":case"(children)":return n&&n===e.parent;case"(sibling)":case"(siblings)":return n&&n.parent===e.parent&&n!==e;default:return!1}}function ma(t,e,n){if("(root)"==t)return[e];if("(self)"==t)return n?[n]:[];let i;switch(t.charAt(0)){case"#":const n=e.root.findAllById?.(t.substring(1));return n||[];case".":i=da;break;case"(":i=ga;break;default:i=ua}return fa(i,t,e,n,e,[])}function ya(t,...e){if(t(this,...e))return this}function ba(t,...e){return"string"==typeof t?ma(t,this,e[0]||this):"function"==typeof t&&t(this,...e)?[this]:void 0}function _a(t,e,n){if(!this.capturable||n?.(this))return!1;const i=this.fromParent(t,e);return this.contains(i.x,i.y)?this:void 0}function va(t){return this.anchors.find(e=>e.name===t)}function xa(t){return!0}function wa(t){return this._parent.getContext(t??this)}function Ma(){return this.isRoot()?this:this.parent&&this.parent.root}function Sa(){return this.isRootModel()?this:this.parent&&this.parent.rootModel}function Aa(){return this._parent}function Ea(t){this._parent=t}function ka(){return this.nature.anchors||[]}function Ca(){let t=this.position,e=this;for(;"static"===t&&e.parent;)e=e.parent,t=e.position;return"static"==t}function Ta(){return!!(this.parent&&this.parent.layout.isStuck(this)||this.get("locked"))}function Pa(){return!1!==this.get("capturable")&&(this.app.isEditMode||!this.hidden)}function Da(){return this.app?.isViewMode&&this.isPositionable()?this.state.position??"static":"static"}function Oa(){return this.app&&this.app.isViewMode&&this.state.origin||""}function za(){const{offsetX:t=0,offsetY:e=0}=this.state;return{x:t,y:e}}function La(){return!this._app&&this.parent&&(this._app=this.parent.app),this._app}const Ia={},Ra={mutable:!1,resizable:!0,rotatable:!0,properties:[],"value-property":"text"},ja=[],Fa=new Set(["data","text","value","source","accessor","mappings","variables","fillStyle","strokeStyle","fontColor","alpha","opacity","hidden","locked","hatched","started","animation","sensitive","event","src","href","url","class","templatePrefix"]),Ba={theta:0,tx:0,ty:0,sx:1,sy:1,fade:0};let Na=0;const Ha={};const Ya=new FinalizationRegistry(t=>{!function(t){Na--;let e=Ha[t];e||(e=Ha[t]={up:0,down:0}),e.down++}(t)});class Ga{static get nature(){return Ra}static register(t,e){if(!e)return Ia[t];Ia[t]=e}static types(){return Object.keys(Ia)}static get residents(){return Ha}static get residentsCount(){return Na}static registerDecorator(t,e){_s.registerDecorator(t,e)}constructor(t,e){this._app=e,this._model=t||{},this._state={},this._delta=Hn(Ba),e&&this.animation?.config&&(1==this.animation.config.autoplay||(this.animation.config.autoplay??1))&&(this.animation.started=!0),this.clearCache(),ps.add(this),function(t){Na++;let e=Ha[t];e||(e=Ha[t]={up:0,down:0}),e.up++}(this._model.type),Ya.register(this,this._model.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){this._cachedState=null,function(t,...e){0==e.length?t.__cache__={}:e.forEach(e=>delete t.__cache__[e])}(this,...t)}removeSelf(t){t?this.dispose():this.parent?.removeComponent?.(this)}resetAnimation(){this._animation&&(this._animation.dispose(),this._animation=null,this._delta=Hn(Ba))}dispose(){this.resetAnimation(),this.disposeMappings(),this.parent?.removeComponent?.(this),delete this._text_substitutor,delete this._value_substitutor,this._disposed=!0,this._realObject&&(this._realObject.dispose(),this._realObject=void 0),this.retention&&ps.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!0}get is3dMode(){return!1}isIn3DSpace(){return!!this._realObject}isTemplate(){return!!this.get("templatePrefix")}isHTMLElement(){return!1}isConnectable(){return!1}isIdentifiable(){return!0}isPositionable(){return this.parent?.isRootModel()}replaceRefids(t){}get(t){return this._model[t]}set(t,e){if("string"==typeof t)return this.set({[t]:e});const n=this;return this._applyProps(this._model,t,{getBeforeVal:function(t){return n._model[t]},clearState:!0,sensitive:!1,beforeFillStyle:function(t,e){t.hasOwnProperty("retention")&&ps.add(n)},afterFillStyle:function(t,e){t.hasOwnProperty("mappings")&&n.onchangeMappings(t,e)}})}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});const n=this;return this._applyProps(this._state,t,{getBeforeVal:function(t){return n.getState(t)},clearState:!1,sensitive:this.getState("sensitive")})}get model(){return this._model}get state(){return this._cachedState||(this._cachedState=Object.freeze(Object.assign({},this._model,this._state))),this._cachedState}get hierarchy(){const t=Hn(this._model);return this.volatile.forEach(e=>{delete t[e]}),Xo(t)}get volatile(){return ja}_applyProps(t,e,n){const i={},r={};let s=!1;const o=Hn(e),a=this;if(Object.getOwnPropertyNames(o).forEach(function(e){const c=n.getBeforeVal(e),l=o[e];!n.sensitive&&function(t,e){return ve(t,e)}(c,l)||(r[e]=c,i[e]=l,t[e]=l,n.clearState&&delete a._state[e],s=!0)}),s){this._cachedState=null;Object.keys(i).some(t=>!Fa.has(t))&&this.clearCache(),i.hasOwnProperty("text")&&delete this._text_substitutor,n.beforeFillStyle&&n.beforeFillStyle(i,r),i.hasOwnProperty("fillStyle")&&this.onchangeFill(i,r),n.afterFillStyle&&n.afterFillStyle(i,r),i.hasOwnProperty("data")&&this.onchangeData(i,r),this.onchange&&this.onchange(i,r),this.trigger("change",i,r)}return this}contains(t,e){return xs.call(this,t,e)}move(t,...e){ws.call(this,t,...e)}symmetryX(t){Ms.call(this,t)}symmetryY(t){Ss.call(this,t)}adjustResize(t,e,n){return As.call(this,t,e,n)}adjustRotation(t,e){return Es.call(this,t,e)}outline(t){return ks.call(this,t)}get bounds(){return Cs.call(this)}set bounds(t){Ts.call(this,t)}get center(){return Ps.call(this)}set center(t){Ds.call(this,t)}get location(){return Os.call(this)}set location(t){zs.call(this,t)}get rotate(){return Ls.call(this)}set rotate(t){Is.call(this,t)}get dimension(){return Rs.call(this)}set dimension(t){js.call(this,t)}get path(){return Fs.call(this)}set path(t){Bs.call(this,t)}get drawPath(){return Ns.call(this)}get rotatePoint(){return Hs.call(this)}get mutable(){return Ys.call(this)}get resizable(){return Gs.call(this)}get rotatable(){return Vs.call(this)}buildRealObject(){}get realObject(){return this.disposed||this._realObject||(this._realObject=this.buildRealObject(),this._realObject&&(this._realObject.update(),this._realObject.updateTransform())),this._realObject}draw(t){t&&Ws.call(this,t)}prerender(t){Xs.call(this,t)}render(t){qs.call(this,t)}postrender(t){Ks.call(this,t)}prepare(t,e){Qs.call(this,t,e)}prepareIf(t){Zs.call(this,t)}drawText(t){Js.call(this,t)}drawStroke(t,e){to.call(this,t,e)}drawFill(t,e){eo.call(this,t,e)}get strokeStyle(){return no.call(this)}set strokeStyle(t){io.call(this,t)}get fillStyle(){return ro.call(this)}set fillStyle(t){so.call(this,t)}get fontColor(){return oo.call(this)}set fontColor(t){ao.call(this,t)}get rotation(){return co.call(this)}set rotation(t){lo.call(this,t)}get decorators(){return ho.call(this)}get decotag(){return uo.call(this)}get hidden(){return po.call(this)}set hidden(t){fo.call(this,t)}get tag(){return go.call(this)}set tag(t){mo.call(this,t)}get appendum(){return yo.call(this)}set appendum(t){bo.call(this,t)}defaultTextSubstitutor(){return _o.call(this)}textLines(t){return vo.call(this,t)}get font(){return xo.call(this)}get lineHeight(){return wo.call(this)}get textSubstitutor(){return Mo.call(this)}get text(){return So.call(this)}set text(t){Ao.call(this,t)}get textBounds(){return Eo.call(this)}get textRotation(){return ko.call(this)}get textHidden(){return Co.call(this)}set textHidden(t){To.call(this,t)}get hasTextProperty(){return Po.call(this)}animate(t){return Vo.call(this,t)}effect(t,e){return Uo.call(this,t,e)}serialize(...t){return qo.call(this,...t)}trim(){Ko.call(this)}closeScene(t){Qo.call(this,t)}delta(t,e){return Zo.call(this,t,e)}invalidate(){Jo.call(this)}get value(){return ta.call(this)}set value(t){ea.call(this,t)}get data(){return na.call(this)}set data(t){ia.call(this,t)}set tap(t){ra.call(this,t)}get mappings(){return sa.call(this)}get retention(){return oa.call(this)}get animation(){return aa.call(this)}get started(){return ca.call(this)}set started(t){la.call(this,t)}get controls(){return ha.call(this)}findFirst(t,...e){return ya.call(this,t,...e)}findAll(t,...e){return ba.call(this,t,...e)}capture(t,e,n){return _a.call(this,t,e,n)}findAnchor(t){return va.call(this,t)}isDescendible(t){return xa.call(this,t)}getContext(t){return wa.call(this,t)}get root(){return Ma.call(this)}get rootModel(){return Sa.call(this)}get parent(){return Aa.call(this)}set parent(t){Ea.call(this,t)}get anchors(){return ka.call(this)}get scalable(){return Ca.call(this)}get stuck(){return Ta.call(this)}get capturable(){return Pa.call(this)}get position(){return Da.call(this)}get origin(){return Oa.call(this)}get offset(){return za.call(this)}get app(){return La.call(this)}drawEffect(t){_r.call(this,t)}prepareFill(t,e){Pr.call(this,t,e)}prepareFillIf(t){Dr.call(this,t)}onchangeFill(t,e){Or.call(this,t,e)}drawImage(t,e,n,i,r,s){br.call(this,t,e,n,i,r,s)}mutateBounds(t,e){os.call(this,t,e)}mutatePath(t,e,n){as.call(this,t,e,n)}access(t){return ms.call(this,t)}substitute(t,e){return ys.call(this,t,e)}onchangeMappings(t,e){yr.call(this,t,e)}onchangeData(t,e){fr.call(this,t,e)}buildMappings(){gr.call(this)}executeMappings(t){pr.call(this,t)}disposeMappings(){mr.call(this)}ondropfile(t,e){Yr.call(this,t,e)}transcoordS2P(t,e,n){return Wr.call(this,t,e,n)}transcoordP2S(t,e,n){return $r.call(this,t,e,n)}transcoordS2T(t,e,n){return qr.call(this,t,e,n)}transcoordT2P(t,e,n){return Kr.call(this,t,e,n)}transcoordT2S(t,e,n){return Qr.call(this,t,e,n)}transcoordS2TR(t,e,n){return Xr.call(this,t,e,n)}transcoordS2O(t,e,n){return Zr.call(this,t,e,n)}transcoordC2S(t,e,n){return Jr.call(this,t,e,n)}transcoordS2C(t,e,n){return ts.call(this,t,e,n)}toParent(t,e,n){return Wr.call(this,t,e,n)}fromParent(t,e,n){return $r.call(this,t,e,n)}toScene(t,e,n){return qr.call(this,t,e,n)}fromScene(t,e,n){return Qr.call(this,t,e,n)}toLocal(t,e,n){return Jr.call(this,t,e,n)}toGlobal(t,e,n){return ts.call(this,t,e,n)}toOther(t,e,n){return Zr.call(this,t,e,n)}on(t,e,n){return Pi.call(this,t,e,n)}off(t,e,n){return Di.call(this,t,e,n)}once(t,e,n){return Oi.call(this,t,e,n)}trigger(t,...e){return zi.call(this,t,...e)}delegate_on(t){return Li.call(this,t)}delegate_off(t){return Ii.call(this,t)}onchange(t,e){}removeComponent(t,e){}addComponent(t,e){}insertComponentAt(t,e,n){}getOverlay(t){}findById(t){}findByRefid(t){}findAllById(t){return[]}resize(){}fit(t){}get components(){}get layout(){}get auxOverlay(){}get isReady(){return!1}get unitScale(){return 1}get selected(){return[]}set selected(t){}get focused(){return null}set focused(t){}get hasSameParentForAllSelected(){return!1}set hasSameParentForAllSelected(t){}get fitMode(){}set fitMode(t){}get element(){return null}set element(t){}}Ga.union=es,Ga.transcoordR=Vr,Ga.transcoordRR=Ur,Ga.createCanvas=Cr,Ga.memoize=Ni,Ga.mixin=Ri,Ga.drawText=Nr,Ga.font=Fr,Ga.textLines=jr,Ga.drawStroke=zr,Ga.drawFill=Tr,Ga.reposition=ss,Ga.RetentionManager=ps,Ga.template=function(t,e,n){var i=dn.imports._.templateSettings||dn;n&&Le(t,e,n)&&(e=void 0),t=cn(t),e=Be({},e,i,Qe);var r,s,o=Be({},e.imports,i.imports,Qe),a=Qt(o),c=function(t,e){return Xe(e,function(e){return t[e]})}(o,a),l=0,h=e.interpolate||yn,d="__p += '",u=RegExp((e.escape||yn).source+"|"+h.source+"|"+(h===tn?mn:yn).source+"|"+(e.evaluate||yn).source+"|$","g"),p=_n.call(e,"sourceURL")?"//# sourceURL="+(e.sourceURL+"").replace(/\s/g," ")+"\n":"";t.replace(u,function(e,n,i,o,a,c){return i||(i=o),d+=t.slice(l,c).replace(bn,Je),n&&(r=!0,d+="' +\n__e("+n+") +\n'"),a&&(s=!0,d+="';\n"+a+";\n__p += '"),i&&(d+="' +\n((__t = ("+i+")) == null ? '' : __t) +\n'"),l=c+e.length,e}),d+="';\n";var f=_n.call(e,"variable")&&e.variable;if(f){if(gn.test(f))throw new Error("Invalid `variable` option passed into `_.template`")}else d="with (obj) {\n"+d+"\n}\n";d=(s?d.replace(un,""):d).replace(pn,"$1").replace(fn,"$1;"),d="function("+(f||"obj")+") {\n"+(f?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(r?", __e = _.escape":"")+(s?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+d+"return __p\n}";var g=We(function(){return Function(a,p+"return "+d).apply(void 0,c)});if(g.source=d,$e(g))throw g;return g},Ga.buildSubstitutor=bs,["rotatePoint","font","lineHeight","retention"].forEach(t=>Ga.memoize(Ga.prototype,t,!1)),["bounds","center","textBounds"].forEach(t=>Ga.memoize(Ga.prototype,t,!0));class Va extends Ga{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,void 0),this.drawStroke(t,void 0),super.postrender(t)}render(t){const e=this.drawPath,{round:n=0}=this.state;if(!(e.length<=1)){t.beginPath();for(let i=0;i<e.length;i++){const r=e[(i-1+e.length)%e.length],s=e[(i+e.length)%e.length],o=e[(i+1)%e.length];if(r.x===s.x&&r.y===s.y)continue;let a=Math.sqrt((r.x-s.x)*(r.x-s.x)+(r.y-s.y)*(r.y-s.y)),c=0!==a?Math.atan2(r.x-s.x,r.y-s.y):0,l=Math.sin(c)*Math.min(n,a/2)+s.x,h=Math.cos(c)*Math.min(n,a/2)+s.y;const d=n>0||0!==a?{x:l,y:h}:s;a=Math.sqrt((o.x-s.x)*(o.x-s.x)+(o.y-s.y)*(o.y-s.y)),c=0!==a?Math.atan2(o.x-s.x,o.y-s.y):0,l=Math.sin(c)*Math.min(n,a/2)+s.x,h=Math.cos(c)*Math.min(n,a/2)+s.y;const u=n>0||0!==a?{x:l,y:h}:s;0==i?t.moveTo(d.x,d.y):t.lineTo(d.x,d.y),n>0&&t.quadraticCurveTo(s.x,s.y,u.x,u.y)}t.closePath()}}}function Ua(t,e,n){return Math.max(0,Math.min(t,Math.min(n,e)/2))}function $a(t){const e=class extends t{contains(t,e){const{left:n,top:i,width:r,height:s,lineWidth:o=0}=this.state,a=o/2;return t<Math.max(n+r,n)+a&&t>Math.min(n+r,n)-a&&e<Math.max(i+s,i)+a&&e>Math.min(i+s,i)-a}set path(t){const e=t[0],n=t[2];this.set({left:e.x,top:e.y,width:n.x-e.x,height:n.y-e.y})}get path(){const{left:t=0,top:e=0,width:n=0,height:i=0}=this.state;return[{x:t,y:e},{x:t+n,y:e},{x:t+n,y:e+i},{x:t,y:e+i}]}get anchors(){return function(t){const{left:e,top:n,width:i,height:r}=t.bounds,s=e+i/2,o=n+r/2;return[{name:"TOP",position:{x:s,y:n}},{name:"RIGHT",position:{x:e+i,y:o}},{name:"BOTTOM",position:{x:s,y:n+r}},{name:"LEFT",position:{x:e,y:o}}]}(this)}get bounds(){const{left:t=0,top:e=0,width:n=0,height:i=0}=this.state;return{left:t,top:e,width:n,height:i}}set bounds(t){this.set({left:0,top:0,width:0,height:0,...t})}render(t){let{round:e=0}=this.model;const{left:n,top:i,width:r,height:s}=this.bounds;t.translate(n,i),t.beginPath(),e=Ua(e,r,s),e>0?t.roundRect(0,0,r,s,e):t.rect(0,0,r,s),t.translate(-n,-i)}};return Ni(e.prototype,"path",!1),Ni(e.prototype,"bounds",!0),e}const Wa={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 Xa=20;function qa(t,e){const n=t.split(/\s+/),i=n.indexOf(e);return-1!=i?n.splice(i,1):n.splice(-1,0,e),n.join(" ")}class Ka extends($a(Va)){static get image(){return Ka._image||(Ka._image=new Image,Ka._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=="),Ka._image}static toggle(t,e,n,i){if(!e)return void Fi("InfoWindow not defined.");const r=t.root.findById(e);r?r._findInfoWindowByComponent(t)?Ka.hide(t,e):Ka.show(t,e,n,i):Fi("InfoWindow Not Found.",e)}static hide(t,e){if(!e)return;const n=t.root.findById(e);n?n._removeInfoWindow(t):Fi("InfoWindow Not Found.",e)}static show(t,n,i,r){if(!n)return void Fi("InfoWindow not defined.");const s=t.root.findById(n);if(!s)return void Fi("InfoWindow Not Found.",n);if(s._findInfoWindowByComponent(t))return;const{frontSideTemplate:o="",backSideTemplate:a=""}=s.model;let c=[o,a].filter(t=>String(t).trim());if(c=c.map(t=>Ga.template(function(t,e,n){return(e||n?['<div class="info-window-btns">',e?'<button class="closable">X</button>':"",n?'<button class="flipable">⇌</button>':"","</div>"]:[]).concat(['<div class="info-window-content">',t,"</div>"]).join("")}(t,!i,2==c.length))),0==c.length)return;const 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'+s.get("style");let{left:h,top:d}=t.bounds;const{x:u,y:p}=r?t.rootModel.toLocal(r.x,r.y):t.toScene(h,d);h=u,d=p;const f=document.createElement("span");f.style.position="absolute";const g=document.createElement("style");let m,y;g.type="text/css",g.appendChild(document.createTextNode(l)),f.appendChild(g),c[0]&&(m=document.createElement("div"),m.id="side-1",m.className="flip",m.style.display="inline-block",m.innerHTML=e.sanitize(c[0](t),{ADD_TAGS:["style"],ADD_ATTR:["class","id","style"]})),c[1]&&(y=document.createElement("div"),y.id="side-2",y.className="flip",y.style.display="inline-block",y.innerHTML=e.sanitize(c[1](t),{ADD_TAGS:["style"],ADD_ATTR:["class","id","style"]}));const b=t.rootModel.getOverlay(t);m&&f.appendChild(m),y&&f.appendChild(y),b.appendChild(f);const _=s._addInfoWindow(t,f,g).signal;if(Mr.forEach(function(t){f.addEventListener(t,t=>t.stopPropagation(),{signal:_})}),Sr.forEach(function(t){f.addEventListener(t,t=>t.stopPropagation(),{signal:_})}),m){const e=m.querySelector(".info-window-btns > .flipable");e&&e.addEventListener("click",function(t){t.preventDefault(),y.className=qa(y.className,"flip-side-1"),m.className=qa(m.className,"flip-side-2")},{signal:_});const i=m.querySelector(".info-window-btns > .closable");i&&i.addEventListener("click",function(e){e.preventDefault(),Ka.hide(t,n)},{signal:_})}if(y){const e=y.querySelector(".info-window-btns > .flipable");e&&e.addEventListener("click",function(t){t.preventDefault(),y.className=qa(y.className,"flip-side-1"),m.className=qa(m.className,"flip-side-2")},{signal:_});const i=y.querySelector(".info-window-btns > .closable");i&&i.addEventListener("click",function(e){e.preventDefault(),Ka.hide(t,n)},{signal:_})}const v=m.offsetWidth,x=m.offsetHeight,w=t.rootModel.target.getBoundingClientRect(),M=[];m&&M.push(m),y&&M.push(y);const S={x:h,y:d};let A=t.toGlobal(S.x,S.y);if(A.x+v/2+w.left<w.right&&A.x-v/2>w.left){if(x+Xa<A.y)return f.style.marginLeft=S.x-v/2+"px",f.style.marginTop=S.y-x-Xa+"px",void M.forEach(t=>t.className+=" arrow-bottom");if(A=t.toGlobal(S.x,S.y+x+Xa),w.bottom>A.y+w.top)return f.style.marginLeft=S.x-v/2+"px",f.style.marginTop=S.y+Xa+"px",void M.forEach(t=>t.className+=" arrow-top")}if(A=t.toGlobal(S.x,S.y),A.x-(v+Xa)>w.left)return f.style.marginLeft=S.x-v-Xa+"px",f.style.marginTop=S.y-x/2+"px",void M.forEach(t=>t.className+=" arrow-right");f.style.marginLeft=S.x+Xa+"px",f.style.marginTop=S.y-x/2+"px",M.forEach(t=>t.className+=" arrow-left")}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,n){if(this._findInfoWindowByComponent(t))return;const i=new AbortController;return this._windows.push({component:t,window:e,styleElement:n,abortController:i}),i}_removeInfoWindow(t){const e=this._findInfoWindowByComponent(t);if(!e)return;e.abortController.abort();const n=e.window;n&&n.parentNode.removeChild(n);const i=this.infoWindows.lastIndexOf(e);this.infoWindows.splice(i,1)}render(t){const{left:e,top:n,width:i,height:r}=this.bounds;t.beginPath(),this.drawImage(t,Ka.image,e,n,i,r)}get hasTextProperty(){return!1}get nature(){return Wa}}Ga.register("info-window",Ka);const Qa={};var Za={list:function(){return{...Qa}},register:function(t,e){Qa[t]=e},unregister:function(t){delete Qa[t]},get:function(t){if(!t)return;const e=Qa[t];return e||ji("Layout Not Found - ",t),e}};const Ja=new class{constructor(){this.ABSOLUTE=!0}reflow(t,e){this.drawables(t).filter(t=>t.isHTMLElement()).forEach(t=>t.reposition())}capturables(t){return t.components}drawables(t){return t.app&&!t.app.isViewMode?t.components:t.components.filter(t=>!t.hidden)}isStuck(t){return!1}};Za.register("html-absolute",Ja);const tc=new class{constructor(){this.ABSOLUTE=!0}reflow(t,e){}capturables(t){return t.components}drawables(t){return t.app?.isViewMode?t.components.filter(t=>!t.hidden):t.components}isStuck(t){return!1}};function ec(t){const e=t.components.filter(t=>!t.hidden),n=t.getState("layoutConfig")||{},i=e[n&&n.activeIndex||0];return i&&[i]||[]}Za.register("absolute",tc);const nc=new class{reflow(t){const e=t.bounds,n=t.getState("layoutConfig")||{},i={left:0,top:0,width:e.width,height:e.height};t.forEach((t,e)=>{const r=e!=(n.activeIndex||0);t.bounds=i,t.setState("rotation",0),"element"in t&&t.element&&(t.element.style.visibility=r?"hidden":"visible")})}capturables(t){return ec(t)}drawables(t){return ec(t)}isStuck(t){return!0}};function ic(t){const e=t.getState("layoutConfig");return e&&e.weight||1}Za.register("card",nc);const rc=new class{reflow(t){const e=this.drawables(t),n=t.getState("padding")||{},i=e.reduce((t,e)=>t+ic(e),0),r=t.bounds,s=i>0?(r.width-((n.left||0)+(n.right||0)))/i:r.width,o=r.height-((n.top||0)+(n.bottom||0));let a=0;e.forEach(t=>{const e=ic(t),i=t.getState("margin")||{};t.bounds={left:s*a+(n.left||0)+(i.left||0),top:0+(n.top||0)+(i.top||0),width:e*s-((i.left||0)+(i.right||0)),height:o-((i.top||0)+(i.bottom||0))},t.setState("rotation",0),a+=e})}capturables(t){return t.components}drawables(t){return t.app?.isViewMode?t.components.filter(t=>!t.hidden):t.components}isStuck(t){return!0}};function sc(t){const e=t.getState("layoutConfig");return e&&e.weight||1}Za.register("linear-horizontal",rc);const oc=new class{reflow(t){const e=this.drawables(t),n=t.getState("padding")||{},i=e.reduce((t,e)=>t+sc(e),0),r=t.bounds,s=i>0?(r.height-((n.top||0)+(n.bottom||0)))/i:r.height,o=r.width-((n.left||0)+(n.right||0));let a=0;e.forEach(t=>{const e=sc(t),i=t.getState("margin")||{};t.bounds={left:0+(n.left||0)+(i.left||0),top:s*a+(n.top||0)+(i.top||0),width:o-((i.left||0)+(i.right||0)),height:e*s-((i.top||0)+(i.bottom||0))},t.setState("rotation",0),a+=e})}capturables(t){return t.components}drawables(t){return t.app?.isViewMode?t.components.filter(t=>!t.hidden):t.components}isStuck(t){return!0}};Za.register("linear-vertical",oc);const ac=new class{constructor(){this.joinType=!0}reflow(t){const e=t.getState("layoutConfig"),n=e&&e.columns||t.getState("columns"),i=e&&e.rows||t.getState("rows"),r=e&&e.widths||t.getState("widths"),s=e&&e.heights||t.getState("heights"),o=r?r.filter((t,e)=>e<n).reduce((t,e)=>t+e,0):n,a=s?s.filter((t,e)=>e<i).reduce((t,e)=>t+e,0):i,c=t.textBounds,l=t.getState("paddingLeft")||0,h=t.getState("paddingTop")||0,d=c.width/o,u=c.height/a;let p=0,f=0;t.components.forEach((t,e)=>{const i=r?r[e%n]:1,o=s?s[Math.floor(e/n)]:1;let a=t.colspan||1,c=0;for(;--a>0;)c+=r?r[(e+a)%n]:1;let g=t.rowspan||1,m=0;for(;--g>0;)m+=s?s[Math.floor(e/n)+g]:1;t.bounds={left:l+p,top:h+f,width:d*(i+c),height:u*(o+m)},t.setState("rotation",0),e%n==n-1?(p=0,f+=o*u):p+=i*d})}capturables(t){return t.components.filter(t=>!t.merged)}drawables(t){return t.components.filter(t=>!t.merged&&!t.hidden)}isStuck(t){return!0}keyNavigate(t,e,n){const i=t.getState("layoutConfig"),r=i&&i.columns||t.getState("columns"),s=i&&i.rows||t.getState("rows"),{row:o,column:a}=t.getRowColumn(e);switch(n.code){case"ArrowUp":if(o>0)return t.getAt?.((o-1)*r+a);break;case"ArrowDown":if(o<s-1)return t.getAt?.((o+1)*r+a);break;case"ArrowRight":if(a<r-1)return t.getAt?.(o*r+a+1);break;case"ArrowLeft":if(a>0)return t.getAt?.(o*r+a-1);break;default:return e}}};function cc(){const t=arguments,e=t[t.length-1],n=this.event_pump;n.listeners.forEach(i=>{!function(t,e,n,i,r){for(const s in n){const o=n[s];if(pa(s,i.origin,0,t))for(const t in o){const n=o[t];t==i.name&&(i.listener=e,n.apply(e,r))}}}(n.deliverer,i.listener,i.cloned_handlers,e,t)})}Za.register("table",ac);class lc{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)",cc,{event_pump:this})}stop(){this.deliverer.off("(all)",cc)}on(t,e){const n=Object.assign({},e);Object.keys(n).forEach(e=>{if(0==e.indexOf("?")){const i=n[e],r=e.substr(1),s=t.get(r);delete n[e],s?n[s]=i:Fi("EventPump#on","variable #{selector} is not evaluated on listener")}}),this.listeners.push({listener:t,handlers:e,cloned_handlers:n})}off(t,e){for(let n=0;n<this.listeners.length;n++){const i=this.listeners[n];i.listener!==t||e&&i.handlers!==e||this.listeners.splice(n,1)}}clear(){this.listeners=[]}dispose(){this.stop(),this.clear()}}class hc{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(const n in e){const i=e[n];if("(self)"===n&&void 0===t.on)throw new Error("(self) selector not available when deliverer is not a event handlable object.");ma(n,this.root,t).forEach(n=>{const r=new lc(n);r.on(t,i),r.start(),this.eventMaps.push({eventPump:r,listener:t,handlerMap:e,deliverer:n})})}}remove(t,e){const n=this.eventMaps.slice(0);for(let i=0;i<n.length;i++){const r=n[i];r.listener!==t||e&&r.handlerMap!==e||(this.eventMaps.splice(i,1),r.eventPump.dispose())}}clear(){this.eventMaps.slice(0).forEach(t=>t.eventPump.dispose()),this.eventMaps=[]}dispose(){this.stop(),this.clear()}}const dc=0,uc=1,pc=2,fc=0,gc=1,mc=2;let yc={},bc=0;class _c{constructor(t,e){this._type=e||t.type,this._ctrlKey=t.ctrlKey,this._altKey=t.altKey,this._shiftKey=t.shiftKey,this._metaKey=t.metaKey;const n=function(t){if(t.touches){const e=t.touches[0];if(!e)return yc;const n=e.target.getBoundingClientRect();return yc={x:t.offsetX||e.clientX-n.left,y:t.offsetY||e.clientY-n.top},yc}return{x:t.offsetX,y:t.offsetY}}(t);if(this._offsetX=n.x,this._offsetY=n.y,t.touches&&t.touches[0]?(this._clientX=t.touches[0].clientX,this._clientY=t.touches[0].clientY):(this._clientX=t.clientX,this._clientY=t.clientY),"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)){const e=function(t){let e,n,i=0,r=0,s=0;if(1===t.touches.length)return s;Array.from(t.touches).forEach(t=>{e=null!=e?Math.min(t.screenX,e):t.screenX,i=Math.max(t.screenX,i),n=null!=n?Math.min(t.screenY,n):t.screenY,r=Math.max(t.screenY,r)});const o=i-e||0,a=r-n||0;return s=Math.sqrt(Math.pow(o,2)+Math.pow(a,2))||0,s}(t);bc>0&&(this._scale=e/bc),bc=e}}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 clientX(){return this._clientX}get clientY(){return this._clientY}get touches(){return this._touches}get changedTouches(){return this._changedTouches}get scale(){return this._scale}stopPropagation(){this._stop_=!0,this.originalEvent?.stopPropagation()}isPropagationStopped(){return this._stop_}preventDefault(){this._prevented=!0}isDefaultPrevented(){return this._prevented}}function vc(t,e,n){if(!t||!t.app)return;if(t.app.isViewMode&&t.hidden)return;n instanceof _c&&e===n.type||(n=new _c(n,e));const i="on"+e;t[i]&&t[i](n),n.isPropagationStopped()||t.trigger(e,n)}class xc{constructor(t,e){this.gestureHandlerBuilder=t=>{const e=this[`on${t}`];return t=>{const n=new _c(t),i=this.getChildScrollOffset();return n._offsetX+=this.html_element.scrollLeft+i.scrollLeft,n._offsetY+=this.html_element.scrollTop+i.scrollTop,e(n),n.isDefaultPrevented()&&t.preventDefault(),!1}},this.keyeventHandlerBuilder=t=>this[`on${t}`],this.ondragover=t=>(vc(this.findTarget(t),t.type,t),!1),this.ondrop=t=>(vc(this.findTarget(t),t.type,t),!1),this.ondblclick=t=>(vc(this.findTarget(t),t.type,t),this.last_target=null,!1),this.onkeydown=t=>(this.container.trigger(t.type,t),!1),this.onkeyup=t=>(this.container.trigger(t.type,t),!1),this.onmousemove=t=>{switch(this.status){case uc:const e=t.offsetX-this.__dragstart_e.offsetX,n=t.offsetY-this.__dragstart_e.offsetY;if(e*e+n*n<16)break;this.status=pc,vc(this.last_target,"dragstart",this.__dragstart_e),this.__dragmove_e=t,vc(this.last_target,"dragmove",t);break;case pc:this.__dragmove_e=t,vc(this.last_target,"dragmove",t);break;default:{const e=this.findTarget(t);this.last_enter_target!==e&&(this.last_enter_target&&vc(this.last_enter_target,"mouseleave",t),e&&vc(e,"mouseenter",t),this.last_enter_target=e),vc(e,t.type,t),this.last_target=e}}return!1},this.onmousedown=t=>{if(this.status===pc)vc(this.last_target,"dragend",t),this.last_target=null,this.status=dc;else{const e=this.findTarget(t);this.last_target=e,this.status=uc,this.__dragstart_e=t,vc(e,t.type,t)}return!1},this.onmouseup=t=>{if(this.status===pc)vc(this.last_target,"dragend",t);else{const e=this.findTarget(t);vc(e,t.type,t),this.last_target===e&&vc(e,"click",t)}return this.last_target=null,this.status=dc,!1},this.onmouseout=t=>{const e=this.findTarget(t);if(this.status===pc)vc(this.last_target,"dragend",t);else{if(this.last_target&&this.last_target===e)return;this.last_enter_target&&(vc(this.last_enter_target,"mouseleave",t),delete this.last_enter_target)}return this.last_target=null,this.status=dc,!1},this.ontouchstart=t=>{const e=this.findTarget(t);return this.last_target=e,this.status=gc,this.touchPoints||(this.touchPoints=[]),this.touchPoints.push(t.changedTouches[0]),this.holdTimer=setTimeout(()=>{this.status=fc,vc(this.last_target,"hold",t),delete this.holdTimer},500),vc(e,t.type,t),!1},this.ontouchmove=t=>{if(!t.touches||!t.changedTouches)return vc(this.last_target,"dragstart",t),vc(this.last_target,"dragmove",t),!1;let e=this.findTarget(t);switch(this.status){case gc:Array.from(t.changedTouches).forEach(t=>{const e=this.touchPoints.find(e=>e.identifier===t.identifier);if(!e)return;const n=e.clientX-t.clientX,i=e.clientY-t.clientY;return Math.sqrt(Math.pow(n,2)+Math.pow(i,2))>=16?(this.status=mc,void(this.holdTimer&&(clearTimeout(this.holdTimer),delete this.holdTimer))):void 0});break;case mc: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 vc(this.last_target,"pinch",t),!1;vc(this.last_target,"pan",t),e=this.last_target;break;default:this.last_enter_target!==e&&(this.last_enter_target&&vc(this.last_enter_target,"mouseleave",t),e&&vc(e,"mouseenter",t),this.last_enter_target=e),this.last_target=e}return vc(e,"touchmove",t),!1},this.ontouchend=t=>{let e=this.findTarget(t);switch(this.status){case mc:e=this.last_target;break;case gc:{const n=performance.now(),i=n-this.touchedAt;this.holdTimer&&(clearTimeout(this.holdTimer),delete this.holdTimer,vc(e,i<500?"doubletap":"tap",t),this.touchedAt=n);break}}vc(e,"touchend",t);const n=this.touchPoints.findIndex(e=>e.identifier===t.changedTouches[0].identifier);return this.touchPoints.splice(n,1),this.last_target=null,this.status=fc,!1},this.onwheel=t=>(vc(this.findTarget(t),t.type,t),!1),this.container=t,this.html_element=e,this.status=dc,this.last_target=null,this.gesture_handlers=Mr.map(t=>this.gestureHandlerBuilder(t)),this.keyevent_handlers=Sr.map(t=>this.keyeventHandlerBuilder(t)),Mr.forEach((t,n)=>e.addEventListener(t,this.gesture_handlers[n]),{passive:!1}),Sr.forEach((t,n)=>e.addEventListener(t,this.keyevent_handlers[n])),e.ondragover=this.gestureHandlerBuilder("dragover"),e.ondrop=this.gestureHandlerBuilder("drop"),e.tabIndex=1}dispose(){this.last_enter_target&&vc(this.last_enter_target,"mouseleave",new CustomEvent("mouseleave")),Mr.forEach((t,e)=>this.html_element.removeEventListener(t,this.gesture_handlers[e])),Sr.forEach((t,e)=>this.html_element.removeEventListener(t,this.keyevent_handlers[e])),delete this.gesture_handlers,delete this.keyevent_handlers,delete this.last_target}getChildScrollOffset(){for(const t of this.html_element.children)if(t.scrollTop>0||t.scrollLeft>0)return{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop};return{scrollLeft:0,scrollTop:0}}findTarget(t){const e=this.container.rootModel;if(e?.is3dMode)return e;const n=this.html_element.getBoundingClientRect(),i=this.getChildScrollOffset(),r=t.clientX-n.left+this.html_element.scrollLeft+i.scrollLeft,s=t.clientY-n.top+this.html_element.scrollTop+i.scrollTop;return this.container.capture(r,s)}}class wc{constructor(t){this.params=Object.assign({},t)}excute(){}}class Mc extends wc{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,n){e.call(n),t.execute(null,!1)}}function Sc(t,e,n,i=0){if(e.length<2)return e;let r=2;for(;r<e.length;r++){const s=e.substring(0,r);if(!(t.measureText(s).width+(s.length-1)*i<n))break}return e.substring(0,r-1)}function Ac(t,e,n,i,r=0){const s=String(e).split("\n");return i?[].concat.apply([],s.map(e=>function(t,e,n,i=0){const r=e.split(" "),s=[];let o,a,c=[];for(o=0,a=1;a<=r.length;a++)if(c=r.slice(o,a),t.measureText(c.join(" ")).width+(c.join("").length-1)*i>n){if(a-o==1){const e=Sc(t,c[0],n,i);s.push([e]),r.splice(o,1,e,c[0].substring(e.length))}else{for(;""==r[a-1];)a++;s.push(r.slice(o,--a))}o=a}return a-o>1&&s.push(c),0==s.length&&s.push([""]),s}(t,e,n,r))):s.map(t=>t.split(" "))}const Ec={},kc={},Cc=()=>{};var Tc={register:function(t,e,n){Ec[t]=e,n&&(kc[t]=n)},unregister:function(t){delete Ec[t],delete kc[t]},get:function(t){return Ec[t]},getDisposer:function(t){return kc[t]||Cc}};function Pc(t){if(!t.hasTextProperty||t.textHidden)return;let{text:e="",bold:n=Ar.BOLD,italic:i=Ar.ITALIC,textWrap:r=Ar.TEXT_WRAP,letterSpacing:s=0,fontFamily:o=Ar.FONT_FAMILY,fontColor:a=Ar.FONT_COLOR,textAlign:c=Ar.TEXT_ALIGN,textBaseline:l=Ar.TEXT_BASELINE,fontSize:h=Ar.FONT_SIZE,lineHeight:d=1.2*h}=t.model;const{left:u,top:p,width:f,height:g}=t.textBounds;h||=Ar.FONT_SIZE,d||=1.2*h,t.textHidden=!0;const m=document.createElement("textarea"),y=new AbortController;Mr.forEach(function(t){m.addEventListener(t,t=>t.stopPropagation(),{capture:!0,signal:y.signal})});const b=t.toGlobal(u,p),{rotation:_,scale:v}=function(t){let e=0,n=1,i=t;for(;i;){e+=i.get("rotation")||0;const{x:t,y:r}=i.get("scale")||{x:1,y:1};n*=Math.max(t,r)||1,i=i.parent}return{rotation:e,scale:n}}(t);m.value=e;const x={position:"absolute",width:f+"px",height:g+"px",padding:"0",fontFamily:o,fontSize:h+"px",lineHeight:d+"px",overflow:"hidden",resize:"none",outline:"none",border:"0",backgroundColor:"transparent",display:"inline-block",color:a};switch(n&&(x.fontWeight="bold"),i&&(x.fontStyle="italic"),c){case"right":case"end":x.textAlign="right";break;case"justify":x.textAlign="justify";break;case"left":case"start":x.textAlign="left";break;default:x.textAlign="center"}const w=[n,i,h+"px",o].filter(Boolean).join(" ");function M(e){const n={left:0,top:0},i=d*function(t,e,n,i,r=0){const s=t.getContext();let o;return s.save(),s.font=n,o=Ac(s,e,i,t.get("textWrap"),r).length,s.restore(),o}(t,e,w,f,s);switch(x.height=i+"px",l){case"top":case"hanging":break;case"bottom":case"alphabetic":n.top=g-i;break;default:n.top=g/2-i/2}if(!r){const i=function(t,e,n,i){const r=e.split("\n");let s=i;const o=t.getContext();return o.save(),o.font=n,r.forEach(t=>{const e=o.measureText(t).width;e>s&&(s=e)}),o.restore(),s}(t,e,w,f);switch(x.width=i+"px",c){case"right":case"end":n.left=f-i;break;case"left":case"start":break;default:n.left=(f-i)/2}}x.marginLeft=n.left+"px",x.marginTop=n.top+"px",x.transform=`translate(${b.x}px, ${b.y}px) scale(${v}) rotate(${_}rad)`,x.transformOrigin=`${-n.left}px ${-n.top}px`,Object.assign(m.style,x)}M(e);const S=t.root.target_element;S.appendChild(m),m.select();let A,E=!1;m.addEventListener("keydown",function(t){t.stopPropagation(),"Escape"!=t.code&&(t.shiftKey||"Enter"!=t.code&&"NumpadEnter"!=t.code)?setTimeout(()=>{M(m.value)}):(E=A.skipUpdate="Escape"==t.code,"function"==typeof document.createEvent?m.dispatchEvent(A):m.fireEvent(A.eventType,A))},{signal:y.signal}),document.createEvent?(A=document.createEvent("HTMLEvents"),A.initEvent("blur",!0,!1)):(A=document.createEventObject(),A.eventType="blur");const k=t.root.selected,C=function(n){t.root.selected=k,t.textHidden=!1,y.abort(),m.removeEventListener("blur",C,!1),m.parentElement&&m.parentElement.removeChild(m),S.focus(),n.skipUpdate||E||t.app.commander.execute(new Mc({changes:[{component:t,before:{text:e},after:{text:m.value}}]}))};m.addEventListener("blur",C,!1)}function Dc(t){let e=0;for(;t&&!t.isRootModel();)e+=t.get("rotation")||0,t=t.parent;return e%(2*Math.PI)}Tc.register("text-editor",{"(root)":{"(self)":{keydown:function(t,e){const{deliverer:n}=e,i=n.selected;return!(1!==i.length||!i[0].hasTextProperty)&&(("Enter"==t.code||"NumpadEnter"==t.code)&&(Pc(i[0]),t.preventDefault(),!0))}}},"model-layer":{"(descendant)":{dblclick:function(t,e){Pc(e.origin)}}}});class Oc extends wc{execute(){this.params.changes.forEach(t=>{const{component:e,to_container:n,to_index:i,to_left:r,to_top:s}=t,o=function(t){if(t.isRootModel())return t.bounds;const{bounds:e,rotatePoint:n}=t;let i=n;return i=t.toScene(i.x,i.y),{left:i.x-(n.x-e.left),top:i.y-(n.y-e.top),width:e.width,height:e.height}}(e),a=Dc(e);if(function(t){const e=t.parent?.model?.zPos;if(null==e)return;const n=t.state.zPos||0;t.set("zPos",n+e)}(e),e.removeSelf(!n),e.bounds=o,e.set("rotation",a),n){e.set("rotation",function(t,e){return((t.get("rotation")||0)-Dc(e))%(2*Math.PI)}(e,n));const o=function(t,e){if(e.isRootModel())return t.bounds;const{bounds:n,rotatePoint:i}=t,r=e.fromScene(i.x,i.y),s=e.bounds;return{left:r.x-(i.x-n.left)-s.left,top:r.y-(i.y-n.top)-s.top,width:n.width,height:n.height}}(e,n);t.to_left=void 0!==r?r:o.left,t.to_top=void 0!==s?s:o.top,e.bounds={left:t.to_left,top:t.to_top,width:o.width,height:o.height},void 0===i?n.addComponent(e):n.insertComponentAt(e,i)}})}}class zc{constructor(t){const e=[],n=[];for(let i=0,r=t.length;i<r;i++){const r=t[i],s=r.left,o=r.left+r.width,a=s+r.width/2,c=r.top,l=r.top+r.height,h=c+r.height/2;e.push({value:s,perpMin:c,perpMax:l},{value:a,perpMin:c,perpMax:l},{value:o,perpMin:c,perpMax:l}),n.push({value:c,perpMin:s,perpMax:o},{value:h,perpMin:s,perpMax:o},{value:l,perpMin:s,perpMax:o})}e.sort((t,e)=>t.value-e.value),n.sort((t,e)=>t.value-e.value),this.xEdges=e,this.yEdges=n}get empty(){return 0===this.xEdges.length&&0===this.yEdges.length}calculateSnap(t,e,n,i){if(0===this.xEdges.length&&0===this.yEdges.length)return{dx:e,dy:n,guides:[]};const r={left:t.left+e,top:t.top+n,width:t.width,height:t.height},s=r.left,o=s+r.width,a=s+r.width/2,c=r.top,l=c+r.height,h=c+r.height/2,d=this.findBestSnap(this.xEdges,[s,a,o],i),u=this.findBestSnap(this.yEdges,[c,h,l],i),p=d?e+d.correction:e,f=u?n+u.correction:n;if(!d&&!u)return{dx:e,dy:n,guides:[]};const g=[];if(d){const e=t.top+f,n=e+t.height;for(const t of d.matches)g.push({axis:"x",position:t.value,from:Math.min(e,t.perpMin),to:Math.max(n,t.perpMax)})}if(u){const e=t.left+p,n=e+t.width;for(const t of u.matches)g.push({axis:"y",position:t.value,from:Math.min(e,t.perpMin),to:Math.max(n,t.perpMax)})}return{dx:p,dy:f,guides:g}}findBestSnap(t,e,n){let i=n+1,r=0,s=[];for(let o=0;o<3;o++){const a=e[o],c=this.searchNearest(t,a,n);if(!c)continue;const l=Math.abs(c.correction);if(l<i)i=l,r=c.correction,s=c.matches;else if(l===i&&c.correction===r)for(const t of c.matches)s.push(t)}return i<=n?{correction:r,matches:s}:null}searchNearest(t,e,n){const i=t.length;if(0===i)return null;let r=0,s=i;for(;r<s;){const n=r+s>>1;t[n].value<e?r=n+1:s=n}let o=-1,a=n+1;if(r<i){const i=t[r].value-e;i<=n&&(o=r,a=i)}if(r>0){const n=e-t[r-1].value;n<a&&(o=r-1,a=n)}if(o<0||a>n)return null;const c=t[o].value,l=c-e,h=[t[o]];for(let e=o-1;e>=0&&t[e].value===c;e--)h.push(t[e]);for(let e=o+1;e<i&&t[e].value===c;e++)h.push(t[e]);return{correction:l,matches:h}}}function Lc(t,e,n,i){const r=Ga.register(t.type);if(!r)return Fi("Class not found",t.type),null;n&&(t.refid=n(t.refid)),t.id&&i&&i(t.id)&&delete t.id;const s=new r(t,e);return t.components&&s.isContainer()&&(t.components.forEach(t=>{const r=Lc(t,e,n,i);r&&s.addComponent(r)}),delete t.components),s.created(),s}function Ic(t,e){const n=Hn(t.hierarchy);return delete n.id,Lc(n,t.app,e)}function Rc(t){const e=t.root;if(!e||!e.assist_layers)return null;for(const t of e.assist_layers)if("snap-guide-layer"===t.state?.type)return t;return null}const jc=Jn(function(t,e,n){if(!t.hasSameParentForAllSelected||n)return void(t.focused=null);const i=[];e[0].parent.isGroup()?t.focused=e[0].parent:(e.forEach(t=>{t.path.forEach(e=>{i.push(t.toScene(e.x,e.y))})}),t.focused=t.capturePath(i,e))},300);let Fc;Tc.register("move-handler",{"model-layer":{"(descendant)":{dragstart:function(t,e){const{origin:n,deliverer:i}=e;if(n.stuck)return;let r=i.selected;const s=i.selected.filter(t=>!t.stuck);if(r.length!==s.length&&(r=i.selected=s),0==r.length)return;let o;if(r[0].scalable?(o=r[0].toLocal(t.offsetX,t.offsetY),o=r[0].toParent(o.x,o.y)):o={x:t.offsetX,y:t.offsetY},this.last_pos=o,this.direction=0,i.focused=r[0].parent,t.altKey){const t=[],e=new Map;i.selected=i.selected.filter(t=>!t.isRootModel()).map(n=>{const r=Ic(n,t=>{const n=i.root.getNewRefid();return void 0!==t&&e.set(t,n),n});return t.push({component:r,to_container:n.parent}),r}).map(t=>(t.replaceRefids(e),t)),t.forEach(({component:t,to_container:e})=>{e.addComponent(t)}),this.duplicates=i.selected.map(t=>({component:t}))}else this.changes=Mc.before(r);this.snapIndex=function(t){if(0===t.length)return null;const e=t[0].parent;if(!e||!e.components)return null;const n=new Set(t),i=[];for(const t of e.components)t.isLayer?.()||t.stuck||n.has(t)||i.push(t.bounds);return 0===i.length?null:new zc(i)}(r);const a=n.rootModel?.get("scale"),c=a?(Math.abs(a.x)+Math.abs(a.y))/2:1;this.snapThreshold=5/(c||1)},dragmove:function(t,e){const{origin:n,deliverer:i}=e;if(n.stuck)return;const r=i.selected;if(0==r.length||!this.last_pos)return;let s;r[0].scalable?(s=r[0].toLocal(t.offsetX,t.offsetY),s=r[0].toParent(s.x,s.y)):s={x:t.offsetX,y:t.offsetY},t.shiftKey?2==this.direction&&(this.direction=0):this.direction=2;let o=s.x-this.last_pos.x,a=s.y-this.last_pos.y;if(0==this.direction){if(o*o+a*a<25)return;Math.abs(o)>Math.abs(a)?this.direction=3:this.direction=4}3==this.direction?a=0:4==this.direction&&(o=0);const c=this.snapIndex,l=c&&!t.metaKey&&!t.ctrlKey,h=o,d=a;if(l){const t=function(t){return 0===t.length?null:1===t.length?t[0].bounds:es(t.map(t=>t.bounds))}(r);if(t){const e=c.calculateSnap(t,o,a,this.snapThreshold);o=e.dx,a=e.dy;const n=Rc(i);n&&(n.snapResult=e.guides.length>0?e:null)}}else{const t=Rc(i);t&&(t.snapResult=null)}r.forEach(t=>{t.move({x:o,y:a},1===r.length)}),this.last_pos={x:s.x-(h-o),y:s.y-(d-a)},jc(i,r)},dragend:function(t,e){const{origin:n,deliverer:i}=e;if(n.stuck)return;const r=i.selected;if(0==r.length)return;const s=r[0].parent,o=i.focused||e.deliverer;if(this.changes&&!o.isGroup())if(i.hasSameParentForAllSelected&&o&&o!==s){const t=this.changes.map(t=>{const{component:e}=t;return{component:e,to_container:o}});i.app.commander.execute(new Oc({changes:t}))}else Mc.after(this.changes,i.app.commander);else if(this.duplicates){this.duplicates=this.duplicates.map(t=>(t.to_container=o,t));const t=new Oc({changes:this.duplicates});i.app.commander.execute(t)}r.forEach(t=>{t.parent&&t.parent.calculateBounds&&t.parent.calculateBounds()}),this.last_pos=null,this.changes=null,this.duplicates=null,this.snapIndex=null,this.snapThreshold=5;const a=Rc(i);a&&a.clear(),jc(i,r,!0)}}},"(root)":{"(self)":{keydown:function(t,e){const{origin:n,deliverer:i}=e,r={},s=t.shiftKey?n.rootModel.MPP:1;switch(t.which){case 37:r.x=-s,r.y=0;break;case 38:r.x=0,r.y=-s;break;case 39:r.x=s,r.y=0;break;case 40:r.x=0,r.y=s;break;default:return}const o=i.selected;Mc.around(i.app.commander,function(){o.forEach(t=>{!t.stuck&&t.move(r,!1)})})}}}}),Tc.register("shift-handler",{"model-layer":{"(all)":{dragstart:function(t,e){Fc={x:t.offsetX,y:t.offsetY}},dragmove:function(t,e){const{deliverer:n}=e,i=t.offsetX,r=t.offsetY;n.rootModel.move({x:i-Fc.x,y:r-Fc.y},!1),Fc={x:i,y:r}}}}}),Tc.register("zoom-handler",{"model-layer":{"(all)":{wheel:function(t,e){if(0==t.deltaY&&0==t.deltaX)return;const n=e.deliverer,i=t.deltaY<0?1:-1,r=n.get("scale")||{x:1,y:1},s=n.get("translate"),o=t.offsetX,a=t.offsetY,c=n.toLocal(o,a),l=.1*i,h={x:r.x+l,y:r.y+l};if(i<0&&r.x<.2||i>0&&r.x>10)return;n.set("scale",h);const d=n.toLocal(o,a);n.set("translate",{x:s.x+(d.x-c.x)*h.x,y:s.y+(d.y-c.y)*h.y})}},"(self)":{dblclick:function(t,e){const n=e.origin;n?.root.fit()}}}});let Bc={},Nc={};function Hc(t){const e={};for(const n in t)t.hasOwnProperty(n)&&void 0!==t[n]&&(e[n]=t[n]);return e}Tc.register("paste-handler",{"(root)":{"(self)":{stylepastestart:function(t){const{deliverer:e}=t,n=e.app,i=e.selected;if(i&&i[0]&&i!==e.rootModel){const t=i[0],{fillStyle:e,strokeStyle:r,alpha:s,lineWidth:o,lineDash:a,lineCap:c,lineJoin:l,fontColor:h,fontSize:d,fontFamily:u,bold:p,italic:f,textAlign:g,textBaseline:m,textOverflow:y,paddingTop:b,paddingBottom:_,paddingLeft:v,paddingRight:x}=t.state;Bc=Hn({fillStyle:e,strokeStyle:r,alpha:s,lineWidth:o,lineDash:a,lineCap:c,lineJoin:l,fontColor:h,fontSize:d,fontFamily:u,bold:p,italic:f,textAlign:g,textBaseline:m,textOverflow:y,paddingTop:b,paddingBottom:_,paddingLeft:v,paddingRight:x}),n.mode=4}},stylepastestop:function(t){const{deliverer:e}=t,n=e.app;Bc={},4==n.mode&&(n.mode=1)},databindpastestart:function(t){const{deliverer:e}=t,n=e.app,i=e.selected;if(i&&i[0]&&i!==e.rootModel){const t=i[0],{mappings:e}=t.state;Nc=Hn({mappings:e}),n.mode=5}},databindpastestop:function(t){const{deliverer:e}=t,n=e.app;Nc={},5==n.mode&&(n.mode=1)},pasteapply:function(t,e){const{deliverer:n}=e,i=n.app;t&&(4==i.mode?Mc.around(i.commander,()=>{t.set(Hc({...t.model,...Bc}))}):5==i.mode&&Mc.around(i.commander,()=>{t.set(Hc({...t.model,...Nc}))}))},keydown:function(t,e){const{deliverer:n}=e;"Esc"!=t.code&&"Escape"!=t.code||(4==n.app.mode?n.trigger("stylepastestop"):5==n.app.mode&&n.trigger("databindpastestop"))}}},"model-layer":{"(all)":{click:function(t,e){const{deliverer:n}=e,i=n.app;if(4!=i.mode&&5!=i.mode)return;const r=e.origin;4==i.mode?r===n?n.root.trigger("stylepastestop"):r&&Mc.around(i.commander,()=>{const t=Hc({...r.model,...Bc});r?.set(t)}):r===n?n.root.trigger("databindpastestop"):r&&Mc.around(i.commander,()=>{const t=Hc({...r.model,...Nc});r?.set(t)})}}}});class Yc{constructor(){this.animatorMap=new Map}waypoint(t,e){this.animatorMap.has(t)&&this.off(t);let{from:n,to:i}=e;if("string"==typeof n&&(n=t.root?.findById(n)),"string"==typeof i&&(i=t.root.findById(i)),!i)return void Fi("WaypointAnimation: Source or target component not found");const r=Yo(t,{type:"waypoint",fromComponent:n,toComponent:i,...e,onComplete:()=>{this.off(t)}});r&&(this.animatorMap.set(t,r),r.start())}off(t){const e=this.animatorMap.get(t);e&&(e.stop(),this.animatorMap.delete(t))}reset(t){if(this.animatorMap.size>0){for(const t of this.animatorMap.values())t.stop();this.animatorMap.clear()}}dispose(){this.reset(null),this.animatorMap=null}}function Gc(t){const{origin:e}=t,n=e.root,{waypointHandler:i}=n;i?.reset()}Tc.register("waypoint-handler",{"model-layer":{"(descendant)":{waypoint:function(t,e){const{origin:n}=e,i=n.root;let{waypointHandler:r}=i;r||(r=new Yc,i.waypointHandler=r),r.waypoint(n,t)},waypointoff:function(t){const{origin:e}=t,n=e.root,{waypointHandler:i}=n;i?i.off(e):Fi("waypoint-handler not found")},waypointreset:Gc},"(self)":{waypointreset:Gc}}},function(t){const{waypointHandler:e}=t;e&&(e.dispose(),delete t.waypointHandler)});class Vc{constructor(){this.animatorMap=new Map}transition(t,e){this.animatorMap.has(t)&&this.off(t);const n=Yo(t,{type:"transition",fromComponent:e.from,toComponent:e.to,...e,onComplete:()=>{this.off(t)}});n&&(this.animatorMap.set(t,n),n.start())}off(t){const e=this.animatorMap.get(t);e&&(e.stop(),this.animatorMap.delete(t))}reset(){for(const t of this.animatorMap.values())t.stop();this.animatorMap.clear()}dispose(){this.reset(),this.animatorMap=null}}function Uc(t){const{origin:e}=t,n=e.root,{transitionHandler:i}=n;i?.reset()}function $c(t){return t<.5?2*t*t:1-2*(1-t)*(1-t)}Tc.register("transition-handler",{"model-layer":{"(descendant)":{transition:function(t,e){const{origin:n}=e,i=n.root;let{transitionHandler:r}=i;r||(r=new Vc,i.transitionHandler=r),r.transition(n,t)},transitionoff:function(t){const{origin:e}=t,n=e.root,{transitionHandler:i}=n;i?i.off(e):Fi("transition-handler not found")},transitionreset:Uc},"(self)":{transitionreset:Uc}}},function(t){const{transitionHandler:e}=t;e&&(e.dispose(),delete t.transitionHandler)});class Wc{constructor(t){this.active=new Map,this.rafId=0,this._canvas=null,this._ctx=null,this.root=t}isReparenting(t){return this.active.has(t)}getState(t){return this.active.get(t)||null}begin(t,e){if(this.cancel(t),this.root?.app?.suppressAnimations)return this.cleanup3D(t),t.clearCache?.(),void t.invalidate?.();const n={fromWorld:e.fromWorld,toWorld:e.toWorld,from3D:e.from3D,to3D:e.to3D,duration:Math.max(e.duration,1),startTime:performance.now(),progress:0};if(this.active.set(t,n),n.fromWorld&&this.ensureCanvas(),n.from3D){const e=t._realObject?.object3d;if(e){e.position.copy(n.from3D.pos),e.quaternion.copy(n.from3D.quat);const t=n.from3D.fromScale;t&&e.scale.set(t.x,t.y,t.z)}}this.startLoop()}cancel(t){this.active.has(t)&&this.complete(t)}renderComponent(t,e){const n=this.active.get(t);if(!n?.fromWorld||!n?.toWorld||!this._ctx)return;const i=this._ctx,r=n.progress,s=n.fromWorld,o=n.toWorld,a=s.x+(o.x-s.x)*r,c=s.y+(o.y-s.y)*r,l=s.rotation+(o.rotation-s.rotation)*r,h=s.width+(o.width-s.width)*r,d=s.height+(o.height-s.height)*r,{translate:u={x:0,y:0},scale:p={x:1,y:1}}=e.model;i.save(),i.translate(u.x,u.y),i.scale(p.x,p.y),i.translate(a,c),i.rotate(l);const f=t.bounds;if(f&&f.width&&f.height){const t=h/f.width,e=d/f.height;i.scale(t,e),i.translate(-(f.left+f.width/2),-(f.top+f.height/2))}t.render(i),i.restore()}beginDraw(){if(!this._canvas||!this._ctx)return;this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._ctx.save();const t=globalThis.devicePixelRatio||1;this._ctx.scale(t,t)}endDraw(){this._ctx&&this._ctx.restore()}resize(){if(!this._canvas)return;const t=this.root?.model_layer;if(!t?.element)return;const e=t.element.clientWidth,n=t.element.clientHeight;t.fitSize(this._canvas,!0,e,n)}dispose(){for(const[t]of this.active)this.cleanup3D(t);this.active.clear(),this.stopLoop(),this.removeCanvas()}ensureCanvas(){if(this._canvas)return;const t=this.root?.model_layer;if(!t?.element)return;const e=t.element;this._canvas=document.createElement("canvas"),this._canvas.width=1,this._canvas.height=1,this._canvas.style.position="absolute",this._canvas.style.pointerEvents="none",this._canvas.style.zIndex="50",this._canvas.setAttribute("scene","transition-canvas"),e.appendChild(this._canvas);const n=e.clientWidth,i=e.clientHeight;t.fitSize(this._canvas,!0,n,i),this._ctx=this._canvas.getContext("2d")}removeCanvas(){this._canvas&&(this._canvas.parentNode?.removeChild(this._canvas),this._canvas=null,this._ctx=null)}startLoop(){if(this.rafId)return;const t=()=>{this.tick(),this.active.size>0?this.rafId=requestAnimationFrame(t):this.rafId=0};this.rafId=requestAnimationFrame(t)}stopLoop(){this.rafId&&(cancelAnimationFrame(this.rafId),this.rafId=0)}tick(){if(this.root?.app?.suppressAnimations){const t=[...this.active.keys()];for(const e of t)this.complete(e);return}const t=performance.now(),e=[];for(const[n,i]of this.active){const r=t-i.startTime,s=Math.min(r/i.duration,1),o=$c(s);if(i.progress=o,i.from3D&&i.to3D){const t=n._realObject?.object3d;if(t){t.position.lerpVectors(i.from3D.pos,i.to3D.pos,o),t.quaternion.copy(i.from3D.quat).slerp(i.to3D.quat,o);const e=i.from3D.fromScale,n=i.from3D.toScale;e&&n&&t.scale.set(e.x+(n.x-e.x)*o,e.y+(n.y-e.y)*o,e.z+(n.z-e.z)*o)}}n.clearCache?.(),n.invalidate?.(),s>=1&&e.push(n)}for(const t of e)this.complete(t)}complete(t){this.active.get(t),this.cleanup3D(t),this.active.delete(t),t.clearCache?.(),t.invalidate?.();let e=!1;for(const[,t]of this.active)if(t.fromWorld){e=!0;break}e||this.removeCanvas()}cleanup3D(t){const e=t._realObject;e&&(e.object3d&&e.object3d.scale.set(1,1,1),e.suppressTransform=!1,e.update?.())}}const Xc=new Image;function qc(t){return class extends t{get showMoveHandle(){return!1}postrender(t){super.postrender(t),this.app.isEditMode&&this._focused&&this.showMoveHandle&&this._draw_move_handle(t)}_draw_move_handle(t){const{left:e,top:n,width:i}=this.bounds;t.save(),t.beginPath(),t.globalAlpha=1,t.rect(e+i,n,25,25);t.fillStyle="rgba(235, 235, 235, 1)",t.fill(),t.drawImage(Xc,e+i+3.75,n+3.75,17.5,17.5),t.closePath(),t.restore()}contains(t,e){let n=super.contains(t,e);if(this.app.isViewMode)return n;if(!n){const{left:i,top:r,width:s}=this.bounds,o=i+s,a=25;this.showMoveHandle&&(n=t<Math.max(o+25,o)&&t>Math.min(o+25,o)&&e<Math.max(r+a,r)&&e>Math.min(r+a,r))}return this._focused!==n&&(this._focused=n,this.invalidate()),n}}}Xc.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAAclBMVEVHcEwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAC0BbqFAAAAJXRSTlMAgAP3VSI6/g9fBk5FavJsMrariSjzPnO1enRRL5SMhmOOWB9keFTE0wAAANxJREFUOMutk9kWgyAMRLFuiLjUtdp9yf//YglVsQXz1HniMPcEMgHGvpX2O0Ypi+EgCL+IAShC+wB7QfubRDT7AFcnUPoLMLiP4PyJbsb55i05AgnR5iaQDsICgtH0cotBWoAP1c7kC6kFxEseCfZfB6gEgbNeBrira2QmH1uVYCXlA3is8UmgUCPIyQJKEmu8QtQJN0e9DPXVpzG2G216c1CqRmcBOdxXk07sWUSPv07zo0amCNQycv+NzmR6cRcwmfbuI7p2nZ/z4be0P83Foz6vIkhfZXr82XgDlZsspIq4peUAAAAASUVORK5CYII=";const Kc=[];class Qc extends(qc($a(Ga))){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 Za.get(this.get("layout"))||tc}reflow(){this.layout.reflow(this),this.components&&this.components.forEach(t=>{t.isContainer()&&t.reflow()})}get hierarchy(){const t=super.hierarchy;return this.components?.length&&(t.components=this.components.map(t=>t.hierarchy)),t}reparent(t,e={}){if(!t)return;const{animated:n=!1,duration:i=2e3,ease:r="inout"}=e,s=t.parent;if(!s||s===this)return;const o=t=>{let e=0,n=t;for(;n&&!n.isRootModel?.();)e+=n.state?.rotation||0,n=n.parent;return e},a=!(!t._realObject?.object3d||!this._realObject?.object3d);let c=null,l=null,h=null,d=null;if(a){const e=this._realObject.object3d,n=t._realObject.object3d,i=t._realObject.dimension||{width:1,height:1,depth:1};e.updateWorldMatrix(!0,!1),n.updateWorldMatrix(!0,!1),e.attach(n),c={pos:n.position.clone(),quat:n.quaternion.clone(),fromDimW:i.width||1,fromDimH:i.height||1,fromDimD:i.depth||1},t._realObject.suppressTransform=!0}else{const e=t.bounds,n=t.center,i=t.toScene(n.x,n.y);h={x:i.x,y:i.y,rotation:o(s),width:e.width,height:e.height}}if(this.addComponent(t,{silent:!0}),a){const e=t._realObject.object3d;t.clearCache();const n=t._realObject.position,i=t._realObject.rotation,r=t._realObject.dimension||{width:1,height:1,depth:1},s=r.width||1,o=r.height||1,a=r.depth||1,h={x:c.fromDimW/s,y:c.fromDimH/o,z:c.fromDimD/a};l={pos:e.position.clone().set(n.x,n.y,n.z),quat:e.quaternion.clone().setFromEuler(e.rotation.clone().set(i.x,i.y,i.z))},c.fromScale=h,c.toScale={x:1,y:1,z:1},e.position.copy(c.pos),e.quaternion.copy(c.quat)}else{const e=t.bounds,n=t.center,i=t.toScene(n.x,n.y);d={x:i.x,y:i.y,rotation:o(this),width:e.width,height:e.height}}if(n){const e=this.root?.transitionEffect;e&&e.begin(t,{fromWorld:h,toWorld:d,from3D:c,to3D:l,duration:i,ease:r})}}addComponent(t,e=!1){const{ghost:n=!1,silent:i=!1}="boolean"==typeof e?{ghost:e}:e,r=t.parent;if(r){if(this===r)return;r.removeComponent(t,n||i)}const s=this._components.push(t)-1;i&&(t._silentAdd=!0),t.parent=this,t.added(this),n||i||this.trigger("add",this,t,s),t.delegate_on(this),i?(r&&this.root?._removeTraverse?.(t),this.trigger("add",this,t,s),t.trigger("added",this,t,s),delete t._silentAdd):n||t.trigger("added",this,t,s),this.root&&this.root.isReady&&t.ready()}removeComponent(t,e=!1){const n=this._components.indexOf(t);-1!=n&&(this._components.splice(n,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,n=!1){const i=t.parent;i&&i.removeComponent(t,n);const r=this._components.splice(0,e);this._components=r.concat(t,this._components),e=this._components.indexOf(t),t.parent=this,t.added(this),n||this.trigger("add",this,t,e),t.delegate_on(this),n||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(n=>{n.isContainer()?n.traverse(t,e):t.call(e,n)})}indexOf(t){return(this._components||Kc).indexOf(t)}size(){return(this._components||Kc).length}moveChildAt(t,e){const n=this.indexOf(e);if(-1==n)return;let i=this._components.splice(0,n);const r=this._components.splice(1);this._components=i.concat(r),t=Math.max(0,t),t=Math.min(t,this._components.length),i=this._components.splice(0,t),this._components=i.concat(e,this._components)}moveChildForward(t){const e=this.indexOf(t);-1!=e&&e!=this.size()-1&&(this._components[e]=this._components[e+1],this._components[e+1]=t)}moveChildBackward(t){const e=this.indexOf(t);-1!=e&&0!=e&&(this._components[e]=this._components[e-1],this._components[e-1]=t)}moveChildToFront(t){const e=this.indexOf(t);if(-1==e||e==this.size()-1)return;const n=this._components.splice(0,e),i=this._components.splice(1);this._components=n.concat(i,this._components)}moveChildToBack(t){const e=this.indexOf(t);if(-1==e||0==e)return;const n=this._components.splice(0,e),i=this._components.splice(1);this._components=this._components.concat(n,i)}symmetryX(t){super.symmetryX(t),this.components.map(t=>{t.symmetryX(0)})}findAll(t,...e){if("string"==typeof t)return ma(t,this,e[0]||this);if("function"!=typeof t)return[];let n=[];for(let i=this.components.length-1;i>=0;i--){const r=this.components[i].findAll(t,...e);r&&(n=n.concat(r))}return t(this,...e)&&n.push(this),n}findFirst(t,...e){if("string"==typeof t)return ma(t,this,e[0])[0];if("function"==typeof t){for(let n=this.components.length-1;n>=0;n--){const i=this.components[n].findFirst(t,...e);if(null!=i)return i}return t(this,...e)?this:void 0}}findById(t){return this.root.findAllById?.(t)?.[0]}findByRefid(t){return this.root.findByRefid?.(t)}contains(t,e){let n=super.contains(t,e);if(!n){const{left:i,top:r,width:s,height:o}=this.state;n=t<Math.max(i+s,i)&&t>Math.min(i+s,i)&&e<Math.max(r+o,r)&&e>Math.min(r+o,r)}return n}capture(t,e,n){if(!this.app.isEditMode&&this.hidden)return!1;const i=this.fromParent(t,e);if(!this.contains(i.x,i.y))return!1;const r=this.bounds;i.x-=r.left,i.y-=r.top;const s=this.layout.capturables(this);for(let r=s.length-1;r>=0;r--){const o=s[r];let a;if(a="static"==o.position?o.capture(i.x,i.y,n):o.capture(t,e,n),a)return a}return this.capturable&&!n?.(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}const n=[],{left:i,top:r,width:s,height:o}=this.bounds;for(let e=0;e<t.length;e++){const a=this.fromParent(t[e].x,t[e].y);if(a.x<i||a.x>i+s||a.y<r||a.y>r+o)return!1;a.x-=i,a.y-=r,n.push(a)}const a=this.layout.capturables(this);for(let t=a.length-1;t>=0;t--){const i=a[t];if(!i.isContainer())continue;const r=i.capturePath(n,e);if(r)return r}return this.focusible&&this}render(t){if("popup"===this.position)return;const{left:e=0,top:n=0,width:i,height:r}=this.bounds;t.beginPath(),t.rect(e,n,i,r),t.closePath(),this.drawFill(t),this.drawStroke(t)}postrender(t){if("popup"===this.position)return void super.postrender(t);const e=this.layout.drawables(this);if(e.length>0){let{left:n=0,top:i=0,width:r,height:s}=this.bounds;t.save(),this.showOverflow||(t.beginPath(),t.rect(n,i,r,s),t.clip(),t.closePath()),({top:i,left:n}=this.state),t.translate(n,i),e.forEach(e=>{const n=this.root?.transitionEffect;n?.isReparenting(e)?n.renderComponent(e,this.root?.model_layer):e.draw(this.position&&"static"!==this.position?t:this.getContext(e))}),t.translate(-n,-i),t.restore()}super.postrender(t)}trim(){this.components.forEach(t=>{t.trim()}),super.trim()}}["layout"].forEach(t=>Ga.memoize(Qc.prototype,t,!1));const Zc=[],Jc=Jn(function(){Zc.forEach(t=>{t.resize()})},100);"undefined"!=typeof window&&window.addEventListener("resize",Jc);class tl extends Qc{constructor(t,e){super(Object.assign({type:"root",scale:{x:1,y:1}},t||{}),e),this._hasSameParentForAllSelected=!1,this._maxRefid=e?.isViewMode?1e6:0,t=t||{},this.fitMode=t.model&&t.model.fitMode,this._app=e,this.style=t.style,this.indexMap=new Map,this.refidIndexMap=new Map,this.templateMap={},this._serviceMap=new Map,this.transitionEffect=new Wc(this),this.target_element=t.target_element,this.rebuildContentModel(this.model.model),Zc.push(this)}registerService(t,e){this._serviceMap.set(t,e)}getService(t){return this._serviceMap.get(t)}unregisterService(t){this._serviceMap.delete(t)}dispose(){wd.hideAll(this),this.transitionEffect?.dispose(),this._app&&this._app.dispose(),super.dispose(),this._disposeAllResources(),this.target_element=null,this._refresh_mapping_debouncer&&"function"==typeof this._refresh_mapping_debouncer.cancel&&this._refresh_mapping_debouncer.cancel(),delete this._refresh_mapping_debouncer;const t=Zc.indexOf(this);t>=0&&Zc.splice(t,1),this.refidIndexMap.clear(),this.indexMap.clear(),this._serviceMap.clear(),this._maxRefid=0}isRoot(){return!0}get app(){return this._app}get target_element(){return this._target_element}set target_element(t){this._ua_event_handler&&(this._ua_event_handler.dispose(),delete this._ua_event_handler),t&&(t.style.position="absolute",t.style.cursor="default",t.style.overflow="hidden",t.setAttribute("scene","root-container"),this._ua_event_handler=new xc(this,t)),this.forEach(e=>e.target=t),this._target_element=t}get fitMode(){return this._fitMode}set fitMode(t){this._fitMode=t}get hasSameParentForAllSelected(){return this._hasSameParentForAllSelected}set hasSameParentForAllSelected(t){this._hasSameParentForAllSelected=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){const n=this.templateMap[t];n&&ji("Template replaced (duplicated)",t,e,n),this.templateMap[t]=e,delete this.templatePrefixes}removeTemplate(t,e){const n=this.templateMap[t];n!==e?Fi("Removing template failed (different)",t,e,n):delete this.templateMap[t],delete this.templatePrefixes}findTemplateFor(t){this.templatePrefixes||(this.templatePrefixes=Object.keys(this.templateMap).sort().reverse());const e=this.templatePrefixes.find(e=>t.startsWith(e));if(e)return this.templateMap[e]}addIndex(t,e){if(!t)return;const n="#"===t[0]?t.substring(1):t,i=this.indexMap.get(n);i?i.push(e):this.indexMap.set(n,[e])}removeIndex(t,e){if(!t)return;const n="#"===t[0]?t.substring(1):t,i=this.indexMap.get(n);if(!i)return;const r=i.indexOf(e);-1===r?Fi("Removing index failed (not found)",t,e):(i.splice(r,1),0===i.length&&this.indexMap.delete(n))}addRefidIndex(t,e){null==t&&(t=this.getNewRefid(),e.set("refid",t)),this._maxRefid=Math.max(t,this._maxRefid);const n=this.refidIndexMap.get(t);n&&ji("Refid Index replaced (has not to be)",t,e,n),this.refidIndexMap.set(t,e)}removeRefidIndex(t,e){if(null==t)return;const n=this.refidIndexMap.get(t);n!==e?ji("Refid Removing index failed (has not to be)",t,e,n):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){if(!t)return null;const e=this.indexMap.get("#"===t[0]?t.substring(1):t);return e?e[0]:null}findAllById(t){return t&&this.indexMap.get("#"===t[0]?t.substring(1):t)||tl.EMPTY_ARRAY}findByRefid(t){return this.refidIndexMap.get(t)}findOrCreate(t){const e=this.findAllById(t);if(!e||0===e.length){if(this.app&&!this.app.isEditMode){const e=this.findTemplateFor(t);if(e){const n=Lc(Object.assign(Hn(e.hierarchy),{id:t,templatePrefix:""}),this.app);return this.model_layer.addComponent(n),[n]}}return[]}return e}resize(){this.components.forEach(t=>{t.resize&&t.resize()}),this.invalidate()}fit(t){const{width:e,height:n,fitMode:i}=this.model_layer.model,r=this.target_element,s=this.model_layer;if(this.fitMode=t||this.fitMode||i||"ratio",e&&n&&r&&r.clientWidth&&r.clientHeight){switch(this.fitMode){case"center":!function(t,e,n){const i=t.unitScale,{width:r,height:s}=e.model;e.set("scale",{x:i,y:i}),e.set("translate",{x:Math.max((n.clientWidth-r*i)/2,0),y:Math.max((n.clientHeight-s*i)/2,0)})}(this,s,r);break;case"both":!function(t,e,n){const{width:i,height:r}=e.model,s=n.clientWidth,o=n.clientHeight;e.set("scale",{x:s/i,y:o/r}),e.set("translate",{x:0,y:0})}(0,s,r);break;case"width":!function(t,e,n){const i=n.clientWidth/e.get("width");e.set("scale",{x:i,y:i}),e.set("translate",{x:0,y:0})}(0,s,r);break;case"height":!function(t,e,n){const i=n.clientHeight/e.get("height");e.set("scale",{x:i,y:i}),e.set("translate",{x:0,y:0})}(0,s,r);break;case"ratio":!function(t,e,n){const{width:i,height:r}=e.model,s=n.clientWidth,o=n.clientHeight,a=s/i,c=o/r,l=Math.min(a,c);e.set("scale",{x:l,y:l}),e.set("translate",{x:(s-i*l)/2,y:(o-r*l)/2})}(0,s,r);break;default:!function(t,e){const n=t.unitScale;e.set("scale",{x:n,y:n}),e.set("translate",{x:0,y:0})}(this,s)}this.resize()}}_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=>{Tc.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=new Map,this.refidIndexMap=new Map,this.templateMap={}}rebuildContentModel(t,e){let n,i;if(e?.preserveThreeD&&this.model_layer?.is3dMode){const t=this.model_layer._threeCapability;t&&(i=t.captureSessionState()),n=this.model_layer.detachThreeCapability()}this._disposeAllResources(),this.eventEngine=new hc(this);const r=this._app?.loadTracker;(t=t||{}).type="model-layer",t.dataLagMonitor&&this._app&&this._app.initLagTracker(t.dataLagMonitor),r?.setPhase("compile"),this.model_layer=Lc(t,this.app),this.addComponent(this.model_layer),this.model_layer.target=this.target_element,this.assist_layers=(this.model.layers||[]).map(t=>{const e=Lc(t,this.app);if(e)return this.addComponent(e),e.target=this.target_element,e;ji("Layer compile failed",t)}).filter(Boolean),this.assist_handlers=(this.model.handlers||[]).map(t=>{const e={};return this.eventEngine.add(e,Tc.get(t)),e}),n&&(this.model_layer?.model?.threed?(this.model_layer.adoptThreeCapability(n),i&&n.restoreSessionState(i)):n.dispose()),r?.setPhase("assets"),this._ready=!0,this.traverse(t=>t.ready()),r?.checkComplete(),r?.startGlobalTimeout()}get root(){return this}get anchors(){return[]}get isReady(){return this._ready}get rootModel(){return this.model_layer}get threed(){return this.model_layer?.model?.threed||!1}set threed(t){this.model_layer&&this.model_layer.toggleThreeD(t)}get stuck(){return!0}get data(){const t={};for(const[e,n]of this.indexMap.entries())n.length>0&&(t[e]=n[0].data);return t}set data(t){for(const e in t){const n=this.findOrCreate(e);n&&0!==n.length&&n.forEach(n=>n.data=t[e])}}get dataByRefid(){const t={};for(const[e,n]of this.refidIndexMap.entries())t[e]=n.data;return t}set dataByRefid(t){for(const e in t){const n=this.findByRefid(Number(e));n&&(n.data=t[e])}}get values(){const t={};for(const[e,n]of this.indexMap.entries())n.length>0&&(t[e]=n[0].value);return t}set values(t){for(const e in t){const n=this.findOrCreate(e);n&&0!==n.length&&n.forEach(n=>n.value=t[e])}}get valuesByRefid(){const t={};for(const[e,n]of this.refidIndexMap.entries())t[e]=n.value;return t}set valuesByRefid(t){for(const e in t){const n=this.findByRefid(Number(e));n&&(n.value=t[e])}}get selected(){return(this._selected||[]).filter(t=>t.parent)}set selected(t){const e=this._selected;if(this._selected=t,!t||t.length<=1)this.hasSameParentForAllSelected=!0;else{const 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())}_areAliasesEqual(t,e){if(!Array.isArray(t)&&!Array.isArray(e))return!0;if(!Array.isArray(t)||!Array.isArray(e))return!1;if(t.length!==e.length)return!1;const n=[...t].sort(),i=[...e].sort();return n.every((t,e)=>t===i[e])}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=Jn(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));const{id:e,alias:n,refid:i,tag:r,templatePrefix:s}=t.model;this.addRefidIndex(i,t),e&&this.addIndex(e,t),Array.isArray(n)&&n.forEach(e=>{e&&this.addIndex(e,t)}),r&&this.subscribe(r,t),s&&this.addTemplate(s,t);const o=oi({},t.eventMap,t.model.eventMap);this.eventEngine.add(t,o)}_removeTraverse(t){t.components&&t.components.forEach(t=>this._removeTraverse(t));const{id:e,alias:n,refid:i,tag:r,templatePrefix:s}=t.model;this.removeRefidIndex(i,t),e&&this.removeIndex(e,t),Array.isArray(n)&&n.forEach(e=>{e&&this.removeIndex(e,t)}),r&&this.unsubscribe(r,t),s&&this.removeTemplate(s,t),this.eventEngine.remove(t)}onadded(t,e){this._addTraverse(e),e._silentAdd||this.refreshMappings(),this.invalidate()}onremoved(t,e){this._removeTraverse(e),this.invalidate()}onchanged(t,e,n){e.templatePrefix&&this.removeTemplate(e.templatePrefix,n.origin),t.templatePrefix&&this.addTemplate(t.templatePrefix,n.origin),e.id&&this.removeIndex(e.id,n.origin),t.id&&this.addIndex(t.id,n.origin),Array.isArray(e.alias)&&e.alias.forEach(t=>{t&&this.removeIndex(t,n.origin)}),Array.isArray(t.alias)&&t.alias.forEach(t=>{t&&this.addIndex(t,n.origin)}),e.tag&&this.unsubscribe(e.tag,n.origin),t.tag&&this.subscribe(t.tag,n.origin),e.id==t.id&&e.class==t.class&&this._areAliasesEqual(e.alias,t.alias)||n.origin._silentAdd||this.refreshMappings()}}tl.EMPTY_ARRAY=[],Ga.memoize(tl.prototype,"unitScale",!1);const el=60;class nl{constructor(){this._monitors=new Map,this._disposed=!1}configure(t){const e=Array.isArray(t)?t:[t];for(const t of e)this._monitors.set(t.tag,{config:{...t,warnThreshold:t.warnThreshold??5e3,criticalThreshold:t.criticalThreshold??15e3},fieldKeys:t.timestampField.split("."),samples:new Float64Array(el),writeIdx:0,count:0,baseline:0,baselineSet:!1,baselineSum:0,baselineCount:0,lastLevel:"normal"})}isMonitored(t){return this._monitors.has(t)}recordIfMonitored(t,e){if(this._disposed)return;const n=this._monitors.get(t);if(!n||!e)return;const i=this._extractField(e,n.fieldKeys);if("number"!=typeof i||i<=0)return;const r=Date.now()-i;n.samples[n.writeIdx]=r,n.writeIdx=(n.writeIdx+1)%el,n.count<el&&n.count++,n.baselineSet||(n.baselineSum+=r,n.baselineCount++,n.baselineCount>=5&&(n.baseline=n.baselineSum/n.baselineCount,n.baselineSet=!0))}getStats(t){const e=this._monitors.get(t);if(!e)return null;const{count:n,baseline:i,baselineSet:r}=e;if(0===n)return{tag:t,currentDelta:0,baseline:0,drift:0,driftAvg:0,driftMax:0,trend:"stable",sampleCount:0,level:"normal"};const s=(e.writeIdx-1+el)%el,o=e.samples[s],a=r?o-i:0;let c=0,l=0;const h=this._getRecentDrifts(e);for(const t of h)c+=t,Math.abs(t)>Math.abs(l)&&(l=t);return{tag:t,currentDelta:o,baseline:i,drift:a,driftAvg:h.length>0?c/h.length:0,driftMax:l,trend:this._calcTrend(e),sampleCount:n,level:this._calcLevel(Math.abs(a),e.config)}}getAllStats(){const t=[];for(const e of this._monitors.keys()){const n=this.getStats(e);n&&t.push(n)}return t}evaluateAll(){if(!this._disposed)for(const[t,e]of this._monitors.entries()){const n=this.getStats(t);n&&(n.level!==e.lastLevel&&(e.lastLevel=n.level,this.onLevelChange?.(t,n.level,n)))}}dispose(){this._disposed=!0,this._monitors.clear(),this.onLevelChange=void 0}_extractField(t,e){let n=t;for(const t of e){if(null==n)return;n=n[t]}return n}_getRecentDrifts(t){if(!t.baselineSet||0===t.count)return[];const e=Math.min(t.count,10),n=[];for(let i=0;i<e;i++){const e=(t.writeIdx-1-i+el)%el;n.push(t.samples[e]-t.baseline)}return n.reverse()}_calcTrend(t){if(!t.baselineSet)return"stable";const e=this._getRecentDrifts(t),n=e.length;if(n<3)return"stable";let i=0,r=0,s=0,o=0;for(let t=0;t<n;t++)i+=t,r+=e[t],s+=t*e[t],o+=t*t;const a=(n*s-i*r)/(n*o-i*i),c=r/n,l=e.map(Math.abs),h=l.reduce((t,e)=>t+e,0)/n;if(h>0&&l[n-1]>3*h)return"spike";const d=Math.max(.1*Math.abs(c),50);return a>d?"increasing":a<-d?"decreasing":"stable"}_calcLevel(t,e){return t>=(e.criticalThreshold??15e3)?"critical":t>=(e.warnThreshold??5e3)?"warn":"normal"}}const il=5e3;class rl{constructor(t){this._entries=new Map,this._phase="fetch",this._phaseHistory=[],this._disposed=!1,this.needsOverlay=!1,this._firstRenderDone=!1,this._options=t||{},this._startTime=performance.now(),this._promise=new Promise(t=>{this._promiseResolve=t}),this._phaseHistory.push({phase:"fetch",timestamp:this._startTime,elapsed:0}),this._slowTimerId=setTimeout(()=>{"complete"===this._phase||this._disposed||(this.needsOverlay=!0,this.onNeedsOverlay?.())},il)}get phase(){return this._phase}get phaseHistory(){return this._phaseHistory}get progress(){const t=this._entries.size;if(0===t)return 1;let e=0;for(const t of this._entries.values())"pending"!==t.status&&e++;return e/t}get pending(){const t=[],e=performance.now();for(const n of this._entries.values())"pending"===n.status&&t.push(this._toPublicEntry(n,e));return t}get entries(){const t=performance.now(),e=[];for(const n of this._entries.values())e.push(this._toPublicEntry(n,t));return e}get stats(){let t=0,e=0,n=0,i=0,r=0;for(const s of this._entries.values())switch(s.status){case"loaded":t++;break;case"timeout":e++;break;case"error":n++;break;case"cancelled":i++;break;case"pending":r++}return{total:this._entries.size,loaded:t,timeout:e,error:n,cancelled:i,pending:r,elapsed:this._completedElapsed??performance.now()-this._startTime}}get promise(){return this._promise}markFirstRender(){this._firstRenderDone||this._disposed||(this._firstRenderDone=!0,this.setPhase("render"),this.checkComplete())}setPhase(t){if(this._disposed||this._phase===t||"complete"===this._phase)return;const e=performance.now(),n=this._phaseHistory[this._phaseHistory.length-1];n&&void 0===n.duration&&(n.duration=e-n.timestamp),this._phase=t,"complete"!==t?(this._phaseHistory.push({phase:t,timestamp:e,elapsed:e-this._startTime}),this.onPhase?.(t)):this.onPhase?.(t)}track(t,e,n,i){if(this._disposed)return;const r={id:t,type:e,url:n,startTime:performance.now(),status:"pending"};this._entries.set(t,r),this._options.assetTimeout&&this._options.assetTimeout>0&&(r.timerId=setTimeout(()=>{"pending"===r.status&&(r.status="timeout",r.endTime=performance.now(),r.timerId&&(r.timerId=void 0),this.onTimeout?.(this._toPublicEntry(r)),this._onEntryDone())},this._options.assetTimeout)),i.then(()=>{"pending"===r.status&&(r.status="loaded",r.endTime=performance.now(),this._clearEntryTimer(r),this._onEntryDone())},()=>{"pending"===r.status&&(r.status="error",r.endTime=performance.now(),this._clearEntryTimer(r),this._onEntryDone())})}checkComplete(){if(this._disposed||"complete"===this._phase)return;let t=!1;for(const e of this._entries.values())if("pending"===e.status){t=!0;break}!t&&this._firstRenderDone&&this._doComplete()}startGlobalTimeout(){if(this._disposed)return;const t=this._options.timeout;!t||t<=0||(this._globalTimerId=setTimeout(()=>{if("complete"===this._phase||this._disposed)return;const t=performance.now();for(const e of this._entries.values())"pending"===e.status&&(e.status="timeout",e.endTime=t,this._clearEntryTimer(e),this.onTimeout?.(this._toPublicEntry(e)));this._doComplete(!0)},t))}abort(){if(this._disposed)return;const t=performance.now();for(const e of this._entries.values())"pending"===e.status&&(e.status="cancelled",e.endTime=t,this._clearEntryTimer(e));this._doComplete(!0)}reset(){for(const t of this._entries.values())this._clearEntryTimer(t);this._globalTimerId&&(clearTimeout(this._globalTimerId),this._globalTimerId=void 0),this._slowTimerId&&(clearTimeout(this._slowTimerId),this._slowTimerId=void 0),this._entries.clear(),this._phase="fetch",this._startTime=performance.now(),this._phaseHistory=[{phase:"fetch",timestamp:this._startTime,elapsed:0}],this._completedElapsed=void 0,this._firstRenderDone=!1,this.needsOverlay=!1,this._disposed=!1,this._promise=new Promise(t=>{this._promiseResolve=t}),this._slowTimerId=setTimeout(()=>{"complete"===this._phase||this._disposed||(this.needsOverlay=!0,this.onNeedsOverlay?.())},il)}dispose(){if(!this._disposed){this._disposed=!0;for(const t of this._entries.values())this._clearEntryTimer(t);this._globalTimerId&&(clearTimeout(this._globalTimerId),this._globalTimerId=void 0),this._slowTimerId&&(clearTimeout(this._slowTimerId),this._slowTimerId=void 0),this._promiseResolve(),this.onPhase=void 0,this.onProgress=void 0,this.onTimeout=void 0,this.onComplete=void 0,this.onNeedsOverlay=void 0}}_onEntryDone(){this._disposed||(this.onProgress?.(this.stats),this.checkComplete())}_doComplete(t=!1){"complete"!==this._phase&&(this._completedElapsed=performance.now()-this._startTime,this._completedElapsed>il&&(this.needsOverlay=!0),this._globalTimerId&&(clearTimeout(this._globalTimerId),this._globalTimerId=void 0),this.setPhase("complete"),this.onComplete?.(this.stats),this._promiseResolve())}_clearEntryTimer(t){t.timerId&&(clearTimeout(t.timerId),t.timerId=void 0)}_toPublicEntry(t,e){const n=t.endTime?t.endTime-t.startTime:(e??performance.now())-t.startTime;return{id:t.id,type:t.type,url:t.url,startTime:t.startTime,status:t.status,elapsed:n}}}let sl=13.3;var ol=function(t){return void 0!==t&&(sl=t),sl};const al="$base_url";const cl=Math.PI/12;class ll{constructor(t,e){this._postprocessing=!0,this._loadTrackerOwned=!1,this._suppressAnimationsFlag=!1,this._suppressScopeCount=0,this._mode=t,this.screen=ol(),this._baseUrl="undefined"!=typeof window?window.location.origin:null,this._refProvider=e,this.isEditMode&&(this._rotateStep=cl,this._rotateStepForced=!1)}initLoadTracker(t){return this._loadTracker=new rl(t),this._loadTrackerOwned=!0,this._loadTracker}get loadTracker(){return this._loadTracker}adoptLoadTracker(t){this._loadTracker=t,this._loadTrackerOwned=!1}initLagTracker(t){return this._lagTracker=new nl,this._lagTracker.configure(t),this._lagTracker}get lagTracker(){return this._lagTracker}dispose(){this._loadTrackerOwned&&this._loadTracker?.dispose(),this._loadTracker=void 0,this._lagTracker?.dispose(),this._lagTracker=void 0,this._dataSubscriptionProvider?.dispose?.(),delete this._dataStorage}_calcScreen(){const t={width:screen.width,height:screen.height};this._PPI=function(t,e,n,i="d"){t<=0&&(t=1),e<=0&&(e=1);const r=("d"===i?Math.sqrt(t*t+e*e):"w"===i?t:e)/n;return r>0?Math.round(r):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 wr}get PPI(){return this._PPI}get PPM(){return this._PPM}get mode(){return this._mode}set mode(t){const 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{let e;return e=t.includes(al)?new URL(t.replace(al,this.baseUrl??""),this.baseUrl??void 0):new URL(t,location.origin),e.href}catch(e){Fi(e,t)}}get rotateStep(){return this._rotateStep}set rotateStep(t){this._rotateStep=Number(t)||cl}get rotateStepForced(){return this._rotateStepForced}set rotateStepForced(t){this._rotateStepForced=!!t}get dataStorage(){return this._dataStorage}set dataStorage(t){this._dataStorage=t}get postprocessing(){return this._postprocessing}set postprocessing(t){this._postprocessing=t}get suppressAnimations(){return this._suppressAnimationsFlag||this._suppressScopeCount>0}set suppressAnimations(t){this._suppressAnimationsFlag=!!t}withSuppressedAnimations(t){let e;this._suppressScopeCount++;try{e=t()}catch(t){throw this._suppressScopeCount--,t}return e&&"function"==typeof e.then?e.finally(()=>{this._suppressScopeCount--}):(this._suppressScopeCount--,e)}beginSuppressAnimations(){this._suppressScopeCount++;let t=!1;return{end:()=>{t||(t=!0,this._suppressScopeCount--)}}}}Ri(ll.prototype,Ei.withEvent);class hl{constructor(t,e){!(t=Number(t))||t<=0?(ji("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];Fi("Not forwardable.")}backward(){if(this.snapshot_taker&&this.snapshot_taker.take(),this.backwardable)return this.q[--this.pos];Fi("Not backwardable.")}get current(){if(-1!==this.pos)return this.q[this.pos];Fi("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}}const dl=Jn(t=>{t.brake||t.take()},1e3,{leading:!0,trailing:!1});function ul(t){!t.brake&&t.dirty&&dl(t)}class pl{constructor(t,e){this._brake=!1,this.dirty=!1,this.brake=!1,this.dirty=!1,this.state_holder=t,this.timecapsule=e,this.timecapsule.snapshot_taker=this}dispose(){dl.cancel(),this.state_holder=null,this.timecapsule=null}touch(){this.dirty=!0,ul(this)}take(t=!1){(this.dirty||t)&&(this.timecapsule.snapshot(this.state_holder.state),this.dirty=!1)}get brake(){return this._brake}set brake(t){this._brake=!!t,ul(this)}}function fl(t,e){const n=e.model_layer.get("scale"),i=e.model_layer.get("translate"),r=e.model_layer.is3dMode;if(t){const s=JSON.parse(t);s.scale=n,s.translate=i,s.threed=r,e.rebuildContentModel(s,{preserveThreeD:!0})}}class gl{constructor(t){this.container=t,this.timecapsule=new hl(20);const e=this;this.snapshot_taker=new pl({get state(){const t=e.container.model_layer.hierarchy;return JSON.stringify(t,Wo)}},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&&(fl(this.timecapsule.backward(),this.container),this.trigger("undo",this.undoable(),this.redoable()))}redo(){this.timecapsule.forwardable&&(fl(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")}}Ri(gl.prototype,Ei.withEvent);const ml="left",yl="right",bl="center",_l="bottom",vl="middle",xl="z-front",wl="z-back",Ml="z-middle",Sl=[ml,yl,bl,"top",vl,_l,xl,wl,Ml];function Al(t){if(!this.hasSameParentForAllSelected||-1===Sl.indexOf(t))return;const e=this.selected.filter(t=>!t.stuck);if(e.length<=1)return;const n=this.app.commander;Mc.around(n,function(){!function(t,e){const n=JSON.parse(JSON.stringify(e[0].bounds));let i=n.left+n.width,r=n.top+n.height;for(let t=0;t<e.length;t++){const s=e[t].bounds;n.left=s.left>n.left?n.left:s.left,n.top=s.top>n.top?n.top:s.top,i=s.left+s.width>i?s.left+s.width:i,r=s.top+s.height>r?s.top+s.height:r}switch(n.width=i-n.left,n.height=r-n.top,t){case ml:for(let t=0;t<e.length;t++){const i=e[t].bounds;e[t].bounds={left:n.left,top:i.top,width:i.width,height:i.height}}break;case bl:for(let t=0;t<e.length;t++){const i=e[t].bounds;e[t].bounds={left:n.left+n.width/2-i.width/2,top:i.top,width:i.width,height:i.height}}break;case yl:for(let t=0;t<e.length;t++){const n=e[t].bounds;e[t].bounds={left:i-n.width,top:n.top,width:n.width,height:n.height}}break;case"top":for(let t=0;t<e.length;t++){const i=e[t].bounds;e[t].bounds={left:i.left,top:n.top,width:i.width,height:i.height}}break;case vl:for(let t=0;t<e.length;t++){const i=e[t].bounds;e[t].bounds={left:i.left,top:n.top+n.height/2-i.height/2,width:i.width,height:i.height}}break;case _l:for(let t=0;t<e.length;t++){const n=e[t].bounds;e[t].bounds={left:n.left,top:r-n.height,width:n.width,height:n.height}}break;case xl:{let t=1/0;for(let n=0;n<e.length;n++){const i=e[n].state.zPos||0;i<t&&(t=i)}for(let n=0;n<e.length;n++)e[n].set({zPos:t});break}case wl:{let t=-1/0;for(let n=0;n<e.length;n++){const i=(e[n].state.zPos||0)+(e[n].state.depth||0);i>t&&(t=i)}for(let n=0;n<e.length;n++){const i=e[n].state.depth||0;e[n].set({zPos:t-i})}break}case Ml:{let t=1/0,n=-1/0;for(let i=0;i<e.length;i++){const r=e[i].state.zPos||0,s=e[i].state.depth||0;r<t&&(t=r),r+s>n&&(n=r+s)}const i=(t+n)/2;for(let t=0;t<e.length;t++){const n=e[t].state.depth||0;e[t].set({zPos:i-n/2})}break}default:;}}(t,e)})}const El="VERTICAL",kl=[El,"HORIZONTAL","Z"];function Cl(t){if(!this.hasSameParentForAllSelected||-1===kl.indexOf(t))return;const e=this.selected;if(e.length<=1)return;const n=this.app.commander;Mc.around(n,function(){!function(t,e){if("Z"===t)return void function(t){const e=t.filter(t=>!t.stuck).slice(0);e.sort((t,e)=>(t.state.zPos||0)+(t.state.depth||0)/2-((e.state.zPos||0)+(e.state.depth||0)/2));const n=e.reduce((t,e)=>t+(e.state.depth||0),0),i=e[0].state.zPos||0,r=((e[e.length-1].state.zPos||0)+(e[e.length-1].state.depth||0)-i-n)/(e.length-1);let s=i+(e[0].state.depth||0);for(let t=1;t<e.length-1;t++){const n=e[t],i=n.state.depth||0;s+=r,n.set({zPos:s}),s+=i}}(e);const n=e.filter(t=>!t.stuck).slice(0);n.sort(function(e,n){const i=e.center,r=n.center;return t===El?i.y-r.y:i.x-r.x});const i=n.reduce((e,n)=>e+(t===El?n.bounds.height:n.bounds.width),0),r=n[0].bounds,s=n[n.length-1].bounds,o=((t===El?s.top+s.height-r.top:s.left+s.width-r.left)-i)/(n.length-1);let a=t===El?r.top+r.height:r.left+r.width;for(let e=1;e<n.length-1;e++){const i=n[e],r=i.bounds;a+=o,t===El?(i.bounds={left:r.left,top:a,width:r.width,height:r.height},a+=r.height):(i.bounds={left:a,top:r.top,width:r.width,height:r.height},a+=r.width)}}(t,e)})}function Tl(t,e,n){this.app.commander.execute(new Oc({changes:[{component:t,to_container:e,to_index:n}]}))}function Pl(t){const e=this.selected.filter(t=>!t.stuck);if(0===e.length||e[0].isRootModel())return;if(e.length>1&&("forward"===t||"backward"===t))return;const n=e[0].parent;let i;if("forward"===t){const t=n.indexOf(e[0]);i=[{component:e[0],from_container:n,to_container:n,from_index:t,to_index:t+1}]}else if("backward"===t){const t=n.indexOf(e[0]);i=[{component:e[0],from_container:n,to_container:n,from_index:t,to_index:t-1}]}else i=e.filter(t=>t.parent===n).sort((e,i)=>{const r=n.indexOf(e)<n.indexOf(i);return"front"===t?r:!r}).map((e,i)=>(n.indexOf(e),{component:e,to_container:n,to_index:"front"===t?n.components.length-i-1:i}));const r=new Oc({changes:i});this.app.commander.execute(r)}function Dl(t,e,n){t instanceof Array||(t=[t]),n||(n=this.model_layer);const i=[],r=new Map;this.selected=t.map(t=>{try{return Lc(t,n.app,t=>{const e=this.getNewRefid();return void 0!==t&&r.set(t,e),e},t=>(this.indexMap[t]||[])[0])}catch(t){return Fi(t),!1}}).filter(Boolean).map(t=>{const{left:s,top:o,width:a,height:c,x:l,y:h,cx:d,cy:u}=e;return t.replaceRefids(r),isNaN(s)||isNaN(o)||isNaN(a)||isNaN(c)||(t.bounds={left:s,top:o,width:a,height:c}),isNaN(l)||isNaN(h)||t.move({x:l,y:h},!1),isNaN(d)||isNaN(u)||(t.center={x:d,y:u}),i.push({component:t,to_container:n}),t}),this.app.commander.execute(new Oc({changes:i}))}function Ol(){const t=[],e=new Map;if(this.selected=this.selected.filter(t=>!t.isRootModel()).map(n=>{const i=Ic(n,t=>{const n=this.getNewRefid();return void 0!==t&&e.set(t,n),n});return i.move({x:20,y:20},!1),t.push({component:i,to_container:n.parent}),i}).map(t=>(t.replaceRefids(e),t)),0===t.length)return;const n=new Oc({changes:t});this.app.commander.execute(n)}function zl(){const t=this.selected;this.selected=[];let e=null;const n=t.filter(t=>!t.isRootModel()&&(t.parent.focusible||t.parent.isGroup())).map(t=>(e||(e=t.parent),{component:t,to_container:null}));for(;e&&e.isGroup();){const t=[];if(e.components.filter(t=>!n.find(e=>e.component===t)).forEach(e=>t.push(e)),t.length>1)break;const i=e.parent;t.forEach(t=>n.push({component:t,to_container:i})),n.push({component:e,to_container:null}),e=i}n.length>0&&this.app.commander.execute(new Oc({changes:n})),e&&e.calculateBounds&&e.calculateBounds()}const Ll=new Set(["execute","redo","undo","command-reset"]);function Il(t,e,n,i){const r=function(t,e){return Ll.has(e)?t.app?.commander:"mode"===e?t.app:t}(this,e);r?.[t](e,n,i)}function Rl(t,e,n){Il.call(this,"on",t,e,n)}function jl(t,e,n){Il.call(this,"once",t,e,n)}function Fl(t,e,n){Il.call(this,"off",t,e,n)}function Bl(t){const e=this.target_element,n=t||this.fitMode,i=this;function r(){i.fit(n),document.fullscreenElement||document.removeEventListener("fullscreenchange",r)}document.addEventListener("fullscreenchange",r),e.requestFullscreen().catch(()=>{document.removeEventListener("fullscreenchange",r)})}let Nl=0;function Hl(){const t=this.selected.filter(t=>!t.isRootModel()).map(t=>t.hierarchy);if(0!==t.length)return Nl=0,JSON.stringify(t,null,2)}function Yl(){Nl=0;const t=Hl.call(this);return zl.call(this),t}function Gl(t){if(t)try{Nl++,Dl.call(this,JSON.parse(t),{x:15*Nl,y:15*Nl})}catch(e){ji(e,t)}}const Vl=function(){return{escape:function(t){return t.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1")},parseExtension:t,mimeType:function(e){const n=t(e).toLowerCase();return function(){const t="application/font-woff",e="image/jpeg";return{woff:t,woff2:t,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:e,jpeg:e,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml"}}()[n]||""},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){const n=window.atob(t.toDataURL().split(",")[1]),i=n.length,r=new Uint8Array(i);for(let t=0;t<i;t++)r[t]=n.charCodeAt(t);e(new Blob([r],{type:"image/png"}))})}(t)},resolveUrl:function(t,e){const n=document.implementation.createHTMLDocument(),i=n.createElement("base");n.head.appendChild(i);const r=n.createElement("a");return n.body.appendChild(r),i.href=e,r.href=t,r.href},getAndEncode:function(t){const e=3e4;Zl.impl.options.cacheBust&&(t+=(/\?/.test(t)?"&":"?")+(new Date).getTime());return new Promise(function(n){const i=new XMLHttpRequest;let r;if(i.onreadystatechange=s,i.ontimeout=o,i.responseType="blob",i.timeout=e,i.open("GET",t,!0),i.send(),Zl.impl.options.imagePlaceholder){const t=Zl.impl.options.imagePlaceholder.split(/,/);t&&t[1]&&(r=t[1])}function s(){if(4!==i.readyState)return;if(200!==i.status)return void(r?n(r):a("cannot fetch resource: "+t+", status: "+i.status));const e=new FileReader;e.onloadend=function(){const t=e.result.split(/,/)[1];n(t)},e.readAsDataURL(i.response)}function o(){r?n(r):a("timeout of "+e+"ms occured while fetching resource: "+t)}function a(t){ji(t),n("")}})},uid:function(){let 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(n){setTimeout(function(){n(e)},t)})}},asArray:function(t){const e=[],n=t.length;for(let i=0;i<n;i++)e.push(t[i]);return e},escapeXhtml:function(t){return t.replace(/#/g,"%23").replace(/\n/g,"%0A")},makeImage:function(t){return new Promise(function(e,n){const i=new Image;i.onload=function(){e(i)},i.onerror=n,i.src=t})},width:function(t){const n=e(t,"border-left-width"),i=e(t,"border-right-width");return t.scrollWidth+n+i},height:function(t){const n=e(t,"border-top-width"),i=e(t,"border-bottom-width");return t.scrollHeight+n+i}};function t(t){const e=/\.([^\.\/]*?)$/g.exec(t);return e?e[1]:""}function e(t,e){const n=window.getComputedStyle(t).getPropertyValue(e);return parseFloat(n.replace("px",""))}}(),Ul=function(){const t=/url\(['"]?([^'"]+?)['"]?\)/g;return{inlineAll:function(t,r,s){return o()?Promise.resolve(t):Promise.resolve(t).then(n).then(function(e){let n=Promise.resolve(t);return e.forEach(function(t){n=n.then(function(e){return i(e,t,r,s)})}),n});function o(){return!e(t)}},shouldProcess:e,impl:{readUrls:n,inline:i}};function e(e){return-1!==e.search(t)}function n(e){const n=[];let i;for(;null!==(i=t.exec(e));)n.push(i[1]);return n.filter(function(t){return!Vl.isDataUrl(t)})}function i(t,e,n,i){return Promise.resolve(e).then(function(t){return n?Vl.resolveUrl(t,n):t}).then(i||Vl.getAndEncode).then(function(t){return Vl.dataAsUrl(t,Vl.mimeType(e))}).then(function(n){return t.replace(function(t){return new RegExp("(url\\(['\"]?)("+Vl.escape(t)+")(['\"]?\\))","g")}(e),"$1"+n+"$3")})}}(),$l=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(Vl.asArray(document.styleSheets)).then(function(t){const e=[];return t.forEach(function(t){try{Vl.asArray(t.cssRules||[]).forEach(t=>e.push(t))}catch(e){Fi("Error while reading CSS rules from "+t.href,e instanceof Error?e.message:String(e))}}),e}).then(function(t){return t.filter(function(t){return t.type===CSSRule.FONT_FACE_RULE}).filter(function(t){return Ul.shouldProcess(t.style.getPropertyValue("src"))})}).then(function(e){return e.map(t)});function t(t){return{resolve:function(){const e=(t.parentStyleSheet||{}).href;return Ul.inlineAll(t.cssText,e)},src:function(){return t.style.getPropertyValue("src")}}}}}(),Wl=function(){return{inlineAll:function e(n){return n instanceof Element?i(n).then(function(){return n instanceof HTMLImageElement?t(n).inline().then(()=>n):Promise.all(Vl.asArray(n.childNodes).map(function(t){return e(t)})).then(()=>n)}):Promise.resolve(n);function i(t){const e=t.style.getPropertyValue("background");return e?Ul.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 Vl.isDataUrl(t.src)?Promise.resolve():Promise.resolve(t.src).then(e||Vl.getAndEncode).then(function(e){return Vl.dataAsUrl(e,Vl.mimeType(t.src))}).then(function(e){return new Promise(function(n,i){t.onload=n,t.onerror=i,t.src=e})})}}}}(),Xl={imagePlaceholder:void 0,cacheBust:!1};function ql(t,e){return function(t){void 0===t.imagePlaceholder?Zl.impl.options.imagePlaceholder=Xl.imagePlaceholder:Zl.impl.options.imagePlaceholder=t.imagePlaceholder;void 0===t.cacheBust?Zl.impl.options.cacheBust=Xl.cacheBust:Zl.impl.options.cacheBust=t.cacheBust}(e=e||{}),Promise.resolve(t).then(function(t){return Ql(t,e.filter,!0)}).then(function(t){return function(t){return Wl.inlineAll(t).then(function(){return t})}(t)}).then(function(t){const{bgcolor:n,width:i,height:r,style:s,sx:o=1,sy:a=1}=e||{},c=t.style;n&&(c.backgroundColor=n);i&&(c.width=i+"px");r&&(c.height=r+"px");c["margin-left"]="0px",c["margin-top"]="0px",c.transform=`rotate(0rad) translate(0px, 0px) scale(${o}, ${a}) perspective(1px)`,s&&Object.keys(s).forEach(function(t){c[t]=s[t]});return t}).then(function(n){return function(t,e,n){return Promise.resolve(t).then(function(t){return t.setAttribute("xmlns","http://www.w3.org/1999/xhtml"),(new XMLSerializer).serializeToString(t)}).then(Vl.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="'+n+'">'+t+"</svg>"}).then(function(t){return"data:image/svg+xml;charset=utf-8,"+t})}(n,e.width||Vl.width(t),e.height||Vl.height(t))})}function Kl(t,e){return ql(t,e).then(Vl.makeImage).then(Vl.delay(100)).then(function(n){const i=function(t){const n=document.createElement("canvas");if(n.width=e.width||Vl.width(t),n.height=e.height||Vl.height(t),e.bgcolor){const t=n.getContext("2d");t.fillStyle=e.bgcolor,t.fillRect(0,0,n.width,n.height)}return n}(t);return i.getContext("2d").drawImage(n,0,0),i})}function Ql(t,e,n){return n||!e||e(t)?Promise.resolve(t).then(function(t){if(t instanceof HTMLCanvasElement)try{return Vl.makeImage(t.toDataURL()).then(t=>t)}catch(t){Fi(t)}return t.cloneNode(!1)}).then(function(n){return function(t,e,n){const i=t.childNodes;return 0===i.length?Promise.resolve(e):r(e,Vl.asArray(i),n).then(function(){return e});function r(t,e,n){let i=Promise.resolve();return e.forEach(function(e){i=i.then(function(){return Ql(e,n,!1)}).then(function(e){e&&t.appendChild(e)})}),i}}(t,n,e)}).then(function(e){return function(t,e){return e instanceof Element?Promise.resolve().then(n).then(i).then(r).then(s).then(function(){return e}):e;function n(){function n(t,e){function n(t,e){Vl.asArray(t).forEach(function(n){e.setProperty(n,t.getPropertyValue(n),t.getPropertyPriority(n))})}t.cssText?e.cssText=t.cssText:n(t,e)}n(window.getComputedStyle(t),e.style)}function i(){function n(n){const i=window.getComputedStyle(t,n),r=i.getPropertyValue("content");if(""===r||"none"===r)return;const s=Vl.uid(),o=e;o.className=o.className+" "+s;const a=document.createElement("style");function c(t,e,n){const i="."+t+":"+e,r=n.cssText?s(n):o(n);return document.createTextNode(i+"{"+r+"}");function s(t){const e=t.getPropertyValue("content");return t.cssText+" content: "+e+";"}function o(t){return Vl.asArray(t).map(e).join("; ")+";";function e(e){return e+": "+t.getPropertyValue(e)+(t.getPropertyPriority(e)?" !important":"")}}}a.appendChild(c(s,n,i)),e.appendChild(a)}[":before",":after"].forEach(function(t){n(t)})}function r(){t instanceof HTMLTextAreaElement&&e instanceof HTMLTextAreaElement&&(e.textContent=t.value),t instanceof HTMLInputElement&&e instanceof HTMLInputElement&&e.setAttribute("value",t.value)}function s(){e instanceof SVGElement&&(e.setAttribute("xmlns","http://www.w3.org/2000/svg"),e instanceof SVGRectElement&&["width","height"].forEach(function(t){const n=e.getAttribute(t);n&&e.style.setProperty(t,n)}))}}(t,e)}):Promise.resolve(void 0)}const Zl={toSvg:ql,toPng:function(t,e){return Kl(t,e||{}).then(function(t){return t.toDataURL()})},toJpeg:function(t,e){return Kl(t,e=e||{}).then(function(t){return t.toDataURL("image/jpeg",e.quality||1)})},toBlob:function(t,e){return Kl(t,e||{}).then(t=>Vl.canvasToBlob(t))},toPixelData:function(t,e){return Kl(t,e||{}).then(function(e){return e.getContext("2d").getImageData(0,0,Vl.width(t),Vl.height(t)).data})},impl:{fontFaces:$l,images:Wl,util:Vl,inliner:Ul,options:{}}};function Jl(t,e,n,i){const r=this.model_layer,s=r._overlay;return new Promise(function(o,a){if(r){const a=r.get("width"),c=r.get("height");n=n||a,i=i||c;const l=r.get("translate"),h=r.get("scale"),d=Math.min(n/a,i/c);n=a*d,i=c*d,r.set("translate",{x:0,y:0}),r.set("scale",{x:d/wr,y:d/wr});let u=Ga.createCanvas(n,i);const p=u.getContext("2d");if(r.draw(p),r.set("translate",l),r.set("scale",h),!s)return o(u.toDataURL(t,e)),void(u=null);Zl.toPng(s,{sx:d,sy:d,width:n,height:i}).then(function(r){const s=new Image;s.onload=function(){p.drawImage(s,0,0,n,i),o(u.toDataURL(t,e)),u=null},s.src=r},function(n){ji(n),o(u.toDataURL(t,e)),u=null})}else a("No target model")})}function th(){if(!this.hasSameParentForAllSelected)return;const t=this.selected.filter(t=>!!t.parent&&!t.stuck);if(t.length<2)return;const e=t[0].parent,n=[],i=t.sort((t,n)=>e.components.indexOf(t)-e.components.indexOf(n));i.forEach(t=>{n.push(t.bounds)});const r=Ga.union(n);let s=t[0].fromParent(r.left,r.top);s=t[0].toScene(s.x,s.y);const o=new Map,a=Lc({type:"group",left:s.x,top:s.y,width:r.width,height:r.height},e.app,t=>{const e=this.getNewRefid();return void 0!==t&&o.set(t,e),e});a.replaceRefids(o);const c=[{component:a,to_container:e}];i.forEach(t=>{c.push({component:t,to_container:a})}),this.app.commander.execute(new Oc({changes:c})),this.selected=[a]}function eh(){if(0===this.selected.length)return;const t=[],e=[];this.selected.forEach(n=>{if(!n.isGroup())return;const i=n.parent;n.components.forEach(n=>{t.push(n),e.push({component:n,to_container:i})}),e.push({component:n,to_container:null})}),this.app.commander.execute(new Oc({changes:e})),this.selected=t}function nh(){const t=this.selected;if(0===t.length)return;const e=t.map(t=>t.bounds),n=Ga.union(e),i=n.left+n.width/2;t.map(t=>{t.symmetryX(i)})}function ih(){const t=this.selected;if(0===t.length)return;const e=t.map(t=>t.bounds),n=Ga.union(e),i=n.top+n.height/2;t.map(t=>{t.symmetryY(i)})}function rh(){Mc.around(this.app.commander,nh,this)}function sh(){Mc.around(this.app.commander,ih,this)}function oh(t,e,n){const i=this.findAll(t,n);return i.forEach(t=>{t.set(e)}),i}function ah(t){Mc.around(this.app.commander,t)}function ch(){return Object.values(this.indexMap).map(t=>t.map(t=>{const{id:e,data:n}=t.model;return{key:e,value:n}})).flat().sort((t,e)=>t.key>e.key?1:-1)}const lh="left",hh="right",dh="center",uh="bottom",ph="middle",fh=[lh,hh,dh,"top",ph,uh];function gh(t){if(!this.hasSameParentForAllSelected||-1===fh.indexOf(t))return;const e=this.selected.filter(t=>!t.stuck);if(0===e.length)return;const n=this.app.commander;Mc.around(n,function(){!function(t,e){const n=e[0].parent,{width:i,height:r}=n.bounds;switch(t){case lh:for(let t=0;t<e.length;t++){const n=e[t].bounds;e[t].bounds={...n,left:0}}break;case dh:for(let t=0;t<e.length;t++){const n=e[t].bounds;e[t].bounds={...n,left:i/2-n.width/2}}break;case hh:for(let t=0;t<e.length;t++){const n=e[t].bounds;e[t].bounds={...n,left:i-n.width}}break;case"top":for(let t=0;t<e.length;t++){const n=e[t].bounds;e[t].bounds={...n,top:0}}break;case ph:for(let t=0;t<e.length;t++){const n=e[t].bounds;e[t].bounds={...n,top:r/2-n.height/2}}break;case uh:for(let t=0;t<e.length;t++){const n=e[t].bounds;e[t].bounds={...n,top:r-n.height}}break;default:;}}(t,e)})}function mh(t){t instanceof Array||(t=[t]),this.trigger("addstart",t)}function yh(){this.trigger("stylepastestart")}function bh(){this.trigger("stylepastestop")}function _h(){this.trigger("databindpastestart")}function vh(){this.trigger("databindpastestop")}const xh={default:{metalness:0,roughness:.4},metal:{metalness:1,roughness:.3,envMapIntensity:1},glass:{metalness:0,roughness:.1,opacity:.3,envMapIntensity:1.5},plastic:{metalness:0,roughness:.4},wood:{metalness:0,roughness:.8,envMapIntensity:.3},ceramic:{metalness:.1,roughness:.2,envMapIntensity:.3},rubber:{metalness:0,roughness:.9,envMapIntensity:.3}};function wh(t){if(!t)return{metalness:0,roughness:.4,emissive:"#000000",emissiveIntensity:0,opacity:1,envMapIntensity:.5,side:"double",castShadow:!0,receiveShadow:!1};const e=xh[t.preset??"default"]??xh.default;return{metalness:t.metalness??e.metalness,roughness:t.roughness??e.roughness,emissive:t.emissive??"#000000",emissiveIntensity:t.emissiveIntensity??0,opacity:t.opacity??e.opacity??1,envMapIntensity:t.envMapIntensity??e.envMapIntensity??.5,side:t.side??"double",castShadow:t.castShadow??!0,receiveShadow:t.receiveShadow??!1}}const Mh={double:w.DoubleSide,front:w.FrontSide,back:w.BackSide};function Sh(t){return Mh[t]??w.DoubleSide}function Ah(t,e){t.metalness=e.metalness,t.roughness=e.roughness,t.emissive.set(e.emissive),t.emissiveIntensity=e.emissiveIntensity,t.opacity=e.opacity,t.transparent=e.opacity<1,t.envMapIntensity=e.envMapIntensity,t.side=Sh(e.side)}const Eh=new class{constructor(){this._scenes=[],this.onSceneChange=null,this._watchedComponent=null,this._watchedHandler=null,this.onWatchedComponentChange=null}setWatchedComponent(t,e=0){if(this._clearWatched(),null==t)return!0;const n=this._getScene(e);if(!n)return!1;const i=n.rootContainer;if(!i)return!1;const r="root"===t||"__root__"===t?i.model_layer:this._findComponent(i,t);if(!r||"function"!=typeof r.on)return!1;const s=(e,n)=>{this.onWatchedComponentChange?.(t,e,n)};return r.on("change",s),this._watchedComponent=r,this._watchedHandler=s,!0}_clearWatched(){this._watchedComponent&&this._watchedHandler&&"function"==typeof this._watchedComponent.off&&this._watchedComponent.off("change",this._watchedHandler),this._watchedComponent=null,this._watchedHandler=null}register(t){this._cleanup(),this._scenes.push(new WeakRef(t)),this.onSceneChange?.(this._scenes.length)}unregister(t){this._clearWatched(),this._scenes=this._scenes.filter(e=>{const n=e.deref();return n&&n!==t}),this.onSceneChange?.(this._scenes.length)}getScenes(){return this._cleanup(),this._scenes.map((t,e)=>{const n=t.deref();if(!n)return null;const i=n.root,r=i?.model||{};return{index:e,model:{width:r.width||0,height:r.height||0,type:r.type||"unknown"}}}).filter(Boolean)}getComponentTree(t=0){const e=this._getScene(t);if(!e)return[];const n=e.rootContainer;if(!n)return[];const i=n.model_layer;return i?this._childrenOf(i):[]}getChildTree(t,e=0){const n=this._getScene(e);if(!n)return[];const i=n.rootContainer;if(!i)return[];let r;return r="root"===t||"__root__"===t?i.model_layer:this._findComponent(i,t),r?this._childrenOf(r):[]}getComponentInfo(t,e=0){const n=this._getScene(e);if(!n)return null;const i=n.rootContainer;if(!i)return null;let r;if(r="root"===t||"__root__"===t?i.model_layer:this._findComponent(i,t),!r)return null;const s=this._safeBounds(r),o={model:this._safeClone(r.model),state:this._safeClone(r.state),nature:r.nature||{},data:this._safeValue(r.data),value:this._safeValue(r.value),bounds:s,type:r.model?.type||"unknown",isContainer:!!r.isContainer?.(),hidden:!!r.model?.hidden};return"model-layer"===r.model?.type&&(o.is3dMode=!!r.model?.threed),o}selectComponent(t,e=0){const n=this._getScene(e);if(!n)return!1;const i=n.rootContainer;if(!i)return!1;if(!t||"root"===t||"__root__"===t)return i.selected=[],!0;const r=this._findComponent(i,t);return!!r&&(i.selected=[r],!0)}setComponentProperty(t,e,n,i=0){const r=this._getScene(i);if(!r)return!1;const s=r.rootContainer;if(!s)return!1;let o;if(o="root"===t||"__root__"===t?s.model_layer:this._findComponent(s,t),!o)return!1;try{return o.set(e,n),!0}catch{return!1}}setCameraView(t,e=0){const n=this._getScene(e);if(!n)return!1;const i=n.rootContainer;if(!i)return!1;const r=i.model_layer;if(!r||!r._threeCapability)return!1;try{return r._threeCapability.setCameraView(t),!0}catch{return!1}}getCameraState(t=0){const e=this._getScene(t);if(!e)return null;const n=e.rootContainer;if(!n)return null;const i=n.model_layer;if(!i||!i._threeCapability)return null;try{return i._threeCapability.getCameraState()}catch{return null}}toggleHidden(t,e=0){const n=this._getScene(e);if(!n)return!1;const i=n.rootContainer;if(!i)return!1;const r=this._findComponent(i,t);if(!r)return!1;try{return r.set("hidden",!r.model?.hidden),!r.model?.hidden}catch{return!1}}evaluateData(t,e=0){const n=this._getScene(e);if(!n)return;const i=n.rootContainer;if(!i)return;const r="root"===t||"__root__"===t?i.model_layer:this._findComponent(i,t);return r?this._safeValue(r.data):void 0}evaluateValue(t,e=0){const n=this._getScene(e);if(!n)return;const i=n.rootContainer;if(!i)return;const r="root"===t||"__root__"===t?i.model_layer:this._findComponent(i,t);return r?this._safeValue(r.value):void 0}searchComponents(t,e=0){const n=this._getScene(e);if(!n)return[];const i=n.rootContainer;if(!i)return[];const r=i.model_layer;if(!r)return[];const s=[],o=t.toLowerCase();return this._traverseComponent(r,t=>{const e=t.state||t.model||{};[e.type||"",e.name||"",e.id||"",e.tag||"",e.class||"",String(e.refid||"")].join(" ").toLowerCase().includes(o)&&s.push(this._toTreeNode(t))}),s}getComponentPath(t,e=0){const n=this._getScene(e);if(!n)return[];const i=n.rootContainer;if(!i)return[];const r=i.model_layer;if(!r)return[];const s=[];return this._findPath(r,t,s)?s:[]}getThreedInfo(t,e=0){const n=this._getScene(e);if(!n)return null;const i=n.rootContainer;if(!i)return null;let r;if(r="root"===t||"__root__"===t?i.model_layer:this._findComponent(i,t),!r)return null;const s=r.model||{},o=s.type||"unknown",a=s.material3d,c={is3dish:"function"==typeof r.is3dish&&r.is3dish(),type:o};if(a&&(c.material3d=this._safeClone(a)),c.resolved=wh(a),"gltf-object"===o)try{c.nodeNames=r.nodeNames??[],c.animationNames=r.animationNames??[],c.nodes=this._safeClone(r.nodes),c.animations=this._safeClone(r.animations),c.fillStyleTargets=r.fillStyleTargets}catch{}return c}_getScene(t){this._cleanup();const e=this._scenes[t];return e?.deref()??null}_cleanup(){this._scenes=this._scenes.filter(t=>void 0!==t.deref())}_findComponent(t,e){const n=Number(e);if(!isNaN(n)){const e=t.findByRefid(n);if(e)return e}const i=t.findById(e);return i||null}_childrenOf(t){const e=t.components;return e?e.map(t=>this._toTreeNode(t)):[]}_toTreeNode(t){const e=t.components,n=!!e&&e.length>0,i=t.state||t.model||{};return{id:String(i.refid??i.id??""),type:i.type||"unknown",model_id:i.id,hasChildren:n,childCount:n?e.length:0,refid:i.refid,tag:i.tag,name:i.name,hidden:!!i.hidden,clazz:i.class}}_componentId(t){const e=t.state||t.model||{};return String(e.refid??e.id??"")}_findPath(t,e,n){const i=this._componentId(t);if(i===e)return!0;const r=t.components;if(!r)return!1;for(const s of r)if(this._findPath(s,e,n))return n.unshift("model-layer"===t.model?.type?"__root__":i),!0;return!1}_traverseComponent(t,e){e(t);const n=t.components;if(n)for(const t of n)this._traverseComponent(t,e)}_safeBounds(t){try{const e=t.bounds;return e?{left:e.left??0,top:e.top??0,width:e.width??0,height:e.height??0}:null}catch{return null}}_safeClone(t){if(!t||"object"!=typeof t)return t??{};try{return JSON.parse(JSON.stringify(t))}catch{const e={};for(const n of Object.keys(t))try{const i=t[n];if("function"==typeof i)continue;e[n]="object"==typeof i?String(i):i}catch{e[n]="[error]"}return e}}_safeValue(t){if(null==t)return t;try{return JSON.parse(JSON.stringify(t))}catch{return String(t)}}},kh={fetch:"Fetching model...",parse:"Parsing model...",init:"Initializing...",compile:"Building components...",assets:"Loading assets...",data:"Waiting for data...",render:"Rendering..."},Ch={stable:"─",increasing:"▲",decreasing:"▼",spike:"⚡"},Th={normal:"rgba(100,200,100,0.9)",warn:"rgba(255,180,50,0.9)",critical:"rgba(255,80,80,0.9)"};class Ph{constructor(){this._visible=!1,this._manualOpen=!1,this._phaseRenderedCount=0}attach(t,e,n){this._targetElement=t,this._tracker=e,this._lagTracker=n,this._phaseRenderedCount=0,this._visible=!1,this._phaseListEl&&(this._phaseListEl.innerHTML=""),this._pendingListEl&&(this._pendingListEl.innerHTML=""),e&&(e.needsOverlay&&this._show(),e.onNeedsOverlay=()=>{this._visible||this._manualOpen||this._show()},e.onComplete=()=>{this._visible&&(this._update(),this._manualOpen||setTimeout(()=>{this._manualOpen||this._hide()},5e3))})}toggle(){this._visible?(this._hide(),this._manualOpen=!1):(this._manualOpen=!0,this._show())}show(){this._manualOpen=!0,this._show()}hide(){this._manualOpen=!1,this._hide()}destroy(){this._hide(),this._container?.parentElement&&this._container.parentElement.removeChild(this._container),this._container=void 0,this._targetElement=void 0,this._tracker=void 0,this._lagTracker=void 0,this._phaseListEl=void 0}get isVisible(){return this._visible}get isAttached(){return!!this._targetElement}_show(){this._targetElement&&(this._container||this._buildDOM(),this._container&&!this._container.parentElement&&this._targetElement.appendChild(this._container),this._container.style.display="flex",this._visible=!0,this._update(),this._updateTimer||(this._updateTimer=setInterval(()=>this._update(),500)),"complete"!==this._tracker?.phase||this._manualOpen||setTimeout(()=>{this._manualOpen||this._hide()},5e3))}_hide(){this._container&&(this._container.style.display="none"),this._visible=!1,this._updateTimer&&(clearInterval(this._updateTimer),this._updateTimer=void 0)}_update(){if(!this._visible||!this._tracker)return;const t=this._tracker,e=t.stats,n=t.phase,i="complete"===n;this._headerEl&&(this._headerEl.textContent=i?`Scene Monitor — ${(e.elapsed/1e3).toFixed(1)}s`:`Scene Monitor — ${kh[n]||n}`),this._updateProgress(t,i),this._updatePhaseList(t),this._updateAssetList(t,e,i),this._updateLagDisplay(),this._elapsedEl&&(this._elapsedEl.textContent=`${(e.elapsed/1e3).toFixed(1)}s`)}_updateProgress(t,e){if(!this._progressFillEl&&!this._progressTextEl)return;const n=t.phaseHistory,i=n.length,r=n.filter(t=>void 0!==t.duration).length,s=i>0?Math.round(r/i*100):e?100:0;this._progressFillEl&&(this._progressFillEl.style.width=s+"%"),this._progressTextEl&&(this._progressTextEl.textContent=`${r} / ${i}`)}_updatePhaseList(t){if(!this._phaseListEl)return;const e=t.phaseHistory;for(let t=this._phaseRenderedCount;t<e.length;t++){const n=e[t];if("complete"===n.phase)continue;const i=150*(t-this._phaseRenderedCount),r=document.createElement("div");r.dataset.phase=n.phase,r.style.cssText="display:flex;gap:8px;align-items:center;padding:1px 0;font-size:11px;opacity:0;transition:opacity 0.3s ease",r.innerHTML='<span data-field="icon" style="flex-shrink:0"></span><span data-field="label" style="flex:1"></span><span data-field="time" style="width:60px;text-align:right"></span>',this._phaseListEl.appendChild(r),setTimeout(()=>{r.style.opacity="1"},i+16)}this._phaseRenderedCount=e.length;const n=performance.now();for(const t of Array.from(this._phaseListEl.querySelectorAll("[data-phase]"))){const i=t,r=e.find(t=>t.phase===i.dataset.phase);if(!r)continue;const s=kh[r.phase]||r.phase,o=i.querySelector('[data-field="icon"]'),a=i.querySelector('[data-field="label"]'),c=i.querySelector('[data-field="time"]');void 0===r.duration?(o.textContent="⏳",o.style.color="rgba(255,200,50,0.8)",a.textContent=s,a.style.color="rgba(255,255,255,0.9)",c.textContent=`${((n-r.timestamp)/1e3).toFixed(1)}s`,c.style.color="rgba(255,200,50,0.8)"):(o.textContent="✓",o.style.color="rgba(100,200,100,0.8)",a.textContent=s,a.style.color="rgba(255,255,255,0.5)",c.textContent=`${(r.duration/1e3).toFixed(1)}s`,c.style.color="rgba(255,255,255,0.4)")}}_updateAssetList(t,e,n){if(this._pendingListEl)if(n&&"complete"!==this._pendingListEl.dataset.mode)this._pendingListEl.innerHTML="",this._pendingListEl.dataset.mode="complete",this._renderHistorySummary(e);else if(!n){this._pendingListEl.dataset.mode="pending";const e=t.pending.sort((t,e)=>e.elapsed-t.elapsed),n=e.slice(0,5);for(let t=0;t<n.length;t++)t<this._pendingListEl.children.length?this._updatePendingRow(this._pendingListEl.children[t],n[t]):this._pendingListEl.appendChild(this._createPendingRow(n[t]));const i=n.length+(e.length>5?1:0);for(;this._pendingListEl.children.length>i;)this._pendingListEl.lastChild?.remove();if(e.length>5){const t=this._pendingListEl.lastElementChild;if(t?.dataset?.more)t.textContent=`... ${e.length-5} more`;else{const t=document.createElement("div");t.dataset.more="1",t.style.cssText="color:rgba(255,255,255,0.4);font-size:11px;padding:2px 0",t.textContent=`... ${e.length-5} more`,this._pendingListEl.appendChild(t)}}}}_updateLagDisplay(){if(!this._lagSectionEl||!this._lagTracker)return;this._lagTracker.evaluateAll();const t=this._lagTracker.getAllStats();0!==t.length&&(this._lagSectionEl.dataset.built?this._updateLagSection(t):(this._lagSectionEl.innerHTML="",this._renderLagSection(t),this._lagSectionEl.dataset.built="1"))}_renderHistorySummary(t){if(!this._pendingListEl)return;const e=document.createElement("div");e.style.cssText="color:rgba(255,255,255,0.7);padding:2px 0;font-size:12px",e.textContent=`Total: ${t.total} assets | Loaded: ${t.loaded} | Timeout: ${t.timeout} | Error: ${t.error}`,this._pendingListEl.appendChild(e);const n=this._tracker.entries.filter(t=>"pending"!==t.status).sort((t,e)=>e.elapsed-t.elapsed).slice(0,5);for(const t of n){const e=document.createElement("div");e.style.cssText="display:flex;gap:8px;align-items:center;padding:1px 0;font-size:11px";const n="loaded"===t.status?"✓":"timeout"===t.status?"⚠":"✗",i="loaded"===t.status?"rgba(100,200,100,0.8)":"timeout"===t.status?"rgba(255,180,50,0.8)":"rgba(255,80,80,0.8)";e.innerHTML=`<span style="color:${i}">${n}</span><span style="color:rgba(74,158,255,0.8);width:50px">${t.type}</span><span style="color:rgba(255,255,255,0.6);flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap">${this._shortUrl(t.url)}</span><span style="color:rgba(255,255,255,0.5);width:50px;text-align:right">${(t.elapsed/1e3).toFixed(1)}s</span>`,this._pendingListEl.appendChild(e)}}_renderLagSection(t){if(!this._lagSectionEl)return;const e=document.createElement("div");e.style.cssText="color:rgba(255,255,255,0.5);font-size:11px;padding:4px 0 2px;border-top:1px solid rgba(255,255,255,0.08);margin-top:4px",e.textContent="Data Lag",this._lagSectionEl.appendChild(e);for(const e of t){const t=document.createElement("div");t.dataset.tag=e.tag,t.style.cssText="display:flex;gap:8px;align-items:center;padding:1px 0;font-size:11px";const n=Th[e.level],i=Ch[e.trend];t.innerHTML=`<span style="color:rgba(255,255,255,0.7);flex:1">${e.tag}</span><span data-field="drift" style="color:rgba(255,255,255,0.6)">drift: ${e.drift>=0?"+":""}${(e.drift/1e3).toFixed(1)}s</span><span style="color:rgba(255,255,255,0.4)">base: ${(e.baseline/1e3).toFixed(1)}s</span><span data-field="trend" style="color:${n}">${i}</span>`,this._lagSectionEl.appendChild(t)}}_createPendingRow(t){const e=document.createElement("div");return e.style.cssText="display:flex;gap:8px;align-items:center;padding:1px 0;font-size:11px",e.dataset.id=t.id,e.innerHTML=`<span style="color:rgba(255,200,50,0.7)">⏳</span><span style="color:rgba(74,158,255,0.8);width:50px">${t.type}</span><span data-field="url" style="color:rgba(255,255,255,0.6);flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap">${this._shortUrl(t.url)}</span><span data-field="time" style="color:rgba(255,255,255,0.5);width:50px;text-align:right">${(t.elapsed/1e3).toFixed(1)}s</span>`,e}_updatePendingRow(t,e){const n=t.querySelector('[data-field="url"]'),i=t.querySelector('[data-field="time"]');n&&(n.textContent=this._shortUrl(e.url)),i&&(i.textContent=`${(e.elapsed/1e3).toFixed(1)}s`)}_updateLagSection(t){if(!this._lagSectionEl)return;const e=this._lagSectionEl.querySelectorAll("[data-tag]");for(const n of t){const t=Array.from(e).find(t=>t.dataset.tag===n.tag);if(t){const e=t.querySelector('[data-field="drift"]'),i=t.querySelector('[data-field="trend"]');e&&(e.textContent=`drift: ${n.drift>=0?"+":""}${(n.drift/1e3).toFixed(1)}s`),i&&(i.textContent=Ch[n.trend],i.style.color=Th[n.level])}}}_shortUrl(t){if(!t)return"";const e=t.split("/");return e[e.length-1]||t}_buildDOM(){const t=document.createElement("div");t.setAttribute("scene","loading-overlay"),t.style.cssText=["position:absolute","top:50%","left:50%","transform:translate(-50%,-50%)","display:flex","flex-direction:column","background:rgba(30,30,30,0.94)","border:1px solid rgba(255,255,255,0.12)","border-radius:8px","backdrop-filter:blur(12px)","pointer-events:auto","user-select:none","z-index:9999",'font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif',"font-size:13px","color:rgba(255,255,255,0.9)","box-shadow:0 4px 16px rgba(0,0,0,0.3)","min-width:320px","max-width:450px","padding:12px 16px","gap:8px"].join(";");const e=document.createElement("div");e.style.cssText="display:flex;align-items:center;justify-content:space-between";const n=document.createElement("span");n.style.cssText="font-weight:600;font-size:13px",n.textContent="Loading...",this._headerEl=n,e.appendChild(n);const i=document.createElement("button");i.textContent="✕",i.title="Close",i.style.cssText="background:none;border:none;color:rgba(255,255,255,0.6);cursor:pointer;font-size:14px;padding:2px 4px;border-radius:3px;line-height:1",i.addEventListener("mouseenter",()=>{i.style.color="rgba(255,255,255,0.9)"}),i.addEventListener("mouseleave",()=>{i.style.color="rgba(255,255,255,0.6)"}),i.addEventListener("click",()=>this.hide()),e.appendChild(i),t.appendChild(e);const r=document.createElement("div");r.style.cssText="display:flex;align-items:center;gap:8px";const s=document.createElement("div");s.style.cssText="flex:1;height:4px;background:rgba(255,255,255,0.1);border-radius:2px;overflow:hidden";const o=document.createElement("div");o.style.cssText="height:100%;width:0%;background:rgba(74,158,255,0.8);border-radius:2px;transition:width 0.3s ease",this._progressFillEl=o,s.appendChild(o),r.appendChild(s);const a=document.createElement("span");a.style.cssText="font-size:11px;color:rgba(255,255,255,0.5);white-space:nowrap;min-width:80px;text-align:right",this._progressTextEl=a,r.appendChild(a),t.appendChild(r);const c=document.createElement("div");c.style.cssText="border-top:1px solid rgba(255,255,255,0.08);padding-top:4px",this._phaseListEl=c,t.appendChild(c);const l=document.createElement("div");l.style.cssText="max-height:120px;overflow-y:auto",this._pendingListEl=l,t.appendChild(l);const h=document.createElement("div");this._lagSectionEl=h,t.appendChild(h);const d=document.createElement("div");d.style.cssText="display:flex;align-items:center;border-top:1px solid rgba(255,255,255,0.08);padding-top:8px";const u=document.createElement("span");u.style.cssText="font-size:11px;color:rgba(255,255,255,0.4)",this._elapsedEl=u,d.appendChild(u),t.appendChild(d),t.addEventListener("keydown",t=>t.stopPropagation()),this._container=t}}const Dh=.001;function Oh(t,e,n){let r=1;if(n&&"none"!=n&&"transparent"!=n){r=e*("string"==typeof n?i(n).getAlpha():1)}else r=0;t.opacity=r,t.transparent=r<1}function zh(t){const e=i(t);return e.isValid()?e.toHexString():t}const Lh={width:1,height:1,depth:1},Ih={x:1,y:1,z:1},Rh={x:0,y:0,z:0},jh={x:0,y:0,z:0},Fh=["map","normalMap","roughnessMap","metalnessMap","aoMap","emissiveMap","bumpMap","displacementMap","alphaMap","envMap","lightMap"];function Bh(t){for(const e of Fh){const n=t[e];n?.dispose()}t.dispose()}function Nh(t){t.traverse(t=>{const e=t.userData?.dispose;if("function"==typeof e)try{e()}catch{}if(t.geometry?.dispose(),t.material){const e=Array.isArray(t.material)?t.material:[t.material];for(const t of e)Bh(t)}})}function Hh(t,e,n){const i=document.createElement("canvas");i.width=e,i.height=n;const r=i.getContext("2d");if(!r)return null;let s;if("radial"===t.gradientType){const i=e/2,o=n/2,a=Math.max(e,n)/2;switch(t.center){case"left-top":s=r.createRadialGradient(0,0,0,0,0,2*a);break;case"right-top":s=r.createRadialGradient(e,0,0,e,0,2*a);break;case"left-bottom":s=r.createRadialGradient(0,n,0,0,n,2*a);break;case"right-bottom":s=r.createRadialGradient(e,n,0,e,n,2*a);break;default:s=r.createRadialGradient(i,o,0,i,o,a)}}else{const i=t.rotation??0,o=e/2,a=n/2,c=Math.cos(i)*o,l=Math.sin(i)*a;s=r.createLinearGradient(o-c,a-l,o+c,a+l)}const o=Array.isArray(t.colorStops)?t.colorStops:Array.isArray(t.gradientStops)?t.gradientStops:[];for(const t of o)if(t.position>=0&&t.position<=1)try{s.addColorStop(t.position,t.color)}catch{s.addColorStop(t.position,"#fff")}return r.fillStyle=s,r.fillRect(0,0,e,n),i}function Yh(t,e){const n=void 0!==e?e:t.state.fillStyle;if(!n||"object"!=typeof n)return;const i=n;if("pattern"===i.type&&i.image)return function(t,e){const{width:n,height:i}=t.state,r=Math.abs(n)||1,s=Math.abs(i)||1,o=new w.Texture;o.colorSpace=w.SRGBColorSpace;const a=new Image;"data"!==String(e.image).substring(0,4)&&(a.crossOrigin="anonymous"),a.onload=()=>{const n=2*r,i=2*s,c=document.createElement("canvas");c.width=n,c.height=i;const l=c.getContext("2d");if(l){if(e.color&&(l.fillStyle=e.color,l.fillRect(0,0,n,i)),e.fitPattern)l.drawImage(a,0,0,n,i);else{const t=2*(e.width||a.naturalWidth),r=2*(e.height||a.naturalHeight),s=2*(e.offsetX||0),o=2*(e.offsetY||0);let c=0,h=0;switch(e.align){case"center":c=(n-t)/2,h=(i-r)/2;break;case"left-top":break;case"left-bottom":h=i-r;break;case"right-top":c=n-t;break;case"right-bottom":c=n-t,h=i-r;break;case"left":h=(i-r)/2;break;case"right":c=n-t,h=(i-r)/2;break;case"top":c=(n-t)/2;break;case"bottom":c=(n-t)/2,h=i-r}const d=s+c,u=o+h;if(e.noRepeat)l.drawImage(a,0,0,a.naturalWidth,a.naturalHeight,d,u,t,r);else{l.save(),l.rect(0,0,n,i),l.clip();const e=d>0?d-Math.ceil(d/t)*t:d;for(let s=u>0?u-Math.ceil(u/r)*r:u;s<i;s+=r)for(let i=e;i<n;i+=t)l.drawImage(a,0,0,a.naturalWidth,a.naturalHeight,i,s,t,r);l.restore()}}o.image=c,o.minFilter=w.LinearFilter,o.needsUpdate=!0,t.invalidate()}},a.onerror=t=>{ji("Pattern texture load error:",t)};const c=e.image;a.src=t.app.url(c);const l=t.root?.app?.loadTracker;if(l){const t=new Promise((t,e)=>{a.addEventListener("load",()=>t(),{once:!0}),a.addEventListener("error",()=>e(),{once:!0})});l.track(`pattern:${c}`,"pattern",c,t)}return o}(t,i);if("gradient"===i.type){if(Array.isArray(i.colorStops)&&i.colorStops.length>0||Array.isArray(i.gradientStops)&&i.gradientStops.length>0)return function(t){const e=Hh(t,256,256);if(!e)return;const n=new w.CanvasTexture(e);return n.colorSpace=w.SRGBColorSpace,n.needsUpdate=!0,n}(i)}}function Gh(t,e){return-1!==t.findIndex(t=>t in e)}const Vh=()=>{};class Uh{static buildFillStyleTexture(t,e){return Yh(t,e)}constructor(t){this._focused=!1,this._suppressOnchange=!1,this._onchangeWrapper=(t,e,n)=>{this._suppressOnchange||n&&n.origin&&n.origin!==this._component||this.onchange(t,e)},this.suppressTransform=!1,this._component=t,this.object3d=this.getObject3dInstance(),this.component.on("change",this._onchangeWrapper)}update(){this.clear(),this.build(),this.updateTransform(),this.updateFillStyle(),this.updateStrokeStyle(),this.updateAlpha(),this.updateHidden(),this.updateText(),this._applyRaycastTarget()}getObject3dInstance(){return new w.Object3D}build(){this.object3d.userData.context=this;const t=wh(this.component.state.material3d);this._applyShadow(t.castShadow,t.receiveShadow),this.object3d.name=this.component.state.id}updateMaterial3d(){const t=wh(this.component.state.material3d);this._applyShadow(t.castShadow,t.receiveShadow)}_applyShadow(t,e){this.object3d.castShadow=t,this.object3d.receiveShadow=e,this.object3d.traverse(n=>{n!==this.object3d&&(n.castShadow=t,n.receiveShadow=e)})}get gizmoTransformable(){return!0}get allowedGizmoModes(){return null}get component(){return this._component}get threeContainer(){let t=this.component;for(;t;){if("is3dContainer"in t&&t.is3dContainer())return t;t=t.parent}}get focused(){return this._focused}set focused(t){this._focused=t,t&&(this._focusedAt=performance.now())}dispose(){this.component.off("change",this._onchangeWrapper),this.clear()}clear(){const t=[];for(const e of this.object3d.children){const n=e.userData?.context;n&&n!==this&&n instanceof Uh?t.push(e):Nh(e)}this._components3D=void 0,this.object3d.userData={},this.object3d.clear();for(const e of t)this.object3d.add(e);return this.object3d}updateTransform(){if(this.suppressTransform)return;if(this.component.state.screenFixed&&this.component.isHTMLElement()){const{x:t=0,y:e=0}=this.component.center,{width:n=0,height:i=0}=this.component.parent?.bounds??{};return this.object3d.position.set(t-n/2,-(e-i/2),0),void this.object3d.rotation.set(0,0,0)}const{x:t,y:e,z:n}=this.position,{x:i,y:r,z:s}=this.rotation,{x:o,y:a,z:c}=this.scale;this.object3d.position.set(t,e,n),this.object3d.rotation.set(i,r,s),this.object3d.scale.set(Math.max(o,Dh),Math.max(a,Dh),Math.max(c,Dh))}get position(){const{x:t,y:e,z:n}=this.center;return{x:t,y:n,z:e}}get rotation(){const{rotationX:t=0,rotationY:e=0,rotation:n=0}=this.component.state;return{x:t,y:-n,z:e}}get scale(){const{scale:t}=this.component.state,e="number"==typeof t?t:t?.x??1;return{x:e,y:e,z:e}}get cx(){const{x:t=0}=this.component.center,{width:e=0}=this.component.parent?.bounds??{},{tx:n=0}=this.component.delta();return t+n-e/2}get cy(){const{y:t=0}=this.component.center,{height:e=0}=this.component.parent?.bounds??{},{ty:n=0}=this.component.delta();return t+n-e/2}get cz(){const t=this.effectiveZPos,{tz:e=0}=this.component.delta(),n=this.component.parent?._realObject,i=n?.geometricOffsetY??0;return t+e+this.syncZPosOffset-i}get effectiveZPos(){const t=this.component.state.zPos;if("number"==typeof t&&Number.isFinite(t))return t;const e=this.component.effectiveZPos;return"number"==typeof e&&Number.isFinite(e)?e:0}get geometricOffsetY(){const t=this.effectiveDepth/2;switch(this.scenePlacement){case"space":return 0;case"inverted":return-t;default:return t}}get scenePlacement(){const t=this.component.rootModel??this.component,e=t?.state?.placement;return"space"===e||"inverted"===e?e:"floor"}get components3D(){return this._components3D&&this._components3D.parent===this.object3d||(this._components3D=new w.Group,this.object3d.add(this._components3D)),this._components3D.position.y=-this.geometricOffsetY,this._components3D}get center(){const{x:t=0,y:e=0}=this.component.center,{width:n=0,height:i=0}=this.component.parent?.bounds??{},{tx:r=0,ty:s=0}=this.component.delta();return{x:t+r-n/2,y:e+s-i/2,z:this.cz}}freezeDimension(){this._frozenDimension={...this.dimension}}unfreezeDimension(){delete this._frozenDimension}get dimension(){if(this._frozenDimension)return this._frozenDimension;const{width:t,height:e}=this.component.bounds;return{width:Math.abs(t)||1,height:Math.abs(e)||1,depth:this.effectiveDepth}}get effectiveDepth(){const t=this.component.state.depth;if("number"==typeof t&&Number.isFinite(t)&&t>0)return t;const e=this.component.effectiveDepth;return"number"==typeof e&&Number.isFinite(e)&&e>0?e:1}updatePosition(){const{x:t=0,y:e=0,z:n=0}=this.position;this.object3d.position.set(t,e,n)}updateRotate(){const{x:t=0,y:e=0,z:n=0}=this.rotation;this.object3d.rotation.set(t,e,n)}updateScale(){const{x:t=1,y:e=1,z:n=1}=this.scale;this.object3d.scale.set(Math.max(t,Dh),Math.max(e,Dh),Math.max(n,Dh))}syncAnimationDelta(){if(this.suppressTransform)return;const t=this.component.delta();this.updatePosition();const{rotationX:e=0,rotationY:n=0,rotation:i=0}=this.component.state,r=t.theta||0,s=t.rx||0,o=t.ry||0,a=t.rz||0;this.object3d.rotation.set(e+s,-(i+r)+o,n+a);const{scale:c}=this.component.state,l="number"==typeof c?c:c?.x??1,h=t.sx??1,d=t.sy??1,u=t.sz??1;this.object3d.scale.set(Math.max(l*h,Dh),Math.max(l*d,Dh),Math.max(l*u,Dh));const p=t.fade||0;if(0!==p){const t=(this.component.state.alpha??1)*(1-p);this.object3d.traverse(e=>{if(e.isMesh&&e.material){const n=Array.isArray(e.material)?e.material:[e.material];for(const e of n)e.opacity=t,e.transparent=e.opacity<1}})}}updateDimension(){this.clear(),this.build()}updateAlpha(){let{alpha:t}=this.component.state;t=null==t?1:t,this.object3d.traverse(e=>{let n=e.material;e.material&&(Array.isArray(n)||(n=[n]),n.forEach(e=>{e.opacity*=t,e.transparent=t<1}))})}updateHidden(){this.object3d.visible=!this.component.state.hidden}updateStrokeStyle(){}updateFillStyle(){}updateText(){}_applyRaycastTarget(){const t=this.component.state.raycastTarget;let e;if("boolean"==typeof t)e=t;else{const t=this.component.constructor;e=!1!==t.raycastTargetDefault}const n=t=>{const i=t.userData?.context;if(t===this.object3d||!i||i===this){t.userData?.alwaysRaycast||(e?delete t.raycast:t.raycast=Vh);for(const e of t.children)n(e)}};n(this.object3d)}get syncZPosOffset(){const t=this.effectiveDepth/2;switch(this.scenePlacement){case"space":return 0;case"inverted":return-t;default:return t}}get textSurfaceYOffset(){return this.effectiveDepth-this.syncZPosOffset}syncFromObject3D(){const t=this.object3d,e=this._component,{width:n=0,height:i=0}=e.parent?.bounds??{},r=e.bounds,{tx:s=0,ty:o=0,tz:a=0}=e.delta();this._suppressOnchange=!0,e.bounds={left:t.position.x-s+n/2-r.width/2,top:t.position.z-o+i/2-r.height/2,width:r.width,height:r.height};const c=this.component.parent?._realObject,l=c?.geometricOffsetY??0;e.set({zPos:t.position.y-a-this.syncZPosOffset+l,rotationX:t.rotation.x,rotation:-t.rotation.y,rotationY:t.rotation.z}),this._suppressOnchange=!1}onGizmoDragEnd(t){}applyDimensionFromGizmo(t){this._suppressOnchange=!0,this._component.set(t),this._suppressOnchange=!1}onchange(t,e){if("screenFixed"in t&&this.updateTransform(),Gh(["cx","cy","cz","zPos","left","top"],t)&&this.updatePosition(),Gh(["width","height","depth","lineWidth","round"],t)&&(this.updateDimension(),"depth"in t)){this.updatePosition();const t=this.component.components;if(t)for(const e of t){const t=e?._realObject;t?.updateTransform&&t.updateTransform()}}if(Gh(["rotationX","rotationY","rotation"],t)&&this.updateRotate(),"scale"in t&&this.updateScale(),"hidden"in t&&this.updateHidden(),"alpha"in t&&this.updateAlpha(),"strokeStyle"in t&&this.updateStrokeStyle(),"fillStyle"in t&&this.updateFillStyle(),Gh(["text","fontColor","fontSize","fontFamily","bold","italic","textAlign","textBaseline"],t))this._lastText=this.component.hasTextProperty?this.component.text:"",this.updateText();else if(Gh(["value","data"],t)){const t=this.component.hasTextProperty?this.component.text:"";t!==this._lastText&&(this._lastText=t,this.updateText())}"material3d"in t&&this.updateMaterial3d(),"raycastTarget"in t&&this._applyRaycastTarget()}}class $h extends Uh{constructor(){super(...arguments),this._loadGen=0,this._objectSize=new w.Vector3}get objectSize(){return this._objectSize}build(){super.build();const{src:t}=this.component.state;if(!t)return this.clear(),this._showEmptyPlaceholder(),void(this.object3d.userData.context=this);const e=++this._loadGen,n=this.component.app.url(t),i=this._loadExternal(n).then(t=>{e===this._loadGen&&this._onLoaded(t)},t=>{e===this._loadGen&&(ji(`${this._formatLabel}.load`,t),this.clear(),this._showErrorPlaceholder(),this.component.setState({loadError:String(t)}))});this.component.root?.app?.loadTracker?.track(`${this._formatLabel}:${t}`,this._formatLabel,t,i)}updateSource(){this.build()}get _placeholderColor(){return 6770852}_showEmptyPlaceholder(){const{width:t=100,height:e=100,depth:n=100}=this.component.state,i=t||100,r=e||100,s=n||100,o=this._placeholderColor,a=new w.BoxGeometry(i,s,r),c=new w.MeshStandardMaterial({color:o,transparent:!0,opacity:.15,depthWrite:!1}),l=new w.Mesh(a,c);l.name="__empty_placeholder__";const h=new w.EdgesGeometry(a),d=new w.LineBasicMaterial({color:o,transparent:!0,opacity:.4}),u=new w.LineSegments(h,d);u.name="__empty_placeholder_edge__",l.add(u),this.object3d.add(l)}_showErrorPlaceholder(){const t=new w.BoxGeometry(1,1,1),e=new w.MeshStandardMaterial({color:13369344,wireframe:!0}),n=new w.Mesh(t,e);n.name="__error_placeholder__",this.object3d.add(n)}clear(){return this.pivot&&Nh(this.pivot),this.pivot=void 0,this._objectSize=void 0,super.clear()}}const Wh="KHR_materials_pbrSpecularGlossiness";class Xh{constructor(t){this.name=Wh,this.parser=t}extendMaterialParams(t,e){const i=this.parser.json.materials?.[t],r=i?.extensions?.[Wh];if(!r)return Promise.resolve();const s=[];if(Array.isArray(r.diffuseFactor)){const[t,i,s,o]=r.diffuseFactor;e.color||(e.color=new n.Color),e.color.setRGB(t,i,s,n.LinearSRGBColorSpace),e.opacity=o}null!=r.diffuseTexture&&s.push(this.parser.assignTexture(e,"map",r.diffuseTexture,n.SRGBColorSpace));const o=r.glossinessFactor??1;e.roughness=1-o;const a=r.specularFactor??[1,1,1],c=Math.max(a[0],a[1],a[2]);return e.metalness=c>.5?c:0,Promise.all(s)}}(()=>{const t="__urdfBlobCrossOriginPatched__",e=w.ImageLoader.prototype;if(e[t])return;const n=e.load;e.load=function(t,e,i,r){if("string"==typeof t&&t.startsWith("blob:")){const s=this.crossOrigin;this.crossOrigin=void 0;try{return n.call(this,t,e,i,r)}finally{this.crossOrigin=s}}return n.call(this,t,e,i,r)},e[t]=!0})();const qh={once:w.LoopOnce,repeat:w.LoopRepeat,pingpong:w.LoopPingPong};class Kh extends $h{constructor(){super(...arguments),this._nodeIndex=new Map,this._originals=new Map,this._animationActions=new Map,this._fillStyleOriginals=new Map,this._clonedMaterials=new WeakSet}get _formatLabel(){return"gltf"}static getSharedSnapshotRenderer(){const t=Kh._sharedSnapshotRenderer;if(t){const e=t.getContext();if(e&&!e.isContextLost())return t;try{t.forceContextLoss()}catch{}t.dispose(),Kh._sharedSnapshotRenderer=void 0}try{const t=new w.WebGLRenderer({antialias:!0,alpha:!0}),e=t.getContext();if(!e||e.isContextLost()){try{t.forceContextLoss()}catch{}return void t.dispose()}return Kh._sharedSnapshotRenderer=t,t}catch{return}}static getSharedLoader(t){if(!Kh._sharedLoader){const t=new r.GLTFLoader;!function(t){t.register(t=>new Xh(t))}(t);const e=new s.DRACOLoader;e.setDecoderPath("/node_modules/three/examples/jsm/libs/draco/"),t.setDRACOLoader(e);const n=new o.KTX2Loader;n.setTranscoderPath("/node_modules/three/examples/jsm/libs/basis/"),t.setKTX2Loader(n),t.setMeshoptDecoder(a.MeshoptDecoder),t.setCrossOrigin("anonymous"),Kh._sharedLoader=t}return t&&Kh._sharedLoader.ktx2Loader?.detectSupport(t),Kh._sharedLoader}static loadGLTF(t,e){let n=Kh._gltfCache.get(t);if(!n){const i=Kh.getSharedLoader(e);n=new Promise((e,n)=>{i.load(t,e,void 0,n)}).catch(e=>{throw Kh._gltfCache.delete(t),e}),Kh._gltfCache.set(t,n)}return n}_ensureOwnMaterial(t){let e=t.material;return this._clonedMaterials.has(e)||(e=e.clone(),t.material=e,this._clonedMaterials.add(e)),e}_loadExternal(t){return Kh.loadGLTF(t,this.threeContainer?.renderer3d)}_onLoaded(t){this.component.state.loadError&&this.component.setState({loadError:void 0});const e=t.scene,n=t.animations,i=c.clone(e);i.userData.context=this,i.traverse(t=>{t.isMesh&&(t.castShadow=!0)});const r=(new w.Box3).setFromObject(i),s=r.getCenter(i.position),o=r.getSize(new w.Vector3);if(s.multiplyScalar(-1),this.clear(),this.object3d.userData.context=this,this._objectSize=o,this.pivot=new w.Object3D,this.component.state.floorAlign?this.components3D.add(this.pivot):this.object3d.add(this.pivot),this.pivot.add(i),this._buildNodeIndex(i),this.component.state.autoFit&&o.x>0&&o.y>0&&o.z>0){const t=(Number(this.component.state.autoFitSize)>0?Number(this.component.state.autoFitSize):200)/Math.max(o.x,o.y,o.z),e=Math.max(1,Math.round(o.x*t)),n=Math.max(1,Math.round(o.y*t)),i=Math.max(1,Math.round(o.z*t)),r=this.component;r._ratioLocking=!0;try{this.component.set({width:e,height:i,depth:n,autoFit:!1})}finally{r._ratioLocking=!1}}if(this.updateDimension(),this.component.state.floorAlign){const t=this.scenePlacement;if("space"!==t){this.components3D.updateMatrixWorld(!0);const e=(new w.Box3).setFromObject(this.pivot);if(isFinite(e.min.y)&&isFinite(e.max.y))if("inverted"===t){const t=this.components3D.worldToLocal(e.max.clone());t.y>0&&(this.pivot.position.y-=t.y)}else{const t=this.components3D.worldToLocal(e.min.clone());t.y<0&&(this.pivot.position.y-=t.y)}}}n&&n.length&&this._setupAnimations(n);const a=this.component.state.nodes;a&&this._applyNodeStates(a),this.updateFillStyle()}static renderTopView(t){const e=256,n=new w.Scene,i=t.parent;n.add(t);const r=new w.AmbientLight(16777215,.8);n.add(r);const s=new w.DirectionalLight(16777215,1);s.position.set(0,10,0),n.add(s);const o=(new w.Box3).setFromObject(t),a=o.getSize(new w.Vector3),c=o.getCenter(new w.Vector3),l=(a.x||1)/2*1.02,h=(a.z||1)/2*1.02,d=new w.OrthographicCamera(-l,l,h,-h,.01,10*a.y+1);d.position.set(c.x,o.max.y+a.y,c.z),d.lookAt(c.x,c.y,c.z);const u=l/h,p=u>=1?e:Math.round(e*u),f=u>=1?Math.round(e/u):e,g=Kh.getSharedSnapshotRenderer();if(!g){i?i.add(t):n.remove(t);const e=document.createElement("canvas");return e.width=p,e.height=f,e}g.setClearColor(0,0),g.setSize(p,f),g.render(n,d),i?i.add(t):n.remove(t);const m=document.createElement("canvas");m.width=p,m.height=f;const y=m.getContext("2d");return y&&y.drawImage(g.domElement,0,0),m}static getTopViewCache(t){return Kh._topViewCache.get(t)}static setTopViewCache(t,e){Kh._topViewCache.set(t,e)}static flushCache(){if(Kh._gltfCache.clear(),Kh._topViewCache.clear(),Kh._sharedSnapshotRenderer){try{Kh._sharedSnapshotRenderer.forceContextLoss()}catch{}Kh._sharedSnapshotRenderer.dispose(),Kh._sharedSnapshotRenderer=void 0}}_buildNodeIndex(t){this._nodeIndex.clear(),this._originals.clear(),t.traverse(t=>{if(!t.name)return;this._nodeIndex.set(t.name,t);const e={visible:t.visible,scale:t.scale.clone()};if(t.isMesh){const n=t.material;n&&(e.color=n.color.clone(),e.opacity=n.opacity,e.transparent=n.transparent,e.emissive=n.emissive.clone(),e.emissiveIntensity=n.emissiveIntensity)}this._originals.set(t.name,e)})}getNode(t){return this._nodeIndex.get(t)}get nodeNames(){return Array.from(this._nodeIndex.keys())}_applyNodeStates(t){for(const[e,n]of Object.entries(t)){const t=this._nodeIndex.get(e);if(t&&(void 0!==n.visible&&(t.visible=n.visible),void 0!==n.scale&&t.scale.setScalar(n.scale),t.isMesh)){const e=t;if(!(void 0!==n.color||void 0!==n.opacity||void 0!==n.emissive||void 0!==n.emissiveIntensity))continue;const i=this._ensureOwnMaterial(e);void 0!==n.color&&i.color.set(n.color),void 0!==n.opacity&&(i.opacity=n.opacity,i.transparent=n.opacity<1),void 0!==n.emissive&&i.emissive.set(n.emissive),void 0!==n.emissiveIntensity&&(i.emissiveIntensity=n.emissiveIntensity)}}}_resetNode(t){const e=this._nodeIndex.get(t),n=this._originals.get(t);if(e&&n&&(e.visible=n.visible,e.scale.copy(n.scale),e.isMesh)){const t=e.material;t&&n.color&&(t.color.copy(n.color),t.opacity=n.opacity,t.transparent=n.transparent,t.emissive.copy(n.emissive),t.emissiveIntensity=n.emissiveIntensity)}}_resetAllNodes(){for(const t of this._originals.keys())this._resetNode(t)}_setupAnimations(t){const e=this.threeContainer.mixer;this._animationActions.clear();for(const n of t){const t=e.clipAction(n);this._animationActions.set(n.name,t)}!1!==this.component.state.play&&this._playTargetAnimations();const n=this.component.state.animations;n&&this._applyAnimationStates(n)}_playTargetAnimations(){const t=this.component.state.playTargets;if("*"===t)this._animationActions.forEach(t=>t.play());else if(Array.isArray(t)&&t.length>0)for(const e of t)this._animationActions.get(e)?.play()}_applyAnimationStates(t){for(const[e,n]of Object.entries(t)){const t=this._animationActions.get(e);t&&(void 0!==n.loop&&(t.loop=qh[n.loop]??w.LoopRepeat,"once"===n.loop&&(t.clampWhenFinished=!0)),void 0!==n.speed&&(t.timeScale=n.speed),void 0!==n.weight&&(t.weight=n.weight),void 0!==n.play&&(n.play?t.play():t.stop()))}}get animationNames(){return Array.from(this._animationActions.keys())}updateFillStyle(){const{fillStyle:t}=this.component.state;if(!t)return;const e=this.component.state.fillStyleTargets;let n;if("*"===e)n=[...this._nodeIndex.entries()].filter(([,t])=>t.isMesh).map(([t])=>t);else{if(!(Array.isArray(e)&&e.length>0))return;n=e}if(0===n.length)return;const i=Uh.buildFillStyleTexture(this.component);for(const e of n){const n=this._nodeIndex.get(e);if(!n||!n.isMesh)continue;const r=this._ensureOwnMaterial(n);r&&(this._fillStyleOriginals.has(e)||this._fillStyleOriginals.set(e,{color:r.color.clone(),map:r.map,opacity:r.opacity,transparent:r.transparent}),i?(r.map&&r.map!==this._fillStyleOriginals.get(e)?.map&&r.map.dispose(),i.needsUpdate=!0,r.map=i):"string"==typeof t&&("transparent"!==t?r.color.set(t):(r.opacity=0,r.transparent=!0)))}}_restoreFillStyleTargets(t){for(const e of t){const t=this._fillStyleOriginals.get(e);if(!t)continue;const n=this._nodeIndex.get(e);if(!n||!n.isMesh)continue;const i=n.material;i&&(i.map&&i.map!==t.map&&i.map.dispose(),i.color.copy(t.color),i.map=t.map,i.opacity=t.opacity,i.transparent=t.transparent,this._fillStyleOriginals.delete(e))}}clear(){return this._animationActions.forEach(t=>t.stop()),this._animationActions.clear(),this._nodeIndex.clear(),this._originals.clear(),this._fillStyleOriginals.clear(),super.clear()}updateDimension(){const{width:t=1,height:e=1,depth:n=1}=this.component.state,{x:i=1,y:r=1,z:s=1}=this.objectSize||{};this.pivot&&this.pivot.scale.set(t/i,n/r,e/s),this.component.invalidate()}onchange(t,e){if(super.onchange(t,e),("src"in t||"floorAlign"in t)&&this.updateSource(),"nodes"in t){this._resetAllNodes();const e=t.nodes;e&&Object.keys(e).length>0&&this._applyNodeStates(e)}if("animations"in t){const e=t.animations;e&&this._applyAnimationStates(e)}if("fillStyleTargets"in t){const t=[...this._fillStyleOriginals.keys()];t.length>0&&this._restoreFillStyleTargets(t),this.updateFillStyle()}("play"in t||"playTargets"in t)&&(this._animationActions.forEach(t=>t.stop()),!1!==this.component.state.play&&this._playTargetAnimations())}}Kh._topViewCache=new Map,Kh._gltfCache=new Map,Kh._sharedLoader=null;const Qh=["id","name","tag","type","class","text","data","property"];class Zh{constructor(){this._results=[],this._currentIndex=-1,this._lastQuery=""}get results(){return this._results}get currentIndex(){return this._currentIndex}get currentResult(){return this._results[this._currentIndex]}get resultCount(){return this._results.length}search(t,e,n){if(this._lastQuery=e,this._results=[],this._currentIndex=-1,!e||!t)return this._results;const i=n?.fields||Qh,r=n?.caseSensitive??!1,s=n?.includeHidden??!1,o=n?.maxResults??1/0,a=r?e:e.toLowerCase(),c=new Set;return this._traverse(t,t=>{if(c.has(t))return;if(this._results.length>=o)return;if(!s&&t.state.hidden)return;const e=this._matchComponent(t,a,i,r);e&&(c.add(t),this._results.push(e))}),this._results.length>0&&(this._currentIndex=0),this._results}navigateNext(){if(0!==this._results.length)return this._currentIndex=(this._currentIndex+1)%this._results.length,this._results[this._currentIndex]}navigatePrev(){if(0!==this._results.length)return this._currentIndex=(this._currentIndex-1+this._results.length)%this._results.length,this._results[this._currentIndex]}navigateTo(t){if(!(t<0||t>=this._results.length))return this._currentIndex=t,this._results[this._currentIndex]}clear(){this._results=[],this._currentIndex=-1,this._lastQuery=""}_traverse(t,e){e(t);const n=t.components;if(n)for(const t of n)this._traverse(t,e)}_matchComponent(t,e,n,i){const r=t.state,s=t=>{if(!t)return!1;return(i?t:t.toLowerCase()).includes(e)};for(const o of n)switch(o){case"id":if(s(r.id))return{component:t,matchType:"id",matchField:"id",matchValue:r.id};break;case"name":if(s(r.name))return{component:t,matchType:"name",matchField:"name",matchValue:r.name};break;case"tag":if(s(r.tag))return{component:t,matchType:"tag",matchField:"tag",matchValue:r.tag};break;case"type":if(s(r.type))return{component:t,matchType:"type",matchField:"type",matchValue:r.type};break;case"class":if(s(r.class))return{component:t,matchType:"class",matchField:"class",matchValue:r.class};break;case"text":if(s(r.text))return{component:t,matchType:"text",matchField:"text",matchValue:r.text};break;case"data":{const n=this._matchDataBinding(t,e,i);if(n)return n;break}case"property":{const n=this._matchProperties(t,e,i);if(n)return n;break}}return null}_matchDataBinding(t,e,n){const i=t._model,r=i?.mappings;if(!r||!Array.isArray(r))return null;const s=t=>{if(!t)return!1;return(n?t:t.toLowerCase()).includes(e)};for(const e of r){if(s(e.accessor))return{component:t,matchType:"data",matchField:"accessor",matchValue:e.accessor};if(s(e.target))return{component:t,matchType:"data",matchField:"target",matchValue:e.target};if(s(e.property))return{component:t,matchType:"data",matchField:"property",matchValue:e.property};if(s(e.source))return{component:t,matchType:"data",matchField:"source",matchValue:e.source}}return null}_matchProperties(t,e,n){const i=t.state,r=t=>{if(!t)return!1;return(n?t:t.toLowerCase()).includes(e)},s=["ref","src","value","action"];for(const e of s){const n=i[e];if("string"==typeof n&&r(n))return{component:t,matchType:"property",matchField:e,matchValue:n}}const o=i.fillStyle;if(o){if("string"==typeof o&&r(o))return{component:t,matchType:"property",matchField:"fillStyle",matchValue:o};if("object"==typeof o&&"pattern"===o.type&&"string"==typeof o.image&&r(o.image))return{component:t,matchType:"property",matchField:"fillStyle.image",matchValue:o.image}}return null}}const Jh={id:"ID",name:"Name",tag:"Tag",type:"Type",class:"Class",text:"Text",data:"Data",property:"Prop"};class td{constructor(){this._engine=new Zh,this._visible=!1,this._queryHistory=[],this._historyIndex=-1,this._savedInput="",this._keyboardNav=!1}get isVisible(){return this._visible}get engine(){return this._engine}setup(t){this.destroy(),this._host=t}toggle(){this._visible?this._input&&document.activeElement!==this._input?(this._input.focus(),this._input.select()):this.hide():this.show()}show(){this._host?.element&&(this._container||this._buildDOM(),this._container&&!this._container.parentElement&&this._host.element.appendChild(this._container),this._container.style.display="flex",this._visible=!0,requestAnimationFrame(()=>{this._input?.focus(),this._input?.select()}))}hide(){this._container&&(this._container.style.display="none"),this._visible=!1,this._historyIndex=-1,this._clearHighlight(),this._engine.clear(),this._updateStatus(),this._hideResultList()}destroy(){this._container?.parentElement&&this._container.parentElement.removeChild(this._container),this._container=void 0,this._input=void 0,this._statusEl=void 0,this._resultListEl=void 0,this._host=void 0,this._visible=!1,this._engine.clear()}_buildDOM(){const t=this._host,e=document.createElement("div");e.setAttribute("scene","search-overlay"),e.style.cssText=["position:absolute","top:8px","right:8px","display:flex","flex-direction:column","background:rgba(30,30,30,0.94)","border:1px solid rgba(255,255,255,0.12)","border-radius:8px","backdrop-filter:blur(12px)","pointer-events:auto","user-select:none","z-index:10000",'font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif',"font-size:13px","color:rgba(255,255,255,0.9)","box-shadow:0 4px 16px rgba(0,0,0,0.3)","min-width:280px","max-width:400px"].join(";");const n=document.createElement("div");n.style.cssText="display:flex;align-items:center;padding:6px 8px;gap:6px";const i=document.createElement("span");i.textContent="🔍",i.style.cssText="font-size:14px;flex-shrink:0;opacity:0.6",n.appendChild(i);const r=document.createElement("input");r.type="text",r.placeholder="Search: type, id, tag, text, data...",r.style.cssText=["flex:1","background:rgba(255,255,255,0.08)","border:1px solid rgba(255,255,255,0.15)","border-radius:4px","color:white","padding:4px 8px","font-size:13px","outline:none","min-width:0"].join(";"),r.addEventListener("focus",()=>{r.style.borderColor="rgba(74,158,255,0.6)"}),r.addEventListener("blur",()=>{r.style.borderColor="rgba(255,255,255,0.15)"}),n.appendChild(r);const s=document.createElement("span");s.style.cssText="font-size:11px;color:rgba(255,255,255,0.5);white-space:nowrap;flex-shrink:0",n.appendChild(s);const o=document.createElement("button");o.textContent="✕",o.title="Close (Esc)",o.style.cssText=this._buttonStyle(),o.addEventListener("click",()=>this.hide()),n.appendChild(o),e.appendChild(n);const a=document.createElement("div");a.style.cssText=["max-height:240px","overflow-y:auto","border-top:1px solid rgba(255,255,255,0.08)","display:none"].join(";"),e.appendChild(a),r.addEventListener("input",()=>{this._historyIndex=-1,this._debounceTimer&&clearTimeout(this._debounceTimer),this._debounceTimer=setTimeout(()=>this._doSearch(r.value),150)}),r.addEventListener("keydown",e=>{if(e.stopPropagation(),"Escape"===e.key)return this.hide(),void t.element?.focus();if("ArrowDown"===e.key||"Tab"===e.key){if("Tab"===e.key&&e.shiftKey)return;return this._isHistoryMode()||!this._input?.value&&"ArrowDown"===e.key?this._navigateHistory(1):this._engine.resultCount>0&&this._focusResult(0),void e.preventDefault()}if("ArrowUp"===e.key)return this._navigateHistory(-1),void e.preventDefault();if("Enter"===e.key){const t=this._engine.currentIndex>=0?this._engine.currentIndex:0;return this._selectResult(t),void e.preventDefault()}}),this._container=e,this._input=r,this._statusEl=s,this._resultListEl=a}_buttonStyle(){return["background:none","border:none","color:rgba(255,255,255,0.6)","cursor:pointer","font-size:12px","padding:2px 4px","border-radius:3px","line-height:1"].join(";")}_doSearch(t){if(!this._host?.root)return;const e=t.trim();if(!e)return this._engine.clear(),this._clearHighlight(),this._updateStatus(),void this._hideResultList();this._engine.search(this._host.root,e),this._updateStatus(),this._renderResultList()}_addToHistory(t){const e=t.trim();if(!e)return;const n=this._queryHistory.indexOf(e);n>=0&&this._queryHistory.splice(n,1),this._queryHistory.unshift(e),this._queryHistory.length>td.MAX_HISTORY&&this._queryHistory.pop()}_navigateHistory(t){if(0===this._queryHistory.length)return;if(!this._input)return;-1===this._historyIndex&&-1===t&&(this._savedInput=this._input.value);const e=this._historyIndex+(-1===t?1:-1);e<-1||e>=this._queryHistory.length||(this._historyIndex=e,-1===this._historyIndex?this._input.value=this._savedInput:this._input.value=this._queryHistory[this._historyIndex],this._debounceTimer&&clearTimeout(this._debounceTimer),this._doSearch(this._input.value))}_isHistoryMode(){return this._historyIndex>=0}_focusResult(t){if(t<0||t>=this._engine.resultCount)return;if(t>=50)return;this._engine.navigateTo(t),this._keyboardNav=!0,this._updateStatus(),this._updateResultListSelection();const e=this._resultListEl?.querySelector(`[data-index="${t}"]`);e?.focus()}_selectResult(t){if(!this._host)return;if(0===this._engine.resultCount)return;if(t<0||t>=this._engine.resultCount)return;this._engine.navigateTo(t);const e=this._engine.currentResult;if(!e)return;this._addToHistory(this._input?.value||""),this._host.setSelected([e.component]),this._host.centerTo(e.component,!0);const n=this._engine.results.map(t=>t.component);this._host.highlightSearchResults?.(n),this._host.invalidate?.(),this._updateStatus(),this._updateResultListSelection()}_clearHighlight(){this._host?.highlightSearchResults?.([]),this._host?.invalidate?.()}_updateStatus(){if(!this._statusEl)return;const t=this._engine.resultCount,e=this._engine.currentIndex;0===t&&this._input?.value?.trim()?(this._statusEl.textContent="No results",this._statusEl.style.color="rgba(255,120,120,0.8)"):t>0?(this._statusEl.textContent=`${e+1}/${t}`,this._statusEl.style.color="rgba(255,255,255,0.5)"):this._statusEl.textContent=""}_renderResultList(){if(!this._resultListEl)return;const t=this._engine.results;if(this._resultListEl.innerHTML="",0===t.length)return void(this._resultListEl.style.display="none");const e=t.slice(0,50);for(let t=0;t<e.length;t++){const n=e[t],i=document.createElement("div");i.dataset.index=String(t),i.tabIndex=-1,i.style.cssText=["padding:4px 10px","cursor:pointer","display:flex","align-items:center","gap:6px","font-size:12px","border-bottom:1px solid rgba(255,255,255,0.04)","transition:background 0.1s","outline:none"].join(";"),i.addEventListener("mouseenter",()=>{this._keyboardNav=!1,i.style.background="rgba(255,255,255,0.08)"}),i.addEventListener("mouseleave",()=>{this._engine.currentIndex!==t?i.style.background="none":i.style.background="rgba(74,158,255,0.15)"}),i.addEventListener("click",()=>{this._selectResult(t)}),i.addEventListener("keydown",e=>{e.stopPropagation(),"ArrowDown"===e.key?(this._focusResult(t+1),e.preventDefault()):"ArrowUp"===e.key?(0===t?(this._input?.focus(),this._input?.select()):this._focusResult(t-1),e.preventDefault()):"Enter"===e.key?(this._selectResult(t),e.preventDefault()):"Escape"===e.key?(this.hide(),this._host?.element?.focus(),e.preventDefault()):e.shiftKey&&"Tab"===e.key?(this._input?.focus(),e.preventDefault()):1!==e.key.length||e.metaKey||e.ctrlKey||e.altKey||this._input?.focus()});const r=document.createElement("span");r.textContent=Jh[n.matchType]||n.matchType,r.style.cssText=["font-size:9px","padding:1px 4px","border-radius:3px","background:rgba(74,158,255,0.2)","color:rgba(74,158,255,0.9)","flex-shrink:0","text-transform:uppercase","letter-spacing:0.5px"].join(";"),i.appendChild(r);const s=document.createElement("span");s.textContent=n.component.state.type||"?",s.style.cssText="color:rgba(255,255,255,0.7);flex-shrink:0",i.appendChild(s);const o=document.createElement("span");if(o.textContent=this._truncate(n.matchValue,30),o.style.cssText="color:rgba(255,200,100,0.8);overflow:hidden;text-overflow:ellipsis;white-space:nowrap",i.appendChild(o),"id"!==n.matchType&&n.component.state.id){const t=document.createElement("span");t.textContent=`#${n.component.state.id}`,t.style.cssText="color:rgba(255,255,255,0.3);font-size:11px;margin-left:auto;flex-shrink:0",i.appendChild(t)}this._resultListEl.appendChild(i)}if(t.length>50){const e=document.createElement("div");e.style.cssText="padding:4px 10px;font-size:11px;color:rgba(255,255,255,0.3);text-align:center",e.textContent=`... and ${t.length-50} more`,this._resultListEl.appendChild(e)}this._resultListEl.style.display="block",this._updateResultListSelection()}_updateResultListSelection(){if(!this._resultListEl)return;const t=this._engine.currentIndex;for(const e of Array.from(this._resultListEl.children)){const n=e,i=parseInt(n.dataset.index||"-1",10);n.style.background=i===t?"rgba(74,158,255,0.15)":"none"}const e=this._resultListEl.querySelector(`[data-index="${t}"]`);e?.scrollIntoView({block:"nearest"})}_hideResultList(){this._resultListEl&&(this._resultListEl.style.display="none",this._resultListEl.innerHTML="")}_truncate(t,e){return t.length>e?t.slice(0,e)+"...":t}}td.MAX_HISTORY=20;let ed=0;const nd=new FinalizationRegistry(t=>{ed--});class id{static get residents(){return ed}static get residentsCount(){return ed}constructor(t){this._searchOverlay=new td,this._loadingOverlay=new Ph,this._container=t,this.app=t.app,this._commander=new gl(this._container),this.app.commander=this._commander,ed++,nd.register(this,ed),Eh.register(this),this._container.target_element&&this._setupSearchOverlay()}add(t,e,n){return Dl.call(this._container,t,e,n)}duplicate(){return Ol.call(this._container)}remove(){return zl.call(this._container)}animate(t){return Bo.call(this,t)}fullscreen(t){return Bl.call(this._container,t)}get target(){return this._container.target_element}set target(t){let e;if("string"==typeof t){if(e=document.getElementById(t),!e)throw new Error(`target element '${t}' does not exist`);if(e.firstChild)throw new Error(`target element '${t}' already has children`)}else e=t;e&&e.style&&(e.style.cursor="default"),this._container.target_element=e,this._setupSearchOverlay(),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 wr}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._loadingOverlay.destroy(),this._searchOverlay.destroy(),Eh.unregister(this),this._commander&&this._commander.dispose(),this._container&&this._container.dispose(),Kh.flushCache()}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 Yl.call(this._container)}copy(){return Hl.call(this._container)}paste(t){return Gl.call(this._container,t)}undoableChange(t){return ah.call(this._container,t)}change(t,e,n){return oh.call(this.root,t,e,n)}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(t,...e){return this.root.findAll(t,...e)}findFirst(t,...e){return this.root.findFirst(t,...e)}findById(t){return this._container.findById(t)}findAllById(t){return this._container.findAllById(t)}serialize(){return this.root.trim(),this.root.serialize()}align(t){return Al.call(this._container,t)}place(t){return gh.call(this._container,t)}distribute(t){return Cl.call(this._container,t)}move(t,e,n){return Tl.call(this._container,t,e,n)}zorder(t){return Pl.call(this._container,t)}symmetryX(){return rh.call(this._container)}symmetryY(){return sh.call(this._container)}on(t,e,n){return Rl.call(this._container,t,e,n)}once(t,e,n){return jl.call(this._container,t,e,n)}off(t,e,n){return this._container&&Fl.call(this._container,t,e,n)}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(t,e,n,i){return Jl.call(this._container,t,e,n,i)}group(){return th.call(this._container)}ungroup(){return eh.call(this._container)}fit(t){this._container.once("redraw",()=>this._container.fit(t)),this._container.invalidate()}get fitMode(){return this._container.fitMode}get ids(){return ch.call(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}get suppressAnimations(){return this.app.suppressAnimations}set suppressAnimations(t){this.app.suppressAnimations=t}withSuppressedAnimations(t){return this.app.withSuppressedAnimations(t)}beginSuppressAnimations(){return this.app.beginSuppressAnimations()}startAddMode(t){return mh.call(this._container,t)}startStylePasteMode(){return yh.call(this._container)}stopStylePasteMode(){return bh.call(this._container)}startDatabindPasteMode(){return _h.call(this._container)}stopDatabindPasteMode(){return vh.call(this._container)}get loading(){return this.app.loadTracker}get loadingOverlay(){return this._loadingOverlay}showLoadingOverlay(){this._loadingOverlay.show()}hideLoadingOverlay(){this._loadingOverlay.hide()}toggleLoadingOverlay(){if(!this._loadingOverlay.isAttached){const t=this._container.target_element;t&&this._loadingOverlay.attach(t,this.app.loadTracker,this.app.lagTracker)}this._loadingOverlay.toggle()}get searchOverlay(){return this._searchOverlay}_setupSearchOverlay(){const t=this;this._searchOverlay.setup({get root(){return t.root},get element(){return t.target},centerTo(e,n){t.centerTo(e,n)},setSelected(e){t.selected=e},invalidate(){t._container?.invalidate()}});const e=this._container.model_layer;e&&(e.onSearchToggle=()=>this._searchOverlay.toggle(),e.onDataBindingToggle=()=>this.onDataBindingToggle?.(),e.onMonitorToggle=()=>this.toggleLoadingOverlay())}_setupLoadingOverlay(){const t=this._container.target_element;t&&this._loadingOverlay.attach(t,this.app.loadTracker,this.app.lagTracker)}}const rd=new class{async load(t){}async save(t,e){}async clear(t){}};function sd({target:t,model:e,style:n,layers:i=[],handlers:r=[],mode:s=0,refProvider:o,dataSubscriptionProvider:a,dataStorage:c=rd,baseUrl:l,fitMode:h,postprocessing:d=!0,loading:u}){let p=null;if("string"==typeof t){if(p=document.getElementById(t),!p)throw new Error(`target element '${t}' does not exist`);if(p.firstChild)throw new Error(`target element '${t}' is not empty`)}else p=t??null;p&&p.style&&(p.style.position="absolute",p.style.cursor="default",p.style.overflow="hidden");const f=new ll(s,o);return l&&(f.baseUrl=l),f.postprocessing=d,f.dataSubscriptionProvider=a,f.dataStorage=c,u?.tracker?f.adoptLoadTracker(u.tracker):f.initLoadTracker(u||{}),f.loadTracker?.setPhase("init"),new id(new tl({target_element:p,model:e,style:n,layers:i,handlers:r,fitMode:h},f))}const od=20;function ad(t,e="static",n,i,r,s,o={}){const{title:a="",gap:c=od}=o;if("auto"===n){const{x:e,y:n}=function(t,e,n,i="",r=od){const s=Math.max(e.width/4-n.width/2,r),o=Math.min(3*e.width/4+n.width/2,e.width-r)-n.width,a=Math.max(e.height/4-n.height/2,r),c=Math.min(3*e.height/4+n.height/2,e.height-r)-n.height+(i?-30:0);return{x:t.x<e.width/2?Math.min(o,t.x+20):Math.max(s,t.x-(n.width+20)),y:t.y<e.height/2?Math.min(c,t.y+20+(i?30:0)):Math.max(a,t.y-(n.height+20))}}(i,r,s,a,c);Object.assign(t.style,{position:"absolute",left:`${e}px`,top:`${n}px`})}else"static"===e?function(t,e,n,i,r){const s=t.style,o=e.includes("left")?r:e.includes("right")?n.width-i.width-r:n.width/2-i.width/2,a=e.includes("top")?r:e.includes("bottom")?n.height-i.height-r:n.height/2-i.height/2;Object.assign(s,{left:`${o}px`,top:`${a}px`})}(t,n,r,s,c):function(t,e,n=od){const i=t.style;switch(Object.assign(i,{position:"absolute",left:"",right:"",top:"",bottom:"",transform:""}),e){case"center-middle":default:Object.assign(i,{left:"50%",top:"50%",transform:"translate(-50%, -50%)"});break;case"center-top":Object.assign(i,{left:"50%",top:`${n}px`,transform:"translateX(-50%)"});break;case"center-bottom":Object.assign(i,{left:"50%",bottom:`${n}px`,transform:"translateX(-50%)"});break;case"left-middle":Object.assign(i,{left:`${n}px`,top:"50%",transform:"translateY(-50%)"});break;case"right-middle":Object.assign(i,{right:`${n}px`,top:"50%",transform:"translateY(-50%)"});break;case"left-top":Object.assign(i,{left:`${n}px`,top:`${n}px`});break;case"right-top":Object.assign(i,{right:`${n}px`,top:`${n}px`});break;case"left-bottom":Object.assign(i,{left:`${n}px`,bottom:`${n}px`});break;case"right-bottom":Object.assign(i,{right:`${n}px`,bottom:`${n}px`})}}(t,n,c)}function cd(t,e,n={sx:1,sy:1},i={}){const{signal:r}=i;let s,o,a=0,c=0,l=!1;const h=/translate\(([-\d.]+)px,\s*([-\d.]+)px\)/;function d(){const e=(t.style.transform||"").match(h);return{x:e?parseFloat(e[1]):0,y:e?parseFloat(e[2]):0}}function u(t,e){l=!0;const n=d();a=n.x,c=n.y,s=t,o=e}function p(e,i){if(!l)return;const r=e-s,h=i-o,{sx:d,sy:u}=n;!function(e,n){t.style.transform=`translate(${e}px, ${n}px)`}(a+r/d,c+h/u)}function f(){const t=d();a=t.x,c=t.y,l=!1}function g(t){if(!r)return t.signal;const e=AbortSignal.any;return e?e([t.signal,r]):(r.aborted?t.abort():r.addEventListener("abort",()=>t.abort(),{once:!0}),t.signal)}e?.addEventListener("mousedown",t=>{t.preventDefault(),t.stopPropagation(),u(t.clientX,t.clientY);const e=new AbortController,n=g(e);window.addEventListener("mousemove",t=>{t.preventDefault(),p(t.clientX,t.clientY)},{capture:!0,signal:n}),window.addEventListener("mouseup",t=>{t.preventDefault(),f(),e.abort()},{capture:!0,signal:n})},{signal:r}),e?.addEventListener("touchstart",t=>{if(1!==t.touches.length)return;t.preventDefault(),t.stopPropagation(),u(t.touches[0].clientX,t.touches[0].clientY);const e=new AbortController,n=g(e);window.addEventListener("touchmove",t=>{1===t.touches.length&&(t.preventDefault(),p(t.touches[0].clientX,t.touches[0].clientY))},{capture:!0,signal:n});const i=()=>{f(),e.abort()};window.addEventListener("touchend",i,{capture:!0,signal:n}),window.addEventListener("touchcancel",i,{capture:!0,signal:n})},{signal:r})}function ld(t,e,n){const i=t.rootModel;if(i?.is3dMode){const e=t._realObject?.object3d,n=i.activeCamera3d,r=i.renderer3d;if(e&&n&&r){const t=new w.Vector3;e.getWorldPosition(t);const i=t.clone().project(n),s=r.domElement;return{x:(.5*i.x+.5)*s.clientWidth,y:(.5*-i.y+.5)*s.clientHeight}}return null}const r=t.toGlobal(e,n,i);return isNaN(r.x)||isNaN(r.y)?null:r}const hd=new w.Box3,dd=new w.Vector3;function ud(t,e="top",n={},i=new w.Vector3){const r=t._realObject;return r?.object3d?(r.object3d.updateWorldMatrix(!0,!0),"center"===e?i.setFromMatrixPosition(r.object3d.matrixWorld):(hd.setFromObject(r.object3d),hd.isEmpty()?i.setFromMatrixPosition(r.object3d.matrixWorld):(hd.getCenter(dd),"bottom"===e?i.set(dd.x,hd.min.y,dd.z):i.set(dd.x,hd.max.y,dd.z))),i.x+=n.x??0,i.y+=n.y??0,i.z+=n.z??0,Number.isFinite(i.x)&&Number.isFinite(i.y)&&Number.isFinite(i.z)?i:null):null}function pd(t){const e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("style","position:absolute; left:0; top:0; width:100%; height:100%; pointer-events:none; overflow:visible; opacity:0; transition: opacity 200ms ease;"),e.dataset.role="tether";const n=document.createElementNS("http://www.w3.org/2000/svg","circle");n.setAttribute("r","8"),n.setAttribute("opacity","0"),e.appendChild(n);const i=document.createElementNS("http://www.w3.org/2000/svg","path");i.setAttribute("fill","none"),i.setAttribute("stroke-width","2"),i.setAttribute("stroke-linecap","round"),e.appendChild(i);const r=document.createElementNS("http://www.w3.org/2000/svg","circle");return r.setAttribute("r","3.5"),r.setAttribute("opacity","0"),e.appendChild(r),t.appendChild(e),{svg:e,path:i,halo:n,dot:r}}function fd(t,e,n,i,r,s,o,a,c,l,h){const{svg:d,path:u,halo:p,dot:f}=t;d.setAttribute("width",String(l)),d.setAttribute("height",String(h)),d.setAttribute("viewBox",`0 0 ${l} ${h}`);const g=function(t,e,n,i,r,s){const o=n+r/2,a=i+s/2,c=t-o,l=e-a;if(Math.abs(c)*s>Math.abs(l)*r)return{x:c>0?n+r:n,y:a};return{x:o,y:l>0?i+s:i}}(e,n,i,r,s,o),m=g.x-e,y=g.y-n,b=(e+g.x)/2,_=(n+g.y)/2,v=Math.sqrt(m*m+y*y),x=v>0?-y/v:0,w=v>0?m/v:0,M=Math.min(18,.12*v),S=b+x*M,A=_+w*M;u.setAttribute("d",`M ${e} ${n} Q ${S} ${A} ${g.x} ${g.y}`),u.setAttribute("stroke",a),u.setAttribute("opacity",String(c)),p.setAttribute("cx",String(e)),p.setAttribute("cy",String(n)),p.setAttribute("fill",a),p.setAttribute("opacity",String(.25*c)),f.setAttribute("cx",String(e)),f.setAttribute("cy",String(n)),f.setAttribute("fill",a),f.setAttribute("opacity",String(c))}function gd(t){t.path.setAttribute("d",""),t.halo.setAttribute("opacity","0"),t.dot.setAttribute("opacity","0")}function md(t){t.svg.parentNode?.removeChild(t.svg)}const yd=["run","goto","goto-playlist","link-open","link-move","route-page","start-scenario","run-scenario","export-data","import-data"];function bd(t,e){const n=document.createElement("button");return n.className=t,n.textContent=e,n}function _d(t){const{component:e,anchor:n,anchorPin:i,anchorOffset:r,popupRoot:s,popupSize:o,constantSize:a,billboard:c,tetherEnabled:h,offScreen:d,signal:u,popupEntry:p}=t,f=e.rootModel??e.root;if(!f?.on)return;if(!a)return void function(t){const{component:e,anchor:n,anchorPin:i,anchorOffset:r,popupRoot:s,billboard:o,tetherEnabled:a,signal:c,popupEntry:h}=t,d=e.rootModel??e.root,u=d?._threeCapability,p=u?.rendererManager?.css3DScene;if(!p)return void ji("perspective popup requires 3D mode active (css3DScene unavailable)");s.style.position="absolute";const f=o?new l.CSS3DSprite(s):new l.CSS3DObject(s);p.add(f),s.dataset.perspectiveCss3d="true";const g=()=>wd.hide(e);n.on?.("removed",g);const m=d.target??null;let y;a&&m&&(y=pd(m),h&&(h.tether=y));const b=()=>{const t=ud(n,i,r);if(t){if(f.position.set(t.x,t.y,t.z),y&&m){const t=ld(n,0,0),e=m.getBoundingClientRect(),i=s.getBoundingClientRect();if(t&&e.width>0&&e.height>0&&i.width>0){const n=i.left-e.left,r=i.top-e.top,s=o;fd(y,t.x,t.y,s?n:n+i.width/2,s?r:r+i.height/2,s?i.width:0,s?i.height:0,"rgba(80, 120, 200, 0.7)",1,e.width,e.height)}}}else y&&gd(y)},_=()=>b();d.on("redraw",_),b(),d.invalidate?.(),c.addEventListener("abort",()=>{d.off?.("redraw",_),n.off?.("removed",g),p.remove(f),s.parentNode&&s.parentNode.removeChild(s),y&&md(y)})}({component:e,anchor:n,anchorPin:i,anchorOffset:r,popupRoot:s,billboard:c,tetherEnabled:h,signal:u,popupEntry:p});Object.assign(s.style,{position:"absolute",pointerEvents:"auto"});const g=s.parentElement;let m;h&&g&&(m=pd(g),p&&(p.tether=m));const y=()=>wd.hide(e);n.on?.("removed",y);const b=()=>{if(!ud(n,i,r))return void("hide"===d&&(s.style.opacity="0",m&&gd(m)));const t=ld(n,0,0);if(!t||!Number.isFinite(t.x)||!Number.isFinite(t.y))return void("hide"===d&&(s.style.opacity="0",m&&gd(m)));const e=g?.getBoundingClientRect(),a=e?.width??0,c=e?.height??0,l=t.x<0||t.x>a||t.y<0||t.y>c;if(l&&"hide"===d)return s.style.opacity="0",void(m&&gd(m));if(l&&"keep-last"===d)return;let{x:h,y:u}=t;l&&"edge-pin"===d&&(h=Math.max(0,Math.min(a,h)),u=Math.max(0,Math.min(c,u)));const p=h+24,f=u-24-o.height,y=Math.max(8,Math.min(p,a-o.width-8)),b=Math.max(8,Math.min(f,c-o.height-8));s.style.opacity="1",s.style.left=`${y}px`,s.style.top=`${b}px`,m&&fd(m,h,u,y,b,o.width,o.height,"rgba(80, 120, 200, 0.7)",1,a,c)},_=()=>b();f.on("redraw",_),b(),f.invalidate?.(),u.addEventListener("abort",()=>{f.off?.("redraw",_),n.off?.("removed",y),m&&md(m)})}const vd=new WeakMap;function xd(t){const e=t.root,n=vd.get(e);if(!n)return;if(e===t)return n.forEach(t=>xd(t[0])),void vd.delete(e);const i=n.findIndex(e=>e[0]===t);if(-1===i)return;const r=n[i][1];cancelAnimationFrame(r.rafId),r.ac.abort(),r.div.parentNode?.removeChild(r.div),r.scene.target=null,r.scene.release?.(),n.splice(i,1)}class wd{static hideAll(t){(vd.get(t)||[]).forEach(([t])=>xd(t))}static hide(t){const e=t.root,n=vd.get(e);if(!n)return;const i=n.findIndex(e=>e[0]===t);if(-1===i)return;const r=n[i][1],s=()=>{r.div.style.backgroundColor="transparent",r.rafId=function(t,e,n){const i="true"===t.dataset.perspectiveCss3d;t.style.opacity="1";const r=(t.style.transform||"").replace(/scale\([^)]+\)/,"").trim();i||(t.style.transform=`${r} scale(1)`);let s=0;const o=Date.now(),a=()=>{if(n?.aborted)return;const c=Math.min((Date.now()-o)/200,1);t.style.opacity=String(1-c),i||(t.style.transform=`${r} scale(${1-c})`.trim()),c<1?s=requestAnimationFrame(a):(t.style.display="none",e&&e())};return s=requestAnimationFrame(a),s}(r.div,()=>{xd(t)},r.ac.signal)};r.tether?(r.tether.svg.style.opacity="0",setTimeout(s,200)):s()}static show(t,e,n={}){const{data:i,modal:r=!1,closable:s=!0,minimizable:o=!1,draggable:a=!1,output:c=!0,popupPosition:l="static",origin:h="center-middle",title:d="",threed:u=!1,anchor:p,anchorPin:f="top",anchorOffsetX:g=0,anchorOffsetY:m=0,anchorOffsetZ:y=0,constantSize:b=!0,billboard:_=!0,tether:v=!1,offScreen:x="hide"}=n,w=t.app?.refProvider,M=!!p&&!r&&!a,S=!!t.rootModel?.is3dMode,A=M||S?"absolute":l,E=!A||"static"===A;let k;n.containerRef?k=function(t,e){const n=t.rootModel,i=n?.findById?.(e);if(!i)return ji(`PopupContainer not found: ${e}`),Promise.reject(new Error(`PopupContainer not found: ${e}`));const r=Hn(i.hierarchy);delete r.id,r.position="static",r.left=0,r.top=0;const{width:s=320,height:o=200}=i.bounds||{},a={width:s,height:o,components:[r]},c=t.app;return Promise.resolve(sd({model:a,mode:0,refProvider:c?.refProvider,dataSubscriptionProvider:c?.dataSubscriptionProvider,dataStorage:c?.dataStorage,baseUrl:c?.baseUrl,fitMode:"both"}))}(t,n.containerRef):n.htmlTemplate?k=function(t){const e={width:320,height:200};let n=null;const i={root:{model:e,bounds:e},data:void 0,fit(){},on(){},off(){},release(){}};return Object.defineProperty(i,"target",{get:()=>n,set:e=>{n=e,e&&(e.innerHTML=t)},configurable:!0}),Promise.resolve(i)}(n.htmlTemplate):e&&(k=w?.create?w.create(e):w?.get(e,!0)),k?.then(e=>{const n=document.createElement("div");n.setAttribute("popup",""),"absolute"==A&&(n.style.zIndex="100");const w=n.style;if(r){const{width:e,height:n}=E?t.rootModel.bounds:t.rootModel.auxOverlay.getBoundingClientRect();Object.assign(w,{position:"absolute",zIndex:"100",left:0,top:0,width:E?`${e}px`:"100%",height:E?`${n}px`:"100%",overflow:"hidden",backgroundColor:"transparent"})}else Object.assign(w,{position:"absolute",display:"inline-block"});n.appendChild(function(t){const e=document.createDocumentFragment(),n=document.createElement("div");n.className="popup-wrap";const i=document.createElement("div");if(i.className="popup-translate",t){const t=document.createElement("div");t.className="popup-title-bar";const e=document.createElement("div");e.className="popup-title",t.appendChild(e);const n=document.createElement("div");n.className="popup-buttons-wrap",n.appendChild(bd("closable","close")),n.appendChild(bd("minimizable","minimize")),n.appendChild(bd("draggable","drag_pan")),t.appendChild(n),i.appendChild(t)}else{const t=document.createElement("div");t.className="popup-buttons-wrap float-right",t.appendChild(bd("closable","close")),t.appendChild(bd("minimizable","minimize")),t.appendChild(bd("draggable","drag_pan")),i.appendChild(t)}const r=document.createElement("div");return r.className="popup-content",i.appendChild(r),n.appendChild(i),e.appendChild(n),e}(!!d));const S=n.querySelector(".popup-content"),{width:k,height:C}=e.root.model;Object.assign(S.style,{width:`${k}px`,height:`${C}px`});const T=document.createElement("style");T.appendChild(document.createTextNode("\n\n.popup-wrap .popup-translate {\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n min-width: 120px;\n overflow: hidden;\n transition: height 0.5s ease;\n}\n\n.popup-wrap .popup-translate > * {\n pointer-events: auto;\n}\n\n.popup-wrap .popup-content {\n /* 배경을 강제하지 않는다 — 로딩된 보드의 자체 배경/투명도가 그대로 보이도록.\n * 보드가 transparent 일 때 popup 안의 round corner / 그림자 효과가 망가지지 않게.\n * 흰 배경이 필요하면 보드 root 의 fillStyle 로 설정하거나 (또는 popup-content\n * CSS 변수를 외부에서 override). */\n background-color: transparent;\n}\n\n.popup-wrap .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-wrap .popup-title {\n flex: 1;\n text-align: center;\n}\n\n.popup-wrap .popup-buttons-wrap {\n position: relative;\n display: flex;\n flex-direction: row-reverse;\n gap: 4px;\n min-width: 100px;\n align-items: center;\n justify-items: center;\n margin: 0;\n padding: 0;\n}\n\n.popup-wrap .popup-buttons-wrap.float-right {\n position: absolute;\n right: 0;\n top: 0;\n height: 30px;\n margin-right: 5px;\n}\n\n.popup-wrap button.closable, \n.popup-wrap button.minimizable, \n.popup-wrap button.draggable {\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: 16px;\n}\n\n.popup-wrap button.draggable {\n cursor: move;\n}\n\n.popup-wrap button.closable:hover, \n.popup-wrap button.minimizable:hover, \n.popup-wrap button.draggable:hover {\n opacity: .6; \n}\n")),n.appendChild(T);const P=new AbortController,D=P.signal;yd.forEach(n=>{const i=(...e)=>t.trigger(n,...e);e.on(n,i),D.addEventListener("abort",()=>e.off?.(n,i))});const O=n.querySelector(".draggable");[...Mr,...Sr].forEach(t=>{S.addEventListener(t,t=>t.stopPropagation(),{signal:D})}),[...Mr,...Sr].forEach(t=>{n.addEventListener(t,t=>t.stopPropagation(),{signal:D})}),r&&s&&n.addEventListener("click",e=>{e.target===n&&wd.hide(t)},{signal:D});const z=t.rootModel.getOverlay?.({...t,scalable:!A||"static"==A});z?.appendChild(n),function(t,e,n,i,r){const s=t.root;if(s===t)return;xd(t);let o=vd.get(s)||[];o=[...o,[t,{div:e,scene:n,ac:i,rafId:r}]],vd.set(s,o)}(t,n,e,P,0);const L=vd.get(t.root)?.find(e=>e[0]===t)?.[1];if(d){const t=n.querySelector(".popup-title-bar .popup-title");t&&(t.textContent=d)}const I=n.querySelector(".popup-translate");if(a&&(cd(I,d?n.querySelector(".popup-title-bar"):n.querySelector(".draggable"),function(t,e){if(!(e=e||t.position)||"static"===e){const e=(t.rootModel.getOverlay(t).style.transform||"").match(/scale\(([^,\s)]+)(?:,\s*([^)]+))?\)/),n=e?parseFloat(e[1]):1;return{sx:n,sy:e&&e[2]?parseFloat(e[2]):n}}return{sx:1,sy:1}}(t,l),{signal:D}),d?O&&(O.style.display="block"):(I?.addEventListener("mouseenter",()=>{O&&(O.style.display="block")},{signal:D}),I?.addEventListener("mouseleave",()=>{O&&(O.style.display="none")},{signal:D}))),o){const t=n.querySelector(".minimizable");let e=!1;t.addEventListener("click",t=>{t.preventDefault(),e=!e;const i=n.querySelector(".popup-wrap");!function(t,e,n){const i=e.querySelector(".minimizable"),r=e.querySelector(".popup-translate");r&&(n?(i.textContent="crop_square",r.style.height="30px"):(i.textContent="minimize",r.style.height="100%"))}(0,r?i:n,e)},{signal:D}),d?t&&(t.style.display="block"):(I?.addEventListener("mouseenter",()=>{t&&(t.style.display="block")},{signal:D}),I?.addEventListener("mouseleave",()=>{t&&(t.style.display="none")},{signal:D}))}if(s){const t=n.querySelector(".closable");d?t&&(t.style.display="block"):(I?.addEventListener("mouseenter",()=>{t&&(t.style.display="block")},{signal:D}),I?.addEventListener("mouseleave",()=>{t&&(t.style.display="none")},{signal:D}))}n.querySelector(".closable")?.addEventListener("click",e=>{e.preventDefault(),wd.hide(t)},{signal:D}),n.addEventListener("close-scene",e=>{e.preventDefault(),e.stopPropagation(),wd.hide(t),c&&(t.data=e.detail)},{signal:D}),e.target=S,e.data=i||t.data,e.fit("both"),u&&(e.root.threed=!0);const{x:R,y:j}=t.center,F=t.toScene(R,j),B=r?n.querySelector(".popup-wrap"):n;M?_d({component:t,anchor:p,anchorPin:f,anchorOffset:{x:g,y:m,z:y},popupRoot:n,popupSize:{width:k,height:d?C+30:C},constantSize:b,billboard:_,tetherEnabled:v,offScreen:x,signal:D,popupEntry:L}):ad(B,A,h,F,e.root.bounds,{width:k,height:C},{title:d}),r?Object.assign(B.style,{position:"absolute",pointerEvents:"none",width:`${k}px`,height:`${d?C+30:C}px`}):Object.assign(B.style,{pointerEvents:"none",width:`${k}px`,height:`${d?C+30:C}px`});const N=function(t,e,n){const i="true"===t.dataset.perspectiveCss3d;t.style.opacity="0";const r=(t.style.transform||"").replace(/scale\([^)]+\)/,"").trim();i||(t.style.transform=`${r} scale(0)`),t.style.display="block";let s=0;const o=Date.now(),a=()=>{if(n?.aborted)return;const c=Math.min((Date.now()-o)/200,1);t.style.opacity=String(c),i||(t.style.transform=`${r} scale(${c})`.trim()),c<1?s=requestAnimationFrame(a):e&&e()};return s=requestAnimationFrame(a),s}(n,()=>{r&&(n.style.backgroundColor="rgba(0,0,0,0.3)"),L?.tether&&(L.tether.svg.style.opacity="1")},D);L&&(L.rafId=N)},t=>{ji("cannot fetch board: "+e,t)})}}class Md extends Qc{constructor(t,e){super(t,e),this._element=null,this._firstDrawReported=!1,t.translate=t.translate||{x:0,y:0},this._draw_reserved=!1,this.__draw__=()=>{this._draw_reserved=!1;const t=performance.now();this.trigger("redraw"),this.reflow(),this.draw();const e=performance.now()-t;wi.drawCount++,wi.drawTimeSum+=e,wi.drawTimeLast=e,wi.countFrame(),this._firstDrawReported||(this._firstDrawReported=!0,this.app?.loadTracker?.markFirstRender())},this.throttle_render=()=>{this._draw_reserved||requestAnimationFrame(this.__draw__),this._draw_reserved=!0}}get element(){return this._element}set element(t){this._element=t}fitSize(t,e,n,i){if(this.target){if(e){const t=getComputedStyle(this.target);n=n||(t?parseFloat(t.getPropertyValue("width")):this.target.clientWidth),i=i||(t?parseFloat(t.getPropertyValue("height")):this.target.clientHeight)}else n=this.model.width,i=this.model.height;"CANVAS"==t.tagName&&(t.setAttribute("width",n*wr),t.setAttribute("height",i*wr)),t.style.width=n+"px",t.style.height=i+"px"}}resize(){this.fitSize(this.element,!0)}isLayer(){return!0}get showOverflow(){return this.app.isEditMode}get anchors(){}createElement(){const t=Ga.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,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}get context2D(){if(!this._context2D&&(this._context2D=this.canvas&&this.canvas.getContext("2d"),this._context2D)){const t=getComputedStyle(document.documentElement),e=t.getPropertyValue("--scene-theme-font-family")?.trim()||t.fontFamily||"sans-serif";this._context2D.font=["10px",e].join(" "),this._context2D.save()}return this._context2D}getContext(t){return this._context2D||this.context2D}draw(t){this.canvas&&(t=t||this.getContext(void 0))&&(t.save(),super.draw(t),t.restore())}prerender(t){const{translate:e,scale:n={x:1,y:1},rotation:i}=this.model;t.clearRect(0,0,t.canvas.width,t.canvas.height),e&&t.translate(e.x*wr,e.y*wr),t.scale(n.x*wr,n.y*wr),i&&t.rotate(i)}get rotatePoint(){return{x:0,y:0}}contains(t,e){return!1}invalidate(){wi.invalidateCount++,this.throttle_render()}move(t){const 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 n=t.rootModel.toLocal(this.canvas.clientWidth/2,this.canvas.clientHeight/2),{x:i,y:r}=t.center,{x:s,y:o}=t.fromParent(i,r),{x:a,y:c}=t.toScene(s,o),{x:l,y:h}=t.rootModel.get("translate"),{x:d,y:u}=t.rootModel.get("scale");e?Bo({step:function(e){t.rootModel.set({translate:{x:l+(n.x-a)*d*e,y:h+(n.y-c)*u*e}})},duration:1e3,delta:"circ"}).start():t.rootModel.set({translate:{x:l+(n.x-a)*d,y:h+(n.y-c)*u}})}}class Sd extends Md{dispose(){super.dispose(),delete this._canvas,delete this._auxCanvas}createElement(){const t=document.createElement("div");return t.style.position="absolute",t.setAttribute("scene",`${this.state.type}-anchor`),t.style["user-select"]="none",t.style.overflow="hidden",this._canvas=Ga.createCanvas(1,1),this._canvas.style.position="absolute",this._canvas.style.pointerEvents="none",this._canvas.setAttribute("scene",`${this.state.type}-canvas`),t.appendChild(this._canvas),this._auxCanvas=Ga.createCanvas(1,1),this._auxCanvas.style.position="absolute",this._auxCanvas.style.pointerEvents="none",this._auxCanvas.style.zIndex="100",this._auxCanvas.setAttribute("scene",`${this.state.type}-aux-canvas`),t.appendChild(this._auxCanvas),t}resize(){if(!this.element)return;this.fitSize(this.element,!0);const t=this.element.clientWidth,e=this.element.clientHeight;this.fitSize(this.canvas,!0,t,e),this.fitSize(this.auxCanvas,!0,t,e)}get canvas(){return this._canvas}get auxCanvas(){return this._auxCanvas}get context2D(){if(!this._context2D){this._context2D=this.canvas&&this.canvas.getContext("2d");const t=getComputedStyle(document.documentElement),e=t.getPropertyValue("--scene-theme-font-family")?.trim()||t.fontFamily||"sans-serif";this._context2D.font=["10px",e].join(" "),this._context2D.save()}return this._context2D}get auxContext2D(){if(!this._auxContext2D){this._auxContext2D=this.auxCanvas&&this.auxCanvas.getContext("2d");const t=getComputedStyle(document.documentElement),e=t.getPropertyValue("--scene-theme-font-family")?.trim()||t.fontFamily||"sans-serif";this._auxContext2D.font=["10px",e].join(" "),this._auxContext2D.save()}return this._auxContext2D}getContext(t){return t?t.scalable?this.context2D:this.auxContext2D:this.context2D}draw(t){this.canvas&&this.element&&(t=t||this.getContext(void 0))&&(this.auxContext2D.clearRect(0,0,this.auxCanvas.width,this.auxCanvas.height),this.auxContext2D.save(),this.auxContext2D.scale(wr,wr),super.draw(t),this.auxContext2D.restore())}}var Ad,Ed,kd,Cd;!function(t){t.CANVAS="canvas",t.DOM="dom"}(Ad||(Ad={}));class Td{get overlay(){return this._overlay}constructor(t,e,n={}){if(this.element=null,this.isActive=!1,this._overlay=null,this.target=e,this.options={animation:!0,repeat:!0,duration:3e3,color:"#ff0000",opacity:1,fadeOut:!1,...n},this.mode=n.mode||this.determineOptimalMode(),t){this._overlay=t;vs.getInstance().addOverlay(t)}}determineOptimalMode(){return!1!==this.options.animation?Ad.DOM:Ad.CANVAS}start(){if(!this.isActive&&(this.isActive=!0,this.mode===Ad.DOM)){this.overlay?(this.createDOMElements(),this.target.on("change",this.handleTargetChange,this),this.target.on("removed",this.handleTargetRemoved,this)):(Fi("오버레이가 설정되지 않아 DOM 모드 데코레이터를 시작할 수 없습니다."),this.isActive=!1)}}stop(){this.isActive&&(this.isActive=!1,this.mode===Ad.DOM&&(this.target.off("change",this.handleTargetChange,this),this.target.off("removed",this.handleTargetRemoved,this),this.removeDOMElements()))}update(t){if(t&&(this.options={...this.options,...t},t.mode&&t.mode!==this.mode))return this.stop(),this.mode=t.mode,void this.start();this.mode===Ad.DOM&&this.isActive&&this.updateDOMElements()}render(t,e){return!(this.mode!==Ad.CANVAS||!this.isActive)&&this.renderCanvas(t,e)}removeDOMElements(){this.element&&this.element.parentNode&&(this.element.parentNode.removeChild(this.element),this.element=null)}updateDOMElements(){this.removeDOMElements(),this.createDOMElements()}getComponentPosition(){const{left:t,top:e,width:n,height:i}=this.target.bounds;if("function"==typeof this.target.toGlobal)try{const{x:r,y:s}=this.target.toGlobal(t,e,this.target.rootModel);return{x:r,y:s,width:n,height:i}}catch(t){Fi("좌표 변환 실패, 기본값 사용:",t)}return{x:t,y:e,width:n,height:i}}handleTargetChange(t,e){this.target.disposed?this.stop():this.invalidate()}handleTargetRemoved(){this.stop()}invalidate(){}}class Pd extends Td{constructor(t,e,n={}){super(t,e,{strokeWidth:2,strokeColor:"#FF0000",strokeOpacity:1,fillColor:"none",fillOpacity:.5,scale:1,rotation:0,x:0,y:0,zIndex:0,mode:Ad.DOM,...n}),this.vectorElement=null,this.animationElements=[],this.svgContainer=null,this.animationElement=null}getDecoratorType(){return this.constructor.DECORATOR_TYPE}dispose(){this.removeDOMElements()}determineOptimalMode(){return Ad.DOM}renderCanvas(t,e){return Fi("VectorDecorator는 Canvas 렌더링을 지원하지 않습니다. DOM 모드를 사용하세요."),!1}getSvgContainer(){if(!this.overlay)throw new Error("오버레이 요소가 없습니다.");if(!Pd.svgContainerCache.has(this.overlay)){const t=document.createElementNS("http://www.w3.org/2000/svg","svg");t.setAttribute("class","vector-decorator-container"),t.setAttribute("pointer-events","none"),t.style.overflow="visible",t.style.position="absolute",t.style.top="0",t.style.left="0",this.overlay.appendChild(t),Pd.svgContainerCache.set(this.overlay,t)}return Pd.svgContainerCache.get(this.overlay)}getOrCreateDecoratorGroup(t=!1){const e=this.getSvgContainer(),n=this.getVectorGroupId(),i=this.getDecoratorType();let r=e.querySelector(`g[data-decorator-type-container="${i}"]`);if(!r){r=document.createElementNS("http://www.w3.org/2000/svg","g"),r.setAttribute("data-decorator-type-container",i),r.setAttribute("class",`${i}-container`),e.appendChild(r);const t=document.createElementNS("http://www.w3.org/2000/svg","defs");t.setAttribute("data-defs-for",i),r.appendChild(t)}let s=r.querySelector(`g[data-decorator-group-id="${n}"]`);if(!s){const{id:t}=this.target.state;return s=document.createElementNS("http://www.w3.org/2000/svg","g"),s.setAttribute("data-decorator-group-id",n),s.setAttribute("data-decorator-type",i),t&&s.setAttribute("data-component-id",t),r.appendChild(s),s}if(t)for(;s.firstChild;)s.removeChild(s.firstChild);return s}getDefsForType(){const t=this.getSvgContainer(),e=this.getDecoratorType();let n=t.querySelector(`g[data-decorator-type-container="${e}"]`);n||(this.getOrCreateDecoratorGroup(),n=t.querySelector(`g[data-decorator-type-container="${e}"]`));let i=n.querySelector(`defs[data-defs-for="${e}"]`);return i||(i=document.createElementNS("http://www.w3.org/2000/svg","defs"),i.setAttribute("data-defs-for",e),n.appendChild(i)),i}getDecoratorGroup(){const t=this.getSvgContainer(),e=this.getVectorGroupId(),n=t.querySelector(`g[data-decorator-group-id="${e}"]`);if(n)return n}createFadeAnimation(t=0,e=1,n=1e3,i={}){const r=document.createElementNS("http://www.w3.org/2000/svg","animate");return r.setAttribute("attributeName","opacity"),r.setAttribute("from",t.toString()),r.setAttribute("to",e.toString()),r.setAttribute("dur",`${n}ms`),i.delay&&r.setAttribute("begin",`${i.delay}ms`),r.setAttribute("fill","freeze"),i.repeat?r.setAttribute("repeatCount","indefinite"):r.setAttribute("repeatCount","1"),r}createTranslateAnimation(t,e=[],n=1e3,i={}){const r=document.createElementNS("http://www.w3.org/2000/svg","animateTransform");return r.setAttribute("attributeName","transform"),r.setAttribute("type","translate"),r.setAttribute("values",t.join(";")),e.length>0&&r.setAttribute("keyTimes",e.join(";")),r.setAttribute("dur",`${n}ms`),i.delay&&r.setAttribute("begin",`${i.delay}ms`),i.repeat?r.setAttribute("repeatCount","indefinite"):r.setAttribute("repeatCount","1"),r}createRotateAnimation(t=0,e=360,n=0,i=0,r=1e3,s={}){const o=document.createElementNS("http://www.w3.org/2000/svg","animateTransform");return o.setAttribute("attributeName","transform"),o.setAttribute("type","rotate"),o.setAttribute("from",`${t} ${n} ${i}`),o.setAttribute("to",`${e} ${n} ${i}`),o.setAttribute("dur",`${r}ms`),s.delay&&o.setAttribute("begin",`${s.delay}ms`),s.repeat?o.setAttribute("repeatCount","indefinite"):o.setAttribute("repeatCount","1"),o}addAnimations(t,e){e.forEach(e=>{t.appendChild(e),this.animationElements.push(e)})}projectComponentPoint(t,e,n){return ld(t,e,n)}updatePosition(){if(!this.vectorElement)return;const t=this.options,{left:e,top:n}=this.target.bounds,i=this.projectComponentPoint(this.target,e,n);if(!i)return;const r=i.x+(t.x??0),s=i.y+(t.y??0);this.vectorElement.setAttribute("transform",`translate(${r}, ${s})`)}updateDOMElements(){this.createDOMElements()}getVectorGroupId(){const t=this.getDecoratorType(),{refid:e="unknown"}=this.target.state;return`decorator-${t}-${e}`}removeVectorElements(){if(this.overlay)try{const t=Pd.svgContainerCache.get(this.overlay);if(!t)return;const e=this.getVectorGroupId(),n=this.getDecoratorType(),i=t.querySelector(`g[data-decorator-type-container="${n}"]`);if(i){const t=i.querySelector(`g[data-decorator-group-id="${e}"]`);if(t&&(this.vectorElement&&(this.vectorElement===t||t.contains(this.vectorElement))&&(this.vectorElement=null),this.animationElements=this.animationElements.filter(e=>!t.contains(e)),t.remove()),!i.querySelector("g[data-decorator-group-id]")){const t=i.querySelector(`defs[data-defs-for="${n}"]`);t&&t.remove(),i.remove()}}0===t.children.length&&(t.remove(),Pd.svgContainerCache.delete(this.overlay))}catch(t){ji("벡터 요소 제거 실패:",t)}}removeDOMElements(){this.removeVectorElements()}delta(t,e){if("string"==typeof t)return"fade"===t?this.applyFadeValue(e):"theta"===t&&this.applyRotationValue(e),{tx:0,ty:0};if("object"==typeof t){const e=t;("tx"in e||"ty"in e)&&this.applyTranslateValues(e.tx||0,e.ty||0),("sx"in e||"sy"in e)&&this.applyScaleValues(e.sx||1,e.sy||1)}return null}invalidate(){this.mode===Ad.DOM&&this.isActive&&this.updateDOMElements()}touch(){}applyFadeValue(t){if(this.vectorElement){const e=t.toFixed(2);this.vectorElement.setAttribute("opacity",e)}}applyRotationValue(t){if(this.vectorElement){const e=this.getComponentBounds(),n=e.width/2,i=e.height/2,r=(180*t/Math.PI).toFixed(1);this.vectorElement.setAttribute("transform",`rotate(${r} ${n} ${i})`)}}applyTranslateValues(t,e){if(this.vectorElement){const n=this.vectorElement.getAttribute("transform")||"";if(n.includes("translate")){const i=n.replace(/translate\([^)]+\)/,`translate(${t}, ${e})`);this.vectorElement.setAttribute("transform",i)}else this.vectorElement.setAttribute("transform",`${n} translate(${t}, ${e})`.trim())}}applyScaleValues(t,e){if(this.vectorElement){const n=this.vectorElement.getAttribute("transform")||"";if(n.includes("scale")){const i=n.replace(/scale\([^)]+\)/,`scale(${t}, ${e})`);this.vectorElement.setAttribute("transform",i)}else this.vectorElement.setAttribute("transform",`${n} scale(${t}, ${e})`.trim())}}getComponentBounds(){return this.target&&this.target.bounds?this.target.bounds:{top:0,left:0,width:100,height:100}}}Pd.svgContainerCache=new WeakMap,Pd.DECORATOR_TYPE="vector";class Dd extends Td{constructor(t,e,n={}){super(t,e,{scale:1,strokeColor:"#000000",strokeWidth:1,rotation:0,shadow:!1,shadowColor:"rgba(0,0,0,0.5)",shadowBlur:5,shadowOffsetX:2,shadowOffsetY:2,...n}),this.animationId=null,this.canvasElement=null,this.context=null,this.animationFrame=null,this.deltaValue=0}determineOptimalMode(){return Ad.CANVAS}createDOMElements(){Fi("RasterDecorator는 DOM 렌더링을 지원하지 않습니다. Canvas 모드를 사용하세요.")}setAnimationState(t=3e3,e=!1){Dd.animationStateMap.set(this.target,{startTime:Date.now(),duration:t,repeat:e})}getAnimationState(){const t=Dd.animationStateMap.get(this.target);if(!t)return{delta:0,finished:!0};const{startTime:e,duration:n,repeat:i}=t,r=Date.now()-e;let s=Math.min(1,r/n),o=s>=1;return i&&o&&(Dd.animationStateMap.set(this.target,{startTime:Date.now(),duration:n,repeat:i}),s=0,o=!1),{delta:s,finished:o}}bounceEffect(t,e=10){const n=Math.min(1,4*t);return Math.sin(n*Math.PI*10)*e*(1-n)}fadeEffect(t,e=!1){return e?t:1-t}pulseEffect(t,e=.8,n=1.2){return e+(.5*Math.sin(t*Math.PI*2)+.5)*(n-e)}rotateEffect(t,e=360){return t*e}applyShadowEffect(t){if(this.options.shadow){const e=this.options;t.shadowColor=e.shadowColor||"rgba(0,0,0,0.5)",t.shadowBlur=e.shadowBlur||5,t.shadowOffsetX=e.shadowOffsetX||2,t.shadowOffsetY=e.shadowOffsetY||2}}removeShadowEffect(t){t.shadowColor="transparent",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0}start(){super.start(),this.isActive&&this.options.animation&&this.setAnimationState(this.options.duration||3e3,this.options.repeat||!1)}stop(){null!==this.animationFrame&&(cancelAnimationFrame(this.animationFrame),this.animationFrame=null),super.stop(),Dd.animationStateMap.delete(this.target)}applyTransform(t,e,n){const i=this.options,r=i.scale||1,s=i.rotation||0;if(1!==r||0!==s){if(t.translate(e,n),0!==s){const e=s*Math.PI/180;t.rotate(e)}1!==r&&t.scale(r,r),t.translate(-e,-n)}}delta(t,e){return"string"==typeof t?("fade"===t?(this.deltaValue=e,this.context&&(this.context.globalAlpha=e)):"theta"===t&&(this.deltaValue=e),{tx:0,ty:0}):null}invalidate(){this.context&&this.isActive&&(this.animationFrame||(this.animationFrame=requestAnimationFrame(()=>{this.animationFrame=null,this.renderCanvas(this.context,this.deltaValue)})))}touch(){this.deltaValue=0}}Dd.animationStateMap=new WeakMap;class Od extends Pd{constructor(t,e,n={}){super(t,e,{size:1,showId:!1,animation:!1,...n}),this.arrowElement=null,this.labelElement=null,this.decoratorGroup=null}createDOMElements(){if(this.overlay)try{const t=this.getOrCreateDecoratorGroup(!0);this.decoratorGroup=t,t.setAttribute("transform","translate(0, 0)");const{size:e=1,showId:n=!1,duration:i=3e3,repeat:r=!0}=this.options,s=this.options.color||"#FF0000",o=document.createElementNS("http://www.w3.org/2000/svg","path");o.setAttribute("d",this.createArrowPath(0,0,e)),o.setAttribute("fill",s),o.setAttribute("stroke",s),o.setAttribute("stroke-width","1"),o.setAttribute("class","bouncing-arrow");const a=[];if(this.options.animation){const t=this.createBounceAnimation(i,r);if(a.push(t),this.options.fadeOut){const t=this.createFadeAnimation(1,0,i,{repeat:r});a.push(t)}}if(this.addAnimations(o,a),t.appendChild(o),this.arrowElement=o,n&&this.target.state?.id){const n=this.createArrowLabel(0,0,s,this.target.state.id,e);if(this.options.animation){const t=[],e=this.createBounceAnimation(i,r);if(t.push(e),this.options.fadeOut){const e=this.createFadeAnimation(1,0,i,{repeat:r});t.push(e)}this.addAnimations(n,t)}t.appendChild(n),this.labelElement=n}this.vectorElement=t,this.updatePosition(),this.options.animation&&this.startAnimations()}catch(t){ji("화살표 SVG 요소 생성 실패:",t)}}createArrowPath(t,e,n=1){const i=n/this.getScale();return`\n M${t-10*i},${e-16*i} \n L${t+10*i},${e-16*i} \n L${t+10*i},${e-8*i} \n L${t+16*i},${e-8*i} \n L${t},${e} \n L${t-16*i},${e-8*i} \n L${t-10*i},${e-8*i} \n Z\n `}getScale(){try{if(this.target.rootModel&&"number"==typeof this.target.rootModel.scale)return this.target.rootModel.scale||1}catch(t){Fi("스케일 계산 실패, 기본값 사용",t)}return 1}createBounceAnimation(t,e){const n=["0,-10"],i=["0"];for(let t=1;t<=20;t++){const e=t/20;let r=Math.pow(e,.5).toFixed(3);parseFloat(i[i.length-1])>=parseFloat(r)&&(r=(parseFloat(i[i.length-1])+.01).toFixed(3)),n.push("0,0"),n.push("0,-10"),i.push(r),i.push((parseFloat(r)+.01).toFixed(3))}return i[i.length-1]="1.000",this.createTranslateAnimation(n,i,t,{repeat:e})}createArrowLabel(t,e,n,i,r=1){const s=document.createElementNS("http://www.w3.org/2000/svg","g");s.setAttribute("class","bouncing-arrow-label");const o=document.createElementNS("http://www.w3.org/2000/svg","rect");o.setAttribute("x",`${t+20*r}`),o.setAttribute("y",""+(e-20*r)),o.setAttribute("width",""+40*r),o.setAttribute("height",""+20*r),o.setAttribute("rx","3"),o.setAttribute("fill",n);const a=document.createElementNS("http://www.w3.org/2000/svg","text");return a.setAttribute("x",`${t+40*r}`),a.setAttribute("y",""+(e-6*r)),a.setAttribute("fill","white"),a.setAttribute("font-size",12*r+"px"),a.setAttribute("text-anchor","middle"),a.textContent=i,s.appendChild(o),s.appendChild(a),s}startAnimations(){setTimeout(()=>{this.animationElements.forEach(t=>{try{t instanceof SVGElement&&"beginElement"in t&&t.beginElement()}catch(t){ji("애니메이션 시작 오류:",t)}})},10)}invalidate(){this.updatePosition()}updatePosition(){if(!this.vectorElement)return;const{left:t,top:e,width:n}=this.target.bounds,i=this.projectComponentPoint(this.target,t+n/2,e);if(!i)return;const r=Math.max(i.x,20),s=Math.max(i.y,20);this.vectorElement.setAttribute("transform",`translate(${r}, ${s})`)}}Od.DECORATOR_TYPE="bouncing-arrow",function(t){t.ROTATE="rotate",t.TRANSLATE_X="translateX",t.TRANSLATE_Y="translateY",t.SCALE="scale",t.FADE="fade"}(Ed||(Ed={})),function(t){t.VIBRATION="vibration",t.ROTATION="rotation",t.HEARTBEAT="heartbeat",t.MOVING="moving",t.OUTLINE="outline",t.FADE="fade",t.WAYPOINT="waypoint"}(kd||(kd={})),function(t){t.CENTER="center",t.TOP="top",t.RIGHT="right",t.BOTTOM="bottom",t.LEFT="left",t.TOP_RIGHT="top-right",t.BOTTOM_RIGHT="bottom-right",t.BOTTOM_LEFT="bottom-left",t.TOP_LEFT="top-left",t.TOP_LEFT_CORNER="top-left-corner",t.TOP_RIGHT_CORNER="top-right-corner",t.BOTTOM_LEFT_CORNER="bottom-left-corner",t.BOTTOM_RIGHT_CORNER="bottom-right-corner",t.LEFT_TOP="left-top",t.LEFT_BOTTOM="left-bottom",t.RIGHT_TOP="right-top",t.RIGHT_BOTTOM="right-bottom"}(Cd||(Cd={}));class zd extends Pd{constructor(t,e,n={}){const{animations:i,...r}=n;super(t,e,{icon:"arrow_forward",size:24,color:"#FF0000",deltaX:0,deltaY:0,...r}),this.animations=[],this._location=null,this.element=null,this._delta={theta:0,tx:0,ty:0,sx:1,sy:1,fade:0},this.animations=this.createAnimations(i)}delta(t,e){if(!t)return this._delta;switch(typeof t){case"object":this._delta={...this._delta,...t};break;case"string":if(void 0===e)return this._delta[t];this._delta[t]=e}const{tx:n,ty:i,sx:r,sy:s,theta:o,fade:a}=this._delta;return this.element&&Object.assign(this._getElement().style,{opacity:1-a,transform:`rotate(${o}rad) translate(${n}px, ${i}px) scale(${r}, ${s}) perspective(1px)`}),this._delta}getScaledSize(){const t=this.options.size||24,{x:e}=this.target.rootModel?.state.scale||{x:1},{x:n}=this.target.state.scale||{x:1};return t*e*n}get location(){if(this._location)return this._location;const{location:t,position:e,size:n}=this.options,{bounds:i}=this.target,{left:r,top:s,width:o,height:a}=i,c=n/2;let l;switch(e||t||Cd.CENTER){case Cd.TOP_LEFT:case"top-left":l={x:r,y:s-n};break;case Cd.TOP:case"top":l={x:r+(o-n)/2,y:s-n};break;case Cd.TOP_RIGHT:case"top-right":l={x:r+o-n,y:s-n};break;case Cd.BOTTOM_LEFT:case"bottom-left":l={x:r,y:s+a};break;case Cd.BOTTOM:case"bottom":l={x:r+(o-n)/2,y:s+a};break;case Cd.BOTTOM_RIGHT:case"bottom-right":l={x:r+o-n,y:s+a};break;case Cd.LEFT_TOP:case"left-top":l={x:r-n,y:s};break;case Cd.LEFT:case"left":l={x:r-n,y:s+(a-n)/2};break;case Cd.LEFT_BOTTOM:case"left-bottom":l={x:r-n,y:s+(a-n)};break;case Cd.RIGHT_TOP:case"right-top":l={x:r+o,y:s};break;case Cd.RIGHT:case"right":l={x:r+o,y:s+(a-n)/2};break;case Cd.RIGHT_BOTTOM:case"right-bottom":l={x:r+o,y:s+(a-n)};break;case Cd.TOP_LEFT_CORNER:case"top-left-corner":l={x:r-c,y:s-c};break;case Cd.TOP_RIGHT_CORNER:case"top-right-corner":l={x:r+o-c,y:s-c};break;case Cd.BOTTOM_LEFT_CORNER:case"bottom-left-corner":l={x:r-c,y:s+a-c};break;case Cd.BOTTOM_RIGHT_CORNER:case"bottom-right-corner":l={x:r+o-c,y:s+a-c};break;case Cd.CENTER:default:l={x:r+o/2-n/2,y:s+a/2-n/2}}return this._location=this.toGlobal(l.x,l.y),this._location}_getElement(){return this.element||this._createElementIfNeeded(),this.element}_createElementIfNeeded(){if(this.element)return;const{icon:t="arrow_forward",color:e="#FF0000"}=this.options,n=this.getScaledSize(),{x:i,y:r}=this.location,s=document.createElement("div");s.setAttribute("scene","animated-icon"),Object.assign(s.style,{position:"absolute",fontVariationSettings:"'FILL' 1",fontFamily:"Material Symbols Outlined",fontSize:n+"px",width:n+"px",height:n+"px",lineHeight:n+"px",padding:0,margin:0,color:e,textAlign:"center",verticalAlign:"middle",left:i+"px",top:r+"px",pointerEvents:"none"}),s.textContent=t,this.element=s}updateIconSizeAndPosition(){if(!this.element)return;this._location=null;const t=this.getScaledSize(),{x:e,y:n}=this.location;Object.assign(this.element.style,{fontSize:t+"px",width:t+"px",height:t+"px",lineHeight:t+"px",left:e+"px",top:n+"px"})}touch(){}invalidate(){this.updateIconSizeAndPosition()}start(){if(super.start(),this.isActive){if(this.overlay&&this._getElement().parentNode!==this.overlay&&this.overlay.appendChild(this._getElement()),this.target?.root?.app?.suppressAnimations)return;this.animations.forEach(t=>t.start())}}stop(){this.animations.forEach(t=>t.stop()),this.element&&this._getElement().parentNode&&this._getElement().parentNode.removeChild(this._getElement()),this._location=null,super.stop()}get center(){const t=this.getScaledSize(),{x:e,y:n}=this.location;return{x:e+t/2,y:n+t/2}}toGlobal(t,e){const{tx:n,ty:i}=this._delta;return this.projectComponentPoint(this.target,t+n,e+i)??this.target.toGlobal(t+n,e+i)}get root(){return this.target.root}createDOMElements(){this._getElement()}updateDOMElements(){this.element?this.updateIconSizeAndPosition():this._getElement()}updatePosition(){this.updateIconSizeAndPosition()}createAnimations(t){if(Array.isArray(t))return t.map(t=>("theta"in t&&(t={...t,theta:t.theta*(Math.PI/180)}),Yo(this,t)));if(t){const e={...t};return"theta"in e&&(e.theta=e.theta*(Math.PI/180)),[Yo(this,e)]}return[]}}zd.DECORATOR_TYPE="animated-icon";class Ld extends Pd{constructor(t,e,n={}){super(t,e,{distance:10,lineWidth:2,fillStyle:"rgba(0, 0, 0, 0.5)",animation:!1,...n}),this.pathElement=null,this.decoratorGroup=null,this.elementId=""}createDOMElements(){if(this.overlay)try{this.getSvgContainer();const t=this.getOrCreateDecoratorGroup(!0);this.decoratorGroup=t;const e=this.getDefsForType(),n=this.getVectorGroupId();this.elementId=`${n}-border`;const{color:i="#FF0000",animation:r=!1}=this.options,{fillStyle:s}=this.target.state||{},o=this.createFilter(this.elementId,this.options.fillStyle||s||"rgba(0, 0, 0, 0.5)");if(e.appendChild(o),r){const t=this.createGradient(this.elementId,i);e.appendChild(t)}const a=document.createElementNS("http://www.w3.org/2000/svg","path");a.setAttribute("fill","none"),a.setAttribute("stroke-width",(this.options.lineWidth||2).toString()),a.setAttribute("stroke-linejoin","round"),a.setAttribute("pointer-events","none"),a.setAttribute("class","border-highlighting-path"),a.setAttribute("filter",`url(#${this.elementId}-filter)`),r?a.setAttribute("stroke",`url(#${this.elementId})`):a.setAttribute("stroke",i),t.appendChild(a),this.pathElement=a,this.vectorElement=t,this.updatePathData(),this.options.animation&&this.startAnimations()}catch(t){ji("테두리 하이라이팅 요소 생성 실패:",t)}}updatePathData(){if(!this.pathElement)return;this.pathElement.setAttribute("visibility","visible"),this.pathElement.setAttribute("opacity","1"),this.decoratorGroup&&(this.decoratorGroup.setAttribute("visibility","visible"),this.decoratorGroup.setAttribute("opacity","1"));const t=this.getPathPoints(),e=this.createOffsetPath(t,this.options.distance),{round:n=0}=this.target.state||{},i=this.pointsToPathData(e,n);this.pathElement.setAttribute("d",i)}invalidate(){this.updatePathData()}startAnimations(){if(!this.isActive||!this.options.animation||!this.pathElement)return;this.pathElement.setAttribute("visibility","visible"),this.pathElement.setAttribute("opacity","1"),this.decoratorGroup&&(this.decoratorGroup.setAttribute("visibility","visible"),this.decoratorGroup.setAttribute("opacity","1")),this.elementId&&(this.pathElement.setAttribute("stroke",`url(#${this.elementId})`),this.pathElement.setAttribute("filter",`url(#${this.elementId}-filter)`));const t=this.getDefsForType();if(t){const e=t.querySelector(`#${this.elementId}`);if(e){e.querySelectorAll("animate").forEach(t=>{try{t instanceof SVGElement&&"beginElement"in t&&(t.setAttribute("restart","always"),t.beginElement())}catch(t){ji("애니메이션 시작 오류:",t)}})}}}createDefsElement(t){const e=document.createElementNS("http://www.w3.org/2000/svg","defs");return t.appendChild(e),e}getPathPoints(){if(!this.target.path||!Array.isArray(this.target.path)){const{left:t,top:e,width:n,height:i}=this.target.bounds;return[{x:t,y:e},{x:t+n,y:e},{x:t+n,y:e+i},{x:t,y:e+i}]}return this.target.path.map(t=>this.target.toGlobal(t.x,t.y))}createOffsetPath(t,e){const n=[],i=t.length;for(let r=0;r<i;r++){const s=t[(r-1+i)%i],o=t[r],a=t[(r+1)%i],c=o.x-s.x,l=o.y-s.y,h=a.x-o.x,d=a.y-o.y,u=this.normalize({x:l,y:-c}),p=this.normalize({x:d,y:-h}),f=this.normalize({x:(u.x+p.x)/2,y:(u.y+p.y)/2}),g={x:o.x+f.x*e,y:o.y+f.y*e};n.push(g)}return n}normalize(t){const e=Math.sqrt(t.x*t.x+t.y*t.y);return{x:t.x/e||0,y:t.y/e||0}}pointsToPathData(t,e=0){if(t.length<2)return"";let n="";const i=t.length,r=(t,e,n)=>{const i=e.x-t.x,r=e.y-t.y,s=Math.sqrt(i*i+r*r);return{x:t.x+i/s*n,y:t.y+r/s*n}};for(let s=0;s<i;s++){const o=t[s],a=t[(s+1)%i],c=t[(s-1+i)%i],l=Math.sqrt((o.x-c.x)**2+(o.y-c.y)**2),h=Math.sqrt((o.x-a.x)**2+(o.y-a.y)**2),d=Math.min(e,l/2,h/2),u=r(o,c,d),p=r(o,a,d);n+=0===s?`M${u.x},${u.y}`:` L${u.x},${u.y}`,n+=` Q${o.x},${o.y} ${p.x},${p.y}`}return n+=" Z",n}createFilter(t,e){const n=document.createElementNS("http://www.w3.org/2000/svg","filter");n.setAttribute("id",`${t}-filter`);const i=document.createElementNS("http://www.w3.org/2000/svg","feFlood");i.setAttribute("flood-color",e),i.setAttribute("result","flood");const r=document.createElementNS("http://www.w3.org/2000/svg","feComposite");r.setAttribute("in","flood"),r.setAttribute("in2","SourceAlpha"),r.setAttribute("operator","in"),r.setAttribute("result","mask");const s=document.createElementNS("http://www.w3.org/2000/svg","feMerge"),o=document.createElementNS("http://www.w3.org/2000/svg","feMergeNode");o.setAttribute("in","mask");const a=document.createElementNS("http://www.w3.org/2000/svg","feMergeNode");return a.setAttribute("in","SourceGraphic"),s.appendChild(o),s.appendChild(a),n.appendChild(i),n.appendChild(r),n.appendChild(s),n}createGradient(t,e){const n=document.createElementNS("http://www.w3.org/2000/svg","linearGradient");n.setAttribute("id",t),n.setAttribute("x1","0%"),n.setAttribute("y1","0%"),n.setAttribute("x2","100%"),n.setAttribute("y2","0%");const i=this.alterColor(e,120),r=this.alterColor(e,240),s=document.createElementNS("http://www.w3.org/2000/svg","stop");s.setAttribute("offset","0%"),s.setAttribute("stop-color",e);const o=document.createElementNS("http://www.w3.org/2000/svg","animate");o.setAttribute("attributeName","stop-color"),o.setAttribute("values",`${e};${i};${r};${e}`),o.setAttribute("dur","5s"),o.setAttribute("repeatCount","indefinite");const a=document.createElementNS("http://www.w3.org/2000/svg","stop");a.setAttribute("offset","100%"),a.setAttribute("stop-color",r);const c=document.createElementNS("http://www.w3.org/2000/svg","animate");return c.setAttribute("attributeName","stop-color"),c.setAttribute("values",`${r};${e};${i};${r}`),c.setAttribute("dur","5s"),c.setAttribute("repeatCount","indefinite"),s.appendChild(o),a.appendChild(c),n.appendChild(s),n.appendChild(a),n}alterColor(t,e){const n=this.convertToHex(t),i=parseInt(n.substring(1,3),16),r=parseInt(n.substring(3,5),16),s=parseInt(n.substring(5,7),16),o=this.rgbToHsl(i,r,s);o[0]=(o[0]+e/360)%1;const a=this.hslToRgb(o[0],o[1],o[2]);return`#${a[0].toString(16).padStart(2,"0")}${a[1].toString(16).padStart(2,"0")}${a[2].toString(16).padStart(2,"0")}`}rgbToHsl(t,e,n){t/=255,e/=255,n/=255;const i=Math.max(t,e,n),r=Math.min(t,e,n);let s=0,o=0;const a=(i+r)/2;if(i!==r){const c=i-r;switch(o=a>.5?c/(2-i-r):c/(i+r),i){case t:s=(e-n)/c+(e<n?6:0);break;case e:s=(n-t)/c+2;break;case n:s=(t-e)/c+4}s/=6}return[s,o,a]}hslToRgb(t,e,n){let i,r,s;if(0===e)i=r=s=n;else{const o=(t,e,n)=>(n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+6*(e-t)*n:n<.5?e:n<2/3?t+(e-t)*(2/3-n)*6:t),a=n<.5?n*(1+e):n+e-n*e,c=2*n-a;i=o(c,a,t+1/3),r=o(c,a,t),s=o(c,a,t-1/3)}return[Math.round(255*i),Math.round(255*r),Math.round(255*s)]}convertToHex(t){if(/^#([0-9A-F]{6})$/i.test(t))return t;const e=document.createElement("canvas");e.width=1,e.height=1;const n=e.getContext("2d");if(!n)return"#FF0000";n.fillStyle=t,n.fillRect(0,0,1,1);const i=n.getImageData(0,0,1,1).data;return`#${i[0].toString(16).padStart(2,"0")}${i[1].toString(16).padStart(2,"0")}${i[2].toString(16).padStart(2,"0")}`}start(){super.start(),this.isActive&&this.options.animation&&this.startAnimations()}removeDOMElements(){try{if(this.pathElement&&this.pathElement.parentNode&&this.pathElement.parentNode.removeChild(this.pathElement),this.pathElement=null,this.overlay){const t=this.getDefsForType();if(t&&this.elementId){const e=t.querySelector(`#${this.elementId}-filter`);e&&e.remove();const n=t.querySelector(`#${this.elementId}`);n&&n.remove()}}super.removeDOMElements()}catch(t){ji("테두리 하이라이팅 요소 제거 중 오류:",t)}}}Ld.DECORATOR_TYPE="border-highlighting";class Id extends Pd{constructor(t,e,n={}){super(t,e,{bgColor:"#FF0000",textColor:"white",cornerRadius:3,padding:3,fontSize:"12px",fontFamily:"Arial",...n}),this.textElements=[],this.rectElements=[]}updateDOMElements(){if(!this.target.anchors||!this.target.anchors.length)return void this.removeDOMElements();const t=this.options,e=this.target.anchors,n=this.getOrCreateDecoratorGroup(!0);this.textElements=[],this.rectElements=[];const i=this.getComponentBounds();e.forEach(e=>{const{name:r,position:s}=e;let{x:o,y:a}=s||{};if(!r)return;let c=this.calculateOffsetX(o,i),l=this.calculateOffsetY(a,i);const h=this.projectComponentPoint(this.target,o,a);if(!h)return;o=h.x,a=h.y;const d=document.createElementNS("http://www.w3.org/2000/svg","text");d.setAttribute("fill",t.textColor),d.setAttribute("font-family",t.fontFamily),d.setAttribute("font-size",t.fontSize),d.textContent=r,n.appendChild(d);const u=d.getBBox();n.removeChild(d);const p=u.width,f=u.height;c=-1==c?-p-9:3,l=-1==l?-f-9:3,d.setAttribute("x",(o+c+3).toString()),d.setAttribute("y",(a+l+f).toString());const g=document.createElementNS("http://www.w3.org/2000/svg","rect");g.setAttribute("x",(o+c).toString()),g.setAttribute("y",(a+l).toString()),g.setAttribute("width",(p+6).toString()),g.setAttribute("height",(f+6).toString()),g.setAttribute("rx",t.cornerRadius.toString()),g.setAttribute("ry",t.cornerRadius.toString()),g.setAttribute("fill",t.bgColor),n.appendChild(g),n.appendChild(d),this.rectElements.push(g),this.textElements.push(d)})}calculateOffsetX(t,e){return t<e.left+1?-1:1}calculateOffsetY(t,e){return t<e.top+1?-1:1}updatePosition(){super.updatePosition(),this.updateDOMElements()}invalidate(){this.updatePosition()}createDOMElements(){this.updateDOMElements()}}Id.DECORATOR_TYPE="anchors";class Rd extends Pd{constructor(t,e,n={}){super(t,e,{bgColor:"#FF0000",textColor:"white",cornerRadius:3,padding:3,fontSize:"12px",fontFamily:"Arial",offsetX:3,offsetY:-8,animation:!1,...n}),this.textElement=null,this.backgroundElement=null,this.currentTag=""}createDOMElements(){const t=this.target.decotag;if(!t)return;this.currentTag=t;const{fontFamily:e,fontSize:n,textColor:i,padding:r,cornerRadius:s,bgColor:o,animation:a,repeat:c,duration:l}=this.options,h=this.getOrCreateDecoratorGroup(!0);h.setAttribute("transform","translate(0, 0)"),this.textElement=document.createElementNS("http://www.w3.org/2000/svg","text"),this.textElement.textContent=t,this.textElement.setAttribute("x",`${r}`),this.textElement.setAttribute("y",`-${n}`),this.textElement.setAttribute("font-family",e),this.textElement.setAttribute("font-size",n),this.textElement.setAttribute("fill",i),this.textElement.setAttribute("dominant-baseline","middle"),h.appendChild(this.textElement);const d=this.textElement.getBBox();if(this.backgroundElement=document.createElementNS("http://www.w3.org/2000/svg","rect"),this.backgroundElement.setAttribute("x",(d.x-r).toString()),this.backgroundElement.setAttribute("y",(d.y-r).toString()),this.backgroundElement.setAttribute("width",(d.width+2*r).toString()),this.backgroundElement.setAttribute("height",(d.height+2*r).toString()),this.backgroundElement.setAttribute("rx",s.toString()),this.backgroundElement.setAttribute("ry",s.toString()),this.backgroundElement.setAttribute("fill",o),h.replaceChildren(),h.appendChild(this.backgroundElement),h.appendChild(this.textElement),a){const t=this.createFadeAnimation(.3,1,l,{repeat:c});this.addAnimations(h,[t])}this.vectorElement=h,this.updatePosition()}updateDOMElements(){const t=this.target.decotag;t&&t===this.currentTag?this.vectorElement&&this.updatePosition():(this.removeDOMElements(),this.createDOMElements())}updatePosition(){super.updatePosition()}invalidate(){this.updatePosition()}}Rd.DECORATOR_TYPE="decotag";class jd extends Pd{constructor(t,e,n={}){super(t,e,{arrowColor:"#FFA500",arrowHeadLength:12,lineWidth:1.5,startAlpha:.6,endAlpha:1,animated:!0,animationDuration:5e3,repeat:!1,...n}),this.currentMappings=null,this.cachedArrows=[],this._incomingTimer=null}findIncomingSources(){const t=this.target.root;if(!t)return[];const e=this.target.state?.id;if(!e)return[];const n=[];return t.traverse(i=>{if(i===this.target)return;const r=i.model?.mappings;if(r)for(const s of r){if(!s.target)continue;if(s.target===`#${e}`){n.push({from:i,to:this.target});break}const r=t.findAll(s.target,i);if(r?.some(t=>t===this.target)){n.push({from:i,to:this.target});break}}}),n}appendArrow(t,e,n,i,r,s){const o=e.center,a=n.center,c=this.projectComponentPoint(e,o.x,o.y),l=this.projectComponentPoint(n,a.x,a.y);if(!c||!l)return;const{linePath:h,headPath:d}=this.createArrowPaths(c,l,s.arrowHeadLength),u=document.createElementNS("http://www.w3.org/2000/svg","path");u.setAttribute("d",h),u.setAttribute("stroke",r),u.setAttribute("stroke-width",String(s.lineWidth||2)),u.setAttribute("fill","none"),u.setAttribute("data-source-id",e.state?.id||""),u.setAttribute("data-target-id",n.state?.id||"");const p=document.createElementNS("http://www.w3.org/2000/svg","path");p.setAttribute("d",d),p.setAttribute("fill",i),p.setAttribute("stroke","none"),t.appendChild(u),t.appendChild(p)}createDOMElements(){this.removeDOMElements();const t=this.target.mappings&&this.target.mappings.length>0;this.currentMappings=this.target.mappings;const e=this.options,n=e.arrowColor||"#FFA500",i=this.getOrCreateDecoratorGroup(!0),r=this.getDefsForType(),s=`data-spread-style-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,o=document.createElementNS("http://www.w3.org/2000/svg","style");o.setAttribute("id",s),o.textContent=`\n @keyframes fadeOut {\n from { opacity: 1; }\n to { opacity: ${e.repeat?"0.2":"0"}; }\n }\n .arrow-animated {\n animation: fadeOut ${e.animationDuration||2e3}ms linear ${e.repeat?"infinite":"1"} forwards;\n }\n `,r.appendChild(o);const a=Date.now(),c=Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15),l=`arrow-gradient-out-${a}-${c}`,h=this.createGradient(l,n,e);r.appendChild(h);const d=jd.INCOMING_ARROW_COLOR,u=`arrow-gradient-in-${a}-${c}`,p=this.createGradient(u,d,e);r.appendChild(p);const f=document.createElementNS("http://www.w3.org/2000/svg","g");if(f.setAttribute("class",e.animated?"arrow-animated":""),i.appendChild(f),this.cachedArrows=[],t){this.target.mappings.forEach(t=>{const i=this.target.root.findAll(t.target,this.target);i?.length&&i.forEach(t=>{t!==this.target&&(this.cachedArrows.push({from:this.target,to:t}),this.appendArrow(f,this.target,t,n,`url(#${l})`,e))})})}this.vectorElement=i,this._incomingTimer=setTimeout(()=>{if(this._incomingTimer=null,!this.vectorElement)return;this.findIncomingSources().forEach(({from:t})=>{this.cachedArrows.push({from:t,to:this.target}),this.appendArrow(f,t,this.target,d,`url(#${u})`,e)})},jd.INCOMING_DEBOUNCE_MS)}createGradient(t,e,n){const i=document.createElementNS("http://www.w3.org/2000/svg","linearGradient");i.setAttribute("id",t),i.setAttribute("gradientUnits","userSpaceOnUse");const r=document.createElementNS("http://www.w3.org/2000/svg","stop");r.setAttribute("offset","0%"),r.setAttribute("stop-color",e),r.setAttribute("stop-opacity",(n.startAlpha||.5).toString());const s=document.createElementNS("http://www.w3.org/2000/svg","stop");return s.setAttribute("offset","100%"),s.setAttribute("stop-color",e),s.setAttribute("stop-opacity",(n.endAlpha||1).toString()),i.appendChild(r),i.appendChild(s),i}createArrowPaths(t,e,n){const i=e.x-t.x,r=e.y-t.y,s=Math.atan2(r,i),o=e.x+n*Math.cos(s+jd.ARROW_ANGLE_1),a=e.y+n*Math.sin(s+jd.ARROW_ANGLE_1),c=e.x+n*Math.cos(s+jd.ARROW_ANGLE_2),l=e.y+n*Math.sin(s+jd.ARROW_ANGLE_2);return{linePath:`M ${t.x} ${t.y} L ${e.x} ${e.y}`,headPath:`M ${e.x} ${e.y} L ${o} ${a} L ${c} ${l} Z`}}updateDOMElements(){if(!this.target.app?.isEditMode)return void this.removeDOMElements();this.target.mappings!==this.currentMappings?(this.removeDOMElements(),requestAnimationFrame(()=>{this.createDOMElements()})):this.vectorElement&&this.updatePosition()}updatePosition(){const t=this.getDecoratorType(),e=this.getSvgContainer().querySelector(`g[data-decorator-type-container="${t}"]`);if(!e)return;const n=this.getVectorGroupId(),i=e.querySelector(`g[data-decorator-group-id="${n}"]`);if(!i)return;const r=this.options,s=i.querySelector("g.arrow-animated")||i,o=Array.from(s.querySelectorAll('path[fill="none"]')),a=Array.from(s.querySelectorAll('path[stroke="none"]'));if(0===o.length)return;const c=Math.min(o.length,a.length,this.cachedArrows.length);for(let t=0;t<c;t++){const{from:e,to:n}=this.cachedArrows[t],i=e.center,s=n.center,c=this.projectComponentPoint(e,i.x,i.y),l=this.projectComponentPoint(n,s.x,s.y);if(!c||!l)continue;const{linePath:h,headPath:d}=this.createArrowPaths(c,l,r.arrowHeadLength);o[t].setAttribute("d",h),a[t].setAttribute("d",d)}}removeDOMElements(){this.currentMappings=null,this.cachedArrows=[],this._incomingTimer&&(clearTimeout(this._incomingTimer),this._incomingTimer=null);try{if(this.overlay){const t=this.getSvgContainer();if(t){const e=this.getDecoratorType(),n=t.querySelector(`g[data-decorator-type-container="${e}"]`);if(n){const t=n.querySelector(`defs[data-defs-for="${e}"]`);if(t){t.querySelectorAll("style").forEach(t=>t.remove());t.querySelectorAll("linearGradient").forEach(t=>t.remove())}}}}this.animationElements=[],super.removeDOMElements()}catch(t){ji("데이터 스프레드 데코레이터 요소 제거 중 오류:",t)}}invalidate(){this.updatePosition()}}jd.DECORATOR_TYPE="data-spread",jd.ARROW_ANGLE_1=160*Math.PI/180,jd.ARROW_ANGLE_2=200*Math.PI/180,jd.INCOMING_ARROW_COLOR="#4A9EFF",jd.INCOMING_DEBOUNCE_MS=500;class Fd extends Pd{constructor(t,e,n={}){super(t,e,{bgColor:"#FF0000",textColor:"white",cornerRadius:2,padding:2,fontSize:"12px",fontFamily:"Arial",offsetX:4,offsetY:4,...n}),this.textElements=[],this.rectElements=[]}createDOMElements(){this.updateDOMElements()}updateDOMElements(){if(!this.target.isLine||!this.target.isLine())return void this.removeDOMElements();const{offsetX:t,offsetY:e,padding:n,textColor:i,bgColor:r,cornerRadius:s,fontSize:o,fontFamily:a}=this.options,c=this.getOrCreateDecoratorGroup(!0);this.textElements=[],this.rectElements=[];const{fromEnd:l,toEnd:h}=this.target;[l,h].filter(Boolean).forEach(l=>{const{component:h,anchor:d}=l;if(!d)return;const{name:u,position:p}=d||{};if(!h.rootModel||!u||!p)return;const f=this.projectComponentPoint(h,p.x,p.y);if(!f)return;let{x:g,y:m}=f;const y=document.createElementNS("http://www.w3.org/2000/svg","g"),b=document.createElementNS("http://www.w3.org/2000/svg","text");b.setAttribute("text-anchor","middle"),b.setAttribute("dominant-baseline","middle"),b.setAttribute("x","0"),b.setAttribute("y","0"),b.setAttribute("fill",i),b.setAttribute("font-family",a),b.setAttribute("font-size",o),b.textContent=u,c.appendChild(b);const _=b.getBBox();c.removeChild(b);const v=document.createElementNS("http://www.w3.org/2000/svg","rect"),x=_.width+2*(n??0),w=_.height+2*(n??0);g+=(t??0)+x/2,m+=(e??0)+w/2,v.setAttribute("x",(-x/2).toString()),v.setAttribute("y",(-w/2).toString()),v.setAttribute("width",x.toString()),v.setAttribute("height",w.toString()),v.setAttribute("rx",(s??0).toString()),v.setAttribute("ry",(s??0).toString()),v.setAttribute("fill",r),y.appendChild(v),y.appendChild(b),y.setAttribute("transform",`translate(${g}, ${m})`),c.appendChild(y),this.rectElements.push(v),this.textElements.push(b)})}updatePosition(){super.updatePosition(),this.updateDOMElements()}invalidate(){this.updatePosition()}}Fd.DECORATOR_TYPE="link",_s.registerDecorator("bouncing-arrow",Od),_s.registerDecorator("animated-icon",zd),_s.registerDecorator("border-highlighting",Ld),_s.registerDecorator("anchors",Id),_s.registerDecorator("decotag",Rd),_s.registerDecorator("data-spread",jd),_s.registerDecorator("link",Fd);let Bd=0,Nd=0,Hd=0,Yd=null;function Gd(){Hd++;const t=performance.now(),e=t-Nd;e>=1e3&&(Bd=Math.round(1e3*Hd/e),Nd=t,Hd=0),Yd=requestAnimationFrame(Gd)}function Vd(){null!==Yd&&(cancelAnimationFrame(Yd),Yd=null)}function Ud(){return null===Yd&&(Nd=performance.now(),Hd=0,Yd=requestAnimationFrame(Gd)),Bd}const $d=function(){const t=document.createElement("canvas").getContext("2d");return(window.devicePixelRatio||1)/(t.webkitBackingStorePixelRatio||t.mozBackingStorePixelRatio||t.msBackingStorePixelRatio||t.oBackingStorePixelRatio||t.backingStorePixelRatio||1)}();function Wd(t,e){const n=document.createElement("canvas");return n.width=t,n.height=e,n.style.width=t+"px",n.style.height=e+"px",n}const Xd=Math.sqrt(3);function qd(t,e){const n=1.2*e;switch(t){case"size1":return{X:n,Y:n};case"size2":return{X:1.5*n,Y:n};case"size3":return{X:2*n,Y:n};case"size4":return{X:n,Y:1.5*n};case"size5":default:return{X:1.5*n,Y:1.5*n};case"size6":return{X:2*n,Y:1.5*n};case"size7":return{X:n,Y:2*n};case"size8":return{X:1.5*n,Y:2*n};case"size9":return{X:2*n,Y:2*n}}}function Kd(t,e,n){switch(t){case"none":default:return null;case"arrow":{const t=Xd*e.X,n=e.Y,i=new w.ConeGeometry(n,t,16);return i.rotateZ(-Math.PI/2),i.translate(-t/2,0,0),{mesh:new w.Mesh(i,new w.MeshBasicMaterial)}}case"sharp-arrow":{const t=Xd*e.X*1.3,n=.65*e.Y,i=new w.ConeGeometry(n,t,16);return i.rotateZ(-Math.PI/2),i.translate(-t/2,0,0),{mesh:new w.Mesh(i,new w.MeshBasicMaterial)}}case"open-arrow":{const t=Xd*e.X,n=e.Y,i=new w.ConeGeometry(n,t,6);return i.rotateZ(-Math.PI/2),i.translate(-t/2,0,0),{mesh:new w.Mesh(i,new w.MeshBasicMaterial({wireframe:!0}))}}case"diamond":{const t=new w.OctahedronGeometry(1);return t.scale(e.X,e.Y,e.Y),{mesh:new w.Mesh(t,new w.MeshBasicMaterial)}}case"oval":{const t=new w.SphereGeometry(1,16,12);return t.scale(e.X,e.Y,e.Y),{mesh:new w.Mesh(t,new w.MeshBasicMaterial)}}case"cross":{const t=Math.max(e.X,e.Y),n=.9*t,i=.25*t,r=.15*t,s=new w.Group,o=[new w.Vector3(1,1,1).normalize(),new w.Vector3(1,-1,-1).normalize(),new w.Vector3(-1,1,-1).normalize(),new w.Vector3(-1,-1,1).normalize()];for(const t of o){const e=new w.CylinderGeometry(i,r,n,6),o=(new w.Quaternion).setFromUnitVectors(new w.Vector3(0,1,0),t);e.applyQuaternion(o),e.translate(t.x*n/2,t.y*n/2,t.z*n/2),s.add(new w.Mesh(e,new w.MeshBasicMaterial))}return{group:s}}}}function Qd(t,e){return"none"===t?0:t.endsWith("arrow")?1.5*e:0}function Zd(t,e,n,i){const{strokeStyle:r,alpha:s=1,lineWidth:o=2,begin:a="none",beginSize:c="size2",end:l="arrow",endSize:p="size2",label:f}=n,g=(new w.Vector3).subVectors(e,t),m=g.length(),y=new w.Group;if(m<.01)return y;const b=g.clone().normalize(),_=Qd(a,o),v=Qd(l,o),x=t.clone().add(b.clone().multiplyScalar(_)),M=e.clone().sub(b.clone().multiplyScalar(v));let S;if(Array.isArray(r)&&r.length>=2){const t=r[1];S=new w.Color(t.length>7?t.slice(0,7):t)}else S=new w.Color("string"==typeof r?r:"#00B050");const A=function(t,e,n,i){const{strokeStyle:r,alpha:s=1,lineWidth:o=2,lineDash:a="solid"}=n,c=new u.LineGeometry;let l;c.setPositions([t.x,t.y,t.z,e.x,e.y,e.z]);let p=!1;if(Array.isArray(r)&&r.length>=2){const t=new w.Color(r[0].length>7?r[0].slice(0,7):r[0]),e=new w.Color(r[1].length>7?r[1].slice(0,7):r[1]);c.setColors([t.r,t.g,t.b,e.r,e.g,e.b]),p=!0,l=e}else l=new w.Color("string"==typeof r?r:"#00B050");const{dashed:f,dashSize:g,gapSize:m}=function(t,e){switch(t){case"solid":default:return{dashed:!1,dashSize:1,gapSize:0};case"round-dot":return{dashed:!0,dashSize:e,gapSize:2*e};case"square-dot":return{dashed:!0,dashSize:2*e,gapSize:e};case"dash":return{dashed:!0,dashSize:4*e,gapSize:1.5*e};case"dash-dot":return{dashed:!0,dashSize:2.5*e,gapSize:1.5*e};case"long-dash":return{dashed:!0,dashSize:6*e,gapSize:3*e};case"long-dash-dot":return{dashed:!0,dashSize:3.5*e,gapSize:2*e};case"long-dash-dot-dot":return{dashed:!0,dashSize:3*e,gapSize:1.5*e}}}(a,o),y=new d.LineMaterial({color:p?16777215:l.getHex(),linewidth:o,worldUnits:!0,vertexColors:p,dashed:f,dashSize:g,gapSize:m,transparent:s<1||Array.isArray(r)&&r.some(t=>t.length>7),opacity:s,resolution:i}),b=new h.Line2(c,y);return b.computeLineDistances(),b}(x,M,n,i);y.add(A);const E=(new w.Quaternion).setFromUnitVectors(new w.Vector3(1,0,0),b),k=(new w.Quaternion).setFromUnitVectors(new w.Vector3(1,0,0),b.clone().negate()),C=(t,e,n)=>{if(!t)return;const r=t.mesh||t.line2||t.group;if(r){if(r.position.copy(e),r.setRotationFromQuaternion(n),t.mesh){const e=t.mesh.material;e.color.copy(S),e.transparent=s<1,e.opacity=s}else if(t.line2){const e=t.line2.material;e.color.copy(S),e.transparent=s<1,e.opacity=s,e.resolution.copy(i)}else t.group&&t.group.traverse(t=>{if(t.material){const e=t.material;e.color.copy(S),e.transparent=s<1,e.opacity=s,e.resolution&&e.resolution.copy(i)}});y.add(r)}};C(Kd(l,qd(p,o)),e,E);if(C(Kd(a,qd(c,o)),t,k),f){const n=(new w.Vector3).addVectors(t,e).multiplyScalar(.5);n.y+=3;const i=function(t,e,n){const i="Arial",r=Wd(256,64),s=r.getContext("2d");s.font=`bold 28px ${i}`;const o=s.measureText(t).width;s.fillStyle=e,s.fillRect(0,0,o+12,40),s.fillStyle="white",s.font=`bold 28px ${i}`,s.textBaseline="top",s.fillText(t,6,6);const a=new w.CanvasTexture(r);a.needsUpdate=!0,a.minFilter=w.LinearFilter,a.colorSpace=w.SRGBColorSpace;const c=new w.SpriteMaterial({map:a,transparent:!0}),l=new w.Sprite(c);l.position.copy(n);const h=(o+12)/40;return l.scale.set(4*h,4,1),l}(f,"string"==typeof r?r:Array.isArray(r)&&r[1]||"#00B050",n);y.add(i)}return y}class Jd extends Uh{get syncZPosOffset(){return this.effectiveDepth}get geometricOffsetY(){return this.effectiveDepth}getObject3dInstance(){return new l.CSS3DObject(this.component.element)}get rotation(){const{rotationX:t=0,rotationY:e=0,rotation:n=0}=this.component.state;return{x:t-Math.PI/2,y:e,z:-n}}syncFromObject3D(){const t=this.object3d,e=this._component,{width:n=0,height:i=0}=e.parent?.bounds??{},r=e.bounds,{tx:s=0,ty:o=0,tz:a=0}=e.delta();this._suppressOnchange=!0;const c=t.scale.x;e.bounds={left:t.position.x-s+n/2-r.width/2,top:t.position.z-o+i/2-r.height/2,width:r.width,height:r.height};const l=this.component.parent?._realObject,h=l?.geometricOffsetY??0;e.set({zPos:t.position.y-a-this.syncZPosOffset+h,rotationX:t.rotation.x+Math.PI/2,rotation:-t.rotation.z,rotationY:t.rotation.y,scale:{x:c,y:c}}),this._suppressOnchange=!1}build(){super.build();const t=this.component.element;if(!t)return;if(t.style.left="",t.style.top="",this.component.state.screenFixed&&this.component.isContainer?.())return;const{width:e,height:n}=this.component.bounds;t.style.width=e+"px",t.style.height=n+"px"}updateDimension(){if(this.component.state.screenFixed&&this.component.isContainer?.())return;super.updateDimension();const t=this.dimension,e=this.component.element;e&&(e.style.width=t.width+"px",e.style.height=t.height+"px")}updateAlpha(){super.updateAlpha();const{alpha:t=1}=this.component.state,e=this.component.element;e&&(e.style.opacity=String(t))}}const tu=new Map;let eu;function nu(t,e){tu.set(t,e)}function iu(t){eu=t}function ru(t){const e=t.buildRealObject();if(e)return e;const n=t.model?.type,i=n?tu.get(n):void 0;if(i)return i(t);if(t.isHTMLElement()){const e=tu.get("html-overlay-element");if(e)return e(t)}return eu?.(t)}function su(t,e,n){if(!t.hasTextProperty||t.textHidden)return;const i=t._realObject;if(!i?.object3d)return;const{text:r="",bold:s=Ar.BOLD,italic:o=Ar.ITALIC,fontFamily:a=Ar.FONT_FAMILY,fontColor:c=Ar.FONT_COLOR,fontSize:h=Ar.FONT_SIZE,textAlign:d=Ar.TEXT_ALIGN,textBaseline:u=Ar.TEXT_BASELINE,width:p,height:f}=t.model,g=Math.abs(p)||1,m=Math.abs(f)||1,y=document.createElement("textarea"),b=new AbortController;Mr.forEach(t=>{y.addEventListener(t,t=>t.stopPropagation(),{capture:!0,signal:b.signal})}),y.value=r;const _="right"===d||"end"===d?"right":"left"===d||"start"===d?"left":"justify"===d?"justify":"center";let v="0";if("bottom"===u||"alphabetic"===u){const t=1.2*h*Math.max(1,(r.match(/\n/g)||[]).length+1);v=Math.max(0,m-t)+"px"}else if("middle"===u){const t=1.2*h*Math.max(1,(r.match(/\n/g)||[]).length+1);v=Math.max(0,(m-t)/2)+"px"}y.style.cssText=[`width: ${g}px`,`height: ${m}px`,`padding: ${v} 0 0 0`,"margin: 0",`font-family: ${a}`,`font-size: ${h}px`,`line-height: ${1.2*h}px`,"overflow: hidden","resize: none","outline: 1px solid #f26522","border: 0","background-color: rgba(255, 255, 255, 0.85)","display: block",`color: ${c}`,"box-sizing: border-box","font-weight: "+(s?"bold":"normal"),"font-style: "+(o?"italic":"normal"),`text-align: ${_}`].join("; ");const x=new l.CSS3DObject(y),M=i.object3d;M.updateWorldMatrix(!0,!1);const S=new w.Vector3,A=new w.Quaternion,E=new w.Vector3;M.matrixWorld.decompose(S,A,E);const k=new w.Vector3(0,i.textSurfaceYOffset,0);k.multiply(E),k.applyQuaternion(A),x.position.copy(S).add(k);const C=(new w.Quaternion).setFromAxisAngle(new w.Vector3(1,0,0),-Math.PI/2);x.quaternion.copy(A).multiply(C),x.scale.copy(E),e.css3DScene.add(x),n();const T=e.css3DRenderer.domElement,P=T.style.getPropertyValue("pointer-events"),D=T.style.getPropertyPriority("pointer-events"),O=[];let z=y;for(;z&&z!==T.parentElement;)O.push({el:z,saved:z.style.pointerEvents}),z.style.setProperty("pointer-events","auto","important"),z=z.parentElement;y.focus(),y.select();let L=!1;const I=t.root?.selected;y.addEventListener("keydown",t=>{t.stopPropagation(),"Escape"!==t.code&&(t.shiftKey||"Enter"!==t.code&&"NumpadEnter"!==t.code)||(L="Escape"===t.code,y.blur())},{signal:b.signal});const R=()=>{e.css3DScene.remove(x);for(const{el:t,saved:e}of O)e?t.style.pointerEvents=e:t.style.removeProperty("pointer-events");D?T.style.setProperty("pointer-events",P,D):P&&T.style.setProperty("pointer-events",P),b.abort(),y.removeEventListener("blur",R),I&&t.root&&(t.root.selected=I),L||y.value===r||t.app.commander.execute(new Mc({changes:[{component:t,before:{text:r},after:{text:y.value}}]})),n()};y.addEventListener("blur",R)}class ou extends n.Scene{dispose(){const t=new Set;this.traverse(e=>{if(e.isMesh){t.add(e.geometry);const n=e.material;Array.isArray(n)?n.forEach(e=>t.add(e)):t.add(n)}});for(const e of t)e.dispose()}}function au(t,e){t.metalness=e.metalness,t.roughness=e.roughness,t.opacity=e.opacity,t.transparent=e.opacity<1,t.envMapIntensity=e.envMapIntensity,t.polygonOffset=!0,t.polygonOffsetFactor=1,t.polygonOffsetUnits=1}function cu(t){const{fillStyle:e,floorMaterial3d:n,placement:i}=t.state,r=wh({...n,preset:n?.preset??"rubber",envMapIntensity:n?.envMapIntensity??0});if("none"===e)return;if("space"===i)return;const s=new w.BoxGeometry(1,1,1);let o;if(e){const n=Uh.buildFillStyleTexture(t);if(n){const t="#424b57",e=[new w.MeshStandardMaterial({color:t}),new w.MeshStandardMaterial({color:t}),new w.MeshStandardMaterial({color:t}),new w.MeshStandardMaterial({color:t}),new w.MeshStandardMaterial({map:n}),new w.MeshStandardMaterial({color:t})];e.forEach(t=>au(t,r)),o=e}else if("string"==typeof e){const t=new w.MeshStandardMaterial({color:e});au(t,r),o=t}}if(!o){const t=new w.MeshStandardMaterial({color:"#e0e0e0"});au(t,r),o=t}const a=new w.Mesh(s,o),{width:c,height:l}=t.state;return a.scale.set(c,l,5),a.rotation.x=-Math.PI/2,a.position.y="inverted"===i?3.5:-3.5,a.name="floor",a.receiveShadow=!1!==n?.receiveShadow,a.castShadow=!0===n?.castShadow,a}const lu={studio:class extends ou{constructor(){super(),this.name="StudioEnvironment",this.position.y=-3.5;const t=new n.BoxGeometry;t.deleteAttribute("uv");const e=new n.MeshStandardMaterial({side:n.BackSide,color:13421772}),i=new n.Mesh(t,e);i.position.set(0,13,0),i.scale.set(40,30,35),this.add(i);const r=new n.MeshStandardMaterial({color:11184810,roughness:.8}),s=new n.Mesh(t,r);s.position.set(0,-1.5,0),s.scale.set(40,.5,35),this.add(s);const o=new n.PointLight(16777215,500,40,2);o.position.set(0,24,0),this.add(o);const a=new n.PointLight(16777215,200,30,2);a.position.set(-10,22,-8),this.add(a);const c=new n.PointLight(16777215,200,30,2);c.position.set(10,22,8),this.add(c);const l=(e,i,r)=>{const s=new n.MeshLambertMaterial({color:0,emissive:16777215,emissiveIntensity:r}),o=new n.Mesh(t,s);return o.position.set(e,26,i),o.scale.set(6,.1,6),o};this.add(l(-8,-6,60)),this.add(l(8,-6,60)),this.add(l(-8,6,60)),this.add(l(8,6,60)),this.add(l(0,0,50))}},warehouse:class extends ou{constructor(){super(),this.name="WarehouseEnvironment",this.position.y=-3.5;const t=new n.BoxGeometry;t.deleteAttribute("uv");const e=new n.MeshStandardMaterial({side:n.BackSide,color:8425632}),i=new n.Mesh(t,e);i.position.set(0,18,0),i.scale.set(50,40,40),this.add(i);const r=new n.MeshStandardMaterial({color:9474192,roughness:.9}),s=new n.Mesh(t,r);s.position.set(0,-1.5,0),s.scale.set(50,.5,40),this.add(s);const o=new n.PointLight(15266047,600,50,2);o.position.set(-10,30,0),this.add(o);const a=new n.PointLight(15266047,600,50,2);a.position.set(10,30,0),this.add(a);const c=(e,i,r)=>{const s=new n.MeshLambertMaterial({color:0,emissive:15266047,emissiveIntensity:r}),o=new n.Mesh(t,s);return o.position.set(e,35,i),o.scale.set(8,.1,2),o};this.add(c(-12,-6,80)),this.add(c(-12,6,80)),this.add(c(0,0,60)),this.add(c(12,-6,80)),this.add(c(12,6,80));const l=new n.Mesh(t,new n.MeshLambertMaterial({color:0,emissive:16772829,emissiveIntensity:15}));l.position.set(0,10,-19),l.scale.set(12,8,.1),this.add(l)}},factory:class extends ou{constructor(){super(),this.name="FactoryEnvironment",this.position.y=-3.5;const t=new n.BoxGeometry;t.deleteAttribute("uv");const e=new n.MeshStandardMaterial({side:n.BackSide,color:6318192,metalness:.1,roughness:.8}),i=new n.Mesh(t,e);i.position.set(0,20,0),i.scale.set(60,44,45),this.add(i);const r=new n.MeshStandardMaterial({color:8028272,roughness:.7,metalness:.05}),s=new n.Mesh(t,r);s.position.set(0,-1.5,0),s.scale.set(60,.5,45),this.add(s);const o=(t,e)=>{const i=new n.PointLight(15791615,800,55,2);return i.position.set(t,35,e),i};this.add(o(-15,-10)),this.add(o(-15,10)),this.add(o(0,0)),this.add(o(15,-10)),this.add(o(15,10));const a=(e,i,r)=>{const s=new n.MeshLambertMaterial({color:0,emissive:15791615,emissiveIntensity:r}),o=new n.Mesh(t,s);return o.position.set(e,38,i),o.scale.set(6,.1,3),o};this.add(a(-18,-10,90)),this.add(a(-18,10,90)),this.add(a(0,-10,70)),this.add(a(0,10,70)),this.add(a(18,-10,90)),this.add(a(18,10,90));const c=new n.Mesh(t,new n.MeshLambertMaterial({color:0,emissive:11206570,emissiveIntensity:10}));c.position.set(28,14,-21),c.scale.set(1,2,.1),this.add(c);const l=new n.Mesh(t,new n.MeshLambertMaterial({color:0,emissive:16772829,emissiveIntensity:25}));l.position.set(0,8,-22),l.scale.set(10,10,.1),this.add(l)}},office:class extends ou{constructor(){super(),this.name="OfficeEnvironment",this.position.y=-3.5;const t=new n.BoxGeometry;t.deleteAttribute("uv");const e=new n.MeshStandardMaterial({side:n.BackSide,color:14209224}),i=new n.Mesh(t,e);i.position.set(0,10,0),i.scale.set(35,22,30),this.add(i);const r=new n.MeshStandardMaterial({color:10524808,roughness:.85}),s=new n.Mesh(t,r);s.position.set(0,-1.5,0),s.scale.set(35,.5,30),this.add(s);const o=new n.PointLight(16774374,400,30,2);o.position.set(0,17,0),this.add(o);const a=(e,i,r)=>{const s=new n.MeshLambertMaterial({color:0,emissive:16775408,emissiveIntensity:r}),o=new n.Mesh(t,s);return o.position.set(e,19.5,i),o.scale.set(4,.1,4),o};this.add(a(-8,-6,60)),this.add(a(-8,6,60)),this.add(a(8,-6,60)),this.add(a(8,6,60)),this.add(a(0,0,50));const c=new n.Mesh(t,new n.MeshLambertMaterial({color:0,emissive:14544639,emissiveIntensity:30}));c.position.set(17,10,0),c.scale.set(.1,6,12),this.add(c);const l=new n.Mesh(t,new n.MeshLambertMaterial({color:0,emissive:14544639,emissiveIntensity:20}));l.position.set(-17,10,0),l.scale.set(.1,4,8),this.add(l)}},home:class extends ou{constructor(){super(),this.name="HomeEnvironment",this.position.y=-3.5;const t=new n.BoxGeometry;t.deleteAttribute("uv");const e=new n.MeshStandardMaterial({side:n.BackSide,color:15261136}),i=new n.Mesh(t,e);i.position.set(0,8,0),i.scale.set(28,18,24),this.add(i);const r=new n.MeshStandardMaterial({color:11571312,roughness:.7}),s=new n.Mesh(t,r);s.position.set(0,-1.5,0),s.scale.set(28,.5,24),this.add(s);const o=new n.PointLight(16770244,300,25,2);o.position.set(0,14,0),this.add(o);const a=new n.PointLight(16767152,100,20,2);a.position.set(-8,12,-6),this.add(a);const c=(e,i,r)=>{const s=new n.MeshLambertMaterial({color:0,emissive:16771280,emissiveIntensity:r}),o=new n.Mesh(t,s);return o.position.set(e,15.5,i),o.scale.set(3,.1,3),o};this.add(c(0,0,40)),this.add(c(-6,-4,25)),this.add(c(6,4,25));const l=new n.Mesh(t,new n.MeshLambertMaterial({color:0,emissive:14544639,emissiveIntensity:35}));l.position.set(13.5,8,0),l.scale.set(.1,8,10),this.add(l);const h=new n.Mesh(t,new n.MeshLambertMaterial({color:0,emissive:14544639,emissiveIntensity:15}));h.position.set(-13.5,9,3),h.scale.set(.1,5,6),this.add(h)}},sunny:class extends ou{constructor(){super(),this.name="SunnyEnvironment";const t=new p.Sky;t.scale.setScalar(1e3);const e=t.material.uniforms;e.turbidity.value=2,e.rayleigh.value=1.5,e.mieCoefficient.value=.005,e.mieDirectionalG.value=.8;const i=n.MathUtils.degToRad(60),r=n.MathUtils.degToRad(135),s=Math.PI/2-i;e.sunPosition.value.setFromSphericalCoords(1,s,r),this.add(t)}},cloudy:class extends ou{constructor(){super(),this.name="CloudyEnvironment";const t=new p.Sky;t.scale.setScalar(1e3);const e=t.material.uniforms;e.turbidity.value=10,e.rayleigh.value=.3,e.mieCoefficient.value=.03,e.mieDirectionalG.value=.7;const i=n.MathUtils.degToRad(50),r=n.MathUtils.degToRad(120),s=Math.PI/2-i;e.sunPosition.value.setFromSphericalCoords(1,s,r),this.add(t)}},rainy:class extends ou{constructor(){super(),this.name="RainyEnvironment";const t=new p.Sky;t.scale.setScalar(1e3);const e=t.material.uniforms;e.turbidity.value=20,e.rayleigh.value=.1,e.mieCoefficient.value=.05,e.mieDirectionalG.value=.6;const i=n.MathUtils.degToRad(40),r=n.MathUtils.degToRad(110),s=Math.PI/2-i;e.sunPosition.value.setFromSphericalCoords(1,s,r),this.add(t)}}};class hu{get scene(){return this._scene}get mixer(){return this._mixer}setup(){return this._scene=new w.Scene,this._scene}setupMixer(){return this._timer=new w.Timer,this._timer.connect(document),this._mixer=new w.AnimationMixer(this._scene),this._mixer}setupEnvironment(t){this._renderer=t}_applyEnvironment(t){if(this._envTexture&&(this._envTexture.dispose(),this._envTexture=void 0),!this._renderer||!this._scene)return;const e=new(0,lu[t]),n=new w.PMREMGenerator(this._renderer);this._envTexture=n.fromScene(e).texture,this._scene.environment=this._envTexture,e.dispose(),n.dispose()}_clearEnvironment(){this._envTexture&&(this._envTexture.dispose(),this._envTexture=void 0),this._scene&&(this._scene.environment=null)}setSky(t,e){if(!this._scene||!this._renderer)return;const n=t;n&&n in lu?(this._applyEnvironment(n),this._scene.background=this._envTexture):"color"===t&&e?(this._clearEnvironment(),this._scene.background=new w.Color(e)):(this._clearEnvironment(),this._scene.background=null)}addFloor(t){const e=cu(t);e&&this._scene.add(e)}updateFloor(t){if(!this._scene)return;const e=this._scene.children.find(t=>"floor"===t.name);e&&(Nh(e),this._scene.remove(e)),this.addFloor(t)}addObject(t){this._scene.add(t)}updateAnimation(){this._mixer&&this._timer&&(this._timer.update(),this._mixer.update(this._timer.getDelta()))}destroy(){this._mixer&&(this._mixer.stopAllAction(),this._mixer.uncacheRoot(this._scene)),this._envTexture&&(this._envTexture.dispose(),delete this._envTexture),this._scene&&(this._scene.environment=null,Nh(this._scene),this._scene.clear()),delete this._scene,delete this._mixer,delete this._renderer,this._timer&&this._timer.disconnect(),delete this._timer}}class du{constructor(){this._activeView="perspective",this._cameraZPos=0}get camera(){return this._perspCamera}get activeCamera(){return"perspective"!==this._activeView&&this._orthoCamera?this._orthoCamera:this._perspCamera}get activeView(){return this._activeView}get cameraZPos(){return this._cameraZPos}setup(t,e,n){const{fov:i,near:r,far:s,cameraX:o,cameraY:a,cameraZ:c}=n,l=t/e;this._perspCamera=new w.PerspectiveCamera(i,l,r,s);const h=Math.sqrt(t*t+e*e),d=(i||45)/2*Math.PI/180,u=h/2/Math.tan(d)*.75,p=25*Math.PI/180,f=30*Math.PI/180,g=u*Math.sin(p),m=u*Math.cos(p);let y=m*Math.sin(f),b=m*Math.cos(f);return this._cameraZPos=Math.floor(g),null!=o&&(y=o*t),null!=a&&(b=a*e),null!=c&&(this._cameraZPos=c*Math.floor(Math.min(t,e))),this._perspCamera.position.set(y,this._cameraZPos,b),this._activeView="perspective",this._perspCamera}addToScene(t){t.add(this._perspCamera),this._perspCamera.lookAt(t.position)}updateAspect(t,e){if(this._perspCamera&&(this._perspCamera.aspect=t/e,this._perspCamera.updateProjectionMatrix()),this._orthoCamera){const n=this._orthoCamera,i=(n.top-n.bottom)/2,r=t/e;n.left=-i*r,n.right=i*r,n.updateProjectionMatrix()}}updateProperties(t){this._perspCamera&&(void 0!==t.fov&&(this._perspCamera.fov=t.fov),void 0!==t.near&&(this._perspCamera.near=t.near),void 0!==t.far&&(this._perspCamera.far=t.far),this._perspCamera.updateProjectionMatrix())}setOrthoView(t,e,n,i,r){this._orthoCamera||(this._orthoCamera=new w.OrthographicCamera(-1,1,1,-1,.1,5e4)),this.updateOrthoFrustum(e,n,i,r);const s=this._orthoCamera;s.zoom=1;const o=2*Math.max(e,n);switch(t){case"top":s.position.set(0,o,0),s.up.set(0,0,-1);break;case"front":s.position.set(0,0,o),s.up.set(0,1,0);break;case"back":s.position.set(0,0,-o),s.up.set(0,1,0);break;case"right":s.position.set(o,0,0),s.up.set(0,1,0);break;case"left":s.position.set(-o,0,0),s.up.set(0,1,0)}return s.lookAt(0,0,0),s.updateProjectionMatrix(),this._activeView=t,s}restorePerspective(){return this._activeView="perspective",this._perspCamera}updateOrthoFrustum(t,e,n,i){if(!this._orthoCamera)return;const r=(n||t)/(i||e),s=Math.max(t,e)/2;r>=1?(this._orthoCamera.left=-s*r,this._orthoCamera.right=s*r,this._orthoCamera.top=s,this._orthoCamera.bottom=-s):(this._orthoCamera.left=-s,this._orthoCamera.right=s,this._orthoCamera.top=s/r,this._orthoCamera.bottom=-s/r),this._orthoCamera.updateProjectionMatrix()}destroy(){delete this._perspCamera,delete this._orthoCamera,this._activeView="perspective"}}class uu{constructor(){this._noSupportWebgl=!1}get renderer(){return this._renderer}setExposure(t){this._renderer&&(this._renderer.toneMappingExposure=t)}get css3DRenderer(){return this._css3DRenderer||(this._css3DRenderer=this.createCSS3DRenderer()),this._css3DRenderer}get css3DScene(){return this._css3DScene||(this._css3DScene=new w.Scene),this._css3DScene}get composer(){return this._composer}get noSupportWebgl(){return this._noSupportWebgl}get domElement(){return this._renderer?.domElement}get hudScene(){return this._hudScene||(this._hudScene=new w.Scene),this._hudScene}get hudCSS3DScene(){return this._hudCSS3DScene||(this._hudCSS3DScene=new w.Scene),this._hudCSS3DScene}get hudCamera(){return this._hudCamera}setupHUD(t,e){this._hudCamera=new w.OrthographicCamera(-t/2,t/2,e/2,-e/2,.1,1e4),this._hudCamera.position.set(0,5e3,0),this._hudCamera.lookAt(0,0,0),this._hudCSS3DCamera=new w.OrthographicCamera(-t/2,t/2,e/2,-e/2,.1,1e4),this._hudCSS3DCamera.position.set(0,0,1e3),this._hudCSS3DCamera.lookAt(0,0,0),this._hudCSS3DRenderer=new l.CSS3DRenderer,this._hudCSS3DRenderer.setSize(t,e);const n=this._hudCSS3DRenderer.domElement;n.style.position="absolute",n.style.left="0",n.style.top="0",n.style.pointerEvents="none",n.setAttribute("scene","model-layer:css3d-hud-renderer");const i=new w.AmbientLight(16777215,3);this.hudScene.add(i);const r=new Float32Array(64).fill(1),s=new w.DataTexture(r,4,4,w.RGBAFormat,w.FloatType);s.mapping=w.EquirectangularReflectionMapping,s.needsUpdate=!0,this.hudScene.environment=s}resizeHUD(t,e){this._hudCamera&&(this._hudCamera.right=t,this._hudCamera.bottom=-e,this._hudCamera.updateProjectionMatrix())}setupWebGL(t,e,n){try{const i=document.createElement("canvas"),r=i.getContext("webgl2");if(!r)return this._noSupportWebgl=!0,!1;const s=new w.WebGLRenderer({canvas:i,context:r,precision:n.precision,alpha:!0,antialias:n.antialias,logarithmicDepthBuffer:n.logarithmicDepthBuffer??!1!==n.postprocessing,premultipliedAlpha:!1});return s.autoClear=!0,s.outputColorSpace=w.SRGBColorSpace,s.toneMapping=w.ACESFilmicToneMapping,s.toneMappingExposure=n.exposure,s.shadowMap.enabled=!1!==n.shadowMap,s.shadowMap.type=w.PCFShadowMap,s.setClearColor(16777215,1),s.setPixelRatio(window.devicePixelRatio),s.setSize(t,e,!1),i.style.width="100%",i.style.height="100%",this._renderer=s,this._noSupportWebgl=!1,!0}catch(t){return this._noSupportWebgl=!0,!1}}setupCSS3D(t,e){const n=this.css3DRenderer.domElement;n.style.position="absolute",n.style.left="0",n.style.top="0",n.style.pointerEvents="none",e&&n.setAttribute("scene",e),n.style.setProperty("pointer-events","none","important")}createCSS3DRenderer(){return new l.CSS3DRenderer}setupComposer(t,e,n,i,r){const s=new w.WebGLRenderTarget(n,i,{samples:4});this._composer=new f.EffectComposer(this._renderer,s),this._composer.setSize(n,i);const o=new g.RenderPass(t,e);this._composer.addPass(o);const a=new m.OutlinePass(new w.Vector2(n,i),t,e);if(a.visibleEdgeColor.set(15885602),a.hiddenEdgeColor.set(15885602),a.edgeStrength=3,a.edgeThickness=1.5,a.edgeGlow=.5,a.pulsePeriod=0,r){const t=a.render.bind(a);a.render=(e,n,i,s,o)=>{const a=r.visible;r.visible=!1,t(e,n,i,s,o),r.visible=a}}return this._outlinePass=a,this._composer.addPass(a),this._composer.addPass(new b.SMAAPass),this._composer.addPass(new y.OutputPass),this._composer}setupLightComposer(t,e,n,i){const r=new w.WebGLRenderTarget(n,i);this._composer=new f.EffectComposer(this._renderer,r),this._composer.setSize(n,i),this._composer.addPass(new g.RenderPass(t,e));const s=new m.OutlinePass(new w.Vector2(n,i),t,e);return s.visibleEdgeColor.set(15885602),s.hiddenEdgeColor.set(15885602),s.edgeStrength=3,s.edgeThickness=1.5,s.edgeGlow=.5,s.pulsePeriod=0,this._outlinePass=s,this._composer.addPass(s),this._composer.addPass(new y.OutputPass),this._composer}get hasOutlinePass(){return!!this._outlinePass}updateRenderPassCamera(t){this._composer&&this._composer.passes.length>0&&(this._composer.passes[0].camera=t),this._outlinePass&&(this._outlinePass.renderCamera=t),this._camera&&(this._camera=t)}setOutlineObjects(t){this._outlinePass&&(this._outlinePass.selectedObjects=t)}resize(t,e){if(this._renderer?.setSize(t,e,!1),this._css3DRenderer?.setSize(t,e),this._composer?.setSize(t,e),this._hudCSS3DRenderer&&this._hudCSS3DCamera){const n=t/(this._hudCSS3DCamera.right-this._hudCSS3DCamera.left),i=e/(this._hudCSS3DCamera.top-this._hudCSS3DCamera.bottom),r=this._hudCSS3DRenderer.domElement;r.style.transformOrigin="0 0",r.style.transform=`scale(${n}, ${i})`}}teardownLightComposer(){this._composer&&(this._outlinePass=void 0,this._composer.dispose(),this._composer=void 0)}setDirectRenderTargets(t,e){this._scene=t,this._camera=e}render(){if(this._composer){if(this._composer.render(),this._renderer){const t=this._renderer.getContext();t.colorMask(!1,!1,!1,!0),t.clearColor(0,0,0,1),t.clear(t.COLOR_BUFFER_BIT),t.colorMask(!0,!0,!0,!0)}}else this._renderer&&this._scene&&this._camera&&this._renderer.render(this._scene,this._camera);this.renderHUD()}renderHUD(){if(!this._renderer||!this._hudScene||!this._hudCamera)return;if(0===this._hudScene.children.length)return;const t=this._renderer.autoClear;this._renderer.autoClear=!1,this._renderer.setRenderTarget(null),this._renderer.clearDepth(),this._renderer.render(this._hudScene,this._hudCamera),this._renderer.autoClear=t}renderCSS3D(t){if(this._css3DRenderer?.render(this.css3DScene,t),this._hudCSS3DRenderer&&this._hudCSS3DCamera&&this._hudCSS3DScene){const t=this._hudCSS3DRenderer.domElement;this._hudCSS3DScene.children.length>0?(t.style.display="",this._hudCSS3DRenderer.render(this._hudCSS3DScene,this._hudCSS3DCamera)):t.style.display="none"}}get hudCSS3DRenderer(){return this._hudCSS3DRenderer}getSize(){const t=new w.Vector2;return this._renderer?.getSize(t),{width:t.x,height:t.y}}destroy(){this._outlinePass=void 0,this._composer?.dispose(),this._renderer?.forceContextLoss(),this._renderer?.dispose(),delete this._composer,delete this._renderer,this.disposeHUD()}disposeHUD(){if(this._hudScene){[...this._hudScene.children].forEach(t=>{if(this._hudScene.remove(t),t.geometry&&t.geometry.dispose(),t.material){const e=t.material;e.map&&e.map.dispose(),e.dispose()}}),this._hudScene.environment&&(this._hudScene.environment.dispose(),this._hudScene.environment=null),this._hudScene=void 0}if(this._hudCamera=void 0,this._hudCSS3DScene){[...this._hudCSS3DScene.children].forEach(t=>this._hudCSS3DScene.remove(t)),this._hudCSS3DScene=void 0}this._hudCSS3DRenderer&&(this._hudCSS3DRenderer.domElement.remove(),this._hudCSS3DRenderer=void 0),this._hudCSS3DCamera=void 0}disposeCSS3DScene(){if(this._css3DScene){[...this._css3DScene.children].forEach(t=>this._css3DScene.remove(t))}}}class pu{constructor(){this.lights=[]}get hemiLight(){return this._hemiLight}get dirLight(){return this._dirLight}setup(t,e,n){this._scene=t,this._camera=e;const{hemisphere:i,directional:r,point:s}=n;if(this._hemiLight=new w.HemisphereLight(i.skyColor,i.groundColor,i.intensity),t.add(this._hemiLight),this.lights.push(this._hemiLight),r){if(this._dirLight=new w.DirectionalLight(r.color,r.intensity),r.position&&this._dirLight.position.set(...r.position),!1!==r.castShadow){this._dirLight.castShadow=!0;const t=r.shadowMapSize??2048;this._dirLight.shadow.mapSize.set(t,t),this._dirLight.shadow.bias=r.shadowBias??-5e-4;const e=this._dirLight.shadow.camera;e.near=.1,e.far=5e3,e.left=-1500,e.right=1500,e.top=1500,e.bottom=-1500}r.attachToCamera?e.add(this._dirLight):t.add(this._dirLight),this.lights.push(this._dirLight)}if(s){const e=new w.PointLight(s.color,s.intensity,void 0,s.decay);e.power=s.power,e.castShadow=s.castShadow,e.position.set(...s.position),e.shadow.camera.near=s.shadowNear,e.shadow.camera.far=s.shadowFar,t.add(e),this.lights.push(e)}}updateHemisphere(t){this._hemiLight&&(void 0!==t.skyColor&&this._hemiLight.color.set(t.skyColor),void 0!==t.groundColor&&this._hemiLight.groundColor.set(t.groundColor),void 0!==t.intensity&&(this._hemiLight.intensity=t.intensity))}updateDirectional(t){this._dirLight&&(void 0!==t.color&&this._dirLight.color.set(t.color),void 0!==t.intensity&&(this._dirLight.intensity=t.intensity))}setDirectionalFollowCamera(t){this._dirLight&&this._scene&&this._camera&&(this._dirLight.removeFromParent(),t?this._camera.add(this._dirLight):this._scene.add(this._dirLight))}setDirectionalAngle(t,e,n=1e3){if(!this._dirLight)return;const i=t*Math.PI/180,r=e*Math.PI/180,s=n;this._dirLight.position.set(s*Math.cos(r)*Math.sin(i),s*Math.sin(r),s*Math.cos(r)*Math.cos(i)),this._dirLight.target.position.set(0,0,0),!this._dirLight.target.parent&&this._scene&&this._scene.add(this._dirLight.target)}setDirectionalEnabled(t,e){if(t&&!this._dirLight&&this._camera){const t=e?.color??16777215,n=e?.intensity??2;this._dirLight=new w.DirectionalLight(t,n),this._camera.add(this._dirLight),this.lights.push(this._dirLight)}else!t&&this._dirLight&&(this._dirLight.removeFromParent(),this._dirLight.dispose(),this.lights=this.lights.filter(t=>t!==this._dirLight),this._dirLight=void 0)}destroy(){this.lights.forEach(t=>t.dispose()),this.lights=[],this._hemiLight=void 0,this._dirLight=void 0,this._scene=void 0,this._camera=void 0}}const fu=1e-6;class gu{constructor(){this._enabled=!0,this._state=0,this._autoRotate=!1,this._autoRotateSpeed=2,this._dampingFactor=.15,this._rotateSpeed=.1,this._panSpeed=1,this._dollyStart=0,this._lastScale=1,this._floorConstraint=!1,this._spherical=new w.Spherical,this._sphericalDelta=new w.Spherical,this._panOffset=new w.Vector3,this._target=new w.Vector3,this._target0=new w.Vector3,this._position0=new w.Vector3,this._rotateStart=new w.Vector2,this._rotateEnd=new w.Vector2,this._rotateDelta=new w.Vector2,this._panStart=new w.Vector2,this._panEnd=new w.Vector2,this._panDelta=new w.Vector2,this._offset=new w.Vector3,this._lastPosition=new w.Vector3,this._lastQuaternion=new w.Quaternion,this._panLeftV=new w.Vector3,this._panUpV=new w.Vector3,this._panCalcOffset=new w.Vector3}get isActive(){return!!this._camera}get target(){return this._target.clone()}restoreTarget(t){this._target.copy(t),this.update()}get _isOrthoLocked(){return!!this._camera?.isOrthographicCamera}setup(t,e){this._camera=t,this._host=e,this._target.set(0,0,0),this._target0.copy(this._target),this._position0.copy(t.position),this._quat=(new w.Quaternion).setFromUnitVectors(t.up,new w.Vector3(0,1,0)),this._quatInverse=this._quat.clone().invert();const n=e.state;this._autoRotate=!e.app?.isEditMode&&(n.autoRotate||"orbit"===n.cameraAutoPlay)||!1,this._autoRotateSpeed=n.rotationSpeed||2,this._floorConstraint=!e.app?.isEditMode&&!!n.cameraFloorConstraint||!1,this.update()}setEnabled(t){this._enabled=t}setOnUserInteraction(t){this._onUserInteraction=t}onDragStart(t){this._enabled&&(this._onUserInteraction?.(),this._isOrthoLocked?(this._state=2,this._panStart.set(t.offsetX,t.offsetY)):(this._state=t.altKey?2:t.ctrlKey||t.metaKey?3:1,1===this._state?this._rotateStart.set(t.offsetX,t.offsetY):3===this._state?this._dollyStart=t.offsetY:this._panStart.set(t.offsetX,t.offsetY)))}onDragMove(t){if(this._enabled)if(this._isOrthoLocked)this._state=2,this._handlePanMove(t.offsetX,t.offsetY);else if(this._state=t.altKey?2:t.ctrlKey||t.metaKey?3:1,3===this._state){const e=t.offsetY-this._dollyStart;this._dollyStart=t.offsetY;const n=1+.005*e;this.dollyAtCursor(n,0,0)}else 1===this._state?this._handleRotateMove(t.offsetX,t.offsetY):this._handlePanMove(t.offsetX,t.offsetY)}onDragEnd(t){this._state=0,this._host?.invalidate()}onTouchStart(t){this._onUserInteraction?.();const e=t.touches[0],n=e.offsetX??e.pageX,i=e.offsetY??e.pageY;if(this._isOrthoLocked)return this._panStart.set(n,i),void(this._state=5);switch(t.touches.length){case 1:this._rotateStart.set(n,i),this._state=4;break;case 2:this._lastScale=t.scale||1,this._panStart.set(n,i),this._state=5;break;default:this._state=0}}onTouchMove(t){const e=t.touches[0],n=e.offsetX??e.pageX,i=e.offsetY??e.pageY;if(this._isOrthoLocked)this._handlePanMove(n,i);else switch(t.touches.length){case 1:if(4!==this._state)return;this._handleRotateMove(n,i);break;case 2:{if(5!==this._state)return;const e=t.scale||1;if(Math.abs(this._lastScale-e)>.01){const t=this._lastScale/e;this._lastScale=e,this.dollyAtCursor(t,0,0)}else this._handlePanMove(n,i);break}default:this._state=0}}onTouchEnd(t){this._lastScale=1,this._state=0}onKeyDown(t){switch(t.code){case"ArrowUp":this._pan(0,7);break;case"ArrowDown":this._pan(0,-7);break;case"ArrowLeft":this._pan(7,0);break;case"ArrowRight":this._pan(-7,0);break;default:return}this.update()}update(){const t=this._camera,e=t.position;if(this._isOrthoLocked)return this._panOffset.lengthSq()>0&&(this._target.add(this._panOffset),e.add(this._panOffset),this._panOffset.set(0,0,0)),(this._lastPosition.distanceToSquared(e)>fu||8*(1-this._lastQuaternion.dot(t.quaternion))>fu)&&(this._lastPosition.copy(e),this._lastQuaternion.copy(t.quaternion),this._host?.invalidate(),!0);if(this._offset.copy(e).sub(this._target),this._offset.applyQuaternion(this._quat),this._spherical.setFromVector3(this._offset),this._spherical.theta+=this._sphericalDelta.theta,this._autoRotate&&0===this._state){const t=2*Math.PI/60*(this._autoRotateSpeed/60);this._spherical.theta-=t}this._spherical.phi+=this._sphericalDelta.phi,this._spherical.phi=Math.max(0,Math.min(Math.PI,this._spherical.phi)),this._spherical.makeSafe(),this._target.add(this._panOffset),this._offset.setFromSpherical(this._spherical),this._offset.applyQuaternion(this._quatInverse),e.copy(this._target).add(this._offset),this._floorConstraint&&(this._target.y<0&&(this._target.y=0),e.y<0&&(e.y=0)),t.lookAt(this._target);const n=1-this._dampingFactor;return this._sphericalDelta.theta*=n,this._sphericalDelta.phi*=n,this._panOffset.set(0,0,0),(this._lastPosition.distanceToSquared(e)>fu||8*(1-this._lastQuaternion.dot(t.quaternion))>fu)&&(this._lastPosition.copy(e),this._lastQuaternion.copy(t.quaternion),this._host?.invalidate(),!0)}reset(){this._target.copy(this._target0),this._camera.position.copy(this._position0),this._camera.updateProjectionMatrix(),this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0),this._state=0,this.update()}pinResetPosition(){this._camera&&(this._position0.copy(this._camera.position),this._target0.copy(this._target))}setCamera(t){this._camera=t,this._target.set(0,0,0),this._position0.copy(t.position),this._quat=(new w.Quaternion).setFromUnitVectors(t.up,new w.Vector3(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0),this._lastPosition.copy(t.position),this._lastQuaternion.copy(t.quaternion),this._state=0,t.updateMatrixWorld(!0)}isAutoRotating(){return this._autoRotate}setAutoRotate(t){this._autoRotate=t,this._host?.invalidate()}setFloorConstraint(t){this._floorConstraint=t,this.update()}markCameraChanged(){this._host?.invalidate()}dollyAtCursor(t,e,n){this._onUserInteraction?.();const i=this._camera,r=i.position.distanceTo(this._target),s=Math.max(1,Math.min(5e4,r*t));if(Math.abs(s-r)<fu)return;const o=Math.tan(i.fov/2*Math.PI/180)/i.zoom,a=r-s,c=e*a*o*i.aspect,l=n*a*o;this._panLeftV.setFromMatrixColumn(i.matrix,0).multiplyScalar(c),this._panUpV.setFromMatrixColumn(i.matrix,1).multiplyScalar(l),this._target.add(this._panLeftV).add(this._panUpV),i.position.add(this._panLeftV).add(this._panUpV),this._panCalcOffset.subVectors(i.position,this._target).normalize().multiplyScalar(s),i.position.copy(this._target).add(this._panCalcOffset),this._floorConstraint&&(this._target.y<0&&(this._target.y=0),i.position.y<0&&(i.position.y=0)),this._host?.invalidate()}zoomOrthoAtCursor(t,e,n){this._onUserInteraction?.();const i=this._camera,r=i.zoom,s=Math.max(.1,Math.min(20,r*t)),o=e*(i.right-i.left)/2*(1/r-1/s),a=n*(i.top-i.bottom)/2*(1/r-1/s);this._panLeftV.setFromMatrixColumn(i.matrix,0).multiplyScalar(o),this._panUpV.setFromMatrixColumn(i.matrix,1).multiplyScalar(a),this._target.add(this._panLeftV).add(this._panUpV),i.position.add(this._panLeftV).add(this._panUpV),i.zoom=s,i.updateProjectionMatrix(),this._host?.invalidate()}destroy(){delete this._camera,delete this._host}_getViewportSize(){const t=this._host;if(!t)return{width:1,height:1};const e=t?.element;if(e){const t=e.getBoundingClientRect();if(t.width>0&&t.height>0)return{width:t.width,height:t.height}}const n=t.bounds;return{width:Math.abs(n?.width)||1,height:Math.abs(n?.height)||1}}_handleRotateMove(t,e){this._rotateEnd.set(t,e),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart);const{width:n,height:i}=this._getViewportSize();this._sphericalDelta.theta-=2*Math.PI*this._rotateDelta.x/n*this._rotateSpeed,this._sphericalDelta.phi-=2*Math.PI*this._rotateDelta.y/i*this._rotateSpeed,this._rotateStart.copy(this._rotateEnd),this._host?.invalidate()}_handlePanMove(t,e){this._panEnd.set(t,e),this._panDelta.subVectors(this._panEnd,this._panStart),this._isOrthoLocked?this._panOrtho(this._panDelta.x,this._panDelta.y):this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this._host?.invalidate()}_panOrtho(t,e){const n=this._camera,{width:i,height:r}=this._getViewportSize();this._panLeftV.setFromMatrixColumn(n.matrix,0),this._panLeftV.multiplyScalar(-t*(n.right-n.left)/n.zoom/i),this._panUpV.setFromMatrixColumn(n.matrix,1),this._panUpV.multiplyScalar(e*(n.top-n.bottom)/n.zoom/r),this._target.add(this._panLeftV).add(this._panUpV),n.position.add(this._panLeftV).add(this._panUpV)}panByPixels(t,e){this._onUserInteraction?.(),this._pan(t,e),this._target.add(this._panOffset),this._camera.position.add(this._panOffset),this._panOffset.set(0,0,0),this._host?.invalidate()}_pan(t,e){t*=this._panSpeed,e*=this._panSpeed;const{width:n,height:i}=this._getViewportSize(),r=this._camera;if(r.isPerspectiveCamera){this._panCalcOffset.copy(r.position).sub(this._target);let n=this._panCalcOffset.length();n*=Math.tan(r.fov/2*Math.PI/180),this._panLeftV.setFromMatrixColumn(r.matrix,0),this._panLeftV.multiplyScalar(-2*t*n/i),this._panOffset.add(this._panLeftV),this._panUpV.setFromMatrixColumn(r.matrix,1),this._panUpV.multiplyScalar(2*e*n/i),this._panOffset.add(this._panUpV)}else r.isOrthographicCamera&&(this._panLeftV.setFromMatrixColumn(r.matrix,0),this._panLeftV.multiplyScalar(-t*(r.right-r.left)/r.zoom/n),this._panOffset.add(this._panLeftV),this._panUpV.setFromMatrixColumn(r.matrix,1),this._panUpV.multiplyScalar(e*(r.top-r.bottom)/r.zoom/i),this._panOffset.add(this._panUpV))}}class mu{constructor(){this._mouse=new w.Vector2,this._raycaster=new w.Raycaster}get mouse(){return this._mouse}get lastFocused(){return this._lastFocused}set lastFocused(t){this._lastFocused=t}get lastHovered(){return this._lastHovered}set lastHovered(t){this._lastHovered=t}updateMouseNDC(t,e,n,i,r,s){this._mouse.x=(t-n)/r*2-1,this._mouse.y=-(e-i)/s*2+1}getObjectByRaycast(t,e){const n=this.getObjectsByRaycast(t,e);if(n&&n.length>0)for(const t of n){if(!this._isWorldVisible(t.object))continue;let e=t.object;for(;e;){if(e.userData.context)return e;e=e.parent}}}_isWorldVisible(t){let e=t;for(;e;){if(!e.visible)return!1;e=e.parent}return!0}getObjectsByRaycast(t,e){return this._raycaster.setFromCamera(this._mouse,t),this._raycaster.intersectObjects(e.children,!0)}setHUD(t,e){this._hudScene=t,this._hudCamera=e}handleClick(t,e,n){let i;this._lastFocused&&(this._lastFocused.focused=!1),this._hudScene&&this._hudCamera&&(i=this.getObjectByRaycast(this._hudCamera,this._hudScene)),i||(i=this.getObjectByRaycast(t,e));const r=i?.userData.context;return r&&(r.focused=!0,this._lastFocused=r,r.component?.trigger("click",n)),r}handleHover(t,e,n){let i;this._hudScene&&this._hudCamera&&(i=this.getObjectByRaycast(this._hudCamera,this._hudScene)),i||(i=this.getObjectByRaycast(t,e));const r=i?.userData.context;r!==this._lastHovered&&(this._lastHovered&&(this._lastHovered.component?.trigger("mouseleave",n),this._lastHovered=void 0),r&&(this._lastHovered=r,this._lastHovered.component?.trigger("mouseenter",n)))}destroy(){this._lastFocused=void 0,this._lastHovered=void 0,this._hudScene=void 0,this._hudCamera=void 0}}const yu=Math.PI/180*15;class bu{constructor(){this._mode="translate",this._isDragging=!1}get controls(){return this._controls}get mode(){return this._mode}get attached(){return this._attached}get isAttached(){return!!this._attached}get isDragging(){return this._isDragging}get isEngaged(){return!!this._controls?.axis}setup(t,e,n){this.destroy(),this._scene=n;const i=document.createElement("div");i.style.cssText="position:absolute;left:0;top:0;width:100%;height:100%;pointer-events:none",i.setPointerCapture=()=>{},i.releasePointerCapture=()=>{},e.appendChild(i),this._proxyElement=i,this._controls=new _.TransformControls(t,i),this._controls.setMode(this._mode),n.add(this._controls.getHelper()),this._controls.addEventListener("dragging-changed",t=>{this._isDragging=t.value,this.onDraggingChanged?.(t.value)}),this._controls.addEventListener("change",()=>{this._attached&&this.onObjectChange?.(this._attached)})}forwardEvent(t,e){if(!this._proxyElement||!this._controls)return;"rotate"===this._mode&&this._controls.setRotationSnap(t.shiftKey?yu:null);const n=new PointerEvent(e,{clientX:t.clientX,clientY:t.clientY,button:"pointermove"===e?-1:t.button??0,pointerId:1,pointerType:"mouse",bubbles:!0});this._proxyElement.dispatchEvent(n)}forwardTouch(t,e){if(!this._proxyElement||!this._controls)return;const n=new PointerEvent(e,{clientX:t.clientX,clientY:t.clientY,button:"pointermove"===e?-1:0,pointerId:t.identifier+10,pointerType:"touch",bubbles:!0});this._proxyElement.dispatchEvent(n)}setMode(t){this._mode=t,this._controls?.setMode(t)}attach(t){this._attached=t,this._controls?.attach(t),this._controls?.getHelper().updateMatrixWorld(!0),this.onAttachChanged?.(!0)}detach(){this._controls?.detach(),this._attached=void 0,this.onAttachChanged?.(!1)}setRotationSnap(t){this._controls&&this._controls.setRotationSnap(t?yu:null)}updateCamera(t){this._controls&&(this._controls.camera=t)}destroy(){this._controls&&(this._controls.detach(),this._controls.dispose(),this._scene&&this._scene.remove(this._controls.getHelper()),this._controls=void 0),this._proxyElement?.parentNode&&this._proxyElement.parentNode.removeChild(this._proxyElement),this._proxyElement=void 0,this._attached=void 0,this._isDragging=!1}}const _u=.01;function vu(t){const[e,n,i]=t,r=Math.abs(e-1),s=Math.abs(n-1),o=Math.abs(i-1);return r<_u&&s<_u&&o<_u?null:r>=s&&r>=o?e:s>=r&&s>=o?n:i}class xu{constructor(){this._mouseDownAltKey=!1}captureAltKey(t){this._mouseDownAltKey=t}setupCallbacks(t,e,n,i){t.onDraggingChanged=r=>{e.setEnabled(!r);const s=n();s&&(i?.onDraggingChanged?.(r),r?(this._onDragStart(t,s),s.hostElement&&this._showInfoOverlay(s.hostElement)):(this._hideInfoOverlay(),this._onDragEnd(t,s)),s.app?.commander?.execute(null),s.invalidate())},t.onObjectChange=e=>{if(this._syncFromGizmo(t,e),this._infoOverlay){const n=t.controls?.axis??null;this._updateInfoOverlay(t.mode,e,n)}n()?.invalidate()},t.onAttachChanged=t=>{i?.onAttachChanged?.(t)}}_onDragStart(t,e){this._mouseDownAltKey&&"translate"===t.mode&&this._performAltDragDuplicate(e);const n=e.root?.selected||[];n.length>1&&this._captureMultiSelectState(t,n);const i=t.attached;i&&("rotate"!==t.mode||this._gizmoInitialRotation?"translate"!==t.mode||this._dragStartPosition||(this._dragStartPosition=i.position.clone()):this._gizmoInitialRotation=i.rotation.clone()),"scale"===t.mode&&this._captureScalePreDrag(t)}_performAltDragDuplicate(t){const e=t.root?.selected||[];if(0===e.length||!t.root)return;const n=t.root,i=[];for(const t of e){const e=t.parent,r=new Map,s=Ic(t,t=>{const e=n.getNewRefid();return void 0!==t&&r.set(t,e),e});s.replaceRefids(r),e.addComponent(s),i.push({component:s,to_container:e})}this._altDragDuplicates=i}_captureMultiSelectState(t,e){const n=t.attached;if(n)if("translate"===t.mode){const t=new Map,i=n.position;for(let n=1;n<e.length;n++){const r=e[n]._realObject;r?.object3d&&r.gizmoTransformable&&t.set(r,r.object3d.position.clone().sub(i))}this._multiSelectOffsets=t}else if("rotate"===t.mode){this._gizmoInitialRotation=n.rotation.clone();const t=new Map;for(let n=1;n<e.length;n++){const i=e[n]._realObject;i?.object3d&&i.gizmoTransformable&&t.set(i,i.object3d.rotation.clone())}this._multiSelectInitialRotations=t}else if("scale"===t.mode){const t=new Map;for(let n=1;n<e.length;n++){const i=e[n],r=i._realObject;if(r?.object3d&&r.gizmoTransformable){const{left:e,top:n,width:s,height:o}=i.bounds,{zPos:a=0}=i.state,c=i.state.depth;t.set(r,{left:e,top:n,width:s,height:o,depth:c,zPos:a,scaleX:r.object3d.scale.x,scaleY:r.object3d.scale.y,scaleZ:r.object3d.scale.z})}}this._multiSelectPreDragDimensions=t}}_captureScalePreDrag(t){const e=t.attached,n=e?.userData.context;if(!n||!e)return;const{left:i,top:r,width:s,height:o}=n.component.bounds,{zPos:a=0}=n.component.state,c=n.component.state.depth??n.effectiveDepth;this._preDragDimension={left:i,top:r,width:s,height:o,depth:c,zPos:a},this._preDragScale={x:e.scale.x,y:e.scale.y,z:e.scale.z},this._preDragEffectiveDepth=void 0,this._scaleAnchorSign=this._computeAnchorSign(t,e),this._preDragAttachedPosition=e.position.clone()}_computeAnchorSign(t,e){const n=t.controls;if(!n)return{x:0,y:0,z:0};const i=n.axis;if(!i||"XYZE"===i)return{x:0,y:0,z:0};if(i.includes("X")&&i.includes("Y")&&i.includes("Z"))return{x:0,y:0,z:0};const r=new w.Quaternion;e.getWorldQuaternion(r),r.invert();const s=n.pointStart.clone().applyQuaternion(r),o=.001,a={x:0,y:0,z:0};return i.includes("X")&&Math.abs(s.x)>o&&(a.x=Math.sign(s.x)),i.includes("Y")&&Math.abs(s.y)>o&&(a.y=Math.sign(s.y)),i.includes("Z")&&Math.abs(s.z)>o&&(a.z=Math.sign(s.z)),a}_onDragEnd(t,e){if(this._altDragDuplicates&&this._altDragDuplicates.length>0&&(e.app?.commander.execute(new Oc({changes:this._altDragDuplicates})),this._altDragDuplicates=void 0),this._multiSelectOffsets=void 0,this._gizmoInitialRotation=void 0,this._multiSelectInitialRotations=void 0,this._dragStartPosition=void 0,this._preDragDimension){const e=t.attached,n=e?.userData.context;if(n&&(void 0!==this._preDragEffectiveDepth&&n.applyDimensionFromGizmo({depth:this._preDragEffectiveDepth}),n.update()),this._multiSelectPreDragDimensions)for(const[t]of this._multiSelectPreDragDimensions)t.update()}const n=e.root?.selected||[];for(const e of n){const n=e._realObject;n?.onGizmoDragEnd(t.mode)}for(const t of n){let e=t.parent;for(;e?.isGroup?.();){const t=[];e._realObject&&t.push(e._realObject);for(const n of e.components||[])n._realObject&&t.push(n._realObject);for(const e of t)e._suppressOnchange=!0;e.calculateBounds();for(const e of t)e._suppressOnchange=!1,e.updateTransform();e=e.parent}}this._preDragDimension=void 0,this._preDragScale=void 0,this._preDragEffectiveDepth=void 0,this._multiSelectPreDragDimensions=void 0,this._scaleAnchorSign=void 0,this._preDragAttachedPosition=void 0}_syncFromGizmo(t,e){const n=e.userData.context;if(n)if("scale"===t.mode&&this._preDragDimension&&this._preDragScale){const{ratioX:t,ratioY:i,ratioZ:r,sign:s}=this._syncDimensionFromGizmo(n,e);if(this._multiSelectPreDragDimensions)for(const[e,n]of this._multiSelectPreDragDimensions)e.applyDimensionFromGizmo(this._computeAnchorProps(n,t,i,r,s))}else{if(n.syncFromObject3D(),"translate"===t.mode&&this._applyGroundSnap(e,n),this._multiSelectOffsets){const n=e.position;for(const[e,i]of this._multiSelectOffsets)e.object3d&&(e.object3d.position.copy(n).add(i),"translate"===t.mode&&this._applyGroundSnap(e.object3d,e),e.syncFromObject3D())}if(this._multiSelectInitialRotations&&this._gizmoInitialRotation){const t=e.rotation.x-this._gizmoInitialRotation.x,n=e.rotation.y-this._gizmoInitialRotation.y,i=e.rotation.z-this._gizmoInitialRotation.z;for(const[e,r]of this._multiSelectInitialRotations)e.object3d&&(e.object3d.rotation.set(r.x+t,r.y+n,r.z+i),e.syncFromObject3D())}}}_applyGroundSnap(t,e){const n=e.effectiveDepth/2,i=t.position.y-n,r=Math.abs(i);if(r<2)t.position.y=n,e.syncFromObject3D();else if(r<10){const s=(r-2)/8,o=1-s*s;t.position.y=n+i*(1-o),e.syncFromObject3D()}}_syncDimensionFromGizmo(t,e){const n=this._preDragDimension,i=this._preDragScale;let r={...this._scaleAnchorSign??{x:0,y:0,z:0}},s=e.scale.x/i.x,o=e.scale.y/i.y,a=e.scale.z/i.z;if(t.component.state.ratioLock){const t=vu([s,o,a]);if(t){s=o=a=t,e.scale.set(t*i.x,t*i.y,t*i.z);const n=r.x||r.y||r.z;n&&(r={x:n,y:n,z:n})}}return t.applyDimensionFromGizmo(this._computeAnchorProps(n,s,o,a,r)),!this._preDragAttachedPosition||0===r.x&&0===r.y&&0===r.z||this._applyAnchorPositionCorrection(e,n,i,r),{ratioX:s,ratioY:o,ratioZ:a,sign:r}}_computeAnchorProps(t,e,n,i,r){const s=t.width*e,o=t.height*i,a=r.x>0?0:r.x<0?t.width-s:(t.width-s)/2,c=r.z>0?0:r.z<0?t.height-o:(t.height-o)/2,l={left:t.left+a,top:t.top+c,width:s,height:o};if(void 0!==t.depth){const e=t.depth*n,i=r.y>0?0:r.y<0?t.depth-e:(t.depth-e)/2;l.depth=e,l.zPos=t.zPos+i}return l}_applyAnchorPositionCorrection(t,e,n,i){const r=new w.Vector3(i.x*(t.scale.x-n.x)*e.width/2,i.y*(t.scale.y-n.y)*(e.depth??0)/2,i.z*(t.scale.z-n.z)*e.height/2),s=new w.Quaternion;t.getWorldQuaternion(s),r.applyQuaternion(s);const o=this._preDragAttachedPosition;t.position.set(o.x+r.x,o.y+r.y,o.z+r.z)}_showInfoOverlay(t){if(this._infoHostElement=t,this._infoOverlay)return;const e=document.createElement("div");e.style.cssText="\n position: absolute; z-index: 10000; pointer-events: none;\n left: 50%; top: 16px; transform: translateX(-50%);\n padding: 6px 16px; border-radius: 6px;\n background: rgba(0,0,0,0.8); color: #fff;\n font: bold 16px/1.4 'Pretendard', system-ui, sans-serif;\n letter-spacing: 0.5px;\n white-space: nowrap; opacity: 0; transition: opacity 0.15s;\n box-shadow: 0 2px 8px rgba(0,0,0,0.3);\n ",t.style.position="relative",t.appendChild(e),this._infoOverlay=e,requestAnimationFrame(()=>{e.style.opacity="1"})}_updateInfoOverlay(t,e,n){if(!this._infoOverlay)return;const i=t=>(t>=0?"+":"")+t.toFixed(1);if("rotate"===t){if(!this._gizmoInitialRotation)return;const t=180/Math.PI,n=(e.rotation.x-this._gizmoInitialRotation.x)*t,r=(e.rotation.y-this._gizmoInitialRotation.y)*t,s=(e.rotation.z-this._gizmoInitialRotation.z)*t,o=[Math.abs(n),Math.abs(r),Math.abs(s)],a=o.indexOf(Math.max(...o)),c=["X","Y","Z"],l=[n,r,s],h=[e.rotation.x*t,e.rotation.y*t,e.rotation.z*t];this._infoOverlay.textContent=`↻ ${c[a]}: ${h[a].toFixed(1)}° (${i(l[a])})`}else if("translate"===t){if(!this._dragStartPosition)return;const t=e.position.clone().sub(this._dragStartPosition),n=e.position,r=(t,e,n)=>Math.abs(n)<.05?`${t}:${e.toFixed(0)}`:`${t}:${e.toFixed(0)}(${i(n)})`;this._infoOverlay.textContent=`↔ ${r("X",n.x,t.x)} ${r("Y",n.y,t.y)} ${r("Z",n.z,t.z)}`}else if("scale"===t){if(!this._preDragScale)return;this._infoOverlay.textContent=this._formatScaleInfo(e,n)}}_formatScaleInfo(t,e){const n=this._preDragScale,i=this._preDragDimension,r=t.scale.x/(n.x||1),s=t.scale.y/(n.y||1),o=t.scale.z/(n.z||1),a=i?i.width*r:t.scale.x,c=null!=i?.depth?i.depth*s:t.scale.y,l=i?i.height*o:t.scale.z,h=i?i.width*(r-1):t.scale.x-n.x,d=null!=i?.depth?i.depth*(s-1):t.scale.y-n.y,u=i?i.height*(o-1):t.scale.z-n.z,p=t=>(t>=0?"+":"")+t.toFixed(0),f=t=>t.toFixed(0);switch(e){case"X":return`⤢ W ${f(a)}px (${p(h)})`;case"Y":return`⤢ D ${f(c)}px (${p(d)})`;case"Z":return`⤢ H ${f(l)}px (${p(u)})`}return Math.abs(r-s)<.01&&Math.abs(s-o)<.01?`⤢ ×${r.toFixed(2)} (${f(a)}×${f(c)}×${f(l)})`:`⤢ W:${f(a)}(${p(h)}) D:${f(c)}(${p(d)}) H:${f(l)}(${p(u)})`}_hideInfoOverlay(){this._infoOverlay&&(this._infoOverlay.remove(),this._infoOverlay=void 0),this._infoHostElement=void 0}}class wu{constructor(){this._mouseIsDown=!1,this._isDragging=!1,this._touchGizmoCaptured=!1,this._mouseDownPos={x:0,y:0}}get hostElement(){return this._hostElement}setup(t,e,n){this.cleanup(),this._hostElement=t,this._gizmo=e.gizmo,this._controls=e.controls,this._camera=e.camera,this._scene=e.scene,this._event=e.event,this._delegate=n,t.hasAttribute("tabindex")||t.setAttribute("tabindex","0"),t.style.outline="none";const i={mousedown:t=>this._onMouseDown(t),mousemove:t=>this._onMouseMove(t),wheel:t=>{t.stopPropagation(),this._delegate.handleWheel(t)},dblclick:t=>{t.stopPropagation(),this.updateMouseNDCFromClient(t.clientX,t.clientY),this._delegate.handleDblClick(t)},contextmenu:t=>{t.preventDefault()},touchstart:t=>{if(t.stopPropagation(),1===t.touches?.length&&this._gizmo?.isAttached){const e=t.touches[0];if(this._gizmo.forwardTouch(e,"pointermove"),this._gizmo.isEngaged)return this._gizmo.forwardTouch(e,"pointerdown"),this._touchGizmoCaptured=!0,void t.preventDefault()}this._touchGizmoCaptured=!1,this._delegate.handleTouchStart(t)},touchmove:t=>{if(t.stopPropagation(),this._touchGizmoCaptured&&1===t.touches.length)return this._gizmo.forwardTouch(t.touches[0],"pointermove"),void t.preventDefault();this._delegate.handleTouchMove(t)},touchend:t=>{if(t.stopPropagation(),this._touchGizmoCaptured){const e=t.changedTouches[0];return e&&this._gizmo.forwardTouch(e,"pointerup"),void(this._touchGizmoCaptured=!1)}this._delegate.handleTouchEnd(t)},keydown:t=>{!this._delegate.handleKeyDown(t)||t.ctrlKey||t.metaKey||t.stopPropagation()},keyup:t=>{(this._delegate.handleKeyUp?.(t)??!1)&&t.stopPropagation()}};t.addEventListener("mousedown",i.mousedown),t.addEventListener("mousemove",i.mousemove),t.addEventListener("wheel",i.wheel),t.addEventListener("dblclick",i.dblclick),t.addEventListener("contextmenu",i.contextmenu),t.addEventListener("touchstart",i.touchstart,{passive:!1}),t.addEventListener("touchmove",i.touchmove,{passive:!1}),t.addEventListener("touchend",i.touchend),t.addEventListener("keydown",i.keydown),t.addEventListener("keyup",i.keyup),this._boundHandlers=i}cleanup(){this._removeDocCapture();const t=this._hostElement,e=this._boundHandlers;t&&e&&(t.removeEventListener("mousedown",e.mousedown),t.removeEventListener("mousemove",e.mousemove),t.removeEventListener("wheel",e.wheel),t.removeEventListener("dblclick",e.dblclick),t.removeEventListener("contextmenu",e.contextmenu),t.removeEventListener("touchstart",e.touchstart),t.removeEventListener("touchmove",e.touchmove),t.removeEventListener("touchend",e.touchend),t.removeEventListener("keydown",e.keydown),t.removeEventListener("keyup",e.keyup),t.removeAttribute("tabindex"),t.style.outline=""),this._boundHandlers=void 0,this._hostElement=void 0,this._mouseIsDown=!1,this._isDragging=!1}forceCleanupDragState(){this._removeDocCapture(),this._mouseIsDown=!1,this._isDragging=!1}clientToElementCoords(t,e){const n=this._hostElement;if(!n)return{x:t,y:e};const i=n.getBoundingClientRect();return{x:t-i.left,y:e-i.top}}updateMouseNDCFromClient(t,e){const n=this._hostElement?.getBoundingClientRect();if(!n||0===n.width||0===n.height)return;const i=t-n.left,r=e-n.top;this._event.updateMouseNDC(i,r,0,0,n.width,n.height)}_onMouseDown(t){if(t.stopPropagation(),0!==t.button)return void(this._mouseIsDown&&(this._removeDocCapture(),this._isDragging&&(this._gizmo?.forwardEvent(new MouseEvent("pointerup",{bubbles:!1}),"pointerup"),this._controls?.onDragEnd?.({offsetX:t.offsetX,offsetY:t.offsetY})),this._mouseIsDown=!1,this._isDragging=!1));if(this._hostElement.focus(),this._removeDocCapture(),this._mouseIsDown=!1,this._isDragging=!1,this._delegate.isPlacementMode())return void this._delegate.handlePlacementClick(t);if(this._delegate.isSpacePanning?.()??!1)return this._mouseIsDown=!0,this._isDragging=!1,this._mouseDownPos={x:t.clientX,y:t.clientY},this._docMoveHandler=t=>{t.stopPropagation();const e=t.clientX-this._mouseDownPos.x,n=t.clientY-this._mouseDownPos.y;if(!this._isDragging){if(e*e+n*n<wu.DRAG_THRESHOLD)return;this._isDragging=!0;const t=this.clientToElementCoords(this._mouseDownPos.x,this._mouseDownPos.y);this._controls.onDragStart({offsetX:t.x,offsetY:t.y,altKey:!0})}const i=this.clientToElementCoords(t.clientX,t.clientY);this._controls.onDragMove({offsetX:i.x,offsetY:i.y,altKey:!0})},this._docUpHandler=t=>{if(t.stopPropagation(),this._removeDocCapture(),this._isDragging){const e=this.clientToElementCoords(t.clientX,t.clientY);this._controls.onDragEnd({offsetX:e.x,offsetY:e.y})}this._mouseIsDown=!1,this._isDragging=!1},document.addEventListener("mousemove",this._docMoveHandler,!0),void document.addEventListener("mouseup",this._docUpHandler,!0);if(t.shiftKey&&!t.altKey&&!this._gizmo?.isEngaged){const e=this.clientToElementCoords(t.clientX,t.clientY);return this._mouseIsDown=!0,this._isDragging=!1,this._mouseDownPos={x:t.clientX,y:t.clientY},this._docMoveHandler=t=>{t.stopPropagation();const n=t.clientX-this._mouseDownPos.x,i=t.clientY-this._mouseDownPos.y;if(!this._isDragging){if(n*n+i*i<wu.DRAG_THRESHOLD)return;this._isDragging=!0,this._delegate.handleBoxSelectionStart?.(e.x,e.y)}const r=this.clientToElementCoords(t.clientX,t.clientY);this._delegate.handleBoxSelectionUpdate?.(r.x,r.y)},this._docUpHandler=t=>{if(t.stopPropagation(),this._removeDocCapture(),this._isDragging)this._delegate.handleBoxSelectionEnd?.(t.shiftKey,t.ctrlKey||t.metaKey);else{const e=this.clientToElementCoords(t.clientX,t.clientY);this.updateMouseNDCFromClient(t.clientX,t.clientY),this._delegate.handleClickAt(e.x,e.y,t)}this._mouseIsDown=!1,this._isDragging=!1},document.addEventListener("mousemove",this._docMoveHandler,!0),void document.addEventListener("mouseup",this._docUpHandler,!0)}if(this.updateMouseNDCFromClient(t.clientX,t.clientY),this._delegate.tryVertexDragStart?.(t))return this._mouseIsDown=!0,this._isDragging=!0,this._mouseDownPos={x:t.clientX,y:t.clientY},this._docMoveHandler=t=>{t.stopPropagation(),this.updateMouseNDCFromClient(t.clientX,t.clientY),this._delegate.handleVertexDragMove?.(t)},this._docUpHandler=t=>{t.stopPropagation(),this._removeDocCapture(),this._delegate.handleVertexDragEnd?.(t),this._mouseIsDown=!1,this._isDragging=!1},document.addEventListener("mousemove",this._docMoveHandler,!0),void document.addEventListener("mouseup",this._docUpHandler,!0);this._delegate.captureMouseDownAltKey(t.altKey),this._gizmo.forwardEvent(t,"pointermove"),this._gizmo.forwardEvent(t,"pointerdown");let e=this._gizmo.isDragging;!e&&t.altKey&&this._delegate.tryAltClickSelect(t)&&(this._gizmo.forwardEvent(t,"pointermove"),this._gizmo.forwardEvent(t,"pointerdown"),e=this._gizmo.isDragging),this._mouseIsDown=!0,this._isDragging=!1,this._mouseDownPos={x:t.clientX,y:t.clientY},this._docMoveHandler=t=>{if(t.stopPropagation(),e)return void this._gizmo.forwardEvent(t,"pointermove");const n=t.clientX-this._mouseDownPos.x,i=t.clientY-this._mouseDownPos.y;if(!this._isDragging){if(n*n+i*i<wu.DRAG_THRESHOLD)return;this._isDragging=!0;const e=this.clientToElementCoords(this._mouseDownPos.x,this._mouseDownPos.y);this._controls.onDragStart({offsetX:e.x,offsetY:e.y,altKey:t.altKey,ctrlKey:t.ctrlKey,metaKey:t.metaKey})}const r=this.clientToElementCoords(t.clientX,t.clientY);this._controls.onDragMove({offsetX:r.x,offsetY:r.y,altKey:t.altKey,ctrlKey:t.ctrlKey,metaKey:t.metaKey})},this._docUpHandler=t=>{if(t.stopPropagation(),this._removeDocCapture(),e)return this._gizmo.forwardEvent(t,"pointerup"),this._mouseIsDown=!1,void(this._isDragging=!1);if(this._isDragging){const e=this.clientToElementCoords(t.clientX,t.clientY);this._controls.onDragEnd({offsetX:e.x,offsetY:e.y})}else{const e=this.clientToElementCoords(t.clientX,t.clientY);this.updateMouseNDCFromClient(t.clientX,t.clientY),this._delegate.handleClickAt(e.x,e.y,t)}this._mouseIsDown=!1,this._isDragging=!1},document.addEventListener("mousemove",this._docMoveHandler,!0),document.addEventListener("mouseup",this._docUpHandler,!0)}_onMouseMove(t){if(t.stopPropagation(),this._mouseIsDown)return;if(this._delegate.isPlacementMode())return void this._delegate.handlePlacementHover(t);this.updateMouseNDCFromClient(t.clientX,t.clientY);const e=this._camera.activeCamera;e&&this._scene.scene&&this._event.handleHover(e,this._scene.scene,t),this._gizmo.forwardEvent(t,"pointermove")}_removeDocCapture(){this._docMoveHandler&&(document.removeEventListener("mousemove",this._docMoveHandler,!0),this._docMoveHandler=void 0),this._docUpHandler&&(document.removeEventListener("mouseup",this._docUpHandler,!0),this._docUpHandler=void 0)}}wu.DRAG_THRESHOLD=16;class Mu{constructor(){this._groundPlane=new w.Plane(new w.Vector3(0,1,0),0)}get isActive(){return!!this._pendingModels}get pendingModels(){return this._pendingModels}setup(t,e){this._camera=t.camera,this._event=t.event,this._scene=t.scene,this._delegate=e}start(t){this._pendingModels=t}stop(){this._pendingModels=void 0,this._removeIndicator()}destroy(){this._removeIndicator(),this._pendingModels=void 0}raycastGroundPlane(t){this._delegate.updateMouseNDCFromClient(t.clientX,t.clientY);const e=this._camera.activeCamera;if(!e)return null;e.updateMatrixWorld(!0);const n=new w.Raycaster;n.setFromCamera(this._event.mouse,e);const i=new w.Vector3;return n.ray.intersectPlane(this._groundPlane,i)}updateIndicator(t){if(!t)return void(this._placementIndicator&&(this._placementIndicator.visible=!1));if(!this._placementIndicator){const t=this._scene?.scene;if(!t)return;const e=new w.RingGeometry(.8,1,32);e.rotateX(-Math.PI/2);const n=new w.MeshBasicMaterial({color:48340,opacity:.6,transparent:!0,side:w.DoubleSide,depthTest:!1});this._placementIndicator=new w.Mesh(e,n),this._placementIndicator.renderOrder=999,t.add(this._placementIndicator)}const e=this._pendingModels?.[0],n=e?.rx??e?.width??50,i=e?.ry??e?.height??50;this._placementIndicator.scale.set(n,1,i),this._placementIndicator.position.copy(t),this._placementIndicator.position.y=1,this._placementIndicator.visible=!0}_removeIndicator(){if(this._placementIndicator){const t=this._placementIndicator;this._scene?.scene?.remove(t),t.geometry.dispose(),t.material.dispose(),this._placementIndicator=void 0}}}const Su={linear:t=>t,"ease-in":t=>t*t,"ease-out":t=>1-(1-t)*(1-t),"ease-in-out":t=>t<.5?2*t*t:1-Math.pow(-2*t+2,2)/2};function Au(t,e,n,i,r,s=new w.Vector3){const o=t*t,a=o*t;return s.set(.5*(2*n.x+(-e.x+i.x)*t+(2*e.x-5*n.x+4*i.x-r.x)*o+(-e.x+3*n.x-3*i.x+r.x)*a),.5*(2*n.y+(-e.y+i.y)*t+(2*e.y-5*n.y+4*i.y-r.y)*o+(-e.y+3*n.y-3*i.y+r.y)*a),.5*(2*n.z+(-e.z+i.z)*t+(2*e.z-5*n.z+4*i.z-r.z)*o+(-e.z+3*n.z-3*i.z+r.z)*a))}class Eu{constructor(){this._slots=new Array(10),this._animating=!1,this._animationProgress=0,this._playStartOffset=0,this._lastPlayProgress=-1,this._playIndex=-1,this._playing=!1,this._orbitRotating=!1,this._orbitPaused=!1}get isAnimating(){return this._animating}get isPlaying(){return this._playing}get isOrbitRotating(){return this._orbitRotating}get isOrbitPaused(){return this._orbitPaused}get playIndex(){return this._playIndex}get lastPlayProgress(){return this._lastPlayProgress}get playProgress(){if(!this._playing||this._playIndex<0)return 0;const t=this.getPlayableSlots().length;if(t<2)return 0;const e=(this._playIndex-1+t)%t;let n=this._animating?this._animationProgress:1;return this._playStartOffset>0&&(n=this._playStartOffset+n*(1-this._playStartOffset)),(e+n)%t/t}setCallbacks(t,e){this._onInvalidate=t,this._onAnimationComplete=e}saveSlot(t,e){if(t<0||t>9)return;const n=this._slots[t];this._slots[t]={...e,name:"name"in e?e.name:n?.name}}renameSlot(t,e){if(t<0||t>9)return;const n=this._slots[t];n&&(n.name=e||void 0)}clearSlot(t){t<0||t>9||(this._slots[t]=void 0)}getSlot(t){return this._slots[t]}exportSlots(){return this._slots.map(t=>t?{...t}:null)}importSlots(t){if(Array.isArray(t))for(let e=0;e<10;e++){const n=t[e];this._slots[e]=n?{...n}:void 0}}resetAll(){this._slots=new Array(10)}getPlayableSlots(){return this._slots.map((t,e)=>t&&!t.excludeFromPlay?e:-1).filter(t=>t>=0)}swapSlots(t,e){if(t<0||t>9||e<0||e>9||t===e)return;const n=this._slots[t];this._slots[t]=this._slots[e],this._slots[e]=n}moveSlot(t,e){if(t<1||t>9||e<1||e>9||t===e)return;const n=this._slots[t];this._slots.splice(t,1),this._slots.splice(e,0,n)}animateToSlot(t,e,n,i=800,r){const s=this._slots[t];if(!s)return!1;this.stopAnimation(),this._animating=!0,this._animationProgress=0;const o=e.position.clone(),a=n.target.clone(),c=new w.Vector3(s.position.x,s.position.y,s.position.z),l=new w.Vector3(s.target.x,s.target.y,s.target.z),h=.01,d=Math.max(o.distanceTo(a),h),u=Math.max(c.distanceTo(l),h),p=(new w.Vector3).subVectors(a,o),f=(new w.Vector3).subVectors(l,c),g=p.lengthSq()>1e-4?p.normalize():new w.Vector3(0,0,-1).applyQuaternion(e.quaternion),m=f.lengthSq()>1e-4?f.normalize():g.clone(),y=(new w.Quaternion).setFromUnitVectors(new w.Vector3(0,0,-1),g),b=(new w.Quaternion).setFromUnitVectors(new w.Vector3(0,0,-1),m),_=Su[s.easing??"ease-in-out"];return this._runAnimation(i,_,t=>{r?Au(t,r.prevPos,o,c,r.nextPos,e.position):e.position.lerpVectors(o,c,t);const i=y.clone().slerp(b,t),s=new w.Vector3(0,0,-1).applyQuaternion(i),a=d+(u-d)*t,l=e.position.clone().add(s.multiplyScalar(a));n.restoreTarget(l)}),!0}_animatePathSegment(t,e,n,i,r,s){const o=Su[i];this._runAnimation(n,o,n=>{const i=t+(e-t)*n,o=this.evaluatePath(i<=1?i:i-1);o&&(r.position.copy(o.position),s.restoreTarget(o.target))})}_runAnimation(t,e,n){this.stopAnimation(),this._animating=!0,this._animationProgress=0;const i=performance.now(),r=()=>{const s=performance.now()-i,o=Math.min(s/t,1),a=e(o);this._animationProgress=a,n(a),this._onInvalidate?.(),o<1?this._animationId=requestAnimationFrame(r):(this._animating=!1,this._animationId=void 0,this._onAnimationComplete?.())};this._animationId=requestAnimationFrame(r)}_initFromProgress(t,e){const n=t*e,i=Math.min(Math.floor(n),e-1);this._playStartOffset=n-i,this._playIndex=(i+1)%e}startPlay(t,e,n=2e3,i=1200,r=-1,s=!1){if(this._playing)return void this.stopPlay();const o=this.getPlayableSlots();if(o.length<2)return;this._playing=!0;let a=!0,c=-1;const l=r>=0&&r<=1?r:this._lastPlayProgress>0&&this._lastPlayProgress<1?this._lastPlayProgress:-1;s?this._playIndex=0:l>=0?(this._initFromProgress(l,o.length),c=l,a=!1):this._playIndex=0;const h=t=>new w.Vector3(t.x,t.y,t.z),d=t=>{this._onAnimationComplete=()=>{this._playing&&(this._playStartOffset=0,setTimeout(()=>{this._playing&&(this._playIndex=(this._playIndex+1)%o.length,u())},t))}},u=()=>{if(!this._playing)return;const r=o[this._playIndex],s=this._slots[r],l=s?.holdDuration??n,u=s?.transitionDuration??i;if(c>=0){const n=c;let i=this._playIndex/o.length;i<=n&&(i+=1),c=-1;const r=this._playStartOffset,a=Math.max(Math.round(u*(1-r)),100);return d(l),void this._animatePathSegment(n,i,a,s?.easing??"ease-in-out",t,e)}const p=this._buildSplineContext(o,a,t,e,h);a=!1,d(l),this.animateToSlot(r,t,e,u,p)};u()}_buildSplineContext(t,e,n,i,r){if(t.length<3)return;const s=t.length,o=t[(this._playIndex+1)%s],a=this._slots[o];if(!a)return;if(e)return{prevPos:n.position.clone(),nextPos:r(a.position)};const c=t[(this._playIndex-2+s)%s],l=this._slots[c];return l?{prevPos:r(l.position),nextPos:r(a.position)}:void 0}setProgressForSlot(t){const e=this.getPlayableSlots(),n=e.indexOf(t);n<0||e.length<2?this._lastPlayProgress=-1:this._lastPlayProgress=n/e.length}stopPlay(){this._lastPlayProgress=this.playProgress,this._playing=!1,this._playIndex=-1,this._playStartOffset=0,this._onAnimationComplete=void 0,this.stopAnimation()}resetPlay(){this.stopPlay(),this._lastPlayProgress=-1}toggleOrbitRotation(t){const e=t.isAutoRotating();this._orbitRotating=!e,this._orbitPaused=!this._orbitRotating,t.setAutoRotate(this._orbitRotating)}stopOrbitRotation(t){this._orbitRotating=!1,this._orbitPaused=!1,t.setAutoRotate(!1)}evaluatePath(t){const e=this.getPlayableSlots();if(e.length<2)return null;const n=e.length,i=Math.max(0,Math.min(1,t)),r=t=>{const i=this._slots[e[(t%n+n)%n]];return i?new w.Vector3(i.position.x,i.position.y,i.position.z):new w.Vector3},s=t=>{const i=this._slots[e[(t%n+n)%n]];return i?new w.Vector3(i.target.x,i.target.y,i.target.z):new w.Vector3};if(2===n){const t=i<.5?2*i:2*(1-i);return{position:r(0).lerp(r(1),t),target:s(0).lerp(s(1),t)}}const o=i*n,a=Math.min(Math.floor(o),n-1),c=o-a,l=Au(c,r(a-1),r(a),r(a+1),r(a+2)),h=r(a),d=r(a+1),u=s(a),p=s(a+1),f=.01,g=Math.max(h.distanceTo(u),f),m=Math.max(d.distanceTo(p),f),y=(new w.Vector3).subVectors(u,h),b=(new w.Vector3).subVectors(p,d),_=y.lengthSq()>1e-4?y.normalize():new w.Vector3(0,0,-1),v=b.lengthSq()>1e-4?b.normalize():_.clone(),x=(new w.Quaternion).setFromUnitVectors(new w.Vector3(0,0,-1),_),M=(new w.Quaternion).setFromUnitVectors(new w.Vector3(0,0,-1),v),S=x.clone().slerp(M,c),A=new w.Vector3(0,0,-1).applyQuaternion(S),E=g+(m-g)*c,k=l.clone().add(A.multiplyScalar(E));return{position:l,target:k}}stopAnimation(){void 0!==this._animationId&&(cancelAnimationFrame(this._animationId),this._animationId=void 0),this._animating=!1}destroy(){this.stopPlay(),this.stopAnimation(),this._orbitPaused=!1,this._slots=new Array(10),this._onInvalidate=void 0,this._onAnimationComplete=void 0}}class ku{constructor(){this._overlay=null,this._hostElement=null,this._startX=0,this._startY=0,this._currentX=0,this._currentY=0,this._active=!1}get isActive(){return this._active}setup(t){this._hostElement=t}startSelection(t,e){this._hostElement&&(this._startX=t,this._startY=e,this._currentX=t,this._currentY=e,this._active=!0,this._overlay=document.createElement("div"),this._overlay.style.cssText="\n position: absolute;\n border: 1px solid #4a9eff;\n background: rgba(74, 158, 255, 0.1);\n pointer-events: none;\n z-index: 1000;\n ",this._hostElement.appendChild(this._overlay),this._updateOverlay())}updateSelection(t,e){this._active&&(this._currentX=t,this._currentY=e,this._updateOverlay())}endSelection(t,e,n){if(!this._active||!this._hostElement)return this.cancelSelection(),[];const i=this._hostElement.getBoundingClientRect(),r=i.width,s=i.height,o=Math.min(this._startX,this._currentX),a=Math.max(this._startX,this._currentX),c=Math.min(this._startY,this._currentY),l=Math.max(this._startY,this._currentY);if(a-o<5&&l-c<5)return this.cancelSelection(),[];const h=o/r*2-1,d=a/r*2-1,u=-l/s*2+1,p=-c/s*2+1,f=[],g=new w.Vector3;for(const e of n){const n=e._realObject;n?.object3d&&(g.copy(n.object3d.position),g.project(t),g.z>1||g.x>=h&&g.x<=d&&g.y>=u&&g.y<=p&&f.push(e))}return this.cancelSelection(),f}cancelSelection(){this._active=!1,this._overlay&&this._hostElement&&this._hostElement.removeChild(this._overlay),this._overlay=null}destroy(){this.cancelSelection(),this._hostElement=null}_updateOverlay(){if(!this._overlay)return;const t=Math.min(this._startX,this._currentX),e=Math.min(this._startY,this._currentY),n=Math.abs(this._currentX-this._startX),i=Math.abs(this._currentY-this._startY);this._overlay.style.left=`${t}px`,this._overlay.style.top=`${e}px`,this._overlay.style.width=`${n}px`,this._overlay.style.height=`${i}px`}}const Cu=4890367,Tu=16750592;class Pu{constructor(){this._componentHandles=[],this._activeVertexHandles=[],this._activeHandleIndex=-1,this._isDragging=!1,this._isExtending=!1,this._dragPlane=new w.Plane,this._dragOffset=new w.Vector3,this._raycaster=new w.Raycaster,this._intersection=new w.Vector3}get isDragging(){return this._isDragging}get isAttached(){return this._componentHandles.length>0}setVisible(t){this._handleGroup&&(this._handleGroup.visible=t)}attachMultiple(t,e,n){this.detach();const i=t.filter(t=>t.mutable&&t.path&&t.path.length>=2);if(0!==i.length){this._scene3d=e,this._commander=n,this._handleGroup=new w.Group,this._handleGroup.name="__vertexHandles__",this._handleGroup.renderOrder=1e4;for(const t of i){const e=this._buildComponentHandles(t);this._componentHandles.push(e)}e.add(this._handleGroup)}}attach(t,e,n){this.attachMultiple([t],e,n)}detach(){this._handleGroup&&this._scene3d&&(this._scene3d.remove(this._handleGroup),Nh(this._handleGroup)),this._componentHandles=[],this._handleGroup=void 0,this._scene3d=void 0,this._commander=void 0,this._activeComponent=void 0,this._activeVertexHandles=[],this._activeHandleIndex=-1,this._isDragging=!1,this._isExtending=!1}_buildComponentHandles(t){const e=[],n=[],i=t.path;if(!i||!this._handleGroup)return{component:t,vertexHandles:e,midpointHandles:n};const{width:r=0,height:s=0}=t.parent?.bounds??{},o=t._realObject,a=o?o.object3d.position.y:0;for(let n=0;n<i.length;n++){const o=i[n],c=new w.Vector3(o.x-r/2,(o.z||0)+a,o.y-s/2),l=this._createVertexHandle(c,n,t);e.push(l),this._handleGroup.add(l)}if(t.pathExtendable)for(let e=0;e<i.length-1;e++){const o=i[e],c=i[e+1],l=new w.Vector3((o.x+c.x)/2-r/2,((o.z||0)+(c.z||0))/2+a,(o.y+c.y)/2-s/2),h=this._createMidpointHandle(l,e,t);n.push(h),this._handleGroup.add(h)}return{component:t,vertexHandles:e,midpointHandles:n}}_rebuildComponentHandles(t){const e=this._componentHandles.findIndex(e=>e.component===t);if(e<0||!this._handleGroup)return;const n=this._componentHandles[e];for(const t of[...n.vertexHandles,...n.midpointHandles])this._handleGroup.remove(t),t.geometry.dispose(),t.material.dispose();this._componentHandles[e]=this._buildComponentHandles(t),this._activeComponent===t&&(this._activeVertexHandles=this._componentHandles[e].vertexHandles)}_createVertexHandle(t,e,n){const i=new w.SphereGeometry(1,16,12),r=new w.MeshBasicMaterial({color:Cu,transparent:!0,opacity:.8,depthTest:!1}),s=new w.Mesh(i,r);return s.position.copy(t),s.userData.vertexIndex=e,s.userData.handleType="vertex",s.userData.component=n,s.renderOrder=10001,s}_createMidpointHandle(t,e,n){const i=new w.OctahedronGeometry(.7,0),r=new w.MeshBasicMaterial({color:16735602,transparent:!0,opacity:.7,depthTest:!1}),s=new w.Mesh(i,r);return s.position.copy(t),s.userData.segmentIndex=e,s.userData.handleType="midpoint",s.userData.component=n,s.renderOrder=10001,s}_handlePosToPoint(t,e){const{width:n=0,height:i=0}=e.parent?.bounds??{},r=e._realObject,s=r?r.object3d.position.y:0,o={x:t.x+n/2,y:t.z+i/2},a=t.y-s;return Math.abs(a)>.001&&(o.z=a),o}_execMutatePath(t,e){const n=this._commander;n?Mc.around(n,()=>{t.mutatePath(null,e)}):t.mutatePath(null,e)}_getAllHandles(){const t=[];for(const e of this._componentHandles)t.push(...e.vertexHandles,...e.midpointHandles);return t}_findComponentHandles(t){return this._componentHandles.find(e=>e.component===t)}onPointerDown(t,e,n){if(!this._handleGroup)return!1;const i=this._getAllHandles();if(0===i.length)return!1;this._raycaster.setFromCamera(t,e);const r=this._raycaster.intersectObjects(i,!1);if(0===r.length)return!1;const s=r[0].object,o=s.userData.handleType,a=s.userData.component,c=this._findComponentHandles(a);if(!c)return!1;if(this._activeComponent=a,this._activeVertexHandles=c.vertexHandles,"midpoint"===o)return this._startMidpointDrag(s,a,e);const l=s.userData.vertexIndex,h=a.path;if(!h)return!1;const d=0===l||l===h.length-1;return n.altKey&&d&&a.pathExtendable?this._startEndpointExtend(s,l,a,e):(this._activeHandleIndex=l,this._isDragging=!0,this._isExtending=!1,s.material.color.setHex(Tu),this._setupDragPlane(e,s.position),!0)}_startMidpointDrag(t,e,n){const i=t.userData.segmentIndex+1,r=this._handlePosToPoint(t.position,e);this._execMutatePath(e,t=>{t.splice(i,0,r)}),this._rebuildComponentHandles(e);const s=this._activeVertexHandles[i];return!!s&&(this._activeHandleIndex=i,this._isDragging=!0,this._isExtending=!1,s.material.color.setHex(Tu),this._setupDragPlane(n,s.position),!0)}_startEndpointExtend(t,e,n,i){const r=n.path;if(!r)return!1;const s=this._handlePosToPoint(t.position,n),o=0===e?0:r.length;this._execMutatePath(n,t=>{t.splice(o,0,s)}),this._rebuildComponentHandles(n);const a=this._activeVertexHandles[o];return!!a&&(this._activeHandleIndex=o,this._isDragging=!0,this._isExtending=!0,a.material.color.setHex(Tu),this._setupDragPlane(i,a.position),!0)}_setupDragPlane(t,e){const n=new w.Vector3;t.getWorldDirection(n),this._dragPlane.setFromNormalAndCoplanarPoint(n,e),this._raycaster.ray.intersectPlane(this._dragPlane,this._intersection),this._dragOffset.copy(e).sub(this._intersection)}onPointerMove(t,e,n){if(!this._isDragging||this._activeHandleIndex<0)return!1;this._raycaster.setFromCamera(t,e),this._raycaster.ray.intersectPlane(this._dragPlane,this._intersection);const i=this._intersection.add(this._dragOffset);if(n.shiftKey){const t=this._activeVertexHandles[this._activeHandleIndex];t&&(i.x=t.position.x,i.z=t.position.z)}const r=this._activeVertexHandles[this._activeHandleIndex];return r&&r.position.copy(i),this._updateLinePreview(),!0}_updateLinePreview(){if(!this._activeComponent)return;const t=this._activeComponent._realObject;if(!t?._line2)return;const{width:e=0,height:n=0}=this._activeComponent.parent?.bounds??{},{x:i,y:r}=this._activeComponent.center,s=t.object3d?t.object3d.position.y:0,o=[];for(const t of this._activeVertexHandles){const a=t.position.x+e/2-i,c=t.position.y-s,l=t.position.z+n/2-r;o.push(a,c,l)}if(o.length<6)return;t._line2.geometry.setPositions(o),t._line2.computeLineDistances()}onPointerUp(){if(!this._isDragging||this._activeHandleIndex<0||!this._activeComponent)return!1;const t=this._activeHandleIndex,e=this._activeVertexHandles[t],n=this._activeComponent;if(!e)return this._isDragging=!1,this._activeHandleIndex=-1,this._isExtending=!1,!0;e.material.color.setHex(Cu);const i=this._handlePosToPoint(e.position,n);return this._execMutatePath(n,e=>{e[t]=i}),this._isDragging=!1,this._activeHandleIndex=-1,this._isExtending=!1,this._rebuildComponentHandles(n),!0}onDblClick(t,e){if(!this._handleGroup)return!1;const n=[];for(const t of this._componentHandles)n.push(...t.vertexHandles);this._raycaster.setFromCamera(t,e);const i=this._raycaster.intersectObjects(n,!1);if(0===i.length)return!1;const r=i[0].object,s=r.userData.component;if(!s.pathExtendable)return!1;const o=s.path;if(!o||o.length<=2)return!1;const a=r.userData.vertexIndex;return this._execMutatePath(s,t=>{t.splice(a,1)}),this._rebuildComponentHandles(s),!0}syncHandles(){for(const t of this._componentHandles)this._rebuildComponentHandles(t.component)}updateHandleScales(t){const e=this._getAllHandles();if(0!==e.length)for(const n of e){const e=t.position.distanceTo(n.position),i="midpoint"===n.userData.handleType?5:8;let r;if(t.isPerspectiveCamera){const n=t.fov,s=2*Math.tan(n*Math.PI/360)*e;r=i/window.innerHeight*s}else{const e=t,n=(e.top-e.bottom)/e.zoom;r=i/window.innerHeight*n}n.scale.setScalar(Math.max(r,.1))}}destroy(){this.detach()}}class Du{constructor(){this.sceneManager=new hu,this.cameraManager=new du,this.rendererManager=new uu,this.lightManager=new pu,this.controlsManager=new gu,this.eventManager=new mu,this.gizmoManager=new bu,this.interactionManager=new wu,this.placementManager=new Mu,this.gizmoOperationManager=new xu,this.bookmarkManager=new Eu,this.boxSelectionManager=new ku,this.vertexGizmoManager=new Pu,this._isSpacePanning=!1,this._initialized=!1,this._decoratorOutlines=new Set,this._selectionOutlineObjects=[],this._highlightedMarkerIndex=-1,this._arrows=new Map,this._pathVisible=!1}get isInitialized(){return this._initialized}get host(){return this._host}get scene3d(){return this.sceneManager.scene}get renderer3d(){return this.rendererManager.renderer}get mixer(){return this.sceneManager.mixer}get camera(){return this.cameraManager.camera}get activeCamera(){return this.cameraManager.activeCamera}get css3DScene(){return this.rendererManager.css3DScene}get css3DRenderer(){return this.rendererManager.css3DRenderer}get noSupportWebgl(){return this.rendererManager.noSupportWebgl}get isActive(){return this.controlsManager.isActive}setGizmoMode(t){if(this.gizmoManager.mode===t&&this.gizmoManager.attached)return this.gizmoManager.detach(),void this._host?.invalidate();this.gizmoManager.setMode(t),this.onGizmoModeChanged?.(t);const e=this._host?.root?.selected,n=e?.filter(t=>t!==this._host&&t._realObject)||[];if(n.length>=1){const e=n[0]._realObject;if(e?.object3d&&e.gizmoTransformable){const n=e.allowedGizmoModes;!n||n.includes(t)?this.gizmoManager.attach(e.object3d):this.gizmoManager.detach()}this._host?.invalidate()}}get gizmoMode(){return this.gizmoManager.mode}init(t,e){this.interactionManager.cleanup(),this._cleanupEventHandlers(),this._host=t,this.sceneManager.scene&&this.destroy(),this._redrawHandler=()=>this.animate(),t.root.on("redraw",this._redrawHandler),this._initialized=!0,this._setupScene(e),this._onComponentAdd=(t,e)=>this.addObject(e),this._onComponentRemove=(t,e)=>this.removeObject(e),t.on&&(t.on("add",this._onComponentAdd),t.on("remove",this._onComponentRemove)),t.app?.isEditMode&&t.root?.on&&(this._onSelectionChanged=t=>this._handleSelectionChanged(t),t.root.on("selected",this._onSelectionChanged)),t.app?.isEditMode&&t.root?.on&&(this._onAddStart=t=>{this.placementManager.start(t),this._host?.element&&(this._host.element.style.cursor="crosshair",this._host.element.focus())},this._onAddStop=()=>{this.placementManager.stop(),this._host?.element&&(this._host.element.style.cursor="")},t.root.on("addstart",this._onAddStart),t.root.on("addstop",this._onAddStop))}_cleanupEventHandlers(){const t=this._host;t&&(this._redrawHandler&&(t.root.off("redraw",this._redrawHandler),this._redrawHandler=void 0),t.off&&(this._onComponentAdd&&(t.off("add",this._onComponentAdd),this._onComponentAdd=void 0),this._onComponentRemove&&(t.off("remove",this._onComponentRemove),this._onComponentRemove=void 0)),this._onSelectionChanged&&t.root?.off&&(t.root.off("selected",this._onSelectionChanged),this._onSelectionChanged=void 0),this._onAddStart&&t.root?.off&&(t.root.off("addstart",this._onAddStart),this._onAddStart=void 0),this._onAddStop&&t.root?.off&&(t.root.off("addstop",this._onAddStop),this._onAddStop=void 0))}_setupScene(t){const e=this._host;let{width:n,height:i}=e.bounds;n=Math.abs(n)||1,i=Math.abs(i)||1;const{fov:r=45,near:s=.1,far:o=2e4,antialias:a=!0,precision:c="highp",cameraX:l,cameraY:h,cameraZ:d,exposure:u=1.2}=e.state,p=e.components||[],f=t?.lightingConfig??{hemisphere:{skyColor:16777215,groundColor:4473924,intensity:.4}},g=t?.css3DSceneAttribute??"three-container:css3d-renderer",m=this.sceneManager.setup(),y=this.cameraManager.setup(n,i,{fov:r,near:s,far:o,cameraX:l,cameraY:h,cameraZ:d});this.cameraManager.addToScene(m);const b=e.app?.postprocessing,_=!t?.skipShadowMap&&void 0,v=!t?.skipPostprocessing&&void 0;if(this.rendererManager.setupWebGL(n,i,{precision:c,antialias:a,exposure:u,postprocessing:b,shadowMap:_,logarithmicDepthBuffer:v})){if(t?.skipEnvironment||this.sceneManager.setupEnvironment(this.rendererManager.renderer),this.controlsManager.setup(y,e),this.controlsManager.setOnUserInteraction(()=>{this.bookmarkManager.isPlaying&&(this.bookmarkManager.stopPlay(),this._pathVisible&&this.showBookmarkPath()),this.bookmarkManager.isOrbitRotating&&this.bookmarkManager.stopOrbitRotation(this.controlsManager)}),e.app?.isEditMode&&e.element&&(this.gizmoManager.setup(y,e.element,m),this._setupGizmoCallbacks()),this.placementManager.setup({camera:this.cameraManager,event:this.eventManager,scene:this.sceneManager},{updateMouseNDCFromClient:(t,e)=>this._updateMouseNDCFromClient(t,e)}),this.lightManager.setup(m,y,f),this.sceneManager.setupMixer(),this.createObjects(p),y.updateProjectionMatrix(),t?.skipFloor||this.sceneManager.addFloor(e),this.sceneManager.setSky(e.state.sky,e.state.skyColor),t?.skipPostprocessing||!1===e.app?.postprocessing)t?.useLightComposer?this.rendererManager.setupLightComposer(m,y,n,i):this.rendererManager.setDirectRenderTargets(m,y);else{const t=this.gizmoManager.controls?.getHelper();this.rendererManager.setupComposer(m,y,n,i,t)}this.rendererManager.setupHUD(n,i),this.rendererManager.hudCamera&&this.eventManager.setHUD(this.rendererManager.hudScene,this.rendererManager.hudCamera),this.rendererManager.setupCSS3D(e.app.isViewMode,g),this._onFocus=()=>this.renderThreeD(),window.addEventListener("focus",this._onFocus),e.element&&(this.interactionManager.setup(e.element,{gizmo:this.gizmoManager,controls:this.controlsManager,camera:this.cameraManager,scene:this.sceneManager,event:this.eventManager},this._buildInteractionDelegate()),e.app?.isEditMode&&this.boxSelectionManager.setup(e.element))}}_setupGizmoCallbacks(){this.gizmoOperationManager.setupCallbacks(this.gizmoManager,this.controlsManager,()=>{const t=this._host;if(t)return Object.create(t,{hostElement:{get:()=>t.target??t.element??void 0}})},{onAttachChanged:t=>this.onGizmoAttachChanged?.(t),onDraggingChanged:t=>{t?this.vertexGizmoManager.setVisible(!1):(this.vertexGizmoManager.syncHandles(),this.vertexGizmoManager.setVisible(!0))}})}createObjects(t){for(const e of t)this.addObject(e)}addObject(t){if(t._realObject){const e=t._realObject;if(e.object3d&&!e.object3d.parent)if(t.state.screenFixed)e instanceof Jd?this.rendererManager.hudCSS3DScene.add(e.object3d):this.rendererManager.hudScene.add(e.object3d);else if(e instanceof Jd)this.rendererManager.css3DScene.add(e.object3d);else{const n=t.parent?._realObject?.object3d;n&&n!==this.sceneManager.scene?n.add(e.object3d):this.sceneManager.scene&&this.sceneManager.scene.add(e.object3d)}return}if(!t.is3dContainer?.()&&"popup"!==t.state?.position){try{if(!t.isLine?.()){const{width:e,height:n}=t.bounds;if(!e||!n)return}if(t.isHTMLElement()&&!t.element)return;const e=ru(t);if(e){if(t._realObject=e,e.update(),e.updateTransform(),t.state.screenFixed)e instanceof Jd?this.rendererManager.hudCSS3DScene.add(e.object3d):this.rendererManager.hudScene.add(e.object3d);else if(e instanceof Jd)this.rendererManager.css3DScene.add(e.object3d);else{const n=t.parent?._realObject?.object3d;n&&n!==this.sceneManager.scene?n.add(e.object3d):this.sceneManager.scene&&this.sceneManager.scene.add(e.object3d)}const n=this._host?.root?.selected;n&&n.length>0&&n[0]===t&&e.object3d&&e.gizmoTransformable&&this.gizmoManager.attached&&this.gizmoManager.attach(e.object3d)}}catch(t){ji(t)}if(t.isContainer()){const e=t,n=e.components||[];this.createObjects(n),e.on&&(e.on("add",this._onComponentAdd),e.on("remove",this._onComponentRemove))}}}removeObject(t){if(t.is3dContainer?.())return;if(t.isContainer()){const e=t,n=e.components||[];for(const t of n)this.removeObject(t);e.off&&(e.off("add",this._onComponentAdd),e.off("remove",this._onComponentRemove))}const e=t._realObject;if(e)try{const n=e.object3d;n&&this.gizmoManager.attached===n&&this.gizmoManager.detach(),n&&(e instanceof Jd?this.rendererManager.css3DScene.remove(n):n.removeFromParent()),e.dispose?.(),t._realObject=void 0}catch(t){ji(t)}}resize(t,e,n=!1){const i=this._host;if(!i)return;if(void 0===t||void 0===e){const n=i.bounds;t=n.width,e=n.height}if(t=Math.abs(t)||1,e=Math.abs(e)||1,n)return void this._applyResize(t,e);this.rendererManager.css3DRenderer?.setSize(t,e);const r=t,s=e;clearTimeout(this._resizeDebouncer),this._resizeDebouncer=window.setTimeout(()=>{this._resizeDebouncer=void 0,this._applyResize(r,s)},100)}_applyResize(t,e){this.cameraManager.updateAspect(t,e),this.rendererManager.resize(t,e);const n=new w.Vector2(t,e);for(const t of this._arrows.values())t.traverse(t=>{t instanceof h.Line2&&t.material.resolution.copy(n)});this._initialized&&(this.renderThreeD(),this._host?.invalidate())}animate(){if(!this._initialized||!this.controlsManager.isActive)return;this.sceneManager.updateAnimation();let t=!1;const e=n=>{for(const i of n)i._animation?.started&&i._realObject&&(i._realObject.syncAnimationDelta(),t=!0),i.components&&e(i.components)};e(this._host?.components||[]),this.controlsManager.update(),this.renderThreeD(),t&&this._host?.invalidate()}renderThreeD(){this._initialized&&(this.vertexGizmoManager?.isAttached&&this.vertexGizmoManager.updateHandleScales(this.cameraManager.activeCamera),this.rendererManager.render(),this.renderCSS3D())}setCameraView(t,e){const n=this._host;if(!n)return;const{width:i,height:r}=n.bounds,s=n.element,o=s?.clientWidth||i,a=s?.clientHeight||r;let c;c="perspective"===t?this.cameraManager.restorePerspective():this.cameraManager.setOrthoView(t,i,r,o,a),this.controlsManager.setCamera(c),this.gizmoManager.updateCamera(c),this.rendererManager.updateRenderPassCamera(c),!1!==e?.render&&this.renderThreeD(),this.onCameraViewChanged?.(t)}renderCSS3D(){const t=this.cameraManager.activeCamera;t&&this.rendererManager.renderCSS3D(t)}buildOverlays(){const t=this._host;if(!t?.element)return;t.element.appendChild(this.css3DRenderer.domElement);const e=this.rendererManager.hudCSS3DRenderer?.domElement;e&&t.element.appendChild(e)}destroy(){this.interactionManager.cleanup(),this._resizeDebouncer&&(clearTimeout(this._resizeDebouncer),this._resizeDebouncer=void 0),this._onFocus&&(window.removeEventListener("focus",this._onFocus),this._onFocus=void 0),this.vertexGizmoManager.destroy(),this.boxSelectionManager.destroy(),this.bookmarkManager.destroy(),this.gizmoManager.destroy(),this.controlsManager.destroy(),this.lightManager.destroy(),this.rendererManager.destroy(),this.cameraManager.destroy(),this.sceneManager.destroy(),this.eventManager.destroy(),this._initialized=!1}forceCleanupDragState(){this.interactionManager.forceCleanupDragState(),this.boxSelectionManager.isActive&&(this.boxSelectionManager.cancelSelection(),this.controlsManager.setEnabled(!0)),this._isSpacePanning&&(this._isSpacePanning=!1,void 0!==this._beforeSpaceMode&&this._host?.app&&(this._host.app.mode=this._beforeSpaceMode,this._beforeSpaceMode=void 0)),this._host?.element&&(this._host.element.style.cursor="")}clearAllObjects(){this.gizmoManager.detach();const t=this._host?.components||[];for(const e of t)e._realObject&&this.removeObject(e)}rebuildForHost(t,e){this.interactionManager.cleanup();try{this._cleanupEventHandlers()}catch(t){}this._host=t,this._redrawHandler=()=>this.animate(),t.root.on("redraw",this._redrawHandler),this._onComponentAdd=(t,e)=>this.addObject(e),this._onComponentRemove=(t,e)=>this.removeObject(e),t.on&&(t.on("add",this._onComponentAdd),t.on("remove",this._onComponentRemove)),t.app?.isEditMode&&t.root?.on&&(this._onSelectionChanged=t=>this._handleSelectionChanged(t),t.root.on("selected",this._onSelectionChanged),this._onAddStart=t=>{this.placementManager.start(t),this._host?.element&&(this._host.element.style.cursor="crosshair",this._host.element.focus())},this._onAddStop=()=>{this.placementManager.stop(),this._host?.element&&(this._host.element.style.cursor="")},t.root.on("addstart",this._onAddStart),t.root.on("addstop",this._onAddStop)),this.createObjects(t.components||[]),t.element&&this.interactionManager.setup(t.element,{gizmo:this.gizmoManager,controls:this.controlsManager,camera:this.cameraManager,scene:this.sceneManager,event:this.eventManager},this._buildInteractionDelegate());const n=this.controlsManager._position0?.clone(),i=this.controlsManager._target0?.clone();this.controlsManager.setup(this.cameraManager.camera,t),n&&this.controlsManager._position0.copy(n),i&&this.controlsManager._target0.copy(i),t.app?.isEditMode&&t.element&&this.boxSelectionManager.setup(t.element),t.app?.isEditMode&&t.element&&this.sceneManager.scene&&(this.gizmoManager.setup(this.cameraManager.camera,t.element,this.sceneManager.scene),this._setupGizmoCallbacks()),this._onFocus||(this._onFocus=()=>this.renderThreeD(),window.addEventListener("focus",this._onFocus)),this.renderThreeD()}dispose(){const t=e=>{for(const n of e)if(!n.is3dContainer?.()){if(n.isContainer()){const e=n.components||[];t(e)}n._realObject&&(n._realObject.dispose?.(),n._realObject=void 0)}};t(this._host?.components||[]),this._decoratorOutlines.clear(),this._selectionOutlineObjects=[],this.clearArrows(),this.placementManager.destroy(),this._cleanupEventHandlers(),this.rendererManager.disposeCSS3DScene(),this.destroy(),this._host=void 0}_buildInteractionDelegate(){return{isPlacementMode:()=>this.placementManager.isActive,handlePlacementClick:t=>{if(!this._host?.root)return;const e=this.placementManager.raycastGroundPlane(t);if(e){const t=this._host,n=t.bounds.width||800,i=t.bounds.height||600,r=e.x+n/2,s=e.z+i/2;Dl.call(t.root,this.placementManager.pendingModels,{cx:r,cy:s}),t.root.trigger("addstop")}},handlePlacementHover:t=>{const e=this.placementManager.raycastGroundPlane(t);this.placementManager.updateIndicator(e),this.renderThreeD()},tryAltClickSelect:t=>{if(!this._host?.app?.isEditMode||!this._host.root)return!1;this._updateMouseNDCFromClient(t.clientX,t.clientY);const e=this.cameraManager.activeCamera;if(e&&this.sceneManager.scene){const n=this.eventManager.handleClick(e,this.sceneManager.scene,t);if(n?.component)return this._host.root.selected=[n.component],!0}return!1},captureMouseDownAltKey:t=>{this.gizmoOperationManager.captureAltKey(t)},handleClickAt:(t,e,n)=>{this._handleClickAt(n)},handleWheel:t=>this.onWheel(t),handleDblClick:t=>this.onDblClick(t),handleTouchStart:t=>this.onTouchStart(t),handleTouchMove:t=>this.onPan(t),handleTouchEnd:t=>this.onTouchEnd(t),handleKeyDown:t=>this.onKeyDown(t),handleKeyUp:t=>this._onKeyUp(t),isSpacePanning:()=>this._isSpacePanning,handleBoxSelectionStart:(t,e)=>{this.controlsManager.setEnabled(!1),this._host?.element&&(this._host.element.style.cursor="crosshair"),this.boxSelectionManager.startSelection(t,e)},handleBoxSelectionUpdate:(t,e)=>{this.boxSelectionManager.updateSelection(t,e)},tryVertexDragStart:t=>{if(!this.vertexGizmoManager.isAttached)return!1;const e=this.cameraManager.activeCamera;if(!e)return!1;const n=this.eventManager.mouse,i=this.vertexGizmoManager.onPointerDown(n,e,t);return i&&this.controlsManager.setEnabled(!1),i},handleVertexDragMove:t=>{const e=this.cameraManager.activeCamera;if(!e)return;const n=this.eventManager.mouse;this.vertexGizmoManager.onPointerMove(n,e,t),this._host?.invalidate()},handleVertexDragEnd:t=>{this.vertexGizmoManager.onPointerUp(),this.controlsManager.setEnabled(!0),this._host?.invalidate()},handleBoxSelectionEnd:(t,e)=>{this.controlsManager.setEnabled(!0),this._host?.element&&(this._host.element.style.cursor="");const n=this.cameraManager.activeCamera,i=this.sceneManager.scene,r=this._host?.components||[];if(n&&i){let s=this.boxSelectionManager.endSelection(n,i,r);if(e&&t){const t=this._host?.root?.selected||[];if(t.length>0){const e=t[0].state?.type;e&&(s=s.filter(t=>t.state?.type===e))}}if(s.length>0&&this._host?.root)if(t){const t=this._host,e=(this._host.root.selected||[]).filter(e=>e!==t);for(const t of s)e.includes(t)||e.push(t);this._host.root.selected=e}else this._host.root.selected=s}else this.boxSelectionManager.cancelSelection()}}}_handleClickAt(t){const e=this._host,n=this.cameraManager.activeCamera;if(!n||!this.sceneManager.scene)return;if(this._pathMarkers&&this._pathMarkers.children.length>0){const t=new w.Raycaster,e=this.eventManager.mouse;t.setFromCamera(e,n);const i=t.intersectObjects(this._pathMarkers.children,!0);if(i.length>0){let t=i[0].object;for(;t&&void 0===t.userData.bookmarkSlotIndex;)t=t.parent;if(t&&void 0!==t.userData.bookmarkSlotIndex)return void this.animateToSlot(t.userData.bookmarkSlotIndex)}}if(this.vertexGizmoManager?.isDragging)return this.vertexGizmoManager.onPointerUp(),this.controlsManager.setEnabled(!0),void this._host?.invalidate();const i=this.gizmoManager.isDragging;if(this.gizmoManager.forwardEvent(t,"pointerup"),i)return;const r=this.eventManager.handleClick(n,this.sceneManager.scene,t);if(e.root){const t=e.app?.mode;if(4===t||5===t){if(!r?.component){const n=4===t?"stylepastestop":"databindpastestop";e.root.trigger(n)}return}}e.app?.isEditMode&&e.root&&this._applySelection(e.root,r?.component,t.shiftKey)}_applySelection(t,e,n){if(e)if(n){const n=(t.selected||[]).slice(),i=n.indexOf(e);-1===i?n.push(e):n.splice(i,1),t.selected=n}else{let n=null,i=e.parent;for(;i?.isGroup?.();)n=i,i=i.parent;if(n){if(!(t.selected||[]).some(t=>{if(t===n)return!0;let e=t.parent;for(;e?.isGroup?.();){if(e===n)return!0;e=e.parent}return!1}))return void(t.selected=[n])}t.selected=[e]}else n||(t.selected=[])}getObjectByRaycast(){if(!this.sceneManager.scene)return;const t=this.cameraManager.activeCamera;return t?this.eventManager.getObjectByRaycast(t,this.sceneManager.scene):void 0}getObjectsByRaycast(){if(!this.sceneManager.scene)return;const t=this.cameraManager.activeCamera;return t?this.eventManager.getObjectsByRaycast(t,this.sceneManager.scene):void 0}_updateMouseNDCFromClient(t,e){const n=this._host?.element;if(n){const i=n.getBoundingClientRect();if(i.width>0&&i.height>0){const n=t-i.left,r=e-i.top;return void this.eventManager.updateMouseNDC(n,r,0,0,i.width,i.height)}}const i=this._host;if(i){const{left:n,top:r,width:s,height:o}=i.bounds;s>0&&o>0&&this.eventManager.updateMouseNDC(t,e,n,r,Math.abs(s),Math.abs(o))}}_eventToNDC(t){const e=this._host?.element;if(e){const n=e.getBoundingClientRect();if(n.width>0&&n.height>0)return{ndcX:(t.clientX-n.left)/n.width*2-1,ndcY:-(t.clientY-n.top)/n.height*2+1}}const n=this._host;if(n?.transcoordC2S){const{width:e,height:i}=n.bounds;if(Math.abs(e)>0&&Math.abs(i)>0){const r=n.transcoordC2S(t.offsetX,t.offsetY);return{ndcX:r.x/Math.abs(e)*2-1,ndcY:-(r.y/Math.abs(i)*2-1)}}}return{ndcX:0,ndcY:0}}_updateMouseNDC(t){const e=this._host?.element;if(e){const n=e.getBoundingClientRect();if(n.width>0&&n.height>0){const e=t.clientX-n.left,i=t.clientY-n.top;return void this.eventManager.updateMouseNDC(e,i,0,0,n.width,n.height)}}const n=this._host;if(n?.transcoordC2S){const{width:e,height:i}=n.bounds;if(Math.abs(e)>0&&Math.abs(i)>0){const r=n.transcoordC2S(t.offsetX,t.offsetY);this.eventManager.updateMouseNDC(r.x,r.y,0,0,Math.abs(e),Math.abs(i))}}}onMouseUp(t){if(this.controlsManager.isActive){const e=this.gizmoManager.isDragging;if(this.gizmoManager.forwardEvent(t,"pointerup"),e)return t.stopPropagation(),!0;const n=this.cameraManager.activeCamera;this._updateMouseNDC(t);const i=this.eventManager.handleClick(n,this.sceneManager.scene,t),r=this._host;return r?.app?.isEditMode&&r.root&&this._applySelection(r.root,i?.component,t.shiftKey),t.stopPropagation(),!0}return!1}onMouseMove(t){if(this.controlsManager.isActive){this.gizmoManager.forwardEvent(t,"pointermove");const e=this.cameraManager.activeCamera;return this._updateMouseNDC(t),this.eventManager.handleHover(e,this.sceneManager.scene,t),t.stopPropagation(),!0}return!1}onMouseDown(t){return!(!this.controlsManager.isActive||(this.gizmoManager.forwardEvent(t,"pointerdown"),!this.gizmoManager.isDragging))&&(t.stopPropagation(),!0)}onMouseLeave(t){return!1}onWheel(t){if(this.controlsManager.isActive){const{ndcX:e,ndcY:n}=this._eventToNDC(t);if("perspective"!==this.cameraManager.activeView){const i=t.deltaY>0?.9:1.1;this.controlsManager.zoomOrthoAtCursor(i,e,n),this.renderThreeD()}else{const i=Math.pow(.999,-t.deltaY);this.controlsManager.dollyAtCursor(i,e,n),this.renderThreeD()}return t.stopPropagation(),!0}return!1}onDblClick(t){if(!this.controlsManager.isActive)return!1;const e=this._host,n=this.cameraManager.activeCamera;if(!n||!this.sceneManager.scene)return this.controlsManager.reset(),!0;if(e?.app?.isEditMode&&e.root){if(this.vertexGizmoManager.isAttached){const t=this.eventManager.mouse;if(this.vertexGizmoManager.onDblClick(t,n))return this._host?.invalidate(),!0}const t=this.eventManager.getObjectByRaycast(n,this.sceneManager.scene),e=t?.userData?.context?.component;if(e?.hasTextProperty)return su(e,this.rendererManager,()=>{this.renderThreeD()}),!0}return this.controlsManager.reset(),t.stopPropagation(),!0}pinResetPosition(){this.controlsManager.pinResetPosition()}onDragStart(t){return!!this.controlsManager.isActive&&(this.gizmoManager.isDragging?(t.stopPropagation(),!0):(this.bookmarkManager.stopOrbitRotation(this.controlsManager),this.bookmarkManager.stopPlay(),this.controlsManager.onDragStart(t),t.stopPropagation(),!0))}onDragMove(t){return!!this.controlsManager.isActive&&(this.gizmoManager.isDragging?(this.gizmoManager.forwardEvent(t,"pointermove"),t.stopPropagation(),!0):(this.controlsManager.onDragMove(t),t.stopPropagation(),!0))}onDragEnd(t){return!!this.controlsManager.isActive&&(this.gizmoManager.isDragging?(this.gizmoManager.forwardEvent(t,"pointerup"),t.stopPropagation(),!0):(this.controlsManager.onDragEnd(t),t.stopPropagation(),!0))}onTouchStart(t){return!!this.controlsManager.isActive&&(this.controlsManager.onTouchStart(t),t.stopPropagation(),!0)}onPan(t){return!!this.controlsManager.isActive&&(this.controlsManager.onTouchMove(t),t.stopPropagation(),!0)}onTouchEnd(t){return!!this.controlsManager.isActive&&(this.controlsManager.onTouchEnd(t),t.stopPropagation(),!0)}onKeyDown(t){return!t.isComposing&&229!==t.keyCode&&(!!this.controlsManager.isActive&&(!!this._handleEscapeKey(t)||(!(!this._host?.app?.isEditMode||!this._handleEditModeKey(t))||(!!this._handleCursorHintKey(t)||(!!this._handleCameraAndViewKey(t)||(!!this._handlePlaybackKey(t)||(!t.shiftKey||t.ctrlKey||t.metaKey||t.altKey||"KeyB"!==t.code||!this._host?.app?.isEditMode?(this.controlsManager.onKeyDown(t),t.ctrlKey||t.metaKey||t.stopPropagation(),!0):(this.onBookmarkEditToggle?.(),t.preventDefault(),!0))))))))}_handleEscapeKey(t){if("Escape"!==t.key&&"Escape"!==t.code)return!1;if(this.placementManager.isActive&&this._host?.root)return this._host.root.trigger("addstop"),t.stopPropagation(),!0;const e=this._host?.app,n=this._host?.root;return e&&4===e.mode?(n?.trigger("stylepastestop"),!0):e&&5===e.mode?(n?.trigger("databindpastestop"),!0):!(!e?.isEditMode||!n)&&(this.gizmoManager.detach(),n.selected=[],!0)}_handleEditModeKey(t){const e=this._host.root;if(t.metaKey||t.ctrlKey)switch(t.code){case"KeyZ":{const n=this._host?.app?.commander,i=(e?.selected||[]).filter(t=>t!==this._host).map(t=>t.state?.id).filter(Boolean);if(t.shiftKey?n?.redo():n?.undo(),e&&i.length>0){const t=i.map(t=>e.findById(t)).filter(Boolean);t.length>0&&(e.selected=t)}return t.preventDefault(),!0}case"KeyC":return e&&(this._clipboard=Hl.call(e)),t.preventDefault(),!0;case"KeyX":return e&&(this._clipboard=Yl.call(e)),t.preventDefault(),!0;case"KeyV":return e&&this._clipboard&&Gl.call(e,this._clipboard),t.preventDefault(),!0;case"KeyD":return e&&(this._clipboard=Hl.call(e),this._clipboard&&Gl.call(e,this._clipboard)),t.preventDefault(),!0;default:return!1}if("Enter"===t.code||"NumpadEnter"===t.code){const n=e?.selected;if(1===n?.length&&n[0].hasTextProperty)return su(n[0],this.rendererManager,()=>{this.renderThreeD()}),t.preventDefault(),!0}switch(t.code){case"KeyW":return this.setGizmoMode("translate"),!0;case"KeyE":return this.setGizmoMode("rotate"),!0;case"KeyR":return this.setGizmoMode("scale"),!0;case"Delete":case"Backspace":return e&&zl.call(e),!0}return this._handleArrowKeyMove(t,e)}_handleArrowKeyMove(t,e){const n=e?.selected;if(!n||0===n.length)return!1;const i=t.shiftKey?this._host.MPP||10:1;let r;switch(t.code){case"ArrowLeft":r={x:-i,y:0};break;case"ArrowRight":r={x:i,y:0};break;case"ArrowUp":r={x:0,y:-i};break;case"ArrowDown":r={x:0,y:i}}return!!r&&(Mc.around(this._host.app.commander,()=>{n.forEach(t=>{t.stuck||t.move(r,!1)})}),t.preventDefault(),t.stopPropagation(),!0)}_handleCursorHintKey(t){return!(t.repeat||!this._host?.app?.isEditMode)&&("AltLeft"===t.code||"AltRight"===t.code?(this._host?.element&&(this._host.element.style.cursor="grab"),!0):("ShiftLeft"===t.code||"ShiftRight"===t.code)&&(this._host?.element&&(this._host.element.style.cursor=this.gizmoManager.isEngaged?"grab":"crosshair"),!0))}_handleCameraAndViewKey(t){if(t.metaKey||t.ctrlKey||t.altKey||t.shiftKey)return!1;switch(t.code){case"KeyQ":case"Digit0":return this._host?.toggleThreeD?.(),t.preventDefault(),!0;case"Digit1":return this.setCameraView("perspective"),t.preventDefault(),!0;case"Digit2":return this.setCameraView("top"),t.preventDefault(),!0;case"Digit3":return this.setCameraView("front"),t.preventDefault(),!0;case"Digit4":return this.setCameraView("back"),t.preventDefault(),!0;case"Digit5":return this.setCameraView("right"),t.preventDefault(),!0;case"Digit6":return this.setCameraView("left"),t.preventDefault(),!0;case"KeyH":return this.onHelpToggle?.(),t.preventDefault(),!0;case"KeyB":return this.onBookmarkNavToggle?.(),t.preventDefault(),!0;case"KeyF":return this.onSearchToggle?.(),t.preventDefault(),!0;case"KeyD":return this.onDataBindingToggle?.(),t.preventDefault(),!0;case"KeyM":return this.onMonitorToggle?.(),t.preventDefault(),!0}return!1}_handlePlaybackKey(t){return!(t.metaKey||t.ctrlKey||t.altKey||t.shiftKey)&&("KeyP"!==t.code||this._host?.app?.isEditMode?"Space"===t.code&&this._host?.app?.isEditMode?(this._isSpacePanning=!0,this._beforeSpaceMode=this._host.app.mode,this._host.app.mode=2,this._host?.element&&(this._host.element.style.cursor="grab"),t.preventDefault(),!0):"Space"!==t.code||this._host?.app?.isEditMode?"KeyO"===t.code&&!this._host?.app?.isEditMode&&(this.bookmarkManager.resetPlay(),this.bookmarkManager.toggleOrbitRotation(this.controlsManager),t.preventDefault(),!0):(this.bookmarkManager.isOrbitRotating||this.bookmarkManager.isOrbitPaused?this.bookmarkManager.toggleOrbitRotation(this.controlsManager):(this.bookmarkManager.isPlaying||this.bookmarkManager.lastPlayProgress>=0)&&this.togglePlay(),t.preventDefault(),!0):(this.bookmarkManager.stopOrbitRotation(this.controlsManager),this.restartPlay(),t.preventDefault(),!0))}_onKeyUp(t){return"AltLeft"===t.code||"AltRight"===t.code||"ShiftLeft"===t.code||"ShiftRight"===t.code?(this._host?.element&&!this._isSpacePanning&&(this._host.element.style.cursor=""),!0):!("Space"!==t.code||!this._isSpacePanning)&&(this._isSpacePanning=!1,void 0!==this._beforeSpaceMode&&this._host?.app&&(this._host.app.mode=this._beforeSpaceMode,this._beforeSpaceMode=void 0),this._host?.element&&(this._host.element.style.cursor=""),t.preventDefault(),!0)}onPinch(t){if(this.controlsManager.isActive){if("perspective"!==this.cameraManager.activeView){const e=this.cameraManager.activeCamera,n=t.scale||1;e.zoom=Math.max(.1,Math.min(20,e.zoom*n)),e.updateProjectionMatrix(),this.controlsManager.markCameraChanged(),this.renderThreeD()}else{const e=t.scale||1;Math.abs(e-1)>.01&&(this.controlsManager.dollyAtCursor(1/e,0,0),this.renderThreeD())}return t.stopPropagation(),!0}return!1}onDoubleTap(){this.controlsManager.reset()}getCameraState(){const t=this._host;if(!t)return null;const e=this.cameraManager.camera;if(!e)return null;const{width:n,height:i}=t.bounds,r=Math.floor(Math.min(n,i))||1;return{view:this.cameraManager.activeView,cameraX:e.position.x/(n||1),cameraY:e.position.z/(i||1),cameraZ:e.position.y/r}}getCameraWorldState(){const t=this.cameraManager.camera;if(!t)return null;const e=this.controlsManager.target;return{position:{x:t.position.x,y:t.position.y,z:t.position.z},target:{x:e.x,y:e.y,z:e.z}}}captureSessionState(){const t=this.cameraManager.activeView,e=this.cameraManager.camera,n=this.controlsManager.target,i={view:t};return e&&(i.perspPosition={x:e.position.x,y:e.position.y,z:e.position.z}),i.orbitTarget={x:n.x,y:n.y,z:n.z},i}captureViewportInfo(){const t=this.cameraManager.activeCamera,e=this.controlsManager.target.clone();let n=0,i=0;if(t?.fov){i=2*t.position.distanceTo(e)*Math.tan(t.fov*Math.PI/180/2),n=i*(t.aspect||1)}return{target:e,visibleWidth:n,visibleHeight:i}}restoreSessionState(t){"perspective"!==t.view&&this.setCameraView(t.view,{render:!1});const e=this.cameraManager.camera;e&&t.perspPosition&&e.position.set(t.perspPosition.x,t.perspPosition.y,t.perspPosition.z),t.orbitTarget&&this.controlsManager.restoreTarget(new w.Vector3(t.orbitTarget.x,t.orbitTarget.y,t.orbitTarget.z))}saveCameraToSlot(t){if(!this._host?.app?.isEditMode)return;const e=this.cameraManager.camera;if(!e)return;if("perspective"!==this.cameraManager.activeView)return;const n=this.controlsManager.target,i=e.position;let r=n.x,s=n.y,o=n.z;if(i.distanceTo(n)<1){const t=new w.Vector3(0,0,-1).applyQuaternion(e.quaternion);r=i.x+1*t.x,s=i.y+1*t.y,o=i.z+1*t.z}const a={position:{x:i.x,y:i.y,z:i.z},target:{x:r,y:s,z:o}};this.bookmarkManager.saveSlot(t,a),this._host?.app?.isEditMode&&this._host?.set?.("cameraBookmarks",this.bookmarkManager.exportSlots()),this.onBookmarkChanged?.()}positionCameraForViewport(t,e,n,i,r){const s=this.cameraManager.activeCamera;if(!s?.position)return;const o=(s.fov||45)*Math.PI/180,a=s.aspect||1,c=i/2/Math.tan(o/2),l=n/2/(a*Math.tan(o/2)),h=Math.max(c,l),d=r?.orbitTarget?.y??0,u=new w.Vector3(t,d,e);let p;if(r?.perspPosition&&r?.orbitTarget){const t=new w.Vector3(r.perspPosition.x,r.perspPosition.y,r.perspPosition.z),e=new w.Vector3(r.orbitTarget.x,r.orbitTarget.y,r.orbitTarget.z);p=t.sub(e).normalize()}else p=s.position.clone().normalize();s.position.copy(u.clone().add(p.multiplyScalar(h)));try{this.controlsManager.restoreTarget(u)}catch{s.lookAt(u)}this._host?.invalidate()}centerToComponent(t,e){const n=this.cameraManager.activeCamera;if(!n)return;const i=new w.Vector3,r=t._realObject;if(r?.object3d)r.object3d.getWorldPosition(i);else{const{x:e=0,y:n=0}=t.center,{width:r=0,height:s=0}=t.parent?.bounds??{};i.set(e-r/2,0,n-s/2)}const s=this.controlsManager.target,o=n.position.clone().sub(s),a=i.clone().add(o);if(!e)return n.position.copy(a),this.controlsManager.restoreTarget(i),void this._host?.invalidate();const c=n.position.clone(),l=s.clone(),h=performance.now(),d=()=>{const t=performance.now()-h,e=Math.min(t/800,1),r=e<.5?2*e*e:1-Math.pow(-2*e+2,2)/2;n.position.lerpVectors(c,a,r);const s=l.clone().lerp(i,r);this.controlsManager.restoreTarget(s),this._host?.invalidate(),e<1&&requestAnimationFrame(d)};requestAnimationFrame(d)}animateToSlot(t){const e=this.cameraManager.camera;e&&(this.bookmarkManager.isPlaying&&this.bookmarkManager.stopPlay(),"perspective"!==this.cameraManager.activeView&&this.setCameraView("perspective",{render:!1}),this.bookmarkManager.animateToSlot(t,e,this.controlsManager),this.bookmarkManager.setProgressForSlot(t))}scrubPath(t){const e=this.cameraManager.camera;if(!e)return;const n=this.bookmarkManager.evaluatePath(t);n&&(e.position.copy(n.position),this.controlsManager.restoreTarget(n.target),this._host?.invalidate())}togglePlay(t=-1){const e=this.cameraManager.camera;if(e){if("perspective"!==this.cameraManager.activeView&&this.setCameraView("perspective",{render:!1}),this.bookmarkManager.isPlaying)return this.bookmarkManager.stopPlay(),void(this._pathVisible&&this.showBookmarkPath());this.hideBookmarkPath(),this.bookmarkManager.startPlay(e,this.controlsManager,2e3,1200,t)}}restartPlay(){const t=this.cameraManager.camera;t&&("perspective"!==this.cameraManager.activeView&&this.setCameraView("perspective",{render:!1}),this.bookmarkManager.stopPlay(),this.hideBookmarkPath(),this.bookmarkManager.startPlay(t,this.controlsManager,2e3,1200,-1,!0))}startAutoPlay(t){"orbit"===t?this.bookmarkManager.toggleOrbitRotation(this.controlsManager):"play"===t&&this.togglePlay()}showBookmarkPath(){this._pathVisible=!0,this.hideBookmarkPath();const t=this.sceneManager.scene;if(!t)return;const e=this.bookmarkManager.getPlayableSlots();if(0===e.length)return;const n=[];for(const t of e){const e=this.bookmarkManager.getSlot(t);e&&n.push(new w.Vector3(e.position.x,e.position.y,e.position.z))}if(n.length>=2){let e=0;for(let t=1;t<n.length;t++)e+=n[t].distanceTo(n[t-1]);const i=e/(n.length-1),r=n.length>=3?new w.CatmullRomCurve3(n,!0,"centripetal").getPoints(30*n.length):n,s=(new w.BufferGeometry).setFromPoints(r),o=new w.LineDashedMaterial({color:4890367,dashSize:.06*i,gapSize:.03*i,opacity:.5,transparent:!0,depthTest:!1});this._pathLine=new w.Line(s,o),this._pathLine.computeLineDistances(),this._pathLine.renderOrder=9999,t.add(this._pathLine)}let i;if(n.length>=2){let t=0;for(let e=1;e<n.length;e++)t+=n[e].distanceTo(n[e-1]);i=t/(n.length-1)*.08}else{const t=this.bookmarkManager.getSlot(e[0]);i=.08*(t?new w.Vector3(t.position.x,t.position.y,t.position.z).distanceTo(new w.Vector3(t.target.x,t.target.y,t.target.z)):10)}this._pathMarkers=new w.Group,this._pathMarkers.renderOrder=9999;const r=new w.MeshBasicMaterial({color:4890367,opacity:.6,transparent:!0,depthTest:!1}),s=new w.MeshBasicMaterial({color:4890367,opacity:.15,transparent:!0,depthTest:!1,side:w.DoubleSide});for(const t of e){const e=this.bookmarkManager.getSlot(t);if(!e)continue;const n=new w.Vector3(e.position.x,e.position.y,e.position.z),o=new w.Vector3(e.target.x,e.target.y,e.target.z),a=(new w.Vector3).subVectors(o,n).normalize(),c=new w.Group;c.position.copy(n);const l=(new w.Matrix4).lookAt(new w.Vector3(0,0,0),a,new w.Vector3(0,1,0));c.quaternion.setFromRotationMatrix(l);const h=.2*i,d=new w.BoxGeometry(1.2*h,.8*h,h),u=new w.Mesh(d,r);u.renderOrder=9999,c.add(u);const p=Math.max(.06*n.distanceTo(o),.5*h),f=.35*p,g=9*f/16,m=new w.BufferGeometry,y=[0,0,0,-f,g,-p,f,g,-p,f,-g,-p,-f,-g,-p],b=[0,1,2,0,2,3,0,3,4,0,4,1];m.setAttribute("position",new w.Float32BufferAttribute(y,3)),m.setIndex(b),m.computeVertexNormals();const _=new w.Mesh(m,s);_.position.z=.5*-h,_.renderOrder=9999,c.add(_);const v=new Float32Array([0,0,0,-f,g,-p,0,0,0,f,g,-p,0,0,0,f,-g,-p,0,0,0,-f,-g,-p,-f,g,-p,f,g,-p,f,g,-p,f,-g,-p,f,-g,-p,-f,-g,-p,-f,-g,-p,-f,g,-p]),x=new w.BufferGeometry;x.setAttribute("position",new w.BufferAttribute(v,3));const M=new w.LineSegments(x,new w.LineBasicMaterial({color:4890367,opacity:.5,transparent:!0,depthTest:!1}));M.position.z=.5*-h,M.renderOrder=9999,c.add(M),c.userData.bookmarkSlotIndex=t,this._pathMarkers.add(c)}t.add(this._pathMarkers),this._host?.invalidate()}hideBookmarkPath(t=!1){t&&(this._pathVisible=!1);const e=this.sceneManager.scene;if(this._pathLine&&(e?.remove(this._pathLine),this._pathLine.geometry.dispose(),this._pathLine.material.dispose(),this._pathLine=void 0),this._pathMarkers){e?.remove(this._pathMarkers);const t=new Set;this._pathMarkers.traverse(e=>{e.geometry&&e.geometry.dispose();const n=e.material;n&&!t.has(n)&&(n.dispose(),t.add(n))}),this._pathMarkers=void 0}this._host?.invalidate()}initBookmarks(){const t=this._host;if(!t)return;const e=t.state.cameraBookmarks;Array.isArray(e)&&this.bookmarkManager.importSlots(e),this.bookmarkManager.setCallbacks(()=>this._host?.invalidate())}onchange(t){if(t.hasOwnProperty("autoRotate")&&this.controlsManager.setAutoRotate(t.autoRotate),t.hasOwnProperty("cameraFloorConstraint")){const e=!this._host?.app?.isEditMode;this.controlsManager.setFloorConstraint(e&&!!t.cameraFloorConstraint)}if(t.hasOwnProperty("fov")||t.hasOwnProperty("near")||t.hasOwnProperty("far")){const t=this._host;if(t){const{near:e,far:n,fov:i}=t.state;this.cameraManager.updateProperties({near:e,far:n,fov:i}),this.controlsManager.markCameraChanged()}}t.hasOwnProperty("exposure")&&(this.rendererManager.setExposure(Number(t.exposure)||1),this.renderThreeD());let e=!1;if((t.hasOwnProperty("hemiIntensity")||t.hasOwnProperty("hemiSkyColor")||t.hasOwnProperty("hemiGroundColor"))&&(this.lightManager.updateHemisphere({intensity:t.hemiIntensity,skyColor:t.hemiSkyColor,groundColor:t.hemiGroundColor}),e=!0),t.hasOwnProperty("dirLightEnabled")){const n=this._host;n&&this.lightManager.setDirectionalEnabled(t.dirLightEnabled,{color:n.state.dirLightColor,intensity:n.state.dirLightIntensity}),e=!0}if((t.hasOwnProperty("dirLightColor")||t.hasOwnProperty("dirLightIntensity"))&&(this.lightManager.updateDirectional({color:t.dirLightColor,intensity:t.dirLightIntensity}),e=!0),t.hasOwnProperty("dirLightFollowCamera")){if(this.lightManager.setDirectionalFollowCamera(!1!==t.dirLightFollowCamera),!1===t.dirLightFollowCamera){const t=this._host?.state;this.lightManager.setDirectionalAngle(t?.dirLightAzimuth??30,t?.dirLightElevation??45)}e=!0}if(t.hasOwnProperty("dirLightAzimuth")||t.hasOwnProperty("dirLightElevation")){const n=this._host?.state;!1===n?.dirLightFollowCamera&&this.lightManager.setDirectionalAngle(t.dirLightAzimuth??n?.dirLightAzimuth??30,t.dirLightElevation??n?.dirLightElevation??45),e=!0}if(t.hasOwnProperty("dirShadowEnabled")||t.hasOwnProperty("dirShadowBias")){const n=this.lightManager.dirLight;n&&(t.hasOwnProperty("dirShadowEnabled")&&(n.castShadow=!1!==t.dirShadowEnabled),t.hasOwnProperty("dirShadowBias")&&(n.shadow.bias=t.dirShadowBias??-5e-4)),e=!0}e&&this.renderThreeD(),(t.hasOwnProperty("fillStyle")||t.hasOwnProperty("floorMaterial3d"))&&(this.sceneManager.updateFloor(this._host),this.renderThreeD()),(t.hasOwnProperty("sky")||t.hasOwnProperty("skyColor"))&&(this.sceneManager.setSky(this._host.state.sky,this._host.state.skyColor),this.renderThreeD()),t.hasOwnProperty("placement")&&(this.sceneManager.updateFloor(this._host),this._cascadeUpdateTransform(this._host),this.renderThreeD())}_cascadeUpdateTransform(t){const e=t?._realObject;e&&e.updateTransform?.();const n=t?.components;if(n)for(const t of n)this._cascadeUpdateTransform(t)}get domElement(){return this.rendererManager.domElement}getRendererSize(){return this.rendererManager.getSize()}showWebglNoSupportText(t,e,n){t.save(),t.font=e/20+"px Arial",t.textAlign="center",t.fillText("WebGL no support",e/2-e/40,n/2),t.restore()}showDebugFPS(t){t.font="100px Arial",t.textAlign="center",t.fillStyle="black",t.globalAlpha=.5,t.fillText(String(Ud()),100,100)}get decoratorOutlines(){return this._decoratorOutlines}addOutline(t){this._decoratorOutlines.add(t),this._syncOutlinePass(),this._host?.invalidate()}removeOutline(t){this._decoratorOutlines.delete(t),this._syncOutlinePass(),this._host?.invalidate()}clearOutlines(){this._decoratorOutlines.clear(),this._syncOutlinePass(),this._host?.invalidate()}addArrow(t,e,n,i={}){this.removeArrow(t);const r=e._realObject,s=n._realObject;if(!r?.object3d||!s?.object3d)return;const o=new w.Vector3,a=new w.Vector3;r.object3d.getWorldPosition(o),s.object3d.getWorldPosition(a),o.y+=1,a.y+=1;const c=this.rendererManager.getSize(),l=Zd(o,a,i,new w.Vector2(c.width,c.height));l.name=`arrow-${t}`,l.userData._arrowStyle=i,this.sceneManager.scene?.add(l),this._arrows.set(t,l),this._host?.invalidate()}removeArrow(t){const e=this._arrows.get(t);e&&(e.traverse(t=>{if(t instanceof h.Line2)return t.geometry.dispose(),void t.material.dispose();if(t instanceof w.Sprite){const e=t.material.map;if(e){e.dispose();const t=e.source?.data;t instanceof HTMLCanvasElement&&(t.width=0,t.height=0)}return void t.material.dispose()}(t instanceof w.Mesh||t instanceof w.Line)&&(t.geometry.dispose(),t.material instanceof w.Material&&t.material.dispose())}),e.removeFromParent(),this._arrows.delete(t),this._host?.invalidate())}clearArrows(){for(const t of this._arrows.keys())this.removeArrow(t)}updateArrow(t,e,n){const i=this._getArrowStyle(t);i&&this.addArrow(t,e,n,i)}_getArrowStyle(t){const e=this._arrows.get(t);return e?e.userData._arrowStyle??null:null}highlightBookmarkMarker(t){this._highlightedMarkerIndex!==t&&(this._highlightedMarkerIndex=t,this._syncOutlinePass(),this._host?.invalidate())}clearBookmarkMarkerHighlight(){-1!==this._highlightedMarkerIndex&&(this._highlightedMarkerIndex=-1,this._syncOutlinePass(),this._host?.invalidate())}_syncOutlinePass(){const t=[...this._selectionOutlineObjects];for(const e of this._decoratorOutlines){const n=e._realObject;n?.object3d&&!t.includes(n.object3d)&&t.push(n.object3d)}if(this._highlightedMarkerIndex>=0&&this._pathMarkers)for(const e of this._pathMarkers.children)if(e.userData.bookmarkSlotIndex===this._highlightedMarkerIndex){e.traverse(e=>{e.isMesh&&t.push(e)});break}this.rendererManager.setOutlineObjects(t)}_handleSelectionChanged(t){const e=t.filter(t=>t!==this._host&&t._realObject);if(e.length>=1){const t=e[0]._realObject;t?.object3d&&t.gizmoTransformable?this.gizmoManager.attached&&this.gizmoManager.attach(t.object3d):this.gizmoManager.detach()}else this.gizmoManager.detach();const n=e.filter(t=>t.mutable&&t.path);n.length>0&&this.sceneManager.scene?this.vertexGizmoManager.attachMultiple(n,this.sceneManager.scene,this._host?.app?.commander):this.vertexGizmoManager.detach(),this._updateSelectionOutline(e),this._host?.invalidate()}_updateSelectionOutline(t){this._selectionOutlineObjects=[];for(const e of t){const t=e._realObject;t?.object3d&&this._selectionOutlineObjects.push(t.object3d)}this._syncOutlinePass()}}Za.register("three",{reflow:function(t){},capturables:function(t){return t.state.threed?[]:t.components},drawables:function(t){return t.state.threed?[]:t.components},isStuck:function(t){return!1}});const Ou={x:1,y:1},zu={x:0,y:0},Lu='<svg viewBox="0 0 20 20" width="18" height="18" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">\n <path d="M4 5l12-1v12l-12-1z"/>\n <circle cx="10" cy="10" r="1.5"/>\n</svg>',Iu='<svg viewBox="0 0 20 20" width="18" height="18" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">\n <rect x="4" y="4" width="12" height="12" rx="1"/>\n <path d="M10 2v2M10 16v2"/>\n <path d="M10 7v3l2-1.5" opacity="0.5"/>\n</svg>',Ru='<svg viewBox="0 0 20 20" width="18" height="18" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">\n <path d="M4 14l2-10h8l2 10z"/>\n <path d="M6 4h8" stroke-width="2"/>\n</svg>',ju='<svg viewBox="0 0 20 20" width="18" height="18" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">\n <path d="M4 6l2 10h8l2-10z"/>\n <path d="M6 16h8" stroke-width="2"/>\n</svg>',Fu='<svg viewBox="0 0 20 20" width="18" height="18" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">\n <path d="M6 4l10 2v8l-10 2z"/>\n <path d="M16 6v8" stroke-width="2"/>\n</svg>',Bu='<svg viewBox="0 0 20 20" width="18" height="18" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">\n <path d="M14 4L4 6v8l10 2z"/>\n <path d="M4 6v8" stroke-width="2"/>\n</svg>',Nu={mutable:!1,resizable:!0,rotatable:!1,properties:[{type:"number",label:"width",name:"width"},{type:"number",label:"height",name:"height"},{type:"select",label:"fit-mode",name:"fitMode",property:{options:["ratio","both","width","height","center","none"]}}]};class Hu extends Sd{constructor(){super(...arguments),this._threeDUserDeactivated=!1}get nature(){return Nu}get is3dMode(){return!!this._threeCapability?.isInitialized}is3dContainer(){return this.is3dMode}get gizmoMode(){return this._threeCapability?.gizmoMode}setGizmoMode(t){this._threeCapability?.setGizmoMode(t)}get scene3d(){return this._threeCapability?.scene3d}get renderer3d(){return this._threeCapability?.renderer3d}get activeCamera3d(){return this._threeCapability?.activeCamera}get mixer(){return this._threeCapability?.mixer}addArrow3D(t,e,n,i){this._threeCapability?.addArrow(t,e,n,i)}removeArrow3D(t){this._threeCapability?.removeArrow(t)}clearArrows3D(){this._threeCapability?.clearArrows()}_buildLightingConfig(){const t=this.state,e={hemisphere:{skyColor:t.hemiSkyColor||"#ffffff",groundColor:t.hemiGroundColor||"#444444",intensity:t.hemiIntensity??4}};if(!1!==t.dirLightEnabled){const n=!1!==t.dirLightFollowCamera;if(e.directional={color:t.dirLightColor||"#ffffff",intensity:t.dirLightIntensity??2,attachToCamera:n,castShadow:!1!==t.dirShadowEnabled,shadowMapSize:t.dirShadowMapSize??2048,shadowBias:t.dirShadowBias??-5e-4},!n){const n=(t.dirLightAzimuth??30)*Math.PI/180,i=(t.dirLightElevation??45)*Math.PI/180,r=1e3;e.directional.position=[r*Math.cos(i)*Math.sin(n),r*Math.sin(i),r*Math.cos(i)*Math.cos(n)]}}return e}_hide2DLayers(){this.canvas&&(this.canvas.style.display="none"),this._overlay&&(this._overlay.style.display="none"),this._auxCanvas&&(this._auxCanvas.style.display="none"),this._decoratorAuxOverlay&&(this._decoratorAuxOverlay.style.display="none");for(const t of this.root?.assist_layers||[])t.element&&(t.element.style.display="none")}get _hasZoomHandler(){return(this.root?.model?.handlers||[]).includes("zoom-handler")}get _needsViewportSync(){return!!this.app?.isEditMode||this._hasZoomHandler}_activateThreeD(t=!1){wd.hideAll(this.root),this._threeCapability&&this._deactivateThreeD(),t&&!this._needsViewportSync&&(this._saved2DViewport={scale:{...this.get("scale")||{x:1,y:1}},translate:{...this.get("translate")||{x:0,y:0}}}),this._threeCapability=new Du,this._threeCapability.init(this,{lightingConfig:this._buildLightingConfig(),css3DSceneAttribute:"model-layer:css3d-renderer"}),this._hide2DLayers(),this.root?.transitionEffect?.dispose();const e=vs.getInstance(),n=[];this.decoratorOverlay&&(n.push(...e.getTargetsWithType(this.decoratorOverlay,"border-highlighting")),e.removeAllFromOverlay(this.decoratorOverlay,"border-highlighting")),this.decoratorAuxOverlay&&(n.push(...e.getTargetsWithType(this.decoratorAuxOverlay,"border-highlighting")),e.removeAllFromOverlay(this.decoratorAuxOverlay,"border-highlighting"));for(const t of n)this._threeCapability.addOutline(t);if(this._threeCapability.domElement&&this.element){const t=this._threeCapability.domElement;t.style.position="absolute",t.style.left="0",t.style.top="0",t.style.pointerEvents="none",t.setAttribute("scene","model-layer-webgl");const e=this._decoratorOverlay||this.element.firstChild;this.element.insertBefore(t,e)}if(this._threeCapability.buildOverlays(),t&&this._needsViewportSync){const t=this.get("scale")||{x:1};this._2dScaleBeforeThreeD=t.x||1,this._initCameraFrom2DViewport();const e=this._threeCapability?.captureViewportInfo();e&&(this._initialVisibleHeight=e.visibleHeight)}else if(this._lastCameraState)this._threeCapability.restoreSessionState(this._lastCameraState);else{const t=this.model.initialCameraView;t&&"perspective"!==t&&this._threeCapability.setCameraView(t,{render:!1})}if(this._pendingCameraView&&(this._threeCapability.setCameraView(this._pendingCameraView,{render:!1}),delete this._pendingCameraView),this._threeCapability.initBookmarks(),!this.app?.isEditMode){const t=this.model?.cameraAutoPlay;"orbit"!==t&&"play"!==t||this._threeCapability.startAutoPlay(t)}this.app?.isEditMode&&this._createToolbar(),this._registerPopupCallbacks();const i=this.root;i?.selected?.length>0&&this._threeCapability._handleSelectionChanged(i.selected),this._resizeThreeD(!0),this.element&&"function"==typeof this.element.focus&&this.element.focus()}_createToolbar(){if(!this.element)return;this._removeToolbar();const t=!!this._threeCapability,e=document.createElement("div");e.setAttribute("scene","threed-toolbar"),e.style.cssText=["position:absolute","top:12px","left:12px","display:flex","flex-direction:column","gap:1px","padding:4px","background:rgba(30,30,30,0.92)","border:1px solid rgba(255,255,255,0.08)","border-radius:8px","pointer-events:auto","backdrop-filter:blur(8px)","-webkit-backdrop-filter:blur(8px)","box-shadow:0 4px 16px rgba(0,0,0,0.4),inset 0 1px 0 rgba(255,255,255,0.05)","user-select:none"].join(";");const n=["width:32px","height:32px","display:flex","align-items:center","justify-content:center","border-radius:5px","cursor:pointer","transition:all 0.12s ease","position:relative"].join(";"),i=(t,e)=>{const i=document.createElement("div");return i.innerHTML=t,i.title=e,i.style.cssText=n,this._applyButtonStyle(i,!1),i.addEventListener("mouseenter",()=>{i.dataset.active||(i.style.background="rgba(255,255,255,0.1)")}),i.addEventListener("mouseleave",()=>{this._applyButtonStyle(i,!!i.dataset.active)}),i},r=()=>{const t=document.createElement("div");return t.style.cssText="height:1px;margin:3px 4px;background:rgba(255,255,255,0.1)",t},s=i(t?'<svg viewBox="0 0 20 20" width="18" height="18" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">\n <rect x="3" y="3" width="14" height="14" rx="1.5"/>\n <line x1="3" y1="10" x2="17" y2="10" opacity="0.4"/>\n <line x1="10" y1="3" x2="10" y2="17" opacity="0.4"/>\n </svg>':'<svg viewBox="0 0 20 20" width="18" height="18" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">\n <path d="M10 2l7 4v8l-7 4-7-4V6l7-4z"/>\n <path d="M10 10l7-4M10 10v8M10 10L3 6"/>\n </svg>',t?"2D Mode":"3D Mode");if(this._applyToggleStyle(s,t),s.addEventListener("mouseenter",()=>{s.style.background=t?"rgba(255,160,60,0.35)":"rgba(255,160,60,0.25)"}),s.addEventListener("mouseleave",()=>{this._applyToggleStyle(s,t)}),s.addEventListener("click",()=>{this.toggleThreeD()}),e.appendChild(s),!t)return e.addEventListener("mousedown",t=>t.stopPropagation()),e.addEventListener("mouseup",t=>t.stopPropagation()),this.target.appendChild(e),void(this._toolbar=e);e.appendChild(r());const o=this._threeCapability,a=document.createElement("div");a.style.cssText="display:flex;flex-direction:column;gap:1px";const c=o.getCameraState()?.view??"perspective",l=[{view:"perspective",icon:Lu,title:"Perspective"},{view:"top",icon:Iu,title:"Top"},{view:"front",icon:Ru,title:"Front"},{view:"back",icon:ju,title:"Back"},{view:"right",icon:Fu,title:"Right"},{view:"left",icon:Bu,title:"Left"}],h=[];for(const{view:t,icon:e,title:n}of l){const r=i(e,n);r.dataset.view=t,t===c&&(this._applyButtonStyle(r,!0),r.dataset.active="1"),r.addEventListener("click",()=>{this._threeCapability?.setCameraView(t)}),h.push(r),a.appendChild(r)}a.appendChild(r());const d=i('<svg viewBox="0 0 20 20" width="18" height="18" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">\n <path d="M10 2 L13 5 L12 10 L15 13 L5 13 L8 10 L7 5 Z"/>\n <line x1="10" y1="13" x2="10" y2="18"/>\n </svg>',"Pin Camera View");d.addEventListener("click",()=>{const t=this._threeCapability?.getCameraState();t&&(this.set("cameraX",t.cameraX),this.set("cameraY",t.cameraY),this.set("cameraZ",t.cameraZ),this._threeCapability?.pinResetPosition())}),a.appendChild(d),e.appendChild(a),this._cameraButtons=h,o.onGizmoAttachChanged=t=>{this.root?.trigger("gizmoattach",t)},o.onCameraViewChanged=t=>{this._updateCameraButtons(t)},o.onGizmoModeChanged=t=>{this.root?.trigger("gizmomode",t)},e.addEventListener("mousedown",t=>{t.stopPropagation(),t.preventDefault()}),e.addEventListener("mouseup",t=>t.stopPropagation()),this.target.appendChild(e),this._toolbar=e}_applyToggleStyle(t,e){e?(t.style.background="rgba(255,140,40,0.3)",t.style.color="#ffaa44",t.style.boxShadow="inset 0 0 0 1.5px rgba(255,140,40,0.5)"):(t.style.background="rgba(255,140,40,0.15)",t.style.color="#cc8833",t.style.boxShadow="inset 0 0 0 1.5px rgba(255,140,40,0.3)")}_applyButtonStyle(t,e){e?(t.style.background="rgba(74,158,255,0.25)",t.style.color="#4a9eff",t.style.boxShadow="inset 0 0 0 1.5px rgba(74,158,255,0.5)",t.dataset.active="1"):(t.style.background="transparent",t.style.color="rgba(255,255,255,0.55)",t.style.boxShadow="none",delete t.dataset.active)}_updateCameraButtons(t){this._cameraButtons?.forEach(e=>{this._applyButtonStyle(e,e.dataset.view===t)})}_registerPopupCallbacks(){const t=this._threeCapability;t&&(t.onHelpToggle=()=>this._toggleHelpPanel(),t.onSearchToggle=()=>this.onSearchToggle?.(),t.onDataBindingToggle=()=>this.onDataBindingToggle?.(),t.onMonitorToggle=()=>this.onMonitorToggle?.(),t.onBookmarkNavToggle=()=>this._toggleBookmarkNav(),t.onBookmarkEditToggle=()=>this._toggleBookmarkEdit())}_closeFloatingPopup(){this._floatingPopupCloseHandler&&(this.target?.removeEventListener("mousedown",this._floatingPopupCloseHandler,!0),this._floatingPopupCloseHandler=void 0),this._floatingPopup?.parentNode&&this._floatingPopup.parentNode.removeChild(this._floatingPopup),this._floatingPopup=void 0}_showFloatingPopup(t,e=!1){this._closeFloatingPopup(),this._floatingPopup=t,e||(this._floatingPopupCloseHandler=e=>{t.contains(e.target)||this._closeFloatingPopup()},setTimeout(()=>{this.target?.addEventListener("mousedown",this._floatingPopupCloseHandler,!0)},0)),t.addEventListener("mousedown",t=>{t.stopPropagation();const e=t.target?.tagName;"INPUT"!==e&&"TEXTAREA"!==e&&"SELECT"!==e&&t.preventDefault()}),t.addEventListener("mouseup",t=>t.stopPropagation()),this._makePopupDraggable(t),this.target.appendChild(t)}_makePopupDraggable(t){let e=0,n=0,i=0,r=0;const s=s=>{const o=s.clientX-e,a=s.clientY-n;t.style.left=i+o+"px",t.style.top=r+a+"px"},o=e=>{t.releasePointerCapture(e.pointerId),t.removeEventListener("pointermove",s),t.removeEventListener("pointerup",o),t.style.cursor=""};t.addEventListener("pointerdown",a=>{const c=a.target,l=c.tagName?.toLowerCase();if("button"===l||"input"===l||"select"===l||"pointer"===c.style.cursor)return;if(c.closest("[data-drag-handle]"))return;const h=t.getBoundingClientRect(),d=t.parentElement.getBoundingClientRect();i=h.left-d.left,r=h.top-d.top,t.style.left=i+"px",t.style.top=r+"px",t.style.right="auto",t.style.bottom="auto",t.style.transform="none",e=a.clientX,n=a.clientY,t.style.cursor="grabbing",t.setPointerCapture(a.pointerId),t.addEventListener("pointermove",s),t.addEventListener("pointerup",o)})}_toggleHelpPanel(){if("help"===this._floatingPopup?.dataset.popupType)return void this._closeFloatingPopup();const t=!!this.app?.isEditMode,e=document.createElement("div");e.dataset.popupType="help",e.style.cssText=["position:absolute","top:50%","left:50%","transform:translate(-50%,-50%)","max-width:min(560px, calc(100% - 40px))","max-height:calc(100% - 40px)","overflow-y:auto","padding:16px 20px","background:rgba(30,30,30,0.94)","border:1px solid rgba(255,255,255,0.08)","border-radius:10px","pointer-events:auto","backdrop-filter:blur(8px)","-webkit-backdrop-filter:blur(8px)","box-shadow:0 4px 20px rgba(0,0,0,0.5)","user-select:none","color:rgba(255,255,255,0.85)","font:12px/1.6 -apple-system,BlinkMacSystemFont,sans-serif","z-index:200"].join(";");const n=document.createElement("div");n.textContent="×",n.style.cssText="position:absolute;top:8px;right:12px;cursor:pointer;font-size:18px;color:rgba(255,255,255,0.4);line-height:1",n.addEventListener("click",()=>this._closeFloatingPopup()),n.addEventListener("mouseenter",()=>{n.style.color="#fff"}),n.addEventListener("mouseleave",()=>{n.style.color="rgba(255,255,255,0.4)"}),e.appendChild(n);const i=document.createElement("div");i.textContent="Help",i.style.cssText="font-size:13px;font-weight:600;color:#4a9eff;margin-bottom:12px",e.appendChild(i);const r=document.createElement("div");r.style.cssText="display:grid;grid-template-columns:1fr 1fr;gap:0 24px",e.appendChild(r);const s=[{label:"Camera",items:[{key:"1",desc:"Perspective",icon:Lu},{key:"2",desc:"Top",icon:Iu},{key:"3",desc:"Front",icon:Ru},{key:"4",desc:"Back",icon:ju},{key:"5",desc:"Right",icon:Fu},{key:"6",desc:"Left",icon:Bu},{key:"0 / Q",desc:"Exit 3D"}]},{label:"Bookmarks",items:[{key:"B",desc:"Bookmark navigator"},{key:"Shift+B",desc:"Bookmark editor",editOnly:!0},{key:"P",desc:"Play tour",viewOnly:!0},{key:"O",desc:"Orbit rotation",viewOnly:!0},{key:"Space",desc:"Pan mode (edit) / Pause (view)"}]},{label:"Navigation",items:[{key:"Drag",desc:"Rotate camera"},{key:"Alt+Drag",desc:"Pan camera"},{key:"Space+Drag",desc:"Pan camera (no select)",editOnly:!0},{key:"Shift+Drag",desc:"Box select",editOnly:!0},{key:"Scroll",desc:"Dolly zoom"},{key:"DblClick",desc:"Reset camera"},{key:"Arrows",desc:"Pan camera"}]},{label:"Edit",items:[{key:"W",desc:"Move gizmo",editOnly:!0},{key:"E",desc:"Rotate gizmo",editOnly:!0},{key:"R",desc:"Scale gizmo",editOnly:!0},{key:"Ctrl+Z",desc:"Undo",editOnly:!0},{key:"Ctrl+Shift+Z",desc:"Redo",editOnly:!0},{key:"Ctrl+C/X/V",desc:"Copy / Cut / Paste",editOnly:!0},{key:"Del",desc:"Delete selected",editOnly:!0},{key:"Esc",desc:"Deselect all",editOnly:!0}]},{label:"Misc",items:[{key:"H",desc:"This help"},{key:"F",desc:"Search"}]}].map(e=>({...e,items:e.items.filter(e=>!(e.editOnly&&!t)&&(!e.viewOnly||!t))})).filter(t=>t.items.length>0),o=s.reduce((t,e)=>t+e.items.length+1,0);let a=0,c=s.length;for(let t=0;t<s.length;t++)if(a+=s[t].items.length+1,a>=o/2){c=t+1;break}const l=[s.slice(0,c),s.slice(c)];for(const t of l){const e=document.createElement("div");let n=!0;for(const i of t){if(!n){const t=document.createElement("div");t.style.cssText="height:1px;margin:8px 0;background:rgba(255,255,255,0.08)",e.appendChild(t)}n=!1;const t=document.createElement("div");t.textContent=i.label,t.style.cssText="font-size:10px;font-weight:700;text-transform:uppercase;color:rgba(255,255,255,0.45);margin:0 0 5px;letter-spacing:0.8px",e.appendChild(t);for(const t of i.items){const n=document.createElement("div");n.style.cssText="display:flex;justify-content:space-between;align-items:center;padding:2px 0;gap:12px";const i=document.createElement("span");i.style.cssText="display:inline-flex;gap:2px;flex-shrink:0";for(const e of t.key.split("+")){const n=document.createElement("kbd");if(n.textContent=e.trim(),n.style.cssText="font-size:10px;font-family:monospace;padding:1px 5px;border-radius:3px;background:rgba(255,255,255,0.08);border:1px solid rgba(255,255,255,0.12);color:rgba(255,255,255,0.65);line-height:1.4",i.appendChild(n),e!==t.key.split("+").at(-1)){const t=document.createElement("span");t.textContent="+",t.style.cssText="color:rgba(255,255,255,0.2);font-size:10px;margin:0 1px",i.appendChild(t)}}const r=document.createElement("span");if(r.style.cssText="font-size:11px;color:rgba(255,255,255,0.7);text-align:right;white-space:nowrap;display:inline-flex;align-items:center;gap:4px",r.appendChild(document.createTextNode(t.desc)),t.icon){const e=document.createElement("span");e.innerHTML=t.icon,e.style.cssText="display:inline-flex;opacity:0.6",r.appendChild(e)}n.appendChild(i),n.appendChild(r),e.appendChild(n)}}r.appendChild(e)}this._showFloatingPopup(e)}_toggleBookmarkNav(){"bookmark-nav"!==this._floatingPopup?.dataset.popupType?this._buildBookmarkPopup("bookmark-nav"):this._closeFloatingPopup()}_toggleBookmarkEdit(){"bookmark-edit"!==this._floatingPopup?.dataset.popupType?this._buildBookmarkPopup("bookmark-edit"):this._closeFloatingPopup()}_buildBookmarkPopup(t){const e=this._threeCapability;if(!e)return;const n="bookmark-nav"===t,i=!!this.app?.isEditMode,r=document.createElement("div");r.dataset.popupType=t,r.tabIndex=-1,r.style.cssText=["position:absolute",n?"bottom:12px":"top:12px","right:12px","min-width:"+(n?"140px":"200px"),"padding:10px 12px","background:rgba(30,30,30,0.94)","border:1px solid rgba(255,255,255,0.08)","border-radius:10px","pointer-events:auto","backdrop-filter:blur(8px)","-webkit-backdrop-filter:blur(8px)","box-shadow:0 4px 20px rgba(0,0,0,0.5)","user-select:none","color:rgba(255,255,255,0.85)","font:12px/1.5 -apple-system,BlinkMacSystemFont,sans-serif","z-index:200"].join(";");const s=document.createElement("div");s.textContent="×",s.style.cssText="position:absolute;top:6px;right:10px;cursor:pointer;font-size:18px;color:rgba(255,255,255,0.4);line-height:1",s.addEventListener("click",()=>this._closeFloatingPopup()),s.addEventListener("mouseenter",()=>{s.style.color="#fff"}),s.addEventListener("mouseleave",()=>{s.style.color="rgba(255,255,255,0.4)"}),r.appendChild(s);const o=document.createElement("div");o.textContent="Bookmarks",o.style.cssText="font-size:13px;font-weight:600;color:#4a9eff;margin-bottom:8px;cursor:grab",r.appendChild(o);const a=document.createElement("div");a.style.cssText="display:flex;flex-direction:column;gap:2px",r.appendChild(a);const c=e.bookmarkManager,l=()=>{i&&this.set?.("cameraBookmarks",c.exportSlots()),e.onBookmarkChanged?.()},h="border:none;background:transparent;color:inherit;cursor:pointer;padding:2px 4px;border-radius:4px;font-size:13px;line-height:1;display:flex;align-items:center;justify-content:center;width:24px;height:24px",d=t=>{const e=28,n=window.devicePixelRatio||1,i=document.createElement("canvas");i.width=e*n,i.height=e*n,i.style.cssText="width:28px;height:28px;flex-shrink:0;border-radius:50%;background:rgba(0,0,0,0.3)";const r=i.getContext("2d");r.scale(n,n);const s=14,o=14,a=12,c=t.position.x-t.target.x,l=t.position.z-t.target.z,h=t.position.y-t.target.y,d=Math.sqrt(c*c+l*l),u=Math.sqrt(c*c+h*h+l*l),p=u>.001?Math.max(0,h/u):0;let f=0,g=0;d>.001&&(f=c/d,g=l/d);const m=1-.6*p,y=s+f*a*.7*m,b=o+g*a*.7*m;r.strokeStyle="rgba(255,255,255,0.12)",r.lineWidth=1,r.beginPath(),r.arc(s,o,a,0,2*Math.PI),r.stroke(),r.strokeStyle="rgba(255,255,255,0.06)",r.beginPath(),r.moveTo(s,2),r.lineTo(s,26),r.moveTo(2,o),r.lineTo(26,o),r.stroke(),r.fillStyle="rgba(255,255,255,0.25)",r.beginPath(),r.arc(s,o,1.5,0,2*Math.PI),r.fill(),r.strokeStyle=`rgba(74,158,255,${.2+.2*p})`,r.lineWidth=1,r.beginPath(),r.moveTo(y,b),r.lineTo(s,o),r.stroke();const _=.6+.4*p;r.fillStyle=`rgba(74,158,255,${_})`,r.beginPath(),r.arc(y,b,3,0,2*Math.PI),r.fill();const v=Math.atan2(g,f),x=Math.PI/8;return r.fillStyle="rgba(74,158,255,0.08)",r.beginPath(),r.moveTo(y,b),r.arc(y,b,.6*a,v+Math.PI-x,v+Math.PI+x),r.closePath(),r.fill(),i},u=()=>{const t=e.getCameraWorldState();if(!t)return-1;const n=.01;for(let e=1;e<=9;e++){const i=c.getSlot(e);if(i&&(Math.abs(t.position.x-i.position.x)<n&&Math.abs(t.position.y-i.position.y)<n&&Math.abs(t.position.z-i.position.z)<n&&Math.abs(t.target.x-i.target.x)<n&&Math.abs(t.target.y-i.target.y)<n&&Math.abs(t.target.z-i.target.z)<n))return e}return-1};let p,f,g=-1;const m=()=>{a.innerHTML="";let t=!1;const i=u(),r=Array.from({length:9},(t,e)=>e+1);for(const s of r){const r=c.getSlot(s),o=!!r,u=s===i;if(n&&!o)continue;t=t||o;const p=document.createElement("div"),f=u?"rgba(74,158,255,0.1)":"transparent";if(p.style.cssText=`display:flex;align-items:center;gap:6px;padding:${n?"6px 8px":"3px 4px"};border-radius:6px;transition:background 0.15s;background:${f}${u?";box-shadow:inset 0 0 0 1px rgba(74,158,255,0.25)":""}`,p.dataset.active=u?"1":"",p.addEventListener("mouseenter",()=>{p.style.background=p.dataset.active?"rgba(74,158,255,0.15)":"rgba(255,255,255,0.06)",!n&&o&&e.highlightBookmarkMarker(s)}),p.addEventListener("mouseleave",()=>{const t=p.dataset.active;p.style.background=t?"rgba(74,158,255,0.1)":"transparent",n||e.clearBookmarkMarkerHighlight()}),n){if(o&&r){const t=d(r);t.style.pointerEvents="none",p.appendChild(t)}const t=document.createElement("span");t.textContent=r?.name||"noname",t.style.cssText=`flex:1;color:${r?.name?"rgba(255,255,255,0.8)":"rgba(255,255,255,0.35)"};font-size:13px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;pointer-events:none;${r?.name?"":"font-style:italic"}`,p.appendChild(t),p.style.cursor="pointer",p.addEventListener("click",()=>{e.animateToSlot(s)})}else{const t=document.createElement("div");t.textContent="⠿";const n=o,i=o?"color:rgba(255,255,255,0.3)":"color:rgba(255,255,255,0.12)";if(t.style.cssText=`width:16px;display:flex;align-items:center;justify-content:center;font-size:14px;flex-shrink:0;user-select:none;${i}${n?";cursor:grab":""}`,n&&(t.dataset.dragHandle="1",t.addEventListener("mouseenter",()=>{t.style.color="rgba(255,255,255,0.6)"}),t.addEventListener("mouseleave",()=>{t.style.color="rgba(255,255,255,0.3)"})),p.appendChild(t),o&&r){const t=d(r);t.style.pointerEvents="none",p.appendChild(t)}o&&(p.style.cursor="pointer",p.addEventListener("click",t=>{const n=t.target.tagName;"INPUT"!==n&&"BUTTON"!==n&&e.animateToSlot(s)}));const a=document.createElement("input");a.type="text",a.value=r?.name||"",a.placeholder=o?"noname":"Empty",a.style.cssText=`width:80px;font-size:12px;color:${o?"rgba(255,255,255,0.7)":"rgba(255,255,255,0.3)"};background:transparent;border:none;border-bottom:1px solid rgba(255,255,255,0.1);outline:none;padding:2px 0;min-width:0`,a.addEventListener("focus",()=>{a.style.borderBottomColor="rgba(74,158,255,0.5)",a.style.color="rgba(255,255,255,0.9)"}),a.addEventListener("blur",()=>{a.style.borderBottomColor="rgba(255,255,255,0.1)",a.style.color=o?"rgba(255,255,255,0.7)":"rgba(255,255,255,0.3)",o&&(c.renameSlot(s,a.value.trim()),l())}),a.addEventListener("keydown",t=>{t.stopPropagation(),t.isComposing||"Enter"!==t.key||a.blur()}),p.appendChild(a);const u=document.createElement("div");if(u.style.cssText="display:flex;gap:2px;flex-shrink:0",o){const t=document.createElement("button");t.textContent="📌",t.title="Overwrite with current view",t.style.cssText=h+";color:#ffaa44",t.addEventListener("mouseenter",()=>{t.style.background="rgba(255,170,68,0.15)"}),t.addEventListener("mouseleave",()=>{t.style.background="transparent"}),t.addEventListener("click",()=>{e.saveCameraToSlot(s),m()}),u.appendChild(t);const n=document.createElement("button");n.textContent="🗑",n.title="Delete this slot",n.style.cssText=h+";color:#ff6b6b",n.addEventListener("mouseenter",()=>{n.style.background="rgba(255,107,107,0.15)"}),n.addEventListener("mouseleave",()=>{n.style.background="transparent"}),n.addEventListener("click",()=>{c.clearSlot(s),l(),m()}),u.appendChild(n);const i=document.createElement("button");i.textContent="⋮",i.title="Playlist settings",i.style.cssText=h+";color:rgba(255,255,255,0.35);font-size:14px",i.addEventListener("mouseenter",()=>{i.style.background="rgba(255,255,255,0.08)"}),i.addEventListener("mouseleave",()=>{i.style.background="transparent"}),u.appendChild(i)}else{const t=document.createElement("button");t.textContent="📌",t.title="Save current view here",t.style.cssText=h+";color:#4ade80",t.addEventListener("mouseenter",()=>{t.style.background="rgba(74,222,128,0.15)"}),t.addEventListener("mouseleave",()=>{t.style.background="transparent"}),t.addEventListener("click",()=>{e.saveCameraToSlot(s),m()}),u.appendChild(t)}p.appendChild(u)}const y=document.createElement("div");if(y.dataset.slotIndex=String(s),y.dataset.filled=o?"1":"",y.appendChild(p),!n&&o){const t=p.querySelector("[data-drag-handle]");t&&t.addEventListener("pointerdown",e=>{e.preventDefault(),e.stopPropagation(),y.style.opacity="0.3",y.style.pointerEvents="none",y.style.outline="1px dashed rgba(74,158,255,0.4)",y.style.borderRadius="4px",t.style.cursor="grabbing";const n=document.createElement("div");n.style.cssText="height:2px;background:#4a9eff;border-radius:1px;margin:1px 0",t.setPointerCapture(e.pointerId);const i=t=>{const e=Array.from(a.querySelectorAll('[data-slot-index][data-filled="1"]'));n.parentNode&&n.parentNode.removeChild(n);let i=null;for(const n of e){if(n===y)continue;const e=n.getBoundingClientRect();if(t.clientY<e.top+e.height/2){i=n;break}}if(i)a.insertBefore(n,i);else{const t=e[e.length-1];t&&t.after(n)}},r=e=>{t.releasePointerCapture(e.pointerId),t.removeEventListener("pointermove",i),t.removeEventListener("pointerup",r),y.style.cssText="",t.style.cursor="grab";const s=Array.from(a.querySelectorAll('[data-slot-index][data-filled="1"]'));n.parentNode&&(a.insertBefore(y,n),n.parentNode.removeChild(n));const o=Array.from(a.querySelectorAll('[data-slot-index][data-filled="1"]')).map(t=>parseInt(t.dataset.slotIndex)).map(t=>{const e=c.getSlot(t);return e?{...e,name:e.name}:void 0}),h=s.map(t=>parseInt(t.dataset.slotIndex)).sort((t,e)=>t-e);o.forEach((t,e)=>{const n=h[e];t?c.saveSlot(n,t):c.clearSlot(n)}),l(),m()};t.addEventListener("pointermove",i),t.addEventListener("pointerup",r)})}if(!n&&o&&r){const t=document.createElement("div");t.dataset.slotDetail="1";const e=g===s;t.style.cssText=`display:${e?"block":"none"};margin:2px 0 4px 26px;padding:6px 8px;background:rgba(255,255,255,0.03);border-radius:4px;border:1px solid rgba(255,255,255,0.06)`;const n="width:50px;font-size:11px;color:rgba(255,255,255,0.7);background:rgba(255,255,255,0.06);border:1px solid rgba(255,255,255,0.12);border-radius:3px;padding:2px 4px;outline:none;text-align:right",i="font-size:10px;color:rgba(255,255,255,0.45);white-space:nowrap",o="display:flex;align-items:center;gap:6px;margin-bottom:4px",c=document.createElement("div");c.style.cssText=o;const h=document.createElement("span");h.textContent="Hold",h.style.cssText=i+";width:55px";const d=document.createElement("input");d.type="number",d.min="0",d.step="500",d.value=String(r.holdDuration??2e3),d.style.cssText=n;const u=document.createElement("span");u.textContent="ms",u.style.cssText=i,d.addEventListener("change",()=>{const t=parseInt(d.value);r.holdDuration=isNaN(t)?void 0:Math.max(0,t),l()}),d.addEventListener("keydown",t=>t.stopPropagation()),c.appendChild(h),c.appendChild(d),c.appendChild(u),t.appendChild(c);const f=document.createElement("div");f.style.cssText=o;const m=document.createElement("span");m.textContent="Transition",m.style.cssText=i+";width:55px";const b=document.createElement("input");b.type="number",b.min="0",b.step="200",b.value=String(r.transitionDuration??1200),b.style.cssText=n;const _=document.createElement("span");_.textContent="ms",_.style.cssText=i,b.addEventListener("change",()=>{const t=parseInt(b.value);r.transitionDuration=isNaN(t)?void 0:Math.max(0,t),l()}),b.addEventListener("keydown",t=>t.stopPropagation()),f.appendChild(m),f.appendChild(b),f.appendChild(_),t.appendChild(f);const v=document.createElement("div");v.style.cssText=o;const x=document.createElement("span");x.textContent="Easing",x.style.cssText=i+";width:55px";const w=document.createElement("select");w.style.cssText="font-size:11px;color:rgba(255,255,255,0.7);background:rgba(255,255,255,0.06);border:1px solid rgba(255,255,255,0.12);border-radius:3px;padding:2px 4px;outline:none";for(const t of["ease-in-out","ease-in","ease-out","linear"]){const e=document.createElement("option");e.value=t,e.textContent=t,e.style.cssText="background:#2a2a2a;color:#ccc",(r.easing??"ease-in-out")===t&&(e.selected=!0),w.appendChild(e)}w.addEventListener("change",()=>{r.easing="ease-in-out"===w.value?void 0:w.value,l()}),v.appendChild(x),v.appendChild(w),t.appendChild(v);const M=document.createElement("div");M.style.cssText=o+";margin-bottom:0";const S=document.createElement("span");S.textContent="Skip in play",S.style.cssText=i+";width:55px";const A=document.createElement("input");A.type="checkbox",A.checked=!!r.excludeFromPlay,A.style.cssText="accent-color:#4a9eff;cursor:pointer",A.addEventListener("change",()=>{r.excludeFromPlay=A.checked||void 0,l()}),M.appendChild(S),M.appendChild(A),t.appendChild(M),y.appendChild(t);const E=p.querySelector("button:last-child");E&&(e&&(E.style.color="#4a9eff"),E.addEventListener("click",()=>{const e="none"!==t.style.display;a.querySelectorAll("[data-slot-detail]").forEach(e=>{if(e!==t&&"none"!==e.style.display){e.style.display="none";const t=e.parentElement?.firstElementChild?.querySelector("button:last-child");t&&(t.style.color="rgba(255,255,255,0.35)")}}),t.style.display=e?"none":"block",E.style.color=e?"rgba(255,255,255,0.35)":"#4a9eff",g=e?-1:s}))}a.appendChild(y)}if(!t){const t=document.createElement("div");if(t.textContent=n?"No bookmarks defined":"No bookmarks saved",t.style.cssText="color:rgba(255,255,255,0.3);font-size:12px;text-align:center;padding:12px 0",a.appendChild(t),!n){const t=document.createElement("div");t.textContent="Use 📌 to save camera positions",t.style.cssText="color:rgba(255,255,255,0.2);font-size:11px;text-align:center;padding:0 0 4px",a.appendChild(t)}}p&&(p.style.display=c.getPlayableSlots().length>=2?"block":"none")};if(m(),!n){p=document.createElement("div"),p.style.cssText="display:none;margin-top:6px;padding:4px 8px;border-top:1px solid rgba(255,255,255,0.06)";const t=document.createElement("div");t.style.cssText="display:flex;align-items:center;gap:6px";const n=document.createElement("input");n.type="range",n.min="0",n.max="1000",n.value="0",n.tabIndex=-1,n.style.cssText="flex:1;min-width:0;margin:0;height:14px;cursor:grab;accent-color:#4a9eff;outline:none";const i=document.createElement("button");i.textContent="▶",i.title="Play / Stop",i.style.cssText="border:none;background:rgba(255,255,255,0.06);color:rgba(255,255,255,0.5);cursor:pointer;font-size:12px;padding:3px 6px;border-radius:4px;line-height:1;flex-shrink:0",i.addEventListener("mouseenter",()=>{i.style.background="rgba(74,158,255,0.15)",i.style.color="#4a9eff"}),i.addEventListener("mouseleave",()=>{i.style.background="rgba(255,255,255,0.06)",i.style.color=c.isPlaying?"#4a9eff":"rgba(255,255,255,0.5)"}),i.addEventListener("click",()=>{const t=c.isPlaying?-1:parseInt(n.value)/1e3;e.togglePlay(t),a()}),n.addEventListener("focus",()=>n.blur());let s=!1;n.addEventListener("mousedown",()=>{s=!0,n.style.cursor="grabbing",c.isPlaying&&(e.togglePlay(),a())}),n.addEventListener("input",()=>{const t=parseInt(n.value)/1e3;e.scrubPath(t)});const o=()=>{s&&(s=!1,n.style.cursor="grab")};n.addEventListener("mouseup",o),n.addEventListener("mouseleave",o),r.addEventListener("keydown",t=>{if("Space"===t.code&&"none"!==p.style.display){t.preventDefault(),t.stopPropagation();const i=c.isPlaying?-1:parseInt(n.value)/1e3;e.togglePlay(i),a()}}),t.appendChild(n),t.appendChild(i),p.appendChild(t),r.appendChild(p);const a=()=>{const t=c.isPlaying;i.textContent=t?"⏹":"▶",i.style.color=t?"#4a9eff":"rgba(255,255,255,0.5)"};let l=-1;const h=()=>{if(this._floatingPopup===r){if(c.isPlaying){const t=c.playProgress;n.value=String(Math.round(1e3*t)),l=-1}else{"⏹"===i.textContent&&a();const t=c.lastPlayProgress;t>=0&&t!==l&&(n.value=String(Math.round(1e3*t)),l=t)}f=requestAnimationFrame(h)}};f=requestAnimationFrame(h);(()=>{const t=c.getPlayableSlots().length;p.style.display=t>=2?"block":"none"})()}if(!n){const t=document.createElement("button"),e="display:block;width:100%;margin-top:8px;padding:5px 0;border:1px solid rgba(255,255,255,0.12);border-radius:6px;background:transparent;color:rgba(255,255,255,0.45);font-size:11px;cursor:pointer;transition:all 0.15s";i&&(t.textContent="Clear All",t.style.cssText=e,t.addEventListener("mouseenter",()=>{t.style.borderColor="rgba(255,107,107,0.4)",t.style.color="#ff6b6b"}),t.addEventListener("mouseleave",()=>{t.style.borderColor="rgba(255,255,255,0.12)",t.style.color="rgba(255,255,255,0.45)"}),t.addEventListener("click",()=>{c.resetAll(),l(),m()})),r.appendChild(t)}const y=e.onBookmarkChanged;e.onBookmarkChanged=()=>{y?.(),this._floatingPopup===r&&(m(),_=-2,n||e.showBookmarkPath())},this._showFloatingPopup(r,!0),n||e.showBookmarkPath();let b,_=u();const v=()=>{if(this._floatingPopup!==r)return;const t=u();if(t!==_){_=t;a.querySelectorAll("[data-slot-index]").forEach(e=>{const n=parseInt(e.dataset.slotIndex||"-1"),i=e.firstElementChild;if(!i)return;const r=n===t,s=r?"rgba(74,158,255,0.1)":"transparent";i.style.background=s,i.style.boxShadow=r?"inset 0 0 0 1px rgba(74,158,255,0.25)":"none",i.dataset.active=r?"1":""})}b=requestAnimationFrame(v)};b=requestAnimationFrame(v);const x=this._closeFloatingPopup.bind(this);this._closeFloatingPopup=()=>{void 0!==b&&cancelAnimationFrame(b),void 0!==f&&cancelAnimationFrame(f),c.isPlaying&&e.togglePlay(),e.clearBookmarkMarkerHighlight(),e.hideBookmarkPath(!0),this._closeFloatingPopup=x,x()}}_removeToolbar(){this._closeFloatingPopup(),this._threeCapability&&(this._threeCapability.onGizmoModeChanged=void 0,this._threeCapability.onGizmoAttachChanged=void 0,this._threeCapability.onCameraViewChanged=void 0,this._threeCapability.onBookmarkChanged=void 0,this._threeCapability.onHelpToggle=void 0,this._threeCapability.onSearchToggle=void 0,this._threeCapability.onDataBindingToggle=void 0,this._threeCapability.onMonitorToggle=void 0,this._threeCapability.onBookmarkNavToggle=void 0,this._threeCapability.onBookmarkEditToggle=void 0),this._toolbar?.parentNode&&this._toolbar.parentNode.removeChild(this._toolbar),this._toolbar=void 0,this._cameraButtons=void 0}_resizeThreeD(t=!1){if(!this._threeCapability||!this.element)return;const e=this.canvas?.clientWidth??0,n=this.canvas?.clientHeight??0,i=e>0?e:this.element.clientWidth,r=n>0?n:this.element.clientHeight;i>0&&r>0&&this._threeCapability.resize(i,r,t)}detachThreeCapability(){const t=this._threeCapability;if(t)return t.forceCleanupDragState(),t.clearAllObjects(),this._threeCapability=void 0,t}adoptThreeCapability(t){this._threeCapability=t,this._hide2DLayers();const e=t.domElement;if(e&&this.element){e.style.position="absolute",e.style.left="0",e.style.top="0",e.style.pointerEvents="none",e.setAttribute("scene","model-layer-webgl");const t=this._decoratorOverlay||this.element.firstChild;this.element.insertBefore(e,t)}t.buildOverlays(),t.rebuildForHost(this,{lightingConfig:this._buildLightingConfig(),css3DSceneAttribute:"model-layer:css3d-renderer"}),this.app?.isEditMode&&this._createToolbar(),this._registerPopupCallbacks(),this._resizeThreeD(!0)}_deactivateThreeD(){if(!this._threeCapability)return;wd.hideAll(this.root),this._removeToolbar(),this._lastCameraState=this._threeCapability.captureSessionState();const{target:t,visibleWidth:e,visibleHeight:n}=this._threeCapability.captureViewportInfo();this._threeCapability.forceCleanupDragState();const i=this._threeCapability.domElement,r=this._threeCapability.css3DRenderer?.domElement,s=[...this._threeCapability.decoratorOutlines];this._threeCapability.dispose(),this._threeCapability=void 0,r?.parentNode&&r.parentNode.removeChild(r);for(const t of this.components)if(t.isHTMLElement()&&t.element){const e=t.element,n=this.getOverlay(t);n?.appendChild(e)}i?.parentNode&&i.parentNode.removeChild(i),this.canvas&&(this.canvas.style.display=""),this._overlay&&(this._overlay.style.display=""),this._auxCanvas&&(this._auxCanvas.style.display=""),this._decoratorOverlay&&(this._decoratorOverlay.style.display=""),this._decoratorAuxOverlay&&(this._decoratorAuxOverlay.style.display="");for(const t of this.root?.assist_layers||[])t.element&&(t.element.style.display="");for(const t of this.components)t.isHTMLElement()&&t.element&&t.reposition();this.app?.isEditMode&&this._createToolbar();for(const t of s)t.disposed||this.applyDecorator(t,"border-highlighting",{distance:8,lineWidth:4,color:"#f007"});this._saved2DViewport?(this.set({scale:this._saved2DViewport.scale,translate:this._saved2DViewport.translate}),this._saved2DViewport=void 0):this._needsViewportSync&&this._init2DViewportFrom3DCamera(t,e,n),this.root.target_element?.focus()}_getViewportSize(){const t=this.target;return{w:t?.clientWidth||this.canvas?.clientWidth||this.state.width||800,h:t?.clientHeight||this.canvas?.clientHeight||this.state.height||600}}_initCameraFrom2DViewport(){if(!this._threeCapability)return;const{w:t,h:e}=this._getViewportSize(),n=this.get("translate")||{x:0,y:0},i=this.get("scale")||{x:1,y:1},r=i.x||1,s=i.y||1,{width:o=800,height:a=600}=this.state,c=(t/2-n.x)/r-o/2,l=(e/2-n.y)/s-a/2,h=t/r,d=e/s;this._threeCapability.positionCameraForViewport(c,l,h,d,this._lastCameraState)}_init2DViewportFrom3DCamera(t,e,n){const{w:i,h:r}=this._getViewportSize(),{width:s=800,height:o=600}=this.state,a=t.x+s/2,c=t.z+o/2;let l;if(this._2dScaleBeforeThreeD&&this._initialVisibleHeight&&n>0){const t=this._initialVisibleHeight/n;l=this._2dScaleBeforeThreeD*t}else if(e>0||n>0){const t=e>0?i/e:1,s=n>0?r/n:1;l=Math.max(t,s)}else l=1;l=Math.max(.1,Math.min(l,10));const h=i/2-a*l,d=r/2-c*l;this.set({translate:{x:h,y:d},scale:{x:l,y:l}}),this._2dScaleBeforeThreeD=void 0,this._initialVisibleHeight=void 0}centerTo(t,e){this.is3dMode&&this._threeCapability?this._threeCapability.centerToComponent(t,e):super.centerTo(t,e)}async ready(){await super.ready(),this.model.threed?this._threeCapability||(await new Promise(t=>setTimeout(t,0)),this._activateThreeD()):this.app?.isEditMode&&this._createToolbar(),this.root?.trigger("dimension",this.model.threed?"3d":"2d")}toggleThreeD(t){const e=t??!this.is3dMode;e?(this._threeDUserDeactivated=!1,this._activateThreeD(!0)):(this._threeDUserDeactivated=!0,this._deactivateThreeD(),this.resize(),this.invalidate()),this.root?.trigger("dimension",e?"3d":"2d")}dispose(){this._deactivateThreeD(),this._removeToolbar(),super.dispose(),this._overlay=null,this._decoratorOverlay&&(vs.getInstance().removeOverlay(this._decoratorOverlay),this._decoratorOverlay.parentNode&&this._decoratorOverlay.parentNode.removeChild(this._decoratorOverlay),this._decoratorOverlay=null),this._decoratorAuxOverlay&&(vs.getInstance().removeOverlay(this._decoratorAuxOverlay),this._decoratorAuxOverlay.parentNode&&this._decoratorAuxOverlay.parentNode.removeChild(this._decoratorAuxOverlay),this._decoratorAuxOverlay=null)}contains(t,e){return!0}isRootModel(){return!0}get stuck(){return!0}get layout(){return this.is3dMode?Za.get("three"):Ja}get overlay(){if(!this._overlay){const t=document.createElement("div");t.style.position="absolute",t.style.width="0",t.style.height="0",t.style.margin="0",t.style.padding="0",t.style.overflow="initial",t.style["user-select"]="none",t.style["transform-origin"]="top left",t.setAttribute("scene","model-layer-overlay"),this.element.insertBefore(t,this.auxCanvas),this._overlay=t,this._repositionOverlay()}return this._overlay}get auxOverlay(){return this.element??void 0}get decoratorOverlay(){if(!this._decoratorOverlay){const t=document.createElement("div");t.style.position="absolute",t.style.width="0",t.style.height="0",t.style.margin="0",t.style.padding="0",t.style.overflow="initial",t.style["user-select"]="none",t.style["transform-origin"]="top left",t.setAttribute("scene","decorator-overlay"),t.id=`decorator-overlay-${Date.now()}`,this.element.insertBefore(t,this.overlay),this._decoratorOverlay=t,vs.getInstance().addOverlay(t)}return this._decoratorOverlay}get decoratorAuxOverlay(){if(!this._decoratorAuxOverlay){const t=document.createElement("div");t.style.position="absolute",t.style.width="0",t.style.height="0",t.style.margin="0",t.style.padding="0",t.style.overflow="initial",t.style.zIndex="100",t.style["user-select"]="none",t.style["transform-origin"]="top left",t.setAttribute("scene","decorator-aux-overlay"),t.id=`decorator-overlay-${Date.now()}`,this.element.appendChild(t),this._decoratorAuxOverlay=t,vs.getInstance().addOverlay(t)}return this._decoratorAuxOverlay}createElement(){const t=super.createElement();return this._overlay&&t.appendChild(this._overlay),t}resize(){if(!this.target||!this.element)return;let{width:t,height:e,fitMode:n}=this.model;this.root.fitMode?n=this.root.fitMode:n||(n="ratio");let i=null;try{i=getComputedStyle(this.target)}catch(t){return void ji(t,this.target)}let r=i?parseFloat(i.getPropertyValue("width")):this.target.clientWidth,s=i?parseFloat(i.getPropertyValue("height")):this.target.clientHeight;switch(n){case"both":case"ratio":break;case"width":s=e*r/t,this.element.style.overflowX="hidden",this.element.style.overflowY="auto";break;case"height":r=t*s/e,this.element.style.overflowX="auto",this.element.style.overflowY="hidden";break;default:r=Math.max(t,r),s=Math.max(e,s),this.element.style.overflowX=r>t?"hidden":"auto",this.element.style.overflowY=s>e?"hidden":"auto"}this.fitSize(this.element,!0),this.fitSize(this.canvas,!0,r,s),this.fitSize(this.auxCanvas,!0,r,s),this.root?.transitionEffect?.resize(),this.is3dMode&&this._threeCapability.resize(r,s)}draw(t){if(this.is3dMode){if(!this.element)return;return void this._threeCapability.renderCSS3D()}if(this.model.threed&&!this._threeCapability&&!this._threeDUserDeactivated)return;const e=this.root?.transitionEffect;e?.beginDraw(),super.draw(t),e?.endDraw()}get MPP(){const{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){const n=this.layout.capturables(this);for(let i=n.length-1;i>=0;i--){const r=n[i];if(!r.isContainer())continue;const s=r.capturePath(t,e);if(s)return s}return!1}getOverlay(t){return t&&!t.scalable?this.auxOverlay:this.overlay}getDecoratorOverlay(t){return t&&!t.scalable?this.decoratorAuxOverlay:this.decoratorOverlay}_onkeydown_root(t){if(t.metaKey||t.ctrlKey||t.altKey||t.shiftKey)return;const e=this.rootModel;if(!e)return;if("KeyF"===t.code)return this.onSearchToggle?.(),void t.preventDefault();if("KeyH"===t.code)return this._toggleHelpPanel(),void t.preventDefault();if("KeyD"===t.code)return this.onDataBindingToggle?.(),void t.preventDefault();if("KeyM"===t.code)return this.onMonitorToggle?.(),void t.preventDefault();if("KeyQ"===t.code)return this.toggleThreeD(),void t.preventDefault();if(e.is3dMode)return;const n={Digit1:"perspective",Digit2:"top",Digit3:"front",Digit4:"back",Digit5:"right",Digit6:"left"}[t.code];n&&(e._pendingCameraView=n,this.toggleThreeD(!0),t.preventDefault())}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,"deco-reset":t=>this.resetDecorator(void 0,t.origin)},"(descendant)":{"deco-anchors":(t,e)=>this.applyDecorator(e.origin,"anchors",t),"deco-anchors-off":t=>this.offdecorator(t.origin,"anchors"),"deco-anchors-reset":t=>this.resetDecorator("anchors"),"deco-dataspread":(t,e)=>this.applyDecorator(e.origin,"data-spread",t),"deco-dataspread-off":t=>this.offdecorator(t.origin,"data-spread"),"deco-dataspread-reset":t=>this.resetDecorator("data-spread"),"deco-link":(t,e)=>this.applyDecorator(e.origin,"link",t),"deco-link-off":t=>this.offdecorator(t.origin,"link"),"deco-link-reset":t=>this.resetDecorator("link"),"deco-arrow":(t,e)=>this.applyDecorator(e.origin,"bouncing-arrow",t),"deco-arrow-off":t=>this.offdecorator(t.origin,"bouncing-arrow"),"deco-arrow-reset":t=>this.resetDecorator("bouncing-arrow"),"deco-icon":(t,e)=>this.applyDecorator(e.origin,"animated-icon",t),"deco-icon-off":t=>this.offdecorator(t.origin,"animated-icon"),"deco-icon-reset":t=>this.resetDecorator("animated-icon"),"deco-border":(t,e)=>{this.app.isEditMode||(this._threeCapability?this._threeCapability.addOutline(e.origin):this.applyDecorator(e.origin,"border-highlighting",t))},"deco-border-off":t=>{this.app.isEditMode||(this._threeCapability?this._threeCapability.removeOutline(t.origin):this.offdecorator(t.origin,"border-highlighting"))},"deco-border-reset":t=>{this.app.isEditMode||(this._threeCapability?this._threeCapability.clearOutlines():this.resetDecorator("border-highlighting"))},"deco-tag":(t,e)=>this.applyDecorator(e.origin,"decotag",t),"deco-tag-off":t=>this.offdecorator(t.origin,"decotag"),"deco-tag-reset":t=>this.resetDecorator("decotag",t.origin),"deco-off":t=>{this.offdecorator(t.origin),this._threeCapability?.removeOutline(t.origin)},mouseenter:this.onmouseenterForDecorator,mouseleave:this.onmouseleaveForDecorator},"(self)":{change:this.onChangeForDecorator,redraw:this.onRedrawForDecorator}},"(root)":{"(self)":{selected:this._onRootSelected,keydown:this._onkeydown_root}}}}onRedrawForDecorator(){this.is3dMode||(vs.getInstance().invalidateOverlay(this.decoratorOverlay),vs.getInstance().invalidateOverlay(this.decoratorAuxOverlay))}closeScene(t){requestAnimationFrame(()=>this.overlay.dispatchEvent(new CustomEvent("close-scene",{bubbles:!0,composed:!0,detail:t})))}_repositionOverlay(){const t=this._overlay;if(!t)return;const{translate:e=zu,scale:n=Ou,rotation:i=0}=this.model,{left:r,top:s}=this.bounds;t.style.left=r+"px",t.style.top=s+"px",t.style.transform=`rotate(${i}rad) scale(${n.x}, ${n.y}) perspective(1px)`,t.style.marginLeft=`${e.x}px`,t.style.marginTop=`${e.y}px`}onchange(t){const e=this._model;delete e.id,delete e.text,delete e.class,this._repositionOverlay(),t.hasOwnProperty("threed")&&(t.threed?this._activateThreeD(!0):this._deactivateThreeD(),this.root?.trigger("dimension",t.threed?"3d":"2d")),this.is3dMode&&((t.hasOwnProperty("width")||t.hasOwnProperty("height"))&&this._resizeThreeD(),this._threeCapability.onchange(t))}_onRootSelected(t){const e=1===t?.length?t[0]:t&&0!==t.length?null:this;e&&globalThis.dispatchEvent?.(new CustomEvent("clickComponent",{detail:e}))}_onchanged_all(t,e,n){this.invalidate()}_onmouseenter_all(t,e){if(t.stopPropagation(),!this.app||this.app.isEditMode)return;if(!e)return;const n=e.origin;if(n instanceof Hu||!n.model.event||!n.model.event.hover)return;if(n.hidden)return;const i=n.model.event.hover;i&&this._doEventAction(i,n,!0,t)}_onmouseleave_all(t,e){if(t.stopPropagation(),!e)return;const n=e.origin;if(!this.app||this.app.isEditMode)return;const i=n.model.event&&n.model.event.hover;i&&this._doEventAction(i,n,!1,t)}_onclick(t,e){if(t.stopPropagation(),this.app.isEditMode)return;if(!e)return;const n=e.origin,i=n.model.event?.tap;i&&this._doEventAction(i,n,!0,t)}_onmousedownup(t,e){if(t.stopPropagation(),this.app.isEditMode)return;if(!e)return;const n=e.origin,i=n.model.event?.tap;i&&i.pressed&&this._doMouseDownUpEventAction(i,n,"mousedown"==t.type||"touchstart"==t.type,t)}_doMouseDownUpEventAction(t,e,n,i){const{pressed:r=!1}=t;r&&(n?function(t){if(t.hasOwnProperty("_backupShadow"))return;const e=t.get("shadow");t._backupShadow=e;const{left:n=0,top:i=0}=e||{};t.delta("tx",n),t.delta("ty",i),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,n,i){let{action:r,target:s,value:o,emphasize:a=!1,restore:c=!1,options:l}=t;if(s&&(s=e.access(s)),o&&(o=e.access(o)),a&&(n?function(t){const{hover:e}=t.state.event||{},{emphasize:n}=e||{};if(t.hasOwnProperty("_backupStrokeStyle"))return;if("__backup_emphasize"in t)return;const{strokeStyle:i,lineWidth:r,fillStyle:s}=t.state;t.__backup_emphasize={strokeStyle:i,lineWidth:r,fillStyle:s},t.setState(n)}(e):c&&function(t){"__backup_emphasize"in t&&(t.setState(t.__backup_emphasize),delete t.__backup_emphasize)}(e)),r)switch(r){case"data-toggle":if(!s)return;(n||c)&&this.root.findAll(s,e)?.forEach(t=>{t.data=!t.data});break;case"data-tristate":if(!s)return;(n||c)&&this.root.findAll(s,e)?.forEach(t=>{const e=Math.round(Math.max(Number(t.data)||0,0));t.data=(e+(n?1:2))%3});break;case"data-spreading":if(!s)return;n&&(e.access(o),this.root.findAll(s,e)?.forEach(t=>{t.executeMappings(!0)}));break;case"data-set":if(!s)return;if(n){const t=e.access(o);this.root.findAll(s,e)?.forEach(e=>{e.data=t})}break;case"partial-data-set":if(!s)return;if(n){const t=e.access(o);this.root.findAll(s,e)?.forEach(e=>{e.data={...e.data,...t}})}break;case"value-set":if(!s)return;if(n){const t=e.access(o);this.root.findAll(s,e)?.forEach(e=>{e.value=t})}break;case"partial-value-set":if(!s)return;if(n){const t=e.access(o);this.root.findAll(s,e)?.forEach(e=>{e.value={...e.value,...t}})}break;case"infoWindow":case"info-window":if(!s)return;"click"==i.type||n?Ka.show(e,s,c,{x:i.offsetX,y:i.offsetY}):c&&Ka.hide(e,s);break;case"toggle-info-window":if(!s)return;Ka.toggle(e,s,!1,{x:i.offsetX,y:i.offsetY});break;case"popup":case"modal-popup":if(!s)return;const t=l&&"input"in l?l.input:"(self)",a=!l||(!("output"in l)||l.output),h=this.is3dMode&&"modal-popup"!==r;wd.show(e,s,{data:t&&this.root.findFirst(t,e)?.data,output:a,modal:"modal-popup"===r,closable:!0,draggable:!h,origin:"auto",anchor:h?e:void 0,tether:h});break;case"inline-popup":case"inline-modal-popup":{if(!s)return;const t=this.root.findById(s);if(!t)return;const n=t.state||{},i="inline-modal-popup"===r,o=this.is3dMode&&!i;wd.show(e,"",{containerRef:s,modal:i,closable:!0,draggable:!o,origin:"auto",anchor:o?e:void 0,constantSize:n.constantSize??!0,billboard:n.billboard??!0,tether:n.tether??o,offScreen:n.offScreen??"hide",data:e.data});break}case"close-scene":this.closeScene(e.data);break;case"goto":case"goto-playlist":this.trigger(r,s,l,e);break;case"mouse-cursor":n?this.target.style.cursor=s||"auto":c&&(this.target.style.cursor="auto");break;default:this.trigger(r,s,o,e)}}applyDecorator(t,e,n={}){const i=this.getDecoratorOverlay(t);if(i){vs.getInstance().addToOverlay(i,t,e,n)}}offdecorator(t,e){const n=this.getDecoratorOverlay(t);if(n){vs.getInstance().removeFromOverlay(n,t,e)}}resetDecorator(t,e){const n=this.getDecoratorOverlay(e);n&&vs.getInstance().removeAllFromOverlay(n,t)}onChangeForDecorator(t,e,n){const{origin:i}=n,r=this.getDecoratorOverlay(i);vs.getInstance().invalidateOverlay(r)}onmouseenterForDecorator(t,e){const{origin:n}=e;n.decorators&&n.decorators.forEach(t=>{this.applyDecorator(n,t)})}onmouseleaveForDecorator(t,e){const{origin:n}=e;n.decorators&&n.decorators.forEach(t=>{this.offdecorator(n,t)})}}function Yu(t,e){const n=t.state.refid;return t.root.findAll(t=>t.isLine()&&t.from?.component===n&&(!e||t.from.anchor===e))}function Gu(t,e){const n=t.state.refid;return t.root.findAll(t=>t.isLine()&&t.to?.component===n&&(!e||t.to.anchor===e))}function Vu(t){return class extends t{isConnectable(){return!0}postrender(t){super.postrender(t),this._draw_anchors(t)}_draw_anchors(t){const e=this.anchors||[];t.save(),e.forEach(e=>{const{draw:n}=e;if(n){t.beginPath();try{n.call(e,t,this)}catch(t){ji(t)}t.closePath()}}),t.restore()}contains(t,e){let n=super.contains(t,e);if(n)return n;const i=this.anchors||[];for(const r of i){const i=r.bounds;if(!i)continue;const{left:s,top:o,width:a,height:c}=i;if(n=t<Math.max(s+a,s)&&t>Math.min(s+a,s)&&e<Math.max(o+c,o)&&e>Math.min(o+c,o),n)return n}return!1}findInOutLines(t){return function(t,e){const n=t.state.refid;return t.root.findAll(t=>!(!t.isLine()||(t.from?.component!==n||e&&t.from.anchor!==e)&&(t.to?.component!==n||e&&t.to.anchor!==e)))}(this,t)}findOutletLines(t){return Yu(this,t)}findOutletEnds(t){return function(t,e){return Yu(t,e).map(t=>t.toEnd?.component).filter(Boolean)}(this,t)}findInletLines(t){return Gu(this,t)}findInletEnds(t){return function(t,e){return Gu(t,e).map(t=>t.fromEnd?.component).filter(Boolean)}(this,t)}}}Hu.Popup=wd,Ga.register("model-layer",Hu);const Uu={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"number",label:"round",name:"round",property:{min:0}}],help:"scene/component/rect"},$u={ondragmove:function(t,e,n){const{left:i,width:r,height:s}=n.model;let o=(n.fromParent(t.x,t.y).x-i)/(r/2)*100;o=Ua(o,r,s),n.set({round:o})}};class Wu extends(Vu($a(Va))){is3dish(){return!0}get controls(){let{left:t,top:e,width:n,round:i,height:r}=this.state;return i=null==i?0:Ua(i,n,r),[{x:t+n/2*(i/100),y:e,handler:$u}]}get nature(){return Uu}}Ga.register("rect",Wu);const Xu=[1,2,10,20,50,50,50,50,50,50];class qu extends($a(Va)){render(t){const{lineWidth:e=1,fillStyle:n="lightgray",font:i="15px Arial",left:r,top:s,origin:o,width:a,height:c,side:l="bottom",strokeStyle:h="#000000",scale:d=1}=this.state;t.translate(r,s),t.beginPath();const u=Math.round(e/2);t.rect(-u,-u,a+2*u,c+2*u),t.clip(),t.beginPath(),t.rect(0,0,a,c),n&&(t.fillStyle=n,t.fill()),t.lineWidth=e,t.strokeStyle=h,t.stroke(),t.beginPath(),t.font=i;const p="bottom"!==l,f=p?0:c;let g=4*c/5,m=2*c/3,y=1*c/2,b=3*c/5;p&&(g=c-g,m=c-m,y=c-y,b=c-1.5*c/5);const _=d*this.app.PPM/this.root.unitScale;let v=Math.ceil(o/_);const x=this.app.PPM/_,w=x<=1.1?1:Xu[Math.round(x)]||100;1!=w&&(v+=(w-v%w)%w);let M=Math.ceil(v*_);const S=o+a;for(t.fillStyle=h;M<S;){if(v%10==0){t.moveTo(M-o,y),t.lineTo(M-o,f);const e=(v/10).toString(),n=t.measureText(e);t.fillText(e,M-o-n.width-6,b)}else v%5==0?(t.moveTo(M-o,m),t.lineTo(M-o,f)):(t.moveTo(M-o,g),t.lineTo(M-o,f));v+=w,M=Math.ceil(v*_)}}}Ga.register("ruler",qu);const Ku=20,Qu=20,Zu=90*Math.PI/180,Ju="9px Verdana",tp=20,ep="#f4f4f4",np="#999";function ip(t,e,n){return{left:-t.x,top:-t.y,width:Ku,height:tp}}function rp(t,e,n,i){return{left:Ku-t.x,top:0-t.y,origin:20-t.x,width:e-Ku,height:tp}}function sp(t,e,n,i){const r={x:0-t.x+10,y:-t.y+Qu+(n-Qu)/2},s=Ga.transcoordRR(0-t.x,-t.y+Qu,r,Zu);return{left:s.x-(n-Qu),top:s.y,origin:20-t.y,width:n-Qu,height:tp}}function op(t){const e=t.get("translate");return{left:-e.x,top:-e.y,width:t.canvas.width/wr,height:t.canvas.height/wr}}Ga.register("guide-layer",class extends Md{constructor(t,e){super(t,e),this.appScale={x:1,y:1},"disabled"!==t.ruler&&(this.hruler=new qu({left:Ku,top:0,origin:20,margin:0,height:tp,unit:"m",rotation:0,font:Ju,fillStyle:ep,strokeStyle:np,capturable:!1}),this.vruler=new qu({left:0,top:0,origin:20,margin:0,height:tp,unit:"m",rotation:Zu,font:Ju,side:"top",fillStyle:ep,strokeStyle:np,capturable:!1}),this.origin_rect=new Wu({left:-20,top:-20,width:20,height:20,fillStyle:ep,strokeStyle:np,lineWidth:1}),this.addComponent(this.hruler),this.addComponent(this.vruler),this.addComponent(this.origin_rect)),this.invalidate()}get capturable(){return!1}async ready(){if(await super.ready(),!this.hruler)return void(this.screen_coord=op(this));const t=this.rootModel,e=Object.assign({},t.get("translate"));e.x<Ku&&(e.x+=Ku),e.y<Qu&&(e.y+=Qu);const n=t.get("scale")||{x:1,y:1};this.appScale=n,this.hruler.set("scale",n.x),this.vruler.set("scale",n.y),t.set("translate",e),this.set("translate",e),this.screen_coord=op(this);const{width:i,height:r}=this.screen_coord;this.hruler.set(rp(e,i)),this.vruler.set(sp(e,0,r)),this.origin_rect.set(ip(e))}resize(){super.resize(),this.screen_coord=op(this);const{width:t,height:e}=this.screen_coord;this.hruler&&(this.hruler.set(rp(this.model.translate,t)),this.vruler.set(sp(this.model.translate,0,e)),this.origin_rect.set(ip(this.model.translate)))}render(t){if(this.rootModel?.is3dMode)return;if(!this.guide)return;t.save();const{x:e,y:n}=this.guide,{top:i,left:r,width:s,height:o}=this.screen_coord;t.beginPath(),t.moveTo(e,i),t.lineTo(e,i+o),t.moveTo(r,n),t.lineTo(r+s,n),t.lineWidth=1,t.strokeStyle="tomato",t.setLineDash([2,3]),t.font="10px tahoma",t.fillStyle="#333";const a=this.toGlobal(e,n,this.rootModel);t.textBaseline=a.y>200?"bottom":"top",t.textAlign=a.x>200?"right":"left";const c=a.y>200?-5:5,l=a.x>200?-5:5,h=Math.round(e/this.appScale.x),d=Math.round(n/this.appScale.y);t.fillText(` ${h}, ${d} `,e+l,n+c),t.stroke(),t.restore()}get guide(){return this._guide}set guide(t){this._guide=t,this.invalidate()}contains(t,e){return!0}get eventMap(){return{"(root)":{"(descendant)":{mousemove:this.onmousemove_child,mouseout:this.onmouseout_child,dragmove:this.onmousemove_child},"model-layer":{change:this.onchange_root_model}},"(self)":{"(descendant)":{mousedown:this.onmousedown_origin}}}}onmousedown_origin(t,e){this.rootModel.set("translate",{x:20,y:20})}onchange_root_model(t,e,n){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=op(this),this.hruler){const{translate:t}=this.model,{width:e,height:n}=this.screen_coord;this.hruler.set(rp(t,e)),this.vruler.set(sp(t,0,n)),this.origin_rect.set(ip(t))}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.toLocal(t.offsetX,t.offsetY)}});Ga.register("shift-layer",class extends Md{async ready(){await super.ready();const 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.toLocal(t.offsetX,t.offsetY)}ondragmove(t){const{x:e,y:n}=this.toLocal(t.offsetX,t.offsetY);this.rootModel.move({x:e-this.last_position.x,y:n-this.last_position.y},!1),this.last_position=this.toLocal(t.offsetX,t.offsetY)}});function ap(t,e,n,i,r){const s=t.selected;let o=i?s.slice(0):[];e.isContainer()||(e=e.parent);const a=e.layout.capturables(e),c=!!e.layout.joinType;if(i&&n.selected.forEach(t=>{o.splice(o.indexOf(t),1)}),n.selected=[],a.forEach(t=>{!t.capturable||!function(t,e,n){const{sx:i,sy:r,ex:s,ey:o}=e;let a,c,l,h;if(i>s?(a=s,c=i):(a=i,c=s),r>o?(l=o,h=r):(l=r,h=o),n){const e=t.bounds,n=t.transcoordS2TR(e.left,e.top),i=t.transcoordS2TR(e.left+e.width,e.top+e.height),r=n.x,s=i.x,o=n.y,d=i.y,u=Math.min(a,r,c,s),p=Math.max(a,r,c,s),f=Math.min(l,o,h,d),g=Math.max(l,o,h,d);return!(p-u>Math.abs(c-a)+Math.abs(s-r)||g-f>Math.abs(h-l)+Math.abs(d-o))}{const e=t.path;if(!e)return ji("컴포넌트에 get path가 잘못 구현되어있음.",t),!1;for(let n=0;n<e.length;n++){const i=t.transcoordS2TR(e[n].x,e[n].y);if(a>i.x||c<i.x||l>i.y||h<i.y)return!1}return!0}}(t,n,c)||-1!=o.indexOf(t)||r&&t.state.type!==r||n.selected.push(t)}),o=o.concat(n.selected),s.length!==o.length)t.selected=o;else for(let e=0;e<o.length;e++)if(s[e]!=o[e]){t.selected=o;break}}function cp(t,e,n,i,r,s){r||ap(t,e,n,i,s)}function lp(t,e){const n=t.components||[];for(const t of n){lp(t,e);const n=e.indexOf(t);-1!=n&&e.splice(n,1)}}Ga.register("add-layer",class extends Md{async ready(){await super.ready();const t=this.rootModel,e=t.get("translate"),n=t.get("scale");this.set("translate",e),this.set("scale",n)}get pointerEvents(){return"none"}render(t){const e=this.addbox;if(e){const{sx:n,sy:i,ex:r,ey:s}=e,o=this.get("scale")||{x:1,y:1};t.beginPath(),t.rect(n,i,r-n,s-i),t.setLineDash([2/o.x,4/o.y]),t.lineWidth=1/o.x,t.strokeStyle="black",t.stroke()}}contains(t,e){return!(3!=this.app.mode)}get eventMap(){return{"(root)":{"(self)":{addstart:this.onaddstart,addstop:this.onaddstop,keydown:this.onkeydown,dragstart:this.ondragstart,dragmove:this.ondragmove,dragend:this.ondragend,mousedown:this.onmousedown,mouseup:this.onmouseup}},"model-layer":{"(self)":{change:this.onchange_root_model}}}}onchange_root_model(t,e,n){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,this.root.target_element?.focus())}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){const{x:e,y:n}=this.toLocal(t.offsetX,t.offsetY);this.addbox={sx:e,sy:n}}ondragmove(t){if(3!==this.app.mode)return;const{x:e,y:n}=this.toLocal(t.offsetX,t.offsetY);this.addbox&&(this.addbox.ex=e,this.addbox.ey=n,this.invalidate())}ondragend(t,e){if(3!==this.app.mode)return;const{sx:n,sy:i,ex:r,ey:s}=this.addbox;Dl.call(this.root,this.models,{left:Math.min(n,r),top:Math.min(i,s),width:Math.abs(r-n),height:Math.abs(s-i)}),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)return;const{x:n,y:i}=this.toLocal(t.offsetX,t.offsetY);Dl.call(this.root,this.models,{cx:n,cy:i}),this.root.trigger("addstop")}});Ga.register("selection-layer",class extends Md{async ready(){await super.ready();const t=this.rootModel,e=t.get("translate"),n=t.get("scale");this.set("translate",e),this.set("scale",n);const i=this.root?.target_element;i?.addEventListener("contextmenu",t=>{t.shiftKey&&t.preventDefault()})}contains(t,e){return!1}render(t){const e=this.selbox;if(e){const{sx:n,sy:i,ex:r,ey:s}=e,o=this.get("scale")||{x:1,y:1};t.beginPath(),t.rect(n,i,r-n,s-i),t.setLineDash([2/o.x,4/o.y]),t.lineWidth=1/o.x,t.strokeStyle="black",t.stroke()}}get eventMap(){return{"(root)":{"(self)":{keydown:this.onkeydown}},"model-layer":{"(self)":{change:this.onchange_root_model},"(all)":{dragstart:this.ondragstart_selbox,dragmove:this.ondragmove_selbox,dragend:this.ondragend_selbox,mousedown:this.onmousedown_comp,mouseup:this.onmouseup_comp}}}}onkeydown(t,e){const{deliverer:n}=e,i=n.selected;if(1!==i.length)return!1;let r=i[0];const s=r.parent;if(!s||s===n)return!1;if("Tab"===t.code){const e=s.layout.capturables(s);let n=e.indexOf(r);if(-1==n){if(!s.indexOf(r))return Fi("Container not contains [",r,"] as a component"),!1;n=0}const i=e.length;t.shiftKey?n--:n++,r=e[(n+i)%i]}else{if(!s.layout.keyNavigate)return!1;r=s.layout.keyNavigate(s,r,t)||r}n.selected=[r],t.preventDefault()}onchange_root_model(t,e,n){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){const n=this.selected.indexOf(t);let i=t.parent;for(;i.parent.isGroup();)i=i.parent;let r=[],s=!1,o=!1;if(this.selected.forEach(t=>{let e=t.parent;if(t!==i){for(;e.parent&&e.parent.isGroup();)e=e.parent;e===i&&(r.push(t),s=!0)}else o=!0}),s)if(e.shiftKey){if(-1!=n)return void this._pendingDecision(e);r.push(t)}else{if(-1!=n)return void this._pendingDecision(e);r=[t]}else{if(o)return void this._pendingDecision(e);if(e.shiftKey)if(this.selected.length>0){if(-1!=this.selected.indexOf(i))return;r=[...this.selected,i]}else r=[i];else r=[i]}this.selected=r}onmousedown_comp(t,e){const{origin:n}=e;if(this.downpoint=null,t.shiftKey){if(n.stuck)return;if(n.parent.isGroup())return void this._selectGroupItem(n,t);if(-1==this.selected.indexOf(n)){if((t.ctrlKey||t.metaKey)&&this.selected.length>0){const t=this.selected[0].state.type;if(n.state.type!==t)return}this.selected=[...this.selected,n]}else this._pendingDecision(t)}else{if(n.parent.isGroup())return void this._selectGroupItem(n,t);if(n.stuck)this.selected.length>0&&(this.selected=[]);else{if(-1!=this.selected.indexOf(n))return;this.selected=[n],this.sameParent=!0}}}onmouseup_comp(t,e){if(!this.downpoint)return;if(this.downpoint.x!==t.offsetX||this.downpoint.y!==t.offsetY)return;const{origin:n}=e;if(t.shiftKey){let t=this.selected.indexOf(n);if(-1==t&&n.parent.isGroup()&&(t=this.selected.indexOf(n.parent)),-1!==t){const e=this.selected.slice();e.splice(t,1),this.selected=e}else{const t=this.selected.filter(t=>!t.isRootModel()&&!!t.parent),e=t.length>0&&t[0].parent;e&&e!==n.parent&&(!function(t,e){let n=t.parent;for(;n;){const t=e.indexOf(n);-1!=t&&e.splice(t,1),n=n.parent}}(n,t),lp(n,t)),t.push(n),this.selected=t}}else if(n.parent.isGroup())return void(this.selected=[n])}ondragstart_selbox(t,e){const{origin:n}=e;if(!n.stuck)return;const{x:i,y:r}=this.toLocal(t.offsetX,t.offsetY);this.selbox={sx:i,sy:r,selected:[]}}ondragmove_selbox(t,e){const{origin:n}=e;if(!n.stuck)return;const{x:i,y:r}=this.toLocal(t.offsetX,t.offsetY);if(this.selbox){this.selbox.ex=i,this.selbox.ey=r;const e=t.shiftKey&&(t.ctrlKey||t.metaKey)&&this.selected.length>0?this.selected[0].state.type:null;cp(this,n,this.selbox,t.shiftKey,!1,e),this.invalidate()}}ondragend_selbox(t,e){const{origin:n}=e;n.stuck&&(this.last_pos=null,this.selbox=null,cp(this,null,null,!1,!0),this.invalidate())}});class hp{constructor(t){this.layer=t}draw(t,e,n){const{left:i,top:r,width:s,height:o}=e.bounds;0!=s&&0!=o&&(t.beginPath(),t.rect(i,r,s,o),t.clip(),t.beginPath(),t.strokeStyle="#f26522",t.lineWidth=4,t.shadowBlur=10,t.shadowColor="black",t.shadowOffsetX=0,t.shadowOffsetY=0,t.rect(i,r,s,o),t.stroke(),t.closePath())}}class dp{constructor(t){this.layer=t}draw(t,e,n){const i=e.bounds;t.beginPath(),t.rect(i.left-4/n.x,i.top-4/n.y,i.width+8/n.x,i.height+8/n.y),t.setLineDash([3/n.x,4/n.y]),t.lineWidth=1/n.x,t.strokeStyle="black",t.stroke(),t.setLineDash([]),t.closePath()}}class up{constructor(t){this.layer=t}reset(){this.active=null}get selected(){return this.layer.selected}contains(t,e,n,i){const r=n.controls;return!!r&&(r.every((r,s)=>(Math.abs(t-r.x)<=4/i.x&&Math.abs(e-r.y)<=4/i.y&&(this.active={component:n,index:s,handler:r.handler}),!this.active)),!!this.active)}draw(t,e,n){const i=e.controls;i&&i.forEach((e,i)=>{t.beginPath(),t.lineWidth=1/n.x,t.ellipse(e.x,e.y,4/n.x,4/n.y,0,0,2*Math.PI,!0),t.fillStyle="#ff5d72",t.fill(),t.strokeStyle="#fff",t.stroke()})}onevent(t,e){const{handler:n,component:i,index:r}=this.active;let s=i.toLocal(e.offsetX,e.offsetY);s=i.toParent(s.x,s.y),n&&"function"==typeof n[t]&&n[t](s,r,i)}onmousedown(t){this.onevent("onmousedown",t)}ondragstart(t){const e=this.active;e.changes=Mc.before([e.component]),this.onevent("ondragstart",t)}ondragmove(t){this.onevent("ondragmove",t)}ondragend(t){this.onevent("ondragend",t);const{component:e,changes:n}=this.active;Mc.after(n,e.app.commander),e.parent&&e.parent.calculateBounds&&e.parent.calculateBounds()}}function pp(t,e){return Math.atan2(e.y-t.y,e.x-t.x)}const fp=15*Math.PI/180;class gp{constructor(t){this.layer=t}reset(){this.active=null,this.created=null}get selected(){return this.layer.selected}contains(t,e,n,i){return!!n.mutable&&(n.path.every((r,s)=>(Math.abs(t-r.x)<=4/i.x&&Math.abs(e-r.y)<=4/i.y&&(this.active={component:n,index:s}),!this.active)),!!this.active)}startLinkProcess(t,e,n){try{const i=Lc(e,t.app,void 0);return t.rootModel.addComponent(i),this.layer.selected=[i],this.active={component:i,index:1},this.ondragstart(n),i}catch(t){Fi(t)}}draw(t,e,n){if(!e.mutable||e.stuck)return;const i=e.path,r=this.active;i.forEach((i,s)=>{t.beginPath(),t.ellipse(i.x,i.y,4/n.x,4/n.y,0,0,2*Math.PI,!0),t.lineWidth=1/n.x,t.strokeStyle="#656565",t.fillStyle="#fff",r&&r.component===e&&r.index===s&&(t.strokeStyle="#fa7703",r.toFill&&(t.fillStyle="#ffb80c")),t.fill(),t.stroke()})}ondblclick(t){const e=this.active.component;if(!e.pathExtendable)return;const n=e.path.slice();n.length<3||(n.splice(this.active.index,1),e.path=n)}onmousedown(t){this.active.toFill=!0}ondragstart(t){const{index:e,component:n}=this.active;this.created||(this.active.changes=Mc.before([n])),0!==e&&e!==n.path.length-1||(this.layer.counterEnd=0===e?n.toEnd||{fromto:"to"}:n.fromEnd||{fromto:"from"})}ondragmove(t){const{component:e,index:n}=this.active||{},{offsetX:i,offsetY:r}=t;let s=e.toLocal(i,r);if(s=e.toParent(s.x,s.y),t.shiftKey){const t=e.path.length;let i=e.isLine()&&0==n?e.path[1]:e.path[(n-1+t)%t];i=e.toParent(i.x,i.y);let r=0;if(t>2){let s;e.isLine()?0==n?s=e.path[2]:1!=n&&(s=e.path[n-2]):s=e.path[(n-2+t)%t],s&&(s=e.toParent(s.x,s.y),r=pp(s,i))}const c=Math.round((pp(i,s)-r)/fp)*fp+r;s=function(t,e,n){return{x:Math.cos(e)*n+t.x,y:Math.sin(e)*n+t.y}}(i,c,(o=i,a=s,Math.sqrt((a.x-o.x)*(a.x-o.x)+(a.y-o.y)*(a.y-o.y))))}var o,a;if(0===n||n===e.path.length-1){const t=this.layer.anchorTarget=e.rootModel.capture(i,r,t=>!t.isConnectable());if(t){const{x:o,y:a}=t.toLocal(i,r),c=this.layer.get("scale")||{x:1,y:1},l=this.layer.counterEnd,h=(t.anchors||[]).find(n=>{const{name:i,inout:r,multiplicity:s=1/0,position:h,filter:d}=n;if(l){const{anchor:t,fromto:e}=l;if(t&&("out"===t.inout&&"out"===r||"in"===t.inout&&"in"===r))return!1;if("from"===e&&"out"===r||"to"===e&&"in"===r)return!1}else ji("should not be here.");if(Math.abs(o-h.x)>8/c.x||Math.abs(a-h.y)>8/c.y)return!1;const u=t.findInOutLines(i);return!!u.includes(e)||!(s!==1/0&&u.length>=s)&&(!l||!d||!!d.call(n,l))});h?0==n?e.from={component:t.get("refid"),anchor:h.name,position:s}:e.to={component:t.get("refid"),anchor:h.name,position:s}:0==n?e.from={position:s}:e.to={position:s}}else 0==n?e.from={position:s}:e.to={position:s}}e.mutatePath(null,function(t){const e=t[n]?.z;t[n]=s,void 0!==e&&(s.z=e)})}ondragend(t){const{component:e,index:n,changes:i}=this.active;if(0===n||n===e.path.length-1){const{offsetX:i,offsetY:r}=t,s=e.rootModel.capture(i,r,t=>t===e||t.isLine()),{x:o,y:a}=s.toLocal(i,r),c=this.layer.get("scale")||{x:1,y:1},l=(s.anchors||[]).find(t=>t&&Math.abs(o-t.position.x)<=8/c.x&&Math.abs(a-t.position.y)<=8/c.y);l&&(0==n?e.from={component:s.get("refid"),anchor:l.name}:e.to={component:s.get("refid"),anchor:l.name}),this.layer.endLinkProcess()}if(this.created){const t=new Oc({changes:[{component:this.created,to_container:this.created.parent}]});this.created.app.commander.execute(t)}else Mc.after(i,e.app.commander);e.parent&&e.parent.calculateBounds&&e.parent.calculateBounds()}}function mp(t,e,n){return t.filter(t=>{const{name:i,inout:r,multiplicity:s=1/0,filter:o}=t;if(n){const{anchor:t,fromto:e}=n;if(t&&("out"===t.inout&&"out"===r||"in"===t.inout&&"in"===r))return!1;if("from"===e&&"out"===r||"to"===e&&"in"===r)return!1}else if("in"===r)return!1;return!(s!==1/0&&e.findInOutLines(i).length>=s)&&(!o||!n||!!o.call(t,n))})}class yp{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,n,i){const r=this.active?.component===n&&this.active?.anchor;this.active=null;const s=this.layer.counterEnd;return mp(n.isConnectable()&&!n.disposed&&this.getAnchorHandles(n,i)||[],n,s).every(s=>{const o=r===s.name?2:1;return s&&s.position&&Math.abs(t-s.position.x)<=4*o/i.x&&Math.abs(e-s.position.y)<=4*o/i.y&&(this.active={component:n,anchor:s.name,template:s.template}),!this.active}),!!this.active}getAnchorHandles(t,e){const{width:n,height:i}=t.bounds;return n*e.x<30||i*e.y<30?[]:t.anchors}draw(t,e,n){if(!e.get("refid")||e.isLine())return;const i=this.active,r=this.active?.component===e&&this.active?.anchor,s=this.layer.counterEnd;mp(e.isConnectable()&&!e.disposed&&this.getAnchorHandles(e,n)||[],e,s).forEach(s=>{const{name:o,position:a}=s,c=r===o?2:1;a&&(t.beginPath(),t.ellipse(a.x,a.y,4*c/n.x,4*c/n.y,0,0,2*Math.PI),t.setLineDash([0,0]),t.lineWidth=1/n.x,t.strokeStyle="#656565",t.stroke(),t.fillStyle="#fff",i&&i.component===e&&i.anchor===o&&(t.strokeStyle="#fa7703",i.focus&&(t.fillStyle="#ffb80c")),t.fill(),t.stroke())})}onmousedown(t){this.active.focus=!0}ondragstart(t){const{component:e,anchor:n,template:i}=this.active,r=this.layer.toLocal(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,...i,from:{component:e.get("refid"),anchor:n,position:r},to:{position:r}},t)}ondragmove(t){}ondragend(t){}}function bp(t,e){const{left:n,top:i,width:r,height:s}=t,o=n+r/2,a=i+s/2,c=n+r,l=i+s,h=r*e.x>50,d=s*e.y>50;return[{x:n,y:i},h?{x:o,y:i}:{x:null,y:null},{x:c,y:i},d?{x:c,y:a}:{x:null,y:null},{x:c,y:l},h?{x:o,y:l}:{x:null,y:null},{x:n,y:l},d?{x:n,y:a}:{x:null,y:null}]}class _p{constructor(t){this.layer=t}reset(){this.active=null}get selected(){return this.layer.selected}contains(t,e,n,i){if(!n.resizable)return!1;const r=bp(n.bounds,i);for(let s=0;s<r.length;s++){const o=r[s];if(null!=o.x&&null!=o.y&&Math.abs(t-o.x)<=4/i.x&&Math.abs(e-o.y)<=4/i.y)return this.active={component:n,index:s},!0}return!1}draw(t,e,n){if(e.isLine())return;const{left:i,top:r,width:s,height:o}=e.bounds;if(t.beginPath(),t.rect(i-4/n.x,r-4/n.y,s+8/n.x,o+8/n.y),t.setLineDash([3/n.x,4/n.y]),t.lineWidth=1/n.x,t.strokeStyle="black",t.stroke(),t.setLineDash([]),!e.resizable)return;const a=this.active;bp(e.bounds,n).forEach((i,r)=>{null!=i.x&&null!=i.y&&(t.beginPath(),t.rect(i.x-4/n.x,i.y-4/n.y,8/n.x,8/n.y),t.setLineDash([]),t.strokeStyle="#656565",t.stroke(),t.fillStyle="#fff",a&&a.component===e&&a.index===r&&(t.strokeStyle="#fa7703",a.focus&&(t.fillStyle="#ffb80c")),t.fill(),t.stroke())})}onmousedown(t){this.active.focus=!0}ondragstart(t){const{component:e}=this.active;this.active.bounds=e.bounds,this.active.boundsList=this.layer.selected.filter(t=>t.resizable).map(t=>t.bounds)}_resizeAll(t,e){const{component:n,index:i,boundsList:r,bounds:s}=this.active,o=n.scalable?this.layer.toLocal(t.offsetX,t.offsetY):{x:t.offsetX,y:t.offsetY};n.bounds=s;const a=function(t,e,n){const{left:i,top:r,width:s,height:o}=t.bounds;let a,c;switch(e){case 0:a=i,c=r;break;case 1:a=i+s/2,c=r;break;case 2:a=i+s,c=r;break;case 3:a=i+s,c=r+o/2;break;case 4:a=i+s,c=r+o;break;case 5:a=i+s/2,c=r+o;break;case 6:a=i,c=r+o;break;case 7:a=i,c=r+o/2}const l=a,h=c,d=t.fromScene(n.x,n.y);return{dx:d.x-l,dy:d.y-h}}(n,i,o);this.layer.selected.filter(t=>t.resizable).forEach((n,s)=>{n.bounds=r[s],function(t,e,n,i,r,s){let{left:o,top:a,width:c,height:l}=t.bounds;const h={left:o,top:a,width:c,height:l};switch(e){case 0:o+=i,a+=r,c-=i,l-=r;break;case 1:a+=r,l-=r;break;case 2:a+=r,c+=i,l-=r;break;case 3:c+=i;break;case 4:c+=i,l+=r;break;case 5:l+=r;break;case 6:o+=i,c-=i,l+=r;break;case 7:o+=i,c-=i}if(t.mutateBounds(function(e){return Math.abs(c)<=.001&&(c=.001),Math.abs(l)<=.001&&(l=.001),t.adjustResize({left:o,top:a,width:c,height:l},h,n)},this),t.isContainer()&&t.layout.ABSOLUTE&&!t.isGroup()){const e=h.left-o,n=h.top-a;return void(s?t.components.forEach(t=>{t.delta("tx",0),t.delta("ty",0),t.move({x:e,y:n},!1)}):t.components.forEach(t=>{t.delta("tx",e),t.delta("ty",n)}))}const d=s&&t.parent;d&&d.isGroup()&&d.calculateBounds()}(n,i,t.shiftKey,a.dx,a.dy,e)})}ondragmove(t){this._resizeAll(t,!1)}ondragend(t){this._resizeAll(t,!0),this.active.component.app.commander.execute(null,!1)}}const vp=2*Math.PI,xp=Math.PI/2;function wp(t,e){const n=t.bounds;return{x:n.left+n.width/2,y:n.top-20/e.y}}class Mp{constructor(t){this.layer=t}reset(){this.active=null}get selected(){return this.layer.selected}contains(t,e,n,i){if(!n.rotatable)return!1;const r=wp(n,i);return Math.abs(t-r.x)<=4/i.x&&Math.abs(e-r.y)<=4/i.y&&(this.active={component:n},!0)}draw(t,e,n){if(!e.rotatable)return;t.beginPath();const i=wp(e,n);t.lineWidth=1.5/n.x,t.moveTo(i.x,i.y+20/n.y),t.lineTo(i.x,i.y),t.strokeStyle="#656565",t.stroke(),t.beginPath(),t.ellipse(i.x,i.y,4/n.x,4/n.y,0,0,vp,!0),t.stroke(),t.fillStyle="#fff",t.fill();const r=this.active;r&&r.component===e&&(t.strokeStyle="#fa7703",t.stroke(),r.toFill&&(t.fillStyle="#ffb80c",t.fill()))}onmousedown(t){this.active.toFill=!0}ondragstart(t){const e=this.active;e.start_rotation=e.component.get("rotation"),e.rotations=this.layer.selected.filter(t=>t.rotatable).map(t=>t.get("rotation"))}ondragmove(t){const{component:e}=this.active;let n;e.scalable?(n=e.toLocal(t.offsetX,t.offsetY),n=e.toParent(n.x,n.y)):(n={x:t.offsetX,y:t.offsetY},e.parent?.isRootModel()||(n=e.toParent(n.x,n.y)));const i=e.rotatePoint,r=e.get("rotation")||0;let s=Math.atan((i.y-n.y)/(i.x-n.x));s=i.x>=n.x?s-xp:xp+s;const o=s-r;this.layer.selected.filter(t=>t.rotatable).forEach((e,n)=>{const i=((e.get("rotation")||0)+o)%vp;e.set("rotation",e.adjustRotation(i,t.shiftKey))})}ondragend(t){const{component:e}=this.active;e.app.commander.execute(null,!1)}}Ga.register("modeling-layer",class extends Sd{constructor(t,e){super(t,e),this.pathHandler=new gp(this);const n=this.pathHandler,i=new up(this),r=new _p(this),s=new Mp(this);this._modelers=[n,i,r,s],this._control_mode_modelers=[i,n,r,s],this.focusOutline=new hp(this),this.groupOutline=new dp(this),this.anchorHandler=new yp(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}async ready(){await super.ready();const t=this.rootModel,e=t.get("translate"),n=t.get("scale");this.set("translate",e),this.set("scale",n)}capture(t,e,n){return!!this.contains(t,e)&&this}contains(t,e){let n=this.selected.filter(t=>!!t.parent);const i=this.fromParent(t,e),r=this.get("scale")||{x:1,y:1};let s;if(this._state_dragging){if(this._counter_end){let n=r;if(this.anchorTarget.scalable?s=this.anchorTarget.fromScene(i.x,i.y):(s=this.anchorTarget.fromScene(t,e),n={x:1,y:1}),this.anchorHandler.contains(s.x,s.y,this.anchorTarget,n))return!0}return!0}this.modelers.forEach(t=>t.reset()),n=this.selected.filter(t=>!!t.parent);for(let o=0;o<n.length;o++){const a=n[o];let c=r;a.scalable?s=a.fromScene(i.x,i.y):(s=a.fromScene(t,e),c={x:1,y:1});for(let t=0;t<this.modelers.length;t++){const e=this.modelers[t];if(e.contains(s.x,s.y,a,c))return this.currentModeler=e,!0}}if(this.anchorTarget){let n=r;if(this.anchorTarget.scalable?s=this.anchorTarget.fromScene(i.x,i.y):(s=this.anchorTarget.fromScene(t,e),n={x:1,y:1}),this.anchorHandler.contains(s.x,s.y,this.anchorTarget,n))return this.currentModeler=this.anchorHandler,!0}else this.anchorHandler.reset();return this.currentModeler=null,!1}_componentDrawer(t,e,n,i){const r=[];let s=e.parent;if(e.isRootModel())return t.save(),i(t,e,n),void t.restore();for((t=this.getContext(e))==this.auxContext2D&&(n={x:1,y:1});s&&!s.isRootModel();)r.push(s),s=s.parent;t.save(),r.reverse().forEach(function(e){const n=e.rotatePoint;t.translate(n.x,n.y);const i=e.get("scale");i&&t.scale(i.x,i.y),t.rotate(e.get("rotation")),t.translate(-n.x,-n.y);const r=e.bounds;t.translate(r.left,r.top)});const o=e.rotatePoint;t.translate(o.x,o.y);const a=e.get("scale");a&&t.scale(a.x,a.y),t.rotate(e.get("rotation")),t.translate(-o.x,-o.y),i(t,e,n),t.restore()}prerender(t){const{translate:e,scale:n={x:1,y:1},rotation:i}=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*wr,e.y*wr),t.scale(n.x*wr,n.y*wr),i&&t.rotate(i),t.clearRect(0,0,this.rootModel.get("width"),this.rootModel.get("height"))}render(t){if(this.rootModel?.is3dMode)return;t.beginPath();const e=this.get("scale")||{x:1,y:1},n=this.selected.filter(t=>!!t.parent);if(this.anchorTarget&&this._componentDrawer(t,this.anchorTarget,e,(t,e,n)=>{this.anchorHandler.draw(t,e,n)}),this.focused&&this._componentDrawer(t,this.focused,e,(t,e,n)=>{this.focusOutline.draw(t,e,n)}),n.length>0&&n[0].parent.isGroup()){let i=n[0].parent;for(;i.parent.isGroup();)i=i.parent;this._componentDrawer(t,i,e,(t,e,n)=>{this.groupOutline.draw(t,e,n)})}n.forEach(n=>{this._componentDrawer(t,n,e,(t,e,n)=>{this.reversedModelers.forEach(i=>i.draw(t,e,n))})})}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,n){this.currentModeler=this.pathHandler,this.processingLink=this.pathHandler.startLinkProcess(t,e,n),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,n){const{origin:i,deliverer:r}=n;i===r&&(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 n=e.origin;n?.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){const{origin:n}=e,i=t.dataTransfer.files;if(i.length<1)return;const r=this.rootModel.toLocal(t.offsetX,t.offsetY),s=this.rootModel;Promise.all(Array.from(i).map(t=>new Promise((e,n)=>{const i=new FileReader;i.addEventListener("loadend",t=>{e(i.result)}),["error","abort"].forEach(t=>i.addEventListener(t,t=>{n(t)})),i.readAsDataURL(t)}))).then(e=>{if(t.altKey)return Mc.around(this.app.commander,()=>{n.ondropfile(i,e)}),void(this.selected=[n]);const o=[],a=e.map((t,e)=>{let n;const a=i[e].type,c=i[e].name;return a.startsWith("image/")?(n=Lc({type:a.startsWith("image/gif")?"gif-view":"image-view",top:0,left:0,width:200,height:200,src:t},s.app),o.push(new Promise((e,i)=>{const r=new Image;r.src=t,r.onload=()=>{n.set({width:r.width,height:r.height}),e()},r.onerror=t=>{i(t)}}))):a.startsWith("audio/")?n=Lc({type:"audio",top:0,left:0,width:100,height:100,src:t},s.app):a.startsWith("vnd.ms-excel/")||/\.xlsx?$/.test(c)?n=Lc({type:"excel",top:0,left:0,width:100,height:100,src:t},s.app):Bi("dropped file",i[e]),n&&(n.center=r,r.x+=50,r.y+=50),n}).filter(Boolean).map(t=>({component:t,to_container:s}));a.length>0&&Promise.all(o).then(()=>{this.app.commander.execute(new Oc({changes:a})),this.selected=a.map(t=>t.component)},t=>{ji(t)})},t=>{ji(t)})}onwheel_scale(t,e){if(0==t.deltaY&&0==t.deltaX)return;const n=e.deliverer;let i;if(t.shiftKey)i=-1!=navigator.userAgent.indexOf("Win")?t.deltaY<0?1:-1:t.deltaX<0?1:-1,t.altKey?Mc.around(this.app.commander,()=>{n.selected.forEach(t=>{let e=t.get("letterSpacing")||Ar.LETTER_SPACING;e+=i,t.set("letterSpacing",e)})}):Mc.around(this.app.commander,()=>{n.selected.forEach(t=>{let e=t.get("fontSize")||Ar.FONT_SIZE;e<1&&(e=1),e+=i,t.set("fontSize",e)})});else{i=t.deltaY<0?1:-1;const e=n.get("scale")||{x:1,y:1},r=n.get("translate"),s=t.offsetX,o=t.offsetY,a=n.toLocal(s,o),c=.1*i,l={x:e.x+c,y:e.y+c};if(i<0&&e.x<.2||i>0&&e.x>10)return;n.set("scale",l);const h=n.toLocal(s,o);n.set("translate",{x:r.x+(h.x-a.x)*l.x,y:r.y+(h.y-a.y)*l.y})}}});Ga.register("scroll-layer",class extends Md{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:n,top:i,width:r,height:s}=this.vscroller;t.globalAlpha="v"==e?1:.3,t.fillRect(n,i,r,s)}if(this.hscroller){const{left:n,top:i,width:r,height:s}=this.hscroller;t.globalAlpha="h"==e?1:.3,t.fillRect(n,i,r,s)}t.stroke(),t.restore()}resize(){super.resize(),this.calcScrollerBounds()}contains(t,e){const n=this.vscroller,i=this.hscroller;return this.setState("scrolling",n&&t>=n.left&&t<=n.left+n.width&&e>=n.top&&e<=n.top+n.height?"v":i&&t>=i.left&&t<=i.left+i.width&&e>=i.top&&e<=i.top+i.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 n=this.root,{clientWidth:i,clientHeight:r}=this.canvas,{width:s,height:o}=this.rootModel.model,{x:a,y:c}={x:t.offsetX,y:t.offsetY},{x:l,y:h}=this._scale,{scrolling:d}=this.state,u=s/i,p=o/r;d&&n.rootModel.move({x:"h"==d?(-a+this.lastPosition.x)*l*u:0,y:"v"==d?(-c+this.lastPosition.y)*h*p:0},!1),this.lastPosition={x:t.offsetX,y:t.offsetY}}ondragend(){delete this.lastPosition,this.setState({scrolling:null})}calcScrollerBounds(){if(!this.rootModel)return;const{clientWidth:t,clientHeight:e}=this.canvas,{width:n,height:i}=this.rootModel.model,{x:r=1,y:s=1}=this._scale||{},{x:o=0,y:a=0}=this._translate||{},c=n/t,l=i/e;let h={left:-o/r/c,top:e-10,width:t/r/c,height:10};this.hscroller=h.left>1||h.width+h.left<t-1?h:null,h={left:t-10,top:-a/s/l,width:10,height:e/s/l},this.vscroller=h.top>1||h.height+h.top<e-1?h:null,this.invalidate()}onchangeModelLayer(t,e,n){if(t.scale){const{x:e=1,y:n=1}=t?.scale||{};this._scale={x:e,y:n},this.calcScrollerBounds()}if(t.translate){const{x:e=0,y:n=0}=t.translate||{};this._translate={x:e,y:n},this.calcScrollerBounds()}}});const Sp="#ff3366",Ap=[3,3];function Ep(t,e,n,i){var r,s=arguments.length,o=s<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,n,i);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(o=(s<3?r(o):s>3?r(e,n,o):r(e,n))||o);return s>3&&o&&Object.defineProperty(e,n,o),o}function kp(t,e,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(t):i?i.value:e.get(t)}function Cp(t,e,n,i,r){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!r:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(t,n):r?r.value=n:e.set(t,n),n}Ga.register("snap-guide-layer",class extends Md{constructor(){super(...arguments),this._snapResult=null}get pointerEvents(){return"none"}get capturable(){return!1}contains(t,e){return!1}get snapResult(){return this._snapResult}set snapResult(t){this._snapResult=t,this.invalidate()}clear(){this._snapResult&&(this._snapResult=null,this.invalidate())}get eventMap(){return{"(root)":{"model-layer":{change:this.onchange_root_model}}}}onchange_root_model(t){(t.translate||t.scale)&&this.syncTransform()}syncTransform(){const t=this.rootModel;if(!t)return;const e=t.get("translate")||{x:0,y:0},n=t.get("scale")||{x:1,y:1};this.set({translate:e,scale:n})}async ready(){await super.ready(),this.syncTransform()}render(t){const e=this._snapResult;if(e&&0!==e.guides.length){t.save(),t.strokeStyle=Sp,t.fillStyle=Sp,t.lineWidth=1,t.setLineDash(Ap);for(let n=0,i=e.guides.length;n<i;n++){const i=e.guides[n];t.beginPath(),"x"===i.axis?(t.moveTo(i.position,i.from),t.lineTo(i.position,i.to)):(t.moveTo(i.from,i.position),t.lineTo(i.to,i.position)),t.stroke()}t.restore()}}}),"function"==typeof SuppressedError&&SuppressedError;
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("dompurify"),require("three"),require("tinycolor2"),require("three/examples/jsm/loaders/GLTFLoader.js"),require("three/examples/jsm/loaders/DRACOLoader.js"),require("three/examples/jsm/loaders/KTX2Loader.js"),require("three/examples/jsm/libs/meshopt_decoder.module.js"),require("three/examples/jsm/utils/SkeletonUtils.js"),require("three/examples/jsm/renderers/CSS3DRenderer.js"),require("three/examples/jsm/lines/Line2.js"),require("three/examples/jsm/lines/LineMaterial.js"),require("three/examples/jsm/lines/LineGeometry.js"),require("three/examples/jsm/objects/Sky.js"),require("three/examples/jsm/postprocessing/EffectComposer.js"),require("three/examples/jsm/postprocessing/RenderPass.js"),require("three/examples/jsm/postprocessing/OutlinePass.js"),require("three/examples/jsm/postprocessing/OutputPass.js"),require("three/examples/jsm/postprocessing/SMAAPass.js"),require("three/examples/jsm/controls/TransformControls.js"),require("three/examples/jsm/geometries/RoundedBoxGeometry.js")):"function"==typeof define&&define.amd?define(["exports","dompurify","three","tinycolor2","three/examples/jsm/loaders/GLTFLoader.js","three/examples/jsm/loaders/DRACOLoader.js","three/examples/jsm/loaders/KTX2Loader.js","three/examples/jsm/libs/meshopt_decoder.module.js","three/examples/jsm/utils/SkeletonUtils.js","three/examples/jsm/renderers/CSS3DRenderer.js","three/examples/jsm/lines/Line2.js","three/examples/jsm/lines/LineMaterial.js","three/examples/jsm/lines/LineGeometry.js","three/examples/jsm/objects/Sky.js","three/examples/jsm/postprocessing/EffectComposer.js","three/examples/jsm/postprocessing/RenderPass.js","three/examples/jsm/postprocessing/OutlinePass.js","three/examples/jsm/postprocessing/OutputPass.js","three/examples/jsm/postprocessing/SMAAPass.js","three/examples/jsm/controls/TransformControls.js","three/examples/jsm/geometries/RoundedBoxGeometry.js"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).scene={},t.DOMPurify,t.THREE,t.tinycolor,t.THREE,t.THREE,t.THREE,t.THREE,t.SkeletonUtils_js,t.THREE,t.THREE,t.THREE,t.THREE,t.Sky_js,t.THREE,t.THREE,t.THREE,t.THREE,t.THREE,t.THREE,t.THREE)}(this,function(t,e,n,i,r,s,o,a,c,l,h,d,u,p,f,g,m,y,b,_,v){"use strict";function x(t){var e=Object.create(null);return t&&Object.keys(t).forEach(function(n){if("default"!==n){var i=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,i.get?i:{enumerable:!0,get:function(){return t[n]}})}}),e.default=t,Object.freeze(e)}var w=x(n);function M(t,e){return t===e||t!=t&&e!=e}function S(t,e){for(var n=t.length;n--;)if(M(t[n][0],e))return n;return-1}var A=Array.prototype.splice;function E(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var i=t[e];this.set(i[0],i[1])}}E.prototype.clear=function(){this.__data__=[],this.size=0},E.prototype.delete=function(t){var e=this.__data__,n=S(e,t);return!(n<0)&&(n==e.length-1?e.pop():A.call(e,n,1),--this.size,!0)},E.prototype.get=function(t){var e=this.__data__,n=S(e,t);return n<0?void 0:e[n][1]},E.prototype.has=function(t){return S(this.__data__,t)>-1},E.prototype.set=function(t,e){var n=this.__data__,i=S(n,t);return i<0?(++this.size,n.push([t,e])):n[i][1]=e,this};var k="object"==typeof global&&global&&global.Object===Object&&global,C="object"==typeof self&&self&&self.Object===Object&&self,T=k||C||Function("return this")(),P=T.Symbol,D=Object.prototype,O=D.hasOwnProperty,z=D.toString,L=P?P.toStringTag:void 0;var I=Object.prototype.toString;var R=P?P.toStringTag:void 0;function j(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":R&&R in Object(t)?function(t){var e=O.call(t,L),n=t[L];try{t[L]=void 0;var i=!0}catch(t){}var r=z.call(t);return i&&(e?t[L]=n:delete t[L]),r}(t):function(t){return I.call(t)}(t)}function F(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function B(t){if(!F(t))return!1;var e=j(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e}var N,H=T["__core-js_shared__"],Y=(N=/[^.]+$/.exec(H&&H.keys&&H.keys.IE_PROTO||""))?"Symbol(src)_1."+N:"";var G=Function.prototype.toString;function V(t){if(null!=t){try{return G.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var U=/^\[object .+?Constructor\]$/,$=Function.prototype,W=Object.prototype,X=$.toString,q=W.hasOwnProperty,K=RegExp("^"+X.call(q).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Q(t){return!(!F(t)||(e=t,Y&&Y in e))&&(B(t)?K:U).test(V(t));var e}function Z(t,e){var n=function(t,e){return null==t?void 0:t[e]}(t,e);return Q(n)?n:void 0}var J=Z(T,"Map"),tt=Z(Object,"create");var et=Object.prototype.hasOwnProperty;var nt=Object.prototype.hasOwnProperty;function it(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var i=t[e];this.set(i[0],i[1])}}function rt(t,e){var n=t.__data__;return function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t}(e)?n["string"==typeof e?"string":"hash"]:n.map}function st(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var i=t[e];this.set(i[0],i[1])}}it.prototype.clear=function(){this.__data__=tt?tt(null):{},this.size=0},it.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},it.prototype.get=function(t){var e=this.__data__;if(tt){var n=e[t];return"__lodash_hash_undefined__"===n?void 0:n}return et.call(e,t)?e[t]:void 0},it.prototype.has=function(t){var e=this.__data__;return tt?void 0!==e[t]:nt.call(e,t)},it.prototype.set=function(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=tt&&void 0===e?"__lodash_hash_undefined__":e,this},st.prototype.clear=function(){this.size=0,this.__data__={hash:new it,map:new(J||E),string:new it}},st.prototype.delete=function(t){var e=rt(this,t).delete(t);return this.size-=e?1:0,e},st.prototype.get=function(t){return rt(this,t).get(t)},st.prototype.has=function(t){return rt(this,t).has(t)},st.prototype.set=function(t,e){var n=rt(this,t),i=n.size;return n.set(t,e),this.size+=n.size==i?0:1,this};function ot(t){var e=this.__data__=new E(t);this.size=e.size}ot.prototype.clear=function(){this.__data__=new E,this.size=0},ot.prototype.delete=function(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n},ot.prototype.get=function(t){return this.__data__.get(t)},ot.prototype.has=function(t){return this.__data__.has(t)},ot.prototype.set=function(t,e){var n=this.__data__;if(n instanceof E){var i=n.__data__;if(!J||i.length<199)return i.push([t,e]),this.size=++n.size,this;n=this.__data__=new st(i)}return n.set(t,e),this.size=n.size,this};function at(t){var e=-1,n=null==t?0:t.length;for(this.__data__=new st;++e<n;)this.add(t[e])}function ct(t,e){for(var n=-1,i=null==t?0:t.length;++n<i;)if(e(t[n],n,t))return!0;return!1}at.prototype.add=at.prototype.push=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this},at.prototype.has=function(t){return this.__data__.has(t)};function lt(t,e,n,i,r,s){var o=1&n,a=t.length,c=e.length;if(a!=c&&!(o&&c>a))return!1;var l=s.get(t),h=s.get(e);if(l&&h)return l==e&&h==t;var d=-1,u=!0,p=2&n?new at:void 0;for(s.set(t,e),s.set(e,t);++d<a;){var f=t[d],g=e[d];if(i)var m=o?i(g,f,d,e,t,s):i(f,g,d,t,e,s);if(void 0!==m){if(m)continue;u=!1;break}if(p){if(!ct(e,function(t,e){if(o=e,!p.has(o)&&(f===t||r(f,t,n,i,s)))return p.push(e);var o})){u=!1;break}}else if(f!==g&&!r(f,g,n,i,s)){u=!1;break}}return s.delete(t),s.delete(e),u}var ht=T.Uint8Array;function dt(t){var e=-1,n=Array(t.size);return t.forEach(function(t,i){n[++e]=[i,t]}),n}function ut(t){var e=-1,n=Array(t.size);return t.forEach(function(t){n[++e]=t}),n}var pt=P?P.prototype:void 0,ft=pt?pt.valueOf:void 0;function gt(t,e){for(var n=-1,i=e.length,r=t.length;++n<i;)t[r+n]=e[n];return t}var mt=Array.isArray;function yt(){return[]}var bt=Object.prototype.propertyIsEnumerable,_t=Object.getOwnPropertySymbols,vt=_t?function(t){return null==t?[]:(t=Object(t),function(t,e){for(var n=-1,i=null==t?0:t.length,r=0,s=[];++n<i;){var o=t[n];e(o,n,t)&&(s[r++]=o)}return s}(_t(t),function(e){return bt.call(t,e)}))}:yt;function xt(t){return null!=t&&"object"==typeof t}function wt(t){return xt(t)&&"[object Arguments]"==j(t)}var Mt=Object.prototype,St=Mt.hasOwnProperty,At=Mt.propertyIsEnumerable,Et=wt(function(){return arguments}())?wt:function(t){return xt(t)&&St.call(t,"callee")&&!At.call(t,"callee")};var kt="object"==typeof t&&t&&!t.nodeType&&t,Ct=kt&&"object"==typeof module&&module&&!module.nodeType&&module,Tt=Ct&&Ct.exports===kt?T.Buffer:void 0,Pt=(Tt?Tt.isBuffer:void 0)||function(){return!1},Dt=/^(?:0|[1-9]\d*)$/;function Ot(t,e){var n=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==n||"symbol"!=n&&Dt.test(t))&&t>-1&&t%1==0&&t<e}function zt(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}var Lt={};function It(t){return function(e){return t(e)}}Lt["[object Float32Array]"]=Lt["[object Float64Array]"]=Lt["[object Int8Array]"]=Lt["[object Int16Array]"]=Lt["[object Int32Array]"]=Lt["[object Uint8Array]"]=Lt["[object Uint8ClampedArray]"]=Lt["[object Uint16Array]"]=Lt["[object Uint32Array]"]=!0,Lt["[object Arguments]"]=Lt["[object Array]"]=Lt["[object ArrayBuffer]"]=Lt["[object Boolean]"]=Lt["[object DataView]"]=Lt["[object Date]"]=Lt["[object Error]"]=Lt["[object Function]"]=Lt["[object Map]"]=Lt["[object Number]"]=Lt["[object Object]"]=Lt["[object RegExp]"]=Lt["[object Set]"]=Lt["[object String]"]=Lt["[object WeakMap]"]=!1;var Rt="object"==typeof t&&t&&!t.nodeType&&t,jt=Rt&&"object"==typeof module&&module&&!module.nodeType&&module,Ft=jt&&jt.exports===Rt&&k.process,Bt=function(){try{var t=jt&&jt.require&&jt.require("util").types;return t||Ft&&Ft.binding&&Ft.binding("util")}catch(t){}}(),Nt=Bt&&Bt.isTypedArray,Ht=Nt?It(Nt):function(t){return xt(t)&&zt(t.length)&&!!Lt[j(t)]},Yt=Object.prototype.hasOwnProperty;function Gt(t,e){var n=mt(t),i=!n&&Et(t),r=!n&&!i&&Pt(t),s=!n&&!i&&!r&&Ht(t),o=n||i||r||s,a=o?function(t,e){for(var n=-1,i=Array(t);++n<t;)i[n]=e(n);return i}(t.length,String):[],c=a.length;for(var l in t)!e&&!Yt.call(t,l)||o&&("length"==l||r&&("offset"==l||"parent"==l)||s&&("buffer"==l||"byteLength"==l||"byteOffset"==l)||Ot(l,c))||a.push(l);return a}var Vt=Object.prototype;function Ut(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||Vt)}function $t(t,e){return function(n){return t(e(n))}}var Wt=$t(Object.keys,Object),Xt=Object.prototype.hasOwnProperty;function qt(t){if(!Ut(t))return Wt(t);var e=[];for(var n in Object(t))Xt.call(t,n)&&"constructor"!=n&&e.push(n);return e}function Kt(t){return null!=t&&zt(t.length)&&!B(t)}function Qt(t){return Kt(t)?Gt(t):qt(t)}function Zt(t){return function(t,e,n){var i=e(t);return mt(t)?i:gt(i,n(t))}(t,Qt,vt)}var Jt=Object.prototype.hasOwnProperty;var te=Z(T,"DataView"),ee=Z(T,"Promise"),ne=Z(T,"Set"),ie=Z(T,"WeakMap"),re="[object Map]",se="[object Promise]",oe="[object Set]",ae="[object WeakMap]",ce="[object DataView]",le=V(te),he=V(J),de=V(ee),ue=V(ne),pe=V(ie),fe=j;(te&&fe(new te(new ArrayBuffer(1)))!=ce||J&&fe(new J)!=re||ee&&fe(ee.resolve())!=se||ne&&fe(new ne)!=oe||ie&&fe(new ie)!=ae)&&(fe=function(t){var e=j(t),n="[object Object]"==e?t.constructor:void 0,i=n?V(n):"";if(i)switch(i){case le:return ce;case he:return re;case de:return se;case ue:return oe;case pe:return ae}return e});var ge="[object Arguments]",me="[object Array]",ye="[object Object]",be=Object.prototype.hasOwnProperty;function _e(t,e,n,i,r,s){var o=mt(t),a=mt(e),c=o?me:fe(t),l=a?me:fe(e),h=(c=c==ge?ye:c)==ye,d=(l=l==ge?ye:l)==ye,u=c==l;if(u&&Pt(t)){if(!Pt(e))return!1;o=!0,h=!1}if(u&&!h)return s||(s=new ot),o||Ht(t)?lt(t,e,n,i,r,s):function(t,e,n,i,r,s,o){switch(n){case"[object DataView]":if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case"[object ArrayBuffer]":return!(t.byteLength!=e.byteLength||!s(new ht(t),new ht(e)));case"[object Boolean]":case"[object Date]":case"[object Number]":return M(+t,+e);case"[object Error]":return t.name==e.name&&t.message==e.message;case"[object RegExp]":case"[object String]":return t==e+"";case"[object Map]":var a=dt;case"[object Set]":var c=1&i;if(a||(a=ut),t.size!=e.size&&!c)return!1;var l=o.get(t);if(l)return l==e;i|=2,o.set(t,e);var h=lt(a(t),a(e),i,r,s,o);return o.delete(t),h;case"[object Symbol]":if(ft)return ft.call(t)==ft.call(e)}return!1}(t,e,c,n,i,r,s);if(!(1&n)){var p=h&&be.call(t,"__wrapped__"),f=d&&be.call(e,"__wrapped__");if(p||f){var g=p?t.value():t,m=f?e.value():e;return s||(s=new ot),r(g,m,n,i,s)}}return!!u&&(s||(s=new ot),function(t,e,n,i,r,s){var o=1&n,a=Zt(t),c=a.length;if(c!=Zt(e).length&&!o)return!1;for(var l=c;l--;){var h=a[l];if(!(o?h in e:Jt.call(e,h)))return!1}var d=s.get(t),u=s.get(e);if(d&&u)return d==e&&u==t;var p=!0;s.set(t,e),s.set(e,t);for(var f=o;++l<c;){var g=t[h=a[l]],m=e[h];if(i)var y=o?i(m,g,h,e,t,s):i(g,m,h,t,e,s);if(!(void 0===y?g===m||r(g,m,n,i,s):y)){p=!1;break}f||(f="constructor"==h)}if(p&&!f){var b=t.constructor,_=e.constructor;b==_||!("constructor"in t)||!("constructor"in e)||"function"==typeof b&&b instanceof b&&"function"==typeof _&&_ instanceof _||(p=!1)}return s.delete(t),s.delete(e),p}(t,e,n,i,r,s))}function ve(t,e,n,i,r){return t===e||(null==t||null==e||!xt(t)&&!xt(e)?t!=t&&e!=e:_e(t,e,n,i,ve,r))}function xe(t,e){for(var n=-1,i=null==t?0:t.length;++n<i&&!1!==e(t[n],n,t););return t}var we=function(){try{var t=Z(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();function Me(t,e,n){"__proto__"==e&&we?we(t,e,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[e]=n}var Se=Object.prototype.hasOwnProperty;function Ae(t,e,n){var i=t[e];Se.call(t,e)&&M(i,n)&&(void 0!==n||e in t)||Me(t,e,n)}function Ee(t,e,n,i){var r=!n;n||(n={});for(var s=-1,o=e.length;++s<o;){var a=e[s],c=i?i(n[a],t[a],a,n,t):void 0;void 0===c&&(c=t[a]),r?Me(n,a,c):Ae(n,a,c)}return n}function ke(t){return t}function Ce(t,e,n){switch(n.length){case 0:return t.call(e);case 1:return t.call(e,n[0]);case 2:return t.call(e,n[0],n[1]);case 3:return t.call(e,n[0],n[1],n[2])}return t.apply(e,n)}var Te=Math.max;function Pe(t){return function(){return t}}var De=we?function(t,e){return we(t,"toString",{configurable:!0,enumerable:!1,value:Pe(e),writable:!0})}:ke,Oe=Date.now;var ze=function(t){var e=0,n=0;return function(){var i=Oe(),r=16-(i-n);if(n=i,r>0){if(++e>=800)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(De);function Le(t,e){return ze(function(t,e,n){return e=Te(void 0===e?t.length-1:e,0),function(){for(var i=arguments,r=-1,s=Te(i.length-e,0),o=Array(s);++r<s;)o[r]=i[e+r];r=-1;for(var a=Array(e+1);++r<e;)a[r]=i[r];return a[e]=n(o),Ce(t,this,a)}}(t,e,ke),t+"")}function Ie(t,e,n){if(!F(n))return!1;var i=typeof e;return!!("number"==i?Kt(n)&&Ot(e,n.length):"string"==i&&e in n)&&M(n[e],t)}var Re,je=(Re=function(t,e,n,i){Ee(e,Qt(e),t,i)},Le(function(t,e){var n=-1,i=e.length,r=i>1?e[i-1]:void 0,s=i>2?e[2]:void 0;for(r=Re.length>3&&"function"==typeof r?(i--,r):void 0,s&&Ie(e[0],e[1],s)&&(r=i<3?void 0:r,i=1),t=Object(t);++n<i;){var o=e[n];o&&Re(t,o,n,r)}return t})),Fe=$t(Object.getPrototypeOf,Object),Be=Function.prototype,Ne=Object.prototype,He=Be.toString,Ye=Ne.hasOwnProperty,Ge=He.call(Object);function Ve(t){if(!xt(t))return!1;var e=j(t);return"[object Error]"==e||"[object DOMException]"==e||"string"==typeof t.message&&"string"==typeof t.name&&!function(t){if(!xt(t)||"[object Object]"!=j(t))return!1;var e=Fe(t);if(null===e)return!0;var n=Ye.call(e,"constructor")&&e.constructor;return"function"==typeof n&&n instanceof n&&He.call(n)==Ge}(t)}var Ue=Le(function(t,e){try{return Ce(t,void 0,e)}catch(t){return Ve(t)?t:new Error(t)}});function $e(t,e){for(var n=-1,i=null==t?0:t.length,r=Array(i);++n<i;)r[n]=e(t[n],n,t);return r}var We=Object.prototype,Xe=We.hasOwnProperty;function qe(t,e,n,i){return void 0===t||M(t,We[n])&&!Xe.call(i,n)?e:t}var Ke={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"};function Qe(t){return"\\"+Ke[t]}var Ze=/<%=([\s\S]+?)%>/g;var Je,tn=(Je={"&":"&","<":"<",">":">",'"':""","'":"'"},function(t){return null==Je?void 0:Je[t]});function en(t){return"symbol"==typeof t||xt(t)&&"[object Symbol]"==j(t)}var nn=P?P.prototype:void 0,rn=nn?nn.toString:void 0;function sn(t){if("string"==typeof t)return t;if(mt(t))return $e(t,sn)+"";if(en(t))return rn?rn.call(t):"";var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}function on(t){return null==t?"":sn(t)}var an=/[&<>"']/g,cn=RegExp(an.source);var ln={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:Ze,variable:"",imports:{_:{escape:function(t){return(t=on(t))&&cn.test(t)?t.replace(an,tn):t}}}},hn=/\b__p \+= '';/g,dn=/\b(__p \+=) '' \+/g,un=/(__e\(.*?\)|\b__t\)) \+\n'';/g,pn=/[()=,{}\[\]\/\s]/,fn=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,gn=/($^)/,mn=/['\n\r\u2028\u2029\\]/g,yn=Object.prototype.hasOwnProperty;var bn=Object.prototype.hasOwnProperty;function _n(t){if(!F(t))return function(t){var e=[];if(null!=t)for(var n in Object(t))e.push(n);return e}(t);var e=Ut(t),n=[];for(var i in t)("constructor"!=i||!e&&bn.call(t,i))&&n.push(i);return n}function vn(t,e){return t&&Ee(e,function(t){return Kt(t)?Gt(t,!0):_n(t)}(e),t)}var xn="object"==typeof t&&t&&!t.nodeType&&t,wn=xn&&"object"==typeof module&&module&&!module.nodeType&&module,Mn=wn&&wn.exports===xn?T.Buffer:void 0,Sn=Mn?Mn.allocUnsafe:void 0;var An=Object.getOwnPropertySymbols?function(t){for(var e=[];t;)gt(e,vt(t)),t=Fe(t);return e}:yt;var En=Object.prototype.hasOwnProperty;var kn=/\w*$/;var Cn=P?P.prototype:void 0,Tn=Cn?Cn.valueOf:void 0;function Pn(t,e,n){var i,r,s,o,a,c=t.constructor;switch(e){case"[object ArrayBuffer]":return a=new(o=t).constructor(o.byteLength),new ht(a).set(new ht(o)),a;case"[object Boolean]":case"[object Date]":return new c(+t);case"[object DataView]":return s=(r=t).buffer,new r.constructor(s,r.byteOffset,r.byteLength);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return function(t){var e=t.buffer;return new t.constructor(e,t.byteOffset,t.length)}(t);case"[object Map]":case"[object Set]":return new c;case"[object Number]":case"[object String]":return new c(t);case"[object RegExp]":return function(t){var e=new t.constructor(t.source,kn.exec(t));return e.lastIndex=t.lastIndex,e}(t);case"[object Symbol]":return i=t,Tn?Object(Tn.call(i)):{}}}var Dn=Object.create,On=function(){function t(){}return function(e){if(!F(e))return{};if(Dn)return Dn(e);t.prototype=e;var n=new t;return t.prototype=void 0,n}}();var zn=Bt&&Bt.isMap,Ln=zn?It(zn):function(t){return xt(t)&&"[object Map]"==fe(t)};var In=Bt&&Bt.isSet,Rn=In?It(In):function(t){return xt(t)&&"[object Set]"==fe(t)},jn="[object Arguments]",Fn="[object Function]",Bn="[object Object]",Nn={};function Hn(t,e,n,i,r,s){var o,a=2&e;if(void 0!==o)return o;if(!F(t))return t;var c=mt(t);if(c)return o=function(t){var e=t.length,n=new t.constructor(e);return e&&"string"==typeof t[0]&&En.call(t,"index")&&(n.index=t.index,n.input=t.input),n}(t),function(t,e){var n=-1,i=t.length;for(e||(e=Array(i));++n<i;)e[n]=t[n];return e}(t,o);var l=fe(t),h=l==Fn||"[object GeneratorFunction]"==l;if(Pt(t))return function(t){var e=t.length,n=Sn?Sn(e):new t.constructor(e);return t.copy(n),n}(t);if(l==Bn||l==jn||h&&!r)return o=h?{}:function(t){return"function"!=typeof t.constructor||Ut(t)?{}:On(Fe(t))}(t),a?function(t,e){return Ee(t,An(t),e)}(t,vn(o,t)):function(t,e){return Ee(t,vt(t),e)}(t,function(t,e){return t&&Ee(e,Qt(e),t)}(o,t));if(!Nn[l])return r?t:{};o=Pn(t,l),s||(s=new ot);var d=s.get(t);if(d)return d;s.set(t,o),Rn(t)?t.forEach(function(i){o.add(Hn(i,e,n,i,t,s))}):Ln(t)&&t.forEach(function(i,r){o.set(r,Hn(i,e,n,r,t,s))});var u=c?void 0:Zt(t);return xe(u||t,function(i,r){u&&(i=t[r=i]),Ae(o,r,Hn(i,e,n,r,t,s))}),o}Nn[jn]=Nn["[object Array]"]=Nn["[object ArrayBuffer]"]=Nn["[object DataView]"]=Nn["[object Boolean]"]=Nn["[object Date]"]=Nn["[object Float32Array]"]=Nn["[object Float64Array]"]=Nn["[object Int8Array]"]=Nn["[object Int16Array]"]=Nn["[object Int32Array]"]=Nn["[object Map]"]=Nn["[object Number]"]=Nn[Bn]=Nn["[object RegExp]"]=Nn["[object Set]"]=Nn["[object String]"]=Nn["[object Symbol]"]=Nn["[object Uint8Array]"]=Nn["[object Uint8ClampedArray]"]=Nn["[object Uint16Array]"]=Nn["[object Uint32Array]"]=!0,Nn["[object Error]"]=Nn[Fn]=Nn["[object WeakMap]"]=!1;function Yn(t){return Hn(t,4)}var Gn=function(){return T.Date.now()},Vn=/\s/;var Un=/^\s+/;function $n(t){return t?t.slice(0,function(t){for(var e=t.length;e--&&Vn.test(t.charAt(e)););return e}(t)+1).replace(Un,""):t}var Wn=/^[-+]0x[0-9a-f]+$/i,Xn=/^0b[01]+$/i,qn=/^0o[0-7]+$/i,Kn=parseInt;function Qn(t){if("number"==typeof t)return t;if(en(t))return NaN;if(F(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=F(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=$n(t);var n=Xn.test(t);return n||qn.test(t)?Kn(t.slice(2),n?2:8):Wn.test(t)?NaN:+t}var Zn=Math.max,Jn=Math.min;function ti(t,e,n){var i,r,s,o,a,c,l=0,h=!1,d=!1,u=!0;if("function"!=typeof t)throw new TypeError("Expected a function");function p(e){var n=i,s=r;return i=r=void 0,l=e,o=t.apply(s,n)}function f(t){var n=t-c;return void 0===c||n>=e||n<0||d&&t-l>=s}function g(){var t=Gn();if(f(t))return m(t);a=setTimeout(g,function(t){var n=e-(t-c);return d?Jn(n,s-(t-l)):n}(t))}function m(t){return a=void 0,u&&i?p(t):(i=r=void 0,o)}function y(){var t=Gn(),n=f(t);if(i=arguments,r=this,c=t,n){if(void 0===a)return function(t){return l=t,a=setTimeout(g,e),h?p(t):o}(c);if(d)return clearTimeout(a),a=setTimeout(g,e),p(c)}return void 0===a&&(a=setTimeout(g,e)),o}return e=Qn(e)||0,F(n)&&(h=!!n.leading,s=(d="maxWait"in n)?Zn(Qn(n.maxWait)||0,e):s,u="trailing"in n?!!n.trailing:u),y.cancel=function(){void 0!==a&&clearTimeout(a),l=0,i=c=r=a=void 0},y.flush=function(){return void 0===a?o:m(Gn())},y}var ei=1/0;function ni(t){var e=function(t){return t?(t=Qn(t))===ei||t===-1/0?17976931348623157e292*(t<0?-1:1):t==t?t:0:0===t?t:0}(t),n=e%1;return e==e?n?e-n:e:0}function ii(t){return function(t,e){var n;if("function"!=typeof e)throw new TypeError("Expected a function");return t=ni(t),function(){return--t>0&&(n=e.apply(this,arguments)),t<=1&&(e=void 0),n}}(2,t)}var ri=Object.prototype.hasOwnProperty;function si(t){if(null==t)return!0;if(Kt(t)&&(mt(t)||"string"==typeof t||"function"==typeof t.splice||Pt(t)||Ht(t)||Et(t)))return!t.length;var e=fe(t);if("[object Map]"==e||"[object Set]"==e)return!t.size;if(Ut(t))return!qt(t).length;for(var n in t)if(ri.call(t,n))return!1;return!0}let oi=0;function ai(t={},...e){return"object"!=typeof t&&(t={}),e.forEach(e=>{for(const n in e)"object"!=typeof e[n]?t[n]=e[n]:e[n].length>0?t[n]=e[n].map(t=>{let i;return i="object"!=typeof e[n]?t:ai({},t),i}):t[n]=ai(t[n],e[n])}),t}function ci(t){for(;t&&"object"==typeof t;){const e=t;for(const e in t){t=t[e];break}if(t===e){t=void 0;break}}return t}function li(t,e){if(!this.__collection__)return this;return-1==this.__collection__.indexOf(e)&&this.__collection__.splice(t,0,e),this}function hi(t){return this.__collection__||(this.__collection__=[]),-1==this.__collection__.indexOf(t)&&this.__collection__.push(t),this}function di(t){return this.__collection__||(this.__collection__=[]),-1==this.__collection__.indexOf(t)&&this.__collection__.unshift(t),this}function ui(t){if(!this.__collection__)return this;const e=this.__collection__.indexOf(t);return e>=0&&this.__collection__.splice(e,1),this}function pi(t){if(this.__collection__)return this.__collection__[t]}function fi(t,e){this.__collection__&&this.__collection__.forEach(t,e)}function gi(t){return this.__collection__?this.__collection__.indexOf(t):-1}function mi(){return this.__collection__?this.__collection__.length:0}function yi(){this.__collection__=[]}function bi(t){const e=this.indexOf(t);-1!=e&&0!=e&&(this.__collection__[e]=this.__collection__[e-1],this.__collection__[e-1]=t)}function _i(t){const e=this.indexOf(t);-1!=e&&e!=this.size()-1&&(this.__collection__[e]=this.__collection__[e+1],this.__collection__[e+1]=t)}function vi(t){const e=this.indexOf(t);if(-1==e||0==e)return;const n=this.__collection__.splice(0,e),i=this.__collection__.splice(1);this.__collection__=this.__collection__.concat(n,i)}function xi(t){const e=this.indexOf(t);if(-1==e||e==this.size()-1)return;const n=this.__collection__.splice(0,e),i=this.__collection__.splice(1);this.__collection__=n.concat(i,this.__collection__)}class wi{constructor(){this.__collection__=[],this.insertAt=li,this.append=hi,this.prepend=di,this.remove=ui,this.getAt=pi,this.forEach=fi,this.indexOf=gi,this.size=mi,this.clear=yi,this.moveForward=bi,this.moveBackward=_i,this.moveToHead=vi,this.moveToTail=xi}}const Mi=new class{constructor(){this.drawCount=0,this.drawTimeSum=0,this.drawTimeLast=0,this.invalidateCount=0,this.triggerCount=0,this.cacheHit=0,this.cacheMiss=0,this._lastSnapshotTime=0,this._frameCount=0,this._getResidents=null}registerResidents(t){this._getResidents=t}countFrame(){this._frameCount++}snapshot(){const t=performance.now(),e=this.drawCount,n=this.cacheHit+this.cacheMiss,i=this._getResidents?.()??null;let r=0;if(this._lastSnapshotTime>0){const e=t-this._lastSnapshotTime;e>0&&(r=Math.round(1e3*this._frameCount/e))}this._lastSnapshotTime=t,this._frameCount=0;const s={fps:r,drawCount:e,drawTimeAvg:e>0?Math.round(this.drawTimeSum/e*100)/100:0,drawTimeLast:Math.round(100*this.drawTimeLast)/100,invalidateCount:this.invalidateCount,triggerCount:this.triggerCount,cacheHitRate:n>0?Math.round(this.cacheHit/n*1e3)/10:0,...i??{}};return this.drawCount=0,this.drawTimeSum=0,this.invalidateCount=0,this.triggerCount=0,this.cacheHit=0,this.cacheMiss=0,s}},Si=/\s+/;function Ai(t,e,n,i){if(!n)return!0;if("object"==typeof n){for(const i in n){const r=n[i];t[e].apply(t,[i,r])}return!1}if(Si.test(n)){return n.split(Si).forEach(n=>t[e].apply(t,[n].concat(i))),!1}return!0}const Ei=["on","off","once","delegate_on","delegate_off","trigger","listenTo"],ki={withEvent(){Ei.forEach(t=>this[t]=ki[t])},on(t,e,n){if(!Ai(this,"on",t,[e,n])||!e)return this;this._listeners||(this._listeners={});return(this._listeners[t]||(this._listeners[t]=[])).push({callback:e,context:n,ctx:n||this}),this},once(t,e,n){if(!Ai(this,"once",t,[e,n])||!e)return this;const i=this,r=ii(function(){i.off(t,r,n),e.apply(i,arguments)});return r._callback=e,this.on(t,r,n),this},off(t,e,n){if(!this._listeners||!Ai(this,"off",t,[e,n]))return this;if(!t&&!e&&!n)return this._listeners=void 0,this;let i;i=t&&"string"==typeof t?[t]:Object.keys(this._listeners||{});for(let t=0;t<i.length;t++){const r=i[t],s=this._listeners?.[r];if(s){const t=[];if(this._listeners[r]=t,e||n)for(let i=0;i<s.length;i++){const r=s[i];(e&&e!==r.callback&&e!==r.callback._callback||n&&n!==r.context)&&t.push(r)}t.length||delete this._listeners[r]}}return this},delegate_on(t){return this._delegators||(this._delegators=new wi),this._delegators.append(t),this},delegate_off(t){return this._delegators?(this._delegators.remove(t),this):this},delegate(){if(this._delegators&&this._delegators.size()>0&&Ti(this._delegators,arguments),!this._listeners)return this;const t=arguments.length-1,e=arguments[t];arguments[t]={origin:e.origin,name:e.name,deliverer:this};const n=this._listeners[e.name],i=this._listeners["(all)"];return n&&Ci(n,arguments),i&&Ci(i,arguments),this},trigger(t){Mi.triggerCount++;const e=[].slice.call(arguments,1);if(e.push({origin:this,name:t,deliverer:this}),this._delegators&&this._delegators.size()>0&&Ti(this._delegators,e),!this._listeners)return this;if(!Ai(this,"trigger",t,e))return this;const n=this._listeners[t],i=this._listeners["(all)"];return n&&Ci(n,e),i&&Ci(i,e),this},stopListening(t,e,n){let i=this._listeningTo;if(!i)return this;const r=!e&&!n;n||"object"!=typeof e||(n=this),t&&(i={},i[t._listenId]=t);for(const t in i){const s=i[t];s.off(e,n,this),(r||si(s._events))&&delete this._listeningTo[t]}return this}};function Ci(t,e){t.forEach(t=>t.callback.apply(t.ctx,e))}function Ti(t,e){t.forEach(t=>ki.delegate.apply(t,e))}const Pi={listenTo:"on",listenToOnce:"once"};for(const t in Pi){const e=Pi[t];ki[t]=function(t,n,i){this._listeningTo||(this._listeningTo={});const r=this._listeningTo;t._listenId||(t._listenId=`${"l"}${++oi}`);return r[t._listenId]=t,i||"object"!=typeof n||(i=this),t[e](n,i,this),this}}const Di=ki.on,Oi=ki.off,zi=ki.once,Li=ki.trigger,Ii=ki.delegate_on,Ri=ki.delegate_off;function ji(t,e){if(e instanceof Array)e.forEach(e=>ji(t,e));else{if(t.mixedIn=t.hasOwnProperty("mixedIn")?t.mixedIn:[],t.mixingIn=t.hasOwnProperty("mixingIn")?t.mixingIn:[],t.mixedIn.indexOf(e)>=0)return t;if(t.mixingIn.indexOf(e)>=0)throw new Error(`found cyclic dependencies between ${t.mixingIn}`);t.mixingIn.push(e),e.call(t),t.mixingIn.pop(),t.mixedIn.push(e)}return t}const Fi=(...t)=>{const e=[];t.forEach(t=>t&&t.stack&&e.push(t.stack)),console.error("[ERROR]",...t,e.join(" "))},Bi=(...t)=>{const e=[];t.forEach(t=>t&&t.stack&&e.push(t.stack)),console.warn("[WARN]",...t,e.join(" "))},Ni=(...t)=>console.log("[DEBUG]",...t);function Hi(t,e,n){const i=function(t,e){let n=t;for(;n;){const t=Object.getOwnPropertyDescriptor(n,e);if(t?.get)return t;n=Object.getPrototypeOf(n)}}(t,e);if(!i?.get)return void Fi(`${String(e)} is not defined in ${t.constructor.name}`);const r=i.get,s={get:n?function(){return e in this.__cache__?Mi.cacheHit++:(Mi.cacheMiss++,this.__cache__[e]=Object.freeze(r.call(this))),this.__cache__[e]}:function(){return e in this.__cache__?Mi.cacheHit++:(Mi.cacheMiss++,this.__cache__[e]=r.call(this)),this.__cache__[e]},configurable:!0};i.set&&(s.set=i.set),Object.defineProperty(t,e,s)}var Yi="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Gi(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function Vi(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Ui,$i={exports:{}};var Wi=(Ui||(Ui=1,function(t){var e=function(t){var e,n=Object.prototype,i=n.hasOwnProperty,r=Object.defineProperty||function(t,e,n){t[e]=n.value},s="function"==typeof Symbol?Symbol:{},o=s.iterator||"@@iterator",a=s.asyncIterator||"@@asyncIterator",c=s.toStringTag||"@@toStringTag";function l(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{l({},"")}catch(t){l=function(t,e,n){return t[e]=n}}function h(t,e,n,i){var s=e&&e.prototype instanceof y?e:y,o=Object.create(s.prototype),a=new P(i||[]);return r(o,"_invoke",{value:E(t,n,a)}),o}function d(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}t.wrap=h;var u="suspendedStart",p="suspendedYield",f="executing",g="completed",m={};function y(){}function b(){}function _(){}var v={};l(v,o,function(){return this});var x=Object.getPrototypeOf,w=x&&x(x(D([])));w&&w!==n&&i.call(w,o)&&(v=w);var M=_.prototype=y.prototype=Object.create(v);function S(t){["next","throw","return"].forEach(function(e){l(t,e,function(t){return this._invoke(e,t)})})}function A(t,e){function n(r,s,o,a){var c=d(t[r],t,s);if("throw"!==c.type){var l=c.arg,h=l.value;return h&&"object"==typeof h&&i.call(h,"__await")?e.resolve(h.__await).then(function(t){n("next",t,o,a)},function(t){n("throw",t,o,a)}):e.resolve(h).then(function(t){l.value=t,o(l)},function(t){return n("throw",t,o,a)})}a(c.arg)}var s;r(this,"_invoke",{value:function(t,i){function r(){return new e(function(e,r){n(t,i,e,r)})}return s=s?s.then(r,r):r()}})}function E(t,n,i){var r=u;return function(s,o){if(r===f)throw new Error("Generator is already running");if(r===g){if("throw"===s)throw o;return{value:e,done:!0}}for(i.method=s,i.arg=o;;){var a=i.delegate;if(a){var c=k(a,i);if(c){if(c===m)continue;return c}}if("next"===i.method)i.sent=i._sent=i.arg;else if("throw"===i.method){if(r===u)throw r=g,i.arg;i.dispatchException(i.arg)}else"return"===i.method&&i.abrupt("return",i.arg);r=f;var l=d(t,n,i);if("normal"===l.type){if(r=i.done?g:p,l.arg===m)continue;return{value:l.arg,done:i.done}}"throw"===l.type&&(r=g,i.method="throw",i.arg=l.arg)}}}function k(t,n){var i=n.method,r=t.iterator[i];if(r===e)return n.delegate=null,"throw"===i&&t.iterator.return&&(n.method="return",n.arg=e,k(t,n),"throw"===n.method)||"return"!==i&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+i+"' method")),m;var s=d(r,t.iterator,n.arg);if("throw"===s.type)return n.method="throw",n.arg=s.arg,n.delegate=null,m;var o=s.arg;return o?o.done?(n[t.resultName]=o.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,m):o:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,m)}function C(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 T(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function P(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(C,this),this.reset(!0)}function D(t){if(null!=t){var n=t[o];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,s=function n(){for(;++r<t.length;)if(i.call(t,r))return n.value=t[r],n.done=!1,n;return n.value=e,n.done=!0,n};return s.next=s}}throw new TypeError(typeof t+" is not iterable")}return b.prototype=_,r(M,"constructor",{value:_,configurable:!0}),r(_,"constructor",{value:b,configurable:!0}),b.displayName=l(_,c,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===b||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,_):(t.__proto__=_,l(t,c,"GeneratorFunction")),t.prototype=Object.create(M),t},t.awrap=function(t){return{__await:t}},S(A.prototype),l(A.prototype,a,function(){return this}),t.AsyncIterator=A,t.async=function(e,n,i,r,s){void 0===s&&(s=Promise);var o=new A(h(e,n,i,r),s);return t.isGeneratorFunction(n)?o:o.next().then(function(t){return t.done?t.value:o.next()})},S(M),l(M,c,"Generator"),l(M,o,function(){return this}),l(M,"toString",function(){return"[object Generator]"}),t.keys=function(t){var e=Object(t),n=[];for(var i in e)n.push(i);return n.reverse(),function t(){for(;n.length;){var i=n.pop();if(i in e)return t.value=i,t.done=!1,t}return t.done=!0,t}},t.values=D,P.prototype={constructor:P,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(T),!t)for(var n in this)"t"===n.charAt(0)&&i.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function r(i,r){return a.type="throw",a.arg=t,n.next=i,r&&(n.method="next",n.arg=e),!!r}for(var s=this.tryEntries.length-1;s>=0;--s){var o=this.tryEntries[s],a=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var c=i.call(o,"catchLoc"),l=i.call(o,"finallyLoc");if(c&&l){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!l)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&i.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var s=r;break}}s&&("break"===t||"continue"===t)&&s.tryLoc<=e&&e<=s.finallyLoc&&(s=null);var o=s?s.completion:{};return o.type=t,o.arg=e,s?(this.method="next",this.next=s.finallyLoc,m):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),m},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),T(n),m}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var i=n.completion;if("throw"===i.type){var r=i.arg;T(n)}return r}}throw new Error("illegal catch attempt")},delegateYield:function(t,n,i){return this.delegate={iterator:D(t),resultName:n,nextLoc:i},"next"===this.method&&(this.arg=e),m}},t}(t.exports);try{regeneratorRuntime=e}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=e:Function("r","regeneratorRuntime = r")(e)}Number.isInteger=Number.isInteger||function(t){return"number"==typeof t&&isFinite(t)&&Math.floor(t)===t},String.fromCodePoint||function(t){var e=function(e){for(var n=[],i=0,r="",s=0,o=arguments.length;s!==o;++s){var a=+arguments[s];if(!(a<1114111&&a>>>0===a))throw RangeError("Invalid code point: "+a);a<=65535?i=n.push(a):(a-=65536,i=n.push(55296+(a>>10),a%1024+56320)),i>=16383&&(r+=t.apply(null,n),n.length=0)}return r+t.apply(null,n)};try{Object.defineProperty(String,"fromCodePoint",{value:e,configurable:!0,writable:!0})}catch(t){String.fromCodePoint=e}}(String.fromCharCode),Object.is||(Object.is=function(t,e){return t===e?0!==t||1/t==1/e:t!=t&&e!=e})
|
|
2
|
+
/*! https://mths.be/codepointat v0.2.0 by @mathias */,String.prototype.codePointAt||function(){var t=function(){try{var t={},e=Object.defineProperty,n=e(t,t,t)&&e}catch(t){}return n}(),e=function(t){if(null==this)throw TypeError();var e=String(this),n=e.length,i=t?Number(t):0;if(i!=i&&(i=0),!(i<0||i>=n)){var r,s=e.charCodeAt(i);return s>=55296&&s<=56319&&n>i+1&&(r=e.charCodeAt(i+1))>=56320&&r<=57343?1024*(s-55296)+r-56320+65536:s}};t?t(String.prototype,"codePointAt",{value:e,configurable:!0,writable:!0}):String.prototype.codePointAt=e}(),Math.log10=Math.log10||function(t){return Math.log(t)*Math.LOG10E},t.exports=function(){function t(e,n,i){function r(o,a){if(!n[o]){if(!e[o]){if(!a&&Vi)return Vi(o);if(s)return s(o,!0);var c=new Error("Cannot find module '"+o+"'");throw c.code="MODULE_NOT_FOUND",c}var l=n[o]={exports:{}};e[o][0].call(l.exports,function(t){return r(e[o][1][t]||t)},l,l.exports,t,e,n,i)}return n[o].exports}for(var s=Vi,o=0;o<i.length;o++)r(i[o]);return r}return t}()({1:[function(t,e,n){var i=t("./utils"),r=function(){var t=i.stringToArray,e=["Zero","One","Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten","Eleven","Twelve","Thirteen","Fourteen","Fifteen","Sixteen","Seventeen","Eighteen","Nineteen"],n=["Zeroth","First","Second","Third","Fourth","Fifth","Sixth","Seventh","Eighth","Ninth","Tenth","Eleventh","Twelfth","Thirteenth","Fourteenth","Fifteenth","Sixteenth","Seventeenth","Eighteenth","Nineteenth"],r=["Twenty","Thirty","Forty","Fifty","Sixty","Seventy","Eighty","Ninety","Hundred"],s=["Thousand","Million","Billion","Trillion"];function o(t,i){var o=function t(i,o,a){var c="";if(i<=19)c=(o?" and ":"")+(a?n[i]:e[i]);else if(i<100){var l=Math.floor(i/10),h=i%10;c=(o?" and ":"")+r[l-2],h>0?c+="-"+t(h,!1,a):a&&(c=c.substring(0,c.length-1)+"ieth")}else if(i<1e3){var d=Math.floor(i/100),u=i%100;c=(o?", ":"")+e[d]+" Hundred",u>0?c+=t(u,!0,a):a&&(c+="th")}else{var p=Math.floor(Math.log10(i)/3);p>s.length&&(p=s.length);var f=Math.pow(10,3*p),g=Math.floor(i/f),m=i-g*f;c=(o?", ":"")+t(g,!1,!1)+" "+s[p-1],m>0?c+=t(m,!0,a):a&&(c+="th")}return c};return o(t,!1,i)}var a={};function c(t){var e=t.split(/,\s|\sand\s|[\s\\-]/).map(function(t){return a[t]}),n=[0];e.forEach(function(t){if(t<100){var e=n.pop();e>=1e3&&(n.push(e),e=0),n.push(e+t)}else n.push(n.pop()*t)});var i=n.reduce(function(t,e){return t+e},0);return i}e.forEach(function(t,e){a[t.toLowerCase()]=e}),n.forEach(function(t,e){a[t.toLowerCase()]=e}),r.forEach(function(t,e){var n=t.toLowerCase();a[n]=10*(e+2),a[n.substring(0,t.length-1)+"ieth"]=a[n]}),a.hundredth=100,s.forEach(function(t,e){var n=t.toLowerCase(),i=Math.pow(10,3*(e+1));a[n]=i,a[n+"th"]=i});var l=[[1e3,"m"],[900,"cm"],[500,"d"],[400,"cd"],[100,"c"],[90,"xc"],[50,"l"],[40,"xl"],[10,"x"],[9,"ix"],[5,"v"],[4,"iv"],[1,"i"]],h={M:1e3,D:500,C:100,L:50,X:10,V:5,I:1};function d(t){for(var e=0;e<l.length;e++){var n=l[e];if(t>=n[0])return n[1]+d(t-n[0])}return""}function u(t){for(var e=0,n=1,i=t.length-1;i>=0;i--){var r=t[i],s=h[r];s<n?e-=s:(n=s,e+=s)}return e}function p(t,e){for(var n=[],i=e.charCodeAt(0);t>0;)n.unshift(String.fromCharCode((t-1)%26+i)),t=Math.floor((t-1)/26);return n.join("")}function f(t,e){for(var n=e.charCodeAt(0),i=0,r=0;r<t.length;r++)i+=(t.charCodeAt(t.length-r-1)-n+1)*Math.pow(26,r);return i}function g(t,e){if(void 0!==t)return b(t=Math.floor(t),v(e))}var m={DECIMAL:"decimal",LETTERS:"letters",ROMAN:"roman",WORDS:"words",SEQUENCE:"sequence"},y={UPPER:"upper",LOWER:"lower",TITLE:"title"};function b(e,n){var i,r=e<0;switch(e=Math.abs(e),n.primary){case m.LETTERS:i=p(e,n.case===y.UPPER?"A":"a");break;case m.ROMAN:i=d(e),n.case===y.UPPER&&(i=i.toUpperCase());break;case m.WORDS:i=o(e,n.ordinal),n.case===y.UPPER?i=i.toUpperCase():n.case===y.LOWER&&(i=i.toLowerCase());break;case m.DECIMAL:i=""+e;var s=n.mandatoryDigits-i.length;if(s>0){var a=new Array(s+1).join("0");i=a+i}if(48!==n.zeroCode&&(i=t(i).map(function(t){return String.fromCodePoint(t.codePointAt(0)+n.zeroCode-48)}).join("")),n.regular)for(var c=Math.floor((i.length-1)/n.groupingSeparators.position);c>0;c--){var l=i.length-c*n.groupingSeparators.position;i=i.substr(0,l)+n.groupingSeparators.character+i.substr(l)}else n.groupingSeparators.reverse().forEach(function(t){var e=i.length-t.position;i=i.substr(0,e)+t.character+i.substr(e)});if(n.ordinal){var h={1:"st",2:"nd",3:"rd"}[i[i.length-1]];(!h||i.length>1&&"1"===i[i.length-2])&&(h="th"),i+=h}break;case m.SEQUENCE:throw{code:"D3130",value:n.token}}return r&&(i="-"+i),i}var _=[48,1632,1776,1984,2406,2534,2662,2790,2918,3046,3174,3302,3430,3558,3664,3792,3872,4160,4240,6112,6160,6470,6608,6784,6800,6992,7088,7232,7248,42528,43216,43264,43472,43504,43600,44016,65296];function v(e){var n,i={type:"integer",primary:m.DECIMAL,case:y.LOWER,ordinal:!1},r=e.lastIndexOf(";");switch(-1===r?n=e:(n=e.substring(0,r),"o"===e.substring(r+1)[0]&&(i.ordinal=!0)),n){case"A":i.case=y.UPPER;case"a":i.primary=m.LETTERS;break;case"I":i.case=y.UPPER;case"i":i.primary=m.ROMAN;break;case"W":i.case=y.UPPER,i.primary=m.WORDS;break;case"Ww":i.case=y.TITLE,i.primary=m.WORDS;break;case"w":i.primary=m.WORDS;break;default:var s=null,o=0,a=0,c=[],l=0,h=t(n).map(function(t){return t.codePointAt(0)}).reverse();if(h.forEach(function(t){for(var e=!1,n=0;n<_.length;n++){var i=_[n];if(t>=i&&t<=i+9){if(e=!0,o++,l++,null===s)s=i;else if(i!==s)throw{code:"D3131"};break}}e||(35===t?(l++,a++):c.push({position:l,character:String.fromCodePoint(t)}))}),o>0){i.primary=m.DECIMAL,i.zeroCode=s,i.mandatoryDigits=o,i.optionalDigits=a;var d=function(t){if(0===t.length)return 0;for(var e=t[0].character,n=1;n<t.length;n++)if(t[n].character!==e)return 0;for(var i=t.map(function(t){return t.position}),r=function t(e,n){return 0===n?e:t(n,e%n)},s=i.reduce(r),o=1;o<=i.length;o++)if(-1===i.indexOf(o*s))return 0;return s},u=d(c);u>0?(i.regular=!0,i.groupingSeparators={position:u,character:c[0].character}):(i.regular=!1,i.groupingSeparators=c)}else i.primary=m.SEQUENCE,i.token=n}return i}var x={Y:"1",M:"1",D:"1",d:"1",F:"n",W:"1",w:"1",X:"1",x:"1",H:"1",h:"1",P:"n",m:"01",s:"01",f:"1",Z:"01:01",z:"01:01",C:"n",E:"n"};function w(t){for(var e=[],n={type:"datetime",parts:e},i=function(n,i){if(i>n){var r=t.substring(n,i);r=r.split("]]").join("]"),e.push({type:"literal",value:r})}},r=0,s=0;s<t.length;){if("["===t.charAt(s)){if("["===t.charAt(s+1)){i(r,s),e.push({type:"literal",value:"["}),r=s+=2;continue}if(i(r,s),r=s,-1===(s=t.indexOf("]",r)))throw{code:"D3135"};var o,a=t.substring(r+1,s),c={type:"marker",component:(a=a.split(/\s+/).join("")).charAt(0)},l=a.lastIndexOf(",");if(-1!==l){var h=a.substring(l+1),d=h.indexOf("-"),u=void 0,p=void 0,f=function(t){return void 0===t||"*"===t?void 0:parseInt(t)};-1===d?u=h:(u=h.substring(0,d),p=h.substring(d+1));var g={min:f(u),max:f(p)};c.width=g,o=a.substring(1,l)}else o=a.substring(1);if(1===o.length)c.presentation1=o;else if(o.length>1){var m=o.charAt(o.length-1);-1!=="atco".indexOf(m)?(c.presentation2=m,"o"===m&&(c.ordinal=!0),c.presentation1=o.substring(0,o.length-1)):c.presentation1=o}else c.presentation1=x[c.component];if(void 0===c.presentation1)throw{code:"D3132",value:c.component};if("n"===c.presentation1[0])c.names=y.LOWER;else if("N"===c.presentation1[0])"n"===c.presentation1[1]?c.names=y.TITLE:c.names=y.UPPER;else if(-1!=="YMDdFWwXxHhmsf".indexOf(c.component)){var b=c.presentation1;if(c.presentation2&&(b+=";"+c.presentation2),c.integerFormat=v(b),c.width&&void 0!==c.width.min&&c.integerFormat.mandatoryDigits<c.width.min&&(c.integerFormat.mandatoryDigits=c.width.min),-1!=="YMD".indexOf(c.component))if(c.n=-1,c.width&&void 0!==c.width.max)c.n=c.width.max,c.integerFormat.mandatoryDigits=c.n;else{var _=c.integerFormat.mandatoryDigits+c.integerFormat.optionalDigits;_>=2&&(c.n=_)}}"Z"!==c.component&&"z"!==c.component||(c.integerFormat=v(c.presentation1)),e.push(c),r=s+1}s++}return i(r,s),n}var M=["","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],S=["January","February","March","April","May","June","July","August","September","October","November","December"],A=864e5,E=function(t){var e=Date.UTC(t.year,t.month),n=new Date(e).getUTCDay();return 0===n&&(n=7),n>4?e+(8-n)*A:e-(n-1)*A},k=function t(e,n){return{year:e,month:n,nextMonth:function(){return 11===n?t(e+1,0):t(e,n+1)},previousMonth:function(){return 0===n?t(e-1,11):t(e,n-1)},nextYear:function(){return t(e+1,n)},previousYear:function(){return t(e-1,n)}}},C=function(t,e){return(e-t)/(7*A)+1},T=function(t,e){var n;switch(e){case"Y":n=t.getUTCFullYear();break;case"M":n=t.getUTCMonth()+1;break;case"D":n=t.getUTCDate();break;case"d":n=(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate())-Date.UTC(t.getUTCFullYear(),0))/A+1;break;case"F":0===(n=t.getUTCDay())&&(n=7);break;case"W":var i=k(t.getUTCFullYear(),0),r=E(i),s=Date.UTC(i.year,t.getUTCMonth(),t.getUTCDate()),o=C(r,s);if(o>52)s>=E(i.nextYear())&&(o=1);else if(o<1){var a=E(i.previousYear());o=C(a,s)}n=Math.floor(o);break;case"w":var c=k(t.getUTCFullYear(),t.getUTCMonth()),l=E(c),h=Date.UTC(c.year,c.month,t.getUTCDate()),d=C(l,h);if(d>4)h>=E(c.nextMonth())&&(d=1);else if(d<1){var u=E(c.previousMonth());d=C(u,h)}n=Math.floor(d);break;case"X":var p=k(t.getUTCFullYear(),0),f=E(p),g=E(p.nextYear()),m=t.getTime();n=m<f?p.year-1:m>=g?p.year+1:p.year;break;case"x":var y=k(t.getUTCFullYear(),t.getUTCMonth()),b=E(y),_=y.nextMonth(),v=E(_),x=t.getTime();n=x<b?y.previousMonth().month+1:x>=v?_.month+1:y.month+1;break;case"H":n=t.getUTCHours();break;case"h":n=t.getUTCHours(),0==(n%=12)&&(n=12);break;case"P":n=t.getUTCHours()>=12?"pm":"am";break;case"m":n=t.getUTCMinutes();break;case"s":n=t.getUTCSeconds();break;case"f":n=t.getUTCMilliseconds();break;case"Z":case"z":break;case"C":case"E":n="ISO"}return n},P=null;function D(t,e,n){var i=0,r=0;if(void 0!==n){var s=parseInt(n);i=Math.floor(s/100),r=s%100}var o,a=function(t,e){var n=T(t,e.component);if(-1!=="YMDdFWwXxHhms".indexOf(e.component))if("Y"===e.component&&-1!==e.n&&(n%=Math.pow(10,e.n)),e.names){if("M"===e.component||"x"===e.component)n=S[n-1];else{if("F"!==e.component)throw{code:"D3133",value:e.component};n=M[n]}e.names===y.UPPER?n=n.toUpperCase():e.names===y.LOWER&&(n=n.toLowerCase()),e.width&&n.length>e.width.max&&(n=n.substring(0,e.width.max))}else n=b(n,e.integerFormat);else if("f"===e.component)n=b(n,e.integerFormat);else if("Z"===e.component||"z"===e.component){var s=100*i+r;if(e.integerFormat.regular)n=b(s,e.integerFormat);else{var o=e.integerFormat.mandatoryDigits;if(1===o||2===o)n=b(i,e.integerFormat),0!==r&&(n+=":"+g(r,"00"));else{if(3!==o&&4!==o)throw{code:"D3134",value:o};n=b(s,e.integerFormat)}}s>=0&&(n="+"+n),"z"===e.component&&(n="GMT"+n),0===s&&"t"===e.presentation2&&(n="Z")}return n};void 0===e?(null===P&&(P=w("[Y0001]-[M01]-[D01]T[H01]:[m01]:[s01].[f001][Z01:01t]")),o=P):o=w(e);var c=new Date(t+60*(60*i+r)*1e3),l="";return o.parts.forEach(function(t){"literal"===t.type?l+=t.value:l+=a(c,t)}),l}function O(t){var e={};if("datetime"===t.type)e.type="datetime",e.parts=t.parts.map(function(t){var e={};if("literal"===t.type)e.regex=t.value.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");else if("Z"===t.component||"z"===t.component){var n;Array.isArray(t.integerFormat.groupingSeparators)||(n=t.integerFormat.groupingSeparators),e.regex="","z"===t.component&&(e.regex="GMT"),e.regex+="[-+][0-9]+",n&&(e.regex+=n.character+"[0-9]+"),e.parse=function(e){"z"===t.component&&(e=e.substring(3));var i=0,r=0;return n?(i=Number.parseInt(e.substring(0,e.indexOf(n.character))),r=Number.parseInt(e.substring(e.indexOf(n.character)+1))):e.length-1<=2?i=Number.parseInt(e):(i=Number.parseInt(e.substring(0,3)),r=Number.parseInt(e.substring(3))),60*i+r}}else if(t.integerFormat)t.integerFormat.n=t.n,e=O(t.integerFormat);else{e.regex="[a-zA-Z]+";var i={};if("M"===t.component||"x"===t.component)S.forEach(function(e,n){t.width&&t.width.max?i[e.substring(0,t.width.max)]=n+1:i[e]=n+1});else if("F"===t.component)M.forEach(function(e,n){n>0&&(t.width&&t.width.max?i[e.substring(0,t.width.max)]=n:i[e]=n)});else{if("P"!==t.component)throw{code:"D3133",value:t.component};i={am:0,AM:0,pm:1,PM:1}}e.parse=function(t){return i[t]}}return e.component=t.component,e});else{e.type="integer";var n,i=t.case===y.UPPER;switch(n=t.n&&t.n>0?0===t.optionalDigits?"{".concat(t.n,"}"):"{".concat(t.n-t.optionalDigits,",").concat(t.n,"}"):"+",t.primary){case m.LETTERS:e.regex=i?"[A-Z]+":"[a-z]+",e.parse=function(t){return f(t,i?"A":"a")};break;case m.ROMAN:e.regex=i?"[MDCLXVI]+":"[mdclxvi]+",e.parse=function(t){return u(i?t:t.toUpperCase())};break;case m.WORDS:e.regex="(?:"+Object.keys(a).concat("and","[\\-, ]").join("|")+")+",e.parse=function(t){return c(t.toLowerCase())};break;case m.DECIMAL:e.regex="[0-9]".concat(n),t.ordinal&&(e.regex+="(?:th|st|nd|rd)"),e.parse=function(e){var n=e;return t.ordinal&&(n=e.substring(0,e.length-2)),t.regular?n=n.split(",").join(""):t.groupingSeparators.forEach(function(t){n=n.split(t.character).join("")}),48!==t.zeroCode&&(n=n.split("").map(function(e){return String.fromCodePoint(e.codePointAt(0)-t.zeroCode+48)}).join("")),parseInt(n)};break;case m.SEQUENCE:throw{code:"D3130",value:t.token}}}return e}function z(t,e){if(void 0!==t)return O(v(e)).parse(t)}function L(t,e){var n=O(w(e)),i="^"+n.parts.map(function(t){return"("+t.regex+")"}).join("")+"$",r=new RegExp(i,"i").exec(t);if(null!==r){for(var s=161,o=130,a=84,c=72,l=23,h=47,d={},u=1;u<r.length;u++){var p=n.parts[u-1];p.parse&&(d[p.component]=p.parse(r[u]))}if(0===Object.getOwnPropertyNames(d).length)return;var f=0,g=function(t){f<<=1,f+=t?1:0},m=function(t){return!(~t&f||!(t&f))};"YXMxWwdD".split("").forEach(function(t){return g(d[t])});var y=!m(s)&&m(o),b=m(a),_=!b&&m(c);f=0,"PHhmsf".split("").forEach(function(t){return g(d[t])});var v=!m(l)&&m(h),x=(y?"YD":b?"XxwF":_?"XWF":"YMD")+(v?"Phmsf":"Hmsf"),M=this.environment.timestamp,S=!1,A=!1;if(x.split("").forEach(function(t){if(void 0===d[t])S?(d[t]=-1!=="MDd".indexOf(t)?1:0,A=!0):d[t]=T(M,t);else if(S=!0,A)throw{code:"D3136"}}),d.M>0?d.M-=1:d.M=0,y){var E=Date.UTC(d.Y,0),k=1e3*(d.d-1)*60*60*24,C=new Date(E+k);d.M=C.getUTCMonth(),d.D=C.getUTCDate()}if(b)throw{code:"D3136"};if(_)throw{code:"D3136"};v&&(d.H=12===d.h?0:d.h,1===d.P&&(d.H+=12));var P=Date.UTC(d.Y,d.M,d.D,d.H,d.m,d.s,d.f);return(d.Z||d.z)&&(P-=60*(d.Z||d.z)*1e3),P}}var I=new RegExp("^\\d{4}(-[01]\\d)*(-[0-3]\\d)*(T[0-2]\\d:[0-5]\\d:[0-5]\\d)*(\\.\\d+)?([+-][0-2]\\d:?[0-5]\\d|Z)?$");function R(t,e){if(void 0!==t){if(void 0===e){if(!I.test(t))throw{stack:(new Error).stack,code:"D3110",value:t};return Date.parse(t)}return L.call(this,t,e)}}function j(t,e,n){if(void 0!==t)return D.call(this,t,e,n)}return{formatInteger:g,parseInteger:z,fromMillis:j,toMillis:R}}();e.exports=r},{"./utils":6}],2:[function(t,e,n){(function(n){(function(){function i(t){return i="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},i(t)}function r(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */r=function(){return e};var t,e={},n=Object.prototype,s=n.hasOwnProperty,o=Object.defineProperty||function(t,e,n){t[e]=n.value},a="function"==typeof Symbol?Symbol:{},c=a.iterator||"@@iterator",l=a.asyncIterator||"@@asyncIterator",h=a.toStringTag||"@@toStringTag";function d(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{d({},"")}catch(t){d=function(t,e,n){return t[e]=n}}function u(t,e,n,i){var r=e&&e.prototype instanceof _?e:_,s=Object.create(r.prototype),a=new O(i||[]);return o(s,"_invoke",{value:C(t,n,a)}),s}function p(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}e.wrap=u;var f="suspendedStart",g="suspendedYield",m="executing",y="completed",b={};function _(){}function v(){}function x(){}var w={};d(w,c,function(){return this});var M=Object.getPrototypeOf,S=M&&M(M(z([])));S&&S!==n&&s.call(S,c)&&(w=S);var A=x.prototype=_.prototype=Object.create(w);function E(t){["next","throw","return"].forEach(function(e){d(t,e,function(t){return this._invoke(e,t)})})}function k(t,e){function n(r,o,a,c){var l=p(t[r],t,o);if("throw"!==l.type){var h=l.arg,d=h.value;return d&&"object"==i(d)&&s.call(d,"__await")?e.resolve(d.__await).then(function(t){n("next",t,a,c)},function(t){n("throw",t,a,c)}):e.resolve(d).then(function(t){h.value=t,a(h)},function(t){return n("throw",t,a,c)})}c(l.arg)}var r;o(this,"_invoke",{value:function(t,i){function s(){return new e(function(e,r){n(t,i,e,r)})}return r=r?r.then(s,s):s()}})}function C(e,n,i){var r=f;return function(s,o){if(r===m)throw new Error("Generator is already running");if(r===y){if("throw"===s)throw o;return{value:t,done:!0}}for(i.method=s,i.arg=o;;){var a=i.delegate;if(a){var c=T(a,i);if(c){if(c===b)continue;return c}}if("next"===i.method)i.sent=i._sent=i.arg;else if("throw"===i.method){if(r===f)throw r=y,i.arg;i.dispatchException(i.arg)}else"return"===i.method&&i.abrupt("return",i.arg);r=m;var l=p(e,n,i);if("normal"===l.type){if(r=i.done?y:g,l.arg===b)continue;return{value:l.arg,done:i.done}}"throw"===l.type&&(r=y,i.method="throw",i.arg=l.arg)}}}function T(e,n){var i=n.method,r=e.iterator[i];if(r===t)return n.delegate=null,"throw"===i&&e.iterator.return&&(n.method="return",n.arg=t,T(e,n),"throw"===n.method)||"return"!==i&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+i+"' method")),b;var s=p(r,e.iterator,n.arg);if("throw"===s.type)return n.method="throw",n.arg=s.arg,n.delegate=null,b;var o=s.arg;return o?o.done?(n[e.resultName]=o.value,n.next=e.nextLoc,"return"!==n.method&&(n.method="next",n.arg=t),n.delegate=null,b):o:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,b)}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 D(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function O(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(P,this),this.reset(!0)}function z(e){if(e||""===e){var n=e[c];if(n)return n.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,o=function n(){for(;++r<e.length;)if(s.call(e,r))return n.value=e[r],n.done=!1,n;return n.value=t,n.done=!0,n};return o.next=o}}throw new TypeError(i(e)+" is not iterable")}return v.prototype=x,o(A,"constructor",{value:x,configurable:!0}),o(x,"constructor",{value:v,configurable:!0}),v.displayName=d(x,h,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,x):(t.__proto__=x,d(t,h,"GeneratorFunction")),t.prototype=Object.create(A),t},e.awrap=function(t){return{__await:t}},E(k.prototype),d(k.prototype,l,function(){return this}),e.AsyncIterator=k,e.async=function(t,n,i,r,s){void 0===s&&(s=Promise);var o=new k(u(t,n,i,r),s);return e.isGeneratorFunction(n)?o:o.next().then(function(t){return t.done?t.value:o.next()})},E(A),d(A,h,"Generator"),d(A,c,function(){return this}),d(A,"toString",function(){return"[object Generator]"}),e.keys=function(t){var e=Object(t),n=[];for(var i in e)n.push(i);return n.reverse(),function t(){for(;n.length;){var i=n.pop();if(i in e)return t.value=i,t.done=!1,t}return t.done=!0,t}},e.values=z,O.prototype={constructor:O,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(D),!e)for(var n in this)"t"===n.charAt(0)&&s.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=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 n=this;function i(i,r){return a.type="throw",a.arg=e,n.next=i,r&&(n.method="next",n.arg=t),!!r}for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r],a=o.completion;if("root"===o.tryLoc)return i("end");if(o.tryLoc<=this.prev){var c=s.call(o,"catchLoc"),l=s.call(o,"finallyLoc");if(c&&l){if(this.prev<o.catchLoc)return i(o.catchLoc,!0);if(this.prev<o.finallyLoc)return i(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return i(o.catchLoc,!0)}else{if(!l)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return i(o.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&s.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var r=i;break}}r&&("break"===t||"continue"===t)&&r.tryLoc<=e&&e<=r.finallyLoc&&(r=null);var o=r?r.completion:{};return o.type=t,o.arg=e,r?(this.method="next",this.next=r.finallyLoc,b):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),b},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),D(n),b}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var i=n.completion;if("throw"===i.type){var r=i.arg;D(n)}return r}}throw new Error("illegal catch attempt")},delegateYield:function(e,n,i){return this.delegate={iterator:z(e),resultName:n,nextLoc:i},"next"===this.method&&(this.arg=t),b}},e}var s=t("./utils"),o=function(){var t=r().mark(H),e=r().mark(Y),o=r().mark(G),a=r().mark(V),c=r().mark(Q),l=r().mark(ut),h=r().mark(pt),d=r().mark(ft),u=r().mark(mt),p=r().mark(St),f=r().mark(Ct),g=r().mark(Dt),m=s.isNumeric,y=s.isArrayOfStrings,b=s.isArrayOfNumbers,_=s.createSequence,v=s.isSequence,x=s.isFunction,w=s.isLambda,M=s.isIterable,S=s.getFunctionArity,A=s.isDeepEqual,E=s.stringToArray;function k(t){if(void 0!==t){var e=0;return t.forEach(function(t){e+=t}),e}}function C(t){return void 0===t?0:t.length}function T(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 D(t){if(void 0!==t&&0!==t.length){var e=0;return t.forEach(function(t){e+=t}),e/t.length}}function O(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(void 0!==t){var n;if("string"==typeof t)n=t;else if(x(t))n="";else{if("number"==typeof t&&!isFinite(t))throw{code:"D3001",value:t,stack:(new Error).stack};var i=e?2:0;Array.isArray(t)&&t.outerWrapper&&(t=t[0]),n=JSON.stringify(t,function(t,e){return null!=e&&e.toPrecision&&m(e)?Number(e.toPrecision(15)):e&&x(e)?"":e},i)}return n}}function z(t,e,n){if(void 0!==t){var i=E(t),r=i.length;if(r+e<0&&(e=0),void 0!==n){if(n<=0)return"";var s=e>=0?e+n:r+e+n;return i.slice(e,s).join("")}return i.slice(e).join("")}}function L(t,e){if(void 0!==t){var n=t.indexOf(e);return n>-1?t.substr(0,n):t}}function I(t,e){if(void 0!==t){var n=t.indexOf(e);return n>-1?t.substr(n+e.length):t}}function R(t){if(void 0!==t)return t.toLowerCase()}function j(t){if(void 0!==t)return t.toUpperCase()}function F(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 N(t,e,n){if(void 0!==t){var i;void 0!==n&&0!==n.length||(n=" ");var r=Math.abs(e)-F(t);if(r>0){var s=new Array(r+1).join(n);n.length>1&&(s=z(s,0,r)),i=e>0?t+s:s+t}else i=t;return i}}function H(e,n){var i;return r().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(i=e.apply(this,[n]),!M(i)){t.next=4;break}return t.delegateYield(i,"t0",3);case 3:i=t.t0;case 4:if(!i||"number"==typeof i.start||"number"===i.end||Array.isArray(i.groups)||x(i.next)){t.next=6;break}throw{code:"T1010",stack:(new Error).stack};case 6:return t.abrupt("return",i);case 7:case"end":return t.stop()}},t,this)}function Y(t,n){var i,s;return r().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==t){e.next=2;break}return e.abrupt("return",void 0);case 2:if("string"!=typeof n){e.next=6;break}i=-1!==t.indexOf(n),e.next=9;break;case 6:return e.delegateYield(H(n,t),"t0",7);case 7:s=e.t0,i=void 0!==s;case 9:return e.abrupt("return",i);case 10:case"end":return e.stop()}},e)}function G(t,e,n){var i,s,a;return r().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(!(n<0)){r.next=4;break}throw{stack:(new Error).stack,value:n,code:"D3040",index:3};case 4:if(i=_(),!(void 0===n||n>0)){r.next=17;break}return s=0,r.delegateYield(H(e,t),"t0",8);case 8:if(void 0===(a=r.t0)){r.next=17;break}case 10:if(void 0===a||!(void 0===n||s<n)){r.next=17;break}return i.push({match:a.match,index:a.start,groups:a.groups}),r.delegateYield(H(a.next),"t1",13);case 13:a=r.t1,s++,r.next=10;break;case 17:return r.abrupt("return",i);case 18:case"end":return r.stop()}},o)}function V(t,e,n,i){var s,o,c,l,h,d,u,p;return r().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(s=this,""!==e){r.next=5;break}throw{code:"D3010",stack:(new Error).stack,value:e,index:2};case 5:if(!(i<0)){r.next=7;break}throw{code:"D3011",stack:(new Error).stack,value:i,index:4};case 7:if(o="string"==typeof n?function(t){for(var e="",i=0,r=n.indexOf("$",i);-1!==r&&i<n.length;){e+=n.substring(i,r),i=r+1;var s=n.charAt(i);if("$"===s)e+="$",i++;else if("0"===s)e+=t.match,i++;else{var o;if(o=0===t.groups.length?1:Math.floor(Math.log(t.groups.length)*Math.LOG10E)+1,r=parseInt(n.substring(i,i+o),10),o>1&&r>t.groups.length&&(r=parseInt(n.substring(i,i+o-1),10)),isNaN(r))e+="$";else{if(t.groups.length>0){var a=t.groups[r-1];void 0!==a&&(e+=a)}i+=r.toString().length}}r=n.indexOf("$",i)}return e+=n.substring(i)}:n,c="",l=0,!(void 0===i||i>0)){r.next=44;break}if(h=0,"string"!=typeof e){r.next=18;break}for(d=t.indexOf(e,l);-1!==d&&(void 0===i||h<i);)c+=t.substring(l,d),c+=n,l=d+e.length,h++,d=t.indexOf(e,l);c+=t.substring(l),r.next=42;break;case 18:return r.delegateYield(H(e,t),"t0",19);case 19:if(void 0===(u=r.t0)){r.next=41;break}case 21:if(void 0===u||!(void 0===i||h<i)){r.next=38;break}if(c+=t.substring(l,u.start),p=o.apply(s,[u]),!M(p)){r.next=27;break}return r.delegateYield(p,"t1",26);case 26:p=r.t1;case 27:if("string"!=typeof p){r.next=31;break}c+=p,r.next=32;break;case 31:throw{code:"D3012",stack:(new Error).stack,value:p};case 32:return l=u.start+u.match.length,h++,r.delegateYield(H(u.next),"t2",35);case 35:u=r.t2,r.next=21;break;case 38:c+=t.substring(l),r.next=42;break;case 41:c=t;case 42:r.next=45;break;case 44:c=t;case 45:return r.abrupt("return",c);case 46:case"end":return r.stop()}},a,this)}function U(t){if(void 0!==t){var e="undefined"!=typeof window?window.btoa:function(t){return new n.Buffer.from(t,"binary").toString("base64")};return e(t)}}function $(t){if(void 0!==t){var e="undefined"!=typeof window?window.atob:function(t){return new n.Buffer.from(t,"base64").toString("binary")};return e(t)}}function W(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 q(t){if(void 0!==t){var e;try{e=decodeURIComponent(t)}catch(e){throw{code:"D3140",stack:(new Error).stack,value:t,functionName:"decodeUrlComponent"}}return e}}function K(t){if(void 0!==t){var e;try{e=decodeURI(t)}catch(e){throw{code:"D3140",stack:(new Error).stack,value:t,functionName:"decodeUrl"}}return e}}function Q(t,e,n){var i,s,o,a;return r().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(!(n<0)){r.next=4;break}throw{code:"D3020",stack:(new Error).stack,value:n,index:3};case 4:if(i=[],!(void 0===n||n>0)){r.next=27;break}if("string"!=typeof e){r.next=10;break}i=t.split(e,n),r.next=27;break;case 10:return s=0,r.delegateYield(H(e,t),"t0",12);case 12:if(void 0===(o=r.t0)){r.next=26;break}a=0;case 15:if(void 0===o||!(void 0===n||s<n)){r.next=23;break}return i.push(t.substring(a,o.start)),a=o.end,r.delegateYield(H(o.next),"t1",19);case 19:o=r.t1,s++,r.next=15;break;case 23:(void 0===n||s<n)&&i.push(t.substring(a)),r.next=27;break;case 26:i.push(t);case 27:return r.abrupt("return",i);case 28:case"end":return r.stop()}},c)}function Z(t,e){if(void 0!==t)return void 0===e&&(e=""),t.join(e)}function J(t,e,n){if(void 0!==t){var i={"decimal-separator":".","grouping-separator":",","exponent-separator":"e",infinity:"Infinity","minus-sign":"-",NaN:"NaN",percent:"%","per-mille":"‰","zero-digit":"0",digit:"#","pattern-separator":";"};void 0!==n&&Object.keys(n).forEach(function(t){i[t]=n[t]});for(var r=[],s=i["zero-digit"].charCodeAt(0),o=s;o<s+10;o++)r.push(String.fromCharCode(o));var a=r.concat([i["decimal-separator"],i["exponent-separator"],i["grouping-separator"],i.digit,i["pattern-separator"]]),c=e.split(i["pattern-separator"]);if(c.length>2)throw{code:"D3080",stack:(new Error).stack};var l=function(t){var e,n,r,s,o=function(){for(var e,n=0;n<t.length;n++)if(e=t.charAt(n),-1!==a.indexOf(e)&&e!==i["exponent-separator"])return t.substring(0,n)}(),c=function(){for(var e,n=t.length-1;n>=0;n--)if(e=t.charAt(n),-1!==a.indexOf(e)&&e!==i["exponent-separator"])return t.substring(n+1)}(),l=t.substring(o.length,t.length-c.length),h=t.indexOf(i["exponent-separator"],o.length);-1===h||h>t.length-c.length?(e=l,n=void 0):(e=l.substring(0,h),n=l.substring(h+1));var d=e.indexOf(i["decimal-separator"]);return-1===d?(r=e,s=c):(r=e.substring(0,d),s=e.substring(d+1)),{prefix:o,suffix:c,activePart:l,mantissaPart:e,exponentPart:n,integerPart:r,fractionalPart:s,subpicture:t}},h=function(t){var e,n,s=t.subpicture,o=s.indexOf(i["decimal-separator"]);o!==s.lastIndexOf(i["decimal-separator"])&&(e="D3081"),s.indexOf(i.percent)!==s.lastIndexOf(i.percent)&&(e="D3082"),s.indexOf(i["per-mille"])!==s.lastIndexOf(i["per-mille"])&&(e="D3083"),-1!==s.indexOf(i.percent)&&-1!==s.indexOf(i["per-mille"])&&(e="D3084");var c=!1;for(n=0;n<t.mantissaPart.length;n++){var l=t.mantissaPart.charAt(n);if(-1!==r.indexOf(l)||l===i.digit){c=!0;break}}c||(e="D3085"),-1!==t.activePart.split("").map(function(t){return-1===a.indexOf(t)?"p":"a"}).join("").indexOf("p")&&(e="D3086"),-1!==o?s.charAt(o-1)!==i["grouping-separator"]&&s.charAt(o+1)!==i["grouping-separator"]||(e="D3087"):t.integerPart.charAt(t.integerPart.length-1)===i["grouping-separator"]&&(e="D3088"),-1!==s.indexOf(i["grouping-separator"]+i["grouping-separator"])&&(e="D3089");var h=t.integerPart.indexOf(i.digit);-1!==h&&t.integerPart.substring(0,h).split("").filter(function(t){return r.indexOf(t)>-1}).length>0&&(e="D3090"),-1!==(h=t.fractionalPart.lastIndexOf(i.digit))&&t.fractionalPart.substring(h).split("").filter(function(t){return r.indexOf(t)>-1}).length>0&&(e="D3091");var d="string"==typeof t.exponentPart;if(d&&t.exponentPart.length>0&&(-1!==s.indexOf(i.percent)||-1!==s.indexOf(i["per-mille"]))&&(e="D3092"),d&&(0===t.exponentPart.length||t.exponentPart.split("").filter(function(t){return-1===r.indexOf(t)}).length>0)&&(e="D3093"),e)throw{code:e,stack:(new Error).stack}},d=function(t){var e=function(e,n){for(var s=[],o=e.indexOf(i["grouping-separator"]);-1!==o;){var a=(n?e.substring(0,o):e.substring(o)).split("").filter(function(t){return-1!==r.indexOf(t)||t===i.digit}).length;s.push(a),o=t.integerPart.indexOf(i["grouping-separator"],o+1)}return s},n=e(t.integerPart),s=function(t){if(0===t.length)return 0;for(var e=function t(e,n){return 0===n?e:t(n,e%n)},n=t.reduce(e),i=1;i<=t.length;i++)if(-1===t.indexOf(i*n))return 0;return n},o=s(n),a=e(t.fractionalPart,!0),c=t.integerPart.split("").filter(function(t){return-1!==r.indexOf(t)}).length,l=c,h=t.fractionalPart.split(""),d=h.filter(function(t){return-1!==r.indexOf(t)}).length,u=h.filter(function(t){return-1!==r.indexOf(t)||t===i.digit}).length,p="string"==typeof t.exponentPart;0===c&&0===u&&(p?(d=1,u=1):c=1),p&&0===c&&-1!==t.integerPart.indexOf(i.digit)&&(c=1),0===c&&0===d&&(d=1);var f=0;return p&&(f=t.exponentPart.split("").filter(function(t){return-1!==r.indexOf(t)}).length),{integerPartGroupingPositions:n,regularGrouping:o,minimumIntegerPartSize:c,scalingFactor:l,prefix:t.prefix,fractionalPartGroupingPositions:a,minimumFactionalPartSize:d,maximumFactionalPartSize:u,minimumExponentSize:f,suffix:t.suffix,picture:t.subpicture}},u=c.map(l);u.forEach(h);var p,f,g,m,y=u.map(d),b=i["minus-sign"],_=i["zero-digit"],v=i["decimal-separator"],x=i["grouping-separator"];if(1===y.length&&(y.push(JSON.parse(JSON.stringify(y[0]))),y[1].prefix=b+y[1].prefix),f=-1!==(p=t>=0?y[0]:y[1]).picture.indexOf(i.percent)?100*t:-1!==p.picture.indexOf(i["per-mille"])?1e3*t:t,0===p.minimumExponentSize)g=f;else{var w=Math.pow(10,p.scalingFactor),M=Math.pow(10,p.scalingFactor-1);for(g=f,m=0;g<M;)g*=10,m-=1;for(;g>w;)g/=10,m+=1}var S=function(t,e){var n=Math.abs(t).toFixed(e);return"0"!==_&&(n=n.split("").map(function(t){return t>="0"&&t<="9"?r[t.charCodeAt(0)-48]:t}).join("")),n},A=S(st(g,p.maximumFactionalPartSize),p.maximumFactionalPartSize),E=A.indexOf(".");for(-1===E?A+=v:A=A.replace(".",v);A.charAt(0)===_;)A=A.substring(1);for(;A.charAt(A.length-1)===_;)A=A.substring(0,A.length-1);E=A.indexOf(v);var k=p.minimumIntegerPartSize-E,C=p.minimumFactionalPartSize-(A.length-E-1);if(A=(k>0?new Array(k+1).join(_):"")+A,A+=C>0?new Array(C+1).join(_):"",E=A.indexOf(v),p.regularGrouping>0)for(var T=Math.floor((E-1)/p.regularGrouping),P=1;P<=T;P++)A=[A.slice(0,E-P*p.regularGrouping),x,A.slice(E-P*p.regularGrouping)].join("");else p.integerPartGroupingPositions.forEach(function(t){A=[A.slice(0,E-t),x,A.slice(E-t)].join(""),E++});if(E=A.indexOf(v),p.fractionalPartGroupingPositions.forEach(function(t){A=[A.slice(0,t+E+1),x,A.slice(t+E+1)].join("")}),E=A.indexOf(v),-1!==p.picture.indexOf(v)&&E!==A.length-1||(A=A.substring(0,A.length-1)),void 0!==m){var D=S(m,0);(k=p.minimumExponentSize-D.length)>0&&(D=new Array(k+1).join(_)+D),A=A+i["exponent-separator"]+(m<0?b:"")+D}return A=p.prefix+A+p.suffix}}function tt(t,e){if(void 0!==t){if(t=st(t),(e=void 0===e?10:st(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 nt(t){if(void 0!==t)return Math.abs(t)}function it(t){if(void 0!==t)return Math.floor(t)}function rt(t){if(void 0!==t)return Math.ceil(t)}function st(t,e){var n;if(void 0!==t){if(e){var i=t.toString().split("e");t=+(i[0]+"e"+(i[1]?+i[1]+e:e))}var r=(n=Math.round(t))-t;return.5===Math.abs(r)&&1===Math.abs(n%2)&&(n-=1),e&&(i=n.toString().split("e"),n=+(i[0]+"e"+(i[1]?+i[1]-e:-e))),Object.is(n,-0)&&(n=0),n}}function ot(t){if(void 0!==t){if(t<0)throw{stack:(new Error).stack,code:"D3060",index:1,value:t};return Math.sqrt(t)}}function at(t,e){var n;if(void 0!==t){if(n=Math.pow(t,e),!isFinite(n))throw{stack:(new Error).stack,code:"D3061",index:1,value:t,exp:e};return n}}function ct(){return Math.random()}function lt(t){if(void 0!==t){var e=!1;return Array.isArray(t)?1===t.length?e=lt(t[0]):t.length>1&&(e=t.filter(function(t){return lt(t)}).length>0):"string"==typeof t?t.length>0&&(e=!0):m(t)?0!==t&&(e=!0):null!==t&&"object"===i(t)?Object.keys(t).length>0&&(e=!0):"boolean"==typeof t&&!0===t&&(e=!0),e}}function ht(t){if(void 0!==t)return!lt(t)}function dt(t,e,n,i){var r=[e],s=S(t);return s>=2&&r.push(n),s>=3&&r.push(i),r}function ut(t,e){var n,i,s,o;return r().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:n=_(),i=0;case 4:if(!(i<t.length)){r.next=12;break}return s=dt(e,t[i],i,t),r.delegateYield(e.apply(this,s),"t0",7);case 7:void 0!==(o=r.t0)&&n.push(o);case 9:i++,r.next=4;break;case 12:return r.abrupt("return",n);case 13:case"end":return r.stop()}},l,this)}function pt(t,e){var n,i,s,o;return r().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:n=_(),i=0;case 4:if(!(i<t.length)){r.next=13;break}return s=t[i],o=dt(e,s,i,t),r.delegateYield(e.apply(this,o),"t0",8);case 8:lt(r.t0)&&n.push(s);case 10:i++,r.next=4;break;case 13:return r.abrupt("return",n);case 14:case"end":return r.stop()}},h,this)}function ft(t,e){var n,i,s,o,a,c,l;return r().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:n=!1,s=0;case 4:if(!(s<t.length)){r.next=22;break}if(o=t[s],a=!0,void 0===e){r.next=12;break}return c=dt(e,o,s,t),r.delegateYield(e.apply(this,c),"t0",10);case 10:l=r.t0,a=lt(l);case 12:if(!a){r.next=19;break}if(n){r.next=18;break}i=o,n=!0,r.next=19;break;case 18:throw{stack:(new Error).stack,code:"D3138",index:s};case 19:s++,r.next=4;break;case 22:if(n){r.next=24;break}throw{stack:(new Error).stack,code:"D3139"};case 24:return r.abrupt("return",i);case 25:case"end":return r.stop()}},d,this)}function gt(){for(var t=[],e=Array.prototype.slice.call(arguments),n=Math.min.apply(Math,e.map(function(t){return Array.isArray(t)?t.length:0})),i=0;i<n;i++){var r=e.map(function(t){return t[i]});t.push(r)}return t}function mt(t,e,n){var i,s,o,a;return r().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(!((s=S(e))<2)){r.next=5;break}throw{stack:(new Error).stack,code:"D3050",index:1};case 5:void 0===n&&t.length>0?(i=t[0],o=1):(i=n,o=0);case 6:if(!(o<t.length)){r.next=15;break}return a=[i,t[o]],s>=3&&a.push(o),s>=4&&a.push(t),r.delegateYield(e.apply(this,a),"t0",11);case 11:i=r.t0,o++,r.next=6;break;case 15:return r.abrupt("return",i);case 16:case"end":return r.stop()}},u,this)}function yt(t){var e=_();if(Array.isArray(t)){var n={};t.forEach(function(t){yt(t).forEach(function(t){n[t]=!0})}),e=yt(n)}else null===t||"object"!==i(t)||w(t)||Object.keys(t).forEach(function(t){return e.push(t)});return e}function bt(t,e){var n;if(Array.isArray(t)){n=_();for(var r=0;r<t.length;r++){var s=bt(t[r],e);void 0!==s&&(Array.isArray(s)?s.forEach(function(t){return n.push(t)}):n.push(s))}}else null!==t&&"object"===i(t)&&(n=t[e]);return n}function _t(t,e){return void 0===t?e:void 0===e?t:(Array.isArray(t)||(t=_(t)),Array.isArray(e)||(e=[e]),t.concat(e))}function vt(t){return void 0!==t}function xt(t){var e=_();if(Array.isArray(t))t.forEach(function(t){e=_t(e,xt(t))});else if(null===t||"object"!==i(t)||w(t))e=t;else for(var n in t){var r={};r[n]=t[n],e.push(r)}return e}function wt(t){if(void 0!==t){var e={};return t.forEach(function(t){for(var n in t)e[n]=t[n]}),e}}function Mt(t){if(void 0!==t){if(t.length<=1)return t;for(var e=t.length,n=new Array(e),i=0;i<e;i++)n[e-i-1]=t[i];return n}}function St(t,e){var n,i,s,o;return r().wrap(function(a){for(;;)switch(a.prev=a.next){case 0:n=_(),a.t0=r().keys(t);case 2:if((a.t1=a.t0()).done){a.next=10;break}return i=a.t1.value,s=dt(e,t[i],i,t),a.delegateYield(e.apply(this,s),"t2",6);case 6:void 0!==(o=a.t2)&&n.push(o),a.next=2;break;case 10:return a.abrupt("return",n);case 11:case"end":return a.stop()}},p,this)}function At(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 kt(t){if(void 0!==t)return null===t?"null":m(t)?"number":"string"==typeof t?"string":"boolean"==typeof t?"boolean":Array.isArray(t)?"array":x(t)?"function":"object"}function Ct(t,e){var n,i,s,o;return r().wrap(function(a){for(;;)switch(a.prev=a.next){case 0:if(void 0!==t){a.next=2;break}return a.abrupt("return",void 0);case 2:if(!(t.length<=1)){a.next=4;break}return a.abrupt("return",t);case 4:if(void 0!==e){a.next=10;break}if(b(t)||y(t)){a.next=7;break}throw{stack:(new Error).stack,code:"D3070",index:1};case 7:n=r().mark(function t(e,n){return r().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",e>n);case 1:case"end":return t.stop()}},t)}),a.next=11;break;case 10:n=e;case 11:return i=r().mark(function t(e,i){var s,o;return r().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return s=r().mark(function t(e,i,s){return r().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:if(0!==i.length){r.next=4;break}Array.prototype.push.apply(e,s),r.next=16;break;case 4:if(0!==s.length){r.next=8;break}Array.prototype.push.apply(e,i),r.next=16;break;case 8:return r.delegateYield(n(i[0],s[0]),"t0",9);case 9:if(!r.t0){r.next=14;break}return e.push(s[0]),r.delegateYield(t(e,i,s.slice(1)),"t1",12);case 12:r.next=16;break;case 14:return e.push(i[0]),r.delegateYield(t(e,i.slice(1),s),"t2",16);case 16:case"end":return r.stop()}},t)}),o=[],t.delegateYield(s(o,e,i),"t0",3);case 3:return t.abrupt("return",o);case 4:case"end":return t.stop()}},t)}),s=r().mark(function t(e){var n,s,o;return r().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:if(Array.isArray(e)&&!(e.length<=1)){r.next=4;break}return r.abrupt("return",e);case 4:return n=Math.floor(e.length/2),s=e.slice(0,n),o=e.slice(n),r.delegateYield(t(s),"t0",8);case 8:return s=r.t0,r.delegateYield(t(o),"t1",10);case 10:return o=r.t1,r.delegateYield(i(s,o),"t2",12);case 12:return r.abrupt("return",r.t2);case 13:case"end":return r.stop()}},t)}),a.delegateYield(s(t),"t0",14);case 14:return o=a.t0,a.abrupt("return",o);case 16:case"end":return a.stop()}},f)}function Tt(t){if(void 0!==t){if(t.length<=1)return t;for(var e=new Array(t.length),n=0;n<t.length;n++){var i=Math.floor(Math.random()*(n+1));n!==i&&(e[n]=e[i]),e[i]=t[n]}return e}}function Pt(t){if(void 0!==t){if(!Array.isArray(t)||t.length<=1)return t;for(var e=v(t)?_():[],n=0;n<t.length;n++){for(var i=t[n],r=!1,s=0;s<e.length;s++)if(A(i,e[s])){r=!0;break}r||e.push(i)}return e}}function Dt(t,e){var n,i,s,o;return r().wrap(function(a){for(;;)switch(a.prev=a.next){case 0:n={},a.t0=r().keys(t);case 2:if((a.t1=a.t0()).done){a.next=11;break}return i=a.t1.value,s=t[i],o=dt(e,s,i,t),a.delegateYield(e.apply(this,o),"t2",7);case 7:lt(a.t2)&&(n[i]=s),a.next=2;break;case 11:return 0===Object.keys(n).length&&(n=void 0),a.abrupt("return",n);case 13:case"end":return a.stop()}},g,this)}return{sum:k,count:C,max:T,min:P,average:D,string:O,substring:z,substringBefore:L,substringAfter:I,lowercase:R,uppercase:j,length:F,trim:B,pad:N,match:G,contains:Y,replace:V,split:Q,join:Z,formatNumber:J,formatBase:tt,number:et,floor:it,ceil:rt,round:st,abs:nt,sqrt:ot,power:at,random:ct,boolean:lt,not:ht,map:ut,zip:gt,filter:pt,single:ft,foldLeft:mt,sift:Dt,keys:yt,lookup:bt,append:_t,exists:vt,spread:xt,merge:wt,reverse:Mt,each:St,error:At,assert:Et,type:kt,sort:Ct,shuffle:Tt,distinct:Pt,base64encode:U,base64decode:$,encodeUrlComponent:W,encodeUrl:X,decodeUrlComponent:q,decodeUrl:K}}();e.exports=o}).call(this)}).call(this,void 0!==Yi?Yi:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./utils":6}],3:[function(t,e,n){function i(t){return i="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},i(t)}function r(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */r=function(){return e};var t,e={},n=Object.prototype,s=n.hasOwnProperty,o=Object.defineProperty||function(t,e,n){t[e]=n.value},a="function"==typeof Symbol?Symbol:{},c=a.iterator||"@@iterator",l=a.asyncIterator||"@@asyncIterator",h=a.toStringTag||"@@toStringTag";function d(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{d({},"")}catch(t){d=function(t,e,n){return t[e]=n}}function u(t,e,n,i){var r=e&&e.prototype instanceof _?e:_,s=Object.create(r.prototype),a=new O(i||[]);return o(s,"_invoke",{value:C(t,n,a)}),s}function p(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}e.wrap=u;var f="suspendedStart",g="suspendedYield",m="executing",y="completed",b={};function _(){}function v(){}function x(){}var w={};d(w,c,function(){return this});var M=Object.getPrototypeOf,S=M&&M(M(z([])));S&&S!==n&&s.call(S,c)&&(w=S);var A=x.prototype=_.prototype=Object.create(w);function E(t){["next","throw","return"].forEach(function(e){d(t,e,function(t){return this._invoke(e,t)})})}function k(t,e){function n(r,o,a,c){var l=p(t[r],t,o);if("throw"!==l.type){var h=l.arg,d=h.value;return d&&"object"==i(d)&&s.call(d,"__await")?e.resolve(d.__await).then(function(t){n("next",t,a,c)},function(t){n("throw",t,a,c)}):e.resolve(d).then(function(t){h.value=t,a(h)},function(t){return n("throw",t,a,c)})}c(l.arg)}var r;o(this,"_invoke",{value:function(t,i){function s(){return new e(function(e,r){n(t,i,e,r)})}return r=r?r.then(s,s):s()}})}function C(e,n,i){var r=f;return function(s,o){if(r===m)throw new Error("Generator is already running");if(r===y){if("throw"===s)throw o;return{value:t,done:!0}}for(i.method=s,i.arg=o;;){var a=i.delegate;if(a){var c=T(a,i);if(c){if(c===b)continue;return c}}if("next"===i.method)i.sent=i._sent=i.arg;else if("throw"===i.method){if(r===f)throw r=y,i.arg;i.dispatchException(i.arg)}else"return"===i.method&&i.abrupt("return",i.arg);r=m;var l=p(e,n,i);if("normal"===l.type){if(r=i.done?y:g,l.arg===b)continue;return{value:l.arg,done:i.done}}"throw"===l.type&&(r=y,i.method="throw",i.arg=l.arg)}}}function T(e,n){var i=n.method,r=e.iterator[i];if(r===t)return n.delegate=null,"throw"===i&&e.iterator.return&&(n.method="return",n.arg=t,T(e,n),"throw"===n.method)||"return"!==i&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+i+"' method")),b;var s=p(r,e.iterator,n.arg);if("throw"===s.type)return n.method="throw",n.arg=s.arg,n.delegate=null,b;var o=s.arg;return o?o.done?(n[e.resultName]=o.value,n.next=e.nextLoc,"return"!==n.method&&(n.method="next",n.arg=t),n.delegate=null,b):o:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,b)}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 D(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function O(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(P,this),this.reset(!0)}function z(e){if(e||""===e){var n=e[c];if(n)return n.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,o=function n(){for(;++r<e.length;)if(s.call(e,r))return n.value=e[r],n.done=!1,n;return n.value=t,n.done=!0,n};return o.next=o}}throw new TypeError(i(e)+" is not iterable")}return v.prototype=x,o(A,"constructor",{value:x,configurable:!0}),o(x,"constructor",{value:v,configurable:!0}),v.displayName=d(x,h,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,x):(t.__proto__=x,d(t,h,"GeneratorFunction")),t.prototype=Object.create(A),t},e.awrap=function(t){return{__await:t}},E(k.prototype),d(k.prototype,l,function(){return this}),e.AsyncIterator=k,e.async=function(t,n,i,r,s){void 0===s&&(s=Promise);var o=new k(u(t,n,i,r),s);return e.isGeneratorFunction(n)?o:o.next().then(function(t){return t.done?t.value:o.next()})},E(A),d(A,h,"Generator"),d(A,c,function(){return this}),d(A,"toString",function(){return"[object Generator]"}),e.keys=function(t){var e=Object(t),n=[];for(var i in e)n.push(i);return n.reverse(),function t(){for(;n.length;){var i=n.pop();if(i in e)return t.value=i,t.done=!1,t}return t.done=!0,t}},e.values=z,O.prototype={constructor:O,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(D),!e)for(var n in this)"t"===n.charAt(0)&&s.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=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 n=this;function i(i,r){return a.type="throw",a.arg=e,n.next=i,r&&(n.method="next",n.arg=t),!!r}for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r],a=o.completion;if("root"===o.tryLoc)return i("end");if(o.tryLoc<=this.prev){var c=s.call(o,"catchLoc"),l=s.call(o,"finallyLoc");if(c&&l){if(this.prev<o.catchLoc)return i(o.catchLoc,!0);if(this.prev<o.finallyLoc)return i(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return i(o.catchLoc,!0)}else{if(!l)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return i(o.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&s.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var r=i;break}}r&&("break"===t||"continue"===t)&&r.tryLoc<=e&&e<=r.finallyLoc&&(r=null);var o=r?r.completion:{};return o.type=t,o.arg=e,r?(this.method="next",this.next=r.finallyLoc,b):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),b},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),D(n),b}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var i=n.completion;if("throw"===i.type){var r=i.arg;D(n)}return r}}throw new Error("illegal catch attempt")},delegateYield:function(e,n,i){return this.delegate={iterator:z(e),resultName:n,nextLoc:i},"next"===this.method&&(this.arg=t),b}},e}var s=t("./datetime"),o=t("./functions"),a=t("./utils"),c=t("./parser"),l=t("./signature"),h=function(){var t=r().mark(N),e=r().mark(H),n=r().mark(G),h=r().mark(V),d=r().mark(U),u=r().mark($),p=r().mark(W),f=r().mark(X),g=r().mark(st),m=r().mark(ct),y=r().mark(dt),b=r().mark(ut),_=r().mark(pt),v=r().mark(mt),x=r().mark(_t),w=r().mark(vt),M=r().mark(xt),S=r().mark(wt),A=r().mark(St),E=r().mark(Et),k=r().mark(Tt),C=r().mark(Ot),T=a.isNumeric,P=a.isArrayOfStrings,D=a.isArrayOfNumbers,O=a.createSequence,z=a.isSequence,L=a.isFunction,I=a.isLambda,R=a.isIterable,j=a.getFunctionArity,F=a.isDeepEqual,B=Lt(null);function N(e,n,i){var s,o,a,c;return r().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:(o=i.lookup("__evaluate_entry"))&&o(e,n,i),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(H(e,n,i),"t1",6);case 6:return s=t.t1,t.abrupt("break",50);case 8:return t.delegateYield(W(e,n,i),"t2",9);case 9:return s=t.t2,t.abrupt("break",50);case 11:return t.delegateYield(X(e,n,i),"t3",12);case 12:return s=t.t3,t.abrupt("break",50);case 14:return s=q(e,n),t.abrupt("break",50);case 16:return s=K(e),t.abrupt("break",50);case 18:return s=Q(e,n),t.abrupt("break",50);case 20:return s=J(e,n),t.abrupt("break",50);case 22:return s=i.lookup(e.slot.label),t.abrupt("break",50);case 24:return t.delegateYield(ut(e,n,i),"t4",25);case 25:return s=t.t4,t.abrupt("break",50);case 27:return t.delegateYield(pt(e,n,i),"t5",28);case 28:return s=t.t5,t.abrupt("break",50);case 30:return t.delegateYield(dt(e,n,i),"t6",31);case 31:return s=t.t6,t.abrupt("break",50);case 33:return s=ft(e),t.abrupt("break",50);case 35:return t.delegateYield(vt(e,n,i),"t7",36);case 36:return s=t.t7,t.abrupt("break",50);case 38:return s=gt(e,n,i),t.abrupt("break",50);case 40:return s=Mt(e,n,i),t.abrupt("break",50);case 42:return t.delegateYield(St(e,n,i),"t8",43);case 43:return s=t.t8,t.abrupt("break",50);case 45:return t.delegateYield(_t(e,n,i),"t9",46);case 46:return s=t.t9,t.abrupt("break",50);case 48:return s=yt(e,n,i),t.abrupt("break",50);case 50:if(!i.async||null!=s&&"function"==typeof s.then||(s=Promise.resolve(s)),!i.async||"function"!=typeof s.then||!e.nextFunction||"function"!=typeof s[e.nextFunction]){t.next=54;break}t.next=57;break;case 54:return t.next=56,s;case 56:s=t.sent;case 57:if(!Object.prototype.hasOwnProperty.call(e,"predicate")){t.next=65;break}a=0;case 59:if(!(a<e.predicate.length)){t.next=65;break}return t.delegateYield($(e.predicate[a].expr,s,i),"t10",61);case 61:s=t.t10;case 62:a++,t.next=59;break;case 65:if("path"===e.type||!Object.prototype.hasOwnProperty.call(e,"group")){t.next=68;break}return t.delegateYield(ct(e.group,s,i),"t11",67);case 67:s=t.t11;case 68:return(c=i.lookup("__evaluate_exit"))&&c(e,n,i,s),s&&z(s)&&!s.tupleStream&&(e.keepArray&&(s.keepSingleton=!0),0===s.length?s=void 0:1===s.length&&(s=s.keepSingleton?s:s[0])),t.abrupt("return",s);case 72:case"end":return t.stop()}},t)}function H(t,n,i){var s,o,a,c,l,h;return r().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:s=Array.isArray(n)&&"variable"!==t.steps[0].type?n:O(n),a=!1,c=void 0,l=0;case 4:if(!(l<t.steps.length)){e.next=25;break}if((h=t.steps[l]).tuple&&(a=!0),0!==l||!h.consarray){e.next=12;break}return e.delegateYield(N(h,s,i),"t0",9);case 9:o=e.t0,e.next=19;break;case 12:if(!a){e.next=17;break}return e.delegateYield(U(h,s,c,i),"t1",14);case 14:c=e.t1,e.next=19;break;case 17:return e.delegateYield(G(h,s,i,l===t.steps.length-1),"t2",18);case 18:o=e.t2;case 19:if(a||void 0!==o&&0!==o.length){e.next=21;break}return e.abrupt("break",25);case 21:void 0===h.focus&&(s=o);case 22:l++,e.next=4;break;case 25:if(a)if(t.tuple)o=c;else for(o=O(),l=0;l<c.length;l++)o.push(c[l]["@"]);if(t.keepSingletonArray&&(Array.isArray(o)&&o.cons&&!o.sequence&&(o=O(o)),o.keepSingleton=!0),!t.hasOwnProperty("group")){e.next=30;break}return e.delegateYield(ct(t.group,a?c:o,i),"t3",29);case 29:o=e.t3;case 30:return e.abrupt("return",o);case 31:case"end":return e.stop()}},e)}function Y(t,e){var n=Lt(t);for(var i in e)n.bind(i,e[i]);return n}function G(t,e,i,s){var o,a,c,l,h;return r().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:if("sort"!==t.type){n.next=7;break}return n.delegateYield(mt(t,e,i),"t0",2);case 2:if(o=n.t0,!t.stages){n.next=6;break}return n.delegateYield(V(t.stages,o,i),"t1",5);case 5:o=n.t1;case 6:return n.abrupt("return",o);case 7:o=O(),a=0;case 9:if(!(a<e.length)){n.next=24;break}return n.delegateYield(N(t,e[a],i),"t2",11);case 11:if(c=n.t2,!t.stages){n.next=20;break}l=0;case 14:if(!(l<t.stages.length)){n.next=20;break}return n.delegateYield($(t.stages[l].expr,c,i),"t3",16);case 16:c=n.t3;case 17:l++,n.next=14;break;case 20:void 0!==c&&o.push(c);case 21:a++,n.next=9;break;case 24:return h=O(),s&&1===o.length&&Array.isArray(o[0])&&!z(o[0])?h=o[0]:o.forEach(function(t){!Array.isArray(t)||t.cons?h.push(t):t.forEach(function(t){return h.push(t)})}),n.abrupt("return",h);case 27:case"end":return n.stop()}},n)}function V(t,e,n){var i,s,o,a;return r().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:i=e,s=0;case 2:if(!(s<t.length)){r.next=15;break}o=t[s],r.t0=o.type,r.next="filter"===r.t0?7:"index"===r.t0?10:12;break;case 7:return r.delegateYield($(o.expr,i,n),"t1",8);case 8:return i=r.t1,r.abrupt("break",12);case 10:for(a=0;a<i.length;a++)i[a][o.value]=a;return r.abrupt("break",12);case 12:s++,r.next=2;break;case 15:return r.abrupt("return",i);case 16:case"end":return r.stop()}},h)}function U(t,e,n,i){var s,o,a,c,l,h,u,p;return r().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:if("sort"!==t.type){r.next=15;break}if(!n){r.next=6;break}return r.delegateYield(mt(t,n,i),"t0",3);case 3:s=r.t0,r.next=11;break;case 6:return r.delegateYield(mt(t,e,i),"t1",7);case 7:for(o=r.t1,(s=O()).tupleStream=!0,a=0;a<o.length;a++)(c={"@":o[a]})[t.index]=a,s.push(c);case 11:if(!t.stages){r.next=14;break}return r.delegateYield(V(t.stages,s,i),"t2",13);case 13:s=r.t2;case 14:return r.abrupt("return",s);case 15:(s=O()).tupleStream=!0,l=i,void 0===n&&(n=e.map(function(t){return{"@":t}})),h=0;case 20:if(!(h<n.length)){r.next=28;break}return l=Y(i,n[h]),r.delegateYield(N(t,n[h]["@"],l),"t3",23);case 23:if(void 0!==(u=r.t3))for(Array.isArray(u)||(u=[u]),p=0;p<u.length;p++)c={},Object.assign(c,n[h]),u.tupleStream?Object.assign(c,u[p]):(t.focus?(c[t.focus]=u[p],c["@"]=n[h]["@"]):c["@"]=u[p],t.index&&(c[t.index]=p),t.ancestor&&(c[t.ancestor.label]=n[h]["@"])),s.push(c);case 25:h++,r.next=20;break;case 28:if(!t.stages){r.next=31;break}return r.delegateYield(V(t.stages,s,i),"t4",30);case 30:s=r.t4;case 31:return r.abrupt("return",s);case 32:case"end":return r.stop()}},d)}function $(t,e,n){var i,s,a,c,l,h;return r().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:if(i=O(),e&&e.tupleStream&&(i.tupleStream=!0),Array.isArray(e)||(e=O(e)),"number"!==t.type){r.next=10;break}(s=Math.floor(t.value))<0&&(s=e.length+s),void 0!==(a=e[s])&&(Array.isArray(a)?i=a:i.push(a)),r.next=23;break;case 10:s=0;case 11:if(!(s<e.length)){r.next=23;break}return a=e[s],c=a,l=n,e.tupleStream&&(c=a["@"],l=Y(n,a)),r.delegateYield(N(t,c,l),"t0",17);case 17:h=r.t0,T(h)&&(h=[h]),D(h)?h.forEach(function(t){var n=Math.floor(t);n<0&&(n=e.length+n),n===s&&i.push(a)}):o.boolean(h)&&i.push(a);case 20:s++,r.next=11;break;case 23:return r.abrupt("return",i);case 24:case"end":return r.stop()}},u)}function W(t,e,n){var i,s,o,a,c;return r().wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return l.delegateYield(N(t.lhs,e,n),"t0",1);case 1:if(s=l.t0,o=t.value,a=r().mark(function i(){return r().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:return i.delegateYield(N(t.rhs,e,n),"t0",1);case 1:return i.abrupt("return",i.t0);case 2:case"end":return i.stop()}},i)}),"and"!==o&&"or"!==o){l.next=15;break}return l.prev=5,l.delegateYield(st(s,a,o),"t1",7);case 7:return l.abrupt("return",l.t1);case 10:throw l.prev=10,l.t2=l.catch(5),l.t2.position=t.position,l.t2.token=o,l.t2;case 15:return l.delegateYield(a(),"t3",16);case 16:c=l.t3,l.prev=17,l.t4=o,l.next="+"===l.t4||"-"===l.t4||"*"===l.t4||"/"===l.t4||"%"===l.t4?21:"="===l.t4||"!="===l.t4?23:"<"===l.t4||"<="===l.t4||">"===l.t4||">="===l.t4?25:"&"===l.t4?27:".."===l.t4?29:"in"===l.t4?31:33;break;case 21:return i=et(s,c,o),l.abrupt("break",33);case 23:return i=nt(s,c,o),l.abrupt("break",33);case 25:return i=it(s,c,o),l.abrupt("break",33);case 27:return i=at(s,c),l.abrupt("break",33);case 29:return i=ht(s,c),l.abrupt("break",33);case 31:return i=rt(s,c),l.abrupt("break",33);case 33:l.next=40;break;case 35:throw l.prev=35,l.t5=l.catch(17),l.t5.position=t.position,l.t5.token=o,l.t5;case 40:return l.abrupt("return",i);case 41:case"end":return l.stop()}},p,null,[[5,10],[17,35]])}function X(t,e,n){var i,s,a,c;return r().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:r.t0=t.value,r.next="-"===r.t0?3:"["===r.t0?15:"{"===r.t0?27:30;break;case 3:return r.delegateYield(N(t.expression,e,n),"t1",4);case 4:if(void 0!==(i=r.t1)){r.next=9;break}i=void 0,r.next=14;break;case 9:if(!T(i)){r.next=13;break}i=-i,r.next=14;break;case 13:throw{code:"D1002",stack:(new Error).stack,position:t.position,token:t.value,value:i};case 14:return r.abrupt("break",30);case 15:i=[],s=0;case 17:if(!(s<t.expressions.length)){r.next=25;break}return a=t.expressions[s],r.delegateYield(N(a,e,n),"t2",20);case 20:void 0!==(c=r.t2)&&("["===a.value?i.push(c):i=o.append(i,c));case 22:s++,r.next=17;break;case 25:return t.consarray&&Object.defineProperty(i,"cons",{enumerable:!1,configurable:!1,value:!0}),r.abrupt("break",30);case 27:return r.delegateYield(ct(t,e,n),"t3",28);case 28:return i=r.t3,r.abrupt("break",30);case 30:return r.abrupt("return",i);case 31:case"end":return r.stop()}},f)}function q(t,e,n){return o.lookup(e,t.value)}function K(t){return t.value}function Q(t,e){var n=O();return Array.isArray(e)&&e.outerWrapper&&e.length>0&&(e=e[0]),null!==e&&"object"===i(e)&&Object.keys(e).forEach(function(t){var i=e[t];Array.isArray(i)?(i=Z(i),n=o.append(n,i)):n.push(i)}),n}function Z(t,e){return void 0===e&&(e=[]),Array.isArray(t)?t.forEach(function(t){Z(t,e)}):e.push(t),e}function J(t,e){var n,i=O();return void 0!==e&&(tt(e,i),n=1===i.length?i[0]:i),n}function tt(t,e){Array.isArray(t)||e.push(t),Array.isArray(t)?t.forEach(function(t){tt(t,e)}):null!==t&&"object"===i(t)&&Object.keys(t).forEach(function(n){tt(t[n],e)})}function et(t,e,n){var i;if(void 0!==t&&!T(t))throw{code:"T2001",stack:(new Error).stack,value:t};if(void 0!==e&&!T(e))throw{code:"T2002",stack:(new Error).stack,value:e};if(void 0===t||void 0===e)return i;switch(n){case"+":i=t+e;break;case"-":i=t-e;break;case"*":i=t*e;break;case"/":i=t/e;break;case"%":i=t%e}return i}function nt(t,e,n){var r,s=i(t),o=i(e);if("undefined"===s||"undefined"===o)return!1;switch(n){case"=":r=F(t,e);break;case"!=":r=!F(t,e)}return r}function it(t,e,n){var r,s=i(t),o=i(e);if("undefined"!==s&&"string"!==s&&"number"!==s||"undefined"!==o&&"string"!==o&&"number"!==o)throw{code:"T2010",stack:(new Error).stack,value:"string"!==s&&"number"!==s?t:e};if("undefined"!==s&&"undefined"!==o){if(s!==o)throw{code:"T2009",stack:(new Error).stack,value:t,value2:e};switch(n){case"<":r=t<e;break;case"<=":r=t<=e;break;case">":r=t>e;break;case">=":r=t>=e}return r}}function rt(t,e){var n=!1;if(void 0===t||void 0===e)return!1;Array.isArray(e)||(e=[e]);for(var i=0;i<e.length;i++)if(e[i]===t){n=!0;break}return n}function st(t,e,n){var i,s;return r().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:s=ot(t),r.t0=n,r.next="and"===r.t0?4:"or"===r.t0?12:20;break;case 4:if(r.t1=s,!r.t1){r.next=10;break}return r.t2=ot,r.delegateYield(e(),"t3",8);case 8:r.t4=r.t3,r.t1=(0,r.t2)(r.t4);case 10:return i=r.t1,r.abrupt("break",20);case 12:if(r.t5=s,r.t5){r.next=18;break}return r.t6=ot,r.delegateYield(e(),"t7",16);case 16:r.t8=r.t7,r.t5=(0,r.t6)(r.t8);case 18:return i=r.t5,r.abrupt("break",20);case 20:return r.abrupt("return",i);case 21:case"end":return r.stop()}},g)}function ot(t){var e=o.boolean(t);return void 0!==e&&e}function at(t,e){var n="",i="";return void 0!==t&&(n=o.string(t)),void 0!==e&&(i=o.string(e)),n.concat(i)}function ct(t,e,n){var i,s,a,c,l,h,d,u,p,f,g,y,b;return r().wrap(function(m){for(;;)switch(m.prev=m.next){case 0:i={},s={},a=!(!e||!e.tupleStream),Array.isArray(e)||(e=O(e)),0===e.length&&e.push(void 0),c=0;case 6:if(!(c<e.length)){m.next=31;break}l=e[c],h=a?Y(n,l):n,d=0;case 10:if(!(d<t.lhs.length)){m.next=28;break}return u=t.lhs[d],m.delegateYield(N(u[0],a?l["@"]:l,h),"t0",13);case 13:if("string"==typeof(p=m.t0)||void 0===p){m.next=16;break}throw{code:"T1003",stack:(new Error).stack,position:t.position,value:p};case 16:if(void 0===p){m.next=25;break}if(f={data:l,exprIndex:d},!s.hasOwnProperty(p)){m.next=24;break}if(s[p].exprIndex===d){m.next=21;break}throw{code:"D1009",stack:(new Error).stack,position:t.position,value:p};case 21:s[p].data=o.append(s[p].data,l),m.next=25;break;case 24:s[p]=f;case 25:d++,m.next=10;break;case 28:c++,m.next=6;break;case 31:m.t1=r().keys(s);case 32:if((m.t2=m.t1()).done){m.next=43;break}return p=m.t2.value,f=s[p],g=f.data,h=n,a&&(y=lt(f.data),g=y["@"],delete y["@"],h=Y(n,y)),m.delegateYield(N(t.lhs[f.exprIndex][1],g,h),"t3",39);case 39:void 0!==(b=m.t3)&&(i[p]=b),m.next=32;break;case 43:return m.abrupt("return",i);case 44:case"end":return m.stop()}},m)}function lt(t){if(!Array.isArray(t))return t;var e={};Object.assign(e,t[0]);for(var n=1;n<t.length;n++)for(var i in t[n])e[i]=o.append(e[i],t[n][i]);return e}function ht(t,e){var n;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 n;if(t>e)return n;var i=e-t+1;if(i>1e7)throw{code:"D2014",stack:(new Error).stack,value:i};n=new Array(i);for(var r=t,s=0;r<=e;r++,s++)n[s]=r;return n.sequence=!0,n}function dt(t,e,n){var i;return r().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:return r.delegateYield(N(t.rhs,e,n),"t0",1);case 1:return i=r.t0,n.bind(t.lhs.value,i),r.abrupt("return",i);case 4:case"end":return r.stop()}},y)}function ut(t,e,n){var i,s;return r().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:return r.delegateYield(N(t.condition,e,n),"t0",1);case 1:if(s=r.t0,!o.boolean(s)){r.next=7;break}return r.delegateYield(N(t.then,e,n),"t1",4);case 4:i=r.t1,r.next=10;break;case 7:if(void 0===t.else){r.next=10;break}return r.delegateYield(N(t.else,e,n),"t2",9);case 9:i=r.t2;case 10:return r.abrupt("return",i);case 11:case"end":return r.stop()}},b)}function pt(t,e,n){var i,s,o;return r().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:s=Lt(n),o=0;case 2:if(!(o<t.expressions.length)){r.next=8;break}return r.delegateYield(N(t.expressions[o],e,s),"t0",4);case 4:i=r.t0;case 5:o++,r.next=2;break;case 8:return r.abrupt("return",i);case 9:case"end":return r.stop()}},_)}function ft(t){var e=new jt.RegexEngine(t.value),n=function n(i,r){var s;e.lastIndex=r||0;var o=e.exec(i);if(null!==o){if(s={match:o[0],start:o.index,end:o.index+o[0].length,groups:[]},o.length>1)for(var a=1;a<o.length;a++)s.groups.push(o[a]);s.next=function(){if(!(e.lastIndex>=i.length)){var r=n(i,e.lastIndex);if(r&&""===r.match)throw{code:"D1004",stack:(new Error).stack,position:t.position,value:t.value.source};return r}}}return s};return n}function gt(t,e,n){return""===t.value?e&&e.outerWrapper?e[0]:e:n.lookup(t.value)}function mt(t,e,n){var s,a,c,l,h;return r().wrap(function(d){for(;;)switch(d.prev=d.next){case 0:return a=e,c=!!e.tupleStream,l=r().mark(function e(s,o){var a,l,h,d,u,p,f,g,m;return r().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:a=0,l=0;case 2:if(!(0===a&&l<t.terms.length)){e.next=35;break}return h=t.terms[l],d=s,u=n,c&&(d=s["@"],u=Y(n,s)),e.delegateYield(N(h.expression,d,u),"t0",8);case 8:return p=e.t0,d=o,u=n,c&&(d=o["@"],u=Y(n,o)),e.delegateYield(N(h.expression,d,u),"t1",13);case 13:if(f=e.t1,g=i(p),m=i(f),"undefined"!==g){e.next=19;break}return a="undefined"===m?0:1,e.abrupt("continue",32);case 19:if("undefined"!==m){e.next=22;break}return a=-1,e.abrupt("continue",32);case 22:if(!("string"!==g&&"number"!==g||"string"!==m&&"number"!==m)){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===m){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:a=p<f?-1:1;case 31:!0===h.descending&&(a=-a);case 32:l++,e.next=2;break;case 35:return e.abrupt("return",1===a);case 36:case"end":return e.stop()}},e)}),h={environment:n,input:e},d.delegateYield(o.sort.apply(h,[a,l]),"t0",5);case 5:return s=d.t0,d.abrupt("return",s);case 7:case"end":return d.stop()}},v)}function yt(t,e,n){var s=r().mark(function e(s){var o,a,c,l,h,d,u,p,f,g,m;return r().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==s){e.next=2;break}return e.abrupt("return",void 0);case 2:if(o=n.lookup("clone"),L(o)){e.next=5;break}throw{code:"T2013",stack:(new Error).stack,position:t.position};case 5:return e.delegateYield(xt(o,[s],null,n),"t0",6);case 6:return a=e.t0,e.delegateYield(N(t.pattern,a,n),"t1",8);case 8:if(void 0===(c=e.t1)){e.next=35;break}Array.isArray(c)||(c=[c]),l=0;case 12:if(!(l<c.length)){e.next=35;break}if(!(h=c[l])||!(h.isPrototypeOf(a)||h instanceof Object.constructor)){e.next=16;break}throw{code:"D1010",stack:(new Error).stack,position:t.position};case 16:return e.delegateYield(N(t.update,h,n),"t2",17);case 17:if(d=e.t2,"undefined"===(u=i(d))){e.next=23;break}if("object"===u&&null!==d&&!Array.isArray(d)){e.next=22;break}throw{code:"T2011",stack:(new Error).stack,position:t.update.position,value:d};case 22:for(p in d)h[p]=d[p];case 23:if(void 0===t.delete){e.next=32;break}return e.delegateYield(N(t.delete,h,n),"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(m=0;m<f.length;m++)"object"===i(h)&&null!==h&&delete h[f[m]];case 32:l++,e.next=12;break;case 35:return e.abrupt("return",a);case 36:case"end":return e.stop()}},e)});return Dt(s,"<(oa):o>")}var bt=c("function($f, $g) { function($x){ $g($f($x)) } }");function _t(t,e,n){var i,s,o,a;return r().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:return r.delegateYield(N(t.lhs,e,n),"t0",1);case 1:if(s=r.t0,"function"!==t.rhs.type){r.next=7;break}return r.delegateYield(vt(t.rhs,e,n,{context:s}),"t1",4);case 4:i=r.t1,r.next=20;break;case 7:return r.delegateYield(N(t.rhs,e,n),"t2",8);case 8:if(o=r.t2,L(o)){r.next=11;break}throw{code:"T2006",stack:(new Error).stack,position:t.position,value:o};case 11:if(!L(s)){r.next=18;break}return r.delegateYield(N(bt,null,n),"t3",13);case 13:return a=r.t3,r.delegateYield(xt(a,[s,o],null,n),"t4",15);case 15:i=r.t4,r.next=20;break;case 18:return r.delegateYield(xt(o,[s],null,n),"t5",19);case 19:i=r.t5;case 20:return r.abrupt("return",i);case 21:case"end":return r.stop()}},x)}function vt(t,e,n,s){var o,a,c,l,h,d;return r().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.delegateYield(N(t.procedure,e,n),"t0",1);case 1:if(void 0!==(a=u.t0)||"path"!==t.procedure.type||!n.lookup(t.procedure.steps[0].value)){u.next=4;break}throw{code:"T1005",stack:(new Error).stack,position:t.position,token:t.procedure.steps[0].value};case 4:c=[],void 0!==s&&c.push(s.context),l=r().mark(function i(){var s,o;return r().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:return i.delegateYield(N(t.arguments[h],e,n),"t0",1);case 1:s=i.t0,L(s)?(o=r().mark(function t(){var e,i,o,a=arguments;return r().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:for(e=a.length,i=new Array(e),o=0;o<e;o++)i[o]=a[o];return t.delegateYield(xt(s,i,null,n),"t0",2);case 2:return t.abrupt("return",t.t0);case 3:case"end":return t.stop()}},t)}),o.arity=j(s),c.push(o)):c.push(s);case 3:case"end":return i.stop()}},i)}),h=0;case 8:if(!(h<t.arguments.length)){u.next=13;break}return u.delegateYield(l(),"t1",10);case 10:h++,u.next=8;break;case 13:return d="path"===t.procedure.type?t.procedure.steps[0].value:t.procedure.value,u.prev=14,"object"===i(a)&&(a.token=d,a.position=t.position),u.delegateYield(xt(a,c,e,n),"t2",17);case 17:o=u.t2,u.next=25;break;case 20:throw u.prev=20,u.t3=u.catch(14),u.t3.position||(u.t3.position=t.position),u.t3.token||(u.t3.token=d),u.t3;case 25:return u.abrupt("return",o);case 26:case"end":return u.stop()}},w,null,[[14,20]])}function xt(t,e,n,i){var s,o,a,c;return r().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:return r.delegateYield(wt(t,e,n,i),"t0",1);case 1:s=r.t0;case 2:if(!I(s)||!0!==s.thunk){r.next=21;break}return r.delegateYield(N(s.body.procedure,s.input,s.environment),"t1",4);case 4:o=r.t1,"variable"===s.body.procedure.type&&(o.token=s.body.procedure.value),o.position=s.body.procedure.position,a=[],c=0;case 9:if(!(c<s.body.arguments.length)){r.next=17;break}return r.t2=a,r.delegateYield(N(s.body.arguments[c],s.input,s.environment),"t3",12);case 12:r.t4=r.t3,r.t2.push.call(r.t2,r.t4);case 14:c++,r.next=9;break;case 17:return r.delegateYield(wt(o,a,n,i),"t5",18);case 18:s=r.t5,r.next=2;break;case 21:return r.abrupt("return",s);case 22:case"end":return r.stop()}},M)}function wt(t,e,n,i){var s,o,a;return r().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:if(r.prev=0,o=e,t&&(o=At(t.signature,e,n)),!I(t)){r.next=8;break}return r.delegateYield(Et(t,o),"t0",5);case 5:s=r.t0,r.next=24;break;case 8:if(!t||!0!==t._jsonata_function){r.next=16;break}if(a={environment:i,input:n},s=t.implementation.apply(a,o),!R(s)){r.next=14;break}return r.delegateYield(s,"t1",13);case 13:s=r.t1;case 14:r.next=24;break;case 16:if("function"!=typeof t){r.next=23;break}if(s=t.apply(n,o),!R(s)){r.next=21;break}return r.delegateYield(s,"t2",20);case 20:s=r.t2;case 21:r.next=24;break;case 23:throw{code:"T1006",stack:(new Error).stack};case 24:r.next=30;break;case 26:throw r.prev=26,r.t3=r.catch(0),t&&(void 0===r.t3.token&&void 0!==t.token&&(r.t3.token=t.token),r.t3.position=t.position||r.t3.position),r.t3;case 30:return r.abrupt("return",s);case 31:case"end":return r.stop()}},S,null,[[0,26]])}function Mt(t,e,n){var i={_jsonata_lambda:!0,input:e,environment:n,arguments:t.arguments,signature:t.signature,body:t.body};return!0===t.thunk&&(i.thunk=!0),i.apply=r().mark(function t(n,s){return r().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.delegateYield(xt(i,s,e,n.environment),"t0",1);case 1:return t.abrupt("return",t.t0);case 2:case"end":return t.stop()}},t)}),i}function St(t,e,n){var i,s,o,a,c;return r().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:s=[],o=0;case 2:if(!(o<t.arguments.length)){r.next=15;break}if("operator"!==(a=t.arguments[o]).type||"?"!==a.value){r.next=8;break}s.push(a),r.next=12;break;case 8:return r.t0=s,r.delegateYield(N(a,e,n),"t1",10);case 10:r.t2=r.t1,r.t0.push.call(r.t0,r.t2);case 12:o++,r.next=2;break;case 15:return r.delegateYield(N(t.procedure,e,n),"t3",16);case 16:if(void 0!==(c=r.t3)||"path"!==t.procedure.type||!n.lookup(t.procedure.steps[0].value)){r.next=19;break}throw{code:"T1007",stack:(new Error).stack,position:t.position,token:t.procedure.steps[0].value};case 19:if(!I(c)){r.next=23;break}i=kt(c,s),r.next=32;break;case 23:if(!c||!0!==c._jsonata_function){r.next=27;break}i=Ct(c.implementation,s),r.next=32;break;case 27:if("function"!=typeof c){r.next=31;break}i=Ct(c,s),r.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 r.abrupt("return",i);case 33:case"end":return r.stop()}},A)}function At(t,e,n){return void 0===t?e:t.validate(e,n)}function Et(t,e){var n,i;return r().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:if(i=Lt(t.environment),t.arguments.forEach(function(t,n){i.bind(t.value,e[n])}),"function"!=typeof t.body){r.next=7;break}return r.delegateYield(Tt(t.body,i),"t0",4);case 4:n=r.t0,r.next=9;break;case 7:return r.delegateYield(N(t.body,t.input,i),"t1",8);case 8:n=r.t1;case 9:return r.abrupt("return",n);case 10:case"end":return r.stop()}},E)}function kt(t,e){var n=Lt(t.environment),i=[];return t.arguments.forEach(function(t,r){var s=e[r];s&&"operator"===s.type&&"?"===s.value?i.push(t):n.bind(t.value,s)}),{_jsonata_lambda:!0,input:t.input,environment:n,arguments:i,body:t.body}}function Ct(t,e){var n=Pt(t),i="function("+(n=n.map(function(t){return"$"+t.trim()})).join(", ")+"){ _ }",r=c(i);return r.body=t,kt(r,e)}function Tt(t,e){var n,i,s,o;return r().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:if(n=Pt(t),i=n.map(function(t){return e.lookup(t.trim())}),s={environment:e},o=t.apply(s,i),!R(o)){r.next=7;break}return r.delegateYield(o,"t0",6);case 6:o=r.t0;case 7:return r.abrupt("return",o);case 8:case"end":return r.stop()}},k)}function Pt(t){var e=t.toString();return/\(([^)]*)\)/.exec(e)[1].split(",")}function Dt(t,e){var n={_jsonata_function:!0,implementation:t};return void 0!==e&&(n.signature=l(e)),n}function Ot(t,e){var n,i,s;return r().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:n=this.input,void 0!==e&&(n=e,Array.isArray(n)&&!z(n)&&((n=O(n)).outerWrapper=!0)),r.prev=4,i=c(t,!1),r.next=12;break;case 8:throw r.prev=8,r.t0=r.catch(4),Rt(r.t0),{stack:(new Error).stack,code:"D3120",value:r.t0.message,error:r.t0};case 12:return r.prev=12,r.delegateYield(N(i,n,this.environment),"t1",14);case 14:s=r.t1,r.next=21;break;case 17:throw r.prev=17,r.t2=r.catch(12),Rt(r.t2),{stack:(new Error).stack,code:"D3121",value:r.t2.message,error:r.t2};case 21:return r.abrupt("return",s);case 22:case"end":return r.stop()}},C,this,[[4,8],[12,17]])}function zt(t){if(void 0!==t)return JSON.parse(o.string(t))}function Lt(t){var e={};return{bind:function(t,n){e[t]=n},lookup:function(n){var i;return e.hasOwnProperty(n)?i=e[n]:t&&(i=t.lookup(n)),i},timestamp:t?t.timestamp:null,async:!!t&&t.async,global:t?t.global:{ancestry:[null]}}}B.bind("sum",Dt(o.sum,"<a<n>:n>")),B.bind("count",Dt(o.count,"<a:n>")),B.bind("max",Dt(o.max,"<a<n>:n>")),B.bind("min",Dt(o.min,"<a<n>:n>")),B.bind("average",Dt(o.average,"<a<n>:n>")),B.bind("string",Dt(o.string,"<x-b?:s>")),B.bind("substring",Dt(o.substring,"<s-nn?:s>")),B.bind("substringBefore",Dt(o.substringBefore,"<s-s:s>")),B.bind("substringAfter",Dt(o.substringAfter,"<s-s:s>")),B.bind("lowercase",Dt(o.lowercase,"<s-:s>")),B.bind("uppercase",Dt(o.uppercase,"<s-:s>")),B.bind("length",Dt(o.length,"<s-:n>")),B.bind("trim",Dt(o.trim,"<s-:s>")),B.bind("pad",Dt(o.pad,"<s-ns?:s>")),B.bind("match",Dt(o.match,"<s-f<s:o>n?:a<o>>")),B.bind("contains",Dt(o.contains,"<s-(sf):b>")),B.bind("replace",Dt(o.replace,"<s-(sf)(sf)n?:s>")),B.bind("split",Dt(o.split,"<s-(sf)n?:a<s>>")),B.bind("join",Dt(o.join,"<a<s>s?:s>")),B.bind("formatNumber",Dt(o.formatNumber,"<n-so?:s>")),B.bind("formatBase",Dt(o.formatBase,"<n-n?:s>")),B.bind("formatInteger",Dt(s.formatInteger,"<n-s:s>")),B.bind("parseInteger",Dt(s.parseInteger,"<s-s:n>")),B.bind("number",Dt(o.number,"<(nsb)-:n>")),B.bind("floor",Dt(o.floor,"<n-:n>")),B.bind("ceil",Dt(o.ceil,"<n-:n>")),B.bind("round",Dt(o.round,"<n-n?:n>")),B.bind("abs",Dt(o.abs,"<n-:n>")),B.bind("sqrt",Dt(o.sqrt,"<n-:n>")),B.bind("power",Dt(o.power,"<n-n:n>")),B.bind("random",Dt(o.random,"<:n>")),B.bind("boolean",Dt(o.boolean,"<x-:b>")),B.bind("not",Dt(o.not,"<x-:b>")),B.bind("map",Dt(o.map,"<af>")),B.bind("zip",Dt(o.zip,"<a+>")),B.bind("filter",Dt(o.filter,"<af>")),B.bind("single",Dt(o.single,"<af?>")),B.bind("reduce",Dt(o.foldLeft,"<afj?:j>")),B.bind("sift",Dt(o.sift,"<o-f?:o>")),B.bind("keys",Dt(o.keys,"<x-:a<s>>")),B.bind("lookup",Dt(o.lookup,"<x-s:x>")),B.bind("append",Dt(o.append,"<xx:a>")),B.bind("exists",Dt(o.exists,"<x:b>")),B.bind("spread",Dt(o.spread,"<x-:a<o>>")),B.bind("merge",Dt(o.merge,"<a<o>:o>")),B.bind("reverse",Dt(o.reverse,"<a:a>")),B.bind("each",Dt(o.each,"<o-f:a>")),B.bind("error",Dt(o.error,"<s?:x>")),B.bind("assert",Dt(o.assert,"<bs?:x>")),B.bind("type",Dt(o.type,"<x:s>")),B.bind("sort",Dt(o.sort,"<af?:a>")),B.bind("shuffle",Dt(o.shuffle,"<a:a>")),B.bind("distinct",Dt(o.distinct,"<x:x>")),B.bind("base64encode",Dt(o.base64encode,"<s-:s>")),B.bind("base64decode",Dt(o.base64decode,"<s-:s>")),B.bind("encodeUrlComponent",Dt(o.encodeUrlComponent,"<s-:s>")),B.bind("encodeUrl",Dt(o.encodeUrl,"<s-:s>")),B.bind("decodeUrlComponent",Dt(o.decodeUrlComponent,"<s-:s>")),B.bind("decodeUrl",Dt(o.decodeUrl,"<s-:s>")),B.bind("eval",Dt(Ot,"<sx?:x>")),B.bind("toMillis",Dt(s.toMillis,"<s-s?:n>")),B.bind("fromMillis",Dt(s.fromMillis,"<n-s?s?:s>")),B.bind("clone",Dt(zt,"<(oa)-:o>"));var It={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 Rt(t){var e=It[t.code];if(void 0!==e){var n=e.replace(/\{\{\{([^}]+)}}}/g,function(){return t[arguments[1]]});n=n.replace(/\{\{([^}]+)}}/g,function(){return JSON.stringify(t[arguments[1]])}),t.message=n}}function jt(t,e){var n,i;try{n=c(t,e&&e.recover),i=n.errors,delete n.errors}catch(t){throw Rt(t),t}var r=Lt(B),o=new Date;return r.bind("now",Dt(function(t,e){return s.fromMillis(o.getTime(),t,e)},"<s?s?:s>")),r.bind("millis",Dt(function(){return o.getTime()},"<:n>")),e&&e.RegexEngine?jt.RegexEngine=e.RegexEngine:jt.RegexEngine=RegExp,{evaluate:function(t,e,s){if(void 0!==i){var a={code:"S0500",position:0};throw Rt(a),a}var c,l,h;if(void 0!==e)for(var d in c=Lt(r),e)c.bind(d,e[d]);else c=r;if(c.bind("$",t),o=new Date,c.timestamp=o,Array.isArray(t)&&!z(t)&&((t=O(t)).outerWrapper=!0),"function"==typeof s){c.async=!0;var u=function(t){Rt(t),s(t,null)},p=function t(e){(l=h.next(e)).done?s(null,l.value):l.value.then(t).catch(u)};h=N(n,t,c),(l=h.next()).value.then(p).catch(u)}else try{for(h=N(n,t,c),l=h.next();!l.done;)l=h.next(l.value);return l.value}catch(a){throw Rt(a),a}},assign:function(t,e){r.bind(t,e)},registerFunction:function(t,e,n){var i=Dt(e,n);r.bind(t,i)},ast:function(){return n},errors:function(){return i}}}return jt.parser=c,jt}();e.exports=h},{"./datetime":1,"./functions":2,"./parser":4,"./signature":5,"./utils":6}],4:[function(t,e,n){var i=t("./signature"),r=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"},n=function(n){var i=0,r=n.length,s=function(t,e){return{type:t,value:e,position:i}},o=function(){for(var t,e,s=i,o=0;i<r;){var a=n.charAt(i);if("/"===a&&"\\"!==n.charAt(i-1)&&0===o){if(""===(t=n.substring(s,i)))throw{code:"S0301",stack:(new Error).stack,position:i};for(i++,a=n.charAt(i),s=i;"i"===a||"m"===a;)i++,a=n.charAt(i);return e=n.substring(s,i)+"g",new RegExp(t,e)}"("!==a&&"["!==a&&"{"!==a||"\\"===n.charAt(i-1)||o++,")"!==a&&"]"!==a&&"}"!==a||"\\"===n.charAt(i-1)||o--,i++}throw{code:"S0302",stack:(new Error).stack,position:i}},a=function a(c){if(i>=r)return null;for(var l=n.charAt(i);i<r&&" \t\n\r\v".indexOf(l)>-1;)i++,l=n.charAt(i);if("/"===l&&"*"===n.charAt(i+1)){var h=i;for(i+=2,l=n.charAt(i);"*"!==l||"/"!==n.charAt(i+1);)if(l=n.charAt(++i),i>=r)throw{code:"S0106",stack:(new Error).stack,position:h};return i+=2,l=n.charAt(i),a(c)}if(!0!==c&&"/"===l)return i++,s("regex",o());if("."===l&&"."===n.charAt(i+1))return i+=2,s("operator","..");if(":"===l&&"="===n.charAt(i+1))return i+=2,s("operator",":=");if("!"===l&&"="===n.charAt(i+1))return i+=2,s("operator","!=");if(">"===l&&"="===n.charAt(i+1))return i+=2,s("operator",">=");if("<"===l&&"="===n.charAt(i+1))return i+=2,s("operator","<=");if("*"===l&&"*"===n.charAt(i+1))return i+=2,s("operator","**");if("~"===l&&">"===n.charAt(i+1))return i+=2,s("operator","~>");if(Object.prototype.hasOwnProperty.call(t,l))return i++,s("operator",l);if('"'===l||"'"===l){var d=l;i++;for(var u="";i<r;){if("\\"===(l=n.charAt(i)))if(i++,l=n.charAt(i),Object.prototype.hasOwnProperty.call(e,l))u+=e[l];else{if("u"!==l)throw{code:"S0103",stack:(new Error).stack,position:i,token:l};var p=n.substr(i+1,4);if(!/^[0-9a-fA-F]+$/.test(p))throw{code:"S0104",stack:(new Error).stack,position:i};var f=parseInt(p,16);u+=String.fromCharCode(f),i+=4}else{if(l===d)return i++,s("string",u);u+=l}i++}throw{code:"S0101",stack:(new Error).stack,position:i}}var g,m=/^-?(0|([1-9][0-9]*))(\.[0-9]+)?([Ee][-+]?[0-9]+)?/.exec(n.substring(i));if(null!==m){var y=parseFloat(m[0]);if(!isNaN(y)&&isFinite(y))return i+=m[0].length,s("number",y);throw{code:"S0102",stack:(new Error).stack,position:i,token:m[0]}}if("`"===l){i++;var b=n.indexOf("`",i);if(-1!==b)return g=n.substring(i,b),i=b+1,s("name",g);throw i=r,{code:"S0105",stack:(new Error).stack,position:i}}for(var _,v=i;;)if(_=n.charAt(v),v===r||" \t\n\r\v".indexOf(_)>-1||Object.prototype.hasOwnProperty.call(t,_)){if("$"===n.charAt(i))return g=n.substring(i+1,v),i=v,s("variable",g);switch(g=n.substring(i,v),i=v,g){case"or":case"in":case"and":return s("operator",g);case"true":return s("value",!0);case"false":return s("value",!1);case"null":return s("value",null);default:return i===r&&""===g?null:s("name",g)}}else v++};return a},r=function(e,r){var s,o,a={},c=[],l=function(){var t=[];"(end)"!==s.id&&t.push({type:s.type,value:s.value,position:s.position});for(var e=o();null!==e;)t.push(e),e=o();return t},h={nud:function(){var t={code:"S0211",token:this.value,position:this.position};if(r)return t.remaining=l(),t.type="error",c.push(t),t;throw t.stack=(new Error).stack,t}},d=function(t,e){var n=a[t];return e=e||0,n?e>=n.lbp&&(n.lbp=e):((n=Object.create(h)).id=n.value=t,n.lbp=e,a[t]=n),n},u=function(t){if(r){t.remaining=l(),c.push(t);var e=a["(error)"];return(s=Object.create(e)).error=t,s.type="(error)",s}throw t.stack=(new Error).stack,t},p=function(t,n){if(t&&s.id!==t){var i={code:"(end)"===s.id?"S0203":"S0202",position:s.position,token:s.value,value:t};return u(i)}var r=o(n);if(null===r)return(s=a["(end)"]).position=e.length,s;var c,l=r.value,h=r.type;switch(h){case"name":case"variable":c=a["(name)"];break;case"operator":if(!(c=a[l]))return u({code:"S0204",stack:(new Error).stack,position:r.position,token:l});break;case"string":case"number":case"value":c=a["(literal)"];break;case"regex":h="regex",c=a["(regex)"];break;default:return u({code:"S0205",stack:(new Error).stack,position:r.position,token:l})}return(s=Object.create(c)).value=l,s.type=h,s.position=r.position,s},f=function(t){var e,n=s;for(p(null,!0),e=n.nud();t<s.lbp;)n=s,p(),e=n.led(e);return e},g=function(t){d(t,0).nud=function(){return this}},m=function(e,n,i){var r=n||t[e],s=d(e,r);return s.led=i||function(t){return this.lhs=t,this.rhs=f(r),this.type="binary",this},s},y=function(t,e,n){var i=d(t,e);return i.led=n,i},b=function(t,e){var n=d(t);return n.nud=e||function(){return this.expression=f(70),this.type="unary",this},n};g("(end)"),g("(name)"),g("(literal)"),g("(regex)"),d(":"),d(";"),d(","),d(")"),d("]"),d("}"),d(".."),m("."),m("+"),m("-"),m("*"),m("/"),m("%"),m("="),m("<"),m(">"),m("!="),m("<="),m(">="),m("&"),m("and"),m("or"),m("in"),g("and"),g("or"),g("in"),b("-"),m("~>"),y("(error)",10,function(t){return this.lhs=t,this.error=s.error,this.remaining=l(),this.type="error",this}),b("*",function(){return this.type="wildcard",this}),b("**",function(){return this.type="descendant",this}),b("%",function(){return this.type="parent",this}),m("(",t["("],function(t){if(this.procedure=t,this.type="function",this.arguments=[],")"!==s.id)for(;"operator"===s.type&&"?"===s.id?(this.type="partial",this.arguments.push(s),p("?")):this.arguments.push(f(0)),","===s.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 u({code:"S0208",stack:(new Error).stack,position:t.position,token:t.value,value:e+1})}),this.type="lambda","<"===s.id){for(var e=s.position,n=1,r="<";n>0&&"{"!==s.id&&"(end)"!==s.id;){var o=p();">"===o.id?n--:"<"===o.id&&n++,r+=o.value}p(">");try{this.signature=i(r)}catch(t){return t.position=e+t.offset,u(t)}}p("{"),this.body=f(0),p("}")}return this}),b("(",function(){for(var t=[];")"!==s.id&&(t.push(f(0)),";"===s.id);)p(";");return p(")",!0),this.type="block",this.expressions=t,this}),b("[",function(){var t=[];if("]"!==s.id)for(;;){var e=f(0);if(".."===s.id){var n={type:"binary",value:"..",position:s.position,lhs:e};p(".."),n.rhs=f(0),e=n}if(t.push(e),","!==s.id)break;p(",")}return p("]",!0),this.expressions=t,this.type="unary",this}),m("[",t["["],function(e){if("]"===s.id){for(var n=e;n&&"binary"===n.type&&"["===n.value;)n=n.lhs;return n.keepArray=!0,p("]"),e}return this.lhs=e,this.rhs=f(t["]"]),this.type="binary",p("]",!0),this}),m("^",t["^"],function(t){p("(");for(var e=[];;){var n={descending:!1};if("<"===s.id?p("<"):">"===s.id&&(n.descending=!0,p(">")),n.expression=f(0),e.push(n),","!==s.id)break;p(",")}return p(")"),this.lhs=t,this.rhs=e,this.type="binary",this});var _=function(t){var e=[];if("}"!==s.id)for(;;){var n=f(0);p(":");var i=f(0);if(e.push([n,i]),","!==s.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};b("{",_),m("{",t["{"],_),y(":=",t[":="],function(e){return"variable"!==e.type?u({code:"S0212",stack:(new Error).stack,position:e.position,token:e.value}):(this.lhs=e,this.rhs=f(t[":="]-1),this.type="binary",this)}),m("@",t["@"],function(e){return this.lhs=e,this.rhs=f(t["@"]),"variable"!==this.rhs.type?u({code:"S0214",stack:(new Error).stack,position:this.rhs.position,token:"@"}):(this.type="binary",this)}),m("#",t["#"],function(e){return this.lhs=e,this.rhs=f(t["#"]),"variable"!==this.rhs.type?u({code:"S0214",stack:(new Error).stack,position:this.rhs.position,token:"#"}):(this.type="binary",this)}),m("?",t["?"],function(t){return this.type="condition",this.condition=t,this.then=f(0),":"===s.id&&(p(":"),this.else=f(0)),this}),b("|",function(){return this.type="transform",this.pattern=f(0),p("|"),this.update=f(0),","===s.id&&(p(","),this.delete=f(0)),p("|"),this});var v=function t(e){var n;if("function"!==e.type||e.predicate)if("condition"===e.type)e.then=t(e.then),void 0!==e.else&&(e.else=t(e.else)),n=e;else if("block"===e.type){var i=e.expressions.length;i>0&&(e.expressions[i-1]=t(e.expressions[i-1])),n=e}else n=e;else{var r={type:"lambda",thunk:!0,arguments:[],position:e.position};r.body=e,n=r}return n},x=0,w=0,M=[],S=function t(e,n){switch(e.type){case"name":case"wildcard":n.level--,0===n.level&&(void 0===e.ancestor||(M[n.index].slot.label=e.ancestor.label),e.ancestor=n,e.tuple=!0);break;case"parent":n.level++;break;case"block":e.expressions.length>0&&(e.tuple=!0,n=t(e.expressions[e.expressions.length-1],n));break;case"path":e.tuple=!0;var i=e.steps.length-1;for(n=t(e.steps[i--],n);n.level>0&&i>=0;)n=t(e.steps[i--],n);break;default:throw{code:"S0217",token:e.type,position:e.position}}return n},A=function(t,e){if(void 0!==e.seekingParent||"parent"===e.type){var n=void 0!==e.seekingParent?e.seekingParent:[];"parent"===e.type&&n.push(e.slot),void 0===t.seekingParent?t.seekingParent=n:Array.prototype.push.apply(t.seekingParent,n)}},E=function(t){var e=t.steps.length-1,n=t.steps[e],i=void 0!==n.seekingParent?n.seekingParent:[];"parent"===n.type&&i.push(n.slot);for(var r=0;r<i.length;r++){var s=i[r];for(e=t.steps.length-2;s.level>0;){if(e<0){void 0===t.seekingParent?t.seekingParent=[s]:t.seekingParent.push(s);break}for(var o=t.steps[e--];e>=0&&o.focus&&t.steps[e].focus;)o=t.steps[e--];s=S(o,s)}}},k=function t(e){var n;switch(e.type){case"binary":switch(e.value){case".":var i=t(e.lhs);n="path"===i.type?i:{type:"path",steps:[i]},"parent"===i.type&&(n.seekingParent=[i.slot]);var s=t(e.rhs);"function"===s.type&&"path"===s.procedure.type&&1===s.procedure.steps.length&&"name"===s.procedure.steps[0].type&&"function"===n.steps[n.steps.length-1].type&&(n.steps[n.steps.length-1].nextFunction=s.procedure.steps[0].value),"path"===s.type?Array.prototype.push.apply(n.steps,s.steps):(void 0!==s.predicate&&(s.stages=s.predicate,delete s.predicate),n.steps.push(s)),n.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"}),n.steps.filter(function(t){return!0===t.keepArray}).length>0&&(n.keepSingletonArray=!0);var o=n.steps[0];"unary"===o.type&&"["===o.value&&(o.consarray=!0);var a=n.steps[n.steps.length-1];"unary"===a.type&&"["===a.value&&(a.consarray=!0),E(n);break;case"[":var l=n=t(e.lhs),h="predicate";if("path"===n.type&&(l=n.steps[n.steps.length-1],h="stages"),void 0!==l.group)throw{code:"S0209",stack:(new Error).stack,position:e.position};void 0===l[h]&&(l[h]=[]);var d=t(e.rhs);void 0!==d.seekingParent&&(d.seekingParent.forEach(function(t){1===t.level?S(l,t):t.level--}),A(l,d)),l[h].push({type:"filter",expr:d,position:e.position});break;case"{":if(void 0!==(n=t(e.lhs)).group)throw{code:"S0210",stack:(new Error).stack,position:e.position};n.group={lhs:e.rhs.map(function(e){return[t(e[0]),t(e[1])]}),position:e.position};break;case"^":"path"!==(n=t(e.lhs)).type&&(n={type:"path",steps:[n]});var u={type:"sort",position:e.position};u.terms=e.rhs.map(function(e){var n=t(e.expression);return A(u,n),{descending:e.descending,expression:n}}),n.steps.push(u),E(n);break;case":=":(n={type:"bind",value:e.value,position:e.position}).lhs=t(e.lhs),n.rhs=t(e.rhs),A(n,n.rhs);break;case"@":if(n=t(e.lhs),l=n,"path"===n.type&&(l=n.steps[n.steps.length-1]),void 0!==l.stages||void 0!==l.predicate)throw{code:"S0215",stack:(new Error).stack,position:e.position};if("sort"===l.type)throw{code:"S0216",stack:(new Error).stack,position:e.position};e.keepArray&&(l.keepArray=!0),l.focus=e.rhs.value,l.tuple=!0;break;case"#":n=t(e.lhs),l=n,"path"===n.type?l=n.steps[n.steps.length-1]:(n={type:"path",steps:[n]},void 0!==l.predicate&&(l.stages=l.predicate,delete l.predicate)),void 0===l.stages?l.index=e.rhs.value:l.stages.push({type:"index",value:e.rhs.value,position:e.position}),l.tuple=!0;break;case"~>":(n={type:"apply",value:e.value,position:e.position}).lhs=t(e.lhs),n.rhs=t(e.rhs);break;default:(n={type:e.type,value:e.value,position:e.position}).lhs=t(e.lhs),n.rhs=t(e.rhs),A(n,n.lhs),A(n,n.rhs)}break;case"unary":n={type:e.type,value:e.value,position:e.position},"["===e.value?n.expressions=e.expressions.map(function(e){var i=t(e);return A(n,i),i}):"{"===e.value?n.lhs=e.lhs.map(function(e){var i=t(e[0]);A(n,i);var r=t(e[1]);return A(n,r),[i,r]}):(n.expression=t(e.expression),"-"===e.value&&"number"===n.expression.type?(n=n.expression).value=-n.value:A(n,n.expression));break;case"function":case"partial":(n={type:e.type,name:e.name,value:e.value,position:e.position}).arguments=e.arguments.map(function(e){var i=t(e);return A(n,i),i}),n.procedure=t(e.procedure);break;case"lambda":n={type:e.type,arguments:e.arguments,signature:e.signature,position:e.position};var p=t(e.body);n.body=v(p);break;case"condition":(n={type:e.type,position:e.position}).condition=t(e.condition),A(n,n.condition),n.then=t(e.then),A(n,n.then),void 0!==e.else&&(n.else=t(e.else),A(n,n.else));break;case"transform":(n={type:e.type,position:e.position}).pattern=t(e.pattern),n.update=t(e.update),void 0!==e.delete&&(n.delete=t(e.delete));break;case"block":(n={type:e.type,position:e.position}).expressions=e.expressions.map(function(e){var i=t(e);return A(n,i),(i.consarray||"path"===i.type&&i.steps[0].consarray)&&(n.consarray=!0),i});break;case"name":n={type:"path",steps:[e]},e.keepArray&&(n.keepSingletonArray=!0);break;case"parent":n={type:"parent",slot:{label:"!"+x++,level:1,index:w++}},M.push(n);break;case"string":case"number":case"value":case"wildcard":case"descendant":case"variable":case"regex":n=e;break;case"operator":if("and"===e.value||"or"===e.value||"in"===e.value)e.type="name",n=t(e);else{if("?"!==e.value)throw{code:"S0201",stack:(new Error).stack,position:e.position,token:e.value};n=e}break;case"error":n=e,e.lhs&&(n=t(e.lhs));break;default:var f="S0206";"(end)"===e.id&&(f="S0207");var g={code:f,position:e.position,token:e.value};if(r)return c.push(g),{type:"error",error:g};throw g.stack=(new Error).stack,g}return e.keepArray&&(n.keepArray=!0),n};o=n(e),p();var C=f(0);if("(end)"!==s.id){var T={code:"S0201",position:s.position,token:s.value};u(T)}if("parent"===(C=k(C)).type||void 0!==C.seekingParent)throw{code:"S0217",token:C.type,position:C.position};return c.length>0&&(C.errors=c),C};return r}();e.exports=r},{"./signature":5}],5:[function(t,e,n){function i(t){return i="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},i(t)}var r=t("./utils"),s=function(){var t={a:"arrays",b:"booleans",f:"functions",n:"numbers",o:"objects",s:"strings"};function e(e){for(var n=1,s=[],o={},a=o;n<e.length;){var c=e.charAt(n);if(":"===c)break;var l=function(){s.push(o),a=o,o={}},h=function(t,e,n,i){for(var r=1,s=e;s<t.length;)if(s++,(c=t.charAt(s))===i){if(0===--r)break}else c===n&&r++;return s};switch(c){case"s":case"n":case"b":case"l":case"o":o.regex="["+c+"m]",o.type=c,l();break;case"a":o.regex="[asnblfom]",o.type=c,o.array=!0,l();break;case"f":o.regex="f",o.type=c,l();break;case"j":o.regex="[asnblom]",o.type=c,l();break;case"x":o.regex="[asnblfom]",o.type=c,l();break;case"-":a.context=!0,a.contextRegex=new RegExp(a.regex),a.regex+="?";break;case"?":case"+":a.regex+=c;break;case"(":var d=h(e,n,"(",")"),u=e.substring(n+1,d);if(-1!==u.indexOf("<"))throw{code:"S0402",stack:(new Error).stack,value:u,offset:n};o.regex="["+u+"m]",o.type="("+u+")",n=d,l();break;case"<":if("a"!==a.type&&"f"!==a.type)throw{code:"S0401",stack:(new Error).stack,value:a.type,offset:n};var p=h(e,n,"<",">");a.subtype=e.substring(n+1,p),n=p}n++}var f="^"+s.map(function(t){return"("+t.regex+")"}).join("")+"$",g=new RegExp(f),m=function(t){var e;if(r.isFunction(t))e="f";else switch(i(t)){case"string":e="s";break;case"number":e="n";break;case"boolean":e="b";break;case"object":e=null===t?"l":Array.isArray(t)?"a":"o";break;default:e="m"}return e},y=function(t,e){for(var n="^",i=0,r=0;r<s.length;r++){n+=s[r].regex;var o=e.match(n);if(null===o)throw{code:"T0410",stack:(new Error).stack,value:t[i],index:i+1};i=o[0].length}throw{code:"T0410",stack:(new Error).stack,value:t[i],index:i+1}};return{definition:e,validate:function(e,n){var i="";e.forEach(function(t){i+=m(t)});var r=g.exec(i);if(r){var o=[],a=0;return s.forEach(function(i,s){var c=e[a],l=r[s+1];if(""===l)if(i.context&&i.contextRegex){var h=m(n);if(!i.contextRegex.test(h))throw{code:"T0411",stack:(new Error).stack,value:n,index:a+1};o.push(n)}else o.push(c),a++;else l.split("").forEach(function(n){if("a"===i.type){if("m"===n)c=void 0;else{c=e[a];var r=!0;if(void 0!==i.subtype)if("a"!==n&&l!==i.subtype)r=!1;else if("a"===n&&c.length>0){var s=m(c[0]);r=s===i.subtype.charAt(0)&&0===c.filter(function(t){return m(t)!==s}).length}if(!r)throw{code:"T0412",stack:(new Error).stack,value:c,index:a+1,type:t[i.subtype]};"a"!==n&&(c=[c])}o.push(c),a++}else o.push(c),a++})}),o}y(e,i)}}}return e}();e.exports=s},{"./utils":6}],6:[function(t,e,n){function i(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=r(t))||e){n&&(t=n);var i=0,s=function(){};return{s:s,n:function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:s}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,c=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){c=!0,o=t},f:function(){try{a||null==n.return||n.return()}finally{if(c)throw o}}}}function r(t,e){if(t){if("string"==typeof t)return s(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?s(t,e):void 0}}function s(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function o(t){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},o(t)}var a=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 n(e){var n=!1;return Array.isArray(e)&&(n=0===e.filter(function(e){return!t(e)}).length),n}function r(){var t=[];return t.sequence=!0,1===arguments.length&&t.push(arguments[0]),t}function s(t){return!0===t.sequence&&Array.isArray(t)}function a(t){return t&&(!0===t._jsonata_function||!0===t._jsonata_lambda)||"function"==typeof t}function c(t){return"number"==typeof t.arity?t.arity:"function"==typeof t.implementation?t.implementation.length:"number"==typeof t.length?t.length:t.arguments.length}function l(t){return t&&!0===t._jsonata_lambda}var h=("function"==typeof Symbol?Symbol:{}).iterator||"@@iterator";function d(t){return"object"===o(t)&&null!==t&&h in t&&"next"in t&&"function"==typeof t.next}function u(t,e){if(t===e)return!0;if("object"===o(t)&&"object"===o(e)&&null!==t&&null!==e){if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return!1;for(var n=0;n<t.length;n++)if(!u(t[n],e[n]))return!1;return!0}var i=Object.getOwnPropertyNames(t),r=Object.getOwnPropertyNames(e);if(i.length!==r.length)return!1;for(i=i.sort(),r=r.sort(),n=0;n<i.length;n++)if(i[n]!==r[n])return!1;for(n=0;n<i.length;n++){var s=i[n];if(!u(t[s],e[s]))return!1}return!0}return!1}function p(t){var e,n=[],r=i(t);try{for(r.s();!(e=r.n()).done;){var s=e.value;n.push(s)}}catch(t){r.e(t)}finally{r.f()}return n}return{isNumeric:t,isArrayOfStrings:e,isArrayOfNumbers:n,createSequence:r,isSequence:s,isFunction:a,isLambda:l,isIterable:d,getFunctionArity:c,isDeepEqual:u,stringToArray:p}}();e.exports=a},{}]},{},[3])(3)}($i)),$i.exports),Xi=Gi(Wi);const qi=function(t){return t};function Ki(t){if(!t)return qi;try{const e=Xi(function(t){return t.replace(/(?<=^|\.|\[)([a-zA-Z_][\w]*-[\w-]*)(?=\.|$|\[|])/g,"`$1`")}(t));return function(t){return e.evaluate(t)}}catch(t){return Fi(t),qi}}function Qi(t){const e=ci(t);return null==e?"":String(e)}function Zi(t){return Number(ci(t))}function Ji(t){return t}function tr(t){return Qi(t)}function er(t){return Zi(t)}function nr(t){if(this.param)return t=Qi(t),this.param.hasOwnProperty(t)?this.param[t]:this.param.default}function ir(t){const{param:e}=this;if(e){for(const n in e){let[i,r]=n.split("~");const s=!!i,o=!!r,a=parseFloat(i),c=parseFloat(r);if(t=Zi(t),s&&!o&&t>=a)return e[n];if(!s&&o&&t<a)return e[n];if(t>=a&&t<c)return e[n]}return e.default}}function rr(t){return Zi(t)*Math.PI/180}function sr(){}const or=[/\bimport\b/,/\brequire\b/,/\b__proto__\b/,/\bconstructor\s*\[/,/\bprototype\b/];const ar=["globalThis","self","top","parent","frames","fetch","XMLHttpRequest","eval","Function","require","importScripts","process"],cr=new Array(ar.length).fill(void 0);function lr(t){try{!function(t){for(const e of or)if(e.test(t))throw new Error(`Blocked pattern detected: ${e}`)}(t);const e=new Function("value","targets","scene",...ar,t);return function(t,n){try{return e.call(this,t,n,globalThis.scene,...cr)}catch(t){return void Fi(t)}}}catch(t){return Fi(t),sr}}function hr(t,e,n,i,r){switch(n){case"value":return"text"===r||"string"===r?tr.bind(t):"number"===r?er.bind(t):Ji.bind(e);case"map":return nr.bind(t);case"range":return ir.bind(t);case"radian":return rr.bind(t);case"eval":return lr(i).bind(e);default:return Ji.bind(e)}}class dr{constructor(t,e){this.owner=e,this.model=t}dispose(){this._model=null,this.owner=null,this.evaluator=null,this.accessor=null}get model(){return this._model}set model(t){const{target:e,property:n,rule:i,param:r,accessor:s}=t;this._model=t,this.evaluator=hr(this,this.owner,i,r,function(t){switch(t){case"ref":case"fillStyle":case"strokeStyle":return"string";default:return}}(n)),this.accessor=Ki(s);const o=e.match(/\[(.*?)\]/);if(o){const[t,e]=o[1].split(":");this.propAccessor=Ki(t),this.partAccessor=Ki(e)}}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 ur(t,e,n,i){const r=e.split(".");if(1===r.length)return void(t[e]=i?{...t[e],...n}:n);const s=r[0],o=void 0!==t[s]?t[s]:"function"==typeof t.get?t.get(s):void 0,a=o?{...o}:{};let c=a;for(let t=1;t<r.length-1;t++)c[r[t]]=c[r[t]]?{...c[r[t]]}:{},c=c[r[t]];const l=r[r.length-1];c[l]=i?{...c[l],...n}:n,t[s]=a}function pr(t,e,n,i){t.forEach(t=>ur(t,e,n,i))}function fr(t=!1){(t||void 0!==this.data)&&this.mappings&&this.mappings.forEach(t=>{try{let e,{source:n,target:i,property:r,accessor:s,propAccessor:o,partAccessor:a,ndnsp:c=!1,partial:l=!1}=t;i=(i||"(self)").trim(),t.rule||(t.rule="value"),n&&"(self)"!=n?(n.startsWith("#")&&(n=n.substring(1)),e=this.root.findById(n)?.data||{}):e=this.data;const h=s(e);if("(root)"==i||"(key)"==i){if(null==h)return;const e=Object.keys(h||{}).map(t=>this.root.findOrCreate(t)).filter(Boolean).flat();e.length>0&&e.forEach(e=>{const n=t.evaluator(h[e.get("id")],[e]);!r||"(action)"===r||c&&!n&&0!==n&&!1!==n||ur(e,r,n,l)})}else if(i.startsWith("[")){if(null==h)return;if(h instanceof Array)h.forEach(e=>{const n=o(e);if(n){const i=this.root.findOrCreate(n);if(i){const n=t.evaluator(a(e),i);!r||"(action)"===r||c&&!n&&0!==n&&!1!==n||pr(i,r,n,l)}}});else{if(!(h instanceof Object))throw String("mapping data should be an object to target property-id.("+h+")");{const e=o(h);if(e){const n=this.root.findOrCreate(e);if(n){const e=t.evaluator(a(h),n);!r||"(action)"===r||c&&!e&&0!==e&&!1!==e||pr(n,r,e,l)}}}}}else{const e=this.root.findAll(i,this);if(e.length>0){const n=t.evaluator(h,e);!r||"(action)"===r||c&&!n&&0!==n&&!1!==n||pr(e,r,n,l)}}}catch(e){Fi(e,this,t)}})}function gr(t,e){this.state.persistent&&this.app?.isViewMode&&this.app?.dataStorage.save(this,t.data),this.app?.lagTracker?.recordIfMonitored(this.state.tag,t.data),fr.call(this,!0)}function mr(){if(this._model.mappings)return this._model.mappings instanceof Array?void(this._mappings=(this._model.mappings||[]).filter(t=>t.property).map(t=>new dr({target:"(self)",rule:"value",...t},this))):(Fi("Mappings model is invalid (should be a Array) ..",this._model.mappings),void(this._mappings=[]));this._mappings=[]}function yr(){this._mappings&&this._mappings.forEach(t=>t.dispose()),delete this._mappings}function br(t,e){this.disposeMappings(),fr.call(this)}function _r(t,e,n,i,r,s){e.complete?t.drawImage(e,n,i,r,s):e.addEventListener("load",()=>{this.invalidate()})}function vr(t){const{effects:e}=this.state;(e||[]).forEach(e=>{this.effect(t,e)})}const xr={},wr={VIEW:0,EDIT:1,SHIFT:2,ADD:3},Mr="undefined"==typeof window?1:window.devicePixelRatio||(window.matchMedia&&window.matchMedia("(min-resolution: 2dppx), (-webkit-min-device-pixel-ratio: 1.5),(-moz-min-device-pixel-ratio: 1.5),(min-device-pixel-ratio: 1.5)").matches?2:1),Sr=["mousemove","mouseup","mousedown","mouseout","wheel","touchstart","touchmove","touchend","dblclick"],Ar=["keydown","keyup"],Er={ALPHA:1,FONT_SIZE:15,FONT_FAMILY:"Roboto, sans-serif",FONT_COLOR:"black",TEXT_ALIGN:"center",TEXT_BASELINE:"middle",TEXT_WRAP:!1,BOLD:!1,ITALIC:!1,STROKE_STYLE:"#999",LINE_DASH:"solid",LETTER_SPACING:0},kr=()=>{if("undefined"==typeof document||"function"!=typeof getComputedStyle||!document.documentElement)return;const t=getComputedStyle(document.documentElement);if(!t)return;const e=t.getPropertyValue?.("--scene-theme-font-family")?.trim(),n=t.fontFamily||"sans-serif";Er.FONT_FAMILY=e||n},Cr=()=>{if("undefined"!=typeof window&&"undefined"!=typeof document&&(window.addEventListener("load",()=>{kr()}),"fonts"in document&&"ready"in document.fonts&&document.fonts.ready.then(kr),"undefined"!=typeof MutationObserver&&document.documentElement)){new MutationObserver(()=>{kr()}).observe(document.documentElement,{attributes:!0,attributeFilter:["style","class"]})}};let Tr;function Pr(t,e,n,i,r){const{alpha:s=1}=i,o=r.fillStyle;if(t.globalAlpha*=s,o)if("string"==typeof o)t.fillStyle=o,t.fill();else if("object"==typeof o)if("gradient"==o.type){t.translate(n.x,n.y);let i,{width:r,height:s}=e;if("linear"==o.gradientType){const e=3.141592653589793,n="number"==typeof o.rotation&&Number.isFinite(o.rotation)?o.rotation:0;if(n>=.436332&&n<=1.13446||n>=2.00713&&n<=2.70526||n>=3.57792&&n<=4.27606||n>=5.14872&&n<=5.84685){let o=Math.sqrt(Math.pow((r-4)/2,2)+Math.pow((s-4)/2,2));o-=o-(r+s)/3,i=t.createLinearGradient(o*Math.cos(n+e),o*Math.sin(n+e),o*Math.cos(n),o*Math.sin(n))}else i=t.createLinearGradient((r-4)/2*Math.cos(n+e),(s-4)/2*Math.sin(n+e),(r-4)/2*Math.cos(n),(s-4)/2*Math.sin(n))}else if("radial"==o.gradientType){const e=.95*Math.sqrt(Math.pow((r-4)/2,2)+Math.pow((s-4)/2,2));switch(o.center){case"center":default:i=t.createRadialGradient(0,0,0,0,0,e);break;case"left-top":i=t.createRadialGradient(-r/2,-s/2,0,-r/2,-s/2,2*e);break;case"right-top":i=t.createRadialGradient(r/2,-s/2,0,r/2,-s/2,2*e);break;case"left-bottom":i=t.createRadialGradient(-r/2,s/2,0,-r/2,s/2,2*e);break;case"right-bottom":i=t.createRadialGradient(r/2,s/2,0,r/2,s/2,2*e)}}(Array.isArray(o.colorStops)?o.colorStops:Array.isArray(o.gradientStops)?o.gradientStops:[]).forEach(t=>{if(t.position>=0&&t.position<=1)try{i.addColorStop(t.position,t.color)}catch(e){Bi("Invalid Color for colorstop : ",t.color),i.addColorStop(t.position,"#fff")}}),t.fillStyle=i,t.fill(),t.translate(-n.x,-n.y)}else if("pattern"==o.type&&o.image)if(o.guideOnly&&1!=r.app.mode)o.color&&(t.fillStyle=o.color,t.fill());else{r.prepareFillIf(!r._pattern_image_origin);const n=r._pattern_image;if(!n||!n.width||!n.height)return;let i=0,s=0,a=0,c=0,l=e.left,h=e.top;if(!o.fitPattern){i=o.offsetX,s=o.offsetY;const t=o.width?o.width:n.width,r=o.height?o.height:n.height;switch(o.align){case"center":a=e.width/2-t/2,c=e.height/2-r/2;break;case"left-top":a=0,c=0;break;case"left-bottom":a=0,c=e.height-r;break;case"right-top":a=e.width-t,c=0;break;case"right-bottom":a=e.width-t,c=e.height-r;break;case"left":a=0,c=e.height/2-r/2;break;case"right":a=e.width-t,c=e.height/2-r/2;break;case"top":a=e.width/2-t/2,c=0;break;case"bottom":a=e.width/2-t/2,c=e.height-r}l+=i+a,h+=s+c}t.translate(l,h),o.color&&(t.fillStyle=o.color,t.fill()),o.fitPattern?Math.abs((n.width-e.width)*(n.height-e.height))>1?(delete r._pattern_image,delete r._pattern_image_origin):t.fillStyle=t.createPattern(n,"no-repeat"):t.fillStyle=t.createPattern(n,o.noRepeat?"no-repeat":"repeat"),t.fill(),t.translate(-l,-h)}}function Dr(t,e){const n=this.fillStyle;if(!n||"pattern"!=n.type||!n.image)return void t(this);if("string"!=typeof n.image)return this._pattern_image_origin=this._pattern_image=n.image,void t(this);this._pattern_image=null,this._pattern_image_origin=new Image;const i=this;this._pattern_image_origin.onload=function(){if(!n.fitPattern&&!n.width&&!n.height)return i._pattern_image=i._pattern_image_origin,void t(this);let e=n.width||this.width,r=n.height||this.height;n.fitPattern&&(e=i.bounds.width,r=i.bounds.height);const s=Tr(e,r);s.getContext("2d").drawImage(this,0,0,this.width,this.height,0,0,e,r),i._pattern_image=s,t(this)},this._pattern_image_origin.onerror=function(t){e(t)};try{"data"!==String(n.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(n.image)}catch(t){e(t)}}function Or(t){t&&this.prepareFill(t=>{this.invalidate()},t=>{Fi(t)})}function zr(t,e){const n=this.fillStyle;n&&"pattern"!==n.type?this._pattern_image&&(this._pattern_image=null,this._pattern_image_origin=null):n?.image&&this.prepareFillIf(n.image)}function Lr(t,e,n){let{strokeStyle:i,lineDash:r,lineWidth:s,lineCap:o,lineJoin:a,alpha:c}=e;if(i&&0!=s){if(o&&(t.lineCap=o),r){const e="round"==o;switch(r){case"solid":r=[0,0];break;case"round-dot":r=e?[0,2*s]:[s,s];break;case"square-dot":r=e?[s,2*s]:[2*s,s];break;case"dash":r=e?[3*s,2.5*s]:[4*s,1.5*s];break;case"dash-dot":r=e?[3*s,3*s,0,3*s]:[4*s,2*s,s,2*s];break;case"long-dash":r=e?[5*s,4*s]:[6*s,3*s];break;case"long-dash-dot":r=e?[5*s,3*s,0,3*s]:[6*s,2*s,s,2*s];break;case"long-dash-dot-dot":r=e?[5*s,2*s,0,2*s,0,2*s]:[6*s,s,s,s,s,s]}Array.isArray(r)||(r=[]),t.setLineDash(r)}t.globalAlpha*=c,t.strokeStyle=i,t.lineWidth=s,t.lineJoin=a,t.stroke()}}function Ir(t){const e=/(\*\*|__)(.*?)\1|(\*|_)(.*?)\3|([^\*_]+)/g,n=[];let i;for(;null!==(i=e.exec(t));)i[1]?n.push({text:i[2],bold:!0,italic:!1}):i[3]?n.push({text:i[4],bold:!1,italic:!0}):i[5]&&n.push({text:i[5],bold:!1,italic:!1});return n}function Rr(t,e,n,i=0){if(e.text.length<2)return e;let r=2;for(;r<e.text.length;r++){const s=e.text.substring(0,r);if(!(t.measureText(s).width+(r-1)*i<n))break}return{...e,text:e.text.substring(0,r-1)}}function jr(t,e,n,i,r,s=0){const o=String(e).split("\n");return i?[].concat(...o.map(e=>function(t,e,n,i=0){const r=[];let s=[],o=0;return e.forEach(e=>{let a=e.text;for(;a.length>0;){const c=n-o,l=t.measureText(a).width+(a.length-1)*i;if(l<=c)s.push({...e,text:a}),o+=l,a="";else{const n=Rr(t,{...e,text:a},c,i);s.push(n),r.push(s),s=[],o=0,a=a.substring(n.text.length)}}}),s.length>0&&r.push(s),r}(t,r?Ir(e):[{text:e,bold:!1,italic:!1}],n,s))):o.map(t=>r?Ir(t):[{text:t,bold:!1,italic:!1}])}function Fr(t,e,n,i,r,s,o=0){if(!i)return[];t.save(),t.font=n;const a=jr(t,i,e,!!r,s,o);return t.restore(),a}function Br(t){const{fontFamily:e=Er.FONT_FAMILY,bold:n=Er.BOLD,italic:i=Er.ITALIC,fontSize:r=Er.FONT_SIZE}=t,s=[];return n&&s.push("bold"),i&&s.push("italic"),s.push(r+"px"),s.push(e),s.join(" ")}function Nr(t,e){const n=t.bold||e.bold,i=t.italic||e.italic;return Br({...t,bold:n,italic:i})}function Hr(t,e,n,i){let{alpha:r,rotation:s,keepTextAngle:o=!1,fontColor:a=Er.FONT_COLOR,textAlign:c=Er.TEXT_ALIGN,textBaseline:l=Er.TEXT_BASELINE,textBackgroundStyle:h,fontSize:d,lineHeight:u,textWrap:p,textOverflow:f,letterSpacing:g=0}=i;r=void 0!==r?r:1,d||=Er.FONT_SIZE,u||=1.2*d,t.save();const{left:m,top:y,width:b,height:_}=e;if(s&&o&&(t.translate(m+b/2,y+_/2),t.rotate(-s),t.translate(-(m+b/2),-(y+_/2))),t.beginPath(),t.font=Br(i),!p&&f){const e=function(t,e,n,i){const r="ellipsis"===t?"…":"",s=e.measureText(r).width,o=[];let a=0;for(const r of n){const n=[];for(const c of r){const r=e.measureText(c.text).width;if(!(a+r<=i-("ellipsis"===t?s:0))){const r=Yr(e,c,i-a-("ellipsis"===t?s:0),t);return n.push(r),o.push(n),o}n.push(c),a+=r}o.push(n),a=0}return o}(f,t,n,b);n=e}const v=n.length*u;let x;switch(l){case"top":x=y,t.textBaseline="top";break;case"bottom":x=y+_-v+u,t.textBaseline="bottom";break;default:x=y+_/2-v/2+u/2,t.textBaseline="middle"}t.globalAlpha*=r,t.fillStyle=a,n.forEach((e,r)=>{const s=x+r*u,o=function(t,e,n,i=0){return e.reduce((e,r)=>(t.font=Nr(n,r),e+t.measureText(r.text).width+i*(r.text.length-1)),0)}(t,e,i,g);let l=m;switch(c){case"left":case"justify":l=m;break;case"right":l=m+b-o;break;case"center":l=m+(b-o)/2}if(h&&(t.fillStyle=h,function(t,e,n,i,r,s=0,o=!1,a=!0){s="number"==typeof s?{tl:s,tr:s,br:s,bl:s}:{tl:0,tr:0,br:0,bl:0,...s},t.beginPath(),t.moveTo(e+s.tl,n),t.lineTo(e+i-s.tr,n),t.quadraticCurveTo(e+i,n,e+i,n+s.tr),t.lineTo(e+i,n+r-s.br),t.quadraticCurveTo(e+i,n+r,e+i-s.br,n+r),t.lineTo(e+s.bl,n+r),t.quadraticCurveTo(e,n+r,e,n+r-s.bl),t.lineTo(e,n+s.tl),t.quadraticCurveTo(e,n,e+s.tl,n),t.closePath(),o&&t.fill(),a&&t.stroke()}(t,l-4,s-d/2-4,o+8,d+8,4,!0,!1),t.fillStyle=a),"justify"===c&&r<n.length-1&&e.length>1){const n=b-o,r=e.length-1,a=n/r;e.forEach((e,n)=>{t.font=Nr(i,e),t.fillText(e.text,l,s),l+=t.measureText(e.text).width+(n<r?a:0)})}else e.forEach(e=>{t.font=Nr(i,e),[...e.text].forEach(e=>{t.fillText(e,l,s),l+=t.measureText(e).width+g})})}),t.restore()}function Yr(t,e,n,i){let r="";for(let i=0;i<e.text.length;i++){const s=r+e.text[i];if(t.measureText(s).width>n)break;r=s}return{...e,text:r+("ellipsis"===i?"…":"")}}function Gr(t,e){for(let n=0;n<t.length;n++)if(t[n].type.startsWith("image/"))return void this.set("fillStyle",{type:"pattern",image:e[n],fitPattern:!0})}Cr(),kr(),Tr="undefined"==typeof document?function(t,e){return new Canvas(t,e)}:function(t,e){const n=document.createElement("canvas");return n.width=t,n.height=e,n};const Vr=[];function Ur(t,e,n={x:0,y:0},i=0,r={x:1,y:1}){if(1!==r.x||1!==r.y?(t=(t-n.x)/r.x,e=(e-n.y)/r.y):(t-=n.x,e-=n.y),0!==i){const n=Math.cos(-i),r=Math.sin(-i),s=t*r+e*n;t=t*n-e*r,e=s}return{x:t+n.x,y:e+n.y}}function $r(t,e,n={x:0,y:0},i=0,r={x:1,y:1}){if(t-=n.x,e-=n.y,0!==i){const n=Math.cos(i),r=Math.sin(i),s=t*r+e*n;t=t*n-e*r,e=s}return 1!==r.x||1!==r.y?{x:t*r.x+n.x,y:e*r.y+n.y}:{x:t+n.x,y:e+n.y}}function Wr(t,e,n){if(!this.parent)return{x:t,y:e};const{rotation:i=0,scale:r={x:1,y:1}}=this.state;if(this.isLayer()){const n=this.state.translate,s=Ur(t,e,n,i,r);return n&&(s.x-=n.x,s.y-=n.y),s}return Ur(t,e,n=n||this.rotatePoint,i,r)}function Xr(t,e,n){if(!this.parent)return{x:t,y:e};let{rotation:i=0,scale:r={x:1,y:1}}=this.state;if(this.isLayer()){const n=this.state.translate,s=$r(t,e,void 0,i+(this._delta?.theta??0),r);return n&&(s.x+=n.x,s.y+=n.y),s}n=n||this.rotatePoint;const{theta:s=0,tx:o=0,ty:a=0,sx:c=1,sy:l=1}=this._delta||{};if(0===s&&0===o&&0===a&&1===c&&1===l)return $r(t,e,n,i,r);return $r(t+o,e+a,{x:n.x+o,y:n.y+a},i+s,{x:r.x*c,y:r.y*l})}function qr(t,e,n){n=n||this.rootModel;const i=this.transcoordS2T(t,e,n);return $r(i.x,i.y,void 0,(n.get("rotation")||0)+n._delta.theta)}function Kr(t,e,n){n=n||this.rootModel,Vr.length=0;for(let t=this.parent;t&&t!==n;t=t.parent)Vr.push(t);let i=this.transcoordS2P(t,e);for(let t=0;t<Vr.length;t++){const e=Vr[t],n=e.bounds;i.x+=n.left,i.y+=n.top,i=e.transcoordS2P(i.x,i.y)}return i}function Qr(t,e,n){n=n||this.rootModel,Vr.length=0;for(let t=this.parent;t&&t!==n;t=t.parent)Vr.push(t);let i={x:t,y:e};for(let t=Vr.length-1;t>=0;t--){const e=Vr[t];i=e.transcoordP2S(i.x,i.y);const n=e.bounds;i.x-=n.left,i.y-=n.top}return i}function Zr(t,e,n){const i=this.transcoordT2P(t,e,n);return this.transcoordP2S(i.x,i.y)}function Jr(t,e,n){const i=this.rootModel,r=this.transcoordS2T(t,e,i);return n.transcoordT2S(r.x,r.y,i)}function ts(t,e,n){if(!n)for(n=this;n&&!n.isLayer();)n=n.parent;const{translate:i={x:0,y:0},scale:r={x:1,y:1},rotation:s=0}=n.model,o=Ur(t,e,i,s,r);return i&&(o.x-=i.x,o.y-=i.y),n===this?o:this.transcoordT2S(o.x,o.y,n)}function es(t,e,n){if(!n)for(n=this;n&&!n.isLayer();)n=n.parent;let i;if(i=n!==this?this.transcoordS2T(t,e,n):{x:t,y:e},!this.scalable)return i;const{translate:r={x:0,y:0},rotation:s=0,scale:o={x:1,y:1}}=n.model;return i=$r(i.x,i.y,void 0,s+n._delta.theta,o),r&&(i.x+=r.x,i.y+=r.y),i}function ns(t){let e=0,n=0,i=0,r=0,s=!1;return t.forEach(t=>{s?(e=Math.min(t.left,e),n=Math.min(t.top,n),i=Math.max(t.left+t.width,i),r=Math.max(t.top+t.height,r)):(e=t.left,n=t.top,i=t.left+t.width,r=t.top+t.height,s=!0)}),{left:e,top:n,width:i-e,height:r-n}}function is(t){const e=t.element,n=t.fillStyle,i=e.style;if(n)if("string"==typeof n)i.backgroundColor=n;else switch(n.type){case"pattern":if(i.backgroundImage="url("+n.image+")",i.backgroundColor="transparent",n.fitPattern?i.backgroundSize="100% 100%":n.width||n.height?i.backgroundSize=`${n.width?n.width+"px":"auto"} ${n.height?n.height+"px":"auto"}`:i.backgroundSize="contain",n.fitPattern)i.backgroundRepeat="no-repeat";else{const{offsetX:t,offsetY:e,noRepeat:r,align:s,color:o}=n;if(r&&(i.backgroundRepeat="no-repeat"),o&&(i.backgroundColor=o),s)switch(s){case"center":i.backgroundPosition="center center";break;case"left-top":i.backgroundPosition="left top";break;case"left-bottom":i.backgroundPosition="left bottom";break;case"right-top":i.backgroundPosition="right top";break;case"right-bottom":i.backgroundPosition="right bottom";break;case"left":i.backgroundPosition="left center";break;case"right":i.backgroundPosition="right center";break;case"top":i.backgroundPosition="center top";break;case"bottom":i.backgroundPosition="center bottom"}else t||e?i.backgroundPosition=`${Number(t)||0}px ${Number(e)||0}px`:delete i.backgroundPosition}break;case"gradient":i.background=function(t,e){const n=e.colorStops,i=e.gradientType;if(n instanceof Array&&n.length>0)switch(i){case"radial":return"radial-gradient(farthest-corner at "+function(t,e){const{width:n,height:i}=t.bounds;switch(e){case"center":return[n/2,i/2];case"left-top":return[0,0];case"right-top":return[n,0];case"left-bottom":return[0,i];default:return[n,i]}}(t,e.center||"center").map(t=>t+"px").join(" ")+","+n.map(t=>`${t.color} ${100*t.position}%`).join(",")+")";case"linear":return"linear-gradient("+(180*(e.rotation||0)/3.141592653589793+90+"deg")+", "+n.map(t=>`${t.color} ${100*t.position}%`).join(",")+")"}return""}(t,n)}else i.background="transparent"}const rs={x:1,y:1},ss={boxSizing:"border-box",margin:"0px",position:"absolute",outline:"none"};function os(t){let{id:e,scale:n=rs,bold:i,italic:r,fontFamily:s="",textAlign:o,textBaseline:a,textOverflow:c,paddingTop:l,paddingBottom:h,paddingLeft:d,paddingRight:u,fontSize:p=Er.FONT_SIZE,lineWidth:f=0,lineHeight:g,lineDash:m}=t.state;h||=0,l||=0,d||=0,u||=0;const y=t.state.class,{strokeStyle:b,rotation:_=0,fontColor:v,hidden:x}=t,{left:w,top:M,width:S,height:A}=t.bounds,E=t.element;if(E.hidden=x,e&&(E.id=e),y&&(E.className=y),Object.assign(E.style,ss,{fontFamily:s,fontSize:p+"px",width:S+"px",height:A+"px",paddingTop:l+"px",paddingRight:u+"px",paddingBottom:h+"px",paddingLeft:d+"px",border:f+"px",borderColor:b,borderStyle:f>0?m||Er.LINE_DASH:"",color:v,fontWeight:i?"bold":"",fontStyle:r?"italic":"",textAlign:"end"==o?"right":"start"==o?"left":o,verticalAlign:a,lineHeight:void 0===g?"":g+"px",whiteSpace:c?"nowrap":"",overflow:c?"hidden":"",textOverflow:c||""},t.isIn3DSpace()?{}:{left:w+"px",top:M+"px"}),is(t),function(t){if(!t.isShadowable()||!t.state.shadow)return;const e=t.state.shadow,n=e.offsetX??e.left??0,i=e.offsetY??e.top??0,r=e.blur??e.blurSize??0,s=e.color??"transparent";t.element.style.boxShadow=`${n}px ${i}px ${r}px ${s}`}(t),t.isIn3DSpace())return;const k=t.delta(),C=(n&&n.x||1)*k.sx,T=(n&&n.y||1)*k.sy,P=(_||0)+k.theta,D=k.tx||0,O=k.ty||0;E.style.transform=`rotate(${P}rad) translate(${D}px, ${O}px) scale(${C}, ${T}) perspective(1px)`}function as(t,e){let n=this.bounds,i=this.rotatePoint;const r=this.get("rotation"),s=this.get("scale");if(t){const i=t.call(e,n);i&&(n=i)}const{left:o,top:a,width:c,height:l}=n;let h=[{x:o,y:a},{x:o+c,y:a+l}];h=h.map(t=>$r(t.x,t.y,i,r,s));let d=h[0],u=h[1];i={x:(d.x+u.x)/2,y:(d.y+u.y)/2},h=h.map(t=>Ur(t.x,t.y,i,r,s)),d=h[0],u=h[1],this.bounds={left:d.x,top:d.y,width:u.x-d.x,height:u.y-d.y}}function cs(t,e,n){let i=this.path,r=this.rotatePoint;this.get("rotation"),this.get("scale"),t&&(i=t.call(n,i));let s=i.map(t=>{const e=this.toParent(t.x,t.y);return void 0!==t.z&&(e.z=t.z),e});if(e){const t=e.call(n,s);t&&(s=t)}const o={x:0,y:0};let a,c,l,h;i=s.map(t=>this.fromParent(t.x,t.y,o)),a=c=i[0].x,l=h=i[0].y;for(let t=1;t<i.length;t++){const e=i[t];e.x<a?a=e.x:e.x>c&&(c=e.x),e.y<l?l=e.y:e.y>h&&(h=e.y)}r={x:(a+c)/2,y:(l+h)/2},r=this.toParent(r.x,r.y,o),this.path=s.map(t=>{const e=this.fromParent(t.x,t.y,r);return void 0!==t.z&&(e.z=t.z),e})}let ls,hs=[];function ds(){ls=null;const t=performance.now();hs=hs.filter(t=>us(t));const e=hs.reduce((e,n)=>{const i=t-n.updatedAt;return i>=n.retention?e.kills.push(n):e.next=0==e.next?n.retention-i:Math.min(e.next,n.retention-i),e},{next:0,kills:[]});e.kills.forEach(t=>{const e=hs.indexOf(t);-1!=e?(hs.splice(e,1),t.removeSelf(!0)):Fi("Should not be here. Maybe reentrance problem.")}),e.next>0&&(ls=setTimeout(ps,Math.max(e.next,500)))}function us(t){return!t.disposed&&t.retention>0&&!t.isTemplate()&&t.app&&t.app.isViewMode}const ps=function(t,e,n){var i=!0,r=!0;if("function"!=typeof t)throw new TypeError("Expected a function");return F(n)&&(i="leading"in n?!!n.leading:i,r="trailing"in n?!!n.trailing:r),ti(t,e,{leading:i,maxWait:e,trailing:r})}(function(){requestAnimationFrame(ds)},500);var fs=new class{add(t){us(t)&&-1==hs.indexOf(t)&&(hs.push(t),t.touch()),this.touch()}remove(t){const e=hs.indexOf(t);e>0&&hs.splice(e,1),this.touch()}touch(){null!==ls&&(clearTimeout(ls),ls=null),ps()}dispose(){ps.cancel(),null!==ls&&(clearTimeout(ls),ls=null),hs=[]}get length(){return hs.length}};const gs=function(t){return t};function ms(t){const e=t.indexOf("||");let n="",i="";-1!=e&&(n=t,i=t.substring(e+2,t.length-1).trim(),t=t.replace(t.substring(e,t.length-1),"").trim());const r=t.substr(2,t.length-3).trim().replace(/\[(\w+)\]/g,".$1").replace(/^\./,"").split(".").filter(t=>!!t.trim()),s=r.slice(1);return{defaultValue:i,match:t,originText:n||t,target:r[0],accessor:s.length>0?function(t){return s.reduce((t,e)=>t?t[e]:void 0,t)}:gs}}function ys(t){if(!t)return;const e=String(t),n=(e.match(/#{(\S*)}/)||[]).map(t=>ms(t))[0];if(n)return n.accessor(this.getState(n.target));const i=(e.match(/\${[^}]*}/)||[]).map(t=>ms(t))[0];if(i){const t=this.root.findById(i.target);return i.accessor(this.getState(t))}return t}function bs(t,e){if(!t)return;const n=String(t),i=e||ci,r=(n.match(/#{(\S*)}/gi)||[]).map(t=>ms(t)),s=(n.match(/\${[^}]*}/gi)||[]).map(t=>ms(t));if(0==r.length&&0==s.length)return n;let o=n;return r.forEach(t=>{const e=i(t.accessor(this.getState(t.target)));o=o.replace(t.match,void 0===e?"":e)}),s.forEach(t=>{const e=this.root.findById(t.target),n=i(t.accessor(e&&e.data));o=o.replace(t.match,void 0===n?"":n)}),o}function _s(t,e,n){if(!t)return;const i=n||ci,r=String(t),s=(r.match(/#{[^}]*}/gi)||[]).map(t=>ms(t)),o=(r.match(/\${[^}]*}/gi)||[]).map(t=>ms(t));return 0!=s.length||0!=o.length?function(){let t=r;return s.forEach(n=>{const r=i(n.accessor(e.getState(n.target)));t=t.replace(n.originText,void 0===r?n.defaultValue||"":r)}),o.forEach(n=>{const r=e.root.findById(n.target),s=i(n.accessor(r&&r.data));t=t.replace(n.originText,void 0===s?n.defaultValue||"":s)}),t}:void 0}class vs{constructor(){}static registerDecorator(t,e){vs.constructors.set(t,e)}static create(t,e,n={},i){const r=vs.constructors.get(t);if(!r)throw new Error(`unknown decorator type: ${t}`);return new r(i,e,n)}}vs.constructors=new Map;class xs{constructor(){this.overlays=new WeakMap}static getInstance(){return xs.instance||(xs.instance=new xs),xs.instance}addOverlay(t){if(this.overlays.has(t))return!1;const e={element:t,registry:new Map};return this.overlays.set(t,e),!0}removeOverlay(t){if(!this.overlays.has(t))return!1;const e=this.overlays.get(t);for(const[n]of e.registry)this.removeFromOverlay(t,n);return this.overlays.delete(t),!0}addToOverlay(t,e,n,i={}){this.overlays.has(t)||this.addOverlay(t);const r=this.overlays.get(t);r.registry.has(e)||r.registry.set(e,new Map);const s=r.registry.get(e);s.has(n)&&s.get(n).stop();const o=vs.create(n,e,i,t);return s.set(n,o),e?.root?.app?.suppressAnimations||o.start(),o}removeFromOverlay(t,e,n){if(!this.overlays.has(t))return;const i=this.overlays.get(t);if(!i.registry.has(e))return;const r=i.registry.get(e);let s=null;if(n){if(r.has(n))try{const t=r.get(n);s=n,t&&"function"==typeof t.stop&&t.stop(),r.delete(n)}catch(t){Fi(`데코레이터(${n}) 제거 중 오류:`,t)}}else{const t=Array.from(r.keys());for(const e of t)try{const t=r.get(e);t&&"function"==typeof t.stop&&t.stop(),r.delete(e)}catch(t){Fi(`데코레이터(${e}) 제거 중 오류:`,t)}s="_all_"}0===r.size&&i.registry.delete(e),!s||"data-spread"!==s&&"_all_"!==s||this.restartBorderAnimations(t,e)}restartBorderAnimations(t,e){if(!this.overlays.has(t))return;const n=this.overlays.get(t);for(const[t,i]of n.registry.entries()){if(e&&t===e)continue;const n=i.get("border-highlighting");if(n)try{"function"==typeof n.invalidate&&n.invalidate();const t=n;"function"==typeof t.startAnimations&&t.options&&t.options.animation&&t.startAnimations()}catch(t){Fi("애니메이션 재시작 중 오류:",t)}}}removeAllFromOverlay(t,e){if(!this.overlays.has(t))return;const n=this.overlays.get(t);if(e)for(const[i]of n.registry)this.removeFromOverlay(t,i,e);else{for(const[t,e]of n.registry)for(const t of e.values())t.stop();n.registry.clear()}}getDecoratorFromOverlay(t,e,n){const i=this.overlays.get(t);return i?.registry.get(e)?.get(n)}getDecoratorsFromOverlay(t,e){const n=this.overlays.get(t);return n&&n.registry.has(e)?Array.from(n.registry.get(e).values()):[]}getTargetsWithType(t,e){const n=this.overlays.get(t);if(!n)return[];const i=[];for(const[t,r]of n.registry)r.has(e)&&i.push(t);return i}updateInOverlay(t,e,n,i){const r=this.getDecoratorFromOverlay(t,e,n);r&&r.update(i)}invalidateOverlay(t){if(!this.overlays.has(t))return;const e=this.overlays.get(t),n=Array.from(e.registry.entries());for(const[e,i]of n){if(e.disposed){this.removeFromOverlay(t,e);continue}this.getDecoratorsFromOverlay(t,e).forEach(t=>{t.invalidate()})}}}function ws(t,e){return!1}function Ms({x:t,y:e},...n){const i=this.path,r=t,s=e;this.path=i.map(t=>({x:t.x+r,y:t.y+s}))}function Ss(t){const e=t??this.center.x,{rotation:n}=this.state,i=this.fillStyle;if(this.set("rotation",2*Math.PI-n),i&&"gradient"===i.type&&"linear"===i.gradientType){const t=Yn(i);t.rotation=(Math.PI-parseFloat(i.rotation||0))%(2*Math.PI),this.set("fillStyle",t)}this.path=this.path.map(t=>({x:2*e-t.x,y:t.y}))}function As(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)}function Es(t,e,n){if(n){const e=this.bounds,n=e.height/e.width;let i=t.width-e.width,r=t.height-e.height;i*n>r?r=i*n:i=r/n;let s=t.left-e.left,o=t.top-e.top;return 0!=s&&0!=o?(o=-r,s=-i):0!=s?s=-i:0!=o&&(o=-r),{left:e.left+s,top:e.top+o,width:e.width+i,height:e.height+r}}return t}function ks(t,e){if(e||this.app.rotateStepForced){const e=this.app.rotateStep;return Math.floor((t+e/2)/e)*e}return t}function Cs(t){return function(t,e){const n=t.path.slice();if(!n||!n.length)return void Fi("path should not be empty");let i=1;const r=[];if(t.isLine()||n.push(n[0]),e<=0)return t.toScene(n[0].x,n[0].y);if(e>=1)return t.toScene(n[n.length-1].x,n[n.length-1].y);for(;n[i];){const t=n[i-1],e=n[i],s=e.x-t.x,o=e.y-t.y;r.push(Math.sqrt(s*s+o*o)),i++}const s=r.reduce(function(t,e){return t+e},0);i=0;let o=0;do{o+=r[i++]}while(o/s<e);o-=r[--i],e=(e-o/s)*(s/r[i]);const a=n[i%n.length],c=n[(i+1)%n.length],l=a.x+Math.round((c.x-a.x)*e),h=a.y+Math.round((c.y-a.y)*e);return t.toScene(l,h)}(this,t||0)}function Ts(){const t=this.path;let e,n,i,r;e=n=t[0].x,i=r=t[0].y;for(let s=1;s<t.length;s++){const o=t[s];o.x<e?e=o.x:o.x>n&&(n=o.x),o.y<i?i=o.y:o.y>r&&(r=o.y)}return{left:e,top:i,width:n-e,height:r-i}}function Ps(t){const 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)return;const n=0==e.width?1:t.width/e.width,i=0==e.height?1:t.height/e.height;this.path=this.path.map(r=>({x:t.left+(r.x-e.left)*n,y:t.top+(r.y-e.top)*i}))}function Ds(){const t=this.bounds;return{x:t.left+t.width/2,y:t.top+t.height/2}}function Os(t){if(!t||isNaN(t.x)||isNaN(t.y))return;const 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)return;const n=t.x-e.x,i=t.y-e.y;this.path=this.path.map(t=>({x:t.x+n,y:t.y+i}))}function zs(){const{x:t,y:e}=this.center;return{x:t,y:e,z:this.state.zPos}}function Ls(t){const{x:e,y:n,z:i}=t||{};this.center={x:e,y:n},isNaN(i)||this.setState("zPos",Number(i))}function Is(){const{rotationX:t,rotationY:e,rotation:n}=this.state;return{x:t,y:e,z:-n}}function Rs(t){const{x:e,y:n,z:i}=t;this.setState({rotationX:e,rotationY:n,rotation:-i})}function js(){const{width:t,height:e}=this.bounds,{depth:n}=this.state;return{width:t,height:e,depth:n}}function Fs(t){const{width:e,height:n,depth:i}=t,{top:r,left:s}=this.bounds;this.bounds={top:r,left:s,width:e,height:n},this.setState("depth",i)}function Bs(){return Fi("이 컴포넌트에 get path 가 구현되어있지 않음.",this),[]}function Ns(t){Fi("이 컴포넌트에 get path 가 구현되어있지 않음.",this)}function Hs(){return this.path}function Ys(){return this.center}function Gs(){return this.nature.mutable}function Vs(){return this.nature.resizable&&!this.stuck}function Us(){return this.nature.rotatable&&!this.stuck}const $s={x:1,y:1};function Ws(t,e,n){const{offsetX:i,offsetY:r,blur:s,color:o}=function(t){return{offsetX:t.offsetX??t.left??0,offsetY:t.offsetY??t.top??0,blur:t.blur??t.blurSize??0,color:t.color??"transparent"}}(e),a=n.rootModel.get("scale")??$s;t.shadowOffsetX=i*a.x*Mr,t.shadowOffsetY=r*a.y*Mr,t.shadowBlur=s*a.x*Mr,t.shadowColor=o}function Xs(t){t.save(),this.prerender(t),this.render(t),this.postrender(t),t.restore()}function qs(t){const e=this.rotatePoint,{scale:n,rotation:i,shadow:r,alpha:s}=this.state,o=(n&&n.x||1)*this._delta.sx,a=(n&&n.y||1)*this._delta.sy,c=(i||0)+this._delta.theta,{tx:l=0,ty:h=0}=this._delta,d=(s||1)-this._delta.fade;(l||h)&&t.translate(l,h),(1!=o||1!=a||c)&&(t.translate(e.x,e.y),1==o&&1==a||t.scale(o,a),c&&t.rotate(c),t.translate(-e.x,-e.y)),d&&(t.globalAlpha=d),r&&Ws(t,r,this),this.app.isEditMode&&this.hidden&&(t.globalAlpha*=.5)}function Ks(t){}function Qs(t){this.drawText(t)}function Zs(t,e){t(this)}function Js(t){t&&this.prepare&&this.prepare(t=>{this.invalidate()},t=>{Fi(t)})}function to(t){!this.textHidden&&this.text&&this.hasTextProperty&&Hr(t,this.textBounds,this.textLines(t),this.state)}function eo(t,e){Lr(t,e?{...this.state,...e}:this.state)}function no(t,e){this.fillStyle&&"transparent"!=this.fillStyle&&(Pr(t,this.bounds,this.center,e?{...this.state,...e}:this.state,this),function(t){t.shadowColor="transparent"}(t))}function io(){return this.get("strokeStyle")}function ro(t){this.set("strokeStyle",t)}function so(){return this.getState("fillStyle")}function oo(t){this.setState("fillStyle",t)}function ao(){return this.get("fontColor")}function co(t){this.set("fontColor",String(ci(t)))}function lo(){return this.getState("rotation")}function ho(t){this.setState("rotation",Number(ci(t)))}function uo(){return this.app.isEditMode?["decotag","data-spread"]:[]}function po(){const{id:t,tag:e}=this.state;return(t?`#${t}`:"")+(e?`@${e}`:"")}function fo(){return this.getState("hidden")||!this.data&&0!==this.data&&this.getState("ndns")||this.isTemplate()}function go(t){this.setState("hidden",t)}function mo(){return this.state.tag}function yo(t){this.setState("tag",t)}function bo(){}function _o(t){this.data instanceof Array?this.data=this.data.concat(t):this.data instanceof Object?this.data={...this.data,...t}:this.data??=t}function vo(){const t=this.getState("text");return null==t?"":String(t)}function xo(t){const{textWrap:e,supportMarkdown:n}=this.state;return Fr(t||this.getContext(),this.textBounds.width,this.font,this.text,e,n)}function wo(){return Br(this.model)}function Mo(){const t=this.get("lineHeight");return t||1.2*this.fontSize}function So(){return this._text_substitutor||(this._text_substitutor=_s(this.getState("text"),this,void 0)||this.defaultTextSubstitutor),this._text_substitutor}function Ao(){const t=this.get("textFormat");return t?function(t,e){if(!t||isNaN(+e))return e;let n,i,r,s,o,a,c,l,h,d,u,p=t.length,f=t.search(/[0-9\-\+#]/),g=f>0?t.substring(0,f):"",m=t.split("").reverse().join(""),y=m.search(/[0-9\-\+#]/),b=p-y,_=t.substring(b,b+1),v=b+("."===_||","===_?1:0),x=y>0?t.substring(v,p):"";if(n=(e="-"===(t=t.substring(f,v)).charAt(0)?-e:+e)<0?e=-e:0,i=t.match(/[^\d\-\+#]/g),r=".",s=i&&i[1]&&i[0]||",",t=t.split("."),e=+(e=e.toFixed(t[1]&&t[1].length))+"",a=t[1]&&t[1].lastIndexOf("0"),l=e.split("."),(!l[1]||l[1]&&l[1].length<=a)&&(e=(+e).toFixed(a+1)),h=t[0].split(s),t[0]=h.join(""),o=t[0]&&t[0].indexOf("0"),o>-1)for(;l[0].length<t[0].length-o;)l[0]="0"+l[0];else 0===+l[0]&&(l[0]="");if((e=e.split("."))[0]=l[0],c=h[1]&&h[h.length-1].length,c){for(d=e[0],m="",b=d.length%c,p=d.length,v=0;v<p;v++)m+=d.charAt(v),!((v-b+1)%c)&&v<p-c&&(m+=s);e[0]=m}return e[1]=t[1]&&e[1]?"."+e[1]:"",i=e.join(""),"0"!==i&&""!==i||(n=!1),u="+"==t[0].substring(0,1)?n?"-":"+":n?"-":"",g+(u+i)+x}(t,this.textSubstitutor()):this.textSubstitutor()}function Eo(t){delete this._text_substitutor;const e=ci(t);this.setState("text",null==e?"":String(e))}function ko(){let{paddingTop:t,paddingLeft:e,paddingRight:n,paddingBottom:i}=this.state;i||=0,t||=0,e||=0,n||=0;const{left:r,top:s,width:o,height:a}=this.bounds;return{left:r+e,top:s+t,width:Math.max(o-e-n,0),height:Math.max(a-t-i,0)}}function Co(){return 0}function To(){return!!this._textHidden}function Po(t){this._textHidden=!!t,this.invalidate()}function Do(){return!0}function Oo(t){return t}function zo(t){return Math.pow(t,2)}function Lo(t){return 1-Math.sin(Math.acos(t))}function Io(t,e={x:1.5}){return Math.pow(t,2)*((e.x+1)*t-e.x)}function Ro(t){for(let e=0,n=1;;e+=n,n/=2)if(t>=(7-4*e)/11)return-Math.pow((11-6*e-11*t)/4,2)+Math.pow(n,2)}function jo(t,e={x:1.5}){return Math.pow(2,10*(t-1))*Math.cos(20*Math.PI*e.x/3*t)}var Fo={linear:Oo,quad:zo,circ:Lo,back:Io,bounce:Ro,elastic:jo},Bo=Object.freeze({__proto__:null,back:Io,bounce:Ro,circ:Lo,default:Fo,elastic:jo,linear:Oo,quad:zo});function No(t){const{duration:e=1e3,easing:n,component:i,step:r=()=>{},onStart:s,onProgress:o,onComplete:a,options:c,repeat:l=!1,delta:h}=t;let d;d="string"==typeof h?Bo[h]:h||Oo,"out"===n?d=function(t,e){return function(n){return 1-t(1-n,e)}}(d,c):"inout"===n&&(d=function(t,e){return function(n){return n<.5?t(2*n,e)/2:(2-t(2*(1-n),e))/2}}(d,c));let u=!1,p=null;return{start:function(){if(u)return this;if(i?.root?.app?.suppressAnimations)return this;u=!0,s&&s();let t=0;const n=()=>{if(!u)return;if(i?.root?.app?.suppressAnimations)return this.stop(),void(t=0);0===t&&(t=performance.now());const s=(performance.now()-t)/e,a=l?s%1:Math.min(s,1);r(d(a,c)),o&&o(a),!(s>=1)||l&&u||(this.stop(),t=0),u&&(p=requestAnimationFrame(n))};return p=requestAnimationFrame(n),this},stop:function(){return u=!1,null!==p&&(cancelAnimationFrame(p),p=null),a&&a(),this}}}class Ho{constructor(t,e){this._started=!1,this._raf=null,this._timeout=null,this.client=t,this.config=e,this._started=!1;const{delta:n="linear",options:i,ease:r}=this.config;let s;s="string"==typeof n?Fo[n]:n,this.delta="out"===r?function(t,e){return function(n){return 1-t(1-n,e)}}(s,i):"inout"===r?function(t,e){return function(n){return n<.5?t(2*n,e)/2:(2-t(2*(1-n),e))/2}}(s,i):s,this.init()}dispose(){this.stop(),delete this.client}init(){}start(){if(this._started)return;if(this.client?.root?.app?.suppressAnimations)return;const{duration:t=2e3,delay:e=0,repeat:n=!1,interval:i=0,onComplete:r}=this.config;this._started=!0;let s=0,o=0;const a=()=>{if(this._raf=null,this._timeout=null,!this._started)return;if(this.client?.root?.app?.suppressAnimations)return void this.stop(r);0==s&&(s=performance.now(),this.client?.touch?.());const c=performance.now()-s,l=Math.max((c-e)%(t+i),0)/t,h=i<=0&&o>l;if(o=l,l>=1||h){if(this.step(1),this.client&&this.client.invalidate?.(),!n||!this._started)return this.stop(r),void(s=0);if(i>0)return void(this._timeout=setTimeout(()=>{this.step(0),this.client&&this.client.invalidate?.(),this._timeout=setTimeout(a,i/2)},i/2))}else this.step(this.delta(l)),this.client&&this.client.invalidate?.();this._raf=requestAnimationFrame(a)};this._raf=requestAnimationFrame(a)}stop(t){this._raf&&cancelAnimationFrame(this._raf),this._timeout&&clearTimeout(this._timeout),this._raf=null,this._timeout=null,this._started=!1,t?.()}step(t){}get started(){return this._started}set started(t){this.started!=!!t&&(t?this.start():this.stop())}}const Yo={rotation:class extends Ho{step(t){const{theta:e=6.28}=this.config;this.client.delta?.("theta",t*e)}},vibration:class extends Ho{step(t){const{theta:e=.2617993877991494}=this.config,n=4*e;let i=t*n;t<1/4?i*=-1:t<3/4?i-=2*e:i=n-i,this.client.delta?.("theta",i)}},heartbeat:class extends Ho{step(t){const{scale:e=1.3}=this.config,n=2*(e-1);let i;i=t<.5?1+n*t:1+(1-t)*n,this.client.delta?.({sx:i,sy:i,sz:i})}},moving:class extends Ho{step(t){const{x:e=0,y:n=0}=this.config;this.client.delta?.({tx:t*e,ty:t*n})}},outline:class extends Ho{step(t){const{rideOn:e}=this.config;if(!e||!this.client)return;const n=this.client.root.findById(e);if(!n)return;let i={tx:0,ty:0};const r=this.client.delta("");r&&"object"==typeof r&&"tx"in r&&"ty"in r&&(i=r);const{tx:s,ty:o}=i,a=n.outline(t),{x:c,y:l}=this.client.center,h=this.client.toScene(c,l);this.client.delta({tx:a.x-h.x+s,ty:a.y-h.y+o})}},fade:class extends Ho{step(t){const{startAlpha:e=1,endAlpha:n=0}=this.config,i=Math.max(Math.min(e,n,1),0),r=2*(Math.min(Math.max(e,n,1),1)-i);let s;s=t<.5?r*t:(1-t)*r,this.client.delta?.("fade",s)}},waypoint:class extends Ho{constructor(){super(...arguments),this._startX=0,this._startY=0,this._endX=0,this._endY=0}start(){let{toComponent:t,fromComponent:e}=this.config;e||(e=t);const n=e.center,i=t.center,{x:r,y:s}=e.toScene(n.x,n.y),{x:o,y:a}=t.toScene(i.x,i.y);this._startX=r,this._startY=s,this._endX=o,this._endY=a;const c=this.config.yawOffset??Math.PI/2,l=Math.atan2(a-s,o-r)+c;this.client.location={x:r,y:s},this.client.setState("rotation",l),super.start()}stop(t){const{toComponent:e,finalize:n="snap"}=this.config;if(super.stop(t),"snap"===n&&e){const t=e.center,n=e.toScene(t.x,t.y);this.client.delta({tx:0,ty:0}),this.client.location=n}}step(t){const e=(this._endX-this._startX)*t,n=(this._endY-this._startY)*t;this.client.location={x:this._startX+e,y:this._startY+n}}}};function Go(t,e){const n=e.type?Yo[e.type]:void 0;return n?new n(t,e):null}const Vo={gradation:function(t,e,n){const{subType:i,from:r,to:s,colors:o}=n;let a;switch(i){case"linear":default:a=e.createLinearGradient(r.x,r.y,s.x,s.y);break;case"radial":a=e.createRadialGradient(r.x,r.y,r.r,s.x,s.y,s.r)}o&&(o.forEach(function(t){a.addColorStop(t.endPoint,t.color)}),e.fillStyle=a,e.fill())},shadow:Ws};function Uo(t){return this._animate&&this._animate.stop(),this._animate=No(t),this._animate}function $o(t,e){return function(t,e,n){const i=Vo[n.type];i&&i(t,e,n)}(this,t,e)}const Wo=100;function Xo(t,e){if(null!==e){if("number"==typeof e){if(!Number.isFinite(e))return;if(!Number.isInteger(e))return Math.round(e*Wo)/Wo}return e}}function qo(t){if(null==t||"object"!=typeof t)return t;for(const e in t){const n=t[e];null===n?delete t[e]:"number"==typeof n?Number.isFinite(n)?Number.isInteger(n)||(t[e]=Math.round(n*Wo)/Wo):delete t[e]:"object"==typeof n&&qo(n)}return t}function Ko(...t){return JSON.stringify(this.hierarchy,Xo,...t)}function Qo(){delete this._model[""],"chartjs"!==this._model.type&&delete this._model.chart}function Zo(t){this.rootModel.closeScene(t)}function Jo(t,e){return t?"object"==typeof t?(this._delta={...this._delta,...t},this._delta):void 0!==e?(this._delta[t]=e,this._delta[t]):void 0:this._delta}function ta(){this.parent&&this.parent.invalidate()}function ea(){const t=this.nature["value-property"]||"text";return"value"==t?this.getState("value"):this[t]}function na(t){const e=this.nature["value-property"]||"text";"value"==e?this.setState("value",t):this[e]=t}function ia(){return this.getState("data")}function ra(t){this.setState("data",t),this.touch()}function sa(t){const e=this.model.event?.tap;if(e){const{x:t,y:n}=this.center;this.rootModel?._doEventAction(e,this,!0,new MouseEvent("click",{clientX:t,clientY:n}))}}function oa(){return!this._mappings&&this.parent&&this.buildMappings(),this._mappings}function aa(){return Number(this.get("retention"))||0}function ca(){if(this.app.isViewMode&&!this.isTemplate()){if(!this._animation){const t=this.state.animation;t&&t.oncreate&&(this._animation=Go(this,t.oncreate))}return this._animation}}function la(){return!!this.animation?.started}function ha(t){this.animation&&(this.animation.started=t)}function da(){}function ua(t,e,n,i){const r=e.get("class");if(!r)return!1;return(r.split(" ")||[]).indexOf(t.substr(1))>=0}function pa(t,e,n,i){return t==e.get("type")}function fa(t,e,n,i){if("(all)"==t)return!0;switch(t.charAt(0)){case"#":return function(t,e){return t.substring(1)==e.get("id")}(t,e);case".":return ua(t,e);case"(":return function(t,e,n,i){switch(t){case"(all)":return!0;case"(self)":return i===e;case"(root)":return!i.parent&&i===e;case"(descendant)":return i!==e;case"(child)":return i===e.parent;default:return!1}}(t,e,0,i);default:return pa(t,e)}}function ga(t,e,n,i,r,s){return t(e,n,i,r)&&s.push(n),n.components&&n.components.forEach(n=>{ga(t,e,n,i,r,s)}),s}function ma(t,e,n,i){switch(t){case"(all)":return!0;case"(parent)":return n&&n.parent===e;case"(child)":case"(children)":return n&&n===e.parent;case"(sibling)":case"(siblings)":return n&&n.parent===e.parent&&n!==e;default:return!1}}function ya(t,e,n){if("(root)"==t)return[e];if("(self)"==t)return n?[n]:[];let i;switch(t.charAt(0)){case"#":const n=e.root.findAllById?.(t.substring(1));return n||[];case".":i=ua;break;case"(":i=ma;break;default:i=pa}return ga(i,t,e,n,e,[])}function ba(t,...e){if(t(this,...e))return this}function _a(t,...e){return"string"==typeof t?ya(t,this,e[0]||this):"function"==typeof t&&t(this,...e)?[this]:void 0}function va(t,e,n){if(!this.capturable||n?.(this))return!1;const i=this.fromParent(t,e);return this.contains(i.x,i.y)?this:void 0}function xa(t){return this.anchors.find(e=>e.name===t)}function wa(t){return!0}function Ma(t){return this._parent.getContext(t??this)}function Sa(){return this.isRoot()?this:this.parent&&this.parent.root}function Aa(){return this.isRootModel()?this:this.parent&&this.parent.rootModel}function Ea(){return this._parent}function ka(t){this._parent=t}function Ca(){return this.nature.anchors||[]}function Ta(){let t=this.position,e=this;for(;"static"===t&&e.parent;)e=e.parent,t=e.position;return"static"==t}function Pa(){return!!(this.parent&&this.parent.layout.isStuck(this)||this.get("locked"))}function Da(){return!1!==this.get("capturable")&&(this.app.isEditMode||!this.hidden)}function Oa(){return this.app?.isViewMode&&this.isPositionable()?this.state.position??"static":"static"}function za(){return this.app&&this.app.isViewMode&&this.state.origin||""}function La(){const{offsetX:t=0,offsetY:e=0}=this.state;return{x:t,y:e}}function Ia(){return!this._app&&this.parent&&(this._app=this.parent.app),this._app}const Ra={},ja={mutable:!1,resizable:!0,rotatable:!0,properties:[],"value-property":"text"},Fa=[],Ba=new Set(["data","text","value","source","accessor","mappings","variables","fillStyle","strokeStyle","fontColor","alpha","opacity","hidden","locked","hatched","started","animation","sensitive","event","src","href","url","class","templatePrefix"]),Na={theta:0,tx:0,ty:0,sx:1,sy:1,fade:0};let Ha=0;const Ya={};const Ga=new FinalizationRegistry(t=>{!function(t){Ha--;let e=Ya[t];e||(e=Ya[t]={up:0,down:0}),e.down++}(t)});class Va{static get nature(){return ja}static register(t,e){if(!e)return Ra[t];Ra[t]=e}static types(){return Object.keys(Ra)}static get residents(){return Ya}static get residentsCount(){return Ha}static registerDecorator(t,e){vs.registerDecorator(t,e)}constructor(t,e){this._app=e,this._model=t||{},this._state={},this._delta=Yn(Na),e&&this.animation?.config&&(1==this.animation.config.autoplay||(this.animation.config.autoplay??1))&&(this.animation.started=!0),this.clearCache(),fs.add(this),function(t){Ha++;let e=Ya[t];e||(e=Ya[t]={up:0,down:0}),e.up++}(this._model.type),Ga.register(this,this._model.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){this._cachedState=null,function(t,...e){0==e.length?t.__cache__={}:e.forEach(e=>delete t.__cache__[e])}(this,...t)}removeSelf(t){t?this.dispose():this.parent?.removeComponent?.(this)}resetAnimation(){this._animation&&(this._animation.dispose(),this._animation=null,this._delta=Yn(Na))}dispose(){this.resetAnimation(),this.disposeMappings(),this.parent?.removeComponent?.(this),delete this._text_substitutor,delete this._value_substitutor,this._disposed=!0,this._realObject&&(this._realObject.dispose(),this._realObject=void 0),this.retention&&fs.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!0}get is3dMode(){return!1}isIn3DSpace(){return!!this._realObject}isTemplate(){return!!this.get("templatePrefix")}isHTMLElement(){return!1}isConnectable(){return!1}isIdentifiable(){return!0}isPositionable(){return this.parent?.isRootModel()}replaceRefids(t){}get(t){return this._model[t]}set(t,e){if("string"==typeof t)return this.set({[t]:e});const n=this;return this._applyProps(this._model,t,{getBeforeVal:function(t){return n._model[t]},clearState:!0,sensitive:!1,beforeFillStyle:function(t,e){t.hasOwnProperty("retention")&&fs.add(n)},afterFillStyle:function(t,e){t.hasOwnProperty("mappings")&&n.onchangeMappings(t,e)}})}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});const n=this;return this._applyProps(this._state,t,{getBeforeVal:function(t){return n.getState(t)},clearState:!1,sensitive:this.getState("sensitive")})}get model(){return this._model}get state(){return this._cachedState||(this._cachedState=Object.freeze(Object.assign({},this._model,this._state))),this._cachedState}get hierarchy(){const t=Yn(this._model);return this.volatile.forEach(e=>{delete t[e]}),qo(t)}get volatile(){return Fa}_applyProps(t,e,n){const i={},r={};let s=!1;const o=Yn(e),a=this;if(Object.getOwnPropertyNames(o).forEach(function(e){const c=n.getBeforeVal(e),l=o[e];!n.sensitive&&function(t,e){return ve(t,e)}(c,l)||(r[e]=c,i[e]=l,t[e]=l,n.clearState&&delete a._state[e],s=!0)}),s){this._cachedState=null;Object.keys(i).some(t=>!Ba.has(t))&&this.clearCache(),i.hasOwnProperty("text")&&delete this._text_substitutor,n.beforeFillStyle&&n.beforeFillStyle(i,r),i.hasOwnProperty("fillStyle")&&this.onchangeFill(i,r),n.afterFillStyle&&n.afterFillStyle(i,r),i.hasOwnProperty("data")&&this.onchangeData(i,r),this.onchange&&this.onchange(i,r),this.trigger("change",i,r)}return this}contains(t,e){return ws.call(this,t,e)}move(t,...e){Ms.call(this,t,...e)}symmetryX(t){Ss.call(this,t)}symmetryY(t){As.call(this,t)}adjustResize(t,e,n){return Es.call(this,t,e,n)}adjustRotation(t,e){return ks.call(this,t,e)}outline(t){return Cs.call(this,t)}get bounds(){return Ts.call(this)}set bounds(t){Ps.call(this,t)}get center(){return Ds.call(this)}set center(t){Os.call(this,t)}get location(){return zs.call(this)}set location(t){Ls.call(this,t)}get rotate(){return Is.call(this)}set rotate(t){Rs.call(this,t)}get dimension(){return js.call(this)}set dimension(t){Fs.call(this,t)}get path(){return Bs.call(this)}set path(t){Ns.call(this,t)}get drawPath(){return Hs.call(this)}get rotatePoint(){return Ys.call(this)}get mutable(){return Gs.call(this)}get resizable(){return Vs.call(this)}get rotatable(){return Us.call(this)}buildRealObject(){}get realObject(){return this.disposed||this._realObject||(this._realObject=this.buildRealObject(),this._realObject&&(this._realObject.update(),this._realObject.updateTransform())),this._realObject}draw(t){t&&Xs.call(this,t)}prerender(t){qs.call(this,t)}render(t){Ks.call(this,t)}postrender(t){Qs.call(this,t)}prepare(t,e){Zs.call(this,t,e)}prepareIf(t){Js.call(this,t)}drawText(t){to.call(this,t)}drawStroke(t,e){eo.call(this,t,e)}drawFill(t,e){no.call(this,t,e)}get strokeStyle(){return io.call(this)}set strokeStyle(t){ro.call(this,t)}get fillStyle(){return so.call(this)}set fillStyle(t){oo.call(this,t)}get fontColor(){return ao.call(this)}set fontColor(t){co.call(this,t)}get rotation(){return lo.call(this)}set rotation(t){ho.call(this,t)}get decorators(){return uo.call(this)}get decotag(){return po.call(this)}get hidden(){return fo.call(this)}set hidden(t){go.call(this,t)}get tag(){return mo.call(this)}set tag(t){yo.call(this,t)}get appendum(){return bo.call(this)}set appendum(t){_o.call(this,t)}defaultTextSubstitutor(){return vo.call(this)}textLines(t){return xo.call(this,t)}get font(){return wo.call(this)}get lineHeight(){return Mo.call(this)}get textSubstitutor(){return So.call(this)}get text(){return Ao.call(this)}set text(t){Eo.call(this,t)}get textBounds(){return ko.call(this)}get textRotation(){return Co.call(this)}get textHidden(){return To.call(this)}set textHidden(t){Po.call(this,t)}get hasTextProperty(){return Do.call(this)}animate(t){return Uo.call(this,t)}effect(t,e){return $o.call(this,t,e)}serialize(...t){return Ko.call(this,...t)}trim(){Qo.call(this)}closeScene(t){Zo.call(this,t)}delta(t,e){return Jo.call(this,t,e)}invalidate(){ta.call(this)}get value(){return ea.call(this)}set value(t){na.call(this,t)}get data(){return ia.call(this)}set data(t){ra.call(this,t)}set tap(t){sa.call(this,t)}get mappings(){return oa.call(this)}get retention(){return aa.call(this)}get animation(){return ca.call(this)}get started(){return la.call(this)}set started(t){ha.call(this,t)}get controls(){return da.call(this)}findFirst(t,...e){return ba.call(this,t,...e)}findAll(t,...e){return _a.call(this,t,...e)}capture(t,e,n){return va.call(this,t,e,n)}findAnchor(t){return xa.call(this,t)}isDescendible(t){return wa.call(this,t)}getContext(t){return Ma.call(this,t)}get root(){return Sa.call(this)}get rootModel(){return Aa.call(this)}get parent(){return Ea.call(this)}set parent(t){ka.call(this,t)}get anchors(){return Ca.call(this)}get scalable(){return Ta.call(this)}get stuck(){return Pa.call(this)}get capturable(){return Da.call(this)}get position(){return Oa.call(this)}get origin(){return za.call(this)}get offset(){return La.call(this)}get app(){return Ia.call(this)}drawEffect(t){vr.call(this,t)}prepareFill(t,e){Dr.call(this,t,e)}prepareFillIf(t){Or.call(this,t)}onchangeFill(t,e){zr.call(this,t,e)}drawImage(t,e,n,i,r,s){_r.call(this,t,e,n,i,r,s)}mutateBounds(t,e){as.call(this,t,e)}mutatePath(t,e,n){cs.call(this,t,e,n)}access(t){return ys.call(this,t)}substitute(t,e){return bs.call(this,t,e)}onchangeMappings(t,e){br.call(this,t,e)}onchangeData(t,e){gr.call(this,t,e)}buildMappings(){mr.call(this)}executeMappings(t){fr.call(this,t)}disposeMappings(){yr.call(this)}ondropfile(t,e){Gr.call(this,t,e)}transcoordS2P(t,e,n){return Xr.call(this,t,e,n)}transcoordP2S(t,e,n){return Wr.call(this,t,e,n)}transcoordS2T(t,e,n){return Kr.call(this,t,e,n)}transcoordT2P(t,e,n){return Qr.call(this,t,e,n)}transcoordT2S(t,e,n){return Zr.call(this,t,e,n)}transcoordS2TR(t,e,n){return qr.call(this,t,e,n)}transcoordS2O(t,e,n){return Jr.call(this,t,e,n)}transcoordC2S(t,e,n){return ts.call(this,t,e,n)}transcoordS2C(t,e,n){return es.call(this,t,e,n)}toParent(t,e,n){return Xr.call(this,t,e,n)}fromParent(t,e,n){return Wr.call(this,t,e,n)}toScene(t,e,n){return Kr.call(this,t,e,n)}fromScene(t,e,n){return Zr.call(this,t,e,n)}toLocal(t,e,n){return ts.call(this,t,e,n)}toGlobal(t,e,n){return es.call(this,t,e,n)}toOther(t,e,n){return Jr.call(this,t,e,n)}on(t,e,n){return Di.call(this,t,e,n)}off(t,e,n){return Oi.call(this,t,e,n)}once(t,e,n){return zi.call(this,t,e,n)}trigger(t,...e){return Li.call(this,t,...e)}delegate_on(t){return Ii.call(this,t)}delegate_off(t){return Ri.call(this,t)}onchange(t,e){}removeComponent(t,e){}addComponent(t,e){}insertComponentAt(t,e,n){}getOverlay(t){}findById(t){}findByRefid(t){}findAllById(t){return[]}resize(){}fit(t){}get components(){}get layout(){}get auxOverlay(){}get isReady(){return!1}get unitScale(){return 1}get selected(){return[]}set selected(t){}get focused(){return null}set focused(t){}get hasSameParentForAllSelected(){return!1}set hasSameParentForAllSelected(t){}get fitMode(){}set fitMode(t){}get element(){return null}set element(t){}}Va.union=ns,Va.transcoordR=Ur,Va.transcoordRR=$r,Va.createCanvas=Tr,Va.memoize=Hi,Va.mixin=ji,Va.drawText=Hr,Va.font=Br,Va.textLines=Fr,Va.drawStroke=Lr,Va.drawFill=Pr,Va.reposition=os,Va.RetentionManager=fs,Va.template=function(t,e,n){var i=ln.imports._.templateSettings||ln;n&&Ie(t,e,n)&&(e=void 0),t=on(t),e=je({},e,i,qe);var r=je({},e.imports,i.imports,qe),s=Qt(r),o=function(t,e){return $e(e,function(e){return t[e]})}(r,s);xe(s,function(t){if(pn.test(t))throw new Error("Invalid `imports` option passed into `_.template`")});var a,c,l=0,h=e.interpolate||gn,d="__p += '",u=RegExp((e.escape||gn).source+"|"+h.source+"|"+(h===Ze?fn:gn).source+"|"+(e.evaluate||gn).source+"|$","g"),p=yn.call(e,"sourceURL")?"//# sourceURL="+(e.sourceURL+"").replace(/\s/g," ")+"\n":"";t.replace(u,function(e,n,i,r,s,o){return i||(i=r),d+=t.slice(l,o).replace(mn,Qe),n&&(a=!0,d+="' +\n__e("+n+") +\n'"),s&&(c=!0,d+="';\n"+s+";\n__p += '"),i&&(d+="' +\n((__t = ("+i+")) == null ? '' : __t) +\n'"),l=o+e.length,e}),d+="';\n";var f=yn.call(e,"variable")&&e.variable;if(f){if(pn.test(f))throw new Error("Invalid `variable` option passed into `_.template`")}else d="with (obj) {\n"+d+"\n}\n";d=(c?d.replace(hn,""):d).replace(dn,"$1").replace(un,"$1;"),d="function("+(f||"obj")+") {\n"+(f?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(a?", __e = _.escape":"")+(c?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+d+"return __p\n}";var g=Ue(function(){return Function(s,p+"return "+d).apply(void 0,o)});if(g.source=d,Ve(g))throw g;return g},Va.buildSubstitutor=_s,["rotatePoint","font","lineHeight","retention"].forEach(t=>Va.memoize(Va.prototype,t,!1)),["bounds","center","textBounds"].forEach(t=>Va.memoize(Va.prototype,t,!0));class Ua extends Va{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,void 0),this.drawStroke(t,void 0),super.postrender(t)}render(t){const e=this.drawPath,{round:n=0}=this.state;if(!(e.length<=1)){t.beginPath();for(let i=0;i<e.length;i++){const r=e[(i-1+e.length)%e.length],s=e[(i+e.length)%e.length],o=e[(i+1)%e.length];if(r.x===s.x&&r.y===s.y)continue;let a=Math.sqrt((r.x-s.x)*(r.x-s.x)+(r.y-s.y)*(r.y-s.y)),c=0!==a?Math.atan2(r.x-s.x,r.y-s.y):0,l=Math.sin(c)*Math.min(n,a/2)+s.x,h=Math.cos(c)*Math.min(n,a/2)+s.y;const d=n>0||0!==a?{x:l,y:h}:s;a=Math.sqrt((o.x-s.x)*(o.x-s.x)+(o.y-s.y)*(o.y-s.y)),c=0!==a?Math.atan2(o.x-s.x,o.y-s.y):0,l=Math.sin(c)*Math.min(n,a/2)+s.x,h=Math.cos(c)*Math.min(n,a/2)+s.y;const u=n>0||0!==a?{x:l,y:h}:s;0==i?t.moveTo(d.x,d.y):t.lineTo(d.x,d.y),n>0&&t.quadraticCurveTo(s.x,s.y,u.x,u.y)}t.closePath()}}}function $a(t,e,n){return Math.max(0,Math.min(t,Math.min(n,e)/2))}function Wa(t){const e=class extends t{contains(t,e){const{left:n,top:i,width:r,height:s,lineWidth:o=0}=this.state,a=o/2;return t<Math.max(n+r,n)+a&&t>Math.min(n+r,n)-a&&e<Math.max(i+s,i)+a&&e>Math.min(i+s,i)-a}set path(t){const e=t[0],n=t[2];this.set({left:e.x,top:e.y,width:n.x-e.x,height:n.y-e.y})}get path(){const{left:t=0,top:e=0,width:n=0,height:i=0}=this.state;return[{x:t,y:e},{x:t+n,y:e},{x:t+n,y:e+i},{x:t,y:e+i}]}get anchors(){return function(t){const{left:e,top:n,width:i,height:r}=t.bounds,s=e+i/2,o=n+r/2;return[{name:"TOP",position:{x:s,y:n}},{name:"RIGHT",position:{x:e+i,y:o}},{name:"BOTTOM",position:{x:s,y:n+r}},{name:"LEFT",position:{x:e,y:o}}]}(this)}get bounds(){const{left:t=0,top:e=0,width:n=0,height:i=0}=this.state;return{left:t,top:e,width:n,height:i}}set bounds(t){this.set({left:0,top:0,width:0,height:0,...t})}render(t){let{round:e=0}=this.model;const{left:n,top:i,width:r,height:s}=this.bounds;t.translate(n,i),t.beginPath(),e=$a(e,r,s),e>0?t.roundRect(0,0,r,s,e):t.rect(0,0,r,s),t.translate(-n,-i)}};return Hi(e.prototype,"path",!1),Hi(e.prototype,"bounds",!0),e}const Xa={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 qa=20;function Ka(t,e){const n=t.split(/\s+/),i=n.indexOf(e);return-1!=i?n.splice(i,1):n.splice(-1,0,e),n.join(" ")}class Qa extends(Wa(Ua)){static get image(){return Qa._image||(Qa._image=new Image,Qa._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=="),Qa._image}static toggle(t,e,n,i){if(!e)return void Bi("InfoWindow not defined.");const r=t.root.findById(e);r?r._findInfoWindowByComponent(t)?Qa.hide(t,e):Qa.show(t,e,n,i):Bi("InfoWindow Not Found.",e)}static hide(t,e){if(!e)return;const n=t.root.findById(e);n?n._removeInfoWindow(t):Bi("InfoWindow Not Found.",e)}static show(t,n,i,r){if(!n)return void Bi("InfoWindow not defined.");const s=t.root.findById(n);if(!s)return void Bi("InfoWindow Not Found.",n);if(s._findInfoWindowByComponent(t))return;const{frontSideTemplate:o="",backSideTemplate:a=""}=s.model;let c=[o,a].filter(t=>String(t).trim());if(c=c.map(t=>Va.template(function(t,e,n){return(e||n?['<div class="info-window-btns">',e?'<button class="closable">X</button>':"",n?'<button class="flipable">⇌</button>':"","</div>"]:[]).concat(['<div class="info-window-content">',t,"</div>"]).join("")}(t,!i,2==c.length))),0==c.length)return;const 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'+s.get("style");let{left:h,top:d}=t.bounds;const{x:u,y:p}=r?t.rootModel.toLocal(r.x,r.y):t.toScene(h,d);h=u,d=p;const f=document.createElement("span");f.style.position="absolute";const g=document.createElement("style");let m,y;g.type="text/css",g.appendChild(document.createTextNode(l)),f.appendChild(g),c[0]&&(m=document.createElement("div"),m.id="side-1",m.className="flip",m.style.display="inline-block",m.innerHTML=e.sanitize(c[0](t),{ADD_TAGS:["style"],ADD_ATTR:["class","id","style"]})),c[1]&&(y=document.createElement("div"),y.id="side-2",y.className="flip",y.style.display="inline-block",y.innerHTML=e.sanitize(c[1](t),{ADD_TAGS:["style"],ADD_ATTR:["class","id","style"]}));const b=t.rootModel.getOverlay(t);m&&f.appendChild(m),y&&f.appendChild(y),b.appendChild(f);const _=s._addInfoWindow(t,f,g).signal;if(Sr.forEach(function(t){f.addEventListener(t,t=>t.stopPropagation(),{signal:_})}),Ar.forEach(function(t){f.addEventListener(t,t=>t.stopPropagation(),{signal:_})}),m){const e=m.querySelector(".info-window-btns > .flipable");e&&e.addEventListener("click",function(t){t.preventDefault(),y.className=Ka(y.className,"flip-side-1"),m.className=Ka(m.className,"flip-side-2")},{signal:_});const i=m.querySelector(".info-window-btns > .closable");i&&i.addEventListener("click",function(e){e.preventDefault(),Qa.hide(t,n)},{signal:_})}if(y){const e=y.querySelector(".info-window-btns > .flipable");e&&e.addEventListener("click",function(t){t.preventDefault(),y.className=Ka(y.className,"flip-side-1"),m.className=Ka(m.className,"flip-side-2")},{signal:_});const i=y.querySelector(".info-window-btns > .closable");i&&i.addEventListener("click",function(e){e.preventDefault(),Qa.hide(t,n)},{signal:_})}const v=m.offsetWidth,x=m.offsetHeight,w=t.rootModel.target.getBoundingClientRect(),M=[];m&&M.push(m),y&&M.push(y);const S={x:h,y:d};let A=t.toGlobal(S.x,S.y);if(A.x+v/2+w.left<w.right&&A.x-v/2>w.left){if(x+qa<A.y)return f.style.marginLeft=S.x-v/2+"px",f.style.marginTop=S.y-x-qa+"px",void M.forEach(t=>t.className+=" arrow-bottom");if(A=t.toGlobal(S.x,S.y+x+qa),w.bottom>A.y+w.top)return f.style.marginLeft=S.x-v/2+"px",f.style.marginTop=S.y+qa+"px",void M.forEach(t=>t.className+=" arrow-top")}if(A=t.toGlobal(S.x,S.y),A.x-(v+qa)>w.left)return f.style.marginLeft=S.x-v-qa+"px",f.style.marginTop=S.y-x/2+"px",void M.forEach(t=>t.className+=" arrow-right");f.style.marginLeft=S.x+qa+"px",f.style.marginTop=S.y-x/2+"px",M.forEach(t=>t.className+=" arrow-left")}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,n){if(this._findInfoWindowByComponent(t))return;const i=new AbortController;return this._windows.push({component:t,window:e,styleElement:n,abortController:i}),i}_removeInfoWindow(t){const e=this._findInfoWindowByComponent(t);if(!e)return;e.abortController.abort();const n=e.window;n&&n.parentNode.removeChild(n);const i=this.infoWindows.lastIndexOf(e);this.infoWindows.splice(i,1)}render(t){const{left:e,top:n,width:i,height:r}=this.bounds;t.beginPath(),this.drawImage(t,Qa.image,e,n,i,r)}get hasTextProperty(){return!1}get nature(){return Xa}}Va.register("info-window",Qa);const Za={};var Ja={list:function(){return{...Za}},register:function(t,e){Za[t]=e},unregister:function(t){delete Za[t]},get:function(t){if(!t)return;const e=Za[t];return e||Fi("Layout Not Found - ",t),e}};const tc=new class{constructor(){this.ABSOLUTE=!0}reflow(t,e){this.drawables(t).filter(t=>t.isHTMLElement()).forEach(t=>t.reposition())}capturables(t){return t.components}drawables(t){return t.app&&!t.app.isViewMode?t.components:t.components.filter(t=>!t.hidden)}isStuck(t){return!1}};Ja.register("html-absolute",tc);const ec=new class{constructor(){this.ABSOLUTE=!0}reflow(t,e){}capturables(t){return t.components}drawables(t){return t.app?.isViewMode?t.components.filter(t=>!t.hidden):t.components}isStuck(t){return!1}};function nc(t){const e=t.components.filter(t=>!t.hidden),n=t.getState("layoutConfig")||{},i=e[n&&n.activeIndex||0];return i&&[i]||[]}Ja.register("absolute",ec);const ic=new class{reflow(t){const e=t.bounds,n=t.getState("layoutConfig")||{},i={left:0,top:0,width:e.width,height:e.height};t.forEach((t,e)=>{const r=e!=(n.activeIndex||0);t.bounds=i,t.setState("rotation",0),"element"in t&&t.element&&(t.element.style.visibility=r?"hidden":"visible")})}capturables(t){return nc(t)}drawables(t){return nc(t)}isStuck(t){return!0}};function rc(t){const e=t.getState("layoutConfig");return e&&e.weight||1}Ja.register("card",ic);const sc=new class{reflow(t){const e=this.drawables(t),n=t.getState("padding")||{},i=e.reduce((t,e)=>t+rc(e),0),r=t.bounds,s=i>0?(r.width-((n.left||0)+(n.right||0)))/i:r.width,o=r.height-((n.top||0)+(n.bottom||0));let a=0;e.forEach(t=>{const e=rc(t),i=t.getState("margin")||{};t.bounds={left:s*a+(n.left||0)+(i.left||0),top:0+(n.top||0)+(i.top||0),width:e*s-((i.left||0)+(i.right||0)),height:o-((i.top||0)+(i.bottom||0))},t.setState("rotation",0),a+=e})}capturables(t){return t.components}drawables(t){return t.app?.isViewMode?t.components.filter(t=>!t.hidden):t.components}isStuck(t){return!0}};function oc(t){const e=t.getState("layoutConfig");return e&&e.weight||1}Ja.register("linear-horizontal",sc);const ac=new class{reflow(t){const e=this.drawables(t),n=t.getState("padding")||{},i=e.reduce((t,e)=>t+oc(e),0),r=t.bounds,s=i>0?(r.height-((n.top||0)+(n.bottom||0)))/i:r.height,o=r.width-((n.left||0)+(n.right||0));let a=0;e.forEach(t=>{const e=oc(t),i=t.getState("margin")||{};t.bounds={left:0+(n.left||0)+(i.left||0),top:s*a+(n.top||0)+(i.top||0),width:o-((i.left||0)+(i.right||0)),height:e*s-((i.top||0)+(i.bottom||0))},t.setState("rotation",0),a+=e})}capturables(t){return t.components}drawables(t){return t.app?.isViewMode?t.components.filter(t=>!t.hidden):t.components}isStuck(t){return!0}};Ja.register("linear-vertical",ac);const cc=new class{constructor(){this.joinType=!0}reflow(t){const e=t.getState("layoutConfig"),n=e&&e.columns||t.getState("columns"),i=e&&e.rows||t.getState("rows"),r=e&&e.widths||t.getState("widths"),s=e&&e.heights||t.getState("heights"),o=r?r.filter((t,e)=>e<n).reduce((t,e)=>t+e,0):n,a=s?s.filter((t,e)=>e<i).reduce((t,e)=>t+e,0):i,c=t.textBounds,l=t.getState("paddingLeft")||0,h=t.getState("paddingTop")||0,d=c.width/o,u=c.height/a;let p=0,f=0;t.components.forEach((t,e)=>{const i=r?r[e%n]:1,o=s?s[Math.floor(e/n)]:1;let a=t.colspan||1,c=0;for(;--a>0;)c+=r?r[(e+a)%n]:1;let g=t.rowspan||1,m=0;for(;--g>0;)m+=s?s[Math.floor(e/n)+g]:1;t.bounds={left:l+p,top:h+f,width:d*(i+c),height:u*(o+m)},t.setState("rotation",0),e%n==n-1?(p=0,f+=o*u):p+=i*d})}capturables(t){return t.components.filter(t=>!t.merged)}drawables(t){return t.components.filter(t=>!t.merged&&!t.hidden)}isStuck(t){return!0}keyNavigate(t,e,n){const i=t.getState("layoutConfig"),r=i&&i.columns||t.getState("columns"),s=i&&i.rows||t.getState("rows"),{row:o,column:a}=t.getRowColumn(e);switch(n.code){case"ArrowUp":if(o>0)return t.getAt?.((o-1)*r+a);break;case"ArrowDown":if(o<s-1)return t.getAt?.((o+1)*r+a);break;case"ArrowRight":if(a<r-1)return t.getAt?.(o*r+a+1);break;case"ArrowLeft":if(a>0)return t.getAt?.(o*r+a-1);break;default:return e}}};function lc(){const t=arguments,e=t[t.length-1],n=this.event_pump;n.listeners.forEach(i=>{!function(t,e,n,i,r){for(const s in n){const o=n[s];if(fa(s,i.origin,0,t))for(const t in o){const n=o[t];t==i.name&&(i.listener=e,n.apply(e,r))}}}(n.deliverer,i.listener,i.cloned_handlers,e,t)})}Ja.register("table",cc);class hc{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)",lc,{event_pump:this})}stop(){this.deliverer.off("(all)",lc)}on(t,e){const n=Object.assign({},e);Object.keys(n).forEach(e=>{if(0==e.indexOf("?")){const i=n[e],r=e.substr(1),s=t.get(r);delete n[e],s?n[s]=i:Bi("EventPump#on","variable #{selector} is not evaluated on listener")}}),this.listeners.push({listener:t,handlers:e,cloned_handlers:n})}off(t,e){for(let n=0;n<this.listeners.length;n++){const i=this.listeners[n];i.listener!==t||e&&i.handlers!==e||this.listeners.splice(n,1)}}clear(){this.listeners=[]}dispose(){this.stop(),this.clear()}}class dc{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(const n in e){const i=e[n];if("(self)"===n&&void 0===t.on)throw new Error("(self) selector not available when deliverer is not a event handlable object.");ya(n,this.root,t).forEach(n=>{const r=new hc(n);r.on(t,i),r.start(),this.eventMaps.push({eventPump:r,listener:t,handlerMap:e,deliverer:n})})}}remove(t,e){const n=this.eventMaps.slice(0);for(let i=0;i<n.length;i++){const r=n[i];r.listener!==t||e&&r.handlerMap!==e||(this.eventMaps.splice(i,1),r.eventPump.dispose())}}clear(){this.eventMaps.slice(0).forEach(t=>t.eventPump.dispose()),this.eventMaps=[]}dispose(){this.stop(),this.clear()}}const uc=0,pc=1,fc=2,gc=0,mc=1,yc=2;let bc={},_c=0;class vc{constructor(t,e){this._type=e||t.type,this._ctrlKey=t.ctrlKey,this._altKey=t.altKey,this._shiftKey=t.shiftKey,this._metaKey=t.metaKey;const n=function(t){if(t.touches){const e=t.touches[0];if(!e)return bc;const n=e.target.getBoundingClientRect();return bc={x:t.offsetX||e.clientX-n.left,y:t.offsetY||e.clientY-n.top},bc}return{x:t.offsetX,y:t.offsetY}}(t);if(this._offsetX=n.x,this._offsetY=n.y,t.touches&&t.touches[0]?(this._clientX=t.touches[0].clientX,this._clientY=t.touches[0].clientY):(this._clientX=t.clientX,this._clientY=t.clientY),"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)){const e=function(t){let e,n,i=0,r=0,s=0;if(1===t.touches.length)return s;Array.from(t.touches).forEach(t=>{e=null!=e?Math.min(t.screenX,e):t.screenX,i=Math.max(t.screenX,i),n=null!=n?Math.min(t.screenY,n):t.screenY,r=Math.max(t.screenY,r)});const o=i-e||0,a=r-n||0;return s=Math.sqrt(Math.pow(o,2)+Math.pow(a,2))||0,s}(t);_c>0&&(this._scale=e/_c),_c=e}}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 clientX(){return this._clientX}get clientY(){return this._clientY}get touches(){return this._touches}get changedTouches(){return this._changedTouches}get scale(){return this._scale}stopPropagation(){this._stop_=!0,this.originalEvent?.stopPropagation()}isPropagationStopped(){return this._stop_}preventDefault(){this._prevented=!0}isDefaultPrevented(){return this._prevented}}function xc(t,e,n){if(!t||!t.app)return;if(t.app.isViewMode&&t.hidden)return;n instanceof vc&&e===n.type||(n=new vc(n,e));const i="on"+e;t[i]&&t[i](n),n.isPropagationStopped()||t.trigger(e,n)}class wc{constructor(t,e){this.gestureHandlerBuilder=t=>{const e=this[`on${t}`];return t=>{const n=new vc(t),i=this.getChildScrollOffset();return n._offsetX+=this.html_element.scrollLeft+i.scrollLeft,n._offsetY+=this.html_element.scrollTop+i.scrollTop,e(n),n.isDefaultPrevented()&&t.preventDefault(),!1}},this.keyeventHandlerBuilder=t=>this[`on${t}`],this.ondragover=t=>(xc(this.findTarget(t),t.type,t),!1),this.ondrop=t=>(xc(this.findTarget(t),t.type,t),!1),this.ondblclick=t=>(xc(this.findTarget(t),t.type,t),this.last_target=null,!1),this.onkeydown=t=>(this.container.trigger(t.type,t),!1),this.onkeyup=t=>(this.container.trigger(t.type,t),!1),this.onmousemove=t=>{switch(this.status){case pc:const e=t.offsetX-this.__dragstart_e.offsetX,n=t.offsetY-this.__dragstart_e.offsetY;if(e*e+n*n<16)break;this.status=fc,xc(this.last_target,"dragstart",this.__dragstart_e),this.__dragmove_e=t,xc(this.last_target,"dragmove",t);break;case fc:this.__dragmove_e=t,xc(this.last_target,"dragmove",t);break;default:{const e=this.findTarget(t);this.last_enter_target!==e&&(this.last_enter_target&&xc(this.last_enter_target,"mouseleave",t),e&&xc(e,"mouseenter",t),this.last_enter_target=e),xc(e,t.type,t),this.last_target=e}}return!1},this.onmousedown=t=>{if(this.status===fc)xc(this.last_target,"dragend",t),this.last_target=null,this.status=uc;else{const e=this.findTarget(t);this.last_target=e,this.status=pc,this.__dragstart_e=t,xc(e,t.type,t)}return!1},this.onmouseup=t=>{if(this.status===fc)xc(this.last_target,"dragend",t);else{const e=this.findTarget(t);xc(e,t.type,t),this.last_target===e&&xc(e,"click",t)}return this.last_target=null,this.status=uc,!1},this.onmouseout=t=>{const e=this.findTarget(t);if(this.status===fc)xc(this.last_target,"dragend",t);else{if(this.last_target&&this.last_target===e)return;this.last_enter_target&&(xc(this.last_enter_target,"mouseleave",t),delete this.last_enter_target)}return this.last_target=null,this.status=uc,!1},this.ontouchstart=t=>{const e=this.findTarget(t);return this.last_target=e,this.status=mc,this.touchPoints||(this.touchPoints=[]),this.touchPoints.push(t.changedTouches[0]),this.holdTimer=setTimeout(()=>{this.status=gc,xc(this.last_target,"hold",t),delete this.holdTimer},500),xc(e,t.type,t),!1},this.ontouchmove=t=>{if(!t.touches||!t.changedTouches)return xc(this.last_target,"dragstart",t),xc(this.last_target,"dragmove",t),!1;let e=this.findTarget(t);switch(this.status){case mc:Array.from(t.changedTouches).forEach(t=>{const e=this.touchPoints.find(e=>e.identifier===t.identifier);if(!e)return;const n=e.clientX-t.clientX,i=e.clientY-t.clientY;return Math.sqrt(Math.pow(n,2)+Math.pow(i,2))>=16?(this.status=yc,void(this.holdTimer&&(clearTimeout(this.holdTimer),delete this.holdTimer))):void 0});break;case yc: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 xc(this.last_target,"pinch",t),!1;xc(this.last_target,"pan",t),e=this.last_target;break;default:this.last_enter_target!==e&&(this.last_enter_target&&xc(this.last_enter_target,"mouseleave",t),e&&xc(e,"mouseenter",t),this.last_enter_target=e),this.last_target=e}return xc(e,"touchmove",t),!1},this.ontouchend=t=>{let e=this.findTarget(t);switch(this.status){case yc:e=this.last_target;break;case mc:{const n=performance.now(),i=n-this.touchedAt;this.holdTimer&&(clearTimeout(this.holdTimer),delete this.holdTimer,xc(e,i<500?"doubletap":"tap",t),this.touchedAt=n);break}}xc(e,"touchend",t);const n=this.touchPoints.findIndex(e=>e.identifier===t.changedTouches[0].identifier);return this.touchPoints.splice(n,1),this.last_target=null,this.status=gc,!1},this.onwheel=t=>(xc(this.findTarget(t),t.type,t),!1),this.container=t,this.html_element=e,this.status=uc,this.last_target=null,this.gesture_handlers=Sr.map(t=>this.gestureHandlerBuilder(t)),this.keyevent_handlers=Ar.map(t=>this.keyeventHandlerBuilder(t)),Sr.forEach((t,n)=>e.addEventListener(t,this.gesture_handlers[n]),{passive:!1}),Ar.forEach((t,n)=>e.addEventListener(t,this.keyevent_handlers[n])),e.ondragover=this.gestureHandlerBuilder("dragover"),e.ondrop=this.gestureHandlerBuilder("drop"),e.tabIndex=1}dispose(){this.last_enter_target&&xc(this.last_enter_target,"mouseleave",new CustomEvent("mouseleave")),Sr.forEach((t,e)=>this.html_element.removeEventListener(t,this.gesture_handlers[e])),Ar.forEach((t,e)=>this.html_element.removeEventListener(t,this.keyevent_handlers[e])),delete this.gesture_handlers,delete this.keyevent_handlers,delete this.last_target}getChildScrollOffset(){for(const t of this.html_element.children)if(t.scrollTop>0||t.scrollLeft>0)return{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop};return{scrollLeft:0,scrollTop:0}}findTarget(t){const e=this.container.rootModel;if(e?.is3dMode)return e;const n=this.html_element.getBoundingClientRect(),i=this.getChildScrollOffset(),r=t.clientX-n.left+this.html_element.scrollLeft+i.scrollLeft,s=t.clientY-n.top+this.html_element.scrollTop+i.scrollTop;return this.container.capture(r,s)}}class Mc{constructor(t){this.params=Object.assign({},t)}excute(){}}class Sc extends Mc{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,n){e.call(n),t.execute(null,!1)}}function Ac(t,e,n,i=0){if(e.length<2)return e;let r=2;for(;r<e.length;r++){const s=e.substring(0,r);if(!(t.measureText(s).width+(s.length-1)*i<n))break}return e.substring(0,r-1)}function Ec(t,e,n,i,r=0){const s=String(e).split("\n");return i?[].concat.apply([],s.map(e=>function(t,e,n,i=0){const r=e.split(" "),s=[];let o,a,c=[];for(o=0,a=1;a<=r.length;a++)if(c=r.slice(o,a),t.measureText(c.join(" ")).width+(c.join("").length-1)*i>n){if(a-o==1){const e=Ac(t,c[0],n,i);s.push([e]),r.splice(o,1,e,c[0].substring(e.length))}else{for(;""==r[a-1];)a++;s.push(r.slice(o,--a))}o=a}return a-o>1&&s.push(c),0==s.length&&s.push([""]),s}(t,e,n,r))):s.map(t=>t.split(" "))}const kc={},Cc={},Tc=()=>{};var Pc={register:function(t,e,n){kc[t]=e,n&&(Cc[t]=n)},unregister:function(t){delete kc[t],delete Cc[t]},get:function(t){return kc[t]},getDisposer:function(t){return Cc[t]||Tc}};function Dc(t){if(!t.hasTextProperty||t.textHidden)return;let{text:e="",bold:n=Er.BOLD,italic:i=Er.ITALIC,textWrap:r=Er.TEXT_WRAP,letterSpacing:s=0,fontFamily:o=Er.FONT_FAMILY,fontColor:a=Er.FONT_COLOR,textAlign:c=Er.TEXT_ALIGN,textBaseline:l=Er.TEXT_BASELINE,fontSize:h=Er.FONT_SIZE,lineHeight:d=1.2*h}=t.model;const{left:u,top:p,width:f,height:g}=t.textBounds;h||=Er.FONT_SIZE,d||=1.2*h,t.textHidden=!0;const m=document.createElement("textarea"),y=new AbortController;Sr.forEach(function(t){m.addEventListener(t,t=>t.stopPropagation(),{capture:!0,signal:y.signal})});const b=t.toGlobal(u,p),{rotation:_,scale:v}=function(t){let e=0,n=1,i=t;for(;i;){e+=i.get("rotation")||0;const{x:t,y:r}=i.get("scale")||{x:1,y:1};n*=Math.max(t,r)||1,i=i.parent}return{rotation:e,scale:n}}(t);m.value=e;const x={position:"absolute",width:f+"px",height:g+"px",padding:"0",fontFamily:o,fontSize:h+"px",lineHeight:d+"px",overflow:"hidden",resize:"none",outline:"none",border:"0",backgroundColor:"transparent",display:"inline-block",color:a};switch(n&&(x.fontWeight="bold"),i&&(x.fontStyle="italic"),c){case"right":case"end":x.textAlign="right";break;case"justify":x.textAlign="justify";break;case"left":case"start":x.textAlign="left";break;default:x.textAlign="center"}const w=[n,i,h+"px",o].filter(Boolean).join(" ");function M(e){const n={left:0,top:0},i=d*function(t,e,n,i,r=0){const s=t.getContext();let o;return s.save(),s.font=n,o=Ec(s,e,i,t.get("textWrap"),r).length,s.restore(),o}(t,e,w,f,s);switch(x.height=i+"px",l){case"top":case"hanging":break;case"bottom":case"alphabetic":n.top=g-i;break;default:n.top=g/2-i/2}if(!r){const i=function(t,e,n,i){const r=e.split("\n");let s=i;const o=t.getContext();return o.save(),o.font=n,r.forEach(t=>{const e=o.measureText(t).width;e>s&&(s=e)}),o.restore(),s}(t,e,w,f);switch(x.width=i+"px",c){case"right":case"end":n.left=f-i;break;case"left":case"start":break;default:n.left=(f-i)/2}}x.marginLeft=n.left+"px",x.marginTop=n.top+"px",x.transform=`translate(${b.x}px, ${b.y}px) scale(${v}) rotate(${_}rad)`,x.transformOrigin=`${-n.left}px ${-n.top}px`,Object.assign(m.style,x)}M(e);const S=t.root.target_element;S.appendChild(m),m.select();let A,E=!1;m.addEventListener("keydown",function(t){t.stopPropagation(),"Escape"!=t.code&&(t.shiftKey||"Enter"!=t.code&&"NumpadEnter"!=t.code)?setTimeout(()=>{M(m.value)}):(E=A.skipUpdate="Escape"==t.code,"function"==typeof document.createEvent?m.dispatchEvent(A):m.fireEvent(A.eventType,A))},{signal:y.signal}),document.createEvent?(A=document.createEvent("HTMLEvents"),A.initEvent("blur",!0,!1)):(A=document.createEventObject(),A.eventType="blur");const k=t.root.selected,C=function(n){t.root.selected=k,t.textHidden=!1,y.abort(),m.removeEventListener("blur",C,!1),m.parentElement&&m.parentElement.removeChild(m),S.focus(),n.skipUpdate||E||t.app.commander.execute(new Sc({changes:[{component:t,before:{text:e},after:{text:m.value}}]}))};m.addEventListener("blur",C,!1)}function Oc(t){let e=0;for(;t&&!t.isRootModel();)e+=t.get("rotation")||0,t=t.parent;return e%(2*Math.PI)}Pc.register("text-editor",{"(root)":{"(self)":{keydown:function(t,e){const{deliverer:n}=e,i=n.selected;return!(1!==i.length||!i[0].hasTextProperty)&&(("Enter"==t.code||"NumpadEnter"==t.code)&&(Dc(i[0]),t.preventDefault(),!0))}}},"model-layer":{"(descendant)":{dblclick:function(t,e){Dc(e.origin)}}}});class zc extends Mc{execute(){this.params.changes.forEach(t=>{const{component:e,to_container:n,to_index:i,to_left:r,to_top:s}=t,o=function(t){if(t.isRootModel())return t.bounds;const{bounds:e,rotatePoint:n}=t;let i=n;return i=t.toScene(i.x,i.y),{left:i.x-(n.x-e.left),top:i.y-(n.y-e.top),width:e.width,height:e.height}}(e),a=Oc(e);if(function(t){const e=t.parent?.model?.zPos;if(null==e)return;const n=t.state.zPos||0;t.set("zPos",n+e)}(e),e.removeSelf(!n),e.bounds=o,e.set("rotation",a),n){e.set("rotation",function(t,e){return((t.get("rotation")||0)-Oc(e))%(2*Math.PI)}(e,n));const o=function(t,e){if(e.isRootModel())return t.bounds;const{bounds:n,rotatePoint:i}=t,r=e.fromScene(i.x,i.y),s=e.bounds;return{left:r.x-(i.x-n.left)-s.left,top:r.y-(i.y-n.top)-s.top,width:n.width,height:n.height}}(e,n);t.to_left=void 0!==r?r:o.left,t.to_top=void 0!==s?s:o.top,e.bounds={left:t.to_left,top:t.to_top,width:o.width,height:o.height},void 0===i?n.addComponent(e):n.insertComponentAt(e,i)}})}}class Lc{constructor(t){const e=[],n=[];for(let i=0,r=t.length;i<r;i++){const r=t[i],s=r.left,o=r.left+r.width,a=s+r.width/2,c=r.top,l=r.top+r.height,h=c+r.height/2;e.push({value:s,perpMin:c,perpMax:l},{value:a,perpMin:c,perpMax:l},{value:o,perpMin:c,perpMax:l}),n.push({value:c,perpMin:s,perpMax:o},{value:h,perpMin:s,perpMax:o},{value:l,perpMin:s,perpMax:o})}e.sort((t,e)=>t.value-e.value),n.sort((t,e)=>t.value-e.value),this.xEdges=e,this.yEdges=n}get empty(){return 0===this.xEdges.length&&0===this.yEdges.length}calculateSnap(t,e,n,i){if(0===this.xEdges.length&&0===this.yEdges.length)return{dx:e,dy:n,guides:[]};const r={left:t.left+e,top:t.top+n,width:t.width,height:t.height},s=r.left,o=s+r.width,a=s+r.width/2,c=r.top,l=c+r.height,h=c+r.height/2,d=this.findBestSnap(this.xEdges,[s,a,o],i),u=this.findBestSnap(this.yEdges,[c,h,l],i),p=d?e+d.correction:e,f=u?n+u.correction:n;if(!d&&!u)return{dx:e,dy:n,guides:[]};const g=[];if(d){const e=t.top+f,n=e+t.height;for(const t of d.matches)g.push({axis:"x",position:t.value,from:Math.min(e,t.perpMin),to:Math.max(n,t.perpMax)})}if(u){const e=t.left+p,n=e+t.width;for(const t of u.matches)g.push({axis:"y",position:t.value,from:Math.min(e,t.perpMin),to:Math.max(n,t.perpMax)})}return{dx:p,dy:f,guides:g}}findBestSnap(t,e,n){let i=n+1,r=0,s=[];for(let o=0;o<3;o++){const a=e[o],c=this.searchNearest(t,a,n);if(!c)continue;const l=Math.abs(c.correction);if(l<i)i=l,r=c.correction,s=c.matches;else if(l===i&&c.correction===r)for(const t of c.matches)s.push(t)}return i<=n?{correction:r,matches:s}:null}searchNearest(t,e,n){const i=t.length;if(0===i)return null;let r=0,s=i;for(;r<s;){const n=r+s>>1;t[n].value<e?r=n+1:s=n}let o=-1,a=n+1;if(r<i){const i=t[r].value-e;i<=n&&(o=r,a=i)}if(r>0){const n=e-t[r-1].value;n<a&&(o=r-1,a=n)}if(o<0||a>n)return null;const c=t[o].value,l=c-e,h=[t[o]];for(let e=o-1;e>=0&&t[e].value===c;e--)h.push(t[e]);for(let e=o+1;e<i&&t[e].value===c;e++)h.push(t[e]);return{correction:l,matches:h}}}function Ic(t,e,n,i){const r=Va.register(t.type);if(!r)return Bi("Class not found",t.type),null;n&&(t.refid=n(t.refid)),t.id&&i&&i(t.id)&&delete t.id;const s=new r(t,e);return t.components&&s.isContainer()&&(t.components.forEach(t=>{const r=Ic(t,e,n,i);r&&s.addComponent(r)}),delete t.components),s.created(),s}function Rc(t,e){const n=Yn(t.hierarchy);return delete n.id,Ic(n,t.app,e)}function jc(t){const e=t.root;if(!e||!e.assist_layers)return null;for(const t of e.assist_layers)if("snap-guide-layer"===t.state?.type)return t;return null}const Fc=ti(function(t,e,n){if(!t.hasSameParentForAllSelected||n)return void(t.focused=null);const i=[];e[0].parent.isGroup()?t.focused=e[0].parent:(e.forEach(t=>{t.path.forEach(e=>{i.push(t.toScene(e.x,e.y))})}),t.focused=t.capturePath(i,e))},300);let Bc;Pc.register("move-handler",{"model-layer":{"(descendant)":{dragstart:function(t,e){const{origin:n,deliverer:i}=e;if(n.stuck)return;let r=i.selected;const s=i.selected.filter(t=>!t.stuck);if(r.length!==s.length&&(r=i.selected=s),0==r.length)return;let o;if(r[0].scalable?(o=r[0].toLocal(t.offsetX,t.offsetY),o=r[0].toParent(o.x,o.y)):o={x:t.offsetX,y:t.offsetY},this.last_pos=o,this.direction=0,i.focused=r[0].parent,t.altKey){const t=[],e=new Map;i.selected=i.selected.filter(t=>!t.isRootModel()).map(n=>{const r=Rc(n,t=>{const n=i.root.getNewRefid();return void 0!==t&&e.set(t,n),n});return t.push({component:r,to_container:n.parent}),r}).map(t=>(t.replaceRefids(e),t)),t.forEach(({component:t,to_container:e})=>{e.addComponent(t)}),this.duplicates=i.selected.map(t=>({component:t}))}else this.changes=Sc.before(r);this.snapIndex=function(t){if(0===t.length)return null;const e=t[0].parent;if(!e||!e.components)return null;const n=new Set(t),i=[];for(const t of e.components)t.isLayer?.()||t.stuck||n.has(t)||i.push(t.bounds);return 0===i.length?null:new Lc(i)}(r);const a=n.rootModel?.get("scale"),c=a?(Math.abs(a.x)+Math.abs(a.y))/2:1;this.snapThreshold=5/(c||1)},dragmove:function(t,e){const{origin:n,deliverer:i}=e;if(n.stuck)return;const r=i.selected;if(0==r.length||!this.last_pos)return;let s;r[0].scalable?(s=r[0].toLocal(t.offsetX,t.offsetY),s=r[0].toParent(s.x,s.y)):s={x:t.offsetX,y:t.offsetY},t.shiftKey?2==this.direction&&(this.direction=0):this.direction=2;let o=s.x-this.last_pos.x,a=s.y-this.last_pos.y;if(0==this.direction){if(o*o+a*a<25)return;Math.abs(o)>Math.abs(a)?this.direction=3:this.direction=4}3==this.direction?a=0:4==this.direction&&(o=0);const c=this.snapIndex,l=c&&!t.metaKey&&!t.ctrlKey,h=o,d=a;if(l){const t=function(t){return 0===t.length?null:1===t.length?t[0].bounds:ns(t.map(t=>t.bounds))}(r);if(t){const e=c.calculateSnap(t,o,a,this.snapThreshold);o=e.dx,a=e.dy;const n=jc(i);n&&(n.snapResult=e.guides.length>0?e:null)}}else{const t=jc(i);t&&(t.snapResult=null)}r.forEach(t=>{t.move({x:o,y:a},1===r.length)}),this.last_pos={x:s.x-(h-o),y:s.y-(d-a)},Fc(i,r)},dragend:function(t,e){const{origin:n,deliverer:i}=e;if(n.stuck)return;const r=i.selected;if(0==r.length)return;const s=r[0].parent,o=i.focused||e.deliverer;if(this.changes&&!o.isGroup())if(i.hasSameParentForAllSelected&&o&&o!==s){const t=this.changes.map(t=>{const{component:e}=t;return{component:e,to_container:o}});i.app.commander.execute(new zc({changes:t}))}else Sc.after(this.changes,i.app.commander);else if(this.duplicates){this.duplicates=this.duplicates.map(t=>(t.to_container=o,t));const t=new zc({changes:this.duplicates});i.app.commander.execute(t)}r.forEach(t=>{t.parent&&t.parent.calculateBounds&&t.parent.calculateBounds()}),this.last_pos=null,this.changes=null,this.duplicates=null,this.snapIndex=null,this.snapThreshold=5;const a=jc(i);a&&a.clear(),Fc(i,r,!0)}}},"(root)":{"(self)":{keydown:function(t,e){const{origin:n,deliverer:i}=e,r={},s=t.shiftKey?n.rootModel.MPP:1;switch(t.which){case 37:r.x=-s,r.y=0;break;case 38:r.x=0,r.y=-s;break;case 39:r.x=s,r.y=0;break;case 40:r.x=0,r.y=s;break;default:return}const o=i.selected;Sc.around(i.app.commander,function(){o.forEach(t=>{!t.stuck&&t.move(r,!1)})})}}}}),Pc.register("shift-handler",{"model-layer":{"(all)":{dragstart:function(t,e){Bc={x:t.offsetX,y:t.offsetY}},dragmove:function(t,e){const{deliverer:n}=e,i=t.offsetX,r=t.offsetY;n.rootModel.move({x:i-Bc.x,y:r-Bc.y},!1),Bc={x:i,y:r}}}}}),Pc.register("zoom-handler",{"model-layer":{"(all)":{wheel:function(t,e){if(0==t.deltaY&&0==t.deltaX)return;const n=e.deliverer,i=t.deltaY<0?1:-1,r=n.get("scale")||{x:1,y:1},s=n.get("translate"),o=t.offsetX,a=t.offsetY,c=n.toLocal(o,a),l=.1*i,h={x:r.x+l,y:r.y+l};if(i<0&&r.x<.2||i>0&&r.x>10)return;n.set("scale",h);const d=n.toLocal(o,a);n.set("translate",{x:s.x+(d.x-c.x)*h.x,y:s.y+(d.y-c.y)*h.y})}},"(self)":{dblclick:function(t,e){const n=e.origin;n?.root.fit()}}}});let Nc={},Hc={};function Yc(t){const e={};for(const n in t)t.hasOwnProperty(n)&&void 0!==t[n]&&(e[n]=t[n]);return e}Pc.register("paste-handler",{"(root)":{"(self)":{stylepastestart:function(t){const{deliverer:e}=t,n=e.app,i=e.selected;if(i&&i[0]&&i!==e.rootModel){const t=i[0],{fillStyle:e,strokeStyle:r,alpha:s,lineWidth:o,lineDash:a,lineCap:c,lineJoin:l,fontColor:h,fontSize:d,fontFamily:u,bold:p,italic:f,textAlign:g,textBaseline:m,textOverflow:y,paddingTop:b,paddingBottom:_,paddingLeft:v,paddingRight:x}=t.state;Nc=Yn({fillStyle:e,strokeStyle:r,alpha:s,lineWidth:o,lineDash:a,lineCap:c,lineJoin:l,fontColor:h,fontSize:d,fontFamily:u,bold:p,italic:f,textAlign:g,textBaseline:m,textOverflow:y,paddingTop:b,paddingBottom:_,paddingLeft:v,paddingRight:x}),n.mode=4}},stylepastestop:function(t){const{deliverer:e}=t,n=e.app;Nc={},4==n.mode&&(n.mode=1)},databindpastestart:function(t){const{deliverer:e}=t,n=e.app,i=e.selected;if(i&&i[0]&&i!==e.rootModel){const t=i[0],{mappings:e}=t.state;Hc=Yn({mappings:e}),n.mode=5}},databindpastestop:function(t){const{deliverer:e}=t,n=e.app;Hc={},5==n.mode&&(n.mode=1)},pasteapply:function(t,e){const{deliverer:n}=e,i=n.app;t&&(4==i.mode?Sc.around(i.commander,()=>{t.set(Yc({...t.model,...Nc}))}):5==i.mode&&Sc.around(i.commander,()=>{t.set(Yc({...t.model,...Hc}))}))},keydown:function(t,e){const{deliverer:n}=e;"Esc"!=t.code&&"Escape"!=t.code||(4==n.app.mode?n.trigger("stylepastestop"):5==n.app.mode&&n.trigger("databindpastestop"))}}},"model-layer":{"(all)":{click:function(t,e){const{deliverer:n}=e,i=n.app;if(4!=i.mode&&5!=i.mode)return;const r=e.origin;4==i.mode?r===n?n.root.trigger("stylepastestop"):r&&Sc.around(i.commander,()=>{const t=Yc({...r.model,...Nc});r?.set(t)}):r===n?n.root.trigger("databindpastestop"):r&&Sc.around(i.commander,()=>{const t=Yc({...r.model,...Hc});r?.set(t)})}}}});class Gc{constructor(){this.animatorMap=new Map}waypoint(t,e){this.animatorMap.has(t)&&this.off(t);let{from:n,to:i}=e;if("string"==typeof n&&(n=t.root?.findById(n)),"string"==typeof i&&(i=t.root.findById(i)),!i)return void Bi("WaypointAnimation: Source or target component not found");const r=Go(t,{type:"waypoint",fromComponent:n,toComponent:i,...e,onComplete:()=>{this.off(t)}});r&&(this.animatorMap.set(t,r),r.start())}off(t){const e=this.animatorMap.get(t);e&&(e.stop(),this.animatorMap.delete(t))}reset(t){if(this.animatorMap.size>0){for(const t of this.animatorMap.values())t.stop();this.animatorMap.clear()}}dispose(){this.reset(null),this.animatorMap=null}}function Vc(t){const{origin:e}=t,n=e.root,{waypointHandler:i}=n;i?.reset()}Pc.register("waypoint-handler",{"model-layer":{"(descendant)":{waypoint:function(t,e){const{origin:n}=e,i=n.root;let{waypointHandler:r}=i;r||(r=new Gc,i.waypointHandler=r),r.waypoint(n,t)},waypointoff:function(t){const{origin:e}=t,n=e.root,{waypointHandler:i}=n;i?i.off(e):Bi("waypoint-handler not found")},waypointreset:Vc},"(self)":{waypointreset:Vc}}},function(t){const{waypointHandler:e}=t;e&&(e.dispose(),delete t.waypointHandler)});class Uc{constructor(){this.animatorMap=new Map}transition(t,e){this.animatorMap.has(t)&&this.off(t);const n=Go(t,{type:"transition",fromComponent:e.from,toComponent:e.to,...e,onComplete:()=>{this.off(t)}});n&&(this.animatorMap.set(t,n),n.start())}off(t){const e=this.animatorMap.get(t);e&&(e.stop(),this.animatorMap.delete(t))}reset(){for(const t of this.animatorMap.values())t.stop();this.animatorMap.clear()}dispose(){this.reset(),this.animatorMap=null}}function $c(t){const{origin:e}=t,n=e.root,{transitionHandler:i}=n;i?.reset()}function Wc(t){return t<.5?2*t*t:1-2*(1-t)*(1-t)}Pc.register("transition-handler",{"model-layer":{"(descendant)":{transition:function(t,e){const{origin:n}=e,i=n.root;let{transitionHandler:r}=i;r||(r=new Uc,i.transitionHandler=r),r.transition(n,t)},transitionoff:function(t){const{origin:e}=t,n=e.root,{transitionHandler:i}=n;i?i.off(e):Bi("transition-handler not found")},transitionreset:$c},"(self)":{transitionreset:$c}}},function(t){const{transitionHandler:e}=t;e&&(e.dispose(),delete t.transitionHandler)});class Xc{constructor(t){this.active=new Map,this.rafId=0,this._canvas=null,this._ctx=null,this.root=t}isReparenting(t){return this.active.has(t)}getState(t){return this.active.get(t)||null}begin(t,e){if(this.cancel(t),this.root?.app?.suppressAnimations)return this.cleanup3D(t),t.clearCache?.(),void t.invalidate?.();const n={fromWorld:e.fromWorld,toWorld:e.toWorld,from3D:e.from3D,to3D:e.to3D,duration:Math.max(e.duration,1),startTime:performance.now(),progress:0};if(this.active.set(t,n),n.fromWorld&&this.ensureCanvas(),n.from3D){const e=t._realObject?.object3d;if(e){e.position.copy(n.from3D.pos),e.quaternion.copy(n.from3D.quat);const t=n.from3D.fromScale;t&&e.scale.set(t.x,t.y,t.z)}}this.startLoop()}cancel(t){this.active.has(t)&&this.complete(t)}renderComponent(t,e){const n=this.active.get(t);if(!n?.fromWorld||!n?.toWorld||!this._ctx)return;const i=this._ctx,r=n.progress,s=n.fromWorld,o=n.toWorld,a=s.x+(o.x-s.x)*r,c=s.y+(o.y-s.y)*r,l=s.rotation+(o.rotation-s.rotation)*r,h=s.width+(o.width-s.width)*r,d=s.height+(o.height-s.height)*r,{translate:u={x:0,y:0},scale:p={x:1,y:1}}=e.model;i.save(),i.translate(u.x,u.y),i.scale(p.x,p.y),i.translate(a,c),i.rotate(l);const f=t.bounds;if(f&&f.width&&f.height){const t=h/f.width,e=d/f.height;i.scale(t,e),i.translate(-(f.left+f.width/2),-(f.top+f.height/2))}t.render(i),i.restore()}beginDraw(){if(!this._canvas||!this._ctx)return;this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._ctx.save();const t=globalThis.devicePixelRatio||1;this._ctx.scale(t,t)}endDraw(){this._ctx&&this._ctx.restore()}resize(){if(!this._canvas)return;const t=this.root?.model_layer;if(!t?.element)return;const e=t.element.clientWidth,n=t.element.clientHeight;t.fitSize(this._canvas,!0,e,n)}dispose(){for(const[t]of this.active)this.cleanup3D(t);this.active.clear(),this.stopLoop(),this.removeCanvas()}ensureCanvas(){if(this._canvas)return;const t=this.root?.model_layer;if(!t?.element)return;const e=t.element;this._canvas=document.createElement("canvas"),this._canvas.width=1,this._canvas.height=1,this._canvas.style.position="absolute",this._canvas.style.pointerEvents="none",this._canvas.style.zIndex="50",this._canvas.setAttribute("scene","transition-canvas"),e.appendChild(this._canvas);const n=e.clientWidth,i=e.clientHeight;t.fitSize(this._canvas,!0,n,i),this._ctx=this._canvas.getContext("2d")}removeCanvas(){this._canvas&&(this._canvas.parentNode?.removeChild(this._canvas),this._canvas=null,this._ctx=null)}startLoop(){if(this.rafId)return;const t=()=>{this.tick(),this.active.size>0?this.rafId=requestAnimationFrame(t):this.rafId=0};this.rafId=requestAnimationFrame(t)}stopLoop(){this.rafId&&(cancelAnimationFrame(this.rafId),this.rafId=0)}tick(){if(this.root?.app?.suppressAnimations){const t=[...this.active.keys()];for(const e of t)this.complete(e);return}const t=performance.now(),e=[];for(const[n,i]of this.active){const r=t-i.startTime,s=Math.min(r/i.duration,1),o=Wc(s);if(i.progress=o,i.from3D&&i.to3D){const t=n._realObject?.object3d;if(t){t.position.lerpVectors(i.from3D.pos,i.to3D.pos,o),t.quaternion.copy(i.from3D.quat).slerp(i.to3D.quat,o);const e=i.from3D.fromScale,n=i.from3D.toScale;e&&n&&t.scale.set(e.x+(n.x-e.x)*o,e.y+(n.y-e.y)*o,e.z+(n.z-e.z)*o)}}n.clearCache?.(),n.invalidate?.(),s>=1&&e.push(n)}for(const t of e)this.complete(t)}complete(t){this.active.get(t),this.cleanup3D(t),this.active.delete(t),t.clearCache?.(),t.invalidate?.();let e=!1;for(const[,t]of this.active)if(t.fromWorld){e=!0;break}e||this.removeCanvas()}cleanup3D(t){const e=t._realObject;e&&(e.object3d&&e.object3d.scale.set(1,1,1),e.suppressTransform=!1,e.update?.())}}const qc=new Image;function Kc(t){return class extends t{get showMoveHandle(){return!1}postrender(t){super.postrender(t),this.app.isEditMode&&this._focused&&this.showMoveHandle&&this._draw_move_handle(t)}_draw_move_handle(t){const{left:e,top:n,width:i}=this.bounds;t.save(),t.beginPath(),t.globalAlpha=1,t.rect(e+i,n,25,25);t.fillStyle="rgba(235, 235, 235, 1)",t.fill(),t.drawImage(qc,e+i+3.75,n+3.75,17.5,17.5),t.closePath(),t.restore()}contains(t,e){let n=super.contains(t,e);if(this.app.isViewMode)return n;if(!n){const{left:i,top:r,width:s}=this.bounds,o=i+s,a=25;this.showMoveHandle&&(n=t<Math.max(o+25,o)&&t>Math.min(o+25,o)&&e<Math.max(r+a,r)&&e>Math.min(r+a,r))}return this._focused!==n&&(this._focused=n,this.invalidate()),n}}}qc.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAAclBMVEVHcEwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAC0BbqFAAAAJXRSTlMAgAP3VSI6/g9fBk5FavJsMrariSjzPnO1enRRL5SMhmOOWB9keFTE0wAAANxJREFUOMutk9kWgyAMRLFuiLjUtdp9yf//YglVsQXz1HniMPcEMgHGvpX2O0Ypi+EgCL+IAShC+wB7QfubRDT7AFcnUPoLMLiP4PyJbsb55i05AgnR5iaQDsICgtH0cotBWoAP1c7kC6kFxEseCfZfB6gEgbNeBrira2QmH1uVYCXlA3is8UmgUCPIyQJKEmu8QtQJN0e9DPXVpzG2G216c1CqRmcBOdxXk07sWUSPv07zo0amCNQycv+NzmR6cRcwmfbuI7p2nZ/z4be0P83Foz6vIkhfZXr82XgDlZsspIq4peUAAAAASUVORK5CYII=";const Qc=[];class Zc extends(Kc(Wa(Va))){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 Ja.get(this.get("layout"))||ec}reflow(){this.layout.reflow(this),this.components&&this.components.forEach(t=>{t.isContainer()&&t.reflow()})}get hierarchy(){const t=super.hierarchy;return this.components?.length&&(t.components=this.components.map(t=>t.hierarchy)),t}reparent(t,e={}){if(!t)return;const{animated:n=!1,duration:i=2e3,ease:r="inout"}=e,s=t.parent;if(!s||s===this)return;const o=t=>{let e=0,n=t;for(;n&&!n.isRootModel?.();)e+=n.state?.rotation||0,n=n.parent;return e},a=!(!t._realObject?.object3d||!this._realObject?.object3d);let c=null,l=null,h=null,d=null;if(a){const e=this._realObject.object3d,n=t._realObject.object3d,i=t._realObject.dimension||{width:1,height:1,depth:1};e.updateWorldMatrix(!0,!1),n.updateWorldMatrix(!0,!1),e.attach(n),c={pos:n.position.clone(),quat:n.quaternion.clone(),fromDimW:i.width||1,fromDimH:i.height||1,fromDimD:i.depth||1},t._realObject.suppressTransform=!0}else{const e=t.bounds,n=t.center,i=t.toScene(n.x,n.y);h={x:i.x,y:i.y,rotation:o(s),width:e.width,height:e.height}}if(this.addComponent(t,{silent:!0}),a){const e=t._realObject.object3d;t.clearCache();const n=t._realObject.position,i=t._realObject.rotation,r=t._realObject.dimension||{width:1,height:1,depth:1},s=r.width||1,o=r.height||1,a=r.depth||1,h={x:c.fromDimW/s,y:c.fromDimH/o,z:c.fromDimD/a};l={pos:e.position.clone().set(n.x,n.y,n.z),quat:e.quaternion.clone().setFromEuler(e.rotation.clone().set(i.x,i.y,i.z))},c.fromScale=h,c.toScale={x:1,y:1,z:1},e.position.copy(c.pos),e.quaternion.copy(c.quat)}else{const e=t.bounds,n=t.center,i=t.toScene(n.x,n.y);d={x:i.x,y:i.y,rotation:o(this),width:e.width,height:e.height}}if(n){const e=this.root?.transitionEffect;e&&e.begin(t,{fromWorld:h,toWorld:d,from3D:c,to3D:l,duration:i,ease:r})}}addComponent(t,e=!1){const{ghost:n=!1,silent:i=!1}="boolean"==typeof e?{ghost:e}:e,r=t.parent;if(r){if(this===r)return;r.removeComponent(t,n||i)}const s=this._components.push(t)-1;i&&(t._silentAdd=!0),t.parent=this,t.added(this),n||i||this.trigger("add",this,t,s),t.delegate_on(this),i?(r&&this.root?._removeTraverse?.(t),this.trigger("add",this,t,s),t.trigger("added",this,t,s),delete t._silentAdd):n||t.trigger("added",this,t,s),this.root&&this.root.isReady&&t.ready()}removeComponent(t,e=!1){const n=this._components.indexOf(t);-1!=n&&(this._components.splice(n,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,n=!1){const i=t.parent;i&&i.removeComponent(t,n);const r=this._components.splice(0,e);this._components=r.concat(t,this._components),e=this._components.indexOf(t),t.parent=this,t.added(this),n||this.trigger("add",this,t,e),t.delegate_on(this),n||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(n=>{n.isContainer()?n.traverse(t,e):t.call(e,n)})}indexOf(t){return(this._components||Qc).indexOf(t)}size(){return(this._components||Qc).length}moveChildAt(t,e){const n=this.indexOf(e);if(-1==n)return;let i=this._components.splice(0,n);const r=this._components.splice(1);this._components=i.concat(r),t=Math.max(0,t),t=Math.min(t,this._components.length),i=this._components.splice(0,t),this._components=i.concat(e,this._components)}moveChildForward(t){const e=this.indexOf(t);-1!=e&&e!=this.size()-1&&(this._components[e]=this._components[e+1],this._components[e+1]=t)}moveChildBackward(t){const e=this.indexOf(t);-1!=e&&0!=e&&(this._components[e]=this._components[e-1],this._components[e-1]=t)}moveChildToFront(t){const e=this.indexOf(t);if(-1==e||e==this.size()-1)return;const n=this._components.splice(0,e),i=this._components.splice(1);this._components=n.concat(i,this._components)}moveChildToBack(t){const e=this.indexOf(t);if(-1==e||0==e)return;const n=this._components.splice(0,e),i=this._components.splice(1);this._components=this._components.concat(n,i)}symmetryX(t){super.symmetryX(t),this.components.map(t=>{t.symmetryX(0)})}findAll(t,...e){if("string"==typeof t)return ya(t,this,e[0]||this);if("function"!=typeof t)return[];let n=[];for(let i=this.components.length-1;i>=0;i--){const r=this.components[i].findAll(t,...e);r&&(n=n.concat(r))}return t(this,...e)&&n.push(this),n}findFirst(t,...e){if("string"==typeof t)return ya(t,this,e[0])[0];if("function"==typeof t){for(let n=this.components.length-1;n>=0;n--){const i=this.components[n].findFirst(t,...e);if(null!=i)return i}return t(this,...e)?this:void 0}}findById(t){return this.root.findAllById?.(t)?.[0]}findByRefid(t){return this.root.findByRefid?.(t)}contains(t,e){let n=super.contains(t,e);if(!n){const{left:i,top:r,width:s,height:o}=this.state;n=t<Math.max(i+s,i)&&t>Math.min(i+s,i)&&e<Math.max(r+o,r)&&e>Math.min(r+o,r)}return n}capture(t,e,n){if(!this.app.isEditMode&&this.hidden)return!1;const i=this.fromParent(t,e);if(!this.contains(i.x,i.y))return!1;const r=this.bounds;i.x-=r.left,i.y-=r.top;const s=this.layout.capturables(this);for(let r=s.length-1;r>=0;r--){const o=s[r];let a;if(a="static"==o.position?o.capture(i.x,i.y,n):o.capture(t,e,n),a)return a}return this.capturable&&!n?.(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}const n=[],{left:i,top:r,width:s,height:o}=this.bounds;for(let e=0;e<t.length;e++){const a=this.fromParent(t[e].x,t[e].y);if(a.x<i||a.x>i+s||a.y<r||a.y>r+o)return!1;a.x-=i,a.y-=r,n.push(a)}const a=this.layout.capturables(this);for(let t=a.length-1;t>=0;t--){const i=a[t];if(!i.isContainer())continue;const r=i.capturePath(n,e);if(r)return r}return this.focusible&&this}render(t){if("popup"===this.position)return;const{left:e=0,top:n=0,width:i,height:r}=this.bounds;t.beginPath(),t.rect(e,n,i,r),t.closePath(),this.drawFill(t),this.drawStroke(t)}postrender(t){if("popup"===this.position)return void super.postrender(t);const e=this.layout.drawables(this);if(e.length>0){let{left:n=0,top:i=0,width:r,height:s}=this.bounds;t.save(),this.showOverflow||(t.beginPath(),t.rect(n,i,r,s),t.clip(),t.closePath()),({top:i,left:n}=this.state),t.translate(n,i),e.forEach(e=>{const n=this.root?.transitionEffect;n?.isReparenting(e)?n.renderComponent(e,this.root?.model_layer):e.draw(this.position&&"static"!==this.position?t:this.getContext(e))}),t.translate(-n,-i),t.restore()}super.postrender(t)}trim(){this.components.forEach(t=>{t.trim()}),super.trim()}}["layout"].forEach(t=>Va.memoize(Zc.prototype,t,!1));const Jc=[],tl=ti(function(){Jc.forEach(t=>{t.resize()})},100);"undefined"!=typeof window&&window.addEventListener("resize",tl);class el extends Zc{constructor(t,e){super(Object.assign({type:"root",scale:{x:1,y:1}},t||{}),e),this._hasSameParentForAllSelected=!1,this._maxRefid=e?.isViewMode?1e6:0,t=t||{},this.fitMode=t.model&&t.model.fitMode,this._app=e,this.style=t.style,this.indexMap=new Map,this.refidIndexMap=new Map,this.templateMap={},this._serviceMap=new Map,this.transitionEffect=new Xc(this),this.target_element=t.target_element,this.rebuildContentModel(this.model.model),Jc.push(this)}registerService(t,e){this._serviceMap.set(t,e)}getService(t){return this._serviceMap.get(t)}unregisterService(t){this._serviceMap.delete(t)}dispose(){Md.hideAll(this),this.transitionEffect?.dispose(),this._app&&this._app.dispose(),super.dispose(),this._disposeAllResources(),this.target_element=null,this._refresh_mapping_debouncer&&"function"==typeof this._refresh_mapping_debouncer.cancel&&this._refresh_mapping_debouncer.cancel(),delete this._refresh_mapping_debouncer;const t=Jc.indexOf(this);t>=0&&Jc.splice(t,1),this.refidIndexMap.clear(),this.indexMap.clear(),this._serviceMap.clear(),this._maxRefid=0}isRoot(){return!0}get app(){return this._app}get target_element(){return this._target_element}set target_element(t){this._ua_event_handler&&(this._ua_event_handler.dispose(),delete this._ua_event_handler),t&&(t.style.position="absolute",t.style.cursor="default",t.style.overflow="hidden",t.setAttribute("scene","root-container"),this._ua_event_handler=new wc(this,t)),this.forEach(e=>e.target=t),this._target_element=t}get fitMode(){return this._fitMode}set fitMode(t){this._fitMode=t}get hasSameParentForAllSelected(){return this._hasSameParentForAllSelected}set hasSameParentForAllSelected(t){this._hasSameParentForAllSelected=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){const n=this.templateMap[t];n&&Fi("Template replaced (duplicated)",t,e,n),this.templateMap[t]=e,delete this.templatePrefixes}removeTemplate(t,e){const n=this.templateMap[t];n!==e?Bi("Removing template failed (different)",t,e,n):delete this.templateMap[t],delete this.templatePrefixes}findTemplateFor(t){this.templatePrefixes||(this.templatePrefixes=Object.keys(this.templateMap).sort().reverse());const e=this.templatePrefixes.find(e=>t.startsWith(e));if(e)return this.templateMap[e]}addIndex(t,e){if(!t)return;const n="#"===t[0]?t.substring(1):t,i=this.indexMap.get(n);i?i.push(e):this.indexMap.set(n,[e])}removeIndex(t,e){if(!t)return;const n="#"===t[0]?t.substring(1):t,i=this.indexMap.get(n);if(!i)return;const r=i.indexOf(e);-1===r?Bi("Removing index failed (not found)",t,e):(i.splice(r,1),0===i.length&&this.indexMap.delete(n))}addRefidIndex(t,e){null==t&&(t=this.getNewRefid(),e.set("refid",t)),this._maxRefid=Math.max(t,this._maxRefid);const n=this.refidIndexMap.get(t);n&&Fi("Refid Index replaced (has not to be)",t,e,n),this.refidIndexMap.set(t,e)}removeRefidIndex(t,e){if(null==t)return;const n=this.refidIndexMap.get(t);n!==e?Fi("Refid Removing index failed (has not to be)",t,e,n):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){if(!t)return null;const e=this.indexMap.get("#"===t[0]?t.substring(1):t);return e?e[0]:null}findAllById(t){return t&&this.indexMap.get("#"===t[0]?t.substring(1):t)||el.EMPTY_ARRAY}findByRefid(t){return this.refidIndexMap.get(t)}findOrCreate(t){const e=this.findAllById(t);if(!e||0===e.length){if(this.app&&!this.app.isEditMode){const e=this.findTemplateFor(t);if(e){const n=Ic(Object.assign(Yn(e.hierarchy),{id:t,templatePrefix:""}),this.app);return this.model_layer.addComponent(n),[n]}}return[]}return e}resize(){this.components.forEach(t=>{t.resize&&t.resize()}),this.invalidate()}fit(t){const{width:e,height:n,fitMode:i}=this.model_layer.model,r=this.target_element,s=this.model_layer;if(this.fitMode=t||this.fitMode||i||"ratio",e&&n&&r&&r.clientWidth&&r.clientHeight){switch(this.fitMode){case"center":!function(t,e,n){const i=t.unitScale,{width:r,height:s}=e.model;e.set("scale",{x:i,y:i}),e.set("translate",{x:Math.max((n.clientWidth-r*i)/2,0),y:Math.max((n.clientHeight-s*i)/2,0)})}(this,s,r);break;case"both":!function(t,e,n){const{width:i,height:r}=e.model,s=n.clientWidth,o=n.clientHeight;e.set("scale",{x:s/i,y:o/r}),e.set("translate",{x:0,y:0})}(0,s,r);break;case"width":!function(t,e,n){const i=n.clientWidth/e.get("width");e.set("scale",{x:i,y:i}),e.set("translate",{x:0,y:0})}(0,s,r);break;case"height":!function(t,e,n){const i=n.clientHeight/e.get("height");e.set("scale",{x:i,y:i}),e.set("translate",{x:0,y:0})}(0,s,r);break;case"ratio":!function(t,e,n){const{width:i,height:r}=e.model,s=n.clientWidth,o=n.clientHeight,a=s/i,c=o/r,l=Math.min(a,c);e.set("scale",{x:l,y:l}),e.set("translate",{x:(s-i*l)/2,y:(o-r*l)/2})}(0,s,r);break;default:!function(t,e){const n=t.unitScale;e.set("scale",{x:n,y:n}),e.set("translate",{x:0,y:0})}(this,s)}this.resize()}}_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=>{Pc.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=new Map,this.refidIndexMap=new Map,this.templateMap={}}rebuildContentModel(t,e){let n,i;if(e?.preserveThreeD&&this.model_layer?.is3dMode){const t=this.model_layer._threeCapability;t&&(i=t.captureSessionState()),n=this.model_layer.detachThreeCapability()}this._disposeAllResources(),this.eventEngine=new dc(this);const r=this._app?.loadTracker;(t=t||{}).type="model-layer",t.dataLagMonitor&&this._app&&this._app.initLagTracker(t.dataLagMonitor),r?.setPhase("compile"),this.model_layer=Ic(t,this.app),this.addComponent(this.model_layer),this.model_layer.target=this.target_element,this.assist_layers=(this.model.layers||[]).map(t=>{const e=Ic(t,this.app);if(e)return this.addComponent(e),e.target=this.target_element,e;Fi("Layer compile failed",t)}).filter(Boolean),this.assist_handlers=(this.model.handlers||[]).map(t=>{const e={};return this.eventEngine.add(e,Pc.get(t)),e}),n&&(this.model_layer?.model?.threed?(this.model_layer.adoptThreeCapability(n),i&&n.restoreSessionState(i)):n.dispose()),r?.setPhase("assets"),this._ready=!0,this.traverse(t=>t.ready()),r?.checkComplete(),r?.startGlobalTimeout()}get root(){return this}get anchors(){return[]}get isReady(){return this._ready}get rootModel(){return this.model_layer}get threed(){return this.model_layer?.model?.threed||!1}set threed(t){this.model_layer&&this.model_layer.toggleThreeD(t)}get stuck(){return!0}get data(){const t={};for(const[e,n]of this.indexMap.entries())n.length>0&&(t[e]=n[0].data);return t}set data(t){for(const e in t){const n=this.findOrCreate(e);n&&0!==n.length&&n.forEach(n=>n.data=t[e])}}get dataByRefid(){const t={};for(const[e,n]of this.refidIndexMap.entries())t[e]=n.data;return t}set dataByRefid(t){for(const e in t){const n=this.findByRefid(Number(e));n&&(n.data=t[e])}}get values(){const t={};for(const[e,n]of this.indexMap.entries())n.length>0&&(t[e]=n[0].value);return t}set values(t){for(const e in t){const n=this.findOrCreate(e);n&&0!==n.length&&n.forEach(n=>n.value=t[e])}}get valuesByRefid(){const t={};for(const[e,n]of this.refidIndexMap.entries())t[e]=n.value;return t}set valuesByRefid(t){for(const e in t){const n=this.findByRefid(Number(e));n&&(n.value=t[e])}}get selected(){return(this._selected||[]).filter(t=>t.parent)}set selected(t){const e=this._selected;if(this._selected=t,!t||t.length<=1)this.hasSameParentForAllSelected=!0;else{const 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())}_areAliasesEqual(t,e){if(!Array.isArray(t)&&!Array.isArray(e))return!0;if(!Array.isArray(t)||!Array.isArray(e))return!1;if(t.length!==e.length)return!1;const n=[...t].sort(),i=[...e].sort();return n.every((t,e)=>t===i[e])}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=ti(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));const{id:e,alias:n,refid:i,tag:r,templatePrefix:s}=t.model;this.addRefidIndex(i,t),e&&this.addIndex(e,t),Array.isArray(n)&&n.forEach(e=>{e&&this.addIndex(e,t)}),r&&this.subscribe(r,t),s&&this.addTemplate(s,t);const o=ai({},t.eventMap,t.model.eventMap);this.eventEngine.add(t,o)}_removeTraverse(t){t.components&&t.components.forEach(t=>this._removeTraverse(t));const{id:e,alias:n,refid:i,tag:r,templatePrefix:s}=t.model;this.removeRefidIndex(i,t),e&&this.removeIndex(e,t),Array.isArray(n)&&n.forEach(e=>{e&&this.removeIndex(e,t)}),r&&this.unsubscribe(r,t),s&&this.removeTemplate(s,t),this.eventEngine.remove(t)}onadded(t,e){this._addTraverse(e),e._silentAdd||this.refreshMappings(),this.invalidate()}onremoved(t,e){this._removeTraverse(e),this.invalidate()}onchanged(t,e,n){e.templatePrefix&&this.removeTemplate(e.templatePrefix,n.origin),t.templatePrefix&&this.addTemplate(t.templatePrefix,n.origin),e.id&&this.removeIndex(e.id,n.origin),t.id&&this.addIndex(t.id,n.origin),Array.isArray(e.alias)&&e.alias.forEach(t=>{t&&this.removeIndex(t,n.origin)}),Array.isArray(t.alias)&&t.alias.forEach(t=>{t&&this.addIndex(t,n.origin)}),e.tag&&this.unsubscribe(e.tag,n.origin),t.tag&&this.subscribe(t.tag,n.origin),e.id==t.id&&e.class==t.class&&this._areAliasesEqual(e.alias,t.alias)||n.origin._silentAdd||this.refreshMappings()}}el.EMPTY_ARRAY=[],Va.memoize(el.prototype,"unitScale",!1);const nl=60;class il{constructor(){this._monitors=new Map,this._disposed=!1}configure(t){const e=Array.isArray(t)?t:[t];for(const t of e)this._monitors.set(t.tag,{config:{...t,warnThreshold:t.warnThreshold??5e3,criticalThreshold:t.criticalThreshold??15e3},fieldKeys:t.timestampField.split("."),samples:new Float64Array(nl),writeIdx:0,count:0,baseline:0,baselineSet:!1,baselineSum:0,baselineCount:0,lastLevel:"normal"})}isMonitored(t){return this._monitors.has(t)}recordIfMonitored(t,e){if(this._disposed)return;const n=this._monitors.get(t);if(!n||!e)return;const i=this._extractField(e,n.fieldKeys);if("number"!=typeof i||i<=0)return;const r=Date.now()-i;n.samples[n.writeIdx]=r,n.writeIdx=(n.writeIdx+1)%nl,n.count<nl&&n.count++,n.baselineSet||(n.baselineSum+=r,n.baselineCount++,n.baselineCount>=5&&(n.baseline=n.baselineSum/n.baselineCount,n.baselineSet=!0))}getStats(t){const e=this._monitors.get(t);if(!e)return null;const{count:n,baseline:i,baselineSet:r}=e;if(0===n)return{tag:t,currentDelta:0,baseline:0,drift:0,driftAvg:0,driftMax:0,trend:"stable",sampleCount:0,level:"normal"};const s=(e.writeIdx-1+nl)%nl,o=e.samples[s],a=r?o-i:0;let c=0,l=0;const h=this._getRecentDrifts(e);for(const t of h)c+=t,Math.abs(t)>Math.abs(l)&&(l=t);return{tag:t,currentDelta:o,baseline:i,drift:a,driftAvg:h.length>0?c/h.length:0,driftMax:l,trend:this._calcTrend(e),sampleCount:n,level:this._calcLevel(Math.abs(a),e.config)}}getAllStats(){const t=[];for(const e of this._monitors.keys()){const n=this.getStats(e);n&&t.push(n)}return t}evaluateAll(){if(!this._disposed)for(const[t,e]of this._monitors.entries()){const n=this.getStats(t);n&&(n.level!==e.lastLevel&&(e.lastLevel=n.level,this.onLevelChange?.(t,n.level,n)))}}dispose(){this._disposed=!0,this._monitors.clear(),this.onLevelChange=void 0}_extractField(t,e){let n=t;for(const t of e){if(null==n)return;n=n[t]}return n}_getRecentDrifts(t){if(!t.baselineSet||0===t.count)return[];const e=Math.min(t.count,10),n=[];for(let i=0;i<e;i++){const e=(t.writeIdx-1-i+nl)%nl;n.push(t.samples[e]-t.baseline)}return n.reverse()}_calcTrend(t){if(!t.baselineSet)return"stable";const e=this._getRecentDrifts(t),n=e.length;if(n<3)return"stable";let i=0,r=0,s=0,o=0;for(let t=0;t<n;t++)i+=t,r+=e[t],s+=t*e[t],o+=t*t;const a=(n*s-i*r)/(n*o-i*i),c=r/n,l=e.map(Math.abs),h=l.reduce((t,e)=>t+e,0)/n;if(h>0&&l[n-1]>3*h)return"spike";const d=Math.max(.1*Math.abs(c),50);return a>d?"increasing":a<-d?"decreasing":"stable"}_calcLevel(t,e){return t>=(e.criticalThreshold??15e3)?"critical":t>=(e.warnThreshold??5e3)?"warn":"normal"}}const rl=5e3;class sl{constructor(t){this._entries=new Map,this._phase="fetch",this._phaseHistory=[],this._disposed=!1,this.needsOverlay=!1,this._firstRenderDone=!1,this._options=t||{},this._startTime=performance.now(),this._promise=new Promise(t=>{this._promiseResolve=t}),this._phaseHistory.push({phase:"fetch",timestamp:this._startTime,elapsed:0}),this._slowTimerId=setTimeout(()=>{"complete"===this._phase||this._disposed||(this.needsOverlay=!0,this.onNeedsOverlay?.())},rl)}get phase(){return this._phase}get phaseHistory(){return this._phaseHistory}get progress(){const t=this._entries.size;if(0===t)return 1;let e=0;for(const t of this._entries.values())"pending"!==t.status&&e++;return e/t}get pending(){const t=[],e=performance.now();for(const n of this._entries.values())"pending"===n.status&&t.push(this._toPublicEntry(n,e));return t}get entries(){const t=performance.now(),e=[];for(const n of this._entries.values())e.push(this._toPublicEntry(n,t));return e}get stats(){let t=0,e=0,n=0,i=0,r=0;for(const s of this._entries.values())switch(s.status){case"loaded":t++;break;case"timeout":e++;break;case"error":n++;break;case"cancelled":i++;break;case"pending":r++}return{total:this._entries.size,loaded:t,timeout:e,error:n,cancelled:i,pending:r,elapsed:this._completedElapsed??performance.now()-this._startTime}}get promise(){return this._promise}markFirstRender(){this._firstRenderDone||this._disposed||(this._firstRenderDone=!0,this.setPhase("render"),this.checkComplete())}setPhase(t){if(this._disposed||this._phase===t||"complete"===this._phase)return;const e=performance.now(),n=this._phaseHistory[this._phaseHistory.length-1];n&&void 0===n.duration&&(n.duration=e-n.timestamp),this._phase=t,"complete"!==t?(this._phaseHistory.push({phase:t,timestamp:e,elapsed:e-this._startTime}),this.onPhase?.(t)):this.onPhase?.(t)}track(t,e,n,i){if(this._disposed)return;const r={id:t,type:e,url:n,startTime:performance.now(),status:"pending"};this._entries.set(t,r),this._options.assetTimeout&&this._options.assetTimeout>0&&(r.timerId=setTimeout(()=>{"pending"===r.status&&(r.status="timeout",r.endTime=performance.now(),r.timerId&&(r.timerId=void 0),this.onTimeout?.(this._toPublicEntry(r)),this._onEntryDone())},this._options.assetTimeout)),i.then(()=>{"pending"===r.status&&(r.status="loaded",r.endTime=performance.now(),this._clearEntryTimer(r),this._onEntryDone())},()=>{"pending"===r.status&&(r.status="error",r.endTime=performance.now(),this._clearEntryTimer(r),this._onEntryDone())})}checkComplete(){if(this._disposed||"complete"===this._phase)return;let t=!1;for(const e of this._entries.values())if("pending"===e.status){t=!0;break}!t&&this._firstRenderDone&&this._doComplete()}startGlobalTimeout(){if(this._disposed)return;const t=this._options.timeout;!t||t<=0||(this._globalTimerId=setTimeout(()=>{if("complete"===this._phase||this._disposed)return;const t=performance.now();for(const e of this._entries.values())"pending"===e.status&&(e.status="timeout",e.endTime=t,this._clearEntryTimer(e),this.onTimeout?.(this._toPublicEntry(e)));this._doComplete(!0)},t))}abort(){if(this._disposed)return;const t=performance.now();for(const e of this._entries.values())"pending"===e.status&&(e.status="cancelled",e.endTime=t,this._clearEntryTimer(e));this._doComplete(!0)}reset(){for(const t of this._entries.values())this._clearEntryTimer(t);this._globalTimerId&&(clearTimeout(this._globalTimerId),this._globalTimerId=void 0),this._slowTimerId&&(clearTimeout(this._slowTimerId),this._slowTimerId=void 0),this._entries.clear(),this._phase="fetch",this._startTime=performance.now(),this._phaseHistory=[{phase:"fetch",timestamp:this._startTime,elapsed:0}],this._completedElapsed=void 0,this._firstRenderDone=!1,this.needsOverlay=!1,this._disposed=!1,this._promise=new Promise(t=>{this._promiseResolve=t}),this._slowTimerId=setTimeout(()=>{"complete"===this._phase||this._disposed||(this.needsOverlay=!0,this.onNeedsOverlay?.())},rl)}dispose(){if(!this._disposed){this._disposed=!0;for(const t of this._entries.values())this._clearEntryTimer(t);this._globalTimerId&&(clearTimeout(this._globalTimerId),this._globalTimerId=void 0),this._slowTimerId&&(clearTimeout(this._slowTimerId),this._slowTimerId=void 0),this._promiseResolve(),this.onPhase=void 0,this.onProgress=void 0,this.onTimeout=void 0,this.onComplete=void 0,this.onNeedsOverlay=void 0}}_onEntryDone(){this._disposed||(this.onProgress?.(this.stats),this.checkComplete())}_doComplete(t=!1){"complete"!==this._phase&&(this._completedElapsed=performance.now()-this._startTime,this._completedElapsed>rl&&(this.needsOverlay=!0),this._globalTimerId&&(clearTimeout(this._globalTimerId),this._globalTimerId=void 0),this.setPhase("complete"),this.onComplete?.(this.stats),this._promiseResolve())}_clearEntryTimer(t){t.timerId&&(clearTimeout(t.timerId),t.timerId=void 0)}_toPublicEntry(t,e){const n=t.endTime?t.endTime-t.startTime:(e??performance.now())-t.startTime;return{id:t.id,type:t.type,url:t.url,startTime:t.startTime,status:t.status,elapsed:n}}}let ol=13.3;var al=function(t){return void 0!==t&&(ol=t),ol};const cl="$base_url";const ll=Math.PI/12;class hl{constructor(t,e){this._postprocessing=!0,this._loadTrackerOwned=!1,this._suppressAnimationsFlag=!1,this._suppressScopeCount=0,this._mode=t,this.screen=al(),this._baseUrl="undefined"!=typeof window?window.location.origin:null,this._refProvider=e,this.isEditMode&&(this._rotateStep=ll,this._rotateStepForced=!1)}initLoadTracker(t){return this._loadTracker=new sl(t),this._loadTrackerOwned=!0,this._loadTracker}get loadTracker(){return this._loadTracker}adoptLoadTracker(t){this._loadTracker=t,this._loadTrackerOwned=!1}initLagTracker(t){return this._lagTracker=new il,this._lagTracker.configure(t),this._lagTracker}get lagTracker(){return this._lagTracker}dispose(){this._loadTrackerOwned&&this._loadTracker?.dispose(),this._loadTracker=void 0,this._lagTracker?.dispose(),this._lagTracker=void 0,this._dataSubscriptionProvider?.dispose?.(),delete this._dataStorage}_calcScreen(){const t={width:screen.width,height:screen.height};this._PPI=function(t,e,n,i="d"){t<=0&&(t=1),e<=0&&(e=1);const r=("d"===i?Math.sqrt(t*t+e*e):"w"===i?t:e)/n;return r>0?Math.round(r):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 Mr}get PPI(){return this._PPI}get PPM(){return this._PPM}get mode(){return this._mode}set mode(t){const 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{let e;return e=t.includes(cl)?new URL(t.replace(cl,this.baseUrl??""),this.baseUrl??void 0):new URL(t,location.origin),e.href}catch(e){Bi(e,t)}}get rotateStep(){return this._rotateStep}set rotateStep(t){this._rotateStep=Number(t)||ll}get rotateStepForced(){return this._rotateStepForced}set rotateStepForced(t){this._rotateStepForced=!!t}get dataStorage(){return this._dataStorage}set dataStorage(t){this._dataStorage=t}get postprocessing(){return this._postprocessing}set postprocessing(t){this._postprocessing=t}get suppressAnimations(){return this._suppressAnimationsFlag||this._suppressScopeCount>0}set suppressAnimations(t){this._suppressAnimationsFlag=!!t}withSuppressedAnimations(t){let e;this._suppressScopeCount++;try{e=t()}catch(t){throw this._suppressScopeCount--,t}return e&&"function"==typeof e.then?e.finally(()=>{this._suppressScopeCount--}):(this._suppressScopeCount--,e)}beginSuppressAnimations(){this._suppressScopeCount++;let t=!1;return{end:()=>{t||(t=!0,this._suppressScopeCount--)}}}}ji(hl.prototype,ki.withEvent);class dl{constructor(t,e){!(t=Number(t))||t<=0?(Fi("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];Bi("Not forwardable.")}backward(){if(this.snapshot_taker&&this.snapshot_taker.take(),this.backwardable)return this.q[--this.pos];Bi("Not backwardable.")}get current(){if(-1!==this.pos)return this.q[this.pos];Bi("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}}const ul=ti(t=>{t.brake||t.take()},1e3,{leading:!0,trailing:!1});function pl(t){!t.brake&&t.dirty&&ul(t)}class fl{constructor(t,e){this._brake=!1,this.dirty=!1,this.brake=!1,this.dirty=!1,this.state_holder=t,this.timecapsule=e,this.timecapsule.snapshot_taker=this}dispose(){ul.cancel(),this.state_holder=null,this.timecapsule=null}touch(){this.dirty=!0,pl(this)}take(t=!1){(this.dirty||t)&&(this.timecapsule.snapshot(this.state_holder.state),this.dirty=!1)}get brake(){return this._brake}set brake(t){this._brake=!!t,pl(this)}}function gl(t,e){const n=e.model_layer.get("scale"),i=e.model_layer.get("translate"),r=e.model_layer.is3dMode;if(t){const s=JSON.parse(t);s.scale=n,s.translate=i,s.threed=r,e.rebuildContentModel(s,{preserveThreeD:!0})}}class ml{constructor(t){this.container=t,this.timecapsule=new dl(20);const e=this;this.snapshot_taker=new fl({get state(){const t=e.container.model_layer.hierarchy;return JSON.stringify(t,Xo)}},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&&(gl(this.timecapsule.backward(),this.container),this.trigger("undo",this.undoable(),this.redoable()))}redo(){this.timecapsule.forwardable&&(gl(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")}}ji(ml.prototype,ki.withEvent);const yl="left",bl="right",_l="center",vl="bottom",xl="middle",wl="z-front",Ml="z-back",Sl="z-middle",Al=[yl,bl,_l,"top",xl,vl,wl,Ml,Sl];function El(t){if(!this.hasSameParentForAllSelected||-1===Al.indexOf(t))return;const e=this.selected.filter(t=>!t.stuck);if(e.length<=1)return;const n=this.app.commander;Sc.around(n,function(){!function(t,e){const n=JSON.parse(JSON.stringify(e[0].bounds));let i=n.left+n.width,r=n.top+n.height;for(let t=0;t<e.length;t++){const s=e[t].bounds;n.left=s.left>n.left?n.left:s.left,n.top=s.top>n.top?n.top:s.top,i=s.left+s.width>i?s.left+s.width:i,r=s.top+s.height>r?s.top+s.height:r}switch(n.width=i-n.left,n.height=r-n.top,t){case yl:for(let t=0;t<e.length;t++){const i=e[t].bounds;e[t].bounds={left:n.left,top:i.top,width:i.width,height:i.height}}break;case _l:for(let t=0;t<e.length;t++){const i=e[t].bounds;e[t].bounds={left:n.left+n.width/2-i.width/2,top:i.top,width:i.width,height:i.height}}break;case bl:for(let t=0;t<e.length;t++){const n=e[t].bounds;e[t].bounds={left:i-n.width,top:n.top,width:n.width,height:n.height}}break;case"top":for(let t=0;t<e.length;t++){const i=e[t].bounds;e[t].bounds={left:i.left,top:n.top,width:i.width,height:i.height}}break;case xl:for(let t=0;t<e.length;t++){const i=e[t].bounds;e[t].bounds={left:i.left,top:n.top+n.height/2-i.height/2,width:i.width,height:i.height}}break;case vl:for(let t=0;t<e.length;t++){const n=e[t].bounds;e[t].bounds={left:n.left,top:r-n.height,width:n.width,height:n.height}}break;case wl:{let t=1/0;for(let n=0;n<e.length;n++){const i=e[n].state.zPos||0;i<t&&(t=i)}for(let n=0;n<e.length;n++)e[n].set({zPos:t});break}case Ml:{let t=-1/0;for(let n=0;n<e.length;n++){const i=(e[n].state.zPos||0)+(e[n].state.depth||0);i>t&&(t=i)}for(let n=0;n<e.length;n++){const i=e[n].state.depth||0;e[n].set({zPos:t-i})}break}case Sl:{let t=1/0,n=-1/0;for(let i=0;i<e.length;i++){const r=e[i].state.zPos||0,s=e[i].state.depth||0;r<t&&(t=r),r+s>n&&(n=r+s)}const i=(t+n)/2;for(let t=0;t<e.length;t++){const n=e[t].state.depth||0;e[t].set({zPos:i-n/2})}break}default:;}}(t,e)})}const kl="VERTICAL",Cl=[kl,"HORIZONTAL","Z"];function Tl(t){if(!this.hasSameParentForAllSelected||-1===Cl.indexOf(t))return;const e=this.selected;if(e.length<=1)return;const n=this.app.commander;Sc.around(n,function(){!function(t,e){if("Z"===t)return void function(t){const e=t.filter(t=>!t.stuck).slice(0);e.sort((t,e)=>(t.state.zPos||0)+(t.state.depth||0)/2-((e.state.zPos||0)+(e.state.depth||0)/2));const n=e.reduce((t,e)=>t+(e.state.depth||0),0),i=e[0].state.zPos||0,r=((e[e.length-1].state.zPos||0)+(e[e.length-1].state.depth||0)-i-n)/(e.length-1);let s=i+(e[0].state.depth||0);for(let t=1;t<e.length-1;t++){const n=e[t],i=n.state.depth||0;s+=r,n.set({zPos:s}),s+=i}}(e);const n=e.filter(t=>!t.stuck).slice(0);n.sort(function(e,n){const i=e.center,r=n.center;return t===kl?i.y-r.y:i.x-r.x});const i=n.reduce((e,n)=>e+(t===kl?n.bounds.height:n.bounds.width),0),r=n[0].bounds,s=n[n.length-1].bounds,o=((t===kl?s.top+s.height-r.top:s.left+s.width-r.left)-i)/(n.length-1);let a=t===kl?r.top+r.height:r.left+r.width;for(let e=1;e<n.length-1;e++){const i=n[e],r=i.bounds;a+=o,t===kl?(i.bounds={left:r.left,top:a,width:r.width,height:r.height},a+=r.height):(i.bounds={left:a,top:r.top,width:r.width,height:r.height},a+=r.width)}}(t,e)})}function Pl(t,e,n){this.app.commander.execute(new zc({changes:[{component:t,to_container:e,to_index:n}]}))}function Dl(t){const e=this.selected.filter(t=>!t.stuck);if(0===e.length||e[0].isRootModel())return;if(e.length>1&&("forward"===t||"backward"===t))return;const n=e[0].parent;let i;if("forward"===t){const t=n.indexOf(e[0]);i=[{component:e[0],from_container:n,to_container:n,from_index:t,to_index:t+1}]}else if("backward"===t){const t=n.indexOf(e[0]);i=[{component:e[0],from_container:n,to_container:n,from_index:t,to_index:t-1}]}else i=e.filter(t=>t.parent===n).sort((e,i)=>{const r=n.indexOf(e)<n.indexOf(i);return"front"===t?r:!r}).map((e,i)=>(n.indexOf(e),{component:e,to_container:n,to_index:"front"===t?n.components.length-i-1:i}));const r=new zc({changes:i});this.app.commander.execute(r)}function Ol(t,e,n){t instanceof Array||(t=[t]),n||(n=this.model_layer);const i=[],r=new Map;this.selected=t.map(t=>{try{return Ic(t,n.app,t=>{const e=this.getNewRefid();return void 0!==t&&r.set(t,e),e},t=>(this.indexMap[t]||[])[0])}catch(t){return Bi(t),!1}}).filter(Boolean).map(t=>{const{left:s,top:o,width:a,height:c,x:l,y:h,cx:d,cy:u}=e;return t.replaceRefids(r),isNaN(s)||isNaN(o)||isNaN(a)||isNaN(c)||(t.bounds={left:s,top:o,width:a,height:c}),isNaN(l)||isNaN(h)||t.move({x:l,y:h},!1),isNaN(d)||isNaN(u)||(t.center={x:d,y:u}),i.push({component:t,to_container:n}),t}),this.app.commander.execute(new zc({changes:i}))}function zl(){const t=[],e=new Map;if(this.selected=this.selected.filter(t=>!t.isRootModel()).map(n=>{const i=Rc(n,t=>{const n=this.getNewRefid();return void 0!==t&&e.set(t,n),n});return i.move({x:20,y:20},!1),t.push({component:i,to_container:n.parent}),i}).map(t=>(t.replaceRefids(e),t)),0===t.length)return;const n=new zc({changes:t});this.app.commander.execute(n)}function Ll(){const t=this.selected;this.selected=[];let e=null;const n=t.filter(t=>!t.isRootModel()&&(t.parent.focusible||t.parent.isGroup())).map(t=>(e||(e=t.parent),{component:t,to_container:null}));for(;e&&e.isGroup();){const t=[];if(e.components.filter(t=>!n.find(e=>e.component===t)).forEach(e=>t.push(e)),t.length>1)break;const i=e.parent;t.forEach(t=>n.push({component:t,to_container:i})),n.push({component:e,to_container:null}),e=i}n.length>0&&this.app.commander.execute(new zc({changes:n})),e&&e.calculateBounds&&e.calculateBounds()}const Il=new Set(["execute","redo","undo","command-reset"]);function Rl(t,e,n,i){const r=function(t,e){return Il.has(e)?t.app?.commander:"mode"===e?t.app:t}(this,e);r?.[t](e,n,i)}function jl(t,e,n){Rl.call(this,"on",t,e,n)}function Fl(t,e,n){Rl.call(this,"once",t,e,n)}function Bl(t,e,n){Rl.call(this,"off",t,e,n)}function Nl(t){const e=this.target_element,n=t||this.fitMode,i=this;function r(){i.fit(n),document.fullscreenElement||document.removeEventListener("fullscreenchange",r)}document.addEventListener("fullscreenchange",r),e.requestFullscreen().catch(()=>{document.removeEventListener("fullscreenchange",r)})}let Hl=0;function Yl(){const t=this.selected.filter(t=>!t.isRootModel()).map(t=>t.hierarchy);if(0!==t.length)return Hl=0,JSON.stringify(t,null,2)}function Gl(){Hl=0;const t=Yl.call(this);return Ll.call(this),t}function Vl(t){if(t)try{Hl++,Ol.call(this,JSON.parse(t),{x:15*Hl,y:15*Hl})}catch(e){Fi(e,t)}}const Ul=function(){return{escape:function(t){return t.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1")},parseExtension:t,mimeType:function(e){const n=t(e).toLowerCase();return function(){const t="application/font-woff",e="image/jpeg";return{woff:t,woff2:t,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:e,jpeg:e,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml"}}()[n]||""},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){const n=window.atob(t.toDataURL().split(",")[1]),i=n.length,r=new Uint8Array(i);for(let t=0;t<i;t++)r[t]=n.charCodeAt(t);e(new Blob([r],{type:"image/png"}))})}(t)},resolveUrl:function(t,e){const n=document.implementation.createHTMLDocument(),i=n.createElement("base");n.head.appendChild(i);const r=n.createElement("a");return n.body.appendChild(r),i.href=e,r.href=t,r.href},getAndEncode:function(t){const e=3e4;Jl.impl.options.cacheBust&&(t+=(/\?/.test(t)?"&":"?")+(new Date).getTime());return new Promise(function(n){const i=new XMLHttpRequest;let r;if(i.onreadystatechange=s,i.ontimeout=o,i.responseType="blob",i.timeout=e,i.open("GET",t,!0),i.send(),Jl.impl.options.imagePlaceholder){const t=Jl.impl.options.imagePlaceholder.split(/,/);t&&t[1]&&(r=t[1])}function s(){if(4!==i.readyState)return;if(200!==i.status)return void(r?n(r):a("cannot fetch resource: "+t+", status: "+i.status));const e=new FileReader;e.onloadend=function(){const t=e.result.split(/,/)[1];n(t)},e.readAsDataURL(i.response)}function o(){r?n(r):a("timeout of "+e+"ms occured while fetching resource: "+t)}function a(t){Fi(t),n("")}})},uid:function(){let 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(n){setTimeout(function(){n(e)},t)})}},asArray:function(t){const e=[],n=t.length;for(let i=0;i<n;i++)e.push(t[i]);return e},escapeXhtml:function(t){return t.replace(/#/g,"%23").replace(/\n/g,"%0A")},makeImage:function(t){return new Promise(function(e,n){const i=new Image;i.onload=function(){e(i)},i.onerror=n,i.src=t})},width:function(t){const n=e(t,"border-left-width"),i=e(t,"border-right-width");return t.scrollWidth+n+i},height:function(t){const n=e(t,"border-top-width"),i=e(t,"border-bottom-width");return t.scrollHeight+n+i}};function t(t){const e=/\.([^\.\/]*?)$/g.exec(t);return e?e[1]:""}function e(t,e){const n=window.getComputedStyle(t).getPropertyValue(e);return parseFloat(n.replace("px",""))}}(),$l=function(){const t=/url\(['"]?([^'"]+?)['"]?\)/g;return{inlineAll:function(t,r,s){return o()?Promise.resolve(t):Promise.resolve(t).then(n).then(function(e){let n=Promise.resolve(t);return e.forEach(function(t){n=n.then(function(e){return i(e,t,r,s)})}),n});function o(){return!e(t)}},shouldProcess:e,impl:{readUrls:n,inline:i}};function e(e){return-1!==e.search(t)}function n(e){const n=[];let i;for(;null!==(i=t.exec(e));)n.push(i[1]);return n.filter(function(t){return!Ul.isDataUrl(t)})}function i(t,e,n,i){return Promise.resolve(e).then(function(t){return n?Ul.resolveUrl(t,n):t}).then(i||Ul.getAndEncode).then(function(t){return Ul.dataAsUrl(t,Ul.mimeType(e))}).then(function(n){return t.replace(function(t){return new RegExp("(url\\(['\"]?)("+Ul.escape(t)+")(['\"]?\\))","g")}(e),"$1"+n+"$3")})}}(),Wl=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(Ul.asArray(document.styleSheets)).then(function(t){const e=[];return t.forEach(function(t){try{Ul.asArray(t.cssRules||[]).forEach(t=>e.push(t))}catch(e){Bi("Error while reading CSS rules from "+t.href,e instanceof Error?e.message:String(e))}}),e}).then(function(t){return t.filter(function(t){return t.type===CSSRule.FONT_FACE_RULE}).filter(function(t){return $l.shouldProcess(t.style.getPropertyValue("src"))})}).then(function(e){return e.map(t)});function t(t){return{resolve:function(){const e=(t.parentStyleSheet||{}).href;return $l.inlineAll(t.cssText,e)},src:function(){return t.style.getPropertyValue("src")}}}}}(),Xl=function(){return{inlineAll:function e(n){return n instanceof Element?i(n).then(function(){return n instanceof HTMLImageElement?t(n).inline().then(()=>n):Promise.all(Ul.asArray(n.childNodes).map(function(t){return e(t)})).then(()=>n)}):Promise.resolve(n);function i(t){const e=t.style.getPropertyValue("background");return e?$l.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 Ul.isDataUrl(t.src)?Promise.resolve():Promise.resolve(t.src).then(e||Ul.getAndEncode).then(function(e){return Ul.dataAsUrl(e,Ul.mimeType(t.src))}).then(function(e){return new Promise(function(n,i){t.onload=n,t.onerror=i,t.src=e})})}}}}(),ql={imagePlaceholder:void 0,cacheBust:!1};function Kl(t,e){return function(t){void 0===t.imagePlaceholder?Jl.impl.options.imagePlaceholder=ql.imagePlaceholder:Jl.impl.options.imagePlaceholder=t.imagePlaceholder;void 0===t.cacheBust?Jl.impl.options.cacheBust=ql.cacheBust:Jl.impl.options.cacheBust=t.cacheBust}(e=e||{}),Promise.resolve(t).then(function(t){return Zl(t,e.filter,!0)}).then(function(t){return function(t){return Xl.inlineAll(t).then(function(){return t})}(t)}).then(function(t){const{bgcolor:n,width:i,height:r,style:s,sx:o=1,sy:a=1}=e||{},c=t.style;n&&(c.backgroundColor=n);i&&(c.width=i+"px");r&&(c.height=r+"px");c["margin-left"]="0px",c["margin-top"]="0px",c.transform=`rotate(0rad) translate(0px, 0px) scale(${o}, ${a}) perspective(1px)`,s&&Object.keys(s).forEach(function(t){c[t]=s[t]});return t}).then(function(n){return function(t,e,n){return Promise.resolve(t).then(function(t){return t.setAttribute("xmlns","http://www.w3.org/1999/xhtml"),(new XMLSerializer).serializeToString(t)}).then(Ul.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="'+n+'">'+t+"</svg>"}).then(function(t){return"data:image/svg+xml;charset=utf-8,"+t})}(n,e.width||Ul.width(t),e.height||Ul.height(t))})}function Ql(t,e){return Kl(t,e).then(Ul.makeImage).then(Ul.delay(100)).then(function(n){const i=function(t){const n=document.createElement("canvas");if(n.width=e.width||Ul.width(t),n.height=e.height||Ul.height(t),e.bgcolor){const t=n.getContext("2d");t.fillStyle=e.bgcolor,t.fillRect(0,0,n.width,n.height)}return n}(t);return i.getContext("2d").drawImage(n,0,0),i})}function Zl(t,e,n){return n||!e||e(t)?Promise.resolve(t).then(function(t){if(t instanceof HTMLCanvasElement)try{return Ul.makeImage(t.toDataURL()).then(t=>t)}catch(t){Bi(t)}return t.cloneNode(!1)}).then(function(n){return function(t,e,n){const i=t.childNodes;return 0===i.length?Promise.resolve(e):r(e,Ul.asArray(i),n).then(function(){return e});function r(t,e,n){let i=Promise.resolve();return e.forEach(function(e){i=i.then(function(){return Zl(e,n,!1)}).then(function(e){e&&t.appendChild(e)})}),i}}(t,n,e)}).then(function(e){return function(t,e){return e instanceof Element?Promise.resolve().then(n).then(i).then(r).then(s).then(function(){return e}):e;function n(){function n(t,e){function n(t,e){Ul.asArray(t).forEach(function(n){e.setProperty(n,t.getPropertyValue(n),t.getPropertyPriority(n))})}t.cssText?e.cssText=t.cssText:n(t,e)}n(window.getComputedStyle(t),e.style)}function i(){function n(n){const i=window.getComputedStyle(t,n),r=i.getPropertyValue("content");if(""===r||"none"===r)return;const s=Ul.uid(),o=e;o.className=o.className+" "+s;const a=document.createElement("style");function c(t,e,n){const i="."+t+":"+e,r=n.cssText?s(n):o(n);return document.createTextNode(i+"{"+r+"}");function s(t){const e=t.getPropertyValue("content");return t.cssText+" content: "+e+";"}function o(t){return Ul.asArray(t).map(e).join("; ")+";";function e(e){return e+": "+t.getPropertyValue(e)+(t.getPropertyPriority(e)?" !important":"")}}}a.appendChild(c(s,n,i)),e.appendChild(a)}[":before",":after"].forEach(function(t){n(t)})}function r(){t instanceof HTMLTextAreaElement&&e instanceof HTMLTextAreaElement&&(e.textContent=t.value),t instanceof HTMLInputElement&&e instanceof HTMLInputElement&&e.setAttribute("value",t.value)}function s(){e instanceof SVGElement&&(e.setAttribute("xmlns","http://www.w3.org/2000/svg"),e instanceof SVGRectElement&&["width","height"].forEach(function(t){const n=e.getAttribute(t);n&&e.style.setProperty(t,n)}))}}(t,e)}):Promise.resolve(void 0)}const Jl={toSvg:Kl,toPng:function(t,e){return Ql(t,e||{}).then(function(t){return t.toDataURL()})},toJpeg:function(t,e){return Ql(t,e=e||{}).then(function(t){return t.toDataURL("image/jpeg",e.quality||1)})},toBlob:function(t,e){return Ql(t,e||{}).then(t=>Ul.canvasToBlob(t))},toPixelData:function(t,e){return Ql(t,e||{}).then(function(e){return e.getContext("2d").getImageData(0,0,Ul.width(t),Ul.height(t)).data})},impl:{fontFaces:Wl,images:Xl,util:Ul,inliner:$l,options:{}}};function th(t,e,n,i){const r=this.model_layer,s=r._overlay;return new Promise(function(o,a){if(r){const a=r.get("width"),c=r.get("height");n=n||a,i=i||c;const l=r.get("translate"),h=r.get("scale"),d=Math.min(n/a,i/c);n=a*d,i=c*d,r.set("translate",{x:0,y:0}),r.set("scale",{x:d/Mr,y:d/Mr});let u=Va.createCanvas(n,i);const p=u.getContext("2d");if(r.draw(p),r.set("translate",l),r.set("scale",h),!s)return o(u.toDataURL(t,e)),void(u=null);Jl.toPng(s,{sx:d,sy:d,width:n,height:i}).then(function(r){const s=new Image;s.onload=function(){p.drawImage(s,0,0,n,i),o(u.toDataURL(t,e)),u=null},s.src=r},function(n){Fi(n),o(u.toDataURL(t,e)),u=null})}else a("No target model")})}function eh(){if(!this.hasSameParentForAllSelected)return;const t=this.selected.filter(t=>!!t.parent&&!t.stuck);if(t.length<2)return;const e=t[0].parent,n=[],i=t.sort((t,n)=>e.components.indexOf(t)-e.components.indexOf(n));i.forEach(t=>{n.push(t.bounds)});const r=Va.union(n);let s=t[0].fromParent(r.left,r.top);s=t[0].toScene(s.x,s.y);const o=new Map,a=Ic({type:"group",left:s.x,top:s.y,width:r.width,height:r.height},e.app,t=>{const e=this.getNewRefid();return void 0!==t&&o.set(t,e),e});a.replaceRefids(o);const c=[{component:a,to_container:e}];i.forEach(t=>{c.push({component:t,to_container:a})}),this.app.commander.execute(new zc({changes:c})),this.selected=[a]}function nh(){if(0===this.selected.length)return;const t=[],e=[];this.selected.forEach(n=>{if(!n.isGroup())return;const i=n.parent;n.components.forEach(n=>{t.push(n),e.push({component:n,to_container:i})}),e.push({component:n,to_container:null})}),this.app.commander.execute(new zc({changes:e})),this.selected=t}function ih(){const t=this.selected;if(0===t.length)return;const e=t.map(t=>t.bounds),n=Va.union(e),i=n.left+n.width/2;t.map(t=>{t.symmetryX(i)})}function rh(){const t=this.selected;if(0===t.length)return;const e=t.map(t=>t.bounds),n=Va.union(e),i=n.top+n.height/2;t.map(t=>{t.symmetryY(i)})}function sh(){Sc.around(this.app.commander,ih,this)}function oh(){Sc.around(this.app.commander,rh,this)}function ah(t,e,n){const i=this.findAll(t,n);return i.forEach(t=>{t.set(e)}),i}function ch(t){Sc.around(this.app.commander,t)}function lh(){return Object.values(this.indexMap).map(t=>t.map(t=>{const{id:e,data:n}=t.model;return{key:e,value:n}})).flat().sort((t,e)=>t.key>e.key?1:-1)}const hh="left",dh="right",uh="center",ph="bottom",fh="middle",gh=[hh,dh,uh,"top",fh,ph];function mh(t){if(!this.hasSameParentForAllSelected||-1===gh.indexOf(t))return;const e=this.selected.filter(t=>!t.stuck);if(0===e.length)return;const n=this.app.commander;Sc.around(n,function(){!function(t,e){const n=e[0].parent,{width:i,height:r}=n.bounds;switch(t){case hh:for(let t=0;t<e.length;t++){const n=e[t].bounds;e[t].bounds={...n,left:0}}break;case uh:for(let t=0;t<e.length;t++){const n=e[t].bounds;e[t].bounds={...n,left:i/2-n.width/2}}break;case dh:for(let t=0;t<e.length;t++){const n=e[t].bounds;e[t].bounds={...n,left:i-n.width}}break;case"top":for(let t=0;t<e.length;t++){const n=e[t].bounds;e[t].bounds={...n,top:0}}break;case fh:for(let t=0;t<e.length;t++){const n=e[t].bounds;e[t].bounds={...n,top:r/2-n.height/2}}break;case ph:for(let t=0;t<e.length;t++){const n=e[t].bounds;e[t].bounds={...n,top:r-n.height}}break;default:;}}(t,e)})}function yh(t){t instanceof Array||(t=[t]),this.trigger("addstart",t)}function bh(){this.trigger("stylepastestart")}function _h(){this.trigger("stylepastestop")}function vh(){this.trigger("databindpastestart")}function xh(){this.trigger("databindpastestop")}const wh={default:{metalness:0,roughness:.4},metal:{metalness:1,roughness:.3,envMapIntensity:1},glass:{metalness:0,roughness:.1,opacity:.3,envMapIntensity:1.5},plastic:{metalness:0,roughness:.4},wood:{metalness:0,roughness:.8,envMapIntensity:.3},ceramic:{metalness:.1,roughness:.2,envMapIntensity:.3},rubber:{metalness:0,roughness:.9,envMapIntensity:.3}};function Mh(t){if(!t)return{metalness:0,roughness:.4,emissive:"#000000",emissiveIntensity:0,opacity:1,envMapIntensity:.5,side:"double",castShadow:!0,receiveShadow:!1};const e=wh[t.preset??"default"]??wh.default;return{metalness:t.metalness??e.metalness,roughness:t.roughness??e.roughness,emissive:t.emissive??"#000000",emissiveIntensity:t.emissiveIntensity??0,opacity:t.opacity??e.opacity??1,envMapIntensity:t.envMapIntensity??e.envMapIntensity??.5,side:t.side??"double",castShadow:t.castShadow??!0,receiveShadow:t.receiveShadow??!1}}const Sh={double:w.DoubleSide,front:w.FrontSide,back:w.BackSide};function Ah(t){return Sh[t]??w.DoubleSide}function Eh(t,e){t.metalness=e.metalness,t.roughness=e.roughness,t.emissive.set(e.emissive),t.emissiveIntensity=e.emissiveIntensity,t.opacity=e.opacity,t.transparent=e.opacity<1,t.envMapIntensity=e.envMapIntensity,t.side=Ah(e.side)}const kh=new class{constructor(){this._scenes=[],this.onSceneChange=null,this._watchedComponent=null,this._watchedHandler=null,this.onWatchedComponentChange=null}setWatchedComponent(t,e=0){if(this._clearWatched(),null==t)return!0;const n=this._getScene(e);if(!n)return!1;const i=n.rootContainer;if(!i)return!1;const r="root"===t||"__root__"===t?i.model_layer:this._findComponent(i,t);if(!r||"function"!=typeof r.on)return!1;const s=(e,n)=>{this.onWatchedComponentChange?.(t,e,n)};return r.on("change",s),this._watchedComponent=r,this._watchedHandler=s,!0}_clearWatched(){this._watchedComponent&&this._watchedHandler&&"function"==typeof this._watchedComponent.off&&this._watchedComponent.off("change",this._watchedHandler),this._watchedComponent=null,this._watchedHandler=null}register(t){this._cleanup(),this._scenes.push(new WeakRef(t)),this.onSceneChange?.(this._scenes.length)}unregister(t){this._clearWatched(),this._scenes=this._scenes.filter(e=>{const n=e.deref();return n&&n!==t}),this.onSceneChange?.(this._scenes.length)}getScenes(){return this._cleanup(),this._scenes.map((t,e)=>{const n=t.deref();if(!n)return null;const i=n.root,r=i?.model||{};return{index:e,model:{width:r.width||0,height:r.height||0,type:r.type||"unknown"}}}).filter(Boolean)}getComponentTree(t=0){const e=this._getScene(t);if(!e)return[];const n=e.rootContainer;if(!n)return[];const i=n.model_layer;return i?this._childrenOf(i):[]}getChildTree(t,e=0){const n=this._getScene(e);if(!n)return[];const i=n.rootContainer;if(!i)return[];let r;return r="root"===t||"__root__"===t?i.model_layer:this._findComponent(i,t),r?this._childrenOf(r):[]}getComponentInfo(t,e=0){const n=this._getScene(e);if(!n)return null;const i=n.rootContainer;if(!i)return null;let r;if(r="root"===t||"__root__"===t?i.model_layer:this._findComponent(i,t),!r)return null;const s=this._safeBounds(r),o={model:this._safeClone(r.model),state:this._safeClone(r.state),nature:r.nature||{},data:this._safeValue(r.data),value:this._safeValue(r.value),bounds:s,type:r.model?.type||"unknown",isContainer:!!r.isContainer?.(),hidden:!!r.model?.hidden};return"model-layer"===r.model?.type&&(o.is3dMode=!!r.model?.threed),o}selectComponent(t,e=0){const n=this._getScene(e);if(!n)return!1;const i=n.rootContainer;if(!i)return!1;if(!t||"root"===t||"__root__"===t)return i.selected=[],!0;const r=this._findComponent(i,t);return!!r&&(i.selected=[r],!0)}setComponentProperty(t,e,n,i=0){const r=this._getScene(i);if(!r)return!1;const s=r.rootContainer;if(!s)return!1;let o;if(o="root"===t||"__root__"===t?s.model_layer:this._findComponent(s,t),!o)return!1;try{return o.set(e,n),!0}catch{return!1}}setCameraView(t,e=0){const n=this._getScene(e);if(!n)return!1;const i=n.rootContainer;if(!i)return!1;const r=i.model_layer;if(!r||!r._threeCapability)return!1;try{return r._threeCapability.setCameraView(t),!0}catch{return!1}}getCameraState(t=0){const e=this._getScene(t);if(!e)return null;const n=e.rootContainer;if(!n)return null;const i=n.model_layer;if(!i||!i._threeCapability)return null;try{return i._threeCapability.getCameraState()}catch{return null}}toggleHidden(t,e=0){const n=this._getScene(e);if(!n)return!1;const i=n.rootContainer;if(!i)return!1;const r=this._findComponent(i,t);if(!r)return!1;try{return r.set("hidden",!r.model?.hidden),!r.model?.hidden}catch{return!1}}evaluateData(t,e=0){const n=this._getScene(e);if(!n)return;const i=n.rootContainer;if(!i)return;const r="root"===t||"__root__"===t?i.model_layer:this._findComponent(i,t);return r?this._safeValue(r.data):void 0}evaluateValue(t,e=0){const n=this._getScene(e);if(!n)return;const i=n.rootContainer;if(!i)return;const r="root"===t||"__root__"===t?i.model_layer:this._findComponent(i,t);return r?this._safeValue(r.value):void 0}searchComponents(t,e=0){const n=this._getScene(e);if(!n)return[];const i=n.rootContainer;if(!i)return[];const r=i.model_layer;if(!r)return[];const s=[],o=t.toLowerCase();return this._traverseComponent(r,t=>{const e=t.state||t.model||{};[e.type||"",e.name||"",e.id||"",e.tag||"",e.class||"",String(e.refid||"")].join(" ").toLowerCase().includes(o)&&s.push(this._toTreeNode(t))}),s}getComponentPath(t,e=0){const n=this._getScene(e);if(!n)return[];const i=n.rootContainer;if(!i)return[];const r=i.model_layer;if(!r)return[];const s=[];return this._findPath(r,t,s)?s:[]}getThreedInfo(t,e=0){const n=this._getScene(e);if(!n)return null;const i=n.rootContainer;if(!i)return null;let r;if(r="root"===t||"__root__"===t?i.model_layer:this._findComponent(i,t),!r)return null;const s=r.model||{},o=s.type||"unknown",a=s.material3d,c={is3dish:"function"==typeof r.is3dish&&r.is3dish(),type:o};if(a&&(c.material3d=this._safeClone(a)),c.resolved=Mh(a),"gltf-object"===o)try{c.nodeNames=r.nodeNames??[],c.animationNames=r.animationNames??[],c.nodes=this._safeClone(r.nodes),c.animations=this._safeClone(r.animations),c.fillStyleTargets=r.fillStyleTargets}catch{}return c}_getScene(t){this._cleanup();const e=this._scenes[t];return e?.deref()??null}_cleanup(){this._scenes=this._scenes.filter(t=>void 0!==t.deref())}_findComponent(t,e){const n=Number(e);if(!isNaN(n)){const e=t.findByRefid(n);if(e)return e}const i=t.findById(e);return i||null}_childrenOf(t){const e=t.components;return e?e.map(t=>this._toTreeNode(t)):[]}_toTreeNode(t){const e=t.components,n=!!e&&e.length>0,i=t.state||t.model||{};return{id:String(i.refid??i.id??""),type:i.type||"unknown",model_id:i.id,hasChildren:n,childCount:n?e.length:0,refid:i.refid,tag:i.tag,name:i.name,hidden:!!i.hidden,clazz:i.class}}_componentId(t){const e=t.state||t.model||{};return String(e.refid??e.id??"")}_findPath(t,e,n){const i=this._componentId(t);if(i===e)return!0;const r=t.components;if(!r)return!1;for(const s of r)if(this._findPath(s,e,n))return n.unshift("model-layer"===t.model?.type?"__root__":i),!0;return!1}_traverseComponent(t,e){e(t);const n=t.components;if(n)for(const t of n)this._traverseComponent(t,e)}_safeBounds(t){try{const e=t.bounds;return e?{left:e.left??0,top:e.top??0,width:e.width??0,height:e.height??0}:null}catch{return null}}_safeClone(t){if(!t||"object"!=typeof t)return t??{};try{return JSON.parse(JSON.stringify(t))}catch{const e={};for(const n of Object.keys(t))try{const i=t[n];if("function"==typeof i)continue;e[n]="object"==typeof i?String(i):i}catch{e[n]="[error]"}return e}}_safeValue(t){if(null==t)return t;try{return JSON.parse(JSON.stringify(t))}catch{return String(t)}}},Ch={fetch:"Fetching model...",parse:"Parsing model...",init:"Initializing...",compile:"Building components...",assets:"Loading assets...",data:"Waiting for data...",render:"Rendering..."},Th={stable:"─",increasing:"▲",decreasing:"▼",spike:"⚡"},Ph={normal:"rgba(100,200,100,0.9)",warn:"rgba(255,180,50,0.9)",critical:"rgba(255,80,80,0.9)"};class Dh{constructor(){this._visible=!1,this._manualOpen=!1,this._phaseRenderedCount=0}attach(t,e,n){this._targetElement=t,this._tracker=e,this._lagTracker=n,this._phaseRenderedCount=0,this._visible=!1,this._phaseListEl&&(this._phaseListEl.innerHTML=""),this._pendingListEl&&(this._pendingListEl.innerHTML=""),e&&(e.needsOverlay&&this._show(),e.onNeedsOverlay=()=>{this._visible||this._manualOpen||this._show()},e.onComplete=()=>{this._visible&&(this._update(),this._manualOpen||setTimeout(()=>{this._manualOpen||this._hide()},5e3))})}toggle(){this._visible?(this._hide(),this._manualOpen=!1):(this._manualOpen=!0,this._show())}show(){this._manualOpen=!0,this._show()}hide(){this._manualOpen=!1,this._hide()}destroy(){this._hide(),this._container?.parentElement&&this._container.parentElement.removeChild(this._container),this._container=void 0,this._targetElement=void 0,this._tracker=void 0,this._lagTracker=void 0,this._phaseListEl=void 0}get isVisible(){return this._visible}get isAttached(){return!!this._targetElement}_show(){this._targetElement&&(this._container||this._buildDOM(),this._container&&!this._container.parentElement&&this._targetElement.appendChild(this._container),this._container.style.display="flex",this._visible=!0,this._update(),this._updateTimer||(this._updateTimer=setInterval(()=>this._update(),500)),"complete"!==this._tracker?.phase||this._manualOpen||setTimeout(()=>{this._manualOpen||this._hide()},5e3))}_hide(){this._container&&(this._container.style.display="none"),this._visible=!1,this._updateTimer&&(clearInterval(this._updateTimer),this._updateTimer=void 0)}_update(){if(!this._visible||!this._tracker)return;const t=this._tracker,e=t.stats,n=t.phase,i="complete"===n;this._headerEl&&(this._headerEl.textContent=i?`Scene Monitor — ${(e.elapsed/1e3).toFixed(1)}s`:`Scene Monitor — ${Ch[n]||n}`),this._updateProgress(t,i),this._updatePhaseList(t),this._updateAssetList(t,e,i),this._updateLagDisplay(),this._elapsedEl&&(this._elapsedEl.textContent=`${(e.elapsed/1e3).toFixed(1)}s`)}_updateProgress(t,e){if(!this._progressFillEl&&!this._progressTextEl)return;const n=t.phaseHistory,i=n.length,r=n.filter(t=>void 0!==t.duration).length,s=i>0?Math.round(r/i*100):e?100:0;this._progressFillEl&&(this._progressFillEl.style.width=s+"%"),this._progressTextEl&&(this._progressTextEl.textContent=`${r} / ${i}`)}_updatePhaseList(t){if(!this._phaseListEl)return;const e=t.phaseHistory;for(let t=this._phaseRenderedCount;t<e.length;t++){const n=e[t];if("complete"===n.phase)continue;const i=150*(t-this._phaseRenderedCount),r=document.createElement("div");r.dataset.phase=n.phase,r.style.cssText="display:flex;gap:8px;align-items:center;padding:1px 0;font-size:11px;opacity:0;transition:opacity 0.3s ease",r.innerHTML='<span data-field="icon" style="flex-shrink:0"></span><span data-field="label" style="flex:1"></span><span data-field="time" style="width:60px;text-align:right"></span>',this._phaseListEl.appendChild(r),setTimeout(()=>{r.style.opacity="1"},i+16)}this._phaseRenderedCount=e.length;const n=performance.now();for(const t of Array.from(this._phaseListEl.querySelectorAll("[data-phase]"))){const i=t,r=e.find(t=>t.phase===i.dataset.phase);if(!r)continue;const s=Ch[r.phase]||r.phase,o=i.querySelector('[data-field="icon"]'),a=i.querySelector('[data-field="label"]'),c=i.querySelector('[data-field="time"]');void 0===r.duration?(o.textContent="⏳",o.style.color="rgba(255,200,50,0.8)",a.textContent=s,a.style.color="rgba(255,255,255,0.9)",c.textContent=`${((n-r.timestamp)/1e3).toFixed(1)}s`,c.style.color="rgba(255,200,50,0.8)"):(o.textContent="✓",o.style.color="rgba(100,200,100,0.8)",a.textContent=s,a.style.color="rgba(255,255,255,0.5)",c.textContent=`${(r.duration/1e3).toFixed(1)}s`,c.style.color="rgba(255,255,255,0.4)")}}_updateAssetList(t,e,n){if(this._pendingListEl)if(n&&"complete"!==this._pendingListEl.dataset.mode)this._pendingListEl.innerHTML="",this._pendingListEl.dataset.mode="complete",this._renderHistorySummary(e);else if(!n){this._pendingListEl.dataset.mode="pending";const e=t.pending.sort((t,e)=>e.elapsed-t.elapsed),n=e.slice(0,5);for(let t=0;t<n.length;t++)t<this._pendingListEl.children.length?this._updatePendingRow(this._pendingListEl.children[t],n[t]):this._pendingListEl.appendChild(this._createPendingRow(n[t]));const i=n.length+(e.length>5?1:0);for(;this._pendingListEl.children.length>i;)this._pendingListEl.lastChild?.remove();if(e.length>5){const t=this._pendingListEl.lastElementChild;if(t?.dataset?.more)t.textContent=`... ${e.length-5} more`;else{const t=document.createElement("div");t.dataset.more="1",t.style.cssText="color:rgba(255,255,255,0.4);font-size:11px;padding:2px 0",t.textContent=`... ${e.length-5} more`,this._pendingListEl.appendChild(t)}}}}_updateLagDisplay(){if(!this._lagSectionEl||!this._lagTracker)return;this._lagTracker.evaluateAll();const t=this._lagTracker.getAllStats();0!==t.length&&(this._lagSectionEl.dataset.built?this._updateLagSection(t):(this._lagSectionEl.innerHTML="",this._renderLagSection(t),this._lagSectionEl.dataset.built="1"))}_renderHistorySummary(t){if(!this._pendingListEl)return;const e=document.createElement("div");e.style.cssText="color:rgba(255,255,255,0.7);padding:2px 0;font-size:12px",e.textContent=`Total: ${t.total} assets | Loaded: ${t.loaded} | Timeout: ${t.timeout} | Error: ${t.error}`,this._pendingListEl.appendChild(e);const n=this._tracker.entries.filter(t=>"pending"!==t.status).sort((t,e)=>e.elapsed-t.elapsed).slice(0,5);for(const t of n){const e=document.createElement("div");e.style.cssText="display:flex;gap:8px;align-items:center;padding:1px 0;font-size:11px";const n="loaded"===t.status?"✓":"timeout"===t.status?"⚠":"✗",i="loaded"===t.status?"rgba(100,200,100,0.8)":"timeout"===t.status?"rgba(255,180,50,0.8)":"rgba(255,80,80,0.8)";e.innerHTML=`<span style="color:${i}">${n}</span><span style="color:rgba(74,158,255,0.8);width:50px">${t.type}</span><span style="color:rgba(255,255,255,0.6);flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap">${this._shortUrl(t.url)}</span><span style="color:rgba(255,255,255,0.5);width:50px;text-align:right">${(t.elapsed/1e3).toFixed(1)}s</span>`,this._pendingListEl.appendChild(e)}}_renderLagSection(t){if(!this._lagSectionEl)return;const e=document.createElement("div");e.style.cssText="color:rgba(255,255,255,0.5);font-size:11px;padding:4px 0 2px;border-top:1px solid rgba(255,255,255,0.08);margin-top:4px",e.textContent="Data Lag",this._lagSectionEl.appendChild(e);for(const e of t){const t=document.createElement("div");t.dataset.tag=e.tag,t.style.cssText="display:flex;gap:8px;align-items:center;padding:1px 0;font-size:11px";const n=Ph[e.level],i=Th[e.trend];t.innerHTML=`<span style="color:rgba(255,255,255,0.7);flex:1">${e.tag}</span><span data-field="drift" style="color:rgba(255,255,255,0.6)">drift: ${e.drift>=0?"+":""}${(e.drift/1e3).toFixed(1)}s</span><span style="color:rgba(255,255,255,0.4)">base: ${(e.baseline/1e3).toFixed(1)}s</span><span data-field="trend" style="color:${n}">${i}</span>`,this._lagSectionEl.appendChild(t)}}_createPendingRow(t){const e=document.createElement("div");return e.style.cssText="display:flex;gap:8px;align-items:center;padding:1px 0;font-size:11px",e.dataset.id=t.id,e.innerHTML=`<span style="color:rgba(255,200,50,0.7)">⏳</span><span style="color:rgba(74,158,255,0.8);width:50px">${t.type}</span><span data-field="url" style="color:rgba(255,255,255,0.6);flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap">${this._shortUrl(t.url)}</span><span data-field="time" style="color:rgba(255,255,255,0.5);width:50px;text-align:right">${(t.elapsed/1e3).toFixed(1)}s</span>`,e}_updatePendingRow(t,e){const n=t.querySelector('[data-field="url"]'),i=t.querySelector('[data-field="time"]');n&&(n.textContent=this._shortUrl(e.url)),i&&(i.textContent=`${(e.elapsed/1e3).toFixed(1)}s`)}_updateLagSection(t){if(!this._lagSectionEl)return;const e=this._lagSectionEl.querySelectorAll("[data-tag]");for(const n of t){const t=Array.from(e).find(t=>t.dataset.tag===n.tag);if(t){const e=t.querySelector('[data-field="drift"]'),i=t.querySelector('[data-field="trend"]');e&&(e.textContent=`drift: ${n.drift>=0?"+":""}${(n.drift/1e3).toFixed(1)}s`),i&&(i.textContent=Th[n.trend],i.style.color=Ph[n.level])}}}_shortUrl(t){if(!t)return"";const e=t.split("/");return e[e.length-1]||t}_buildDOM(){const t=document.createElement("div");t.setAttribute("scene","loading-overlay"),t.style.cssText=["position:absolute","top:50%","left:50%","transform:translate(-50%,-50%)","display:flex","flex-direction:column","background:rgba(30,30,30,0.94)","border:1px solid rgba(255,255,255,0.12)","border-radius:8px","backdrop-filter:blur(12px)","pointer-events:auto","user-select:none","z-index:9999",'font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif',"font-size:13px","color:rgba(255,255,255,0.9)","box-shadow:0 4px 16px rgba(0,0,0,0.3)","min-width:320px","max-width:450px","padding:12px 16px","gap:8px"].join(";");const e=document.createElement("div");e.style.cssText="display:flex;align-items:center;justify-content:space-between";const n=document.createElement("span");n.style.cssText="font-weight:600;font-size:13px",n.textContent="Loading...",this._headerEl=n,e.appendChild(n);const i=document.createElement("button");i.textContent="✕",i.title="Close",i.style.cssText="background:none;border:none;color:rgba(255,255,255,0.6);cursor:pointer;font-size:14px;padding:2px 4px;border-radius:3px;line-height:1",i.addEventListener("mouseenter",()=>{i.style.color="rgba(255,255,255,0.9)"}),i.addEventListener("mouseleave",()=>{i.style.color="rgba(255,255,255,0.6)"}),i.addEventListener("click",()=>this.hide()),e.appendChild(i),t.appendChild(e);const r=document.createElement("div");r.style.cssText="display:flex;align-items:center;gap:8px";const s=document.createElement("div");s.style.cssText="flex:1;height:4px;background:rgba(255,255,255,0.1);border-radius:2px;overflow:hidden";const o=document.createElement("div");o.style.cssText="height:100%;width:0%;background:rgba(74,158,255,0.8);border-radius:2px;transition:width 0.3s ease",this._progressFillEl=o,s.appendChild(o),r.appendChild(s);const a=document.createElement("span");a.style.cssText="font-size:11px;color:rgba(255,255,255,0.5);white-space:nowrap;min-width:80px;text-align:right",this._progressTextEl=a,r.appendChild(a),t.appendChild(r);const c=document.createElement("div");c.style.cssText="border-top:1px solid rgba(255,255,255,0.08);padding-top:4px",this._phaseListEl=c,t.appendChild(c);const l=document.createElement("div");l.style.cssText="max-height:120px;overflow-y:auto",this._pendingListEl=l,t.appendChild(l);const h=document.createElement("div");this._lagSectionEl=h,t.appendChild(h);const d=document.createElement("div");d.style.cssText="display:flex;align-items:center;border-top:1px solid rgba(255,255,255,0.08);padding-top:8px";const u=document.createElement("span");u.style.cssText="font-size:11px;color:rgba(255,255,255,0.4)",this._elapsedEl=u,d.appendChild(u),t.appendChild(d),t.addEventListener("keydown",t=>t.stopPropagation()),this._container=t}}const Oh=.001;function zh(t,e,n){let r=1;if(n&&"none"!=n&&"transparent"!=n){r=e*("string"==typeof n?i(n).getAlpha():1)}else r=0;t.opacity=r,t.transparent=r<1}function Lh(t){const e=i(t);return e.isValid()?e.toHexString():t}const Ih={width:1,height:1,depth:1},Rh={x:1,y:1,z:1},jh={x:0,y:0,z:0},Fh={x:0,y:0,z:0},Bh=["map","normalMap","roughnessMap","metalnessMap","aoMap","emissiveMap","bumpMap","displacementMap","alphaMap","envMap","lightMap"];function Nh(t){for(const e of Bh){const n=t[e];n?.dispose()}t.dispose()}function Hh(t){t.traverse(t=>{const e=t.userData?.dispose;if("function"==typeof e)try{e()}catch{}if(t.geometry?.dispose(),t.material){const e=Array.isArray(t.material)?t.material:[t.material];for(const t of e)Nh(t)}})}function Yh(t,e,n){const i=document.createElement("canvas");i.width=e,i.height=n;const r=i.getContext("2d");if(!r)return null;let s;if("radial"===t.gradientType){const i=e/2,o=n/2,a=Math.max(e,n)/2;switch(t.center){case"left-top":s=r.createRadialGradient(0,0,0,0,0,2*a);break;case"right-top":s=r.createRadialGradient(e,0,0,e,0,2*a);break;case"left-bottom":s=r.createRadialGradient(0,n,0,0,n,2*a);break;case"right-bottom":s=r.createRadialGradient(e,n,0,e,n,2*a);break;default:s=r.createRadialGradient(i,o,0,i,o,a)}}else{const i=t.rotation??0,o=e/2,a=n/2,c=Math.cos(i)*o,l=Math.sin(i)*a;s=r.createLinearGradient(o-c,a-l,o+c,a+l)}const o=Array.isArray(t.colorStops)?t.colorStops:Array.isArray(t.gradientStops)?t.gradientStops:[];for(const t of o)if(t.position>=0&&t.position<=1)try{s.addColorStop(t.position,t.color)}catch{s.addColorStop(t.position,"#fff")}return r.fillStyle=s,r.fillRect(0,0,e,n),i}function Gh(t,e){const n=void 0!==e?e:t.state.fillStyle;if(!n||"object"!=typeof n)return;const i=n;if("pattern"===i.type&&i.image)return function(t,e){const{width:n,height:i}=t.state,r=Math.abs(n)||1,s=Math.abs(i)||1,o=new w.Texture;o.colorSpace=w.SRGBColorSpace;const a=new Image;"data"!==String(e.image).substring(0,4)&&(a.crossOrigin="anonymous"),a.onload=()=>{const n=2*r,i=2*s,c=document.createElement("canvas");c.width=n,c.height=i;const l=c.getContext("2d");if(l){if(e.color&&(l.fillStyle=e.color,l.fillRect(0,0,n,i)),e.fitPattern)l.drawImage(a,0,0,n,i);else{const t=2*(e.width||a.naturalWidth),r=2*(e.height||a.naturalHeight),s=2*(e.offsetX||0),o=2*(e.offsetY||0);let c=0,h=0;switch(e.align){case"center":c=(n-t)/2,h=(i-r)/2;break;case"left-top":break;case"left-bottom":h=i-r;break;case"right-top":c=n-t;break;case"right-bottom":c=n-t,h=i-r;break;case"left":h=(i-r)/2;break;case"right":c=n-t,h=(i-r)/2;break;case"top":c=(n-t)/2;break;case"bottom":c=(n-t)/2,h=i-r}const d=s+c,u=o+h;if(e.noRepeat)l.drawImage(a,0,0,a.naturalWidth,a.naturalHeight,d,u,t,r);else{l.save(),l.rect(0,0,n,i),l.clip();const e=d>0?d-Math.ceil(d/t)*t:d;for(let s=u>0?u-Math.ceil(u/r)*r:u;s<i;s+=r)for(let i=e;i<n;i+=t)l.drawImage(a,0,0,a.naturalWidth,a.naturalHeight,i,s,t,r);l.restore()}}o.image=c,o.minFilter=w.LinearFilter,o.needsUpdate=!0,t.invalidate()}},a.onerror=t=>{Fi("Pattern texture load error:",t)};const c=e.image;a.src=t.app.url(c);const l=t.root?.app?.loadTracker;if(l){const t=new Promise((t,e)=>{a.addEventListener("load",()=>t(),{once:!0}),a.addEventListener("error",()=>e(),{once:!0})});l.track(`pattern:${c}`,"pattern",c,t)}return o}(t,i);if("gradient"===i.type){if(Array.isArray(i.colorStops)&&i.colorStops.length>0||Array.isArray(i.gradientStops)&&i.gradientStops.length>0)return function(t){const e=Yh(t,256,256);if(!e)return;const n=new w.CanvasTexture(e);return n.colorSpace=w.SRGBColorSpace,n.needsUpdate=!0,n}(i)}}function Vh(t,e){return-1!==t.findIndex(t=>t in e)}const Uh=()=>{};class $h{static buildFillStyleTexture(t,e){return Gh(t,e)}constructor(t){this._focused=!1,this._suppressOnchange=!1,this._onchangeWrapper=(t,e,n)=>{this._suppressOnchange||n&&n.origin&&n.origin!==this._component||this.onchange(t,e)},this.suppressTransform=!1,this._component=t,this.object3d=this.getObject3dInstance(),this.component.on("change",this._onchangeWrapper)}update(){this.clear(),this.build(),this.updateTransform(),this.updateFillStyle(),this.updateStrokeStyle(),this.updateAlpha(),this.updateHidden(),this.updateText(),this._applyRaycastTarget()}getObject3dInstance(){return new w.Object3D}build(){this.object3d.userData.context=this;const t=Mh(this.component.state.material3d);this._applyShadow(t.castShadow,t.receiveShadow),this.object3d.name=this.component.state.id}updateMaterial3d(){const t=Mh(this.component.state.material3d);this._applyShadow(t.castShadow,t.receiveShadow)}_applyShadow(t,e){this.object3d.castShadow=t,this.object3d.receiveShadow=e,this.object3d.traverse(n=>{n!==this.object3d&&(n.castShadow=t,n.receiveShadow=e)})}get gizmoTransformable(){return!0}get allowedGizmoModes(){return null}get component(){return this._component}get threeContainer(){let t=this.component;for(;t;){if("is3dContainer"in t&&t.is3dContainer())return t;t=t.parent}}get focused(){return this._focused}set focused(t){this._focused=t,t&&(this._focusedAt=performance.now())}dispose(){this.component.off("change",this._onchangeWrapper),this.clear()}clear(){const t=[];for(const e of this.object3d.children){const n=e.userData?.context;n&&n!==this&&n instanceof $h?t.push(e):Hh(e)}this._components3D=void 0,this.object3d.userData={},this.object3d.clear();for(const e of t)this.object3d.add(e);return this.object3d}updateTransform(){if(this.suppressTransform)return;if(this.component.state.screenFixed&&this.component.isHTMLElement()){const{x:t=0,y:e=0}=this.component.center,{width:n=0,height:i=0}=this.component.parent?.bounds??{};return this.object3d.position.set(t-n/2,-(e-i/2),0),void this.object3d.rotation.set(0,0,0)}const{x:t,y:e,z:n}=this.position,{x:i,y:r,z:s}=this.rotation,{x:o,y:a,z:c}=this.scale;this.object3d.position.set(t,e,n),this.object3d.rotation.set(i,r,s),this.object3d.scale.set(Math.max(o,Oh),Math.max(a,Oh),Math.max(c,Oh))}get position(){const{x:t,y:e,z:n}=this.center;return{x:t,y:n,z:e}}get rotation(){const{rotationX:t=0,rotationY:e=0,rotation:n=0}=this.component.state;return{x:t,y:-n,z:e}}get scale(){const{scale:t}=this.component.state,e="number"==typeof t?t:t?.x??1;return{x:e,y:e,z:e}}get cx(){const{x:t=0}=this.component.center,{width:e=0}=this.component.parent?.bounds??{},{tx:n=0}=this.component.delta();return t+n-e/2}get cy(){const{y:t=0}=this.component.center,{height:e=0}=this.component.parent?.bounds??{},{ty:n=0}=this.component.delta();return t+n-e/2}get cz(){const t=this.effectiveZPos,{tz:e=0}=this.component.delta(),n=this.component.parent?._realObject,i=n?.geometricOffsetY??0;return t+e+this.syncZPosOffset-i}get effectiveZPos(){const t=this.component.state.zPos;if("number"==typeof t&&Number.isFinite(t))return t;const e=this.component.effectiveZPos;return"number"==typeof e&&Number.isFinite(e)?e:0}get geometricOffsetY(){const t=this.effectiveDepth/2;switch(this.scenePlacement){case"space":return 0;case"inverted":return-t;default:return t}}get scenePlacement(){const t=this.component.rootModel??this.component,e=t?.state?.placement;return"space"===e||"inverted"===e?e:"floor"}get components3D(){return this._components3D&&this._components3D.parent===this.object3d||(this._components3D=new w.Group,this.object3d.add(this._components3D)),this._components3D.position.y=-this.geometricOffsetY,this._components3D}get center(){const{x:t=0,y:e=0}=this.component.center,{width:n=0,height:i=0}=this.component.parent?.bounds??{},{tx:r=0,ty:s=0}=this.component.delta();return{x:t+r-n/2,y:e+s-i/2,z:this.cz}}freezeDimension(){this._frozenDimension={...this.dimension}}unfreezeDimension(){delete this._frozenDimension}get dimension(){if(this._frozenDimension)return this._frozenDimension;const{width:t,height:e}=this.component.bounds;return{width:Math.abs(t)||1,height:Math.abs(e)||1,depth:this.effectiveDepth}}get effectiveDepth(){const t=this.component.state.depth;if("number"==typeof t&&Number.isFinite(t)&&t>0)return t;const e=this.component.effectiveDepth;return"number"==typeof e&&Number.isFinite(e)&&e>0?e:1}updatePosition(){const{x:t=0,y:e=0,z:n=0}=this.position;this.object3d.position.set(t,e,n)}updateRotate(){const{x:t=0,y:e=0,z:n=0}=this.rotation;this.object3d.rotation.set(t,e,n)}updateScale(){const{x:t=1,y:e=1,z:n=1}=this.scale;this.object3d.scale.set(Math.max(t,Oh),Math.max(e,Oh),Math.max(n,Oh))}syncAnimationDelta(){if(this.suppressTransform)return;const t=this.component.delta();this.updatePosition();const{rotationX:e=0,rotationY:n=0,rotation:i=0}=this.component.state,r=t.theta||0,s=t.rx||0,o=t.ry||0,a=t.rz||0;this.object3d.rotation.set(e+s,-(i+r)+o,n+a);const{scale:c}=this.component.state,l="number"==typeof c?c:c?.x??1,h=t.sx??1,d=t.sy??1,u=t.sz??1;this.object3d.scale.set(Math.max(l*h,Oh),Math.max(l*d,Oh),Math.max(l*u,Oh));const p=t.fade||0;if(0!==p){const t=(this.component.state.alpha??1)*(1-p);this.object3d.traverse(e=>{if(e.isMesh&&e.material){const n=Array.isArray(e.material)?e.material:[e.material];for(const e of n)e.opacity=t,e.transparent=e.opacity<1}})}}updateDimension(){this.clear(),this.build()}updateAlpha(){let{alpha:t}=this.component.state;t=null==t?1:t,this.object3d.traverse(e=>{let n=e.material;e.material&&(Array.isArray(n)||(n=[n]),n.forEach(e=>{e.opacity*=t,e.transparent=t<1}))})}updateHidden(){this.object3d.visible=!this.component.state.hidden}updateStrokeStyle(){}updateFillStyle(){}updateText(){}_applyRaycastTarget(){const t=this.component.state.raycastTarget;let e;if("boolean"==typeof t)e=t;else{const t=this.component.constructor;e=!1!==t.raycastTargetDefault}const n=t=>{const i=t.userData?.context;if(t===this.object3d||!i||i===this){t.userData?.alwaysRaycast||(e?delete t.raycast:t.raycast=Uh);for(const e of t.children)n(e)}};n(this.object3d)}get syncZPosOffset(){const t=this.effectiveDepth/2;switch(this.scenePlacement){case"space":return 0;case"inverted":return-t;default:return t}}get textSurfaceYOffset(){return this.effectiveDepth-this.syncZPosOffset}syncFromObject3D(){const t=this.object3d,e=this._component,{width:n=0,height:i=0}=e.parent?.bounds??{},r=e.bounds,{tx:s=0,ty:o=0,tz:a=0}=e.delta();this._suppressOnchange=!0,e.bounds={left:t.position.x-s+n/2-r.width/2,top:t.position.z-o+i/2-r.height/2,width:r.width,height:r.height};const c=this.component.parent?._realObject,l=c?.geometricOffsetY??0;e.set({zPos:t.position.y-a-this.syncZPosOffset+l,rotationX:t.rotation.x,rotation:-t.rotation.y,rotationY:t.rotation.z}),this._suppressOnchange=!1}onGizmoDragEnd(t){}applyDimensionFromGizmo(t){this._suppressOnchange=!0,this._component.set(t),this._suppressOnchange=!1}onchange(t,e){if("screenFixed"in t&&this.updateTransform(),Vh(["cx","cy","cz","zPos","left","top"],t)&&this.updatePosition(),Vh(["width","height","depth","lineWidth","round"],t)&&(this.updateDimension(),"depth"in t)){this.updatePosition();const t=this.component.components;if(t)for(const e of t){const t=e?._realObject;t?.updateTransform&&t.updateTransform()}}if(Vh(["rotationX","rotationY","rotation"],t)&&this.updateRotate(),"scale"in t&&this.updateScale(),"hidden"in t&&this.updateHidden(),"alpha"in t&&this.updateAlpha(),"strokeStyle"in t&&this.updateStrokeStyle(),"fillStyle"in t&&this.updateFillStyle(),Vh(["text","fontColor","fontSize","fontFamily","bold","italic","textAlign","textBaseline"],t))this._lastText=this.component.hasTextProperty?this.component.text:"",this.updateText();else if(Vh(["value","data"],t)){const t=this.component.hasTextProperty?this.component.text:"";t!==this._lastText&&(this._lastText=t,this.updateText())}"material3d"in t&&this.updateMaterial3d(),"raycastTarget"in t&&this._applyRaycastTarget()}}class Wh extends $h{constructor(){super(...arguments),this._loadGen=0,this._objectSize=new w.Vector3}get objectSize(){return this._objectSize}build(){super.build();const{src:t}=this.component.state;if(!t)return this.clear(),this._showEmptyPlaceholder(),void(this.object3d.userData.context=this);const e=++this._loadGen,n=this.component.app.url(t),i=this._loadExternal(n).then(t=>{e===this._loadGen&&this._onLoaded(t)},t=>{e===this._loadGen&&(Fi(`${this._formatLabel}.load`,t),this.clear(),this._showErrorPlaceholder(),this.component.setState({loadError:String(t)}))});this.component.root?.app?.loadTracker?.track(`${this._formatLabel}:${t}`,this._formatLabel,t,i)}updateSource(){this.build()}get _placeholderColor(){return 6770852}_showEmptyPlaceholder(){const{width:t=100,height:e=100,depth:n=100}=this.component.state,i=t||100,r=e||100,s=n||100,o=this._placeholderColor,a=new w.BoxGeometry(i,s,r),c=new w.MeshStandardMaterial({color:o,transparent:!0,opacity:.15,depthWrite:!1}),l=new w.Mesh(a,c);l.name="__empty_placeholder__";const h=new w.EdgesGeometry(a),d=new w.LineBasicMaterial({color:o,transparent:!0,opacity:.4}),u=new w.LineSegments(h,d);u.name="__empty_placeholder_edge__",l.add(u),this.object3d.add(l)}_showErrorPlaceholder(){const t=new w.BoxGeometry(1,1,1),e=new w.MeshStandardMaterial({color:13369344,wireframe:!0}),n=new w.Mesh(t,e);n.name="__error_placeholder__",this.object3d.add(n)}clear(){return this.pivot&&Hh(this.pivot),this.pivot=void 0,this._objectSize=void 0,super.clear()}}const Xh="KHR_materials_pbrSpecularGlossiness";class qh{constructor(t){this.name=Xh,this.parser=t}extendMaterialParams(t,e){const i=this.parser.json.materials?.[t],r=i?.extensions?.[Xh];if(!r)return Promise.resolve();const s=[];if(Array.isArray(r.diffuseFactor)){const[t,i,s,o]=r.diffuseFactor;e.color||(e.color=new n.Color),e.color.setRGB(t,i,s,n.LinearSRGBColorSpace),e.opacity=o}null!=r.diffuseTexture&&s.push(this.parser.assignTexture(e,"map",r.diffuseTexture,n.SRGBColorSpace));const o=r.glossinessFactor??1;e.roughness=1-o;const a=r.specularFactor??[1,1,1],c=Math.max(a[0],a[1],a[2]);return e.metalness=c>.5?c:0,Promise.all(s)}}(()=>{const t="__urdfBlobCrossOriginPatched__",e=w.ImageLoader.prototype;if(e[t])return;const n=e.load;e.load=function(t,e,i,r){if("string"==typeof t&&t.startsWith("blob:")){const s=this.crossOrigin;this.crossOrigin=void 0;try{return n.call(this,t,e,i,r)}finally{this.crossOrigin=s}}return n.call(this,t,e,i,r)},e[t]=!0})();const Kh={once:w.LoopOnce,repeat:w.LoopRepeat,pingpong:w.LoopPingPong};class Qh extends Wh{constructor(){super(...arguments),this._nodeIndex=new Map,this._originals=new Map,this._animationActions=new Map,this._fillStyleOriginals=new Map,this._clonedMaterials=new WeakSet}get _formatLabel(){return"gltf"}static getSharedSnapshotRenderer(){const t=Qh._sharedSnapshotRenderer;if(t){const e=t.getContext();if(e&&!e.isContextLost())return t;try{t.forceContextLoss()}catch{}t.dispose(),Qh._sharedSnapshotRenderer=void 0}try{const t=new w.WebGLRenderer({antialias:!0,alpha:!0}),e=t.getContext();if(!e||e.isContextLost()){try{t.forceContextLoss()}catch{}return void t.dispose()}return Qh._sharedSnapshotRenderer=t,t}catch{return}}static getSharedLoader(t){if(!Qh._sharedLoader){const t=new r.GLTFLoader;!function(t){t.register(t=>new qh(t))}(t);const e=new s.DRACOLoader;e.setDecoderPath("/node_modules/three/examples/jsm/libs/draco/"),t.setDRACOLoader(e);const n=new o.KTX2Loader;n.setTranscoderPath("/node_modules/three/examples/jsm/libs/basis/"),t.setKTX2Loader(n),t.setMeshoptDecoder(a.MeshoptDecoder),t.setCrossOrigin("anonymous"),Qh._sharedLoader=t}return t&&Qh._sharedLoader.ktx2Loader?.detectSupport(t),Qh._sharedLoader}static loadGLTF(t,e){let n=Qh._gltfCache.get(t);if(!n){const i=Qh.getSharedLoader(e);n=new Promise((e,n)=>{i.load(t,e,void 0,n)}).catch(e=>{throw Qh._gltfCache.delete(t),e}),Qh._gltfCache.set(t,n)}return n}_ensureOwnMaterial(t){let e=t.material;return this._clonedMaterials.has(e)||(e=e.clone(),t.material=e,this._clonedMaterials.add(e)),e}_loadExternal(t){return Qh.loadGLTF(t,this.threeContainer?.renderer3d)}_onLoaded(t){this.component.state.loadError&&this.component.setState({loadError:void 0});const e=t.scene,n=t.animations,i=c.clone(e);i.userData.context=this,i.traverse(t=>{t.isMesh&&(t.castShadow=!0)});const r=(new w.Box3).setFromObject(i),s=r.getCenter(i.position),o=r.getSize(new w.Vector3);if(s.multiplyScalar(-1),this.clear(),this.object3d.userData.context=this,this._objectSize=o,this.pivot=new w.Object3D,this.component.state.floorAlign?this.components3D.add(this.pivot):this.object3d.add(this.pivot),this.pivot.add(i),this._buildNodeIndex(i),this.component.state.autoFit&&o.x>0&&o.y>0&&o.z>0){const t=(Number(this.component.state.autoFitSize)>0?Number(this.component.state.autoFitSize):200)/Math.max(o.x,o.y,o.z),e=Math.max(1,Math.round(o.x*t)),n=Math.max(1,Math.round(o.y*t)),i=Math.max(1,Math.round(o.z*t)),r=this.component;r._ratioLocking=!0;try{this.component.set({width:e,height:i,depth:n,autoFit:!1})}finally{r._ratioLocking=!1}}if(this.updateDimension(),this.component.state.floorAlign){const t=this.scenePlacement;if("space"!==t){this.components3D.updateMatrixWorld(!0);const e=(new w.Box3).setFromObject(this.pivot);if(isFinite(e.min.y)&&isFinite(e.max.y))if("inverted"===t){const t=this.components3D.worldToLocal(e.max.clone());t.y>0&&(this.pivot.position.y-=t.y)}else{const t=this.components3D.worldToLocal(e.min.clone());t.y<0&&(this.pivot.position.y-=t.y)}}}n&&n.length&&this._setupAnimations(n);const a=this.component.state.nodes;a&&this._applyNodeStates(a),this.updateFillStyle()}static renderTopView(t){const e=256,n=new w.Scene,i=t.parent;n.add(t);const r=new w.AmbientLight(16777215,.8);n.add(r);const s=new w.DirectionalLight(16777215,1);s.position.set(0,10,0),n.add(s);const o=(new w.Box3).setFromObject(t),a=o.getSize(new w.Vector3),c=o.getCenter(new w.Vector3),l=(a.x||1)/2*1.02,h=(a.z||1)/2*1.02,d=new w.OrthographicCamera(-l,l,h,-h,.01,10*a.y+1);d.position.set(c.x,o.max.y+a.y,c.z),d.lookAt(c.x,c.y,c.z);const u=l/h,p=u>=1?e:Math.round(e*u),f=u>=1?Math.round(e/u):e,g=Qh.getSharedSnapshotRenderer();if(!g){i?i.add(t):n.remove(t);const e=document.createElement("canvas");return e.width=p,e.height=f,e}g.setClearColor(0,0),g.setSize(p,f),g.render(n,d),i?i.add(t):n.remove(t);const m=document.createElement("canvas");m.width=p,m.height=f;const y=m.getContext("2d");return y&&y.drawImage(g.domElement,0,0),m}static getTopViewCache(t){return Qh._topViewCache.get(t)}static setTopViewCache(t,e){Qh._topViewCache.set(t,e)}static flushCache(){if(Qh._gltfCache.clear(),Qh._topViewCache.clear(),Qh._sharedSnapshotRenderer){try{Qh._sharedSnapshotRenderer.forceContextLoss()}catch{}Qh._sharedSnapshotRenderer.dispose(),Qh._sharedSnapshotRenderer=void 0}}_buildNodeIndex(t){this._nodeIndex.clear(),this._originals.clear(),t.traverse(t=>{if(!t.name)return;this._nodeIndex.set(t.name,t);const e={visible:t.visible,scale:t.scale.clone()};if(t.isMesh){const n=t.material;n&&(e.color=n.color.clone(),e.opacity=n.opacity,e.transparent=n.transparent,e.emissive=n.emissive.clone(),e.emissiveIntensity=n.emissiveIntensity)}this._originals.set(t.name,e)})}getNode(t){return this._nodeIndex.get(t)}get nodeNames(){return Array.from(this._nodeIndex.keys())}_applyNodeStates(t){for(const[e,n]of Object.entries(t)){const t=this._nodeIndex.get(e);if(t&&(void 0!==n.visible&&(t.visible=n.visible),void 0!==n.scale&&t.scale.setScalar(n.scale),t.isMesh)){const e=t;if(!(void 0!==n.color||void 0!==n.opacity||void 0!==n.emissive||void 0!==n.emissiveIntensity))continue;const i=this._ensureOwnMaterial(e);void 0!==n.color&&i.color.set(n.color),void 0!==n.opacity&&(i.opacity=n.opacity,i.transparent=n.opacity<1),void 0!==n.emissive&&i.emissive.set(n.emissive),void 0!==n.emissiveIntensity&&(i.emissiveIntensity=n.emissiveIntensity)}}}_resetNode(t){const e=this._nodeIndex.get(t),n=this._originals.get(t);if(e&&n&&(e.visible=n.visible,e.scale.copy(n.scale),e.isMesh)){const t=e.material;t&&n.color&&(t.color.copy(n.color),t.opacity=n.opacity,t.transparent=n.transparent,t.emissive.copy(n.emissive),t.emissiveIntensity=n.emissiveIntensity)}}_resetAllNodes(){for(const t of this._originals.keys())this._resetNode(t)}_setupAnimations(t){const e=this.threeContainer.mixer;this._animationActions.clear();for(const n of t){const t=e.clipAction(n);this._animationActions.set(n.name,t)}!1!==this.component.state.play&&this._playTargetAnimations();const n=this.component.state.animations;n&&this._applyAnimationStates(n)}_playTargetAnimations(){const t=this.component.state.playTargets;if("*"===t)this._animationActions.forEach(t=>t.play());else if(Array.isArray(t)&&t.length>0)for(const e of t)this._animationActions.get(e)?.play()}_applyAnimationStates(t){for(const[e,n]of Object.entries(t)){const t=this._animationActions.get(e);t&&(void 0!==n.loop&&(t.loop=Kh[n.loop]??w.LoopRepeat,"once"===n.loop&&(t.clampWhenFinished=!0)),void 0!==n.speed&&(t.timeScale=n.speed),void 0!==n.weight&&(t.weight=n.weight),void 0!==n.play&&(n.play?t.play():t.stop()))}}get animationNames(){return Array.from(this._animationActions.keys())}updateFillStyle(){const{fillStyle:t}=this.component.state;if(!t)return;const e=this.component.state.fillStyleTargets;let n;if("*"===e)n=[...this._nodeIndex.entries()].filter(([,t])=>t.isMesh).map(([t])=>t);else{if(!(Array.isArray(e)&&e.length>0))return;n=e}if(0===n.length)return;const i=$h.buildFillStyleTexture(this.component);for(const e of n){const n=this._nodeIndex.get(e);if(!n||!n.isMesh)continue;const r=this._ensureOwnMaterial(n);r&&(this._fillStyleOriginals.has(e)||this._fillStyleOriginals.set(e,{color:r.color.clone(),map:r.map,opacity:r.opacity,transparent:r.transparent}),i?(r.map&&r.map!==this._fillStyleOriginals.get(e)?.map&&r.map.dispose(),i.needsUpdate=!0,r.map=i):"string"==typeof t&&("transparent"!==t?r.color.set(t):(r.opacity=0,r.transparent=!0)))}}_restoreFillStyleTargets(t){for(const e of t){const t=this._fillStyleOriginals.get(e);if(!t)continue;const n=this._nodeIndex.get(e);if(!n||!n.isMesh)continue;const i=n.material;i&&(i.map&&i.map!==t.map&&i.map.dispose(),i.color.copy(t.color),i.map=t.map,i.opacity=t.opacity,i.transparent=t.transparent,this._fillStyleOriginals.delete(e))}}clear(){return this._animationActions.forEach(t=>t.stop()),this._animationActions.clear(),this._nodeIndex.clear(),this._originals.clear(),this._fillStyleOriginals.clear(),super.clear()}updateDimension(){const{width:t=1,height:e=1,depth:n=1}=this.component.state,{x:i=1,y:r=1,z:s=1}=this.objectSize||{};this.pivot&&this.pivot.scale.set(t/i,n/r,e/s),this.component.invalidate()}onchange(t,e){if(super.onchange(t,e),("src"in t||"floorAlign"in t)&&this.updateSource(),"nodes"in t){this._resetAllNodes();const e=t.nodes;e&&Object.keys(e).length>0&&this._applyNodeStates(e)}if("animations"in t){const e=t.animations;e&&this._applyAnimationStates(e)}if("fillStyleTargets"in t){const t=[...this._fillStyleOriginals.keys()];t.length>0&&this._restoreFillStyleTargets(t),this.updateFillStyle()}("play"in t||"playTargets"in t)&&(this._animationActions.forEach(t=>t.stop()),!1!==this.component.state.play&&this._playTargetAnimations())}}Qh._topViewCache=new Map,Qh._gltfCache=new Map,Qh._sharedLoader=null;const Zh=["id","name","tag","type","class","text","data","property"];class Jh{constructor(){this._results=[],this._currentIndex=-1,this._lastQuery=""}get results(){return this._results}get currentIndex(){return this._currentIndex}get currentResult(){return this._results[this._currentIndex]}get resultCount(){return this._results.length}search(t,e,n){if(this._lastQuery=e,this._results=[],this._currentIndex=-1,!e||!t)return this._results;const i=n?.fields||Zh,r=n?.caseSensitive??!1,s=n?.includeHidden??!1,o=n?.maxResults??1/0,a=r?e:e.toLowerCase(),c=new Set;return this._traverse(t,t=>{if(c.has(t))return;if(this._results.length>=o)return;if(!s&&t.state.hidden)return;const e=this._matchComponent(t,a,i,r);e&&(c.add(t),this._results.push(e))}),this._results.length>0&&(this._currentIndex=0),this._results}navigateNext(){if(0!==this._results.length)return this._currentIndex=(this._currentIndex+1)%this._results.length,this._results[this._currentIndex]}navigatePrev(){if(0!==this._results.length)return this._currentIndex=(this._currentIndex-1+this._results.length)%this._results.length,this._results[this._currentIndex]}navigateTo(t){if(!(t<0||t>=this._results.length))return this._currentIndex=t,this._results[this._currentIndex]}clear(){this._results=[],this._currentIndex=-1,this._lastQuery=""}_traverse(t,e){e(t);const n=t.components;if(n)for(const t of n)this._traverse(t,e)}_matchComponent(t,e,n,i){const r=t.state,s=t=>{if(!t)return!1;return(i?t:t.toLowerCase()).includes(e)};for(const o of n)switch(o){case"id":if(s(r.id))return{component:t,matchType:"id",matchField:"id",matchValue:r.id};break;case"name":if(s(r.name))return{component:t,matchType:"name",matchField:"name",matchValue:r.name};break;case"tag":if(s(r.tag))return{component:t,matchType:"tag",matchField:"tag",matchValue:r.tag};break;case"type":if(s(r.type))return{component:t,matchType:"type",matchField:"type",matchValue:r.type};break;case"class":if(s(r.class))return{component:t,matchType:"class",matchField:"class",matchValue:r.class};break;case"text":if(s(r.text))return{component:t,matchType:"text",matchField:"text",matchValue:r.text};break;case"data":{const n=this._matchDataBinding(t,e,i);if(n)return n;break}case"property":{const n=this._matchProperties(t,e,i);if(n)return n;break}}return null}_matchDataBinding(t,e,n){const i=t._model,r=i?.mappings;if(!r||!Array.isArray(r))return null;const s=t=>{if(!t)return!1;return(n?t:t.toLowerCase()).includes(e)};for(const e of r){if(s(e.accessor))return{component:t,matchType:"data",matchField:"accessor",matchValue:e.accessor};if(s(e.target))return{component:t,matchType:"data",matchField:"target",matchValue:e.target};if(s(e.property))return{component:t,matchType:"data",matchField:"property",matchValue:e.property};if(s(e.source))return{component:t,matchType:"data",matchField:"source",matchValue:e.source}}return null}_matchProperties(t,e,n){const i=t.state,r=t=>{if(!t)return!1;return(n?t:t.toLowerCase()).includes(e)},s=["ref","src","value","action"];for(const e of s){const n=i[e];if("string"==typeof n&&r(n))return{component:t,matchType:"property",matchField:e,matchValue:n}}const o=i.fillStyle;if(o){if("string"==typeof o&&r(o))return{component:t,matchType:"property",matchField:"fillStyle",matchValue:o};if("object"==typeof o&&"pattern"===o.type&&"string"==typeof o.image&&r(o.image))return{component:t,matchType:"property",matchField:"fillStyle.image",matchValue:o.image}}return null}}const td={id:"ID",name:"Name",tag:"Tag",type:"Type",class:"Class",text:"Text",data:"Data",property:"Prop"};class ed{constructor(){this._engine=new Jh,this._visible=!1,this._queryHistory=[],this._historyIndex=-1,this._savedInput="",this._keyboardNav=!1}get isVisible(){return this._visible}get engine(){return this._engine}setup(t){this.destroy(),this._host=t}toggle(){this._visible?this._input&&document.activeElement!==this._input?(this._input.focus(),this._input.select()):this.hide():this.show()}show(){this._host?.element&&(this._container||this._buildDOM(),this._container&&!this._container.parentElement&&this._host.element.appendChild(this._container),this._container.style.display="flex",this._visible=!0,requestAnimationFrame(()=>{this._input?.focus(),this._input?.select()}))}hide(){this._container&&(this._container.style.display="none"),this._visible=!1,this._historyIndex=-1,this._clearHighlight(),this._engine.clear(),this._updateStatus(),this._hideResultList()}destroy(){this._container?.parentElement&&this._container.parentElement.removeChild(this._container),this._container=void 0,this._input=void 0,this._statusEl=void 0,this._resultListEl=void 0,this._host=void 0,this._visible=!1,this._engine.clear()}_buildDOM(){const t=this._host,e=document.createElement("div");e.setAttribute("scene","search-overlay"),e.style.cssText=["position:absolute","top:8px","right:8px","display:flex","flex-direction:column","background:rgba(30,30,30,0.94)","border:1px solid rgba(255,255,255,0.12)","border-radius:8px","backdrop-filter:blur(12px)","pointer-events:auto","user-select:none","z-index:10000",'font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif',"font-size:13px","color:rgba(255,255,255,0.9)","box-shadow:0 4px 16px rgba(0,0,0,0.3)","min-width:280px","max-width:400px"].join(";");const n=document.createElement("div");n.style.cssText="display:flex;align-items:center;padding:6px 8px;gap:6px";const i=document.createElement("span");i.textContent="🔍",i.style.cssText="font-size:14px;flex-shrink:0;opacity:0.6",n.appendChild(i);const r=document.createElement("input");r.type="text",r.placeholder="Search: type, id, tag, text, data...",r.style.cssText=["flex:1","background:rgba(255,255,255,0.08)","border:1px solid rgba(255,255,255,0.15)","border-radius:4px","color:white","padding:4px 8px","font-size:13px","outline:none","min-width:0"].join(";"),r.addEventListener("focus",()=>{r.style.borderColor="rgba(74,158,255,0.6)"}),r.addEventListener("blur",()=>{r.style.borderColor="rgba(255,255,255,0.15)"}),n.appendChild(r);const s=document.createElement("span");s.style.cssText="font-size:11px;color:rgba(255,255,255,0.5);white-space:nowrap;flex-shrink:0",n.appendChild(s);const o=document.createElement("button");o.textContent="✕",o.title="Close (Esc)",o.style.cssText=this._buttonStyle(),o.addEventListener("click",()=>this.hide()),n.appendChild(o),e.appendChild(n);const a=document.createElement("div");a.style.cssText=["max-height:240px","overflow-y:auto","border-top:1px solid rgba(255,255,255,0.08)","display:none"].join(";"),e.appendChild(a),r.addEventListener("input",()=>{this._historyIndex=-1,this._debounceTimer&&clearTimeout(this._debounceTimer),this._debounceTimer=setTimeout(()=>this._doSearch(r.value),150)}),r.addEventListener("keydown",e=>{if(e.stopPropagation(),"Escape"===e.key)return this.hide(),void t.element?.focus();if("ArrowDown"===e.key||"Tab"===e.key){if("Tab"===e.key&&e.shiftKey)return;return this._isHistoryMode()||!this._input?.value&&"ArrowDown"===e.key?this._navigateHistory(1):this._engine.resultCount>0&&this._focusResult(0),void e.preventDefault()}if("ArrowUp"===e.key)return this._navigateHistory(-1),void e.preventDefault();if("Enter"===e.key){const t=this._engine.currentIndex>=0?this._engine.currentIndex:0;return this._selectResult(t),void e.preventDefault()}}),this._container=e,this._input=r,this._statusEl=s,this._resultListEl=a}_buttonStyle(){return["background:none","border:none","color:rgba(255,255,255,0.6)","cursor:pointer","font-size:12px","padding:2px 4px","border-radius:3px","line-height:1"].join(";")}_doSearch(t){if(!this._host?.root)return;const e=t.trim();if(!e)return this._engine.clear(),this._clearHighlight(),this._updateStatus(),void this._hideResultList();this._engine.search(this._host.root,e),this._updateStatus(),this._renderResultList()}_addToHistory(t){const e=t.trim();if(!e)return;const n=this._queryHistory.indexOf(e);n>=0&&this._queryHistory.splice(n,1),this._queryHistory.unshift(e),this._queryHistory.length>ed.MAX_HISTORY&&this._queryHistory.pop()}_navigateHistory(t){if(0===this._queryHistory.length)return;if(!this._input)return;-1===this._historyIndex&&-1===t&&(this._savedInput=this._input.value);const e=this._historyIndex+(-1===t?1:-1);e<-1||e>=this._queryHistory.length||(this._historyIndex=e,-1===this._historyIndex?this._input.value=this._savedInput:this._input.value=this._queryHistory[this._historyIndex],this._debounceTimer&&clearTimeout(this._debounceTimer),this._doSearch(this._input.value))}_isHistoryMode(){return this._historyIndex>=0}_focusResult(t){if(t<0||t>=this._engine.resultCount)return;if(t>=50)return;this._engine.navigateTo(t),this._keyboardNav=!0,this._updateStatus(),this._updateResultListSelection();const e=this._resultListEl?.querySelector(`[data-index="${t}"]`);e?.focus()}_selectResult(t){if(!this._host)return;if(0===this._engine.resultCount)return;if(t<0||t>=this._engine.resultCount)return;this._engine.navigateTo(t);const e=this._engine.currentResult;if(!e)return;this._addToHistory(this._input?.value||""),this._host.setSelected([e.component]),this._host.centerTo(e.component,!0);const n=this._engine.results.map(t=>t.component);this._host.highlightSearchResults?.(n),this._host.invalidate?.(),this._updateStatus(),this._updateResultListSelection()}_clearHighlight(){this._host?.highlightSearchResults?.([]),this._host?.invalidate?.()}_updateStatus(){if(!this._statusEl)return;const t=this._engine.resultCount,e=this._engine.currentIndex;0===t&&this._input?.value?.trim()?(this._statusEl.textContent="No results",this._statusEl.style.color="rgba(255,120,120,0.8)"):t>0?(this._statusEl.textContent=`${e+1}/${t}`,this._statusEl.style.color="rgba(255,255,255,0.5)"):this._statusEl.textContent=""}_renderResultList(){if(!this._resultListEl)return;const t=this._engine.results;if(this._resultListEl.innerHTML="",0===t.length)return void(this._resultListEl.style.display="none");const e=t.slice(0,50);for(let t=0;t<e.length;t++){const n=e[t],i=document.createElement("div");i.dataset.index=String(t),i.tabIndex=-1,i.style.cssText=["padding:4px 10px","cursor:pointer","display:flex","align-items:center","gap:6px","font-size:12px","border-bottom:1px solid rgba(255,255,255,0.04)","transition:background 0.1s","outline:none"].join(";"),i.addEventListener("mouseenter",()=>{this._keyboardNav=!1,i.style.background="rgba(255,255,255,0.08)"}),i.addEventListener("mouseleave",()=>{this._engine.currentIndex!==t?i.style.background="none":i.style.background="rgba(74,158,255,0.15)"}),i.addEventListener("click",()=>{this._selectResult(t)}),i.addEventListener("keydown",e=>{e.stopPropagation(),"ArrowDown"===e.key?(this._focusResult(t+1),e.preventDefault()):"ArrowUp"===e.key?(0===t?(this._input?.focus(),this._input?.select()):this._focusResult(t-1),e.preventDefault()):"Enter"===e.key?(this._selectResult(t),e.preventDefault()):"Escape"===e.key?(this.hide(),this._host?.element?.focus(),e.preventDefault()):e.shiftKey&&"Tab"===e.key?(this._input?.focus(),e.preventDefault()):1!==e.key.length||e.metaKey||e.ctrlKey||e.altKey||this._input?.focus()});const r=document.createElement("span");r.textContent=td[n.matchType]||n.matchType,r.style.cssText=["font-size:9px","padding:1px 4px","border-radius:3px","background:rgba(74,158,255,0.2)","color:rgba(74,158,255,0.9)","flex-shrink:0","text-transform:uppercase","letter-spacing:0.5px"].join(";"),i.appendChild(r);const s=document.createElement("span");s.textContent=n.component.state.type||"?",s.style.cssText="color:rgba(255,255,255,0.7);flex-shrink:0",i.appendChild(s);const o=document.createElement("span");if(o.textContent=this._truncate(n.matchValue,30),o.style.cssText="color:rgba(255,200,100,0.8);overflow:hidden;text-overflow:ellipsis;white-space:nowrap",i.appendChild(o),"id"!==n.matchType&&n.component.state.id){const t=document.createElement("span");t.textContent=`#${n.component.state.id}`,t.style.cssText="color:rgba(255,255,255,0.3);font-size:11px;margin-left:auto;flex-shrink:0",i.appendChild(t)}this._resultListEl.appendChild(i)}if(t.length>50){const e=document.createElement("div");e.style.cssText="padding:4px 10px;font-size:11px;color:rgba(255,255,255,0.3);text-align:center",e.textContent=`... and ${t.length-50} more`,this._resultListEl.appendChild(e)}this._resultListEl.style.display="block",this._updateResultListSelection()}_updateResultListSelection(){if(!this._resultListEl)return;const t=this._engine.currentIndex;for(const e of Array.from(this._resultListEl.children)){const n=e,i=parseInt(n.dataset.index||"-1",10);n.style.background=i===t?"rgba(74,158,255,0.15)":"none"}const e=this._resultListEl.querySelector(`[data-index="${t}"]`);e?.scrollIntoView({block:"nearest"})}_hideResultList(){this._resultListEl&&(this._resultListEl.style.display="none",this._resultListEl.innerHTML="")}_truncate(t,e){return t.length>e?t.slice(0,e)+"...":t}}ed.MAX_HISTORY=20;let nd=0;const id=new FinalizationRegistry(t=>{nd--});class rd{static get residents(){return nd}static get residentsCount(){return nd}constructor(t){this._searchOverlay=new ed,this._loadingOverlay=new Dh,this._container=t,this.app=t.app,this._commander=new ml(this._container),this.app.commander=this._commander,nd++,id.register(this,nd),kh.register(this),this._container.target_element&&this._setupSearchOverlay()}add(t,e,n){return Ol.call(this._container,t,e,n)}duplicate(){return zl.call(this._container)}remove(){return Ll.call(this._container)}animate(t){return No.call(this,t)}fullscreen(t){return Nl.call(this._container,t)}get target(){return this._container.target_element}set target(t){let e;if("string"==typeof t){if(e=document.getElementById(t),!e)throw new Error(`target element '${t}' does not exist`);if(e.firstChild)throw new Error(`target element '${t}' already has children`)}else e=t;e&&e.style&&(e.style.cursor="default"),this._container.target_element=e,this._setupSearchOverlay(),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 Mr}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._loadingOverlay.destroy(),this._searchOverlay.destroy(),kh.unregister(this),this._commander&&this._commander.dispose(),this._container&&this._container.dispose(),Qh.flushCache()}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 Gl.call(this._container)}copy(){return Yl.call(this._container)}paste(t){return Vl.call(this._container,t)}undoableChange(t){return ch.call(this._container,t)}change(t,e,n){return ah.call(this.root,t,e,n)}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(t,...e){return this.root.findAll(t,...e)}findFirst(t,...e){return this.root.findFirst(t,...e)}findById(t){return this._container.findById(t)}findAllById(t){return this._container.findAllById(t)}serialize(){return this.root.trim(),this.root.serialize()}align(t){return El.call(this._container,t)}place(t){return mh.call(this._container,t)}distribute(t){return Tl.call(this._container,t)}move(t,e,n){return Pl.call(this._container,t,e,n)}zorder(t){return Dl.call(this._container,t)}symmetryX(){return sh.call(this._container)}symmetryY(){return oh.call(this._container)}on(t,e,n){return jl.call(this._container,t,e,n)}once(t,e,n){return Fl.call(this._container,t,e,n)}off(t,e,n){return this._container&&Bl.call(this._container,t,e,n)}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(t,e,n,i){return th.call(this._container,t,e,n,i)}group(){return eh.call(this._container)}ungroup(){return nh.call(this._container)}fit(t){this._container.once("redraw",()=>this._container.fit(t)),this._container.invalidate()}get fitMode(){return this._container.fitMode}get ids(){return lh.call(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}get suppressAnimations(){return this.app.suppressAnimations}set suppressAnimations(t){this.app.suppressAnimations=t}withSuppressedAnimations(t){return this.app.withSuppressedAnimations(t)}beginSuppressAnimations(){return this.app.beginSuppressAnimations()}startAddMode(t){return yh.call(this._container,t)}startStylePasteMode(){return bh.call(this._container)}stopStylePasteMode(){return _h.call(this._container)}startDatabindPasteMode(){return vh.call(this._container)}stopDatabindPasteMode(){return xh.call(this._container)}get loading(){return this.app.loadTracker}get loadingOverlay(){return this._loadingOverlay}showLoadingOverlay(){this._loadingOverlay.show()}hideLoadingOverlay(){this._loadingOverlay.hide()}toggleLoadingOverlay(){if(!this._loadingOverlay.isAttached){const t=this._container.target_element;t&&this._loadingOverlay.attach(t,this.app.loadTracker,this.app.lagTracker)}this._loadingOverlay.toggle()}get searchOverlay(){return this._searchOverlay}_setupSearchOverlay(){const t=this;this._searchOverlay.setup({get root(){return t.root},get element(){return t.target},centerTo(e,n){t.centerTo(e,n)},setSelected(e){t.selected=e},invalidate(){t._container?.invalidate()}});const e=this._container.model_layer;e&&(e.onSearchToggle=()=>this._searchOverlay.toggle(),e.onDataBindingToggle=()=>this.onDataBindingToggle?.(),e.onMonitorToggle=()=>this.toggleLoadingOverlay())}_setupLoadingOverlay(){const t=this._container.target_element;t&&this._loadingOverlay.attach(t,this.app.loadTracker,this.app.lagTracker)}}const sd=new class{async load(t){}async save(t,e){}async clear(t){}};function od({target:t,model:e,style:n,layers:i=[],handlers:r=[],mode:s=0,refProvider:o,dataSubscriptionProvider:a,dataStorage:c=sd,baseUrl:l,fitMode:h,postprocessing:d=!0,loading:u}){let p=null;if("string"==typeof t){if(p=document.getElementById(t),!p)throw new Error(`target element '${t}' does not exist`);if(p.firstChild)throw new Error(`target element '${t}' is not empty`)}else p=t??null;p&&p.style&&(p.style.position="absolute",p.style.cursor="default",p.style.overflow="hidden");const f=new hl(s,o);return l&&(f.baseUrl=l),f.postprocessing=d,f.dataSubscriptionProvider=a,f.dataStorage=c,u?.tracker?f.adoptLoadTracker(u.tracker):f.initLoadTracker(u||{}),f.loadTracker?.setPhase("init"),new rd(new el({target_element:p,model:e,style:n,layers:i,handlers:r,fitMode:h},f))}const ad=20;function cd(t,e="static",n,i,r,s,o={}){const{title:a="",gap:c=ad}=o;if("auto"===n){const{x:e,y:n}=function(t,e,n,i="",r=ad){const s=Math.max(e.width/4-n.width/2,r),o=Math.min(3*e.width/4+n.width/2,e.width-r)-n.width,a=Math.max(e.height/4-n.height/2,r),c=Math.min(3*e.height/4+n.height/2,e.height-r)-n.height+(i?-30:0);return{x:t.x<e.width/2?Math.min(o,t.x+20):Math.max(s,t.x-(n.width+20)),y:t.y<e.height/2?Math.min(c,t.y+20+(i?30:0)):Math.max(a,t.y-(n.height+20))}}(i,r,s,a,c);Object.assign(t.style,{position:"absolute",left:`${e}px`,top:`${n}px`})}else"static"===e?function(t,e,n,i,r){const s=t.style,o=e.includes("left")?r:e.includes("right")?n.width-i.width-r:n.width/2-i.width/2,a=e.includes("top")?r:e.includes("bottom")?n.height-i.height-r:n.height/2-i.height/2;Object.assign(s,{left:`${o}px`,top:`${a}px`})}(t,n,r,s,c):function(t,e,n=ad){const i=t.style;switch(Object.assign(i,{position:"absolute",left:"",right:"",top:"",bottom:"",transform:""}),e){case"center-middle":default:Object.assign(i,{left:"50%",top:"50%",transform:"translate(-50%, -50%)"});break;case"center-top":Object.assign(i,{left:"50%",top:`${n}px`,transform:"translateX(-50%)"});break;case"center-bottom":Object.assign(i,{left:"50%",bottom:`${n}px`,transform:"translateX(-50%)"});break;case"left-middle":Object.assign(i,{left:`${n}px`,top:"50%",transform:"translateY(-50%)"});break;case"right-middle":Object.assign(i,{right:`${n}px`,top:"50%",transform:"translateY(-50%)"});break;case"left-top":Object.assign(i,{left:`${n}px`,top:`${n}px`});break;case"right-top":Object.assign(i,{right:`${n}px`,top:`${n}px`});break;case"left-bottom":Object.assign(i,{left:`${n}px`,bottom:`${n}px`});break;case"right-bottom":Object.assign(i,{right:`${n}px`,bottom:`${n}px`})}}(t,n,c)}function ld(t,e,n={sx:1,sy:1},i={}){const{signal:r}=i;let s,o,a=0,c=0,l=!1;const h=/translate\(([-\d.]+)px,\s*([-\d.]+)px\)/;function d(){const e=(t.style.transform||"").match(h);return{x:e?parseFloat(e[1]):0,y:e?parseFloat(e[2]):0}}function u(t,e){l=!0;const n=d();a=n.x,c=n.y,s=t,o=e}function p(e,i){if(!l)return;const r=e-s,h=i-o,{sx:d,sy:u}=n;!function(e,n){t.style.transform=`translate(${e}px, ${n}px)`}(a+r/d,c+h/u)}function f(){const t=d();a=t.x,c=t.y,l=!1}function g(t){if(!r)return t.signal;const e=AbortSignal.any;return e?e([t.signal,r]):(r.aborted?t.abort():r.addEventListener("abort",()=>t.abort(),{once:!0}),t.signal)}e?.addEventListener("mousedown",t=>{t.preventDefault(),t.stopPropagation(),u(t.clientX,t.clientY);const e=new AbortController,n=g(e);window.addEventListener("mousemove",t=>{t.preventDefault(),p(t.clientX,t.clientY)},{capture:!0,signal:n}),window.addEventListener("mouseup",t=>{t.preventDefault(),f(),e.abort()},{capture:!0,signal:n})},{signal:r}),e?.addEventListener("touchstart",t=>{if(1!==t.touches.length)return;t.preventDefault(),t.stopPropagation(),u(t.touches[0].clientX,t.touches[0].clientY);const e=new AbortController,n=g(e);window.addEventListener("touchmove",t=>{1===t.touches.length&&(t.preventDefault(),p(t.touches[0].clientX,t.touches[0].clientY))},{capture:!0,signal:n});const i=()=>{f(),e.abort()};window.addEventListener("touchend",i,{capture:!0,signal:n}),window.addEventListener("touchcancel",i,{capture:!0,signal:n})},{signal:r})}function hd(t,e,n){const i=t.rootModel;if(i?.is3dMode){const e=t._realObject?.object3d,n=i.activeCamera3d,r=i.renderer3d;if(e&&n&&r){const t=new w.Vector3;e.getWorldPosition(t);const i=t.clone().project(n),s=r.domElement;return{x:(.5*i.x+.5)*s.clientWidth,y:(.5*-i.y+.5)*s.clientHeight}}return null}const r=t.toGlobal(e,n,i);return isNaN(r.x)||isNaN(r.y)?null:r}const dd=new w.Box3,ud=new w.Vector3;function pd(t,e="top",n={},i=new w.Vector3){const r=t._realObject;return r?.object3d?(r.object3d.updateWorldMatrix(!0,!0),"center"===e?i.setFromMatrixPosition(r.object3d.matrixWorld):(dd.setFromObject(r.object3d),dd.isEmpty()?i.setFromMatrixPosition(r.object3d.matrixWorld):(dd.getCenter(ud),"bottom"===e?i.set(ud.x,dd.min.y,ud.z):i.set(ud.x,dd.max.y,ud.z))),i.x+=n.x??0,i.y+=n.y??0,i.z+=n.z??0,Number.isFinite(i.x)&&Number.isFinite(i.y)&&Number.isFinite(i.z)?i:null):null}function fd(t){const e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("style","position:absolute; left:0; top:0; width:100%; height:100%; pointer-events:none; overflow:visible; opacity:0; transition: opacity 200ms ease;"),e.dataset.role="tether";const n=document.createElementNS("http://www.w3.org/2000/svg","circle");n.setAttribute("r","8"),n.setAttribute("opacity","0"),e.appendChild(n);const i=document.createElementNS("http://www.w3.org/2000/svg","path");i.setAttribute("fill","none"),i.setAttribute("stroke-width","2"),i.setAttribute("stroke-linecap","round"),e.appendChild(i);const r=document.createElementNS("http://www.w3.org/2000/svg","circle");return r.setAttribute("r","3.5"),r.setAttribute("opacity","0"),e.appendChild(r),t.appendChild(e),{svg:e,path:i,halo:n,dot:r}}function gd(t,e,n,i,r,s,o,a,c,l,h){const{svg:d,path:u,halo:p,dot:f}=t;d.setAttribute("width",String(l)),d.setAttribute("height",String(h)),d.setAttribute("viewBox",`0 0 ${l} ${h}`);const g=function(t,e,n,i,r,s){const o=n+r/2,a=i+s/2,c=t-o,l=e-a;if(Math.abs(c)*s>Math.abs(l)*r)return{x:c>0?n+r:n,y:a};return{x:o,y:l>0?i+s:i}}(e,n,i,r,s,o),m=g.x-e,y=g.y-n,b=(e+g.x)/2,_=(n+g.y)/2,v=Math.sqrt(m*m+y*y),x=v>0?-y/v:0,w=v>0?m/v:0,M=Math.min(18,.12*v),S=b+x*M,A=_+w*M;u.setAttribute("d",`M ${e} ${n} Q ${S} ${A} ${g.x} ${g.y}`),u.setAttribute("stroke",a),u.setAttribute("opacity",String(c)),p.setAttribute("cx",String(e)),p.setAttribute("cy",String(n)),p.setAttribute("fill",a),p.setAttribute("opacity",String(.25*c)),f.setAttribute("cx",String(e)),f.setAttribute("cy",String(n)),f.setAttribute("fill",a),f.setAttribute("opacity",String(c))}function md(t){t.path.setAttribute("d",""),t.halo.setAttribute("opacity","0"),t.dot.setAttribute("opacity","0")}function yd(t){t.svg.parentNode?.removeChild(t.svg)}const bd=["run","goto","goto-playlist","link-open","link-move","route-page","start-scenario","run-scenario","export-data","import-data"];function _d(t,e){const n=document.createElement("button");return n.className=t,n.textContent=e,n}function vd(t){const{component:e,anchor:n,anchorPin:i,anchorOffset:r,popupRoot:s,popupSize:o,constantSize:a,billboard:c,tetherEnabled:h,offScreen:d,signal:u,popupEntry:p}=t,f=e.rootModel??e.root;if(!f?.on)return;if(!a)return void function(t){const{component:e,anchor:n,anchorPin:i,anchorOffset:r,popupRoot:s,billboard:o,tetherEnabled:a,signal:c,popupEntry:h}=t,d=e.rootModel??e.root,u=d?._threeCapability,p=u?.rendererManager?.css3DScene;if(!p)return void Fi("perspective popup requires 3D mode active (css3DScene unavailable)");s.style.position="absolute";const f=o?new l.CSS3DSprite(s):new l.CSS3DObject(s);p.add(f),s.dataset.perspectiveCss3d="true";const g=()=>Md.hide(e);n.on?.("removed",g);const m=d.target??null;let y;a&&m&&(y=fd(m),h&&(h.tether=y));const b=()=>{const t=pd(n,i,r);if(t){if(f.position.set(t.x,t.y,t.z),y&&m){const t=hd(n,0,0),e=m.getBoundingClientRect(),i=s.getBoundingClientRect();if(t&&e.width>0&&e.height>0&&i.width>0){const n=i.left-e.left,r=i.top-e.top,s=o;gd(y,t.x,t.y,s?n:n+i.width/2,s?r:r+i.height/2,s?i.width:0,s?i.height:0,"rgba(80, 120, 200, 0.7)",1,e.width,e.height)}}}else y&&md(y)},_=()=>b();d.on("redraw",_),b(),d.invalidate?.(),c.addEventListener("abort",()=>{d.off?.("redraw",_),n.off?.("removed",g),p.remove(f),s.parentNode&&s.parentNode.removeChild(s),y&&yd(y)})}({component:e,anchor:n,anchorPin:i,anchorOffset:r,popupRoot:s,billboard:c,tetherEnabled:h,signal:u,popupEntry:p});Object.assign(s.style,{position:"absolute",pointerEvents:"auto"});const g=s.parentElement;let m;h&&g&&(m=fd(g),p&&(p.tether=m));const y=()=>Md.hide(e);n.on?.("removed",y);const b=()=>{if(!pd(n,i,r))return void("hide"===d&&(s.style.opacity="0",m&&md(m)));const t=hd(n,0,0);if(!t||!Number.isFinite(t.x)||!Number.isFinite(t.y))return void("hide"===d&&(s.style.opacity="0",m&&md(m)));const e=g?.getBoundingClientRect(),a=e?.width??0,c=e?.height??0,l=t.x<0||t.x>a||t.y<0||t.y>c;if(l&&"hide"===d)return s.style.opacity="0",void(m&&md(m));if(l&&"keep-last"===d)return;let{x:h,y:u}=t;l&&"edge-pin"===d&&(h=Math.max(0,Math.min(a,h)),u=Math.max(0,Math.min(c,u)));const p=h+24,f=u-24-o.height,y=Math.max(8,Math.min(p,a-o.width-8)),b=Math.max(8,Math.min(f,c-o.height-8));s.style.opacity="1",s.style.left=`${y}px`,s.style.top=`${b}px`,m&&gd(m,h,u,y,b,o.width,o.height,"rgba(80, 120, 200, 0.7)",1,a,c)},_=()=>b();f.on("redraw",_),b(),f.invalidate?.(),u.addEventListener("abort",()=>{f.off?.("redraw",_),n.off?.("removed",y),m&&yd(m)})}const xd=new WeakMap;function wd(t){const e=t.root,n=xd.get(e);if(!n)return;if(e===t)return n.forEach(t=>wd(t[0])),void xd.delete(e);const i=n.findIndex(e=>e[0]===t);if(-1===i)return;const r=n[i][1];cancelAnimationFrame(r.rafId),r.ac.abort(),r.div.parentNode?.removeChild(r.div),r.scene.target=null,r.scene.release?.(),n.splice(i,1)}class Md{static hideAll(t){(xd.get(t)||[]).forEach(([t])=>wd(t))}static hide(t){const e=t.root,n=xd.get(e);if(!n)return;const i=n.findIndex(e=>e[0]===t);if(-1===i)return;const r=n[i][1],s=()=>{r.div.style.backgroundColor="transparent",r.rafId=function(t,e,n){const i="true"===t.dataset.perspectiveCss3d;t.style.opacity="1";const r=(t.style.transform||"").replace(/scale\([^)]+\)/,"").trim();i||(t.style.transform=`${r} scale(1)`);let s=0;const o=Date.now(),a=()=>{if(n?.aborted)return;const c=Math.min((Date.now()-o)/200,1);t.style.opacity=String(1-c),i||(t.style.transform=`${r} scale(${1-c})`.trim()),c<1?s=requestAnimationFrame(a):(t.style.display="none",e&&e())};return s=requestAnimationFrame(a),s}(r.div,()=>{wd(t)},r.ac.signal)};r.tether?(r.tether.svg.style.opacity="0",setTimeout(s,200)):s()}static show(t,e,n={}){const{data:i,modal:r=!1,closable:s=!0,minimizable:o=!1,draggable:a=!1,output:c=!0,popupPosition:l="static",origin:h="center-middle",title:d="",threed:u=!1,anchor:p,anchorPin:f="top",anchorOffsetX:g=0,anchorOffsetY:m=0,anchorOffsetZ:y=0,constantSize:b=!0,billboard:_=!0,tether:v=!1,offScreen:x="hide"}=n,w=t.app?.refProvider,M=!!p&&!r&&!a,S=!!t.rootModel?.is3dMode,A=M||S?"absolute":l,E=!A||"static"===A;let k;n.containerRef?k=function(t,e){const n=t.rootModel,i=n?.findById?.(e);if(!i)return Fi(`PopupContainer not found: ${e}`),Promise.reject(new Error(`PopupContainer not found: ${e}`));const r=Yn(i.hierarchy);delete r.id,r.position="static",r.left=0,r.top=0;const{width:s=320,height:o=200}=i.bounds||{},a={width:s,height:o,components:[r]},c=t.app;return Promise.resolve(od({model:a,mode:0,refProvider:c?.refProvider,dataSubscriptionProvider:c?.dataSubscriptionProvider,dataStorage:c?.dataStorage,baseUrl:c?.baseUrl,fitMode:"both"}))}(t,n.containerRef):n.htmlTemplate?k=function(t){const e={width:320,height:200};let n=null;const i={root:{model:e,bounds:e},data:void 0,fit(){},on(){},off(){},release(){}};return Object.defineProperty(i,"target",{get:()=>n,set:e=>{n=e,e&&(e.innerHTML=t)},configurable:!0}),Promise.resolve(i)}(n.htmlTemplate):e&&(k=w?.create?w.create(e):w?.get(e,!0)),k?.then(e=>{const n=document.createElement("div");n.setAttribute("popup",""),"absolute"==A&&(n.style.zIndex="100");const w=n.style;if(r){const{width:e,height:n}=E?t.rootModel.bounds:t.rootModel.auxOverlay.getBoundingClientRect();Object.assign(w,{position:"absolute",zIndex:"100",left:0,top:0,width:E?`${e}px`:"100%",height:E?`${n}px`:"100%",overflow:"hidden",backgroundColor:"transparent"})}else Object.assign(w,{position:"absolute",display:"inline-block"});n.appendChild(function(t){const e=document.createDocumentFragment(),n=document.createElement("div");n.className="popup-wrap";const i=document.createElement("div");if(i.className="popup-translate",t){const t=document.createElement("div");t.className="popup-title-bar";const e=document.createElement("div");e.className="popup-title",t.appendChild(e);const n=document.createElement("div");n.className="popup-buttons-wrap",n.appendChild(_d("closable","close")),n.appendChild(_d("minimizable","minimize")),n.appendChild(_d("draggable","drag_pan")),t.appendChild(n),i.appendChild(t)}else{const t=document.createElement("div");t.className="popup-buttons-wrap float-right",t.appendChild(_d("closable","close")),t.appendChild(_d("minimizable","minimize")),t.appendChild(_d("draggable","drag_pan")),i.appendChild(t)}const r=document.createElement("div");return r.className="popup-content",i.appendChild(r),n.appendChild(i),e.appendChild(n),e}(!!d));const S=n.querySelector(".popup-content"),{width:k,height:C}=e.root.model;Object.assign(S.style,{width:`${k}px`,height:`${C}px`});const T=document.createElement("style");T.appendChild(document.createTextNode("\n\n.popup-wrap .popup-translate {\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n min-width: 120px;\n overflow: hidden;\n transition: height 0.5s ease;\n}\n\n.popup-wrap .popup-translate > * {\n pointer-events: auto;\n}\n\n.popup-wrap .popup-content {\n /* 배경을 강제하지 않는다 — 로딩된 보드의 자체 배경/투명도가 그대로 보이도록.\n * 보드가 transparent 일 때 popup 안의 round corner / 그림자 효과가 망가지지 않게.\n * 흰 배경이 필요하면 보드 root 의 fillStyle 로 설정하거나 (또는 popup-content\n * CSS 변수를 외부에서 override). */\n background-color: transparent;\n}\n\n.popup-wrap .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-wrap .popup-title {\n flex: 1;\n text-align: center;\n}\n\n.popup-wrap .popup-buttons-wrap {\n position: relative;\n display: flex;\n flex-direction: row-reverse;\n gap: 4px;\n min-width: 100px;\n align-items: center;\n justify-items: center;\n margin: 0;\n padding: 0;\n}\n\n.popup-wrap .popup-buttons-wrap.float-right {\n position: absolute;\n right: 0;\n top: 0;\n height: 30px;\n margin-right: 5px;\n}\n\n.popup-wrap button.closable, \n.popup-wrap button.minimizable, \n.popup-wrap button.draggable {\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: 16px;\n}\n\n.popup-wrap button.draggable {\n cursor: move;\n}\n\n.popup-wrap button.closable:hover, \n.popup-wrap button.minimizable:hover, \n.popup-wrap button.draggable:hover {\n opacity: .6; \n}\n")),n.appendChild(T);const P=new AbortController,D=P.signal;bd.forEach(n=>{const i=(...e)=>t.trigger(n,...e);e.on(n,i),D.addEventListener("abort",()=>e.off?.(n,i))});const O=n.querySelector(".draggable");[...Sr,...Ar].forEach(t=>{S.addEventListener(t,t=>t.stopPropagation(),{signal:D})}),[...Sr,...Ar].forEach(t=>{n.addEventListener(t,t=>t.stopPropagation(),{signal:D})}),r&&s&&n.addEventListener("click",e=>{e.target===n&&Md.hide(t)},{signal:D});const z=t.rootModel.getOverlay?.({...t,scalable:!A||"static"==A});z?.appendChild(n),function(t,e,n,i,r){const s=t.root;if(s===t)return;wd(t);let o=xd.get(s)||[];o=[...o,[t,{div:e,scene:n,ac:i,rafId:r}]],xd.set(s,o)}(t,n,e,P,0);const L=xd.get(t.root)?.find(e=>e[0]===t)?.[1];if(d){const t=n.querySelector(".popup-title-bar .popup-title");t&&(t.textContent=d)}const I=n.querySelector(".popup-translate");if(a&&(ld(I,d?n.querySelector(".popup-title-bar"):n.querySelector(".draggable"),function(t,e){if(!(e=e||t.position)||"static"===e){const e=(t.rootModel.getOverlay(t).style.transform||"").match(/scale\(([^,\s)]+)(?:,\s*([^)]+))?\)/),n=e?parseFloat(e[1]):1;return{sx:n,sy:e&&e[2]?parseFloat(e[2]):n}}return{sx:1,sy:1}}(t,l),{signal:D}),d?O&&(O.style.display="block"):(I?.addEventListener("mouseenter",()=>{O&&(O.style.display="block")},{signal:D}),I?.addEventListener("mouseleave",()=>{O&&(O.style.display="none")},{signal:D}))),o){const t=n.querySelector(".minimizable");let e=!1;t.addEventListener("click",t=>{t.preventDefault(),e=!e;const i=n.querySelector(".popup-wrap");!function(t,e,n){const i=e.querySelector(".minimizable"),r=e.querySelector(".popup-translate");r&&(n?(i.textContent="crop_square",r.style.height="30px"):(i.textContent="minimize",r.style.height="100%"))}(0,r?i:n,e)},{signal:D}),d?t&&(t.style.display="block"):(I?.addEventListener("mouseenter",()=>{t&&(t.style.display="block")},{signal:D}),I?.addEventListener("mouseleave",()=>{t&&(t.style.display="none")},{signal:D}))}if(s){const t=n.querySelector(".closable");d?t&&(t.style.display="block"):(I?.addEventListener("mouseenter",()=>{t&&(t.style.display="block")},{signal:D}),I?.addEventListener("mouseleave",()=>{t&&(t.style.display="none")},{signal:D}))}n.querySelector(".closable")?.addEventListener("click",e=>{e.preventDefault(),Md.hide(t)},{signal:D}),n.addEventListener("close-scene",e=>{e.preventDefault(),e.stopPropagation(),Md.hide(t),c&&(t.data=e.detail)},{signal:D}),e.target=S,e.data=i||t.data,e.fit("both"),u&&(e.root.threed=!0);const{x:R,y:j}=t.center,F=t.toScene(R,j),B=r?n.querySelector(".popup-wrap"):n;M?vd({component:t,anchor:p,anchorPin:f,anchorOffset:{x:g,y:m,z:y},popupRoot:n,popupSize:{width:k,height:d?C+30:C},constantSize:b,billboard:_,tetherEnabled:v,offScreen:x,signal:D,popupEntry:L}):cd(B,A,h,F,e.root.bounds,{width:k,height:C},{title:d}),r?Object.assign(B.style,{position:"absolute",pointerEvents:"none",width:`${k}px`,height:`${d?C+30:C}px`}):Object.assign(B.style,{pointerEvents:"none",width:`${k}px`,height:`${d?C+30:C}px`});const N=function(t,e,n){const i="true"===t.dataset.perspectiveCss3d;t.style.opacity="0";const r=(t.style.transform||"").replace(/scale\([^)]+\)/,"").trim();i||(t.style.transform=`${r} scale(0)`),t.style.display="block";let s=0;const o=Date.now(),a=()=>{if(n?.aborted)return;const c=Math.min((Date.now()-o)/200,1);t.style.opacity=String(c),i||(t.style.transform=`${r} scale(${c})`.trim()),c<1?s=requestAnimationFrame(a):e&&e()};return s=requestAnimationFrame(a),s}(n,()=>{r&&(n.style.backgroundColor="rgba(0,0,0,0.3)"),L?.tether&&(L.tether.svg.style.opacity="1")},D);L&&(L.rafId=N)},t=>{Fi("cannot fetch board: "+e,t)})}}class Sd extends Zc{constructor(t,e){super(t,e),this._element=null,this._firstDrawReported=!1,t.translate=t.translate||{x:0,y:0},this._draw_reserved=!1,this.__draw__=()=>{this._draw_reserved=!1;const t=performance.now();this.trigger("redraw"),this.reflow(),this.draw();const e=performance.now()-t;Mi.drawCount++,Mi.drawTimeSum+=e,Mi.drawTimeLast=e,Mi.countFrame(),this._firstDrawReported||(this._firstDrawReported=!0,this.app?.loadTracker?.markFirstRender())},this.throttle_render=()=>{this._draw_reserved||requestAnimationFrame(this.__draw__),this._draw_reserved=!0}}get element(){return this._element}set element(t){this._element=t}fitSize(t,e,n,i){if(this.target){if(e){const t=getComputedStyle(this.target);n=n||(t?parseFloat(t.getPropertyValue("width")):this.target.clientWidth),i=i||(t?parseFloat(t.getPropertyValue("height")):this.target.clientHeight)}else n=this.model.width,i=this.model.height;"CANVAS"==t.tagName&&(t.setAttribute("width",n*Mr),t.setAttribute("height",i*Mr)),t.style.width=n+"px",t.style.height=i+"px"}}resize(){this.fitSize(this.element,!0)}isLayer(){return!0}get showOverflow(){return this.app.isEditMode}get anchors(){}createElement(){const t=Va.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,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}get context2D(){if(!this._context2D&&(this._context2D=this.canvas&&this.canvas.getContext("2d"),this._context2D)){const t=getComputedStyle(document.documentElement),e=t.getPropertyValue("--scene-theme-font-family")?.trim()||t.fontFamily||"sans-serif";this._context2D.font=["10px",e].join(" "),this._context2D.save()}return this._context2D}getContext(t){return this._context2D||this.context2D}draw(t){this.canvas&&(t=t||this.getContext(void 0))&&(t.save(),super.draw(t),t.restore())}prerender(t){const{translate:e,scale:n={x:1,y:1},rotation:i}=this.model;t.clearRect(0,0,t.canvas.width,t.canvas.height),e&&t.translate(e.x*Mr,e.y*Mr),t.scale(n.x*Mr,n.y*Mr),i&&t.rotate(i)}get rotatePoint(){return{x:0,y:0}}contains(t,e){return!1}invalidate(){Mi.invalidateCount++,this.throttle_render()}move(t){const 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 n=t.rootModel.toLocal(this.canvas.clientWidth/2,this.canvas.clientHeight/2),{x:i,y:r}=t.center,{x:s,y:o}=t.fromParent(i,r),{x:a,y:c}=t.toScene(s,o),{x:l,y:h}=t.rootModel.get("translate"),{x:d,y:u}=t.rootModel.get("scale");e?No({step:function(e){t.rootModel.set({translate:{x:l+(n.x-a)*d*e,y:h+(n.y-c)*u*e}})},duration:1e3,delta:"circ"}).start():t.rootModel.set({translate:{x:l+(n.x-a)*d,y:h+(n.y-c)*u}})}}class Ad extends Sd{dispose(){super.dispose(),delete this._canvas,delete this._auxCanvas}createElement(){const t=document.createElement("div");return t.style.position="absolute",t.setAttribute("scene",`${this.state.type}-anchor`),t.style["user-select"]="none",t.style.overflow="hidden",this._canvas=Va.createCanvas(1,1),this._canvas.style.position="absolute",this._canvas.style.pointerEvents="none",this._canvas.setAttribute("scene",`${this.state.type}-canvas`),t.appendChild(this._canvas),this._auxCanvas=Va.createCanvas(1,1),this._auxCanvas.style.position="absolute",this._auxCanvas.style.pointerEvents="none",this._auxCanvas.style.zIndex="100",this._auxCanvas.setAttribute("scene",`${this.state.type}-aux-canvas`),t.appendChild(this._auxCanvas),t}resize(){if(!this.element)return;this.fitSize(this.element,!0);const t=this.element.clientWidth,e=this.element.clientHeight;this.fitSize(this.canvas,!0,t,e),this.fitSize(this.auxCanvas,!0,t,e)}get canvas(){return this._canvas}get auxCanvas(){return this._auxCanvas}get context2D(){if(!this._context2D){this._context2D=this.canvas&&this.canvas.getContext("2d");const t=getComputedStyle(document.documentElement),e=t.getPropertyValue("--scene-theme-font-family")?.trim()||t.fontFamily||"sans-serif";this._context2D.font=["10px",e].join(" "),this._context2D.save()}return this._context2D}get auxContext2D(){if(!this._auxContext2D){this._auxContext2D=this.auxCanvas&&this.auxCanvas.getContext("2d");const t=getComputedStyle(document.documentElement),e=t.getPropertyValue("--scene-theme-font-family")?.trim()||t.fontFamily||"sans-serif";this._auxContext2D.font=["10px",e].join(" "),this._auxContext2D.save()}return this._auxContext2D}getContext(t){return t?t.scalable?this.context2D:this.auxContext2D:this.context2D}draw(t){this.canvas&&this.element&&(t=t||this.getContext(void 0))&&(this.auxContext2D.clearRect(0,0,this.auxCanvas.width,this.auxCanvas.height),this.auxContext2D.save(),this.auxContext2D.scale(Mr,Mr),super.draw(t),this.auxContext2D.restore())}}var Ed,kd,Cd,Td;!function(t){t.CANVAS="canvas",t.DOM="dom"}(Ed||(Ed={}));class Pd{get overlay(){return this._overlay}constructor(t,e,n={}){if(this.element=null,this.isActive=!1,this._overlay=null,this.target=e,this.options={animation:!0,repeat:!0,duration:3e3,color:"#ff0000",opacity:1,fadeOut:!1,...n},this.mode=n.mode||this.determineOptimalMode(),t){this._overlay=t;xs.getInstance().addOverlay(t)}}determineOptimalMode(){return!1!==this.options.animation?Ed.DOM:Ed.CANVAS}start(){if(!this.isActive&&(this.isActive=!0,this.mode===Ed.DOM)){this.overlay?(this.createDOMElements(),this.target.on("change",this.handleTargetChange,this),this.target.on("removed",this.handleTargetRemoved,this)):(Bi("오버레이가 설정되지 않아 DOM 모드 데코레이터를 시작할 수 없습니다."),this.isActive=!1)}}stop(){this.isActive&&(this.isActive=!1,this.mode===Ed.DOM&&(this.target.off("change",this.handleTargetChange,this),this.target.off("removed",this.handleTargetRemoved,this),this.removeDOMElements()))}update(t){if(t&&(this.options={...this.options,...t},t.mode&&t.mode!==this.mode))return this.stop(),this.mode=t.mode,void this.start();this.mode===Ed.DOM&&this.isActive&&this.updateDOMElements()}render(t,e){return!(this.mode!==Ed.CANVAS||!this.isActive)&&this.renderCanvas(t,e)}removeDOMElements(){this.element&&this.element.parentNode&&(this.element.parentNode.removeChild(this.element),this.element=null)}updateDOMElements(){this.removeDOMElements(),this.createDOMElements()}getComponentPosition(){const{left:t,top:e,width:n,height:i}=this.target.bounds;if("function"==typeof this.target.toGlobal)try{const{x:r,y:s}=this.target.toGlobal(t,e,this.target.rootModel);return{x:r,y:s,width:n,height:i}}catch(t){Bi("좌표 변환 실패, 기본값 사용:",t)}return{x:t,y:e,width:n,height:i}}handleTargetChange(t,e){this.target.disposed?this.stop():this.invalidate()}handleTargetRemoved(){this.stop()}invalidate(){}}class Dd extends Pd{constructor(t,e,n={}){super(t,e,{strokeWidth:2,strokeColor:"#FF0000",strokeOpacity:1,fillColor:"none",fillOpacity:.5,scale:1,rotation:0,x:0,y:0,zIndex:0,mode:Ed.DOM,...n}),this.vectorElement=null,this.animationElements=[],this.svgContainer=null,this.animationElement=null}getDecoratorType(){return this.constructor.DECORATOR_TYPE}dispose(){this.removeDOMElements()}determineOptimalMode(){return Ed.DOM}renderCanvas(t,e){return Bi("VectorDecorator는 Canvas 렌더링을 지원하지 않습니다. DOM 모드를 사용하세요."),!1}getSvgContainer(){if(!this.overlay)throw new Error("오버레이 요소가 없습니다.");if(!Dd.svgContainerCache.has(this.overlay)){const t=document.createElementNS("http://www.w3.org/2000/svg","svg");t.setAttribute("class","vector-decorator-container"),t.setAttribute("pointer-events","none"),t.style.overflow="visible",t.style.position="absolute",t.style.top="0",t.style.left="0",this.overlay.appendChild(t),Dd.svgContainerCache.set(this.overlay,t)}return Dd.svgContainerCache.get(this.overlay)}getOrCreateDecoratorGroup(t=!1){const e=this.getSvgContainer(),n=this.getVectorGroupId(),i=this.getDecoratorType();let r=e.querySelector(`g[data-decorator-type-container="${i}"]`);if(!r){r=document.createElementNS("http://www.w3.org/2000/svg","g"),r.setAttribute("data-decorator-type-container",i),r.setAttribute("class",`${i}-container`),e.appendChild(r);const t=document.createElementNS("http://www.w3.org/2000/svg","defs");t.setAttribute("data-defs-for",i),r.appendChild(t)}let s=r.querySelector(`g[data-decorator-group-id="${n}"]`);if(!s){const{id:t}=this.target.state;return s=document.createElementNS("http://www.w3.org/2000/svg","g"),s.setAttribute("data-decorator-group-id",n),s.setAttribute("data-decorator-type",i),t&&s.setAttribute("data-component-id",t),r.appendChild(s),s}if(t)for(;s.firstChild;)s.removeChild(s.firstChild);return s}getDefsForType(){const t=this.getSvgContainer(),e=this.getDecoratorType();let n=t.querySelector(`g[data-decorator-type-container="${e}"]`);n||(this.getOrCreateDecoratorGroup(),n=t.querySelector(`g[data-decorator-type-container="${e}"]`));let i=n.querySelector(`defs[data-defs-for="${e}"]`);return i||(i=document.createElementNS("http://www.w3.org/2000/svg","defs"),i.setAttribute("data-defs-for",e),n.appendChild(i)),i}getDecoratorGroup(){const t=this.getSvgContainer(),e=this.getVectorGroupId(),n=t.querySelector(`g[data-decorator-group-id="${e}"]`);if(n)return n}createFadeAnimation(t=0,e=1,n=1e3,i={}){const r=document.createElementNS("http://www.w3.org/2000/svg","animate");return r.setAttribute("attributeName","opacity"),r.setAttribute("from",t.toString()),r.setAttribute("to",e.toString()),r.setAttribute("dur",`${n}ms`),i.delay&&r.setAttribute("begin",`${i.delay}ms`),r.setAttribute("fill","freeze"),i.repeat?r.setAttribute("repeatCount","indefinite"):r.setAttribute("repeatCount","1"),r}createTranslateAnimation(t,e=[],n=1e3,i={}){const r=document.createElementNS("http://www.w3.org/2000/svg","animateTransform");return r.setAttribute("attributeName","transform"),r.setAttribute("type","translate"),r.setAttribute("values",t.join(";")),e.length>0&&r.setAttribute("keyTimes",e.join(";")),r.setAttribute("dur",`${n}ms`),i.delay&&r.setAttribute("begin",`${i.delay}ms`),i.repeat?r.setAttribute("repeatCount","indefinite"):r.setAttribute("repeatCount","1"),r}createRotateAnimation(t=0,e=360,n=0,i=0,r=1e3,s={}){const o=document.createElementNS("http://www.w3.org/2000/svg","animateTransform");return o.setAttribute("attributeName","transform"),o.setAttribute("type","rotate"),o.setAttribute("from",`${t} ${n} ${i}`),o.setAttribute("to",`${e} ${n} ${i}`),o.setAttribute("dur",`${r}ms`),s.delay&&o.setAttribute("begin",`${s.delay}ms`),s.repeat?o.setAttribute("repeatCount","indefinite"):o.setAttribute("repeatCount","1"),o}addAnimations(t,e){e.forEach(e=>{t.appendChild(e),this.animationElements.push(e)})}projectComponentPoint(t,e,n){return hd(t,e,n)}updatePosition(){if(!this.vectorElement)return;const t=this.options,{left:e,top:n}=this.target.bounds,i=this.projectComponentPoint(this.target,e,n);if(!i)return;const r=i.x+(t.x??0),s=i.y+(t.y??0);this.vectorElement.setAttribute("transform",`translate(${r}, ${s})`)}updateDOMElements(){this.createDOMElements()}getVectorGroupId(){const t=this.getDecoratorType(),{refid:e="unknown"}=this.target.state;return`decorator-${t}-${e}`}removeVectorElements(){if(this.overlay)try{const t=Dd.svgContainerCache.get(this.overlay);if(!t)return;const e=this.getVectorGroupId(),n=this.getDecoratorType(),i=t.querySelector(`g[data-decorator-type-container="${n}"]`);if(i){const t=i.querySelector(`g[data-decorator-group-id="${e}"]`);if(t&&(this.vectorElement&&(this.vectorElement===t||t.contains(this.vectorElement))&&(this.vectorElement=null),this.animationElements=this.animationElements.filter(e=>!t.contains(e)),t.remove()),!i.querySelector("g[data-decorator-group-id]")){const t=i.querySelector(`defs[data-defs-for="${n}"]`);t&&t.remove(),i.remove()}}0===t.children.length&&(t.remove(),Dd.svgContainerCache.delete(this.overlay))}catch(t){Fi("벡터 요소 제거 실패:",t)}}removeDOMElements(){this.removeVectorElements()}delta(t,e){if("string"==typeof t)return"fade"===t?this.applyFadeValue(e):"theta"===t&&this.applyRotationValue(e),{tx:0,ty:0};if("object"==typeof t){const e=t;("tx"in e||"ty"in e)&&this.applyTranslateValues(e.tx||0,e.ty||0),("sx"in e||"sy"in e)&&this.applyScaleValues(e.sx||1,e.sy||1)}return null}invalidate(){this.mode===Ed.DOM&&this.isActive&&this.updateDOMElements()}touch(){}applyFadeValue(t){if(this.vectorElement){const e=t.toFixed(2);this.vectorElement.setAttribute("opacity",e)}}applyRotationValue(t){if(this.vectorElement){const e=this.getComponentBounds(),n=e.width/2,i=e.height/2,r=(180*t/Math.PI).toFixed(1);this.vectorElement.setAttribute("transform",`rotate(${r} ${n} ${i})`)}}applyTranslateValues(t,e){if(this.vectorElement){const n=this.vectorElement.getAttribute("transform")||"";if(n.includes("translate")){const i=n.replace(/translate\([^)]+\)/,`translate(${t}, ${e})`);this.vectorElement.setAttribute("transform",i)}else this.vectorElement.setAttribute("transform",`${n} translate(${t}, ${e})`.trim())}}applyScaleValues(t,e){if(this.vectorElement){const n=this.vectorElement.getAttribute("transform")||"";if(n.includes("scale")){const i=n.replace(/scale\([^)]+\)/,`scale(${t}, ${e})`);this.vectorElement.setAttribute("transform",i)}else this.vectorElement.setAttribute("transform",`${n} scale(${t}, ${e})`.trim())}}getComponentBounds(){return this.target&&this.target.bounds?this.target.bounds:{top:0,left:0,width:100,height:100}}}Dd.svgContainerCache=new WeakMap,Dd.DECORATOR_TYPE="vector";class Od extends Pd{constructor(t,e,n={}){super(t,e,{scale:1,strokeColor:"#000000",strokeWidth:1,rotation:0,shadow:!1,shadowColor:"rgba(0,0,0,0.5)",shadowBlur:5,shadowOffsetX:2,shadowOffsetY:2,...n}),this.animationId=null,this.canvasElement=null,this.context=null,this.animationFrame=null,this.deltaValue=0}determineOptimalMode(){return Ed.CANVAS}createDOMElements(){Bi("RasterDecorator는 DOM 렌더링을 지원하지 않습니다. Canvas 모드를 사용하세요.")}setAnimationState(t=3e3,e=!1){Od.animationStateMap.set(this.target,{startTime:Date.now(),duration:t,repeat:e})}getAnimationState(){const t=Od.animationStateMap.get(this.target);if(!t)return{delta:0,finished:!0};const{startTime:e,duration:n,repeat:i}=t,r=Date.now()-e;let s=Math.min(1,r/n),o=s>=1;return i&&o&&(Od.animationStateMap.set(this.target,{startTime:Date.now(),duration:n,repeat:i}),s=0,o=!1),{delta:s,finished:o}}bounceEffect(t,e=10){const n=Math.min(1,4*t);return Math.sin(n*Math.PI*10)*e*(1-n)}fadeEffect(t,e=!1){return e?t:1-t}pulseEffect(t,e=.8,n=1.2){return e+(.5*Math.sin(t*Math.PI*2)+.5)*(n-e)}rotateEffect(t,e=360){return t*e}applyShadowEffect(t){if(this.options.shadow){const e=this.options;t.shadowColor=e.shadowColor||"rgba(0,0,0,0.5)",t.shadowBlur=e.shadowBlur||5,t.shadowOffsetX=e.shadowOffsetX||2,t.shadowOffsetY=e.shadowOffsetY||2}}removeShadowEffect(t){t.shadowColor="transparent",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0}start(){super.start(),this.isActive&&this.options.animation&&this.setAnimationState(this.options.duration||3e3,this.options.repeat||!1)}stop(){null!==this.animationFrame&&(cancelAnimationFrame(this.animationFrame),this.animationFrame=null),super.stop(),Od.animationStateMap.delete(this.target)}applyTransform(t,e,n){const i=this.options,r=i.scale||1,s=i.rotation||0;if(1!==r||0!==s){if(t.translate(e,n),0!==s){const e=s*Math.PI/180;t.rotate(e)}1!==r&&t.scale(r,r),t.translate(-e,-n)}}delta(t,e){return"string"==typeof t?("fade"===t?(this.deltaValue=e,this.context&&(this.context.globalAlpha=e)):"theta"===t&&(this.deltaValue=e),{tx:0,ty:0}):null}invalidate(){this.context&&this.isActive&&(this.animationFrame||(this.animationFrame=requestAnimationFrame(()=>{this.animationFrame=null,this.renderCanvas(this.context,this.deltaValue)})))}touch(){this.deltaValue=0}}Od.animationStateMap=new WeakMap;class zd extends Dd{constructor(t,e,n={}){super(t,e,{size:1,showId:!1,animation:!1,...n}),this.arrowElement=null,this.labelElement=null,this.decoratorGroup=null}createDOMElements(){if(this.overlay)try{const t=this.getOrCreateDecoratorGroup(!0);this.decoratorGroup=t,t.setAttribute("transform","translate(0, 0)");const{size:e=1,showId:n=!1,duration:i=3e3,repeat:r=!0}=this.options,s=this.options.color||"#FF0000",o=document.createElementNS("http://www.w3.org/2000/svg","path");o.setAttribute("d",this.createArrowPath(0,0,e)),o.setAttribute("fill",s),o.setAttribute("stroke",s),o.setAttribute("stroke-width","1"),o.setAttribute("class","bouncing-arrow");const a=[];if(this.options.animation){const t=this.createBounceAnimation(i,r);if(a.push(t),this.options.fadeOut){const t=this.createFadeAnimation(1,0,i,{repeat:r});a.push(t)}}if(this.addAnimations(o,a),t.appendChild(o),this.arrowElement=o,n&&this.target.state?.id){const n=this.createArrowLabel(0,0,s,this.target.state.id,e);if(this.options.animation){const t=[],e=this.createBounceAnimation(i,r);if(t.push(e),this.options.fadeOut){const e=this.createFadeAnimation(1,0,i,{repeat:r});t.push(e)}this.addAnimations(n,t)}t.appendChild(n),this.labelElement=n}this.vectorElement=t,this.updatePosition(),this.options.animation&&this.startAnimations()}catch(t){Fi("화살표 SVG 요소 생성 실패:",t)}}createArrowPath(t,e,n=1){const i=n/this.getScale();return`\n M${t-10*i},${e-16*i} \n L${t+10*i},${e-16*i} \n L${t+10*i},${e-8*i} \n L${t+16*i},${e-8*i} \n L${t},${e} \n L${t-16*i},${e-8*i} \n L${t-10*i},${e-8*i} \n Z\n `}getScale(){try{if(this.target.rootModel&&"number"==typeof this.target.rootModel.scale)return this.target.rootModel.scale||1}catch(t){Bi("스케일 계산 실패, 기본값 사용",t)}return 1}createBounceAnimation(t,e){const n=["0,-10"],i=["0"];for(let t=1;t<=20;t++){const e=t/20;let r=Math.pow(e,.5).toFixed(3);parseFloat(i[i.length-1])>=parseFloat(r)&&(r=(parseFloat(i[i.length-1])+.01).toFixed(3)),n.push("0,0"),n.push("0,-10"),i.push(r),i.push((parseFloat(r)+.01).toFixed(3))}return i[i.length-1]="1.000",this.createTranslateAnimation(n,i,t,{repeat:e})}createArrowLabel(t,e,n,i,r=1){const s=document.createElementNS("http://www.w3.org/2000/svg","g");s.setAttribute("class","bouncing-arrow-label");const o=document.createElementNS("http://www.w3.org/2000/svg","rect");o.setAttribute("x",`${t+20*r}`),o.setAttribute("y",""+(e-20*r)),o.setAttribute("width",""+40*r),o.setAttribute("height",""+20*r),o.setAttribute("rx","3"),o.setAttribute("fill",n);const a=document.createElementNS("http://www.w3.org/2000/svg","text");return a.setAttribute("x",`${t+40*r}`),a.setAttribute("y",""+(e-6*r)),a.setAttribute("fill","white"),a.setAttribute("font-size",12*r+"px"),a.setAttribute("text-anchor","middle"),a.textContent=i,s.appendChild(o),s.appendChild(a),s}startAnimations(){setTimeout(()=>{this.animationElements.forEach(t=>{try{t instanceof SVGElement&&"beginElement"in t&&t.beginElement()}catch(t){Fi("애니메이션 시작 오류:",t)}})},10)}invalidate(){this.updatePosition()}updatePosition(){if(!this.vectorElement)return;const{left:t,top:e,width:n}=this.target.bounds,i=this.projectComponentPoint(this.target,t+n/2,e);if(!i)return;const r=Math.max(i.x,20),s=Math.max(i.y,20);this.vectorElement.setAttribute("transform",`translate(${r}, ${s})`)}}zd.DECORATOR_TYPE="bouncing-arrow",function(t){t.ROTATE="rotate",t.TRANSLATE_X="translateX",t.TRANSLATE_Y="translateY",t.SCALE="scale",t.FADE="fade"}(kd||(kd={})),function(t){t.VIBRATION="vibration",t.ROTATION="rotation",t.HEARTBEAT="heartbeat",t.MOVING="moving",t.OUTLINE="outline",t.FADE="fade",t.WAYPOINT="waypoint"}(Cd||(Cd={})),function(t){t.CENTER="center",t.TOP="top",t.RIGHT="right",t.BOTTOM="bottom",t.LEFT="left",t.TOP_RIGHT="top-right",t.BOTTOM_RIGHT="bottom-right",t.BOTTOM_LEFT="bottom-left",t.TOP_LEFT="top-left",t.TOP_LEFT_CORNER="top-left-corner",t.TOP_RIGHT_CORNER="top-right-corner",t.BOTTOM_LEFT_CORNER="bottom-left-corner",t.BOTTOM_RIGHT_CORNER="bottom-right-corner",t.LEFT_TOP="left-top",t.LEFT_BOTTOM="left-bottom",t.RIGHT_TOP="right-top",t.RIGHT_BOTTOM="right-bottom"}(Td||(Td={}));class Ld extends Dd{constructor(t,e,n={}){const{animations:i,...r}=n;super(t,e,{icon:"arrow_forward",size:24,color:"#FF0000",deltaX:0,deltaY:0,...r}),this.animations=[],this._location=null,this.element=null,this._delta={theta:0,tx:0,ty:0,sx:1,sy:1,fade:0},this.animations=this.createAnimations(i)}delta(t,e){if(!t)return this._delta;switch(typeof t){case"object":this._delta={...this._delta,...t};break;case"string":if(void 0===e)return this._delta[t];this._delta[t]=e}const{tx:n,ty:i,sx:r,sy:s,theta:o,fade:a}=this._delta;return this.element&&Object.assign(this._getElement().style,{opacity:1-a,transform:`rotate(${o}rad) translate(${n}px, ${i}px) scale(${r}, ${s}) perspective(1px)`}),this._delta}getScaledSize(){const t=this.options.size||24,{x:e}=this.target.rootModel?.state.scale||{x:1},{x:n}=this.target.state.scale||{x:1};return t*e*n}get location(){if(this._location)return this._location;const{location:t,position:e,size:n}=this.options,{bounds:i}=this.target,{left:r,top:s,width:o,height:a}=i,c=n/2;let l;switch(e||t||Td.CENTER){case Td.TOP_LEFT:case"top-left":l={x:r,y:s-n};break;case Td.TOP:case"top":l={x:r+(o-n)/2,y:s-n};break;case Td.TOP_RIGHT:case"top-right":l={x:r+o-n,y:s-n};break;case Td.BOTTOM_LEFT:case"bottom-left":l={x:r,y:s+a};break;case Td.BOTTOM:case"bottom":l={x:r+(o-n)/2,y:s+a};break;case Td.BOTTOM_RIGHT:case"bottom-right":l={x:r+o-n,y:s+a};break;case Td.LEFT_TOP:case"left-top":l={x:r-n,y:s};break;case Td.LEFT:case"left":l={x:r-n,y:s+(a-n)/2};break;case Td.LEFT_BOTTOM:case"left-bottom":l={x:r-n,y:s+(a-n)};break;case Td.RIGHT_TOP:case"right-top":l={x:r+o,y:s};break;case Td.RIGHT:case"right":l={x:r+o,y:s+(a-n)/2};break;case Td.RIGHT_BOTTOM:case"right-bottom":l={x:r+o,y:s+(a-n)};break;case Td.TOP_LEFT_CORNER:case"top-left-corner":l={x:r-c,y:s-c};break;case Td.TOP_RIGHT_CORNER:case"top-right-corner":l={x:r+o-c,y:s-c};break;case Td.BOTTOM_LEFT_CORNER:case"bottom-left-corner":l={x:r-c,y:s+a-c};break;case Td.BOTTOM_RIGHT_CORNER:case"bottom-right-corner":l={x:r+o-c,y:s+a-c};break;case Td.CENTER:default:l={x:r+o/2-n/2,y:s+a/2-n/2}}return this._location=this.toGlobal(l.x,l.y),this._location}_getElement(){return this.element||this._createElementIfNeeded(),this.element}_createElementIfNeeded(){if(this.element)return;const{icon:t="arrow_forward",color:e="#FF0000"}=this.options,n=this.getScaledSize(),{x:i,y:r}=this.location,s=document.createElement("div");s.setAttribute("scene","animated-icon"),Object.assign(s.style,{position:"absolute",fontVariationSettings:"'FILL' 1",fontFamily:"Material Symbols Outlined",fontSize:n+"px",width:n+"px",height:n+"px",lineHeight:n+"px",padding:0,margin:0,color:e,textAlign:"center",verticalAlign:"middle",left:i+"px",top:r+"px",pointerEvents:"none"}),s.textContent=t,this.element=s}updateIconSizeAndPosition(){if(!this.element)return;this._location=null;const t=this.getScaledSize(),{x:e,y:n}=this.location;Object.assign(this.element.style,{fontSize:t+"px",width:t+"px",height:t+"px",lineHeight:t+"px",left:e+"px",top:n+"px"})}touch(){}invalidate(){this.updateIconSizeAndPosition()}start(){if(super.start(),this.isActive){if(this.overlay&&this._getElement().parentNode!==this.overlay&&this.overlay.appendChild(this._getElement()),this.target?.root?.app?.suppressAnimations)return;this.animations.forEach(t=>t.start())}}stop(){this.animations.forEach(t=>t.stop()),this.element&&this._getElement().parentNode&&this._getElement().parentNode.removeChild(this._getElement()),this._location=null,super.stop()}get center(){const t=this.getScaledSize(),{x:e,y:n}=this.location;return{x:e+t/2,y:n+t/2}}toGlobal(t,e){const{tx:n,ty:i}=this._delta;return this.projectComponentPoint(this.target,t+n,e+i)??this.target.toGlobal(t+n,e+i)}get root(){return this.target.root}createDOMElements(){this._getElement()}updateDOMElements(){this.element?this.updateIconSizeAndPosition():this._getElement()}updatePosition(){this.updateIconSizeAndPosition()}createAnimations(t){if(Array.isArray(t))return t.map(t=>("theta"in t&&(t={...t,theta:t.theta*(Math.PI/180)}),Go(this,t)));if(t){const e={...t};return"theta"in e&&(e.theta=e.theta*(Math.PI/180)),[Go(this,e)]}return[]}}Ld.DECORATOR_TYPE="animated-icon";class Id extends Dd{constructor(t,e,n={}){super(t,e,{distance:10,lineWidth:2,fillStyle:"rgba(0, 0, 0, 0.5)",animation:!1,...n}),this.pathElement=null,this.decoratorGroup=null,this.elementId=""}createDOMElements(){if(this.overlay)try{this.getSvgContainer();const t=this.getOrCreateDecoratorGroup(!0);this.decoratorGroup=t;const e=this.getDefsForType(),n=this.getVectorGroupId();this.elementId=`${n}-border`;const{color:i="#FF0000",animation:r=!1}=this.options,{fillStyle:s}=this.target.state||{},o=this.createFilter(this.elementId,this.options.fillStyle||s||"rgba(0, 0, 0, 0.5)");if(e.appendChild(o),r){const t=this.createGradient(this.elementId,i);e.appendChild(t)}const a=document.createElementNS("http://www.w3.org/2000/svg","path");a.setAttribute("fill","none"),a.setAttribute("stroke-width",(this.options.lineWidth||2).toString()),a.setAttribute("stroke-linejoin","round"),a.setAttribute("pointer-events","none"),a.setAttribute("class","border-highlighting-path"),a.setAttribute("filter",`url(#${this.elementId}-filter)`),r?a.setAttribute("stroke",`url(#${this.elementId})`):a.setAttribute("stroke",i),t.appendChild(a),this.pathElement=a,this.vectorElement=t,this.updatePathData(),this.options.animation&&this.startAnimations()}catch(t){Fi("테두리 하이라이팅 요소 생성 실패:",t)}}updatePathData(){if(!this.pathElement)return;this.pathElement.setAttribute("visibility","visible"),this.pathElement.setAttribute("opacity","1"),this.decoratorGroup&&(this.decoratorGroup.setAttribute("visibility","visible"),this.decoratorGroup.setAttribute("opacity","1"));const t=this.getPathPoints(),e=this.createOffsetPath(t,this.options.distance),{round:n=0}=this.target.state||{},i=this.pointsToPathData(e,n);this.pathElement.setAttribute("d",i)}invalidate(){this.updatePathData()}startAnimations(){if(!this.isActive||!this.options.animation||!this.pathElement)return;this.pathElement.setAttribute("visibility","visible"),this.pathElement.setAttribute("opacity","1"),this.decoratorGroup&&(this.decoratorGroup.setAttribute("visibility","visible"),this.decoratorGroup.setAttribute("opacity","1")),this.elementId&&(this.pathElement.setAttribute("stroke",`url(#${this.elementId})`),this.pathElement.setAttribute("filter",`url(#${this.elementId}-filter)`));const t=this.getDefsForType();if(t){const e=t.querySelector(`#${this.elementId}`);if(e){e.querySelectorAll("animate").forEach(t=>{try{t instanceof SVGElement&&"beginElement"in t&&(t.setAttribute("restart","always"),t.beginElement())}catch(t){Fi("애니메이션 시작 오류:",t)}})}}}createDefsElement(t){const e=document.createElementNS("http://www.w3.org/2000/svg","defs");return t.appendChild(e),e}getPathPoints(){if(!this.target.path||!Array.isArray(this.target.path)){const{left:t,top:e,width:n,height:i}=this.target.bounds;return[{x:t,y:e},{x:t+n,y:e},{x:t+n,y:e+i},{x:t,y:e+i}]}return this.target.path.map(t=>this.target.toGlobal(t.x,t.y))}createOffsetPath(t,e){const n=[],i=t.length;for(let r=0;r<i;r++){const s=t[(r-1+i)%i],o=t[r],a=t[(r+1)%i],c=o.x-s.x,l=o.y-s.y,h=a.x-o.x,d=a.y-o.y,u=this.normalize({x:l,y:-c}),p=this.normalize({x:d,y:-h}),f=this.normalize({x:(u.x+p.x)/2,y:(u.y+p.y)/2}),g={x:o.x+f.x*e,y:o.y+f.y*e};n.push(g)}return n}normalize(t){const e=Math.sqrt(t.x*t.x+t.y*t.y);return{x:t.x/e||0,y:t.y/e||0}}pointsToPathData(t,e=0){if(t.length<2)return"";let n="";const i=t.length,r=(t,e,n)=>{const i=e.x-t.x,r=e.y-t.y,s=Math.sqrt(i*i+r*r);return{x:t.x+i/s*n,y:t.y+r/s*n}};for(let s=0;s<i;s++){const o=t[s],a=t[(s+1)%i],c=t[(s-1+i)%i],l=Math.sqrt((o.x-c.x)**2+(o.y-c.y)**2),h=Math.sqrt((o.x-a.x)**2+(o.y-a.y)**2),d=Math.min(e,l/2,h/2),u=r(o,c,d),p=r(o,a,d);n+=0===s?`M${u.x},${u.y}`:` L${u.x},${u.y}`,n+=` Q${o.x},${o.y} ${p.x},${p.y}`}return n+=" Z",n}createFilter(t,e){const n=document.createElementNS("http://www.w3.org/2000/svg","filter");n.setAttribute("id",`${t}-filter`);const i=document.createElementNS("http://www.w3.org/2000/svg","feFlood");i.setAttribute("flood-color",e),i.setAttribute("result","flood");const r=document.createElementNS("http://www.w3.org/2000/svg","feComposite");r.setAttribute("in","flood"),r.setAttribute("in2","SourceAlpha"),r.setAttribute("operator","in"),r.setAttribute("result","mask");const s=document.createElementNS("http://www.w3.org/2000/svg","feMerge"),o=document.createElementNS("http://www.w3.org/2000/svg","feMergeNode");o.setAttribute("in","mask");const a=document.createElementNS("http://www.w3.org/2000/svg","feMergeNode");return a.setAttribute("in","SourceGraphic"),s.appendChild(o),s.appendChild(a),n.appendChild(i),n.appendChild(r),n.appendChild(s),n}createGradient(t,e){const n=document.createElementNS("http://www.w3.org/2000/svg","linearGradient");n.setAttribute("id",t),n.setAttribute("x1","0%"),n.setAttribute("y1","0%"),n.setAttribute("x2","100%"),n.setAttribute("y2","0%");const i=this.alterColor(e,120),r=this.alterColor(e,240),s=document.createElementNS("http://www.w3.org/2000/svg","stop");s.setAttribute("offset","0%"),s.setAttribute("stop-color",e);const o=document.createElementNS("http://www.w3.org/2000/svg","animate");o.setAttribute("attributeName","stop-color"),o.setAttribute("values",`${e};${i};${r};${e}`),o.setAttribute("dur","5s"),o.setAttribute("repeatCount","indefinite");const a=document.createElementNS("http://www.w3.org/2000/svg","stop");a.setAttribute("offset","100%"),a.setAttribute("stop-color",r);const c=document.createElementNS("http://www.w3.org/2000/svg","animate");return c.setAttribute("attributeName","stop-color"),c.setAttribute("values",`${r};${e};${i};${r}`),c.setAttribute("dur","5s"),c.setAttribute("repeatCount","indefinite"),s.appendChild(o),a.appendChild(c),n.appendChild(s),n.appendChild(a),n}alterColor(t,e){const n=this.convertToHex(t),i=parseInt(n.substring(1,3),16),r=parseInt(n.substring(3,5),16),s=parseInt(n.substring(5,7),16),o=this.rgbToHsl(i,r,s);o[0]=(o[0]+e/360)%1;const a=this.hslToRgb(o[0],o[1],o[2]);return`#${a[0].toString(16).padStart(2,"0")}${a[1].toString(16).padStart(2,"0")}${a[2].toString(16).padStart(2,"0")}`}rgbToHsl(t,e,n){t/=255,e/=255,n/=255;const i=Math.max(t,e,n),r=Math.min(t,e,n);let s=0,o=0;const a=(i+r)/2;if(i!==r){const c=i-r;switch(o=a>.5?c/(2-i-r):c/(i+r),i){case t:s=(e-n)/c+(e<n?6:0);break;case e:s=(n-t)/c+2;break;case n:s=(t-e)/c+4}s/=6}return[s,o,a]}hslToRgb(t,e,n){let i,r,s;if(0===e)i=r=s=n;else{const o=(t,e,n)=>(n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+6*(e-t)*n:n<.5?e:n<2/3?t+(e-t)*(2/3-n)*6:t),a=n<.5?n*(1+e):n+e-n*e,c=2*n-a;i=o(c,a,t+1/3),r=o(c,a,t),s=o(c,a,t-1/3)}return[Math.round(255*i),Math.round(255*r),Math.round(255*s)]}convertToHex(t){if(/^#([0-9A-F]{6})$/i.test(t))return t;const e=document.createElement("canvas");e.width=1,e.height=1;const n=e.getContext("2d");if(!n)return"#FF0000";n.fillStyle=t,n.fillRect(0,0,1,1);const i=n.getImageData(0,0,1,1).data;return`#${i[0].toString(16).padStart(2,"0")}${i[1].toString(16).padStart(2,"0")}${i[2].toString(16).padStart(2,"0")}`}start(){super.start(),this.isActive&&this.options.animation&&this.startAnimations()}removeDOMElements(){try{if(this.pathElement&&this.pathElement.parentNode&&this.pathElement.parentNode.removeChild(this.pathElement),this.pathElement=null,this.overlay){const t=this.getDefsForType();if(t&&this.elementId){const e=t.querySelector(`#${this.elementId}-filter`);e&&e.remove();const n=t.querySelector(`#${this.elementId}`);n&&n.remove()}}super.removeDOMElements()}catch(t){Fi("테두리 하이라이팅 요소 제거 중 오류:",t)}}}Id.DECORATOR_TYPE="border-highlighting";class Rd extends Dd{constructor(t,e,n={}){super(t,e,{bgColor:"#FF0000",textColor:"white",cornerRadius:3,padding:3,fontSize:"12px",fontFamily:"Arial",...n}),this.textElements=[],this.rectElements=[]}updateDOMElements(){if(!this.target.anchors||!this.target.anchors.length)return void this.removeDOMElements();const t=this.options,e=this.target.anchors,n=this.getOrCreateDecoratorGroup(!0);this.textElements=[],this.rectElements=[];const i=this.getComponentBounds();e.forEach(e=>{const{name:r,position:s}=e;let{x:o,y:a}=s||{};if(!r)return;let c=this.calculateOffsetX(o,i),l=this.calculateOffsetY(a,i);const h=this.projectComponentPoint(this.target,o,a);if(!h)return;o=h.x,a=h.y;const d=document.createElementNS("http://www.w3.org/2000/svg","text");d.setAttribute("fill",t.textColor),d.setAttribute("font-family",t.fontFamily),d.setAttribute("font-size",t.fontSize),d.textContent=r,n.appendChild(d);const u=d.getBBox();n.removeChild(d);const p=u.width,f=u.height;c=-1==c?-p-9:3,l=-1==l?-f-9:3,d.setAttribute("x",(o+c+3).toString()),d.setAttribute("y",(a+l+f).toString());const g=document.createElementNS("http://www.w3.org/2000/svg","rect");g.setAttribute("x",(o+c).toString()),g.setAttribute("y",(a+l).toString()),g.setAttribute("width",(p+6).toString()),g.setAttribute("height",(f+6).toString()),g.setAttribute("rx",t.cornerRadius.toString()),g.setAttribute("ry",t.cornerRadius.toString()),g.setAttribute("fill",t.bgColor),n.appendChild(g),n.appendChild(d),this.rectElements.push(g),this.textElements.push(d)})}calculateOffsetX(t,e){return t<e.left+1?-1:1}calculateOffsetY(t,e){return t<e.top+1?-1:1}updatePosition(){super.updatePosition(),this.updateDOMElements()}invalidate(){this.updatePosition()}createDOMElements(){this.updateDOMElements()}}Rd.DECORATOR_TYPE="anchors";class jd extends Dd{constructor(t,e,n={}){super(t,e,{bgColor:"#FF0000",textColor:"white",cornerRadius:3,padding:3,fontSize:"12px",fontFamily:"Arial",offsetX:3,offsetY:-8,animation:!1,...n}),this.textElement=null,this.backgroundElement=null,this.currentTag=""}createDOMElements(){const t=this.target.decotag;if(!t)return;this.currentTag=t;const{fontFamily:e,fontSize:n,textColor:i,padding:r,cornerRadius:s,bgColor:o,animation:a,repeat:c,duration:l}=this.options,h=this.getOrCreateDecoratorGroup(!0);h.setAttribute("transform","translate(0, 0)"),this.textElement=document.createElementNS("http://www.w3.org/2000/svg","text"),this.textElement.textContent=t,this.textElement.setAttribute("x",`${r}`),this.textElement.setAttribute("y",`-${n}`),this.textElement.setAttribute("font-family",e),this.textElement.setAttribute("font-size",n),this.textElement.setAttribute("fill",i),this.textElement.setAttribute("dominant-baseline","middle"),h.appendChild(this.textElement);const d=this.textElement.getBBox();if(this.backgroundElement=document.createElementNS("http://www.w3.org/2000/svg","rect"),this.backgroundElement.setAttribute("x",(d.x-r).toString()),this.backgroundElement.setAttribute("y",(d.y-r).toString()),this.backgroundElement.setAttribute("width",(d.width+2*r).toString()),this.backgroundElement.setAttribute("height",(d.height+2*r).toString()),this.backgroundElement.setAttribute("rx",s.toString()),this.backgroundElement.setAttribute("ry",s.toString()),this.backgroundElement.setAttribute("fill",o),h.replaceChildren(),h.appendChild(this.backgroundElement),h.appendChild(this.textElement),a){const t=this.createFadeAnimation(.3,1,l,{repeat:c});this.addAnimations(h,[t])}this.vectorElement=h,this.updatePosition()}updateDOMElements(){const t=this.target.decotag;t&&t===this.currentTag?this.vectorElement&&this.updatePosition():(this.removeDOMElements(),this.createDOMElements())}updatePosition(){super.updatePosition()}invalidate(){this.updatePosition()}}jd.DECORATOR_TYPE="decotag";class Fd extends Dd{constructor(t,e,n={}){super(t,e,{arrowColor:"#FFA500",arrowHeadLength:12,lineWidth:1.5,startAlpha:.6,endAlpha:1,animated:!0,animationDuration:5e3,repeat:!1,...n}),this.currentMappings=null,this.cachedArrows=[],this._incomingTimer=null}findIncomingSources(){const t=this.target.root;if(!t)return[];const e=this.target.state?.id;if(!e)return[];const n=[];return t.traverse(i=>{if(i===this.target)return;const r=i.model?.mappings;if(r)for(const s of r){if(!s.target)continue;if(s.target===`#${e}`){n.push({from:i,to:this.target});break}const r=t.findAll(s.target,i);if(r?.some(t=>t===this.target)){n.push({from:i,to:this.target});break}}}),n}appendArrow(t,e,n,i,r,s){const o=e.center,a=n.center,c=this.projectComponentPoint(e,o.x,o.y),l=this.projectComponentPoint(n,a.x,a.y);if(!c||!l)return;const{linePath:h,headPath:d}=this.createArrowPaths(c,l,s.arrowHeadLength),u=document.createElementNS("http://www.w3.org/2000/svg","path");u.setAttribute("d",h),u.setAttribute("stroke",r),u.setAttribute("stroke-width",String(s.lineWidth||2)),u.setAttribute("fill","none"),u.setAttribute("data-source-id",e.state?.id||""),u.setAttribute("data-target-id",n.state?.id||"");const p=document.createElementNS("http://www.w3.org/2000/svg","path");p.setAttribute("d",d),p.setAttribute("fill",i),p.setAttribute("stroke","none"),t.appendChild(u),t.appendChild(p)}createDOMElements(){this.removeDOMElements();const t=this.target.mappings&&this.target.mappings.length>0;this.currentMappings=this.target.mappings;const e=this.options,n=e.arrowColor||"#FFA500",i=this.getOrCreateDecoratorGroup(!0),r=this.getDefsForType(),s=`data-spread-style-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,o=document.createElementNS("http://www.w3.org/2000/svg","style");o.setAttribute("id",s),o.textContent=`\n @keyframes fadeOut {\n from { opacity: 1; }\n to { opacity: ${e.repeat?"0.2":"0"}; }\n }\n .arrow-animated {\n animation: fadeOut ${e.animationDuration||2e3}ms linear ${e.repeat?"infinite":"1"} forwards;\n }\n `,r.appendChild(o);const a=Date.now(),c=Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15),l=`arrow-gradient-out-${a}-${c}`,h=this.createGradient(l,n,e);r.appendChild(h);const d=Fd.INCOMING_ARROW_COLOR,u=`arrow-gradient-in-${a}-${c}`,p=this.createGradient(u,d,e);r.appendChild(p);const f=document.createElementNS("http://www.w3.org/2000/svg","g");if(f.setAttribute("class",e.animated?"arrow-animated":""),i.appendChild(f),this.cachedArrows=[],t){this.target.mappings.forEach(t=>{const i=this.target.root.findAll(t.target,this.target);i?.length&&i.forEach(t=>{t!==this.target&&(this.cachedArrows.push({from:this.target,to:t}),this.appendArrow(f,this.target,t,n,`url(#${l})`,e))})})}this.vectorElement=i,this._incomingTimer=setTimeout(()=>{if(this._incomingTimer=null,!this.vectorElement)return;this.findIncomingSources().forEach(({from:t})=>{this.cachedArrows.push({from:t,to:this.target}),this.appendArrow(f,t,this.target,d,`url(#${u})`,e)})},Fd.INCOMING_DEBOUNCE_MS)}createGradient(t,e,n){const i=document.createElementNS("http://www.w3.org/2000/svg","linearGradient");i.setAttribute("id",t),i.setAttribute("gradientUnits","userSpaceOnUse");const r=document.createElementNS("http://www.w3.org/2000/svg","stop");r.setAttribute("offset","0%"),r.setAttribute("stop-color",e),r.setAttribute("stop-opacity",(n.startAlpha||.5).toString());const s=document.createElementNS("http://www.w3.org/2000/svg","stop");return s.setAttribute("offset","100%"),s.setAttribute("stop-color",e),s.setAttribute("stop-opacity",(n.endAlpha||1).toString()),i.appendChild(r),i.appendChild(s),i}createArrowPaths(t,e,n){const i=e.x-t.x,r=e.y-t.y,s=Math.atan2(r,i),o=e.x+n*Math.cos(s+Fd.ARROW_ANGLE_1),a=e.y+n*Math.sin(s+Fd.ARROW_ANGLE_1),c=e.x+n*Math.cos(s+Fd.ARROW_ANGLE_2),l=e.y+n*Math.sin(s+Fd.ARROW_ANGLE_2);return{linePath:`M ${t.x} ${t.y} L ${e.x} ${e.y}`,headPath:`M ${e.x} ${e.y} L ${o} ${a} L ${c} ${l} Z`}}updateDOMElements(){if(!this.target.app?.isEditMode)return void this.removeDOMElements();this.target.mappings!==this.currentMappings?(this.removeDOMElements(),requestAnimationFrame(()=>{this.createDOMElements()})):this.vectorElement&&this.updatePosition()}updatePosition(){const t=this.getDecoratorType(),e=this.getSvgContainer().querySelector(`g[data-decorator-type-container="${t}"]`);if(!e)return;const n=this.getVectorGroupId(),i=e.querySelector(`g[data-decorator-group-id="${n}"]`);if(!i)return;const r=this.options,s=i.querySelector("g.arrow-animated")||i,o=Array.from(s.querySelectorAll('path[fill="none"]')),a=Array.from(s.querySelectorAll('path[stroke="none"]'));if(0===o.length)return;const c=Math.min(o.length,a.length,this.cachedArrows.length);for(let t=0;t<c;t++){const{from:e,to:n}=this.cachedArrows[t],i=e.center,s=n.center,c=this.projectComponentPoint(e,i.x,i.y),l=this.projectComponentPoint(n,s.x,s.y);if(!c||!l)continue;const{linePath:h,headPath:d}=this.createArrowPaths(c,l,r.arrowHeadLength);o[t].setAttribute("d",h),a[t].setAttribute("d",d)}}removeDOMElements(){this.currentMappings=null,this.cachedArrows=[],this._incomingTimer&&(clearTimeout(this._incomingTimer),this._incomingTimer=null);try{if(this.overlay){const t=this.getSvgContainer();if(t){const e=this.getDecoratorType(),n=t.querySelector(`g[data-decorator-type-container="${e}"]`);if(n){const t=n.querySelector(`defs[data-defs-for="${e}"]`);if(t){t.querySelectorAll("style").forEach(t=>t.remove());t.querySelectorAll("linearGradient").forEach(t=>t.remove())}}}}this.animationElements=[],super.removeDOMElements()}catch(t){Fi("데이터 스프레드 데코레이터 요소 제거 중 오류:",t)}}invalidate(){this.updatePosition()}}Fd.DECORATOR_TYPE="data-spread",Fd.ARROW_ANGLE_1=160*Math.PI/180,Fd.ARROW_ANGLE_2=200*Math.PI/180,Fd.INCOMING_ARROW_COLOR="#4A9EFF",Fd.INCOMING_DEBOUNCE_MS=500;class Bd extends Dd{constructor(t,e,n={}){super(t,e,{bgColor:"#FF0000",textColor:"white",cornerRadius:2,padding:2,fontSize:"12px",fontFamily:"Arial",offsetX:4,offsetY:4,...n}),this.textElements=[],this.rectElements=[]}createDOMElements(){this.updateDOMElements()}updateDOMElements(){if(!this.target.isLine||!this.target.isLine())return void this.removeDOMElements();const{offsetX:t,offsetY:e,padding:n,textColor:i,bgColor:r,cornerRadius:s,fontSize:o,fontFamily:a}=this.options,c=this.getOrCreateDecoratorGroup(!0);this.textElements=[],this.rectElements=[];const{fromEnd:l,toEnd:h}=this.target;[l,h].filter(Boolean).forEach(l=>{const{component:h,anchor:d}=l;if(!d)return;const{name:u,position:p}=d||{};if(!h.rootModel||!u||!p)return;const f=this.projectComponentPoint(h,p.x,p.y);if(!f)return;let{x:g,y:m}=f;const y=document.createElementNS("http://www.w3.org/2000/svg","g"),b=document.createElementNS("http://www.w3.org/2000/svg","text");b.setAttribute("text-anchor","middle"),b.setAttribute("dominant-baseline","middle"),b.setAttribute("x","0"),b.setAttribute("y","0"),b.setAttribute("fill",i),b.setAttribute("font-family",a),b.setAttribute("font-size",o),b.textContent=u,c.appendChild(b);const _=b.getBBox();c.removeChild(b);const v=document.createElementNS("http://www.w3.org/2000/svg","rect"),x=_.width+2*(n??0),w=_.height+2*(n??0);g+=(t??0)+x/2,m+=(e??0)+w/2,v.setAttribute("x",(-x/2).toString()),v.setAttribute("y",(-w/2).toString()),v.setAttribute("width",x.toString()),v.setAttribute("height",w.toString()),v.setAttribute("rx",(s??0).toString()),v.setAttribute("ry",(s??0).toString()),v.setAttribute("fill",r),y.appendChild(v),y.appendChild(b),y.setAttribute("transform",`translate(${g}, ${m})`),c.appendChild(y),this.rectElements.push(v),this.textElements.push(b)})}updatePosition(){super.updatePosition(),this.updateDOMElements()}invalidate(){this.updatePosition()}}Bd.DECORATOR_TYPE="link",vs.registerDecorator("bouncing-arrow",zd),vs.registerDecorator("animated-icon",Ld),vs.registerDecorator("border-highlighting",Id),vs.registerDecorator("anchors",Rd),vs.registerDecorator("decotag",jd),vs.registerDecorator("data-spread",Fd),vs.registerDecorator("link",Bd);let Nd=0,Hd=0,Yd=0,Gd=null;function Vd(){Yd++;const t=performance.now(),e=t-Hd;e>=1e3&&(Nd=Math.round(1e3*Yd/e),Hd=t,Yd=0),Gd=requestAnimationFrame(Vd)}function Ud(){null!==Gd&&(cancelAnimationFrame(Gd),Gd=null)}function $d(){return null===Gd&&(Hd=performance.now(),Yd=0,Gd=requestAnimationFrame(Vd)),Nd}const Wd=function(){const t=document.createElement("canvas").getContext("2d");return(window.devicePixelRatio||1)/(t.webkitBackingStorePixelRatio||t.mozBackingStorePixelRatio||t.msBackingStorePixelRatio||t.oBackingStorePixelRatio||t.backingStorePixelRatio||1)}();function Xd(t,e){const n=document.createElement("canvas");return n.width=t,n.height=e,n.style.width=t+"px",n.style.height=e+"px",n}const qd=Math.sqrt(3);function Kd(t,e){const n=1.2*e;switch(t){case"size1":return{X:n,Y:n};case"size2":return{X:1.5*n,Y:n};case"size3":return{X:2*n,Y:n};case"size4":return{X:n,Y:1.5*n};case"size5":default:return{X:1.5*n,Y:1.5*n};case"size6":return{X:2*n,Y:1.5*n};case"size7":return{X:n,Y:2*n};case"size8":return{X:1.5*n,Y:2*n};case"size9":return{X:2*n,Y:2*n}}}function Qd(t,e,n){switch(t){case"none":default:return null;case"arrow":{const t=qd*e.X,n=e.Y,i=new w.ConeGeometry(n,t,16);return i.rotateZ(-Math.PI/2),i.translate(-t/2,0,0),{mesh:new w.Mesh(i,new w.MeshBasicMaterial)}}case"sharp-arrow":{const t=qd*e.X*1.3,n=.65*e.Y,i=new w.ConeGeometry(n,t,16);return i.rotateZ(-Math.PI/2),i.translate(-t/2,0,0),{mesh:new w.Mesh(i,new w.MeshBasicMaterial)}}case"open-arrow":{const t=qd*e.X,n=e.Y,i=new w.ConeGeometry(n,t,6);return i.rotateZ(-Math.PI/2),i.translate(-t/2,0,0),{mesh:new w.Mesh(i,new w.MeshBasicMaterial({wireframe:!0}))}}case"diamond":{const t=new w.OctahedronGeometry(1);return t.scale(e.X,e.Y,e.Y),{mesh:new w.Mesh(t,new w.MeshBasicMaterial)}}case"oval":{const t=new w.SphereGeometry(1,16,12);return t.scale(e.X,e.Y,e.Y),{mesh:new w.Mesh(t,new w.MeshBasicMaterial)}}case"cross":{const t=Math.max(e.X,e.Y),n=.9*t,i=.25*t,r=.15*t,s=new w.Group,o=[new w.Vector3(1,1,1).normalize(),new w.Vector3(1,-1,-1).normalize(),new w.Vector3(-1,1,-1).normalize(),new w.Vector3(-1,-1,1).normalize()];for(const t of o){const e=new w.CylinderGeometry(i,r,n,6),o=(new w.Quaternion).setFromUnitVectors(new w.Vector3(0,1,0),t);e.applyQuaternion(o),e.translate(t.x*n/2,t.y*n/2,t.z*n/2),s.add(new w.Mesh(e,new w.MeshBasicMaterial))}return{group:s}}}}function Zd(t,e){return"none"===t?0:t.endsWith("arrow")?1.5*e:0}function Jd(t,e,n,i){const{strokeStyle:r,alpha:s=1,lineWidth:o=2,begin:a="none",beginSize:c="size2",end:l="arrow",endSize:p="size2",label:f}=n,g=(new w.Vector3).subVectors(e,t),m=g.length(),y=new w.Group;if(m<.01)return y;const b=g.clone().normalize(),_=Zd(a,o),v=Zd(l,o),x=t.clone().add(b.clone().multiplyScalar(_)),M=e.clone().sub(b.clone().multiplyScalar(v));let S;if(Array.isArray(r)&&r.length>=2){const t=r[1];S=new w.Color(t.length>7?t.slice(0,7):t)}else S=new w.Color("string"==typeof r?r:"#00B050");const A=function(t,e,n,i){const{strokeStyle:r,alpha:s=1,lineWidth:o=2,lineDash:a="solid"}=n,c=new u.LineGeometry;let l;c.setPositions([t.x,t.y,t.z,e.x,e.y,e.z]);let p=!1;if(Array.isArray(r)&&r.length>=2){const t=new w.Color(r[0].length>7?r[0].slice(0,7):r[0]),e=new w.Color(r[1].length>7?r[1].slice(0,7):r[1]);c.setColors([t.r,t.g,t.b,e.r,e.g,e.b]),p=!0,l=e}else l=new w.Color("string"==typeof r?r:"#00B050");const{dashed:f,dashSize:g,gapSize:m}=function(t,e){switch(t){case"solid":default:return{dashed:!1,dashSize:1,gapSize:0};case"round-dot":return{dashed:!0,dashSize:e,gapSize:2*e};case"square-dot":return{dashed:!0,dashSize:2*e,gapSize:e};case"dash":return{dashed:!0,dashSize:4*e,gapSize:1.5*e};case"dash-dot":return{dashed:!0,dashSize:2.5*e,gapSize:1.5*e};case"long-dash":return{dashed:!0,dashSize:6*e,gapSize:3*e};case"long-dash-dot":return{dashed:!0,dashSize:3.5*e,gapSize:2*e};case"long-dash-dot-dot":return{dashed:!0,dashSize:3*e,gapSize:1.5*e}}}(a,o),y=new d.LineMaterial({color:p?16777215:l.getHex(),linewidth:o,worldUnits:!0,vertexColors:p,dashed:f,dashSize:g,gapSize:m,transparent:s<1||Array.isArray(r)&&r.some(t=>t.length>7),opacity:s,resolution:i}),b=new h.Line2(c,y);return b.computeLineDistances(),b}(x,M,n,i);y.add(A);const E=(new w.Quaternion).setFromUnitVectors(new w.Vector3(1,0,0),b),k=(new w.Quaternion).setFromUnitVectors(new w.Vector3(1,0,0),b.clone().negate()),C=(t,e,n)=>{if(!t)return;const r=t.mesh||t.line2||t.group;if(r){if(r.position.copy(e),r.setRotationFromQuaternion(n),t.mesh){const e=t.mesh.material;e.color.copy(S),e.transparent=s<1,e.opacity=s}else if(t.line2){const e=t.line2.material;e.color.copy(S),e.transparent=s<1,e.opacity=s,e.resolution.copy(i)}else t.group&&t.group.traverse(t=>{if(t.material){const e=t.material;e.color.copy(S),e.transparent=s<1,e.opacity=s,e.resolution&&e.resolution.copy(i)}});y.add(r)}};C(Qd(l,Kd(p,o)),e,E);if(C(Qd(a,Kd(c,o)),t,k),f){const n=(new w.Vector3).addVectors(t,e).multiplyScalar(.5);n.y+=3;const i=function(t,e,n){const i="Arial",r=Xd(256,64),s=r.getContext("2d");s.font=`bold 28px ${i}`;const o=s.measureText(t).width;s.fillStyle=e,s.fillRect(0,0,o+12,40),s.fillStyle="white",s.font=`bold 28px ${i}`,s.textBaseline="top",s.fillText(t,6,6);const a=new w.CanvasTexture(r);a.needsUpdate=!0,a.minFilter=w.LinearFilter,a.colorSpace=w.SRGBColorSpace;const c=new w.SpriteMaterial({map:a,transparent:!0}),l=new w.Sprite(c);l.position.copy(n);const h=(o+12)/40;return l.scale.set(4*h,4,1),l}(f,"string"==typeof r?r:Array.isArray(r)&&r[1]||"#00B050",n);y.add(i)}return y}class tu extends $h{get syncZPosOffset(){return this.effectiveDepth}get geometricOffsetY(){return this.effectiveDepth}getObject3dInstance(){return new l.CSS3DObject(this.component.element)}get rotation(){const{rotationX:t=0,rotationY:e=0,rotation:n=0}=this.component.state;return{x:t-Math.PI/2,y:e,z:-n}}syncFromObject3D(){const t=this.object3d,e=this._component,{width:n=0,height:i=0}=e.parent?.bounds??{},r=e.bounds,{tx:s=0,ty:o=0,tz:a=0}=e.delta();this._suppressOnchange=!0;const c=t.scale.x;e.bounds={left:t.position.x-s+n/2-r.width/2,top:t.position.z-o+i/2-r.height/2,width:r.width,height:r.height};const l=this.component.parent?._realObject,h=l?.geometricOffsetY??0;e.set({zPos:t.position.y-a-this.syncZPosOffset+h,rotationX:t.rotation.x+Math.PI/2,rotation:-t.rotation.z,rotationY:t.rotation.y,scale:{x:c,y:c}}),this._suppressOnchange=!1}build(){super.build();const t=this.component.element;if(!t)return;if(t.style.left="",t.style.top="",this.component.state.screenFixed&&this.component.isContainer?.())return;const{width:e,height:n}=this.component.bounds;t.style.width=e+"px",t.style.height=n+"px"}updateDimension(){if(this.component.state.screenFixed&&this.component.isContainer?.())return;super.updateDimension();const t=this.dimension,e=this.component.element;e&&(e.style.width=t.width+"px",e.style.height=t.height+"px")}updateAlpha(){super.updateAlpha();const{alpha:t=1}=this.component.state,e=this.component.element;e&&(e.style.opacity=String(t))}}const eu=new Map;let nu;function iu(t,e){eu.set(t,e)}function ru(t){nu=t}function su(t){const e=t.buildRealObject();if(e)return e;const n=t.model?.type,i=n?eu.get(n):void 0;if(i)return i(t);if(t.isHTMLElement()){const e=eu.get("html-overlay-element");if(e)return e(t)}return nu?.(t)}function ou(t,e,n){if(!t.hasTextProperty||t.textHidden)return;const i=t._realObject;if(!i?.object3d)return;const{text:r="",bold:s=Er.BOLD,italic:o=Er.ITALIC,fontFamily:a=Er.FONT_FAMILY,fontColor:c=Er.FONT_COLOR,fontSize:h=Er.FONT_SIZE,textAlign:d=Er.TEXT_ALIGN,textBaseline:u=Er.TEXT_BASELINE,width:p,height:f}=t.model,g=Math.abs(p)||1,m=Math.abs(f)||1,y=document.createElement("textarea"),b=new AbortController;Sr.forEach(t=>{y.addEventListener(t,t=>t.stopPropagation(),{capture:!0,signal:b.signal})}),y.value=r;const _="right"===d||"end"===d?"right":"left"===d||"start"===d?"left":"justify"===d?"justify":"center";let v="0";if("bottom"===u||"alphabetic"===u){const t=1.2*h*Math.max(1,(r.match(/\n/g)||[]).length+1);v=Math.max(0,m-t)+"px"}else if("middle"===u){const t=1.2*h*Math.max(1,(r.match(/\n/g)||[]).length+1);v=Math.max(0,(m-t)/2)+"px"}y.style.cssText=[`width: ${g}px`,`height: ${m}px`,`padding: ${v} 0 0 0`,"margin: 0",`font-family: ${a}`,`font-size: ${h}px`,`line-height: ${1.2*h}px`,"overflow: hidden","resize: none","outline: 1px solid #f26522","border: 0","background-color: rgba(255, 255, 255, 0.85)","display: block",`color: ${c}`,"box-sizing: border-box","font-weight: "+(s?"bold":"normal"),"font-style: "+(o?"italic":"normal"),`text-align: ${_}`].join("; ");const x=new l.CSS3DObject(y),M=i.object3d;M.updateWorldMatrix(!0,!1);const S=new w.Vector3,A=new w.Quaternion,E=new w.Vector3;M.matrixWorld.decompose(S,A,E);const k=new w.Vector3(0,i.textSurfaceYOffset,0);k.multiply(E),k.applyQuaternion(A),x.position.copy(S).add(k);const C=(new w.Quaternion).setFromAxisAngle(new w.Vector3(1,0,0),-Math.PI/2);x.quaternion.copy(A).multiply(C),x.scale.copy(E),e.css3DScene.add(x),n();const T=e.css3DRenderer.domElement,P=T.style.getPropertyValue("pointer-events"),D=T.style.getPropertyPriority("pointer-events"),O=[];let z=y;for(;z&&z!==T.parentElement;)O.push({el:z,saved:z.style.pointerEvents}),z.style.setProperty("pointer-events","auto","important"),z=z.parentElement;y.focus(),y.select();let L=!1;const I=t.root?.selected;y.addEventListener("keydown",t=>{t.stopPropagation(),"Escape"!==t.code&&(t.shiftKey||"Enter"!==t.code&&"NumpadEnter"!==t.code)||(L="Escape"===t.code,y.blur())},{signal:b.signal});const R=()=>{e.css3DScene.remove(x);for(const{el:t,saved:e}of O)e?t.style.pointerEvents=e:t.style.removeProperty("pointer-events");D?T.style.setProperty("pointer-events",P,D):P&&T.style.setProperty("pointer-events",P),b.abort(),y.removeEventListener("blur",R),I&&t.root&&(t.root.selected=I),L||y.value===r||t.app.commander.execute(new Sc({changes:[{component:t,before:{text:r},after:{text:y.value}}]})),n()};y.addEventListener("blur",R)}class au extends n.Scene{dispose(){const t=new Set;this.traverse(e=>{if(e.isMesh){t.add(e.geometry);const n=e.material;Array.isArray(n)?n.forEach(e=>t.add(e)):t.add(n)}});for(const e of t)e.dispose()}}function cu(t,e){t.metalness=e.metalness,t.roughness=e.roughness,t.opacity=e.opacity,t.transparent=e.opacity<1,t.envMapIntensity=e.envMapIntensity,t.polygonOffset=!0,t.polygonOffsetFactor=1,t.polygonOffsetUnits=1}function lu(t){const{fillStyle:e,floorMaterial3d:n,placement:i}=t.state,r=Mh({...n,preset:n?.preset??"rubber",envMapIntensity:n?.envMapIntensity??0});if("none"===e)return;if("space"===i)return;const s=new w.BoxGeometry(1,1,1);let o;if(e){const n=$h.buildFillStyleTexture(t);if(n){const t="#424b57",e=[new w.MeshStandardMaterial({color:t}),new w.MeshStandardMaterial({color:t}),new w.MeshStandardMaterial({color:t}),new w.MeshStandardMaterial({color:t}),new w.MeshStandardMaterial({map:n}),new w.MeshStandardMaterial({color:t})];e.forEach(t=>cu(t,r)),o=e}else if("string"==typeof e){const t=new w.MeshStandardMaterial({color:e});cu(t,r),o=t}}if(!o){const t=new w.MeshStandardMaterial({color:"#e0e0e0"});cu(t,r),o=t}const a=new w.Mesh(s,o),{width:c,height:l}=t.state;return a.scale.set(c,l,5),a.rotation.x=-Math.PI/2,a.position.y="inverted"===i?3.5:-3.5,a.name="floor",a.receiveShadow=!1!==n?.receiveShadow,a.castShadow=!0===n?.castShadow,a}const hu={studio:class extends au{constructor(){super(),this.name="StudioEnvironment",this.position.y=-3.5;const t=new n.BoxGeometry;t.deleteAttribute("uv");const e=new n.MeshStandardMaterial({side:n.BackSide,color:13421772}),i=new n.Mesh(t,e);i.position.set(0,13,0),i.scale.set(40,30,35),this.add(i);const r=new n.MeshStandardMaterial({color:11184810,roughness:.8}),s=new n.Mesh(t,r);s.position.set(0,-1.5,0),s.scale.set(40,.5,35),this.add(s);const o=new n.PointLight(16777215,500,40,2);o.position.set(0,24,0),this.add(o);const a=new n.PointLight(16777215,200,30,2);a.position.set(-10,22,-8),this.add(a);const c=new n.PointLight(16777215,200,30,2);c.position.set(10,22,8),this.add(c);const l=(e,i,r)=>{const s=new n.MeshLambertMaterial({color:0,emissive:16777215,emissiveIntensity:r}),o=new n.Mesh(t,s);return o.position.set(e,26,i),o.scale.set(6,.1,6),o};this.add(l(-8,-6,60)),this.add(l(8,-6,60)),this.add(l(-8,6,60)),this.add(l(8,6,60)),this.add(l(0,0,50))}},warehouse:class extends au{constructor(){super(),this.name="WarehouseEnvironment",this.position.y=-3.5;const t=new n.BoxGeometry;t.deleteAttribute("uv");const e=new n.MeshStandardMaterial({side:n.BackSide,color:8425632}),i=new n.Mesh(t,e);i.position.set(0,18,0),i.scale.set(50,40,40),this.add(i);const r=new n.MeshStandardMaterial({color:9474192,roughness:.9}),s=new n.Mesh(t,r);s.position.set(0,-1.5,0),s.scale.set(50,.5,40),this.add(s);const o=new n.PointLight(15266047,600,50,2);o.position.set(-10,30,0),this.add(o);const a=new n.PointLight(15266047,600,50,2);a.position.set(10,30,0),this.add(a);const c=(e,i,r)=>{const s=new n.MeshLambertMaterial({color:0,emissive:15266047,emissiveIntensity:r}),o=new n.Mesh(t,s);return o.position.set(e,35,i),o.scale.set(8,.1,2),o};this.add(c(-12,-6,80)),this.add(c(-12,6,80)),this.add(c(0,0,60)),this.add(c(12,-6,80)),this.add(c(12,6,80));const l=new n.Mesh(t,new n.MeshLambertMaterial({color:0,emissive:16772829,emissiveIntensity:15}));l.position.set(0,10,-19),l.scale.set(12,8,.1),this.add(l)}},factory:class extends au{constructor(){super(),this.name="FactoryEnvironment",this.position.y=-3.5;const t=new n.BoxGeometry;t.deleteAttribute("uv");const e=new n.MeshStandardMaterial({side:n.BackSide,color:6318192,metalness:.1,roughness:.8}),i=new n.Mesh(t,e);i.position.set(0,20,0),i.scale.set(60,44,45),this.add(i);const r=new n.MeshStandardMaterial({color:8028272,roughness:.7,metalness:.05}),s=new n.Mesh(t,r);s.position.set(0,-1.5,0),s.scale.set(60,.5,45),this.add(s);const o=(t,e)=>{const i=new n.PointLight(15791615,800,55,2);return i.position.set(t,35,e),i};this.add(o(-15,-10)),this.add(o(-15,10)),this.add(o(0,0)),this.add(o(15,-10)),this.add(o(15,10));const a=(e,i,r)=>{const s=new n.MeshLambertMaterial({color:0,emissive:15791615,emissiveIntensity:r}),o=new n.Mesh(t,s);return o.position.set(e,38,i),o.scale.set(6,.1,3),o};this.add(a(-18,-10,90)),this.add(a(-18,10,90)),this.add(a(0,-10,70)),this.add(a(0,10,70)),this.add(a(18,-10,90)),this.add(a(18,10,90));const c=new n.Mesh(t,new n.MeshLambertMaterial({color:0,emissive:11206570,emissiveIntensity:10}));c.position.set(28,14,-21),c.scale.set(1,2,.1),this.add(c);const l=new n.Mesh(t,new n.MeshLambertMaterial({color:0,emissive:16772829,emissiveIntensity:25}));l.position.set(0,8,-22),l.scale.set(10,10,.1),this.add(l)}},office:class extends au{constructor(){super(),this.name="OfficeEnvironment",this.position.y=-3.5;const t=new n.BoxGeometry;t.deleteAttribute("uv");const e=new n.MeshStandardMaterial({side:n.BackSide,color:14209224}),i=new n.Mesh(t,e);i.position.set(0,10,0),i.scale.set(35,22,30),this.add(i);const r=new n.MeshStandardMaterial({color:10524808,roughness:.85}),s=new n.Mesh(t,r);s.position.set(0,-1.5,0),s.scale.set(35,.5,30),this.add(s);const o=new n.PointLight(16774374,400,30,2);o.position.set(0,17,0),this.add(o);const a=(e,i,r)=>{const s=new n.MeshLambertMaterial({color:0,emissive:16775408,emissiveIntensity:r}),o=new n.Mesh(t,s);return o.position.set(e,19.5,i),o.scale.set(4,.1,4),o};this.add(a(-8,-6,60)),this.add(a(-8,6,60)),this.add(a(8,-6,60)),this.add(a(8,6,60)),this.add(a(0,0,50));const c=new n.Mesh(t,new n.MeshLambertMaterial({color:0,emissive:14544639,emissiveIntensity:30}));c.position.set(17,10,0),c.scale.set(.1,6,12),this.add(c);const l=new n.Mesh(t,new n.MeshLambertMaterial({color:0,emissive:14544639,emissiveIntensity:20}));l.position.set(-17,10,0),l.scale.set(.1,4,8),this.add(l)}},home:class extends au{constructor(){super(),this.name="HomeEnvironment",this.position.y=-3.5;const t=new n.BoxGeometry;t.deleteAttribute("uv");const e=new n.MeshStandardMaterial({side:n.BackSide,color:15261136}),i=new n.Mesh(t,e);i.position.set(0,8,0),i.scale.set(28,18,24),this.add(i);const r=new n.MeshStandardMaterial({color:11571312,roughness:.7}),s=new n.Mesh(t,r);s.position.set(0,-1.5,0),s.scale.set(28,.5,24),this.add(s);const o=new n.PointLight(16770244,300,25,2);o.position.set(0,14,0),this.add(o);const a=new n.PointLight(16767152,100,20,2);a.position.set(-8,12,-6),this.add(a);const c=(e,i,r)=>{const s=new n.MeshLambertMaterial({color:0,emissive:16771280,emissiveIntensity:r}),o=new n.Mesh(t,s);return o.position.set(e,15.5,i),o.scale.set(3,.1,3),o};this.add(c(0,0,40)),this.add(c(-6,-4,25)),this.add(c(6,4,25));const l=new n.Mesh(t,new n.MeshLambertMaterial({color:0,emissive:14544639,emissiveIntensity:35}));l.position.set(13.5,8,0),l.scale.set(.1,8,10),this.add(l);const h=new n.Mesh(t,new n.MeshLambertMaterial({color:0,emissive:14544639,emissiveIntensity:15}));h.position.set(-13.5,9,3),h.scale.set(.1,5,6),this.add(h)}},sunny:class extends au{constructor(){super(),this.name="SunnyEnvironment";const t=new p.Sky;t.scale.setScalar(1e3);const e=t.material.uniforms;e.turbidity.value=2,e.rayleigh.value=1.5,e.mieCoefficient.value=.005,e.mieDirectionalG.value=.8;const i=n.MathUtils.degToRad(60),r=n.MathUtils.degToRad(135),s=Math.PI/2-i;e.sunPosition.value.setFromSphericalCoords(1,s,r),this.add(t)}},cloudy:class extends au{constructor(){super(),this.name="CloudyEnvironment";const t=new p.Sky;t.scale.setScalar(1e3);const e=t.material.uniforms;e.turbidity.value=10,e.rayleigh.value=.3,e.mieCoefficient.value=.03,e.mieDirectionalG.value=.7;const i=n.MathUtils.degToRad(50),r=n.MathUtils.degToRad(120),s=Math.PI/2-i;e.sunPosition.value.setFromSphericalCoords(1,s,r),this.add(t)}},rainy:class extends au{constructor(){super(),this.name="RainyEnvironment";const t=new p.Sky;t.scale.setScalar(1e3);const e=t.material.uniforms;e.turbidity.value=20,e.rayleigh.value=.1,e.mieCoefficient.value=.05,e.mieDirectionalG.value=.6;const i=n.MathUtils.degToRad(40),r=n.MathUtils.degToRad(110),s=Math.PI/2-i;e.sunPosition.value.setFromSphericalCoords(1,s,r),this.add(t)}}};class du{get scene(){return this._scene}get mixer(){return this._mixer}setup(){return this._scene=new w.Scene,this._scene}setupMixer(){return this._timer=new w.Timer,this._timer.connect(document),this._mixer=new w.AnimationMixer(this._scene),this._mixer}setupEnvironment(t){this._renderer=t}_applyEnvironment(t){if(this._envTexture&&(this._envTexture.dispose(),this._envTexture=void 0),!this._renderer||!this._scene)return;const e=new(0,hu[t]),n=new w.PMREMGenerator(this._renderer);this._envTexture=n.fromScene(e).texture,this._scene.environment=this._envTexture,e.dispose(),n.dispose()}_clearEnvironment(){this._envTexture&&(this._envTexture.dispose(),this._envTexture=void 0),this._scene&&(this._scene.environment=null)}setSky(t,e){if(!this._scene||!this._renderer)return;const n=t;n&&n in hu?(this._applyEnvironment(n),this._scene.background=this._envTexture):"color"===t&&e?(this._clearEnvironment(),this._scene.background=new w.Color(e)):(this._clearEnvironment(),this._scene.background=null)}addFloor(t){const e=lu(t);e&&this._scene.add(e)}updateFloor(t){if(!this._scene)return;const e=this._scene.children.find(t=>"floor"===t.name);e&&(Hh(e),this._scene.remove(e)),this.addFloor(t)}addObject(t){this._scene.add(t)}updateAnimation(){this._mixer&&this._timer&&(this._timer.update(),this._mixer.update(this._timer.getDelta()))}destroy(){this._mixer&&(this._mixer.stopAllAction(),this._mixer.uncacheRoot(this._scene)),this._envTexture&&(this._envTexture.dispose(),delete this._envTexture),this._scene&&(this._scene.environment=null,Hh(this._scene),this._scene.clear()),delete this._scene,delete this._mixer,delete this._renderer,this._timer&&this._timer.disconnect(),delete this._timer}}class uu{constructor(){this._activeView="perspective",this._cameraZPos=0}get camera(){return this._perspCamera}get activeCamera(){return"perspective"!==this._activeView&&this._orthoCamera?this._orthoCamera:this._perspCamera}get activeView(){return this._activeView}get cameraZPos(){return this._cameraZPos}setup(t,e,n){const{fov:i,near:r,far:s,cameraX:o,cameraY:a,cameraZ:c}=n,l=t/e;this._perspCamera=new w.PerspectiveCamera(i,l,r,s);const h=Math.sqrt(t*t+e*e),d=(i||45)/2*Math.PI/180,u=h/2/Math.tan(d)*.75,p=25*Math.PI/180,f=30*Math.PI/180,g=u*Math.sin(p),m=u*Math.cos(p);let y=m*Math.sin(f),b=m*Math.cos(f);return this._cameraZPos=Math.floor(g),null!=o&&(y=o*t),null!=a&&(b=a*e),null!=c&&(this._cameraZPos=c*Math.floor(Math.min(t,e))),this._perspCamera.position.set(y,this._cameraZPos,b),this._activeView="perspective",this._perspCamera}addToScene(t){t.add(this._perspCamera),this._perspCamera.lookAt(t.position)}updateAspect(t,e){if(this._perspCamera&&(this._perspCamera.aspect=t/e,this._perspCamera.updateProjectionMatrix()),this._orthoCamera){const n=this._orthoCamera,i=(n.top-n.bottom)/2,r=t/e;n.left=-i*r,n.right=i*r,n.updateProjectionMatrix()}}updateProperties(t){this._perspCamera&&(void 0!==t.fov&&(this._perspCamera.fov=t.fov),void 0!==t.near&&(this._perspCamera.near=t.near),void 0!==t.far&&(this._perspCamera.far=t.far),this._perspCamera.updateProjectionMatrix())}setOrthoView(t,e,n,i,r){this._orthoCamera||(this._orthoCamera=new w.OrthographicCamera(-1,1,1,-1,.1,5e4)),this.updateOrthoFrustum(e,n,i,r);const s=this._orthoCamera;s.zoom=1;const o=2*Math.max(e,n);switch(t){case"top":s.position.set(0,o,0),s.up.set(0,0,-1);break;case"front":s.position.set(0,0,o),s.up.set(0,1,0);break;case"back":s.position.set(0,0,-o),s.up.set(0,1,0);break;case"right":s.position.set(o,0,0),s.up.set(0,1,0);break;case"left":s.position.set(-o,0,0),s.up.set(0,1,0)}return s.lookAt(0,0,0),s.updateProjectionMatrix(),this._activeView=t,s}restorePerspective(){return this._activeView="perspective",this._perspCamera}updateOrthoFrustum(t,e,n,i){if(!this._orthoCamera)return;const r=(n||t)/(i||e),s=Math.max(t,e)/2;r>=1?(this._orthoCamera.left=-s*r,this._orthoCamera.right=s*r,this._orthoCamera.top=s,this._orthoCamera.bottom=-s):(this._orthoCamera.left=-s,this._orthoCamera.right=s,this._orthoCamera.top=s/r,this._orthoCamera.bottom=-s/r),this._orthoCamera.updateProjectionMatrix()}destroy(){delete this._perspCamera,delete this._orthoCamera,this._activeView="perspective"}}class pu{constructor(){this._noSupportWebgl=!1}get renderer(){return this._renderer}setExposure(t){this._renderer&&(this._renderer.toneMappingExposure=t)}get css3DRenderer(){return this._css3DRenderer||(this._css3DRenderer=this.createCSS3DRenderer()),this._css3DRenderer}get css3DScene(){return this._css3DScene||(this._css3DScene=new w.Scene),this._css3DScene}get composer(){return this._composer}get noSupportWebgl(){return this._noSupportWebgl}get domElement(){return this._renderer?.domElement}get hudScene(){return this._hudScene||(this._hudScene=new w.Scene),this._hudScene}get hudCSS3DScene(){return this._hudCSS3DScene||(this._hudCSS3DScene=new w.Scene),this._hudCSS3DScene}get hudCamera(){return this._hudCamera}setupHUD(t,e){this._hudCamera=new w.OrthographicCamera(-t/2,t/2,e/2,-e/2,.1,1e4),this._hudCamera.position.set(0,5e3,0),this._hudCamera.lookAt(0,0,0),this._hudCSS3DCamera=new w.OrthographicCamera(-t/2,t/2,e/2,-e/2,.1,1e4),this._hudCSS3DCamera.position.set(0,0,1e3),this._hudCSS3DCamera.lookAt(0,0,0),this._hudCSS3DRenderer=new l.CSS3DRenderer,this._hudCSS3DRenderer.setSize(t,e);const n=this._hudCSS3DRenderer.domElement;n.style.position="absolute",n.style.left="0",n.style.top="0",n.style.pointerEvents="none",n.setAttribute("scene","model-layer:css3d-hud-renderer");const i=new w.AmbientLight(16777215,3);this.hudScene.add(i);const r=new Float32Array(64).fill(1),s=new w.DataTexture(r,4,4,w.RGBAFormat,w.FloatType);s.mapping=w.EquirectangularReflectionMapping,s.needsUpdate=!0,this.hudScene.environment=s}resizeHUD(t,e){this._hudCamera&&(this._hudCamera.right=t,this._hudCamera.bottom=-e,this._hudCamera.updateProjectionMatrix())}setupWebGL(t,e,n){try{const i=document.createElement("canvas"),r=i.getContext("webgl2");if(!r)return this._noSupportWebgl=!0,!1;const s=new w.WebGLRenderer({canvas:i,context:r,precision:n.precision,alpha:!0,antialias:n.antialias,logarithmicDepthBuffer:n.logarithmicDepthBuffer??!1!==n.postprocessing,premultipliedAlpha:!1});return s.autoClear=!0,s.outputColorSpace=w.SRGBColorSpace,s.toneMapping=w.ACESFilmicToneMapping,s.toneMappingExposure=n.exposure,s.shadowMap.enabled=!1!==n.shadowMap,s.shadowMap.type=w.PCFShadowMap,s.setClearColor(16777215,1),s.setPixelRatio(window.devicePixelRatio),s.setSize(t,e,!1),i.style.width="100%",i.style.height="100%",this._renderer=s,this._noSupportWebgl=!1,!0}catch(t){return this._noSupportWebgl=!0,!1}}setupCSS3D(t,e){const n=this.css3DRenderer.domElement;n.style.position="absolute",n.style.left="0",n.style.top="0",n.style.pointerEvents="none",e&&n.setAttribute("scene",e),n.style.setProperty("pointer-events","none","important")}createCSS3DRenderer(){return new l.CSS3DRenderer}setupComposer(t,e,n,i,r){const s=new w.WebGLRenderTarget(n,i,{samples:4});this._composer=new f.EffectComposer(this._renderer,s),this._composer.setSize(n,i);const o=new g.RenderPass(t,e);this._composer.addPass(o);const a=new m.OutlinePass(new w.Vector2(n,i),t,e);if(a.visibleEdgeColor.set(15885602),a.hiddenEdgeColor.set(15885602),a.edgeStrength=3,a.edgeThickness=1.5,a.edgeGlow=.5,a.pulsePeriod=0,r){const t=a.render.bind(a);a.render=(e,n,i,s,o)=>{const a=r.visible;r.visible=!1,t(e,n,i,s,o),r.visible=a}}return this._outlinePass=a,this._composer.addPass(a),this._composer.addPass(new b.SMAAPass),this._composer.addPass(new y.OutputPass),this._composer}setupLightComposer(t,e,n,i){const r=new w.WebGLRenderTarget(n,i);this._composer=new f.EffectComposer(this._renderer,r),this._composer.setSize(n,i),this._composer.addPass(new g.RenderPass(t,e));const s=new m.OutlinePass(new w.Vector2(n,i),t,e);return s.visibleEdgeColor.set(15885602),s.hiddenEdgeColor.set(15885602),s.edgeStrength=3,s.edgeThickness=1.5,s.edgeGlow=.5,s.pulsePeriod=0,this._outlinePass=s,this._composer.addPass(s),this._composer.addPass(new y.OutputPass),this._composer}get hasOutlinePass(){return!!this._outlinePass}updateRenderPassCamera(t){this._composer&&this._composer.passes.length>0&&(this._composer.passes[0].camera=t),this._outlinePass&&(this._outlinePass.renderCamera=t),this._camera&&(this._camera=t)}setOutlineObjects(t){this._outlinePass&&(this._outlinePass.selectedObjects=t)}resize(t,e){if(this._renderer?.setSize(t,e,!1),this._css3DRenderer?.setSize(t,e),this._composer?.setSize(t,e),this._hudCSS3DRenderer&&this._hudCSS3DCamera){const n=t/(this._hudCSS3DCamera.right-this._hudCSS3DCamera.left),i=e/(this._hudCSS3DCamera.top-this._hudCSS3DCamera.bottom),r=this._hudCSS3DRenderer.domElement;r.style.transformOrigin="0 0",r.style.transform=`scale(${n}, ${i})`}}teardownLightComposer(){this._composer&&(this._outlinePass=void 0,this._composer.dispose(),this._composer=void 0)}setDirectRenderTargets(t,e){this._scene=t,this._camera=e}render(){if(this._composer){if(this._composer.render(),this._renderer){const t=this._renderer.getContext();t.colorMask(!1,!1,!1,!0),t.clearColor(0,0,0,1),t.clear(t.COLOR_BUFFER_BIT),t.colorMask(!0,!0,!0,!0)}}else this._renderer&&this._scene&&this._camera&&this._renderer.render(this._scene,this._camera);this.renderHUD()}renderHUD(){if(!this._renderer||!this._hudScene||!this._hudCamera)return;if(0===this._hudScene.children.length)return;const t=this._renderer.autoClear;this._renderer.autoClear=!1,this._renderer.setRenderTarget(null),this._renderer.clearDepth(),this._renderer.render(this._hudScene,this._hudCamera),this._renderer.autoClear=t}renderCSS3D(t){if(this._css3DRenderer?.render(this.css3DScene,t),this._hudCSS3DRenderer&&this._hudCSS3DCamera&&this._hudCSS3DScene){const t=this._hudCSS3DRenderer.domElement;this._hudCSS3DScene.children.length>0?(t.style.display="",this._hudCSS3DRenderer.render(this._hudCSS3DScene,this._hudCSS3DCamera)):t.style.display="none"}}get hudCSS3DRenderer(){return this._hudCSS3DRenderer}getSize(){const t=new w.Vector2;return this._renderer?.getSize(t),{width:t.x,height:t.y}}destroy(){this._outlinePass=void 0,this._composer?.dispose(),this._renderer?.forceContextLoss(),this._renderer?.dispose(),delete this._composer,delete this._renderer,this.disposeHUD()}disposeHUD(){if(this._hudScene){[...this._hudScene.children].forEach(t=>{if(this._hudScene.remove(t),t.geometry&&t.geometry.dispose(),t.material){const e=t.material;e.map&&e.map.dispose(),e.dispose()}}),this._hudScene.environment&&(this._hudScene.environment.dispose(),this._hudScene.environment=null),this._hudScene=void 0}if(this._hudCamera=void 0,this._hudCSS3DScene){[...this._hudCSS3DScene.children].forEach(t=>this._hudCSS3DScene.remove(t)),this._hudCSS3DScene=void 0}this._hudCSS3DRenderer&&(this._hudCSS3DRenderer.domElement.remove(),this._hudCSS3DRenderer=void 0),this._hudCSS3DCamera=void 0}disposeCSS3DScene(){if(this._css3DScene){[...this._css3DScene.children].forEach(t=>this._css3DScene.remove(t))}}}class fu{constructor(){this.lights=[]}get hemiLight(){return this._hemiLight}get dirLight(){return this._dirLight}setup(t,e,n){this._scene=t,this._camera=e;const{hemisphere:i,directional:r,point:s}=n;if(this._hemiLight=new w.HemisphereLight(i.skyColor,i.groundColor,i.intensity),t.add(this._hemiLight),this.lights.push(this._hemiLight),r){if(this._dirLight=new w.DirectionalLight(r.color,r.intensity),r.position&&this._dirLight.position.set(...r.position),!1!==r.castShadow){this._dirLight.castShadow=!0;const t=r.shadowMapSize??2048;this._dirLight.shadow.mapSize.set(t,t),this._dirLight.shadow.bias=r.shadowBias??-5e-4;const e=this._dirLight.shadow.camera;e.near=.1,e.far=5e3,e.left=-1500,e.right=1500,e.top=1500,e.bottom=-1500}r.attachToCamera?e.add(this._dirLight):t.add(this._dirLight),this.lights.push(this._dirLight)}if(s){const e=new w.PointLight(s.color,s.intensity,void 0,s.decay);e.power=s.power,e.castShadow=s.castShadow,e.position.set(...s.position),e.shadow.camera.near=s.shadowNear,e.shadow.camera.far=s.shadowFar,t.add(e),this.lights.push(e)}}updateHemisphere(t){this._hemiLight&&(void 0!==t.skyColor&&this._hemiLight.color.set(t.skyColor),void 0!==t.groundColor&&this._hemiLight.groundColor.set(t.groundColor),void 0!==t.intensity&&(this._hemiLight.intensity=t.intensity))}updateDirectional(t){this._dirLight&&(void 0!==t.color&&this._dirLight.color.set(t.color),void 0!==t.intensity&&(this._dirLight.intensity=t.intensity))}setDirectionalFollowCamera(t){this._dirLight&&this._scene&&this._camera&&(this._dirLight.removeFromParent(),t?this._camera.add(this._dirLight):this._scene.add(this._dirLight))}setDirectionalAngle(t,e,n=1e3){if(!this._dirLight)return;const i=t*Math.PI/180,r=e*Math.PI/180,s=n;this._dirLight.position.set(s*Math.cos(r)*Math.sin(i),s*Math.sin(r),s*Math.cos(r)*Math.cos(i)),this._dirLight.target.position.set(0,0,0),!this._dirLight.target.parent&&this._scene&&this._scene.add(this._dirLight.target)}setDirectionalEnabled(t,e){if(t&&!this._dirLight&&this._camera){const t=e?.color??16777215,n=e?.intensity??2;this._dirLight=new w.DirectionalLight(t,n),this._camera.add(this._dirLight),this.lights.push(this._dirLight)}else!t&&this._dirLight&&(this._dirLight.removeFromParent(),this._dirLight.dispose(),this.lights=this.lights.filter(t=>t!==this._dirLight),this._dirLight=void 0)}destroy(){this.lights.forEach(t=>t.dispose()),this.lights=[],this._hemiLight=void 0,this._dirLight=void 0,this._scene=void 0,this._camera=void 0}}const gu=1e-6;class mu{constructor(){this._enabled=!0,this._state=0,this._autoRotate=!1,this._autoRotateSpeed=2,this._dampingFactor=.15,this._rotateSpeed=.1,this._panSpeed=1,this._dollyStart=0,this._lastScale=1,this._floorConstraint=!1,this._spherical=new w.Spherical,this._sphericalDelta=new w.Spherical,this._panOffset=new w.Vector3,this._target=new w.Vector3,this._target0=new w.Vector3,this._position0=new w.Vector3,this._rotateStart=new w.Vector2,this._rotateEnd=new w.Vector2,this._rotateDelta=new w.Vector2,this._panStart=new w.Vector2,this._panEnd=new w.Vector2,this._panDelta=new w.Vector2,this._offset=new w.Vector3,this._lastPosition=new w.Vector3,this._lastQuaternion=new w.Quaternion,this._panLeftV=new w.Vector3,this._panUpV=new w.Vector3,this._panCalcOffset=new w.Vector3}get isActive(){return!!this._camera}get target(){return this._target.clone()}restoreTarget(t){this._target.copy(t),this.update()}get _isOrthoLocked(){return!!this._camera?.isOrthographicCamera}setup(t,e){this._camera=t,this._host=e,this._target.set(0,0,0),this._target0.copy(this._target),this._position0.copy(t.position),this._quat=(new w.Quaternion).setFromUnitVectors(t.up,new w.Vector3(0,1,0)),this._quatInverse=this._quat.clone().invert();const n=e.state;this._autoRotate=!e.app?.isEditMode&&(n.autoRotate||"orbit"===n.cameraAutoPlay)||!1,this._autoRotateSpeed=n.rotationSpeed||2,this._floorConstraint=!e.app?.isEditMode&&!!n.cameraFloorConstraint||!1,this.update()}setEnabled(t){this._enabled=t}setOnUserInteraction(t){this._onUserInteraction=t}onDragStart(t){this._enabled&&(this._onUserInteraction?.(),this._isOrthoLocked?(this._state=2,this._panStart.set(t.offsetX,t.offsetY)):(this._state=t.altKey?2:t.ctrlKey||t.metaKey?3:1,1===this._state?this._rotateStart.set(t.offsetX,t.offsetY):3===this._state?this._dollyStart=t.offsetY:this._panStart.set(t.offsetX,t.offsetY)))}onDragMove(t){if(this._enabled)if(this._isOrthoLocked)this._state=2,this._handlePanMove(t.offsetX,t.offsetY);else if(this._state=t.altKey?2:t.ctrlKey||t.metaKey?3:1,3===this._state){const e=t.offsetY-this._dollyStart;this._dollyStart=t.offsetY;const n=1+.005*e;this.dollyAtCursor(n,0,0)}else 1===this._state?this._handleRotateMove(t.offsetX,t.offsetY):this._handlePanMove(t.offsetX,t.offsetY)}onDragEnd(t){this._state=0,this._host?.invalidate()}onTouchStart(t){this._onUserInteraction?.();const e=t.touches[0],n=e.offsetX??e.pageX,i=e.offsetY??e.pageY;if(this._isOrthoLocked)return this._panStart.set(n,i),void(this._state=5);switch(t.touches.length){case 1:this._rotateStart.set(n,i),this._state=4;break;case 2:this._lastScale=t.scale||1,this._panStart.set(n,i),this._state=5;break;default:this._state=0}}onTouchMove(t){const e=t.touches[0],n=e.offsetX??e.pageX,i=e.offsetY??e.pageY;if(this._isOrthoLocked)this._handlePanMove(n,i);else switch(t.touches.length){case 1:if(4!==this._state)return;this._handleRotateMove(n,i);break;case 2:{if(5!==this._state)return;const e=t.scale||1;if(Math.abs(this._lastScale-e)>.01){const t=this._lastScale/e;this._lastScale=e,this.dollyAtCursor(t,0,0)}else this._handlePanMove(n,i);break}default:this._state=0}}onTouchEnd(t){this._lastScale=1,this._state=0}onKeyDown(t){switch(t.code){case"ArrowUp":this._pan(0,7);break;case"ArrowDown":this._pan(0,-7);break;case"ArrowLeft":this._pan(7,0);break;case"ArrowRight":this._pan(-7,0);break;default:return}this.update()}update(){const t=this._camera,e=t.position;if(this._isOrthoLocked)return this._panOffset.lengthSq()>0&&(this._target.add(this._panOffset),e.add(this._panOffset),this._panOffset.set(0,0,0)),(this._lastPosition.distanceToSquared(e)>gu||8*(1-this._lastQuaternion.dot(t.quaternion))>gu)&&(this._lastPosition.copy(e),this._lastQuaternion.copy(t.quaternion),this._host?.invalidate(),!0);if(this._offset.copy(e).sub(this._target),this._offset.applyQuaternion(this._quat),this._spherical.setFromVector3(this._offset),this._spherical.theta+=this._sphericalDelta.theta,this._autoRotate&&0===this._state){const t=2*Math.PI/60*(this._autoRotateSpeed/60);this._spherical.theta-=t}this._spherical.phi+=this._sphericalDelta.phi,this._spherical.phi=Math.max(0,Math.min(Math.PI,this._spherical.phi)),this._spherical.makeSafe(),this._target.add(this._panOffset),this._offset.setFromSpherical(this._spherical),this._offset.applyQuaternion(this._quatInverse),e.copy(this._target).add(this._offset),this._floorConstraint&&(this._target.y<0&&(this._target.y=0),e.y<0&&(e.y=0)),t.lookAt(this._target);const n=1-this._dampingFactor;return this._sphericalDelta.theta*=n,this._sphericalDelta.phi*=n,this._panOffset.set(0,0,0),(this._lastPosition.distanceToSquared(e)>gu||8*(1-this._lastQuaternion.dot(t.quaternion))>gu)&&(this._lastPosition.copy(e),this._lastQuaternion.copy(t.quaternion),this._host?.invalidate(),!0)}reset(){this._target.copy(this._target0),this._camera.position.copy(this._position0),this._camera.updateProjectionMatrix(),this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0),this._state=0,this.update()}pinResetPosition(){this._camera&&(this._position0.copy(this._camera.position),this._target0.copy(this._target))}setCamera(t){this._camera=t,this._target.set(0,0,0),this._position0.copy(t.position),this._quat=(new w.Quaternion).setFromUnitVectors(t.up,new w.Vector3(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0),this._lastPosition.copy(t.position),this._lastQuaternion.copy(t.quaternion),this._state=0,t.updateMatrixWorld(!0)}isAutoRotating(){return this._autoRotate}setAutoRotate(t){this._autoRotate=t,this._host?.invalidate()}setFloorConstraint(t){this._floorConstraint=t,this.update()}markCameraChanged(){this._host?.invalidate()}dollyAtCursor(t,e,n){this._onUserInteraction?.();const i=this._camera,r=i.position.distanceTo(this._target),s=Math.max(1,Math.min(5e4,r*t));if(Math.abs(s-r)<gu)return;const o=Math.tan(i.fov/2*Math.PI/180)/i.zoom,a=r-s,c=e*a*o*i.aspect,l=n*a*o;this._panLeftV.setFromMatrixColumn(i.matrix,0).multiplyScalar(c),this._panUpV.setFromMatrixColumn(i.matrix,1).multiplyScalar(l),this._target.add(this._panLeftV).add(this._panUpV),i.position.add(this._panLeftV).add(this._panUpV),this._panCalcOffset.subVectors(i.position,this._target).normalize().multiplyScalar(s),i.position.copy(this._target).add(this._panCalcOffset),this._floorConstraint&&(this._target.y<0&&(this._target.y=0),i.position.y<0&&(i.position.y=0)),this._host?.invalidate()}zoomOrthoAtCursor(t,e,n){this._onUserInteraction?.();const i=this._camera,r=i.zoom,s=Math.max(.1,Math.min(20,r*t)),o=e*(i.right-i.left)/2*(1/r-1/s),a=n*(i.top-i.bottom)/2*(1/r-1/s);this._panLeftV.setFromMatrixColumn(i.matrix,0).multiplyScalar(o),this._panUpV.setFromMatrixColumn(i.matrix,1).multiplyScalar(a),this._target.add(this._panLeftV).add(this._panUpV),i.position.add(this._panLeftV).add(this._panUpV),i.zoom=s,i.updateProjectionMatrix(),this._host?.invalidate()}destroy(){delete this._camera,delete this._host}_getViewportSize(){const t=this._host;if(!t)return{width:1,height:1};const e=t?.element;if(e){const t=e.getBoundingClientRect();if(t.width>0&&t.height>0)return{width:t.width,height:t.height}}const n=t.bounds;return{width:Math.abs(n?.width)||1,height:Math.abs(n?.height)||1}}_handleRotateMove(t,e){this._rotateEnd.set(t,e),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart);const{width:n,height:i}=this._getViewportSize();this._sphericalDelta.theta-=2*Math.PI*this._rotateDelta.x/n*this._rotateSpeed,this._sphericalDelta.phi-=2*Math.PI*this._rotateDelta.y/i*this._rotateSpeed,this._rotateStart.copy(this._rotateEnd),this._host?.invalidate()}_handlePanMove(t,e){this._panEnd.set(t,e),this._panDelta.subVectors(this._panEnd,this._panStart),this._isOrthoLocked?this._panOrtho(this._panDelta.x,this._panDelta.y):this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this._host?.invalidate()}_panOrtho(t,e){const n=this._camera,{width:i,height:r}=this._getViewportSize();this._panLeftV.setFromMatrixColumn(n.matrix,0),this._panLeftV.multiplyScalar(-t*(n.right-n.left)/n.zoom/i),this._panUpV.setFromMatrixColumn(n.matrix,1),this._panUpV.multiplyScalar(e*(n.top-n.bottom)/n.zoom/r),this._target.add(this._panLeftV).add(this._panUpV),n.position.add(this._panLeftV).add(this._panUpV)}panByPixels(t,e){this._onUserInteraction?.(),this._pan(t,e),this._target.add(this._panOffset),this._camera.position.add(this._panOffset),this._panOffset.set(0,0,0),this._host?.invalidate()}_pan(t,e){t*=this._panSpeed,e*=this._panSpeed;const{width:n,height:i}=this._getViewportSize(),r=this._camera;if(r.isPerspectiveCamera){this._panCalcOffset.copy(r.position).sub(this._target);let n=this._panCalcOffset.length();n*=Math.tan(r.fov/2*Math.PI/180),this._panLeftV.setFromMatrixColumn(r.matrix,0),this._panLeftV.multiplyScalar(-2*t*n/i),this._panOffset.add(this._panLeftV),this._panUpV.setFromMatrixColumn(r.matrix,1),this._panUpV.multiplyScalar(2*e*n/i),this._panOffset.add(this._panUpV)}else r.isOrthographicCamera&&(this._panLeftV.setFromMatrixColumn(r.matrix,0),this._panLeftV.multiplyScalar(-t*(r.right-r.left)/r.zoom/n),this._panOffset.add(this._panLeftV),this._panUpV.setFromMatrixColumn(r.matrix,1),this._panUpV.multiplyScalar(e*(r.top-r.bottom)/r.zoom/i),this._panOffset.add(this._panUpV))}}class yu{constructor(){this._mouse=new w.Vector2,this._raycaster=new w.Raycaster}get mouse(){return this._mouse}get lastFocused(){return this._lastFocused}set lastFocused(t){this._lastFocused=t}get lastHovered(){return this._lastHovered}set lastHovered(t){this._lastHovered=t}updateMouseNDC(t,e,n,i,r,s){this._mouse.x=(t-n)/r*2-1,this._mouse.y=-(e-i)/s*2+1}getObjectByRaycast(t,e){const n=this.getObjectsByRaycast(t,e);if(n&&n.length>0)for(const t of n){if(!this._isWorldVisible(t.object))continue;let e=t.object;for(;e;){if(e.userData.context)return e;e=e.parent}}}_isWorldVisible(t){let e=t;for(;e;){if(!e.visible)return!1;e=e.parent}return!0}getObjectsByRaycast(t,e){return this._raycaster.setFromCamera(this._mouse,t),this._raycaster.intersectObjects(e.children,!0)}setHUD(t,e){this._hudScene=t,this._hudCamera=e}handleClick(t,e,n){let i;this._lastFocused&&(this._lastFocused.focused=!1),this._hudScene&&this._hudCamera&&(i=this.getObjectByRaycast(this._hudCamera,this._hudScene)),i||(i=this.getObjectByRaycast(t,e));const r=i?.userData.context;return r&&(r.focused=!0,this._lastFocused=r,r.component?.trigger("click",n)),r}handleHover(t,e,n){let i;this._hudScene&&this._hudCamera&&(i=this.getObjectByRaycast(this._hudCamera,this._hudScene)),i||(i=this.getObjectByRaycast(t,e));const r=i?.userData.context;r!==this._lastHovered&&(this._lastHovered&&(this._lastHovered.component?.trigger("mouseleave",n),this._lastHovered=void 0),r&&(this._lastHovered=r,this._lastHovered.component?.trigger("mouseenter",n)))}destroy(){this._lastFocused=void 0,this._lastHovered=void 0,this._hudScene=void 0,this._hudCamera=void 0}}const bu=Math.PI/180*15;class _u{constructor(){this._mode="translate",this._isDragging=!1}get controls(){return this._controls}get mode(){return this._mode}get attached(){return this._attached}get isAttached(){return!!this._attached}get isDragging(){return this._isDragging}get isEngaged(){return!!this._controls?.axis}setup(t,e,n){this.destroy(),this._scene=n;const i=document.createElement("div");i.style.cssText="position:absolute;left:0;top:0;width:100%;height:100%;pointer-events:none",i.setPointerCapture=()=>{},i.releasePointerCapture=()=>{},e.appendChild(i),this._proxyElement=i,this._controls=new _.TransformControls(t,i),this._controls.setMode(this._mode),n.add(this._controls.getHelper()),this._controls.addEventListener("dragging-changed",t=>{this._isDragging=t.value,this.onDraggingChanged?.(t.value)}),this._controls.addEventListener("change",()=>{this._attached&&this.onObjectChange?.(this._attached)})}forwardEvent(t,e){if(!this._proxyElement||!this._controls)return;"rotate"===this._mode&&this._controls.setRotationSnap(t.shiftKey?bu:null);const n=new PointerEvent(e,{clientX:t.clientX,clientY:t.clientY,button:"pointermove"===e?-1:t.button??0,pointerId:1,pointerType:"mouse",bubbles:!0});this._proxyElement.dispatchEvent(n)}forwardTouch(t,e){if(!this._proxyElement||!this._controls)return;const n=new PointerEvent(e,{clientX:t.clientX,clientY:t.clientY,button:"pointermove"===e?-1:0,pointerId:t.identifier+10,pointerType:"touch",bubbles:!0});this._proxyElement.dispatchEvent(n)}setMode(t){this._mode=t,this._controls?.setMode(t)}attach(t){this._attached=t,this._controls?.attach(t),this._controls?.getHelper().updateMatrixWorld(!0),this.onAttachChanged?.(!0)}detach(){this._controls?.detach(),this._attached=void 0,this.onAttachChanged?.(!1)}setRotationSnap(t){this._controls&&this._controls.setRotationSnap(t?bu:null)}updateCamera(t){this._controls&&(this._controls.camera=t)}destroy(){this._controls&&(this._controls.detach(),this._controls.dispose(),this._scene&&this._scene.remove(this._controls.getHelper()),this._controls=void 0),this._proxyElement?.parentNode&&this._proxyElement.parentNode.removeChild(this._proxyElement),this._proxyElement=void 0,this._attached=void 0,this._isDragging=!1}}const vu=.01;function xu(t){const[e,n,i]=t,r=Math.abs(e-1),s=Math.abs(n-1),o=Math.abs(i-1);return r<vu&&s<vu&&o<vu?null:r>=s&&r>=o?e:s>=r&&s>=o?n:i}class wu{constructor(){this._mouseDownAltKey=!1}captureAltKey(t){this._mouseDownAltKey=t}setupCallbacks(t,e,n,i){t.onDraggingChanged=r=>{e.setEnabled(!r);const s=n();s&&(i?.onDraggingChanged?.(r),r?(this._onDragStart(t,s),s.hostElement&&this._showInfoOverlay(s.hostElement)):(this._hideInfoOverlay(),this._onDragEnd(t,s)),s.app?.commander?.execute(null),s.invalidate())},t.onObjectChange=e=>{if(this._syncFromGizmo(t,e),this._infoOverlay){const n=t.controls?.axis??null;this._updateInfoOverlay(t.mode,e,n)}n()?.invalidate()},t.onAttachChanged=t=>{i?.onAttachChanged?.(t)}}_onDragStart(t,e){this._mouseDownAltKey&&"translate"===t.mode&&this._performAltDragDuplicate(e);const n=e.root?.selected||[];n.length>1&&this._captureMultiSelectState(t,n);const i=t.attached;i&&("rotate"!==t.mode||this._gizmoInitialRotation?"translate"!==t.mode||this._dragStartPosition||(this._dragStartPosition=i.position.clone()):this._gizmoInitialRotation=i.rotation.clone()),"scale"===t.mode&&this._captureScalePreDrag(t)}_performAltDragDuplicate(t){const e=t.root?.selected||[];if(0===e.length||!t.root)return;const n=t.root,i=[];for(const t of e){const e=t.parent,r=new Map,s=Rc(t,t=>{const e=n.getNewRefid();return void 0!==t&&r.set(t,e),e});s.replaceRefids(r),e.addComponent(s),i.push({component:s,to_container:e})}this._altDragDuplicates=i}_captureMultiSelectState(t,e){const n=t.attached;if(n)if("translate"===t.mode){const t=new Map,i=n.position;for(let n=1;n<e.length;n++){const r=e[n]._realObject;r?.object3d&&r.gizmoTransformable&&t.set(r,r.object3d.position.clone().sub(i))}this._multiSelectOffsets=t}else if("rotate"===t.mode){this._gizmoInitialRotation=n.rotation.clone();const t=new Map;for(let n=1;n<e.length;n++){const i=e[n]._realObject;i?.object3d&&i.gizmoTransformable&&t.set(i,i.object3d.rotation.clone())}this._multiSelectInitialRotations=t}else if("scale"===t.mode){const t=new Map;for(let n=1;n<e.length;n++){const i=e[n],r=i._realObject;if(r?.object3d&&r.gizmoTransformable){const{left:e,top:n,width:s,height:o}=i.bounds,{zPos:a=0}=i.state,c=i.state.depth;t.set(r,{left:e,top:n,width:s,height:o,depth:c,zPos:a,scaleX:r.object3d.scale.x,scaleY:r.object3d.scale.y,scaleZ:r.object3d.scale.z})}}this._multiSelectPreDragDimensions=t}}_captureScalePreDrag(t){const e=t.attached,n=e?.userData.context;if(!n||!e)return;const{left:i,top:r,width:s,height:o}=n.component.bounds,{zPos:a=0}=n.component.state,c=n.component.state.depth??n.effectiveDepth;this._preDragDimension={left:i,top:r,width:s,height:o,depth:c,zPos:a},this._preDragScale={x:e.scale.x,y:e.scale.y,z:e.scale.z},this._preDragEffectiveDepth=void 0,this._scaleAnchorSign=this._computeAnchorSign(t,e),this._preDragAttachedPosition=e.position.clone()}_computeAnchorSign(t,e){const n=t.controls;if(!n)return{x:0,y:0,z:0};const i=n.axis;if(!i||"XYZE"===i)return{x:0,y:0,z:0};if(i.includes("X")&&i.includes("Y")&&i.includes("Z"))return{x:0,y:0,z:0};const r=new w.Quaternion;e.getWorldQuaternion(r),r.invert();const s=n.pointStart.clone().applyQuaternion(r),o=.001,a={x:0,y:0,z:0};return i.includes("X")&&Math.abs(s.x)>o&&(a.x=Math.sign(s.x)),i.includes("Y")&&Math.abs(s.y)>o&&(a.y=Math.sign(s.y)),i.includes("Z")&&Math.abs(s.z)>o&&(a.z=Math.sign(s.z)),a}_onDragEnd(t,e){if(this._altDragDuplicates&&this._altDragDuplicates.length>0&&(e.app?.commander.execute(new zc({changes:this._altDragDuplicates})),this._altDragDuplicates=void 0),this._multiSelectOffsets=void 0,this._gizmoInitialRotation=void 0,this._multiSelectInitialRotations=void 0,this._dragStartPosition=void 0,this._preDragDimension){const e=t.attached,n=e?.userData.context;if(n&&(void 0!==this._preDragEffectiveDepth&&n.applyDimensionFromGizmo({depth:this._preDragEffectiveDepth}),n.update()),this._multiSelectPreDragDimensions)for(const[t]of this._multiSelectPreDragDimensions)t.update()}const n=e.root?.selected||[];for(const e of n){const n=e._realObject;n?.onGizmoDragEnd(t.mode)}for(const t of n){let e=t.parent;for(;e?.isGroup?.();){const t=[];e._realObject&&t.push(e._realObject);for(const n of e.components||[])n._realObject&&t.push(n._realObject);for(const e of t)e._suppressOnchange=!0;e.calculateBounds();for(const e of t)e._suppressOnchange=!1,e.updateTransform();e=e.parent}}this._preDragDimension=void 0,this._preDragScale=void 0,this._preDragEffectiveDepth=void 0,this._multiSelectPreDragDimensions=void 0,this._scaleAnchorSign=void 0,this._preDragAttachedPosition=void 0}_syncFromGizmo(t,e){const n=e.userData.context;if(n)if("scale"===t.mode&&this._preDragDimension&&this._preDragScale){const{ratioX:t,ratioY:i,ratioZ:r,sign:s}=this._syncDimensionFromGizmo(n,e);if(this._multiSelectPreDragDimensions)for(const[e,n]of this._multiSelectPreDragDimensions)e.applyDimensionFromGizmo(this._computeAnchorProps(n,t,i,r,s))}else{if(n.syncFromObject3D(),"translate"===t.mode&&this._applyGroundSnap(e,n),this._multiSelectOffsets){const n=e.position;for(const[e,i]of this._multiSelectOffsets)e.object3d&&(e.object3d.position.copy(n).add(i),"translate"===t.mode&&this._applyGroundSnap(e.object3d,e),e.syncFromObject3D())}if(this._multiSelectInitialRotations&&this._gizmoInitialRotation){const t=e.rotation.x-this._gizmoInitialRotation.x,n=e.rotation.y-this._gizmoInitialRotation.y,i=e.rotation.z-this._gizmoInitialRotation.z;for(const[e,r]of this._multiSelectInitialRotations)e.object3d&&(e.object3d.rotation.set(r.x+t,r.y+n,r.z+i),e.syncFromObject3D())}}}_applyGroundSnap(t,e){const n=e.effectiveDepth/2,i=t.position.y-n,r=Math.abs(i);if(r<2)t.position.y=n,e.syncFromObject3D();else if(r<10){const s=(r-2)/8,o=1-s*s;t.position.y=n+i*(1-o),e.syncFromObject3D()}}_syncDimensionFromGizmo(t,e){const n=this._preDragDimension,i=this._preDragScale;let r={...this._scaleAnchorSign??{x:0,y:0,z:0}},s=e.scale.x/i.x,o=e.scale.y/i.y,a=e.scale.z/i.z;if(t.component.state.ratioLock){const t=xu([s,o,a]);if(t){s=o=a=t,e.scale.set(t*i.x,t*i.y,t*i.z);const n=r.x||r.y||r.z;n&&(r={x:n,y:n,z:n})}}return t.applyDimensionFromGizmo(this._computeAnchorProps(n,s,o,a,r)),!this._preDragAttachedPosition||0===r.x&&0===r.y&&0===r.z||this._applyAnchorPositionCorrection(e,n,i,r),{ratioX:s,ratioY:o,ratioZ:a,sign:r}}_computeAnchorProps(t,e,n,i,r){const s=t.width*e,o=t.height*i,a=r.x>0?0:r.x<0?t.width-s:(t.width-s)/2,c=r.z>0?0:r.z<0?t.height-o:(t.height-o)/2,l={left:t.left+a,top:t.top+c,width:s,height:o};if(void 0!==t.depth){const e=t.depth*n,i=r.y>0?0:r.y<0?t.depth-e:(t.depth-e)/2;l.depth=e,l.zPos=t.zPos+i}return l}_applyAnchorPositionCorrection(t,e,n,i){const r=new w.Vector3(i.x*(t.scale.x-n.x)*e.width/2,i.y*(t.scale.y-n.y)*(e.depth??0)/2,i.z*(t.scale.z-n.z)*e.height/2),s=new w.Quaternion;t.getWorldQuaternion(s),r.applyQuaternion(s);const o=this._preDragAttachedPosition;t.position.set(o.x+r.x,o.y+r.y,o.z+r.z)}_showInfoOverlay(t){if(this._infoHostElement=t,this._infoOverlay)return;const e=document.createElement("div");e.style.cssText="\n position: absolute; z-index: 10000; pointer-events: none;\n left: 50%; top: 16px; transform: translateX(-50%);\n padding: 6px 16px; border-radius: 6px;\n background: rgba(0,0,0,0.8); color: #fff;\n font: bold 16px/1.4 'Pretendard', system-ui, sans-serif;\n letter-spacing: 0.5px;\n white-space: nowrap; opacity: 0; transition: opacity 0.15s;\n box-shadow: 0 2px 8px rgba(0,0,0,0.3);\n ",t.style.position="relative",t.appendChild(e),this._infoOverlay=e,requestAnimationFrame(()=>{e.style.opacity="1"})}_updateInfoOverlay(t,e,n){if(!this._infoOverlay)return;const i=t=>(t>=0?"+":"")+t.toFixed(1);if("rotate"===t){if(!this._gizmoInitialRotation)return;const t=180/Math.PI,n=(e.rotation.x-this._gizmoInitialRotation.x)*t,r=(e.rotation.y-this._gizmoInitialRotation.y)*t,s=(e.rotation.z-this._gizmoInitialRotation.z)*t,o=[Math.abs(n),Math.abs(r),Math.abs(s)],a=o.indexOf(Math.max(...o)),c=["X","Y","Z"],l=[n,r,s],h=[e.rotation.x*t,e.rotation.y*t,e.rotation.z*t];this._infoOverlay.textContent=`↻ ${c[a]}: ${h[a].toFixed(1)}° (${i(l[a])})`}else if("translate"===t){if(!this._dragStartPosition)return;const t=e.position.clone().sub(this._dragStartPosition),n=e.position,r=(t,e,n)=>Math.abs(n)<.05?`${t}:${e.toFixed(0)}`:`${t}:${e.toFixed(0)}(${i(n)})`;this._infoOverlay.textContent=`↔ ${r("X",n.x,t.x)} ${r("Y",n.y,t.y)} ${r("Z",n.z,t.z)}`}else if("scale"===t){if(!this._preDragScale)return;this._infoOverlay.textContent=this._formatScaleInfo(e,n)}}_formatScaleInfo(t,e){const n=this._preDragScale,i=this._preDragDimension,r=t.scale.x/(n.x||1),s=t.scale.y/(n.y||1),o=t.scale.z/(n.z||1),a=i?i.width*r:t.scale.x,c=null!=i?.depth?i.depth*s:t.scale.y,l=i?i.height*o:t.scale.z,h=i?i.width*(r-1):t.scale.x-n.x,d=null!=i?.depth?i.depth*(s-1):t.scale.y-n.y,u=i?i.height*(o-1):t.scale.z-n.z,p=t=>(t>=0?"+":"")+t.toFixed(0),f=t=>t.toFixed(0);switch(e){case"X":return`⤢ W ${f(a)}px (${p(h)})`;case"Y":return`⤢ D ${f(c)}px (${p(d)})`;case"Z":return`⤢ H ${f(l)}px (${p(u)})`}return Math.abs(r-s)<.01&&Math.abs(s-o)<.01?`⤢ ×${r.toFixed(2)} (${f(a)}×${f(c)}×${f(l)})`:`⤢ W:${f(a)}(${p(h)}) D:${f(c)}(${p(d)}) H:${f(l)}(${p(u)})`}_hideInfoOverlay(){this._infoOverlay&&(this._infoOverlay.remove(),this._infoOverlay=void 0),this._infoHostElement=void 0}}class Mu{constructor(){this._mouseIsDown=!1,this._isDragging=!1,this._touchGizmoCaptured=!1,this._mouseDownPos={x:0,y:0}}get hostElement(){return this._hostElement}setup(t,e,n){this.cleanup(),this._hostElement=t,this._gizmo=e.gizmo,this._controls=e.controls,this._camera=e.camera,this._scene=e.scene,this._event=e.event,this._delegate=n,t.hasAttribute("tabindex")||t.setAttribute("tabindex","0"),t.style.outline="none";const i={mousedown:t=>this._onMouseDown(t),mousemove:t=>this._onMouseMove(t),wheel:t=>{t.stopPropagation(),this._delegate.handleWheel(t)},dblclick:t=>{t.stopPropagation(),this.updateMouseNDCFromClient(t.clientX,t.clientY),this._delegate.handleDblClick(t)},contextmenu:t=>{t.preventDefault()},touchstart:t=>{if(t.stopPropagation(),1===t.touches?.length&&this._gizmo?.isAttached){const e=t.touches[0];if(this._gizmo.forwardTouch(e,"pointermove"),this._gizmo.isEngaged)return this._gizmo.forwardTouch(e,"pointerdown"),this._touchGizmoCaptured=!0,void t.preventDefault()}this._touchGizmoCaptured=!1,this._delegate.handleTouchStart(t)},touchmove:t=>{if(t.stopPropagation(),this._touchGizmoCaptured&&1===t.touches.length)return this._gizmo.forwardTouch(t.touches[0],"pointermove"),void t.preventDefault();this._delegate.handleTouchMove(t)},touchend:t=>{if(t.stopPropagation(),this._touchGizmoCaptured){const e=t.changedTouches[0];return e&&this._gizmo.forwardTouch(e,"pointerup"),void(this._touchGizmoCaptured=!1)}this._delegate.handleTouchEnd(t)},keydown:t=>{!this._delegate.handleKeyDown(t)||t.ctrlKey||t.metaKey||t.stopPropagation()},keyup:t=>{(this._delegate.handleKeyUp?.(t)??!1)&&t.stopPropagation()}};t.addEventListener("mousedown",i.mousedown),t.addEventListener("mousemove",i.mousemove),t.addEventListener("wheel",i.wheel),t.addEventListener("dblclick",i.dblclick),t.addEventListener("contextmenu",i.contextmenu),t.addEventListener("touchstart",i.touchstart,{passive:!1}),t.addEventListener("touchmove",i.touchmove,{passive:!1}),t.addEventListener("touchend",i.touchend),t.addEventListener("keydown",i.keydown),t.addEventListener("keyup",i.keyup),this._boundHandlers=i}cleanup(){this._removeDocCapture();const t=this._hostElement,e=this._boundHandlers;t&&e&&(t.removeEventListener("mousedown",e.mousedown),t.removeEventListener("mousemove",e.mousemove),t.removeEventListener("wheel",e.wheel),t.removeEventListener("dblclick",e.dblclick),t.removeEventListener("contextmenu",e.contextmenu),t.removeEventListener("touchstart",e.touchstart),t.removeEventListener("touchmove",e.touchmove),t.removeEventListener("touchend",e.touchend),t.removeEventListener("keydown",e.keydown),t.removeEventListener("keyup",e.keyup),t.removeAttribute("tabindex"),t.style.outline=""),this._boundHandlers=void 0,this._hostElement=void 0,this._mouseIsDown=!1,this._isDragging=!1}forceCleanupDragState(){this._removeDocCapture(),this._mouseIsDown=!1,this._isDragging=!1}clientToElementCoords(t,e){const n=this._hostElement;if(!n)return{x:t,y:e};const i=n.getBoundingClientRect();return{x:t-i.left,y:e-i.top}}updateMouseNDCFromClient(t,e){const n=this._hostElement?.getBoundingClientRect();if(!n||0===n.width||0===n.height)return;const i=t-n.left,r=e-n.top;this._event.updateMouseNDC(i,r,0,0,n.width,n.height)}_onMouseDown(t){if(t.stopPropagation(),0!==t.button)return void(this._mouseIsDown&&(this._removeDocCapture(),this._isDragging&&(this._gizmo?.forwardEvent(new MouseEvent("pointerup",{bubbles:!1}),"pointerup"),this._controls?.onDragEnd?.({offsetX:t.offsetX,offsetY:t.offsetY})),this._mouseIsDown=!1,this._isDragging=!1));if(this._hostElement.focus(),this._removeDocCapture(),this._mouseIsDown=!1,this._isDragging=!1,this._delegate.isPlacementMode())return void this._delegate.handlePlacementClick(t);if(this._delegate.isSpacePanning?.()??!1)return this._mouseIsDown=!0,this._isDragging=!1,this._mouseDownPos={x:t.clientX,y:t.clientY},this._docMoveHandler=t=>{t.stopPropagation();const e=t.clientX-this._mouseDownPos.x,n=t.clientY-this._mouseDownPos.y;if(!this._isDragging){if(e*e+n*n<Mu.DRAG_THRESHOLD)return;this._isDragging=!0;const t=this.clientToElementCoords(this._mouseDownPos.x,this._mouseDownPos.y);this._controls.onDragStart({offsetX:t.x,offsetY:t.y,altKey:!0})}const i=this.clientToElementCoords(t.clientX,t.clientY);this._controls.onDragMove({offsetX:i.x,offsetY:i.y,altKey:!0})},this._docUpHandler=t=>{if(t.stopPropagation(),this._removeDocCapture(),this._isDragging){const e=this.clientToElementCoords(t.clientX,t.clientY);this._controls.onDragEnd({offsetX:e.x,offsetY:e.y})}this._mouseIsDown=!1,this._isDragging=!1},document.addEventListener("mousemove",this._docMoveHandler,!0),void document.addEventListener("mouseup",this._docUpHandler,!0);if(t.shiftKey&&!t.altKey&&!this._gizmo?.isEngaged){const e=this.clientToElementCoords(t.clientX,t.clientY);return this._mouseIsDown=!0,this._isDragging=!1,this._mouseDownPos={x:t.clientX,y:t.clientY},this._docMoveHandler=t=>{t.stopPropagation();const n=t.clientX-this._mouseDownPos.x,i=t.clientY-this._mouseDownPos.y;if(!this._isDragging){if(n*n+i*i<Mu.DRAG_THRESHOLD)return;this._isDragging=!0,this._delegate.handleBoxSelectionStart?.(e.x,e.y)}const r=this.clientToElementCoords(t.clientX,t.clientY);this._delegate.handleBoxSelectionUpdate?.(r.x,r.y)},this._docUpHandler=t=>{if(t.stopPropagation(),this._removeDocCapture(),this._isDragging)this._delegate.handleBoxSelectionEnd?.(t.shiftKey,t.ctrlKey||t.metaKey);else{const e=this.clientToElementCoords(t.clientX,t.clientY);this.updateMouseNDCFromClient(t.clientX,t.clientY),this._delegate.handleClickAt(e.x,e.y,t)}this._mouseIsDown=!1,this._isDragging=!1},document.addEventListener("mousemove",this._docMoveHandler,!0),void document.addEventListener("mouseup",this._docUpHandler,!0)}if(this.updateMouseNDCFromClient(t.clientX,t.clientY),this._delegate.tryVertexDragStart?.(t))return this._mouseIsDown=!0,this._isDragging=!0,this._mouseDownPos={x:t.clientX,y:t.clientY},this._docMoveHandler=t=>{t.stopPropagation(),this.updateMouseNDCFromClient(t.clientX,t.clientY),this._delegate.handleVertexDragMove?.(t)},this._docUpHandler=t=>{t.stopPropagation(),this._removeDocCapture(),this._delegate.handleVertexDragEnd?.(t),this._mouseIsDown=!1,this._isDragging=!1},document.addEventListener("mousemove",this._docMoveHandler,!0),void document.addEventListener("mouseup",this._docUpHandler,!0);this._delegate.captureMouseDownAltKey(t.altKey),this._gizmo.forwardEvent(t,"pointermove"),this._gizmo.forwardEvent(t,"pointerdown");let e=this._gizmo.isDragging;!e&&t.altKey&&this._delegate.tryAltClickSelect(t)&&(this._gizmo.forwardEvent(t,"pointermove"),this._gizmo.forwardEvent(t,"pointerdown"),e=this._gizmo.isDragging),this._mouseIsDown=!0,this._isDragging=!1,this._mouseDownPos={x:t.clientX,y:t.clientY},this._docMoveHandler=t=>{if(t.stopPropagation(),e)return void this._gizmo.forwardEvent(t,"pointermove");const n=t.clientX-this._mouseDownPos.x,i=t.clientY-this._mouseDownPos.y;if(!this._isDragging){if(n*n+i*i<Mu.DRAG_THRESHOLD)return;this._isDragging=!0;const e=this.clientToElementCoords(this._mouseDownPos.x,this._mouseDownPos.y);this._controls.onDragStart({offsetX:e.x,offsetY:e.y,altKey:t.altKey,ctrlKey:t.ctrlKey,metaKey:t.metaKey})}const r=this.clientToElementCoords(t.clientX,t.clientY);this._controls.onDragMove({offsetX:r.x,offsetY:r.y,altKey:t.altKey,ctrlKey:t.ctrlKey,metaKey:t.metaKey})},this._docUpHandler=t=>{if(t.stopPropagation(),this._removeDocCapture(),e)return this._gizmo.forwardEvent(t,"pointerup"),this._mouseIsDown=!1,void(this._isDragging=!1);if(this._isDragging){const e=this.clientToElementCoords(t.clientX,t.clientY);this._controls.onDragEnd({offsetX:e.x,offsetY:e.y})}else{const e=this.clientToElementCoords(t.clientX,t.clientY);this.updateMouseNDCFromClient(t.clientX,t.clientY),this._delegate.handleClickAt(e.x,e.y,t)}this._mouseIsDown=!1,this._isDragging=!1},document.addEventListener("mousemove",this._docMoveHandler,!0),document.addEventListener("mouseup",this._docUpHandler,!0)}_onMouseMove(t){if(t.stopPropagation(),this._mouseIsDown)return;if(this._delegate.isPlacementMode())return void this._delegate.handlePlacementHover(t);this.updateMouseNDCFromClient(t.clientX,t.clientY);const e=this._camera.activeCamera;e&&this._scene.scene&&this._event.handleHover(e,this._scene.scene,t),this._gizmo.forwardEvent(t,"pointermove")}_removeDocCapture(){this._docMoveHandler&&(document.removeEventListener("mousemove",this._docMoveHandler,!0),this._docMoveHandler=void 0),this._docUpHandler&&(document.removeEventListener("mouseup",this._docUpHandler,!0),this._docUpHandler=void 0)}}Mu.DRAG_THRESHOLD=16;class Su{constructor(){this._groundPlane=new w.Plane(new w.Vector3(0,1,0),0)}get isActive(){return!!this._pendingModels}get pendingModels(){return this._pendingModels}setup(t,e){this._camera=t.camera,this._event=t.event,this._scene=t.scene,this._delegate=e}start(t){this._pendingModels=t}stop(){this._pendingModels=void 0,this._removeIndicator()}destroy(){this._removeIndicator(),this._pendingModels=void 0}raycastGroundPlane(t){this._delegate.updateMouseNDCFromClient(t.clientX,t.clientY);const e=this._camera.activeCamera;if(!e)return null;e.updateMatrixWorld(!0);const n=new w.Raycaster;n.setFromCamera(this._event.mouse,e);const i=new w.Vector3;return n.ray.intersectPlane(this._groundPlane,i)}updateIndicator(t){if(!t)return void(this._placementIndicator&&(this._placementIndicator.visible=!1));if(!this._placementIndicator){const t=this._scene?.scene;if(!t)return;const e=new w.RingGeometry(.8,1,32);e.rotateX(-Math.PI/2);const n=new w.MeshBasicMaterial({color:48340,opacity:.6,transparent:!0,side:w.DoubleSide,depthTest:!1});this._placementIndicator=new w.Mesh(e,n),this._placementIndicator.renderOrder=999,t.add(this._placementIndicator)}const e=this._pendingModels?.[0],n=e?.rx??e?.width??50,i=e?.ry??e?.height??50;this._placementIndicator.scale.set(n,1,i),this._placementIndicator.position.copy(t),this._placementIndicator.position.y=1,this._placementIndicator.visible=!0}_removeIndicator(){if(this._placementIndicator){const t=this._placementIndicator;this._scene?.scene?.remove(t),t.geometry.dispose(),t.material.dispose(),this._placementIndicator=void 0}}}const Au={linear:t=>t,"ease-in":t=>t*t,"ease-out":t=>1-(1-t)*(1-t),"ease-in-out":t=>t<.5?2*t*t:1-Math.pow(-2*t+2,2)/2};function Eu(t,e,n,i,r,s=new w.Vector3){const o=t*t,a=o*t;return s.set(.5*(2*n.x+(-e.x+i.x)*t+(2*e.x-5*n.x+4*i.x-r.x)*o+(-e.x+3*n.x-3*i.x+r.x)*a),.5*(2*n.y+(-e.y+i.y)*t+(2*e.y-5*n.y+4*i.y-r.y)*o+(-e.y+3*n.y-3*i.y+r.y)*a),.5*(2*n.z+(-e.z+i.z)*t+(2*e.z-5*n.z+4*i.z-r.z)*o+(-e.z+3*n.z-3*i.z+r.z)*a))}class ku{constructor(){this._slots=new Array(10),this._animating=!1,this._animationProgress=0,this._playStartOffset=0,this._lastPlayProgress=-1,this._playIndex=-1,this._playing=!1,this._orbitRotating=!1,this._orbitPaused=!1}get isAnimating(){return this._animating}get isPlaying(){return this._playing}get isOrbitRotating(){return this._orbitRotating}get isOrbitPaused(){return this._orbitPaused}get playIndex(){return this._playIndex}get lastPlayProgress(){return this._lastPlayProgress}get playProgress(){if(!this._playing||this._playIndex<0)return 0;const t=this.getPlayableSlots().length;if(t<2)return 0;const e=(this._playIndex-1+t)%t;let n=this._animating?this._animationProgress:1;return this._playStartOffset>0&&(n=this._playStartOffset+n*(1-this._playStartOffset)),(e+n)%t/t}setCallbacks(t,e){this._onInvalidate=t,this._onAnimationComplete=e}saveSlot(t,e){if(t<0||t>9)return;const n=this._slots[t];this._slots[t]={...e,name:"name"in e?e.name:n?.name}}renameSlot(t,e){if(t<0||t>9)return;const n=this._slots[t];n&&(n.name=e||void 0)}clearSlot(t){t<0||t>9||(this._slots[t]=void 0)}getSlot(t){return this._slots[t]}exportSlots(){return this._slots.map(t=>t?{...t}:null)}importSlots(t){if(Array.isArray(t))for(let e=0;e<10;e++){const n=t[e];this._slots[e]=n?{...n}:void 0}}resetAll(){this._slots=new Array(10)}getPlayableSlots(){return this._slots.map((t,e)=>t&&!t.excludeFromPlay?e:-1).filter(t=>t>=0)}swapSlots(t,e){if(t<0||t>9||e<0||e>9||t===e)return;const n=this._slots[t];this._slots[t]=this._slots[e],this._slots[e]=n}moveSlot(t,e){if(t<1||t>9||e<1||e>9||t===e)return;const n=this._slots[t];this._slots.splice(t,1),this._slots.splice(e,0,n)}animateToSlot(t,e,n,i=800,r){const s=this._slots[t];if(!s)return!1;this.stopAnimation(),this._animating=!0,this._animationProgress=0;const o=e.position.clone(),a=n.target.clone(),c=new w.Vector3(s.position.x,s.position.y,s.position.z),l=new w.Vector3(s.target.x,s.target.y,s.target.z),h=.01,d=Math.max(o.distanceTo(a),h),u=Math.max(c.distanceTo(l),h),p=(new w.Vector3).subVectors(a,o),f=(new w.Vector3).subVectors(l,c),g=p.lengthSq()>1e-4?p.normalize():new w.Vector3(0,0,-1).applyQuaternion(e.quaternion),m=f.lengthSq()>1e-4?f.normalize():g.clone(),y=(new w.Quaternion).setFromUnitVectors(new w.Vector3(0,0,-1),g),b=(new w.Quaternion).setFromUnitVectors(new w.Vector3(0,0,-1),m),_=Au[s.easing??"ease-in-out"];return this._runAnimation(i,_,t=>{r?Eu(t,r.prevPos,o,c,r.nextPos,e.position):e.position.lerpVectors(o,c,t);const i=y.clone().slerp(b,t),s=new w.Vector3(0,0,-1).applyQuaternion(i),a=d+(u-d)*t,l=e.position.clone().add(s.multiplyScalar(a));n.restoreTarget(l)}),!0}_animatePathSegment(t,e,n,i,r,s){const o=Au[i];this._runAnimation(n,o,n=>{const i=t+(e-t)*n,o=this.evaluatePath(i<=1?i:i-1);o&&(r.position.copy(o.position),s.restoreTarget(o.target))})}_runAnimation(t,e,n){this.stopAnimation(),this._animating=!0,this._animationProgress=0;const i=performance.now(),r=()=>{const s=performance.now()-i,o=Math.min(s/t,1),a=e(o);this._animationProgress=a,n(a),this._onInvalidate?.(),o<1?this._animationId=requestAnimationFrame(r):(this._animating=!1,this._animationId=void 0,this._onAnimationComplete?.())};this._animationId=requestAnimationFrame(r)}_initFromProgress(t,e){const n=t*e,i=Math.min(Math.floor(n),e-1);this._playStartOffset=n-i,this._playIndex=(i+1)%e}startPlay(t,e,n=2e3,i=1200,r=-1,s=!1){if(this._playing)return void this.stopPlay();const o=this.getPlayableSlots();if(o.length<2)return;this._playing=!0;let a=!0,c=-1;const l=r>=0&&r<=1?r:this._lastPlayProgress>0&&this._lastPlayProgress<1?this._lastPlayProgress:-1;s?this._playIndex=0:l>=0?(this._initFromProgress(l,o.length),c=l,a=!1):this._playIndex=0;const h=t=>new w.Vector3(t.x,t.y,t.z),d=t=>{this._onAnimationComplete=()=>{this._playing&&(this._playStartOffset=0,setTimeout(()=>{this._playing&&(this._playIndex=(this._playIndex+1)%o.length,u())},t))}},u=()=>{if(!this._playing)return;const r=o[this._playIndex],s=this._slots[r],l=s?.holdDuration??n,u=s?.transitionDuration??i;if(c>=0){const n=c;let i=this._playIndex/o.length;i<=n&&(i+=1),c=-1;const r=this._playStartOffset,a=Math.max(Math.round(u*(1-r)),100);return d(l),void this._animatePathSegment(n,i,a,s?.easing??"ease-in-out",t,e)}const p=this._buildSplineContext(o,a,t,e,h);a=!1,d(l),this.animateToSlot(r,t,e,u,p)};u()}_buildSplineContext(t,e,n,i,r){if(t.length<3)return;const s=t.length,o=t[(this._playIndex+1)%s],a=this._slots[o];if(!a)return;if(e)return{prevPos:n.position.clone(),nextPos:r(a.position)};const c=t[(this._playIndex-2+s)%s],l=this._slots[c];return l?{prevPos:r(l.position),nextPos:r(a.position)}:void 0}setProgressForSlot(t){const e=this.getPlayableSlots(),n=e.indexOf(t);n<0||e.length<2?this._lastPlayProgress=-1:this._lastPlayProgress=n/e.length}stopPlay(){this._lastPlayProgress=this.playProgress,this._playing=!1,this._playIndex=-1,this._playStartOffset=0,this._onAnimationComplete=void 0,this.stopAnimation()}resetPlay(){this.stopPlay(),this._lastPlayProgress=-1}toggleOrbitRotation(t){const e=t.isAutoRotating();this._orbitRotating=!e,this._orbitPaused=!this._orbitRotating,t.setAutoRotate(this._orbitRotating)}stopOrbitRotation(t){this._orbitRotating=!1,this._orbitPaused=!1,t.setAutoRotate(!1)}evaluatePath(t){const e=this.getPlayableSlots();if(e.length<2)return null;const n=e.length,i=Math.max(0,Math.min(1,t)),r=t=>{const i=this._slots[e[(t%n+n)%n]];return i?new w.Vector3(i.position.x,i.position.y,i.position.z):new w.Vector3},s=t=>{const i=this._slots[e[(t%n+n)%n]];return i?new w.Vector3(i.target.x,i.target.y,i.target.z):new w.Vector3};if(2===n){const t=i<.5?2*i:2*(1-i);return{position:r(0).lerp(r(1),t),target:s(0).lerp(s(1),t)}}const o=i*n,a=Math.min(Math.floor(o),n-1),c=o-a,l=Eu(c,r(a-1),r(a),r(a+1),r(a+2)),h=r(a),d=r(a+1),u=s(a),p=s(a+1),f=.01,g=Math.max(h.distanceTo(u),f),m=Math.max(d.distanceTo(p),f),y=(new w.Vector3).subVectors(u,h),b=(new w.Vector3).subVectors(p,d),_=y.lengthSq()>1e-4?y.normalize():new w.Vector3(0,0,-1),v=b.lengthSq()>1e-4?b.normalize():_.clone(),x=(new w.Quaternion).setFromUnitVectors(new w.Vector3(0,0,-1),_),M=(new w.Quaternion).setFromUnitVectors(new w.Vector3(0,0,-1),v),S=x.clone().slerp(M,c),A=new w.Vector3(0,0,-1).applyQuaternion(S),E=g+(m-g)*c,k=l.clone().add(A.multiplyScalar(E));return{position:l,target:k}}stopAnimation(){void 0!==this._animationId&&(cancelAnimationFrame(this._animationId),this._animationId=void 0),this._animating=!1}destroy(){this.stopPlay(),this.stopAnimation(),this._orbitPaused=!1,this._slots=new Array(10),this._onInvalidate=void 0,this._onAnimationComplete=void 0}}class Cu{constructor(){this._overlay=null,this._hostElement=null,this._startX=0,this._startY=0,this._currentX=0,this._currentY=0,this._active=!1}get isActive(){return this._active}setup(t){this._hostElement=t}startSelection(t,e){this._hostElement&&(this._startX=t,this._startY=e,this._currentX=t,this._currentY=e,this._active=!0,this._overlay=document.createElement("div"),this._overlay.style.cssText="\n position: absolute;\n border: 1px solid #4a9eff;\n background: rgba(74, 158, 255, 0.1);\n pointer-events: none;\n z-index: 1000;\n ",this._hostElement.appendChild(this._overlay),this._updateOverlay())}updateSelection(t,e){this._active&&(this._currentX=t,this._currentY=e,this._updateOverlay())}endSelection(t,e,n){if(!this._active||!this._hostElement)return this.cancelSelection(),[];const i=this._hostElement.getBoundingClientRect(),r=i.width,s=i.height,o=Math.min(this._startX,this._currentX),a=Math.max(this._startX,this._currentX),c=Math.min(this._startY,this._currentY),l=Math.max(this._startY,this._currentY);if(a-o<5&&l-c<5)return this.cancelSelection(),[];const h=o/r*2-1,d=a/r*2-1,u=-l/s*2+1,p=-c/s*2+1,f=[],g=new w.Vector3;for(const e of n){const n=e._realObject;n?.object3d&&(g.copy(n.object3d.position),g.project(t),g.z>1||g.x>=h&&g.x<=d&&g.y>=u&&g.y<=p&&f.push(e))}return this.cancelSelection(),f}cancelSelection(){this._active=!1,this._overlay&&this._hostElement&&this._hostElement.removeChild(this._overlay),this._overlay=null}destroy(){this.cancelSelection(),this._hostElement=null}_updateOverlay(){if(!this._overlay)return;const t=Math.min(this._startX,this._currentX),e=Math.min(this._startY,this._currentY),n=Math.abs(this._currentX-this._startX),i=Math.abs(this._currentY-this._startY);this._overlay.style.left=`${t}px`,this._overlay.style.top=`${e}px`,this._overlay.style.width=`${n}px`,this._overlay.style.height=`${i}px`}}const Tu=4890367,Pu=16750592;class Du{constructor(){this._componentHandles=[],this._activeVertexHandles=[],this._activeHandleIndex=-1,this._isDragging=!1,this._isExtending=!1,this._dragPlane=new w.Plane,this._dragOffset=new w.Vector3,this._raycaster=new w.Raycaster,this._intersection=new w.Vector3}get isDragging(){return this._isDragging}get isAttached(){return this._componentHandles.length>0}setVisible(t){this._handleGroup&&(this._handleGroup.visible=t)}attachMultiple(t,e,n){this.detach();const i=t.filter(t=>t.mutable&&t.path&&t.path.length>=2);if(0!==i.length){this._scene3d=e,this._commander=n,this._handleGroup=new w.Group,this._handleGroup.name="__vertexHandles__",this._handleGroup.renderOrder=1e4;for(const t of i){const e=this._buildComponentHandles(t);this._componentHandles.push(e)}e.add(this._handleGroup)}}attach(t,e,n){this.attachMultiple([t],e,n)}detach(){this._handleGroup&&this._scene3d&&(this._scene3d.remove(this._handleGroup),Hh(this._handleGroup)),this._componentHandles=[],this._handleGroup=void 0,this._scene3d=void 0,this._commander=void 0,this._activeComponent=void 0,this._activeVertexHandles=[],this._activeHandleIndex=-1,this._isDragging=!1,this._isExtending=!1}_buildComponentHandles(t){const e=[],n=[],i=t.path;if(!i||!this._handleGroup)return{component:t,vertexHandles:e,midpointHandles:n};const{width:r=0,height:s=0}=t.parent?.bounds??{},o=t._realObject,a=o?o.object3d.position.y:0;for(let n=0;n<i.length;n++){const o=i[n],c=new w.Vector3(o.x-r/2,(o.z||0)+a,o.y-s/2),l=this._createVertexHandle(c,n,t);e.push(l),this._handleGroup.add(l)}if(t.pathExtendable)for(let e=0;e<i.length-1;e++){const o=i[e],c=i[e+1],l=new w.Vector3((o.x+c.x)/2-r/2,((o.z||0)+(c.z||0))/2+a,(o.y+c.y)/2-s/2),h=this._createMidpointHandle(l,e,t);n.push(h),this._handleGroup.add(h)}return{component:t,vertexHandles:e,midpointHandles:n}}_rebuildComponentHandles(t){const e=this._componentHandles.findIndex(e=>e.component===t);if(e<0||!this._handleGroup)return;const n=this._componentHandles[e];for(const t of[...n.vertexHandles,...n.midpointHandles])this._handleGroup.remove(t),t.geometry.dispose(),t.material.dispose();this._componentHandles[e]=this._buildComponentHandles(t),this._activeComponent===t&&(this._activeVertexHandles=this._componentHandles[e].vertexHandles)}_createVertexHandle(t,e,n){const i=new w.SphereGeometry(1,16,12),r=new w.MeshBasicMaterial({color:Tu,transparent:!0,opacity:.8,depthTest:!1}),s=new w.Mesh(i,r);return s.position.copy(t),s.userData.vertexIndex=e,s.userData.handleType="vertex",s.userData.component=n,s.renderOrder=10001,s}_createMidpointHandle(t,e,n){const i=new w.OctahedronGeometry(.7,0),r=new w.MeshBasicMaterial({color:16735602,transparent:!0,opacity:.7,depthTest:!1}),s=new w.Mesh(i,r);return s.position.copy(t),s.userData.segmentIndex=e,s.userData.handleType="midpoint",s.userData.component=n,s.renderOrder=10001,s}_handlePosToPoint(t,e){const{width:n=0,height:i=0}=e.parent?.bounds??{},r=e._realObject,s=r?r.object3d.position.y:0,o={x:t.x+n/2,y:t.z+i/2},a=t.y-s;return Math.abs(a)>.001&&(o.z=a),o}_execMutatePath(t,e){const n=this._commander;n?Sc.around(n,()=>{t.mutatePath(null,e)}):t.mutatePath(null,e)}_getAllHandles(){const t=[];for(const e of this._componentHandles)t.push(...e.vertexHandles,...e.midpointHandles);return t}_findComponentHandles(t){return this._componentHandles.find(e=>e.component===t)}onPointerDown(t,e,n){if(!this._handleGroup)return!1;const i=this._getAllHandles();if(0===i.length)return!1;this._raycaster.setFromCamera(t,e);const r=this._raycaster.intersectObjects(i,!1);if(0===r.length)return!1;const s=r[0].object,o=s.userData.handleType,a=s.userData.component,c=this._findComponentHandles(a);if(!c)return!1;if(this._activeComponent=a,this._activeVertexHandles=c.vertexHandles,"midpoint"===o)return this._startMidpointDrag(s,a,e);const l=s.userData.vertexIndex,h=a.path;if(!h)return!1;const d=0===l||l===h.length-1;return n.altKey&&d&&a.pathExtendable?this._startEndpointExtend(s,l,a,e):(this._activeHandleIndex=l,this._isDragging=!0,this._isExtending=!1,s.material.color.setHex(Pu),this._setupDragPlane(e,s.position),!0)}_startMidpointDrag(t,e,n){const i=t.userData.segmentIndex+1,r=this._handlePosToPoint(t.position,e);this._execMutatePath(e,t=>{t.splice(i,0,r)}),this._rebuildComponentHandles(e);const s=this._activeVertexHandles[i];return!!s&&(this._activeHandleIndex=i,this._isDragging=!0,this._isExtending=!1,s.material.color.setHex(Pu),this._setupDragPlane(n,s.position),!0)}_startEndpointExtend(t,e,n,i){const r=n.path;if(!r)return!1;const s=this._handlePosToPoint(t.position,n),o=0===e?0:r.length;this._execMutatePath(n,t=>{t.splice(o,0,s)}),this._rebuildComponentHandles(n);const a=this._activeVertexHandles[o];return!!a&&(this._activeHandleIndex=o,this._isDragging=!0,this._isExtending=!0,a.material.color.setHex(Pu),this._setupDragPlane(i,a.position),!0)}_setupDragPlane(t,e){const n=new w.Vector3;t.getWorldDirection(n),this._dragPlane.setFromNormalAndCoplanarPoint(n,e),this._raycaster.ray.intersectPlane(this._dragPlane,this._intersection),this._dragOffset.copy(e).sub(this._intersection)}onPointerMove(t,e,n){if(!this._isDragging||this._activeHandleIndex<0)return!1;this._raycaster.setFromCamera(t,e),this._raycaster.ray.intersectPlane(this._dragPlane,this._intersection);const i=this._intersection.add(this._dragOffset);if(n.shiftKey){const t=this._activeVertexHandles[this._activeHandleIndex];t&&(i.x=t.position.x,i.z=t.position.z)}const r=this._activeVertexHandles[this._activeHandleIndex];return r&&r.position.copy(i),this._updateLinePreview(),!0}_updateLinePreview(){if(!this._activeComponent)return;const t=this._activeComponent._realObject;if(!t?._line2)return;const{width:e=0,height:n=0}=this._activeComponent.parent?.bounds??{},{x:i,y:r}=this._activeComponent.center,s=t.object3d?t.object3d.position.y:0,o=[];for(const t of this._activeVertexHandles){const a=t.position.x+e/2-i,c=t.position.y-s,l=t.position.z+n/2-r;o.push(a,c,l)}if(o.length<6)return;t._line2.geometry.setPositions(o),t._line2.computeLineDistances()}onPointerUp(){if(!this._isDragging||this._activeHandleIndex<0||!this._activeComponent)return!1;const t=this._activeHandleIndex,e=this._activeVertexHandles[t],n=this._activeComponent;if(!e)return this._isDragging=!1,this._activeHandleIndex=-1,this._isExtending=!1,!0;e.material.color.setHex(Tu);const i=this._handlePosToPoint(e.position,n);return this._execMutatePath(n,e=>{e[t]=i}),this._isDragging=!1,this._activeHandleIndex=-1,this._isExtending=!1,this._rebuildComponentHandles(n),!0}onDblClick(t,e){if(!this._handleGroup)return!1;const n=[];for(const t of this._componentHandles)n.push(...t.vertexHandles);this._raycaster.setFromCamera(t,e);const i=this._raycaster.intersectObjects(n,!1);if(0===i.length)return!1;const r=i[0].object,s=r.userData.component;if(!s.pathExtendable)return!1;const o=s.path;if(!o||o.length<=2)return!1;const a=r.userData.vertexIndex;return this._execMutatePath(s,t=>{t.splice(a,1)}),this._rebuildComponentHandles(s),!0}syncHandles(){for(const t of this._componentHandles)this._rebuildComponentHandles(t.component)}updateHandleScales(t){const e=this._getAllHandles();if(0!==e.length)for(const n of e){const e=t.position.distanceTo(n.position),i="midpoint"===n.userData.handleType?5:8;let r;if(t.isPerspectiveCamera){const n=t.fov,s=2*Math.tan(n*Math.PI/360)*e;r=i/window.innerHeight*s}else{const e=t,n=(e.top-e.bottom)/e.zoom;r=i/window.innerHeight*n}n.scale.setScalar(Math.max(r,.1))}}destroy(){this.detach()}}class Ou{constructor(){this.sceneManager=new du,this.cameraManager=new uu,this.rendererManager=new pu,this.lightManager=new fu,this.controlsManager=new mu,this.eventManager=new yu,this.gizmoManager=new _u,this.interactionManager=new Mu,this.placementManager=new Su,this.gizmoOperationManager=new wu,this.bookmarkManager=new ku,this.boxSelectionManager=new Cu,this.vertexGizmoManager=new Du,this._isSpacePanning=!1,this._initialized=!1,this._decoratorOutlines=new Set,this._selectionOutlineObjects=[],this._highlightedMarkerIndex=-1,this._arrows=new Map,this._pathVisible=!1}get isInitialized(){return this._initialized}get host(){return this._host}get scene3d(){return this.sceneManager.scene}get renderer3d(){return this.rendererManager.renderer}get mixer(){return this.sceneManager.mixer}get camera(){return this.cameraManager.camera}get activeCamera(){return this.cameraManager.activeCamera}get css3DScene(){return this.rendererManager.css3DScene}get css3DRenderer(){return this.rendererManager.css3DRenderer}get noSupportWebgl(){return this.rendererManager.noSupportWebgl}get isActive(){return this.controlsManager.isActive}setGizmoMode(t){if(this.gizmoManager.mode===t&&this.gizmoManager.attached)return this.gizmoManager.detach(),void this._host?.invalidate();this.gizmoManager.setMode(t),this.onGizmoModeChanged?.(t);const e=this._host?.root?.selected,n=e?.filter(t=>t!==this._host&&t._realObject)||[];if(n.length>=1){const e=n[0]._realObject;if(e?.object3d&&e.gizmoTransformable){const n=e.allowedGizmoModes;!n||n.includes(t)?this.gizmoManager.attach(e.object3d):this.gizmoManager.detach()}this._host?.invalidate()}}get gizmoMode(){return this.gizmoManager.mode}init(t,e){this.interactionManager.cleanup(),this._cleanupEventHandlers(),this._host=t,this.sceneManager.scene&&this.destroy(),this._redrawHandler=()=>this.animate(),t.root.on("redraw",this._redrawHandler),this._initialized=!0,this._setupScene(e),this._onComponentAdd=(t,e)=>this.addObject(e),this._onComponentRemove=(t,e)=>this.removeObject(e),t.on&&(t.on("add",this._onComponentAdd),t.on("remove",this._onComponentRemove)),t.app?.isEditMode&&t.root?.on&&(this._onSelectionChanged=t=>this._handleSelectionChanged(t),t.root.on("selected",this._onSelectionChanged)),t.app?.isEditMode&&t.root?.on&&(this._onAddStart=t=>{this.placementManager.start(t),this._host?.element&&(this._host.element.style.cursor="crosshair",this._host.element.focus())},this._onAddStop=()=>{this.placementManager.stop(),this._host?.element&&(this._host.element.style.cursor="")},t.root.on("addstart",this._onAddStart),t.root.on("addstop",this._onAddStop))}_cleanupEventHandlers(){const t=this._host;t&&(this._redrawHandler&&(t.root.off("redraw",this._redrawHandler),this._redrawHandler=void 0),t.off&&(this._onComponentAdd&&(t.off("add",this._onComponentAdd),this._onComponentAdd=void 0),this._onComponentRemove&&(t.off("remove",this._onComponentRemove),this._onComponentRemove=void 0)),this._onSelectionChanged&&t.root?.off&&(t.root.off("selected",this._onSelectionChanged),this._onSelectionChanged=void 0),this._onAddStart&&t.root?.off&&(t.root.off("addstart",this._onAddStart),this._onAddStart=void 0),this._onAddStop&&t.root?.off&&(t.root.off("addstop",this._onAddStop),this._onAddStop=void 0))}_setupScene(t){const e=this._host;let{width:n,height:i}=e.bounds;n=Math.abs(n)||1,i=Math.abs(i)||1;const{fov:r=45,near:s=.1,far:o=2e4,antialias:a=!0,precision:c="highp",cameraX:l,cameraY:h,cameraZ:d,exposure:u=1.2}=e.state,p=e.components||[],f=t?.lightingConfig??{hemisphere:{skyColor:16777215,groundColor:4473924,intensity:.4}},g=t?.css3DSceneAttribute??"three-container:css3d-renderer",m=this.sceneManager.setup(),y=this.cameraManager.setup(n,i,{fov:r,near:s,far:o,cameraX:l,cameraY:h,cameraZ:d});this.cameraManager.addToScene(m);const b=e.app?.postprocessing,_=!t?.skipShadowMap&&void 0,v=!t?.skipPostprocessing&&void 0;if(this.rendererManager.setupWebGL(n,i,{precision:c,antialias:a,exposure:u,postprocessing:b,shadowMap:_,logarithmicDepthBuffer:v})){if(t?.skipEnvironment||this.sceneManager.setupEnvironment(this.rendererManager.renderer),this.controlsManager.setup(y,e),this.controlsManager.setOnUserInteraction(()=>{this.bookmarkManager.isPlaying&&(this.bookmarkManager.stopPlay(),this._pathVisible&&this.showBookmarkPath()),this.bookmarkManager.isOrbitRotating&&this.bookmarkManager.stopOrbitRotation(this.controlsManager)}),e.app?.isEditMode&&e.element&&(this.gizmoManager.setup(y,e.element,m),this._setupGizmoCallbacks()),this.placementManager.setup({camera:this.cameraManager,event:this.eventManager,scene:this.sceneManager},{updateMouseNDCFromClient:(t,e)=>this._updateMouseNDCFromClient(t,e)}),this.lightManager.setup(m,y,f),this.sceneManager.setupMixer(),this.createObjects(p),y.updateProjectionMatrix(),t?.skipFloor||this.sceneManager.addFloor(e),this.sceneManager.setSky(e.state.sky,e.state.skyColor),t?.skipPostprocessing||!1===e.app?.postprocessing)t?.useLightComposer?this.rendererManager.setupLightComposer(m,y,n,i):this.rendererManager.setDirectRenderTargets(m,y);else{const t=this.gizmoManager.controls?.getHelper();this.rendererManager.setupComposer(m,y,n,i,t)}this.rendererManager.setupHUD(n,i),this.rendererManager.hudCamera&&this.eventManager.setHUD(this.rendererManager.hudScene,this.rendererManager.hudCamera),this.rendererManager.setupCSS3D(e.app.isViewMode,g),this._onFocus=()=>this.renderThreeD(),window.addEventListener("focus",this._onFocus),e.element&&(this.interactionManager.setup(e.element,{gizmo:this.gizmoManager,controls:this.controlsManager,camera:this.cameraManager,scene:this.sceneManager,event:this.eventManager},this._buildInteractionDelegate()),e.app?.isEditMode&&this.boxSelectionManager.setup(e.element))}}_setupGizmoCallbacks(){this.gizmoOperationManager.setupCallbacks(this.gizmoManager,this.controlsManager,()=>{const t=this._host;if(t)return Object.create(t,{hostElement:{get:()=>t.target??t.element??void 0}})},{onAttachChanged:t=>this.onGizmoAttachChanged?.(t),onDraggingChanged:t=>{t?this.vertexGizmoManager.setVisible(!1):(this.vertexGizmoManager.syncHandles(),this.vertexGizmoManager.setVisible(!0))}})}createObjects(t){for(const e of t)this.addObject(e)}addObject(t){if(t._realObject){const e=t._realObject;if(e.object3d&&!e.object3d.parent)if(t.state.screenFixed)e instanceof tu?this.rendererManager.hudCSS3DScene.add(e.object3d):this.rendererManager.hudScene.add(e.object3d);else if(e instanceof tu)this.rendererManager.css3DScene.add(e.object3d);else{const n=t.parent?._realObject?.object3d;n&&n!==this.sceneManager.scene?n.add(e.object3d):this.sceneManager.scene&&this.sceneManager.scene.add(e.object3d)}return}if(!t.is3dContainer?.()&&"popup"!==t.state?.position){try{if(!t.isLine?.()){const{width:e,height:n}=t.bounds;if(!e||!n)return}if(t.isHTMLElement()&&!t.element)return;const e=su(t);if(e){if(t._realObject=e,e.update(),e.updateTransform(),t.state.screenFixed)e instanceof tu?this.rendererManager.hudCSS3DScene.add(e.object3d):this.rendererManager.hudScene.add(e.object3d);else if(e instanceof tu)this.rendererManager.css3DScene.add(e.object3d);else{const n=t.parent?._realObject?.object3d;n&&n!==this.sceneManager.scene?n.add(e.object3d):this.sceneManager.scene&&this.sceneManager.scene.add(e.object3d)}const n=this._host?.root?.selected;n&&n.length>0&&n[0]===t&&e.object3d&&e.gizmoTransformable&&this.gizmoManager.attached&&this.gizmoManager.attach(e.object3d)}}catch(t){Fi(t)}if(t.isContainer()){const e=t,n=e.components||[];this.createObjects(n),e.on&&(e.on("add",this._onComponentAdd),e.on("remove",this._onComponentRemove))}}}removeObject(t){if(t.is3dContainer?.())return;if(t.isContainer()){const e=t,n=e.components||[];for(const t of n)this.removeObject(t);e.off&&(e.off("add",this._onComponentAdd),e.off("remove",this._onComponentRemove))}const e=t._realObject;if(e)try{const n=e.object3d;n&&this.gizmoManager.attached===n&&this.gizmoManager.detach(),n&&(e instanceof tu?this.rendererManager.css3DScene.remove(n):n.removeFromParent()),e.dispose?.(),t._realObject=void 0}catch(t){Fi(t)}}resize(t,e,n=!1){const i=this._host;if(!i)return;if(void 0===t||void 0===e){const n=i.bounds;t=n.width,e=n.height}if(t=Math.abs(t)||1,e=Math.abs(e)||1,n)return void this._applyResize(t,e);this.rendererManager.css3DRenderer?.setSize(t,e);const r=t,s=e;clearTimeout(this._resizeDebouncer),this._resizeDebouncer=window.setTimeout(()=>{this._resizeDebouncer=void 0,this._applyResize(r,s)},100)}_applyResize(t,e){this.cameraManager.updateAspect(t,e),this.rendererManager.resize(t,e);const n=new w.Vector2(t,e);for(const t of this._arrows.values())t.traverse(t=>{t instanceof h.Line2&&t.material.resolution.copy(n)});this._initialized&&(this.renderThreeD(),this._host?.invalidate())}animate(){if(!this._initialized||!this.controlsManager.isActive)return;this.sceneManager.updateAnimation();let t=!1;const e=n=>{for(const i of n)i._animation?.started&&i._realObject&&(i._realObject.syncAnimationDelta(),t=!0),i.components&&e(i.components)};e(this._host?.components||[]),this.controlsManager.update(),this.renderThreeD(),t&&this._host?.invalidate()}renderThreeD(){this._initialized&&(this.vertexGizmoManager?.isAttached&&this.vertexGizmoManager.updateHandleScales(this.cameraManager.activeCamera),this.rendererManager.render(),this.renderCSS3D())}setCameraView(t,e){const n=this._host;if(!n)return;const{width:i,height:r}=n.bounds,s=n.element,o=s?.clientWidth||i,a=s?.clientHeight||r;let c;c="perspective"===t?this.cameraManager.restorePerspective():this.cameraManager.setOrthoView(t,i,r,o,a),this.controlsManager.setCamera(c),this.gizmoManager.updateCamera(c),this.rendererManager.updateRenderPassCamera(c),!1!==e?.render&&this.renderThreeD(),this.onCameraViewChanged?.(t)}renderCSS3D(){const t=this.cameraManager.activeCamera;t&&this.rendererManager.renderCSS3D(t)}buildOverlays(){const t=this._host;if(!t?.element)return;t.element.appendChild(this.css3DRenderer.domElement);const e=this.rendererManager.hudCSS3DRenderer?.domElement;e&&t.element.appendChild(e)}destroy(){this.interactionManager.cleanup(),this._resizeDebouncer&&(clearTimeout(this._resizeDebouncer),this._resizeDebouncer=void 0),this._onFocus&&(window.removeEventListener("focus",this._onFocus),this._onFocus=void 0),this.vertexGizmoManager.destroy(),this.boxSelectionManager.destroy(),this.bookmarkManager.destroy(),this.gizmoManager.destroy(),this.controlsManager.destroy(),this.lightManager.destroy(),this.rendererManager.destroy(),this.cameraManager.destroy(),this.sceneManager.destroy(),this.eventManager.destroy(),this._initialized=!1}forceCleanupDragState(){this.interactionManager.forceCleanupDragState(),this.boxSelectionManager.isActive&&(this.boxSelectionManager.cancelSelection(),this.controlsManager.setEnabled(!0)),this._isSpacePanning&&(this._isSpacePanning=!1,void 0!==this._beforeSpaceMode&&this._host?.app&&(this._host.app.mode=this._beforeSpaceMode,this._beforeSpaceMode=void 0)),this._host?.element&&(this._host.element.style.cursor="")}clearAllObjects(){this.gizmoManager.detach();const t=this._host?.components||[];for(const e of t)e._realObject&&this.removeObject(e)}rebuildForHost(t,e){this.interactionManager.cleanup();try{this._cleanupEventHandlers()}catch(t){}this._host=t,this._redrawHandler=()=>this.animate(),t.root.on("redraw",this._redrawHandler),this._onComponentAdd=(t,e)=>this.addObject(e),this._onComponentRemove=(t,e)=>this.removeObject(e),t.on&&(t.on("add",this._onComponentAdd),t.on("remove",this._onComponentRemove)),t.app?.isEditMode&&t.root?.on&&(this._onSelectionChanged=t=>this._handleSelectionChanged(t),t.root.on("selected",this._onSelectionChanged),this._onAddStart=t=>{this.placementManager.start(t),this._host?.element&&(this._host.element.style.cursor="crosshair",this._host.element.focus())},this._onAddStop=()=>{this.placementManager.stop(),this._host?.element&&(this._host.element.style.cursor="")},t.root.on("addstart",this._onAddStart),t.root.on("addstop",this._onAddStop)),this.createObjects(t.components||[]),t.element&&this.interactionManager.setup(t.element,{gizmo:this.gizmoManager,controls:this.controlsManager,camera:this.cameraManager,scene:this.sceneManager,event:this.eventManager},this._buildInteractionDelegate());const n=this.controlsManager._position0?.clone(),i=this.controlsManager._target0?.clone();this.controlsManager.setup(this.cameraManager.camera,t),n&&this.controlsManager._position0.copy(n),i&&this.controlsManager._target0.copy(i),t.app?.isEditMode&&t.element&&this.boxSelectionManager.setup(t.element),t.app?.isEditMode&&t.element&&this.sceneManager.scene&&(this.gizmoManager.setup(this.cameraManager.camera,t.element,this.sceneManager.scene),this._setupGizmoCallbacks()),this._onFocus||(this._onFocus=()=>this.renderThreeD(),window.addEventListener("focus",this._onFocus)),this.renderThreeD()}dispose(){const t=e=>{for(const n of e)if(!n.is3dContainer?.()){if(n.isContainer()){const e=n.components||[];t(e)}n._realObject&&(n._realObject.dispose?.(),n._realObject=void 0)}};t(this._host?.components||[]),this._decoratorOutlines.clear(),this._selectionOutlineObjects=[],this.clearArrows(),this.placementManager.destroy(),this._cleanupEventHandlers(),this.rendererManager.disposeCSS3DScene(),this.destroy(),this._host=void 0}_buildInteractionDelegate(){return{isPlacementMode:()=>this.placementManager.isActive,handlePlacementClick:t=>{if(!this._host?.root)return;const e=this.placementManager.raycastGroundPlane(t);if(e){const t=this._host,n=t.bounds.width||800,i=t.bounds.height||600,r=e.x+n/2,s=e.z+i/2;Ol.call(t.root,this.placementManager.pendingModels,{cx:r,cy:s}),t.root.trigger("addstop")}},handlePlacementHover:t=>{const e=this.placementManager.raycastGroundPlane(t);this.placementManager.updateIndicator(e),this.renderThreeD()},tryAltClickSelect:t=>{if(!this._host?.app?.isEditMode||!this._host.root)return!1;this._updateMouseNDCFromClient(t.clientX,t.clientY);const e=this.cameraManager.activeCamera;if(e&&this.sceneManager.scene){const n=this.eventManager.handleClick(e,this.sceneManager.scene,t);if(n?.component)return this._host.root.selected=[n.component],!0}return!1},captureMouseDownAltKey:t=>{this.gizmoOperationManager.captureAltKey(t)},handleClickAt:(t,e,n)=>{this._handleClickAt(n)},handleWheel:t=>this.onWheel(t),handleDblClick:t=>this.onDblClick(t),handleTouchStart:t=>this.onTouchStart(t),handleTouchMove:t=>this.onPan(t),handleTouchEnd:t=>this.onTouchEnd(t),handleKeyDown:t=>this.onKeyDown(t),handleKeyUp:t=>this._onKeyUp(t),isSpacePanning:()=>this._isSpacePanning,handleBoxSelectionStart:(t,e)=>{this.controlsManager.setEnabled(!1),this._host?.element&&(this._host.element.style.cursor="crosshair"),this.boxSelectionManager.startSelection(t,e)},handleBoxSelectionUpdate:(t,e)=>{this.boxSelectionManager.updateSelection(t,e)},tryVertexDragStart:t=>{if(!this.vertexGizmoManager.isAttached)return!1;const e=this.cameraManager.activeCamera;if(!e)return!1;const n=this.eventManager.mouse,i=this.vertexGizmoManager.onPointerDown(n,e,t);return i&&this.controlsManager.setEnabled(!1),i},handleVertexDragMove:t=>{const e=this.cameraManager.activeCamera;if(!e)return;const n=this.eventManager.mouse;this.vertexGizmoManager.onPointerMove(n,e,t),this._host?.invalidate()},handleVertexDragEnd:t=>{this.vertexGizmoManager.onPointerUp(),this.controlsManager.setEnabled(!0),this._host?.invalidate()},handleBoxSelectionEnd:(t,e)=>{this.controlsManager.setEnabled(!0),this._host?.element&&(this._host.element.style.cursor="");const n=this.cameraManager.activeCamera,i=this.sceneManager.scene,r=this._host?.components||[];if(n&&i){let s=this.boxSelectionManager.endSelection(n,i,r);if(e&&t){const t=this._host?.root?.selected||[];if(t.length>0){const e=t[0].state?.type;e&&(s=s.filter(t=>t.state?.type===e))}}if(s.length>0&&this._host?.root)if(t){const t=this._host,e=(this._host.root.selected||[]).filter(e=>e!==t);for(const t of s)e.includes(t)||e.push(t);this._host.root.selected=e}else this._host.root.selected=s}else this.boxSelectionManager.cancelSelection()}}}_handleClickAt(t){const e=this._host,n=this.cameraManager.activeCamera;if(!n||!this.sceneManager.scene)return;if(this._pathMarkers&&this._pathMarkers.children.length>0){const t=new w.Raycaster,e=this.eventManager.mouse;t.setFromCamera(e,n);const i=t.intersectObjects(this._pathMarkers.children,!0);if(i.length>0){let t=i[0].object;for(;t&&void 0===t.userData.bookmarkSlotIndex;)t=t.parent;if(t&&void 0!==t.userData.bookmarkSlotIndex)return void this.animateToSlot(t.userData.bookmarkSlotIndex)}}if(this.vertexGizmoManager?.isDragging)return this.vertexGizmoManager.onPointerUp(),this.controlsManager.setEnabled(!0),void this._host?.invalidate();const i=this.gizmoManager.isDragging;if(this.gizmoManager.forwardEvent(t,"pointerup"),i)return;const r=this.eventManager.handleClick(n,this.sceneManager.scene,t);if(e.root){const t=e.app?.mode;if(4===t||5===t){if(!r?.component){const n=4===t?"stylepastestop":"databindpastestop";e.root.trigger(n)}return}}e.app?.isEditMode&&e.root&&this._applySelection(e.root,r?.component,t.shiftKey)}_applySelection(t,e,n){if(e)if(n){const n=(t.selected||[]).slice(),i=n.indexOf(e);-1===i?n.push(e):n.splice(i,1),t.selected=n}else{let n=null,i=e.parent;for(;i?.isGroup?.();)n=i,i=i.parent;if(n){if(!(t.selected||[]).some(t=>{if(t===n)return!0;let e=t.parent;for(;e?.isGroup?.();){if(e===n)return!0;e=e.parent}return!1}))return void(t.selected=[n])}t.selected=[e]}else n||(t.selected=[])}getObjectByRaycast(){if(!this.sceneManager.scene)return;const t=this.cameraManager.activeCamera;return t?this.eventManager.getObjectByRaycast(t,this.sceneManager.scene):void 0}getObjectsByRaycast(){if(!this.sceneManager.scene)return;const t=this.cameraManager.activeCamera;return t?this.eventManager.getObjectsByRaycast(t,this.sceneManager.scene):void 0}_updateMouseNDCFromClient(t,e){const n=this._host?.element;if(n){const i=n.getBoundingClientRect();if(i.width>0&&i.height>0){const n=t-i.left,r=e-i.top;return void this.eventManager.updateMouseNDC(n,r,0,0,i.width,i.height)}}const i=this._host;if(i){const{left:n,top:r,width:s,height:o}=i.bounds;s>0&&o>0&&this.eventManager.updateMouseNDC(t,e,n,r,Math.abs(s),Math.abs(o))}}_eventToNDC(t){const e=this._host?.element;if(e){const n=e.getBoundingClientRect();if(n.width>0&&n.height>0)return{ndcX:(t.clientX-n.left)/n.width*2-1,ndcY:-(t.clientY-n.top)/n.height*2+1}}const n=this._host;if(n?.transcoordC2S){const{width:e,height:i}=n.bounds;if(Math.abs(e)>0&&Math.abs(i)>0){const r=n.transcoordC2S(t.offsetX,t.offsetY);return{ndcX:r.x/Math.abs(e)*2-1,ndcY:-(r.y/Math.abs(i)*2-1)}}}return{ndcX:0,ndcY:0}}_updateMouseNDC(t){const e=this._host?.element;if(e){const n=e.getBoundingClientRect();if(n.width>0&&n.height>0){const e=t.clientX-n.left,i=t.clientY-n.top;return void this.eventManager.updateMouseNDC(e,i,0,0,n.width,n.height)}}const n=this._host;if(n?.transcoordC2S){const{width:e,height:i}=n.bounds;if(Math.abs(e)>0&&Math.abs(i)>0){const r=n.transcoordC2S(t.offsetX,t.offsetY);this.eventManager.updateMouseNDC(r.x,r.y,0,0,Math.abs(e),Math.abs(i))}}}onMouseUp(t){if(this.controlsManager.isActive){const e=this.gizmoManager.isDragging;if(this.gizmoManager.forwardEvent(t,"pointerup"),e)return t.stopPropagation(),!0;const n=this.cameraManager.activeCamera;this._updateMouseNDC(t);const i=this.eventManager.handleClick(n,this.sceneManager.scene,t),r=this._host;return r?.app?.isEditMode&&r.root&&this._applySelection(r.root,i?.component,t.shiftKey),t.stopPropagation(),!0}return!1}onMouseMove(t){if(this.controlsManager.isActive){this.gizmoManager.forwardEvent(t,"pointermove");const e=this.cameraManager.activeCamera;return this._updateMouseNDC(t),this.eventManager.handleHover(e,this.sceneManager.scene,t),t.stopPropagation(),!0}return!1}onMouseDown(t){return!(!this.controlsManager.isActive||(this.gizmoManager.forwardEvent(t,"pointerdown"),!this.gizmoManager.isDragging))&&(t.stopPropagation(),!0)}onMouseLeave(t){return!1}onWheel(t){if(this.controlsManager.isActive){const{ndcX:e,ndcY:n}=this._eventToNDC(t);if("perspective"!==this.cameraManager.activeView){const i=t.deltaY>0?.9:1.1;this.controlsManager.zoomOrthoAtCursor(i,e,n),this.renderThreeD()}else{const i=Math.pow(.999,-t.deltaY);this.controlsManager.dollyAtCursor(i,e,n),this.renderThreeD()}return t.stopPropagation(),!0}return!1}onDblClick(t){if(!this.controlsManager.isActive)return!1;const e=this._host,n=this.cameraManager.activeCamera;if(!n||!this.sceneManager.scene)return this.controlsManager.reset(),!0;if(e?.app?.isEditMode&&e.root){if(this.vertexGizmoManager.isAttached){const t=this.eventManager.mouse;if(this.vertexGizmoManager.onDblClick(t,n))return this._host?.invalidate(),!0}const t=this.eventManager.getObjectByRaycast(n,this.sceneManager.scene),e=t?.userData?.context?.component;if(e?.hasTextProperty)return ou(e,this.rendererManager,()=>{this.renderThreeD()}),!0}return this.controlsManager.reset(),t.stopPropagation(),!0}pinResetPosition(){this.controlsManager.pinResetPosition()}onDragStart(t){return!!this.controlsManager.isActive&&(this.gizmoManager.isDragging?(t.stopPropagation(),!0):(this.bookmarkManager.stopOrbitRotation(this.controlsManager),this.bookmarkManager.stopPlay(),this.controlsManager.onDragStart(t),t.stopPropagation(),!0))}onDragMove(t){return!!this.controlsManager.isActive&&(this.gizmoManager.isDragging?(this.gizmoManager.forwardEvent(t,"pointermove"),t.stopPropagation(),!0):(this.controlsManager.onDragMove(t),t.stopPropagation(),!0))}onDragEnd(t){return!!this.controlsManager.isActive&&(this.gizmoManager.isDragging?(this.gizmoManager.forwardEvent(t,"pointerup"),t.stopPropagation(),!0):(this.controlsManager.onDragEnd(t),t.stopPropagation(),!0))}onTouchStart(t){return!!this.controlsManager.isActive&&(this.controlsManager.onTouchStart(t),t.stopPropagation(),!0)}onPan(t){return!!this.controlsManager.isActive&&(this.controlsManager.onTouchMove(t),t.stopPropagation(),!0)}onTouchEnd(t){return!!this.controlsManager.isActive&&(this.controlsManager.onTouchEnd(t),t.stopPropagation(),!0)}onKeyDown(t){return!t.isComposing&&229!==t.keyCode&&(!!this.controlsManager.isActive&&(!!this._handleEscapeKey(t)||(!(!this._host?.app?.isEditMode||!this._handleEditModeKey(t))||(!!this._handleCursorHintKey(t)||(!!this._handleCameraAndViewKey(t)||(!!this._handlePlaybackKey(t)||(!t.shiftKey||t.ctrlKey||t.metaKey||t.altKey||"KeyB"!==t.code||!this._host?.app?.isEditMode?(this.controlsManager.onKeyDown(t),t.ctrlKey||t.metaKey||t.stopPropagation(),!0):(this.onBookmarkEditToggle?.(),t.preventDefault(),!0))))))))}_handleEscapeKey(t){if("Escape"!==t.key&&"Escape"!==t.code)return!1;if(this.placementManager.isActive&&this._host?.root)return this._host.root.trigger("addstop"),t.stopPropagation(),!0;const e=this._host?.app,n=this._host?.root;return e&&4===e.mode?(n?.trigger("stylepastestop"),!0):e&&5===e.mode?(n?.trigger("databindpastestop"),!0):!(!e?.isEditMode||!n)&&(this.gizmoManager.detach(),n.selected=[],!0)}_handleEditModeKey(t){const e=this._host.root;if(t.metaKey||t.ctrlKey)switch(t.code){case"KeyZ":{const n=this._host?.app?.commander,i=(e?.selected||[]).filter(t=>t!==this._host).map(t=>t.state?.id).filter(Boolean);if(t.shiftKey?n?.redo():n?.undo(),e&&i.length>0){const t=i.map(t=>e.findById(t)).filter(Boolean);t.length>0&&(e.selected=t)}return t.preventDefault(),!0}case"KeyC":return e&&(this._clipboard=Yl.call(e)),t.preventDefault(),!0;case"KeyX":return e&&(this._clipboard=Gl.call(e)),t.preventDefault(),!0;case"KeyV":return e&&this._clipboard&&Vl.call(e,this._clipboard),t.preventDefault(),!0;case"KeyD":return e&&(this._clipboard=Yl.call(e),this._clipboard&&Vl.call(e,this._clipboard)),t.preventDefault(),!0;default:return!1}if("Enter"===t.code||"NumpadEnter"===t.code){const n=e?.selected;if(1===n?.length&&n[0].hasTextProperty)return ou(n[0],this.rendererManager,()=>{this.renderThreeD()}),t.preventDefault(),!0}switch(t.code){case"KeyW":return this.setGizmoMode("translate"),!0;case"KeyE":return this.setGizmoMode("rotate"),!0;case"KeyR":return this.setGizmoMode("scale"),!0;case"Delete":case"Backspace":return e&&Ll.call(e),!0}return this._handleArrowKeyMove(t,e)}_handleArrowKeyMove(t,e){const n=e?.selected;if(!n||0===n.length)return!1;const i=t.shiftKey?this._host.MPP||10:1;let r;switch(t.code){case"ArrowLeft":r={x:-i,y:0};break;case"ArrowRight":r={x:i,y:0};break;case"ArrowUp":r={x:0,y:-i};break;case"ArrowDown":r={x:0,y:i}}return!!r&&(Sc.around(this._host.app.commander,()=>{n.forEach(t=>{t.stuck||t.move(r,!1)})}),t.preventDefault(),t.stopPropagation(),!0)}_handleCursorHintKey(t){return!(t.repeat||!this._host?.app?.isEditMode)&&("AltLeft"===t.code||"AltRight"===t.code?(this._host?.element&&(this._host.element.style.cursor="grab"),!0):("ShiftLeft"===t.code||"ShiftRight"===t.code)&&(this._host?.element&&(this._host.element.style.cursor=this.gizmoManager.isEngaged?"grab":"crosshair"),!0))}_handleCameraAndViewKey(t){if(t.metaKey||t.ctrlKey||t.altKey||t.shiftKey)return!1;switch(t.code){case"KeyQ":case"Digit0":return this._host?.toggleThreeD?.(),t.preventDefault(),!0;case"Digit1":return this.setCameraView("perspective"),t.preventDefault(),!0;case"Digit2":return this.setCameraView("top"),t.preventDefault(),!0;case"Digit3":return this.setCameraView("front"),t.preventDefault(),!0;case"Digit4":return this.setCameraView("back"),t.preventDefault(),!0;case"Digit5":return this.setCameraView("right"),t.preventDefault(),!0;case"Digit6":return this.setCameraView("left"),t.preventDefault(),!0;case"KeyH":return this.onHelpToggle?.(),t.preventDefault(),!0;case"KeyB":return this.onBookmarkNavToggle?.(),t.preventDefault(),!0;case"KeyF":return this.onSearchToggle?.(),t.preventDefault(),!0;case"KeyD":return this.onDataBindingToggle?.(),t.preventDefault(),!0;case"KeyM":return this.onMonitorToggle?.(),t.preventDefault(),!0}return!1}_handlePlaybackKey(t){return!(t.metaKey||t.ctrlKey||t.altKey||t.shiftKey)&&("KeyP"!==t.code||this._host?.app?.isEditMode?"Space"===t.code&&this._host?.app?.isEditMode?(this._isSpacePanning=!0,this._beforeSpaceMode=this._host.app.mode,this._host.app.mode=2,this._host?.element&&(this._host.element.style.cursor="grab"),t.preventDefault(),!0):"Space"!==t.code||this._host?.app?.isEditMode?"KeyO"===t.code&&!this._host?.app?.isEditMode&&(this.bookmarkManager.resetPlay(),this.bookmarkManager.toggleOrbitRotation(this.controlsManager),t.preventDefault(),!0):(this.bookmarkManager.isOrbitRotating||this.bookmarkManager.isOrbitPaused?this.bookmarkManager.toggleOrbitRotation(this.controlsManager):(this.bookmarkManager.isPlaying||this.bookmarkManager.lastPlayProgress>=0)&&this.togglePlay(),t.preventDefault(),!0):(this.bookmarkManager.stopOrbitRotation(this.controlsManager),this.restartPlay(),t.preventDefault(),!0))}_onKeyUp(t){return"AltLeft"===t.code||"AltRight"===t.code||"ShiftLeft"===t.code||"ShiftRight"===t.code?(this._host?.element&&!this._isSpacePanning&&(this._host.element.style.cursor=""),!0):!("Space"!==t.code||!this._isSpacePanning)&&(this._isSpacePanning=!1,void 0!==this._beforeSpaceMode&&this._host?.app&&(this._host.app.mode=this._beforeSpaceMode,this._beforeSpaceMode=void 0),this._host?.element&&(this._host.element.style.cursor=""),t.preventDefault(),!0)}onPinch(t){if(this.controlsManager.isActive){if("perspective"!==this.cameraManager.activeView){const e=this.cameraManager.activeCamera,n=t.scale||1;e.zoom=Math.max(.1,Math.min(20,e.zoom*n)),e.updateProjectionMatrix(),this.controlsManager.markCameraChanged(),this.renderThreeD()}else{const e=t.scale||1;Math.abs(e-1)>.01&&(this.controlsManager.dollyAtCursor(1/e,0,0),this.renderThreeD())}return t.stopPropagation(),!0}return!1}onDoubleTap(){this.controlsManager.reset()}getCameraState(){const t=this._host;if(!t)return null;const e=this.cameraManager.camera;if(!e)return null;const{width:n,height:i}=t.bounds,r=Math.floor(Math.min(n,i))||1;return{view:this.cameraManager.activeView,cameraX:e.position.x/(n||1),cameraY:e.position.z/(i||1),cameraZ:e.position.y/r}}getCameraWorldState(){const t=this.cameraManager.camera;if(!t)return null;const e=this.controlsManager.target;return{position:{x:t.position.x,y:t.position.y,z:t.position.z},target:{x:e.x,y:e.y,z:e.z}}}captureSessionState(){const t=this.cameraManager.activeView,e=this.cameraManager.camera,n=this.controlsManager.target,i={view:t};return e&&(i.perspPosition={x:e.position.x,y:e.position.y,z:e.position.z}),i.orbitTarget={x:n.x,y:n.y,z:n.z},i}captureViewportInfo(){const t=this.cameraManager.activeCamera,e=this.controlsManager.target.clone();let n=0,i=0;if(t?.fov){i=2*t.position.distanceTo(e)*Math.tan(t.fov*Math.PI/180/2),n=i*(t.aspect||1)}return{target:e,visibleWidth:n,visibleHeight:i}}restoreSessionState(t){"perspective"!==t.view&&this.setCameraView(t.view,{render:!1});const e=this.cameraManager.camera;e&&t.perspPosition&&e.position.set(t.perspPosition.x,t.perspPosition.y,t.perspPosition.z),t.orbitTarget&&this.controlsManager.restoreTarget(new w.Vector3(t.orbitTarget.x,t.orbitTarget.y,t.orbitTarget.z))}saveCameraToSlot(t){if(!this._host?.app?.isEditMode)return;const e=this.cameraManager.camera;if(!e)return;if("perspective"!==this.cameraManager.activeView)return;const n=this.controlsManager.target,i=e.position;let r=n.x,s=n.y,o=n.z;if(i.distanceTo(n)<1){const t=new w.Vector3(0,0,-1).applyQuaternion(e.quaternion);r=i.x+1*t.x,s=i.y+1*t.y,o=i.z+1*t.z}const a={position:{x:i.x,y:i.y,z:i.z},target:{x:r,y:s,z:o}};this.bookmarkManager.saveSlot(t,a),this._host?.app?.isEditMode&&this._host?.set?.("cameraBookmarks",this.bookmarkManager.exportSlots()),this.onBookmarkChanged?.()}positionCameraForViewport(t,e,n,i,r){const s=this.cameraManager.activeCamera;if(!s?.position)return;const o=(s.fov||45)*Math.PI/180,a=s.aspect||1,c=i/2/Math.tan(o/2),l=n/2/(a*Math.tan(o/2)),h=Math.max(c,l),d=r?.orbitTarget?.y??0,u=new w.Vector3(t,d,e);let p;if(r?.perspPosition&&r?.orbitTarget){const t=new w.Vector3(r.perspPosition.x,r.perspPosition.y,r.perspPosition.z),e=new w.Vector3(r.orbitTarget.x,r.orbitTarget.y,r.orbitTarget.z);p=t.sub(e).normalize()}else p=s.position.clone().normalize();s.position.copy(u.clone().add(p.multiplyScalar(h)));try{this.controlsManager.restoreTarget(u)}catch{s.lookAt(u)}this._host?.invalidate()}centerToComponent(t,e){const n=this.cameraManager.activeCamera;if(!n)return;const i=new w.Vector3,r=t._realObject;if(r?.object3d)r.object3d.getWorldPosition(i);else{const{x:e=0,y:n=0}=t.center,{width:r=0,height:s=0}=t.parent?.bounds??{};i.set(e-r/2,0,n-s/2)}const s=this.controlsManager.target,o=n.position.clone().sub(s),a=i.clone().add(o);if(!e)return n.position.copy(a),this.controlsManager.restoreTarget(i),void this._host?.invalidate();const c=n.position.clone(),l=s.clone(),h=performance.now(),d=()=>{const t=performance.now()-h,e=Math.min(t/800,1),r=e<.5?2*e*e:1-Math.pow(-2*e+2,2)/2;n.position.lerpVectors(c,a,r);const s=l.clone().lerp(i,r);this.controlsManager.restoreTarget(s),this._host?.invalidate(),e<1&&requestAnimationFrame(d)};requestAnimationFrame(d)}animateToSlot(t){const e=this.cameraManager.camera;e&&(this.bookmarkManager.isPlaying&&this.bookmarkManager.stopPlay(),"perspective"!==this.cameraManager.activeView&&this.setCameraView("perspective",{render:!1}),this.bookmarkManager.animateToSlot(t,e,this.controlsManager),this.bookmarkManager.setProgressForSlot(t))}scrubPath(t){const e=this.cameraManager.camera;if(!e)return;const n=this.bookmarkManager.evaluatePath(t);n&&(e.position.copy(n.position),this.controlsManager.restoreTarget(n.target),this._host?.invalidate())}togglePlay(t=-1){const e=this.cameraManager.camera;if(e){if("perspective"!==this.cameraManager.activeView&&this.setCameraView("perspective",{render:!1}),this.bookmarkManager.isPlaying)return this.bookmarkManager.stopPlay(),void(this._pathVisible&&this.showBookmarkPath());this.hideBookmarkPath(),this.bookmarkManager.startPlay(e,this.controlsManager,2e3,1200,t)}}restartPlay(){const t=this.cameraManager.camera;t&&("perspective"!==this.cameraManager.activeView&&this.setCameraView("perspective",{render:!1}),this.bookmarkManager.stopPlay(),this.hideBookmarkPath(),this.bookmarkManager.startPlay(t,this.controlsManager,2e3,1200,-1,!0))}startAutoPlay(t){"orbit"===t?this.bookmarkManager.toggleOrbitRotation(this.controlsManager):"play"===t&&this.togglePlay()}showBookmarkPath(){this._pathVisible=!0,this.hideBookmarkPath();const t=this.sceneManager.scene;if(!t)return;const e=this.bookmarkManager.getPlayableSlots();if(0===e.length)return;const n=[];for(const t of e){const e=this.bookmarkManager.getSlot(t);e&&n.push(new w.Vector3(e.position.x,e.position.y,e.position.z))}if(n.length>=2){let e=0;for(let t=1;t<n.length;t++)e+=n[t].distanceTo(n[t-1]);const i=e/(n.length-1),r=n.length>=3?new w.CatmullRomCurve3(n,!0,"centripetal").getPoints(30*n.length):n,s=(new w.BufferGeometry).setFromPoints(r),o=new w.LineDashedMaterial({color:4890367,dashSize:.06*i,gapSize:.03*i,opacity:.5,transparent:!0,depthTest:!1});this._pathLine=new w.Line(s,o),this._pathLine.computeLineDistances(),this._pathLine.renderOrder=9999,t.add(this._pathLine)}let i;if(n.length>=2){let t=0;for(let e=1;e<n.length;e++)t+=n[e].distanceTo(n[e-1]);i=t/(n.length-1)*.08}else{const t=this.bookmarkManager.getSlot(e[0]);i=.08*(t?new w.Vector3(t.position.x,t.position.y,t.position.z).distanceTo(new w.Vector3(t.target.x,t.target.y,t.target.z)):10)}this._pathMarkers=new w.Group,this._pathMarkers.renderOrder=9999;const r=new w.MeshBasicMaterial({color:4890367,opacity:.6,transparent:!0,depthTest:!1}),s=new w.MeshBasicMaterial({color:4890367,opacity:.15,transparent:!0,depthTest:!1,side:w.DoubleSide});for(const t of e){const e=this.bookmarkManager.getSlot(t);if(!e)continue;const n=new w.Vector3(e.position.x,e.position.y,e.position.z),o=new w.Vector3(e.target.x,e.target.y,e.target.z),a=(new w.Vector3).subVectors(o,n).normalize(),c=new w.Group;c.position.copy(n);const l=(new w.Matrix4).lookAt(new w.Vector3(0,0,0),a,new w.Vector3(0,1,0));c.quaternion.setFromRotationMatrix(l);const h=.2*i,d=new w.BoxGeometry(1.2*h,.8*h,h),u=new w.Mesh(d,r);u.renderOrder=9999,c.add(u);const p=Math.max(.06*n.distanceTo(o),.5*h),f=.35*p,g=9*f/16,m=new w.BufferGeometry,y=[0,0,0,-f,g,-p,f,g,-p,f,-g,-p,-f,-g,-p],b=[0,1,2,0,2,3,0,3,4,0,4,1];m.setAttribute("position",new w.Float32BufferAttribute(y,3)),m.setIndex(b),m.computeVertexNormals();const _=new w.Mesh(m,s);_.position.z=.5*-h,_.renderOrder=9999,c.add(_);const v=new Float32Array([0,0,0,-f,g,-p,0,0,0,f,g,-p,0,0,0,f,-g,-p,0,0,0,-f,-g,-p,-f,g,-p,f,g,-p,f,g,-p,f,-g,-p,f,-g,-p,-f,-g,-p,-f,-g,-p,-f,g,-p]),x=new w.BufferGeometry;x.setAttribute("position",new w.BufferAttribute(v,3));const M=new w.LineSegments(x,new w.LineBasicMaterial({color:4890367,opacity:.5,transparent:!0,depthTest:!1}));M.position.z=.5*-h,M.renderOrder=9999,c.add(M),c.userData.bookmarkSlotIndex=t,this._pathMarkers.add(c)}t.add(this._pathMarkers),this._host?.invalidate()}hideBookmarkPath(t=!1){t&&(this._pathVisible=!1);const e=this.sceneManager.scene;if(this._pathLine&&(e?.remove(this._pathLine),this._pathLine.geometry.dispose(),this._pathLine.material.dispose(),this._pathLine=void 0),this._pathMarkers){e?.remove(this._pathMarkers);const t=new Set;this._pathMarkers.traverse(e=>{e.geometry&&e.geometry.dispose();const n=e.material;n&&!t.has(n)&&(n.dispose(),t.add(n))}),this._pathMarkers=void 0}this._host?.invalidate()}initBookmarks(){const t=this._host;if(!t)return;const e=t.state.cameraBookmarks;Array.isArray(e)&&this.bookmarkManager.importSlots(e),this.bookmarkManager.setCallbacks(()=>this._host?.invalidate())}onchange(t){if(t.hasOwnProperty("autoRotate")&&this.controlsManager.setAutoRotate(t.autoRotate),t.hasOwnProperty("cameraFloorConstraint")){const e=!this._host?.app?.isEditMode;this.controlsManager.setFloorConstraint(e&&!!t.cameraFloorConstraint)}if(t.hasOwnProperty("fov")||t.hasOwnProperty("near")||t.hasOwnProperty("far")){const t=this._host;if(t){const{near:e,far:n,fov:i}=t.state;this.cameraManager.updateProperties({near:e,far:n,fov:i}),this.controlsManager.markCameraChanged()}}t.hasOwnProperty("exposure")&&(this.rendererManager.setExposure(Number(t.exposure)||1),this.renderThreeD());let e=!1;if((t.hasOwnProperty("hemiIntensity")||t.hasOwnProperty("hemiSkyColor")||t.hasOwnProperty("hemiGroundColor"))&&(this.lightManager.updateHemisphere({intensity:t.hemiIntensity,skyColor:t.hemiSkyColor,groundColor:t.hemiGroundColor}),e=!0),t.hasOwnProperty("dirLightEnabled")){const n=this._host;n&&this.lightManager.setDirectionalEnabled(t.dirLightEnabled,{color:n.state.dirLightColor,intensity:n.state.dirLightIntensity}),e=!0}if((t.hasOwnProperty("dirLightColor")||t.hasOwnProperty("dirLightIntensity"))&&(this.lightManager.updateDirectional({color:t.dirLightColor,intensity:t.dirLightIntensity}),e=!0),t.hasOwnProperty("dirLightFollowCamera")){if(this.lightManager.setDirectionalFollowCamera(!1!==t.dirLightFollowCamera),!1===t.dirLightFollowCamera){const t=this._host?.state;this.lightManager.setDirectionalAngle(t?.dirLightAzimuth??30,t?.dirLightElevation??45)}e=!0}if(t.hasOwnProperty("dirLightAzimuth")||t.hasOwnProperty("dirLightElevation")){const n=this._host?.state;!1===n?.dirLightFollowCamera&&this.lightManager.setDirectionalAngle(t.dirLightAzimuth??n?.dirLightAzimuth??30,t.dirLightElevation??n?.dirLightElevation??45),e=!0}if(t.hasOwnProperty("dirShadowEnabled")||t.hasOwnProperty("dirShadowBias")){const n=this.lightManager.dirLight;n&&(t.hasOwnProperty("dirShadowEnabled")&&(n.castShadow=!1!==t.dirShadowEnabled),t.hasOwnProperty("dirShadowBias")&&(n.shadow.bias=t.dirShadowBias??-5e-4)),e=!0}e&&this.renderThreeD(),(t.hasOwnProperty("fillStyle")||t.hasOwnProperty("floorMaterial3d"))&&(this.sceneManager.updateFloor(this._host),this.renderThreeD()),(t.hasOwnProperty("sky")||t.hasOwnProperty("skyColor"))&&(this.sceneManager.setSky(this._host.state.sky,this._host.state.skyColor),this.renderThreeD()),t.hasOwnProperty("placement")&&(this.sceneManager.updateFloor(this._host),this._cascadeUpdateTransform(this._host),this.renderThreeD())}_cascadeUpdateTransform(t){const e=t?._realObject;e&&e.updateTransform?.();const n=t?.components;if(n)for(const t of n)this._cascadeUpdateTransform(t)}get domElement(){return this.rendererManager.domElement}getRendererSize(){return this.rendererManager.getSize()}showWebglNoSupportText(t,e,n){t.save(),t.font=e/20+"px Arial",t.textAlign="center",t.fillText("WebGL no support",e/2-e/40,n/2),t.restore()}showDebugFPS(t){t.font="100px Arial",t.textAlign="center",t.fillStyle="black",t.globalAlpha=.5,t.fillText(String($d()),100,100)}get decoratorOutlines(){return this._decoratorOutlines}addOutline(t){this._decoratorOutlines.add(t),this._syncOutlinePass(),this._host?.invalidate()}removeOutline(t){this._decoratorOutlines.delete(t),this._syncOutlinePass(),this._host?.invalidate()}clearOutlines(){this._decoratorOutlines.clear(),this._syncOutlinePass(),this._host?.invalidate()}addArrow(t,e,n,i={}){this.removeArrow(t);const r=e._realObject,s=n._realObject;if(!r?.object3d||!s?.object3d)return;const o=new w.Vector3,a=new w.Vector3;r.object3d.getWorldPosition(o),s.object3d.getWorldPosition(a),o.y+=1,a.y+=1;const c=this.rendererManager.getSize(),l=Jd(o,a,i,new w.Vector2(c.width,c.height));l.name=`arrow-${t}`,l.userData._arrowStyle=i,this.sceneManager.scene?.add(l),this._arrows.set(t,l),this._host?.invalidate()}removeArrow(t){const e=this._arrows.get(t);e&&(e.traverse(t=>{if(t instanceof h.Line2)return t.geometry.dispose(),void t.material.dispose();if(t instanceof w.Sprite){const e=t.material.map;if(e){e.dispose();const t=e.source?.data;t instanceof HTMLCanvasElement&&(t.width=0,t.height=0)}return void t.material.dispose()}(t instanceof w.Mesh||t instanceof w.Line)&&(t.geometry.dispose(),t.material instanceof w.Material&&t.material.dispose())}),e.removeFromParent(),this._arrows.delete(t),this._host?.invalidate())}clearArrows(){for(const t of this._arrows.keys())this.removeArrow(t)}updateArrow(t,e,n){const i=this._getArrowStyle(t);i&&this.addArrow(t,e,n,i)}_getArrowStyle(t){const e=this._arrows.get(t);return e?e.userData._arrowStyle??null:null}highlightBookmarkMarker(t){this._highlightedMarkerIndex!==t&&(this._highlightedMarkerIndex=t,this._syncOutlinePass(),this._host?.invalidate())}clearBookmarkMarkerHighlight(){-1!==this._highlightedMarkerIndex&&(this._highlightedMarkerIndex=-1,this._syncOutlinePass(),this._host?.invalidate())}_syncOutlinePass(){const t=[...this._selectionOutlineObjects];for(const e of this._decoratorOutlines){const n=e._realObject;n?.object3d&&!t.includes(n.object3d)&&t.push(n.object3d)}if(this._highlightedMarkerIndex>=0&&this._pathMarkers)for(const e of this._pathMarkers.children)if(e.userData.bookmarkSlotIndex===this._highlightedMarkerIndex){e.traverse(e=>{e.isMesh&&t.push(e)});break}this.rendererManager.setOutlineObjects(t)}_handleSelectionChanged(t){const e=t.filter(t=>t!==this._host&&t._realObject);if(e.length>=1){const t=e[0]._realObject;t?.object3d&&t.gizmoTransformable?this.gizmoManager.attached&&this.gizmoManager.attach(t.object3d):this.gizmoManager.detach()}else this.gizmoManager.detach();const n=e.filter(t=>t.mutable&&t.path);n.length>0&&this.sceneManager.scene?this.vertexGizmoManager.attachMultiple(n,this.sceneManager.scene,this._host?.app?.commander):this.vertexGizmoManager.detach(),this._updateSelectionOutline(e),this._host?.invalidate()}_updateSelectionOutline(t){this._selectionOutlineObjects=[];for(const e of t){const t=e._realObject;t?.object3d&&this._selectionOutlineObjects.push(t.object3d)}this._syncOutlinePass()}}Ja.register("three",{reflow:function(t){},capturables:function(t){return t.state.threed?[]:t.components},drawables:function(t){return t.state.threed?[]:t.components},isStuck:function(t){return!1}});const zu={x:1,y:1},Lu={x:0,y:0},Iu='<svg viewBox="0 0 20 20" width="18" height="18" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">\n <path d="M4 5l12-1v12l-12-1z"/>\n <circle cx="10" cy="10" r="1.5"/>\n</svg>',Ru='<svg viewBox="0 0 20 20" width="18" height="18" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">\n <rect x="4" y="4" width="12" height="12" rx="1"/>\n <path d="M10 2v2M10 16v2"/>\n <path d="M10 7v3l2-1.5" opacity="0.5"/>\n</svg>',ju='<svg viewBox="0 0 20 20" width="18" height="18" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">\n <path d="M4 14l2-10h8l2 10z"/>\n <path d="M6 4h8" stroke-width="2"/>\n</svg>',Fu='<svg viewBox="0 0 20 20" width="18" height="18" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">\n <path d="M4 6l2 10h8l2-10z"/>\n <path d="M6 16h8" stroke-width="2"/>\n</svg>',Bu='<svg viewBox="0 0 20 20" width="18" height="18" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">\n <path d="M6 4l10 2v8l-10 2z"/>\n <path d="M16 6v8" stroke-width="2"/>\n</svg>',Nu='<svg viewBox="0 0 20 20" width="18" height="18" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">\n <path d="M14 4L4 6v8l10 2z"/>\n <path d="M4 6v8" stroke-width="2"/>\n</svg>',Hu={mutable:!1,resizable:!0,rotatable:!1,properties:[{type:"number",label:"width",name:"width"},{type:"number",label:"height",name:"height"},{type:"select",label:"fit-mode",name:"fitMode",property:{options:["ratio","both","width","height","center","none"]}}]};class Yu extends Ad{constructor(){super(...arguments),this._threeDUserDeactivated=!1}get nature(){return Hu}get is3dMode(){return!!this._threeCapability?.isInitialized}is3dContainer(){return this.is3dMode}get gizmoMode(){return this._threeCapability?.gizmoMode}setGizmoMode(t){this._threeCapability?.setGizmoMode(t)}get scene3d(){return this._threeCapability?.scene3d}get renderer3d(){return this._threeCapability?.renderer3d}get activeCamera3d(){return this._threeCapability?.activeCamera}get mixer(){return this._threeCapability?.mixer}addArrow3D(t,e,n,i){this._threeCapability?.addArrow(t,e,n,i)}removeArrow3D(t){this._threeCapability?.removeArrow(t)}clearArrows3D(){this._threeCapability?.clearArrows()}_buildLightingConfig(){const t=this.state,e={hemisphere:{skyColor:t.hemiSkyColor||"#ffffff",groundColor:t.hemiGroundColor||"#444444",intensity:t.hemiIntensity??4}};if(!1!==t.dirLightEnabled){const n=!1!==t.dirLightFollowCamera;if(e.directional={color:t.dirLightColor||"#ffffff",intensity:t.dirLightIntensity??2,attachToCamera:n,castShadow:!1!==t.dirShadowEnabled,shadowMapSize:t.dirShadowMapSize??2048,shadowBias:t.dirShadowBias??-5e-4},!n){const n=(t.dirLightAzimuth??30)*Math.PI/180,i=(t.dirLightElevation??45)*Math.PI/180,r=1e3;e.directional.position=[r*Math.cos(i)*Math.sin(n),r*Math.sin(i),r*Math.cos(i)*Math.cos(n)]}}return e}_hide2DLayers(){this.canvas&&(this.canvas.style.display="none"),this._overlay&&(this._overlay.style.display="none"),this._auxCanvas&&(this._auxCanvas.style.display="none"),this._decoratorAuxOverlay&&(this._decoratorAuxOverlay.style.display="none");for(const t of this.root?.assist_layers||[])t.element&&(t.element.style.display="none")}get _hasZoomHandler(){return(this.root?.model?.handlers||[]).includes("zoom-handler")}get _needsViewportSync(){return!!this.app?.isEditMode||this._hasZoomHandler}_activateThreeD(t=!1){Md.hideAll(this.root),this._threeCapability&&this._deactivateThreeD(),t&&!this._needsViewportSync&&(this._saved2DViewport={scale:{...this.get("scale")||{x:1,y:1}},translate:{...this.get("translate")||{x:0,y:0}}}),this._threeCapability=new Ou,this._threeCapability.init(this,{lightingConfig:this._buildLightingConfig(),css3DSceneAttribute:"model-layer:css3d-renderer"}),this._hide2DLayers(),this.root?.transitionEffect?.dispose();const e=xs.getInstance(),n=[];this.decoratorOverlay&&(n.push(...e.getTargetsWithType(this.decoratorOverlay,"border-highlighting")),e.removeAllFromOverlay(this.decoratorOverlay,"border-highlighting")),this.decoratorAuxOverlay&&(n.push(...e.getTargetsWithType(this.decoratorAuxOverlay,"border-highlighting")),e.removeAllFromOverlay(this.decoratorAuxOverlay,"border-highlighting"));for(const t of n)this._threeCapability.addOutline(t);if(this._threeCapability.domElement&&this.element){const t=this._threeCapability.domElement;t.style.position="absolute",t.style.left="0",t.style.top="0",t.style.pointerEvents="none",t.setAttribute("scene","model-layer-webgl");const e=this._decoratorOverlay||this.element.firstChild;this.element.insertBefore(t,e)}if(this._threeCapability.buildOverlays(),t&&this._needsViewportSync){const t=this.get("scale")||{x:1};this._2dScaleBeforeThreeD=t.x||1,this._initCameraFrom2DViewport();const e=this._threeCapability?.captureViewportInfo();e&&(this._initialVisibleHeight=e.visibleHeight)}else if(this._lastCameraState)this._threeCapability.restoreSessionState(this._lastCameraState);else{const t=this.model.initialCameraView;t&&"perspective"!==t&&this._threeCapability.setCameraView(t,{render:!1})}if(this._pendingCameraView&&(this._threeCapability.setCameraView(this._pendingCameraView,{render:!1}),delete this._pendingCameraView),this._threeCapability.initBookmarks(),!this.app?.isEditMode){const t=this.model?.cameraAutoPlay;"orbit"!==t&&"play"!==t||this._threeCapability.startAutoPlay(t)}this.app?.isEditMode&&this._createToolbar(),this._registerPopupCallbacks();const i=this.root;i?.selected?.length>0&&this._threeCapability._handleSelectionChanged(i.selected),this._resizeThreeD(!0),this.element&&"function"==typeof this.element.focus&&this.element.focus()}_createToolbar(){if(!this.element)return;this._removeToolbar();const t=!!this._threeCapability,e=document.createElement("div");e.setAttribute("scene","threed-toolbar"),e.style.cssText=["position:absolute","top:12px","left:12px","display:flex","flex-direction:column","gap:1px","padding:4px","background:rgba(30,30,30,0.92)","border:1px solid rgba(255,255,255,0.08)","border-radius:8px","pointer-events:auto","backdrop-filter:blur(8px)","-webkit-backdrop-filter:blur(8px)","box-shadow:0 4px 16px rgba(0,0,0,0.4),inset 0 1px 0 rgba(255,255,255,0.05)","user-select:none"].join(";");const n=["width:32px","height:32px","display:flex","align-items:center","justify-content:center","border-radius:5px","cursor:pointer","transition:all 0.12s ease","position:relative"].join(";"),i=(t,e)=>{const i=document.createElement("div");return i.innerHTML=t,i.title=e,i.style.cssText=n,this._applyButtonStyle(i,!1),i.addEventListener("mouseenter",()=>{i.dataset.active||(i.style.background="rgba(255,255,255,0.1)")}),i.addEventListener("mouseleave",()=>{this._applyButtonStyle(i,!!i.dataset.active)}),i},r=()=>{const t=document.createElement("div");return t.style.cssText="height:1px;margin:3px 4px;background:rgba(255,255,255,0.1)",t},s=i(t?'<svg viewBox="0 0 20 20" width="18" height="18" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">\n <rect x="3" y="3" width="14" height="14" rx="1.5"/>\n <line x1="3" y1="10" x2="17" y2="10" opacity="0.4"/>\n <line x1="10" y1="3" x2="10" y2="17" opacity="0.4"/>\n </svg>':'<svg viewBox="0 0 20 20" width="18" height="18" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">\n <path d="M10 2l7 4v8l-7 4-7-4V6l7-4z"/>\n <path d="M10 10l7-4M10 10v8M10 10L3 6"/>\n </svg>',t?"2D Mode":"3D Mode");if(this._applyToggleStyle(s,t),s.addEventListener("mouseenter",()=>{s.style.background=t?"rgba(255,160,60,0.35)":"rgba(255,160,60,0.25)"}),s.addEventListener("mouseleave",()=>{this._applyToggleStyle(s,t)}),s.addEventListener("click",()=>{this.toggleThreeD()}),e.appendChild(s),!t)return e.addEventListener("mousedown",t=>t.stopPropagation()),e.addEventListener("mouseup",t=>t.stopPropagation()),this.target.appendChild(e),void(this._toolbar=e);e.appendChild(r());const o=this._threeCapability,a=document.createElement("div");a.style.cssText="display:flex;flex-direction:column;gap:1px";const c=o.getCameraState()?.view??"perspective",l=[{view:"perspective",icon:Iu,title:"Perspective"},{view:"top",icon:Ru,title:"Top"},{view:"front",icon:ju,title:"Front"},{view:"back",icon:Fu,title:"Back"},{view:"right",icon:Bu,title:"Right"},{view:"left",icon:Nu,title:"Left"}],h=[];for(const{view:t,icon:e,title:n}of l){const r=i(e,n);r.dataset.view=t,t===c&&(this._applyButtonStyle(r,!0),r.dataset.active="1"),r.addEventListener("click",()=>{this._threeCapability?.setCameraView(t)}),h.push(r),a.appendChild(r)}a.appendChild(r());const d=i('<svg viewBox="0 0 20 20" width="18" height="18" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">\n <path d="M10 2 L13 5 L12 10 L15 13 L5 13 L8 10 L7 5 Z"/>\n <line x1="10" y1="13" x2="10" y2="18"/>\n </svg>',"Pin Camera View");d.addEventListener("click",()=>{const t=this._threeCapability?.getCameraState();t&&(this.set("cameraX",t.cameraX),this.set("cameraY",t.cameraY),this.set("cameraZ",t.cameraZ),this._threeCapability?.pinResetPosition())}),a.appendChild(d),e.appendChild(a),this._cameraButtons=h,o.onGizmoAttachChanged=t=>{this.root?.trigger("gizmoattach",t)},o.onCameraViewChanged=t=>{this._updateCameraButtons(t)},o.onGizmoModeChanged=t=>{this.root?.trigger("gizmomode",t)},e.addEventListener("mousedown",t=>{t.stopPropagation(),t.preventDefault()}),e.addEventListener("mouseup",t=>t.stopPropagation()),this.target.appendChild(e),this._toolbar=e}_applyToggleStyle(t,e){e?(t.style.background="rgba(255,140,40,0.3)",t.style.color="#ffaa44",t.style.boxShadow="inset 0 0 0 1.5px rgba(255,140,40,0.5)"):(t.style.background="rgba(255,140,40,0.15)",t.style.color="#cc8833",t.style.boxShadow="inset 0 0 0 1.5px rgba(255,140,40,0.3)")}_applyButtonStyle(t,e){e?(t.style.background="rgba(74,158,255,0.25)",t.style.color="#4a9eff",t.style.boxShadow="inset 0 0 0 1.5px rgba(74,158,255,0.5)",t.dataset.active="1"):(t.style.background="transparent",t.style.color="rgba(255,255,255,0.55)",t.style.boxShadow="none",delete t.dataset.active)}_updateCameraButtons(t){this._cameraButtons?.forEach(e=>{this._applyButtonStyle(e,e.dataset.view===t)})}_registerPopupCallbacks(){const t=this._threeCapability;t&&(t.onHelpToggle=()=>this._toggleHelpPanel(),t.onSearchToggle=()=>this.onSearchToggle?.(),t.onDataBindingToggle=()=>this.onDataBindingToggle?.(),t.onMonitorToggle=()=>this.onMonitorToggle?.(),t.onBookmarkNavToggle=()=>this._toggleBookmarkNav(),t.onBookmarkEditToggle=()=>this._toggleBookmarkEdit())}_closeFloatingPopup(){this._floatingPopupCloseHandler&&(this.target?.removeEventListener("mousedown",this._floatingPopupCloseHandler,!0),this._floatingPopupCloseHandler=void 0),this._floatingPopup?.parentNode&&this._floatingPopup.parentNode.removeChild(this._floatingPopup),this._floatingPopup=void 0}_showFloatingPopup(t,e=!1){this._closeFloatingPopup(),this._floatingPopup=t,e||(this._floatingPopupCloseHandler=e=>{t.contains(e.target)||this._closeFloatingPopup()},setTimeout(()=>{this.target?.addEventListener("mousedown",this._floatingPopupCloseHandler,!0)},0)),t.addEventListener("mousedown",t=>{t.stopPropagation();const e=t.target?.tagName;"INPUT"!==e&&"TEXTAREA"!==e&&"SELECT"!==e&&t.preventDefault()}),t.addEventListener("mouseup",t=>t.stopPropagation()),this._makePopupDraggable(t),this.target.appendChild(t)}_makePopupDraggable(t){let e=0,n=0,i=0,r=0;const s=s=>{const o=s.clientX-e,a=s.clientY-n;t.style.left=i+o+"px",t.style.top=r+a+"px"},o=e=>{t.releasePointerCapture(e.pointerId),t.removeEventListener("pointermove",s),t.removeEventListener("pointerup",o),t.style.cursor=""};t.addEventListener("pointerdown",a=>{const c=a.target,l=c.tagName?.toLowerCase();if("button"===l||"input"===l||"select"===l||"pointer"===c.style.cursor)return;if(c.closest("[data-drag-handle]"))return;const h=t.getBoundingClientRect(),d=t.parentElement.getBoundingClientRect();i=h.left-d.left,r=h.top-d.top,t.style.left=i+"px",t.style.top=r+"px",t.style.right="auto",t.style.bottom="auto",t.style.transform="none",e=a.clientX,n=a.clientY,t.style.cursor="grabbing",t.setPointerCapture(a.pointerId),t.addEventListener("pointermove",s),t.addEventListener("pointerup",o)})}_toggleHelpPanel(){if("help"===this._floatingPopup?.dataset.popupType)return void this._closeFloatingPopup();const t=!!this.app?.isEditMode,e=document.createElement("div");e.dataset.popupType="help",e.style.cssText=["position:absolute","top:50%","left:50%","transform:translate(-50%,-50%)","max-width:min(560px, calc(100% - 40px))","max-height:calc(100% - 40px)","overflow-y:auto","padding:16px 20px","background:rgba(30,30,30,0.94)","border:1px solid rgba(255,255,255,0.08)","border-radius:10px","pointer-events:auto","backdrop-filter:blur(8px)","-webkit-backdrop-filter:blur(8px)","box-shadow:0 4px 20px rgba(0,0,0,0.5)","user-select:none","color:rgba(255,255,255,0.85)","font:12px/1.6 -apple-system,BlinkMacSystemFont,sans-serif","z-index:200"].join(";");const n=document.createElement("div");n.textContent="×",n.style.cssText="position:absolute;top:8px;right:12px;cursor:pointer;font-size:18px;color:rgba(255,255,255,0.4);line-height:1",n.addEventListener("click",()=>this._closeFloatingPopup()),n.addEventListener("mouseenter",()=>{n.style.color="#fff"}),n.addEventListener("mouseleave",()=>{n.style.color="rgba(255,255,255,0.4)"}),e.appendChild(n);const i=document.createElement("div");i.textContent="Help",i.style.cssText="font-size:13px;font-weight:600;color:#4a9eff;margin-bottom:12px",e.appendChild(i);const r=document.createElement("div");r.style.cssText="display:grid;grid-template-columns:1fr 1fr;gap:0 24px",e.appendChild(r);const s=[{label:"Camera",items:[{key:"1",desc:"Perspective",icon:Iu},{key:"2",desc:"Top",icon:Ru},{key:"3",desc:"Front",icon:ju},{key:"4",desc:"Back",icon:Fu},{key:"5",desc:"Right",icon:Bu},{key:"6",desc:"Left",icon:Nu},{key:"0 / Q",desc:"Exit 3D"}]},{label:"Bookmarks",items:[{key:"B",desc:"Bookmark navigator"},{key:"Shift+B",desc:"Bookmark editor",editOnly:!0},{key:"P",desc:"Play tour",viewOnly:!0},{key:"O",desc:"Orbit rotation",viewOnly:!0},{key:"Space",desc:"Pan mode (edit) / Pause (view)"}]},{label:"Navigation",items:[{key:"Drag",desc:"Rotate camera"},{key:"Alt+Drag",desc:"Pan camera"},{key:"Space+Drag",desc:"Pan camera (no select)",editOnly:!0},{key:"Shift+Drag",desc:"Box select",editOnly:!0},{key:"Scroll",desc:"Dolly zoom"},{key:"DblClick",desc:"Reset camera"},{key:"Arrows",desc:"Pan camera"}]},{label:"Edit",items:[{key:"W",desc:"Move gizmo",editOnly:!0},{key:"E",desc:"Rotate gizmo",editOnly:!0},{key:"R",desc:"Scale gizmo",editOnly:!0},{key:"Ctrl+Z",desc:"Undo",editOnly:!0},{key:"Ctrl+Shift+Z",desc:"Redo",editOnly:!0},{key:"Ctrl+C/X/V",desc:"Copy / Cut / Paste",editOnly:!0},{key:"Del",desc:"Delete selected",editOnly:!0},{key:"Esc",desc:"Deselect all",editOnly:!0}]},{label:"Misc",items:[{key:"H",desc:"This help"},{key:"F",desc:"Search"}]}].map(e=>({...e,items:e.items.filter(e=>!(e.editOnly&&!t)&&(!e.viewOnly||!t))})).filter(t=>t.items.length>0),o=s.reduce((t,e)=>t+e.items.length+1,0);let a=0,c=s.length;for(let t=0;t<s.length;t++)if(a+=s[t].items.length+1,a>=o/2){c=t+1;break}const l=[s.slice(0,c),s.slice(c)];for(const t of l){const e=document.createElement("div");let n=!0;for(const i of t){if(!n){const t=document.createElement("div");t.style.cssText="height:1px;margin:8px 0;background:rgba(255,255,255,0.08)",e.appendChild(t)}n=!1;const t=document.createElement("div");t.textContent=i.label,t.style.cssText="font-size:10px;font-weight:700;text-transform:uppercase;color:rgba(255,255,255,0.45);margin:0 0 5px;letter-spacing:0.8px",e.appendChild(t);for(const t of i.items){const n=document.createElement("div");n.style.cssText="display:flex;justify-content:space-between;align-items:center;padding:2px 0;gap:12px";const i=document.createElement("span");i.style.cssText="display:inline-flex;gap:2px;flex-shrink:0";for(const e of t.key.split("+")){const n=document.createElement("kbd");if(n.textContent=e.trim(),n.style.cssText="font-size:10px;font-family:monospace;padding:1px 5px;border-radius:3px;background:rgba(255,255,255,0.08);border:1px solid rgba(255,255,255,0.12);color:rgba(255,255,255,0.65);line-height:1.4",i.appendChild(n),e!==t.key.split("+").at(-1)){const t=document.createElement("span");t.textContent="+",t.style.cssText="color:rgba(255,255,255,0.2);font-size:10px;margin:0 1px",i.appendChild(t)}}const r=document.createElement("span");if(r.style.cssText="font-size:11px;color:rgba(255,255,255,0.7);text-align:right;white-space:nowrap;display:inline-flex;align-items:center;gap:4px",r.appendChild(document.createTextNode(t.desc)),t.icon){const e=document.createElement("span");e.innerHTML=t.icon,e.style.cssText="display:inline-flex;opacity:0.6",r.appendChild(e)}n.appendChild(i),n.appendChild(r),e.appendChild(n)}}r.appendChild(e)}this._showFloatingPopup(e)}_toggleBookmarkNav(){"bookmark-nav"!==this._floatingPopup?.dataset.popupType?this._buildBookmarkPopup("bookmark-nav"):this._closeFloatingPopup()}_toggleBookmarkEdit(){"bookmark-edit"!==this._floatingPopup?.dataset.popupType?this._buildBookmarkPopup("bookmark-edit"):this._closeFloatingPopup()}_buildBookmarkPopup(t){const e=this._threeCapability;if(!e)return;const n="bookmark-nav"===t,i=!!this.app?.isEditMode,r=document.createElement("div");r.dataset.popupType=t,r.tabIndex=-1,r.style.cssText=["position:absolute",n?"bottom:12px":"top:12px","right:12px","min-width:"+(n?"140px":"200px"),"padding:10px 12px","background:rgba(30,30,30,0.94)","border:1px solid rgba(255,255,255,0.08)","border-radius:10px","pointer-events:auto","backdrop-filter:blur(8px)","-webkit-backdrop-filter:blur(8px)","box-shadow:0 4px 20px rgba(0,0,0,0.5)","user-select:none","color:rgba(255,255,255,0.85)","font:12px/1.5 -apple-system,BlinkMacSystemFont,sans-serif","z-index:200"].join(";");const s=document.createElement("div");s.textContent="×",s.style.cssText="position:absolute;top:6px;right:10px;cursor:pointer;font-size:18px;color:rgba(255,255,255,0.4);line-height:1",s.addEventListener("click",()=>this._closeFloatingPopup()),s.addEventListener("mouseenter",()=>{s.style.color="#fff"}),s.addEventListener("mouseleave",()=>{s.style.color="rgba(255,255,255,0.4)"}),r.appendChild(s);const o=document.createElement("div");o.textContent="Bookmarks",o.style.cssText="font-size:13px;font-weight:600;color:#4a9eff;margin-bottom:8px;cursor:grab",r.appendChild(o);const a=document.createElement("div");a.style.cssText="display:flex;flex-direction:column;gap:2px",r.appendChild(a);const c=e.bookmarkManager,l=()=>{i&&this.set?.("cameraBookmarks",c.exportSlots()),e.onBookmarkChanged?.()},h="border:none;background:transparent;color:inherit;cursor:pointer;padding:2px 4px;border-radius:4px;font-size:13px;line-height:1;display:flex;align-items:center;justify-content:center;width:24px;height:24px",d=t=>{const e=28,n=window.devicePixelRatio||1,i=document.createElement("canvas");i.width=e*n,i.height=e*n,i.style.cssText="width:28px;height:28px;flex-shrink:0;border-radius:50%;background:rgba(0,0,0,0.3)";const r=i.getContext("2d");r.scale(n,n);const s=14,o=14,a=12,c=t.position.x-t.target.x,l=t.position.z-t.target.z,h=t.position.y-t.target.y,d=Math.sqrt(c*c+l*l),u=Math.sqrt(c*c+h*h+l*l),p=u>.001?Math.max(0,h/u):0;let f=0,g=0;d>.001&&(f=c/d,g=l/d);const m=1-.6*p,y=s+f*a*.7*m,b=o+g*a*.7*m;r.strokeStyle="rgba(255,255,255,0.12)",r.lineWidth=1,r.beginPath(),r.arc(s,o,a,0,2*Math.PI),r.stroke(),r.strokeStyle="rgba(255,255,255,0.06)",r.beginPath(),r.moveTo(s,2),r.lineTo(s,26),r.moveTo(2,o),r.lineTo(26,o),r.stroke(),r.fillStyle="rgba(255,255,255,0.25)",r.beginPath(),r.arc(s,o,1.5,0,2*Math.PI),r.fill(),r.strokeStyle=`rgba(74,158,255,${.2+.2*p})`,r.lineWidth=1,r.beginPath(),r.moveTo(y,b),r.lineTo(s,o),r.stroke();const _=.6+.4*p;r.fillStyle=`rgba(74,158,255,${_})`,r.beginPath(),r.arc(y,b,3,0,2*Math.PI),r.fill();const v=Math.atan2(g,f),x=Math.PI/8;return r.fillStyle="rgba(74,158,255,0.08)",r.beginPath(),r.moveTo(y,b),r.arc(y,b,.6*a,v+Math.PI-x,v+Math.PI+x),r.closePath(),r.fill(),i},u=()=>{const t=e.getCameraWorldState();if(!t)return-1;const n=.01;for(let e=1;e<=9;e++){const i=c.getSlot(e);if(i&&(Math.abs(t.position.x-i.position.x)<n&&Math.abs(t.position.y-i.position.y)<n&&Math.abs(t.position.z-i.position.z)<n&&Math.abs(t.target.x-i.target.x)<n&&Math.abs(t.target.y-i.target.y)<n&&Math.abs(t.target.z-i.target.z)<n))return e}return-1};let p,f,g=-1;const m=()=>{a.innerHTML="";let t=!1;const i=u(),r=Array.from({length:9},(t,e)=>e+1);for(const s of r){const r=c.getSlot(s),o=!!r,u=s===i;if(n&&!o)continue;t=t||o;const p=document.createElement("div"),f=u?"rgba(74,158,255,0.1)":"transparent";if(p.style.cssText=`display:flex;align-items:center;gap:6px;padding:${n?"6px 8px":"3px 4px"};border-radius:6px;transition:background 0.15s;background:${f}${u?";box-shadow:inset 0 0 0 1px rgba(74,158,255,0.25)":""}`,p.dataset.active=u?"1":"",p.addEventListener("mouseenter",()=>{p.style.background=p.dataset.active?"rgba(74,158,255,0.15)":"rgba(255,255,255,0.06)",!n&&o&&e.highlightBookmarkMarker(s)}),p.addEventListener("mouseleave",()=>{const t=p.dataset.active;p.style.background=t?"rgba(74,158,255,0.1)":"transparent",n||e.clearBookmarkMarkerHighlight()}),n){if(o&&r){const t=d(r);t.style.pointerEvents="none",p.appendChild(t)}const t=document.createElement("span");t.textContent=r?.name||"noname",t.style.cssText=`flex:1;color:${r?.name?"rgba(255,255,255,0.8)":"rgba(255,255,255,0.35)"};font-size:13px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;pointer-events:none;${r?.name?"":"font-style:italic"}`,p.appendChild(t),p.style.cursor="pointer",p.addEventListener("click",()=>{e.animateToSlot(s)})}else{const t=document.createElement("div");t.textContent="⠿";const n=o,i=o?"color:rgba(255,255,255,0.3)":"color:rgba(255,255,255,0.12)";if(t.style.cssText=`width:16px;display:flex;align-items:center;justify-content:center;font-size:14px;flex-shrink:0;user-select:none;${i}${n?";cursor:grab":""}`,n&&(t.dataset.dragHandle="1",t.addEventListener("mouseenter",()=>{t.style.color="rgba(255,255,255,0.6)"}),t.addEventListener("mouseleave",()=>{t.style.color="rgba(255,255,255,0.3)"})),p.appendChild(t),o&&r){const t=d(r);t.style.pointerEvents="none",p.appendChild(t)}o&&(p.style.cursor="pointer",p.addEventListener("click",t=>{const n=t.target.tagName;"INPUT"!==n&&"BUTTON"!==n&&e.animateToSlot(s)}));const a=document.createElement("input");a.type="text",a.value=r?.name||"",a.placeholder=o?"noname":"Empty",a.style.cssText=`width:80px;font-size:12px;color:${o?"rgba(255,255,255,0.7)":"rgba(255,255,255,0.3)"};background:transparent;border:none;border-bottom:1px solid rgba(255,255,255,0.1);outline:none;padding:2px 0;min-width:0`,a.addEventListener("focus",()=>{a.style.borderBottomColor="rgba(74,158,255,0.5)",a.style.color="rgba(255,255,255,0.9)"}),a.addEventListener("blur",()=>{a.style.borderBottomColor="rgba(255,255,255,0.1)",a.style.color=o?"rgba(255,255,255,0.7)":"rgba(255,255,255,0.3)",o&&(c.renameSlot(s,a.value.trim()),l())}),a.addEventListener("keydown",t=>{t.stopPropagation(),t.isComposing||"Enter"!==t.key||a.blur()}),p.appendChild(a);const u=document.createElement("div");if(u.style.cssText="display:flex;gap:2px;flex-shrink:0",o){const t=document.createElement("button");t.textContent="📌",t.title="Overwrite with current view",t.style.cssText=h+";color:#ffaa44",t.addEventListener("mouseenter",()=>{t.style.background="rgba(255,170,68,0.15)"}),t.addEventListener("mouseleave",()=>{t.style.background="transparent"}),t.addEventListener("click",()=>{e.saveCameraToSlot(s),m()}),u.appendChild(t);const n=document.createElement("button");n.textContent="🗑",n.title="Delete this slot",n.style.cssText=h+";color:#ff6b6b",n.addEventListener("mouseenter",()=>{n.style.background="rgba(255,107,107,0.15)"}),n.addEventListener("mouseleave",()=>{n.style.background="transparent"}),n.addEventListener("click",()=>{c.clearSlot(s),l(),m()}),u.appendChild(n);const i=document.createElement("button");i.textContent="⋮",i.title="Playlist settings",i.style.cssText=h+";color:rgba(255,255,255,0.35);font-size:14px",i.addEventListener("mouseenter",()=>{i.style.background="rgba(255,255,255,0.08)"}),i.addEventListener("mouseleave",()=>{i.style.background="transparent"}),u.appendChild(i)}else{const t=document.createElement("button");t.textContent="📌",t.title="Save current view here",t.style.cssText=h+";color:#4ade80",t.addEventListener("mouseenter",()=>{t.style.background="rgba(74,222,128,0.15)"}),t.addEventListener("mouseleave",()=>{t.style.background="transparent"}),t.addEventListener("click",()=>{e.saveCameraToSlot(s),m()}),u.appendChild(t)}p.appendChild(u)}const y=document.createElement("div");if(y.dataset.slotIndex=String(s),y.dataset.filled=o?"1":"",y.appendChild(p),!n&&o){const t=p.querySelector("[data-drag-handle]");t&&t.addEventListener("pointerdown",e=>{e.preventDefault(),e.stopPropagation(),y.style.opacity="0.3",y.style.pointerEvents="none",y.style.outline="1px dashed rgba(74,158,255,0.4)",y.style.borderRadius="4px",t.style.cursor="grabbing";const n=document.createElement("div");n.style.cssText="height:2px;background:#4a9eff;border-radius:1px;margin:1px 0",t.setPointerCapture(e.pointerId);const i=t=>{const e=Array.from(a.querySelectorAll('[data-slot-index][data-filled="1"]'));n.parentNode&&n.parentNode.removeChild(n);let i=null;for(const n of e){if(n===y)continue;const e=n.getBoundingClientRect();if(t.clientY<e.top+e.height/2){i=n;break}}if(i)a.insertBefore(n,i);else{const t=e[e.length-1];t&&t.after(n)}},r=e=>{t.releasePointerCapture(e.pointerId),t.removeEventListener("pointermove",i),t.removeEventListener("pointerup",r),y.style.cssText="",t.style.cursor="grab";const s=Array.from(a.querySelectorAll('[data-slot-index][data-filled="1"]'));n.parentNode&&(a.insertBefore(y,n),n.parentNode.removeChild(n));const o=Array.from(a.querySelectorAll('[data-slot-index][data-filled="1"]')).map(t=>parseInt(t.dataset.slotIndex)).map(t=>{const e=c.getSlot(t);return e?{...e,name:e.name}:void 0}),h=s.map(t=>parseInt(t.dataset.slotIndex)).sort((t,e)=>t-e);o.forEach((t,e)=>{const n=h[e];t?c.saveSlot(n,t):c.clearSlot(n)}),l(),m()};t.addEventListener("pointermove",i),t.addEventListener("pointerup",r)})}if(!n&&o&&r){const t=document.createElement("div");t.dataset.slotDetail="1";const e=g===s;t.style.cssText=`display:${e?"block":"none"};margin:2px 0 4px 26px;padding:6px 8px;background:rgba(255,255,255,0.03);border-radius:4px;border:1px solid rgba(255,255,255,0.06)`;const n="width:50px;font-size:11px;color:rgba(255,255,255,0.7);background:rgba(255,255,255,0.06);border:1px solid rgba(255,255,255,0.12);border-radius:3px;padding:2px 4px;outline:none;text-align:right",i="font-size:10px;color:rgba(255,255,255,0.45);white-space:nowrap",o="display:flex;align-items:center;gap:6px;margin-bottom:4px",c=document.createElement("div");c.style.cssText=o;const h=document.createElement("span");h.textContent="Hold",h.style.cssText=i+";width:55px";const d=document.createElement("input");d.type="number",d.min="0",d.step="500",d.value=String(r.holdDuration??2e3),d.style.cssText=n;const u=document.createElement("span");u.textContent="ms",u.style.cssText=i,d.addEventListener("change",()=>{const t=parseInt(d.value);r.holdDuration=isNaN(t)?void 0:Math.max(0,t),l()}),d.addEventListener("keydown",t=>t.stopPropagation()),c.appendChild(h),c.appendChild(d),c.appendChild(u),t.appendChild(c);const f=document.createElement("div");f.style.cssText=o;const m=document.createElement("span");m.textContent="Transition",m.style.cssText=i+";width:55px";const b=document.createElement("input");b.type="number",b.min="0",b.step="200",b.value=String(r.transitionDuration??1200),b.style.cssText=n;const _=document.createElement("span");_.textContent="ms",_.style.cssText=i,b.addEventListener("change",()=>{const t=parseInt(b.value);r.transitionDuration=isNaN(t)?void 0:Math.max(0,t),l()}),b.addEventListener("keydown",t=>t.stopPropagation()),f.appendChild(m),f.appendChild(b),f.appendChild(_),t.appendChild(f);const v=document.createElement("div");v.style.cssText=o;const x=document.createElement("span");x.textContent="Easing",x.style.cssText=i+";width:55px";const w=document.createElement("select");w.style.cssText="font-size:11px;color:rgba(255,255,255,0.7);background:rgba(255,255,255,0.06);border:1px solid rgba(255,255,255,0.12);border-radius:3px;padding:2px 4px;outline:none";for(const t of["ease-in-out","ease-in","ease-out","linear"]){const e=document.createElement("option");e.value=t,e.textContent=t,e.style.cssText="background:#2a2a2a;color:#ccc",(r.easing??"ease-in-out")===t&&(e.selected=!0),w.appendChild(e)}w.addEventListener("change",()=>{r.easing="ease-in-out"===w.value?void 0:w.value,l()}),v.appendChild(x),v.appendChild(w),t.appendChild(v);const M=document.createElement("div");M.style.cssText=o+";margin-bottom:0";const S=document.createElement("span");S.textContent="Skip in play",S.style.cssText=i+";width:55px";const A=document.createElement("input");A.type="checkbox",A.checked=!!r.excludeFromPlay,A.style.cssText="accent-color:#4a9eff;cursor:pointer",A.addEventListener("change",()=>{r.excludeFromPlay=A.checked||void 0,l()}),M.appendChild(S),M.appendChild(A),t.appendChild(M),y.appendChild(t);const E=p.querySelector("button:last-child");E&&(e&&(E.style.color="#4a9eff"),E.addEventListener("click",()=>{const e="none"!==t.style.display;a.querySelectorAll("[data-slot-detail]").forEach(e=>{if(e!==t&&"none"!==e.style.display){e.style.display="none";const t=e.parentElement?.firstElementChild?.querySelector("button:last-child");t&&(t.style.color="rgba(255,255,255,0.35)")}}),t.style.display=e?"none":"block",E.style.color=e?"rgba(255,255,255,0.35)":"#4a9eff",g=e?-1:s}))}a.appendChild(y)}if(!t){const t=document.createElement("div");if(t.textContent=n?"No bookmarks defined":"No bookmarks saved",t.style.cssText="color:rgba(255,255,255,0.3);font-size:12px;text-align:center;padding:12px 0",a.appendChild(t),!n){const t=document.createElement("div");t.textContent="Use 📌 to save camera positions",t.style.cssText="color:rgba(255,255,255,0.2);font-size:11px;text-align:center;padding:0 0 4px",a.appendChild(t)}}p&&(p.style.display=c.getPlayableSlots().length>=2?"block":"none")};if(m(),!n){p=document.createElement("div"),p.style.cssText="display:none;margin-top:6px;padding:4px 8px;border-top:1px solid rgba(255,255,255,0.06)";const t=document.createElement("div");t.style.cssText="display:flex;align-items:center;gap:6px";const n=document.createElement("input");n.type="range",n.min="0",n.max="1000",n.value="0",n.tabIndex=-1,n.style.cssText="flex:1;min-width:0;margin:0;height:14px;cursor:grab;accent-color:#4a9eff;outline:none";const i=document.createElement("button");i.textContent="▶",i.title="Play / Stop",i.style.cssText="border:none;background:rgba(255,255,255,0.06);color:rgba(255,255,255,0.5);cursor:pointer;font-size:12px;padding:3px 6px;border-radius:4px;line-height:1;flex-shrink:0",i.addEventListener("mouseenter",()=>{i.style.background="rgba(74,158,255,0.15)",i.style.color="#4a9eff"}),i.addEventListener("mouseleave",()=>{i.style.background="rgba(255,255,255,0.06)",i.style.color=c.isPlaying?"#4a9eff":"rgba(255,255,255,0.5)"}),i.addEventListener("click",()=>{const t=c.isPlaying?-1:parseInt(n.value)/1e3;e.togglePlay(t),a()}),n.addEventListener("focus",()=>n.blur());let s=!1;n.addEventListener("mousedown",()=>{s=!0,n.style.cursor="grabbing",c.isPlaying&&(e.togglePlay(),a())}),n.addEventListener("input",()=>{const t=parseInt(n.value)/1e3;e.scrubPath(t)});const o=()=>{s&&(s=!1,n.style.cursor="grab")};n.addEventListener("mouseup",o),n.addEventListener("mouseleave",o),r.addEventListener("keydown",t=>{if("Space"===t.code&&"none"!==p.style.display){t.preventDefault(),t.stopPropagation();const i=c.isPlaying?-1:parseInt(n.value)/1e3;e.togglePlay(i),a()}}),t.appendChild(n),t.appendChild(i),p.appendChild(t),r.appendChild(p);const a=()=>{const t=c.isPlaying;i.textContent=t?"⏹":"▶",i.style.color=t?"#4a9eff":"rgba(255,255,255,0.5)"};let l=-1;const h=()=>{if(this._floatingPopup===r){if(c.isPlaying){const t=c.playProgress;n.value=String(Math.round(1e3*t)),l=-1}else{"⏹"===i.textContent&&a();const t=c.lastPlayProgress;t>=0&&t!==l&&(n.value=String(Math.round(1e3*t)),l=t)}f=requestAnimationFrame(h)}};f=requestAnimationFrame(h);(()=>{const t=c.getPlayableSlots().length;p.style.display=t>=2?"block":"none"})()}if(!n){const t=document.createElement("button"),e="display:block;width:100%;margin-top:8px;padding:5px 0;border:1px solid rgba(255,255,255,0.12);border-radius:6px;background:transparent;color:rgba(255,255,255,0.45);font-size:11px;cursor:pointer;transition:all 0.15s";i&&(t.textContent="Clear All",t.style.cssText=e,t.addEventListener("mouseenter",()=>{t.style.borderColor="rgba(255,107,107,0.4)",t.style.color="#ff6b6b"}),t.addEventListener("mouseleave",()=>{t.style.borderColor="rgba(255,255,255,0.12)",t.style.color="rgba(255,255,255,0.45)"}),t.addEventListener("click",()=>{c.resetAll(),l(),m()})),r.appendChild(t)}const y=e.onBookmarkChanged;e.onBookmarkChanged=()=>{y?.(),this._floatingPopup===r&&(m(),_=-2,n||e.showBookmarkPath())},this._showFloatingPopup(r,!0),n||e.showBookmarkPath();let b,_=u();const v=()=>{if(this._floatingPopup!==r)return;const t=u();if(t!==_){_=t;a.querySelectorAll("[data-slot-index]").forEach(e=>{const n=parseInt(e.dataset.slotIndex||"-1"),i=e.firstElementChild;if(!i)return;const r=n===t,s=r?"rgba(74,158,255,0.1)":"transparent";i.style.background=s,i.style.boxShadow=r?"inset 0 0 0 1px rgba(74,158,255,0.25)":"none",i.dataset.active=r?"1":""})}b=requestAnimationFrame(v)};b=requestAnimationFrame(v);const x=this._closeFloatingPopup.bind(this);this._closeFloatingPopup=()=>{void 0!==b&&cancelAnimationFrame(b),void 0!==f&&cancelAnimationFrame(f),c.isPlaying&&e.togglePlay(),e.clearBookmarkMarkerHighlight(),e.hideBookmarkPath(!0),this._closeFloatingPopup=x,x()}}_removeToolbar(){this._closeFloatingPopup(),this._threeCapability&&(this._threeCapability.onGizmoModeChanged=void 0,this._threeCapability.onGizmoAttachChanged=void 0,this._threeCapability.onCameraViewChanged=void 0,this._threeCapability.onBookmarkChanged=void 0,this._threeCapability.onHelpToggle=void 0,this._threeCapability.onSearchToggle=void 0,this._threeCapability.onDataBindingToggle=void 0,this._threeCapability.onMonitorToggle=void 0,this._threeCapability.onBookmarkNavToggle=void 0,this._threeCapability.onBookmarkEditToggle=void 0),this._toolbar?.parentNode&&this._toolbar.parentNode.removeChild(this._toolbar),this._toolbar=void 0,this._cameraButtons=void 0}_resizeThreeD(t=!1){if(!this._threeCapability||!this.element)return;const e=this.canvas?.clientWidth??0,n=this.canvas?.clientHeight??0,i=e>0?e:this.element.clientWidth,r=n>0?n:this.element.clientHeight;i>0&&r>0&&this._threeCapability.resize(i,r,t)}detachThreeCapability(){const t=this._threeCapability;if(t)return t.forceCleanupDragState(),t.clearAllObjects(),this._threeCapability=void 0,t}adoptThreeCapability(t){this._threeCapability=t,this._hide2DLayers();const e=t.domElement;if(e&&this.element){e.style.position="absolute",e.style.left="0",e.style.top="0",e.style.pointerEvents="none",e.setAttribute("scene","model-layer-webgl");const t=this._decoratorOverlay||this.element.firstChild;this.element.insertBefore(e,t)}t.buildOverlays(),t.rebuildForHost(this,{lightingConfig:this._buildLightingConfig(),css3DSceneAttribute:"model-layer:css3d-renderer"}),this.app?.isEditMode&&this._createToolbar(),this._registerPopupCallbacks(),this._resizeThreeD(!0)}_deactivateThreeD(){if(!this._threeCapability)return;Md.hideAll(this.root),this._removeToolbar(),this._lastCameraState=this._threeCapability.captureSessionState();const{target:t,visibleWidth:e,visibleHeight:n}=this._threeCapability.captureViewportInfo();this._threeCapability.forceCleanupDragState();const i=this._threeCapability.domElement,r=this._threeCapability.css3DRenderer?.domElement,s=[...this._threeCapability.decoratorOutlines];this._threeCapability.dispose(),this._threeCapability=void 0,r?.parentNode&&r.parentNode.removeChild(r);for(const t of this.components)if(t.isHTMLElement()&&t.element){const e=t.element,n=this.getOverlay(t);n?.appendChild(e)}i?.parentNode&&i.parentNode.removeChild(i),this.canvas&&(this.canvas.style.display=""),this._overlay&&(this._overlay.style.display=""),this._auxCanvas&&(this._auxCanvas.style.display=""),this._decoratorOverlay&&(this._decoratorOverlay.style.display=""),this._decoratorAuxOverlay&&(this._decoratorAuxOverlay.style.display="");for(const t of this.root?.assist_layers||[])t.element&&(t.element.style.display="");for(const t of this.components)t.isHTMLElement()&&t.element&&t.reposition();this.app?.isEditMode&&this._createToolbar();for(const t of s)t.disposed||this.applyDecorator(t,"border-highlighting",{distance:8,lineWidth:4,color:"#f007"});this._saved2DViewport?(this.set({scale:this._saved2DViewport.scale,translate:this._saved2DViewport.translate}),this._saved2DViewport=void 0):this._needsViewportSync&&this._init2DViewportFrom3DCamera(t,e,n),this.root.target_element?.focus()}_getViewportSize(){const t=this.target;return{w:t?.clientWidth||this.canvas?.clientWidth||this.state.width||800,h:t?.clientHeight||this.canvas?.clientHeight||this.state.height||600}}_initCameraFrom2DViewport(){if(!this._threeCapability)return;const{w:t,h:e}=this._getViewportSize(),n=this.get("translate")||{x:0,y:0},i=this.get("scale")||{x:1,y:1},r=i.x||1,s=i.y||1,{width:o=800,height:a=600}=this.state,c=(t/2-n.x)/r-o/2,l=(e/2-n.y)/s-a/2,h=t/r,d=e/s;this._threeCapability.positionCameraForViewport(c,l,h,d,this._lastCameraState)}_init2DViewportFrom3DCamera(t,e,n){const{w:i,h:r}=this._getViewportSize(),{width:s=800,height:o=600}=this.state,a=t.x+s/2,c=t.z+o/2;let l;if(this._2dScaleBeforeThreeD&&this._initialVisibleHeight&&n>0){const t=this._initialVisibleHeight/n;l=this._2dScaleBeforeThreeD*t}else if(e>0||n>0){const t=e>0?i/e:1,s=n>0?r/n:1;l=Math.max(t,s)}else l=1;l=Math.max(.1,Math.min(l,10));const h=i/2-a*l,d=r/2-c*l;this.set({translate:{x:h,y:d},scale:{x:l,y:l}}),this._2dScaleBeforeThreeD=void 0,this._initialVisibleHeight=void 0}centerTo(t,e){this.is3dMode&&this._threeCapability?this._threeCapability.centerToComponent(t,e):super.centerTo(t,e)}async ready(){await super.ready(),this.model.threed?this._threeCapability||(await new Promise(t=>setTimeout(t,0)),this._activateThreeD()):this.app?.isEditMode&&this._createToolbar(),this.root?.trigger("dimension",this.model.threed?"3d":"2d")}toggleThreeD(t){const e=t??!this.is3dMode;e?(this._threeDUserDeactivated=!1,this._activateThreeD(!0)):(this._threeDUserDeactivated=!0,this._deactivateThreeD(),this.resize(),this.invalidate()),this.root?.trigger("dimension",e?"3d":"2d")}dispose(){this._deactivateThreeD(),this._removeToolbar(),super.dispose(),this._overlay=null,this._decoratorOverlay&&(xs.getInstance().removeOverlay(this._decoratorOverlay),this._decoratorOverlay.parentNode&&this._decoratorOverlay.parentNode.removeChild(this._decoratorOverlay),this._decoratorOverlay=null),this._decoratorAuxOverlay&&(xs.getInstance().removeOverlay(this._decoratorAuxOverlay),this._decoratorAuxOverlay.parentNode&&this._decoratorAuxOverlay.parentNode.removeChild(this._decoratorAuxOverlay),this._decoratorAuxOverlay=null)}contains(t,e){return!0}isRootModel(){return!0}get stuck(){return!0}get layout(){return this.is3dMode?Ja.get("three"):tc}get overlay(){if(!this._overlay){const t=document.createElement("div");t.style.position="absolute",t.style.width="0",t.style.height="0",t.style.margin="0",t.style.padding="0",t.style.overflow="initial",t.style["user-select"]="none",t.style["transform-origin"]="top left",t.setAttribute("scene","model-layer-overlay"),this.element.insertBefore(t,this.auxCanvas),this._overlay=t,this._repositionOverlay()}return this._overlay}get auxOverlay(){return this.element??void 0}get decoratorOverlay(){if(!this._decoratorOverlay){const t=document.createElement("div");t.style.position="absolute",t.style.width="0",t.style.height="0",t.style.margin="0",t.style.padding="0",t.style.overflow="initial",t.style["user-select"]="none",t.style["transform-origin"]="top left",t.setAttribute("scene","decorator-overlay"),t.id=`decorator-overlay-${Date.now()}`,this.element.insertBefore(t,this.overlay),this._decoratorOverlay=t,xs.getInstance().addOverlay(t)}return this._decoratorOverlay}get decoratorAuxOverlay(){if(!this._decoratorAuxOverlay){const t=document.createElement("div");t.style.position="absolute",t.style.width="0",t.style.height="0",t.style.margin="0",t.style.padding="0",t.style.overflow="initial",t.style.zIndex="100",t.style["user-select"]="none",t.style["transform-origin"]="top left",t.setAttribute("scene","decorator-aux-overlay"),t.id=`decorator-overlay-${Date.now()}`,this.element.appendChild(t),this._decoratorAuxOverlay=t,xs.getInstance().addOverlay(t)}return this._decoratorAuxOverlay}createElement(){const t=super.createElement();return this._overlay&&t.appendChild(this._overlay),t}resize(){if(!this.target||!this.element)return;let{width:t,height:e,fitMode:n}=this.model;this.root.fitMode?n=this.root.fitMode:n||(n="ratio");let i=null;try{i=getComputedStyle(this.target)}catch(t){return void Fi(t,this.target)}let r=i?parseFloat(i.getPropertyValue("width")):this.target.clientWidth,s=i?parseFloat(i.getPropertyValue("height")):this.target.clientHeight;switch(n){case"both":case"ratio":break;case"width":s=e*r/t,this.element.style.overflowX="hidden",this.element.style.overflowY="auto";break;case"height":r=t*s/e,this.element.style.overflowX="auto",this.element.style.overflowY="hidden";break;default:r=Math.max(t,r),s=Math.max(e,s),this.element.style.overflowX=r>t?"hidden":"auto",this.element.style.overflowY=s>e?"hidden":"auto"}this.fitSize(this.element,!0),this.fitSize(this.canvas,!0,r,s),this.fitSize(this.auxCanvas,!0,r,s),this.root?.transitionEffect?.resize(),this.is3dMode&&this._threeCapability.resize(r,s)}draw(t){if(this.is3dMode){if(!this.element)return;return void this._threeCapability.renderCSS3D()}if(this.model.threed&&!this._threeCapability&&!this._threeDUserDeactivated)return;const e=this.root?.transitionEffect;e?.beginDraw(),super.draw(t),e?.endDraw()}get MPP(){const{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){const n=this.layout.capturables(this);for(let i=n.length-1;i>=0;i--){const r=n[i];if(!r.isContainer())continue;const s=r.capturePath(t,e);if(s)return s}return!1}getOverlay(t){return t&&!t.scalable?this.auxOverlay:this.overlay}getDecoratorOverlay(t){return t&&!t.scalable?this.decoratorAuxOverlay:this.decoratorOverlay}_onkeydown_root(t){if(t.metaKey||t.ctrlKey||t.altKey||t.shiftKey)return;const e=this.rootModel;if(!e)return;if("KeyF"===t.code)return this.onSearchToggle?.(),void t.preventDefault();if("KeyH"===t.code)return this._toggleHelpPanel(),void t.preventDefault();if("KeyD"===t.code)return this.onDataBindingToggle?.(),void t.preventDefault();if("KeyM"===t.code)return this.onMonitorToggle?.(),void t.preventDefault();if("KeyQ"===t.code)return this.toggleThreeD(),void t.preventDefault();if(e.is3dMode)return;const n={Digit1:"perspective",Digit2:"top",Digit3:"front",Digit4:"back",Digit5:"right",Digit6:"left"}[t.code];n&&(e._pendingCameraView=n,this.toggleThreeD(!0),t.preventDefault())}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,"deco-reset":t=>this.resetDecorator(void 0,t.origin)},"(descendant)":{"deco-anchors":(t,e)=>this.applyDecorator(e.origin,"anchors",t),"deco-anchors-off":t=>this.offdecorator(t.origin,"anchors"),"deco-anchors-reset":t=>this.resetDecorator("anchors"),"deco-dataspread":(t,e)=>this.applyDecorator(e.origin,"data-spread",t),"deco-dataspread-off":t=>this.offdecorator(t.origin,"data-spread"),"deco-dataspread-reset":t=>this.resetDecorator("data-spread"),"deco-link":(t,e)=>this.applyDecorator(e.origin,"link",t),"deco-link-off":t=>this.offdecorator(t.origin,"link"),"deco-link-reset":t=>this.resetDecorator("link"),"deco-arrow":(t,e)=>this.applyDecorator(e.origin,"bouncing-arrow",t),"deco-arrow-off":t=>this.offdecorator(t.origin,"bouncing-arrow"),"deco-arrow-reset":t=>this.resetDecorator("bouncing-arrow"),"deco-icon":(t,e)=>this.applyDecorator(e.origin,"animated-icon",t),"deco-icon-off":t=>this.offdecorator(t.origin,"animated-icon"),"deco-icon-reset":t=>this.resetDecorator("animated-icon"),"deco-border":(t,e)=>{this.app.isEditMode||(this._threeCapability?this._threeCapability.addOutline(e.origin):this.applyDecorator(e.origin,"border-highlighting",t))},"deco-border-off":t=>{this.app.isEditMode||(this._threeCapability?this._threeCapability.removeOutline(t.origin):this.offdecorator(t.origin,"border-highlighting"))},"deco-border-reset":t=>{this.app.isEditMode||(this._threeCapability?this._threeCapability.clearOutlines():this.resetDecorator("border-highlighting"))},"deco-tag":(t,e)=>this.applyDecorator(e.origin,"decotag",t),"deco-tag-off":t=>this.offdecorator(t.origin,"decotag"),"deco-tag-reset":t=>this.resetDecorator("decotag",t.origin),"deco-off":t=>{this.offdecorator(t.origin),this._threeCapability?.removeOutline(t.origin)},mouseenter:this.onmouseenterForDecorator,mouseleave:this.onmouseleaveForDecorator},"(self)":{change:this.onChangeForDecorator,redraw:this.onRedrawForDecorator}},"(root)":{"(self)":{selected:this._onRootSelected,keydown:this._onkeydown_root}}}}onRedrawForDecorator(){this.is3dMode||(xs.getInstance().invalidateOverlay(this.decoratorOverlay),xs.getInstance().invalidateOverlay(this.decoratorAuxOverlay))}closeScene(t){requestAnimationFrame(()=>this.overlay.dispatchEvent(new CustomEvent("close-scene",{bubbles:!0,composed:!0,detail:t})))}_repositionOverlay(){const t=this._overlay;if(!t)return;const{translate:e=Lu,scale:n=zu,rotation:i=0}=this.model,{left:r,top:s}=this.bounds;t.style.left=r+"px",t.style.top=s+"px",t.style.transform=`rotate(${i}rad) scale(${n.x}, ${n.y}) perspective(1px)`,t.style.marginLeft=`${e.x}px`,t.style.marginTop=`${e.y}px`}onchange(t){const e=this._model;delete e.id,delete e.text,delete e.class,this._repositionOverlay(),t.hasOwnProperty("threed")&&(t.threed?this._activateThreeD(!0):this._deactivateThreeD(),this.root?.trigger("dimension",t.threed?"3d":"2d")),this.is3dMode&&((t.hasOwnProperty("width")||t.hasOwnProperty("height"))&&this._resizeThreeD(),this._threeCapability.onchange(t))}_onRootSelected(t){const e=1===t?.length?t[0]:t&&0!==t.length?null:this;e&&globalThis.dispatchEvent?.(new CustomEvent("clickComponent",{detail:e}))}_onchanged_all(t,e,n){this.invalidate()}_onmouseenter_all(t,e){if(t.stopPropagation(),!this.app||this.app.isEditMode)return;if(!e)return;const n=e.origin;if(n instanceof Yu||!n.model.event||!n.model.event.hover)return;if(n.hidden)return;const i=n.model.event.hover;i&&this._doEventAction(i,n,!0,t)}_onmouseleave_all(t,e){if(t.stopPropagation(),!e)return;const n=e.origin;if(!this.app||this.app.isEditMode)return;const i=n.model.event&&n.model.event.hover;i&&this._doEventAction(i,n,!1,t)}_onclick(t,e){if(t.stopPropagation(),this.app.isEditMode)return;if(!e)return;const n=e.origin,i=n.model.event?.tap;i&&this._doEventAction(i,n,!0,t)}_onmousedownup(t,e){if(t.stopPropagation(),this.app.isEditMode)return;if(!e)return;const n=e.origin,i=n.model.event?.tap;i&&i.pressed&&this._doMouseDownUpEventAction(i,n,"mousedown"==t.type||"touchstart"==t.type,t)}_doMouseDownUpEventAction(t,e,n,i){const{pressed:r=!1}=t;r&&(n?function(t){if(t.hasOwnProperty("_backupShadow"))return;const e=t.get("shadow");t._backupShadow=e;const{left:n=0,top:i=0}=e||{};t.delta("tx",n),t.delta("ty",i),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,n,i){let{action:r,target:s,value:o,emphasize:a=!1,restore:c=!1,options:l}=t;if(s&&(s=e.access(s)),o&&(o=e.access(o)),a&&(n?function(t){const{hover:e}=t.state.event||{},{emphasize:n}=e||{};if(t.hasOwnProperty("_backupStrokeStyle"))return;if("__backup_emphasize"in t)return;const{strokeStyle:i,lineWidth:r,fillStyle:s}=t.state;t.__backup_emphasize={strokeStyle:i,lineWidth:r,fillStyle:s},t.setState(n)}(e):c&&function(t){"__backup_emphasize"in t&&(t.setState(t.__backup_emphasize),delete t.__backup_emphasize)}(e)),r)switch(r){case"data-toggle":if(!s)return;(n||c)&&this.root.findAll(s,e)?.forEach(t=>{t.data=!t.data});break;case"data-tristate":if(!s)return;(n||c)&&this.root.findAll(s,e)?.forEach(t=>{const e=Math.round(Math.max(Number(t.data)||0,0));t.data=(e+(n?1:2))%3});break;case"data-spreading":if(!s)return;n&&(e.access(o),this.root.findAll(s,e)?.forEach(t=>{t.executeMappings(!0)}));break;case"data-set":if(!s)return;if(n){const t=e.access(o);this.root.findAll(s,e)?.forEach(e=>{e.data=t})}break;case"partial-data-set":if(!s)return;if(n){const t=e.access(o);this.root.findAll(s,e)?.forEach(e=>{e.data={...e.data,...t}})}break;case"value-set":if(!s)return;if(n){const t=e.access(o);this.root.findAll(s,e)?.forEach(e=>{e.value=t})}break;case"partial-value-set":if(!s)return;if(n){const t=e.access(o);this.root.findAll(s,e)?.forEach(e=>{e.value={...e.value,...t}})}break;case"infoWindow":case"info-window":if(!s)return;"click"==i.type||n?Qa.show(e,s,c,{x:i.offsetX,y:i.offsetY}):c&&Qa.hide(e,s);break;case"toggle-info-window":if(!s)return;Qa.toggle(e,s,!1,{x:i.offsetX,y:i.offsetY});break;case"popup":case"modal-popup":if(!s)return;const t=l&&"input"in l?l.input:"(self)",a=!l||(!("output"in l)||l.output),h=this.is3dMode&&"modal-popup"!==r;Md.show(e,s,{data:t&&this.root.findFirst(t,e)?.data,output:a,modal:"modal-popup"===r,closable:!0,draggable:!h,origin:"auto",anchor:h?e:void 0,tether:h});break;case"inline-popup":case"inline-modal-popup":{if(!s)return;const t=this.root.findById(s);if(!t)return;const n=t.state||{},i="inline-modal-popup"===r,o=this.is3dMode&&!i;Md.show(e,"",{containerRef:s,modal:i,closable:!0,draggable:!o,origin:"auto",anchor:o?e:void 0,constantSize:n.constantSize??!0,billboard:n.billboard??!0,tether:n.tether??o,offScreen:n.offScreen??"hide",data:e.data});break}case"close-scene":this.closeScene(e.data);break;case"goto":case"goto-playlist":this.trigger(r,s,l,e);break;case"mouse-cursor":n?this.target.style.cursor=s||"auto":c&&(this.target.style.cursor="auto");break;default:this.trigger(r,s,o,e)}}applyDecorator(t,e,n={}){const i=this.getDecoratorOverlay(t);if(i){xs.getInstance().addToOverlay(i,t,e,n)}}offdecorator(t,e){const n=this.getDecoratorOverlay(t);if(n){xs.getInstance().removeFromOverlay(n,t,e)}}resetDecorator(t,e){const n=this.getDecoratorOverlay(e);n&&xs.getInstance().removeAllFromOverlay(n,t)}onChangeForDecorator(t,e,n){const{origin:i}=n,r=this.getDecoratorOverlay(i);xs.getInstance().invalidateOverlay(r)}onmouseenterForDecorator(t,e){const{origin:n}=e;n.decorators&&n.decorators.forEach(t=>{this.applyDecorator(n,t)})}onmouseleaveForDecorator(t,e){const{origin:n}=e;n.decorators&&n.decorators.forEach(t=>{this.offdecorator(n,t)})}}function Gu(t,e){const n=t.state.refid;return t.root.findAll(t=>t.isLine()&&t.from?.component===n&&(!e||t.from.anchor===e))}function Vu(t,e){const n=t.state.refid;return t.root.findAll(t=>t.isLine()&&t.to?.component===n&&(!e||t.to.anchor===e))}function Uu(t){return class extends t{isConnectable(){return!0}postrender(t){super.postrender(t),this._draw_anchors(t)}_draw_anchors(t){const e=this.anchors||[];t.save(),e.forEach(e=>{const{draw:n}=e;if(n){t.beginPath();try{n.call(e,t,this)}catch(t){Fi(t)}t.closePath()}}),t.restore()}contains(t,e){let n=super.contains(t,e);if(n)return n;const i=this.anchors||[];for(const r of i){const i=r.bounds;if(!i)continue;const{left:s,top:o,width:a,height:c}=i;if(n=t<Math.max(s+a,s)&&t>Math.min(s+a,s)&&e<Math.max(o+c,o)&&e>Math.min(o+c,o),n)return n}return!1}findInOutLines(t){return function(t,e){const n=t.state.refid;return t.root.findAll(t=>!(!t.isLine()||(t.from?.component!==n||e&&t.from.anchor!==e)&&(t.to?.component!==n||e&&t.to.anchor!==e)))}(this,t)}findOutletLines(t){return Gu(this,t)}findOutletEnds(t){return function(t,e){return Gu(t,e).map(t=>t.toEnd?.component).filter(Boolean)}(this,t)}findInletLines(t){return Vu(this,t)}findInletEnds(t){return function(t,e){return Vu(t,e).map(t=>t.fromEnd?.component).filter(Boolean)}(this,t)}}}Yu.Popup=Md,Va.register("model-layer",Yu);const $u={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"number",label:"round",name:"round",property:{min:0}}],help:"scene/component/rect"},Wu={ondragmove:function(t,e,n){const{left:i,width:r,height:s}=n.model;let o=(n.fromParent(t.x,t.y).x-i)/(r/2)*100;o=$a(o,r,s),n.set({round:o})}};class Xu extends(Uu(Wa(Ua))){is3dish(){return!0}get controls(){let{left:t,top:e,width:n,round:i,height:r}=this.state;return i=null==i?0:$a(i,n,r),[{x:t+n/2*(i/100),y:e,handler:Wu}]}get nature(){return $u}}Va.register("rect",Xu);const qu=[1,2,10,20,50,50,50,50,50,50];class Ku extends(Wa(Ua)){render(t){const{lineWidth:e=1,fillStyle:n="lightgray",font:i="15px Arial",left:r,top:s,origin:o,width:a,height:c,side:l="bottom",strokeStyle:h="#000000",scale:d=1}=this.state;t.translate(r,s),t.beginPath();const u=Math.round(e/2);t.rect(-u,-u,a+2*u,c+2*u),t.clip(),t.beginPath(),t.rect(0,0,a,c),n&&(t.fillStyle=n,t.fill()),t.lineWidth=e,t.strokeStyle=h,t.stroke(),t.beginPath(),t.font=i;const p="bottom"!==l,f=p?0:c;let g=4*c/5,m=2*c/3,y=1*c/2,b=3*c/5;p&&(g=c-g,m=c-m,y=c-y,b=c-1.5*c/5);const _=d*this.app.PPM/this.root.unitScale;let v=Math.ceil(o/_);const x=this.app.PPM/_,w=x<=1.1?1:qu[Math.round(x)]||100;1!=w&&(v+=(w-v%w)%w);let M=Math.ceil(v*_);const S=o+a;for(t.fillStyle=h;M<S;){if(v%10==0){t.moveTo(M-o,y),t.lineTo(M-o,f);const e=(v/10).toString(),n=t.measureText(e);t.fillText(e,M-o-n.width-6,b)}else v%5==0?(t.moveTo(M-o,m),t.lineTo(M-o,f)):(t.moveTo(M-o,g),t.lineTo(M-o,f));v+=w,M=Math.ceil(v*_)}}}Va.register("ruler",Ku);const Qu=20,Zu=20,Ju=90*Math.PI/180,tp="9px Verdana",ep=20,np="#f4f4f4",ip="#999";function rp(t,e,n){return{left:-t.x,top:-t.y,width:Qu,height:ep}}function sp(t,e,n,i){return{left:Qu-t.x,top:0-t.y,origin:20-t.x,width:e-Qu,height:ep}}function op(t,e,n,i){const r={x:0-t.x+10,y:-t.y+Zu+(n-Zu)/2},s=Va.transcoordRR(0-t.x,-t.y+Zu,r,Ju);return{left:s.x-(n-Zu),top:s.y,origin:20-t.y,width:n-Zu,height:ep}}function ap(t){const e=t.get("translate");return{left:-e.x,top:-e.y,width:t.canvas.width/Mr,height:t.canvas.height/Mr}}Va.register("guide-layer",class extends Sd{constructor(t,e){super(t,e),this.appScale={x:1,y:1},"disabled"!==t.ruler&&(this.hruler=new Ku({left:Qu,top:0,origin:20,margin:0,height:ep,unit:"m",rotation:0,font:tp,fillStyle:np,strokeStyle:ip,capturable:!1}),this.vruler=new Ku({left:0,top:0,origin:20,margin:0,height:ep,unit:"m",rotation:Ju,font:tp,side:"top",fillStyle:np,strokeStyle:ip,capturable:!1}),this.origin_rect=new Xu({left:-20,top:-20,width:20,height:20,fillStyle:np,strokeStyle:ip,lineWidth:1}),this.addComponent(this.hruler),this.addComponent(this.vruler),this.addComponent(this.origin_rect)),this.invalidate()}get capturable(){return!1}async ready(){if(await super.ready(),!this.hruler)return void(this.screen_coord=ap(this));const t=this.rootModel,e=Object.assign({},t.get("translate"));e.x<Qu&&(e.x+=Qu),e.y<Zu&&(e.y+=Zu);const n=t.get("scale")||{x:1,y:1};this.appScale=n,this.hruler.set("scale",n.x),this.vruler.set("scale",n.y),t.set("translate",e),this.set("translate",e),this.screen_coord=ap(this);const{width:i,height:r}=this.screen_coord;this.hruler.set(sp(e,i)),this.vruler.set(op(e,0,r)),this.origin_rect.set(rp(e))}resize(){super.resize(),this.screen_coord=ap(this);const{width:t,height:e}=this.screen_coord;this.hruler&&(this.hruler.set(sp(this.model.translate,t)),this.vruler.set(op(this.model.translate,0,e)),this.origin_rect.set(rp(this.model.translate)))}render(t){if(this.rootModel?.is3dMode)return;if(!this.guide)return;t.save();const{x:e,y:n}=this.guide,{top:i,left:r,width:s,height:o}=this.screen_coord;t.beginPath(),t.moveTo(e,i),t.lineTo(e,i+o),t.moveTo(r,n),t.lineTo(r+s,n),t.lineWidth=1,t.strokeStyle="tomato",t.setLineDash([2,3]),t.font="10px tahoma",t.fillStyle="#333";const a=this.toGlobal(e,n,this.rootModel);t.textBaseline=a.y>200?"bottom":"top",t.textAlign=a.x>200?"right":"left";const c=a.y>200?-5:5,l=a.x>200?-5:5,h=Math.round(e/this.appScale.x),d=Math.round(n/this.appScale.y);t.fillText(` ${h}, ${d} `,e+l,n+c),t.stroke(),t.restore()}get guide(){return this._guide}set guide(t){this._guide=t,this.invalidate()}contains(t,e){return!0}get eventMap(){return{"(root)":{"(descendant)":{mousemove:this.onmousemove_child,mouseout:this.onmouseout_child,dragmove:this.onmousemove_child},"model-layer":{change:this.onchange_root_model}},"(self)":{"(descendant)":{mousedown:this.onmousedown_origin}}}}onmousedown_origin(t,e){this.rootModel.set("translate",{x:20,y:20})}onchange_root_model(t,e,n){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=ap(this),this.hruler){const{translate:t}=this.model,{width:e,height:n}=this.screen_coord;this.hruler.set(sp(t,e)),this.vruler.set(op(t,0,n)),this.origin_rect.set(rp(t))}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.toLocal(t.offsetX,t.offsetY)}});Va.register("shift-layer",class extends Sd{async ready(){await super.ready();const 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.toLocal(t.offsetX,t.offsetY)}ondragmove(t){const{x:e,y:n}=this.toLocal(t.offsetX,t.offsetY);this.rootModel.move({x:e-this.last_position.x,y:n-this.last_position.y},!1),this.last_position=this.toLocal(t.offsetX,t.offsetY)}});function cp(t,e,n,i,r){const s=t.selected;let o=i?s.slice(0):[];e.isContainer()||(e=e.parent);const a=e.layout.capturables(e),c=!!e.layout.joinType;if(i&&n.selected.forEach(t=>{o.splice(o.indexOf(t),1)}),n.selected=[],a.forEach(t=>{!t.capturable||!function(t,e,n){const{sx:i,sy:r,ex:s,ey:o}=e;let a,c,l,h;if(i>s?(a=s,c=i):(a=i,c=s),r>o?(l=o,h=r):(l=r,h=o),n){const e=t.bounds,n=t.transcoordS2TR(e.left,e.top),i=t.transcoordS2TR(e.left+e.width,e.top+e.height),r=n.x,s=i.x,o=n.y,d=i.y,u=Math.min(a,r,c,s),p=Math.max(a,r,c,s),f=Math.min(l,o,h,d),g=Math.max(l,o,h,d);return!(p-u>Math.abs(c-a)+Math.abs(s-r)||g-f>Math.abs(h-l)+Math.abs(d-o))}{const e=t.path;if(!e)return Fi("컴포넌트에 get path가 잘못 구현되어있음.",t),!1;for(let n=0;n<e.length;n++){const i=t.transcoordS2TR(e[n].x,e[n].y);if(a>i.x||c<i.x||l>i.y||h<i.y)return!1}return!0}}(t,n,c)||-1!=o.indexOf(t)||r&&t.state.type!==r||n.selected.push(t)}),o=o.concat(n.selected),s.length!==o.length)t.selected=o;else for(let e=0;e<o.length;e++)if(s[e]!=o[e]){t.selected=o;break}}function lp(t,e,n,i,r,s){r||cp(t,e,n,i,s)}function hp(t,e){const n=t.components||[];for(const t of n){hp(t,e);const n=e.indexOf(t);-1!=n&&e.splice(n,1)}}Va.register("add-layer",class extends Sd{async ready(){await super.ready();const t=this.rootModel,e=t.get("translate"),n=t.get("scale");this.set("translate",e),this.set("scale",n)}get pointerEvents(){return"none"}render(t){const e=this.addbox;if(e){const{sx:n,sy:i,ex:r,ey:s}=e,o=this.get("scale")||{x:1,y:1};t.beginPath(),t.rect(n,i,r-n,s-i),t.setLineDash([2/o.x,4/o.y]),t.lineWidth=1/o.x,t.strokeStyle="black",t.stroke()}}contains(t,e){return!(3!=this.app.mode)}get eventMap(){return{"(root)":{"(self)":{addstart:this.onaddstart,addstop:this.onaddstop,keydown:this.onkeydown,dragstart:this.ondragstart,dragmove:this.ondragmove,dragend:this.ondragend,mousedown:this.onmousedown,mouseup:this.onmouseup}},"model-layer":{"(self)":{change:this.onchange_root_model}}}}onchange_root_model(t,e,n){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,this.root.target_element?.focus())}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){const{x:e,y:n}=this.toLocal(t.offsetX,t.offsetY);this.addbox={sx:e,sy:n}}ondragmove(t){if(3!==this.app.mode)return;const{x:e,y:n}=this.toLocal(t.offsetX,t.offsetY);this.addbox&&(this.addbox.ex=e,this.addbox.ey=n,this.invalidate())}ondragend(t,e){if(3!==this.app.mode)return;const{sx:n,sy:i,ex:r,ey:s}=this.addbox;Ol.call(this.root,this.models,{left:Math.min(n,r),top:Math.min(i,s),width:Math.abs(r-n),height:Math.abs(s-i)}),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)return;const{x:n,y:i}=this.toLocal(t.offsetX,t.offsetY);Ol.call(this.root,this.models,{cx:n,cy:i}),this.root.trigger("addstop")}});Va.register("selection-layer",class extends Sd{async ready(){await super.ready();const t=this.rootModel,e=t.get("translate"),n=t.get("scale");this.set("translate",e),this.set("scale",n);const i=this.root?.target_element;i?.addEventListener("contextmenu",t=>{t.shiftKey&&t.preventDefault()})}contains(t,e){return!1}render(t){const e=this.selbox;if(e){const{sx:n,sy:i,ex:r,ey:s}=e,o=this.get("scale")||{x:1,y:1};t.beginPath(),t.rect(n,i,r-n,s-i),t.setLineDash([2/o.x,4/o.y]),t.lineWidth=1/o.x,t.strokeStyle="black",t.stroke()}}get eventMap(){return{"(root)":{"(self)":{keydown:this.onkeydown}},"model-layer":{"(self)":{change:this.onchange_root_model},"(all)":{dragstart:this.ondragstart_selbox,dragmove:this.ondragmove_selbox,dragend:this.ondragend_selbox,mousedown:this.onmousedown_comp,mouseup:this.onmouseup_comp}}}}onkeydown(t,e){const{deliverer:n}=e,i=n.selected;if(1!==i.length)return!1;let r=i[0];const s=r.parent;if(!s||s===n)return!1;if("Tab"===t.code){const e=s.layout.capturables(s);let n=e.indexOf(r);if(-1==n){if(!s.indexOf(r))return Bi("Container not contains [",r,"] as a component"),!1;n=0}const i=e.length;t.shiftKey?n--:n++,r=e[(n+i)%i]}else{if(!s.layout.keyNavigate)return!1;r=s.layout.keyNavigate(s,r,t)||r}n.selected=[r],t.preventDefault()}onchange_root_model(t,e,n){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){const n=this.selected.indexOf(t);let i=t.parent;for(;i.parent.isGroup();)i=i.parent;let r=[],s=!1,o=!1;if(this.selected.forEach(t=>{let e=t.parent;if(t!==i){for(;e.parent&&e.parent.isGroup();)e=e.parent;e===i&&(r.push(t),s=!0)}else o=!0}),s)if(e.shiftKey){if(-1!=n)return void this._pendingDecision(e);r.push(t)}else{if(-1!=n)return void this._pendingDecision(e);r=[t]}else{if(o)return void this._pendingDecision(e);if(e.shiftKey)if(this.selected.length>0){if(-1!=this.selected.indexOf(i))return;r=[...this.selected,i]}else r=[i];else r=[i]}this.selected=r}onmousedown_comp(t,e){const{origin:n}=e;if(this.downpoint=null,t.shiftKey){if(n.stuck)return;if(n.parent.isGroup())return void this._selectGroupItem(n,t);if(-1==this.selected.indexOf(n)){if((t.ctrlKey||t.metaKey)&&this.selected.length>0){const t=this.selected[0].state.type;if(n.state.type!==t)return}this.selected=[...this.selected,n]}else this._pendingDecision(t)}else{if(n.parent.isGroup())return void this._selectGroupItem(n,t);if(n.stuck)this.selected.length>0&&(this.selected=[]);else{if(-1!=this.selected.indexOf(n))return;this.selected=[n],this.sameParent=!0}}}onmouseup_comp(t,e){if(!this.downpoint)return;if(this.downpoint.x!==t.offsetX||this.downpoint.y!==t.offsetY)return;const{origin:n}=e;if(t.shiftKey){let t=this.selected.indexOf(n);if(-1==t&&n.parent.isGroup()&&(t=this.selected.indexOf(n.parent)),-1!==t){const e=this.selected.slice();e.splice(t,1),this.selected=e}else{const t=this.selected.filter(t=>!t.isRootModel()&&!!t.parent),e=t.length>0&&t[0].parent;e&&e!==n.parent&&(!function(t,e){let n=t.parent;for(;n;){const t=e.indexOf(n);-1!=t&&e.splice(t,1),n=n.parent}}(n,t),hp(n,t)),t.push(n),this.selected=t}}else if(n.parent.isGroup())return void(this.selected=[n])}ondragstart_selbox(t,e){const{origin:n}=e;if(!n.stuck)return;const{x:i,y:r}=this.toLocal(t.offsetX,t.offsetY);this.selbox={sx:i,sy:r,selected:[]}}ondragmove_selbox(t,e){const{origin:n}=e;if(!n.stuck)return;const{x:i,y:r}=this.toLocal(t.offsetX,t.offsetY);if(this.selbox){this.selbox.ex=i,this.selbox.ey=r;const e=t.shiftKey&&(t.ctrlKey||t.metaKey)&&this.selected.length>0?this.selected[0].state.type:null;lp(this,n,this.selbox,t.shiftKey,!1,e),this.invalidate()}}ondragend_selbox(t,e){const{origin:n}=e;n.stuck&&(this.last_pos=null,this.selbox=null,lp(this,null,null,!1,!0),this.invalidate())}});class dp{constructor(t){this.layer=t}draw(t,e,n){const{left:i,top:r,width:s,height:o}=e.bounds;0!=s&&0!=o&&(t.beginPath(),t.rect(i,r,s,o),t.clip(),t.beginPath(),t.strokeStyle="#f26522",t.lineWidth=4,t.shadowBlur=10,t.shadowColor="black",t.shadowOffsetX=0,t.shadowOffsetY=0,t.rect(i,r,s,o),t.stroke(),t.closePath())}}class up{constructor(t){this.layer=t}draw(t,e,n){const i=e.bounds;t.beginPath(),t.rect(i.left-4/n.x,i.top-4/n.y,i.width+8/n.x,i.height+8/n.y),t.setLineDash([3/n.x,4/n.y]),t.lineWidth=1/n.x,t.strokeStyle="black",t.stroke(),t.setLineDash([]),t.closePath()}}class pp{constructor(t){this.layer=t}reset(){this.active=null}get selected(){return this.layer.selected}contains(t,e,n,i){const r=n.controls;return!!r&&(r.every((r,s)=>(Math.abs(t-r.x)<=4/i.x&&Math.abs(e-r.y)<=4/i.y&&(this.active={component:n,index:s,handler:r.handler}),!this.active)),!!this.active)}draw(t,e,n){const i=e.controls;i&&i.forEach((e,i)=>{t.beginPath(),t.lineWidth=1/n.x,t.ellipse(e.x,e.y,4/n.x,4/n.y,0,0,2*Math.PI,!0),t.fillStyle="#ff5d72",t.fill(),t.strokeStyle="#fff",t.stroke()})}onevent(t,e){const{handler:n,component:i,index:r}=this.active;let s=i.toLocal(e.offsetX,e.offsetY);s=i.toParent(s.x,s.y),n&&"function"==typeof n[t]&&n[t](s,r,i)}onmousedown(t){this.onevent("onmousedown",t)}ondragstart(t){const e=this.active;e.changes=Sc.before([e.component]),this.onevent("ondragstart",t)}ondragmove(t){this.onevent("ondragmove",t)}ondragend(t){this.onevent("ondragend",t);const{component:e,changes:n}=this.active;Sc.after(n,e.app.commander),e.parent&&e.parent.calculateBounds&&e.parent.calculateBounds()}}function fp(t,e){return Math.atan2(e.y-t.y,e.x-t.x)}const gp=15*Math.PI/180;class mp{constructor(t){this.layer=t}reset(){this.active=null,this.created=null}get selected(){return this.layer.selected}contains(t,e,n,i){return!!n.mutable&&(n.path.every((r,s)=>(Math.abs(t-r.x)<=4/i.x&&Math.abs(e-r.y)<=4/i.y&&(this.active={component:n,index:s}),!this.active)),!!this.active)}startLinkProcess(t,e,n){try{const i=Ic(e,t.app,void 0);return t.rootModel.addComponent(i),this.layer.selected=[i],this.active={component:i,index:1},this.ondragstart(n),i}catch(t){Bi(t)}}draw(t,e,n){if(!e.mutable||e.stuck)return;const i=e.path,r=this.active;i.forEach((i,s)=>{t.beginPath(),t.ellipse(i.x,i.y,4/n.x,4/n.y,0,0,2*Math.PI,!0),t.lineWidth=1/n.x,t.strokeStyle="#656565",t.fillStyle="#fff",r&&r.component===e&&r.index===s&&(t.strokeStyle="#fa7703",r.toFill&&(t.fillStyle="#ffb80c")),t.fill(),t.stroke()})}ondblclick(t){const e=this.active.component;if(!e.pathExtendable)return;const n=e.path.slice();n.length<3||(n.splice(this.active.index,1),e.path=n)}onmousedown(t){this.active.toFill=!0}ondragstart(t){const{index:e,component:n}=this.active;this.created||(this.active.changes=Sc.before([n])),0!==e&&e!==n.path.length-1||(this.layer.counterEnd=0===e?n.toEnd||{fromto:"to"}:n.fromEnd||{fromto:"from"})}ondragmove(t){const{component:e,index:n}=this.active||{},{offsetX:i,offsetY:r}=t;let s=e.toLocal(i,r);if(s=e.toParent(s.x,s.y),t.shiftKey){const t=e.path.length;let i=e.isLine()&&0==n?e.path[1]:e.path[(n-1+t)%t];i=e.toParent(i.x,i.y);let r=0;if(t>2){let s;e.isLine()?0==n?s=e.path[2]:1!=n&&(s=e.path[n-2]):s=e.path[(n-2+t)%t],s&&(s=e.toParent(s.x,s.y),r=fp(s,i))}const c=Math.round((fp(i,s)-r)/gp)*gp+r;s=function(t,e,n){return{x:Math.cos(e)*n+t.x,y:Math.sin(e)*n+t.y}}(i,c,(o=i,a=s,Math.sqrt((a.x-o.x)*(a.x-o.x)+(a.y-o.y)*(a.y-o.y))))}var o,a;if(0===n||n===e.path.length-1){const t=this.layer.anchorTarget=e.rootModel.capture(i,r,t=>!t.isConnectable());if(t){const{x:o,y:a}=t.toLocal(i,r),c=this.layer.get("scale")||{x:1,y:1},l=this.layer.counterEnd,h=(t.anchors||[]).find(n=>{const{name:i,inout:r,multiplicity:s=1/0,position:h,filter:d}=n;if(l){const{anchor:t,fromto:e}=l;if(t&&("out"===t.inout&&"out"===r||"in"===t.inout&&"in"===r))return!1;if("from"===e&&"out"===r||"to"===e&&"in"===r)return!1}else Fi("should not be here.");if(Math.abs(o-h.x)>8/c.x||Math.abs(a-h.y)>8/c.y)return!1;const u=t.findInOutLines(i);return!!u.includes(e)||!(s!==1/0&&u.length>=s)&&(!l||!d||!!d.call(n,l))});h?0==n?e.from={component:t.get("refid"),anchor:h.name,position:s}:e.to={component:t.get("refid"),anchor:h.name,position:s}:0==n?e.from={position:s}:e.to={position:s}}else 0==n?e.from={position:s}:e.to={position:s}}e.mutatePath(null,function(t){const e=t[n]?.z;t[n]=s,void 0!==e&&(s.z=e)})}ondragend(t){const{component:e,index:n,changes:i}=this.active;if(0===n||n===e.path.length-1){const{offsetX:i,offsetY:r}=t,s=e.rootModel.capture(i,r,t=>t===e||t.isLine()),{x:o,y:a}=s.toLocal(i,r),c=this.layer.get("scale")||{x:1,y:1},l=(s.anchors||[]).find(t=>t&&Math.abs(o-t.position.x)<=8/c.x&&Math.abs(a-t.position.y)<=8/c.y);l&&(0==n?e.from={component:s.get("refid"),anchor:l.name}:e.to={component:s.get("refid"),anchor:l.name}),this.layer.endLinkProcess()}if(this.created){const t=new zc({changes:[{component:this.created,to_container:this.created.parent}]});this.created.app.commander.execute(t)}else Sc.after(i,e.app.commander);e.parent&&e.parent.calculateBounds&&e.parent.calculateBounds()}}function yp(t,e,n){return t.filter(t=>{const{name:i,inout:r,multiplicity:s=1/0,filter:o}=t;if(n){const{anchor:t,fromto:e}=n;if(t&&("out"===t.inout&&"out"===r||"in"===t.inout&&"in"===r))return!1;if("from"===e&&"out"===r||"to"===e&&"in"===r)return!1}else if("in"===r)return!1;return!(s!==1/0&&e.findInOutLines(i).length>=s)&&(!o||!n||!!o.call(t,n))})}class bp{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,n,i){const r=this.active?.component===n&&this.active?.anchor;this.active=null;const s=this.layer.counterEnd;return yp(n.isConnectable()&&!n.disposed&&this.getAnchorHandles(n,i)||[],n,s).every(s=>{const o=r===s.name?2:1;return s&&s.position&&Math.abs(t-s.position.x)<=4*o/i.x&&Math.abs(e-s.position.y)<=4*o/i.y&&(this.active={component:n,anchor:s.name,template:s.template}),!this.active}),!!this.active}getAnchorHandles(t,e){const{width:n,height:i}=t.bounds;return n*e.x<30||i*e.y<30?[]:t.anchors}draw(t,e,n){if(!e.get("refid")||e.isLine())return;const i=this.active,r=this.active?.component===e&&this.active?.anchor,s=this.layer.counterEnd;yp(e.isConnectable()&&!e.disposed&&this.getAnchorHandles(e,n)||[],e,s).forEach(s=>{const{name:o,position:a}=s,c=r===o?2:1;a&&(t.beginPath(),t.ellipse(a.x,a.y,4*c/n.x,4*c/n.y,0,0,2*Math.PI),t.setLineDash([0,0]),t.lineWidth=1/n.x,t.strokeStyle="#656565",t.stroke(),t.fillStyle="#fff",i&&i.component===e&&i.anchor===o&&(t.strokeStyle="#fa7703",i.focus&&(t.fillStyle="#ffb80c")),t.fill(),t.stroke())})}onmousedown(t){this.active.focus=!0}ondragstart(t){const{component:e,anchor:n,template:i}=this.active,r=this.layer.toLocal(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,...i,from:{component:e.get("refid"),anchor:n,position:r},to:{position:r}},t)}ondragmove(t){}ondragend(t){}}function _p(t,e){const{left:n,top:i,width:r,height:s}=t,o=n+r/2,a=i+s/2,c=n+r,l=i+s,h=r*e.x>50,d=s*e.y>50;return[{x:n,y:i},h?{x:o,y:i}:{x:null,y:null},{x:c,y:i},d?{x:c,y:a}:{x:null,y:null},{x:c,y:l},h?{x:o,y:l}:{x:null,y:null},{x:n,y:l},d?{x:n,y:a}:{x:null,y:null}]}class vp{constructor(t){this.layer=t}reset(){this.active=null}get selected(){return this.layer.selected}contains(t,e,n,i){if(!n.resizable)return!1;const r=_p(n.bounds,i);for(let s=0;s<r.length;s++){const o=r[s];if(null!=o.x&&null!=o.y&&Math.abs(t-o.x)<=4/i.x&&Math.abs(e-o.y)<=4/i.y)return this.active={component:n,index:s},!0}return!1}draw(t,e,n){if(e.isLine())return;const{left:i,top:r,width:s,height:o}=e.bounds;if(t.beginPath(),t.rect(i-4/n.x,r-4/n.y,s+8/n.x,o+8/n.y),t.setLineDash([3/n.x,4/n.y]),t.lineWidth=1/n.x,t.strokeStyle="black",t.stroke(),t.setLineDash([]),!e.resizable)return;const a=this.active;_p(e.bounds,n).forEach((i,r)=>{null!=i.x&&null!=i.y&&(t.beginPath(),t.rect(i.x-4/n.x,i.y-4/n.y,8/n.x,8/n.y),t.setLineDash([]),t.strokeStyle="#656565",t.stroke(),t.fillStyle="#fff",a&&a.component===e&&a.index===r&&(t.strokeStyle="#fa7703",a.focus&&(t.fillStyle="#ffb80c")),t.fill(),t.stroke())})}onmousedown(t){this.active.focus=!0}ondragstart(t){const{component:e}=this.active;this.active.bounds=e.bounds,this.active.boundsList=this.layer.selected.filter(t=>t.resizable).map(t=>t.bounds)}_resizeAll(t,e){const{component:n,index:i,boundsList:r,bounds:s}=this.active,o=n.scalable?this.layer.toLocal(t.offsetX,t.offsetY):{x:t.offsetX,y:t.offsetY};n.bounds=s;const a=function(t,e,n){const{left:i,top:r,width:s,height:o}=t.bounds;let a,c;switch(e){case 0:a=i,c=r;break;case 1:a=i+s/2,c=r;break;case 2:a=i+s,c=r;break;case 3:a=i+s,c=r+o/2;break;case 4:a=i+s,c=r+o;break;case 5:a=i+s/2,c=r+o;break;case 6:a=i,c=r+o;break;case 7:a=i,c=r+o/2}const l=a,h=c,d=t.fromScene(n.x,n.y);return{dx:d.x-l,dy:d.y-h}}(n,i,o);this.layer.selected.filter(t=>t.resizable).forEach((n,s)=>{n.bounds=r[s],function(t,e,n,i,r,s){let{left:o,top:a,width:c,height:l}=t.bounds;const h={left:o,top:a,width:c,height:l};switch(e){case 0:o+=i,a+=r,c-=i,l-=r;break;case 1:a+=r,l-=r;break;case 2:a+=r,c+=i,l-=r;break;case 3:c+=i;break;case 4:c+=i,l+=r;break;case 5:l+=r;break;case 6:o+=i,c-=i,l+=r;break;case 7:o+=i,c-=i}if(t.mutateBounds(function(e){return Math.abs(c)<=.001&&(c=.001),Math.abs(l)<=.001&&(l=.001),t.adjustResize({left:o,top:a,width:c,height:l},h,n)},this),t.isContainer()&&t.layout.ABSOLUTE&&!t.isGroup()){const e=h.left-o,n=h.top-a;return void(s?t.components.forEach(t=>{t.delta("tx",0),t.delta("ty",0),t.move({x:e,y:n},!1)}):t.components.forEach(t=>{t.delta("tx",e),t.delta("ty",n)}))}const d=s&&t.parent;d&&d.isGroup()&&d.calculateBounds()}(n,i,t.shiftKey,a.dx,a.dy,e)})}ondragmove(t){this._resizeAll(t,!1)}ondragend(t){this._resizeAll(t,!0),this.active.component.app.commander.execute(null,!1)}}const xp=2*Math.PI,wp=Math.PI/2;function Mp(t,e){const n=t.bounds;return{x:n.left+n.width/2,y:n.top-20/e.y}}class Sp{constructor(t){this.layer=t}reset(){this.active=null}get selected(){return this.layer.selected}contains(t,e,n,i){if(!n.rotatable)return!1;const r=Mp(n,i);return Math.abs(t-r.x)<=4/i.x&&Math.abs(e-r.y)<=4/i.y&&(this.active={component:n},!0)}draw(t,e,n){if(!e.rotatable)return;t.beginPath();const i=Mp(e,n);t.lineWidth=1.5/n.x,t.moveTo(i.x,i.y+20/n.y),t.lineTo(i.x,i.y),t.strokeStyle="#656565",t.stroke(),t.beginPath(),t.ellipse(i.x,i.y,4/n.x,4/n.y,0,0,xp,!0),t.stroke(),t.fillStyle="#fff",t.fill();const r=this.active;r&&r.component===e&&(t.strokeStyle="#fa7703",t.stroke(),r.toFill&&(t.fillStyle="#ffb80c",t.fill()))}onmousedown(t){this.active.toFill=!0}ondragstart(t){const e=this.active;e.start_rotation=e.component.get("rotation"),e.rotations=this.layer.selected.filter(t=>t.rotatable).map(t=>t.get("rotation"))}ondragmove(t){const{component:e}=this.active;let n;e.scalable?(n=e.toLocal(t.offsetX,t.offsetY),n=e.toParent(n.x,n.y)):(n={x:t.offsetX,y:t.offsetY},e.parent?.isRootModel()||(n=e.toParent(n.x,n.y)));const i=e.rotatePoint,r=e.get("rotation")||0;let s=Math.atan((i.y-n.y)/(i.x-n.x));s=i.x>=n.x?s-wp:wp+s;const o=s-r;this.layer.selected.filter(t=>t.rotatable).forEach((e,n)=>{const i=((e.get("rotation")||0)+o)%xp;e.set("rotation",e.adjustRotation(i,t.shiftKey))})}ondragend(t){const{component:e}=this.active;e.app.commander.execute(null,!1)}}Va.register("modeling-layer",class extends Ad{constructor(t,e){super(t,e),this.pathHandler=new mp(this);const n=this.pathHandler,i=new pp(this),r=new vp(this),s=new Sp(this);this._modelers=[n,i,r,s],this._control_mode_modelers=[i,n,r,s],this.focusOutline=new dp(this),this.groupOutline=new up(this),this.anchorHandler=new bp(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}async ready(){await super.ready();const t=this.rootModel,e=t.get("translate"),n=t.get("scale");this.set("translate",e),this.set("scale",n)}capture(t,e,n){return!!this.contains(t,e)&&this}contains(t,e){let n=this.selected.filter(t=>!!t.parent);const i=this.fromParent(t,e),r=this.get("scale")||{x:1,y:1};let s;if(this._state_dragging){if(this._counter_end){let n=r;if(this.anchorTarget.scalable?s=this.anchorTarget.fromScene(i.x,i.y):(s=this.anchorTarget.fromScene(t,e),n={x:1,y:1}),this.anchorHandler.contains(s.x,s.y,this.anchorTarget,n))return!0}return!0}this.modelers.forEach(t=>t.reset()),n=this.selected.filter(t=>!!t.parent);for(let o=0;o<n.length;o++){const a=n[o];let c=r;a.scalable?s=a.fromScene(i.x,i.y):(s=a.fromScene(t,e),c={x:1,y:1});for(let t=0;t<this.modelers.length;t++){const e=this.modelers[t];if(e.contains(s.x,s.y,a,c))return this.currentModeler=e,!0}}if(this.anchorTarget){let n=r;if(this.anchorTarget.scalable?s=this.anchorTarget.fromScene(i.x,i.y):(s=this.anchorTarget.fromScene(t,e),n={x:1,y:1}),this.anchorHandler.contains(s.x,s.y,this.anchorTarget,n))return this.currentModeler=this.anchorHandler,!0}else this.anchorHandler.reset();return this.currentModeler=null,!1}_componentDrawer(t,e,n,i){const r=[];let s=e.parent;if(e.isRootModel())return t.save(),i(t,e,n),void t.restore();for((t=this.getContext(e))==this.auxContext2D&&(n={x:1,y:1});s&&!s.isRootModel();)r.push(s),s=s.parent;t.save(),r.reverse().forEach(function(e){const n=e.rotatePoint;t.translate(n.x,n.y);const i=e.get("scale");i&&t.scale(i.x,i.y),t.rotate(e.get("rotation")),t.translate(-n.x,-n.y);const r=e.bounds;t.translate(r.left,r.top)});const o=e.rotatePoint;t.translate(o.x,o.y);const a=e.get("scale");a&&t.scale(a.x,a.y),t.rotate(e.get("rotation")),t.translate(-o.x,-o.y),i(t,e,n),t.restore()}prerender(t){const{translate:e,scale:n={x:1,y:1},rotation:i}=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*Mr,e.y*Mr),t.scale(n.x*Mr,n.y*Mr),i&&t.rotate(i),t.clearRect(0,0,this.rootModel.get("width"),this.rootModel.get("height"))}render(t){if(this.rootModel?.is3dMode)return;t.beginPath();const e=this.get("scale")||{x:1,y:1},n=this.selected.filter(t=>!!t.parent);if(this.anchorTarget&&this._componentDrawer(t,this.anchorTarget,e,(t,e,n)=>{this.anchorHandler.draw(t,e,n)}),this.focused&&this._componentDrawer(t,this.focused,e,(t,e,n)=>{this.focusOutline.draw(t,e,n)}),n.length>0&&n[0].parent.isGroup()){let i=n[0].parent;for(;i.parent.isGroup();)i=i.parent;this._componentDrawer(t,i,e,(t,e,n)=>{this.groupOutline.draw(t,e,n)})}n.forEach(n=>{this._componentDrawer(t,n,e,(t,e,n)=>{this.reversedModelers.forEach(i=>i.draw(t,e,n))})})}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,n){this.currentModeler=this.pathHandler,this.processingLink=this.pathHandler.startLinkProcess(t,e,n),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,n){const{origin:i,deliverer:r}=n;i===r&&(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 n=e.origin;n?.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){const{origin:n}=e,i=t.dataTransfer.files;if(i.length<1)return;const r=this.rootModel.toLocal(t.offsetX,t.offsetY),s=this.rootModel;Promise.all(Array.from(i).map(t=>new Promise((e,n)=>{const i=new FileReader;i.addEventListener("loadend",t=>{e(i.result)}),["error","abort"].forEach(t=>i.addEventListener(t,t=>{n(t)})),i.readAsDataURL(t)}))).then(e=>{if(t.altKey)return Sc.around(this.app.commander,()=>{n.ondropfile(i,e)}),void(this.selected=[n]);const o=[],a=e.map((t,e)=>{let n;const a=i[e].type,c=i[e].name;return a.startsWith("image/")?(n=Ic({type:a.startsWith("image/gif")?"gif-view":"image-view",top:0,left:0,width:200,height:200,src:t},s.app),o.push(new Promise((e,i)=>{const r=new Image;r.src=t,r.onload=()=>{n.set({width:r.width,height:r.height}),e()},r.onerror=t=>{i(t)}}))):a.startsWith("audio/")?n=Ic({type:"audio",top:0,left:0,width:100,height:100,src:t},s.app):a.startsWith("vnd.ms-excel/")||/\.xlsx?$/.test(c)?n=Ic({type:"excel",top:0,left:0,width:100,height:100,src:t},s.app):Ni("dropped file",i[e]),n&&(n.center=r,r.x+=50,r.y+=50),n}).filter(Boolean).map(t=>({component:t,to_container:s}));a.length>0&&Promise.all(o).then(()=>{this.app.commander.execute(new zc({changes:a})),this.selected=a.map(t=>t.component)},t=>{Fi(t)})},t=>{Fi(t)})}onwheel_scale(t,e){if(0==t.deltaY&&0==t.deltaX)return;const n=e.deliverer;let i;if(t.shiftKey)i=-1!=navigator.userAgent.indexOf("Win")?t.deltaY<0?1:-1:t.deltaX<0?1:-1,t.altKey?Sc.around(this.app.commander,()=>{n.selected.forEach(t=>{let e=t.get("letterSpacing")||Er.LETTER_SPACING;e+=i,t.set("letterSpacing",e)})}):Sc.around(this.app.commander,()=>{n.selected.forEach(t=>{let e=t.get("fontSize")||Er.FONT_SIZE;e<1&&(e=1),e+=i,t.set("fontSize",e)})});else{i=t.deltaY<0?1:-1;const e=n.get("scale")||{x:1,y:1},r=n.get("translate"),s=t.offsetX,o=t.offsetY,a=n.toLocal(s,o),c=.1*i,l={x:e.x+c,y:e.y+c};if(i<0&&e.x<.2||i>0&&e.x>10)return;n.set("scale",l);const h=n.toLocal(s,o);n.set("translate",{x:r.x+(h.x-a.x)*l.x,y:r.y+(h.y-a.y)*l.y})}}});Va.register("scroll-layer",class extends Sd{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:n,top:i,width:r,height:s}=this.vscroller;t.globalAlpha="v"==e?1:.3,t.fillRect(n,i,r,s)}if(this.hscroller){const{left:n,top:i,width:r,height:s}=this.hscroller;t.globalAlpha="h"==e?1:.3,t.fillRect(n,i,r,s)}t.stroke(),t.restore()}resize(){super.resize(),this.calcScrollerBounds()}contains(t,e){const n=this.vscroller,i=this.hscroller;return this.setState("scrolling",n&&t>=n.left&&t<=n.left+n.width&&e>=n.top&&e<=n.top+n.height?"v":i&&t>=i.left&&t<=i.left+i.width&&e>=i.top&&e<=i.top+i.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 n=this.root,{clientWidth:i,clientHeight:r}=this.canvas,{width:s,height:o}=this.rootModel.model,{x:a,y:c}={x:t.offsetX,y:t.offsetY},{x:l,y:h}=this._scale,{scrolling:d}=this.state,u=s/i,p=o/r;d&&n.rootModel.move({x:"h"==d?(-a+this.lastPosition.x)*l*u:0,y:"v"==d?(-c+this.lastPosition.y)*h*p:0},!1),this.lastPosition={x:t.offsetX,y:t.offsetY}}ondragend(){delete this.lastPosition,this.setState({scrolling:null})}calcScrollerBounds(){if(!this.rootModel)return;const{clientWidth:t,clientHeight:e}=this.canvas,{width:n,height:i}=this.rootModel.model,{x:r=1,y:s=1}=this._scale||{},{x:o=0,y:a=0}=this._translate||{},c=n/t,l=i/e;let h={left:-o/r/c,top:e-10,width:t/r/c,height:10};this.hscroller=h.left>1||h.width+h.left<t-1?h:null,h={left:t-10,top:-a/s/l,width:10,height:e/s/l},this.vscroller=h.top>1||h.height+h.top<e-1?h:null,this.invalidate()}onchangeModelLayer(t,e,n){if(t.scale){const{x:e=1,y:n=1}=t?.scale||{};this._scale={x:e,y:n},this.calcScrollerBounds()}if(t.translate){const{x:e=0,y:n=0}=t.translate||{};this._translate={x:e,y:n},this.calcScrollerBounds()}}});const Ap="#ff3366",Ep=[3,3];function kp(t,e,n,i){var r,s=arguments.length,o=s<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,n,i);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(o=(s<3?r(o):s>3?r(e,n,o):r(e,n))||o);return s>3&&o&&Object.defineProperty(e,n,o),o}function Cp(t,e,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(t):i?i.value:e.get(t)}function Tp(t,e,n,i,r){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!r:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(t,n):r?r.value=n:e.set(t,n),n}Va.register("snap-guide-layer",class extends Sd{constructor(){super(...arguments),this._snapResult=null}get pointerEvents(){return"none"}get capturable(){return!1}contains(t,e){return!1}get snapResult(){return this._snapResult}set snapResult(t){this._snapResult=t,this.invalidate()}clear(){this._snapResult&&(this._snapResult=null,this.invalidate())}get eventMap(){return{"(root)":{"model-layer":{change:this.onchange_root_model}}}}onchange_root_model(t){(t.translate||t.scale)&&this.syncTransform()}syncTransform(){const t=this.rootModel;if(!t)return;const e=t.get("translate")||{x:0,y:0},n=t.get("scale")||{x:1,y:1};this.set({translate:e,scale:n})}async ready(){await super.ready(),this.syncTransform()}render(t){const e=this._snapResult;if(e&&0!==e.guides.length){t.save(),t.strokeStyle=Ap,t.fillStyle=Ap,t.lineWidth=1,t.setLineDash(Ep);for(let n=0,i=e.guides.length;n<i;n++){const i=e.guides[n];t.beginPath(),"x"===i.axis?(t.moveTo(i.position,i.from),t.lineTo(i.position,i.to)):(t.moveTo(i.from,i.position),t.lineTo(i.to,i.position)),t.stroke()}t.restore()}}}),"function"==typeof SuppressedError&&SuppressedError;
|
|
3
3
|
/**
|
|
4
4
|
* @license
|
|
5
5
|
* Copyright 2019 Google LLC
|
|
6
6
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
7
7
|
*/
|
|
8
|
-
const
|
|
8
|
+
const Pp=globalThis,Dp=Pp.ShadowRoot&&(void 0===Pp.ShadyCSS||Pp.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Op=Symbol(),zp=new WeakMap;let Lp=class{constructor(t,e,n){if(this._$cssResult$=!0,n!==Op)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const e=this.t;if(Dp&&void 0===t){const n=void 0!==e&&1===e.length;n&&(t=zp.get(e)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),n&&zp.set(e,t))}return t}toString(){return this.cssText}};const Ip=Dp?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const n of t.cssRules)e+=n.cssText;return(t=>new Lp("string"==typeof t?t:t+"",void 0,Op))(e)})(t):t,{is:Rp,defineProperty:jp,getOwnPropertyDescriptor:Fp,getOwnPropertyNames:Bp,getOwnPropertySymbols:Np,getPrototypeOf:Hp}=Object,Yp=globalThis,Gp=Yp.trustedTypes,Vp=Gp?Gp.emptyScript:"",Up=Yp.reactiveElementPolyfillSupport,$p=(t,e)=>t,Wp={toAttribute(t,e){switch(e){case Boolean:t=t?Vp:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let n=t;switch(e){case Boolean:n=null!==t;break;case Number:n=null===t?null:Number(t);break;case Object:case Array:try{n=JSON.parse(t)}catch(t){n=null}}return n}},Xp=(t,e)=>!Rp(t,e),qp={attribute:!0,type:String,converter:Wp,reflect:!1,useDefault:!1,hasChanged:Xp};
|
|
9
9
|
/**
|
|
10
10
|
* @license
|
|
11
11
|
* Copyright 2017 Google LLC
|
|
12
12
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
13
|
-
*/Symbol.metadata??=Symbol("metadata"),
|
|
13
|
+
*/Symbol.metadata??=Symbol("metadata"),Yp.litPropertyMetadata??=new WeakMap;let Kp=class extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=qp){if(e.state&&(e.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((e=Object.create(e)).wrapped=!0),this.elementProperties.set(t,e),!e.noAccessor){const n=Symbol(),i=this.getPropertyDescriptor(t,n,e);void 0!==i&&jp(this.prototype,t,i)}}static getPropertyDescriptor(t,e,n){const{get:i,set:r}=Fp(this.prototype,t)??{get(){return this[e]},set(t){this[e]=t}};return{get:i,set(e){const s=i?.call(this);r?.call(this,e),this.requestUpdate(t,s,n)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??qp}static _$Ei(){if(this.hasOwnProperty($p("elementProperties")))return;const t=Hp(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty($p("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty($p("properties"))){const t=this.properties,e=[...Bp(t),...Np(t)];for(const n of e)this.createProperty(n,t[n])}const t=this[Symbol.metadata];if(null!==t){const e=litPropertyMetadata.get(t);if(void 0!==e)for(const[t,n]of e)this.elementProperties.set(t,n)}this._$Eh=new Map;for(const[t,e]of this.elementProperties){const n=this._$Eu(t,e);void 0!==n&&this._$Eh.set(n,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const n=new Set(t.flat(1/0).reverse());for(const t of n)e.unshift(Ip(t))}else void 0!==t&&e.push(Ip(t));return e}static _$Eu(t,e){const n=e.attribute;return!1===n?void 0:"string"==typeof n?n:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(t=>this.enableUpdating=t),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(t=>t(this))}addController(t){(this._$EO??=new Set).add(t),void 0!==this.renderRoot&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$EO?.delete(t)}_$E_(){const t=new Map,e=this.constructor.elementProperties;for(const n of e.keys())this.hasOwnProperty(n)&&(t.set(n,this[n]),delete this[n]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return((t,e)=>{if(Dp)t.adoptedStyleSheets=e.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(const n of e){const e=document.createElement("style"),i=Pp.litNonce;void 0!==i&&e.setAttribute("nonce",i),e.textContent=n.cssText,t.appendChild(e)}})(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(t=>t.hostConnected?.())}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach(t=>t.hostDisconnected?.())}attributeChangedCallback(t,e,n){this._$AK(t,n)}_$ET(t,e){const n=this.constructor.elementProperties.get(t),i=this.constructor._$Eu(t,n);if(void 0!==i&&!0===n.reflect){const r=(void 0!==n.converter?.toAttribute?n.converter:Wp).toAttribute(e,n.type);this._$Em=t,null==r?this.removeAttribute(i):this.setAttribute(i,r),this._$Em=null}}_$AK(t,e){const n=this.constructor,i=n._$Eh.get(t);if(void 0!==i&&this._$Em!==i){const t=n.getPropertyOptions(i),r="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:Wp;this._$Em=i;const s=r.fromAttribute(e,t.type);this[i]=s??this._$Ej?.get(i)??s,this._$Em=null}}requestUpdate(t,e,n,i=!1,r){if(void 0!==t){const s=this.constructor;if(!1===i&&(r=this[t]),n??=s.getPropertyOptions(t),!((n.hasChanged??Xp)(r,e)||n.useDefault&&n.reflect&&r===this._$Ej?.get(t)&&!this.hasAttribute(s._$Eu(t,n))))return;this.C(t,e,n)}!1===this.isUpdatePending&&(this._$ES=this._$EP())}C(t,e,{useDefault:n,reflect:i,wrapped:r},s){n&&!(this._$Ej??=new Map).has(t)&&(this._$Ej.set(t,s??e??this[t]),!0!==r||void 0!==s)||(this._$AL.has(t)||(this.hasUpdated||n||(e=void 0),this._$AL.set(t,e)),!0===i&&this._$Em!==t&&(this._$Eq??=new Set).add(t))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[t,e]of this._$Ep)this[t]=e;this._$Ep=void 0}const t=this.constructor.elementProperties;if(t.size>0)for(const[e,n]of t){const{wrapped:t}=n,i=this[e];!0!==t||this._$AL.has(e)||void 0===i||this.C(e,void 0,n,i)}}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),this._$EO?.forEach(t=>t.hostUpdate?.()),this.update(e)):this._$EM()}catch(e){throw t=!1,this._$EM(),e}t&&this._$AE(e)}willUpdate(t){}_$AE(t){this._$EO?.forEach(t=>t.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Eq&&=this._$Eq.forEach(t=>this._$ET(t,this[t])),this._$EM()}updated(t){}firstUpdated(t){}};Kp.elementStyles=[],Kp.shadowRootOptions={mode:"open"},Kp[$p("elementProperties")]=new Map,Kp[$p("finalized")]=new Map,Up?.({ReactiveElement:Kp}),(Yp.reactiveElementVersions??=[]).push("2.1.2");
|
|
14
14
|
/**
|
|
15
15
|
* @license
|
|
16
16
|
* Copyright 2017 Google LLC
|
|
17
17
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
18
18
|
*/
|
|
19
|
-
const
|
|
19
|
+
const Qp=globalThis,Zp=t=>t,Jp=Qp.trustedTypes,tf=Jp?Jp.createPolicy("lit-html",{createHTML:t=>t}):void 0,ef="$lit$",nf=`lit$${Math.random().toFixed(9).slice(2)}$`,rf="?"+nf,sf=`<${rf}>`,of=document,af=()=>of.createComment(""),cf=t=>null===t||"object"!=typeof t&&"function"!=typeof t,lf=Array.isArray,hf="[ \t\n\f\r]",df=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,uf=/-->/g,pf=/>/g,ff=RegExp(`>|${hf}(?:([^\\s"'>=/]+)(${hf}*=${hf}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),gf=/'/g,mf=/"/g,yf=/^(?:script|style|textarea|title)$/i,bf=(t=>(e,...n)=>({_$litType$:t,strings:e,values:n}))(1),_f=Symbol.for("lit-noChange"),vf=Symbol.for("lit-nothing"),xf=new WeakMap,wf=of.createTreeWalker(of,129);function Mf(t,e){if(!lf(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==tf?tf.createHTML(e):e}const Sf=(t,e)=>{const n=t.length-1,i=[];let r,s=2===e?"<svg>":3===e?"<math>":"",o=df;for(let e=0;e<n;e++){const n=t[e];let a,c,l=-1,h=0;for(;h<n.length&&(o.lastIndex=h,c=o.exec(n),null!==c);)h=o.lastIndex,o===df?"!--"===c[1]?o=uf:void 0!==c[1]?o=pf:void 0!==c[2]?(yf.test(c[2])&&(r=RegExp("</"+c[2],"g")),o=ff):void 0!==c[3]&&(o=ff):o===ff?">"===c[0]?(o=r??df,l=-1):void 0===c[1]?l=-2:(l=o.lastIndex-c[2].length,a=c[1],o=void 0===c[3]?ff:'"'===c[3]?mf:gf):o===mf||o===gf?o=ff:o===uf||o===pf?o=df:(o=ff,r=void 0);const d=o===ff&&t[e+1].startsWith("/>")?" ":"";s+=o===df?n+sf:l>=0?(i.push(a),n.slice(0,l)+ef+n.slice(l)+nf+d):n+nf+(-2===l?e:d)}return[Mf(t,s+(t[n]||"<?>")+(2===e?"</svg>":3===e?"</math>":"")),i]};class Af{constructor({strings:t,_$litType$:e},n){let i;this.parts=[];let r=0,s=0;const o=t.length-1,a=this.parts,[c,l]=Sf(t,e);if(this.el=Af.createElement(c,n),wf.currentNode=this.el.content,2===e||3===e){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(i=wf.nextNode())&&a.length<o;){if(1===i.nodeType){if(i.hasAttributes())for(const t of i.getAttributeNames())if(t.endsWith(ef)){const e=l[s++],n=i.getAttribute(t).split(nf),o=/([.?@])?(.*)/.exec(e);a.push({type:1,index:r,name:o[2],strings:n,ctor:"."===o[1]?Pf:"?"===o[1]?Df:"@"===o[1]?Of:Tf}),i.removeAttribute(t)}else t.startsWith(nf)&&(a.push({type:6,index:r}),i.removeAttribute(t));if(yf.test(i.tagName)){const t=i.textContent.split(nf),e=t.length-1;if(e>0){i.textContent=Jp?Jp.emptyScript:"";for(let n=0;n<e;n++)i.append(t[n],af()),wf.nextNode(),a.push({type:2,index:++r});i.append(t[e],af())}}}else if(8===i.nodeType)if(i.data===rf)a.push({type:2,index:r});else{let t=-1;for(;-1!==(t=i.data.indexOf(nf,t+1));)a.push({type:7,index:r}),t+=nf.length-1}r++}}static createElement(t,e){const n=of.createElement("template");return n.innerHTML=t,n}}function Ef(t,e,n=t,i){if(e===_f)return e;let r=void 0!==i?n._$Co?.[i]:n._$Cl;const s=cf(e)?void 0:e._$litDirective$;return r?.constructor!==s&&(r?._$AO?.(!1),void 0===s?r=void 0:(r=new s(t),r._$AT(t,n,i)),void 0!==i?(n._$Co??=[])[i]=r:n._$Cl=r),void 0!==r&&(e=Ef(t,r._$AS(t,e.values),r,i)),e}class kf{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:e},parts:n}=this._$AD,i=(t?.creationScope??of).importNode(e,!0);wf.currentNode=i;let r=wf.nextNode(),s=0,o=0,a=n[0];for(;void 0!==a;){if(s===a.index){let e;2===a.type?e=new Cf(r,r.nextSibling,this,t):1===a.type?e=new a.ctor(r,a.name,a.strings,this,t):6===a.type&&(e=new zf(r,this,t)),this._$AV.push(e),a=n[++o]}s!==a?.index&&(r=wf.nextNode(),s++)}return wf.currentNode=of,i}p(t){let e=0;for(const n of this._$AV)void 0!==n&&(void 0!==n.strings?(n._$AI(t,n,e),e+=n.strings.length-2):n._$AI(t[e])),e++}}class Cf{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,e,n,i){this.type=2,this._$AH=vf,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=n,this.options=i,this._$Cv=i?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return void 0!==e&&11===t?.nodeType&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=Ef(this,t,e),cf(t)?t===vf||null==t||""===t?(this._$AH!==vf&&this._$AR(),this._$AH=vf):t!==this._$AH&&t!==_f&&this._(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):(t=>lf(t)||"function"==typeof t?.[Symbol.iterator])(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==vf&&cf(this._$AH)?this._$AA.nextSibling.data=t:this.T(of.createTextNode(t)),this._$AH=t}$(t){const{values:e,_$litType$:n}=t,i="number"==typeof n?this._$AC(t):(void 0===n.el&&(n.el=Af.createElement(Mf(n.h,n.h[0]),this.options)),n);if(this._$AH?._$AD===i)this._$AH.p(e);else{const t=new kf(i,this),n=t.u(this.options);t.p(e),this.T(n),this._$AH=t}}_$AC(t){let e=xf.get(t.strings);return void 0===e&&xf.set(t.strings,e=new Af(t)),e}k(t){lf(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let n,i=0;for(const r of t)i===e.length?e.push(n=new Cf(this.O(af()),this.O(af()),this,this.options)):n=e[i],n._$AI(r),i++;i<e.length&&(this._$AR(n&&n._$AB.nextSibling,i),e.length=i)}_$AR(t=this._$AA.nextSibling,e){for(this._$AP?.(!1,!0,e);t!==this._$AB;){const e=Zp(t).nextSibling;Zp(t).remove(),t=e}}setConnected(t){void 0===this._$AM&&(this._$Cv=t,this._$AP?.(t))}}class Tf{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,n,i,r){this.type=1,this._$AH=vf,this._$AN=void 0,this.element=t,this.name=e,this._$AM=i,this.options=r,n.length>2||""!==n[0]||""!==n[1]?(this._$AH=Array(n.length-1).fill(new String),this.strings=n):this._$AH=vf}_$AI(t,e=this,n,i){const r=this.strings;let s=!1;if(void 0===r)t=Ef(this,t,e,0),s=!cf(t)||t!==this._$AH&&t!==_f,s&&(this._$AH=t);else{const i=t;let o,a;for(t=r[0],o=0;o<r.length-1;o++)a=Ef(this,i[n+o],e,o),a===_f&&(a=this._$AH[o]),s||=!cf(a)||a!==this._$AH[o],a===vf?t=vf:t!==vf&&(t+=(a??"")+r[o+1]),this._$AH[o]=a}s&&!i&&this.j(t)}j(t){t===vf?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class Pf extends Tf{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===vf?void 0:t}}class Df extends Tf{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==vf)}}class Of extends Tf{constructor(t,e,n,i,r){super(t,e,n,i,r),this.type=5}_$AI(t,e=this){if((t=Ef(this,t,e,0)??vf)===_f)return;const n=this._$AH,i=t===vf&&n!==vf||t.capture!==n.capture||t.once!==n.once||t.passive!==n.passive,r=t!==vf&&(n===vf||i);i&&this.element.removeEventListener(this.name,this,n),r&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){"function"==typeof this._$AH?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t)}}class zf{constructor(t,e,n){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=n}get _$AU(){return this._$AM._$AU}_$AI(t){Ef(this,t)}}const Lf=Qp.litHtmlPolyfillSupport;Lf?.(Af,Cf),(Qp.litHtmlVersions??=[]).push("3.3.2");const If=(t,e,n)=>{const i=n?.renderBefore??e;let r=i._$litPart$;if(void 0===r){const t=n?.renderBefore??null;i._$litPart$=r=new Cf(e.insertBefore(af(),t),t,void 0,n??{})}return r._$AI(t),r
|
|
20
20
|
/**
|
|
21
21
|
* @license
|
|
22
22
|
* Copyright 2017 Google LLC
|
|
23
23
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
24
|
-
*/},
|
|
24
|
+
*/},Rf=globalThis;class jf extends Kp{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){const t=super.createRenderRoot();return this.renderOptions.renderBefore??=t.firstChild,t}update(t){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=If(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return _f}}jf._$litElement$=!0,jf.finalized=!0,Rf.litElementHydrateSupport?.({LitElement:jf});const Ff=Rf.litElementPolyfillSupport;Ff?.({LitElement:jf}),(Rf.litElementVersions??=[]).push("4.2.2");const Bf=["mousemove","mouseup","mousedown","mouseout","wheel","tap","click","touchstart","touchmove","touchend","mouseenter","mouseleave","dragstart","dragmove","dragend","dblclick"];function Nf(t){return class extends t{constructor(){super(...arguments),this.userInputEventHandler=t=>{xc(this,t.type,t),t.stopPropagation()}}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&&("popup"!==this.position&&(this.parent.isHTMLElement()?this.parent.element.appendChild(this.element):this.rootModel.getOverlay?.(this)?.appendChild(this.element)),this.scalable||(this.element.style.zIndex="100"),Bf.forEach(t=>{this.element.addEventListener(t,this.userInputEventHandler)}),Ar.forEach(t=>{this.element.addEventListener(t,this.userInputEventHandler)}),this.oncreate_element&&this.oncreate_element(this.element))}reposition(){this.state.screenFixed&&this.isContainer?.()||this.element&&os(this)}disposeElement(){if(!this.element)return;Bf.forEach(t=>{this.element.removeEventListener(t,this.userInputEventHandler)}),Ar.forEach(t=>{this.element.removeEventListener(t,this.userInputEventHandler)});const t=this.element;t&&t.parentElement&&t.parentElement.removeChild(t),this.element=null}async ready(){await super.ready(),!this.element&&this.createElement(),"popup"!==this.position&&(this.parent.isHTMLElement()?this.parent.element.appendChild(this.element):this.rootModel.getOverlay?.(this)?.appendChild(this.element)),this.setElementProperties(this.element),this.reposition()}dispose(){this.disposeElement(),super.dispose()}get hasTextProperty(){return!0}get textHidden(){return!0}set textHidden(t){}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),"position"in t&&this.onchangePosition(),this.reposition()}onchangePosition(){this.element&&("popup"!==this.position?"static"==this.position&&this.parent.isHTMLElement()?this.parent.element.appendChild(this.element):this.rootModel.getOverlay?.(this)?.appendChild(this.element):this.element.parentNode?.removeChild(this.element))}isDescendible(t){return t.isHTMLElement()}}}var Hf;const Yf={x:1,y:1},Gf={boxSizing:"border-box",margin:"0px",position:"absolute",outline:"none"},Vf={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"select",label:"position-origin",name:"origin",property:{options:[{display:"",value:""},{display:"left-top",value:"left-top"},{display:"center-top",value:"center-top"},{display:"right-top",value:"right-top"},{display:"left-middle",value:"left-middle"},{display:"center-middle",value:"center-middle"},{display:"right-middle",value:"right-middle"},{display:"left-bottom",value:"left-bottom"},{display:"center-bottom",value:"center-bottom"},{display:"right-bottom",value:"right-bottom"}]}},{type:"number",label:"offset-x",name:"offsetX"},{type:"number",label:"offset-y",name:"offsetY"},{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 Uf extends(Nf(Zc)){constructor(){super(...arguments),Hf.set(this,null),this.startDragging=t=>{if(!this.state.draggable)return;t.preventDefault(),t.stopPropagation();const e=t.clientX,n=t.clientY,{left:i,top:r}=this.bounds,s=this.rootModel.getOverlay?.(this)?.style.transform,o=s?.match(/scale\(([^,]+),\s*([^)]+)\)/),a=o?parseFloat(o[1]):1,c=o?parseFloat(o[2]):a,l=t=>{t.preventDefault(),t.stopPropagation();const s=(t.clientX-e)/a,o=(t.clientY-n)/c;this.setState({left:i+s,top:r+o})},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)},this.toggleMinimizable=()=>{const{minimized:t}=this.state;this.setState("minimized",!t)},this.closeContainer=()=>{this.setState("hidden",!0)}}get tagName(){return"div"}get nature(){return Vf}isPositionable(){return!0}setElementProperties(t){}get layout(){return Ja.get(this.get("layout"))||tc}reposition(){if(!this.element)return;const t=this,{id:e,class:n,scale:i=Yf}=t.state,{rotation:r=0,hidden:s}=t,{left:o,top:a,width:c,height:l}=t.bounds,h=c/2,d=l/2,u=t.element;u.hidden=s,e&&(u.id=e),n&&(u.className=n),Object.assign(u.style,Gf,{left:o+"px",top:a+"px",width:"0px",height:"0px",backgroundColor:"transparent"});const p=t.delta(),f=(i&&i.x||1)*p.sx,g=(i&&i.y||1)*p.sy,m=(r||0)+p.theta,y=p.tx||0,b=p.ty||0;u.style.transform=`translate(${y+h}px, ${b+d}px) rotate(${m}rad) translate(${-h}px, ${-d}px) scale(${f}, ${g}) perspective(1px)`}set path(t){const{minimized:e}=this.state,n=t[0],i=t[2];e?this.set({left:n.x,top:n.y,width:i.x-n.x}):this.set({left:n.x,top:n.y,width:i.x-n.x,height:i.y-n.y})}get path(){const{left:t=0,top:e=0,width:n=0,height:i=0}=this.state;return[{x:t,y:e},{x:t+n,y:e},{x:t+n,y:e+i},{x:t,y:e+i}]}get bounds(){const{left:t=0,top:e=0,width:n=0,height:i=0}=this.state;return{left:t,top:e,width:n,height:i}}set bounds(t){const{minimized:e}=this.state,{left:n=0,top:i=0,width:r=0,height:s=0}=t,o={left:n,top:i};e?this.set({...o,width:r}):this.set({...o,width:r,height:s})}updatePosition(){if(!this.origin)return void(Cp(this,Hf,"f")&&(Cp(this,Hf,"f").disconnect(),Tp(this,Hf,null,"f")));const t=this.rootModel.auxOverlay;if(!t)return;const e=this.bounds,{width:n,height:i}="static"!==this.position?t.getBoundingClientRect():this.parent.bounds,{x:r,y:s}=function(t,e,n){const{left:i,top:r,width:s,height:o}=e,{width:a,height:c}=n;return t?{x:t.includes("left")?i:t.includes("center")?i+(s-a)/2:i+(s-a),y:t.includes("top")?r:t.includes("middle")?r+(o-c)/2:r+(o-c)}:{x:n.left,y:n.top}}(this.origin,{left:0,top:0,width:n,height:i},e),o=this.offset;this.bounds={left:r+(this.origin.includes("right")?-o.x:+o.x),top:s+(this.origin.includes("bottom")?-o.y:+o.y),width:e.width,height:e.height},Cp(this,Hf,"f")||(Tp(this,Hf,new ResizeObserver(()=>{requestAnimationFrame(()=>this.updatePosition())}),"f"),Cp(this,Hf,"f").observe(t))}onchange(t,e){const n=["draggable","minimizable","closable","minimized","width","height","origin","offsetX","offsetY","hidden"];super.onchange(t,e),Object.keys(t).some(t=>n.includes(t))&&this.onchangeButtons(),"minimized"in t&&this.onchangeMinimized(),("origin"in t||"offsetX"in t||"offsetY"in t)&&this.updatePosition()}async ready(){await super.ready(),this.updatePosition()}dispose(){Cp(this,Hf,"f")&&(Cp(this,Hf,"f").disconnect(),Tp(this,Hf,null,"f")),super.dispose()}createElement(){super.createElement(),this.element&&(this.element.setAttribute("scene","container"),this.onchangeButtons(),this.onchangeMinimized())}onchangeButtons(){if(!this.element)return;const{draggable:t,minimizable:e,closable:n,minimized:i,hidden:r}=this.state,{width:s}=this.bounds;this.element.style.setProperty("--container-width",`${s}px`);try{If(r?vf:bf`
|
|
25
25
|
<style>
|
|
26
26
|
[scene='container'] .buttons {
|
|
27
27
|
position: absolute;
|
|
@@ -63,11 +63,11 @@ const Kp=globalThis,Qp=t=>t,Zp=Kp.trustedTypes,Jp=Zp?Zp.createPolicy("lit-html",
|
|
|
63
63
|
|
|
64
64
|
<div class="buttons" @mousedown=${this.startDragging}>
|
|
65
65
|
<span></span>
|
|
66
|
-
${t?
|
|
67
|
-
${e?
|
|
66
|
+
${t?bf`<button class="draggable">drag_pan</button>`:vf}
|
|
67
|
+
${e?bf`<button class="minimizable" @click=${this.toggleMinimizable}>
|
|
68
68
|
${i?"crop_square":"minimize"}
|
|
69
|
-
</button>`:
|
|
70
|
-
${n?
|
|
69
|
+
</button>`:vf}
|
|
70
|
+
${n?bf`<button class="closable" @click=${this.closeContainer}>close</button>`:vf}
|
|
71
71
|
</div>
|
|
72
|
-
`,this.element)}catch(t){}}onchangeMinimized(){const{minimized:t}=this.state;t?this.setState("height",24):this.setState("height",this.get("height"))}}Nf=new WeakMap,Ga.memoize(Vf.prototype,"bounds",!0),Ga.register("container",Vf);const Uf=Math.sqrt(3),$f=2;function Wf(t,e,n,i,r){const s=5+r,o=n.x,a=n.y,c=i.x,l=i.y;if(Math.abs(o-c)>s&&Math.abs(a-l)>s){const n=(l-a)/(c-o),i=a-n*o;if(Math.abs(e-(n*t+i))>s)return!1}let h,d,u,p;return o>c?(d=o,h=c):(d=c,h=o),a>l?(p=a,u=l):(p=l,u=a),!(d+5<t)&&(!(h-5>t)&&(!(p+5<e)&&!(u-5>e)))}function Xf(t,e,n,i=2){for(let r=0;r<n.length-1;r++)if(Wf(t,e,n[r],n[r+1],i))return!0;return!1}function qf(t,e,n,i){if("arrow"!=t.slice(-5))return n;const r=Math.atan2(i.y-n.y,i.x-n.x),s=1.5*e;return{x:n.x+Math.cos(r)*s,y:n.y+Math.sin(r)*s}}function Kf(t,e,n){let{lineWidth:i=$f,strokeStyle:r="#000000",lineCap:s=!1,alpha:o=1,begin:a="none",end:c="none",beginSize:l="size5",endSize:h="size5"}=n;if(("none"!=a||"none"!=c)&&(i=Number(i)||$f,t.lineCap=s,t.lineWidth=i,t.strokeStyle=r,t.fillStyle=r,t.globalAlpha*=o,"none"!=a&&Qf(t,e[0],e[1],i,a,Zf(l,i)),"none"!=c)){const n=e.length;Qf(t,e[n-1],e[n-2],i,c,Zf(h,i))}}function Qf(t,e,n,i,r,s){const{x:o,y:a}=e,c=Math.atan2(n.y-a,n.x-o);switch(t.beginPath(),t.translate(o,a),t.rotate(c),r){case"oval":t.ellipse(0,0,s.X,s.Y,0,0,2*Math.PI),t.fill();break;case"diamond":t.moveTo(-s.X,0),t.lineTo(0,-s.Y),t.lineTo(s.X,0),t.lineTo(0,s.Y),t.fill();break;case"arrow":t.moveTo(0,0),t.lineTo(Uf*s.X,-s.Y),t.lineTo(Uf*s.X,s.Y),t.fill();break;case"sharp-arrow":t.moveTo(0,0),t.lineTo(Uf*s.X,-s.Y),t.lineTo(-s.X/1.5+Uf*s.X,0),t.lineTo(Uf*s.X,s.Y),t.fill();break;case"open-arrow":t.moveTo(Uf*s.X+i,-s.Y),t.lineTo(i,0),t.lineTo(Uf*s.X+i,s.Y),t.stroke();break;case"cross":t.moveTo(-s.X,-s.Y),t.lineTo(s.X,s.Y),t.moveTo(s.X,-s.Y),t.lineTo(-s.X,s.Y),t.stroke()}t.rotate(-c),t.translate(-o,-a),t.closePath()}function Zf(t,e){const n={X:0,Y:0};switch(e*=1.2,t){case"size1":n.X=e,n.Y=e;break;case"size2":n.X=1.5*e,n.Y=e;break;case"size3":n.X=2*e,n.Y=e;break;case"size4":n.X=e,n.Y=1.5*e;break;case"size5":default:n.X=1.5*e,n.Y=1.5*e;break;case"size6":n.X=2*e,n.Y=1.5*e;break;case"size7":n.X=e,n.Y=2*e;break;case"size8":n.X=1.5*e,n.Y=2*e;break;case"size9":n.X=2*e,n.Y=2*e}return n}const Jf="N",tg="S",eg="E",ng="W";class ig{constructor({component:t,anchor:e,position:n,self:i}){this.component=t,this._anchorName=e,this._position=n,this.self=i}get position(){const t=this.anchor;if(t){const{position:e}=t,n=this.component.toScene(e.x,e.y);return this.self.transcoordT2P(n.x,n.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 eg;const n=e.position;return n.y<=t.top?Jf:n.y>=t.top+t.height?tg:n.x<=t.left?ng:eg}get boundaryPosition(){const t=this.anchor;if(t){let{position:e}=t,n=0,i=0;switch(this.direction){case tg:i=20;break;case Jf:i=-20;break;case ng:n=-20;break;default:n=20}e={x:e.x+n,y:e.y+i};const r=this.component.toScene(e.x,e.y);return this.self.transcoordT2P(r.x,r.y)}}}class rg extends Ga{isLine(){return!0}is3dish(){return!0}replaceRefids(t){["from","to"].forEach(e=>{const n=this.get(e);if(n?.component){const i=t.get(n.component)||n.component;this.set(e,{...n,component:i})}})}get fromEnd(){if(this.parent&&!this._fromEnd){const{component:t,anchor:e,position:n}=this.getState("from")||{};if(!t)return;const i=this.root?.findByRefid?.(t);if(!i)return;this._fromEnd=new ig({component:i,fromto:"from",anchor:e,position:n,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:n}=this.getState("to")||{};if(!t)return;const i=this.root?.findByRefid?.(t);if(!i)return;this._toEnd=new ig({component:i,fromto:"to",anchor:e,position:n,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},n){n&&(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})}render(t){const{begin:e="none",end:n="none",lineWidth:i,round:r=0}=this.state;let s=this.drawPath;Kf(t,s,this.state),t.beginPath();const o=qf(e,i,s[0],s[1]),a=qf(n,i,s[s.length-1],s[s.length-2]);s=[o,...s.slice(1,-1),a];let c={x:o.x,y:o.y};t.moveTo(o.x,o.y);for(let e=1;e<s.length;e++){const n=c;c=s[e];const i=s[e+1];if(n.x===c.x&&n.y===c.y)continue;if(!i){t.lineTo(c.x,c.y);break}let o=Math.sqrt((n.x-c.x)*(n.x-c.x)+(n.y-c.y)*(n.y-c.y)),a=0!==o?Math.atan2(n.x-c.x,n.y-c.y):0,l=Math.sin(a)*Math.min(r,o/2)+c.x,h=Math.cos(a)*Math.min(r,o/2)+c.y;const d=r>0||0!==o?{x:l,y:h}:c;o=Math.sqrt((i.x-c.x)*(i.x-c.x)+(i.y-c.y)*(i.y-c.y)),a=0!==o?Math.atan2(i.x-c.x,i.y-c.y):0,l=Math.sin(a)*Math.min(r,o/2)+c.x,h=Math.cos(a)*Math.min(r,o/2)+c.y;const u=r>0||0!==o?{x:l,y:h}:c;t.lineTo(d.x,d.y),r>0&&t.quadraticCurveTo(c.x,c.y,u.x,u.y)}this.drawStroke(t,void 0)}contains(t,e){const{lineWidth:n}=this.state;return Xf(t,e,this.drawPath,n)}get resizable(){return!1}get mutable(){return!0}get rotatable(){return!1}get path(){const{from:t,to:e}=this.state,{x1:n,y1:i,x2:r,y2:s}=this.state;return[this.fromEnd?.position||t?.position||{x:n,y:i},this.toEnd?.position||e?.position||{x:r,y:s}]}set path(t){const[e,n]=t,{from:i,to:r}=this.state;delete this._fromEnd,delete this._toEnd,this.set({from:{...i,position:e},to:{...r,position:n}})}get textBounds(){const t=this.drawPath;let e,n,i=0;for(let r=1;r<t.length;r++){const s=t[r-1],o=t[r],a=(s.x-o.x)*(s.x-o.x)+(s.y-o.y)*(s.y-o.y);a>i&&(i=Math.ceil(a),e=s,n=o)}let{paddingTop:r,paddingLeft:s,paddingRight:o,paddingBottom:a}=this.state;return a||=0,r||=0,s||=0,o||=0,{left:Math.min(e.x,n.x)+s,top:Math.min(e.y,n.y)+r,width:Math.max(Math.abs(e.x-n.x)-s-o,0),height:Math.max(Math.abs(e.y-n.y)-r-a,0)}}get decorators(){return this.app.isEditMode?["decotag"]:[]}}rg.getTipNeckPos=qf,rg.containedInPath=Xf,rg.drawEndTips=Kf,Ga.register("line",rg);const sg={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 og extends(Vu(Va)){is3dish(){return!0}render(t){const{cx:e,cy:n,rx:i,ry:r,startAngle:s,endAngle:o,anticlockwise:a}=this.state;t.beginPath(),t.ellipse(e,n,Math.abs(i),Math.abs(r),0,s||0,o||2*Math.PI,a),void 0!==s&&void 0!==o&&(t.lineTo(e,n),t.closePath())}get path(){const{cx:t,cy:e,rx:n,ry:i}=this.state;return[{x:t-n,y:e-i},{x:t+n,y:e-i},{x:t+n,y:e+i},{x:t-n,y:e+i}]}set path(t){const e=t[0],n=t[2];this.set({cx:e.x+(n.x-e.x)/2,cy:e.y+(n.y-e.y)/2,rx:(n.x-e.x)/2,ry:(n.y-e.y)/2})}contains(t,e){const{cx:n,cy:i,rx:r,ry:s}=this.state,o=(t-n)/(2*r-.5),a=(e-i)/(2*s-.5);return o*o+a*a<.25}outline(t){return function(t,e){const{cx:n,cy:i,rx:r,ry:s}=t.model,o=2*Math.PI*e,a=n+r*Math.cos(o),c=i+s*Math.sin(o);return t.toScene(a,c)}(this,t)}get anchors(){return function(t){const{left:e,top:n,width:i,height:r}=t.bounds,s=e+i/2,o=n+r/2;return[{name:"TOP",position:{x:s,y:n}},{name:"RIGHT",position:{x:e+i,y:o}},{name:"BOTTOM",position:{x:s,y:n+r}},{name:"LEFT",position:{x:e,y:o}}]}(this)}get nature(){return sg}}Ga.memoize(og.prototype,"path",!1),Ga.register("ellipse",og);const ag={object:{fill:"rgba(180,180,180,0.18)",stroke:"#888888",icon:"?",label:"object"},transport:{fill:"rgba(100,180,255,0.18)",stroke:"#3a78c8",icon:"⇄",label:"transport"},facility:{fill:"rgba(160,140,220,0.18)",stroke:"#6b4ec8",icon:"◫",label:"facility"},vehicle:{fill:"rgba(120,200,140,0.18)",stroke:"#3a8c5e",icon:"⊙",label:"vehicle"},region:{fill:"rgba(220,200,100,0.18)",stroke:"#a0892a",icon:"▢",label:"region"},path:{fill:"rgba(200,140,160,0.18)",stroke:"#a0506a",icon:"⌐",label:"path"},"3d-asset":{fill:"rgba(255,180,80,0.18)",stroke:"#c87a2a",icon:"◈",label:"3D asset"}},cg=[{type:"string",label:"placeholder-label",name:"placeholderLabel",description:'사용자에게 표시할 추가 라벨 (예: "Stocker A1")'},{type:"string",label:"hint",name:"placeholderHint",description:"구체화 시 참고 — 도면의 원본 식별자 / VLM 라벨 등"}];function lg(t,e,n,i,r){const{left:s,top:o,width:a,height:c}=e,l=Math.max(a,1),h=Math.max(c,1);t.save(),t.fillStyle=n.fill,t.fillRect(s,o,l,h),t.strokeStyle=n.stroke,t.lineWidth=1.5,t.setLineDash([4,3]),t.strokeRect(s,o,l,h),t.setLineDash([]),t.restore(),Math.min(l,h)>=24&&(t.save(),t.fillStyle=n.stroke,t.font=`bold ${Math.min(20,.4*Math.min(l,h))}px Arial`,t.textAlign="center",t.textBaseline="middle",t.fillText(n.icon,s+l/2,o+h/2),t.restore());const d=i?`${n.label}: ${i}`:n.label;h>=32&&(t.save(),t.fillStyle=n.stroke,t.font="10px Arial",t.textAlign="center",t.textBaseline="bottom",t.fillText(d,s+l/2,o+h-4),t.restore()),r&&h>=40&&(t.save(),t.fillStyle=n.stroke,t.font="9px Arial",t.textAlign="right",t.textBaseline="top",t.fillText(`hint: ${r}`,s+l-4,o+4),t.restore())}const hg={mutable:!1,resizable:!0,rotatable:!0,properties:[...cg,{type:"placeholder-convert",label:"",name:"_convert"}],help:"scene/component/placeholder"};class dg extends($a(Va)){get nature(){return hg}render(t){const{placeholderLabel:e,placeholderHint:n}=this.state;lg(t,this.bounds,ag.object,e,n)}}Ga.register("placeholder",dg);const ug=["placeholder"];function pg(t,e=[]){return!!t&&(!!ug.includes(t)||e.includes(t))}const fg={ondragstart:function(t,e,n){n.mutatePath(null,function(n){n.splice(e+1,0,t)})},ondragmove:function(t,e,n){n.mutatePath(null,function(n){n[e+1]=t})},ondragend:function(t,e,n){}},gg={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 mg extends Va{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){const n=this.state.path;let i=!1;return n.forEach((r,s)=>{const o=(s+n.length+1)%n.length,a=r.x,c=r.y,l=n[o].x,h=n[o].y;c>e!=h>e&&t<(l-a)*(e-c)/(h-c)+a&&(i=!i)}),i}get controls(){const t=this.path;return t.map((e,n)=>{const i=t[n+1>=t.length?0:n+1];return{x:(e.x+i.x)/2,y:(e.y+i.y)/2,handler:fg}})}get nature(){return gg}}Ga.memoize(mg.prototype,"controls",!1),Ga.register("polygon",mg);const yg={ondragstart:function(t,e,n){n.mutatePath(null,function(n){n.splice(e,0,t)})},ondragmove:function(t,e,n){n.mutatePath(null,function(n){n[e]=t})},ondragend:function(t,e,n){}},bg={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 _g extends rg{get pathExtendable(){return!0}get path(){const{from:t,to:e}=this.state,{path:n}=this.state;return[this.fromEnd?.position||t?.position||n[0],...n.slice(1,-1),this.toEnd?.position||e?.position||n[n.length-1]]}set path(t){const{from:e,to:n}=this.state;delete this._fromEnd,delete this._toEnd,this.set({from:{...e,position:t[0]},to:{...n,position:t[t.length-1]},path:t})}get controls(){const t=this.path,e=[];for(let n=0;n<t.length-1;n++){const i=t[n],r=t[n+1];0==n&&e.push({x:i.x,y:i.y,handler:yg}),e.push({x:(i.x+r.x)/2,y:(i.y+r.y)/2,handler:yg}),n==t.length-2&&e.push({x:r.x,y:r.y,handler:yg})}return e}get nature(){return bg}}Ga.register("polyline",_g);const vg={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 xg extends rg{get pathExtendable(){return!1}get drawPath(){const t=this.path[0],e=this.path[1],{component:n,direction:i,boundaryPosition:r=t}=this.fromEnd||{},{component:s,direction:o,boundaryPosition:a=e}=this.toEnd||{},c=[r,a],l=[];r&&l.push(r);let h,d=n?.bounds;d&&(h=n.toScene(d.left,d.top),h=this.transcoordT2P(h.x,h.y),d={...d,left:h.x,top:h.y});const u=d?{left:d.left-20,top:d.top-20,width:d.width+40,height:d.height+40}:{left:r.x,top:r.y,width:0,height:0};d=d||u;let p=s?.bounds;p&&(h=s.toScene(p.left,p.top),h=this.transcoordT2P(h.x,h.y),p={...p,left:h.x,top:h.y});const f=p?{left:p.left-20,top:p.top-20,width:p.width+40,height:p.height+40}:{left:a.x,top:a.y,width:0,height:0};p=p||f;const g=[u,f],m=u.left>f.left?f.left:u.left,y=u.top>f.top?f.top:u.top,b={left:m,top:y,width:u.left+u.width>f.left+f.width?u.left+u.width-m:f.left+f.width-m,height:u.top+u.height>f.top+f.height?u.top+u.height-y:f.top+f.height-y};let _,v,x,w,M,S,A,E,k,C,T=0,P=0;d.left+d.width<p.left?(w=0,M=1,k=i,C=o,_=(d.left+d.width+p.left)/2,T=p.left-_):p.left+p.width<d.left&&(w=1,M=0,k=o,C=i,_=(d.left+p.width+p.left)/2,T=d.left-_),d.top+d.height<p.top?(x=0,S=1,A=i,E=o,v=(d.top+d.height+p.top)/2,P=p.top-v):p.top+p.height<d.top&&(x=1,S=0,A=o,E=i,v=(d.top+p.height+p.top)/2,P=d.top-v);const D=[];if(_&&T>P){let t,e,n;switch(C){case ng:switch(k){case eg:D.push({x:_,y:c[w].y}),D.push({x:_,y:c[M].y});break;case ng:t=g[w].top+g[w].height/2,e=t>c[M].y?Math.min(g[w].top,c[M].y):Math.max(g[w].top+g[w].height,c[M].y),D.push({x:c[w].x,y:e}),D.push({x:_,y:e}),D.push({x:_,y:c[M].y});break;case Jf:case tg:e=k===tg?Math.max(c[w].y,c[M].y):Math.min(c[w].y,c[M].y),D.push({x:c[w].x,y:e}),D.push({x:_,y:e}),D.push({x:_,y:c[M].y});break;default:return this.path}break;case eg:switch(k){case eg:e=c[w].y<c[M].y?Math.min(g[M].top,c[w].y):Math.max(g[M].top+g[M].height,c[w].y),n=e;break;case ng:e=void 0!==v?v:c[w].y<c[M].y?b.top-.5*T:b.top+b.height+.5*T,n=e;break;case tg:e=void 0!==v?Math.max(v,c[w].y):b.top+b.height,n=e;break;case Jf:e=v?Math.min(v,g[w].top):b.top,n=e;break;default:return this.path}D.push({x:c[w].x,y:e}),D.push({x:_,y:e}),D.push({x:_,y:n}),D.push({x:c[M].x,y:n});break;case tg:switch(k){case eg:e=c[w].y,n=c[w].y>c[M].y?c[w].y:g[M].top+g[M].height;break;case ng:e=v?Math.max(v,g[M].top+g[M].height):b.top+b.height,n=e;break;case tg:e=b.top+b.height,n=e;break;case Jf:e=v?Math.min(v,g[w].top):g[w].top,n=v?Math.max(v,g[M].top+g[M].height):g[M].top+g[M].height;break;default:return this.path}D.push({x:c[w].x,y:e}),D.push({x:_,y:e}),D.push({x:_,y:n}),D.push({x:c[M].x,y:n});break;case Jf:switch(k){case eg:e=c[w].y,n=c[w].y<c[M].y?c[w].y:g[M].top;break;case ng:e=v?Math.min(v,g[M].top):b.top,n=e;break;case tg:e=void 0!==v?Math.max(v,c[w].y):c[w].y,n=void 0!==v?Math.min(v,c[M].y):c[M].y;break;case Jf:e=b.top,n=e;break;default:return this.path}D.push({x:c[w].x,y:e}),D.push({x:_,y:e}),D.push({x:_,y:n}),D.push({x:c[M].x,y:n});break;default:return this.path}l.push(...0===w?D:D.reverse())}else if(v){let t,e,n;switch(E){case Jf:switch(A){case tg:D.push({x:c[x].x,y:v}),D.push({x:c[S].x,y:v});break;case Jf:t=g[x].left+g[x].width/2,e=t>c[S].x?Math.min(g[x].left,c[S].x):Math.max(g[x].left+g[x].width,c[S].x),D.push({x:e,y:c[x].y}),D.push({x:e,y:v}),D.push({x:c[S].x,y:v});break;case ng:e=Math.min(c[x].x,c[S].x),D.push({x:e,y:c[x].y}),D.push({x:e,y:v}),D.push({x:c[S].x,y:v});break;case eg:e=Math.max(c[x].x,c[S].x),D.push({x:e,y:c[x].y}),D.push({x:e,y:v}),D.push({x:c[S].x,y:v});break;default:return this.path}break;case tg:switch(A){case ng:e=b.left,n=e;break;case eg:e=void 0!==_?Math.max(_,c[x].x):b.left+b.width,n=e;break;case Jf:e=void 0!==_?_:c[x].x<c[S].x?b.left-.5*P:b.left+b.width+.5*P,n=e;break;case tg:e=c[x].x,n=c[x].x<c[S].x?Math.min(g[S].left,c[x].x):Math.max(g[S].left+g[S].width,c[x].x);break;default:return this.path}D.push({x:e,y:c[x].y}),D.push({x:e,y:v}),D.push({x:n,y:v}),D.push({x:n,y:c[S].y});break;case eg:switch(A){case ng:e=void 0!==_?Math.min(_,c[x].x):c[x].x,n=void 0!==_?Math.max(_,c[S].x):c[S].x;break;case eg:e=b.left+b.width,n=e;break;case Jf:e=void 0!==_?Math.max(_,c[S].x):b.left+b.width,n=e;break;case tg:e=c[x].x,n=Math.max(g[S].left+g[S].width,c[x].x);break;default:return this.path}D.push({x:e,y:c[x].y}),D.push({x:e,y:v}),D.push({x:n,y:v}),D.push({x:n,y:c[S].y});break;case ng:switch(A){case ng:e=b.left,n=e;break;case eg:e=void 0!==_?Math.max(_,c[x].x):c[x].x,n=void 0!==_?Math.min(_,c[S].x):c[S].x;break;case Jf:e=b.left,n=e;break;case tg:e=c[x].x<c[S].x?Math.min(g[S].left,c[x].x):c[x].x,n=Math.min(e,c[S].x);break;default:return this.path}D.push({x:e,y:c[x].y}),D.push({x:e,y:v}),D.push({x:n,y:v}),D.push({x:n,y:c[S].y});break;default:return this.path}l.push(...0===x?D:D.reverse())}else{let t,e;switch(i){case Jf:switch(o){case Jf:e=b.top,l.push({x:c[0].x,y:e}),l.push({x:c[1].x,y:e});break;case tg:t=b.left+b.width,l.push({x:t,y:c[0].y}),l.push({x:t,y:b.top+b.height}),l.push({x:c[1].x,y:b.top+b.height});break;case eg:t=c[1].y<c[0].y&&c[1].x<c[0].x?c[0].x:b.left+b.width,l.push({x:t,y:c[0].y}),l.push({x:t,y:c[1].y});break;case ng:t=b.left,l.push({x:t,y:c[0].y}),l.push({x:t,y:c[1].y});break;default:return this.path}break;case tg:switch(o){case Jf:t=b.left+b.width,l.push({x:t,y:c[0].y}),l.push({x:t,y:b.top}),l.push({x:c[1].x,y:b.top});break;case tg:case eg:case ng:e=b.top+b.height,l.push({x:c[0].x,y:e}),l.push({x:c[1].x,y:e});break;default:return this.path}break;case ng:switch(o){case Jf:t=c[0].x>c[1].x&&c[0].y<c[1].y?c[1].x:b.left,e=c[0].x>c[1].x&&c[0].y<c[1].y?c[1].y:Math.min(b.top,c[0].y),l.push({x:t,y:c[0].y}),l.push({x:t,y:e}),l.push({x:c[1].x,y:e});break;case tg:t=b.left,e=Math.max(b.top+b.height,c[0].y),l.push({x:t,y:c[0].y}),l.push({x:t,y:e}),l.push({x:c[1].x,y:e});break;case eg:t=b.left+b.width,l.push({x:c[0].x,y:b.top}),l.push({x:t,y:b.top}),l.push({x:t,y:c[1].y});break;case ng:t=b.left,l.push({x:t,y:c[0].y}),l.push({x:t,y:c[1].y});break;default:return this.path}break;case eg:switch(o){case Jf:e=c[0].y<c[1].y&&c[0].x<c[1].x?c[0].y:b.top,l.push({x:c[0].x,y:e}),l.push({x:c[1].x,y:e});break;case tg:e=c[0].y>c[1].y&&c[0].x<c[1].x?c[0].y:b.top+b.height,l.push({x:c[0].x,y:e}),l.push({x:c[1].x,y:e});break;case eg:case ng:e=b.top+b.height,l.push({x:c[0].x,y:e}),l.push({x:c[1].x,y:e});break;default:return this.path}break;default:return this.path}}return a&&l.push(a),[t,...l,e].filter((t,e,n)=>{if(0===e)return!0;const i=n[e-1];return t.x!==i.x||t.y!==i.y}).filter((t,e,n)=>{if(0===e||e>=n.length-1)return!0;const i=n[e-1],r=n[e+1];return!(t.x===i.x&&t.x===r.x||t.y===i.y&&t.y===r.y)})}get nature(){return vg}}Ga.register("ortholine",xg);const wg={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 Mg extends($a(Va)){static get noimage(){return Mg.NOIMAGE||(Mg.NOIMAGE=new Image,Mg.NOIMAGE.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAABIBAMAAAD7Se1QAAAAIVBMVEUAAABHcEwBAQEREREBAQEEBAQGBgYLCwsDAwMDAwMICAi6HF9tAAAAC3RSTlNNAEAERiMYCS41Eac10lYAAAEgSURBVHhe7dY9asQwEAXgh7DNertNiJy48pIitY3SB7bYdk0ukL1BDDmA9gZecoH4pmFQ3MQayUMguPBrNPD4wD9TCMvJmt3M/AtYwXOlXiWgqADVCUBD46MAnGhMBaCiUQmAm8VA/Eh/eWl9Fn5WcxD+OLuRrUYJDKLluwH2InACUgkoACSdADxQc50Bytadb9RkM0CT13TcvlCT1HFg8UTHvasuUVACCa3El6u2UdD8LFTlKhUFFgA+d3dj10aABkUN72N3jAADCrJq7PIIsPidcxBoTHIIAjMFmyCwmGYIAA1P9gFgfCANAOsDSccCDW+uLDB+kLGg94OkZoAGkwsDDAe2DOg5oPxAg03rBR88OHpBz4N8UVeHFSwma74BTW6Ge4rIRa4AAAAASUVORK5CYII="),Mg.NOIMAGE}dispose(){super.dispose(),this._offcanvas=null,this._image=null}render(t){const{left:e,top:n,width:i,height:r,isGray:s=!1,alpha:o=1,src:a}=this.state;if(this.prepareIf(!this._image&&a),t.beginPath(),t.globalAlpha*=o,this._image&&this._image.complete)if(s&&this._offcanvas)t.drawImage(this._offcanvas,e,n,i,r);else try{t.drawImage(this._image,e,n,i,r)}catch(s){t.drawImage(Mg.noimage,e,n,i,r)}else!this.app.isViewMode&&t.drawImage(Mg.noimage,e,n,i,r)}get nature(){return wg}get hasTextProperty(){return!1}async ready(){await super.ready();const{src:t}=this.state;if(!this._image&&t){const e=this.root?.app?.loadTracker;if(e){const n=new Promise((t,e)=>{this.prepare(()=>t(),t=>e(t))});e.track(`image:${t}`,"image",t,n)}else this.prepareIf(!0)}}prepare(t,e){const{src:n,crossOrigin:i}=this.state;if(n){this._image=new Image;try{i&&(this._image.crossOrigin=i),this._image.src=this.app.url(n)||""}catch(t){return void e(t)}this._image.onload=()=>{if(this.get("isGray")){const t=this._image.width,e=this._image.height;this._offcanvas=Ga.createCanvas(t,e);const n=this._offcanvas.getContext("2d");n.drawImage(this._image,0,0);const i=function(t,e,n){let i;try{i=t.getImageData(0,0,e,n)}catch(t){return ji("Get Image Data Error: "+(t instanceof Error?t.message:String(t))),null}const r=i.data;for(let t=0;t<e*n*4;t+=4){const e=r[t],n=r[t+1],s=r[t+2],o=Math.floor((e+n+s)/3);i.data[t]=o,i.data[t+1]=o,i.data[t+2]=o}return i}(n,t,e);n.putImageData(i,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 n=0;n<t.length;n++)if(t[n].type.startsWith("image/"))return void(this.src=e[n])}}Ga.register("image-view",Mg);class Sg extends(Bf($a(Ga))){is3dish(){return!0}prerender(){}}var Ag,Eg,kg={},Cg={},Tg={};function Pg(){if(Eg)return Cg;Eg=1,Object.defineProperty(Cg,"__esModule",{value:!0});var t=function(){if(Ag)return Tg;Ag=1,Object.defineProperty(Tg,"__esModule",{value:!0});var t=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=[],n=7;n>=0;n--)e.push(!!(t&1<<n));return e},t.lzwDecode=function(t,e){for(var n,i,r=0,s=function(t){for(var n=0,i=0;i<t;i++)e.charCodeAt(r>>3)&1<<(7&r)&&(n|=1<<i),r++;return n},o=[],a=1<<t,c=a+1,l=t+1,h=[],d=function(){h=[],l=t+1;for(var e=0;e<a;e++)h[e]=[e];h[a]=[],h[c]=null};;)if(i=n,(n=s(l))!==a){if(n===c)break;if(n<h.length)i!==a&&h.push(h[i].concat(h[n][0]));else{if(n!==h.length)throw new Error("Invalid LZW code.");h.push(h[i].concat(h[i][0]))}o.push.apply(o,h[n]),h.length===1<<l&&l<12&&l++}else d();return o},t}();return Tg.SuperGifUtils=t,Tg}(),e=function(){function e(t,e){this.stream=t,this.handler=e}return e.prototype.parseCT=function(t){for(var e=[],n=0;n<t;n++)e.push(this.stream.readBytes(3));return e},e.prototype.readSubBlocks=function(){var t,e;e="";do{t=this.stream.readByte(),e+=this.stream.read(t)}while(0!==t);return e},e.prototype.parseHeader=function(){var e={};if(e.sig=this.stream.read(3),e.ver=this.stream.read(3),"GIF"!==e.sig)throw new Error("Not a GIF file.");e.width=this.stream.readUnsigned(),e.height=this.stream.readUnsigned();var n=t.SuperGifUtils.byteToBitArr(this.stream.readByte());e.gctFlag=n.shift(),e.colorRes=t.SuperGifUtils.bitsToNum(n.splice(0,3)),e.sorted=n.shift(),e.gctSize=t.SuperGifUtils.bitsToNum(n.splice(0,3)),e.bgColor=this.stream.readByte(),e.pixelAspectRatio=this.stream.readByte(),e.gctFlag&&(e.gct=this.parseCT(1<<e.gctSize+1)),this.handler.hdr&&this.handler.hdr(e)},e.prototype.parseExt=function(e){var n=this;switch(e.label=this.stream.readByte(),e.label){case 249:e.extType="gce",function(e){n.stream.readByte();var i=t.SuperGifUtils.byteToBitArr(n.stream.readByte());e.reserved=i.splice(0,3),e.disposalMethod=t.SuperGifUtils.bitsToNum(i.splice(0,3)),e.userInput=i.shift(),e.transparencyGiven=i.shift(),e.delayTime=n.stream.readUnsigned(),e.transparencyIndex=n.stream.readByte(),e.terminator=n.stream.readByte(),n.handler.gce&&n.handler.gce(e)}(e);break;case 254:e.extType="com",function(t){t.comment=n.readSubBlocks(),n.handler.com&&n.handler.com(t)}(e);break;case 1:e.extType="pte",function(t){n.stream.readByte(),t.ptHeader=n.stream.readBytes(12),t.ptData=n.readSubBlocks(),n.handler.pte&&n.handler.pte(t)}(e);break;case 255:e.extType="app",function(t){n.stream.readByte(),t.identifier=n.stream.read(8),t.authCode=n.stream.read(3),"NETSCAPE"===t.identifier?function(t){n.stream.readByte(),t.unknown=n.stream.readByte(),t.iterations=n.stream.readUnsigned(),t.terminator=n.stream.readByte(),n.handler.app&&n.handler.app.NETSCAPE&&n.handler.app.NETSCAPE(t)}(t):function(t){t.appData=n.readSubBlocks(),n.handler.app&&n.handler.app[t.identifier]&&n.handler.app[t.identifier](t)}(t)}(e);break;default:e.extType="unknown",function(t){t.data=n.readSubBlocks(),n.handler.unknown&&n.handler.unknown(t)}(e)}},e.prototype.parseImg=function(e){e.leftPos=this.stream.readUnsigned(),e.topPos=this.stream.readUnsigned(),e.width=this.stream.readUnsigned(),e.height=this.stream.readUnsigned();var n=t.SuperGifUtils.byteToBitArr(this.stream.readByte());e.lctFlag=n.shift(),e.interlaced=n.shift(),e.sorted=n.shift(),e.reserved=n.splice(0,2),e.lctSize=t.SuperGifUtils.bitsToNum(n.splice(0,3)),e.lctFlag&&(e.lct=this.parseCT(1<<e.lctSize+1)),e.lzwMinCodeSize=this.stream.readByte();var i=this.readSubBlocks();e.pixels=t.SuperGifUtils.lzwDecode(e.lzwMinCodeSize,i),e.interlaced&&(e.pixels=function(t,e){for(var n=new Array(t.length),i=t.length/e,r=function(i,r){var s=t.slice(r*e,(r+1)*e);n.splice.apply(n,[i*e,e].concat(s))},s=[0,4,2,1],o=[8,8,4,2],a=0,c=0;c<4;c++)for(var l=s[c];l<i;l+=o[c])r(l,a),a++;return n}(e.pixels,e.width)),this.handler.img&&this.handler.img(e)},e.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)},e.prototype.parse=function(){this.parseHeader(),setTimeout(this.parseBlock.bind(this),0)},e}();return Cg.SuperGifParser=e,Cg}var Dg,Og,zg={};var Lg=function(){if(Og)return kg;Og=1,Object.defineProperty(kg,"__esModule",{value:!0});var t=Pg(),e=function(){if(Dg)return zg;Dg=1,Object.defineProperty(zg,"__esModule",{value:!0});var t=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=[],n=0;n<t;n++)e.push(this.readByte());return e},t.prototype.read=function(t){for(var e="",n=0;n<t;n++)e+=String.fromCharCode(this.readByte());return e},t.prototype.readUnsigned=function(){var t=this.readBytes(2);return(t[1]<<8)+t[0]},t}();return zg.SuperGifStream=t,zg}(),n=function(){function n(t,e){var n=this;for(var i 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(){n.pushFrame(),n.canvas.width=n.hdr.width*n.getCanvasScale(),n.canvas.height=n.hdr.height*n.getCanvasScale(),n.playerInit(),n.loading=!1,n.ready=!0,n.loadCallback&&n.loadCallback(n.gifImgElement)}},e)this.options[i]=e[i];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 n.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},n.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)},n.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)},n.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)}},n.prototype.step=function(){this.stepping||setTimeout(this.doStep.bind(this),0)},n.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)},n.prototype.playerInit=function(){this.loadErrorCause||(this.canvasContext.scale(this.getCanvasScale(),this.getCanvasScale()),this.options.autoPlay?this.step():(this.currentFrameIndex=0,this.putFrame()))},n.prototype.clear=function(){this.transparency=null,this.delay=null,this.lastDisposalMethod=this.disposalMethod,this.disposalMethod=null,this.frame=null},n.prototype.parseStream=function(e){try{new t.SuperGifParser(e,this.handler).parse()}catch(t){this.handleError("parse")}},n.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)},n.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()},n.prototype.handleError=function(t){this.loadErrorCause=t,this.hdr={width:this.gifImgElement.width,height:this.gifImgElement.height},this.frames=[],this.drawError()},n.prototype.doHdr=function(t){this.hdr=t,this.setSizes(this.hdr.width,this.hdr.height)},n.prototype.doGCE=function(t){this.pushFrame(),this.clear(),this.transparency=t.transparencyGiven?t.transparencyIndex:null,this.delay=t.delayTime,this.disposalMethod=t.disposalMethod},n.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}))},n.prototype.doImg=function(t){var e=this;this.frame||(this.frame=this.tmpCanvas.getContext("2d"));var n=this.frames.length,i=t.lctFlag?t.lct:this.hdr.gct;n>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=n-1,2===this.lastDisposalMethod&&this.frame.clearRect(this.lastImg.leftPos,this.lastImg.topPos,this.lastImg.width,this.lastImg.height));var r=this.frame.getImageData(t.leftPos,t.topPos,t.width,t.height);t.pixels.forEach(function(t,n){t!==e.transparency&&(r.data[4*n+0]=i[t][0],r.data[4*n+1]=i[t][1],r.data[4*n+2]=i[t][2],r.data[4*n+3]=255)}),this.frame.putImageData(r,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},n.prototype.doNothing=function(){},n.prototype.withProgress=function(t){return function(e){t(e)}},n.prototype.getNextFrameNo=function(){var t=this.forward?1:-1;return(this.currentFrameIndex+t+this.frames.length)%this.frames.length},n.prototype.stepFrame=function(t){this.currentFrameIndex=this.currentFrameIndex+t,this.putFrame()},n.prototype.getCanvasScale=function(){return this.options.maxWidth&&this.hdr&&this.hdr.width>this.options.maxWidth?this.options.maxWidth/this.hdr.width:window.devicePixelRatio||1},n.prototype.play=function(){this.playing=!0,this.step()},n.prototype.pause=function(){this.playing=!1},n.prototype.isPlaying=function(){return this.playing},n.prototype.getCanvas=function(){return this.canvas},n.prototype.isLoading=function(){return this.loading},n.prototype.isReady=function(){return this.ready},n.prototype.isAutoPlay=function(){return this.options.autoPlay},n.prototype.getLength=function(){return this.frames.length},n.prototype.getCurrentFrame=function(){return this.currentFrameIndex},n.prototype.moveTo=function(t){this.currentFrameIndex=t,this.putFrame()},n.prototype.loadURL=function(t,n){var i=this;if(this.loadSetup(n)){var r=new XMLHttpRequest;r.open("GET",t,!0),"overrideMimeType"in r?r.overrideMimeType("text/plain; charset=x-user-defined"):"responseType"in r?r.responseType="arraybuffer":r.setRequestHeader("Accept-Charset","x-user-defined"),r.onloadstart=function(){i.initialized||i.init()},r.onload=function(){if(200===r.status){var t=r.response;t.toString().indexOf("ArrayBuffer")>0&&(t=new Uint8Array(t));var n=new e.SuperGifStream(t);setTimeout(function(){i.parseStream(n)},0)}else i.handleError("xhr - response")},r.onerror=function(){i.handleError("xhr")},r.send()}},n.prototype.load=function(t){this.loadURL(this.gifImgElement.src,t)},n}();return kg.SuperGif=n,kg}();const Ig={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 Rg extends Sg{async oncreate_element(t){const{src:e,play:n}=this.state;this.onchangesrc(e),this.onchangeplay(n)}buildImg(){const t=this.element;if(!t)return document.createElement("img");t.replaceChildren();const 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){const e=this._superGif;e&&e.isReady()&&(t?e.play():e.pause())}onchangesrc(t){const 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",String(0)),this._superGif=new Lg.SuperGif(e,{autoPlay:!1}),this._superGif.init(),this.element&&Array.from(this.element.children).forEach(t=>{t.style.width="100%",t.style.height="100%"});const n=this._superGif.getCanvas();n.style.width="100%",n.style.height="100%",this._superGif.load(()=>{setTimeout(()=>{this._superGif.moveTo(0),this.play&&this._superGif.play()},100)})}ondropfile(t,e){for(let n=0;n<t.length;n++)if(/\.gif$/.test(t[n].name))return void(this.src=e[n])}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 Ig}get tagName(){return"div"}}Ga.register("gif-view",Rg);const jg={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 Fg extends($a(Va)){static get image(){return Fg.IMAGE||(Fg.IMAGE=new Image,Fg.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="),Fg.IMAGE}dispose(){super.dispose(),this.started=!1,delete this._audio}async ready(){super.ready(),this._audio=new Audio;const{src:t="",loop:e=!1,started:n=!1}=this.state;if(t){const e=this.root?.app?.loadTracker;if(e){const n=new Promise((e,n)=>{this._audio.addEventListener("canplay",()=>e(),{once:!0}),this._audio.addEventListener("error",()=>n(new Error(`Audio load failed: ${t}`)),{once:!0})});e.track(`audio:${t}`,"audio",t,n)}}this._audio.addEventListener("canplay",()=>{this.started&&this._audio.play()}),this.onchangeSrc(t),this.onchangeLoop(e),this.onchangeStarted(n)}render(t){const{left:e,top:n,width:i,height:r}=this.state;t.beginPath(),this.drawImage(t,Fg.image,e,n,i,r)}get nature(){return jg}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 ji(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 n=0;n<t.length;n++)if(t[n].type.startsWith("audio/"))return void(this.src=e[n])}}Ga.register("audio",Fg);class Bg extends($a(Ga)){is3dish(){return!0}}Ga.register("text",Bg);const Ng=["refid","left","top","width","height","rotation","animation","zPos"];class Hg extends Vf{isGroup(){return!0}is3dish(){return!0}get(t){return this._model[t]}set(t,e){if("string"==typeof t)return this.set({[t]:e});const n=Ng.reduce((e,n)=>(t.hasOwnProperty(n)&&(e[n]=t[n]),e),{});return super.set(n,void 0)}capture(t,e,n){const i=super.capture(t,e,n);if(i!==this)return i}set bounds(t){if(this.__MUTATING__)return void(super.bounds=t);const e=this.bounds,n=t.width/e.width,i=t.height/e.height;this.path=this.path.map(r=>({x:t.left+(r.x-e.left)*n,y:t.top+(r.y-e.top)*i})),this.components&&this.components.forEach(t=>{if(t.mutable)t.mutatePath(null,function(t){return t.map(function(t){return{x:t.x*n,y:t.y*i}})});else{const e=t.bounds,r=t.center,s={x:r.x*(1-n),y:r.y*(1-i)},o=e.width*(1-n),a=e.height*(1-i),c=-(s.x-o/2),l=-(s.y-a/2);t.bounds={left:e.left+c,top:e.top+l,width:e.width*n,height:e.height*i}}})}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){const e=Ga.union(this.components.map(t=>t.bounds));return this.components.forEach(t=>{const n=t.bounds;t.bounds={left:n.left-e.left,top:n.top-e.top,width:n.width,height:n.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){const{top:e,left:n}=this.state;t.translate(n,e),this.layout.drawables(this).forEach(e=>{e.draw(t)}),t.translate(-n,-e)}}Ga.memoize(Hg.prototype,"bounds",!0),Ga.register("group",Hg);const Yg={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 Gg extends($a(Va)){get ref(){const t=this.getState("ref");return t&&"string"==typeof t?this.root.findById?.(t):null}set ref(t){this.setState("ref",t)}get refScale(){const t=this.ref;if(!t)return{x:1,y:1};const e=t.bounds,n=this.bounds,i=n.width/e.width,r=n.height/e.height;return"both"===this.model.fit?{x:i,y:r}:{x:Math.min(i,r),y:Math.min(i,r)}}draw(t){this._drawing||(this._drawing=!0,super.draw(t),this._drawing=!1)}prerender(t){if(super.prerender(t),this.ref){const e=this.ref.center,n=this.center,i=this.refScale;t.translate(n.x,n.y),t.scale(i.x,i.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);const{left:e,top:n,width:i,height:r}=this.bounds;t.beginPath(),t.rect(e,n,i,r)}get nature(){return Yg}get hasTextProperty(){return!1}}Ga.memoize(Gg.prototype,"ref",!1),Ga.memoize(Gg.prototype,"refScale",!1),Ga.register("local-ref",Gg);class Vg extends(Bf(Qc)){render(t){}is3dish(){return!0}get layout(){return Za.get(this.get("layout"))||Ja}}const Ug={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 $g extends Vg{dispose(){this._releaseRef(),super.dispose()}get nature(){return Ug}get hasTextProperty(){return!1}get tagName(){return"div"}setElementProperties(t){const{mode:e="view",round:n=0}=this.state;t.style.pointerEvents="view"==e?"none":"inherit",t.style.borderRadius=n+"px"}async ready(){super.ready(),this.fetchRef()}reposition(){if(!this.element)return;super.reposition();const t=this._element_bounds,{offsetWidth:e,offsetHeight:n}=this.element;if(this._element_bounds={offsetWidth:e,offsetHeight:n},(!t||t.offsetWidth!=e||t.offsetHeight!=n)&&this.ref&&this.root.target_element){const{fit:t="ratio"}=this.state;this.ref.fit(t)}}async fetchRef(){this._releaseRef();const{ref:t,fit:e="ratio"}=this.state;if(!t)return;const n=this.app.refProvider;if(n&&t){const i=(async()=>{this.__ref=await n.get(t,!0),this.__ref.target=this.element,this.__ref.fit(e),this.__ref.data=this.data})();this.root?.app?.loadTracker?.track(`ref:${t}`,"ref-board",t,i);try{await i}catch(t){ji(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,n){super.onchange(t,e),"ref"in t&&this.fetchRef(),"fit"in t&&this.ref&&requestAnimationFrame(()=>{const{fit:t}=this.state;this.ref.fit(t)}),"data"in t&&this.ref&&requestAnimationFrame(()=>{this.ref.data=t.data})}}Ga.register("global-ref",$g);const Wg="center-middle",Xg={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:"popup-position",name:"popupPosition",property:{options:["static","absolute"]}},{type:"select",label:"popup-origin",name:"origin",property:{options:["left-top","center-top","right-top","left-middle",Wg,"right-middle","left-bottom","center-bottom","right-bottom","auto"]}},{type:"string",label:"title",name:"text"},{type:"data",label:"value",name:"value"},{type:"string",label:"container-ref",name:"containerRef",placeholder:"PopupContainer id (same board)"},{type:"textarea",label:"html-template",name:"htmlTemplate",property:{language:"html"}},{type:"string",label:"anchor-ref",name:"anchorRef",placeholder:"component id (3D-tracked anchor)"},{type:"select",label:"anchor-pin",name:"anchorPin",property:{options:[{display:"Top",value:"top"},{display:"Center",value:"center"},{display:"Bottom",value:"bottom"}]}},{type:"number",label:"anchor-offset-x",name:"anchorOffsetX"},{type:"number",label:"anchor-offset-y",name:"anchorOffsetY"},{type:"number",label:"anchor-offset-z",name:"anchorOffsetZ"},{type:"checkbox",label:"constant-size",name:"constantSize"},{type:"checkbox",label:"tether",name:"tether"},{type:"select",label:"off-screen",name:"offScreen",property:{options:[{display:"Hide",value:"hide"},{display:"Edge-pin",value:"edge-pin"},{display:"Keep last",value:"keep-last"}]}}],help:"scene/component/popup"};class qg extends($a(Va)){static get image(){return qg._image||(qg._image=new Image,qg._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"),qg._image}async ready(){await super.ready(),this.show&&this.onchangeShow(!0)}render(t){const{left:e,top:n,width:i,height:r}=this.bounds;t.beginPath(),this.drawImage(t,qg.image,e,n,i,r)}onchange(t,e){"value"in t?this.show?this.onchangeShow(!0):this.show=!0:"show"in t&&this.onchangeShow(this.show)}onchangeShow(t){if(this.app.isEditMode)return;(this.getState("board")||this.getState("containerRef")||this.getState("htmlTemplate"))&&(t?this.openPopup(this.value):this.hidePopup())}openPopup(t,e){if(this.app.isEditMode)return;const n=this.getState("anchorRef"),i=n&&this.rootModel?.findById?this.rootModel.findById(n):void 0;wd.show(this,this.getState("board"),{origin:this.getState("origin")||Wg,modal:this.getState("modal"),closable:this.getState("closable")||!1,draggable:this.getState("draggable")||!1,minimizable:this.getState("minimizable")||!1,popupPosition:this.getState("popupPosition"),title:this.text,data:t||this.value,containerRef:this.getState("containerRef"),htmlTemplate:this.getState("htmlTemplate"),anchor:i,anchorPin:this.getState("anchorPin")||"top",anchorOffsetX:this.getState("anchorOffsetX")??0,anchorOffsetY:this.getState("anchorOffsetY")??0,anchorOffsetZ:this.getState("anchorOffsetZ")??0,constantSize:this.getState("constantSize")??!0,tether:this.getState("tether")??!1,offScreen:this.getState("offScreen")||"hide",...e})}hidePopup(){wd.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 Xg}}Ga.register("popup",qg);const Kg={mutable:!1,resizable:!0,rotatable:!1,properties:[{type:"layout",label:"layout",name:"layoutOption"},{type:"checkbox",label:"constant-size",name:"constantSize"},{type:"checkbox",label:"billboard",name:"billboard"},{type:"checkbox",label:"tether",name:"tether"},{type:"select",label:"off-screen",name:"offScreen",property:{options:[{display:"Hide",value:"hide"},{display:"Edge-pin",value:"edge-pin"},{display:"Keep last",value:"keep-last"}]}}],help:"scene/component/popup-container"};class Qg extends Vf{get nature(){return Kg}isPopupContainer(){return!0}}Ga.register("popup-container",Qg);class Zg extends Ga{render(t){const{path:e=[]}=this.state;if(!(e.length<=1)){t.beginPath(),t.moveTo(e[0].x,e[0].y);for(let n=1;n<e.length;n++)t.lineTo(e[n].x,e[n].y);t.closePath(),this.drawStroke(t,void 0)}}get path(){return this.model.path}set path(t){this.set("path",t)}contains(t,e){const n=this.state.path;let i=!1;return n.forEach((r,s)=>{const o=(s+n.length+1)%n.length,a=r.x,c=r.y,l=n[o].x,h=n[o].y;c>e!=h>e&&t<(l-a)*(e-c)/(h-c)+a&&(i=!i)}),i}}Ga.register("path",Zg);const Jg={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 tm extends Va{is3dish(){return!0}contains(t,e){const{x1:n,y1:i,x2:r,y2:s,x3:o,y3:a}=this.state,c=[n,i,r,s,o,a];let l=!1;for(let n=0;n<c.length;n+=2){const i=(n+2)%c.length,r=c[n],s=c[n+1],o=c[i+1];s>e!=o>e&&t<(c[i]-r)*(e-s)/(o-s)+r&&(l=!l)}return l}get mutable(){return!0}get path(){const{x1:t,y1:e,x2:n,y2:i,x3:r,y3:s}=this.state;return[{x:t,y:e},{x:n,y:i},{x:r,y:s}]}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 Jg}}Ga.memoize(tm.prototype,"path",!1),Ga.register("triangle",tm);const em={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"number",label:"ratio",name:"ratio",property:"ratio"}],help:"scene/component/donut"},nm={ondragmove:function(t,e,n){let{cx:i,rx:r}=n.model;r=Math.abs(r);let s=(n.fromParent(t.x,t.y).x-i)/r*100;s=s>=100||s<=-100?100:Math.abs(s),n.set({ratio:s})}};class im extends og{is3dish(){return!0}render(t){let{ratio:e=50,cx:n,cy:i,rx:r,ry:s,startAngle:o,endAngle:a,anticlockwise:c}=this.state;r=Math.abs(r),s=Math.abs(s),t.beginPath(),t.ellipse(n,i,r,s,0,o||0,a||2*Math.PI,c),t.moveTo(n+r/100*e,i),t.ellipse(n,i,r/100*e,s/100*e,0,o||0,a||2*Math.PI,!0)}contains(t,e){let{cx:n,cy:i,rx:r,ry:s,ratio:o}=this.state;r=Math.abs(r),s=Math.abs(s);const a=(t-n)/(2*r-.5),c=(e-i)/(2*s-.5),l=(t-n)/(r/100*o*2-.5),h=(e-i)/(s/100*o*2-.5);let d=!1;return a*a+c*c<.25&&l*l+h*h>.25&&(d=!d),d}get controls(){let{cx:t,cy:e,rx:n,ratio:i}=this.state;return n=Math.abs(n),[{x:t+n/100*i,y:e,handler:nm}]}get nature(){return em}}Ga.memoize(im.prototype,"controls",!1),Ga.register("donut",im);const rm={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"},sm={ondragmove:function(t,e,n){const{cy:i,ry:r}=n.model;let s=(n.fromParent(t.x,t.y).y-i)/r*100+100;s>=100?s=100:s<=0&&(s=0),n.set({ratio:s})}};class om extends og{is3dish(){return!0}render(t){const{ratio:e=30,wing:n=5,cx:i,cy:r,rx:s,ry:o}=this.state;if(n<3)return;const a=1.5707963267948966,c=2*Math.PI/n,l=s-e/100*s,h=o-e/100*o;t.save(),t.beginPath(),t.translate(i,r),t.moveTo(s*Math.cos(-a),o*Math.sin(-a)),t.lineTo((s-l)*(Math.cos(c-a)+Math.cos(0-a))/2,(o-h)*(Math.sin(c-a)+Math.sin(0-a))/2);for(let e=1;e<n;e++)t.lineTo(s*Math.cos(c*e-a),o*Math.sin(c*e-a)),t.lineTo((s-l)*(Math.cos(c*(e+1)-a)+Math.cos(c*e-a))/2,(o-h)*(Math.sin(c*(e+1)-a)+Math.sin(c*e-a))/2);t.closePath(),t.restore()}get controls(){const{cx:t,cy:e,ry:n,ratio:i}=this.state;return[{x:t,y:e-n+n*(i/100),handler:sm}]}get nature(){return rm}}Ga.memoize(om.prototype,"controls",!1),Ga.register("star",om);const am={mutable:!1,resizable:!1,rotatable:!1,properties:[]};class cm extends(Vu(Va)){is3dish(){return!1}isDescendible(){return!1}render(t){const{cx:e,cy:n,anticlockwise:i}=this.state,r=this.app?.scale||1;t.beginPath(),t.scale(1/r,1/r),t.ellipse(e,n,Math.abs(cm.RADIUS),Math.abs(cm.RADIUS),0,0,2*Math.PI,i),t.scale(r,r),t.closePath()}get path(){const{cx:t,cy:e}=this.state;return[{x:t-cm.RADIUS,y:e-cm.RADIUS},{x:t+cm.RADIUS,y:e-cm.RADIUS},{x:t+cm.RADIUS,y:e+cm.RADIUS},{x:t-cm.RADIUS,y:e+cm.RADIUS}]}set path(t){const e=t[0],n=t[2];this.set({cx:e.x+(n.x-e.x)/2,cy:e.y+(n.y-e.y)/2})}contains(t,e){const{cx:n,cy:i}=this.state,r=(t-n)/(2*cm.RADIUS-.5),s=(e-i)/(2*cm.RADIUS-.5);return r*r+s*s<.25}outline(t){const{cx:e,cy:n}=this.state;return this.toScene(e,n)}get nature(){return am}}cm.RADIUS=5,Ga.memoize(cm.prototype,"path",!1),Ga.register("node",cm);class lm extends Uh{getObject3dInstance(){return new w.Mesh}build(){super.build();const{width:t,height:e}=this.component.bounds,n=this.component.state.depth||.5*Math.min(t,e),i=.15*Math.min(t,e,n),r=new v.RoundedBoxGeometry(1,1,1,4,i/Math.min(t,e,n));r.scale(t,n,e),this.object3d.geometry=r,this.object3d.material=new w.MeshStandardMaterial({color:"#5090d0",transparent:!0,opacity:.35,roughness:.6,metalness:.1,side:w.FrontSide,depthWrite:!1}),this.object3d.visible=!!this.component.app?.isEditMode}updateAlpha(){const t=this.object3d.material;t&&(t.opacity=this.component.app?.isEditMode?.35:0)}updateHidden(){this.object3d.visible=!!this.component.app?.isEditMode&&!this.component.state.hidden}updateDimension(){const{width:t,height:e}=this.component.bounds,n=this.component.state.depth||.5*Math.min(t,e);this.object3d.geometry.computeBoundingBox();const i=this.object3d.geometry.boundingBox;if(i){const r=i.max.x-i.min.x,s=i.max.y-i.min.y,o=i.max.z-i.min.z;this.object3d.scale.set(t/r,n/s,e/o)}}updateFillStyle(){}updateStrokeStyle(){}updateText(){}clear(){return Nh(this.object3d),super.clear()}}const hm="data:image/svg+xml;base64,"+btoa('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" fill="#5090d0">\n <path d="M32 20a12 12 0 1 0 0 24 12 12 0 0 0 0-24zm0 18a6 6 0 1 1 0-12 6 6 0 0 1 0 12z"/>\n <path d="M55.4 27.2l-3.6-.6c-.4-1.2-.8-2.4-1.4-3.4l2.2-3c.6-.8.4-2-.2-2.6l-3-3c-.8-.6-1.8-.8-2.6-.2l-3 2.2c-1.2-.6-2.2-1-3.4-1.4l-.6-3.6c-.2-1-1-1.6-2-1.6h-4.2c-1 0-1.8.6-2 1.6l-.6 3.6c-1.2.4-2.4.8-3.4 1.4l-3-2.2c-.8-.6-2-.4-2.6.2l-3 3c-.6.8-.8 1.8-.2 2.6l2.2 3c-.6 1.2-1 2.2-1.4 3.4l-3.6.6c-1 .2-1.6 1-1.6 2v4.2c0 1 .6 1.8 1.6 2l3.6.6c.4 1.2.8 2.4 1.4 3.4l-2.2 3c-.6.8-.4 2 .2 2.6l3 3c.8.6 1.8.8 2.6.2l3-2.2c1.2.6 2.2 1 3.4 1.4l.6 3.6c.2 1 1 1.6 2 1.6h4.2c1 0 1.8-.6 2-1.6l.6-3.6c1.2-.4 2.4-.8 3.4-1.4l3 2.2c.8.6 2 .4 2.6-.2l3-3c.6-.8.8-1.8.2-2.6l-2.2-3c.6-1.2 1-2.2 1.4-3.4l3.6-.6c1-.2 1.6-1 1.6-2v-4.2c0-1-.6-1.8-1.6-2z"/>\n</svg>');class dm extends($a(Ga)){static get icon(){return dm._defaultIcon||(dm._defaultIcon=new Image,dm._defaultIcon.src=hm),dm._defaultIcon}get serviceName(){}get hasTextProperty(){return!1}is3dish(){return!0}buildRealObject(){return new lm(this)}render(t){if(this.app?.isViewMode)return;const{left:e,top:n,width:i,height:r}=this.bounds,s=this.constructor.icon;t.beginPath(),t.globalAlpha=.6,this.drawImage(t,s,e,n,i,r),t.globalAlpha=1}added(t){super.added(t);const e=this.serviceName;e&&(this._registeredRoot=this.root,this._registeredRoot?.registerService?.(e,this))}removed(t){const e=this.serviceName;e&&this._registeredRoot&&(this._registeredRoot.unregisterService?.(e),this._registeredRoot=void 0),super.removed(t)}get controls(){return[]}}function um(t){return class extends t{animOnValueChange(t,e=!1,n){if(t==this._lastValue)return;if(this.root?.app?.suppressAnimations)return this._lastValue=t,this._anim_alpha=0,void this.invalidate();let i;i=e?t-(Number(n)||0):t-(this._lastValue||0),this._lastValue=t,this._anim_alpha=-i,this.animate({step:t=>{this._anim_alpha=i*(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=bs(this.getState("value"),this,void 0)||this.defaultValueSubstitutor),this._value_substitutor}get value(){return Number(this.valueSubstitutor())||0}set value(t){delete this._value_substitutor,this.setState("value",Number(ai(t)))}}}function pm(t){return class extends t{_convertDataFormat(t,e){let n;if("json"===e)n=JSON.parse(t);else n=t;return n}isDataSource(){return!0}}}function fm(t){var e;return(e=class extends t{is3dish(){return!0}get hasTextProperty(){return!1}get capturable(){return!1}render(t){}}).raycastTargetDefault=!1,e}const gm="$base_url",mm=[{type:"gltf-preset",label:"preset",name:"preset"},{type:"gltf-selector",label:"url",name:"src",property:{displayField:"id",displayFullUrl:!0,baseUrlAlias:gm,defaultStorage:"3d-model",storageFilters:{type:Array,value:[{name:"category",value:"image"}]},useUpload:!0,category:"application"},observe:function(t){const e=this.parentNode?.querySelector("[name=gltfInfo]");e&&(e.src=t);const n=this.parentNode?.querySelector("[name=fillStyleTargets]");n&&(n.src=t);const i=this.parentNode?.querySelector("[name=playTargets]");i&&(i.src=t)}},{type:"gltf-info",label:"",name:"gltfInfo",readonly:!0,property:{action:(t,e)=>{t._ratioLocking=!0;try{t.set(e)}finally{t._ratioLocking=!1}}},editor:{fullwidth:!0}},{type:"gltf-fill-targets",label:"fill-targets",name:"fillStyleTargets",editor:{fullwidth:!0}},{type:"gltf-play-targets",label:"play-targets",name:"playTargets",editor:{fullwidth:!0}}];function ym(t){return class extends t{constructor(){super(...arguments),this._snapshotLoading=!1,this._ratioLocking=!1}is3dish(){return!0}get hasTextProperty(){return!1}get controls(){return[]}render(t){const{left:e,top:n,width:i,height:r}=this.bounds;t.beginPath();const s=this._topViewSnapshot;if(s)return void t.drawImage(s,e,n,i,r);this._ensureTopViewSnapshot(),t.rect(e,n,i,r),t.fillStyle="#f0f0f0",t.fill(),t.strokeStyle="#999",t.lineWidth=1,t.stroke();const o=this.getState("src"),a=o&&o.split("/").pop()?.replace(/\.[^.]+$/,"")||"GLTF",c=Math.max(10,.12*Math.min(i,r));t.fillStyle="#666",t.font=`${c}px sans-serif`,t.textAlign="center",t.textBaseline="middle",t.fillText(a,e+i/2,n+r/2,.9*i)}onchange(t,e){super.onchange?.(t,e),"src"in t&&(this._topViewSnapshot=void 0)}_ensureTopViewSnapshot(){if(this._snapshotLoading)return;const t=this.getState("src");if(!t)return;const e=Kh.getTopViewCache(t);if(e)return this._topViewSnapshot=e,void this.invalidate();this._snapshotLoading=!0;const n=this.app.url(t);Kh.loadGLTF(n).then(e=>{if(this._snapshotLoading=!1,this.getState("src")!==t)return;const n=Kh.getTopViewCache(t);if(n)return this._topViewSnapshot=n,void this.invalidate();const i=Kh.renderTopView(e.scene);Kh.setTopViewCache(t,i),this._topViewSnapshot=i,this.invalidate()}).catch(()=>{this._snapshotLoading=!1})}buildRealObject(){return new Kh(this)}get source(){return this.getState("src")}set source(t){this.setState("src",t)}get play(){return!1!==this.getState("play")}set play(t){this.setState("play",t)}get nodes(){return this.getState("nodes")}set nodes(t){this.setState("nodes",t)}get animations(){return this.getState("animations")}set animations(t){this.setState("animations",t)}get playTargets(){return this.getState("playTargets")}set playTargets(t){this.setState("playTargets",t)}get fillStyleTargets(){return this.getState("fillStyleTargets")}set fillStyleTargets(t){this.setState("fillStyleTargets",t)}get nodeNames(){const t=this.realObject;return t?.nodeNames??[]}get animationNames(){const t=this.realObject;return t?.animationNames??[]}set dimension(t){const{width:e=1,height:n=1,depth:i=1}=t;this.setState({width:e,height:n,depth:i}),this.realObject?.updateDimension()}_applyRatioLock(t){if(!("width"in t||"height"in t||"depth"in t))return t;const e=this.state.width||1,n=this.state.height||1,i=this.state.depth||1,r=vu([(t.width??e)/e,(t.height??n)/n,(t.depth??i)/i]);return r?{...t,width:Math.round(e*r),height:Math.round(n*r),depth:Math.round(i*r)}:t}set(t,e){if("string"==typeof t&&(t={[t]:e}),this.state?.ratioLock&&!this._ratioLocking){this._ratioLocking=!0;try{t=this._applyRatioLock(t)}finally{}}try{return super.set(t)}finally{this._ratioLocking=!1}}setState(t,e){if("string"==typeof t&&(t={[t]:e}),this.state?.ratioLock&&!this._ratioLocking){this._ratioLocking=!0;try{t=this._applyRatioLock(t)}finally{}}try{return super.setState(t)}finally{this._ratioLocking=!1}}}}function bm(t){return function(e){return Array.isArray(t)?t.forEach(t=>{Ga.register(t,e)}):Ga.register(t,e),e}}let _m=0;const vm=new FinalizationRegistry(()=>{_m--});class xm{static get residents(){return _m}static get residentsCount(){return _m}constructor(t,e){this.counters={},this.references={},this.creator=t,this.disposer=e,_m++,vm.register(this,_m)}dispose(){if(this.disposer)for(const t in this.references)this.disposer(t,this.references[t]);this.references={},this.counters={}}get ids(){return Object.keys(this.references)}create(t){return new Promise((e,n)=>{this.creator?this.creator(t,n=>{n.release=()=>{this.disposer?.(t,n),delete n.release,Bi("RELEASED",t)},e(n)},n):n(Error("Reference id("+t+") could not be created. Reference creator should be defined."))})}add(t,e){const n=new Promise((n,i)=>{const r=this.references[t];if(r)r===e?i(Error("Reference ID and target duplicate")):e?i(Error("Reference ID duplicate")):n(r);else{const r=e=>{e.release=()=>{this.release(e)},this.references[t]=e,this.counters[t]=1,n(e)};if(e)r(e);else{if(!this.creator)return void i(Error("Reference id("+t+") is not allowed. Reference creator should be defined."));this.creator(t,r,i)}}});return this.references[t]||(this.references[t]=n),n}async get(t,e=!1){let n=this.references[t];if(n){if(!(n instanceof Promise)){if(!(t in this.counters))throw new Error("No Reference Count");return this.counters[t]++,n}if(e)return n=await n,this.counters[t]++,n}if(e)return await this.add(t);throw new Error("No References for "+t)}_id(t){for(const e in this.references){if(this.references[e]===t)return e}}release(t){const e=this._id(t);if(!e)return void ji("No Referenced ID");const n=this.references[e];n&&(this.counters[e]--,0==this.counters[e]&&(this.disposer?.(e,n),delete this.references[e],delete this.counters[e],delete t.release,Bi("RELEASED",e)))}}const wm={},Mm={};let Sm=[];function Am(t){const e=t.target,n="SCRIPT"===e.tagName?wm:Mm,i=e.src||e.href;n[i]=!0,Sm.forEach((t,e)=>{if(!t)return;const{resolve:r,scripts:s,styles:o}=t;if(n===wm){const t=s.indexOf(i);t>-1&&t<s.length-1&&km(s[t+1])}s.some(t=>!wm[t])||o?.some(t=>!Mm[t])||(r(),Sm[e]=null)}),Sm=Sm.filter(Boolean)}function Em(t){if("string"==typeof t)return;const e=t.target,n=e.src,i="SCRIPT"===e.tagName?wm:Mm;Sm.forEach((e,r)=>{if(!e)return;const{reject:s,scripts:o,styles:a}=e;(i===wm&&o.includes(n)||i===Mm&&!!a?.includes(n))&&(s(t),Sm[r]=null)}),Sm=Sm.filter(Boolean),delete i[n],document.head.removeChild(e)}function km(t){wm[t]=!1;const e=document.createElement("script");e.onload=Am,e.onerror=Em,e.type="text/javascript",e.src=t,document.head.appendChild(e)}class Cm{static load(t,e){const n="string"==typeof t?[t]:t,i="string"==typeof e?[e]:e;return new Promise(function(t,e){if(n&&!Array.isArray(n)||i&&!Array.isArray(i))return void e(new Error("invalid sources for load"));let r,s=!0;if(i?.forEach(t=>{t in Mm||function(t){Mm[t]=!1;const e=document.createElement("link");e.onload=Am,e.onerror=Em,e.type="text/css",e.rel="stylesheet",e.media="screen,print",e.href=t,document.head.appendChild(e)}(t),Mm[t]||(s=!1)}),n&&n.length>0)for(const t of n)t in wm?wm[t]||(s=!1):r??=t;if(r)km(r);else if(s)return void t();Sm.push({resolve:t,reject:e,scripts:n,styles:i})})}}const Tm="0.0.0";function Pm(t){if(!(t>0))return 1;let e=0;if(!(t&t-1))return t;for(;0!=t;)t>>=1,e+=1;return 1<<e}function Dm(t){const{lineWidth:e=0}=t.state;let{width:n,height:i}=t.bounds;n+=e,i+=e;const r=Pm(2*n),s=Pm(2*i),o=Wd(r,s),a=new w.CanvasTexture(o);return Om(o,t,2),a.needsUpdate=!0,a.wrapS=w.RepeatWrapping,a.wrapT=w.RepeatWrapping,a.offset.set(0,1-2*i/s),a.repeat.set(2*n/r,2*i/s),a.magFilter=w.NearestFilter,a.minFilter=w.LinearFilter,a.colorSpace=w.SRGBColorSpace,a}function Om(t,e,n){const{lineWidth:i=0}=e.state;let{left:r,top:s}=e.bounds;r-=i/2,s-=i/2;const o=t.getContext("2d");o.scale(n,n),o.translate(-r,-s),e.render(o),e.postrender(o)}function zm(t,e,n=2){const i=t.getContext("2d");i&&(i.setTransform(1,0,0,1,0,0),i.clearRect(0,0,t.width,t.height),Om(t,e,n))}const Lm=new Set(["cx","cy","cz","zPos","left","top","width","height","depth","lineWidth","rotationX","rotationY","rotation","scale","hidden","alpha","material3d","screenFixed"]);class Im extends Uh{get syncZPosOffset(){return this.effectiveDepth}get geometricOffsetY(){return this.effectiveDepth}constructor(t){super(t),this._origInvalidate=t.invalidate.bind(t),t.invalidate=()=>{this._origInvalidate(),this._refreshTextureNow()}}getObject3dInstance(){return new w.Mesh}build(){super.build();const{width:t,height:e}=this.component.bounds;if(!t||!e)return;const n=wh(this.component.state.material3d),i=new w.PlaneGeometry(1,1);i.rotateX(-Math.PI/2),this.object3d.geometry=i;const r=Dm(this.component);this.object3d.material=new w.MeshStandardMaterial({map:r,transparent:!0,side:w.DoubleSide,metalness:n.metalness,roughness:n.roughness,emissive:new w.Color(n.emissive),emissiveIntensity:n.emissiveIntensity}),this.object3d.castShadow=n.castShadow,this.object3d.receiveShadow=n.receiveShadow}updateDimension(){const{width:t,height:e}=this.component.bounds;this.object3d.scale.set(t,1,e)}updateAlpha(){const{alpha:t=1,fillStyle:e}=this.component.state;Oh(this.object3d.material,t,e)}updateHidden(){this.object3d.visible=!this.component.state.hidden}_debouncedRebuild(){this._debounceTimer&&clearTimeout(this._debounceTimer),this._debounceTimer=setTimeout(()=>{this._debounceTimer=void 0,this._rebuildTexture()},100)}_rebuildTexture(){this.clear(),this.build(),this.updateTransform(),this.updateDimension(),this.updateHidden()}_refreshTextureNow(){const t=this.object3d.material,e=t?.map;if(!e)return;const n=e.source?.data;n&&(zm(n,this.component,2),e.needsUpdate=!0)}updateFillStyle(){this._debouncedRebuild()}updateStrokeStyle(){this._debouncedRebuild()}updateText(){this._debouncedRebuild()}onchange(t,e){super.onchange(t,e);for(const e of Object.keys(t))if(!Lm.has(e)){this._debouncedRebuild();break}}updateMaterial3d(){super.updateMaterial3d();const t=this.object3d.material;if(!t)return;const e=wh(this.component.state.material3d);t.metalness=e.metalness,t.roughness=e.roughness,t.emissive.set(e.emissive),t.emissiveIntensity=e.emissiveIntensity}clear(){return this._debounceTimer&&(clearTimeout(this._debounceTimer),this._debounceTimer=void 0),Nh(this.object3d),super.clear()}dispose(){this._debounceTimer&&(clearTimeout(this._debounceTimer),this._debounceTimer=void 0),this._origInvalidate&&(this.component.invalidate=this._origInvalidate,this._origInvalidate=void 0),super.dispose()}}class Rm extends Uh{getObject3dInstance(){return new w.Mesh}build(){super.build(),this.buildGeometry(),this.buildMaterial()}updateAlpha(){const{alpha:t=1,fillStyle:e}=this.component.state;Oh(this.object3d.material,t,e)}updateHidden(){this.object3d.visible=!this.component.state.hidden}updateFillStyle(){const{fillStyle:t}=this.component.state,e=this.object3d.material;if(!e)return;const n=Uh.buildFillStyleTexture(this.component);n?(e.map&&e.map.dispose(),n.needsUpdate=!0,e.map=n):"string"==typeof t&&("transparent"!==t?e.color.set(zh(t)):e.opacity=0)}updateStrokeStyle(){const t=this.object3d.getObjectByName("__edgeLines__");t&&(this.object3d.remove(t),Nh(t));const{strokeStyle:e}=this.component.state;if(!e||"transparent"===e||"none"===e)return;const n=this.object3d.geometry;if(!n?.getAttribute("position"))return;const i=new w.EdgesGeometry(n),r=new w.LineBasicMaterial({color:e}),s=new w.LineSegments(i,r);s.name="__edgeLines__",this.object3d.add(s)}updateDimension(){const{width:t,height:e}=this.component.bounds,{depth:n=1}=this.component.state;if(!this.object3d)return;this.object3d.geometry.computeBoundingBox();const i=this.object3d.geometry.boundingBox;if(i){const r=i.max.x-i.min.x,s=i.max.y-i.min.y,o=i.max.z-i.min.z;this.object3d.scale.set(t/r,n/s,e/o)}}buildMaterial(){const t=wh(this.component.state.material3d),e=new w.MeshStandardMaterial({transparent:!0});Ah(e,t),this.object3d.material=e}updateMaterial3d(){super.updateMaterial3d();const t=this.object3d.material;t&&Ah(t,wh(this.component.state.material3d))}clear(){return Nh(this.object3d),super.clear()}}function jm(t,e,n,i){return[["bold",t],["italic",e],[n+"px",!0],[i,!0]].filter(t=>t[1]).map(t=>t[0]).join(" ")}function Fm(t){let e=0;if(!((t=Math.abs(t)||1)&t-1))return t;for(;0!=t;)t>>=1,e+=1;return 1<<e}function Bm(t,e,n){const{bold:i=!1,italic:r=!1,fontFamily:s="Serif",fontSize:o=10,fontColor:a="black",textAlign:c="center",textBaseline:l="middle",width:h=t.width,height:d=t.height,offsetX:u=0,offsetY:p=0}=n||{},f=t.getContext("2d");let g,m;f.imageSmoothingEnabled=!1,f.fillStyle=a,f.strokeStyle=a,f.font=jm(i,r,o,s),"left"===c||"start"===c?(f.textAlign="left",g=u):"right"===c||"end"===c?(f.textAlign="right",g=u+h):(f.textAlign="center",g=u+h/2);const y=1.2*o,b=String(e).split("\n"),_=y*b.length;m="top"===l||"hanging"===l?p+.1*o:"bottom"===l||"alphabetic"===l?p+d-_+.1*o:p+(d-_)/2+.1*o,f.textBaseline="top";for(const t of b)f.fillText(t,g,m),m+=y}function Nm(t,e,n,i){const r=Fm(2*e),s=Fm(2*n),o=Wd(r,s),a=o.getContext("2d"),{fillStyle:c}=i||{};if(c&&"object"==typeof c&&c.colorStops?.length){const t=Hh(c,2*e,2*n);t&&a.drawImage(t,0,0)}a.scale(2,2),"string"==typeof c&&""!==c&&"transparent"!==c&&(a.fillStyle=c,a.fillRect(0,0,e,n)),Bm(o,t,i);const l=new w.CanvasTexture(o);return l.needsUpdate=!0,l.wrapS=w.RepeatWrapping,l.wrapT=w.RepeatWrapping,l.offset.set(0,1-2*n/s),l.repeat.set(2*e/r,2*n/s),l.minFilter=w.LinearFilter,l.colorSpace=w.SRGBColorSpace,l}function Hm(t,e,n,i,r,s,o){const a=new Image;a.crossOrigin="anonymous",a.onload=()=>{const t=2*n,c=2*i,l=Fm(t),h=Fm(c),d=Wd(l,h),u=d.getContext("2d");if(s.color&&(u.fillStyle=s.color,u.fillRect(0,0,t,c)),s.fitPattern)u.drawImage(a,0,0,t,c);else{const e=2*(s.width||a.naturalWidth),n=2*(s.height||a.naturalHeight),i=2*(s.offsetX||0),r=2*(s.offsetY||0);let o=0,l=0;switch(s.align){case"center":o=(t-e)/2,l=(c-n)/2;break;case"left-top":break;case"left-bottom":l=c-n;break;case"right-top":o=t-e;break;case"right-bottom":o=t-e,l=c-n;break;case"left":l=(c-n)/2;break;case"right":o=t-e,l=(c-n)/2;break;case"top":o=(t-e)/2;break;case"bottom":o=(t-e)/2,l=c-n}const h=i+o,d=r+l;if(s.noRepeat)u.drawImage(a,0,0,a.naturalWidth,a.naturalHeight,h,d,e,n);else{u.save(),u.rect(0,0,t,c),u.clip();const i=h>0?h-Math.ceil(h/e)*e:h;for(let r=d>0?d-Math.ceil(d/n)*n:d;r<c;r+=n)for(let s=i;s<t;s+=e)u.drawImage(a,0,0,a.naturalWidth,a.naturalHeight,s,r,e,n);u.restore()}}e&&(u.scale(2,2),Bm(d,e,r));const p=new w.CanvasTexture(d);p.needsUpdate=!0,p.wrapS=w.RepeatWrapping,p.wrapT=w.RepeatWrapping,p.offset.set(0,1-c/h),p.repeat.set(t/l,c/h),p.minFilter=w.LinearFilter,p.colorSpace=w.SRGBColorSpace,o(p)},a.onerror=()=>{const t=Nm(e,n,i,r);o(t)},a.src=t}function Ym(t,e){let{bold:n=!1,italic:i=!1,fontFamily:r="Serif",fontSize:s=10,lineHeight:o="normal"}=e||{};t=void 0===t||""==t?" ":String(t);const a=document.createElement("span");a.style.font=jm(n,i,s,r),a.style.lineHeight=String(o),a.style.whiteSpace="pre",a.style.position="absolute",a.textContent=t,document.body.appendChild(a);const c=a.getBoundingClientRect();return document.body.removeChild(a),{width:c.width,height:c.height}}class Gm extends Rm{get syncZPosOffset(){return this.effectiveDepth}get geometricOffsetY(){return this.effectiveDepth}buildGeometry(){this.updateDimension()}updateStrokeStyle(){}updateFillStyle(){this.updateText()}updateDimension(){const{width:t,height:e}=this.component.state,n=Math.abs(t)||1,i=Math.abs(e)||1;this.object3d.geometry&&this.object3d.geometry.dispose();const r=new w.PlaneGeometry(n,i);r.rotateX(-Math.PI/2),this.object3d.geometry=r}updateText(){const t=this.object3d.material;if(!t)return;const{width:e,height:n,bold:i=!1,italic:r=!1,fontFamily:s="Serif",fontSize:o=10,fontColor:a="black",textAlign:c="center",textBaseline:l="middle",fillStyle:h}=this.component.state,d=Math.abs(e)||1,u=Math.abs(n)||1,p=this.component.text,f=h&&"none"!==h?h:"transparent",g={bold:i,italic:r,fontFamily:s,fontSize:o,fontColor:a,textAlign:c,textBaseline:l,width:d,height:u,fillStyle:f};if("object"==typeof f&&"pattern"===f?.type&&f.image){return void Hm(this.component.app.url(h.image),p,d,u,g,h,e=>{t.map&&t.map.dispose(),t.map=e,t.color.set(16777215),t.needsUpdate=!0})}const m=Nm(p,d,u,g);m?(t.map&&t.map.dispose(),t.map=m,t.color.set(16777215),m.needsUpdate=!0):"string"==typeof h&&(""!==h&&"transparent"!==h?t.color.set(zh(h)):t.opacity=0)}updateAlpha(){const{alpha:t=1}=this.component.state,e=this.object3d.material;e.opacity=t,e.transparent=!0}}nu("text",t=>new Gm(t));const Vm={input:"css3d",select:"css3d",textarea:"css3d",button:"css3d",iframe:"css3d",video:"css3d",label:"texture",table:"texture",progress:"texture"};function Um(t){const e=t.model?.type??"";return"texture"===(Vm[e]??"css3d")?new Im(t):new Jd(t)}nu("html-overlay-element",Um),nu("html-overlay-container",Um);class $m{setShape({extrudedShape:t,extrudedOptions:e}){this.extrudedShape=t,this.bb=new w.Box2,this.bb.setFromPoints(this.extrudedShape?.extractPoints(0).shape),this.extrudedOptions=e}generateTopUV(t,e,n,i,r){const s=e[3*n],o=e[3*n+1],a=e[3*i],c=e[3*i+1],l=e[3*r],h=e[3*r+1],d=this.bb,u=d.max.x-d.min.x,p=d.max.y-d.min.y;return[new w.Vector2((s-d.min.x)/u,1-(o-d.min.y)/p),new w.Vector2((a-d.min.x)/u,1-(c-d.min.y)/p),new w.Vector2((l-d.min.x)/u,1-(h-d.min.y)/p)]}generateSideWallUV(t,e,n,i,r,s){const o=e[3*n],a=e[3*n+1],c=e[3*n+2],l=e[3*i],h=e[3*i+1],d=e[3*i+2],u=e[3*r],p=e[3*r+1],f=e[3*r+2],g=e[3*s],m=e[3*s+1],y=e[3*s+2],b=this.extrudedOptions?.depth||100,_=this.bb,v=_.max.x-_.min.x,x=_.max.y-_.min.y;return Math.abs(a-h)<.01?[new w.Vector2(o/v,1-c/b),new w.Vector2(l/v,1-d/b),new w.Vector2(u/v,1-f/b),new w.Vector2(g/v,1-y/b)]:[new w.Vector2(a/x,1-c/b),new w.Vector2(h/x,1-d/b),new w.Vector2(p/x,1-f/b),new w.Vector2(m/x,1-y/b)]}}class Wm extends Uh{clear(){return this._mesh=void 0,super.clear()}get shape(){return null}get boundUVGenerator(){return this._boundUVGenerator||(this._boundUVGenerator=new $m),this._boundUVGenerator}build(){super.build();const t=this.effectiveDepth,e=this.shape;if(!e)return;const n=this.boundUVGenerator;n&&n.setShape({extrudedShape:e,extrudedOptions:{depth:t}});const i=this.createGeometry(e),r=this.createMaterials();this._mesh=new w.Mesh(i,r),this._mesh.rotation.x=-Math.PI/2,this._mesh.rotation.y=-Math.PI,this._mesh.rotation.z=-Math.PI,this._mesh.castShadow=!0,this.object3d.add(this._mesh),this.updateFillStyle(),this.updateStrokeStyle()}createGeometry(t){const e=this.effectiveDepth,{lineWidth:n=0}=this.component.state,i={steps:1,depth:e,bevelEnabled:n>0,bevelThickness:0,bevelSize:n,bevelSegments:1,UVGenerator:this.boundUVGenerator},r=new w.ExtrudeGeometry(t,i);return r.center(),r}createMaterials(){const t=wh(this.component.state.material3d),e=new w.MeshStandardMaterial;Ah(e,t);const n=new w.MeshStandardMaterial;return Ah(n,t),[e,n]}createTexture(){const{width:t,height:e}=this.component.bounds,n=Fm(t),i=Fm(e),r=Wd(n,i);this.component.render(r.getContext("2d"));const s=new w.CanvasTexture(r);return s.needsUpdate=!0,s.wrapS=w.RepeatWrapping,s.wrapT=w.RepeatWrapping,s.offset.set(0,1-e/i),s.repeat.set(t/n,e/i),s.minFilter=w.LinearFilter,s}getMaterials(){if(!this._mesh)return;const t=this._mesh.material;return Array.isArray(t)?t:void 0}updateMaterial3d(){super.updateMaterial3d();const t=this.getMaterials();if(!t)return;const e=wh(this.component.state.material3d);for(const n of t)Ah(n,e)}updateAlpha(){const{alpha:t=1,fillStyle:e,strokeStyle:n}=this.component.state,i=this.getMaterials();i&&(Oh(i[0],t,e),Oh(i[1],t,n))}updateStrokeStyle(){const t=this.getMaterials();if(!t)return;const{strokeStyle:e}=this.component.state;t[1].color.set(zh(e))}updateFillStyle(){this._applyCapTexture()}updateText(){this._applyCapTexture()}_applyCapTexture(){const t=this.getMaterials();if(!t)return;const e=t[0],{fillStyle:n}=this.component.state,i=this.component.hasTextProperty?this.component.text:"";if(!i){const t=Uh.buildFillStyleTexture(this.component);return t?(e.map&&e.map.dispose(),e.map=t,e.color.set(16777215)):(e.map&&(e.map.dispose(),e.map=null),e.color.set(zh(n))),void(e.needsUpdate=!0)}const{bold:r=!1,italic:s=!1,fontFamily:o="Serif",fontSize:a=10,fontColor:c="black",textAlign:l="center",textBaseline:h="middle",paddingTop:d=0,paddingLeft:u=0,paddingRight:p=0,paddingBottom:f=0}=this.component.state,{width:g,height:m}=this.component.bounds,y=Math.abs(g)||1,b=Math.abs(m)||1,_={bold:r,italic:s,fontFamily:o,fontSize:a,fontColor:c,textAlign:l,textBaseline:h,width:Math.max(y-u-p,0),height:Math.max(b-d-f,0),fillStyle:n,offsetX:u,offsetY:d};if("object"==typeof n&&"pattern"===n?.type&&n.image){return void Hm(this.component.app.url(n.image),i,y,b,_,n,t=>{e.map&&e.map.dispose(),e.map=t,e.color.set(16777215),e.needsUpdate=!0})}e.map&&e.map.dispose();const v=Nm(i,y,b,_);e.map=v,e.color.set(16777215),e.needsUpdate=!0}updateDimension(){super.updateDimension()}}class Xm extends Wm{get shape(){const{cx:t=0,cy:e=0,rx:n=1,ry:i=1,startAngle:r=0,endAngle:s=2*Math.PI,anticlockwise:o=!1}=this.component.state,a=new w.EllipseCurve(t,e,Math.abs(n),Math.abs(i),r,s,o,0);return new w.Shape(a.getPoints(50))}}nu("ellipse",t=>new Xm(t));class qm extends Wm{get shape(){const{width:t,height:e,round:n=0}=this.component.state,i=Ua(n,t,e);if(i>0){const n=i,r=new w.Path;return r.moveTo(n,0),r.lineTo(t-n,0),r.quadraticCurveTo(t,0,t,n),r.lineTo(t,e-n),r.quadraticCurveTo(t,e,t-n,e),r.lineTo(n,e),r.quadraticCurveTo(0,e,0,e-n),r.lineTo(0,n),r.quadraticCurveTo(0,0,n,0),new w.Shape(r.getPoints(12))}const r=new w.Shape;return r.moveTo(0,0),r.lineTo(t,0),r.lineTo(t,e),r.lineTo(0,e),r.lineTo(0,0),r}}nu("rect",t=>new qm(t));class Km extends Wm{get shape(){const{path:t=[],round:e=0}=this.component.state;if(e>0){const n=new w.Path;for(let i=0;i<t.length;i++){const r=t[(i-1+t.length)%t.length],s=t[i],o=t[(i+1)%t.length];if(r.x===s.x&&r.y===s.y)continue;let a=Math.sqrt((r.x-s.x)**2+(r.y-s.y)**2),c=0!==a?Math.atan2(r.x-s.x,r.y-s.y):0;const l=Math.sin(c)*Math.min(e,a/2)+s.x,h=Math.cos(c)*Math.min(e,a/2)+s.y;a=Math.sqrt((o.x-s.x)**2+(o.y-s.y)**2),c=0!==a?Math.atan2(o.x-s.x,o.y-s.y):0;const d=Math.sin(c)*Math.min(e,a/2)+s.x,u=Math.cos(c)*Math.min(e,a/2)+s.y;0===i?n.moveTo(l,h):n.lineTo(l,h),n.quadraticCurveTo(s.x,s.y,d,u)}return new w.Shape(n.getPoints(12))}const n=new w.Shape;for(let e=0;e<t.length;e++)0===e?n.moveTo(t[e].x,t[e].y):n.lineTo(t[e].x,t[e].y);return n}get minMax(){if(!this._minMax){const{path:t}=this.component.state;let e,n,i,r;t.forEach((t,s)=>{if(0==s)return e=i=t.x,void(n=r=t.y);e=Math.min(e,t.x),i=Math.max(i,t.x),n=Math.min(n,t.y),r=Math.max(r,t.y)}),this._minMax={minX:e,minY:n,maxX:i,maxY:r}}return this._minMax}}nu("polygon",t=>new Km(t));class Qm extends Wm{get shape(){const{cx:t=0,cy:e=0,rx:n=1,ry:i=1,ratio:r=50,startAngle:s=0,endAngle:o=2*Math.PI,anticlockwise:a=!1}=this.component.state,c=Math.abs(n),l=Math.abs(i),h=new w.EllipseCurve(t,e,c,l,s,o,a,0),d=new w.Shape(h.getPoints(50)),u=c/100*r,p=l/100*r;if(u>0&&p>0){const n=new w.EllipseCurve(t,e,u,p,s,o,a,0),i=new w.Path(n.getPoints(50));d.holes.push(i)}return d}}nu("donut",t=>new Qm(t));class Zm extends Wm{get shape(){const{x1:t=0,y1:e=0,x2:n=0,y2:i=0,x3:r=0,y3:s=0,round:o=0}=this.component.state,a=[{x:t,y:e},{x:n,y:i},{x:r,y:s}];if(o>0){const t=new w.Path;for(let e=0;e<a.length;e++){const n=a[(e-1+a.length)%a.length],i=a[e],r=a[(e+1)%a.length];let s=Math.sqrt((n.x-i.x)**2+(n.y-i.y)**2),c=0!==s?Math.atan2(n.x-i.x,n.y-i.y):0;const l=Math.sin(c)*Math.min(o,s/2)+i.x,h=Math.cos(c)*Math.min(o,s/2)+i.y;s=Math.sqrt((r.x-i.x)**2+(r.y-i.y)**2),c=0!==s?Math.atan2(r.x-i.x,r.y-i.y):0;const d=Math.sin(c)*Math.min(o,s/2)+i.x,u=Math.cos(c)*Math.min(o,s/2)+i.y;0===e?t.moveTo(l,h):t.lineTo(l,h),t.quadraticCurveTo(i.x,i.y,d,u)}return new w.Shape(t.getPoints(12))}const c=new w.Shape;return c.moveTo(t,e),c.lineTo(n,i),c.lineTo(r,s),c.closePath(),c}}nu("triangle",t=>new Zm(t));class Jm extends Wm{get shape(){const{ratio:t=30,wing:e=5,cx:n=0,cy:i=0,rx:r=1,ry:s=1}=this.component.state;if(e<3)return null;const o=Math.PI/2,a=2*Math.PI/e,c=r-t/100*r,l=s-t/100*s,h=new w.Shape;h.moveTo(n+r*Math.cos(-o),i+s*Math.sin(-o)),h.lineTo(n+(r-c)*(Math.cos(a-o)+Math.cos(0-o))/2,i+(s-l)*(Math.sin(a-o)+Math.sin(0-o))/2);for(let t=1;t<e;t++)h.lineTo(n+r*Math.cos(a*t-o),i+s*Math.sin(a*t-o)),h.lineTo(n+(r-c)*(Math.cos(a*(t+1)-o)+Math.cos(a*t-o))/2,i+(s-l)*(Math.sin(a*(t+1)-o)+Math.sin(a*t-o))/2);return h.closePath(),h}}nu("star",t=>new Jm(t));const ty={mutable:!1,resizable:!0,rotatable:!0,properties:[],help:"scene/component/sphere"};class ey extends Rm{buildGeometry(){const{rx:t=0,ry:e=0,rz:n}=this.component.state,i=n??t,r=new w.SphereGeometry(1,32,16);r.scale(t,i,e),this.object3d.geometry=r}updateDimension(){this.buildGeometry()}get effectiveDepth(){const{rx:t=0,rz:e}=this.component.state,n=e??t;return Math.max(2*n,1)}}t.Sphere=class extends og{get hasTextProperty(){return!1}is3dish(){return!0}buildRealObject(){return new ey(this)}get nature(){return ty}},t.Sphere=Ep([bm("sphere")],t.Sphere);class ny extends Uh{getObject3dInstance(){return new w.Sprite}build(){super.build(),this.buildMaterial()}get cz(){const{zPos:t=0}=this.component.state,{height:e}=this.component.bounds,{tz:n=0}=this.component.delta(),i=this.component.parent?._realObject;return t+n+e/2-(i?.geometricOffsetY??0)}get geometricOffsetY(){const{height:t=0}=this.component.bounds;return t/2}updateAlpha(){const{alpha:t=1,fillStyle:e}=this.component.state;Oh(this.object3d.material,t,e)}updateHidden(){this.object3d.visible=!this.component.state.hidden}updateFillStyle(){const{fillStyle:t}=this.component.state,e=this.object3d.material;if(!e)return;const n=Uh.buildFillStyleTexture(this.component);n?(e.map&&e.map.dispose(),n.needsUpdate=!0,e.map=n):"string"==typeof t&&("transparent"!==t?e.color.set(zh(t)):e.opacity=0)}}class iy extends ny{buildMaterial(){const t=this.object3d.material;t&&t.dispose(),this.object3d.material=new w.SpriteMaterial({map:Dm(this.component),alphaTest:.01,sizeAttenuation:!1})}get scale(){const{width:t,height:e}=this.component.bounds,n=this.threeContainer,{width:i=1,height:r=1}=n?.bounds??{},{scale:s=1}=this.component.state;return{x:s*t/i,y:s*e/r,z:s}}update(){this.build(),this.updateHidden()}updateFillStyle(){this.update()}updateStrokeStyle(){this.update()}updateAlpha(){this.update()}updateText(){this.update()}}const ry={mutable:!1,resizable:!0,rotatable:!0,properties:[]};t.Sprite=class extends($a(Va)){get hasTextProperty(){return!1}is3dish(){return!0}buildRealObject(){return new iy(this)}get nature(){return ry}},t.Sprite=Ep([bm("sprite")],t.Sprite);const sy={mutable:!1,resizable:!0,rotatable:!0,properties:[],help:"scene/component/cube"};class oy extends Rm{buildGeometry(){const{width:t=0,height:e=0,depth:n=0}=this.component.state,i=new w.BoxGeometry(1,1,1);i.scale(t,n,e),this.object3d.geometry=i}}t.Cube=class extends($a(Va)){get hasTextProperty(){return!1}is3dish(){return!0}buildRealObject(){return new oy(this)}get nature(){return sy}},t.Cube=Ep([bm("cube")],t.Cube);const ay={mutable:!1,resizable:!0,rotatable:!0,properties:[],help:"scene/component/cylinder"};class cy extends Rm{buildGeometry(){const{rx:t=0,ry:e=0}=this.component.state,n=this.component.state.depth??1,i=new w.CylinderGeometry(1,1,1,25);i.scale(t||1,n||1,e||1),this.object3d.geometry=i}updateDimension(){this.buildGeometry()}}t.Cylinder=class extends og{get hasTextProperty(){return!1}is3dish(){return!0}buildRealObject(){return new cy(this)}get nature(){return ay}},t.Cylinder=Ep([bm("cylinder")],t.Cylinder);const ly={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"color",label:"box-color",name:"boxColor",property:"boxColor"}],help:"scene/component/banner"};class hy extends Uh{build(){super.build();const{width:t=1,height:e=1,depth:n=1}=this.component.state;this.object3d.add(this.createCube(t,e,n));const i=this.createTextureBoard(t,n);i.position.set(0,0,.5*e+1),this.object3d.add(i)}createCube(t,e,n){const{boxColor:i="#ccaa76"}=this.component.state,r=wh(this.component.state.material3d),s=new w.BoxGeometry(t,n,e),o=new w.MeshStandardMaterial({color:i,side:w.FrontSide});Ah(o,r);const a=new w.Mesh(s,o);return a.castShadow=r.castShadow,a.receiveShadow=r.receiveShadow,a}createTextureBoard(t,e){const n=wh(this.component.state.material3d),{fillStyle:i="#ccaa76"}=this.component.state,r=Uh.buildFillStyleTexture(this.component),s=new w.MeshStandardMaterial(r?{map:r}:{color:i||"#ccaa76",side:w.FrontSide});Ah(s,n);const o=new w.PlaneGeometry(t,e,1,1),a=new w.Mesh(o,s);return a.castShadow=n.castShadow,a.receiveShadow=n.receiveShadow,a}updateMaterial3d(){super.updateMaterial3d();const t=wh(this.component.state.material3d);this.object3d.traverse(e=>{if(e.isMesh){const n=e.material;n&&Ah(n,t),e.castShadow=t.castShadow,e.receiveShadow=t.receiveShadow}})}}var dy;t.Banner=class extends($a(Va)){get hasTextProperty(){return!1}is3dish(){return!0}get nature(){return ly}buildRealObject(){return new hy(this)}},t.Banner=Ep([bm("banner")],t.Banner);const uy={far:1e5,fov:80,near:1,zoom:1},py={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"number",label:"near",name:"near"},{type:"number",label:"far",name:"far"},{type:"number",label:"fov",name:"fov"},{type:"number",label:"zoom",name:"zoom"},{type:"checkbox",label:"show-helper",name:"showHelper"}],help:"scene/component/camera"};class fy extends Uh{getObject3dInstance(){return new w.Mesh}updateCamera(){const{near:t=uy.near,far:e=uy.far,fov:n=uy.fov,zoom:i=uy.zoom,showHelper:r}=this.component.state;this.camera.far=e,this.camera.fov=n,this.camera.near=t,this.camera.zoom=i,r?this.helper||(this.helper=new w.CameraHelper(this.camera),this.object3d.add(this.helper)):this.helper&&(this.object3d.remove(this.helper),delete this.helper)}build(){super.build();const{width:t=0,height:e=0,depth:n=0,fillStyle:i="lightgray"}=this.component.state;this.object3d.geometry=new w.BoxGeometry(t,n,e),this.object3d.material=new w.MeshStandardMaterial({color:i,side:w.FrontSide}),this.camera=new w.PerspectiveCamera,this.camera.position.set(0,0,0),this.object3d.add(this.camera),this.object3d.lookAt(0,0,0),this.updateCamera()}}t.Camera=dy=class extends($a(Va)){get hasTextProperty(){return!1}is3dish(){return!0}static get image(){return dy._image||(dy._image=new Image,dy._image.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA1IAAANSAQMAAABV6G1EAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAABlBMVEX6+voBAQGV71ZvAAAFO0lEQVR42u3dMZLkNBiGYakUKFRIqKOISxDvETiCTBEQcgQOQE7clyAi8REm7KDXIhgYoMa/7fbIX+2K9w022MCP/25Z28GW5RwRERERERERERERERERERERERERERERERERERERERERERERERHRl9mv7fdPn7879sf8Mcq3J3r5EJXaUy3Wddrcd6qNybx9F2/lZ63H+nVCa9Oe9elZa5ksa/dDbE+3fsm4v27C89bd+i6W3l+XdcnSWtuxyvPW+hqorbWb0Jr7Pl3m4tjfVMIZ625d6L5pxTPWw7rQY9P6pqu1dF8aq5d83cE3rXrGWluIxV6h53eotv4c1V3Ln7Nm66ZvvZf8SSues16sD2jubz2sC839fmvYiz7t//LJna27wsr7VjlnNWtPeHTfNlae2bZvnaTePUd+74fqV2LNxv6zdN8O3z9HSWhlc4F+dOvdsKbe2+F7q+zPddq6W2ts6r31vrN825/rtPWwvvcL5losy11uxQNz5U6fYT4w12mrWf80TUNZdetXal/LtwNW6WOFI1Y9bU3GVnfFXM9bneZKwrmKcK4qnKsK52q6uULTzRWFVjpkta/OykKrCq02puWFVhRaSWjlQa0itJrO8oNaQWgloZWFVhnUqjrLN50VBrWi0MpCqwitOqjVdFYQWlFopUGtLLSq0GpjWl5oRaGVBrWy0KpCq+ksP6gVhFYSWllolUGtqrNW/jvBZVYY1IpCKwutIrTqoFbTWUFoxUGtJLSK0KpCq41peaEVhVYa1MpCqwqtprP8oFYUWklo5UGtIrSazvJCKwxqRaGVhVYZ1Ko664ems34UWj8Nav0stBoWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhbW/9L6RWgp37WofIek8j2cyveLTkqrCq0itLLQSkJL+Q5k5budle/HVr73e/24gAHenZ6FlvK9+srzAoLQUp65oDy3QnoeRxFaWWgpz2pRnncThJbyzCDpuUtVaBWhlYWW8qwx5RlqynPovNBSnuUnPaOwCK0stJLQUp4BqjzbVHk+rFNaVWgVoZWFlvJc6Si0lGdzK88cV57bLj2PvgitLLSS0IpCKwgtL7Sc0qpCqwitLLSS0IpCKwgtL7Sc0qpCqwitLLSS0IpCKwgtL7Sc0qpCqwitLLSS0IpCKwgtL7Sc0qpCqwitLLSS0IpCKwgtL7Sc0qpCqxyyahcrH7JKFysJ54rCuYJwLi+cywnn+vdlLp+rCOfKwrnStXP95zLxiJX7WEFoeaHljO/xEqsaf9/FWqz1bM+VzloP655df2uxrnP9XPHKue7OeMDsuWInyx+Y67T1Yv0gs+cKvay6P5fvZZULrdnYFBbbcr2sdKF1MxbZFdZkLLItq3aay6/vJ102eusD2rJKl633nw/o3n+uxbrpLSv1svL6M95hQ3xYNz33t16sC21Zoc+28Xahm+u+Ic7WhbYs1+dRfrvQ5LpvHOaFNq3SZ8n/faEt6twDtli7wrJpxT6P1183/di0Ti36u3XT903Ld1qGrzf9smmdWhyTddNzf8t8UqdtK/dZGq8P2DZ1ZnHcrQ/osWO5PkvDuby7NE58Yctk7Qq3PSv3+bpc3F0aJ56wF+uLX9xu6eOb4es9z/vWc0vR3oZuByjnf2t/fP/54B/2WvvWEREREREREREREREREREREREREREREREREREREREREREREREREX2J/QlrTpqHD8xO1gAAAABJRU5ErkJggg=="),dy._image}render(t){const{left:e,top:n,width:i,height:r}=this.bounds;t.beginPath(),this.drawImage(t,dy.image,e,n,i,r)}buildRealObject(){return new fy(this)}get nature(){return py}},t.Camera=dy=Ep([bm("camera")],t.Camera);const gy={mutable:!1,resizable:!0,rotatable:!0,properties:[...mm],"value-property":"source",help:"scene/component/gltf-object"};t.GLTFObject=class extends(ym($a(Va))){get nature(){return gy}},t.GLTFObject=Ep([bm("gltf-object")],t.GLTFObject);const my={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"select",label:"light-type",name:"lightType",property:{options:["","point","directional"]}},{type:"number",label:"intensity",name:"intensity"},{type:"number",label:"distance",name:"distance"},{type:"number",label:"decay",name:"decay"},{type:"checkbox",label:"cast-shadow",name:"castShadow"},{type:"number",label:"near",name:"near",placeholder:"0.5"},{type:"number",label:"far",name:"far",placeholder:"1000"},{type:"number",label:"fov",name:"fov",placeholder:"90"},{type:"number",label:"zoom",name:"zoom",placeholder:"1"},{type:"checkbox",label:"show-helper",name:"showHelper"}],help:"scene/component/light"};class yy extends Uh{updatePointLight(){const{lightType:t="point",distance:e=0,intensity:n=10,decay:i=1,fillStyle:r="white",castShadow:s,near:o=.5,far:a=1e3,fov:c=90,zoom:l=1,showHelper:h}=this.component.state;if(this.object3d.color=new w.Color(r),"point"==t&&(this.object3d.distance=e,this.object3d.decay=i),this.object3d.intensity=n,this.object3d.castShadow=s,s){const t=this.object3d.shadow?.camera;t.far=a,t.near=o,t.fov=c,t.zoom=l}if(h){const t=this.object3d.shadow?.camera;this.helper||(this.helper=new w.CameraHelper(t),this.object3d.add(this.helper))}else this.helper&&(this.object3d.remove(this.helper),delete this.helper)}getObject3dInstance(){const{lightType:t="point"}=this.component.state;return"point"==t?new w.PointLight:new w.DirectionalLight}update(){this.clear(),this.build(),this.updateDimension(),this.updateHidden(),this.updatePointLight()}}t.PointLight=class extends og{get hasTextProperty(){return!1}is3dish(){return!0}buildRealObject(){return new yy(this)}get anchors(){return[]}get nature(){return my}},t.PointLight=Ep([bm("light")],t.PointLight);const by={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"number",label:"depth",name:"depth",property:"depth"}],help:"scene/component/wall"};class _y extends Rm{buildGeometry(){const{width:t=0,height:e=0,depth:n=0}=this.component.state,i=new w.BoxGeometry(1,1,1);i.scale(t,n,e),this.object3d.geometry=i}}t.Wall=class extends($a(Va)){get hasTextProperty(){return!1}is3dish(){return!0}buildRealObject(){return new _y(this)}get nature(){return by}},t.Wall=Ep([bm("wall")],t.Wall);const vy={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"number",label:"depth",name:"depth",property:"depth"}],help:"scene/component/floor-plate"};class xy extends Uh{clear(){return this._topTexture&&(this._topTexture.dispose(),this._topTexture=void 0),this._mesh=void 0,super.clear()}build(){super.build();const{width:t,height:e,depth:n=1}=this.component.state;if(!t||!e)return;const i=Math.abs(t),r=Math.abs(e),s=Math.max(n,.5),o=new w.BoxGeometry(i,s,r),a=this._buildTopMaterial(),c=this._buildSideMaterial(),l=[c,c,a,c,c,c];this._mesh=new w.Mesh(o,l),this._mesh.position.y=0,this._mesh.receiveShadow=!0,this._mesh.castShadow=!1,this.object3d.add(this._mesh)}_buildTopMaterial(){const{alpha:t=1}=this.component.state,e=wh(this.component.state.material3d),n=Uh.buildFillStyleTexture(this.component);if(n){this._topTexture=n;const i=new w.MeshStandardMaterial({map:n,side:w.DoubleSide,transparent:!0,opacity:t,depthWrite:t>=.9});return Ah(i,e),i}const{fillStyle:i}=this.component.state,r="string"==typeof i&&"none"!==i?i:"#e0e0e0",s=new w.MeshStandardMaterial({color:r,side:w.DoubleSide,transparent:!0,opacity:t,depthWrite:t>=.9});return Ah(s,e),s}_buildSideMaterial(){const{strokeStyle:t,alpha:e=1}=this.component.state,n="string"==typeof t&&t?t:"#999999";return new w.MeshStandardMaterial({color:n,side:w.DoubleSide,transparent:!0,opacity:.8*e,depthWrite:e>=.9})}updateAlpha(){if(!this._mesh)return;const{alpha:t=1}=this.component.state,e=this._mesh.material;for(let n=0;n<e.length;n++){const i=e[n];i.opacity=2===n?t:.8*t,i.transparent=!0,i.depthWrite=t>=.9}}updateFillStyle(){if(!this._mesh)return;this._topTexture&&(this._topTexture.dispose(),this._topTexture=void 0);const t=this._mesh.material;t[2].dispose(),t[2]=this._buildTopMaterial()}updateStrokeStyle(){if(!this._mesh)return;const t=this._mesh.material,e=this._buildSideMaterial();for(let n=0;n<t.length;n++)2!==n&&(t[n].dispose(),t[n]=e)}}t.FloorPlate=class extends Qc{get hasTextProperty(){return!1}is3dish(){return!0}buildRealObject(){return new xy(this)}get nature(){return vy}},t.FloorPlate=Ep([bm("floor-plate")],t.FloorPlate);function wy(t,e={}){const n=e.size??5,i=e.color??4500172,r=e.emissive??2245734,s=new w.SphereGeometry(n,16,12),o=new w.MeshStandardMaterial({color:i,emissive:r,emissiveIntensity:.15,metalness:.3,roughness:.4,transparent:!0,opacity:.35}),a=new w.Mesh(s,o);e.position&&a.position.set(e.position[0],e.position[1],e.position[2]),a.userData.alwaysRaycast=!0,a.scale.setScalar(1),a.visible=e.visible??!!t.app?.isEditMode;const c=()=>{o.emissiveIntensity=.9,o.opacity=.95,a.scale.setScalar(1.35),t.invalidate?.()},l=()=>{o.emissiveIntensity=.15,o.opacity=.35,a.scale.setScalar(1),t.invalidate?.()};return t.on("mouseenter",c),t.on("mouseleave",l),a.userData.dispose=()=>{t.off("mouseenter",c),t.off("mouseleave",l)},a}class My extends Rm{get syncZPosOffset(){return this.effectiveDepth}get geometricOffsetY(){return this.effectiveDepth}buildGeometry(){const{width:t,height:e}=this.component.state,n=Math.abs(t)||1,i=Math.abs(e)||1,r=new w.PlaneGeometry(n,i);r.rotateX(-Math.PI/2),this.object3d.geometry=r}updateDimension(){this.update()}buildMaterial(){super.buildMaterial();const t=this.object3d.material;t&&(t.side=w.DoubleSide)}build(){super.build();const{width:t,height:e}=this.component.state,n=Math.abs(t)||1,i=Math.abs(e)||1,r=Math.max(2,.04*Math.min(n,i));this.object3d.add(wy(this.component,{size:r,position:[n/2-r,r,-i/2+r]}))}}const Sy={mutable:!1,resizable:!0,rotatable:!0,properties:[],help:"scene/component/decal"};let Ay=class extends(fm($a(Va))){buildRealObject(){return new My(this)}get nature(){return Sy}};Ay=Ep([bm("decal")],Ay);class Ey extends Uh{getObject3dInstance(){return new w.Group}get allowedGizmoModes(){return this.component.isGroup?.()?["translate"]:null}}const ky="#dde2e8",Cy="#9c9c9c",Ty="#e8e8ec",Py=.35;function Dy(t,e,n,i){if(!e.visible)return new w.MeshStandardMaterial({transparent:!0,opacity:0,depthWrite:!1});const r=e.alpha*n,s="wall"===i?ky:"floor"===i?Cy:Ty,o=new w.MeshStandardMaterial({metalness:0,roughness:"wall"===i?.6:.85,transparent:r<1,opacity:r,side:w.DoubleSide});return function(t,e,n,i,r,s){if("string"==typeof n&&n&&"transparent"!==n)t.color.set(n);else{if(n&&"object"==typeof n){const i=Uh.buildFillStyleTexture(e,n);if(i){t.map&&t.map.dispose();const e=!s;return i.wrapS=w.RepeatWrapping,e&&(i.repeat.x=-1,i.offset.x=1),r&&(i.center.set(.5,.5),i.rotation=r*Math.PI/180),i.needsUpdate=!0,t.map=i,void t.color.set("#ffffff")}}t.color.set(i)}}(o,t,e.fillStyle,s,e.rotation,e.mirror),o}class Oy extends Ey{get position(){if(this.component.state.fitToBoard){return{x:0,y:super.position.y,z:0}}return super.position}build(){super.build();const t=this.component.state;let e=t.width,n=t.height;if(t.fitToBoard){const t=this.component.rootModel,i=t?.state;i&&Number.isFinite(i.width)&&Number.isFinite(i.height)&&(e=i.width,n=i.height)}const i=this.effectiveDepth||Math.min(e,n)||200,r=t.alpha??1,s={east:this._resolveFace("east",ky,!0,Py),west:this._resolveFace("west",ky,!0,Py),north:this._resolveFace("north",ky,!0,Py),south:this._resolveFace("south",ky,!0,Py),floor:this._resolveFace("floor",Cy,!0,1),ceiling:this._resolveFace("ceiling",Ty,!0,1)},o=[Dy(this.component,s.east,r,"wall"),Dy(this.component,s.west,r,"wall"),Dy(this.component,s.ceiling,r,"ceiling"),Dy(this.component,s.floor,r,"floor"),Dy(this.component,s.south,r,"wall"),Dy(this.component,s.north,r,"wall")],a=new w.BoxGeometry(e,i,n),c=new w.Mesh(a,o);if(c.receiveShadow=!0,this.object3d.add(c),this.component.app?.isEditMode){const t=new w.LineBasicMaterial({color:4473941,transparent:!0,opacity:.7}),e=new w.LineSegments(new w.EdgesGeometry(a),t);this.object3d.add(e)}const l=.04*Math.min(e,n,i);this.object3d.add(wy(this.component,{size:l,position:[e/2,i/2+l,-n/2]}))}_resolveFace(t,e,n,i){const r=this.component.state,s=r.faces?.[t]??{},o=s.visible,a=s.alpha,c=s.rotation,l=90===c||180===c||270===c?c:0;return{fillStyle:s.fillStyle??e,visible:"boolean"==typeof o?o:n,alpha:"number"==typeof a&&Number.isFinite(a)?a:i,rotation:l,mirror:!0===s.mirror}}updateDimension(){}onchange(t,e){["alpha","width","height","depth","fitToBoard","faces"].some(e=>e in t)?this.update():super.onchange(t,e)}updateAlpha(){}}const zy={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"checkbox",label:"fit-to-board",name:"fitToBoard"},{type:"backdrop-faces",label:"",name:"faces"}],help:"scene/component/backdrop"};let Ly=class extends(fm($a(Va))){buildRealObject(){return new Oy(this)}get nature(){return zy}added(t){super.added?.(t),this.state.fitToBoard&&(this._syncFromRoot(!0),this._attachRootListener())}async ready(){await(super.ready?.()),this.state.fitToBoard&&this._syncFromRoot(!1)}removed(t){this._detachRootListener(),super.removed?.(t)}dispose(){this._detachRootListener(),super.dispose?.()}onchange(t,e){"fitToBoard"in t&&(t.fitToBoard?(this._syncFromRoot(!0),this._attachRootListener()):this._detachRootListener()),super.onchange?.(t,e)}_syncFromRoot(t=!1){const e=this.rootModel;if(!e||e===this)return;const n=e.state;if(!n)return;const i={},r=Number.isFinite(n.width)?n.width:this.state.width,s=Number.isFinite(n.height)?n.height:this.state.height;r!==this.state.width&&(i.width=r),s!==this.state.height&&(i.height=s);const o=Number.isFinite(n.left)?n.left:0,a=Number.isFinite(n.top)?n.top:0;if(o!==this.state.left&&(i.left=o),a!==this.state.top&&(i.top=a),t){const t=this.state.depth;if(!("number"==typeof t&&Number.isFinite(t)&&t>0)){const e=Math.min(r,s);e!==t&&(i.depth=e)}}Object.keys(i).length>0&&this.set(i)}_attachRootListener(){if(this._onRootChange)return;const t=this.rootModel;t&&t!==this&&(this._onRootChange=t=>{("width"in t||"height"in t||"left"in t||"top"in t)&&this._syncFromRoot()},t.on?.("change",this._onRootChange))}_detachRootListener(){if(!this._onRootChange)return;const t=this.rootModel;t?.off?.("change",this._onRootChange),this._onRootChange=void 0}};function Iy(t,e){return"none"===t?0:t.endsWith("arrow")?1.5*e:0}function Ry(t,e,n,i){const r=[];for(let s=1;s<=i;s++){const o=s/i,a=1-o;r.push(new w.Vector3(a*a*t.x+2*a*o*e.x+o*o*n.x,a*a*t.y+2*a*o*e.y+o*o*n.y,a*a*t.z+2*a*o*e.z+o*o*n.z))}return r}Ly=Ep([bm("backdrop")],Ly);class jy extends Uh{getObject3dInstance(){return new w.Group}get gizmoTransformable(){return!0}get syncZPosOffset(){return 0}get geometricOffsetY(){return 0}syncFromObject3D(){}applyDimensionFromGizmo(t){}build(){super.build(),this._buildLine()}get smoothedPath(){const t=this.worldPath;if(t.length<2)return t;const{round:e=0}=this.component.state;if(e<=0||t.length<3)return t;const n=[];n.push(t[0]);for(let i=1;i<t.length;i++){const r=t[i-1],s=t[i],o=t[i+1];if(!o){n.push(s);break}const a=r.x-s.x,c=r.y-s.y,l=r.z-s.z,h=Math.sqrt(a*a+c*c+l*l),d=Math.min(e,h/2),u=o.x-s.x,p=o.y-s.y,f=o.z-s.z,g=Math.sqrt(u*u+p*p+f*f),m=Math.min(e,g/2),y=h>0?new w.Vector3(s.x+a/h*d,s.y+c/h*d,s.z+l/h*d):s.clone(),b=g>0?new w.Vector3(s.x+u/g*m,s.y+p/g*m,s.z+f/g*m):s.clone();n.push(y),n.push(...Ry(y,s,b,8))}return n}_buildLine(){const t=this.smoothedPath;if(t.length<2)return;const{strokeStyle:e,lineWidth:n=2,alpha:i=1,lineDash:r,begin:s="none",beginSize:o="size5",end:a="none",endSize:c="size5"}=this.component.state,l=Math.max(n,1),p="string"==typeof e&&"transparent"!==e?zh(e):"#000000",f=new w.Color(p),g=this._getResolution(),m=s,y=a,b=Iy(m,l),_=Iy(y,l),v=t[0],x=t[t.length-1],M=(new w.Vector3).subVectors(t[1],v).normalize(),S=(new w.Vector3).subVectors(t[t.length-2],x).normalize(),A=[...t];b>0&&(A[0]=v.clone().add(M.clone().multiplyScalar(b))),_>0&&(A[A.length-1]=x.clone().add(S.clone().multiplyScalar(_)));const E=new u.LineGeometry;E.setPositions(A.flatMap(t=>[t.x,t.y,t.z]));const k=function(t,e){switch(t){case"round-dot":return{dashSize:e,gapSize:e};case"square-dot":return{dashSize:2*e,gapSize:e};case"dash":return{dashSize:4*e,gapSize:1.5*e};case"dash-dot":return{dashSize:4*e,gapSize:2*e};case"long-dash":return{dashSize:6*e,gapSize:3*e};case"long-dash-dot":return{dashSize:6*e,gapSize:2*e};case"long-dash-dot-dot":return{dashSize:6*e,gapSize:e};default:return null}}(r,l),C=new d.LineMaterial({color:f.getHex(),linewidth:l,worldUnits:!0,transparent:i<1,opacity:i,resolution:g,dashed:!!k,dashSize:k?.dashSize??1,gapSize:k?.gapSize??1,dashScale:1});if(this._line2=new h.Line2(E,C),this._line2.computeLineDistances(),this.object3d.add(this._line2),"none"!==m){const t=Kd(m,qd(o,l));if(t){const e=(new w.Quaternion).setFromUnitVectors(new w.Vector3(1,0,0),M.clone().negate());this._placeTip(t,v,e,f,i,g)}}if("none"!==y){const t=Kd(y,qd(c,l));if(t){const e=(new w.Quaternion).setFromUnitVectors(new w.Vector3(1,0,0),S.clone().negate());this._placeTip(t,x,e,f,i,g)}}}_placeTip(t,e,n,i,r,s){const o=t.mesh||t.line2||t.group;if(o){if(o.position.copy(e),o.setRotationFromQuaternion(n),t.mesh){const e=t.mesh.material;e.color.copy(i),e.transparent=r<1,e.opacity=r}else if(t.line2){const e=t.line2.material;e.color.copy(i),e.transparent=r<1,e.opacity=r,e.resolution.copy(s)}else t.group&&t.group.traverse(t=>{if(t.material){const e=t.material;e.color&&e.color.copy(i),e.transparent=r<1,e.opacity=r,e.resolution&&e.resolution.copy(s)}});this.object3d.add(o)}}_getResolution(){const t=this.threeContainer?.renderer3d;if(t){return t.getSize(new w.Vector2)}return new w.Vector2(window.innerWidth,window.innerHeight)}onGizmoDragEnd(t){const e=this._component,n=e.path;if(!n||n.length<2)return;const i=this.object3d,{width:r=0,height:s=0}=e.parent?.bounds??{},{x:o,y:a}=e.center,c=i.position,l=i.rotation,h=i.scale,d=this.position;if(Math.abs(c.x-d.x)<.001&&Math.abs(c.y-d.y)<.001&&Math.abs(c.z-d.z)<.001&&Math.abs(l.x)<.001&&Math.abs(l.y)<.001&&Math.abs(l.z)<.001&&Math.abs(h.x-1)<.001&&Math.abs(h.y-1)<.001&&Math.abs(h.z-1)<.001)return;const u=jy.computeBakedPath(n,{x:o,y:a},{width:r,height:s},i);this._suppressOnchange=!0,e.set({rotation:0,rotationX:0,rotationY:0,zPos:0}),e.mutatePath(null,()=>u),this._suppressOnchange=!1,this.update()}static computeBakedPath(t,e,n,i){const r=n.width,s=n.height,o=e.x,a=e.y;return i.updateMatrixWorld(!0),t.map(t=>{const e=new w.Vector3(t.x-o,t.z||0,t.y-a).applyMatrix4(i.matrixWorld),n={x:e.x+r/2,y:e.z+s/2};return Math.abs(e.y)>.001&&(n.z=e.y),n})}updateStrokeStyle(){this.updateDimension()}updateAlpha(){this.updateDimension()}updateDimension(){this.clear(),this.build()}onchange(t,e){("path"in t||"from"in t||"to"in t)&&(this.updateDimension(),this.updatePosition()),("round"in t||"lineDash"in t||"lineWidth"in t||"begin"in t||"end"in t||"beginSize"in t||"endSize"in t)&&this.updateDimension(),super.onchange(t,e)}clear(){for(;this.object3d.children.length>0;){const t=this.object3d.children[0];this.object3d.remove(t),Nh(t)}return this._line2=void 0,super.clear()}}class Fy extends jy{get worldPath(){const t=this.component.path;if(!t||t.length<2)return[];const{x:e,y:n}=this.component.center,i=this.component,r=i.fromEnd?.component?._realObject?.object3d?.position?.y??0,s=i.toEnd?.component?._realObject?.object3d?.position?.y??0;return t.map((i,o)=>{const a=t.length>1?o/(t.length-1):0;return new w.Vector3(i.x-e,i.z||r+(s-r)*a,i.y-n)})}}nu("line",t=>new Fy(t));class By extends jy{get worldPath(){const t=this.component.path;if(!t||t.length<2)return[];const{x:e,y:n}=this.component.center;return t.map(t=>new w.Vector3(t.x-e,t.z||0,t.y-n))}}nu("polyline",t=>new By(t));class Ny extends jy{get worldPath(){const t=this.component.drawPath;if(!t||t.length<2)return[];const{x:e,y:n}=this.component.center,i=this.component,r=i.fromEnd?.component?._realObject?.object3d?.position?.y??0,s=i.toEnd?.component?._realObject?.object3d?.position?.y??0;return t.map((i,o)=>{const a=t.length>1?o/(t.length-1):0;return new w.Vector3(i.x-e,i.z||r+(s-r)*a,i.y-n)})}}nu("ortholine",t=>new Ny(t)),nu("group",t=>new Ey(t));class Hy extends Uh{build(){super.build()}update(){}}const Yy={far:1e5,fov:80,near:1,zoom:1};class Gy extends Uh{build(){super.build()}update(){super.update(),this.updateCamera()}getObject3dInstance(){return new w.PerspectiveCamera}updateCamera(){const{near:t=Yy.near,far:e=Yy.far,fov:n=Yy.fov,zoom:i=Yy.zoom}=this.component.state;this.object3d.far=e,this.object3d.fov=n,this.object3d.near=t,this.object3d.zoom=i}}class Vy extends Rm{buildGeometry(){const{width:t,height:e}=this.component.state.dimension;this.object3d.geometry=new w.PlaneGeometry(t,e)}buildMaterial(){this.object3d.material=new w.MeshStandardMaterial({opacity:0,side:w.DoubleSide,blending:w.NoBlending})}}class Uy extends Uh{getObject3dInstance(){return new w.Scene}dispose(){for(const t of this.object3d.children)Nh(t);this._animationMixer&&(this._animationMixer.stopAllAction(),this._animationMixer.uncacheRoot(this.object3d),this._animationMixer=void 0),super.dispose()}clear(){return this._floor&&(this.object3d.remove(this._floor),this._floor.material instanceof Array?this._floor.material.forEach(t=>t.dispose()):this._floor.material.dispose(),this._floor.geometry.dispose(),delete this._floor),super.clear()}get floor(){return this._floor}set floor(t){this._floor&&(this.object3d.remove(this._floor),this._floor.clear(),delete this._floor),t&&(this._floor=t,this.object3d.add(t)),this.component.invalidate()}build(){super.build(),this.floor=cu(this.component)}updateTransform(){}updateDimension(){}updatePosition(){}updateRotate(){}updateScale(){}updateAlpha(){}updateHidden(){}get animationMixer(){return this._animationMixer||(this._animationMixer=new w.AnimationMixer(this.object3d)),this._animationMixer}}const $y=new Set(["cx","cy","cz","zPos","left","top","width","height","depth","lineWidth","rotationX","rotationY","rotation","scale","hidden","alpha","material3d","screenFixed"]);class Wy extends Uh{get syncZPosOffset(){return this.effectiveDepth}get geometricOffsetY(){return this.effectiveDepth}constructor(t){super(t),this._origInvalidate=t.invalidate.bind(t),t.invalidate=()=>{this._origInvalidate(),this._refreshTextureNow()}}getObject3dInstance(){return new w.Mesh}build(){super.build();const{width:t,height:e}=this.component.bounds;if(!t||!e)return;const n=wh(this.component.state.material3d),i=new w.PlaneGeometry(1,1);i.rotateX(-Math.PI/2),this.object3d.geometry=i;const r=Dm(this.component);this.object3d.material=new w.MeshStandardMaterial({map:r,transparent:!0,side:w.DoubleSide,metalness:n.metalness,roughness:n.roughness,emissive:new w.Color(n.emissive),emissiveIntensity:n.emissiveIntensity}),this.object3d.castShadow=n.castShadow,this.object3d.receiveShadow=n.receiveShadow}updateAlpha(){const{alpha:t=1,fillStyle:e}=this.component.state;Oh(this.object3d.material,t,e)}updateHidden(){this.object3d.visible=!this.component.state.hidden}get dimension(){const{width:t,height:e}=this.component.bounds;return{width:t||1,height:e||1,depth:1}}get scale(){const t=super.scale,{width:e,height:n}=this.dimension;return{x:t.x*e,y:t.y,z:t.z*n}}updateDimension(){this.updateTransform()}_debouncedRebuild(){this._debounceTimer&&clearTimeout(this._debounceTimer),this._debounceTimer=setTimeout(()=>{this._debounceTimer=void 0,this.update()},100)}_refreshTextureNow(){const t=this.object3d.material,e=t?.map;if(!e)return;const n=e.source?.data;n&&(zm(n,this.component,2),e.needsUpdate=!0)}update(){this.clear(),this.build(),this.updateDimension(),this.updateTransform(),this.updateHidden()}onchange(t,e){super.onchange(t,e);for(const e of Object.keys(t))if(!$y.has(e)){this._debouncedRebuild();break}}updateFillStyle(){this._debouncedRebuild()}updateStrokeStyle(){this._debouncedRebuild()}updateText(){this._debouncedRebuild()}updateMaterial3d(){super.updateMaterial3d();const t=this.object3d.material;if(!t)return;const e=wh(this.component.state.material3d);t.metalness=e.metalness,t.roughness=e.roughness,t.emissive.set(e.emissive),t.emissiveIntensity=e.emissiveIntensity}clear(){return this._debounceTimer&&(clearTimeout(this._debounceTimer),this._debounceTimer=void 0),Nh(this.object3d),super.clear()}dispose(){this._debounceTimer&&(clearTimeout(this._debounceTimer),this._debounceTimer=void 0),this._origInvalidate&&(this.component.invalidate=this._origInvalidate,this._origInvalidate=void 0),super.dispose()}}const Xy={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"select",label:"precision",name:"precision",property:{options:[{display:"High",value:"highp"},{display:"Medium",value:"mediump"},{display:"Low",value:"lowp"}]}},{type:"checkbox",label:"anti-alias",name:"antialias",property:"antialias"},{type:"checkbox",label:"3dmode",name:"threed",property:"threed"},{type:"checkbox",label:"auto-rotate",name:"autoRotate",property:"autoRotate"},{type:"checkbox",label:"debug",name:"debug",property:"debug"}],help:"scene/component/three-container"};var qy;t.ThreeContainer=class extends Vf{constructor(){super(...arguments),this._capability=new Du}get sceneManager(){return this._capability.sceneManager}get cameraManager(){return this._capability.cameraManager}get rendererManager(){return this._capability.rendererManager}get lightManager(){return this._capability.lightManager}get controlsManager(){return this._capability.controlsManager}get eventManager(){return this._capability.eventManager}containable(t){return!0}is3dContainer(){return!0}getLightingConfig(){return{hemisphere:{skyColor:16777215,groundColor:14540253,intensity:1},directional:{color:16777215,intensity:1.2,attachToCamera:!0,castShadow:!1}}}getCss3DSceneAttribute(){return"three-container:css3d-renderer"}init_scene3d(){this._capability.isInitialized&&this._capability.destroy(),this._capability.init(this,{lightingConfig:this.getLightingConfig(),css3DSceneAttribute:this.getCss3DSceneAttribute(),skipEnvironment:!0,skipPostprocessing:!0,skipShadowMap:!0}),this._capability.buildOverlays(),this._capability.resize(),this.onchangeData&&this.onchangeData(this.data,this.data)}destroy_scene3d(){this.stop(),this._capability.destroy()}stop(){}resize(){this._capability.resize()}get scene3d(){return this._capability.isInitialized||this.init_scene3d(),this._capability.scene3d}get renderer3d(){return this._capability.renderer3d}get mixer(){return this._capability.mixer}get css3DScene(){return this._capability.css3DScene}get css3DRenderer(){return this._capability.css3DRenderer}render_threed(){this._capability.renderThreeD()}get _parentIs3dMode(){return!!this.rootModel?.is3dMode}render(t){this._parentIs3dMode||(this.app.isViewMode&&this.setState("threed",!0),!this.state.threed||this._capability.noSupportWebgl?super.render(t):this._capability.camera&&this._capability.renderCSS3D())}postrender(t){if(this._parentIs3dMode)return;const{left:e,top:n,debug:i,threed:r}=this.state;let{width:s,height:o}=this.bounds;if(s=Math.floor(s),o=Math.floor(o),r){if(this._capability.isInitialized||this.init_scene3d(),this._capability.noSupportWebgl)return void this._capability.showWebglNoSupportText(t,this.state.width,this.state.height);if(!this._capability.renderer3d)return;this._capability.renderThreeD();const r=this._capability.domElement;if(!r||!r.width||!r.height)return;t.drawImage(r,0,0,r.width,r.height,e,n,s,o),i&&this._capability.showDebugFPS(t)}else super.postrender(t)}dispose(){this._capability.dispose(),super.dispose()}get layout(){return Za.get("three")}get nature(){return Xy}getObjectByRaycast(){return this._capability.getObjectByRaycast()}getObjectsByRaycast(){return this._capability.getObjectsByRaycast()}onchange(t,e){(t.hasOwnProperty("width")||t.hasOwnProperty("height"))&&this._capability.destroy(),this._capability.onchange(t)}onmousedown(t){this._capability.onMouseDown(t)}onmouseup(t){this._capability.onMouseUp(t)}onmousemove(t){this._capability.onMouseMove(t)}onmouseleave(t){this._capability.onMouseLeave(t)}onwheel(t){this._capability.onWheel(t)&&this.invalidate()}ondblclick(t){this._capability.onDblClick(t)&&this.invalidate()}ondragstart(t){this._capability.onDragStart(t)}ondragmove(t){this._capability.onDragMove(t)&&this.invalidate()}ondragend(t){this._capability.onDragEnd(t)&&this.invalidate()}ontouchstart(t){this._capability.onTouchStart(t)}onpan(t){this._capability.onPan(t)&&this.invalidate()}ontouchend(t){this._capability.onTouchEnd(t)}onkeydown(t){this._capability.onKeyDown(t)}onpinch(t){this._capability.onPinch(t)&&this.invalidate()}ondoubletap(){this._capability.onDoubleTap(),this.invalidate()}},t.ThreeContainer=Ep([bm("3d-container")],t.ThreeContainer),iu(t=>new Im(t)),t.Model=void 0,(qy=t.Model||(t.Model={})).compile=Lc,qy.duplicate=Ic,qy.select=ma,qy.match=pa,wi.registerResidents(()=>({componentResidentsCount:Ga.residentsCount,sceneResidentsCount:id.residentsCount,referenceMapResidentsCount:xm.residentsCount,sceneResidents:Ga.residents}));var Ky=Object.freeze({__proto__:null,AbsoluteLayout:tc,Animation:No,AudioPlayer:Fg,get Banner(){return t.Banner},Banner3D:hy,BoxSelectionManager:ku,COMMON_PLACEHOLDER_PROPERTIES:cg,CORE_PLACEHOLDER_TYPES:ug,get Camera(){return t.Camera},Camera3D:fy,CameraBookmarkManager:Eu,CameraManager:du,CardLayout:nc,Component:Ga,Connectable:Vu,Container:Vf,ContainerAbstract:Qc,ControlsManager:gu,get Cube(){return t.Cube},Cube3D:oy,get Cylinder(){return t.Cylinder},Cylinder3D:cy,DEFAULT:Ar,DPPX:wr,DataLagTracker:nl,DataSource:pm,Donut:im,DonutExtrude:Qm,Ellipse:og,EllipseExtrude:Xm,EventManager3D:mu,EventMap:Tc,FPS:Ud,get FloorPlate(){return t.FloorPlate},GESTURES:Mr,get GLTFObject(){return t.GLTFObject},GLTF_BASE_URL_ALIAS:gm,GenericObject:dg,GifView:Rg,GizmoManager:bu,GizmoOperationManager:xu,GlobalRef:$g,GltfComponent:ym,Group:Hg,HTMLAbsoluteLayout:Ja,HTMLOverlayContainer:Vg,HTMLOverlayElement:Sg,ImageView:Mg,InfoWindow:Ka,InteractionManager:wu,KEYEVENTS:Sr,Layer:Md,Layout:Za,LightManager:pu,LightObject:yy,Line:rg,Line3D:Fy,LinearHorizontalLayout:rc,LinearVerticalLayout:oc,LoadTracker:rl,LoadingOverlay:Ph,LocalRef:Gg,MATERIAL_PRESETS:xh,MAX_UNDO_SIZE:30,MODE_ADD:3,MODE_EDIT:1,MODE_PASTE_DATABIND:5,MODE_PASTE_STYLE:4,MODE_SHIFT:2,MODE_VIEW:0,get Model(){return t.Model},MoveHandle:qc,NOTHING:vr,Node:cm,OrthoLine:xg,OrthoLine3D:Ny,PIXEL_RATIO:$d,PLACEHOLDER_THEMES:ag,Path:Zg,PlacementManager:Mu,get PointLight(){return t.PointLight},Polygon:mg,PolygonExtrude:Km,Polyline:_g,Polyline3D:By,Popup:qg,PopupContainer:Qg,RealObject:Uh,RealObjectCamera:Gy,RealObjectDomElement:Jd,RealObjectDomTexture:Im,RealObjectDummy:Hy,RealObjectExternalModel:$h,RealObjectExtrude:Wm,RealObjectGLTF:Kh,RealObjectGroup:Ey,RealObjectLine:jy,RealObjectMesh:Rm,RealObjectPlane:Vy,RealObjectPlane2D:Wy,RealObjectScene:Uy,RealObjectService:lm,RealObjectSprite:ny,RealObjectSprite2D:iy,RealObjectText:Gm,Rect:Wu,RectExtrude:qm,RectPath:$a,ReferenceMap:xm,RendererManager:uu,RootContainer:tl,Ruler:qu,SCALE_MIN:Dh,SCENE_MODE:xr,Scene:id,SceneManager:hu,ScenePopup:wd,SceneSearchEngine:Zh,ScriptLoader:Cm,SearchOverlay:td,ServiceComponent:dm,Shape:Va,get Sphere(){return t.Sphere},Sphere3D:ey,get Sprite(){return t.Sprite},Star:om,StarExtrude:Jm,TableLayout:ac,Text:Bg,ThreeCapability:Du,get ThreeContainer(){return t.ThreeContainer},ThreeDOnly:fm,TransitionEffect:Wc,Triangle:tm,TriangleExtrude:Zm,UNIT_DIMENSION:Lh,UNIT_ROTATE:jh,UNIT_SCALE:Ih,UNIT_TRANSLATE:Rh,ValueHolder:um,VertexGizmoManager:Pu,get Wall(){return t.Wall},Wall3D:_y,animate:Bo,applyAlpha:Oh,applyMaterial3dProps:Ah,buildArrow3D:Zd,buildTether:pd,clearTether:gd,compile:Yo,create:sd,createCanvas:Wd,createCanvasTexture:Dm,createFloor:cu,createRealObjectFor:ru,createSelectionHandle3D:wy,debug:Bi,delta:jo,disposeObject3D:Nh,disposeTether:md,drawTextTexture:Bm,error:ji,fontStyle:jm,gltfNatureProperties:mm,initFontFamilyWatcher:kr,inspector:Eh,isGenericPlaceholder:pg,metrics:wi,opaqueColor:zh,projectToScreen:ld,registerDefaultRealObjectFactory:iu,registerRealObjectFactory:nu,renderCanvasTexture:Om,renderPlaceholder:lg,resolveAnchorWorldPosition:ud,resolveMaterial3d:wh,sceneComponent:bm,stopFPSMeasure:Vd,textBounds:Ym,textTexture:Nm,toThreeSide:Sh,updateDefaultFontFamily:Er,updateTether:fd,version:Tm,warn:Fi});const Qy=globalThis;"undefined"==typeof globalThis||Qy.scene||(Qy.scene=Ky),t.AbsoluteLayout=tc,t.Animation=No,t.AudioPlayer=Fg,t.Banner3D=hy,t.BoxSelectionManager=ku,t.COMMON_PLACEHOLDER_PROPERTIES=cg,t.CORE_PLACEHOLDER_TYPES=ug,t.Camera3D=fy,t.CameraBookmarkManager=Eu,t.CameraManager=du,t.CardLayout=nc,t.Component=Ga,t.Connectable=Vu,t.Container=Vf,t.ContainerAbstract=Qc,t.ControlsManager=gu,t.Cube3D=oy,t.Cylinder3D=cy,t.DEFAULT=Ar,t.DPPX=wr,t.DataLagTracker=nl,t.DataSource=pm,t.Donut=im,t.DonutExtrude=Qm,t.Ellipse=og,t.EllipseExtrude=Xm,t.EventManager3D=mu,t.EventMap=Tc,t.FPS=Ud,t.GESTURES=Mr,t.GLTF_BASE_URL_ALIAS=gm,t.GenericObject=dg,t.GifView=Rg,t.GizmoManager=bu,t.GizmoOperationManager=xu,t.GlobalRef=$g,t.GltfComponent=ym,t.Group=Hg,t.HTMLAbsoluteLayout=Ja,t.HTMLOverlayContainer=Vg,t.HTMLOverlayElement=Sg,t.ImageView=Mg,t.InfoWindow=Ka,t.InteractionManager=wu,t.KEYEVENTS=Sr,t.Layer=Md,t.Layout=Za,t.LightManager=pu,t.LightObject=yy,t.Line=rg,t.Line3D=Fy,t.LinearHorizontalLayout=rc,t.LinearVerticalLayout=oc,t.LoadTracker=rl,t.LoadingOverlay=Ph,t.LocalRef=Gg,t.MATERIAL_PRESETS=xh,t.MAX_UNDO_SIZE=30,t.MODE_ADD=3,t.MODE_EDIT=1,t.MODE_PASTE_DATABIND=5,t.MODE_PASTE_STYLE=4,t.MODE_SHIFT=2,t.MODE_VIEW=0,t.MoveHandle=qc,t.NOTHING=vr,t.Node=cm,t.OrthoLine=xg,t.OrthoLine3D=Ny,t.PIXEL_RATIO=$d,t.PLACEHOLDER_THEMES=ag,t.Path=Zg,t.PlacementManager=Mu,t.Polygon=mg,t.PolygonExtrude=Km,t.Polyline=_g,t.Polyline3D=By,t.Popup=qg,t.PopupContainer=Qg,t.RealObject=Uh,t.RealObjectCamera=Gy,t.RealObjectDomElement=Jd,t.RealObjectDomTexture=Im,t.RealObjectDummy=Hy,t.RealObjectExternalModel=$h,t.RealObjectExtrude=Wm,t.RealObjectGLTF=Kh,t.RealObjectGroup=Ey,t.RealObjectLine=jy,t.RealObjectMesh=Rm,t.RealObjectPlane=Vy,t.RealObjectPlane2D=Wy,t.RealObjectScene=Uy,t.RealObjectService=lm,t.RealObjectSprite=ny,t.RealObjectSprite2D=iy,t.RealObjectText=Gm,t.Rect=Wu,t.RectExtrude=qm,t.RectPath=$a,t.ReferenceMap=xm,t.RendererManager=uu,t.RootContainer=tl,t.Ruler=qu,t.SCALE_MIN=Dh,t.SCENE_MODE=xr,t.Scene=id,t.SceneManager=hu,t.ScenePopup=wd,t.SceneSearchEngine=Zh,t.ScriptLoader=Cm,t.SearchOverlay=td,t.ServiceComponent=dm,t.Shape=Va,t.Sphere3D=ey,t.Star=om,t.StarExtrude=Jm,t.TableLayout=ac,t.Text=Bg,t.ThreeCapability=Du,t.ThreeDOnly=fm,t.TransitionEffect=Wc,t.Triangle=tm,t.TriangleExtrude=Zm,t.UNIT_DIMENSION=Lh,t.UNIT_ROTATE=jh,t.UNIT_SCALE=Ih,t.UNIT_TRANSLATE=Rh,t.ValueHolder=um,t.VertexGizmoManager=Pu,t.Wall3D=_y,t.animate=Bo,t.applyAlpha=Oh,t.applyMaterial3dProps=Ah,t.buildArrow3D=Zd,t.buildTether=pd,t.clearTether=gd,t.compile=Yo,t.create=sd,t.createCanvas=Wd,t.createCanvasTexture=Dm,t.createFloor=cu,t.createRealObjectFor=ru,t.createSelectionHandle3D=wy,t.debug=Bi,t.delta=jo,t.disposeObject3D=Nh,t.disposeTether=md,t.drawTextTexture=Bm,t.error=ji,t.fontStyle=jm,t.gltfNatureProperties=mm,t.initFontFamilyWatcher=kr,t.inspector=Eh,t.isGenericPlaceholder=pg,t.metrics=wi,t.opaqueColor=zh,t.projectToScreen=ld,t.registerDefaultRealObjectFactory=iu,t.registerRealObjectFactory=nu,t.renderCanvasTexture=Om,t.renderPlaceholder=lg,t.resolveAnchorWorldPosition=ud,t.resolveMaterial3d=wh,t.sceneComponent=bm,t.stopFPSMeasure=Vd,t.textBounds=Ym,t.textTexture=Nm,t.toThreeSide=Sh,t.updateDefaultFontFamily=Er,t.updateTether=fd,t.version=Tm,t.warn=Fi});
|
|
72
|
+
`,this.element)}catch(t){}}onchangeMinimized(){const{minimized:t}=this.state;t?this.setState("height",24):this.setState("height",this.get("height"))}}Hf=new WeakMap,Va.memoize(Uf.prototype,"bounds",!0),Va.register("container",Uf);const $f=Math.sqrt(3),Wf=2;function Xf(t,e,n,i,r){const s=5+r,o=n.x,a=n.y,c=i.x,l=i.y;if(Math.abs(o-c)>s&&Math.abs(a-l)>s){const n=(l-a)/(c-o),i=a-n*o;if(Math.abs(e-(n*t+i))>s)return!1}let h,d,u,p;return o>c?(d=o,h=c):(d=c,h=o),a>l?(p=a,u=l):(p=l,u=a),!(d+5<t)&&(!(h-5>t)&&(!(p+5<e)&&!(u-5>e)))}function qf(t,e,n,i=2){for(let r=0;r<n.length-1;r++)if(Xf(t,e,n[r],n[r+1],i))return!0;return!1}function Kf(t,e,n,i){if("arrow"!=t.slice(-5))return n;const r=Math.atan2(i.y-n.y,i.x-n.x),s=1.5*e;return{x:n.x+Math.cos(r)*s,y:n.y+Math.sin(r)*s}}function Qf(t,e,n){let{lineWidth:i=Wf,strokeStyle:r="#000000",lineCap:s=!1,alpha:o=1,begin:a="none",end:c="none",beginSize:l="size5",endSize:h="size5"}=n;if(("none"!=a||"none"!=c)&&(i=Number(i)||Wf,t.lineCap=s,t.lineWidth=i,t.strokeStyle=r,t.fillStyle=r,t.globalAlpha*=o,"none"!=a&&Zf(t,e[0],e[1],i,a,Jf(l,i)),"none"!=c)){const n=e.length;Zf(t,e[n-1],e[n-2],i,c,Jf(h,i))}}function Zf(t,e,n,i,r,s){const{x:o,y:a}=e,c=Math.atan2(n.y-a,n.x-o);switch(t.beginPath(),t.translate(o,a),t.rotate(c),r){case"oval":t.ellipse(0,0,s.X,s.Y,0,0,2*Math.PI),t.fill();break;case"diamond":t.moveTo(-s.X,0),t.lineTo(0,-s.Y),t.lineTo(s.X,0),t.lineTo(0,s.Y),t.fill();break;case"arrow":t.moveTo(0,0),t.lineTo($f*s.X,-s.Y),t.lineTo($f*s.X,s.Y),t.fill();break;case"sharp-arrow":t.moveTo(0,0),t.lineTo($f*s.X,-s.Y),t.lineTo(-s.X/1.5+$f*s.X,0),t.lineTo($f*s.X,s.Y),t.fill();break;case"open-arrow":t.moveTo($f*s.X+i,-s.Y),t.lineTo(i,0),t.lineTo($f*s.X+i,s.Y),t.stroke();break;case"cross":t.moveTo(-s.X,-s.Y),t.lineTo(s.X,s.Y),t.moveTo(s.X,-s.Y),t.lineTo(-s.X,s.Y),t.stroke()}t.rotate(-c),t.translate(-o,-a),t.closePath()}function Jf(t,e){const n={X:0,Y:0};switch(e*=1.2,t){case"size1":n.X=e,n.Y=e;break;case"size2":n.X=1.5*e,n.Y=e;break;case"size3":n.X=2*e,n.Y=e;break;case"size4":n.X=e,n.Y=1.5*e;break;case"size5":default:n.X=1.5*e,n.Y=1.5*e;break;case"size6":n.X=2*e,n.Y=1.5*e;break;case"size7":n.X=e,n.Y=2*e;break;case"size8":n.X=1.5*e,n.Y=2*e;break;case"size9":n.X=2*e,n.Y=2*e}return n}const tg="N",eg="S",ng="E",ig="W";class rg{constructor({component:t,anchor:e,position:n,self:i}){this.component=t,this._anchorName=e,this._position=n,this.self=i}get position(){const t=this.anchor;if(t){const{position:e}=t,n=this.component.toScene(e.x,e.y);return this.self.transcoordT2P(n.x,n.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 ng;const n=e.position;return n.y<=t.top?tg:n.y>=t.top+t.height?eg:n.x<=t.left?ig:ng}get boundaryPosition(){const t=this.anchor;if(t){let{position:e}=t,n=0,i=0;switch(this.direction){case eg:i=20;break;case tg:i=-20;break;case ig:n=-20;break;default:n=20}e={x:e.x+n,y:e.y+i};const r=this.component.toScene(e.x,e.y);return this.self.transcoordT2P(r.x,r.y)}}}class sg extends Va{isLine(){return!0}is3dish(){return!0}replaceRefids(t){["from","to"].forEach(e=>{const n=this.get(e);if(n?.component){const i=t.get(n.component)||n.component;this.set(e,{...n,component:i})}})}get fromEnd(){if(this.parent&&!this._fromEnd){const{component:t,anchor:e,position:n}=this.getState("from")||{};if(!t)return;const i=this.root?.findByRefid?.(t);if(!i)return;this._fromEnd=new rg({component:i,fromto:"from",anchor:e,position:n,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:n}=this.getState("to")||{};if(!t)return;const i=this.root?.findByRefid?.(t);if(!i)return;this._toEnd=new rg({component:i,fromto:"to",anchor:e,position:n,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},n){n&&(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})}render(t){const{begin:e="none",end:n="none",lineWidth:i,round:r=0}=this.state;let s=this.drawPath;Qf(t,s,this.state),t.beginPath();const o=Kf(e,i,s[0],s[1]),a=Kf(n,i,s[s.length-1],s[s.length-2]);s=[o,...s.slice(1,-1),a];let c={x:o.x,y:o.y};t.moveTo(o.x,o.y);for(let e=1;e<s.length;e++){const n=c;c=s[e];const i=s[e+1];if(n.x===c.x&&n.y===c.y)continue;if(!i){t.lineTo(c.x,c.y);break}let o=Math.sqrt((n.x-c.x)*(n.x-c.x)+(n.y-c.y)*(n.y-c.y)),a=0!==o?Math.atan2(n.x-c.x,n.y-c.y):0,l=Math.sin(a)*Math.min(r,o/2)+c.x,h=Math.cos(a)*Math.min(r,o/2)+c.y;const d=r>0||0!==o?{x:l,y:h}:c;o=Math.sqrt((i.x-c.x)*(i.x-c.x)+(i.y-c.y)*(i.y-c.y)),a=0!==o?Math.atan2(i.x-c.x,i.y-c.y):0,l=Math.sin(a)*Math.min(r,o/2)+c.x,h=Math.cos(a)*Math.min(r,o/2)+c.y;const u=r>0||0!==o?{x:l,y:h}:c;t.lineTo(d.x,d.y),r>0&&t.quadraticCurveTo(c.x,c.y,u.x,u.y)}this.drawStroke(t,void 0)}contains(t,e){const{lineWidth:n}=this.state;return qf(t,e,this.drawPath,n)}get resizable(){return!1}get mutable(){return!0}get rotatable(){return!1}get path(){const{from:t,to:e}=this.state,{x1:n,y1:i,x2:r,y2:s}=this.state;return[this.fromEnd?.position||t?.position||{x:n,y:i},this.toEnd?.position||e?.position||{x:r,y:s}]}set path(t){const[e,n]=t,{from:i,to:r}=this.state;delete this._fromEnd,delete this._toEnd,this.set({from:{...i,position:e},to:{...r,position:n}})}get textBounds(){const t=this.drawPath;let e,n,i=0;for(let r=1;r<t.length;r++){const s=t[r-1],o=t[r],a=(s.x-o.x)*(s.x-o.x)+(s.y-o.y)*(s.y-o.y);a>i&&(i=Math.ceil(a),e=s,n=o)}let{paddingTop:r,paddingLeft:s,paddingRight:o,paddingBottom:a}=this.state;return a||=0,r||=0,s||=0,o||=0,{left:Math.min(e.x,n.x)+s,top:Math.min(e.y,n.y)+r,width:Math.max(Math.abs(e.x-n.x)-s-o,0),height:Math.max(Math.abs(e.y-n.y)-r-a,0)}}get decorators(){return this.app.isEditMode?["decotag"]:[]}}sg.getTipNeckPos=Kf,sg.containedInPath=qf,sg.drawEndTips=Qf,Va.register("line",sg);const og={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 ag extends(Uu(Ua)){is3dish(){return!0}render(t){const{cx:e,cy:n,rx:i,ry:r,startAngle:s,endAngle:o,anticlockwise:a}=this.state;t.beginPath(),t.ellipse(e,n,Math.abs(i),Math.abs(r),0,s||0,o||2*Math.PI,a),void 0!==s&&void 0!==o&&(t.lineTo(e,n),t.closePath())}get path(){const{cx:t,cy:e,rx:n,ry:i}=this.state;return[{x:t-n,y:e-i},{x:t+n,y:e-i},{x:t+n,y:e+i},{x:t-n,y:e+i}]}set path(t){const e=t[0],n=t[2];this.set({cx:e.x+(n.x-e.x)/2,cy:e.y+(n.y-e.y)/2,rx:(n.x-e.x)/2,ry:(n.y-e.y)/2})}contains(t,e){const{cx:n,cy:i,rx:r,ry:s}=this.state,o=(t-n)/(2*r-.5),a=(e-i)/(2*s-.5);return o*o+a*a<.25}outline(t){return function(t,e){const{cx:n,cy:i,rx:r,ry:s}=t.model,o=2*Math.PI*e,a=n+r*Math.cos(o),c=i+s*Math.sin(o);return t.toScene(a,c)}(this,t)}get anchors(){return function(t){const{left:e,top:n,width:i,height:r}=t.bounds,s=e+i/2,o=n+r/2;return[{name:"TOP",position:{x:s,y:n}},{name:"RIGHT",position:{x:e+i,y:o}},{name:"BOTTOM",position:{x:s,y:n+r}},{name:"LEFT",position:{x:e,y:o}}]}(this)}get nature(){return og}}Va.memoize(ag.prototype,"path",!1),Va.register("ellipse",ag);const cg={object:{fill:"rgba(180,180,180,0.18)",stroke:"#888888",icon:"?",label:"object"},transport:{fill:"rgba(100,180,255,0.18)",stroke:"#3a78c8",icon:"⇄",label:"transport"},facility:{fill:"rgba(160,140,220,0.18)",stroke:"#6b4ec8",icon:"◫",label:"facility"},vehicle:{fill:"rgba(120,200,140,0.18)",stroke:"#3a8c5e",icon:"⊙",label:"vehicle"},region:{fill:"rgba(220,200,100,0.18)",stroke:"#a0892a",icon:"▢",label:"region"},path:{fill:"rgba(200,140,160,0.18)",stroke:"#a0506a",icon:"⌐",label:"path"},"3d-asset":{fill:"rgba(255,180,80,0.18)",stroke:"#c87a2a",icon:"◈",label:"3D asset"}},lg=[{type:"string",label:"placeholder-label",name:"placeholderLabel",description:'사용자에게 표시할 추가 라벨 (예: "Stocker A1")'},{type:"string",label:"hint",name:"placeholderHint",description:"구체화 시 참고 — 도면의 원본 식별자 / VLM 라벨 등"}];function hg(t,e,n,i,r){const{left:s,top:o,width:a,height:c}=e,l=Math.max(a,1),h=Math.max(c,1);t.save(),t.fillStyle=n.fill,t.fillRect(s,o,l,h),t.strokeStyle=n.stroke,t.lineWidth=1.5,t.setLineDash([4,3]),t.strokeRect(s,o,l,h),t.setLineDash([]),t.restore(),Math.min(l,h)>=24&&(t.save(),t.fillStyle=n.stroke,t.font=`bold ${Math.min(20,.4*Math.min(l,h))}px Arial`,t.textAlign="center",t.textBaseline="middle",t.fillText(n.icon,s+l/2,o+h/2),t.restore());const d=i?`${n.label}: ${i}`:n.label;h>=32&&(t.save(),t.fillStyle=n.stroke,t.font="10px Arial",t.textAlign="center",t.textBaseline="bottom",t.fillText(d,s+l/2,o+h-4),t.restore()),r&&h>=40&&(t.save(),t.fillStyle=n.stroke,t.font="9px Arial",t.textAlign="right",t.textBaseline="top",t.fillText(`hint: ${r}`,s+l-4,o+4),t.restore())}const dg={mutable:!1,resizable:!0,rotatable:!0,properties:[...lg,{type:"placeholder-convert",label:"",name:"_convert"}],help:"scene/component/placeholder"};class ug extends(Wa(Ua)){get nature(){return dg}render(t){const{placeholderLabel:e,placeholderHint:n}=this.state;hg(t,this.bounds,cg.object,e,n)}}Va.register("placeholder",ug);const pg=["placeholder"];function fg(t,e=[]){return!!t&&(!!pg.includes(t)||e.includes(t))}const gg={ondragstart:function(t,e,n){n.mutatePath(null,function(n){n.splice(e+1,0,t)})},ondragmove:function(t,e,n){n.mutatePath(null,function(n){n[e+1]=t})},ondragend:function(t,e,n){}},mg={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 yg extends Ua{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){const n=this.state.path;let i=!1;return n.forEach((r,s)=>{const o=(s+n.length+1)%n.length,a=r.x,c=r.y,l=n[o].x,h=n[o].y;c>e!=h>e&&t<(l-a)*(e-c)/(h-c)+a&&(i=!i)}),i}get controls(){const t=this.path;return t.map((e,n)=>{const i=t[n+1>=t.length?0:n+1];return{x:(e.x+i.x)/2,y:(e.y+i.y)/2,handler:gg}})}get nature(){return mg}}Va.memoize(yg.prototype,"controls",!1),Va.register("polygon",yg);const bg={ondragstart:function(t,e,n){n.mutatePath(null,function(n){n.splice(e,0,t)})},ondragmove:function(t,e,n){n.mutatePath(null,function(n){n[e]=t})},ondragend:function(t,e,n){}},_g={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 vg extends sg{get pathExtendable(){return!0}get path(){const{from:t,to:e}=this.state,{path:n}=this.state;return[this.fromEnd?.position||t?.position||n[0],...n.slice(1,-1),this.toEnd?.position||e?.position||n[n.length-1]]}set path(t){const{from:e,to:n}=this.state;delete this._fromEnd,delete this._toEnd,this.set({from:{...e,position:t[0]},to:{...n,position:t[t.length-1]},path:t})}get controls(){const t=this.path,e=[];for(let n=0;n<t.length-1;n++){const i=t[n],r=t[n+1];0==n&&e.push({x:i.x,y:i.y,handler:bg}),e.push({x:(i.x+r.x)/2,y:(i.y+r.y)/2,handler:bg}),n==t.length-2&&e.push({x:r.x,y:r.y,handler:bg})}return e}get nature(){return _g}}Va.register("polyline",vg);const xg={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 wg extends sg{get pathExtendable(){return!1}get drawPath(){const t=this.path[0],e=this.path[1],{component:n,direction:i,boundaryPosition:r=t}=this.fromEnd||{},{component:s,direction:o,boundaryPosition:a=e}=this.toEnd||{},c=[r,a],l=[];r&&l.push(r);let h,d=n?.bounds;d&&(h=n.toScene(d.left,d.top),h=this.transcoordT2P(h.x,h.y),d={...d,left:h.x,top:h.y});const u=d?{left:d.left-20,top:d.top-20,width:d.width+40,height:d.height+40}:{left:r.x,top:r.y,width:0,height:0};d=d||u;let p=s?.bounds;p&&(h=s.toScene(p.left,p.top),h=this.transcoordT2P(h.x,h.y),p={...p,left:h.x,top:h.y});const f=p?{left:p.left-20,top:p.top-20,width:p.width+40,height:p.height+40}:{left:a.x,top:a.y,width:0,height:0};p=p||f;const g=[u,f],m=u.left>f.left?f.left:u.left,y=u.top>f.top?f.top:u.top,b={left:m,top:y,width:u.left+u.width>f.left+f.width?u.left+u.width-m:f.left+f.width-m,height:u.top+u.height>f.top+f.height?u.top+u.height-y:f.top+f.height-y};let _,v,x,w,M,S,A,E,k,C,T=0,P=0;d.left+d.width<p.left?(w=0,M=1,k=i,C=o,_=(d.left+d.width+p.left)/2,T=p.left-_):p.left+p.width<d.left&&(w=1,M=0,k=o,C=i,_=(d.left+p.width+p.left)/2,T=d.left-_),d.top+d.height<p.top?(x=0,S=1,A=i,E=o,v=(d.top+d.height+p.top)/2,P=p.top-v):p.top+p.height<d.top&&(x=1,S=0,A=o,E=i,v=(d.top+p.height+p.top)/2,P=d.top-v);const D=[];if(_&&T>P){let t,e,n;switch(C){case ig:switch(k){case ng:D.push({x:_,y:c[w].y}),D.push({x:_,y:c[M].y});break;case ig:t=g[w].top+g[w].height/2,e=t>c[M].y?Math.min(g[w].top,c[M].y):Math.max(g[w].top+g[w].height,c[M].y),D.push({x:c[w].x,y:e}),D.push({x:_,y:e}),D.push({x:_,y:c[M].y});break;case tg:case eg:e=k===eg?Math.max(c[w].y,c[M].y):Math.min(c[w].y,c[M].y),D.push({x:c[w].x,y:e}),D.push({x:_,y:e}),D.push({x:_,y:c[M].y});break;default:return this.path}break;case ng:switch(k){case ng:e=c[w].y<c[M].y?Math.min(g[M].top,c[w].y):Math.max(g[M].top+g[M].height,c[w].y),n=e;break;case ig:e=void 0!==v?v:c[w].y<c[M].y?b.top-.5*T:b.top+b.height+.5*T,n=e;break;case eg:e=void 0!==v?Math.max(v,c[w].y):b.top+b.height,n=e;break;case tg:e=v?Math.min(v,g[w].top):b.top,n=e;break;default:return this.path}D.push({x:c[w].x,y:e}),D.push({x:_,y:e}),D.push({x:_,y:n}),D.push({x:c[M].x,y:n});break;case eg:switch(k){case ng:e=c[w].y,n=c[w].y>c[M].y?c[w].y:g[M].top+g[M].height;break;case ig:e=v?Math.max(v,g[M].top+g[M].height):b.top+b.height,n=e;break;case eg:e=b.top+b.height,n=e;break;case tg:e=v?Math.min(v,g[w].top):g[w].top,n=v?Math.max(v,g[M].top+g[M].height):g[M].top+g[M].height;break;default:return this.path}D.push({x:c[w].x,y:e}),D.push({x:_,y:e}),D.push({x:_,y:n}),D.push({x:c[M].x,y:n});break;case tg:switch(k){case ng:e=c[w].y,n=c[w].y<c[M].y?c[w].y:g[M].top;break;case ig:e=v?Math.min(v,g[M].top):b.top,n=e;break;case eg:e=void 0!==v?Math.max(v,c[w].y):c[w].y,n=void 0!==v?Math.min(v,c[M].y):c[M].y;break;case tg:e=b.top,n=e;break;default:return this.path}D.push({x:c[w].x,y:e}),D.push({x:_,y:e}),D.push({x:_,y:n}),D.push({x:c[M].x,y:n});break;default:return this.path}l.push(...0===w?D:D.reverse())}else if(v){let t,e,n;switch(E){case tg:switch(A){case eg:D.push({x:c[x].x,y:v}),D.push({x:c[S].x,y:v});break;case tg:t=g[x].left+g[x].width/2,e=t>c[S].x?Math.min(g[x].left,c[S].x):Math.max(g[x].left+g[x].width,c[S].x),D.push({x:e,y:c[x].y}),D.push({x:e,y:v}),D.push({x:c[S].x,y:v});break;case ig:e=Math.min(c[x].x,c[S].x),D.push({x:e,y:c[x].y}),D.push({x:e,y:v}),D.push({x:c[S].x,y:v});break;case ng:e=Math.max(c[x].x,c[S].x),D.push({x:e,y:c[x].y}),D.push({x:e,y:v}),D.push({x:c[S].x,y:v});break;default:return this.path}break;case eg:switch(A){case ig:e=b.left,n=e;break;case ng:e=void 0!==_?Math.max(_,c[x].x):b.left+b.width,n=e;break;case tg:e=void 0!==_?_:c[x].x<c[S].x?b.left-.5*P:b.left+b.width+.5*P,n=e;break;case eg:e=c[x].x,n=c[x].x<c[S].x?Math.min(g[S].left,c[x].x):Math.max(g[S].left+g[S].width,c[x].x);break;default:return this.path}D.push({x:e,y:c[x].y}),D.push({x:e,y:v}),D.push({x:n,y:v}),D.push({x:n,y:c[S].y});break;case ng:switch(A){case ig:e=void 0!==_?Math.min(_,c[x].x):c[x].x,n=void 0!==_?Math.max(_,c[S].x):c[S].x;break;case ng:e=b.left+b.width,n=e;break;case tg:e=void 0!==_?Math.max(_,c[S].x):b.left+b.width,n=e;break;case eg:e=c[x].x,n=Math.max(g[S].left+g[S].width,c[x].x);break;default:return this.path}D.push({x:e,y:c[x].y}),D.push({x:e,y:v}),D.push({x:n,y:v}),D.push({x:n,y:c[S].y});break;case ig:switch(A){case ig:e=b.left,n=e;break;case ng:e=void 0!==_?Math.max(_,c[x].x):c[x].x,n=void 0!==_?Math.min(_,c[S].x):c[S].x;break;case tg:e=b.left,n=e;break;case eg:e=c[x].x<c[S].x?Math.min(g[S].left,c[x].x):c[x].x,n=Math.min(e,c[S].x);break;default:return this.path}D.push({x:e,y:c[x].y}),D.push({x:e,y:v}),D.push({x:n,y:v}),D.push({x:n,y:c[S].y});break;default:return this.path}l.push(...0===x?D:D.reverse())}else{let t,e;switch(i){case tg:switch(o){case tg:e=b.top,l.push({x:c[0].x,y:e}),l.push({x:c[1].x,y:e});break;case eg:t=b.left+b.width,l.push({x:t,y:c[0].y}),l.push({x:t,y:b.top+b.height}),l.push({x:c[1].x,y:b.top+b.height});break;case ng:t=c[1].y<c[0].y&&c[1].x<c[0].x?c[0].x:b.left+b.width,l.push({x:t,y:c[0].y}),l.push({x:t,y:c[1].y});break;case ig:t=b.left,l.push({x:t,y:c[0].y}),l.push({x:t,y:c[1].y});break;default:return this.path}break;case eg:switch(o){case tg:t=b.left+b.width,l.push({x:t,y:c[0].y}),l.push({x:t,y:b.top}),l.push({x:c[1].x,y:b.top});break;case eg:case ng:case ig:e=b.top+b.height,l.push({x:c[0].x,y:e}),l.push({x:c[1].x,y:e});break;default:return this.path}break;case ig:switch(o){case tg:t=c[0].x>c[1].x&&c[0].y<c[1].y?c[1].x:b.left,e=c[0].x>c[1].x&&c[0].y<c[1].y?c[1].y:Math.min(b.top,c[0].y),l.push({x:t,y:c[0].y}),l.push({x:t,y:e}),l.push({x:c[1].x,y:e});break;case eg:t=b.left,e=Math.max(b.top+b.height,c[0].y),l.push({x:t,y:c[0].y}),l.push({x:t,y:e}),l.push({x:c[1].x,y:e});break;case ng:t=b.left+b.width,l.push({x:c[0].x,y:b.top}),l.push({x:t,y:b.top}),l.push({x:t,y:c[1].y});break;case ig:t=b.left,l.push({x:t,y:c[0].y}),l.push({x:t,y:c[1].y});break;default:return this.path}break;case ng:switch(o){case tg:e=c[0].y<c[1].y&&c[0].x<c[1].x?c[0].y:b.top,l.push({x:c[0].x,y:e}),l.push({x:c[1].x,y:e});break;case eg:e=c[0].y>c[1].y&&c[0].x<c[1].x?c[0].y:b.top+b.height,l.push({x:c[0].x,y:e}),l.push({x:c[1].x,y:e});break;case ng:case ig:e=b.top+b.height,l.push({x:c[0].x,y:e}),l.push({x:c[1].x,y:e});break;default:return this.path}break;default:return this.path}}return a&&l.push(a),[t,...l,e].filter((t,e,n)=>{if(0===e)return!0;const i=n[e-1];return t.x!==i.x||t.y!==i.y}).filter((t,e,n)=>{if(0===e||e>=n.length-1)return!0;const i=n[e-1],r=n[e+1];return!(t.x===i.x&&t.x===r.x||t.y===i.y&&t.y===r.y)})}get nature(){return xg}}Va.register("ortholine",wg);const Mg={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 Sg extends(Wa(Ua)){static get noimage(){return Sg.NOIMAGE||(Sg.NOIMAGE=new Image,Sg.NOIMAGE.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAABIBAMAAAD7Se1QAAAAIVBMVEUAAABHcEwBAQEREREBAQEEBAQGBgYLCwsDAwMDAwMICAi6HF9tAAAAC3RSTlNNAEAERiMYCS41Eac10lYAAAEgSURBVHhe7dY9asQwEAXgh7DNertNiJy48pIitY3SB7bYdk0ukL1BDDmA9gZecoH4pmFQ3MQayUMguPBrNPD4wD9TCMvJmt3M/AtYwXOlXiWgqADVCUBD46MAnGhMBaCiUQmAm8VA/Eh/eWl9Fn5WcxD+OLuRrUYJDKLluwH2InACUgkoACSdADxQc50Bytadb9RkM0CT13TcvlCT1HFg8UTHvasuUVACCa3El6u2UdD8LFTlKhUFFgA+d3dj10aABkUN72N3jAADCrJq7PIIsPidcxBoTHIIAjMFmyCwmGYIAA1P9gFgfCANAOsDSccCDW+uLDB+kLGg94OkZoAGkwsDDAe2DOg5oPxAg03rBR88OHpBz4N8UVeHFSwma74BTW6Ge4rIRa4AAAAASUVORK5CYII="),Sg.NOIMAGE}dispose(){super.dispose(),this._offcanvas=null,this._image=null}render(t){const{left:e,top:n,width:i,height:r,isGray:s=!1,alpha:o=1,src:a}=this.state;if(this.prepareIf(!this._image&&a),t.beginPath(),t.globalAlpha*=o,this._image&&this._image.complete)if(s&&this._offcanvas)t.drawImage(this._offcanvas,e,n,i,r);else try{t.drawImage(this._image,e,n,i,r)}catch(s){t.drawImage(Sg.noimage,e,n,i,r)}else!this.app.isViewMode&&t.drawImage(Sg.noimage,e,n,i,r)}get nature(){return Mg}get hasTextProperty(){return!1}async ready(){await super.ready();const{src:t}=this.state;if(!this._image&&t){const e=this.root?.app?.loadTracker;if(e){const n=new Promise((t,e)=>{this.prepare(()=>t(),t=>e(t))});e.track(`image:${t}`,"image",t,n)}else this.prepareIf(!0)}}prepare(t,e){const{src:n,crossOrigin:i}=this.state;if(n){this._image=new Image;try{i&&(this._image.crossOrigin=i),this._image.src=this.app.url(n)||""}catch(t){return void e(t)}this._image.onload=()=>{if(this.get("isGray")){const t=this._image.width,e=this._image.height;this._offcanvas=Va.createCanvas(t,e);const n=this._offcanvas.getContext("2d");n.drawImage(this._image,0,0);const i=function(t,e,n){let i;try{i=t.getImageData(0,0,e,n)}catch(t){return Fi("Get Image Data Error: "+(t instanceof Error?t.message:String(t))),null}const r=i.data;for(let t=0;t<e*n*4;t+=4){const e=r[t],n=r[t+1],s=r[t+2],o=Math.floor((e+n+s)/3);i.data[t]=o,i.data[t+1]=o,i.data[t+2]=o}return i}(n,t,e);n.putImageData(i,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 n=0;n<t.length;n++)if(t[n].type.startsWith("image/"))return void(this.src=e[n])}}Va.register("image-view",Sg);class Ag extends(Nf(Wa(Va))){is3dish(){return!0}prerender(){}}var Eg,kg,Cg={},Tg={},Pg={};function Dg(){if(kg)return Tg;kg=1,Object.defineProperty(Tg,"__esModule",{value:!0});var t=function(){if(Eg)return Pg;Eg=1,Object.defineProperty(Pg,"__esModule",{value:!0});var t=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=[],n=7;n>=0;n--)e.push(!!(t&1<<n));return e},t.lzwDecode=function(t,e){for(var n,i,r=0,s=function(t){for(var n=0,i=0;i<t;i++)e.charCodeAt(r>>3)&1<<(7&r)&&(n|=1<<i),r++;return n},o=[],a=1<<t,c=a+1,l=t+1,h=[],d=function(){h=[],l=t+1;for(var e=0;e<a;e++)h[e]=[e];h[a]=[],h[c]=null};;)if(i=n,(n=s(l))!==a){if(n===c)break;if(n<h.length)i!==a&&h.push(h[i].concat(h[n][0]));else{if(n!==h.length)throw new Error("Invalid LZW code.");h.push(h[i].concat(h[i][0]))}o.push.apply(o,h[n]),h.length===1<<l&&l<12&&l++}else d();return o},t}();return Pg.SuperGifUtils=t,Pg}(),e=function(){function e(t,e){this.stream=t,this.handler=e}return e.prototype.parseCT=function(t){for(var e=[],n=0;n<t;n++)e.push(this.stream.readBytes(3));return e},e.prototype.readSubBlocks=function(){var t,e;e="";do{t=this.stream.readByte(),e+=this.stream.read(t)}while(0!==t);return e},e.prototype.parseHeader=function(){var e={};if(e.sig=this.stream.read(3),e.ver=this.stream.read(3),"GIF"!==e.sig)throw new Error("Not a GIF file.");e.width=this.stream.readUnsigned(),e.height=this.stream.readUnsigned();var n=t.SuperGifUtils.byteToBitArr(this.stream.readByte());e.gctFlag=n.shift(),e.colorRes=t.SuperGifUtils.bitsToNum(n.splice(0,3)),e.sorted=n.shift(),e.gctSize=t.SuperGifUtils.bitsToNum(n.splice(0,3)),e.bgColor=this.stream.readByte(),e.pixelAspectRatio=this.stream.readByte(),e.gctFlag&&(e.gct=this.parseCT(1<<e.gctSize+1)),this.handler.hdr&&this.handler.hdr(e)},e.prototype.parseExt=function(e){var n=this;switch(e.label=this.stream.readByte(),e.label){case 249:e.extType="gce",function(e){n.stream.readByte();var i=t.SuperGifUtils.byteToBitArr(n.stream.readByte());e.reserved=i.splice(0,3),e.disposalMethod=t.SuperGifUtils.bitsToNum(i.splice(0,3)),e.userInput=i.shift(),e.transparencyGiven=i.shift(),e.delayTime=n.stream.readUnsigned(),e.transparencyIndex=n.stream.readByte(),e.terminator=n.stream.readByte(),n.handler.gce&&n.handler.gce(e)}(e);break;case 254:e.extType="com",function(t){t.comment=n.readSubBlocks(),n.handler.com&&n.handler.com(t)}(e);break;case 1:e.extType="pte",function(t){n.stream.readByte(),t.ptHeader=n.stream.readBytes(12),t.ptData=n.readSubBlocks(),n.handler.pte&&n.handler.pte(t)}(e);break;case 255:e.extType="app",function(t){n.stream.readByte(),t.identifier=n.stream.read(8),t.authCode=n.stream.read(3),"NETSCAPE"===t.identifier?function(t){n.stream.readByte(),t.unknown=n.stream.readByte(),t.iterations=n.stream.readUnsigned(),t.terminator=n.stream.readByte(),n.handler.app&&n.handler.app.NETSCAPE&&n.handler.app.NETSCAPE(t)}(t):function(t){t.appData=n.readSubBlocks(),n.handler.app&&n.handler.app[t.identifier]&&n.handler.app[t.identifier](t)}(t)}(e);break;default:e.extType="unknown",function(t){t.data=n.readSubBlocks(),n.handler.unknown&&n.handler.unknown(t)}(e)}},e.prototype.parseImg=function(e){e.leftPos=this.stream.readUnsigned(),e.topPos=this.stream.readUnsigned(),e.width=this.stream.readUnsigned(),e.height=this.stream.readUnsigned();var n=t.SuperGifUtils.byteToBitArr(this.stream.readByte());e.lctFlag=n.shift(),e.interlaced=n.shift(),e.sorted=n.shift(),e.reserved=n.splice(0,2),e.lctSize=t.SuperGifUtils.bitsToNum(n.splice(0,3)),e.lctFlag&&(e.lct=this.parseCT(1<<e.lctSize+1)),e.lzwMinCodeSize=this.stream.readByte();var i=this.readSubBlocks();e.pixels=t.SuperGifUtils.lzwDecode(e.lzwMinCodeSize,i),e.interlaced&&(e.pixels=function(t,e){for(var n=new Array(t.length),i=t.length/e,r=function(i,r){var s=t.slice(r*e,(r+1)*e);n.splice.apply(n,[i*e,e].concat(s))},s=[0,4,2,1],o=[8,8,4,2],a=0,c=0;c<4;c++)for(var l=s[c];l<i;l+=o[c])r(l,a),a++;return n}(e.pixels,e.width)),this.handler.img&&this.handler.img(e)},e.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)},e.prototype.parse=function(){this.parseHeader(),setTimeout(this.parseBlock.bind(this),0)},e}();return Tg.SuperGifParser=e,Tg}var Og,zg,Lg={};var Ig=function(){if(zg)return Cg;zg=1,Object.defineProperty(Cg,"__esModule",{value:!0});var t=Dg(),e=function(){if(Og)return Lg;Og=1,Object.defineProperty(Lg,"__esModule",{value:!0});var t=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=[],n=0;n<t;n++)e.push(this.readByte());return e},t.prototype.read=function(t){for(var e="",n=0;n<t;n++)e+=String.fromCharCode(this.readByte());return e},t.prototype.readUnsigned=function(){var t=this.readBytes(2);return(t[1]<<8)+t[0]},t}();return Lg.SuperGifStream=t,Lg}(),n=function(){function n(t,e){var n=this;for(var i 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(){n.pushFrame(),n.canvas.width=n.hdr.width*n.getCanvasScale(),n.canvas.height=n.hdr.height*n.getCanvasScale(),n.playerInit(),n.loading=!1,n.ready=!0,n.loadCallback&&n.loadCallback(n.gifImgElement)}},e)this.options[i]=e[i];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 n.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},n.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)},n.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)},n.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)}},n.prototype.step=function(){this.stepping||setTimeout(this.doStep.bind(this),0)},n.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)},n.prototype.playerInit=function(){this.loadErrorCause||(this.canvasContext.scale(this.getCanvasScale(),this.getCanvasScale()),this.options.autoPlay?this.step():(this.currentFrameIndex=0,this.putFrame()))},n.prototype.clear=function(){this.transparency=null,this.delay=null,this.lastDisposalMethod=this.disposalMethod,this.disposalMethod=null,this.frame=null},n.prototype.parseStream=function(e){try{new t.SuperGifParser(e,this.handler).parse()}catch(t){this.handleError("parse")}},n.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)},n.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()},n.prototype.handleError=function(t){this.loadErrorCause=t,this.hdr={width:this.gifImgElement.width,height:this.gifImgElement.height},this.frames=[],this.drawError()},n.prototype.doHdr=function(t){this.hdr=t,this.setSizes(this.hdr.width,this.hdr.height)},n.prototype.doGCE=function(t){this.pushFrame(),this.clear(),this.transparency=t.transparencyGiven?t.transparencyIndex:null,this.delay=t.delayTime,this.disposalMethod=t.disposalMethod},n.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}))},n.prototype.doImg=function(t){var e=this;this.frame||(this.frame=this.tmpCanvas.getContext("2d"));var n=this.frames.length,i=t.lctFlag?t.lct:this.hdr.gct;n>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=n-1,2===this.lastDisposalMethod&&this.frame.clearRect(this.lastImg.leftPos,this.lastImg.topPos,this.lastImg.width,this.lastImg.height));var r=this.frame.getImageData(t.leftPos,t.topPos,t.width,t.height);t.pixels.forEach(function(t,n){t!==e.transparency&&(r.data[4*n+0]=i[t][0],r.data[4*n+1]=i[t][1],r.data[4*n+2]=i[t][2],r.data[4*n+3]=255)}),this.frame.putImageData(r,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},n.prototype.doNothing=function(){},n.prototype.withProgress=function(t){return function(e){t(e)}},n.prototype.getNextFrameNo=function(){var t=this.forward?1:-1;return(this.currentFrameIndex+t+this.frames.length)%this.frames.length},n.prototype.stepFrame=function(t){this.currentFrameIndex=this.currentFrameIndex+t,this.putFrame()},n.prototype.getCanvasScale=function(){return this.options.maxWidth&&this.hdr&&this.hdr.width>this.options.maxWidth?this.options.maxWidth/this.hdr.width:window.devicePixelRatio||1},n.prototype.play=function(){this.playing=!0,this.step()},n.prototype.pause=function(){this.playing=!1},n.prototype.isPlaying=function(){return this.playing},n.prototype.getCanvas=function(){return this.canvas},n.prototype.isLoading=function(){return this.loading},n.prototype.isReady=function(){return this.ready},n.prototype.isAutoPlay=function(){return this.options.autoPlay},n.prototype.getLength=function(){return this.frames.length},n.prototype.getCurrentFrame=function(){return this.currentFrameIndex},n.prototype.moveTo=function(t){this.currentFrameIndex=t,this.putFrame()},n.prototype.loadURL=function(t,n){var i=this;if(this.loadSetup(n)){var r=new XMLHttpRequest;r.open("GET",t,!0),"overrideMimeType"in r?r.overrideMimeType("text/plain; charset=x-user-defined"):"responseType"in r?r.responseType="arraybuffer":r.setRequestHeader("Accept-Charset","x-user-defined"),r.onloadstart=function(){i.initialized||i.init()},r.onload=function(){if(200===r.status){var t=r.response;t.toString().indexOf("ArrayBuffer")>0&&(t=new Uint8Array(t));var n=new e.SuperGifStream(t);setTimeout(function(){i.parseStream(n)},0)}else i.handleError("xhr - response")},r.onerror=function(){i.handleError("xhr")},r.send()}},n.prototype.load=function(t){this.loadURL(this.gifImgElement.src,t)},n}();return Cg.SuperGif=n,Cg}();const Rg={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 jg extends Ag{async oncreate_element(t){const{src:e,play:n}=this.state;this.onchangesrc(e),this.onchangeplay(n)}buildImg(){const t=this.element;if(!t)return document.createElement("img");t.replaceChildren();const 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){const e=this._superGif;e&&e.isReady()&&(t?e.play():e.pause())}onchangesrc(t){const 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",String(0)),this._superGif=new Ig.SuperGif(e,{autoPlay:!1}),this._superGif.init(),this.element&&Array.from(this.element.children).forEach(t=>{t.style.width="100%",t.style.height="100%"});const n=this._superGif.getCanvas();n.style.width="100%",n.style.height="100%",this._superGif.load(()=>{setTimeout(()=>{this._superGif.moveTo(0),this.play&&this._superGif.play()},100)})}ondropfile(t,e){for(let n=0;n<t.length;n++)if(/\.gif$/.test(t[n].name))return void(this.src=e[n])}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 Rg}get tagName(){return"div"}}Va.register("gif-view",jg);const Fg={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 Bg extends(Wa(Ua)){static get image(){return Bg.IMAGE||(Bg.IMAGE=new Image,Bg.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="),Bg.IMAGE}dispose(){super.dispose(),this.started=!1,delete this._audio}async ready(){super.ready(),this._audio=new Audio;const{src:t="",loop:e=!1,started:n=!1}=this.state;if(t){const e=this.root?.app?.loadTracker;if(e){const n=new Promise((e,n)=>{this._audio.addEventListener("canplay",()=>e(),{once:!0}),this._audio.addEventListener("error",()=>n(new Error(`Audio load failed: ${t}`)),{once:!0})});e.track(`audio:${t}`,"audio",t,n)}}this._audio.addEventListener("canplay",()=>{this.started&&this._audio.play()}),this.onchangeSrc(t),this.onchangeLoop(e),this.onchangeStarted(n)}render(t){const{left:e,top:n,width:i,height:r}=this.state;t.beginPath(),this.drawImage(t,Bg.image,e,n,i,r)}get nature(){return Fg}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 Fi(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 n=0;n<t.length;n++)if(t[n].type.startsWith("audio/"))return void(this.src=e[n])}}Va.register("audio",Bg);class Ng extends(Wa(Va)){is3dish(){return!0}}Va.register("text",Ng);const Hg=["refid","left","top","width","height","rotation","animation","zPos"];class Yg extends Uf{isGroup(){return!0}is3dish(){return!0}get(t){return this._model[t]}set(t,e){if("string"==typeof t)return this.set({[t]:e});const n=Hg.reduce((e,n)=>(t.hasOwnProperty(n)&&(e[n]=t[n]),e),{});return super.set(n,void 0)}capture(t,e,n){const i=super.capture(t,e,n);if(i!==this)return i}set bounds(t){if(this.__MUTATING__)return void(super.bounds=t);const e=this.bounds,n=t.width/e.width,i=t.height/e.height;this.path=this.path.map(r=>({x:t.left+(r.x-e.left)*n,y:t.top+(r.y-e.top)*i})),this.components&&this.components.forEach(t=>{if(t.mutable)t.mutatePath(null,function(t){return t.map(function(t){return{x:t.x*n,y:t.y*i}})});else{const e=t.bounds,r=t.center,s={x:r.x*(1-n),y:r.y*(1-i)},o=e.width*(1-n),a=e.height*(1-i),c=-(s.x-o/2),l=-(s.y-a/2);t.bounds={left:e.left+c,top:e.top+l,width:e.width*n,height:e.height*i}}})}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){const e=Va.union(this.components.map(t=>t.bounds));return this.components.forEach(t=>{const n=t.bounds;t.bounds={left:n.left-e.left,top:n.top-e.top,width:n.width,height:n.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){const{top:e,left:n}=this.state;t.translate(n,e),this.layout.drawables(this).forEach(e=>{e.draw(t)}),t.translate(-n,-e)}}Va.memoize(Yg.prototype,"bounds",!0),Va.register("group",Yg);const Gg={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 Vg extends(Wa(Ua)){get ref(){const t=this.getState("ref");return t&&"string"==typeof t?this.root.findById?.(t):null}set ref(t){this.setState("ref",t)}get refScale(){const t=this.ref;if(!t)return{x:1,y:1};const e=t.bounds,n=this.bounds,i=n.width/e.width,r=n.height/e.height;return"both"===this.model.fit?{x:i,y:r}:{x:Math.min(i,r),y:Math.min(i,r)}}draw(t){this._drawing||(this._drawing=!0,super.draw(t),this._drawing=!1)}prerender(t){if(super.prerender(t),this.ref){const e=this.ref.center,n=this.center,i=this.refScale;t.translate(n.x,n.y),t.scale(i.x,i.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);const{left:e,top:n,width:i,height:r}=this.bounds;t.beginPath(),t.rect(e,n,i,r)}get nature(){return Gg}get hasTextProperty(){return!1}}Va.memoize(Vg.prototype,"ref",!1),Va.memoize(Vg.prototype,"refScale",!1),Va.register("local-ref",Vg);class Ug extends(Nf(Zc)){render(t){}is3dish(){return!0}get layout(){return Ja.get(this.get("layout"))||tc}}const $g={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 Wg extends Ug{dispose(){this._releaseRef(),super.dispose()}get nature(){return $g}get hasTextProperty(){return!1}get tagName(){return"div"}setElementProperties(t){const{mode:e="view",round:n=0}=this.state;t.style.pointerEvents="view"==e?"none":"inherit",t.style.borderRadius=n+"px"}async ready(){super.ready(),this.fetchRef()}reposition(){if(!this.element)return;super.reposition();const t=this._element_bounds,{offsetWidth:e,offsetHeight:n}=this.element;if(this._element_bounds={offsetWidth:e,offsetHeight:n},(!t||t.offsetWidth!=e||t.offsetHeight!=n)&&this.ref&&this.root.target_element){const{fit:t="ratio"}=this.state;this.ref.fit(t)}}async fetchRef(){this._releaseRef();const{ref:t,fit:e="ratio"}=this.state;if(!t)return;const n=this.app.refProvider;if(n&&t){const i=(async()=>{this.__ref=await n.get(t,!0),this.__ref.target=this.element,this.__ref.fit(e),this.__ref.data=this.data})();this.root?.app?.loadTracker?.track(`ref:${t}`,"ref-board",t,i);try{await i}catch(t){Fi(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,n){super.onchange(t,e),"ref"in t&&this.fetchRef(),"fit"in t&&this.ref&&requestAnimationFrame(()=>{const{fit:t}=this.state;this.ref.fit(t)}),"data"in t&&this.ref&&requestAnimationFrame(()=>{this.ref.data=t.data})}}Va.register("global-ref",Wg);const Xg="center-middle",qg={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:"popup-position",name:"popupPosition",property:{options:["static","absolute"]}},{type:"select",label:"popup-origin",name:"origin",property:{options:["left-top","center-top","right-top","left-middle",Xg,"right-middle","left-bottom","center-bottom","right-bottom","auto"]}},{type:"string",label:"title",name:"text"},{type:"data",label:"value",name:"value"},{type:"string",label:"container-ref",name:"containerRef",placeholder:"PopupContainer id (same board)"},{type:"textarea",label:"html-template",name:"htmlTemplate",property:{language:"html"}},{type:"string",label:"anchor-ref",name:"anchorRef",placeholder:"component id (3D-tracked anchor)"},{type:"select",label:"anchor-pin",name:"anchorPin",property:{options:[{display:"Top",value:"top"},{display:"Center",value:"center"},{display:"Bottom",value:"bottom"}]}},{type:"number",label:"anchor-offset-x",name:"anchorOffsetX"},{type:"number",label:"anchor-offset-y",name:"anchorOffsetY"},{type:"number",label:"anchor-offset-z",name:"anchorOffsetZ"},{type:"checkbox",label:"constant-size",name:"constantSize"},{type:"checkbox",label:"tether",name:"tether"},{type:"select",label:"off-screen",name:"offScreen",property:{options:[{display:"Hide",value:"hide"},{display:"Edge-pin",value:"edge-pin"},{display:"Keep last",value:"keep-last"}]}}],help:"scene/component/popup"};class Kg extends(Wa(Ua)){static get image(){return Kg._image||(Kg._image=new Image,Kg._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"),Kg._image}async ready(){await super.ready(),this.show&&this.onchangeShow(!0)}render(t){const{left:e,top:n,width:i,height:r}=this.bounds;t.beginPath(),this.drawImage(t,Kg.image,e,n,i,r)}onchange(t,e){"value"in t?this.show?this.onchangeShow(!0):this.show=!0:"show"in t&&this.onchangeShow(this.show)}onchangeShow(t){if(this.app.isEditMode)return;(this.getState("board")||this.getState("containerRef")||this.getState("htmlTemplate"))&&(t?this.openPopup(this.value):this.hidePopup())}openPopup(t,e){if(this.app.isEditMode)return;const n=this.getState("anchorRef"),i=n&&this.rootModel?.findById?this.rootModel.findById(n):void 0;Md.show(this,this.getState("board"),{origin:this.getState("origin")||Xg,modal:this.getState("modal"),closable:this.getState("closable")||!1,draggable:this.getState("draggable")||!1,minimizable:this.getState("minimizable")||!1,popupPosition:this.getState("popupPosition"),title:this.text,data:t||this.value,containerRef:this.getState("containerRef"),htmlTemplate:this.getState("htmlTemplate"),anchor:i,anchorPin:this.getState("anchorPin")||"top",anchorOffsetX:this.getState("anchorOffsetX")??0,anchorOffsetY:this.getState("anchorOffsetY")??0,anchorOffsetZ:this.getState("anchorOffsetZ")??0,constantSize:this.getState("constantSize")??!0,tether:this.getState("tether")??!1,offScreen:this.getState("offScreen")||"hide",...e})}hidePopup(){Md.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 qg}}Va.register("popup",Kg);const Qg={mutable:!1,resizable:!0,rotatable:!1,properties:[{type:"layout",label:"layout",name:"layoutOption"},{type:"checkbox",label:"constant-size",name:"constantSize"},{type:"checkbox",label:"billboard",name:"billboard"},{type:"checkbox",label:"tether",name:"tether"},{type:"select",label:"off-screen",name:"offScreen",property:{options:[{display:"Hide",value:"hide"},{display:"Edge-pin",value:"edge-pin"},{display:"Keep last",value:"keep-last"}]}}],help:"scene/component/popup-container"};class Zg extends Uf{get nature(){return Qg}isPopupContainer(){return!0}}Va.register("popup-container",Zg);class Jg extends Va{render(t){const{path:e=[]}=this.state;if(!(e.length<=1)){t.beginPath(),t.moveTo(e[0].x,e[0].y);for(let n=1;n<e.length;n++)t.lineTo(e[n].x,e[n].y);t.closePath(),this.drawStroke(t,void 0)}}get path(){return this.model.path}set path(t){this.set("path",t)}contains(t,e){const n=this.state.path;let i=!1;return n.forEach((r,s)=>{const o=(s+n.length+1)%n.length,a=r.x,c=r.y,l=n[o].x,h=n[o].y;c>e!=h>e&&t<(l-a)*(e-c)/(h-c)+a&&(i=!i)}),i}}Va.register("path",Jg);const tm={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 em extends Ua{is3dish(){return!0}contains(t,e){const{x1:n,y1:i,x2:r,y2:s,x3:o,y3:a}=this.state,c=[n,i,r,s,o,a];let l=!1;for(let n=0;n<c.length;n+=2){const i=(n+2)%c.length,r=c[n],s=c[n+1],o=c[i+1];s>e!=o>e&&t<(c[i]-r)*(e-s)/(o-s)+r&&(l=!l)}return l}get mutable(){return!0}get path(){const{x1:t,y1:e,x2:n,y2:i,x3:r,y3:s}=this.state;return[{x:t,y:e},{x:n,y:i},{x:r,y:s}]}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 tm}}Va.memoize(em.prototype,"path",!1),Va.register("triangle",em);const nm={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"number",label:"ratio",name:"ratio",property:"ratio"}],help:"scene/component/donut"},im={ondragmove:function(t,e,n){let{cx:i,rx:r}=n.model;r=Math.abs(r);let s=(n.fromParent(t.x,t.y).x-i)/r*100;s=s>=100||s<=-100?100:Math.abs(s),n.set({ratio:s})}};class rm extends ag{is3dish(){return!0}render(t){let{ratio:e=50,cx:n,cy:i,rx:r,ry:s,startAngle:o,endAngle:a,anticlockwise:c}=this.state;r=Math.abs(r),s=Math.abs(s),t.beginPath(),t.ellipse(n,i,r,s,0,o||0,a||2*Math.PI,c),t.moveTo(n+r/100*e,i),t.ellipse(n,i,r/100*e,s/100*e,0,o||0,a||2*Math.PI,!0)}contains(t,e){let{cx:n,cy:i,rx:r,ry:s,ratio:o}=this.state;r=Math.abs(r),s=Math.abs(s);const a=(t-n)/(2*r-.5),c=(e-i)/(2*s-.5),l=(t-n)/(r/100*o*2-.5),h=(e-i)/(s/100*o*2-.5);let d=!1;return a*a+c*c<.25&&l*l+h*h>.25&&(d=!d),d}get controls(){let{cx:t,cy:e,rx:n,ratio:i}=this.state;return n=Math.abs(n),[{x:t+n/100*i,y:e,handler:im}]}get nature(){return nm}}Va.memoize(rm.prototype,"controls",!1),Va.register("donut",rm);const sm={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"},om={ondragmove:function(t,e,n){const{cy:i,ry:r}=n.model;let s=(n.fromParent(t.x,t.y).y-i)/r*100+100;s>=100?s=100:s<=0&&(s=0),n.set({ratio:s})}};class am extends ag{is3dish(){return!0}render(t){const{ratio:e=30,wing:n=5,cx:i,cy:r,rx:s,ry:o}=this.state;if(n<3)return;const a=1.5707963267948966,c=2*Math.PI/n,l=s-e/100*s,h=o-e/100*o;t.save(),t.beginPath(),t.translate(i,r),t.moveTo(s*Math.cos(-a),o*Math.sin(-a)),t.lineTo((s-l)*(Math.cos(c-a)+Math.cos(0-a))/2,(o-h)*(Math.sin(c-a)+Math.sin(0-a))/2);for(let e=1;e<n;e++)t.lineTo(s*Math.cos(c*e-a),o*Math.sin(c*e-a)),t.lineTo((s-l)*(Math.cos(c*(e+1)-a)+Math.cos(c*e-a))/2,(o-h)*(Math.sin(c*(e+1)-a)+Math.sin(c*e-a))/2);t.closePath(),t.restore()}get controls(){const{cx:t,cy:e,ry:n,ratio:i}=this.state;return[{x:t,y:e-n+n*(i/100),handler:om}]}get nature(){return sm}}Va.memoize(am.prototype,"controls",!1),Va.register("star",am);const cm={mutable:!1,resizable:!1,rotatable:!1,properties:[]};class lm extends(Uu(Ua)){is3dish(){return!1}isDescendible(){return!1}render(t){const{cx:e,cy:n,anticlockwise:i}=this.state,r=this.app?.scale||1;t.beginPath(),t.scale(1/r,1/r),t.ellipse(e,n,Math.abs(lm.RADIUS),Math.abs(lm.RADIUS),0,0,2*Math.PI,i),t.scale(r,r),t.closePath()}get path(){const{cx:t,cy:e}=this.state;return[{x:t-lm.RADIUS,y:e-lm.RADIUS},{x:t+lm.RADIUS,y:e-lm.RADIUS},{x:t+lm.RADIUS,y:e+lm.RADIUS},{x:t-lm.RADIUS,y:e+lm.RADIUS}]}set path(t){const e=t[0],n=t[2];this.set({cx:e.x+(n.x-e.x)/2,cy:e.y+(n.y-e.y)/2})}contains(t,e){const{cx:n,cy:i}=this.state,r=(t-n)/(2*lm.RADIUS-.5),s=(e-i)/(2*lm.RADIUS-.5);return r*r+s*s<.25}outline(t){const{cx:e,cy:n}=this.state;return this.toScene(e,n)}get nature(){return cm}}lm.RADIUS=5,Va.memoize(lm.prototype,"path",!1),Va.register("node",lm);class hm extends $h{getObject3dInstance(){return new w.Mesh}build(){super.build();const{width:t,height:e}=this.component.bounds,n=this.component.state.depth||.5*Math.min(t,e),i=.15*Math.min(t,e,n),r=new v.RoundedBoxGeometry(1,1,1,4,i/Math.min(t,e,n));r.scale(t,n,e),this.object3d.geometry=r,this.object3d.material=new w.MeshStandardMaterial({color:"#5090d0",transparent:!0,opacity:.35,roughness:.6,metalness:.1,side:w.FrontSide,depthWrite:!1}),this.object3d.visible=!!this.component.app?.isEditMode}updateAlpha(){const t=this.object3d.material;t&&(t.opacity=this.component.app?.isEditMode?.35:0)}updateHidden(){this.object3d.visible=!!this.component.app?.isEditMode&&!this.component.state.hidden}updateDimension(){const{width:t,height:e}=this.component.bounds,n=this.component.state.depth||.5*Math.min(t,e);this.object3d.geometry.computeBoundingBox();const i=this.object3d.geometry.boundingBox;if(i){const r=i.max.x-i.min.x,s=i.max.y-i.min.y,o=i.max.z-i.min.z;this.object3d.scale.set(t/r,n/s,e/o)}}updateFillStyle(){}updateStrokeStyle(){}updateText(){}clear(){return Hh(this.object3d),super.clear()}}const dm="data:image/svg+xml;base64,"+btoa('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" fill="#5090d0">\n <path d="M32 20a12 12 0 1 0 0 24 12 12 0 0 0 0-24zm0 18a6 6 0 1 1 0-12 6 6 0 0 1 0 12z"/>\n <path d="M55.4 27.2l-3.6-.6c-.4-1.2-.8-2.4-1.4-3.4l2.2-3c.6-.8.4-2-.2-2.6l-3-3c-.8-.6-1.8-.8-2.6-.2l-3 2.2c-1.2-.6-2.2-1-3.4-1.4l-.6-3.6c-.2-1-1-1.6-2-1.6h-4.2c-1 0-1.8.6-2 1.6l-.6 3.6c-1.2.4-2.4.8-3.4 1.4l-3-2.2c-.8-.6-2-.4-2.6.2l-3 3c-.6.8-.8 1.8-.2 2.6l2.2 3c-.6 1.2-1 2.2-1.4 3.4l-3.6.6c-1 .2-1.6 1-1.6 2v4.2c0 1 .6 1.8 1.6 2l3.6.6c.4 1.2.8 2.4 1.4 3.4l-2.2 3c-.6.8-.4 2 .2 2.6l3 3c.8.6 1.8.8 2.6.2l3-2.2c1.2.6 2.2 1 3.4 1.4l.6 3.6c.2 1 1 1.6 2 1.6h4.2c1 0 1.8-.6 2-1.6l.6-3.6c1.2-.4 2.4-.8 3.4-1.4l3 2.2c.8.6 2 .4 2.6-.2l3-3c.6-.8.8-1.8.2-2.6l-2.2-3c.6-1.2 1-2.2 1.4-3.4l3.6-.6c1-.2 1.6-1 1.6-2v-4.2c0-1-.6-1.8-1.6-2z"/>\n</svg>');class um extends(Wa(Va)){static get icon(){return um._defaultIcon||(um._defaultIcon=new Image,um._defaultIcon.src=dm),um._defaultIcon}get serviceName(){}get hasTextProperty(){return!1}is3dish(){return!0}buildRealObject(){return new hm(this)}render(t){if(this.app?.isViewMode)return;const{left:e,top:n,width:i,height:r}=this.bounds,s=this.constructor.icon;t.beginPath(),t.globalAlpha=.6,this.drawImage(t,s,e,n,i,r),t.globalAlpha=1}added(t){super.added(t);const e=this.serviceName;e&&(this._registeredRoot=this.root,this._registeredRoot?.registerService?.(e,this))}removed(t){const e=this.serviceName;e&&this._registeredRoot&&(this._registeredRoot.unregisterService?.(e),this._registeredRoot=void 0),super.removed(t)}get controls(){return[]}}function pm(t){return class extends t{animOnValueChange(t,e=!1,n){if(t==this._lastValue)return;if(this.root?.app?.suppressAnimations)return this._lastValue=t,this._anim_alpha=0,void this.invalidate();let i;i=e?t-(Number(n)||0):t-(this._lastValue||0),this._lastValue=t,this._anim_alpha=-i,this.animate({step:t=>{this._anim_alpha=i*(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=_s(this.getState("value"),this,void 0)||this.defaultValueSubstitutor),this._value_substitutor}get value(){return Number(this.valueSubstitutor())||0}set value(t){delete this._value_substitutor,this.setState("value",Number(ci(t)))}}}function fm(t){return class extends t{_convertDataFormat(t,e){let n;if("json"===e)n=JSON.parse(t);else n=t;return n}isDataSource(){return!0}}}function gm(t){var e;return(e=class extends t{is3dish(){return!0}get hasTextProperty(){return!1}get capturable(){return!1}render(t){}}).raycastTargetDefault=!1,e}const mm="$base_url",ym=[{type:"gltf-preset",label:"preset",name:"preset"},{type:"gltf-selector",label:"url",name:"src",property:{displayField:"id",displayFullUrl:!0,baseUrlAlias:mm,defaultStorage:"3d-model",storageFilters:{type:Array,value:[{name:"category",value:"image"}]},useUpload:!0,category:"application"},observe:function(t){const e=this.parentNode?.querySelector("[name=gltfInfo]");e&&(e.src=t);const n=this.parentNode?.querySelector("[name=fillStyleTargets]");n&&(n.src=t);const i=this.parentNode?.querySelector("[name=playTargets]");i&&(i.src=t)}},{type:"gltf-info",label:"",name:"gltfInfo",readonly:!0,property:{action:(t,e)=>{t._ratioLocking=!0;try{t.set(e)}finally{t._ratioLocking=!1}}},editor:{fullwidth:!0}},{type:"gltf-fill-targets",label:"fill-targets",name:"fillStyleTargets",editor:{fullwidth:!0}},{type:"gltf-play-targets",label:"play-targets",name:"playTargets",editor:{fullwidth:!0}}];function bm(t){return class extends t{constructor(){super(...arguments),this._snapshotLoading=!1,this._ratioLocking=!1}is3dish(){return!0}get hasTextProperty(){return!1}get controls(){return[]}render(t){const{left:e,top:n,width:i,height:r}=this.bounds;t.beginPath();const s=this._topViewSnapshot;if(s)return void t.drawImage(s,e,n,i,r);this._ensureTopViewSnapshot(),t.rect(e,n,i,r),t.fillStyle="#f0f0f0",t.fill(),t.strokeStyle="#999",t.lineWidth=1,t.stroke();const o=this.getState("src"),a=o&&o.split("/").pop()?.replace(/\.[^.]+$/,"")||"GLTF",c=Math.max(10,.12*Math.min(i,r));t.fillStyle="#666",t.font=`${c}px sans-serif`,t.textAlign="center",t.textBaseline="middle",t.fillText(a,e+i/2,n+r/2,.9*i)}onchange(t,e){super.onchange?.(t,e),"src"in t&&(this._topViewSnapshot=void 0)}_ensureTopViewSnapshot(){if(this._snapshotLoading)return;const t=this.getState("src");if(!t)return;const e=Qh.getTopViewCache(t);if(e)return this._topViewSnapshot=e,void this.invalidate();this._snapshotLoading=!0;const n=this.app.url(t);Qh.loadGLTF(n).then(e=>{if(this._snapshotLoading=!1,this.getState("src")!==t)return;const n=Qh.getTopViewCache(t);if(n)return this._topViewSnapshot=n,void this.invalidate();const i=Qh.renderTopView(e.scene);Qh.setTopViewCache(t,i),this._topViewSnapshot=i,this.invalidate()}).catch(()=>{this._snapshotLoading=!1})}buildRealObject(){return new Qh(this)}get source(){return this.getState("src")}set source(t){this.setState("src",t)}get play(){return!1!==this.getState("play")}set play(t){this.setState("play",t)}get nodes(){return this.getState("nodes")}set nodes(t){this.setState("nodes",t)}get animations(){return this.getState("animations")}set animations(t){this.setState("animations",t)}get playTargets(){return this.getState("playTargets")}set playTargets(t){this.setState("playTargets",t)}get fillStyleTargets(){return this.getState("fillStyleTargets")}set fillStyleTargets(t){this.setState("fillStyleTargets",t)}get nodeNames(){const t=this.realObject;return t?.nodeNames??[]}get animationNames(){const t=this.realObject;return t?.animationNames??[]}set dimension(t){const{width:e=1,height:n=1,depth:i=1}=t;this.setState({width:e,height:n,depth:i}),this.realObject?.updateDimension()}_applyRatioLock(t){if(!("width"in t||"height"in t||"depth"in t))return t;const e=this.state.width||1,n=this.state.height||1,i=this.state.depth||1,r=xu([(t.width??e)/e,(t.height??n)/n,(t.depth??i)/i]);return r?{...t,width:Math.round(e*r),height:Math.round(n*r),depth:Math.round(i*r)}:t}set(t,e){if("string"==typeof t&&(t={[t]:e}),this.state?.ratioLock&&!this._ratioLocking){this._ratioLocking=!0;try{t=this._applyRatioLock(t)}finally{}}try{return super.set(t)}finally{this._ratioLocking=!1}}setState(t,e){if("string"==typeof t&&(t={[t]:e}),this.state?.ratioLock&&!this._ratioLocking){this._ratioLocking=!0;try{t=this._applyRatioLock(t)}finally{}}try{return super.setState(t)}finally{this._ratioLocking=!1}}}}function _m(t){return function(e){return Array.isArray(t)?t.forEach(t=>{Va.register(t,e)}):Va.register(t,e),e}}let vm=0;const xm=new FinalizationRegistry(()=>{vm--});class wm{static get residents(){return vm}static get residentsCount(){return vm}constructor(t,e){this.counters={},this.references={},this.creator=t,this.disposer=e,vm++,xm.register(this,vm)}dispose(){if(this.disposer)for(const t in this.references)this.disposer(t,this.references[t]);this.references={},this.counters={}}get ids(){return Object.keys(this.references)}create(t){return new Promise((e,n)=>{this.creator?this.creator(t,n=>{n.release=()=>{this.disposer?.(t,n),delete n.release,Ni("RELEASED",t)},e(n)},n):n(Error("Reference id("+t+") could not be created. Reference creator should be defined."))})}add(t,e){const n=new Promise((n,i)=>{const r=this.references[t];if(r)r===e?i(Error("Reference ID and target duplicate")):e?i(Error("Reference ID duplicate")):n(r);else{const r=e=>{e.release=()=>{this.release(e)},this.references[t]=e,this.counters[t]=1,n(e)};if(e)r(e);else{if(!this.creator)return void i(Error("Reference id("+t+") is not allowed. Reference creator should be defined."));this.creator(t,r,i)}}});return this.references[t]||(this.references[t]=n),n}async get(t,e=!1){let n=this.references[t];if(n){if(!(n instanceof Promise)){if(!(t in this.counters))throw new Error("No Reference Count");return this.counters[t]++,n}if(e)return n=await n,this.counters[t]++,n}if(e)return await this.add(t);throw new Error("No References for "+t)}_id(t){for(const e in this.references){if(this.references[e]===t)return e}}release(t){const e=this._id(t);if(!e)return void Fi("No Referenced ID");const n=this.references[e];n&&(this.counters[e]--,0==this.counters[e]&&(this.disposer?.(e,n),delete this.references[e],delete this.counters[e],delete t.release,Ni("RELEASED",e)))}}const Mm={},Sm={};let Am=[];function Em(t){const e=t.target,n="SCRIPT"===e.tagName?Mm:Sm,i=e.src||e.href;n[i]=!0,Am.forEach((t,e)=>{if(!t)return;const{resolve:r,scripts:s,styles:o}=t;if(n===Mm){const t=s.indexOf(i);t>-1&&t<s.length-1&&Cm(s[t+1])}s.some(t=>!Mm[t])||o?.some(t=>!Sm[t])||(r(),Am[e]=null)}),Am=Am.filter(Boolean)}function km(t){if("string"==typeof t)return;const e=t.target,n=e.src,i="SCRIPT"===e.tagName?Mm:Sm;Am.forEach((e,r)=>{if(!e)return;const{reject:s,scripts:o,styles:a}=e;(i===Mm&&o.includes(n)||i===Sm&&!!a?.includes(n))&&(s(t),Am[r]=null)}),Am=Am.filter(Boolean),delete i[n],document.head.removeChild(e)}function Cm(t){Mm[t]=!1;const e=document.createElement("script");e.onload=Em,e.onerror=km,e.type="text/javascript",e.src=t,document.head.appendChild(e)}class Tm{static load(t,e){const n="string"==typeof t?[t]:t,i="string"==typeof e?[e]:e;return new Promise(function(t,e){if(n&&!Array.isArray(n)||i&&!Array.isArray(i))return void e(new Error("invalid sources for load"));let r,s=!0;if(i?.forEach(t=>{t in Sm||function(t){Sm[t]=!1;const e=document.createElement("link");e.onload=Em,e.onerror=km,e.type="text/css",e.rel="stylesheet",e.media="screen,print",e.href=t,document.head.appendChild(e)}(t),Sm[t]||(s=!1)}),n&&n.length>0)for(const t of n)t in Mm?Mm[t]||(s=!1):r??=t;if(r)Cm(r);else if(s)return void t();Am.push({resolve:t,reject:e,scripts:n,styles:i})})}}const Pm="0.0.0";function Dm(t){if(!(t>0))return 1;let e=0;if(!(t&t-1))return t;for(;0!=t;)t>>=1,e+=1;return 1<<e}function Om(t){const{lineWidth:e=0}=t.state;let{width:n,height:i}=t.bounds;n+=e,i+=e;const r=Dm(2*n),s=Dm(2*i),o=Xd(r,s),a=new w.CanvasTexture(o);return zm(o,t,2),a.needsUpdate=!0,a.wrapS=w.RepeatWrapping,a.wrapT=w.RepeatWrapping,a.offset.set(0,1-2*i/s),a.repeat.set(2*n/r,2*i/s),a.magFilter=w.NearestFilter,a.minFilter=w.LinearFilter,a.colorSpace=w.SRGBColorSpace,a}function zm(t,e,n){const{lineWidth:i=0}=e.state;let{left:r,top:s}=e.bounds;r-=i/2,s-=i/2;const o=t.getContext("2d");o.scale(n,n),o.translate(-r,-s),e.render(o),e.postrender(o)}function Lm(t,e,n=2){const i=t.getContext("2d");i&&(i.setTransform(1,0,0,1,0,0),i.clearRect(0,0,t.width,t.height),zm(t,e,n))}const Im=new Set(["cx","cy","cz","zPos","left","top","width","height","depth","lineWidth","rotationX","rotationY","rotation","scale","hidden","alpha","material3d","screenFixed"]);class Rm extends $h{get syncZPosOffset(){return this.effectiveDepth}get geometricOffsetY(){return this.effectiveDepth}constructor(t){super(t),this._origInvalidate=t.invalidate.bind(t),t.invalidate=()=>{this._origInvalidate(),this._refreshTextureNow()}}getObject3dInstance(){return new w.Mesh}build(){super.build();const{width:t,height:e}=this.component.bounds;if(!t||!e)return;const n=Mh(this.component.state.material3d),i=new w.PlaneGeometry(1,1);i.rotateX(-Math.PI/2),this.object3d.geometry=i;const r=Om(this.component);this.object3d.material=new w.MeshStandardMaterial({map:r,transparent:!0,side:w.DoubleSide,metalness:n.metalness,roughness:n.roughness,emissive:new w.Color(n.emissive),emissiveIntensity:n.emissiveIntensity}),this.object3d.castShadow=n.castShadow,this.object3d.receiveShadow=n.receiveShadow}updateDimension(){const{width:t,height:e}=this.component.bounds;this.object3d.scale.set(t,1,e)}updateAlpha(){const{alpha:t=1,fillStyle:e}=this.component.state;zh(this.object3d.material,t,e)}updateHidden(){this.object3d.visible=!this.component.state.hidden}_debouncedRebuild(){this._debounceTimer&&clearTimeout(this._debounceTimer),this._debounceTimer=setTimeout(()=>{this._debounceTimer=void 0,this._rebuildTexture()},100)}_rebuildTexture(){this.clear(),this.build(),this.updateTransform(),this.updateDimension(),this.updateHidden()}_refreshTextureNow(){const t=this.object3d.material,e=t?.map;if(!e)return;const n=e.source?.data;n&&(Lm(n,this.component,2),e.needsUpdate=!0)}updateFillStyle(){this._debouncedRebuild()}updateStrokeStyle(){this._debouncedRebuild()}updateText(){this._debouncedRebuild()}onchange(t,e){super.onchange(t,e);for(const e of Object.keys(t))if(!Im.has(e)){this._debouncedRebuild();break}}updateMaterial3d(){super.updateMaterial3d();const t=this.object3d.material;if(!t)return;const e=Mh(this.component.state.material3d);t.metalness=e.metalness,t.roughness=e.roughness,t.emissive.set(e.emissive),t.emissiveIntensity=e.emissiveIntensity}clear(){return this._debounceTimer&&(clearTimeout(this._debounceTimer),this._debounceTimer=void 0),Hh(this.object3d),super.clear()}dispose(){this._debounceTimer&&(clearTimeout(this._debounceTimer),this._debounceTimer=void 0),this._origInvalidate&&(this.component.invalidate=this._origInvalidate,this._origInvalidate=void 0),super.dispose()}}class jm extends $h{getObject3dInstance(){return new w.Mesh}build(){super.build(),this.buildGeometry(),this.buildMaterial()}updateAlpha(){const{alpha:t=1,fillStyle:e}=this.component.state;zh(this.object3d.material,t,e)}updateHidden(){this.object3d.visible=!this.component.state.hidden}updateFillStyle(){const{fillStyle:t}=this.component.state,e=this.object3d.material;if(!e)return;const n=$h.buildFillStyleTexture(this.component);n?(e.map&&e.map.dispose(),n.needsUpdate=!0,e.map=n):"string"==typeof t&&("transparent"!==t?e.color.set(Lh(t)):e.opacity=0)}updateStrokeStyle(){const t=this.object3d.getObjectByName("__edgeLines__");t&&(this.object3d.remove(t),Hh(t));const{strokeStyle:e}=this.component.state;if(!e||"transparent"===e||"none"===e)return;const n=this.object3d.geometry;if(!n?.getAttribute("position"))return;const i=new w.EdgesGeometry(n),r=new w.LineBasicMaterial({color:e}),s=new w.LineSegments(i,r);s.name="__edgeLines__",this.object3d.add(s)}updateDimension(){const{width:t,height:e}=this.component.bounds,{depth:n=1}=this.component.state;if(!this.object3d)return;this.object3d.geometry.computeBoundingBox();const i=this.object3d.geometry.boundingBox;if(i){const r=i.max.x-i.min.x,s=i.max.y-i.min.y,o=i.max.z-i.min.z;this.object3d.scale.set(t/r,n/s,e/o)}}buildMaterial(){const t=Mh(this.component.state.material3d),e=new w.MeshStandardMaterial({transparent:!0});Eh(e,t),this.object3d.material=e}updateMaterial3d(){super.updateMaterial3d();const t=this.object3d.material;t&&Eh(t,Mh(this.component.state.material3d))}clear(){return Hh(this.object3d),super.clear()}}function Fm(t,e,n,i){return[["bold",t],["italic",e],[n+"px",!0],[i,!0]].filter(t=>t[1]).map(t=>t[0]).join(" ")}function Bm(t){let e=0;if(!((t=Math.abs(t)||1)&t-1))return t;for(;0!=t;)t>>=1,e+=1;return 1<<e}function Nm(t,e,n){const{bold:i=!1,italic:r=!1,fontFamily:s="Serif",fontSize:o=10,fontColor:a="black",textAlign:c="center",textBaseline:l="middle",width:h=t.width,height:d=t.height,offsetX:u=0,offsetY:p=0}=n||{},f=t.getContext("2d");let g,m;f.imageSmoothingEnabled=!1,f.fillStyle=a,f.strokeStyle=a,f.font=Fm(i,r,o,s),"left"===c||"start"===c?(f.textAlign="left",g=u):"right"===c||"end"===c?(f.textAlign="right",g=u+h):(f.textAlign="center",g=u+h/2);const y=1.2*o,b=String(e).split("\n"),_=y*b.length;m="top"===l||"hanging"===l?p+.1*o:"bottom"===l||"alphabetic"===l?p+d-_+.1*o:p+(d-_)/2+.1*o,f.textBaseline="top";for(const t of b)f.fillText(t,g,m),m+=y}function Hm(t,e,n,i){const r=Bm(2*e),s=Bm(2*n),o=Xd(r,s),a=o.getContext("2d"),{fillStyle:c}=i||{};if(c&&"object"==typeof c&&c.colorStops?.length){const t=Yh(c,2*e,2*n);t&&a.drawImage(t,0,0)}a.scale(2,2),"string"==typeof c&&""!==c&&"transparent"!==c&&(a.fillStyle=c,a.fillRect(0,0,e,n)),Nm(o,t,i);const l=new w.CanvasTexture(o);return l.needsUpdate=!0,l.wrapS=w.RepeatWrapping,l.wrapT=w.RepeatWrapping,l.offset.set(0,1-2*n/s),l.repeat.set(2*e/r,2*n/s),l.minFilter=w.LinearFilter,l.colorSpace=w.SRGBColorSpace,l}function Ym(t,e,n,i,r,s,o){const a=new Image;a.crossOrigin="anonymous",a.onload=()=>{const t=2*n,c=2*i,l=Bm(t),h=Bm(c),d=Xd(l,h),u=d.getContext("2d");if(s.color&&(u.fillStyle=s.color,u.fillRect(0,0,t,c)),s.fitPattern)u.drawImage(a,0,0,t,c);else{const e=2*(s.width||a.naturalWidth),n=2*(s.height||a.naturalHeight),i=2*(s.offsetX||0),r=2*(s.offsetY||0);let o=0,l=0;switch(s.align){case"center":o=(t-e)/2,l=(c-n)/2;break;case"left-top":break;case"left-bottom":l=c-n;break;case"right-top":o=t-e;break;case"right-bottom":o=t-e,l=c-n;break;case"left":l=(c-n)/2;break;case"right":o=t-e,l=(c-n)/2;break;case"top":o=(t-e)/2;break;case"bottom":o=(t-e)/2,l=c-n}const h=i+o,d=r+l;if(s.noRepeat)u.drawImage(a,0,0,a.naturalWidth,a.naturalHeight,h,d,e,n);else{u.save(),u.rect(0,0,t,c),u.clip();const i=h>0?h-Math.ceil(h/e)*e:h;for(let r=d>0?d-Math.ceil(d/n)*n:d;r<c;r+=n)for(let s=i;s<t;s+=e)u.drawImage(a,0,0,a.naturalWidth,a.naturalHeight,s,r,e,n);u.restore()}}e&&(u.scale(2,2),Nm(d,e,r));const p=new w.CanvasTexture(d);p.needsUpdate=!0,p.wrapS=w.RepeatWrapping,p.wrapT=w.RepeatWrapping,p.offset.set(0,1-c/h),p.repeat.set(t/l,c/h),p.minFilter=w.LinearFilter,p.colorSpace=w.SRGBColorSpace,o(p)},a.onerror=()=>{const t=Hm(e,n,i,r);o(t)},a.src=t}function Gm(t,e){let{bold:n=!1,italic:i=!1,fontFamily:r="Serif",fontSize:s=10,lineHeight:o="normal"}=e||{};t=void 0===t||""==t?" ":String(t);const a=document.createElement("span");a.style.font=Fm(n,i,s,r),a.style.lineHeight=String(o),a.style.whiteSpace="pre",a.style.position="absolute",a.textContent=t,document.body.appendChild(a);const c=a.getBoundingClientRect();return document.body.removeChild(a),{width:c.width,height:c.height}}class Vm extends jm{get syncZPosOffset(){return this.effectiveDepth}get geometricOffsetY(){return this.effectiveDepth}buildGeometry(){this.updateDimension()}updateStrokeStyle(){}updateFillStyle(){this.updateText()}updateDimension(){const{width:t,height:e}=this.component.state,n=Math.abs(t)||1,i=Math.abs(e)||1;this.object3d.geometry&&this.object3d.geometry.dispose();const r=new w.PlaneGeometry(n,i);r.rotateX(-Math.PI/2),this.object3d.geometry=r}updateText(){const t=this.object3d.material;if(!t)return;const{width:e,height:n,bold:i=!1,italic:r=!1,fontFamily:s="Serif",fontSize:o=10,fontColor:a="black",textAlign:c="center",textBaseline:l="middle",fillStyle:h}=this.component.state,d=Math.abs(e)||1,u=Math.abs(n)||1,p=this.component.text,f=h&&"none"!==h?h:"transparent",g={bold:i,italic:r,fontFamily:s,fontSize:o,fontColor:a,textAlign:c,textBaseline:l,width:d,height:u,fillStyle:f};if("object"==typeof f&&"pattern"===f?.type&&f.image){return void Ym(this.component.app.url(h.image),p,d,u,g,h,e=>{t.map&&t.map.dispose(),t.map=e,t.color.set(16777215),t.needsUpdate=!0})}const m=Hm(p,d,u,g);m?(t.map&&t.map.dispose(),t.map=m,t.color.set(16777215),m.needsUpdate=!0):"string"==typeof h&&(""!==h&&"transparent"!==h?t.color.set(Lh(h)):t.opacity=0)}updateAlpha(){const{alpha:t=1}=this.component.state,e=this.object3d.material;e.opacity=t,e.transparent=!0}}iu("text",t=>new Vm(t));const Um={input:"css3d",select:"css3d",textarea:"css3d",button:"css3d",iframe:"css3d",video:"css3d",label:"texture",table:"texture",progress:"texture"};function $m(t){const e=t.model?.type??"";return"texture"===(Um[e]??"css3d")?new Rm(t):new tu(t)}iu("html-overlay-element",$m),iu("html-overlay-container",$m);class Wm{setShape({extrudedShape:t,extrudedOptions:e}){this.extrudedShape=t,this.bb=new w.Box2,this.bb.setFromPoints(this.extrudedShape?.extractPoints(0).shape),this.extrudedOptions=e}generateTopUV(t,e,n,i,r){const s=e[3*n],o=e[3*n+1],a=e[3*i],c=e[3*i+1],l=e[3*r],h=e[3*r+1],d=this.bb,u=d.max.x-d.min.x,p=d.max.y-d.min.y;return[new w.Vector2((s-d.min.x)/u,1-(o-d.min.y)/p),new w.Vector2((a-d.min.x)/u,1-(c-d.min.y)/p),new w.Vector2((l-d.min.x)/u,1-(h-d.min.y)/p)]}generateSideWallUV(t,e,n,i,r,s){const o=e[3*n],a=e[3*n+1],c=e[3*n+2],l=e[3*i],h=e[3*i+1],d=e[3*i+2],u=e[3*r],p=e[3*r+1],f=e[3*r+2],g=e[3*s],m=e[3*s+1],y=e[3*s+2],b=this.extrudedOptions?.depth||100,_=this.bb,v=_.max.x-_.min.x,x=_.max.y-_.min.y;return Math.abs(a-h)<.01?[new w.Vector2(o/v,1-c/b),new w.Vector2(l/v,1-d/b),new w.Vector2(u/v,1-f/b),new w.Vector2(g/v,1-y/b)]:[new w.Vector2(a/x,1-c/b),new w.Vector2(h/x,1-d/b),new w.Vector2(p/x,1-f/b),new w.Vector2(m/x,1-y/b)]}}class Xm extends $h{clear(){return this._mesh=void 0,super.clear()}get shape(){return null}get boundUVGenerator(){return this._boundUVGenerator||(this._boundUVGenerator=new Wm),this._boundUVGenerator}build(){super.build();const t=this.effectiveDepth,e=this.shape;if(!e)return;const n=this.boundUVGenerator;n&&n.setShape({extrudedShape:e,extrudedOptions:{depth:t}});const i=this.createGeometry(e),r=this.createMaterials();this._mesh=new w.Mesh(i,r),this._mesh.rotation.x=-Math.PI/2,this._mesh.rotation.y=-Math.PI,this._mesh.rotation.z=-Math.PI,this._mesh.castShadow=!0,this.object3d.add(this._mesh),this.updateFillStyle(),this.updateStrokeStyle()}createGeometry(t){const e=this.effectiveDepth,{lineWidth:n=0}=this.component.state,i={steps:1,depth:e,bevelEnabled:n>0,bevelThickness:0,bevelSize:n,bevelSegments:1,UVGenerator:this.boundUVGenerator},r=new w.ExtrudeGeometry(t,i);return r.center(),r}createMaterials(){const t=Mh(this.component.state.material3d),e=new w.MeshStandardMaterial;Eh(e,t);const n=new w.MeshStandardMaterial;return Eh(n,t),[e,n]}createTexture(){const{width:t,height:e}=this.component.bounds,n=Bm(t),i=Bm(e),r=Xd(n,i);this.component.render(r.getContext("2d"));const s=new w.CanvasTexture(r);return s.needsUpdate=!0,s.wrapS=w.RepeatWrapping,s.wrapT=w.RepeatWrapping,s.offset.set(0,1-e/i),s.repeat.set(t/n,e/i),s.minFilter=w.LinearFilter,s}getMaterials(){if(!this._mesh)return;const t=this._mesh.material;return Array.isArray(t)?t:void 0}updateMaterial3d(){super.updateMaterial3d();const t=this.getMaterials();if(!t)return;const e=Mh(this.component.state.material3d);for(const n of t)Eh(n,e)}updateAlpha(){const{alpha:t=1,fillStyle:e,strokeStyle:n}=this.component.state,i=this.getMaterials();i&&(zh(i[0],t,e),zh(i[1],t,n))}updateStrokeStyle(){const t=this.getMaterials();if(!t)return;const{strokeStyle:e}=this.component.state;t[1].color.set(Lh(e))}updateFillStyle(){this._applyCapTexture()}updateText(){this._applyCapTexture()}_applyCapTexture(){const t=this.getMaterials();if(!t)return;const e=t[0],{fillStyle:n}=this.component.state,i=this.component.hasTextProperty?this.component.text:"";if(!i){const t=$h.buildFillStyleTexture(this.component);return t?(e.map&&e.map.dispose(),e.map=t,e.color.set(16777215)):(e.map&&(e.map.dispose(),e.map=null),e.color.set(Lh(n))),void(e.needsUpdate=!0)}const{bold:r=!1,italic:s=!1,fontFamily:o="Serif",fontSize:a=10,fontColor:c="black",textAlign:l="center",textBaseline:h="middle",paddingTop:d=0,paddingLeft:u=0,paddingRight:p=0,paddingBottom:f=0}=this.component.state,{width:g,height:m}=this.component.bounds,y=Math.abs(g)||1,b=Math.abs(m)||1,_={bold:r,italic:s,fontFamily:o,fontSize:a,fontColor:c,textAlign:l,textBaseline:h,width:Math.max(y-u-p,0),height:Math.max(b-d-f,0),fillStyle:n,offsetX:u,offsetY:d};if("object"==typeof n&&"pattern"===n?.type&&n.image){return void Ym(this.component.app.url(n.image),i,y,b,_,n,t=>{e.map&&e.map.dispose(),e.map=t,e.color.set(16777215),e.needsUpdate=!0})}e.map&&e.map.dispose();const v=Hm(i,y,b,_);e.map=v,e.color.set(16777215),e.needsUpdate=!0}updateDimension(){super.updateDimension()}}class qm extends Xm{get shape(){const{cx:t=0,cy:e=0,rx:n=1,ry:i=1,startAngle:r=0,endAngle:s=2*Math.PI,anticlockwise:o=!1}=this.component.state,a=new w.EllipseCurve(t,e,Math.abs(n),Math.abs(i),r,s,o,0);return new w.Shape(a.getPoints(50))}}iu("ellipse",t=>new qm(t));class Km extends Xm{get shape(){const{width:t,height:e,round:n=0}=this.component.state,i=$a(n,t,e);if(i>0){const n=i,r=new w.Path;return r.moveTo(n,0),r.lineTo(t-n,0),r.quadraticCurveTo(t,0,t,n),r.lineTo(t,e-n),r.quadraticCurveTo(t,e,t-n,e),r.lineTo(n,e),r.quadraticCurveTo(0,e,0,e-n),r.lineTo(0,n),r.quadraticCurveTo(0,0,n,0),new w.Shape(r.getPoints(12))}const r=new w.Shape;return r.moveTo(0,0),r.lineTo(t,0),r.lineTo(t,e),r.lineTo(0,e),r.lineTo(0,0),r}}iu("rect",t=>new Km(t));class Qm extends Xm{get shape(){const{path:t=[],round:e=0}=this.component.state;if(e>0){const n=new w.Path;for(let i=0;i<t.length;i++){const r=t[(i-1+t.length)%t.length],s=t[i],o=t[(i+1)%t.length];if(r.x===s.x&&r.y===s.y)continue;let a=Math.sqrt((r.x-s.x)**2+(r.y-s.y)**2),c=0!==a?Math.atan2(r.x-s.x,r.y-s.y):0;const l=Math.sin(c)*Math.min(e,a/2)+s.x,h=Math.cos(c)*Math.min(e,a/2)+s.y;a=Math.sqrt((o.x-s.x)**2+(o.y-s.y)**2),c=0!==a?Math.atan2(o.x-s.x,o.y-s.y):0;const d=Math.sin(c)*Math.min(e,a/2)+s.x,u=Math.cos(c)*Math.min(e,a/2)+s.y;0===i?n.moveTo(l,h):n.lineTo(l,h),n.quadraticCurveTo(s.x,s.y,d,u)}return new w.Shape(n.getPoints(12))}const n=new w.Shape;for(let e=0;e<t.length;e++)0===e?n.moveTo(t[e].x,t[e].y):n.lineTo(t[e].x,t[e].y);return n}get minMax(){if(!this._minMax){const{path:t}=this.component.state;let e,n,i,r;t.forEach((t,s)=>{if(0==s)return e=i=t.x,void(n=r=t.y);e=Math.min(e,t.x),i=Math.max(i,t.x),n=Math.min(n,t.y),r=Math.max(r,t.y)}),this._minMax={minX:e,minY:n,maxX:i,maxY:r}}return this._minMax}}iu("polygon",t=>new Qm(t));class Zm extends Xm{get shape(){const{cx:t=0,cy:e=0,rx:n=1,ry:i=1,ratio:r=50,startAngle:s=0,endAngle:o=2*Math.PI,anticlockwise:a=!1}=this.component.state,c=Math.abs(n),l=Math.abs(i),h=new w.EllipseCurve(t,e,c,l,s,o,a,0),d=new w.Shape(h.getPoints(50)),u=c/100*r,p=l/100*r;if(u>0&&p>0){const n=new w.EllipseCurve(t,e,u,p,s,o,a,0),i=new w.Path(n.getPoints(50));d.holes.push(i)}return d}}iu("donut",t=>new Zm(t));class Jm extends Xm{get shape(){const{x1:t=0,y1:e=0,x2:n=0,y2:i=0,x3:r=0,y3:s=0,round:o=0}=this.component.state,a=[{x:t,y:e},{x:n,y:i},{x:r,y:s}];if(o>0){const t=new w.Path;for(let e=0;e<a.length;e++){const n=a[(e-1+a.length)%a.length],i=a[e],r=a[(e+1)%a.length];let s=Math.sqrt((n.x-i.x)**2+(n.y-i.y)**2),c=0!==s?Math.atan2(n.x-i.x,n.y-i.y):0;const l=Math.sin(c)*Math.min(o,s/2)+i.x,h=Math.cos(c)*Math.min(o,s/2)+i.y;s=Math.sqrt((r.x-i.x)**2+(r.y-i.y)**2),c=0!==s?Math.atan2(r.x-i.x,r.y-i.y):0;const d=Math.sin(c)*Math.min(o,s/2)+i.x,u=Math.cos(c)*Math.min(o,s/2)+i.y;0===e?t.moveTo(l,h):t.lineTo(l,h),t.quadraticCurveTo(i.x,i.y,d,u)}return new w.Shape(t.getPoints(12))}const c=new w.Shape;return c.moveTo(t,e),c.lineTo(n,i),c.lineTo(r,s),c.closePath(),c}}iu("triangle",t=>new Jm(t));class ty extends Xm{get shape(){const{ratio:t=30,wing:e=5,cx:n=0,cy:i=0,rx:r=1,ry:s=1}=this.component.state;if(e<3)return null;const o=Math.PI/2,a=2*Math.PI/e,c=r-t/100*r,l=s-t/100*s,h=new w.Shape;h.moveTo(n+r*Math.cos(-o),i+s*Math.sin(-o)),h.lineTo(n+(r-c)*(Math.cos(a-o)+Math.cos(0-o))/2,i+(s-l)*(Math.sin(a-o)+Math.sin(0-o))/2);for(let t=1;t<e;t++)h.lineTo(n+r*Math.cos(a*t-o),i+s*Math.sin(a*t-o)),h.lineTo(n+(r-c)*(Math.cos(a*(t+1)-o)+Math.cos(a*t-o))/2,i+(s-l)*(Math.sin(a*(t+1)-o)+Math.sin(a*t-o))/2);return h.closePath(),h}}iu("star",t=>new ty(t));const ey={mutable:!1,resizable:!0,rotatable:!0,properties:[],help:"scene/component/sphere"};class ny extends jm{buildGeometry(){const{rx:t=0,ry:e=0,rz:n}=this.component.state,i=n??t,r=new w.SphereGeometry(1,32,16);r.scale(t,i,e),this.object3d.geometry=r}updateDimension(){this.buildGeometry()}get effectiveDepth(){const{rx:t=0,rz:e}=this.component.state,n=e??t;return Math.max(2*n,1)}}t.Sphere=class extends ag{get hasTextProperty(){return!1}is3dish(){return!0}buildRealObject(){return new ny(this)}get nature(){return ey}},t.Sphere=kp([_m("sphere")],t.Sphere);class iy extends $h{getObject3dInstance(){return new w.Sprite}build(){super.build(),this.buildMaterial()}get cz(){const{zPos:t=0}=this.component.state,{height:e}=this.component.bounds,{tz:n=0}=this.component.delta(),i=this.component.parent?._realObject;return t+n+e/2-(i?.geometricOffsetY??0)}get geometricOffsetY(){const{height:t=0}=this.component.bounds;return t/2}updateAlpha(){const{alpha:t=1,fillStyle:e}=this.component.state;zh(this.object3d.material,t,e)}updateHidden(){this.object3d.visible=!this.component.state.hidden}updateFillStyle(){const{fillStyle:t}=this.component.state,e=this.object3d.material;if(!e)return;const n=$h.buildFillStyleTexture(this.component);n?(e.map&&e.map.dispose(),n.needsUpdate=!0,e.map=n):"string"==typeof t&&("transparent"!==t?e.color.set(Lh(t)):e.opacity=0)}}class ry extends iy{buildMaterial(){const t=this.object3d.material;t&&t.dispose(),this.object3d.material=new w.SpriteMaterial({map:Om(this.component),alphaTest:.01,sizeAttenuation:!1})}get scale(){const{width:t,height:e}=this.component.bounds,n=this.threeContainer,{width:i=1,height:r=1}=n?.bounds??{},{scale:s=1}=this.component.state;return{x:s*t/i,y:s*e/r,z:s}}update(){this.build(),this.updateHidden()}updateFillStyle(){this.update()}updateStrokeStyle(){this.update()}updateAlpha(){this.update()}updateText(){this.update()}}const sy={mutable:!1,resizable:!0,rotatable:!0,properties:[]};t.Sprite=class extends(Wa(Ua)){get hasTextProperty(){return!1}is3dish(){return!0}buildRealObject(){return new ry(this)}get nature(){return sy}},t.Sprite=kp([_m("sprite")],t.Sprite);const oy={mutable:!1,resizable:!0,rotatable:!0,properties:[],help:"scene/component/cube"};class ay extends jm{buildGeometry(){const{width:t=0,height:e=0,depth:n=0}=this.component.state,i=new w.BoxGeometry(1,1,1);i.scale(t,n,e),this.object3d.geometry=i}}t.Cube=class extends(Wa(Ua)){get hasTextProperty(){return!1}is3dish(){return!0}buildRealObject(){return new ay(this)}get nature(){return oy}},t.Cube=kp([_m("cube")],t.Cube);const cy={mutable:!1,resizable:!0,rotatable:!0,properties:[],help:"scene/component/cylinder"};class ly extends jm{buildGeometry(){const{rx:t=0,ry:e=0}=this.component.state,n=this.component.state.depth??1,i=new w.CylinderGeometry(1,1,1,25);i.scale(t||1,n||1,e||1),this.object3d.geometry=i}updateDimension(){this.buildGeometry()}}t.Cylinder=class extends ag{get hasTextProperty(){return!1}is3dish(){return!0}buildRealObject(){return new ly(this)}get nature(){return cy}},t.Cylinder=kp([_m("cylinder")],t.Cylinder);const hy={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"color",label:"box-color",name:"boxColor",property:"boxColor"}],help:"scene/component/banner"};class dy extends $h{build(){super.build();const{width:t=1,height:e=1,depth:n=1}=this.component.state;this.object3d.add(this.createCube(t,e,n));const i=this.createTextureBoard(t,n);i.position.set(0,0,.5*e+1),this.object3d.add(i)}createCube(t,e,n){const{boxColor:i="#ccaa76"}=this.component.state,r=Mh(this.component.state.material3d),s=new w.BoxGeometry(t,n,e),o=new w.MeshStandardMaterial({color:i,side:w.FrontSide});Eh(o,r);const a=new w.Mesh(s,o);return a.castShadow=r.castShadow,a.receiveShadow=r.receiveShadow,a}createTextureBoard(t,e){const n=Mh(this.component.state.material3d),{fillStyle:i="#ccaa76"}=this.component.state,r=$h.buildFillStyleTexture(this.component),s=new w.MeshStandardMaterial(r?{map:r}:{color:i||"#ccaa76",side:w.FrontSide});Eh(s,n);const o=new w.PlaneGeometry(t,e,1,1),a=new w.Mesh(o,s);return a.castShadow=n.castShadow,a.receiveShadow=n.receiveShadow,a}updateMaterial3d(){super.updateMaterial3d();const t=Mh(this.component.state.material3d);this.object3d.traverse(e=>{if(e.isMesh){const n=e.material;n&&Eh(n,t),e.castShadow=t.castShadow,e.receiveShadow=t.receiveShadow}})}}var uy;t.Banner=class extends(Wa(Ua)){get hasTextProperty(){return!1}is3dish(){return!0}get nature(){return hy}buildRealObject(){return new dy(this)}},t.Banner=kp([_m("banner")],t.Banner);const py={far:1e5,fov:80,near:1,zoom:1},fy={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"number",label:"near",name:"near"},{type:"number",label:"far",name:"far"},{type:"number",label:"fov",name:"fov"},{type:"number",label:"zoom",name:"zoom"},{type:"checkbox",label:"show-helper",name:"showHelper"}],help:"scene/component/camera"};class gy extends $h{getObject3dInstance(){return new w.Mesh}updateCamera(){const{near:t=py.near,far:e=py.far,fov:n=py.fov,zoom:i=py.zoom,showHelper:r}=this.component.state;this.camera.far=e,this.camera.fov=n,this.camera.near=t,this.camera.zoom=i,r?this.helper||(this.helper=new w.CameraHelper(this.camera),this.object3d.add(this.helper)):this.helper&&(this.object3d.remove(this.helper),delete this.helper)}build(){super.build();const{width:t=0,height:e=0,depth:n=0,fillStyle:i="lightgray"}=this.component.state;this.object3d.geometry=new w.BoxGeometry(t,n,e),this.object3d.material=new w.MeshStandardMaterial({color:i,side:w.FrontSide}),this.camera=new w.PerspectiveCamera,this.camera.position.set(0,0,0),this.object3d.add(this.camera),this.object3d.lookAt(0,0,0),this.updateCamera()}}t.Camera=uy=class extends(Wa(Ua)){get hasTextProperty(){return!1}is3dish(){return!0}static get image(){return uy._image||(uy._image=new Image,uy._image.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA1IAAANSAQMAAABV6G1EAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAABlBMVEX6+voBAQGV71ZvAAAFO0lEQVR42u3dMZLkNBiGYakUKFRIqKOISxDvETiCTBEQcgQOQE7clyAi8REm7KDXIhgYoMa/7fbIX+2K9w022MCP/25Z28GW5RwRERERERERERERERERERERERERERERERERERERERERERERERHRl9mv7fdPn7879sf8Mcq3J3r5EJXaUy3Wddrcd6qNybx9F2/lZ63H+nVCa9Oe9elZa5ksa/dDbE+3fsm4v27C89bd+i6W3l+XdcnSWtuxyvPW+hqorbWb0Jr7Pl3m4tjfVMIZ625d6L5pxTPWw7rQY9P6pqu1dF8aq5d83cE3rXrGWluIxV6h53eotv4c1V3Ln7Nm66ZvvZf8SSues16sD2jubz2sC839fmvYiz7t//LJna27wsr7VjlnNWtPeHTfNlae2bZvnaTePUd+74fqV2LNxv6zdN8O3z9HSWhlc4F+dOvdsKbe2+F7q+zPddq6W2ts6r31vrN825/rtPWwvvcL5losy11uxQNz5U6fYT4w12mrWf80TUNZdetXal/LtwNW6WOFI1Y9bU3GVnfFXM9bneZKwrmKcK4qnKsK52q6uULTzRWFVjpkta/OykKrCq02puWFVhRaSWjlQa0itJrO8oNaQWgloZWFVhnUqjrLN50VBrWi0MpCqwitOqjVdFYQWlFopUGtLLSq0GpjWl5oRaGVBrWy0KpCq+ksP6gVhFYSWllolUGtqrNW/jvBZVYY1IpCKwutIrTqoFbTWUFoxUGtJLSK0KpCq41peaEVhVYa1MpCqwqtprP8oFYUWklo5UGtIrSazvJCKwxqRaGVhVYZ1Ko664ems34UWj8Nav0stBoWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhbW/9L6RWgp37WofIek8j2cyveLTkqrCq0itLLQSkJL+Q5k5budle/HVr73e/24gAHenZ6FlvK9+srzAoLQUp65oDy3QnoeRxFaWWgpz2pRnncThJbyzCDpuUtVaBWhlYWW8qwx5RlqynPovNBSnuUnPaOwCK0stJLQUp4BqjzbVHk+rFNaVWgVoZWFlvJc6Si0lGdzK88cV57bLj2PvgitLLSS0IpCKwgtL7Sc0qpCqwitLLSS0IpCKwgtL7Sc0qpCqwitLLSS0IpCKwgtL7Sc0qpCqwitLLSS0IpCKwgtL7Sc0qpCqwitLLSS0IpCKwgtL7Sc0qpCqxyyahcrH7JKFysJ54rCuYJwLi+cywnn+vdlLp+rCOfKwrnStXP95zLxiJX7WEFoeaHljO/xEqsaf9/FWqz1bM+VzloP655df2uxrnP9XPHKue7OeMDsuWInyx+Y67T1Yv0gs+cKvay6P5fvZZULrdnYFBbbcr2sdKF1MxbZFdZkLLItq3aay6/vJ102eusD2rJKl633nw/o3n+uxbrpLSv1svL6M95hQ3xYNz33t16sC21Zoc+28Xahm+u+Ic7WhbYs1+dRfrvQ5LpvHOaFNq3SZ8n/faEt6twDtli7wrJpxT6P1183/di0Ti36u3XT903Ld1qGrzf9smmdWhyTddNzf8t8UqdtK/dZGq8P2DZ1ZnHcrQ/osWO5PkvDuby7NE58Yctk7Qq3PSv3+bpc3F0aJ56wF+uLX9xu6eOb4es9z/vWc0vR3oZuByjnf2t/fP/54B/2WvvWEREREREREREREREREREREREREREREREREREREREREREREREREX2J/QlrTpqHD8xO1gAAAABJRU5ErkJggg=="),uy._image}render(t){const{left:e,top:n,width:i,height:r}=this.bounds;t.beginPath(),this.drawImage(t,uy.image,e,n,i,r)}buildRealObject(){return new gy(this)}get nature(){return fy}},t.Camera=uy=kp([_m("camera")],t.Camera);const my={mutable:!1,resizable:!0,rotatable:!0,properties:[...ym],"value-property":"source",help:"scene/component/gltf-object"};t.GLTFObject=class extends(bm(Wa(Ua))){get nature(){return my}},t.GLTFObject=kp([_m("gltf-object")],t.GLTFObject);const yy={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"select",label:"light-type",name:"lightType",property:{options:["","point","directional"]}},{type:"number",label:"intensity",name:"intensity"},{type:"number",label:"distance",name:"distance"},{type:"number",label:"decay",name:"decay"},{type:"checkbox",label:"cast-shadow",name:"castShadow"},{type:"number",label:"near",name:"near",placeholder:"0.5"},{type:"number",label:"far",name:"far",placeholder:"1000"},{type:"number",label:"fov",name:"fov",placeholder:"90"},{type:"number",label:"zoom",name:"zoom",placeholder:"1"},{type:"checkbox",label:"show-helper",name:"showHelper"}],help:"scene/component/light"};class by extends $h{updatePointLight(){const{lightType:t="point",distance:e=0,intensity:n=10,decay:i=1,fillStyle:r="white",castShadow:s,near:o=.5,far:a=1e3,fov:c=90,zoom:l=1,showHelper:h}=this.component.state;if(this.object3d.color=new w.Color(r),"point"==t&&(this.object3d.distance=e,this.object3d.decay=i),this.object3d.intensity=n,this.object3d.castShadow=s,s){const t=this.object3d.shadow?.camera;t.far=a,t.near=o,t.fov=c,t.zoom=l}if(h){const t=this.object3d.shadow?.camera;this.helper||(this.helper=new w.CameraHelper(t),this.object3d.add(this.helper))}else this.helper&&(this.object3d.remove(this.helper),delete this.helper)}getObject3dInstance(){const{lightType:t="point"}=this.component.state;return"point"==t?new w.PointLight:new w.DirectionalLight}update(){this.clear(),this.build(),this.updateDimension(),this.updateHidden(),this.updatePointLight()}}t.PointLight=class extends ag{get hasTextProperty(){return!1}is3dish(){return!0}buildRealObject(){return new by(this)}get anchors(){return[]}get nature(){return yy}},t.PointLight=kp([_m("light")],t.PointLight);const _y={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"number",label:"depth",name:"depth",property:"depth"}],help:"scene/component/wall"};class vy extends jm{buildGeometry(){const{width:t=0,height:e=0,depth:n=0}=this.component.state,i=new w.BoxGeometry(1,1,1);i.scale(t,n,e),this.object3d.geometry=i}}t.Wall=class extends(Wa(Ua)){get hasTextProperty(){return!1}is3dish(){return!0}buildRealObject(){return new vy(this)}get nature(){return _y}},t.Wall=kp([_m("wall")],t.Wall);const xy={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"number",label:"depth",name:"depth",property:"depth"}],help:"scene/component/floor-plate"};class wy extends $h{clear(){return this._topTexture&&(this._topTexture.dispose(),this._topTexture=void 0),this._mesh=void 0,super.clear()}build(){super.build();const{width:t,height:e,depth:n=1}=this.component.state;if(!t||!e)return;const i=Math.abs(t),r=Math.abs(e),s=Math.max(n,.5),o=new w.BoxGeometry(i,s,r),a=this._buildTopMaterial(),c=this._buildSideMaterial(),l=[c,c,a,c,c,c];this._mesh=new w.Mesh(o,l),this._mesh.position.y=0,this._mesh.receiveShadow=!0,this._mesh.castShadow=!1,this.object3d.add(this._mesh)}_buildTopMaterial(){const{alpha:t=1}=this.component.state,e=Mh(this.component.state.material3d),n=$h.buildFillStyleTexture(this.component);if(n){this._topTexture=n;const i=new w.MeshStandardMaterial({map:n,side:w.DoubleSide,transparent:!0,opacity:t,depthWrite:t>=.9});return Eh(i,e),i}const{fillStyle:i}=this.component.state,r="string"==typeof i&&"none"!==i?i:"#e0e0e0",s=new w.MeshStandardMaterial({color:r,side:w.DoubleSide,transparent:!0,opacity:t,depthWrite:t>=.9});return Eh(s,e),s}_buildSideMaterial(){const{strokeStyle:t,alpha:e=1}=this.component.state,n="string"==typeof t&&t?t:"#999999";return new w.MeshStandardMaterial({color:n,side:w.DoubleSide,transparent:!0,opacity:.8*e,depthWrite:e>=.9})}updateAlpha(){if(!this._mesh)return;const{alpha:t=1}=this.component.state,e=this._mesh.material;for(let n=0;n<e.length;n++){const i=e[n];i.opacity=2===n?t:.8*t,i.transparent=!0,i.depthWrite=t>=.9}}updateFillStyle(){if(!this._mesh)return;this._topTexture&&(this._topTexture.dispose(),this._topTexture=void 0);const t=this._mesh.material;t[2].dispose(),t[2]=this._buildTopMaterial()}updateStrokeStyle(){if(!this._mesh)return;const t=this._mesh.material,e=this._buildSideMaterial();for(let n=0;n<t.length;n++)2!==n&&(t[n].dispose(),t[n]=e)}}t.FloorPlate=class extends Zc{get hasTextProperty(){return!1}is3dish(){return!0}buildRealObject(){return new wy(this)}get nature(){return xy}},t.FloorPlate=kp([_m("floor-plate")],t.FloorPlate);function My(t,e={}){const n=e.size??5,i=e.color??4500172,r=e.emissive??2245734,s=new w.SphereGeometry(n,16,12),o=new w.MeshStandardMaterial({color:i,emissive:r,emissiveIntensity:.15,metalness:.3,roughness:.4,transparent:!0,opacity:.35}),a=new w.Mesh(s,o);e.position&&a.position.set(e.position[0],e.position[1],e.position[2]),a.userData.alwaysRaycast=!0,a.scale.setScalar(1),a.visible=e.visible??!!t.app?.isEditMode;const c=()=>{o.emissiveIntensity=.9,o.opacity=.95,a.scale.setScalar(1.35),t.invalidate?.()},l=()=>{o.emissiveIntensity=.15,o.opacity=.35,a.scale.setScalar(1),t.invalidate?.()};return t.on("mouseenter",c),t.on("mouseleave",l),a.userData.dispose=()=>{t.off("mouseenter",c),t.off("mouseleave",l)},a}class Sy extends jm{get syncZPosOffset(){return this.effectiveDepth}get geometricOffsetY(){return this.effectiveDepth}buildGeometry(){const{width:t,height:e}=this.component.state,n=Math.abs(t)||1,i=Math.abs(e)||1,r=new w.PlaneGeometry(n,i);r.rotateX(-Math.PI/2),this.object3d.geometry=r}updateDimension(){this.update()}buildMaterial(){super.buildMaterial();const t=this.object3d.material;t&&(t.side=w.DoubleSide)}build(){super.build();const{width:t,height:e}=this.component.state,n=Math.abs(t)||1,i=Math.abs(e)||1,r=Math.max(2,.04*Math.min(n,i));this.object3d.add(My(this.component,{size:r,position:[n/2-r,r,-i/2+r]}))}}const Ay={mutable:!1,resizable:!0,rotatable:!0,properties:[],help:"scene/component/decal"};let Ey=class extends(gm(Wa(Ua))){buildRealObject(){return new Sy(this)}get nature(){return Ay}};Ey=kp([_m("decal")],Ey);class ky extends $h{getObject3dInstance(){return new w.Group}get allowedGizmoModes(){return this.component.isGroup?.()?["translate"]:null}}const Cy="#dde2e8",Ty="#9c9c9c",Py="#e8e8ec",Dy=.35;function Oy(t,e,n,i){if(!e.visible)return new w.MeshStandardMaterial({transparent:!0,opacity:0,depthWrite:!1});const r=e.alpha*n,s="wall"===i?Cy:"floor"===i?Ty:Py,o=new w.MeshStandardMaterial({metalness:0,roughness:"wall"===i?.6:.85,transparent:r<1,opacity:r,side:w.DoubleSide});return function(t,e,n,i,r,s){if("string"==typeof n&&n&&"transparent"!==n)t.color.set(n);else{if(n&&"object"==typeof n){const i=$h.buildFillStyleTexture(e,n);if(i){t.map&&t.map.dispose();const e=!s;return i.wrapS=w.RepeatWrapping,e&&(i.repeat.x=-1,i.offset.x=1),r&&(i.center.set(.5,.5),i.rotation=r*Math.PI/180),i.needsUpdate=!0,t.map=i,void t.color.set("#ffffff")}}t.color.set(i)}}(o,t,e.fillStyle,s,e.rotation,e.mirror),o}class zy extends ky{get position(){if(this.component.state.fitToBoard){return{x:0,y:super.position.y,z:0}}return super.position}build(){super.build();const t=this.component.state;let e=t.width,n=t.height;if(t.fitToBoard){const t=this.component.rootModel,i=t?.state;i&&Number.isFinite(i.width)&&Number.isFinite(i.height)&&(e=i.width,n=i.height)}const i=this.effectiveDepth||Math.min(e,n)||200,r=t.alpha??1,s={east:this._resolveFace("east",Cy,!0,Dy),west:this._resolveFace("west",Cy,!0,Dy),north:this._resolveFace("north",Cy,!0,Dy),south:this._resolveFace("south",Cy,!0,Dy),floor:this._resolveFace("floor",Ty,!0,1),ceiling:this._resolveFace("ceiling",Py,!0,1)},o=[Oy(this.component,s.east,r,"wall"),Oy(this.component,s.west,r,"wall"),Oy(this.component,s.ceiling,r,"ceiling"),Oy(this.component,s.floor,r,"floor"),Oy(this.component,s.south,r,"wall"),Oy(this.component,s.north,r,"wall")],a=new w.BoxGeometry(e,i,n),c=new w.Mesh(a,o);if(c.receiveShadow=!0,this.object3d.add(c),this.component.app?.isEditMode){const t=new w.LineBasicMaterial({color:4473941,transparent:!0,opacity:.7}),e=new w.LineSegments(new w.EdgesGeometry(a),t);this.object3d.add(e)}const l=.04*Math.min(e,n,i);this.object3d.add(My(this.component,{size:l,position:[e/2,i/2+l,-n/2]}))}_resolveFace(t,e,n,i){const r=this.component.state,s=r.faces?.[t]??{},o=s.visible,a=s.alpha,c=s.rotation,l=90===c||180===c||270===c?c:0;return{fillStyle:s.fillStyle??e,visible:"boolean"==typeof o?o:n,alpha:"number"==typeof a&&Number.isFinite(a)?a:i,rotation:l,mirror:!0===s.mirror}}updateDimension(){}onchange(t,e){["alpha","width","height","depth","fitToBoard","faces"].some(e=>e in t)?this.update():super.onchange(t,e)}updateAlpha(){}}const Ly={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"checkbox",label:"fit-to-board",name:"fitToBoard"},{type:"backdrop-faces",label:"",name:"faces"}],help:"scene/component/backdrop"};let Iy=class extends(gm(Wa(Ua))){buildRealObject(){return new zy(this)}get nature(){return Ly}added(t){super.added?.(t),this.state.fitToBoard&&(this._syncFromRoot(!0),this._attachRootListener())}async ready(){await(super.ready?.()),this.state.fitToBoard&&this._syncFromRoot(!1)}removed(t){this._detachRootListener(),super.removed?.(t)}dispose(){this._detachRootListener(),super.dispose?.()}onchange(t,e){"fitToBoard"in t&&(t.fitToBoard?(this._syncFromRoot(!0),this._attachRootListener()):this._detachRootListener()),super.onchange?.(t,e)}_syncFromRoot(t=!1){const e=this.rootModel;if(!e||e===this)return;const n=e.state;if(!n)return;const i={},r=Number.isFinite(n.width)?n.width:this.state.width,s=Number.isFinite(n.height)?n.height:this.state.height;r!==this.state.width&&(i.width=r),s!==this.state.height&&(i.height=s);const o=Number.isFinite(n.left)?n.left:0,a=Number.isFinite(n.top)?n.top:0;if(o!==this.state.left&&(i.left=o),a!==this.state.top&&(i.top=a),t){const t=this.state.depth;if(!("number"==typeof t&&Number.isFinite(t)&&t>0)){const e=Math.min(r,s);e!==t&&(i.depth=e)}}Object.keys(i).length>0&&this.set(i)}_attachRootListener(){if(this._onRootChange)return;const t=this.rootModel;t&&t!==this&&(this._onRootChange=t=>{("width"in t||"height"in t||"left"in t||"top"in t)&&this._syncFromRoot()},t.on?.("change",this._onRootChange))}_detachRootListener(){if(!this._onRootChange)return;const t=this.rootModel;t?.off?.("change",this._onRootChange),this._onRootChange=void 0}};function Ry(t,e){return"none"===t?0:t.endsWith("arrow")?1.5*e:0}function jy(t,e,n,i){const r=[];for(let s=1;s<=i;s++){const o=s/i,a=1-o;r.push(new w.Vector3(a*a*t.x+2*a*o*e.x+o*o*n.x,a*a*t.y+2*a*o*e.y+o*o*n.y,a*a*t.z+2*a*o*e.z+o*o*n.z))}return r}Iy=kp([_m("backdrop")],Iy);class Fy extends $h{getObject3dInstance(){return new w.Group}get gizmoTransformable(){return!0}get syncZPosOffset(){return 0}get geometricOffsetY(){return 0}syncFromObject3D(){}applyDimensionFromGizmo(t){}build(){super.build(),this._buildLine()}get smoothedPath(){const t=this.worldPath;if(t.length<2)return t;const{round:e=0}=this.component.state;if(e<=0||t.length<3)return t;const n=[];n.push(t[0]);for(let i=1;i<t.length;i++){const r=t[i-1],s=t[i],o=t[i+1];if(!o){n.push(s);break}const a=r.x-s.x,c=r.y-s.y,l=r.z-s.z,h=Math.sqrt(a*a+c*c+l*l),d=Math.min(e,h/2),u=o.x-s.x,p=o.y-s.y,f=o.z-s.z,g=Math.sqrt(u*u+p*p+f*f),m=Math.min(e,g/2),y=h>0?new w.Vector3(s.x+a/h*d,s.y+c/h*d,s.z+l/h*d):s.clone(),b=g>0?new w.Vector3(s.x+u/g*m,s.y+p/g*m,s.z+f/g*m):s.clone();n.push(y),n.push(...jy(y,s,b,8))}return n}_buildLine(){const t=this.smoothedPath;if(t.length<2)return;const{strokeStyle:e,lineWidth:n=2,alpha:i=1,lineDash:r,begin:s="none",beginSize:o="size5",end:a="none",endSize:c="size5"}=this.component.state,l=Math.max(n,1),p="string"==typeof e&&"transparent"!==e?Lh(e):"#000000",f=new w.Color(p),g=this._getResolution(),m=s,y=a,b=Ry(m,l),_=Ry(y,l),v=t[0],x=t[t.length-1],M=(new w.Vector3).subVectors(t[1],v).normalize(),S=(new w.Vector3).subVectors(t[t.length-2],x).normalize(),A=[...t];b>0&&(A[0]=v.clone().add(M.clone().multiplyScalar(b))),_>0&&(A[A.length-1]=x.clone().add(S.clone().multiplyScalar(_)));const E=new u.LineGeometry;E.setPositions(A.flatMap(t=>[t.x,t.y,t.z]));const k=function(t,e){switch(t){case"round-dot":return{dashSize:e,gapSize:e};case"square-dot":return{dashSize:2*e,gapSize:e};case"dash":return{dashSize:4*e,gapSize:1.5*e};case"dash-dot":return{dashSize:4*e,gapSize:2*e};case"long-dash":return{dashSize:6*e,gapSize:3*e};case"long-dash-dot":return{dashSize:6*e,gapSize:2*e};case"long-dash-dot-dot":return{dashSize:6*e,gapSize:e};default:return null}}(r,l),C=new d.LineMaterial({color:f.getHex(),linewidth:l,worldUnits:!0,transparent:i<1,opacity:i,resolution:g,dashed:!!k,dashSize:k?.dashSize??1,gapSize:k?.gapSize??1,dashScale:1});if(this._line2=new h.Line2(E,C),this._line2.computeLineDistances(),this.object3d.add(this._line2),"none"!==m){const t=Qd(m,Kd(o,l));if(t){const e=(new w.Quaternion).setFromUnitVectors(new w.Vector3(1,0,0),M.clone().negate());this._placeTip(t,v,e,f,i,g)}}if("none"!==y){const t=Qd(y,Kd(c,l));if(t){const e=(new w.Quaternion).setFromUnitVectors(new w.Vector3(1,0,0),S.clone().negate());this._placeTip(t,x,e,f,i,g)}}}_placeTip(t,e,n,i,r,s){const o=t.mesh||t.line2||t.group;if(o){if(o.position.copy(e),o.setRotationFromQuaternion(n),t.mesh){const e=t.mesh.material;e.color.copy(i),e.transparent=r<1,e.opacity=r}else if(t.line2){const e=t.line2.material;e.color.copy(i),e.transparent=r<1,e.opacity=r,e.resolution.copy(s)}else t.group&&t.group.traverse(t=>{if(t.material){const e=t.material;e.color&&e.color.copy(i),e.transparent=r<1,e.opacity=r,e.resolution&&e.resolution.copy(s)}});this.object3d.add(o)}}_getResolution(){const t=this.threeContainer?.renderer3d;if(t){return t.getSize(new w.Vector2)}return new w.Vector2(window.innerWidth,window.innerHeight)}onGizmoDragEnd(t){const e=this._component,n=e.path;if(!n||n.length<2)return;const i=this.object3d,{width:r=0,height:s=0}=e.parent?.bounds??{},{x:o,y:a}=e.center,c=i.position,l=i.rotation,h=i.scale,d=this.position;if(Math.abs(c.x-d.x)<.001&&Math.abs(c.y-d.y)<.001&&Math.abs(c.z-d.z)<.001&&Math.abs(l.x)<.001&&Math.abs(l.y)<.001&&Math.abs(l.z)<.001&&Math.abs(h.x-1)<.001&&Math.abs(h.y-1)<.001&&Math.abs(h.z-1)<.001)return;const u=Fy.computeBakedPath(n,{x:o,y:a},{width:r,height:s},i);this._suppressOnchange=!0,e.set({rotation:0,rotationX:0,rotationY:0,zPos:0}),e.mutatePath(null,()=>u),this._suppressOnchange=!1,this.update()}static computeBakedPath(t,e,n,i){const r=n.width,s=n.height,o=e.x,a=e.y;return i.updateMatrixWorld(!0),t.map(t=>{const e=new w.Vector3(t.x-o,t.z||0,t.y-a).applyMatrix4(i.matrixWorld),n={x:e.x+r/2,y:e.z+s/2};return Math.abs(e.y)>.001&&(n.z=e.y),n})}updateStrokeStyle(){this.updateDimension()}updateAlpha(){this.updateDimension()}updateDimension(){this.clear(),this.build()}onchange(t,e){("path"in t||"from"in t||"to"in t)&&(this.updateDimension(),this.updatePosition()),("round"in t||"lineDash"in t||"lineWidth"in t||"begin"in t||"end"in t||"beginSize"in t||"endSize"in t)&&this.updateDimension(),super.onchange(t,e)}clear(){for(;this.object3d.children.length>0;){const t=this.object3d.children[0];this.object3d.remove(t),Hh(t)}return this._line2=void 0,super.clear()}}class By extends Fy{get worldPath(){const t=this.component.path;if(!t||t.length<2)return[];const{x:e,y:n}=this.component.center,i=this.component,r=i.fromEnd?.component?._realObject?.object3d?.position?.y??0,s=i.toEnd?.component?._realObject?.object3d?.position?.y??0;return t.map((i,o)=>{const a=t.length>1?o/(t.length-1):0;return new w.Vector3(i.x-e,i.z||r+(s-r)*a,i.y-n)})}}iu("line",t=>new By(t));class Ny extends Fy{get worldPath(){const t=this.component.path;if(!t||t.length<2)return[];const{x:e,y:n}=this.component.center;return t.map(t=>new w.Vector3(t.x-e,t.z||0,t.y-n))}}iu("polyline",t=>new Ny(t));class Hy extends Fy{get worldPath(){const t=this.component.drawPath;if(!t||t.length<2)return[];const{x:e,y:n}=this.component.center,i=this.component,r=i.fromEnd?.component?._realObject?.object3d?.position?.y??0,s=i.toEnd?.component?._realObject?.object3d?.position?.y??0;return t.map((i,o)=>{const a=t.length>1?o/(t.length-1):0;return new w.Vector3(i.x-e,i.z||r+(s-r)*a,i.y-n)})}}iu("ortholine",t=>new Hy(t)),iu("group",t=>new ky(t));class Yy extends $h{build(){super.build()}update(){}}const Gy={far:1e5,fov:80,near:1,zoom:1};class Vy extends $h{build(){super.build()}update(){super.update(),this.updateCamera()}getObject3dInstance(){return new w.PerspectiveCamera}updateCamera(){const{near:t=Gy.near,far:e=Gy.far,fov:n=Gy.fov,zoom:i=Gy.zoom}=this.component.state;this.object3d.far=e,this.object3d.fov=n,this.object3d.near=t,this.object3d.zoom=i}}class Uy extends jm{buildGeometry(){const{width:t,height:e}=this.component.state.dimension;this.object3d.geometry=new w.PlaneGeometry(t,e)}buildMaterial(){this.object3d.material=new w.MeshStandardMaterial({opacity:0,side:w.DoubleSide,blending:w.NoBlending})}}class $y extends $h{getObject3dInstance(){return new w.Scene}dispose(){for(const t of this.object3d.children)Hh(t);this._animationMixer&&(this._animationMixer.stopAllAction(),this._animationMixer.uncacheRoot(this.object3d),this._animationMixer=void 0),super.dispose()}clear(){return this._floor&&(this.object3d.remove(this._floor),this._floor.material instanceof Array?this._floor.material.forEach(t=>t.dispose()):this._floor.material.dispose(),this._floor.geometry.dispose(),delete this._floor),super.clear()}get floor(){return this._floor}set floor(t){this._floor&&(this.object3d.remove(this._floor),this._floor.clear(),delete this._floor),t&&(this._floor=t,this.object3d.add(t)),this.component.invalidate()}build(){super.build(),this.floor=lu(this.component)}updateTransform(){}updateDimension(){}updatePosition(){}updateRotate(){}updateScale(){}updateAlpha(){}updateHidden(){}get animationMixer(){return this._animationMixer||(this._animationMixer=new w.AnimationMixer(this.object3d)),this._animationMixer}}const Wy=new Set(["cx","cy","cz","zPos","left","top","width","height","depth","lineWidth","rotationX","rotationY","rotation","scale","hidden","alpha","material3d","screenFixed"]);class Xy extends $h{get syncZPosOffset(){return this.effectiveDepth}get geometricOffsetY(){return this.effectiveDepth}constructor(t){super(t),this._origInvalidate=t.invalidate.bind(t),t.invalidate=()=>{this._origInvalidate(),this._refreshTextureNow()}}getObject3dInstance(){return new w.Mesh}build(){super.build();const{width:t,height:e}=this.component.bounds;if(!t||!e)return;const n=Mh(this.component.state.material3d),i=new w.PlaneGeometry(1,1);i.rotateX(-Math.PI/2),this.object3d.geometry=i;const r=Om(this.component);this.object3d.material=new w.MeshStandardMaterial({map:r,transparent:!0,side:w.DoubleSide,metalness:n.metalness,roughness:n.roughness,emissive:new w.Color(n.emissive),emissiveIntensity:n.emissiveIntensity}),this.object3d.castShadow=n.castShadow,this.object3d.receiveShadow=n.receiveShadow}updateAlpha(){const{alpha:t=1,fillStyle:e}=this.component.state;zh(this.object3d.material,t,e)}updateHidden(){this.object3d.visible=!this.component.state.hidden}get dimension(){const{width:t,height:e}=this.component.bounds;return{width:t||1,height:e||1,depth:1}}get scale(){const t=super.scale,{width:e,height:n}=this.dimension;return{x:t.x*e,y:t.y,z:t.z*n}}updateDimension(){this.updateTransform()}_debouncedRebuild(){this._debounceTimer&&clearTimeout(this._debounceTimer),this._debounceTimer=setTimeout(()=>{this._debounceTimer=void 0,this.update()},100)}_refreshTextureNow(){const t=this.object3d.material,e=t?.map;if(!e)return;const n=e.source?.data;n&&(Lm(n,this.component,2),e.needsUpdate=!0)}update(){this.clear(),this.build(),this.updateDimension(),this.updateTransform(),this.updateHidden()}onchange(t,e){super.onchange(t,e);for(const e of Object.keys(t))if(!Wy.has(e)){this._debouncedRebuild();break}}updateFillStyle(){this._debouncedRebuild()}updateStrokeStyle(){this._debouncedRebuild()}updateText(){this._debouncedRebuild()}updateMaterial3d(){super.updateMaterial3d();const t=this.object3d.material;if(!t)return;const e=Mh(this.component.state.material3d);t.metalness=e.metalness,t.roughness=e.roughness,t.emissive.set(e.emissive),t.emissiveIntensity=e.emissiveIntensity}clear(){return this._debounceTimer&&(clearTimeout(this._debounceTimer),this._debounceTimer=void 0),Hh(this.object3d),super.clear()}dispose(){this._debounceTimer&&(clearTimeout(this._debounceTimer),this._debounceTimer=void 0),this._origInvalidate&&(this.component.invalidate=this._origInvalidate,this._origInvalidate=void 0),super.dispose()}}const qy={mutable:!1,resizable:!0,rotatable:!0,properties:[{type:"select",label:"precision",name:"precision",property:{options:[{display:"High",value:"highp"},{display:"Medium",value:"mediump"},{display:"Low",value:"lowp"}]}},{type:"checkbox",label:"anti-alias",name:"antialias",property:"antialias"},{type:"checkbox",label:"3dmode",name:"threed",property:"threed"},{type:"checkbox",label:"auto-rotate",name:"autoRotate",property:"autoRotate"},{type:"checkbox",label:"debug",name:"debug",property:"debug"}],help:"scene/component/three-container"};var Ky;t.ThreeContainer=class extends Uf{constructor(){super(...arguments),this._capability=new Ou}get sceneManager(){return this._capability.sceneManager}get cameraManager(){return this._capability.cameraManager}get rendererManager(){return this._capability.rendererManager}get lightManager(){return this._capability.lightManager}get controlsManager(){return this._capability.controlsManager}get eventManager(){return this._capability.eventManager}containable(t){return!0}is3dContainer(){return!0}getLightingConfig(){return{hemisphere:{skyColor:16777215,groundColor:14540253,intensity:1},directional:{color:16777215,intensity:1.2,attachToCamera:!0,castShadow:!1}}}getCss3DSceneAttribute(){return"three-container:css3d-renderer"}init_scene3d(){this._capability.isInitialized&&this._capability.destroy(),this._capability.init(this,{lightingConfig:this.getLightingConfig(),css3DSceneAttribute:this.getCss3DSceneAttribute(),skipEnvironment:!0,skipPostprocessing:!0,skipShadowMap:!0}),this._capability.buildOverlays(),this._capability.resize(),this.onchangeData&&this.onchangeData(this.data,this.data)}destroy_scene3d(){this.stop(),this._capability.destroy()}stop(){}resize(){this._capability.resize()}get scene3d(){return this._capability.isInitialized||this.init_scene3d(),this._capability.scene3d}get renderer3d(){return this._capability.renderer3d}get mixer(){return this._capability.mixer}get css3DScene(){return this._capability.css3DScene}get css3DRenderer(){return this._capability.css3DRenderer}render_threed(){this._capability.renderThreeD()}get _parentIs3dMode(){return!!this.rootModel?.is3dMode}render(t){this._parentIs3dMode||(this.app.isViewMode&&this.setState("threed",!0),!this.state.threed||this._capability.noSupportWebgl?super.render(t):this._capability.camera&&this._capability.renderCSS3D())}postrender(t){if(this._parentIs3dMode)return;const{left:e,top:n,debug:i,threed:r}=this.state;let{width:s,height:o}=this.bounds;if(s=Math.floor(s),o=Math.floor(o),r){if(this._capability.isInitialized||this.init_scene3d(),this._capability.noSupportWebgl)return void this._capability.showWebglNoSupportText(t,this.state.width,this.state.height);if(!this._capability.renderer3d)return;this._capability.renderThreeD();const r=this._capability.domElement;if(!r||!r.width||!r.height)return;t.drawImage(r,0,0,r.width,r.height,e,n,s,o),i&&this._capability.showDebugFPS(t)}else super.postrender(t)}dispose(){this._capability.dispose(),super.dispose()}get layout(){return Ja.get("three")}get nature(){return qy}getObjectByRaycast(){return this._capability.getObjectByRaycast()}getObjectsByRaycast(){return this._capability.getObjectsByRaycast()}onchange(t,e){(t.hasOwnProperty("width")||t.hasOwnProperty("height"))&&this._capability.destroy(),this._capability.onchange(t)}onmousedown(t){this._capability.onMouseDown(t)}onmouseup(t){this._capability.onMouseUp(t)}onmousemove(t){this._capability.onMouseMove(t)}onmouseleave(t){this._capability.onMouseLeave(t)}onwheel(t){this._capability.onWheel(t)&&this.invalidate()}ondblclick(t){this._capability.onDblClick(t)&&this.invalidate()}ondragstart(t){this._capability.onDragStart(t)}ondragmove(t){this._capability.onDragMove(t)&&this.invalidate()}ondragend(t){this._capability.onDragEnd(t)&&this.invalidate()}ontouchstart(t){this._capability.onTouchStart(t)}onpan(t){this._capability.onPan(t)&&this.invalidate()}ontouchend(t){this._capability.onTouchEnd(t)}onkeydown(t){this._capability.onKeyDown(t)}onpinch(t){this._capability.onPinch(t)&&this.invalidate()}ondoubletap(){this._capability.onDoubleTap(),this.invalidate()}},t.ThreeContainer=kp([_m("3d-container")],t.ThreeContainer),ru(t=>new Rm(t)),t.Model=void 0,(Ky=t.Model||(t.Model={})).compile=Ic,Ky.duplicate=Rc,Ky.select=ya,Ky.match=fa,Mi.registerResidents(()=>({componentResidentsCount:Va.residentsCount,sceneResidentsCount:rd.residentsCount,referenceMapResidentsCount:wm.residentsCount,sceneResidents:Va.residents}));var Qy=Object.freeze({__proto__:null,AbsoluteLayout:ec,Animation:Ho,AudioPlayer:Bg,get Banner(){return t.Banner},Banner3D:dy,BoxSelectionManager:Cu,COMMON_PLACEHOLDER_PROPERTIES:lg,CORE_PLACEHOLDER_TYPES:pg,get Camera(){return t.Camera},Camera3D:gy,CameraBookmarkManager:ku,CameraManager:uu,CardLayout:ic,Component:Va,Connectable:Uu,Container:Uf,ContainerAbstract:Zc,ControlsManager:mu,get Cube(){return t.Cube},Cube3D:ay,get Cylinder(){return t.Cylinder},Cylinder3D:ly,DEFAULT:Er,DPPX:Mr,DataLagTracker:il,DataSource:fm,Donut:rm,DonutExtrude:Zm,Ellipse:ag,EllipseExtrude:qm,EventManager3D:yu,EventMap:Pc,FPS:$d,get FloorPlate(){return t.FloorPlate},GESTURES:Sr,get GLTFObject(){return t.GLTFObject},GLTF_BASE_URL_ALIAS:mm,GenericObject:ug,GifView:jg,GizmoManager:_u,GizmoOperationManager:wu,GlobalRef:Wg,GltfComponent:bm,Group:Yg,HTMLAbsoluteLayout:tc,HTMLOverlayContainer:Ug,HTMLOverlayElement:Ag,ImageView:Sg,InfoWindow:Qa,InteractionManager:Mu,KEYEVENTS:Ar,Layer:Sd,Layout:Ja,LightManager:fu,LightObject:by,Line:sg,Line3D:By,LinearHorizontalLayout:sc,LinearVerticalLayout:ac,LoadTracker:sl,LoadingOverlay:Dh,LocalRef:Vg,MATERIAL_PRESETS:wh,MAX_UNDO_SIZE:30,MODE_ADD:3,MODE_EDIT:1,MODE_PASTE_DATABIND:5,MODE_PASTE_STYLE:4,MODE_SHIFT:2,MODE_VIEW:0,get Model(){return t.Model},MoveHandle:Kc,NOTHING:xr,Node:lm,OrthoLine:wg,OrthoLine3D:Hy,PIXEL_RATIO:Wd,PLACEHOLDER_THEMES:cg,Path:Jg,PlacementManager:Su,get PointLight(){return t.PointLight},Polygon:yg,PolygonExtrude:Qm,Polyline:vg,Polyline3D:Ny,Popup:Kg,PopupContainer:Zg,RealObject:$h,RealObjectCamera:Vy,RealObjectDomElement:tu,RealObjectDomTexture:Rm,RealObjectDummy:Yy,RealObjectExternalModel:Wh,RealObjectExtrude:Xm,RealObjectGLTF:Qh,RealObjectGroup:ky,RealObjectLine:Fy,RealObjectMesh:jm,RealObjectPlane:Uy,RealObjectPlane2D:Xy,RealObjectScene:$y,RealObjectService:hm,RealObjectSprite:iy,RealObjectSprite2D:ry,RealObjectText:Vm,Rect:Xu,RectExtrude:Km,RectPath:Wa,ReferenceMap:wm,RendererManager:pu,RootContainer:el,Ruler:Ku,SCALE_MIN:Oh,SCENE_MODE:wr,Scene:rd,SceneManager:du,ScenePopup:Md,SceneSearchEngine:Jh,ScriptLoader:Tm,SearchOverlay:ed,ServiceComponent:um,Shape:Ua,get Sphere(){return t.Sphere},Sphere3D:ny,get Sprite(){return t.Sprite},Star:am,StarExtrude:ty,TableLayout:cc,Text:Ng,ThreeCapability:Ou,get ThreeContainer(){return t.ThreeContainer},ThreeDOnly:gm,TransitionEffect:Xc,Triangle:em,TriangleExtrude:Jm,UNIT_DIMENSION:Ih,UNIT_ROTATE:Fh,UNIT_SCALE:Rh,UNIT_TRANSLATE:jh,ValueHolder:pm,VertexGizmoManager:Du,get Wall(){return t.Wall},Wall3D:vy,animate:No,applyAlpha:zh,applyMaterial3dProps:Eh,buildArrow3D:Jd,buildTether:fd,clearTether:md,compile:Go,create:od,createCanvas:Xd,createCanvasTexture:Om,createFloor:lu,createRealObjectFor:su,createSelectionHandle3D:My,debug:Ni,delta:Fo,disposeObject3D:Hh,disposeTether:yd,drawTextTexture:Nm,error:Fi,fontStyle:Fm,gltfNatureProperties:ym,initFontFamilyWatcher:Cr,inspector:kh,isGenericPlaceholder:fg,metrics:Mi,opaqueColor:Lh,projectToScreen:hd,registerDefaultRealObjectFactory:ru,registerRealObjectFactory:iu,renderCanvasTexture:zm,renderPlaceholder:hg,resolveAnchorWorldPosition:pd,resolveMaterial3d:Mh,sceneComponent:_m,stopFPSMeasure:Ud,textBounds:Gm,textTexture:Hm,toThreeSide:Ah,updateDefaultFontFamily:kr,updateTether:gd,version:Pm,warn:Bi});const Zy=globalThis;"undefined"==typeof globalThis||Zy.scene||(Zy.scene=Qy),t.AbsoluteLayout=ec,t.Animation=Ho,t.AudioPlayer=Bg,t.Banner3D=dy,t.BoxSelectionManager=Cu,t.COMMON_PLACEHOLDER_PROPERTIES=lg,t.CORE_PLACEHOLDER_TYPES=pg,t.Camera3D=gy,t.CameraBookmarkManager=ku,t.CameraManager=uu,t.CardLayout=ic,t.Component=Va,t.Connectable=Uu,t.Container=Uf,t.ContainerAbstract=Zc,t.ControlsManager=mu,t.Cube3D=ay,t.Cylinder3D=ly,t.DEFAULT=Er,t.DPPX=Mr,t.DataLagTracker=il,t.DataSource=fm,t.Donut=rm,t.DonutExtrude=Zm,t.Ellipse=ag,t.EllipseExtrude=qm,t.EventManager3D=yu,t.EventMap=Pc,t.FPS=$d,t.GESTURES=Sr,t.GLTF_BASE_URL_ALIAS=mm,t.GenericObject=ug,t.GifView=jg,t.GizmoManager=_u,t.GizmoOperationManager=wu,t.GlobalRef=Wg,t.GltfComponent=bm,t.Group=Yg,t.HTMLAbsoluteLayout=tc,t.HTMLOverlayContainer=Ug,t.HTMLOverlayElement=Ag,t.ImageView=Sg,t.InfoWindow=Qa,t.InteractionManager=Mu,t.KEYEVENTS=Ar,t.Layer=Sd,t.Layout=Ja,t.LightManager=fu,t.LightObject=by,t.Line=sg,t.Line3D=By,t.LinearHorizontalLayout=sc,t.LinearVerticalLayout=ac,t.LoadTracker=sl,t.LoadingOverlay=Dh,t.LocalRef=Vg,t.MATERIAL_PRESETS=wh,t.MAX_UNDO_SIZE=30,t.MODE_ADD=3,t.MODE_EDIT=1,t.MODE_PASTE_DATABIND=5,t.MODE_PASTE_STYLE=4,t.MODE_SHIFT=2,t.MODE_VIEW=0,t.MoveHandle=Kc,t.NOTHING=xr,t.Node=lm,t.OrthoLine=wg,t.OrthoLine3D=Hy,t.PIXEL_RATIO=Wd,t.PLACEHOLDER_THEMES=cg,t.Path=Jg,t.PlacementManager=Su,t.Polygon=yg,t.PolygonExtrude=Qm,t.Polyline=vg,t.Polyline3D=Ny,t.Popup=Kg,t.PopupContainer=Zg,t.RealObject=$h,t.RealObjectCamera=Vy,t.RealObjectDomElement=tu,t.RealObjectDomTexture=Rm,t.RealObjectDummy=Yy,t.RealObjectExternalModel=Wh,t.RealObjectExtrude=Xm,t.RealObjectGLTF=Qh,t.RealObjectGroup=ky,t.RealObjectLine=Fy,t.RealObjectMesh=jm,t.RealObjectPlane=Uy,t.RealObjectPlane2D=Xy,t.RealObjectScene=$y,t.RealObjectService=hm,t.RealObjectSprite=iy,t.RealObjectSprite2D=ry,t.RealObjectText=Vm,t.Rect=Xu,t.RectExtrude=Km,t.RectPath=Wa,t.ReferenceMap=wm,t.RendererManager=pu,t.RootContainer=el,t.Ruler=Ku,t.SCALE_MIN=Oh,t.SCENE_MODE=wr,t.Scene=rd,t.SceneManager=du,t.ScenePopup=Md,t.SceneSearchEngine=Jh,t.ScriptLoader=Tm,t.SearchOverlay=ed,t.ServiceComponent=um,t.Shape=Ua,t.Sphere3D=ny,t.Star=am,t.StarExtrude=ty,t.TableLayout=cc,t.Text=Ng,t.ThreeCapability=Ou,t.ThreeDOnly=gm,t.TransitionEffect=Xc,t.Triangle=em,t.TriangleExtrude=Jm,t.UNIT_DIMENSION=Ih,t.UNIT_ROTATE=Fh,t.UNIT_SCALE=Rh,t.UNIT_TRANSLATE=jh,t.ValueHolder=pm,t.VertexGizmoManager=Du,t.Wall3D=vy,t.animate=No,t.applyAlpha=zh,t.applyMaterial3dProps=Eh,t.buildArrow3D=Jd,t.buildTether=fd,t.clearTether=md,t.compile=Go,t.create=od,t.createCanvas=Xd,t.createCanvasTexture=Om,t.createFloor=lu,t.createRealObjectFor=su,t.createSelectionHandle3D=My,t.debug=Ni,t.delta=Fo,t.disposeObject3D=Hh,t.disposeTether=yd,t.drawTextTexture=Nm,t.error=Fi,t.fontStyle=Fm,t.gltfNatureProperties=ym,t.initFontFamilyWatcher=Cr,t.inspector=kh,t.isGenericPlaceholder=fg,t.metrics=Mi,t.opaqueColor=Lh,t.projectToScreen=hd,t.registerDefaultRealObjectFactory=ru,t.registerRealObjectFactory=iu,t.renderCanvasTexture=zm,t.renderPlaceholder=hg,t.resolveAnchorWorldPosition=pd,t.resolveMaterial3d=Mh,t.sceneComponent=_m,t.stopFPSMeasure=Ud,t.textBounds=Gm,t.textTexture=Hm,t.toThreeSide=Ah,t.updateDefaultFontFamily=kr,t.updateTether=gd,t.version=Pm,t.warn=Bi});
|
|
73
73
|
//# sourceMappingURL=things-scene-min.js.map
|