@osamash/floor-planner 1.0.3 → 1.0.5
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/dist/floor-planner.es.js +6132 -6482
- package/dist/floor-planner.umd.js +20 -28
- package/dist/types/react-planner/catalog/catalog.d.ts +1 -1
- package/dist/types/react-planner/footer-bar/FooterContentButton.d.ts +1 -1
- package/dist/types/react-planner/hooks/useScreenshotBeforeUnload.d.ts +1 -1
- package/package.json +7 -8
|
@@ -1,33 +1,25 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(me,N){typeof exports=="object"&&typeof module<"u"?N(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],N):(me=typeof globalThis<"u"?globalThis:me||self,N(me.FloorPlanner={},me.React))})(this,(function(me,N){"use strict";var kM=Object.defineProperty;var IM=(me,N,Br)=>N in me?kM(me,N,{enumerable:!0,configurable:!0,writable:!0,value:Br}):me[N]=Br;var It=(me,N,Br)=>IM(me,typeof N!="symbol"?N+"":N,Br);function Br(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}function jh(n){if(Object.prototype.hasOwnProperty.call(n,"__esModule"))return n;var t=n.default;if(typeof t=="function"){var e=function r(){return this instanceof r?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};e.prototype=t.prototype}else e={};return Object.defineProperty(e,"__esModule",{value:!0}),Object.keys(n).forEach(function(r){var i=Object.getOwnPropertyDescriptor(n,r);Object.defineProperty(e,r,i.get?i:{enumerable:!0,get:function(){return n[r]}})}),e}var To={exports:{}},Ms={};/**
|
|
2
2
|
* @license React
|
|
3
|
-
* react-jsx-runtime.production.
|
|
3
|
+
* react-jsx-runtime.production.js
|
|
4
4
|
*
|
|
5
|
-
* Copyright (c)
|
|
5
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var
|
|
9
|
+
*/var Vh;function e0(){if(Vh)return Ms;Vh=1;var n=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function e(r,i,s){var o=null;if(s!==void 0&&(o=""+s),i.key!==void 0&&(o=""+i.key),"key"in i){s={};for(var a in i)a!=="key"&&(s[a]=i[a])}else s=i;return i=s.ref,{$$typeof:n,type:r,key:o,ref:i!==void 0?i:null,props:s}}return Ms.Fragment=t,Ms.jsx=e,Ms.jsxs=e,Ms}var Es={};/**
|
|
10
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.development.js
|
|
12
12
|
*
|
|
13
|
-
* Copyright (c)
|
|
13
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var
|
|
18
|
-
`+U+I}}var vt=!1,B;{var pt=typeof WeakMap=="function"?WeakMap:Map;B=new pt}function H(I,G){if(!I||vt)return"";{var ot=B.get(I);if(ot!==void 0)return ot}var Mt;vt=!0;var jt=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var qt;qt=Q.current,Q.current=null,rt();try{if(G){var At=function(){throw Error()};if(Object.defineProperty(At.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(At,[])}catch(me){Mt=me}Reflect.construct(I,[],At)}else{try{At.call()}catch(me){Mt=me}I.call(At.prototype)}}else{try{throw Error()}catch(me){Mt=me}I()}}catch(me){if(me&&Mt&&typeof me.stack=="string"){for(var nt=me.stack.split(`
|
|
19
|
-
`),Oe=Mt.stack.split(`
|
|
20
|
-
`),ue=nt.length-1,mt=Oe.length-1;ue>=1&&mt>=0&&nt[ue]!==Oe[mt];)mt--;for(;ue>=1&&mt>=0;ue--,mt--)if(nt[ue]!==Oe[mt]){if(ue!==1||mt!==1)do if(ue--,mt--,mt<0||nt[ue]!==Oe[mt]){var Pe=`
|
|
21
|
-
`+nt[ue].replace(" at new "," at ");return I.displayName&&Pe.includes("<anonymous>")&&(Pe=Pe.replace("<anonymous>",I.displayName)),typeof I=="function"&&B.set(I,Pe),Pe}while(ue>=1&&mt>=0);break}}}finally{vt=!1,Q.current=qt,Z(),Error.prepareStackTrace=jt}var pr=I?I.displayName||I.name:"",gr=pr?st(pr):"";return typeof I=="function"&&B.set(I,gr),gr}function Ot(I,G,ot){return H(I,!1)}function Bt(I){var G=I.prototype;return!!(G&&G.isReactComponent)}function kt(I,G,ot){if(I==null)return"";if(typeof I=="function")return H(I,Bt(I));if(typeof I=="string")return st(I);switch(I){case c:return st("Suspense");case h:return st("SuspenseList")}if(typeof I=="object")switch(I.$$typeof){case l:return Ot(I.render);case f:return kt(I.type,G,ot);case g:{var Mt=I,jt=Mt._payload,qt=Mt._init;try{return kt(qt(jt),G,ot)}catch{}}}return""}var Ct=Object.prototype.hasOwnProperty,Gt={},gt=S.ReactDebugCurrentFrame;function _t(I){if(I){var G=I._owner,ot=kt(I.type,I._source,G?G.type:null);gt.setExtraStackFrame(ot)}else gt.setExtraStackFrame(null)}function Dt(I,G,ot,Mt,jt){{var qt=Function.call.bind(Ct);for(var At in I)if(qt(I,At)){var nt=void 0;try{if(typeof I[At]!="function"){var Oe=Error((Mt||"React class")+": "+ot+" type `"+At+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof I[At]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw Oe.name="Invariant Violation",Oe}nt=I[At](G,At,Mt,ot,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(ue){nt=ue}nt&&!(nt instanceof Error)&&(_t(jt),M("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",Mt||"React class",ot,At,typeof nt),_t(null)),nt instanceof Error&&!(nt.message in Gt)&&(Gt[nt.message]=!0,_t(jt),M("Failed %s type: %s",ot,nt.message),_t(null))}}}var zt=Array.isArray;function Le(I){return zt(I)}function tn(I){{var G=typeof Symbol=="function"&&Symbol.toStringTag,ot=G&&I[Symbol.toStringTag]||I.constructor.name||"Object";return ot}}function Dn(I){try{return _n(I),!1}catch{return!0}}function _n(I){return""+I}function Bn(I){if(Dn(I))return M("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",tn(I)),_n(I)}var Ci=S.ReactCurrentOwner,Ii={key:!0,ref:!0,__self:!0,__source:!0},se,Ye;function Cr(I){if(Ct.call(I,"ref")){var G=Object.getOwnPropertyDescriptor(I,"ref").get;if(G&&G.isReactWarning)return!1}return I.ref!==void 0}function dr(I){if(Ct.call(I,"key")){var G=Object.getOwnPropertyDescriptor(I,"key").get;if(G&&G.isReactWarning)return!1}return I.key!==void 0}function ki(I,G){typeof I.ref=="string"&&Ci.current}function qn(I,G){{var ot=function(){se||(se=!0,M("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",G))};ot.isReactWarning=!0,Object.defineProperty(I,"key",{get:ot,configurable:!0})}}function oe(I,G){{var ot=function(){Ye||(Ye=!0,M("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",G))};ot.isReactWarning=!0,Object.defineProperty(I,"ref",{get:ot,configurable:!0})}}var $n=function(I,G,ot,Mt,jt,qt,At){var nt={$$typeof:t,type:I,key:G,ref:ot,props:At,_owner:qt};return nt._store={},Object.defineProperty(nt._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(nt,"_self",{configurable:!1,enumerable:!1,writable:!1,value:Mt}),Object.defineProperty(nt,"_source",{configurable:!1,enumerable:!1,writable:!1,value:jt}),Object.freeze&&(Object.freeze(nt.props),Object.freeze(nt)),nt};function we(I,G,ot,Mt,jt){{var qt,At={},nt=null,Oe=null;ot!==void 0&&(Bn(ot),nt=""+ot),dr(G)&&(Bn(G.key),nt=""+G.key),Cr(G)&&(Oe=G.ref,ki(G,jt));for(qt in G)Ct.call(G,qt)&&!Ii.hasOwnProperty(qt)&&(At[qt]=G[qt]);if(I&&I.defaultProps){var ue=I.defaultProps;for(qt in ue)At[qt]===void 0&&(At[qt]=ue[qt])}if(nt||Oe){var mt=typeof I=="function"?I.displayName||I.name||"Unknown":I;nt&&qn(At,mt),Oe&&oe(At,mt)}return $n(I,nt,Oe,jt,Mt,Ci.current,At)}}var Pi=S.ReactCurrentOwner,Ri=S.ReactDebugCurrentFrame;function ae(I){if(I){var G=I._owner,ot=kt(I.type,I._source,G?G.type:null);Ri.setExtraStackFrame(ot)}else Ri.setExtraStackFrame(null)}var Li;Li=!1;function Ir(I){return typeof I=="object"&&I!==null&&I.$$typeof===t}function oi(){{if(Pi.current){var I=tt(Pi.current.type);if(I)return`
|
|
22
|
-
|
|
23
|
-
Check the render method of \``+I+"`."}return""}}function ai(I){return""}var Fi={};function Ni(I){{var G=oi();if(!G){var ot=typeof I=="string"?I:I.displayName||I.name;ot&&(G=`
|
|
24
|
-
|
|
25
|
-
Check the top-level render call using <`+ot+">.")}return G}}function Fs(I,G){{if(!I._store||I._store.validated||I.key!=null)return;I._store.validated=!0;var ot=Ni(G);if(Fi[ot])return;Fi[ot]=!0;var Mt="";I&&I._owner&&I._owner!==Pi.current&&(Mt=" It was passed a child from "+tt(I._owner.type)+"."),ae(I),M('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',ot,Mt),ae(null)}}function $e(I,G){{if(typeof I!="object")return;if(Le(I))for(var ot=0;ot<I.length;ot++){var Mt=I[ot];Ir(Mt)&&Fs(Mt,G)}else if(Ir(I))I._store&&(I._store.validated=!0);else if(I){var jt=_(I);if(typeof jt=="function"&&jt!==I.entries)for(var qt=jt.call(I),At;!(At=qt.next()).done;)Ir(At.value)&&Fs(At.value,G)}}}function Th(I){{var G=I.type;if(G==null||typeof G=="string")return;var ot;if(typeof G=="function")ot=G.propTypes;else if(typeof G=="object"&&(G.$$typeof===l||G.$$typeof===f))ot=G.propTypes;else return;if(ot){var Mt=tt(G);Dt(ot,I.props,"prop",Mt,I)}else if(G.PropTypes!==void 0&&!Li){Li=!0;var jt=tt(G);M("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",jt||"Unknown")}typeof G.getDefaultProps=="function"&&!G.getDefaultProps.isReactClassApproved&&M("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function jo(I){{for(var G=Object.keys(I.props),ot=0;ot<G.length;ot++){var Mt=G[ot];if(Mt!=="children"&&Mt!=="key"){ae(I),M("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",Mt),ae(null);break}}I.ref!==null&&(ae(I),M("Invalid attribute `ref` supplied to `React.Fragment`."),ae(null))}}var _u={};function Vo(I,G,ot,Mt,jt,qt){{var At=X(I);if(!At){var nt="";(I===void 0||typeof I=="object"&&I!==null&&Object.keys(I).length===0)&&(nt+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var Oe=ai();Oe?nt+=Oe:nt+=oi();var ue;I===null?ue="null":Le(I)?ue="array":I!==void 0&&I.$$typeof===t?(ue="<"+(tt(I.type)||"Unknown")+" />",nt=" Did you accidentally export a JSX literal instead of a component?"):ue=typeof I,M("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",ue,nt)}var mt=we(I,G,ot,jt,qt);if(mt==null)return mt;if(At){var Pe=G.children;if(Pe!==void 0)if(Mt)if(Le(Pe)){for(var pr=0;pr<Pe.length;pr++)$e(Pe[pr],I);Object.freeze&&Object.freeze(Pe)}else M("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else $e(Pe,I)}if(Ct.call(G,"key")){var gr=tt(I),me=Object.keys(G).filter(function($o){return $o!=="key"}),mr=me.length>0?"{key: someKey, "+me.join(": ..., ")+": ...}":"{key: someKey}";if(!_u[gr+mr]){var qo=me.length>0?"{"+me.join(": ..., ")+": ...}":"{}";M(`A props object containing a "key" prop is being spread into JSX:
|
|
17
|
+
*/var Dh;function r0(){return Dh||(Dh=1,process.env.NODE_ENV!=="production"&&(function(){function n(k){if(k==null)return null;if(typeof k=="function")return k.$$typeof===Y?null:k.displayName||k.name||null;if(typeof k=="string")return k;switch(k){case v:return"Fragment";case S:return"Profiler";case _:return"StrictMode";case M:return"Suspense";case z:return"SuspenseList";case L:return"Activity"}if(typeof k=="object")switch(typeof k.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),k.$$typeof){case m:return"Portal";case C:return(k.displayName||"Context")+".Provider";case A:return(k._context.displayName||"Context")+".Consumer";case O:var j=k.render;return k=k.displayName,k||(k=j.displayName||j.name||"",k=k!==""?"ForwardRef("+k+")":"ForwardRef"),k;case R:return j=k.displayName||null,j!==null?j:n(k.type)||"Memo";case I:j=k._payload,k=k._init;try{return n(k(j))}catch{}}return null}function t(k){return""+k}function e(k){try{t(k);var j=!1}catch{j=!0}if(j){j=console;var K=j.error,Z=typeof Symbol=="function"&&Symbol.toStringTag&&k[Symbol.toStringTag]||k.constructor.name||"Object";return K.call(j,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",Z),t(k)}}function r(k){if(k===v)return"<>";if(typeof k=="object"&&k!==null&&k.$$typeof===I)return"<...>";try{var j=n(k);return j?"<"+j+">":"<...>"}catch{return"<...>"}}function i(){var k=X.A;return k===null?null:k.getOwner()}function s(){return Error("react-stack-top-frame")}function o(k){if(it.call(k,"key")){var j=Object.getOwnPropertyDescriptor(k,"key").get;if(j&&j.isReactWarning)return!1}return k.key!==void 0}function a(k,j){function K(){mt||(mt=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",j))}K.isReactWarning=!0,Object.defineProperty(k,"key",{get:K,configurable:!0})}function l(){var k=n(this.type);return dt[k]||(dt[k]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),k=this.props.ref,k!==void 0?k:null}function c(k,j,K,Z,et,U,Q,G){return K=U.ref,k={$$typeof:p,type:k,key:j,props:U,_owner:et},(K!==void 0?K:null)!==null?Object.defineProperty(k,"ref",{enumerable:!1,get:l}):Object.defineProperty(k,"ref",{enumerable:!1,value:null}),k._store={},Object.defineProperty(k._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(k,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(k,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:Q}),Object.defineProperty(k,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:G}),Object.freeze&&(Object.freeze(k.props),Object.freeze(k)),k}function h(k,j,K,Z,et,U,Q,G){var tt=j.children;if(tt!==void 0)if(Z)if(rt(tt)){for(Z=0;Z<tt.length;Z++)f(tt[Z]);Object.freeze&&Object.freeze(tt)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else f(tt);if(it.call(j,"key")){tt=n(k);var ht=Object.keys(j).filter(function(ct){return ct!=="key"});Z=0<ht.length?"{key: someKey, "+ht.join(": ..., ")+": ...}":"{key: someKey}",gt[tt+Z]||(ht=0<ht.length?"{"+ht.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
26
18
|
let props = %s;
|
|
27
19
|
<%s {...props} />
|
|
28
20
|
React keys must be passed directly to JSX without using spread:
|
|
29
21
|
let props = %s;
|
|
30
|
-
<%s key={someKey} {...props} />`,
|
|
22
|
+
<%s key={someKey} {...props} />`,Z,tt,ht,tt),gt[tt+Z]=!0)}if(tt=null,K!==void 0&&(e(K),tt=""+K),o(j)&&(e(j.key),tt=""+j.key),"key"in j){K={};for(var B in j)B!=="key"&&(K[B]=j[B])}else K=j;return tt&&a(K,typeof k=="function"?k.displayName||k.name||"Unknown":k),c(k,tt,U,et,i(),K,Q,G)}function f(k){typeof k=="object"&&k!==null&&k.$$typeof===p&&k._store&&(k._store.validated=1)}var g=N,p=Symbol.for("react.transitional.element"),m=Symbol.for("react.portal"),v=Symbol.for("react.fragment"),_=Symbol.for("react.strict_mode"),S=Symbol.for("react.profiler"),A=Symbol.for("react.consumer"),C=Symbol.for("react.context"),O=Symbol.for("react.forward_ref"),M=Symbol.for("react.suspense"),z=Symbol.for("react.suspense_list"),R=Symbol.for("react.memo"),I=Symbol.for("react.lazy"),L=Symbol.for("react.activity"),Y=Symbol.for("react.client.reference"),X=g.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,it=Object.prototype.hasOwnProperty,rt=Array.isArray,vt=console.createTask?console.createTask:function(){return null};g={react_stack_bottom_frame:function(k){return k()}};var mt,dt={},ut=g.react_stack_bottom_frame.bind(g,s)(),W=vt(r(s)),gt={};Es.Fragment=v,Es.jsx=function(k,j,K,Z,et){var U=1e4>X.recentlyCreatedOwnerStacks++;return h(k,j,K,!1,Z,et,U?Error("react-stack-top-frame"):ut,U?vt(r(k)):W)},Es.jsxs=function(k,j,K,Z,et){var U=1e4>X.recentlyCreatedOwnerStacks++;return h(k,j,K,!0,Z,et,U?Error("react-stack-top-frame"):ut,U?vt(r(k)):W)}})()),Es}var Bh;function n0(){return Bh||(Bh=1,process.env.NODE_ENV==="production"?To.exports=e0():To.exports=r0()),To.exports}var w=n0();const qh=n=>{let t;const e=new Set,r=(c,h)=>{const f=typeof c=="function"?c(t):c;if(!Object.is(f,t)){const g=t;t=h??(typeof f!="object"||f===null)?f:Object.assign({},t,f),e.forEach(p=>p(t,g))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>l,subscribe:c=>(e.add(c),()=>e.delete(c))},l=t=n(r,i,a);return a},i0=(n=>n?qh(n):qh),s0=n=>n;function o0(n,t=s0){const e=N.useSyncExternalStore(n.subscribe,N.useCallback(()=>t(n.getState()),[n,t]),N.useCallback(()=>t(n.getInitialState()),[n,t]));return N.useDebugValue(e),e}const $h=n=>{const t=i0(n),e=r=>o0(t,r);return Object.assign(e,t),e},a0=(n=>n?$h(n):$h);/**
|
|
31
23
|
* @license
|
|
32
24
|
* MIT License
|
|
33
25
|
*
|
|
@@ -50,38 +42,38 @@ React keys must be passed directly to JSX without using spread:
|
|
|
50
42
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
51
43
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
52
44
|
* SOFTWARE.
|
|
53
|
-
*/var Gs="delete",Ut=5,rr=1<<Ut,He=rr-1,Ft={};function ku(){return{value:!1}}function xr(n){n&&(n.value=!0)}function Pu(){}function ji(n){return n.size===void 0&&(n.size=n.__iterate(Kh)),n.size}function Hn(n,t){if(typeof t!="number"){var e=t>>>0;if(""+e!==t||e===4294967295)return NaN;t=e}return t<0?ji(n)+t:t}function Kh(){return!0}function Ws(n,t,e){return(n===0&&!tf(n)||e!==void 0&&n<=-e)&&(t===void 0||e!==void 0&&t>=e)}function Vi(n,t){return Qh(n,t,0)}function Us(n,t){return Qh(n,t,t)}function Qh(n,t,e){return n===void 0?e:tf(n)?t===1/0?t:Math.max(0,t+n)|0:t===void 0||t===n?n:Math.min(t,n)|0}function tf(n){return n<0||n===0&&1/n===-1/0}var ef="@@__IMMUTABLE_ITERABLE__@@";function Ze(n){return!!(n&&n[ef])}var Xo="@@__IMMUTABLE_KEYED__@@";function Kt(n){return!!(n&&n[Xo])}var Jo="@@__IMMUTABLE_INDEXED__@@";function Ke(n){return!!(n&&n[Jo])}function Zo(n){return Kt(n)||Ke(n)}var Te=function(t){return Ze(t)?t:Ee(t)},_r=function(n){function t(e){return Kt(e)?e:Un(e)}return n&&(t.__proto__=n),t.prototype=Object.create(n&&n.prototype),t.prototype.constructor=t,t}(Te),ci=function(n){function t(e){return Ke(e)?e:wr(e)}return n&&(t.__proto__=n),t.prototype=Object.create(n&&n.prototype),t.prototype.constructor=t,t}(Te),Di=function(n){function t(e){return Ze(e)&&!Zo(e)?e:$i(e)}return n&&(t.__proto__=n),t.prototype=Object.create(n&&n.prototype),t.prototype.constructor=t,t}(Te);Te.Keyed=_r,Te.Indexed=ci,Te.Set=Di;var rf="@@__IMMUTABLE_SEQ__@@";function Ko(n){return!!(n&&n[rf])}var nf="@@__IMMUTABLE_RECORD__@@";function Gn(n){return!!(n&&n[nf])}function br(n){return Ze(n)||Gn(n)}var Wn="@@__IMMUTABLE_ORDERED__@@";function Rr(n){return!!(n&&n[Wn])}var Bi=0,nr=1,ir=2,Ru=typeof Symbol=="function"&&Symbol.iterator,sf="@@iterator",Qo=Ru||sf,Nt=function(t){this.next=t};Nt.prototype.toString=function(){return"[Iterator]"},Nt.KEYS=Bi,Nt.VALUES=nr,Nt.ENTRIES=ir,Nt.prototype.inspect=Nt.prototype.toSource=function(){return this.toString()},Nt.prototype[Qo]=function(){return this};function ee(n,t,e,r){var i=n===Bi?t:n===nr?e:[t,e];return r?r.value=i:r={value:i,done:!1},r}function Ne(){return{value:void 0,done:!0}}function Lu(n){return Array.isArray(n)?!0:!!ta(n)}function of(n){return n&&typeof n.next=="function"}function Fu(n){var t=ta(n);return t&&t.call(n)}function ta(n){var t=n&&(Ru&&n[Ru]||n[sf]);if(typeof t=="function")return t}function d0(n){var t=ta(n);return t&&t===n.entries}function p0(n){var t=ta(n);return t&&t===n.keys}var qi=Object.prototype.hasOwnProperty;function Nu(n){return Array.isArray(n)||typeof n=="string"?!0:n&&typeof n=="object"&&Number.isInteger(n.length)&&n.length>=0&&(n.length===0?Object.keys(n).length===1:n.hasOwnProperty(n.length-1))}var Ee=function(n){function t(e){return e==null?Vu():br(e)?e.toSeq():m0(e)}return n&&(t.__proto__=n),t.prototype=Object.create(n&&n.prototype),t.prototype.constructor=t,t.prototype.toSeq=function(){return this},t.prototype.toString=function(){return this.__toString("Seq {","}")},t.prototype.cacheResult=function(){return!this._cache&&this.__iterateUncached&&(this._cache=this.entrySeq().toArray(),this.size=this._cache.length),this},t.prototype.__iterate=function(r,i){var s=this._cache;if(s){for(var o=s.length,a=0;a!==o;){var l=s[i?o-++a:a++];if(r(l[1],l[0],this)===!1)break}return a}return this.__iterateUncached(r,i)},t.prototype.__iterator=function(r,i){var s=this._cache;if(s){var o=s.length,a=0;return new Nt(function(){if(a===o)return Ne();var l=s[i?o-++a:a++];return ee(r,l[0],l[1])})}return this.__iteratorUncached(r,i)},t}(Te),Un=function(n){function t(e){return e==null?Vu().toKeyedSeq():Ze(e)?Kt(e)?e.toSeq():e.fromEntrySeq():Gn(e)?e.toSeq():Du(e)}return n&&(t.__proto__=n),t.prototype=Object.create(n&&n.prototype),t.prototype.constructor=t,t.prototype.toKeyedSeq=function(){return this},t}(Ee),wr=function(n){function t(e){return e==null?Vu():Ze(e)?Kt(e)?e.entrySeq():e.toIndexedSeq():Gn(e)?e.toSeq().entrySeq():uf(e)}return n&&(t.__proto__=n),t.prototype=Object.create(n&&n.prototype),t.prototype.constructor=t,t.of=function(){return t(arguments)},t.prototype.toIndexedSeq=function(){return this},t.prototype.toString=function(){return this.__toString("Seq [","]")},t}(Ee),$i=function(n){function t(e){return(Ze(e)&&!Zo(e)?e:wr(e)).toSetSeq()}return n&&(t.__proto__=n),t.prototype=Object.create(n&&n.prototype),t.prototype.constructor=t,t.of=function(){return t(arguments)},t.prototype.toSetSeq=function(){return this},t}(Ee);Ee.isSeq=Ko,Ee.Keyed=Un,Ee.Set=$i,Ee.Indexed=wr,Ee.prototype[rf]=!0;var Hi=function(n){function t(e){this._array=e,this.size=e.length}return n&&(t.__proto__=n),t.prototype=Object.create(n&&n.prototype),t.prototype.constructor=t,t.prototype.get=function(r,i){return this.has(r)?this._array[Hn(this,r)]:i},t.prototype.__iterate=function(r,i){for(var s=this._array,o=s.length,a=0;a!==o;){var l=i?o-++a:a++;if(r(s[l],l,this)===!1)break}return a},t.prototype.__iterator=function(r,i){var s=this._array,o=s.length,a=0;return new Nt(function(){if(a===o)return Ne();var l=i?o-++a:a++;return ee(r,l,s[l])})},t}(wr),ju=function(n){function t(e){var r=Object.keys(e).concat(Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e):[]);this._object=e,this._keys=r,this.size=r.length}return n&&(t.__proto__=n),t.prototype=Object.create(n&&n.prototype),t.prototype.constructor=t,t.prototype.get=function(r,i){return i!==void 0&&!this.has(r)?i:this._object[r]},t.prototype.has=function(r){return qi.call(this._object,r)},t.prototype.__iterate=function(r,i){for(var s=this._object,o=this._keys,a=o.length,l=0;l!==a;){var c=o[i?a-++l:l++];if(r(s[c],c,this)===!1)break}return l},t.prototype.__iterator=function(r,i){var s=this._object,o=this._keys,a=o.length,l=0;return new Nt(function(){if(l===a)return Ne();var c=o[i?a-++l:l++];return ee(r,c,s[c])})},t}(Un);ju.prototype[Wn]=!0;var g0=function(n){function t(e){this._collection=e,this.size=e.length||e.size}return n&&(t.__proto__=n),t.prototype=Object.create(n&&n.prototype),t.prototype.constructor=t,t.prototype.__iterateUncached=function(r,i){if(i)return this.cacheResult().__iterate(r,i);var s=this._collection,o=Fu(s),a=0;if(of(o))for(var l;!(l=o.next()).done&&r(l.value,a++,this)!==!1;);return a},t.prototype.__iteratorUncached=function(r,i){if(i)return this.cacheResult().__iterator(r,i);var s=this._collection,o=Fu(s);if(!of(o))return new Nt(Ne);var a=0;return new Nt(function(){var l=o.next();return l.done?l:ee(r,a++,l.value)})},t}(wr),af;function Vu(){return af||(af=new Hi([]))}function Du(n){var t=Bu(n);if(t)return t.fromEntrySeq();if(typeof n=="object")return new ju(n);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+n)}function uf(n){var t=Bu(n);if(t)return t;throw new TypeError("Expected Array or collection object of values: "+n)}function m0(n){var t=Bu(n);if(t)return d0(n)?t.fromEntrySeq():p0(n)?t.toSetSeq():t;if(typeof n=="object")return new ju(n);throw new TypeError("Expected Array or collection object of values, or keyed object: "+n)}function Bu(n){return Nu(n)?new Hi(n):Lu(n)?new g0(n):void 0}var lf="@@__IMMUTABLE_MAP__@@";function ea(n){return!!(n&&n[lf])}function qu(n){return ea(n)&&Rr(n)}function $u(n){return!!(n&&typeof n.equals=="function"&&typeof n.hashCode=="function")}function Ce(n,t){if(n===t||n!==n&&t!==t)return!0;if(!n||!t)return!1;if(typeof n.valueOf=="function"&&typeof t.valueOf=="function"){if(n=n.valueOf(),t=t.valueOf(),n===t||n!==n&&t!==t)return!0;if(!n||!t)return!1}return!!($u(n)&&$u(t)&&n.equals(t))}var Ys=typeof Math.imul=="function"&&Math.imul(4294967295,2)===-2?Math.imul:function(t,e){t|=0,e|=0;var r=t&65535,i=e&65535;return r*i+((t>>>16)*i+r*(e>>>16)<<16>>>0)|0};function ra(n){return n>>>1&1073741824|n&3221225471}var y0=Object.prototype.valueOf;function Qe(n){if(n==null)return cf(n);if(typeof n.hashCode=="function")return ra(n.hashCode(n));var t=S0(n);if(t==null)return cf(t);switch(typeof t){case"boolean":return t?1108378657:1108378656;case"number":return v0(t);case"string":return t.length>E0?x0(t):Hu(t);case"object":case"function":return b0(t);case"symbol":return _0(t);default:if(typeof t.toString=="function")return Hu(t.toString());throw new Error("Value type "+typeof t+" cannot be hashed.")}}function cf(n){return n===null?1108378658:1108378659}function v0(n){if(n!==n||n===1/0)return 0;var t=n|0;for(t!==n&&(t^=n*4294967295);n>4294967295;)n/=4294967295,t^=n;return ra(t)}function x0(n){var t=Xu[n];return t===void 0&&(t=Hu(n),Yu===M0&&(Yu=0,Xu={}),Yu++,Xu[n]=t),t}function Hu(n){for(var t=0,e=0;e<n.length;e++)t=31*t+n.charCodeAt(e)|0;return ra(t)}function _0(n){var t=pf[n];return t!==void 0||(t=df(),pf[n]=t),t}function b0(n){var t;if(Gu&&(t=Wu.get(n),t!==void 0)||(t=n[hi],t!==void 0)||!ff&&(t=n.propertyIsEnumerable&&n.propertyIsEnumerable[hi],t!==void 0||(t=w0(n),t!==void 0)))return t;if(t=df(),Gu)Wu.set(n,t);else{if(hf!==void 0&&hf(n)===!1)throw new Error("Non-extensible objects are not allowed as keys.");if(ff)Object.defineProperty(n,hi,{enumerable:!1,configurable:!1,writable:!1,value:t});else if(n.propertyIsEnumerable!==void 0&&n.propertyIsEnumerable===n.constructor.prototype.propertyIsEnumerable)n.propertyIsEnumerable=function(){return this.constructor.prototype.propertyIsEnumerable.apply(this,arguments)},n.propertyIsEnumerable[hi]=t;else if(n.nodeType!==void 0)n[hi]=t;else throw new Error("Unable to set a non-enumerable property on object.")}return t}var hf=Object.isExtensible,ff=function(){try{return Object.defineProperty({},"@",{}),!0}catch{return!1}}();function w0(n){if(n&&n.nodeType>0)switch(n.nodeType){case 1:return n.uniqueID;case 9:return n.documentElement&&n.documentElement.uniqueID}}function S0(n){return n.valueOf!==y0&&typeof n.valueOf=="function"?n.valueOf(n):n}function df(){var n=++Uu;return Uu&1073741824&&(Uu=0),n}var Gu=typeof WeakMap=="function",Wu;Gu&&(Wu=new WeakMap);var pf=Object.create(null),Uu=0,hi="__immutablehash__";typeof Symbol=="function"&&(hi=Symbol(hi));var E0=16,M0=255,Yu=0,Xu={},na=function(n){function t(e,r){this._iter=e,this._useKeys=r,this.size=e.size}return n&&(t.__proto__=n),t.prototype=Object.create(n&&n.prototype),t.prototype.constructor=t,t.prototype.get=function(r,i){return this._iter.get(r,i)},t.prototype.has=function(r){return this._iter.has(r)},t.prototype.valueSeq=function(){return this._iter.valueSeq()},t.prototype.reverse=function(){var r=this,i=Ju(this,!0);return this._useKeys||(i.valueSeq=function(){return r._iter.toSeq().reverse()}),i},t.prototype.map=function(r,i){var s=this,o=xf(this,r,i);return this._useKeys||(o.valueSeq=function(){return s._iter.toSeq().map(r,i)}),o},t.prototype.__iterate=function(r,i){var s=this;return this._iter.__iterate(function(o,a){return r(o,a,s)},i)},t.prototype.__iterator=function(r,i){return this._iter.__iterator(r,i)},t}(Un);na.prototype[Wn]=!0;var gf=function(n){function t(e){this._iter=e,this.size=e.size}return n&&(t.__proto__=n),t.prototype=Object.create(n&&n.prototype),t.prototype.constructor=t,t.prototype.includes=function(r){return this._iter.includes(r)},t.prototype.__iterate=function(r,i){var s=this,o=0;return i&&ji(this),this._iter.__iterate(function(a){return r(a,i?s.size-++o:o++,s)},i)},t.prototype.__iterator=function(r,i){var s=this,o=this._iter.__iterator(nr,i),a=0;return i&&ji(this),new Nt(function(){var l=o.next();return l.done?l:ee(r,i?s.size-++a:a++,l.value,l)})},t}(wr),mf=function(n){function t(e){this._iter=e,this.size=e.size}return n&&(t.__proto__=n),t.prototype=Object.create(n&&n.prototype),t.prototype.constructor=t,t.prototype.has=function(r){return this._iter.includes(r)},t.prototype.__iterate=function(r,i){var s=this;return this._iter.__iterate(function(o){return r(o,o,s)},i)},t.prototype.__iterator=function(r,i){var s=this._iter.__iterator(nr,i);return new Nt(function(){var o=s.next();return o.done?o:ee(r,o.value,o.value,o)})},t}($i),yf=function(n){function t(e){this._iter=e,this.size=e.size}return n&&(t.__proto__=n),t.prototype=Object.create(n&&n.prototype),t.prototype.constructor=t,t.prototype.entrySeq=function(){return this._iter.toSeq()},t.prototype.__iterate=function(r,i){var s=this;return this._iter.__iterate(function(o){if(o){Ef(o);var a=Ze(o);return r(a?o.get(1):o[1],a?o.get(0):o[0],s)}},i)},t.prototype.__iterator=function(r,i){var s=this._iter.__iterator(nr,i);return new Nt(function(){for(;;){var o=s.next();if(o.done)return o;var a=o.value;if(a){Ef(a);var l=Ze(a);return ee(r,l?a.get(0):a[0],l?a.get(1):a[1],o)}}})},t}(Un);gf.prototype.cacheResult=na.prototype.cacheResult=mf.prototype.cacheResult=yf.prototype.cacheResult=Qu;function vf(n){var t=sn(n);return t._iter=n,t.size=n.size,t.flip=function(){return n},t.reverse=function(){var e=n.reverse.apply(this);return e.flip=function(){return n.reverse()},e},t.has=function(e){return n.includes(e)},t.includes=function(e){return n.has(e)},t.cacheResult=Qu,t.__iterateUncached=function(e,r){var i=this;return n.__iterate(function(s,o){return e(o,s,i)!==!1},r)},t.__iteratorUncached=function(e,r){if(e===ir){var i=n.__iterator(e,r);return new Nt(function(){var s=i.next();if(!s.done){var o=s.value[0];s.value[0]=s.value[1],s.value[1]=o}return s})}return n.__iterator(e===nr?Bi:nr,r)},t}function xf(n,t,e){var r=sn(n);return r.size=n.size,r.has=function(i){return n.has(i)},r.get=function(i,s){var o=n.get(i,Ft);return o===Ft?s:t.call(e,o,i,n)},r.__iterateUncached=function(i,s){var o=this;return n.__iterate(function(a,l,c){return i(t.call(e,a,l,c),l,o)!==!1},s)},r.__iteratorUncached=function(i,s){var o=n.__iterator(ir,s);return new Nt(function(){var a=o.next();if(a.done)return a;var l=a.value,c=l[0];return ee(i,c,t.call(e,l[1],c,n),a)})},r}function Ju(n,t){var e=this,r=sn(n);return r._iter=n,r.size=n.size,r.reverse=function(){return n},n.flip&&(r.flip=function(){var i=vf(n);return i.reverse=function(){return n.flip()},i}),r.get=function(i,s){return n.get(t?i:-1-i,s)},r.has=function(i){return n.has(t?i:-1-i)},r.includes=function(i){return n.includes(i)},r.cacheResult=Qu,r.__iterate=function(i,s){var o=this,a=0;return s&&ji(n),n.__iterate(function(l,c){return i(l,t?c:s?o.size-++a:a++,o)},!s)},r.__iterator=function(i,s){var o=0;s&&ji(n);var a=n.__iterator(ir,!s);return new Nt(function(){var l=a.next();if(l.done)return l;var c=l.value;return ee(i,t?c[0]:s?e.size-++o:o++,c[1],l)})},r}function _f(n,t,e,r){var i=sn(n);return r&&(i.has=function(s){var o=n.get(s,Ft);return o!==Ft&&!!t.call(e,o,s,n)},i.get=function(s,o){var a=n.get(s,Ft);return a!==Ft&&t.call(e,a,s,n)?a:o}),i.__iterateUncached=function(s,o){var a=this,l=0;return n.__iterate(function(c,h,f){if(t.call(e,c,h,f))return l++,s(c,r?h:l-1,a)},o),l},i.__iteratorUncached=function(s,o){var a=n.__iterator(ir,o),l=0;return new Nt(function(){for(;;){var c=a.next();if(c.done)return c;var h=c.value,f=h[0],g=h[1];if(t.call(e,g,f,n))return ee(s,r?f:l++,g,c)}})},i}function A0(n,t,e){var r=K().asMutable();return n.__iterate(function(i,s){r.update(t.call(e,i,s,n),0,function(o){return o+1})}),r.asImmutable()}function O0(n,t,e){var r=Kt(n),i=(Rr(n)?un():K()).asMutable();n.__iterate(function(o,a){i.update(t.call(e,o,a,n),function(l){return l=l||[],l.push(r?[a,o]:o),l})});var s=Ku(n);return i.map(function(o){return Yt(n,s(o))}).asImmutable()}function z0(n,t,e){var r=Kt(n),i=[[],[]];n.__iterate(function(o,a){i[t.call(e,o,a,n)?1:0].push(r?[a,o]:o)});var s=Ku(n);return i.map(function(o){return Yt(n,s(o))})}function Zu(n,t,e,r){var i=n.size;if(Ws(t,e,i))return n;if(typeof i>"u"&&(t<0||e<0))return Zu(n.toSeq().cacheResult(),t,e,r);var s=Vi(t,i),o=Us(e,i),a=o-s,l;a===a&&(l=a<0?0:a);var c=sn(n);return c.size=l===0?l:n.size&&l||void 0,!r&&Ko(n)&&l>=0&&(c.get=function(h,f){return h=Hn(this,h),h>=0&&h<l?n.get(h+s,f):f}),c.__iterateUncached=function(h,f){var g=this;if(l===0)return 0;if(f)return this.cacheResult().__iterate(h,f);var p=0,m=!0,v=0;return n.__iterate(function(_,S){if(!(m&&(m=p++<s)))return v++,h(_,r?S:v-1,g)!==!1&&v!==l}),v},c.__iteratorUncached=function(h,f){if(l!==0&&f)return this.cacheResult().__iterator(h,f);if(l===0)return new Nt(Ne);var g=n.__iterator(h,f),p=0,m=0;return new Nt(function(){for(;p++<s;)g.next();if(++m>l)return Ne();var v=g.next();return r||h===nr||v.done?v:h===Bi?ee(h,m-1,void 0,v):ee(h,m-1,v.value[1],v)})},c}function T0(n,t,e){var r=sn(n);return r.__iterateUncached=function(i,s){var o=this;if(s)return this.cacheResult().__iterate(i,s);var a=0;return n.__iterate(function(l,c,h){return t.call(e,l,c,h)&&++a&&i(l,c,o)}),a},r.__iteratorUncached=function(i,s){var o=this;if(s)return this.cacheResult().__iterator(i,s);var a=n.__iterator(ir,s),l=!0;return new Nt(function(){if(!l)return Ne();var c=a.next();if(c.done)return c;var h=c.value,f=h[0],g=h[1];return t.call(e,g,f,o)?i===ir?c:ee(i,f,g,c):(l=!1,Ne())})},r}function bf(n,t,e,r){var i=sn(n);return i.__iterateUncached=function(s,o){var a=this;if(o)return this.cacheResult().__iterate(s,o);var l=!0,c=0;return n.__iterate(function(h,f,g){if(!(l&&(l=t.call(e,h,f,g))))return c++,s(h,r?f:c-1,a)}),c},i.__iteratorUncached=function(s,o){var a=this;if(o)return this.cacheResult().__iterator(s,o);var l=n.__iterator(ir,o),c=!0,h=0;return new Nt(function(){var f,g,p;do{if(f=l.next(),f.done)return r||s===nr?f:s===Bi?ee(s,h++,void 0,f):ee(s,h++,f.value[1],f);var m=f.value;g=m[0],p=m[1],c&&(c=t.call(e,p,g,a))}while(c);return s===ir?f:ee(s,g,p,f)})},i}var C0=function(n){function t(e){this._wrappedIterables=e.flatMap(function(r){return r._wrappedIterables?r._wrappedIterables:[r]}),this.size=this._wrappedIterables.reduce(function(r,i){if(r!==void 0){var s=i.size;if(s!==void 0)return r+s}},0),this[Xo]=this._wrappedIterables[0][Xo],this[Jo]=this._wrappedIterables[0][Jo],this[Wn]=this._wrappedIterables[0][Wn]}return n&&(t.__proto__=n),t.prototype=Object.create(n&&n.prototype),t.prototype.constructor=t,t.prototype.__iterateUncached=function(r,i){if(this._wrappedIterables.length!==0){if(i)return this.cacheResult().__iterate(r,i);for(var s=0,o=Kt(this),a=o?ir:nr,l=this._wrappedIterables[s].__iterator(a,i),c=!0,h=0;c;){for(var f=l.next();f.done;){if(s++,s===this._wrappedIterables.length)return h;l=this._wrappedIterables[s].__iterator(a,i),f=l.next()}var g=o?r(f.value[1],f.value[0],this):r(f.value,h,this);c=g!==!1,h++}return h}},t.prototype.__iteratorUncached=function(r,i){var s=this;if(this._wrappedIterables.length===0)return new Nt(Ne);if(i)return this.cacheResult().__iterator(r,i);var o=0,a=this._wrappedIterables[o].__iterator(r,i);return new Nt(function(){for(var l=a.next();l.done;){if(o++,o===s._wrappedIterables.length)return l;a=s._wrappedIterables[o].__iterator(r,i),l=a.next()}return l})},t}(Ee);function I0(n,t){var e=Kt(n),r=[n].concat(t).map(function(s){return Ze(s)?e&&(s=_r(s)):s=e?Du(s):uf(Array.isArray(s)?s:[s]),s}).filter(function(s){return s.size!==0});if(r.length===0)return n;if(r.length===1){var i=r[0];if(i===n||e&&Kt(i)||Ke(n)&&Ke(i))return i}return new C0(r)}function wf(n,t,e){var r=sn(n);return r.__iterateUncached=function(i,s){if(s)return this.cacheResult().__iterate(i,s);var o=0,a=!1;function l(c,h){c.__iterate(function(f,g){return(!t||h<t)&&Ze(f)?l(f,h+1):(o++,i(f,e?g:o-1,r)===!1&&(a=!0)),!a},s)}return l(n,0),o},r.__iteratorUncached=function(i,s){if(s)return this.cacheResult().__iterator(i,s);var o=n.__iterator(i,s),a=[],l=0;return new Nt(function(){for(;o;){var c=o.next();if(c.done!==!1){o=a.pop();continue}var h=c.value;if(i===ir&&(h=h[1]),(!t||a.length<t)&&Ze(h))a.push(o),o=h.__iterator(i,s);else return e?c:ee(i,l++,h,c)}return Ne()})},r}function k0(n,t,e){var r=Ku(n);return n.toSeq().map(function(i,s){return r(t.call(e,i,s,n))}).flatten(!0)}function P0(n,t){var e=sn(n);return e.size=n.size&&n.size*2-1,e.__iterateUncached=function(r,i){var s=this,o=0;return n.__iterate(function(a){return(!o||r(t,o++,s)!==!1)&&r(a,o++,s)!==!1},i),o},e.__iteratorUncached=function(r,i){var s=n.__iterator(nr,i),o=0,a;return new Nt(function(){return(!a||o%2)&&(a=s.next(),a.done)?a:o%2?ee(r,o++,t):ee(r,o++,a.value,a)})},e}function Gi(n,t,e){t||(t=Mf);var r=Kt(n),i=0,s=n.toSeq().map(function(o,a){return[a,o,i++,e?e(o,a,n):o]}).valueSeq().toArray();return s.sort(function(o,a){return t(o[3],a[3])||o[2]-a[2]}).forEach(r?function(o,a){s[a].length=2}:function(o,a){s[a]=o[1]}),r?Un(s):Ke(n)?wr(s):$i(s)}function ia(n,t,e){if(t||(t=Mf),e){var r=n.toSeq().map(function(i,s){return[i,e(i,s,n)]}).reduce(function(i,s){return Sf(t,i[1],s[1])?s:i});return r&&r[0]}return n.reduce(function(i,s){return Sf(t,i,s)?s:i})}function Sf(n,t,e){var r=n(e,t);return r===0&&e!==t&&(e==null||e!==e)||r>0}function sa(n,t,e,r){var i=sn(n),s=new Hi(e).map(function(o){return o.size});return i.size=r?s.max():s.min(),i.__iterate=function(o,a){for(var l=this.__iterator(nr,a),c,h=0;!(c=l.next()).done&&o(c.value,h++,this)!==!1;);return h},i.__iteratorUncached=function(o,a){var l=e.map(function(f){return f=Te(f),Fu(a?f.reverse():f)}),c=0,h=!1;return new Nt(function(){var f;return h||(f=l.map(function(g){return g.next()}),h=r?f.every(function(g){return g.done}):f.some(function(g){return g.done})),h?Ne():ee(o,c++,t.apply(null,f.map(function(g){return g.value})))})},i}function Yt(n,t){return n===t?n:Ko(n)?t:n.constructor(t)}function Ef(n){if(n!==Object(n))throw new TypeError("Expected [K, V] tuple: "+n)}function Ku(n){return Kt(n)?_r:Ke(n)?ci:Di}function sn(n){return Object.create((Kt(n)?Un:Ke(n)?wr:$i).prototype)}function Qu(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):Ee.prototype.cacheResult.call(this)}function Mf(n,t){return n===void 0&&t===void 0?0:n===void 0?1:t===void 0?-1:n>t?1:n<t?-1:0}function on(n,t){t=t||0;for(var e=Math.max(0,n.length-t),r=new Array(e),i=0;i<e;i++)r[i]=n[i+t];return r}function Xs(n,t){if(!n)throw new Error(t)}function sr(n){Xs(n!==1/0,"Cannot perform this action with an infinite size.")}function Af(n){if(Nu(n)&&typeof n!="string")return n;if(Rr(n))return n.toArray();throw new TypeError("Invalid keyPath: expected Ordered Collection or Array: "+n)}var R0=Object.prototype.toString;function tl(n){if(!n||typeof n!="object"||R0.call(n)!=="[object Object]")return!1;var t=Object.getPrototypeOf(n);if(t===null)return!0;for(var e=t,r=Object.getPrototypeOf(t);r!==null;)e=r,r=Object.getPrototypeOf(e);return e===t}function Yn(n){return typeof n=="object"&&(br(n)||Array.isArray(n)||tl(n))}function Js(n){try{return typeof n=="string"?JSON.stringify(n):String(n)}catch{return JSON.stringify(n)}}function Of(n,t){return br(n)?n.has(t):Yn(n)&&qi.call(n,t)}function el(n,t,e){return br(n)?n.get(t,e):Of(n,t)?typeof n.get=="function"?n.get(t):n[t]:e}function oa(n){if(Array.isArray(n))return on(n);var t={};for(var e in n)qi.call(n,e)&&(t[e]=n[e]);return t}function zf(n,t){if(!Yn(n))throw new TypeError("Cannot update non-data-structure value: "+n);if(br(n)){if(!n.remove)throw new TypeError("Cannot update immutable value without .remove() method: "+n);return n.remove(t)}if(!qi.call(n,t))return n;var e=oa(n);return Array.isArray(e)?e.splice(t,1):delete e[t],e}function Tf(n,t,e){if(!Yn(n))throw new TypeError("Cannot update non-data-structure value: "+n);if(br(n)){if(!n.set)throw new TypeError("Cannot update immutable value without .set() method: "+n);return n.set(t,e)}if(qi.call(n,t)&&e===n[t])return n;var r=oa(n);return r[t]=e,r}function fi(n,t,e,r){r||(r=e,e=void 0);var i=Cf(br(n),n,Af(t),0,e,r);return i===Ft?e:i}function Cf(n,t,e,r,i,s){var o=t===Ft;if(r===e.length){var a=o?i:t,l=s(a);return l===a?t:l}if(!o&&!Yn(t))throw new TypeError("Cannot update within non-data-structure value in path ["+Array.from(e).slice(0,r).map(Js)+"]: "+t);var c=e[r],h=o?Ft:el(t,c,Ft),f=Cf(h===Ft?n:br(h),h,e,r+1,i,s);return f===h?t:f===Ft?zf(t,c):Tf(o?n?an():{}:t,c,f)}function If(n,t,e){return fi(n,t,Ft,function(){return e})}function rl(n,t){return If(this,n,t)}function kf(n,t){return fi(n,t,function(){return Ft})}function nl(n){return kf(this,n)}function il(n,t,e,r){return fi(n,[t],e,r)}function sl(n,t,e){return arguments.length===1?n(this):il(this,n,t,e)}function ol(n,t,e){return fi(this,n,t,e)}function Pf(){for(var n=[],t=arguments.length;t--;)n[t]=arguments[t];return Lf(this,n)}function Rf(n){for(var t=[],e=arguments.length-1;e-- >0;)t[e]=arguments[e+1];if(typeof n!="function")throw new TypeError("Invalid merger function: "+n);return Lf(this,t,n)}function Lf(n,t,e){for(var r=[],i=0;i<t.length;i++){var s=_r(t[i]);s.size!==0&&r.push(s)}return r.length===0?n:n.toSeq().size===0&&!n.__ownerID&&r.length===1?Gn(n)?n:n.constructor(r[0]):n.withMutations(function(o){for(var a=e?function(c,h){il(o,h,Ft,function(f){return f===Ft?c:e(f,c,h)})}:function(c,h){o.set(h,c)},l=0;l<r.length;l++)r[l].forEach(a)})}function L0(n){for(var t=[],e=arguments.length-1;e-- >0;)t[e]=arguments[e+1];return Ks(n,t)}function F0(n,t){for(var e=[],r=arguments.length-2;r-- >0;)e[r]=arguments[r+2];return Ks(t,e,n)}function N0(n){for(var t=[],e=arguments.length-1;e-- >0;)t[e]=arguments[e+1];return Zs(n,t)}function j0(n,t){for(var e=[],r=arguments.length-2;r-- >0;)e[r]=arguments[r+2];return Zs(t,e,n)}function Zs(n,t,e){return Ks(n,t,V0(e))}function Ks(n,t,e){if(!Yn(n))throw new TypeError("Cannot merge into non-data-structure value: "+n);if(br(n))return typeof e=="function"&&n.mergeWith?n.mergeWith.apply(n,[e].concat(t)):n.merge?n.merge.apply(n,t):n.concat.apply(n,t);for(var r=Array.isArray(n),i=n,s=r?ci:_r,o=r?function(l){i===n&&(i=oa(i)),i.push(l)}:function(l,c){var h=qi.call(i,c),f=h&&e?e(i[c],l,c):l;(!h||f!==i[c])&&(i===n&&(i=oa(i)),i[c]=f)},a=0;a<t.length;a++)s(t[a]).forEach(o);return i}function V0(n){function t(e,r,i){return Yn(e)&&Yn(r)&&D0(e,r)?Ks(e,[r],t):n?n(e,r,i):r}return t}function D0(n,t){var e=Ee(n),r=Ee(t);return Ke(e)===Ke(r)&&Kt(e)===Kt(r)}function Ff(){for(var n=[],t=arguments.length;t--;)n[t]=arguments[t];return Zs(this,n)}function Nf(n){for(var t=[],e=arguments.length-1;e-- >0;)t[e]=arguments[e+1];return Zs(this,t,n)}function al(n){for(var t=[],e=arguments.length-1;e-- >0;)t[e]=arguments[e+1];return fi(this,n,an(),function(r){return Ks(r,t)})}function ul(n){for(var t=[],e=arguments.length-1;e-- >0;)t[e]=arguments[e+1];return fi(this,n,an(),function(r){return Zs(r,t)})}function Qs(n){var t=this.asMutable();return n(t),t.wasAltered()?t.__ensureOwner(this.__ownerID):this}function to(){return this.__ownerID?this:this.__ensureOwner(new Pu)}function eo(){return this.__ensureOwner()}function ll(){return this.__altered}var K=function(n){function t(e){return e==null?an():ea(e)&&!Rr(e)?e:an().withMutations(function(r){var i=n(e);sr(i.size),i.forEach(function(s,o){return r.set(o,s)})})}return n&&(t.__proto__=n),t.prototype=Object.create(n&&n.prototype),t.prototype.constructor=t,t.prototype.toString=function(){return this.__toString("Map {","}")},t.prototype.get=function(r,i){return this._root?this._root.get(0,void 0,r,i):i},t.prototype.set=function(r,i){return Df(this,r,i)},t.prototype.remove=function(r){return Df(this,r,Ft)},t.prototype.deleteAll=function(r){var i=Te(r);return i.size===0?this:this.withMutations(function(s){i.forEach(function(o){return s.remove(o)})})},t.prototype.clear=function(){return this.size===0?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):an()},t.prototype.sort=function(r){return un(Gi(this,r))},t.prototype.sortBy=function(r,i){return un(Gi(this,i,r))},t.prototype.map=function(r,i){var s=this;return this.withMutations(function(o){o.forEach(function(a,l){o.set(l,r.call(i,a,l,s))})})},t.prototype.__iterator=function(r,i){return new B0(this,r,i)},t.prototype.__iterate=function(r,i){var s=this,o=0;return this._root&&this._root.iterate(function(a){return o++,r(a[1],a[0],s)},i),o},t.prototype.__ensureOwner=function(r){return r===this.__ownerID?this:r?hl(this.size,this._root,r,this.__hash):this.size===0?an():(this.__ownerID=r,this.__altered=!1,this)},t}(_r);K.isMap=ea;var re=K.prototype;re[lf]=!0,re[Gs]=re.remove,re.removeAll=re.deleteAll,re.setIn=rl,re.removeIn=re.deleteIn=nl,re.update=sl,re.updateIn=ol,re.merge=re.concat=Pf,re.mergeWith=Rf,re.mergeDeep=Ff,re.mergeDeepWith=Nf,re.mergeIn=al,re.mergeDeepIn=ul,re.withMutations=Qs,re.wasAltered=ll,re.asImmutable=eo,re["@@transducer/init"]=re.asMutable=to,re["@@transducer/step"]=function(n,t){return n.set(t[0],t[1])},re["@@transducer/result"]=function(n){return n.asImmutable()};var ro=function(t,e){this.ownerID=t,this.entries=e};ro.prototype.get=function(t,e,r,i){for(var s=this.entries,o=0,a=s.length;o<a;o++)if(Ce(r,s[o][0]))return s[o][1];return i},ro.prototype.update=function(t,e,r,i,s,o,a){for(var l=s===Ft,c=this.entries,h=0,f=c.length;h<f&&!Ce(i,c[h][0]);h++);var g=h<f;if(g?c[h][1]===s:l)return this;if(xr(a),(l||!g)&&xr(o),!(l&&c.length===1)){if(!g&&!l&&c.length>=U0)return q0(t,c,i,s);var p=t&&t===this.ownerID,m=p?c:on(c);return g?l?h===f-1?m.pop():m[h]=m.pop():m[h]=[i,s]:m.push([i,s]),p?(this.entries=m,this):new ro(t,m)}};var Wi=function(t,e,r){this.ownerID=t,this.bitmap=e,this.nodes=r};Wi.prototype.get=function(t,e,r,i){e===void 0&&(e=Qe(r));var s=1<<((t===0?e:e>>>t)&He),o=this.bitmap;return(o&s)===0?i:this.nodes[qf(o&s-1)].get(t+Ut,e,r,i)},Wi.prototype.update=function(t,e,r,i,s,o,a){r===void 0&&(r=Qe(i));var l=(e===0?r:r>>>e)&He,c=1<<l,h=this.bitmap,f=(h&c)!==0;if(!f&&s===Ft)return this;var g=qf(h&c-1),p=this.nodes,m=f?p[g]:void 0,v=fl(m,t,e+Ut,r,i,s,o,a);if(v===m)return this;if(!f&&v&&p.length>=Y0)return H0(t,p,h,l,v);if(f&&!v&&p.length===2&&Bf(p[g^1]))return p[g^1];if(f&&v&&p.length===1&&Bf(v))return v;var _=t&&t===this.ownerID,S=f?v?h:h^c:h|c,M=f?v?$f(p,g,v,_):W0(p,g,_):G0(p,g,v,_);return _?(this.bitmap=S,this.nodes=M,this):new Wi(t,S,M)};var no=function(t,e,r){this.ownerID=t,this.count=e,this.nodes=r};no.prototype.get=function(t,e,r,i){e===void 0&&(e=Qe(r));var s=(t===0?e:e>>>t)&He,o=this.nodes[s];return o?o.get(t+Ut,e,r,i):i},no.prototype.update=function(t,e,r,i,s,o,a){r===void 0&&(r=Qe(i));var l=(e===0?r:r>>>e)&He,c=s===Ft,h=this.nodes,f=h[l];if(c&&!f)return this;var g=fl(f,t,e+Ut,r,i,s,o,a);if(g===f)return this;var p=this.count;if(!f)p++;else if(!g&&(p--,p<X0))return $0(t,h,p,l);var m=t&&t===this.ownerID,v=$f(h,l,g,m);return m?(this.count=p,this.nodes=v,this):new no(t,p,v)};var Ui=function(t,e,r){this.ownerID=t,this.keyHash=e,this.entries=r};Ui.prototype.get=function(t,e,r,i){for(var s=this.entries,o=0,a=s.length;o<a;o++)if(Ce(r,s[o][0]))return s[o][1];return i},Ui.prototype.update=function(t,e,r,i,s,o,a){r===void 0&&(r=Qe(i));var l=s===Ft;if(r!==this.keyHash)return l?this:(xr(a),xr(o),dl(this,t,e,r,[i,s]));for(var c=this.entries,h=0,f=c.length;h<f&&!Ce(i,c[h][0]);h++);var g=h<f;if(g?c[h][1]===s:l)return this;if(xr(a),(l||!g)&&xr(o),l&&f===2)return new Mn(t,this.keyHash,c[h^1]);var p=t&&t===this.ownerID,m=p?c:on(c);return g?l?h===f-1?m.pop():m[h]=m.pop():m[h]=[i,s]:m.push([i,s]),p?(this.entries=m,this):new Ui(t,this.keyHash,m)};var Mn=function(t,e,r){this.ownerID=t,this.keyHash=e,this.entry=r};Mn.prototype.get=function(t,e,r,i){return Ce(r,this.entry[0])?this.entry[1]:i},Mn.prototype.update=function(t,e,r,i,s,o,a){var l=s===Ft,c=Ce(i,this.entry[0]);if(c?s===this.entry[1]:l)return this;if(xr(a),l){xr(o);return}return c?t&&t===this.ownerID?(this.entry[1]=s,this):new Mn(t,this.keyHash,[i,s]):(xr(o),dl(this,t,e,Qe(i),[i,s]))},ro.prototype.iterate=Ui.prototype.iterate=function(n,t){for(var e=this.entries,r=0,i=e.length-1;r<=i;r++)if(n(e[t?i-r:r])===!1)return!1},Wi.prototype.iterate=no.prototype.iterate=function(n,t){for(var e=this.nodes,r=0,i=e.length-1;r<=i;r++){var s=e[t?i-r:r];if(s&&s.iterate(n,t)===!1)return!1}},Mn.prototype.iterate=function(n,t){return n(this.entry)};var B0=function(n){function t(e,r,i){this._type=r,this._reverse=i,this._stack=e._root&&jf(e._root)}return n&&(t.__proto__=n),t.prototype=Object.create(n&&n.prototype),t.prototype.constructor=t,t.prototype.next=function(){for(var r=this._type,i=this._stack;i;){var s=i.node,o=i.index++,a=void 0;if(s.entry){if(o===0)return cl(r,s.entry)}else if(s.entries){if(a=s.entries.length-1,o<=a)return cl(r,s.entries[this._reverse?a-o:o])}else if(a=s.nodes.length-1,o<=a){var l=s.nodes[this._reverse?a-o:o];if(l){if(l.entry)return cl(r,l.entry);i=this._stack=jf(l,i)}continue}i=this._stack=this._stack.__prev}return Ne()},t}(Nt);function cl(n,t){return ee(n,t[0],t[1])}function jf(n,t){return{node:n,index:0,__prev:t}}function hl(n,t,e,r){var i=Object.create(re);return i.size=n,i._root=t,i.__ownerID=e,i.__hash=r,i.__altered=!1,i}var Vf;function an(){return Vf||(Vf=hl(0))}function Df(n,t,e){var r,i;if(n._root){var s=ku(),o=ku();if(r=fl(n._root,n.__ownerID,0,void 0,t,e,s,o),!o.value)return n;i=n.size+(s.value?e===Ft?-1:1:0)}else{if(e===Ft)return n;i=1,r=new ro(n.__ownerID,[[t,e]])}return n.__ownerID?(n.size=i,n._root=r,n.__hash=void 0,n.__altered=!0,n):r?hl(i,r):an()}function fl(n,t,e,r,i,s,o,a){return n?n.update(t,e,r,i,s,o,a):s===Ft?n:(xr(a),xr(o),new Mn(t,r,[i,s]))}function Bf(n){return n.constructor===Mn||n.constructor===Ui}function dl(n,t,e,r,i){if(n.keyHash===r)return new Ui(t,r,[n.entry,i]);var s=(e===0?n.keyHash:n.keyHash>>>e)&He,o=(e===0?r:r>>>e)&He,a,l=s===o?[dl(n,t,e+Ut,r,i)]:(a=new Mn(t,r,i),s<o?[n,a]:[a,n]);return new Wi(t,1<<s|1<<o,l)}function q0(n,t,e,r){n||(n=new Pu);for(var i=new Mn(n,Qe(e),[e,r]),s=0;s<t.length;s++){var o=t[s];i=i.update(n,0,void 0,o[0],o[1])}return i}function $0(n,t,e,r){for(var i=0,s=0,o=new Array(e),a=0,l=1,c=t.length;a<c;a++,l<<=1){var h=t[a];h!==void 0&&a!==r&&(i|=l,o[s++]=h)}return new Wi(n,i,o)}function H0(n,t,e,r,i){for(var s=0,o=new Array(rr),a=0;e!==0;a++,e>>>=1)o[a]=e&1?t[s++]:void 0;return o[r]=i,new no(n,s+1,o)}function qf(n){return n-=n>>1&1431655765,n=(n&858993459)+(n>>2&858993459),n=n+(n>>4)&252645135,n+=n>>8,n+=n>>16,n&127}function $f(n,t,e,r){var i=r?n:on(n);return i[t]=e,i}function G0(n,t,e,r){var i=n.length+1;if(r&&t+1===i)return n[t]=e,n;for(var s=new Array(i),o=0,a=0;a<i;a++)a===t?(s[a]=e,o=-1):s[a]=n[a+o];return s}function W0(n,t,e){var r=n.length-1;if(e&&t===r)return n.pop(),n;for(var i=new Array(r),s=0,o=0;o<r;o++)o===t&&(s=1),i[o]=n[o+s];return i}var U0=rr/4,Y0=rr/2,X0=rr/4,Hf="@@__IMMUTABLE_LIST__@@";function pl(n){return!!(n&&n[Hf])}var ut=function(n){function t(e){var r=aa();if(e==null)return r;if(pl(e))return e;var i=n(e),s=i.size;return s===0?r:(sr(s),s>0&&s<rr?so(0,s,Ut,null,new Xn(i.toArray())):r.withMutations(function(o){o.setSize(s),i.forEach(function(a,l){return o.set(l,a)})}))}return n&&(t.__proto__=n),t.prototype=Object.create(n&&n.prototype),t.prototype.constructor=t,t.of=function(){return this(arguments)},t.prototype.toString=function(){return this.__toString("List [","]")},t.prototype.get=function(r,i){if(r=Hn(this,r),r>=0&&r<this.size){r+=this._origin;var s=Wf(this,r);return s&&s.array[r&He]}return i},t.prototype.set=function(r,i){return J0(this,r,i)},t.prototype.remove=function(r){return this.has(r)?r===0?this.shift():r===this.size-1?this.pop():this.splice(r,1):this},t.prototype.insert=function(r,i){return this.splice(r,0,i)},t.prototype.clear=function(){return this.size===0?this:this.__ownerID?(this.size=this._origin=this._capacity=0,this._level=Ut,this._root=this._tail=this.__hash=void 0,this.__altered=!0,this):aa()},t.prototype.push=function(){var r=arguments,i=this.size;return this.withMutations(function(s){Jn(s,0,i+r.length);for(var o=0;o<r.length;o++)s.set(i+o,r[o])})},t.prototype.pop=function(){return Jn(this,0,-1)},t.prototype.unshift=function(){var r=arguments;return this.withMutations(function(i){Jn(i,-r.length);for(var s=0;s<r.length;s++)i.set(s,r[s])})},t.prototype.shift=function(){return Jn(this,1)},t.prototype.shuffle=function(r){return r===void 0&&(r=Math.random),this.withMutations(function(i){for(var s=i.size,o,a;s;)o=Math.floor(r()*s--),a=i.get(o),i.set(o,i.get(s)),i.set(s,a)})},t.prototype.concat=function(){for(var r=arguments,i=[],s=0;s<arguments.length;s++){var o=r[s],a=n(typeof o!="string"&&Lu(o)?o:[o]);a.size!==0&&i.push(a)}return i.length===0?this:this.size===0&&!this.__ownerID&&i.length===1?this.constructor(i[0]):this.withMutations(function(l){i.forEach(function(c){return c.forEach(function(h){return l.push(h)})})})},t.prototype.setSize=function(r){return Jn(this,0,r)},t.prototype.map=function(r,i){var s=this;return this.withMutations(function(o){for(var a=0;a<s.size;a++)o.set(a,r.call(i,o.get(a),a,s))})},t.prototype.slice=function(r,i){var s=this.size;return Ws(r,i,s)?this:Jn(this,Vi(r,s),Us(i,s))},t.prototype.__iterator=function(r,i){var s=i?this.size:0,o=Gf(this,i);return new Nt(function(){var a=o();return a===io?Ne():ee(r,i?--s:s++,a)})},t.prototype.__iterate=function(r,i){for(var s=i?this.size:0,o=Gf(this,i),a;(a=o())!==io&&r(a,i?--s:s++,this)!==!1;);return s},t.prototype.__ensureOwner=function(r){return r===this.__ownerID?this:r?so(this._origin,this._capacity,this._level,this._root,this._tail,r,this.__hash):this.size===0?aa():(this.__ownerID=r,this.__altered=!1,this)},t}(ci);ut.isList=pl;var ve=ut.prototype;ve[Hf]=!0,ve[Gs]=ve.remove,ve.merge=ve.concat,ve.setIn=rl,ve.deleteIn=ve.removeIn=nl,ve.update=sl,ve.updateIn=ol,ve.mergeIn=al,ve.mergeDeepIn=ul,ve.withMutations=Qs,ve.wasAltered=ll,ve.asImmutable=eo,ve["@@transducer/init"]=ve.asMutable=to,ve["@@transducer/step"]=function(n,t){return n.push(t)},ve["@@transducer/result"]=function(n){return n.asImmutable()};var Xn=function(t,e){this.array=t,this.ownerID=e};Xn.prototype.removeBefore=function(t,e,r){if((r&(1<<e+Ut)-1)===0||this.array.length===0)return this;var i=r>>>e&He;if(i>=this.array.length)return new Xn([],t);var s=i===0,o;if(e>0){var a=this.array[i];if(o=a&&a.removeBefore(t,e-Ut,r),o===a&&s)return this}if(s&&!o)return this;var l=Yi(this,t);if(!s)for(var c=0;c<i;c++)l.array[c]=void 0;return o&&(l.array[i]=o),l},Xn.prototype.removeAfter=function(t,e,r){if(r===(e?1<<e+Ut:rr)||this.array.length===0)return this;var i=r-1>>>e&He;if(i>=this.array.length)return this;var s;if(e>0){var o=this.array[i];if(s=o&&o.removeAfter(t,e-Ut,r),s===o&&i===this.array.length-1)return this}var a=Yi(this,t);return a.array.splice(i+1),s&&(a.array[i]=s),a};var io={};function Gf(n,t){var e=n._origin,r=n._capacity,i=oo(r),s=n._tail;return o(n._root,n._level,0);function o(c,h,f){return h===0?a(c,f):l(c,h,f)}function a(c,h){var f=h===i?s&&s.array:c&&c.array,g=h>e?0:e-h,p=r-h;return p>rr&&(p=rr),function(){if(g===p)return io;var m=t?--p:g++;return f&&f[m]}}function l(c,h,f){var g,p=c&&c.array,m=f>e?0:e-f>>h,v=(r-f>>h)+1;return v>rr&&(v=rr),function(){for(;;){if(g){var _=g();if(_!==io)return _;g=null}if(m===v)return io;var S=t?--v:m++;g=o(p&&p[S],h-Ut,f+(S<<h))}}}}function so(n,t,e,r,i,s,o){var a=Object.create(ve);return a.size=t-n,a._origin=n,a._capacity=t,a._level=e,a._root=r,a._tail=i,a.__ownerID=s,a.__hash=o,a.__altered=!1,a}function aa(){return so(0,0,Ut)}function J0(n,t,e){if(t=Hn(n,t),t!==t)return n;if(t>=n.size||t<0)return n.withMutations(function(o){t<0?Jn(o,t).set(0,e):Jn(o,0,t+1).set(t,e)});t+=n._origin;var r=n._tail,i=n._root,s=ku();return t>=oo(n._capacity)?r=gl(r,n.__ownerID,0,t,e,s):i=gl(i,n.__ownerID,n._level,t,e,s),s.value?n.__ownerID?(n._root=i,n._tail=r,n.__hash=void 0,n.__altered=!0,n):so(n._origin,n._capacity,n._level,i,r):n}function gl(n,t,e,r,i,s){var o=r>>>e&He,a=n&&o<n.array.length;if(!a&&i===void 0)return n;var l;if(e>0){var c=n&&n.array[o],h=gl(c,t,e-Ut,r,i,s);return h===c?n:(l=Yi(n,t),l.array[o]=h,l)}return a&&n.array[o]===i?n:(s&&xr(s),l=Yi(n,t),i===void 0&&o===l.array.length-1?l.array.pop():l.array[o]=i,l)}function Yi(n,t){return t&&n&&t===n.ownerID?n:new Xn(n?n.array.slice():[],t)}function Wf(n,t){if(t>=oo(n._capacity))return n._tail;if(t<1<<n._level+Ut){for(var e=n._root,r=n._level;e&&r>0;)e=e.array[t>>>r&He],r-=Ut;return e}}function Jn(n,t,e){t!==void 0&&(t|=0),e!==void 0&&(e|=0);var r=n.__ownerID||new Pu,i=n._origin,s=n._capacity,o=i+t,a=e===void 0?s:e<0?s+e:i+e;if(o===i&&a===s)return n;if(o>=a)return n.clear();for(var l=n._level,c=n._root,h=0;o+h<0;)c=new Xn(c&&c.array.length?[void 0,c]:[],r),l+=Ut,h+=1<<l;h&&(o+=h,i+=h,a+=h,s+=h);for(var f=oo(s),g=oo(a);g>=1<<l+Ut;)c=new Xn(c&&c.array.length?[c]:[],r),l+=Ut;var p=n._tail,m=g<f?Wf(n,a-1):g>f?new Xn([],r):p;if(p&&g>f&&o<s&&p.array.length){c=Yi(c,r);for(var v=c,_=l;_>Ut;_-=Ut){var S=f>>>_&He;v=v.array[S]=Yi(v.array[S],r)}v.array[f>>>Ut&He]=p}if(a<s&&(m=m&&m.removeAfter(r,0,a)),o>=g)o-=g,a-=g,l=Ut,c=null,m=m&&m.removeBefore(r,0,o);else if(o>i||g<f){for(h=0;c;){var M=o>>>l&He;if(M!==g>>>l&He)break;M&&(h+=(1<<l)*M),l-=Ut,c=c.array[M]}c&&o>i&&(c=c.removeBefore(r,l,o-h)),c&&g<f&&(c=c.removeAfter(r,l,g-h)),h&&(o-=h,a-=h)}return n.__ownerID?(n.size=a-o,n._origin=o,n._capacity=a,n._level=l,n._root=c,n._tail=m,n.__hash=void 0,n.__altered=!0,n):so(o,a,l,c,m)}function oo(n){return n<rr?0:n-1>>>Ut<<Ut}var un=function(n){function t(e){return e==null?ao():qu(e)?e:ao().withMutations(function(r){var i=_r(e);sr(i.size),i.forEach(function(s,o){return r.set(o,s)})})}return n&&(t.__proto__=n),t.prototype=Object.create(n&&n.prototype),t.prototype.constructor=t,t.of=function(){return this(arguments)},t.prototype.toString=function(){return this.__toString("OrderedMap {","}")},t.prototype.get=function(r,i){var s=this._map.get(r);return s!==void 0?this._list.get(s)[1]:i},t.prototype.clear=function(){return this.size===0?this:this.__ownerID?(this.size=0,this._map.clear(),this._list.clear(),this.__altered=!0,this):ao()},t.prototype.set=function(r,i){return Yf(this,r,i)},t.prototype.remove=function(r){return Yf(this,r,Ft)},t.prototype.__iterate=function(r,i){var s=this;return this._list.__iterate(function(o){return o&&r(o[1],o[0],s)},i)},t.prototype.__iterator=function(r,i){return this._list.fromEntrySeq().__iterator(r,i)},t.prototype.__ensureOwner=function(r){if(r===this.__ownerID)return this;var i=this._map.__ensureOwner(r),s=this._list.__ensureOwner(r);return r?ml(i,s,r,this.__hash):this.size===0?ao():(this.__ownerID=r,this.__altered=!1,this._map=i,this._list=s,this)},t}(K);un.isOrderedMap=qu,un.prototype[Wn]=!0,un.prototype[Gs]=un.prototype.remove;function ml(n,t,e,r){var i=Object.create(un.prototype);return i.size=n?n.size:0,i._map=n,i._list=t,i.__ownerID=e,i.__hash=r,i.__altered=!1,i}var Uf;function ao(){return Uf||(Uf=ml(an(),aa()))}function Yf(n,t,e){var r=n._map,i=n._list,s=r.get(t),o=s!==void 0,a,l;if(e===Ft){if(!o)return n;i.size>=rr&&i.size>=r.size*2?(l=i.filter(function(c,h){return c!==void 0&&s!==h}),a=l.toKeyedSeq().map(function(c){return c[0]}).flip().toMap(),n.__ownerID&&(a.__ownerID=l.__ownerID=n.__ownerID)):(a=r.remove(t),l=s===i.size-1?i.pop():i.set(s,void 0))}else if(o){if(e===i.get(s)[1])return n;a=r,l=i.set(s,[t,e])}else a=r.set(t,i.size),l=i.set(i.size,[t,e]);return n.__ownerID?(n.size=a.size,n._map=a,n._list=l,n.__hash=void 0,n.__altered=!0,n):ml(a,l)}var Xf="@@__IMMUTABLE_STACK__@@";function ua(n){return!!(n&&n[Xf])}var la=function(n){function t(e){return e==null?ca():ua(e)?e:ca().pushAll(e)}return n&&(t.__proto__=n),t.prototype=Object.create(n&&n.prototype),t.prototype.constructor=t,t.of=function(){return this(arguments)},t.prototype.toString=function(){return this.__toString("Stack [","]")},t.prototype.get=function(r,i){var s=this._head;for(r=Hn(this,r);s&&r--;)s=s.next;return s?s.value:i},t.prototype.peek=function(){return this._head&&this._head.value},t.prototype.push=function(){var r=arguments;if(arguments.length===0)return this;for(var i=this.size+arguments.length,s=this._head,o=arguments.length-1;o>=0;o--)s={value:r[o],next:s};return this.__ownerID?(this.size=i,this._head=s,this.__hash=void 0,this.__altered=!0,this):uo(i,s)},t.prototype.pushAll=function(r){if(r=n(r),r.size===0)return this;if(this.size===0&&ua(r))return r;sr(r.size);var i=this.size,s=this._head;return r.__iterate(function(o){i++,s={value:o,next:s}},!0),this.__ownerID?(this.size=i,this._head=s,this.__hash=void 0,this.__altered=!0,this):uo(i,s)},t.prototype.pop=function(){return this.slice(1)},t.prototype.clear=function(){return this.size===0?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):ca()},t.prototype.slice=function(r,i){if(Ws(r,i,this.size))return this;var s=Vi(r,this.size),o=Us(i,this.size);if(o!==this.size)return n.prototype.slice.call(this,r,i);for(var a=this.size-s,l=this._head;s--;)l=l.next;return this.__ownerID?(this.size=a,this._head=l,this.__hash=void 0,this.__altered=!0,this):uo(a,l)},t.prototype.__ensureOwner=function(r){return r===this.__ownerID?this:r?uo(this.size,this._head,r,this.__hash):this.size===0?ca():(this.__ownerID=r,this.__altered=!1,this)},t.prototype.__iterate=function(r,i){var s=this;if(i)return new Hi(this.toArray()).__iterate(function(l,c){return r(l,c,s)},i);for(var o=0,a=this._head;a&&r(a.value,o++,this)!==!1;)a=a.next;return o},t.prototype.__iterator=function(r,i){if(i)return new Hi(this.toArray()).__iterator(r,i);var s=0,o=this._head;return new Nt(function(){if(o){var a=o.value;return o=o.next,ee(r,s++,a)}return Ne()})},t}(ci);la.isStack=ua;var Ge=la.prototype;Ge[Xf]=!0,Ge.shift=Ge.pop,Ge.unshift=Ge.push,Ge.unshiftAll=Ge.pushAll,Ge.withMutations=Qs,Ge.wasAltered=ll,Ge.asImmutable=eo,Ge["@@transducer/init"]=Ge.asMutable=to,Ge["@@transducer/step"]=function(n,t){return n.unshift(t)},Ge["@@transducer/result"]=function(n){return n.asImmutable()};function uo(n,t,e,r){var i=Object.create(Ge);return i.size=n,i._head=t,i.__ownerID=e,i.__hash=r,i.__altered=!1,i}var Jf;function ca(){return Jf||(Jf=uo(0))}var Zf="@@__IMMUTABLE_SET__@@";function ha(n){return!!(n&&n[Zf])}function yl(n){return ha(n)&&Rr(n)}function vl(n,t){if(n===t)return!0;if(!Ze(t)||n.size!==void 0&&t.size!==void 0&&n.size!==t.size||n.__hash!==void 0&&t.__hash!==void 0&&n.__hash!==t.__hash||Kt(n)!==Kt(t)||Ke(n)!==Ke(t)||Rr(n)!==Rr(t))return!1;if(n.size===0&&t.size===0)return!0;var e=!Zo(n);if(Rr(n)){var r=n.entries();return t.every(function(l,c){var h=r.next().value;return h&&Ce(h[1],l)&&(e||Ce(h[0],c))})&&r.next().done}var i=!1;if(n.size===void 0)if(t.size===void 0)typeof n.cacheResult=="function"&&n.cacheResult();else{i=!0;var s=n;n=t,t=s}var o=!0,a=t.__iterate(function(l,c){if(e?!n.has(l):i?!Ce(l,n.get(c,Ft)):!Ce(n.get(c,Ft),l))return o=!1,!1});return o&&n.size===a}function di(n,t){var e=function(r){n.prototype[r]=t[r]};return Object.keys(t).forEach(e),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(t).forEach(e),n}function fa(n){if(!n||typeof n!="object")return n;if(!Ze(n)){if(!Yn(n))return n;n=Ee(n)}if(Kt(n)){var t={};return n.__iterate(function(r,i){t[i]=fa(r)}),t}var e=[];return n.__iterate(function(r){e.push(fa(r))}),e}var lo=function(n){function t(e){return e==null?co():ha(e)&&!Rr(e)?e:co().withMutations(function(r){var i=n(e);sr(i.size),i.forEach(function(s){return r.add(s)})})}return n&&(t.__proto__=n),t.prototype=Object.create(n&&n.prototype),t.prototype.constructor=t,t.of=function(){return this(arguments)},t.fromKeys=function(r){return this(_r(r).keySeq())},t.intersect=function(r){return r=Te(r).toArray(),r.length?Re.intersect.apply(t(r.pop()),r):co()},t.union=function(r){return r=Te(r).toArray(),r.length?Re.union.apply(t(r.pop()),r):co()},t.prototype.toString=function(){return this.__toString("Set {","}")},t.prototype.has=function(r){return this._map.has(r)},t.prototype.add=function(r){return da(this,this._map.set(r,r))},t.prototype.remove=function(r){return da(this,this._map.remove(r))},t.prototype.clear=function(){return da(this,this._map.clear())},t.prototype.map=function(r,i){var s=this,o=!1,a=da(this,this._map.mapEntries(function(l){var c=l[1],h=r.call(i,c,c,s);return h!==c&&(o=!0),[h,h]},i));return o?a:this},t.prototype.union=function(){for(var r=[],i=arguments.length;i--;)r[i]=arguments[i];return r=r.filter(function(s){return s.size!==0}),r.length===0?this:this.size===0&&!this.__ownerID&&r.length===1?this.constructor(r[0]):this.withMutations(function(s){for(var o=0;o<r.length;o++)typeof r[o]=="string"?s.add(r[o]):n(r[o]).forEach(function(a){return s.add(a)})})},t.prototype.intersect=function(){for(var r=[],i=arguments.length;i--;)r[i]=arguments[i];if(r.length===0)return this;r=r.map(function(o){return n(o)});var s=[];return this.forEach(function(o){r.every(function(a){return a.includes(o)})||s.push(o)}),this.withMutations(function(o){s.forEach(function(a){o.remove(a)})})},t.prototype.subtract=function(){for(var r=[],i=arguments.length;i--;)r[i]=arguments[i];if(r.length===0)return this;r=r.map(function(o){return n(o)});var s=[];return this.forEach(function(o){r.some(function(a){return a.includes(o)})&&s.push(o)}),this.withMutations(function(o){s.forEach(function(a){o.remove(a)})})},t.prototype.sort=function(r){return Zi(Gi(this,r))},t.prototype.sortBy=function(r,i){return Zi(Gi(this,i,r))},t.prototype.wasAltered=function(){return this._map.wasAltered()},t.prototype.__iterate=function(r,i){var s=this;return this._map.__iterate(function(o){return r(o,o,s)},i)},t.prototype.__iterator=function(r,i){return this._map.__iterator(r,i)},t.prototype.__ensureOwner=function(r){if(r===this.__ownerID)return this;var i=this._map.__ensureOwner(r);return r?this.__make(i,r):this.size===0?this.__empty():(this.__ownerID=r,this._map=i,this)},t}(Di);lo.isSet=ha;var Re=lo.prototype;Re[Zf]=!0,Re[Gs]=Re.remove,Re.merge=Re.concat=Re.union,Re.withMutations=Qs,Re.asImmutable=eo,Re["@@transducer/init"]=Re.asMutable=to,Re["@@transducer/step"]=function(n,t){return n.add(t)},Re["@@transducer/result"]=function(n){return n.asImmutable()},Re.__empty=co,Re.__make=Kf;function da(n,t){return n.__ownerID?(n.size=t.size,n._map=t,n):t===n._map?n:t.size===0?n.__empty():n.__make(t)}function Kf(n,t){var e=Object.create(Re);return e.size=n?n.size:0,e._map=n,e.__ownerID=t,e}var Qf;function co(){return Qf||(Qf=Kf(an()))}var td=function(n){function t(e,r,i){if(i===void 0&&(i=1),!(this instanceof t))return new t(e,r,i);if(Xs(i!==0,"Cannot step a Range by 0"),Xs(e!==void 0,"You must define a start value when using Range"),Xs(r!==void 0,"You must define an end value when using Range"),i=Math.abs(i),r<e&&(i=-i),this._start=e,this._end=r,this._step=i,this.size=Math.max(0,Math.ceil((r-e)/i-1)+1),this.size===0){if(xl)return xl;xl=this}}return n&&(t.__proto__=n),t.prototype=Object.create(n&&n.prototype),t.prototype.constructor=t,t.prototype.toString=function(){return this.size===0?"Range []":"Range [ "+this._start+"..."+this._end+(this._step!==1?" by "+this._step:"")+" ]"},t.prototype.get=function(r,i){return this.has(r)?this._start+Hn(this,r)*this._step:i},t.prototype.includes=function(r){var i=(r-this._start)/this._step;return i>=0&&i<this.size&&i===Math.floor(i)},t.prototype.slice=function(r,i){return Ws(r,i,this.size)?this:(r=Vi(r,this.size),i=Us(i,this.size),i<=r?new t(0,0):new t(this.get(r,this._end),this.get(i,this._end),this._step))},t.prototype.indexOf=function(r){var i=r-this._start;if(i%this._step===0){var s=i/this._step;if(s>=0&&s<this.size)return s}return-1},t.prototype.lastIndexOf=function(r){return this.indexOf(r)},t.prototype.__iterate=function(r,i){for(var s=this.size,o=this._step,a=i?this._start+(s-1)*o:this._start,l=0;l!==s&&r(a,i?s-++l:l++,this)!==!1;)a+=i?-o:o;return l},t.prototype.__iterator=function(r,i){var s=this.size,o=this._step,a=i?this._start+(s-1)*o:this._start,l=0;return new Nt(function(){if(l===s)return Ne();var c=a;return a+=i?-o:o,ee(r,i?s-++l:l++,c)})},t.prototype.equals=function(r){return r instanceof t?this._start===r._start&&this._end===r._end&&this._step===r._step:vl(this,r)},t}(wr),xl;function _l(n,t,e){for(var r=Af(t),i=0;i!==r.length;)if(n=el(n,r[i++],Ft),n===Ft)return e;return n}function ed(n,t){return _l(this,n,t)}function rd(n,t){return _l(n,t,Ft)!==Ft}function Z0(n){return rd(this,n)}function nd(){sr(this.size);var n={};return this.__iterate(function(t,e){n[e]=t}),n}Te.Iterator=Nt,di(Te,{toArray:function(){sr(this.size);var t=new Array(this.size||0),e=Kt(this),r=0;return this.__iterate(function(i,s){t[r++]=e?[s,i]:i}),t},toIndexedSeq:function(){return new gf(this)},toJS:function(){return fa(this)},toKeyedSeq:function(){return new na(this,!0)},toMap:function(){return K(this.toKeyedSeq())},toObject:nd,toOrderedMap:function(){return un(this.toKeyedSeq())},toOrderedSet:function(){return Zi(Kt(this)?this.valueSeq():this)},toSet:function(){return lo(Kt(this)?this.valueSeq():this)},toSetSeq:function(){return new mf(this)},toSeq:function(){return Ke(this)?this.toIndexedSeq():Kt(this)?this.toKeyedSeq():this.toSetSeq()},toStack:function(){return la(Kt(this)?this.valueSeq():this)},toList:function(){return ut(Kt(this)?this.valueSeq():this)},toString:function(){return"[Collection]"},__toString:function(t,e){return this.size===0?t+e:t+" "+this.toSeq().map(this.__toStringMapper).join(", ")+" "+e},concat:function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return Yt(this,I0(this,t))},includes:function(t){return this.some(function(e){return Ce(e,t)})},entries:function(){return this.__iterator(ir)},every:function(t,e){sr(this.size);var r=!0;return this.__iterate(function(i,s,o){if(!t.call(e,i,s,o))return r=!1,!1}),r},filter:function(t,e){return Yt(this,_f(this,t,e,!0))},partition:function(t,e){return z0(this,t,e)},find:function(t,e,r){var i=this.findEntry(t,e);return i?i[1]:r},forEach:function(t,e){return sr(this.size),this.__iterate(e?t.bind(e):t)},join:function(t){sr(this.size),t=t!==void 0?""+t:",";var e="",r=!0;return this.__iterate(function(i){r?r=!1:e+=t,e+=i!=null?i.toString():""}),e},keys:function(){return this.__iterator(Bi)},map:function(t,e){return Yt(this,xf(this,t,e))},reduce:function(t,e,r){return id(this,t,e,r,arguments.length<2,!1)},reduceRight:function(t,e,r){return id(this,t,e,r,arguments.length<2,!0)},reverse:function(){return Yt(this,Ju(this,!0))},slice:function(t,e){return Yt(this,Zu(this,t,e,!0))},some:function(t,e){sr(this.size);var r=!1;return this.__iterate(function(i,s,o){if(t.call(e,i,s,o))return r=!0,!1}),r},sort:function(t){return Yt(this,Gi(this,t))},values:function(){return this.__iterator(nr)},butLast:function(){return this.slice(0,-1)},isEmpty:function(){return this.size!==void 0?this.size===0:!this.some(function(){return!0})},count:function(t,e){return ji(t?this.toSeq().filter(t,e):this)},countBy:function(t,e){return A0(this,t,e)},equals:function(t){return vl(this,t)},entrySeq:function(){var t=this;if(t._cache)return new Hi(t._cache);var e=t.toSeq().map(Q0).toIndexedSeq();return e.fromEntrySeq=function(){return t.toSeq()},e},filterNot:function(t,e){return this.filter(bl(t),e)},findEntry:function(t,e,r){var i=r;return this.__iterate(function(s,o,a){if(t.call(e,s,o,a))return i=[o,s],!1}),i},findKey:function(t,e){var r=this.findEntry(t,e);return r&&r[0]},findLast:function(t,e,r){return this.toKeyedSeq().reverse().find(t,e,r)},findLastEntry:function(t,e,r){return this.toKeyedSeq().reverse().findEntry(t,e,r)},findLastKey:function(t,e){return this.toKeyedSeq().reverse().findKey(t,e)},first:function(t){return this.find(Kh,null,t)},flatMap:function(t,e){return Yt(this,k0(this,t,e))},flatten:function(t){return Yt(this,wf(this,t,!0))},fromEntrySeq:function(){return new yf(this)},get:function(t,e){return this.find(function(r,i){return Ce(i,t)},void 0,e)},getIn:ed,groupBy:function(t,e){return O0(this,t,e)},has:function(t){return this.get(t,Ft)!==Ft},hasIn:Z0,isSubset:function(t){return t=typeof t.includes=="function"?t:Te(t),this.every(function(e){return t.includes(e)})},isSuperset:function(t){return t=typeof t.isSubset=="function"?t:Te(t),t.isSubset(this)},keyOf:function(t){return this.findKey(function(e){return Ce(e,t)})},keySeq:function(){return this.toSeq().map(K0).toIndexedSeq()},last:function(t){return this.toSeq().reverse().first(t)},lastKeyOf:function(t){return this.toKeyedSeq().reverse().keyOf(t)},max:function(t){return ia(this,t)},maxBy:function(t,e){return ia(this,e,t)},min:function(t){return ia(this,t?sd(t):ad)},minBy:function(t,e){return ia(this,e?sd(e):ad,t)},rest:function(){return this.slice(1)},skip:function(t){return t===0?this:this.slice(Math.max(0,t))},skipLast:function(t){return t===0?this:this.slice(0,-Math.max(0,t))},skipWhile:function(t,e){return Yt(this,bf(this,t,e,!0))},skipUntil:function(t,e){return this.skipWhile(bl(t),e)},sortBy:function(t,e){return Yt(this,Gi(this,e,t))},take:function(t){return this.slice(0,Math.max(0,t))},takeLast:function(t){return this.slice(-Math.max(0,t))},takeWhile:function(t,e){return Yt(this,T0(this,t,e))},takeUntil:function(t,e){return this.takeWhile(bl(t),e)},update:function(t){return t(this)},valueSeq:function(){return this.toIndexedSeq()},hashCode:function(){return this.__hash||(this.__hash=tv(this))}});var je=Te.prototype;je[ef]=!0,je[Qo]=je.values,je.toJSON=je.toArray,je.__toStringMapper=Js,je.inspect=je.toSource=function(){return this.toString()},je.chain=je.flatMap,je.contains=je.includes,di(_r,{flip:function(){return Yt(this,vf(this))},mapEntries:function(t,e){var r=this,i=0;return Yt(this,this.toSeq().map(function(s,o){return t.call(e,[o,s],i++,r)}).fromEntrySeq())},mapKeys:function(t,e){var r=this;return Yt(this,this.toSeq().flip().map(function(i,s){return t.call(e,i,s,r)}).flip())}});var ho=_r.prototype;ho[Xo]=!0,ho[Qo]=je.entries,ho.toJSON=nd,ho.__toStringMapper=function(n,t){return Js(t)+": "+Js(n)},di(ci,{toKeyedSeq:function(){return new na(this,!1)},filter:function(t,e){return Yt(this,_f(this,t,e,!1))},findIndex:function(t,e){var r=this.findEntry(t,e);return r?r[0]:-1},indexOf:function(t){var e=this.keyOf(t);return e===void 0?-1:e},lastIndexOf:function(t){var e=this.lastKeyOf(t);return e===void 0?-1:e},reverse:function(){return Yt(this,Ju(this,!1))},slice:function(t,e){return Yt(this,Zu(this,t,e,!1))},splice:function(t,e){var r=arguments.length;if(e=Math.max(e||0,0),r===0||r===2&&!e)return this;t=Vi(t,t<0?this.count():this.size);var i=this.slice(0,t);return Yt(this,r===1?i:i.concat(on(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){var r=this.findLastEntry(t,e);return r?r[0]:-1},first:function(t){return this.get(0,t)},flatten:function(t){return Yt(this,wf(this,t,!1))},get:function(t,e){return t=Hn(this,t),t<0||this.size===1/0||this.size!==void 0&&t>this.size?e:this.find(function(r,i){return i===t},void 0,e)},has:function(t){return t=Hn(this,t),t>=0&&(this.size!==void 0?this.size===1/0||t<this.size:this.indexOf(t)!==-1)},interpose:function(t){return Yt(this,P0(this,t))},interleave:function(){var t=[this].concat(on(arguments)),e=sa(this.toSeq(),wr.of,t),r=e.flatten(!0);return e.size&&(r.size=e.size*t.length),Yt(this,r)},keySeq:function(){return td(0,this.size)},last:function(t){return this.get(-1,t)},skipWhile:function(t,e){return Yt(this,bf(this,t,e,!1))},zip:function(){var t=[this].concat(on(arguments));return Yt(this,sa(this,od,t))},zipAll:function(){var t=[this].concat(on(arguments));return Yt(this,sa(this,od,t,!0))},zipWith:function(t){var e=on(arguments);return e[0]=this,Yt(this,sa(this,t,e))}});var Xi=ci.prototype;Xi[Jo]=!0,Xi[Wn]=!0,di(Di,{get:function(t,e){return this.has(t)?t:e},includes:function(t){return this.has(t)},keySeq:function(){return this.valueSeq()}});var Ji=Di.prototype;Ji.has=je.includes,Ji.contains=Ji.includes,Ji.keys=Ji.values,di(Un,ho),di(wr,Xi),di($i,Ji);function id(n,t,e,r,i,s){return sr(n.size),n.__iterate(function(o,a,l){i?(i=!1,e=o):e=t.call(r,e,o,a,l)},s),e}function K0(n,t){return t}function Q0(n,t){return[t,n]}function bl(n){return function(){return!n.apply(this,arguments)}}function sd(n){return function(){return-n.apply(this,arguments)}}function od(){return on(arguments)}function ad(n,t){return n<t?1:n>t?-1:0}function tv(n){if(n.size===1/0)return 0;var t=Rr(n),e=Kt(n),r=t?1:0;return n.__iterate(e?t?function(i,s){r=31*r+ud(Qe(i),Qe(s))|0}:function(i,s){r=r+ud(Qe(i),Qe(s))|0}:t?function(i){r=31*r+Qe(i)|0}:function(i){r=r+Qe(i)|0}),ev(n.size,r)}function ev(n,t){return t=Ys(t,3432918353),t=Ys(t<<15|t>>>-15,461845907),t=Ys(t<<13|t>>>-13,5),t=(t+3864292196|0)^n,t=Ys(t^t>>>16,2246822507),t=Ys(t^t>>>13,3266489909),t=ra(t^t>>>16),t}function ud(n,t){return n^t+2654435769+(n<<6)+(n>>2)|0}var Zi=function(n){function t(e){return e==null?wl():yl(e)?e:wl().withMutations(function(r){var i=Di(e);sr(i.size),i.forEach(function(s){return r.add(s)})})}return n&&(t.__proto__=n),t.prototype=Object.create(n&&n.prototype),t.prototype.constructor=t,t.of=function(){return this(arguments)},t.fromKeys=function(r){return this(_r(r).keySeq())},t.prototype.toString=function(){return this.__toString("OrderedSet {","}")},t}(lo);Zi.isOrderedSet=yl;var pi=Zi.prototype;pi[Wn]=!0,pi.zip=Xi.zip,pi.zipWith=Xi.zipWith,pi.zipAll=Xi.zipAll,pi.__empty=wl,pi.__make=ld;function ld(n,t){var e=Object.create(pi);return e.size=n?n.size:0,e._map=n,e.__ownerID=t,e}var cd;function wl(){return cd||(cd=ld(ao()))}var rv={LeftThenRight:-1,RightThenLeft:1};function nv(n){if(Gn(n))throw new Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(br(n))throw new Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(n===null||typeof n!="object")throw new Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}var Rt=function(t,e){var r;nv(t);var i=function(a){var l=this;if(a instanceof i)return a;if(!(this instanceof i))return new i(a);if(!r){r=!0;var c=Object.keys(t),h=s._indices={};s._name=e,s._keys=c,s._defaultValues=t;for(var f=0;f<c.length;f++){var g=c[f];h[g]=f,s[g]?typeof console=="object"&&console.warn&&console.warn("Cannot define "+El(this)+' with property "'+g+'" since that property name is part of the Record API.'):iv(s,g)}}return this.__ownerID=void 0,this._values=ut().withMutations(function(p){p.setSize(l._keys.length),_r(a).forEach(function(m,v){p.set(l._indices[v],m===l._defaultValues[v]?void 0:m)})}),this},s=i.prototype=Object.create(Qt);return s.constructor=i,e&&(i.displayName=e),i};Rt.prototype.toString=function(){for(var t=El(this)+" { ",e=this._keys,r,i=0,s=e.length;i!==s;i++)r=e[i],t+=(i?", ":"")+r+": "+Js(this.get(r));return t+" }"},Rt.prototype.equals=function(t){return this===t||Gn(t)&&Ki(this).equals(Ki(t))},Rt.prototype.hashCode=function(){return Ki(this).hashCode()},Rt.prototype.has=function(t){return this._indices.hasOwnProperty(t)},Rt.prototype.get=function(t,e){if(!this.has(t))return e;var r=this._indices[t],i=this._values.get(r);return i===void 0?this._defaultValues[t]:i},Rt.prototype.set=function(t,e){if(this.has(t)){var r=this._values.set(this._indices[t],e===this._defaultValues[t]?void 0:e);if(r!==this._values&&!this.__ownerID)return Sl(this,r)}return this},Rt.prototype.remove=function(t){return this.set(t)},Rt.prototype.clear=function(){var t=this._values.clear().setSize(this._keys.length);return this.__ownerID?this:Sl(this,t)},Rt.prototype.wasAltered=function(){return this._values.wasAltered()},Rt.prototype.toSeq=function(){return Ki(this)},Rt.prototype.toJS=function(){return fa(this)},Rt.prototype.entries=function(){return this.__iterator(ir)},Rt.prototype.__iterator=function(t,e){return Ki(this).__iterator(t,e)},Rt.prototype.__iterate=function(t,e){return Ki(this).__iterate(t,e)},Rt.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var e=this._values.__ensureOwner(t);return t?Sl(this,e,t):(this.__ownerID=t,this._values=e,this)},Rt.isRecord=Gn,Rt.getDescriptiveName=El;var Qt=Rt.prototype;Qt[nf]=!0,Qt[Gs]=Qt.remove,Qt.deleteIn=Qt.removeIn=nl,Qt.getIn=ed,Qt.hasIn=je.hasIn,Qt.merge=Pf,Qt.mergeWith=Rf,Qt.mergeIn=al,Qt.mergeDeep=Ff,Qt.mergeDeepWith=Nf,Qt.mergeDeepIn=ul,Qt.setIn=rl,Qt.update=sl,Qt.updateIn=ol,Qt.withMutations=Qs,Qt.asMutable=to,Qt.asImmutable=eo,Qt[Qo]=Qt.entries,Qt.toJSON=Qt.toObject=je.toObject,Qt.inspect=Qt.toSource=function(){return this.toString()};function Sl(n,t,e){var r=Object.create(Object.getPrototypeOf(n));return r._values=t,r.__ownerID=e,r}function El(n){return n.constructor.displayName||n.constructor.name||"Record"}function Ki(n){return Du(n._keys.map(function(t){return[t,n.get(t)]}))}function iv(n,t){try{Object.defineProperty(n,t,{get:function(){return this.get(t)},set:function(e){Xs(this.__ownerID,"Cannot set on an immutable record."),this.set(t,e)}})}catch{}}var sv=function(n){function t(e,r){if(!(this instanceof t))return new t(e,r);if(this._value=e,this.size=r===void 0?1/0:Math.max(0,r),this.size===0){if(Ml)return Ml;Ml=this}}return n&&(t.__proto__=n),t.prototype=Object.create(n&&n.prototype),t.prototype.constructor=t,t.prototype.toString=function(){return this.size===0?"Repeat []":"Repeat [ "+this._value+" "+this.size+" times ]"},t.prototype.get=function(r,i){return this.has(r)?this._value:i},t.prototype.includes=function(r){return Ce(this._value,r)},t.prototype.slice=function(r,i){var s=this.size;return Ws(r,i,s)?this:new t(this._value,Us(i,s)-Vi(r,s))},t.prototype.reverse=function(){return this},t.prototype.indexOf=function(r){return Ce(this._value,r)?0:-1},t.prototype.lastIndexOf=function(r){return Ce(this._value,r)?this.size:-1},t.prototype.__iterate=function(r,i){for(var s=this.size,o=0;o!==s&&r(this._value,i?s-++o:o++,this)!==!1;);return o},t.prototype.__iterator=function(r,i){var s=this,o=this.size,a=0;return new Nt(function(){return a===o?Ne():ee(r,i?o-++a:a++,s._value)})},t.prototype.equals=function(r){return r instanceof t?Ce(this._value,r._value):vl(this,r)},t}(wr),Ml;function Xt(n,t){return hd([],t||ov,n,"",t&&t.length>2?[]:void 0,{"":n})}function hd(n,t,e,r,i,s){if(typeof e!="string"&&!br(e)&&(Nu(e)||Lu(e)||tl(e))){if(~n.indexOf(e))throw new TypeError("Cannot convert circular structure to Immutable");n.push(e),i&&r!==""&&i.push(r);var o=t.call(s,r,Ee(e).map(function(a,l){return hd(n,t,a,l,i,e)}),i&&i.slice());return n.pop(),i&&i.pop(),o}return e}function ov(n,t){return Ke(t)?t.toList():Kt(t)?t.toMap():t.toSet()}var av="5.1.3",uv=Te;const lv=Object.freeze(Object.defineProperty({__proto__:null,Collection:Te,Iterable:uv,List:ut,Map:K,OrderedMap:un,OrderedSet:Zi,PairSorting:rv,Range:td,Record:Rt,Repeat:sv,Seq:Ee,Set:lo,Stack:la,fromJS:Xt,get:el,getIn:_l,has:Of,hasIn:rd,hash:Qe,is:Ce,isAssociative:Zo,isCollection:Ze,isImmutable:br,isIndexed:Ke,isKeyed:Kt,isList:pl,isMap:ea,isOrdered:Rr,isOrderedMap:qu,isOrderedSet:yl,isPlainObject:tl,isRecord:Gn,isSeq:Ko,isSet:ha,isStack:ua,isValueObject:$u,merge:L0,mergeDeep:N0,mergeDeepWith:j0,mergeWith:F0,remove:zf,removeIn:kf,set:Tf,setIn:If,update:il,updateIn:fi,version:av},Symbol.toStringTag,{value:"Module"})),fe="MODE_IDLE",gi="MODE_2D_ZOOM_IN",mi="MODE_2D_ZOOM_OUT",yi="MODE_2D_PAN",vi="MODE_3D_VIEW",Qi="MODE_3D_FIRST_PERSON",Lr="MODE_WAITING_DRAWING_LINE",Fr="MODE_DRAGGING_LINE",Nr="MODE_DRAGGING_VERTEX",jr="MODE_DRAGGING_ITEM",Vr="MODE_DRAGGING_HOLE",or="MODE_DRAWING_LINE",ar="MODE_DRAWING_HOLE",Sr="MODE_DRAWING_ITEM",An="MODE_ROTATING_ITEM",Al="MODE_UPLOADING_IMAGE",Ol="MODE_FITTING_IMAGE",zl="MODE_VIEWING_CATALOG",fd="MODE_CONFIGURING_PROJECT",Tl=[fe,gi,mi,yi,Lr,or,ar,Sr,Fr,Nr,jr,Vr,Ol,Al,An],cv="mm",ln="cm",dd=[cv,ln,"m","in","ft","mi"],cn=1e-6,Er={DELETE:46,BACKSPACE:8,ESC:27,Z:90,ALT:18,C:67,V:86,CTRL:17,ENTER:13,TAB:9},tr=(n,t=6)=>n&&t?parseFloat(parseFloat(n.toString()).toFixed(t)):0,ts=n=>{let t=n;return t<0&&(t=~t+1),t};function Cl(n,t){return n.x===t.x?n.y-t.y:n.x-t.x}function pa(n,t){return Cl(n,t)>0?t:n}function Il(n,t){return Cl(n,t)>0?n:t}function fo(n){return n.sort(Cl)}function Ve(n,t,e,r){let i=n-e,s=t-r;return Math.sqrt(i*i+s*s)}function ga(n,t){let{x:e,y:r}=n,{x:i,y:s}=t;return Ve(e,r,i,s)}function ma(n){return{a:0,b:1,c:-n}}function ya(n){return{a:1,b:0,c:-n}}function hv(n,t,e,r,i){return ts(n*r+t*i+e)/Math.sqrt(n*n+t*t)}function fv(n,t,e,r,i){let s=n*n+t*t;return{x:(t*(t*r-n*i)-n*e)/s,y:(n*-t*r+n*i-t*e)/s}}function po(n,t,e,r,i,s){let o=t*r-n*i;if(o===0)return;let a=(n*s-e*r)/o;return{x:(e*i-t*s)/o,y:a}}function dv(n,t,e,r){let{x:i,y:s}=n,{x:o,y:a}=t,{x:l,y:c}=e,{x:h,y:f}=r,g=(f-c)*(o-i)-(h-l)*(a-s),p=(h-l)*(s-c)-(f-c)*(i-l),m=(o-i)*(s-c)-(a-s)*(i-l);if(ts(g)<=cn){if(ts(p)<=cn&&ts(m)<=cn){let S=(z,R)=>z.x===R.x?z.y-R.y:z.x-R.x,M=[n,t].sort(S),C=[e.toJS(),r.toJS()].sort(S),[O,E]=[M,C].sort((z,R)=>S(z[0],R[0]));return O[1].x===E[0].x?{type:E[0].y<=O[1].y?"colinear":"none"}:{type:E[0].x<=O[1].x?"colinear":"none"}}return{type:"parallel"}}let v=p/g,_=m/g;return v>=0-cn&&v<=1+cn&&_>=0-cn&&_<=1+cn?{type:"intersecting",point:{x:i+v*(o-i),y:s+v*(a-s)}}:{type:"none"}}function pd(n,t,e,r,i,s){let o=i-n,a=s-t,l=e-n,c=r-t,h=o*l+a*c,f=l*l+c*c,g=-1;f!=0&&(g=h/f);let p,m;g<0?(p=n,m=t):g>1?(p=e,m=r):(p=n+g*l,m=t+g*c);let v=i-p,_=s-m;return Math.sqrt(v*v+_*_)}function pv(n,t,e,r,i,s,o=cn){return pd(n,t,e,r,i,s)<=o}function gv(n,t,e,r,i,s){if(n===e)return{x:n,y:s};if(t===r)return{x:i,y:t};let o=(r-t)/(e-n),a=t-o*n,l=-1/o,h=(s-l*i-a)/(o-l),f=o*h+a;return{x:h,y:f}}function De(n,t,e,r,i,s){let o=Ve(n,t,e,r),l=Ve(n,t,i,s)/o;return n>e&&(l=mv(l,0,1,1,0)),l}function mv(n,t,e,r,i){return r+(i-r)*(n-t)/(e-t)}function yv(n,t,e,r){return-Math.atan2(t-r,e-n)*180/Math.PI}function kl(n,t,e,r){return Math.atan2(r-t,e-n)}function vv(n,t,e,r){return Math.atan2(Math.abs(r-t),Math.abs(e-n))}function Dr({x:n,y:t},{x:e,y:r}){return ts(n-e)<=cn&&ts(t-r)<=cn}function va(n,t,e,r,i,s=6){let o=kl(n,t,e,r);return{x:tr(n+Math.cos(o)*i,s),y:tr(t+Math.sin(o)*i,s)}}function xv(n,t,e){let r=n.length>>1,i,s,o=n[2*r-3]-e,a=n[2*r-2]-t,l=n[2*r-1]-e;if(a===0&&l===0)return!1;for(let h=0;h<r;h++){if(i=a,o=l,a=n[2*h]-t,l=n[2*h+1]-e,a===0&&l===0)return!1;o!==l&&(s=l>o)}let c=0;for(let h=0;h<r;h++){if(i=a,o=l,a=n[2*h]-t,l=n[2*h+1]-e,o<0&&l<0||o>0&&l>0||i<0&&a<0)continue;if(o===l&&Math.min(i,a)<0)return!0;if(o===l)continue;let f=i+(a-i)*-o/(l-o);if(f===0)return!1;f>0&&c++,o===0&&s&&l>o&&c--,o===0&&!s&&l<o&&c--,s=l>o}return(c&1)===1}function _v(n,t){let e=Math.cos(n);return e<t?0:e}function bv(n,t){let e=Math.sin(n);return e<t?0:e}function wv(n,t,e,r){return{x:(n+e)/2,y:(t+r)/2}}function Sv(n){let t=n.reduce((e,r)=>({x:e.x+r.x,y:e.y+r.y}),{x:0,y:0});return{x:t.x/n.length,y:t.y/n.length}}function gd(n,t,e,r,i){let s=i*Math.PI/180,o=Math.cos(s),a=Math.sin(s),l=n-e,c=t-r;return{x:o*l-a*c+e,y:a*l+o*c+r}}const Pl="SNAP_POINT",Rl="SNAP_LINE",Ll="SNAP_SEGMENT",Fl="SNAP_GRID",md="SNAP_GUIDE",Ev=K({SNAP_POINT:!0,SNAP_LINE:!0,SNAP_SEGMENT:!0,SNAP_GRID:!1,SNAP_GUIDE:!0});class Mv extends Rt({type:"point",x:-1,y:-1,radius:1,priority:1,related:ut()}){nearestPoint(t,e){return{x:this.x,y:this.y,distance:Ve(this.x,this.y,t,e)}}isNear(t,e,r){return~(this.x-t)+1<r&&~(this.y-e)+1<r}}class Av extends Rt({type:"line",a:-1,b:-1,c:-1,radius:1,priority:1,related:ut()}){nearestPoint(t,e){return{...fv(this.a,this.b,this.c,t,e),distance:hv(this.a,this.b,this.c,t,e)}}isNear(t,e,r){return!0}}class Ov extends Rt({type:"line-segment",x1:-1,y1:-1,x2:-1,y2:-1,radius:1,priority:1,related:ut()}){nearestPoint(t,e){return{...gv(this.x1,this.y1,this.x2,this.y2,t,e),distance:pd(this.x1,this.y1,this.x2,this.y2,t,e)}}isNear(t,e,r){return!0}}class zv extends Rt({type:"grid",x:-1,y:-1,radius:1,priority:1,related:ut()}){nearestPoint(t,e){return{x:this.x,y:this.y,distance:Ve(this.x,this.y,t,e)}}isNear(t,e,r){return~(this.x-t)+1<r&&~(this.y-e)+1<r}}function hn(n,t,e,r){let i={point:r.get(Pl),line:r.get(Rl),"line-segment":r.get(Ll),grid:r.get(Fl)};return n.valueSeq().filter(s=>i[s.type]&&s.isNear(t,e,s.radius)).map(s=>({snap:s,point:s.nearestPoint(t,e)})).filter(({snap:{radius:s},point:{distance:o}})=>o<s).min(({snap:{priority:s},point:{distance:o}},{snap:{priority:a},point:{distance:l}})=>s===a?o<l?-1:1:s>a?-1:1)}function Nl(n,t,e,r,i,s){return s=ut([s]),n.push(new Mv({x:t,y:e,radius:r,priority:i,related:s}))}function xa(n,t,e,r,i,s,o){return o=ut([o]),n.withMutations(a=>{if(a.some(c=>c.type==="line"&&t===c.a&&e===c.b&&r===c.c))return a;a.valueSeq().filter(c=>c.type==="line").map(c=>po(c.a,c.b,c.c,t,e,r)).filter(c=>c!==void 0).forEach(({x:c,y:h})=>Nl(a,c,h,20,40)),a.push(new Av({a:t,b:e,c:r,radius:i,priority:s,related:o}))})}function go(n,t,e,r,i,s,o,a){return a=ut([a]),n.push(new Ov({x1:t,y1:e,x2:r,y2:i,radius:s,priority:o,related:a}))}function Tv(n,t,e,r,i,s){return s=ut([s]),n.push(new zv({x:t,y:e,radius:r,priority:i,related:s}))}let On=(n,t,e)=>n?K(n).map(r=>new t(r)).toMap():e||K();class jl extends Rt({id:"",type:"",properties:K()},"Grid"){constructor(t={}){super({...t,properties:Xt(t.properties||{})})}}const Cv=K({h1:new jl({id:"h1",type:"horizontal-streak",properties:{step:20,colors:["#808080","#ddd","#ddd","#ddd","#ddd"]}}),v1:new jl({id:"v1",type:"vertical-streak",properties:{step:20,colors:["#808080","#ddd","#ddd","#ddd","#ddd"]}})});class yd extends Rt({vertices:ut(),lines:ut(),holes:ut(),areas:ut(),items:ut()},"ElementsSet"){constructor(t={}){super({vertices:ut(t.vertices||[]),lines:ut(t.lines||[]),holes:ut(t.holes||[]),areas:ut(t.areas||[]),items:ut(t.items||[])})}}const es={id:"",type:"",prototype:"",name:"",misc:K(),selected:!1,properties:K(),visible:!0};let vd=class extends Rt({...es,x:-1,y:-1,prototype:"vertices",lines:ut(),areas:ut()},"Vertex"){constructor(t={}){super({...t,lines:ut(t.lines||[]),areas:ut(t.areas||[])})}},xd=class extends Rt({...es,prototype:"lines",vertices:ut(),holes:ut()},"Line"){constructor(t={}){super({...t,properties:Xt(t.properties||{}),vertices:ut(t.vertices||[]),holes:ut(t.holes||[])})}},_d=class extends Rt({...es,prototype:"holes",offset:-1,line:""},"Hole"){constructor(t={}){super({...t,properties:Xt(t.properties||{})})}},bd=class extends Rt({...es,prototype:"areas",vertices:ut(),holes:ut()},"Area"){constructor(t={}){super({...t,properties:Xt(t.properties||{}),vertices:ut(t.vertices||[])})}},wd=class extends Rt({...es,prototype:"items",x:0,y:0,rotation:0},"Item"){constructor(t={}){super({...t,properties:Xt(t.properties||{})})}},Vl=class extends Rt({id:"",altitude:0,order:0,opacity:1,name:"",visible:!0,vertices:K(),lines:K(),holes:K(),areas:K(),items:K(),selected:new yd},"Layer"){constructor(t={}){super({...t,vertices:On(t.vertices,vd),lines:On(t.lines,xd),holes:On(t.holes,_d),areas:On(t.areas,bd),items:On(t.items,wd),selected:new yd(t.selected)})}},Dl=class extends Rt({...es,prototype:"groups",x:0,y:0,rotation:0,elements:K()},"Group"){constructor(t={}){super({...t,properties:Xt(t.properties||{}),elements:Xt(t.elements||{})})}};const Iv=K({"layer-1":new Vl({id:"layer-1",name:"default"})});let _a=class extends Rt({unit:"cm",layers:K(),grids:K(),selectedLayer:null,groups:K(),width:3e3,height:2e3,meta:K(),guides:K()},"Scene"){constructor(t={}){let e=On(t.layers,Vl,Iv);super({...t,grids:On(t.grids,jl,Cv),layers:e,selectedLayer:e.first().id,groups:On(t.groups||{},Dl),meta:t.meta?Xt(t.meta):K(),guides:t.guides?Xt(t.guides):K({horizontal:K(),vertical:K(),circular:K()})})}};class kv extends Rt({name:"",prototype:"",info:K(),properties:K()},"CatalogElement"){constructor(t={}){super({...t,info:Xt(t.info),properties:Xt(t.properties)})}}let Bl=class extends Rt({ready:!1,page:"root",path:ut(),elements:K()},"Catalog"){constructor(t={}){let e=On(t.elements,kv);super({elements:e,ready:!e.isEmpty()})}factoryElement(t,e,r){if(!this.elements.has(t)){let o=this.elements.map(a=>a.name).toArray();throw new Error(`Element ${t} does not exist in catalog ${o}`)}const i=this.elements.get(t),s=i.properties.map((o,a)=>r&&r.has(a)?r.get(a):o.get("defaultValue"));switch(i.prototype){case"lines":return new xd(e).merge({properties:s});case"holes":return new _d(e).merge({properties:s});case"areas":return new bd(e).merge({properties:s});case"items":return new wd(e).merge({properties:s});default:throw new Error("prototype not valid")}}};class Sd extends Rt({list:ut(),first:null,last:null,redoList:ut()},"HistoryStructure"){constructor(t={}){super({list:Xt(t.list||[]),first:new _a(t.scene),last:new _a(t.last||t.scene)})}}let ba=class extends Rt({mode:fe,scene:new _a,sceneHistory:new Sd,catalog:new Bl,viewer2D:K(),mouse:K({x:0,y:0}),zoom:0,snapMask:Ev,snapElements:ut(),activeSnapElement:null,drawingSupport:K(),draggingSupport:K(),rotatingSupport:K(),errors:ut(),warnings:ut(),clipboardProperties:K(),selectedElementsHistory:ut(),misc:K(),alterate:!1},"State"){constructor(t={}){super({...t,scene:new _a(t.scene),sceneHistory:new Sd(t),catalog:new Bl(t.catalog||{}),viewer2D:K(t.viewer2D||{}),drawingSupport:K(t.drawingSupport||{}),draggingSupport:K(t.draggingSupport||{}),rotatingSupport:K(t.rotatingSupport||{}),misc:t.misc?Xt(t.misc):K()})}};function wa(n){let t=[];for(let e=0;e<n;++e)t.push([]);return t}class Ed{constructor(t,e){Vt(this,"u");Vt(this,"v");this.u=t,this.v=e}}class Pv{constructor(t){Vt(this,"count");Vt(this,"subgraphs");Vt(this,"time");Vt(this,"V");Vt(this,"E");Vt(this,"adj");Vt(this,"children");this.count=0,this.subgraphs=[],this.time=0,this.children=0,this.V=t,this.E=0,this.adj=[],this.adj=wa(t)}addEdge(t,e){this.adj[t].push(e),this.E++}_BCCUtil(t,e,r,i,s){e[t]=r[t]=++this.time,this.children=0,this.adj[t].forEach(o=>{if(e[o]==-1){if(this.children++,s[o]=t,i.push(new Ed(t,o)),this._BCCUtil(o,e,r,i,s),r[t]>r[o]&&(r[t]=r[o]),e[t]==1&&this.children>1||e[t]>1&&r[o]>=e[t]){let a=[];for(;i[i.length-1].u!=t||i[i.length-1].v!=o;)a.push(i[i.length-1]),i.splice(i.length-1,1);a.push(i[i.length-1]),this.subgraphs.push(a),a=[],i.splice(i.length-1,1),this.count++}}else o!=s[t]&&e[o]<r[t]&&(r[t]>e[o]&&(r[t]=e[o]),i.push(new Ed(t,o)))})}BCC(){let t=this.V,e=wa(t),r=wa(t),i=wa(t),s=[];for(let o=0;o<t;o++)e[o]=-1,r[o]=-1,i[o]=-1;for(let o=0;o<t;o++){e[o]==-1&&this._BCCUtil(o,e,r,s,i);let a=0,l=[];for(;s.length>0;)a=1,l.push(s[s.length-1]),s.splice(s.length-1,1);a==1&&(this.subgraphs.push(l),l=[],this.count++)}}}const Rv=(n,t)=>{let e=[];return n.forEach(r=>{e.push([]);let i=Lv(r);i.forEach(s=>{t.adj[s].forEach(a=>{s<=a&&i.has(a)&&e[e.length-1].push([s,a])})})}),e},Lv=n=>{let t=new Set;return n.forEach(e=>{t.add(e.u),t.add(e.v)}),t};function Fv(n,t){return[n[0]-t[0],n[1]-t[1]]}function Md(n,t){return(n%t+t)%t}function Nv(n){return n.map(function(e){return{ev:e,color:0,direction:-1}})}function jv(n,t){let e=Fv(t,n);return Math.atan2(e[1],e[0])}function Vv(n,t){return n.map(function(e,r){let i=[];return t.forEach(function(s,o){let a,l;s[0]===r&&(a=s[1],l=1),s[1]===r&&(a=s[0],l=0),a!==void 0&&i.push({index:o,endpoint:a,angle:jv(e,n[a]),edge:s,position:l})}),i.sort(function(s,o){return o.angle-s.angle}),i})}function Ad(n,t){let e,r;for(e=0;e<t.length;e+=1)if(t[e].color<2)return r=-1*t[e].direction,zd(t,e,r),{edge:e,direction:r,position:r===-1?0:1}}function Od(n,t,e,r){let i=n[r[t][e]],s=i.length,o,a,l;for(l=0;l<s;l+=1)if(o=i[l],o.index===t)return a=i[Md(l+1,i.length)],{edge:a.index,vertex:a.endpoint,position:a.position,direction:a.position?1:-1}}function zd(n,t,e){n[t].color+=1,n[t].direction=e}function Dv(n,t){let e=Nv(t),r=Vv(n,t),i=[],s=[],o=[],a,l,c,h,f=Ad(r,e);for(;f!==void 0;){for(a=[t[f.edge][Md(f.position+1,2)],t[f.edge][f.position]],l=[f.edge],c=[f.direction],h=Od(r,f.edge,f.position,t);h.edge!==f.edge;)a.push(h.vertex),l.push(h.edge),c.push(h.direction),zd(e,h.edge,h.direction),h=Od(r,h.edge,h.position,t);s.push(l),i.push(a),o.push(c),f=Ad(r,e)}return{v_cycles:i,e_cycles:s,dir_e_cycles:o,ev_mapping:e}}function Bv(n,t){let e=[],r,i,s;for(s=0;s<t.length;s+=1)r=t[s],i=n[s],(r.length<3||i[0]!==i[i.length-1])&&e.push(s);return e}function qv(n,t){let e=Dv(n,t),r=e.v_cycles,i=e.e_cycles;Bv(r,i).forEach(g=>{r.splice(g,1),i.splice(g,1)});let o=e.dir_e_cycles,l=e.e_cycles.map((g,p)=>g.map(function(m,v){let _,S;return o[p][v]>0?(_=t[m][0],S=t[m][1]):(_=t[m][1],S=t[m][0]),(n[S][0]-n[_][0])*(n[S][1]+n[_][1])})).map(g=>g.reduce((p,m)=>p+m)),c=l.filter(g=>g>0).length,h=l.length-c,f=c>=h?1:-1;return{v_cycles:e.v_cycles.filter((g,p)=>f*l[p]>0),e_cycles:e.e_cycles.filter((g,p)=>f*l[p]>0),ev_mapping:e.ev_mapping}}function $v(n,t){let e=ut();const r=new Pv(n.length);t.forEach(([l,c])=>{r.addEdge(l,c),r.addEdge(c,l)}),r.BCC();const i=r.subgraphs.filter(l=>l.length>=3),s=Rv(i,r),o=[];return s.forEach(l=>{l.forEach(c=>o.push(c))}),qv(n,o).v_cycles.forEach(l=>{l.shift(),e=e.push(l)}),e}function Hv(n){let t=0,e=0,r=n.size;for(t=0;t<r;t++){let{x:i,y:s}=n.get(t)||{x:0,y:0},{x:o,y:a}=n.get((t+1)%r)||{x:0,y:0};e+=(o-i)*(a+s)}return e>0}function ql(n,t=ut(),e=K()){let{width:r,height:i}=n,s,o,a;return t.withMutations(l=>{if(n.layers.forEach(c=>{let{lines:h,vertices:f}=c;f.forEach(({id:g,x:p,y:m})=>{e.get(Pl)&&Nl(l,p,m,10,10,g),e.get(Rl)&&({a:s,b:o,c:a}=ma(m),xa(l,s,o,a,10,1,g),{a:s,b:o,c:a}=ya(p),xa(l,s,o,a,10,1,g))}),e.get(Ll)&&h.forEach(({id:g,vertices:[p,m]})=>{let{x:v,y:_}=f.get(p),{x:S,y:M}=f.get(m);go(l,v,_,S,M,20,1,g)})}),e.get(Fl)){let c=5,h=100/c,f=r/h,g=i/h;for(let p=0;p<f;p++){let m=p*h;for(let v=0;v<g;v++){let _=v*h,S=!(p%c),M=!(v%c);Tv(l,m,_,10,S&&M?15:10,null)}}}if(e.get(md)){let c=n.getIn(["guides","horizontal"]),h=n.getIn(["guides","vertical"]),f=c.valueSeq(),g=h.valueSeq();f.forEach(p=>{g.forEach(m=>{Nl(l,m,p,10,10)})}),f.forEach(p=>go(l,0,p,r,p,20,1)),g.forEach(p=>go(l,p,0,p,i,20,1))}})}var Sa={exports:{}},Gv=Sa.exports,Td;function $l(){return Td||(Td=1,function(n,t){(function(e,r){n.exports=r()})(Gv,function(){var e=Array.prototype.slice;function r(u,d){d&&(u.prototype=Object.create(d.prototype)),u.prototype.constructor=u}function i(u){return l(u)?u:Ot(u)}r(s,i);function s(u){return c(u)?u:Bt(u)}r(o,i);function o(u){return h(u)?u:kt(u)}r(a,i);function a(u){return l(u)&&!f(u)?u:Ct(u)}function l(u){return!!(u&&u[p])}function c(u){return!!(u&&u[m])}function h(u){return!!(u&&u[v])}function f(u){return c(u)||h(u)}function g(u){return!!(u&&u[_])}i.isIterable=l,i.isKeyed=c,i.isIndexed=h,i.isAssociative=f,i.isOrdered=g,i.Keyed=s,i.Indexed=o,i.Set=a;var p="@@__IMMUTABLE_ITERABLE__@@",m="@@__IMMUTABLE_KEYED__@@",v="@@__IMMUTABLE_INDEXED__@@",_="@@__IMMUTABLE_ORDERED__@@",S="delete",M=5,C=1<<M,O=C-1,E={},z={value:!1},R={value:!1};function k(u){return u.value=!1,u}function L(u){u&&(u.value=!0)}function X(){}function J(u,d){d=d||0;for(var y=Math.max(0,u.length-d),x=new Array(y),b=0;b<y;b++)x[b]=u[b+d];return x}function at(u){return u.size===void 0&&(u.size=u.__iterate(bt)),u.size}function tt(u,d){if(typeof d!="number"){var y=d>>>0;if(""+y!==d||y===4294967295)return NaN;d=y}return d<0?at(u)+d:d}function bt(){return!0}function xt(u,d,y){return(u===0||y!==void 0&&u<=-y)&&(d===void 0||y!==void 0&&d>=y)}function yt(u,d){return Y(u,d,0)}function ht(u,d){return Y(u,d,d)}function Y(u,d,y){return u===void 0?y:u<0?Math.max(0,d+u):d===void 0?u:Math.min(d,u)}var St=0,j=1,W=2,ft=typeof Symbol=="function"&&Symbol.iterator,et="@@iterator",rt=ft||et;function Z(u){this.next=u}Z.prototype.toString=function(){return"[Iterator]"},Z.KEYS=St,Z.VALUES=j,Z.ENTRIES=W,Z.prototype.inspect=Z.prototype.toSource=function(){return this.toString()},Z.prototype[rt]=function(){return this};function Q(u,d,y,x){var b=u===0?d:u===1?y:[d,y];return x?x.value=b:x={value:b,done:!1},x}function U(){return{value:void 0,done:!0}}function st(u){return!!pt(u)}function vt(u){return u&&typeof u.next=="function"}function B(u){var d=pt(u);return d&&d.call(u)}function pt(u){var d=u&&(ft&&u[ft]||u[et]);if(typeof d=="function")return d}function H(u){return u&&typeof u.length=="number"}r(Ot,i);function Ot(u){return u==null?Dn():l(u)?u.toSeq():Ci(u)}Ot.of=function(){return Ot(arguments)},Ot.prototype.toSeq=function(){return this},Ot.prototype.toString=function(){return this.__toString("Seq {","}")},Ot.prototype.cacheResult=function(){return!this._cache&&this.__iterateUncached&&(this._cache=this.entrySeq().toArray(),this.size=this._cache.length),this},Ot.prototype.__iterate=function(u,d){return se(this,u,d,!0)},Ot.prototype.__iterator=function(u,d){return Ye(this,u,d,!0)},r(Bt,Ot);function Bt(u){return u==null?Dn().toKeyedSeq():l(u)?c(u)?u.toSeq():u.fromEntrySeq():_n(u)}Bt.prototype.toKeyedSeq=function(){return this},r(kt,Ot);function kt(u){return u==null?Dn():l(u)?c(u)?u.entrySeq():u.toIndexedSeq():Bn(u)}kt.of=function(){return kt(arguments)},kt.prototype.toIndexedSeq=function(){return this},kt.prototype.toString=function(){return this.__toString("Seq [","]")},kt.prototype.__iterate=function(u,d){return se(this,u,d,!1)},kt.prototype.__iterator=function(u,d){return Ye(this,u,d,!1)},r(Ct,Ot);function Ct(u){return(u==null?Dn():l(u)?c(u)?u.entrySeq():u:Bn(u)).toSetSeq()}Ct.of=function(){return Ct(arguments)},Ct.prototype.toSetSeq=function(){return this},Ot.isSeq=Le,Ot.Keyed=Bt,Ot.Set=Ct,Ot.Indexed=kt;var Gt="@@__IMMUTABLE_SEQ__@@";Ot.prototype[Gt]=!0,r(gt,kt);function gt(u){this._array=u,this.size=u.length}gt.prototype.get=function(u,d){return this.has(u)?this._array[tt(this,u)]:d},gt.prototype.__iterate=function(u,d){for(var y=this._array,x=y.length-1,b=0;b<=x;b++)if(u(y[d?x-b:b],b,this)===!1)return b+1;return b},gt.prototype.__iterator=function(u,d){var y=this._array,x=y.length-1,b=0;return new Z(function(){return b>x?U():Q(u,b,y[d?x-b++:b++])})},r(_t,Bt);function _t(u){var d=Object.keys(u);this._object=u,this._keys=d,this.size=d.length}_t.prototype.get=function(u,d){return d!==void 0&&!this.has(u)?d:this._object[u]},_t.prototype.has=function(u){return this._object.hasOwnProperty(u)},_t.prototype.__iterate=function(u,d){for(var y=this._object,x=this._keys,b=x.length-1,A=0;A<=b;A++){var T=x[d?b-A:A];if(u(y[T],T,this)===!1)return A+1}return A},_t.prototype.__iterator=function(u,d){var y=this._object,x=this._keys,b=x.length-1,A=0;return new Z(function(){var T=x[d?b-A:A];return A++>b?U():Q(u,T,y[T])})},_t.prototype[_]=!0,r(Dt,kt);function Dt(u){this._iterable=u,this.size=u.length||u.size}Dt.prototype.__iterateUncached=function(u,d){if(d)return this.cacheResult().__iterate(u,d);var y=this._iterable,x=B(y),b=0;if(vt(x))for(var A;!(A=x.next()).done&&u(A.value,b++,this)!==!1;);return b},Dt.prototype.__iteratorUncached=function(u,d){if(d)return this.cacheResult().__iterator(u,d);var y=this._iterable,x=B(y);if(!vt(x))return new Z(U);var b=0;return new Z(function(){var A=x.next();return A.done?A:Q(u,b++,A.value)})},r(zt,kt);function zt(u){this._iterator=u,this._iteratorCache=[]}zt.prototype.__iterateUncached=function(u,d){if(d)return this.cacheResult().__iterate(u,d);for(var y=this._iterator,x=this._iteratorCache,b=0;b<x.length;)if(u(x[b],b++,this)===!1)return b;for(var A;!(A=y.next()).done;){var T=A.value;if(x[b]=T,u(T,b++,this)===!1)break}return b},zt.prototype.__iteratorUncached=function(u,d){if(d)return this.cacheResult().__iterator(u,d);var y=this._iterator,x=this._iteratorCache,b=0;return new Z(function(){if(b>=x.length){var A=y.next();if(A.done)return A;x[b]=A.value}return Q(u,b,x[b++])})};function Le(u){return!!(u&&u[Gt])}var tn;function Dn(){return tn||(tn=new gt([]))}function _n(u){var d=Array.isArray(u)?new gt(u).fromEntrySeq():vt(u)?new zt(u).fromEntrySeq():st(u)?new Dt(u).fromEntrySeq():typeof u=="object"?new _t(u):void 0;if(!d)throw new TypeError("Expected Array or iterable object of [k, v] entries, or keyed object: "+u);return d}function Bn(u){var d=Ii(u);if(!d)throw new TypeError("Expected Array or iterable object of values: "+u);return d}function Ci(u){var d=Ii(u)||typeof u=="object"&&new _t(u);if(!d)throw new TypeError("Expected Array or iterable object of values, or keyed object: "+u);return d}function Ii(u){return H(u)?new gt(u):vt(u)?new zt(u):st(u)?new Dt(u):void 0}function se(u,d,y,x){var b=u._cache;if(b){for(var A=b.length-1,T=0;T<=A;T++){var P=b[y?A-T:T];if(d(P[1],x?P[0]:T,u)===!1)return T+1}return T}return u.__iterateUncached(d,y)}function Ye(u,d,y,x){var b=u._cache;if(b){var A=b.length-1,T=0;return new Z(function(){var P=b[y?A-T:T];return T++>A?U():Q(d,x?P[0]:T-1,P[1])})}return u.__iteratorUncached(d,y)}function Cr(u,d){return d?dr(d,u,"",{"":u}):ki(u)}function dr(u,d,y,x){return Array.isArray(d)?u.call(x,y,kt(d).map(function(b,A){return dr(u,b,A,d)})):qn(d)?u.call(x,y,Bt(d).map(function(b,A){return dr(u,b,A,d)})):d}function ki(u){return Array.isArray(u)?kt(u).map(ki).toList():qn(u)?Bt(u).map(ki).toMap():u}function qn(u){return u&&(u.constructor===Object||u.constructor===void 0)}function oe(u,d){if(u===d||u!==u&&d!==d)return!0;if(!u||!d)return!1;if(typeof u.valueOf=="function"&&typeof d.valueOf=="function"){if(u=u.valueOf(),d=d.valueOf(),u===d||u!==u&&d!==d)return!0;if(!u||!d)return!1}return!!(typeof u.equals=="function"&&typeof d.equals=="function"&&u.equals(d))}function $n(u,d){if(u===d)return!0;if(!l(d)||u.size!==void 0&&d.size!==void 0&&u.size!==d.size||u.__hash!==void 0&&d.__hash!==void 0&&u.__hash!==d.__hash||c(u)!==c(d)||h(u)!==h(d)||g(u)!==g(d))return!1;if(u.size===0&&d.size===0)return!0;var y=!f(u);if(g(u)){var x=u.entries();return d.every(function(N,V){var q=x.next().value;return q&&oe(q[1],N)&&(y||oe(q[0],V))})&&x.next().done}var b=!1;if(u.size===void 0)if(d.size===void 0)typeof u.cacheResult=="function"&&u.cacheResult();else{b=!0;var A=u;u=d,d=A}var T=!0,P=d.__iterate(function(N,V){if(y?!u.has(N):b?!oe(N,u.get(V,E)):!oe(u.get(V,E),N))return T=!1,!1});return T&&u.size===P}r(we,kt);function we(u,d){if(!(this instanceof we))return new we(u,d);if(this._value=u,this.size=d===void 0?1/0:Math.max(0,d),this.size===0){if(Pi)return Pi;Pi=this}}we.prototype.toString=function(){return this.size===0?"Repeat []":"Repeat [ "+this._value+" "+this.size+" times ]"},we.prototype.get=function(u,d){return this.has(u)?this._value:d},we.prototype.includes=function(u){return oe(this._value,u)},we.prototype.slice=function(u,d){var y=this.size;return xt(u,d,y)?this:new we(this._value,ht(d,y)-yt(u,y))},we.prototype.reverse=function(){return this},we.prototype.indexOf=function(u){return oe(this._value,u)?0:-1},we.prototype.lastIndexOf=function(u){return oe(this._value,u)?this.size:-1},we.prototype.__iterate=function(u,d){for(var y=0;y<this.size;y++)if(u(this._value,y,this)===!1)return y+1;return y},we.prototype.__iterator=function(u,d){var y=this,x=0;return new Z(function(){return x<y.size?Q(u,x++,y._value):U()})},we.prototype.equals=function(u){return u instanceof we?oe(this._value,u._value):$n(u)};var Pi;function Ri(u,d){if(!u)throw new Error(d)}r(ae,kt);function ae(u,d,y){if(!(this instanceof ae))return new ae(u,d,y);if(Ri(y!==0,"Cannot step a Range by 0"),u=u||0,d===void 0&&(d=1/0),y=y===void 0?1:Math.abs(y),d<u&&(y=-y),this._start=u,this._end=d,this._step=y,this.size=Math.max(0,Math.ceil((d-u)/y-1)+1),this.size===0){if(Li)return Li;Li=this}}ae.prototype.toString=function(){return this.size===0?"Range []":"Range [ "+this._start+"..."+this._end+(this._step!==1?" by "+this._step:"")+" ]"},ae.prototype.get=function(u,d){return this.has(u)?this._start+tt(this,u)*this._step:d},ae.prototype.includes=function(u){var d=(u-this._start)/this._step;return d>=0&&d<this.size&&d===Math.floor(d)},ae.prototype.slice=function(u,d){return xt(u,d,this.size)?this:(u=yt(u,this.size),d=ht(d,this.size),d<=u?new ae(0,0):new ae(this.get(u,this._end),this.get(d,this._end),this._step))},ae.prototype.indexOf=function(u){var d=u-this._start;if(d%this._step===0){var y=d/this._step;if(y>=0&&y<this.size)return y}return-1},ae.prototype.lastIndexOf=function(u){return this.indexOf(u)},ae.prototype.__iterate=function(u,d){for(var y=this.size-1,x=this._step,b=d?this._start+y*x:this._start,A=0;A<=y;A++){if(u(b,A,this)===!1)return A+1;b+=d?-x:x}return A},ae.prototype.__iterator=function(u,d){var y=this.size-1,x=this._step,b=d?this._start+y*x:this._start,A=0;return new Z(function(){var T=b;return b+=d?-x:x,A>y?U():Q(u,A++,T)})},ae.prototype.equals=function(u){return u instanceof ae?this._start===u._start&&this._end===u._end&&this._step===u._step:$n(this,u)};var Li;r(Ir,i);function Ir(){throw TypeError("Abstract")}r(oi,Ir);function oi(){}r(ai,Ir);function ai(){}r(Fi,Ir);function Fi(){}Ir.Keyed=oi,Ir.Indexed=ai,Ir.Set=Fi;var Ni=typeof Math.imul=="function"&&Math.imul(4294967295,2)===-2?Math.imul:function(d,y){d=d|0,y=y|0;var x=d&65535,b=y&65535;return x*b+((d>>>16)*b+x*(y>>>16)<<16>>>0)|0};function Fs(u){return u>>>1&1073741824|u&3221225471}function $e(u){if(u===!1||u===null||u===void 0||typeof u.valueOf=="function"&&(u=u.valueOf(),u===!1||u===null||u===void 0))return 0;if(u===!0)return 1;var d=typeof u;if(d==="number"){if(u!==u||u===1/0)return 0;var y=u|0;for(y!==u&&(y^=u*4294967295);u>4294967295;)u/=4294967295,y^=u;return Fs(y)}if(d==="string")return u.length>ot?Th(u):jo(u);if(typeof u.hashCode=="function")return u.hashCode();if(d==="object")return _u(u);if(typeof u.toString=="function")return jo(u.toString());throw new Error("Value type "+d+" cannot be hashed.")}function Th(u){var d=qt[u];return d===void 0&&(d=jo(u),jt===Mt&&(jt=0,qt={}),jt++,qt[u]=d),d}function jo(u){for(var d=0,y=0;y<u.length;y++)d=31*d+u.charCodeAt(y)|0;return Fs(d)}function _u(u){var d;if(Do&&(d=Bo.get(u),d!==void 0)||(d=u[G],d!==void 0)||!bu&&(d=u.propertyIsEnumerable&&u.propertyIsEnumerable[G],d!==void 0||(d=Ch(u),d!==void 0)))return d;if(d=++I,I&1073741824&&(I=0),Do)Bo.set(u,d);else{if(Vo!==void 0&&Vo(u)===!1)throw new Error("Non-extensible objects are not allowed as keys.");if(bu)Object.defineProperty(u,G,{enumerable:!1,configurable:!1,writable:!1,value:d});else if(u.propertyIsEnumerable!==void 0&&u.propertyIsEnumerable===u.constructor.prototype.propertyIsEnumerable)u.propertyIsEnumerable=function(){return this.constructor.prototype.propertyIsEnumerable.apply(this,arguments)},u.propertyIsEnumerable[G]=d;else if(u.nodeType!==void 0)u[G]=d;else throw new Error("Unable to set a non-enumerable property on object.")}return d}var Vo=Object.isExtensible,bu=function(){try{return Object.defineProperty({},"@",{}),!0}catch{return!1}}();function Ch(u){if(u&&u.nodeType>0)switch(u.nodeType){case 1:return u.uniqueID;case 9:return u.documentElement&&u.documentElement.uniqueID}}var Do=typeof WeakMap=="function",Bo;Do&&(Bo=new WeakMap);var I=0,G="__immutablehash__";typeof Symbol=="function"&&(G=Symbol(G));var ot=16,Mt=255,jt=0,qt={};function At(u){Ri(u!==1/0,"Cannot perform this action with an infinite size.")}r(nt,oi);function nt(u){return u==null?en():Oe(u)&&!g(u)?u:en().withMutations(function(d){var y=s(u);At(y.size),y.forEach(function(x,b){return d.set(b,x)})})}nt.of=function(){var u=e.call(arguments,0);return en().withMutations(function(d){for(var y=0;y<u.length;y+=2){if(y+1>=u.length)throw new Error("Missing value for key: "+u[y]);d.set(u[y],u[y+1])}})},nt.prototype.toString=function(){return this.__toString("Map {","}")},nt.prototype.get=function(u,d){return this._root?this._root.get(0,void 0,u,d):d},nt.prototype.set=function(u,d){return vy(this,u,d)},nt.prototype.setIn=function(u,d){return this.updateIn(u,E,function(){return d})},nt.prototype.remove=function(u){return vy(this,u,E)},nt.prototype.deleteIn=function(u){return this.updateIn(u,function(){return E})},nt.prototype.update=function(u,d,y){return arguments.length===1?u(this):this.updateIn([u],d,y)},nt.prototype.updateIn=function(u,d,y){y||(y=d,d=void 0);var x=Sy(this,Hy(u),d,y);return x===E?void 0:x},nt.prototype.clear=function(){return this.size===0?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):en()},nt.prototype.merge=function(){return wu(this,void 0,arguments)},nt.prototype.mergeWith=function(u){var d=e.call(arguments,1);return wu(this,u,d)},nt.prototype.mergeIn=function(u){var d=e.call(arguments,1);return this.updateIn(u,en(),function(y){return typeof y.merge=="function"?y.merge.apply(y,d):d[d.length-1]})},nt.prototype.mergeDeep=function(){return wu(this,_y,arguments)},nt.prototype.mergeDeepWith=function(u){var d=e.call(arguments,1);return wu(this,by(u),d)},nt.prototype.mergeDeepIn=function(u){var d=e.call(arguments,1);return this.updateIn(u,en(),function(y){return typeof y.mergeDeep=="function"?y.mergeDeep.apply(y,d):d[d.length-1]})},nt.prototype.sort=function(u){return ye(Bs(this,u))},nt.prototype.sortBy=function(u,d){return ye(Bs(this,d,u))},nt.prototype.withMutations=function(u){var d=this.asMutable();return u(d),d.wasAltered()?d.__ensureOwner(this.__ownerID):this},nt.prototype.asMutable=function(){return this.__ownerID?this:this.__ensureOwner(new X)},nt.prototype.asImmutable=function(){return this.__ensureOwner()},nt.prototype.wasAltered=function(){return this.__altered},nt.prototype.__iterator=function(u,d){return new qo(this,u,d)},nt.prototype.__iterate=function(u,d){var y=this,x=0;return this._root&&this._root.iterate(function(b){return x++,u(b[1],b[0],y)},d),x},nt.prototype.__ensureOwner=function(u){return u===this.__ownerID?this:u?Ih(this.size,this._root,u,this.__hash):(this.__ownerID=u,this.__altered=!1,this)};function Oe(u){return!!(u&&u[ue])}nt.isMap=Oe;var ue="@@__IMMUTABLE_MAP__@@",mt=nt.prototype;mt[ue]=!0,mt[S]=mt.remove,mt.removeIn=mt.deleteIn;function Pe(u,d){this.ownerID=u,this.entries=d}Pe.prototype.get=function(u,d,y,x){for(var b=this.entries,A=0,T=b.length;A<T;A++)if(oe(y,b[A][0]))return b[A][1];return x},Pe.prototype.update=function(u,d,y,x,b,A,T){for(var P=b===E,N=this.entries,V=0,q=N.length;V<q&&!oe(x,N[V][0]);V++);var it=V<q;if(it?N[V][1]===b:P)return this;if(L(T),(P||!it)&&L(A),!(P&&N.length===1)){if(!it&&!P&&N.length>=dE)return uE(u,N,x,b);var dt=u&&u===this.ownerID,Tt=dt?N:J(N);return it?P?V===q-1?Tt.pop():Tt[V]=Tt.pop():Tt[V]=[x,b]:Tt.push([x,b]),dt?(this.entries=Tt,this):new Pe(u,Tt)}};function pr(u,d,y){this.ownerID=u,this.bitmap=d,this.nodes=y}pr.prototype.get=function(u,d,y,x){d===void 0&&(d=$e(y));var b=1<<((u===0?d:d>>>u)&O),A=this.bitmap;return(A&b)===0?x:this.nodes[Ey(A&b-1)].get(u+M,d,y,x)},pr.prototype.update=function(u,d,y,x,b,A,T){y===void 0&&(y=$e(x));var P=(d===0?y:y>>>d)&O,N=1<<P,V=this.bitmap,q=(V&N)!==0;if(!q&&b===E)return this;var it=Ey(V&N-1),dt=this.nodes,Tt=q?dt[it]:void 0,Pt=kh(Tt,u,d+M,y,x,b,A,T);if(Pt===Tt)return this;if(!q&&Pt&&dt.length>=pE)return cE(u,dt,V,P,Pt);if(q&&!Pt&&dt.length===2&&xy(dt[it^1]))return dt[it^1];if(q&&Pt&&dt.length===1&&xy(Pt))return Pt;var ce=u&&u===this.ownerID,rn=q?Pt?V:V^N:V|N,En=q?Pt?My(dt,it,Pt,ce):fE(dt,it,ce):hE(dt,it,Pt,ce);return ce?(this.bitmap=rn,this.nodes=En,this):new pr(u,rn,En)};function gr(u,d,y){this.ownerID=u,this.count=d,this.nodes=y}gr.prototype.get=function(u,d,y,x){d===void 0&&(d=$e(y));var b=(u===0?d:d>>>u)&O,A=this.nodes[b];return A?A.get(u+M,d,y,x):x},gr.prototype.update=function(u,d,y,x,b,A,T){y===void 0&&(y=$e(x));var P=(d===0?y:y>>>d)&O,N=b===E,V=this.nodes,q=V[P];if(N&&!q)return this;var it=kh(q,u,d+M,y,x,b,A,T);if(it===q)return this;var dt=this.count;if(!q)dt++;else if(!it&&(dt--,dt<gE))return lE(u,V,dt,P);var Tt=u&&u===this.ownerID,Pt=My(V,P,it,Tt);return Tt?(this.count=dt,this.nodes=Pt,this):new gr(u,dt,Pt)};function me(u,d,y){this.ownerID=u,this.keyHash=d,this.entries=y}me.prototype.get=function(u,d,y,x){for(var b=this.entries,A=0,T=b.length;A<T;A++)if(oe(y,b[A][0]))return b[A][1];return x},me.prototype.update=function(u,d,y,x,b,A,T){y===void 0&&(y=$e(x));var P=b===E;if(y!==this.keyHash)return P?this:(L(T),L(A),Ph(this,u,d,y,[x,b]));for(var N=this.entries,V=0,q=N.length;V<q&&!oe(x,N[V][0]);V++);var it=V<q;if(it?N[V][1]===b:P)return this;if(L(T),(P||!it)&&L(A),P&&q===2)return new mr(u,this.keyHash,N[V^1]);var dt=u&&u===this.ownerID,Tt=dt?N:J(N);return it?P?V===q-1?Tt.pop():Tt[V]=Tt.pop():Tt[V]=[x,b]:Tt.push([x,b]),dt?(this.entries=Tt,this):new me(u,this.keyHash,Tt)};function mr(u,d,y){this.ownerID=u,this.keyHash=d,this.entry=y}mr.prototype.get=function(u,d,y,x){return oe(y,this.entry[0])?this.entry[1]:x},mr.prototype.update=function(u,d,y,x,b,A,T){var P=b===E,N=oe(x,this.entry[0]);if(N?b===this.entry[1]:P)return this;if(L(T),P){L(A);return}return N?u&&u===this.ownerID?(this.entry[1]=b,this):new mr(u,this.keyHash,[x,b]):(L(A),Ph(this,u,d,$e(x),[x,b]))},Pe.prototype.iterate=me.prototype.iterate=function(u,d){for(var y=this.entries,x=0,b=y.length-1;x<=b;x++)if(u(y[d?b-x:x])===!1)return!1},pr.prototype.iterate=gr.prototype.iterate=function(u,d){for(var y=this.nodes,x=0,b=y.length-1;x<=b;x++){var A=y[d?b-x:x];if(A&&A.iterate(u,d)===!1)return!1}},mr.prototype.iterate=function(u,d){return u(this.entry)},r(qo,Z);function qo(u,d,y){this._type=d,this._reverse=y,this._stack=u._root&&my(u._root)}qo.prototype.next=function(){for(var u=this._type,d=this._stack;d;){var y=d.node,x=d.index++,b;if(y.entry){if(x===0)return $o(u,y.entry)}else if(y.entries){if(b=y.entries.length-1,x<=b)return $o(u,y.entries[this._reverse?b-x:x])}else if(b=y.nodes.length-1,x<=b){var A=y.nodes[this._reverse?b-x:x];if(A){if(A.entry)return $o(u,A.entry);d=this._stack=my(A,d)}continue}d=this._stack=this._stack.__prev}return U()};function $o(u,d){return Q(u,d[0],d[1])}function my(u,d){return{node:u,index:0,__prev:d}}function Ih(u,d,y,x){var b=Object.create(mt);return b.size=u,b._root=d,b.__ownerID=y,b.__hash=x,b.__altered=!1,b}var yy;function en(){return yy||(yy=Ih(0))}function vy(u,d,y){var x,b;if(u._root){var A=k(z),T=k(R);if(x=kh(u._root,u.__ownerID,0,void 0,d,y,A,T),!T.value)return u;b=u.size+(A.value?y===E?-1:1:0)}else{if(y===E)return u;b=1,x=new Pe(u.__ownerID,[[d,y]])}return u.__ownerID?(u.size=b,u._root=x,u.__hash=void 0,u.__altered=!0,u):x?Ih(b,x):en()}function kh(u,d,y,x,b,A,T,P){return u?u.update(d,y,x,b,A,T,P):A===E?u:(L(P),L(T),new mr(d,x,[b,A]))}function xy(u){return u.constructor===mr||u.constructor===me}function Ph(u,d,y,x,b){if(u.keyHash===x)return new me(d,x,[u.entry,b]);var A=(y===0?u.keyHash:u.keyHash>>>y)&O,T=(y===0?x:x>>>y)&O,P,N=A===T?[Ph(u,d,y+M,x,b)]:(P=new mr(d,x,b),A<T?[u,P]:[P,u]);return new pr(d,1<<A|1<<T,N)}function uE(u,d,y,x){u||(u=new X);for(var b=new mr(u,$e(y),[y,x]),A=0;A<d.length;A++){var T=d[A];b=b.update(u,0,void 0,T[0],T[1])}return b}function lE(u,d,y,x){for(var b=0,A=0,T=new Array(y),P=0,N=1,V=d.length;P<V;P++,N<<=1){var q=d[P];q!==void 0&&P!==x&&(b|=N,T[A++]=q)}return new pr(u,b,T)}function cE(u,d,y,x,b){for(var A=0,T=new Array(C),P=0;y!==0;P++,y>>>=1)T[P]=y&1?d[A++]:void 0;return T[x]=b,new gr(u,A+1,T)}function wu(u,d,y){for(var x=[],b=0;b<y.length;b++){var A=y[b],T=s(A);l(A)||(T=T.map(function(P){return Cr(P)})),x.push(T)}return wy(u,d,x)}function _y(u,d,y){return u&&u.mergeDeep&&l(d)?u.mergeDeep(d):oe(u,d)?u:d}function by(u){return function(d,y,x){if(d&&d.mergeDeepWith&&l(y))return d.mergeDeepWith(u,y);var b=u(d,y,x);return oe(d,b)?d:b}}function wy(u,d,y){return y=y.filter(function(x){return x.size!==0}),y.length===0?u:u.size===0&&!u.__ownerID&&y.length===1?u.constructor(y[0]):u.withMutations(function(x){for(var b=d?function(T,P){x.update(P,E,function(N){return N===E?T:d(N,T,P)})}:function(T,P){x.set(P,T)},A=0;A<y.length;A++)y[A].forEach(b)})}function Sy(u,d,y,x){var b=u===E,A=d.next();if(A.done){var T=b?y:u,P=x(T);return P===T?u:P}Ri(b||u&&u.set,"invalid keyPath");var N=A.value,V=b?E:u.get(N,E),q=Sy(V,d,y,x);return q===V?u:q===E?u.remove(N):(b?en():u).set(N,q)}function Ey(u){return u=u-(u>>1&1431655765),u=(u&858993459)+(u>>2&858993459),u=u+(u>>4)&252645135,u=u+(u>>8),u=u+(u>>16),u&127}function My(u,d,y,x){var b=x?u:J(u);return b[d]=y,b}function hE(u,d,y,x){var b=u.length+1;if(x&&d+1===b)return u[d]=y,u;for(var A=new Array(b),T=0,P=0;P<b;P++)P===d?(A[P]=y,T=-1):A[P]=u[P+T];return A}function fE(u,d,y){var x=u.length-1;if(y&&d===x)return u.pop(),u;for(var b=new Array(x),A=0,T=0;T<x;T++)T===d&&(A=1),b[T]=u[T+A];return b}var dE=C/4,pE=C/2,gE=C/4;r(ie,ai);function ie(u){var d=Rh();if(u==null)return d;if(Ay(u))return u;var y=o(u),x=y.size;return x===0?d:(At(x),x>0&&x<C?Go(0,x,M,null,new ui(y.toArray())):d.withMutations(function(b){b.setSize(x),y.forEach(function(A,T){return b.set(T,A)})}))}ie.of=function(){return this(arguments)},ie.prototype.toString=function(){return this.__toString("List [","]")},ie.prototype.get=function(u,d){if(u=tt(this,u),u>=0&&u<this.size){u+=this._origin;var y=Cy(this,u);return y&&y.array[u&O]}return d},ie.prototype.set=function(u,d){return mE(this,u,d)},ie.prototype.remove=function(u){return this.has(u)?u===0?this.shift():u===this.size-1?this.pop():this.splice(u,1):this},ie.prototype.insert=function(u,d){return this.splice(u,0,d)},ie.prototype.clear=function(){return this.size===0?this:this.__ownerID?(this.size=this._origin=this._capacity=0,this._level=M,this._root=this._tail=null,this.__hash=void 0,this.__altered=!0,this):Rh()},ie.prototype.push=function(){var u=arguments,d=this.size;return this.withMutations(function(y){li(y,0,d+u.length);for(var x=0;x<u.length;x++)y.set(d+x,u[x])})},ie.prototype.pop=function(){return li(this,0,-1)},ie.prototype.unshift=function(){var u=arguments;return this.withMutations(function(d){li(d,-u.length);for(var y=0;y<u.length;y++)d.set(y,u[y])})},ie.prototype.shift=function(){return li(this,1)},ie.prototype.merge=function(){return Su(this,void 0,arguments)},ie.prototype.mergeWith=function(u){var d=e.call(arguments,1);return Su(this,u,d)},ie.prototype.mergeDeep=function(){return Su(this,_y,arguments)},ie.prototype.mergeDeepWith=function(u){var d=e.call(arguments,1);return Su(this,by(u),d)},ie.prototype.setSize=function(u){return li(this,0,u)},ie.prototype.slice=function(u,d){var y=this.size;return xt(u,d,y)?this:li(this,yt(u,y),ht(d,y))},ie.prototype.__iterator=function(u,d){var y=0,x=zy(this,d);return new Z(function(){var b=x();return b===Ho?U():Q(u,y++,b)})},ie.prototype.__iterate=function(u,d){for(var y=0,x=zy(this,d),b;(b=x())!==Ho&&u(b,y++,this)!==!1;);return y},ie.prototype.__ensureOwner=function(u){return u===this.__ownerID?this:u?Go(this._origin,this._capacity,this._level,this._root,this._tail,u,this.__hash):(this.__ownerID=u,this)};function Ay(u){return!!(u&&u[Oy])}ie.isList=Ay;var Oy="@@__IMMUTABLE_LIST__@@",Xe=ie.prototype;Xe[Oy]=!0,Xe[S]=Xe.remove,Xe.setIn=mt.setIn,Xe.deleteIn=Xe.removeIn=mt.removeIn,Xe.update=mt.update,Xe.updateIn=mt.updateIn,Xe.mergeIn=mt.mergeIn,Xe.mergeDeepIn=mt.mergeDeepIn,Xe.withMutations=mt.withMutations,Xe.asMutable=mt.asMutable,Xe.asImmutable=mt.asImmutable,Xe.wasAltered=mt.wasAltered;function ui(u,d){this.array=u,this.ownerID=d}ui.prototype.removeBefore=function(u,d,y){if(y===d?1<<d:this.array.length===0)return this;var x=y>>>d&O;if(x>=this.array.length)return new ui([],u);var b=x===0,A;if(d>0){var T=this.array[x];if(A=T&&T.removeBefore(u,d-M,y),A===T&&b)return this}if(b&&!A)return this;var P=Ns(this,u);if(!b)for(var N=0;N<x;N++)P.array[N]=void 0;return A&&(P.array[x]=A),P},ui.prototype.removeAfter=function(u,d,y){if(y===(d?1<<d:0)||this.array.length===0)return this;var x=y-1>>>d&O;if(x>=this.array.length)return this;var b;if(d>0){var A=this.array[x];if(b=A&&A.removeAfter(u,d-M,y),b===A&&x===this.array.length-1)return this}var T=Ns(this,u);return T.array.splice(x+1),b&&(T.array[x]=b),T};var Ho={};function zy(u,d){var y=u._origin,x=u._capacity,b=Wo(x),A=u._tail;return T(u._root,u._level,0);function T(V,q,it){return q===0?P(V,it):N(V,q,it)}function P(V,q){var it=q===b?A&&A.array:V&&V.array,dt=q>y?0:y-q,Tt=x-q;return Tt>C&&(Tt=C),function(){if(dt===Tt)return Ho;var Pt=d?--Tt:dt++;return it&&it[Pt]}}function N(V,q,it){var dt,Tt=V&&V.array,Pt=it>y?0:y-it>>q,ce=(x-it>>q)+1;return ce>C&&(ce=C),function(){do{if(dt){var rn=dt();if(rn!==Ho)return rn;dt=null}if(Pt===ce)return Ho;var En=d?--ce:Pt++;dt=T(Tt&&Tt[En],q-M,it+(En<<q))}while(!0)}}}function Go(u,d,y,x,b,A,T){var P=Object.create(Xe);return P.size=d-u,P._origin=u,P._capacity=d,P._level=y,P._root=x,P._tail=b,P.__ownerID=A,P.__hash=T,P.__altered=!1,P}var Ty;function Rh(){return Ty||(Ty=Go(0,0,M))}function mE(u,d,y){if(d=tt(u,d),d!==d)return u;if(d>=u.size||d<0)return u.withMutations(function(T){d<0?li(T,d).set(0,y):li(T,0,d+1).set(d,y)});d+=u._origin;var x=u._tail,b=u._root,A=k(R);return d>=Wo(u._capacity)?x=Lh(x,u.__ownerID,0,d,y,A):b=Lh(b,u.__ownerID,u._level,d,y,A),A.value?u.__ownerID?(u._root=b,u._tail=x,u.__hash=void 0,u.__altered=!0,u):Go(u._origin,u._capacity,u._level,b,x):u}function Lh(u,d,y,x,b,A){var T=x>>>y&O,P=u&&T<u.array.length;if(!P&&b===void 0)return u;var N;if(y>0){var V=u&&u.array[T],q=Lh(V,d,y-M,x,b,A);return q===V?u:(N=Ns(u,d),N.array[T]=q,N)}return P&&u.array[T]===b?u:(L(A),N=Ns(u,d),b===void 0&&T===N.array.length-1?N.array.pop():N.array[T]=b,N)}function Ns(u,d){return d&&u&&d===u.ownerID?u:new ui(u?u.array.slice():[],d)}function Cy(u,d){if(d>=Wo(u._capacity))return u._tail;if(d<1<<u._level+M){for(var y=u._root,x=u._level;y&&x>0;)y=y.array[d>>>x&O],x-=M;return y}}function li(u,d,y){d!==void 0&&(d=d|0),y!==void 0&&(y=y|0);var x=u.__ownerID||new X,b=u._origin,A=u._capacity,T=b+d,P=y===void 0?A:y<0?A+y:b+y;if(T===b&&P===A)return u;if(T>=P)return u.clear();for(var N=u._level,V=u._root,q=0;T+q<0;)V=new ui(V&&V.array.length?[void 0,V]:[],x),N+=M,q+=1<<N;q&&(T+=q,b+=q,P+=q,A+=q);for(var it=Wo(A),dt=Wo(P);dt>=1<<N+M;)V=new ui(V&&V.array.length?[V]:[],x),N+=M;var Tt=u._tail,Pt=dt<it?Cy(u,P-1):dt>it?new ui([],x):Tt;if(Tt&&dt>it&&T<A&&Tt.array.length){V=Ns(V,x);for(var ce=V,rn=N;rn>M;rn-=M){var En=it>>>rn&O;ce=ce.array[En]=Ns(ce.array[En],x)}ce.array[it>>>M&O]=Tt}if(P<A&&(Pt=Pt&&Pt.removeAfter(x,0,P)),T>=dt)T-=dt,P-=dt,N=M,V=null,Pt=Pt&&Pt.removeBefore(x,0,T);else if(T>b||dt<it){for(q=0;V;){var Cu=T>>>N&O;if(Cu!==dt>>>N&O)break;Cu&&(q+=(1<<N)*Cu),N-=M,V=V.array[Cu]}V&&T>b&&(V=V.removeBefore(x,N,T-q)),V&&dt<it&&(V=V.removeAfter(x,N,dt-q)),q&&(T-=q,P-=q)}return u.__ownerID?(u.size=P-T,u._origin=T,u._capacity=P,u._level=N,u._root=V,u._tail=Pt,u.__hash=void 0,u.__altered=!0,u):Go(T,P,N,V,Pt)}function Su(u,d,y){for(var x=[],b=0,A=0;A<y.length;A++){var T=y[A],P=o(T);P.size>b&&(b=P.size),l(T)||(P=P.map(function(N){return Cr(N)})),x.push(P)}return b>u.size&&(u=u.setSize(b)),wy(u,d,x)}function Wo(u){return u<C?0:u-1>>>M<<M}r(ye,nt);function ye(u){return u==null?Eu():Iy(u)?u:Eu().withMutations(function(d){var y=s(u);At(y.size),y.forEach(function(x,b){return d.set(b,x)})})}ye.of=function(){return this(arguments)},ye.prototype.toString=function(){return this.__toString("OrderedMap {","}")},ye.prototype.get=function(u,d){var y=this._map.get(u);return y!==void 0?this._list.get(y)[1]:d},ye.prototype.clear=function(){return this.size===0?this:this.__ownerID?(this.size=0,this._map.clear(),this._list.clear(),this):Eu()},ye.prototype.set=function(u,d){return Py(this,u,d)},ye.prototype.remove=function(u){return Py(this,u,E)},ye.prototype.wasAltered=function(){return this._map.wasAltered()||this._list.wasAltered()},ye.prototype.__iterate=function(u,d){var y=this;return this._list.__iterate(function(x){return x&&u(x[1],x[0],y)},d)},ye.prototype.__iterator=function(u,d){return this._list.fromEntrySeq().__iterator(u,d)},ye.prototype.__ensureOwner=function(u){if(u===this.__ownerID)return this;var d=this._map.__ensureOwner(u),y=this._list.__ensureOwner(u);return u?Fh(d,y,u,this.__hash):(this.__ownerID=u,this._map=d,this._list=y,this)};function Iy(u){return Oe(u)&&g(u)}ye.isOrderedMap=Iy,ye.prototype[_]=!0,ye.prototype[S]=ye.prototype.remove;function Fh(u,d,y,x){var b=Object.create(ye.prototype);return b.size=u?u.size:0,b._map=u,b._list=d,b.__ownerID=y,b.__hash=x,b}var ky;function Eu(){return ky||(ky=Fh(en(),Rh()))}function Py(u,d,y){var x=u._map,b=u._list,A=x.get(d),T=A!==void 0,P,N;if(y===E){if(!T)return u;b.size>=C&&b.size>=x.size*2?(N=b.filter(function(V,q){return V!==void 0&&A!==q}),P=N.toKeyedSeq().map(function(V){return V[0]}).flip().toMap(),u.__ownerID&&(P.__ownerID=N.__ownerID=u.__ownerID)):(P=x.remove(d),N=A===b.size-1?b.pop():b.set(A,void 0))}else if(T){if(y===b.get(A)[1])return u;P=x,N=b.set(A,[d,y])}else P=x.set(d,b.size),N=b.set(b.size,[d,y]);return u.__ownerID?(u.size=P.size,u._map=P,u._list=N,u.__hash=void 0,u):Fh(P,N)}r(kr,Bt);function kr(u,d){this._iter=u,this._useKeys=d,this.size=u.size}kr.prototype.get=function(u,d){return this._iter.get(u,d)},kr.prototype.has=function(u){return this._iter.has(u)},kr.prototype.valueSeq=function(){return this._iter.valueSeq()},kr.prototype.reverse=function(){var u=this,d=Nh(this,!0);return this._useKeys||(d.valueSeq=function(){return u._iter.toSeq().reverse()}),d},kr.prototype.map=function(u,d){var y=this,x=Ly(this,u,d);return this._useKeys||(x.valueSeq=function(){return y._iter.toSeq().map(u,d)}),x},kr.prototype.__iterate=function(u,d){var y=this,x;return this._iter.__iterate(this._useKeys?function(b,A){return u(b,A,y)}:(x=d?By(this):0,function(b){return u(b,d?--x:x++,y)}),d)},kr.prototype.__iterator=function(u,d){if(this._useKeys)return this._iter.__iterator(u,d);var y=this._iter.__iterator(j,d),x=d?By(this):0;return new Z(function(){var b=y.next();return b.done?b:Q(u,d?--x:x++,b.value,b)})},kr.prototype[_]=!0,r(js,kt);function js(u){this._iter=u,this.size=u.size}js.prototype.includes=function(u){return this._iter.includes(u)},js.prototype.__iterate=function(u,d){var y=this,x=0;return this._iter.__iterate(function(b){return u(b,x++,y)},d)},js.prototype.__iterator=function(u,d){var y=this._iter.__iterator(j,d),x=0;return new Z(function(){var b=y.next();return b.done?b:Q(u,x++,b.value,b)})},r(Vs,Ct);function Vs(u){this._iter=u,this.size=u.size}Vs.prototype.has=function(u){return this._iter.includes(u)},Vs.prototype.__iterate=function(u,d){var y=this;return this._iter.__iterate(function(x){return u(x,x,y)},d)},Vs.prototype.__iterator=function(u,d){var y=this._iter.__iterator(j,d);return new Z(function(){var x=y.next();return x.done?x:Q(u,x.value,x.value,x)})},r(Ds,Bt);function Ds(u){this._iter=u,this.size=u.size}Ds.prototype.entrySeq=function(){return this._iter.toSeq()},Ds.prototype.__iterate=function(u,d){var y=this;return this._iter.__iterate(function(x){if(x){Dy(x);var b=l(x);return u(b?x.get(1):x[1],b?x.get(0):x[0],y)}},d)},Ds.prototype.__iterator=function(u,d){var y=this._iter.__iterator(j,d);return new Z(function(){for(;;){var x=y.next();if(x.done)return x;var b=x.value;if(b){Dy(b);var A=l(b);return Q(u,A?b.get(0):b[0],A?b.get(1):b[1],x)}}})},js.prototype.cacheResult=kr.prototype.cacheResult=Vs.prototype.cacheResult=Ds.prototype.cacheResult=Dh;function Ry(u){var d=bn(u);return d._iter=u,d.size=u.size,d.flip=function(){return u},d.reverse=function(){var y=u.reverse.apply(this);return y.flip=function(){return u.reverse()},y},d.has=function(y){return u.includes(y)},d.includes=function(y){return u.has(y)},d.cacheResult=Dh,d.__iterateUncached=function(y,x){var b=this;return u.__iterate(function(A,T){return y(T,A,b)!==!1},x)},d.__iteratorUncached=function(y,x){if(y===W){var b=u.__iterator(y,x);return new Z(function(){var A=b.next();if(!A.done){var T=A.value[0];A.value[0]=A.value[1],A.value[1]=T}return A})}return u.__iterator(y===j?St:j,x)},d}function Ly(u,d,y){var x=bn(u);return x.size=u.size,x.has=function(b){return u.has(b)},x.get=function(b,A){var T=u.get(b,E);return T===E?A:d.call(y,T,b,u)},x.__iterateUncached=function(b,A){var T=this;return u.__iterate(function(P,N,V){return b(d.call(y,P,N,V),N,T)!==!1},A)},x.__iteratorUncached=function(b,A){var T=u.__iterator(W,A);return new Z(function(){var P=T.next();if(P.done)return P;var N=P.value,V=N[0];return Q(b,V,d.call(y,N[1],V,u),P)})},x}function Nh(u,d){var y=bn(u);return y._iter=u,y.size=u.size,y.reverse=function(){return u},u.flip&&(y.flip=function(){var x=Ry(u);return x.reverse=function(){return u.flip()},x}),y.get=function(x,b){return u.get(d?x:-1-x,b)},y.has=function(x){return u.has(d?x:-1-x)},y.includes=function(x){return u.includes(x)},y.cacheResult=Dh,y.__iterate=function(x,b){var A=this;return u.__iterate(function(T,P){return x(T,P,A)},!b)},y.__iterator=function(x,b){return u.__iterator(x,!b)},y}function Fy(u,d,y,x){var b=bn(u);return x&&(b.has=function(A){var T=u.get(A,E);return T!==E&&!!d.call(y,T,A,u)},b.get=function(A,T){var P=u.get(A,E);return P!==E&&d.call(y,P,A,u)?P:T}),b.__iterateUncached=function(A,T){var P=this,N=0;return u.__iterate(function(V,q,it){if(d.call(y,V,q,it))return N++,A(V,x?q:N-1,P)},T),N},b.__iteratorUncached=function(A,T){var P=u.__iterator(W,T),N=0;return new Z(function(){for(;;){var V=P.next();if(V.done)return V;var q=V.value,it=q[0],dt=q[1];if(d.call(y,dt,it,u))return Q(A,x?it:N++,dt,V)}})},b}function yE(u,d,y){var x=nt().asMutable();return u.__iterate(function(b,A){x.update(d.call(y,b,A,u),0,function(T){return T+1})}),x.asImmutable()}function vE(u,d,y){var x=c(u),b=(g(u)?ye():nt()).asMutable();u.__iterate(function(T,P){b.update(d.call(y,T,P,u),function(N){return N=N||[],N.push(x?[P,T]:T),N})});var A=qy(u);return b.map(function(T){return Zt(u,A(T))})}function jh(u,d,y,x){var b=u.size;if(d!==void 0&&(d=d|0),y!==void 0&&(y===1/0?y=b:y=y|0),xt(d,y,b))return u;var A=yt(d,b),T=ht(y,b);if(A!==A||T!==T)return jh(u.toSeq().cacheResult(),d,y,x);var P=T-A,N;P===P&&(N=P<0?0:P);var V=bn(u);return V.size=N===0?N:u.size&&N||void 0,!x&&Le(u)&&N>=0&&(V.get=function(q,it){return q=tt(this,q),q>=0&&q<N?u.get(q+A,it):it}),V.__iterateUncached=function(q,it){var dt=this;if(N===0)return 0;if(it)return this.cacheResult().__iterate(q,it);var Tt=0,Pt=!0,ce=0;return u.__iterate(function(rn,En){if(!(Pt&&(Pt=Tt++<A)))return ce++,q(rn,x?En:ce-1,dt)!==!1&&ce!==N}),ce},V.__iteratorUncached=function(q,it){if(N!==0&&it)return this.cacheResult().__iterator(q,it);var dt=N!==0&&u.__iterator(q,it),Tt=0,Pt=0;return new Z(function(){for(;Tt++<A;)dt.next();if(++Pt>N)return U();var ce=dt.next();return x||q===j?ce:q===St?Q(q,Pt-1,void 0,ce):Q(q,Pt-1,ce.value[1],ce)})},V}function xE(u,d,y){var x=bn(u);return x.__iterateUncached=function(b,A){var T=this;if(A)return this.cacheResult().__iterate(b,A);var P=0;return u.__iterate(function(N,V,q){return d.call(y,N,V,q)&&++P&&b(N,V,T)}),P},x.__iteratorUncached=function(b,A){var T=this;if(A)return this.cacheResult().__iterator(b,A);var P=u.__iterator(W,A),N=!0;return new Z(function(){if(!N)return U();var V=P.next();if(V.done)return V;var q=V.value,it=q[0],dt=q[1];return d.call(y,dt,it,T)?b===W?V:Q(b,it,dt,V):(N=!1,U())})},x}function Ny(u,d,y,x){var b=bn(u);return b.__iterateUncached=function(A,T){var P=this;if(T)return this.cacheResult().__iterate(A,T);var N=!0,V=0;return u.__iterate(function(q,it,dt){if(!(N&&(N=d.call(y,q,it,dt))))return V++,A(q,x?it:V-1,P)}),V},b.__iteratorUncached=function(A,T){var P=this;if(T)return this.cacheResult().__iterator(A,T);var N=u.__iterator(W,T),V=!0,q=0;return new Z(function(){var it,dt,Tt;do{if(it=N.next(),it.done)return x||A===j?it:A===St?Q(A,q++,void 0,it):Q(A,q++,it.value[1],it);var Pt=it.value;dt=Pt[0],Tt=Pt[1],V&&(V=d.call(y,Tt,dt,P))}while(V);return A===W?it:Q(A,dt,Tt,it)})},b}function _E(u,d){var y=c(u),x=[u].concat(d).map(function(T){return l(T)?y&&(T=s(T)):T=y?_n(T):Bn(Array.isArray(T)?T:[T]),T}).filter(function(T){return T.size!==0});if(x.length===0)return u;if(x.length===1){var b=x[0];if(b===u||y&&c(b)||h(u)&&h(b))return b}var A=new gt(x);return y?A=A.toKeyedSeq():h(u)||(A=A.toSetSeq()),A=A.flatten(!0),A.size=x.reduce(function(T,P){if(T!==void 0){var N=P.size;if(N!==void 0)return T+N}},0),A}function jy(u,d,y){var x=bn(u);return x.__iterateUncached=function(b,A){var T=0,P=!1;function N(V,q){var it=this;V.__iterate(function(dt,Tt){return(!d||q<d)&&l(dt)?N(dt,q+1):b(dt,y?Tt:T++,it)===!1&&(P=!0),!P},A)}return N(u,0),T},x.__iteratorUncached=function(b,A){var T=u.__iterator(b,A),P=[],N=0;return new Z(function(){for(;T;){var V=T.next();if(V.done!==!1){T=P.pop();continue}var q=V.value;if(b===W&&(q=q[1]),(!d||P.length<d)&&l(q))P.push(T),T=q.__iterator(b,A);else return y?V:Q(b,N++,q,V)}return U()})},x}function bE(u,d,y){var x=qy(u);return u.toSeq().map(function(b,A){return x(d.call(y,b,A,u))}).flatten(!0)}function wE(u,d){var y=bn(u);return y.size=u.size&&u.size*2-1,y.__iterateUncached=function(x,b){var A=this,T=0;return u.__iterate(function(P,N){return(!T||x(d,T++,A)!==!1)&&x(P,T++,A)!==!1},b),T},y.__iteratorUncached=function(x,b){var A=u.__iterator(j,b),T=0,P;return new Z(function(){return(!P||T%2)&&(P=A.next(),P.done)?P:T%2?Q(x,T++,d):Q(x,T++,P.value,P)})},y}function Bs(u,d,y){d||(d=$y);var x=c(u),b=0,A=u.toSeq().map(function(T,P){return[P,T,b++,y?y(T,P,u):T]}).toArray();return A.sort(function(T,P){return d(T[3],P[3])||T[2]-P[2]}).forEach(x?function(T,P){A[P].length=2}:function(T,P){A[P]=T[1]}),x?Bt(A):h(u)?kt(A):Ct(A)}function Mu(u,d,y){if(d||(d=$y),y){var x=u.toSeq().map(function(b,A){return[b,y(b,A,u)]}).reduce(function(b,A){return Vy(d,b[1],A[1])?A:b});return x&&x[0]}else return u.reduce(function(b,A){return Vy(d,b,A)?A:b})}function Vy(u,d,y){var x=u(y,d);return x===0&&y!==d&&(y==null||y!==y)||x>0}function Vh(u,d,y){var x=bn(u);return x.size=new gt(y).map(function(b){return b.size}).min(),x.__iterate=function(b,A){for(var T=this.__iterator(j,A),P,N=0;!(P=T.next()).done&&b(P.value,N++,this)!==!1;);return N},x.__iteratorUncached=function(b,A){var T=y.map(function(V){return V=i(V),B(A?V.reverse():V)}),P=0,N=!1;return new Z(function(){var V;return N||(V=T.map(function(q){return q.next()}),N=V.some(function(q){return q.done})),N?U():Q(b,P++,d.apply(null,V.map(function(q){return q.value})))})},x}function Zt(u,d){return Le(u)?d:u.constructor(d)}function Dy(u){if(u!==Object(u))throw new TypeError("Expected [K, V] tuple: "+u)}function By(u){return At(u.size),at(u)}function qy(u){return c(u)?s:h(u)?o:a}function bn(u){return Object.create((c(u)?Bt:h(u)?kt:Ct).prototype)}function Dh(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):Ot.prototype.cacheResult.call(this)}function $y(u,d){return u>d?1:u<d?-1:0}function Hy(u){var d=B(u);if(!d){if(!H(u))throw new TypeError("Expected iterable or array-like: "+u);d=B(i(u))}return d}r(yr,oi);function yr(u,d){var y,x=function(T){if(T instanceof x)return T;if(!(this instanceof x))return new x(T);if(!y){y=!0;var P=Object.keys(u);SE(b,P),b.size=P.length,b._name=d,b._keys=P,b._defaultValues=u}this._map=nt(T)},b=x.prototype=Object.create(Fe);return b.constructor=x,x}yr.prototype.toString=function(){return this.__toString(Gy(this)+" {","}")},yr.prototype.has=function(u){return this._defaultValues.hasOwnProperty(u)},yr.prototype.get=function(u,d){if(!this.has(u))return d;var y=this._defaultValues[u];return this._map?this._map.get(u,y):y},yr.prototype.clear=function(){if(this.__ownerID)return this._map&&this._map.clear(),this;var u=this.constructor;return u._empty||(u._empty=Au(this,en()))},yr.prototype.set=function(u,d){if(!this.has(u))throw new Error('Cannot set unknown key "'+u+'" on '+Gy(this));if(this._map&&!this._map.has(u)){var y=this._defaultValues[u];if(d===y)return this}var x=this._map&&this._map.set(u,d);return this.__ownerID||x===this._map?this:Au(this,x)},yr.prototype.remove=function(u){if(!this.has(u))return this;var d=this._map&&this._map.remove(u);return this.__ownerID||d===this._map?this:Au(this,d)},yr.prototype.wasAltered=function(){return this._map.wasAltered()},yr.prototype.__iterator=function(u,d){var y=this;return s(this._defaultValues).map(function(x,b){return y.get(b)}).__iterator(u,d)},yr.prototype.__iterate=function(u,d){var y=this;return s(this._defaultValues).map(function(x,b){return y.get(b)}).__iterate(u,d)},yr.prototype.__ensureOwner=function(u){if(u===this.__ownerID)return this;var d=this._map&&this._map.__ensureOwner(u);return u?Au(this,d,u):(this.__ownerID=u,this._map=d,this)};var Fe=yr.prototype;Fe[S]=Fe.remove,Fe.deleteIn=Fe.removeIn=mt.removeIn,Fe.merge=mt.merge,Fe.mergeWith=mt.mergeWith,Fe.mergeIn=mt.mergeIn,Fe.mergeDeep=mt.mergeDeep,Fe.mergeDeepWith=mt.mergeDeepWith,Fe.mergeDeepIn=mt.mergeDeepIn,Fe.setIn=mt.setIn,Fe.update=mt.update,Fe.updateIn=mt.updateIn,Fe.withMutations=mt.withMutations,Fe.asMutable=mt.asMutable,Fe.asImmutable=mt.asImmutable;function Au(u,d,y){var x=Object.create(Object.getPrototypeOf(u));return x._map=d,x.__ownerID=y,x}function Gy(u){return u._name||u.constructor.name||"Record"}function SE(u,d){try{d.forEach(EE.bind(void 0,u))}catch{}}function EE(u,d){Object.defineProperty(u,d,{get:function(){return this.get(d)},set:function(y){Ri(this.__ownerID,"Cannot set on an immutable record."),this.set(d,y)}})}r(le,Fi);function le(u){return u==null?$h():Bh(u)&&!g(u)?u:$h().withMutations(function(d){var y=a(u);At(y.size),y.forEach(function(x){return d.add(x)})})}le.of=function(){return this(arguments)},le.fromKeys=function(u){return this(s(u).keySeq())},le.prototype.toString=function(){return this.__toString("Set {","}")},le.prototype.has=function(u){return this._map.has(u)},le.prototype.add=function(u){return qh(this,this._map.set(u,!0))},le.prototype.remove=function(u){return qh(this,this._map.remove(u))},le.prototype.clear=function(){return qh(this,this._map.clear())},le.prototype.union=function(){var u=e.call(arguments,0);return u=u.filter(function(d){return d.size!==0}),u.length===0?this:this.size===0&&!this.__ownerID&&u.length===1?this.constructor(u[0]):this.withMutations(function(d){for(var y=0;y<u.length;y++)a(u[y]).forEach(function(x){return d.add(x)})})},le.prototype.intersect=function(){var u=e.call(arguments,0);if(u.length===0)return this;u=u.map(function(y){return a(y)});var d=this;return this.withMutations(function(y){d.forEach(function(x){u.every(function(b){return b.includes(x)})||y.remove(x)})})},le.prototype.subtract=function(){var u=e.call(arguments,0);if(u.length===0)return this;u=u.map(function(y){return a(y)});var d=this;return this.withMutations(function(y){d.forEach(function(x){u.some(function(b){return b.includes(x)})&&y.remove(x)})})},le.prototype.merge=function(){return this.union.apply(this,arguments)},le.prototype.mergeWith=function(u){var d=e.call(arguments,1);return this.union.apply(this,d)},le.prototype.sort=function(u){return wn(Bs(this,u))},le.prototype.sortBy=function(u,d){return wn(Bs(this,d,u))},le.prototype.wasAltered=function(){return this._map.wasAltered()},le.prototype.__iterate=function(u,d){var y=this;return this._map.__iterate(function(x,b){return u(b,b,y)},d)},le.prototype.__iterator=function(u,d){return this._map.map(function(y,x){return x}).__iterator(u,d)},le.prototype.__ensureOwner=function(u){if(u===this.__ownerID)return this;var d=this._map.__ensureOwner(u);return u?this.__make(d,u):(this.__ownerID=u,this._map=d,this)};function Bh(u){return!!(u&&u[Wy])}le.isSet=Bh;var Wy="@@__IMMUTABLE_SET__@@",vr=le.prototype;vr[Wy]=!0,vr[S]=vr.remove,vr.mergeDeep=vr.merge,vr.mergeDeepWith=vr.mergeWith,vr.withMutations=mt.withMutations,vr.asMutable=mt.asMutable,vr.asImmutable=mt.asImmutable,vr.__empty=$h,vr.__make=Uy;function qh(u,d){return u.__ownerID?(u.size=d.size,u._map=d,u):d===u._map?u:d.size===0?u.__empty():u.__make(d)}function Uy(u,d){var y=Object.create(vr);return y.size=u?u.size:0,y._map=u,y.__ownerID=d,y}var Yy;function $h(){return Yy||(Yy=Uy(en()))}r(wn,le);function wn(u){return u==null?Hh():Xy(u)?u:Hh().withMutations(function(d){var y=a(u);At(y.size),y.forEach(function(x){return d.add(x)})})}wn.of=function(){return this(arguments)},wn.fromKeys=function(u){return this(s(u).keySeq())},wn.prototype.toString=function(){return this.__toString("OrderedSet {","}")};function Xy(u){return Bh(u)&&g(u)}wn.isOrderedSet=Xy;var Ou=wn.prototype;Ou[_]=!0,Ou.__empty=Hh,Ou.__make=Jy;function Jy(u,d){var y=Object.create(Ou);return y.size=u?u.size:0,y._map=u,y.__ownerID=d,y}var Zy;function Hh(){return Zy||(Zy=Jy(Eu()))}r(Se,ai);function Se(u){return u==null?Gh():Ky(u)?u:Gh().unshiftAll(u)}Se.of=function(){return this(arguments)},Se.prototype.toString=function(){return this.__toString("Stack [","]")},Se.prototype.get=function(u,d){var y=this._head;for(u=tt(this,u);y&&u--;)y=y.next;return y?y.value:d},Se.prototype.peek=function(){return this._head&&this._head.value},Se.prototype.push=function(){if(arguments.length===0)return this;for(var u=this.size+arguments.length,d=this._head,y=arguments.length-1;y>=0;y--)d={value:arguments[y],next:d};return this.__ownerID?(this.size=u,this._head=d,this.__hash=void 0,this.__altered=!0,this):Uo(u,d)},Se.prototype.pushAll=function(u){if(u=o(u),u.size===0)return this;At(u.size);var d=this.size,y=this._head;return u.reverse().forEach(function(x){d++,y={value:x,next:y}}),this.__ownerID?(this.size=d,this._head=y,this.__hash=void 0,this.__altered=!0,this):Uo(d,y)},Se.prototype.pop=function(){return this.slice(1)},Se.prototype.unshift=function(){return this.push.apply(this,arguments)},Se.prototype.unshiftAll=function(u){return this.pushAll(u)},Se.prototype.shift=function(){return this.pop.apply(this,arguments)},Se.prototype.clear=function(){return this.size===0?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Gh()},Se.prototype.slice=function(u,d){if(xt(u,d,this.size))return this;var y=yt(u,this.size),x=ht(d,this.size);if(x!==this.size)return ai.prototype.slice.call(this,u,d);for(var b=this.size-y,A=this._head;y--;)A=A.next;return this.__ownerID?(this.size=b,this._head=A,this.__hash=void 0,this.__altered=!0,this):Uo(b,A)},Se.prototype.__ensureOwner=function(u){return u===this.__ownerID?this:u?Uo(this.size,this._head,u,this.__hash):(this.__ownerID=u,this.__altered=!1,this)},Se.prototype.__iterate=function(u,d){if(d)return this.reverse().__iterate(u);for(var y=0,x=this._head;x&&u(x.value,y++,this)!==!1;)x=x.next;return y},Se.prototype.__iterator=function(u,d){if(d)return this.reverse().__iterator(u);var y=0,x=this._head;return new Z(function(){if(x){var b=x.value;return x=x.next,Q(u,y++,b)}return U()})};function Ky(u){return!!(u&&u[Qy])}Se.isStack=Ky;var Qy="@@__IMMUTABLE_STACK__@@",qs=Se.prototype;qs[Qy]=!0,qs.withMutations=mt.withMutations,qs.asMutable=mt.asMutable,qs.asImmutable=mt.asImmutable,qs.wasAltered=mt.wasAltered;function Uo(u,d,y,x){var b=Object.create(qs);return b.size=u,b._head=d,b.__ownerID=y,b.__hash=x,b.__altered=!1,b}var t0;function Gh(){return t0||(t0=Uo(0))}function Sn(u,d){var y=function(x){u.prototype[x]=d[x]};return Object.keys(d).forEach(y),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(d).forEach(y),u}i.Iterator=Z,Sn(i,{toArray:function(){At(this.size);var u=new Array(this.size||0);return this.valueSeq().__iterate(function(d,y){u[y]=d}),u},toIndexedSeq:function(){return new js(this)},toJS:function(){return this.toSeq().map(function(u){return u&&typeof u.toJS=="function"?u.toJS():u}).__toJS()},toJSON:function(){return this.toSeq().map(function(u){return u&&typeof u.toJSON=="function"?u.toJSON():u}).__toJS()},toKeyedSeq:function(){return new kr(this,!0)},toMap:function(){return nt(this.toKeyedSeq())},toObject:function(){At(this.size);var u={};return this.__iterate(function(d,y){u[y]=d}),u},toOrderedMap:function(){return ye(this.toKeyedSeq())},toOrderedSet:function(){return wn(c(this)?this.valueSeq():this)},toSet:function(){return le(c(this)?this.valueSeq():this)},toSetSeq:function(){return new Vs(this)},toSeq:function(){return h(this)?this.toIndexedSeq():c(this)?this.toKeyedSeq():this.toSetSeq()},toStack:function(){return Se(c(this)?this.valueSeq():this)},toList:function(){return ie(c(this)?this.valueSeq():this)},toString:function(){return"[Iterable]"},__toString:function(u,d){return this.size===0?u+d:u+" "+this.toSeq().map(this.__toStringMapper).join(", ")+" "+d},concat:function(){var u=e.call(arguments,0);return Zt(this,_E(this,u))},includes:function(u){return this.some(function(d){return oe(d,u)})},entries:function(){return this.__iterator(W)},every:function(u,d){At(this.size);var y=!0;return this.__iterate(function(x,b,A){if(!u.call(d,x,b,A))return y=!1,!1}),y},filter:function(u,d){return Zt(this,Fy(this,u,d,!0))},find:function(u,d,y){var x=this.findEntry(u,d);return x?x[1]:y},forEach:function(u,d){return At(this.size),this.__iterate(d?u.bind(d):u)},join:function(u){At(this.size),u=u!==void 0?""+u:",";var d="",y=!0;return this.__iterate(function(x){y?y=!1:d+=u,d+=x!=null?x.toString():""}),d},keys:function(){return this.__iterator(St)},map:function(u,d){return Zt(this,Ly(this,u,d))},reduce:function(u,d,y){At(this.size);var x,b;return arguments.length<2?b=!0:x=d,this.__iterate(function(A,T,P){b?(b=!1,x=A):x=u.call(y,x,A,T,P)}),x},reduceRight:function(u,d,y){var x=this.toKeyedSeq().reverse();return x.reduce.apply(x,arguments)},reverse:function(){return Zt(this,Nh(this,!0))},slice:function(u,d){return Zt(this,jh(this,u,d,!0))},some:function(u,d){return!this.every(Tu(u),d)},sort:function(u){return Zt(this,Bs(this,u))},values:function(){return this.__iterator(j)},butLast:function(){return this.slice(0,-1)},isEmpty:function(){return this.size!==void 0?this.size===0:!this.some(function(){return!0})},count:function(u,d){return at(u?this.toSeq().filter(u,d):this)},countBy:function(u,d){return yE(this,u,d)},equals:function(u){return $n(this,u)},entrySeq:function(){var u=this;if(u._cache)return new gt(u._cache);var d=u.toSeq().map(AE).toIndexedSeq();return d.fromEntrySeq=function(){return u.toSeq()},d},filterNot:function(u,d){return this.filter(Tu(u),d)},findEntry:function(u,d,y){var x=y;return this.__iterate(function(b,A,T){if(u.call(d,b,A,T))return x=[A,b],!1}),x},findKey:function(u,d){var y=this.findEntry(u,d);return y&&y[0]},findLast:function(u,d,y){return this.toKeyedSeq().reverse().find(u,d,y)},findLastEntry:function(u,d,y){return this.toKeyedSeq().reverse().findEntry(u,d,y)},findLastKey:function(u,d){return this.toKeyedSeq().reverse().findKey(u,d)},first:function(){return this.find(bt)},flatMap:function(u,d){return Zt(this,bE(this,u,d))},flatten:function(u){return Zt(this,jy(this,u,!0))},fromEntrySeq:function(){return new Ds(this)},get:function(u,d){return this.find(function(y,x){return oe(x,u)},void 0,d)},getIn:function(u,d){for(var y=this,x=Hy(u),b;!(b=x.next()).done;){var A=b.value;if(y=y&&y.get?y.get(A,E):E,y===E)return d}return y},groupBy:function(u,d){return vE(this,u,d)},has:function(u){return this.get(u,E)!==E},hasIn:function(u){return this.getIn(u,E)!==E},isSubset:function(u){return u=typeof u.includes=="function"?u:i(u),this.every(function(d){return u.includes(d)})},isSuperset:function(u){return u=typeof u.isSubset=="function"?u:i(u),u.isSubset(this)},keyOf:function(u){return this.findKey(function(d){return oe(d,u)})},keySeq:function(){return this.toSeq().map(ME).toIndexedSeq()},last:function(){return this.toSeq().reverse().first()},lastKeyOf:function(u){return this.toKeyedSeq().reverse().keyOf(u)},max:function(u){return Mu(this,u)},maxBy:function(u,d){return Mu(this,d,u)},min:function(u){return Mu(this,u?e0(u):n0)},minBy:function(u,d){return Mu(this,d?e0(d):n0,u)},rest:function(){return this.slice(1)},skip:function(u){return this.slice(Math.max(0,u))},skipLast:function(u){return Zt(this,this.toSeq().reverse().skip(u).reverse())},skipWhile:function(u,d){return Zt(this,Ny(this,u,d,!0))},skipUntil:function(u,d){return this.skipWhile(Tu(u),d)},sortBy:function(u,d){return Zt(this,Bs(this,d,u))},take:function(u){return this.slice(0,Math.max(0,u))},takeLast:function(u){return Zt(this,this.toSeq().reverse().take(u).reverse())},takeWhile:function(u,d){return Zt(this,xE(this,u,d))},takeUntil:function(u,d){return this.takeWhile(Tu(u),d)},valueSeq:function(){return this.toIndexedSeq()},hashCode:function(){return this.__hash||(this.__hash=zE(this))}});var Je=i.prototype;Je[p]=!0,Je[rt]=Je.values,Je.__toJS=Je.toArray,Je.__toStringMapper=r0,Je.inspect=Je.toSource=function(){return this.toString()},Je.chain=Je.flatMap,Je.contains=Je.includes,Sn(s,{flip:function(){return Zt(this,Ry(this))},mapEntries:function(u,d){var y=this,x=0;return Zt(this,this.toSeq().map(function(b,A){return u.call(d,[A,b],x++,y)}).fromEntrySeq())},mapKeys:function(u,d){var y=this;return Zt(this,this.toSeq().flip().map(function(x,b){return u.call(d,x,b,y)}).flip())}});var zu=s.prototype;zu[m]=!0,zu[rt]=Je.entries,zu.__toJS=Je.toObject,zu.__toStringMapper=function(u,d){return JSON.stringify(d)+": "+r0(u)},Sn(o,{toKeyedSeq:function(){return new kr(this,!1)},filter:function(u,d){return Zt(this,Fy(this,u,d,!1))},findIndex:function(u,d){var y=this.findEntry(u,d);return y?y[0]:-1},indexOf:function(u){var d=this.keyOf(u);return d===void 0?-1:d},lastIndexOf:function(u){var d=this.lastKeyOf(u);return d===void 0?-1:d},reverse:function(){return Zt(this,Nh(this,!1))},slice:function(u,d){return Zt(this,jh(this,u,d,!1))},splice:function(u,d){var y=arguments.length;if(d=Math.max(d|0,0),y===0||y===2&&!d)return this;u=yt(u,u<0?this.count():this.size);var x=this.slice(0,u);return Zt(this,y===1?x:x.concat(J(arguments,2),this.slice(u+d)))},findLastIndex:function(u,d){var y=this.findLastEntry(u,d);return y?y[0]:-1},first:function(){return this.get(0)},flatten:function(u){return Zt(this,jy(this,u,!1))},get:function(u,d){return u=tt(this,u),u<0||this.size===1/0||this.size!==void 0&&u>this.size?d:this.find(function(y,x){return x===u},void 0,d)},has:function(u){return u=tt(this,u),u>=0&&(this.size!==void 0?this.size===1/0||u<this.size:this.indexOf(u)!==-1)},interpose:function(u){return Zt(this,wE(this,u))},interleave:function(){var u=[this].concat(J(arguments)),d=Vh(this.toSeq(),kt.of,u),y=d.flatten(!0);return d.size&&(y.size=d.size*u.length),Zt(this,y)},keySeq:function(){return ae(0,this.size)},last:function(){return this.get(-1)},skipWhile:function(u,d){return Zt(this,Ny(this,u,d,!1))},zip:function(){var u=[this].concat(J(arguments));return Zt(this,Vh(this,OE,u))},zipWith:function(u){var d=J(arguments);return d[0]=this,Zt(this,Vh(this,u,d))}}),o.prototype[v]=!0,o.prototype[_]=!0,Sn(a,{get:function(u,d){return this.has(u)?u:d},includes:function(u){return this.has(u)},keySeq:function(){return this.valueSeq()}}),a.prototype.has=Je.includes,a.prototype.contains=a.prototype.includes,Sn(Bt,s.prototype),Sn(kt,o.prototype),Sn(Ct,a.prototype),Sn(oi,s.prototype),Sn(ai,o.prototype),Sn(Fi,a.prototype);function ME(u,d){return d}function AE(u,d){return[d,u]}function Tu(u){return function(){return!u.apply(this,arguments)}}function e0(u){return function(){return-u.apply(this,arguments)}}function r0(u){return typeof u=="string"?JSON.stringify(u):String(u)}function OE(){return J(arguments)}function n0(u,d){return u<d?1:u>d?-1:0}function zE(u){if(u.size===1/0)return 0;var d=g(u),y=c(u),x=d?1:0,b=u.__iterate(y?d?function(A,T){x=31*x+i0($e(A),$e(T))|0}:function(A,T){x=x+i0($e(A),$e(T))|0}:d?function(A){x=31*x+$e(A)|0}:function(A){x=x+$e(A)|0});return TE(b,x)}function TE(u,d){return d=Ni(d,3432918353),d=Ni(d<<15|d>>>-15,461845907),d=Ni(d<<13|d>>>-13,5),d=(d+3864292196|0)^u,d=Ni(d^d>>>16,2246822507),d=Ni(d^d>>>13,3266489909),d=Fs(d^d>>>16),d}function i0(u,d){return u^d+2654435769+(u<<6)+(u>>2)|0}var CE={Iterable:i,Seq:Ot,Collection:Ir,Map:nt,OrderedMap:ye,List:ie,Stack:Se,Set:le,OrderedSet:wn,Record:yr,Range:ae,Repeat:we,is:oe,fromJS:Cr};return CE})}(Sa)),Sa.exports}var Hl,Cd;function Wv(){if(Cd)return Hl;Cd=1;var n=$l(),t=function(i){return n.Iterable.isKeyed(i)},e=function(i){return n.Iterable.isIndexed(i)},r=function(i,s,o){return i==="remove"?{op:i,path:s}:{op:i,path:s,value:o}};return Hl={isMap:t,isIndexed:e,op:r},Hl}var Gl,Id;function Uv(){if(Id)return Gl;Id=1;var n=$l(),t=function(c,h,f){for(var g=[],p=0;p<c;p++){g[p]=new Array(h);for(var m=0;m<h;m++)g[p][m]=f}return g},e=function(c,h){var f=a(c,h);return l(c,h,f)},r=n.Record({op:"=",val:null}),i=n.Record({op:"!=",val:null,newVal:null}),s=function(c,h){var f=a(c,h);return o(f,c,h,c.size||0,h.size||0)},o=function(c,h,f,g,p){for(var m=[],v=g-1,_=p-1;v>=0||_>=0;)v>=0&&_>=0&&n.is(h.get(v),f.get(_))?(m.push(new r({op:"=",val:h.get(v)})),v-=1,_-=1):v>=0&&_>=0&&v===_&&!n.is(h.get(v),f.get(_))?(m.push(new i({val:h.get(v),newVal:f.get(v)})),v-=1,_-=1):_>=0&&(v===-1||c[v+1][_]>=c[v][_+1])?(m.push(new r({op:"+",val:f.get(_)})),_-=1):v>=0&&(_===-1||c[v+1][_]<c[v][_+1])&&(m.push(new r({op:"-",val:h.get(v)})),v-=1);return m.reverse()};function a(c,h){for(var f=c.size||0,g=h.size||0,p=t(f+1,g+1,0),m=0;m<f;m++)for(var v=0;v<g;v++)n.is(c.get(m),h.get(v))?p[m+1][v+1]=p[m][v]+1:p[m+1][v+1]=Math.max(p[m+1][v],p[m][v+1]);return p}var l=function(c,h,f){for(var g=[],p=c.size,m=h.size;p!==0&&m!==0;)f[p][m]===f[p-1][m]?p--:f[p][m]===f[p][m-1]?m--:n.is(c.get(p-1),h.get(m-1))&&(g.push(c.get(p-1)),p--,m--);return g.reverse()};return Gl={lcs:e,computeLcsMatrix:a,diff:s},Gl}var Wl,kd;function Yv(){if(kd)return Wl;kd=1;var n=new RegExp("/","g"),t=new RegExp("~1","g"),e=/~/g,r=/~0/g,i={escape:function(s){if(typeof s=="number")return s.toString();if(typeof s!="string")throw"param str ("+s+") is not a string";return s.replace(e,"~0").replace(n,"~1")},unescape:function(s){return typeof s=="string"?s.replace(t,"/").replace(r,"~"):s},concat:function(s,o){return s+"/"+o}};return Wl=i,Wl}var Ul,Pd;function Xv(){if(Pd)return Ul;Pd=1;var n=$l(),t=Wv(),e=Uv(),r=Yv(),i=r.concat,s=r.escape,o=t.op,a=t.isMap,l=t.isIndexed,c=function(p,m,v){var _=[],S=v||"";if(n.is(p,m)||p==m==null)return _;var M=l(p)&&l(m),C=null,O=null;return p.forEach&&p.forEach(function(E,z){if(m.has(z))if(a(E)&&a(m.get(z)))_=_.concat(c(E,m.get(z),i(S,s(z))));else if(l(m.get(z))&&l(E))_=_.concat(h(E,m.get(z),i(S,s(z))));else{var R=m.get?m.get(z):m,k=E!==R;k&&_.push(o("replace",i(S,s(z)),R))}else M?(O=C!=null&&C+1===z?O:z,_.push(o("remove",i(S,s(O)))),C=z):_.push(o("remove",i(S,s(z))))}),m.forEach(function(E,z){p.has&&!p.has(z)&&_.push(o("add",i(S,s(z)),E))}),_},h=function(p,m,v){var _=[],S=v||"";if(n.is(p,m)||p==m==null)return _;if((p.count()+1)*(m.count()+1)>=1e4)return c(p,m,v);var M=e.diff(p,m),C=0;return M.forEach(function(O){if(O.op==="=")C++;else if(O.op==="!="){if(a(O.val)&&a(O.newVal)){var E=c(O.val,O.newVal,i(S,C));_=_.concat(E)}else _.push(o("replace",i(S,C),O.newVal));C++}else O.op==="+"?(_.push(o("add",i(S,C),O.val)),C++):O.op==="-"&&_.push(o("remove",i(S,C)))}),_},f=function(p,m,v){var _=v||"";return p===m?[]:[o("replace",i(_,""),m)]},g=function(p,m,v){return n.is(p,m)?n.List():p!=m&&(p==null||m==null)?n.fromJS([o("replace","/",m)]):l(p)&&l(m)?n.fromJS(h(p,m)):a(p)&&a(m)?n.fromJS(c(p,m)):n.fromJS(f(p,m,v))};return Ul=g,Ul}var Jv=Xv();const Zv=nn(Jv),Kv=Wh(lv);var Yl,Rd;function Qv(){if(Rd)return Yl;Rd=1;var n=new RegExp("/","g"),t=new RegExp("~1","g"),e=/~/g,r=/~0/g,i={escape:function(s){if(typeof s!="string")throw"param str ("+s+") is not a string";return s.replace(e,"~0").replace(n,"~1")},unescape:function(s){return typeof s=="string"?s.replace(t,"/").replace(r,"~"):s}};return Yl=i,Yl}var Xl,Ld;function tx(){if(Ld)return Xl;Ld=1;var n=Kv,t=Qv(),e=function(h){var f=parseInt(h);return isNaN(f)?h:f},r=function(h,f){if(h==="add"||h==="replace")return f;if(h==="remove")return null},i=function(h,f,g,p,m){if(p==="add")if(g.length>0&&h.get(f)===void 0){var v=g[0].match(/^\d+$/)?n.List():n.Map();return h.set(f,a(v,g,p,m))}else return h.set(f,a(h.get(f),g,p,m));else{if(p==="replace")return g.length>0?h.set(f,a(h.get(f),g,p,m)):h.set(f,m);if(p==="remove")return g.length>0?h.set(f,a(h.get(f),g,p,m)):h.remove(f);throw new Error("map patch Error, unknown op: "+p)}},s=function(h,f,g,p,m){if(f=e(f),p==="add")if(h.get(f)===void 0)if(g.length>0){var v=g[0].match(/^\d+$/)?n.List():n.Map();return h.set(f,a(v,g,p,m))}else return f==="-"?h.splice(h.size,0,m):h.splice(f,0,m);else return g.length>0?h.set(f,a(h.get(f),g,p,m)):h.splice(f,0,m);else{if(p==="replace")return g.length>0?h.set(f,a(h.get(f),g,p,m)):h.set(f,m);if(p==="remove")return g.length>0?h.set(f,a(h.get(f),g,p,m)):h.remove(f);throw new Error("sequence patch Error, unknown op: "+p)}},o=function(h){return h!=null&&typeof h.updateIn=="function"&&typeof h.set=="function"},a=function(h,f,g,p){var m,v;return n.Iterable.isIndexed(h)?f.length===0?h:(m=f[0],v=f.slice(1),s(h,m,v,g,p)):n.Iterable.isKeyed(h)||o(h)?f.length===0?h:(m=f[0],v=f.slice(1),i(h,m,v,g,p)):f.length===0?p:r(g,p)},l=function(h,f){for(;f.size;){var g=f.get(0),f=f.slice(1),p=g.get("path").split("/").slice(1).map(t.unescape);h=a(h,p,g.get("op"),g.get("value"))}return h},c=function(h,f){if(f.size===1){var g=f.get(0);if(g.get("op")==="replace"&&g.get("path")==="/")return g.get("value")}return l(h,f)};return c.default=c,Xl=c,Xl}var ex=tx();const Fd=nn(ex),de=(n,t)=>{if(n.last){if(n.last.hashCode()!==t.hashCode()){let e=K({time:Date.now(),diff:Zv(n.last,t)});n=n.set("last",t).set("list",n.list.push(e)).set("redoList",n.redoList.clear())}}else n=n.set("last",t);return n},rx=n=>{if(n.last&&n.redoList.size){const t=n.redoList.last(),e=Fd(n.last,t.get("diff"));n=n.set("last",e).set("list",n.list.push(t)).set("redoList",n.redoList.pop())}return n},Nd=n=>{var t;if(n.last&&n.list.size){const e=n.list.last();let r=n.first;for(let i=0;i<n.list.size-1;i++)r=Fd(r,(t=n.list.get(i))==null?void 0:t.get("diff"));n=n.set("last",r).set("list",n.list.pop()).set("redoList",n.redoList.push(e))}return n};var Jl={exports:{}},Zl,jd;function nx(){if(jd)return Zl;jd=1;var n=1;function t(){return n=(n*9301+49297)%233280,n/233280}function e(r){n=r}return Zl={nextValue:t,seed:e},Zl}var Kl,Vd;function Ea(){if(Vd)return Kl;Vd=1;var n=nx(),t="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-",e,r,i;function s(){i=!1}function o(p){if(!p){e!==t&&(e=t,s());return}if(p!==e){if(p.length!==t.length)throw new Error("Custom alphabet for shortid must be "+t.length+" unique characters. You submitted "+p.length+" characters: "+p);var m=p.split("").filter(function(v,_,S){return _!==S.lastIndexOf(v)});if(m.length)throw new Error("Custom alphabet for shortid must be "+t.length+" unique characters. These characters were not unique: "+m.join(", "));e=p,s()}}function a(p){return o(p),e}function l(p){n.seed(p),r!==p&&(s(),r=p)}function c(){e||o(t);for(var p=e.split(""),m=[],v=n.nextValue(),_;p.length>0;)v=n.nextValue(),_=Math.floor(v*p.length),m.push(p.splice(_,1)[0]);return m.join("")}function h(){return i||(i=c(),i)}function f(p){var m=h();return m[p]}function g(){return e||t}return Kl={get:g,characters:a,seed:l,lookup:f,shuffled:h},Kl}var Ql,Dd;function ix(){if(Dd)return Ql;Dd=1;var n=typeof window=="object"&&(window.crypto||window.msCrypto),t;return!n||!n.getRandomValues?t=function(e){for(var r=[],i=0;i<e;i++)r.push(Math.floor(Math.random()*256));return r}:t=function(e){return n.getRandomValues(new Uint8Array(e))},Ql=t,Ql}let sx="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict",Bd=n=>crypto.getRandomValues(new Uint8Array(n)),qd=(n,t,e)=>{let r=(2<<Math.log(n.length-1)/Math.LN2)-1,i=-~(1.6*r*t/n.length);return(s=t)=>{let o="";for(;;){let a=e(i),l=i|0;for(;l--;)if(o+=n[a[l]&r]||"",o.length===s)return o}}};const ox=Wh(Object.freeze(Object.defineProperty({__proto__:null,customAlphabet:(n,t=21)=>qd(n,t,Bd),customRandom:qd,nanoid:(n=21)=>crypto.getRandomValues(new Uint8Array(n)).reduce((t,e)=>(e&=63,e<36?t+=e.toString(36):e<62?t+=(e-26).toString(36).toUpperCase():e>62?t+="-":t+="_",t),""),random:Bd,urlAlphabet:sx},Symbol.toStringTag,{value:"Module"})));var tc,$d;function ax(){if($d)return tc;$d=1;var n=Ea(),t=ix(),e=ox.customRandom;function r(i){for(var s=0,o,a="";!o;)a=a+e(n.get(),1,t)(),o=i<Math.pow(16,s+1),s++;return a}return tc=r,tc}var ec,Hd;function ux(){if(Hd)return ec;Hd=1;var n=ax();Ea();var t=1567752802062,e=7,r,i;function s(o){var a="",l=Math.floor((Date.now()-t)*.001);return l===i?r++:(r=0,i=l),a=a+n(e),a=a+n(o),r>0&&(a=a+n(r)),a=a+n(l),a}return ec=s,ec}var rc,Gd;function lx(){if(Gd)return rc;Gd=1;var n=Ea();function t(e){if(!e||typeof e!="string"||e.length<6)return!1;var r=new RegExp("[^"+n.get().replace(/[|\\{}()[\]^$+*?.-]/g,"\\$&")+"]");return!r.test(e)}return rc=t,rc}var nc,Wd;function cx(){return Wd||(Wd=1,nc=0),nc}var Ud;function hx(){return Ud||(Ud=1,function(n){var t=Ea(),e=ux(),r=lx(),i=cx()||0;function s(c){return t.seed(c),n.exports}function o(c){return i=c,n.exports}function a(c){return c!==void 0&&t.characters(c),t.shuffled()}function l(){return e(i)}n.exports=l,n.exports.generate=l,n.exports.seed=s,n.exports.worker=o,n.exports.characters=a,n.exports.isValid=r}(Jl)),Jl.exports}var ic,Yd;function fx(){return Yd||(Yd=1,ic=hx()),ic}var dx=fx();const px=nn(dx);class fn{static acquireID(){return px.generate()}}class Ma{static generateName(t,e){return e.charAt(0).toUpperCase()+e.slice(1)}}class xe{static create(t,e,r,i,s,o){let a=fn.acquireID(),l=t.catalog.factoryElement(r,{id:a,name:Ma.generateName("holes",t.catalog.getIn(["elements",r,"info","title"])),type:r,offset:s,line:i},o);return t=t.setIn(["scene","layers",e,"holes",a],l),t=t.updateIn(["scene","layers",e,"lines",i,"holes"],c=>c.push(a)),{updatedState:t,hole:l}}static select(t,e,r){return t=wt.select(t,e).updatedState,t=wt.selectElement(t,e,"holes",r).updatedState,{updatedState:t}}static remove(t,e,r){let i=t.getIn(["scene","layers",e,"holes",r]);return t=this.unselect(t,e,r).updatedState,t=wt.removeElement(t,e,"holes",r).updatedState,t=t.updateIn(["scene","layers",e,"lines",i.line,"holes"],s=>{let o=s.findIndex(a=>r===a);return o!==-1?s.remove(o):s}),t.getIn(["scene","groups"]).forEach(s=>t=_e.removeElement(t,s.id,e,"holes",r).updatedState),{updatedState:t}}static unselect(t,e,r){return t=wt.unselect(t,e,"holes",r).updatedState,{updatedState:t}}static selectToolDrawingHole(t,e){let r=ut().withMutations(i=>{let{lines:s,vertices:o}=t.getIn(["scene","layers",t.scene.selectedLayer]);s.forEach(a=>{let{x:l,y:c}=o.get(a.vertices.get(0)),{x:h,y:f}=o.get(a.vertices.get(1));go(i,l,c,h,f,20,1,a.id)})});return t=t.merge({mode:ar,snapElements:r,drawingSupport:K({type:e})}),{updatedState:t}}static updateDrawingHole(t,e,r,i){let s=t.catalog,o=hn(t.snapElements,r,i,t.snapMask.merge({SNAP_SEGMENT:!0}));o&&({x:r,y:i}=o.point);let a=t.getIn(["scene","layers",e,"selected","holes"]).first();if(o){let l=o.snap.related.get(0),c=t.getIn(["scene","layers",e,"lines",l,"vertices"]),{x:h,y:f}=t.getIn(["scene","layers",e,"vertices",c.get(0)]),{x:g,y:p}=t.getIn(["scene","layers",e,"vertices",c.get(1)]),m=pa({x:h,y:f},{x:g,y:p}),v=Il({x:h,y:f},{x:g,y:p}),_=s.factoryElement(t.drawingSupport.get("type")).properties.getIn(["width","length"]),S=Ve(h,f,g,p),M=vv(h,f,g,p),C=_v(M,1e-7),O=bv(M,1e-7),E={x:m.x+_/2*C,y:m.y+_/2*O},z={x:m.x+S*C-_/2*C,y:m.y+S*O-_/2*O},R;if(r<E.x?R=De(m.x,m.y,v.x,v.y,E.x,E.y):r>z.x?R=De(m.x,m.y,v.x,v.y,z.x,z.y):r===E.x&&r===z.x?i<E.y?(R=De(m.x,m.y,v.x,v.y,E.x,E.y),R=m.x===h&&m.y===f?R:1-R):i>z.y?(R=De(m.x,m.y,v.x,v.y,z.x,z.y),R=m.x===h&&m.y===f?R:1-R):R=De(h,f,g,p,r,i):R=De(h,f,g,p,r,i),a&&o){t=t.mergeIn(["scene","layers",e,"holes",a],{offset:R,line:l});let k=t.getIn(["scene","layers",e,"lines"]).findEntry(X=>X.id!==l&&X.get("holes").contains(a));if(k){let X=k[1].get("holes").filter(J=>J!==a);t=t.setIn(["scene","layers",e,"lines",k[0],"holes"],X)}let L=t.getIn(["scene","layers",e,"lines",l,"holes"]);L.contains(a)||(t=t.setIn(["scene","layers",e,"lines",l,"holes"],L.push(a)))}else if(!a&&o){let{updatedState:k,hole:L}=this.create(t,e,t.drawingSupport.get("type"),l,R);t=xe.select(k,e,L.id).updatedState}}return{updatedState:t}}static endDrawingHole(t,e,r,i){return t=this.updateDrawingHole(t,e,r,i).updatedState,t=wt.unselectAll(t,e).updatedState,{updatedState:t}}static beginDraggingHole(t,e,r,i,s){let o=t.getIn(["scene","layers",e]),a=o.getIn(["holes",r]),l=o.getIn(["lines",a.line]),c=o.getIn(["vertices",l.vertices.get(0)]),h=o.getIn(["vertices",l.vertices.get(1)]),f=go(ut(),c.x,c.y,h.x,h.y,9999999,1,null);return t=t.merge({mode:Vr,snapElements:f,draggingSupport:K({layerID:e,holeID:r,startPointX:i,startPointY:s})}),{updatedState:t}}static updateDraggingHole(t,e,r){let i=hn(t.snapElements,e,r,t.snapMask.merge({SNAP_SEGMENT:!0}));if(!i)return t;let{draggingSupport:s,scene:o}=t,a=s.get("layerID"),l=s.get("holeID"),c=t.getIn(["scene","layers",a]),h=c.getIn(["holes",l]),f=c.getIn(["lines",h.line]),g=c.getIn(["vertices",f.vertices.get(0)]),p=c.getIn(["vertices",f.vertices.get(1)]);({x:e,y:r}=i.point);let m=pa(g,p),v=Il(g,p),_=h.properties.get("width").get("length"),S=Ve(g.x,g.y,p.x,p.y),M=Math.atan2(Math.abs(p.y-g.y),Math.abs(p.x-g.x)),C=X=>{let J=Math.cos(X);return J<1e-7?0:J},O=X=>{let J=Math.sin(X);return J<1e-7?0:J},E=C(M),z=O(M),R={x:m.x+_/2*E,y:m.y+_/2*z},k={x:m.x+S*E-_/2*E,y:m.y+S*z-_/2*z},L;return e<R.x?L=De(m.x,m.y,v.x,v.y,R.x,R.y):e>k.x?L=De(m.x,m.y,v.x,v.y,k.x,k.y):e===R.x&&e===k.x?r<R.y?(L=De(m.x,m.y,v.x,v.y,R.x,R.y),L=m===g?L:1-L):r>k.y?(L=De(m.x,m.y,v.x,v.y,k.x,k.y),L=m===g?L:1-L):(L=De(m.x,m.y,v.x,v.y,e,r),L=m===g?L:1-L):L=De(m.x,m.y,v.x,v.y,e,r),h=h.set("offset",L),t=t.merge({scene:o.mergeIn(["layers",a,"holes",l],h)}),{updatedState:t}}static endDraggingHole(t,e,r){return t=this.updateDraggingHole(t,e,r).updatedState,t=t.merge({mode:fe}),{updatedState:t}}static setProperties(t,e,r,i){return t=t.setIn(["scene","layers",e,"holes",r,"properties"],i),{updatedState:t}}static setJsProperties(t,e,r,i){return this.setProperties(t,e,r,Xt(i))}static updateProperties(t,e,r,i){return i.forEach((s,o)=>{t.hasIn(["scene","layers",e,"holes",r,"properties",o])&&(t=t.mergeIn(["scene","layers",e,"holes",r,"properties",o],s))}),{updatedState:t}}static updateJsProperties(t,e,r,i){return this.updateProperties(t,e,r,Xt(i))}static setAttributes(t,e,r,i){let s=i.toJS(),{offsetA:o,offsetB:a,offset:l}=s;delete s.offsetA,delete s.offsetB,delete s.offset;let c=K({_unitA:o._unit,_unitB:a._unit});return t=t.mergeIn(["scene","layers",e,"holes",r],Xt(s)).mergeDeepIn(["scene","layers",e,"holes",r],K({offset:l,misc:c})),{updatedState:t}}}let Me=class s0{static create(t,e,r,i,s,o,a,l){let c=fn.acquireID(),h=t.catalog.factoryElement(r,{id:c,name:Ma.generateName("items",t.catalog.getIn(["elements",r,"info","title"])),type:r,height:a,width:o,x:i,y:s,rotation:l});return t=t.setIn(["scene","layers",e,"items",c],h),{updatedState:t,item:h}}static select(t,e,r){return t=wt.select(t,e).updatedState,t=wt.selectElement(t,e,"items",r).updatedState,{updatedState:t}}static remove(t,e,r){return t=this.unselect(t,e,r).updatedState,t=wt.removeElement(t,e,"items",r).updatedState,t.getIn(["scene","groups"]).forEach(i=>t=_e.removeElement(t,i.id,e,"items",r).updatedState),{updatedState:t}}static unselect(t,e,r){return t=wt.unselect(t,e,"items",r).updatedState,{updatedState:t}}static selectToolDrawingItem(t,e){return t=t.merge({mode:Sr,drawingSupport:K({type:e})}),{updatedState:t}}static updateDrawingItem(t,e,r,i){if(t.hasIn(["drawingSupport","currentID"]))t=t.updateIn(["scene","layers",e,"items",t.getIn(["drawingSupport","currentID"])],s=>s.merge({x:r,y:i}));else{let{updatedState:s,item:o}=this.create(t,e,t.getIn(["drawingSupport","type"]),r,i,200,100,0);t=s0.select(s,e,o.id).updatedState,t=t.setIn(["drawingSupport","currentID"],o.id)}return{updatedState:t}}static endDrawingItem(t,e,r,i){return t=this.updateDrawingItem(t,e,r,i).updatedState,t=wt.unselectAll(t,e).updatedState,t=t.merge({drawingSupport:K({type:t.drawingSupport.get("type")})}),{updatedState:t}}static beginDraggingItem(t,e,r,i,s){let o=t.getIn(["scene","layers",e,"items",r]);return t=t.merge({mode:jr,draggingSupport:K({layerID:e,itemID:r,startPointX:i,startPointY:s,originalX:o.x,originalY:o.y})}),{updatedState:t}}static updateDraggingItem(t,e,r){let{draggingSupport:i,scene:s}=t,o=i.get("layerID"),a=i.get("itemID"),l=i.get("startPointX"),c=i.get("startPointY"),h=i.get("originalX"),f=i.get("originalY"),g=l-e,p=c-r,m=s.getIn(["layers",o,"items",a]);return m=m.merge({x:h-g,y:f-p}),t=t.merge({scene:s.mergeIn(["layers",o,"items",a],m)}),{updatedState:t}}static endDraggingItem(t,e,r){return t=this.updateDraggingItem(t,e,r).updatedState,t=t.merge({mode:fe}),{updatedState:t}}static beginRotatingItem(t,e,r,i,s){return t=t.merge({mode:An,rotatingSupport:K({layerID:e,itemID:r})}),{updatedState:t}}static updateRotatingItem(t,e,r){let{rotatingSupport:i,scene:s}=t,o=i.get("layerID"),a=i.get("itemID"),l=t.getIn(["scene","layers",o,"items",a]),c=e-l.x,h=r-l.y,f=Math.atan2(h,c)*180/Math.PI-90;return-5<f&&f<5&&(f=0),-95<f&&f<-85&&(f=-90),-185<f&&f<-175&&(f=-180),85<f&&f<90&&(f=90),-270<f&&f<-265&&(f=90),l=l.merge({rotation:f}),t=t.merge({scene:s.mergeIn(["layers",o,"items",a],l)}),{updatedState:t}}static endRotatingItem(t,e,r){return t=this.updateRotatingItem(t,e,r).updatedState,t=t.merge({mode:fe}),{updatedState:t}}static setProperties(t,e,r,i){return t=t.mergeIn(["scene","layers",e,"items",r,"properties"],i),{updatedState:t}}static setJsProperties(t,e,r,i){return this.setProperties(t,e,r,Xt(i))}static updateProperties(t,e,r,i){return i.forEach((s,o)=>{t.hasIn(["scene","layers",e,"items",r,"properties",o])&&(t=t.mergeIn(["scene","layers",e,"items",r,"properties",o],s))}),{updatedState:t}}static updateJsProperties(t,e,r,i){return this.updateProperties(t,e,r,Xt(i))}static setAttributes(t,e,r,i){return t=t.mergeIn(["scene","layers",e,"items",r],i),{updatedState:t}}static setJsAttributes(t,e,r,i){return i=Xt(i),this.setAttributes(t,e,r,i)}},_e=class Iu{static select(t,e){let r=t.getIn(["scene","groups",e,"elements"]);t=Jt.setAlterate(t).updatedState,r.entrySeq().forEach(([s,o])=>{t=wt.unselectAll(t,s).updatedState;let a=o.get("lines"),l=o.get("holes"),c=o.get("items"),h=o.get("areas");a&&a.forEach(f=>{t=Ie.select(t,s,f).updatedState}),l&&l.forEach(f=>{t=xe.select(t,s,f).updatedState}),c&&c.forEach(f=>{t=Me.select(t,s,f).updatedState}),h&&h.forEach(f=>{t=xi.select(t,s,f).updatedState})}),t=Jt.setAlterate(t).updatedState;let i=t.getIn(["scene","groups"]).map(s=>s.set("selected",!1));return t=t.setIn(["scene","groups"],i).setIn(["scene","groups",e,"selected"],!0),{updatedState:t}}static unselect(t,e){return t=t.getIn(["scene","groups",e,"elements"]).reduce((s,o,a)=>wt.unselectAll(s,a).updatedState,t).setIn(["scene","groups",e,"selected"],!1),{updatedState:t}}static create(t){let e=fn.acquireID();return t=t.setIn(["scene","groups",e],new Dl({id:e,name:e})),{updatedState:t}}static createFromSelectedElements(t){let e=fn.acquireID();return t=t.setIn(["scene","groups",e],new Dl({id:e,name:e})),t.getIn(["scene","layers"]).forEach(r=>{let i=r.get("id"),s={lines:r.get("lines").filter(o=>o.get("selected")),items:r.get("items").filter(o=>o.get("selected")),holes:r.get("holes").filter(o=>o.get("selected")),areas:r.get("areas").filter(o=>o.get("selected"))};for(let o in s)s[o].forEach(a=>t=this.addElement(t,e,i,o,a.get("id")).updatedState)}),{updatedState:t}}static addElement(t,e,r,i,s){let o=t.getIn(["scene","groups",e,"elements",r,i])||ut();return o.contains(s)||(t=t.setIn(["scene","groups",e,"elements",r,i],o.push(s)),t=this.reloadBaricenter(t,e).updatedState),{updatedState:t}}static setBarycenter(t,e,r,i){return typeof r<"u"&&(t=t.setIn(["scene","groups",e,"x"],r)),typeof i<"u"&&(t=t.setIn(["scene","groups",e,"y"],i)),{updatedState:t}}static reloadBaricenter(t,e){let r=t.getIn(["scene","groups",e,"elements"]),i=0,s=0,o=0;return r.entrySeq().forEach(([a,l])=>{t=wt.unselectAll(t,a).updatedState;let c=l.get("lines"),h=l.get("holes"),f=l.get("items"),g=l.get("areas");c&&c.forEach(p=>{let m=t.getIn(["scene","layers",a,"lines",p,"vertices"]).map(E=>t.getIn(["scene","layers",a,"vertices",E])),{x:v,y:_}=m.get(0),{x:S,y:M}=m.get(1),{x:C,y:O}=wv(v,_,S,M);i+=C,s+=O,o++}),h&&h.forEach(p=>{let m=t.getIn(["scene","layers",a,"holes",p]),v=t.getIn(["scene","layers",a,"lines",m.line,"vertices"]).map(z=>t.getIn(["scene","layers",a,"vertices",z])),{x:_,y:S}=v.get(0),{x:M,y:C}=v.get(1),{x:O,y:E}=va(_,S,M,C,m.offset*Ve(_,S,M,C));i+=O,s+=E,o++}),f&&f.forEach(p=>{let{x:m,y:v}=t.getIn(["scene","layers",a,"items",p]);i+=m,s+=v,o++}),g&&g.forEach(p=>{let m=t.getIn(["scene","layers",a,"areas",p,"vertices"]).map(S=>t.getIn(["scene","layers",a,"vertices",S])).toJS(),{x:v,y:_}=Sv(m);i+=v,s+=_,o++})}),o&&(t=this.setBarycenter(t,e,i/o,s/o).updatedState),{updatedState:t}}static removeElement(t,e,r,i,s){let o=t.getIn(["scene","groups",e,"elements",r,i]);return!o||!o.contains(s)?{updatedState:t}:(t=t.setIn(["scene","groups",e,"elements",r,i],o.filterNot(a=>a===s)),{updatedState:t})}static setAttributes(t,e,r){return t=t.mergeIn(["scene","groups",e],r),{updatedState:t}}static setProperties(t,e,r){return t=t.mergeIn(["scene","groups",e,"properties"],r),{updatedState:t}}static remove(t,e){return t=t.removeIn(["scene","groups",e]),{updatedState:t}}static removeAndDeleteElements(t,e){return t.getIn(["scene","groups",e,"elements"]).entrySeq().forEach(([i,s])=>{t=wt.unselectAll(t,i).updatedState;let o=s.get("lines"),a=s.get("holes"),l=s.get("items");s.get("areas"),o&&o.forEach(c=>{t=Ie.remove(t,i,c).updatedState,t=wt.detectAndUpdateAreas(t,i).updatedState}),a&&a.forEach(c=>{t=xe.remove(t,i,c).updatedState}),l&&l.forEach(c=>{t=Me.remove(t,i,c).updatedState})}),t=t.deleteIn(["scene","groups",e]),{updatedState:t}}static translate(t,e,r,i){let s=r-t.getIn(["scene","groups",e,"x"]),o=i-t.getIn(["scene","groups",e,"y"]);return t.getIn(["scene","groups",e,"elements"]).entrySeq().forEach(([l,c])=>{let h=c.get("lines"),f=c.get("items");if(h){let g={};h.forEach(p=>{let m=t.getIn(["scene","layers",l,"lines",p]);g[m.vertices.get(0)]||(g[m.vertices.get(0)]=t.getIn(["scene","layers",l,"vertices",m.vertices.get(0)])),g[m.vertices.get(1)]||(g[m.vertices.get(1)]=t.getIn(["scene","layers",l,"vertices",m.vertices.get(1)]))});for(let p in g){let{x:m,y:v}=g[p];t=pe.setAttributes(t,l,p,K({x:m+s,y:v+o})).updatedState}for(let p in g)t=pe.beginDraggingVertex(t,l,p).updatedState,t=pe.endDraggingVertex(t).updatedState}f&&(t=f.map(g=>t.getIn(["scene","layers",l,"items",g])).reduce((g,p)=>{let{x:m,y:v}=p;return Me.setAttributes(g,l,p.id,K({x:m+s,y:v+o})).updatedState},t)),t=wt.detectAndUpdateAreas(t,l).updatedState}),t=this.setBarycenter(t,e,r,i).updatedState,t=Iu.select(t,e).updatedState,{updatedState:t}}static rotate(t,e,r){let{x:i,y:s,rotation:o}=t.getIn(["scene","groups",e]),a=r-o;return t=Iu.setAttributes(t,e,K({rotation:r})).updatedState,t.getIn(["scene","groups",e,"elements"]).entrySeq().forEach(([c,h])=>{let f=h.get("lines"),g=h.get("items");if(f){let p={};f.forEach(m=>{let v=t.getIn(["scene","layers",c,"lines",m]);p[v.vertices.get(0)]||(p[v.vertices.get(0)]=t.getIn(["scene","layers",c,"vertices",v.vertices.get(0)])),p[v.vertices.get(1)]||(p[v.vertices.get(1)]=t.getIn(["scene","layers",c,"vertices",v.vertices.get(1)]))});for(let m in p){let{x:v,y:_}=p[m],{x:S,y:M}=gd(v,_,i,s,a);t=pe.setAttributes(t,c,m,K({x:S,y:M})).updatedState}for(let m in p)t=pe.beginDraggingVertex(t,c,m).updatedState,t=pe.endDraggingVertex(t).updatedState}g&&(t=g.map(p=>t.getIn(["scene","layers",c,"items",p])).reduce((p,m)=>{let{x:v,y:_,rotation:S}=m,{x:M,y:C}=gd(v,_,i,s,a);return Me.setAttributes(p,c,m.id,K({x:M,y:C,rotation:S+a})).updatedState},t)),t=wt.detectAndUpdateAreas(t,c).updatedState}),t=Iu.select(t,e).updatedState,{updatedState:t}}},Ie=class Pr{static create(t,e,r,i,s,o,a,l){let c=fn.acquireID(),{updatedState:h,vertex:f}=pe.add(t,e,i,s,"lines",c),{updatedState:g,vertex:p}=pe.add(h,e,o,a,"lines",c);t=g;let m=t.catalog.factoryElement(r,{id:c,name:Ma.generateName("lines",t.catalog.getIn(["elements",r,"info","title"])),vertices:ut([f.id,p.id]),type:r},l);return t=t.setIn(["scene","layers",e,"lines",c],m),{updatedState:t,line:m}}static select(t,e,r){t=wt.select(t,e).updatedState;let i=t.getIn(["scene","layers",e,"lines",r]);return t=wt.selectElement(t,e,"lines",r).updatedState,t=wt.selectElement(t,e,"vertices",i.vertices.get(0)).updatedState,t=wt.selectElement(t,e,"vertices",i.vertices.get(1)).updatedState,{updatedState:t}}static remove(t,e,r){let i=t.getIn(["scene","layers",e,"lines",r]);return i&&(t=this.unselect(t,e,r).updatedState,i.holes.forEach(s=>t=xe.remove(t,e,s).updatedState),t=wt.removeElement(t,e,"lines",r).updatedState,i.vertices.forEach(s=>t=pe.remove(t,e,s,"lines",r).updatedState),t.getIn(["scene","groups"]).forEach(s=>t=_e.removeElement(t,s.id,e,"lines",r).updatedState)),{updatedState:t}}static unselect(t,e,r){let i=t.getIn(["scene","layers",e,"lines",r]);return i&&(t=wt.unselect(t,e,"vertices",i.vertices.get(0)).updatedState,t=wt.unselect(t,e,"vertices",i.vertices.get(1)).updatedState,t=wt.unselect(t,e,"lines",r).updatedState),{updatedState:t}}static split(t,e,r,i,s){let o=t.getIn(["scene","layers",e,"lines",r]),a=t.getIn(["scene","layers",e,"vertices",o.vertices.get(0)]),l=t.getIn(["scene","layers",e,"vertices",o.vertices.get(1)]),{x:c,y:h}=a,{x:f,y:g}=l,{updatedState:p,line:m}=Pr.create(t,e,o.type,c,h,i,s,o.get("properties")),{updatedState:v,line:_}=Pr.create(p,e,o.type,f,g,i,s,o.get("properties"));t=v;let S=De(c,h,f,g,i,s),M=pa(a,l);return o.holes.forEach(O=>{let E=t.getIn(["scene","layers",e,"holes",O]),z=E.offset;if(M.x===f&&M.y===g&&(S=1-S,z=1-E.offset),z<S){let R=z/S;M.x===f&&M.y===g&&(R=1-R),t=xe.create(t,e,E.type,m.id,R,E.properties).updatedState}else{let R=(z-S)/(1-S);M.x===f&&M.y===g&&(R=1-R),t=xe.create(t,e,E.type,_.id,R,E.properties).updatedState}}),t.getIn(["scene","groups"]).filter(O=>{const E=O.getIn(["elements",e,"lines"]);return E&&E.contains(r)}).forEach(O=>{t=_e.addElement(t,O.id,e,"lines",m.id).updatedState,t=_e.addElement(t,O.id,e,"lines",_.id).updatedState}),t=Pr.remove(t,e,r).updatedState,{updatedState:t,lines:ut([m,_])}}static addFromPoints(t,e,r,i,s,o){i=ut(i).sort(({x:c,y:h},{x:f,y:g})=>c===f?h-g:c-f);let a=i.zip(i.skip(1)).filterNot(([{x:c,y:h},{x:f,y:g}])=>c===f&&h===g),l=[];return a.forEach(([{x:c,y:h},{x:f,y:g}])=>{let{updatedState:p,line:m}=this.create(t,e,r,c,h,f,g,s);t=p,o&&o.forEach(v=>{let{x:_,y:S}=v.offsetPosition;if(pv(c,h,f,g,_,S)){let M=De(c,h,f,g,_,S);M>=0&&M<=1&&(t=xe.create(t,e,v.hole.type,m.id,M,v.hole.properties).updatedState)}}),l.push(m)}),{updatedState:t,lines:ut(l)}}static createAvoidingIntersections(t,e,r,i,s,o,a,l,c){let h=[{x:i,y:s},{x:o,y:a}];t=t.getIn(["scene","layers",e,"lines"]).reduce((p,m)=>{var C,O;let[v,_]=m.vertices.map(E=>p.getIn(["scene","layers",e,"vertices"]).get(E)).toArray(),S=Dr(v,h[0])||Dr(v,h[1])||Dr(_,h[0])||Dr(_,h[1]),M=dv(h[0],h[1],v,_);if(M.type==="colinear"){c||(c=[]);const E=fo(h);p.getIn(["scene","layers",e,"lines",m.id,"holes"]).forEach(z=>{let R=p.getIn(["scene","layers",e,"holes",z]),k=Ve(v.x,v.y,_.x,_.y),L=Dr(E[1],m.vertices.get(1))?1-R.offset:R.offset,X=va(v.x,v.y,_.x,_.y,k*L);c.push({hole:R,offsetPosition:X})}),p=this.remove(p,e,m.id).updatedState,h.push(v,_)}return M.type==="intersecting"&&!S&&(p=this.split(p,e,m.id,((C=M.point)==null?void 0:C.x)??0,((O=M.point)==null?void 0:O.y)??0).updatedState,h.push(M.point??{x:0,y:0})),p},t);let{updatedState:f,lines:g}=Pr.addFromPoints(t,e,r,h,l,c);return{updatedState:f,lines:g}}static replaceVertex(t,e,r,i,s,o){let a=t.getIn(["scene","layers",e,"lines",r,"vertices",i]);t=pe.remove(t,e,a,"lines",r).updatedState;let{updatedState:l,vertex:c}=pe.add(t,e,s,o,"lines",r);return t=l,t=t.setIn(["scene","layers",e,"lines",r,"vertices",i],c.id),t=t.setIn(["scene","layers",e,"lines",r],t.getIn(["scene","layers",e,"lines",r])),{updatedState:t,line:t.getIn(["scene","layers",e,"lines",r]),vertex:c}}static selectToolDrawingLine(t,e){return t=t.merge({mode:Lr,drawingSupport:K({type:e})}),{updatedState:t}}static beginDrawingLine(t,e,r,i){let s=ql(t.scene,ut(),t.snapMask),o=null;t.snapMask&&!t.snapMask.isEmpty()&&(o=hn(s,r,i,t.snapMask),o&&({x:r,y:i}=o.point),s=s.withMutations(h=>{let f,g,p;({a:f,b:g,c:p}=ma(i)),xa(h,f,g,p,10,3,null),{a:f,b:g,c:p}=ya(r),xa(h,f,g,p,10,3,null)}));let a=t.get("drawingSupport").set("layerID",e);t=wt.unselectAll(t,e).updatedState;let{updatedState:l,line:c}=Pr.create(t,e,a.get("type"),r,i,r,i);return t=Pr.select(l,e,c.id).updatedState,t=t.merge({mode:or,snapElements:s,activeSnapElement:o?o.snap:null,drawingSupport:a}),{updatedState:t}}static updateDrawingLine(t,e,r){let i=null;t.snapMask&&!t.snapMask.isEmpty()&&(i=hn(t.snapElements,e,r,t.snapMask),i&&({x:e,y:r}=i.point));let s=t.getIn(["drawingSupport","layerID"]),o=t.getIn(["scene","layers",s,"selected","lines"]).first(),{updatedState:a}=Pr.replaceVertex(t,s,o,1,e,r);return t=a,t=this.select(t,s,o).updatedState,t=t.merge({activeSnapElement:i?i.snap:null}),{updatedState:t}}static endDrawingLine(t,e,r){if(t.snapMask&&!t.snapMask.isEmpty()){let c=hn(t.snapElements,e,r,t.snapMask);c&&({x:e,y:r}=c.point)}const i=t.getIn(["drawingSupport","layerID"]),s=t.getIn(["scene","layers",i]),o=t.getIn(["scene","layers",i,"selected","lines"]).first(),a=t.getIn(["scene","layers",i,"lines",o]),l=s.vertices.get(a.vertices.get(0));return t=Pr.remove(t,i,o).updatedState,t=Pr.createAvoidingIntersections(t,i,a.type,l.x,l.y,e,r).updatedState,t=wt.detectAndUpdateAreas(t,i).updatedState,t=t.merge({mode:Lr,snapElements:ut(),activeSnapElement:null}),{updatedState:t}}static beginDraggingLine(t,e,r,i,s){let o=ql(t.scene,ut(),t.snapMask),a=t.scene.layers.get(e),l=a.lines.get(r),c=a.vertices.get(l.vertices.get(0)),h=a.vertices.get(l.vertices.get(1));return t=t.merge({mode:Fr,snapElements:o,draggingSupport:K({layerID:e,lineID:r,startPointX:i,startPointY:s,startVertex0X:c.x,startVertex0Y:c.y,startVertex1X:h.x,startVertex1Y:h.y})}),{updatedState:t}}static updateDraggingLine(t,e,r){let i=t.draggingSupport,s=t.snapElements,o=i.get("layerID"),a=i.get("lineID"),l=e-i.get("startPointX"),c=r-i.get("startPointY"),h=i.get("startVertex0X")+l,f=i.get("startVertex0Y")+c,g=i.get("startVertex1X")+l,p=i.get("startVertex1Y")+c,m=null,v=null,_=null;t.snapMask&&!t.snapMask.isEmpty()&&(v=hn(s,h,f,t.snapMask),_=hn(s,g,p,t.snapMask));let S=0,M=0;return v&&_?v.point.distance<_.point.distance?(S=v.point.x-h,M=v.point.y-f,m=v.snap):(S=_.point.x-g,M=_.point.y-p,m=_.snap):(v&&(S=v.point.x-h,M=v.point.y-f,m=v.snap),_&&(S=_.point.x-g,M=_.point.y-p,m=_.snap)),h+=S,f+=M,g+=S,p+=M,t=t.merge({activeSnapElement:m,scene:t.scene.updateIn(["layers",o],C=>C.withMutations(O=>{let E=O.getIn(["lines",a,"vertices"]);return O.updateIn(["vertices",E.get(0)],z=>z.merge({x:h,y:f})),O.updateIn(["vertices",E.get(1)],z=>z.merge({x:g,y:p})),O}))}),{updatedState:t}}static endDraggingLine(t,e,r){let{draggingSupport:i}=t,s=i.get("layerID"),o=t.scene.layers.get(s),a=i.get("lineID"),l=o.lines.get(a),c=o.vertices.get(l.vertices.get(0)),h=o.vertices.get(l.vertices.get(1)),f=Il(c,h),g=pa(c,h),p=ga(g,f),m=Math.atan2(f.y-g.y,f.x-g.x),v=[];o.lines.get(a).holes.forEach(R=>{let k=o.holes.get(R),L=p*k.offset,X={x:L*Math.cos(m)+g.x,y:L*Math.sin(m)+g.y};v.push({hole:k,offsetPosition:X})});let _=e-i.get("startPointX"),S=r-i.get("startPointY"),M=i.get("startVertex0X")+_,C=i.get("startVertex0Y")+S,O=i.get("startVertex1X")+_,E=i.get("startVertex1Y")+S;if(t.snapMask&&!t.snapMask.isEmpty()){let R=hn(t.snapElements,M,C,t.snapMask),k=hn(t.snapElements,O,E,t.snapMask),L=0,X=0;R&&k?R.point.distance<k.point.distance?(L=R.point.x-M,X=R.point.y-C):(L=k.point.x-O,X=k.point.y-E):(R&&(L=R.point.x-M,X=R.point.y-C),k&&(L=k.point.x-O,X=k.point.y-E)),M+=L,C+=X,O+=L,E+=X}let z=t.getIn(["scene","groups"]).filter(R=>{const k=R.getIn(["elements",s,"lines"]);return k&&k.contains(a)});if(t=wt.mergeEqualsVertices(t,s,l.vertices.get(0)).updatedState,t=wt.mergeEqualsVertices(t,s,l.vertices.get(1)).updatedState,t=Pr.remove(t,s,a).updatedState,!Dr({x:M,y:C},{x:O,y:E})){let R=Pr.createAvoidingIntersections(t,s,l.type,M,C,O,E,l.properties,v);t=R.updatedState,R.lines.forEach(k=>{z.forEach(L=>{t=_e.addElement(t,L.id,s,"lines",k.id).updatedState})})}return t=wt.detectAndUpdateAreas(t,s).updatedState,t=t.merge({mode:fe,draggingSupport:null,activeSnapElement:null,snapElements:ut()}),{updatedState:t}}static setProperties(t,e,r,i){return t=t.mergeIn(["scene","layers",e,"lines",r,"properties"],i),{updatedState:t}}static setJsProperties(t,e,r,i){return this.setProperties(t,e,r,Xt(i))}static updateProperties(t,e,r,i){return i.forEach((s,o)=>{t.hasIn(["scene","layers",e,"lines",r,"properties",o])&&(t=t.mergeIn(["scene","layers",e,"lines",r,"properties",o],s))}),{updatedState:t}}static updateJsProperties(t,e,r,i){return this.updateProperties(t,e,r,Xt(i))}static setAttributes(t,e,r,i){let s=i.toJS(),{vertexOne:o,vertexTwo:a,lineLength:l}=s;return delete s.vertexOne,delete s.vertexTwo,delete s.lineLength,t=t.mergeIn(["scene","layers",e,"lines",r],Xt(s)).mergeIn(["scene","layers",e,"vertices",o.id],{x:o.x,y:o.y}).mergeIn(["scene","layers",e,"vertices",a.id],{x:a.x,y:a.y}).mergeIn(["scene","layers",e,"lines",r,"misc"],K({_unitLength:l._unit})),t=wt.mergeEqualsVertices(t,e,o.id).updatedState,o.x!=a.x&&o.y!=a.y&&(t=wt.mergeEqualsVertices(t,e,a.id).updatedState),t=wt.detectAndUpdateAreas(t,e).updatedState,{updatedState:t}}static setVerticesCoords(t,e,r,i,s,o,a){let l=t.getIn(["scene","layers",e,"lines",r]);return t=pe.setAttributes(t,e,l.vertices.get(0),K({x:i,y:s})).updatedState,t=pe.setAttributes(t,e,l.vertices.get(1),K({x:o,y:a})).updatedState,{updatedState:t}}},pe=class{static add(t,e,r,i,s,o){let a=t.getIn(["scene","layers",e,"vertices"]).find(l=>Dr(l,{x:r,y:i}));return a?a=a.update(s,l=>l.push(o)):a=new vd({id:fn.acquireID(),name:"Vertex",x:r,y:i,[s]:ut([o])}),t=t.setIn(["scene","layers",e,"vertices",a.id],a),{updatedState:t,vertex:a}}static setAttributes(t,e,r,i){return t=t.mergeIn(["scene","layers",e,"vertices",r],i),{updatedState:t}}static addElement(t,e,r,i,s){return t=t.updateIn(["scene","layers",e,"vertices",r,i],o=>o.push(s)),{updatedState:t}}static removeElement(t,e,r,i,s){let o=t.getIn(["scene","layers",e,"vertices",r,i]).findIndex(a=>a===s);return o!==-1&&(t=t.updateIn(["scene","layers",e,"vertices",r,i],a=>a.remove(o))),{updatedState:t}}static select(t,e,r){return t=t.setIn(["scene","layers",e,"vertices",r,"selected"],!0),t=t.updateIn(["scene","layers",e,"selected","vertices"],i=>i.push(r)),{updatedState:t}}static unselect(t,e,r){return t=t.setIn(["scene","layers",e,"vertices",r,"selected"],!1),t=t.updateIn(["scene","layers",e,"selected","vertices"],i=>i.filter(s=>s.id!==r)),{updatedState:t}}static remove(t,e,r,i,s,o){let a=t.getIn(["scene","layers",e,"vertices",r]);return a&&(i&&s&&(a=a.update(i,c=>{let h=c.findIndex(f=>s===f);return c.delete(h)})),(a.areas.size||a.lines.size)&&!o?t=t.setIn(["scene","layers",e,"vertices",r],a):t=t.deleteIn(["scene","layers",e,"vertices",r])),{updatedState:t}}static beginDraggingVertex(t,e,r){let i=ql(t.scene,ut(),t.snapMask);return t=t.merge({mode:Nr,snapElements:i,draggingSupport:K({layerID:e,vertexID:r,previousMode:t.get("mode")})}),{updatedState:t}}static updateDraggingVertex(t,e,r){let{draggingSupport:i,snapElements:s,scene:o}=t,a=null;t.snapMask&&!t.snapMask.isEmpty()&&(a=hn(s,e,r,t.snapMask),a&&({x:e,y:r}=a.point));let l=i.get("layerID"),c=i.get("vertexID");return t=t.merge({activeSnapElement:a?a.snap:null,scene:o.mergeIn(["layers",l,"vertices",c],{x:e,y:r})}),{updatedState:t}}static endDraggingVertex(t){let{draggingSupport:e}=t,r=e.get("layerID"),i=e.get("vertexID"),s=t.getIn(["scene","layers",r,"vertices",i,"lines"]);return s&&(t=s.reduce((o,a)=>{if(!o.getIn(["scene","layers",r,"lines",a]))return o;let l=o.getIn(["scene","layers",r,"lines",a,"vertices",0]),c=o.getIn(["scene","layers",r,"lines",a,"vertices",1]),h=l===i?c:l,f=o.getIn(["scene","layers",r,"vertices",h]),g=o.getIn(["scene","layers",r,"vertices",i]),p=[],m=fo([f,g]);o.getIn(["scene","layers",r,"lines",a,"holes"]).forEach(M=>{let C=o.getIn(["scene","layers",r,"holes",M]),O=Ve(f.x,f.y,g.x,g.y),E=Dr(m[1],o.getIn(["scene","layers",r,"lines",a,"vertices",1]))?1-C.offset:C.offset,z=va(f.x,f.y,g.x,g.y,O*E);p.push({hole:C,offsetPosition:z})});let v=o.getIn(["scene","layers",r,"lines",a,"type"]),_=o.getIn(["scene","layers",r,"lines",a,"properties"]),S=o.getIn(["scene","groups"]).filter(M=>{const C=M.getIn(["elements",r,"lines"]);return C&&C.contains(a)});if(o=wt.removeZeroLengthLines(o,r).updatedState,o=wt.mergeEqualsVertices(o,r,i).updatedState,o=Ie.remove(o,r,a).updatedState,!Dr(f,g)){let M=Ie.createAvoidingIntersections(o,r,v,f.x,f.y,g.x,g.y,_,p);o=M.updatedState,M.lines.forEach(C=>{S.forEach(O=>{o=_e.addElement(o,O.id,r,"lines",C.id).updatedState})})}return o},t)),t=wt.detectAndUpdateAreas(t,r).updatedState,t=t.merge({mode:e.get("previousMode"),draggingSupport:null,activeSnapElement:null,snapElements:ut()}),{updatedState:t}}},xi=class{static add(t,e,r,i,s){let o,a=t.getIn(["scene","layers",e]);return a=a.withMutations(l=>{const c=fn.acquireID(),h=i.map(f=>pe.add(t,e,f.x,f.y,"areas",c).vertex.id);o=s.factoryElement(r,{id:c,name:Ma.generateName("areas",s.getIn(["elements",r,"info","title"])),type:r,prototype:"areas",vertices:h}),l.setIn(["areas",c],o)}),t=t.setIn(["scene","layers",e],a),{updatedState:t,area:o}}static select(t,e,r){return t=wt.select(t,e).updatedState,t=wt.selectElement(t,e,"areas",r).updatedState,{updatedState:t}}static remove(t,e,r){let i=t.getIn(["scene","layers",e,"areas",r]);return i.get("selected")===!0&&(t=this.unselect(t,e,r).updatedState),i.vertices.forEach(s=>{t=pe.remove(t,e,s,"areas",r).updatedState}),t=t.deleteIn(["scene","layers",e,"areas",r]),t.getIn(["scene","groups"]).forEach(s=>t=_e.removeElement(t,s.id,e,"areas",r).updatedState),{updatedState:t}}static unselect(t,e,r){return t=wt.unselect(t,e,"areas",r).updatedState,{updatedState:t}}static setProperties(t,e,r,i){return t=t.mergeIn(["scene","layers",e,"areas",r,"properties"],i),{updatedState:t}}static setJsProperties(t,e,r,i){return this.setProperties(t,e,r,Xt(i))}static updateProperties(t,e,r,i){return i.forEach((s,o)=>{t.hasIn(["scene","layers",e,"areas",r,"properties",o])&&(t=t.mergeIn(["scene","layers",e,"areas",r,"properties",o],s))}),{updatedState:t}}static updateJsProperties(t,e,r,i){return this.updateProperties(t,e,r,Xt(i))}static setAttributes(t){return{updatedState:t}}};const Xd=(n,t)=>n.size===t.size&&n.isSuperset(t)&&n.isSubset(t);let wt=class{static create(t,e,r){let i=fn.acquireID();e=e||`layer ${i}`,r=r||0;let s=new Vl({id:i,name:e,altitude:r});return t=t.setIn(["scene","selectedLayer"],i),t=t.setIn(["scene","layers",i],s),{updatedState:t}}static select(t,e){return t.get("alterate")||(t=Jt.unselectAll(t).updatedState),t=t.setIn(["scene","selectedLayer"],e),{updatedState:t}}static selectElement(t,e,r,i){return t=t.setIn(["scene","layers",e,r,i,"selected"],!0),t=t.updateIn(["scene","layers",e,"selected",r],s=>s.push(i)),{updatedState:t}}static unselect(t,e,r,i){return t=t.setIn(["scene","layers",e,r,i,"selected"],!1),t=t.updateIn(["scene","layers",e,"selected",r],s=>s.filter(o=>o.id===i)),{updatedState:t}}static unselectAll(t,e){let{lines:r,holes:i,items:s,areas:o}=t.getIn(["scene","layers",e]);return r&&r.forEach(a=>{t=Ie.unselect(t,e,a.id).updatedState}),i&&i.forEach(a=>{t=xe.unselect(t,e,a.id).updatedState}),s&&s.forEach(a=>{t=Me.unselect(t,e,a.id).updatedState}),o&&o.forEach(a=>{t=xi.unselect(t,e,a.id).updatedState}),{updatedState:t}}static setProperties(t,e,r){return t=t.mergeIn(["scene","layers",e],r),t=t.updateIn(["scene","layers"],i=>i.sort((s,o)=>s.altitude!==o.altitude?s.altitude-o.altitude:s.order-o.order)),{updatedState:t}}static remove(t,e){return t=t.removeIn(["scene","layers",e]),t=t.setIn(["scene","selectedLayer"],t.scene.selectedLayer!==e?t.scene.selectedLayer:t.scene.layers.first().id),{updatedState:t}}static removeElement(t,e,r,i){return t=t.deleteIn(["scene","layers",e,r,i]),{updatedState:t}}static detectAndUpdateAreas(t,e){let r=[],i,s={},o={};t.getIn(["scene","layers",e,"vertices"]).forEach(p=>{let v=r.push([p.x,p.y])-1;s[p.id]=v,o[v]=p.id}),i=t.getIn(["scene","layers",e,"lines"]).map(p=>p.vertices.map(m=>s[m]).toArray());const a=$v(r,i);let l=ut(a).map(p=>ut(p.map(m=>o[m])));l=l.map(p=>Hv(p.map(m=>t.getIn(["scene","layers",e,"vertices",m])))?p.reverse():p);const c=[];t.getIn(["scene","layers",e,"areas"]).forEach(p=>{l.some(v=>Xd(v,p.vertices))||(t=xi.remove(t,e,p.id).updatedState)}),l.forEach((p,m)=>{const v=t.getIn(["scene","layers",e,"areas"]).find(_=>Xd(_.vertices,p));if(v)c[m]=v.id,t=t.setIn(["scene","layers",e,"areas",c[m],"holes"],ut());else{const _=p.map(M=>t.getIn(["scene","layers",e,"vertices",M])),S=xi.add(t,e,"area",_,t.catalog);c[m]=S.area.id,t=S.updatedState}});let h=c.map(p=>{let m=t.getIn(["scene","layers",e,"areas",p]).vertices.map(v=>{let{x:_,y:S}=t.getIn(["scene","layers",e,"vertices",v]);return ut([_,S])});return{id:p,vertices:m}}),f,g;for(f=0;f<h.length;f++){let p=ut(),m=h[f].vertices.flatten().toArray();for(g=0;g<h.length;g++)f!==g&&xv(m,h[g].vertices.get(0).get(0),h[g].vertices.get(0).get(1))&&(p=p.push(h[g].id));t=t.setIn(["scene","layers",e,"areas",h[f].id,"holes"],p)}return c.forEach(p=>{let m=new Set,v=t.getIn(["scene","layers",e,"areas",p,"holes"]);v.forEach(_=>{t.getIn(["scene","layers",e,"areas",_,"holes"]).forEach(M=>{v.indexOf(M)!==-1&&m.add(M)})}),m.forEach(_=>{v=v.remove(v.indexOf(_))}),t=t.setIn(["scene","layers",e,"areas",p,"holes"],v)}),{updatedState:t}}static removeZeroLengthLines(t,e){return{updatedState:t.getIn(["scene","layers",e,"lines"]).reduce((i,s)=>{let o=s.getIn(["vertices",0]),a=s.getIn(["vertices",1]),l=i.getIn(["scene","layers",e,"vertices",o]),c=i.getIn(["scene","layers",e,"vertices",a]);return ga(l,c)===0&&(i=Ie.remove(i,e,s.id).updatedState),i},t)}}static mergeEqualsVertices(t,e,r){let i=t.getIn(["scene","layers",e,"vertices",r]),s=t.getIn(["scene","layers",e,"vertices"]).filter(o=>o.id!==r&&Dr(i,o));return s.isEmpty()?{updatedState:t}:(s.forEach(o=>{let a=o.lines.reduce((c,h)=>(c=c.updateIn(["scene","layers",e,"lines",h,"vertices"],f=>{if(f)return f.map(g=>g===o.id?r:g)}),c=pe.addElement(c,e,r,"lines",h).updatedState,c),t),l=o.areas.reduce((c,h)=>(c=c.updateIn(["scene","layers",e,"areas",h,"vertices"],f=>{if(f)return f.map(g=>g===o.id?r:g)}),c=pe.addElement(c,e,r,"areas",h).updatedState,c),a);t=pe.remove(l,e,o.id,null,null,!0).updatedState}),{updatedState:t})}static setPropertiesOnSelected(t,e,r){let i=t.getIn(["scene","layers",e,"selected"]);return i.lines.forEach(s=>t=Ie.setProperties(t,e,s,r).updatedState),i.holes.forEach(s=>t=xe.setProperties(t,e,s,r).updatedState),i.areas.forEach(s=>t=xi.setProperties(t,e,s,r).updatedState),i.items.forEach(s=>t=Me.setProperties(t,e,s,r).updatedState),{updatedState:t}}static updatePropertiesOnSelected(t,e,r){let i=t.getIn(["scene","layers",e,"selected"]);return i.lines.forEach(s=>t=Ie.updateProperties(t,e,s,r).updatedState),i.holes.forEach(s=>t=xe.updateProperties(t,e,s,r).updatedState),i.areas.forEach(s=>t=xi.updateProperties(t,e,s,r).updatedState),i.items.forEach(s=>t=Me.updateProperties(t,e,s,r).updatedState),{updatedState:t}}static setAttributesOnSelected(t,e,r){let i=t.getIn(["scene","layers",e,"selected"]);return i.lines.forEach(s=>t=Ie.setAttributes(t,e,s,r).updatedState),i.holes.forEach(s=>t=xe.setAttributes(t,e,s,r).updatedState),i.items.forEach(s=>t=Me.setAttributes(t,e,s,r).updatedState),{updatedState:t}}};class Aa{static create(t,e){let r=fn.acquireID();return t=t.setIn(["scene","guides","horizontal",r],e),{updatedState:t}}static remove(t,e){return t=t.deleteIn(["scene","guides","horizontal",e]),{updatedState:t}}}class Oa{static create(t,e){let r=fn.acquireID();return t=t.setIn(["scene","guides","vertical",r],e),{updatedState:t}}static remove(t,e){return t=t.deleteIn(["scene","guides","vertical",e]),{updatedState:t}}}class Jt{static setAlterate(t){return{updatedState:t.set("alterate",!t.alterate)}}static openCatalog(t){return t=this.setMode(t,zl).updatedState,{updatedState:t}}static newProject(t){return t=new ba({viewer2D:t.get("viewer2D")}),{updatedState:t}}static loadProject(t,e){return t=new ba({scene:e,catalog:t.catalog.toJS()}),{updatedState:t}}static setProperties(t,e,r){return t=wt.setPropertiesOnSelected(t,e,r).updatedState,{updatedState:t}}static updateProperties(t,e,r){return t=wt.updatePropertiesOnSelected(t,e,r).updatedState,{updatedState:t}}static setItemsAttributes(t,e){return t.getIn(["scene","layers"]).forEach(r=>{t=wt.setAttributesOnSelected(t,r.id,e).updatedState}),{updatedState:t}}static setLinesAttributes(t,e){return t.getIn(["scene","layers"]).forEach(r=>{t=wt.setAttributesOnSelected(t,r.id,e).updatedState}),{updatedState:t}}static setHolesAttributes(t,e){return t.getIn(["scene","layers"]).forEach(r=>{t=wt.setAttributesOnSelected(t,r.id,e).updatedState}),{updatedState:t}}static unselectAll(t){return t.getIn(["scene","layers"]).forEach(({id:e})=>{t=wt.unselectAll(t,e).updatedState}),t.getIn(["scene","groups"]).forEach(e=>{t=_e.unselect(t,e.get("id")).updatedState}),{updatedState:t}}static remove(t){let e=t.getIn(["scene","selectedLayer"]),{lines:r,holes:i,items:s}=t.getIn(["scene","layers",e,"selected"]);return t=wt.unselectAll(t,e).updatedState,r.forEach(o=>{t=Ie.remove(t,e,o).updatedState}),i.forEach(o=>{t=xe.remove(t,e,o).updatedState}),s.forEach(o=>{t=Me.remove(t,e,o).updatedState}),t=wt.detectAndUpdateAreas(t,e).updatedState,{updatedState:t}}static undo(t){let e=t.sceneHistory;return t.scene===e.last&&e.list.size>1&&(e=Nd(e)),t=t.merge({mode:fe,scene:e.last,sceneHistory:Nd(e)}),{updatedState:t}}static redo(t){let e=t.sceneHistory;return t.scene===e.last&&e.redoList.size>0&&(e=rx(e)),t=t.merge({mode:fe,scene:e.last,sceneHistory:e}),{updatedState:t}}static rollback(t){let e=t.sceneHistory;return!e.last&&e.list.isEmpty()?{updatedState:t}:(t=this.unselectAll(t).updatedState,t=t.merge({mode:fe,scene:e.last,sceneHistory:de(e,e.last),snapElements:ut(),activeSnapElement:null,drawingSupport:K(),draggingSupport:K(),rotatingSupport:K()}),{updatedState:t})}static setProjectProperties(t,e){let r=t.scene.merge(e);return t=t.merge({mode:fe,scene:r}),{updatedState:t}}static openProjectConfigurator(t){return t=t.merge({mode:fd}),{updatedState:t}}static initCatalog(t,e){return t=t.set("catalog",new Bl(e)),{updatedState:t}}static updateMouseCoord(t,e){return t=t.set("mouse",K(e)),{updatedState:t}}static updateZoomScale(t,e){return t=t.set("zoom",e),{updatedState:t}}static toggleSnap(t,e){return t=t.set("snapMask",e),{updatedState:t}}static throwError(t,e){return t=t.set("errors",t.get("errors").push({date:Date.now(),error:e})),{updatedState:t}}static throwWarning(t,e){return t=t.set("warnings",t.get("warnings").push({date:Date.now(),warning:e})),{updatedState:t}}static copyProperties(t,e){return t=t.set("clipboardProperties",e),{updatedState:t}}static pasteProperties(t){return t=this.updateProperties(t,t.getIn(["scene","selectedLayer"]),t.get("clipboardProperties")).updatedState,{updatedState:t}}static pushLastSelectedCatalogElementToHistory(t,e){let r=t.selectedElementsHistory,i=r.findIndex(s=>s.name===e.name);return i!==-1&&(r=r.splice(i,1)),r=r.splice(0,0,e),t=t.set("selectedElementsHistory",r),{updatedState:t}}static changeCatalogPage(t,e,r){return t=t.setIn(["catalog","page"],r).updateIn(["catalog","path"],i=>i.push(e)),{updatedState:t}}static goBackToCatalogPage(t,e){let r=t.catalog.path.findIndex(i=>i===e);return t=t.setIn(["catalog","page"],e).updateIn(["catalog","path"],i=>i.take(r)),{updatedState:t}}static setMode(t,e){return t=t.set("mode",e),{updatedState:t}}static addHorizontalGuide(t,e){return t=Aa.create(t,e).updatedState,{updatedState:t}}static addVerticalGuide(t,e){return t=Oa.create(t,e).updatedState,{updatedState:t}}static addCircularGuide(t,e,r,i){return console.log("adding horizontal guide at",e,r,i),{updatedState:t}}static removeHorizontalGuide(t,e){return t=Aa.remove(t,e).updatedState,{updatedState:t}}static removeVerticalGuide(t,e){return t=Oa.remove(t,e).updatedState,{updatedState:t}}static removeCircularGuide(t,e){return console.log("removeing horizontal guide ",e),{updatedState:t}}}var za={exports:{}},Ta={exports:{}},$t={};/** @license React v16.13.1
|
|
45
|
+
*/var As="delete",Vt=5,qe=1<<Vt,ke=qe-1,Tt={};function pu(){return{value:!1}}function ir(n){n&&(n.value=!0)}function gu(){}function mi(n){return n.size===void 0&&(n.size=n.__iterate(Hh)),n.size}function An(n,t){if(typeof t!="number"){var e=t>>>0;if(""+e!==t||e===4294967295)return NaN;t=e}return t<0?mi(n)+t:t}function Hh(){return!0}function Os(n,t,e){return(n===0&&!Wh(n)||e!==void 0&&n<=-e)&&(t===void 0||e!==void 0&&t>=e)}function yi(n,t){return Gh(n,t,0)}function zs(n,t){return Gh(n,t,t)}function Gh(n,t,e){return n===void 0?e:Wh(n)?t===1/0?t:Math.max(0,t+n)|0:t===void 0||t===n?n:Math.min(t,n)|0}function Wh(n){return n<0||n===0&&1/n===-1/0}var Uh="@@__IMMUTABLE_ITERABLE__@@";function Fe(n){return!!(n&&n[Uh])}var Co="@@__IMMUTABLE_KEYED__@@";function Gt(n){return!!(n&&n[Co])}var ko="@@__IMMUTABLE_INDEXED__@@";function je(n){return!!(n&&n[ko])}function Io(n){return Gt(n)||je(n)}var ye=function(t){return Fe(t)?t:de(t)},sr=(function(n){function t(e){return Gt(e)?e:Tn(e)}return n&&(t.__proto__=n),t.prototype=Object.create(n&&n.prototype),t.prototype.constructor=t,t})(ye),Gn=(function(n){function t(e){return je(e)?e:ar(e)}return n&&(t.__proto__=n),t.prototype=Object.create(n&&n.prototype),t.prototype.constructor=t,t})(ye),vi=(function(n){function t(e){return Fe(e)&&!Io(e)?e:bi(e)}return n&&(t.__proto__=n),t.prototype=Object.create(n&&n.prototype),t.prototype.constructor=t,t})(ye);ye.Keyed=sr,ye.Indexed=Gn,ye.Set=vi;var Yh="@@__IMMUTABLE_SEQ__@@";function Po(n){return!!(n&&n[Yh])}var Xh="@@__IMMUTABLE_RECORD__@@";function On(n){return!!(n&&n[Xh])}function or(n){return Fe(n)||On(n)}var zn="@@__IMMUTABLE_ORDERED__@@";function vr(n){return!!(n&&n[zn])}var xi=0,$e=1,He=2,mu=typeof Symbol=="function"&&Symbol.iterator,Jh="@@iterator",Ro=mu||Jh,Ct=function(t){this.next=t};Ct.prototype.toString=function(){return"[Iterator]"},Ct.KEYS=xi,Ct.VALUES=$e,Ct.ENTRIES=He,Ct.prototype.inspect=Ct.prototype.toSource=function(){return this.toString()},Ct.prototype[Ro]=function(){return this};function Yt(n,t,e,r){var i=n===xi?t:n===$e?e:[t,e];return r?r.value=i:r={value:i,done:!1},r}function Ee(){return{value:void 0,done:!0}}function yu(n){return Array.isArray(n)?!0:!!Lo(n)}function Zh(n){return n&&typeof n.next=="function"}function vu(n){var t=Lo(n);return t&&t.call(n)}function Lo(n){var t=n&&(mu&&n[mu]||n[Jh]);if(typeof t=="function")return t}function u0(n){var t=Lo(n);return t&&t===n.entries}function l0(n){var t=Lo(n);return t&&t===n.keys}var _i=Object.prototype.hasOwnProperty;function xu(n){return Array.isArray(n)||typeof n=="string"?!0:n&&typeof n=="object"&&Number.isInteger(n.length)&&n.length>=0&&(n.length===0?Object.keys(n).length===1:n.hasOwnProperty(n.length-1))}var de=(function(n){function t(e){return e==null?bu():or(e)?e.toSeq():h0(e)}return n&&(t.__proto__=n),t.prototype=Object.create(n&&n.prototype),t.prototype.constructor=t,t.prototype.toSeq=function(){return this},t.prototype.toString=function(){return this.__toString("Seq {","}")},t.prototype.cacheResult=function(){return!this._cache&&this.__iterateUncached&&(this._cache=this.entrySeq().toArray(),this.size=this._cache.length),this},t.prototype.__iterate=function(r,i){var s=this._cache;if(s){for(var o=s.length,a=0;a!==o;){var l=s[i?o-++a:a++];if(r(l[1],l[0],this)===!1)break}return a}return this.__iterateUncached(r,i)},t.prototype.__iterator=function(r,i){var s=this._cache;if(s){var o=s.length,a=0;return new Ct(function(){if(a===o)return Ee();var l=s[i?o-++a:a++];return Yt(r,l[0],l[1])})}return this.__iteratorUncached(r,i)},t})(ye),Tn=(function(n){function t(e){return e==null?bu().toKeyedSeq():Fe(e)?Gt(e)?e.toSeq():e.fromEntrySeq():On(e)?e.toSeq():wu(e)}return n&&(t.__proto__=n),t.prototype=Object.create(n&&n.prototype),t.prototype.constructor=t,t.prototype.toKeyedSeq=function(){return this},t})(de),ar=(function(n){function t(e){return e==null?bu():Fe(e)?Gt(e)?e.entrySeq():e.toIndexedSeq():On(e)?e.toSeq().entrySeq():Qh(e)}return n&&(t.__proto__=n),t.prototype=Object.create(n&&n.prototype),t.prototype.constructor=t,t.of=function(){return t(arguments)},t.prototype.toIndexedSeq=function(){return this},t.prototype.toString=function(){return this.__toString("Seq [","]")},t})(de),bi=(function(n){function t(e){return(Fe(e)&&!Io(e)?e:ar(e)).toSetSeq()}return n&&(t.__proto__=n),t.prototype=Object.create(n&&n.prototype),t.prototype.constructor=t,t.of=function(){return t(arguments)},t.prototype.toSetSeq=function(){return this},t})(de);de.isSeq=Po,de.Keyed=Tn,de.Set=bi,de.Indexed=ar,de.prototype[Yh]=!0;var wi=(function(n){function t(e){this._array=e,this.size=e.length}return n&&(t.__proto__=n),t.prototype=Object.create(n&&n.prototype),t.prototype.constructor=t,t.prototype.get=function(r,i){return this.has(r)?this._array[An(this,r)]:i},t.prototype.__iterate=function(r,i){for(var s=this._array,o=s.length,a=0;a!==o;){var l=i?o-++a:a++;if(r(s[l],l,this)===!1)break}return a},t.prototype.__iterator=function(r,i){var s=this._array,o=s.length,a=0;return new Ct(function(){if(a===o)return Ee();var l=i?o-++a:a++;return Yt(r,l,s[l])})},t})(ar),_u=(function(n){function t(e){var r=Object.keys(e).concat(Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e):[]);this._object=e,this._keys=r,this.size=r.length}return n&&(t.__proto__=n),t.prototype=Object.create(n&&n.prototype),t.prototype.constructor=t,t.prototype.get=function(r,i){return i!==void 0&&!this.has(r)?i:this._object[r]},t.prototype.has=function(r){return _i.call(this._object,r)},t.prototype.__iterate=function(r,i){for(var s=this._object,o=this._keys,a=o.length,l=0;l!==a;){var c=o[i?a-++l:l++];if(r(s[c],c,this)===!1)break}return l},t.prototype.__iterator=function(r,i){var s=this._object,o=this._keys,a=o.length,l=0;return new Ct(function(){if(l===a)return Ee();var c=o[i?a-++l:l++];return Yt(r,c,s[c])})},t})(Tn);_u.prototype[zn]=!0;var c0=(function(n){function t(e){this._collection=e,this.size=e.length||e.size}return n&&(t.__proto__=n),t.prototype=Object.create(n&&n.prototype),t.prototype.constructor=t,t.prototype.__iterateUncached=function(r,i){if(i)return this.cacheResult().__iterate(r,i);var s=this._collection,o=vu(s),a=0;if(Zh(o))for(var l;!(l=o.next()).done&&r(l.value,a++,this)!==!1;);return a},t.prototype.__iteratorUncached=function(r,i){if(i)return this.cacheResult().__iterator(r,i);var s=this._collection,o=vu(s);if(!Zh(o))return new Ct(Ee);var a=0;return new Ct(function(){var l=o.next();return l.done?l:Yt(r,a++,l.value)})},t})(ar),Kh;function bu(){return Kh||(Kh=new wi([]))}function wu(n){var t=Su(n);if(t)return t.fromEntrySeq();if(typeof n=="object")return new _u(n);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+n)}function Qh(n){var t=Su(n);if(t)return t;throw new TypeError("Expected Array or collection object of values: "+n)}function h0(n){var t=Su(n);if(t)return u0(n)?t.fromEntrySeq():l0(n)?t.toSetSeq():t;if(typeof n=="object")return new _u(n);throw new TypeError("Expected Array or collection object of values, or keyed object: "+n)}function Su(n){return xu(n)?new wi(n):yu(n)?new c0(n):void 0}var tf="@@__IMMUTABLE_MAP__@@";function No(n){return!!(n&&n[tf])}function Mu(n){return No(n)&&vr(n)}function Eu(n){return!!(n&&typeof n.equals=="function"&&typeof n.hashCode=="function")}function ve(n,t){if(n===t||n!==n&&t!==t)return!0;if(!n||!t)return!1;if(typeof n.valueOf=="function"&&typeof t.valueOf=="function"){if(n=n.valueOf(),t=t.valueOf(),n===t||n!==n&&t!==t)return!0;if(!n||!t)return!1}return!!(Eu(n)&&Eu(t)&&n.equals(t))}var Ts=typeof Math.imul=="function"&&Math.imul(4294967295,2)===-2?Math.imul:function(t,e){t|=0,e|=0;var r=t&65535,i=e&65535;return r*i+((t>>>16)*i+r*(e>>>16)<<16>>>0)|0};function Fo(n){return n>>>1&1073741824|n&3221225471}var f0=Object.prototype.valueOf;function Ve(n){if(n==null)return ef(n);if(typeof n.hashCode=="function")return Fo(n.hashCode(n));var t=v0(n);if(t==null)return ef(t);switch(typeof t){case"boolean":return t?1108378657:1108378656;case"number":return d0(t);case"string":return t.length>x0?p0(t):Au(t);case"object":case"function":return m0(t);case"symbol":return g0(t);default:if(typeof t.toString=="function")return Au(t.toString());throw new Error("Value type "+typeof t+" cannot be hashed.")}}function ef(n){return n===null?1108378658:1108378659}function d0(n){if(n!==n||n===1/0)return 0;var t=n|0;for(t!==n&&(t^=n*4294967295);n>4294967295;)n/=4294967295,t^=n;return Fo(t)}function p0(n){var t=ku[n];return t===void 0&&(t=Au(n),Cu===_0&&(Cu=0,ku={}),Cu++,ku[n]=t),t}function Au(n){for(var t=0,e=0;e<n.length;e++)t=31*t+n.charCodeAt(e)|0;return Fo(t)}function g0(n){var t=of[n];return t!==void 0||(t=sf(),of[n]=t),t}function m0(n){var t;if(Ou&&(t=zu.get(n),t!==void 0)||(t=n[Wn],t!==void 0)||!nf&&(t=n.propertyIsEnumerable&&n.propertyIsEnumerable[Wn],t!==void 0||(t=y0(n),t!==void 0)))return t;if(t=sf(),Ou)zu.set(n,t);else{if(rf!==void 0&&rf(n)===!1)throw new Error("Non-extensible objects are not allowed as keys.");if(nf)Object.defineProperty(n,Wn,{enumerable:!1,configurable:!1,writable:!1,value:t});else if(n.propertyIsEnumerable!==void 0&&n.propertyIsEnumerable===n.constructor.prototype.propertyIsEnumerable)n.propertyIsEnumerable=function(){return this.constructor.prototype.propertyIsEnumerable.apply(this,arguments)},n.propertyIsEnumerable[Wn]=t;else if(n.nodeType!==void 0)n[Wn]=t;else throw new Error("Unable to set a non-enumerable property on object.")}return t}var rf=Object.isExtensible,nf=(function(){try{return Object.defineProperty({},"@",{}),!0}catch{return!1}})();function y0(n){if(n&&n.nodeType>0)switch(n.nodeType){case 1:return n.uniqueID;case 9:return n.documentElement&&n.documentElement.uniqueID}}function v0(n){return n.valueOf!==f0&&typeof n.valueOf=="function"?n.valueOf(n):n}function sf(){var n=++Tu;return Tu&1073741824&&(Tu=0),n}var Ou=typeof WeakMap=="function",zu;Ou&&(zu=new WeakMap);var of=Object.create(null),Tu=0,Wn="__immutablehash__";typeof Symbol=="function"&&(Wn=Symbol(Wn));var x0=16,_0=255,Cu=0,ku={},jo=(function(n){function t(e,r){this._iter=e,this._useKeys=r,this.size=e.size}return n&&(t.__proto__=n),t.prototype=Object.create(n&&n.prototype),t.prototype.constructor=t,t.prototype.get=function(r,i){return this._iter.get(r,i)},t.prototype.has=function(r){return this._iter.has(r)},t.prototype.valueSeq=function(){return this._iter.valueSeq()},t.prototype.reverse=function(){var r=this,i=Iu(this,!0);return this._useKeys||(i.valueSeq=function(){return r._iter.toSeq().reverse()}),i},t.prototype.map=function(r,i){var s=this,o=hf(this,r,i);return this._useKeys||(o.valueSeq=function(){return s._iter.toSeq().map(r,i)}),o},t.prototype.__iterate=function(r,i){var s=this;return this._iter.__iterate(function(o,a){return r(o,a,s)},i)},t.prototype.__iterator=function(r,i){return this._iter.__iterator(r,i)},t})(Tn);jo.prototype[zn]=!0;var af=(function(n){function t(e){this._iter=e,this.size=e.size}return n&&(t.__proto__=n),t.prototype=Object.create(n&&n.prototype),t.prototype.constructor=t,t.prototype.includes=function(r){return this._iter.includes(r)},t.prototype.__iterate=function(r,i){var s=this,o=0;return i&&mi(this),this._iter.__iterate(function(a){return r(a,i?s.size-++o:o++,s)},i)},t.prototype.__iterator=function(r,i){var s=this,o=this._iter.__iterator($e,i),a=0;return i&&mi(this),new Ct(function(){var l=o.next();return l.done?l:Yt(r,i?s.size-++a:a++,l.value,l)})},t})(ar),uf=(function(n){function t(e){this._iter=e,this.size=e.size}return n&&(t.__proto__=n),t.prototype=Object.create(n&&n.prototype),t.prototype.constructor=t,t.prototype.has=function(r){return this._iter.includes(r)},t.prototype.__iterate=function(r,i){var s=this;return this._iter.__iterate(function(o){return r(o,o,s)},i)},t.prototype.__iterator=function(r,i){var s=this._iter.__iterator($e,i);return new Ct(function(){var o=s.next();return o.done?o:Yt(r,o.value,o.value,o)})},t})(bi),lf=(function(n){function t(e){this._iter=e,this.size=e.size}return n&&(t.__proto__=n),t.prototype=Object.create(n&&n.prototype),t.prototype.constructor=t,t.prototype.entrySeq=function(){return this._iter.toSeq()},t.prototype.__iterate=function(r,i){var s=this;return this._iter.__iterate(function(o){if(o){mf(o);var a=Fe(o);return r(a?o.get(1):o[1],a?o.get(0):o[0],s)}},i)},t.prototype.__iterator=function(r,i){var s=this._iter.__iterator($e,i);return new Ct(function(){for(;;){var o=s.next();if(o.done)return o;var a=o.value;if(a){mf(a);var l=Fe(a);return Yt(r,l?a.get(0):a[0],l?a.get(1):a[1],o)}}})},t})(Tn);af.prototype.cacheResult=jo.prototype.cacheResult=uf.prototype.cacheResult=lf.prototype.cacheResult=Lu;function cf(n){var t=qr(n);return t._iter=n,t.size=n.size,t.flip=function(){return n},t.reverse=function(){var e=n.reverse.apply(this);return e.flip=function(){return n.reverse()},e},t.has=function(e){return n.includes(e)},t.includes=function(e){return n.has(e)},t.cacheResult=Lu,t.__iterateUncached=function(e,r){var i=this;return n.__iterate(function(s,o){return e(o,s,i)!==!1},r)},t.__iteratorUncached=function(e,r){if(e===He){var i=n.__iterator(e,r);return new Ct(function(){var s=i.next();if(!s.done){var o=s.value[0];s.value[0]=s.value[1],s.value[1]=o}return s})}return n.__iterator(e===$e?xi:$e,r)},t}function hf(n,t,e){var r=qr(n);return r.size=n.size,r.has=function(i){return n.has(i)},r.get=function(i,s){var o=n.get(i,Tt);return o===Tt?s:t.call(e,o,i,n)},r.__iterateUncached=function(i,s){var o=this;return n.__iterate(function(a,l,c){return i(t.call(e,a,l,c),l,o)!==!1},s)},r.__iteratorUncached=function(i,s){var o=n.__iterator(He,s);return new Ct(function(){var a=o.next();if(a.done)return a;var l=a.value,c=l[0];return Yt(i,c,t.call(e,l[1],c,n),a)})},r}function Iu(n,t){var e=this,r=qr(n);return r._iter=n,r.size=n.size,r.reverse=function(){return n},n.flip&&(r.flip=function(){var i=cf(n);return i.reverse=function(){return n.flip()},i}),r.get=function(i,s){return n.get(t?i:-1-i,s)},r.has=function(i){return n.has(t?i:-1-i)},r.includes=function(i){return n.includes(i)},r.cacheResult=Lu,r.__iterate=function(i,s){var o=this,a=0;return s&&mi(n),n.__iterate(function(l,c){return i(l,t?c:s?o.size-++a:a++,o)},!s)},r.__iterator=function(i,s){var o=0;s&&mi(n);var a=n.__iterator(He,!s);return new Ct(function(){var l=a.next();if(l.done)return l;var c=l.value;return Yt(i,t?c[0]:s?e.size-++o:o++,c[1],l)})},r}function ff(n,t,e,r){var i=qr(n);return r&&(i.has=function(s){var o=n.get(s,Tt);return o!==Tt&&!!t.call(e,o,s,n)},i.get=function(s,o){var a=n.get(s,Tt);return a!==Tt&&t.call(e,a,s,n)?a:o}),i.__iterateUncached=function(s,o){var a=this,l=0;return n.__iterate(function(c,h,f){if(t.call(e,c,h,f))return l++,s(c,r?h:l-1,a)},o),l},i.__iteratorUncached=function(s,o){var a=n.__iterator(He,o),l=0;return new Ct(function(){for(;;){var c=a.next();if(c.done)return c;var h=c.value,f=h[0],g=h[1];if(t.call(e,g,f,n))return Yt(s,r?f:l++,g,c)}})},i}function b0(n,t,e){var r=J().asMutable();return n.__iterate(function(i,s){r.update(t.call(e,i,s,n),0,function(o){return o+1})}),r.asImmutable()}function w0(n,t,e){var r=Gt(n),i=(vr(n)?Gr():J()).asMutable();n.__iterate(function(o,a){i.update(t.call(e,o,a,n),function(l){return l=l||[],l.push(r?[a,o]:o),l})});var s=Ru(n);return i.map(function(o){return Dt(n,s(o))}).asImmutable()}function S0(n,t,e){var r=Gt(n),i=[[],[]];n.__iterate(function(o,a){i[t.call(e,o,a,n)?1:0].push(r?[a,o]:o)});var s=Ru(n);return i.map(function(o){return Dt(n,s(o))})}function Pu(n,t,e,r){var i=n.size;if(Os(t,e,i))return n;if(typeof i>"u"&&(t<0||e<0))return Pu(n.toSeq().cacheResult(),t,e,r);var s=yi(t,i),o=zs(e,i),a=o-s,l;a===a&&(l=a<0?0:a);var c=qr(n);return c.size=l===0?l:n.size&&l||void 0,!r&&Po(n)&&l>=0&&(c.get=function(h,f){return h=An(this,h),h>=0&&h<l?n.get(h+s,f):f}),c.__iterateUncached=function(h,f){var g=this;if(l===0)return 0;if(f)return this.cacheResult().__iterate(h,f);var p=0,m=!0,v=0;return n.__iterate(function(_,S){if(!(m&&(m=p++<s)))return v++,h(_,r?S:v-1,g)!==!1&&v!==l}),v},c.__iteratorUncached=function(h,f){if(l!==0&&f)return this.cacheResult().__iterator(h,f);if(l===0)return new Ct(Ee);var g=n.__iterator(h,f),p=0,m=0;return new Ct(function(){for(;p++<s;)g.next();if(++m>l)return Ee();var v=g.next();return r||h===$e||v.done?v:h===xi?Yt(h,m-1,void 0,v):Yt(h,m-1,v.value[1],v)})},c}function M0(n,t,e){var r=qr(n);return r.__iterateUncached=function(i,s){var o=this;if(s)return this.cacheResult().__iterate(i,s);var a=0;return n.__iterate(function(l,c,h){return t.call(e,l,c,h)&&++a&&i(l,c,o)}),a},r.__iteratorUncached=function(i,s){var o=this;if(s)return this.cacheResult().__iterator(i,s);var a=n.__iterator(He,s),l=!0;return new Ct(function(){if(!l)return Ee();var c=a.next();if(c.done)return c;var h=c.value,f=h[0],g=h[1];return t.call(e,g,f,o)?i===He?c:Yt(i,f,g,c):(l=!1,Ee())})},r}function df(n,t,e,r){var i=qr(n);return i.__iterateUncached=function(s,o){var a=this;if(o)return this.cacheResult().__iterate(s,o);var l=!0,c=0;return n.__iterate(function(h,f,g){if(!(l&&(l=t.call(e,h,f,g))))return c++,s(h,r?f:c-1,a)}),c},i.__iteratorUncached=function(s,o){var a=this;if(o)return this.cacheResult().__iterator(s,o);var l=n.__iterator(He,o),c=!0,h=0;return new Ct(function(){var f,g,p;do{if(f=l.next(),f.done)return r||s===$e?f:s===xi?Yt(s,h++,void 0,f):Yt(s,h++,f.value[1],f);var m=f.value;g=m[0],p=m[1],c&&(c=t.call(e,p,g,a))}while(c);return s===He?f:Yt(s,g,p,f)})},i}var E0=(function(n){function t(e){this._wrappedIterables=e.flatMap(function(r){return r._wrappedIterables?r._wrappedIterables:[r]}),this.size=this._wrappedIterables.reduce(function(r,i){if(r!==void 0){var s=i.size;if(s!==void 0)return r+s}},0),this[Co]=this._wrappedIterables[0][Co],this[ko]=this._wrappedIterables[0][ko],this[zn]=this._wrappedIterables[0][zn]}return n&&(t.__proto__=n),t.prototype=Object.create(n&&n.prototype),t.prototype.constructor=t,t.prototype.__iterateUncached=function(r,i){if(this._wrappedIterables.length!==0){if(i)return this.cacheResult().__iterate(r,i);for(var s=0,o=Gt(this),a=o?He:$e,l=this._wrappedIterables[s].__iterator(a,i),c=!0,h=0;c;){for(var f=l.next();f.done;){if(s++,s===this._wrappedIterables.length)return h;l=this._wrappedIterables[s].__iterator(a,i),f=l.next()}var g=o?r(f.value[1],f.value[0],this):r(f.value,h,this);c=g!==!1,h++}return h}},t.prototype.__iteratorUncached=function(r,i){var s=this;if(this._wrappedIterables.length===0)return new Ct(Ee);if(i)return this.cacheResult().__iterator(r,i);var o=0,a=this._wrappedIterables[o].__iterator(r,i);return new Ct(function(){for(var l=a.next();l.done;){if(o++,o===s._wrappedIterables.length)return l;a=s._wrappedIterables[o].__iterator(r,i),l=a.next()}return l})},t})(de);function A0(n,t){var e=Gt(n),r=[n].concat(t).map(function(s){return Fe(s)?e&&(s=sr(s)):s=e?wu(s):Qh(Array.isArray(s)?s:[s]),s}).filter(function(s){return s.size!==0});if(r.length===0)return n;if(r.length===1){var i=r[0];if(i===n||e&&Gt(i)||je(n)&&je(i))return i}return new E0(r)}function pf(n,t,e){var r=qr(n);return r.__iterateUncached=function(i,s){if(s)return this.cacheResult().__iterate(i,s);var o=0,a=!1;function l(c,h){c.__iterate(function(f,g){return(!t||h<t)&&Fe(f)?l(f,h+1):(o++,i(f,e?g:o-1,r)===!1&&(a=!0)),!a},s)}return l(n,0),o},r.__iteratorUncached=function(i,s){if(s)return this.cacheResult().__iterator(i,s);var o=n.__iterator(i,s),a=[],l=0;return new Ct(function(){for(;o;){var c=o.next();if(c.done!==!1){o=a.pop();continue}var h=c.value;if(i===He&&(h=h[1]),(!t||a.length<t)&&Fe(h))a.push(o),o=h.__iterator(i,s);else return e?c:Yt(i,l++,h,c)}return Ee()})},r}function O0(n,t,e){var r=Ru(n);return n.toSeq().map(function(i,s){return r(t.call(e,i,s,n))}).flatten(!0)}function z0(n,t){var e=qr(n);return e.size=n.size&&n.size*2-1,e.__iterateUncached=function(r,i){var s=this,o=0;return n.__iterate(function(a){return(!o||r(t,o++,s)!==!1)&&r(a,o++,s)!==!1},i),o},e.__iteratorUncached=function(r,i){var s=n.__iterator($e,i),o=0,a;return new Ct(function(){return(!a||o%2)&&(a=s.next(),a.done)?a:o%2?Yt(r,o++,t):Yt(r,o++,a.value,a)})},e}function Si(n,t,e){t||(t=yf);var r=Gt(n),i=0,s=n.toSeq().map(function(o,a){return[a,o,i++,e?e(o,a,n):o]}).valueSeq().toArray();return s.sort(function(o,a){return t(o[3],a[3])||o[2]-a[2]}).forEach(r?function(o,a){s[a].length=2}:function(o,a){s[a]=o[1]}),r?Tn(s):je(n)?ar(s):bi(s)}function Vo(n,t,e){if(t||(t=yf),e){var r=n.toSeq().map(function(i,s){return[i,e(i,s,n)]}).reduce(function(i,s){return gf(t,i[1],s[1])?s:i});return r&&r[0]}return n.reduce(function(i,s){return gf(t,i,s)?s:i})}function gf(n,t,e){var r=n(e,t);return r===0&&e!==t&&(e==null||e!==e)||r>0}function Do(n,t,e,r){var i=qr(n),s=new wi(e).map(function(o){return o.size});return i.size=r?s.max():s.min(),i.__iterate=function(o,a){for(var l=this.__iterator($e,a),c,h=0;!(c=l.next()).done&&o(c.value,h++,this)!==!1;);return h},i.__iteratorUncached=function(o,a){var l=e.map(function(f){return f=ye(f),vu(a?f.reverse():f)}),c=0,h=!1;return new Ct(function(){var f;return h||(f=l.map(function(g){return g.next()}),h=r?f.every(function(g){return g.done}):f.some(function(g){return g.done})),h?Ee():Yt(o,c++,t.apply(null,f.map(function(g){return g.value})))})},i}function Dt(n,t){return n===t?n:Po(n)?t:n.constructor(t)}function mf(n){if(n!==Object(n))throw new TypeError("Expected [K, V] tuple: "+n)}function Ru(n){return Gt(n)?sr:je(n)?Gn:vi}function qr(n){return Object.create((Gt(n)?Tn:je(n)?ar:bi).prototype)}function Lu(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):de.prototype.cacheResult.call(this)}function yf(n,t){return n===void 0&&t===void 0?0:n===void 0?1:t===void 0?-1:n>t?1:n<t?-1:0}function $r(n,t){t=t||0;for(var e=Math.max(0,n.length-t),r=new Array(e),i=0;i<e;i++)r[i]=n[i+t];return r}function Cs(n,t){if(!n)throw new Error(t)}function Ge(n){Cs(n!==1/0,"Cannot perform this action with an infinite size.")}function vf(n){if(xu(n)&&typeof n!="string")return n;if(vr(n))return n.toArray();throw new TypeError("Invalid keyPath: expected Ordered Collection or Array: "+n)}var T0=Object.prototype.toString;function Nu(n){if(!n||typeof n!="object"||T0.call(n)!=="[object Object]")return!1;var t=Object.getPrototypeOf(n);if(t===null)return!0;for(var e=t,r=Object.getPrototypeOf(t);r!==null;)e=r,r=Object.getPrototypeOf(e);return e===t}function Cn(n){return typeof n=="object"&&(or(n)||Array.isArray(n)||Nu(n))}function ks(n){try{return typeof n=="string"?JSON.stringify(n):String(n)}catch{return JSON.stringify(n)}}function xf(n,t){return or(n)?n.has(t):Cn(n)&&_i.call(n,t)}function Fu(n,t,e){return or(n)?n.get(t,e):xf(n,t)?typeof n.get=="function"?n.get(t):n[t]:e}function Bo(n){if(Array.isArray(n))return $r(n);var t={};for(var e in n)_i.call(n,e)&&(t[e]=n[e]);return t}function _f(n,t){if(!Cn(n))throw new TypeError("Cannot update non-data-structure value: "+n);if(or(n)){if(!n.remove)throw new TypeError("Cannot update immutable value without .remove() method: "+n);return n.remove(t)}if(!_i.call(n,t))return n;var e=Bo(n);return Array.isArray(e)?e.splice(t,1):delete e[t],e}function bf(n,t,e){if(!Cn(n))throw new TypeError("Cannot update non-data-structure value: "+n);if(or(n)){if(!n.set)throw new TypeError("Cannot update immutable value without .set() method: "+n);return n.set(t,e)}if(_i.call(n,t)&&e===n[t])return n;var r=Bo(n);return r[t]=e,r}function Un(n,t,e,r){r||(r=e,e=void 0);var i=wf(or(n),n,vf(t),0,e,r);return i===Tt?e:i}function wf(n,t,e,r,i,s){var o=t===Tt;if(r===e.length){var a=o?i:t,l=s(a);return l===a?t:l}if(!o&&!Cn(t))throw new TypeError("Cannot update within non-data-structure value in path ["+Array.from(e).slice(0,r).map(ks)+"]: "+t);var c=e[r],h=o?Tt:Fu(t,c,Tt),f=wf(h===Tt?n:or(h),h,e,r+1,i,s);return f===h?t:f===Tt?_f(t,c):bf(o?n?Hr():{}:t,c,f)}function Sf(n,t,e){return Un(n,t,Tt,function(){return e})}function ju(n,t){return Sf(this,n,t)}function Mf(n,t){return Un(n,t,function(){return Tt})}function Vu(n){return Mf(this,n)}function Du(n,t,e,r){return Un(n,[t],e,r)}function Bu(n,t,e){return arguments.length===1?n(this):Du(this,n,t,e)}function qu(n,t,e){return Un(this,n,t,e)}function Ef(){for(var n=[],t=arguments.length;t--;)n[t]=arguments[t];return Of(this,n)}function Af(n){for(var t=[],e=arguments.length-1;e-- >0;)t[e]=arguments[e+1];if(typeof n!="function")throw new TypeError("Invalid merger function: "+n);return Of(this,t,n)}function Of(n,t,e){for(var r=[],i=0;i<t.length;i++){var s=sr(t[i]);s.size!==0&&r.push(s)}return r.length===0?n:n.toSeq().size===0&&!n.__ownerID&&r.length===1?On(n)?n:n.constructor(r[0]):n.withMutations(function(o){for(var a=e?function(c,h){Du(o,h,Tt,function(f){return f===Tt?c:e(f,c,h)})}:function(c,h){o.set(h,c)},l=0;l<r.length;l++)r[l].forEach(a)})}function C0(n){for(var t=[],e=arguments.length-1;e-- >0;)t[e]=arguments[e+1];return Ps(n,t)}function k0(n,t){for(var e=[],r=arguments.length-2;r-- >0;)e[r]=arguments[r+2];return Ps(t,e,n)}function I0(n){for(var t=[],e=arguments.length-1;e-- >0;)t[e]=arguments[e+1];return Is(n,t)}function P0(n,t){for(var e=[],r=arguments.length-2;r-- >0;)e[r]=arguments[r+2];return Is(t,e,n)}function Is(n,t,e){return Ps(n,t,R0(e))}function Ps(n,t,e){if(!Cn(n))throw new TypeError("Cannot merge into non-data-structure value: "+n);if(or(n))return typeof e=="function"&&n.mergeWith?n.mergeWith.apply(n,[e].concat(t)):n.merge?n.merge.apply(n,t):n.concat.apply(n,t);for(var r=Array.isArray(n),i=n,s=r?Gn:sr,o=r?function(l){i===n&&(i=Bo(i)),i.push(l)}:function(l,c){var h=_i.call(i,c),f=h&&e?e(i[c],l,c):l;(!h||f!==i[c])&&(i===n&&(i=Bo(i)),i[c]=f)},a=0;a<t.length;a++)s(t[a]).forEach(o);return i}function R0(n){function t(e,r,i){return Cn(e)&&Cn(r)&&L0(e,r)?Ps(e,[r],t):n?n(e,r,i):r}return t}function L0(n,t){var e=de(n),r=de(t);return je(e)===je(r)&&Gt(e)===Gt(r)}function zf(){for(var n=[],t=arguments.length;t--;)n[t]=arguments[t];return Is(this,n)}function Tf(n){for(var t=[],e=arguments.length-1;e-- >0;)t[e]=arguments[e+1];return Is(this,t,n)}function $u(n){for(var t=[],e=arguments.length-1;e-- >0;)t[e]=arguments[e+1];return Un(this,n,Hr(),function(r){return Ps(r,t)})}function Hu(n){for(var t=[],e=arguments.length-1;e-- >0;)t[e]=arguments[e+1];return Un(this,n,Hr(),function(r){return Is(r,t)})}function Rs(n){var t=this.asMutable();return n(t),t.wasAltered()?t.__ensureOwner(this.__ownerID):this}function Ls(){return this.__ownerID?this:this.__ensureOwner(new gu)}function Ns(){return this.__ensureOwner()}function Gu(){return this.__altered}var J=(function(n){function t(e){return e==null?Hr():No(e)&&!vr(e)?e:Hr().withMutations(function(r){var i=n(e);Ge(i.size),i.forEach(function(s,o){return r.set(o,s)})})}return n&&(t.__proto__=n),t.prototype=Object.create(n&&n.prototype),t.prototype.constructor=t,t.prototype.toString=function(){return this.__toString("Map {","}")},t.prototype.get=function(r,i){return this._root?this._root.get(0,void 0,r,i):i},t.prototype.set=function(r,i){return If(this,r,i)},t.prototype.remove=function(r){return If(this,r,Tt)},t.prototype.deleteAll=function(r){var i=ye(r);return i.size===0?this:this.withMutations(function(s){i.forEach(function(o){return s.remove(o)})})},t.prototype.clear=function(){return this.size===0?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):Hr()},t.prototype.sort=function(r){return Gr(Si(this,r))},t.prototype.sortBy=function(r,i){return Gr(Si(this,i,r))},t.prototype.map=function(r,i){var s=this;return this.withMutations(function(o){o.forEach(function(a,l){o.set(l,r.call(i,a,l,s))})})},t.prototype.__iterator=function(r,i){return new N0(this,r,i)},t.prototype.__iterate=function(r,i){var s=this,o=0;return this._root&&this._root.iterate(function(a){return o++,r(a[1],a[0],s)},i),o},t.prototype.__ensureOwner=function(r){return r===this.__ownerID?this:r?Uu(this.size,this._root,r,this.__hash):this.size===0?Hr():(this.__ownerID=r,this.__altered=!1,this)},t})(sr);J.isMap=No;var Xt=J.prototype;Xt[tf]=!0,Xt[As]=Xt.remove,Xt.removeAll=Xt.deleteAll,Xt.setIn=ju,Xt.removeIn=Xt.deleteIn=Vu,Xt.update=Bu,Xt.updateIn=qu,Xt.merge=Xt.concat=Ef,Xt.mergeWith=Af,Xt.mergeDeep=zf,Xt.mergeDeepWith=Tf,Xt.mergeIn=$u,Xt.mergeDeepIn=Hu,Xt.withMutations=Rs,Xt.wasAltered=Gu,Xt.asImmutable=Ns,Xt["@@transducer/init"]=Xt.asMutable=Ls,Xt["@@transducer/step"]=function(n,t){return n.set(t[0],t[1])},Xt["@@transducer/result"]=function(n){return n.asImmutable()};var Fs=function(t,e){this.ownerID=t,this.entries=e};Fs.prototype.get=function(t,e,r,i){for(var s=this.entries,o=0,a=s.length;o<a;o++)if(ve(r,s[o][0]))return s[o][1];return i},Fs.prototype.update=function(t,e,r,i,s,o,a){for(var l=s===Tt,c=this.entries,h=0,f=c.length;h<f&&!ve(i,c[h][0]);h++);var g=h<f;if(g?c[h][1]===s:l)return this;if(ir(a),(l||!g)&&ir(o),!(l&&c.length===1)){if(!g&&!l&&c.length>=q0)return F0(t,c,i,s);var p=t&&t===this.ownerID,m=p?c:$r(c);return g?l?h===f-1?m.pop():m[h]=m.pop():m[h]=[i,s]:m.push([i,s]),p?(this.entries=m,this):new Fs(t,m)}};var Mi=function(t,e,r){this.ownerID=t,this.bitmap=e,this.nodes=r};Mi.prototype.get=function(t,e,r,i){e===void 0&&(e=Ve(r));var s=1<<((t===0?e:e>>>t)&ke),o=this.bitmap;return(o&s)===0?i:this.nodes[Rf(o&s-1)].get(t+Vt,e,r,i)},Mi.prototype.update=function(t,e,r,i,s,o,a){r===void 0&&(r=Ve(i));var l=(e===0?r:r>>>e)&ke,c=1<<l,h=this.bitmap,f=(h&c)!==0;if(!f&&s===Tt)return this;var g=Rf(h&c-1),p=this.nodes,m=f?p[g]:void 0,v=Yu(m,t,e+Vt,r,i,s,o,a);if(v===m)return this;if(!f&&v&&p.length>=$0)return V0(t,p,h,l,v);if(f&&!v&&p.length===2&&Pf(p[g^1]))return p[g^1];if(f&&v&&p.length===1&&Pf(v))return v;var _=t&&t===this.ownerID,S=f?v?h:h^c:h|c,A=f?v?Lf(p,g,v,_):B0(p,g,_):D0(p,g,v,_);return _?(this.bitmap=S,this.nodes=A,this):new Mi(t,S,A)};var js=function(t,e,r){this.ownerID=t,this.count=e,this.nodes=r};js.prototype.get=function(t,e,r,i){e===void 0&&(e=Ve(r));var s=(t===0?e:e>>>t)&ke,o=this.nodes[s];return o?o.get(t+Vt,e,r,i):i},js.prototype.update=function(t,e,r,i,s,o,a){r===void 0&&(r=Ve(i));var l=(e===0?r:r>>>e)&ke,c=s===Tt,h=this.nodes,f=h[l];if(c&&!f)return this;var g=Yu(f,t,e+Vt,r,i,s,o,a);if(g===f)return this;var p=this.count;if(!f)p++;else if(!g&&(p--,p<H0))return j0(t,h,p,l);var m=t&&t===this.ownerID,v=Lf(h,l,g,m);return m?(this.count=p,this.nodes=v,this):new js(t,p,v)};var Ei=function(t,e,r){this.ownerID=t,this.keyHash=e,this.entries=r};Ei.prototype.get=function(t,e,r,i){for(var s=this.entries,o=0,a=s.length;o<a;o++)if(ve(r,s[o][0]))return s[o][1];return i},Ei.prototype.update=function(t,e,r,i,s,o,a){r===void 0&&(r=Ve(i));var l=s===Tt;if(r!==this.keyHash)return l?this:(ir(a),ir(o),Xu(this,t,e,r,[i,s]));for(var c=this.entries,h=0,f=c.length;h<f&&!ve(i,c[h][0]);h++);var g=h<f;if(g?c[h][1]===s:l)return this;if(ir(a),(l||!g)&&ir(o),l&&f===2)return new ln(t,this.keyHash,c[h^1]);var p=t&&t===this.ownerID,m=p?c:$r(c);return g?l?h===f-1?m.pop():m[h]=m.pop():m[h]=[i,s]:m.push([i,s]),p?(this.entries=m,this):new Ei(t,this.keyHash,m)};var ln=function(t,e,r){this.ownerID=t,this.keyHash=e,this.entry=r};ln.prototype.get=function(t,e,r,i){return ve(r,this.entry[0])?this.entry[1]:i},ln.prototype.update=function(t,e,r,i,s,o,a){var l=s===Tt,c=ve(i,this.entry[0]);if(c?s===this.entry[1]:l)return this;if(ir(a),l){ir(o);return}return c?t&&t===this.ownerID?(this.entry[1]=s,this):new ln(t,this.keyHash,[i,s]):(ir(o),Xu(this,t,e,Ve(i),[i,s]))},Fs.prototype.iterate=Ei.prototype.iterate=function(n,t){for(var e=this.entries,r=0,i=e.length-1;r<=i;r++)if(n(e[t?i-r:r])===!1)return!1},Mi.prototype.iterate=js.prototype.iterate=function(n,t){for(var e=this.nodes,r=0,i=e.length-1;r<=i;r++){var s=e[t?i-r:r];if(s&&s.iterate(n,t)===!1)return!1}},ln.prototype.iterate=function(n,t){return n(this.entry)};var N0=(function(n){function t(e,r,i){this._type=r,this._reverse=i,this._stack=e._root&&Cf(e._root)}return n&&(t.__proto__=n),t.prototype=Object.create(n&&n.prototype),t.prototype.constructor=t,t.prototype.next=function(){for(var r=this._type,i=this._stack;i;){var s=i.node,o=i.index++,a=void 0;if(s.entry){if(o===0)return Wu(r,s.entry)}else if(s.entries){if(a=s.entries.length-1,o<=a)return Wu(r,s.entries[this._reverse?a-o:o])}else if(a=s.nodes.length-1,o<=a){var l=s.nodes[this._reverse?a-o:o];if(l){if(l.entry)return Wu(r,l.entry);i=this._stack=Cf(l,i)}continue}i=this._stack=this._stack.__prev}return Ee()},t})(Ct);function Wu(n,t){return Yt(n,t[0],t[1])}function Cf(n,t){return{node:n,index:0,__prev:t}}function Uu(n,t,e,r){var i=Object.create(Xt);return i.size=n,i._root=t,i.__ownerID=e,i.__hash=r,i.__altered=!1,i}var kf;function Hr(){return kf||(kf=Uu(0))}function If(n,t,e){var r,i;if(n._root){var s=pu(),o=pu();if(r=Yu(n._root,n.__ownerID,0,void 0,t,e,s,o),!o.value)return n;i=n.size+(s.value?e===Tt?-1:1:0)}else{if(e===Tt)return n;i=1,r=new Fs(n.__ownerID,[[t,e]])}return n.__ownerID?(n.size=i,n._root=r,n.__hash=void 0,n.__altered=!0,n):r?Uu(i,r):Hr()}function Yu(n,t,e,r,i,s,o,a){return n?n.update(t,e,r,i,s,o,a):s===Tt?n:(ir(a),ir(o),new ln(t,r,[i,s]))}function Pf(n){return n.constructor===ln||n.constructor===Ei}function Xu(n,t,e,r,i){if(n.keyHash===r)return new Ei(t,r,[n.entry,i]);var s=(e===0?n.keyHash:n.keyHash>>>e)&ke,o=(e===0?r:r>>>e)&ke,a,l=s===o?[Xu(n,t,e+Vt,r,i)]:(a=new ln(t,r,i),s<o?[n,a]:[a,n]);return new Mi(t,1<<s|1<<o,l)}function F0(n,t,e,r){n||(n=new gu);for(var i=new ln(n,Ve(e),[e,r]),s=0;s<t.length;s++){var o=t[s];i=i.update(n,0,void 0,o[0],o[1])}return i}function j0(n,t,e,r){for(var i=0,s=0,o=new Array(e),a=0,l=1,c=t.length;a<c;a++,l<<=1){var h=t[a];h!==void 0&&a!==r&&(i|=l,o[s++]=h)}return new Mi(n,i,o)}function V0(n,t,e,r,i){for(var s=0,o=new Array(qe),a=0;e!==0;a++,e>>>=1)o[a]=e&1?t[s++]:void 0;return o[r]=i,new js(n,s+1,o)}function Rf(n){return n-=n>>1&1431655765,n=(n&858993459)+(n>>2&858993459),n=n+(n>>4)&252645135,n+=n>>8,n+=n>>16,n&127}function Lf(n,t,e,r){var i=r?n:$r(n);return i[t]=e,i}function D0(n,t,e,r){var i=n.length+1;if(r&&t+1===i)return n[t]=e,n;for(var s=new Array(i),o=0,a=0;a<i;a++)a===t?(s[a]=e,o=-1):s[a]=n[a+o];return s}function B0(n,t,e){var r=n.length-1;if(e&&t===r)return n.pop(),n;for(var i=new Array(r),s=0,o=0;o<r;o++)o===t&&(s=1),i[o]=n[o+s];return i}var q0=qe/4,$0=qe/2,H0=qe/4,Nf="@@__IMMUTABLE_LIST__@@";function Ju(n){return!!(n&&n[Nf])}var st=(function(n){function t(e){var r=qo();if(e==null)return r;if(Ju(e))return e;var i=n(e),s=i.size;return s===0?r:(Ge(s),s>0&&s<qe?Ds(0,s,Vt,null,new kn(i.toArray())):r.withMutations(function(o){o.setSize(s),i.forEach(function(a,l){return o.set(l,a)})}))}return n&&(t.__proto__=n),t.prototype=Object.create(n&&n.prototype),t.prototype.constructor=t,t.of=function(){return this(arguments)},t.prototype.toString=function(){return this.__toString("List [","]")},t.prototype.get=function(r,i){if(r=An(this,r),r>=0&&r<this.size){r+=this._origin;var s=jf(this,r);return s&&s.array[r&ke]}return i},t.prototype.set=function(r,i){return G0(this,r,i)},t.prototype.remove=function(r){return this.has(r)?r===0?this.shift():r===this.size-1?this.pop():this.splice(r,1):this},t.prototype.insert=function(r,i){return this.splice(r,0,i)},t.prototype.clear=function(){return this.size===0?this:this.__ownerID?(this.size=this._origin=this._capacity=0,this._level=Vt,this._root=this._tail=this.__hash=void 0,this.__altered=!0,this):qo()},t.prototype.push=function(){var r=arguments,i=this.size;return this.withMutations(function(s){In(s,0,i+r.length);for(var o=0;o<r.length;o++)s.set(i+o,r[o])})},t.prototype.pop=function(){return In(this,0,-1)},t.prototype.unshift=function(){var r=arguments;return this.withMutations(function(i){In(i,-r.length);for(var s=0;s<r.length;s++)i.set(s,r[s])})},t.prototype.shift=function(){return In(this,1)},t.prototype.shuffle=function(r){return r===void 0&&(r=Math.random),this.withMutations(function(i){for(var s=i.size,o,a;s;)o=Math.floor(r()*s--),a=i.get(o),i.set(o,i.get(s)),i.set(s,a)})},t.prototype.concat=function(){for(var r=arguments,i=[],s=0;s<arguments.length;s++){var o=r[s],a=n(typeof o!="string"&&yu(o)?o:[o]);a.size!==0&&i.push(a)}return i.length===0?this:this.size===0&&!this.__ownerID&&i.length===1?this.constructor(i[0]):this.withMutations(function(l){i.forEach(function(c){return c.forEach(function(h){return l.push(h)})})})},t.prototype.setSize=function(r){return In(this,0,r)},t.prototype.map=function(r,i){var s=this;return this.withMutations(function(o){for(var a=0;a<s.size;a++)o.set(a,r.call(i,o.get(a),a,s))})},t.prototype.slice=function(r,i){var s=this.size;return Os(r,i,s)?this:In(this,yi(r,s),zs(i,s))},t.prototype.__iterator=function(r,i){var s=i?this.size:0,o=Ff(this,i);return new Ct(function(){var a=o();return a===Vs?Ee():Yt(r,i?--s:s++,a)})},t.prototype.__iterate=function(r,i){for(var s=i?this.size:0,o=Ff(this,i),a;(a=o())!==Vs&&r(a,i?--s:s++,this)!==!1;);return s},t.prototype.__ensureOwner=function(r){return r===this.__ownerID?this:r?Ds(this._origin,this._capacity,this._level,this._root,this._tail,r,this.__hash):this.size===0?qo():(this.__ownerID=r,this.__altered=!1,this)},t})(Gn);st.isList=Ju;var ue=st.prototype;ue[Nf]=!0,ue[As]=ue.remove,ue.merge=ue.concat,ue.setIn=ju,ue.deleteIn=ue.removeIn=Vu,ue.update=Bu,ue.updateIn=qu,ue.mergeIn=$u,ue.mergeDeepIn=Hu,ue.withMutations=Rs,ue.wasAltered=Gu,ue.asImmutable=Ns,ue["@@transducer/init"]=ue.asMutable=Ls,ue["@@transducer/step"]=function(n,t){return n.push(t)},ue["@@transducer/result"]=function(n){return n.asImmutable()};var kn=function(t,e){this.array=t,this.ownerID=e};kn.prototype.removeBefore=function(t,e,r){if((r&(1<<e+Vt)-1)===0||this.array.length===0)return this;var i=r>>>e&ke;if(i>=this.array.length)return new kn([],t);var s=i===0,o;if(e>0){var a=this.array[i];if(o=a&&a.removeBefore(t,e-Vt,r),o===a&&s)return this}if(s&&!o)return this;var l=Ai(this,t);if(!s)for(var c=0;c<i;c++)l.array[c]=void 0;return o&&(l.array[i]=o),l},kn.prototype.removeAfter=function(t,e,r){if(r===(e?1<<e+Vt:qe)||this.array.length===0)return this;var i=r-1>>>e&ke;if(i>=this.array.length)return this;var s;if(e>0){var o=this.array[i];if(s=o&&o.removeAfter(t,e-Vt,r),s===o&&i===this.array.length-1)return this}var a=Ai(this,t);return a.array.splice(i+1),s&&(a.array[i]=s),a};var Vs={};function Ff(n,t){var e=n._origin,r=n._capacity,i=Bs(r),s=n._tail;return o(n._root,n._level,0);function o(c,h,f){return h===0?a(c,f):l(c,h,f)}function a(c,h){var f=h===i?s&&s.array:c&&c.array,g=h>e?0:e-h,p=r-h;return p>qe&&(p=qe),function(){if(g===p)return Vs;var m=t?--p:g++;return f&&f[m]}}function l(c,h,f){var g,p=c&&c.array,m=f>e?0:e-f>>h,v=(r-f>>h)+1;return v>qe&&(v=qe),function(){for(;;){if(g){var _=g();if(_!==Vs)return _;g=null}if(m===v)return Vs;var S=t?--v:m++;g=o(p&&p[S],h-Vt,f+(S<<h))}}}}function Ds(n,t,e,r,i,s,o){var a=Object.create(ue);return a.size=t-n,a._origin=n,a._capacity=t,a._level=e,a._root=r,a._tail=i,a.__ownerID=s,a.__hash=o,a.__altered=!1,a}function qo(){return Ds(0,0,Vt)}function G0(n,t,e){if(t=An(n,t),t!==t)return n;if(t>=n.size||t<0)return n.withMutations(function(o){t<0?In(o,t).set(0,e):In(o,0,t+1).set(t,e)});t+=n._origin;var r=n._tail,i=n._root,s=pu();return t>=Bs(n._capacity)?r=Zu(r,n.__ownerID,0,t,e,s):i=Zu(i,n.__ownerID,n._level,t,e,s),s.value?n.__ownerID?(n._root=i,n._tail=r,n.__hash=void 0,n.__altered=!0,n):Ds(n._origin,n._capacity,n._level,i,r):n}function Zu(n,t,e,r,i,s){var o=r>>>e&ke,a=n&&o<n.array.length;if(!a&&i===void 0)return n;var l;if(e>0){var c=n&&n.array[o],h=Zu(c,t,e-Vt,r,i,s);return h===c?n:(l=Ai(n,t),l.array[o]=h,l)}return a&&n.array[o]===i?n:(s&&ir(s),l=Ai(n,t),i===void 0&&o===l.array.length-1?l.array.pop():l.array[o]=i,l)}function Ai(n,t){return t&&n&&t===n.ownerID?n:new kn(n?n.array.slice():[],t)}function jf(n,t){if(t>=Bs(n._capacity))return n._tail;if(t<1<<n._level+Vt){for(var e=n._root,r=n._level;e&&r>0;)e=e.array[t>>>r&ke],r-=Vt;return e}}function In(n,t,e){t!==void 0&&(t|=0),e!==void 0&&(e|=0);var r=n.__ownerID||new gu,i=n._origin,s=n._capacity,o=i+t,a=e===void 0?s:e<0?s+e:i+e;if(o===i&&a===s)return n;if(o>=a)return n.clear();for(var l=n._level,c=n._root,h=0;o+h<0;)c=new kn(c&&c.array.length?[void 0,c]:[],r),l+=Vt,h+=1<<l;h&&(o+=h,i+=h,a+=h,s+=h);for(var f=Bs(s),g=Bs(a);g>=1<<l+Vt;)c=new kn(c&&c.array.length?[c]:[],r),l+=Vt;var p=n._tail,m=g<f?jf(n,a-1):g>f?new kn([],r):p;if(p&&g>f&&o<s&&p.array.length){c=Ai(c,r);for(var v=c,_=l;_>Vt;_-=Vt){var S=f>>>_&ke;v=v.array[S]=Ai(v.array[S],r)}v.array[f>>>Vt&ke]=p}if(a<s&&(m=m&&m.removeAfter(r,0,a)),o>=g)o-=g,a-=g,l=Vt,c=null,m=m&&m.removeBefore(r,0,o);else if(o>i||g<f){for(h=0;c;){var A=o>>>l&ke;if(A!==g>>>l&ke)break;A&&(h+=(1<<l)*A),l-=Vt,c=c.array[A]}c&&o>i&&(c=c.removeBefore(r,l,o-h)),c&&g<f&&(c=c.removeAfter(r,l,g-h)),h&&(o-=h,a-=h)}return n.__ownerID?(n.size=a-o,n._origin=o,n._capacity=a,n._level=l,n._root=c,n._tail=m,n.__hash=void 0,n.__altered=!0,n):Ds(o,a,l,c,m)}function Bs(n){return n<qe?0:n-1>>>Vt<<Vt}var Gr=(function(n){function t(e){return e==null?qs():Mu(e)?e:qs().withMutations(function(r){var i=sr(e);Ge(i.size),i.forEach(function(s,o){return r.set(o,s)})})}return n&&(t.__proto__=n),t.prototype=Object.create(n&&n.prototype),t.prototype.constructor=t,t.of=function(){return this(arguments)},t.prototype.toString=function(){return this.__toString("OrderedMap {","}")},t.prototype.get=function(r,i){var s=this._map.get(r);return s!==void 0?this._list.get(s)[1]:i},t.prototype.clear=function(){return this.size===0?this:this.__ownerID?(this.size=0,this._map.clear(),this._list.clear(),this.__altered=!0,this):qs()},t.prototype.set=function(r,i){return Df(this,r,i)},t.prototype.remove=function(r){return Df(this,r,Tt)},t.prototype.__iterate=function(r,i){var s=this;return this._list.__iterate(function(o){return o&&r(o[1],o[0],s)},i)},t.prototype.__iterator=function(r,i){return this._list.fromEntrySeq().__iterator(r,i)},t.prototype.__ensureOwner=function(r){if(r===this.__ownerID)return this;var i=this._map.__ensureOwner(r),s=this._list.__ensureOwner(r);return r?Ku(i,s,r,this.__hash):this.size===0?qs():(this.__ownerID=r,this.__altered=!1,this._map=i,this._list=s,this)},t})(J);Gr.isOrderedMap=Mu,Gr.prototype[zn]=!0,Gr.prototype[As]=Gr.prototype.remove;function Ku(n,t,e,r){var i=Object.create(Gr.prototype);return i.size=n?n.size:0,i._map=n,i._list=t,i.__ownerID=e,i.__hash=r,i.__altered=!1,i}var Vf;function qs(){return Vf||(Vf=Ku(Hr(),qo()))}function Df(n,t,e){var r=n._map,i=n._list,s=r.get(t),o=s!==void 0,a,l;if(e===Tt){if(!o)return n;i.size>=qe&&i.size>=r.size*2?(l=i.filter(function(c,h){return c!==void 0&&s!==h}),a=l.toKeyedSeq().map(function(c){return c[0]}).flip().toMap(),n.__ownerID&&(a.__ownerID=l.__ownerID=n.__ownerID)):(a=r.remove(t),l=s===i.size-1?i.pop():i.set(s,void 0))}else if(o){if(e===i.get(s)[1])return n;a=r,l=i.set(s,[t,e])}else a=r.set(t,i.size),l=i.set(i.size,[t,e]);return n.__ownerID?(n.size=a.size,n._map=a,n._list=l,n.__hash=void 0,n.__altered=!0,n):Ku(a,l)}var Bf="@@__IMMUTABLE_STACK__@@";function $o(n){return!!(n&&n[Bf])}var Ho=(function(n){function t(e){return e==null?Go():$o(e)?e:Go().pushAll(e)}return n&&(t.__proto__=n),t.prototype=Object.create(n&&n.prototype),t.prototype.constructor=t,t.of=function(){return this(arguments)},t.prototype.toString=function(){return this.__toString("Stack [","]")},t.prototype.get=function(r,i){var s=this._head;for(r=An(this,r);s&&r--;)s=s.next;return s?s.value:i},t.prototype.peek=function(){return this._head&&this._head.value},t.prototype.push=function(){var r=arguments;if(arguments.length===0)return this;for(var i=this.size+arguments.length,s=this._head,o=arguments.length-1;o>=0;o--)s={value:r[o],next:s};return this.__ownerID?(this.size=i,this._head=s,this.__hash=void 0,this.__altered=!0,this):$s(i,s)},t.prototype.pushAll=function(r){if(r=n(r),r.size===0)return this;if(this.size===0&&$o(r))return r;Ge(r.size);var i=this.size,s=this._head;return r.__iterate(function(o){i++,s={value:o,next:s}},!0),this.__ownerID?(this.size=i,this._head=s,this.__hash=void 0,this.__altered=!0,this):$s(i,s)},t.prototype.pop=function(){return this.slice(1)},t.prototype.clear=function(){return this.size===0?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Go()},t.prototype.slice=function(r,i){if(Os(r,i,this.size))return this;var s=yi(r,this.size),o=zs(i,this.size);if(o!==this.size)return n.prototype.slice.call(this,r,i);for(var a=this.size-s,l=this._head;s--;)l=l.next;return this.__ownerID?(this.size=a,this._head=l,this.__hash=void 0,this.__altered=!0,this):$s(a,l)},t.prototype.__ensureOwner=function(r){return r===this.__ownerID?this:r?$s(this.size,this._head,r,this.__hash):this.size===0?Go():(this.__ownerID=r,this.__altered=!1,this)},t.prototype.__iterate=function(r,i){var s=this;if(i)return new wi(this.toArray()).__iterate(function(l,c){return r(l,c,s)},i);for(var o=0,a=this._head;a&&r(a.value,o++,this)!==!1;)a=a.next;return o},t.prototype.__iterator=function(r,i){if(i)return new wi(this.toArray()).__iterator(r,i);var s=0,o=this._head;return new Ct(function(){if(o){var a=o.value;return o=o.next,Yt(r,s++,a)}return Ee()})},t})(Gn);Ho.isStack=$o;var Ie=Ho.prototype;Ie[Bf]=!0,Ie.shift=Ie.pop,Ie.unshift=Ie.push,Ie.unshiftAll=Ie.pushAll,Ie.withMutations=Rs,Ie.wasAltered=Gu,Ie.asImmutable=Ns,Ie["@@transducer/init"]=Ie.asMutable=Ls,Ie["@@transducer/step"]=function(n,t){return n.unshift(t)},Ie["@@transducer/result"]=function(n){return n.asImmutable()};function $s(n,t,e,r){var i=Object.create(Ie);return i.size=n,i._head=t,i.__ownerID=e,i.__hash=r,i.__altered=!1,i}var qf;function Go(){return qf||(qf=$s(0))}var $f="@@__IMMUTABLE_SET__@@";function Wo(n){return!!(n&&n[$f])}function Qu(n){return Wo(n)&&vr(n)}function tl(n,t){if(n===t)return!0;if(!Fe(t)||n.size!==void 0&&t.size!==void 0&&n.size!==t.size||n.__hash!==void 0&&t.__hash!==void 0&&n.__hash!==t.__hash||Gt(n)!==Gt(t)||je(n)!==je(t)||vr(n)!==vr(t))return!1;if(n.size===0&&t.size===0)return!0;var e=!Io(n);if(vr(n)){var r=n.entries();return t.every(function(l,c){var h=r.next().value;return h&&ve(h[1],l)&&(e||ve(h[0],c))})&&r.next().done}var i=!1;if(n.size===void 0)if(t.size===void 0)typeof n.cacheResult=="function"&&n.cacheResult();else{i=!0;var s=n;n=t,t=s}var o=!0,a=t.__iterate(function(l,c){if(e?!n.has(l):i?!ve(l,n.get(c,Tt)):!ve(n.get(c,Tt),l))return o=!1,!1});return o&&n.size===a}function Yn(n,t){var e=function(r){n.prototype[r]=t[r]};return Object.keys(t).forEach(e),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(t).forEach(e),n}function Uo(n){if(!n||typeof n!="object")return n;if(!Fe(n)){if(!Cn(n))return n;n=de(n)}if(Gt(n)){var t={};return n.__iterate(function(r,i){t[i]=Uo(r)}),t}var e=[];return n.__iterate(function(r){e.push(Uo(r))}),e}var Hs=(function(n){function t(e){return e==null?Gs():Wo(e)&&!vr(e)?e:Gs().withMutations(function(r){var i=n(e);Ge(i.size),i.forEach(function(s){return r.add(s)})})}return n&&(t.__proto__=n),t.prototype=Object.create(n&&n.prototype),t.prototype.constructor=t,t.of=function(){return this(arguments)},t.fromKeys=function(r){return this(sr(r).keySeq())},t.intersect=function(r){return r=ye(r).toArray(),r.length?we.intersect.apply(t(r.pop()),r):Gs()},t.union=function(r){return r=ye(r).toArray(),r.length?we.union.apply(t(r.pop()),r):Gs()},t.prototype.toString=function(){return this.__toString("Set {","}")},t.prototype.has=function(r){return this._map.has(r)},t.prototype.add=function(r){return Yo(this,this._map.set(r,r))},t.prototype.remove=function(r){return Yo(this,this._map.remove(r))},t.prototype.clear=function(){return Yo(this,this._map.clear())},t.prototype.map=function(r,i){var s=this,o=!1,a=Yo(this,this._map.mapEntries(function(l){var c=l[1],h=r.call(i,c,c,s);return h!==c&&(o=!0),[h,h]},i));return o?a:this},t.prototype.union=function(){for(var r=[],i=arguments.length;i--;)r[i]=arguments[i];return r=r.filter(function(s){return s.size!==0}),r.length===0?this:this.size===0&&!this.__ownerID&&r.length===1?this.constructor(r[0]):this.withMutations(function(s){for(var o=0;o<r.length;o++)typeof r[o]=="string"?s.add(r[o]):n(r[o]).forEach(function(a){return s.add(a)})})},t.prototype.intersect=function(){for(var r=[],i=arguments.length;i--;)r[i]=arguments[i];if(r.length===0)return this;r=r.map(function(o){return n(o)});var s=[];return this.forEach(function(o){r.every(function(a){return a.includes(o)})||s.push(o)}),this.withMutations(function(o){s.forEach(function(a){o.remove(a)})})},t.prototype.subtract=function(){for(var r=[],i=arguments.length;i--;)r[i]=arguments[i];if(r.length===0)return this;r=r.map(function(o){return n(o)});var s=[];return this.forEach(function(o){r.some(function(a){return a.includes(o)})&&s.push(o)}),this.withMutations(function(o){s.forEach(function(a){o.remove(a)})})},t.prototype.sort=function(r){return Ti(Si(this,r))},t.prototype.sortBy=function(r,i){return Ti(Si(this,i,r))},t.prototype.wasAltered=function(){return this._map.wasAltered()},t.prototype.__iterate=function(r,i){var s=this;return this._map.__iterate(function(o){return r(o,o,s)},i)},t.prototype.__iterator=function(r,i){return this._map.__iterator(r,i)},t.prototype.__ensureOwner=function(r){if(r===this.__ownerID)return this;var i=this._map.__ensureOwner(r);return r?this.__make(i,r):this.size===0?this.__empty():(this.__ownerID=r,this._map=i,this)},t})(vi);Hs.isSet=Wo;var we=Hs.prototype;we[$f]=!0,we[As]=we.remove,we.merge=we.concat=we.union,we.withMutations=Rs,we.asImmutable=Ns,we["@@transducer/init"]=we.asMutable=Ls,we["@@transducer/step"]=function(n,t){return n.add(t)},we["@@transducer/result"]=function(n){return n.asImmutable()},we.__empty=Gs,we.__make=Hf;function Yo(n,t){return n.__ownerID?(n.size=t.size,n._map=t,n):t===n._map?n:t.size===0?n.__empty():n.__make(t)}function Hf(n,t){var e=Object.create(we);return e.size=n?n.size:0,e._map=n,e.__ownerID=t,e}var Gf;function Gs(){return Gf||(Gf=Hf(Hr()))}var Wf=(function(n){function t(e,r,i){if(i===void 0&&(i=1),!(this instanceof t))return new t(e,r,i);if(Cs(i!==0,"Cannot step a Range by 0"),Cs(e!==void 0,"You must define a start value when using Range"),Cs(r!==void 0,"You must define an end value when using Range"),i=Math.abs(i),r<e&&(i=-i),this._start=e,this._end=r,this._step=i,this.size=Math.max(0,Math.ceil((r-e)/i-1)+1),this.size===0){if(el)return el;el=this}}return n&&(t.__proto__=n),t.prototype=Object.create(n&&n.prototype),t.prototype.constructor=t,t.prototype.toString=function(){return this.size===0?"Range []":"Range [ "+this._start+"..."+this._end+(this._step!==1?" by "+this._step:"")+" ]"},t.prototype.get=function(r,i){return this.has(r)?this._start+An(this,r)*this._step:i},t.prototype.includes=function(r){var i=(r-this._start)/this._step;return i>=0&&i<this.size&&i===Math.floor(i)},t.prototype.slice=function(r,i){return Os(r,i,this.size)?this:(r=yi(r,this.size),i=zs(i,this.size),i<=r?new t(0,0):new t(this.get(r,this._end),this.get(i,this._end),this._step))},t.prototype.indexOf=function(r){var i=r-this._start;if(i%this._step===0){var s=i/this._step;if(s>=0&&s<this.size)return s}return-1},t.prototype.lastIndexOf=function(r){return this.indexOf(r)},t.prototype.__iterate=function(r,i){for(var s=this.size,o=this._step,a=i?this._start+(s-1)*o:this._start,l=0;l!==s&&r(a,i?s-++l:l++,this)!==!1;)a+=i?-o:o;return l},t.prototype.__iterator=function(r,i){var s=this.size,o=this._step,a=i?this._start+(s-1)*o:this._start,l=0;return new Ct(function(){if(l===s)return Ee();var c=a;return a+=i?-o:o,Yt(r,i?s-++l:l++,c)})},t.prototype.equals=function(r){return r instanceof t?this._start===r._start&&this._end===r._end&&this._step===r._step:tl(this,r)},t})(ar),el;function rl(n,t,e){for(var r=vf(t),i=0;i!==r.length;)if(n=Fu(n,r[i++],Tt),n===Tt)return e;return n}function Uf(n,t){return rl(this,n,t)}function Yf(n,t){return rl(n,t,Tt)!==Tt}function W0(n){return Yf(this,n)}function Xf(){Ge(this.size);var n={};return this.__iterate(function(t,e){n[e]=t}),n}ye.Iterator=Ct,Yn(ye,{toArray:function(){Ge(this.size);var t=new Array(this.size||0),e=Gt(this),r=0;return this.__iterate(function(i,s){t[r++]=e?[s,i]:i}),t},toIndexedSeq:function(){return new af(this)},toJS:function(){return Uo(this)},toKeyedSeq:function(){return new jo(this,!0)},toMap:function(){return J(this.toKeyedSeq())},toObject:Xf,toOrderedMap:function(){return Gr(this.toKeyedSeq())},toOrderedSet:function(){return Ti(Gt(this)?this.valueSeq():this)},toSet:function(){return Hs(Gt(this)?this.valueSeq():this)},toSetSeq:function(){return new uf(this)},toSeq:function(){return je(this)?this.toIndexedSeq():Gt(this)?this.toKeyedSeq():this.toSetSeq()},toStack:function(){return Ho(Gt(this)?this.valueSeq():this)},toList:function(){return st(Gt(this)?this.valueSeq():this)},toString:function(){return"[Collection]"},__toString:function(t,e){return this.size===0?t+e:t+" "+this.toSeq().map(this.__toStringMapper).join(", ")+" "+e},concat:function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return Dt(this,A0(this,t))},includes:function(t){return this.some(function(e){return ve(e,t)})},entries:function(){return this.__iterator(He)},every:function(t,e){Ge(this.size);var r=!0;return this.__iterate(function(i,s,o){if(!t.call(e,i,s,o))return r=!1,!1}),r},filter:function(t,e){return Dt(this,ff(this,t,e,!0))},partition:function(t,e){return S0(this,t,e)},find:function(t,e,r){var i=this.findEntry(t,e);return i?i[1]:r},forEach:function(t,e){return Ge(this.size),this.__iterate(e?t.bind(e):t)},join:function(t){Ge(this.size),t=t!==void 0?""+t:",";var e="",r=!0;return this.__iterate(function(i){r?r=!1:e+=t,e+=i!=null?i.toString():""}),e},keys:function(){return this.__iterator(xi)},map:function(t,e){return Dt(this,hf(this,t,e))},reduce:function(t,e,r){return Jf(this,t,e,r,arguments.length<2,!1)},reduceRight:function(t,e,r){return Jf(this,t,e,r,arguments.length<2,!0)},reverse:function(){return Dt(this,Iu(this,!0))},slice:function(t,e){return Dt(this,Pu(this,t,e,!0))},some:function(t,e){Ge(this.size);var r=!1;return this.__iterate(function(i,s,o){if(t.call(e,i,s,o))return r=!0,!1}),r},sort:function(t){return Dt(this,Si(this,t))},values:function(){return this.__iterator($e)},butLast:function(){return this.slice(0,-1)},isEmpty:function(){return this.size!==void 0?this.size===0:!this.some(function(){return!0})},count:function(t,e){return mi(t?this.toSeq().filter(t,e):this)},countBy:function(t,e){return b0(this,t,e)},equals:function(t){return tl(this,t)},entrySeq:function(){var t=this;if(t._cache)return new wi(t._cache);var e=t.toSeq().map(Y0).toIndexedSeq();return e.fromEntrySeq=function(){return t.toSeq()},e},filterNot:function(t,e){return this.filter(nl(t),e)},findEntry:function(t,e,r){var i=r;return this.__iterate(function(s,o,a){if(t.call(e,s,o,a))return i=[o,s],!1}),i},findKey:function(t,e){var r=this.findEntry(t,e);return r&&r[0]},findLast:function(t,e,r){return this.toKeyedSeq().reverse().find(t,e,r)},findLastEntry:function(t,e,r){return this.toKeyedSeq().reverse().findEntry(t,e,r)},findLastKey:function(t,e){return this.toKeyedSeq().reverse().findKey(t,e)},first:function(t){return this.find(Hh,null,t)},flatMap:function(t,e){return Dt(this,O0(this,t,e))},flatten:function(t){return Dt(this,pf(this,t,!0))},fromEntrySeq:function(){return new lf(this)},get:function(t,e){return this.find(function(r,i){return ve(i,t)},void 0,e)},getIn:Uf,groupBy:function(t,e){return w0(this,t,e)},has:function(t){return this.get(t,Tt)!==Tt},hasIn:W0,isSubset:function(t){return t=typeof t.includes=="function"?t:ye(t),this.every(function(e){return t.includes(e)})},isSuperset:function(t){return t=typeof t.isSubset=="function"?t:ye(t),t.isSubset(this)},keyOf:function(t){return this.findKey(function(e){return ve(e,t)})},keySeq:function(){return this.toSeq().map(U0).toIndexedSeq()},last:function(t){return this.toSeq().reverse().first(t)},lastKeyOf:function(t){return this.toKeyedSeq().reverse().keyOf(t)},max:function(t){return Vo(this,t)},maxBy:function(t,e){return Vo(this,e,t)},min:function(t){return Vo(this,t?Zf(t):Qf)},minBy:function(t,e){return Vo(this,e?Zf(e):Qf,t)},rest:function(){return this.slice(1)},skip:function(t){return t===0?this:this.slice(Math.max(0,t))},skipLast:function(t){return t===0?this:this.slice(0,-Math.max(0,t))},skipWhile:function(t,e){return Dt(this,df(this,t,e,!0))},skipUntil:function(t,e){return this.skipWhile(nl(t),e)},sortBy:function(t,e){return Dt(this,Si(this,e,t))},take:function(t){return this.slice(0,Math.max(0,t))},takeLast:function(t){return this.slice(-Math.max(0,t))},takeWhile:function(t,e){return Dt(this,M0(this,t,e))},takeUntil:function(t,e){return this.takeWhile(nl(t),e)},update:function(t){return t(this)},valueSeq:function(){return this.toIndexedSeq()},hashCode:function(){return this.__hash||(this.__hash=X0(this))}});var Ae=ye.prototype;Ae[Uh]=!0,Ae[Ro]=Ae.values,Ae.toJSON=Ae.toArray,Ae.__toStringMapper=ks,Ae.inspect=Ae.toSource=function(){return this.toString()},Ae.chain=Ae.flatMap,Ae.contains=Ae.includes,Yn(sr,{flip:function(){return Dt(this,cf(this))},mapEntries:function(t,e){var r=this,i=0;return Dt(this,this.toSeq().map(function(s,o){return t.call(e,[o,s],i++,r)}).fromEntrySeq())},mapKeys:function(t,e){var r=this;return Dt(this,this.toSeq().flip().map(function(i,s){return t.call(e,i,s,r)}).flip())}});var Ws=sr.prototype;Ws[Co]=!0,Ws[Ro]=Ae.entries,Ws.toJSON=Xf,Ws.__toStringMapper=function(n,t){return ks(t)+": "+ks(n)},Yn(Gn,{toKeyedSeq:function(){return new jo(this,!1)},filter:function(t,e){return Dt(this,ff(this,t,e,!1))},findIndex:function(t,e){var r=this.findEntry(t,e);return r?r[0]:-1},indexOf:function(t){var e=this.keyOf(t);return e===void 0?-1:e},lastIndexOf:function(t){var e=this.lastKeyOf(t);return e===void 0?-1:e},reverse:function(){return Dt(this,Iu(this,!1))},slice:function(t,e){return Dt(this,Pu(this,t,e,!1))},splice:function(t,e){var r=arguments.length;if(e=Math.max(e||0,0),r===0||r===2&&!e)return this;t=yi(t,t<0?this.count():this.size);var i=this.slice(0,t);return Dt(this,r===1?i:i.concat($r(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){var r=this.findLastEntry(t,e);return r?r[0]:-1},first:function(t){return this.get(0,t)},flatten:function(t){return Dt(this,pf(this,t,!1))},get:function(t,e){return t=An(this,t),t<0||this.size===1/0||this.size!==void 0&&t>this.size?e:this.find(function(r,i){return i===t},void 0,e)},has:function(t){return t=An(this,t),t>=0&&(this.size!==void 0?this.size===1/0||t<this.size:this.indexOf(t)!==-1)},interpose:function(t){return Dt(this,z0(this,t))},interleave:function(){var t=[this].concat($r(arguments)),e=Do(this.toSeq(),ar.of,t),r=e.flatten(!0);return e.size&&(r.size=e.size*t.length),Dt(this,r)},keySeq:function(){return Wf(0,this.size)},last:function(t){return this.get(-1,t)},skipWhile:function(t,e){return Dt(this,df(this,t,e,!1))},zip:function(){var t=[this].concat($r(arguments));return Dt(this,Do(this,Kf,t))},zipAll:function(){var t=[this].concat($r(arguments));return Dt(this,Do(this,Kf,t,!0))},zipWith:function(t){var e=$r(arguments);return e[0]=this,Dt(this,Do(this,t,e))}});var Oi=Gn.prototype;Oi[ko]=!0,Oi[zn]=!0,Yn(vi,{get:function(t,e){return this.has(t)?t:e},includes:function(t){return this.has(t)},keySeq:function(){return this.valueSeq()}});var zi=vi.prototype;zi.has=Ae.includes,zi.contains=zi.includes,zi.keys=zi.values,Yn(Tn,Ws),Yn(ar,Oi),Yn(bi,zi);function Jf(n,t,e,r,i,s){return Ge(n.size),n.__iterate(function(o,a,l){i?(i=!1,e=o):e=t.call(r,e,o,a,l)},s),e}function U0(n,t){return t}function Y0(n,t){return[t,n]}function nl(n){return function(){return!n.apply(this,arguments)}}function Zf(n){return function(){return-n.apply(this,arguments)}}function Kf(){return $r(arguments)}function Qf(n,t){return n<t?1:n>t?-1:0}function X0(n){if(n.size===1/0)return 0;var t=vr(n),e=Gt(n),r=t?1:0;return n.__iterate(e?t?function(i,s){r=31*r+td(Ve(i),Ve(s))|0}:function(i,s){r=r+td(Ve(i),Ve(s))|0}:t?function(i){r=31*r+Ve(i)|0}:function(i){r=r+Ve(i)|0}),J0(n.size,r)}function J0(n,t){return t=Ts(t,3432918353),t=Ts(t<<15|t>>>-15,461845907),t=Ts(t<<13|t>>>-13,5),t=(t+3864292196|0)^n,t=Ts(t^t>>>16,2246822507),t=Ts(t^t>>>13,3266489909),t=Fo(t^t>>>16),t}function td(n,t){return n^t+2654435769+(n<<6)+(n>>2)|0}var Ti=(function(n){function t(e){return e==null?il():Qu(e)?e:il().withMutations(function(r){var i=vi(e);Ge(i.size),i.forEach(function(s){return r.add(s)})})}return n&&(t.__proto__=n),t.prototype=Object.create(n&&n.prototype),t.prototype.constructor=t,t.of=function(){return this(arguments)},t.fromKeys=function(r){return this(sr(r).keySeq())},t.prototype.toString=function(){return this.__toString("OrderedSet {","}")},t})(Hs);Ti.isOrderedSet=Qu;var Xn=Ti.prototype;Xn[zn]=!0,Xn.zip=Oi.zip,Xn.zipWith=Oi.zipWith,Xn.zipAll=Oi.zipAll,Xn.__empty=il,Xn.__make=ed;function ed(n,t){var e=Object.create(Xn);return e.size=n?n.size:0,e._map=n,e.__ownerID=t,e}var rd;function il(){return rd||(rd=ed(qs()))}var Z0={LeftThenRight:-1,RightThenLeft:1};function K0(n){if(On(n))throw new Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(or(n))throw new Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(n===null||typeof n!="object")throw new Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}var Et=function(t,e){var r;K0(t);var i=function(a){var l=this;if(a instanceof i)return a;if(!(this instanceof i))return new i(a);if(!r){r=!0;var c=Object.keys(t),h=s._indices={};s._name=e,s._keys=c,s._defaultValues=t;for(var f=0;f<c.length;f++){var g=c[f];h[g]=f,s[g]?typeof console=="object"&&console.warn&&console.warn("Cannot define "+ol(this)+' with property "'+g+'" since that property name is part of the Record API.'):Q0(s,g)}}return this.__ownerID=void 0,this._values=st().withMutations(function(p){p.setSize(l._keys.length),sr(a).forEach(function(m,v){p.set(l._indices[v],m===l._defaultValues[v]?void 0:m)})}),this},s=i.prototype=Object.create(Wt);return s.constructor=i,e&&(i.displayName=e),i};Et.prototype.toString=function(){for(var t=ol(this)+" { ",e=this._keys,r,i=0,s=e.length;i!==s;i++)r=e[i],t+=(i?", ":"")+r+": "+ks(this.get(r));return t+" }"},Et.prototype.equals=function(t){return this===t||On(t)&&Ci(this).equals(Ci(t))},Et.prototype.hashCode=function(){return Ci(this).hashCode()},Et.prototype.has=function(t){return this._indices.hasOwnProperty(t)},Et.prototype.get=function(t,e){if(!this.has(t))return e;var r=this._indices[t],i=this._values.get(r);return i===void 0?this._defaultValues[t]:i},Et.prototype.set=function(t,e){if(this.has(t)){var r=this._values.set(this._indices[t],e===this._defaultValues[t]?void 0:e);if(r!==this._values&&!this.__ownerID)return sl(this,r)}return this},Et.prototype.remove=function(t){return this.set(t)},Et.prototype.clear=function(){var t=this._values.clear().setSize(this._keys.length);return this.__ownerID?this:sl(this,t)},Et.prototype.wasAltered=function(){return this._values.wasAltered()},Et.prototype.toSeq=function(){return Ci(this)},Et.prototype.toJS=function(){return Uo(this)},Et.prototype.entries=function(){return this.__iterator(He)},Et.prototype.__iterator=function(t,e){return Ci(this).__iterator(t,e)},Et.prototype.__iterate=function(t,e){return Ci(this).__iterate(t,e)},Et.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var e=this._values.__ensureOwner(t);return t?sl(this,e,t):(this.__ownerID=t,this._values=e,this)},Et.isRecord=On,Et.getDescriptiveName=ol;var Wt=Et.prototype;Wt[Xh]=!0,Wt[As]=Wt.remove,Wt.deleteIn=Wt.removeIn=Vu,Wt.getIn=Uf,Wt.hasIn=Ae.hasIn,Wt.merge=Ef,Wt.mergeWith=Af,Wt.mergeIn=$u,Wt.mergeDeep=zf,Wt.mergeDeepWith=Tf,Wt.mergeDeepIn=Hu,Wt.setIn=ju,Wt.update=Bu,Wt.updateIn=qu,Wt.withMutations=Rs,Wt.asMutable=Ls,Wt.asImmutable=Ns,Wt[Ro]=Wt.entries,Wt.toJSON=Wt.toObject=Ae.toObject,Wt.inspect=Wt.toSource=function(){return this.toString()};function sl(n,t,e){var r=Object.create(Object.getPrototypeOf(n));return r._values=t,r.__ownerID=e,r}function ol(n){return n.constructor.displayName||n.constructor.name||"Record"}function Ci(n){return wu(n._keys.map(function(t){return[t,n.get(t)]}))}function Q0(n,t){try{Object.defineProperty(n,t,{get:function(){return this.get(t)},set:function(e){Cs(this.__ownerID,"Cannot set on an immutable record."),this.set(t,e)}})}catch{}}var tv=(function(n){function t(e,r){if(!(this instanceof t))return new t(e,r);if(this._value=e,this.size=r===void 0?1/0:Math.max(0,r),this.size===0){if(al)return al;al=this}}return n&&(t.__proto__=n),t.prototype=Object.create(n&&n.prototype),t.prototype.constructor=t,t.prototype.toString=function(){return this.size===0?"Repeat []":"Repeat [ "+this._value+" "+this.size+" times ]"},t.prototype.get=function(r,i){return this.has(r)?this._value:i},t.prototype.includes=function(r){return ve(this._value,r)},t.prototype.slice=function(r,i){var s=this.size;return Os(r,i,s)?this:new t(this._value,zs(i,s)-yi(r,s))},t.prototype.reverse=function(){return this},t.prototype.indexOf=function(r){return ve(this._value,r)?0:-1},t.prototype.lastIndexOf=function(r){return ve(this._value,r)?this.size:-1},t.prototype.__iterate=function(r,i){for(var s=this.size,o=0;o!==s&&r(this._value,i?s-++o:o++,this)!==!1;);return o},t.prototype.__iterator=function(r,i){var s=this,o=this.size,a=0;return new Ct(function(){return a===o?Ee():Yt(r,i?o-++a:a++,s._value)})},t.prototype.equals=function(r){return r instanceof t?ve(this._value,r._value):tl(this,r)},t})(ar),al;function Bt(n,t){return nd([],t||ev,n,"",t&&t.length>2?[]:void 0,{"":n})}function nd(n,t,e,r,i,s){if(typeof e!="string"&&!or(e)&&(xu(e)||yu(e)||Nu(e))){if(~n.indexOf(e))throw new TypeError("Cannot convert circular structure to Immutable");n.push(e),i&&r!==""&&i.push(r);var o=t.call(s,r,de(e).map(function(a,l){return nd(n,t,a,l,i,e)}),i&&i.slice());return n.pop(),i&&i.pop(),o}return e}function ev(n,t){return je(t)?t.toList():Gt(t)?t.toMap():t.toSet()}var rv="5.1.3",nv=ye;const iv=Object.freeze(Object.defineProperty({__proto__:null,Collection:ye,Iterable:nv,List:st,Map:J,OrderedMap:Gr,OrderedSet:Ti,PairSorting:Z0,Range:Wf,Record:Et,Repeat:tv,Seq:de,Set:Hs,Stack:Ho,fromJS:Bt,get:Fu,getIn:rl,has:xf,hasIn:Yf,hash:Ve,is:ve,isAssociative:Io,isCollection:Fe,isImmutable:or,isIndexed:je,isKeyed:Gt,isList:Ju,isMap:No,isOrdered:vr,isOrderedMap:Mu,isOrderedSet:Qu,isPlainObject:Nu,isRecord:On,isSeq:Po,isSet:Wo,isStack:$o,isValueObject:Eu,merge:C0,mergeDeep:I0,mergeDeepWith:P0,mergeWith:k0,remove:_f,removeIn:Mf,set:bf,setIn:Sf,update:Du,updateIn:Un,version:rv},Symbol.toStringTag,{value:"Module"})),re="MODE_IDLE",Jn="MODE_2D_ZOOM_IN",Zn="MODE_2D_ZOOM_OUT",Kn="MODE_2D_PAN",Qn="MODE_3D_VIEW",ki="MODE_3D_FIRST_PERSON",xr="MODE_WAITING_DRAWING_LINE",_r="MODE_DRAGGING_LINE",br="MODE_DRAGGING_VERTEX",wr="MODE_DRAGGING_ITEM",Sr="MODE_DRAGGING_HOLE",We="MODE_DRAWING_LINE",Ue="MODE_DRAWING_HOLE",ur="MODE_DRAWING_ITEM",cn="MODE_ROTATING_ITEM",ul="MODE_UPLOADING_IMAGE",ll="MODE_FITTING_IMAGE",cl="MODE_VIEWING_CATALOG",id="MODE_CONFIGURING_PROJECT",hl=[re,Jn,Zn,Kn,xr,We,Ue,ur,_r,br,wr,Sr,ll,ul,cn],sv="mm",Wr="cm",sd=[sv,Wr,"m","in","ft","mi"],Ur=1e-6,lr={DELETE:46,BACKSPACE:8,ESC:27,Z:90,ALT:18,C:67,V:86,CTRL:17,ENTER:13,TAB:9},De=(n,t=6)=>n&&t?parseFloat(parseFloat(n.toString()).toFixed(t)):0,Ii=n=>{let t=n;return t<0&&(t=~t+1),t};function fl(n,t){return n.x===t.x?n.y-t.y:n.x-t.x}function Xo(n,t){return fl(n,t)>0?t:n}function dl(n,t){return fl(n,t)>0?n:t}function Us(n){return n.sort(fl)}function Oe(n,t,e,r){let i=n-e,s=t-r;return Math.sqrt(i*i+s*s)}function Jo(n,t){let{x:e,y:r}=n,{x:i,y:s}=t;return Oe(e,r,i,s)}function Zo(n){return{a:0,b:1,c:-n}}function Ko(n){return{a:1,b:0,c:-n}}function ov(n,t,e,r,i){return Ii(n*r+t*i+e)/Math.sqrt(n*n+t*t)}function av(n,t,e,r,i){let s=n*n+t*t;return{x:(t*(t*r-n*i)-n*e)/s,y:(n*-t*r+n*i-t*e)/s}}function Ys(n,t,e,r,i,s){let o=t*r-n*i;if(o===0)return;let a=(n*s-e*r)/o;return{x:(e*i-t*s)/o,y:a}}function uv(n,t,e,r){let{x:i,y:s}=n,{x:o,y:a}=t,{x:l,y:c}=e,{x:h,y:f}=r,g=(f-c)*(o-i)-(h-l)*(a-s),p=(h-l)*(s-c)-(f-c)*(i-l),m=(o-i)*(s-c)-(a-s)*(i-l);if(Ii(g)<=Ur){if(Ii(p)<=Ur&&Ii(m)<=Ur){let S=(z,R)=>z.x===R.x?z.y-R.y:z.x-R.x,A=[n,t].sort(S),C=[e.toJS(),r.toJS()].sort(S),[O,M]=[A,C].sort((z,R)=>S(z[0],R[0]));return O[1].x===M[0].x?{type:M[0].y<=O[1].y?"colinear":"none"}:{type:M[0].x<=O[1].x?"colinear":"none"}}return{type:"parallel"}}let v=p/g,_=m/g;return v>=0-Ur&&v<=1+Ur&&_>=0-Ur&&_<=1+Ur?{type:"intersecting",point:{x:i+v*(o-i),y:s+v*(a-s)}}:{type:"none"}}function od(n,t,e,r,i,s){let o=i-n,a=s-t,l=e-n,c=r-t,h=o*l+a*c,f=l*l+c*c,g=-1;f!=0&&(g=h/f);let p,m;g<0?(p=n,m=t):g>1?(p=e,m=r):(p=n+g*l,m=t+g*c);let v=i-p,_=s-m;return Math.sqrt(v*v+_*_)}function lv(n,t,e,r,i,s,o=Ur){return od(n,t,e,r,i,s)<=o}function cv(n,t,e,r,i,s){if(n===e)return{x:n,y:s};if(t===r)return{x:i,y:t};let o=(r-t)/(e-n),a=t-o*n,l=-1/o,h=(s-l*i-a)/(o-l),f=o*h+a;return{x:h,y:f}}function ze(n,t,e,r,i,s){let o=Oe(n,t,e,r),l=Oe(n,t,i,s)/o;return n>e&&(l=hv(l,0,1,1,0)),l}function hv(n,t,e,r,i){return r+(i-r)*(n-t)/(e-t)}function fv(n,t,e,r){return-Math.atan2(t-r,e-n)*180/Math.PI}function pl(n,t,e,r){return Math.atan2(r-t,e-n)}function dv(n,t,e,r){return Math.atan2(Math.abs(r-t),Math.abs(e-n))}function Mr({x:n,y:t},{x:e,y:r}){return Ii(n-e)<=Ur&&Ii(t-r)<=Ur}function Qo(n,t,e,r,i,s=6){let o=pl(n,t,e,r);return{x:De(n+Math.cos(o)*i,s),y:De(t+Math.sin(o)*i,s)}}function pv(n,t,e){let r=n.length>>1,i,s,o=n[2*r-3]-e,a=n[2*r-2]-t,l=n[2*r-1]-e;if(a===0&&l===0)return!1;for(let h=0;h<r;h++){if(i=a,o=l,a=n[2*h]-t,l=n[2*h+1]-e,a===0&&l===0)return!1;o!==l&&(s=l>o)}let c=0;for(let h=0;h<r;h++){if(i=a,o=l,a=n[2*h]-t,l=n[2*h+1]-e,o<0&&l<0||o>0&&l>0||i<0&&a<0)continue;if(o===l&&Math.min(i,a)<0)return!0;if(o===l)continue;let f=i+(a-i)*-o/(l-o);if(f===0)return!1;f>0&&c++,o===0&&s&&l>o&&c--,o===0&&!s&&l<o&&c--,s=l>o}return(c&1)===1}function gv(n,t){let e=Math.cos(n);return e<t?0:e}function mv(n,t){let e=Math.sin(n);return e<t?0:e}function yv(n,t,e,r){return{x:(n+e)/2,y:(t+r)/2}}function vv(n){let t=n.reduce((e,r)=>({x:e.x+r.x,y:e.y+r.y}),{x:0,y:0});return{x:t.x/n.length,y:t.y/n.length}}function ad(n,t,e,r,i){let s=i*Math.PI/180,o=Math.cos(s),a=Math.sin(s),l=n-e,c=t-r;return{x:o*l-a*c+e,y:a*l+o*c+r}}const gl="SNAP_POINT",ml="SNAP_LINE",yl="SNAP_SEGMENT",vl="SNAP_GRID",ud="SNAP_GUIDE",xv=J({SNAP_POINT:!0,SNAP_LINE:!0,SNAP_SEGMENT:!0,SNAP_GRID:!1,SNAP_GUIDE:!0});class _v extends Et({type:"point",x:-1,y:-1,radius:1,priority:1,related:st()}){nearestPoint(t,e){return{x:this.x,y:this.y,distance:Oe(this.x,this.y,t,e)}}isNear(t,e,r){return~(this.x-t)+1<r&&~(this.y-e)+1<r}}class bv extends Et({type:"line",a:-1,b:-1,c:-1,radius:1,priority:1,related:st()}){nearestPoint(t,e){return{...av(this.a,this.b,this.c,t,e),distance:ov(this.a,this.b,this.c,t,e)}}isNear(t,e,r){return!0}}class wv extends Et({type:"line-segment",x1:-1,y1:-1,x2:-1,y2:-1,radius:1,priority:1,related:st()}){nearestPoint(t,e){return{...cv(this.x1,this.y1,this.x2,this.y2,t,e),distance:od(this.x1,this.y1,this.x2,this.y2,t,e)}}isNear(t,e,r){return!0}}class Sv extends Et({type:"grid",x:-1,y:-1,radius:1,priority:1,related:st()}){nearestPoint(t,e){return{x:this.x,y:this.y,distance:Oe(this.x,this.y,t,e)}}isNear(t,e,r){return~(this.x-t)+1<r&&~(this.y-e)+1<r}}function Yr(n,t,e,r){let i={point:r.get(gl),line:r.get(ml),"line-segment":r.get(yl),grid:r.get(vl)};return n.valueSeq().filter(s=>i[s.type]&&s.isNear(t,e,s.radius)).map(s=>({snap:s,point:s.nearestPoint(t,e)})).filter(({snap:{radius:s},point:{distance:o}})=>o<s).min(({snap:{priority:s},point:{distance:o}},{snap:{priority:a},point:{distance:l}})=>s===a?o<l?-1:1:s>a?-1:1)}function xl(n,t,e,r,i,s){return s=st([s]),n.push(new _v({x:t,y:e,radius:r,priority:i,related:s}))}function ta(n,t,e,r,i,s,o){return o=st([o]),n.withMutations(a=>{if(a.some(c=>c.type==="line"&&t===c.a&&e===c.b&&r===c.c))return a;a.valueSeq().filter(c=>c.type==="line").map(c=>Ys(c.a,c.b,c.c,t,e,r)).filter(c=>c!==void 0).forEach(({x:c,y:h})=>xl(a,c,h,20,40)),a.push(new bv({a:t,b:e,c:r,radius:i,priority:s,related:o}))})}function Xs(n,t,e,r,i,s,o,a){return a=st([a]),n.push(new wv({x1:t,y1:e,x2:r,y2:i,radius:s,priority:o,related:a}))}function Mv(n,t,e,r,i,s){return s=st([s]),n.push(new Sv({x:t,y:e,radius:r,priority:i,related:s}))}let hn=(n,t,e)=>n?J(n).map(r=>new t(r)).toMap():e||J();class _l extends Et({id:"",type:"",properties:J()},"Grid"){constructor(t={}){super({...t,properties:Bt(t.properties||{})})}}const Ev=J({h1:new _l({id:"h1",type:"horizontal-streak",properties:{step:20,colors:["#808080","#ddd","#ddd","#ddd","#ddd"]}}),v1:new _l({id:"v1",type:"vertical-streak",properties:{step:20,colors:["#808080","#ddd","#ddd","#ddd","#ddd"]}})});class ld extends Et({vertices:st(),lines:st(),holes:st(),areas:st(),items:st()},"ElementsSet"){constructor(t={}){super({vertices:st(t.vertices||[]),lines:st(t.lines||[]),holes:st(t.holes||[]),areas:st(t.areas||[]),items:st(t.items||[])})}}const Pi={id:"",type:"",prototype:"",name:"",misc:J(),selected:!1,properties:J(),visible:!0};let cd=class extends Et({...Pi,x:-1,y:-1,prototype:"vertices",lines:st(),areas:st()},"Vertex"){constructor(t={}){super({...t,lines:st(t.lines||[]),areas:st(t.areas||[])})}},hd=class extends Et({...Pi,prototype:"lines",vertices:st(),holes:st()},"Line"){constructor(t={}){super({...t,properties:Bt(t.properties||{}),vertices:st(t.vertices||[]),holes:st(t.holes||[])})}},fd=class extends Et({...Pi,prototype:"holes",offset:-1,line:""},"Hole"){constructor(t={}){super({...t,properties:Bt(t.properties||{})})}},dd=class extends Et({...Pi,prototype:"areas",vertices:st(),holes:st()},"Area"){constructor(t={}){super({...t,properties:Bt(t.properties||{}),vertices:st(t.vertices||[])})}},pd=class extends Et({...Pi,prototype:"items",x:0,y:0,rotation:0},"Item"){constructor(t={}){super({...t,properties:Bt(t.properties||{})})}},bl=class extends Et({id:"",altitude:0,order:0,opacity:1,name:"",visible:!0,vertices:J(),lines:J(),holes:J(),areas:J(),items:J(),selected:new ld},"Layer"){constructor(t={}){super({...t,vertices:hn(t.vertices,cd),lines:hn(t.lines,hd),holes:hn(t.holes,fd),areas:hn(t.areas,dd),items:hn(t.items,pd),selected:new ld(t.selected)})}},wl=class extends Et({...Pi,prototype:"groups",x:0,y:0,rotation:0,elements:J()},"Group"){constructor(t={}){super({...t,properties:Bt(t.properties||{}),elements:Bt(t.elements||{})})}};const Av=J({"layer-1":new bl({id:"layer-1",name:"default"})});let ea=class extends Et({unit:"cm",layers:J(),grids:J(),selectedLayer:null,groups:J(),width:3e3,height:2e3,meta:J(),guides:J()},"Scene"){constructor(t={}){let e=hn(t.layers,bl,Av);super({...t,grids:hn(t.grids,_l,Ev),layers:e,selectedLayer:e.first().id,groups:hn(t.groups||{},wl),meta:t.meta?Bt(t.meta):J(),guides:t.guides?Bt(t.guides):J({horizontal:J(),vertical:J(),circular:J()})})}};class Ov extends Et({name:"",prototype:"",info:J(),properties:J()},"CatalogElement"){constructor(t={}){super({...t,info:Bt(t.info),properties:Bt(t.properties)})}}let Sl=class extends Et({ready:!1,page:"root",path:st(),elements:J()},"Catalog"){constructor(t={}){let e=hn(t.elements,Ov);super({elements:e,ready:!e.isEmpty()})}factoryElement(t,e,r){if(!this.elements.has(t)){let o=this.elements.map(a=>a.name).toArray();throw new Error(`Element ${t} does not exist in catalog ${o}`)}const i=this.elements.get(t),s=i.properties.map((o,a)=>r&&r.has(a)?r.get(a):o.get("defaultValue"));switch(i.prototype){case"lines":return new hd(e).merge({properties:s});case"holes":return new fd(e).merge({properties:s});case"areas":return new dd(e).merge({properties:s});case"items":return new pd(e).merge({properties:s});default:throw new Error("prototype not valid")}}};class gd extends Et({list:st(),first:null,last:null,redoList:st()},"HistoryStructure"){constructor(t={}){super({list:Bt(t.list||[]),first:new ea(t.scene),last:new ea(t.last||t.scene)})}}let ra=class extends Et({mode:re,scene:new ea,sceneHistory:new gd,catalog:new Sl,viewer2D:J(),mouse:J({x:0,y:0}),zoom:0,snapMask:xv,snapElements:st(),activeSnapElement:null,drawingSupport:J(),draggingSupport:J(),rotatingSupport:J(),errors:st(),warnings:st(),clipboardProperties:J(),selectedElementsHistory:st(),misc:J(),alterate:!1},"State"){constructor(t={}){super({...t,scene:new ea(t.scene),sceneHistory:new gd(t),catalog:new Sl(t.catalog||{}),viewer2D:J(t.viewer2D||{}),drawingSupport:J(t.drawingSupport||{}),draggingSupport:J(t.draggingSupport||{}),rotatingSupport:J(t.rotatingSupport||{}),misc:t.misc?Bt(t.misc):J()})}};function na(n){let t=[];for(let e=0;e<n;++e)t.push([]);return t}class md{constructor(t,e){It(this,"u");It(this,"v");this.u=t,this.v=e}}class zv{constructor(t){It(this,"count");It(this,"subgraphs");It(this,"time");It(this,"V");It(this,"E");It(this,"adj");It(this,"children");this.count=0,this.subgraphs=[],this.time=0,this.children=0,this.V=t,this.E=0,this.adj=[],this.adj=na(t)}addEdge(t,e){this.adj[t].push(e),this.E++}_BCCUtil(t,e,r,i,s){e[t]=r[t]=++this.time,this.children=0,this.adj[t].forEach(o=>{if(e[o]==-1){if(this.children++,s[o]=t,i.push(new md(t,o)),this._BCCUtil(o,e,r,i,s),r[t]>r[o]&&(r[t]=r[o]),e[t]==1&&this.children>1||e[t]>1&&r[o]>=e[t]){let a=[];for(;i[i.length-1].u!=t||i[i.length-1].v!=o;)a.push(i[i.length-1]),i.splice(i.length-1,1);a.push(i[i.length-1]),this.subgraphs.push(a),a=[],i.splice(i.length-1,1),this.count++}}else o!=s[t]&&e[o]<r[t]&&(r[t]>e[o]&&(r[t]=e[o]),i.push(new md(t,o)))})}BCC(){let t=this.V,e=na(t),r=na(t),i=na(t),s=[];for(let o=0;o<t;o++)e[o]=-1,r[o]=-1,i[o]=-1;for(let o=0;o<t;o++){e[o]==-1&&this._BCCUtil(o,e,r,s,i);let a=0,l=[];for(;s.length>0;)a=1,l.push(s[s.length-1]),s.splice(s.length-1,1);a==1&&(this.subgraphs.push(l),l=[],this.count++)}}}const Tv=(n,t)=>{let e=[];return n.forEach(r=>{e.push([]);let i=Cv(r);i.forEach(s=>{t.adj[s].forEach(a=>{s<=a&&i.has(a)&&e[e.length-1].push([s,a])})})}),e},Cv=n=>{let t=new Set;return n.forEach(e=>{t.add(e.u),t.add(e.v)}),t};function kv(n,t){return[n[0]-t[0],n[1]-t[1]]}function yd(n,t){return(n%t+t)%t}function Iv(n){return n.map(function(e){return{ev:e,color:0,direction:-1}})}function Pv(n,t){let e=kv(t,n);return Math.atan2(e[1],e[0])}function Rv(n,t){return n.map(function(e,r){let i=[];return t.forEach(function(s,o){let a,l;s[0]===r&&(a=s[1],l=1),s[1]===r&&(a=s[0],l=0),a!==void 0&&i.push({index:o,endpoint:a,angle:Pv(e,n[a]),edge:s,position:l})}),i.sort(function(s,o){return o.angle-s.angle}),i})}function vd(n,t){let e,r;for(e=0;e<t.length;e+=1)if(t[e].color<2)return r=-1*t[e].direction,_d(t,e,r),{edge:e,direction:r,position:r===-1?0:1}}function xd(n,t,e,r){let i=n[r[t][e]],s=i.length,o,a,l;for(l=0;l<s;l+=1)if(o=i[l],o.index===t)return a=i[yd(l+1,i.length)],{edge:a.index,vertex:a.endpoint,position:a.position,direction:a.position?1:-1}}function _d(n,t,e){n[t].color+=1,n[t].direction=e}function Lv(n,t){let e=Iv(t),r=Rv(n,t),i=[],s=[],o=[],a,l,c,h,f=vd(r,e);for(;f!==void 0;){for(a=[t[f.edge][yd(f.position+1,2)],t[f.edge][f.position]],l=[f.edge],c=[f.direction],h=xd(r,f.edge,f.position,t);h.edge!==f.edge;)a.push(h.vertex),l.push(h.edge),c.push(h.direction),_d(e,h.edge,h.direction),h=xd(r,h.edge,h.position,t);s.push(l),i.push(a),o.push(c),f=vd(r,e)}return{v_cycles:i,e_cycles:s,dir_e_cycles:o,ev_mapping:e}}function Nv(n,t){let e=[],r,i,s;for(s=0;s<t.length;s+=1)r=t[s],i=n[s],(r.length<3||i[0]!==i[i.length-1])&&e.push(s);return e}function Fv(n,t){let e=Lv(n,t),r=e.v_cycles,i=e.e_cycles;Nv(r,i).forEach(g=>{r.splice(g,1),i.splice(g,1)});let o=e.dir_e_cycles,l=e.e_cycles.map((g,p)=>g.map(function(m,v){let _,S;return o[p][v]>0?(_=t[m][0],S=t[m][1]):(_=t[m][1],S=t[m][0]),(n[S][0]-n[_][0])*(n[S][1]+n[_][1])})).map(g=>g.reduce((p,m)=>p+m)),c=l.filter(g=>g>0).length,h=l.length-c,f=c>=h?1:-1;return{v_cycles:e.v_cycles.filter((g,p)=>f*l[p]>0),e_cycles:e.e_cycles.filter((g,p)=>f*l[p]>0),ev_mapping:e.ev_mapping}}function jv(n,t){let e=st();const r=new zv(n.length);t.forEach(([l,c])=>{r.addEdge(l,c),r.addEdge(c,l)}),r.BCC();const i=r.subgraphs.filter(l=>l.length>=3),s=Tv(i,r),o=[];return s.forEach(l=>{l.forEach(c=>o.push(c))}),Fv(n,o).v_cycles.forEach(l=>{l.shift(),e=e.push(l)}),e}function Vv(n){let t=0,e=0,r=n.size;for(t=0;t<r;t++){let{x:i,y:s}=n.get(t)||{x:0,y:0},{x:o,y:a}=n.get((t+1)%r)||{x:0,y:0};e+=(o-i)*(a+s)}return e>0}function Ml(n,t=st(),e=J()){let{width:r,height:i}=n,s,o,a;return t.withMutations(l=>{if(n.layers.forEach(c=>{let{lines:h,vertices:f}=c;f.forEach(({id:g,x:p,y:m})=>{e.get(gl)&&xl(l,p,m,10,10,g),e.get(ml)&&({a:s,b:o,c:a}=Zo(m),ta(l,s,o,a,10,1,g),{a:s,b:o,c:a}=Ko(p),ta(l,s,o,a,10,1,g))}),e.get(yl)&&h.forEach(({id:g,vertices:[p,m]})=>{let{x:v,y:_}=f.get(p),{x:S,y:A}=f.get(m);Xs(l,v,_,S,A,20,1,g)})}),e.get(vl)){let c=5,h=100/c,f=r/h,g=i/h;for(let p=0;p<f;p++){let m=p*h;for(let v=0;v<g;v++){let _=v*h,S=!(p%c),A=!(v%c);Mv(l,m,_,10,S&&A?15:10,null)}}}if(e.get(ud)){let c=n.getIn(["guides","horizontal"]),h=n.getIn(["guides","vertical"]),f=c.valueSeq(),g=h.valueSeq();f.forEach(p=>{g.forEach(m=>{xl(l,m,p,10,10)})}),f.forEach(p=>Xs(l,0,p,r,p,20,1)),g.forEach(p=>Xs(l,p,0,p,i,20,1))}})}var ia={exports:{}},Dv=ia.exports,bd;function El(){return bd||(bd=1,(function(n,t){(function(e,r){n.exports=r()})(Dv,function(){var e=Array.prototype.slice;function r(u,d){d&&(u.prototype=Object.create(d.prototype)),u.prototype.constructor=u}function i(u){return l(u)?u:_t(u)}r(s,i);function s(u){return c(u)?u:Ft(u)}r(o,i);function o(u){return h(u)?u:Pt(u)}r(a,i);function a(u){return l(u)&&!f(u)?u:Ot(u)}function l(u){return!!(u&&u[p])}function c(u){return!!(u&&u[m])}function h(u){return!!(u&&u[v])}function f(u){return c(u)||h(u)}function g(u){return!!(u&&u[_])}i.isIterable=l,i.isKeyed=c,i.isIndexed=h,i.isAssociative=f,i.isOrdered=g,i.Keyed=s,i.Indexed=o,i.Set=a;var p="@@__IMMUTABLE_ITERABLE__@@",m="@@__IMMUTABLE_KEYED__@@",v="@@__IMMUTABLE_INDEXED__@@",_="@@__IMMUTABLE_ORDERED__@@",S="delete",A=5,C=1<<A,O=C-1,M={},z={value:!1},R={value:!1};function I(u){return u.value=!1,u}function L(u){u&&(u.value=!0)}function Y(){}function X(u,d){d=d||0;for(var y=Math.max(0,u.length-d),x=new Array(y),b=0;b<y;b++)x[b]=u[b+d];return x}function it(u){return u.size===void 0&&(u.size=u.__iterate(vt)),u.size}function rt(u,d){if(typeof d!="number"){var y=d>>>0;if(""+y!==d||y===4294967295)return NaN;d=y}return d<0?it(u)+d:d}function vt(){return!0}function mt(u,d,y){return(u===0||y!==void 0&&u<=-y)&&(d===void 0||y!==void 0&&d>=y)}function dt(u,d){return W(u,d,0)}function ut(u,d){return W(u,d,d)}function W(u,d,y){return u===void 0?y:u<0?Math.max(0,d+u):d===void 0?u:Math.min(d,u)}var gt=0,k=1,j=2,K=typeof Symbol=="function"&&Symbol.iterator,Z="@@iterator",et=K||Z;function U(u){this.next=u}U.prototype.toString=function(){return"[Iterator]"},U.KEYS=gt,U.VALUES=k,U.ENTRIES=j,U.prototype.inspect=U.prototype.toSource=function(){return this.toString()},U.prototype[et]=function(){return this};function Q(u,d,y,x){var b=u===0?d:u===1?y:[d,y];return x?x.value=b:x={value:b,done:!1},x}function G(){return{value:void 0,done:!0}}function tt(u){return!!ct(u)}function ht(u){return u&&typeof u.next=="function"}function B(u){var d=ct(u);return d&&d.call(u)}function ct(u){var d=u&&(K&&u[K]||u[Z]);if(typeof d=="function")return d}function H(u){return u&&typeof u.length=="number"}r(_t,i);function _t(u){return u==null?hi():l(u)?u.toSeq():eu(u)}_t.of=function(){return _t(arguments)},_t.prototype.toSeq=function(){return this},_t.prototype.toString=function(){return this.__toString("Seq {","}")},_t.prototype.cacheResult=function(){return!this._cache&&this.__iterateUncached&&(this._cache=this.entrySeq().toArray(),this.size=this._cache.length),this},_t.prototype.__iterate=function(u,d){return oe(this,u,d,!0)},_t.prototype.__iterator=function(u,d){return gr(this,u,d,!0)},r(Ft,_t);function Ft(u){return u==null?hi().toKeyedSeq():l(u)?c(u)?u.toSeq():u.fromEntrySeq():fi(u)}Ft.prototype.toKeyedSeq=function(){return this},r(Pt,_t);function Pt(u){return u==null?hi():l(u)?c(u)?u.entrySeq():u.toIndexedSeq():ps(u)}Pt.of=function(){return Pt(arguments)},Pt.prototype.toIndexedSeq=function(){return this},Pt.prototype.toString=function(){return this.__toString("Seq [","]")},Pt.prototype.__iterate=function(u,d){return oe(this,u,d,!1)},Pt.prototype.__iterator=function(u,d){return gr(this,u,d,!1)},r(Ot,_t);function Ot(u){return(u==null?hi():l(u)?c(u)?u.entrySeq():u:ps(u)).toSetSeq()}Ot.of=function(){return Ot(arguments)},Ot.prototype.toSetSeq=function(){return this},_t.isSeq=Qe,_t.Keyed=Ft,_t.Set=Ot,_t.Indexed=Pt;var $t="@@__IMMUTABLE_SEQ__@@";_t.prototype[$t]=!0,r(ft,Pt);function ft(u){this._array=u,this.size=u.length}ft.prototype.get=function(u,d){return this.has(u)?this._array[rt(this,u)]:d},ft.prototype.__iterate=function(u,d){for(var y=this._array,x=y.length-1,b=0;b<=x;b++)if(u(y[d?x-b:b],b,this)===!1)return b+1;return b},ft.prototype.__iterator=function(u,d){var y=this._array,x=y.length-1,b=0;return new U(function(){return b>x?G():Q(u,b,y[d?x-b++:b++])})},r(xt,Ft);function xt(u){var d=Object.keys(u);this._object=u,this._keys=d,this.size=d.length}xt.prototype.get=function(u,d){return d!==void 0&&!this.has(u)?d:this._object[u]},xt.prototype.has=function(u){return this._object.hasOwnProperty(u)},xt.prototype.__iterate=function(u,d){for(var y=this._object,x=this._keys,b=x.length-1,E=0;E<=b;E++){var T=x[d?b-E:E];if(u(y[T],T,this)===!1)return E+1}return E},xt.prototype.__iterator=function(u,d){var y=this._object,x=this._keys,b=x.length-1,E=0;return new U(function(){var T=x[d?b-E:E];return E++>b?G():Q(u,T,y[T])})},xt.prototype[_]=!0,r(Nt,Pt);function Nt(u){this._iterable=u,this.size=u.length||u.size}Nt.prototype.__iterateUncached=function(u,d){if(d)return this.cacheResult().__iterate(u,d);var y=this._iterable,x=B(y),b=0;if(ht(x))for(var E;!(E=x.next()).done&&u(E.value,b++,this)!==!1;);return b},Nt.prototype.__iteratorUncached=function(u,d){if(d)return this.cacheResult().__iterator(u,d);var y=this._iterable,x=B(y);if(!ht(x))return new U(G);var b=0;return new U(function(){var E=x.next();return E.done?E:Q(u,b++,E.value)})},r(wt,Pt);function wt(u){this._iterator=u,this._iteratorCache=[]}wt.prototype.__iterateUncached=function(u,d){if(d)return this.cacheResult().__iterate(u,d);for(var y=this._iterator,x=this._iteratorCache,b=0;b<x.length;)if(u(x[b],b++,this)===!1)return b;for(var E;!(E=y.next()).done;){var T=E.value;if(x[b]=T,u(T,b++,this)===!1)break}return b},wt.prototype.__iteratorUncached=function(u,d){if(d)return this.cacheResult().__iterator(u,d);var y=this._iterator,x=this._iteratorCache,b=0;return new U(function(){if(b>=x.length){var E=y.next();if(E.done)return E;x[b]=E.value}return Q(u,b,x[b++])})};function Qe(u){return!!(u&&u[$t])}var Mn;function hi(){return Mn||(Mn=new ft([]))}function fi(u){var d=Array.isArray(u)?new ft(u).fromEntrySeq():ht(u)?new wt(u).fromEntrySeq():tt(u)?new Nt(u).fromEntrySeq():typeof u=="object"?new xt(u):void 0;if(!d)throw new TypeError("Expected Array or iterable object of [k, v] entries, or keyed object: "+u);return d}function ps(u){var d=xo(u);if(!d)throw new TypeError("Expected Array or iterable object of values: "+u);return d}function eu(u){var d=xo(u)||typeof u=="object"&&new xt(u);if(!d)throw new TypeError("Expected Array or iterable object of values, or keyed object: "+u);return d}function xo(u){return H(u)?new ft(u):ht(u)?new wt(u):tt(u)?new Nt(u):void 0}function oe(u,d,y,x){var b=u._cache;if(b){for(var E=b.length-1,T=0;T<=E;T++){var P=b[y?E-T:T];if(d(P[1],x?P[0]:T,u)===!1)return T+1}return T}return u.__iterateUncached(d,y)}function gr(u,d,y,x){var b=u._cache;if(b){var E=b.length-1,T=0;return new U(function(){var P=b[y?E-T:T];return T++>E?G():Q(d,x?P[0]:T-1,P[1])})}return u.__iteratorUncached(d,y)}function nn(u,d){return d?jr(d,u,"",{"":u}):_o(u)}function jr(u,d,y,x){return Array.isArray(d)?u.call(x,y,Pt(d).map(function(b,E){return jr(u,b,E,d)})):di(d)?u.call(x,y,Ft(d).map(function(b,E){return jr(u,b,E,d)})):d}function _o(u){return Array.isArray(u)?Pt(u).map(_o).toList():di(u)?Ft(u).map(_o).toMap():u}function di(u){return u&&(u.constructor===Object||u.constructor===void 0)}function ee(u,d){if(u===d||u!==u&&d!==d)return!0;if(!u||!d)return!1;if(typeof u.valueOf=="function"&&typeof d.valueOf=="function"){if(u=u.valueOf(),d=d.valueOf(),u===d||u!==u&&d!==d)return!0;if(!u||!d)return!1}return!!(typeof u.equals=="function"&&typeof d.equals=="function"&&u.equals(d))}function pi(u,d){if(u===d)return!0;if(!l(d)||u.size!==void 0&&d.size!==void 0&&u.size!==d.size||u.__hash!==void 0&&d.__hash!==void 0&&u.__hash!==d.__hash||c(u)!==c(d)||h(u)!==h(d)||g(u)!==g(d))return!1;if(u.size===0&&d.size===0)return!0;var y=!f(u);if(g(u)){var x=u.entries();return d.every(function(F,V){var q=x.next().value;return q&&ee(q[1],F)&&(y||ee(q[0],V))})&&x.next().done}var b=!1;if(u.size===void 0)if(d.size===void 0)typeof u.cacheResult=="function"&&u.cacheResult();else{b=!0;var E=u;u=d,d=E}var T=!0,P=d.__iterate(function(F,V){if(y?!u.has(F):b?!ee(F,u.get(V,M)):!ee(u.get(V,M),F))return T=!1,!1});return T&&u.size===P}r(be,Pt);function be(u,d){if(!(this instanceof be))return new be(u,d);if(this._value=u,this.size=d===void 0?1/0:Math.max(0,d),this.size===0){if(hh)return hh;hh=this}}be.prototype.toString=function(){return this.size===0?"Repeat []":"Repeat [ "+this._value+" "+this.size+" times ]"},be.prototype.get=function(u,d){return this.has(u)?this._value:d},be.prototype.includes=function(u){return ee(this._value,u)},be.prototype.slice=function(u,d){var y=this.size;return mt(u,d,y)?this:new be(this._value,ut(d,y)-dt(u,y))},be.prototype.reverse=function(){return this},be.prototype.indexOf=function(u){return ee(this._value,u)?0:-1},be.prototype.lastIndexOf=function(u){return ee(this._value,u)?this.size:-1},be.prototype.__iterate=function(u,d){for(var y=0;y<this.size;y++)if(u(this._value,y,this)===!1)return y+1;return y},be.prototype.__iterator=function(u,d){var y=this,x=0;return new U(function(){return x<y.size?Q(u,x++,y._value):G()})},be.prototype.equals=function(u){return u instanceof be?ee(this._value,u._value):pi(u)};var hh;function ru(u,d){if(!u)throw new Error(d)}r(Se,Pt);function Se(u,d,y){if(!(this instanceof Se))return new Se(u,d,y);if(ru(y!==0,"Cannot step a Range by 0"),u=u||0,d===void 0&&(d=1/0),y=y===void 0?1:Math.abs(y),d<u&&(y=-y),this._start=u,this._end=d,this._step=y,this.size=Math.max(0,Math.ceil((d-u)/y-1)+1),this.size===0){if(fh)return fh;fh=this}}Se.prototype.toString=function(){return this.size===0?"Range []":"Range [ "+this._start+"..."+this._end+(this._step!==1?" by "+this._step:"")+" ]"},Se.prototype.get=function(u,d){return this.has(u)?this._start+rt(this,u)*this._step:d},Se.prototype.includes=function(u){var d=(u-this._start)/this._step;return d>=0&&d<this.size&&d===Math.floor(d)},Se.prototype.slice=function(u,d){return mt(u,d,this.size)?this:(u=dt(u,this.size),d=ut(d,this.size),d<=u?new Se(0,0):new Se(this.get(u,this._end),this.get(d,this._end),this._step))},Se.prototype.indexOf=function(u){var d=u-this._start;if(d%this._step===0){var y=d/this._step;if(y>=0&&y<this.size)return y}return-1},Se.prototype.lastIndexOf=function(u){return this.indexOf(u)},Se.prototype.__iterate=function(u,d){for(var y=this.size-1,x=this._step,b=d?this._start+y*x:this._start,E=0;E<=y;E++){if(u(b,E,this)===!1)return E+1;b+=d?-x:x}return E},Se.prototype.__iterator=function(u,d){var y=this.size-1,x=this._step,b=d?this._start+y*x:this._start,E=0;return new U(function(){var T=b;return b+=d?-x:x,E>y?G():Q(u,E++,T)})},Se.prototype.equals=function(u){return u instanceof Se?this._start===u._start&&this._end===u._end&&this._step===u._step:pi(this,u)};var fh;r(qn,i);function qn(){throw TypeError("Abstract")}r(bo,qn);function bo(){}r(gs,qn);function gs(){}r(nu,qn);function nu(){}qn.Keyed=bo,qn.Indexed=gs,qn.Set=nu;var wo=typeof Math.imul=="function"&&Math.imul(4294967295,2)===-2?Math.imul:function(d,y){d=d|0,y=y|0;var x=d&65535,b=y&65535;return x*b+((d>>>16)*b+x*(y>>>16)<<16>>>0)|0};function dh(u){return u>>>1&1073741824|u&3221225471}function tr(u){if(u===!1||u===null||u===void 0||typeof u.valueOf=="function"&&(u=u.valueOf(),u===!1||u===null||u===void 0))return 0;if(u===!0)return 1;var d=typeof u;if(d==="number"){if(u!==u||u===1/0)return 0;var y=u|0;for(y!==u&&(y^=u*4294967295);u>4294967295;)u/=4294967295,y^=u;return dh(y)}if(d==="string")return u.length>oM?nM(u):ph(u);if(typeof u.hashCode=="function")return u.hashCode();if(d==="object")return iM(u);if(typeof u.toString=="function")return ph(u.toString());throw new Error("Value type "+d+" cannot be hashed.")}function nM(u){var d=xh[u];return d===void 0&&(d=ph(u),vh===aM&&(vh=0,xh={}),vh++,xh[u]=d),d}function ph(u){for(var d=0,y=0;y<u.length;y++)d=31*d+u.charCodeAt(y)|0;return dh(d)}function iM(u){var d;if(gh&&(d=mh.get(u),d!==void 0)||(d=u[gi],d!==void 0)||!ly&&(d=u.propertyIsEnumerable&&u.propertyIsEnumerable[gi],d!==void 0||(d=sM(u),d!==void 0)))return d;if(d=++yh,yh&1073741824&&(yh=0),gh)mh.set(u,d);else{if(uy!==void 0&&uy(u)===!1)throw new Error("Non-extensible objects are not allowed as keys.");if(ly)Object.defineProperty(u,gi,{enumerable:!1,configurable:!1,writable:!1,value:d});else if(u.propertyIsEnumerable!==void 0&&u.propertyIsEnumerable===u.constructor.prototype.propertyIsEnumerable)u.propertyIsEnumerable=function(){return this.constructor.prototype.propertyIsEnumerable.apply(this,arguments)},u.propertyIsEnumerable[gi]=d;else if(u.nodeType!==void 0)u[gi]=d;else throw new Error("Unable to set a non-enumerable property on object.")}return d}var uy=Object.isExtensible,ly=(function(){try{return Object.defineProperty({},"@",{}),!0}catch{return!1}})();function sM(u){if(u&&u.nodeType>0)switch(u.nodeType){case 1:return u.uniqueID;case 9:return u.documentElement&&u.documentElement.uniqueID}}var gh=typeof WeakMap=="function",mh;gh&&(mh=new WeakMap);var yh=0,gi="__immutablehash__";typeof Symbol=="function"&&(gi=Symbol(gi));var oM=16,aM=255,vh=0,xh={};function er(u){ru(u!==1/0,"Cannot perform this action with an infinite size.")}r(kt,bo);function kt(u){return u==null?Vr():_h(u)&&!g(u)?u:Vr().withMutations(function(d){var y=s(u);er(y.size),y.forEach(function(x,b){return d.set(b,x)})})}kt.of=function(){var u=e.call(arguments,0);return Vr().withMutations(function(d){for(var y=0;y<u.length;y+=2){if(y+1>=u.length)throw new Error("Missing value for key: "+u[y]);d.set(u[y],u[y+1])}})},kt.prototype.toString=function(){return this.__toString("Map {","}")},kt.prototype.get=function(u,d){return this._root?this._root.get(0,void 0,u,d):d},kt.prototype.set=function(u,d){return dy(this,u,d)},kt.prototype.setIn=function(u,d){return this.updateIn(u,M,function(){return d})},kt.prototype.remove=function(u){return dy(this,u,M)},kt.prototype.deleteIn=function(u){return this.updateIn(u,function(){return M})},kt.prototype.update=function(u,d,y){return arguments.length===1?u(this):this.updateIn([u],d,y)},kt.prototype.updateIn=function(u,d,y){y||(y=d,d=void 0);var x=vy(this,Vy(u),d,y);return x===M?void 0:x},kt.prototype.clear=function(){return this.size===0?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):Vr()},kt.prototype.merge=function(){return iu(this,void 0,arguments)},kt.prototype.mergeWith=function(u){var d=e.call(arguments,1);return iu(this,u,d)},kt.prototype.mergeIn=function(u){var d=e.call(arguments,1);return this.updateIn(u,Vr(),function(y){return typeof y.merge=="function"?y.merge.apply(y,d):d[d.length-1]})},kt.prototype.mergeDeep=function(){return iu(this,gy,arguments)},kt.prototype.mergeDeepWith=function(u){var d=e.call(arguments,1);return iu(this,my(u),d)},kt.prototype.mergeDeepIn=function(u){var d=e.call(arguments,1);return this.updateIn(u,Vr(),function(y){return typeof y.mergeDeep=="function"?y.mergeDeep.apply(y,d):d[d.length-1]})},kt.prototype.sort=function(u){return ae(ws(this,u))},kt.prototype.sortBy=function(u,d){return ae(ws(this,d,u))},kt.prototype.withMutations=function(u){var d=this.asMutable();return u(d),d.wasAltered()?d.__ensureOwner(this.__ownerID):this},kt.prototype.asMutable=function(){return this.__ownerID?this:this.__ensureOwner(new Y)},kt.prototype.asImmutable=function(){return this.__ensureOwner()},kt.prototype.wasAltered=function(){return this.__altered},kt.prototype.__iterator=function(u,d){return new bh(this,u,d)},kt.prototype.__iterate=function(u,d){var y=this,x=0;return this._root&&this._root.iterate(function(b){return x++,u(b[1],b[0],y)},d),x},kt.prototype.__ensureOwner=function(u){return u===this.__ownerID?this:u?Sh(this.size,this._root,u,this.__hash):(this.__ownerID=u,this.__altered=!1,this)};function _h(u){return!!(u&&u[cy])}kt.isMap=_h;var cy="@@__IMMUTABLE_MAP__@@",zt=kt.prototype;zt[cy]=!0,zt[S]=zt.remove,zt.removeIn=zt.deleteIn;function So(u,d){this.ownerID=u,this.entries=d}So.prototype.get=function(u,d,y,x){for(var b=this.entries,E=0,T=b.length;E<T;E++)if(ee(y,b[E][0]))return b[E][1];return x},So.prototype.update=function(u,d,y,x,b,E,T){for(var P=b===M,F=this.entries,V=0,q=F.length;V<q&&!ee(x,F[V][0]);V++);var nt=V<q;if(nt?F[V][1]===b:P)return this;if(L(T),(P||!nt)&&L(E),!(P&&F.length===1)){if(!nt&&!P&&F.length>=dM)return uM(u,F,x,b);var lt=u&&u===this.ownerID,bt=lt?F:X(F);return nt?P?V===q-1?bt.pop():bt[V]=bt.pop():bt[V]=[x,b]:bt.push([x,b]),lt?(this.entries=bt,this):new So(u,bt)}};function ms(u,d,y){this.ownerID=u,this.bitmap=d,this.nodes=y}ms.prototype.get=function(u,d,y,x){d===void 0&&(d=tr(y));var b=1<<((u===0?d:d>>>u)&O),E=this.bitmap;return(E&b)===0?x:this.nodes[xy(E&b-1)].get(u+A,d,y,x)},ms.prototype.update=function(u,d,y,x,b,E,T){y===void 0&&(y=tr(x));var P=(d===0?y:y>>>d)&O,F=1<<P,V=this.bitmap,q=(V&F)!==0;if(!q&&b===M)return this;var nt=xy(V&F-1),lt=this.nodes,bt=q?lt[nt]:void 0,Mt=Mh(bt,u,d+A,y,x,b,E,T);if(Mt===bt)return this;if(!q&&Mt&<.length>=pM)return cM(u,lt,V,P,Mt);if(q&&!Mt&<.length===2&&py(lt[nt^1]))return lt[nt^1];if(q&&Mt&<.length===1&&py(Mt))return Mt;var Qt=u&&u===this.ownerID,Dr=q?Mt?V:V^F:V|F,un=q?Mt?_y(lt,nt,Mt,Qt):fM(lt,nt,Qt):hM(lt,nt,Mt,Qt);return Qt?(this.bitmap=Dr,this.nodes=un,this):new ms(u,Dr,un)};function Mo(u,d,y){this.ownerID=u,this.count=d,this.nodes=y}Mo.prototype.get=function(u,d,y,x){d===void 0&&(d=tr(y));var b=(u===0?d:d>>>u)&O,E=this.nodes[b];return E?E.get(u+A,d,y,x):x},Mo.prototype.update=function(u,d,y,x,b,E,T){y===void 0&&(y=tr(x));var P=(d===0?y:y>>>d)&O,F=b===M,V=this.nodes,q=V[P];if(F&&!q)return this;var nt=Mh(q,u,d+A,y,x,b,E,T);if(nt===q)return this;var lt=this.count;if(!q)lt++;else if(!nt&&(lt--,lt<gM))return lM(u,V,lt,P);var bt=u&&u===this.ownerID,Mt=_y(V,P,nt,bt);return bt?(this.count=lt,this.nodes=Mt,this):new Mo(u,lt,Mt)};function ys(u,d,y){this.ownerID=u,this.keyHash=d,this.entries=y}ys.prototype.get=function(u,d,y,x){for(var b=this.entries,E=0,T=b.length;E<T;E++)if(ee(y,b[E][0]))return b[E][1];return x},ys.prototype.update=function(u,d,y,x,b,E,T){y===void 0&&(y=tr(x));var P=b===M;if(y!==this.keyHash)return P?this:(L(T),L(E),Eh(this,u,d,y,[x,b]));for(var F=this.entries,V=0,q=F.length;V<q&&!ee(x,F[V][0]);V++);var nt=V<q;if(nt?F[V][1]===b:P)return this;if(L(T),(P||!nt)&&L(E),P&&q===2)return new En(u,this.keyHash,F[V^1]);var lt=u&&u===this.ownerID,bt=lt?F:X(F);return nt?P?V===q-1?bt.pop():bt[V]=bt.pop():bt[V]=[x,b]:bt.push([x,b]),lt?(this.entries=bt,this):new ys(u,this.keyHash,bt)};function En(u,d,y){this.ownerID=u,this.keyHash=d,this.entry=y}En.prototype.get=function(u,d,y,x){return ee(y,this.entry[0])?this.entry[1]:x},En.prototype.update=function(u,d,y,x,b,E,T){var P=b===M,F=ee(x,this.entry[0]);if(F?b===this.entry[1]:P)return this;if(L(T),P){L(E);return}return F?u&&u===this.ownerID?(this.entry[1]=b,this):new En(u,this.keyHash,[x,b]):(L(E),Eh(this,u,d,tr(x),[x,b]))},So.prototype.iterate=ys.prototype.iterate=function(u,d){for(var y=this.entries,x=0,b=y.length-1;x<=b;x++)if(u(y[d?b-x:x])===!1)return!1},ms.prototype.iterate=Mo.prototype.iterate=function(u,d){for(var y=this.nodes,x=0,b=y.length-1;x<=b;x++){var E=y[d?b-x:x];if(E&&E.iterate(u,d)===!1)return!1}},En.prototype.iterate=function(u,d){return u(this.entry)},r(bh,U);function bh(u,d,y){this._type=d,this._reverse=y,this._stack=u._root&&hy(u._root)}bh.prototype.next=function(){for(var u=this._type,d=this._stack;d;){var y=d.node,x=d.index++,b;if(y.entry){if(x===0)return wh(u,y.entry)}else if(y.entries){if(b=y.entries.length-1,x<=b)return wh(u,y.entries[this._reverse?b-x:x])}else if(b=y.nodes.length-1,x<=b){var E=y.nodes[this._reverse?b-x:x];if(E){if(E.entry)return wh(u,E.entry);d=this._stack=hy(E,d)}continue}d=this._stack=this._stack.__prev}return G()};function wh(u,d){return Q(u,d[0],d[1])}function hy(u,d){return{node:u,index:0,__prev:d}}function Sh(u,d,y,x){var b=Object.create(zt);return b.size=u,b._root=d,b.__ownerID=y,b.__hash=x,b.__altered=!1,b}var fy;function Vr(){return fy||(fy=Sh(0))}function dy(u,d,y){var x,b;if(u._root){var E=I(z),T=I(R);if(x=Mh(u._root,u.__ownerID,0,void 0,d,y,E,T),!T.value)return u;b=u.size+(E.value?y===M?-1:1:0)}else{if(y===M)return u;b=1,x=new So(u.__ownerID,[[d,y]])}return u.__ownerID?(u.size=b,u._root=x,u.__hash=void 0,u.__altered=!0,u):x?Sh(b,x):Vr()}function Mh(u,d,y,x,b,E,T,P){return u?u.update(d,y,x,b,E,T,P):E===M?u:(L(P),L(T),new En(d,x,[b,E]))}function py(u){return u.constructor===En||u.constructor===ys}function Eh(u,d,y,x,b){if(u.keyHash===x)return new ys(d,x,[u.entry,b]);var E=(y===0?u.keyHash:u.keyHash>>>y)&O,T=(y===0?x:x>>>y)&O,P,F=E===T?[Eh(u,d,y+A,x,b)]:(P=new En(d,x,b),E<T?[u,P]:[P,u]);return new ms(d,1<<E|1<<T,F)}function uM(u,d,y,x){u||(u=new Y);for(var b=new En(u,tr(y),[y,x]),E=0;E<d.length;E++){var T=d[E];b=b.update(u,0,void 0,T[0],T[1])}return b}function lM(u,d,y,x){for(var b=0,E=0,T=new Array(y),P=0,F=1,V=d.length;P<V;P++,F<<=1){var q=d[P];q!==void 0&&P!==x&&(b|=F,T[E++]=q)}return new ms(u,b,T)}function cM(u,d,y,x,b){for(var E=0,T=new Array(C),P=0;y!==0;P++,y>>>=1)T[P]=y&1?d[E++]:void 0;return T[x]=b,new Mo(u,E+1,T)}function iu(u,d,y){for(var x=[],b=0;b<y.length;b++){var E=y[b],T=s(E);l(E)||(T=T.map(function(P){return nn(P)})),x.push(T)}return yy(u,d,x)}function gy(u,d,y){return u&&u.mergeDeep&&l(d)?u.mergeDeep(d):ee(u,d)?u:d}function my(u){return function(d,y,x){if(d&&d.mergeDeepWith&&l(y))return d.mergeDeepWith(u,y);var b=u(d,y,x);return ee(d,b)?d:b}}function yy(u,d,y){return y=y.filter(function(x){return x.size!==0}),y.length===0?u:u.size===0&&!u.__ownerID&&y.length===1?u.constructor(y[0]):u.withMutations(function(x){for(var b=d?function(T,P){x.update(P,M,function(F){return F===M?T:d(F,T,P)})}:function(T,P){x.set(P,T)},E=0;E<y.length;E++)y[E].forEach(b)})}function vy(u,d,y,x){var b=u===M,E=d.next();if(E.done){var T=b?y:u,P=x(T);return P===T?u:P}ru(b||u&&u.set,"invalid keyPath");var F=E.value,V=b?M:u.get(F,M),q=vy(V,d,y,x);return q===V?u:q===M?u.remove(F):(b?Vr():u).set(F,q)}function xy(u){return u=u-(u>>1&1431655765),u=(u&858993459)+(u>>2&858993459),u=u+(u>>4)&252645135,u=u+(u>>8),u=u+(u>>16),u&127}function _y(u,d,y,x){var b=x?u:X(u);return b[d]=y,b}function hM(u,d,y,x){var b=u.length+1;if(x&&d+1===b)return u[d]=y,u;for(var E=new Array(b),T=0,P=0;P<b;P++)P===d?(E[P]=y,T=-1):E[P]=u[P+T];return E}function fM(u,d,y){var x=u.length-1;if(y&&d===x)return u.pop(),u;for(var b=new Array(x),E=0,T=0;T<x;T++)T===d&&(E=1),b[T]=u[T+E];return b}var dM=C/4,pM=C/2,gM=C/4;r(Zt,gs);function Zt(u){var d=Ah();if(u==null)return d;if(by(u))return u;var y=o(u),x=y.size;return x===0?d:(er(x),x>0&&x<C?Ao(0,x,A,null,new $n(y.toArray())):d.withMutations(function(b){b.setSize(x),y.forEach(function(E,T){return b.set(T,E)})}))}Zt.of=function(){return this(arguments)},Zt.prototype.toString=function(){return this.__toString("List [","]")},Zt.prototype.get=function(u,d){if(u=rt(this,u),u>=0&&u<this.size){u+=this._origin;var y=Ey(this,u);return y&&y.array[u&O]}return d},Zt.prototype.set=function(u,d){return mM(this,u,d)},Zt.prototype.remove=function(u){return this.has(u)?u===0?this.shift():u===this.size-1?this.pop():this.splice(u,1):this},Zt.prototype.insert=function(u,d){return this.splice(u,0,d)},Zt.prototype.clear=function(){return this.size===0?this:this.__ownerID?(this.size=this._origin=this._capacity=0,this._level=A,this._root=this._tail=null,this.__hash=void 0,this.__altered=!0,this):Ah()},Zt.prototype.push=function(){var u=arguments,d=this.size;return this.withMutations(function(y){Hn(y,0,d+u.length);for(var x=0;x<u.length;x++)y.set(d+x,u[x])})},Zt.prototype.pop=function(){return Hn(this,0,-1)},Zt.prototype.unshift=function(){var u=arguments;return this.withMutations(function(d){Hn(d,-u.length);for(var y=0;y<u.length;y++)d.set(y,u[y])})},Zt.prototype.shift=function(){return Hn(this,1)},Zt.prototype.merge=function(){return su(this,void 0,arguments)},Zt.prototype.mergeWith=function(u){var d=e.call(arguments,1);return su(this,u,d)},Zt.prototype.mergeDeep=function(){return su(this,gy,arguments)},Zt.prototype.mergeDeepWith=function(u){var d=e.call(arguments,1);return su(this,my(u),d)},Zt.prototype.setSize=function(u){return Hn(this,0,u)},Zt.prototype.slice=function(u,d){var y=this.size;return mt(u,d,y)?this:Hn(this,dt(u,y),ut(d,y))},Zt.prototype.__iterator=function(u,d){var y=0,x=Sy(this,d);return new U(function(){var b=x();return b===Eo?G():Q(u,y++,b)})},Zt.prototype.__iterate=function(u,d){for(var y=0,x=Sy(this,d),b;(b=x())!==Eo&&u(b,y++,this)!==!1;);return y},Zt.prototype.__ensureOwner=function(u){return u===this.__ownerID?this:u?Ao(this._origin,this._capacity,this._level,this._root,this._tail,u,this.__hash):(this.__ownerID=u,this)};function by(u){return!!(u&&u[wy])}Zt.isList=by;var wy="@@__IMMUTABLE_LIST__@@",Le=Zt.prototype;Le[wy]=!0,Le[S]=Le.remove,Le.setIn=zt.setIn,Le.deleteIn=Le.removeIn=zt.removeIn,Le.update=zt.update,Le.updateIn=zt.updateIn,Le.mergeIn=zt.mergeIn,Le.mergeDeepIn=zt.mergeDeepIn,Le.withMutations=zt.withMutations,Le.asMutable=zt.asMutable,Le.asImmutable=zt.asImmutable,Le.wasAltered=zt.wasAltered;function $n(u,d){this.array=u,this.ownerID=d}$n.prototype.removeBefore=function(u,d,y){if(y===d?1<<d:this.array.length===0)return this;var x=y>>>d&O;if(x>=this.array.length)return new $n([],u);var b=x===0,E;if(d>0){var T=this.array[x];if(E=T&&T.removeBefore(u,d-A,y),E===T&&b)return this}if(b&&!E)return this;var P=vs(this,u);if(!b)for(var F=0;F<x;F++)P.array[F]=void 0;return E&&(P.array[x]=E),P},$n.prototype.removeAfter=function(u,d,y){if(y===(d?1<<d:0)||this.array.length===0)return this;var x=y-1>>>d&O;if(x>=this.array.length)return this;var b;if(d>0){var E=this.array[x];if(b=E&&E.removeAfter(u,d-A,y),b===E&&x===this.array.length-1)return this}var T=vs(this,u);return T.array.splice(x+1),b&&(T.array[x]=b),T};var Eo={};function Sy(u,d){var y=u._origin,x=u._capacity,b=Oo(x),E=u._tail;return T(u._root,u._level,0);function T(V,q,nt){return q===0?P(V,nt):F(V,q,nt)}function P(V,q){var nt=q===b?E&&E.array:V&&V.array,lt=q>y?0:y-q,bt=x-q;return bt>C&&(bt=C),function(){if(lt===bt)return Eo;var Mt=d?--bt:lt++;return nt&&nt[Mt]}}function F(V,q,nt){var lt,bt=V&&V.array,Mt=nt>y?0:y-nt>>q,Qt=(x-nt>>q)+1;return Qt>C&&(Qt=C),function(){do{if(lt){var Dr=lt();if(Dr!==Eo)return Dr;lt=null}if(Mt===Qt)return Eo;var un=d?--Qt:Mt++;lt=T(bt&&bt[un],q-A,nt+(un<<q))}while(!0)}}}function Ao(u,d,y,x,b,E,T){var P=Object.create(Le);return P.size=d-u,P._origin=u,P._capacity=d,P._level=y,P._root=x,P._tail=b,P.__ownerID=E,P.__hash=T,P.__altered=!1,P}var My;function Ah(){return My||(My=Ao(0,0,A))}function mM(u,d,y){if(d=rt(u,d),d!==d)return u;if(d>=u.size||d<0)return u.withMutations(function(T){d<0?Hn(T,d).set(0,y):Hn(T,0,d+1).set(d,y)});d+=u._origin;var x=u._tail,b=u._root,E=I(R);return d>=Oo(u._capacity)?x=Oh(x,u.__ownerID,0,d,y,E):b=Oh(b,u.__ownerID,u._level,d,y,E),E.value?u.__ownerID?(u._root=b,u._tail=x,u.__hash=void 0,u.__altered=!0,u):Ao(u._origin,u._capacity,u._level,b,x):u}function Oh(u,d,y,x,b,E){var T=x>>>y&O,P=u&&T<u.array.length;if(!P&&b===void 0)return u;var F;if(y>0){var V=u&&u.array[T],q=Oh(V,d,y-A,x,b,E);return q===V?u:(F=vs(u,d),F.array[T]=q,F)}return P&&u.array[T]===b?u:(L(E),F=vs(u,d),b===void 0&&T===F.array.length-1?F.array.pop():F.array[T]=b,F)}function vs(u,d){return d&&u&&d===u.ownerID?u:new $n(u?u.array.slice():[],d)}function Ey(u,d){if(d>=Oo(u._capacity))return u._tail;if(d<1<<u._level+A){for(var y=u._root,x=u._level;y&&x>0;)y=y.array[d>>>x&O],x-=A;return y}}function Hn(u,d,y){d!==void 0&&(d=d|0),y!==void 0&&(y=y|0);var x=u.__ownerID||new Y,b=u._origin,E=u._capacity,T=b+d,P=y===void 0?E:y<0?E+y:b+y;if(T===b&&P===E)return u;if(T>=P)return u.clear();for(var F=u._level,V=u._root,q=0;T+q<0;)V=new $n(V&&V.array.length?[void 0,V]:[],x),F+=A,q+=1<<F;q&&(T+=q,b+=q,P+=q,E+=q);for(var nt=Oo(E),lt=Oo(P);lt>=1<<F+A;)V=new $n(V&&V.array.length?[V]:[],x),F+=A;var bt=u._tail,Mt=lt<nt?Ey(u,P-1):lt>nt?new $n([],x):bt;if(bt&<>nt&&T<E&&bt.array.length){V=vs(V,x);for(var Qt=V,Dr=F;Dr>A;Dr-=A){var un=nt>>>Dr&O;Qt=Qt.array[un]=vs(Qt.array[un],x)}Qt.array[nt>>>A&O]=bt}if(P<E&&(Mt=Mt&&Mt.removeAfter(x,0,P)),T>=lt)T-=lt,P-=lt,F=A,V=null,Mt=Mt&&Mt.removeBefore(x,0,T);else if(T>b||lt<nt){for(q=0;V;){var fu=T>>>F&O;if(fu!==lt>>>F&O)break;fu&&(q+=(1<<F)*fu),F-=A,V=V.array[fu]}V&&T>b&&(V=V.removeBefore(x,F,T-q)),V&<<nt&&(V=V.removeAfter(x,F,lt-q)),q&&(T-=q,P-=q)}return u.__ownerID?(u.size=P-T,u._origin=T,u._capacity=P,u._level=F,u._root=V,u._tail=Mt,u.__hash=void 0,u.__altered=!0,u):Ao(T,P,F,V,Mt)}function su(u,d,y){for(var x=[],b=0,E=0;E<y.length;E++){var T=y[E],P=o(T);P.size>b&&(b=P.size),l(T)||(P=P.map(function(F){return nn(F)})),x.push(P)}return b>u.size&&(u=u.setSize(b)),yy(u,d,x)}function Oo(u){return u<C?0:u-1>>>A<<A}r(ae,kt);function ae(u){return u==null?ou():Ay(u)?u:ou().withMutations(function(d){var y=s(u);er(y.size),y.forEach(function(x,b){return d.set(b,x)})})}ae.of=function(){return this(arguments)},ae.prototype.toString=function(){return this.__toString("OrderedMap {","}")},ae.prototype.get=function(u,d){var y=this._map.get(u);return y!==void 0?this._list.get(y)[1]:d},ae.prototype.clear=function(){return this.size===0?this:this.__ownerID?(this.size=0,this._map.clear(),this._list.clear(),this):ou()},ae.prototype.set=function(u,d){return zy(this,u,d)},ae.prototype.remove=function(u){return zy(this,u,M)},ae.prototype.wasAltered=function(){return this._map.wasAltered()||this._list.wasAltered()},ae.prototype.__iterate=function(u,d){var y=this;return this._list.__iterate(function(x){return x&&u(x[1],x[0],y)},d)},ae.prototype.__iterator=function(u,d){return this._list.fromEntrySeq().__iterator(u,d)},ae.prototype.__ensureOwner=function(u){if(u===this.__ownerID)return this;var d=this._map.__ensureOwner(u),y=this._list.__ensureOwner(u);return u?zh(d,y,u,this.__hash):(this.__ownerID=u,this._map=d,this._list=y,this)};function Ay(u){return _h(u)&&g(u)}ae.isOrderedMap=Ay,ae.prototype[_]=!0,ae.prototype[S]=ae.prototype.remove;function zh(u,d,y,x){var b=Object.create(ae.prototype);return b.size=u?u.size:0,b._map=u,b._list=d,b.__ownerID=y,b.__hash=x,b}var Oy;function ou(){return Oy||(Oy=zh(Vr(),Ah()))}function zy(u,d,y){var x=u._map,b=u._list,E=x.get(d),T=E!==void 0,P,F;if(y===M){if(!T)return u;b.size>=C&&b.size>=x.size*2?(F=b.filter(function(V,q){return V!==void 0&&E!==q}),P=F.toKeyedSeq().map(function(V){return V[0]}).flip().toMap(),u.__ownerID&&(P.__ownerID=F.__ownerID=u.__ownerID)):(P=x.remove(d),F=E===b.size-1?b.pop():b.set(E,void 0))}else if(T){if(y===b.get(E)[1])return u;P=x,F=b.set(E,[d,y])}else P=x.set(d,b.size),F=b.set(b.size,[d,y]);return u.__ownerID?(u.size=P.size,u._map=P,u._list=F,u.__hash=void 0,u):zh(P,F)}r(mr,Ft);function mr(u,d){this._iter=u,this._useKeys=d,this.size=u.size}mr.prototype.get=function(u,d){return this._iter.get(u,d)},mr.prototype.has=function(u){return this._iter.has(u)},mr.prototype.valueSeq=function(){return this._iter.valueSeq()},mr.prototype.reverse=function(){var u=this,d=Th(this,!0);return this._useKeys||(d.valueSeq=function(){return u._iter.toSeq().reverse()}),d},mr.prototype.map=function(u,d){var y=this,x=Cy(this,u,d);return this._useKeys||(x.valueSeq=function(){return y._iter.toSeq().map(u,d)}),x},mr.prototype.__iterate=function(u,d){var y=this,x;return this._iter.__iterate(this._useKeys?function(b,E){return u(b,E,y)}:(x=d?Ny(this):0,function(b){return u(b,d?--x:x++,y)}),d)},mr.prototype.__iterator=function(u,d){if(this._useKeys)return this._iter.__iterator(u,d);var y=this._iter.__iterator(k,d),x=d?Ny(this):0;return new U(function(){var b=y.next();return b.done?b:Q(u,d?--x:x++,b.value,b)})},mr.prototype[_]=!0,r(xs,Pt);function xs(u){this._iter=u,this.size=u.size}xs.prototype.includes=function(u){return this._iter.includes(u)},xs.prototype.__iterate=function(u,d){var y=this,x=0;return this._iter.__iterate(function(b){return u(b,x++,y)},d)},xs.prototype.__iterator=function(u,d){var y=this._iter.__iterator(k,d),x=0;return new U(function(){var b=y.next();return b.done?b:Q(u,x++,b.value,b)})},r(_s,Ot);function _s(u){this._iter=u,this.size=u.size}_s.prototype.has=function(u){return this._iter.includes(u)},_s.prototype.__iterate=function(u,d){var y=this;return this._iter.__iterate(function(x){return u(x,x,y)},d)},_s.prototype.__iterator=function(u,d){var y=this._iter.__iterator(k,d);return new U(function(){var x=y.next();return x.done?x:Q(u,x.value,x.value,x)})},r(bs,Ft);function bs(u){this._iter=u,this.size=u.size}bs.prototype.entrySeq=function(){return this._iter.toSeq()},bs.prototype.__iterate=function(u,d){var y=this;return this._iter.__iterate(function(x){if(x){Ly(x);var b=l(x);return u(b?x.get(1):x[1],b?x.get(0):x[0],y)}},d)},bs.prototype.__iterator=function(u,d){var y=this._iter.__iterator(k,d);return new U(function(){for(;;){var x=y.next();if(x.done)return x;var b=x.value;if(b){Ly(b);var E=l(b);return Q(u,E?b.get(0):b[0],E?b.get(1):b[1],x)}}})},xs.prototype.cacheResult=mr.prototype.cacheResult=_s.prototype.cacheResult=bs.prototype.cacheResult=Ih;function Ty(u){var d=sn(u);return d._iter=u,d.size=u.size,d.flip=function(){return u},d.reverse=function(){var y=u.reverse.apply(this);return y.flip=function(){return u.reverse()},y},d.has=function(y){return u.includes(y)},d.includes=function(y){return u.has(y)},d.cacheResult=Ih,d.__iterateUncached=function(y,x){var b=this;return u.__iterate(function(E,T){return y(T,E,b)!==!1},x)},d.__iteratorUncached=function(y,x){if(y===j){var b=u.__iterator(y,x);return new U(function(){var E=b.next();if(!E.done){var T=E.value[0];E.value[0]=E.value[1],E.value[1]=T}return E})}return u.__iterator(y===k?gt:k,x)},d}function Cy(u,d,y){var x=sn(u);return x.size=u.size,x.has=function(b){return u.has(b)},x.get=function(b,E){var T=u.get(b,M);return T===M?E:d.call(y,T,b,u)},x.__iterateUncached=function(b,E){var T=this;return u.__iterate(function(P,F,V){return b(d.call(y,P,F,V),F,T)!==!1},E)},x.__iteratorUncached=function(b,E){var T=u.__iterator(j,E);return new U(function(){var P=T.next();if(P.done)return P;var F=P.value,V=F[0];return Q(b,V,d.call(y,F[1],V,u),P)})},x}function Th(u,d){var y=sn(u);return y._iter=u,y.size=u.size,y.reverse=function(){return u},u.flip&&(y.flip=function(){var x=Ty(u);return x.reverse=function(){return u.flip()},x}),y.get=function(x,b){return u.get(d?x:-1-x,b)},y.has=function(x){return u.has(d?x:-1-x)},y.includes=function(x){return u.includes(x)},y.cacheResult=Ih,y.__iterate=function(x,b){var E=this;return u.__iterate(function(T,P){return x(T,P,E)},!b)},y.__iterator=function(x,b){return u.__iterator(x,!b)},y}function ky(u,d,y,x){var b=sn(u);return x&&(b.has=function(E){var T=u.get(E,M);return T!==M&&!!d.call(y,T,E,u)},b.get=function(E,T){var P=u.get(E,M);return P!==M&&d.call(y,P,E,u)?P:T}),b.__iterateUncached=function(E,T){var P=this,F=0;return u.__iterate(function(V,q,nt){if(d.call(y,V,q,nt))return F++,E(V,x?q:F-1,P)},T),F},b.__iteratorUncached=function(E,T){var P=u.__iterator(j,T),F=0;return new U(function(){for(;;){var V=P.next();if(V.done)return V;var q=V.value,nt=q[0],lt=q[1];if(d.call(y,lt,nt,u))return Q(E,x?nt:F++,lt,V)}})},b}function yM(u,d,y){var x=kt().asMutable();return u.__iterate(function(b,E){x.update(d.call(y,b,E,u),0,function(T){return T+1})}),x.asImmutable()}function vM(u,d,y){var x=c(u),b=(g(u)?ae():kt()).asMutable();u.__iterate(function(T,P){b.update(d.call(y,T,P,u),function(F){return F=F||[],F.push(x?[P,T]:T),F})});var E=Fy(u);return b.map(function(T){return Ht(u,E(T))})}function Ch(u,d,y,x){var b=u.size;if(d!==void 0&&(d=d|0),y!==void 0&&(y===1/0?y=b:y=y|0),mt(d,y,b))return u;var E=dt(d,b),T=ut(y,b);if(E!==E||T!==T)return Ch(u.toSeq().cacheResult(),d,y,x);var P=T-E,F;P===P&&(F=P<0?0:P);var V=sn(u);return V.size=F===0?F:u.size&&F||void 0,!x&&Qe(u)&&F>=0&&(V.get=function(q,nt){return q=rt(this,q),q>=0&&q<F?u.get(q+E,nt):nt}),V.__iterateUncached=function(q,nt){var lt=this;if(F===0)return 0;if(nt)return this.cacheResult().__iterate(q,nt);var bt=0,Mt=!0,Qt=0;return u.__iterate(function(Dr,un){if(!(Mt&&(Mt=bt++<E)))return Qt++,q(Dr,x?un:Qt-1,lt)!==!1&&Qt!==F}),Qt},V.__iteratorUncached=function(q,nt){if(F!==0&&nt)return this.cacheResult().__iterator(q,nt);var lt=F!==0&&u.__iterator(q,nt),bt=0,Mt=0;return new U(function(){for(;bt++<E;)lt.next();if(++Mt>F)return G();var Qt=lt.next();return x||q===k?Qt:q===gt?Q(q,Mt-1,void 0,Qt):Q(q,Mt-1,Qt.value[1],Qt)})},V}function xM(u,d,y){var x=sn(u);return x.__iterateUncached=function(b,E){var T=this;if(E)return this.cacheResult().__iterate(b,E);var P=0;return u.__iterate(function(F,V,q){return d.call(y,F,V,q)&&++P&&b(F,V,T)}),P},x.__iteratorUncached=function(b,E){var T=this;if(E)return this.cacheResult().__iterator(b,E);var P=u.__iterator(j,E),F=!0;return new U(function(){if(!F)return G();var V=P.next();if(V.done)return V;var q=V.value,nt=q[0],lt=q[1];return d.call(y,lt,nt,T)?b===j?V:Q(b,nt,lt,V):(F=!1,G())})},x}function Iy(u,d,y,x){var b=sn(u);return b.__iterateUncached=function(E,T){var P=this;if(T)return this.cacheResult().__iterate(E,T);var F=!0,V=0;return u.__iterate(function(q,nt,lt){if(!(F&&(F=d.call(y,q,nt,lt))))return V++,E(q,x?nt:V-1,P)}),V},b.__iteratorUncached=function(E,T){var P=this;if(T)return this.cacheResult().__iterator(E,T);var F=u.__iterator(j,T),V=!0,q=0;return new U(function(){var nt,lt,bt;do{if(nt=F.next(),nt.done)return x||E===k?nt:E===gt?Q(E,q++,void 0,nt):Q(E,q++,nt.value[1],nt);var Mt=nt.value;lt=Mt[0],bt=Mt[1],V&&(V=d.call(y,bt,lt,P))}while(V);return E===j?nt:Q(E,lt,bt,nt)})},b}function _M(u,d){var y=c(u),x=[u].concat(d).map(function(T){return l(T)?y&&(T=s(T)):T=y?fi(T):ps(Array.isArray(T)?T:[T]),T}).filter(function(T){return T.size!==0});if(x.length===0)return u;if(x.length===1){var b=x[0];if(b===u||y&&c(b)||h(u)&&h(b))return b}var E=new ft(x);return y?E=E.toKeyedSeq():h(u)||(E=E.toSetSeq()),E=E.flatten(!0),E.size=x.reduce(function(T,P){if(T!==void 0){var F=P.size;if(F!==void 0)return T+F}},0),E}function Py(u,d,y){var x=sn(u);return x.__iterateUncached=function(b,E){var T=0,P=!1;function F(V,q){var nt=this;V.__iterate(function(lt,bt){return(!d||q<d)&&l(lt)?F(lt,q+1):b(lt,y?bt:T++,nt)===!1&&(P=!0),!P},E)}return F(u,0),T},x.__iteratorUncached=function(b,E){var T=u.__iterator(b,E),P=[],F=0;return new U(function(){for(;T;){var V=T.next();if(V.done!==!1){T=P.pop();continue}var q=V.value;if(b===j&&(q=q[1]),(!d||P.length<d)&&l(q))P.push(T),T=q.__iterator(b,E);else return y?V:Q(b,F++,q,V)}return G()})},x}function bM(u,d,y){var x=Fy(u);return u.toSeq().map(function(b,E){return x(d.call(y,b,E,u))}).flatten(!0)}function wM(u,d){var y=sn(u);return y.size=u.size&&u.size*2-1,y.__iterateUncached=function(x,b){var E=this,T=0;return u.__iterate(function(P,F){return(!T||x(d,T++,E)!==!1)&&x(P,T++,E)!==!1},b),T},y.__iteratorUncached=function(x,b){var E=u.__iterator(k,b),T=0,P;return new U(function(){return(!P||T%2)&&(P=E.next(),P.done)?P:T%2?Q(x,T++,d):Q(x,T++,P.value,P)})},y}function ws(u,d,y){d||(d=jy);var x=c(u),b=0,E=u.toSeq().map(function(T,P){return[P,T,b++,y?y(T,P,u):T]}).toArray();return E.sort(function(T,P){return d(T[3],P[3])||T[2]-P[2]}).forEach(x?function(T,P){E[P].length=2}:function(T,P){E[P]=T[1]}),x?Ft(E):h(u)?Pt(E):Ot(E)}function au(u,d,y){if(d||(d=jy),y){var x=u.toSeq().map(function(b,E){return[b,y(b,E,u)]}).reduce(function(b,E){return Ry(d,b[1],E[1])?E:b});return x&&x[0]}else return u.reduce(function(b,E){return Ry(d,b,E)?E:b})}function Ry(u,d,y){var x=u(y,d);return x===0&&y!==d&&(y==null||y!==y)||x>0}function kh(u,d,y){var x=sn(u);return x.size=new ft(y).map(function(b){return b.size}).min(),x.__iterate=function(b,E){for(var T=this.__iterator(k,E),P,F=0;!(P=T.next()).done&&b(P.value,F++,this)!==!1;);return F},x.__iteratorUncached=function(b,E){var T=y.map(function(V){return V=i(V),B(E?V.reverse():V)}),P=0,F=!1;return new U(function(){var V;return F||(V=T.map(function(q){return q.next()}),F=V.some(function(q){return q.done})),F?G():Q(b,P++,d.apply(null,V.map(function(q){return q.value})))})},x}function Ht(u,d){return Qe(u)?d:u.constructor(d)}function Ly(u){if(u!==Object(u))throw new TypeError("Expected [K, V] tuple: "+u)}function Ny(u){return er(u.size),it(u)}function Fy(u){return c(u)?s:h(u)?o:a}function sn(u){return Object.create((c(u)?Ft:h(u)?Pt:Ot).prototype)}function Ih(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):_t.prototype.cacheResult.call(this)}function jy(u,d){return u>d?1:u<d?-1:0}function Vy(u){var d=B(u);if(!d){if(!H(u))throw new TypeError("Expected iterable or array-like: "+u);d=B(i(u))}return d}r(rr,bo);function rr(u,d){var y,x=function(T){if(T instanceof x)return T;if(!(this instanceof x))return new x(T);if(!y){y=!0;var P=Object.keys(u);SM(b,P),b.size=P.length,b._name=d,b._keys=P,b._defaultValues=u}this._map=kt(T)},b=x.prototype=Object.create(Me);return b.constructor=x,x}rr.prototype.toString=function(){return this.__toString(Dy(this)+" {","}")},rr.prototype.has=function(u){return this._defaultValues.hasOwnProperty(u)},rr.prototype.get=function(u,d){if(!this.has(u))return d;var y=this._defaultValues[u];return this._map?this._map.get(u,y):y},rr.prototype.clear=function(){if(this.__ownerID)return this._map&&this._map.clear(),this;var u=this.constructor;return u._empty||(u._empty=uu(this,Vr()))},rr.prototype.set=function(u,d){if(!this.has(u))throw new Error('Cannot set unknown key "'+u+'" on '+Dy(this));if(this._map&&!this._map.has(u)){var y=this._defaultValues[u];if(d===y)return this}var x=this._map&&this._map.set(u,d);return this.__ownerID||x===this._map?this:uu(this,x)},rr.prototype.remove=function(u){if(!this.has(u))return this;var d=this._map&&this._map.remove(u);return this.__ownerID||d===this._map?this:uu(this,d)},rr.prototype.wasAltered=function(){return this._map.wasAltered()},rr.prototype.__iterator=function(u,d){var y=this;return s(this._defaultValues).map(function(x,b){return y.get(b)}).__iterator(u,d)},rr.prototype.__iterate=function(u,d){var y=this;return s(this._defaultValues).map(function(x,b){return y.get(b)}).__iterate(u,d)},rr.prototype.__ensureOwner=function(u){if(u===this.__ownerID)return this;var d=this._map&&this._map.__ensureOwner(u);return u?uu(this,d,u):(this.__ownerID=u,this._map=d,this)};var Me=rr.prototype;Me[S]=Me.remove,Me.deleteIn=Me.removeIn=zt.removeIn,Me.merge=zt.merge,Me.mergeWith=zt.mergeWith,Me.mergeIn=zt.mergeIn,Me.mergeDeep=zt.mergeDeep,Me.mergeDeepWith=zt.mergeDeepWith,Me.mergeDeepIn=zt.mergeDeepIn,Me.setIn=zt.setIn,Me.update=zt.update,Me.updateIn=zt.updateIn,Me.withMutations=zt.withMutations,Me.asMutable=zt.asMutable,Me.asImmutable=zt.asImmutable;function uu(u,d,y){var x=Object.create(Object.getPrototypeOf(u));return x._map=d,x.__ownerID=y,x}function Dy(u){return u._name||u.constructor.name||"Record"}function SM(u,d){try{d.forEach(MM.bind(void 0,u))}catch{}}function MM(u,d){Object.defineProperty(u,d,{get:function(){return this.get(d)},set:function(y){ru(this.__ownerID,"Cannot set on an immutable record."),this.set(d,y)}})}r(Kt,nu);function Kt(u){return u==null?Lh():Ph(u)&&!g(u)?u:Lh().withMutations(function(d){var y=a(u);er(y.size),y.forEach(function(x){return d.add(x)})})}Kt.of=function(){return this(arguments)},Kt.fromKeys=function(u){return this(s(u).keySeq())},Kt.prototype.toString=function(){return this.__toString("Set {","}")},Kt.prototype.has=function(u){return this._map.has(u)},Kt.prototype.add=function(u){return Rh(this,this._map.set(u,!0))},Kt.prototype.remove=function(u){return Rh(this,this._map.remove(u))},Kt.prototype.clear=function(){return Rh(this,this._map.clear())},Kt.prototype.union=function(){var u=e.call(arguments,0);return u=u.filter(function(d){return d.size!==0}),u.length===0?this:this.size===0&&!this.__ownerID&&u.length===1?this.constructor(u[0]):this.withMutations(function(d){for(var y=0;y<u.length;y++)a(u[y]).forEach(function(x){return d.add(x)})})},Kt.prototype.intersect=function(){var u=e.call(arguments,0);if(u.length===0)return this;u=u.map(function(y){return a(y)});var d=this;return this.withMutations(function(y){d.forEach(function(x){u.every(function(b){return b.includes(x)})||y.remove(x)})})},Kt.prototype.subtract=function(){var u=e.call(arguments,0);if(u.length===0)return this;u=u.map(function(y){return a(y)});var d=this;return this.withMutations(function(y){d.forEach(function(x){u.some(function(b){return b.includes(x)})&&y.remove(x)})})},Kt.prototype.merge=function(){return this.union.apply(this,arguments)},Kt.prototype.mergeWith=function(u){var d=e.call(arguments,1);return this.union.apply(this,d)},Kt.prototype.sort=function(u){return on(ws(this,u))},Kt.prototype.sortBy=function(u,d){return on(ws(this,d,u))},Kt.prototype.wasAltered=function(){return this._map.wasAltered()},Kt.prototype.__iterate=function(u,d){var y=this;return this._map.__iterate(function(x,b){return u(b,b,y)},d)},Kt.prototype.__iterator=function(u,d){return this._map.map(function(y,x){return x}).__iterator(u,d)},Kt.prototype.__ensureOwner=function(u){if(u===this.__ownerID)return this;var d=this._map.__ensureOwner(u);return u?this.__make(d,u):(this.__ownerID=u,this._map=d,this)};function Ph(u){return!!(u&&u[By])}Kt.isSet=Ph;var By="@@__IMMUTABLE_SET__@@",nr=Kt.prototype;nr[By]=!0,nr[S]=nr.remove,nr.mergeDeep=nr.merge,nr.mergeDeepWith=nr.mergeWith,nr.withMutations=zt.withMutations,nr.asMutable=zt.asMutable,nr.asImmutable=zt.asImmutable,nr.__empty=Lh,nr.__make=qy;function Rh(u,d){return u.__ownerID?(u.size=d.size,u._map=d,u):d===u._map?u:d.size===0?u.__empty():u.__make(d)}function qy(u,d){var y=Object.create(nr);return y.size=u?u.size:0,y._map=u,y.__ownerID=d,y}var $y;function Lh(){return $y||($y=qy(Vr()))}r(on,Kt);function on(u){return u==null?Nh():Hy(u)?u:Nh().withMutations(function(d){var y=a(u);er(y.size),y.forEach(function(x){return d.add(x)})})}on.of=function(){return this(arguments)},on.fromKeys=function(u){return this(s(u).keySeq())},on.prototype.toString=function(){return this.__toString("OrderedSet {","}")};function Hy(u){return Ph(u)&&g(u)}on.isOrderedSet=Hy;var lu=on.prototype;lu[_]=!0,lu.__empty=Nh,lu.__make=Gy;function Gy(u,d){var y=Object.create(lu);return y.size=u?u.size:0,y._map=u,y.__ownerID=d,y}var Wy;function Nh(){return Wy||(Wy=Gy(ou()))}r(fe,gs);function fe(u){return u==null?Fh():Uy(u)?u:Fh().unshiftAll(u)}fe.of=function(){return this(arguments)},fe.prototype.toString=function(){return this.__toString("Stack [","]")},fe.prototype.get=function(u,d){var y=this._head;for(u=rt(this,u);y&&u--;)y=y.next;return y?y.value:d},fe.prototype.peek=function(){return this._head&&this._head.value},fe.prototype.push=function(){if(arguments.length===0)return this;for(var u=this.size+arguments.length,d=this._head,y=arguments.length-1;y>=0;y--)d={value:arguments[y],next:d};return this.__ownerID?(this.size=u,this._head=d,this.__hash=void 0,this.__altered=!0,this):zo(u,d)},fe.prototype.pushAll=function(u){if(u=o(u),u.size===0)return this;er(u.size);var d=this.size,y=this._head;return u.reverse().forEach(function(x){d++,y={value:x,next:y}}),this.__ownerID?(this.size=d,this._head=y,this.__hash=void 0,this.__altered=!0,this):zo(d,y)},fe.prototype.pop=function(){return this.slice(1)},fe.prototype.unshift=function(){return this.push.apply(this,arguments)},fe.prototype.unshiftAll=function(u){return this.pushAll(u)},fe.prototype.shift=function(){return this.pop.apply(this,arguments)},fe.prototype.clear=function(){return this.size===0?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Fh()},fe.prototype.slice=function(u,d){if(mt(u,d,this.size))return this;var y=dt(u,this.size),x=ut(d,this.size);if(x!==this.size)return gs.prototype.slice.call(this,u,d);for(var b=this.size-y,E=this._head;y--;)E=E.next;return this.__ownerID?(this.size=b,this._head=E,this.__hash=void 0,this.__altered=!0,this):zo(b,E)},fe.prototype.__ensureOwner=function(u){return u===this.__ownerID?this:u?zo(this.size,this._head,u,this.__hash):(this.__ownerID=u,this.__altered=!1,this)},fe.prototype.__iterate=function(u,d){if(d)return this.reverse().__iterate(u);for(var y=0,x=this._head;x&&u(x.value,y++,this)!==!1;)x=x.next;return y},fe.prototype.__iterator=function(u,d){if(d)return this.reverse().__iterator(u);var y=0,x=this._head;return new U(function(){if(x){var b=x.value;return x=x.next,Q(u,y++,b)}return G()})};function Uy(u){return!!(u&&u[Yy])}fe.isStack=Uy;var Yy="@@__IMMUTABLE_STACK__@@",Ss=fe.prototype;Ss[Yy]=!0,Ss.withMutations=zt.withMutations,Ss.asMutable=zt.asMutable,Ss.asImmutable=zt.asImmutable,Ss.wasAltered=zt.wasAltered;function zo(u,d,y,x){var b=Object.create(Ss);return b.size=u,b._head=d,b.__ownerID=y,b.__hash=x,b.__altered=!1,b}var Xy;function Fh(){return Xy||(Xy=zo(0))}function an(u,d){var y=function(x){u.prototype[x]=d[x]};return Object.keys(d).forEach(y),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(d).forEach(y),u}i.Iterator=U,an(i,{toArray:function(){er(this.size);var u=new Array(this.size||0);return this.valueSeq().__iterate(function(d,y){u[y]=d}),u},toIndexedSeq:function(){return new xs(this)},toJS:function(){return this.toSeq().map(function(u){return u&&typeof u.toJS=="function"?u.toJS():u}).__toJS()},toJSON:function(){return this.toSeq().map(function(u){return u&&typeof u.toJSON=="function"?u.toJSON():u}).__toJS()},toKeyedSeq:function(){return new mr(this,!0)},toMap:function(){return kt(this.toKeyedSeq())},toObject:function(){er(this.size);var u={};return this.__iterate(function(d,y){u[y]=d}),u},toOrderedMap:function(){return ae(this.toKeyedSeq())},toOrderedSet:function(){return on(c(this)?this.valueSeq():this)},toSet:function(){return Kt(c(this)?this.valueSeq():this)},toSetSeq:function(){return new _s(this)},toSeq:function(){return h(this)?this.toIndexedSeq():c(this)?this.toKeyedSeq():this.toSetSeq()},toStack:function(){return fe(c(this)?this.valueSeq():this)},toList:function(){return Zt(c(this)?this.valueSeq():this)},toString:function(){return"[Iterable]"},__toString:function(u,d){return this.size===0?u+d:u+" "+this.toSeq().map(this.__toStringMapper).join(", ")+" "+d},concat:function(){var u=e.call(arguments,0);return Ht(this,_M(this,u))},includes:function(u){return this.some(function(d){return ee(d,u)})},entries:function(){return this.__iterator(j)},every:function(u,d){er(this.size);var y=!0;return this.__iterate(function(x,b,E){if(!u.call(d,x,b,E))return y=!1,!1}),y},filter:function(u,d){return Ht(this,ky(this,u,d,!0))},find:function(u,d,y){var x=this.findEntry(u,d);return x?x[1]:y},forEach:function(u,d){return er(this.size),this.__iterate(d?u.bind(d):u)},join:function(u){er(this.size),u=u!==void 0?""+u:",";var d="",y=!0;return this.__iterate(function(x){y?y=!1:d+=u,d+=x!=null?x.toString():""}),d},keys:function(){return this.__iterator(gt)},map:function(u,d){return Ht(this,Cy(this,u,d))},reduce:function(u,d,y){er(this.size);var x,b;return arguments.length<2?b=!0:x=d,this.__iterate(function(E,T,P){b?(b=!1,x=E):x=u.call(y,x,E,T,P)}),x},reduceRight:function(u,d,y){var x=this.toKeyedSeq().reverse();return x.reduce.apply(x,arguments)},reverse:function(){return Ht(this,Th(this,!0))},slice:function(u,d){return Ht(this,Ch(this,u,d,!0))},some:function(u,d){return!this.every(hu(u),d)},sort:function(u){return Ht(this,ws(this,u))},values:function(){return this.__iterator(k)},butLast:function(){return this.slice(0,-1)},isEmpty:function(){return this.size!==void 0?this.size===0:!this.some(function(){return!0})},count:function(u,d){return it(u?this.toSeq().filter(u,d):this)},countBy:function(u,d){return yM(this,u,d)},equals:function(u){return pi(this,u)},entrySeq:function(){var u=this;if(u._cache)return new ft(u._cache);var d=u.toSeq().map(AM).toIndexedSeq();return d.fromEntrySeq=function(){return u.toSeq()},d},filterNot:function(u,d){return this.filter(hu(u),d)},findEntry:function(u,d,y){var x=y;return this.__iterate(function(b,E,T){if(u.call(d,b,E,T))return x=[E,b],!1}),x},findKey:function(u,d){var y=this.findEntry(u,d);return y&&y[0]},findLast:function(u,d,y){return this.toKeyedSeq().reverse().find(u,d,y)},findLastEntry:function(u,d,y){return this.toKeyedSeq().reverse().findEntry(u,d,y)},findLastKey:function(u,d){return this.toKeyedSeq().reverse().findKey(u,d)},first:function(){return this.find(vt)},flatMap:function(u,d){return Ht(this,bM(this,u,d))},flatten:function(u){return Ht(this,Py(this,u,!0))},fromEntrySeq:function(){return new bs(this)},get:function(u,d){return this.find(function(y,x){return ee(x,u)},void 0,d)},getIn:function(u,d){for(var y=this,x=Vy(u),b;!(b=x.next()).done;){var E=b.value;if(y=y&&y.get?y.get(E,M):M,y===M)return d}return y},groupBy:function(u,d){return vM(this,u,d)},has:function(u){return this.get(u,M)!==M},hasIn:function(u){return this.getIn(u,M)!==M},isSubset:function(u){return u=typeof u.includes=="function"?u:i(u),this.every(function(d){return u.includes(d)})},isSuperset:function(u){return u=typeof u.isSubset=="function"?u:i(u),u.isSubset(this)},keyOf:function(u){return this.findKey(function(d){return ee(d,u)})},keySeq:function(){return this.toSeq().map(EM).toIndexedSeq()},last:function(){return this.toSeq().reverse().first()},lastKeyOf:function(u){return this.toKeyedSeq().reverse().keyOf(u)},max:function(u){return au(this,u)},maxBy:function(u,d){return au(this,d,u)},min:function(u){return au(this,u?Jy(u):Ky)},minBy:function(u,d){return au(this,d?Jy(d):Ky,u)},rest:function(){return this.slice(1)},skip:function(u){return this.slice(Math.max(0,u))},skipLast:function(u){return Ht(this,this.toSeq().reverse().skip(u).reverse())},skipWhile:function(u,d){return Ht(this,Iy(this,u,d,!0))},skipUntil:function(u,d){return this.skipWhile(hu(u),d)},sortBy:function(u,d){return Ht(this,ws(this,d,u))},take:function(u){return this.slice(0,Math.max(0,u))},takeLast:function(u){return Ht(this,this.toSeq().reverse().take(u).reverse())},takeWhile:function(u,d){return Ht(this,xM(this,u,d))},takeUntil:function(u,d){return this.takeWhile(hu(u),d)},valueSeq:function(){return this.toIndexedSeq()},hashCode:function(){return this.__hash||(this.__hash=zM(this))}});var Ne=i.prototype;Ne[p]=!0,Ne[et]=Ne.values,Ne.__toJS=Ne.toArray,Ne.__toStringMapper=Zy,Ne.inspect=Ne.toSource=function(){return this.toString()},Ne.chain=Ne.flatMap,Ne.contains=Ne.includes,an(s,{flip:function(){return Ht(this,Ty(this))},mapEntries:function(u,d){var y=this,x=0;return Ht(this,this.toSeq().map(function(b,E){return u.call(d,[E,b],x++,y)}).fromEntrySeq())},mapKeys:function(u,d){var y=this;return Ht(this,this.toSeq().flip().map(function(x,b){return u.call(d,x,b,y)}).flip())}});var cu=s.prototype;cu[m]=!0,cu[et]=Ne.entries,cu.__toJS=Ne.toObject,cu.__toStringMapper=function(u,d){return JSON.stringify(d)+": "+Zy(u)},an(o,{toKeyedSeq:function(){return new mr(this,!1)},filter:function(u,d){return Ht(this,ky(this,u,d,!1))},findIndex:function(u,d){var y=this.findEntry(u,d);return y?y[0]:-1},indexOf:function(u){var d=this.keyOf(u);return d===void 0?-1:d},lastIndexOf:function(u){var d=this.lastKeyOf(u);return d===void 0?-1:d},reverse:function(){return Ht(this,Th(this,!1))},slice:function(u,d){return Ht(this,Ch(this,u,d,!1))},splice:function(u,d){var y=arguments.length;if(d=Math.max(d|0,0),y===0||y===2&&!d)return this;u=dt(u,u<0?this.count():this.size);var x=this.slice(0,u);return Ht(this,y===1?x:x.concat(X(arguments,2),this.slice(u+d)))},findLastIndex:function(u,d){var y=this.findLastEntry(u,d);return y?y[0]:-1},first:function(){return this.get(0)},flatten:function(u){return Ht(this,Py(this,u,!1))},get:function(u,d){return u=rt(this,u),u<0||this.size===1/0||this.size!==void 0&&u>this.size?d:this.find(function(y,x){return x===u},void 0,d)},has:function(u){return u=rt(this,u),u>=0&&(this.size!==void 0?this.size===1/0||u<this.size:this.indexOf(u)!==-1)},interpose:function(u){return Ht(this,wM(this,u))},interleave:function(){var u=[this].concat(X(arguments)),d=kh(this.toSeq(),Pt.of,u),y=d.flatten(!0);return d.size&&(y.size=d.size*u.length),Ht(this,y)},keySeq:function(){return Se(0,this.size)},last:function(){return this.get(-1)},skipWhile:function(u,d){return Ht(this,Iy(this,u,d,!1))},zip:function(){var u=[this].concat(X(arguments));return Ht(this,kh(this,OM,u))},zipWith:function(u){var d=X(arguments);return d[0]=this,Ht(this,kh(this,u,d))}}),o.prototype[v]=!0,o.prototype[_]=!0,an(a,{get:function(u,d){return this.has(u)?u:d},includes:function(u){return this.has(u)},keySeq:function(){return this.valueSeq()}}),a.prototype.has=Ne.includes,a.prototype.contains=a.prototype.includes,an(Ft,s.prototype),an(Pt,o.prototype),an(Ot,a.prototype),an(bo,s.prototype),an(gs,o.prototype),an(nu,a.prototype);function EM(u,d){return d}function AM(u,d){return[d,u]}function hu(u){return function(){return!u.apply(this,arguments)}}function Jy(u){return function(){return-u.apply(this,arguments)}}function Zy(u){return typeof u=="string"?JSON.stringify(u):String(u)}function OM(){return X(arguments)}function Ky(u,d){return u<d?1:u>d?-1:0}function zM(u){if(u.size===1/0)return 0;var d=g(u),y=c(u),x=d?1:0,b=u.__iterate(y?d?function(E,T){x=31*x+Qy(tr(E),tr(T))|0}:function(E,T){x=x+Qy(tr(E),tr(T))|0}:d?function(E){x=31*x+tr(E)|0}:function(E){x=x+tr(E)|0});return TM(b,x)}function TM(u,d){return d=wo(d,3432918353),d=wo(d<<15|d>>>-15,461845907),d=wo(d<<13|d>>>-13,5),d=(d+3864292196|0)^u,d=wo(d^d>>>16,2246822507),d=wo(d^d>>>13,3266489909),d=dh(d^d>>>16),d}function Qy(u,d){return u^d+2654435769+(u<<6)+(u>>2)|0}var CM={Iterable:i,Seq:_t,Collection:qn,Map:kt,OrderedMap:ae,List:Zt,Stack:fe,Set:Kt,OrderedSet:on,Record:rr,Range:Se,Repeat:be,is:ee,fromJS:nn};return CM})})(ia)),ia.exports}var Al,wd;function Bv(){if(wd)return Al;wd=1;var n=El(),t=function(i){return n.Iterable.isKeyed(i)},e=function(i){return n.Iterable.isIndexed(i)},r=function(i,s,o){return i==="remove"?{op:i,path:s}:{op:i,path:s,value:o}};return Al={isMap:t,isIndexed:e,op:r},Al}var Ol,Sd;function qv(){if(Sd)return Ol;Sd=1;var n=El(),t=function(c,h,f){for(var g=[],p=0;p<c;p++){g[p]=new Array(h);for(var m=0;m<h;m++)g[p][m]=f}return g},e=function(c,h){var f=a(c,h);return l(c,h,f)},r=n.Record({op:"=",val:null}),i=n.Record({op:"!=",val:null,newVal:null}),s=function(c,h){var f=a(c,h);return o(f,c,h,c.size||0,h.size||0)},o=function(c,h,f,g,p){for(var m=[],v=g-1,_=p-1;v>=0||_>=0;)v>=0&&_>=0&&n.is(h.get(v),f.get(_))?(m.push(new r({op:"=",val:h.get(v)})),v-=1,_-=1):v>=0&&_>=0&&v===_&&!n.is(h.get(v),f.get(_))?(m.push(new i({val:h.get(v),newVal:f.get(v)})),v-=1,_-=1):_>=0&&(v===-1||c[v+1][_]>=c[v][_+1])?(m.push(new r({op:"+",val:f.get(_)})),_-=1):v>=0&&(_===-1||c[v+1][_]<c[v][_+1])&&(m.push(new r({op:"-",val:h.get(v)})),v-=1);return m.reverse()};function a(c,h){for(var f=c.size||0,g=h.size||0,p=t(f+1,g+1,0),m=0;m<f;m++)for(var v=0;v<g;v++)n.is(c.get(m),h.get(v))?p[m+1][v+1]=p[m][v]+1:p[m+1][v+1]=Math.max(p[m+1][v],p[m][v+1]);return p}var l=function(c,h,f){for(var g=[],p=c.size,m=h.size;p!==0&&m!==0;)f[p][m]===f[p-1][m]?p--:f[p][m]===f[p][m-1]?m--:n.is(c.get(p-1),h.get(m-1))&&(g.push(c.get(p-1)),p--,m--);return g.reverse()};return Ol={lcs:e,computeLcsMatrix:a,diff:s},Ol}var zl,Md;function $v(){if(Md)return zl;Md=1;var n=new RegExp("/","g"),t=new RegExp("~1","g"),e=/~/g,r=/~0/g,i={escape:function(s){if(typeof s=="number")return s.toString();if(typeof s!="string")throw"param str ("+s+") is not a string";return s.replace(e,"~0").replace(n,"~1")},unescape:function(s){return typeof s=="string"?s.replace(t,"/").replace(r,"~"):s},concat:function(s,o){return s+"/"+o}};return zl=i,zl}var Tl,Ed;function Hv(){if(Ed)return Tl;Ed=1;var n=El(),t=Bv(),e=qv(),r=$v(),i=r.concat,s=r.escape,o=t.op,a=t.isMap,l=t.isIndexed,c=function(p,m,v){var _=[],S=v||"";if(n.is(p,m)||p==m==null)return _;var A=l(p)&&l(m),C=null,O=null;return p.forEach&&p.forEach(function(M,z){if(m.has(z))if(a(M)&&a(m.get(z)))_=_.concat(c(M,m.get(z),i(S,s(z))));else if(l(m.get(z))&&l(M))_=_.concat(h(M,m.get(z),i(S,s(z))));else{var R=m.get?m.get(z):m,I=M!==R;I&&_.push(o("replace",i(S,s(z)),R))}else A?(O=C!=null&&C+1===z?O:z,_.push(o("remove",i(S,s(O)))),C=z):_.push(o("remove",i(S,s(z))))}),m.forEach(function(M,z){p.has&&!p.has(z)&&_.push(o("add",i(S,s(z)),M))}),_},h=function(p,m,v){var _=[],S=v||"";if(n.is(p,m)||p==m==null)return _;if((p.count()+1)*(m.count()+1)>=1e4)return c(p,m,v);var A=e.diff(p,m),C=0;return A.forEach(function(O){if(O.op==="=")C++;else if(O.op==="!="){if(a(O.val)&&a(O.newVal)){var M=c(O.val,O.newVal,i(S,C));_=_.concat(M)}else _.push(o("replace",i(S,C),O.newVal));C++}else O.op==="+"?(_.push(o("add",i(S,C),O.val)),C++):O.op==="-"&&_.push(o("remove",i(S,C)))}),_},f=function(p,m,v){var _=v||"";return p===m?[]:[o("replace",i(_,""),m)]},g=function(p,m,v){return n.is(p,m)?n.List():p!=m&&(p==null||m==null)?n.fromJS([o("replace","/",m)]):l(p)&&l(m)?n.fromJS(h(p,m)):a(p)&&a(m)?n.fromJS(c(p,m)):n.fromJS(f(p,m,v))};return Tl=g,Tl}var Gv=Hv();const Wv=Br(Gv),Uv=jh(iv);var Cl,Ad;function Yv(){if(Ad)return Cl;Ad=1;var n=new RegExp("/","g"),t=new RegExp("~1","g"),e=/~/g,r=/~0/g,i={escape:function(s){if(typeof s!="string")throw"param str ("+s+") is not a string";return s.replace(e,"~0").replace(n,"~1")},unescape:function(s){return typeof s=="string"?s.replace(t,"/").replace(r,"~"):s}};return Cl=i,Cl}var kl,Od;function Xv(){if(Od)return kl;Od=1;var n=Uv,t=Yv(),e=function(h){var f=parseInt(h);return isNaN(f)?h:f},r=function(h,f){if(h==="add"||h==="replace")return f;if(h==="remove")return null},i=function(h,f,g,p,m){if(p==="add")if(g.length>0&&h.get(f)===void 0){var v=g[0].match(/^\d+$/)?n.List():n.Map();return h.set(f,a(v,g,p,m))}else return h.set(f,a(h.get(f),g,p,m));else{if(p==="replace")return g.length>0?h.set(f,a(h.get(f),g,p,m)):h.set(f,m);if(p==="remove")return g.length>0?h.set(f,a(h.get(f),g,p,m)):h.remove(f);throw new Error("map patch Error, unknown op: "+p)}},s=function(h,f,g,p,m){if(f=e(f),p==="add")if(h.get(f)===void 0)if(g.length>0){var v=g[0].match(/^\d+$/)?n.List():n.Map();return h.set(f,a(v,g,p,m))}else return f==="-"?h.splice(h.size,0,m):h.splice(f,0,m);else return g.length>0?h.set(f,a(h.get(f),g,p,m)):h.splice(f,0,m);else{if(p==="replace")return g.length>0?h.set(f,a(h.get(f),g,p,m)):h.set(f,m);if(p==="remove")return g.length>0?h.set(f,a(h.get(f),g,p,m)):h.remove(f);throw new Error("sequence patch Error, unknown op: "+p)}},o=function(h){return h!=null&&typeof h.updateIn=="function"&&typeof h.set=="function"},a=function(h,f,g,p){var m,v;return n.Iterable.isIndexed(h)?f.length===0?h:(m=f[0],v=f.slice(1),s(h,m,v,g,p)):n.Iterable.isKeyed(h)||o(h)?f.length===0?h:(m=f[0],v=f.slice(1),i(h,m,v,g,p)):f.length===0?p:r(g,p)},l=function(h,f){for(;f.size;){var g=f.get(0),f=f.slice(1),p=g.get("path").split("/").slice(1).map(t.unescape);h=a(h,p,g.get("op"),g.get("value"))}return h},c=function(h,f){if(f.size===1){var g=f.get(0);if(g.get("op")==="replace"&&g.get("path")==="/")return g.get("value")}return l(h,f)};return c.default=c,kl=c,kl}var Jv=Xv();const zd=Br(Jv),ne=(n,t)=>{if(n.last){if(n.last.hashCode()!==t.hashCode()){let e=J({time:Date.now(),diff:Wv(n.last,t)});n=n.set("last",t).set("list",n.list.push(e)).set("redoList",n.redoList.clear())}}else n=n.set("last",t);return n},Zv=n=>{if(n.last&&n.redoList.size){const t=n.redoList.last(),e=zd(n.last,t.get("diff"));n=n.set("last",e).set("list",n.list.push(t)).set("redoList",n.redoList.pop())}return n},Td=n=>{var t;if(n.last&&n.list.size){const e=n.list.last();let r=n.first;for(let i=0;i<n.list.size-1;i++)r=zd(r,(t=n.list.get(i))==null?void 0:t.get("diff"));n=n.set("last",r).set("list",n.list.pop()).set("redoList",n.redoList.push(e))}return n};var Il={exports:{}},Pl,Cd;function Kv(){if(Cd)return Pl;Cd=1;var n=1;function t(){return n=(n*9301+49297)%233280,n/233280}function e(r){n=r}return Pl={nextValue:t,seed:e},Pl}var Rl,kd;function sa(){if(kd)return Rl;kd=1;var n=Kv(),t="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-",e,r,i;function s(){i=!1}function o(p){if(!p){e!==t&&(e=t,s());return}if(p!==e){if(p.length!==t.length)throw new Error("Custom alphabet for shortid must be "+t.length+" unique characters. You submitted "+p.length+" characters: "+p);var m=p.split("").filter(function(v,_,S){return _!==S.lastIndexOf(v)});if(m.length)throw new Error("Custom alphabet for shortid must be "+t.length+" unique characters. These characters were not unique: "+m.join(", "));e=p,s()}}function a(p){return o(p),e}function l(p){n.seed(p),r!==p&&(s(),r=p)}function c(){e||o(t);for(var p=e.split(""),m=[],v=n.nextValue(),_;p.length>0;)v=n.nextValue(),_=Math.floor(v*p.length),m.push(p.splice(_,1)[0]);return m.join("")}function h(){return i||(i=c(),i)}function f(p){var m=h();return m[p]}function g(){return e||t}return Rl={get:g,characters:a,seed:l,lookup:f,shuffled:h},Rl}var Ll,Id;function Qv(){if(Id)return Ll;Id=1;var n=typeof window=="object"&&(window.crypto||window.msCrypto),t;return!n||!n.getRandomValues?t=function(e){for(var r=[],i=0;i<e;i++)r.push(Math.floor(Math.random()*256));return r}:t=function(e){return n.getRandomValues(new Uint8Array(e))},Ll=t,Ll}let tx="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict",Pd=n=>crypto.getRandomValues(new Uint8Array(n)),Rd=(n,t,e)=>{let r=(2<<Math.log(n.length-1)/Math.LN2)-1,i=-~(1.6*r*t/n.length);return(s=t)=>{let o="";for(;;){let a=e(i),l=i|0;for(;l--;)if(o+=n[a[l]&r]||"",o.length===s)return o}}};const ex=jh(Object.freeze(Object.defineProperty({__proto__:null,customAlphabet:(n,t=21)=>Rd(n,t,Pd),customRandom:Rd,nanoid:(n=21)=>crypto.getRandomValues(new Uint8Array(n)).reduce((t,e)=>(e&=63,e<36?t+=e.toString(36):e<62?t+=(e-26).toString(36).toUpperCase():e>62?t+="-":t+="_",t),""),random:Pd,urlAlphabet:tx},Symbol.toStringTag,{value:"Module"})));var Nl,Ld;function rx(){if(Ld)return Nl;Ld=1;var n=sa(),t=Qv(),e=ex.customRandom;function r(i){for(var s=0,o,a="";!o;)a=a+e(n.get(),1,t)(),o=i<Math.pow(16,s+1),s++;return a}return Nl=r,Nl}var Fl,Nd;function nx(){if(Nd)return Fl;Nd=1;var n=rx();sa();var t=1567752802062,e=7,r,i;function s(o){var a="",l=Math.floor((Date.now()-t)*.001);return l===i?r++:(r=0,i=l),a=a+n(e),a=a+n(o),r>0&&(a=a+n(r)),a=a+n(l),a}return Fl=s,Fl}var jl,Fd;function ix(){if(Fd)return jl;Fd=1;var n=sa();function t(e){if(!e||typeof e!="string"||e.length<6)return!1;var r=new RegExp("[^"+n.get().replace(/[|\\{}()[\]^$+*?.-]/g,"\\$&")+"]");return!r.test(e)}return jl=t,jl}var Vl,jd;function sx(){return jd||(jd=1,Vl=0),Vl}var Vd;function ox(){return Vd||(Vd=1,(function(n){var t=sa(),e=nx(),r=ix(),i=sx()||0;function s(c){return t.seed(c),n.exports}function o(c){return i=c,n.exports}function a(c){return c!==void 0&&t.characters(c),t.shuffled()}function l(){return e(i)}n.exports=l,n.exports.generate=l,n.exports.seed=s,n.exports.worker=o,n.exports.characters=a,n.exports.isValid=r})(Il)),Il.exports}var Dl,Dd;function ax(){return Dd||(Dd=1,Dl=ox()),Dl}var ux=ax();const lx=Br(ux);class Xr{static acquireID(){return lx.generate()}}class oa{static generateName(t,e){return e.charAt(0).toUpperCase()+e.slice(1)}}class le{static create(t,e,r,i,s,o){let a=Xr.acquireID(),l=t.catalog.factoryElement(r,{id:a,name:oa.generateName("holes",t.catalog.getIn(["elements",r,"info","title"])),type:r,offset:s,line:i},o);return t=t.setIn(["scene","layers",e,"holes",a],l),t=t.updateIn(["scene","layers",e,"lines",i,"holes"],c=>c.push(a)),{updatedState:t,hole:l}}static select(t,e,r){return t=pt.select(t,e).updatedState,t=pt.selectElement(t,e,"holes",r).updatedState,{updatedState:t}}static remove(t,e,r){let i=t.getIn(["scene","layers",e,"holes",r]);return t=this.unselect(t,e,r).updatedState,t=pt.removeElement(t,e,"holes",r).updatedState,t=t.updateIn(["scene","layers",e,"lines",i.line,"holes"],s=>{let o=s.findIndex(a=>r===a);return o!==-1?s.remove(o):s}),t.getIn(["scene","groups"]).forEach(s=>t=ce.removeElement(t,s.id,e,"holes",r).updatedState),{updatedState:t}}static unselect(t,e,r){return t=pt.unselect(t,e,"holes",r).updatedState,{updatedState:t}}static selectToolDrawingHole(t,e){let r=st().withMutations(i=>{let{lines:s,vertices:o}=t.getIn(["scene","layers",t.scene.selectedLayer]);s.forEach(a=>{let{x:l,y:c}=o.get(a.vertices.get(0)),{x:h,y:f}=o.get(a.vertices.get(1));Xs(i,l,c,h,f,20,1,a.id)})});return t=t.merge({mode:Ue,snapElements:r,drawingSupport:J({type:e})}),{updatedState:t}}static updateDrawingHole(t,e,r,i){let s=t.catalog,o=Yr(t.snapElements,r,i,t.snapMask.merge({SNAP_SEGMENT:!0}));o&&({x:r,y:i}=o.point);let a=t.getIn(["scene","layers",e,"selected","holes"]).first();if(o){let l=o.snap.related.get(0),c=t.getIn(["scene","layers",e,"lines",l,"vertices"]),{x:h,y:f}=t.getIn(["scene","layers",e,"vertices",c.get(0)]),{x:g,y:p}=t.getIn(["scene","layers",e,"vertices",c.get(1)]),m=Xo({x:h,y:f},{x:g,y:p}),v=dl({x:h,y:f},{x:g,y:p}),_=s.factoryElement(t.drawingSupport.get("type")).properties.getIn(["width","length"]),S=Oe(h,f,g,p),A=dv(h,f,g,p),C=gv(A,1e-7),O=mv(A,1e-7),M={x:m.x+_/2*C,y:m.y+_/2*O},z={x:m.x+S*C-_/2*C,y:m.y+S*O-_/2*O},R;if(r<M.x?R=ze(m.x,m.y,v.x,v.y,M.x,M.y):r>z.x?R=ze(m.x,m.y,v.x,v.y,z.x,z.y):r===M.x&&r===z.x?i<M.y?(R=ze(m.x,m.y,v.x,v.y,M.x,M.y),R=m.x===h&&m.y===f?R:1-R):i>z.y?(R=ze(m.x,m.y,v.x,v.y,z.x,z.y),R=m.x===h&&m.y===f?R:1-R):R=ze(h,f,g,p,r,i):R=ze(h,f,g,p,r,i),a&&o){t=t.mergeIn(["scene","layers",e,"holes",a],{offset:R,line:l});let I=t.getIn(["scene","layers",e,"lines"]).findEntry(Y=>Y.id!==l&&Y.get("holes").contains(a));if(I){let Y=I[1].get("holes").filter(X=>X!==a);t=t.setIn(["scene","layers",e,"lines",I[0],"holes"],Y)}let L=t.getIn(["scene","layers",e,"lines",l,"holes"]);L.contains(a)||(t=t.setIn(["scene","layers",e,"lines",l,"holes"],L.push(a)))}else if(!a&&o){let{updatedState:I,hole:L}=this.create(t,e,t.drawingSupport.get("type"),l,R);t=le.select(I,e,L.id).updatedState}}return{updatedState:t}}static endDrawingHole(t,e,r,i){return t=this.updateDrawingHole(t,e,r,i).updatedState,t=pt.unselectAll(t,e).updatedState,{updatedState:t}}static beginDraggingHole(t,e,r,i,s){let o=t.getIn(["scene","layers",e]),a=o.getIn(["holes",r]),l=o.getIn(["lines",a.line]),c=o.getIn(["vertices",l.vertices.get(0)]),h=o.getIn(["vertices",l.vertices.get(1)]),f=Xs(st(),c.x,c.y,h.x,h.y,9999999,1,null);return t=t.merge({mode:Sr,snapElements:f,draggingSupport:J({layerID:e,holeID:r,startPointX:i,startPointY:s})}),{updatedState:t}}static updateDraggingHole(t,e,r){let i=Yr(t.snapElements,e,r,t.snapMask.merge({SNAP_SEGMENT:!0}));if(!i)return t;let{draggingSupport:s,scene:o}=t,a=s.get("layerID"),l=s.get("holeID"),c=t.getIn(["scene","layers",a]),h=c.getIn(["holes",l]),f=c.getIn(["lines",h.line]),g=c.getIn(["vertices",f.vertices.get(0)]),p=c.getIn(["vertices",f.vertices.get(1)]);({x:e,y:r}=i.point);let m=Xo(g,p),v=dl(g,p),_=h.properties.get("width").get("length"),S=Oe(g.x,g.y,p.x,p.y),A=Math.atan2(Math.abs(p.y-g.y),Math.abs(p.x-g.x)),C=Y=>{let X=Math.cos(Y);return X<1e-7?0:X},O=Y=>{let X=Math.sin(Y);return X<1e-7?0:X},M=C(A),z=O(A),R={x:m.x+_/2*M,y:m.y+_/2*z},I={x:m.x+S*M-_/2*M,y:m.y+S*z-_/2*z},L;return e<R.x?L=ze(m.x,m.y,v.x,v.y,R.x,R.y):e>I.x?L=ze(m.x,m.y,v.x,v.y,I.x,I.y):e===R.x&&e===I.x?r<R.y?(L=ze(m.x,m.y,v.x,v.y,R.x,R.y),L=m===g?L:1-L):r>I.y?(L=ze(m.x,m.y,v.x,v.y,I.x,I.y),L=m===g?L:1-L):(L=ze(m.x,m.y,v.x,v.y,e,r),L=m===g?L:1-L):L=ze(m.x,m.y,v.x,v.y,e,r),h=h.set("offset",L),t=t.merge({scene:o.mergeIn(["layers",a,"holes",l],h)}),{updatedState:t}}static endDraggingHole(t,e,r){return t=this.updateDraggingHole(t,e,r).updatedState,t=t.merge({mode:re}),{updatedState:t}}static setProperties(t,e,r,i){return t=t.setIn(["scene","layers",e,"holes",r,"properties"],i),{updatedState:t}}static setJsProperties(t,e,r,i){return this.setProperties(t,e,r,Bt(i))}static updateProperties(t,e,r,i){return i.forEach((s,o)=>{t.hasIn(["scene","layers",e,"holes",r,"properties",o])&&(t=t.mergeIn(["scene","layers",e,"holes",r,"properties",o],s))}),{updatedState:t}}static updateJsProperties(t,e,r,i){return this.updateProperties(t,e,r,Bt(i))}static setAttributes(t,e,r,i){let s=i.toJS(),{offsetA:o,offsetB:a,offset:l}=s;delete s.offsetA,delete s.offsetB,delete s.offset;let c=J({_unitA:o._unit,_unitB:a._unit});return t=t.mergeIn(["scene","layers",e,"holes",r],Bt(s)).mergeDeepIn(["scene","layers",e,"holes",r],J({offset:l,misc:c})),{updatedState:t}}}let pe=class t0{static create(t,e,r,i,s,o,a,l){let c=Xr.acquireID(),h=t.catalog.factoryElement(r,{id:c,name:oa.generateName("items",t.catalog.getIn(["elements",r,"info","title"])),type:r,height:a,width:o,x:i,y:s,rotation:l});return t=t.setIn(["scene","layers",e,"items",c],h),{updatedState:t,item:h}}static select(t,e,r){return t=pt.select(t,e).updatedState,t=pt.selectElement(t,e,"items",r).updatedState,{updatedState:t}}static remove(t,e,r){return t=this.unselect(t,e,r).updatedState,t=pt.removeElement(t,e,"items",r).updatedState,t.getIn(["scene","groups"]).forEach(i=>t=ce.removeElement(t,i.id,e,"items",r).updatedState),{updatedState:t}}static unselect(t,e,r){return t=pt.unselect(t,e,"items",r).updatedState,{updatedState:t}}static selectToolDrawingItem(t,e){return t=t.merge({mode:ur,drawingSupport:J({type:e})}),{updatedState:t}}static updateDrawingItem(t,e,r,i){if(t.hasIn(["drawingSupport","currentID"]))t=t.updateIn(["scene","layers",e,"items",t.getIn(["drawingSupport","currentID"])],s=>s.merge({x:r,y:i}));else{let{updatedState:s,item:o}=this.create(t,e,t.getIn(["drawingSupport","type"]),r,i,200,100,0);t=t0.select(s,e,o.id).updatedState,t=t.setIn(["drawingSupport","currentID"],o.id)}return{updatedState:t}}static endDrawingItem(t,e,r,i){return t=this.updateDrawingItem(t,e,r,i).updatedState,t=pt.unselectAll(t,e).updatedState,t=t.merge({drawingSupport:J({type:t.drawingSupport.get("type")})}),{updatedState:t}}static beginDraggingItem(t,e,r,i,s){let o=t.getIn(["scene","layers",e,"items",r]);return t=t.merge({mode:wr,draggingSupport:J({layerID:e,itemID:r,startPointX:i,startPointY:s,originalX:o.x,originalY:o.y})}),{updatedState:t}}static updateDraggingItem(t,e,r){let{draggingSupport:i,scene:s}=t,o=i.get("layerID"),a=i.get("itemID"),l=i.get("startPointX"),c=i.get("startPointY"),h=i.get("originalX"),f=i.get("originalY"),g=l-e,p=c-r,m=s.getIn(["layers",o,"items",a]);return m=m.merge({x:h-g,y:f-p}),t=t.merge({scene:s.mergeIn(["layers",o,"items",a],m)}),{updatedState:t}}static endDraggingItem(t,e,r){return t=this.updateDraggingItem(t,e,r).updatedState,t=t.merge({mode:re}),{updatedState:t}}static beginRotatingItem(t,e,r,i,s){return t=t.merge({mode:cn,rotatingSupport:J({layerID:e,itemID:r})}),{updatedState:t}}static updateRotatingItem(t,e,r){let{rotatingSupport:i,scene:s}=t,o=i.get("layerID"),a=i.get("itemID"),l=t.getIn(["scene","layers",o,"items",a]),c=e-l.x,h=r-l.y,f=Math.atan2(h,c)*180/Math.PI-90;return-5<f&&f<5&&(f=0),-95<f&&f<-85&&(f=-90),-185<f&&f<-175&&(f=-180),85<f&&f<90&&(f=90),-270<f&&f<-265&&(f=90),l=l.merge({rotation:f}),t=t.merge({scene:s.mergeIn(["layers",o,"items",a],l)}),{updatedState:t}}static endRotatingItem(t,e,r){return t=this.updateRotatingItem(t,e,r).updatedState,t=t.merge({mode:re}),{updatedState:t}}static setProperties(t,e,r,i){return t=t.mergeIn(["scene","layers",e,"items",r,"properties"],i),{updatedState:t}}static setJsProperties(t,e,r,i){return this.setProperties(t,e,r,Bt(i))}static updateProperties(t,e,r,i){return i.forEach((s,o)=>{t.hasIn(["scene","layers",e,"items",r,"properties",o])&&(t=t.mergeIn(["scene","layers",e,"items",r,"properties",o],s))}),{updatedState:t}}static updateJsProperties(t,e,r,i){return this.updateProperties(t,e,r,Bt(i))}static setAttributes(t,e,r,i){return t=t.mergeIn(["scene","layers",e,"items",r],i),{updatedState:t}}static setJsAttributes(t,e,r,i){return i=Bt(i),this.setAttributes(t,e,r,i)}},ce=class du{static select(t,e){let r=t.getIn(["scene","groups",e,"elements"]);t=qt.setAlterate(t).updatedState,r.entrySeq().forEach(([s,o])=>{t=pt.unselectAll(t,s).updatedState;let a=o.get("lines"),l=o.get("holes"),c=o.get("items"),h=o.get("areas");a&&a.forEach(f=>{t=xe.select(t,s,f).updatedState}),l&&l.forEach(f=>{t=le.select(t,s,f).updatedState}),c&&c.forEach(f=>{t=pe.select(t,s,f).updatedState}),h&&h.forEach(f=>{t=ti.select(t,s,f).updatedState})}),t=qt.setAlterate(t).updatedState;let i=t.getIn(["scene","groups"]).map(s=>s.set("selected",!1));return t=t.setIn(["scene","groups"],i).setIn(["scene","groups",e,"selected"],!0),{updatedState:t}}static unselect(t,e){return t=t.getIn(["scene","groups",e,"elements"]).reduce((s,o,a)=>pt.unselectAll(s,a).updatedState,t).setIn(["scene","groups",e,"selected"],!1),{updatedState:t}}static create(t){let e=Xr.acquireID();return t=t.setIn(["scene","groups",e],new wl({id:e,name:e})),{updatedState:t}}static createFromSelectedElements(t){let e=Xr.acquireID();return t=t.setIn(["scene","groups",e],new wl({id:e,name:e})),t.getIn(["scene","layers"]).forEach(r=>{let i=r.get("id"),s={lines:r.get("lines").filter(o=>o.get("selected")),items:r.get("items").filter(o=>o.get("selected")),holes:r.get("holes").filter(o=>o.get("selected")),areas:r.get("areas").filter(o=>o.get("selected"))};for(let o in s)s[o].forEach(a=>t=this.addElement(t,e,i,o,a.get("id")).updatedState)}),{updatedState:t}}static addElement(t,e,r,i,s){let o=t.getIn(["scene","groups",e,"elements",r,i])||st();return o.contains(s)||(t=t.setIn(["scene","groups",e,"elements",r,i],o.push(s)),t=this.reloadBaricenter(t,e).updatedState),{updatedState:t}}static setBarycenter(t,e,r,i){return typeof r<"u"&&(t=t.setIn(["scene","groups",e,"x"],r)),typeof i<"u"&&(t=t.setIn(["scene","groups",e,"y"],i)),{updatedState:t}}static reloadBaricenter(t,e){let r=t.getIn(["scene","groups",e,"elements"]),i=0,s=0,o=0;return r.entrySeq().forEach(([a,l])=>{t=pt.unselectAll(t,a).updatedState;let c=l.get("lines"),h=l.get("holes"),f=l.get("items"),g=l.get("areas");c&&c.forEach(p=>{let m=t.getIn(["scene","layers",a,"lines",p,"vertices"]).map(M=>t.getIn(["scene","layers",a,"vertices",M])),{x:v,y:_}=m.get(0),{x:S,y:A}=m.get(1),{x:C,y:O}=yv(v,_,S,A);i+=C,s+=O,o++}),h&&h.forEach(p=>{let m=t.getIn(["scene","layers",a,"holes",p]),v=t.getIn(["scene","layers",a,"lines",m.line,"vertices"]).map(z=>t.getIn(["scene","layers",a,"vertices",z])),{x:_,y:S}=v.get(0),{x:A,y:C}=v.get(1),{x:O,y:M}=Qo(_,S,A,C,m.offset*Oe(_,S,A,C));i+=O,s+=M,o++}),f&&f.forEach(p=>{let{x:m,y:v}=t.getIn(["scene","layers",a,"items",p]);i+=m,s+=v,o++}),g&&g.forEach(p=>{let m=t.getIn(["scene","layers",a,"areas",p,"vertices"]).map(S=>t.getIn(["scene","layers",a,"vertices",S])).toJS(),{x:v,y:_}=vv(m);i+=v,s+=_,o++})}),o&&(t=this.setBarycenter(t,e,i/o,s/o).updatedState),{updatedState:t}}static removeElement(t,e,r,i,s){let o=t.getIn(["scene","groups",e,"elements",r,i]);return!o||!o.contains(s)?{updatedState:t}:(t=t.setIn(["scene","groups",e,"elements",r,i],o.filterNot(a=>a===s)),{updatedState:t})}static setAttributes(t,e,r){return t=t.mergeIn(["scene","groups",e],r),{updatedState:t}}static setProperties(t,e,r){return t=t.mergeIn(["scene","groups",e,"properties"],r),{updatedState:t}}static remove(t,e){return t=t.removeIn(["scene","groups",e]),{updatedState:t}}static removeAndDeleteElements(t,e){return t.getIn(["scene","groups",e,"elements"]).entrySeq().forEach(([i,s])=>{t=pt.unselectAll(t,i).updatedState;let o=s.get("lines"),a=s.get("holes"),l=s.get("items");s.get("areas"),o&&o.forEach(c=>{t=xe.remove(t,i,c).updatedState,t=pt.detectAndUpdateAreas(t,i).updatedState}),a&&a.forEach(c=>{t=le.remove(t,i,c).updatedState}),l&&l.forEach(c=>{t=pe.remove(t,i,c).updatedState})}),t=t.deleteIn(["scene","groups",e]),{updatedState:t}}static translate(t,e,r,i){let s=r-t.getIn(["scene","groups",e,"x"]),o=i-t.getIn(["scene","groups",e,"y"]);return t.getIn(["scene","groups",e,"elements"]).entrySeq().forEach(([l,c])=>{let h=c.get("lines"),f=c.get("items");if(h){let g={};h.forEach(p=>{let m=t.getIn(["scene","layers",l,"lines",p]);g[m.vertices.get(0)]||(g[m.vertices.get(0)]=t.getIn(["scene","layers",l,"vertices",m.vertices.get(0)])),g[m.vertices.get(1)]||(g[m.vertices.get(1)]=t.getIn(["scene","layers",l,"vertices",m.vertices.get(1)]))});for(let p in g){let{x:m,y:v}=g[p];t=ie.setAttributes(t,l,p,J({x:m+s,y:v+o})).updatedState}for(let p in g)t=ie.beginDraggingVertex(t,l,p).updatedState,t=ie.endDraggingVertex(t).updatedState}f&&(t=f.map(g=>t.getIn(["scene","layers",l,"items",g])).reduce((g,p)=>{let{x:m,y:v}=p;return pe.setAttributes(g,l,p.id,J({x:m+s,y:v+o})).updatedState},t)),t=pt.detectAndUpdateAreas(t,l).updatedState}),t=this.setBarycenter(t,e,r,i).updatedState,t=du.select(t,e).updatedState,{updatedState:t}}static rotate(t,e,r){let{x:i,y:s,rotation:o}=t.getIn(["scene","groups",e]),a=r-o;return t=du.setAttributes(t,e,J({rotation:r})).updatedState,t.getIn(["scene","groups",e,"elements"]).entrySeq().forEach(([c,h])=>{let f=h.get("lines"),g=h.get("items");if(f){let p={};f.forEach(m=>{let v=t.getIn(["scene","layers",c,"lines",m]);p[v.vertices.get(0)]||(p[v.vertices.get(0)]=t.getIn(["scene","layers",c,"vertices",v.vertices.get(0)])),p[v.vertices.get(1)]||(p[v.vertices.get(1)]=t.getIn(["scene","layers",c,"vertices",v.vertices.get(1)]))});for(let m in p){let{x:v,y:_}=p[m],{x:S,y:A}=ad(v,_,i,s,a);t=ie.setAttributes(t,c,m,J({x:S,y:A})).updatedState}for(let m in p)t=ie.beginDraggingVertex(t,c,m).updatedState,t=ie.endDraggingVertex(t).updatedState}g&&(t=g.map(p=>t.getIn(["scene","layers",c,"items",p])).reduce((p,m)=>{let{x:v,y:_,rotation:S}=m,{x:A,y:C}=ad(v,_,i,s,a);return pe.setAttributes(p,c,m.id,J({x:A,y:C,rotation:S+a})).updatedState},t)),t=pt.detectAndUpdateAreas(t,c).updatedState}),t=du.select(t,e).updatedState,{updatedState:t}}},xe=class yr{static create(t,e,r,i,s,o,a,l){let c=Xr.acquireID(),{updatedState:h,vertex:f}=ie.add(t,e,i,s,"lines",c),{updatedState:g,vertex:p}=ie.add(h,e,o,a,"lines",c);t=g;let m=t.catalog.factoryElement(r,{id:c,name:oa.generateName("lines",t.catalog.getIn(["elements",r,"info","title"])),vertices:st([f.id,p.id]),type:r},l);return t=t.setIn(["scene","layers",e,"lines",c],m),{updatedState:t,line:m}}static select(t,e,r){t=pt.select(t,e).updatedState;let i=t.getIn(["scene","layers",e,"lines",r]);return t=pt.selectElement(t,e,"lines",r).updatedState,t=pt.selectElement(t,e,"vertices",i.vertices.get(0)).updatedState,t=pt.selectElement(t,e,"vertices",i.vertices.get(1)).updatedState,{updatedState:t}}static remove(t,e,r){let i=t.getIn(["scene","layers",e,"lines",r]);return i&&(t=this.unselect(t,e,r).updatedState,i.holes.forEach(s=>t=le.remove(t,e,s).updatedState),t=pt.removeElement(t,e,"lines",r).updatedState,i.vertices.forEach(s=>t=ie.remove(t,e,s,"lines",r).updatedState),t.getIn(["scene","groups"]).forEach(s=>t=ce.removeElement(t,s.id,e,"lines",r).updatedState)),{updatedState:t}}static unselect(t,e,r){let i=t.getIn(["scene","layers",e,"lines",r]);return i&&(t=pt.unselect(t,e,"vertices",i.vertices.get(0)).updatedState,t=pt.unselect(t,e,"vertices",i.vertices.get(1)).updatedState,t=pt.unselect(t,e,"lines",r).updatedState),{updatedState:t}}static split(t,e,r,i,s){let o=t.getIn(["scene","layers",e,"lines",r]),a=t.getIn(["scene","layers",e,"vertices",o.vertices.get(0)]),l=t.getIn(["scene","layers",e,"vertices",o.vertices.get(1)]),{x:c,y:h}=a,{x:f,y:g}=l,{updatedState:p,line:m}=yr.create(t,e,o.type,c,h,i,s,o.get("properties")),{updatedState:v,line:_}=yr.create(p,e,o.type,f,g,i,s,o.get("properties"));t=v;let S=ze(c,h,f,g,i,s),A=Xo(a,l);return o.holes.forEach(O=>{let M=t.getIn(["scene","layers",e,"holes",O]),z=M.offset;if(A.x===f&&A.y===g&&(S=1-S,z=1-M.offset),z<S){let R=z/S;A.x===f&&A.y===g&&(R=1-R),t=le.create(t,e,M.type,m.id,R,M.properties).updatedState}else{let R=(z-S)/(1-S);A.x===f&&A.y===g&&(R=1-R),t=le.create(t,e,M.type,_.id,R,M.properties).updatedState}}),t.getIn(["scene","groups"]).filter(O=>{const M=O.getIn(["elements",e,"lines"]);return M&&M.contains(r)}).forEach(O=>{t=ce.addElement(t,O.id,e,"lines",m.id).updatedState,t=ce.addElement(t,O.id,e,"lines",_.id).updatedState}),t=yr.remove(t,e,r).updatedState,{updatedState:t,lines:st([m,_])}}static addFromPoints(t,e,r,i,s,o){i=st(i).sort(({x:c,y:h},{x:f,y:g})=>c===f?h-g:c-f);let a=i.zip(i.skip(1)).filterNot(([{x:c,y:h},{x:f,y:g}])=>c===f&&h===g),l=[];return a.forEach(([{x:c,y:h},{x:f,y:g}])=>{let{updatedState:p,line:m}=this.create(t,e,r,c,h,f,g,s);t=p,o&&o.forEach(v=>{let{x:_,y:S}=v.offsetPosition;if(lv(c,h,f,g,_,S)){let A=ze(c,h,f,g,_,S);A>=0&&A<=1&&(t=le.create(t,e,v.hole.type,m.id,A,v.hole.properties).updatedState)}}),l.push(m)}),{updatedState:t,lines:st(l)}}static createAvoidingIntersections(t,e,r,i,s,o,a,l,c){let h=[{x:i,y:s},{x:o,y:a}];t=t.getIn(["scene","layers",e,"lines"]).reduce((p,m)=>{var C,O;let[v,_]=m.vertices.map(M=>p.getIn(["scene","layers",e,"vertices"]).get(M)).toArray(),S=Mr(v,h[0])||Mr(v,h[1])||Mr(_,h[0])||Mr(_,h[1]),A=uv(h[0],h[1],v,_);if(A.type==="colinear"){c||(c=[]);const M=Us(h);p.getIn(["scene","layers",e,"lines",m.id,"holes"]).forEach(z=>{let R=p.getIn(["scene","layers",e,"holes",z]),I=Oe(v.x,v.y,_.x,_.y),L=Mr(M[1],m.vertices.get(1))?1-R.offset:R.offset,Y=Qo(v.x,v.y,_.x,_.y,I*L);c.push({hole:R,offsetPosition:Y})}),p=this.remove(p,e,m.id).updatedState,h.push(v,_)}return A.type==="intersecting"&&!S&&(p=this.split(p,e,m.id,((C=A.point)==null?void 0:C.x)??0,((O=A.point)==null?void 0:O.y)??0).updatedState,h.push(A.point??{x:0,y:0})),p},t);let{updatedState:f,lines:g}=yr.addFromPoints(t,e,r,h,l,c);return{updatedState:f,lines:g}}static replaceVertex(t,e,r,i,s,o){let a=t.getIn(["scene","layers",e,"lines",r,"vertices",i]);t=ie.remove(t,e,a,"lines",r).updatedState;let{updatedState:l,vertex:c}=ie.add(t,e,s,o,"lines",r);return t=l,t=t.setIn(["scene","layers",e,"lines",r,"vertices",i],c.id),t=t.setIn(["scene","layers",e,"lines",r],t.getIn(["scene","layers",e,"lines",r])),{updatedState:t,line:t.getIn(["scene","layers",e,"lines",r]),vertex:c}}static selectToolDrawingLine(t,e){return t=t.merge({mode:xr,drawingSupport:J({type:e})}),{updatedState:t}}static beginDrawingLine(t,e,r,i){let s=Ml(t.scene,st(),t.snapMask),o=null;t.snapMask&&!t.snapMask.isEmpty()&&(o=Yr(s,r,i,t.snapMask),o&&({x:r,y:i}=o.point),s=s.withMutations(h=>{let f,g,p;({a:f,b:g,c:p}=Zo(i)),ta(h,f,g,p,10,3,null),{a:f,b:g,c:p}=Ko(r),ta(h,f,g,p,10,3,null)}));let a=t.get("drawingSupport").set("layerID",e);t=pt.unselectAll(t,e).updatedState;let{updatedState:l,line:c}=yr.create(t,e,a.get("type"),r,i,r,i);return t=yr.select(l,e,c.id).updatedState,t=t.merge({mode:We,snapElements:s,activeSnapElement:o?o.snap:null,drawingSupport:a}),{updatedState:t}}static updateDrawingLine(t,e,r){let i=null;t.snapMask&&!t.snapMask.isEmpty()&&(i=Yr(t.snapElements,e,r,t.snapMask),i&&({x:e,y:r}=i.point));let s=t.getIn(["drawingSupport","layerID"]),o=t.getIn(["scene","layers",s,"selected","lines"]).first(),{updatedState:a}=yr.replaceVertex(t,s,o,1,e,r);return t=a,t=this.select(t,s,o).updatedState,t=t.merge({activeSnapElement:i?i.snap:null}),{updatedState:t}}static endDrawingLine(t,e,r){if(t.snapMask&&!t.snapMask.isEmpty()){let c=Yr(t.snapElements,e,r,t.snapMask);c&&({x:e,y:r}=c.point)}const i=t.getIn(["drawingSupport","layerID"]),s=t.getIn(["scene","layers",i]),o=t.getIn(["scene","layers",i,"selected","lines"]).first(),a=t.getIn(["scene","layers",i,"lines",o]),l=s.vertices.get(a.vertices.get(0));return t=yr.remove(t,i,o).updatedState,t=yr.createAvoidingIntersections(t,i,a.type,l.x,l.y,e,r).updatedState,t=pt.detectAndUpdateAreas(t,i).updatedState,t=t.merge({mode:xr,snapElements:st(),activeSnapElement:null}),{updatedState:t}}static beginDraggingLine(t,e,r,i,s){let o=Ml(t.scene,st(),t.snapMask),a=t.scene.layers.get(e),l=a.lines.get(r),c=a.vertices.get(l.vertices.get(0)),h=a.vertices.get(l.vertices.get(1));return t=t.merge({mode:_r,snapElements:o,draggingSupport:J({layerID:e,lineID:r,startPointX:i,startPointY:s,startVertex0X:c.x,startVertex0Y:c.y,startVertex1X:h.x,startVertex1Y:h.y})}),{updatedState:t}}static updateDraggingLine(t,e,r){let i=t.draggingSupport,s=t.snapElements,o=i.get("layerID"),a=i.get("lineID"),l=e-i.get("startPointX"),c=r-i.get("startPointY"),h=i.get("startVertex0X")+l,f=i.get("startVertex0Y")+c,g=i.get("startVertex1X")+l,p=i.get("startVertex1Y")+c,m=null,v=null,_=null;t.snapMask&&!t.snapMask.isEmpty()&&(v=Yr(s,h,f,t.snapMask),_=Yr(s,g,p,t.snapMask));let S=0,A=0;return v&&_?v.point.distance<_.point.distance?(S=v.point.x-h,A=v.point.y-f,m=v.snap):(S=_.point.x-g,A=_.point.y-p,m=_.snap):(v&&(S=v.point.x-h,A=v.point.y-f,m=v.snap),_&&(S=_.point.x-g,A=_.point.y-p,m=_.snap)),h+=S,f+=A,g+=S,p+=A,t=t.merge({activeSnapElement:m,scene:t.scene.updateIn(["layers",o],C=>C.withMutations(O=>{let M=O.getIn(["lines",a,"vertices"]);return O.updateIn(["vertices",M.get(0)],z=>z.merge({x:h,y:f})),O.updateIn(["vertices",M.get(1)],z=>z.merge({x:g,y:p})),O}))}),{updatedState:t}}static endDraggingLine(t,e,r){let{draggingSupport:i}=t,s=i.get("layerID"),o=t.scene.layers.get(s),a=i.get("lineID"),l=o.lines.get(a),c=o.vertices.get(l.vertices.get(0)),h=o.vertices.get(l.vertices.get(1)),f=dl(c,h),g=Xo(c,h),p=Jo(g,f),m=Math.atan2(f.y-g.y,f.x-g.x),v=[];o.lines.get(a).holes.forEach(R=>{let I=o.holes.get(R),L=p*I.offset,Y={x:L*Math.cos(m)+g.x,y:L*Math.sin(m)+g.y};v.push({hole:I,offsetPosition:Y})});let _=e-i.get("startPointX"),S=r-i.get("startPointY"),A=i.get("startVertex0X")+_,C=i.get("startVertex0Y")+S,O=i.get("startVertex1X")+_,M=i.get("startVertex1Y")+S;if(t.snapMask&&!t.snapMask.isEmpty()){let R=Yr(t.snapElements,A,C,t.snapMask),I=Yr(t.snapElements,O,M,t.snapMask),L=0,Y=0;R&&I?R.point.distance<I.point.distance?(L=R.point.x-A,Y=R.point.y-C):(L=I.point.x-O,Y=I.point.y-M):(R&&(L=R.point.x-A,Y=R.point.y-C),I&&(L=I.point.x-O,Y=I.point.y-M)),A+=L,C+=Y,O+=L,M+=Y}let z=t.getIn(["scene","groups"]).filter(R=>{const I=R.getIn(["elements",s,"lines"]);return I&&I.contains(a)});if(t=pt.mergeEqualsVertices(t,s,l.vertices.get(0)).updatedState,t=pt.mergeEqualsVertices(t,s,l.vertices.get(1)).updatedState,t=yr.remove(t,s,a).updatedState,!Mr({x:A,y:C},{x:O,y:M})){let R=yr.createAvoidingIntersections(t,s,l.type,A,C,O,M,l.properties,v);t=R.updatedState,R.lines.forEach(I=>{z.forEach(L=>{t=ce.addElement(t,L.id,s,"lines",I.id).updatedState})})}return t=pt.detectAndUpdateAreas(t,s).updatedState,t=t.merge({mode:re,draggingSupport:null,activeSnapElement:null,snapElements:st()}),{updatedState:t}}static setProperties(t,e,r,i){return t=t.mergeIn(["scene","layers",e,"lines",r,"properties"],i),{updatedState:t}}static setJsProperties(t,e,r,i){return this.setProperties(t,e,r,Bt(i))}static updateProperties(t,e,r,i){return i.forEach((s,o)=>{t.hasIn(["scene","layers",e,"lines",r,"properties",o])&&(t=t.mergeIn(["scene","layers",e,"lines",r,"properties",o],s))}),{updatedState:t}}static updateJsProperties(t,e,r,i){return this.updateProperties(t,e,r,Bt(i))}static setAttributes(t,e,r,i){let s=i.toJS(),{vertexOne:o,vertexTwo:a,lineLength:l}=s;return delete s.vertexOne,delete s.vertexTwo,delete s.lineLength,t=t.mergeIn(["scene","layers",e,"lines",r],Bt(s)).mergeIn(["scene","layers",e,"vertices",o.id],{x:o.x,y:o.y}).mergeIn(["scene","layers",e,"vertices",a.id],{x:a.x,y:a.y}).mergeIn(["scene","layers",e,"lines",r,"misc"],J({_unitLength:l._unit})),t=pt.mergeEqualsVertices(t,e,o.id).updatedState,o.x!=a.x&&o.y!=a.y&&(t=pt.mergeEqualsVertices(t,e,a.id).updatedState),t=pt.detectAndUpdateAreas(t,e).updatedState,{updatedState:t}}static setVerticesCoords(t,e,r,i,s,o,a){let l=t.getIn(["scene","layers",e,"lines",r]);return t=ie.setAttributes(t,e,l.vertices.get(0),J({x:i,y:s})).updatedState,t=ie.setAttributes(t,e,l.vertices.get(1),J({x:o,y:a})).updatedState,{updatedState:t}}},ie=class{static add(t,e,r,i,s,o){let a=t.getIn(["scene","layers",e,"vertices"]).find(l=>Mr(l,{x:r,y:i}));return a?a=a.update(s,l=>l.push(o)):a=new cd({id:Xr.acquireID(),name:"Vertex",x:r,y:i,[s]:st([o])}),t=t.setIn(["scene","layers",e,"vertices",a.id],a),{updatedState:t,vertex:a}}static setAttributes(t,e,r,i){return t=t.mergeIn(["scene","layers",e,"vertices",r],i),{updatedState:t}}static addElement(t,e,r,i,s){return t=t.updateIn(["scene","layers",e,"vertices",r,i],o=>o.push(s)),{updatedState:t}}static removeElement(t,e,r,i,s){let o=t.getIn(["scene","layers",e,"vertices",r,i]).findIndex(a=>a===s);return o!==-1&&(t=t.updateIn(["scene","layers",e,"vertices",r,i],a=>a.remove(o))),{updatedState:t}}static select(t,e,r){return t=t.setIn(["scene","layers",e,"vertices",r,"selected"],!0),t=t.updateIn(["scene","layers",e,"selected","vertices"],i=>i.push(r)),{updatedState:t}}static unselect(t,e,r){return t=t.setIn(["scene","layers",e,"vertices",r,"selected"],!1),t=t.updateIn(["scene","layers",e,"selected","vertices"],i=>i.filter(s=>s.id!==r)),{updatedState:t}}static remove(t,e,r,i,s,o){let a=t.getIn(["scene","layers",e,"vertices",r]);return a&&(i&&s&&(a=a.update(i,c=>{let h=c.findIndex(f=>s===f);return c.delete(h)})),(a.areas.size||a.lines.size)&&!o?t=t.setIn(["scene","layers",e,"vertices",r],a):t=t.deleteIn(["scene","layers",e,"vertices",r])),{updatedState:t}}static beginDraggingVertex(t,e,r){let i=Ml(t.scene,st(),t.snapMask);return t=t.merge({mode:br,snapElements:i,draggingSupport:J({layerID:e,vertexID:r,previousMode:t.get("mode")})}),{updatedState:t}}static updateDraggingVertex(t,e,r){let{draggingSupport:i,snapElements:s,scene:o}=t,a=null;t.snapMask&&!t.snapMask.isEmpty()&&(a=Yr(s,e,r,t.snapMask),a&&({x:e,y:r}=a.point));let l=i.get("layerID"),c=i.get("vertexID");return t=t.merge({activeSnapElement:a?a.snap:null,scene:o.mergeIn(["layers",l,"vertices",c],{x:e,y:r})}),{updatedState:t}}static endDraggingVertex(t){let{draggingSupport:e}=t,r=e.get("layerID"),i=e.get("vertexID"),s=t.getIn(["scene","layers",r,"vertices",i,"lines"]);return s&&(t=s.reduce((o,a)=>{if(!o.getIn(["scene","layers",r,"lines",a]))return o;let l=o.getIn(["scene","layers",r,"lines",a,"vertices",0]),c=o.getIn(["scene","layers",r,"lines",a,"vertices",1]),h=l===i?c:l,f=o.getIn(["scene","layers",r,"vertices",h]),g=o.getIn(["scene","layers",r,"vertices",i]),p=[],m=Us([f,g]);o.getIn(["scene","layers",r,"lines",a,"holes"]).forEach(A=>{let C=o.getIn(["scene","layers",r,"holes",A]),O=Oe(f.x,f.y,g.x,g.y),M=Mr(m[1],o.getIn(["scene","layers",r,"lines",a,"vertices",1]))?1-C.offset:C.offset,z=Qo(f.x,f.y,g.x,g.y,O*M);p.push({hole:C,offsetPosition:z})});let v=o.getIn(["scene","layers",r,"lines",a,"type"]),_=o.getIn(["scene","layers",r,"lines",a,"properties"]),S=o.getIn(["scene","groups"]).filter(A=>{const C=A.getIn(["elements",r,"lines"]);return C&&C.contains(a)});if(o=pt.removeZeroLengthLines(o,r).updatedState,o=pt.mergeEqualsVertices(o,r,i).updatedState,o=xe.remove(o,r,a).updatedState,!Mr(f,g)){let A=xe.createAvoidingIntersections(o,r,v,f.x,f.y,g.x,g.y,_,p);o=A.updatedState,A.lines.forEach(C=>{S.forEach(O=>{o=ce.addElement(o,O.id,r,"lines",C.id).updatedState})})}return o},t)),t=pt.detectAndUpdateAreas(t,r).updatedState,t=t.merge({mode:e.get("previousMode"),draggingSupport:null,activeSnapElement:null,snapElements:st()}),{updatedState:t}}},ti=class{static add(t,e,r,i,s){let o,a=t.getIn(["scene","layers",e]);return a=a.withMutations(l=>{const c=Xr.acquireID(),h=i.map(f=>ie.add(t,e,f.x,f.y,"areas",c).vertex.id);o=s.factoryElement(r,{id:c,name:oa.generateName("areas",s.getIn(["elements",r,"info","title"])),type:r,prototype:"areas",vertices:h}),l.setIn(["areas",c],o)}),t=t.setIn(["scene","layers",e],a),{updatedState:t,area:o}}static select(t,e,r){return t=pt.select(t,e).updatedState,t=pt.selectElement(t,e,"areas",r).updatedState,{updatedState:t}}static remove(t,e,r){let i=t.getIn(["scene","layers",e,"areas",r]);return i.get("selected")===!0&&(t=this.unselect(t,e,r).updatedState),i.vertices.forEach(s=>{t=ie.remove(t,e,s,"areas",r).updatedState}),t=t.deleteIn(["scene","layers",e,"areas",r]),t.getIn(["scene","groups"]).forEach(s=>t=ce.removeElement(t,s.id,e,"areas",r).updatedState),{updatedState:t}}static unselect(t,e,r){return t=pt.unselect(t,e,"areas",r).updatedState,{updatedState:t}}static setProperties(t,e,r,i){return t=t.mergeIn(["scene","layers",e,"areas",r,"properties"],i),{updatedState:t}}static setJsProperties(t,e,r,i){return this.setProperties(t,e,r,Bt(i))}static updateProperties(t,e,r,i){return i.forEach((s,o)=>{t.hasIn(["scene","layers",e,"areas",r,"properties",o])&&(t=t.mergeIn(["scene","layers",e,"areas",r,"properties",o],s))}),{updatedState:t}}static updateJsProperties(t,e,r,i){return this.updateProperties(t,e,r,Bt(i))}static setAttributes(t){return{updatedState:t}}};const Bd=(n,t)=>n.size===t.size&&n.isSuperset(t)&&n.isSubset(t);let pt=class{static create(t,e,r){let i=Xr.acquireID();e=e||`layer ${i}`,r=r||0;let s=new bl({id:i,name:e,altitude:r});return t=t.setIn(["scene","selectedLayer"],i),t=t.setIn(["scene","layers",i],s),{updatedState:t}}static select(t,e){return t.get("alterate")||(t=qt.unselectAll(t).updatedState),t=t.setIn(["scene","selectedLayer"],e),{updatedState:t}}static selectElement(t,e,r,i){return t=t.setIn(["scene","layers",e,r,i,"selected"],!0),t=t.updateIn(["scene","layers",e,"selected",r],s=>s.push(i)),{updatedState:t}}static unselect(t,e,r,i){return t=t.setIn(["scene","layers",e,r,i,"selected"],!1),t=t.updateIn(["scene","layers",e,"selected",r],s=>s.filter(o=>o.id===i)),{updatedState:t}}static unselectAll(t,e){let{lines:r,holes:i,items:s,areas:o}=t.getIn(["scene","layers",e]);return r&&r.forEach(a=>{t=xe.unselect(t,e,a.id).updatedState}),i&&i.forEach(a=>{t=le.unselect(t,e,a.id).updatedState}),s&&s.forEach(a=>{t=pe.unselect(t,e,a.id).updatedState}),o&&o.forEach(a=>{t=ti.unselect(t,e,a.id).updatedState}),{updatedState:t}}static setProperties(t,e,r){return t=t.mergeIn(["scene","layers",e],r),t=t.updateIn(["scene","layers"],i=>i.sort((s,o)=>s.altitude!==o.altitude?s.altitude-o.altitude:s.order-o.order)),{updatedState:t}}static remove(t,e){return t=t.removeIn(["scene","layers",e]),t=t.setIn(["scene","selectedLayer"],t.scene.selectedLayer!==e?t.scene.selectedLayer:t.scene.layers.first().id),{updatedState:t}}static removeElement(t,e,r,i){return t=t.deleteIn(["scene","layers",e,r,i]),{updatedState:t}}static detectAndUpdateAreas(t,e){let r=[],i,s={},o={};t.getIn(["scene","layers",e,"vertices"]).forEach(p=>{let v=r.push([p.x,p.y])-1;s[p.id]=v,o[v]=p.id}),i=t.getIn(["scene","layers",e,"lines"]).map(p=>p.vertices.map(m=>s[m]).toArray());const a=jv(r,i);let l=st(a).map(p=>st(p.map(m=>o[m])));l=l.map(p=>Vv(p.map(m=>t.getIn(["scene","layers",e,"vertices",m])))?p.reverse():p);const c=[];t.getIn(["scene","layers",e,"areas"]).forEach(p=>{l.some(v=>Bd(v,p.vertices))||(t=ti.remove(t,e,p.id).updatedState)}),l.forEach((p,m)=>{const v=t.getIn(["scene","layers",e,"areas"]).find(_=>Bd(_.vertices,p));if(v)c[m]=v.id,t=t.setIn(["scene","layers",e,"areas",c[m],"holes"],st());else{const _=p.map(A=>t.getIn(["scene","layers",e,"vertices",A])),S=ti.add(t,e,"area",_,t.catalog);c[m]=S.area.id,t=S.updatedState}});let h=c.map(p=>{let m=t.getIn(["scene","layers",e,"areas",p]).vertices.map(v=>{let{x:_,y:S}=t.getIn(["scene","layers",e,"vertices",v]);return st([_,S])});return{id:p,vertices:m}}),f,g;for(f=0;f<h.length;f++){let p=st(),m=h[f].vertices.flatten().toArray();for(g=0;g<h.length;g++)f!==g&&pv(m,h[g].vertices.get(0).get(0),h[g].vertices.get(0).get(1))&&(p=p.push(h[g].id));t=t.setIn(["scene","layers",e,"areas",h[f].id,"holes"],p)}return c.forEach(p=>{let m=new Set,v=t.getIn(["scene","layers",e,"areas",p,"holes"]);v.forEach(_=>{t.getIn(["scene","layers",e,"areas",_,"holes"]).forEach(A=>{v.indexOf(A)!==-1&&m.add(A)})}),m.forEach(_=>{v=v.remove(v.indexOf(_))}),t=t.setIn(["scene","layers",e,"areas",p,"holes"],v)}),{updatedState:t}}static removeZeroLengthLines(t,e){return{updatedState:t.getIn(["scene","layers",e,"lines"]).reduce((i,s)=>{let o=s.getIn(["vertices",0]),a=s.getIn(["vertices",1]),l=i.getIn(["scene","layers",e,"vertices",o]),c=i.getIn(["scene","layers",e,"vertices",a]);return Jo(l,c)===0&&(i=xe.remove(i,e,s.id).updatedState),i},t)}}static mergeEqualsVertices(t,e,r){let i=t.getIn(["scene","layers",e,"vertices",r]),s=t.getIn(["scene","layers",e,"vertices"]).filter(o=>o.id!==r&&Mr(i,o));return s.isEmpty()?{updatedState:t}:(s.forEach(o=>{let a=o.lines.reduce((c,h)=>(c=c.updateIn(["scene","layers",e,"lines",h,"vertices"],f=>{if(f)return f.map(g=>g===o.id?r:g)}),c=ie.addElement(c,e,r,"lines",h).updatedState,c),t),l=o.areas.reduce((c,h)=>(c=c.updateIn(["scene","layers",e,"areas",h,"vertices"],f=>{if(f)return f.map(g=>g===o.id?r:g)}),c=ie.addElement(c,e,r,"areas",h).updatedState,c),a);t=ie.remove(l,e,o.id,null,null,!0).updatedState}),{updatedState:t})}static setPropertiesOnSelected(t,e,r){let i=t.getIn(["scene","layers",e,"selected"]);return i.lines.forEach(s=>t=xe.setProperties(t,e,s,r).updatedState),i.holes.forEach(s=>t=le.setProperties(t,e,s,r).updatedState),i.areas.forEach(s=>t=ti.setProperties(t,e,s,r).updatedState),i.items.forEach(s=>t=pe.setProperties(t,e,s,r).updatedState),{updatedState:t}}static updatePropertiesOnSelected(t,e,r){let i=t.getIn(["scene","layers",e,"selected"]);return i.lines.forEach(s=>t=xe.updateProperties(t,e,s,r).updatedState),i.holes.forEach(s=>t=le.updateProperties(t,e,s,r).updatedState),i.areas.forEach(s=>t=ti.updateProperties(t,e,s,r).updatedState),i.items.forEach(s=>t=pe.updateProperties(t,e,s,r).updatedState),{updatedState:t}}static setAttributesOnSelected(t,e,r){let i=t.getIn(["scene","layers",e,"selected"]);return i.lines.forEach(s=>t=xe.setAttributes(t,e,s,r).updatedState),i.holes.forEach(s=>t=le.setAttributes(t,e,s,r).updatedState),i.items.forEach(s=>t=pe.setAttributes(t,e,s,r).updatedState),{updatedState:t}}};class aa{static create(t,e){let r=Xr.acquireID();return t=t.setIn(["scene","guides","horizontal",r],e),{updatedState:t}}static remove(t,e){return t=t.deleteIn(["scene","guides","horizontal",e]),{updatedState:t}}}class ua{static create(t,e){let r=Xr.acquireID();return t=t.setIn(["scene","guides","vertical",r],e),{updatedState:t}}static remove(t,e){return t=t.deleteIn(["scene","guides","vertical",e]),{updatedState:t}}}class qt{static setAlterate(t){return{updatedState:t.set("alterate",!t.alterate)}}static openCatalog(t){return t=this.setMode(t,cl).updatedState,{updatedState:t}}static newProject(t){return t=new ra({viewer2D:t.get("viewer2D")}),{updatedState:t}}static loadProject(t,e){return t=new ra({scene:e,catalog:t.catalog.toJS()}),{updatedState:t}}static setProperties(t,e,r){return t=pt.setPropertiesOnSelected(t,e,r).updatedState,{updatedState:t}}static updateProperties(t,e,r){return t=pt.updatePropertiesOnSelected(t,e,r).updatedState,{updatedState:t}}static setItemsAttributes(t,e){return t.getIn(["scene","layers"]).forEach(r=>{t=pt.setAttributesOnSelected(t,r.id,e).updatedState}),{updatedState:t}}static setLinesAttributes(t,e){return t.getIn(["scene","layers"]).forEach(r=>{t=pt.setAttributesOnSelected(t,r.id,e).updatedState}),{updatedState:t}}static setHolesAttributes(t,e){return t.getIn(["scene","layers"]).forEach(r=>{t=pt.setAttributesOnSelected(t,r.id,e).updatedState}),{updatedState:t}}static unselectAll(t){return t.getIn(["scene","layers"]).forEach(({id:e})=>{t=pt.unselectAll(t,e).updatedState}),t.getIn(["scene","groups"]).forEach(e=>{t=ce.unselect(t,e.get("id")).updatedState}),{updatedState:t}}static remove(t){let e=t.getIn(["scene","selectedLayer"]),{lines:r,holes:i,items:s}=t.getIn(["scene","layers",e,"selected"]);return t=pt.unselectAll(t,e).updatedState,r.forEach(o=>{t=xe.remove(t,e,o).updatedState}),i.forEach(o=>{t=le.remove(t,e,o).updatedState}),s.forEach(o=>{t=pe.remove(t,e,o).updatedState}),t=pt.detectAndUpdateAreas(t,e).updatedState,{updatedState:t}}static undo(t){let e=t.sceneHistory;return t.scene===e.last&&e.list.size>1&&(e=Td(e)),t=t.merge({mode:re,scene:e.last,sceneHistory:Td(e)}),{updatedState:t}}static redo(t){let e=t.sceneHistory;return t.scene===e.last&&e.redoList.size>0&&(e=Zv(e)),t=t.merge({mode:re,scene:e.last,sceneHistory:e}),{updatedState:t}}static rollback(t){let e=t.sceneHistory;return!e.last&&e.list.isEmpty()?{updatedState:t}:(t=this.unselectAll(t).updatedState,t=t.merge({mode:re,scene:e.last,sceneHistory:ne(e,e.last),snapElements:st(),activeSnapElement:null,drawingSupport:J(),draggingSupport:J(),rotatingSupport:J()}),{updatedState:t})}static setProjectProperties(t,e){let r=t.scene.merge(e);return t=t.merge({mode:re,scene:r}),{updatedState:t}}static openProjectConfigurator(t){return t=t.merge({mode:id}),{updatedState:t}}static initCatalog(t,e){return t=t.set("catalog",new Sl(e)),{updatedState:t}}static updateMouseCoord(t,e){return t=t.set("mouse",J(e)),{updatedState:t}}static updateZoomScale(t,e){return t=t.set("zoom",e),{updatedState:t}}static toggleSnap(t,e){return t=t.set("snapMask",e),{updatedState:t}}static throwError(t,e){return t=t.set("errors",t.get("errors").push({date:Date.now(),error:e})),{updatedState:t}}static throwWarning(t,e){return t=t.set("warnings",t.get("warnings").push({date:Date.now(),warning:e})),{updatedState:t}}static copyProperties(t,e){return t=t.set("clipboardProperties",e),{updatedState:t}}static pasteProperties(t){return t=this.updateProperties(t,t.getIn(["scene","selectedLayer"]),t.get("clipboardProperties")).updatedState,{updatedState:t}}static pushLastSelectedCatalogElementToHistory(t,e){let r=t.selectedElementsHistory,i=r.findIndex(s=>s.name===e.name);return i!==-1&&(r=r.splice(i,1)),r=r.splice(0,0,e),t=t.set("selectedElementsHistory",r),{updatedState:t}}static changeCatalogPage(t,e,r){return t=t.setIn(["catalog","page"],r).updateIn(["catalog","path"],i=>i.push(e)),{updatedState:t}}static goBackToCatalogPage(t,e){let r=t.catalog.path.findIndex(i=>i===e);return t=t.setIn(["catalog","page"],e).updateIn(["catalog","path"],i=>i.take(r)),{updatedState:t}}static setMode(t,e){return t=t.set("mode",e),{updatedState:t}}static addHorizontalGuide(t,e){return t=aa.create(t,e).updatedState,{updatedState:t}}static addVerticalGuide(t,e){return t=ua.create(t,e).updatedState,{updatedState:t}}static addCircularGuide(t,e,r,i){return console.log("adding horizontal guide at",e,r,i),{updatedState:t}}static removeHorizontalGuide(t,e){return t=aa.remove(t,e).updatedState,{updatedState:t}}static removeVerticalGuide(t,e){return t=ua.remove(t,e).updatedState,{updatedState:t}}static removeCircularGuide(t,e){return console.log("removeing horizontal guide ",e),{updatedState:t}}}var la={exports:{}},ca={exports:{}},Rt={};/** @license React v16.13.1
|
|
54
46
|
* react-is.production.min.js
|
|
55
47
|
*
|
|
56
48
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
57
49
|
*
|
|
58
50
|
* This source code is licensed under the MIT license found in the
|
|
59
51
|
* LICENSE file in the root directory of this source tree.
|
|
60
|
-
*/var
|
|
52
|
+
*/var qd;function cx(){if(qd)return Rt;qd=1;var n=typeof Symbol=="function"&&Symbol.for,t=n?Symbol.for("react.element"):60103,e=n?Symbol.for("react.portal"):60106,r=n?Symbol.for("react.fragment"):60107,i=n?Symbol.for("react.strict_mode"):60108,s=n?Symbol.for("react.profiler"):60114,o=n?Symbol.for("react.provider"):60109,a=n?Symbol.for("react.context"):60110,l=n?Symbol.for("react.async_mode"):60111,c=n?Symbol.for("react.concurrent_mode"):60111,h=n?Symbol.for("react.forward_ref"):60112,f=n?Symbol.for("react.suspense"):60113,g=n?Symbol.for("react.suspense_list"):60120,p=n?Symbol.for("react.memo"):60115,m=n?Symbol.for("react.lazy"):60116,v=n?Symbol.for("react.block"):60121,_=n?Symbol.for("react.fundamental"):60117,S=n?Symbol.for("react.responder"):60118,A=n?Symbol.for("react.scope"):60119;function C(M){if(typeof M=="object"&&M!==null){var z=M.$$typeof;switch(z){case t:switch(M=M.type,M){case l:case c:case r:case s:case i:case f:return M;default:switch(M=M&&M.$$typeof,M){case a:case h:case m:case p:case o:return M;default:return z}}case e:return z}}}function O(M){return C(M)===c}return Rt.AsyncMode=l,Rt.ConcurrentMode=c,Rt.ContextConsumer=a,Rt.ContextProvider=o,Rt.Element=t,Rt.ForwardRef=h,Rt.Fragment=r,Rt.Lazy=m,Rt.Memo=p,Rt.Portal=e,Rt.Profiler=s,Rt.StrictMode=i,Rt.Suspense=f,Rt.isAsyncMode=function(M){return O(M)||C(M)===l},Rt.isConcurrentMode=O,Rt.isContextConsumer=function(M){return C(M)===a},Rt.isContextProvider=function(M){return C(M)===o},Rt.isElement=function(M){return typeof M=="object"&&M!==null&&M.$$typeof===t},Rt.isForwardRef=function(M){return C(M)===h},Rt.isFragment=function(M){return C(M)===r},Rt.isLazy=function(M){return C(M)===m},Rt.isMemo=function(M){return C(M)===p},Rt.isPortal=function(M){return C(M)===e},Rt.isProfiler=function(M){return C(M)===s},Rt.isStrictMode=function(M){return C(M)===i},Rt.isSuspense=function(M){return C(M)===f},Rt.isValidElementType=function(M){return typeof M=="string"||typeof M=="function"||M===r||M===c||M===s||M===i||M===f||M===g||typeof M=="object"&&M!==null&&(M.$$typeof===m||M.$$typeof===p||M.$$typeof===o||M.$$typeof===a||M.$$typeof===h||M.$$typeof===_||M.$$typeof===S||M.$$typeof===A||M.$$typeof===v)},Rt.typeOf=C,Rt}var Lt={};/** @license React v16.13.1
|
|
61
53
|
* react-is.development.js
|
|
62
54
|
*
|
|
63
55
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
64
56
|
*
|
|
65
57
|
* This source code is licensed under the MIT license found in the
|
|
66
58
|
* LICENSE file in the root directory of this source tree.
|
|
67
|
-
*/var
|
|
59
|
+
*/var $d;function hx(){return $d||($d=1,process.env.NODE_ENV!=="production"&&(function(){var n=typeof Symbol=="function"&&Symbol.for,t=n?Symbol.for("react.element"):60103,e=n?Symbol.for("react.portal"):60106,r=n?Symbol.for("react.fragment"):60107,i=n?Symbol.for("react.strict_mode"):60108,s=n?Symbol.for("react.profiler"):60114,o=n?Symbol.for("react.provider"):60109,a=n?Symbol.for("react.context"):60110,l=n?Symbol.for("react.async_mode"):60111,c=n?Symbol.for("react.concurrent_mode"):60111,h=n?Symbol.for("react.forward_ref"):60112,f=n?Symbol.for("react.suspense"):60113,g=n?Symbol.for("react.suspense_list"):60120,p=n?Symbol.for("react.memo"):60115,m=n?Symbol.for("react.lazy"):60116,v=n?Symbol.for("react.block"):60121,_=n?Symbol.for("react.fundamental"):60117,S=n?Symbol.for("react.responder"):60118,A=n?Symbol.for("react.scope"):60119;function C(H){return typeof H=="string"||typeof H=="function"||H===r||H===c||H===s||H===i||H===f||H===g||typeof H=="object"&&H!==null&&(H.$$typeof===m||H.$$typeof===p||H.$$typeof===o||H.$$typeof===a||H.$$typeof===h||H.$$typeof===_||H.$$typeof===S||H.$$typeof===A||H.$$typeof===v)}function O(H){if(typeof H=="object"&&H!==null){var _t=H.$$typeof;switch(_t){case t:var Ft=H.type;switch(Ft){case l:case c:case r:case s:case i:case f:return Ft;default:var Pt=Ft&&Ft.$$typeof;switch(Pt){case a:case h:case m:case p:case o:return Pt;default:return _t}}case e:return _t}}}var M=l,z=c,R=a,I=o,L=t,Y=h,X=r,it=m,rt=p,vt=e,mt=s,dt=i,ut=f,W=!1;function gt(H){return W||(W=!0,console.warn("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 17+. Update your code to use ReactIs.isConcurrentMode() instead. It has the exact same API.")),k(H)||O(H)===l}function k(H){return O(H)===c}function j(H){return O(H)===a}function K(H){return O(H)===o}function Z(H){return typeof H=="object"&&H!==null&&H.$$typeof===t}function et(H){return O(H)===h}function U(H){return O(H)===r}function Q(H){return O(H)===m}function G(H){return O(H)===p}function tt(H){return O(H)===e}function ht(H){return O(H)===s}function B(H){return O(H)===i}function ct(H){return O(H)===f}Lt.AsyncMode=M,Lt.ConcurrentMode=z,Lt.ContextConsumer=R,Lt.ContextProvider=I,Lt.Element=L,Lt.ForwardRef=Y,Lt.Fragment=X,Lt.Lazy=it,Lt.Memo=rt,Lt.Portal=vt,Lt.Profiler=mt,Lt.StrictMode=dt,Lt.Suspense=ut,Lt.isAsyncMode=gt,Lt.isConcurrentMode=k,Lt.isContextConsumer=j,Lt.isContextProvider=K,Lt.isElement=Z,Lt.isForwardRef=et,Lt.isFragment=U,Lt.isLazy=Q,Lt.isMemo=G,Lt.isPortal=tt,Lt.isProfiler=ht,Lt.isStrictMode=B,Lt.isSuspense=ct,Lt.isValidElementType=C,Lt.typeOf=O})()),Lt}var Hd;function Gd(){return Hd||(Hd=1,process.env.NODE_ENV==="production"?ca.exports=cx():ca.exports=hx()),ca.exports}/*
|
|
68
60
|
object-assign
|
|
69
61
|
(c) Sindre Sorhus
|
|
70
62
|
@license MIT
|
|
71
|
-
*/var
|
|
72
|
-
Valid keys: `+JSON.stringify(Object.keys(
|
|
63
|
+
*/var Bl,Wd;function fx(){if(Wd)return Bl;Wd=1;var n=Object.getOwnPropertySymbols,t=Object.prototype.hasOwnProperty,e=Object.prototype.propertyIsEnumerable;function r(s){if(s==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(s)}function i(){try{if(!Object.assign)return!1;var s=new String("abc");if(s[5]="de",Object.getOwnPropertyNames(s)[0]==="5")return!1;for(var o={},a=0;a<10;a++)o["_"+String.fromCharCode(a)]=a;var l=Object.getOwnPropertyNames(o).map(function(h){return o[h]});if(l.join("")!=="0123456789")return!1;var c={};return"abcdefghijklmnopqrst".split("").forEach(function(h){c[h]=h}),Object.keys(Object.assign({},c)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return Bl=i()?Object.assign:function(s,o){for(var a,l=r(s),c,h=1;h<arguments.length;h++){a=Object(arguments[h]);for(var f in a)t.call(a,f)&&(l[f]=a[f]);if(n){c=n(a);for(var g=0;g<c.length;g++)e.call(a,c[g])&&(l[c[g]]=a[c[g]])}}return l},Bl}var ql,Ud;function $l(){if(Ud)return ql;Ud=1;var n="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return ql=n,ql}var Hl,Yd;function Xd(){return Yd||(Yd=1,Hl=Function.call.bind(Object.prototype.hasOwnProperty)),Hl}var Gl,Jd;function dx(){if(Jd)return Gl;Jd=1;var n=function(){};if(process.env.NODE_ENV!=="production"){var t=$l(),e={},r=Xd();n=function(s){var o="Warning: "+s;typeof console<"u"&&console.error(o);try{throw new Error(o)}catch{}}}function i(s,o,a,l,c){if(process.env.NODE_ENV!=="production"){for(var h in s)if(r(s,h)){var f;try{if(typeof s[h]!="function"){var g=Error((l||"React class")+": "+a+" type `"+h+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof s[h]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw g.name="Invariant Violation",g}f=s[h](o,h,l,a,null,t)}catch(m){f=m}if(f&&!(f instanceof Error)&&n((l||"React class")+": type specification of "+a+" `"+h+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof f+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),f instanceof Error&&!(f.message in e)){e[f.message]=!0;var p=c?c():"";n("Failed "+a+" type: "+f.message+(p??""))}}}}return i.resetWarningCache=function(){process.env.NODE_ENV!=="production"&&(e={})},Gl=i,Gl}var Wl,Zd;function px(){if(Zd)return Wl;Zd=1;var n=Gd(),t=fx(),e=$l(),r=Xd(),i=dx(),s=function(){};process.env.NODE_ENV!=="production"&&(s=function(a){var l="Warning: "+a;typeof console<"u"&&console.error(l);try{throw new Error(l)}catch{}});function o(){return null}return Wl=function(a,l){var c=typeof Symbol=="function"&&Symbol.iterator,h="@@iterator";function f(k){var j=k&&(c&&k[c]||k[h]);if(typeof j=="function")return j}var g="<<anonymous>>",p={array:S("array"),bigint:S("bigint"),bool:S("boolean"),func:S("function"),number:S("number"),object:S("object"),string:S("string"),symbol:S("symbol"),any:A(),arrayOf:C,element:O(),elementType:M(),instanceOf:z,node:Y(),objectOf:I,oneOf:R,oneOfType:L,shape:it,exact:rt};function m(k,j){return k===j?k!==0||1/k===1/j:k!==k&&j!==j}function v(k,j){this.message=k,this.data=j&&typeof j=="object"?j:{},this.stack=""}v.prototype=Error.prototype;function _(k){if(process.env.NODE_ENV!=="production")var j={},K=0;function Z(U,Q,G,tt,ht,B,ct){if(tt=tt||g,B=B||G,ct!==e){if(l){var H=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");throw H.name="Invariant Violation",H}else if(process.env.NODE_ENV!=="production"&&typeof console<"u"){var _t=tt+":"+G;!j[_t]&&K<3&&(s("You are manually calling a React.PropTypes validation function for the `"+B+"` prop on `"+tt+"`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details."),j[_t]=!0,K++)}}return Q[G]==null?U?Q[G]===null?new v("The "+ht+" `"+B+"` is marked as required "+("in `"+tt+"`, but its value is `null`.")):new v("The "+ht+" `"+B+"` is marked as required in "+("`"+tt+"`, but its value is `undefined`.")):null:k(Q,G,tt,ht,B)}var et=Z.bind(null,!1);return et.isRequired=Z.bind(null,!0),et}function S(k){function j(K,Z,et,U,Q,G){var tt=K[Z],ht=dt(tt);if(ht!==k){var B=ut(tt);return new v("Invalid "+U+" `"+Q+"` of type "+("`"+B+"` supplied to `"+et+"`, expected ")+("`"+k+"`."),{expectedType:k})}return null}return _(j)}function A(){return _(o)}function C(k){function j(K,Z,et,U,Q){if(typeof k!="function")return new v("Property `"+Q+"` of component `"+et+"` has invalid PropType notation inside arrayOf.");var G=K[Z];if(!Array.isArray(G)){var tt=dt(G);return new v("Invalid "+U+" `"+Q+"` of type "+("`"+tt+"` supplied to `"+et+"`, expected an array."))}for(var ht=0;ht<G.length;ht++){var B=k(G,ht,et,U,Q+"["+ht+"]",e);if(B instanceof Error)return B}return null}return _(j)}function O(){function k(j,K,Z,et,U){var Q=j[K];if(!a(Q)){var G=dt(Q);return new v("Invalid "+et+" `"+U+"` of type "+("`"+G+"` supplied to `"+Z+"`, expected a single ReactElement."))}return null}return _(k)}function M(){function k(j,K,Z,et,U){var Q=j[K];if(!n.isValidElementType(Q)){var G=dt(Q);return new v("Invalid "+et+" `"+U+"` of type "+("`"+G+"` supplied to `"+Z+"`, expected a single ReactElement type."))}return null}return _(k)}function z(k){function j(K,Z,et,U,Q){if(!(K[Z]instanceof k)){var G=k.name||g,tt=gt(K[Z]);return new v("Invalid "+U+" `"+Q+"` of type "+("`"+tt+"` supplied to `"+et+"`, expected ")+("instance of `"+G+"`."))}return null}return _(j)}function R(k){if(!Array.isArray(k))return process.env.NODE_ENV!=="production"&&(arguments.length>1?s("Invalid arguments supplied to oneOf, expected an array, got "+arguments.length+" arguments. A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z])."):s("Invalid argument supplied to oneOf, expected an array.")),o;function j(K,Z,et,U,Q){for(var G=K[Z],tt=0;tt<k.length;tt++)if(m(G,k[tt]))return null;var ht=JSON.stringify(k,function(ct,H){var _t=ut(H);return _t==="symbol"?String(H):H});return new v("Invalid "+U+" `"+Q+"` of value `"+String(G)+"` "+("supplied to `"+et+"`, expected one of "+ht+"."))}return _(j)}function I(k){function j(K,Z,et,U,Q){if(typeof k!="function")return new v("Property `"+Q+"` of component `"+et+"` has invalid PropType notation inside objectOf.");var G=K[Z],tt=dt(G);if(tt!=="object")return new v("Invalid "+U+" `"+Q+"` of type "+("`"+tt+"` supplied to `"+et+"`, expected an object."));for(var ht in G)if(r(G,ht)){var B=k(G,ht,et,U,Q+"."+ht,e);if(B instanceof Error)return B}return null}return _(j)}function L(k){if(!Array.isArray(k))return process.env.NODE_ENV!=="production"&&s("Invalid argument supplied to oneOfType, expected an instance of array."),o;for(var j=0;j<k.length;j++){var K=k[j];if(typeof K!="function")return s("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+W(K)+" at index "+j+"."),o}function Z(et,U,Q,G,tt){for(var ht=[],B=0;B<k.length;B++){var ct=k[B],H=ct(et,U,Q,G,tt,e);if(H==null)return null;H.data&&r(H.data,"expectedType")&&ht.push(H.data.expectedType)}var _t=ht.length>0?", expected one of type ["+ht.join(", ")+"]":"";return new v("Invalid "+G+" `"+tt+"` supplied to "+("`"+Q+"`"+_t+"."))}return _(Z)}function Y(){function k(j,K,Z,et,U){return vt(j[K])?null:new v("Invalid "+et+" `"+U+"` supplied to "+("`"+Z+"`, expected a ReactNode."))}return _(k)}function X(k,j,K,Z,et){return new v((k||"React class")+": "+j+" type `"+K+"."+Z+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+et+"`.")}function it(k){function j(K,Z,et,U,Q){var G=K[Z],tt=dt(G);if(tt!=="object")return new v("Invalid "+U+" `"+Q+"` of type `"+tt+"` "+("supplied to `"+et+"`, expected `object`."));for(var ht in k){var B=k[ht];if(typeof B!="function")return X(et,U,Q,ht,ut(B));var ct=B(G,ht,et,U,Q+"."+ht,e);if(ct)return ct}return null}return _(j)}function rt(k){function j(K,Z,et,U,Q){var G=K[Z],tt=dt(G);if(tt!=="object")return new v("Invalid "+U+" `"+Q+"` of type `"+tt+"` "+("supplied to `"+et+"`, expected `object`."));var ht=t({},K[Z],k);for(var B in ht){var ct=k[B];if(r(k,B)&&typeof ct!="function")return X(et,U,Q,B,ut(ct));if(!ct)return new v("Invalid "+U+" `"+Q+"` key `"+B+"` supplied to `"+et+"`.\nBad object: "+JSON.stringify(K[Z],null," ")+`
|
|
64
|
+
Valid keys: `+JSON.stringify(Object.keys(k),null," "));var H=ct(G,B,et,U,Q+"."+B,e);if(H)return H}return null}return _(j)}function vt(k){switch(typeof k){case"number":case"string":case"undefined":return!0;case"boolean":return!k;case"object":if(Array.isArray(k))return k.every(vt);if(k===null||a(k))return!0;var j=f(k);if(j){var K=j.call(k),Z;if(j!==k.entries){for(;!(Z=K.next()).done;)if(!vt(Z.value))return!1}else for(;!(Z=K.next()).done;){var et=Z.value;if(et&&!vt(et[1]))return!1}}else return!1;return!0;default:return!1}}function mt(k,j){return k==="symbol"?!0:j?j["@@toStringTag"]==="Symbol"||typeof Symbol=="function"&&j instanceof Symbol:!1}function dt(k){var j=typeof k;return Array.isArray(k)?"array":k instanceof RegExp?"object":mt(j,k)?"symbol":j}function ut(k){if(typeof k>"u"||k===null)return""+k;var j=dt(k);if(j==="object"){if(k instanceof Date)return"date";if(k instanceof RegExp)return"regexp"}return j}function W(k){var j=ut(k);switch(j){case"array":case"object":return"an "+j;case"boolean":case"date":case"regexp":return"a "+j;default:return j}}function gt(k){return!k.constructor||!k.constructor.name?g:k.constructor.name}return p.checkPropTypes=i,p.resetWarningCache=i.resetWarningCache,p.PropTypes=p,p},Wl}var Ul,Kd;function gx(){if(Kd)return Ul;Kd=1;var n=$l();function t(){}function e(){}return e.resetWarningCache=t,Ul=function(){function r(o,a,l,c,h,f){if(f!==n){var g=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw g.name="Invariant Violation",g}}r.isRequired=r;function i(){return r}var s={array:r,bigint:r,bool:r,func:r,number:r,object:r,string:r,symbol:r,any:r,arrayOf:i,element:r,elementType:r,instanceOf:i,node:r,objectOf:i,oneOf:i,oneOfType:i,shape:i,exact:i,checkPropTypes:e,resetWarningCache:t};return s.PropTypes=s,s},Ul}var Qd;function mx(){if(Qd)return la.exports;if(Qd=1,process.env.NODE_ENV!=="production"){var n=Gd(),t=!0;la.exports=px()(n.isElement,t)}else la.exports=gx()();return la.exports}var yx=mx();const $=Br(yx);function tp(n,t){return Array.isArray(t)?[n.a*t[0]+n.c*t[1]+n.e,n.b*t[0]+n.d*t[1]+n.f]:{x:n.a*t.x+n.c*t.y+n.e,y:n.b*t.x+n.d*t.y+n.f}}function ep(n,t){return t.map(e=>tp(n,e))}function Js(n){return{a:parseFloat(n.a),b:parseFloat(n.b),c:parseFloat(n.c),d:parseFloat(n.d),e:parseFloat(n.e),f:parseFloat(n.f)}}function rp(){return{a:1,c:0,e:0,b:0,d:1,f:0}}function np(n){const{a:t,b:e,c:r,d:i,e:s,f:o}=n,a=t*i-e*r;return{a:i/a,b:e/-a,c:r/-a,d:t/a,e:(i*s-r*o)/-a,f:(e*s-t*o)/a}}function Yl(n){return typeof n>"u"}function Ye(n,t=0){return{a:1,c:0,e:n,b:0,d:1,f:t}}function fn(...n){n=Array.isArray(n[0])?n[0]:n;const t=(e,r)=>({a:e.a*r.a+e.c*r.b,c:e.a*r.c+e.c*r.d,e:e.a*r.e+e.c*r.f+e.e,b:e.b*r.a+e.d*r.b,d:e.b*r.c+e.d*r.d,f:e.b*r.e+e.d*r.f+e.f});switch(n.length){case 0:throw new Error("no matrices provided");case 1:return n[0];case 2:return t(n[0],n[1]);default:{const[e,r,...i]=n,s=t(e,r);return fn(s,...i)}}}function ei(n,t=void 0,e=void 0,r=void 0){Yl(t)&&(t=n);const i={a:n,c:0,e:0,b:0,d:t,f:0};return Yl(e)||Yl(r)?i:fn([Ye(e,r),i,Ye(-e,-r)])}function vx(n){return xx(n)}function xx(n){return`matrix(${n.a},${n.b},${n.c},${n.d},${n.e},${n.f})`}function _x(n,t){function e(){this.constructor=n}e.prototype=t.prototype,n.prototype=new e}function ha(n,t,e,r){var i=Error.call(this,n);return Object.setPrototypeOf&&Object.setPrototypeOf(i,ha.prototype),i.expected=t,i.found=e,i.location=r,i.name="SyntaxError",i}_x(ha,Error);function Xl(n,t,e){return e=e||" ",n.length>t?n:(t-=n.length,e+=e.repeat(t),n+e.slice(0,t))}ha.prototype.format=function(n){var t="Error: "+this.message;if(this.location){var e=null,r;for(r=0;r<n.length;r++)if(n[r].source===this.location.source){e=n[r].text.split(/\r\n|\n|\r/g);break}var i=this.location.start,s=this.location.source&&typeof this.location.source.offset=="function"?this.location.source.offset(i):i,o=this.location.source+":"+s.line+":"+s.column;if(e){var a=this.location.end,l=Xl("",s.line.toString().length," "),c=e[i.line-1],h=i.line===a.line?a.column:c.length+1,f=h-i.column||1;t+=`
|
|
73
65
|
--> `+o+`
|
|
74
66
|
`+l+` |
|
|
75
67
|
`+s.line+" | "+c+`
|
|
76
|
-
`+l+" | "+
|
|
77
|
-
at `+o}return t},Ca.buildMessage=function(n,t){var e={literal:function(c){return'"'+i(c.text)+'"'},class:function(c){var h=c.parts.map(function(f){return Array.isArray(f)?s(f[0])+"-"+s(f[1]):s(f)});return"["+(c.inverted?"^":"")+h.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(c){return c.description}};function r(c){return c.charCodeAt(0).toString(16).toUpperCase()}function i(c){return c.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(h){return"\\x0"+r(h)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(h){return"\\x"+r(h)})}function s(c){return c.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(h){return"\\x0"+r(h)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(h){return"\\x"+r(h)})}function o(c){return e[c.type](c)}function a(c){var h=c.map(o),f,g;if(h.sort(),h.length>0){for(f=1,g=1;f<h.length;f++)h[f-1]!==h[f]&&(h[g]=h[f],g++);h.length=g}switch(h.length){case 1:return h[0];case 2:return h[0]+" or "+h[1];default:return h.slice(0,-1).join(", ")+", or "+h[h.length-1]}}function l(c){return c?'"'+i(c)+'"':"end of input"}return"Expected "+a(n)+" but "+l(t)+" found."};const lr="idle",Br="panning",qr="zooming",Mr="auto",dn="none",Ar="pan",$r="zoom-in",pn="zoom-out",Ia="none",gn="top",cr="right",mn="bottom",We="left",ka="zoom",yo="pan",rs="center",ns="left",pc="right",is="top",gc="bottom",fp="cover";function dp(n,t){var e=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),e.push.apply(e,r)}return e}function Pa(n){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?dp(Object(e),!0).forEach(function(r){Ax(n,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(e)):dp(Object(e)).forEach(function(r){Object.defineProperty(n,r,Object.getOwnPropertyDescriptor(e,r))})}return n}function Ax(n,t,e){return(t=Ox(t))in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}function Ox(n){var t=zx(n,"string");return typeof t=="symbol"?t:t+""}function zx(n,t){if(typeof n!="object"||!n)return n;var e=n[Symbol.toPrimitive];if(e!==void 0){var r=e.call(n,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(n)}const pp=3,gp=lr;function mp(n,t,e,r,i,s){let o=arguments.length>6&&arguments[6]!==void 0?arguments[6]:null,a=arguments.length>7&&arguments[7]!==void 0?arguments[7]:null;return te({},Pa(Pa({},cp()),{},{version:pp,mode:gp,focus:!1,pinchPointDistance:null,prePinchMode:null,viewerWidth:n,viewerHeight:t,SVGMinX:e,SVGMinY:r,SVGWidth:i,SVGHeight:s,scaleFactorMin:o,scaleFactorMax:a,startX:null,startY:null,endX:null,endY:null,miniatureOpen:!0,lastAction:null}))}function te(n,t){let e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null;return n=Object.assign({},n,t,{lastAction:e}),Object.freeze(n)}function Tx(n){return n!==null&&typeof n=="object"&&n.hasOwnProperty("version")&&n.version===pp}function Or(n,t,e){let r=mo(n),i=hp(r);return up(i,{x:t,y:e})}function Ra(n){let t=mo(n);return{scaleFactor:t.a,translationX:t.e,translationY:t.f}}function Cx(n,t){return te(n,{focus:t})}function Ix(n,t,e){return te(n,{viewerWidth:t,viewerHeight:e})}function yp(n,t,e,r,i){return te(n,{SVGMinX:t,SVGMinY:e,SVGWidth:r,SVGHeight:i})}function kx(n,t,e){return te(n,{scaleFactorMin:t,scaleFactorMax:e})}function Px(n,t,e,r){let{viewerWidth:i,viewerHeight:s}=n,o=zn(ur(-t+i/2,-e+s/2),ur(t,e),_i(r,r),ur(-t,-e));return te(n,Pa({mode:lr},o))}function Rx(n){return te(n,Pa({mode:lr},cp()))}function vp(n){return te(n,{mode:gp,startX:null,startY:null,endX:null,endY:null})}class xp{constructor(t,e,r){this.originalEvent=t,this.value=e,this.SVGViewer=r}get scaleFactor(){return this._cacheDecomposedValue=this._cacheDecomposedValue||Ra(this.value),this._cacheDecomposedValue.scaleFactor}get translationX(){return this._cacheDecomposedValue=this._cacheDecomposedValue||Ra(this.value),this._cacheDecomposedValue.translationX}get translationY(){return this._cacheDecomposedValue=this._cacheDecomposedValue||Ra(this.value),this._cacheDecomposedValue.translationY}preventDefault(){this.originalEvent.preventDefault()}stopPropagation(){this.originalEvent.stopPropagation()}}function _p(n,t){var e=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),e.push.apply(e,r)}return e}function Lx(n){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?_p(Object(e),!0).forEach(function(r){Fx(n,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(e)):_p(Object(e)).forEach(function(r){Object.defineProperty(n,r,Object.getOwnPropertyDescriptor(e,r))})}return n}function Fx(n,t,e){return(t=Nx(t))in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}function Nx(n){var t=jx(n,"string");return typeof t=="symbol"?t:t+""}function jx(n,t){if(typeof n!="object"||!n)return n;var e=n[Symbol.toPrimitive];if(e!==void 0){var r=e.call(n,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(n)}function mc(n,t,e){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:void 0,i=zn(mo(n),ur(t,e));if(r){let[{x:s,y:o},{x:a,y:l}]=lp(i,[{x:n.SVGMinX+r,y:n.SVGMinY+r},{x:n.SVGMinX+n.SVGWidth-r,y:n.SVGMinY+n.SVGHeight-r}]),c=0;n.viewerWidth-s<0?c=n.viewerWidth-s:a<0&&(c=-a);let h=0;n.viewerHeight-o<0?h=n.viewerHeight-o:l<0&&(h=-l),i=zn(ur(c,h),i)}return te(n,Lx({mode:lr},i),yo)}function Vx(n,t,e){return te(n,{mode:Br,startX:t,startY:e,endX:t,endY:e},yo)}function Dx(n,t,e,r){if(n.mode!==Br)throw new Error("update pan not allowed in this mode "+n.mode);let{endX:i,endY:s}=n,o=Or(n,i,s),a=Or(n,t,e),l=a.x-o.x,c=a.y-o.y,h=mc(n,l,c,r);return te(h,{mode:Br,endX:t,endY:e},yo)}function bp(n){return te(n,{mode:lr,startX:null,startY:null,endX:null,endY:null},yo)}function Bx(n,t,e){let r=0,i=0;return e<=20&&(i=2),n.viewerWidth-t<=20&&(r=-2),n.viewerHeight-e<=20&&(i=-2),t<=20&&(r=2),r=r/n.d,i=i/n.d,r===0&&i===0?n:mc(n,r,i)}function wp(n,t){if(n.x<=t.x&&n.y<=t.y)return{x:n.x,y:n.y,width:t.x-n.x,height:t.y-n.y};if(n.x>=t.x&&n.y<=t.y)return{x:t.x,y:n.y,width:n.x-t.x,height:t.y-n.y};if(n.x>=t.x&&n.y>=t.y)return{x:t.x,y:t.y,width:n.x-t.x,height:n.y-t.y};if(n.x<=t.x&&n.y>=t.y)return{x:n.x,y:t.y,width:t.x-n.x,height:n.y-t.y}}function Sp(n,t){var e=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),e.push.apply(e,r)}return e}function ss(n){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?Sp(Object(e),!0).forEach(function(r){qx(n,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(e)):Sp(Object(e)).forEach(function(r){Object.defineProperty(n,r,Object.getOwnPropertyDescriptor(e,r))})}return n}function qx(n,t,e){return(t=$x(t))in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}function $x(n){var t=Hx(n,"string");return typeof t=="symbol"?t:t+""}function Hx(n,t){if(typeof n!="object"||!n)return n;var e=n[Symbol.toPrimitive];if(e!==void 0){var r=e.call(n,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(n)}function La(n,t){const{scaleFactor:e}=Ra(n),r=n.scaleFactorMin&&e*t<n.scaleFactorMin,i=n.scaleFactorMax&&e*t>n.scaleFactorMax;return r&&t<1||i&&t>1}function yc(n,t){let e=t.a;return n.scaleFactorMin!=null&&(e=Math.max(e,n.scaleFactorMin)),n.scaleFactorMax!=null&&(e=Math.min(e,n.scaleFactorMax)),te(t,{a:e,d:e})}function os(n,t,e,r){if(La(n,r))return n;const i=zn(mo(n),ur(t,e),_i(r,r),ur(-t,-e));return te(n,ss(ss({mode:lr},i),{},{startX:null,startY:null,endX:null,endY:null}),ka)}function Ep(n,t,e,r,i){let{viewerWidth:s,viewerHeight:o}=n,a=s/r,l=o/i,c=Math.min(a,l);const h=zn(_i(c,c),ur(-t,-e));return La(n,c/n.d)?te(n,{mode:lr,startX:null,startY:null,endX:null,endY:null}):te(n,ss(ss({mode:lr},yc(n,h)),{},{startX:null,startY:null,endX:null,endY:null}),ka)}function Mp(n){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:ns,e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:is,{viewerWidth:r,viewerHeight:i,SVGMinX:s,SVGMinY:o,SVGWidth:a,SVGHeight:l}=n,c=r/a,h=i/l,f=Math.min(c,h),g=_i(f,f),p=-s*c,m=-o*h;if(c<h){let S=i-c*l;switch(e){case is:m=-o*f;break;case rs:m=Math.round(S/2)-o*f;break;case gc:m=S-o*f;break;case fp:g=_i(h,h);let M=r-h*a;p=s+Math.round(M/2);break}}else{let S=r-h*a;switch(t){case ns:p=-s*f;break;case rs:p=Math.round(S/2)-s*f;break;case pc:p=S-s*f;break;case fp:g=_i(c,c);let M=i-c*l;m=o+Math.round(M/2);break}}const v=ur(p,m),_=zn(v,g);return La(n,f/n.d)?te(n,{mode:lr,startX:null,startY:null,endX:null,endY:null}):te(n,ss(ss({mode:lr},yc(n,_)),{},{startX:null,startY:null,endX:null,endY:null}),ka)}function Gx(n,t){let{viewerWidth:e,viewerHeight:r}=n,i=Or(n,e/2,r/2);return os(n,i.x,i.y,t)}function Wx(n,t,e){return te(n,{mode:qr,startX:t,startY:e,endX:t,endY:e})}function Ux(n,t,e){if(n.mode!==qr)throw new Error("update selection not allowed in this mode "+n.mode);return te(n,{endX:t,endY:e})}function vc(n,t,e,r){let{startX:s,startY:o}=n,a=Or(n,s,o),l=Or(n,t,e);if(Math.abs(s-t)>7&&Math.abs(o-e)>7){let c=wp(a,l);return Ep(n,c.x,c.y,c.width,c.height)}else{let c=Or(n,t,e);return os(n,c.x,c.y,r)}}function Yx(n,t,e,r,i){return r+(i-r)*(n-t)/(e-t)}function as(n,t){let{left:e,top:r}=t.getBoundingClientRect(),i=n.clientX-Math.round(e),s=n.clientY-Math.round(r);return{x:i,y:s}}function Ap(n,t,e,r,i){let s=arguments.length>5&&arguments[5]!==void 0?arguments[5]:null;const{x:o,y:a}=s||as(n,t);let l=r;switch(e){case pn:let c=Or(r,o,a);l=os(r,c.x,c.y,1/i.scaleFactor);break;case $r:l=Wx(r,o,a);break;case Mr:case Ar:l=Vx(r,o,a);break;default:return r}return n.preventDefault(),l}function Op(n,t,e,r,i){let s=arguments.length>5&&arguments[5]!==void 0?arguments[5]:null;const{x:o,y:a}=s||as(n,t);let l=n.buttons===0,c=r;switch(e){case $r:r.mode===qr&&(c=l?vc(r,o,a,i.scaleFactor):Ux(r,o,a));break;case Mr:case Ar:r.mode===Br&&(c=l?bp(r):Dx(r,o,a,i.preventPanOutside?20:void 0));break;default:return r}return n.preventDefault(),c}function zp(n,t,e,r,i){let s=arguments.length>5&&arguments[5]!==void 0?arguments[5]:null;const{x:o,y:a}=s||as(n,t);let l=r;switch(e){case pn:r.mode===qr&&(l=vc(r,o,a,1/i.scaleFactor));break;case $r:r.mode===qr&&(l=vc(r,o,a,i.scaleFactor));break;case Mr:case Ar:r.mode===Br&&(l=bp(r));break;default:return r}return n.preventDefault(),l}function Xx(n,t,e,r,i){let s=arguments.length>5&&arguments[5]!==void 0?arguments[5]:null;const{x:o,y:a}=s||as(n,t);let l=r;if(e===Mr&&!i.disableDoubleClickZoomWithToolAuto){const{modifierKeys:c=[]}=i;let h=Or(r,o,a),f=(m,v)=>m||n.getModifierState(v),p=c.reduce(f,!1)?1/i.scaleFactor:i.scaleFactor;l=os(r,h.x,h.y,p)}return n.preventDefault(),l}function Jx(n,t,e,r,i){let s=arguments.length>5&&arguments[5]!==void 0?arguments[5]:null;const{x:o,y:a}=s||as(n,t);if(!i.detectWheel)return r;let l=Math.max(-1,Math.min(1,n.deltaY)),c=Yx(l,-1,1,i.scaleFactorOnWheel,1/i.scaleFactorOnWheel),h=Or(r,o,a),f=os(r,h.x,h.y,c);return n.preventDefault(),f}function Tp(n,t,e,r,i){let s=Cx(r,n.type==="mouseenter");return n.preventDefault(),s}function Zx(n,t,e,r,i){let s=arguments.length>5&&arguments[5]!==void 0?arguments[5]:null,{x:o,y:a}=s;return!([dn,Mr].indexOf(e)>=0)||!i.detectAutoPan||!r.focus?r:Bx(r,o,a)}class Kx extends xp{get point(){if(!this._cachePoint){const{originalEvent:t,SVGViewer:e,value:r}=this,i=as(t,e);this._cachePoint=Or(r,i.x,i.y)}return this._cachePoint}get x(){return this.point.x}get y(){return this.point.y}}function Cp(n,t){var e=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),e.push.apply(e,r)}return e}function Ip(n){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?Cp(Object(e),!0).forEach(function(r){Qx(n,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(e)):Cp(Object(e)).forEach(function(r){Object.defineProperty(n,r,Object.getOwnPropertyDescriptor(e,r))})}return n}function Qx(n,t,e){return(t=t_(t))in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}function t_(n){var t=e_(n,"string");return typeof t=="symbol"?t:t+""}function e_(n,t){if(typeof n!="object"||!n)return n;var e=n[Symbol.toPrimitive];if(e!==void 0){var r=e.call(n,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(n)}class Fa extends xp{get points(){return this._cachePoints||(this._cachePoints=Fa.touchesToPoints(this.originalEvent.touches,this.SVGViewer,this.value)),this._cachePoints}get changedPoints(){return this._cacheChangedPoints||(this._cacheChangedPoints=Fa.touchesToPoints(this.originalEvent.changedTouches,this.SVGViewer,this.value)),this._cacheChangedPoints}static touchesToPoints(t,e,r){let i=[];for(let s=0;s<t.length;s++){let o=t[s],a=e.getBoundingClientRect(),l=o.clientX-Math.round(a.left),c=o.clientY-Math.round(a.top),h=Or(r,l,c);i.push(Ip(Ip({},h),{},{identifier:o.identifier}))}return i}}function r_(n,t,e){let r=n.type;switch(r){case"mousemove":case"mouseup":case"mousedown":case"click":case"dblclick":return new Kx(n,t,e);case"touchstart":case"touchmove":case"touchend":case"touchcancel":return new Fa(n,t,e);default:throw new Error(`${r} not supported`)}}function kp(n){return n.split(/[ ,]/).filter(Boolean).map(Number)}function Pp(n,t){var e=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),e.push.apply(e,r)}return e}function Rp(n){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?Pp(Object(e),!0).forEach(function(r){n_(n,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(e)):Pp(Object(e)).forEach(function(r){Object.defineProperty(n,r,Object.getOwnPropertyDescriptor(e,r))})}return n}function n_(n,t,e){return(t=i_(t))in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}function i_(n){var t=s_(n,"string");return typeof t=="symbol"?t:t+""}function s_(n,t){if(typeof n!="object"||!n)return n;var e=n[Symbol.toPrimitive];if(e!==void 0){var r=e.call(n,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(n)}function o_(n,t){let{left:e,top:r}=t.getBoundingClientRect(),i=n.clientX-Math.round(e),s=n.clientY-Math.round(r);return{x:i,y:s}}function a_(n,t,e,r,i){if(Fp(n,i))return Np(n,t,e,r);if(n.touches.length!==1){if([Br,qr].indexOf(r.mode)>=0)return vp(r);if([lr].indexOf(r.mode)>=0)return r}return xc(n,t,e,r,i,Ap)}function u_(n,t,e,r,i){return Fp(n,i)?Np(n,t,e,r):[Br,qr].indexOf(r.mode)>=0?xc(n,t,e,r,i,Op):r}function l_(n,t,e,r,i){if(!([Br,qr].indexOf(r.mode)>=0))return r;let s=h_(n,r,i)?te(r,{pinchPointDistance:null}):r;return n.touches.length>0?s:xc(n,t,e,s,i,zp)}function c_(n,t,e,r,i){return n.stopPropagation(),n.preventDefault(),vp(r)}function Lp(n){return typeof n.pinchPointDistance=="number"}function h_(n,t,e){return e.detectPinchGesture&&Lp(t)&&n.touches.length<2}function Fp(n,t){return t.detectPinchGesture&&n.touches.length>1}function xc(n,t,e,r,i,s){let o=n.touches.length===0?te(r,{mode:r.prePinchMode?lr:r.mode,prePinchMode:null}):r,a=n.touches.length>0?n.touches[0]:n.changedTouches[0],l=o_(a,t);switch(e){case pn:case $r:case Mr:case Ar:return n.stopPropagation(),n.preventDefault(),s(n,t,e,o,i,l);default:return o}}function Np(n,t,e,r,i){const{left:s,top:o}=t.getBoundingClientRect(),a=n.touches[0].clientX-Math.round(s),l=n.touches[0].clientY-Math.round(o),c=n.touches[1].clientX-Math.round(s),h=n.touches[1].clientY-Math.round(o),f=Math.sqrt(Math.pow(c-a,2)+Math.pow(h-l,2)),g=Lp(r)?r.pinchPointDistance:f,p=Or(r,(a+c)/2,(l+h)/2);let m=f/g;if(La(r,m))return r;n.cancelable&&n.preventDefault();let v=zn(mo(r),ur(p.x,p.y),_i(m,m),ur(-p.x,-p.y));return te(r,te(Rp(Rp({mode:qr},yc(r,v)),{},{startX:null,startY:null,endX:null,endY:null,prePinchMode:r.prePinchMode?r.prePinchMode:r.mode,pinchPointDistance:f})))}function jp(n){return te(n,{miniatureOpen:!0})}function Vp(n){return te(n,{miniatureOpen:!1})}let f_=n=>["zoom-in","zoom-out","grab","grabbing"].indexOf(n)>-1,Dp=()=>navigator.userAgent.toLowerCase(),d_=()=>Dp().indexOf("firefox")>-1,p_=()=>Dp().indexOf("webkit")>-1;function Na(n){if(!f_(n))return n;if(d_())return`-moz-${n}`;if(p_())return`-webkit-${n}`}function g_(n){return n.displayName||n.name||"Component"}function _c(){return _c=Object.assign?Object.assign.bind():function(n){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var r in e)({}).hasOwnProperty.call(e,r)&&(n[r]=e[r])}return n},_c.apply(null,arguments)}let m_=1;const y_=()=>`uid${m_++}`;function Bp(n){class t extends F.Component{constructor(r){super(r),this.state={uid:y_()}}render(){return F.createElement(n,_c({_uid:this.state.uid},this.props))}}return t.displayName=`RandomUID(${g_(n)})`,t}const qp="react-svg-pan-zoom_border_gradient";function $p(n){let{direction:t,width:e,height:r,_uid:i}=n,s;switch(t){case gn:s=`translate(${e}, 0) rotate(90)`;break;case cr:s=`translate(${e}, ${r}) rotate(180)`;break;case mn:s=`translate(0, ${r}) rotate(270)`;break;case We:default:s=" ";break}let o=`${qp}_gradient_${i}`,a=`${qp}_mask_${i}`;return F.createElement("g",null,F.createElement("defs",null,F.createElement("linearGradient",{id:o,x1:"0%",y1:"0%",x2:"100%",y2:"0%",spreadMethod:"pad"},F.createElement("stop",{offset:"0%",stopColor:"#fff",stopOpacity:"0.8"}),F.createElement("stop",{offset:"100%",stopColor:"#000",stopOpacity:"0.5"})),F.createElement("mask",{id:a,x:"0",y:"0",width:"20",height:Math.max(e,r)},F.createElement("rect",{x:"0",y:"0",width:"20",height:Math.max(e,r),style:{stroke:"none",fill:`url(#${o})`}}))),F.createElement("rect",{x:"0",y:"0",width:"20",height:Math.max(e,r),style:{stroke:"none",fill:"#000",mask:`url(#${a})`},transform:s}))}$p.propTypes={direction:$.oneOf([gn,cr,mn,We]).isRequired,width:$.number.isRequired,height:$.number.isRequired};const ja=Bp($p);function Hp(n){let{startX:t,startY:e,endX:r,endY:i}=n;if(!t||!e||!r||!i)return null;let s=wp({x:t,y:e},{x:r,y:i});return F.createElement("rect",{stroke:"#969FFF",strokeOpacity:.7,fill:"#F3F4FF",fillOpacity:.7,x:s.x,y:s.y,width:s.width,height:s.height,style:{pointerEvents:"none"}})}Hp.propTypes={startX:$.number,startY:$.number,endX:$.number,endY:$.number};function v_(){return F.createElement("svg",{width:24,height:24,stroke:"currentColor"},F.createElement("path",{d:"M10.07,14.27C10.57,14.03 11.16,14.25 11.4,14.75L13.7,19.74L15.5,18.89L13.19,13.91C12.95,13.41 13.17,12.81 13.67,12.58L13.95,12.5L16.25,12.05L8,5.12V15.9L9.82,14.43L10.07,14.27M13.64,21.97C13.14,22.21 12.54,22 12.31,21.5L10.13,16.76L7.62,18.78C7.45,18.92 7.24,19 7,19A1,1 0 0,1 6,18V3A1,1 0 0,1 7,2C7.24,2 7.47,2.09 7.64,2.23L7.65,2.22L19.14,11.86C19.57,12.22 19.62,12.85 19.27,13.27C19.12,13.45 18.91,13.57 18.7,13.61L15.54,14.23L17.74,18.96C18,19.46 17.76,20.05 17.26,20.28L13.64,21.97Z"}))}function x_(){return F.createElement("svg",{width:24,height:24,stroke:"currentColor"},F.createElement("path",{d:"M13,6V11H18V7.75L22.25,12L18,16.25V13H13V18H16.25L12,22.25L7.75,18H11V13H6V16.25L1.75,12L6,7.75V11H11V6H7.75L12,1.75L16.25,6H13Z"}))}function __(){return F.createElement("svg",{width:24,height:24,stroke:"currentColor"},F.createElement("g",null,F.createElement("path",{d:"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"}),F.createElement("path",{d:"M12 10h-2v2H9v-2H7V9h2V7h1v2h2v1z"})))}function b_(){return F.createElement("svg",{width:24,height:24,stroke:"currentColor"},F.createElement("path",{d:"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14zM7 9h5v1H7z"}))}function w_(){return F.createElement("svg",{width:24,height:24,stroke:"currentColor"},F.createElement("path",{d:"M15 3l2.3 2.3-2.89 2.87 1.42 1.42L18.7 6.7 21 9V3zM3 9l2.3-2.3 2.87 2.89 1.42-1.42L6.7 5.3 9 3H3zm6 12l-2.3-2.3 2.89-2.87-1.42-1.42L5.3 17.3 3 15v6zm12-6l-2.3 2.3-2.87-2.89-1.42 1.42 2.89 2.87L15 21h6z"}))}let us=class extends F.Component{constructor(t){super(t),this.state={hover:!1}}change(t){switch(t.preventDefault(),t.stopPropagation(),t.type){case"mouseenter":case"touchstart":this.setState({hover:!0});break;case"mouseleave":case"touchend":case"touchcancel":this.setState({hover:!1});break}}render(){let t={display:"block",width:"24px",height:"24px",margin:[gn,mn].indexOf(this.props.toolbarPosition)>=0?"2px 1px":"1px 2px",color:this.props.active||this.state.hover?this.props.activeColor:"#FFF",transition:"color 200ms ease",background:"none",padding:"0px",border:"0px",outline:"0px",cursor:"pointer"};return F.createElement("button",{onMouseEnter:e=>this.change(e),onMouseLeave:e=>this.change(e),onTouchStart:e=>{this.change(e),this.props.onClick(e)},onTouchEnd:e=>this.change(e),onTouchCancel:e=>this.change(e),onClick:this.props.onClick,style:t,title:this.props.title,name:this.props.name,type:"button"},this.props.children)}};us.propTypes={title:$.string.isRequired,name:$.string.isRequired,toolbarPosition:$.string.isRequired,activeColor:$.string.isRequired,onClick:$.func.isRequired,active:$.bool.isRequired};const S_="#1CA6FC";function Gp(n){let{tool:t,value:e,onChangeValue:r,onChangeTool:i,activeToolColor:s=S_,position:o=cr,SVGAlignX:a=ns,SVGAlignY:l=is}=n,c=(p,m)=>{i(m),p.stopPropagation(),p.preventDefault()},h=p=>{r(Mp(e,a,l)),p.stopPropagation(),p.preventDefault()},f=[gn,mn].indexOf(o)>=0,g={position:"absolute",transform:[gn,mn].indexOf(o)>=0?"translate(-50%, 0px)":"none",top:[We,cr,gn].indexOf(o)>=0?"5px":"unset",left:[gn,mn].indexOf(o)>=0?"50%":We===o?"5px":"unset",right:[cr].indexOf(o)>=0?"5px":"unset",bottom:[mn].indexOf(o)>=0?"5px":"unset",backgroundColor:"rgba(19, 20, 22, 0.90)",borderRadius:"2px",display:"flex",flexDirection:f?"row":"column",padding:f?"1px 2px":"2px 1px"};return F.createElement("div",{style:g,role:"toolbar"},F.createElement(us,{toolbarPosition:o,active:t===dn,activeColor:s,name:"unselect-tools",title:"Selection",onClick:p=>c(p,dn)},F.createElement(v_,null)),F.createElement(us,{toolbarPosition:o,active:t===Ar,activeColor:s,name:"select-tool-pan",title:"Pan",onClick:p=>c(p,Ar)},F.createElement(x_,null)),F.createElement(us,{toolbarPosition:o,active:t===$r,activeColor:s,name:"select-tool-zoom-in",title:"Zoom in",onClick:p=>c(p,$r)},F.createElement(__,null)),F.createElement(us,{toolbarPosition:o,active:t===pn,activeColor:s,name:"select-tool-zoom-out",title:"Zoom out",onClick:p=>c(p,pn)},F.createElement(b_,null)),F.createElement(us,{toolbarPosition:o,active:!1,activeColor:s,name:"fit-to-viewer",title:"Fit to viewer",onClick:p=>h(p)},F.createElement(w_,null)))}Gp.propTypes={tool:$.string.isRequired,onChangeTool:$.func.isRequired,value:$.object.isRequired,onChangeValue:$.func.isRequired,position:$.oneOf([gn,cr,mn,We]),SVGAlignX:$.oneOf([rs,ns,pc]),SVGAlignY:$.oneOf([rs,is,gc]),activeToolColor:$.string};function E_(){return"ontouchstart"in window||navigator.maxTouchPoints}function Wp(n){let{open:t,position:e}=n,r=0;switch(e){case We:r=t?"rotate(225, 12, 13)":"rotate(45, 12, 13)";break;case cr:r=r=t?"rotate(135, 12, 13)":"rotate(-45, 12, 13)";break}return F.createElement("svg",{width:24,height:24,stroke:"currentColor"},F.createElement("g",{transform:r},F.createElement("path",{fill:"#000000",d:"M7.41,15.41L12,10.83L16.59,15.41L18,14L12,8L6,14L7.41,15.41Z"})))}Wp.propTypes={open:$.bool.isRequired,position:$.oneOf([cr,We]).isRequired};function Up(n){let{value:t,onChangeValue:e,position:r}=n,i={width:"24px",height:"24px",display:"block",position:"absolute",bottom:0,[r===We?"left":"right"]:"0px",background:"rgba(19, 20, 22, 0.901961)",border:0,padding:0,outline:0,color:"#fff"},s=t.miniatureOpen?Vp:jp;return F.createElement("button",{type:"button",style:i,onClick:()=>e(s(t))},F.createElement(Wp,{open:t.miniatureOpen,position:r}))}Up.propTypes={value:$.object.isRequired,onChangeValue:$.func.isRequired,position:$.oneOf([cr,We]).isRequired};const M_="react-svg-pan-zoom_miniature";function Yp(n){let{SVGMinX:t,SVGMinY:e,SVGWidth:r,SVGHeight:i,x1:s,y1:o,x2:a,y2:l,zoomToFit:c,_uid:h}=n;const f=`${M_}_mask_${h}`;return F.createElement("g",null,F.createElement("defs",null,F.createElement("mask",{id:f},F.createElement("rect",{x:t,y:e,width:r,height:i,fill:"#ffffff"}),F.createElement("rect",{x:s,y:o,width:a-s,height:l-o}))),F.createElement("rect",{x:t,y:e,width:r,height:i,style:{stroke:"none",fill:"#000",mask:`url(#${f})`,opacity:.4}}))}Yp.propTypes={SVGWidth:$.number.isRequired,SVGHeight:$.number.isRequired,SVGMinX:$.number.isRequired,SVGMinY:$.number.isRequired,x1:$.number.isRequired,y1:$.number.isRequired,x2:$.number.isRequired,y2:$.number.isRequired,zoomToFit:$.number.isRequired};const A_=Bp(Yp),O_="#616264";function Xp(n){let{value:t,onChangeValue:e,children:r,SVGBackground:i,background:s=O_,position:o=We,width:a=100,height:l=80}=n,{SVGMinX:c,SVGMinY:h,SVGWidth:f,SVGHeight:g,viewerWidth:p,viewerHeight:m}=t,v=g/f,_=v>=1?l/g:a/f,[{x:S,y:M},{x:C,y:O}]=lp(hp(t),[{x:0,y:0},{x:p,y:m}]),E,z;t.miniatureOpen?(E=a,z=l):(E=24,z=24);let R={position:"absolute",overflow:"hidden",outline:"1px solid rgba(19, 20, 22, 0.90)",transition:"width 200ms ease, height 200ms ease, bottom 200ms ease",width:E+"px",height:z+"px",bottom:"6px",[o===We?"left":"right"]:"6px",background:s},k=v>=1?`translate(${(a-f*_)/2-c*_}, ${-h*_})`:`translate(${-c*_}, ${(l-g*_)/2-h*_})`;return F.createElement("div",{role:"navigation",style:R},F.createElement("svg",{width:a,height:l,style:{pointerEvents:"none"}},F.createElement("g",{transform:k},F.createElement("g",{transform:`scale(${_}, ${_})`},F.createElement("rect",{fill:i,x:c,y:h,width:f,height:g}),r,F.createElement(A_,{SVGWidth:f,SVGHeight:g,SVGMinX:c,SVGMinY:h,x1:S,y1:M,x2:C,y2:O,zoomToFit:_})))),F.createElement(Up,{value:t,onChangeValue:e,position:o}))}Xp.propTypes={value:$.object.isRequired,onChangeValue:$.func.isRequired,SVGBackground:$.string.isRequired,position:$.oneOf([cr,We]),background:$.string,width:$.number,height:$.number};function bi(n){return typeof n>"u"||n===null}const bc="https://github.com/chrvadala/react-svg-pan-zoom/blob/main"+"/docs/migrate-from-v2-to-v3.md";function z_(){console.error(`HEY! With ReactSVGPanZoom >= 3 you MUST specify value and tool props. Please read here ${bc}`)}function T_(){console.error(`HEY! With ReactSVGPanZoom >= 3 the props miniaturePosition, miniatureBackground, miniatureWidth, miniatureHeight can be specified as key in the miniatureProps object. Please read here ${bc}`)}function C_(){console.error(`HEY! With ReactSVGPanZoom >= 3 the prop toolbarPosition can be specified as key in the toolbarProps object. Please read here ${bc}`)}function Jp(n){(bi(n.tool)||bi(n.value))&&z_(),(!bi(n.miniaturePosition)||!bi(n.miniatureBackground)||!bi(n.miniatureWidth)||!bi(n.miniatureHeight))&&T_(),bi(n.toolbarPosition)||C_()}function Va(){return Va=Object.assign?Object.assign.bind():function(n){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var r in e)({}).hasOwnProperty.call(e,r)&&(n[r]=e[r])}return n},Va.apply(null,arguments)}function Zp(n,t){var e=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),e.push.apply(e,r)}return e}function I_(n){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?Zp(Object(e),!0).forEach(function(r){k_(n,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(e)):Zp(Object(e)).forEach(function(r){Object.defineProperty(n,r,Object.getOwnPropertyDescriptor(e,r))})}return n}function k_(n,t,e){return(t=P_(t))in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}function P_(n){var t=R_(n,"string");return typeof t=="symbol"?t:t+""}function R_(n,t){if(typeof n!="object"||!n)return n;var e=n[Symbol.toPrimitive];if(e!==void 0){var r=e.call(n,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(n)}class Da extends F.Component{constructor(t,e){const{width:r,height:i,scaleFactorMin:s,scaleFactorMax:o,children:a}=t,{viewBox:l}=a.props;let c;if(l){const[h,f,g,p]=kp(l);c=mp(r,i,h,f,g,p,s,o)}else{const{width:h,height:f}=a.props;c=mp(r,i,0,0,h,f,s,o)}super(t,e),this.ViewerDOM=null,this.state={pointerX:null,pointerY:null,defaultValue:c},this.autoPanLoop=this.autoPanLoop.bind(this),this.onWheel=this.onWheel.bind(this),process.env.NODE_ENV!=="production"&&Jp(t)}componentDidUpdate(t){const e=this.getValue(),r=this.props;let i=e,s=!1;process.env.NODE_ENV!=="production"&&Jp(r);const{viewBox:o}=r.children.props;if(o){const[a,l,c,h]=kp(o);(e.SVGMinX!==a||e.SVGMinY!==l||e.SVGWidth!==c||e.SVGHeight!==h)&&(i=yp(i,a,l,c,h),s=!0)}else{const{width:a,height:l}=r.children.props;(e.SVGWidth!==a||e.SVGHeight!==l)&&(i=yp(i,0,0,a,l),s=!0)}(t.width!==r.width||t.height!==r.height)&&(i=Ix(i,r.width,r.height),s=!0),(t.scaleFactorMin!==r.scaleFactorMin||t.scaleFactorMax!==r.scaleFactorMax)&&(i=kx(i,r.scaleFactorMin,r.scaleFactorMax),s=!0),s&&this.setValue(i)}componentDidMount(){this.autoPanIsRunning=!0,requestAnimationFrame(this.autoPanLoop),this.ViewerDOM.addEventListener("wheel",this.onWheel,!1)}componentWillUnmount(){this.autoPanIsRunning=!1,this.ViewerDOM.removeEventListener("wheel",this.onWheel)}getValue(){return Tx(this.props.value)?this.props.value:this.state.defaultValue}getTool(){return this.props.tool?this.props.tool:dn}setValue(t){let{onChangeValue:e,onZoom:r,onPan:i}=this.props;e&&e(t),t.lastAction&&(r&&t.lastAction===ka&&r(t),i&&t.lastAction===yo&&i(t))}pan(t,e){let r=mc(this.getValue(),t,e);this.setValue(r)}zoom(t,e,r){let i=os(this.getValue(),t,e,r);this.setValue(i)}fitSelection(t,e,r,i){let s=Ep(this.getValue(),t,e,r,i);this.setValue(s)}fitToViewer(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:ns,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:is,r=Mp(this.getValue(),t,e);this.setValue(r)}zoomOnViewerCenter(t){let e=Gx(this.getValue(),t);this.setValue(e)}setPointOnViewerCenter(t,e,r){let i=Px(this.getValue(),t,e,r);this.setValue(i)}reset(){let t=Rx(this.getValue());this.setValue(t)}openMiniature(){let t=jp(this.getValue());this.setValue(t)}closeMiniature(){let t=Vp(this.getValue());this.setValue(t)}handleViewerEvent(t){let{props:e,ViewerDOM:r}=this;if(!([dn,Mr].indexOf(this.getTool())>=0)||t.target===r)return;let s={click:e.onClick,dblclick:e.onDoubleClick,mousemove:e.onMouseMove,mouseup:e.onMouseUp,mousedown:e.onMouseDown,touchstart:e.onTouchStart,touchmove:e.onTouchMove,touchend:e.onTouchEnd,touchcancel:e.onTouchCancel}[t.type];s&&s(r_(t,e.value,r))}autoPanLoop(){let t={x:this.state.pointerX,y:this.state.pointerY},e=Zx(null,this.ViewerDOM,this.getTool(),this.getValue(),this.props,t);this.getValue()!==e&&this.setValue(e),this.autoPanIsRunning&&requestAnimationFrame(this.autoPanLoop)}onWheel(t){let e=Jx(t,this.ViewerDOM,this.getTool(),this.getValue(),this.props);this.getValue()!==e&&this.setValue(e)}render(){let{props:t,state:{pointerX:e,pointerY:r}}=this,i=this.getTool(),s=this.getValue(),{customToolbar:o=Gp,customMiniature:a=Xp}=t,l=i===Mr&&s.mode===Br&&s.startX!==s.endX&&s.startY!==s.endY,c;i===Ar&&(c=Na(s.mode===Br?"grabbing":"grab")),i===$r&&(c=Na("zoom-in")),i===pn&&(c=Na("zoom-out")),l&&(c=Na("grabbing"));let h=[Ar,$r,pn].indexOf(i)>=0;h=h||l;const f=this.props.detectPinchGesture||[Ar,Mr].indexOf(this.getTool())!==-1?"none":void 0,g={display:"block",cursor:c,touchAction:f};return F.createElement("div",{style:I_({position:"relative",width:s.viewerWidth,height:s.viewerHeight},t.style),className:this.props.className},F.createElement("svg",{ref:p=>this.ViewerDOM=p,width:s.viewerWidth,height:s.viewerHeight,style:g,onMouseDown:p=>{let m=Ap(p,this.ViewerDOM,this.getTool(),this.getValue(),this.props);this.getValue()!==m&&this.setValue(m),this.handleViewerEvent(p)},onMouseMove:p=>{let{left:m,top:v}=this.ViewerDOM.getBoundingClientRect(),_=p.clientX-Math.round(m),S=p.clientY-Math.round(v),M=Op(p,this.ViewerDOM,this.getTool(),this.getValue(),this.props,{x:_,y:S});this.getValue()!==M&&this.setValue(M),this.setState({pointerX:_,pointerY:S}),this.handleViewerEvent(p)},onMouseUp:p=>{let m=zp(p,this.ViewerDOM,this.getTool(),this.getValue(),this.props);this.getValue()!==m&&this.setValue(m),this.handleViewerEvent(p)},onClick:p=>{this.handleViewerEvent(p)},onDoubleClick:p=>{let m=Xx(p,this.ViewerDOM,this.getTool(),this.getValue(),this.props);this.getValue()!==m&&this.setValue(m),this.handleViewerEvent(p)},onMouseEnter:p=>{if(E_())return;let m=Tp(p,this.ViewerDOM,this.getTool(),this.getValue(),this.props);this.getValue()!==m&&this.setValue(m)},onMouseLeave:p=>{let m=Tp(p,this.ViewerDOM,this.getTool(),this.getValue(),this.props);this.getValue()!==m&&this.setValue(m)},onTouchStart:p=>{let m=a_(p,this.ViewerDOM,this.getTool(),this.getValue(),this.props);this.getValue()!==m&&this.setValue(m),this.handleViewerEvent(p)},onTouchMove:p=>{let m=u_(p,this.ViewerDOM,this.getTool(),this.getValue(),this.props);this.getValue()!==m&&this.setValue(m),this.handleViewerEvent(p)},onTouchEnd:p=>{let m=l_(p,this.ViewerDOM,this.getTool(),this.getValue(),this.props);this.getValue()!==m&&this.setValue(m),this.handleViewerEvent(p)},onTouchCancel:p=>{let m=c_(p,this.ViewerDOM,this.getTool(),this.getValue(),this.props);this.getValue()!==m&&this.setValue(m),this.handleViewerEvent(p)}},F.createElement("rect",{fill:t.background,x:0,y:0,width:s.viewerWidth,height:s.viewerHeight,style:{pointerEvents:"none"}}),F.createElement("g",{transform:Sx(s),style:h?{pointerEvents:"none"}:{}},F.createElement("rect",{fill:this.props.SVGBackground,style:this.props.SVGStyle,x:s.SVGMinX||0,y:s.SVGMinY||0,width:s.SVGWidth,height:s.SVGHeight}),F.createElement("g",null,t.children.props.children)),[dn,Mr].indexOf(i)>=0&&t.detectAutoPan&&s.focus?F.createElement("g",{style:{pointerEvents:"none"}},r<=20?F.createElement(ja,{direction:gn,width:s.viewerWidth,height:s.viewerHeight}):null,s.viewerWidth-e<=20?F.createElement(ja,{direction:cr,width:s.viewerWidth,height:s.viewerHeight}):null,s.viewerHeight-r<=20?F.createElement(ja,{direction:mn,width:s.viewerWidth,height:s.viewerHeight}):null,s.focus&&e<=20?F.createElement(ja,{direction:We,width:s.viewerWidth,height:s.viewerHeight}):null):null,s.mode!==qr?null:F.createElement(Hp,{startX:s.startX,startY:s.startY,endX:s.endX,endY:s.endY})),t.toolbarProps.position===Ia?null:F.createElement(o,Va({},this.props.toolbarProps,{value:s,onChangeValue:p=>this.setValue(p),tool:i,onChangeTool:p=>this.props.onChangeTool(p)})),t.miniatureProps.position===Ia?null:F.createElement(a,Va({},this.props.miniatureProps,{value:s,onChangeValue:p=>this.setValue(p),SVGBackground:this.props.SVGBackground}),t.children.props.children))}}Da.propTypes={width:$.number.isRequired,height:$.number.isRequired,value:$.oneOfType([$.object,$.shape({version:$.oneOf([2]).isRequired,mode:$.oneOf([lr,Br,qr]).isRequired,focus:$.bool.isRequired,a:$.number.isRequired,b:$.number.isRequired,c:$.number.isRequired,d:$.number.isRequired,e:$.number.isRequired,f:$.number.isRequired,viewerWidth:$.number.isRequired,viewerHeight:$.number.isRequired,SVGMinX:$.number.isRequired,SVGMinY:$.number.isRequired,SVGWidth:$.number.isRequired,SVGHeight:$.number.isRequired,startX:$.number,startY:$.number,endX:$.number,endY:$.number,miniatureOpen:$.bool.isRequired})]).isRequired,onChangeValue:$.func.isRequired,tool:$.oneOf([Mr,dn,Ar,$r,pn]).isRequired,onChangeTool:$.func.isRequired,background:$.string,SVGBackground:$.string,SVGStyle:$.object,style:$.object,className:$.string,detectWheel:$.bool,detectAutoPan:$.bool,detectPinchGesture:$.bool,onZoom:$.func,onPan:$.func,onClick:$.func,onDoubleClick:$.func,onMouseUp:$.func,onMouseMove:$.func,onMouseDown:$.func,preventPanOutside:$.bool,scaleFactor:$.number,scaleFactorOnWheel:$.number,scaleFactorMax:$.number,scaleFactorMin:$.number,modifierKeys:$.array,disableDoubleClickZoomWithToolAuto:$.bool,customMiniature:$.oneOfType([$.element,$.func]),miniatureProps:$.shape({position:$.oneOf([Ia,cr,We]),background:$.string,width:$.number,height:$.number}),customToolbar:$.oneOfType([$.element,$.func]),toolbarProps:$.shape({position:$.oneOf([Ia,gn,cr,mn,We]),SVGAlignX:$.oneOf([rs,ns,pc]),SVGAlignY:$.oneOf([rs,is,gc]),activeToolColor:$.string}),children:function(n,t,e){let r=n[t],i=["svg"];if(F.Children.count(r)!==1||i.indexOf(r.type)===-1)return new Error("`"+e+"` should have a single child of the following types: `"+i.join("`, `")+"`.");if((!r.props.hasOwnProperty("width")||!r.props.hasOwnProperty("height"))&&!r.props.hasOwnProperty("viewBox"))return new Error("SVG should have props `width` and `height` or `viewBox`")}},Da.defaultProps={style:{},background:"#616264",SVGBackground:"#fff",SVGStyle:{},detectWheel:!0,detectAutoPan:!0,detectPinchGesture:!0,modifierKeys:["Alt","Shift","Control"],preventPanOutside:!0,scaleFactor:1.1,scaleFactorOnWheel:1.06,disableZoomWithToolAuto:!1,onZoom:null,onPan:null,toolbarProps:{},miniatureProps:{}};const L_=["width","height","onChangeTool","onChangeValue"];function wc(){return wc=Object.assign?Object.assign.bind():function(n){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var r in e)({}).hasOwnProperty.call(e,r)&&(n[r]=e[r])}return n},wc.apply(null,arguments)}function F_(n,t){if(n==null)return{};var e,r,i=N_(n,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(n);for(r=0;r<s.length;r++)e=s[r],t.includes(e)||{}.propertyIsEnumerable.call(n,e)&&(i[e]=n[e])}return i}function N_(n,t){if(n==null)return{};var e={};for(var r in n)if({}.hasOwnProperty.call(n,r)){if(t.includes(r))continue;e[r]=n[r]}return e}class j_ extends F.Component{constructor(t){super(t),this.state={value:t.defaultValue||{},tool:t.defaultTool||dn},this.Viewer=null,this.changeTool=this.changeTool.bind(this),this.changeValue=this.changeValue.bind(this)}changeTool(t){this.setState({tool:t})}changeValue(t){this.setState({value:t})}pan(t,e){this.Viewer.pan(t,e)}zoom(t,e,r){this.Viewer.zoom(t,e,r)}fitSelection(t,e,r,i){this.Viewer.fitSelection(t,e,r,i)}fitToViewer(t,e){this.Viewer.fitToViewer(t,e)}zoomOnViewerCenter(t){this.Viewer.zoomOnViewerCenter(t)}setPointOnViewerCenter(t,e,r){this.Viewer.setPointOnViewerCenter(t,e,r)}reset(){this.Viewer.reset()}openMiniature(){this.Viewer.openMiniature()}closeMiniature(){this.Viewer.closeMiniature()}render(){const t=this.props,{width:e,height:r,onChangeTool:i,onChangeValue:s}=t,o=F_(t,L_),{tool:a,value:l}=this.state;return F.createElement(Da,wc({width:e,height:r,tool:a,onChangeTool:this.changeTool,value:l,onChangeValue:this.changeValue,ref:c=>this.Viewer=c},o))}}j_.propTypes={width:$.number.isRequired,height:$.number.isRequired,defaultValue:$.object,defaultTool:$.string};const ne=f0(n=>({planner:new ba,viewer:null,plan:null,activeFloor:0,setViewer:t=>{n(e=>({...e,viewer:t}))},setActiveFloor:t=>{n(e=>({...e,activeFloor:t}))},newProject:()=>{n(t=>({...t,planner:Jt.newProject(t.planner).updatedState}))},selectTool3DView:()=>{n(t=>{const e=Jt.rollback(t.planner).updatedState;return e.set("mode",vi),{...t,planner:e}})},selectTool3DFirstPerson:()=>{n(t=>{const e=Jt.rollback(t.planner).updatedState;return e.set("mode",Qi),{...t,planner:e}})},loadProject:t=>{n(e=>{const r=new ba({scene:t,catalog:e.planner.catalog.toJS()});return{...e,planner:r}})},undo:()=>{n(t=>{const e=Jt.undo(t.planner).updatedState;return{...t,planner:e}})},redo:()=>{n(t=>{const e=Jt.redo(t.planner).updatedState;return{...t,planner:e}})},addLayer:(t,e)=>{n(r=>{const i=wt.create(r.planner,t,e).updatedState;return{...r,planner:i}})},removeLayer:t=>{n(e=>{const r=wt.remove(e.planner,t).updatedState;return{...e,planner:r}})},addGroup:()=>{n(t=>{const e=_e.create(t.planner).updatedState;return{...t,planner:e}})},selectGroup:t=>{n(e=>{const r=_e.select(e.planner,t).updatedState;return{...e,planner:r}})},setGroupProperties:(t,e)=>{n(r=>{const i=_e.setProperties(r.planner,t,e).updatedState;return{...r,planner:i}})},addToGroup:(t,e,r,i)=>{n(s=>{const o=_e.addElement(s.planner,t,e,r,i).updatedState;return{...s,planner:o}})},removeGroup:t=>{n(e=>{const r=_e.remove(e.planner,t).updatedState;return{...e,planner:r}})},setGroupAttributes:(t,e)=>{n(r=>{const i=_e.setAttributes(r.planner,t,e).updatedState;return{...r,planner:i}})},groupTranslate:(t,e,r)=>{n(i=>{const s=_e.translate(i.planner,t,e,r).updatedState;return{...i,planner:s}})},removeFromGroup:(t,e,r,i)=>{n(s=>{const o=_e.removeElement(s.planner,t,e,r,i).updatedState;return{...s,planner:o}})},groupRotate:(t,e)=>{n(r=>{const i=_e.rotate(r.planner,t,e).updatedState;return{...r,planner:i}})},removeGroupAndDeleteElements:t=>{n(e=>{const r=_e.removeAndDeleteElements(e.planner,t).updatedState;return{...e,planner:r}})},addGroupFromSelected:()=>{n(t=>{const e=_e.createFromSelectedElements(t.planner).updatedState;return{...t,planner:e}})},copyProperties:t=>{n(e=>({...e,planner:Jt.copyProperties(e.planner,t).updatedState}))},pasteProperties:()=>{n(t=>{const e=t.planner.merge({sceneHistory:de(t.planner.sceneHistory,t.planner.scene)});return{...t,planner:Jt.pasteProperties(e).updatedState}})},setProperties:t=>{n(e=>{const r=e.planner.merge({sceneHistory:de(e.planner.sceneHistory,e.planner.scene)});return{...e,planner:Jt.setProperties(r,r.getIn(["scene","selectedLayer"]),t).updatedState}})},setHolesAttributes:t=>{n(e=>{const r=t.set("offset",parseFloat(t.get("offset"))),i=e.planner.merge({sceneHistory:de(e.planner.sceneHistory,e.planner.scene)});return{...e,planner:Jt.setHolesAttributes(i,r).updatedState}})},setLinesAttributes:t=>{n(e=>{const r=t.withMutations(s=>{s.setIn(["vertexOne","x"],parseFloat(t.getIn(["vertexOne","x"]))),s.setIn(["vertexOne","y"],parseFloat(t.getIn(["vertexOne","y"]))),s.setIn(["vertexTwo","x"],parseFloat(t.getIn(["vertexTwo","x"]))),s.setIn(["vertexTwo","y"],parseFloat(t.getIn(["vertexTwo","y"])))}),i=e.planner.merge({sceneHistory:de(e.planner.sceneHistory,e.planner.scene)});return{...e,planner:Jt.setLinesAttributes(i,r).updatedState}})},setItemsAttributes:t=>{n(e=>{const r=t.set("rotation",parseFloat(t.get("rotation"))),i=e.planner.merge({sceneHistory:de(e.planner.sceneHistory,e.planner.scene)});return{...e,planner:Jt.setItemsAttributes(i,r).updatedState}})},selectLine:(t,e)=>{n(r=>{const i=Ie.select(r.planner,t,e).updatedState;return{...r,planner:i}})},selectHole:(t,e)=>{n(r=>{const i=xe.select(r.planner,t,e).updatedState;return{...r,planner:i}})},selectItem:(t,e)=>{n(r=>{const i=Me.select(r.planner,t,e).updatedState;return{...r,planner:i}})},selectLayer:t=>{n(e=>{const r=wt.select(e.planner,t).updatedState;return{...e,planner:r}})},setLayerProperties:(t,e)=>{n(r=>{const i=wt.setProperties(r.planner,t,e).updatedState;return{...r,planner:i}})},addVerticalGuide:t=>{n(e=>{const r=Oa.create(e.planner,t).updatedState;return{...e,planner:r}})},addHorizontalGuide:t=>{n(e=>{const r=Aa.create(e.planner,t).updatedState;return{...e,planner:r}})},removeVerticalGuide:t=>{n(e=>{const r=Oa.remove(e.planner,t).updatedState;return{...e,planner:r}})},removeHorizontalGuide:t=>{n(e=>{const r=Aa.remove(e.planner,t).updatedState;return{...e,planner:r}})},toggleSnap:t=>{n(e=>{const r=Jt.toggleSnap(e.planner,t).updatedState;return{...e,planner:r}})},openProjectConfigurator:()=>{n(t=>{const e=Jt.openProjectConfigurator(t.planner).updatedState;return{...t,planner:e}})},setMode:t=>{n(e=>{const r=e.planner.set("mode",t);return{...e,planner:r}})},updateZoomScale:t=>{n(e=>({...e,planner:Jt.updateZoomScale(e.planner,t).updatedState}))},updateCameraView:t=>{n(e=>{const r=e.planner.update("viewer2D",i=>i.merge(Xt(t)));return{...e,planner:r}})},selectToolPan:()=>{n(t=>{const e=t.planner.set("mode",yi);return{...t,planner:e}})},selectToolEdit:()=>{n(t=>({...t,planner:Jt.setMode(t.planner,fe).updatedState}))},selectToolZoomIn:()=>{n(t=>{const e=t.planner.set("mode",gi);return{...t,planner:e}})},selectToolZoomOut:()=>{n(t=>{const e=t.planner.set("mode",mi);return{...t,planner:e}})},updateDrawingLine:(t,e)=>{n(r=>({...r,planner:Ie.updateDrawingLine(r.planner,t,e).updatedState}))},updateMouseCoord:t=>{n(e=>({...e,planner:Jt.updateMouseCoord(e.planner,t).updatedState}))},openCatalog:()=>{n(t=>{const e=t.planner.set("mode",zl);return{...t,planner:e}})},updateDrawingHole:(t,e,r)=>{n(i=>({...i,planner:xe.updateDrawingHole(i.planner,t,e,r).updatedState}))},updateDrawingItem:(t,e,r)=>{n(i=>({...i,planner:Me.updateDrawingItem(i.planner,t,e,r).updatedState}))},blur:()=>{n(t=>{const e=t.planner.merge({mode:fe,activeSnapElement:null});return{...t,planner:e}})},updateDraggingHole:(t,e)=>{n(r=>({...r,planner:xe.updateDraggingHole(r.planner,t,e).updatedState}))},updateDraggingLine:(t,e)=>{n(r=>({...r,planner:Ie.updateDraggingLine(r.planner,t,e).updatedState}))},updateDraggingVertex:(t,e)=>{n(r=>({...r,planner:pe.updateDraggingVertex(r.planner,t,e).updatedState}))},updateDraggingItem:(t,e)=>{n(r=>({...r,planner:Me.updateDraggingItem(r.planner,t,e).updatedState}))},updateRotatingItem:(t,e)=>{n(r=>({...r,planner:Me.updateRotatingItem(r.planner,t,e).updatedState}))},beginDraggingLine:(t,e,r,i)=>{n(s=>{const o=s.planner.merge({sceneHistory:de(s.planner.sceneHistory,s.planner.scene)});return{...s,planner:Ie.beginDraggingLine(o,t,e,r,i).updatedState}})},endDraggingLine:(t,e)=>{n(r=>{const i=r.planner.merge({sceneHistory:de(r.planner.sceneHistory,r.planner.scene)});return{...r,planner:Ie.endDraggingLine(i,t,e).updatedState}})},beginDraggingVertex:(t,e)=>{n(r=>({...r,planner:pe.beginDraggingVertex(r.planner,t,e).updatedState}))},endDraggingVertex:()=>{n(t=>({...t,planner:pe.endDraggingVertex(t.planner).updatedState}))},beginRotatingItem:(t,e,r,i)=>{n(s=>{const o=s.planner.merge({sceneHistory:de(s.planner.sceneHistory,s.planner.scene)});return{...s,planner:Me.beginRotatingItem(o,t,e,r,i).updatedState}})},endRotatingItem:(t,e)=>{n(r=>{const i=r.planner.merge({sceneHistory:de(r.planner.sceneHistory,r.planner.scene)});return{...r,planner:Me.endRotatingItem(i,t,e).updatedState}})},beginDraggingItem:(t,e,r,i)=>{n(s=>{const o=s.planner.merge({sceneHistory:de(s.planner.sceneHistory,s.planner.scene)});return{...s,planner:Me.beginDraggingItem(o,t,e,r,i).updatedState}})},endDraggingItem:(t,e)=>{n(r=>{const i=r.planner.merge({sceneHistory:de(r.planner.sceneHistory,r.planner.scene)});return{...r,planner:Me.endDraggingItem(i,t,e).updatedState}})},beginDraggingHole:(t,e,r,i)=>{n(s=>{const o=s.planner.merge({sceneHistory:de(s.planner.sceneHistory,s.planner.scene)});return{...s,planner:xe.beginDraggingHole(o,t,e,r,i).updatedState}})},endDraggingHole:(t,e)=>{n(r=>{const i=r.planner.merge({sceneHistory:de(r.planner.sceneHistory,r.planner.scene)});return{...r,planner:xe.endDraggingHole(i,t,e).updatedState}})},beginDrawingLine:(t,e,r)=>{n(i=>{const s=i.planner.merge({sceneHistory:de(i.planner.sceneHistory,i.planner.scene)});return{...i,planner:Ie.beginDrawingLine(s,t,e,r).updatedState}})},endDrawingLine:(t,e)=>{n(r=>{const i=r.planner.merge({sceneHistory:de(r.planner.sceneHistory,r.planner.scene)});return{...r,planner:Ie.endDrawingLine(i,t,e).updatedState}})},endDrawingHole:(t,e,r)=>{n(i=>{const s=i.planner.merge({sceneHistory:de(i.planner.sceneHistory,i.planner.scene)});return{...i,planner:xe.endDrawingHole(s,t,e,r).updatedState}})},endDrawingItem:(t,e,r)=>{n(i=>{const s=i.planner.merge({sceneHistory:de(i.planner.sceneHistory,i.planner.scene)});return{...i,planner:Me.endDrawingItem(s,t,e,r).updatedState}})},selectArea:(t,e)=>{n(r=>({...r,planner:xi.select(r.planner,t,e).updatedState}))},initCatalog:t=>{n(e=>({...e,planner:Jt.initCatalog(e.planner,t).updatedState}))},goBackToCatalogPage:t=>{n(e=>({...e,planner:Jt.goBackToCatalogPage(e.planner,t).updatedState}))},pushLastSelectedCatalogElementToHistory:t=>{n(e=>({...e,planner:Jt.pushLastSelectedCatalogElementToHistory(e.planner,t).updatedState}))},selectToolDrawingLine:t=>{n(e=>({...e,planner:Ie.selectToolDrawingLine(e.planner,t).updatedState}))},selectToolDrawingItem:t=>{n(e=>{const r=e.planner.merge({sceneHistory:de(e.planner.sceneHistory,e.planner.scene)});return{...e,planner:Me.selectToolDrawingItem(r,t).updatedState}})},selectToolDrawingHole:t=>{n(e=>{const r=e.planner.merge({sceneHistory:de(e.planner.sceneHistory,e.planner.scene)});return{...e,planner:xe.selectToolDrawingHole(r,t).updatedState}})},changeCatalogPage:(t,e)=>{n(r=>({...r,planner:Jt.changeCatalogPage(r.planner,e,t).updatedState}))},remove:()=>{n(t=>{const e=t.planner.merge({sceneHistory:de(t.planner.sceneHistory,t.planner.scene)});return{...t,planner:Jt.remove(e).updatedState}})},rollback:()=>{n(t=>({...t,planner:Jt.rollback(t.planner).updatedState}))},setAlterateState:()=>{n(t=>({...t,planner:Jt.setAlterate(t.planner).updatedState}))},setPlan:t=>{n(e=>({...e,plan:t}))},unselectAll:()=>{n(t=>({...t,planner:Jt.unselectAll(t.planner).updatedState}))}})),vo={stroke:"#D32F2F",strokeWidth:"1px"};function V_({snap:n,width:t,height:e}){switch(n.type){case"point":return w.jsxs("g",{transform:`translate(${n.x} ${n.y})`,children:[w.jsx("line",{x1:"0",y1:"-70",x2:"0",y2:"70",style:vo}),w.jsx("line",{x1:"-70",y1:"0",x2:"70",y2:"0",style:vo})]});case"line":let r=ma(0),i=ma(e),s=po(n.a,n.b,n.c,r.a,r.b,r.c),o=po(n.a,n.b,n.c,i.a,i.b,i.c),a=ya(0),l=ya(t),c=po(n.a,n.b,n.c,a.a,a.b,a.c),h=po(n.a,n.b,n.c,l.a,l.b,l.c);return s&&o?w.jsx("line",{x1:s.x,y1:s.y,x2:o.x,y2:o.y,style:vo}):c&&h?w.jsx("line",{x1:c.x,y1:c.y,x2:h.x,y2:h.y,style:vo}):null;case"line-segment":return w.jsx("line",{x1:n.x1,y1:n.y1,x2:n.x2,y2:n.y2,style:vo});default:return null}}const Kp={white:"#FFF",black:"#000"},Qp={500:{orange:"#FF9800"}},D_={alt:"#2E2F33",text_main:Kp.white},B_={main:"#1CA6FC"},Sc="#99C3FB",Wt={COLORS:Kp,PRIMARY_COLOR:D_,SECONDARY_COLOR:B_,MESH_SELECTED:Sc,AREA_MESH_COLOR:{selected:Sc,unselected:"#F5F4F4"},LINE_MESH_COLOR:{selected:Sc}};function q_({width:n,height:t,grid:e}){let r=e.properties.get("step"),i;e.properties.has("color")?i=ut([e.properties.get("color")]):i=e.properties.get("colors");let s=[],o=0;for(let a=0;a<=t;a+=r){let l=i.get(o%i.size);o++,s.push(w.jsx("line",{x1:"0",y1:a,x2:n,y2:a,strokeWidth:"1",stroke:l},a))}return w.jsx("g",{children:s})}function $_({width:n,height:t,grid:e}){let r=e.properties.get("step"),i;e.properties.has("color")?i=ut([e.properties.get("color")]):i=e.properties.get("colors");let s=[],o=0;for(let a=0;a<=n;a+=r){let l=i.get(o%i.size);o++,s.push(w.jsx("line",{x1:a,y1:"0",x2:a,y2:t,strokeWidth:"1",stroke:l},a))}return w.jsx("g",{children:s})}function H_({scene:n}){let{width:t,height:e,grids:r}=n,i=r.entrySeq().map(([s,o])=>{switch(o.type){case"horizontal-streak":return w.jsx(q_,{width:t,height:e,grid:o},s);case"vertical-streak":return w.jsx($_,{width:t,height:e,grid:o},s);default:console.warn(`grid ${o.type} not allowed`)}}).toList();return w.jsx("g",{children:i})}class G_{constructor(t=[],e=(r,i)=>r<i?-1:r>i?1:0){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let r=(this.length>>1)-1;r>=0;r--)this._down(r)}push(t){this.data.push(t),this._up(this.length++)}pop(){if(this.length===0)return;const t=this.data[0],e=this.data.pop();return--this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:r}=this,i=e[t];for(;t>0;){const s=t-1>>1,o=e[s];if(r(i,o)>=0)break;e[t]=o,t=s}e[t]=i}_down(t){const{data:e,compare:r}=this,i=this.length>>1,s=e[t];for(;t<i;){let o=(t<<1)+1;const a=o+1;if(a<this.length&&r(e[a],e[o])<0&&(o=a),r(e[o],s)>=0)break;e[t]=e[o],t=o}e[t]=s}}function W_(n,t=1,e=!1){let r=1/0,i=1/0,s=-1/0,o=-1/0;for(const[S,M]of n[0])S<r&&(r=S),M<i&&(i=M),S>s&&(s=S),M>o&&(o=M);const a=s-r,l=o-i,c=Math.max(t,Math.min(a,l));if(c===t){const S=[r,i];return S.distance=0,S}const h=new G_([],(S,M)=>M.max-S.max);let f=Y_(n);const g=new Ba(r+a/2,i+l/2,0,n);g.d>f.d&&(f=g);let p=2;function m(S,M,C){const O=new Ba(S,M,C,n);p++,O.max>f.d+t&&h.push(O),O.d>f.d&&(f=O,e&&console.log(`found best ${Math.round(1e4*O.d)/1e4} after ${p} probes`))}let v=c/2;for(let S=r;S<s;S+=c)for(let M=i;M<o;M+=c)m(S+v,M+v,v);for(;h.length;){const{max:S,x:M,y:C,h:O}=h.pop();if(S-f.d<=t)break;v=O/2,m(M-v,C-v,v),m(M+v,C-v,v),m(M-v,C+v,v),m(M+v,C+v,v)}e&&console.log(`num probes: ${p}
|
|
78
|
-
best distance: ${f.d}`);const _=[f.x,f.y];return _.distance=f.d,_}function Ba(n,t,e,r){this.x=n,this.y=t,this.h=e,this.d=U_(n,t,r),this.max=this.d+this.h*Math.SQRT2}function U_(n,t,e){let r=!1,i=1/0;for(const s of e)for(let o=0,a=s.length,l=a-1;o<a;l=o++){const c=s[o],h=s[l];c[1]>t!=h[1]>t&&n<(h[0]-c[0])*(t-c[1])/(h[1]-c[1])+c[0]&&(r=!r),i=Math.min(i,X_(n,t,c,h))}return i===0?0:(r?1:-1)*Math.sqrt(i)}function Y_(n){let t=0,e=0,r=0;const i=n[0];for(let o=0,a=i.length,l=a-1;o<a;l=o++){const c=i[o],h=i[l],f=c[0]*h[1]-h[0]*c[1];e+=(c[0]+h[0])*f,r+=(c[1]+h[1])*f,t+=f*3}const s=new Ba(e/t,r/t,0,n);return t===0||s.d<0?new Ba(i[0][0],i[0][1],0,n):s}function X_(n,t,e,r){let i=e[0],s=e[1],o=r[0]-i,a=r[1]-s;if(o!==0||a!==0){const l=((n-i)*o+(t-s)*a)/(o*o+a*a);l>1?(i=r[0],s=r[1]):l>0&&(i+=o*l,s+=a*l)}return o=n-i,a=t-s,o*o+a*a}function tg(n,t){var e=n.length,r=0;n=n.map(J_),n[0]!=n[n.length-1]&&(n=n.concat(n[0]));for(var i=0;i<e;i++)r+=n[i].x*n[i+1].y-n[i].y*n[i+1].x;return Math.abs(r)/2}function J_(n){return Array.isArray(n)?{x:n[0],y:n[1]}:n}const Z_={textAnchor:"middle",fontSize:"12px",fontFamily:'"Courier New", Courier, monospace',pointerEvents:"none",fontWeight:"bold",WebkitTouchCallout:"none",WebkitUserSelect:"none",MozUserSelect:"none",userSelect:"none"};function K_({layer:n,area:t,catalog:e}){let r=e.getElement(t.type).render2D(t,n),i=null;if(t.selected){let s=t.vertices.toArray().map(c=>{let{x:h,y:f}=n.vertices.get(c);return[h,f]}),o=s;t.holes.forEach(c=>{let h=n.areas.get(c).vertices.toArray().map(f=>{let{x:g,y:p}=n.vertices.get(f);return[g,p]});o=o.concat(h.reverse())});let a=W_([o],1),l=tg(s);t.holes.forEach(c=>{let f=n.areas.get(c).vertices.toArray().map(g=>{let{x:p,y:m}=n.vertices.get(g);return[p,m]});l-=tg(f)}),i=w.jsxs("text",{x:"0",y:"0",transform:`translate(${a[0]} ${a[1]}) scale(1, -1)`,style:Z_,children:[(l/1e4).toFixed(2)," m","²"]})}return w.jsxs("g",{"data-element-root":!0,"data-prototype":t.prototype,"data-id":t.id,"data-selected":t.selected,"data-layer":n.id,children:[r,i]})}const Q_=0,t1=0,e1=5,r1={fill:Qp[500].orange,stroke:Qp[500].orange,cursor:"default"};function n1({layer:n,group:t}){return w.jsx("g",{"data-element-root":!0,"data-prototype":t.prototype,"data-id":t.id,"data-selected":t.selected,"data-layer":n.id,style:t.selected?{cursor:"move"}:{},transform:`translate(${t.x},${t.y}) rotate(${t.rotation})`,children:t.selected&&w.jsx("g",{"data-element-root":!0,"data-prototype":t.prototype,"data-id":t.id,"data-selected":t.selected,"data-layer":n.id,"data-part":"rotation-anchor",children:w.jsx("circle",{cx:Q_,cy:t1,r:e1,style:r1,children:w.jsx("title",{children:"Group's Barycenter"})})})})}const i1={fill:"#0096fd",stroke:"#0096fd",cursor:"ew-resize"},s1={fill:"none",stroke:"#0096fd",cursor:"ew-resize"};function o1({layer:n,item:t,scene:e,catalog:r}){let{x:i,y:s,rotation:o}=t,a=r.getElement(t.type).render2D(t,n,e);return w.jsxs("g",{"data-element-root":!0,"data-prototype":t.prototype,"data-id":t.id,"data-selected":t.selected,"data-layer":n.id,style:t.selected?{cursor:"move"}:{},transform:`translate(${i},${s}) rotate(${o})`,children:[a,t.selected&&w.jsxs("g",{"data-element-root":!0,"data-prototype":t.prototype,"data-id":t.id,"data-selected":t.selected,"data-layer":n.id,"data-part":"rotation-anchor",children:[w.jsx("circle",{cx:"0",cy:"150",r:"10",style:i1}),w.jsx("circle",{cx:"0",cy:"0",r:"150",style:s1})]})]})}const Ec={stroke:"#0096fd",strokeWidth:"1px"},a1={textAnchor:"middle",fontSize:"12px",fontFamily:"'Courier New', Courier, monospace",pointerEvents:"none",fontWeight:"bold",WebkitTouchCallout:"none",WebkitUserSelect:"none",MozUserSelect:"none",userSelect:"none"};function u1({length:n,unit:t,transform:e}){let r=`${n.toFixed(2)} ${t}`;return w.jsxs("g",{transform:e,children:[w.jsx("text",{x:n/2,y:"-3",transform:"scale(1, -1)",style:a1,children:r}),w.jsx("line",{x1:"0",y1:"-5",x2:"0",y2:"5",style:Ec}),w.jsx("line",{x1:n,y1:"-5",x2:n,y2:"5",style:Ec}),w.jsx("line",{x1:"0",y1:"0",x2:n,y2:"0",style:Ec})]})}const l1=({line:n,layer:t,scene:e,catalog:r})=>{let i=t.vertices.get(n.vertices.get(0)),s=t.vertices.get(n.vertices.get(1));if(i.id===s.id||Dr(i,s))return null;let{x:o,y:a}=i,{x:l,y:c}=s;o>l&&({x:o,y:a}=s,{x:l,y:c}=i);let h=Ve(o,a,l,c),f=yv(o,a,l,c),g=n.holes.map(S=>{let M=t.holes.get(S),C=h*M.offset,O=r.getElement(M.type).render2D(M,t,e);return w.jsx("g",{transform:`translate(${C}, 0)`,"data-element-root":!0,"data-prototype":M.prototype,"data-id":M.id,"data-selected":M.selected,"data-layer":t.id,children:O},S)}),m=n.getIn(["properties","thickness","length"])/2,v=r.getElement(n.type).render2D(n,t),_=n.selected?w.jsx(u1,{unit:e.unit,length:h,transform:`translate(0, ${m+10} )`}):null;return w.jsxs("g",{transform:`translate(${o}, ${a}) rotate(${f}, 0, 0)`,"data-element-root":!0,"data-prototype":n.prototype,"data-id":n.id,"data-selected":n.selected,"data-layer":t.id,style:n.selected?{cursor:"move"}:{},children:[_,v,g]})},c1={fill:"#0096fd",stroke:Wt.COLORS.white,cursor:"move"},h1=({vertex:n,layer:t})=>w.jsx("g",{transform:`translate(${n.x}, ${n.y})`,"data-element-root":!0,"data-prototype":n.prototype,"data-id":n.id,"data-selected":n.selected,"data-layer":t.id,children:w.jsx("circle",{cx:"0",cy:"0",r:"7",style:c1})});function eg({layer:n,scene:t,catalog:e}){const{groups:r}=t,{lines:i,areas:s,vertices:o,id:a,items:l,opacity:c}=n;return w.jsxs("g",{opacity:c,children:[s.valueSeq().map(h=>w.jsx(K_,{layer:n,area:h,catalog:e},h.id)),i.valueSeq().map(h=>w.jsx(l1,{layer:n,line:h,scene:t,catalog:e},h.id)),l.valueSeq().map(h=>w.jsx(o1,{layer:n,item:h,scene:t,catalog:e},h.id)),o.valueSeq().filter(h=>h.selected).map(h=>w.jsx(h1,{layer:n,vertex:h},h.id)),r.valueSeq().filter(h=>h.hasIn(["elements",a])&&h.get("selected")).map(h=>w.jsx(n1,{layer:n,group:h,scene:t,catalog:e},h.get("id")))]})}const f1=({scene:n,catalog:t})=>{const{layers:e}=n,r=e.get(n.selectedLayer);return w.jsxs("g",{children:[w.jsx(H_,{scene:n}),w.jsx("g",{style:{pointerEvents:"none"},children:e.entrySeq().filter(([i,s])=>i!==n.selectedLayer&&s.visible).map(([i,s])=>w.jsx(eg,{layer:s,scene:n,catalog:t},i))}),w.jsx(eg,{layer:r,scene:n,catalog:t},r.id)]})},d1=F.memo(f1,(n,t)=>n.scene.hashCode()===t.scene.hashCode()),rg={stroke:Wt.SECONDARY_COLOR.main,strokeWidth:"2.5px"},p1=({catalog:n})=>{const{planner:t}=ne(),{activeSnapElement:e,snapElements:r,scene:i}=t,{width:s,height:o}=i;return w.jsxs("g",{children:[w.jsx("rect",{x:"0",y:"0",width:s,height:o,fill:Wt.COLORS.white}),w.jsxs("g",{transform:`translate(0, ${i.height}) scale(1, -1)`,id:"svg-drawing-paper",children:[w.jsx(d1,{scene:i,catalog:n}),i.getIn(["guides","horizontal"]).entrySeq().map(([a,l])=>w.jsx("line",{id:"hGuide"+a,x1:0,y1:l,x2:s,y2:l,style:rg},a)),i.getIn(["guides","vertical"]).entrySeq().map(([a,l])=>w.jsx("line",{x1:l,y1:0,x2:l,y2:o,style:rg},a)),e?w.jsx(V_,{snap:e,width:i.width,height:i.height}):null,r?null:w.jsx(w.Fragment,{})]})]})},Mc=.25,ng=5,g1=.25,m1=5.25;function ig(n){return(Math.min(Math.max(n,Mc),ng)-Mc)/(ng-Mc)*100}function y1(n){switch(n){case yi:return Ar;case gi:return $r;case mi:return pn;case fe:return Mr;default:return dn}}function v1(n){switch(n){case or:case ar:case Sr:case Vr:case jr:case Fr:case Nr:return{pointerEvents:"none"};default:return{}}}function x1(n){switch(n){case Vr:case Fr:case Nr:case jr:return{cursor:"move"};case An:return{cursor:"ew-resize"};case Lr:case or:return{cursor:"crosshair"};default:return{cursor:"default"}}}function _1(n){switch(n){case or:case Fr:case Nr:case Vr:case jr:case ar:case Sr:return!0;default:return!1}}function sg(n){for(;!n.attributes.getNamedItem("data-element-root")&&n.tagName!=="svg";)n=n.parentNode;return n.tagName==="svg"?null:{part:n.attributes.getNamedItem("data-part")?n.attributes.getNamedItem("data-part").value:void 0,layer:n.attributes.getNamedItem("data-layer").value,prototype:n.attributes.getNamedItem("data-prototype").value,selected:n.attributes.getNamedItem("data-selected").value==="true",id:n.attributes.getNamedItem("data-id").value}}const b1=({width:n,height:t,catalog:e})=>{const r=F.useRef(null),{planner:i,selectToolZoomOut:s,selectToolZoomIn:o,selectToolPan:a,selectToolEdit:l,updateCameraView:c,updateZoomScale:h,updateMouseCoord:f,updateDrawingLine:g,updateDrawingHole:p,updateDrawingItem:m,updateDraggingHole:v,updateDraggingLine:_,updateDraggingVertex:S,updateDraggingItem:M,updateRotatingItem:C,beginDraggingLine:O,beginDraggingVertex:E,beginRotatingItem:z,beginDraggingItem:R,beginDraggingHole:k,selectArea:L,unselectAll:X,beginDrawingLine:J,endDrawingLine:at,endDrawingHole:tt,endDrawingItem:bt,endDraggingLine:xt,endDraggingVertex:yt,endDraggingItem:ht,endDraggingHole:Y,endRotatingItem:St,selectLine:j,selectHole:W,selectItem:ft,rollback:et,setViewer:rt}=ne(),{viewer2D:Z,scene:Q,mode:U}=i,st=Q.selectedLayer??"";F.useEffect(()=>{r.current&&(rt(r.current),r.current.fitToViewer())},[]);const vt=({x:Ct,y:Gt})=>({x:Ct,y:-Gt+Q.height}),B=Ct=>{const Gt=new Event("mousemove-planner-event");Gt.viewerEvent=Ct,document.dispatchEvent(Gt);let{x:gt,y:_t}=vt(Ct);switch(f({x:gt,y:_t}),U){case or:g(gt,_t,i.snapMask);break;case ar:p(st,gt,_t);break;case Sr:m(st,gt,_t);break;case Vr:v(gt,_t);break;case Fr:_(gt,_t,i.snapMask);break;case Nr:S(gt,_t,i.snapMask);break;case jr:M(gt,_t);break;case An:C(gt,_t);break}Ct.originalEvent.stopPropagation()},pt=Ct=>{const Gt=Ct.originalEvent,gt=new Event("mousedown-planner-event");gt.viewerEvent=Ct,document.dispatchEvent(gt);let{x:_t,y:Dt}=vt(Ct);if(U===fe){let zt=sg(Gt.target);if(!zt||!zt.selected)return;switch(zt.prototype){case"lines":O(zt.layer,zt.id,_t,Dt,i.snapMask);break;case"vertices":E(zt.layer,zt.id,_t,Dt,i.snapMask);break;case"items":zt.part==="rotation-anchor"?z(zt.layer,zt.id,_t,Dt):R(zt.layer,zt.id,_t,Dt);break;case"holes":k(zt.layer,zt.id,_t,Dt);break}}Gt.stopPropagation()},H=Ct=>{const Gt=Ct.originalEvent,gt=new Event("mouseup-planner-event");gt.viewerEvent=Ct,document.dispatchEvent(gt);const{x:_t,y:Dt}=vt(Ct);switch(U){case fe:const zt=sg(Gt.target);if(zt&&zt.selected)return;switch(zt?zt.prototype:"none"){case"areas":L(zt.layer,zt.id);break;case"lines":j(zt.layer,zt.id);break;case"holes":W(zt.layer,zt.id);break;case"items":ft(zt.layer,zt.id);break;case"none":X();break}break;case Lr:J(st,_t,Dt,i.snapMask);break;case or:at(_t,Dt,i.snapMask),J(st,_t,Dt,i.snapMask);break;case ar:tt(st,_t,Dt);break;case Sr:bt(st,_t,Dt);break;case Fr:xt(_t,Dt,i.snapMask);break;case Nr:yt(_t,Dt,i.snapMask);break;case jr:ht(_t,Dt);break;case Vr:Y(_t,Dt);break;case An:St(_t,Dt);break}Gt.stopPropagation()},Ot=()=>{[Lr,or,ar,Sr].includes(U)&&et()},Bt=Ct=>{h(Ct.a),c(Ct)},kt=Ct=>{switch(Ct){case dn:l();break;case Ar:a();break;case $r:o();break;case pn:s();break}};return w.jsx("div",{className:"m-0 p-0 relative",children:w.jsx(Da,{className:"floor_planner-svgPanZoom",ref:r,style:{gridColumn:2,gridRow:2},width:n,height:t,scaleFactorMin:g1,scaleFactorMax:m1,value:Z.isEmpty()?{}:Z.toJS(),onChangeValue:Bt,tool:y1(U),onChangeTool:kt,detectAutoPan:_1(U),onMouseDown:pt,onMouseMove:B,onMouseUp:H,onDoubleClick:Ot,miniatureProps:{position:"none",width:0,height:0,background:""},toolbarProps:{position:"none"},children:w.jsxs("svg",{width:Q.width,height:Q.height,children:[w.jsx("defs",{children:w.jsxs("pattern",{id:"diagonalFill",patternUnits:"userSpaceOnUse",width:"4",height:"4",fill:"#FFF",children:[w.jsx("rect",{x:"0",y:"0",width:"4",height:"4",fill:"#FFF"}),w.jsx("path",{d:"M-1,1 l2,-2 M0,4 l4,-4 M3,5 l2,-2",style:{stroke:"#8E9BA2",strokeWidth:1}})]})}),w.jsx("g",{style:Object.assign(x1(U),v1(U)),children:w.jsx(p1,{catalog:e})})]})})})},w1={color:Wt.PRIMARY_COLOR.alt,fontWeight:300};function S1({children:n,style:t={},...e}){return w.jsx("h1",{style:{...w1,...t},...e,children:n})}const E1={padding:"0 20px",overflowY:"auto"};function M1({children:n,width:t,height:e,style:r={}}){return w.jsx("div",{style:{width:t,height:e,...E1,...r},onWheel:i=>i.stopPropagation(),children:n})}var og={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},ag=F.createContext&&F.createContext(og),A1=["attr","size","title"];function O1(n,t){if(n==null)return{};var e=z1(n,t),r,i;if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(n);for(i=0;i<s.length;i++)r=s[i],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(n,r)&&(e[r]=n[r])}return e}function z1(n,t){if(n==null)return{};var e={};for(var r in n)if(Object.prototype.hasOwnProperty.call(n,r)){if(t.indexOf(r)>=0)continue;e[r]=n[r]}return e}function qa(){return qa=Object.assign?Object.assign.bind():function(n){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r])}return n},qa.apply(this,arguments)}function ug(n,t){var e=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),e.push.apply(e,r)}return e}function $a(n){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?ug(Object(e),!0).forEach(function(r){T1(n,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(e)):ug(Object(e)).forEach(function(r){Object.defineProperty(n,r,Object.getOwnPropertyDescriptor(e,r))})}return n}function T1(n,t,e){return t=C1(t),t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}function C1(n){var t=I1(n,"string");return typeof t=="symbol"?t:t+""}function I1(n,t){if(typeof n!="object"||!n)return n;var e=n[Symbol.toPrimitive];if(e!==void 0){var r=e.call(n,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(n)}function lg(n){return n&&n.map((t,e)=>F.createElement(t.tag,$a({key:e},t.attr),lg(t.child)))}function ge(n){return t=>F.createElement(k1,qa({attr:$a({},n.attr)},t),lg(n.child))}function k1(n){var t=e=>{var{attr:r,size:i,title:s}=n,o=O1(n,A1),a=i||e.size||"1em",l;return e.className&&(l=e.className),n.className&&(l=(l?l+" ":"")+n.className),F.createElement("svg",qa({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},e.attr,r,o,{className:l,style:$a($a({color:n.color||e.color},e.style),n.style),height:a,width:a,xmlns:"http://www.w3.org/2000/svg"}),s&&F.createElement("title",null,s),n.children)};return ag!==void 0?F.createElement(ag.Consumer,null,e=>t(e)):t(og)}function P1(n){return ge({attr:{viewBox:"0 0 320 512"},child:[{tag:"path",attr:{d:"M31.3 192h257.3c17.8 0 26.7 21.5 14.1 34.1L174.1 354.8c-7.8 7.8-20.5 7.8-28.3 0L17.2 226.1C4.6 213.5 13.5 192 31.3 192z"},child:[]}]})(n)}function R1(n){return ge({attr:{viewBox:"0 0 192 512"},child:[{tag:"path",attr:{d:"M0 384.662V127.338c0-17.818 21.543-26.741 34.142-14.142l128.662 128.662c7.81 7.81 7.81 20.474 0 28.284L34.142 398.804C21.543 411.404 0 402.48 0 384.662z"},child:[]}]})(n)}function L1(n){return ge({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm144 276c0 6.6-5.4 12-12 12h-92v92c0 6.6-5.4 12-12 12h-56c-6.6 0-12-5.4-12-12v-92h-92c-6.6 0-12-5.4-12-12v-56c0-6.6 5.4-12 12-12h92v-92c0-6.6 5.4-12 12-12h56c6.6 0 12 5.4 12 12v92h92c6.6 0 12 5.4 12 12v56z"},child:[]}]})(n)}function F1(n){return ge({attr:{viewBox:"0 0 320 512"},child:[{tag:"path",attr:{d:"M41 288h238c21.4 0 32.1 25.9 17 41L177 448c-9.4 9.4-24.6 9.4-33.9 0L24 329c-15.1-15.1-4.4-41 17-41z"},child:[]}]})(n)}function N1(n){return ge({attr:{viewBox:"0 0 352 512"},child:[{tag:"path",attr:{d:"M242.72 256l100.07-100.07c12.28-12.28 12.28-32.19 0-44.48l-22.24-22.24c-12.28-12.28-32.19-12.28-44.48 0L176 189.28 75.93 89.21c-12.28-12.28-32.19-12.28-44.48 0L9.21 111.45c-12.28 12.28-12.28 32.19 0 44.48L109.28 256 9.21 356.07c-12.28 12.28-12.28 32.19 0 44.48l22.24 22.24c12.28 12.28 32.2 12.28 44.48 0L176 322.72l100.07 100.07c12.28 12.28 32.2 12.28 44.48 0l22.24-22.24c12.28-12.28 12.28-32.19 0-44.48L242.72 256z"},child:[]}]})(n)}function j1(n){return ge({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M304.083 405.907c4.686 4.686 4.686 12.284 0 16.971l-44.674 44.674c-59.263 59.262-155.693 59.266-214.961 0-59.264-59.265-59.264-155.696 0-214.96l44.675-44.675c4.686-4.686 12.284-4.686 16.971 0l39.598 39.598c4.686 4.686 4.686 12.284 0 16.971l-44.675 44.674c-28.072 28.073-28.072 73.75 0 101.823 28.072 28.072 73.75 28.073 101.824 0l44.674-44.674c4.686-4.686 12.284-4.686 16.971 0l39.597 39.598zm-56.568-260.216c4.686 4.686 12.284 4.686 16.971 0l44.674-44.674c28.072-28.075 73.75-28.073 101.824 0 28.072 28.073 28.072 73.75 0 101.823l-44.675 44.674c-4.686 4.686-4.686 12.284 0 16.971l39.598 39.598c4.686 4.686 12.284 4.686 16.971 0l44.675-44.675c59.265-59.265 59.265-155.695 0-214.96-59.266-59.264-155.695-59.264-214.961 0l-44.674 44.674c-4.686 4.686-4.686 12.284 0 16.971l39.597 39.598zm234.828 359.28l22.627-22.627c9.373-9.373 9.373-24.569 0-33.941L63.598 7.029c-9.373-9.373-24.569-9.373-33.941 0L7.029 29.657c-9.373 9.373-9.373 24.569 0 33.941l441.373 441.373c9.373 9.372 24.569 9.372 33.941 0z"},child:[]}]})(n)}const cg={width:"14em",height:"14em",padding:"0.625em",background:"#f7f7f9",border:"1px solid #e1e1e8",cursor:"pointer",position:"relative",boxShadow:"0 1px 6px 0 rgba(0, 0, 0, 0.11), 0 1px 4px 0 rgba(0, 0, 0, 0.11)",borderRadius:"2px",transition:"all .15s ease-in-out",WebkitTransition:"all .15s ease-in-out",alignSelf:"center",justifySelf:"center"},V1={...cg,background:Wt.SECONDARY_COLOR.main},hg={width:"100%",textAlign:"center",display:"block",marginBottom:".5em",textTransform:"capitalize"},D1={...hg,color:Wt.COLORS.white},B1={width:"100%",height:"8em",position:"relative",overflow:"hidden",border:"solid 1px #e6e6e6",padding:0,margin:0,marginBottom:"5px"},fg={position:"absolute",background:"#222",width:"100%",height:"100%",backgroundSize:"contain",backgroundPosition:"50% 50%",backgroundColor:Wt.COLORS.white,backgroundRepeat:"no-repeat",transition:"all .2s ease-in-out"},q1={...fg,transform:"scale(1.2)"},$1={marginTop:"1.5em",color:Wt.SECONDARY_COLOR.main,fontSize:"2em",opacity:"0.7",width:"100%"},H1={display:"block",height:"2em",margin:"0 auto",fontSize:"0.75em",fontStyle:"italic",lineHeight:"1em",WebkitLineClamp:"2",WebkitBoxOrient:"vertical",overflow:"hidden",textOverflow:"ellipsis"},G1={listStyle:"none",margin:"0px",padding:"0px",fontSize:"11px",marginBottom:"3px"},W1={display:"inline-block",background:"#337ab7",color:Wt.COLORS.white,padding:"1px 4px",marginRight:"3px",borderRadius:"3px"},dg=({element:n})=>{const[t,e]=F.useState(!1),{selectToolDrawingLine:r,selectToolDrawingItem:i,selectToolDrawingHole:s,pushLastSelectedCatalogElementToHistory:o}=ne(),a=()=>{switch(n.prototype){case"lines":r(n.name);break;case"items":i(n.name);break;case"holes":s(n.name);break}o(n)};return w.jsxs("div",{style:t?V1:cg,onClick:a,onMouseEnter:()=>e(!0),onMouseLeave:()=>e(!1),children:[w.jsx("b",{style:t?D1:hg,children:n.info.title}),w.jsx("div",{style:B1,children:w.jsx("div",{style:{...t?q1:fg,backgroundImage:"url("+n.info.image+")"},children:t?w.jsx(L1,{style:$1}):null})}),w.jsx("ul",{style:G1,children:n.info.tag.map((l,c)=>w.jsx("li",{style:W1,children:l},c))}),w.jsx("div",{style:H1,children:n.info.description})]})};function U1(n){return ge({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M21 10.12h-6.78l2.74-2.82c-2.73-2.7-7.15-2.8-9.88-.1-2.73 2.71-2.73 7.08 0 9.79s7.15 2.71 9.88 0C18.32 15.65 19 14.08 19 12.1h2c0 1.98-.88 4.55-2.64 6.29-3.51 3.48-9.21 3.48-12.72 0-3.5-3.47-3.53-9.11-.02-12.58s9.14-3.47 12.65 0L21 3v7.12zM12.5 8v4.25l3.5 2.08-.72 1.21L11 13V8h1.5z"},child:[]}]})(n)}function Y1(n){return ge({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M1 21h22L12 2 1 21zm12-3h-2v-2h2v2zm0-4h-2v-4h2v4z"},child:[]}]})(n)}function X1(n){return ge({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm5 11h-4v4h-2v-4H7v-2h4V7h2v4h4v2z"},child:[]}]})(n)}function J1(n){return ge({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M18.4 10.6C16.55 8.99 14.15 8 11.5 8c-4.65 0-8.58 3.03-9.96 7.22L3.9 16a8.002 8.002 0 0 1 7.6-5.5c1.95 0 3.73.72 5.12 1.88L13 16h9V7l-3.6 3.6z"},child:[]}]})(n)}function Z1(n){return ge({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M12.5 8c-2.65 0-5.05.99-6.9 2.6L2 7v9h9l-3.62-3.62c1.39-1.16 3.16-1.88 5.12-1.88 3.54 0 6.55 2.31 7.6 5.5l2.37-.78C21.08 11.03 17.15 8 12.5 8z"},child:[]}]})(n)}function K1(n){return ge({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M15.41 7.41 14 6l-6 6 6 6 1.41-1.41L10.83 12z"},child:[]}]})(n)}function pg(n){return ge({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z"},child:[]}]})(n)}function Q1(n){return ge({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 8h-6V5h6v6zm-8-6v6H5V5h6zm-6 8h6v6H5v-6zm8 6v-6h6v6h-6z"},child:[]}]})(n)}const tb={margin:"1.5em",display:"flex"},gg={fontSize:"20px",cursor:"pointer"},eb={...gg,fontWeight:"bolder",color:Wt.SECONDARY_COLOR.main},rb={fill:Wt.COLORS.black,fontSize:"24px",marginLeft:"10px",marginRight:"10px"},nb=({names:n})=>{let t=n.map((e,r)=>{let i=r===n.length-1;return w.jsxs("div",{style:{display:"flex"},children:[w.jsx("div",{style:i?eb:gg,onClick:e.action||null,children:e.name}),i?null:w.jsx(pg,{style:rb})]},r)});return w.jsx("div",{style:tb,children:t})},mg={width:"14em",height:"14em",padding:"0.625em",background:"#f7f7f9",border:"1px solid #e1e1e8",margin:"0.3em",cursor:"pointer",position:"relative",boxShadow:"0 1px 6px 0 rgba(0, 0, 0, 0.11), 0 1px 4px 0 rgba(0, 0, 0, 0.11)",borderRadius:"2px",transition:"all .2s ease-in-out",WebkitTransition:"all .2s ease-in-out"},ib={...mg,background:Wt.SECONDARY_COLOR.main},yg={position:"absolute",color:Wt.COLORS.black,fontSize:"5em",width:"100%"},sb={...yg,color:Wt.SECONDARY_COLOR.main},ob={background:Wt.COLORS.white,marginBottom:"5px",border:"solid 1px #e6e6e6",width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},ab=({page:n})=>{const[t,e]=F.useState(!1),{goBackToCatalogPage:r}=ne(),i=s=>{r(s)};return w.jsx("div",{style:t?ib:mg,onClick:()=>i(n.name),onMouseEnter:()=>e(!0),onMouseLeave:()=>e(!1),children:w.jsx("div",{style:ob,children:w.jsx(K1,{style:t?sb:yg})})})},ub={position:"fixed",width:"calc( 100% - 51px)",height:"calc( 100% - 20px)",backgroundColor:"#FFF",padding:"1em",left:50,overflowY:"auto",overflowX:"hidden",zIndex:10},lb={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(14em, 1fr))",gridGap:"10px",marginTop:"1em"},vg={width:"100%",height:"3em",padding:"0.625em",background:"#f7f7f9",border:"1px solid #e1e1e8",cursor:"pointer",position:"relative",boxShadow:"0 1px 6px 0 rgba(0, 0, 0, 0.11), 0 1px 4px 0 rgba(0, 0, 0, 0.11)",borderRadius:"2px",transition:"all .2s ease-in-out",WebkitTransition:"all .2s ease-in-out",marginBottom:"1em"},cb={width:"8em",display:"inline-block"},hb={width:"calc( 100% - 10em )",height:"2em",margin:"0",padding:"0 1em",border:"1px solid #EEE"},fb={...vg,padding:"0.2em 0.625em"},db={width:"auto",height:"2em",lineHeight:"2em",textAlign:"center",borderRadius:"1em",display:"inline-block",cursor:"pointer",backgroundColor:Wt.PRIMARY_COLOR.alt,color:Wt.PRIMARY_COLOR.text_main,textTransform:"capitalize",margin:"0.25em",padding:"0 1em"},pb=({width:n,height:t,style:e,catalog:r})=>{const{planner:i,goBackToCatalogPage:s,selectToolDrawingHole:o,selectToolDrawingItem:a,selectToolDrawingLine:l,pushLastSelectedCatalogElementToHistory:c}=ne();let h=i.catalog.page;const f=r.getCategory(h);let g=f.elements.filter(L=>L.info.visibility?L.info.visibility.catalog:!0);const[p,m]=F.useState(""),[v,_]=F.useState([]);let S=null;if(h!=="root"){let L=[];i.catalog.path.forEach(X=>{L.push({name:r.getCategory(X).label,action:()=>s(X)})}),L.push({name:f.label,action:""}),S=w.jsx(nb,{names:L})}let M=i.catalog.path.size,C=M>0?w.jsx(ab,{page:r.categories[i.catalog.path.get(M-1)]},M):null,O=i.get("selectedElementsHistory"),E=O.map((L,X)=>w.jsx("div",{style:db,title:L.name,onClick:()=>k(L),children:L.name},X));const z=L=>{let X=[];for(let J=0;J<L.length;J++){let at=L[J];X=X.concat(at.elements),at.categories.length&&(X=X.concat(z(at.categories)))}return X},R=L=>{let X=g.concat(z(f.categories)),J=[];if(L!=""){let at=new RegExp(L,"i");for(let tt=0;tt<X.length;tt++)at.test(X[tt].info.title)&&J.push(X[tt])}m(L),_(J)},k=L=>{switch(L.prototype){case"lines":l(L.name);break;case"items":a(L.name);break;case"holes":o(L.name);break}c(L)};return w.jsxs(M1,{width:n,height:t,style:{...ub,...e},children:[w.jsx(S1,{children:"Catalog"}),S,w.jsxs("div",{style:vg,children:[w.jsx("span",{style:cb,children:"Search Element"}),w.jsx("input",{type:"text",style:hb,onChange:L=>{R(L.target.value)}})]}),O.size?w.jsxs("div",{style:fb,children:[w.jsx("span",{children:"Last Selected"}),E]}):null,w.jsx("div",{style:lb,children:p===""?[C,g.map(L=>w.jsx(dg,{element:L},L.name))]:v.map(L=>w.jsx(dg,{element:L},L.name))})]})},gb={MODE_IDLE:fe,MODE_2D_ZOOM_IN:gi,MODE_2D_ZOOM_OUT:mi,MODE_2D_PAN:yi,MODE_WAITING_DRAWING_LINE:Lr,MODE_DRAGGING_LINE:Fr,MODE_DRAGGING_VERTEX:Nr,MODE_DRAGGING_ITEM:jr,MODE_DRAWING_LINE:or,MODE_DRAWING_HOLE:ar,MODE_DRAWING_ITEM:Sr,MODE_DRAGGING_HOLE:Vr,MODE_ROTATING_ITEM:An};function mb({width:n,height:t,catalog:e}){const{planner:r}=ne(),{mode:i}=r;return i===vi?w.jsx(w.Fragment,{}):i===Qi?w.jsx(w.Fragment,{}):i===zl?w.jsx(pb,{width:n,height:t,catalog:e}):gb[i]?w.jsx(b1,{width:n,height:t,catalog:e}):i===fd?w.jsx(w.Fragment,{}):null}function xg(n){var t,e,r="";if(typeof n=="string"||typeof n=="number")r+=n;else if(typeof n=="object")if(Array.isArray(n)){var i=n.length;for(t=0;t<i;t++)n[t]&&(e=xg(n[t]))&&(r&&(r+=" "),r+=e)}else for(e in n)n[e]&&(r&&(r+=" "),r+=e);return r}function yb(){for(var n,t,e=0,r="",i=arguments.length;e<i;e++)(n=arguments[e])&&(t=xg(n))&&(r&&(r+=" "),r+=t);return r}const Ac="-",vb=n=>{const t=_b(n),{conflictingClassGroups:e,conflictingClassGroupModifiers:r}=n;return{getClassGroupId:o=>{const a=o.split(Ac);return a[0]===""&&a.length!==1&&a.shift(),_g(a,t)||xb(o)},getConflictingClassGroupIds:(o,a)=>{const l=e[o]||[];return a&&r[o]?[...l,...r[o]]:l}}},_g=(n,t)=>{var o;if(n.length===0)return t.classGroupId;const e=n[0],r=t.nextPart.get(e),i=r?_g(n.slice(1),r):void 0;if(i)return i;if(t.validators.length===0)return;const s=n.join(Ac);return(o=t.validators.find(({validator:a})=>a(s)))==null?void 0:o.classGroupId},bg=/^\[(.+)\]$/,xb=n=>{if(bg.test(n)){const t=bg.exec(n)[1],e=t==null?void 0:t.substring(0,t.indexOf(":"));if(e)return"arbitrary.."+e}},_b=n=>{const{theme:t,classGroups:e}=n,r={nextPart:new Map,validators:[]};for(const i in e)Oc(e[i],r,i,t);return r},Oc=(n,t,e,r)=>{n.forEach(i=>{if(typeof i=="string"){const s=i===""?t:wg(t,i);s.classGroupId=e;return}if(typeof i=="function"){if(bb(i)){Oc(i(r),t,e,r);return}t.validators.push({validator:i,classGroupId:e});return}Object.entries(i).forEach(([s,o])=>{Oc(o,wg(t,s),e,r)})})},wg=(n,t)=>{let e=n;return t.split(Ac).forEach(r=>{e.nextPart.has(r)||e.nextPart.set(r,{nextPart:new Map,validators:[]}),e=e.nextPart.get(r)}),e},bb=n=>n.isThemeGetter,wb=n=>{if(n<1)return{get:()=>{},set:()=>{}};let t=0,e=new Map,r=new Map;const i=(s,o)=>{e.set(s,o),t++,t>n&&(t=0,r=e,e=new Map)};return{get(s){let o=e.get(s);if(o!==void 0)return o;if((o=r.get(s))!==void 0)return i(s,o),o},set(s,o){e.has(s)?e.set(s,o):i(s,o)}}},zc="!",Tc=":",Sb=Tc.length,Eb=n=>{const{prefix:t,experimentalParseClassName:e}=n;let r=i=>{const s=[];let o=0,a=0,l=0,c;for(let m=0;m<i.length;m++){let v=i[m];if(o===0&&a===0){if(v===Tc){s.push(i.slice(l,m)),l=m+Sb;continue}if(v==="/"){c=m;continue}}v==="["?o++:v==="]"?o--:v==="("?a++:v===")"&&a--}const h=s.length===0?i:i.substring(l),f=Mb(h),g=f!==h,p=c&&c>l?c-l:void 0;return{modifiers:s,hasImportantModifier:g,baseClassName:f,maybePostfixModifierPosition:p}};if(t){const i=t+Tc,s=r;r=o=>o.startsWith(i)?s(o.substring(i.length)):{isExternal:!0,modifiers:[],hasImportantModifier:!1,baseClassName:o,maybePostfixModifierPosition:void 0}}if(e){const i=r;r=s=>e({className:s,parseClassName:i})}return r},Mb=n=>n.endsWith(zc)?n.substring(0,n.length-1):n.startsWith(zc)?n.substring(1):n,Ab=n=>{const t=Object.fromEntries(n.orderSensitiveModifiers.map(r=>[r,!0]));return r=>{if(r.length<=1)return r;const i=[];let s=[];return r.forEach(o=>{o[0]==="["||t[o]?(i.push(...s.sort(),o),s=[]):s.push(o)}),i.push(...s.sort()),i}},Ob=n=>({cache:wb(n.cacheSize),parseClassName:Eb(n),sortModifiers:Ab(n),...vb(n)}),zb=/\s+/,Tb=(n,t)=>{const{parseClassName:e,getClassGroupId:r,getConflictingClassGroupIds:i,sortModifiers:s}=t,o=[],a=n.trim().split(zb);let l="";for(let c=a.length-1;c>=0;c-=1){const h=a[c],{isExternal:f,modifiers:g,hasImportantModifier:p,baseClassName:m,maybePostfixModifierPosition:v}=e(h);if(f){l=h+(l.length>0?" "+l:l);continue}let _=!!v,S=r(_?m.substring(0,v):m);if(!S){if(!_){l=h+(l.length>0?" "+l:l);continue}if(S=r(m),!S){l=h+(l.length>0?" "+l:l);continue}_=!1}const M=s(g).join(":"),C=p?M+zc:M,O=C+S;if(o.includes(O))continue;o.push(O);const E=i(S,_);for(let z=0;z<E.length;++z){const R=E[z];o.push(C+R)}l=h+(l.length>0?" "+l:l)}return l};function Cb(){let n=0,t,e,r="";for(;n<arguments.length;)(t=arguments[n++])&&(e=Sg(t))&&(r&&(r+=" "),r+=e);return r}const Sg=n=>{if(typeof n=="string")return n;let t,e="";for(let r=0;r<n.length;r++)n[r]&&(t=Sg(n[r]))&&(e&&(e+=" "),e+=t);return e};function Ib(n,...t){let e,r,i,s=o;function o(l){const c=t.reduce((h,f)=>f(h),n());return e=Ob(c),r=e.cache.get,i=e.cache.set,s=a,a(l)}function a(l){const c=r(l);if(c)return c;const h=Tb(l,e);return i(l,h),h}return function(){return s(Cb.apply(null,arguments))}}const Ae=n=>{const t=e=>e[n]||[];return t.isThemeGetter=!0,t},Eg=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Mg=/^\((?:(\w[\w-]*):)?(.+)\)$/i,kb=/^\d+\/\d+$/,Pb=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Rb=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,Lb=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Fb=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Nb=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,ls=n=>kb.test(n),It=n=>!!n&&!Number.isNaN(Number(n)),Zn=n=>!!n&&Number.isInteger(Number(n)),Cc=n=>n.endsWith("%")&&It(n.slice(0,-1)),Tn=n=>Pb.test(n),jb=()=>!0,Vb=n=>Rb.test(n)&&!Lb.test(n),Ag=()=>!1,Db=n=>Fb.test(n),Bb=n=>Nb.test(n),qb=n=>!lt(n)&&!ct(n),$b=n=>cs(n,Ig,Ag),lt=n=>Eg.test(n),wi=n=>cs(n,kg,Vb),Ic=n=>cs(n,Yb,It),Og=n=>cs(n,Tg,Ag),Hb=n=>cs(n,Cg,Bb),Ha=n=>cs(n,Pg,Db),ct=n=>Mg.test(n),xo=n=>hs(n,kg),Gb=n=>hs(n,Xb),zg=n=>hs(n,Tg),Wb=n=>hs(n,Ig),Ub=n=>hs(n,Cg),Ga=n=>hs(n,Pg,!0),cs=(n,t,e)=>{const r=Eg.exec(n);return r?r[1]?t(r[1]):e(r[2]):!1},hs=(n,t,e=!1)=>{const r=Mg.exec(n);return r?r[1]?t(r[1]):e:!1},Tg=n=>n==="position"||n==="percentage",Cg=n=>n==="image"||n==="url",Ig=n=>n==="length"||n==="size"||n==="bg-size",kg=n=>n==="length",Yb=n=>n==="number",Xb=n=>n==="family-name",Pg=n=>n==="shadow",Jb=Ib(()=>{const n=Ae("color"),t=Ae("font"),e=Ae("text"),r=Ae("font-weight"),i=Ae("tracking"),s=Ae("leading"),o=Ae("breakpoint"),a=Ae("container"),l=Ae("spacing"),c=Ae("radius"),h=Ae("shadow"),f=Ae("inset-shadow"),g=Ae("text-shadow"),p=Ae("drop-shadow"),m=Ae("blur"),v=Ae("perspective"),_=Ae("aspect"),S=Ae("ease"),M=Ae("animate"),C=()=>["auto","avoid","all","avoid-page","page","left","right","column"],O=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],E=()=>[...O(),ct,lt],z=()=>["auto","hidden","clip","visible","scroll"],R=()=>["auto","contain","none"],k=()=>[ct,lt,l],L=()=>[ls,"full","auto",...k()],X=()=>[Zn,"none","subgrid",ct,lt],J=()=>["auto",{span:["full",Zn,ct,lt]},Zn,ct,lt],at=()=>[Zn,"auto",ct,lt],tt=()=>["auto","min","max","fr",ct,lt],bt=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],xt=()=>["start","end","center","stretch","center-safe","end-safe"],yt=()=>["auto",...k()],ht=()=>[ls,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...k()],Y=()=>[n,ct,lt],St=()=>[...O(),zg,Og,{position:[ct,lt]}],j=()=>["no-repeat",{repeat:["","x","y","space","round"]}],W=()=>["auto","cover","contain",Wb,$b,{size:[ct,lt]}],ft=()=>[Cc,xo,wi],et=()=>["","none","full",c,ct,lt],rt=()=>["",It,xo,wi],Z=()=>["solid","dashed","dotted","double"],Q=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],U=()=>[It,Cc,zg,Og],st=()=>["","none",m,ct,lt],vt=()=>["none",It,ct,lt],B=()=>["none",It,ct,lt],pt=()=>[It,ct,lt],H=()=>[ls,"full",...k()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Tn],breakpoint:[Tn],color:[jb],container:[Tn],"drop-shadow":[Tn],ease:["in","out","in-out"],font:[qb],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Tn],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Tn],shadow:[Tn],spacing:["px",It],text:[Tn],"text-shadow":[Tn],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",ls,lt,ct,_]}],container:["container"],columns:[{columns:[It,lt,ct,a]}],"break-after":[{"break-after":C()}],"break-before":[{"break-before":C()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:E()}],overflow:[{overflow:z()}],"overflow-x":[{"overflow-x":z()}],"overflow-y":[{"overflow-y":z()}],overscroll:[{overscroll:R()}],"overscroll-x":[{"overscroll-x":R()}],"overscroll-y":[{"overscroll-y":R()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:L()}],"inset-x":[{"inset-x":L()}],"inset-y":[{"inset-y":L()}],start:[{start:L()}],end:[{end:L()}],top:[{top:L()}],right:[{right:L()}],bottom:[{bottom:L()}],left:[{left:L()}],visibility:["visible","invisible","collapse"],z:[{z:[Zn,"auto",ct,lt]}],basis:[{basis:[ls,"full","auto",a,...k()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[It,ls,"auto","initial","none",lt]}],grow:[{grow:["",It,ct,lt]}],shrink:[{shrink:["",It,ct,lt]}],order:[{order:[Zn,"first","last","none",ct,lt]}],"grid-cols":[{"grid-cols":X()}],"col-start-end":[{col:J()}],"col-start":[{"col-start":at()}],"col-end":[{"col-end":at()}],"grid-rows":[{"grid-rows":X()}],"row-start-end":[{row:J()}],"row-start":[{"row-start":at()}],"row-end":[{"row-end":at()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":tt()}],"auto-rows":[{"auto-rows":tt()}],gap:[{gap:k()}],"gap-x":[{"gap-x":k()}],"gap-y":[{"gap-y":k()}],"justify-content":[{justify:[...bt(),"normal"]}],"justify-items":[{"justify-items":[...xt(),"normal"]}],"justify-self":[{"justify-self":["auto",...xt()]}],"align-content":[{content:["normal",...bt()]}],"align-items":[{items:[...xt(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...xt(),{baseline:["","last"]}]}],"place-content":[{"place-content":bt()}],"place-items":[{"place-items":[...xt(),"baseline"]}],"place-self":[{"place-self":["auto",...xt()]}],p:[{p:k()}],px:[{px:k()}],py:[{py:k()}],ps:[{ps:k()}],pe:[{pe:k()}],pt:[{pt:k()}],pr:[{pr:k()}],pb:[{pb:k()}],pl:[{pl:k()}],m:[{m:yt()}],mx:[{mx:yt()}],my:[{my:yt()}],ms:[{ms:yt()}],me:[{me:yt()}],mt:[{mt:yt()}],mr:[{mr:yt()}],mb:[{mb:yt()}],ml:[{ml:yt()}],"space-x":[{"space-x":k()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":k()}],"space-y-reverse":["space-y-reverse"],size:[{size:ht()}],w:[{w:[a,"screen",...ht()]}],"min-w":[{"min-w":[a,"screen","none",...ht()]}],"max-w":[{"max-w":[a,"screen","none","prose",{screen:[o]},...ht()]}],h:[{h:["screen","lh",...ht()]}],"min-h":[{"min-h":["screen","lh","none",...ht()]}],"max-h":[{"max-h":["screen","lh",...ht()]}],"font-size":[{text:["base",e,xo,wi]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,ct,Ic]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Cc,lt]}],"font-family":[{font:[Gb,lt,t]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[i,ct,lt]}],"line-clamp":[{"line-clamp":[It,"none",ct,Ic]}],leading:[{leading:[s,...k()]}],"list-image":[{"list-image":["none",ct,lt]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",ct,lt]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:Y()}],"text-color":[{text:Y()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...Z(),"wavy"]}],"text-decoration-thickness":[{decoration:[It,"from-font","auto",ct,wi]}],"text-decoration-color":[{decoration:Y()}],"underline-offset":[{"underline-offset":[It,"auto",ct,lt]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:k()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",ct,lt]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",ct,lt]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:St()}],"bg-repeat":[{bg:j()}],"bg-size":[{bg:W()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Zn,ct,lt],radial:["",ct,lt],conic:[Zn,ct,lt]},Ub,Hb]}],"bg-color":[{bg:Y()}],"gradient-from-pos":[{from:ft()}],"gradient-via-pos":[{via:ft()}],"gradient-to-pos":[{to:ft()}],"gradient-from":[{from:Y()}],"gradient-via":[{via:Y()}],"gradient-to":[{to:Y()}],rounded:[{rounded:et()}],"rounded-s":[{"rounded-s":et()}],"rounded-e":[{"rounded-e":et()}],"rounded-t":[{"rounded-t":et()}],"rounded-r":[{"rounded-r":et()}],"rounded-b":[{"rounded-b":et()}],"rounded-l":[{"rounded-l":et()}],"rounded-ss":[{"rounded-ss":et()}],"rounded-se":[{"rounded-se":et()}],"rounded-ee":[{"rounded-ee":et()}],"rounded-es":[{"rounded-es":et()}],"rounded-tl":[{"rounded-tl":et()}],"rounded-tr":[{"rounded-tr":et()}],"rounded-br":[{"rounded-br":et()}],"rounded-bl":[{"rounded-bl":et()}],"border-w":[{border:rt()}],"border-w-x":[{"border-x":rt()}],"border-w-y":[{"border-y":rt()}],"border-w-s":[{"border-s":rt()}],"border-w-e":[{"border-e":rt()}],"border-w-t":[{"border-t":rt()}],"border-w-r":[{"border-r":rt()}],"border-w-b":[{"border-b":rt()}],"border-w-l":[{"border-l":rt()}],"divide-x":[{"divide-x":rt()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":rt()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...Z(),"hidden","none"]}],"divide-style":[{divide:[...Z(),"hidden","none"]}],"border-color":[{border:Y()}],"border-color-x":[{"border-x":Y()}],"border-color-y":[{"border-y":Y()}],"border-color-s":[{"border-s":Y()}],"border-color-e":[{"border-e":Y()}],"border-color-t":[{"border-t":Y()}],"border-color-r":[{"border-r":Y()}],"border-color-b":[{"border-b":Y()}],"border-color-l":[{"border-l":Y()}],"divide-color":[{divide:Y()}],"outline-style":[{outline:[...Z(),"none","hidden"]}],"outline-offset":[{"outline-offset":[It,ct,lt]}],"outline-w":[{outline:["",It,xo,wi]}],"outline-color":[{outline:Y()}],shadow:[{shadow:["","none",h,Ga,Ha]}],"shadow-color":[{shadow:Y()}],"inset-shadow":[{"inset-shadow":["none",f,Ga,Ha]}],"inset-shadow-color":[{"inset-shadow":Y()}],"ring-w":[{ring:rt()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:Y()}],"ring-offset-w":[{"ring-offset":[It,wi]}],"ring-offset-color":[{"ring-offset":Y()}],"inset-ring-w":[{"inset-ring":rt()}],"inset-ring-color":[{"inset-ring":Y()}],"text-shadow":[{"text-shadow":["none",g,Ga,Ha]}],"text-shadow-color":[{"text-shadow":Y()}],opacity:[{opacity:[It,ct,lt]}],"mix-blend":[{"mix-blend":[...Q(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":Q()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[It]}],"mask-image-linear-from-pos":[{"mask-linear-from":U()}],"mask-image-linear-to-pos":[{"mask-linear-to":U()}],"mask-image-linear-from-color":[{"mask-linear-from":Y()}],"mask-image-linear-to-color":[{"mask-linear-to":Y()}],"mask-image-t-from-pos":[{"mask-t-from":U()}],"mask-image-t-to-pos":[{"mask-t-to":U()}],"mask-image-t-from-color":[{"mask-t-from":Y()}],"mask-image-t-to-color":[{"mask-t-to":Y()}],"mask-image-r-from-pos":[{"mask-r-from":U()}],"mask-image-r-to-pos":[{"mask-r-to":U()}],"mask-image-r-from-color":[{"mask-r-from":Y()}],"mask-image-r-to-color":[{"mask-r-to":Y()}],"mask-image-b-from-pos":[{"mask-b-from":U()}],"mask-image-b-to-pos":[{"mask-b-to":U()}],"mask-image-b-from-color":[{"mask-b-from":Y()}],"mask-image-b-to-color":[{"mask-b-to":Y()}],"mask-image-l-from-pos":[{"mask-l-from":U()}],"mask-image-l-to-pos":[{"mask-l-to":U()}],"mask-image-l-from-color":[{"mask-l-from":Y()}],"mask-image-l-to-color":[{"mask-l-to":Y()}],"mask-image-x-from-pos":[{"mask-x-from":U()}],"mask-image-x-to-pos":[{"mask-x-to":U()}],"mask-image-x-from-color":[{"mask-x-from":Y()}],"mask-image-x-to-color":[{"mask-x-to":Y()}],"mask-image-y-from-pos":[{"mask-y-from":U()}],"mask-image-y-to-pos":[{"mask-y-to":U()}],"mask-image-y-from-color":[{"mask-y-from":Y()}],"mask-image-y-to-color":[{"mask-y-to":Y()}],"mask-image-radial":[{"mask-radial":[ct,lt]}],"mask-image-radial-from-pos":[{"mask-radial-from":U()}],"mask-image-radial-to-pos":[{"mask-radial-to":U()}],"mask-image-radial-from-color":[{"mask-radial-from":Y()}],"mask-image-radial-to-color":[{"mask-radial-to":Y()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":O()}],"mask-image-conic-pos":[{"mask-conic":[It]}],"mask-image-conic-from-pos":[{"mask-conic-from":U()}],"mask-image-conic-to-pos":[{"mask-conic-to":U()}],"mask-image-conic-from-color":[{"mask-conic-from":Y()}],"mask-image-conic-to-color":[{"mask-conic-to":Y()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:St()}],"mask-repeat":[{mask:j()}],"mask-size":[{mask:W()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",ct,lt]}],filter:[{filter:["","none",ct,lt]}],blur:[{blur:st()}],brightness:[{brightness:[It,ct,lt]}],contrast:[{contrast:[It,ct,lt]}],"drop-shadow":[{"drop-shadow":["","none",p,Ga,Ha]}],"drop-shadow-color":[{"drop-shadow":Y()}],grayscale:[{grayscale:["",It,ct,lt]}],"hue-rotate":[{"hue-rotate":[It,ct,lt]}],invert:[{invert:["",It,ct,lt]}],saturate:[{saturate:[It,ct,lt]}],sepia:[{sepia:["",It,ct,lt]}],"backdrop-filter":[{"backdrop-filter":["","none",ct,lt]}],"backdrop-blur":[{"backdrop-blur":st()}],"backdrop-brightness":[{"backdrop-brightness":[It,ct,lt]}],"backdrop-contrast":[{"backdrop-contrast":[It,ct,lt]}],"backdrop-grayscale":[{"backdrop-grayscale":["",It,ct,lt]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[It,ct,lt]}],"backdrop-invert":[{"backdrop-invert":["",It,ct,lt]}],"backdrop-opacity":[{"backdrop-opacity":[It,ct,lt]}],"backdrop-saturate":[{"backdrop-saturate":[It,ct,lt]}],"backdrop-sepia":[{"backdrop-sepia":["",It,ct,lt]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":k()}],"border-spacing-x":[{"border-spacing-x":k()}],"border-spacing-y":[{"border-spacing-y":k()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",ct,lt]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[It,"initial",ct,lt]}],ease:[{ease:["linear","initial",S,ct,lt]}],delay:[{delay:[It,ct,lt]}],animate:[{animate:["none",M,ct,lt]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[v,ct,lt]}],"perspective-origin":[{"perspective-origin":E()}],rotate:[{rotate:vt()}],"rotate-x":[{"rotate-x":vt()}],"rotate-y":[{"rotate-y":vt()}],"rotate-z":[{"rotate-z":vt()}],scale:[{scale:B()}],"scale-x":[{"scale-x":B()}],"scale-y":[{"scale-y":B()}],"scale-z":[{"scale-z":B()}],"scale-3d":["scale-3d"],skew:[{skew:pt()}],"skew-x":[{"skew-x":pt()}],"skew-y":[{"skew-y":pt()}],transform:[{transform:[ct,lt,"","none","gpu","cpu"]}],"transform-origin":[{origin:E()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:H()}],"translate-x":[{"translate-x":H()}],"translate-y":[{"translate-y":H()}],"translate-z":[{"translate-z":H()}],"translate-none":["translate-none"],accent:[{accent:Y()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:Y()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",ct,lt]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":k()}],"scroll-mx":[{"scroll-mx":k()}],"scroll-my":[{"scroll-my":k()}],"scroll-ms":[{"scroll-ms":k()}],"scroll-me":[{"scroll-me":k()}],"scroll-mt":[{"scroll-mt":k()}],"scroll-mr":[{"scroll-mr":k()}],"scroll-mb":[{"scroll-mb":k()}],"scroll-ml":[{"scroll-ml":k()}],"scroll-p":[{"scroll-p":k()}],"scroll-px":[{"scroll-px":k()}],"scroll-py":[{"scroll-py":k()}],"scroll-ps":[{"scroll-ps":k()}],"scroll-pe":[{"scroll-pe":k()}],"scroll-pt":[{"scroll-pt":k()}],"scroll-pr":[{"scroll-pr":k()}],"scroll-pb":[{"scroll-pb":k()}],"scroll-pl":[{"scroll-pl":k()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",ct,lt]}],fill:[{fill:["none",...Y()]}],"stroke-w":[{stroke:[It,xo,wi,Ic]}],stroke:[{stroke:["none",...Y()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}});function Hr(...n){return Jb(yb(n))}const _o=({text:n,title:t,toggleState:e,toggleOn:r,toggleOff:i})=>{const[s,o]=F.useState(!1),[a,l]=F.useState(e||!1),c=()=>{l(!a),a?i():r()};return w.jsx("div",{className:Hr("w-[5.5em] text-center cursor-pointer select-none rounded-sm - mt-px mr-[5px] mb-0 ml-[5px] inline-block",s||a?"bg-[#5e5e5e] text-white border border-[#FFFFFF]":"text-[#CCCCCC] border border-[transparent]"),onMouseOver:()=>o(!0),onMouseOut:()=>o(!1),onClick:c,title:t,children:n})},Rg=({title:n,icon:t,textStyle:e,text:r,titleStyle:i,content:s})=>{const[o,a]=F.useState(!1),[l,c]=F.useState(!1);return w.jsxs("div",{className:"w-auto inline-block m-0 pr-1.5",children:[w.jsxs("div",{className:Hr("flex items-center cursor-pointer text-center select-none",o?"text-white":"text-[#CCCCCC]"),onClick:()=>a(!o),title:n,children:[t&&t(),w.jsx("span",{className:"relative",style:e,children:r})]}),w.jsxs("div",{className:Hr("fixed left-0 w-[calc(100%_-_2px)] transition-all duration-300 ease-in-out z-0 bottom-5 p-0 m-0 bg-[#2E2F33] border-t border-t-[#555]",o?"h-[40%]":"invisible h-0"),children:[w.jsxs("div",{className:"relative w-full h-[2em] top-0 left-0 border-b border-b-[#555]",children:[w.jsx("b",{className:"relative h-[2em] ml-[1em] leading-[2em]",style:i,children:n}),w.jsx(N1,{className:Hr("absolute w-[2em] h-[2em] right-0 top-0 cursor-pointer p-2 border-l border-l-[#555]",l?"text-white bg-[#005FAF]":""),onMouseOver:()=>c(!0),onMouseOut:()=>c(!1),onClick:()=>a(!o)})]}),w.jsx("div",{className:"relative w-full p-[1em] overflow-y-auto h-[calc(100%_-_2em)]",children:s})]})]})};function Zb(n){return ge({attr:{fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor","aria-hidden":"true"},child:[{tag:"path",attr:{strokeLinecap:"round",strokeLinejoin:"round",d:"m21 21-5.197-5.197m0 0A7.5 7.5 0 1 0 5.196 5.196a7.5 7.5 0 0 0 10.607 10.607ZM13.5 10.5h-6"},child:[]}]})(n)}function Kb(n){return ge({attr:{fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor","aria-hidden":"true"},child:[{tag:"path",attr:{strokeLinecap:"round",strokeLinejoin:"round",d:"m21 21-5.197-5.197m0 0A7.5 7.5 0 1 0 5.196 5.196a7.5 7.5 0 0 0 10.607 10.607ZM10.5 7.5v6m3-3h-6"},child:[]}]})(n)}function Qb(n,t,e,r,i){return r+(i-r)*(n-t)/(e-t)}const tw=()=>{const{planner:n,toggleSnap:t,viewer:e}=ne(),{mode:r,mouse:i,zoom:s,snapMask:o}=n,a=n.get("warnings").toArray(),l=n.get("errors").toArray(),c=f=>t(o.merge(f)),h=f=>{const g=parseInt(ig(s).toFixed());if(g===0&&f==="out"||g===100&&f==="in"||!e)return;const p=e==null?void 0:e.getValue(),m=p.viewerWidth/2,v=p.viewerHeight/2,_=f==="in"?-1:1,S=1.06,M=Math.max(-1,Math.min(1,_)),C=Qb(M,-1,1,S,1/S);e.zoom(m,v,C)};return w.jsxs("div",{className:"floor_planner-footerbar absolute z-[9001] py-[3px] px-[1em] text-xs bg-[#424242] h-5 w-full select-none cursor-default bottom-0 leading-[14px] text-white m-0",children:[Tl.includes(r)&&w.jsxs(w.Fragment,{children:[w.jsx("div",{className:"relative float-left px-[1em] inline-block border-r border-r-white",title:"Scene Zoom Level",children:w.jsxs("div",{className:"flex items-center gap-2",children:[w.jsx("span",{children:"Zoom:"})," ",w.jsx(Zb,{className:"inline-block cursor-pointer",size:16,onClick:()=>h("out")})," ",w.jsxs("span",{children:[ig(s).toFixed(),"%"]})," ",w.jsx(Kb,{className:"inline-block cursor-pointer",size:16,onClick:()=>h("in")})]})}),w.jsxs("div",{className:"relative float-left px-[1em] inline-block border-r border-r-white",children:[w.jsx(_o,{toggleOn:()=>{c({SNAP_POINT:!0})},toggleOff:()=>{c({SNAP_POINT:!1})},text:"Snap PT",toggleState:o.get(Pl),title:"Snap to Point"}),w.jsx(_o,{toggleOn:()=>{c({SNAP_LINE:!0})},toggleOff:()=>{c({SNAP_LINE:!1})},text:"Snap LN",toggleState:o.get(Rl),title:"Snap to Line"}),w.jsx(_o,{toggleOn:()=>{c({SNAP_SEGMENT:!0})},toggleOff:()=>{c({SNAP_SEGMENT:!1})},text:"Snap SEG",toggleState:o.get(Ll),title:"Snap to Segment"}),w.jsx(_o,{toggleOn:()=>{c({SNAP_GRID:!0})},toggleOff:()=>{c({SNAP_GRID:!1})},text:"Snap GRD",toggleState:o.get(Fl),title:"Snap to Grid"}),w.jsx(_o,{toggleOn:()=>{c({SNAP_GUIDE:!0})},toggleOff:()=>{c({SNAP_GUIDE:!1})},text:"Snap GDE",toggleState:o.get(md),title:"Snap to Guide"})]})]}),w.jsxs("div",{className:"relative float-right inline-block px-[1em] border-l border-l-white",children:[w.jsx(Rg,{icon:()=>w.jsx(X1,{style:{width:"15px",height:"15px",marginTop:"-2px",marginRight:"2px",...l.length?{transform:"rotate(45deg)",color:"#F44336"}:{transform:"rotate(45deg)"}}}),text:l.length.toString(),textStyle:l.length?{color:"#F44336"}:{},title:`Errors [ ${l.length} ]`,titleStyle:l.length?{color:"#F44336"}:{},content:w.jsx(w.Fragment,{children:l.map((f,g)=>w.jsxs("div",{style:{borderBottom:"1px solid #555",lineHeight:"1.5em"},children:["[ ",new Date(f.date).toLocaleString()," ] ",f.error]},g))})}),w.jsx(Rg,{icon:()=>w.jsx(Y1,{style:{width:"15px",height:"15px",marginTop:"-2px",marginRight:"2px",...a.length?{color:"#FFEB3B"}:{}}}),text:a.length.toString(),textStyle:a.length?{color:"#FFEB3B"}:{},title:`Warnings [ ${a.length} ]`,titleStyle:a.length?{color:"#FFEB3B"}:{},content:w.jsx(w.Fragment,{children:a.map((f,g)=>w.jsxs("div",{className:"leading-6 border-b border-b-[#555555]",children:["[ ",new Date(f.date).toLocaleString()," ] ",f.warning]},g))})})]})]})},Lg=({children:n,name:t,...e})=>{const[r,i]=F.useState(e.opened||!1);return w.jsxs("div",{className:"select-none",style:{borderBottom:"1px solid #5e5e5e"},children:[w.jsxs("div",{className:"flex px-4 pt-2.5 pb-3 items-center gap-1 bg-[#2b2b2b] text-white cursor-pointer",onClick:()=>i(!r),children:[r?w.jsx(P1,{size:16}):w.jsx(R1,{size:16}),w.jsx("span",{className:"text-sm leading-none",children:t})]}),w.jsx("div",{className:Hr("text-[11px] text-[#EBEBEB] border border-[#222222] bg-[#424242]",r?"block":"hidden"),children:n})]})};function Gr({children:n,style:t,className:e,...r}){return w.jsx("label",{className:Hr("mb-1 text-xs capitalize font-bold text-white block",e),style:t,...r,children:n})}const Cn=({value:n,min:t,max:e,precision:r,onChange:i,onValid:s,onInvalid:o,style:a,placeholder:l})=>{const[c,h]=F.useState(!0),[f,g]=F.useState(n);let p=new RegExp(`^-?([0-9]+)?\\.?([0-9]{0,${r}})?$`);F.useEffect(()=>{t!==void 0&&!isNaN(t)&&isFinite(t)&&Number(f)<t&&g(t),e&&!isNaN(e)&&isFinite(e)&&Number(f)>e&&g(e)},[t,e,f]);const m=F.useMemo(()=>parseFloat(String(n)).toFixed(r)!==parseFloat(String(f)).toFixed(r),[n,f,r]),v=_=>{if(_.stopPropagation(),c){let S=f!==""&&f!=="-"?parseFloat(String(f)):0;g(S),i({target:{value:S}})}};return w.jsxs("div",{className:"relative w-full",children:[w.jsx("input",{type:"text",value:p.test(String(f))?f:parseFloat(String(f)).toFixed(r),className:"block text-[13px] text-white h-[35px] w-full px-2 leading-5 rounded border border-[#5e5e5e] bg-[#2b2b2b] outline-none focus:outline-none",style:{...a},onChange:_=>{let S=p.test(_.target.value);S?(g(_.target.value),s&&s(_.nativeEvent)):o&&o(_.nativeEvent),h(S)},onKeyDown:_=>{var S=_.keyCode||_.which;(S==Er.ENTER||S==Er.TAB)&&m&&v(_)},placeholder:l}),w.jsx("div",{onClick:_=>{m&&v(_)},title:"Confirm",className:"absolute cursor-pointer w-[2em] h-[2em] text-white top-[0.35em] right-[0.35em] bg-[#1CA6FC]",style:{transition:"all 0.1s linear",visibility:m?"visible":"hidden",opacity:m?"1":"0"},children:w.jsx(U1,{style:{width:"100%",height:"100%",padding:"0.2em",color:"#FFF"}})})]})},ew={mm:{name:{singular:"Millimeter",plural:"Millimeters"},to_anchor:1/1e3},cm:{name:{singular:"Centimeter",plural:"Centimeters"},to_anchor:1/100},m:{name:{singular:"Meter",plural:"Meters"},to_anchor:1},km:{name:{singular:"Kilometer",plural:"Kilometers"},to_anchor:1e3}},rw={in:{name:{singular:"Inch",plural:"Inches"},to_anchor:1/12},yd:{name:{singular:"Yard",plural:"Yards"},to_anchor:3},"ft-us":{name:{singular:"US Survey Foot",plural:"US Survey Feet"},to_anchor:1.000002},ft:{name:{singular:"Foot",plural:"Feet"},to_anchor:1},mi:{name:{singular:"Mile",plural:"Miles"},to_anchor:5280}},nw={metric:ew,imperial:rw,_anchors:{metric:{unit:"m",ratio:3.28084},imperial:{unit:"ft",ratio:1/3.28084}}},iw={mm2:{name:{singular:"Square Millimeter",plural:"Square Millimeters"},to_anchor:1/1e6},cm2:{name:{singular:"Centimeter",plural:"Centimeters"},to_anchor:1/1e4},m2:{name:{singular:"Square Meter",plural:"Square Meters"},to_anchor:1},ha:{name:{singular:"Hectare",plural:"Hectares"},to_anchor:1e4},km2:{name:{singular:"Square Kilometer",plural:"Square Kilometers"},to_anchor:1e6}},sw={in2:{name:{singular:"Square Inch",plural:"Square Inches"},to_anchor:1/144},yd2:{name:{singular:"Square Yard",plural:"Square Yards"},to_anchor:9},ft2:{name:{singular:"Square Foot",plural:"Square Feet"},to_anchor:1},ac:{name:{singular:"Acre",plural:"Acres"},to_anchor:43560},mi2:{name:{singular:"Square Mile",plural:"Square Miles"},to_anchor:27878400}},ow={metric:iw,imperial:sw,_anchors:{metric:{unit:"m2",ratio:10.7639},imperial:{unit:"ft2",ratio:1/10.7639}}},aw={mcg:{name:{singular:"Microgram",plural:"Micrograms"},to_anchor:1/1e6},mg:{name:{singular:"Milligram",plural:"Milligrams"},to_anchor:1/1e3},g:{name:{singular:"Gram",plural:"Grams"},to_anchor:1},kg:{name:{singular:"Kilogram",plural:"Kilograms"},to_anchor:1e3},mt:{name:{singular:"Metric Tonne",plural:"Metric Tonnes"},to_anchor:1e6}},uw={oz:{name:{singular:"Ounce",plural:"Ounces"},to_anchor:1/16},lb:{name:{singular:"Pound",plural:"Pounds"},to_anchor:1},t:{name:{singular:"Ton",plural:"Tons"},to_anchor:2e3}},lw={metric:aw,imperial:uw,_anchors:{metric:{unit:"g",ratio:1/453.592},imperial:{unit:"lb",ratio:453.592}}},cw={mm3:{name:{singular:"Cubic Millimeter",plural:"Cubic Millimeters"},to_anchor:1/1e6},cm3:{name:{singular:"Cubic Centimeter",plural:"Cubic Centimeters"},to_anchor:1/1e3},ml:{name:{singular:"Millilitre",plural:"Millilitres"},to_anchor:1/1e3},cl:{name:{singular:"Centilitre",plural:"Centilitres"},to_anchor:1/100},dl:{name:{singular:"Decilitre",plural:"Decilitres"},to_anchor:1/10},l:{name:{singular:"Litre",plural:"Litres"},to_anchor:1},kl:{name:{singular:"Kilolitre",plural:"Kilolitres"},to_anchor:1e3},m3:{name:{singular:"Cubic meter",plural:"Cubic meters"},to_anchor:1e3},km3:{name:{singular:"Cubic kilometer",plural:"Cubic kilometers"},to_anchor:1e12},krm:{name:{singular:"Matsked",plural:"Matskedar"},to_anchor:1/1e3},tsk:{name:{singular:"Tesked",plural:"Teskedar"},to_anchor:5/1e3},msk:{name:{singular:"Matsked",plural:"Matskedar"},to_anchor:15/1e3},kkp:{name:{singular:"Kaffekopp",plural:"Kaffekoppar"},to_anchor:150/1e3},glas:{name:{singular:"Glas",plural:"Glas"},to_anchor:200/1e3},kanna:{name:{singular:"Kanna",plural:"Kannor"},to_anchor:2.617}},hw={tsp:{name:{singular:"Teaspoon",plural:"Teaspoons"},to_anchor:1/6},Tbs:{name:{singular:"Tablespoon",plural:"Tablespoons"},to_anchor:1/2},in3:{name:{singular:"Cubic inch",plural:"Cubic inches"},to_anchor:.55411},"fl-oz":{name:{singular:"Fluid Ounce",plural:"Fluid Ounces"},to_anchor:1},cup:{name:{singular:"Cup",plural:"Cups"},to_anchor:8},pnt:{name:{singular:"Pint",plural:"Pints"},to_anchor:16},qt:{name:{singular:"Quart",plural:"Quarts"},to_anchor:32},gal:{name:{singular:"Gallon",plural:"Gallons"},to_anchor:128},ft3:{name:{singular:"Cubic foot",plural:"Cubic feet"},to_anchor:957.506},yd3:{name:{singular:"Cubic yard",plural:"Cubic yards"},to_anchor:25852.7}},fw={metric:cw,imperial:hw,_anchors:{metric:{unit:"l",ratio:33.8140226},imperial:{unit:"fl-oz",ratio:1/33.8140226}}},dw={metric:{ea:{name:{singular:"Each",plural:"Each"},to_anchor:1},dz:{name:{singular:"Dozen",plural:"Dozens"},to_anchor:12}},imperial:{},_anchors:{metric:{unit:"ea",ratio:1}}},pw={metric:{C:{name:{singular:"degree Celsius",plural:"degrees Celsius"},to_anchor:1,anchor_shift:0},K:{name:{singular:"degree Kelvin",plural:"degrees Kelvin"},to_anchor:1,anchor_shift:273.15}},imperial:{F:{name:{singular:"degree Fahrenheit",plural:"degrees Fahrenheit"},to_anchor:1},R:{name:{singular:"degree Rankine",plural:"degrees Rankine"},to_anchor:1,anchor_shift:459.67}},_anchors:{metric:{unit:"C",transform:function(n){return n/(5/9)+32}},imperial:{unit:"F",transform:function(n){return(n-32)*(5/9)}}}},Fg=365.25,gw={metric:{ns:{name:{singular:"Nanosecond",plural:"Nanoseconds"},to_anchor:1/1e9},mu:{name:{singular:"Microsecond",plural:"Microseconds"},to_anchor:1/1e6},ms:{name:{singular:"Millisecond",plural:"Milliseconds"},to_anchor:1/1e3},s:{name:{singular:"Second",plural:"Seconds"},to_anchor:1},min:{name:{singular:"Minute",plural:"Minutes"},to_anchor:60},h:{name:{singular:"Hour",plural:"Hours"},to_anchor:3600},d:{name:{singular:"Day",plural:"Days"},to_anchor:3600*24},week:{name:{singular:"Week",plural:"Weeks"},to_anchor:3600*24*7},month:{name:{singular:"Month",plural:"Months"},to_anchor:3600*24*Fg/12},year:{name:{singular:"Year",plural:"Years"},to_anchor:3600*24*Fg}},_anchors:{metric:{unit:"s",ratio:1}}},mw={bits:{b:{name:{singular:"Bit",plural:"Bits"},to_anchor:1},Kb:{name:{singular:"Kilobit",plural:"Kilobits"},to_anchor:1024},Mb:{name:{singular:"Megabit",plural:"Megabits"},to_anchor:1048576},Gb:{name:{singular:"Gigabit",plural:"Gigabits"},to_anchor:1073741824},Tb:{name:{singular:"Terabit",plural:"Terabits"},to_anchor:1099511627776}},bytes:{B:{name:{singular:"Byte",plural:"Bytes"},to_anchor:1},KB:{name:{singular:"Kilobyte",plural:"Kilobytes"},to_anchor:1024},MB:{name:{singular:"Megabyte",plural:"Megabytes"},to_anchor:1048576},GB:{name:{singular:"Gigabyte",plural:"Gigabytes"},to_anchor:1073741824},TB:{name:{singular:"Terabyte",plural:"Terabytes"},to_anchor:1099511627776}},_anchors:{bits:{unit:"b",ratio:1/8},bytes:{unit:"B",ratio:8}}},yw={metric:{ppm:{name:{singular:"Part-per Million",plural:"Parts-per Million"},to_anchor:1},ppb:{name:{singular:"Part-per Billion",plural:"Parts-per Billion"},to_anchor:.001},ppt:{name:{singular:"Part-per Trillion",plural:"Parts-per Trillion"},to_anchor:1e-6},ppq:{name:{singular:"Part-per Quadrillion",plural:"Parts-per Quadrillion"},to_anchor:1e-9}},imperial:{},_anchors:{metric:{unit:"ppm",ratio:1e-6}}},vw={metric:{"m/s":{name:{singular:"Metre per second",plural:"Metres per second"},to_anchor:3.6},"km/h":{name:{singular:"Kilometre per hour",plural:"Kilometres per hour"},to_anchor:1}},imperial:{"m/h":{name:{singular:"Mile per hour",plural:"Miles per hour"},to_anchor:1},knot:{name:{singular:"Knot",plural:"Knots"},to_anchor:1.150779},"ft/s":{name:{singular:"Foot per second",plural:"Feet per second"},to_anchor:.681818}},_anchors:{metric:{unit:"km/h",ratio:1/1.609344},imperial:{unit:"m/h",ratio:1.609344}}},xw={Pa:{name:{singular:"pascal",plural:"pascals"},to_anchor:1/1e3},kPa:{name:{singular:"kilopascal",plural:"kilopascals"},to_anchor:1},MPa:{name:{singular:"megapascal",plural:"megapascals"},to_anchor:1e3},hPa:{name:{singular:"hectopascal",plural:"hectopascals"},to_anchor:1/10},bar:{name:{singular:"bar",plural:"bar"},to_anchor:100},torr:{name:{singular:"torr",plural:"torr"},to_anchor:101325/76e4}},_w={psi:{name:{singular:"pound per square inch",plural:"pounds per square inch"},to_anchor:1/1e3},ksi:{name:{singular:"kilopound per square inch",plural:"kilopound per square inch"},to_anchor:1}},bw={metric:xw,imperial:_w,_anchors:{metric:{unit:"kPa",ratio:.00014503768078},imperial:{unit:"psi",ratio:1/.00014503768078}}},ww={metric:{A:{name:{singular:"Ampere",plural:"Amperes"},to_anchor:1},mA:{name:{singular:"Milliampere",plural:"Milliamperes"},to_anchor:.001},kA:{name:{singular:"Kiloampere",plural:"Kiloamperes"},to_anchor:1e3}},_anchors:{metric:{unit:"A",ratio:1}}},Sw={metric:{V:{name:{singular:"Volt",plural:"Volts"},to_anchor:1},mV:{name:{singular:"Millivolt",plural:"Millivolts"},to_anchor:.001},kV:{name:{singular:"Kilovolt",plural:"Kilovolts"},to_anchor:1e3}},_anchors:{metric:{unit:"V",ratio:1}}},Ew={metric:{W:{name:{singular:"Watt",plural:"Watts"},to_anchor:1},mW:{name:{singular:"Milliwatt",plural:"Milliwatts"},to_anchor:.001},kW:{name:{singular:"Kilowatt",plural:"Kilowatts"},to_anchor:1e3},MW:{name:{singular:"Megawatt",plural:"Megawatts"},to_anchor:1e6},GW:{name:{singular:"Gigawatt",plural:"Gigawatts"},to_anchor:1e9}},_anchors:{metric:{unit:"W",ratio:1}}},Mw={metric:{VAR:{name:{singular:"Volt-Ampere Reactive",plural:"Volt-Amperes Reactive"},to_anchor:1},mVAR:{name:{singular:"Millivolt-Ampere Reactive",plural:"Millivolt-Amperes Reactive"},to_anchor:.001},kVAR:{name:{singular:"Kilovolt-Ampere Reactive",plural:"Kilovolt-Amperes Reactive"},to_anchor:1e3},MVAR:{name:{singular:"Megavolt-Ampere Reactive",plural:"Megavolt-Amperes Reactive"},to_anchor:1e6},GVAR:{name:{singular:"Gigavolt-Ampere Reactive",plural:"Gigavolt-Amperes Reactive"},to_anchor:1e9}},_anchors:{metric:{unit:"VAR",ratio:1}}},Aw={metric:{VA:{name:{singular:"Volt-Ampere",plural:"Volt-Amperes"},to_anchor:1},mVA:{name:{singular:"Millivolt-Ampere",plural:"Millivolt-Amperes"},to_anchor:.001},kVA:{name:{singular:"Kilovolt-Ampere",plural:"Kilovolt-Amperes"},to_anchor:1e3},MVA:{name:{singular:"Megavolt-Ampere",plural:"Megavolt-Amperes"},to_anchor:1e6},GVA:{name:{singular:"Gigavolt-Ampere",plural:"Gigavolt-Amperes"},to_anchor:1e9}},_anchors:{metric:{unit:"VA",ratio:1}}},Ow={metric:{Wh:{name:{singular:"Watt-hour",plural:"Watt-hours"},to_anchor:3600},mWh:{name:{singular:"Milliwatt-hour",plural:"Milliwatt-hours"},to_anchor:3.6},kWh:{name:{singular:"Kilowatt-hour",plural:"Kilowatt-hours"},to_anchor:36e5},MWh:{name:{singular:"Megawatt-hour",plural:"Megawatt-hours"},to_anchor:36e8},GWh:{name:{singular:"Gigawatt-hour",plural:"Gigawatt-hours"},to_anchor:36e11},J:{name:{singular:"Joule",plural:"Joules"},to_anchor:1},kJ:{name:{singular:"Kilojoule",plural:"Kilojoules"},to_anchor:1e3}},_anchors:{metric:{unit:"J",ratio:1}}},zw={metric:{VARh:{name:{singular:"Volt-Ampere Reactive Hour",plural:"Volt-Amperes Reactive Hour"},to_anchor:1},mVARh:{name:{singular:"Millivolt-Ampere Reactive Hour",plural:"Millivolt-Amperes Reactive Hour"},to_anchor:.001},kVARh:{name:{singular:"Kilovolt-Ampere Reactive Hour",plural:"Kilovolt-Amperes Reactive Hour"},to_anchor:1e3},MVARh:{name:{singular:"Megavolt-Ampere Reactive Hour",plural:"Megavolt-Amperes Reactive Hour"},to_anchor:1e6},GVARh:{name:{singular:"Gigavolt-Ampere Reactive Hour",plural:"Gigavolt-Amperes Reactive Hour"},to_anchor:1e9}},_anchors:{metric:{unit:"VARh",ratio:1}}},Tw={"mm3/s":{name:{singular:"Cubic Millimeter per second",plural:"Cubic Millimeters per second"},to_anchor:1/1e6},"cm3/s":{name:{singular:"Cubic Centimeter per second",plural:"Cubic Centimeters per second"},to_anchor:1/1e3},"ml/s":{name:{singular:"Millilitre per second",plural:"Millilitres per second"},to_anchor:1/1e3},"cl/s":{name:{singular:"Centilitre per second",plural:"Centilitres per second"},to_anchor:1/100},"dl/s":{name:{singular:"Decilitre per second",plural:"Decilitres per second"},to_anchor:1/10},"l/s":{name:{singular:"Litre per second",plural:"Litres per second"},to_anchor:1},"l/min":{name:{singular:"Litre per minute",plural:"Litres per minute"},to_anchor:1/60},"l/h":{name:{singular:"Litre per hour",plural:"Litres per hour"},to_anchor:1/3600},"kl/s":{name:{singular:"Kilolitre per second",plural:"Kilolitres per second"},to_anchor:1e3},"kl/min":{name:{singular:"Kilolitre per minute",plural:"Kilolitres per minute"},to_anchor:50/3},"kl/h":{name:{singular:"Kilolitre per hour",plural:"Kilolitres per hour"},to_anchor:5/18},"m3/s":{name:{singular:"Cubic meter per second",plural:"Cubic meters per second"},to_anchor:1e3},"m3/min":{name:{singular:"Cubic meter per minute",plural:"Cubic meters per minute"},to_anchor:50/3},"m3/h":{name:{singular:"Cubic meter per hour",plural:"Cubic meters per hour"},to_anchor:5/18},"km3/s":{name:{singular:"Cubic kilometer per second",plural:"Cubic kilometers per second"},to_anchor:1e12}},Cw={"tsp/s":{name:{singular:"Teaspoon per second",plural:"Teaspoons per second"},to_anchor:1/6},"Tbs/s":{name:{singular:"Tablespoon per second",plural:"Tablespoons per second"},to_anchor:1/2},"in3/s":{name:{singular:"Cubic inch per second",plural:"Cubic inches per second"},to_anchor:.55411},"in3/min":{name:{singular:"Cubic inch per minute",plural:"Cubic inches per minute"},to_anchor:.55411/60},"in3/h":{name:{singular:"Cubic inch per hour",plural:"Cubic inches per hour"},to_anchor:.55411/3600},"fl-oz/s":{name:{singular:"Fluid Ounce per second",plural:"Fluid Ounces per second"},to_anchor:1},"fl-oz/min":{name:{singular:"Fluid Ounce per minute",plural:"Fluid Ounces per minute"},to_anchor:1/60},"fl-oz/h":{name:{singular:"Fluid Ounce per hour",plural:"Fluid Ounces per hour"},to_anchor:1/3600},"cup/s":{name:{singular:"Cup per second",plural:"Cups per second"},to_anchor:8},"pnt/s":{name:{singular:"Pint per second",plural:"Pints per second"},to_anchor:16},"pnt/min":{name:{singular:"Pint per minute",plural:"Pints per minute"},to_anchor:4/15},"pnt/h":{name:{singular:"Pint per hour",plural:"Pints per hour"},to_anchor:1/225},"qt/s":{name:{singular:"Quart per second",plural:"Quarts per second"},to_anchor:32},"gal/s":{name:{singular:"Gallon per second",plural:"Gallons per second"},to_anchor:128},"gal/min":{name:{singular:"Gallon per minute",plural:"Gallons per minute"},to_anchor:32/15},"gal/h":{name:{singular:"Gallon per hour",plural:"Gallons per hour"},to_anchor:8/225},"ft3/s":{name:{singular:"Cubic foot per second",plural:"Cubic feet per second"},to_anchor:957.506},"ft3/min":{name:{singular:"Cubic foot per minute",plural:"Cubic feet per minute"},to_anchor:957.506/60},"ft3/h":{name:{singular:"Cubic foot per hour",plural:"Cubic feet per hour"},to_anchor:957.506/3600},"yd3/s":{name:{singular:"Cubic yard per second",plural:"Cubic yards per second"},to_anchor:25852.7},"yd3/min":{name:{singular:"Cubic yard per minute",plural:"Cubic yards per minute"},to_anchor:25852.7/60},"yd3/h":{name:{singular:"Cubic yard per hour",plural:"Cubic yards per hour"},to_anchor:25852.7/3600}},Iw={metric:Tw,imperial:Cw,_anchors:{metric:{unit:"l/s",ratio:33.8140227},imperial:{unit:"fl-oz/s",ratio:1/33.8140227}}},kw={metric:{lx:{name:{singular:"Lux",plural:"Lux"},to_anchor:1}},imperial:{"ft-cd":{name:{singular:"Foot-candle",plural:"Foot-candles"},to_anchor:1}},_anchors:{metric:{unit:"lx",ratio:1/10.76391},imperial:{unit:"ft-cd",ratio:10.76391}}},Pw={metric:{mHz:{name:{singular:"millihertz",plural:"millihertz"},to_anchor:1/1e3},Hz:{name:{singular:"hertz",plural:"hertz"},to_anchor:1},kHz:{name:{singular:"kilohertz",plural:"kilohertz"},to_anchor:1e3},MHz:{name:{singular:"megahertz",plural:"megahertz"},to_anchor:1e3*1e3},GHz:{name:{singular:"gigahertz",plural:"gigahertz"},to_anchor:1e3*1e3*1e3},THz:{name:{singular:"terahertz",plural:"terahertz"},to_anchor:1e3*1e3*1e3*1e3},rpm:{name:{singular:"rotation per minute",plural:"rotations per minute"},to_anchor:1/60},"deg/s":{name:{singular:"degree per second",plural:"degrees per second"},to_anchor:1/360},"rad/s":{name:{singular:"radian per second",plural:"radians per second"},to_anchor:1/(Math.PI*2)}},_anchors:{frequency:{unit:"hz",ratio:1}}},Kn={length:nw,area:ow,mass:lw,volume:fw,each:dw,temperature:pw,time:gw,digital:mw,partsPer:yw,speed:vw,pressure:bw,current:ww,voltage:Sw,power:Ew,reactivePower:Mw,apparentPower:Aw,energy:Ow,reactiveEnergy:zw,volumeFlowRate:Iw,illuminance:kw,frequency:Pw};function bo(n){return Object.keys(n)}function Ng(n){return{abbr:n.abbr,measure:n.measure,system:n.system,singular:n.unit.name.singular,plural:n.unit.name.plural}}function zr(n,t){if(Array.isArray(n))for(let e=0;e<n.length;e++)t(n[e],e,n);else if(n&&typeof n=="object")for(let e in n)Object.prototype.hasOwnProperty.call(n,e)&&t(n[e],e,n)}class Rw{constructor(t,e){Vt(this,"val");Vt(this,"destination");Vt(this,"origin");this.val=e?t/e:t}from(t){if(this.destination)throw new Error(".from must be called before .to");return this.origin=this.getUnit(t),this.origin||this.throwUnsupportedUnitError(t),this}to(t){if(!this.origin)throw new Error(".to must be called after .from");if(this.destination=this.getUnit(t),this.destination||this.throwUnsupportedUnitError(t),this.origin.abbr===this.destination.abbr)return this.val;if(this.destination.measure!==this.origin.measure)throw new Error(`Cannot convert incompatible measures of ${this.destination.measure} and ${this.origin.measure}`);let e=this.val*this.origin.unit.to_anchor;if(this.origin.unit.anchor_shift&&(e-=this.origin.unit.anchor_shift),this.origin.system!==this.destination.system){const r=Kn[this.origin.measure]._anchors[this.origin.system];e=typeof r.transform=="function"?r.transform(e):e*r.ratio}return this.destination.unit.anchor_shift&&(e+=this.destination.unit.anchor_shift),e/this.destination.unit.to_anchor}toBest(t){if(!this.origin)throw new Error(".toBest must be called after .from");const e={exclude:[],cutOffNumber:1,...t};let r=null;return zr(this.possibilities(),i=>{if(e.exclude.includes(i))return;const s=this.describe(i);if(s.system!==this.origin.system)return;const o=this.to(i);(!r||o>=e.cutOffNumber&&o<r.val)&&(r={val:o,unit:i,singular:s.singular,plural:s.plural})}),r}getUnit(t){let e=null;return zr(Kn,(r,i)=>{zr(r,(s,o)=>{o!=="_anchors"&&zr(s,(a,l)=>{l===t&&(e={abbr:t,measure:i,system:o,unit:a})})})}),e}describe(t){const e=this.getUnit(t);return e||this.throwUnsupportedUnitError(t),Ng(e)}list(t){const e=[];return zr(Kn,(r,i)=>{t&&t!==i||zr(r,(s,o)=>{o!=="_anchors"&&zr(s,(a,l)=>{e.push(Ng({abbr:l,measure:i,system:o,unit:a}))})})}),e}throwUnsupportedUnitError(t){const e=[];throw zr(Kn,r=>{zr(r,(i,s)=>{s!=="_anchors"&&e.push(...bo(i))})}),new Error(`Unsupported unit ${t}, use one of: ${e.join(", ")}`)}possibilities(t){const e=[];if(!this.origin&&!t)zr(bo(Kn),r=>{zr(Kn[r],(i,s)=>{s!=="_anchors"&&e.push(...bo(i))})});else{const r=t||this.origin.measure;zr(Kn[r],(i,s)=>{s!=="_anchors"&&e.push(...bo(i))})}return e}measures(){return bo(Kn)}}function Wr(n){return new Rw(n)}const Lw={fontSize:"13px",WebkitAppearance:"none"};function kc({children:n,style:t,...e}){return w.jsx("select",{className:"w-full cursor-pointer block px-2 outline-none rounded h-[35px] text-white bg-[#5e5e5e]",style:{...Lw,...t},...e,children:n})}const Pc=({value:n,onUpdate:t,onValid:e,configs:r,sourceElement:i,internalState:s})=>{const{planner:o}=ne(),a=n.get("length")||0,l=n.get("_length")||a,c=n.get("_unit")||ln,{hook:h,label:f,...g}=r,p=(m,v)=>{let _=tr(m),S=n.merge({length:v!==ln?Wr(_).from(v).to(ln):_,_length:m,_unit:v});return h?h(S,i,s,o).then(M=>t(M)):t(S)};return w.jsxs("div",{className:"PropertyLengthMeasure w-full mb-2",children:[w.jsx(Gr,{children:f}),w.jsxs("div",{className:"w-full flex",children:[w.jsx(Cn,{value:l,style:{borderTopRightRadius:0,borderBottomRightRadius:0,borderRightWidth:0},onChange:m=>p(m.target.value,c),onValid:e,...g}),w.jsx("div",{className:"w-1/4 [&>*:first-child]:text-center",children:w.jsx(kc,{style:{borderTopLeftRadius:"0px",borderBottomLeftRadius:"0px"},value:c,onChange:m=>p(l,m.target.value),children:dd.map(m=>w.jsx("option",{value:m,children:m},m))})})]})]})},wo=({style:n,...t})=>w.jsx("input",{className:"block w-full px-2 text-sm leading-5 bg-[#2b2b2b] rounded border border-[#5e5e5e] outline-none h-[35px] text-white",style:{...n},type:"text",...t}),Fw=({value:n,onUpdate:t,configs:e,sourceElement:r,internalState:i})=>{const{planner:s}=ne(),o=a=>e.hook?e.hook(a,r,i,s).then(l=>t(l)):t(a);return w.jsxs("div",{className:"PropertyString w-full mb-2",children:[w.jsx(Gr,{children:e.label}),w.jsx(wo,{value:n,onChange:a=>o(a.target.value)})]})},Nw=({element:n,attributeFormData:t,onUpdate:e,...r})=>{let i=t.has("name")?t.get("name"):n.name,s=t.has("offsetA")?t.get("offsetA"):n.offsetA,o=t.has("offsetB")?t.get("offsetB"):n.offsetA;return w.jsxs("div",{children:[w.jsx(Fw,{value:i,onUpdate:a=>e("name",a),configs:{label:"Nome"},...r}),w.jsx(Pc,{value:s,onUpdate:a=>e("offsetA",a),configs:{label:"Offset 1",min:0,max:1/0,precision:2},...r}),w.jsx(Pc,{value:o,onUpdate:a=>e("offsetB",a),configs:{label:"Offset 2",min:0,max:1/0,precision:2},...r})]})},jw=({element:n,onUpdate:t,attributeFormData:e,...r})=>{let i=e.has("name")?e.get("name"):n.name,s=e.has("x")?e.get("x"):n.x,o=e.has("y")?e.get("y"):n.y,a=e.has("rotation")?e.get("rotation"):n.rotation;return w.jsx("table",{className:"w-full",children:w.jsxs("tbody",{children:[w.jsxs("tr",{children:[w.jsx("td",{className:"w-[6em]",children:"Name"}),w.jsx("td",{children:w.jsx(wo,{value:i,onChange:l=>t("name",l.target.value),style:{textAlign:"left"}})})]}),w.jsxs("tr",{children:[w.jsx("td",{className:"w-[6em]",children:"X"}),w.jsx("td",{children:w.jsx(Cn,{value:s,onChange:l=>t("x",l.target.value),style:{textAlign:"left"},precision:2,...r})})]}),w.jsxs("tr",{children:[w.jsx("td",{className:"w-[6em]",children:"Y"}),w.jsx("td",{children:w.jsx(Cn,{value:o,onChange:l=>t("y",l.target.value),style:{textAlign:"left"},precision:2,...r})})]}),w.jsxs("tr",{children:[w.jsx("td",{className:"w-[6em]",children:"Rotation"}),w.jsx("td",{children:w.jsx(Cn,{value:a,onChange:l=>t("rotation",l.target.value),style:{textAlign:"left"},precision:2,...r})})]})]})})},Vw=({element:n,onUpdate:t,attributeFormData:e})=>{let r=e.has("name")?e.get("name"):n.name,i=e.has("lineLength")?e.get("lineLength"):null;return w.jsxs("div",{children:[w.jsxs("div",{className:"w-full mb-2",children:[w.jsx(Gr,{children:"Name"}),w.jsx(wo,{value:r,onChange:s=>t("name",s.target.value),style:{textAlign:"left"}})]}),w.jsx(Pc,{value:i,onUpdate:s=>t("lineLength",s),configs:{label:"Length",min:0,max:1/0,precision:2}})]})},Dw=({element:n,onUpdate:t,onValid:e,attributeFormData:r,...i})=>n.prototype==="items"?w.jsx(jw,{element:n,onUpdate:t,onValid:e,attributeFormData:r,...i}):n.prototype==="lines"?w.jsx(Vw,{element:n,onUpdate:t,onValid:e,attributeFormData:r,...i}):n.prototype==="holes"?w.jsx(Nw,{element:n,onUpdate:t,onValid:e,attributeFormData:r,...i}):null,Ur=2,Bw=(n,t,e)=>{switch(n=typeof n.misc=="object"?n.set("misc",K(n.misc)):n,n.prototype){case"items":return K(n);case"lines":{let r=t.vertices.get(n.vertices.get(0)),i=t.vertices.get(n.vertices.get(1)),s=Ve(r.x,r.y,i.x,i.y),o=n.misc.get("_unitLength")||e.unit,a=Wr(s).from(e.unit).to(o);return K({vertexOne:r,vertexTwo:i,lineLength:K({length:s,_length:a,_unit:o})})}case"holes":{let r=t.lines.get(n.line),{x:i,y:s}=t.vertices.get(r.vertices.get(0)),{x:o,y:a}=t.vertices.get(r.vertices.get(1)),l=Ve(i,s,o,a),c=l*n.offset-n.properties.get("width").get("length")/2,h=n.misc.get("_unitA")||e.unit,f=Wr(c).from(e.unit).to(h),g=l-l*n.offset-n.properties.get("width").get("length")/2,p=n.misc.get("_unitB")||e.unit,m=Wr(g).from(e.unit).to(p);return K({offset:n.offset,offsetA:K({length:tr(c,Ur),_length:tr(f,Ur),_unit:h}),offsetB:K({length:tr(g,Ur),_length:tr(m,Ur),_unit:p})})}case"areas":return K({});default:return null}},qw=(n,t)=>{const e=t.getElement(n.type),r={};for(const i in e.properties)r[i]=K({currentValue:n.properties.has(i)?n.properties.get(i):Xt(e.properties[i].defaultValue),configs:e.properties[i]});return K(r)},$w=({element:n,layer:t,catalog:e})=>{const{planner:r,setItemsAttributes:i,setProperties:s,setLinesAttributes:o,setHolesAttributes:a}=ne(),[l,c]=F.useState(Bw(n,t,e)),[h,f]=F.useState(qw(n,e)),g=({propertiesFormData:v,attributesFormData:_})=>{if(v){let S=v.map(M=>M.get("currentValue"));s(S)}if(_)switch(n.prototype){case"items":{i(_);break}case"lines":{o(_);break}case"holes":{a(_);break}}},p=(v,_)=>{if(!l)return;let S;switch(n.prototype){case"items":{S=l.set(v,_);break}case"lines":{switch(v){case"lineLength":{let M=l.get("vertexOne"),C=l.get("vertexTwo"),[O,E]=fo([M,C]),z=va(O.x,O.y,E.x,E.y,_.get("length"),Ur);S=l.withMutations(R=>{R.set(M===O?"vertexTwo":"vertexOne",E.merge(z)),R.set("lineLength",_)});break}case"vertexOne":case"vertexTwo":{S=l.withMutations(M=>{M.set(v,M.get(v).merge(_));let C=ga(M.get("vertexOne"),M.get("vertexTwo"));M.mergeIn(["lineLength"],M.get("lineLength").merge({length:C,_length:Wr(C).from(e.unit).to(M.get("lineLength").get("_unit"))}))});break}default:{S=l.set(v,_);break}}break}case"holes":{switch(v){case"offsetA":{let M=t.lines.get(n.line),C=fo([t.vertices.get(M.vertices.get(0)),t.vertices.get(M.vertices.get(1))]),[{x:O,y:E},{x:z,y:R}]=C,k=kl(O,E,z,R),L=Ve(O,E,z,R),X=n.properties.get("width").get("length"),J=X/2,at=_.get("length");at=Math.max(at,0),at=Math.min(at,L-X);let tt=(at+J)*Math.cos(k)+O,bt=(at+J)*Math.sin(k)+E,xt=De(O,E,z,R,tt,bt),yt=tr(L-L*xt-J,Ur),ht=l.getIn(["offsetB","_unit"]),Y=K({length:yt,_length:Wr(yt).from(e.unit).to(ht),_unit:ht});S=l.set("offsetB",Y).set("offset",xt);let St=K({length:tr(at,Ur),_unit:_.get("_unit"),_length:tr(Wr(at).from(e.unit).to(_.get("_unit")),Ur)});S=l.set(v,St);break}case"offsetB":{let M=t.lines.get(n.line),C=fo([t.vertices.get(M.vertices.get(0)),t.vertices.get(M.vertices.get(1))]),[{x:O,y:E},{x:z,y:R}]=C,k=kl(O,E,z,R),L=Ve(O,E,z,R),X=n.properties.get("width").get("length"),J=X/2,at=_.get("length");at=Math.max(at,0),at=Math.min(at,L-X);let tt=z-(at+J)*Math.cos(k),bt=R-(at+J)*Math.sin(k),xt=De(O,E,z,R,tt,bt),yt=tr(L*xt-J,Ur),ht=l.getIn(["offsetA","_unit"]),Y=K({length:yt,_length:Wr(yt).from(e.unit).to(ht),_unit:ht});S=l.set("offsetA",Y).set("offset",xt);let St=K({length:tr(at,Ur),_unit:_.get("_unit"),_length:tr(Wr(at).from(e.unit).to(_.get("_unit")),Ur)});S=l.set(v,St);break}default:{S=l.set(v,_);break}}break}}S&&(c(S),g({attributesFormData:S,propertiesFormData:h}))},m=(v,_)=>{const S=h.setIn([v,"currentValue"],_);f(S),g({propertiesFormData:S,attributesFormData:l})};return w.jsxs("div",{children:[w.jsx(Dw,{element:n,onValid:()=>{},onUpdate:p,attributeFormData:l}),h.entrySeq().map(([v,_])=>{let S=_.get("currentValue"),M=_.get("configs"),{Editor:C}=e.getPropertyType(M.type);return w.jsx(C,{propertyName:v,value:S,configs:M,onUpdate:O=>m(v,O),state:r,sourceElement:n,internalState:{attributesFormData:l,propertiesFormData:h}},v)})]})},Hw=()=>w.jsxs("div",{className:"h-full flex flex-col gap-4 justify-center items-center",children:[w.jsx("div",{className:"text-3xl text-white",children:w.jsx("img",{src:"/assets/icons/bullseye-arrow.svg",alt:"bullseye-arrow",width:34,height:34})}),w.jsx("p",{className:"mx-4 text-white text-sm text-center",children:"Select an element on the canvas to edit its properties."})]}),Gw=[fe,gi,mi,yi,vi,Qi,Lr,or,ar,Sr,Fr,Nr,jr,Vr,An,Al,Ol],Ww=({catalog:n})=>{const{planner:t}=ne(),{scene:e,mode:r}=t;return Gw.includes(r)?e.layers.valueSeq().flatMap(s=>Ee().concat(s.lines,s.holes,s.areas,s.items).filter(o=>o.selected).map(o=>({element:o,layer:s}))).toArray().length===0?w.jsx(Hw,{}):w.jsx("div",{children:e.layers.valueSeq().map(s=>Ee().concat(s.lines,s.holes,s.areas,s.items).filter(o=>o.selected).map(o=>w.jsx(Lg,{name:"Properties",opened:!0,children:w.jsx("div",{style:{padding:"5px 15px"},children:w.jsx($w,{element:o,layer:s,catalog:n})})},o.id)).valueSeq())}):null},Uw={MODE_IDLE:fe,MODE_2D_ZOOM_IN:gi,MODE_2D_ZOOM_OUT:mi,MODE_2D_PAN:yi,MODE_3D_VIEW:vi,MODE_3D_FIRST_PERSON:Qi,MODE_WAITING_DRAWING_LINE:Lr,MODE_DRAWING_LINE:or,MODE_DRAWING_HOLE:ar,MODE_DRAWING_ITEM:Sr,MODE_DRAGGING_LINE:Fr,MODE_DRAGGING_VERTEX:Nr,MODE_DRAGGING_ITEM:jr,MODE_DRAGGING_HOLE:Vr,MODE_FITTING_IMAGE:Ol,MODE_UPLOADING_IMAGE:Al,MODE_ROTATING_ITEM:An},Yw={width:"100%"},Wa={width:"6em"},Ua={textAlign:"left"},Xw={marginLeft:"5px",border:"0px",background:"none",color:"#FFFFFF",fontSize:"14px",outline:"0px"},Jw={width:"100%",cursor:"pointer",maxHeight:"20em",marginLeft:"1px",marginTop:"1em"},jg={width:"2em"},Zw=({groupID:n})=>{const{planner:t,setGroupAttributes:e,groupTranslate:r,groupRotate:i,removeFromGroup:s}=ne(),{mode:o}=t;if(!n||!Uw[o])return null;const a=t.getIn(["scene","groups",n]),l=a.get("elements");return w.jsx(Lg,{name:`Group [${a.get("name")}]`,opened:!0,children:w.jsxs("div",{style:{padding:"5px 15px"},children:[w.jsx("table",{style:Yw,children:w.jsxs("tbody",{children:[w.jsxs("tr",{children:[w.jsx("td",{style:Wa,children:"Name"}),w.jsx("td",{children:w.jsx(wo,{value:a.get("name"),onChange:c=>e(n,K({name:c.target.value})),style:Ua})})]}),w.jsxs("tr",{children:[w.jsx("td",{style:Wa,children:"X"}),w.jsx("td",{children:w.jsx(Cn,{value:a.get("x"),onChange:c=>r(n,c.target.value,a.get("y")),style:Ua,precision:2})})]}),w.jsxs("tr",{children:[w.jsx("td",{style:Wa,children:"Y"}),w.jsx("td",{children:w.jsx(Cn,{value:a.get("y"),onChange:c=>r(n,a.get("x"),c.target.value),style:Ua,precision:2})})]}),w.jsxs("tr",{children:[w.jsx("td",{style:Wa,children:"Rotation"}),w.jsx("td",{children:w.jsx(Cn,{value:a.get("rotation"),onChange:c=>i(n,c.target.value),style:Ua,precision:2})})]})]})}),l.size?w.jsxs("div",{children:[w.jsx("p",{style:{textAlign:"center",borderBottom:"1px solid #555",paddingBottom:"1em"},children:"Group's Elements"}),w.jsxs("table",{style:Jw,children:[w.jsx("thead",{children:w.jsxs("tr",{children:[w.jsx("th",{style:jg}),w.jsx("th",{children:"Layer"}),w.jsx("th",{children:"Prototype"}),w.jsx("th",{children:"Name"})]})}),w.jsx("tbody",{children:l.entrySeq().map(([c,h])=>h.entrySeq().map(([f,g])=>g.valueSeq().map(p=>{let m=t.getIn(["scene","layers",c,f,p]);return w.jsxs("tr",{children:[w.jsx("td",{style:jg,title:"Un-chain Element from Group",children:w.jsx(j1,{onClick:()=>s(n,c,f,p),style:Xw})}),w.jsx("td",{style:{textAlign:"center"},children:c}),w.jsx("td",{style:{textAlign:"center",textTransform:"capitalize"},children:f}),w.jsx("td",{style:{textAlign:"center"},children:m.name})]},p)})))})]})]}):null]})})},Kw=({catalog:n})=>{const{planner:t}=ne(),e=t.getIn(["scene","selectedLayer"]),r=t.getIn(["scene","layers",e,"selected"]),i=t.getIn(["scene","groups"]).findEntry(o=>o.get("selected")),s=r.lines.size>1||r.items.size>1||r.holes.size>1||r.areas.size>1||r.lines.size+r.items.size+r.holes.size+r.areas.size>1;return w.jsxs("aside",{onKeyDown:o=>o.stopPropagation(),onKeyUp:o=>o.stopPropagation(),className:"floor_planner-sidebar w-[300px] bg-[#424242] h-[calc(100%_-_20px)] block overflow-y-auto overflow-x-hidden pb-5",children:[!s&&w.jsx(Ww,{catalog:n}),!!i&&w.jsx(Zw,{groupID:i?i[0]:null})]})},In=({active:n,tooltip:t,onClick:e,children:r,className:i})=>{const[s,o]=F.useState(!1),a=n||s?"text-[#1CA6FC]":"text-[#C2C2C2]";return w.jsxs("div",{className:Hr("w-[30px] h-[30px] flex items-center justify-center text-[25px] relative cursor-pointer",i),onMouseOver:()=>o(!0),onMouseOut:()=>o(!1),children:[w.jsx("div",{className:a,onClick:e,children:r}),s&&w.jsxs("div",{className:"absolute w-[140px] text-white bg-black h-[30px] leading-[30px] text-center rounded-md opacity-80 left-full top-1/2 -mt-[15px] ml-[15px] z-[999] text-[12px]",children:[w.jsx("span",{className:"absolute top-1/2 right-full -mt-[8px] w-0 h-0 border-r-[8px] border-r-black border-t-[8px] border-t-transparent border-b-[8px] border-b-transparent"}),t]})]})},Vg=()=>new Promise(async n=>{const t=document.getElementsByTagName("svg");if(!t.length)return;let e=t[0];for(let g=1;g<t.length;g++)t[g].width.baseVal.value>e.width.baseVal.value&&(e=t[g]);const r=e.cloneNode(!0),i=r.querySelectorAll("image");await Promise.all(Array.from(i).map(async g=>{const p=g.getAttribute("href")||g.getAttribute("xlink:href");if(p)try{const v=await(await fetch(p)).blob(),_=new FileReader;await new Promise(S=>{_.onloadend=()=>{g.setAttribute("href",_.result),S()},_.readAsDataURL(v)})}catch(m){console.warn("⚠️ Could not inline image:",p,m)}}));const o=new XMLSerializer().serializeToString(r),a=e.width.baseVal.value,l=e.height.baseVal.value,c=document.createElement("canvas");c.width=a,c.height=l;const h=c.getContext("2d");h.fillStyle="white",h.fillRect(0,0,a,l);const f=new Image;f.src=`data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(o)))}`,f.onload=()=>{h.drawImage(f,0,0,a,l),n(c.toDataURL("image/png"))}});function Dg(n){return ge({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M7 19a2 2 0 0 1 -2 -2"},child:[]},{tag:"path",attr:{d:"M5 13v-2"},child:[]},{tag:"path",attr:{d:"M5 7a2 2 0 0 1 2 -2"},child:[]},{tag:"path",attr:{d:"M11 5h2"},child:[]},{tag:"path",attr:{d:"M17 5a2 2 0 0 1 2 2"},child:[]},{tag:"path",attr:{d:"M19 11v2"},child:[]},{tag:"path",attr:{d:"M19 17v4"},child:[]},{tag:"path",attr:{d:"M21 19h-4"},child:[]},{tag:"path",attr:{d:"M13 19h-2"},child:[]}]})(n)}const Bg=n=>{let t=document.createElement("a"),e="output"+Date.now()+".png";e=window.prompt("Insert output filename",e),e&&(t.setAttribute("download",e),t.href=n,t.style.display="none",document.body.appendChild(t),t.click(),document.body.removeChild(t))};function Qw({mode:n}){const t=r=>{r.preventDefault();const i=document.getElementsByTagName("canvas")[0];Bg(i.toDataURL())},e=async r=>{r.preventDefault(),Vg().then(Bg)};return[Qi,vi].includes(n)?w.jsx(In,{active:!1,tooltip:"Get Screenshot",onClick:t,children:w.jsx(Dg,{size:28})}):[fe,gi,mi,yi,Lr,Fr,Nr,jr,or,ar,Sr,Vr,An].includes(n)?w.jsx(In,{active:!1,tooltip:"Get Screenshot",onClick:e,children:w.jsx(Dg,{size:28})}):null}function tS(n){return ge({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"rect",attr:{width:"18",height:"18",x:"3",y:"3",rx:"2"},child:[]},{tag:"path",attr:{d:"M12 9v6"},child:[]},{tag:"path",attr:{d:"M16 15v6"},child:[]},{tag:"path",attr:{d:"M16 3v6"},child:[]},{tag:"path",attr:{d:"M3 15h18"},child:[]},{tag:"path",attr:{d:"M3 9h18"},child:[]},{tag:"path",attr:{d:"M8 15v6"},child:[]},{tag:"path",attr:{d:"M8 3v6"},child:[]}]})(n)}const eS=/^.*$/;function rS({onChange:n,...t}){const[e,r]=F.useState(""),i=F.useRef(null);F.useEffect(()=>{r(t.value)},[t.value]);const s=a=>{if(!a)return;const l=a.target.value;eS.test(l)&&n&&n(a)},o=a=>{(!a.key||a.key==="Enter")&&s({target:{value:e}})};return w.jsxs("div",{className:"color-field flex-1 flex pr-3 mt-1 cursor-pointer",children:[w.jsx("div",{className:"colorBox relative w-[22px] h-[22px]",style:{background:t.value},onClick:()=>{i.current&&i.current.click()},children:w.jsx("input",{ref:i,type:"color",onChange:s,value:t.value,className:"absolute invisible h-full w-full"})}),w.jsx("div",{className:"flex-1 pl-2",children:w.jsx("input",{className:"colorFieldInput min-w-[90px] cursor-pointer",type:"text",value:e,onKeyDown:o,onChange:a=>r(a.target.value),onBlur:o})})]})}function qg({value:n,onUpdate:t,configs:e,sourceElement:r,internalState:i}){const{planner:s}=ne(),o=a=>e.hook?e.hook(a,r,i,s).then(l=>t(l)):t(a);return w.jsxs("div",{className:"PropertyColor w-full mb-2",children:[w.jsx(Gr,{children:e.label}),w.jsx(rS,{value:n,onChange:a=>o(a.target.value)})]})}function $g({value:n,onUpdate:t,configs:e,sourceElement:r,internalState:i}){const{planner:s}=ne(),o=a=>e.hook?e.hook(a,r,i,s).then(l=>t(l)):t(a);return w.jsxs("div",{className:"PropertyEnum w-full mb-2",children:[w.jsx(Gr,{children:e.label}),w.jsx(kc,{value:n,onChange:a=>o(a.target.value),children:Ee(e.values).entrySeq().map(([a,l])=>w.jsx("option",{value:a,children:l},a))})]})}function Hg({value:n,onUpdate:t,configs:e,sourceElement:r,internalState:i}){const{planner:s}=ne();let o=a=>e.hook?e.hook(a,r,i,s).then(l=>t(l)):t(a);return w.jsxs("div",{className:"PropertyString w-full mb-2",children:[w.jsx(Gr,{children:e.label}),w.jsx(wo,{value:n,onChange:a=>o(a.target.value)})]})}function Gg({value:n,onUpdate:t,onValid:e,configs:r,sourceElement:i,internalState:s}){const{planner:o}=ne(),a=l=>{let c=parseFloat(l);return isNaN(c)&&(c=0),r.hook?r.hook(c,i,s,o).then(h=>t(h)):t(c)};return w.jsxs("div",{className:"PropertyNumber w-full mb-2",children:[w.jsx(Gr,{children:r.label}),w.jsx(Cn,{value:n,onChange:l=>a(l.target.value),onValid:e,min:r.min,max:r.max})]})}function Wg({value:n,onUpdate:t,onValid:e,configs:r,sourceElement:i,internalState:s}){const{planner:o}=ne();let a=n.get("length")||0,l=n.get("_length")||a,c=n.get("_unit")||ln,{hook:h,label:f,...g}=r;const p=(m,v)=>{let _=tr(m),S=n.merge({length:v!==ln?Wr(_).from(v).to(ln):_,_length:m,_unit:v});return h?h(S,i,s,o).then(M=>t(M)):t(S)};return w.jsxs("div",{className:"PropertyLengthMeasure w-full mb-2",children:[w.jsx(Gr,{children:f}),w.jsxs("div",{className:"w-full flex",children:[w.jsx(Cn,{value:l,onChange:m=>p(m.target.value,c),onValid:e,style:{borderTopRightRadius:0,borderBottomRightRadius:0,borderRightWidth:0},...g}),w.jsx("div",{className:"w-1/4 [&>*:first-child]:text-center",children:w.jsx(kc,{style:{borderTopLeftRadius:"0px",borderBottomLeftRadius:"0px"},value:c,onChange:m=>p(l,m.target.value),children:dd.map(m=>w.jsx("option",{value:m,children:m},m))})})]})]})}function nS({type:n="button",size:t="normal",style:e,styleHover:r,children:i,...s}){const[o,a]=F.useState(!1),l="inline-block font-normal leading-[1.25] text-center whitespace-nowrap align-middle cursor-pointer select-none outline-none border border-solid w-full transition-colors duration-175 ease-linear rounded-[2px]",c=t==="small"?"text-[12px] px-2 py-[3px]":t==="large"?"px-5 py-2":"text-[14px] px-3 py-[5px]",h={backgroundColor:"#e6e6e6",borderColor:"#adadad"},f={backgroundColor:"#d4d4d4",borderColor:"#8c8c8c"};return w.jsx("button",{type:n,className:`${l} ${c}`,style:{...o?{...f,...r}:{...h,...e}},onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),...s,children:i})}const Ya={tableStyle:{width:"100%",borderSpacing:"2px 0",marginBottom:"2px"},firstTdStyle:{width:"6em",textTransform:"capitalize"}};function Ug({value:n,onUpdate:t,configs:e,sourceElement:r,internalState:i}){const{planner:s}=ne(),o=a=>e.hook?e.hook(a,r,i,s).then(l=>t(l)):t(a);return w.jsx("table",{className:"PropertyToggle",style:Ya.tableStyle,children:w.jsx("tbody",{children:w.jsxs("tr",{children:[w.jsx("td",{style:Ya.firstTdStyle,children:w.jsx(Gr,{children:e.label})}),w.jsx("td",{children:w.jsx(nS,{onClick:()=>o(!n),size:"small",children:e.actionName})})]})})})}function Yg({value:n,onUpdate:t,configs:e,sourceElement:r,internalState:i}){const{planner:s}=ne(),o=a=>e.hook?e.hook(a,r,i,s).then(l=>t(l)):t(a);return w.jsxs("div",{className:"PropertyCheckbox w-full flex items-center gap-2 mb-2",children:[w.jsx("input",{className:"m-0 mt-0.5",type:"checkbox",checked:n,onChange:()=>o(!n)}),w.jsx(Gr,{className:"mb-0",children:e.label})]})}function Xg(){return null}function Jg({value:n,configs:t}){return w.jsx("table",{className:"PropertyReadOnly",style:Ya.tableStyle,children:w.jsx("tbody",{children:w.jsxs("tr",{children:[w.jsx("td",{style:Ya.firstTdStyle,children:w.jsx(Gr,{children:t.label})}),w.jsx("td",{children:w.jsx("div",{children:n})})]})})})}/**
|
|
68
|
+
`+l+" | "+Xl("",i.column-1," ")+Xl("",f,"^")}else t+=`
|
|
69
|
+
at `+o}return t},ha.buildMessage=function(n,t){var e={literal:function(c){return'"'+i(c.text)+'"'},class:function(c){var h=c.parts.map(function(f){return Array.isArray(f)?s(f[0])+"-"+s(f[1]):s(f)});return"["+(c.inverted?"^":"")+h.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(c){return c.description}};function r(c){return c.charCodeAt(0).toString(16).toUpperCase()}function i(c){return c.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(h){return"\\x0"+r(h)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(h){return"\\x"+r(h)})}function s(c){return c.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(h){return"\\x0"+r(h)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(h){return"\\x"+r(h)})}function o(c){return e[c.type](c)}function a(c){var h=c.map(o),f,g;if(h.sort(),h.length>0){for(f=1,g=1;f<h.length;f++)h[f-1]!==h[f]&&(h[g]=h[f],g++);h.length=g}switch(h.length){case 1:return h[0];case 2:return h[0]+" or "+h[1];default:return h.slice(0,-1).join(", ")+", or "+h[h.length-1]}}function l(c){return c?'"'+i(c)+'"':"end of input"}return"Expected "+a(n)+" but "+l(t)+" found."};const Xe="idle",Er="panning",Ar="zooming",cr="auto",Jr="none",hr="pan",Or="zoom-in",Zr="zoom-out",fa="none",Kr="top",Je="right",Qr="bottom",Pe="left",da="zoom",Zs="pan",Ri="center",Li="left",Jl="right",Ni="top",Zl="bottom",ip="cover";function sp(n,t){var e=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),e.push.apply(e,r)}return e}function pa(n){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?sp(Object(e),!0).forEach(function(r){bx(n,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(e)):sp(Object(e)).forEach(function(r){Object.defineProperty(n,r,Object.getOwnPropertyDescriptor(e,r))})}return n}function bx(n,t,e){return(t=wx(t))in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}function wx(n){var t=Sx(n,"string");return typeof t=="symbol"?t:t+""}function Sx(n,t){if(typeof n!="object"||!n)return n;var e=n[Symbol.toPrimitive];if(e!==void 0){var r=e.call(n,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(n)}const op=3,ap=Xe;function up(n,t,e,r,i,s){let o=arguments.length>6&&arguments[6]!==void 0?arguments[6]:null,a=arguments.length>7&&arguments[7]!==void 0?arguments[7]:null;return Ut({},pa(pa({},rp()),{},{version:op,mode:ap,focus:!1,pinchPointDistance:null,prePinchMode:null,viewerWidth:n,viewerHeight:t,SVGMinX:e,SVGMinY:r,SVGWidth:i,SVGHeight:s,scaleFactorMin:o,scaleFactorMax:a,startX:null,startY:null,endX:null,endY:null,miniatureOpen:!0,lastAction:null}))}function Ut(n,t){let e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null;return n=Object.assign({},n,t,{lastAction:e}),Object.freeze(n)}function Mx(n){return n!==null&&typeof n=="object"&&n.hasOwnProperty("version")&&n.version===op}function fr(n,t,e){let r=Js(n),i=np(r);return tp(i,{x:t,y:e})}function ga(n){let t=Js(n);return{scaleFactor:t.a,translationX:t.e,translationY:t.f}}function Ex(n,t){return Ut(n,{focus:t})}function Ax(n,t,e){return Ut(n,{viewerWidth:t,viewerHeight:e})}function lp(n,t,e,r,i){return Ut(n,{SVGMinX:t,SVGMinY:e,SVGWidth:r,SVGHeight:i})}function Ox(n,t,e){return Ut(n,{scaleFactorMin:t,scaleFactorMax:e})}function zx(n,t,e,r){let{viewerWidth:i,viewerHeight:s}=n,o=fn(Ye(-t+i/2,-e+s/2),Ye(t,e),ei(r,r),Ye(-t,-e));return Ut(n,pa({mode:Xe},o))}function Tx(n){return Ut(n,pa({mode:Xe},rp()))}function cp(n){return Ut(n,{mode:ap,startX:null,startY:null,endX:null,endY:null})}class hp{constructor(t,e,r){this.originalEvent=t,this.value=e,this.SVGViewer=r}get scaleFactor(){return this._cacheDecomposedValue=this._cacheDecomposedValue||ga(this.value),this._cacheDecomposedValue.scaleFactor}get translationX(){return this._cacheDecomposedValue=this._cacheDecomposedValue||ga(this.value),this._cacheDecomposedValue.translationX}get translationY(){return this._cacheDecomposedValue=this._cacheDecomposedValue||ga(this.value),this._cacheDecomposedValue.translationY}preventDefault(){this.originalEvent.preventDefault()}stopPropagation(){this.originalEvent.stopPropagation()}}function fp(n,t){var e=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),e.push.apply(e,r)}return e}function Cx(n){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?fp(Object(e),!0).forEach(function(r){kx(n,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(e)):fp(Object(e)).forEach(function(r){Object.defineProperty(n,r,Object.getOwnPropertyDescriptor(e,r))})}return n}function kx(n,t,e){return(t=Ix(t))in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}function Ix(n){var t=Px(n,"string");return typeof t=="symbol"?t:t+""}function Px(n,t){if(typeof n!="object"||!n)return n;var e=n[Symbol.toPrimitive];if(e!==void 0){var r=e.call(n,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(n)}function Kl(n,t,e){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:void 0,i=fn(Js(n),Ye(t,e));if(r){let[{x:s,y:o},{x:a,y:l}]=ep(i,[{x:n.SVGMinX+r,y:n.SVGMinY+r},{x:n.SVGMinX+n.SVGWidth-r,y:n.SVGMinY+n.SVGHeight-r}]),c=0;n.viewerWidth-s<0?c=n.viewerWidth-s:a<0&&(c=-a);let h=0;n.viewerHeight-o<0?h=n.viewerHeight-o:l<0&&(h=-l),i=fn(Ye(c,h),i)}return Ut(n,Cx({mode:Xe},i),Zs)}function Rx(n,t,e){return Ut(n,{mode:Er,startX:t,startY:e,endX:t,endY:e},Zs)}function Lx(n,t,e,r){if(n.mode!==Er)throw new Error("update pan not allowed in this mode "+n.mode);let{endX:i,endY:s}=n,o=fr(n,i,s),a=fr(n,t,e),l=a.x-o.x,c=a.y-o.y,h=Kl(n,l,c,r);return Ut(h,{mode:Er,endX:t,endY:e},Zs)}function dp(n){return Ut(n,{mode:Xe,startX:null,startY:null,endX:null,endY:null},Zs)}function Nx(n,t,e){let r=0,i=0;return e<=20&&(i=2),n.viewerWidth-t<=20&&(r=-2),n.viewerHeight-e<=20&&(i=-2),t<=20&&(r=2),r=r/n.d,i=i/n.d,r===0&&i===0?n:Kl(n,r,i)}function pp(n,t){if(n.x<=t.x&&n.y<=t.y)return{x:n.x,y:n.y,width:t.x-n.x,height:t.y-n.y};if(n.x>=t.x&&n.y<=t.y)return{x:t.x,y:n.y,width:n.x-t.x,height:t.y-n.y};if(n.x>=t.x&&n.y>=t.y)return{x:t.x,y:t.y,width:n.x-t.x,height:n.y-t.y};if(n.x<=t.x&&n.y>=t.y)return{x:n.x,y:t.y,width:t.x-n.x,height:n.y-t.y}}function gp(n,t){var e=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),e.push.apply(e,r)}return e}function Fi(n){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?gp(Object(e),!0).forEach(function(r){Fx(n,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(e)):gp(Object(e)).forEach(function(r){Object.defineProperty(n,r,Object.getOwnPropertyDescriptor(e,r))})}return n}function Fx(n,t,e){return(t=jx(t))in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}function jx(n){var t=Vx(n,"string");return typeof t=="symbol"?t:t+""}function Vx(n,t){if(typeof n!="object"||!n)return n;var e=n[Symbol.toPrimitive];if(e!==void 0){var r=e.call(n,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(n)}function ma(n,t){const{scaleFactor:e}=ga(n),r=n.scaleFactorMin&&e*t<n.scaleFactorMin,i=n.scaleFactorMax&&e*t>n.scaleFactorMax;return r&&t<1||i&&t>1}function Ql(n,t){let e=t.a;return n.scaleFactorMin!=null&&(e=Math.max(e,n.scaleFactorMin)),n.scaleFactorMax!=null&&(e=Math.min(e,n.scaleFactorMax)),Ut(t,{a:e,d:e})}function ji(n,t,e,r){if(ma(n,r))return n;const i=fn(Js(n),Ye(t,e),ei(r,r),Ye(-t,-e));return Ut(n,Fi(Fi({mode:Xe},i),{},{startX:null,startY:null,endX:null,endY:null}),da)}function mp(n,t,e,r,i){let{viewerWidth:s,viewerHeight:o}=n,a=s/r,l=o/i,c=Math.min(a,l);const h=fn(ei(c,c),Ye(-t,-e));return ma(n,c/n.d)?Ut(n,{mode:Xe,startX:null,startY:null,endX:null,endY:null}):Ut(n,Fi(Fi({mode:Xe},Ql(n,h)),{},{startX:null,startY:null,endX:null,endY:null}),da)}function yp(n){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Li,e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Ni,{viewerWidth:r,viewerHeight:i,SVGMinX:s,SVGMinY:o,SVGWidth:a,SVGHeight:l}=n,c=r/a,h=i/l,f=Math.min(c,h),g=ei(f,f),p=-s*c,m=-o*h;if(c<h){let S=i-c*l;switch(e){case Ni:m=-o*f;break;case Ri:m=Math.round(S/2)-o*f;break;case Zl:m=S-o*f;break;case ip:g=ei(h,h);let A=r-h*a;p=s+Math.round(A/2);break}}else{let S=r-h*a;switch(t){case Li:p=-s*f;break;case Ri:p=Math.round(S/2)-s*f;break;case Jl:p=S-s*f;break;case ip:g=ei(c,c);let A=i-c*l;m=o+Math.round(A/2);break}}const v=Ye(p,m),_=fn(v,g);return ma(n,f/n.d)?Ut(n,{mode:Xe,startX:null,startY:null,endX:null,endY:null}):Ut(n,Fi(Fi({mode:Xe},Ql(n,_)),{},{startX:null,startY:null,endX:null,endY:null}),da)}function Dx(n,t){let{viewerWidth:e,viewerHeight:r}=n,i=fr(n,e/2,r/2);return ji(n,i.x,i.y,t)}function Bx(n,t,e){return Ut(n,{mode:Ar,startX:t,startY:e,endX:t,endY:e})}function qx(n,t,e){if(n.mode!==Ar)throw new Error("update selection not allowed in this mode "+n.mode);return Ut(n,{endX:t,endY:e})}function tc(n,t,e,r){let{startX:s,startY:o}=n,a=fr(n,s,o),l=fr(n,t,e);if(Math.abs(s-t)>7&&Math.abs(o-e)>7){let c=pp(a,l);return mp(n,c.x,c.y,c.width,c.height)}else{let c=fr(n,t,e);return ji(n,c.x,c.y,r)}}function $x(n,t,e,r,i){return r+(i-r)*(n-t)/(e-t)}function Vi(n,t){let{left:e,top:r}=t.getBoundingClientRect(),i=n.clientX-Math.round(e),s=n.clientY-Math.round(r);return{x:i,y:s}}function vp(n,t,e,r,i){let s=arguments.length>5&&arguments[5]!==void 0?arguments[5]:null;const{x:o,y:a}=s||Vi(n,t);let l=r;switch(e){case Zr:let c=fr(r,o,a);l=ji(r,c.x,c.y,1/i.scaleFactor);break;case Or:l=Bx(r,o,a);break;case cr:case hr:l=Rx(r,o,a);break;default:return r}return n.preventDefault(),l}function xp(n,t,e,r,i){let s=arguments.length>5&&arguments[5]!==void 0?arguments[5]:null;const{x:o,y:a}=s||Vi(n,t);let l=n.buttons===0,c=r;switch(e){case Or:r.mode===Ar&&(c=l?tc(r,o,a,i.scaleFactor):qx(r,o,a));break;case cr:case hr:r.mode===Er&&(c=l?dp(r):Lx(r,o,a,i.preventPanOutside?20:void 0));break;default:return r}return n.preventDefault(),c}function _p(n,t,e,r,i){let s=arguments.length>5&&arguments[5]!==void 0?arguments[5]:null;const{x:o,y:a}=s||Vi(n,t);let l=r;switch(e){case Zr:r.mode===Ar&&(l=tc(r,o,a,1/i.scaleFactor));break;case Or:r.mode===Ar&&(l=tc(r,o,a,i.scaleFactor));break;case cr:case hr:r.mode===Er&&(l=dp(r));break;default:return r}return n.preventDefault(),l}function Hx(n,t,e,r,i){let s=arguments.length>5&&arguments[5]!==void 0?arguments[5]:null;const{x:o,y:a}=s||Vi(n,t);let l=r;if(e===cr&&!i.disableDoubleClickZoomWithToolAuto){const{modifierKeys:c=[]}=i;let h=fr(r,o,a),f=(m,v)=>m||n.getModifierState(v),p=c.reduce(f,!1)?1/i.scaleFactor:i.scaleFactor;l=ji(r,h.x,h.y,p)}return n.preventDefault(),l}function Gx(n,t,e,r,i){let s=arguments.length>5&&arguments[5]!==void 0?arguments[5]:null;const{x:o,y:a}=s||Vi(n,t);if(!i.detectWheel)return r;let l=Math.max(-1,Math.min(1,n.deltaY)),c=$x(l,-1,1,i.scaleFactorOnWheel,1/i.scaleFactorOnWheel),h=fr(r,o,a),f=ji(r,h.x,h.y,c);return n.preventDefault(),f}function bp(n,t,e,r,i){let s=Ex(r,n.type==="mouseenter");return n.preventDefault(),s}function Wx(n,t,e,r,i){let s=arguments.length>5&&arguments[5]!==void 0?arguments[5]:null,{x:o,y:a}=s;return!([Jr,cr].indexOf(e)>=0)||!i.detectAutoPan||!r.focus?r:Nx(r,o,a)}class Ux extends hp{get point(){if(!this._cachePoint){const{originalEvent:t,SVGViewer:e,value:r}=this,i=Vi(t,e);this._cachePoint=fr(r,i.x,i.y)}return this._cachePoint}get x(){return this.point.x}get y(){return this.point.y}}function wp(n,t){var e=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),e.push.apply(e,r)}return e}function Sp(n){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?wp(Object(e),!0).forEach(function(r){Yx(n,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(e)):wp(Object(e)).forEach(function(r){Object.defineProperty(n,r,Object.getOwnPropertyDescriptor(e,r))})}return n}function Yx(n,t,e){return(t=Xx(t))in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}function Xx(n){var t=Jx(n,"string");return typeof t=="symbol"?t:t+""}function Jx(n,t){if(typeof n!="object"||!n)return n;var e=n[Symbol.toPrimitive];if(e!==void 0){var r=e.call(n,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(n)}class ya extends hp{get points(){return this._cachePoints||(this._cachePoints=ya.touchesToPoints(this.originalEvent.touches,this.SVGViewer,this.value)),this._cachePoints}get changedPoints(){return this._cacheChangedPoints||(this._cacheChangedPoints=ya.touchesToPoints(this.originalEvent.changedTouches,this.SVGViewer,this.value)),this._cacheChangedPoints}static touchesToPoints(t,e,r){let i=[];for(let s=0;s<t.length;s++){let o=t[s],a=e.getBoundingClientRect(),l=o.clientX-Math.round(a.left),c=o.clientY-Math.round(a.top),h=fr(r,l,c);i.push(Sp(Sp({},h),{},{identifier:o.identifier}))}return i}}function Zx(n,t,e){let r=n.type;switch(r){case"mousemove":case"mouseup":case"mousedown":case"click":case"dblclick":return new Ux(n,t,e);case"touchstart":case"touchmove":case"touchend":case"touchcancel":return new ya(n,t,e);default:throw new Error(`${r} not supported`)}}function Mp(n){return n.split(/[ ,]/).filter(Boolean).map(Number)}function Ep(n,t){var e=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),e.push.apply(e,r)}return e}function Ap(n){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?Ep(Object(e),!0).forEach(function(r){Kx(n,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(e)):Ep(Object(e)).forEach(function(r){Object.defineProperty(n,r,Object.getOwnPropertyDescriptor(e,r))})}return n}function Kx(n,t,e){return(t=Qx(t))in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}function Qx(n){var t=t_(n,"string");return typeof t=="symbol"?t:t+""}function t_(n,t){if(typeof n!="object"||!n)return n;var e=n[Symbol.toPrimitive];if(e!==void 0){var r=e.call(n,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(n)}function e_(n,t){let{left:e,top:r}=t.getBoundingClientRect(),i=n.clientX-Math.round(e),s=n.clientY-Math.round(r);return{x:i,y:s}}function r_(n,t,e,r,i){if(zp(n,i))return Tp(n,t,e,r);if(n.touches.length!==1){if([Er,Ar].indexOf(r.mode)>=0)return cp(r);if([Xe].indexOf(r.mode)>=0)return r}return ec(n,t,e,r,i,vp)}function n_(n,t,e,r,i){return zp(n,i)?Tp(n,t,e,r):[Er,Ar].indexOf(r.mode)>=0?ec(n,t,e,r,i,xp):r}function i_(n,t,e,r,i){if(!([Er,Ar].indexOf(r.mode)>=0))return r;let s=o_(n,r,i)?Ut(r,{pinchPointDistance:null}):r;return n.touches.length>0?s:ec(n,t,e,s,i,_p)}function s_(n,t,e,r,i){return n.stopPropagation(),n.preventDefault(),cp(r)}function Op(n){return typeof n.pinchPointDistance=="number"}function o_(n,t,e){return e.detectPinchGesture&&Op(t)&&n.touches.length<2}function zp(n,t){return t.detectPinchGesture&&n.touches.length>1}function ec(n,t,e,r,i,s){let o=n.touches.length===0?Ut(r,{mode:r.prePinchMode?Xe:r.mode,prePinchMode:null}):r,a=n.touches.length>0?n.touches[0]:n.changedTouches[0],l=e_(a,t);switch(e){case Zr:case Or:case cr:case hr:return n.stopPropagation(),n.preventDefault(),s(n,t,e,o,i,l);default:return o}}function Tp(n,t,e,r,i){const{left:s,top:o}=t.getBoundingClientRect(),a=n.touches[0].clientX-Math.round(s),l=n.touches[0].clientY-Math.round(o),c=n.touches[1].clientX-Math.round(s),h=n.touches[1].clientY-Math.round(o),f=Math.sqrt(Math.pow(c-a,2)+Math.pow(h-l,2)),g=Op(r)?r.pinchPointDistance:f,p=fr(r,(a+c)/2,(l+h)/2);let m=f/g;if(ma(r,m))return r;n.cancelable&&n.preventDefault();let v=fn(Js(r),Ye(p.x,p.y),ei(m,m),Ye(-p.x,-p.y));return Ut(r,Ut(Ap(Ap({mode:Ar},Ql(r,v)),{},{startX:null,startY:null,endX:null,endY:null,prePinchMode:r.prePinchMode?r.prePinchMode:r.mode,pinchPointDistance:f})))}function Cp(n){return Ut(n,{miniatureOpen:!0})}function kp(n){return Ut(n,{miniatureOpen:!1})}let a_=n=>["zoom-in","zoom-out","grab","grabbing"].indexOf(n)>-1,Ip=()=>navigator.userAgent.toLowerCase(),u_=()=>Ip().indexOf("firefox")>-1,l_=()=>Ip().indexOf("webkit")>-1;function va(n){if(!a_(n))return n;if(u_())return`-moz-${n}`;if(l_())return`-webkit-${n}`}function c_(n){return n.displayName||n.name||"Component"}function rc(){return rc=Object.assign?Object.assign.bind():function(n){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var r in e)({}).hasOwnProperty.call(e,r)&&(n[r]=e[r])}return n},rc.apply(null,arguments)}let h_=1;const f_=()=>`uid${h_++}`;function Pp(n){class t extends N.Component{constructor(r){super(r),this.state={uid:f_()}}render(){return N.createElement(n,rc({_uid:this.state.uid},this.props))}}return t.displayName=`RandomUID(${c_(n)})`,t}const Rp="react-svg-pan-zoom_border_gradient";function Lp(n){let{direction:t,width:e,height:r,_uid:i}=n,s;switch(t){case Kr:s=`translate(${e}, 0) rotate(90)`;break;case Je:s=`translate(${e}, ${r}) rotate(180)`;break;case Qr:s=`translate(0, ${r}) rotate(270)`;break;case Pe:default:s=" ";break}let o=`${Rp}_gradient_${i}`,a=`${Rp}_mask_${i}`;return N.createElement("g",null,N.createElement("defs",null,N.createElement("linearGradient",{id:o,x1:"0%",y1:"0%",x2:"100%",y2:"0%",spreadMethod:"pad"},N.createElement("stop",{offset:"0%",stopColor:"#fff",stopOpacity:"0.8"}),N.createElement("stop",{offset:"100%",stopColor:"#000",stopOpacity:"0.5"})),N.createElement("mask",{id:a,x:"0",y:"0",width:"20",height:Math.max(e,r)},N.createElement("rect",{x:"0",y:"0",width:"20",height:Math.max(e,r),style:{stroke:"none",fill:`url(#${o})`}}))),N.createElement("rect",{x:"0",y:"0",width:"20",height:Math.max(e,r),style:{stroke:"none",fill:"#000",mask:`url(#${a})`},transform:s}))}Lp.propTypes={direction:$.oneOf([Kr,Je,Qr,Pe]).isRequired,width:$.number.isRequired,height:$.number.isRequired};const xa=Pp(Lp);function Np(n){let{startX:t,startY:e,endX:r,endY:i}=n;if(!t||!e||!r||!i)return null;let s=pp({x:t,y:e},{x:r,y:i});return N.createElement("rect",{stroke:"#969FFF",strokeOpacity:.7,fill:"#F3F4FF",fillOpacity:.7,x:s.x,y:s.y,width:s.width,height:s.height,style:{pointerEvents:"none"}})}Np.propTypes={startX:$.number,startY:$.number,endX:$.number,endY:$.number};function d_(){return N.createElement("svg",{width:24,height:24,stroke:"currentColor"},N.createElement("path",{d:"M10.07,14.27C10.57,14.03 11.16,14.25 11.4,14.75L13.7,19.74L15.5,18.89L13.19,13.91C12.95,13.41 13.17,12.81 13.67,12.58L13.95,12.5L16.25,12.05L8,5.12V15.9L9.82,14.43L10.07,14.27M13.64,21.97C13.14,22.21 12.54,22 12.31,21.5L10.13,16.76L7.62,18.78C7.45,18.92 7.24,19 7,19A1,1 0 0,1 6,18V3A1,1 0 0,1 7,2C7.24,2 7.47,2.09 7.64,2.23L7.65,2.22L19.14,11.86C19.57,12.22 19.62,12.85 19.27,13.27C19.12,13.45 18.91,13.57 18.7,13.61L15.54,14.23L17.74,18.96C18,19.46 17.76,20.05 17.26,20.28L13.64,21.97Z"}))}function p_(){return N.createElement("svg",{width:24,height:24,stroke:"currentColor"},N.createElement("path",{d:"M13,6V11H18V7.75L22.25,12L18,16.25V13H13V18H16.25L12,22.25L7.75,18H11V13H6V16.25L1.75,12L6,7.75V11H11V6H7.75L12,1.75L16.25,6H13Z"}))}function g_(){return N.createElement("svg",{width:24,height:24,stroke:"currentColor"},N.createElement("g",null,N.createElement("path",{d:"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"}),N.createElement("path",{d:"M12 10h-2v2H9v-2H7V9h2V7h1v2h2v1z"})))}function m_(){return N.createElement("svg",{width:24,height:24,stroke:"currentColor"},N.createElement("path",{d:"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14zM7 9h5v1H7z"}))}function y_(){return N.createElement("svg",{width:24,height:24,stroke:"currentColor"},N.createElement("path",{d:"M15 3l2.3 2.3-2.89 2.87 1.42 1.42L18.7 6.7 21 9V3zM3 9l2.3-2.3 2.87 2.89 1.42-1.42L6.7 5.3 9 3H3zm6 12l-2.3-2.3 2.89-2.87-1.42-1.42L5.3 17.3 3 15v6zm12-6l-2.3 2.3-2.87-2.89-1.42 1.42 2.89 2.87L15 21h6z"}))}let Di=class extends N.Component{constructor(t){super(t),this.state={hover:!1}}change(t){switch(t.preventDefault(),t.stopPropagation(),t.type){case"mouseenter":case"touchstart":this.setState({hover:!0});break;case"mouseleave":case"touchend":case"touchcancel":this.setState({hover:!1});break}}render(){let t={display:"block",width:"24px",height:"24px",margin:[Kr,Qr].indexOf(this.props.toolbarPosition)>=0?"2px 1px":"1px 2px",color:this.props.active||this.state.hover?this.props.activeColor:"#FFF",transition:"color 200ms ease",background:"none",padding:"0px",border:"0px",outline:"0px",cursor:"pointer"};return N.createElement("button",{onMouseEnter:e=>this.change(e),onMouseLeave:e=>this.change(e),onTouchStart:e=>{this.change(e),this.props.onClick(e)},onTouchEnd:e=>this.change(e),onTouchCancel:e=>this.change(e),onClick:this.props.onClick,style:t,title:this.props.title,name:this.props.name,type:"button"},this.props.children)}};Di.propTypes={title:$.string.isRequired,name:$.string.isRequired,toolbarPosition:$.string.isRequired,activeColor:$.string.isRequired,onClick:$.func.isRequired,active:$.bool.isRequired};const v_="#1CA6FC";function Fp(n){let{tool:t,value:e,onChangeValue:r,onChangeTool:i,activeToolColor:s=v_,position:o=Je,SVGAlignX:a=Li,SVGAlignY:l=Ni}=n,c=(p,m)=>{i(m),p.stopPropagation(),p.preventDefault()},h=p=>{r(yp(e,a,l)),p.stopPropagation(),p.preventDefault()},f=[Kr,Qr].indexOf(o)>=0,g={position:"absolute",transform:[Kr,Qr].indexOf(o)>=0?"translate(-50%, 0px)":"none",top:[Pe,Je,Kr].indexOf(o)>=0?"5px":"unset",left:[Kr,Qr].indexOf(o)>=0?"50%":Pe===o?"5px":"unset",right:[Je].indexOf(o)>=0?"5px":"unset",bottom:[Qr].indexOf(o)>=0?"5px":"unset",backgroundColor:"rgba(19, 20, 22, 0.90)",borderRadius:"2px",display:"flex",flexDirection:f?"row":"column",padding:f?"1px 2px":"2px 1px"};return N.createElement("div",{style:g,role:"toolbar"},N.createElement(Di,{toolbarPosition:o,active:t===Jr,activeColor:s,name:"unselect-tools",title:"Selection",onClick:p=>c(p,Jr)},N.createElement(d_,null)),N.createElement(Di,{toolbarPosition:o,active:t===hr,activeColor:s,name:"select-tool-pan",title:"Pan",onClick:p=>c(p,hr)},N.createElement(p_,null)),N.createElement(Di,{toolbarPosition:o,active:t===Or,activeColor:s,name:"select-tool-zoom-in",title:"Zoom in",onClick:p=>c(p,Or)},N.createElement(g_,null)),N.createElement(Di,{toolbarPosition:o,active:t===Zr,activeColor:s,name:"select-tool-zoom-out",title:"Zoom out",onClick:p=>c(p,Zr)},N.createElement(m_,null)),N.createElement(Di,{toolbarPosition:o,active:!1,activeColor:s,name:"fit-to-viewer",title:"Fit to viewer",onClick:p=>h(p)},N.createElement(y_,null)))}Fp.propTypes={tool:$.string.isRequired,onChangeTool:$.func.isRequired,value:$.object.isRequired,onChangeValue:$.func.isRequired,position:$.oneOf([Kr,Je,Qr,Pe]),SVGAlignX:$.oneOf([Ri,Li,Jl]),SVGAlignY:$.oneOf([Ri,Ni,Zl]),activeToolColor:$.string};function x_(){return"ontouchstart"in window||navigator.maxTouchPoints}function jp(n){let{open:t,position:e}=n,r=0;switch(e){case Pe:r=t?"rotate(225, 12, 13)":"rotate(45, 12, 13)";break;case Je:r=r=t?"rotate(135, 12, 13)":"rotate(-45, 12, 13)";break}return N.createElement("svg",{width:24,height:24,stroke:"currentColor"},N.createElement("g",{transform:r},N.createElement("path",{fill:"#000000",d:"M7.41,15.41L12,10.83L16.59,15.41L18,14L12,8L6,14L7.41,15.41Z"})))}jp.propTypes={open:$.bool.isRequired,position:$.oneOf([Je,Pe]).isRequired};function Vp(n){let{value:t,onChangeValue:e,position:r}=n,i={width:"24px",height:"24px",display:"block",position:"absolute",bottom:0,[r===Pe?"left":"right"]:"0px",background:"rgba(19, 20, 22, 0.901961)",border:0,padding:0,outline:0,color:"#fff"},s=t.miniatureOpen?kp:Cp;return N.createElement("button",{type:"button",style:i,onClick:()=>e(s(t))},N.createElement(jp,{open:t.miniatureOpen,position:r}))}Vp.propTypes={value:$.object.isRequired,onChangeValue:$.func.isRequired,position:$.oneOf([Je,Pe]).isRequired};const __="react-svg-pan-zoom_miniature";function Dp(n){let{SVGMinX:t,SVGMinY:e,SVGWidth:r,SVGHeight:i,x1:s,y1:o,x2:a,y2:l,zoomToFit:c,_uid:h}=n;const f=`${__}_mask_${h}`;return N.createElement("g",null,N.createElement("defs",null,N.createElement("mask",{id:f},N.createElement("rect",{x:t,y:e,width:r,height:i,fill:"#ffffff"}),N.createElement("rect",{x:s,y:o,width:a-s,height:l-o}))),N.createElement("rect",{x:t,y:e,width:r,height:i,style:{stroke:"none",fill:"#000",mask:`url(#${f})`,opacity:.4}}))}Dp.propTypes={SVGWidth:$.number.isRequired,SVGHeight:$.number.isRequired,SVGMinX:$.number.isRequired,SVGMinY:$.number.isRequired,x1:$.number.isRequired,y1:$.number.isRequired,x2:$.number.isRequired,y2:$.number.isRequired,zoomToFit:$.number.isRequired};const b_=Pp(Dp),w_="#616264";function Bp(n){let{value:t,onChangeValue:e,children:r,SVGBackground:i,background:s=w_,position:o=Pe,width:a=100,height:l=80}=n,{SVGMinX:c,SVGMinY:h,SVGWidth:f,SVGHeight:g,viewerWidth:p,viewerHeight:m}=t,v=g/f,_=v>=1?l/g:a/f,[{x:S,y:A},{x:C,y:O}]=ep(np(t),[{x:0,y:0},{x:p,y:m}]),M,z;t.miniatureOpen?(M=a,z=l):(M=24,z=24);let R={position:"absolute",overflow:"hidden",outline:"1px solid rgba(19, 20, 22, 0.90)",transition:"width 200ms ease, height 200ms ease, bottom 200ms ease",width:M+"px",height:z+"px",bottom:"6px",[o===Pe?"left":"right"]:"6px",background:s},I=v>=1?`translate(${(a-f*_)/2-c*_}, ${-h*_})`:`translate(${-c*_}, ${(l-g*_)/2-h*_})`;return N.createElement("div",{role:"navigation",style:R},N.createElement("svg",{width:a,height:l,style:{pointerEvents:"none"}},N.createElement("g",{transform:I},N.createElement("g",{transform:`scale(${_}, ${_})`},N.createElement("rect",{fill:i,x:c,y:h,width:f,height:g}),r,N.createElement(b_,{SVGWidth:f,SVGHeight:g,SVGMinX:c,SVGMinY:h,x1:S,y1:A,x2:C,y2:O,zoomToFit:_})))),N.createElement(Vp,{value:t,onChangeValue:e,position:o}))}Bp.propTypes={value:$.object.isRequired,onChangeValue:$.func.isRequired,SVGBackground:$.string.isRequired,position:$.oneOf([Je,Pe]),background:$.string,width:$.number,height:$.number};function ri(n){return typeof n>"u"||n===null}const nc="https://github.com/chrvadala/react-svg-pan-zoom/blob/main"+"/docs/migrate-from-v2-to-v3.md";function S_(){console.error(`HEY! With ReactSVGPanZoom >= 3 you MUST specify value and tool props. Please read here ${nc}`)}function M_(){console.error(`HEY! With ReactSVGPanZoom >= 3 the props miniaturePosition, miniatureBackground, miniatureWidth, miniatureHeight can be specified as key in the miniatureProps object. Please read here ${nc}`)}function E_(){console.error(`HEY! With ReactSVGPanZoom >= 3 the prop toolbarPosition can be specified as key in the toolbarProps object. Please read here ${nc}`)}function qp(n){(ri(n.tool)||ri(n.value))&&S_(),(!ri(n.miniaturePosition)||!ri(n.miniatureBackground)||!ri(n.miniatureWidth)||!ri(n.miniatureHeight))&&M_(),ri(n.toolbarPosition)||E_()}function _a(){return _a=Object.assign?Object.assign.bind():function(n){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var r in e)({}).hasOwnProperty.call(e,r)&&(n[r]=e[r])}return n},_a.apply(null,arguments)}function $p(n,t){var e=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),e.push.apply(e,r)}return e}function A_(n){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?$p(Object(e),!0).forEach(function(r){O_(n,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(e)):$p(Object(e)).forEach(function(r){Object.defineProperty(n,r,Object.getOwnPropertyDescriptor(e,r))})}return n}function O_(n,t,e){return(t=z_(t))in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}function z_(n){var t=T_(n,"string");return typeof t=="symbol"?t:t+""}function T_(n,t){if(typeof n!="object"||!n)return n;var e=n[Symbol.toPrimitive];if(e!==void 0){var r=e.call(n,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(n)}class ba extends N.Component{constructor(t,e){const{width:r,height:i,scaleFactorMin:s,scaleFactorMax:o,children:a}=t,{viewBox:l}=a.props;let c;if(l){const[h,f,g,p]=Mp(l);c=up(r,i,h,f,g,p,s,o)}else{const{width:h,height:f}=a.props;c=up(r,i,0,0,h,f,s,o)}super(t,e),this.ViewerDOM=null,this.state={pointerX:null,pointerY:null,defaultValue:c},this.autoPanLoop=this.autoPanLoop.bind(this),this.onWheel=this.onWheel.bind(this),process.env.NODE_ENV!=="production"&&qp(t)}componentDidUpdate(t){const e=this.getValue(),r=this.props;let i=e,s=!1;process.env.NODE_ENV!=="production"&&qp(r);const{viewBox:o}=r.children.props;if(o){const[a,l,c,h]=Mp(o);(e.SVGMinX!==a||e.SVGMinY!==l||e.SVGWidth!==c||e.SVGHeight!==h)&&(i=lp(i,a,l,c,h),s=!0)}else{const{width:a,height:l}=r.children.props;(e.SVGWidth!==a||e.SVGHeight!==l)&&(i=lp(i,0,0,a,l),s=!0)}(t.width!==r.width||t.height!==r.height)&&(i=Ax(i,r.width,r.height),s=!0),(t.scaleFactorMin!==r.scaleFactorMin||t.scaleFactorMax!==r.scaleFactorMax)&&(i=Ox(i,r.scaleFactorMin,r.scaleFactorMax),s=!0),s&&this.setValue(i)}componentDidMount(){this.autoPanIsRunning=!0,requestAnimationFrame(this.autoPanLoop),this.ViewerDOM.addEventListener("wheel",this.onWheel,!1)}componentWillUnmount(){this.autoPanIsRunning=!1,this.ViewerDOM.removeEventListener("wheel",this.onWheel)}getValue(){return Mx(this.props.value)?this.props.value:this.state.defaultValue}getTool(){return this.props.tool?this.props.tool:Jr}setValue(t){let{onChangeValue:e,onZoom:r,onPan:i}=this.props;e&&e(t),t.lastAction&&(r&&t.lastAction===da&&r(t),i&&t.lastAction===Zs&&i(t))}pan(t,e){let r=Kl(this.getValue(),t,e);this.setValue(r)}zoom(t,e,r){let i=ji(this.getValue(),t,e,r);this.setValue(i)}fitSelection(t,e,r,i){let s=mp(this.getValue(),t,e,r,i);this.setValue(s)}fitToViewer(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Li,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Ni,r=yp(this.getValue(),t,e);this.setValue(r)}zoomOnViewerCenter(t){let e=Dx(this.getValue(),t);this.setValue(e)}setPointOnViewerCenter(t,e,r){let i=zx(this.getValue(),t,e,r);this.setValue(i)}reset(){let t=Tx(this.getValue());this.setValue(t)}openMiniature(){let t=Cp(this.getValue());this.setValue(t)}closeMiniature(){let t=kp(this.getValue());this.setValue(t)}handleViewerEvent(t){let{props:e,ViewerDOM:r}=this;if(!([Jr,cr].indexOf(this.getTool())>=0)||t.target===r)return;let s={click:e.onClick,dblclick:e.onDoubleClick,mousemove:e.onMouseMove,mouseup:e.onMouseUp,mousedown:e.onMouseDown,touchstart:e.onTouchStart,touchmove:e.onTouchMove,touchend:e.onTouchEnd,touchcancel:e.onTouchCancel}[t.type];s&&s(Zx(t,e.value,r))}autoPanLoop(){let t={x:this.state.pointerX,y:this.state.pointerY},e=Wx(null,this.ViewerDOM,this.getTool(),this.getValue(),this.props,t);this.getValue()!==e&&this.setValue(e),this.autoPanIsRunning&&requestAnimationFrame(this.autoPanLoop)}onWheel(t){let e=Gx(t,this.ViewerDOM,this.getTool(),this.getValue(),this.props);this.getValue()!==e&&this.setValue(e)}render(){let{props:t,state:{pointerX:e,pointerY:r}}=this,i=this.getTool(),s=this.getValue(),{customToolbar:o=Fp,customMiniature:a=Bp}=t,l=i===cr&&s.mode===Er&&s.startX!==s.endX&&s.startY!==s.endY,c;i===hr&&(c=va(s.mode===Er?"grabbing":"grab")),i===Or&&(c=va("zoom-in")),i===Zr&&(c=va("zoom-out")),l&&(c=va("grabbing"));let h=[hr,Or,Zr].indexOf(i)>=0;h=h||l;const f=this.props.detectPinchGesture||[hr,cr].indexOf(this.getTool())!==-1?"none":void 0,g={display:"block",cursor:c,touchAction:f};return N.createElement("div",{style:A_({position:"relative",width:s.viewerWidth,height:s.viewerHeight},t.style),className:this.props.className},N.createElement("svg",{ref:p=>this.ViewerDOM=p,width:s.viewerWidth,height:s.viewerHeight,style:g,onMouseDown:p=>{let m=vp(p,this.ViewerDOM,this.getTool(),this.getValue(),this.props);this.getValue()!==m&&this.setValue(m),this.handleViewerEvent(p)},onMouseMove:p=>{let{left:m,top:v}=this.ViewerDOM.getBoundingClientRect(),_=p.clientX-Math.round(m),S=p.clientY-Math.round(v),A=xp(p,this.ViewerDOM,this.getTool(),this.getValue(),this.props,{x:_,y:S});this.getValue()!==A&&this.setValue(A),this.setState({pointerX:_,pointerY:S}),this.handleViewerEvent(p)},onMouseUp:p=>{let m=_p(p,this.ViewerDOM,this.getTool(),this.getValue(),this.props);this.getValue()!==m&&this.setValue(m),this.handleViewerEvent(p)},onClick:p=>{this.handleViewerEvent(p)},onDoubleClick:p=>{let m=Hx(p,this.ViewerDOM,this.getTool(),this.getValue(),this.props);this.getValue()!==m&&this.setValue(m),this.handleViewerEvent(p)},onMouseEnter:p=>{if(x_())return;let m=bp(p,this.ViewerDOM,this.getTool(),this.getValue(),this.props);this.getValue()!==m&&this.setValue(m)},onMouseLeave:p=>{let m=bp(p,this.ViewerDOM,this.getTool(),this.getValue(),this.props);this.getValue()!==m&&this.setValue(m)},onTouchStart:p=>{let m=r_(p,this.ViewerDOM,this.getTool(),this.getValue(),this.props);this.getValue()!==m&&this.setValue(m),this.handleViewerEvent(p)},onTouchMove:p=>{let m=n_(p,this.ViewerDOM,this.getTool(),this.getValue(),this.props);this.getValue()!==m&&this.setValue(m),this.handleViewerEvent(p)},onTouchEnd:p=>{let m=i_(p,this.ViewerDOM,this.getTool(),this.getValue(),this.props);this.getValue()!==m&&this.setValue(m),this.handleViewerEvent(p)},onTouchCancel:p=>{let m=s_(p,this.ViewerDOM,this.getTool(),this.getValue(),this.props);this.getValue()!==m&&this.setValue(m),this.handleViewerEvent(p)}},N.createElement("rect",{fill:t.background,x:0,y:0,width:s.viewerWidth,height:s.viewerHeight,style:{pointerEvents:"none"}}),N.createElement("g",{transform:vx(s),style:h?{pointerEvents:"none"}:{}},N.createElement("rect",{fill:this.props.SVGBackground,style:this.props.SVGStyle,x:s.SVGMinX||0,y:s.SVGMinY||0,width:s.SVGWidth,height:s.SVGHeight}),N.createElement("g",null,t.children.props.children)),[Jr,cr].indexOf(i)>=0&&t.detectAutoPan&&s.focus?N.createElement("g",{style:{pointerEvents:"none"}},r<=20?N.createElement(xa,{direction:Kr,width:s.viewerWidth,height:s.viewerHeight}):null,s.viewerWidth-e<=20?N.createElement(xa,{direction:Je,width:s.viewerWidth,height:s.viewerHeight}):null,s.viewerHeight-r<=20?N.createElement(xa,{direction:Qr,width:s.viewerWidth,height:s.viewerHeight}):null,s.focus&&e<=20?N.createElement(xa,{direction:Pe,width:s.viewerWidth,height:s.viewerHeight}):null):null,s.mode!==Ar?null:N.createElement(Np,{startX:s.startX,startY:s.startY,endX:s.endX,endY:s.endY})),t.toolbarProps.position===fa?null:N.createElement(o,_a({},this.props.toolbarProps,{value:s,onChangeValue:p=>this.setValue(p),tool:i,onChangeTool:p=>this.props.onChangeTool(p)})),t.miniatureProps.position===fa?null:N.createElement(a,_a({},this.props.miniatureProps,{value:s,onChangeValue:p=>this.setValue(p),SVGBackground:this.props.SVGBackground}),t.children.props.children))}}ba.propTypes={width:$.number.isRequired,height:$.number.isRequired,value:$.oneOfType([$.object,$.shape({version:$.oneOf([2]).isRequired,mode:$.oneOf([Xe,Er,Ar]).isRequired,focus:$.bool.isRequired,a:$.number.isRequired,b:$.number.isRequired,c:$.number.isRequired,d:$.number.isRequired,e:$.number.isRequired,f:$.number.isRequired,viewerWidth:$.number.isRequired,viewerHeight:$.number.isRequired,SVGMinX:$.number.isRequired,SVGMinY:$.number.isRequired,SVGWidth:$.number.isRequired,SVGHeight:$.number.isRequired,startX:$.number,startY:$.number,endX:$.number,endY:$.number,miniatureOpen:$.bool.isRequired})]).isRequired,onChangeValue:$.func.isRequired,tool:$.oneOf([cr,Jr,hr,Or,Zr]).isRequired,onChangeTool:$.func.isRequired,background:$.string,SVGBackground:$.string,SVGStyle:$.object,style:$.object,className:$.string,detectWheel:$.bool,detectAutoPan:$.bool,detectPinchGesture:$.bool,onZoom:$.func,onPan:$.func,onClick:$.func,onDoubleClick:$.func,onMouseUp:$.func,onMouseMove:$.func,onMouseDown:$.func,preventPanOutside:$.bool,scaleFactor:$.number,scaleFactorOnWheel:$.number,scaleFactorMax:$.number,scaleFactorMin:$.number,modifierKeys:$.array,disableDoubleClickZoomWithToolAuto:$.bool,customMiniature:$.oneOfType([$.element,$.func]),miniatureProps:$.shape({position:$.oneOf([fa,Je,Pe]),background:$.string,width:$.number,height:$.number}),customToolbar:$.oneOfType([$.element,$.func]),toolbarProps:$.shape({position:$.oneOf([fa,Kr,Je,Qr,Pe]),SVGAlignX:$.oneOf([Ri,Li,Jl]),SVGAlignY:$.oneOf([Ri,Ni,Zl]),activeToolColor:$.string}),children:function(n,t,e){let r=n[t],i=["svg"];if(N.Children.count(r)!==1||i.indexOf(r.type)===-1)return new Error("`"+e+"` should have a single child of the following types: `"+i.join("`, `")+"`.");if((!r.props.hasOwnProperty("width")||!r.props.hasOwnProperty("height"))&&!r.props.hasOwnProperty("viewBox"))return new Error("SVG should have props `width` and `height` or `viewBox`")}},ba.defaultProps={style:{},background:"#616264",SVGBackground:"#fff",SVGStyle:{},detectWheel:!0,detectAutoPan:!0,detectPinchGesture:!0,modifierKeys:["Alt","Shift","Control"],preventPanOutside:!0,scaleFactor:1.1,scaleFactorOnWheel:1.06,disableZoomWithToolAuto:!1,onZoom:null,onPan:null,toolbarProps:{},miniatureProps:{}};const C_=["width","height","onChangeTool","onChangeValue"];function ic(){return ic=Object.assign?Object.assign.bind():function(n){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var r in e)({}).hasOwnProperty.call(e,r)&&(n[r]=e[r])}return n},ic.apply(null,arguments)}function k_(n,t){if(n==null)return{};var e,r,i=I_(n,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(n);for(r=0;r<s.length;r++)e=s[r],t.includes(e)||{}.propertyIsEnumerable.call(n,e)&&(i[e]=n[e])}return i}function I_(n,t){if(n==null)return{};var e={};for(var r in n)if({}.hasOwnProperty.call(n,r)){if(t.includes(r))continue;e[r]=n[r]}return e}class P_ extends N.Component{constructor(t){super(t),this.state={value:t.defaultValue||{},tool:t.defaultTool||Jr},this.Viewer=null,this.changeTool=this.changeTool.bind(this),this.changeValue=this.changeValue.bind(this)}changeTool(t){this.setState({tool:t})}changeValue(t){this.setState({value:t})}pan(t,e){this.Viewer.pan(t,e)}zoom(t,e,r){this.Viewer.zoom(t,e,r)}fitSelection(t,e,r,i){this.Viewer.fitSelection(t,e,r,i)}fitToViewer(t,e){this.Viewer.fitToViewer(t,e)}zoomOnViewerCenter(t){this.Viewer.zoomOnViewerCenter(t)}setPointOnViewerCenter(t,e,r){this.Viewer.setPointOnViewerCenter(t,e,r)}reset(){this.Viewer.reset()}openMiniature(){this.Viewer.openMiniature()}closeMiniature(){this.Viewer.closeMiniature()}render(){const t=this.props,{width:e,height:r,onChangeTool:i,onChangeValue:s}=t,o=k_(t,C_),{tool:a,value:l}=this.state;return N.createElement(ba,ic({width:e,height:r,tool:a,onChangeTool:this.changeTool,value:l,onChangeValue:this.changeValue,ref:c=>this.Viewer=c},o))}}P_.propTypes={width:$.number.isRequired,height:$.number.isRequired,defaultValue:$.object,defaultTool:$.string};const Jt=a0(n=>({planner:new ra,viewer:null,plan:null,activeFloor:0,setViewer:t=>{n(e=>({...e,viewer:t}))},setActiveFloor:t=>{n(e=>({...e,activeFloor:t}))},newProject:()=>{n(t=>({...t,planner:qt.newProject(t.planner).updatedState}))},selectTool3DView:()=>{n(t=>{const e=qt.rollback(t.planner).updatedState;return e.set("mode",Qn),{...t,planner:e}})},selectTool3DFirstPerson:()=>{n(t=>{const e=qt.rollback(t.planner).updatedState;return e.set("mode",ki),{...t,planner:e}})},loadProject:t=>{n(e=>{const r=new ra({scene:t,catalog:e.planner.catalog.toJS()});return{...e,planner:r}})},undo:()=>{n(t=>{const e=qt.undo(t.planner).updatedState;return{...t,planner:e}})},redo:()=>{n(t=>{const e=qt.redo(t.planner).updatedState;return{...t,planner:e}})},addLayer:(t,e)=>{n(r=>{const i=pt.create(r.planner,t,e).updatedState;return{...r,planner:i}})},removeLayer:t=>{n(e=>{const r=pt.remove(e.planner,t).updatedState;return{...e,planner:r}})},addGroup:()=>{n(t=>{const e=ce.create(t.planner).updatedState;return{...t,planner:e}})},selectGroup:t=>{n(e=>{const r=ce.select(e.planner,t).updatedState;return{...e,planner:r}})},setGroupProperties:(t,e)=>{n(r=>{const i=ce.setProperties(r.planner,t,e).updatedState;return{...r,planner:i}})},addToGroup:(t,e,r,i)=>{n(s=>{const o=ce.addElement(s.planner,t,e,r,i).updatedState;return{...s,planner:o}})},removeGroup:t=>{n(e=>{const r=ce.remove(e.planner,t).updatedState;return{...e,planner:r}})},setGroupAttributes:(t,e)=>{n(r=>{const i=ce.setAttributes(r.planner,t,e).updatedState;return{...r,planner:i}})},groupTranslate:(t,e,r)=>{n(i=>{const s=ce.translate(i.planner,t,e,r).updatedState;return{...i,planner:s}})},removeFromGroup:(t,e,r,i)=>{n(s=>{const o=ce.removeElement(s.planner,t,e,r,i).updatedState;return{...s,planner:o}})},groupRotate:(t,e)=>{n(r=>{const i=ce.rotate(r.planner,t,e).updatedState;return{...r,planner:i}})},removeGroupAndDeleteElements:t=>{n(e=>{const r=ce.removeAndDeleteElements(e.planner,t).updatedState;return{...e,planner:r}})},addGroupFromSelected:()=>{n(t=>{const e=ce.createFromSelectedElements(t.planner).updatedState;return{...t,planner:e}})},copyProperties:t=>{n(e=>({...e,planner:qt.copyProperties(e.planner,t).updatedState}))},pasteProperties:()=>{n(t=>{const e=t.planner.merge({sceneHistory:ne(t.planner.sceneHistory,t.planner.scene)});return{...t,planner:qt.pasteProperties(e).updatedState}})},setProperties:t=>{n(e=>{const r=e.planner.merge({sceneHistory:ne(e.planner.sceneHistory,e.planner.scene)});return{...e,planner:qt.setProperties(r,r.getIn(["scene","selectedLayer"]),t).updatedState}})},setHolesAttributes:t=>{n(e=>{const r=t.set("offset",parseFloat(t.get("offset"))),i=e.planner.merge({sceneHistory:ne(e.planner.sceneHistory,e.planner.scene)});return{...e,planner:qt.setHolesAttributes(i,r).updatedState}})},setLinesAttributes:t=>{n(e=>{const r=t.withMutations(s=>{s.setIn(["vertexOne","x"],parseFloat(t.getIn(["vertexOne","x"]))),s.setIn(["vertexOne","y"],parseFloat(t.getIn(["vertexOne","y"]))),s.setIn(["vertexTwo","x"],parseFloat(t.getIn(["vertexTwo","x"]))),s.setIn(["vertexTwo","y"],parseFloat(t.getIn(["vertexTwo","y"])))}),i=e.planner.merge({sceneHistory:ne(e.planner.sceneHistory,e.planner.scene)});return{...e,planner:qt.setLinesAttributes(i,r).updatedState}})},setItemsAttributes:t=>{n(e=>{const r=t.set("rotation",parseFloat(t.get("rotation"))),i=e.planner.merge({sceneHistory:ne(e.planner.sceneHistory,e.planner.scene)});return{...e,planner:qt.setItemsAttributes(i,r).updatedState}})},selectLine:(t,e)=>{n(r=>{const i=xe.select(r.planner,t,e).updatedState;return{...r,planner:i}})},selectHole:(t,e)=>{n(r=>{const i=le.select(r.planner,t,e).updatedState;return{...r,planner:i}})},selectItem:(t,e)=>{n(r=>{const i=pe.select(r.planner,t,e).updatedState;return{...r,planner:i}})},selectLayer:t=>{n(e=>{const r=pt.select(e.planner,t).updatedState;return{...e,planner:r}})},setLayerProperties:(t,e)=>{n(r=>{const i=pt.setProperties(r.planner,t,e).updatedState;return{...r,planner:i}})},addVerticalGuide:t=>{n(e=>{const r=ua.create(e.planner,t).updatedState;return{...e,planner:r}})},addHorizontalGuide:t=>{n(e=>{const r=aa.create(e.planner,t).updatedState;return{...e,planner:r}})},removeVerticalGuide:t=>{n(e=>{const r=ua.remove(e.planner,t).updatedState;return{...e,planner:r}})},removeHorizontalGuide:t=>{n(e=>{const r=aa.remove(e.planner,t).updatedState;return{...e,planner:r}})},toggleSnap:t=>{n(e=>{const r=qt.toggleSnap(e.planner,t).updatedState;return{...e,planner:r}})},openProjectConfigurator:()=>{n(t=>{const e=qt.openProjectConfigurator(t.planner).updatedState;return{...t,planner:e}})},setMode:t=>{n(e=>{const r=e.planner.set("mode",t);return{...e,planner:r}})},updateZoomScale:t=>{n(e=>({...e,planner:qt.updateZoomScale(e.planner,t).updatedState}))},updateCameraView:t=>{n(e=>{const r=e.planner.update("viewer2D",i=>i.merge(Bt(t)));return{...e,planner:r}})},selectToolPan:()=>{n(t=>{const e=t.planner.set("mode",Kn);return{...t,planner:e}})},selectToolEdit:()=>{n(t=>({...t,planner:qt.setMode(t.planner,re).updatedState}))},selectToolZoomIn:()=>{n(t=>{const e=t.planner.set("mode",Jn);return{...t,planner:e}})},selectToolZoomOut:()=>{n(t=>{const e=t.planner.set("mode",Zn);return{...t,planner:e}})},updateDrawingLine:(t,e)=>{n(r=>({...r,planner:xe.updateDrawingLine(r.planner,t,e).updatedState}))},updateMouseCoord:t=>{n(e=>({...e,planner:qt.updateMouseCoord(e.planner,t).updatedState}))},openCatalog:()=>{n(t=>{const e=t.planner.set("mode",cl);return{...t,planner:e}})},updateDrawingHole:(t,e,r)=>{n(i=>({...i,planner:le.updateDrawingHole(i.planner,t,e,r).updatedState}))},updateDrawingItem:(t,e,r)=>{n(i=>({...i,planner:pe.updateDrawingItem(i.planner,t,e,r).updatedState}))},blur:()=>{n(t=>{const e=t.planner.merge({mode:re,activeSnapElement:null});return{...t,planner:e}})},updateDraggingHole:(t,e)=>{n(r=>({...r,planner:le.updateDraggingHole(r.planner,t,e).updatedState}))},updateDraggingLine:(t,e)=>{n(r=>({...r,planner:xe.updateDraggingLine(r.planner,t,e).updatedState}))},updateDraggingVertex:(t,e)=>{n(r=>({...r,planner:ie.updateDraggingVertex(r.planner,t,e).updatedState}))},updateDraggingItem:(t,e)=>{n(r=>({...r,planner:pe.updateDraggingItem(r.planner,t,e).updatedState}))},updateRotatingItem:(t,e)=>{n(r=>({...r,planner:pe.updateRotatingItem(r.planner,t,e).updatedState}))},beginDraggingLine:(t,e,r,i)=>{n(s=>{const o=s.planner.merge({sceneHistory:ne(s.planner.sceneHistory,s.planner.scene)});return{...s,planner:xe.beginDraggingLine(o,t,e,r,i).updatedState}})},endDraggingLine:(t,e)=>{n(r=>{const i=r.planner.merge({sceneHistory:ne(r.planner.sceneHistory,r.planner.scene)});return{...r,planner:xe.endDraggingLine(i,t,e).updatedState}})},beginDraggingVertex:(t,e)=>{n(r=>({...r,planner:ie.beginDraggingVertex(r.planner,t,e).updatedState}))},endDraggingVertex:()=>{n(t=>({...t,planner:ie.endDraggingVertex(t.planner).updatedState}))},beginRotatingItem:(t,e,r,i)=>{n(s=>{const o=s.planner.merge({sceneHistory:ne(s.planner.sceneHistory,s.planner.scene)});return{...s,planner:pe.beginRotatingItem(o,t,e,r,i).updatedState}})},endRotatingItem:(t,e)=>{n(r=>{const i=r.planner.merge({sceneHistory:ne(r.planner.sceneHistory,r.planner.scene)});return{...r,planner:pe.endRotatingItem(i,t,e).updatedState}})},beginDraggingItem:(t,e,r,i)=>{n(s=>{const o=s.planner.merge({sceneHistory:ne(s.planner.sceneHistory,s.planner.scene)});return{...s,planner:pe.beginDraggingItem(o,t,e,r,i).updatedState}})},endDraggingItem:(t,e)=>{n(r=>{const i=r.planner.merge({sceneHistory:ne(r.planner.sceneHistory,r.planner.scene)});return{...r,planner:pe.endDraggingItem(i,t,e).updatedState}})},beginDraggingHole:(t,e,r,i)=>{n(s=>{const o=s.planner.merge({sceneHistory:ne(s.planner.sceneHistory,s.planner.scene)});return{...s,planner:le.beginDraggingHole(o,t,e,r,i).updatedState}})},endDraggingHole:(t,e)=>{n(r=>{const i=r.planner.merge({sceneHistory:ne(r.planner.sceneHistory,r.planner.scene)});return{...r,planner:le.endDraggingHole(i,t,e).updatedState}})},beginDrawingLine:(t,e,r)=>{n(i=>{const s=i.planner.merge({sceneHistory:ne(i.planner.sceneHistory,i.planner.scene)});return{...i,planner:xe.beginDrawingLine(s,t,e,r).updatedState}})},endDrawingLine:(t,e)=>{n(r=>{const i=r.planner.merge({sceneHistory:ne(r.planner.sceneHistory,r.planner.scene)});return{...r,planner:xe.endDrawingLine(i,t,e).updatedState}})},endDrawingHole:(t,e,r)=>{n(i=>{const s=i.planner.merge({sceneHistory:ne(i.planner.sceneHistory,i.planner.scene)});return{...i,planner:le.endDrawingHole(s,t,e,r).updatedState}})},endDrawingItem:(t,e,r)=>{n(i=>{const s=i.planner.merge({sceneHistory:ne(i.planner.sceneHistory,i.planner.scene)});return{...i,planner:pe.endDrawingItem(s,t,e,r).updatedState}})},selectArea:(t,e)=>{n(r=>({...r,planner:ti.select(r.planner,t,e).updatedState}))},initCatalog:t=>{n(e=>({...e,planner:qt.initCatalog(e.planner,t).updatedState}))},goBackToCatalogPage:t=>{n(e=>({...e,planner:qt.goBackToCatalogPage(e.planner,t).updatedState}))},pushLastSelectedCatalogElementToHistory:t=>{n(e=>({...e,planner:qt.pushLastSelectedCatalogElementToHistory(e.planner,t).updatedState}))},selectToolDrawingLine:t=>{n(e=>({...e,planner:xe.selectToolDrawingLine(e.planner,t).updatedState}))},selectToolDrawingItem:t=>{n(e=>{const r=e.planner.merge({sceneHistory:ne(e.planner.sceneHistory,e.planner.scene)});return{...e,planner:pe.selectToolDrawingItem(r,t).updatedState}})},selectToolDrawingHole:t=>{n(e=>{const r=e.planner.merge({sceneHistory:ne(e.planner.sceneHistory,e.planner.scene)});return{...e,planner:le.selectToolDrawingHole(r,t).updatedState}})},changeCatalogPage:(t,e)=>{n(r=>({...r,planner:qt.changeCatalogPage(r.planner,e,t).updatedState}))},remove:()=>{n(t=>{const e=t.planner.merge({sceneHistory:ne(t.planner.sceneHistory,t.planner.scene)});return{...t,planner:qt.remove(e).updatedState}})},rollback:()=>{n(t=>({...t,planner:qt.rollback(t.planner).updatedState}))},setAlterateState:()=>{n(t=>({...t,planner:qt.setAlterate(t.planner).updatedState}))},setPlan:t=>{n(e=>({...e,plan:t}))},unselectAll:()=>{n(t=>({...t,planner:qt.unselectAll(t.planner).updatedState}))}})),Ks={stroke:"#D32F2F",strokeWidth:"1px"};function R_({snap:n,width:t,height:e}){switch(n.type){case"point":return w.jsxs("g",{transform:`translate(${n.x} ${n.y})`,children:[w.jsx("line",{x1:"0",y1:"-70",x2:"0",y2:"70",style:Ks}),w.jsx("line",{x1:"-70",y1:"0",x2:"70",y2:"0",style:Ks})]});case"line":let r=Zo(0),i=Zo(e),s=Ys(n.a,n.b,n.c,r.a,r.b,r.c),o=Ys(n.a,n.b,n.c,i.a,i.b,i.c),a=Ko(0),l=Ko(t),c=Ys(n.a,n.b,n.c,a.a,a.b,a.c),h=Ys(n.a,n.b,n.c,l.a,l.b,l.c);return s&&o?w.jsx("line",{x1:s.x,y1:s.y,x2:o.x,y2:o.y,style:Ks}):c&&h?w.jsx("line",{x1:c.x,y1:c.y,x2:h.x,y2:h.y,style:Ks}):null;case"line-segment":return w.jsx("line",{x1:n.x1,y1:n.y1,x2:n.x2,y2:n.y2,style:Ks});default:return null}}const Hp={white:"#FFF",black:"#000"},Gp={500:{orange:"#FF9800"}},L_={alt:"#2E2F33",text_main:Hp.white},N_={main:"#1CA6FC"},sc="#99C3FB",jt={COLORS:Hp,PRIMARY_COLOR:L_,SECONDARY_COLOR:N_,MESH_SELECTED:sc,AREA_MESH_COLOR:{selected:sc,unselected:"#F5F4F4"},LINE_MESH_COLOR:{selected:sc}};function F_({width:n,height:t,grid:e}){let r=e.properties.get("step"),i;e.properties.has("color")?i=st([e.properties.get("color")]):i=e.properties.get("colors");let s=[],o=0;for(let a=0;a<=t;a+=r){let l=i.get(o%i.size);o++,s.push(w.jsx("line",{x1:"0",y1:a,x2:n,y2:a,strokeWidth:"1",stroke:l},a))}return w.jsx("g",{children:s})}function j_({width:n,height:t,grid:e}){let r=e.properties.get("step"),i;e.properties.has("color")?i=st([e.properties.get("color")]):i=e.properties.get("colors");let s=[],o=0;for(let a=0;a<=n;a+=r){let l=i.get(o%i.size);o++,s.push(w.jsx("line",{x1:a,y1:"0",x2:a,y2:t,strokeWidth:"1",stroke:l},a))}return w.jsx("g",{children:s})}function V_({scene:n}){let{width:t,height:e,grids:r}=n,i=r.entrySeq().map(([s,o])=>{switch(o.type){case"horizontal-streak":return w.jsx(F_,{width:t,height:e,grid:o},s);case"vertical-streak":return w.jsx(j_,{width:t,height:e,grid:o},s);default:console.warn(`grid ${o.type} not allowed`)}}).toList();return w.jsx("g",{children:i})}class D_{constructor(t=[],e=(r,i)=>r<i?-1:r>i?1:0){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let r=(this.length>>1)-1;r>=0;r--)this._down(r)}push(t){this.data.push(t),this._up(this.length++)}pop(){if(this.length===0)return;const t=this.data[0],e=this.data.pop();return--this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:r}=this,i=e[t];for(;t>0;){const s=t-1>>1,o=e[s];if(r(i,o)>=0)break;e[t]=o,t=s}e[t]=i}_down(t){const{data:e,compare:r}=this,i=this.length>>1,s=e[t];for(;t<i;){let o=(t<<1)+1;const a=o+1;if(a<this.length&&r(e[a],e[o])<0&&(o=a),r(e[o],s)>=0)break;e[t]=e[o],t=o}e[t]=s}}function B_(n,t=1,e=!1){let r=1/0,i=1/0,s=-1/0,o=-1/0;for(const[S,A]of n[0])S<r&&(r=S),A<i&&(i=A),S>s&&(s=S),A>o&&(o=A);const a=s-r,l=o-i,c=Math.max(t,Math.min(a,l));if(c===t){const S=[r,i];return S.distance=0,S}const h=new D_([],(S,A)=>A.max-S.max);let f=$_(n);const g=new wa(r+a/2,i+l/2,0,n);g.d>f.d&&(f=g);let p=2;function m(S,A,C){const O=new wa(S,A,C,n);p++,O.max>f.d+t&&h.push(O),O.d>f.d&&(f=O,e&&console.log(`found best ${Math.round(1e4*O.d)/1e4} after ${p} probes`))}let v=c/2;for(let S=r;S<s;S+=c)for(let A=i;A<o;A+=c)m(S+v,A+v,v);for(;h.length;){const{max:S,x:A,y:C,h:O}=h.pop();if(S-f.d<=t)break;v=O/2,m(A-v,C-v,v),m(A+v,C-v,v),m(A-v,C+v,v),m(A+v,C+v,v)}e&&console.log(`num probes: ${p}
|
|
70
|
+
best distance: ${f.d}`);const _=[f.x,f.y];return _.distance=f.d,_}function wa(n,t,e,r){this.x=n,this.y=t,this.h=e,this.d=q_(n,t,r),this.max=this.d+this.h*Math.SQRT2}function q_(n,t,e){let r=!1,i=1/0;for(const s of e)for(let o=0,a=s.length,l=a-1;o<a;l=o++){const c=s[o],h=s[l];c[1]>t!=h[1]>t&&n<(h[0]-c[0])*(t-c[1])/(h[1]-c[1])+c[0]&&(r=!r),i=Math.min(i,H_(n,t,c,h))}return i===0?0:(r?1:-1)*Math.sqrt(i)}function $_(n){let t=0,e=0,r=0;const i=n[0];for(let o=0,a=i.length,l=a-1;o<a;l=o++){const c=i[o],h=i[l],f=c[0]*h[1]-h[0]*c[1];e+=(c[0]+h[0])*f,r+=(c[1]+h[1])*f,t+=f*3}const s=new wa(e/t,r/t,0,n);return t===0||s.d<0?new wa(i[0][0],i[0][1],0,n):s}function H_(n,t,e,r){let i=e[0],s=e[1],o=r[0]-i,a=r[1]-s;if(o!==0||a!==0){const l=((n-i)*o+(t-s)*a)/(o*o+a*a);l>1?(i=r[0],s=r[1]):l>0&&(i+=o*l,s+=a*l)}return o=n-i,a=t-s,o*o+a*a}function Wp(n,t){var e=n.length,r=0;n=n.map(G_),n[0]!=n[n.length-1]&&(n=n.concat(n[0]));for(var i=0;i<e;i++)r+=n[i].x*n[i+1].y-n[i].y*n[i+1].x;return Math.abs(r)/2}function G_(n){return Array.isArray(n)?{x:n[0],y:n[1]}:n}const W_={textAnchor:"middle",fontSize:"12px",fontFamily:'"Courier New", Courier, monospace',pointerEvents:"none",fontWeight:"bold",WebkitTouchCallout:"none",WebkitUserSelect:"none",MozUserSelect:"none",userSelect:"none"};function U_({layer:n,area:t,catalog:e}){let r=e.getElement(t.type).render2D(t,n),i=null;if(t.selected){let s=t.vertices.toArray().map(c=>{let{x:h,y:f}=n.vertices.get(c);return[h,f]}),o=s;t.holes.forEach(c=>{let h=n.areas.get(c).vertices.toArray().map(f=>{let{x:g,y:p}=n.vertices.get(f);return[g,p]});o=o.concat(h.reverse())});let a=B_([o],1),l=Wp(s);t.holes.forEach(c=>{let f=n.areas.get(c).vertices.toArray().map(g=>{let{x:p,y:m}=n.vertices.get(g);return[p,m]});l-=Wp(f)}),i=w.jsxs("text",{x:"0",y:"0",transform:`translate(${a[0]} ${a[1]}) scale(1, -1)`,style:W_,children:[(l/1e4).toFixed(2)," m","²"]})}return w.jsxs("g",{"data-element-root":!0,"data-prototype":t.prototype,"data-id":t.id,"data-selected":t.selected,"data-layer":n.id,children:[r,i]})}const Y_=0,X_=0,J_=5,Z_={fill:Gp[500].orange,stroke:Gp[500].orange,cursor:"default"};function K_({layer:n,group:t}){return w.jsx("g",{"data-element-root":!0,"data-prototype":t.prototype,"data-id":t.id,"data-selected":t.selected,"data-layer":n.id,style:t.selected?{cursor:"move"}:{},transform:`translate(${t.x},${t.y}) rotate(${t.rotation})`,children:t.selected&&w.jsx("g",{"data-element-root":!0,"data-prototype":t.prototype,"data-id":t.id,"data-selected":t.selected,"data-layer":n.id,"data-part":"rotation-anchor",children:w.jsx("circle",{cx:Y_,cy:X_,r:J_,style:Z_,children:w.jsx("title",{children:"Group's Barycenter"})})})})}const Q_={fill:"#0096fd",stroke:"#0096fd",cursor:"ew-resize"},t1={fill:"none",stroke:"#0096fd",cursor:"ew-resize"};function e1({layer:n,item:t,scene:e,catalog:r}){let{x:i,y:s,rotation:o}=t,a=r.getElement(t.type).render2D(t,n,e);return w.jsxs("g",{"data-element-root":!0,"data-prototype":t.prototype,"data-id":t.id,"data-selected":t.selected,"data-layer":n.id,style:t.selected?{cursor:"move"}:{},transform:`translate(${i},${s}) rotate(${o})`,children:[a,t.selected&&w.jsxs("g",{"data-element-root":!0,"data-prototype":t.prototype,"data-id":t.id,"data-selected":t.selected,"data-layer":n.id,"data-part":"rotation-anchor",children:[w.jsx("circle",{cx:"0",cy:"150",r:"10",style:Q_}),w.jsx("circle",{cx:"0",cy:"0",r:"150",style:t1})]})]})}const oc={stroke:"#0096fd",strokeWidth:"1px"},r1={textAnchor:"middle",fontSize:"12px",fontFamily:"'Courier New', Courier, monospace",pointerEvents:"none",fontWeight:"bold",WebkitTouchCallout:"none",WebkitUserSelect:"none",MozUserSelect:"none",userSelect:"none"};function n1({length:n,unit:t,transform:e}){let r=`${n.toFixed(2)} ${t}`;return w.jsxs("g",{transform:e,children:[w.jsx("text",{x:n/2,y:"-3",transform:"scale(1, -1)",style:r1,children:r}),w.jsx("line",{x1:"0",y1:"-5",x2:"0",y2:"5",style:oc}),w.jsx("line",{x1:n,y1:"-5",x2:n,y2:"5",style:oc}),w.jsx("line",{x1:"0",y1:"0",x2:n,y2:"0",style:oc})]})}const i1=({line:n,layer:t,scene:e,catalog:r})=>{let i=t.vertices.get(n.vertices.get(0)),s=t.vertices.get(n.vertices.get(1));if(i.id===s.id||Mr(i,s))return null;let{x:o,y:a}=i,{x:l,y:c}=s;o>l&&({x:o,y:a}=s,{x:l,y:c}=i);let h=Oe(o,a,l,c),f=fv(o,a,l,c),g=n.holes.map(S=>{let A=t.holes.get(S),C=h*A.offset,O=r.getElement(A.type).render2D(A,t,e);return w.jsx("g",{transform:`translate(${C}, 0)`,"data-element-root":!0,"data-prototype":A.prototype,"data-id":A.id,"data-selected":A.selected,"data-layer":t.id,children:O},S)}),m=n.getIn(["properties","thickness","length"])/2,v=r.getElement(n.type).render2D(n,t),_=n.selected?w.jsx(n1,{unit:e.unit,length:h,transform:`translate(0, ${m+10} )`}):null;return w.jsxs("g",{transform:`translate(${o}, ${a}) rotate(${f}, 0, 0)`,"data-element-root":!0,"data-prototype":n.prototype,"data-id":n.id,"data-selected":n.selected,"data-layer":t.id,style:n.selected?{cursor:"move"}:{},children:[_,v,g]})},s1={fill:"#0096fd",stroke:jt.COLORS.white,cursor:"move"},o1=({vertex:n,layer:t})=>w.jsx("g",{transform:`translate(${n.x}, ${n.y})`,"data-element-root":!0,"data-prototype":n.prototype,"data-id":n.id,"data-selected":n.selected,"data-layer":t.id,children:w.jsx("circle",{cx:"0",cy:"0",r:"7",style:s1})});function Up({layer:n,scene:t,catalog:e}){const{groups:r}=t,{lines:i,areas:s,vertices:o,id:a,items:l,opacity:c}=n;return w.jsxs("g",{opacity:c,children:[s.valueSeq().map(h=>w.jsx(U_,{layer:n,area:h,catalog:e},h.id)),i.valueSeq().map(h=>w.jsx(i1,{layer:n,line:h,scene:t,catalog:e},h.id)),l.valueSeq().map(h=>w.jsx(e1,{layer:n,item:h,scene:t,catalog:e},h.id)),o.valueSeq().filter(h=>h.selected).map(h=>w.jsx(o1,{layer:n,vertex:h},h.id)),r.valueSeq().filter(h=>h.hasIn(["elements",a])&&h.get("selected")).map(h=>w.jsx(K_,{layer:n,group:h,scene:t,catalog:e},h.get("id")))]})}const a1=({scene:n,catalog:t})=>{const{layers:e}=n,r=e.get(n.selectedLayer);return w.jsxs("g",{children:[w.jsx(V_,{scene:n}),w.jsx("g",{style:{pointerEvents:"none"},children:e.entrySeq().filter(([i,s])=>i!==n.selectedLayer&&s.visible).map(([i,s])=>w.jsx(Up,{layer:s,scene:n,catalog:t},i))}),w.jsx(Up,{layer:r,scene:n,catalog:t},r.id)]})},u1=N.memo(a1,(n,t)=>n.scene.hashCode()===t.scene.hashCode()),Yp={stroke:jt.SECONDARY_COLOR.main,strokeWidth:"2.5px"},l1=({catalog:n})=>{const{planner:t}=Jt(),{activeSnapElement:e,snapElements:r,scene:i}=t,{width:s,height:o}=i;return w.jsxs("g",{children:[w.jsx("rect",{x:"0",y:"0",width:s,height:o,fill:jt.COLORS.white}),w.jsxs("g",{transform:`translate(0, ${i.height}) scale(1, -1)`,id:"svg-drawing-paper",children:[w.jsx(u1,{scene:i,catalog:n}),i.getIn(["guides","horizontal"]).entrySeq().map(([a,l])=>w.jsx("line",{id:"hGuide"+a,x1:0,y1:l,x2:s,y2:l,style:Yp},a)),i.getIn(["guides","vertical"]).entrySeq().map(([a,l])=>w.jsx("line",{x1:l,y1:0,x2:l,y2:o,style:Yp},a)),e?w.jsx(R_,{snap:e,width:i.width,height:i.height}):null,r?null:w.jsx(w.Fragment,{})]})]})},ac=.25,Xp=5,c1=.25,h1=5.25;function Jp(n){return(Math.min(Math.max(n,ac),Xp)-ac)/(Xp-ac)*100}function f1(n){switch(n){case Kn:return hr;case Jn:return Or;case Zn:return Zr;case re:return cr;default:return Jr}}function d1(n){switch(n){case We:case Ue:case ur:case Sr:case wr:case _r:case br:return{pointerEvents:"none"};default:return{}}}function p1(n){switch(n){case Sr:case _r:case br:case wr:return{cursor:"move"};case cn:return{cursor:"ew-resize"};case xr:case We:return{cursor:"crosshair"};default:return{cursor:"default"}}}function g1(n){switch(n){case We:case _r:case br:case Sr:case wr:case Ue:case ur:return!0;default:return!1}}function Zp(n){for(;!n.attributes.getNamedItem("data-element-root")&&n.tagName!=="svg";)n=n.parentNode;return n.tagName==="svg"?null:{part:n.attributes.getNamedItem("data-part")?n.attributes.getNamedItem("data-part").value:void 0,layer:n.attributes.getNamedItem("data-layer").value,prototype:n.attributes.getNamedItem("data-prototype").value,selected:n.attributes.getNamedItem("data-selected").value==="true",id:n.attributes.getNamedItem("data-id").value}}const m1=({width:n,height:t,catalog:e})=>{const r=N.useRef(null),{planner:i,selectToolZoomOut:s,selectToolZoomIn:o,selectToolPan:a,selectToolEdit:l,updateCameraView:c,updateZoomScale:h,updateMouseCoord:f,updateDrawingLine:g,updateDrawingHole:p,updateDrawingItem:m,updateDraggingHole:v,updateDraggingLine:_,updateDraggingVertex:S,updateDraggingItem:A,updateRotatingItem:C,beginDraggingLine:O,beginDraggingVertex:M,beginRotatingItem:z,beginDraggingItem:R,beginDraggingHole:I,selectArea:L,unselectAll:Y,beginDrawingLine:X,endDrawingLine:it,endDrawingHole:rt,endDrawingItem:vt,endDraggingLine:mt,endDraggingVertex:dt,endDraggingItem:ut,endDraggingHole:W,endRotatingItem:gt,selectLine:k,selectHole:j,selectItem:K,rollback:Z,setViewer:et}=Jt(),{viewer2D:U,scene:Q,mode:G}=i,tt=Q.selectedLayer??"";N.useEffect(()=>{r.current&&(et(r.current),r.current.fitToViewer())},[]);const ht=({x:Ot,y:$t})=>({x:Ot,y:-$t+Q.height}),B=Ot=>{const $t=new Event("mousemove-planner-event");$t.viewerEvent=Ot,document.dispatchEvent($t);let{x:ft,y:xt}=ht(Ot);switch(f({x:ft,y:xt}),G){case We:g(ft,xt,i.snapMask);break;case Ue:p(tt,ft,xt);break;case ur:m(tt,ft,xt);break;case Sr:v(ft,xt);break;case _r:_(ft,xt,i.snapMask);break;case br:S(ft,xt,i.snapMask);break;case wr:A(ft,xt);break;case cn:C(ft,xt);break}Ot.originalEvent.stopPropagation()},ct=Ot=>{const $t=Ot.originalEvent,ft=new Event("mousedown-planner-event");ft.viewerEvent=Ot,document.dispatchEvent(ft);let{x:xt,y:Nt}=ht(Ot);if(G===re){let wt=Zp($t.target);if(!wt||!wt.selected)return;switch(wt.prototype){case"lines":O(wt.layer,wt.id,xt,Nt,i.snapMask);break;case"vertices":M(wt.layer,wt.id,xt,Nt,i.snapMask);break;case"items":wt.part==="rotation-anchor"?z(wt.layer,wt.id,xt,Nt):R(wt.layer,wt.id,xt,Nt);break;case"holes":I(wt.layer,wt.id,xt,Nt);break}}$t.stopPropagation()},H=Ot=>{const $t=Ot.originalEvent,ft=new Event("mouseup-planner-event");ft.viewerEvent=Ot,document.dispatchEvent(ft);const{x:xt,y:Nt}=ht(Ot);switch(G){case re:const wt=Zp($t.target);if(wt&&wt.selected)return;switch(wt?wt.prototype:"none"){case"areas":L(wt.layer,wt.id);break;case"lines":k(wt.layer,wt.id);break;case"holes":j(wt.layer,wt.id);break;case"items":K(wt.layer,wt.id);break;case"none":Y();break}break;case xr:X(tt,xt,Nt,i.snapMask);break;case We:it(xt,Nt,i.snapMask),X(tt,xt,Nt,i.snapMask);break;case Ue:rt(tt,xt,Nt);break;case ur:vt(tt,xt,Nt);break;case _r:mt(xt,Nt,i.snapMask);break;case br:dt(xt,Nt,i.snapMask);break;case wr:ut(xt,Nt);break;case Sr:W(xt,Nt);break;case cn:gt(xt,Nt);break}$t.stopPropagation()},_t=()=>{[xr,We,Ue,ur].includes(G)&&Z()},Ft=Ot=>{h(Ot.a),c(Ot)},Pt=Ot=>{switch(Ot){case Jr:l();break;case hr:a();break;case Or:o();break;case Zr:s();break}};return w.jsx("div",{className:"m-0 p-0 relative",children:w.jsx(ba,{className:"floor_planner-svgPanZoom",ref:r,style:{gridColumn:2,gridRow:2},width:n,height:t,scaleFactorMin:c1,scaleFactorMax:h1,value:U.isEmpty()?{}:U.toJS(),onChangeValue:Ft,tool:f1(G),onChangeTool:Pt,detectAutoPan:g1(G),onMouseDown:ct,onMouseMove:B,onMouseUp:H,onDoubleClick:_t,miniatureProps:{position:"none",width:0,height:0,background:""},toolbarProps:{position:"none"},children:w.jsxs("svg",{width:Q.width,height:Q.height,children:[w.jsx("defs",{children:w.jsxs("pattern",{id:"diagonalFill",patternUnits:"userSpaceOnUse",width:"4",height:"4",fill:"#FFF",children:[w.jsx("rect",{x:"0",y:"0",width:"4",height:"4",fill:"#FFF"}),w.jsx("path",{d:"M-1,1 l2,-2 M0,4 l4,-4 M3,5 l2,-2",style:{stroke:"#8E9BA2",strokeWidth:1}})]})}),w.jsx("g",{style:Object.assign(p1(G),d1(G)),children:w.jsx(l1,{catalog:e})})]})})})},y1={color:jt.PRIMARY_COLOR.alt,fontWeight:300};function v1({children:n,style:t={},...e}){return w.jsx("h1",{style:{...y1,...t},...e,children:n})}const x1={padding:"0 20px",overflowY:"auto"};function _1({children:n,width:t,height:e,style:r={}}){return w.jsx("div",{style:{width:t,height:e,...x1,...r},onWheel:i=>i.stopPropagation(),children:n})}var Kp={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Qp=N.createContext&&N.createContext(Kp),b1=["attr","size","title"];function w1(n,t){if(n==null)return{};var e=S1(n,t),r,i;if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(n);for(i=0;i<s.length;i++)r=s[i],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(n,r)&&(e[r]=n[r])}return e}function S1(n,t){if(n==null)return{};var e={};for(var r in n)if(Object.prototype.hasOwnProperty.call(n,r)){if(t.indexOf(r)>=0)continue;e[r]=n[r]}return e}function Sa(){return Sa=Object.assign?Object.assign.bind():function(n){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r])}return n},Sa.apply(this,arguments)}function tg(n,t){var e=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),e.push.apply(e,r)}return e}function Ma(n){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?tg(Object(e),!0).forEach(function(r){M1(n,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(e)):tg(Object(e)).forEach(function(r){Object.defineProperty(n,r,Object.getOwnPropertyDescriptor(e,r))})}return n}function M1(n,t,e){return t=E1(t),t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}function E1(n){var t=A1(n,"string");return typeof t=="symbol"?t:t+""}function A1(n,t){if(typeof n!="object"||!n)return n;var e=n[Symbol.toPrimitive];if(e!==void 0){var r=e.call(n,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(n)}function eg(n){return n&&n.map((t,e)=>N.createElement(t.tag,Ma({key:e},t.attr),eg(t.child)))}function se(n){return t=>N.createElement(O1,Sa({attr:Ma({},n.attr)},t),eg(n.child))}function O1(n){var t=e=>{var{attr:r,size:i,title:s}=n,o=w1(n,b1),a=i||e.size||"1em",l;return e.className&&(l=e.className),n.className&&(l=(l?l+" ":"")+n.className),N.createElement("svg",Sa({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},e.attr,r,o,{className:l,style:Ma(Ma({color:n.color||e.color},e.style),n.style),height:a,width:a,xmlns:"http://www.w3.org/2000/svg"}),s&&N.createElement("title",null,s),n.children)};return Qp!==void 0?N.createElement(Qp.Consumer,null,e=>t(e)):t(Kp)}function z1(n){return se({attr:{viewBox:"0 0 320 512"},child:[{tag:"path",attr:{d:"M31.3 192h257.3c17.8 0 26.7 21.5 14.1 34.1L174.1 354.8c-7.8 7.8-20.5 7.8-28.3 0L17.2 226.1C4.6 213.5 13.5 192 31.3 192z"},child:[]}]})(n)}function T1(n){return se({attr:{viewBox:"0 0 192 512"},child:[{tag:"path",attr:{d:"M0 384.662V127.338c0-17.818 21.543-26.741 34.142-14.142l128.662 128.662c7.81 7.81 7.81 20.474 0 28.284L34.142 398.804C21.543 411.404 0 402.48 0 384.662z"},child:[]}]})(n)}function C1(n){return se({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm144 276c0 6.6-5.4 12-12 12h-92v92c0 6.6-5.4 12-12 12h-56c-6.6 0-12-5.4-12-12v-92h-92c-6.6 0-12-5.4-12-12v-56c0-6.6 5.4-12 12-12h92v-92c0-6.6 5.4-12 12-12h56c6.6 0 12 5.4 12 12v92h92c6.6 0 12 5.4 12 12v56z"},child:[]}]})(n)}function k1(n){return se({attr:{viewBox:"0 0 320 512"},child:[{tag:"path",attr:{d:"M41 288h238c21.4 0 32.1 25.9 17 41L177 448c-9.4 9.4-24.6 9.4-33.9 0L24 329c-15.1-15.1-4.4-41 17-41z"},child:[]}]})(n)}function I1(n){return se({attr:{viewBox:"0 0 352 512"},child:[{tag:"path",attr:{d:"M242.72 256l100.07-100.07c12.28-12.28 12.28-32.19 0-44.48l-22.24-22.24c-12.28-12.28-32.19-12.28-44.48 0L176 189.28 75.93 89.21c-12.28-12.28-32.19-12.28-44.48 0L9.21 111.45c-12.28 12.28-12.28 32.19 0 44.48L109.28 256 9.21 356.07c-12.28 12.28-12.28 32.19 0 44.48l22.24 22.24c12.28 12.28 32.2 12.28 44.48 0L176 322.72l100.07 100.07c12.28 12.28 32.2 12.28 44.48 0l22.24-22.24c12.28-12.28 12.28-32.19 0-44.48L242.72 256z"},child:[]}]})(n)}function P1(n){return se({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M304.083 405.907c4.686 4.686 4.686 12.284 0 16.971l-44.674 44.674c-59.263 59.262-155.693 59.266-214.961 0-59.264-59.265-59.264-155.696 0-214.96l44.675-44.675c4.686-4.686 12.284-4.686 16.971 0l39.598 39.598c4.686 4.686 4.686 12.284 0 16.971l-44.675 44.674c-28.072 28.073-28.072 73.75 0 101.823 28.072 28.072 73.75 28.073 101.824 0l44.674-44.674c4.686-4.686 12.284-4.686 16.971 0l39.597 39.598zm-56.568-260.216c4.686 4.686 12.284 4.686 16.971 0l44.674-44.674c28.072-28.075 73.75-28.073 101.824 0 28.072 28.073 28.072 73.75 0 101.823l-44.675 44.674c-4.686 4.686-4.686 12.284 0 16.971l39.598 39.598c4.686 4.686 12.284 4.686 16.971 0l44.675-44.675c59.265-59.265 59.265-155.695 0-214.96-59.266-59.264-155.695-59.264-214.961 0l-44.674 44.674c-4.686 4.686-4.686 12.284 0 16.971l39.597 39.598zm234.828 359.28l22.627-22.627c9.373-9.373 9.373-24.569 0-33.941L63.598 7.029c-9.373-9.373-24.569-9.373-33.941 0L7.029 29.657c-9.373 9.373-9.373 24.569 0 33.941l441.373 441.373c9.373 9.372 24.569 9.372 33.941 0z"},child:[]}]})(n)}const rg={width:"14em",height:"14em",padding:"0.625em",background:"#f7f7f9",border:"1px solid #e1e1e8",cursor:"pointer",position:"relative",boxShadow:"0 1px 6px 0 rgba(0, 0, 0, 0.11), 0 1px 4px 0 rgba(0, 0, 0, 0.11)",borderRadius:"2px",transition:"all .15s ease-in-out",WebkitTransition:"all .15s ease-in-out",alignSelf:"center",justifySelf:"center"},R1={...rg,background:jt.SECONDARY_COLOR.main},ng={width:"100%",textAlign:"center",display:"block",marginBottom:".5em",textTransform:"capitalize"},L1={...ng,color:jt.COLORS.white},N1={width:"100%",height:"8em",position:"relative",overflow:"hidden",border:"solid 1px #e6e6e6",padding:0,margin:0,marginBottom:"5px"},ig={position:"absolute",background:"#222",width:"100%",height:"100%",backgroundSize:"contain",backgroundPosition:"50% 50%",backgroundColor:jt.COLORS.white,backgroundRepeat:"no-repeat",transition:"all .2s ease-in-out"},F1={...ig,transform:"scale(1.2)"},j1={marginTop:"1.5em",color:jt.SECONDARY_COLOR.main,fontSize:"2em",opacity:"0.7",width:"100%"},V1={display:"block",height:"2em",margin:"0 auto",fontSize:"0.75em",fontStyle:"italic",lineHeight:"1em",WebkitLineClamp:"2",WebkitBoxOrient:"vertical",overflow:"hidden",textOverflow:"ellipsis"},D1={listStyle:"none",margin:"0px",padding:"0px",fontSize:"11px",marginBottom:"3px"},B1={display:"inline-block",background:"#337ab7",color:jt.COLORS.white,padding:"1px 4px",marginRight:"3px",borderRadius:"3px"},sg=({element:n})=>{const[t,e]=N.useState(!1),{selectToolDrawingLine:r,selectToolDrawingItem:i,selectToolDrawingHole:s,pushLastSelectedCatalogElementToHistory:o}=Jt(),a=()=>{switch(n.prototype){case"lines":r(n.name);break;case"items":i(n.name);break;case"holes":s(n.name);break}o(n)};return w.jsxs("div",{style:t?R1:rg,onClick:a,onMouseEnter:()=>e(!0),onMouseLeave:()=>e(!1),children:[w.jsx("b",{style:t?L1:ng,children:n.info.title}),w.jsx("div",{style:N1,children:w.jsx("div",{style:{...t?F1:ig,backgroundImage:"url("+n.info.image+")"},children:t?w.jsx(C1,{style:j1}):null})}),w.jsx("ul",{style:D1,children:n.info.tag.map((l,c)=>w.jsx("li",{style:B1,children:l},c))}),w.jsx("div",{style:V1,children:n.info.description})]})};function q1(n){return se({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M21 10.12h-6.78l2.74-2.82c-2.73-2.7-7.15-2.8-9.88-.1-2.73 2.71-2.73 7.08 0 9.79s7.15 2.71 9.88 0C18.32 15.65 19 14.08 19 12.1h2c0 1.98-.88 4.55-2.64 6.29-3.51 3.48-9.21 3.48-12.72 0-3.5-3.47-3.53-9.11-.02-12.58s9.14-3.47 12.65 0L21 3v7.12zM12.5 8v4.25l3.5 2.08-.72 1.21L11 13V8h1.5z"},child:[]}]})(n)}function $1(n){return se({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M1 21h22L12 2 1 21zm12-3h-2v-2h2v2zm0-4h-2v-4h2v4z"},child:[]}]})(n)}function H1(n){return se({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm5 11h-4v4h-2v-4H7v-2h4V7h2v4h4v2z"},child:[]}]})(n)}function G1(n){return se({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M18.4 10.6C16.55 8.99 14.15 8 11.5 8c-4.65 0-8.58 3.03-9.96 7.22L3.9 16a8.002 8.002 0 0 1 7.6-5.5c1.95 0 3.73.72 5.12 1.88L13 16h9V7l-3.6 3.6z"},child:[]}]})(n)}function W1(n){return se({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M12.5 8c-2.65 0-5.05.99-6.9 2.6L2 7v9h9l-3.62-3.62c1.39-1.16 3.16-1.88 5.12-1.88 3.54 0 6.55 2.31 7.6 5.5l2.37-.78C21.08 11.03 17.15 8 12.5 8z"},child:[]}]})(n)}function U1(n){return se({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M15.41 7.41 14 6l-6 6 6 6 1.41-1.41L10.83 12z"},child:[]}]})(n)}function og(n){return se({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z"},child:[]}]})(n)}function Y1(n){return se({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 8h-6V5h6v6zm-8-6v6H5V5h6zm-6 8h6v6H5v-6zm8 6v-6h6v6h-6z"},child:[]}]})(n)}const X1={margin:"1.5em",display:"flex"},ag={fontSize:"20px",cursor:"pointer"},J1={...ag,fontWeight:"bolder",color:jt.SECONDARY_COLOR.main},Z1={fill:jt.COLORS.black,fontSize:"24px",marginLeft:"10px",marginRight:"10px"},K1=({names:n})=>{let t=n.map((e,r)=>{let i=r===n.length-1;return w.jsxs("div",{style:{display:"flex"},children:[w.jsx("div",{style:i?J1:ag,onClick:e.action||null,children:e.name}),i?null:w.jsx(og,{style:Z1})]},r)});return w.jsx("div",{style:X1,children:t})},ug={width:"14em",height:"14em",padding:"0.625em",background:"#f7f7f9",border:"1px solid #e1e1e8",margin:"0.3em",cursor:"pointer",position:"relative",boxShadow:"0 1px 6px 0 rgba(0, 0, 0, 0.11), 0 1px 4px 0 rgba(0, 0, 0, 0.11)",borderRadius:"2px",transition:"all .2s ease-in-out",WebkitTransition:"all .2s ease-in-out"},Q1={...ug,background:jt.SECONDARY_COLOR.main},lg={position:"absolute",color:jt.COLORS.black,fontSize:"5em",width:"100%"},tb={...lg,color:jt.SECONDARY_COLOR.main},eb={background:jt.COLORS.white,marginBottom:"5px",border:"solid 1px #e6e6e6",width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},rb=({page:n})=>{const[t,e]=N.useState(!1),{goBackToCatalogPage:r}=Jt(),i=s=>{r(s)};return w.jsx("div",{style:t?Q1:ug,onClick:()=>i(n.name),onMouseEnter:()=>e(!0),onMouseLeave:()=>e(!1),children:w.jsx("div",{style:eb,children:w.jsx(U1,{style:t?tb:lg})})})},nb={position:"fixed",width:"calc( 100% - 51px)",height:"calc( 100% - 20px)",backgroundColor:"#FFF",padding:"1em",left:50,overflowY:"auto",overflowX:"hidden",zIndex:10},ib={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(14em, 1fr))",gridGap:"10px",marginTop:"1em"},cg={width:"100%",height:"3em",padding:"0.625em",background:"#f7f7f9",border:"1px solid #e1e1e8",cursor:"pointer",position:"relative",boxShadow:"0 1px 6px 0 rgba(0, 0, 0, 0.11), 0 1px 4px 0 rgba(0, 0, 0, 0.11)",borderRadius:"2px",transition:"all .2s ease-in-out",WebkitTransition:"all .2s ease-in-out",marginBottom:"1em"},sb={width:"8em",display:"inline-block"},ob={width:"calc( 100% - 10em )",height:"2em",margin:"0",padding:"0 1em",border:"1px solid #EEE"},ab={...cg,padding:"0.2em 0.625em"},ub={width:"auto",height:"2em",lineHeight:"2em",textAlign:"center",borderRadius:"1em",display:"inline-block",cursor:"pointer",backgroundColor:jt.PRIMARY_COLOR.alt,color:jt.PRIMARY_COLOR.text_main,textTransform:"capitalize",margin:"0.25em",padding:"0 1em"},lb=({width:n,height:t,style:e,catalog:r})=>{const{planner:i,goBackToCatalogPage:s,selectToolDrawingHole:o,selectToolDrawingItem:a,selectToolDrawingLine:l,pushLastSelectedCatalogElementToHistory:c}=Jt();let h=i.catalog.page;const f=r.getCategory(h);let g=f.elements.filter(L=>L.info.visibility?L.info.visibility.catalog:!0);const[p,m]=N.useState(""),[v,_]=N.useState([]);let S=null;if(h!=="root"){let L=[];i.catalog.path.forEach(Y=>{L.push({name:r.getCategory(Y).label,action:()=>s(Y)})}),L.push({name:f.label,action:""}),S=w.jsx(K1,{names:L})}let A=i.catalog.path.size,C=A>0?w.jsx(rb,{page:r.categories[i.catalog.path.get(A-1)]},A):null,O=i.get("selectedElementsHistory"),M=O.map((L,Y)=>w.jsx("div",{style:ub,title:L.name,onClick:()=>I(L),children:L.name},Y));const z=L=>{let Y=[];for(let X=0;X<L.length;X++){let it=L[X];Y=Y.concat(it.elements),it.categories.length&&(Y=Y.concat(z(it.categories)))}return Y},R=L=>{let Y=g.concat(z(f.categories)),X=[];if(L!=""){let it=new RegExp(L,"i");for(let rt=0;rt<Y.length;rt++)it.test(Y[rt].info.title)&&X.push(Y[rt])}m(L),_(X)},I=L=>{switch(L.prototype){case"lines":l(L.name);break;case"items":a(L.name);break;case"holes":o(L.name);break}c(L)};return w.jsxs(_1,{width:n,height:t,style:{...nb,...e},children:[w.jsx(v1,{children:"Catalog"}),S,w.jsxs("div",{style:cg,children:[w.jsx("span",{style:sb,children:"Search Element"}),w.jsx("input",{type:"text",style:ob,onChange:L=>{R(L.target.value)}})]}),O.size?w.jsxs("div",{style:ab,children:[w.jsx("span",{children:"Last Selected"}),M]}):null,w.jsx("div",{style:ib,children:p===""?[C,g.map(L=>w.jsx(sg,{element:L},L.name))]:v.map(L=>w.jsx(sg,{element:L},L.name))})]})},cb={MODE_IDLE:re,MODE_2D_ZOOM_IN:Jn,MODE_2D_ZOOM_OUT:Zn,MODE_2D_PAN:Kn,MODE_WAITING_DRAWING_LINE:xr,MODE_DRAGGING_LINE:_r,MODE_DRAGGING_VERTEX:br,MODE_DRAGGING_ITEM:wr,MODE_DRAWING_LINE:We,MODE_DRAWING_HOLE:Ue,MODE_DRAWING_ITEM:ur,MODE_DRAGGING_HOLE:Sr,MODE_ROTATING_ITEM:cn};function hb({width:n,height:t,catalog:e}){const{planner:r}=Jt(),{mode:i}=r;return i===Qn?w.jsx(w.Fragment,{}):i===ki?w.jsx(w.Fragment,{}):i===cl?w.jsx(lb,{width:n,height:t,catalog:e}):cb[i]?w.jsx(m1,{width:n,height:t,catalog:e}):i===id?w.jsx(w.Fragment,{}):null}function hg(n){var t,e,r="";if(typeof n=="string"||typeof n=="number")r+=n;else if(typeof n=="object")if(Array.isArray(n)){var i=n.length;for(t=0;t<i;t++)n[t]&&(e=hg(n[t]))&&(r&&(r+=" "),r+=e)}else for(e in n)n[e]&&(r&&(r+=" "),r+=e);return r}function fb(){for(var n,t,e=0,r="",i=arguments.length;e<i;e++)(n=arguments[e])&&(t=hg(n))&&(r&&(r+=" "),r+=t);return r}const uc="-",db=n=>{const t=gb(n),{conflictingClassGroups:e,conflictingClassGroupModifiers:r}=n;return{getClassGroupId:o=>{const a=o.split(uc);return a[0]===""&&a.length!==1&&a.shift(),fg(a,t)||pb(o)},getConflictingClassGroupIds:(o,a)=>{const l=e[o]||[];return a&&r[o]?[...l,...r[o]]:l}}},fg=(n,t)=>{var o;if(n.length===0)return t.classGroupId;const e=n[0],r=t.nextPart.get(e),i=r?fg(n.slice(1),r):void 0;if(i)return i;if(t.validators.length===0)return;const s=n.join(uc);return(o=t.validators.find(({validator:a})=>a(s)))==null?void 0:o.classGroupId},dg=/^\[(.+)\]$/,pb=n=>{if(dg.test(n)){const t=dg.exec(n)[1],e=t==null?void 0:t.substring(0,t.indexOf(":"));if(e)return"arbitrary.."+e}},gb=n=>{const{theme:t,classGroups:e}=n,r={nextPart:new Map,validators:[]};for(const i in e)lc(e[i],r,i,t);return r},lc=(n,t,e,r)=>{n.forEach(i=>{if(typeof i=="string"){const s=i===""?t:pg(t,i);s.classGroupId=e;return}if(typeof i=="function"){if(mb(i)){lc(i(r),t,e,r);return}t.validators.push({validator:i,classGroupId:e});return}Object.entries(i).forEach(([s,o])=>{lc(o,pg(t,s),e,r)})})},pg=(n,t)=>{let e=n;return t.split(uc).forEach(r=>{e.nextPart.has(r)||e.nextPart.set(r,{nextPart:new Map,validators:[]}),e=e.nextPart.get(r)}),e},mb=n=>n.isThemeGetter,yb=n=>{if(n<1)return{get:()=>{},set:()=>{}};let t=0,e=new Map,r=new Map;const i=(s,o)=>{e.set(s,o),t++,t>n&&(t=0,r=e,e=new Map)};return{get(s){let o=e.get(s);if(o!==void 0)return o;if((o=r.get(s))!==void 0)return i(s,o),o},set(s,o){e.has(s)?e.set(s,o):i(s,o)}}},cc="!",hc=":",vb=hc.length,xb=n=>{const{prefix:t,experimentalParseClassName:e}=n;let r=i=>{const s=[];let o=0,a=0,l=0,c;for(let m=0;m<i.length;m++){let v=i[m];if(o===0&&a===0){if(v===hc){s.push(i.slice(l,m)),l=m+vb;continue}if(v==="/"){c=m;continue}}v==="["?o++:v==="]"?o--:v==="("?a++:v===")"&&a--}const h=s.length===0?i:i.substring(l),f=_b(h),g=f!==h,p=c&&c>l?c-l:void 0;return{modifiers:s,hasImportantModifier:g,baseClassName:f,maybePostfixModifierPosition:p}};if(t){const i=t+hc,s=r;r=o=>o.startsWith(i)?s(o.substring(i.length)):{isExternal:!0,modifiers:[],hasImportantModifier:!1,baseClassName:o,maybePostfixModifierPosition:void 0}}if(e){const i=r;r=s=>e({className:s,parseClassName:i})}return r},_b=n=>n.endsWith(cc)?n.substring(0,n.length-1):n.startsWith(cc)?n.substring(1):n,bb=n=>{const t=Object.fromEntries(n.orderSensitiveModifiers.map(r=>[r,!0]));return r=>{if(r.length<=1)return r;const i=[];let s=[];return r.forEach(o=>{o[0]==="["||t[o]?(i.push(...s.sort(),o),s=[]):s.push(o)}),i.push(...s.sort()),i}},wb=n=>({cache:yb(n.cacheSize),parseClassName:xb(n),sortModifiers:bb(n),...db(n)}),Sb=/\s+/,Mb=(n,t)=>{const{parseClassName:e,getClassGroupId:r,getConflictingClassGroupIds:i,sortModifiers:s}=t,o=[],a=n.trim().split(Sb);let l="";for(let c=a.length-1;c>=0;c-=1){const h=a[c],{isExternal:f,modifiers:g,hasImportantModifier:p,baseClassName:m,maybePostfixModifierPosition:v}=e(h);if(f){l=h+(l.length>0?" "+l:l);continue}let _=!!v,S=r(_?m.substring(0,v):m);if(!S){if(!_){l=h+(l.length>0?" "+l:l);continue}if(S=r(m),!S){l=h+(l.length>0?" "+l:l);continue}_=!1}const A=s(g).join(":"),C=p?A+cc:A,O=C+S;if(o.includes(O))continue;o.push(O);const M=i(S,_);for(let z=0;z<M.length;++z){const R=M[z];o.push(C+R)}l=h+(l.length>0?" "+l:l)}return l};function Eb(){let n=0,t,e,r="";for(;n<arguments.length;)(t=arguments[n++])&&(e=gg(t))&&(r&&(r+=" "),r+=e);return r}const gg=n=>{if(typeof n=="string")return n;let t,e="";for(let r=0;r<n.length;r++)n[r]&&(t=gg(n[r]))&&(e&&(e+=" "),e+=t);return e};function Ab(n,...t){let e,r,i,s=o;function o(l){const c=t.reduce((h,f)=>f(h),n());return e=wb(c),r=e.cache.get,i=e.cache.set,s=a,a(l)}function a(l){const c=r(l);if(c)return c;const h=Mb(l,e);return i(l,h),h}return function(){return s(Eb.apply(null,arguments))}}const ge=n=>{const t=e=>e[n]||[];return t.isThemeGetter=!0,t},mg=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,yg=/^\((?:(\w[\w-]*):)?(.+)\)$/i,Ob=/^\d+\/\d+$/,zb=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Tb=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,Cb=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,kb=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Ib=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Bi=n=>Ob.test(n),St=n=>!!n&&!Number.isNaN(Number(n)),Pn=n=>!!n&&Number.isInteger(Number(n)),fc=n=>n.endsWith("%")&&St(n.slice(0,-1)),dn=n=>zb.test(n),Pb=()=>!0,Rb=n=>Tb.test(n)&&!Cb.test(n),vg=()=>!1,Lb=n=>kb.test(n),Nb=n=>Ib.test(n),Fb=n=>!ot(n)&&!at(n),jb=n=>qi(n,Sg,vg),ot=n=>mg.test(n),ni=n=>qi(n,Mg,Rb),dc=n=>qi(n,$b,St),xg=n=>qi(n,bg,vg),Vb=n=>qi(n,wg,Nb),Ea=n=>qi(n,Eg,Lb),at=n=>yg.test(n),Qs=n=>$i(n,Mg),Db=n=>$i(n,Hb),_g=n=>$i(n,bg),Bb=n=>$i(n,Sg),qb=n=>$i(n,wg),Aa=n=>$i(n,Eg,!0),qi=(n,t,e)=>{const r=mg.exec(n);return r?r[1]?t(r[1]):e(r[2]):!1},$i=(n,t,e=!1)=>{const r=yg.exec(n);return r?r[1]?t(r[1]):e:!1},bg=n=>n==="position"||n==="percentage",wg=n=>n==="image"||n==="url",Sg=n=>n==="length"||n==="size"||n==="bg-size",Mg=n=>n==="length",$b=n=>n==="number",Hb=n=>n==="family-name",Eg=n=>n==="shadow",Gb=Ab(()=>{const n=ge("color"),t=ge("font"),e=ge("text"),r=ge("font-weight"),i=ge("tracking"),s=ge("leading"),o=ge("breakpoint"),a=ge("container"),l=ge("spacing"),c=ge("radius"),h=ge("shadow"),f=ge("inset-shadow"),g=ge("text-shadow"),p=ge("drop-shadow"),m=ge("blur"),v=ge("perspective"),_=ge("aspect"),S=ge("ease"),A=ge("animate"),C=()=>["auto","avoid","all","avoid-page","page","left","right","column"],O=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],M=()=>[...O(),at,ot],z=()=>["auto","hidden","clip","visible","scroll"],R=()=>["auto","contain","none"],I=()=>[at,ot,l],L=()=>[Bi,"full","auto",...I()],Y=()=>[Pn,"none","subgrid",at,ot],X=()=>["auto",{span:["full",Pn,at,ot]},Pn,at,ot],it=()=>[Pn,"auto",at,ot],rt=()=>["auto","min","max","fr",at,ot],vt=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],mt=()=>["start","end","center","stretch","center-safe","end-safe"],dt=()=>["auto",...I()],ut=()=>[Bi,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...I()],W=()=>[n,at,ot],gt=()=>[...O(),_g,xg,{position:[at,ot]}],k=()=>["no-repeat",{repeat:["","x","y","space","round"]}],j=()=>["auto","cover","contain",Bb,jb,{size:[at,ot]}],K=()=>[fc,Qs,ni],Z=()=>["","none","full",c,at,ot],et=()=>["",St,Qs,ni],U=()=>["solid","dashed","dotted","double"],Q=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],G=()=>[St,fc,_g,xg],tt=()=>["","none",m,at,ot],ht=()=>["none",St,at,ot],B=()=>["none",St,at,ot],ct=()=>[St,at,ot],H=()=>[Bi,"full",...I()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[dn],breakpoint:[dn],color:[Pb],container:[dn],"drop-shadow":[dn],ease:["in","out","in-out"],font:[Fb],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[dn],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[dn],shadow:[dn],spacing:["px",St],text:[dn],"text-shadow":[dn],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Bi,ot,at,_]}],container:["container"],columns:[{columns:[St,ot,at,a]}],"break-after":[{"break-after":C()}],"break-before":[{"break-before":C()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:M()}],overflow:[{overflow:z()}],"overflow-x":[{"overflow-x":z()}],"overflow-y":[{"overflow-y":z()}],overscroll:[{overscroll:R()}],"overscroll-x":[{"overscroll-x":R()}],"overscroll-y":[{"overscroll-y":R()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:L()}],"inset-x":[{"inset-x":L()}],"inset-y":[{"inset-y":L()}],start:[{start:L()}],end:[{end:L()}],top:[{top:L()}],right:[{right:L()}],bottom:[{bottom:L()}],left:[{left:L()}],visibility:["visible","invisible","collapse"],z:[{z:[Pn,"auto",at,ot]}],basis:[{basis:[Bi,"full","auto",a,...I()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[St,Bi,"auto","initial","none",ot]}],grow:[{grow:["",St,at,ot]}],shrink:[{shrink:["",St,at,ot]}],order:[{order:[Pn,"first","last","none",at,ot]}],"grid-cols":[{"grid-cols":Y()}],"col-start-end":[{col:X()}],"col-start":[{"col-start":it()}],"col-end":[{"col-end":it()}],"grid-rows":[{"grid-rows":Y()}],"row-start-end":[{row:X()}],"row-start":[{"row-start":it()}],"row-end":[{"row-end":it()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":rt()}],"auto-rows":[{"auto-rows":rt()}],gap:[{gap:I()}],"gap-x":[{"gap-x":I()}],"gap-y":[{"gap-y":I()}],"justify-content":[{justify:[...vt(),"normal"]}],"justify-items":[{"justify-items":[...mt(),"normal"]}],"justify-self":[{"justify-self":["auto",...mt()]}],"align-content":[{content:["normal",...vt()]}],"align-items":[{items:[...mt(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...mt(),{baseline:["","last"]}]}],"place-content":[{"place-content":vt()}],"place-items":[{"place-items":[...mt(),"baseline"]}],"place-self":[{"place-self":["auto",...mt()]}],p:[{p:I()}],px:[{px:I()}],py:[{py:I()}],ps:[{ps:I()}],pe:[{pe:I()}],pt:[{pt:I()}],pr:[{pr:I()}],pb:[{pb:I()}],pl:[{pl:I()}],m:[{m:dt()}],mx:[{mx:dt()}],my:[{my:dt()}],ms:[{ms:dt()}],me:[{me:dt()}],mt:[{mt:dt()}],mr:[{mr:dt()}],mb:[{mb:dt()}],ml:[{ml:dt()}],"space-x":[{"space-x":I()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":I()}],"space-y-reverse":["space-y-reverse"],size:[{size:ut()}],w:[{w:[a,"screen",...ut()]}],"min-w":[{"min-w":[a,"screen","none",...ut()]}],"max-w":[{"max-w":[a,"screen","none","prose",{screen:[o]},...ut()]}],h:[{h:["screen","lh",...ut()]}],"min-h":[{"min-h":["screen","lh","none",...ut()]}],"max-h":[{"max-h":["screen","lh",...ut()]}],"font-size":[{text:["base",e,Qs,ni]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,at,dc]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",fc,ot]}],"font-family":[{font:[Db,ot,t]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[i,at,ot]}],"line-clamp":[{"line-clamp":[St,"none",at,dc]}],leading:[{leading:[s,...I()]}],"list-image":[{"list-image":["none",at,ot]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",at,ot]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:W()}],"text-color":[{text:W()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...U(),"wavy"]}],"text-decoration-thickness":[{decoration:[St,"from-font","auto",at,ni]}],"text-decoration-color":[{decoration:W()}],"underline-offset":[{"underline-offset":[St,"auto",at,ot]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:I()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",at,ot]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",at,ot]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:gt()}],"bg-repeat":[{bg:k()}],"bg-size":[{bg:j()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Pn,at,ot],radial:["",at,ot],conic:[Pn,at,ot]},qb,Vb]}],"bg-color":[{bg:W()}],"gradient-from-pos":[{from:K()}],"gradient-via-pos":[{via:K()}],"gradient-to-pos":[{to:K()}],"gradient-from":[{from:W()}],"gradient-via":[{via:W()}],"gradient-to":[{to:W()}],rounded:[{rounded:Z()}],"rounded-s":[{"rounded-s":Z()}],"rounded-e":[{"rounded-e":Z()}],"rounded-t":[{"rounded-t":Z()}],"rounded-r":[{"rounded-r":Z()}],"rounded-b":[{"rounded-b":Z()}],"rounded-l":[{"rounded-l":Z()}],"rounded-ss":[{"rounded-ss":Z()}],"rounded-se":[{"rounded-se":Z()}],"rounded-ee":[{"rounded-ee":Z()}],"rounded-es":[{"rounded-es":Z()}],"rounded-tl":[{"rounded-tl":Z()}],"rounded-tr":[{"rounded-tr":Z()}],"rounded-br":[{"rounded-br":Z()}],"rounded-bl":[{"rounded-bl":Z()}],"border-w":[{border:et()}],"border-w-x":[{"border-x":et()}],"border-w-y":[{"border-y":et()}],"border-w-s":[{"border-s":et()}],"border-w-e":[{"border-e":et()}],"border-w-t":[{"border-t":et()}],"border-w-r":[{"border-r":et()}],"border-w-b":[{"border-b":et()}],"border-w-l":[{"border-l":et()}],"divide-x":[{"divide-x":et()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":et()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...U(),"hidden","none"]}],"divide-style":[{divide:[...U(),"hidden","none"]}],"border-color":[{border:W()}],"border-color-x":[{"border-x":W()}],"border-color-y":[{"border-y":W()}],"border-color-s":[{"border-s":W()}],"border-color-e":[{"border-e":W()}],"border-color-t":[{"border-t":W()}],"border-color-r":[{"border-r":W()}],"border-color-b":[{"border-b":W()}],"border-color-l":[{"border-l":W()}],"divide-color":[{divide:W()}],"outline-style":[{outline:[...U(),"none","hidden"]}],"outline-offset":[{"outline-offset":[St,at,ot]}],"outline-w":[{outline:["",St,Qs,ni]}],"outline-color":[{outline:W()}],shadow:[{shadow:["","none",h,Aa,Ea]}],"shadow-color":[{shadow:W()}],"inset-shadow":[{"inset-shadow":["none",f,Aa,Ea]}],"inset-shadow-color":[{"inset-shadow":W()}],"ring-w":[{ring:et()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:W()}],"ring-offset-w":[{"ring-offset":[St,ni]}],"ring-offset-color":[{"ring-offset":W()}],"inset-ring-w":[{"inset-ring":et()}],"inset-ring-color":[{"inset-ring":W()}],"text-shadow":[{"text-shadow":["none",g,Aa,Ea]}],"text-shadow-color":[{"text-shadow":W()}],opacity:[{opacity:[St,at,ot]}],"mix-blend":[{"mix-blend":[...Q(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":Q()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[St]}],"mask-image-linear-from-pos":[{"mask-linear-from":G()}],"mask-image-linear-to-pos":[{"mask-linear-to":G()}],"mask-image-linear-from-color":[{"mask-linear-from":W()}],"mask-image-linear-to-color":[{"mask-linear-to":W()}],"mask-image-t-from-pos":[{"mask-t-from":G()}],"mask-image-t-to-pos":[{"mask-t-to":G()}],"mask-image-t-from-color":[{"mask-t-from":W()}],"mask-image-t-to-color":[{"mask-t-to":W()}],"mask-image-r-from-pos":[{"mask-r-from":G()}],"mask-image-r-to-pos":[{"mask-r-to":G()}],"mask-image-r-from-color":[{"mask-r-from":W()}],"mask-image-r-to-color":[{"mask-r-to":W()}],"mask-image-b-from-pos":[{"mask-b-from":G()}],"mask-image-b-to-pos":[{"mask-b-to":G()}],"mask-image-b-from-color":[{"mask-b-from":W()}],"mask-image-b-to-color":[{"mask-b-to":W()}],"mask-image-l-from-pos":[{"mask-l-from":G()}],"mask-image-l-to-pos":[{"mask-l-to":G()}],"mask-image-l-from-color":[{"mask-l-from":W()}],"mask-image-l-to-color":[{"mask-l-to":W()}],"mask-image-x-from-pos":[{"mask-x-from":G()}],"mask-image-x-to-pos":[{"mask-x-to":G()}],"mask-image-x-from-color":[{"mask-x-from":W()}],"mask-image-x-to-color":[{"mask-x-to":W()}],"mask-image-y-from-pos":[{"mask-y-from":G()}],"mask-image-y-to-pos":[{"mask-y-to":G()}],"mask-image-y-from-color":[{"mask-y-from":W()}],"mask-image-y-to-color":[{"mask-y-to":W()}],"mask-image-radial":[{"mask-radial":[at,ot]}],"mask-image-radial-from-pos":[{"mask-radial-from":G()}],"mask-image-radial-to-pos":[{"mask-radial-to":G()}],"mask-image-radial-from-color":[{"mask-radial-from":W()}],"mask-image-radial-to-color":[{"mask-radial-to":W()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":O()}],"mask-image-conic-pos":[{"mask-conic":[St]}],"mask-image-conic-from-pos":[{"mask-conic-from":G()}],"mask-image-conic-to-pos":[{"mask-conic-to":G()}],"mask-image-conic-from-color":[{"mask-conic-from":W()}],"mask-image-conic-to-color":[{"mask-conic-to":W()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:gt()}],"mask-repeat":[{mask:k()}],"mask-size":[{mask:j()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",at,ot]}],filter:[{filter:["","none",at,ot]}],blur:[{blur:tt()}],brightness:[{brightness:[St,at,ot]}],contrast:[{contrast:[St,at,ot]}],"drop-shadow":[{"drop-shadow":["","none",p,Aa,Ea]}],"drop-shadow-color":[{"drop-shadow":W()}],grayscale:[{grayscale:["",St,at,ot]}],"hue-rotate":[{"hue-rotate":[St,at,ot]}],invert:[{invert:["",St,at,ot]}],saturate:[{saturate:[St,at,ot]}],sepia:[{sepia:["",St,at,ot]}],"backdrop-filter":[{"backdrop-filter":["","none",at,ot]}],"backdrop-blur":[{"backdrop-blur":tt()}],"backdrop-brightness":[{"backdrop-brightness":[St,at,ot]}],"backdrop-contrast":[{"backdrop-contrast":[St,at,ot]}],"backdrop-grayscale":[{"backdrop-grayscale":["",St,at,ot]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[St,at,ot]}],"backdrop-invert":[{"backdrop-invert":["",St,at,ot]}],"backdrop-opacity":[{"backdrop-opacity":[St,at,ot]}],"backdrop-saturate":[{"backdrop-saturate":[St,at,ot]}],"backdrop-sepia":[{"backdrop-sepia":["",St,at,ot]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":I()}],"border-spacing-x":[{"border-spacing-x":I()}],"border-spacing-y":[{"border-spacing-y":I()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",at,ot]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[St,"initial",at,ot]}],ease:[{ease:["linear","initial",S,at,ot]}],delay:[{delay:[St,at,ot]}],animate:[{animate:["none",A,at,ot]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[v,at,ot]}],"perspective-origin":[{"perspective-origin":M()}],rotate:[{rotate:ht()}],"rotate-x":[{"rotate-x":ht()}],"rotate-y":[{"rotate-y":ht()}],"rotate-z":[{"rotate-z":ht()}],scale:[{scale:B()}],"scale-x":[{"scale-x":B()}],"scale-y":[{"scale-y":B()}],"scale-z":[{"scale-z":B()}],"scale-3d":["scale-3d"],skew:[{skew:ct()}],"skew-x":[{"skew-x":ct()}],"skew-y":[{"skew-y":ct()}],transform:[{transform:[at,ot,"","none","gpu","cpu"]}],"transform-origin":[{origin:M()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:H()}],"translate-x":[{"translate-x":H()}],"translate-y":[{"translate-y":H()}],"translate-z":[{"translate-z":H()}],"translate-none":["translate-none"],accent:[{accent:W()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:W()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",at,ot]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":I()}],"scroll-mx":[{"scroll-mx":I()}],"scroll-my":[{"scroll-my":I()}],"scroll-ms":[{"scroll-ms":I()}],"scroll-me":[{"scroll-me":I()}],"scroll-mt":[{"scroll-mt":I()}],"scroll-mr":[{"scroll-mr":I()}],"scroll-mb":[{"scroll-mb":I()}],"scroll-ml":[{"scroll-ml":I()}],"scroll-p":[{"scroll-p":I()}],"scroll-px":[{"scroll-px":I()}],"scroll-py":[{"scroll-py":I()}],"scroll-ps":[{"scroll-ps":I()}],"scroll-pe":[{"scroll-pe":I()}],"scroll-pt":[{"scroll-pt":I()}],"scroll-pr":[{"scroll-pr":I()}],"scroll-pb":[{"scroll-pb":I()}],"scroll-pl":[{"scroll-pl":I()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",at,ot]}],fill:[{fill:["none",...W()]}],"stroke-w":[{stroke:[St,Qs,ni,dc]}],stroke:[{stroke:["none",...W()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}});function zr(...n){return Gb(fb(n))}const to=({text:n,title:t,toggleState:e,toggleOn:r,toggleOff:i})=>{const[s,o]=N.useState(!1),[a,l]=N.useState(e||!1),c=()=>{l(!a),a?i():r()};return w.jsx("div",{className:zr("w-[5.5em] text-center cursor-pointer select-none rounded-sm - mt-px mr-[5px] mb-0 ml-[5px] inline-block",s||a?"bg-[#5e5e5e] text-white border border-[#FFFFFF]":"text-[#CCCCCC] border border-[transparent]"),onMouseOver:()=>o(!0),onMouseOut:()=>o(!1),onClick:c,title:t,children:n})},Ag=({title:n,icon:t,textStyle:e,text:r,titleStyle:i,content:s})=>{const[o,a]=N.useState(!1),[l,c]=N.useState(!1);return w.jsxs("div",{className:"w-auto inline-block m-0 pr-1.5",children:[w.jsxs("div",{className:zr("flex items-center cursor-pointer text-center select-none",o?"text-white":"text-[#CCCCCC]"),onClick:()=>a(!o),title:n,children:[t&&t(),w.jsx("span",{className:"relative",style:e,children:r})]}),w.jsxs("div",{className:zr("fixed left-0 w-[calc(100%_-_2px)] transition-all duration-300 ease-in-out z-0 bottom-5 p-0 m-0 bg-[#2E2F33] border-t border-t-[#555]",o?"h-[40%]":"invisible h-0"),children:[w.jsxs("div",{className:"relative w-full h-[2em] top-0 left-0 border-b border-b-[#555]",children:[w.jsx("b",{className:"relative h-[2em] ml-[1em] leading-[2em]",style:i,children:n}),w.jsx(I1,{className:zr("absolute w-[2em] h-[2em] right-0 top-0 cursor-pointer p-2 border-l border-l-[#555]",l?"text-white bg-[#005FAF]":""),onMouseOver:()=>c(!0),onMouseOut:()=>c(!1),onClick:()=>a(!o)})]}),w.jsx("div",{className:"relative w-full p-[1em] overflow-y-auto h-[calc(100%_-_2em)]",children:s})]})]})};function Wb(n){return se({attr:{fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor","aria-hidden":"true"},child:[{tag:"path",attr:{strokeLinecap:"round",strokeLinejoin:"round",d:"m21 21-5.197-5.197m0 0A7.5 7.5 0 1 0 5.196 5.196a7.5 7.5 0 0 0 10.607 10.607ZM13.5 10.5h-6"},child:[]}]})(n)}function Ub(n){return se({attr:{fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor","aria-hidden":"true"},child:[{tag:"path",attr:{strokeLinecap:"round",strokeLinejoin:"round",d:"m21 21-5.197-5.197m0 0A7.5 7.5 0 1 0 5.196 5.196a7.5 7.5 0 0 0 10.607 10.607ZM10.5 7.5v6m3-3h-6"},child:[]}]})(n)}function Yb(n,t,e,r,i){return r+(i-r)*(n-t)/(e-t)}const Xb=()=>{const{planner:n,toggleSnap:t,viewer:e}=Jt(),{mode:r,mouse:i,zoom:s,snapMask:o}=n,a=n.get("warnings").toArray(),l=n.get("errors").toArray(),c=f=>t(o.merge(f)),h=f=>{const g=parseInt(Jp(s).toFixed());if(g===0&&f==="out"||g===100&&f==="in"||!e)return;const p=e==null?void 0:e.getValue(),m=p.viewerWidth/2,v=p.viewerHeight/2,_=f==="in"?-1:1,S=1.06,A=Math.max(-1,Math.min(1,_)),C=Yb(A,-1,1,S,1/S);e.zoom(m,v,C)};return w.jsxs("div",{className:"floor_planner-footerbar absolute z-[9001] py-[3px] px-[1em] text-xs bg-[#424242] h-5 w-full select-none cursor-default bottom-0 leading-[14px] text-white m-0",children:[hl.includes(r)&&w.jsxs(w.Fragment,{children:[w.jsx("div",{className:"relative float-left px-[1em] inline-block border-r border-r-white",title:"Scene Zoom Level",children:w.jsxs("div",{className:"flex items-center gap-2",children:[w.jsx("span",{children:"Zoom:"})," ",w.jsx(Wb,{className:"inline-block cursor-pointer",size:16,onClick:()=>h("out")})," ",w.jsxs("span",{children:[Jp(s).toFixed(),"%"]})," ",w.jsx(Ub,{className:"inline-block cursor-pointer",size:16,onClick:()=>h("in")})]})}),w.jsxs("div",{className:"relative float-left px-[1em] inline-block border-r border-r-white",children:[w.jsx(to,{toggleOn:()=>{c({SNAP_POINT:!0})},toggleOff:()=>{c({SNAP_POINT:!1})},text:"Snap PT",toggleState:o.get(gl),title:"Snap to Point"}),w.jsx(to,{toggleOn:()=>{c({SNAP_LINE:!0})},toggleOff:()=>{c({SNAP_LINE:!1})},text:"Snap LN",toggleState:o.get(ml),title:"Snap to Line"}),w.jsx(to,{toggleOn:()=>{c({SNAP_SEGMENT:!0})},toggleOff:()=>{c({SNAP_SEGMENT:!1})},text:"Snap SEG",toggleState:o.get(yl),title:"Snap to Segment"}),w.jsx(to,{toggleOn:()=>{c({SNAP_GRID:!0})},toggleOff:()=>{c({SNAP_GRID:!1})},text:"Snap GRD",toggleState:o.get(vl),title:"Snap to Grid"}),w.jsx(to,{toggleOn:()=>{c({SNAP_GUIDE:!0})},toggleOff:()=>{c({SNAP_GUIDE:!1})},text:"Snap GDE",toggleState:o.get(ud),title:"Snap to Guide"})]})]}),w.jsxs("div",{className:"relative float-right inline-block px-[1em] border-l border-l-white",children:[w.jsx(Ag,{icon:()=>w.jsx(H1,{style:{width:"15px",height:"15px",marginTop:"-2px",marginRight:"2px",...l.length?{transform:"rotate(45deg)",color:"#F44336"}:{transform:"rotate(45deg)"}}}),text:l.length.toString(),textStyle:l.length?{color:"#F44336"}:{},title:`Errors [ ${l.length} ]`,titleStyle:l.length?{color:"#F44336"}:{},content:w.jsx(w.Fragment,{children:l.map((f,g)=>w.jsxs("div",{style:{borderBottom:"1px solid #555",lineHeight:"1.5em"},children:["[ ",new Date(f.date).toLocaleString()," ] ",f.error]},g))})}),w.jsx(Ag,{icon:()=>w.jsx($1,{style:{width:"15px",height:"15px",marginTop:"-2px",marginRight:"2px",...a.length?{color:"#FFEB3B"}:{}}}),text:a.length.toString(),textStyle:a.length?{color:"#FFEB3B"}:{},title:`Warnings [ ${a.length} ]`,titleStyle:a.length?{color:"#FFEB3B"}:{},content:w.jsx(w.Fragment,{children:a.map((f,g)=>w.jsxs("div",{className:"leading-6 border-b border-b-[#555555]",children:["[ ",new Date(f.date).toLocaleString()," ] ",f.warning]},g))})})]})]})},Og=({children:n,name:t,...e})=>{const[r,i]=N.useState(e.opened||!1);return w.jsxs("div",{className:"select-none",style:{borderBottom:"1px solid #5e5e5e"},children:[w.jsxs("div",{className:"flex px-4 pt-2.5 pb-3 items-center gap-1 bg-[#2b2b2b] text-white cursor-pointer",onClick:()=>i(!r),children:[r?w.jsx(z1,{size:16}):w.jsx(T1,{size:16}),w.jsx("span",{className:"text-sm leading-none",children:t})]}),w.jsx("div",{className:zr("text-[11px] text-[#EBEBEB] border border-[#222222] bg-[#424242]",r?"block":"hidden"),children:n})]})};function Tr({children:n,style:t,className:e,...r}){return w.jsx("label",{className:zr("mb-1 text-xs capitalize font-bold text-white block",e),style:t,...r,children:n})}const pn=({value:n,min:t,max:e,precision:r,onChange:i,onValid:s,onInvalid:o,style:a,placeholder:l})=>{const[c,h]=N.useState(!0),[f,g]=N.useState(n);let p=new RegExp(`^-?([0-9]+)?\\.?([0-9]{0,${r}})?$`);N.useEffect(()=>{t!==void 0&&!isNaN(t)&&isFinite(t)&&Number(f)<t&&g(t),e&&!isNaN(e)&&isFinite(e)&&Number(f)>e&&g(e)},[t,e,f]);const m=N.useMemo(()=>parseFloat(String(n)).toFixed(r)!==parseFloat(String(f)).toFixed(r),[n,f,r]),v=_=>{if(_.stopPropagation(),c){let S=f!==""&&f!=="-"?parseFloat(String(f)):0;g(S),i({target:{value:S}})}};return w.jsxs("div",{className:"relative w-full",children:[w.jsx("input",{type:"text",value:p.test(String(f))?f:parseFloat(String(f)).toFixed(r),className:"block text-[13px] text-white h-[35px] w-full px-2 leading-5 rounded border border-[#5e5e5e] bg-[#2b2b2b] outline-none focus:outline-none",style:{...a},onChange:_=>{let S=p.test(_.target.value);S?(g(_.target.value),s&&s(_.nativeEvent)):o&&o(_.nativeEvent),h(S)},onKeyDown:_=>{var S=_.keyCode||_.which;(S==lr.ENTER||S==lr.TAB)&&m&&v(_)},placeholder:l}),w.jsx("div",{onClick:_=>{m&&v(_)},title:"Confirm",className:"absolute cursor-pointer w-[2em] h-[2em] text-white top-[0.35em] right-[0.35em] bg-[#1CA6FC]",style:{transition:"all 0.1s linear",visibility:m?"visible":"hidden",opacity:m?"1":"0"},children:w.jsx(q1,{style:{width:"100%",height:"100%",padding:"0.2em",color:"#FFF"}})})]})},Jb={mm:{name:{singular:"Millimeter",plural:"Millimeters"},to_anchor:1/1e3},cm:{name:{singular:"Centimeter",plural:"Centimeters"},to_anchor:1/100},m:{name:{singular:"Meter",plural:"Meters"},to_anchor:1},km:{name:{singular:"Kilometer",plural:"Kilometers"},to_anchor:1e3}},Zb={in:{name:{singular:"Inch",plural:"Inches"},to_anchor:1/12},yd:{name:{singular:"Yard",plural:"Yards"},to_anchor:3},"ft-us":{name:{singular:"US Survey Foot",plural:"US Survey Feet"},to_anchor:1.000002},ft:{name:{singular:"Foot",plural:"Feet"},to_anchor:1},mi:{name:{singular:"Mile",plural:"Miles"},to_anchor:5280}},Kb={metric:Jb,imperial:Zb,_anchors:{metric:{unit:"m",ratio:3.28084},imperial:{unit:"ft",ratio:1/3.28084}}},Qb={mm2:{name:{singular:"Square Millimeter",plural:"Square Millimeters"},to_anchor:1/1e6},cm2:{name:{singular:"Centimeter",plural:"Centimeters"},to_anchor:1/1e4},m2:{name:{singular:"Square Meter",plural:"Square Meters"},to_anchor:1},ha:{name:{singular:"Hectare",plural:"Hectares"},to_anchor:1e4},km2:{name:{singular:"Square Kilometer",plural:"Square Kilometers"},to_anchor:1e6}},tw={in2:{name:{singular:"Square Inch",plural:"Square Inches"},to_anchor:1/144},yd2:{name:{singular:"Square Yard",plural:"Square Yards"},to_anchor:9},ft2:{name:{singular:"Square Foot",plural:"Square Feet"},to_anchor:1},ac:{name:{singular:"Acre",plural:"Acres"},to_anchor:43560},mi2:{name:{singular:"Square Mile",plural:"Square Miles"},to_anchor:27878400}},ew={metric:Qb,imperial:tw,_anchors:{metric:{unit:"m2",ratio:10.7639},imperial:{unit:"ft2",ratio:1/10.7639}}},rw={mcg:{name:{singular:"Microgram",plural:"Micrograms"},to_anchor:1/1e6},mg:{name:{singular:"Milligram",plural:"Milligrams"},to_anchor:1/1e3},g:{name:{singular:"Gram",plural:"Grams"},to_anchor:1},kg:{name:{singular:"Kilogram",plural:"Kilograms"},to_anchor:1e3},mt:{name:{singular:"Metric Tonne",plural:"Metric Tonnes"},to_anchor:1e6}},nw={oz:{name:{singular:"Ounce",plural:"Ounces"},to_anchor:1/16},lb:{name:{singular:"Pound",plural:"Pounds"},to_anchor:1},t:{name:{singular:"Ton",plural:"Tons"},to_anchor:2e3}},iw={metric:rw,imperial:nw,_anchors:{metric:{unit:"g",ratio:1/453.592},imperial:{unit:"lb",ratio:453.592}}},sw={mm3:{name:{singular:"Cubic Millimeter",plural:"Cubic Millimeters"},to_anchor:1/1e6},cm3:{name:{singular:"Cubic Centimeter",plural:"Cubic Centimeters"},to_anchor:1/1e3},ml:{name:{singular:"Millilitre",plural:"Millilitres"},to_anchor:1/1e3},cl:{name:{singular:"Centilitre",plural:"Centilitres"},to_anchor:1/100},dl:{name:{singular:"Decilitre",plural:"Decilitres"},to_anchor:1/10},l:{name:{singular:"Litre",plural:"Litres"},to_anchor:1},kl:{name:{singular:"Kilolitre",plural:"Kilolitres"},to_anchor:1e3},m3:{name:{singular:"Cubic meter",plural:"Cubic meters"},to_anchor:1e3},km3:{name:{singular:"Cubic kilometer",plural:"Cubic kilometers"},to_anchor:1e12},krm:{name:{singular:"Matsked",plural:"Matskedar"},to_anchor:1/1e3},tsk:{name:{singular:"Tesked",plural:"Teskedar"},to_anchor:5/1e3},msk:{name:{singular:"Matsked",plural:"Matskedar"},to_anchor:15/1e3},kkp:{name:{singular:"Kaffekopp",plural:"Kaffekoppar"},to_anchor:150/1e3},glas:{name:{singular:"Glas",plural:"Glas"},to_anchor:200/1e3},kanna:{name:{singular:"Kanna",plural:"Kannor"},to_anchor:2.617}},ow={tsp:{name:{singular:"Teaspoon",plural:"Teaspoons"},to_anchor:1/6},Tbs:{name:{singular:"Tablespoon",plural:"Tablespoons"},to_anchor:1/2},in3:{name:{singular:"Cubic inch",plural:"Cubic inches"},to_anchor:.55411},"fl-oz":{name:{singular:"Fluid Ounce",plural:"Fluid Ounces"},to_anchor:1},cup:{name:{singular:"Cup",plural:"Cups"},to_anchor:8},pnt:{name:{singular:"Pint",plural:"Pints"},to_anchor:16},qt:{name:{singular:"Quart",plural:"Quarts"},to_anchor:32},gal:{name:{singular:"Gallon",plural:"Gallons"},to_anchor:128},ft3:{name:{singular:"Cubic foot",plural:"Cubic feet"},to_anchor:957.506},yd3:{name:{singular:"Cubic yard",plural:"Cubic yards"},to_anchor:25852.7}},aw={metric:sw,imperial:ow,_anchors:{metric:{unit:"l",ratio:33.8140226},imperial:{unit:"fl-oz",ratio:1/33.8140226}}},uw={metric:{ea:{name:{singular:"Each",plural:"Each"},to_anchor:1},dz:{name:{singular:"Dozen",plural:"Dozens"},to_anchor:12}},imperial:{},_anchors:{metric:{unit:"ea",ratio:1}}},lw={metric:{C:{name:{singular:"degree Celsius",plural:"degrees Celsius"},to_anchor:1,anchor_shift:0},K:{name:{singular:"degree Kelvin",plural:"degrees Kelvin"},to_anchor:1,anchor_shift:273.15}},imperial:{F:{name:{singular:"degree Fahrenheit",plural:"degrees Fahrenheit"},to_anchor:1},R:{name:{singular:"degree Rankine",plural:"degrees Rankine"},to_anchor:1,anchor_shift:459.67}},_anchors:{metric:{unit:"C",transform:function(n){return n/(5/9)+32}},imperial:{unit:"F",transform:function(n){return(n-32)*(5/9)}}}},zg=365.25,cw={metric:{ns:{name:{singular:"Nanosecond",plural:"Nanoseconds"},to_anchor:1/1e9},mu:{name:{singular:"Microsecond",plural:"Microseconds"},to_anchor:1/1e6},ms:{name:{singular:"Millisecond",plural:"Milliseconds"},to_anchor:1/1e3},s:{name:{singular:"Second",plural:"Seconds"},to_anchor:1},min:{name:{singular:"Minute",plural:"Minutes"},to_anchor:60},h:{name:{singular:"Hour",plural:"Hours"},to_anchor:3600},d:{name:{singular:"Day",plural:"Days"},to_anchor:3600*24},week:{name:{singular:"Week",plural:"Weeks"},to_anchor:3600*24*7},month:{name:{singular:"Month",plural:"Months"},to_anchor:3600*24*zg/12},year:{name:{singular:"Year",plural:"Years"},to_anchor:3600*24*zg}},_anchors:{metric:{unit:"s",ratio:1}}},hw={bits:{b:{name:{singular:"Bit",plural:"Bits"},to_anchor:1},Kb:{name:{singular:"Kilobit",plural:"Kilobits"},to_anchor:1024},Mb:{name:{singular:"Megabit",plural:"Megabits"},to_anchor:1048576},Gb:{name:{singular:"Gigabit",plural:"Gigabits"},to_anchor:1073741824},Tb:{name:{singular:"Terabit",plural:"Terabits"},to_anchor:1099511627776}},bytes:{B:{name:{singular:"Byte",plural:"Bytes"},to_anchor:1},KB:{name:{singular:"Kilobyte",plural:"Kilobytes"},to_anchor:1024},MB:{name:{singular:"Megabyte",plural:"Megabytes"},to_anchor:1048576},GB:{name:{singular:"Gigabyte",plural:"Gigabytes"},to_anchor:1073741824},TB:{name:{singular:"Terabyte",plural:"Terabytes"},to_anchor:1099511627776}},_anchors:{bits:{unit:"b",ratio:1/8},bytes:{unit:"B",ratio:8}}},fw={metric:{ppm:{name:{singular:"Part-per Million",plural:"Parts-per Million"},to_anchor:1},ppb:{name:{singular:"Part-per Billion",plural:"Parts-per Billion"},to_anchor:.001},ppt:{name:{singular:"Part-per Trillion",plural:"Parts-per Trillion"},to_anchor:1e-6},ppq:{name:{singular:"Part-per Quadrillion",plural:"Parts-per Quadrillion"},to_anchor:1e-9}},imperial:{},_anchors:{metric:{unit:"ppm",ratio:1e-6}}},dw={metric:{"m/s":{name:{singular:"Metre per second",plural:"Metres per second"},to_anchor:3.6},"km/h":{name:{singular:"Kilometre per hour",plural:"Kilometres per hour"},to_anchor:1}},imperial:{"m/h":{name:{singular:"Mile per hour",plural:"Miles per hour"},to_anchor:1},knot:{name:{singular:"Knot",plural:"Knots"},to_anchor:1.150779},"ft/s":{name:{singular:"Foot per second",plural:"Feet per second"},to_anchor:.681818}},_anchors:{metric:{unit:"km/h",ratio:1/1.609344},imperial:{unit:"m/h",ratio:1.609344}}},pw={Pa:{name:{singular:"pascal",plural:"pascals"},to_anchor:1/1e3},kPa:{name:{singular:"kilopascal",plural:"kilopascals"},to_anchor:1},MPa:{name:{singular:"megapascal",plural:"megapascals"},to_anchor:1e3},hPa:{name:{singular:"hectopascal",plural:"hectopascals"},to_anchor:1/10},bar:{name:{singular:"bar",plural:"bar"},to_anchor:100},torr:{name:{singular:"torr",plural:"torr"},to_anchor:101325/76e4}},gw={psi:{name:{singular:"pound per square inch",plural:"pounds per square inch"},to_anchor:1/1e3},ksi:{name:{singular:"kilopound per square inch",plural:"kilopound per square inch"},to_anchor:1}},mw={metric:pw,imperial:gw,_anchors:{metric:{unit:"kPa",ratio:.00014503768078},imperial:{unit:"psi",ratio:1/.00014503768078}}},yw={metric:{A:{name:{singular:"Ampere",plural:"Amperes"},to_anchor:1},mA:{name:{singular:"Milliampere",plural:"Milliamperes"},to_anchor:.001},kA:{name:{singular:"Kiloampere",plural:"Kiloamperes"},to_anchor:1e3}},_anchors:{metric:{unit:"A",ratio:1}}},vw={metric:{V:{name:{singular:"Volt",plural:"Volts"},to_anchor:1},mV:{name:{singular:"Millivolt",plural:"Millivolts"},to_anchor:.001},kV:{name:{singular:"Kilovolt",plural:"Kilovolts"},to_anchor:1e3}},_anchors:{metric:{unit:"V",ratio:1}}},xw={metric:{W:{name:{singular:"Watt",plural:"Watts"},to_anchor:1},mW:{name:{singular:"Milliwatt",plural:"Milliwatts"},to_anchor:.001},kW:{name:{singular:"Kilowatt",plural:"Kilowatts"},to_anchor:1e3},MW:{name:{singular:"Megawatt",plural:"Megawatts"},to_anchor:1e6},GW:{name:{singular:"Gigawatt",plural:"Gigawatts"},to_anchor:1e9}},_anchors:{metric:{unit:"W",ratio:1}}},_w={metric:{VAR:{name:{singular:"Volt-Ampere Reactive",plural:"Volt-Amperes Reactive"},to_anchor:1},mVAR:{name:{singular:"Millivolt-Ampere Reactive",plural:"Millivolt-Amperes Reactive"},to_anchor:.001},kVAR:{name:{singular:"Kilovolt-Ampere Reactive",plural:"Kilovolt-Amperes Reactive"},to_anchor:1e3},MVAR:{name:{singular:"Megavolt-Ampere Reactive",plural:"Megavolt-Amperes Reactive"},to_anchor:1e6},GVAR:{name:{singular:"Gigavolt-Ampere Reactive",plural:"Gigavolt-Amperes Reactive"},to_anchor:1e9}},_anchors:{metric:{unit:"VAR",ratio:1}}},bw={metric:{VA:{name:{singular:"Volt-Ampere",plural:"Volt-Amperes"},to_anchor:1},mVA:{name:{singular:"Millivolt-Ampere",plural:"Millivolt-Amperes"},to_anchor:.001},kVA:{name:{singular:"Kilovolt-Ampere",plural:"Kilovolt-Amperes"},to_anchor:1e3},MVA:{name:{singular:"Megavolt-Ampere",plural:"Megavolt-Amperes"},to_anchor:1e6},GVA:{name:{singular:"Gigavolt-Ampere",plural:"Gigavolt-Amperes"},to_anchor:1e9}},_anchors:{metric:{unit:"VA",ratio:1}}},ww={metric:{Wh:{name:{singular:"Watt-hour",plural:"Watt-hours"},to_anchor:3600},mWh:{name:{singular:"Milliwatt-hour",plural:"Milliwatt-hours"},to_anchor:3.6},kWh:{name:{singular:"Kilowatt-hour",plural:"Kilowatt-hours"},to_anchor:36e5},MWh:{name:{singular:"Megawatt-hour",plural:"Megawatt-hours"},to_anchor:36e8},GWh:{name:{singular:"Gigawatt-hour",plural:"Gigawatt-hours"},to_anchor:36e11},J:{name:{singular:"Joule",plural:"Joules"},to_anchor:1},kJ:{name:{singular:"Kilojoule",plural:"Kilojoules"},to_anchor:1e3}},_anchors:{metric:{unit:"J",ratio:1}}},Sw={metric:{VARh:{name:{singular:"Volt-Ampere Reactive Hour",plural:"Volt-Amperes Reactive Hour"},to_anchor:1},mVARh:{name:{singular:"Millivolt-Ampere Reactive Hour",plural:"Millivolt-Amperes Reactive Hour"},to_anchor:.001},kVARh:{name:{singular:"Kilovolt-Ampere Reactive Hour",plural:"Kilovolt-Amperes Reactive Hour"},to_anchor:1e3},MVARh:{name:{singular:"Megavolt-Ampere Reactive Hour",plural:"Megavolt-Amperes Reactive Hour"},to_anchor:1e6},GVARh:{name:{singular:"Gigavolt-Ampere Reactive Hour",plural:"Gigavolt-Amperes Reactive Hour"},to_anchor:1e9}},_anchors:{metric:{unit:"VARh",ratio:1}}},Mw={"mm3/s":{name:{singular:"Cubic Millimeter per second",plural:"Cubic Millimeters per second"},to_anchor:1/1e6},"cm3/s":{name:{singular:"Cubic Centimeter per second",plural:"Cubic Centimeters per second"},to_anchor:1/1e3},"ml/s":{name:{singular:"Millilitre per second",plural:"Millilitres per second"},to_anchor:1/1e3},"cl/s":{name:{singular:"Centilitre per second",plural:"Centilitres per second"},to_anchor:1/100},"dl/s":{name:{singular:"Decilitre per second",plural:"Decilitres per second"},to_anchor:1/10},"l/s":{name:{singular:"Litre per second",plural:"Litres per second"},to_anchor:1},"l/min":{name:{singular:"Litre per minute",plural:"Litres per minute"},to_anchor:1/60},"l/h":{name:{singular:"Litre per hour",plural:"Litres per hour"},to_anchor:1/3600},"kl/s":{name:{singular:"Kilolitre per second",plural:"Kilolitres per second"},to_anchor:1e3},"kl/min":{name:{singular:"Kilolitre per minute",plural:"Kilolitres per minute"},to_anchor:50/3},"kl/h":{name:{singular:"Kilolitre per hour",plural:"Kilolitres per hour"},to_anchor:5/18},"m3/s":{name:{singular:"Cubic meter per second",plural:"Cubic meters per second"},to_anchor:1e3},"m3/min":{name:{singular:"Cubic meter per minute",plural:"Cubic meters per minute"},to_anchor:50/3},"m3/h":{name:{singular:"Cubic meter per hour",plural:"Cubic meters per hour"},to_anchor:5/18},"km3/s":{name:{singular:"Cubic kilometer per second",plural:"Cubic kilometers per second"},to_anchor:1e12}},Ew={"tsp/s":{name:{singular:"Teaspoon per second",plural:"Teaspoons per second"},to_anchor:1/6},"Tbs/s":{name:{singular:"Tablespoon per second",plural:"Tablespoons per second"},to_anchor:1/2},"in3/s":{name:{singular:"Cubic inch per second",plural:"Cubic inches per second"},to_anchor:.55411},"in3/min":{name:{singular:"Cubic inch per minute",plural:"Cubic inches per minute"},to_anchor:.55411/60},"in3/h":{name:{singular:"Cubic inch per hour",plural:"Cubic inches per hour"},to_anchor:.55411/3600},"fl-oz/s":{name:{singular:"Fluid Ounce per second",plural:"Fluid Ounces per second"},to_anchor:1},"fl-oz/min":{name:{singular:"Fluid Ounce per minute",plural:"Fluid Ounces per minute"},to_anchor:1/60},"fl-oz/h":{name:{singular:"Fluid Ounce per hour",plural:"Fluid Ounces per hour"},to_anchor:1/3600},"cup/s":{name:{singular:"Cup per second",plural:"Cups per second"},to_anchor:8},"pnt/s":{name:{singular:"Pint per second",plural:"Pints per second"},to_anchor:16},"pnt/min":{name:{singular:"Pint per minute",plural:"Pints per minute"},to_anchor:4/15},"pnt/h":{name:{singular:"Pint per hour",plural:"Pints per hour"},to_anchor:1/225},"qt/s":{name:{singular:"Quart per second",plural:"Quarts per second"},to_anchor:32},"gal/s":{name:{singular:"Gallon per second",plural:"Gallons per second"},to_anchor:128},"gal/min":{name:{singular:"Gallon per minute",plural:"Gallons per minute"},to_anchor:32/15},"gal/h":{name:{singular:"Gallon per hour",plural:"Gallons per hour"},to_anchor:8/225},"ft3/s":{name:{singular:"Cubic foot per second",plural:"Cubic feet per second"},to_anchor:957.506},"ft3/min":{name:{singular:"Cubic foot per minute",plural:"Cubic feet per minute"},to_anchor:957.506/60},"ft3/h":{name:{singular:"Cubic foot per hour",plural:"Cubic feet per hour"},to_anchor:957.506/3600},"yd3/s":{name:{singular:"Cubic yard per second",plural:"Cubic yards per second"},to_anchor:25852.7},"yd3/min":{name:{singular:"Cubic yard per minute",plural:"Cubic yards per minute"},to_anchor:25852.7/60},"yd3/h":{name:{singular:"Cubic yard per hour",plural:"Cubic yards per hour"},to_anchor:25852.7/3600}},Aw={metric:Mw,imperial:Ew,_anchors:{metric:{unit:"l/s",ratio:33.8140227},imperial:{unit:"fl-oz/s",ratio:1/33.8140227}}},Ow={metric:{lx:{name:{singular:"Lux",plural:"Lux"},to_anchor:1}},imperial:{"ft-cd":{name:{singular:"Foot-candle",plural:"Foot-candles"},to_anchor:1}},_anchors:{metric:{unit:"lx",ratio:1/10.76391},imperial:{unit:"ft-cd",ratio:10.76391}}},zw={metric:{mHz:{name:{singular:"millihertz",plural:"millihertz"},to_anchor:1/1e3},Hz:{name:{singular:"hertz",plural:"hertz"},to_anchor:1},kHz:{name:{singular:"kilohertz",plural:"kilohertz"},to_anchor:1e3},MHz:{name:{singular:"megahertz",plural:"megahertz"},to_anchor:1e3*1e3},GHz:{name:{singular:"gigahertz",plural:"gigahertz"},to_anchor:1e3*1e3*1e3},THz:{name:{singular:"terahertz",plural:"terahertz"},to_anchor:1e3*1e3*1e3*1e3},rpm:{name:{singular:"rotation per minute",plural:"rotations per minute"},to_anchor:1/60},"deg/s":{name:{singular:"degree per second",plural:"degrees per second"},to_anchor:1/360},"rad/s":{name:{singular:"radian per second",plural:"radians per second"},to_anchor:1/(Math.PI*2)}},_anchors:{frequency:{unit:"hz",ratio:1}}},Rn={length:Kb,area:ew,mass:iw,volume:aw,each:uw,temperature:lw,time:cw,digital:hw,partsPer:fw,speed:dw,pressure:mw,current:yw,voltage:vw,power:xw,reactivePower:_w,apparentPower:bw,energy:ww,reactiveEnergy:Sw,volumeFlowRate:Aw,illuminance:Ow,frequency:zw};function eo(n){return Object.keys(n)}function Tg(n){return{abbr:n.abbr,measure:n.measure,system:n.system,singular:n.unit.name.singular,plural:n.unit.name.plural}}function dr(n,t){if(Array.isArray(n))for(let e=0;e<n.length;e++)t(n[e],e,n);else if(n&&typeof n=="object")for(let e in n)Object.prototype.hasOwnProperty.call(n,e)&&t(n[e],e,n)}class Tw{constructor(t,e){It(this,"val");It(this,"destination");It(this,"origin");this.val=e?t/e:t}from(t){if(this.destination)throw new Error(".from must be called before .to");return this.origin=this.getUnit(t),this.origin||this.throwUnsupportedUnitError(t),this}to(t){if(!this.origin)throw new Error(".to must be called after .from");if(this.destination=this.getUnit(t),this.destination||this.throwUnsupportedUnitError(t),this.origin.abbr===this.destination.abbr)return this.val;if(this.destination.measure!==this.origin.measure)throw new Error(`Cannot convert incompatible measures of ${this.destination.measure} and ${this.origin.measure}`);let e=this.val*this.origin.unit.to_anchor;if(this.origin.unit.anchor_shift&&(e-=this.origin.unit.anchor_shift),this.origin.system!==this.destination.system){const r=Rn[this.origin.measure]._anchors[this.origin.system];e=typeof r.transform=="function"?r.transform(e):e*r.ratio}return this.destination.unit.anchor_shift&&(e+=this.destination.unit.anchor_shift),e/this.destination.unit.to_anchor}toBest(t){if(!this.origin)throw new Error(".toBest must be called after .from");const e={exclude:[],cutOffNumber:1,...t};let r=null;return dr(this.possibilities(),i=>{if(e.exclude.includes(i))return;const s=this.describe(i);if(s.system!==this.origin.system)return;const o=this.to(i);(!r||o>=e.cutOffNumber&&o<r.val)&&(r={val:o,unit:i,singular:s.singular,plural:s.plural})}),r}getUnit(t){let e=null;return dr(Rn,(r,i)=>{dr(r,(s,o)=>{o!=="_anchors"&&dr(s,(a,l)=>{l===t&&(e={abbr:t,measure:i,system:o,unit:a})})})}),e}describe(t){const e=this.getUnit(t);return e||this.throwUnsupportedUnitError(t),Tg(e)}list(t){const e=[];return dr(Rn,(r,i)=>{t&&t!==i||dr(r,(s,o)=>{o!=="_anchors"&&dr(s,(a,l)=>{e.push(Tg({abbr:l,measure:i,system:o,unit:a}))})})}),e}throwUnsupportedUnitError(t){const e=[];throw dr(Rn,r=>{dr(r,(i,s)=>{s!=="_anchors"&&e.push(...eo(i))})}),new Error(`Unsupported unit ${t}, use one of: ${e.join(", ")}`)}possibilities(t){const e=[];if(!this.origin&&!t)dr(eo(Rn),r=>{dr(Rn[r],(i,s)=>{s!=="_anchors"&&e.push(...eo(i))})});else{const r=t||this.origin.measure;dr(Rn[r],(i,s)=>{s!=="_anchors"&&e.push(...eo(i))})}return e}measures(){return eo(Rn)}}function Cr(n){return new Tw(n)}const Cw={fontSize:"13px",WebkitAppearance:"none"};function pc({children:n,style:t,...e}){return w.jsx("select",{className:"w-full cursor-pointer block px-2 outline-none rounded h-[35px] text-white bg-[#5e5e5e]",style:{...Cw,...t},...e,children:n})}const gc=({value:n,onUpdate:t,onValid:e,configs:r,sourceElement:i,internalState:s})=>{const{planner:o}=Jt(),a=n.get("length")||0,l=n.get("_length")||a,c=n.get("_unit")||Wr,{hook:h,label:f,...g}=r,p=(m,v)=>{let _=De(m),S=n.merge({length:v!==Wr?Cr(_).from(v).to(Wr):_,_length:m,_unit:v});return h?h(S,i,s,o).then(A=>t(A)):t(S)};return w.jsxs("div",{className:"PropertyLengthMeasure w-full mb-2",children:[w.jsx(Tr,{children:f}),w.jsxs("div",{className:"w-full flex",children:[w.jsx(pn,{value:l,style:{borderTopRightRadius:0,borderBottomRightRadius:0,borderRightWidth:0},onChange:m=>p(m.target.value,c),onValid:e,...g}),w.jsx("div",{className:"w-1/4 [&>*:first-child]:text-center",children:w.jsx(pc,{style:{borderTopLeftRadius:"0px",borderBottomLeftRadius:"0px"},value:c,onChange:m=>p(l,m.target.value),children:sd.map(m=>w.jsx("option",{value:m,children:m},m))})})]})]})},ro=({style:n,...t})=>w.jsx("input",{className:"block w-full px-2 text-sm leading-5 bg-[#2b2b2b] rounded border border-[#5e5e5e] outline-none h-[35px] text-white",style:{...n},type:"text",...t}),kw=({value:n,onUpdate:t,configs:e,sourceElement:r,internalState:i})=>{const{planner:s}=Jt(),o=a=>e.hook?e.hook(a,r,i,s).then(l=>t(l)):t(a);return w.jsxs("div",{className:"PropertyString w-full mb-2",children:[w.jsx(Tr,{children:e.label}),w.jsx(ro,{value:n,onChange:a=>o(a.target.value)})]})},Iw=({element:n,attributeFormData:t,onUpdate:e,...r})=>{let i=t.has("name")?t.get("name"):n.name,s=t.has("offsetA")?t.get("offsetA"):n.offsetA,o=t.has("offsetB")?t.get("offsetB"):n.offsetA;return w.jsxs("div",{children:[w.jsx(kw,{value:i,onUpdate:a=>e("name",a),configs:{label:"Nome"},...r}),w.jsx(gc,{value:s,onUpdate:a=>e("offsetA",a),configs:{label:"Offset 1",min:0,max:1/0,precision:2},...r}),w.jsx(gc,{value:o,onUpdate:a=>e("offsetB",a),configs:{label:"Offset 2",min:0,max:1/0,precision:2},...r})]})},Pw=({element:n,onUpdate:t,attributeFormData:e,...r})=>{let i=e.has("name")?e.get("name"):n.name,s=e.has("x")?e.get("x"):n.x,o=e.has("y")?e.get("y"):n.y,a=e.has("rotation")?e.get("rotation"):n.rotation;return w.jsx("table",{className:"w-full",children:w.jsxs("tbody",{children:[w.jsxs("tr",{children:[w.jsx("td",{className:"w-[6em]",children:"Name"}),w.jsx("td",{children:w.jsx(ro,{value:i,onChange:l=>t("name",l.target.value),style:{textAlign:"left"}})})]}),w.jsxs("tr",{children:[w.jsx("td",{className:"w-[6em]",children:"X"}),w.jsx("td",{children:w.jsx(pn,{value:s,onChange:l=>t("x",l.target.value),style:{textAlign:"left"},precision:2,...r})})]}),w.jsxs("tr",{children:[w.jsx("td",{className:"w-[6em]",children:"Y"}),w.jsx("td",{children:w.jsx(pn,{value:o,onChange:l=>t("y",l.target.value),style:{textAlign:"left"},precision:2,...r})})]}),w.jsxs("tr",{children:[w.jsx("td",{className:"w-[6em]",children:"Rotation"}),w.jsx("td",{children:w.jsx(pn,{value:a,onChange:l=>t("rotation",l.target.value),style:{textAlign:"left"},precision:2,...r})})]})]})})},Rw=({element:n,onUpdate:t,attributeFormData:e})=>{let r=e.has("name")?e.get("name"):n.name,i=e.has("lineLength")?e.get("lineLength"):null;return w.jsxs("div",{children:[w.jsxs("div",{className:"w-full mb-2",children:[w.jsx(Tr,{children:"Name"}),w.jsx(ro,{value:r,onChange:s=>t("name",s.target.value),style:{textAlign:"left"}})]}),w.jsx(gc,{value:i,onUpdate:s=>t("lineLength",s),configs:{label:"Length",min:0,max:1/0,precision:2}})]})},Lw=({element:n,onUpdate:t,onValid:e,attributeFormData:r,...i})=>n.prototype==="items"?w.jsx(Pw,{element:n,onUpdate:t,onValid:e,attributeFormData:r,...i}):n.prototype==="lines"?w.jsx(Rw,{element:n,onUpdate:t,onValid:e,attributeFormData:r,...i}):n.prototype==="holes"?w.jsx(Iw,{element:n,onUpdate:t,onValid:e,attributeFormData:r,...i}):null,kr=2,Nw=(n,t,e)=>{switch(n=typeof n.misc=="object"?n.set("misc",J(n.misc)):n,n.prototype){case"items":return J(n);case"lines":{let r=t.vertices.get(n.vertices.get(0)),i=t.vertices.get(n.vertices.get(1)),s=Oe(r.x,r.y,i.x,i.y),o=n.misc.get("_unitLength")||e.unit,a=Cr(s).from(e.unit).to(o);return J({vertexOne:r,vertexTwo:i,lineLength:J({length:s,_length:a,_unit:o})})}case"holes":{let r=t.lines.get(n.line),{x:i,y:s}=t.vertices.get(r.vertices.get(0)),{x:o,y:a}=t.vertices.get(r.vertices.get(1)),l=Oe(i,s,o,a),c=l*n.offset-n.properties.get("width").get("length")/2,h=n.misc.get("_unitA")||e.unit,f=Cr(c).from(e.unit).to(h),g=l-l*n.offset-n.properties.get("width").get("length")/2,p=n.misc.get("_unitB")||e.unit,m=Cr(g).from(e.unit).to(p);return J({offset:n.offset,offsetA:J({length:De(c,kr),_length:De(f,kr),_unit:h}),offsetB:J({length:De(g,kr),_length:De(m,kr),_unit:p})})}case"areas":return J({});default:return null}},Fw=(n,t)=>{const e=t.getElement(n.type),r={};for(const i in e.properties)r[i]=J({currentValue:n.properties.has(i)?n.properties.get(i):Bt(e.properties[i].defaultValue),configs:e.properties[i]});return J(r)},jw=({element:n,layer:t,catalog:e})=>{const{planner:r,setItemsAttributes:i,setProperties:s,setLinesAttributes:o,setHolesAttributes:a}=Jt(),[l,c]=N.useState(Nw(n,t,e)),[h,f]=N.useState(Fw(n,e)),g=({propertiesFormData:v,attributesFormData:_})=>{if(v){let S=v.map(A=>A.get("currentValue"));s(S)}if(_)switch(n.prototype){case"items":{i(_);break}case"lines":{o(_);break}case"holes":{a(_);break}}},p=(v,_)=>{if(!l)return;let S;switch(n.prototype){case"items":{S=l.set(v,_);break}case"lines":{switch(v){case"lineLength":{let A=l.get("vertexOne"),C=l.get("vertexTwo"),[O,M]=Us([A,C]),z=Qo(O.x,O.y,M.x,M.y,_.get("length"),kr);S=l.withMutations(R=>{R.set(A===O?"vertexTwo":"vertexOne",M.merge(z)),R.set("lineLength",_)});break}case"vertexOne":case"vertexTwo":{S=l.withMutations(A=>{A.set(v,A.get(v).merge(_));let C=Jo(A.get("vertexOne"),A.get("vertexTwo"));A.mergeIn(["lineLength"],A.get("lineLength").merge({length:C,_length:Cr(C).from(e.unit).to(A.get("lineLength").get("_unit"))}))});break}default:{S=l.set(v,_);break}}break}case"holes":{switch(v){case"offsetA":{let A=t.lines.get(n.line),C=Us([t.vertices.get(A.vertices.get(0)),t.vertices.get(A.vertices.get(1))]),[{x:O,y:M},{x:z,y:R}]=C,I=pl(O,M,z,R),L=Oe(O,M,z,R),Y=n.properties.get("width").get("length"),X=Y/2,it=_.get("length");it=Math.max(it,0),it=Math.min(it,L-Y);let rt=(it+X)*Math.cos(I)+O,vt=(it+X)*Math.sin(I)+M,mt=ze(O,M,z,R,rt,vt),dt=De(L-L*mt-X,kr),ut=l.getIn(["offsetB","_unit"]),W=J({length:dt,_length:Cr(dt).from(e.unit).to(ut),_unit:ut});S=l.set("offsetB",W).set("offset",mt);let gt=J({length:De(it,kr),_unit:_.get("_unit"),_length:De(Cr(it).from(e.unit).to(_.get("_unit")),kr)});S=l.set(v,gt);break}case"offsetB":{let A=t.lines.get(n.line),C=Us([t.vertices.get(A.vertices.get(0)),t.vertices.get(A.vertices.get(1))]),[{x:O,y:M},{x:z,y:R}]=C,I=pl(O,M,z,R),L=Oe(O,M,z,R),Y=n.properties.get("width").get("length"),X=Y/2,it=_.get("length");it=Math.max(it,0),it=Math.min(it,L-Y);let rt=z-(it+X)*Math.cos(I),vt=R-(it+X)*Math.sin(I),mt=ze(O,M,z,R,rt,vt),dt=De(L*mt-X,kr),ut=l.getIn(["offsetA","_unit"]),W=J({length:dt,_length:Cr(dt).from(e.unit).to(ut),_unit:ut});S=l.set("offsetA",W).set("offset",mt);let gt=J({length:De(it,kr),_unit:_.get("_unit"),_length:De(Cr(it).from(e.unit).to(_.get("_unit")),kr)});S=l.set(v,gt);break}default:{S=l.set(v,_);break}}break}}S&&(c(S),g({attributesFormData:S,propertiesFormData:h}))},m=(v,_)=>{const S=h.setIn([v,"currentValue"],_);f(S),g({propertiesFormData:S,attributesFormData:l})};return w.jsxs("div",{children:[w.jsx(Lw,{element:n,onValid:()=>{},onUpdate:p,attributeFormData:l}),h.entrySeq().map(([v,_])=>{let S=_.get("currentValue"),A=_.get("configs"),{Editor:C}=e.getPropertyType(A.type);return w.jsx(C,{propertyName:v,value:S,configs:A,onUpdate:O=>m(v,O),state:r,sourceElement:n,internalState:{attributesFormData:l,propertiesFormData:h}},v)})]})},Vw=()=>w.jsxs("div",{className:"h-full flex flex-col gap-4 justify-center items-center",children:[w.jsx("div",{className:"text-3xl text-white",children:w.jsx("img",{src:"/assets/icons/bullseye-arrow.svg",alt:"bullseye-arrow",width:34,height:34})}),w.jsx("p",{className:"mx-4 text-white text-sm text-center",children:"Select an element on the canvas to edit its properties."})]}),Dw=[re,Jn,Zn,Kn,Qn,ki,xr,We,Ue,ur,_r,br,wr,Sr,cn,ul,ll],Bw=({catalog:n})=>{const{planner:t}=Jt(),{scene:e,mode:r}=t;return Dw.includes(r)?e.layers.valueSeq().flatMap(s=>de().concat(s.lines,s.holes,s.areas,s.items).filter(o=>o.selected).map(o=>({element:o,layer:s}))).toArray().length===0?w.jsx(Vw,{}):w.jsx("div",{children:e.layers.valueSeq().map(s=>de().concat(s.lines,s.holes,s.areas,s.items).filter(o=>o.selected).map(o=>w.jsx(Og,{name:"Properties",opened:!0,children:w.jsx("div",{style:{padding:"5px 15px"},children:w.jsx(jw,{element:o,layer:s,catalog:n})})},o.id)).valueSeq())}):null},qw={MODE_IDLE:re,MODE_2D_ZOOM_IN:Jn,MODE_2D_ZOOM_OUT:Zn,MODE_2D_PAN:Kn,MODE_3D_VIEW:Qn,MODE_3D_FIRST_PERSON:ki,MODE_WAITING_DRAWING_LINE:xr,MODE_DRAWING_LINE:We,MODE_DRAWING_HOLE:Ue,MODE_DRAWING_ITEM:ur,MODE_DRAGGING_LINE:_r,MODE_DRAGGING_VERTEX:br,MODE_DRAGGING_ITEM:wr,MODE_DRAGGING_HOLE:Sr,MODE_FITTING_IMAGE:ll,MODE_UPLOADING_IMAGE:ul,MODE_ROTATING_ITEM:cn},$w={width:"100%"},Oa={width:"6em"},za={textAlign:"left"},Hw={marginLeft:"5px",border:"0px",background:"none",color:"#FFFFFF",fontSize:"14px",outline:"0px"},Gw={width:"100%",cursor:"pointer",maxHeight:"20em",marginLeft:"1px",marginTop:"1em"},Cg={width:"2em"},Ww=({groupID:n})=>{const{planner:t,setGroupAttributes:e,groupTranslate:r,groupRotate:i,removeFromGroup:s}=Jt(),{mode:o}=t;if(!n||!qw[o])return null;const a=t.getIn(["scene","groups",n]),l=a.get("elements");return w.jsx(Og,{name:`Group [${a.get("name")}]`,opened:!0,children:w.jsxs("div",{style:{padding:"5px 15px"},children:[w.jsx("table",{style:$w,children:w.jsxs("tbody",{children:[w.jsxs("tr",{children:[w.jsx("td",{style:Oa,children:"Name"}),w.jsx("td",{children:w.jsx(ro,{value:a.get("name"),onChange:c=>e(n,J({name:c.target.value})),style:za})})]}),w.jsxs("tr",{children:[w.jsx("td",{style:Oa,children:"X"}),w.jsx("td",{children:w.jsx(pn,{value:a.get("x"),onChange:c=>r(n,c.target.value,a.get("y")),style:za,precision:2})})]}),w.jsxs("tr",{children:[w.jsx("td",{style:Oa,children:"Y"}),w.jsx("td",{children:w.jsx(pn,{value:a.get("y"),onChange:c=>r(n,a.get("x"),c.target.value),style:za,precision:2})})]}),w.jsxs("tr",{children:[w.jsx("td",{style:Oa,children:"Rotation"}),w.jsx("td",{children:w.jsx(pn,{value:a.get("rotation"),onChange:c=>i(n,c.target.value),style:za,precision:2})})]})]})}),l.size?w.jsxs("div",{children:[w.jsx("p",{style:{textAlign:"center",borderBottom:"1px solid #555",paddingBottom:"1em"},children:"Group's Elements"}),w.jsxs("table",{style:Gw,children:[w.jsx("thead",{children:w.jsxs("tr",{children:[w.jsx("th",{style:Cg}),w.jsx("th",{children:"Layer"}),w.jsx("th",{children:"Prototype"}),w.jsx("th",{children:"Name"})]})}),w.jsx("tbody",{children:l.entrySeq().map(([c,h])=>h.entrySeq().map(([f,g])=>g.valueSeq().map(p=>{let m=t.getIn(["scene","layers",c,f,p]);return w.jsxs("tr",{children:[w.jsx("td",{style:Cg,title:"Un-chain Element from Group",children:w.jsx(P1,{onClick:()=>s(n,c,f,p),style:Hw})}),w.jsx("td",{style:{textAlign:"center"},children:c}),w.jsx("td",{style:{textAlign:"center",textTransform:"capitalize"},children:f}),w.jsx("td",{style:{textAlign:"center"},children:m.name})]},p)})))})]})]}):null]})})},Uw=({catalog:n})=>{const{planner:t}=Jt(),e=t.getIn(["scene","selectedLayer"]),r=t.getIn(["scene","layers",e,"selected"]),i=t.getIn(["scene","groups"]).findEntry(o=>o.get("selected")),s=r.lines.size>1||r.items.size>1||r.holes.size>1||r.areas.size>1||r.lines.size+r.items.size+r.holes.size+r.areas.size>1;return w.jsxs("aside",{onKeyDown:o=>o.stopPropagation(),onKeyUp:o=>o.stopPropagation(),className:"floor_planner-sidebar w-[300px] bg-[#424242] h-[calc(100%_-_20px)] block overflow-y-auto overflow-x-hidden pb-5",children:[!s&&w.jsx(Bw,{catalog:n}),!!i&&w.jsx(Ww,{groupID:i?i[0]:null})]})},gn=({active:n,tooltip:t,onClick:e,children:r,className:i})=>{const[s,o]=N.useState(!1),a=n||s?"text-[#1CA6FC]":"text-[#C2C2C2]";return w.jsxs("div",{className:zr("w-[30px] h-[30px] flex items-center justify-center text-[25px] relative cursor-pointer",i),onMouseOver:()=>o(!0),onMouseOut:()=>o(!1),children:[w.jsx("div",{className:a,onClick:e,children:r}),s&&w.jsxs("div",{className:"absolute w-[140px] text-white bg-black h-[30px] leading-[30px] text-center rounded-md opacity-80 left-full top-1/2 -mt-[15px] ml-[15px] z-[999] text-[12px]",children:[w.jsx("span",{className:"absolute top-1/2 right-full -mt-[8px] w-0 h-0 border-r-[8px] border-r-black border-t-[8px] border-t-transparent border-b-[8px] border-b-transparent"}),t]})]})},kg=()=>new Promise(async n=>{const t=document.getElementsByTagName("svg");if(!t.length)return;let e=t[0];for(let g=1;g<t.length;g++)t[g].width.baseVal.value>e.width.baseVal.value&&(e=t[g]);const r=e.cloneNode(!0),i=r.querySelectorAll("image");await Promise.all(Array.from(i).map(async g=>{const p=g.getAttribute("href")||g.getAttribute("xlink:href");if(p)try{const v=await(await fetch(p)).blob(),_=new FileReader;await new Promise(S=>{_.onloadend=()=>{g.setAttribute("href",_.result),S()},_.readAsDataURL(v)})}catch(m){console.warn("⚠️ Could not inline image:",p,m)}}));const o=new XMLSerializer().serializeToString(r),a=e.width.baseVal.value,l=e.height.baseVal.value,c=document.createElement("canvas");c.width=a,c.height=l;const h=c.getContext("2d");h.fillStyle="white",h.fillRect(0,0,a,l);const f=new Image;f.src=`data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(o)))}`,f.onload=()=>{h.drawImage(f,0,0,a,l),n(c.toDataURL("image/png"))}});function Ig(n){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M7 19a2 2 0 0 1 -2 -2"},child:[]},{tag:"path",attr:{d:"M5 13v-2"},child:[]},{tag:"path",attr:{d:"M5 7a2 2 0 0 1 2 -2"},child:[]},{tag:"path",attr:{d:"M11 5h2"},child:[]},{tag:"path",attr:{d:"M17 5a2 2 0 0 1 2 2"},child:[]},{tag:"path",attr:{d:"M19 11v2"},child:[]},{tag:"path",attr:{d:"M19 17v4"},child:[]},{tag:"path",attr:{d:"M21 19h-4"},child:[]},{tag:"path",attr:{d:"M13 19h-2"},child:[]}]})(n)}const Pg=n=>{let t=document.createElement("a"),e="output"+Date.now()+".png";e=window.prompt("Insert output filename",e),e&&(t.setAttribute("download",e),t.href=n,t.style.display="none",document.body.appendChild(t),t.click(),document.body.removeChild(t))};function Yw({mode:n}){const t=r=>{r.preventDefault();const i=document.getElementsByTagName("canvas")[0];Pg(i.toDataURL())},e=async r=>{r.preventDefault(),kg().then(Pg)};return[ki,Qn].includes(n)?w.jsx(gn,{active:!1,tooltip:"Get Screenshot",onClick:t,children:w.jsx(Ig,{size:28})}):[re,Jn,Zn,Kn,xr,_r,br,wr,We,Ue,ur,Sr,cn].includes(n)?w.jsx(gn,{active:!1,tooltip:"Get Screenshot",onClick:e,children:w.jsx(Ig,{size:28})}):null}function Xw(n){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"rect",attr:{width:"18",height:"18",x:"3",y:"3",rx:"2"},child:[]},{tag:"path",attr:{d:"M12 9v6"},child:[]},{tag:"path",attr:{d:"M16 15v6"},child:[]},{tag:"path",attr:{d:"M16 3v6"},child:[]},{tag:"path",attr:{d:"M3 15h18"},child:[]},{tag:"path",attr:{d:"M3 9h18"},child:[]},{tag:"path",attr:{d:"M8 15v6"},child:[]},{tag:"path",attr:{d:"M8 3v6"},child:[]}]})(n)}const Jw=/^.*$/;function Zw({onChange:n,...t}){const[e,r]=N.useState(""),i=N.useRef(null);N.useEffect(()=>{r(t.value)},[t.value]);const s=a=>{if(!a)return;const l=a.target.value;Jw.test(l)&&n&&n(a)},o=a=>{(!a.key||a.key==="Enter")&&s({target:{value:e}})};return w.jsxs("div",{className:"color-field flex-1 flex pr-3 mt-1 cursor-pointer",children:[w.jsx("div",{className:"colorBox relative w-[22px] h-[22px]",style:{background:t.value},onClick:()=>{i.current&&i.current.click()},children:w.jsx("input",{ref:i,type:"color",onChange:s,value:t.value,className:"absolute invisible h-full w-full"})}),w.jsx("div",{className:"flex-1 pl-2",children:w.jsx("input",{className:"colorFieldInput min-w-[90px] cursor-pointer",type:"text",value:e,onKeyDown:o,onChange:a=>r(a.target.value),onBlur:o})})]})}function Rg({value:n,onUpdate:t,configs:e,sourceElement:r,internalState:i}){const{planner:s}=Jt(),o=a=>e.hook?e.hook(a,r,i,s).then(l=>t(l)):t(a);return w.jsxs("div",{className:"PropertyColor w-full mb-2",children:[w.jsx(Tr,{children:e.label}),w.jsx(Zw,{value:n,onChange:a=>o(a.target.value)})]})}function Lg({value:n,onUpdate:t,configs:e,sourceElement:r,internalState:i}){const{planner:s}=Jt(),o=a=>e.hook?e.hook(a,r,i,s).then(l=>t(l)):t(a);return w.jsxs("div",{className:"PropertyEnum w-full mb-2",children:[w.jsx(Tr,{children:e.label}),w.jsx(pc,{value:n,onChange:a=>o(a.target.value),children:de(e.values).entrySeq().map(([a,l])=>w.jsx("option",{value:a,children:l},a))})]})}function Ng({value:n,onUpdate:t,configs:e,sourceElement:r,internalState:i}){const{planner:s}=Jt();let o=a=>e.hook?e.hook(a,r,i,s).then(l=>t(l)):t(a);return w.jsxs("div",{className:"PropertyString w-full mb-2",children:[w.jsx(Tr,{children:e.label}),w.jsx(ro,{value:n,onChange:a=>o(a.target.value)})]})}function Fg({value:n,onUpdate:t,onValid:e,configs:r,sourceElement:i,internalState:s}){const{planner:o}=Jt(),a=l=>{let c=parseFloat(l);return isNaN(c)&&(c=0),r.hook?r.hook(c,i,s,o).then(h=>t(h)):t(c)};return w.jsxs("div",{className:"PropertyNumber w-full mb-2",children:[w.jsx(Tr,{children:r.label}),w.jsx(pn,{value:n,onChange:l=>a(l.target.value),onValid:e,min:r.min,max:r.max})]})}function jg({value:n,onUpdate:t,onValid:e,configs:r,sourceElement:i,internalState:s}){const{planner:o}=Jt();let a=n.get("length")||0,l=n.get("_length")||a,c=n.get("_unit")||Wr,{hook:h,label:f,...g}=r;const p=(m,v)=>{let _=De(m),S=n.merge({length:v!==Wr?Cr(_).from(v).to(Wr):_,_length:m,_unit:v});return h?h(S,i,s,o).then(A=>t(A)):t(S)};return w.jsxs("div",{className:"PropertyLengthMeasure w-full mb-2",children:[w.jsx(Tr,{children:f}),w.jsxs("div",{className:"w-full flex",children:[w.jsx(pn,{value:l,onChange:m=>p(m.target.value,c),onValid:e,style:{borderTopRightRadius:0,borderBottomRightRadius:0,borderRightWidth:0},...g}),w.jsx("div",{className:"w-1/4 [&>*:first-child]:text-center",children:w.jsx(pc,{style:{borderTopLeftRadius:"0px",borderBottomLeftRadius:"0px"},value:c,onChange:m=>p(l,m.target.value),children:sd.map(m=>w.jsx("option",{value:m,children:m},m))})})]})]})}function Kw({type:n="button",size:t="normal",style:e,styleHover:r,children:i,...s}){const[o,a]=N.useState(!1),l="inline-block font-normal leading-[1.25] text-center whitespace-nowrap align-middle cursor-pointer select-none outline-none border border-solid w-full transition-colors duration-175 ease-linear rounded-[2px]",c=t==="small"?"text-[12px] px-2 py-[3px]":t==="large"?"px-5 py-2":"text-[14px] px-3 py-[5px]",h={backgroundColor:"#e6e6e6",borderColor:"#adadad"},f={backgroundColor:"#d4d4d4",borderColor:"#8c8c8c"};return w.jsx("button",{type:n,className:`${l} ${c}`,style:{...o?{...f,...r}:{...h,...e}},onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),...s,children:i})}const Ta={tableStyle:{width:"100%",borderSpacing:"2px 0",marginBottom:"2px"},firstTdStyle:{width:"6em",textTransform:"capitalize"}};function Vg({value:n,onUpdate:t,configs:e,sourceElement:r,internalState:i}){const{planner:s}=Jt(),o=a=>e.hook?e.hook(a,r,i,s).then(l=>t(l)):t(a);return w.jsx("table",{className:"PropertyToggle",style:Ta.tableStyle,children:w.jsx("tbody",{children:w.jsxs("tr",{children:[w.jsx("td",{style:Ta.firstTdStyle,children:w.jsx(Tr,{children:e.label})}),w.jsx("td",{children:w.jsx(Kw,{onClick:()=>o(!n),size:"small",children:e.actionName})})]})})})}function Dg({value:n,onUpdate:t,configs:e,sourceElement:r,internalState:i}){const{planner:s}=Jt(),o=a=>e.hook?e.hook(a,r,i,s).then(l=>t(l)):t(a);return w.jsxs("div",{className:"PropertyCheckbox w-full flex items-center gap-2 mb-2",children:[w.jsx("input",{className:"m-0 mt-0.5",type:"checkbox",checked:n,onChange:()=>o(!n)}),w.jsx(Tr,{className:"mb-0",children:e.label})]})}function Bg(){return null}function qg({value:n,configs:t}){return w.jsx("table",{className:"PropertyReadOnly",style:Ta.tableStyle,children:w.jsx("tbody",{children:w.jsxs("tr",{children:[w.jsx("td",{style:Ta.firstTdStyle,children:w.jsx(Tr,{children:t.label})}),w.jsx("td",{children:w.jsx("div",{children:n})})]})})})}/**
|
|
79
71
|
* @license
|
|
80
72
|
* Copyright 2010-2025 Three.js Authors
|
|
81
73
|
* SPDX-License-Identifier: MIT
|
|
82
|
-
*/const Zg="179",Rc=0,iS=1,sS=2,Kg=1,Qg=100,tm=204,em=205,rm=3,nm=0,im=300,yn=1e3,Xa=1001,sm=1002,oS=1006,aS=1008,uS=1009,lS=1015,cS=1023,hS=0,om="",Yr="srgb",am="srgb-linear",um="linear",Lc="srgb",fs=7680,lm=519,cm=35044,Ja=2e3,hm=2001;class Za{addEventListener(t,e){this._listeners===void 0&&(this._listeners={});const r=this._listeners;r[t]===void 0&&(r[t]=[]),r[t].indexOf(e)===-1&&r[t].push(e)}hasEventListener(t,e){const r=this._listeners;return r===void 0?!1:r[t]!==void 0&&r[t].indexOf(e)!==-1}removeEventListener(t,e){const r=this._listeners;if(r===void 0)return;const i=r[t];if(i!==void 0){const s=i.indexOf(e);s!==-1&&i.splice(s,1)}}dispatchEvent(t){const e=this._listeners;if(e===void 0)return;const r=e[t.type];if(r!==void 0){t.target=this;const i=r.slice(0);for(let s=0,o=i.length;s<o;s++)i[s].call(this,t);t.target=null}}}const Be=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];function ds(){const n=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(Be[n&255]+Be[n>>8&255]+Be[n>>16&255]+Be[n>>24&255]+"-"+Be[t&255]+Be[t>>8&255]+"-"+Be[t>>16&15|64]+Be[t>>24&255]+"-"+Be[e&63|128]+Be[e>>8&255]+"-"+Be[e>>16&255]+Be[e>>24&255]+Be[r&255]+Be[r>>8&255]+Be[r>>16&255]+Be[r>>24&255]).toLowerCase()}function Lt(n,t,e){return Math.max(t,Math.min(e,n))}function fS(n,t){return(n%t+t)%t}function Fc(n,t,e){return(1-e)*n+e*t}function So(n,t){switch(t.constructor){case Float32Array:return n;case Uint32Array:return n/4294967295;case Uint16Array:return n/65535;case Uint8Array:return n/255;case Int32Array:return Math.max(n/2147483647,-1);case Int16Array:return Math.max(n/32767,-1);case Int8Array:return Math.max(n/127,-1);default:throw new Error("Invalid component type.")}}function er(n,t){switch(t.constructor){case Float32Array:return n;case Uint32Array:return Math.round(n*4294967295);case Uint16Array:return Math.round(n*65535);case Uint8Array:return Math.round(n*255);case Int32Array:return Math.round(n*2147483647);case Int16Array:return Math.round(n*32767);case Int8Array:return Math.round(n*127);default:throw new Error("Invalid component type.")}}class Et{constructor(t=0,e=0){Et.prototype.isVector2=!0,this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,r=this.y,i=t.elements;return this.x=i[0]*e+i[3]*r+i[6],this.y=i[1]*e+i[4]*r+i[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Lt(this.x,t.x,e.x),this.y=Lt(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=Lt(this.x,t,e),this.y=Lt(this.y,t,e),this}clampLength(t,e){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Lt(r,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const r=this.dot(t)/e;return Math.acos(Lt(r,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,r=this.y-t.y;return e*e+r*r}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,r){return this.x=t.x+(e.x-t.x)*r,this.y=t.y+(e.y-t.y)*r,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const r=Math.cos(e),i=Math.sin(e),s=this.x-t.x,o=this.y-t.y;return this.x=s*r-o*i+t.x,this.y=s*i+o*r+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class ps{constructor(t=0,e=0,r=0,i=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=r,this._w=i}static slerpFlat(t,e,r,i,s,o,a){let l=r[i+0],c=r[i+1],h=r[i+2],f=r[i+3];const g=s[o+0],p=s[o+1],m=s[o+2],v=s[o+3];if(a===0){t[e+0]=l,t[e+1]=c,t[e+2]=h,t[e+3]=f;return}if(a===1){t[e+0]=g,t[e+1]=p,t[e+2]=m,t[e+3]=v;return}if(f!==v||l!==g||c!==p||h!==m){let _=1-a;const S=l*g+c*p+h*m+f*v,M=S>=0?1:-1,C=1-S*S;if(C>Number.EPSILON){const E=Math.sqrt(C),z=Math.atan2(E,S*M);_=Math.sin(_*z)/E,a=Math.sin(a*z)/E}const O=a*M;if(l=l*_+g*O,c=c*_+p*O,h=h*_+m*O,f=f*_+v*O,_===1-a){const E=1/Math.sqrt(l*l+c*c+h*h+f*f);l*=E,c*=E,h*=E,f*=E}}t[e]=l,t[e+1]=c,t[e+2]=h,t[e+3]=f}static multiplyQuaternionsFlat(t,e,r,i,s,o){const a=r[i],l=r[i+1],c=r[i+2],h=r[i+3],f=s[o],g=s[o+1],p=s[o+2],m=s[o+3];return t[e]=a*m+h*f+l*p-c*g,t[e+1]=l*m+h*g+c*f-a*p,t[e+2]=c*m+h*p+a*g-l*f,t[e+3]=h*m-a*f-l*g-c*p,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,r,i){return this._x=t,this._y=e,this._z=r,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){const r=t._x,i=t._y,s=t._z,o=t._order,a=Math.cos,l=Math.sin,c=a(r/2),h=a(i/2),f=a(s/2),g=l(r/2),p=l(i/2),m=l(s/2);switch(o){case"XYZ":this._x=g*h*f+c*p*m,this._y=c*p*f-g*h*m,this._z=c*h*m+g*p*f,this._w=c*h*f-g*p*m;break;case"YXZ":this._x=g*h*f+c*p*m,this._y=c*p*f-g*h*m,this._z=c*h*m-g*p*f,this._w=c*h*f+g*p*m;break;case"ZXY":this._x=g*h*f-c*p*m,this._y=c*p*f+g*h*m,this._z=c*h*m+g*p*f,this._w=c*h*f-g*p*m;break;case"ZYX":this._x=g*h*f-c*p*m,this._y=c*p*f+g*h*m,this._z=c*h*m-g*p*f,this._w=c*h*f+g*p*m;break;case"YZX":this._x=g*h*f+c*p*m,this._y=c*p*f+g*h*m,this._z=c*h*m-g*p*f,this._w=c*h*f-g*p*m;break;case"XZY":this._x=g*h*f-c*p*m,this._y=c*p*f-g*h*m,this._z=c*h*m+g*p*f,this._w=c*h*f+g*p*m;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const r=e/2,i=Math.sin(r);return this._x=t.x*i,this._y=t.y*i,this._z=t.z*i,this._w=Math.cos(r),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,r=e[0],i=e[4],s=e[8],o=e[1],a=e[5],l=e[9],c=e[2],h=e[6],f=e[10],g=r+a+f;if(g>0){const p=.5/Math.sqrt(g+1);this._w=.25/p,this._x=(h-l)*p,this._y=(s-c)*p,this._z=(o-i)*p}else if(r>a&&r>f){const p=2*Math.sqrt(1+r-a-f);this._w=(h-l)/p,this._x=.25*p,this._y=(i+o)/p,this._z=(s+c)/p}else if(a>f){const p=2*Math.sqrt(1+a-r-f);this._w=(s-c)/p,this._x=(i+o)/p,this._y=.25*p,this._z=(l+h)/p}else{const p=2*Math.sqrt(1+f-r-a);this._w=(o-i)/p,this._x=(s+c)/p,this._y=(l+h)/p,this._z=.25*p}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let r=t.dot(e)+1;return r<1e-8?(r=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=r):(this._x=0,this._y=-t.z,this._z=t.y,this._w=r)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=r),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(Lt(this.dot(t),-1,1)))}rotateTowards(t,e){const r=this.angleTo(t);if(r===0)return this;const i=Math.min(1,e/r);return this.slerp(t,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const r=t._x,i=t._y,s=t._z,o=t._w,a=e._x,l=e._y,c=e._z,h=e._w;return this._x=r*h+o*a+i*c-s*l,this._y=i*h+o*l+s*a-r*c,this._z=s*h+o*c+r*l-i*a,this._w=o*h-r*a-i*l-s*c,this._onChangeCallback(),this}slerp(t,e){if(e===0)return this;if(e===1)return this.copy(t);const r=this._x,i=this._y,s=this._z,o=this._w;let a=o*t._w+r*t._x+i*t._y+s*t._z;if(a<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,a=-a):this.copy(t),a>=1)return this._w=o,this._x=r,this._y=i,this._z=s,this;const l=1-a*a;if(l<=Number.EPSILON){const p=1-e;return this._w=p*o+e*this._w,this._x=p*r+e*this._x,this._y=p*i+e*this._y,this._z=p*s+e*this._z,this.normalize(),this}const c=Math.sqrt(l),h=Math.atan2(c,a),f=Math.sin((1-e)*h)/c,g=Math.sin(e*h)/c;return this._w=o*f+this._w*g,this._x=r*f+this._x*g,this._y=i*f+this._y*g,this._z=s*f+this._z*g,this._onChangeCallback(),this}slerpQuaternions(t,e,r){return this.copy(t).slerp(e,r)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),r=Math.random(),i=Math.sqrt(1-r),s=Math.sqrt(r);return this.set(i*Math.sin(t),i*Math.cos(t),s*Math.sin(e),s*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class D{constructor(t=0,e=0,r=0){D.prototype.isVector3=!0,this.x=t,this.y=e,this.z=r}set(t,e,r){return r===void 0&&(r=this.z),this.x=t,this.y=e,this.z=r,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(fm.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(fm.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,r=this.y,i=this.z,s=t.elements;return this.x=s[0]*e+s[3]*r+s[6]*i,this.y=s[1]*e+s[4]*r+s[7]*i,this.z=s[2]*e+s[5]*r+s[8]*i,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,r=this.y,i=this.z,s=t.elements,o=1/(s[3]*e+s[7]*r+s[11]*i+s[15]);return this.x=(s[0]*e+s[4]*r+s[8]*i+s[12])*o,this.y=(s[1]*e+s[5]*r+s[9]*i+s[13])*o,this.z=(s[2]*e+s[6]*r+s[10]*i+s[14])*o,this}applyQuaternion(t){const e=this.x,r=this.y,i=this.z,s=t.x,o=t.y,a=t.z,l=t.w,c=2*(o*i-a*r),h=2*(a*e-s*i),f=2*(s*r-o*e);return this.x=e+l*c+o*f-a*h,this.y=r+l*h+a*c-s*f,this.z=i+l*f+s*h-o*c,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,r=this.y,i=this.z,s=t.elements;return this.x=s[0]*e+s[4]*r+s[8]*i,this.y=s[1]*e+s[5]*r+s[9]*i,this.z=s[2]*e+s[6]*r+s[10]*i,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=Lt(this.x,t.x,e.x),this.y=Lt(this.y,t.y,e.y),this.z=Lt(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=Lt(this.x,t,e),this.y=Lt(this.y,t,e),this.z=Lt(this.z,t,e),this}clampLength(t,e){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Lt(r,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,r){return this.x=t.x+(e.x-t.x)*r,this.y=t.y+(e.y-t.y)*r,this.z=t.z+(e.z-t.z)*r,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const r=t.x,i=t.y,s=t.z,o=e.x,a=e.y,l=e.z;return this.x=i*l-s*a,this.y=s*o-r*l,this.z=r*a-i*o,this}projectOnVector(t){const e=t.lengthSq();if(e===0)return this.set(0,0,0);const r=t.dot(this)/e;return this.copy(t).multiplyScalar(r)}projectOnPlane(t){return Nc.copy(this).projectOnVector(t),this.sub(Nc)}reflect(t){return this.sub(Nc.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const r=this.dot(t)/e;return Math.acos(Lt(r,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,r=this.y-t.y,i=this.z-t.z;return e*e+r*r+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,r){const i=Math.sin(e)*t;return this.x=i*Math.sin(r),this.y=Math.cos(e)*t,this.z=i*Math.cos(r),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,r){return this.x=t*Math.sin(e),this.y=r,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),r=this.setFromMatrixColumn(t,1).length(),i=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=r,this.z=i,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,e=Math.random()*2-1,r=Math.sqrt(1-e*e);return this.x=r*Math.cos(t),this.y=e,this.z=r*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Nc=new D,fm=new ps;class Qn{constructor(t,e,r,i,s,o,a,l,c){Qn.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,r,i,s,o,a,l,c)}set(t,e,r,i,s,o,a,l,c){const h=this.elements;return h[0]=t,h[1]=i,h[2]=a,h[3]=e,h[4]=s,h[5]=l,h[6]=r,h[7]=o,h[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,r=t.elements;return e[0]=r[0],e[1]=r[1],e[2]=r[2],e[3]=r[3],e[4]=r[4],e[5]=r[5],e[6]=r[6],e[7]=r[7],e[8]=r[8],this}extractBasis(t,e,r){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),r.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const r=t.elements,i=e.elements,s=this.elements,o=r[0],a=r[3],l=r[6],c=r[1],h=r[4],f=r[7],g=r[2],p=r[5],m=r[8],v=i[0],_=i[3],S=i[6],M=i[1],C=i[4],O=i[7],E=i[2],z=i[5],R=i[8];return s[0]=o*v+a*M+l*E,s[3]=o*_+a*C+l*z,s[6]=o*S+a*O+l*R,s[1]=c*v+h*M+f*E,s[4]=c*_+h*C+f*z,s[7]=c*S+h*O+f*R,s[2]=g*v+p*M+m*E,s[5]=g*_+p*C+m*z,s[8]=g*S+p*O+m*R,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],r=t[1],i=t[2],s=t[3],o=t[4],a=t[5],l=t[6],c=t[7],h=t[8];return e*o*h-e*a*c-r*s*h+r*a*l+i*s*c-i*o*l}invert(){const t=this.elements,e=t[0],r=t[1],i=t[2],s=t[3],o=t[4],a=t[5],l=t[6],c=t[7],h=t[8],f=h*o-a*c,g=a*l-h*s,p=c*s-o*l,m=e*f+r*g+i*p;if(m===0)return this.set(0,0,0,0,0,0,0,0,0);const v=1/m;return t[0]=f*v,t[1]=(i*c-h*r)*v,t[2]=(a*r-i*o)*v,t[3]=g*v,t[4]=(h*e-i*l)*v,t[5]=(i*s-a*e)*v,t[6]=p*v,t[7]=(r*l-c*e)*v,t[8]=(o*e-r*s)*v,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,r,i,s,o,a){const l=Math.cos(s),c=Math.sin(s);return this.set(r*l,r*c,-r*(l*o+c*a)+o+t,-i*c,i*l,-i*(-c*o+l*a)+a+e,0,0,1),this}scale(t,e){return this.premultiply(jc.makeScale(t,e)),this}rotate(t){return this.premultiply(jc.makeRotation(-t)),this}translate(t,e){return this.premultiply(jc.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),r=Math.sin(t);return this.set(e,-r,0,r,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,r=t.elements;for(let i=0;i<9;i++)if(e[i]!==r[i])return!1;return!0}fromArray(t,e=0){for(let r=0;r<9;r++)this.elements[r]=t[r+e];return this}toArray(t=[],e=0){const r=this.elements;return t[e]=r[0],t[e+1]=r[1],t[e+2]=r[2],t[e+3]=r[3],t[e+4]=r[4],t[e+5]=r[5],t[e+6]=r[6],t[e+7]=r[7],t[e+8]=r[8],t}clone(){return new this.constructor().fromArray(this.elements)}}const jc=new Qn;function dS(n){for(let t=n.length-1;t>=0;--t)if(n[t]>=65535)return!0;return!1}function Vc(n){return document.createElementNS("http://www.w3.org/1999/xhtml",n)}const dm={};function pm(n){n in dm||(dm[n]=!0,console.warn(n))}const gm=new Qn().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),mm=new Qn().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function pS(){const n={enabled:!0,workingColorSpace:am,spaces:{},convert:function(i,s,o){return this.enabled===!1||s===o||!s||!o||(this.spaces[s].transfer===Lc&&(i.r=kn(i.r),i.g=kn(i.g),i.b=kn(i.b)),this.spaces[s].primaries!==this.spaces[o].primaries&&(i.applyMatrix3(this.spaces[s].toXYZ),i.applyMatrix3(this.spaces[o].fromXYZ)),this.spaces[o].transfer===Lc&&(i.r=gs(i.r),i.g=gs(i.g),i.b=gs(i.b))),i},workingToColorSpace:function(i,s){return this.convert(i,this.workingColorSpace,s)},colorSpaceToWorking:function(i,s){return this.convert(i,s,this.workingColorSpace)},getPrimaries:function(i){return this.spaces[i].primaries},getTransfer:function(i){return i===om?um:this.spaces[i].transfer},getLuminanceCoefficients:function(i,s=this.workingColorSpace){return i.fromArray(this.spaces[s].luminanceCoefficients)},define:function(i){Object.assign(this.spaces,i)},_getMatrix:function(i,s,o){return i.copy(this.spaces[s].toXYZ).multiply(this.spaces[o].fromXYZ)},_getDrawingBufferColorSpace:function(i){return this.spaces[i].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(i=this.workingColorSpace){return this.spaces[i].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(i,s){return pm("THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),n.workingToColorSpace(i,s)},toWorkingColorSpace:function(i,s){return pm("THREE.ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),n.colorSpaceToWorking(i,s)}},t=[.64,.33,.3,.6,.15,.06],e=[.2126,.7152,.0722],r=[.3127,.329];return n.define({[am]:{primaries:t,whitePoint:r,transfer:um,toXYZ:gm,fromXYZ:mm,luminanceCoefficients:e,workingColorSpaceConfig:{unpackColorSpace:Yr},outputColorSpaceConfig:{drawingBufferColorSpace:Yr}},[Yr]:{primaries:t,whitePoint:r,transfer:Lc,toXYZ:gm,fromXYZ:mm,luminanceCoefficients:e,outputColorSpaceConfig:{drawingBufferColorSpace:Yr}}}),n}const Xr=pS();function kn(n){return n<.04045?n*.0773993808:Math.pow(n*.9478672986+.0521327014,2.4)}function gs(n){return n<.0031308?n*12.92:1.055*Math.pow(n,.41666)-.055}let ms;class gS{static getDataURL(t,e="image/png"){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let r;if(t instanceof HTMLCanvasElement)r=t;else{ms===void 0&&(ms=Vc("canvas")),ms.width=t.width,ms.height=t.height;const i=ms.getContext("2d");t instanceof ImageData?i.putImageData(t,0,0):i.drawImage(t,0,0,t.width,t.height),r=ms}return r.toDataURL(e)}static sRGBToLinear(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap){const e=Vc("canvas");e.width=t.width,e.height=t.height;const r=e.getContext("2d");r.drawImage(t,0,0,t.width,t.height);const i=r.getImageData(0,0,t.width,t.height),s=i.data;for(let o=0;o<s.length;o++)s[o]=kn(s[o]/255)*255;return r.putImageData(i,0,0),e}else if(t.data){const e=t.data.slice(0);for(let r=0;r<e.length;r++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[r]=Math.floor(kn(e[r]/255)*255):e[r]=kn(e[r]);return{data:e,width:t.width,height:t.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}}let mS=0;class yS{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:mS++}),this.uuid=ds(),this.data=t,this.dataReady=!0,this.version=0}getSize(t){const e=this.data;return e instanceof HTMLVideoElement?t.set(e.videoWidth,e.videoHeight,0):e instanceof VideoFrame?t.set(e.displayHeight,e.displayWidth,0):e!==null?t.set(e.width,e.height,e.depth||0):t.set(0,0,0),t}set needsUpdate(t){t===!0&&this.version++}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.images[this.uuid]!==void 0)return t.images[this.uuid];const r={uuid:this.uuid,url:""},i=this.data;if(i!==null){let s;if(Array.isArray(i)){s=[];for(let o=0,a=i.length;o<a;o++)i[o].isDataTexture?s.push(Dc(i[o].image)):s.push(Dc(i[o]))}else s=Dc(i);r.url=s}return e||(t.images[this.uuid]=r),r}}function Dc(n){return typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&n instanceof ImageBitmap?gS.getDataURL(n):n.data?{data:Array.from(n.data),width:n.width,height:n.height,type:n.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let vS=0;const Bc=new D;class ti extends Za{constructor(t=ti.DEFAULT_IMAGE,e=ti.DEFAULT_MAPPING,r=Xa,i=Xa,s=oS,o=aS,a=cS,l=uS,c=ti.DEFAULT_ANISOTROPY,h=om){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:vS++}),this.uuid=ds(),this.name="",this.source=new yS(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=s,this.minFilter=o,this.anisotropy=c,this.format=a,this.internalFormat=null,this.type=l,this.offset=new Et(0,0),this.repeat=new Et(1,1),this.center=new Et(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Qn,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(t&&t.depth&&t.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(Bc).x}get height(){return this.source.getSize(Bc).y}get depth(){return this.source.getSize(Bc).z}get image(){return this.source.data}set image(t=null){this.source.data=t}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(t){return this.name=t.name,this.source=t.source,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.channel=t.channel,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.colorSpace=t.colorSpace,this.renderTarget=t.renderTarget,this.isRenderTargetTexture=t.isRenderTargetTexture,this.isArrayTexture=t.isArrayTexture,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}setValues(t){for(const e in t){const r=t[e];if(r===void 0){console.warn(`THREE.Texture.setValues(): parameter '${e}' has value of undefined.`);continue}const i=this[e];if(i===void 0){console.warn(`THREE.Texture.setValues(): property '${e}' does not exist.`);continue}i&&r&&i.isVector2&&r.isVector2||i&&r&&i.isVector3&&r.isVector3||i&&r&&i.isMatrix3&&r.isMatrix3?i.copy(r):this[e]=r}}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.textures[this.uuid]!==void 0)return t.textures[this.uuid];const r={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(t).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(r.userData=this.userData),e||(t.textures[this.uuid]=r),r}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==im)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case yn:t.x=t.x-Math.floor(t.x);break;case Xa:t.x=t.x<0?0:1;break;case sm:Math.abs(Math.floor(t.x)%2)===1?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x);break}if(t.y<0||t.y>1)switch(this.wrapT){case yn:t.y=t.y-Math.floor(t.y);break;case Xa:t.y=t.y<0?0:1;break;case sm:Math.abs(Math.floor(t.y)%2)===1?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y);break}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){t===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){t===!0&&this.pmremVersion++}}ti.DEFAULT_IMAGE=null,ti.DEFAULT_MAPPING=im,ti.DEFAULT_ANISOTROPY=1;class Eo{constructor(t=0,e=0,r=0,i=1){Eo.prototype.isVector4=!0,this.x=t,this.y=e,this.z=r,this.w=i}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,r,i){return this.x=t,this.y=e,this.z=r,this.w=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w!==void 0?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,r=this.y,i=this.z,s=this.w,o=t.elements;return this.x=o[0]*e+o[4]*r+o[8]*i+o[12]*s,this.y=o[1]*e+o[5]*r+o[9]*i+o[13]*s,this.z=o[2]*e+o[6]*r+o[10]*i+o[14]*s,this.w=o[3]*e+o[7]*r+o[11]*i+o[15]*s,this}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,r,i,s;const l=t.elements,c=l[0],h=l[4],f=l[8],g=l[1],p=l[5],m=l[9],v=l[2],_=l[6],S=l[10];if(Math.abs(h-g)<.01&&Math.abs(f-v)<.01&&Math.abs(m-_)<.01){if(Math.abs(h+g)<.1&&Math.abs(f+v)<.1&&Math.abs(m+_)<.1&&Math.abs(c+p+S-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;const C=(c+1)/2,O=(p+1)/2,E=(S+1)/2,z=(h+g)/4,R=(f+v)/4,k=(m+_)/4;return C>O&&C>E?C<.01?(r=0,i=.707106781,s=.707106781):(r=Math.sqrt(C),i=z/r,s=R/r):O>E?O<.01?(r=.707106781,i=0,s=.707106781):(i=Math.sqrt(O),r=z/i,s=k/i):E<.01?(r=.707106781,i=.707106781,s=0):(s=Math.sqrt(E),r=R/s,i=k/s),this.set(r,i,s,e),this}let M=Math.sqrt((_-m)*(_-m)+(f-v)*(f-v)+(g-h)*(g-h));return Math.abs(M)<.001&&(M=1),this.x=(_-m)/M,this.y=(f-v)/M,this.z=(g-h)/M,this.w=Math.acos((c+p+S-1)/2),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this.w=e[15],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=Lt(this.x,t.x,e.x),this.y=Lt(this.y,t.y,e.y),this.z=Lt(this.z,t.z,e.z),this.w=Lt(this.w,t.w,e.w),this}clampScalar(t,e){return this.x=Lt(this.x,t,e),this.y=Lt(this.y,t,e),this.z=Lt(this.z,t,e),this.w=Lt(this.w,t,e),this}clampLength(t,e){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Lt(r,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,r){return this.x=t.x+(e.x-t.x)*r,this.y=t.y+(e.y-t.y)*r,this.z=t.z+(e.z-t.z)*r,this.w=t.w+(e.w-t.w)*r,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class ys{constructor(t=new D(1/0,1/0,1/0),e=new D(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,r=t.length;e<r;e+=3)this.expandByPoint(Jr.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,r=t.count;e<r;e++)this.expandByPoint(Jr.fromBufferAttribute(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,r=t.length;e<r;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const r=Jr.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(r),this.max.copy(t).add(r),this}setFromObject(t,e=!1){return this.makeEmpty(),this.expandByObject(t,e)}clone(){return new this.constructor().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}expandByObject(t,e=!1){t.updateWorldMatrix(!1,!1);const r=t.geometry;if(r!==void 0){const s=r.getAttribute("position");if(e===!0&&s!==void 0&&t.isInstancedMesh!==!0)for(let o=0,a=s.count;o<a;o++)t.isMesh===!0?t.getVertexPosition(o,Jr):Jr.fromBufferAttribute(s,o),Jr.applyMatrix4(t.matrixWorld),this.expandByPoint(Jr);else t.boundingBox!==void 0?(t.boundingBox===null&&t.computeBoundingBox(),Ka.copy(t.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),Ka.copy(r.boundingBox)),Ka.applyMatrix4(t.matrixWorld),this.union(Ka)}const i=t.children;for(let s=0,o=i.length;s<o;s++)this.expandByObject(i[s],e);return this}containsPoint(t){return t.x>=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y&&t.z>=this.min.z&&t.z<=this.max.z}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y&&t.max.z>=this.min.z&&t.min.z<=this.max.z}intersectsSphere(t){return this.clampPoint(t.center,Jr),Jr.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,r;return t.normal.x>0?(e=t.normal.x*this.min.x,r=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,r=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,r+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,r+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,r+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,r+=t.normal.z*this.min.z),e<=-t.constant&&r>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(Mo),Qa.subVectors(this.max,Mo),vs.subVectors(t.a,Mo),xs.subVectors(t.b,Mo),_s.subVectors(t.c,Mo),ei.subVectors(xs,vs),ri.subVectors(_s,xs),Si.subVectors(vs,_s);let e=[0,-ei.z,ei.y,0,-ri.z,ri.y,0,-Si.z,Si.y,ei.z,0,-ei.x,ri.z,0,-ri.x,Si.z,0,-Si.x,-ei.y,ei.x,0,-ri.y,ri.x,0,-Si.y,Si.x,0];return!qc(e,vs,xs,_s,Qa)||(e=[1,0,0,0,1,0,0,0,1],!qc(e,vs,xs,_s,Qa))?!1:(tu.crossVectors(ei,ri),e=[tu.x,tu.y,tu.z],qc(e,vs,xs,_s,Qa))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Jr).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(Jr).length()*.5),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()?this:(Pn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Pn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Pn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Pn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Pn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Pn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Pn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Pn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Pn),this)}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(t){return this.min.fromArray(t.min),this.max.fromArray(t.max),this}}const Pn=[new D,new D,new D,new D,new D,new D,new D,new D],Jr=new D,Ka=new ys,vs=new D,xs=new D,_s=new D,ei=new D,ri=new D,Si=new D,Mo=new D,Qa=new D,tu=new D,Ei=new D;function qc(n,t,e,r,i){for(let s=0,o=n.length-3;s<=o;s+=3){Ei.fromArray(n,s);const a=i.x*Math.abs(Ei.x)+i.y*Math.abs(Ei.y)+i.z*Math.abs(Ei.z),l=t.dot(Ei),c=e.dot(Ei),h=r.dot(Ei);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>a)return!1}return!0}const xS=new ys,Ao=new D,$c=new D;class ym{constructor(t=new D,e=-1){this.isSphere=!0,this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){const r=this.center;e!==void 0?r.copy(e):xS.setFromPoints(t).getCenter(r);let i=0;for(let s=0,o=t.length;s<o;s++)i=Math.max(i,r.distanceToSquared(t[s]));return this.radius=Math.sqrt(i),this}copy(t){return this.center.copy(t.center),this.radius=t.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(t){return t.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(t){return t.distanceTo(this.center)-this.radius}intersectsSphere(t){const e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e}intersectsBox(t){return t.intersectsSphere(this)}intersectsPlane(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius}clampPoint(t,e){const r=this.center.distanceToSquared(t);return e.copy(t),r>this.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;Ao.subVectors(t,this.center);const e=Ao.lengthSq();if(e>this.radius*this.radius){const r=Math.sqrt(e),i=(r-this.radius)*.5;this.center.addScaledVector(Ao,i/r),this.radius+=i}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(this.center.equals(t.center)===!0?this.radius=Math.max(this.radius,t.radius):($c.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(Ao.copy(t.center).add($c)),this.expandByPoint(Ao.copy(t.center).sub($c))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(t){return this.radius=t.radius,this.center.fromArray(t.center),this}}const Rn=new D,Hc=new D,eu=new D,ni=new D,Gc=new D,ru=new D,Wc=new D;class _S{constructor(t=new D,e=new D(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.copy(this.origin).addScaledVector(this.direction,t)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,Rn)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);const r=e.dot(this.direction);return r<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,r)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const e=Rn.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(Rn.copy(this.origin).addScaledVector(this.direction,e),Rn.distanceToSquared(t))}distanceSqToSegment(t,e,r,i){Hc.copy(t).add(e).multiplyScalar(.5),eu.copy(e).sub(t).normalize(),ni.copy(this.origin).sub(Hc);const s=t.distanceTo(e)*.5,o=-this.direction.dot(eu),a=ni.dot(this.direction),l=-ni.dot(eu),c=ni.lengthSq(),h=Math.abs(1-o*o);let f,g,p,m;if(h>0)if(f=o*l-a,g=o*a-l,m=s*h,f>=0)if(g>=-m)if(g<=m){const v=1/h;f*=v,g*=v,p=f*(f+o*g+2*a)+g*(o*f+g+2*l)+c}else g=s,f=Math.max(0,-(o*g+a)),p=-f*f+g*(g+2*l)+c;else g=-s,f=Math.max(0,-(o*g+a)),p=-f*f+g*(g+2*l)+c;else g<=-m?(f=Math.max(0,-(-o*s+a)),g=f>0?-s:Math.min(Math.max(-s,-l),s),p=-f*f+g*(g+2*l)+c):g<=m?(f=0,g=Math.min(Math.max(-s,-l),s),p=g*(g+2*l)+c):(f=Math.max(0,-(o*s+a)),g=f>0?s:Math.min(Math.max(-s,-l),s),p=-f*f+g*(g+2*l)+c);else g=o>0?-s:s,f=Math.max(0,-(o*g+a)),p=-f*f+g*(g+2*l)+c;return r&&r.copy(this.origin).addScaledVector(this.direction,f),i&&i.copy(Hc).addScaledVector(eu,g),p}intersectSphere(t,e){Rn.subVectors(t.center,this.origin);const r=Rn.dot(this.direction),i=Rn.dot(Rn)-r*r,s=t.radius*t.radius;if(i>s)return null;const o=Math.sqrt(s-i),a=r-o,l=r+o;return l<0?null:a<0?this.at(l,e):this.at(a,e)}intersectsSphere(t){return t.radius<0?!1:this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(e===0)return t.distanceToPoint(this.origin)===0?0:null;const r=-(this.origin.dot(t.normal)+t.constant)/e;return r>=0?r:null}intersectPlane(t,e){const r=this.distanceToPlane(t);return r===null?null:this.at(r,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);return e===0||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let r,i,s,o,a,l;const c=1/this.direction.x,h=1/this.direction.y,f=1/this.direction.z,g=this.origin;return c>=0?(r=(t.min.x-g.x)*c,i=(t.max.x-g.x)*c):(r=(t.max.x-g.x)*c,i=(t.min.x-g.x)*c),h>=0?(s=(t.min.y-g.y)*h,o=(t.max.y-g.y)*h):(s=(t.max.y-g.y)*h,o=(t.min.y-g.y)*h),r>o||s>i||((s>r||isNaN(r))&&(r=s),(o<i||isNaN(i))&&(i=o),f>=0?(a=(t.min.z-g.z)*f,l=(t.max.z-g.z)*f):(a=(t.max.z-g.z)*f,l=(t.min.z-g.z)*f),r>l||a>i)||((a>r||r!==r)&&(r=a),(l<i||i!==i)&&(i=l),i<0)?null:this.at(r>=0?r:i,e)}intersectsBox(t){return this.intersectBox(t,Rn)!==null}intersectTriangle(t,e,r,i,s){Gc.subVectors(e,t),ru.subVectors(r,t),Wc.crossVectors(Gc,ru);let o=this.direction.dot(Wc),a;if(o>0){if(i)return null;a=1}else if(o<0)a=-1,o=-o;else return null;ni.subVectors(this.origin,t);const l=a*this.direction.dot(ru.crossVectors(ni,ru));if(l<0)return null;const c=a*this.direction.dot(Gc.cross(ni));if(c<0||l+c>o)return null;const h=-a*ni.dot(Wc);return h<0?null:this.at(h/o,s)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class Ue{constructor(t,e,r,i,s,o,a,l,c,h,f,g,p,m,v,_){Ue.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,e,r,i,s,o,a,l,c,h,f,g,p,m,v,_)}set(t,e,r,i,s,o,a,l,c,h,f,g,p,m,v,_){const S=this.elements;return S[0]=t,S[4]=e,S[8]=r,S[12]=i,S[1]=s,S[5]=o,S[9]=a,S[13]=l,S[2]=c,S[6]=h,S[10]=f,S[14]=g,S[3]=p,S[7]=m,S[11]=v,S[15]=_,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new Ue().fromArray(this.elements)}copy(t){const e=this.elements,r=t.elements;return e[0]=r[0],e[1]=r[1],e[2]=r[2],e[3]=r[3],e[4]=r[4],e[5]=r[5],e[6]=r[6],e[7]=r[7],e[8]=r[8],e[9]=r[9],e[10]=r[10],e[11]=r[11],e[12]=r[12],e[13]=r[13],e[14]=r[14],e[15]=r[15],this}copyPosition(t){const e=this.elements,r=t.elements;return e[12]=r[12],e[13]=r[13],e[14]=r[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,r){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),r.setFromMatrixColumn(this,2),this}makeBasis(t,e,r){return this.set(t.x,e.x,r.x,0,t.y,e.y,r.y,0,t.z,e.z,r.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,r=t.elements,i=1/bs.setFromMatrixColumn(t,0).length(),s=1/bs.setFromMatrixColumn(t,1).length(),o=1/bs.setFromMatrixColumn(t,2).length();return e[0]=r[0]*i,e[1]=r[1]*i,e[2]=r[2]*i,e[3]=0,e[4]=r[4]*s,e[5]=r[5]*s,e[6]=r[6]*s,e[7]=0,e[8]=r[8]*o,e[9]=r[9]*o,e[10]=r[10]*o,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,r=t.x,i=t.y,s=t.z,o=Math.cos(r),a=Math.sin(r),l=Math.cos(i),c=Math.sin(i),h=Math.cos(s),f=Math.sin(s);if(t.order==="XYZ"){const g=o*h,p=o*f,m=a*h,v=a*f;e[0]=l*h,e[4]=-l*f,e[8]=c,e[1]=p+m*c,e[5]=g-v*c,e[9]=-a*l,e[2]=v-g*c,e[6]=m+p*c,e[10]=o*l}else if(t.order==="YXZ"){const g=l*h,p=l*f,m=c*h,v=c*f;e[0]=g+v*a,e[4]=m*a-p,e[8]=o*c,e[1]=o*f,e[5]=o*h,e[9]=-a,e[2]=p*a-m,e[6]=v+g*a,e[10]=o*l}else if(t.order==="ZXY"){const g=l*h,p=l*f,m=c*h,v=c*f;e[0]=g-v*a,e[4]=-o*f,e[8]=m+p*a,e[1]=p+m*a,e[5]=o*h,e[9]=v-g*a,e[2]=-o*c,e[6]=a,e[10]=o*l}else if(t.order==="ZYX"){const g=o*h,p=o*f,m=a*h,v=a*f;e[0]=l*h,e[4]=m*c-p,e[8]=g*c+v,e[1]=l*f,e[5]=v*c+g,e[9]=p*c-m,e[2]=-c,e[6]=a*l,e[10]=o*l}else if(t.order==="YZX"){const g=o*l,p=o*c,m=a*l,v=a*c;e[0]=l*h,e[4]=v-g*f,e[8]=m*f+p,e[1]=f,e[5]=o*h,e[9]=-a*h,e[2]=-c*h,e[6]=p*f+m,e[10]=g-v*f}else if(t.order==="XZY"){const g=o*l,p=o*c,m=a*l,v=a*c;e[0]=l*h,e[4]=-f,e[8]=c*h,e[1]=g*f+v,e[5]=o*h,e[9]=p*f-m,e[2]=m*f-p,e[6]=a*h,e[10]=v*f+g}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(bS,t,wS)}lookAt(t,e,r){const i=this.elements;return hr.subVectors(t,e),hr.lengthSq()===0&&(hr.z=1),hr.normalize(),ii.crossVectors(r,hr),ii.lengthSq()===0&&(Math.abs(r.z)===1?hr.x+=1e-4:hr.z+=1e-4,hr.normalize(),ii.crossVectors(r,hr)),ii.normalize(),nu.crossVectors(hr,ii),i[0]=ii.x,i[4]=nu.x,i[8]=hr.x,i[1]=ii.y,i[5]=nu.y,i[9]=hr.y,i[2]=ii.z,i[6]=nu.z,i[10]=hr.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const r=t.elements,i=e.elements,s=this.elements,o=r[0],a=r[4],l=r[8],c=r[12],h=r[1],f=r[5],g=r[9],p=r[13],m=r[2],v=r[6],_=r[10],S=r[14],M=r[3],C=r[7],O=r[11],E=r[15],z=i[0],R=i[4],k=i[8],L=i[12],X=i[1],J=i[5],at=i[9],tt=i[13],bt=i[2],xt=i[6],yt=i[10],ht=i[14],Y=i[3],St=i[7],j=i[11],W=i[15];return s[0]=o*z+a*X+l*bt+c*Y,s[4]=o*R+a*J+l*xt+c*St,s[8]=o*k+a*at+l*yt+c*j,s[12]=o*L+a*tt+l*ht+c*W,s[1]=h*z+f*X+g*bt+p*Y,s[5]=h*R+f*J+g*xt+p*St,s[9]=h*k+f*at+g*yt+p*j,s[13]=h*L+f*tt+g*ht+p*W,s[2]=m*z+v*X+_*bt+S*Y,s[6]=m*R+v*J+_*xt+S*St,s[10]=m*k+v*at+_*yt+S*j,s[14]=m*L+v*tt+_*ht+S*W,s[3]=M*z+C*X+O*bt+E*Y,s[7]=M*R+C*J+O*xt+E*St,s[11]=M*k+C*at+O*yt+E*j,s[15]=M*L+C*tt+O*ht+E*W,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],r=t[4],i=t[8],s=t[12],o=t[1],a=t[5],l=t[9],c=t[13],h=t[2],f=t[6],g=t[10],p=t[14],m=t[3],v=t[7],_=t[11],S=t[15];return m*(+s*l*f-i*c*f-s*a*g+r*c*g+i*a*p-r*l*p)+v*(+e*l*p-e*c*g+s*o*g-i*o*p+i*c*h-s*l*h)+_*(+e*c*f-e*a*p-s*o*f+r*o*p+s*a*h-r*c*h)+S*(-i*a*h-e*l*f+e*a*g+i*o*f-r*o*g+r*l*h)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,r){const i=this.elements;return t.isVector3?(i[12]=t.x,i[13]=t.y,i[14]=t.z):(i[12]=t,i[13]=e,i[14]=r),this}invert(){const t=this.elements,e=t[0],r=t[1],i=t[2],s=t[3],o=t[4],a=t[5],l=t[6],c=t[7],h=t[8],f=t[9],g=t[10],p=t[11],m=t[12],v=t[13],_=t[14],S=t[15],M=f*_*c-v*g*c+v*l*p-a*_*p-f*l*S+a*g*S,C=m*g*c-h*_*c-m*l*p+o*_*p+h*l*S-o*g*S,O=h*v*c-m*f*c+m*a*p-o*v*p-h*a*S+o*f*S,E=m*f*l-h*v*l-m*a*g+o*v*g+h*a*_-o*f*_,z=e*M+r*C+i*O+s*E;if(z===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const R=1/z;return t[0]=M*R,t[1]=(v*g*s-f*_*s-v*i*p+r*_*p+f*i*S-r*g*S)*R,t[2]=(a*_*s-v*l*s+v*i*c-r*_*c-a*i*S+r*l*S)*R,t[3]=(f*l*s-a*g*s-f*i*c+r*g*c+a*i*p-r*l*p)*R,t[4]=C*R,t[5]=(h*_*s-m*g*s+m*i*p-e*_*p-h*i*S+e*g*S)*R,t[6]=(m*l*s-o*_*s-m*i*c+e*_*c+o*i*S-e*l*S)*R,t[7]=(o*g*s-h*l*s+h*i*c-e*g*c-o*i*p+e*l*p)*R,t[8]=O*R,t[9]=(m*f*s-h*v*s-m*r*p+e*v*p+h*r*S-e*f*S)*R,t[10]=(o*v*s-m*a*s+m*r*c-e*v*c-o*r*S+e*a*S)*R,t[11]=(h*a*s-o*f*s-h*r*c+e*f*c+o*r*p-e*a*p)*R,t[12]=E*R,t[13]=(h*v*i-m*f*i+m*r*g-e*v*g-h*r*_+e*f*_)*R,t[14]=(m*a*i-o*v*i-m*r*l+e*v*l+o*r*_-e*a*_)*R,t[15]=(o*f*i-h*a*i+h*r*l-e*f*l-o*r*g+e*a*g)*R,this}scale(t){const e=this.elements,r=t.x,i=t.y,s=t.z;return e[0]*=r,e[4]*=i,e[8]*=s,e[1]*=r,e[5]*=i,e[9]*=s,e[2]*=r,e[6]*=i,e[10]*=s,e[3]*=r,e[7]*=i,e[11]*=s,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],r=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],i=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,r,i))}makeTranslation(t,e,r){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,r,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),r=Math.sin(t);return this.set(1,0,0,0,0,e,-r,0,0,r,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),r=Math.sin(t);return this.set(e,0,r,0,0,1,0,0,-r,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),r=Math.sin(t);return this.set(e,-r,0,0,r,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const r=Math.cos(e),i=Math.sin(e),s=1-r,o=t.x,a=t.y,l=t.z,c=s*o,h=s*a;return this.set(c*o+r,c*a-i*l,c*l+i*a,0,c*a+i*l,h*a+r,h*l-i*o,0,c*l-i*a,h*l+i*o,s*l*l+r,0,0,0,0,1),this}makeScale(t,e,r){return this.set(t,0,0,0,0,e,0,0,0,0,r,0,0,0,0,1),this}makeShear(t,e,r,i,s,o){return this.set(1,r,s,0,t,1,o,0,e,i,1,0,0,0,0,1),this}compose(t,e,r){const i=this.elements,s=e._x,o=e._y,a=e._z,l=e._w,c=s+s,h=o+o,f=a+a,g=s*c,p=s*h,m=s*f,v=o*h,_=o*f,S=a*f,M=l*c,C=l*h,O=l*f,E=r.x,z=r.y,R=r.z;return i[0]=(1-(v+S))*E,i[1]=(p+O)*E,i[2]=(m-C)*E,i[3]=0,i[4]=(p-O)*z,i[5]=(1-(g+S))*z,i[6]=(_+M)*z,i[7]=0,i[8]=(m+C)*R,i[9]=(_-M)*R,i[10]=(1-(g+v))*R,i[11]=0,i[12]=t.x,i[13]=t.y,i[14]=t.z,i[15]=1,this}decompose(t,e,r){const i=this.elements;let s=bs.set(i[0],i[1],i[2]).length();const o=bs.set(i[4],i[5],i[6]).length(),a=bs.set(i[8],i[9],i[10]).length();this.determinant()<0&&(s=-s),t.x=i[12],t.y=i[13],t.z=i[14],Zr.copy(this);const c=1/s,h=1/o,f=1/a;return Zr.elements[0]*=c,Zr.elements[1]*=c,Zr.elements[2]*=c,Zr.elements[4]*=h,Zr.elements[5]*=h,Zr.elements[6]*=h,Zr.elements[8]*=f,Zr.elements[9]*=f,Zr.elements[10]*=f,e.setFromRotationMatrix(Zr),r.x=s,r.y=o,r.z=a,this}makePerspective(t,e,r,i,s,o,a=Ja,l=!1){const c=this.elements,h=2*s/(e-t),f=2*s/(r-i),g=(e+t)/(e-t),p=(r+i)/(r-i);let m,v;if(l)m=s/(o-s),v=o*s/(o-s);else if(a===Ja)m=-(o+s)/(o-s),v=-2*o*s/(o-s);else if(a===hm)m=-o/(o-s),v=-o*s/(o-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return c[0]=h,c[4]=0,c[8]=g,c[12]=0,c[1]=0,c[5]=f,c[9]=p,c[13]=0,c[2]=0,c[6]=0,c[10]=m,c[14]=v,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(t,e,r,i,s,o,a=Ja,l=!1){const c=this.elements,h=2/(e-t),f=2/(r-i),g=-(e+t)/(e-t),p=-(r+i)/(r-i);let m,v;if(l)m=1/(o-s),v=o/(o-s);else if(a===Ja)m=-2/(o-s),v=-(o+s)/(o-s);else if(a===hm)m=-1/(o-s),v=-s/(o-s);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return c[0]=h,c[4]=0,c[8]=0,c[12]=g,c[1]=0,c[5]=f,c[9]=0,c[13]=p,c[2]=0,c[6]=0,c[10]=m,c[14]=v,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(t){const e=this.elements,r=t.elements;for(let i=0;i<16;i++)if(e[i]!==r[i])return!1;return!0}fromArray(t,e=0){for(let r=0;r<16;r++)this.elements[r]=t[r+e];return this}toArray(t=[],e=0){const r=this.elements;return t[e]=r[0],t[e+1]=r[1],t[e+2]=r[2],t[e+3]=r[3],t[e+4]=r[4],t[e+5]=r[5],t[e+6]=r[6],t[e+7]=r[7],t[e+8]=r[8],t[e+9]=r[9],t[e+10]=r[10],t[e+11]=r[11],t[e+12]=r[12],t[e+13]=r[13],t[e+14]=r[14],t[e+15]=r[15],t}}const bs=new D,Zr=new Ue,bS=new D(0,0,0),wS=new D(1,1,1),ii=new D,nu=new D,hr=new D,vm=new Ue,xm=new ps;class ws{constructor(t=0,e=0,r=0,i=ws.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=r,this._order=i}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,r,i=this._order){return this._x=t,this._y=e,this._z=r,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,r=!0){const i=t.elements,s=i[0],o=i[4],a=i[8],l=i[1],c=i[5],h=i[9],f=i[2],g=i[6],p=i[10];switch(e){case"XYZ":this._y=Math.asin(Lt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-h,p),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(g,c),this._z=0);break;case"YXZ":this._x=Math.asin(-Lt(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(a,p),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-f,s),this._z=0);break;case"ZXY":this._x=Math.asin(Lt(g,-1,1)),Math.abs(g)<.9999999?(this._y=Math.atan2(-f,p),this._z=Math.atan2(-o,c)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-Lt(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(g,p),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-o,c));break;case"YZX":this._z=Math.asin(Lt(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-h,c),this._y=Math.atan2(-f,s)):(this._x=0,this._y=Math.atan2(a,p));break;case"XZY":this._z=Math.asin(-Lt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(g,c),this._y=Math.atan2(a,s)):(this._x=Math.atan2(-h,p),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,r===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,r){return vm.makeRotationFromQuaternion(t),this.setFromRotationMatrix(vm,e,r)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return xm.setFromEuler(this),this.setFromQuaternion(xm,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}ws.DEFAULT_ORDER="XYZ";class SS{constructor(){this.mask=1}set(t){this.mask=(1<<t|0)>>>0}enable(t){this.mask|=1<<t|0}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t|0}disable(t){this.mask&=~(1<<t|0)}disableAll(){this.mask=0}test(t){return(this.mask&t.mask)!==0}isEnabled(t){return(this.mask&(1<<t|0))!==0}}let ES=0;const _m=new D,Ss=new ps,Ln=new Ue,iu=new D,Oo=new D,MS=new D,AS=new ps,bm=new D(1,0,0),wm=new D(0,1,0),Sm=new D(0,0,1),Em={type:"added"},OS={type:"removed"},Es={type:"childadded",child:null},Uc={type:"childremoved",child:null};class vn extends Za{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:ES++}),this.uuid=ds(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=vn.DEFAULT_UP.clone();const t=new D,e=new ws,r=new ps,i=new D(1,1,1);function s(){r.setFromEuler(e,!1)}function o(){e.setFromQuaternion(r,void 0,!1)}e._onChange(s),r._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Ue},normalMatrix:{value:new Qn}}),this.matrix=new Ue,this.matrixWorld=new Ue,this.matrixAutoUpdate=vn.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=vn.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new SS,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(t){return this.quaternion.premultiply(t),this}setRotationFromAxisAngle(t,e){this.quaternion.setFromAxisAngle(t,e)}setRotationFromEuler(t){this.quaternion.setFromEuler(t,!0)}setRotationFromMatrix(t){this.quaternion.setFromRotationMatrix(t)}setRotationFromQuaternion(t){this.quaternion.copy(t)}rotateOnAxis(t,e){return Ss.setFromAxisAngle(t,e),this.quaternion.multiply(Ss),this}rotateOnWorldAxis(t,e){return Ss.setFromAxisAngle(t,e),this.quaternion.premultiply(Ss),this}rotateX(t){return this.rotateOnAxis(bm,t)}rotateY(t){return this.rotateOnAxis(wm,t)}rotateZ(t){return this.rotateOnAxis(Sm,t)}translateOnAxis(t,e){return _m.copy(t).applyQuaternion(this.quaternion),this.position.add(_m.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(bm,t)}translateY(t){return this.translateOnAxis(wm,t)}translateZ(t){return this.translateOnAxis(Sm,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(Ln.copy(this.matrixWorld).invert())}lookAt(t,e,r){t.isVector3?iu.copy(t):iu.set(t,e,r);const i=this.parent;this.updateWorldMatrix(!0,!1),Oo.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Ln.lookAt(Oo,iu,this.up):Ln.lookAt(iu,Oo,this.up),this.quaternion.setFromRotationMatrix(Ln),i&&(Ln.extractRotation(i.matrixWorld),Ss.setFromRotationMatrix(Ln),this.quaternion.premultiply(Ss.invert()))}add(t){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return t===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(t.removeFromParent(),t.parent=this,this.children.push(t),t.dispatchEvent(Em),Es.child=t,this.dispatchEvent(Es),Es.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let r=0;r<arguments.length;r++)this.remove(arguments[r]);return this}const e=this.children.indexOf(t);return e!==-1&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(OS),Uc.child=t,this.dispatchEvent(Uc),Uc.child=null),this}removeFromParent(){const t=this.parent;return t!==null&&t.remove(this),this}clear(){return this.remove(...this.children)}attach(t){return this.updateWorldMatrix(!0,!1),Ln.copy(this.matrixWorld).invert(),t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),Ln.multiply(t.parent.matrixWorld)),t.applyMatrix4(Ln),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(Em),Es.child=t,this.dispatchEvent(Es),Es.child=null,this}getObjectById(t){return this.getObjectByProperty("id",t)}getObjectByName(t){return this.getObjectByProperty("name",t)}getObjectByProperty(t,e){if(this[t]===e)return this;for(let r=0,i=this.children.length;r<i;r++){const o=this.children[r].getObjectByProperty(t,e);if(o!==void 0)return o}}getObjectsByProperty(t,e,r=[]){this[t]===e&&r.push(this);const i=this.children;for(let s=0,o=i.length;s<o;s++)i[s].getObjectsByProperty(t,e,r);return r}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Oo,t,MS),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Oo,AS,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);const e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}traverse(t){t(this);const e=this.children;for(let r=0,i=e.length;r<i;r++)e[r].traverse(t)}traverseVisible(t){if(this.visible===!1)return;t(this);const e=this.children;for(let r=0,i=e.length;r<i;r++)e[r].traverseVisible(t)}traverseAncestors(t){const e=this.parent;e!==null&&(t(e),e.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);const e=this.children;for(let r=0,i=e.length;r<i;r++)e[r].updateMatrixWorld(t)}updateWorldMatrix(t,e){const r=this.parent;if(t===!0&&r!==null&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),e===!0){const i=this.children;for(let s=0,o=i.length;s<o;s++)i[s].updateWorldMatrix(!1,!0)}}toJSON(t){const e=t===void 0||typeof t=="string",r={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},r.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map(a=>({...a,boundingBox:a.boundingBox?a.boundingBox.toJSON():void 0,boundingSphere:a.boundingSphere?a.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map(a=>({...a})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(t),i.indirectTexture=this._indirectTexture.toJSON(t),this._colorsTexture!==null&&(i.colorsTexture=this._colorsTexture.toJSON(t)),this.boundingSphere!==null&&(i.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(i.boundingBox=this.boundingBox.toJSON()));function s(a,l){return a[l.uuid]===void 0&&(a[l.uuid]=l.toJSON(t)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=s(t.geometries,this.geometry);const a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){const l=a.shapes;if(Array.isArray(l))for(let c=0,h=l.length;c<h;c++){const f=l[c];s(t.shapes,f)}else s(t.shapes,l)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(t.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const a=[];for(let l=0,c=this.material.length;l<c;l++)a.push(s(t.materials,this.material[l]));i.material=a}else i.material=s(t.materials,this.material);if(this.children.length>0){i.children=[];for(let a=0;a<this.children.length;a++)i.children.push(this.children[a].toJSON(t).object)}if(this.animations.length>0){i.animations=[];for(let a=0;a<this.animations.length;a++){const l=this.animations[a];i.animations.push(s(t.animations,l))}}if(e){const a=o(t.geometries),l=o(t.materials),c=o(t.textures),h=o(t.images),f=o(t.shapes),g=o(t.skeletons),p=o(t.animations),m=o(t.nodes);a.length>0&&(r.geometries=a),l.length>0&&(r.materials=l),c.length>0&&(r.textures=c),h.length>0&&(r.images=h),f.length>0&&(r.shapes=f),g.length>0&&(r.skeletons=g),p.length>0&&(r.animations=p),m.length>0&&(r.nodes=m)}return r.object=i,r;function o(a){const l=[];for(const c in a){const h=a[c];delete h.metadata,l.push(h)}return l}}clone(t){return new this.constructor().copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),e===!0)for(let r=0;r<t.children.length;r++){const i=t.children[r];this.add(i.clone())}return this}}vn.DEFAULT_UP=new D(0,1,0),vn.DEFAULT_MATRIX_AUTO_UPDATE=!0,vn.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Kr=new D,Fn=new D,Yc=new D,Nn=new D,Ms=new D,As=new D,Mm=new D,Xc=new D,Jc=new D,Zc=new D,Kc=new Eo,Qc=new Eo,th=new Eo;class Qr{constructor(t=new D,e=new D,r=new D){this.a=t,this.b=e,this.c=r}static getNormal(t,e,r,i){i.subVectors(r,e),Kr.subVectors(t,e),i.cross(Kr);const s=i.lengthSq();return s>0?i.multiplyScalar(1/Math.sqrt(s)):i.set(0,0,0)}static getBarycoord(t,e,r,i,s){Kr.subVectors(i,e),Fn.subVectors(r,e),Yc.subVectors(t,e);const o=Kr.dot(Kr),a=Kr.dot(Fn),l=Kr.dot(Yc),c=Fn.dot(Fn),h=Fn.dot(Yc),f=o*c-a*a;if(f===0)return s.set(0,0,0),null;const g=1/f,p=(c*l-a*h)*g,m=(o*h-a*l)*g;return s.set(1-p-m,m,p)}static containsPoint(t,e,r,i){return this.getBarycoord(t,e,r,i,Nn)===null?!1:Nn.x>=0&&Nn.y>=0&&Nn.x+Nn.y<=1}static getInterpolation(t,e,r,i,s,o,a,l){return this.getBarycoord(t,e,r,i,Nn)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(s,Nn.x),l.addScaledVector(o,Nn.y),l.addScaledVector(a,Nn.z),l)}static getInterpolatedAttribute(t,e,r,i,s,o){return Kc.setScalar(0),Qc.setScalar(0),th.setScalar(0),Kc.fromBufferAttribute(t,e),Qc.fromBufferAttribute(t,r),th.fromBufferAttribute(t,i),o.setScalar(0),o.addScaledVector(Kc,s.x),o.addScaledVector(Qc,s.y),o.addScaledVector(th,s.z),o}static isFrontFacing(t,e,r,i){return Kr.subVectors(r,e),Fn.subVectors(t,e),Kr.cross(Fn).dot(i)<0}set(t,e,r){return this.a.copy(t),this.b.copy(e),this.c.copy(r),this}setFromPointsAndIndices(t,e,r,i){return this.a.copy(t[e]),this.b.copy(t[r]),this.c.copy(t[i]),this}setFromAttributeAndIndices(t,e,r,i){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,r),this.c.fromBufferAttribute(t,i),this}clone(){return new this.constructor().copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return Kr.subVectors(this.c,this.b),Fn.subVectors(this.a,this.b),Kr.cross(Fn).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return Qr.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return Qr.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,r,i,s){return Qr.getInterpolation(t,this.a,this.b,this.c,e,r,i,s)}containsPoint(t){return Qr.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return Qr.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const r=this.a,i=this.b,s=this.c;let o,a;Ms.subVectors(i,r),As.subVectors(s,r),Xc.subVectors(t,r);const l=Ms.dot(Xc),c=As.dot(Xc);if(l<=0&&c<=0)return e.copy(r);Jc.subVectors(t,i);const h=Ms.dot(Jc),f=As.dot(Jc);if(h>=0&&f<=h)return e.copy(i);const g=l*f-h*c;if(g<=0&&l>=0&&h<=0)return o=l/(l-h),e.copy(r).addScaledVector(Ms,o);Zc.subVectors(t,s);const p=Ms.dot(Zc),m=As.dot(Zc);if(m>=0&&p<=m)return e.copy(s);const v=p*c-l*m;if(v<=0&&c>=0&&m<=0)return a=c/(c-m),e.copy(r).addScaledVector(As,a);const _=h*m-p*f;if(_<=0&&f-h>=0&&p-m>=0)return Mm.subVectors(s,i),a=(f-h)/(f-h+(p-m)),e.copy(i).addScaledVector(Mm,a);const S=1/(_+v+g);return o=v*S,a=g*S,e.copy(r).addScaledVector(Ms,o).addScaledVector(As,a)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}const Am={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},si={h:0,s:0,l:0},su={h:0,s:0,l:0};function eh(n,t,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?n+(t-n)*6*e:e<1/2?t:e<2/3?n+(t-n)*6*(2/3-e):n}class Mi{constructor(t,e,r){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,r)}set(t,e,r){if(e===void 0&&r===void 0){const i=t;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(t,e,r);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=Yr){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,Xr.colorSpaceToWorking(this,e),this}setRGB(t,e,r,i=Xr.workingColorSpace){return this.r=t,this.g=e,this.b=r,Xr.colorSpaceToWorking(this,i),this}setHSL(t,e,r,i=Xr.workingColorSpace){if(t=fS(t,1),e=Lt(e,0,1),r=Lt(r,0,1),e===0)this.r=this.g=this.b=r;else{const s=r<=.5?r*(1+e):r+e-r*e,o=2*r-s;this.r=eh(o,s,t+1/3),this.g=eh(o,s,t),this.b=eh(o,s,t-1/3)}return Xr.colorSpaceToWorking(this,i),this}setStyle(t,e=Yr){function r(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(t)){let s;const o=i[1],a=i[2];switch(o){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return r(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,e);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return r(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,e);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return r(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,e);break;default:console.warn("THREE.Color: Unknown color model "+t)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(t)){const s=i[1],o=s.length;if(o===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,e);if(o===6)return this.setHex(parseInt(s,16),e);console.warn("THREE.Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=Yr){const r=Am[t.toLowerCase()];return r!==void 0?this.setHex(r,e):console.warn("THREE.Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=kn(t.r),this.g=kn(t.g),this.b=kn(t.b),this}copyLinearToSRGB(t){return this.r=gs(t.r),this.g=gs(t.g),this.b=gs(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=Yr){return Xr.workingToColorSpace(qe.copy(this),t),Math.round(Lt(qe.r*255,0,255))*65536+Math.round(Lt(qe.g*255,0,255))*256+Math.round(Lt(qe.b*255,0,255))}getHexString(t=Yr){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=Xr.workingColorSpace){Xr.workingToColorSpace(qe.copy(this),e);const r=qe.r,i=qe.g,s=qe.b,o=Math.max(r,i,s),a=Math.min(r,i,s);let l,c;const h=(a+o)/2;if(a===o)l=0,c=0;else{const f=o-a;switch(c=h<=.5?f/(o+a):f/(2-o-a),o){case r:l=(i-s)/f+(i<s?6:0);break;case i:l=(s-r)/f+2;break;case s:l=(r-i)/f+4;break}l/=6}return t.h=l,t.s=c,t.l=h,t}getRGB(t,e=Xr.workingColorSpace){return Xr.workingToColorSpace(qe.copy(this),e),t.r=qe.r,t.g=qe.g,t.b=qe.b,t}getStyle(t=Yr){Xr.workingToColorSpace(qe.copy(this),t);const e=qe.r,r=qe.g,i=qe.b;return t!==Yr?`color(${t} ${e.toFixed(3)} ${r.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(e*255)},${Math.round(r*255)},${Math.round(i*255)})`}offsetHSL(t,e,r){return this.getHSL(si),this.setHSL(si.h+t,si.s+e,si.l+r)}add(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this}addColors(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this}addScalar(t){return this.r+=t,this.g+=t,this.b+=t,this}sub(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this}multiply(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this}multiplyScalar(t){return this.r*=t,this.g*=t,this.b*=t,this}lerp(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this}lerpColors(t,e,r){return this.r=t.r+(e.r-t.r)*r,this.g=t.g+(e.g-t.g)*r,this.b=t.b+(e.b-t.b)*r,this}lerpHSL(t,e){this.getHSL(si),t.getHSL(su);const r=Fc(si.h,su.h,e),i=Fc(si.s,su.s,e),s=Fc(si.l,su.l,e);return this.setHSL(r,i,s),this}setFromVector3(t){return this.r=t.x,this.g=t.y,this.b=t.z,this}applyMatrix3(t){const e=this.r,r=this.g,i=this.b,s=t.elements;return this.r=s[0]*e+s[3]*r+s[6]*i,this.g=s[1]*e+s[4]*r+s[7]*i,this.b=s[2]*e+s[5]*r+s[8]*i,this}equals(t){return t.r===this.r&&t.g===this.g&&t.b===this.b}fromArray(t,e=0){return this.r=t[e],this.g=t[e+1],this.b=t[e+2],this}toArray(t=[],e=0){return t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t}fromBufferAttribute(t,e){return this.r=t.getX(e),this.g=t.getY(e),this.b=t.getZ(e),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const qe=new Mi;Mi.NAMES=Am;let zS=0;class Om extends Za{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:zS++}),this.uuid=ds(),this.name="",this.type="Material",this.blending=Kg,this.side=Rc,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=tm,this.blendDst=em,this.blendEquation=Qg,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Mi(0,0,0),this.blendAlpha=0,this.depthFunc=rm,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=lm,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=fs,this.stencilZFail=fs,this.stencilZPass=fs,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(t!==void 0)for(const e in t){const r=t[e];if(r===void 0){console.warn(`THREE.Material: parameter '${e}' has value of undefined.`);continue}const i=this[e];if(i===void 0){console.warn(`THREE.Material: '${e}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(r):i&&i.isVector3&&r&&r.isVector3?i.copy(r):this[e]=r}}toJSON(t){const e=t===void 0||typeof t=="string";e&&(t={textures:{},images:{}});const r={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.color&&this.color.isColor&&(r.color=this.color.getHex()),this.roughness!==void 0&&(r.roughness=this.roughness),this.metalness!==void 0&&(r.metalness=this.metalness),this.sheen!==void 0&&(r.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(r.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(r.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(r.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(r.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(r.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(r.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(r.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(r.shininess=this.shininess),this.clearcoat!==void 0&&(r.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(r.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(r.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(r.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(r.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,r.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.dispersion!==void 0&&(r.dispersion=this.dispersion),this.iridescence!==void 0&&(r.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(r.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(r.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(r.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(r.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),this.anisotropy!==void 0&&(r.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(r.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(r.anisotropyMap=this.anisotropyMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(r.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(r.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(r.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(r.lightMap=this.lightMap.toJSON(t).uuid,r.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(r.aoMap=this.aoMap.toJSON(t).uuid,r.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(r.bumpMap=this.bumpMap.toJSON(t).uuid,r.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(r.normalMap=this.normalMap.toJSON(t).uuid,r.normalMapType=this.normalMapType,r.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(r.displacementMap=this.displacementMap.toJSON(t).uuid,r.displacementScale=this.displacementScale,r.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(r.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(r.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(r.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(r.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(r.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(r.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(r.envMap=this.envMap.toJSON(t).uuid,this.combine!==void 0&&(r.combine=this.combine)),this.envMapRotation!==void 0&&(r.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(r.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(r.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(r.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(r.gradientMap=this.gradientMap.toJSON(t).uuid),this.transmission!==void 0&&(r.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(r.transmissionMap=this.transmissionMap.toJSON(t).uuid),this.thickness!==void 0&&(r.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(r.thicknessMap=this.thicknessMap.toJSON(t).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(r.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(r.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(r.size=this.size),this.shadowSide!==null&&(r.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(r.sizeAttenuation=this.sizeAttenuation),this.blending!==Kg&&(r.blending=this.blending),this.side!==Rc&&(r.side=this.side),this.vertexColors===!0&&(r.vertexColors=!0),this.opacity<1&&(r.opacity=this.opacity),this.transparent===!0&&(r.transparent=!0),this.blendSrc!==tm&&(r.blendSrc=this.blendSrc),this.blendDst!==em&&(r.blendDst=this.blendDst),this.blendEquation!==Qg&&(r.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(r.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(r.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(r.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(r.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(r.blendAlpha=this.blendAlpha),this.depthFunc!==rm&&(r.depthFunc=this.depthFunc),this.depthTest===!1&&(r.depthTest=this.depthTest),this.depthWrite===!1&&(r.depthWrite=this.depthWrite),this.colorWrite===!1&&(r.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(r.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==lm&&(r.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(r.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==fs&&(r.stencilFail=this.stencilFail),this.stencilZFail!==fs&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==fs&&(r.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(r.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(r.rotation=this.rotation),this.polygonOffset===!0&&(r.polygonOffset=!0),this.polygonOffsetFactor!==0&&(r.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(r.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(r.linewidth=this.linewidth),this.dashSize!==void 0&&(r.dashSize=this.dashSize),this.gapSize!==void 0&&(r.gapSize=this.gapSize),this.scale!==void 0&&(r.scale=this.scale),this.dithering===!0&&(r.dithering=!0),this.alphaTest>0&&(r.alphaTest=this.alphaTest),this.alphaHash===!0&&(r.alphaHash=!0),this.alphaToCoverage===!0&&(r.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(r.premultipliedAlpha=!0),this.forceSinglePass===!0&&(r.forceSinglePass=!0),this.wireframe===!0&&(r.wireframe=!0),this.wireframeLinewidth>1&&(r.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(r.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(r.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(r.flatShading=!0),this.visible===!1&&(r.visible=!1),this.toneMapped===!1&&(r.toneMapped=!1),this.fog===!1&&(r.fog=!1),Object.keys(this.userData).length>0&&(r.userData=this.userData);function i(s){const o=[];for(const a in s){const l=s[a];delete l.metadata,o.push(l)}return o}if(e){const s=i(t.textures),o=i(t.images);s.length>0&&(r.textures=s),o.length>0&&(r.images=o)}return r}clone(){return new this.constructor().copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;const e=t.clippingPlanes;let r=null;if(e!==null){const i=e.length;r=new Array(i);for(let s=0;s!==i;++s)r[s]=e[s].clone()}return this.clippingPlanes=r,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaHash=t.alphaHash,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){t===!0&&this.version++}}class Os extends Om{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Mi(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ws,this.combine=nm,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}const be=new D,ou=new Et;let TS=0;class zs{constructor(t,e,r=!1){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:TS++}),this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=r,this.usage=cm,this.updateRanges=[],this.gpuType=lS,this.version=0}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,r){t*=this.itemSize,r*=e.itemSize;for(let i=0,s=this.itemSize;i<s;i++)this.array[t+i]=e.array[r+i];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(this.itemSize===2)for(let e=0,r=this.count;e<r;e++)ou.fromBufferAttribute(this,e),ou.applyMatrix3(t),this.setXY(e,ou.x,ou.y);else if(this.itemSize===3)for(let e=0,r=this.count;e<r;e++)be.fromBufferAttribute(this,e),be.applyMatrix3(t),this.setXYZ(e,be.x,be.y,be.z);return this}applyMatrix4(t){for(let e=0,r=this.count;e<r;e++)be.fromBufferAttribute(this,e),be.applyMatrix4(t),this.setXYZ(e,be.x,be.y,be.z);return this}applyNormalMatrix(t){for(let e=0,r=this.count;e<r;e++)be.fromBufferAttribute(this,e),be.applyNormalMatrix(t),this.setXYZ(e,be.x,be.y,be.z);return this}transformDirection(t){for(let e=0,r=this.count;e<r;e++)be.fromBufferAttribute(this,e),be.transformDirection(t),this.setXYZ(e,be.x,be.y,be.z);return this}set(t,e=0){return this.array.set(t,e),this}getComponent(t,e){let r=this.array[t*this.itemSize+e];return this.normalized&&(r=So(r,this.array)),r}setComponent(t,e,r){return this.normalized&&(r=er(r,this.array)),this.array[t*this.itemSize+e]=r,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=So(e,this.array)),e}setX(t,e){return this.normalized&&(e=er(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=So(e,this.array)),e}setY(t,e){return this.normalized&&(e=er(e,this.array)),this.array[t*this.itemSize+1]=e,this}getZ(t){let e=this.array[t*this.itemSize+2];return this.normalized&&(e=So(e,this.array)),e}setZ(t,e){return this.normalized&&(e=er(e,this.array)),this.array[t*this.itemSize+2]=e,this}getW(t){let e=this.array[t*this.itemSize+3];return this.normalized&&(e=So(e,this.array)),e}setW(t,e){return this.normalized&&(e=er(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,r){return t*=this.itemSize,this.normalized&&(e=er(e,this.array),r=er(r,this.array)),this.array[t+0]=e,this.array[t+1]=r,this}setXYZ(t,e,r,i){return t*=this.itemSize,this.normalized&&(e=er(e,this.array),r=er(r,this.array),i=er(i,this.array)),this.array[t+0]=e,this.array[t+1]=r,this.array[t+2]=i,this}setXYZW(t,e,r,i,s){return t*=this.itemSize,this.normalized&&(e=er(e,this.array),r=er(r,this.array),i=er(i,this.array),s=er(s,this.array)),this.array[t+0]=e,this.array[t+1]=r,this.array[t+2]=i,this.array[t+3]=s,this}onUpload(t){return this.onUploadCallback=t,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const t={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(t.name=this.name),this.usage!==cm&&(t.usage=this.usage),t}}class CS extends zs{constructor(t,e,r){super(new Uint16Array(t),e,r)}}class IS extends zs{constructor(t,e,r){super(new Uint32Array(t),e,r)}}class jn extends zs{constructor(t,e,r){super(new Float32Array(t),e,r)}}let kS=0;const Tr=new Ue,rh=new vn,Ts=new D,fr=new ys,zo=new ys,ke=new D;class Ai extends Za{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:kS++}),this.uuid=ds(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(t){return Array.isArray(t)?this.index=new(dS(t)?IS:CS)(t,1):this.index=t,this}setIndirect(t){return this.indirect=t,this}getIndirect(){return this.indirect}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return this.attributes[t]!==void 0}addGroup(t,e,r=0){this.groups.push({start:t,count:e,materialIndex:r})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){const e=this.attributes.position;e!==void 0&&(e.applyMatrix4(t),e.needsUpdate=!0);const r=this.attributes.normal;if(r!==void 0){const s=new Qn().getNormalMatrix(t);r.applyNormalMatrix(s),r.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(t),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(t){return Tr.makeRotationFromQuaternion(t),this.applyMatrix4(Tr),this}rotateX(t){return Tr.makeRotationX(t),this.applyMatrix4(Tr),this}rotateY(t){return Tr.makeRotationY(t),this.applyMatrix4(Tr),this}rotateZ(t){return Tr.makeRotationZ(t),this.applyMatrix4(Tr),this}translate(t,e,r){return Tr.makeTranslation(t,e,r),this.applyMatrix4(Tr),this}scale(t,e,r){return Tr.makeScale(t,e,r),this.applyMatrix4(Tr),this}lookAt(t){return rh.lookAt(t),rh.updateMatrix(),this.applyMatrix4(rh.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Ts).negate(),this.translate(Ts.x,Ts.y,Ts.z),this}setFromPoints(t){const e=this.getAttribute("position");if(e===void 0){const r=[];for(let i=0,s=t.length;i<s;i++){const o=t[i];r.push(o.x,o.y,o.z||0)}this.setAttribute("position",new jn(r,3))}else{const r=Math.min(t.length,e.count);for(let i=0;i<r;i++){const s=t[i];e.setXYZ(i,s.x,s.y,s.z||0)}t.length>e.count&&console.warn("THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),e.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new ys);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new D(-1/0,-1/0,-1/0),new D(1/0,1/0,1/0));return}if(t!==void 0){if(this.boundingBox.setFromBufferAttribute(t),e)for(let r=0,i=e.length;r<i;r++){const s=e[r];fr.setFromBufferAttribute(s),this.morphTargetsRelative?(ke.addVectors(this.boundingBox.min,fr.min),this.boundingBox.expandByPoint(ke),ke.addVectors(this.boundingBox.max,fr.max),this.boundingBox.expandByPoint(ke)):(this.boundingBox.expandByPoint(fr.min),this.boundingBox.expandByPoint(fr.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new ym);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new D,1/0);return}if(t){const r=this.boundingSphere.center;if(fr.setFromBufferAttribute(t),e)for(let s=0,o=e.length;s<o;s++){const a=e[s];zo.setFromBufferAttribute(a),this.morphTargetsRelative?(ke.addVectors(fr.min,zo.min),fr.expandByPoint(ke),ke.addVectors(fr.max,zo.max),fr.expandByPoint(ke)):(fr.expandByPoint(zo.min),fr.expandByPoint(zo.max))}fr.getCenter(r);let i=0;for(let s=0,o=t.count;s<o;s++)ke.fromBufferAttribute(t,s),i=Math.max(i,r.distanceToSquared(ke));if(e)for(let s=0,o=e.length;s<o;s++){const a=e[s],l=this.morphTargetsRelative;for(let c=0,h=a.count;c<h;c++)ke.fromBufferAttribute(a,c),l&&(Ts.fromBufferAttribute(t,c),ke.add(Ts)),i=Math.max(i,r.distanceToSquared(ke))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const t=this.index,e=this.attributes;if(t===null||e.position===void 0||e.normal===void 0||e.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const r=e.position,i=e.normal,s=e.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new zs(new Float32Array(4*r.count),4));const o=this.getAttribute("tangent"),a=[],l=[];for(let k=0;k<r.count;k++)a[k]=new D,l[k]=new D;const c=new D,h=new D,f=new D,g=new Et,p=new Et,m=new Et,v=new D,_=new D;function S(k,L,X){c.fromBufferAttribute(r,k),h.fromBufferAttribute(r,L),f.fromBufferAttribute(r,X),g.fromBufferAttribute(s,k),p.fromBufferAttribute(s,L),m.fromBufferAttribute(s,X),h.sub(c),f.sub(c),p.sub(g),m.sub(g);const J=1/(p.x*m.y-m.x*p.y);isFinite(J)&&(v.copy(h).multiplyScalar(m.y).addScaledVector(f,-p.y).multiplyScalar(J),_.copy(f).multiplyScalar(p.x).addScaledVector(h,-m.x).multiplyScalar(J),a[k].add(v),a[L].add(v),a[X].add(v),l[k].add(_),l[L].add(_),l[X].add(_))}let M=this.groups;M.length===0&&(M=[{start:0,count:t.count}]);for(let k=0,L=M.length;k<L;++k){const X=M[k],J=X.start,at=X.count;for(let tt=J,bt=J+at;tt<bt;tt+=3)S(t.getX(tt+0),t.getX(tt+1),t.getX(tt+2))}const C=new D,O=new D,E=new D,z=new D;function R(k){E.fromBufferAttribute(i,k),z.copy(E);const L=a[k];C.copy(L),C.sub(E.multiplyScalar(E.dot(L))).normalize(),O.crossVectors(z,L);const J=O.dot(l[k])<0?-1:1;o.setXYZW(k,C.x,C.y,C.z,J)}for(let k=0,L=M.length;k<L;++k){const X=M[k],J=X.start,at=X.count;for(let tt=J,bt=J+at;tt<bt;tt+=3)R(t.getX(tt+0)),R(t.getX(tt+1)),R(t.getX(tt+2))}}computeVertexNormals(){const t=this.index,e=this.getAttribute("position");if(e!==void 0){let r=this.getAttribute("normal");if(r===void 0)r=new zs(new Float32Array(e.count*3),3),this.setAttribute("normal",r);else for(let g=0,p=r.count;g<p;g++)r.setXYZ(g,0,0,0);const i=new D,s=new D,o=new D,a=new D,l=new D,c=new D,h=new D,f=new D;if(t)for(let g=0,p=t.count;g<p;g+=3){const m=t.getX(g+0),v=t.getX(g+1),_=t.getX(g+2);i.fromBufferAttribute(e,m),s.fromBufferAttribute(e,v),o.fromBufferAttribute(e,_),h.subVectors(o,s),f.subVectors(i,s),h.cross(f),a.fromBufferAttribute(r,m),l.fromBufferAttribute(r,v),c.fromBufferAttribute(r,_),a.add(h),l.add(h),c.add(h),r.setXYZ(m,a.x,a.y,a.z),r.setXYZ(v,l.x,l.y,l.z),r.setXYZ(_,c.x,c.y,c.z)}else for(let g=0,p=e.count;g<p;g+=3)i.fromBufferAttribute(e,g+0),s.fromBufferAttribute(e,g+1),o.fromBufferAttribute(e,g+2),h.subVectors(o,s),f.subVectors(i,s),h.cross(f),r.setXYZ(g+0,h.x,h.y,h.z),r.setXYZ(g+1,h.x,h.y,h.z),r.setXYZ(g+2,h.x,h.y,h.z);this.normalizeNormals(),r.needsUpdate=!0}}normalizeNormals(){const t=this.attributes.normal;for(let e=0,r=t.count;e<r;e++)ke.fromBufferAttribute(t,e),ke.normalize(),t.setXYZ(e,ke.x,ke.y,ke.z)}toNonIndexed(){function t(a,l){const c=a.array,h=a.itemSize,f=a.normalized,g=new c.constructor(l.length*h);let p=0,m=0;for(let v=0,_=l.length;v<_;v++){a.isInterleavedBufferAttribute?p=l[v]*a.data.stride+a.offset:p=l[v]*h;for(let S=0;S<h;S++)g[m++]=c[p++]}return new zs(g,h,f)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const e=new Ai,r=this.index.array,i=this.attributes;for(const a in i){const l=i[a],c=t(l,r);e.setAttribute(a,c)}const s=this.morphAttributes;for(const a in s){const l=[],c=s[a];for(let h=0,f=c.length;h<f;h++){const g=c[h],p=t(g,r);l.push(p)}e.morphAttributes[a]=l}e.morphTargetsRelative=this.morphTargetsRelative;const o=this.groups;for(let a=0,l=o.length;a<l;a++){const c=o[a];e.addGroup(c.start,c.count,c.materialIndex)}return e}toJSON(){const t={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,this.name!==""&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),this.parameters!==void 0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(t[c]=l[c]);return t}t.data={attributes:{}};const e=this.index;e!==null&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const r=this.attributes;for(const l in r){const c=r[l];t.data.attributes[l]=c.toJSON(t.data)}const i={};let s=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],h=[];for(let f=0,g=c.length;f<g;f++){const p=c[f];h.push(p.toJSON(t.data))}h.length>0&&(i[l]=h,s=!0)}s&&(t.data.morphAttributes=i,t.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(t.data.groups=JSON.parse(JSON.stringify(o)));const a=this.boundingSphere;return a!==null&&(t.data.boundingSphere=a.toJSON()),t}clone(){return new this.constructor().copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const e={};this.name=t.name;const r=t.index;r!==null&&this.setIndex(r.clone());const i=t.attributes;for(const c in i){const h=i[c];this.setAttribute(c,h.clone(e))}const s=t.morphAttributes;for(const c in s){const h=[],f=s[c];for(let g=0,p=f.length;g<p;g++)h.push(f[g].clone(e));this.morphAttributes[c]=h}this.morphTargetsRelative=t.morphTargetsRelative;const o=t.groups;for(let c=0,h=o.length;c<h;c++){const f=o[c];this.addGroup(f.start,f.count,f.materialIndex)}const a=t.boundingBox;a!==null&&(this.boundingBox=a.clone());const l=t.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const zm=new Ue,Oi=new _S,au=new ym,Tm=new D,uu=new D,lu=new D,cu=new D,nh=new D,hu=new D,Cm=new D,fu=new D;class Cs extends vn{constructor(t=new Ai,e=new Os){super(),this.isMesh=!0,this.type="Mesh",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),t.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),t.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}updateMorphTargets(){const e=this.geometry.morphAttributes,r=Object.keys(e);if(r.length>0){const i=e[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s<o;s++){const a=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}getVertexPosition(t,e){const r=this.geometry,i=r.attributes.position,s=r.morphAttributes.position,o=r.morphTargetsRelative;e.fromBufferAttribute(i,t);const a=this.morphTargetInfluences;if(s&&a){hu.set(0,0,0);for(let l=0,c=s.length;l<c;l++){const h=a[l],f=s[l];h!==0&&(nh.fromBufferAttribute(f,t),o?hu.addScaledVector(nh,h):hu.addScaledVector(nh.sub(e),h))}e.add(hu)}return e}raycast(t,e){const r=this.geometry,i=this.material,s=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),au.copy(r.boundingSphere),au.applyMatrix4(s),Oi.copy(t.ray).recast(t.near),!(au.containsPoint(Oi.origin)===!1&&(Oi.intersectSphere(au,Tm)===null||Oi.origin.distanceToSquared(Tm)>(t.far-t.near)**2))&&(zm.copy(s).invert(),Oi.copy(t.ray).applyMatrix4(zm),!(r.boundingBox!==null&&Oi.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(t,e,Oi)))}_computeIntersections(t,e,r){let i;const s=this.geometry,o=this.material,a=s.index,l=s.attributes.position,c=s.attributes.uv,h=s.attributes.uv1,f=s.attributes.normal,g=s.groups,p=s.drawRange;if(a!==null)if(Array.isArray(o))for(let m=0,v=g.length;m<v;m++){const _=g[m],S=o[_.materialIndex],M=Math.max(_.start,p.start),C=Math.min(a.count,Math.min(_.start+_.count,p.start+p.count));for(let O=M,E=C;O<E;O+=3){const z=a.getX(O),R=a.getX(O+1),k=a.getX(O+2);i=du(this,S,t,r,c,h,f,z,R,k),i&&(i.faceIndex=Math.floor(O/3),i.face.materialIndex=_.materialIndex,e.push(i))}}else{const m=Math.max(0,p.start),v=Math.min(a.count,p.start+p.count);for(let _=m,S=v;_<S;_+=3){const M=a.getX(_),C=a.getX(_+1),O=a.getX(_+2);i=du(this,o,t,r,c,h,f,M,C,O),i&&(i.faceIndex=Math.floor(_/3),e.push(i))}}else if(l!==void 0)if(Array.isArray(o))for(let m=0,v=g.length;m<v;m++){const _=g[m],S=o[_.materialIndex],M=Math.max(_.start,p.start),C=Math.min(l.count,Math.min(_.start+_.count,p.start+p.count));for(let O=M,E=C;O<E;O+=3){const z=O,R=O+1,k=O+2;i=du(this,S,t,r,c,h,f,z,R,k),i&&(i.faceIndex=Math.floor(O/3),i.face.materialIndex=_.materialIndex,e.push(i))}}else{const m=Math.max(0,p.start),v=Math.min(l.count,p.start+p.count);for(let _=m,S=v;_<S;_+=3){const M=_,C=_+1,O=_+2;i=du(this,o,t,r,c,h,f,M,C,O),i&&(i.faceIndex=Math.floor(_/3),e.push(i))}}}}function PS(n,t,e,r,i,s,o,a){let l;if(t.side===iS?l=r.intersectTriangle(o,s,i,!0,a):l=r.intersectTriangle(i,s,o,t.side===Rc,a),l===null)return null;fu.copy(a),fu.applyMatrix4(n.matrixWorld);const c=e.ray.origin.distanceTo(fu);return c<e.near||c>e.far?null:{distance:c,point:fu.clone(),object:n}}function du(n,t,e,r,i,s,o,a,l,c){n.getVertexPosition(a,uu),n.getVertexPosition(l,lu),n.getVertexPosition(c,cu);const h=PS(n,t,e,r,uu,lu,cu,Cm);if(h){const f=new D;Qr.getBarycoord(Cm,uu,lu,cu,f),i&&(h.uv=Qr.getInterpolatedAttribute(i,a,l,c,f,new Et)),s&&(h.uv1=Qr.getInterpolatedAttribute(s,a,l,c,f,new Et)),o&&(h.normal=Qr.getInterpolatedAttribute(o,a,l,c,f,new D),h.normal.dot(r.direction)>0&&h.normal.multiplyScalar(-1));const g={a,b:l,c,normal:new D,materialIndex:0};Qr.getNormal(uu,lu,cu,g.normal),h.face=g,h.barycoord=f}return h}class pu extends Ai{constructor(t=1,e=1,r=1,i=1,s=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:r,widthSegments:i,heightSegments:s,depthSegments:o};const a=this;i=Math.floor(i),s=Math.floor(s),o=Math.floor(o);const l=[],c=[],h=[],f=[];let g=0,p=0;m("z","y","x",-1,-1,r,e,t,o,s,0),m("z","y","x",1,-1,r,e,-t,o,s,1),m("x","z","y",1,1,t,r,e,i,o,2),m("x","z","y",1,-1,t,r,-e,i,o,3),m("x","y","z",1,-1,t,e,r,i,s,4),m("x","y","z",-1,-1,t,e,-r,i,s,5),this.setIndex(l),this.setAttribute("position",new jn(c,3)),this.setAttribute("normal",new jn(h,3)),this.setAttribute("uv",new jn(f,2));function m(v,_,S,M,C,O,E,z,R,k,L){const X=O/R,J=E/k,at=O/2,tt=E/2,bt=z/2,xt=R+1,yt=k+1;let ht=0,Y=0;const St=new D;for(let j=0;j<yt;j++){const W=j*J-tt;for(let ft=0;ft<xt;ft++){const et=ft*X-at;St[v]=et*M,St[_]=W*C,St[S]=bt,c.push(St.x,St.y,St.z),St[v]=0,St[_]=0,St[S]=z>0?1:-1,h.push(St.x,St.y,St.z),f.push(ft/R),f.push(1-j/k),ht+=1}}for(let j=0;j<k;j++)for(let W=0;W<R;W++){const ft=g+W+xt*j,et=g+W+xt*(j+1),rt=g+(W+1)+xt*(j+1),Z=g+(W+1)+xt*j;l.push(ft,et,Z),l.push(et,rt,Z),Y+=6}a.addGroup(p,Y,L),p+=Y,g+=ht}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new pu(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}}class RS extends vn{constructor(){super(),this.isGroup=!0,this.type="Group"}}class xn{constructor(){this.type="Curve",this.arcLengthDivisions=200,this.needsUpdate=!1,this.cacheArcLengths=null}getPoint(){console.warn("THREE.Curve: .getPoint() not implemented.")}getPointAt(t,e){const r=this.getUtoTmapping(t);return this.getPoint(r,e)}getPoints(t=5){const e=[];for(let r=0;r<=t;r++)e.push(this.getPoint(r/t));return e}getSpacedPoints(t=5){const e=[];for(let r=0;r<=t;r++)e.push(this.getPointAt(r/t));return e}getLength(){const t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const e=[];let r,i=this.getPoint(0),s=0;e.push(0);for(let o=1;o<=t;o++)r=this.getPoint(o/t),s+=r.distanceTo(i),e.push(s),i=r;return this.cacheArcLengths=e,e}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(t,e=null){const r=this.getLengths();let i=0;const s=r.length;let o;e?o=e:o=t*r[s-1];let a=0,l=s-1,c;for(;a<=l;)if(i=Math.floor(a+(l-a)/2),c=r[i]-o,c<0)a=i+1;else if(c>0)l=i-1;else{l=i;break}if(i=l,r[i]===o)return i/(s-1);const h=r[i],g=r[i+1]-h,p=(o-h)/g;return(i+p)/(s-1)}getTangent(t,e){let i=t-1e-4,s=t+1e-4;i<0&&(i=0),s>1&&(s=1);const o=this.getPoint(i),a=this.getPoint(s),l=e||(o.isVector2?new Et:new D);return l.copy(a).sub(o).normalize(),l}getTangentAt(t,e){const r=this.getUtoTmapping(t);return this.getTangent(r,e)}computeFrenetFrames(t,e=!1){const r=new D,i=[],s=[],o=[],a=new D,l=new Ue;for(let p=0;p<=t;p++){const m=p/t;i[p]=this.getTangentAt(m,new D)}s[0]=new D,o[0]=new D;let c=Number.MAX_VALUE;const h=Math.abs(i[0].x),f=Math.abs(i[0].y),g=Math.abs(i[0].z);h<=c&&(c=h,r.set(1,0,0)),f<=c&&(c=f,r.set(0,1,0)),g<=c&&r.set(0,0,1),a.crossVectors(i[0],r).normalize(),s[0].crossVectors(i[0],a),o[0].crossVectors(i[0],s[0]);for(let p=1;p<=t;p++){if(s[p]=s[p-1].clone(),o[p]=o[p-1].clone(),a.crossVectors(i[p-1],i[p]),a.length()>Number.EPSILON){a.normalize();const m=Math.acos(Lt(i[p-1].dot(i[p]),-1,1));s[p].applyMatrix4(l.makeRotationAxis(a,m))}o[p].crossVectors(i[p],s[p])}if(e===!0){let p=Math.acos(Lt(s[0].dot(s[t]),-1,1));p/=t,i[0].dot(a.crossVectors(s[0],s[t]))>0&&(p=-p);for(let m=1;m<=t;m++)s[m].applyMatrix4(l.makeRotationAxis(i[m],p*m)),o[m].crossVectors(i[m],s[m])}return{tangents:i,normals:s,binormals:o}}clone(){return new this.constructor().copy(this)}copy(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}toJSON(){const t={metadata:{version:4.7,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t}fromJSON(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}}class ih extends xn{constructor(t=0,e=0,r=1,i=1,s=0,o=Math.PI*2,a=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=t,this.aY=e,this.xRadius=r,this.yRadius=i,this.aStartAngle=s,this.aEndAngle=o,this.aClockwise=a,this.aRotation=l}getPoint(t,e=new Et){const r=e,i=Math.PI*2;let s=this.aEndAngle-this.aStartAngle;const o=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=i;for(;s>i;)s-=i;s<Number.EPSILON&&(o?s=0:s=i),this.aClockwise===!0&&!o&&(s===i?s=-i:s=s-i);const a=this.aStartAngle+t*s;let l=this.aX+this.xRadius*Math.cos(a),c=this.aY+this.yRadius*Math.sin(a);if(this.aRotation!==0){const h=Math.cos(this.aRotation),f=Math.sin(this.aRotation),g=l-this.aX,p=c-this.aY;l=g*h-p*f+this.aX,c=g*f+p*h+this.aY}return r.set(l,c)}copy(t){return super.copy(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}toJSON(){const t=super.toJSON();return t.aX=this.aX,t.aY=this.aY,t.xRadius=this.xRadius,t.yRadius=this.yRadius,t.aStartAngle=this.aStartAngle,t.aEndAngle=this.aEndAngle,t.aClockwise=this.aClockwise,t.aRotation=this.aRotation,t}fromJSON(t){return super.fromJSON(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}}class LS extends ih{constructor(t,e,r,i,s,o){super(t,e,r,r,i,s,o),this.isArcCurve=!0,this.type="ArcCurve"}}function sh(){let n=0,t=0,e=0,r=0;function i(s,o,a,l){n=s,t=a,e=-3*s+3*o-2*a-l,r=2*s-2*o+a+l}return{initCatmullRom:function(s,o,a,l,c){i(o,a,c*(a-s),c*(l-o))},initNonuniformCatmullRom:function(s,o,a,l,c,h,f){let g=(o-s)/c-(a-s)/(c+h)+(a-o)/h,p=(a-o)/h-(l-o)/(h+f)+(l-a)/f;g*=h,p*=h,i(o,a,g,p)},calc:function(s){const o=s*s,a=o*s;return n+t*s+e*o+r*a}}}const gu=new D,oh=new sh,ah=new sh,uh=new sh;class FS extends xn{constructor(t=[],e=!1,r="centripetal",i=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=t,this.closed=e,this.curveType=r,this.tension=i}getPoint(t,e=new D){const r=e,i=this.points,s=i.length,o=(s-(this.closed?0:1))*t;let a=Math.floor(o),l=o-a;this.closed?a+=a>0?0:(Math.floor(Math.abs(a)/s)+1)*s:l===0&&a===s-1&&(a=s-2,l=1);let c,h;this.closed||a>0?c=i[(a-1)%s]:(gu.subVectors(i[0],i[1]).add(i[0]),c=gu);const f=i[a%s],g=i[(a+1)%s];if(this.closed||a+2<s?h=i[(a+2)%s]:(gu.subVectors(i[s-1],i[s-2]).add(i[s-1]),h=gu),this.curveType==="centripetal"||this.curveType==="chordal"){const p=this.curveType==="chordal"?.5:.25;let m=Math.pow(c.distanceToSquared(f),p),v=Math.pow(f.distanceToSquared(g),p),_=Math.pow(g.distanceToSquared(h),p);v<1e-4&&(v=1),m<1e-4&&(m=v),_<1e-4&&(_=v),oh.initNonuniformCatmullRom(c.x,f.x,g.x,h.x,m,v,_),ah.initNonuniformCatmullRom(c.y,f.y,g.y,h.y,m,v,_),uh.initNonuniformCatmullRom(c.z,f.z,g.z,h.z,m,v,_)}else this.curveType==="catmullrom"&&(oh.initCatmullRom(c.x,f.x,g.x,h.x,this.tension),ah.initCatmullRom(c.y,f.y,g.y,h.y,this.tension),uh.initCatmullRom(c.z,f.z,g.z,h.z,this.tension));return r.set(oh.calc(l),ah.calc(l),uh.calc(l)),r}copy(t){super.copy(t),this.points=[];for(let e=0,r=t.points.length;e<r;e++){const i=t.points[e];this.points.push(i.clone())}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}toJSON(){const t=super.toJSON();t.points=[];for(let e=0,r=this.points.length;e<r;e++){const i=this.points[e];t.points.push(i.toArray())}return t.closed=this.closed,t.curveType=this.curveType,t.tension=this.tension,t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,r=t.points.length;e<r;e++){const i=t.points[e];this.points.push(new D().fromArray(i))}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}}function Im(n,t,e,r,i){const s=(r-t)*.5,o=(i-e)*.5,a=n*n,l=n*a;return(2*e-2*r+s+o)*l+(-3*e+3*r-2*s-o)*a+s*n+e}function NS(n,t){const e=1-n;return e*e*t}function jS(n,t){return 2*(1-n)*n*t}function VS(n,t){return n*n*t}function To(n,t,e,r){return NS(n,t)+jS(n,e)+VS(n,r)}function DS(n,t){const e=1-n;return e*e*e*t}function BS(n,t){const e=1-n;return 3*e*e*n*t}function qS(n,t){return 3*(1-n)*n*n*t}function $S(n,t){return n*n*n*t}function Co(n,t,e,r,i){return DS(n,t)+BS(n,e)+qS(n,r)+$S(n,i)}class km extends xn{constructor(t=new Et,e=new Et,r=new Et,i=new Et){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=t,this.v1=e,this.v2=r,this.v3=i}getPoint(t,e=new Et){const r=e,i=this.v0,s=this.v1,o=this.v2,a=this.v3;return r.set(Co(t,i.x,s.x,o.x,a.x),Co(t,i.y,s.y,o.y,a.y)),r}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}}class HS extends xn{constructor(t=new D,e=new D,r=new D,i=new D){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=t,this.v1=e,this.v2=r,this.v3=i}getPoint(t,e=new D){const r=e,i=this.v0,s=this.v1,o=this.v2,a=this.v3;return r.set(Co(t,i.x,s.x,o.x,a.x),Co(t,i.y,s.y,o.y,a.y),Co(t,i.z,s.z,o.z,a.z)),r}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}}class Pm extends xn{constructor(t=new Et,e=new Et){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=t,this.v2=e}getPoint(t,e=new Et){const r=e;return t===1?r.copy(this.v2):(r.copy(this.v2).sub(this.v1),r.multiplyScalar(t).add(this.v1)),r}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e=new Et){return e.subVectors(this.v2,this.v1).normalize()}getTangentAt(t,e){return this.getTangent(t,e)}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class GS extends xn{constructor(t=new D,e=new D){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=t,this.v2=e}getPoint(t,e=new D){const r=e;return t===1?r.copy(this.v2):(r.copy(this.v2).sub(this.v1),r.multiplyScalar(t).add(this.v1)),r}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e=new D){return e.subVectors(this.v2,this.v1).normalize()}getTangentAt(t,e){return this.getTangent(t,e)}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class Rm extends xn{constructor(t=new Et,e=new Et,r=new Et){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=t,this.v1=e,this.v2=r}getPoint(t,e=new Et){const r=e,i=this.v0,s=this.v1,o=this.v2;return r.set(To(t,i.x,s.x,o.x),To(t,i.y,s.y,o.y)),r}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class WS extends xn{constructor(t=new D,e=new D,r=new D){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=t,this.v1=e,this.v2=r}getPoint(t,e=new D){const r=e,i=this.v0,s=this.v1,o=this.v2;return r.set(To(t,i.x,s.x,o.x),To(t,i.y,s.y,o.y),To(t,i.z,s.z,o.z)),r}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class Lm extends xn{constructor(t=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=t}getPoint(t,e=new Et){const r=e,i=this.points,s=(i.length-1)*t,o=Math.floor(s),a=s-o,l=i[o===0?o:o-1],c=i[o],h=i[o>i.length-2?i.length-1:o+1],f=i[o>i.length-3?i.length-1:o+2];return r.set(Im(a,l.x,c.x,h.x,f.x),Im(a,l.y,c.y,h.y,f.y)),r}copy(t){super.copy(t),this.points=[];for(let e=0,r=t.points.length;e<r;e++){const i=t.points[e];this.points.push(i.clone())}return this}toJSON(){const t=super.toJSON();t.points=[];for(let e=0,r=this.points.length;e<r;e++){const i=this.points[e];t.points.push(i.toArray())}return t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,r=t.points.length;e<r;e++){const i=t.points[e];this.points.push(new Et().fromArray(i))}return this}}var Fm=Object.freeze({__proto__:null,ArcCurve:LS,CatmullRomCurve3:FS,CubicBezierCurve:km,CubicBezierCurve3:HS,EllipseCurve:ih,LineCurve:Pm,LineCurve3:GS,QuadraticBezierCurve:Rm,QuadraticBezierCurve3:WS,SplineCurve:Lm});class US extends xn{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(t){this.curves.push(t)}closePath(){const t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1);if(!t.equals(e)){const r=t.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new Fm[r](e,t))}return this}getPoint(t,e){const r=t*this.getLength(),i=this.getCurveLengths();let s=0;for(;s<i.length;){if(i[s]>=r){const o=i[s]-r,a=this.curves[s],l=a.getLength(),c=l===0?0:1-o/l;return a.getPointAt(c,e)}s++}return null}getLength(){const t=this.getCurveLengths();return t[t.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const t=[];let e=0;for(let r=0,i=this.curves.length;r<i;r++)e+=this.curves[r].getLength(),t.push(e);return this.cacheLengths=t,t}getSpacedPoints(t=40){const e=[];for(let r=0;r<=t;r++)e.push(this.getPoint(r/t));return this.autoClose&&e.push(e[0]),e}getPoints(t=12){const e=[];let r;for(let i=0,s=this.curves;i<s.length;i++){const o=s[i],a=o.isEllipseCurve?t*2:o.isLineCurve||o.isLineCurve3?1:o.isSplineCurve?t*o.points.length:t,l=o.getPoints(a);for(let c=0;c<l.length;c++){const h=l[c];r&&r.equals(h)||(e.push(h),r=h)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}copy(t){super.copy(t),this.curves=[];for(let e=0,r=t.curves.length;e<r;e++){const i=t.curves[e];this.curves.push(i.clone())}return this.autoClose=t.autoClose,this}toJSON(){const t=super.toJSON();t.autoClose=this.autoClose,t.curves=[];for(let e=0,r=this.curves.length;e<r;e++){const i=this.curves[e];t.curves.push(i.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.autoClose=t.autoClose,this.curves=[];for(let e=0,r=t.curves.length;e<r;e++){const i=t.curves[e];this.curves.push(new Fm[i.type]().fromJSON(i))}return this}}class Nm extends US{constructor(t){super(),this.type="Path",this.currentPoint=new Et,t&&this.setFromPoints(t)}setFromPoints(t){this.moveTo(t[0].x,t[0].y);for(let e=1,r=t.length;e<r;e++)this.lineTo(t[e].x,t[e].y);return this}moveTo(t,e){return this.currentPoint.set(t,e),this}lineTo(t,e){const r=new Pm(this.currentPoint.clone(),new Et(t,e));return this.curves.push(r),this.currentPoint.set(t,e),this}quadraticCurveTo(t,e,r,i){const s=new Rm(this.currentPoint.clone(),new Et(t,e),new Et(r,i));return this.curves.push(s),this.currentPoint.set(r,i),this}bezierCurveTo(t,e,r,i,s,o){const a=new km(this.currentPoint.clone(),new Et(t,e),new Et(r,i),new Et(s,o));return this.curves.push(a),this.currentPoint.set(s,o),this}splineThru(t){const e=[this.currentPoint.clone()].concat(t),r=new Lm(e);return this.curves.push(r),this.currentPoint.copy(t[t.length-1]),this}arc(t,e,r,i,s,o){const a=this.currentPoint.x,l=this.currentPoint.y;return this.absarc(t+a,e+l,r,i,s,o),this}absarc(t,e,r,i,s,o){return this.absellipse(t,e,r,r,i,s,o),this}ellipse(t,e,r,i,s,o,a,l){const c=this.currentPoint.x,h=this.currentPoint.y;return this.absellipse(t+c,e+h,r,i,s,o,a,l),this}absellipse(t,e,r,i,s,o,a,l){const c=new ih(t,e,r,i,s,o,a,l);if(this.curves.length>0){const f=c.getPoint(0);f.equals(this.currentPoint)||this.lineTo(f.x,f.y)}this.curves.push(c);const h=c.getPoint(1);return this.currentPoint.copy(h),this}copy(t){return super.copy(t),this.currentPoint.copy(t.currentPoint),this}toJSON(){const t=super.toJSON();return t.currentPoint=this.currentPoint.toArray(),t}fromJSON(t){return super.fromJSON(t),this.currentPoint.fromArray(t.currentPoint),this}}class lh extends Nm{constructor(t){super(t),this.uuid=ds(),this.type="Shape",this.holes=[]}getPointsHoles(t){const e=[];for(let r=0,i=this.holes.length;r<i;r++)e[r]=this.holes[r].getPoints(t);return e}extractPoints(t){return{shape:this.getPoints(t),holes:this.getPointsHoles(t)}}copy(t){super.copy(t),this.holes=[];for(let e=0,r=t.holes.length;e<r;e++){const i=t.holes[e];this.holes.push(i.clone())}return this}toJSON(){const t=super.toJSON();t.uuid=this.uuid,t.holes=[];for(let e=0,r=this.holes.length;e<r;e++){const i=this.holes[e];t.holes.push(i.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.uuid=t.uuid,this.holes=[];for(let e=0,r=t.holes.length;e<r;e++){const i=t.holes[e];this.holes.push(new Nm().fromJSON(i))}return this}}function YS(n,t,e=2){const r=t&&t.length,i=r?t[0]*e:n.length;let s=jm(n,0,i,e,!0);const o=[];if(!s||s.next===s.prev)return o;let a,l,c;if(r&&(s=QS(n,t,s,e)),n.length>80*e){a=1/0,l=1/0;let h=-1/0,f=-1/0;for(let g=e;g<i;g+=e){const p=n[g],m=n[g+1];p<a&&(a=p),m<l&&(l=m),p>h&&(h=p),m>f&&(f=m)}c=Math.max(h-a,f-l),c=c!==0?32767/c:0}return Io(s,o,e,a,l,c,0),o}function jm(n,t,e,r,i){let s;if(i===c2(n,t,e,r)>0)for(let o=t;o<e;o+=r)s=qm(o/r|0,n[o],n[o+1],s);else for(let o=e-r;o>=t;o-=r)s=qm(o/r|0,n[o],n[o+1],s);return s&&Is(s,s.next)&&(Ro(s),s=s.next),s}function zi(n,t){if(!n)return n;t||(t=n);let e=n,r;do if(r=!1,!e.steiner&&(Is(e,e.next)||he(e.prev,e,e.next)===0)){if(Ro(e),e=t=e.prev,e===e.next)break;r=!0}else e=e.next;while(r||e!==t);return t}function Io(n,t,e,r,i,s,o){if(!n)return;!o&&s&&i2(n,r,i,s);let a=n;for(;n.prev!==n.next;){const l=n.prev,c=n.next;if(s?JS(n,r,i,s):XS(n)){t.push(l.i,n.i,c.i),Ro(n),n=c.next,a=c.next;continue}if(n=c,n===a){o?o===1?(n=ZS(zi(n),t),Io(n,t,e,r,i,s,2)):o===2&&KS(n,t,e,r,i,s):Io(zi(n),t,e,r,i,s,1);break}}}function XS(n){const t=n.prev,e=n,r=n.next;if(he(t,e,r)>=0)return!1;const i=t.x,s=e.x,o=r.x,a=t.y,l=e.y,c=r.y,h=Math.min(i,s,o),f=Math.min(a,l,c),g=Math.max(i,s,o),p=Math.max(a,l,c);let m=r.next;for(;m!==t;){if(m.x>=h&&m.x<=g&&m.y>=f&&m.y<=p&&ko(i,a,s,l,o,c,m.x,m.y)&&he(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function JS(n,t,e,r){const i=n.prev,s=n,o=n.next;if(he(i,s,o)>=0)return!1;const a=i.x,l=s.x,c=o.x,h=i.y,f=s.y,g=o.y,p=Math.min(a,l,c),m=Math.min(h,f,g),v=Math.max(a,l,c),_=Math.max(h,f,g),S=ch(p,m,t,e,r),M=ch(v,_,t,e,r);let C=n.prevZ,O=n.nextZ;for(;C&&C.z>=S&&O&&O.z<=M;){if(C.x>=p&&C.x<=v&&C.y>=m&&C.y<=_&&C!==i&&C!==o&&ko(a,h,l,f,c,g,C.x,C.y)&&he(C.prev,C,C.next)>=0||(C=C.prevZ,O.x>=p&&O.x<=v&&O.y>=m&&O.y<=_&&O!==i&&O!==o&&ko(a,h,l,f,c,g,O.x,O.y)&&he(O.prev,O,O.next)>=0))return!1;O=O.nextZ}for(;C&&C.z>=S;){if(C.x>=p&&C.x<=v&&C.y>=m&&C.y<=_&&C!==i&&C!==o&&ko(a,h,l,f,c,g,C.x,C.y)&&he(C.prev,C,C.next)>=0)return!1;C=C.prevZ}for(;O&&O.z<=M;){if(O.x>=p&&O.x<=v&&O.y>=m&&O.y<=_&&O!==i&&O!==o&&ko(a,h,l,f,c,g,O.x,O.y)&&he(O.prev,O,O.next)>=0)return!1;O=O.nextZ}return!0}function ZS(n,t){let e=n;do{const r=e.prev,i=e.next.next;!Is(r,i)&&Dm(r,e,e.next,i)&&Po(r,i)&&Po(i,r)&&(t.push(r.i,e.i,i.i),Ro(e),Ro(e.next),e=n=i),e=e.next}while(e!==n);return zi(e)}function KS(n,t,e,r,i,s){let o=n;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&a2(o,a)){let l=Bm(o,a);o=zi(o,o.next),l=zi(l,l.next),Io(o,t,e,r,i,s,0),Io(l,t,e,r,i,s,0);return}a=a.next}o=o.next}while(o!==n)}function QS(n,t,e,r){const i=[];for(let s=0,o=t.length;s<o;s++){const a=t[s]*r,l=s<o-1?t[s+1]*r:n.length,c=jm(n,a,l,r,!1);c===c.next&&(c.steiner=!0),i.push(o2(c))}i.sort(t2);for(let s=0;s<i.length;s++)e=e2(i[s],e);return e}function t2(n,t){let e=n.x-t.x;if(e===0&&(e=n.y-t.y,e===0)){const r=(n.next.y-n.y)/(n.next.x-n.x),i=(t.next.y-t.y)/(t.next.x-t.x);e=r-i}return e}function e2(n,t){const e=r2(n,t);if(!e)return t;const r=Bm(e,n);return zi(r,r.next),zi(e,e.next)}function r2(n,t){let e=t;const r=n.x,i=n.y;let s=-1/0,o;if(Is(n,e))return e;do{if(Is(n,e.next))return e.next;if(i<=e.y&&i>=e.next.y&&e.next.y!==e.y){const f=e.x+(i-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(f<=r&&f>s&&(s=f,o=e.x<e.next.x?e:e.next,f===r))return o}e=e.next}while(e!==t);if(!o)return null;const a=o,l=o.x,c=o.y;let h=1/0;e=o;do{if(r>=e.x&&e.x>=l&&r!==e.x&&Vm(i<c?r:s,i,l,c,i<c?s:r,i,e.x,e.y)){const f=Math.abs(i-e.y)/(r-e.x);Po(e,n)&&(f<h||f===h&&(e.x>o.x||e.x===o.x&&n2(o,e)))&&(o=e,h=f)}e=e.next}while(e!==a);return o}function n2(n,t){return he(n.prev,n,t.prev)<0&&he(t.next,n,n.next)<0}function i2(n,t,e,r){let i=n;do i.z===0&&(i.z=ch(i.x,i.y,t,e,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==n);i.prevZ.nextZ=null,i.prevZ=null,s2(i)}function s2(n){let t,e=1;do{let r=n,i;n=null;let s=null;for(t=0;r;){t++;let o=r,a=0;for(let c=0;c<e&&(a++,o=o.nextZ,!!o);c++);let l=e;for(;a>0||l>0&&o;)a!==0&&(l===0||!o||r.z<=o.z)?(i=r,r=r.nextZ,a--):(i=o,o=o.nextZ,l--),s?s.nextZ=i:n=i,i.prevZ=s,s=i;r=o}s.nextZ=null,e*=2}while(t>1);return n}function ch(n,t,e,r,i){return n=(n-e)*i|0,t=(t-r)*i|0,n=(n|n<<8)&16711935,n=(n|n<<4)&252645135,n=(n|n<<2)&858993459,n=(n|n<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,n|t<<1}function o2(n){let t=n,e=n;do(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==n);return e}function Vm(n,t,e,r,i,s,o,a){return(i-o)*(t-a)>=(n-o)*(s-a)&&(n-o)*(r-a)>=(e-o)*(t-a)&&(e-o)*(s-a)>=(i-o)*(r-a)}function ko(n,t,e,r,i,s,o,a){return!(n===o&&t===a)&&Vm(n,t,e,r,i,s,o,a)}function a2(n,t){return n.next.i!==t.i&&n.prev.i!==t.i&&!u2(n,t)&&(Po(n,t)&&Po(t,n)&&l2(n,t)&&(he(n.prev,n,t.prev)||he(n,t.prev,t))||Is(n,t)&&he(n.prev,n,n.next)>0&&he(t.prev,t,t.next)>0)}function he(n,t,e){return(t.y-n.y)*(e.x-t.x)-(t.x-n.x)*(e.y-t.y)}function Is(n,t){return n.x===t.x&&n.y===t.y}function Dm(n,t,e,r){const i=yu(he(n,t,e)),s=yu(he(n,t,r)),o=yu(he(e,r,n)),a=yu(he(e,r,t));return!!(i!==s&&o!==a||i===0&&mu(n,e,t)||s===0&&mu(n,r,t)||o===0&&mu(e,n,r)||a===0&&mu(e,t,r))}function mu(n,t,e){return t.x<=Math.max(n.x,e.x)&&t.x>=Math.min(n.x,e.x)&&t.y<=Math.max(n.y,e.y)&&t.y>=Math.min(n.y,e.y)}function yu(n){return n>0?1:n<0?-1:0}function u2(n,t){let e=n;do{if(e.i!==n.i&&e.next.i!==n.i&&e.i!==t.i&&e.next.i!==t.i&&Dm(e,e.next,n,t))return!0;e=e.next}while(e!==n);return!1}function Po(n,t){return he(n.prev,n,n.next)<0?he(n,t,n.next)>=0&&he(n,n.prev,t)>=0:he(n,t,n.prev)<0||he(n,n.next,t)<0}function l2(n,t){let e=n,r=!1;const i=(n.x+t.x)/2,s=(n.y+t.y)/2;do e.y>s!=e.next.y>s&&e.next.y!==e.y&&i<(e.next.x-e.x)*(s-e.y)/(e.next.y-e.y)+e.x&&(r=!r),e=e.next;while(e!==n);return r}function Bm(n,t){const e=hh(n.i,n.x,n.y),r=hh(t.i,t.x,t.y),i=n.next,s=t.prev;return n.next=t,t.prev=n,e.next=i,i.prev=e,r.next=e,e.prev=r,s.next=r,r.prev=s,r}function qm(n,t,e,r){const i=hh(n,t,e);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function Ro(n){n.next.prev=n.prev,n.prev.next=n.next,n.prevZ&&(n.prevZ.nextZ=n.nextZ),n.nextZ&&(n.nextZ.prevZ=n.prevZ)}function hh(n,t,e){return{i:n,x:t,y:e,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function c2(n,t,e,r){let i=0;for(let s=t,o=e-r;s<e;s+=r)i+=(n[o]-n[s])*(n[s+1]+n[o+1]),o=s;return i}class h2{static triangulate(t,e,r=2){return YS(t,e,r)}}class Lo{static area(t){const e=t.length;let r=0;for(let i=e-1,s=0;s<e;i=s++)r+=t[i].x*t[s].y-t[s].x*t[i].y;return r*.5}static isClockWise(t){return Lo.area(t)<0}static triangulateShape(t,e){const r=[],i=[],s=[];$m(t),Hm(r,t);let o=t.length;e.forEach($m);for(let l=0;l<e.length;l++)i.push(o),o+=e[l].length,Hm(r,e[l]);const a=h2.triangulate(r,i);for(let l=0;l<a.length;l+=3)s.push(a.slice(l,l+3));return s}}function $m(n){const t=n.length;t>2&&n[t-1].equals(n[0])&&n.pop()}function Hm(n,t){for(let e=0;e<t.length;e++)n.push(t[e].x),n.push(t[e].y)}class fh extends Ai{constructor(t=new lh([new Et(0,.5),new Et(-.5,-.5),new Et(.5,-.5)]),e=12){super(),this.type="ShapeGeometry",this.parameters={shapes:t,curveSegments:e};const r=[],i=[],s=[],o=[];let a=0,l=0;if(Array.isArray(t)===!1)c(t);else for(let h=0;h<t.length;h++)c(t[h]),this.addGroup(a,l,h),a+=l,l=0;this.setIndex(r),this.setAttribute("position",new jn(i,3)),this.setAttribute("normal",new jn(s,3)),this.setAttribute("uv",new jn(o,2));function c(h){const f=i.length/3,g=h.extractPoints(e);let p=g.shape;const m=g.holes;Lo.isClockWise(p)===!1&&(p=p.reverse());for(let _=0,S=m.length;_<S;_++){const M=m[_];Lo.isClockWise(M)===!0&&(m[_]=M.reverse())}const v=Lo.triangulateShape(p,m);for(let _=0,S=m.length;_<S;_++){const M=m[_];p=p.concat(M)}for(let _=0,S=p.length;_<S;_++){const M=p[_];i.push(M.x,M.y,0),s.push(0,0,1),o.push(M.x,M.y)}for(let _=0,S=v.length;_<S;_++){const M=v[_],C=M[0]+f,O=M[1]+f,E=M[2]+f;r.push(C,O,E),l+=3}}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}toJSON(){const t=super.toJSON(),e=this.parameters.shapes;return f2(e,t)}static fromJSON(t,e){const r=[];for(let i=0,s=t.shapes.length;i<s;i++){const o=e[t.shapes[i]];r.push(o)}return new fh(r,t.curveSegments)}}function f2(n,t){if(t.shapes=[],Array.isArray(n))for(let e=0,r=n.length;e<r;e++){const i=n[e];t.shapes.push(i.uuid)}else t.shapes.push(n.uuid);return t}class d2 extends Om{constructor(t){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Mi(16777215),this.specular=new Mi(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Mi(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=hS,this.normalScale=new Et(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ws,this.combine=nm,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.specular.copy(t.specular),this.shininess=t.shininess,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}const dh={enabled:!1,files:{},add:function(n,t){this.enabled!==!1&&(this.files[n]=t)},get:function(n){if(this.enabled!==!1)return this.files[n]},remove:function(n){delete this.files[n]},clear:function(){this.files={}}};class p2{constructor(t,e,r){const i=this;let s=!1,o=0,a=0,l;const c=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=r,this.abortController=new AbortController,this.itemStart=function(h){a++,s===!1&&i.onStart!==void 0&&i.onStart(h,o,a),s=!0},this.itemEnd=function(h){o++,i.onProgress!==void 0&&i.onProgress(h,o,a),o===a&&(s=!1,i.onLoad!==void 0&&i.onLoad())},this.itemError=function(h){i.onError!==void 0&&i.onError(h)},this.resolveURL=function(h){return l?l(h):h},this.setURLModifier=function(h){return l=h,this},this.addHandler=function(h,f){return c.push(h,f),this},this.removeHandler=function(h){const f=c.indexOf(h);return f!==-1&&c.splice(f,2),this},this.getHandler=function(h){for(let f=0,g=c.length;f<g;f+=2){const p=c[f],m=c[f+1];if(p.global&&(p.lastIndex=0),p.test(h))return m}return null},this.abort=function(){return this.abortController.abort(),this.abortController=new AbortController,this}}}const g2=new p2;class ph{constructor(t){this.manager=t!==void 0?t:g2,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(t,e){const r=this;return new Promise(function(i,s){r.load(t,i,e,s)})}parse(){}setCrossOrigin(t){return this.crossOrigin=t,this}setWithCredentials(t){return this.withCredentials=t,this}setPath(t){return this.path=t,this}setResourcePath(t){return this.resourcePath=t,this}setRequestHeader(t){return this.requestHeader=t,this}abort(){return this}}ph.DEFAULT_MATERIAL_NAME="__DEFAULT";const ks=new WeakMap;class m2 extends ph{constructor(t){super(t)}load(t,e,r,i){this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);const s=this,o=dh.get(`image:${t}`);if(o!==void 0){if(o.complete===!0)s.manager.itemStart(t),setTimeout(function(){e&&e(o),s.manager.itemEnd(t)},0);else{let f=ks.get(o);f===void 0&&(f=[],ks.set(o,f)),f.push({onLoad:e,onError:i})}return o}const a=Vc("img");function l(){h(),e&&e(this);const f=ks.get(this)||[];for(let g=0;g<f.length;g++){const p=f[g];p.onLoad&&p.onLoad(this)}ks.delete(this),s.manager.itemEnd(t)}function c(f){h(),i&&i(f),dh.remove(`image:${t}`);const g=ks.get(this)||[];for(let p=0;p<g.length;p++){const m=g[p];m.onError&&m.onError(f)}ks.delete(this),s.manager.itemError(t),s.manager.itemEnd(t)}function h(){a.removeEventListener("load",l,!1),a.removeEventListener("error",c,!1)}return a.addEventListener("load",l,!1),a.addEventListener("error",c,!1),t.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(a.crossOrigin=this.crossOrigin),dh.add(`image:${t}`,a),s.manager.itemStart(t),a.src=t,a}}class Gm extends ph{constructor(t){super(t)}load(t,e,r,i){const s=new ti,o=new m2(this.manager);return o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(t,function(a){s.image=a,s.needsUpdate=!0,e!==void 0&&e(s)},r,i),s}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Zg}})),typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Zg);class y2{constructor(t=ln){Vt(this,"elements");Vt(this,"categories");Vt(this,"propertyTypes");Vt(this,"unit");this.elements={},this.categories={root:{name:"root",label:"/",elements:[],categories:[]}},this.propertyTypes={},this.unit=t,this.registerMultiplePropertyType([["color",qg,qg],["enum",$g,$g],["string",Hg,Hg],["number",Gg,Gg],["length-measure",Wg,Wg],["toggle",Ug,Ug],["checkbox",Yg,Yg],["hidden",Xg,Xg],["read-only",Jg,Jg]])}getElement(t){if(this.hasElement(t))return this.elements[t];throw new Error(`Element ${t} does not exist in catalog`)}getCategory(t){if(this.hasCategory(t))return this.categories[t];throw new Error(`Category ${t} does not exist in catalog`)}getPropertyType(t){if(this.propertyTypes.hasOwnProperty(t))return this.propertyTypes[t];throw new Error(`Element ${t} does not exist in catalog`)}registerElement(t){t.properties=t.properties||{},this.validateElement(t)&&(this.elements[t.name]=t,this.categories.root.elements.push(this.elements[t.name]))}registerMultipleElements(t){t.forEach(e=>this.registerElement(e))}registerPropertyType(t,e,r){this.propertyTypes[t]={type:t,Viewer:e,Editor:r}}registerMultiplePropertyType(t){t.forEach(e=>this.registerPropertyType(...e))}validateElement(t){if(!t.hasOwnProperty("name"))throw new Error("Element not valid");let e=t.name;if(!t.hasOwnProperty("prototype"))throw new Error(`Element ${e} doesn't have prototype`);if(!t.hasOwnProperty("info"))throw new Error(`Element ${e} doesn't have info`);if(!t.info.hasOwnProperty("tag"))throw new Error(`Element ${e} doesn't have tag`);if(!t.info.hasOwnProperty("description"))throw new Error(`Element ${e} doesn't have description`);if(!t.info.hasOwnProperty("image"))throw new Error(`Element ${e} doesn't have image`);if(!t.hasOwnProperty("render2D"))throw new Error(`Element ${e} doesn't have render2D handler`);if(!t.hasOwnProperty("render3D"))throw new Error(`Element ${e} doesn't have render3D handler`);if(!t.hasOwnProperty("properties"))throw new Error(`Element ${e} doesn't have properties`);for(let r in t.properties){let i=t.properties[r];if(!i.hasOwnProperty("type"))throw new Error(`Element ${e}, Property ${r} doesn't have type`);if(!i.hasOwnProperty("defaultValue"))throw new Error(`Element ${e}, Property ${r} doesn't have defaultValue`)}return!0}hasElement(t){return this.elements.hasOwnProperty(t)}registerCategory(t,e,r){return this.validateCategory(t,e)?(this.categories[t]={name:t,label:e,categories:[],elements:[]},this.categories.root.categories.push(this.categories[t]),r&&r.length&&r.forEach(i=>this.addToCategory(t,i)),this.categories[t]):null}addToCategory(t,e){if(this.hasElement(e.name))this.categories[t].elements.push(e),this.categories.root.elements.splice(this.categories.root.elements.indexOf(e),1);else if(this.hasCategory(e.name))this.categories[t].categories.push(e),this.categories.root.categories.splice(this.categories.root.categories.indexOf(e),1);else throw new Error(`child ${e} is either category nor element`)}categoryHasElement(t,e){return this.hasCategory(t)&&this.categories[t].elements.some(r=>r.name===e)}validateCategory(t,e){if(!t)throw new Error("Category has undefined name");if(t==="")throw new Error("Category has empty name");if(this.hasCategory(t))throw new Error("Category has already been registered");return!0}hasCategory(t){return this.categories.hasOwnProperty(t)}}function v2(n){return ge({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M10 18a7.952 7.952 0 0 0 4.897-1.688l4.396 4.396 1.414-1.414-4.396-4.396A7.952 7.952 0 0 0 18 10c0-4.411-3.589-8-8-8s-8 3.589-8 8 3.589 8 8 8zm0-14c3.309 0 6 2.691 6 6s-2.691 6-6 6-6-2.691-6-6 2.691-6 6-6z"},child:[]}]})(n)}const x2=({term:n="",placeholder:t="Search",noSpacing:e=!1,onClick:r=()=>!1,isStatic:i=!1,hasDropDown:s=!1,onSearch:o,className:a})=>{const[l,c]=F.useState("");return w.jsxs("div",{className:Hr(`relative w-full ${e?"mt-1":"mt-2"}`,a),onClick:r??(()=>!1),children:[w.jsx("span",{className:`absolute left-0 top-2 text-[#637381] ${e?"":"ml-2"}`,style:{zIndex:2},children:w.jsx(v2,{size:18})}),i?w.jsx("div",{className:"w-full rounded border border-gray-300 bg-white px-3 py-1.5 text-xs font-normal cursor-pointer",style:{marginTop:3},children:n}):w.jsx("input",{className:"w-full rounded pl-[30px] focus:outline-none border border-gray-300 bg-white pr-3 py-1.5 text-sm text-gray-900",type:"text",placeholder:t,onChange:h=>{o(h.target.value,h),c(h.target.value)},value:l,onClick:r??(()=>!1)}),r!==null&&s&&w.jsx("span",{className:`absolute right-2 top-1/2 -translate-y-1/2 ${e?"":"ml-2"}`,style:{zIndex:1},children:w.jsx(F1,{className:"-mb-1"})})]})},Wm=8,Um=40,_2=n=>{const t=[{label:"All Categories",value:"all"}],e=n.map(r=>r.info.tag);console.log({paths:e});for(const r of e){let i=t;for(let s=0;s<r.length;s++){const o=r[s];let a=i.find(l=>l.label===o);a||(a={label:o,value:o},s<r.length-1&&(a.options=[{label:"All Categories",value:"all"}]),i.push(a)),s<r.length-1&&a.options&&(i=a.options)}}return console.log({result:t}),t},Ym=({options:n,selections:t,level:e,onChange:r})=>{var i,s;return w.jsxs(w.Fragment,{children:[w.jsx("select",{className:"w-full rounded capitalize cursor-pointer focus:outline-none border border-gray-300 bg-white pr-3 pl-1.5 py-1.5 text-sm text-gray-900",value:t[e]||"all",onChange:o=>r(e,o.target.value),children:n.map(o=>w.jsx("option",{className:"capitalize",value:o.value,children:o.label},o.value))}),t[e]&&t[e]!=="all"&&((i=n.find(o=>o.value===t[e]))==null?void 0:i.options)&&w.jsx(Ym,{options:((s=n.find(o=>o.value===t[e]))==null?void 0:s.options)||[],level:e+1,selections:t,onChange:r})]})},b2=({catalog:n,popupEvent:t,onClose:e})=>{const{selectToolDrawingLine:r,selectToolDrawingItem:i,selectToolDrawingHole:s,pushLastSelectedCatalogElementToHistory:o}=ne(),[a,l]=F.useState([]),[c,h]=F.useState(["all"]),[f,g]=F.useState([]),[p,m]=F.useState(""),v=F.useRef(null),_=F.useRef(null);F.useEffect(()=>{if(t){const E=n.getCategory(t.page).elements.filter(k=>k.info.visibility?k.info.visibility.catalog:!0);v.current=t.page,g(E);const{x:z,y:R}=t.rect;_.current={top:R+Wm,left:z+Um},t.page==="objects"&&(console.log({elementsToDisplay:E}),l(_2(E)))}},[t]);const S=()=>{e()},M=O=>{S(),setTimeout(()=>{switch(O.prototype){case"lines":r(O.name);break;case"items":i(O.name);break;case"holes":s(O.name);break}o(O)},0)},C=(O,E)=>{const z=[...c.slice(0,O),E];h(z)};return w.jsxs(w.Fragment,{children:[t&&w.jsx("div",{className:"fixed inset-0 bg-black/30 z-10",onClick:S}),w.jsxs("div",{style:t&&t.rect?{top:t.rect.y+Wm,left:t.rect.x+Um}:_.current?_.current:{},className:Hr("fixed select-none z-10 shadow-md !gap-0 rounded-lg pt-5 fp_side-bar !min-h-[250px] !max-h-[510px] transition-all duration-200 ease-out transform",t?"opacity-100 scale-100":"opacity-0 scale-95 pointer-events-none"),children:[w.jsxs("header",{className:"px-[18px] sticky top-0 left-0 gap-3 flex flex-col",children:[w.jsx("div",{className:"flex items-center gap-1",children:w.jsx("span",{className:Hr("flex flex-col gap-0.5"),children:w.jsx("span",{className:"fp-sidebar-label capitalize",children:(t==null?void 0:t.page)??v.current})})}),w.jsxs("div",{className:Hr("fp-highlight"),children:[w.jsx(Ym,{options:a,level:0,selections:c,onChange:C}),w.jsx(x2,{className:"mt-0",placeholder:"Search",onSearch:(O,E)=>{E.preventDefault(),E.stopPropagation(),m(O)}})]})]}),f.filter(O=>O.info.title.toLowerCase().includes(p.toLowerCase())&&c.every(E=>E==="all"||O.info.tag.includes(E))).length>0?w.jsx("div",{className:"grid grid-cols-2 gap-x-4 gap-y-6 pb-5 overflow-auto w-full pt-[18px] px-4",onWheel:O=>O.stopPropagation(),children:f.filter(O=>O.info.title.toLowerCase().includes(p.toLowerCase())&&c.every(E=>E==="all"||O.info.tag.includes(E))).map(O=>w.jsxs("div",{className:"w-full space-y-1.5",children:[w.jsx("div",{className:"fp-aspect-ratio-container",children:w.jsx("div",{className:"fp-aspect-ratio-content",onMouseDown:()=>M(O),children:w.jsx("img",{draggable:!1,className:"fp-item-image",alt:O.info.title,src:O.info.image})})}),w.jsx("p",{className:"text-xs font-semibold capitalize",children:O.info.description})]},O.name.replace(/\s+/g,"_")))}):w.jsx("div",{className:"min-h-28 w-full flex items-center justify-center",children:w.jsx("p",{className:"text-sm font-medium text-gray-400 text-center",children:"No records found"})})]})]})};function w2(n){return ge({attr:{viewBox:"0 0 576 512"},child:[{tag:"path",attr:{d:"M320 32c0-9.9-4.5-19.2-12.3-25.2S289.8-1.4 280.2 1l-179.9 45C79 51.3 64 70.5 64 92.5L64 448l-32 0c-17.7 0-32 14.3-32 32s14.3 32 32 32l64 0 192 0 32 0 0-32 0-448zM256 256c0 17.7-10.7 32-24 32s-24-14.3-24-32s10.7-32 24-32s24 14.3 24 32zm96-128l96 0 0 352c0 17.7 14.3 32 32 32l64 0c17.7 0 32-14.3 32-32s-14.3-32-32-32l-32 0 0-320c0-35.3-28.7-64-64-64l-96 0 0 64z"},child:[]}]})(n)}function S2(n){return ge({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M112 73c-13.75 0-24.214 4.87-33.047 13.271-8.832 8.402-15.755 20.6-20.414 34.575-5.887 17.661-7.953 38.064-6.887 56.111a57.246 57.246 0 0 1 2.461-.187c8.38-.405 16.317 1.094 23.494 4.234 14.355 6.28 25.436 18.27 34.057 32.28 15.104 24.543 23.187 55.746 24.96 80.585 114.097-14.223 124.655-14.223 238.753 0 1.772-24.84 9.855-56.042 24.959-80.586 8.62-14.009 19.702-25.999 34.057-32.28 7.875-3.444 16.67-4.898 25.955-4.046 1.066-18.047-1-38.45-6.887-56.111-4.659-13.976-11.582-26.173-20.414-34.575C424.214 77.87 413.75 73 400 73zM56.969 194.502c-.686-.008-1.38.006-2.082.04-5.621.284-11.8 1.978-18.862 5.509-23.413 11.707-26.349 65.687 14.82 79.41l4.505 1.502L86.79 391h338.42l31.44-110.037 4.504-1.502c41.17-13.723 38.234-67.703 14.82-79.41-14.121-7.061-24.722-6.775-34.367-2.555-9.645 4.22-18.564 13.23-25.943 25.22C400.906 246.7 393 282 393 304v10.195l-10.117-1.265c-128-16-125.766-16-253.766 0L119 314.195V304c0-22-7.906-57.3-22.664-81.283-7.38-11.991-16.298-21.001-25.943-25.22-4.22-1.847-8.624-2.94-13.424-2.995zM83.727 409l-23.272 23.271c11.994 3.239 33.75 3.763 42.545-1.666 3.272-4.695 6.903-14.536 10.438-21.605zm314.836 0c1.494 6.017 6.952 19.12 10.437 21.605 13.2 5.463 29.904 5.774 42.545 1.666L428.273 409z"},child:[]}]})(n)}function E2({catalog:n}){const{planner:t,selectTool3DView:e,setMode:r,selectTool3DFirstPerson:i,selectToolDrawingLine:s}=ne(),{mode:o,alterate:a}=t,[l,c]=F.useState(null);return w.jsxs(w.Fragment,{children:[w.jsxs("aside",{className:"floor_planner-toolbar max-h-full max-w-[50px] p-2.5 space-y-4 bg-[#2b2b2b]",children:[w.jsx(In,{active:[Lr,or].includes(o),tooltip:"Draw wall",onClick:()=>s("wall"),children:w.jsx(tS,{})}),w.jsx(In,{active:!!([ar].includes(o)&&l&&l.page==="windows"),tooltip:"Place windows",onClick:h=>{c({rect:h.currentTarget.getBoundingClientRect(),page:"windows"})},children:w.jsx(Q1,{size:26})}),w.jsx(In,{active:!!([ar].includes(o)&&l&&l.page==="doors"),tooltip:"Place doors",onClick:h=>{c({rect:h.currentTarget.getBoundingClientRect(),page:"doors"})},children:w.jsx(w2,{size:26})}),w.jsx(In,{active:!!([Sr].includes(o)&&l&&l.page==="objects"),tooltip:"Place objects",onClick:h=>{c({rect:h.currentTarget.getBoundingClientRect(),page:"objects"})},children:w.jsx(S2,{size:26})}),w.jsx(Qw,{mode:o})]}),w.jsx(b2,{catalog:n,popupEvent:l,onClose:()=>c(null)})]})}const Fo=window.hasOwnProperty("localStorage")?window.localStorage:!1,M2=500;let gh=null;function A2(n,t){return(e,r,i)=>{let s;if(t=t||M2,!!n&&Fo){if(r){e.setPlan(r);const o=r.floors[0].floorDesign;s=JSON.parse(o)}else if(Fo.getItem(n)!==null){const o=Fo.getItem(n);s=JSON.parse(o)}s&&e.loadProject(s),ne.subscribe(o=>{gh&&clearTimeout(gh),gh=setTimeout(()=>{const a=Fo.getItem(n),l=JSON.stringify(o.planner.scene.toJS());if(a!==l&&(Fo.setItem(n,l),o.plan))try{const c=o.plan.floors[o.activeFloor];i&&i({floor:{floorID:c.floorID,title:c.floorTitle,description:c.floorDescription,design:l}})}catch{}},t)})}}}function O2(){return n=>{window.addEventListener("keydown",t=>{const e=n.planner,r=e.get("mode");switch(t.keyCode){case Er.BACKSPACE:case Er.DELETE:{[fe,Qi,vi].includes(r)&&n.remove();break}case Er.ESC:{n.rollback();break}case Er.Z:{(t.getModifierState("Control")||t.getModifierState("Meta"))&&(t.getModifierState("Shift")?n.redo():n.undo());break}case Er.ALT:{Tl.includes(r)&&n.toggleSnap(e.snapMask.merge({SNAP_POINT:!1,SNAP_LINE:!1,SNAP_SEGMENT:!1,SNAP_GRID:!1,SNAP_GUIDE:!1,tempSnapConfiguartion:e.snapMask.toJS()}));break}case Er.C:{let i=e.getIn(["scene","selectedLayer"]),s=e.getIn(["scene","layers",i,"selected"]);if((r===fe||r===vi)&&(s.holes.size||s.areas.size||s.items.size||s.lines.size)){if(s.holes.size){let o=e.getIn(["scene","layers",i,"holes",s.holes.get(0)]);n.copyProperties(o.get("properties"))}else if(s.areas.size){const o=e.getIn(["scene","layers",i,"areas",s.areas.get(0)]);n.copyProperties(o.properties)}else if(s.items.size){const o=e.getIn(["scene","layers",i,"items",s.items.get(0)]);n.copyProperties(o.properties)}else if(s.lines.size){const o=e.getIn(["scene","layers",i,"lines",s.lines.get(0)]);n.copyProperties(o.properties)}}break}case Er.V:{n.pasteProperties();break}case Er.CTRL:{n.setAlterateState();break}}}),window.addEventListener("keyup",t=>{const e=n.planner,r=e.get("mode");switch(t.keyCode){case Er.ALT:{Tl.includes(r)&&n.toggleSnap(e.snapMask.merge(e.snapMask.get("tempSnapConfiguartion")));break}case Er.CTRL:{n.setAlterateState();break}}})}}const z2=({onBack:n,onSave:t})=>{const{undo:e,redo:r,plan:i,setPlan:s}=ne(),[o,a]=F.useState(!1),l=()=>{a(!0)},c=h=>{if(!i)return;a(!1);const f=h.target.value.trim();if(f&&f!==(i==null?void 0:i.planTitle)){s({...i,planTitle:f});try{t&&t({title:f,description:""})}catch{}}};return w.jsxs("div",{className:"floor_planner-headerbar border-b border-b-[#5e5e5e] absolute flex items-center justify-between z-[9001] py-[3px] px-[1em] text-xs bg-[#2b2b2b] w-full select-none cursor-default top-0 leading-[14px] text-white m-0",children:[w.jsx(In,{className:"border border-white rounded -ml-1",active:!1,tooltip:"Go Back",onClick:()=>{n&&n()},children:w.jsx(pg,{})}),w.jsx("div",{className:"flex flex-col items-center justify-center",children:o?w.jsx("input",{autoFocus:!0,type:"text",defaultValue:i==null?void 0:i.planTitle,onBlur:c,onKeyDown:h=>{(h.key==="Enter"||h.key==="Escape")&&c(h)},className:"bg-transparent border-b border-gray-400 outline-none text-lg text-center"}):w.jsx("span",{onDoubleClick:l,className:"projectName__fp text-lg",title:(i==null?void 0:i.planTitle)??"Example House",children:(i==null?void 0:i.planTitle)??"Example House"})}),w.jsxs("div",{className:"flex items-center gap-2 relative right-40",children:[w.jsx(In,{active:!1,tooltip:"Undo (CTRL-Z)",onClick:e,children:w.jsx(Z1,{})}),w.jsx(In,{active:!1,tooltip:"Redo (CTRL-SHIFT-Z)",onClick:r,children:w.jsx(J1,{})})]})]})};var mh={exports:{}},Xm;function Jm(){if(Xm)return mh.exports;Xm=1;var n=mh.exports={};return n.forEach=function(t,e){for(var r=0;r<t.length;r++){var i=e(t[r]);if(i)return i}},mh.exports}var yh,Zm;function T2(){return Zm||(Zm=1,yh=function(n){var t=n.stateHandler.getState;function e(o){var a=t(o);return a&&!!a.isDetectable}function r(o){t(o).isDetectable=!0}function i(o){return!!t(o).busy}function s(o,a){t(o).busy=!!a}return{isDetectable:e,markAsDetectable:r,isBusy:i,markBusy:s}}),yh}var vh,Km;function C2(){return Km||(Km=1,vh=function(n){var t={};function e(o){var a=n.get(o);return a===void 0?[]:t[a]||[]}function r(o,a){var l=n.get(o);t[l]||(t[l]=[]),t[l].push(a)}function i(o,a){for(var l=e(o),c=0,h=l.length;c<h;++c)if(l[c]===a){l.splice(c,1);break}}function s(o){var a=e(o);a&&(a.length=0)}return{get:e,add:r,removeListener:i,removeAllListeners:s}}),vh}var xh,Qm;function I2(){return Qm||(Qm=1,xh=function(){var n=1;function t(){return n++}return{generate:t}}),xh}var _h,ty;function k2(){return ty||(ty=1,_h=function(n){var t=n.idGenerator,e=n.stateHandler.getState;function r(s){var o=e(s);return o&&o.id!==void 0?o.id:null}function i(s){var o=e(s);if(!o)throw new Error("setId required the element to have a resize detection state.");var a=t.generate();return o.id=a,a}return{get:r,set:i}}),_h}var bh,ey;function P2(){return ey||(ey=1,bh=function(n){function t(){}var e={log:t,warn:t,error:t};if(!n&&window.console){var r=function(i,s){i[s]=function(){var a=console[s];if(a.apply)a.apply(console,arguments);else for(var l=0;l<arguments.length;l++)a(arguments[l])}};r(e,"log"),r(e,"warn"),r(e,"error")}return e}),bh}var wh={exports:{}},ry;function ny(){if(ry)return wh.exports;ry=1;var n=wh.exports={};return n.isIE=function(t){function e(){var i=navigator.userAgent.toLowerCase();return i.indexOf("msie")!==-1||i.indexOf("trident")!==-1||i.indexOf(" edge/")!==-1}if(!e())return!1;if(!t)return!0;var r=function(){var i,s=3,o=document.createElement("div"),a=o.getElementsByTagName("i");do o.innerHTML="<!--[if gt IE "+ ++s+"]><i></i><![endif]-->";while(a[0]);return s>4?s:i}();return t===r},n.isLegacyOpera=function(){return!!window.opera},wh.exports}var Sh={exports:{}},iy;function R2(){if(iy)return Sh.exports;iy=1;var n=Sh.exports={};n.getOption=t;function t(e,r,i){var s=e[r];return s==null&&i!==void 0?i:s}return Sh.exports}var Eh,sy;function L2(){if(sy)return Eh;sy=1;var n=R2();Eh=function(r){r=r||{};var i=r.reporter,s=n.getOption(r,"async",!0),o=n.getOption(r,"auto",!0);o&&!s&&(i&&i.warn("Invalid options combination. auto=true and async=false is invalid. Setting async=true."),s=!0);var a=t(),l,c=!1;function h(_,S){!c&&o&&s&&a.size()===0&&p(),a.add(_,S)}function f(){for(c=!0;a.size();){var _=a;a=t(),_.process()}c=!1}function g(_){c||(_===void 0&&(_=s),l&&(m(l),l=null),_?p():f())}function p(){l=v(f)}function m(_){var S=clearTimeout;return S(_)}function v(_){var S=function(M){return setTimeout(M,0)};return S(_)}return{add:h,force:g}};function t(){var e={},r=0,i=0,s=0;function o(c,h){h||(h=c,c=0),c>i?i=c:c<s&&(s=c),e[c]||(e[c]=[]),e[c].push(h),r++}function a(){for(var c=s;c<=i;c++)for(var h=e[c],f=0;f<h.length;f++){var g=h[f];g()}}function l(){return r}return{add:o,process:a,size:l}}return Eh}var Mh,oy;function F2(){if(oy)return Mh;oy=1;var n="_erd";function t(i){return i[n]={},e(i)}function e(i){return i[n]}function r(i){delete i[n]}return Mh={initState:t,getState:e,cleanState:r},Mh}var Ah,ay;function N2(){if(ay)return Ah;ay=1;var n=ny();return Ah=function(t){t=t||{};var e=t.reporter,r=t.batchProcessor,i=t.stateHandler.getState;if(!e)throw new Error("Missing required dependency: reporter.");function s(h,f){function g(){f(h)}if(n.isIE(8))i(h).object={proxy:g},h.attachEvent("onresize",g);else{var p=l(h);if(!p)throw new Error("Element is not detectable by this strategy.");p.contentDocument.defaultView.addEventListener("resize",g)}}function o(h){var f=t.important?" !important; ":"; ";return(h.join(f)+f).trim()}function a(h,f,g){g||(g=f,f=h,h=null),h=h||{},h.debug;function p(m,v){var _=o(["display: block","position: absolute","top: 0","left: 0","width: 100%","height: 100%","border: none","padding: 0","margin: 0","opacity: 0","z-index: -1000","pointer-events: none"]),S=!1,M=window.getComputedStyle(m),C=m.offsetWidth,O=m.offsetHeight;i(m).startSize={width:C,height:O};function E(){function z(){if(M.position==="static"){m.style.setProperty("position","relative",h.important?"important":"");var L=function(X,J,at,tt){function bt(yt){return yt.replace(/[^-\d\.]/g,"")}var xt=at[tt];xt!=="auto"&&bt(xt)!=="0"&&(X.warn("An element that is positioned static has style."+tt+"="+xt+" which is ignored due to the static positioning. The element will need to be positioned relative, so the style."+tt+" will be set to 0. Element: ",J),J.style.setProperty(tt,"0",h.important?"important":""))};L(e,m,M,"top"),L(e,m,M,"right"),L(e,m,M,"bottom"),L(e,m,M,"left")}}function R(){S||z();function L(J,at){if(!J.contentDocument){var tt=i(J);tt.checkForObjectDocumentTimeoutId&&window.clearTimeout(tt.checkForObjectDocumentTimeoutId),tt.checkForObjectDocumentTimeoutId=setTimeout(function(){tt.checkForObjectDocumentTimeoutId=0,L(J,at)},100);return}at(J.contentDocument)}var X=this;L(X,function(at){v(m)})}M.position!==""&&(z(),S=!0);var k=document.createElement("object");k.style.cssText=_,k.tabIndex=-1,k.type="text/html",k.setAttribute("aria-hidden","true"),k.onload=R,n.isIE()||(k.data="about:blank"),i(m)&&(m.appendChild(k),i(m).object=k,n.isIE()&&(k.data="about:blank"))}r?r.add(E):E()}n.isIE(8)?g(f):p(f,g)}function l(h){return i(h).object}function c(h){if(i(h)){var f=l(h);f&&(n.isIE(8)?h.detachEvent("onresize",f.proxy):h.removeChild(f),i(h).checkForObjectDocumentTimeoutId&&window.clearTimeout(i(h).checkForObjectDocumentTimeoutId),delete i(h).object)}}return{makeDetectable:a,addListener:s,uninstall:c}},Ah}var Oh,uy;function j2(){if(uy)return Oh;uy=1;var n=Jm().forEach;return Oh=function(t){t=t||{};var e=t.reporter,r=t.batchProcessor,i=t.stateHandler.getState;t.stateHandler.hasState;var s=t.idHandler;if(!r)throw new Error("Missing required dependency: batchProcessor");if(!e)throw new Error("Missing required dependency: reporter.");var o=f(),a="erd_scroll_detection_scrollbar_style",l="erd_scroll_detection_container";function c(E){g(E,a,l)}c(window.document);function h(E){var z=t.important?" !important; ":"; ";return(E.join(z)+z).trim()}function f(){var E=500,z=500,R=document.createElement("div");R.style.cssText=h(["position: absolute","width: "+E*2+"px","height: "+z*2+"px","visibility: hidden","margin: 0","padding: 0"]);var k=document.createElement("div");k.style.cssText=h(["position: absolute","width: "+E+"px","height: "+z+"px","overflow: scroll","visibility: none","top: "+-E*3+"px","left: "+-z*3+"px","visibility: hidden","margin: 0","padding: 0"]),k.appendChild(R),document.body.insertBefore(k,document.body.firstChild);var L=E-k.clientWidth,X=z-k.clientHeight;return document.body.removeChild(k),{width:L,height:X}}function g(E,z,R){function k(at,tt){tt=tt||function(xt){E.head.appendChild(xt)};var bt=E.createElement("style");return bt.innerHTML=at,bt.id=z,tt(bt),bt}if(!E.getElementById(z)){var L=R+"_animation",X=R+"_animation_active",J=`/* Created by the element-resize-detector library. */
|
|
83
|
-
`;
|
|
74
|
+
*/const $g="179",mc=0,Qw=1,tS=2,Hg=1,Gg=100,Wg=204,Ug=205,Yg=3,Xg=0,Jg=300,tn=1e3,Ca=1001,Zg=1002,eS=1006,rS=1008,nS=1009,iS=1015,sS=1023,oS=0,Kg="",Ir="srgb",Qg="srgb-linear",tm="linear",yc="srgb",Hi=7680,em=519,rm=35044,ka=2e3,nm=2001;class Ia{addEventListener(t,e){this._listeners===void 0&&(this._listeners={});const r=this._listeners;r[t]===void 0&&(r[t]=[]),r[t].indexOf(e)===-1&&r[t].push(e)}hasEventListener(t,e){const r=this._listeners;return r===void 0?!1:r[t]!==void 0&&r[t].indexOf(e)!==-1}removeEventListener(t,e){const r=this._listeners;if(r===void 0)return;const i=r[t];if(i!==void 0){const s=i.indexOf(e);s!==-1&&i.splice(s,1)}}dispatchEvent(t){const e=this._listeners;if(e===void 0)return;const r=e[t.type];if(r!==void 0){t.target=this;const i=r.slice(0);for(let s=0,o=i.length;s<o;s++)i[s].call(this,t);t.target=null}}}const Te=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];function Gi(){const n=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(Te[n&255]+Te[n>>8&255]+Te[n>>16&255]+Te[n>>24&255]+"-"+Te[t&255]+Te[t>>8&255]+"-"+Te[t>>16&15|64]+Te[t>>24&255]+"-"+Te[e&63|128]+Te[e>>8&255]+"-"+Te[e>>16&255]+Te[e>>24&255]+Te[r&255]+Te[r>>8&255]+Te[r>>16&255]+Te[r>>24&255]).toLowerCase()}function At(n,t,e){return Math.max(t,Math.min(e,n))}function aS(n,t){return(n%t+t)%t}function vc(n,t,e){return(1-e)*n+e*t}function no(n,t){switch(t.constructor){case Float32Array:return n;case Uint32Array:return n/4294967295;case Uint16Array:return n/65535;case Uint8Array:return n/255;case Int32Array:return Math.max(n/2147483647,-1);case Int16Array:return Math.max(n/32767,-1);case Int8Array:return Math.max(n/127,-1);default:throw new Error("Invalid component type.")}}function Be(n,t){switch(t.constructor){case Float32Array:return n;case Uint32Array:return Math.round(n*4294967295);case Uint16Array:return Math.round(n*65535);case Uint8Array:return Math.round(n*255);case Int32Array:return Math.round(n*2147483647);case Int16Array:return Math.round(n*32767);case Int8Array:return Math.round(n*127);default:throw new Error("Invalid component type.")}}class yt{constructor(t=0,e=0){yt.prototype.isVector2=!0,this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,r=this.y,i=t.elements;return this.x=i[0]*e+i[3]*r+i[6],this.y=i[1]*e+i[4]*r+i[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=At(this.x,t.x,e.x),this.y=At(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=At(this.x,t,e),this.y=At(this.y,t,e),this}clampLength(t,e){const r=this.length();return this.divideScalar(r||1).multiplyScalar(At(r,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const r=this.dot(t)/e;return Math.acos(At(r,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,r=this.y-t.y;return e*e+r*r}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,r){return this.x=t.x+(e.x-t.x)*r,this.y=t.y+(e.y-t.y)*r,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const r=Math.cos(e),i=Math.sin(e),s=this.x-t.x,o=this.y-t.y;return this.x=s*r-o*i+t.x,this.y=s*i+o*r+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Wi{constructor(t=0,e=0,r=0,i=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=r,this._w=i}static slerpFlat(t,e,r,i,s,o,a){let l=r[i+0],c=r[i+1],h=r[i+2],f=r[i+3];const g=s[o+0],p=s[o+1],m=s[o+2],v=s[o+3];if(a===0){t[e+0]=l,t[e+1]=c,t[e+2]=h,t[e+3]=f;return}if(a===1){t[e+0]=g,t[e+1]=p,t[e+2]=m,t[e+3]=v;return}if(f!==v||l!==g||c!==p||h!==m){let _=1-a;const S=l*g+c*p+h*m+f*v,A=S>=0?1:-1,C=1-S*S;if(C>Number.EPSILON){const M=Math.sqrt(C),z=Math.atan2(M,S*A);_=Math.sin(_*z)/M,a=Math.sin(a*z)/M}const O=a*A;if(l=l*_+g*O,c=c*_+p*O,h=h*_+m*O,f=f*_+v*O,_===1-a){const M=1/Math.sqrt(l*l+c*c+h*h+f*f);l*=M,c*=M,h*=M,f*=M}}t[e]=l,t[e+1]=c,t[e+2]=h,t[e+3]=f}static multiplyQuaternionsFlat(t,e,r,i,s,o){const a=r[i],l=r[i+1],c=r[i+2],h=r[i+3],f=s[o],g=s[o+1],p=s[o+2],m=s[o+3];return t[e]=a*m+h*f+l*p-c*g,t[e+1]=l*m+h*g+c*f-a*p,t[e+2]=c*m+h*p+a*g-l*f,t[e+3]=h*m-a*f-l*g-c*p,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,r,i){return this._x=t,this._y=e,this._z=r,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){const r=t._x,i=t._y,s=t._z,o=t._order,a=Math.cos,l=Math.sin,c=a(r/2),h=a(i/2),f=a(s/2),g=l(r/2),p=l(i/2),m=l(s/2);switch(o){case"XYZ":this._x=g*h*f+c*p*m,this._y=c*p*f-g*h*m,this._z=c*h*m+g*p*f,this._w=c*h*f-g*p*m;break;case"YXZ":this._x=g*h*f+c*p*m,this._y=c*p*f-g*h*m,this._z=c*h*m-g*p*f,this._w=c*h*f+g*p*m;break;case"ZXY":this._x=g*h*f-c*p*m,this._y=c*p*f+g*h*m,this._z=c*h*m+g*p*f,this._w=c*h*f-g*p*m;break;case"ZYX":this._x=g*h*f-c*p*m,this._y=c*p*f+g*h*m,this._z=c*h*m-g*p*f,this._w=c*h*f+g*p*m;break;case"YZX":this._x=g*h*f+c*p*m,this._y=c*p*f+g*h*m,this._z=c*h*m-g*p*f,this._w=c*h*f-g*p*m;break;case"XZY":this._x=g*h*f-c*p*m,this._y=c*p*f-g*h*m,this._z=c*h*m+g*p*f,this._w=c*h*f+g*p*m;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const r=e/2,i=Math.sin(r);return this._x=t.x*i,this._y=t.y*i,this._z=t.z*i,this._w=Math.cos(r),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,r=e[0],i=e[4],s=e[8],o=e[1],a=e[5],l=e[9],c=e[2],h=e[6],f=e[10],g=r+a+f;if(g>0){const p=.5/Math.sqrt(g+1);this._w=.25/p,this._x=(h-l)*p,this._y=(s-c)*p,this._z=(o-i)*p}else if(r>a&&r>f){const p=2*Math.sqrt(1+r-a-f);this._w=(h-l)/p,this._x=.25*p,this._y=(i+o)/p,this._z=(s+c)/p}else if(a>f){const p=2*Math.sqrt(1+a-r-f);this._w=(s-c)/p,this._x=(i+o)/p,this._y=.25*p,this._z=(l+h)/p}else{const p=2*Math.sqrt(1+f-r-a);this._w=(o-i)/p,this._x=(s+c)/p,this._y=(l+h)/p,this._z=.25*p}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let r=t.dot(e)+1;return r<1e-8?(r=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=r):(this._x=0,this._y=-t.z,this._z=t.y,this._w=r)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=r),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(At(this.dot(t),-1,1)))}rotateTowards(t,e){const r=this.angleTo(t);if(r===0)return this;const i=Math.min(1,e/r);return this.slerp(t,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const r=t._x,i=t._y,s=t._z,o=t._w,a=e._x,l=e._y,c=e._z,h=e._w;return this._x=r*h+o*a+i*c-s*l,this._y=i*h+o*l+s*a-r*c,this._z=s*h+o*c+r*l-i*a,this._w=o*h-r*a-i*l-s*c,this._onChangeCallback(),this}slerp(t,e){if(e===0)return this;if(e===1)return this.copy(t);const r=this._x,i=this._y,s=this._z,o=this._w;let a=o*t._w+r*t._x+i*t._y+s*t._z;if(a<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,a=-a):this.copy(t),a>=1)return this._w=o,this._x=r,this._y=i,this._z=s,this;const l=1-a*a;if(l<=Number.EPSILON){const p=1-e;return this._w=p*o+e*this._w,this._x=p*r+e*this._x,this._y=p*i+e*this._y,this._z=p*s+e*this._z,this.normalize(),this}const c=Math.sqrt(l),h=Math.atan2(c,a),f=Math.sin((1-e)*h)/c,g=Math.sin(e*h)/c;return this._w=o*f+this._w*g,this._x=r*f+this._x*g,this._y=i*f+this._y*g,this._z=s*f+this._z*g,this._onChangeCallback(),this}slerpQuaternions(t,e,r){return this.copy(t).slerp(e,r)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),r=Math.random(),i=Math.sqrt(1-r),s=Math.sqrt(r);return this.set(i*Math.sin(t),i*Math.cos(t),s*Math.sin(e),s*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class D{constructor(t=0,e=0,r=0){D.prototype.isVector3=!0,this.x=t,this.y=e,this.z=r}set(t,e,r){return r===void 0&&(r=this.z),this.x=t,this.y=e,this.z=r,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(im.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(im.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,r=this.y,i=this.z,s=t.elements;return this.x=s[0]*e+s[3]*r+s[6]*i,this.y=s[1]*e+s[4]*r+s[7]*i,this.z=s[2]*e+s[5]*r+s[8]*i,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,r=this.y,i=this.z,s=t.elements,o=1/(s[3]*e+s[7]*r+s[11]*i+s[15]);return this.x=(s[0]*e+s[4]*r+s[8]*i+s[12])*o,this.y=(s[1]*e+s[5]*r+s[9]*i+s[13])*o,this.z=(s[2]*e+s[6]*r+s[10]*i+s[14])*o,this}applyQuaternion(t){const e=this.x,r=this.y,i=this.z,s=t.x,o=t.y,a=t.z,l=t.w,c=2*(o*i-a*r),h=2*(a*e-s*i),f=2*(s*r-o*e);return this.x=e+l*c+o*f-a*h,this.y=r+l*h+a*c-s*f,this.z=i+l*f+s*h-o*c,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,r=this.y,i=this.z,s=t.elements;return this.x=s[0]*e+s[4]*r+s[8]*i,this.y=s[1]*e+s[5]*r+s[9]*i,this.z=s[2]*e+s[6]*r+s[10]*i,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=At(this.x,t.x,e.x),this.y=At(this.y,t.y,e.y),this.z=At(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=At(this.x,t,e),this.y=At(this.y,t,e),this.z=At(this.z,t,e),this}clampLength(t,e){const r=this.length();return this.divideScalar(r||1).multiplyScalar(At(r,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,r){return this.x=t.x+(e.x-t.x)*r,this.y=t.y+(e.y-t.y)*r,this.z=t.z+(e.z-t.z)*r,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const r=t.x,i=t.y,s=t.z,o=e.x,a=e.y,l=e.z;return this.x=i*l-s*a,this.y=s*o-r*l,this.z=r*a-i*o,this}projectOnVector(t){const e=t.lengthSq();if(e===0)return this.set(0,0,0);const r=t.dot(this)/e;return this.copy(t).multiplyScalar(r)}projectOnPlane(t){return xc.copy(this).projectOnVector(t),this.sub(xc)}reflect(t){return this.sub(xc.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const r=this.dot(t)/e;return Math.acos(At(r,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,r=this.y-t.y,i=this.z-t.z;return e*e+r*r+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,r){const i=Math.sin(e)*t;return this.x=i*Math.sin(r),this.y=Math.cos(e)*t,this.z=i*Math.cos(r),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,r){return this.x=t*Math.sin(e),this.y=r,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),r=this.setFromMatrixColumn(t,1).length(),i=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=r,this.z=i,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,e=Math.random()*2-1,r=Math.sqrt(1-e*e);return this.x=r*Math.cos(t),this.y=e,this.z=r*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const xc=new D,im=new Wi;class Ln{constructor(t,e,r,i,s,o,a,l,c){Ln.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,r,i,s,o,a,l,c)}set(t,e,r,i,s,o,a,l,c){const h=this.elements;return h[0]=t,h[1]=i,h[2]=a,h[3]=e,h[4]=s,h[5]=l,h[6]=r,h[7]=o,h[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,r=t.elements;return e[0]=r[0],e[1]=r[1],e[2]=r[2],e[3]=r[3],e[4]=r[4],e[5]=r[5],e[6]=r[6],e[7]=r[7],e[8]=r[8],this}extractBasis(t,e,r){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),r.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const r=t.elements,i=e.elements,s=this.elements,o=r[0],a=r[3],l=r[6],c=r[1],h=r[4],f=r[7],g=r[2],p=r[5],m=r[8],v=i[0],_=i[3],S=i[6],A=i[1],C=i[4],O=i[7],M=i[2],z=i[5],R=i[8];return s[0]=o*v+a*A+l*M,s[3]=o*_+a*C+l*z,s[6]=o*S+a*O+l*R,s[1]=c*v+h*A+f*M,s[4]=c*_+h*C+f*z,s[7]=c*S+h*O+f*R,s[2]=g*v+p*A+m*M,s[5]=g*_+p*C+m*z,s[8]=g*S+p*O+m*R,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],r=t[1],i=t[2],s=t[3],o=t[4],a=t[5],l=t[6],c=t[7],h=t[8];return e*o*h-e*a*c-r*s*h+r*a*l+i*s*c-i*o*l}invert(){const t=this.elements,e=t[0],r=t[1],i=t[2],s=t[3],o=t[4],a=t[5],l=t[6],c=t[7],h=t[8],f=h*o-a*c,g=a*l-h*s,p=c*s-o*l,m=e*f+r*g+i*p;if(m===0)return this.set(0,0,0,0,0,0,0,0,0);const v=1/m;return t[0]=f*v,t[1]=(i*c-h*r)*v,t[2]=(a*r-i*o)*v,t[3]=g*v,t[4]=(h*e-i*l)*v,t[5]=(i*s-a*e)*v,t[6]=p*v,t[7]=(r*l-c*e)*v,t[8]=(o*e-r*s)*v,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,r,i,s,o,a){const l=Math.cos(s),c=Math.sin(s);return this.set(r*l,r*c,-r*(l*o+c*a)+o+t,-i*c,i*l,-i*(-c*o+l*a)+a+e,0,0,1),this}scale(t,e){return this.premultiply(_c.makeScale(t,e)),this}rotate(t){return this.premultiply(_c.makeRotation(-t)),this}translate(t,e){return this.premultiply(_c.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),r=Math.sin(t);return this.set(e,-r,0,r,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,r=t.elements;for(let i=0;i<9;i++)if(e[i]!==r[i])return!1;return!0}fromArray(t,e=0){for(let r=0;r<9;r++)this.elements[r]=t[r+e];return this}toArray(t=[],e=0){const r=this.elements;return t[e]=r[0],t[e+1]=r[1],t[e+2]=r[2],t[e+3]=r[3],t[e+4]=r[4],t[e+5]=r[5],t[e+6]=r[6],t[e+7]=r[7],t[e+8]=r[8],t}clone(){return new this.constructor().fromArray(this.elements)}}const _c=new Ln;function uS(n){for(let t=n.length-1;t>=0;--t)if(n[t]>=65535)return!0;return!1}function bc(n){return document.createElementNS("http://www.w3.org/1999/xhtml",n)}const sm={};function om(n){n in sm||(sm[n]=!0,console.warn(n))}const am=new Ln().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),um=new Ln().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function lS(){const n={enabled:!0,workingColorSpace:Qg,spaces:{},convert:function(i,s,o){return this.enabled===!1||s===o||!s||!o||(this.spaces[s].transfer===yc&&(i.r=mn(i.r),i.g=mn(i.g),i.b=mn(i.b)),this.spaces[s].primaries!==this.spaces[o].primaries&&(i.applyMatrix3(this.spaces[s].toXYZ),i.applyMatrix3(this.spaces[o].fromXYZ)),this.spaces[o].transfer===yc&&(i.r=Ui(i.r),i.g=Ui(i.g),i.b=Ui(i.b))),i},workingToColorSpace:function(i,s){return this.convert(i,this.workingColorSpace,s)},colorSpaceToWorking:function(i,s){return this.convert(i,s,this.workingColorSpace)},getPrimaries:function(i){return this.spaces[i].primaries},getTransfer:function(i){return i===Kg?tm:this.spaces[i].transfer},getLuminanceCoefficients:function(i,s=this.workingColorSpace){return i.fromArray(this.spaces[s].luminanceCoefficients)},define:function(i){Object.assign(this.spaces,i)},_getMatrix:function(i,s,o){return i.copy(this.spaces[s].toXYZ).multiply(this.spaces[o].fromXYZ)},_getDrawingBufferColorSpace:function(i){return this.spaces[i].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(i=this.workingColorSpace){return this.spaces[i].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(i,s){return om("THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),n.workingToColorSpace(i,s)},toWorkingColorSpace:function(i,s){return om("THREE.ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),n.colorSpaceToWorking(i,s)}},t=[.64,.33,.3,.6,.15,.06],e=[.2126,.7152,.0722],r=[.3127,.329];return n.define({[Qg]:{primaries:t,whitePoint:r,transfer:tm,toXYZ:am,fromXYZ:um,luminanceCoefficients:e,workingColorSpaceConfig:{unpackColorSpace:Ir},outputColorSpaceConfig:{drawingBufferColorSpace:Ir}},[Ir]:{primaries:t,whitePoint:r,transfer:yc,toXYZ:am,fromXYZ:um,luminanceCoefficients:e,outputColorSpaceConfig:{drawingBufferColorSpace:Ir}}}),n}const Pr=lS();function mn(n){return n<.04045?n*.0773993808:Math.pow(n*.9478672986+.0521327014,2.4)}function Ui(n){return n<.0031308?n*12.92:1.055*Math.pow(n,.41666)-.055}let Yi;class cS{static getDataURL(t,e="image/png"){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let r;if(t instanceof HTMLCanvasElement)r=t;else{Yi===void 0&&(Yi=bc("canvas")),Yi.width=t.width,Yi.height=t.height;const i=Yi.getContext("2d");t instanceof ImageData?i.putImageData(t,0,0):i.drawImage(t,0,0,t.width,t.height),r=Yi}return r.toDataURL(e)}static sRGBToLinear(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap){const e=bc("canvas");e.width=t.width,e.height=t.height;const r=e.getContext("2d");r.drawImage(t,0,0,t.width,t.height);const i=r.getImageData(0,0,t.width,t.height),s=i.data;for(let o=0;o<s.length;o++)s[o]=mn(s[o]/255)*255;return r.putImageData(i,0,0),e}else if(t.data){const e=t.data.slice(0);for(let r=0;r<e.length;r++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[r]=Math.floor(mn(e[r]/255)*255):e[r]=mn(e[r]);return{data:e,width:t.width,height:t.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}}let hS=0;class fS{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:hS++}),this.uuid=Gi(),this.data=t,this.dataReady=!0,this.version=0}getSize(t){const e=this.data;return e instanceof HTMLVideoElement?t.set(e.videoWidth,e.videoHeight,0):e instanceof VideoFrame?t.set(e.displayHeight,e.displayWidth,0):e!==null?t.set(e.width,e.height,e.depth||0):t.set(0,0,0),t}set needsUpdate(t){t===!0&&this.version++}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.images[this.uuid]!==void 0)return t.images[this.uuid];const r={uuid:this.uuid,url:""},i=this.data;if(i!==null){let s;if(Array.isArray(i)){s=[];for(let o=0,a=i.length;o<a;o++)i[o].isDataTexture?s.push(wc(i[o].image)):s.push(wc(i[o]))}else s=wc(i);r.url=s}return e||(t.images[this.uuid]=r),r}}function wc(n){return typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&n instanceof ImageBitmap?cS.getDataURL(n):n.data?{data:Array.from(n.data),width:n.width,height:n.height,type:n.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let dS=0;const Sc=new D;class Nn extends Ia{constructor(t=Nn.DEFAULT_IMAGE,e=Nn.DEFAULT_MAPPING,r=Ca,i=Ca,s=eS,o=rS,a=sS,l=nS,c=Nn.DEFAULT_ANISOTROPY,h=Kg){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:dS++}),this.uuid=Gi(),this.name="",this.source=new fS(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=s,this.minFilter=o,this.anisotropy=c,this.format=a,this.internalFormat=null,this.type=l,this.offset=new yt(0,0),this.repeat=new yt(1,1),this.center=new yt(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Ln,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(t&&t.depth&&t.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(Sc).x}get height(){return this.source.getSize(Sc).y}get depth(){return this.source.getSize(Sc).z}get image(){return this.source.data}set image(t=null){this.source.data=t}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(t){return this.name=t.name,this.source=t.source,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.channel=t.channel,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.colorSpace=t.colorSpace,this.renderTarget=t.renderTarget,this.isRenderTargetTexture=t.isRenderTargetTexture,this.isArrayTexture=t.isArrayTexture,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}setValues(t){for(const e in t){const r=t[e];if(r===void 0){console.warn(`THREE.Texture.setValues(): parameter '${e}' has value of undefined.`);continue}const i=this[e];if(i===void 0){console.warn(`THREE.Texture.setValues(): property '${e}' does not exist.`);continue}i&&r&&i.isVector2&&r.isVector2||i&&r&&i.isVector3&&r.isVector3||i&&r&&i.isMatrix3&&r.isMatrix3?i.copy(r):this[e]=r}}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.textures[this.uuid]!==void 0)return t.textures[this.uuid];const r={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(t).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(r.userData=this.userData),e||(t.textures[this.uuid]=r),r}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==Jg)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case tn:t.x=t.x-Math.floor(t.x);break;case Ca:t.x=t.x<0?0:1;break;case Zg:Math.abs(Math.floor(t.x)%2)===1?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x);break}if(t.y<0||t.y>1)switch(this.wrapT){case tn:t.y=t.y-Math.floor(t.y);break;case Ca:t.y=t.y<0?0:1;break;case Zg:Math.abs(Math.floor(t.y)%2)===1?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y);break}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){t===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){t===!0&&this.pmremVersion++}}Nn.DEFAULT_IMAGE=null,Nn.DEFAULT_MAPPING=Jg,Nn.DEFAULT_ANISOTROPY=1;class io{constructor(t=0,e=0,r=0,i=1){io.prototype.isVector4=!0,this.x=t,this.y=e,this.z=r,this.w=i}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,r,i){return this.x=t,this.y=e,this.z=r,this.w=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w!==void 0?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,r=this.y,i=this.z,s=this.w,o=t.elements;return this.x=o[0]*e+o[4]*r+o[8]*i+o[12]*s,this.y=o[1]*e+o[5]*r+o[9]*i+o[13]*s,this.z=o[2]*e+o[6]*r+o[10]*i+o[14]*s,this.w=o[3]*e+o[7]*r+o[11]*i+o[15]*s,this}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,r,i,s;const l=t.elements,c=l[0],h=l[4],f=l[8],g=l[1],p=l[5],m=l[9],v=l[2],_=l[6],S=l[10];if(Math.abs(h-g)<.01&&Math.abs(f-v)<.01&&Math.abs(m-_)<.01){if(Math.abs(h+g)<.1&&Math.abs(f+v)<.1&&Math.abs(m+_)<.1&&Math.abs(c+p+S-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;const C=(c+1)/2,O=(p+1)/2,M=(S+1)/2,z=(h+g)/4,R=(f+v)/4,I=(m+_)/4;return C>O&&C>M?C<.01?(r=0,i=.707106781,s=.707106781):(r=Math.sqrt(C),i=z/r,s=R/r):O>M?O<.01?(r=.707106781,i=0,s=.707106781):(i=Math.sqrt(O),r=z/i,s=I/i):M<.01?(r=.707106781,i=.707106781,s=0):(s=Math.sqrt(M),r=R/s,i=I/s),this.set(r,i,s,e),this}let A=Math.sqrt((_-m)*(_-m)+(f-v)*(f-v)+(g-h)*(g-h));return Math.abs(A)<.001&&(A=1),this.x=(_-m)/A,this.y=(f-v)/A,this.z=(g-h)/A,this.w=Math.acos((c+p+S-1)/2),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this.w=e[15],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=At(this.x,t.x,e.x),this.y=At(this.y,t.y,e.y),this.z=At(this.z,t.z,e.z),this.w=At(this.w,t.w,e.w),this}clampScalar(t,e){return this.x=At(this.x,t,e),this.y=At(this.y,t,e),this.z=At(this.z,t,e),this.w=At(this.w,t,e),this}clampLength(t,e){const r=this.length();return this.divideScalar(r||1).multiplyScalar(At(r,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,r){return this.x=t.x+(e.x-t.x)*r,this.y=t.y+(e.y-t.y)*r,this.z=t.z+(e.z-t.z)*r,this.w=t.w+(e.w-t.w)*r,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class Xi{constructor(t=new D(1/0,1/0,1/0),e=new D(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,r=t.length;e<r;e+=3)this.expandByPoint(Rr.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,r=t.count;e<r;e++)this.expandByPoint(Rr.fromBufferAttribute(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,r=t.length;e<r;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const r=Rr.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(r),this.max.copy(t).add(r),this}setFromObject(t,e=!1){return this.makeEmpty(),this.expandByObject(t,e)}clone(){return new this.constructor().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}expandByObject(t,e=!1){t.updateWorldMatrix(!1,!1);const r=t.geometry;if(r!==void 0){const s=r.getAttribute("position");if(e===!0&&s!==void 0&&t.isInstancedMesh!==!0)for(let o=0,a=s.count;o<a;o++)t.isMesh===!0?t.getVertexPosition(o,Rr):Rr.fromBufferAttribute(s,o),Rr.applyMatrix4(t.matrixWorld),this.expandByPoint(Rr);else t.boundingBox!==void 0?(t.boundingBox===null&&t.computeBoundingBox(),Pa.copy(t.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),Pa.copy(r.boundingBox)),Pa.applyMatrix4(t.matrixWorld),this.union(Pa)}const i=t.children;for(let s=0,o=i.length;s<o;s++)this.expandByObject(i[s],e);return this}containsPoint(t){return t.x>=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y&&t.z>=this.min.z&&t.z<=this.max.z}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y&&t.max.z>=this.min.z&&t.min.z<=this.max.z}intersectsSphere(t){return this.clampPoint(t.center,Rr),Rr.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,r;return t.normal.x>0?(e=t.normal.x*this.min.x,r=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,r=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,r+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,r+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,r+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,r+=t.normal.z*this.min.z),e<=-t.constant&&r>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(so),Ra.subVectors(this.max,so),Ji.subVectors(t.a,so),Zi.subVectors(t.b,so),Ki.subVectors(t.c,so),Fn.subVectors(Zi,Ji),jn.subVectors(Ki,Zi),ii.subVectors(Ji,Ki);let e=[0,-Fn.z,Fn.y,0,-jn.z,jn.y,0,-ii.z,ii.y,Fn.z,0,-Fn.x,jn.z,0,-jn.x,ii.z,0,-ii.x,-Fn.y,Fn.x,0,-jn.y,jn.x,0,-ii.y,ii.x,0];return!Mc(e,Ji,Zi,Ki,Ra)||(e=[1,0,0,0,1,0,0,0,1],!Mc(e,Ji,Zi,Ki,Ra))?!1:(La.crossVectors(Fn,jn),e=[La.x,La.y,La.z],Mc(e,Ji,Zi,Ki,Ra))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Rr).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(Rr).length()*.5),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()?this:(yn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),yn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),yn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),yn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),yn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),yn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),yn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),yn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(yn),this)}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(t){return this.min.fromArray(t.min),this.max.fromArray(t.max),this}}const yn=[new D,new D,new D,new D,new D,new D,new D,new D],Rr=new D,Pa=new Xi,Ji=new D,Zi=new D,Ki=new D,Fn=new D,jn=new D,ii=new D,so=new D,Ra=new D,La=new D,si=new D;function Mc(n,t,e,r,i){for(let s=0,o=n.length-3;s<=o;s+=3){si.fromArray(n,s);const a=i.x*Math.abs(si.x)+i.y*Math.abs(si.y)+i.z*Math.abs(si.z),l=t.dot(si),c=e.dot(si),h=r.dot(si);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>a)return!1}return!0}const pS=new Xi,oo=new D,Ec=new D;class lm{constructor(t=new D,e=-1){this.isSphere=!0,this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){const r=this.center;e!==void 0?r.copy(e):pS.setFromPoints(t).getCenter(r);let i=0;for(let s=0,o=t.length;s<o;s++)i=Math.max(i,r.distanceToSquared(t[s]));return this.radius=Math.sqrt(i),this}copy(t){return this.center.copy(t.center),this.radius=t.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(t){return t.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(t){return t.distanceTo(this.center)-this.radius}intersectsSphere(t){const e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e}intersectsBox(t){return t.intersectsSphere(this)}intersectsPlane(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius}clampPoint(t,e){const r=this.center.distanceToSquared(t);return e.copy(t),r>this.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;oo.subVectors(t,this.center);const e=oo.lengthSq();if(e>this.radius*this.radius){const r=Math.sqrt(e),i=(r-this.radius)*.5;this.center.addScaledVector(oo,i/r),this.radius+=i}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(this.center.equals(t.center)===!0?this.radius=Math.max(this.radius,t.radius):(Ec.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(oo.copy(t.center).add(Ec)),this.expandByPoint(oo.copy(t.center).sub(Ec))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(t){return this.radius=t.radius,this.center.fromArray(t.center),this}}const vn=new D,Ac=new D,Na=new D,Vn=new D,Oc=new D,Fa=new D,zc=new D;class gS{constructor(t=new D,e=new D(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.copy(this.origin).addScaledVector(this.direction,t)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,vn)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);const r=e.dot(this.direction);return r<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,r)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const e=vn.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(vn.copy(this.origin).addScaledVector(this.direction,e),vn.distanceToSquared(t))}distanceSqToSegment(t,e,r,i){Ac.copy(t).add(e).multiplyScalar(.5),Na.copy(e).sub(t).normalize(),Vn.copy(this.origin).sub(Ac);const s=t.distanceTo(e)*.5,o=-this.direction.dot(Na),a=Vn.dot(this.direction),l=-Vn.dot(Na),c=Vn.lengthSq(),h=Math.abs(1-o*o);let f,g,p,m;if(h>0)if(f=o*l-a,g=o*a-l,m=s*h,f>=0)if(g>=-m)if(g<=m){const v=1/h;f*=v,g*=v,p=f*(f+o*g+2*a)+g*(o*f+g+2*l)+c}else g=s,f=Math.max(0,-(o*g+a)),p=-f*f+g*(g+2*l)+c;else g=-s,f=Math.max(0,-(o*g+a)),p=-f*f+g*(g+2*l)+c;else g<=-m?(f=Math.max(0,-(-o*s+a)),g=f>0?-s:Math.min(Math.max(-s,-l),s),p=-f*f+g*(g+2*l)+c):g<=m?(f=0,g=Math.min(Math.max(-s,-l),s),p=g*(g+2*l)+c):(f=Math.max(0,-(o*s+a)),g=f>0?s:Math.min(Math.max(-s,-l),s),p=-f*f+g*(g+2*l)+c);else g=o>0?-s:s,f=Math.max(0,-(o*g+a)),p=-f*f+g*(g+2*l)+c;return r&&r.copy(this.origin).addScaledVector(this.direction,f),i&&i.copy(Ac).addScaledVector(Na,g),p}intersectSphere(t,e){vn.subVectors(t.center,this.origin);const r=vn.dot(this.direction),i=vn.dot(vn)-r*r,s=t.radius*t.radius;if(i>s)return null;const o=Math.sqrt(s-i),a=r-o,l=r+o;return l<0?null:a<0?this.at(l,e):this.at(a,e)}intersectsSphere(t){return t.radius<0?!1:this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(e===0)return t.distanceToPoint(this.origin)===0?0:null;const r=-(this.origin.dot(t.normal)+t.constant)/e;return r>=0?r:null}intersectPlane(t,e){const r=this.distanceToPlane(t);return r===null?null:this.at(r,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);return e===0||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let r,i,s,o,a,l;const c=1/this.direction.x,h=1/this.direction.y,f=1/this.direction.z,g=this.origin;return c>=0?(r=(t.min.x-g.x)*c,i=(t.max.x-g.x)*c):(r=(t.max.x-g.x)*c,i=(t.min.x-g.x)*c),h>=0?(s=(t.min.y-g.y)*h,o=(t.max.y-g.y)*h):(s=(t.max.y-g.y)*h,o=(t.min.y-g.y)*h),r>o||s>i||((s>r||isNaN(r))&&(r=s),(o<i||isNaN(i))&&(i=o),f>=0?(a=(t.min.z-g.z)*f,l=(t.max.z-g.z)*f):(a=(t.max.z-g.z)*f,l=(t.min.z-g.z)*f),r>l||a>i)||((a>r||r!==r)&&(r=a),(l<i||i!==i)&&(i=l),i<0)?null:this.at(r>=0?r:i,e)}intersectsBox(t){return this.intersectBox(t,vn)!==null}intersectTriangle(t,e,r,i,s){Oc.subVectors(e,t),Fa.subVectors(r,t),zc.crossVectors(Oc,Fa);let o=this.direction.dot(zc),a;if(o>0){if(i)return null;a=1}else if(o<0)a=-1,o=-o;else return null;Vn.subVectors(this.origin,t);const l=a*this.direction.dot(Fa.crossVectors(Vn,Fa));if(l<0)return null;const c=a*this.direction.dot(Oc.cross(Vn));if(c<0||l+c>o)return null;const h=-a*Vn.dot(zc);return h<0?null:this.at(h/o,s)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class Re{constructor(t,e,r,i,s,o,a,l,c,h,f,g,p,m,v,_){Re.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,e,r,i,s,o,a,l,c,h,f,g,p,m,v,_)}set(t,e,r,i,s,o,a,l,c,h,f,g,p,m,v,_){const S=this.elements;return S[0]=t,S[4]=e,S[8]=r,S[12]=i,S[1]=s,S[5]=o,S[9]=a,S[13]=l,S[2]=c,S[6]=h,S[10]=f,S[14]=g,S[3]=p,S[7]=m,S[11]=v,S[15]=_,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new Re().fromArray(this.elements)}copy(t){const e=this.elements,r=t.elements;return e[0]=r[0],e[1]=r[1],e[2]=r[2],e[3]=r[3],e[4]=r[4],e[5]=r[5],e[6]=r[6],e[7]=r[7],e[8]=r[8],e[9]=r[9],e[10]=r[10],e[11]=r[11],e[12]=r[12],e[13]=r[13],e[14]=r[14],e[15]=r[15],this}copyPosition(t){const e=this.elements,r=t.elements;return e[12]=r[12],e[13]=r[13],e[14]=r[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,r){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),r.setFromMatrixColumn(this,2),this}makeBasis(t,e,r){return this.set(t.x,e.x,r.x,0,t.y,e.y,r.y,0,t.z,e.z,r.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,r=t.elements,i=1/Qi.setFromMatrixColumn(t,0).length(),s=1/Qi.setFromMatrixColumn(t,1).length(),o=1/Qi.setFromMatrixColumn(t,2).length();return e[0]=r[0]*i,e[1]=r[1]*i,e[2]=r[2]*i,e[3]=0,e[4]=r[4]*s,e[5]=r[5]*s,e[6]=r[6]*s,e[7]=0,e[8]=r[8]*o,e[9]=r[9]*o,e[10]=r[10]*o,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,r=t.x,i=t.y,s=t.z,o=Math.cos(r),a=Math.sin(r),l=Math.cos(i),c=Math.sin(i),h=Math.cos(s),f=Math.sin(s);if(t.order==="XYZ"){const g=o*h,p=o*f,m=a*h,v=a*f;e[0]=l*h,e[4]=-l*f,e[8]=c,e[1]=p+m*c,e[5]=g-v*c,e[9]=-a*l,e[2]=v-g*c,e[6]=m+p*c,e[10]=o*l}else if(t.order==="YXZ"){const g=l*h,p=l*f,m=c*h,v=c*f;e[0]=g+v*a,e[4]=m*a-p,e[8]=o*c,e[1]=o*f,e[5]=o*h,e[9]=-a,e[2]=p*a-m,e[6]=v+g*a,e[10]=o*l}else if(t.order==="ZXY"){const g=l*h,p=l*f,m=c*h,v=c*f;e[0]=g-v*a,e[4]=-o*f,e[8]=m+p*a,e[1]=p+m*a,e[5]=o*h,e[9]=v-g*a,e[2]=-o*c,e[6]=a,e[10]=o*l}else if(t.order==="ZYX"){const g=o*h,p=o*f,m=a*h,v=a*f;e[0]=l*h,e[4]=m*c-p,e[8]=g*c+v,e[1]=l*f,e[5]=v*c+g,e[9]=p*c-m,e[2]=-c,e[6]=a*l,e[10]=o*l}else if(t.order==="YZX"){const g=o*l,p=o*c,m=a*l,v=a*c;e[0]=l*h,e[4]=v-g*f,e[8]=m*f+p,e[1]=f,e[5]=o*h,e[9]=-a*h,e[2]=-c*h,e[6]=p*f+m,e[10]=g-v*f}else if(t.order==="XZY"){const g=o*l,p=o*c,m=a*l,v=a*c;e[0]=l*h,e[4]=-f,e[8]=c*h,e[1]=g*f+v,e[5]=o*h,e[9]=p*f-m,e[2]=m*f-p,e[6]=a*h,e[10]=v*f+g}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(mS,t,yS)}lookAt(t,e,r){const i=this.elements;return Ze.subVectors(t,e),Ze.lengthSq()===0&&(Ze.z=1),Ze.normalize(),Dn.crossVectors(r,Ze),Dn.lengthSq()===0&&(Math.abs(r.z)===1?Ze.x+=1e-4:Ze.z+=1e-4,Ze.normalize(),Dn.crossVectors(r,Ze)),Dn.normalize(),ja.crossVectors(Ze,Dn),i[0]=Dn.x,i[4]=ja.x,i[8]=Ze.x,i[1]=Dn.y,i[5]=ja.y,i[9]=Ze.y,i[2]=Dn.z,i[6]=ja.z,i[10]=Ze.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const r=t.elements,i=e.elements,s=this.elements,o=r[0],a=r[4],l=r[8],c=r[12],h=r[1],f=r[5],g=r[9],p=r[13],m=r[2],v=r[6],_=r[10],S=r[14],A=r[3],C=r[7],O=r[11],M=r[15],z=i[0],R=i[4],I=i[8],L=i[12],Y=i[1],X=i[5],it=i[9],rt=i[13],vt=i[2],mt=i[6],dt=i[10],ut=i[14],W=i[3],gt=i[7],k=i[11],j=i[15];return s[0]=o*z+a*Y+l*vt+c*W,s[4]=o*R+a*X+l*mt+c*gt,s[8]=o*I+a*it+l*dt+c*k,s[12]=o*L+a*rt+l*ut+c*j,s[1]=h*z+f*Y+g*vt+p*W,s[5]=h*R+f*X+g*mt+p*gt,s[9]=h*I+f*it+g*dt+p*k,s[13]=h*L+f*rt+g*ut+p*j,s[2]=m*z+v*Y+_*vt+S*W,s[6]=m*R+v*X+_*mt+S*gt,s[10]=m*I+v*it+_*dt+S*k,s[14]=m*L+v*rt+_*ut+S*j,s[3]=A*z+C*Y+O*vt+M*W,s[7]=A*R+C*X+O*mt+M*gt,s[11]=A*I+C*it+O*dt+M*k,s[15]=A*L+C*rt+O*ut+M*j,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],r=t[4],i=t[8],s=t[12],o=t[1],a=t[5],l=t[9],c=t[13],h=t[2],f=t[6],g=t[10],p=t[14],m=t[3],v=t[7],_=t[11],S=t[15];return m*(+s*l*f-i*c*f-s*a*g+r*c*g+i*a*p-r*l*p)+v*(+e*l*p-e*c*g+s*o*g-i*o*p+i*c*h-s*l*h)+_*(+e*c*f-e*a*p-s*o*f+r*o*p+s*a*h-r*c*h)+S*(-i*a*h-e*l*f+e*a*g+i*o*f-r*o*g+r*l*h)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,r){const i=this.elements;return t.isVector3?(i[12]=t.x,i[13]=t.y,i[14]=t.z):(i[12]=t,i[13]=e,i[14]=r),this}invert(){const t=this.elements,e=t[0],r=t[1],i=t[2],s=t[3],o=t[4],a=t[5],l=t[6],c=t[7],h=t[8],f=t[9],g=t[10],p=t[11],m=t[12],v=t[13],_=t[14],S=t[15],A=f*_*c-v*g*c+v*l*p-a*_*p-f*l*S+a*g*S,C=m*g*c-h*_*c-m*l*p+o*_*p+h*l*S-o*g*S,O=h*v*c-m*f*c+m*a*p-o*v*p-h*a*S+o*f*S,M=m*f*l-h*v*l-m*a*g+o*v*g+h*a*_-o*f*_,z=e*A+r*C+i*O+s*M;if(z===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const R=1/z;return t[0]=A*R,t[1]=(v*g*s-f*_*s-v*i*p+r*_*p+f*i*S-r*g*S)*R,t[2]=(a*_*s-v*l*s+v*i*c-r*_*c-a*i*S+r*l*S)*R,t[3]=(f*l*s-a*g*s-f*i*c+r*g*c+a*i*p-r*l*p)*R,t[4]=C*R,t[5]=(h*_*s-m*g*s+m*i*p-e*_*p-h*i*S+e*g*S)*R,t[6]=(m*l*s-o*_*s-m*i*c+e*_*c+o*i*S-e*l*S)*R,t[7]=(o*g*s-h*l*s+h*i*c-e*g*c-o*i*p+e*l*p)*R,t[8]=O*R,t[9]=(m*f*s-h*v*s-m*r*p+e*v*p+h*r*S-e*f*S)*R,t[10]=(o*v*s-m*a*s+m*r*c-e*v*c-o*r*S+e*a*S)*R,t[11]=(h*a*s-o*f*s-h*r*c+e*f*c+o*r*p-e*a*p)*R,t[12]=M*R,t[13]=(h*v*i-m*f*i+m*r*g-e*v*g-h*r*_+e*f*_)*R,t[14]=(m*a*i-o*v*i-m*r*l+e*v*l+o*r*_-e*a*_)*R,t[15]=(o*f*i-h*a*i+h*r*l-e*f*l-o*r*g+e*a*g)*R,this}scale(t){const e=this.elements,r=t.x,i=t.y,s=t.z;return e[0]*=r,e[4]*=i,e[8]*=s,e[1]*=r,e[5]*=i,e[9]*=s,e[2]*=r,e[6]*=i,e[10]*=s,e[3]*=r,e[7]*=i,e[11]*=s,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],r=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],i=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,r,i))}makeTranslation(t,e,r){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,r,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),r=Math.sin(t);return this.set(1,0,0,0,0,e,-r,0,0,r,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),r=Math.sin(t);return this.set(e,0,r,0,0,1,0,0,-r,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),r=Math.sin(t);return this.set(e,-r,0,0,r,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const r=Math.cos(e),i=Math.sin(e),s=1-r,o=t.x,a=t.y,l=t.z,c=s*o,h=s*a;return this.set(c*o+r,c*a-i*l,c*l+i*a,0,c*a+i*l,h*a+r,h*l-i*o,0,c*l-i*a,h*l+i*o,s*l*l+r,0,0,0,0,1),this}makeScale(t,e,r){return this.set(t,0,0,0,0,e,0,0,0,0,r,0,0,0,0,1),this}makeShear(t,e,r,i,s,o){return this.set(1,r,s,0,t,1,o,0,e,i,1,0,0,0,0,1),this}compose(t,e,r){const i=this.elements,s=e._x,o=e._y,a=e._z,l=e._w,c=s+s,h=o+o,f=a+a,g=s*c,p=s*h,m=s*f,v=o*h,_=o*f,S=a*f,A=l*c,C=l*h,O=l*f,M=r.x,z=r.y,R=r.z;return i[0]=(1-(v+S))*M,i[1]=(p+O)*M,i[2]=(m-C)*M,i[3]=0,i[4]=(p-O)*z,i[5]=(1-(g+S))*z,i[6]=(_+A)*z,i[7]=0,i[8]=(m+C)*R,i[9]=(_-A)*R,i[10]=(1-(g+v))*R,i[11]=0,i[12]=t.x,i[13]=t.y,i[14]=t.z,i[15]=1,this}decompose(t,e,r){const i=this.elements;let s=Qi.set(i[0],i[1],i[2]).length();const o=Qi.set(i[4],i[5],i[6]).length(),a=Qi.set(i[8],i[9],i[10]).length();this.determinant()<0&&(s=-s),t.x=i[12],t.y=i[13],t.z=i[14],Lr.copy(this);const c=1/s,h=1/o,f=1/a;return Lr.elements[0]*=c,Lr.elements[1]*=c,Lr.elements[2]*=c,Lr.elements[4]*=h,Lr.elements[5]*=h,Lr.elements[6]*=h,Lr.elements[8]*=f,Lr.elements[9]*=f,Lr.elements[10]*=f,e.setFromRotationMatrix(Lr),r.x=s,r.y=o,r.z=a,this}makePerspective(t,e,r,i,s,o,a=ka,l=!1){const c=this.elements,h=2*s/(e-t),f=2*s/(r-i),g=(e+t)/(e-t),p=(r+i)/(r-i);let m,v;if(l)m=s/(o-s),v=o*s/(o-s);else if(a===ka)m=-(o+s)/(o-s),v=-2*o*s/(o-s);else if(a===nm)m=-o/(o-s),v=-o*s/(o-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return c[0]=h,c[4]=0,c[8]=g,c[12]=0,c[1]=0,c[5]=f,c[9]=p,c[13]=0,c[2]=0,c[6]=0,c[10]=m,c[14]=v,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(t,e,r,i,s,o,a=ka,l=!1){const c=this.elements,h=2/(e-t),f=2/(r-i),g=-(e+t)/(e-t),p=-(r+i)/(r-i);let m,v;if(l)m=1/(o-s),v=o/(o-s);else if(a===ka)m=-2/(o-s),v=-(o+s)/(o-s);else if(a===nm)m=-1/(o-s),v=-s/(o-s);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return c[0]=h,c[4]=0,c[8]=0,c[12]=g,c[1]=0,c[5]=f,c[9]=0,c[13]=p,c[2]=0,c[6]=0,c[10]=m,c[14]=v,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(t){const e=this.elements,r=t.elements;for(let i=0;i<16;i++)if(e[i]!==r[i])return!1;return!0}fromArray(t,e=0){for(let r=0;r<16;r++)this.elements[r]=t[r+e];return this}toArray(t=[],e=0){const r=this.elements;return t[e]=r[0],t[e+1]=r[1],t[e+2]=r[2],t[e+3]=r[3],t[e+4]=r[4],t[e+5]=r[5],t[e+6]=r[6],t[e+7]=r[7],t[e+8]=r[8],t[e+9]=r[9],t[e+10]=r[10],t[e+11]=r[11],t[e+12]=r[12],t[e+13]=r[13],t[e+14]=r[14],t[e+15]=r[15],t}}const Qi=new D,Lr=new Re,mS=new D(0,0,0),yS=new D(1,1,1),Dn=new D,ja=new D,Ze=new D,cm=new Re,hm=new Wi;class ts{constructor(t=0,e=0,r=0,i=ts.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=r,this._order=i}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,r,i=this._order){return this._x=t,this._y=e,this._z=r,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,r=!0){const i=t.elements,s=i[0],o=i[4],a=i[8],l=i[1],c=i[5],h=i[9],f=i[2],g=i[6],p=i[10];switch(e){case"XYZ":this._y=Math.asin(At(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-h,p),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(g,c),this._z=0);break;case"YXZ":this._x=Math.asin(-At(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(a,p),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-f,s),this._z=0);break;case"ZXY":this._x=Math.asin(At(g,-1,1)),Math.abs(g)<.9999999?(this._y=Math.atan2(-f,p),this._z=Math.atan2(-o,c)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-At(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(g,p),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-o,c));break;case"YZX":this._z=Math.asin(At(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-h,c),this._y=Math.atan2(-f,s)):(this._x=0,this._y=Math.atan2(a,p));break;case"XZY":this._z=Math.asin(-At(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(g,c),this._y=Math.atan2(a,s)):(this._x=Math.atan2(-h,p),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,r===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,r){return cm.makeRotationFromQuaternion(t),this.setFromRotationMatrix(cm,e,r)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return hm.setFromEuler(this),this.setFromQuaternion(hm,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}ts.DEFAULT_ORDER="XYZ";class vS{constructor(){this.mask=1}set(t){this.mask=(1<<t|0)>>>0}enable(t){this.mask|=1<<t|0}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t|0}disable(t){this.mask&=~(1<<t|0)}disableAll(){this.mask=0}test(t){return(this.mask&t.mask)!==0}isEnabled(t){return(this.mask&(1<<t|0))!==0}}let xS=0;const fm=new D,es=new Wi,xn=new Re,Va=new D,ao=new D,_S=new D,bS=new Wi,dm=new D(1,0,0),pm=new D(0,1,0),gm=new D(0,0,1),mm={type:"added"},wS={type:"removed"},rs={type:"childadded",child:null},Tc={type:"childremoved",child:null};class en extends Ia{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:xS++}),this.uuid=Gi(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=en.DEFAULT_UP.clone();const t=new D,e=new ts,r=new Wi,i=new D(1,1,1);function s(){r.setFromEuler(e,!1)}function o(){e.setFromQuaternion(r,void 0,!1)}e._onChange(s),r._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Re},normalMatrix:{value:new Ln}}),this.matrix=new Re,this.matrixWorld=new Re,this.matrixAutoUpdate=en.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=en.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new vS,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(t){return this.quaternion.premultiply(t),this}setRotationFromAxisAngle(t,e){this.quaternion.setFromAxisAngle(t,e)}setRotationFromEuler(t){this.quaternion.setFromEuler(t,!0)}setRotationFromMatrix(t){this.quaternion.setFromRotationMatrix(t)}setRotationFromQuaternion(t){this.quaternion.copy(t)}rotateOnAxis(t,e){return es.setFromAxisAngle(t,e),this.quaternion.multiply(es),this}rotateOnWorldAxis(t,e){return es.setFromAxisAngle(t,e),this.quaternion.premultiply(es),this}rotateX(t){return this.rotateOnAxis(dm,t)}rotateY(t){return this.rotateOnAxis(pm,t)}rotateZ(t){return this.rotateOnAxis(gm,t)}translateOnAxis(t,e){return fm.copy(t).applyQuaternion(this.quaternion),this.position.add(fm.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(dm,t)}translateY(t){return this.translateOnAxis(pm,t)}translateZ(t){return this.translateOnAxis(gm,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(xn.copy(this.matrixWorld).invert())}lookAt(t,e,r){t.isVector3?Va.copy(t):Va.set(t,e,r);const i=this.parent;this.updateWorldMatrix(!0,!1),ao.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?xn.lookAt(ao,Va,this.up):xn.lookAt(Va,ao,this.up),this.quaternion.setFromRotationMatrix(xn),i&&(xn.extractRotation(i.matrixWorld),es.setFromRotationMatrix(xn),this.quaternion.premultiply(es.invert()))}add(t){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return t===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(t.removeFromParent(),t.parent=this,this.children.push(t),t.dispatchEvent(mm),rs.child=t,this.dispatchEvent(rs),rs.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let r=0;r<arguments.length;r++)this.remove(arguments[r]);return this}const e=this.children.indexOf(t);return e!==-1&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(wS),Tc.child=t,this.dispatchEvent(Tc),Tc.child=null),this}removeFromParent(){const t=this.parent;return t!==null&&t.remove(this),this}clear(){return this.remove(...this.children)}attach(t){return this.updateWorldMatrix(!0,!1),xn.copy(this.matrixWorld).invert(),t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),xn.multiply(t.parent.matrixWorld)),t.applyMatrix4(xn),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(mm),rs.child=t,this.dispatchEvent(rs),rs.child=null,this}getObjectById(t){return this.getObjectByProperty("id",t)}getObjectByName(t){return this.getObjectByProperty("name",t)}getObjectByProperty(t,e){if(this[t]===e)return this;for(let r=0,i=this.children.length;r<i;r++){const o=this.children[r].getObjectByProperty(t,e);if(o!==void 0)return o}}getObjectsByProperty(t,e,r=[]){this[t]===e&&r.push(this);const i=this.children;for(let s=0,o=i.length;s<o;s++)i[s].getObjectsByProperty(t,e,r);return r}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(ao,t,_S),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(ao,bS,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);const e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}traverse(t){t(this);const e=this.children;for(let r=0,i=e.length;r<i;r++)e[r].traverse(t)}traverseVisible(t){if(this.visible===!1)return;t(this);const e=this.children;for(let r=0,i=e.length;r<i;r++)e[r].traverseVisible(t)}traverseAncestors(t){const e=this.parent;e!==null&&(t(e),e.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);const e=this.children;for(let r=0,i=e.length;r<i;r++)e[r].updateMatrixWorld(t)}updateWorldMatrix(t,e){const r=this.parent;if(t===!0&&r!==null&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),e===!0){const i=this.children;for(let s=0,o=i.length;s<o;s++)i[s].updateWorldMatrix(!1,!0)}}toJSON(t){const e=t===void 0||typeof t=="string",r={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},r.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map(a=>({...a,boundingBox:a.boundingBox?a.boundingBox.toJSON():void 0,boundingSphere:a.boundingSphere?a.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map(a=>({...a})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(t),i.indirectTexture=this._indirectTexture.toJSON(t),this._colorsTexture!==null&&(i.colorsTexture=this._colorsTexture.toJSON(t)),this.boundingSphere!==null&&(i.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(i.boundingBox=this.boundingBox.toJSON()));function s(a,l){return a[l.uuid]===void 0&&(a[l.uuid]=l.toJSON(t)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=s(t.geometries,this.geometry);const a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){const l=a.shapes;if(Array.isArray(l))for(let c=0,h=l.length;c<h;c++){const f=l[c];s(t.shapes,f)}else s(t.shapes,l)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(t.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const a=[];for(let l=0,c=this.material.length;l<c;l++)a.push(s(t.materials,this.material[l]));i.material=a}else i.material=s(t.materials,this.material);if(this.children.length>0){i.children=[];for(let a=0;a<this.children.length;a++)i.children.push(this.children[a].toJSON(t).object)}if(this.animations.length>0){i.animations=[];for(let a=0;a<this.animations.length;a++){const l=this.animations[a];i.animations.push(s(t.animations,l))}}if(e){const a=o(t.geometries),l=o(t.materials),c=o(t.textures),h=o(t.images),f=o(t.shapes),g=o(t.skeletons),p=o(t.animations),m=o(t.nodes);a.length>0&&(r.geometries=a),l.length>0&&(r.materials=l),c.length>0&&(r.textures=c),h.length>0&&(r.images=h),f.length>0&&(r.shapes=f),g.length>0&&(r.skeletons=g),p.length>0&&(r.animations=p),m.length>0&&(r.nodes=m)}return r.object=i,r;function o(a){const l=[];for(const c in a){const h=a[c];delete h.metadata,l.push(h)}return l}}clone(t){return new this.constructor().copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),e===!0)for(let r=0;r<t.children.length;r++){const i=t.children[r];this.add(i.clone())}return this}}en.DEFAULT_UP=new D(0,1,0),en.DEFAULT_MATRIX_AUTO_UPDATE=!0,en.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Nr=new D,_n=new D,Cc=new D,bn=new D,ns=new D,is=new D,ym=new D,kc=new D,Ic=new D,Pc=new D,Rc=new io,Lc=new io,Nc=new io;class Fr{constructor(t=new D,e=new D,r=new D){this.a=t,this.b=e,this.c=r}static getNormal(t,e,r,i){i.subVectors(r,e),Nr.subVectors(t,e),i.cross(Nr);const s=i.lengthSq();return s>0?i.multiplyScalar(1/Math.sqrt(s)):i.set(0,0,0)}static getBarycoord(t,e,r,i,s){Nr.subVectors(i,e),_n.subVectors(r,e),Cc.subVectors(t,e);const o=Nr.dot(Nr),a=Nr.dot(_n),l=Nr.dot(Cc),c=_n.dot(_n),h=_n.dot(Cc),f=o*c-a*a;if(f===0)return s.set(0,0,0),null;const g=1/f,p=(c*l-a*h)*g,m=(o*h-a*l)*g;return s.set(1-p-m,m,p)}static containsPoint(t,e,r,i){return this.getBarycoord(t,e,r,i,bn)===null?!1:bn.x>=0&&bn.y>=0&&bn.x+bn.y<=1}static getInterpolation(t,e,r,i,s,o,a,l){return this.getBarycoord(t,e,r,i,bn)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(s,bn.x),l.addScaledVector(o,bn.y),l.addScaledVector(a,bn.z),l)}static getInterpolatedAttribute(t,e,r,i,s,o){return Rc.setScalar(0),Lc.setScalar(0),Nc.setScalar(0),Rc.fromBufferAttribute(t,e),Lc.fromBufferAttribute(t,r),Nc.fromBufferAttribute(t,i),o.setScalar(0),o.addScaledVector(Rc,s.x),o.addScaledVector(Lc,s.y),o.addScaledVector(Nc,s.z),o}static isFrontFacing(t,e,r,i){return Nr.subVectors(r,e),_n.subVectors(t,e),Nr.cross(_n).dot(i)<0}set(t,e,r){return this.a.copy(t),this.b.copy(e),this.c.copy(r),this}setFromPointsAndIndices(t,e,r,i){return this.a.copy(t[e]),this.b.copy(t[r]),this.c.copy(t[i]),this}setFromAttributeAndIndices(t,e,r,i){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,r),this.c.fromBufferAttribute(t,i),this}clone(){return new this.constructor().copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return Nr.subVectors(this.c,this.b),_n.subVectors(this.a,this.b),Nr.cross(_n).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return Fr.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return Fr.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,r,i,s){return Fr.getInterpolation(t,this.a,this.b,this.c,e,r,i,s)}containsPoint(t){return Fr.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return Fr.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const r=this.a,i=this.b,s=this.c;let o,a;ns.subVectors(i,r),is.subVectors(s,r),kc.subVectors(t,r);const l=ns.dot(kc),c=is.dot(kc);if(l<=0&&c<=0)return e.copy(r);Ic.subVectors(t,i);const h=ns.dot(Ic),f=is.dot(Ic);if(h>=0&&f<=h)return e.copy(i);const g=l*f-h*c;if(g<=0&&l>=0&&h<=0)return o=l/(l-h),e.copy(r).addScaledVector(ns,o);Pc.subVectors(t,s);const p=ns.dot(Pc),m=is.dot(Pc);if(m>=0&&p<=m)return e.copy(s);const v=p*c-l*m;if(v<=0&&c>=0&&m<=0)return a=c/(c-m),e.copy(r).addScaledVector(is,a);const _=h*m-p*f;if(_<=0&&f-h>=0&&p-m>=0)return ym.subVectors(s,i),a=(f-h)/(f-h+(p-m)),e.copy(i).addScaledVector(ym,a);const S=1/(_+v+g);return o=v*S,a=g*S,e.copy(r).addScaledVector(ns,o).addScaledVector(is,a)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}const vm={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},Bn={h:0,s:0,l:0},Da={h:0,s:0,l:0};function Fc(n,t,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?n+(t-n)*6*e:e<1/2?t:e<2/3?n+(t-n)*6*(2/3-e):n}class oi{constructor(t,e,r){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,r)}set(t,e,r){if(e===void 0&&r===void 0){const i=t;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(t,e,r);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=Ir){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,Pr.colorSpaceToWorking(this,e),this}setRGB(t,e,r,i=Pr.workingColorSpace){return this.r=t,this.g=e,this.b=r,Pr.colorSpaceToWorking(this,i),this}setHSL(t,e,r,i=Pr.workingColorSpace){if(t=aS(t,1),e=At(e,0,1),r=At(r,0,1),e===0)this.r=this.g=this.b=r;else{const s=r<=.5?r*(1+e):r+e-r*e,o=2*r-s;this.r=Fc(o,s,t+1/3),this.g=Fc(o,s,t),this.b=Fc(o,s,t-1/3)}return Pr.colorSpaceToWorking(this,i),this}setStyle(t,e=Ir){function r(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(t)){let s;const o=i[1],a=i[2];switch(o){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return r(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,e);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return r(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,e);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return r(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,e);break;default:console.warn("THREE.Color: Unknown color model "+t)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(t)){const s=i[1],o=s.length;if(o===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,e);if(o===6)return this.setHex(parseInt(s,16),e);console.warn("THREE.Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=Ir){const r=vm[t.toLowerCase()];return r!==void 0?this.setHex(r,e):console.warn("THREE.Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=mn(t.r),this.g=mn(t.g),this.b=mn(t.b),this}copyLinearToSRGB(t){return this.r=Ui(t.r),this.g=Ui(t.g),this.b=Ui(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=Ir){return Pr.workingToColorSpace(Ce.copy(this),t),Math.round(At(Ce.r*255,0,255))*65536+Math.round(At(Ce.g*255,0,255))*256+Math.round(At(Ce.b*255,0,255))}getHexString(t=Ir){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=Pr.workingColorSpace){Pr.workingToColorSpace(Ce.copy(this),e);const r=Ce.r,i=Ce.g,s=Ce.b,o=Math.max(r,i,s),a=Math.min(r,i,s);let l,c;const h=(a+o)/2;if(a===o)l=0,c=0;else{const f=o-a;switch(c=h<=.5?f/(o+a):f/(2-o-a),o){case r:l=(i-s)/f+(i<s?6:0);break;case i:l=(s-r)/f+2;break;case s:l=(r-i)/f+4;break}l/=6}return t.h=l,t.s=c,t.l=h,t}getRGB(t,e=Pr.workingColorSpace){return Pr.workingToColorSpace(Ce.copy(this),e),t.r=Ce.r,t.g=Ce.g,t.b=Ce.b,t}getStyle(t=Ir){Pr.workingToColorSpace(Ce.copy(this),t);const e=Ce.r,r=Ce.g,i=Ce.b;return t!==Ir?`color(${t} ${e.toFixed(3)} ${r.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(e*255)},${Math.round(r*255)},${Math.round(i*255)})`}offsetHSL(t,e,r){return this.getHSL(Bn),this.setHSL(Bn.h+t,Bn.s+e,Bn.l+r)}add(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this}addColors(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this}addScalar(t){return this.r+=t,this.g+=t,this.b+=t,this}sub(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this}multiply(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this}multiplyScalar(t){return this.r*=t,this.g*=t,this.b*=t,this}lerp(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this}lerpColors(t,e,r){return this.r=t.r+(e.r-t.r)*r,this.g=t.g+(e.g-t.g)*r,this.b=t.b+(e.b-t.b)*r,this}lerpHSL(t,e){this.getHSL(Bn),t.getHSL(Da);const r=vc(Bn.h,Da.h,e),i=vc(Bn.s,Da.s,e),s=vc(Bn.l,Da.l,e);return this.setHSL(r,i,s),this}setFromVector3(t){return this.r=t.x,this.g=t.y,this.b=t.z,this}applyMatrix3(t){const e=this.r,r=this.g,i=this.b,s=t.elements;return this.r=s[0]*e+s[3]*r+s[6]*i,this.g=s[1]*e+s[4]*r+s[7]*i,this.b=s[2]*e+s[5]*r+s[8]*i,this}equals(t){return t.r===this.r&&t.g===this.g&&t.b===this.b}fromArray(t,e=0){return this.r=t[e],this.g=t[e+1],this.b=t[e+2],this}toArray(t=[],e=0){return t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t}fromBufferAttribute(t,e){return this.r=t.getX(e),this.g=t.getY(e),this.b=t.getZ(e),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const Ce=new oi;oi.NAMES=vm;let SS=0;class xm extends Ia{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:SS++}),this.uuid=Gi(),this.name="",this.type="Material",this.blending=Hg,this.side=mc,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Wg,this.blendDst=Ug,this.blendEquation=Gg,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new oi(0,0,0),this.blendAlpha=0,this.depthFunc=Yg,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=em,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Hi,this.stencilZFail=Hi,this.stencilZPass=Hi,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(t!==void 0)for(const e in t){const r=t[e];if(r===void 0){console.warn(`THREE.Material: parameter '${e}' has value of undefined.`);continue}const i=this[e];if(i===void 0){console.warn(`THREE.Material: '${e}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(r):i&&i.isVector3&&r&&r.isVector3?i.copy(r):this[e]=r}}toJSON(t){const e=t===void 0||typeof t=="string";e&&(t={textures:{},images:{}});const r={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.color&&this.color.isColor&&(r.color=this.color.getHex()),this.roughness!==void 0&&(r.roughness=this.roughness),this.metalness!==void 0&&(r.metalness=this.metalness),this.sheen!==void 0&&(r.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(r.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(r.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(r.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(r.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(r.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(r.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(r.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(r.shininess=this.shininess),this.clearcoat!==void 0&&(r.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(r.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(r.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(r.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(r.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,r.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.dispersion!==void 0&&(r.dispersion=this.dispersion),this.iridescence!==void 0&&(r.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(r.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(r.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(r.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(r.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),this.anisotropy!==void 0&&(r.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(r.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(r.anisotropyMap=this.anisotropyMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(r.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(r.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(r.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(r.lightMap=this.lightMap.toJSON(t).uuid,r.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(r.aoMap=this.aoMap.toJSON(t).uuid,r.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(r.bumpMap=this.bumpMap.toJSON(t).uuid,r.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(r.normalMap=this.normalMap.toJSON(t).uuid,r.normalMapType=this.normalMapType,r.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(r.displacementMap=this.displacementMap.toJSON(t).uuid,r.displacementScale=this.displacementScale,r.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(r.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(r.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(r.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(r.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(r.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(r.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(r.envMap=this.envMap.toJSON(t).uuid,this.combine!==void 0&&(r.combine=this.combine)),this.envMapRotation!==void 0&&(r.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(r.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(r.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(r.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(r.gradientMap=this.gradientMap.toJSON(t).uuid),this.transmission!==void 0&&(r.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(r.transmissionMap=this.transmissionMap.toJSON(t).uuid),this.thickness!==void 0&&(r.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(r.thicknessMap=this.thicknessMap.toJSON(t).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(r.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(r.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(r.size=this.size),this.shadowSide!==null&&(r.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(r.sizeAttenuation=this.sizeAttenuation),this.blending!==Hg&&(r.blending=this.blending),this.side!==mc&&(r.side=this.side),this.vertexColors===!0&&(r.vertexColors=!0),this.opacity<1&&(r.opacity=this.opacity),this.transparent===!0&&(r.transparent=!0),this.blendSrc!==Wg&&(r.blendSrc=this.blendSrc),this.blendDst!==Ug&&(r.blendDst=this.blendDst),this.blendEquation!==Gg&&(r.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(r.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(r.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(r.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(r.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(r.blendAlpha=this.blendAlpha),this.depthFunc!==Yg&&(r.depthFunc=this.depthFunc),this.depthTest===!1&&(r.depthTest=this.depthTest),this.depthWrite===!1&&(r.depthWrite=this.depthWrite),this.colorWrite===!1&&(r.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(r.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==em&&(r.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(r.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Hi&&(r.stencilFail=this.stencilFail),this.stencilZFail!==Hi&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==Hi&&(r.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(r.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(r.rotation=this.rotation),this.polygonOffset===!0&&(r.polygonOffset=!0),this.polygonOffsetFactor!==0&&(r.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(r.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(r.linewidth=this.linewidth),this.dashSize!==void 0&&(r.dashSize=this.dashSize),this.gapSize!==void 0&&(r.gapSize=this.gapSize),this.scale!==void 0&&(r.scale=this.scale),this.dithering===!0&&(r.dithering=!0),this.alphaTest>0&&(r.alphaTest=this.alphaTest),this.alphaHash===!0&&(r.alphaHash=!0),this.alphaToCoverage===!0&&(r.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(r.premultipliedAlpha=!0),this.forceSinglePass===!0&&(r.forceSinglePass=!0),this.wireframe===!0&&(r.wireframe=!0),this.wireframeLinewidth>1&&(r.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(r.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(r.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(r.flatShading=!0),this.visible===!1&&(r.visible=!1),this.toneMapped===!1&&(r.toneMapped=!1),this.fog===!1&&(r.fog=!1),Object.keys(this.userData).length>0&&(r.userData=this.userData);function i(s){const o=[];for(const a in s){const l=s[a];delete l.metadata,o.push(l)}return o}if(e){const s=i(t.textures),o=i(t.images);s.length>0&&(r.textures=s),o.length>0&&(r.images=o)}return r}clone(){return new this.constructor().copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;const e=t.clippingPlanes;let r=null;if(e!==null){const i=e.length;r=new Array(i);for(let s=0;s!==i;++s)r[s]=e[s].clone()}return this.clippingPlanes=r,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaHash=t.alphaHash,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){t===!0&&this.version++}}class ss extends xm{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new oi(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ts,this.combine=Xg,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}const he=new D,Ba=new yt;let MS=0;class os{constructor(t,e,r=!1){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:MS++}),this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=r,this.usage=rm,this.updateRanges=[],this.gpuType=iS,this.version=0}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,r){t*=this.itemSize,r*=e.itemSize;for(let i=0,s=this.itemSize;i<s;i++)this.array[t+i]=e.array[r+i];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(this.itemSize===2)for(let e=0,r=this.count;e<r;e++)Ba.fromBufferAttribute(this,e),Ba.applyMatrix3(t),this.setXY(e,Ba.x,Ba.y);else if(this.itemSize===3)for(let e=0,r=this.count;e<r;e++)he.fromBufferAttribute(this,e),he.applyMatrix3(t),this.setXYZ(e,he.x,he.y,he.z);return this}applyMatrix4(t){for(let e=0,r=this.count;e<r;e++)he.fromBufferAttribute(this,e),he.applyMatrix4(t),this.setXYZ(e,he.x,he.y,he.z);return this}applyNormalMatrix(t){for(let e=0,r=this.count;e<r;e++)he.fromBufferAttribute(this,e),he.applyNormalMatrix(t),this.setXYZ(e,he.x,he.y,he.z);return this}transformDirection(t){for(let e=0,r=this.count;e<r;e++)he.fromBufferAttribute(this,e),he.transformDirection(t),this.setXYZ(e,he.x,he.y,he.z);return this}set(t,e=0){return this.array.set(t,e),this}getComponent(t,e){let r=this.array[t*this.itemSize+e];return this.normalized&&(r=no(r,this.array)),r}setComponent(t,e,r){return this.normalized&&(r=Be(r,this.array)),this.array[t*this.itemSize+e]=r,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=no(e,this.array)),e}setX(t,e){return this.normalized&&(e=Be(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=no(e,this.array)),e}setY(t,e){return this.normalized&&(e=Be(e,this.array)),this.array[t*this.itemSize+1]=e,this}getZ(t){let e=this.array[t*this.itemSize+2];return this.normalized&&(e=no(e,this.array)),e}setZ(t,e){return this.normalized&&(e=Be(e,this.array)),this.array[t*this.itemSize+2]=e,this}getW(t){let e=this.array[t*this.itemSize+3];return this.normalized&&(e=no(e,this.array)),e}setW(t,e){return this.normalized&&(e=Be(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,r){return t*=this.itemSize,this.normalized&&(e=Be(e,this.array),r=Be(r,this.array)),this.array[t+0]=e,this.array[t+1]=r,this}setXYZ(t,e,r,i){return t*=this.itemSize,this.normalized&&(e=Be(e,this.array),r=Be(r,this.array),i=Be(i,this.array)),this.array[t+0]=e,this.array[t+1]=r,this.array[t+2]=i,this}setXYZW(t,e,r,i,s){return t*=this.itemSize,this.normalized&&(e=Be(e,this.array),r=Be(r,this.array),i=Be(i,this.array),s=Be(s,this.array)),this.array[t+0]=e,this.array[t+1]=r,this.array[t+2]=i,this.array[t+3]=s,this}onUpload(t){return this.onUploadCallback=t,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const t={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(t.name=this.name),this.usage!==rm&&(t.usage=this.usage),t}}class ES extends os{constructor(t,e,r){super(new Uint16Array(t),e,r)}}class AS extends os{constructor(t,e,r){super(new Uint32Array(t),e,r)}}class wn extends os{constructor(t,e,r){super(new Float32Array(t),e,r)}}let OS=0;const pr=new Re,jc=new en,as=new D,Ke=new Xi,uo=new Xi,_e=new D;class ai extends Ia{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:OS++}),this.uuid=Gi(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(t){return Array.isArray(t)?this.index=new(uS(t)?AS:ES)(t,1):this.index=t,this}setIndirect(t){return this.indirect=t,this}getIndirect(){return this.indirect}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return this.attributes[t]!==void 0}addGroup(t,e,r=0){this.groups.push({start:t,count:e,materialIndex:r})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){const e=this.attributes.position;e!==void 0&&(e.applyMatrix4(t),e.needsUpdate=!0);const r=this.attributes.normal;if(r!==void 0){const s=new Ln().getNormalMatrix(t);r.applyNormalMatrix(s),r.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(t),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(t){return pr.makeRotationFromQuaternion(t),this.applyMatrix4(pr),this}rotateX(t){return pr.makeRotationX(t),this.applyMatrix4(pr),this}rotateY(t){return pr.makeRotationY(t),this.applyMatrix4(pr),this}rotateZ(t){return pr.makeRotationZ(t),this.applyMatrix4(pr),this}translate(t,e,r){return pr.makeTranslation(t,e,r),this.applyMatrix4(pr),this}scale(t,e,r){return pr.makeScale(t,e,r),this.applyMatrix4(pr),this}lookAt(t){return jc.lookAt(t),jc.updateMatrix(),this.applyMatrix4(jc.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(as).negate(),this.translate(as.x,as.y,as.z),this}setFromPoints(t){const e=this.getAttribute("position");if(e===void 0){const r=[];for(let i=0,s=t.length;i<s;i++){const o=t[i];r.push(o.x,o.y,o.z||0)}this.setAttribute("position",new wn(r,3))}else{const r=Math.min(t.length,e.count);for(let i=0;i<r;i++){const s=t[i];e.setXYZ(i,s.x,s.y,s.z||0)}t.length>e.count&&console.warn("THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),e.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Xi);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new D(-1/0,-1/0,-1/0),new D(1/0,1/0,1/0));return}if(t!==void 0){if(this.boundingBox.setFromBufferAttribute(t),e)for(let r=0,i=e.length;r<i;r++){const s=e[r];Ke.setFromBufferAttribute(s),this.morphTargetsRelative?(_e.addVectors(this.boundingBox.min,Ke.min),this.boundingBox.expandByPoint(_e),_e.addVectors(this.boundingBox.max,Ke.max),this.boundingBox.expandByPoint(_e)):(this.boundingBox.expandByPoint(Ke.min),this.boundingBox.expandByPoint(Ke.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new lm);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new D,1/0);return}if(t){const r=this.boundingSphere.center;if(Ke.setFromBufferAttribute(t),e)for(let s=0,o=e.length;s<o;s++){const a=e[s];uo.setFromBufferAttribute(a),this.morphTargetsRelative?(_e.addVectors(Ke.min,uo.min),Ke.expandByPoint(_e),_e.addVectors(Ke.max,uo.max),Ke.expandByPoint(_e)):(Ke.expandByPoint(uo.min),Ke.expandByPoint(uo.max))}Ke.getCenter(r);let i=0;for(let s=0,o=t.count;s<o;s++)_e.fromBufferAttribute(t,s),i=Math.max(i,r.distanceToSquared(_e));if(e)for(let s=0,o=e.length;s<o;s++){const a=e[s],l=this.morphTargetsRelative;for(let c=0,h=a.count;c<h;c++)_e.fromBufferAttribute(a,c),l&&(as.fromBufferAttribute(t,c),_e.add(as)),i=Math.max(i,r.distanceToSquared(_e))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const t=this.index,e=this.attributes;if(t===null||e.position===void 0||e.normal===void 0||e.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const r=e.position,i=e.normal,s=e.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new os(new Float32Array(4*r.count),4));const o=this.getAttribute("tangent"),a=[],l=[];for(let I=0;I<r.count;I++)a[I]=new D,l[I]=new D;const c=new D,h=new D,f=new D,g=new yt,p=new yt,m=new yt,v=new D,_=new D;function S(I,L,Y){c.fromBufferAttribute(r,I),h.fromBufferAttribute(r,L),f.fromBufferAttribute(r,Y),g.fromBufferAttribute(s,I),p.fromBufferAttribute(s,L),m.fromBufferAttribute(s,Y),h.sub(c),f.sub(c),p.sub(g),m.sub(g);const X=1/(p.x*m.y-m.x*p.y);isFinite(X)&&(v.copy(h).multiplyScalar(m.y).addScaledVector(f,-p.y).multiplyScalar(X),_.copy(f).multiplyScalar(p.x).addScaledVector(h,-m.x).multiplyScalar(X),a[I].add(v),a[L].add(v),a[Y].add(v),l[I].add(_),l[L].add(_),l[Y].add(_))}let A=this.groups;A.length===0&&(A=[{start:0,count:t.count}]);for(let I=0,L=A.length;I<L;++I){const Y=A[I],X=Y.start,it=Y.count;for(let rt=X,vt=X+it;rt<vt;rt+=3)S(t.getX(rt+0),t.getX(rt+1),t.getX(rt+2))}const C=new D,O=new D,M=new D,z=new D;function R(I){M.fromBufferAttribute(i,I),z.copy(M);const L=a[I];C.copy(L),C.sub(M.multiplyScalar(M.dot(L))).normalize(),O.crossVectors(z,L);const X=O.dot(l[I])<0?-1:1;o.setXYZW(I,C.x,C.y,C.z,X)}for(let I=0,L=A.length;I<L;++I){const Y=A[I],X=Y.start,it=Y.count;for(let rt=X,vt=X+it;rt<vt;rt+=3)R(t.getX(rt+0)),R(t.getX(rt+1)),R(t.getX(rt+2))}}computeVertexNormals(){const t=this.index,e=this.getAttribute("position");if(e!==void 0){let r=this.getAttribute("normal");if(r===void 0)r=new os(new Float32Array(e.count*3),3),this.setAttribute("normal",r);else for(let g=0,p=r.count;g<p;g++)r.setXYZ(g,0,0,0);const i=new D,s=new D,o=new D,a=new D,l=new D,c=new D,h=new D,f=new D;if(t)for(let g=0,p=t.count;g<p;g+=3){const m=t.getX(g+0),v=t.getX(g+1),_=t.getX(g+2);i.fromBufferAttribute(e,m),s.fromBufferAttribute(e,v),o.fromBufferAttribute(e,_),h.subVectors(o,s),f.subVectors(i,s),h.cross(f),a.fromBufferAttribute(r,m),l.fromBufferAttribute(r,v),c.fromBufferAttribute(r,_),a.add(h),l.add(h),c.add(h),r.setXYZ(m,a.x,a.y,a.z),r.setXYZ(v,l.x,l.y,l.z),r.setXYZ(_,c.x,c.y,c.z)}else for(let g=0,p=e.count;g<p;g+=3)i.fromBufferAttribute(e,g+0),s.fromBufferAttribute(e,g+1),o.fromBufferAttribute(e,g+2),h.subVectors(o,s),f.subVectors(i,s),h.cross(f),r.setXYZ(g+0,h.x,h.y,h.z),r.setXYZ(g+1,h.x,h.y,h.z),r.setXYZ(g+2,h.x,h.y,h.z);this.normalizeNormals(),r.needsUpdate=!0}}normalizeNormals(){const t=this.attributes.normal;for(let e=0,r=t.count;e<r;e++)_e.fromBufferAttribute(t,e),_e.normalize(),t.setXYZ(e,_e.x,_e.y,_e.z)}toNonIndexed(){function t(a,l){const c=a.array,h=a.itemSize,f=a.normalized,g=new c.constructor(l.length*h);let p=0,m=0;for(let v=0,_=l.length;v<_;v++){a.isInterleavedBufferAttribute?p=l[v]*a.data.stride+a.offset:p=l[v]*h;for(let S=0;S<h;S++)g[m++]=c[p++]}return new os(g,h,f)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const e=new ai,r=this.index.array,i=this.attributes;for(const a in i){const l=i[a],c=t(l,r);e.setAttribute(a,c)}const s=this.morphAttributes;for(const a in s){const l=[],c=s[a];for(let h=0,f=c.length;h<f;h++){const g=c[h],p=t(g,r);l.push(p)}e.morphAttributes[a]=l}e.morphTargetsRelative=this.morphTargetsRelative;const o=this.groups;for(let a=0,l=o.length;a<l;a++){const c=o[a];e.addGroup(c.start,c.count,c.materialIndex)}return e}toJSON(){const t={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,this.name!==""&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),this.parameters!==void 0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(t[c]=l[c]);return t}t.data={attributes:{}};const e=this.index;e!==null&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const r=this.attributes;for(const l in r){const c=r[l];t.data.attributes[l]=c.toJSON(t.data)}const i={};let s=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],h=[];for(let f=0,g=c.length;f<g;f++){const p=c[f];h.push(p.toJSON(t.data))}h.length>0&&(i[l]=h,s=!0)}s&&(t.data.morphAttributes=i,t.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(t.data.groups=JSON.parse(JSON.stringify(o)));const a=this.boundingSphere;return a!==null&&(t.data.boundingSphere=a.toJSON()),t}clone(){return new this.constructor().copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const e={};this.name=t.name;const r=t.index;r!==null&&this.setIndex(r.clone());const i=t.attributes;for(const c in i){const h=i[c];this.setAttribute(c,h.clone(e))}const s=t.morphAttributes;for(const c in s){const h=[],f=s[c];for(let g=0,p=f.length;g<p;g++)h.push(f[g].clone(e));this.morphAttributes[c]=h}this.morphTargetsRelative=t.morphTargetsRelative;const o=t.groups;for(let c=0,h=o.length;c<h;c++){const f=o[c];this.addGroup(f.start,f.count,f.materialIndex)}const a=t.boundingBox;a!==null&&(this.boundingBox=a.clone());const l=t.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const _m=new Re,ui=new gS,qa=new lm,bm=new D,$a=new D,Ha=new D,Ga=new D,Vc=new D,Wa=new D,wm=new D,Ua=new D;class us extends en{constructor(t=new ai,e=new ss){super(),this.isMesh=!0,this.type="Mesh",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),t.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),t.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}updateMorphTargets(){const e=this.geometry.morphAttributes,r=Object.keys(e);if(r.length>0){const i=e[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=i.length;s<o;s++){const a=i[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}getVertexPosition(t,e){const r=this.geometry,i=r.attributes.position,s=r.morphAttributes.position,o=r.morphTargetsRelative;e.fromBufferAttribute(i,t);const a=this.morphTargetInfluences;if(s&&a){Wa.set(0,0,0);for(let l=0,c=s.length;l<c;l++){const h=a[l],f=s[l];h!==0&&(Vc.fromBufferAttribute(f,t),o?Wa.addScaledVector(Vc,h):Wa.addScaledVector(Vc.sub(e),h))}e.add(Wa)}return e}raycast(t,e){const r=this.geometry,i=this.material,s=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),qa.copy(r.boundingSphere),qa.applyMatrix4(s),ui.copy(t.ray).recast(t.near),!(qa.containsPoint(ui.origin)===!1&&(ui.intersectSphere(qa,bm)===null||ui.origin.distanceToSquared(bm)>(t.far-t.near)**2))&&(_m.copy(s).invert(),ui.copy(t.ray).applyMatrix4(_m),!(r.boundingBox!==null&&ui.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(t,e,ui)))}_computeIntersections(t,e,r){let i;const s=this.geometry,o=this.material,a=s.index,l=s.attributes.position,c=s.attributes.uv,h=s.attributes.uv1,f=s.attributes.normal,g=s.groups,p=s.drawRange;if(a!==null)if(Array.isArray(o))for(let m=0,v=g.length;m<v;m++){const _=g[m],S=o[_.materialIndex],A=Math.max(_.start,p.start),C=Math.min(a.count,Math.min(_.start+_.count,p.start+p.count));for(let O=A,M=C;O<M;O+=3){const z=a.getX(O),R=a.getX(O+1),I=a.getX(O+2);i=Ya(this,S,t,r,c,h,f,z,R,I),i&&(i.faceIndex=Math.floor(O/3),i.face.materialIndex=_.materialIndex,e.push(i))}}else{const m=Math.max(0,p.start),v=Math.min(a.count,p.start+p.count);for(let _=m,S=v;_<S;_+=3){const A=a.getX(_),C=a.getX(_+1),O=a.getX(_+2);i=Ya(this,o,t,r,c,h,f,A,C,O),i&&(i.faceIndex=Math.floor(_/3),e.push(i))}}else if(l!==void 0)if(Array.isArray(o))for(let m=0,v=g.length;m<v;m++){const _=g[m],S=o[_.materialIndex],A=Math.max(_.start,p.start),C=Math.min(l.count,Math.min(_.start+_.count,p.start+p.count));for(let O=A,M=C;O<M;O+=3){const z=O,R=O+1,I=O+2;i=Ya(this,S,t,r,c,h,f,z,R,I),i&&(i.faceIndex=Math.floor(O/3),i.face.materialIndex=_.materialIndex,e.push(i))}}else{const m=Math.max(0,p.start),v=Math.min(l.count,p.start+p.count);for(let _=m,S=v;_<S;_+=3){const A=_,C=_+1,O=_+2;i=Ya(this,o,t,r,c,h,f,A,C,O),i&&(i.faceIndex=Math.floor(_/3),e.push(i))}}}}function zS(n,t,e,r,i,s,o,a){let l;if(t.side===Qw?l=r.intersectTriangle(o,s,i,!0,a):l=r.intersectTriangle(i,s,o,t.side===mc,a),l===null)return null;Ua.copy(a),Ua.applyMatrix4(n.matrixWorld);const c=e.ray.origin.distanceTo(Ua);return c<e.near||c>e.far?null:{distance:c,point:Ua.clone(),object:n}}function Ya(n,t,e,r,i,s,o,a,l,c){n.getVertexPosition(a,$a),n.getVertexPosition(l,Ha),n.getVertexPosition(c,Ga);const h=zS(n,t,e,r,$a,Ha,Ga,wm);if(h){const f=new D;Fr.getBarycoord(wm,$a,Ha,Ga,f),i&&(h.uv=Fr.getInterpolatedAttribute(i,a,l,c,f,new yt)),s&&(h.uv1=Fr.getInterpolatedAttribute(s,a,l,c,f,new yt)),o&&(h.normal=Fr.getInterpolatedAttribute(o,a,l,c,f,new D),h.normal.dot(r.direction)>0&&h.normal.multiplyScalar(-1));const g={a,b:l,c,normal:new D,materialIndex:0};Fr.getNormal($a,Ha,Ga,g.normal),h.face=g,h.barycoord=f}return h}class Xa extends ai{constructor(t=1,e=1,r=1,i=1,s=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:r,widthSegments:i,heightSegments:s,depthSegments:o};const a=this;i=Math.floor(i),s=Math.floor(s),o=Math.floor(o);const l=[],c=[],h=[],f=[];let g=0,p=0;m("z","y","x",-1,-1,r,e,t,o,s,0),m("z","y","x",1,-1,r,e,-t,o,s,1),m("x","z","y",1,1,t,r,e,i,o,2),m("x","z","y",1,-1,t,r,-e,i,o,3),m("x","y","z",1,-1,t,e,r,i,s,4),m("x","y","z",-1,-1,t,e,-r,i,s,5),this.setIndex(l),this.setAttribute("position",new wn(c,3)),this.setAttribute("normal",new wn(h,3)),this.setAttribute("uv",new wn(f,2));function m(v,_,S,A,C,O,M,z,R,I,L){const Y=O/R,X=M/I,it=O/2,rt=M/2,vt=z/2,mt=R+1,dt=I+1;let ut=0,W=0;const gt=new D;for(let k=0;k<dt;k++){const j=k*X-rt;for(let K=0;K<mt;K++){const Z=K*Y-it;gt[v]=Z*A,gt[_]=j*C,gt[S]=vt,c.push(gt.x,gt.y,gt.z),gt[v]=0,gt[_]=0,gt[S]=z>0?1:-1,h.push(gt.x,gt.y,gt.z),f.push(K/R),f.push(1-k/I),ut+=1}}for(let k=0;k<I;k++)for(let j=0;j<R;j++){const K=g+j+mt*k,Z=g+j+mt*(k+1),et=g+(j+1)+mt*(k+1),U=g+(j+1)+mt*k;l.push(K,Z,U),l.push(Z,et,U),W+=6}a.addGroup(p,W,L),p+=W,g+=ut}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Xa(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}}class TS extends en{constructor(){super(),this.isGroup=!0,this.type="Group"}}class rn{constructor(){this.type="Curve",this.arcLengthDivisions=200,this.needsUpdate=!1,this.cacheArcLengths=null}getPoint(){console.warn("THREE.Curve: .getPoint() not implemented.")}getPointAt(t,e){const r=this.getUtoTmapping(t);return this.getPoint(r,e)}getPoints(t=5){const e=[];for(let r=0;r<=t;r++)e.push(this.getPoint(r/t));return e}getSpacedPoints(t=5){const e=[];for(let r=0;r<=t;r++)e.push(this.getPointAt(r/t));return e}getLength(){const t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const e=[];let r,i=this.getPoint(0),s=0;e.push(0);for(let o=1;o<=t;o++)r=this.getPoint(o/t),s+=r.distanceTo(i),e.push(s),i=r;return this.cacheArcLengths=e,e}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(t,e=null){const r=this.getLengths();let i=0;const s=r.length;let o;e?o=e:o=t*r[s-1];let a=0,l=s-1,c;for(;a<=l;)if(i=Math.floor(a+(l-a)/2),c=r[i]-o,c<0)a=i+1;else if(c>0)l=i-1;else{l=i;break}if(i=l,r[i]===o)return i/(s-1);const h=r[i],g=r[i+1]-h,p=(o-h)/g;return(i+p)/(s-1)}getTangent(t,e){let i=t-1e-4,s=t+1e-4;i<0&&(i=0),s>1&&(s=1);const o=this.getPoint(i),a=this.getPoint(s),l=e||(o.isVector2?new yt:new D);return l.copy(a).sub(o).normalize(),l}getTangentAt(t,e){const r=this.getUtoTmapping(t);return this.getTangent(r,e)}computeFrenetFrames(t,e=!1){const r=new D,i=[],s=[],o=[],a=new D,l=new Re;for(let p=0;p<=t;p++){const m=p/t;i[p]=this.getTangentAt(m,new D)}s[0]=new D,o[0]=new D;let c=Number.MAX_VALUE;const h=Math.abs(i[0].x),f=Math.abs(i[0].y),g=Math.abs(i[0].z);h<=c&&(c=h,r.set(1,0,0)),f<=c&&(c=f,r.set(0,1,0)),g<=c&&r.set(0,0,1),a.crossVectors(i[0],r).normalize(),s[0].crossVectors(i[0],a),o[0].crossVectors(i[0],s[0]);for(let p=1;p<=t;p++){if(s[p]=s[p-1].clone(),o[p]=o[p-1].clone(),a.crossVectors(i[p-1],i[p]),a.length()>Number.EPSILON){a.normalize();const m=Math.acos(At(i[p-1].dot(i[p]),-1,1));s[p].applyMatrix4(l.makeRotationAxis(a,m))}o[p].crossVectors(i[p],s[p])}if(e===!0){let p=Math.acos(At(s[0].dot(s[t]),-1,1));p/=t,i[0].dot(a.crossVectors(s[0],s[t]))>0&&(p=-p);for(let m=1;m<=t;m++)s[m].applyMatrix4(l.makeRotationAxis(i[m],p*m)),o[m].crossVectors(i[m],s[m])}return{tangents:i,normals:s,binormals:o}}clone(){return new this.constructor().copy(this)}copy(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}toJSON(){const t={metadata:{version:4.7,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t}fromJSON(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}}class Dc extends rn{constructor(t=0,e=0,r=1,i=1,s=0,o=Math.PI*2,a=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=t,this.aY=e,this.xRadius=r,this.yRadius=i,this.aStartAngle=s,this.aEndAngle=o,this.aClockwise=a,this.aRotation=l}getPoint(t,e=new yt){const r=e,i=Math.PI*2;let s=this.aEndAngle-this.aStartAngle;const o=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=i;for(;s>i;)s-=i;s<Number.EPSILON&&(o?s=0:s=i),this.aClockwise===!0&&!o&&(s===i?s=-i:s=s-i);const a=this.aStartAngle+t*s;let l=this.aX+this.xRadius*Math.cos(a),c=this.aY+this.yRadius*Math.sin(a);if(this.aRotation!==0){const h=Math.cos(this.aRotation),f=Math.sin(this.aRotation),g=l-this.aX,p=c-this.aY;l=g*h-p*f+this.aX,c=g*f+p*h+this.aY}return r.set(l,c)}copy(t){return super.copy(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}toJSON(){const t=super.toJSON();return t.aX=this.aX,t.aY=this.aY,t.xRadius=this.xRadius,t.yRadius=this.yRadius,t.aStartAngle=this.aStartAngle,t.aEndAngle=this.aEndAngle,t.aClockwise=this.aClockwise,t.aRotation=this.aRotation,t}fromJSON(t){return super.fromJSON(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}}class CS extends Dc{constructor(t,e,r,i,s,o){super(t,e,r,r,i,s,o),this.isArcCurve=!0,this.type="ArcCurve"}}function Bc(){let n=0,t=0,e=0,r=0;function i(s,o,a,l){n=s,t=a,e=-3*s+3*o-2*a-l,r=2*s-2*o+a+l}return{initCatmullRom:function(s,o,a,l,c){i(o,a,c*(a-s),c*(l-o))},initNonuniformCatmullRom:function(s,o,a,l,c,h,f){let g=(o-s)/c-(a-s)/(c+h)+(a-o)/h,p=(a-o)/h-(l-o)/(h+f)+(l-a)/f;g*=h,p*=h,i(o,a,g,p)},calc:function(s){const o=s*s,a=o*s;return n+t*s+e*o+r*a}}}const Ja=new D,qc=new Bc,$c=new Bc,Hc=new Bc;class kS extends rn{constructor(t=[],e=!1,r="centripetal",i=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=t,this.closed=e,this.curveType=r,this.tension=i}getPoint(t,e=new D){const r=e,i=this.points,s=i.length,o=(s-(this.closed?0:1))*t;let a=Math.floor(o),l=o-a;this.closed?a+=a>0?0:(Math.floor(Math.abs(a)/s)+1)*s:l===0&&a===s-1&&(a=s-2,l=1);let c,h;this.closed||a>0?c=i[(a-1)%s]:(Ja.subVectors(i[0],i[1]).add(i[0]),c=Ja);const f=i[a%s],g=i[(a+1)%s];if(this.closed||a+2<s?h=i[(a+2)%s]:(Ja.subVectors(i[s-1],i[s-2]).add(i[s-1]),h=Ja),this.curveType==="centripetal"||this.curveType==="chordal"){const p=this.curveType==="chordal"?.5:.25;let m=Math.pow(c.distanceToSquared(f),p),v=Math.pow(f.distanceToSquared(g),p),_=Math.pow(g.distanceToSquared(h),p);v<1e-4&&(v=1),m<1e-4&&(m=v),_<1e-4&&(_=v),qc.initNonuniformCatmullRom(c.x,f.x,g.x,h.x,m,v,_),$c.initNonuniformCatmullRom(c.y,f.y,g.y,h.y,m,v,_),Hc.initNonuniformCatmullRom(c.z,f.z,g.z,h.z,m,v,_)}else this.curveType==="catmullrom"&&(qc.initCatmullRom(c.x,f.x,g.x,h.x,this.tension),$c.initCatmullRom(c.y,f.y,g.y,h.y,this.tension),Hc.initCatmullRom(c.z,f.z,g.z,h.z,this.tension));return r.set(qc.calc(l),$c.calc(l),Hc.calc(l)),r}copy(t){super.copy(t),this.points=[];for(let e=0,r=t.points.length;e<r;e++){const i=t.points[e];this.points.push(i.clone())}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}toJSON(){const t=super.toJSON();t.points=[];for(let e=0,r=this.points.length;e<r;e++){const i=this.points[e];t.points.push(i.toArray())}return t.closed=this.closed,t.curveType=this.curveType,t.tension=this.tension,t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,r=t.points.length;e<r;e++){const i=t.points[e];this.points.push(new D().fromArray(i))}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}}function Sm(n,t,e,r,i){const s=(r-t)*.5,o=(i-e)*.5,a=n*n,l=n*a;return(2*e-2*r+s+o)*l+(-3*e+3*r-2*s-o)*a+s*n+e}function IS(n,t){const e=1-n;return e*e*t}function PS(n,t){return 2*(1-n)*n*t}function RS(n,t){return n*n*t}function lo(n,t,e,r){return IS(n,t)+PS(n,e)+RS(n,r)}function LS(n,t){const e=1-n;return e*e*e*t}function NS(n,t){const e=1-n;return 3*e*e*n*t}function FS(n,t){return 3*(1-n)*n*n*t}function jS(n,t){return n*n*n*t}function co(n,t,e,r,i){return LS(n,t)+NS(n,e)+FS(n,r)+jS(n,i)}class Mm extends rn{constructor(t=new yt,e=new yt,r=new yt,i=new yt){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=t,this.v1=e,this.v2=r,this.v3=i}getPoint(t,e=new yt){const r=e,i=this.v0,s=this.v1,o=this.v2,a=this.v3;return r.set(co(t,i.x,s.x,o.x,a.x),co(t,i.y,s.y,o.y,a.y)),r}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}}class VS extends rn{constructor(t=new D,e=new D,r=new D,i=new D){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=t,this.v1=e,this.v2=r,this.v3=i}getPoint(t,e=new D){const r=e,i=this.v0,s=this.v1,o=this.v2,a=this.v3;return r.set(co(t,i.x,s.x,o.x,a.x),co(t,i.y,s.y,o.y,a.y),co(t,i.z,s.z,o.z,a.z)),r}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}}class Em extends rn{constructor(t=new yt,e=new yt){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=t,this.v2=e}getPoint(t,e=new yt){const r=e;return t===1?r.copy(this.v2):(r.copy(this.v2).sub(this.v1),r.multiplyScalar(t).add(this.v1)),r}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e=new yt){return e.subVectors(this.v2,this.v1).normalize()}getTangentAt(t,e){return this.getTangent(t,e)}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class DS extends rn{constructor(t=new D,e=new D){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=t,this.v2=e}getPoint(t,e=new D){const r=e;return t===1?r.copy(this.v2):(r.copy(this.v2).sub(this.v1),r.multiplyScalar(t).add(this.v1)),r}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e=new D){return e.subVectors(this.v2,this.v1).normalize()}getTangentAt(t,e){return this.getTangent(t,e)}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class Am extends rn{constructor(t=new yt,e=new yt,r=new yt){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=t,this.v1=e,this.v2=r}getPoint(t,e=new yt){const r=e,i=this.v0,s=this.v1,o=this.v2;return r.set(lo(t,i.x,s.x,o.x),lo(t,i.y,s.y,o.y)),r}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class BS extends rn{constructor(t=new D,e=new D,r=new D){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=t,this.v1=e,this.v2=r}getPoint(t,e=new D){const r=e,i=this.v0,s=this.v1,o=this.v2;return r.set(lo(t,i.x,s.x,o.x),lo(t,i.y,s.y,o.y),lo(t,i.z,s.z,o.z)),r}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class Om extends rn{constructor(t=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=t}getPoint(t,e=new yt){const r=e,i=this.points,s=(i.length-1)*t,o=Math.floor(s),a=s-o,l=i[o===0?o:o-1],c=i[o],h=i[o>i.length-2?i.length-1:o+1],f=i[o>i.length-3?i.length-1:o+2];return r.set(Sm(a,l.x,c.x,h.x,f.x),Sm(a,l.y,c.y,h.y,f.y)),r}copy(t){super.copy(t),this.points=[];for(let e=0,r=t.points.length;e<r;e++){const i=t.points[e];this.points.push(i.clone())}return this}toJSON(){const t=super.toJSON();t.points=[];for(let e=0,r=this.points.length;e<r;e++){const i=this.points[e];t.points.push(i.toArray())}return t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,r=t.points.length;e<r;e++){const i=t.points[e];this.points.push(new yt().fromArray(i))}return this}}var zm=Object.freeze({__proto__:null,ArcCurve:CS,CatmullRomCurve3:kS,CubicBezierCurve:Mm,CubicBezierCurve3:VS,EllipseCurve:Dc,LineCurve:Em,LineCurve3:DS,QuadraticBezierCurve:Am,QuadraticBezierCurve3:BS,SplineCurve:Om});class qS extends rn{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(t){this.curves.push(t)}closePath(){const t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1);if(!t.equals(e)){const r=t.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new zm[r](e,t))}return this}getPoint(t,e){const r=t*this.getLength(),i=this.getCurveLengths();let s=0;for(;s<i.length;){if(i[s]>=r){const o=i[s]-r,a=this.curves[s],l=a.getLength(),c=l===0?0:1-o/l;return a.getPointAt(c,e)}s++}return null}getLength(){const t=this.getCurveLengths();return t[t.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const t=[];let e=0;for(let r=0,i=this.curves.length;r<i;r++)e+=this.curves[r].getLength(),t.push(e);return this.cacheLengths=t,t}getSpacedPoints(t=40){const e=[];for(let r=0;r<=t;r++)e.push(this.getPoint(r/t));return this.autoClose&&e.push(e[0]),e}getPoints(t=12){const e=[];let r;for(let i=0,s=this.curves;i<s.length;i++){const o=s[i],a=o.isEllipseCurve?t*2:o.isLineCurve||o.isLineCurve3?1:o.isSplineCurve?t*o.points.length:t,l=o.getPoints(a);for(let c=0;c<l.length;c++){const h=l[c];r&&r.equals(h)||(e.push(h),r=h)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}copy(t){super.copy(t),this.curves=[];for(let e=0,r=t.curves.length;e<r;e++){const i=t.curves[e];this.curves.push(i.clone())}return this.autoClose=t.autoClose,this}toJSON(){const t=super.toJSON();t.autoClose=this.autoClose,t.curves=[];for(let e=0,r=this.curves.length;e<r;e++){const i=this.curves[e];t.curves.push(i.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.autoClose=t.autoClose,this.curves=[];for(let e=0,r=t.curves.length;e<r;e++){const i=t.curves[e];this.curves.push(new zm[i.type]().fromJSON(i))}return this}}class Tm extends qS{constructor(t){super(),this.type="Path",this.currentPoint=new yt,t&&this.setFromPoints(t)}setFromPoints(t){this.moveTo(t[0].x,t[0].y);for(let e=1,r=t.length;e<r;e++)this.lineTo(t[e].x,t[e].y);return this}moveTo(t,e){return this.currentPoint.set(t,e),this}lineTo(t,e){const r=new Em(this.currentPoint.clone(),new yt(t,e));return this.curves.push(r),this.currentPoint.set(t,e),this}quadraticCurveTo(t,e,r,i){const s=new Am(this.currentPoint.clone(),new yt(t,e),new yt(r,i));return this.curves.push(s),this.currentPoint.set(r,i),this}bezierCurveTo(t,e,r,i,s,o){const a=new Mm(this.currentPoint.clone(),new yt(t,e),new yt(r,i),new yt(s,o));return this.curves.push(a),this.currentPoint.set(s,o),this}splineThru(t){const e=[this.currentPoint.clone()].concat(t),r=new Om(e);return this.curves.push(r),this.currentPoint.copy(t[t.length-1]),this}arc(t,e,r,i,s,o){const a=this.currentPoint.x,l=this.currentPoint.y;return this.absarc(t+a,e+l,r,i,s,o),this}absarc(t,e,r,i,s,o){return this.absellipse(t,e,r,r,i,s,o),this}ellipse(t,e,r,i,s,o,a,l){const c=this.currentPoint.x,h=this.currentPoint.y;return this.absellipse(t+c,e+h,r,i,s,o,a,l),this}absellipse(t,e,r,i,s,o,a,l){const c=new Dc(t,e,r,i,s,o,a,l);if(this.curves.length>0){const f=c.getPoint(0);f.equals(this.currentPoint)||this.lineTo(f.x,f.y)}this.curves.push(c);const h=c.getPoint(1);return this.currentPoint.copy(h),this}copy(t){return super.copy(t),this.currentPoint.copy(t.currentPoint),this}toJSON(){const t=super.toJSON();return t.currentPoint=this.currentPoint.toArray(),t}fromJSON(t){return super.fromJSON(t),this.currentPoint.fromArray(t.currentPoint),this}}class Gc extends Tm{constructor(t){super(t),this.uuid=Gi(),this.type="Shape",this.holes=[]}getPointsHoles(t){const e=[];for(let r=0,i=this.holes.length;r<i;r++)e[r]=this.holes[r].getPoints(t);return e}extractPoints(t){return{shape:this.getPoints(t),holes:this.getPointsHoles(t)}}copy(t){super.copy(t),this.holes=[];for(let e=0,r=t.holes.length;e<r;e++){const i=t.holes[e];this.holes.push(i.clone())}return this}toJSON(){const t=super.toJSON();t.uuid=this.uuid,t.holes=[];for(let e=0,r=this.holes.length;e<r;e++){const i=this.holes[e];t.holes.push(i.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.uuid=t.uuid,this.holes=[];for(let e=0,r=t.holes.length;e<r;e++){const i=t.holes[e];this.holes.push(new Tm().fromJSON(i))}return this}}function $S(n,t,e=2){const r=t&&t.length,i=r?t[0]*e:n.length;let s=Cm(n,0,i,e,!0);const o=[];if(!s||s.next===s.prev)return o;let a,l,c;if(r&&(s=YS(n,t,s,e)),n.length>80*e){a=1/0,l=1/0;let h=-1/0,f=-1/0;for(let g=e;g<i;g+=e){const p=n[g],m=n[g+1];p<a&&(a=p),m<l&&(l=m),p>h&&(h=p),m>f&&(f=m)}c=Math.max(h-a,f-l),c=c!==0?32767/c:0}return ho(s,o,e,a,l,c,0),o}function Cm(n,t,e,r,i){let s;if(i===s2(n,t,e,r)>0)for(let o=t;o<e;o+=r)s=Rm(o/r|0,n[o],n[o+1],s);else for(let o=e-r;o>=t;o-=r)s=Rm(o/r|0,n[o],n[o+1],s);return s&&ls(s,s.next)&&(go(s),s=s.next),s}function li(n,t){if(!n)return n;t||(t=n);let e=n,r;do if(r=!1,!e.steiner&&(ls(e,e.next)||te(e.prev,e,e.next)===0)){if(go(e),e=t=e.prev,e===e.next)break;r=!0}else e=e.next;while(r||e!==t);return t}function ho(n,t,e,r,i,s,o){if(!n)return;!o&&s&&QS(n,r,i,s);let a=n;for(;n.prev!==n.next;){const l=n.prev,c=n.next;if(s?GS(n,r,i,s):HS(n)){t.push(l.i,n.i,c.i),go(n),n=c.next,a=c.next;continue}if(n=c,n===a){o?o===1?(n=WS(li(n),t),ho(n,t,e,r,i,s,2)):o===2&&US(n,t,e,r,i,s):ho(li(n),t,e,r,i,s,1);break}}}function HS(n){const t=n.prev,e=n,r=n.next;if(te(t,e,r)>=0)return!1;const i=t.x,s=e.x,o=r.x,a=t.y,l=e.y,c=r.y,h=Math.min(i,s,o),f=Math.min(a,l,c),g=Math.max(i,s,o),p=Math.max(a,l,c);let m=r.next;for(;m!==t;){if(m.x>=h&&m.x<=g&&m.y>=f&&m.y<=p&&fo(i,a,s,l,o,c,m.x,m.y)&&te(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function GS(n,t,e,r){const i=n.prev,s=n,o=n.next;if(te(i,s,o)>=0)return!1;const a=i.x,l=s.x,c=o.x,h=i.y,f=s.y,g=o.y,p=Math.min(a,l,c),m=Math.min(h,f,g),v=Math.max(a,l,c),_=Math.max(h,f,g),S=Wc(p,m,t,e,r),A=Wc(v,_,t,e,r);let C=n.prevZ,O=n.nextZ;for(;C&&C.z>=S&&O&&O.z<=A;){if(C.x>=p&&C.x<=v&&C.y>=m&&C.y<=_&&C!==i&&C!==o&&fo(a,h,l,f,c,g,C.x,C.y)&&te(C.prev,C,C.next)>=0||(C=C.prevZ,O.x>=p&&O.x<=v&&O.y>=m&&O.y<=_&&O!==i&&O!==o&&fo(a,h,l,f,c,g,O.x,O.y)&&te(O.prev,O,O.next)>=0))return!1;O=O.nextZ}for(;C&&C.z>=S;){if(C.x>=p&&C.x<=v&&C.y>=m&&C.y<=_&&C!==i&&C!==o&&fo(a,h,l,f,c,g,C.x,C.y)&&te(C.prev,C,C.next)>=0)return!1;C=C.prevZ}for(;O&&O.z<=A;){if(O.x>=p&&O.x<=v&&O.y>=m&&O.y<=_&&O!==i&&O!==o&&fo(a,h,l,f,c,g,O.x,O.y)&&te(O.prev,O,O.next)>=0)return!1;O=O.nextZ}return!0}function WS(n,t){let e=n;do{const r=e.prev,i=e.next.next;!ls(r,i)&&Im(r,e,e.next,i)&&po(r,i)&&po(i,r)&&(t.push(r.i,e.i,i.i),go(e),go(e.next),e=n=i),e=e.next}while(e!==n);return li(e)}function US(n,t,e,r,i,s){let o=n;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&r2(o,a)){let l=Pm(o,a);o=li(o,o.next),l=li(l,l.next),ho(o,t,e,r,i,s,0),ho(l,t,e,r,i,s,0);return}a=a.next}o=o.next}while(o!==n)}function YS(n,t,e,r){const i=[];for(let s=0,o=t.length;s<o;s++){const a=t[s]*r,l=s<o-1?t[s+1]*r:n.length,c=Cm(n,a,l,r,!1);c===c.next&&(c.steiner=!0),i.push(e2(c))}i.sort(XS);for(let s=0;s<i.length;s++)e=JS(i[s],e);return e}function XS(n,t){let e=n.x-t.x;if(e===0&&(e=n.y-t.y,e===0)){const r=(n.next.y-n.y)/(n.next.x-n.x),i=(t.next.y-t.y)/(t.next.x-t.x);e=r-i}return e}function JS(n,t){const e=ZS(n,t);if(!e)return t;const r=Pm(e,n);return li(r,r.next),li(e,e.next)}function ZS(n,t){let e=t;const r=n.x,i=n.y;let s=-1/0,o;if(ls(n,e))return e;do{if(ls(n,e.next))return e.next;if(i<=e.y&&i>=e.next.y&&e.next.y!==e.y){const f=e.x+(i-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(f<=r&&f>s&&(s=f,o=e.x<e.next.x?e:e.next,f===r))return o}e=e.next}while(e!==t);if(!o)return null;const a=o,l=o.x,c=o.y;let h=1/0;e=o;do{if(r>=e.x&&e.x>=l&&r!==e.x&&km(i<c?r:s,i,l,c,i<c?s:r,i,e.x,e.y)){const f=Math.abs(i-e.y)/(r-e.x);po(e,n)&&(f<h||f===h&&(e.x>o.x||e.x===o.x&&KS(o,e)))&&(o=e,h=f)}e=e.next}while(e!==a);return o}function KS(n,t){return te(n.prev,n,t.prev)<0&&te(t.next,n,n.next)<0}function QS(n,t,e,r){let i=n;do i.z===0&&(i.z=Wc(i.x,i.y,t,e,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==n);i.prevZ.nextZ=null,i.prevZ=null,t2(i)}function t2(n){let t,e=1;do{let r=n,i;n=null;let s=null;for(t=0;r;){t++;let o=r,a=0;for(let c=0;c<e&&(a++,o=o.nextZ,!!o);c++);let l=e;for(;a>0||l>0&&o;)a!==0&&(l===0||!o||r.z<=o.z)?(i=r,r=r.nextZ,a--):(i=o,o=o.nextZ,l--),s?s.nextZ=i:n=i,i.prevZ=s,s=i;r=o}s.nextZ=null,e*=2}while(t>1);return n}function Wc(n,t,e,r,i){return n=(n-e)*i|0,t=(t-r)*i|0,n=(n|n<<8)&16711935,n=(n|n<<4)&252645135,n=(n|n<<2)&858993459,n=(n|n<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,n|t<<1}function e2(n){let t=n,e=n;do(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==n);return e}function km(n,t,e,r,i,s,o,a){return(i-o)*(t-a)>=(n-o)*(s-a)&&(n-o)*(r-a)>=(e-o)*(t-a)&&(e-o)*(s-a)>=(i-o)*(r-a)}function fo(n,t,e,r,i,s,o,a){return!(n===o&&t===a)&&km(n,t,e,r,i,s,o,a)}function r2(n,t){return n.next.i!==t.i&&n.prev.i!==t.i&&!n2(n,t)&&(po(n,t)&&po(t,n)&&i2(n,t)&&(te(n.prev,n,t.prev)||te(n,t.prev,t))||ls(n,t)&&te(n.prev,n,n.next)>0&&te(t.prev,t,t.next)>0)}function te(n,t,e){return(t.y-n.y)*(e.x-t.x)-(t.x-n.x)*(e.y-t.y)}function ls(n,t){return n.x===t.x&&n.y===t.y}function Im(n,t,e,r){const i=Ka(te(n,t,e)),s=Ka(te(n,t,r)),o=Ka(te(e,r,n)),a=Ka(te(e,r,t));return!!(i!==s&&o!==a||i===0&&Za(n,e,t)||s===0&&Za(n,r,t)||o===0&&Za(e,n,r)||a===0&&Za(e,t,r))}function Za(n,t,e){return t.x<=Math.max(n.x,e.x)&&t.x>=Math.min(n.x,e.x)&&t.y<=Math.max(n.y,e.y)&&t.y>=Math.min(n.y,e.y)}function Ka(n){return n>0?1:n<0?-1:0}function n2(n,t){let e=n;do{if(e.i!==n.i&&e.next.i!==n.i&&e.i!==t.i&&e.next.i!==t.i&&Im(e,e.next,n,t))return!0;e=e.next}while(e!==n);return!1}function po(n,t){return te(n.prev,n,n.next)<0?te(n,t,n.next)>=0&&te(n,n.prev,t)>=0:te(n,t,n.prev)<0||te(n,n.next,t)<0}function i2(n,t){let e=n,r=!1;const i=(n.x+t.x)/2,s=(n.y+t.y)/2;do e.y>s!=e.next.y>s&&e.next.y!==e.y&&i<(e.next.x-e.x)*(s-e.y)/(e.next.y-e.y)+e.x&&(r=!r),e=e.next;while(e!==n);return r}function Pm(n,t){const e=Uc(n.i,n.x,n.y),r=Uc(t.i,t.x,t.y),i=n.next,s=t.prev;return n.next=t,t.prev=n,e.next=i,i.prev=e,r.next=e,e.prev=r,s.next=r,r.prev=s,r}function Rm(n,t,e,r){const i=Uc(n,t,e);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function go(n){n.next.prev=n.prev,n.prev.next=n.next,n.prevZ&&(n.prevZ.nextZ=n.nextZ),n.nextZ&&(n.nextZ.prevZ=n.prevZ)}function Uc(n,t,e){return{i:n,x:t,y:e,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function s2(n,t,e,r){let i=0;for(let s=t,o=e-r;s<e;s+=r)i+=(n[o]-n[s])*(n[s+1]+n[o+1]),o=s;return i}class o2{static triangulate(t,e,r=2){return $S(t,e,r)}}class mo{static area(t){const e=t.length;let r=0;for(let i=e-1,s=0;s<e;i=s++)r+=t[i].x*t[s].y-t[s].x*t[i].y;return r*.5}static isClockWise(t){return mo.area(t)<0}static triangulateShape(t,e){const r=[],i=[],s=[];Lm(t),Nm(r,t);let o=t.length;e.forEach(Lm);for(let l=0;l<e.length;l++)i.push(o),o+=e[l].length,Nm(r,e[l]);const a=o2.triangulate(r,i);for(let l=0;l<a.length;l+=3)s.push(a.slice(l,l+3));return s}}function Lm(n){const t=n.length;t>2&&n[t-1].equals(n[0])&&n.pop()}function Nm(n,t){for(let e=0;e<t.length;e++)n.push(t[e].x),n.push(t[e].y)}class Yc extends ai{constructor(t=new Gc([new yt(0,.5),new yt(-.5,-.5),new yt(.5,-.5)]),e=12){super(),this.type="ShapeGeometry",this.parameters={shapes:t,curveSegments:e};const r=[],i=[],s=[],o=[];let a=0,l=0;if(Array.isArray(t)===!1)c(t);else for(let h=0;h<t.length;h++)c(t[h]),this.addGroup(a,l,h),a+=l,l=0;this.setIndex(r),this.setAttribute("position",new wn(i,3)),this.setAttribute("normal",new wn(s,3)),this.setAttribute("uv",new wn(o,2));function c(h){const f=i.length/3,g=h.extractPoints(e);let p=g.shape;const m=g.holes;mo.isClockWise(p)===!1&&(p=p.reverse());for(let _=0,S=m.length;_<S;_++){const A=m[_];mo.isClockWise(A)===!0&&(m[_]=A.reverse())}const v=mo.triangulateShape(p,m);for(let _=0,S=m.length;_<S;_++){const A=m[_];p=p.concat(A)}for(let _=0,S=p.length;_<S;_++){const A=p[_];i.push(A.x,A.y,0),s.push(0,0,1),o.push(A.x,A.y)}for(let _=0,S=v.length;_<S;_++){const A=v[_],C=A[0]+f,O=A[1]+f,M=A[2]+f;r.push(C,O,M),l+=3}}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}toJSON(){const t=super.toJSON(),e=this.parameters.shapes;return a2(e,t)}static fromJSON(t,e){const r=[];for(let i=0,s=t.shapes.length;i<s;i++){const o=e[t.shapes[i]];r.push(o)}return new Yc(r,t.curveSegments)}}function a2(n,t){if(t.shapes=[],Array.isArray(n))for(let e=0,r=n.length;e<r;e++){const i=n[e];t.shapes.push(i.uuid)}else t.shapes.push(n.uuid);return t}class u2 extends xm{constructor(t){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new oi(16777215),this.specular=new oi(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new oi(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=oS,this.normalScale=new yt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ts,this.combine=Xg,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.specular.copy(t.specular),this.shininess=t.shininess,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}const Xc={enabled:!1,files:{},add:function(n,t){this.enabled!==!1&&(this.files[n]=t)},get:function(n){if(this.enabled!==!1)return this.files[n]},remove:function(n){delete this.files[n]},clear:function(){this.files={}}};class l2{constructor(t,e,r){const i=this;let s=!1,o=0,a=0,l;const c=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=r,this.abortController=new AbortController,this.itemStart=function(h){a++,s===!1&&i.onStart!==void 0&&i.onStart(h,o,a),s=!0},this.itemEnd=function(h){o++,i.onProgress!==void 0&&i.onProgress(h,o,a),o===a&&(s=!1,i.onLoad!==void 0&&i.onLoad())},this.itemError=function(h){i.onError!==void 0&&i.onError(h)},this.resolveURL=function(h){return l?l(h):h},this.setURLModifier=function(h){return l=h,this},this.addHandler=function(h,f){return c.push(h,f),this},this.removeHandler=function(h){const f=c.indexOf(h);return f!==-1&&c.splice(f,2),this},this.getHandler=function(h){for(let f=0,g=c.length;f<g;f+=2){const p=c[f],m=c[f+1];if(p.global&&(p.lastIndex=0),p.test(h))return m}return null},this.abort=function(){return this.abortController.abort(),this.abortController=new AbortController,this}}}const c2=new l2;class Jc{constructor(t){this.manager=t!==void 0?t:c2,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(t,e){const r=this;return new Promise(function(i,s){r.load(t,i,e,s)})}parse(){}setCrossOrigin(t){return this.crossOrigin=t,this}setWithCredentials(t){return this.withCredentials=t,this}setPath(t){return this.path=t,this}setResourcePath(t){return this.resourcePath=t,this}setRequestHeader(t){return this.requestHeader=t,this}abort(){return this}}Jc.DEFAULT_MATERIAL_NAME="__DEFAULT";const cs=new WeakMap;class h2 extends Jc{constructor(t){super(t)}load(t,e,r,i){this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);const s=this,o=Xc.get(`image:${t}`);if(o!==void 0){if(o.complete===!0)s.manager.itemStart(t),setTimeout(function(){e&&e(o),s.manager.itemEnd(t)},0);else{let f=cs.get(o);f===void 0&&(f=[],cs.set(o,f)),f.push({onLoad:e,onError:i})}return o}const a=bc("img");function l(){h(),e&&e(this);const f=cs.get(this)||[];for(let g=0;g<f.length;g++){const p=f[g];p.onLoad&&p.onLoad(this)}cs.delete(this),s.manager.itemEnd(t)}function c(f){h(),i&&i(f),Xc.remove(`image:${t}`);const g=cs.get(this)||[];for(let p=0;p<g.length;p++){const m=g[p];m.onError&&m.onError(f)}cs.delete(this),s.manager.itemError(t),s.manager.itemEnd(t)}function h(){a.removeEventListener("load",l,!1),a.removeEventListener("error",c,!1)}return a.addEventListener("load",l,!1),a.addEventListener("error",c,!1),t.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(a.crossOrigin=this.crossOrigin),Xc.add(`image:${t}`,a),s.manager.itemStart(t),a.src=t,a}}class Fm extends Jc{constructor(t){super(t)}load(t,e,r,i){const s=new Nn,o=new h2(this.manager);return o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(t,function(a){s.image=a,s.needsUpdate=!0,e!==void 0&&e(s)},r,i),s}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:$g}})),typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=$g);class f2{constructor(t=Wr){It(this,"elements");It(this,"categories");It(this,"propertyTypes");It(this,"unit");this.elements={},this.categories={root:{name:"root",label:"/",elements:[],categories:[]}},this.propertyTypes={},this.unit=t,this.registerMultiplePropertyType([["color",Rg,Rg],["enum",Lg,Lg],["string",Ng,Ng],["number",Fg,Fg],["length-measure",jg,jg],["toggle",Vg,Vg],["checkbox",Dg,Dg],["hidden",Bg,Bg],["read-only",qg,qg]])}getElement(t){if(this.hasElement(t))return this.elements[t];throw new Error(`Element ${t} does not exist in catalog`)}getCategory(t){if(this.hasCategory(t))return this.categories[t];throw new Error(`Category ${t} does not exist in catalog`)}getPropertyType(t){if(this.propertyTypes.hasOwnProperty(t))return this.propertyTypes[t];throw new Error(`Element ${t} does not exist in catalog`)}registerElement(t){t.properties=t.properties||{},this.validateElement(t)&&(this.elements[t.name]=t,this.categories.root.elements.push(this.elements[t.name]))}registerMultipleElements(t){t.forEach(e=>this.registerElement(e))}registerPropertyType(t,e,r){this.propertyTypes[t]={type:t,Viewer:e,Editor:r}}registerMultiplePropertyType(t){t.forEach(e=>this.registerPropertyType(...e))}validateElement(t){if(!t.hasOwnProperty("name"))throw new Error("Element not valid");let e=t.name;if(!t.hasOwnProperty("prototype"))throw new Error(`Element ${e} doesn't have prototype`);if(!t.hasOwnProperty("info"))throw new Error(`Element ${e} doesn't have info`);if(!t.info.hasOwnProperty("tag"))throw new Error(`Element ${e} doesn't have tag`);if(!t.info.hasOwnProperty("description"))throw new Error(`Element ${e} doesn't have description`);if(!t.info.hasOwnProperty("image"))throw new Error(`Element ${e} doesn't have image`);if(!t.hasOwnProperty("render2D"))throw new Error(`Element ${e} doesn't have render2D handler`);if(!t.hasOwnProperty("render3D"))throw new Error(`Element ${e} doesn't have render3D handler`);if(!t.hasOwnProperty("properties"))throw new Error(`Element ${e} doesn't have properties`);for(let r in t.properties){let i=t.properties[r];if(!i.hasOwnProperty("type"))throw new Error(`Element ${e}, Property ${r} doesn't have type`);if(!i.hasOwnProperty("defaultValue"))throw new Error(`Element ${e}, Property ${r} doesn't have defaultValue`)}return!0}hasElement(t){return this.elements.hasOwnProperty(t)}registerCategory(t,e,r){return this.validateCategory(t,e)?(this.categories[t]={name:t,label:e,categories:[],elements:[]},this.categories.root.categories.push(this.categories[t]),r&&r.length&&r.forEach(i=>this.addToCategory(t,i)),this.categories[t]):null}addToCategory(t,e){if(this.hasElement(e.name))this.categories[t].elements.push(e),this.categories.root.elements.splice(this.categories.root.elements.indexOf(e),1);else if(this.hasCategory(e.name))this.categories[t].categories.push(e),this.categories.root.categories.splice(this.categories.root.categories.indexOf(e),1);else throw new Error(`child ${e} is either category nor element`)}categoryHasElement(t,e){return this.hasCategory(t)&&this.categories[t].elements.some(r=>r.name===e)}validateCategory(t,e){if(!t)throw new Error("Category has undefined name");if(t==="")throw new Error("Category has empty name");if(this.hasCategory(t))throw new Error("Category has already been registered");return!0}hasCategory(t){return this.categories.hasOwnProperty(t)}}function d2(n){return se({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M10 18a7.952 7.952 0 0 0 4.897-1.688l4.396 4.396 1.414-1.414-4.396-4.396A7.952 7.952 0 0 0 18 10c0-4.411-3.589-8-8-8s-8 3.589-8 8 3.589 8 8 8zm0-14c3.309 0 6 2.691 6 6s-2.691 6-6 6-6-2.691-6-6 2.691-6 6-6z"},child:[]}]})(n)}const p2=({term:n="",placeholder:t="Search",noSpacing:e=!1,onClick:r=()=>!1,isStatic:i=!1,hasDropDown:s=!1,onSearch:o,className:a})=>{const[l,c]=N.useState("");return w.jsxs("div",{className:zr(`relative w-full ${e?"mt-1":"mt-2"}`,a),onClick:r??(()=>!1),children:[w.jsx("span",{className:`absolute left-0 top-2 text-[#637381] ${e?"":"ml-2"}`,style:{zIndex:2},children:w.jsx(d2,{size:18})}),i?w.jsx("div",{className:"w-full rounded border border-gray-300 bg-white px-3 py-1.5 text-xs font-normal cursor-pointer",style:{marginTop:3},children:n}):w.jsx("input",{className:"w-full rounded pl-[30px] focus:outline-none border border-gray-300 bg-white pr-3 py-1.5 text-sm text-gray-900",type:"text",placeholder:t,onChange:h=>{o(h.target.value,h),c(h.target.value)},value:l,onClick:r??(()=>!1)}),r!==null&&s&&w.jsx("span",{className:`absolute right-2 top-1/2 -translate-y-1/2 ${e?"":"ml-2"}`,style:{zIndex:1},children:w.jsx(k1,{className:"-mb-1"})})]})},jm=8,Vm=40,g2=n=>{const t=[{label:"All Categories",value:"all"}],e=n.map(r=>r.info.tag);for(const r of e){let i=t;for(let s=0;s<r.length;s++){const o=r[s];let a=i.find(l=>l.label===o);a||(a={label:o,value:o},s<r.length-1&&(a.options=[{label:"All Categories",value:"all"}]),i.push(a)),s<r.length-1&&a.options&&(i=a.options)}}return t},Dm=({options:n,selections:t,level:e,onChange:r})=>{var i,s;return w.jsxs(w.Fragment,{children:[w.jsx("select",{className:"w-full rounded capitalize cursor-pointer focus:outline-none border border-gray-300 bg-white pr-3 pl-1.5 py-1.5 text-sm text-gray-900",value:t[e]||"all",onChange:o=>r(e,o.target.value),children:n.map(o=>w.jsx("option",{className:"capitalize",value:o.value,children:o.label},o.value))}),t[e]&&t[e]!=="all"&&((i=n.find(o=>o.value===t[e]))==null?void 0:i.options)&&w.jsx(Dm,{options:((s=n.find(o=>o.value===t[e]))==null?void 0:s.options)||[],level:e+1,selections:t,onChange:r})]})},m2=({catalog:n,popupEvent:t,onClose:e})=>{const{selectToolDrawingLine:r,selectToolDrawingItem:i,selectToolDrawingHole:s,pushLastSelectedCatalogElementToHistory:o}=Jt(),[a,l]=N.useState([]),[c,h]=N.useState(["all"]),[f,g]=N.useState([]),[p,m]=N.useState(""),v=N.useRef(null),_=N.useRef(null);N.useEffect(()=>{if(t){const M=n.getCategory(t.page).elements.filter(I=>I.info.visibility?I.info.visibility.catalog:!0);v.current=t.page,g(M);const{x:z,y:R}=t.rect;_.current={top:R+jm,left:z+Vm},t.page==="objects"&&l(g2(M))}},[t]);const S=()=>{e()},A=O=>{S(),setTimeout(()=>{switch(O.prototype){case"lines":r(O.name);break;case"items":i(O.name);break;case"holes":s(O.name);break}o(O)},0)},C=(O,M)=>{const z=[...c.slice(0,O),M];h(z)};return w.jsxs(w.Fragment,{children:[t&&w.jsx("div",{className:"fixed inset-0 bg-black/30 z-10",onClick:S}),w.jsxs("div",{style:t&&t.rect?{top:t.rect.y+jm,left:t.rect.x+Vm}:_.current?_.current:{},className:zr("fixed select-none z-10 shadow-md !gap-0 rounded-lg pt-5 fp_side-bar !min-h-[250px] !max-h-[510px] transition-all duration-200 ease-out transform",t?"opacity-100 scale-100":"opacity-0 scale-95 pointer-events-none"),children:[w.jsxs("header",{className:"px-[18px] sticky top-0 left-0 gap-3 flex flex-col",children:[w.jsx("div",{className:"flex items-center gap-1",children:w.jsx("span",{className:zr("flex flex-col gap-0.5"),children:w.jsx("span",{className:"fp-sidebar-label capitalize",children:(t==null?void 0:t.page)??v.current})})}),w.jsxs("div",{className:zr("fp-highlight"),children:[w.jsx(Dm,{options:a,level:0,selections:c,onChange:C}),w.jsx(p2,{className:"mt-0",placeholder:"Search",onSearch:(O,M)=>{M.preventDefault(),M.stopPropagation(),m(O)}})]})]}),f.filter(O=>O.info.title.toLowerCase().includes(p.toLowerCase())&&c.every(M=>M==="all"||O.info.tag.includes(M))).length>0?w.jsx("div",{className:"grid grid-cols-2 gap-x-4 gap-y-6 pb-5 overflow-auto w-full pt-[18px] px-4",onWheel:O=>O.stopPropagation(),children:f.filter(O=>O.info.title.toLowerCase().includes(p.toLowerCase())&&c.every(M=>M==="all"||O.info.tag.includes(M))).map(O=>w.jsxs("div",{className:"w-full space-y-1.5",children:[w.jsx("div",{className:"fp-aspect-ratio-container",children:w.jsx("div",{className:"fp-aspect-ratio-content",onMouseDown:()=>A(O),children:w.jsx("img",{draggable:!1,className:"fp-item-image",alt:O.info.title,src:O.info.image})})}),w.jsx("p",{className:"text-xs font-semibold capitalize",children:O.info.description})]},O.name.replace(/\s+/g,"_")))}):w.jsx("div",{className:"min-h-28 w-full flex items-center justify-center",children:w.jsx("p",{className:"text-sm font-medium text-gray-400 text-center",children:"No records found"})})]})]})};function y2(n){return se({attr:{viewBox:"0 0 576 512"},child:[{tag:"path",attr:{d:"M320 32c0-9.9-4.5-19.2-12.3-25.2S289.8-1.4 280.2 1l-179.9 45C79 51.3 64 70.5 64 92.5L64 448l-32 0c-17.7 0-32 14.3-32 32s14.3 32 32 32l64 0 192 0 32 0 0-32 0-448zM256 256c0 17.7-10.7 32-24 32s-24-14.3-24-32s10.7-32 24-32s24 14.3 24 32zm96-128l96 0 0 352c0 17.7 14.3 32 32 32l64 0c17.7 0 32-14.3 32-32s-14.3-32-32-32l-32 0 0-320c0-35.3-28.7-64-64-64l-96 0 0 64z"},child:[]}]})(n)}function v2(n){return se({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M112 73c-13.75 0-24.214 4.87-33.047 13.271-8.832 8.402-15.755 20.6-20.414 34.575-5.887 17.661-7.953 38.064-6.887 56.111a57.246 57.246 0 0 1 2.461-.187c8.38-.405 16.317 1.094 23.494 4.234 14.355 6.28 25.436 18.27 34.057 32.28 15.104 24.543 23.187 55.746 24.96 80.585 114.097-14.223 124.655-14.223 238.753 0 1.772-24.84 9.855-56.042 24.959-80.586 8.62-14.009 19.702-25.999 34.057-32.28 7.875-3.444 16.67-4.898 25.955-4.046 1.066-18.047-1-38.45-6.887-56.111-4.659-13.976-11.582-26.173-20.414-34.575C424.214 77.87 413.75 73 400 73zM56.969 194.502c-.686-.008-1.38.006-2.082.04-5.621.284-11.8 1.978-18.862 5.509-23.413 11.707-26.349 65.687 14.82 79.41l4.505 1.502L86.79 391h338.42l31.44-110.037 4.504-1.502c41.17-13.723 38.234-67.703 14.82-79.41-14.121-7.061-24.722-6.775-34.367-2.555-9.645 4.22-18.564 13.23-25.943 25.22C400.906 246.7 393 282 393 304v10.195l-10.117-1.265c-128-16-125.766-16-253.766 0L119 314.195V304c0-22-7.906-57.3-22.664-81.283-7.38-11.991-16.298-21.001-25.943-25.22-4.22-1.847-8.624-2.94-13.424-2.995zM83.727 409l-23.272 23.271c11.994 3.239 33.75 3.763 42.545-1.666 3.272-4.695 6.903-14.536 10.438-21.605zm314.836 0c1.494 6.017 6.952 19.12 10.437 21.605 13.2 5.463 29.904 5.774 42.545 1.666L428.273 409z"},child:[]}]})(n)}function x2({catalog:n}){const{planner:t,selectTool3DView:e,setMode:r,selectTool3DFirstPerson:i,selectToolDrawingLine:s}=Jt(),{mode:o,alterate:a}=t,[l,c]=N.useState(null);return w.jsxs(w.Fragment,{children:[w.jsxs("aside",{className:"floor_planner-toolbar max-h-full max-w-[50px] p-2.5 space-y-4 bg-[#2b2b2b]",children:[w.jsx(gn,{active:[xr,We].includes(o),tooltip:"Draw wall",onClick:()=>s("wall"),children:w.jsx(Xw,{})}),w.jsx(gn,{active:!!([Ue].includes(o)&&l&&l.page==="windows"),tooltip:"Place windows",onClick:h=>{c({rect:h.currentTarget.getBoundingClientRect(),page:"windows"})},children:w.jsx(Y1,{size:26})}),w.jsx(gn,{active:!!([Ue].includes(o)&&l&&l.page==="doors"),tooltip:"Place doors",onClick:h=>{c({rect:h.currentTarget.getBoundingClientRect(),page:"doors"})},children:w.jsx(y2,{size:26})}),w.jsx(gn,{active:!!([ur].includes(o)&&l&&l.page==="objects"),tooltip:"Place objects",onClick:h=>{c({rect:h.currentTarget.getBoundingClientRect(),page:"objects"})},children:w.jsx(v2,{size:26})}),w.jsx(Yw,{mode:o})]}),w.jsx(m2,{catalog:n,popupEvent:l,onClose:()=>c(null)})]})}const yo=window.hasOwnProperty("localStorage")?window.localStorage:!1,_2=500;let Zc=null;function b2(n,t){return(e,r,i)=>{let s;if(t=t||_2,!!n&&yo){if(r){e.setPlan(r);const o=r.floors[0].floorDesign;s=JSON.parse(o)}else if(yo.getItem(n)!==null){const o=yo.getItem(n);s=JSON.parse(o)}s&&e.loadProject(s),Jt.subscribe(o=>{Zc&&clearTimeout(Zc),Zc=setTimeout(()=>{const a=yo.getItem(n),l=JSON.stringify(o.planner.scene.toJS());if(a!==l&&(yo.setItem(n,l),o.plan))try{const c=o.plan.floors[o.activeFloor];i&&i({floor:{floorID:c.floorID,title:c.floorTitle,description:c.floorDescription,design:l}})}catch{}},t)})}}}function w2(){return n=>{window.addEventListener("keydown",t=>{const e=n.planner,r=e.get("mode");switch(t.keyCode){case lr.BACKSPACE:case lr.DELETE:{[re,ki,Qn].includes(r)&&n.remove();break}case lr.ESC:{n.rollback();break}case lr.Z:{(t.getModifierState("Control")||t.getModifierState("Meta"))&&(t.getModifierState("Shift")?n.redo():n.undo());break}case lr.ALT:{hl.includes(r)&&n.toggleSnap(e.snapMask.merge({SNAP_POINT:!1,SNAP_LINE:!1,SNAP_SEGMENT:!1,SNAP_GRID:!1,SNAP_GUIDE:!1,tempSnapConfiguartion:e.snapMask.toJS()}));break}case lr.C:{let i=e.getIn(["scene","selectedLayer"]),s=e.getIn(["scene","layers",i,"selected"]);if((r===re||r===Qn)&&(s.holes.size||s.areas.size||s.items.size||s.lines.size)){if(s.holes.size){let o=e.getIn(["scene","layers",i,"holes",s.holes.get(0)]);n.copyProperties(o.get("properties"))}else if(s.areas.size){const o=e.getIn(["scene","layers",i,"areas",s.areas.get(0)]);n.copyProperties(o.properties)}else if(s.items.size){const o=e.getIn(["scene","layers",i,"items",s.items.get(0)]);n.copyProperties(o.properties)}else if(s.lines.size){const o=e.getIn(["scene","layers",i,"lines",s.lines.get(0)]);n.copyProperties(o.properties)}}break}case lr.V:{n.pasteProperties();break}case lr.CTRL:{n.setAlterateState();break}}}),window.addEventListener("keyup",t=>{const e=n.planner,r=e.get("mode");switch(t.keyCode){case lr.ALT:{hl.includes(r)&&n.toggleSnap(e.snapMask.merge(e.snapMask.get("tempSnapConfiguartion")));break}case lr.CTRL:{n.setAlterateState();break}}})}}const S2=({onBack:n,onSave:t})=>{const{undo:e,redo:r,plan:i,setPlan:s}=Jt(),[o,a]=N.useState(!1),l=()=>{a(!0)},c=h=>{if(!i)return;a(!1);const f=h.target.value.trim();if(f&&f!==(i==null?void 0:i.planTitle)){s({...i,planTitle:f});try{t&&t({title:f,description:""})}catch{}}};return w.jsxs("div",{className:"floor_planner-headerbar border-b border-b-[#5e5e5e] absolute flex items-center justify-between z-[9001] py-[3px] px-[1em] text-xs bg-[#2b2b2b] w-full select-none cursor-default top-0 leading-[14px] text-white m-0",children:[w.jsx(gn,{className:"border border-white rounded -ml-1",active:!1,tooltip:"Go Back",onClick:()=>{n&&n()},children:w.jsx(og,{})}),w.jsx("div",{className:"flex flex-col items-center justify-center",children:o?w.jsx("input",{autoFocus:!0,type:"text",defaultValue:i==null?void 0:i.planTitle,onBlur:c,onKeyDown:h=>{(h.key==="Enter"||h.key==="Escape")&&c(h)},className:"bg-transparent border-b border-gray-400 outline-none text-lg text-center"}):w.jsx("span",{onDoubleClick:l,className:"projectName__fp text-lg",title:(i==null?void 0:i.planTitle)??"Example House",children:(i==null?void 0:i.planTitle)??"Example House"})}),w.jsxs("div",{className:"flex items-center gap-2 relative right-40",children:[w.jsx(gn,{active:!1,tooltip:"Undo (CTRL-Z)",onClick:e,children:w.jsx(W1,{})}),w.jsx(gn,{active:!1,tooltip:"Redo (CTRL-SHIFT-Z)",onClick:r,children:w.jsx(G1,{})})]})]})};var Kc={exports:{}},Bm;function qm(){if(Bm)return Kc.exports;Bm=1;var n=Kc.exports={};return n.forEach=function(t,e){for(var r=0;r<t.length;r++){var i=e(t[r]);if(i)return i}},Kc.exports}var Qc,$m;function M2(){return $m||($m=1,Qc=function(n){var t=n.stateHandler.getState;function e(o){var a=t(o);return a&&!!a.isDetectable}function r(o){t(o).isDetectable=!0}function i(o){return!!t(o).busy}function s(o,a){t(o).busy=!!a}return{isDetectable:e,markAsDetectable:r,isBusy:i,markBusy:s}}),Qc}var th,Hm;function E2(){return Hm||(Hm=1,th=function(n){var t={};function e(o){var a=n.get(o);return a===void 0?[]:t[a]||[]}function r(o,a){var l=n.get(o);t[l]||(t[l]=[]),t[l].push(a)}function i(o,a){for(var l=e(o),c=0,h=l.length;c<h;++c)if(l[c]===a){l.splice(c,1);break}}function s(o){var a=e(o);a&&(a.length=0)}return{get:e,add:r,removeListener:i,removeAllListeners:s}}),th}var eh,Gm;function A2(){return Gm||(Gm=1,eh=function(){var n=1;function t(){return n++}return{generate:t}}),eh}var rh,Wm;function O2(){return Wm||(Wm=1,rh=function(n){var t=n.idGenerator,e=n.stateHandler.getState;function r(s){var o=e(s);return o&&o.id!==void 0?o.id:null}function i(s){var o=e(s);if(!o)throw new Error("setId required the element to have a resize detection state.");var a=t.generate();return o.id=a,a}return{get:r,set:i}}),rh}var nh,Um;function z2(){return Um||(Um=1,nh=function(n){function t(){}var e={log:t,warn:t,error:t};if(!n&&window.console){var r=function(i,s){i[s]=function(){var a=console[s];if(a.apply)a.apply(console,arguments);else for(var l=0;l<arguments.length;l++)a(arguments[l])}};r(e,"log"),r(e,"warn"),r(e,"error")}return e}),nh}var ih={exports:{}},Ym;function Xm(){if(Ym)return ih.exports;Ym=1;var n=ih.exports={};return n.isIE=function(t){function e(){var i=navigator.userAgent.toLowerCase();return i.indexOf("msie")!==-1||i.indexOf("trident")!==-1||i.indexOf(" edge/")!==-1}if(!e())return!1;if(!t)return!0;var r=(function(){var i,s=3,o=document.createElement("div"),a=o.getElementsByTagName("i");do o.innerHTML="<!--[if gt IE "+ ++s+"]><i></i><![endif]-->";while(a[0]);return s>4?s:i})();return t===r},n.isLegacyOpera=function(){return!!window.opera},ih.exports}var sh={exports:{}},Jm;function T2(){if(Jm)return sh.exports;Jm=1;var n=sh.exports={};n.getOption=t;function t(e,r,i){var s=e[r];return s==null&&i!==void 0?i:s}return sh.exports}var oh,Zm;function C2(){if(Zm)return oh;Zm=1;var n=T2();oh=function(r){r=r||{};var i=r.reporter,s=n.getOption(r,"async",!0),o=n.getOption(r,"auto",!0);o&&!s&&(i&&i.warn("Invalid options combination. auto=true and async=false is invalid. Setting async=true."),s=!0);var a=t(),l,c=!1;function h(_,S){!c&&o&&s&&a.size()===0&&p(),a.add(_,S)}function f(){for(c=!0;a.size();){var _=a;a=t(),_.process()}c=!1}function g(_){c||(_===void 0&&(_=s),l&&(m(l),l=null),_?p():f())}function p(){l=v(f)}function m(_){var S=clearTimeout;return S(_)}function v(_){var S=function(A){return setTimeout(A,0)};return S(_)}return{add:h,force:g}};function t(){var e={},r=0,i=0,s=0;function o(c,h){h||(h=c,c=0),c>i?i=c:c<s&&(s=c),e[c]||(e[c]=[]),e[c].push(h),r++}function a(){for(var c=s;c<=i;c++)for(var h=e[c],f=0;f<h.length;f++){var g=h[f];g()}}function l(){return r}return{add:o,process:a,size:l}}return oh}var ah,Km;function k2(){if(Km)return ah;Km=1;var n="_erd";function t(i){return i[n]={},e(i)}function e(i){return i[n]}function r(i){delete i[n]}return ah={initState:t,getState:e,cleanState:r},ah}var uh,Qm;function I2(){if(Qm)return uh;Qm=1;var n=Xm();return uh=function(t){t=t||{};var e=t.reporter,r=t.batchProcessor,i=t.stateHandler.getState;if(!e)throw new Error("Missing required dependency: reporter.");function s(h,f){function g(){f(h)}if(n.isIE(8))i(h).object={proxy:g},h.attachEvent("onresize",g);else{var p=l(h);if(!p)throw new Error("Element is not detectable by this strategy.");p.contentDocument.defaultView.addEventListener("resize",g)}}function o(h){var f=t.important?" !important; ":"; ";return(h.join(f)+f).trim()}function a(h,f,g){g||(g=f,f=h,h=null),h=h||{},h.debug;function p(m,v){var _=o(["display: block","position: absolute","top: 0","left: 0","width: 100%","height: 100%","border: none","padding: 0","margin: 0","opacity: 0","z-index: -1000","pointer-events: none"]),S=!1,A=window.getComputedStyle(m),C=m.offsetWidth,O=m.offsetHeight;i(m).startSize={width:C,height:O};function M(){function z(){if(A.position==="static"){m.style.setProperty("position","relative",h.important?"important":"");var L=function(Y,X,it,rt){function vt(dt){return dt.replace(/[^-\d\.]/g,"")}var mt=it[rt];mt!=="auto"&&vt(mt)!=="0"&&(Y.warn("An element that is positioned static has style."+rt+"="+mt+" which is ignored due to the static positioning. The element will need to be positioned relative, so the style."+rt+" will be set to 0. Element: ",X),X.style.setProperty(rt,"0",h.important?"important":""))};L(e,m,A,"top"),L(e,m,A,"right"),L(e,m,A,"bottom"),L(e,m,A,"left")}}function R(){S||z();function L(X,it){if(!X.contentDocument){var rt=i(X);rt.checkForObjectDocumentTimeoutId&&window.clearTimeout(rt.checkForObjectDocumentTimeoutId),rt.checkForObjectDocumentTimeoutId=setTimeout(function(){rt.checkForObjectDocumentTimeoutId=0,L(X,it)},100);return}it(X.contentDocument)}var Y=this;L(Y,function(it){v(m)})}A.position!==""&&(z(),S=!0);var I=document.createElement("object");I.style.cssText=_,I.tabIndex=-1,I.type="text/html",I.setAttribute("aria-hidden","true"),I.onload=R,n.isIE()||(I.data="about:blank"),i(m)&&(m.appendChild(I),i(m).object=I,n.isIE()&&(I.data="about:blank"))}r?r.add(M):M()}n.isIE(8)?g(f):p(f,g)}function l(h){return i(h).object}function c(h){if(i(h)){var f=l(h);f&&(n.isIE(8)?h.detachEvent("onresize",f.proxy):h.removeChild(f),i(h).checkForObjectDocumentTimeoutId&&window.clearTimeout(i(h).checkForObjectDocumentTimeoutId),delete i(h).object)}}return{makeDetectable:a,addListener:s,uninstall:c}},uh}var lh,ty;function P2(){if(ty)return lh;ty=1;var n=qm().forEach;return lh=function(t){t=t||{};var e=t.reporter,r=t.batchProcessor,i=t.stateHandler.getState;t.stateHandler.hasState;var s=t.idHandler;if(!r)throw new Error("Missing required dependency: batchProcessor");if(!e)throw new Error("Missing required dependency: reporter.");var o=f(),a="erd_scroll_detection_scrollbar_style",l="erd_scroll_detection_container";function c(M){g(M,a,l)}c(window.document);function h(M){var z=t.important?" !important; ":"; ";return(M.join(z)+z).trim()}function f(){var M=500,z=500,R=document.createElement("div");R.style.cssText=h(["position: absolute","width: "+M*2+"px","height: "+z*2+"px","visibility: hidden","margin: 0","padding: 0"]);var I=document.createElement("div");I.style.cssText=h(["position: absolute","width: "+M+"px","height: "+z+"px","overflow: scroll","visibility: none","top: "+-M*3+"px","left: "+-z*3+"px","visibility: hidden","margin: 0","padding: 0"]),I.appendChild(R),document.body.insertBefore(I,document.body.firstChild);var L=M-I.clientWidth,Y=z-I.clientHeight;return document.body.removeChild(I),{width:L,height:Y}}function g(M,z,R){function I(it,rt){rt=rt||function(mt){M.head.appendChild(mt)};var vt=M.createElement("style");return vt.innerHTML=it,vt.id=z,rt(vt),vt}if(!M.getElementById(z)){var L=R+"_animation",Y=R+"_animation_active",X=`/* Created by the element-resize-detector library. */
|
|
75
|
+
`;X+="."+R+" > div::-webkit-scrollbar { "+h(["display: none"])+` }
|
|
84
76
|
|
|
85
|
-
`,
|
|
86
|
-
`,
|
|
87
|
-
`,J+="@keyframes "+L+" { 0% { opacity: 1; } 50% { opacity: 0; } 100% { opacity: 1; } }",k(J)}}function p(E){E.className+=" "+l+"_animation_active"}function m(E,z,R){if(E.addEventListener)E.addEventListener(z,R);else if(E.attachEvent)E.attachEvent("on"+z,R);else return e.error("[scroll] Don't know how to add event listeners.")}function v(E,z,R){if(E.removeEventListener)E.removeEventListener(z,R);else if(E.detachEvent)E.detachEvent("on"+z,R);else return e.error("[scroll] Don't know how to remove event listeners.")}function _(E){return i(E).container.childNodes[0].childNodes[0].childNodes[0]}function S(E){return i(E).container.childNodes[0].childNodes[0].childNodes[1]}function M(E,z){var R=i(E).listeners;if(!R.push)throw new Error("Cannot add listener to an element that is not detectable.");i(E).listeners.push(z)}function C(E,z,R){R||(R=z,z=E,E=null),E=E||{};function k(){if(E.debug){var B=Array.prototype.slice.call(arguments);if(B.unshift(s.get(z),"Scroll: "),e.log.apply)e.log.apply(null,B);else for(var pt=0;pt<B.length;pt++)e.log(B[pt])}}function L(B){function pt(H){var Ot=H.getRootNode&&H.getRootNode().contains(H);return H===H.ownerDocument.body||H.ownerDocument.body.contains(H)||Ot}return!pt(B)||window.getComputedStyle(B)===null}function X(B){var pt=i(B).container.childNodes[0],H=window.getComputedStyle(pt);return!H.width||H.width.indexOf("px")===-1}function J(){var B=window.getComputedStyle(z),pt={};return pt.position=B.position,pt.width=z.offsetWidth,pt.height=z.offsetHeight,pt.top=B.top,pt.right=B.right,pt.bottom=B.bottom,pt.left=B.left,pt.widthCSS=B.width,pt.heightCSS=B.height,pt}function at(){var B=J();i(z).startSize={width:B.width,height:B.height},k("Element start size",i(z).startSize)}function tt(){i(z).listeners=[]}function bt(){if(k("storeStyle invoked."),!i(z)){k("Aborting because element has been uninstalled");return}var B=J();i(z).style=B}function xt(B,pt,H){i(B).lastWidth=pt,i(B).lastHeight=H}function yt(B){return _(B).childNodes[0]}function ht(){return 2*o.width+1}function Y(){return 2*o.height+1}function St(B){return B+10+ht()}function j(B){return B+10+Y()}function W(B){return B*2+ht()}function ft(B){return B*2+Y()}function et(B,pt,H){var Ot=_(B),Bt=S(B),kt=St(pt),Ct=j(H),Gt=W(pt),gt=ft(H);Ot.scrollLeft=kt,Ot.scrollTop=Ct,Bt.scrollLeft=Gt,Bt.scrollTop=gt}function rt(){var B=i(z).container;if(!B){B=document.createElement("div"),B.className=l,B.style.cssText=h(["visibility: hidden","display: inline","width: 0px","height: 0px","z-index: -1","overflow: hidden","margin: 0","padding: 0"]),i(z).container=B,p(B),z.appendChild(B);var pt=function(){i(z).onRendered&&i(z).onRendered()};m(B,"animationstart",pt),i(z).onAnimationStart=pt}return B}function Z(){function B(){var se=i(z).style;if(se.position==="static"){z.style.setProperty("position","relative",E.important?"important":"");var Ye=function(Cr,dr,ki,qn){function oe(we){return we.replace(/[^-\d\.]/g,"")}var $n=ki[qn];$n!=="auto"&&oe($n)!=="0"&&(Cr.warn("An element that is positioned static has style."+qn+"="+$n+" which is ignored due to the static positioning. The element will need to be positioned relative, so the style."+qn+" will be set to 0. Element: ",dr),dr.style[qn]=0)};Ye(e,z,se,"top"),Ye(e,z,se,"right"),Ye(e,z,se,"bottom"),Ye(e,z,se,"left")}}function pt(se,Ye,Cr,dr){return se=se?se+"px":"0",Ye=Ye?Ye+"px":"0",Cr=Cr?Cr+"px":"0",dr=dr?dr+"px":"0",["left: "+se,"top: "+Ye,"right: "+dr,"bottom: "+Cr]}if(k("Injecting elements"),!i(z)){k("Aborting because element has been uninstalled");return}B();var H=i(z).container;H||(H=rt());var Ot=o.width,Bt=o.height,kt=h(["position: absolute","flex: none","overflow: hidden","z-index: -1","visibility: hidden","width: 100%","height: 100%","left: 0px","top: 0px"]),Ct=h(["position: absolute","flex: none","overflow: hidden","z-index: -1","visibility: hidden"].concat(pt(-(1+Ot),-(1+Bt),-Bt,-Ot))),Gt=h(["position: absolute","flex: none","overflow: scroll","z-index: -1","visibility: hidden","width: 100%","height: 100%"]),gt=h(["position: absolute","flex: none","overflow: scroll","z-index: -1","visibility: hidden","width: 100%","height: 100%"]),_t=h(["position: absolute","left: 0","top: 0"]),Dt=h(["position: absolute","width: 200%","height: 200%"]),zt=document.createElement("div"),Le=document.createElement("div"),tn=document.createElement("div"),Dn=document.createElement("div"),_n=document.createElement("div"),Bn=document.createElement("div");zt.dir="ltr",zt.style.cssText=kt,zt.className=l,Le.className=l,Le.style.cssText=Ct,tn.style.cssText=Gt,Dn.style.cssText=_t,_n.style.cssText=gt,Bn.style.cssText=Dt,tn.appendChild(Dn),_n.appendChild(Bn),Le.appendChild(tn),Le.appendChild(_n),zt.appendChild(Le),H.appendChild(zt);function Ci(){var se=i(z);se&&se.onExpand?se.onExpand():k("Aborting expand scroll handler: element has been uninstalled")}function Ii(){var se=i(z);se&&se.onShrink?se.onShrink():k("Aborting shrink scroll handler: element has been uninstalled")}m(tn,"scroll",Ci),m(_n,"scroll",Ii),i(z).onExpandScroll=Ci,i(z).onShrinkScroll=Ii}function Q(){function B(Gt,gt,_t){var Dt=yt(Gt),zt=St(gt),Le=j(_t);Dt.style.setProperty("width",zt+"px",E.important?"important":""),Dt.style.setProperty("height",Le+"px",E.important?"important":"")}function pt(Gt){var gt=z.offsetWidth,_t=z.offsetHeight,Dt=gt!==i(z).lastWidth||_t!==i(z).lastHeight;k("Storing current size",gt,_t),xt(z,gt,_t),r.add(0,function(){if(Dt){if(!i(z)){k("Aborting because element has been uninstalled");return}if(!H()){k("Aborting because element container has not been initialized");return}if(E.debug){var Le=z.offsetWidth,tn=z.offsetHeight;(Le!==gt||tn!==_t)&&e.warn(s.get(z),"Scroll: Size changed before updating detector elements.")}B(z,gt,_t)}}),r.add(1,function(){if(!i(z)){k("Aborting because element has been uninstalled");return}if(!H()){k("Aborting because element container has not been initialized");return}et(z,gt,_t)}),Dt&&Gt&&r.add(2,function(){if(!i(z)){k("Aborting because element has been uninstalled");return}if(!H()){k("Aborting because element container has not been initialized");return}Gt()})}function H(){return!!i(z).container}function Ot(){function Gt(){return i(z).lastNotifiedWidth===void 0}k("notifyListenersIfNeeded invoked");var gt=i(z);if(Gt()&>.lastWidth===gt.startSize.width&>.lastHeight===gt.startSize.height)return k("Not notifying: Size is the same as the start size, and there has been no notification yet.");if(gt.lastWidth===gt.lastNotifiedWidth&>.lastHeight===gt.lastNotifiedHeight)return k("Not notifying: Size already notified");k("Current size not notified, notifying..."),gt.lastNotifiedWidth=gt.lastWidth,gt.lastNotifiedHeight=gt.lastHeight,n(i(z).listeners,function(_t){_t(z)})}function Bt(){if(k("startanimation triggered."),X(z)){k("Ignoring since element is still unrendered...");return}k("Element rendered.");var Gt=_(z),gt=S(z);(Gt.scrollLeft===0||Gt.scrollTop===0||gt.scrollLeft===0||gt.scrollTop===0)&&(k("Scrollbars out of sync. Updating detector elements..."),pt(Ot))}function kt(){if(k("Scroll detected."),X(z)){k("Scroll event fired while unrendered. Ignoring...");return}pt(Ot)}if(k("registerListenersAndPositionElements invoked."),!i(z)){k("Aborting because element has been uninstalled");return}i(z).onRendered=Bt,i(z).onExpand=kt,i(z).onShrink=kt;var Ct=i(z).style;B(z,Ct.width,Ct.height)}function U(){if(k("finalizeDomMutation invoked."),!i(z)){k("Aborting because element has been uninstalled");return}var B=i(z).style;xt(z,B.width,B.height),et(z,B.width,B.height)}function st(){R(z)}function vt(){k("Installing..."),tt(),at(),r.add(0,bt),r.add(1,Z),r.add(2,Q),r.add(3,U),r.add(4,st)}k("Making detectable..."),L(z)?(k("Element is detached"),rt(),k("Waiting until element is attached..."),i(z).onRendered=function(){k("Element is now attached"),vt()}):vt()}function O(E){var z=i(E);z&&(z.onExpandScroll&&v(_(E),"scroll",z.onExpandScroll),z.onShrinkScroll&&v(S(E),"scroll",z.onShrinkScroll),z.onAnimationStart&&v(z.container,"animationstart",z.onAnimationStart),z.container&&E.removeChild(z.container))}return{makeDetectable:C,addListener:M,uninstall:O,initDocument:c}},Oh}var zh,ly;function V2(){if(ly)return zh;ly=1;var n=Jm().forEach,t=T2(),e=C2(),r=I2(),i=k2(),s=P2(),o=ny(),a=L2(),l=F2(),c=N2(),h=j2();function f(v){return Array.isArray(v)||v.length!==void 0}function g(v){if(Array.isArray(v))return v;var _=[];return n(v,function(S){_.push(S)}),_}function p(v){return v&&v.nodeType===1}zh=function(v){v=v||{};var _;if(v.idHandler)_={get:function(ht){return v.idHandler.get(ht,!0)},set:v.idHandler.set};else{var S=r(),M=i({idGenerator:S,stateHandler:l});_=M}var C=v.reporter;if(!C){var O=C===!1;C=s(O)}var E=m(v,"batchProcessor",a({reporter:C})),z={};z.callOnAdd=!!m(v,"callOnAdd",!0),z.debug=!!m(v,"debug",!1);var R=e(_),k=t({stateHandler:l}),L,X=m(v,"strategy","object"),J=m(v,"important",!1),at={reporter:C,batchProcessor:E,stateHandler:l,idHandler:_,important:J};if(X==="scroll"&&(o.isLegacyOpera()?(C.warn("Scroll strategy is not supported on legacy Opera. Changing to object strategy."),X="object"):o.isIE(9)&&(C.warn("Scroll strategy is not supported on IE9. Changing to object strategy."),X="object")),X==="scroll")L=h(at);else if(X==="object")L=c(at);else throw new Error("Invalid strategy name: "+X);var tt={};function bt(ht,Y,St){function j(Q){var U=R.get(Q);n(U,function(vt){vt(Q)})}function W(Q,U,st){R.add(U,st),Q&&st(U)}if(St||(St=Y,Y=ht,ht={}),!Y)throw new Error("At least one element required.");if(!St)throw new Error("Listener required.");if(p(Y))Y=[Y];else if(f(Y))Y=g(Y);else return C.error("Invalid arguments. Must be a DOM element or a collection of DOM elements.");var ft=0,et=m(ht,"callOnAdd",z.callOnAdd),rt=m(ht,"onReady",function(){}),Z=m(ht,"debug",z.debug);n(Y,function(U){l.getState(U)||(l.initState(U),_.set(U));var st=_.get(U);if(Z&&C.log("Attaching listener to element",st,U),!k.isDetectable(U)){if(Z&&C.log(st,"Not detectable."),k.isBusy(U)){Z&&C.log(st,"System busy making it detectable"),W(et,U,St),tt[st]=tt[st]||[],tt[st].push(function(){ft++,ft===Y.length&&rt()});return}return Z&&C.log(st,"Making detectable..."),k.markBusy(U,!0),L.makeDetectable({debug:Z,important:J},U,function(B){if(Z&&C.log(st,"onElementDetectable"),l.getState(B)){k.markAsDetectable(B),k.markBusy(B,!1),L.addListener(B,j),W(et,B,St);var pt=l.getState(B);if(pt&&pt.startSize){var H=B.offsetWidth,Ot=B.offsetHeight;(pt.startSize.width!==H||pt.startSize.height!==Ot)&&j(B)}tt[st]&&n(tt[st],function(Bt){Bt()})}else Z&&C.log(st,"Element uninstalled before being detectable.");delete tt[st],ft++,ft===Y.length&&rt()})}Z&&C.log(st,"Already detecable, adding listener."),W(et,U,St),ft++}),ft===Y.length&&rt()}function xt(ht){if(!ht)return C.error("At least one element is required.");if(p(ht))ht=[ht];else if(f(ht))ht=g(ht);else return C.error("Invalid arguments. Must be a DOM element or a collection of DOM elements.");n(ht,function(Y){R.removeAllListeners(Y),L.uninstall(Y),l.cleanState(Y)})}function yt(ht){L.initDocument&&L.initDocument(ht)}return{listenTo:bt,removeListener:R.removeListener,removeAllListeners:R.removeAllListeners,uninstall:xt,initDocument:yt}};function m(v,_,S){var M=v[_];return M==null&&S!==void 0?S:M}return zh}var D2=V2();const B2=nn(D2);function q2(n){const{top:t,right:e,bottom:r,left:i,width:s,height:o}=n.getBoundingClientRect();return{top:t,right:e,bottom:r,left:i,width:s,height:o}}const $2=({children:n})=>{const[t,e]=F.useState(null),r=F.useRef(null),i=F.useRef(null);return F.useEffect(()=>{if(!r.current)return;const s=r.current.parentElement;if(!s)return;i.current=B2({strategy:"scroll",callOnAdd:!1});const o=()=>{const a=q2(s);e(a)};return i.current.listenTo(s,o),o(),()=>{i.current&&s&&i.current.uninstall(s)}},[]),t?typeof n=="function"?n(t):F.cloneElement(n,t):w.jsx("div",{ref:r})};function H2(n){const t=F.useRef(!1),e=F.useRef(!1),r=F.useCallback(async()=>{if(!(e.current||t.current)){e.current=!0;try{const i=await Vg();t.current=!0,n&&n(i)}catch{}finally{e.current=!1}}},[n]);return F.useEffect(()=>{const i=s=>{if(!t.current)return r(),s.preventDefault(),s.returnValue="",""};return window.addEventListener("beforeunload",i),()=>{window.removeEventListener("beforeunload",i)}},[r]),{ensureScreenshot:r,screenshotDone:t}}const G2=50,W2=300,U2=20,Y2=[A2("pub_planner_v0"),O2()],X2=({plan:n,catalog:t,onSave:e,onBack:r})=>{const i=ne();return F.useEffect(()=>{i.initCatalog(t),Y2.forEach(s=>s(i,n,e))},[]),F.useEffect(()=>{i.planner.getIn(["catalog","ready"])||i.initCatalog(t)},[t]),H2(s=>{e&&e({imageURI:s})}),w.jsx($2,{children:({width:s,height:o})=>{const a=s-G2-W2,l=o-U2;return w.jsxs("div",{className:"flex flex-nowrap flex-row h-full floor_planner",children:[w.jsx(z2,{onSave:e,onBack:r}),w.jsx(E2,{catalog:t}),w.jsx(mb,{width:a,height:l,catalog:t}),w.jsx(Kw,{catalog:t}),w.jsx(tw,{})]})}})},J2=()=>w.jsxs("div",{className:"fixed inset-0 z-[100] flex flex-col bg-[#2b2d35] overflow-hidden",children:[w.jsxs("div",{className:"flex h-[45px] items-center justify-between border border-[#424242] bg-[#2b2d35] px-2",children:[w.jsx("div",{className:"flex flex-1 items-center",children:w.jsx("div",{className:"h-[30px] w-[30px] rounded bg-[#424242] animate-pulse"})}),w.jsx("div",{className:"flex items-center",children:w.jsx("div",{className:"h-[18px] w-[175px] bg-[#424242] animate-pulse"})}),w.jsx("div",{className:"flex flex-1 items-center justify-end",children:w.jsx("div",{className:"mr-40 flex flex-row gap-3",children:[...Array(2)].map((n,t)=>w.jsx("div",{className:"h-[24px] w-[24px] rounded bg-[#424242] animate-pulse"},`${t}`))})})]}),w.jsxs("div",{className:"flex flex-1",children:[w.jsx("div",{className:"block w-[50px] border-r border-[#424242] bg-[#2b2d35]"}),w.jsx("div",{className:"flex flex-1 items-center justify-center bg-[#2b2d35]",children:w.jsx("div",{className:"h-[90%] w-[90%] bg-[#424242] animate-pulse"})}),w.jsx("div",{className:"w-[300px] border-l border-[#424242] bg-[#2b2d35] flex justify-center items-center",children:w.jsxs("div",{className:"flex w-full flex-col gap-2 justify-center items-center p-6",children:[w.jsx("div",{className:"h-[15px] w-[200px] bg-[#424242] animate-pulse"}),w.jsx("div",{className:"h-[15px] w-[150px] bg-[#424242] animate-pulse"})]})})]}),w.jsxs("div",{className:"py-[3px] px-[1em] text-xs border-t border-[#424242] bg-[#2b2d35] h-5 w-full select-none cursor-default bottom-0 leading-[14px] text-white m-0",children:[w.jsx("div",{className:"relative float-left px-[1em] inline-block border-r border-r-white",children:w.jsx("div",{className:"flex items-center gap-2",children:w.jsx("div",{className:"h-[13px] w-[110px] rounded-sm bg-[#424242] animate-pulse"})})}),w.jsxs("div",{className:"flex flex-1 items-center",children:[[...Array(5)].map((n,t)=>w.jsx("div",{className:"ml-5 h-[13px] w-[30px] rounded-sm bg-[#424242] animate-pulse"},t)),w.jsx("div",{className:"flex flex-1 items-center justify-end",children:w.jsx("div",{className:"mr-5 flex flex-row gap-3",children:[...Array(2)].map((n,t)=>w.jsx("div",{className:"h-[13px] w-[13px] rounded-full bg-[#424242] animate-pulse"},`${t}`))})})]})]})]}),cy=1e-5,vu=0,No=1,Ps=2,hy=3;class Ti{constructor(t){Vt(this,"Polygon");Vt(this,"Vertex");Vt(this,"Node");Vt(this,"matrix");Vt(this,"tree");if(this.Polygon=Rs,this.Vertex=xu,this.Node=Vn,t instanceof Cs)t.updateMatrixWorld(),this.matrix=t.matrixWorld.clone(),t=t.geometry;else if(t instanceof Ai)this.matrix=new Ue;else{if(t instanceof Vn)return this.tree=t,this.matrix=new Ue,this;throw new Error("ThreeBSP: Given geometry is unsupported")}const e=[],r=t.getAttribute("position"),i=t.getAttribute("uv"),s=t.getIndex(),o=l=>{const c=r.getX(l),h=r.getY(l),f=r.getZ(l),g=i?new Et(i.getX(l),i.getY(l)):null,p=new xu(c,h,f,new D,g);return p.applyMatrix4(this.matrix),p},a=s?s.array:[...Array(r.count).keys()];for(let l=0;l<a.length;l+=3){const c=o(a[l]),h=o(a[l+1]),f=o(a[l+2]),g=new Rs([c,h,f]);g.calculateProperties(),e.push(g)}this.tree=new Vn(e)}subtract(t){let e=this.tree.clone(),r=t.tree.clone();return e.invert(),e.clipTo(r),r.clipTo(e),r.invert(),r.clipTo(e),r.invert(),e.build(r.allPolygons()),e.invert(),e=new Ti(e),e.matrix=this.matrix,e}union(t){let e=this.tree.clone(),r=t.tree.clone();return e.clipTo(r),r.clipTo(e),r.invert(),r.clipTo(e),r.invert(),e.build(r.allPolygons()),e=new Ti(e),e.matrix=this.matrix,e}intersect(t){let e=this.tree.clone(),r=t.tree.clone();return e.invert(),r.clipTo(e),r.invert(),e.clipTo(r),r.clipTo(e),e.build(r.allPolygons()),e.invert(),e=new Ti(e),e.matrix=this.matrix,e}toGeometry(){const t=new Ue().copy(this.matrix).invert(),e=[],r=[];this.tree.allPolygons().forEach(o=>{for(let a=2;a<o.vertices.length;a++)[o.vertices[0],o.vertices[a-1],o.vertices[a]].forEach(c=>{const h=new D(c.x,c.y,c.z).applyMatrix4(t);e.push(h.x,h.y,h.z),c.uv?r.push(c.uv.x,c.uv.y):r.push(0,0)})});const s=new Ai;return s.setAttribute("position",new jn(e,3)),s.setAttribute("uv",new jn(r,2)),s.computeVertexNormals(),s}toMesh(t){const e=this.toGeometry(),r=new Cs(e,t),i=new D,s=new ps,o=new D;return this.matrix.decompose(i,s,o),r.position.copy(i),r.quaternion.copy(s),r.scale.copy(o),r}}class Rs{constructor(t,e,r){Vt(this,"vertices");Vt(this,"normal");Vt(this,"w");t instanceof Array||(t=[]),this.vertices=t,t.length>0?this.calculateProperties():this.normal=this.w=void 0}calculateProperties(){var t=this.vertices[0],e=this.vertices[1],r=this.vertices[2];return this.normal=e.clone().subtract(t).cross(r.clone().subtract(t)).normalize(),this.normal&&(this.w=this.normal.clone().dot(t)),this}clone(){var t,e,r=new Rs;for(t=0,e=this.vertices.length;t<e;t++)r.vertices.push(this.vertices[t].clone());return r.calculateProperties(),r}flip(){var t,e=[];for(this.normal&&this.normal.multiplyScalar(-1),this.w&&(this.w*=-1),t=this.vertices.length-1;t>=0;t--)e.push(this.vertices[t]);return this.vertices=e,this}classifyVertex(t){if(!this.normal||!this.w)return vu;var e=this.normal.dot(t)-this.w;return e<-cy?Ps:e>cy?No:vu}classifySide(t){var e,r,i,s=0,o=0,a=t.vertices.length;for(e=0;e<a;e++)r=t.vertices[e],i=this.classifyVertex(r),i===No?s++:i===Ps&&o++;return s>0&&o===0?No:s===0&&o>0?Ps:s===0&&o===0?vu:hy}splitPolygon(t,e,r,i,s){var o=this.classifySide(t);if(o===vu)(this.normal&&t.normal&&this.normal.dot(t.normal)>0?e:r).push(t);else if(o===No)i.push(t);else if(o===Ps)s.push(t);else{var a,l,c,h,f,g,p,m,v,_=[],S=[];for(l=0,a=t.vertices.length;l<a;l++)c=(l+1)%a,g=t.vertices[l],p=t.vertices[c],h=this.classifyVertex(g),f=this.classifyVertex(p),h!=Ps&&_.push(g),h!=No&&S.push(g),(h|f)===hy&&this.w&&this.normal&&(m=(this.w-this.normal.dot(g))/this.normal.dot(p.clone().subtract(g)),v=g.interpolate(p,m),_.push(v),S.push(v));_.length>=3&&i.push(new Rs(_).calculateProperties()),S.length>=3&&s.push(new Rs(S).calculateProperties())}}}class xu{constructor(t,e,r,i,s){Vt(this,"x");Vt(this,"y");Vt(this,"z");Vt(this,"normal");Vt(this,"uv");this.x=t,this.y=e,this.z=r,this.normal=i||new D,this.uv=s||new Et}clone(){return new xu(this.x,this.y,this.z,this.normal.clone(),this.uv?this.uv.clone():null)}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}subtract(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}cross(t){var e=this.x,r=this.y,i=this.z;return this.x=r*t.z-i*t.y,this.y=i*t.x-e*t.z,this.z=e*t.y-r*t.x,this}normalize(){var t=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z);return this.x/=t,this.y/=t,this.z/=t,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lerp(t,e){return this.add(t.clone().subtract(this).multiplyScalar(e)),this.normal.add(t.normal.clone().sub(this.normal).multiplyScalar(e)),this.uv&&t.uv&&this.uv.add(t.uv.clone().sub(this.uv).multiplyScalar(e)),this}interpolate(t,e){return this.clone().lerp(t,e)}applyMatrix4(t){var e=this.x,r=this.y,i=this.z,s=t.elements;return this.x=s[0]*e+s[4]*r+s[8]*i+s[12],this.y=s[1]*e+s[5]*r+s[9]*i+s[13],this.z=s[2]*e+s[6]*r+s[10]*i+s[14],this}}class Vn{constructor(t){Vt(this,"polygons");Vt(this,"front");Vt(this,"back");Vt(this,"divider");var e,r,i=[],s=[];if(this.polygons=[],this.front=this.back=void 0,!(!(t instanceof Array)||t.length===0)){for(this.divider=t[0].clone(),e=0,r=t.length;e<r;e++)this.divider.splitPolygon(t[e],this.polygons,this.polygons,i,s);i.length>0&&(this.front=new Vn(i)),s.length>0&&(this.back=new Vn(s))}}isConvex(t){var e,r;for(e=0;e<t.length;e++)for(r=0;r<t.length;r++)if(e!==r&&t[e].classifySide(t[r])!==Ps)return!1;return!0}build(t){var e,r,i=[],s=[];for(this.divider||(this.divider=t[0].clone()),e=0,r=t.length;e<r;e++)this.divider.splitPolygon(t[e],this.polygons,this.polygons,i,s);i.length>0&&(this.front||(this.front=new Vn),this.front.build(i)),s.length>0&&(this.back||(this.back=new Vn),this.back.build(s))}allPolygons(){var t=this.polygons.slice();return this.front&&(t=t.concat(this.front.allPolygons())),this.back&&(t=t.concat(this.back.allPolygons())),t}clone(){var t=new Vn;return t.divider=this.divider?this.divider.clone():void 0,t.polygons=this.polygons.map(function(e){return e.clone()}),t.front=this.front&&this.front.clone(),t.back=this.back&&this.back.clone(),t}invert(){var t,e,r;for(t=0,e=this.polygons.length;t<e;t++)this.polygons[t].flip();return this.divider&&this.divider.flip(),this.front&&this.front.invert(),this.back&&this.back.invert(),r=this.front,this.front=this.back,this.back=r,this}clipPolygons(t){var e,r,i,s;if(!this.divider)return t.slice();for(i=[],s=[],e=0,r=t.length;e<r;e++)this.divider.splitPolygon(t[e],i,s,i,s);return this.front&&(i=this.front.clipPolygons(i)),this.back?s=this.back.clipPolygons(s):s=[],i.concat(s)}clipTo(t){this.polygons=t.clipPolygons(this.polygons),this.front&&this.front.clipTo(t),this.back&&this.back.clipTo(t)}}window.ThreeBSP=Ti;const Ls=Math.PI/2,fy=(n,t,e,r)=>{let i=new Gm;t&&(n.map=i.load(t.uri),n.needsUpdate=!0,n.map.wrapS=yn,n.map.wrapT=yn,n.map.repeat.set(e*t.lengthRepeatScale,r*t.heightRepeatScale),t.normal&&(n.normalMap=i.load(t.normal.uri),n.normalScale=new Et(t.normal.normalScaleX,t.normal.normalScaleY),n.normalMap.wrapS=yn,n.normalMap.wrapT=yn,n.normalMap.repeat.set(e*t.normal.lengthRepeatScale,r*t.normal.heightRepeatScale)))};function Z2(n,t,e,r){let i=t.vertices.get(n.vertices.get(0)),s=t.vertices.get(n.vertices.get(1)),o=!1;if(i.x>s.x){let X=i;i=s,s=X,o=!0}let a=n.properties.getIn(["height","length"]),l=n.properties.getIn(["thickness","length"]),c=l/2,h=.2,f=1,g=ga(i,s),p=g/2,m=new Os({color:n.selected?Wt.MESH_SELECTED:13882323}),v=new Cs(new pu(g,a,l),m),_=Math.asin((s.y-i.y)/g),S=Math.sin(_),M=Math.cos(_);v.position.y+=a/2,v.position.x+=p*M,v.position.z-=p*S,v.rotation.y=_,n.holes.forEach(X=>{let J=t.holes.get(X),at=J.properties.getIn(["width","length"]),tt=J.properties.getIn(["height","length"]),bt=J.properties.getIn(["altitude","length"]),yt=(o?1-J.offset:J.offset)*g,ht=new pu(at,tt,l),Y=new Cs(ht);Y.position.y+=tt/2+bt,Y.position.x+=yt*M,Y.position.z-=yt*S,Y.rotation.y=_;let St=new Ti(v),j=new Ti(Y);v=St.subtract(j).toMesh(m)}),v.name="soul";let C=new Os,O=new Os;fy(C,r[n.properties.get("textureB")],g,a),fy(O,r[n.properties.get("textureA")],g,a);let E=h/l,z=c+f,R=v.clone();R.material=C,R.scale.set(1,1,E),R.position.x+=z*Math.cos(_-Ls),R.position.z-=z*Math.sin(_-Ls),R.name="frontFace";let k=v.clone();k.material=O,k.scale.set(1,1,E),k.position.x+=z*Math.cos(_+Ls),k.position.z-=z*Math.sin(_+Ls),k.name="backFace";let L=new RS;return L.add(v,R,k),Promise.resolve(L)}function K2(n,t,e,r,i,s,o,a,l){let c=()=>(a(),l()),h=i.getObjectByName("soul"),f=i.getObjectByName("frontFace"),g=i.getObjectByName("backFace");if(o[0]=="selected")h.material=new Os({color:n.selected?Wt.MESH_SELECTED:13882323});else if(o[0]=="properties")if(o[1]=="thickness"){let p=n.getIn(["properties","thickness","length"]),m=s.getIn(["properties","thickness","length"]),_=p/2+1,S=m/h.scale.z,M=h.rotation.y,C=_*Math.cos(M-Ls),O=_*Math.sin(M-Ls);h.scale.set(1,1,p/S),f.position.x=h.position.x+C,f.position.z=h.position.z+O,g.position.x=h.position.x-C,g.position.z=h.position.z-O}else return c();else return c();return Promise.resolve(i)}const dy=20,py={textAnchor:"middle"},Q2={stroke:Wt.LINE_MESH_COLOR.selected},gy={strokeWidth:1,stroke:Wt.COLORS.black},tE={...gy,stroke:Wt.LINE_MESH_COLOR.selected};function eE(n,t,e){let r={name:n,prototype:"lines",info:t,properties:{height:{label:"height",type:"length-measure",defaultValue:{length:300}},thickness:{label:"thickness",type:"length-measure",defaultValue:{length:15,_length:15,_unit:ln}}},render2D:function(i,s,o){let{x:a,y:l}=s.vertices.get(i.vertices.get(0)),{x:c,y:h}=s.vertices.get(i.vertices.get(1)),f=Ve(a,l,c,h),g=f/5,p=i.getIn(["properties","thickness","length"]),m=p/2,v=m+dy,_=11,M=m+dy+5;return i.selected?w.jsxs("g",{children:[w.jsx("rect",{x:"0",y:-m,width:f,height:p,style:tE}),w.jsx("line",{x1:g,y1:-v,x2:g,y2:v,style:Q2}),w.jsx("text",{x:g,y:M+_,style:py,children:"A"}),w.jsx("text",{x:g,y:-M,style:py,children:"B"})]}):w.jsx("rect",{x:"0",y:-m,width:f,height:p,style:gy})},render3D:function(i,s,o){return Z2(i,s,o,e)},updateRender3D:(i,s,o,a,l,c,h,f)=>K2(i,s,o,e,a,l,c,h,f)};if(e&&Object.keys(e).length>0){let i={none:"None"};for(let s in e)i[s]=e[s].name;r.properties.textureA={label:"texture A",type:"enum",defaultValue:i.bricks?"bricks":"none",values:i},r.properties.textureB={label:"texture B",type:"enum",defaultValue:i.bricks?"bricks":"none",values:i}}return r}const rE=(n,t,e,r)=>{let i=new Gm;t&&(n.map=i.load(t.uri),n.needsUpdate=!0,n.map.wrapS=yn,n.map.wrapT=yn,n.map.repeat.set(e*t.lengthRepeatScale,r*t.heightRepeatScale),t.normal&&(n.normalMap=i.load(t.normal.uri),n.normalScale=new Et(t.normal.normalScaleX,t.normal.normalScaleY),n.normalMap.wrapS=yn,n.normalMap.wrapT=yn,n.normalMap.repeat.set(e*t.normal.lengthRepeatScale,r*t.normal.heightRepeatScale)))},nE=n=>{n.computeBoundingBox();let{min:t,max:e}=n.boundingBox,r=new Et(0-t.x,0-t.y),i=new Et(e.x-t.x,e.y-t.y);n.faceVertexUvs[0]=n.faces.map(s=>{let o=n.vertices[s.a],a=n.vertices[s.b],l=n.vertices[s.c];return[new Et((o.x+r.x)/i.x,(o.y+r.y)/i.y),new Et((a.x+r.x)/i.x,(a.y+r.y)/i.y),new Et((l.x+r.x)/i.x,(l.y+r.y)/i.y)]}),n.uvsNeedUpdate=!0};function iE(n,t,e,r){let i=[];n.vertices.forEach(v=>{i.push(t.vertices.get(v))});let s=n.properties.get("texture"),o=n.properties.get("patternColor");n.selected?o=Wt.AREA_MESH_COLOR.selected:s&&s!=="none"&&(o=Wt.AREA_MESH_COLOR.unselected);let a=new lh;a.moveTo(i[0].x,i[0].y);for(let v=1;v<i.length;v++)a.lineTo(i[v].x,i[v].y);let l=new d2({side:sS,color:o});n.holes.forEach(v=>{let _=[];t.getIn(["areas",v,"vertices"]).forEach(M=>{let{x:C,y:O}=t.getIn(["vertices",M]);_.push([C,O])}),_=_.reverse();let S=oE(_);a.holes.push(S)});let c=new fh(a);nE(c);let h=new ys().setFromObject(new Cs(c,new Os)),f=h.max.x-h.min.x,g=h.max.y-h.min.y,p=r[s];rE(l,p,f,g);let m=new Cs(c,l);return m.rotation.x-=Math.PI/2,m.name="floor",Promise.resolve(m)}function sE(n,t,e,r,i,s,o,a,l){let c=()=>(a(),l()),h=i.getObjectByName("floor");if(o[0]=="selected"){let f=n.selected?Wt.AREA_MESH_COLOR.selected:n.properties.get("patternColor")||Wt.AREA_MESH_COLOR.unselected;h.material.color.set(f)}else if(o[0]=="properties"){if(o[1]==="texture")return c()}else return c();return Promise.resolve(i)}const oE=n=>{let t=new lh;t.moveTo(n[0][0],n[0][1]);for(let e=1;e<n.length;e++)t.lineTo(n[e][0],n[e][1]);return t};function aE(n,t,e){let r={name:n,prototype:"areas",info:{...t,visibility:{catalog:!1,layerElementsVisible:!1}},properties:{patternColor:{label:"color",type:"color",defaultValue:Wt.AREA_MESH_COLOR.unselected},thickness:{label:"thickness",type:"length-measure",defaultValue:{length:0,_length:0,_unit:ln}}},render2D:function(i,s,o){let a="";const l=i.properties.get("texture"),c=e[l],h=[];i.vertices.forEach((C,O)=>{const E=s.vertices.get(C);h.push(E),a+=(O?"L":"M")+E.x+" "+E.y+" "}),i.holes.forEach(C=>{s.areas.get(C).vertices.reverse().forEach((E,z)=>{const R=s.vertices.get(E);a+=(z?"L":"M")+R.x+" "+R.y+" "})});const f=Math.min(...h.map(C=>C.x)),g=Math.max(...h.map(C=>C.x)),p=Math.min(...h.map(C=>C.y)),m=Math.max(...h.map(C=>C.y)),v=g-f,_=m-p;i.properties.get("patternColor"),i.selected;const S=i.selected?Wt.AREA_MESH_COLOR.selected:i.properties.get("patternColor"),M=`pattern-${i.id}`;return w.jsxs("g",{children:[w.jsx("defs",{children:c&&w.jsx("pattern",{id:M,patternUnits:"userSpaceOnUse",width:v/(v*c.lengthRepeatScale),height:_/(_*c.heightRepeatScale),x:f,y:p,children:w.jsx("image",{href:c.uri,width:v,height:_,preserveAspectRatio:"none"})})}),w.jsx("path",{d:a,fill:c?`url(#${M})`:S,stroke:i.selected?"#0096fd":"#000",strokeWidth:"2"})]})},render3D:function(i,s,o){return iE(i,s,o,e)},updateRender3D:(i,s,o,a,l,c,h,f)=>sE(i,s,o,e,a,l,c,h,f)};if(e&&Object.keys(e).length>0){let i={none:"None"};for(let s in e)i[s]=e[s].name;r.properties.texture={label:"texture",type:"enum",defaultValue:"none",values:i}}return r}ze.AreaFactory=aE,ze.Catalog=y2,ze.ReactPlannerLoader=J2,ze.WallFactory=eE,ze.convertUnits=Wr,ze.default=X2,Object.defineProperties(ze,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
77
|
+
`,X+="."+Y+" { "+h(["-webkit-animation-duration: 0.1s","animation-duration: 0.1s","-webkit-animation-name: "+L,"animation-name: "+L])+` }
|
|
78
|
+
`,X+="@-webkit-keyframes "+L+` { 0% { opacity: 1; } 50% { opacity: 0; } 100% { opacity: 1; } }
|
|
79
|
+
`,X+="@keyframes "+L+" { 0% { opacity: 1; } 50% { opacity: 0; } 100% { opacity: 1; } }",I(X)}}function p(M){M.className+=" "+l+"_animation_active"}function m(M,z,R){if(M.addEventListener)M.addEventListener(z,R);else if(M.attachEvent)M.attachEvent("on"+z,R);else return e.error("[scroll] Don't know how to add event listeners.")}function v(M,z,R){if(M.removeEventListener)M.removeEventListener(z,R);else if(M.detachEvent)M.detachEvent("on"+z,R);else return e.error("[scroll] Don't know how to remove event listeners.")}function _(M){return i(M).container.childNodes[0].childNodes[0].childNodes[0]}function S(M){return i(M).container.childNodes[0].childNodes[0].childNodes[1]}function A(M,z){var R=i(M).listeners;if(!R.push)throw new Error("Cannot add listener to an element that is not detectable.");i(M).listeners.push(z)}function C(M,z,R){R||(R=z,z=M,M=null),M=M||{};function I(){if(M.debug){var B=Array.prototype.slice.call(arguments);if(B.unshift(s.get(z),"Scroll: "),e.log.apply)e.log.apply(null,B);else for(var ct=0;ct<B.length;ct++)e.log(B[ct])}}function L(B){function ct(H){var _t=H.getRootNode&&H.getRootNode().contains(H);return H===H.ownerDocument.body||H.ownerDocument.body.contains(H)||_t}return!ct(B)||window.getComputedStyle(B)===null}function Y(B){var ct=i(B).container.childNodes[0],H=window.getComputedStyle(ct);return!H.width||H.width.indexOf("px")===-1}function X(){var B=window.getComputedStyle(z),ct={};return ct.position=B.position,ct.width=z.offsetWidth,ct.height=z.offsetHeight,ct.top=B.top,ct.right=B.right,ct.bottom=B.bottom,ct.left=B.left,ct.widthCSS=B.width,ct.heightCSS=B.height,ct}function it(){var B=X();i(z).startSize={width:B.width,height:B.height},I("Element start size",i(z).startSize)}function rt(){i(z).listeners=[]}function vt(){if(I("storeStyle invoked."),!i(z)){I("Aborting because element has been uninstalled");return}var B=X();i(z).style=B}function mt(B,ct,H){i(B).lastWidth=ct,i(B).lastHeight=H}function dt(B){return _(B).childNodes[0]}function ut(){return 2*o.width+1}function W(){return 2*o.height+1}function gt(B){return B+10+ut()}function k(B){return B+10+W()}function j(B){return B*2+ut()}function K(B){return B*2+W()}function Z(B,ct,H){var _t=_(B),Ft=S(B),Pt=gt(ct),Ot=k(H),$t=j(ct),ft=K(H);_t.scrollLeft=Pt,_t.scrollTop=Ot,Ft.scrollLeft=$t,Ft.scrollTop=ft}function et(){var B=i(z).container;if(!B){B=document.createElement("div"),B.className=l,B.style.cssText=h(["visibility: hidden","display: inline","width: 0px","height: 0px","z-index: -1","overflow: hidden","margin: 0","padding: 0"]),i(z).container=B,p(B),z.appendChild(B);var ct=function(){i(z).onRendered&&i(z).onRendered()};m(B,"animationstart",ct),i(z).onAnimationStart=ct}return B}function U(){function B(){var oe=i(z).style;if(oe.position==="static"){z.style.setProperty("position","relative",M.important?"important":"");var gr=function(nn,jr,_o,di){function ee(be){return be.replace(/[^-\d\.]/g,"")}var pi=_o[di];pi!=="auto"&&ee(pi)!=="0"&&(nn.warn("An element that is positioned static has style."+di+"="+pi+" which is ignored due to the static positioning. The element will need to be positioned relative, so the style."+di+" will be set to 0. Element: ",jr),jr.style[di]=0)};gr(e,z,oe,"top"),gr(e,z,oe,"right"),gr(e,z,oe,"bottom"),gr(e,z,oe,"left")}}function ct(oe,gr,nn,jr){return oe=oe?oe+"px":"0",gr=gr?gr+"px":"0",nn=nn?nn+"px":"0",jr=jr?jr+"px":"0",["left: "+oe,"top: "+gr,"right: "+jr,"bottom: "+nn]}if(I("Injecting elements"),!i(z)){I("Aborting because element has been uninstalled");return}B();var H=i(z).container;H||(H=et());var _t=o.width,Ft=o.height,Pt=h(["position: absolute","flex: none","overflow: hidden","z-index: -1","visibility: hidden","width: 100%","height: 100%","left: 0px","top: 0px"]),Ot=h(["position: absolute","flex: none","overflow: hidden","z-index: -1","visibility: hidden"].concat(ct(-(1+_t),-(1+Ft),-Ft,-_t))),$t=h(["position: absolute","flex: none","overflow: scroll","z-index: -1","visibility: hidden","width: 100%","height: 100%"]),ft=h(["position: absolute","flex: none","overflow: scroll","z-index: -1","visibility: hidden","width: 100%","height: 100%"]),xt=h(["position: absolute","left: 0","top: 0"]),Nt=h(["position: absolute","width: 200%","height: 200%"]),wt=document.createElement("div"),Qe=document.createElement("div"),Mn=document.createElement("div"),hi=document.createElement("div"),fi=document.createElement("div"),ps=document.createElement("div");wt.dir="ltr",wt.style.cssText=Pt,wt.className=l,Qe.className=l,Qe.style.cssText=Ot,Mn.style.cssText=$t,hi.style.cssText=xt,fi.style.cssText=ft,ps.style.cssText=Nt,Mn.appendChild(hi),fi.appendChild(ps),Qe.appendChild(Mn),Qe.appendChild(fi),wt.appendChild(Qe),H.appendChild(wt);function eu(){var oe=i(z);oe&&oe.onExpand?oe.onExpand():I("Aborting expand scroll handler: element has been uninstalled")}function xo(){var oe=i(z);oe&&oe.onShrink?oe.onShrink():I("Aborting shrink scroll handler: element has been uninstalled")}m(Mn,"scroll",eu),m(fi,"scroll",xo),i(z).onExpandScroll=eu,i(z).onShrinkScroll=xo}function Q(){function B($t,ft,xt){var Nt=dt($t),wt=gt(ft),Qe=k(xt);Nt.style.setProperty("width",wt+"px",M.important?"important":""),Nt.style.setProperty("height",Qe+"px",M.important?"important":"")}function ct($t){var ft=z.offsetWidth,xt=z.offsetHeight,Nt=ft!==i(z).lastWidth||xt!==i(z).lastHeight;I("Storing current size",ft,xt),mt(z,ft,xt),r.add(0,function(){if(Nt){if(!i(z)){I("Aborting because element has been uninstalled");return}if(!H()){I("Aborting because element container has not been initialized");return}if(M.debug){var Qe=z.offsetWidth,Mn=z.offsetHeight;(Qe!==ft||Mn!==xt)&&e.warn(s.get(z),"Scroll: Size changed before updating detector elements.")}B(z,ft,xt)}}),r.add(1,function(){if(!i(z)){I("Aborting because element has been uninstalled");return}if(!H()){I("Aborting because element container has not been initialized");return}Z(z,ft,xt)}),Nt&&$t&&r.add(2,function(){if(!i(z)){I("Aborting because element has been uninstalled");return}if(!H()){I("Aborting because element container has not been initialized");return}$t()})}function H(){return!!i(z).container}function _t(){function $t(){return i(z).lastNotifiedWidth===void 0}I("notifyListenersIfNeeded invoked");var ft=i(z);if($t()&&ft.lastWidth===ft.startSize.width&&ft.lastHeight===ft.startSize.height)return I("Not notifying: Size is the same as the start size, and there has been no notification yet.");if(ft.lastWidth===ft.lastNotifiedWidth&&ft.lastHeight===ft.lastNotifiedHeight)return I("Not notifying: Size already notified");I("Current size not notified, notifying..."),ft.lastNotifiedWidth=ft.lastWidth,ft.lastNotifiedHeight=ft.lastHeight,n(i(z).listeners,function(xt){xt(z)})}function Ft(){if(I("startanimation triggered."),Y(z)){I("Ignoring since element is still unrendered...");return}I("Element rendered.");var $t=_(z),ft=S(z);($t.scrollLeft===0||$t.scrollTop===0||ft.scrollLeft===0||ft.scrollTop===0)&&(I("Scrollbars out of sync. Updating detector elements..."),ct(_t))}function Pt(){if(I("Scroll detected."),Y(z)){I("Scroll event fired while unrendered. Ignoring...");return}ct(_t)}if(I("registerListenersAndPositionElements invoked."),!i(z)){I("Aborting because element has been uninstalled");return}i(z).onRendered=Ft,i(z).onExpand=Pt,i(z).onShrink=Pt;var Ot=i(z).style;B(z,Ot.width,Ot.height)}function G(){if(I("finalizeDomMutation invoked."),!i(z)){I("Aborting because element has been uninstalled");return}var B=i(z).style;mt(z,B.width,B.height),Z(z,B.width,B.height)}function tt(){R(z)}function ht(){I("Installing..."),rt(),it(),r.add(0,vt),r.add(1,U),r.add(2,Q),r.add(3,G),r.add(4,tt)}I("Making detectable..."),L(z)?(I("Element is detached"),et(),I("Waiting until element is attached..."),i(z).onRendered=function(){I("Element is now attached"),ht()}):ht()}function O(M){var z=i(M);z&&(z.onExpandScroll&&v(_(M),"scroll",z.onExpandScroll),z.onShrinkScroll&&v(S(M),"scroll",z.onShrinkScroll),z.onAnimationStart&&v(z.container,"animationstart",z.onAnimationStart),z.container&&M.removeChild(z.container))}return{makeDetectable:C,addListener:A,uninstall:O,initDocument:c}},lh}var ch,ey;function R2(){if(ey)return ch;ey=1;var n=qm().forEach,t=M2(),e=E2(),r=A2(),i=O2(),s=z2(),o=Xm(),a=C2(),l=k2(),c=I2(),h=P2();function f(v){return Array.isArray(v)||v.length!==void 0}function g(v){if(Array.isArray(v))return v;var _=[];return n(v,function(S){_.push(S)}),_}function p(v){return v&&v.nodeType===1}ch=function(v){v=v||{};var _;if(v.idHandler)_={get:function(ut){return v.idHandler.get(ut,!0)},set:v.idHandler.set};else{var S=r(),A=i({idGenerator:S,stateHandler:l});_=A}var C=v.reporter;if(!C){var O=C===!1;C=s(O)}var M=m(v,"batchProcessor",a({reporter:C})),z={};z.callOnAdd=!!m(v,"callOnAdd",!0),z.debug=!!m(v,"debug",!1);var R=e(_),I=t({stateHandler:l}),L,Y=m(v,"strategy","object"),X=m(v,"important",!1),it={reporter:C,batchProcessor:M,stateHandler:l,idHandler:_,important:X};if(Y==="scroll"&&(o.isLegacyOpera()?(C.warn("Scroll strategy is not supported on legacy Opera. Changing to object strategy."),Y="object"):o.isIE(9)&&(C.warn("Scroll strategy is not supported on IE9. Changing to object strategy."),Y="object")),Y==="scroll")L=h(it);else if(Y==="object")L=c(it);else throw new Error("Invalid strategy name: "+Y);var rt={};function vt(ut,W,gt){function k(Q){var G=R.get(Q);n(G,function(ht){ht(Q)})}function j(Q,G,tt){R.add(G,tt),Q&&tt(G)}if(gt||(gt=W,W=ut,ut={}),!W)throw new Error("At least one element required.");if(!gt)throw new Error("Listener required.");if(p(W))W=[W];else if(f(W))W=g(W);else return C.error("Invalid arguments. Must be a DOM element or a collection of DOM elements.");var K=0,Z=m(ut,"callOnAdd",z.callOnAdd),et=m(ut,"onReady",function(){}),U=m(ut,"debug",z.debug);n(W,function(G){l.getState(G)||(l.initState(G),_.set(G));var tt=_.get(G);if(U&&C.log("Attaching listener to element",tt,G),!I.isDetectable(G)){if(U&&C.log(tt,"Not detectable."),I.isBusy(G)){U&&C.log(tt,"System busy making it detectable"),j(Z,G,gt),rt[tt]=rt[tt]||[],rt[tt].push(function(){K++,K===W.length&&et()});return}return U&&C.log(tt,"Making detectable..."),I.markBusy(G,!0),L.makeDetectable({debug:U,important:X},G,function(B){if(U&&C.log(tt,"onElementDetectable"),l.getState(B)){I.markAsDetectable(B),I.markBusy(B,!1),L.addListener(B,k),j(Z,B,gt);var ct=l.getState(B);if(ct&&ct.startSize){var H=B.offsetWidth,_t=B.offsetHeight;(ct.startSize.width!==H||ct.startSize.height!==_t)&&k(B)}rt[tt]&&n(rt[tt],function(Ft){Ft()})}else U&&C.log(tt,"Element uninstalled before being detectable.");delete rt[tt],K++,K===W.length&&et()})}U&&C.log(tt,"Already detecable, adding listener."),j(Z,G,gt),K++}),K===W.length&&et()}function mt(ut){if(!ut)return C.error("At least one element is required.");if(p(ut))ut=[ut];else if(f(ut))ut=g(ut);else return C.error("Invalid arguments. Must be a DOM element or a collection of DOM elements.");n(ut,function(W){R.removeAllListeners(W),L.uninstall(W),l.cleanState(W)})}function dt(ut){L.initDocument&&L.initDocument(ut)}return{listenTo:vt,removeListener:R.removeListener,removeAllListeners:R.removeAllListeners,uninstall:mt,initDocument:dt}};function m(v,_,S){var A=v[_];return A==null&&S!==void 0?S:A}return ch}var L2=R2();const N2=Br(L2);function F2(n){const{top:t,right:e,bottom:r,left:i,width:s,height:o}=n.getBoundingClientRect();return{top:t,right:e,bottom:r,left:i,width:s,height:o}}const j2=({children:n})=>{const[t,e]=N.useState(null),r=N.useRef(null),i=N.useRef(null);return N.useEffect(()=>{if(!r.current)return;const s=r.current.parentElement;if(!s)return;i.current=N2({strategy:"scroll",callOnAdd:!1});const o=()=>{const a=F2(s);e(a)};return i.current.listenTo(s,o),o(),()=>{i.current&&s&&i.current.uninstall(s)}},[]),t?typeof n=="function"?n(t):N.cloneElement(n,t):w.jsx("div",{ref:r})};function V2(n){const t=N.useRef(!1),e=N.useRef(!1),r=N.useCallback(async()=>{if(!(e.current||t.current)){e.current=!0;try{const i=await kg();t.current=!0,n&&n(i)}catch{}finally{e.current=!1}}},[n]);return N.useEffect(()=>{const i=s=>{if(!t.current)return r(),s.preventDefault(),s.returnValue="",""};return window.addEventListener("beforeunload",i),()=>{window.removeEventListener("beforeunload",i)}},[r]),{ensureScreenshot:r,screenshotDone:t}}const D2=50,B2=300,q2=20,$2=[b2("pub_planner_v0"),w2()],H2=({plan:n,catalog:t,onSave:e,onBack:r})=>{const i=Jt();return N.useEffect(()=>{i.initCatalog(t),$2.forEach(s=>s(i,n,e))},[]),N.useEffect(()=>{i.planner.getIn(["catalog","ready"])||i.initCatalog(t)},[t]),V2(s=>{e&&e({imageURI:s})}),w.jsx(j2,{children:({width:s,height:o})=>{const a=s-D2-B2,l=o-q2;return w.jsxs("div",{className:"flex flex-nowrap flex-row h-full floor_planner",children:[w.jsx(S2,{onSave:e,onBack:r}),w.jsx(x2,{catalog:t}),w.jsx(hb,{width:a,height:l,catalog:t}),w.jsx(Uw,{catalog:t}),w.jsx(Xb,{})]})}})},G2=()=>w.jsxs("div",{className:"fixed inset-0 z-[100] flex flex-col bg-[#2b2d35] overflow-hidden",children:[w.jsxs("div",{className:"flex h-[45px] items-center justify-between border border-[#424242] bg-[#2b2d35] px-2",children:[w.jsx("div",{className:"flex flex-1 items-center",children:w.jsx("div",{className:"h-[30px] w-[30px] rounded bg-[#424242] animate-pulse"})}),w.jsx("div",{className:"flex items-center",children:w.jsx("div",{className:"h-[18px] w-[175px] bg-[#424242] animate-pulse"})}),w.jsx("div",{className:"flex flex-1 items-center justify-end",children:w.jsx("div",{className:"mr-40 flex flex-row gap-3",children:[...Array(2)].map((n,t)=>w.jsx("div",{className:"h-[24px] w-[24px] rounded bg-[#424242] animate-pulse"},`${t}`))})})]}),w.jsxs("div",{className:"flex flex-1",children:[w.jsx("div",{className:"block w-[50px] border-r border-[#424242] bg-[#2b2d35]"}),w.jsx("div",{className:"flex flex-1 items-center justify-center bg-[#2b2d35]",children:w.jsx("div",{className:"h-[90%] w-[90%] bg-[#424242] animate-pulse"})}),w.jsx("div",{className:"w-[300px] border-l border-[#424242] bg-[#2b2d35] flex justify-center items-center",children:w.jsxs("div",{className:"flex w-full flex-col gap-2 justify-center items-center p-6",children:[w.jsx("div",{className:"h-[15px] w-[200px] bg-[#424242] animate-pulse"}),w.jsx("div",{className:"h-[15px] w-[150px] bg-[#424242] animate-pulse"})]})})]}),w.jsxs("div",{className:"py-[3px] px-[1em] text-xs border-t border-[#424242] bg-[#2b2d35] h-5 w-full select-none cursor-default bottom-0 leading-[14px] text-white m-0",children:[w.jsx("div",{className:"relative float-left px-[1em] inline-block border-r border-r-white",children:w.jsx("div",{className:"flex items-center gap-2",children:w.jsx("div",{className:"h-[13px] w-[110px] rounded-sm bg-[#424242] animate-pulse"})})}),w.jsxs("div",{className:"flex flex-1 items-center",children:[[...Array(5)].map((n,t)=>w.jsx("div",{className:"ml-5 h-[13px] w-[30px] rounded-sm bg-[#424242] animate-pulse"},t)),w.jsx("div",{className:"flex flex-1 items-center justify-end",children:w.jsx("div",{className:"mr-5 flex flex-row gap-3",children:[...Array(2)].map((n,t)=>w.jsx("div",{className:"h-[13px] w-[13px] rounded-full bg-[#424242] animate-pulse"},`${t}`))})})]})]})]}),ry=1e-5,Qa=0,vo=1,hs=2,ny=3;class ci{constructor(t){It(this,"Polygon");It(this,"Vertex");It(this,"Node");It(this,"matrix");It(this,"tree");if(this.Polygon=fs,this.Vertex=tu,this.Node=Sn,t instanceof us)t.updateMatrixWorld(),this.matrix=t.matrixWorld.clone(),t=t.geometry;else if(t instanceof ai)this.matrix=new Re;else{if(t instanceof Sn)return this.tree=t,this.matrix=new Re,this;throw new Error("ThreeBSP: Given geometry is unsupported")}const e=[],r=t.getAttribute("position"),i=t.getAttribute("uv"),s=t.getIndex(),o=l=>{const c=r.getX(l),h=r.getY(l),f=r.getZ(l),g=i?new yt(i.getX(l),i.getY(l)):null,p=new tu(c,h,f,new D,g);return p.applyMatrix4(this.matrix),p},a=s?s.array:[...Array(r.count).keys()];for(let l=0;l<a.length;l+=3){const c=o(a[l]),h=o(a[l+1]),f=o(a[l+2]),g=new fs([c,h,f]);g.calculateProperties(),e.push(g)}this.tree=new Sn(e)}subtract(t){let e=this.tree.clone(),r=t.tree.clone();return e.invert(),e.clipTo(r),r.clipTo(e),r.invert(),r.clipTo(e),r.invert(),e.build(r.allPolygons()),e.invert(),e=new ci(e),e.matrix=this.matrix,e}union(t){let e=this.tree.clone(),r=t.tree.clone();return e.clipTo(r),r.clipTo(e),r.invert(),r.clipTo(e),r.invert(),e.build(r.allPolygons()),e=new ci(e),e.matrix=this.matrix,e}intersect(t){let e=this.tree.clone(),r=t.tree.clone();return e.invert(),r.clipTo(e),r.invert(),e.clipTo(r),r.clipTo(e),e.build(r.allPolygons()),e.invert(),e=new ci(e),e.matrix=this.matrix,e}toGeometry(){const t=new Re().copy(this.matrix).invert(),e=[],r=[];this.tree.allPolygons().forEach(o=>{for(let a=2;a<o.vertices.length;a++)[o.vertices[0],o.vertices[a-1],o.vertices[a]].forEach(c=>{const h=new D(c.x,c.y,c.z).applyMatrix4(t);e.push(h.x,h.y,h.z),c.uv?r.push(c.uv.x,c.uv.y):r.push(0,0)})});const s=new ai;return s.setAttribute("position",new wn(e,3)),s.setAttribute("uv",new wn(r,2)),s.computeVertexNormals(),s}toMesh(t){const e=this.toGeometry(),r=new us(e,t),i=new D,s=new Wi,o=new D;return this.matrix.decompose(i,s,o),r.position.copy(i),r.quaternion.copy(s),r.scale.copy(o),r}}class fs{constructor(t,e,r){It(this,"vertices");It(this,"normal");It(this,"w");t instanceof Array||(t=[]),this.vertices=t,t.length>0?this.calculateProperties():this.normal=this.w=void 0}calculateProperties(){var t=this.vertices[0],e=this.vertices[1],r=this.vertices[2];return this.normal=e.clone().subtract(t).cross(r.clone().subtract(t)).normalize(),this.normal&&(this.w=this.normal.clone().dot(t)),this}clone(){var t,e,r=new fs;for(t=0,e=this.vertices.length;t<e;t++)r.vertices.push(this.vertices[t].clone());return r.calculateProperties(),r}flip(){var t,e=[];for(this.normal&&this.normal.multiplyScalar(-1),this.w&&(this.w*=-1),t=this.vertices.length-1;t>=0;t--)e.push(this.vertices[t]);return this.vertices=e,this}classifyVertex(t){if(!this.normal||!this.w)return Qa;var e=this.normal.dot(t)-this.w;return e<-ry?hs:e>ry?vo:Qa}classifySide(t){var e,r,i,s=0,o=0,a=t.vertices.length;for(e=0;e<a;e++)r=t.vertices[e],i=this.classifyVertex(r),i===vo?s++:i===hs&&o++;return s>0&&o===0?vo:s===0&&o>0?hs:s===0&&o===0?Qa:ny}splitPolygon(t,e,r,i,s){var o=this.classifySide(t);if(o===Qa)(this.normal&&t.normal&&this.normal.dot(t.normal)>0?e:r).push(t);else if(o===vo)i.push(t);else if(o===hs)s.push(t);else{var a,l,c,h,f,g,p,m,v,_=[],S=[];for(l=0,a=t.vertices.length;l<a;l++)c=(l+1)%a,g=t.vertices[l],p=t.vertices[c],h=this.classifyVertex(g),f=this.classifyVertex(p),h!=hs&&_.push(g),h!=vo&&S.push(g),(h|f)===ny&&this.w&&this.normal&&(m=(this.w-this.normal.dot(g))/this.normal.dot(p.clone().subtract(g)),v=g.interpolate(p,m),_.push(v),S.push(v));_.length>=3&&i.push(new fs(_).calculateProperties()),S.length>=3&&s.push(new fs(S).calculateProperties())}}}class tu{constructor(t,e,r,i,s){It(this,"x");It(this,"y");It(this,"z");It(this,"normal");It(this,"uv");this.x=t,this.y=e,this.z=r,this.normal=i||new D,this.uv=s||new yt}clone(){return new tu(this.x,this.y,this.z,this.normal.clone(),this.uv?this.uv.clone():null)}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}subtract(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}cross(t){var e=this.x,r=this.y,i=this.z;return this.x=r*t.z-i*t.y,this.y=i*t.x-e*t.z,this.z=e*t.y-r*t.x,this}normalize(){var t=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z);return this.x/=t,this.y/=t,this.z/=t,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lerp(t,e){return this.add(t.clone().subtract(this).multiplyScalar(e)),this.normal.add(t.normal.clone().sub(this.normal).multiplyScalar(e)),this.uv&&t.uv&&this.uv.add(t.uv.clone().sub(this.uv).multiplyScalar(e)),this}interpolate(t,e){return this.clone().lerp(t,e)}applyMatrix4(t){var e=this.x,r=this.y,i=this.z,s=t.elements;return this.x=s[0]*e+s[4]*r+s[8]*i+s[12],this.y=s[1]*e+s[5]*r+s[9]*i+s[13],this.z=s[2]*e+s[6]*r+s[10]*i+s[14],this}}class Sn{constructor(t){It(this,"polygons");It(this,"front");It(this,"back");It(this,"divider");var e,r,i=[],s=[];if(this.polygons=[],this.front=this.back=void 0,!(!(t instanceof Array)||t.length===0)){for(this.divider=t[0].clone(),e=0,r=t.length;e<r;e++)this.divider.splitPolygon(t[e],this.polygons,this.polygons,i,s);i.length>0&&(this.front=new Sn(i)),s.length>0&&(this.back=new Sn(s))}}isConvex(t){var e,r;for(e=0;e<t.length;e++)for(r=0;r<t.length;r++)if(e!==r&&t[e].classifySide(t[r])!==hs)return!1;return!0}build(t){var e,r,i=[],s=[];for(this.divider||(this.divider=t[0].clone()),e=0,r=t.length;e<r;e++)this.divider.splitPolygon(t[e],this.polygons,this.polygons,i,s);i.length>0&&(this.front||(this.front=new Sn),this.front.build(i)),s.length>0&&(this.back||(this.back=new Sn),this.back.build(s))}allPolygons(){var t=this.polygons.slice();return this.front&&(t=t.concat(this.front.allPolygons())),this.back&&(t=t.concat(this.back.allPolygons())),t}clone(){var t=new Sn;return t.divider=this.divider?this.divider.clone():void 0,t.polygons=this.polygons.map(function(e){return e.clone()}),t.front=this.front&&this.front.clone(),t.back=this.back&&this.back.clone(),t}invert(){var t,e,r;for(t=0,e=this.polygons.length;t<e;t++)this.polygons[t].flip();return this.divider&&this.divider.flip(),this.front&&this.front.invert(),this.back&&this.back.invert(),r=this.front,this.front=this.back,this.back=r,this}clipPolygons(t){var e,r,i,s;if(!this.divider)return t.slice();for(i=[],s=[],e=0,r=t.length;e<r;e++)this.divider.splitPolygon(t[e],i,s,i,s);return this.front&&(i=this.front.clipPolygons(i)),this.back?s=this.back.clipPolygons(s):s=[],i.concat(s)}clipTo(t){this.polygons=t.clipPolygons(this.polygons),this.front&&this.front.clipTo(t),this.back&&this.back.clipTo(t)}}window.ThreeBSP=ci;const ds=Math.PI/2,iy=(n,t,e,r)=>{let i=new Fm;t&&(n.map=i.load(t.uri),n.needsUpdate=!0,n.map.wrapS=tn,n.map.wrapT=tn,n.map.repeat.set(e*t.lengthRepeatScale,r*t.heightRepeatScale),t.normal&&(n.normalMap=i.load(t.normal.uri),n.normalScale=new yt(t.normal.normalScaleX,t.normal.normalScaleY),n.normalMap.wrapS=tn,n.normalMap.wrapT=tn,n.normalMap.repeat.set(e*t.normal.lengthRepeatScale,r*t.normal.heightRepeatScale)))};function W2(n,t,e,r){let i=t.vertices.get(n.vertices.get(0)),s=t.vertices.get(n.vertices.get(1)),o=!1;if(i.x>s.x){let Y=i;i=s,s=Y,o=!0}let a=n.properties.getIn(["height","length"]),l=n.properties.getIn(["thickness","length"]),c=l/2,h=.2,f=1,g=Jo(i,s),p=g/2,m=new ss({color:n.selected?jt.MESH_SELECTED:13882323}),v=new us(new Xa(g,a,l),m),_=Math.asin((s.y-i.y)/g),S=Math.sin(_),A=Math.cos(_);v.position.y+=a/2,v.position.x+=p*A,v.position.z-=p*S,v.rotation.y=_,n.holes.forEach(Y=>{let X=t.holes.get(Y),it=X.properties.getIn(["width","length"]),rt=X.properties.getIn(["height","length"]),vt=X.properties.getIn(["altitude","length"]),dt=(o?1-X.offset:X.offset)*g,ut=new Xa(it,rt,l),W=new us(ut);W.position.y+=rt/2+vt,W.position.x+=dt*A,W.position.z-=dt*S,W.rotation.y=_;let gt=new ci(v),k=new ci(W);v=gt.subtract(k).toMesh(m)}),v.name="soul";let C=new ss,O=new ss;iy(C,r[n.properties.get("textureB")],g,a),iy(O,r[n.properties.get("textureA")],g,a);let M=h/l,z=c+f,R=v.clone();R.material=C,R.scale.set(1,1,M),R.position.x+=z*Math.cos(_-ds),R.position.z-=z*Math.sin(_-ds),R.name="frontFace";let I=v.clone();I.material=O,I.scale.set(1,1,M),I.position.x+=z*Math.cos(_+ds),I.position.z-=z*Math.sin(_+ds),I.name="backFace";let L=new TS;return L.add(v,R,I),Promise.resolve(L)}function U2(n,t,e,r,i,s,o,a,l){let c=()=>(a(),l()),h=i.getObjectByName("soul"),f=i.getObjectByName("frontFace"),g=i.getObjectByName("backFace");if(o[0]=="selected")h.material=new ss({color:n.selected?jt.MESH_SELECTED:13882323});else if(o[0]=="properties")if(o[1]=="thickness"){let p=n.getIn(["properties","thickness","length"]),m=s.getIn(["properties","thickness","length"]),_=p/2+1,S=m/h.scale.z,A=h.rotation.y,C=_*Math.cos(A-ds),O=_*Math.sin(A-ds);h.scale.set(1,1,p/S),f.position.x=h.position.x+C,f.position.z=h.position.z+O,g.position.x=h.position.x-C,g.position.z=h.position.z-O}else return c();else return c();return Promise.resolve(i)}const sy=20,oy={textAnchor:"middle"},Y2={stroke:jt.LINE_MESH_COLOR.selected},ay={strokeWidth:1,stroke:jt.COLORS.black},X2={...ay,stroke:jt.LINE_MESH_COLOR.selected};function J2(n,t,e){let r={name:n,prototype:"lines",info:t,properties:{height:{label:"height",type:"length-measure",defaultValue:{length:300}},thickness:{label:"thickness",type:"length-measure",defaultValue:{length:15,_length:15,_unit:Wr}}},render2D:function(i,s,o){let{x:a,y:l}=s.vertices.get(i.vertices.get(0)),{x:c,y:h}=s.vertices.get(i.vertices.get(1)),f=Oe(a,l,c,h),g=f/5,p=i.getIn(["properties","thickness","length"]),m=p/2,v=m+sy,_=11,A=m+sy+5;return i.selected?w.jsxs("g",{children:[w.jsx("rect",{x:"0",y:-m,width:f,height:p,style:X2}),w.jsx("line",{x1:g,y1:-v,x2:g,y2:v,style:Y2}),w.jsx("text",{x:g,y:A+_,style:oy,children:"A"}),w.jsx("text",{x:g,y:-A,style:oy,children:"B"})]}):w.jsx("rect",{x:"0",y:-m,width:f,height:p,style:ay})},render3D:function(i,s,o){return W2(i,s,o,e)},updateRender3D:(i,s,o,a,l,c,h,f)=>U2(i,s,o,e,a,l,c,h,f)};if(e&&Object.keys(e).length>0){let i={none:"None"};for(let s in e)i[s]=e[s].name;r.properties.textureA={label:"texture A",type:"enum",defaultValue:i.bricks?"bricks":"none",values:i},r.properties.textureB={label:"texture B",type:"enum",defaultValue:i.bricks?"bricks":"none",values:i}}return r}const Z2=(n,t,e,r)=>{let i=new Fm;t&&(n.map=i.load(t.uri),n.needsUpdate=!0,n.map.wrapS=tn,n.map.wrapT=tn,n.map.repeat.set(e*t.lengthRepeatScale,r*t.heightRepeatScale),t.normal&&(n.normalMap=i.load(t.normal.uri),n.normalScale=new yt(t.normal.normalScaleX,t.normal.normalScaleY),n.normalMap.wrapS=tn,n.normalMap.wrapT=tn,n.normalMap.repeat.set(e*t.normal.lengthRepeatScale,r*t.normal.heightRepeatScale)))},K2=n=>{n.computeBoundingBox();let{min:t,max:e}=n.boundingBox,r=new yt(0-t.x,0-t.y),i=new yt(e.x-t.x,e.y-t.y);n.faceVertexUvs[0]=n.faces.map(s=>{let o=n.vertices[s.a],a=n.vertices[s.b],l=n.vertices[s.c];return[new yt((o.x+r.x)/i.x,(o.y+r.y)/i.y),new yt((a.x+r.x)/i.x,(a.y+r.y)/i.y),new yt((l.x+r.x)/i.x,(l.y+r.y)/i.y)]}),n.uvsNeedUpdate=!0};function Q2(n,t,e,r){let i=[];n.vertices.forEach(v=>{i.push(t.vertices.get(v))});let s=n.properties.get("texture"),o=n.properties.get("patternColor");n.selected?o=jt.AREA_MESH_COLOR.selected:s&&s!=="none"&&(o=jt.AREA_MESH_COLOR.unselected);let a=new Gc;a.moveTo(i[0].x,i[0].y);for(let v=1;v<i.length;v++)a.lineTo(i[v].x,i[v].y);let l=new u2({side:tS,color:o});n.holes.forEach(v=>{let _=[];t.getIn(["areas",v,"vertices"]).forEach(A=>{let{x:C,y:O}=t.getIn(["vertices",A]);_.push([C,O])}),_=_.reverse();let S=eM(_);a.holes.push(S)});let c=new Yc(a);K2(c);let h=new Xi().setFromObject(new us(c,new ss)),f=h.max.x-h.min.x,g=h.max.y-h.min.y,p=r[s];Z2(l,p,f,g);let m=new us(c,l);return m.rotation.x-=Math.PI/2,m.name="floor",Promise.resolve(m)}function tM(n,t,e,r,i,s,o,a,l){let c=()=>(a(),l()),h=i.getObjectByName("floor");if(o[0]=="selected"){let f=n.selected?jt.AREA_MESH_COLOR.selected:n.properties.get("patternColor")||jt.AREA_MESH_COLOR.unselected;h.material.color.set(f)}else if(o[0]=="properties"){if(o[1]==="texture")return c()}else return c();return Promise.resolve(i)}const eM=n=>{let t=new Gc;t.moveTo(n[0][0],n[0][1]);for(let e=1;e<n.length;e++)t.lineTo(n[e][0],n[e][1]);return t};function rM(n,t,e){let r={name:n,prototype:"areas",info:{...t,visibility:{catalog:!1,layerElementsVisible:!1}},properties:{patternColor:{label:"color",type:"color",defaultValue:jt.AREA_MESH_COLOR.unselected},thickness:{label:"thickness",type:"length-measure",defaultValue:{length:0,_length:0,_unit:Wr}}},render2D:function(i,s,o){let a="";const l=i.properties.get("texture"),c=e[l],h=[];i.vertices.forEach((C,O)=>{const M=s.vertices.get(C);h.push(M),a+=(O?"L":"M")+M.x+" "+M.y+" "}),i.holes.forEach(C=>{s.areas.get(C).vertices.reverse().forEach((M,z)=>{const R=s.vertices.get(M);a+=(z?"L":"M")+R.x+" "+R.y+" "})});const f=Math.min(...h.map(C=>C.x)),g=Math.max(...h.map(C=>C.x)),p=Math.min(...h.map(C=>C.y)),m=Math.max(...h.map(C=>C.y)),v=g-f,_=m-p;i.properties.get("patternColor"),i.selected;const S=i.selected?jt.AREA_MESH_COLOR.selected:i.properties.get("patternColor"),A=`pattern-${i.id}`;return w.jsxs("g",{children:[w.jsx("defs",{children:c&&w.jsx("pattern",{id:A,patternUnits:"userSpaceOnUse",width:v/(v*c.lengthRepeatScale),height:_/(_*c.heightRepeatScale),x:f,y:p,children:w.jsx("image",{href:c.uri,width:v,height:_,preserveAspectRatio:"none"})})}),w.jsx("path",{d:a,fill:c?`url(#${A})`:S,stroke:i.selected?"#0096fd":"#000",strokeWidth:"2"})]})},render3D:function(i,s,o){return Q2(i,s,o,e)},updateRender3D:(i,s,o,a,l,c,h,f)=>tM(i,s,o,e,a,l,c,h,f)};if(e&&Object.keys(e).length>0){let i={none:"None"};for(let s in e)i[s]=e[s].name;r.properties.texture={label:"texture",type:"enum",defaultValue:"none",values:i}}return r}me.AreaFactory=rM,me.Catalog=f2,me.ReactPlannerLoader=G2,me.WallFactory=J2,me.convertUnits=Cr,me.default=H2,Object.defineProperties(me,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
|