@epigraph/configurator 2.2.3 → 2.2.4

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.
Files changed (2) hide show
  1. package/dist/index.js +12 -12
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@
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 l$6=Symbol.for("react.element"),n$6=Symbol.for("react.portal"),p$8=Symbol.for("react.fragment"),q$6=Symbol.for("react.strict_mode"),r$6=Symbol.for("react.profiler"),t$4=Symbol.for("react.provider"),u$5=Symbol.for("react.context"),v$3=Symbol.for("react.forward_ref"),w$3=Symbol.for("react.suspense"),x$2=Symbol.for("react.memo"),y$3=Symbol.for("react.lazy"),z$3=Symbol.iterator;function A$3(kt){return kt===null||typeof kt!="object"?null:(kt=z$3&&kt[z$3]||kt["@@iterator"],typeof kt=="function"?kt:null)}var B$4={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C$4=Object.assign,D$3={};function E$4(kt,_e,Dt){this.props=kt,this.context=_e,this.refs=D$3,this.updater=Dt||B$4}E$4.prototype.isReactComponent={};E$4.prototype.setState=function(kt,_e){if(typeof kt!="object"&&typeof kt!="function"&&kt!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,kt,_e,"setState")};E$4.prototype.forceUpdate=function(kt){this.updater.enqueueForceUpdate(this,kt,"forceUpdate")};function F$2(){}F$2.prototype=E$4.prototype;function G$4(kt,_e,Dt){this.props=kt,this.context=_e,this.refs=D$3,this.updater=Dt||B$4}var H$4=G$4.prototype=new F$2;H$4.constructor=G$4;C$4(H$4,E$4.prototype);H$4.isPureReactComponent=!0;var I$4=Array.isArray,J$2=Object.prototype.hasOwnProperty,K$3={current:null},L$3={key:!0,ref:!0,__self:!0,__source:!0};function M$3(kt,_e,Dt){var Vt,Gt={},zt=null,jt=null;if(_e!=null)for(Vt in _e.ref!==void 0&&(jt=_e.ref),_e.key!==void 0&&(zt=""+_e.key),_e)J$2.call(_e,Vt)&&!L$3.hasOwnProperty(Vt)&&(Gt[Vt]=_e[Vt]);var Ht=arguments.length-2;if(Ht===1)Gt.children=Dt;else if(1<Ht){for(var Wt=Array(Ht),qt=0;qt<Ht;qt++)Wt[qt]=arguments[qt+2];Gt.children=Wt}if(kt&&kt.defaultProps)for(Vt in Ht=kt.defaultProps,Ht)Gt[Vt]===void 0&&(Gt[Vt]=Ht[Vt]);return{$$typeof:l$6,type:kt,key:zt,ref:jt,props:Gt,_owner:K$3.current}}function N$4(kt,_e){return{$$typeof:l$6,type:kt.type,key:_e,ref:kt.ref,props:kt.props,_owner:kt._owner}}function O$3(kt){return typeof kt=="object"&&kt!==null&&kt.$$typeof===l$6}function escape$1(kt){var _e={"=":"=0",":":"=2"};return"$"+kt.replace(/[=:]/g,function(Dt){return _e[Dt]})}var P$5=/\/+/g;function Q$3(kt,_e){return typeof kt=="object"&&kt!==null&&kt.key!=null?escape$1(""+kt.key):_e.toString(36)}function R$3(kt,_e,Dt,Vt,Gt){var zt=typeof kt;(zt==="undefined"||zt==="boolean")&&(kt=null);var jt=!1;if(kt===null)jt=!0;else switch(zt){case"string":case"number":jt=!0;break;case"object":switch(kt.$$typeof){case l$6:case n$6:jt=!0}}if(jt)return jt=kt,Gt=Gt(jt),kt=Vt===""?"."+Q$3(jt,0):Vt,I$4(Gt)?(Dt="",kt!=null&&(Dt=kt.replace(P$5,"$&/")+"/"),R$3(Gt,_e,Dt,"",function(qt){return qt})):Gt!=null&&(O$3(Gt)&&(Gt=N$4(Gt,Dt+(!Gt.key||jt&&jt.key===Gt.key?"":(""+Gt.key).replace(P$5,"$&/")+"/")+kt)),_e.push(Gt)),1;if(jt=0,Vt=Vt===""?".":Vt+":",I$4(kt))for(var Ht=0;Ht<kt.length;Ht++){zt=kt[Ht];var Wt=Vt+Q$3(zt,Ht);jt+=R$3(zt,_e,Dt,Wt,Gt)}else if(Wt=A$3(kt),typeof Wt=="function")for(kt=Wt.call(kt),Ht=0;!(zt=kt.next()).done;)zt=zt.value,Wt=Vt+Q$3(zt,Ht++),jt+=R$3(zt,_e,Dt,Wt,Gt);else if(zt==="object")throw _e=String(kt),Error("Objects are not valid as a React child (found: "+(_e==="[object Object]"?"object with keys {"+Object.keys(kt).join(", ")+"}":_e)+"). If you meant to render a collection of children, use an array instead.");return jt}function S$4(kt,_e,Dt){if(kt==null)return kt;var Vt=[],Gt=0;return R$3(kt,Vt,"","",function(zt){return _e.call(Dt,zt,Gt++)}),Vt}function T$2(kt){if(kt._status===-1){var _e=kt._result;_e=_e(),_e.then(function(Dt){(kt._status===0||kt._status===-1)&&(kt._status=1,kt._result=Dt)},function(Dt){(kt._status===0||kt._status===-1)&&(kt._status=2,kt._result=Dt)}),kt._status===-1&&(kt._status=0,kt._result=_e)}if(kt._status===1)return kt._result.default;throw kt._result}var U$3={current:null},V$4={transition:null},W$3={ReactCurrentDispatcher:U$3,ReactCurrentBatchConfig:V$4,ReactCurrentOwner:K$3};react_production_min.Children={map:S$4,forEach:function(kt,_e,Dt){S$4(kt,function(){_e.apply(this,arguments)},Dt)},count:function(kt){var _e=0;return S$4(kt,function(){_e++}),_e},toArray:function(kt){return S$4(kt,function(_e){return _e})||[]},only:function(kt){if(!O$3(kt))throw Error("React.Children.only expected to receive a single React element child.");return kt}};react_production_min.Component=E$4;react_production_min.Fragment=p$8;react_production_min.Profiler=r$6;react_production_min.PureComponent=G$4;react_production_min.StrictMode=q$6;react_production_min.Suspense=w$3;react_production_min.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=W$3;react_production_min.cloneElement=function(kt,_e,Dt){if(kt==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+kt+".");var Vt=C$4({},kt.props),Gt=kt.key,zt=kt.ref,jt=kt._owner;if(_e!=null){if(_e.ref!==void 0&&(zt=_e.ref,jt=K$3.current),_e.key!==void 0&&(Gt=""+_e.key),kt.type&&kt.type.defaultProps)var Ht=kt.type.defaultProps;for(Wt in _e)J$2.call(_e,Wt)&&!L$3.hasOwnProperty(Wt)&&(Vt[Wt]=_e[Wt]===void 0&&Ht!==void 0?Ht[Wt]:_e[Wt])}var Wt=arguments.length-2;if(Wt===1)Vt.children=Dt;else if(1<Wt){Ht=Array(Wt);for(var qt=0;qt<Wt;qt++)Ht[qt]=arguments[qt+2];Vt.children=Ht}return{$$typeof:l$6,type:kt.type,key:Gt,ref:zt,props:Vt,_owner:jt}};react_production_min.createContext=function(kt){return kt={$$typeof:u$5,_currentValue:kt,_currentValue2:kt,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},kt.Provider={$$typeof:t$4,_context:kt},kt.Consumer=kt};react_production_min.createElement=M$3;react_production_min.createFactory=function(kt){var _e=M$3.bind(null,kt);return _e.type=kt,_e};react_production_min.createRef=function(){return{current:null}};react_production_min.forwardRef=function(kt){return{$$typeof:v$3,render:kt}};react_production_min.isValidElement=O$3;react_production_min.lazy=function(kt){return{$$typeof:y$3,_payload:{_status:-1,_result:kt},_init:T$2}};react_production_min.memo=function(kt,_e){return{$$typeof:x$2,type:kt,compare:_e===void 0?null:_e}};react_production_min.startTransition=function(kt){var _e=V$4.transition;V$4.transition={};try{kt()}finally{V$4.transition=_e}};react_production_min.unstable_act=function(){throw Error("act(...) is not supported in production builds of React.")};react_production_min.useCallback=function(kt,_e){return U$3.current.useCallback(kt,_e)};react_production_min.useContext=function(kt){return U$3.current.useContext(kt)};react_production_min.useDebugValue=function(){};react_production_min.useDeferredValue=function(kt){return U$3.current.useDeferredValue(kt)};react_production_min.useEffect=function(kt,_e){return U$3.current.useEffect(kt,_e)};react_production_min.useId=function(){return U$3.current.useId()};react_production_min.useImperativeHandle=function(kt,_e,Dt){return U$3.current.useImperativeHandle(kt,_e,Dt)};react_production_min.useInsertionEffect=function(kt,_e){return U$3.current.useInsertionEffect(kt,_e)};react_production_min.useLayoutEffect=function(kt,_e){return U$3.current.useLayoutEffect(kt,_e)};react_production_min.useMemo=function(kt,_e){return U$3.current.useMemo(kt,_e)};react_production_min.useReducer=function(kt,_e,Dt){return U$3.current.useReducer(kt,_e,Dt)};react_production_min.useRef=function(kt){return U$3.current.useRef(kt)};react_production_min.useState=function(kt){return U$3.current.useState(kt)};react_production_min.useSyncExternalStore=function(kt,_e,Dt){return U$3.current.useSyncExternalStore(kt,_e,Dt)};react_production_min.useTransition=function(){return U$3.current.useTransition()};react_production_min.version="18.2.0";react.exports=react_production_min;var reactExports=react.exports;const React=getDefaultExportFromCjs(reactExports);/**
9
+ */var l$6=Symbol.for("react.element"),n$6=Symbol.for("react.portal"),p$8=Symbol.for("react.fragment"),q$7=Symbol.for("react.strict_mode"),r$6=Symbol.for("react.profiler"),t$4=Symbol.for("react.provider"),u$6=Symbol.for("react.context"),v$4=Symbol.for("react.forward_ref"),w$4=Symbol.for("react.suspense"),x$2=Symbol.for("react.memo"),y$3=Symbol.for("react.lazy"),z$3=Symbol.iterator;function A$3(kt){return kt===null||typeof kt!="object"?null:(kt=z$3&&kt[z$3]||kt["@@iterator"],typeof kt=="function"?kt:null)}var B$4={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C$3=Object.assign,D$3={};function E$3(kt,_e,Dt){this.props=kt,this.context=_e,this.refs=D$3,this.updater=Dt||B$4}E$3.prototype.isReactComponent={};E$3.prototype.setState=function(kt,_e){if(typeof kt!="object"&&typeof kt!="function"&&kt!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,kt,_e,"setState")};E$3.prototype.forceUpdate=function(kt){this.updater.enqueueForceUpdate(this,kt,"forceUpdate")};function F$2(){}F$2.prototype=E$3.prototype;function G$4(kt,_e,Dt){this.props=kt,this.context=_e,this.refs=D$3,this.updater=Dt||B$4}var H$4=G$4.prototype=new F$2;H$4.constructor=G$4;C$3(H$4,E$3.prototype);H$4.isPureReactComponent=!0;var I$4=Array.isArray,J$2=Object.prototype.hasOwnProperty,K$3={current:null},L$3={key:!0,ref:!0,__self:!0,__source:!0};function M$3(kt,_e,Dt){var Vt,Gt={},zt=null,jt=null;if(_e!=null)for(Vt in _e.ref!==void 0&&(jt=_e.ref),_e.key!==void 0&&(zt=""+_e.key),_e)J$2.call(_e,Vt)&&!L$3.hasOwnProperty(Vt)&&(Gt[Vt]=_e[Vt]);var Ht=arguments.length-2;if(Ht===1)Gt.children=Dt;else if(1<Ht){for(var Wt=Array(Ht),qt=0;qt<Ht;qt++)Wt[qt]=arguments[qt+2];Gt.children=Wt}if(kt&&kt.defaultProps)for(Vt in Ht=kt.defaultProps,Ht)Gt[Vt]===void 0&&(Gt[Vt]=Ht[Vt]);return{$$typeof:l$6,type:kt,key:zt,ref:jt,props:Gt,_owner:K$3.current}}function N$3(kt,_e){return{$$typeof:l$6,type:kt.type,key:_e,ref:kt.ref,props:kt.props,_owner:kt._owner}}function O$3(kt){return typeof kt=="object"&&kt!==null&&kt.$$typeof===l$6}function escape$1(kt){var _e={"=":"=0",":":"=2"};return"$"+kt.replace(/[=:]/g,function(Dt){return _e[Dt]})}var P$4=/\/+/g;function Q$3(kt,_e){return typeof kt=="object"&&kt!==null&&kt.key!=null?escape$1(""+kt.key):_e.toString(36)}function R$3(kt,_e,Dt,Vt,Gt){var zt=typeof kt;(zt==="undefined"||zt==="boolean")&&(kt=null);var jt=!1;if(kt===null)jt=!0;else switch(zt){case"string":case"number":jt=!0;break;case"object":switch(kt.$$typeof){case l$6:case n$6:jt=!0}}if(jt)return jt=kt,Gt=Gt(jt),kt=Vt===""?"."+Q$3(jt,0):Vt,I$4(Gt)?(Dt="",kt!=null&&(Dt=kt.replace(P$4,"$&/")+"/"),R$3(Gt,_e,Dt,"",function(qt){return qt})):Gt!=null&&(O$3(Gt)&&(Gt=N$3(Gt,Dt+(!Gt.key||jt&&jt.key===Gt.key?"":(""+Gt.key).replace(P$4,"$&/")+"/")+kt)),_e.push(Gt)),1;if(jt=0,Vt=Vt===""?".":Vt+":",I$4(kt))for(var Ht=0;Ht<kt.length;Ht++){zt=kt[Ht];var Wt=Vt+Q$3(zt,Ht);jt+=R$3(zt,_e,Dt,Wt,Gt)}else if(Wt=A$3(kt),typeof Wt=="function")for(kt=Wt.call(kt),Ht=0;!(zt=kt.next()).done;)zt=zt.value,Wt=Vt+Q$3(zt,Ht++),jt+=R$3(zt,_e,Dt,Wt,Gt);else if(zt==="object")throw _e=String(kt),Error("Objects are not valid as a React child (found: "+(_e==="[object Object]"?"object with keys {"+Object.keys(kt).join(", ")+"}":_e)+"). If you meant to render a collection of children, use an array instead.");return jt}function S$5(kt,_e,Dt){if(kt==null)return kt;var Vt=[],Gt=0;return R$3(kt,Vt,"","",function(zt){return _e.call(Dt,zt,Gt++)}),Vt}function T$2(kt){if(kt._status===-1){var _e=kt._result;_e=_e(),_e.then(function(Dt){(kt._status===0||kt._status===-1)&&(kt._status=1,kt._result=Dt)},function(Dt){(kt._status===0||kt._status===-1)&&(kt._status=2,kt._result=Dt)}),kt._status===-1&&(kt._status=0,kt._result=_e)}if(kt._status===1)return kt._result.default;throw kt._result}var U$3={current:null},V$4={transition:null},W$3={ReactCurrentDispatcher:U$3,ReactCurrentBatchConfig:V$4,ReactCurrentOwner:K$3};react_production_min.Children={map:S$5,forEach:function(kt,_e,Dt){S$5(kt,function(){_e.apply(this,arguments)},Dt)},count:function(kt){var _e=0;return S$5(kt,function(){_e++}),_e},toArray:function(kt){return S$5(kt,function(_e){return _e})||[]},only:function(kt){if(!O$3(kt))throw Error("React.Children.only expected to receive a single React element child.");return kt}};react_production_min.Component=E$3;react_production_min.Fragment=p$8;react_production_min.Profiler=r$6;react_production_min.PureComponent=G$4;react_production_min.StrictMode=q$7;react_production_min.Suspense=w$4;react_production_min.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=W$3;react_production_min.cloneElement=function(kt,_e,Dt){if(kt==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+kt+".");var Vt=C$3({},kt.props),Gt=kt.key,zt=kt.ref,jt=kt._owner;if(_e!=null){if(_e.ref!==void 0&&(zt=_e.ref,jt=K$3.current),_e.key!==void 0&&(Gt=""+_e.key),kt.type&&kt.type.defaultProps)var Ht=kt.type.defaultProps;for(Wt in _e)J$2.call(_e,Wt)&&!L$3.hasOwnProperty(Wt)&&(Vt[Wt]=_e[Wt]===void 0&&Ht!==void 0?Ht[Wt]:_e[Wt])}var Wt=arguments.length-2;if(Wt===1)Vt.children=Dt;else if(1<Wt){Ht=Array(Wt);for(var qt=0;qt<Wt;qt++)Ht[qt]=arguments[qt+2];Vt.children=Ht}return{$$typeof:l$6,type:kt.type,key:Gt,ref:zt,props:Vt,_owner:jt}};react_production_min.createContext=function(kt){return kt={$$typeof:u$6,_currentValue:kt,_currentValue2:kt,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},kt.Provider={$$typeof:t$4,_context:kt},kt.Consumer=kt};react_production_min.createElement=M$3;react_production_min.createFactory=function(kt){var _e=M$3.bind(null,kt);return _e.type=kt,_e};react_production_min.createRef=function(){return{current:null}};react_production_min.forwardRef=function(kt){return{$$typeof:v$4,render:kt}};react_production_min.isValidElement=O$3;react_production_min.lazy=function(kt){return{$$typeof:y$3,_payload:{_status:-1,_result:kt},_init:T$2}};react_production_min.memo=function(kt,_e){return{$$typeof:x$2,type:kt,compare:_e===void 0?null:_e}};react_production_min.startTransition=function(kt){var _e=V$4.transition;V$4.transition={};try{kt()}finally{V$4.transition=_e}};react_production_min.unstable_act=function(){throw Error("act(...) is not supported in production builds of React.")};react_production_min.useCallback=function(kt,_e){return U$3.current.useCallback(kt,_e)};react_production_min.useContext=function(kt){return U$3.current.useContext(kt)};react_production_min.useDebugValue=function(){};react_production_min.useDeferredValue=function(kt){return U$3.current.useDeferredValue(kt)};react_production_min.useEffect=function(kt,_e){return U$3.current.useEffect(kt,_e)};react_production_min.useId=function(){return U$3.current.useId()};react_production_min.useImperativeHandle=function(kt,_e,Dt){return U$3.current.useImperativeHandle(kt,_e,Dt)};react_production_min.useInsertionEffect=function(kt,_e){return U$3.current.useInsertionEffect(kt,_e)};react_production_min.useLayoutEffect=function(kt,_e){return U$3.current.useLayoutEffect(kt,_e)};react_production_min.useMemo=function(kt,_e){return U$3.current.useMemo(kt,_e)};react_production_min.useReducer=function(kt,_e,Dt){return U$3.current.useReducer(kt,_e,Dt)};react_production_min.useRef=function(kt){return U$3.current.useRef(kt)};react_production_min.useState=function(kt){return U$3.current.useState(kt)};react_production_min.useSyncExternalStore=function(kt,_e,Dt){return U$3.current.useSyncExternalStore(kt,_e,Dt)};react_production_min.useTransition=function(){return U$3.current.useTransition()};react_production_min.version="18.2.0";react.exports=react_production_min;var reactExports=react.exports;const React=getDefaultExportFromCjs(reactExports);/**
10
10
  * @license React
11
11
  * react-jsx-runtime.production.min.js
12
12
  *
@@ -14,7 +14,7 @@
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 f$5=reactExports,k$3=Symbol.for("react.element"),l$5=Symbol.for("react.fragment"),m$5=Object.prototype.hasOwnProperty,n$5=f$5.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,p$7={key:!0,ref:!0,__self:!0,__source:!0};function q$5(kt,_e,Dt){var Vt,Gt={},zt=null,jt=null;Dt!==void 0&&(zt=""+Dt),_e.key!==void 0&&(zt=""+_e.key),_e.ref!==void 0&&(jt=_e.ref);for(Vt in _e)m$5.call(_e,Vt)&&!p$7.hasOwnProperty(Vt)&&(Gt[Vt]=_e[Vt]);if(kt&&kt.defaultProps)for(Vt in _e=kt.defaultProps,_e)Gt[Vt]===void 0&&(Gt[Vt]=_e[Vt]);return{$$typeof:k$3,type:kt,key:zt,ref:jt,props:Gt,_owner:n$5.current}}reactJsxRuntime_production_min.Fragment=l$5;reactJsxRuntime_production_min.jsx=q$5;reactJsxRuntime_production_min.jsxs=q$5;jsxRuntime.exports=reactJsxRuntime_production_min;var jsxRuntimeExports=jsxRuntime.exports;const addCoreEventListener=(kt,_e,Dt)=>{const Vt=kt.uiSceneStore(zt=>zt.coreWCRef),Gt=reactExports.useCallback(function(zt){Dt(zt.data)},[_e,Dt,Vt]);reactExports.useEffect(()=>{if(Vt)return Vt.addEventListener(_e,Gt),()=>{Vt&&Vt.removeEventListener(_e,Gt)}},[_e,Vt])};var t$3=(kt=>(kt.Release="release",kt.Staging="staging",kt.Dev="dev",kt))(t$3||{});let a$1=class{constructor(_e){this.context="EPIGRAPH-LOGGER",this._allModes={release:{name:"release",allows:["error"]},staging:{name:"staging",allows:["warn","error"]},dev:{name:"dev",allows:["info","warn","error"]}},this._currentMode="release",_e&&(this.context=_e.toLocaleUpperCase())}get modes(){return this._allModes}setCurrentMode(_e){if(!Object.keys(this._allModes).includes(_e)){console.warn(`"${_e}": is not a valid logger mode`);return}this._currentMode=_e}_isLogTypeAllowedInCurrentMode(_e){return this._allModes[this._currentMode].allows.includes(_e)}info({title:_e,details:Dt="",contextOverride:Vt=void 0}){if(!this._isLogTypeAllowedInCurrentMode("info"))return;const Gt=Vt||this.context;console.groupCollapsed(`[${Gt}]: ${_e}`),console.log(Dt),console.groupCollapsed("Traceback..."),console.trace(),console.groupEnd(),console.groupEnd()}warn({title:_e,details:Dt="",contextOverride:Vt=void 0}){if(!this._isLogTypeAllowedInCurrentMode("warn"))return;const Gt=Vt||this.context;console.groupCollapsed(`%c[${Gt}]: ${_e}`,"color: orange;"),console.warn(Dt),console.groupCollapsed("Traceback..."),console.trace(),console.groupEnd(),console.groupEnd()}error({title:_e,details:Dt="",contextOverride:Vt=void 0}){if(!this._isLogTypeAllowedInCurrentMode("error"))return;const Gt=Vt||this.context;console.groupCollapsed(`%c[${Gt}]: ${_e}`,"color: red;"),console.error(Dt),console.groupCollapsed("Traceback..."),console.trace(),console.groupEnd(),console.groupEnd()}table({title:_e,details:Dt={},contextOverride:Vt=void 0,logType:Gt="info"}){if(!this._isLogTypeAllowedInCurrentMode(Gt))return;const zt=Vt||this.context;console.groupCollapsed(`[${zt}]: ${_e}`),console.table(Dt),console.groupCollapsed("Traceback..."),console.trace(),console.groupEnd(),console.groupEnd()}group({title:_e,contextOverride:Dt=void 0,logType:Vt="info"}){if(!this._isLogTypeAllowedInCurrentMode(Vt))return;const Gt=Dt||this.context;console.group(`%c ${Gt} GROUP`,_e)}groupCollapsed({title:_e,contextOverride:Dt=void 0,logType:Vt="info"}){if(!this._isLogTypeAllowedInCurrentMode(Vt))return;const Gt=Dt||this.context;console.groupCollapsed(`%c ${Gt} GROUP`,_e)}groupEnd(){this._isLogTypeAllowedInCurrentMode("info")&&(console.log("----------------------------------"),console.groupEnd())}};var c$7=(kt=>(kt.type="t",kt.identifierType="idt",kt.identifier="id",kt.epigraphSessionId="eid",kt.action="a",kt))(c$7||{});let l$4=class{constructor(_e=window.location.href){this._baseUrl=_e}get baseUrl(){return this._baseUrl}set baseUrl(_e){this._baseUrl=_e}getParameterInUrl(_e){const Dt=new URL(this._baseUrl);let Vt=Dt.searchParams.get(_e);return Vt||(Vt=this.decryptQueryParametersInUrl(Dt).searchParams.get(_e)),Vt}hasParameterInUrl(_e){return!!this.getParameterInUrl(_e)}generateQrCodeUrl(_e={},Dt=!0){const Vt=new URL(this._baseUrl);for(const[Gt,zt]of Object.entries(_e))Vt.searchParams.set(Gt,zt);return Dt&&this.encryptQueryParametersInUrl(Vt),Vt}encryptQueryParametersInUrl(_e){return _e.search=btoa(_e.search),_e}decryptQueryParametersInUrl(_e){let Dt=_e;try{_e.search=atob(_e.search.slice(1)),Dt=_e}catch(Vt){window.epigraph.logger.info({title:`Couldn't decode URL: ${_e}`,details:Vt})}return Dt}};var s$2=(kt=>(kt.DEVELOPMENT="development",kt.STAGING="staging",kt.PRODUCTION="production",kt))(s$2||{});let g$3=class Wp{constructor(_e){if(this._loggerContext="EPIGRAPH",this._isReady=!1,this._logger=new a$1("EPIGRAPH LOGGER"),this._environment=s$2.DEVELOPMENT,this._activeComponentsInSession=new Map,this._staleComponentsInSession=new Map,this._isSessionWebGL2Compatible=!1,window.epigraph)return window.epigraph.registerActiveComponent(_e),window.epigraph;this._isSessionWebGL2Compatible=this._checkIfWebGL2IsAvailable(),window.epigraph=this,window.epigraph.registerActiveComponent(_e),this.logBranding(),this._initializer=_e,this._environment=this._initializer.environment;const Dt=this.getLoggerModeNameFromEnvironment();this._logger.setCurrentMode(Dt),this._urlProcessor=new l$4,this.id=Wp.safeGenerateUuid();const Vt=this._urlProcessor.getParameterInUrl(c$7.epigraphSessionId);this._epigraphSessionId=Vt??Wp.safeGenerateUuid(),this._logger.info({title:"Epigraph Object Ready!!",details:this,contextOverride:this._loggerContext}),this._isReady=!0}get isReady(){return this._isReady}get logger(){return this._logger}get urlProcessor(){return this._urlProcessor}get epigraphSessionId(){return this._epigraphSessionId}get environment(){return this._environment}get initializer(){return this._initializer}get activeComponentsInSession(){return this._activeComponentsInSession}get staleComponentsInSession(){return this._staleComponentsInSession}isSessionWebGL2Compatible(){return this._isSessionWebGL2Compatible}logBranding(){console.group("Powered by: "),console.log("%cEPIGRAPH","font-weight: bold; font-size: 50px; text-shadow: 3px 3px 0 rgb(100,100,100)"),console.log("Visit for more details: www.epigraph.us"),console.groupEnd()}_checkIfWebGL2IsAvailable(){try{const _e=document.createElement("canvas");return!!(window.WebGL2RenderingContext&&_e.getContext("webgl2"))}catch{return!1}}registerActiveComponent(_e){this._activeComponentsInSession.set(_e.uuid,_e),this._logger.info({title:"Registered a new Active Component",details:_e,contextOverride:this._loggerContext})}deregisterActiveComponent(_e){const Dt=this._activeComponentsInSession.get(_e.uuid);Dt&&(this._staleComponentsInSession.set(Dt.uuid,Dt),this._activeComponentsInSession.delete(Dt.uuid),this._logger.info({title:"Deregistered a new Active Component",details:_e,contextOverride:this._loggerContext}))}getLoggerModeNameFromEnvironment(){let _e=t$3.Dev;return this._environment===s$2.STAGING?_e=t$3.Staging:this._environment===s$2.PRODUCTION&&(_e=t$3.Release),_e}static safeGenerateUuid(){let _e="";try{_e=crypto.randomUUID()}catch{console.error("crypto not available. Not generating a UUID")}return _e}static generateXPath(_e){let Dt="",Vt=_e;for(;Vt;){let Gt=1,zt=Vt.previousSibling;for(;zt;)zt.nodeName===Vt.nodeName&&Gt++,zt=zt.previousSibling;Dt=`/${Vt.nodeName.toLowerCase()+(Gt>1?`[${Gt}]`:"")}${Dt}`,Vt=Vt.parentNode}return Dt}};/**
17
+ */var f$5=reactExports,k$3=Symbol.for("react.element"),l$5=Symbol.for("react.fragment"),m$5=Object.prototype.hasOwnProperty,n$5=f$5.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,p$7={key:!0,ref:!0,__self:!0,__source:!0};function q$6(kt,_e,Dt){var Vt,Gt={},zt=null,jt=null;Dt!==void 0&&(zt=""+Dt),_e.key!==void 0&&(zt=""+_e.key),_e.ref!==void 0&&(jt=_e.ref);for(Vt in _e)m$5.call(_e,Vt)&&!p$7.hasOwnProperty(Vt)&&(Gt[Vt]=_e[Vt]);if(kt&&kt.defaultProps)for(Vt in _e=kt.defaultProps,_e)Gt[Vt]===void 0&&(Gt[Vt]=_e[Vt]);return{$$typeof:k$3,type:kt,key:zt,ref:jt,props:Gt,_owner:n$5.current}}reactJsxRuntime_production_min.Fragment=l$5;reactJsxRuntime_production_min.jsx=q$6;reactJsxRuntime_production_min.jsxs=q$6;jsxRuntime.exports=reactJsxRuntime_production_min;var jsxRuntimeExports=jsxRuntime.exports;const addCoreEventListener=(kt,_e,Dt)=>{const Vt=kt.uiSceneStore(zt=>zt.coreWCRef),Gt=reactExports.useCallback(function(zt){Dt(zt.data)},[_e,Dt,Vt]);reactExports.useEffect(()=>{if(Vt)return Vt.addEventListener(_e,Gt),()=>{Vt&&Vt.removeEventListener(_e,Gt)}},[_e,Vt])};var t$3=(kt=>(kt.Release="release",kt.Staging="staging",kt.Dev="dev",kt))(t$3||{});let a$1=class{constructor(_e){this.context="EPIGRAPH-LOGGER",this._allModes={release:{name:"release",allows:["error"]},staging:{name:"staging",allows:["warn","error"]},dev:{name:"dev",allows:["info","warn","error"]}},this._currentMode="release",_e&&(this.context=_e.toLocaleUpperCase())}get modes(){return this._allModes}setCurrentMode(_e){if(!Object.keys(this._allModes).includes(_e)){console.warn(`"${_e}": is not a valid logger mode`);return}this._currentMode=_e}_isLogTypeAllowedInCurrentMode(_e){return this._allModes[this._currentMode].allows.includes(_e)}info({title:_e,details:Dt="",contextOverride:Vt=void 0}){if(!this._isLogTypeAllowedInCurrentMode("info"))return;const Gt=Vt||this.context;console.groupCollapsed(`[${Gt}]: ${_e}`),console.log(Dt),console.groupCollapsed("Traceback..."),console.trace(),console.groupEnd(),console.groupEnd()}warn({title:_e,details:Dt="",contextOverride:Vt=void 0}){if(!this._isLogTypeAllowedInCurrentMode("warn"))return;const Gt=Vt||this.context;console.groupCollapsed(`%c[${Gt}]: ${_e}`,"color: orange;"),console.warn(Dt),console.groupCollapsed("Traceback..."),console.trace(),console.groupEnd(),console.groupEnd()}error({title:_e,details:Dt="",contextOverride:Vt=void 0}){if(!this._isLogTypeAllowedInCurrentMode("error"))return;const Gt=Vt||this.context;console.groupCollapsed(`%c[${Gt}]: ${_e}`,"color: red;"),console.error(Dt),console.groupCollapsed("Traceback..."),console.trace(),console.groupEnd(),console.groupEnd()}table({title:_e,details:Dt={},contextOverride:Vt=void 0,logType:Gt="info"}){if(!this._isLogTypeAllowedInCurrentMode(Gt))return;const zt=Vt||this.context;console.groupCollapsed(`[${zt}]: ${_e}`),console.table(Dt),console.groupCollapsed("Traceback..."),console.trace(),console.groupEnd(),console.groupEnd()}group({title:_e,contextOverride:Dt=void 0,logType:Vt="info"}){if(!this._isLogTypeAllowedInCurrentMode(Vt))return;const Gt=Dt||this.context;console.group(`%c ${Gt} GROUP`,_e)}groupCollapsed({title:_e,contextOverride:Dt=void 0,logType:Vt="info"}){if(!this._isLogTypeAllowedInCurrentMode(Vt))return;const Gt=Dt||this.context;console.groupCollapsed(`%c ${Gt} GROUP`,_e)}groupEnd(){this._isLogTypeAllowedInCurrentMode("info")&&(console.log("----------------------------------"),console.groupEnd())}};var c$7=(kt=>(kt.type="t",kt.identifierType="idt",kt.identifier="id",kt.epigraphSessionId="eid",kt.action="a",kt))(c$7||{});let l$4=class{constructor(_e=window.location.href){this._baseUrl=_e}get baseUrl(){return this._baseUrl}set baseUrl(_e){this._baseUrl=_e}getParameterInUrl(_e){const Dt=new URL(this._baseUrl);let Vt=Dt.searchParams.get(_e);return Vt||(Vt=this.decryptQueryParametersInUrl(Dt).searchParams.get(_e)),Vt}hasParameterInUrl(_e){return!!this.getParameterInUrl(_e)}generateQrCodeUrl(_e={},Dt=!0){const Vt=new URL(this._baseUrl);for(const[Gt,zt]of Object.entries(_e))Vt.searchParams.set(Gt,zt);return Dt&&this.encryptQueryParametersInUrl(Vt),Vt}encryptQueryParametersInUrl(_e){return _e.search=btoa(_e.search),_e}decryptQueryParametersInUrl(_e){let Dt=_e;try{_e.search=atob(_e.search.slice(1)),Dt=_e}catch(Vt){window.epigraph.logger.info({title:`Couldn't decode URL: ${_e}`,details:Vt})}return Dt}};var s$2=(kt=>(kt.DEVELOPMENT="development",kt.STAGING="staging",kt.PRODUCTION="production",kt))(s$2||{});let g$3=class Wp{constructor(_e){if(this._loggerContext="EPIGRAPH",this._isReady=!1,this._logger=new a$1("EPIGRAPH LOGGER"),this._environment=s$2.DEVELOPMENT,this._activeComponentsInSession=new Map,this._staleComponentsInSession=new Map,this._isSessionWebGL2Compatible=!1,window.epigraph)return window.epigraph.registerActiveComponent(_e),window.epigraph;this._isSessionWebGL2Compatible=this._checkIfWebGL2IsAvailable(),window.epigraph=this,window.epigraph.registerActiveComponent(_e),this.logBranding(),this._initializer=_e,this._environment=this._initializer.environment;const Dt=this.getLoggerModeNameFromEnvironment();this._logger.setCurrentMode(Dt),this._urlProcessor=new l$4,this.id=Wp.safeGenerateUuid();const Vt=this._urlProcessor.getParameterInUrl(c$7.epigraphSessionId);this._epigraphSessionId=Vt??Wp.safeGenerateUuid(),this._logger.info({title:"Epigraph Object Ready!!",details:this,contextOverride:this._loggerContext}),this._isReady=!0}get isReady(){return this._isReady}get logger(){return this._logger}get urlProcessor(){return this._urlProcessor}get epigraphSessionId(){return this._epigraphSessionId}get environment(){return this._environment}get initializer(){return this._initializer}get activeComponentsInSession(){return this._activeComponentsInSession}get staleComponentsInSession(){return this._staleComponentsInSession}isSessionWebGL2Compatible(){return this._isSessionWebGL2Compatible}logBranding(){console.group("Powered by: "),console.log("%cEPIGRAPH","font-weight: bold; font-size: 50px; text-shadow: 3px 3px 0 rgb(100,100,100)"),console.log("Visit for more details: www.epigraph.us"),console.groupEnd()}_checkIfWebGL2IsAvailable(){try{const _e=document.createElement("canvas");return!!(window.WebGL2RenderingContext&&_e.getContext("webgl2"))}catch{return!1}}registerActiveComponent(_e){this._activeComponentsInSession.set(_e.uuid,_e),this._logger.info({title:"Registered a new Active Component",details:_e,contextOverride:this._loggerContext})}deregisterActiveComponent(_e){const Dt=this._activeComponentsInSession.get(_e.uuid);Dt&&(this._staleComponentsInSession.set(Dt.uuid,Dt),this._activeComponentsInSession.delete(Dt.uuid),this._logger.info({title:"Deregistered a new Active Component",details:_e,contextOverride:this._loggerContext}))}getLoggerModeNameFromEnvironment(){let _e=t$3.Dev;return this._environment===s$2.STAGING?_e=t$3.Staging:this._environment===s$2.PRODUCTION&&(_e=t$3.Release),_e}static safeGenerateUuid(){let _e="";try{_e=crypto.randomUUID()}catch{console.error("crypto not available. Not generating a UUID")}return _e}static generateXPath(_e){let Dt="",Vt=_e;for(;Vt;){let Gt=1,zt=Vt.previousSibling;for(;zt;)zt.nodeName===Vt.nodeName&&Gt++,zt=zt.previousSibling;Dt=`/${Vt.nodeName.toLowerCase()+(Gt>1?`[${Gt}]`:"")}${Dt}`,Vt=Vt.parentNode}return Dt}};/**
18
18
  * @license
19
19
  * Copyright 2019 Google LLC
20
20
  * SPDX-License-Identifier: BSD-3-Clause
@@ -22,17 +22,17 @@
22
22
  * @license
23
23
  * Copyright 2017 Google LLC
24
24
  * SPDX-License-Identifier: BSD-3-Clause
25
- */const{is:nt$1,defineProperty:ot$1,getOwnPropertyDescriptor:ht$1,getOwnPropertyNames:at$1,getOwnPropertySymbols:lt$1,getPrototypeOf:ct$1}=Object,M$2=globalThis,V$3=M$2.trustedTypes,dt$1=V$3?V$3.emptyScript:"",pt$1=M$2.reactiveElementPolyfillSupport,S$3=(kt,_e)=>kt,R$2={toAttribute(kt,_e){switch(_e){case Boolean:kt=kt?dt$1:null;break;case Object:case Array:kt=kt==null?kt:JSON.stringify(kt)}return kt},fromAttribute(kt,_e){let Dt=kt;switch(_e){case Boolean:Dt=kt!==null;break;case Number:Dt=kt===null?null:Number(kt);break;case Object:case Array:try{Dt=JSON.parse(kt)}catch{Dt=null}}return Dt}},X$3=(kt,_e)=>!nt$1(kt,_e),W$2={attribute:!0,type:String,converter:R$2,reflect:!1,useDefault:!1,hasChanged:X$3};Symbol.metadata??=Symbol("metadata"),M$2.litPropertyMetadata??=new WeakMap;let y$2=class extends HTMLElement{static addInitializer(_e){this._$Ei(),(this.l??=[]).push(_e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(_e,Dt=W$2){if(Dt.state&&(Dt.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(_e)&&((Dt=Object.create(Dt)).wrapped=!0),this.elementProperties.set(_e,Dt),!Dt.noAccessor){const Vt=Symbol(),Gt=this.getPropertyDescriptor(_e,Vt,Dt);Gt!==void 0&&ot$1(this.prototype,_e,Gt)}}static getPropertyDescriptor(_e,Dt,Vt){const{get:Gt,set:zt}=ht$1(this.prototype,_e)??{get(){return this[Dt]},set(jt){this[Dt]=jt}};return{get:Gt,set(jt){const Ht=Gt?.call(this);zt?.call(this,jt),this.requestUpdate(_e,Ht,Vt)},configurable:!0,enumerable:!0}}static getPropertyOptions(_e){return this.elementProperties.get(_e)??W$2}static _$Ei(){if(this.hasOwnProperty(S$3("elementProperties")))return;const _e=ct$1(this);_e.finalize(),_e.l!==void 0&&(this.l=[..._e.l]),this.elementProperties=new Map(_e.elementProperties)}static finalize(){if(this.hasOwnProperty(S$3("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(S$3("properties"))){const Dt=this.properties,Vt=[...at$1(Dt),...lt$1(Dt)];for(const Gt of Vt)this.createProperty(Gt,Dt[Gt])}const _e=this[Symbol.metadata];if(_e!==null){const Dt=litPropertyMetadata.get(_e);if(Dt!==void 0)for(const[Vt,Gt]of Dt)this.elementProperties.set(Vt,Gt)}this._$Eh=new Map;for(const[Dt,Vt]of this.elementProperties){const Gt=this._$Eu(Dt,Vt);Gt!==void 0&&this._$Eh.set(Gt,Dt)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(_e){const Dt=[];if(Array.isArray(_e)){const Vt=new Set(_e.flat(1/0).reverse());for(const Gt of Vt)Dt.unshift(I$3(Gt))}else _e!==void 0&&Dt.push(I$3(_e));return Dt}static _$Eu(_e,Dt){const Vt=Dt.attribute;return Vt===!1?void 0:typeof Vt=="string"?Vt:typeof _e=="string"?_e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(_e=>this.enableUpdating=_e),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(_e=>_e(this))}addController(_e){(this._$EO??=new Set).add(_e),this.renderRoot!==void 0&&this.isConnected&&_e.hostConnected?.()}removeController(_e){this._$EO?.delete(_e)}_$E_(){const _e=new Map,Dt=this.constructor.elementProperties;for(const Vt of Dt.keys())this.hasOwnProperty(Vt)&&(_e.set(Vt,this[Vt]),delete this[Vt]);_e.size>0&&(this._$Ep=_e)}createRenderRoot(){const _e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return rt$1(_e,this.constructor.elementStyles),_e}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(_e=>_e.hostConnected?.())}enableUpdating(_e){}disconnectedCallback(){this._$EO?.forEach(_e=>_e.hostDisconnected?.())}attributeChangedCallback(_e,Dt,Vt){this._$AK(_e,Vt)}_$ET(_e,Dt){const Vt=this.constructor.elementProperties.get(_e),Gt=this.constructor._$Eu(_e,Vt);if(Gt!==void 0&&Vt.reflect===!0){const zt=(Vt.converter?.toAttribute!==void 0?Vt.converter:R$2).toAttribute(Dt,Vt.type);this._$Em=_e,zt==null?this.removeAttribute(Gt):this.setAttribute(Gt,zt),this._$Em=null}}_$AK(_e,Dt){const Vt=this.constructor,Gt=Vt._$Eh.get(_e);if(Gt!==void 0&&this._$Em!==Gt){const zt=Vt.getPropertyOptions(Gt),jt=typeof zt.converter=="function"?{fromAttribute:zt.converter}:zt.converter?.fromAttribute!==void 0?zt.converter:R$2;this._$Em=Gt,this[Gt]=jt.fromAttribute(Dt,zt.type)??this._$Ej?.get(Gt)??null,this._$Em=null}}requestUpdate(_e,Dt,Vt){if(_e!==void 0){const Gt=this.constructor,zt=this[_e];if(Vt??=Gt.getPropertyOptions(_e),!((Vt.hasChanged??X$3)(zt,Dt)||Vt.useDefault&&Vt.reflect&&zt===this._$Ej?.get(_e)&&!this.hasAttribute(Gt._$Eu(_e,Vt))))return;this.C(_e,Dt,Vt)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(_e,Dt,{useDefault:Vt,reflect:Gt,wrapped:zt},jt){Vt&&!(this._$Ej??=new Map).has(_e)&&(this._$Ej.set(_e,jt??Dt??this[_e]),zt!==!0||jt!==void 0)||(this._$AL.has(_e)||(this.hasUpdated||Vt||(Dt=void 0),this._$AL.set(_e,Dt)),Gt===!0&&this._$Em!==_e&&(this._$Eq??=new Set).add(_e))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(Dt){Promise.reject(Dt)}const _e=this.scheduleUpdate();return _e!=null&&await _e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[Gt,zt]of this._$Ep)this[Gt]=zt;this._$Ep=void 0}const Vt=this.constructor.elementProperties;if(Vt.size>0)for(const[Gt,zt]of Vt){const{wrapped:jt}=zt,Ht=this[Gt];jt!==!0||this._$AL.has(Gt)||Ht===void 0||this.C(Gt,void 0,zt,Ht)}}let _e=!1;const Dt=this._$AL;try{_e=this.shouldUpdate(Dt),_e?(this.willUpdate(Dt),this._$EO?.forEach(Vt=>Vt.hostUpdate?.()),this.update(Dt)):this._$EM()}catch(Vt){throw _e=!1,this._$EM(),Vt}_e&&this._$AE(Dt)}willUpdate(_e){}_$AE(_e){this._$EO?.forEach(Dt=>Dt.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(_e)),this.updated(_e)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(_e){return!0}update(_e){this._$Eq&&=this._$Eq.forEach(Dt=>this._$ET(Dt,this[Dt])),this._$EM()}updated(_e){}firstUpdated(_e){}};y$2.elementStyles=[],y$2.shadowRootOptions={mode:"open"},y$2[S$3("elementProperties")]=new Map,y$2[S$3("finalized")]=new Map,pt$1?.({ReactiveElement:y$2}),(M$2.reactiveElementVersions??=[]).push("2.1.0");/**
25
+ */const{is:nt$1,defineProperty:ot$1,getOwnPropertyDescriptor:ht$1,getOwnPropertyNames:at$1,getOwnPropertySymbols:lt$1,getPrototypeOf:ct$1}=Object,M$2=globalThis,V$3=M$2.trustedTypes,dt$1=V$3?V$3.emptyScript:"",pt$1=M$2.reactiveElementPolyfillSupport,S$4=(kt,_e)=>kt,R$2={toAttribute(kt,_e){switch(_e){case Boolean:kt=kt?dt$1:null;break;case Object:case Array:kt=kt==null?kt:JSON.stringify(kt)}return kt},fromAttribute(kt,_e){let Dt=kt;switch(_e){case Boolean:Dt=kt!==null;break;case Number:Dt=kt===null?null:Number(kt);break;case Object:case Array:try{Dt=JSON.parse(kt)}catch{Dt=null}}return Dt}},X$2=(kt,_e)=>!nt$1(kt,_e),W$2={attribute:!0,type:String,converter:R$2,reflect:!1,useDefault:!1,hasChanged:X$2};Symbol.metadata??=Symbol("metadata"),M$2.litPropertyMetadata??=new WeakMap;let y$2=class extends HTMLElement{static addInitializer(_e){this._$Ei(),(this.l??=[]).push(_e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(_e,Dt=W$2){if(Dt.state&&(Dt.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(_e)&&((Dt=Object.create(Dt)).wrapped=!0),this.elementProperties.set(_e,Dt),!Dt.noAccessor){const Vt=Symbol(),Gt=this.getPropertyDescriptor(_e,Vt,Dt);Gt!==void 0&&ot$1(this.prototype,_e,Gt)}}static getPropertyDescriptor(_e,Dt,Vt){const{get:Gt,set:zt}=ht$1(this.prototype,_e)??{get(){return this[Dt]},set(jt){this[Dt]=jt}};return{get:Gt,set(jt){const Ht=Gt?.call(this);zt?.call(this,jt),this.requestUpdate(_e,Ht,Vt)},configurable:!0,enumerable:!0}}static getPropertyOptions(_e){return this.elementProperties.get(_e)??W$2}static _$Ei(){if(this.hasOwnProperty(S$4("elementProperties")))return;const _e=ct$1(this);_e.finalize(),_e.l!==void 0&&(this.l=[..._e.l]),this.elementProperties=new Map(_e.elementProperties)}static finalize(){if(this.hasOwnProperty(S$4("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(S$4("properties"))){const Dt=this.properties,Vt=[...at$1(Dt),...lt$1(Dt)];for(const Gt of Vt)this.createProperty(Gt,Dt[Gt])}const _e=this[Symbol.metadata];if(_e!==null){const Dt=litPropertyMetadata.get(_e);if(Dt!==void 0)for(const[Vt,Gt]of Dt)this.elementProperties.set(Vt,Gt)}this._$Eh=new Map;for(const[Dt,Vt]of this.elementProperties){const Gt=this._$Eu(Dt,Vt);Gt!==void 0&&this._$Eh.set(Gt,Dt)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(_e){const Dt=[];if(Array.isArray(_e)){const Vt=new Set(_e.flat(1/0).reverse());for(const Gt of Vt)Dt.unshift(I$3(Gt))}else _e!==void 0&&Dt.push(I$3(_e));return Dt}static _$Eu(_e,Dt){const Vt=Dt.attribute;return Vt===!1?void 0:typeof Vt=="string"?Vt:typeof _e=="string"?_e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(_e=>this.enableUpdating=_e),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(_e=>_e(this))}addController(_e){(this._$EO??=new Set).add(_e),this.renderRoot!==void 0&&this.isConnected&&_e.hostConnected?.()}removeController(_e){this._$EO?.delete(_e)}_$E_(){const _e=new Map,Dt=this.constructor.elementProperties;for(const Vt of Dt.keys())this.hasOwnProperty(Vt)&&(_e.set(Vt,this[Vt]),delete this[Vt]);_e.size>0&&(this._$Ep=_e)}createRenderRoot(){const _e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return rt$1(_e,this.constructor.elementStyles),_e}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(_e=>_e.hostConnected?.())}enableUpdating(_e){}disconnectedCallback(){this._$EO?.forEach(_e=>_e.hostDisconnected?.())}attributeChangedCallback(_e,Dt,Vt){this._$AK(_e,Vt)}_$ET(_e,Dt){const Vt=this.constructor.elementProperties.get(_e),Gt=this.constructor._$Eu(_e,Vt);if(Gt!==void 0&&Vt.reflect===!0){const zt=(Vt.converter?.toAttribute!==void 0?Vt.converter:R$2).toAttribute(Dt,Vt.type);this._$Em=_e,zt==null?this.removeAttribute(Gt):this.setAttribute(Gt,zt),this._$Em=null}}_$AK(_e,Dt){const Vt=this.constructor,Gt=Vt._$Eh.get(_e);if(Gt!==void 0&&this._$Em!==Gt){const zt=Vt.getPropertyOptions(Gt),jt=typeof zt.converter=="function"?{fromAttribute:zt.converter}:zt.converter?.fromAttribute!==void 0?zt.converter:R$2;this._$Em=Gt,this[Gt]=jt.fromAttribute(Dt,zt.type)??this._$Ej?.get(Gt)??null,this._$Em=null}}requestUpdate(_e,Dt,Vt){if(_e!==void 0){const Gt=this.constructor,zt=this[_e];if(Vt??=Gt.getPropertyOptions(_e),!((Vt.hasChanged??X$2)(zt,Dt)||Vt.useDefault&&Vt.reflect&&zt===this._$Ej?.get(_e)&&!this.hasAttribute(Gt._$Eu(_e,Vt))))return;this.C(_e,Dt,Vt)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(_e,Dt,{useDefault:Vt,reflect:Gt,wrapped:zt},jt){Vt&&!(this._$Ej??=new Map).has(_e)&&(this._$Ej.set(_e,jt??Dt??this[_e]),zt!==!0||jt!==void 0)||(this._$AL.has(_e)||(this.hasUpdated||Vt||(Dt=void 0),this._$AL.set(_e,Dt)),Gt===!0&&this._$Em!==_e&&(this._$Eq??=new Set).add(_e))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(Dt){Promise.reject(Dt)}const _e=this.scheduleUpdate();return _e!=null&&await _e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[Gt,zt]of this._$Ep)this[Gt]=zt;this._$Ep=void 0}const Vt=this.constructor.elementProperties;if(Vt.size>0)for(const[Gt,zt]of Vt){const{wrapped:jt}=zt,Ht=this[Gt];jt!==!0||this._$AL.has(Gt)||Ht===void 0||this.C(Gt,void 0,zt,Ht)}}let _e=!1;const Dt=this._$AL;try{_e=this.shouldUpdate(Dt),_e?(this.willUpdate(Dt),this._$EO?.forEach(Vt=>Vt.hostUpdate?.()),this.update(Dt)):this._$EM()}catch(Vt){throw _e=!1,this._$EM(),Vt}_e&&this._$AE(Dt)}willUpdate(_e){}_$AE(_e){this._$EO?.forEach(Dt=>Dt.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(_e)),this.updated(_e)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(_e){return!0}update(_e){this._$Eq&&=this._$Eq.forEach(Dt=>this._$ET(Dt,this[Dt])),this._$EM()}updated(_e){}firstUpdated(_e){}};y$2.elementStyles=[],y$2.shadowRootOptions={mode:"open"},y$2[S$4("elementProperties")]=new Map,y$2[S$4("finalized")]=new Map,pt$1?.({ReactiveElement:y$2}),(M$2.reactiveElementVersions??=[]).push("2.1.0");/**
26
26
  * @license
27
27
  * Copyright 2017 Google LLC
28
28
  * SPDX-License-Identifier: BSD-3-Clause
29
- */const L$2=globalThis,H$3=L$2.trustedTypes,q$4=H$3?H$3.createPolicy("lit-html",{createHTML:kt=>kt}):void 0,Y$2="$lit$",_$2=`lit$${Math.random().toFixed(9).slice(2)}$`,tt$1="?"+_$2,ut$1=`<${tt$1}>`,m$4=document,b$1=()=>m$4.createComment(""),w$2=kt=>kt===null||typeof kt!="object"&&typeof kt!="function",j$1=Array.isArray,$t=kt=>j$1(kt)||typeof kt?.[Symbol.iterator]=="function",N$3=`[
30
- \f\r]`,E$3=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,J$1=/-->/g,K$2=/>/g,f$4=RegExp(`>|${N$3}(?:([^\\s"'>=/]+)(${N$3}*=${N$3}*(?:[^
31
- \f\r"'\`<>=]|("|')|))|$)`,"g"),Z$3=/'/g,F$1=/"/g,et$3=/^(?:script|style|textarea|title)$/i,_t$1=kt=>(_e,...Dt)=>({_$litType$:kt,strings:_e,values:Dt}),xt$1=_t$1(1),g$2=Symbol.for("lit-noChange"),c$6=Symbol.for("lit-nothing"),G$3=new WeakMap,A$2=m$4.createTreeWalker(m$4,129);function st$1(kt,_e){if(!j$1(kt)||!kt.hasOwnProperty("raw"))throw Error("invalid template strings array");return q$4!==void 0?q$4.createHTML(_e):_e}const ft$1=(kt,_e)=>{const Dt=kt.length-1,Vt=[];let Gt,zt=_e===2?"<svg>":_e===3?"<math>":"",jt=E$3;for(let Ht=0;Ht<Dt;Ht++){const Wt=kt[Ht];let qt,Xt,Kt=-1,Yt=0;for(;Yt<Wt.length&&(jt.lastIndex=Yt,Xt=jt.exec(Wt),Xt!==null);)Yt=jt.lastIndex,jt===E$3?Xt[1]==="!--"?jt=J$1:Xt[1]!==void 0?jt=K$2:Xt[2]!==void 0?(et$3.test(Xt[2])&&(Gt=RegExp("</"+Xt[2],"g")),jt=f$4):Xt[3]!==void 0&&(jt=f$4):jt===f$4?Xt[0]===">"?(jt=Gt??E$3,Kt=-1):Xt[1]===void 0?Kt=-2:(Kt=jt.lastIndex-Xt[2].length,qt=Xt[1],jt=Xt[3]===void 0?f$4:Xt[3]==='"'?F$1:Z$3):jt===F$1||jt===Z$3?jt=f$4:jt===J$1||jt===K$2?jt=E$3:(jt=f$4,Gt=void 0);const Zt=jt===f$4&&kt[Ht+1].startsWith("/>")?" ":"";zt+=jt===E$3?Wt+ut$1:Kt>=0?(Vt.push(qt),Wt.slice(0,Kt)+Y$2+Wt.slice(Kt)+_$2+Zt):Wt+_$2+(Kt===-2?Ht:Zt)}return[st$1(kt,zt+(kt[Dt]||"<?>")+(_e===2?"</svg>":_e===3?"</math>":"")),Vt]};let C$3=class Tv{constructor({strings:_e,_$litType$:Dt},Vt){let Gt;this.parts=[];let zt=0,jt=0;const Ht=_e.length-1,Wt=this.parts,[qt,Xt]=ft$1(_e,Dt);if(this.el=Tv.createElement(qt,Vt),A$2.currentNode=this.el.content,Dt===2||Dt===3){const Kt=this.el.content.firstChild;Kt.replaceWith(...Kt.childNodes)}for(;(Gt=A$2.nextNode())!==null&&Wt.length<Ht;){if(Gt.nodeType===1){if(Gt.hasAttributes())for(const Kt of Gt.getAttributeNames())if(Kt.endsWith(Y$2)){const Yt=Xt[jt++],Zt=Gt.getAttribute(Kt).split(_$2),Jt=/([.?@])?(.*)/.exec(Yt);Wt.push({type:1,index:zt,name:Jt[2],strings:Zt,ctor:Jt[1]==="."?mt$1:Jt[1]==="?"?yt$1:Jt[1]==="@"?gt$1:T$1}),Gt.removeAttribute(Kt)}else Kt.startsWith(_$2)&&(Wt.push({type:6,index:zt}),Gt.removeAttribute(Kt));if(et$3.test(Gt.tagName)){const Kt=Gt.textContent.split(_$2),Yt=Kt.length-1;if(Yt>0){Gt.textContent=H$3?H$3.emptyScript:"";for(let Zt=0;Zt<Yt;Zt++)Gt.append(Kt[Zt],b$1()),A$2.nextNode(),Wt.push({type:2,index:++zt});Gt.append(Kt[Yt],b$1())}}}else if(Gt.nodeType===8)if(Gt.data===tt$1)Wt.push({type:2,index:zt});else{let Kt=-1;for(;(Kt=Gt.data.indexOf(_$2,Kt+1))!==-1;)Wt.push({type:7,index:zt}),Kt+=_$2.length-1}zt++}}static createElement(_e,Dt){const Vt=m$4.createElement("template");return Vt.innerHTML=_e,Vt}};function v$2(kt,_e,Dt=kt,Vt){if(_e===g$2)return _e;let Gt=Vt!==void 0?Dt._$Co?.[Vt]:Dt._$Cl;const zt=w$2(_e)?void 0:_e._$litDirective$;return Gt?.constructor!==zt&&(Gt?._$AO?.(!1),zt===void 0?Gt=void 0:(Gt=new zt(kt),Gt._$AT(kt,Dt,Vt)),Vt!==void 0?(Dt._$Co??=[])[Vt]=Gt:Dt._$Cl=Gt),Gt!==void 0&&(_e=v$2(kt,Gt._$AS(kt,_e.values),Gt,Vt)),_e}let At$1=class{constructor(_e,Dt){this._$AV=[],this._$AN=void 0,this._$AD=_e,this._$AM=Dt}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(_e){const{el:{content:Dt},parts:Vt}=this._$AD,Gt=(_e?.creationScope??m$4).importNode(Dt,!0);A$2.currentNode=Gt;let zt=A$2.nextNode(),jt=0,Ht=0,Wt=Vt[0];for(;Wt!==void 0;){if(jt===Wt.index){let qt;Wt.type===2?qt=new P$4(zt,zt.nextSibling,this,_e):Wt.type===1?qt=new Wt.ctor(zt,Wt.name,Wt.strings,this,_e):Wt.type===6&&(qt=new vt$1(zt,this,_e)),this._$AV.push(qt),Wt=Vt[++Ht]}jt!==Wt?.index&&(zt=A$2.nextNode(),jt++)}return A$2.currentNode=m$4,Gt}p(_e){let Dt=0;for(const Vt of this._$AV)Vt!==void 0&&(Vt.strings!==void 0?(Vt._$AI(_e,Vt,Dt),Dt+=Vt.strings.length-2):Vt._$AI(_e[Dt])),Dt++}},P$4=class wv{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(_e,Dt,Vt,Gt){this.type=2,this._$AH=c$6,this._$AN=void 0,this._$AA=_e,this._$AB=Dt,this._$AM=Vt,this.options=Gt,this._$Cv=Gt?.isConnected??!0}get parentNode(){let _e=this._$AA.parentNode;const Dt=this._$AM;return Dt!==void 0&&_e?.nodeType===11&&(_e=Dt.parentNode),_e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(_e,Dt=this){_e=v$2(this,_e,Dt),w$2(_e)?_e===c$6||_e==null||_e===""?(this._$AH!==c$6&&this._$AR(),this._$AH=c$6):_e!==this._$AH&&_e!==g$2&&this._(_e):_e._$litType$!==void 0?this.$(_e):_e.nodeType!==void 0?this.T(_e):$t(_e)?this.k(_e):this._(_e)}O(_e){return this._$AA.parentNode.insertBefore(_e,this._$AB)}T(_e){this._$AH!==_e&&(this._$AR(),this._$AH=this.O(_e))}_(_e){this._$AH!==c$6&&w$2(this._$AH)?this._$AA.nextSibling.data=_e:this.T(m$4.createTextNode(_e)),this._$AH=_e}$(_e){const{values:Dt,_$litType$:Vt}=_e,Gt=typeof Vt=="number"?this._$AC(_e):(Vt.el===void 0&&(Vt.el=C$3.createElement(st$1(Vt.h,Vt.h[0]),this.options)),Vt);if(this._$AH?._$AD===Gt)this._$AH.p(Dt);else{const zt=new At$1(Gt,this),jt=zt.u(this.options);zt.p(Dt),this.T(jt),this._$AH=zt}}_$AC(_e){let Dt=G$3.get(_e.strings);return Dt===void 0&&G$3.set(_e.strings,Dt=new C$3(_e)),Dt}k(_e){j$1(this._$AH)||(this._$AH=[],this._$AR());const Dt=this._$AH;let Vt,Gt=0;for(const zt of _e)Gt===Dt.length?Dt.push(Vt=new wv(this.O(b$1()),this.O(b$1()),this,this.options)):Vt=Dt[Gt],Vt._$AI(zt),Gt++;Gt<Dt.length&&(this._$AR(Vt&&Vt._$AB.nextSibling,Gt),Dt.length=Gt)}_$AR(_e=this._$AA.nextSibling,Dt){for(this._$AP?.(!1,!0,Dt);_e&&_e!==this._$AB;){const Vt=_e.nextSibling;_e.remove(),_e=Vt}}setConnected(_e){this._$AM===void 0&&(this._$Cv=_e,this._$AP?.(_e))}},T$1=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(_e,Dt,Vt,Gt,zt){this.type=1,this._$AH=c$6,this._$AN=void 0,this.element=_e,this.name=Dt,this._$AM=Gt,this.options=zt,Vt.length>2||Vt[0]!==""||Vt[1]!==""?(this._$AH=Array(Vt.length-1).fill(new String),this.strings=Vt):this._$AH=c$6}_$AI(_e,Dt=this,Vt,Gt){const zt=this.strings;let jt=!1;if(zt===void 0)_e=v$2(this,_e,Dt,0),jt=!w$2(_e)||_e!==this._$AH&&_e!==g$2,jt&&(this._$AH=_e);else{const Ht=_e;let Wt,qt;for(_e=zt[0],Wt=0;Wt<zt.length-1;Wt++)qt=v$2(this,Ht[Vt+Wt],Dt,Wt),qt===g$2&&(qt=this._$AH[Wt]),jt||=!w$2(qt)||qt!==this._$AH[Wt],qt===c$6?_e=c$6:_e!==c$6&&(_e+=(qt??"")+zt[Wt+1]),this._$AH[Wt]=qt}jt&&!Gt&&this.j(_e)}j(_e){_e===c$6?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,_e??"")}},mt$1=class extends T$1{constructor(){super(...arguments),this.type=3}j(_e){this.element[this.name]=_e===c$6?void 0:_e}},yt$1=class extends T$1{constructor(){super(...arguments),this.type=4}j(_e){this.element.toggleAttribute(this.name,!!_e&&_e!==c$6)}},gt$1=class extends T$1{constructor(_e,Dt,Vt,Gt,zt){super(_e,Dt,Vt,Gt,zt),this.type=5}_$AI(_e,Dt=this){if((_e=v$2(this,_e,Dt,0)??c$6)===g$2)return;const Vt=this._$AH,Gt=_e===c$6&&Vt!==c$6||_e.capture!==Vt.capture||_e.once!==Vt.once||_e.passive!==Vt.passive,zt=_e!==c$6&&(Vt===c$6||Gt);Gt&&this.element.removeEventListener(this.name,this,Vt),zt&&this.element.addEventListener(this.name,this,_e),this._$AH=_e}handleEvent(_e){typeof this._$AH=="function"?this._$AH.call(this.options?.host??this.element,_e):this._$AH.handleEvent(_e)}},vt$1=class{constructor(_e,Dt,Vt){this.element=_e,this.type=6,this._$AN=void 0,this._$AM=Dt,this.options=Vt}get _$AU(){return this._$AM._$AU}_$AI(_e){v$2(this,_e)}};const Et$1=L$2.litHtmlPolyfillSupport;Et$1?.(C$3,P$4),(L$2.litHtmlVersions??=[]).push("3.3.0");const St$1=(kt,_e,Dt)=>{const Vt=Dt?.renderBefore??_e;let Gt=Vt._$litPart$;if(Gt===void 0){const zt=Dt?.renderBefore??null;Vt._$litPart$=Gt=new P$4(_e.insertBefore(b$1(),zt),zt,void 0,Dt??{})}return Gt._$AI(kt),Gt};/**
29
+ */const L$2=globalThis,H$3=L$2.trustedTypes,q$5=H$3?H$3.createPolicy("lit-html",{createHTML:kt=>kt}):void 0,Y$2="$lit$",_$1=`lit$${Math.random().toFixed(9).slice(2)}$`,tt$1="?"+_$1,ut$1=`<${tt$1}>`,m$4=document,b$1=()=>m$4.createComment(""),w$3=kt=>kt===null||typeof kt!="object"&&typeof kt!="function",j$1=Array.isArray,$t=kt=>j$1(kt)||typeof kt?.[Symbol.iterator]=="function",N$2=`[
30
+ \f\r]`,E$2=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,J$1=/-->/g,K$2=/>/g,f$4=RegExp(`>|${N$2}(?:([^\\s"'>=/]+)(${N$2}*=${N$2}*(?:[^
31
+ \f\r"'\`<>=]|("|')|))|$)`,"g"),Z$3=/'/g,F$1=/"/g,et$3=/^(?:script|style|textarea|title)$/i,_t$1=kt=>(_e,...Dt)=>({_$litType$:kt,strings:_e,values:Dt}),xt$1=_t$1(1),g$2=Symbol.for("lit-noChange"),c$6=Symbol.for("lit-nothing"),G$3=new WeakMap,A$2=m$4.createTreeWalker(m$4,129);function st$1(kt,_e){if(!j$1(kt)||!kt.hasOwnProperty("raw"))throw Error("invalid template strings array");return q$5!==void 0?q$5.createHTML(_e):_e}const ft$1=(kt,_e)=>{const Dt=kt.length-1,Vt=[];let Gt,zt=_e===2?"<svg>":_e===3?"<math>":"",jt=E$2;for(let Ht=0;Ht<Dt;Ht++){const Wt=kt[Ht];let qt,Xt,Kt=-1,Yt=0;for(;Yt<Wt.length&&(jt.lastIndex=Yt,Xt=jt.exec(Wt),Xt!==null);)Yt=jt.lastIndex,jt===E$2?Xt[1]==="!--"?jt=J$1:Xt[1]!==void 0?jt=K$2:Xt[2]!==void 0?(et$3.test(Xt[2])&&(Gt=RegExp("</"+Xt[2],"g")),jt=f$4):Xt[3]!==void 0&&(jt=f$4):jt===f$4?Xt[0]===">"?(jt=Gt??E$2,Kt=-1):Xt[1]===void 0?Kt=-2:(Kt=jt.lastIndex-Xt[2].length,qt=Xt[1],jt=Xt[3]===void 0?f$4:Xt[3]==='"'?F$1:Z$3):jt===F$1||jt===Z$3?jt=f$4:jt===J$1||jt===K$2?jt=E$2:(jt=f$4,Gt=void 0);const Zt=jt===f$4&&kt[Ht+1].startsWith("/>")?" ":"";zt+=jt===E$2?Wt+ut$1:Kt>=0?(Vt.push(qt),Wt.slice(0,Kt)+Y$2+Wt.slice(Kt)+_$1+Zt):Wt+_$1+(Kt===-2?Ht:Zt)}return[st$1(kt,zt+(kt[Dt]||"<?>")+(_e===2?"</svg>":_e===3?"</math>":"")),Vt]};let C$2=class Tv{constructor({strings:_e,_$litType$:Dt},Vt){let Gt;this.parts=[];let zt=0,jt=0;const Ht=_e.length-1,Wt=this.parts,[qt,Xt]=ft$1(_e,Dt);if(this.el=Tv.createElement(qt,Vt),A$2.currentNode=this.el.content,Dt===2||Dt===3){const Kt=this.el.content.firstChild;Kt.replaceWith(...Kt.childNodes)}for(;(Gt=A$2.nextNode())!==null&&Wt.length<Ht;){if(Gt.nodeType===1){if(Gt.hasAttributes())for(const Kt of Gt.getAttributeNames())if(Kt.endsWith(Y$2)){const Yt=Xt[jt++],Zt=Gt.getAttribute(Kt).split(_$1),Jt=/([.?@])?(.*)/.exec(Yt);Wt.push({type:1,index:zt,name:Jt[2],strings:Zt,ctor:Jt[1]==="."?mt$1:Jt[1]==="?"?yt$1:Jt[1]==="@"?gt$1:T$1}),Gt.removeAttribute(Kt)}else Kt.startsWith(_$1)&&(Wt.push({type:6,index:zt}),Gt.removeAttribute(Kt));if(et$3.test(Gt.tagName)){const Kt=Gt.textContent.split(_$1),Yt=Kt.length-1;if(Yt>0){Gt.textContent=H$3?H$3.emptyScript:"";for(let Zt=0;Zt<Yt;Zt++)Gt.append(Kt[Zt],b$1()),A$2.nextNode(),Wt.push({type:2,index:++zt});Gt.append(Kt[Yt],b$1())}}}else if(Gt.nodeType===8)if(Gt.data===tt$1)Wt.push({type:2,index:zt});else{let Kt=-1;for(;(Kt=Gt.data.indexOf(_$1,Kt+1))!==-1;)Wt.push({type:7,index:zt}),Kt+=_$1.length-1}zt++}}static createElement(_e,Dt){const Vt=m$4.createElement("template");return Vt.innerHTML=_e,Vt}};function v$3(kt,_e,Dt=kt,Vt){if(_e===g$2)return _e;let Gt=Vt!==void 0?Dt._$Co?.[Vt]:Dt._$Cl;const zt=w$3(_e)?void 0:_e._$litDirective$;return Gt?.constructor!==zt&&(Gt?._$AO?.(!1),zt===void 0?Gt=void 0:(Gt=new zt(kt),Gt._$AT(kt,Dt,Vt)),Vt!==void 0?(Dt._$Co??=[])[Vt]=Gt:Dt._$Cl=Gt),Gt!==void 0&&(_e=v$3(kt,Gt._$AS(kt,_e.values),Gt,Vt)),_e}let At$1=class{constructor(_e,Dt){this._$AV=[],this._$AN=void 0,this._$AD=_e,this._$AM=Dt}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(_e){const{el:{content:Dt},parts:Vt}=this._$AD,Gt=(_e?.creationScope??m$4).importNode(Dt,!0);A$2.currentNode=Gt;let zt=A$2.nextNode(),jt=0,Ht=0,Wt=Vt[0];for(;Wt!==void 0;){if(jt===Wt.index){let qt;Wt.type===2?qt=new P$3(zt,zt.nextSibling,this,_e):Wt.type===1?qt=new Wt.ctor(zt,Wt.name,Wt.strings,this,_e):Wt.type===6&&(qt=new vt$1(zt,this,_e)),this._$AV.push(qt),Wt=Vt[++Ht]}jt!==Wt?.index&&(zt=A$2.nextNode(),jt++)}return A$2.currentNode=m$4,Gt}p(_e){let Dt=0;for(const Vt of this._$AV)Vt!==void 0&&(Vt.strings!==void 0?(Vt._$AI(_e,Vt,Dt),Dt+=Vt.strings.length-2):Vt._$AI(_e[Dt])),Dt++}},P$3=class wv{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(_e,Dt,Vt,Gt){this.type=2,this._$AH=c$6,this._$AN=void 0,this._$AA=_e,this._$AB=Dt,this._$AM=Vt,this.options=Gt,this._$Cv=Gt?.isConnected??!0}get parentNode(){let _e=this._$AA.parentNode;const Dt=this._$AM;return Dt!==void 0&&_e?.nodeType===11&&(_e=Dt.parentNode),_e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(_e,Dt=this){_e=v$3(this,_e,Dt),w$3(_e)?_e===c$6||_e==null||_e===""?(this._$AH!==c$6&&this._$AR(),this._$AH=c$6):_e!==this._$AH&&_e!==g$2&&this._(_e):_e._$litType$!==void 0?this.$(_e):_e.nodeType!==void 0?this.T(_e):$t(_e)?this.k(_e):this._(_e)}O(_e){return this._$AA.parentNode.insertBefore(_e,this._$AB)}T(_e){this._$AH!==_e&&(this._$AR(),this._$AH=this.O(_e))}_(_e){this._$AH!==c$6&&w$3(this._$AH)?this._$AA.nextSibling.data=_e:this.T(m$4.createTextNode(_e)),this._$AH=_e}$(_e){const{values:Dt,_$litType$:Vt}=_e,Gt=typeof Vt=="number"?this._$AC(_e):(Vt.el===void 0&&(Vt.el=C$2.createElement(st$1(Vt.h,Vt.h[0]),this.options)),Vt);if(this._$AH?._$AD===Gt)this._$AH.p(Dt);else{const zt=new At$1(Gt,this),jt=zt.u(this.options);zt.p(Dt),this.T(jt),this._$AH=zt}}_$AC(_e){let Dt=G$3.get(_e.strings);return Dt===void 0&&G$3.set(_e.strings,Dt=new C$2(_e)),Dt}k(_e){j$1(this._$AH)||(this._$AH=[],this._$AR());const Dt=this._$AH;let Vt,Gt=0;for(const zt of _e)Gt===Dt.length?Dt.push(Vt=new wv(this.O(b$1()),this.O(b$1()),this,this.options)):Vt=Dt[Gt],Vt._$AI(zt),Gt++;Gt<Dt.length&&(this._$AR(Vt&&Vt._$AB.nextSibling,Gt),Dt.length=Gt)}_$AR(_e=this._$AA.nextSibling,Dt){for(this._$AP?.(!1,!0,Dt);_e&&_e!==this._$AB;){const Vt=_e.nextSibling;_e.remove(),_e=Vt}}setConnected(_e){this._$AM===void 0&&(this._$Cv=_e,this._$AP?.(_e))}},T$1=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(_e,Dt,Vt,Gt,zt){this.type=1,this._$AH=c$6,this._$AN=void 0,this.element=_e,this.name=Dt,this._$AM=Gt,this.options=zt,Vt.length>2||Vt[0]!==""||Vt[1]!==""?(this._$AH=Array(Vt.length-1).fill(new String),this.strings=Vt):this._$AH=c$6}_$AI(_e,Dt=this,Vt,Gt){const zt=this.strings;let jt=!1;if(zt===void 0)_e=v$3(this,_e,Dt,0),jt=!w$3(_e)||_e!==this._$AH&&_e!==g$2,jt&&(this._$AH=_e);else{const Ht=_e;let Wt,qt;for(_e=zt[0],Wt=0;Wt<zt.length-1;Wt++)qt=v$3(this,Ht[Vt+Wt],Dt,Wt),qt===g$2&&(qt=this._$AH[Wt]),jt||=!w$3(qt)||qt!==this._$AH[Wt],qt===c$6?_e=c$6:_e!==c$6&&(_e+=(qt??"")+zt[Wt+1]),this._$AH[Wt]=qt}jt&&!Gt&&this.j(_e)}j(_e){_e===c$6?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,_e??"")}},mt$1=class extends T$1{constructor(){super(...arguments),this.type=3}j(_e){this.element[this.name]=_e===c$6?void 0:_e}},yt$1=class extends T$1{constructor(){super(...arguments),this.type=4}j(_e){this.element.toggleAttribute(this.name,!!_e&&_e!==c$6)}},gt$1=class extends T$1{constructor(_e,Dt,Vt,Gt,zt){super(_e,Dt,Vt,Gt,zt),this.type=5}_$AI(_e,Dt=this){if((_e=v$3(this,_e,Dt,0)??c$6)===g$2)return;const Vt=this._$AH,Gt=_e===c$6&&Vt!==c$6||_e.capture!==Vt.capture||_e.once!==Vt.once||_e.passive!==Vt.passive,zt=_e!==c$6&&(Vt===c$6||Gt);Gt&&this.element.removeEventListener(this.name,this,Vt),zt&&this.element.addEventListener(this.name,this,_e),this._$AH=_e}handleEvent(_e){typeof this._$AH=="function"?this._$AH.call(this.options?.host??this.element,_e):this._$AH.handleEvent(_e)}},vt$1=class{constructor(_e,Dt,Vt){this.element=_e,this.type=6,this._$AN=void 0,this._$AM=Dt,this.options=Vt}get _$AU(){return this._$AM._$AU}_$AI(_e){v$3(this,_e)}};const Et$1=L$2.litHtmlPolyfillSupport;Et$1?.(C$2,P$3),(L$2.litHtmlVersions??=[]).push("3.3.0");const St$1=(kt,_e,Dt)=>{const Vt=Dt?.renderBefore??_e;let Gt=Vt._$litPart$;if(Gt===void 0){const zt=Dt?.renderBefore??null;Vt._$litPart$=Gt=new P$3(_e.insertBefore(b$1(),zt),zt,void 0,Dt??{})}return Gt._$AI(kt),Gt};/**
32
32
  * @license
33
33
  * Copyright 2017 Google LLC
34
34
  * SPDX-License-Identifier: BSD-3-Clause
35
- */const z$2=globalThis;let O$2=class extends y$2{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){const _e=super.createRenderRoot();return this.renderOptions.renderBefore??=_e.firstChild,_e}update(_e){const Dt=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(_e),this._$Do=St$1(Dt,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return g$2}};O$2._$litElement$=!0,O$2.finalized=!0,z$2.litElementHydrateSupport?.({LitElement:O$2});const bt=z$2.litElementPolyfillSupport;bt?.({LitElement:O$2});(z$2.litElementVersions??=[]).push("4.2.0");let h$5=class extends HTMLElement{constructor(_e,Dt){super(),this._isReady=!1,this._elementName="epigraph-base-solution-html",this._solutionVersion="",this._loggerContextOverride="[EPIGRAPH BASE SOLUTION]",this.attachShadow({mode:"open"}),this._environment=Dt,this._solutionVersion=_e,this._xPath=g$3.generateXPath(this),this._uuid=g$3.safeGenerateUuid()??this._xPath,new g$3(this),window.epigraph.logger.info({title:"Epigraph Base Solution Ready",contextOverride:this._loggerContextOverride})}get isReady(){return this._isReady}get environment(){return this._environment}get elementName(){return this._elementName}get solutionVersion(){return this._solutionVersion}get uuid(){return this._uuid}get xPath(){return this._xPath}disconnectedCallback(){window.epigraph.deregisterActiveComponent(this)}};var o$2=(kt=>(kt.UNAVAILABLE="unavailable",kt.AVAILABLE="available",kt.RESTRICTED="restricted",kt))(o$2||{});const p$6=Symbol("data"),l$3=Symbol("next"),N$2=class Av{constructor(_e){this[p$6]=_e,this[l$3]=null}get data(){return this[p$6]}set next(_e){if(!(_e instanceof Av)&&_e!==null)throw new Error("This node is not an instance of the custom class 'Node'.");this[l$3]=_e}get next(){return this[l$3]}};let g$1=N$2;const d$2=Symbol("head");let P$3=class{constructor(){this[d$2]=null}set head(_e){this[d$2]=_e}get head(){return this[d$2]}addToTail(_e){let Dt=this.head;if(Dt){for(;Dt.next!==null;)Dt=Dt?.next;return Dt.next=new g$1(_e)}return this.head=new g$1(_e)}removeHead(){const _e=this.head;if(_e)return this.head=_e.next,_e.data}};const _$1=Symbol("queue"),h$4=Symbol("size");let m$3=class{constructor(){this[_$1]=new P$3,this[h$4]=0}get queue(){return this[_$1]}get size(){return this[h$4]}enqueue(_e){this.queue.addToTail(_e),this[h$4]++}dequeue(){const _e=this.queue.removeHead();return this[h$4]--,_e}},I$2=class{constructor({trackingID:_e,experienceID:Dt,solution:Vt,verboseLogging:Gt=!1}){this.__status=o$2.UNAVAILABLE,this.__sentEventCount=0,this.__initializationAttempts=0,this.__lastInitializationAttempt=performance.now(),this.__maxInitializationAttempts=10,this.__initializationRetryDelay=2e3,this.__isInitialized=!1,this.__initializationMethod="NONE",this.__nexusFailureReported=!1,this.name=this.pluginName="GA4-PLUGIN",this.trackingID=_e,this.experienceID=Dt,this.solution=Vt,this.verboseLogging=Gt,this.__queue=new m$3,this.initializePlugin()}getStatus(){return this.__status}setStatus(_e){this.__status=_e}getPendingEventCount(){return this.__queue.size}getSentEventCount(){return this.__sentEventCount}getTotalEventCount(){return this.getPendingEventCount()+this.getSentEventCount()}getUniquePluginIdentifier(){return`${this.name}-${this.trackingID}`}setupPlugin(){this.__isInitialized&&this.dataLayer!==void 0&&this.dequeueAndSendEvents()}async sendEvent(_e,Dt){if(this.__queue.enqueue(_e),!Dt){this.__status=o$2.RESTRICTED;return}if(!this.__isInitialized){this.logger("Cannot send analytics event: dataLayer not defined or plugin not initialized.");return}try{await this.dequeueAndSendEvents()}catch(Vt){this.logger(Vt),await this.reportFailureToNexus("EVENT_SEND_ERROR",Vt?.toString()||"Unknown error")}}initializePlugin(){if(this.__isInitialized)return;if(this.__initializationAttempts>=this.__maxInitializationAttempts){this.__nexusFailureReported||(this.reportFailureToNexus("MAX_INITIALIZATION_ATTEMPTS","Maximum initialization attempts reached"),this.__nexusFailureReported=!0);return}const _e=performance.now();if(this.__initializationAttempts>0&&_e-this.__lastInitializationAttempt<this.__initializationRetryDelay)return;this.__lastInitializationAttempt=_e,this.__initializationAttempts++;const Dt=this.detectAndSetupAnalytics();Dt.success?(this.__isInitialized=!0,this.__status=o$2.AVAILABLE,this.__initializationMethod=Dt.method,this.dataLayerName=Dt.dataLayerName,this.dataLayer=window[this.dataLayerName],this.logger(`Successfully initialized ${Dt.method} with dataLayer: ${this.dataLayerName}`),this.__queue.size>0&&this.dequeueAndSendEvents()):(this.logger(`Initialization attempt ${this.__initializationAttempts} failed: ${Dt.error}`),this.__initializationAttempts<this.__maxInitializationAttempts&&setTimeout(()=>{this.initializePlugin()},this.__initializationRetryDelay))}detectAndSetupAnalytics(){const _e=this.detectGTM();if(_e)return this.logger(`GTM detected with container ID: ${_e.containerId}`),{success:!0,method:"GTM",dataLayerName:_e.dataLayerName};const Dt=this.findGA4Info(this.trackingID);if(Dt){const Vt=Dt.l||"dataLayer";return this.logger(`GA4 script found, setting up with dataLayer: ${Vt}`),{success:!0,method:"GA4",dataLayerName:Vt}}return{success:!1,method:"NONE",dataLayerName:"dataLayer",error:"No analytics setup found and unable to create one"}}detectGTM(){const _e=document.querySelectorAll('script[src*="googletagmanager.com/gtm"]');for(const Dt of Array.from(_e)){const Vt=Dt.getAttribute("src");if(Vt){const Gt=Vt.match(/gtm\.js\?id=([^&]+)/);if(Gt&&Gt.length>0){const zt=Vt.match(/&l=([^&]+)/),jt=zt?zt[1]:"dataLayer";return{containerId:Gt[1],dataLayerName:jt}}}}return null}async dequeueAndSendEvents(){if(!this.__isInitialized||!this.dataLayer)return;let _e=this.__queue.size;for(let Dt=0;Dt<_e;Dt++){const Vt=this.__queue.dequeue();try{this.__initializationMethod==="GTM"?(this.sendGTMEvent(Vt),this.__sentEventCount++,this.logger(`Analytics event successfully sent via ${this.__initializationMethod}: ${Vt.eventName}`)):this.__initializationMethod==="GA4"?(this.sendGA4Event(Vt),this.__sentEventCount++,this.logger(`Analytics event successfully sent via ${this.__initializationMethod}: ${Vt.eventName}`)):this.__queue.enqueue(Vt)}catch(Gt){this.logger(`Error sending event ${Vt.eventName}: ${Gt}`),this.__queue.enqueue(Vt)}}}async sendGTMEvent(_e){let Dt=_e.getGTMParameters(this.solution,this.experienceID,this.trackingID);this.isValidPayload(Dt)||(Dt=await this.convertGTMParametersToEpgEventTag(_e.eventName,Dt)),this.dataLayer&&this.dataLayer.push(Dt)}async sendGA4Event(_e){let Dt=_e.getGa4Parameters(this.solution,this.experienceID,this.trackingID);this.isValidPayload(Dt)||(Dt=await this.convertGA4ParametersToEpgEventTag(Dt)),window.gtag("event",_e.eventName,Dt)}isValidPayload(_e){if(Object.keys(_e).length>=25)return!1;for(const[Dt,Vt]of Object.entries(_e))if(Dt!=="items"&&(Dt.length>40||String(Vt).length>100))return!1;return!0}async convertGTMParametersToEpgEventTag(_e,Dt){try{let Vt=await this.sendGA4LongParameters(Dt);return{event:_e,epg_event_tag:Vt,send_to:this.trackingID}}catch{return Dt}}async convertGA4ParametersToEpgEventTag(_e){try{return{epg_event_tag:await this.sendGA4LongParameters(_e),send_to:this.trackingID}}catch{return _e}}logger(_e){this.verboseLogging&&console.warn(_e)}async sendGA4LongParameters(_e){const Dt="https://api.myepigraph.com/api/analytics/ga4/custom",Vt={parameters:_e};try{const Gt=await fetch(Dt,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(Vt)});return Gt.ok?(await Gt.json())?.id??"":""}catch{return""}}async reportFailureToNexus(_e,Dt){try{const Vt={plugin:"GA4",trackingId:this.trackingID,solution:this.solution,experienceId:this.experienceID,failureType:_e,errorMessage:Dt,timestamp:new Date().toISOString(),url:window.location.href,userAgent:navigator.userAgent};this.logger(`Failure reported to Nexus: ${JSON.stringify(Vt)}`)}catch(Vt){this.logger(`Error reporting failure to Nexus: ${Vt}`)}}findGA4Info(_e){if(window.google_tag_manager&&window.google_tag_manager[_e]){const Vt=window.google_tag_manager[_e];if(Vt&&Vt.dataLayerName)return{fullSrc:"",id:_e,l:Vt.dataLayerName}}const Dt=document.querySelectorAll("script[src]");for(const Vt of Dt){const Gt=Vt.getAttribute("src");if(Gt&&Gt.includes(_e)){const zt=new URL(Gt,location.href),jt=Object.fromEntries(zt.searchParams.entries());return{fullSrc:zt.href,id:jt.id||void 0,l:jt.l||void 0}}}return null}},C$2=class{constructor({trackingID:_e,experienceID:Dt,solution:Vt,sessionId:Gt,xPath:zt,verboseLogging:jt=!1,sendToStaging:Ht=!1}){this.__status=o$2.UNAVAILABLE,this.__sentEventCount=0,this.sessionId=Gt,this.xPath=zt,this.name=this.pluginName="NEXUS-PLUGIN",this.trackingID=_e,this.experienceID=Dt,this.solution=Vt,this.verboseLogging=jt,this.__queue=new m$3,this.url=Ht?"https://nexus.epigraph.dev/api/analytics/event":"https://api.myepigraph.com/api/analytics/event",this.__status=o$2.AVAILABLE}getStatus(){return this.__status}setStatus(_e){this.__status=_e}getPendingEventCount(){return this.__queue.size}getSentEventCount(){return this.__sentEventCount}getTotalEventCount(){return this.getPendingEventCount()+this.getSentEventCount()}getUniquePluginIdentifier(){return this.name+"-"+this.trackingID}setupPlugin(){}async sendEvent(_e,Dt){if(this.__queue.enqueue(_e),!Dt){this.__status=o$2.RESTRICTED;return}await this.dequeueAndSendEvents()}async dequeueAndSendEvents(){for(let _e=0;_e<this.__queue.size;_e++){const Dt=this.__queue.dequeue();Dt.customParameters.solution=this.solution;const Vt={trackingID:this.trackingID,experience_id:this.experienceID,action:Dt.eventName,parameters:Dt.getNexusParameters()};try{return(await fetch(this.url,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json","EPG-SESSION-ID":this.sessionId,"EPG-XPATH":this.xPath,Origin:typeof window<"u"?window.location.origin:""},body:JSON.stringify(Vt)})).status,""}catch{return""}this.__sentEventCount++}return""}},A$1=class{constructor(_e){this.consentSet=!1,this.consent=!1,this.pluginName="OneTrustConsentPlugin",this.consentIdentifier=_e,this.consent=!1,this.addConsentChangedListener()}hasConsent(){if(this.consentSet)return this.consent;if(window.OnetrustActiveGroups!==void 0){let _e=window.OnetrustActiveGroups;_e!==void 0&&_e.split(",").forEach(Dt=>{Dt===this.consentIdentifier&&(this.consent=!0,this.consentSet=!0)})}return this.consent}addConsentChangedListener(){window.addEventListener("load",()=>{this.hasConsent(),window.OneTrust!==void 0&&typeof window.OneTrust=="object"&&window.OneTrust.OnConsentChanged(()=>{this.consentSet=!1,this.hasConsent()})})}};var E$2=(kt=>(kt.OneTrust="onetrust",kt))(E$2||{});/**
35
+ */const z$2=globalThis;let O$2=class extends y$2{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){const _e=super.createRenderRoot();return this.renderOptions.renderBefore??=_e.firstChild,_e}update(_e){const Dt=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(_e),this._$Do=St$1(Dt,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return g$2}};O$2._$litElement$=!0,O$2.finalized=!0,z$2.litElementHydrateSupport?.({LitElement:O$2});const bt=z$2.litElementPolyfillSupport;bt?.({LitElement:O$2});(z$2.litElementVersions??=[]).push("4.2.0");let h$5=class extends HTMLElement{constructor(_e,Dt){super(),this._isReady=!1,this._elementName="epigraph-base-solution-html",this._solutionVersion="",this._loggerContextOverride="[EPIGRAPH BASE SOLUTION]",this.attachShadow({mode:"open"}),this._environment=Dt,this._solutionVersion=_e,this._xPath=g$3.generateXPath(this),this._uuid=g$3.safeGenerateUuid()??this._xPath,new g$3(this),window.epigraph.logger.info({title:"Epigraph Base Solution Ready",contextOverride:this._loggerContextOverride})}get isReady(){return this._isReady}get environment(){return this._environment}get elementName(){return this._elementName}get solutionVersion(){return this._solutionVersion}get uuid(){return this._uuid}get xPath(){return this._xPath}disconnectedCallback(){window.epigraph.deregisterActiveComponent(this)}};const d$2=Symbol("data"),u$5=Symbol("next"),v$2=class Av{constructor(_e){this[d$2]=_e,this[u$5]=null}get data(){return this[d$2]}set next(_e){if(!(_e instanceof Av)&&_e!==null)throw new Error("This node is not an instance of the custom class 'Node'.");this[u$5]=_e}get next(){return this[u$5]}};let g$1=v$2;const h$4=Symbol("head");let m$3=class{constructor(){this[h$4]=null}set head(_e){this[h$4]=_e}get head(){return this[h$4]}addToTail(_e){let Dt=this.head;if(Dt){for(;Dt.next!==null;)Dt=Dt?.next;return Dt.next=new g$1(_e)}return this.head=new g$1(_e)}removeHead(){const _e=this.head;if(_e)return this.head=_e.next,_e.data}};const f$3=Symbol("queue"),o$2=Symbol("size");let l$3=class{constructor(){this[f$3]=new m$3,this[o$2]=0}get queue(){return this[f$3]}get size(){return this[o$2]}enqueue(_e){this.queue.addToTail(_e),this[o$2]++}dequeue(){const _e=this.queue.removeHead();return this[o$2]--,_e}},I$2=class{constructor(_e,Dt){this.name=this.pluginName="GA4-PLUGIN",this.trackingID=_e,this.verboseLogging=Dt,this.queue=new l$3,this.dataLayer=window.dataLayer,this.dataLayerName="dataLayer",this.setupDataLayer(),this.initGtag(this.dataLayerName,this.trackingID)}setupDataLayer(){if(this.dataLayer)return;const _e=this.findGA4ScriptInfo(this.trackingID)?.l;_e&&(this.dataLayerName=_e,this.dataLayer=window[_e])}initGtag(_e="dataLayer",Dt){window.epgDataLayerName=_e,typeof window.gtag!="function"&&(window.gtag=function(){window[window.epgDataLayerName].push(arguments)},window.gtag("js",new Date),window.gtag("config",Dt,{send_page_view:!1}))}async sendEvent(_e,Dt){this.queue.enqueue(_e);let Vt=!0;if(Dt&&(Vt=Dt.hasConsent()),this.dataLayer!==void 0&&Vt)try{await this.dequeueAndSendEvents()}catch(Gt){this.logger(Gt)}else this.logger("Cannot send Google Analytics 4 event: dataLayer is not defined.")}async dequeueAndSendEvents(){let _e=this.queue.size;for(let Dt=0;Dt<_e;Dt++){const Vt=this.queue.dequeue();let Gt={send_to:this.trackingID,event_action:Vt.action,event_category:Vt.category,event_label:Vt.label,epg_event_tag:""};if("parameters"in Vt&&Object.assign(Gt,Vt.parameters),JSON.stringify(Gt).length>459)try{let zt=await this.sendGA4LongParameters(Gt);Gt={send_to:this.trackingID,event_action:Vt.action,event_category:Vt.category,event_label:Vt.label,epg_event_tag:zt}}catch{}gtag("event",Vt.action,Gt),this.logger(`Google Analytics 4 event successfully sent: ${Vt.action}`)}}logger(_e){this.verboseLogging&&console.warn(_e)}getUniquePluginIdentifier(){return this.name+"-"+this.trackingID}setupPlugin(){this.dataLayer!==void 0&&this.dequeueAndSendEvents()}async sendGA4LongParameters(_e){const Dt="https://api.myepigraph.com/api/analytics/ga4/custom",Vt={parameters:_e};try{const Gt=await fetch(Dt,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(Vt)});if(Gt.ok){const zt=await Gt.json();return zt&&zt.id?zt.id:""}else return""}catch{return""}}findGA4ScriptInfo(_e){const Dt=document.querySelectorAll("script[src]");for(const Vt of Dt){const Gt=Vt.getAttribute("src");if(Gt&&Gt.includes(_e)){const zt=new URL(Gt,location.href),jt=Object.fromEntries(zt.searchParams.entries());return{fullSrc:zt.href,id:jt.id||void 0,l:jt.l||void 0}}}return null}},A$1=class{constructor(_e,Dt,Vt,Gt,zt=!1){this.sessionId=Dt,this.xPath=Vt,this.name=this.pluginName="NEXUS-PLUGIN",this.trackingID=_e,this.verboseLogging=Gt,this.queue=new l$3,this.url=zt?"https://nexus.epigraph.dev/api/analytics/event":"https://api.myepigraph.com/api/analytics/event"}async sendEvent(_e,Dt){this.queue.enqueue(_e);let Vt=!0;Dt&&(Vt=Dt.hasConsent()),Vt&&await this.dequeueAndSendEvents()}async dequeueAndSendEvents(){for(let _e=0;_e<this.queue.size;_e++){const Dt=this.queue.dequeue(),Vt={experience_id:this.trackingID,action:Dt.action,parameters:Dt.parameters};try{return(await fetch(this.url,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json","EPG-SESSION-ID":this.sessionId,"EPG-XPATH":this.xPath,Origin:typeof window<"u"?window.location.origin:""},body:JSON.stringify(Vt)})).status,""}catch{return""}}return""}getUniquePluginIdentifier(){return this.name+"-"+this.trackingID}setupPlugin(){}},q$4=class{constructor(_e){this.consentSet=!1,this.consent=!1,this.pluginName="OneTrustConsentPlugin",this.consentIdentifier=_e,this.consent=!1,this.addConsentChangedListener()}hasConsent(){if(this.consentSet)return this.consent;if(window.OnetrustActiveGroups!==void 0){let _e=window.OnetrustActiveGroups;_e!==void 0&&_e.split(",").forEach(Dt=>{Dt===this.consentIdentifier&&(this.consent=!0,this.consentSet=!0)})}return this.consent}addConsentChangedListener(){window.addEventListener("load",()=>{this.hasConsent(),window.OneTrust!==void 0&&typeof window.OneTrust=="object"&&window.OneTrust.OnConsentChanged(()=>{this.consentSet=!1,this.hasConsent()})})}};var p$6=(kt=>(kt.OneTrust="onetrust",kt))(p$6||{});/**
36
36
  * @license
37
37
  * Copyright (c) 2023 Epigraph LLC. All Rights Reserved.
38
38
  *
@@ -47,7 +47,7 @@
47
47
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
48
48
  * See the License for the specific language governing permissions and
49
49
  * limitations under the License.
50
- */var f$3;const c$5=Symbol("analyticsPluginsMap");f$3=c$5;let X$2=class{constructor(_e,Dt){this[f$3]=new Map,this.__consentPlugin=null,_e&&Dt&&(this.__consentPlugin=this.buildConsentPlugin(_e,Dt)),window.addEventListener("epigraphAnalyticsConsentChange",this.__onConsentChangeFromEvent)}__onConsentChangeFromEvent(_e){let Dt=_e;this.__overrideConsent=Dt.detail.hasConsent;for(const Vt of this[c$5].values())this.__hasConsent()||Vt.setStatus(o$2.RESTRICTED)}addEventPlugin(_e){this[c$5].has(_e.getUniquePluginIdentifier())||(this[c$5].set(_e.getUniquePluginIdentifier(),_e),_e.setupPlugin())}__hasConsent(){let _e=!0;return this.__overrideConsent!==void 0?(_e=this.__overrideConsent,_e):(this.__consentPlugin&&(_e=this.__consentPlugin.hasConsent()),_e)}sendEvent(_e){this[c$5].forEach(Dt=>{Dt.sendEvent(_e,this.__hasConsent())})}buildConsentPlugin(_e,Dt){return _e.toLowerCase()===E$2.OneTrust.toLowerCase()?new A$1(Dt):null}},u$4=class{constructor(_e,Dt,Vt,Gt=""){this._success=_e,this._payload=Dt,this._status=Vt,this._message=Gt}get success(){return this._success}get payload(){return this._payload}get status(){return this._status}get message(){return this._message}};function c$4(kt,_e,Dt=""){return new u$4(!0,kt,_e,Dt)}function n$4(kt,_e,Dt=""){return new u$4(!1,kt,_e,Dt)}let P$2=class{constructor(_e="https://api.myepigraph.com/api/",Dt,Vt,Gt="",zt="",jt="v1/"){this.epigraphXPath="",this.epigraphComponentVersion=Gt,this.epigraphSessionId=Vt,this.epigraphXPath=zt,this.baseUrl=_e+jt,this.epgLocation=Dt}async getButtonBySku(_e,Dt=""){const Vt={};Dt!==""&&(Vt.version_id=Dt);const Gt=`experience/button/sku/${_e}`,zt=this.buildNexusUrl(Gt,Vt);return await this.callNexusAPI(zt,"GET")}async getButtonByShopifyVariantId(_e,Dt=""){const Vt={};Dt!==""&&(Vt.version_id=Dt);const Gt=`experience/button/shopify_variant_id/${_e}`,zt=this.buildNexusUrl(Gt,Vt);return await this.callNexusAPI(zt,"GET")}async getButtonByUpc(_e,Dt=""){const Vt={};Dt!==""&&(Vt.version_id=Dt);const Gt=`experience/button/upc/${_e}`,zt=this.buildNexusUrl(Gt,Vt);return await this.callNexusAPI(zt,"GET")}async getButtonByAsin(_e,Dt=""){const Vt={};Dt!==""&&(Vt.version_id=Dt);const Gt=`experience/button/asin/${_e}`,zt=this.buildNexusUrl(Gt,Vt);return await this.callNexusAPI(zt,"GET")}async getViewerBySku(_e,Dt=""){const Vt={};Dt!==""&&(Vt.version_id=Dt);const Gt=`experience/viewer/sku/${_e}`,zt=this.buildNexusUrl(Gt,Vt);return await this.callNexusAPI(zt,"GET")}async getViewerByShopifyVariantId(_e,Dt=""){const Vt={};Dt!==""&&(Vt.version_id=Dt);const Gt=`experience/viewer/shopify_variant_id/${_e}`,zt=this.buildNexusUrl(Gt,Vt);return await this.callNexusAPI(zt,"GET")}async getViewerByUpc(_e,Dt=""){const Vt={};Dt!==""&&(Vt.version_id=Dt);const Gt=`experience/viewer/upc/${_e}`,zt=this.buildNexusUrl(Gt,Vt);return await this.callNexusAPI(zt,"GET")}async getViewerByAsin(_e,Dt=""){const Vt={};Dt!==""&&(Vt.version_id=Dt);const Gt=`experience/viewer/asin/${_e}`,zt=this.buildNexusUrl(Gt,Vt);return await this.callNexusAPI(zt,"GET")}async getTourBySku(_e,Dt=""){const Vt={};Dt!==""&&(Vt.version_id=Dt);const Gt=`experience/tour/sku/${_e}`,zt=this.buildNexusUrl(Gt,Vt);return await this.callNexusAPI(zt,"GET")}async getTourByShopifyVariantId(_e,Dt=""){const Vt={};Dt!==""&&(Vt.version_id=Dt);const Gt=`experience/tour/shopify_variant_id/${_e}`,zt=this.buildNexusUrl(Gt,Vt);return await this.callNexusAPI(zt,"GET")}async getTourByUpc(_e,Dt=""){const Vt={};Dt!==""&&(Vt.version_id=Dt);const Gt=`experience/tour/upc/${_e}`,zt=this.buildNexusUrl(Gt,Vt);return await this.callNexusAPI(zt,"GET")}async getTourByAsin(_e,Dt=""){const Vt={};Dt!==""&&(Vt.version_id=Dt);const Gt=`experience/tour/asin/${_e}`,zt=this.buildNexusUrl(Gt,Vt);return await this.callNexusAPI(zt,"GET")}async getConfiguratorByExperienceId(_e,Dt=""){const Vt={};Dt!==""&&(Vt.version_id=Dt);const Gt=`experience/configurator/experience_id/${_e}`,zt=this.buildNexusUrl(Gt,Vt);return await this.callNexusAPI(zt,"GET")}async getConfiguratorByClientAccessKey(_e,Dt=""){const Vt={};Dt!==""&&(Vt.version_id=Dt);const Gt=`experience/configurator/client_access_key/${_e}`,zt=this.buildNexusUrl(Gt,Vt);return await this.callNexusAPI(zt,"GET")}async getConfiguratorLiteByExperienceId(_e,Dt=""){const Vt={};Dt!==""&&(Vt.version_id=Dt);const Gt=`experience/configurator-lite/experience_id/${_e}`,zt=this.buildNexusUrl(Gt,Vt);return await this.callNexusAPI(zt,"GET")}async getConfiguratorLiteByProjectId(_e,Dt=""){const Vt={};Dt!==""&&(Vt.version_id=Dt);const Gt=`experience/configurator-lite/project_id/${_e}`,zt=this.buildNexusUrl(Gt,Vt);return await this.callNexusAPI(zt,"GET")}async postExperienceSaveAndShare(_e,Dt){const Vt=`experience/${_e}/save`,Gt=this.buildNexusUrl(Vt),zt={save_data:JSON.stringify(Dt)},jt=new Headers;return jt.set("Content-Type","application/json"),await this.callNexusAPI(Gt,"POST",JSON.stringify(zt),jt)}async getExperienceSaveAndShare(_e,Dt){const Vt=`experience/${_e}/save/${Dt}`,Gt=this.buildNexusUrl(Vt);return await this.callNexusAPI(Gt,"GET")}async callNexusAPI(_e,Dt="GET",Vt,Gt=new Headers){Gt=this.addRequiredHeaders(Gt);const zt={method:Dt,body:Vt,headers:Gt};try{const jt=await fetch(_e,zt),Ht=await jt.json();if(!jt.ok){let Wt="Unable to retrieve configurator experience";return Ht.message&&(Wt=Ht.message),Promise.resolve(n$4(Ht,jt.status,Wt))}return Promise.resolve(c$4(Ht,jt.status))}catch{return Promise.resolve(n$4({},500,"Unknown error"))}}buildNexusUrl(_e,Dt={}){let Vt=new URL(this.baseUrl);Vt.pathname+=_e;for(const[Gt,zt]of Object.entries(Dt))Vt.searchParams.set(Gt,zt);return Vt}addRequiredHeaders(_e){return _e.has("accept")||_e.set("accept","application/json"),_e.has("EPG-Location")||_e.set("EPG-location",this.epgLocation),_e.has("EPG-Session-ID")||_e.set("EPG-Session-ID",this.epigraphSessionId),_e.has("EPG-XPATH")||_e.set("EPG-XPATH",this.epigraphXPath),_e.has("EPG-Version")||_e.set("EPG-Version",this.epigraphComponentVersion),_e}};var p$5=(kt=>(kt.PRODUCTION="https://api.myepigraph.com/api/",kt.STAGING="https://nexus.epigraph.dev/api/",kt.LOCAL="https://nexus.test/api/",kt))(p$5||{});/**
50
+ */var w$2;const c$5=Symbol("analyticsPluginsMap");w$2=c$5;let S$3=class{constructor(_e,Dt){this[w$2]=new Map,this._consentPlugin=null,_e&&Dt&&(this._consentPlugin=this.buildConsentPlugin(_e,Dt))}addEventPlugin(_e){this[c$5].has(_e.getUniquePluginIdentifier())||(this[c$5].set(_e.getUniquePluginIdentifier(),_e),_e.setupPlugin())}sendEvent(_e){this[c$5].forEach(Dt=>{Dt.sendEvent(_e,this._consentPlugin)})}buildConsentPlugin(_e,Dt){return _e.toLowerCase()===p$6.OneTrust.toLowerCase()?new q$4(Dt):null}},u$4=class{constructor(_e,Dt,Vt,Gt=""){this._success=_e,this._payload=Dt,this._status=Vt,this._message=Gt}get success(){return this._success}get payload(){return this._payload}get status(){return this._status}get message(){return this._message}};function c$4(kt,_e,Dt=""){return new u$4(!0,kt,_e,Dt)}function n$4(kt,_e,Dt=""){return new u$4(!1,kt,_e,Dt)}let P$2=class{constructor(_e="https://api.myepigraph.com/api/",Dt,Vt,Gt="",zt="",jt="v1/"){this.epigraphXPath="",this.epigraphComponentVersion=Gt,this.epigraphSessionId=Vt,this.epigraphXPath=zt,this.baseUrl=_e+jt,this.epgLocation=Dt}async getButtonBySku(_e,Dt=""){const Vt={};Dt!==""&&(Vt.version_id=Dt);const Gt=`experience/button/sku/${_e}`,zt=this.buildNexusUrl(Gt,Vt);return await this.callNexusAPI(zt,"GET")}async getButtonByShopifyVariantId(_e,Dt=""){const Vt={};Dt!==""&&(Vt.version_id=Dt);const Gt=`experience/button/shopify_variant_id/${_e}`,zt=this.buildNexusUrl(Gt,Vt);return await this.callNexusAPI(zt,"GET")}async getButtonByUpc(_e,Dt=""){const Vt={};Dt!==""&&(Vt.version_id=Dt);const Gt=`experience/button/upc/${_e}`,zt=this.buildNexusUrl(Gt,Vt);return await this.callNexusAPI(zt,"GET")}async getButtonByAsin(_e,Dt=""){const Vt={};Dt!==""&&(Vt.version_id=Dt);const Gt=`experience/button/asin/${_e}`,zt=this.buildNexusUrl(Gt,Vt);return await this.callNexusAPI(zt,"GET")}async getViewerBySku(_e,Dt=""){const Vt={};Dt!==""&&(Vt.version_id=Dt);const Gt=`experience/viewer/sku/${_e}`,zt=this.buildNexusUrl(Gt,Vt);return await this.callNexusAPI(zt,"GET")}async getViewerByShopifyVariantId(_e,Dt=""){const Vt={};Dt!==""&&(Vt.version_id=Dt);const Gt=`experience/viewer/shopify_variant_id/${_e}`,zt=this.buildNexusUrl(Gt,Vt);return await this.callNexusAPI(zt,"GET")}async getViewerByUpc(_e,Dt=""){const Vt={};Dt!==""&&(Vt.version_id=Dt);const Gt=`experience/viewer/upc/${_e}`,zt=this.buildNexusUrl(Gt,Vt);return await this.callNexusAPI(zt,"GET")}async getViewerByAsin(_e,Dt=""){const Vt={};Dt!==""&&(Vt.version_id=Dt);const Gt=`experience/viewer/asin/${_e}`,zt=this.buildNexusUrl(Gt,Vt);return await this.callNexusAPI(zt,"GET")}async getTourBySku(_e,Dt=""){const Vt={};Dt!==""&&(Vt.version_id=Dt);const Gt=`experience/tour/sku/${_e}`,zt=this.buildNexusUrl(Gt,Vt);return await this.callNexusAPI(zt,"GET")}async getTourByShopifyVariantId(_e,Dt=""){const Vt={};Dt!==""&&(Vt.version_id=Dt);const Gt=`experience/tour/shopify_variant_id/${_e}`,zt=this.buildNexusUrl(Gt,Vt);return await this.callNexusAPI(zt,"GET")}async getTourByUpc(_e,Dt=""){const Vt={};Dt!==""&&(Vt.version_id=Dt);const Gt=`experience/tour/upc/${_e}`,zt=this.buildNexusUrl(Gt,Vt);return await this.callNexusAPI(zt,"GET")}async getTourByAsin(_e,Dt=""){const Vt={};Dt!==""&&(Vt.version_id=Dt);const Gt=`experience/tour/asin/${_e}`,zt=this.buildNexusUrl(Gt,Vt);return await this.callNexusAPI(zt,"GET")}async getConfiguratorByExperienceId(_e,Dt=""){const Vt={};Dt!==""&&(Vt.version_id=Dt);const Gt=`experience/configurator/experience_id/${_e}`,zt=this.buildNexusUrl(Gt,Vt);return await this.callNexusAPI(zt,"GET")}async getConfiguratorByClientAccessKey(_e,Dt=""){const Vt={};Dt!==""&&(Vt.version_id=Dt);const Gt=`experience/configurator/client_access_key/${_e}`,zt=this.buildNexusUrl(Gt,Vt);return await this.callNexusAPI(zt,"GET")}async getConfiguratorLiteByExperienceId(_e,Dt=""){const Vt={};Dt!==""&&(Vt.version_id=Dt);const Gt=`experience/configurator-lite/experience_id/${_e}`,zt=this.buildNexusUrl(Gt,Vt);return await this.callNexusAPI(zt,"GET")}async getConfiguratorLiteByProjectId(_e,Dt=""){const Vt={};Dt!==""&&(Vt.version_id=Dt);const Gt=`experience/configurator-lite/project_id/${_e}`,zt=this.buildNexusUrl(Gt,Vt);return await this.callNexusAPI(zt,"GET")}async postExperienceSaveAndShare(_e,Dt){const Vt=`experience/${_e}/save`,Gt=this.buildNexusUrl(Vt),zt={save_data:JSON.stringify(Dt)},jt=new Headers;return jt.set("Content-Type","application/json"),await this.callNexusAPI(Gt,"POST",JSON.stringify(zt),jt)}async getExperienceSaveAndShare(_e,Dt){const Vt=`experience/${_e}/save/${Dt}`,Gt=this.buildNexusUrl(Vt);return await this.callNexusAPI(Gt,"GET")}async callNexusAPI(_e,Dt="GET",Vt,Gt=new Headers){Gt=this.addRequiredHeaders(Gt);const zt={method:Dt,body:Vt,headers:Gt};try{const jt=await fetch(_e,zt),Ht=await jt.json();if(!jt.ok){let Wt="Unable to retrieve configurator experience";return Ht.message&&(Wt=Ht.message),Promise.resolve(n$4(Ht,jt.status,Wt))}return Promise.resolve(c$4(Ht,jt.status))}catch{return Promise.resolve(n$4({},500,"Unknown error"))}}buildNexusUrl(_e,Dt={}){let Vt=new URL(this.baseUrl);Vt.pathname+=_e;for(const[Gt,zt]of Object.entries(Dt))Vt.searchParams.set(Gt,zt);return Vt}addRequiredHeaders(_e){return _e.has("accept")||_e.set("accept","application/json"),_e.has("EPG-Location")||_e.set("EPG-location",this.epgLocation),_e.has("EPG-Session-ID")||_e.set("EPG-Session-ID",this.epigraphSessionId),_e.has("EPG-XPATH")||_e.set("EPG-XPATH",this.epigraphXPath),_e.has("EPG-Version")||_e.set("EPG-Version",this.epigraphComponentVersion),_e}};var p$5=(kt=>(kt.PRODUCTION="https://api.myepigraph.com/api/",kt.STAGING="https://nexus.epigraph.dev/api/",kt.LOCAL="https://nexus.test/api/",kt))(p$5||{});/**
51
51
  * @license
52
52
  * Copyright 2019 Google LLC
53
53
  * SPDX-License-Identifier: BSD-3-Clause
@@ -55,7 +55,7 @@
55
55
  * @license
56
56
  * Copyright 2017 Google LLC
57
57
  * SPDX-License-Identifier: BSD-3-Clause
58
- */const{is:i$3,defineProperty:e$4,getOwnPropertyDescriptor:h$3,getOwnPropertyNames:r$4,getOwnPropertySymbols:o,getPrototypeOf:n$2}=Object,a=globalThis,c$2=a.trustedTypes,l$2=c$2?c$2.emptyScript:"",p$4=a.reactiveElementPolyfillSupport,d$1=(kt,_e)=>kt,u$3={toAttribute(kt,_e){switch(_e){case Boolean:kt=kt?l$2:null;break;case Object:case Array:kt=kt==null?kt:JSON.stringify(kt)}return kt},fromAttribute(kt,_e){let Dt=kt;switch(_e){case Boolean:Dt=kt!==null;break;case Number:Dt=kt===null?null:Number(kt);break;case Object:case Array:try{Dt=JSON.parse(kt)}catch{Dt=null}}return Dt}},f$2=(kt,_e)=>!i$3(kt,_e),b={attribute:!0,type:String,converter:u$3,reflect:!1,useDefault:!1,hasChanged:f$2};Symbol.metadata??=Symbol("metadata"),a.litPropertyMetadata??=new WeakMap;let y$1=class extends HTMLElement{static addInitializer(_e){this._$Ei(),(this.l??=[]).push(_e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(_e,Dt=b){if(Dt.state&&(Dt.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(_e)&&((Dt=Object.create(Dt)).wrapped=!0),this.elementProperties.set(_e,Dt),!Dt.noAccessor){const Vt=Symbol(),Gt=this.getPropertyDescriptor(_e,Vt,Dt);Gt!==void 0&&e$4(this.prototype,_e,Gt)}}static getPropertyDescriptor(_e,Dt,Vt){const{get:Gt,set:zt}=h$3(this.prototype,_e)??{get(){return this[Dt]},set(jt){this[Dt]=jt}};return{get:Gt,set(jt){const Ht=Gt?.call(this);zt?.call(this,jt),this.requestUpdate(_e,Ht,Vt)},configurable:!0,enumerable:!0}}static getPropertyOptions(_e){return this.elementProperties.get(_e)??b}static _$Ei(){if(this.hasOwnProperty(d$1("elementProperties")))return;const _e=n$2(this);_e.finalize(),_e.l!==void 0&&(this.l=[..._e.l]),this.elementProperties=new Map(_e.elementProperties)}static finalize(){if(this.hasOwnProperty(d$1("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(d$1("properties"))){const Dt=this.properties,Vt=[...r$4(Dt),...o(Dt)];for(const Gt of Vt)this.createProperty(Gt,Dt[Gt])}const _e=this[Symbol.metadata];if(_e!==null){const Dt=litPropertyMetadata.get(_e);if(Dt!==void 0)for(const[Vt,Gt]of Dt)this.elementProperties.set(Vt,Gt)}this._$Eh=new Map;for(const[Dt,Vt]of this.elementProperties){const Gt=this._$Eu(Dt,Vt);Gt!==void 0&&this._$Eh.set(Gt,Dt)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(_e){const Dt=[];if(Array.isArray(_e)){const Vt=new Set(_e.flat(1/0).reverse());for(const Gt of Vt)Dt.unshift(c$3(Gt))}else _e!==void 0&&Dt.push(c$3(_e));return Dt}static _$Eu(_e,Dt){const Vt=Dt.attribute;return Vt===!1?void 0:typeof Vt=="string"?Vt:typeof _e=="string"?_e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(_e=>this.enableUpdating=_e),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(_e=>_e(this))}addController(_e){(this._$EO??=new Set).add(_e),this.renderRoot!==void 0&&this.isConnected&&_e.hostConnected?.()}removeController(_e){this._$EO?.delete(_e)}_$E_(){const _e=new Map,Dt=this.constructor.elementProperties;for(const Vt of Dt.keys())this.hasOwnProperty(Vt)&&(_e.set(Vt,this[Vt]),delete this[Vt]);_e.size>0&&(this._$Ep=_e)}createRenderRoot(){const _e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return S$2(_e,this.constructor.elementStyles),_e}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(_e=>_e.hostConnected?.())}enableUpdating(_e){}disconnectedCallback(){this._$EO?.forEach(_e=>_e.hostDisconnected?.())}attributeChangedCallback(_e,Dt,Vt){this._$AK(_e,Vt)}_$ET(_e,Dt){const Vt=this.constructor.elementProperties.get(_e),Gt=this.constructor._$Eu(_e,Vt);if(Gt!==void 0&&Vt.reflect===!0){const zt=(Vt.converter?.toAttribute!==void 0?Vt.converter:u$3).toAttribute(Dt,Vt.type);this._$Em=_e,zt==null?this.removeAttribute(Gt):this.setAttribute(Gt,zt),this._$Em=null}}_$AK(_e,Dt){const Vt=this.constructor,Gt=Vt._$Eh.get(_e);if(Gt!==void 0&&this._$Em!==Gt){const zt=Vt.getPropertyOptions(Gt),jt=typeof zt.converter=="function"?{fromAttribute:zt.converter}:zt.converter?.fromAttribute!==void 0?zt.converter:u$3;this._$Em=Gt;const Ht=jt.fromAttribute(Dt,zt.type);this[Gt]=Ht??this._$Ej?.get(Gt)??Ht,this._$Em=null}}requestUpdate(_e,Dt,Vt){if(_e!==void 0){const Gt=this.constructor,zt=this[_e];if(Vt??=Gt.getPropertyOptions(_e),!((Vt.hasChanged??f$2)(zt,Dt)||Vt.useDefault&&Vt.reflect&&zt===this._$Ej?.get(_e)&&!this.hasAttribute(Gt._$Eu(_e,Vt))))return;this.C(_e,Dt,Vt)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(_e,Dt,{useDefault:Vt,reflect:Gt,wrapped:zt},jt){Vt&&!(this._$Ej??=new Map).has(_e)&&(this._$Ej.set(_e,jt??Dt??this[_e]),zt!==!0||jt!==void 0)||(this._$AL.has(_e)||(this.hasUpdated||Vt||(Dt=void 0),this._$AL.set(_e,Dt)),Gt===!0&&this._$Em!==_e&&(this._$Eq??=new Set).add(_e))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(Dt){Promise.reject(Dt)}const _e=this.scheduleUpdate();return _e!=null&&await _e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[Gt,zt]of this._$Ep)this[Gt]=zt;this._$Ep=void 0}const Vt=this.constructor.elementProperties;if(Vt.size>0)for(const[Gt,zt]of Vt){const{wrapped:jt}=zt,Ht=this[Gt];jt!==!0||this._$AL.has(Gt)||Ht===void 0||this.C(Gt,void 0,zt,Ht)}}let _e=!1;const Dt=this._$AL;try{_e=this.shouldUpdate(Dt),_e?(this.willUpdate(Dt),this._$EO?.forEach(Vt=>Vt.hostUpdate?.()),this.update(Dt)):this._$EM()}catch(Vt){throw _e=!1,this._$EM(),Vt}_e&&this._$AE(Dt)}willUpdate(_e){}_$AE(_e){this._$EO?.forEach(Dt=>Dt.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(_e)),this.updated(_e)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(_e){return!0}update(_e){this._$Eq&&=this._$Eq.forEach(Dt=>this._$ET(Dt,this[Dt])),this._$EM()}updated(_e){}firstUpdated(_e){}};y$1.elementStyles=[],y$1.shadowRootOptions={mode:"open"},y$1[d$1("elementProperties")]=new Map,y$1[d$1("finalized")]=new Map,p$4?.({ReactiveElement:y$1}),(a.reactiveElementVersions??=[]).push("2.1.1");/**
58
+ */const{is:i$3,defineProperty:e$4,getOwnPropertyDescriptor:h$3,getOwnPropertyNames:r$4,getOwnPropertySymbols:o,getPrototypeOf:n$2}=Object,a=globalThis,c$2=a.trustedTypes,l$2=c$2?c$2.emptyScript:"",p$4=a.reactiveElementPolyfillSupport,d$1=(kt,_e)=>kt,u$3={toAttribute(kt,_e){switch(_e){case Boolean:kt=kt?l$2:null;break;case Object:case Array:kt=kt==null?kt:JSON.stringify(kt)}return kt},fromAttribute(kt,_e){let Dt=kt;switch(_e){case Boolean:Dt=kt!==null;break;case Number:Dt=kt===null?null:Number(kt);break;case Object:case Array:try{Dt=JSON.parse(kt)}catch{Dt=null}}return Dt}},f$2=(kt,_e)=>!i$3(kt,_e),b={attribute:!0,type:String,converter:u$3,reflect:!1,useDefault:!1,hasChanged:f$2};Symbol.metadata??=Symbol("metadata"),a.litPropertyMetadata??=new WeakMap;let y$1=class extends HTMLElement{static addInitializer(_e){this._$Ei(),(this.l??=[]).push(_e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(_e,Dt=b){if(Dt.state&&(Dt.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(_e)&&((Dt=Object.create(Dt)).wrapped=!0),this.elementProperties.set(_e,Dt),!Dt.noAccessor){const Vt=Symbol(),Gt=this.getPropertyDescriptor(_e,Vt,Dt);Gt!==void 0&&e$4(this.prototype,_e,Gt)}}static getPropertyDescriptor(_e,Dt,Vt){const{get:Gt,set:zt}=h$3(this.prototype,_e)??{get(){return this[Dt]},set(jt){this[Dt]=jt}};return{get:Gt,set(jt){const Ht=Gt?.call(this);zt?.call(this,jt),this.requestUpdate(_e,Ht,Vt)},configurable:!0,enumerable:!0}}static getPropertyOptions(_e){return this.elementProperties.get(_e)??b}static _$Ei(){if(this.hasOwnProperty(d$1("elementProperties")))return;const _e=n$2(this);_e.finalize(),_e.l!==void 0&&(this.l=[..._e.l]),this.elementProperties=new Map(_e.elementProperties)}static finalize(){if(this.hasOwnProperty(d$1("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(d$1("properties"))){const Dt=this.properties,Vt=[...r$4(Dt),...o(Dt)];for(const Gt of Vt)this.createProperty(Gt,Dt[Gt])}const _e=this[Symbol.metadata];if(_e!==null){const Dt=litPropertyMetadata.get(_e);if(Dt!==void 0)for(const[Vt,Gt]of Dt)this.elementProperties.set(Vt,Gt)}this._$Eh=new Map;for(const[Dt,Vt]of this.elementProperties){const Gt=this._$Eu(Dt,Vt);Gt!==void 0&&this._$Eh.set(Gt,Dt)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(_e){const Dt=[];if(Array.isArray(_e)){const Vt=new Set(_e.flat(1/0).reverse());for(const Gt of Vt)Dt.unshift(c$3(Gt))}else _e!==void 0&&Dt.push(c$3(_e));return Dt}static _$Eu(_e,Dt){const Vt=Dt.attribute;return Vt===!1?void 0:typeof Vt=="string"?Vt:typeof _e=="string"?_e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(_e=>this.enableUpdating=_e),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(_e=>_e(this))}addController(_e){(this._$EO??=new Set).add(_e),this.renderRoot!==void 0&&this.isConnected&&_e.hostConnected?.()}removeController(_e){this._$EO?.delete(_e)}_$E_(){const _e=new Map,Dt=this.constructor.elementProperties;for(const Vt of Dt.keys())this.hasOwnProperty(Vt)&&(_e.set(Vt,this[Vt]),delete this[Vt]);_e.size>0&&(this._$Ep=_e)}createRenderRoot(){const _e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return S$2(_e,this.constructor.elementStyles),_e}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(_e=>_e.hostConnected?.())}enableUpdating(_e){}disconnectedCallback(){this._$EO?.forEach(_e=>_e.hostDisconnected?.())}attributeChangedCallback(_e,Dt,Vt){this._$AK(_e,Vt)}_$ET(_e,Dt){const Vt=this.constructor.elementProperties.get(_e),Gt=this.constructor._$Eu(_e,Vt);if(Gt!==void 0&&Vt.reflect===!0){const zt=(Vt.converter?.toAttribute!==void 0?Vt.converter:u$3).toAttribute(Dt,Vt.type);this._$Em=_e,zt==null?this.removeAttribute(Gt):this.setAttribute(Gt,zt),this._$Em=null}}_$AK(_e,Dt){const Vt=this.constructor,Gt=Vt._$Eh.get(_e);if(Gt!==void 0&&this._$Em!==Gt){const zt=Vt.getPropertyOptions(Gt),jt=typeof zt.converter=="function"?{fromAttribute:zt.converter}:zt.converter?.fromAttribute!==void 0?zt.converter:u$3;this._$Em=Gt,this[Gt]=jt.fromAttribute(Dt,zt.type)??this._$Ej?.get(Gt)??null,this._$Em=null}}requestUpdate(_e,Dt,Vt){if(_e!==void 0){const Gt=this.constructor,zt=this[_e];if(Vt??=Gt.getPropertyOptions(_e),!((Vt.hasChanged??f$2)(zt,Dt)||Vt.useDefault&&Vt.reflect&&zt===this._$Ej?.get(_e)&&!this.hasAttribute(Gt._$Eu(_e,Vt))))return;this.C(_e,Dt,Vt)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(_e,Dt,{useDefault:Vt,reflect:Gt,wrapped:zt},jt){Vt&&!(this._$Ej??=new Map).has(_e)&&(this._$Ej.set(_e,jt??Dt??this[_e]),zt!==!0||jt!==void 0)||(this._$AL.has(_e)||(this.hasUpdated||Vt||(Dt=void 0),this._$AL.set(_e,Dt)),Gt===!0&&this._$Em!==_e&&(this._$Eq??=new Set).add(_e))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(Dt){Promise.reject(Dt)}const _e=this.scheduleUpdate();return _e!=null&&await _e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[Gt,zt]of this._$Ep)this[Gt]=zt;this._$Ep=void 0}const Vt=this.constructor.elementProperties;if(Vt.size>0)for(const[Gt,zt]of Vt){const{wrapped:jt}=zt,Ht=this[Gt];jt!==!0||this._$AL.has(Gt)||Ht===void 0||this.C(Gt,void 0,zt,Ht)}}let _e=!1;const Dt=this._$AL;try{_e=this.shouldUpdate(Dt),_e?(this.willUpdate(Dt),this._$EO?.forEach(Vt=>Vt.hostUpdate?.()),this.update(Dt)):this._$EM()}catch(Vt){throw _e=!1,this._$EM(),Vt}_e&&this._$AE(Dt)}willUpdate(_e){}_$AE(_e){this._$EO?.forEach(Dt=>Dt.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(_e)),this.updated(_e)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(_e){return!0}update(_e){this._$Eq&&=this._$Eq.forEach(Dt=>this._$ET(Dt,this[Dt])),this._$EM()}updated(_e){}firstUpdated(_e){}};y$1.elementStyles=[],y$1.shadowRootOptions={mode:"open"},y$1[d$1("elementProperties")]=new Map,y$1[d$1("finalized")]=new Map,p$4?.({ReactiveElement:y$1}),(a.reactiveElementVersions??=[]).push("2.1.0");/**
59
59
  * @license
60
60
  * Copyright 2017 Google LLC
61
61
  * SPDX-License-Identifier: BSD-3-Clause
@@ -4633,7 +4633,7 @@ ${zt.join(`
4633
4633
  float verticalAperture = ${kt.getFilmHeight().toPrecision(PRECISION)}
4634
4634
  }
4635
4635
 
4636
- `}class EventDispatcher{constructor(){this._listeners={}}addEventListener(_e,Dt){const Vt=this._listeners;return Vt[_e]===void 0&&(Vt[_e]=[]),Vt[_e].indexOf(Dt)===-1&&Vt[_e].push(Dt),this}removeEventListener(_e,Dt){if(this._listeners===void 0)return this;const Gt=this._listeners[_e];if(Gt!==void 0){const zt=Gt.indexOf(Dt);zt!==-1&&Gt.splice(zt,1)}return this}dispatchEvent(_e){if(this._listeners===void 0)return this;const Vt=this._listeners[_e.type];if(Vt!==void 0){const Gt=Vt.slice(0);for(let zt=0,jt=Gt.length;zt<jt;zt++)Gt[zt].call(this,_e)}return this}dispose(){for(const _e in this._listeners)delete this._listeners[_e]}}class GraphEdge extends EventDispatcher{constructor(_e,Dt,Vt,Gt={}){if(super(),this._name=void 0,this._parent=void 0,this._child=void 0,this._attributes=void 0,this._disposed=!1,this._name=_e,this._parent=Dt,this._child=Vt,this._attributes=Gt,!Dt.isOnGraph(Vt))throw new Error("Cannot connect disconnected graphs.")}getName(){return this._name}getParent(){return this._parent}getChild(){return this._child}setChild(_e){return this._child=_e,this}getAttributes(){return this._attributes}dispose(){this._disposed||(this._disposed=!0,this.dispatchEvent({type:"dispose",target:this}),super.dispose())}isDisposed(){return this._disposed}}class Graph extends EventDispatcher{constructor(..._e){super(..._e),this._emptySet=new Set,this._edges=new Set,this._parentEdges=new Map,this._childEdges=new Map}listEdges(){return Array.from(this._edges)}listParentEdges(_e){return Array.from(this._childEdges.get(_e)||this._emptySet)}listParents(_e){return this.listParentEdges(_e).map(Dt=>Dt.getParent())}listChildEdges(_e){return Array.from(this._parentEdges.get(_e)||this._emptySet)}listChildren(_e){return this.listChildEdges(_e).map(Dt=>Dt.getChild())}disconnectParents(_e,Dt){let Vt=this.listParentEdges(_e);return Dt&&(Vt=Vt.filter(Gt=>Dt(Gt.getParent()))),Vt.forEach(Gt=>Gt.dispose()),this}createEdge(_e,Dt,Vt,Gt){return this._registerEdge(new GraphEdge(_e,Dt,Vt,Gt))}_registerEdge(_e){this._edges.add(_e);const Dt=_e.getParent();this._parentEdges.has(Dt)||this._parentEdges.set(Dt,new Set),this._parentEdges.get(Dt).add(_e);const Vt=_e.getChild();return this._childEdges.has(Vt)||this._childEdges.set(Vt,new Set),this._childEdges.get(Vt).add(_e),_e.addEventListener("dispose",()=>this._removeEdge(_e)),_e}_removeEdge(_e){return this._edges.delete(_e),this._parentEdges.get(_e.getParent()).delete(_e),this._childEdges.get(_e.getChild()).delete(_e),this}}function _extends(){return _extends=Object.assign||function(kt){for(var _e=1;_e<arguments.length;_e++){var Dt=arguments[_e];for(var Vt in Dt)Object.prototype.hasOwnProperty.call(Dt,Vt)&&(kt[Vt]=Dt[Vt])}return kt},_extends.apply(this,arguments)}function isRef(kt){return kt instanceof GraphEdge}function isRefList(kt){return Array.isArray(kt)&&kt[0]instanceof GraphEdge}function isRefMap(kt){return!!(isPlainObject(kt)&&getFirstValue(kt)instanceof GraphEdge)}function getFirstValue(kt){for(const _e in kt)return kt[_e]}function isPlainObject(kt){return!!kt&&Object.getPrototypeOf(kt)===Object.prototype}const $attributes=Symbol("attributes"),$immutableKeys=Symbol("immutableKeys");class GraphNode extends EventDispatcher{constructor(_e){super(),this._disposed=!1,this.graph=void 0,this[$attributes]=void 0,this[$immutableKeys]=void 0,this.graph=_e,this[$immutableKeys]=new Set,this[$attributes]=this._createAttributes()}getDefaults(){return{}}_createAttributes(){const _e=this.getDefaults(),Dt={};for(const Vt in _e){const Gt=_e[Vt];if(Gt instanceof GraphNode){const zt=this.graph.createEdge(Vt,this,Gt);zt.addEventListener("dispose",()=>Gt.dispose()),this[$immutableKeys].add(Vt),Dt[Vt]=zt}else Dt[Vt]=Gt}return Dt}isOnGraph(_e){return this.graph===_e.graph}isDisposed(){return this._disposed}dispose(){this._disposed||(this.graph.listChildEdges(this).forEach(_e=>_e.dispose()),this.graph.disconnectParents(this),this._disposed=!0,this.dispatchEvent({type:"dispose"}))}detach(){return this.graph.disconnectParents(this),this}swap(_e,Dt){for(const Vt in this[$attributes]){const Gt=this[$attributes][Vt];if(isRef(Gt)){const zt=Gt;zt.getChild()===_e&&this.setRef(Vt,Dt,zt.getAttributes())}else if(isRefList(Gt)){const jt=Gt.find(Ht=>Ht.getChild()===_e);if(jt){const Ht=jt.getAttributes();this.removeRef(Vt,_e).addRef(Vt,Dt,Ht)}}else if(isRefMap(Gt)){const zt=Gt;for(const jt in zt){const Ht=zt[jt];Ht.getChild()===_e&&this.setRefMap(Vt,jt,Dt,Ht.getAttributes())}}}return this}get(_e){return this[$attributes][_e]}set(_e,Dt){return this[$attributes][_e]=Dt,this.dispatchEvent({type:"change",attribute:_e})}getRef(_e){const Dt=this[$attributes][_e];return Dt?Dt.getChild():null}setRef(_e,Dt,Vt){if(this[$immutableKeys].has(_e))throw new Error(`Cannot overwrite immutable attribute, "${_e}".`);const Gt=this[$attributes][_e];if(Gt&&Gt.dispose(),!Dt)return this;const zt=this.graph.createEdge(_e,this,Dt,Vt);return zt.addEventListener("dispose",()=>{delete this[$attributes][_e],this.dispatchEvent({type:"change",attribute:_e})}),this[$attributes][_e]=zt,this.dispatchEvent({type:"change",attribute:_e})}listRefs(_e){return this[$attributes][_e].map(Vt=>Vt.getChild())}addRef(_e,Dt,Vt){const Gt=this.graph.createEdge(_e,this,Dt,Vt),zt=this[$attributes][_e];return zt.push(Gt),Gt.addEventListener("dispose",()=>{let jt;for(;(jt=zt.indexOf(Gt))!==-1;)zt.splice(jt,1);this.dispatchEvent({type:"change",attribute:_e})}),this.dispatchEvent({type:"change",attribute:_e})}removeRef(_e,Dt){return this[$attributes][_e].filter(zt=>zt.getChild()===Dt).forEach(zt=>zt.dispose()),this}listRefMapKeys(_e){return Object.keys(this[$attributes][_e])}listRefMapValues(_e){return Object.values(this[$attributes][_e]).map(Dt=>Dt.getChild())}getRefMap(_e,Dt){const Vt=this[$attributes][_e];return Vt[Dt]?Vt[Dt].getChild():null}setRefMap(_e,Dt,Vt,Gt){const zt=this[$attributes][_e],jt=zt[Dt];if(jt&&jt.dispose(),!Vt)return this;Gt=Object.assign(Gt||{},{key:Dt});const Ht=this.graph.createEdge(_e,this,Vt,_extends({},Gt,{key:Dt}));return Ht.addEventListener("dispose",()=>{delete zt[Dt],this.dispatchEvent({type:"change",attribute:_e,key:Dt})}),zt[Dt]=Ht,this.dispatchEvent({type:"change",attribute:_e,key:Dt})}dispatchEvent(_e){return super.dispatchEvent(_extends({},_e,{target:this})),this.graph.dispatchEvent(_extends({},_e,{target:this,type:`node:${_e.type}`})),this}}const u="v3.7.3",c="@glb.bin";var h,f,l,d,g;(function(kt){kt.ACCESSOR="Accessor",kt.ANIMATION="Animation",kt.ANIMATION_CHANNEL="AnimationChannel",kt.ANIMATION_SAMPLER="AnimationSampler",kt.BUFFER="Buffer",kt.CAMERA="Camera",kt.MATERIAL="Material",kt.MESH="Mesh",kt.PRIMITIVE="Primitive",kt.PRIMITIVE_TARGET="PrimitiveTarget",kt.NODE="Node",kt.ROOT="Root",kt.SCENE="Scene",kt.SKIN="Skin",kt.TEXTURE="Texture",kt.TEXTURE_INFO="TextureInfo"})(h||(h={})),function(kt){kt.INTERLEAVED="interleaved",kt.SEPARATE="separate"}(f||(f={})),function(kt){kt.ARRAY_BUFFER="ARRAY_BUFFER",kt.ELEMENT_ARRAY_BUFFER="ELEMENT_ARRAY_BUFFER",kt.INVERSE_BIND_MATRICES="INVERSE_BIND_MATRICES",kt.OTHER="OTHER",kt.SPARSE="SPARSE"}(l||(l={})),function(kt){kt[kt.R=4096]="R",kt[kt.G=256]="G",kt[kt.B=16]="B",kt[kt.A=1]="A"}(d||(d={})),function(kt){kt.GLTF="GLTF",kt.GLB="GLB"}(g||(g={}));const p={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};var m,w=typeof Float32Array<"u"?Float32Array:Array;function y(kt){return Math.hypot(kt[0],kt[1],kt[2])}Math.hypot||(Math.hypot=function(){for(var kt=0,_e=arguments.length;_e--;)kt+=arguments[_e]*arguments[_e];return Math.sqrt(kt)}),m=new w(3),w!=Float32Array&&(m[0]=0,m[1]=0,m[2]=0);class E{static createBufferFromDataURI(_e){if(typeof Buffer>"u"){const Dt=atob(_e.split(",")[1]),Vt=new Uint8Array(Dt.length);for(let Gt=0;Gt<Dt.length;Gt++)Vt[Gt]=Dt.charCodeAt(Gt);return Vt}{const Dt=_e.split(",")[1],Vt=_e.indexOf("base64")>=0;return Buffer.from(Dt,Vt?"base64":"utf8")}}static encodeText(_e){return typeof TextEncoder<"u"?new TextEncoder().encode(_e):Buffer.from(_e)}static decodeText(_e){return typeof TextDecoder<"u"?new TextDecoder().decode(_e):Buffer.from(_e).toString("utf8")}static concat(_e){let Dt=0;for(const zt of _e)Dt+=zt.byteLength;const Vt=new Uint8Array(Dt);let Gt=0;for(const zt of _e)Vt.set(zt,Gt),Gt+=zt.byteLength;return Vt}static pad(_e,Dt=0){const Vt=this.padNumber(_e.byteLength);if(Vt===_e.byteLength)return _e;const Gt=new Uint8Array(Vt);if(Gt.set(_e),Dt!==0)for(let zt=_e.byteLength;zt<Vt;zt++)Gt[zt]=Dt;return Gt}static padNumber(_e){return 4*Math.ceil(_e/4)}static equals(_e,Dt){if(_e===Dt)return!0;if(_e.byteLength!==Dt.byteLength)return!1;let Vt=_e.byteLength;for(;Vt--;)if(_e[Vt]!==Dt[Vt])return!1;return!0}static toView(_e,Dt=0,Vt=1/0){return new Uint8Array(_e.buffer,_e.byteOffset+Dt,Math.min(_e.byteLength,Vt))}static assertView(_e){if(_e&&!ArrayBuffer.isView(_e))throw new Error(`Method requires Uint8Array parameter; received "${typeof _e}".`);return _e}}class S{static hexToFactor(_e,Dt){_e=Math.floor(_e);const Vt=Dt;return Vt[0]=(_e>>16&255)/255,Vt[1]=(_e>>8&255)/255,Vt[2]=(255&_e)/255,this.convertSRGBToLinear(Dt,Dt)}static factorToHex(_e){const Dt=[..._e],[Vt,Gt,zt]=this.convertLinearToSRGB(_e,Dt);return 255*Vt<<16^255*Gt<<8^255*zt<<0}static convertSRGBToLinear(_e,Dt){const Vt=_e,Gt=Dt;for(let zt=0;zt<3;zt++)Gt[zt]=Vt[zt]<.04045?.0773993808*Vt[zt]:Math.pow(.9478672986*Vt[zt]+.0521327014,2.4);return Dt}static convertLinearToSRGB(_e,Dt){const Vt=_e,Gt=Dt;for(let zt=0;zt<3;zt++)Gt[zt]=Vt[zt]<.0031308?12.92*Vt[zt]:1.055*Math.pow(Vt[zt],.41666)-.055;return Dt}}class M{match(_e){return _e.length>=8&&_e[0]===137&&_e[1]===80&&_e[2]===78&&_e[3]===71&&_e[4]===13&&_e[5]===10&&_e[6]===26&&_e[7]===10}getSize(_e){const Dt=new DataView(_e.buffer,_e.byteOffset);return E.decodeText(_e.slice(12,16))===M.PNG_FRIED_CHUNK_NAME?[Dt.getUint32(32,!1),Dt.getUint32(36,!1)]:[Dt.getUint32(16,!1),Dt.getUint32(20,!1)]}getChannels(_e){return 4}}M.PNG_FRIED_CHUNK_NAME="CgBI";class I{static registerFormat(_e,Dt){this.impls[_e]=Dt}static getMimeType(_e){for(const Dt in this.impls)if(this.impls[Dt].match(_e))return Dt;return null}static getSize(_e,Dt){return this.impls[Dt]?this.impls[Dt].getSize(_e):null}static getChannels(_e,Dt){return this.impls[Dt]?this.impls[Dt].getChannels(_e):null}static getVRAMByteLength(_e,Dt){if(!this.impls[Dt])return null;if(this.impls[Dt].getVRAMByteLength)return this.impls[Dt].getVRAMByteLength(_e);let Vt=0;const Gt=this.getSize(_e,Dt);if(!Gt)return null;for(;Gt[0]>1||Gt[1]>1;)Vt+=Gt[0]*Gt[1]*4,Gt[0]=Math.max(Math.floor(Gt[0]/2),1),Gt[1]=Math.max(Math.floor(Gt[1]/2),1);return Vt+=4,Vt}static mimeTypeToExtension(_e){return _e==="image/jpeg"?"jpg":_e.split("/").pop()}static extensionToMimeType(_e){return _e==="jpg"?"image/jpeg":_e?`image/${_e}`:""}}function R(kt,_e){if(_e>kt.byteLength)throw new TypeError("Corrupt JPG, exceeded buffer limits");if(kt.getUint8(_e)!==255)throw new TypeError("Invalid JPG, marker table corrupted");return kt}I.impls={"image/jpeg":new class{match(kt){return kt.length>=3&&kt[0]===255&&kt[1]===216&&kt[2]===255}getSize(kt){let _e,Dt,Vt=new DataView(kt.buffer,kt.byteOffset+4);for(;Vt.byteLength;){if(_e=Vt.getUint16(0,!1),R(Vt,_e),Dt=Vt.getUint8(_e+1),Dt===192||Dt===193||Dt===194)return[Vt.getUint16(_e+7,!1),Vt.getUint16(_e+5,!1)];Vt=new DataView(kt.buffer,Vt.byteOffset+_e+2)}throw new TypeError("Invalid JPG, no size found")}getChannels(kt){return 3}},"image/png":new M};class N{static basename(_e){const Dt=_e.split(/[\\/]/).pop();return Dt.substring(0,Dt.lastIndexOf("."))}static extension(_e){if(_e.startsWith("data:image/")){const Dt=_e.match(/data:(image\/\w+)/)[1];return I.mimeTypeToExtension(Dt)}return _e.startsWith("data:model/gltf+json")?"gltf":_e.startsWith("data:model/gltf-binary")?"glb":_e.startsWith("data:application/")?"bin":_e.split(/[\\/]/).pop().split(/[.]/).pop()}}function O(kt){return Object.prototype.toString.call(kt)==="[object Object]"}function C(kt){if(O(kt)===!1)return!1;const _e=kt.constructor;if(_e===void 0)return!0;const Dt=_e.prototype;return O(Dt)!==!1&&Object.prototype.hasOwnProperty.call(Dt,"isPrototypeOf")!==!1}var F,U;(function(kt){kt[kt.SILENT=4]="SILENT",kt[kt.ERROR=3]="ERROR",kt[kt.WARN=2]="WARN",kt[kt.INFO=1]="INFO",kt[kt.DEBUG=0]="DEBUG"})(U||(U={}));let B$1=class Ql{constructor(_e){this.verbosity=void 0,this.verbosity=_e}debug(_e){this.verbosity<=Ql.Verbosity.DEBUG&&console.debug(_e)}info(_e){this.verbosity<=Ql.Verbosity.INFO&&console.info(_e)}warn(_e){this.verbosity<=Ql.Verbosity.WARN&&console.warn(_e)}error(_e){this.verbosity<=Ql.Verbosity.ERROR&&console.error(_e)}};function P(kt,_e,Dt){var Vt=_e[0],Gt=_e[1],zt=_e[2],jt=_e[3],Ht=_e[4],Wt=_e[5],qt=_e[6],Xt=_e[7],Kt=_e[8],Yt=_e[9],Zt=_e[10],Jt=_e[11],nn=_e[12],rn=_e[13],Qt=_e[14],en=_e[15],tn=Dt[0],sn=Dt[1],cn=Dt[2],un=Dt[3];return kt[0]=tn*Vt+sn*Ht+cn*Kt+un*nn,kt[1]=tn*Gt+sn*Wt+cn*Yt+un*rn,kt[2]=tn*zt+sn*qt+cn*Zt+un*Qt,kt[3]=tn*jt+sn*Xt+cn*Jt+un*en,kt[4]=(tn=Dt[4])*Vt+(sn=Dt[5])*Ht+(cn=Dt[6])*Kt+(un=Dt[7])*nn,kt[5]=tn*Gt+sn*Wt+cn*Yt+un*rn,kt[6]=tn*zt+sn*qt+cn*Zt+un*Qt,kt[7]=tn*jt+sn*Xt+cn*Jt+un*en,kt[8]=(tn=Dt[8])*Vt+(sn=Dt[9])*Ht+(cn=Dt[10])*Kt+(un=Dt[11])*nn,kt[9]=tn*Gt+sn*Wt+cn*Yt+un*rn,kt[10]=tn*zt+sn*qt+cn*Zt+un*Qt,kt[11]=tn*jt+sn*Xt+cn*Jt+un*en,kt[12]=(tn=Dt[12])*Vt+(sn=Dt[13])*Ht+(cn=Dt[14])*Kt+(un=Dt[15])*nn,kt[13]=tn*Gt+sn*Wt+cn*Yt+un*rn,kt[14]=tn*zt+sn*qt+cn*Zt+un*Qt,kt[15]=tn*jt+sn*Xt+cn*Jt+un*en,kt}F=B$1,B$1.Verbosity=U,B$1.DEFAULT_INSTANCE=new F(F.Verbosity.INFO);class L{static identity(_e){return _e}static eq(_e,Dt,Vt=1e-5){if(_e.length!==Dt.length)return!1;for(let Gt=0;Gt<_e.length;Gt++)if(Math.abs(_e[Gt]-Dt[Gt])>Vt)return!1;return!0}static decodeNormalizedInt(_e,Dt){switch(Dt){case 5126:return _e;case 5123:return _e/65535;case 5121:return _e/255;case 5122:return Math.max(_e/32767,-1);case 5120:return Math.max(_e/127,-1);default:throw new Error("Invalid component type.")}}static denormalize(_e,Dt){return L.decodeNormalizedInt(_e,Dt)}static encodeNormalizedInt(_e,Dt){switch(Dt){case 5126:return _e;case 5123:return Math.round(65535*_e);case 5121:return Math.round(255*_e);case 5122:return Math.round(32767*_e);case 5120:return Math.round(127*_e);default:throw new Error("Invalid component type.")}}static normalize(_e,Dt){return L.encodeNormalizedInt(_e,Dt)}static decompose(_e,Dt,Vt,Gt){let zt=y([_e[0],_e[1],_e[2]]);const jt=y([_e[4],_e[5],_e[6]]),Ht=y([_e[8],_e[9],_e[10]]);var Wt,qt,Xt,Kt,Yt,Zt,Jt,nn,rn,Qt,en,tn,sn,cn,un,hn,fn;((qt=(Wt=_e)[0])*(Jt=Wt[5])-(Xt=Wt[1])*(Zt=Wt[4]))*((tn=Wt[10])*(fn=Wt[15])-(sn=Wt[11])*(hn=Wt[14]))-(qt*(nn=Wt[6])-(Kt=Wt[2])*Zt)*((en=Wt[9])*fn-sn*(un=Wt[13]))+(qt*(rn=Wt[7])-(Yt=Wt[3])*Zt)*(en*hn-tn*un)+(Xt*nn-Kt*Jt)*((Qt=Wt[8])*fn-sn*(cn=Wt[12]))-(Xt*rn-Yt*Jt)*(Qt*hn-tn*cn)+(Kt*rn-Yt*nn)*(Qt*un-en*cn)<0&&(zt=-zt),Dt[0]=_e[12],Dt[1]=_e[13],Dt[2]=_e[14];const pn=_e.slice(),dn=1/zt,mn=1/jt,vn=1/Ht;pn[0]*=dn,pn[1]*=dn,pn[2]*=dn,pn[4]*=mn,pn[5]*=mn,pn[6]*=mn,pn[8]*=vn,pn[9]*=vn,pn[10]*=vn,function(_n,En){var An=new w(3);(function(ar,zn){var ur=zn[4],Hn=zn[5],sr=zn[6],gr=zn[8],fr=zn[9],Un=zn[10];ar[0]=Math.hypot(zn[0],zn[1],zn[2]),ar[1]=Math.hypot(ur,Hn,sr),ar[2]=Math.hypot(gr,fr,Un)})(An,En);var Tn=1/An[0],Cn=1/An[1],yn=1/An[2],Sn=En[0]*Tn,wn=En[1]*Cn,xn=En[2]*yn,Rn=En[4]*Tn,Dn=En[5]*Cn,kn=En[6]*yn,Fn=En[8]*Tn,Pn=En[9]*Cn,Bn=En[10]*yn,qn=Sn+Dn+Bn,tr=0;qn>0?(tr=2*Math.sqrt(qn+1),_n[3]=.25*tr,_n[0]=(kn-Pn)/tr,_n[1]=(Fn-xn)/tr,_n[2]=(wn-Rn)/tr):Sn>Dn&&Sn>Bn?(tr=2*Math.sqrt(1+Sn-Dn-Bn),_n[3]=(kn-Pn)/tr,_n[0]=.25*tr,_n[1]=(wn+Rn)/tr,_n[2]=(Fn+xn)/tr):Dn>Bn?(tr=2*Math.sqrt(1+Dn-Sn-Bn),_n[3]=(Fn-xn)/tr,_n[0]=(wn+Rn)/tr,_n[1]=.25*tr,_n[2]=(kn+Pn)/tr):(tr=2*Math.sqrt(1+Bn-Sn-Dn),_n[3]=(wn-Rn)/tr,_n[0]=(Fn+xn)/tr,_n[1]=(kn+Pn)/tr,_n[2]=.25*tr)}(Vt,pn),Gt[0]=zt,Gt[1]=jt,Gt[2]=Ht}static compose(_e,Dt,Vt,Gt){const zt=Gt,jt=Dt[0],Ht=Dt[1],Wt=Dt[2],qt=Dt[3],Xt=jt+jt,Kt=Ht+Ht,Yt=Wt+Wt,Zt=jt*Xt,Jt=jt*Kt,nn=jt*Yt,rn=Ht*Kt,Qt=Ht*Yt,en=Wt*Yt,tn=qt*Xt,sn=qt*Kt,cn=qt*Yt,un=Vt[0],hn=Vt[1],fn=Vt[2];return zt[0]=(1-(rn+en))*un,zt[1]=(Jt+cn)*un,zt[2]=(nn-sn)*un,zt[3]=0,zt[4]=(Jt-cn)*hn,zt[5]=(1-(Zt+en))*hn,zt[6]=(Qt+tn)*hn,zt[7]=0,zt[8]=(nn+sn)*fn,zt[9]=(Qt-tn)*fn,zt[10]=(1-(Zt+rn))*fn,zt[11]=0,zt[12]=_e[0],zt[13]=_e[1],zt[14]=_e[2],zt[15]=1,zt}}function j(kt,_e){if(!!kt!=!!_e)return!1;const Dt=kt.getChild(),Vt=_e.getChild();return Dt===Vt||Dt.equals(Vt)}function D(kt,_e){if(!!kt!=!!_e||kt.length!==_e.length)return!1;for(let Dt=0;Dt<kt.length;Dt++){const Vt=kt[Dt],Gt=_e[Dt];if(Vt.getChild()!==Gt.getChild()&&!Vt.getChild().equals(Gt.getChild()))return!1}return!0}function _(kt,_e){if(!!kt!=!!_e)return!1;const Dt=Object.keys(kt),Vt=Object.keys(_e);if(Dt.length!==Vt.length)return!1;for(const Gt in kt){const zt=kt[Gt],jt=_e[Gt];if(!!zt!=!!jt)return!1;const Ht=zt.getChild(),Wt=jt.getChild();if(Ht!==Wt&&!Ht.equals(Wt))return!1}return!0}function k(kt,_e){if(kt===_e)return!0;if(!!kt!=!!_e||!kt||!_e||kt.length!==_e.length)return!1;for(let Dt=0;Dt<kt.length;Dt++)if(kt[Dt]!==_e[Dt])return!1;return!0}function z(kt,_e){if(kt===_e)return!0;if(!!kt!=!!_e)return!1;if(!C(kt)||!C(_e))return kt===_e;const Dt=kt,Vt=_e;let Gt,zt=0,jt=0;for(Gt in Dt)zt++;for(Gt in Vt)jt++;if(zt!==jt)return!1;for(Gt in Dt){const Ht=Dt[Gt],Wt=Vt[Gt];if(G(Ht)&&G(Wt)){if(!k(Ht,Wt))return!1}else if(C(Ht)&&C(Wt)){if(!z(Ht,Wt))return!1}else if(Ht!==Wt)return!1}return!0}function G(kt){return Array.isArray(kt)||ArrayBuffer.isView(kt)}const J=new Set,$=function(){let kt="";for(let _e=0;_e<6;_e++)kt+="23456789abdegjkmnpqrvwxyzABDEGJKMNPQRVWXYZ".charAt(Math.floor(42*Math.random()));return kt},V=function(){for(let kt=0;kt<999;kt++){const _e=$();if(!J.has(_e))return J.add(_e),_e}return""},W="https://null.example";let q$1=class{static dirname(_e){const Dt=_e.lastIndexOf("/");return Dt===-1?"./":_e.substring(0,Dt+1)}static basename(_e){return N.basename(new URL(_e,W).pathname)}static extension(_e){return N.extension(new URL(_e,W).pathname)}static resolve(_e,Dt){if(!this.isRelativePath(Dt))return Dt;const Vt=_e.split("/"),Gt=Dt.split("/");Vt.pop();for(let zt=0;zt<Gt.length;zt++)Gt[zt]!=="."&&(Gt[zt]===".."?Vt.pop():Vt.push(Gt[zt]));return Vt.join("/")}static isAbsoluteURL(_e){return this.PROTOCOL_REGEXP.test(_e)}static isRelativePath(_e){return!/^(?:[a-zA-Z]+:)?\//.test(_e)}};q$1.DEFAULT_INIT={},q$1.PROTOCOL_REGEXP=/^[a-zA-Z]+:\/\//;const H=kt=>kt,Y=new Set;let Z$1=class extends GraphNode{constructor(_e,Dt=""){super(_e),this[$attributes].name=Dt,this.init(),this.dispatchEvent({type:"create"})}getGraph(){return this.graph}getDefaults(){return Object.assign(super.getDefaults(),{name:"",extras:{}})}set(_e,Dt){return Array.isArray(Dt)&&(Dt=Dt.slice()),super.set(_e,Dt)}getName(){return this.get("name")}setName(_e){return this.set("name",_e)}getExtras(){return this.get("extras")}setExtras(_e){return this.set("extras",_e)}clone(){return new this.constructor(this.graph).copy(this,H)}copy(_e,Dt=H){for(const Vt in this[$attributes]){const Gt=this[$attributes][Vt];if(Gt instanceof GraphEdge)this[$immutableKeys].has(Vt)||Gt.dispose();else if(isRefList(Gt))for(const zt of Gt)zt.dispose();else if(isRefMap(Gt))for(const zt in Gt)Gt[zt].dispose()}for(const Vt in _e[$attributes]){const Gt=this[$attributes][Vt],zt=_e[$attributes][Vt];if(zt instanceof GraphEdge)this[$immutableKeys].has(Vt)?Gt.getChild().copy(Dt(zt.getChild()),Dt):this.setRef(Vt,Dt(zt.getChild()),zt.getAttributes());else if(isRefList(zt))for(const jt of zt)this.addRef(Vt,Dt(jt.getChild()),jt.getAttributes());else if(isRefMap(zt))for(const jt in zt){const Ht=zt[jt];this.setRefMap(Vt,jt,Dt(Ht.getChild()),Ht.getAttributes())}else this[$attributes][Vt]=C(zt)?JSON.parse(JSON.stringify(zt)):Array.isArray(zt)||zt instanceof ArrayBuffer||ArrayBuffer.isView(zt)?zt.slice():zt}return this}equals(_e,Dt=Y){if(this===_e)return!0;if(this.propertyType!==_e.propertyType)return!1;for(const Vt in this[$attributes]){if(Dt.has(Vt))continue;const Gt=this[$attributes][Vt],zt=_e[$attributes][Vt];if(isRef(Gt)||isRef(zt)){if(!j(Gt,zt))return!1}else if(isRefList(Gt)||isRefList(zt)){if(!D(Gt,zt))return!1}else if(isRefMap(Gt)||isRefMap(zt)){if(!_(Gt,zt))return!1}else if(C(Gt)||C(zt)){if(!z(Gt,zt))return!1}else if(G(Gt)||G(zt)){if(!k(Gt,zt))return!1}else if(Gt!==zt)return!1}return!0}detach(){return this.graph.disconnectParents(this,_e=>_e.propertyType!=="Root"),this}listParents(){return this.graph.listParents(this)}};class K extends Z$1{getDefaults(){return Object.assign(super.getDefaults(),{extensions:{}})}getExtension(_e){return this.getRefMap("extensions",_e)}setExtension(_e,Dt){return Dt&&Dt.t(this),this.setRefMap("extensions",_e,Dt)}listExtensions(){return this.listRefMapValues("extensions")}}class Q extends K{constructor(..._e){super(..._e),this.i=L.identity,this.o=L.identity}init(){this.propertyType=h.ACCESSOR}getDefaults(){return Object.assign(super.getDefaults(),{array:null,type:Q.Type.SCALAR,componentType:Q.ComponentType.FLOAT,normalized:!1,sparse:!1,buffer:null})}copy(_e,Dt=H){return super.copy(_e,Dt),this.i=_e.i,this.o=_e.o,this}static getElementSize(_e){switch(_e){case Q.Type.SCALAR:return 1;case Q.Type.VEC2:return 2;case Q.Type.VEC3:return 3;case Q.Type.VEC4:case Q.Type.MAT2:return 4;case Q.Type.MAT3:return 9;case Q.Type.MAT4:return 16;default:throw new Error("Unexpected type: "+_e)}}static getComponentSize(_e){switch(_e){case Q.ComponentType.BYTE:case Q.ComponentType.UNSIGNED_BYTE:return 1;case Q.ComponentType.SHORT:case Q.ComponentType.UNSIGNED_SHORT:return 2;case Q.ComponentType.UNSIGNED_INT:case Q.ComponentType.FLOAT:return 4;default:throw new Error("Unexpected component type: "+_e)}}getMinNormalized(_e){const Dt=this.getElementSize();this.getMin(_e);for(let Vt=0;Vt<Dt;Vt++)_e[Vt]=this.o(_e[Vt]);return _e}getMin(_e){const Dt=this.get("array"),Vt=this.getCount(),Gt=this.getElementSize();for(let zt=0;zt<Gt;zt++)_e[zt]=1/0;for(let zt=0;zt<Vt*Gt;zt+=Gt)for(let jt=0;jt<Gt;jt++){const Ht=Dt[zt+jt];Number.isFinite(Ht)&&(_e[jt]=Math.min(_e[jt],Ht))}return _e}getMaxNormalized(_e){const Dt=this.getElementSize();this.getMax(_e);for(let Vt=0;Vt<Dt;Vt++)_e[Vt]=this.o(_e[Vt]);return _e}getMax(_e){const Dt=this.get("array"),Vt=this.getCount(),Gt=this.getElementSize();for(let zt=0;zt<Gt;zt++)_e[zt]=-1/0;for(let zt=0;zt<Vt*Gt;zt+=Gt)for(let jt=0;jt<Gt;jt++){const Ht=Dt[zt+jt];Number.isFinite(Ht)&&(_e[jt]=Math.max(_e[jt],Ht))}return _e}getCount(){const _e=this.get("array");return _e?_e.length/this.getElementSize():0}getType(){return this.get("type")}setType(_e){return this.set("type",_e)}getElementSize(){return Q.getElementSize(this.get("type"))}getComponentSize(){return this.get("array").BYTES_PER_ELEMENT}getComponentType(){return this.get("componentType")}getNormalized(){return this.get("normalized")}setNormalized(_e){return this.set("normalized",_e),_e?(this.o=Dt=>L.decodeNormalizedInt(Dt,this.get("componentType")),this.i=Dt=>L.encodeNormalizedInt(Dt,this.get("componentType"))):(this.o=L.identity,this.i=L.identity),this}getScalar(_e){const Dt=this.getElementSize();return this.o(this.get("array")[_e*Dt])}setScalar(_e,Dt){return this.get("array")[_e*this.getElementSize()]=this.i(Dt),this}getElement(_e,Dt){const Vt=this.getElementSize(),Gt=this.get("array");for(let zt=0;zt<Vt;zt++)Dt[zt]=this.o(Gt[_e*Vt+zt]);return Dt}setElement(_e,Dt){const Vt=this.getElementSize(),Gt=this.get("array");for(let zt=0;zt<Vt;zt++)Gt[_e*Vt+zt]=this.i(Dt[zt]);return this}getSparse(){return this.get("sparse")}setSparse(_e){return this.set("sparse",_e)}getBuffer(){return this.getRef("buffer")}setBuffer(_e){return this.setRef("buffer",_e)}getArray(){return this.get("array")}setArray(_e){return this.set("componentType",_e?function(Dt){switch(Dt.constructor){case Float32Array:return Q.ComponentType.FLOAT;case Uint32Array:return Q.ComponentType.UNSIGNED_INT;case Uint16Array:return Q.ComponentType.UNSIGNED_SHORT;case Uint8Array:return Q.ComponentType.UNSIGNED_BYTE;case Int16Array:return Q.ComponentType.SHORT;case Int8Array:return Q.ComponentType.BYTE;default:throw new Error("Unknown accessor componentType.")}}(_e):Q.ComponentType.FLOAT),this.set("array",_e),this}getByteLength(){const _e=this.get("array");return _e?_e.byteLength:0}}Q.Type={SCALAR:"SCALAR",VEC2:"VEC2",VEC3:"VEC3",VEC4:"VEC4",MAT2:"MAT2",MAT3:"MAT3",MAT4:"MAT4"},Q.ComponentType={BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,UNSIGNED_INT:5125,FLOAT:5126};class X extends K{init(){this.propertyType=h.ANIMATION}getDefaults(){return Object.assign(super.getDefaults(),{channels:[],samplers:[]})}addChannel(_e){return this.addRef("channels",_e)}removeChannel(_e){return this.removeRef("channels",_e)}listChannels(){return this.listRefs("channels")}addSampler(_e){return this.addRef("samplers",_e)}removeSampler(_e){return this.removeRef("samplers",_e)}listSamplers(){return this.listRefs("samplers")}}class tt extends K{init(){this.propertyType=h.ANIMATION_CHANNEL}getDefaults(){return Object.assign(super.getDefaults(),{targetPath:null,targetNode:null,sampler:null})}getTargetPath(){return this.get("targetPath")}setTargetPath(_e){return this.set("targetPath",_e)}getTargetNode(){return this.getRef("targetNode")}setTargetNode(_e){return this.setRef("targetNode",_e)}getSampler(){return this.getRef("sampler")}setSampler(_e){return this.setRef("sampler",_e)}}tt.TargetPath={TRANSLATION:"translation",ROTATION:"rotation",SCALE:"scale",WEIGHTS:"weights"};class et extends K{init(){this.propertyType=h.ANIMATION_SAMPLER}getDefaultAttributes(){return Object.assign(super.getDefaults(),{interpolation:et.Interpolation.LINEAR,input:null,output:null})}getInterpolation(){return this.get("interpolation")}setInterpolation(_e){return this.set("interpolation",_e)}getInput(){return this.getRef("input")}setInput(_e){return this.setRef("input",_e,{usage:l.OTHER})}getOutput(){return this.getRef("output")}setOutput(_e){return this.setRef("output",_e,{usage:l.OTHER})}}et.Interpolation={LINEAR:"LINEAR",STEP:"STEP",CUBICSPLINE:"CUBICSPLINE"};class rt extends K{init(){this.propertyType=h.BUFFER}getDefaults(){return Object.assign(super.getDefaults(),{uri:""})}getURI(){return this.get("uri")}setURI(_e){return this.set("uri",_e)}}class st extends K{init(){this.propertyType=h.CAMERA}getDefaults(){return Object.assign(super.getDefaults(),{type:st.Type.PERSPECTIVE,znear:.1,zfar:100,aspectRatio:null,yfov:2*Math.PI*50/360,xmag:1,ymag:1})}getType(){return this.get("type")}setType(_e){return this.set("type",_e)}getZNear(){return this.get("znear")}setZNear(_e){return this.set("znear",_e)}getZFar(){return this.get("zfar")}setZFar(_e){return this.set("zfar",_e)}getAspectRatio(){return this.get("aspectRatio")}setAspectRatio(_e){return this.set("aspectRatio",_e)}getYFov(){return this.get("yfov")}setYFov(_e){return this.set("yfov",_e)}getXMag(){return this.get("xmag")}setXMag(_e){return this.set("xmag",_e)}getYMag(){return this.get("ymag")}setYMag(_e){return this.set("ymag",_e)}}st.Type={PERSPECTIVE:"perspective",ORTHOGRAPHIC:"orthographic"};class nt extends Z$1{t(_e){if(!this.parentTypes.includes(_e.propertyType))throw new Error(`Parent "${_e.propertyType}" invalid for child "${this.propertyType}".`)}}nt.EXTENSION_NAME=void 0;class it extends K{init(){this.propertyType=h.TEXTURE_INFO}getDefaults(){return Object.assign(super.getDefaults(),{texCoord:0,magFilter:null,minFilter:null,wrapS:it.WrapMode.REPEAT,wrapT:it.WrapMode.REPEAT})}getTexCoord(){return this.get("texCoord")}setTexCoord(_e){return this.set("texCoord",_e)}getMagFilter(){return this.get("magFilter")}setMagFilter(_e){return this.set("magFilter",_e)}getMinFilter(){return this.get("minFilter")}setMinFilter(_e){return this.set("minFilter",_e)}getWrapS(){return this.get("wrapS")}setWrapS(_e){return this.set("wrapS",_e)}getWrapT(){return this.get("wrapT")}setWrapT(_e){return this.set("wrapT",_e)}}it.WrapMode={CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,REPEAT:10497},it.MagFilter={NEAREST:9728,LINEAR:9729},it.MinFilter={NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987};const{R:ot,G:at,B:ut,A:ct}=d;class ht extends K{init(){this.propertyType=h.MATERIAL}getDefaults(){return Object.assign(super.getDefaults(),{alphaMode:ht.AlphaMode.OPAQUE,alphaCutoff:.5,doubleSided:!1,baseColorFactor:[1,1,1,1],baseColorTexture:null,baseColorTextureInfo:new it(this.graph,"baseColorTextureInfo"),emissiveFactor:[0,0,0],emissiveTexture:null,emissiveTextureInfo:new it(this.graph,"emissiveTextureInfo"),normalScale:1,normalTexture:null,normalTextureInfo:new it(this.graph,"normalTextureInfo"),occlusionStrength:1,occlusionTexture:null,occlusionTextureInfo:new it(this.graph,"occlusionTextureInfo"),roughnessFactor:1,metallicFactor:1,metallicRoughnessTexture:null,metallicRoughnessTextureInfo:new it(this.graph,"metallicRoughnessTextureInfo")})}getDoubleSided(){return this.get("doubleSided")}setDoubleSided(_e){return this.set("doubleSided",_e)}getAlpha(){return this.get("baseColorFactor")[3]}setAlpha(_e){const Dt=this.get("baseColorFactor").slice();return Dt[3]=_e,this.set("baseColorFactor",Dt)}getAlphaMode(){return this.get("alphaMode")}setAlphaMode(_e){return this.set("alphaMode",_e)}getAlphaCutoff(){return this.get("alphaCutoff")}setAlphaCutoff(_e){return this.set("alphaCutoff",_e)}getBaseColorFactor(){return this.get("baseColorFactor")}setBaseColorFactor(_e){return this.set("baseColorFactor",_e)}getBaseColorHex(){return S.factorToHex(this.get("baseColorFactor"))}setBaseColorHex(_e){const Dt=this.get("baseColorFactor").slice();return this.set("baseColorFactor",S.hexToFactor(_e,Dt))}getBaseColorTexture(){return this.getRef("baseColorTexture")}getBaseColorTextureInfo(){return this.getRef("baseColorTexture")?this.getRef("baseColorTextureInfo"):null}setBaseColorTexture(_e){return this.setRef("baseColorTexture",_e,{channels:ot|at|ut|ct,isColor:!0})}getEmissiveFactor(){return this.get("emissiveFactor")}setEmissiveFactor(_e){return this.set("emissiveFactor",_e)}getEmissiveHex(){return S.factorToHex(this.get("emissiveFactor"))}setEmissiveHex(_e){const Dt=this.get("emissiveFactor").slice();return this.set("emissiveFactor",S.hexToFactor(_e,Dt))}getEmissiveTexture(){return this.getRef("emissiveTexture")}getEmissiveTextureInfo(){return this.getRef("emissiveTexture")?this.getRef("emissiveTextureInfo"):null}setEmissiveTexture(_e){return this.setRef("emissiveTexture",_e,{channels:ot|at|ut,isColor:!0})}getNormalScale(){return this.get("normalScale")}setNormalScale(_e){return this.set("normalScale",_e)}getNormalTexture(){return this.getRef("normalTexture")}getNormalTextureInfo(){return this.getRef("normalTexture")?this.getRef("normalTextureInfo"):null}setNormalTexture(_e){return this.setRef("normalTexture",_e,{channels:ot|at|ut})}getOcclusionStrength(){return this.get("occlusionStrength")}setOcclusionStrength(_e){return this.set("occlusionStrength",_e)}getOcclusionTexture(){return this.getRef("occlusionTexture")}getOcclusionTextureInfo(){return this.getRef("occlusionTexture")?this.getRef("occlusionTextureInfo"):null}setOcclusionTexture(_e){return this.setRef("occlusionTexture",_e,{channels:ot})}getRoughnessFactor(){return this.get("roughnessFactor")}setRoughnessFactor(_e){return this.set("roughnessFactor",_e)}getMetallicFactor(){return this.get("metallicFactor")}setMetallicFactor(_e){return this.set("metallicFactor",_e)}getMetallicRoughnessTexture(){return this.getRef("metallicRoughnessTexture")}getMetallicRoughnessTextureInfo(){return this.getRef("metallicRoughnessTexture")?this.getRef("metallicRoughnessTextureInfo"):null}setMetallicRoughnessTexture(_e){return this.setRef("metallicRoughnessTexture",_e,{channels:at|ut})}}ht.AlphaMode={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};class ft extends K{init(){this.propertyType=h.MESH}getDefaults(){return Object.assign(super.getDefaults(),{weights:[],primitives:[]})}addPrimitive(_e){return this.addRef("primitives",_e)}removePrimitive(_e){return this.removeRef("primitives",_e)}listPrimitives(){return this.listRefs("primitives")}getWeights(){return this.get("weights")}setWeights(_e){return this.set("weights",_e)}}class lt extends K{constructor(..._e){super(..._e),this.u=null,this.h=new Set}init(){this.propertyType=h.NODE}getDefaults(){return Object.assign(super.getDefaults(),{translation:[0,0,0],rotation:[0,0,0,1],scale:[1,1,1],weights:[],camera:null,mesh:null,skin:null,children:[]})}copy(_e,Dt=H){if(Dt===H)throw new Error("Node cannot be copied.");return super.copy(_e,Dt)}getTranslation(){return this.get("translation")}getRotation(){return this.get("rotation")}getScale(){return this.get("scale")}setTranslation(_e){return this.set("translation",_e)}setRotation(_e){return this.set("rotation",_e)}setScale(_e){return this.set("scale",_e)}getMatrix(){return L.compose(this.get("translation"),this.get("rotation"),this.get("scale"),[])}setMatrix(_e){const Dt=this.get("translation").slice(),Vt=this.get("rotation").slice(),Gt=this.get("scale").slice();return L.decompose(_e,Dt,Vt,Gt),this.set("translation",Dt).set("rotation",Vt).set("scale",Gt)}getWorldTranslation(){const _e=[0,0,0];return L.decompose(this.getWorldMatrix(),_e,[0,0,0,1],[1,1,1]),_e}getWorldRotation(){const _e=[0,0,0,1];return L.decompose(this.getWorldMatrix(),[0,0,0],_e,[1,1,1]),_e}getWorldScale(){const _e=[1,1,1];return L.decompose(this.getWorldMatrix(),[0,0,0],[0,0,0,1],_e),_e}getWorldMatrix(){const _e=[];for(let Gt=this;Gt!=null;Gt=Gt.u)_e.push(Gt);let Dt;const Vt=_e.pop().getMatrix();for(;Dt=_e.pop();)P(Vt,Vt,Dt.getMatrix());return Vt}addChild(_e){if(_e.u&&_e.u.removeChild(_e),_e.h.size)for(const Vt of _e.h)Vt.removeChild(_e);this.addRef("children",_e),_e.u=this;const Dt=this[$attributes].children;return Dt[Dt.length-1].addEventListener("dispose",()=>_e.u=null),this}removeChild(_e){return this.removeRef("children",_e)}listChildren(){return this.listRefs("children")}getParent(){return this.u?this.u:this.listParents().find(_e=>_e.propertyType===h.SCENE)||null}getParentNode(){return this.u}getMesh(){return this.getRef("mesh")}setMesh(_e){return this.setRef("mesh",_e)}getCamera(){return this.getRef("camera")}setCamera(_e){return this.setRef("camera",_e)}getSkin(){return this.getRef("skin")}setSkin(_e){return this.setRef("skin",_e)}getWeights(){return this.get("weights")}setWeights(_e){return this.set("weights",_e)}traverse(_e){_e(this);for(const Dt of this.listChildren())Dt.traverse(_e);return this}}class dt extends K{init(){this.propertyType=h.PRIMITIVE}getDefaults(){return Object.assign(super.getDefaults(),{mode:dt.Mode.TRIANGLES,material:null,indices:null,attributes:{},targets:[]})}getIndices(){return this.getRef("indices")}setIndices(_e){return this.setRef("indices",_e,{usage:l.ELEMENT_ARRAY_BUFFER})}getAttribute(_e){return this.getRefMap("attributes",_e)}setAttribute(_e,Dt){return this.setRefMap("attributes",_e,Dt,{usage:l.ARRAY_BUFFER})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}getMaterial(){return this.getRef("material")}setMaterial(_e){return this.setRef("material",_e)}getMode(){return this.get("mode")}setMode(_e){return this.set("mode",_e)}listTargets(){return this.listRefs("targets")}addTarget(_e){return this.addRef("targets",_e)}removeTarget(_e){return this.removeRef("targets",_e)}}dt.Mode={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6};class gt extends Z$1{init(){this.propertyType=h.PRIMITIVE_TARGET}getDefaults(){return Object.assign(super.getDefaults(),{attributes:{}})}getAttribute(_e){return this.getRefMap("attributes",_e)}setAttribute(_e,Dt){return this.setRefMap("attributes",_e,Dt,{usage:l.ARRAY_BUFFER})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}}function pt(){return pt=Object.assign?Object.assign.bind():function(kt){for(var _e=1;_e<arguments.length;_e++){var Dt=arguments[_e];for(var Vt in Dt)Object.prototype.hasOwnProperty.call(Dt,Vt)&&(kt[Vt]=Dt[Vt])}return kt},pt.apply(this,arguments)}class mt extends K{init(){this.propertyType=h.SCENE}getDefaults(){return Object.assign(super.getDefaults(),{children:[]})}copy(_e,Dt=H){if(Dt===H)throw new Error("Scene cannot be copied.");return super.copy(_e,Dt)}addChild(_e){_e.u&&_e.u.removeChild(_e),this.addRef("children",_e),_e.h.add(this);const Dt=this[$attributes].children;return Dt[Dt.length-1].addEventListener("dispose",()=>_e.h.delete(this)),this}removeChild(_e){return this.removeRef("children",_e)}listChildren(){return this.listRefs("children")}traverse(_e){for(const Dt of this.listChildren())Dt.traverse(_e);return this}}class wt extends K{init(){this.propertyType=h.SKIN}getDefaults(){return Object.assign(super.getDefaults(),{skeleton:null,inverseBindMatrices:null,joints:[]})}getSkeleton(){return this.getRef("skeleton")}setSkeleton(_e){return this.setRef("skeleton",_e)}getInverseBindMatrices(){return this.getRef("inverseBindMatrices")}setInverseBindMatrices(_e){return this.setRef("inverseBindMatrices",_e,{usage:l.INVERSE_BIND_MATRICES})}addJoint(_e){return this.addRef("joints",_e)}removeJoint(_e){return this.removeRef("joints",_e)}listJoints(){return this.listRefs("joints")}}class yt extends K{init(){this.propertyType=h.TEXTURE}getDefaults(){return Object.assign(super.getDefaults(),{image:null,mimeType:"",uri:""})}getMimeType(){return this.get("mimeType")||I.extensionToMimeType(N.extension(this.get("uri")))}setMimeType(_e){return this.set("mimeType",_e)}getURI(){return this.get("uri")}setURI(_e){this.set("uri",_e);const Dt=I.extensionToMimeType(N.extension(_e));return Dt&&this.set("mimeType",Dt),this}getImage(){return this.get("image")}setImage(_e){return this.set("image",E.assertView(_e))}getSize(){const _e=this.get("image");return _e?I.getSize(_e,this.getMimeType()):null}}class vt extends K{init(){this.propertyType=h.ROOT}getDefaults(){return Object.assign(super.getDefaults(),{asset:{generator:`glTF-Transform ${u}`,version:"2.0"},defaultScene:null,accessors:[],animations:[],buffers:[],cameras:[],materials:[],meshes:[],nodes:[],scenes:[],skins:[],textures:[]})}constructor(_e){super(_e),this.l=new Set,_e.addEventListener("node:create",Dt=>{this.g(Dt.target)})}clone(){throw new Error("Root cannot be cloned.")}copy(_e,Dt=H){if(Dt===H)throw new Error("Root cannot be copied.");this.set("asset",pt({},_e.get("asset"))),this.setName(_e.getName()),this.setExtras(pt({},_e.getExtras())),this.setDefaultScene(_e.getDefaultScene()?Dt(_e.getDefaultScene()):null);for(const Vt of _e.listRefMapKeys("extensions")){const Gt=_e.getExtension(Vt);this.setExtension(Vt,Dt(Gt))}return this}g(_e){return _e instanceof mt?this.addRef("scenes",_e):_e instanceof lt?this.addRef("nodes",_e):_e instanceof st?this.addRef("cameras",_e):_e instanceof wt?this.addRef("skins",_e):_e instanceof ft?this.addRef("meshes",_e):_e instanceof ht?this.addRef("materials",_e):_e instanceof yt?this.addRef("textures",_e):_e instanceof X?this.addRef("animations",_e):_e instanceof Q?this.addRef("accessors",_e):_e instanceof rt&&this.addRef("buffers",_e),this}getAsset(){return this.get("asset")}listExtensionsUsed(){return Array.from(this.l)}listExtensionsRequired(){return this.listExtensionsUsed().filter(_e=>_e.isRequired())}p(_e){return this.l.add(_e),this}m(_e){return this.l.delete(_e),this}listScenes(){return this.listRefs("scenes")}setDefaultScene(_e){return this.setRef("defaultScene",_e)}getDefaultScene(){return this.getRef("defaultScene")}listNodes(){return this.listRefs("nodes")}listCameras(){return this.listRefs("cameras")}listSkins(){return this.listRefs("skins")}listMeshes(){return this.listRefs("meshes")}listMaterials(){return this.listRefs("materials")}listTextures(){return this.listRefs("textures")}listAnimations(){return this.listRefs("animations")}listAccessors(){return this.listRefs("accessors")}listBuffers(){return this.listRefs("buffers")}}class Tt{static fromGraph(_e){return Tt.v.get(_e)||null}constructor(){this.T=new Graph,this.S=new vt(this.T),this.M=B$1.DEFAULT_INSTANCE,Tt.v.set(this.T,this)}getRoot(){return this.S}getGraph(){return this.T}getLogger(){return this.M}setLogger(_e){return this.M=_e,this}clone(){return new Tt().setLogger(this.M).merge(this)}merge(_e){for(const zt of _e.getRoot().listExtensionsUsed()){const jt=this.createExtension(zt.constructor);zt.isRequired()&&jt.setRequired(!0)}const Dt=new Set,Vt=new Map;Dt.add(_e.S),Vt.set(_e.S,this.S);for(const zt of _e.T.listEdges())for(const jt of[zt.getParent(),zt.getChild()]){if(Dt.has(jt))continue;let Ht;Ht=jt.propertyType===h.TEXTURE_INFO?jt:new jt.constructor(this.T),Vt.set(jt,Ht),Dt.add(jt)}const Gt=zt=>{const jt=Vt.get(zt);if(!jt)throw new Error("Could resolve property.");return jt};for(const zt of Dt){const jt=Vt.get(zt);if(!jt)throw new Error("Could resolve property.");jt.propertyType!==h.TEXTURE_INFO&&jt.copy(zt,Gt)}return this}async transform(..._e){const Dt=_e.map(Vt=>Vt.name);for(const Vt of _e)await Vt(this,{stack:Dt});return this}createExtension(_e){const Dt=_e.EXTENSION_NAME;return this.getRoot().listExtensionsUsed().find(Vt=>Vt.extensionName===Dt)||new _e(this)}createScene(_e=""){return new mt(this.T,_e)}createNode(_e=""){return new lt(this.T,_e)}createCamera(_e=""){return new st(this.T,_e)}createSkin(_e=""){return new wt(this.T,_e)}createMesh(_e=""){return new ft(this.T,_e)}createPrimitive(){return new dt(this.T)}createPrimitiveTarget(_e=""){return new gt(this.T,_e)}createMaterial(_e=""){return new ht(this.T,_e)}createTexture(_e=""){return new yt(this.T,_e)}createAnimation(_e=""){return new X(this.T,_e)}createAnimationChannel(_e=""){return new tt(this.T,_e)}createAnimationSampler(_e=""){return new et(this.T,_e)}createAccessor(_e="",Dt=null){return Dt||(Dt=this.getRoot().listBuffers()[0]),new Q(this.T,_e).setBuffer(Dt)}createBuffer(_e=""){return new rt(this.T,_e)}}Tt.v=new WeakMap;class xt{constructor(_e){this.jsonDoc=void 0,this.buffers=[],this.bufferViews=[],this.bufferViewBuffers=[],this.accessors=[],this.textures=[],this.textureInfos=new Map,this.materials=[],this.meshes=[],this.cameras=[],this.nodes=[],this.skins=[],this.animations=[],this.scenes=[],this.jsonDoc=_e}setTextureInfo(_e,Dt){this.textureInfos.set(_e,Dt),Dt.texCoord!==void 0&&_e.setTexCoord(Dt.texCoord),Dt.extras!==void 0&&_e.setExtras(Dt.extras);const Vt=this.jsonDoc.json.textures[Dt.index];if(Vt.sampler===void 0)return;const Gt=this.jsonDoc.json.samplers[Vt.sampler];Gt.magFilter!==void 0&&_e.setMagFilter(Gt.magFilter),Gt.minFilter!==void 0&&_e.setMinFilter(Gt.minFilter),Gt.wrapS!==void 0&&_e.setWrapS(Gt.wrapS),Gt.wrapT!==void 0&&_e.setWrapT(Gt.wrapT)}}const At={logger:B$1.DEFAULT_INSTANCE,extensions:[],dependencies:{}};class Et{static read(_e,Dt=At){const Vt=pt({},At,Dt),{json:Gt}=_e,zt=new Tt().setLogger(Vt.logger);this.validate(_e,Vt);const jt=new xt(_e),Ht=Gt.asset,Wt=zt.getRoot().getAsset();Ht.copyright&&(Wt.copyright=Ht.copyright),Ht.extras&&(Wt.extras=Ht.extras),Gt.extras!==void 0&&zt.getRoot().setExtras(pt({},Gt.extras));const qt=Gt.extensionsUsed||[],Xt=Gt.extensionsRequired||[];for(const en of Vt.extensions)if(qt.includes(en.EXTENSION_NAME)){const tn=zt.createExtension(en).setRequired(Xt.includes(en.EXTENSION_NAME));for(const sn of tn.readDependencies)tn.install(sn,Vt.dependencies[sn])}const Kt=Gt.buffers||[];zt.getRoot().listExtensionsUsed().filter(en=>en.prereadTypes.includes(h.BUFFER)).forEach(en=>en.preread(jt,h.BUFFER)),jt.buffers=Kt.map(en=>{const tn=zt.createBuffer(en.name);return en.extras&&tn.setExtras(en.extras),en.uri&&en.uri.indexOf("__")!==0&&tn.setURI(en.uri),tn}),jt.bufferViewBuffers=(Gt.bufferViews||[]).map((en,tn)=>{if(!jt.bufferViews[tn]){const sn=_e.json.buffers[en.buffer];jt.bufferViews[tn]=E.toView(sn.uri?_e.resources[sn.uri]:_e.resources[c],en.byteOffset||0,en.byteLength)}return jt.buffers[en.buffer]});const Yt=Gt.accessors||[];jt.accessors=Yt.map(en=>{const tn=zt.createAccessor(en.name,jt.bufferViewBuffers[en.bufferView]).setType(en.type);return en.extras&&tn.setExtras(en.extras),en.normalized!==void 0&&tn.setNormalized(en.normalized),en.bufferView===void 0||tn.setArray(St(en,jt)),tn});const Zt=Gt.images||[],Jt=Gt.textures||[];zt.getRoot().listExtensionsUsed().filter(en=>en.prereadTypes.includes(h.TEXTURE)).forEach(en=>en.preread(jt,h.TEXTURE)),jt.textures=Zt.map(en=>{const tn=zt.createTexture(en.name);if(en.extras&&tn.setExtras(en.extras),en.bufferView!==void 0){const sn=Gt.bufferViews[en.bufferView],cn=_e.json.buffers[sn.buffer],un=sn.byteOffset||0,hn=(cn.uri?_e.resources[cn.uri]:_e.resources[c]).slice(un,un+sn.byteLength);tn.setImage(hn)}else en.uri!==void 0&&(tn.setImage(_e.resources[en.uri]),en.uri.indexOf("__")!==0&&tn.setURI(en.uri));if(en.mimeType!==void 0)tn.setMimeType(en.mimeType);else if(en.uri){const sn=N.extension(en.uri);tn.setMimeType(I.extensionToMimeType(sn))}return tn}),jt.materials=(Gt.materials||[]).map(en=>{const tn=zt.createMaterial(en.name);en.extras&&tn.setExtras(en.extras),en.alphaMode!==void 0&&tn.setAlphaMode(en.alphaMode),en.alphaCutoff!==void 0&&tn.setAlphaCutoff(en.alphaCutoff),en.doubleSided!==void 0&&tn.setDoubleSided(en.doubleSided);const sn=en.pbrMetallicRoughness||{};if(sn.baseColorFactor!==void 0&&tn.setBaseColorFactor(sn.baseColorFactor),en.emissiveFactor!==void 0&&tn.setEmissiveFactor(en.emissiveFactor),sn.metallicFactor!==void 0&&tn.setMetallicFactor(sn.metallicFactor),sn.roughnessFactor!==void 0&&tn.setRoughnessFactor(sn.roughnessFactor),sn.baseColorTexture!==void 0){const cn=sn.baseColorTexture;tn.setBaseColorTexture(jt.textures[Jt[cn.index].source]),jt.setTextureInfo(tn.getBaseColorTextureInfo(),cn)}if(en.emissiveTexture!==void 0){const cn=en.emissiveTexture;tn.setEmissiveTexture(jt.textures[Jt[cn.index].source]),jt.setTextureInfo(tn.getEmissiveTextureInfo(),cn)}if(en.normalTexture!==void 0){const cn=en.normalTexture;tn.setNormalTexture(jt.textures[Jt[cn.index].source]),jt.setTextureInfo(tn.getNormalTextureInfo(),cn),en.normalTexture.scale!==void 0&&tn.setNormalScale(en.normalTexture.scale)}if(en.occlusionTexture!==void 0){const cn=en.occlusionTexture;tn.setOcclusionTexture(jt.textures[Jt[cn.index].source]),jt.setTextureInfo(tn.getOcclusionTextureInfo(),cn),en.occlusionTexture.strength!==void 0&&tn.setOcclusionStrength(en.occlusionTexture.strength)}if(sn.metallicRoughnessTexture!==void 0){const cn=sn.metallicRoughnessTexture;tn.setMetallicRoughnessTexture(jt.textures[Jt[cn.index].source]),jt.setTextureInfo(tn.getMetallicRoughnessTextureInfo(),cn)}return tn});const nn=Gt.meshes||[];zt.getRoot().listExtensionsUsed().filter(en=>en.prereadTypes.includes(h.PRIMITIVE)).forEach(en=>en.preread(jt,h.PRIMITIVE)),jt.meshes=nn.map(en=>{const tn=zt.createMesh(en.name);return en.extras&&tn.setExtras(en.extras),en.weights!==void 0&&tn.setWeights(en.weights),(en.primitives||[]).forEach(sn=>{const cn=zt.createPrimitive();sn.extras&&cn.setExtras(sn.extras),sn.material!==void 0&&cn.setMaterial(jt.materials[sn.material]),sn.mode!==void 0&&cn.setMode(sn.mode);for(const[hn,fn]of Object.entries(sn.attributes||{}))cn.setAttribute(hn,jt.accessors[fn]);sn.indices!==void 0&&cn.setIndices(jt.accessors[sn.indices]);const un=en.extras&&en.extras.targetNames||[];(sn.targets||[]).forEach((hn,fn)=>{const pn=un[fn]||fn.toString(),dn=zt.createPrimitiveTarget(pn);for(const[mn,vn]of Object.entries(hn))dn.setAttribute(mn,jt.accessors[vn]);cn.addTarget(dn)}),tn.addPrimitive(cn)}),tn}),jt.cameras=(Gt.cameras||[]).map(en=>{const tn=zt.createCamera(en.name).setType(en.type);if(en.extras&&tn.setExtras(en.extras),en.type===st.Type.PERSPECTIVE){const sn=en.perspective;tn.setYFov(sn.yfov),tn.setZNear(sn.znear),sn.zfar!==void 0&&tn.setZFar(sn.zfar),sn.aspectRatio!==void 0&&tn.setAspectRatio(sn.aspectRatio)}else{const sn=en.orthographic;tn.setZNear(sn.znear).setZFar(sn.zfar).setXMag(sn.xmag).setYMag(sn.ymag)}return tn});const rn=Gt.nodes||[];zt.getRoot().listExtensionsUsed().filter(en=>en.prereadTypes.includes(h.NODE)).forEach(en=>en.preread(jt,h.NODE)),jt.nodes=rn.map(en=>{const tn=zt.createNode(en.name);if(en.extras&&tn.setExtras(en.extras),en.translation!==void 0&&tn.setTranslation(en.translation),en.rotation!==void 0&&tn.setRotation(en.rotation),en.scale!==void 0&&tn.setScale(en.scale),en.matrix!==void 0){const sn=[0,0,0],cn=[0,0,0,1],un=[1,1,1];L.decompose(en.matrix,sn,cn,un),tn.setTranslation(sn),tn.setRotation(cn),tn.setScale(un)}return en.weights!==void 0&&tn.setWeights(en.weights),tn}),jt.skins=(Gt.skins||[]).map(en=>{const tn=zt.createSkin(en.name);en.extras&&tn.setExtras(en.extras),en.inverseBindMatrices!==void 0&&tn.setInverseBindMatrices(jt.accessors[en.inverseBindMatrices]),en.skeleton!==void 0&&tn.setSkeleton(jt.nodes[en.skeleton]);for(const sn of en.joints)tn.addJoint(jt.nodes[sn]);return tn}),rn.map((en,tn)=>{const sn=jt.nodes[tn];(en.children||[]).forEach(cn=>sn.addChild(jt.nodes[cn])),en.mesh!==void 0&&sn.setMesh(jt.meshes[en.mesh]),en.camera!==void 0&&sn.setCamera(jt.cameras[en.camera]),en.skin!==void 0&&sn.setSkin(jt.skins[en.skin])}),jt.animations=(Gt.animations||[]).map(en=>{const tn=zt.createAnimation(en.name);en.extras&&tn.setExtras(en.extras);const sn=(en.samplers||[]).map(cn=>{const un=zt.createAnimationSampler().setInput(jt.accessors[cn.input]).setOutput(jt.accessors[cn.output]).setInterpolation(cn.interpolation||et.Interpolation.LINEAR);return cn.extras&&un.setExtras(cn.extras),tn.addSampler(un),un});return(en.channels||[]).forEach(cn=>{const un=zt.createAnimationChannel().setSampler(sn[cn.sampler]).setTargetPath(cn.target.path);cn.target.node!==void 0&&un.setTargetNode(jt.nodes[cn.target.node]),cn.extras&&un.setExtras(cn.extras),tn.addChannel(un)}),tn});const Qt=Gt.scenes||[];return zt.getRoot().listExtensionsUsed().filter(en=>en.prereadTypes.includes(h.SCENE)).forEach(en=>en.preread(jt,h.SCENE)),jt.scenes=Qt.map(en=>{const tn=zt.createScene(en.name);return en.extras&&tn.setExtras(en.extras),(en.nodes||[]).map(sn=>jt.nodes[sn]).forEach(sn=>tn.addChild(sn)),tn}),Gt.scene!==void 0&&zt.getRoot().setDefaultScene(jt.scenes[Gt.scene]),zt.getRoot().listExtensionsUsed().forEach(en=>en.read(jt)),Yt.forEach((en,tn)=>{const sn=jt.accessors[tn],cn=!!en.sparse,un=!en.bufferView&&!sn.getArray();(cn||un)&&sn.setSparse(!0).setArray(function(hn,fn){const pn=p[hn.componentType],dn=Q.getElementSize(hn.type);let mn;mn=hn.bufferView!==void 0?St(hn,fn):new pn(hn.count*dn);const vn=hn.sparse;if(!vn)return mn;const _n=vn.count,En=pt({},hn,vn.indices,{count:_n,type:"SCALAR"}),An=pt({},hn,vn.values,{count:_n}),Tn=St(En,fn),Cn=St(An,fn);for(let yn=0;yn<En.count;yn++)for(let Sn=0;Sn<dn;Sn++)mn[Tn[yn]*dn+Sn]=Cn[yn*dn+Sn];return mn}(en,jt))}),zt}static validate(_e,Dt){const Vt=_e.json;if(Vt.asset.version!=="2.0")throw new Error(`Unsupported glTF version, "${Vt.asset.version}".`);if(Vt.extensionsRequired){for(const Gt of Vt.extensionsRequired)if(!Dt.extensions.find(zt=>zt.EXTENSION_NAME===Gt))throw new Error(`Missing required extension, "${Gt}".`)}if(Vt.extensionsUsed)for(const Gt of Vt.extensionsUsed)Dt.extensions.find(zt=>zt.EXTENSION_NAME===Gt)||Dt.logger.warn(`Missing optional extension, "${Gt}".`)}}function St(kt,_e){const Dt=_e.bufferViews[kt.bufferView],Vt=_e.jsonDoc.json.bufferViews[kt.bufferView],Gt=p[kt.componentType],zt=Q.getElementSize(kt.type),jt=Gt.BYTES_PER_ELEMENT;if(Vt.byteStride!==void 0&&Vt.byteStride!==zt*jt)return function(Wt,qt){const Xt=qt.bufferViews[Wt.bufferView],Kt=qt.jsonDoc.json.bufferViews[Wt.bufferView],Yt=p[Wt.componentType],Zt=Q.getElementSize(Wt.type),Jt=Yt.BYTES_PER_ELEMENT,nn=Wt.byteOffset||0,rn=new Yt(Wt.count*Zt),Qt=new DataView(Xt.buffer,Xt.byteOffset,Xt.byteLength),en=Kt.byteStride;for(let tn=0;tn<Wt.count;tn++)for(let sn=0;sn<Zt;sn++){const cn=nn+tn*en+sn*Jt;let un;switch(Wt.componentType){case Q.ComponentType.FLOAT:un=Qt.getFloat32(cn,!0);break;case Q.ComponentType.UNSIGNED_INT:un=Qt.getUint32(cn,!0);break;case Q.ComponentType.UNSIGNED_SHORT:un=Qt.getUint16(cn,!0);break;case Q.ComponentType.UNSIGNED_BYTE:un=Qt.getUint8(cn);break;case Q.ComponentType.SHORT:un=Qt.getInt16(cn,!0);break;case Q.ComponentType.BYTE:un=Qt.getInt8(cn);break;default:throw new Error(`Unexpected componentType "${Wt.componentType}".`)}rn[tn*Zt+sn]=un}return rn}(kt,_e);const Ht=Dt.byteOffset+(kt.byteOffset||0);return new Gt(Dt.buffer.slice(Ht,Ht+kt.count*zt*jt))}var Mt;(function(kt){kt[kt.ARRAY_BUFFER=34962]="ARRAY_BUFFER",kt[kt.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER"})(Mt||(Mt={}));class It{constructor(_e,Dt,Vt){this.C=void 0,this.jsonDoc=void 0,this.options=void 0,this.accessorIndexMap=new Map,this.animationIndexMap=new Map,this.bufferIndexMap=new Map,this.cameraIndexMap=new Map,this.skinIndexMap=new Map,this.materialIndexMap=new Map,this.meshIndexMap=new Map,this.nodeIndexMap=new Map,this.imageIndexMap=new Map,this.textureDefIndexMap=new Map,this.textureInfoDefMap=new Map,this.samplerDefIndexMap=new Map,this.sceneIndexMap=new Map,this.imageBufferViews=[],this.otherBufferViews=new Map,this.otherBufferViewsIndexMap=new Map,this.extensionData={},this.bufferURIGenerator=void 0,this.imageURIGenerator=void 0,this.logger=void 0,this.F=new Map,this.accessorUsageGroupedByParent=new Set(["ARRAY_BUFFER"]),this.accessorParents=new Map,this.C=_e,this.jsonDoc=Dt,this.options=Vt;const Gt=_e.getRoot(),zt=Gt.listBuffers().length,jt=Gt.listTextures().length;this.bufferURIGenerator=new Rt(zt>1,()=>Vt.basename||"buffer"),this.imageURIGenerator=new Rt(jt>1,Ht=>function(Wt,qt){const Xt=Wt.getGraph().listParentEdges(qt).find(Kt=>Kt.getParent()!==Wt.getRoot());return Xt?Xt.getName().replace(/texture$/i,""):""}(_e,Ht)||Vt.basename||"texture"),this.logger=_e.getLogger()}createTextureInfoDef(_e,Dt){const Vt={magFilter:Dt.getMagFilter()||void 0,minFilter:Dt.getMinFilter()||void 0,wrapS:Dt.getWrapS(),wrapT:Dt.getWrapT()},Gt=JSON.stringify(Vt);this.samplerDefIndexMap.has(Gt)||(this.samplerDefIndexMap.set(Gt,this.jsonDoc.json.samplers.length),this.jsonDoc.json.samplers.push(Vt));const zt={source:this.imageIndexMap.get(_e),sampler:this.samplerDefIndexMap.get(Gt)},jt=JSON.stringify(zt);this.textureDefIndexMap.has(jt)||(this.textureDefIndexMap.set(jt,this.jsonDoc.json.textures.length),this.jsonDoc.json.textures.push(zt));const Ht={index:this.textureDefIndexMap.get(jt)};return Dt.getTexCoord()!==0&&(Ht.texCoord=Dt.getTexCoord()),Object.keys(Dt.getExtras()).length>0&&(Ht.extras=Dt.getExtras()),this.textureInfoDefMap.set(Dt,Ht),Ht}createPropertyDef(_e){const Dt={};return _e.getName()&&(Dt.name=_e.getName()),Object.keys(_e.getExtras()).length>0&&(Dt.extras=_e.getExtras()),Dt}createAccessorDef(_e){const Dt=this.createPropertyDef(_e);return Dt.type=_e.getType(),Dt.componentType=_e.getComponentType(),Dt.count=_e.getCount(),this.C.getGraph().listParentEdges(_e).some(Vt=>Vt.getName()==="attributes"&&Vt.getAttributes().key==="POSITION"||Vt.getName()==="input")&&(Dt.max=_e.getMax([]).map(Math.fround),Dt.min=_e.getMin([]).map(Math.fround)),_e.getNormalized()&&(Dt.normalized=_e.getNormalized()),Dt}createImageData(_e,Dt,Vt){if(this.options.format===g.GLB)this.imageBufferViews.push(Dt),_e.bufferView=this.jsonDoc.json.bufferViews.length,this.jsonDoc.json.bufferViews.push({buffer:0,byteOffset:-1,byteLength:Dt.byteLength});else{const Gt=I.mimeTypeToExtension(Vt.getMimeType());_e.uri=this.imageURIGenerator.createURI(Vt,Gt),this.jsonDoc.resources[_e.uri]=Dt}}getAccessorUsage(_e){const Dt=this.F.get(_e);if(Dt)return Dt;if(_e.getSparse())return l.SPARSE;for(const Vt of this.C.getGraph().listParentEdges(_e)){const{usage:Gt}=Vt.getAttributes();if(Gt)return Gt;Vt.getParent().propertyType!==h.ROOT&&this.logger.warn(`Missing attribute ".usage" on edge, "${Vt.getName()}".`)}return l.OTHER}addAccessorToUsageGroup(_e,Dt){const Vt=this.F.get(_e);if(Vt&&Vt!==Dt)throw new Error(`Accessor with usage "${Vt}" cannot be reused as "${Dt}".`);return this.F.set(_e,Dt),this}listAccessorUsageGroups(){const _e={};for(const[Dt,Vt]of Array.from(this.F.entries()))_e[Vt]=_e[Vt]||[],_e[Vt].push(Dt);return _e}}It.BufferViewTarget=Mt,It.BufferViewUsage=l,It.USAGE_TO_TARGET={[l.ARRAY_BUFFER]:Mt.ARRAY_BUFFER,[l.ELEMENT_ARRAY_BUFFER]:Mt.ELEMENT_ARRAY_BUFFER};class Rt{constructor(_e,Dt){this.multiple=void 0,this.basename=void 0,this.counter={},this.multiple=_e,this.basename=Dt}createURI(_e,Dt){if(_e.getURI())return _e.getURI();if(this.multiple){const Vt=this.basename(_e);return this.counter[Vt]=this.counter[Vt]||1,`${Vt}_${this.counter[Vt]++}.${Dt}`}return`${this.basename(_e)}.${Dt}`}}const{BufferViewUsage:Nt}=It,{UNSIGNED_INT:Ot,UNSIGNED_SHORT:Ct,UNSIGNED_BYTE:Ft}=Q.ComponentType;class Ut{static write(_e,Dt){const Vt=_e.getRoot(),Gt={asset:pt({generator:`glTF-Transform ${u}`},Vt.getAsset()),extras:pt({},Vt.getExtras())},zt={json:Gt,resources:{}},jt=new It(_e,zt,Dt),Ht=Dt.logger||B$1.DEFAULT_INSTANCE,Wt=new Set(Dt.extensions.map(rn=>rn.EXTENSION_NAME)),qt=_e.getRoot().listExtensionsUsed().filter(rn=>Wt.has(rn.extensionName)),Xt=_e.getRoot().listExtensionsRequired().filter(rn=>Wt.has(rn.extensionName));qt.length<_e.getRoot().listExtensionsUsed().length&&Ht.warn("Some extensions were not registered for I/O, and will not be written.");for(const rn of qt)for(const Qt of rn.writeDependencies)rn.install(Qt,Dt.dependencies[Qt]);function Kt(rn,Qt,en,tn){const sn=[];let cn=0;for(const hn of rn){const fn=jt.createAccessorDef(hn);fn.bufferView=Gt.bufferViews.length;const pn=hn.getArray(),dn=E.pad(E.toView(pn));fn.byteOffset=cn,cn+=dn.byteLength,sn.push(dn),jt.accessorIndexMap.set(hn,Gt.accessors.length),Gt.accessors.push(fn)}const un={buffer:Qt,byteOffset:en,byteLength:E.concat(sn).byteLength};return tn&&(un.target=tn),Gt.bufferViews.push(un),{buffers:sn,byteLength:cn}}function Yt(rn,Qt,en){const tn=rn[0].getCount();let sn=0;for(const fn of rn){const pn=jt.createAccessorDef(fn);pn.bufferView=Gt.bufferViews.length,pn.byteOffset=sn;const dn=fn.getElementSize(),mn=fn.getComponentSize();sn+=E.padNumber(dn*mn),jt.accessorIndexMap.set(fn,Gt.accessors.length),Gt.accessors.push(pn)}const cn=tn*sn,un=new ArrayBuffer(cn),hn=new DataView(un);for(let fn=0;fn<tn;fn++){let pn=0;for(const dn of rn){const mn=dn.getElementSize(),vn=dn.getComponentSize(),_n=dn.getComponentType(),En=dn.getArray();for(let An=0;An<mn;An++){const Tn=fn*sn+pn+An*vn,Cn=En[fn*mn+An];switch(_n){case Q.ComponentType.FLOAT:hn.setFloat32(Tn,Cn,!0);break;case Q.ComponentType.BYTE:hn.setInt8(Tn,Cn);break;case Q.ComponentType.SHORT:hn.setInt16(Tn,Cn,!0);break;case Q.ComponentType.UNSIGNED_BYTE:hn.setUint8(Tn,Cn);break;case Q.ComponentType.UNSIGNED_SHORT:hn.setUint16(Tn,Cn,!0);break;case Q.ComponentType.UNSIGNED_INT:hn.setUint32(Tn,Cn,!0);break;default:throw new Error("Unexpected component type: "+_n)}}pn+=E.padNumber(mn*vn)}}return Gt.bufferViews.push({buffer:Qt,byteOffset:en,byteLength:cn,byteStride:sn,target:It.BufferViewTarget.ARRAY_BUFFER}),{byteLength:cn,buffers:[new Uint8Array(un)]}}function Zt(rn,Qt,en){const tn=[];let sn=0;const cn=new Map;let un=-1/0;for(const _n of rn){const En=jt.createAccessorDef(_n);Gt.accessors.push(En),jt.accessorIndexMap.set(_n,Gt.accessors.length-1);const An=[],Tn=[],Cn=[],yn=new Array(_n.getElementSize()).fill(0);for(let Rn=0,Dn=_n.getCount();Rn<Dn;Rn++)if(_n.getElement(Rn,Cn),!L.eq(Cn,yn,0)){un=Math.max(Rn,un),An.push(Rn);for(let kn=0;kn<Cn.length;kn++)Tn.push(Cn[kn])}const Sn=An.length,wn={accessorDef:En,count:Sn};if(cn.set(_n,wn),Sn===0)continue;if(Sn>_n.getCount()/3){const Rn=(100*An.length/_n.getCount()).toFixed(1);Ht.warn(`Sparse accessor with many non-zero elements (${Rn}%) may increase file size.`)}const xn=p[_n.getComponentType()];wn.indices=An,wn.values=new xn(Tn)}if(!Number.isFinite(un))return{buffers:tn,byteLength:sn};const hn=un<255?Uint8Array:un<65535?Uint16Array:Uint32Array,fn=un<255?Ft:un<65535?Ct:Ot,pn={buffer:Qt,byteOffset:en+sn,byteLength:0};for(const _n of rn){const En=cn.get(_n);if(En.count===0)continue;En.indicesByteOffset=pn.byteLength;const An=E.pad(E.toView(new hn(En.indices)));tn.push(An),sn+=An.byteLength,pn.byteLength+=An.byteLength}Gt.bufferViews.push(pn);const dn=Gt.bufferViews.length-1,mn={buffer:Qt,byteOffset:en+sn,byteLength:0};for(const _n of rn){const En=cn.get(_n);if(En.count===0)continue;En.valuesByteOffset=mn.byteLength;const An=E.pad(E.toView(En.values));tn.push(An),sn+=An.byteLength,mn.byteLength+=An.byteLength}Gt.bufferViews.push(mn);const vn=Gt.bufferViews.length-1;for(const _n of rn){const En=cn.get(_n);En.count!==0&&(En.accessorDef.sparse={count:En.count,indices:{bufferView:dn,byteOffset:En.indicesByteOffset,componentType:fn},values:{bufferView:vn,byteOffset:En.valuesByteOffset}})}return{buffers:tn,byteLength:sn}}const Jt=new Map;for(const rn of _e.getGraph().listEdges()){if(rn.getParent()===Vt)continue;const Qt=rn.getChild();if(Qt instanceof Q){const en=Jt.get(Qt)||[];en.push(rn),Jt.set(Qt,en)}}if(Gt.accessors=[],Gt.bufferViews=[],Gt.samplers=[],Gt.textures=[],Gt.images=Vt.listTextures().map((rn,Qt)=>{const en=jt.createPropertyDef(rn);rn.getMimeType()&&(en.mimeType=rn.getMimeType());const tn=rn.getImage();return tn&&jt.createImageData(en,tn,rn),jt.imageIndexMap.set(rn,Qt),en}),qt.filter(rn=>rn.prewriteTypes.includes(h.ACCESSOR)).forEach(rn=>rn.prewrite(jt,h.ACCESSOR)),Vt.listAccessors().forEach(rn=>{const Qt=jt.accessorUsageGroupedByParent,en=jt.accessorParents;if(jt.accessorIndexMap.has(rn))return;const tn=Jt.get(rn)||[],sn=jt.getAccessorUsage(rn);if(jt.addAccessorToUsageGroup(rn,sn),Qt.has(sn)){const cn=tn[0].getParent(),un=en.get(cn)||new Set;un.add(rn),en.set(cn,un)}}),qt.filter(rn=>rn.prewriteTypes.includes(h.BUFFER)).forEach(rn=>rn.prewrite(jt,h.BUFFER)),(Vt.listAccessors().length>0||Vt.listTextures().length>0||jt.otherBufferViews.size>0)&&Vt.listBuffers().length===0)throw new Error("Buffer required for Document resources, but none was found.");Gt.buffers=[],Vt.listBuffers().forEach((rn,Qt)=>{const en=jt.createPropertyDef(rn),tn=jt.accessorUsageGroupedByParent,sn=jt.accessorParents,cn=rn.listParents().filter(mn=>mn instanceof Q),un=new Set(cn),hn=[],fn=Gt.buffers.length;let pn=0;const dn=jt.listAccessorUsageGroups();for(const mn in dn)if(tn.has(mn))for(const vn of Array.from(sn.values())){const _n=Array.from(vn).filter(En=>un.has(En)).filter(En=>jt.getAccessorUsage(En)===mn);if(_n.length)if(mn!==Nt.ARRAY_BUFFER||Dt.vertexLayout===f.INTERLEAVED){const En=mn===Nt.ARRAY_BUFFER?Yt(_n,fn,pn):Kt(_n,fn,pn);pn+=En.byteLength,hn.push(...En.buffers)}else for(const En of _n){const An=Yt([En],fn,pn);pn+=An.byteLength,hn.push(...An.buffers)}}else{const vn=dn[mn].filter(An=>un.has(An));if(!vn.length)continue;const _n=mn===Nt.ELEMENT_ARRAY_BUFFER?It.BufferViewTarget.ELEMENT_ARRAY_BUFFER:void 0,En=mn===Nt.SPARSE?Zt(vn,fn,pn):Kt(vn,fn,pn,_n);pn+=En.byteLength,hn.push(...En.buffers)}if(jt.imageBufferViews.length&&Qt===0){for(let mn=0;mn<jt.imageBufferViews.length;mn++)if(Gt.bufferViews[Gt.images[mn].bufferView].byteOffset=pn,pn+=jt.imageBufferViews[mn].byteLength,hn.push(jt.imageBufferViews[mn]),pn%8){const vn=8-pn%8;pn+=vn,hn.push(new Uint8Array(vn))}}if(jt.otherBufferViews.has(rn))for(const mn of jt.otherBufferViews.get(rn))Gt.bufferViews.push({buffer:fn,byteOffset:pn,byteLength:mn.byteLength}),jt.otherBufferViewsIndexMap.set(mn,Gt.bufferViews.length-1),pn+=mn.byteLength,hn.push(mn);if(pn){let mn;Dt.format===g.GLB?mn=c:(mn=jt.bufferURIGenerator.createURI(rn,"bin"),en.uri=mn),en.byteLength=pn,zt.resources[mn]=E.concat(hn)}Gt.buffers.push(en),jt.bufferIndexMap.set(rn,Qt)}),Vt.listAccessors().find(rn=>!rn.getBuffer())&&Ht.warn("Skipped writing one or more Accessors: no Buffer assigned."),Gt.materials=Vt.listMaterials().map((rn,Qt)=>{const en=jt.createPropertyDef(rn);if(rn.getAlphaMode()!==ht.AlphaMode.OPAQUE&&(en.alphaMode=rn.getAlphaMode()),rn.getAlphaMode()===ht.AlphaMode.MASK&&(en.alphaCutoff=rn.getAlphaCutoff()),rn.getDoubleSided()&&(en.doubleSided=!0),en.pbrMetallicRoughness={},L.eq(rn.getBaseColorFactor(),[1,1,1,1])||(en.pbrMetallicRoughness.baseColorFactor=rn.getBaseColorFactor()),L.eq(rn.getEmissiveFactor(),[0,0,0])||(en.emissiveFactor=rn.getEmissiveFactor()),rn.getRoughnessFactor()!==1&&(en.pbrMetallicRoughness.roughnessFactor=rn.getRoughnessFactor()),rn.getMetallicFactor()!==1&&(en.pbrMetallicRoughness.metallicFactor=rn.getMetallicFactor()),rn.getBaseColorTexture()){const tn=rn.getBaseColorTexture(),sn=rn.getBaseColorTextureInfo();en.pbrMetallicRoughness.baseColorTexture=jt.createTextureInfoDef(tn,sn)}if(rn.getEmissiveTexture()){const tn=rn.getEmissiveTexture(),sn=rn.getEmissiveTextureInfo();en.emissiveTexture=jt.createTextureInfoDef(tn,sn)}if(rn.getNormalTexture()){const tn=rn.getNormalTexture(),sn=rn.getNormalTextureInfo(),cn=jt.createTextureInfoDef(tn,sn);rn.getNormalScale()!==1&&(cn.scale=rn.getNormalScale()),en.normalTexture=cn}if(rn.getOcclusionTexture()){const tn=rn.getOcclusionTexture(),sn=rn.getOcclusionTextureInfo(),cn=jt.createTextureInfoDef(tn,sn);rn.getOcclusionStrength()!==1&&(cn.strength=rn.getOcclusionStrength()),en.occlusionTexture=cn}if(rn.getMetallicRoughnessTexture()){const tn=rn.getMetallicRoughnessTexture(),sn=rn.getMetallicRoughnessTextureInfo();en.pbrMetallicRoughness.metallicRoughnessTexture=jt.createTextureInfoDef(tn,sn)}return jt.materialIndexMap.set(rn,Qt),en}),Gt.meshes=Vt.listMeshes().map((rn,Qt)=>{const en=jt.createPropertyDef(rn);let tn=null;return en.primitives=rn.listPrimitives().map(sn=>{const cn={attributes:{}};cn.mode=sn.getMode();const un=sn.getMaterial();un&&(cn.material=jt.materialIndexMap.get(un)),Object.keys(sn.getExtras()).length&&(cn.extras=sn.getExtras());const hn=sn.getIndices();hn&&(cn.indices=jt.accessorIndexMap.get(hn));for(const fn of sn.listSemantics())cn.attributes[fn]=jt.accessorIndexMap.get(sn.getAttribute(fn));for(const fn of sn.listTargets()){const pn={};for(const dn of fn.listSemantics())pn[dn]=jt.accessorIndexMap.get(fn.getAttribute(dn));cn.targets=cn.targets||[],cn.targets.push(pn)}return sn.listTargets().length&&!tn&&(tn=sn.listTargets().map(fn=>fn.getName())),cn}),rn.getWeights().length&&(en.weights=rn.getWeights()),tn&&(en.extras=en.extras||{},en.extras.targetNames=tn),jt.meshIndexMap.set(rn,Qt),en}),Gt.cameras=Vt.listCameras().map((rn,Qt)=>{const en=jt.createPropertyDef(rn);if(en.type=rn.getType(),en.type===st.Type.PERSPECTIVE){en.perspective={znear:rn.getZNear(),zfar:rn.getZFar(),yfov:rn.getYFov()};const tn=rn.getAspectRatio();tn!==null&&(en.perspective.aspectRatio=tn)}else en.orthographic={znear:rn.getZNear(),zfar:rn.getZFar(),xmag:rn.getXMag(),ymag:rn.getYMag()};return jt.cameraIndexMap.set(rn,Qt),en}),Gt.nodes=Vt.listNodes().map((rn,Qt)=>{const en=jt.createPropertyDef(rn);return L.eq(rn.getTranslation(),[0,0,0])||(en.translation=rn.getTranslation()),L.eq(rn.getRotation(),[0,0,0,1])||(en.rotation=rn.getRotation()),L.eq(rn.getScale(),[1,1,1])||(en.scale=rn.getScale()),rn.getWeights().length&&(en.weights=rn.getWeights()),jt.nodeIndexMap.set(rn,Qt),en}),Gt.skins=Vt.listSkins().map((rn,Qt)=>{const en=jt.createPropertyDef(rn),tn=rn.getInverseBindMatrices();tn&&(en.inverseBindMatrices=jt.accessorIndexMap.get(tn));const sn=rn.getSkeleton();return sn&&(en.skeleton=jt.nodeIndexMap.get(sn)),en.joints=rn.listJoints().map(cn=>jt.nodeIndexMap.get(cn)),jt.skinIndexMap.set(rn,Qt),en}),Vt.listNodes().forEach((rn,Qt)=>{const en=Gt.nodes[Qt],tn=rn.getMesh();tn&&(en.mesh=jt.meshIndexMap.get(tn));const sn=rn.getCamera();sn&&(en.camera=jt.cameraIndexMap.get(sn));const cn=rn.getSkin();cn&&(en.skin=jt.skinIndexMap.get(cn)),rn.listChildren().length>0&&(en.children=rn.listChildren().map(un=>jt.nodeIndexMap.get(un)))}),Gt.animations=Vt.listAnimations().map((rn,Qt)=>{const en=jt.createPropertyDef(rn),tn=new Map;return en.samplers=rn.listSamplers().map((sn,cn)=>{const un=jt.createPropertyDef(sn);return un.input=jt.accessorIndexMap.get(sn.getInput()),un.output=jt.accessorIndexMap.get(sn.getOutput()),un.interpolation=sn.getInterpolation(),tn.set(sn,cn),un}),en.channels=rn.listChannels().map(sn=>{const cn=jt.createPropertyDef(sn);return cn.sampler=tn.get(sn.getSampler()),cn.target={node:jt.nodeIndexMap.get(sn.getTargetNode()),path:sn.getTargetPath()},cn}),jt.animationIndexMap.set(rn,Qt),en}),Gt.scenes=Vt.listScenes().map((rn,Qt)=>{const en=jt.createPropertyDef(rn);return en.nodes=rn.listChildren().map(tn=>jt.nodeIndexMap.get(tn)),jt.sceneIndexMap.set(rn,Qt),en});const nn=Vt.getDefaultScene();return nn&&(Gt.scene=Vt.listScenes().indexOf(nn)),Gt.extensionsUsed=qt.map(rn=>rn.extensionName),Gt.extensionsRequired=Xt.map(rn=>rn.extensionName),qt.forEach(rn=>rn.write(jt)),function(rn){const Qt=[];for(const en in rn){const tn=rn[en];(Array.isArray(tn)&&tn.length===0||tn===null||tn===""||tn&&typeof tn=="object"&&Object.keys(tn).length===0)&&Qt.push(en)}for(const en of Qt)delete rn[en]}(Gt),zt}}var Bt;(function(kt){kt[kt.JSON=1313821514]="JSON",kt[kt.BIN=5130562]="BIN"})(Bt||(Bt={}));class Pt{constructor(){this.M=B$1.DEFAULT_INSTANCE,this.l=new Set,this.U={},this.P=f.INTERLEAVED,this.lastReadBytes=0,this.lastWriteBytes=0}setLogger(_e){return this.M=_e,this}registerExtensions(_e){for(const Dt of _e)this.l.add(Dt),Dt.register();return this}registerDependencies(_e){return Object.assign(this.U,_e),this}setVertexLayout(_e){return this.P=_e,this}async read(_e){return await this.readJSON(await this.readAsJSON(_e))}async readAsJSON(_e){const Dt=await this.readURI(_e,"view");this.lastReadBytes=Dt.byteLength;const Vt=Lt(Dt)?this.L(Dt):{json:JSON.parse(E.decodeText(Dt)),resources:{}};return await this.j(Vt,this.dirname(_e)),this.D(Vt),Vt}async readJSON(_e){return _e=this._(_e),this.D(_e),Et.read(_e,{extensions:Array.from(this.l),dependencies:this.U,logger:this.M})}async binaryToJSON(_e){const Dt=this.L(E.assertView(_e));this.D(Dt);const Vt=Dt.json;if(Vt.buffers&&Vt.buffers.some(Gt=>function(zt,jt){return jt.uri!==void 0&&!(jt.uri in zt.resources)}(Dt,Gt)))throw new Error("Cannot resolve external buffers with binaryToJSON().");if(Vt.images&&Vt.images.some(Gt=>function(zt,jt){return jt.uri!==void 0&&!(jt.uri in zt.resources)&&jt.bufferView===void 0}(Dt,Gt)))throw new Error("Cannot resolve external images with binaryToJSON().");return Dt}async readBinary(_e){return this.readJSON(await this.binaryToJSON(E.assertView(_e)))}async writeJSON(_e,Dt={}){if(Dt.format===g.GLB&&_e.getRoot().listBuffers().length>1)throw new Error("GLB must have 0–1 buffers.");return Ut.write(_e,{format:Dt.format||g.GLTF,basename:Dt.basename||"",logger:this.M,vertexLayout:this.P,dependencies:pt({},this.U),extensions:Array.from(this.l)})}async writeBinary(_e){const{json:Dt,resources:Vt}=await this.writeJSON(_e,{format:g.GLB}),Gt=new Uint32Array([1179937895,2,12]),zt=JSON.stringify(Dt),jt=E.pad(E.encodeText(zt),32),Ht=E.toView(new Uint32Array([jt.byteLength,1313821514])),Wt=E.concat([Ht,jt]);Gt[Gt.length-1]+=Wt.byteLength;const qt=Object.values(Vt)[0];if(!qt||!qt.byteLength)return E.concat([E.toView(Gt),Wt]);const Xt=E.pad(qt,0),Kt=E.toView(new Uint32Array([Xt.byteLength,5130562])),Yt=E.concat([Kt,Xt]);return Gt[Gt.length-1]+=Yt.byteLength,E.concat([E.toView(Gt),Wt,Yt])}async j(_e,Dt){var Vt=this;const Gt=[..._e.json.images||[],..._e.json.buffers||[]].map(async function(zt){const jt=zt.uri;if(!jt||jt.match(/data:/))return Promise.resolve();_e.resources[jt]=await Vt.readURI(Vt.resolve(Dt,jt),"view"),Vt.lastReadBytes+=_e.resources[jt].byteLength});await Promise.all(Gt)}D(_e){function Dt(Vt){if(Vt.uri){if(Vt.uri in _e.resources)E.assertView(_e.resources[Vt.uri]);else if(Vt.uri.match(/data:/)){const Gt=`__${V()}.${N.extension(Vt.uri)}`;_e.resources[Gt]=E.createBufferFromDataURI(Vt.uri),Vt.uri=Gt}}}(_e.json.images||[]).forEach(Vt=>{if(Vt.bufferView===void 0&&Vt.uri===void 0)throw new Error("Missing resource URI or buffer view.");Dt(Vt)}),(_e.json.buffers||[]).forEach(Dt)}_(_e){const{images:Dt,buffers:Vt}=_e.json;return _e={json:pt({},_e.json),resources:pt({},_e.resources)},Dt&&(_e.json.images=Dt.map(Gt=>pt({},Gt))),Vt&&(_e.json.buffers=Vt.map(Gt=>pt({},Gt))),_e}L(_e){if(!Lt(_e))throw new Error("Invalid glTF 2.0 binary.");const Dt=new Uint32Array(_e.buffer,_e.byteOffset+12,2);if(Dt[1]!==Bt.JSON)throw new Error("Missing required GLB JSON chunk.");const Vt=Dt[0],Gt=E.decodeText(E.toView(_e,20,Vt)),zt=JSON.parse(Gt),jt=20+Vt;if(_e.byteLength<=jt)return{json:zt,resources:{}};const Ht=new Uint32Array(_e.buffer,_e.byteOffset+jt,2);if(Ht[1]!==Bt.BIN)throw new Error("Expected GLB BIN in second chunk.");const Wt=E.toView(_e,jt+8,Ht[0]);return{json:zt,resources:{[c]:Wt}}}}function Lt(kt){if(kt.byteLength<3*Uint32Array.BYTES_PER_ELEMENT)return!1;const _e=new Uint32Array(kt.buffer,kt.byteOffset,3);return _e[0]===1179937895&&_e[1]===2}class _t extends Pt{constructor(_e=q$1.DEFAULT_INIT){super(),this.J=void 0,this.J=_e}async readURI(_e,Dt){const Vt=await fetch(_e,this.J);switch(Dt){case"view":return new Uint8Array(await Vt.arrayBuffer());case"text":return Vt.text()}}resolve(_e,Dt){return q$1.resolve(_e,Dt)}dirname(_e){return q$1.dirname(_e)}}function q(){return q=Object.assign?Object.assign.bind():function(kt){for(var _e=1;_e<arguments.length;_e++){var Dt=arguments[_e];for(var Vt in Dt)Object.prototype.hasOwnProperty.call(Dt,Vt)&&(kt[Vt]=Dt[Vt])}return kt},q.apply(this,arguments)}function B(kt,_e){return Object.defineProperty(_e,"name",{value:kt}),_e}function Z(kt,_e){if(kt==null&&_e==null)return!0;if(kt==null||_e==null||kt.length!==_e.length)return!1;for(let Dt=0;Dt<kt.length;Dt++)if(kt[Dt]!==_e[Dt])return!1;return!0}var ae=typeof Float32Array<"u"?Float32Array:Array;function ge(){var kt=new ae(3);return ae!=Float32Array&&(kt[0]=0,kt[1]=0,kt[2]=0),kt}function Ae(){var kt=new ae(4);return ae!=Float32Array&&(kt[0]=0,kt[1]=0,kt[2]=0,kt[3]=0),kt}Math.hypot||(Math.hypot=function(){for(var kt=0,_e=arguments.length;_e--;)kt+=arguments[_e]*arguments[_e];return Math.sqrt(kt)}),ge(),Ae();const Te="dedup",ye={propertyTypes:[h.ACCESSOR,h.MESH,h.TEXTURE,h.MATERIAL,h.SKIN]};function Ee(kt=ye){const _e=q({},ye,kt),Dt=new Set(_e.propertyTypes);for(const Vt of _e.propertyTypes)if(!ye.propertyTypes.includes(Vt))throw new Error(`${Te}: Unsupported deduplication on type "${Vt}".`);return B(Te,Vt=>{const Gt=Vt.getLogger();Dt.has(h.ACCESSOR)&&function(zt){const jt=zt.getLogger(),Ht=new Map,Wt=new Map,qt=new Map,Xt=new Map,Kt=zt.getRoot().listMeshes();Kt.forEach(rn=>{rn.listPrimitives().forEach(Qt=>{Qt.listAttributes().forEach(en=>Yt(en,Wt)),Yt(Qt.getIndices(),Ht)})});for(const rn of zt.getRoot().listAnimations())for(const Qt of rn.listSamplers())Yt(Qt.getInput(),qt),Yt(Qt.getOutput(),Xt);function Yt(rn,Qt){if(!rn)return;const en=[rn.getCount(),rn.getType(),rn.getComponentType(),rn.getNormalized(),rn.getSparse()].join(":");let tn=Qt.get(en);tn||Qt.set(en,tn=new Set),tn.add(rn)}function Zt(rn,Qt){for(let en=0;en<rn.length;en++){const tn=rn[en],sn=E.toView(tn.getArray());if(!Qt.has(tn))for(let cn=en+1;cn<rn.length;cn++){const un=rn[cn];Qt.has(un)||E.equals(sn,E.toView(un.getArray()))&&Qt.set(un,tn)}}}let Jt=0;const nn=new Map;for(const rn of[Wt,Ht,qt,Xt])for(const Qt of rn.values())Jt+=Qt.size,Zt(Array.from(Qt),nn);jt.debug(`${Te}: Merged ${nn.size} of ${Jt} accessors.`),Kt.forEach(rn=>{rn.listPrimitives().forEach(Qt=>{Qt.listAttributes().forEach(tn=>{nn.has(tn)&&Qt.swap(tn,nn.get(tn))});const en=Qt.getIndices();en&&nn.has(en)&&Qt.swap(en,nn.get(en))})});for(const rn of zt.getRoot().listAnimations())for(const Qt of rn.listSamplers()){const en=Qt.getInput(),tn=Qt.getOutput();en&&nn.has(en)&&Qt.swap(en,nn.get(en)),tn&&nn.has(tn)&&Qt.swap(tn,nn.get(tn))}Array.from(nn.keys()).forEach(rn=>rn.dispose())}(Vt),Dt.has(h.TEXTURE)&&function(zt){const jt=zt.getLogger(),Ht=zt.getRoot(),Wt=Ht.listTextures(),qt=new Map;for(let Xt=0;Xt<Wt.length;Xt++){const Kt=Wt[Xt],Yt=Kt.getImage();if(!qt.has(Kt))for(let Zt=Xt+1;Zt<Wt.length;Zt++){const Jt=Wt[Zt],nn=Jt.getImage();if(qt.has(Jt)||Kt.getMimeType()!==Jt.getMimeType())continue;const rn=Kt.getSize(),Qt=Jt.getSize();rn&&Qt&&rn[0]===Qt[0]&&rn[1]===Qt[1]&&Yt&&nn&&E.equals(Yt,nn)&&qt.set(Jt,Kt)}}jt.debug(`${Te}: Merged ${qt.size} of ${Ht.listTextures().length} textures.`),Array.from(qt.entries()).forEach(([Xt,Kt])=>{Xt.listParents().forEach(Yt=>{Yt instanceof vt||Yt.swap(Xt,Kt)}),Xt.dispose()})}(Vt),Dt.has(h.MATERIAL)&&function(zt){const jt=zt.getLogger(),Ht=zt.getRoot().listMaterials(),Wt=new Map,qt=new Set(["name"]),Xt=new Map;for(let Kt=0;Kt<Ht.length;Kt++){const Yt=Ht[Kt];if(!Wt.has(Yt)&&!Me(Yt,Xt))for(let Zt=Kt+1;Zt<Ht.length;Zt++){const Jt=Ht[Zt];Wt.has(Jt)||Me(Jt,Xt)||Yt.equals(Jt,qt)&&Wt.set(Jt,Yt)}}jt.debug(`${Te}: Merged ${Wt.size} of ${Ht.length} materials.`),Array.from(Wt.entries()).forEach(([Kt,Yt])=>{Kt.listParents().forEach(Zt=>{Zt instanceof vt||Zt.swap(Kt,Yt)}),Kt.dispose()})}(Vt),Dt.has(h.MESH)&&function(zt){const jt=zt.getLogger(),Ht=zt.getRoot(),Wt=new Map;Ht.listAccessors().forEach((Kt,Yt)=>Wt.set(Kt,Yt)),Ht.listMaterials().forEach((Kt,Yt)=>Wt.set(Kt,Yt));const qt=Ht.listMeshes().length,Xt=new Map;for(const Kt of Ht.listMeshes()){const Yt=[];for(const Jt of Kt.listPrimitives())Yt.push(Se(Jt,Wt));const Zt=Yt.join(";");if(Xt.has(Zt)){const Jt=Xt.get(Zt);Kt.listParents().forEach(nn=>{nn.propertyType!==h.ROOT&&nn.swap(Kt,Jt)}),Kt.dispose()}else Xt.set(Zt,Kt)}jt.debug(`${Te}: Merged ${qt-Xt.size} of ${qt} meshes.`)}(Vt),Dt.has(h.SKIN)&&function(zt){const jt=zt.getLogger(),Ht=zt.getRoot().listSkins(),Wt=new Map,qt=new Set(["name","joints"]);for(let Xt=0;Xt<Ht.length;Xt++){const Kt=Ht[Xt];if(!Wt.has(Kt))for(let Yt=Xt+1;Yt<Ht.length;Yt++){const Zt=Ht[Yt];Wt.has(Zt)||Kt.equals(Zt,qt)&&Z(Kt.listJoints(),Zt.listJoints())&&Wt.set(Zt,Kt)}}jt.debug(`${Te}: Merged ${Wt.size} of ${Ht.length} skins.`),Array.from(Wt.entries()).forEach(([Xt,Kt])=>{Xt.listParents().forEach(Yt=>{Yt instanceof vt||Yt.swap(Xt,Kt)}),Xt.dispose()})}(Vt),Gt.debug(`${Te}: Complete.`)})}function Se(kt,_e){const Dt=[];for(const Vt of kt.listSemantics()){const Gt=kt.getAttribute(Vt);Dt.push(Vt+":"+_e.get(Gt))}if(kt instanceof dt){const Vt=kt.getIndices();Vt&&Dt.push("indices:"+_e.get(Vt));const Gt=kt.getMaterial();Gt&&Dt.push("material:"+_e.get(Gt)),Dt.push("mode:"+kt.getMode());for(const zt of kt.listTargets())Dt.push("target:"+Se(zt,_e))}return Dt.join(",")}function Me(kt,_e){if(_e.has(kt))return _e.get(kt);const Dt=kt.getGraph(),Vt=new Set,Gt=Dt.listParentEdges(kt);for(;Gt.length>0;){const zt=Gt.pop();if(zt.getAttributes().modifyChild===!0)return _e.set(kt,!0),!0;const jt=zt.getChild();if(!Vt.has(jt))for(const Ht of Dt.listChildEdges(jt))Gt.push(Ht)}return _e.set(kt,!1),!1}function we(kt){const _e=kt.getGraph(),Dt=new Set,Vt=new Set;return function Gt(zt){const jt=new Set;for(const Ht of _e.listChildEdges(zt))Ht.getChild()instanceof yt&&jt.add(Ht.getName()+"Info");for(const Ht of _e.listChildEdges(zt)){const Wt=Ht.getChild();Dt.has(Wt)||(Dt.add(Wt),Wt instanceof it&&jt.has(Ht.getName())?Vt.add(Wt):Wt instanceof nt&&Gt(Wt))}}(kt),Array.from(Vt)}const be="prune",Ne={propertyTypes:[h.NODE,h.SKIN,h.MESH,h.CAMERA,h.PRIMITIVE,h.PRIMITIVE_TARGET,h.ANIMATION,h.MATERIAL,h.TEXTURE,h.ACCESSOR,h.BUFFER],keepLeaves:!1,keepAttributes:!0};function Re(kt=Ne){const _e=q({},Ne,kt),Dt=new Set(_e.propertyTypes);return B(be,Vt=>{const Gt=Vt.getLogger(),zt=Vt.getRoot(),jt=Vt.getGraph(),Ht={};if(Dt.has(h.MESH))for(const Yt of zt.listMeshes())Yt.listPrimitives().length>0||(Yt.dispose(),Kt(Yt));if(Dt.has(h.NODE)&&!_e.keepLeaves&&zt.listScenes().forEach(function Yt(Zt){if(Zt.listChildren().forEach(Yt),Zt instanceof mt)return;const Jt=jt.listParentEdges(Zt).some(nn=>{const rn=nn.getParent().propertyType;return rn!==h.ROOT&&rn!==h.SCENE&&rn!==h.NODE});jt.listChildren(Zt).length!==0||Jt||(Zt.dispose(),Kt(Zt))}),Dt.has(h.NODE)&&zt.listNodes().forEach(Wt),Dt.has(h.SKIN)&&zt.listSkins().forEach(Wt),Dt.has(h.MESH)&&zt.listMeshes().forEach(Wt),Dt.has(h.CAMERA)&&zt.listCameras().forEach(Wt),Dt.has(h.PRIMITIVE)&&qt(jt,h.PRIMITIVE),Dt.has(h.PRIMITIVE_TARGET)&&qt(jt,h.PRIMITIVE_TARGET),!_e.keepAttributes&&Dt.has(h.ACCESSOR)){const Yt=new Map;for(const Zt of zt.listMeshes())for(const Jt of Zt.listPrimitives()){const nn=Jt.getMaterial(),rn=Ce(Jt,Oe(Vt,nn));Xt(Jt,rn),Jt.listTargets().forEach(Qt=>Xt(Qt,rn)),nn&&(Yt.has(nn)?Yt.get(nn).add(Jt):Yt.set(nn,new Set([Jt])))}for(const[Zt,Jt]of Yt)$e(Zt,Array.from(Jt))}if(Dt.has(h.ANIMATION))for(const Yt of zt.listAnimations()){for(const Zt of Yt.listChannels())Zt.getTargetNode()||(Zt.dispose(),Kt(Zt));if(Yt.listChannels().length)Yt.listSamplers().forEach(Wt);else{const Zt=Yt.listSamplers();Wt(Yt),Zt.forEach(Wt)}}if(Dt.has(h.MATERIAL)&&zt.listMaterials().forEach(Wt),Dt.has(h.TEXTURE)&&zt.listTextures().forEach(Wt),Dt.has(h.ACCESSOR)&&zt.listAccessors().forEach(Wt),Dt.has(h.BUFFER)&&zt.listBuffers().forEach(Wt),Object.keys(Ht).length){const Yt=Object.keys(Ht).map(Zt=>`${Zt} (${Ht[Zt]})`).join(", ");Gt.info(`${be}: Removed types... ${Yt}`)}else Gt.info(`${be}: No unused properties found.`);function Wt(Yt){Yt.listParents().filter(Zt=>!(Zt instanceof vt||Zt instanceof tt)).length||(Yt.dispose(),Kt(Yt))}function qt(Yt,Zt){Yt.listEdges().map(Jt=>Jt.getParent()).filter(Jt=>Jt.propertyType===Zt).forEach(Wt)}function Xt(Yt,Zt){for(const Jt of Zt)Yt.setAttribute(Jt,null)}function Kt(Yt){Ht[Yt.propertyType]=Ht[Yt.propertyType]||0,Ht[Yt.propertyType]++}Gt.debug(`${be}: Complete.`)})}function Ce(kt,_e){const Dt=[];for(const Vt of kt.listSemantics())Vt!=="TANGENT"||_e.has(Vt)?(Vt.startsWith("TEXCOORD_")&&!_e.has(Vt)||Vt.startsWith("COLOR_")&&Vt!=="COLOR_0")&&Dt.push(Vt):Dt.push(Vt);return Dt}function Oe(kt,_e,Dt=new Set){if(!_e)return Dt;const Vt=kt.getGraph().listChildEdges(_e),Gt=new Set;for(const zt of Vt)zt.getChild()instanceof yt&&Gt.add(zt.getName());for(const zt of Vt){const jt=zt.getName(),Ht=zt.getChild();Ht instanceof it&&Gt.has(jt.replace(/Info$/,""))&&Dt.add(`TEXCOORD_${Ht.getTexCoord()}`),Ht instanceof yt&&jt.match(/normalTexture/i)&&Dt.add("TANGENT"),Ht instanceof nt&&Oe(kt,Ht,Dt)}return Dt}function $e(kt,_e){const Dt=we(kt),Vt=new Set(Dt.map(Wt=>Wt.getTexCoord())),Gt=Array.from(Vt).sort(),zt=new Map(Gt.map((Wt,qt)=>[Wt,qt])),jt=new Map(Gt.map((Wt,qt)=>[`TEXCOORD_${Wt}`,`TEXCOORD_${qt}`]));for(const Wt of Dt){const qt=Wt.getTexCoord();Wt.setTexCoord(zt.get(qt))}for(const Wt of _e){const qt=Wt.listSemantics().filter(Xt=>Xt.startsWith("TEXCOORD_")).sort();Ht(Wt,qt),Wt.listTargets().forEach(Xt=>Ht(Xt,qt))}function Ht(Wt,qt){for(const Xt of qt){const Kt=Wt.getAttribute(Xt);if(!Kt)continue;const Yt=jt.get(Xt);Yt!==Xt&&(Wt.setAttribute(Yt,Kt),Wt.setAttribute(Xt,null))}}}tt.TargetPath;var Vn;function Xn(kt,_e,Dt){for(let Vt=0,Gt=Dt.length;Vt<Gt;Vt++)Dt[Vt]=kt[_e*Gt+Vt];return Dt}function Kn(kt,_e,Dt){for(let Vt=0,Gt=Dt.length;Vt<Gt;Vt++)kt[_e*Gt+Vt]=Dt[Vt]}function Jn(kt,_e,Dt=0){if(kt.length!==_e.length)return!1;for(let Vt=0;Vt<kt.length;Vt++)if(Math.abs(kt[Vt]-_e[Vt])>Dt)return!1;return!0}function Zn(kt,_e,Dt){return kt*(1-Dt)+_e*Dt}function Qn(kt,_e,Dt,Vt){for(let Gt=0;Gt<_e.length;Gt++)kt[Gt]=Zn(_e[Gt],Dt[Gt],Vt);return kt}function Yn(kt,_e,Dt,Vt){let Gt,zt,jt,Ht,Wt,qt=_e[0],Xt=_e[1],Kt=_e[2],Yt=_e[3],Zt=Dt[0],Jt=Dt[1],nn=Dt[2],rn=Dt[3];return zt=qt*Zt+Xt*Jt+Kt*nn+Yt*rn,zt<0&&(zt=-zt,Zt=-Zt,Jt=-Jt,nn=-nn,rn=-rn),1-zt>1e-6?(Gt=Math.acos(zt),jt=Math.sin(Gt),Ht=Math.sin((1-Vt)*Gt)/jt,Wt=Math.sin(Vt*Gt)/jt):(Ht=1-Vt,Wt=Vt),kt[0]=Ht*qt+Wt*Zt,kt[1]=Ht*Xt+Wt*Jt,kt[2]=Ht*Kt+Wt*nn,kt[3]=Ht*Yt+Wt*rn,kt}function eo(kt,_e){const Dt=function(Vt,Gt){return Vt[0]*Gt[0]+Vt[1]*Gt[1]+Vt[2]*Gt[2]+Vt[3]*Gt[3]}(kt,_e);return Math.acos(2*Dt*Dt-1)}(function(kt){kt[kt.STEP=0]="STEP",kt[kt.LERP=1]="LERP",kt[kt.SLERP=2]="SLERP"})(Vn||(Vn={}));Promise.resolve();var yo;(function(kt){kt.LANCZOS3="lanczos3",kt.LANCZOS2="lanczos2"})(yo||(yo={}));yo.LANCZOS3;yo.LANCZOS3;async function getCurrentScene(kt){return kt.coreSceneStore.getState().sceneRef}function calculateSceneCenter(kt){const _e=new Box3().setFromObject(kt),Dt=new Vector3;return _e.getCenter(Dt),Dt.y=_e.min.y,Dt}function getItemsGroupFromScene(kt){return kt.getObjectByName("#ITEMS")}function filterOnlyItems(kt){return getItemsGroupFromScene(kt).children}async function getSceneAsUsdzUrl(kt){kt.coreSceneStore.setState({frameLoop:"never"}),await wait(1e3);try{const _e=new USDZExporter,Dt=await getCurrentScene(kt),Vt=calculateSceneCenter(Dt);Dt.position.sub(Vt);const Gt=Dt.rotation.clone(),zt=kt.coreSceneStore.getState().sceneSettings.arTransforms.rotation;Dt.rotation.set(MathUtils.degToRad(zt[0]),MathUtils.degToRad(zt[1]),MathUtils.degToRad(zt[2])),Dt.updateMatrixWorld();const jt=kt.coreSceneStore.getState().sceneSettings.usdzPrecision,Ht=kt.coreSceneStore.getState().sceneSettings.usdzMaxTextureSize,Wt=await _e.parseAsync(Dt,jt,Ht),qt=new Blob([Wt],{type:"model/vnd.usdz+zip"}),Xt=URL.createObjectURL(qt);return Dt.position.add(Vt),Dt.rotation.set(Gt.x,Gt.y,Gt.z),kt.coreSceneStore.setState({frameLoop:"always"}),Xt}catch(_e){return LOGGER.error("Error exporting USDZ: "+_e),kt.coreSceneStore.setState({frameLoop:"always"}),null}}async function getSceneAsGLBUrl(kt){kt.coreSceneStore.setState({frameLoop:"never"}),await wait(1e3);try{const _e=new _t,Dt=new GLTFExporter,Vt=await getCurrentScene(kt),Gt=filterOnlyItems(Vt),zt=calculateSceneCenter(Vt);for(const Yt of Gt)Yt.position.sub(zt);const jt={binary:!0,forceIndices:!0,trs:!1,onlyVisible:!0,embedImages:!0,maxTextureSize:1024},Ht=await Dt.parseAsync(Gt,jt),Wt=await _e.readBinary(new Uint8Array(Ht));for(const Yt of Gt)Yt.position.add(zt);const qt=await optimiseGlb(Wt),Xt=await _e.writeBinary(qt),Kt=await saveArrayBufferAsURL(Xt);return kt.coreSceneStore.setState({frameLoop:"always"}),Kt}catch(_e){return LOGGER.error({title:"Error exporting GLB: "+_e}),kt.coreSceneStore.setState({frameLoop:"always"}),null}}async function optimiseGlb(kt){const Dt=kt.getRoot().listNodes();for(const Vt of Dt){Vt.setExtras({});const Gt=Vt.getName();(Gt==="GRP_ProxyMesh"||Gt==="GRP_LoadingPlaceholder")&&Vt.dispose()}return await kt.transform(Ee(),Re()),LOGGER.info({title:"GLB as json"}),LOGGER.info({title:kt.getRoot().listTextures()}),kt}async function saveArrayBufferAsURL(kt){const _e=new Blob([kt],{type:"application/gltf-buffer"});return LOGGER.info({title:"Approx scene GLB size: "+_e.size/1e6}),URL.createObjectURL(_e)}const byteToHex=[];for(let kt=0;kt<256;++kt)byteToHex.push((kt+256).toString(16).slice(1));function unsafeStringify(kt,_e=0){return(byteToHex[kt[_e+0]]+byteToHex[kt[_e+1]]+byteToHex[kt[_e+2]]+byteToHex[kt[_e+3]]+"-"+byteToHex[kt[_e+4]]+byteToHex[kt[_e+5]]+"-"+byteToHex[kt[_e+6]]+byteToHex[kt[_e+7]]+"-"+byteToHex[kt[_e+8]]+byteToHex[kt[_e+9]]+"-"+byteToHex[kt[_e+10]]+byteToHex[kt[_e+11]]+byteToHex[kt[_e+12]]+byteToHex[kt[_e+13]]+byteToHex[kt[_e+14]]+byteToHex[kt[_e+15]]).toLowerCase()}let getRandomValues;const rnds8=new Uint8Array(16);function rng(){if(!getRandomValues){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");getRandomValues=crypto.getRandomValues.bind(crypto)}return getRandomValues(rnds8)}const randomUUID=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),native={randomUUID};function v4(kt,_e,Dt){if(native.randomUUID&&!_e&&!kt)return native.randomUUID();kt=kt||{};const Vt=kt.random??kt.rng?.()??rng();if(Vt.length<16)throw new Error("Random bytes length must be >= 16");if(Vt[6]=Vt[6]&15|64,Vt[8]=Vt[8]&63|128,_e){if(Dt=Dt||0,Dt<0||Dt+16>_e.length)throw new RangeError(`UUID byte range ${Dt}:${Dt+15} is out of buffer bounds`);for(let Gt=0;Gt<16;++Gt)_e[Dt+Gt]=Vt[Gt];return _e}return unsafeStringify(Vt)}class Plug{constructor(_e,Dt,Vt=null){this.stores=Dt.stores,this._attachedPlug=null,this._name=_e.name,this._acceptedPlugTypes=_e.acceptedPlugTypes,this._affectedNodes=_e.affectedNodes,this._unvisualizedCount=_e.unvisualizedCount,this._weight=_e.weight,this._connectsToPlugTypes=_e.connectsToPlugTypes,this._dependencySku=_e.dependencySku,this._isDependencySkuInteractive=_e.isDependencySkuInteractive,this._autoSpawnDependencyIfMissing=_e.autoSpawnDependencyIfMissing,this._node=Dt,Vt?(this._comboPlugConnector=Vt.comboPlugConnector,this._guid=Vt.guid,this._isOpen=Vt.isOpen,this._type=Vt.type,this._isReceiverPlug=Vt.isReceiverPlug,this._attachedPlugGUID=Vt.attachedPlugGUID):(this._comboPlugConnector=!1,this._guid=v4(),this._isOpen=!0,this._type=_e.type,this._isReceiverPlug=!1,this._attachedPlugGUID=null)}export(){return this.isOpen?null:{guid:this._guid,type:this._type,isOpen:this._isOpen,comboPlugConnector:this._comboPlugConnector,attachedPlugGUID:this._attachedPlugGUID,isReceiverPlug:this._isReceiverPlug}}get node(){return this._node}set comboPlugConnector(_e){this._comboPlugConnector=_e}get comboPlugConnector(){return this._comboPlugConnector}get attachedPlug(){return this._attachedPlug}set attachedPlug(_e){this._attachedPlug=_e}get attachedNode(){return this._attachedPlug?this._attachedPlug.node:null}get attachedPlugGUID(){return this._attachedPlugGUID}set type(_e){this._type=_e}get type(){return this._type}get weight(){return this._weight}get unvisualizedCount(){return this.__unvisualizedCount}get affectedNodes(){return this._affectedNodes}get guid(){return this._guid}get isReceiverPlug(){return this._isReceiverPlug}get name(){return this._name}get acceptedPlugTypes(){return this._acceptedPlugTypes}set acceptedPlugTypes(_e){this._acceptedPlugTypes=_e}get connectsToPlugTypes(){return this._connectsToPlugTypes}set connectsToPlugTypes(_e){this._connectsToPlugTypes=_e}get isOpen(){return this._isOpen}get isOccupied(){return!this.isOpen}attachPlug(_e,Dt=!1){this._attachedPlug=_e,this._attachedPlugGUID=_e.guid,this._isOpen=!1,this._isReceiverPlug=Dt;const Vt=this,Gt=this._node;if(Gt.isConnectedToRoot&&Dt){const zt=Gt.whichPlugAreWeAttachedUsing();switch(_e.type){case"weighted_hider":zt.weight<Vt.weight&&(Gt.showNodes(zt.affectedNodes)||this.stores.coreSceneStore.getState().CORE_API.coreWCRef.addEventListener(Gt.guid+":modelLoaded",function(){Gt.showNodes(zt.affectedNodes)},{once:!0}));break}}if(Dt&&_e.type!==""&&_e.type==Vt._type)switch(_e.type){default:case"weighted_hider":Vt._weight>_e.weight?_e.node.hideNodes(_e.affectedNodes)||this.stores.coreSceneStore.getState().CORE_API.coreWCRef.addEventListener(_e.node.guid+":modelLoaded",function(){_e.node.hideNodes(_e.affectedNodes)},{once:!0}):Vt._weight<_e.weight&&(Gt.hideNodes(Vt._affectedNodes)||this.stores.coreSceneStore.getState().CORE_API.coreWCRef.addEventListener(Gt.guid+":modelLoaded",function(){Gt.hideNodes(Vt._affectedNodes)},{once:!0}));break}Dt&&(Gt.isEndNode=!1)}async openPlug(){if(this._comboPlugConnector&&(this._comboPlugConnector=!1),this._node.isConnectedToRoot){const _e=this._node.whichPlugAreWeAttachedUsing();if(_e&&this._guid!==_e.guid)switch(this.type){case"weighted_hider":_e.type==="weighted_hider"&&_e.weight<this.weight&&this._node.hideNodes(_e.affectedNodes);break}}if(this._isReceiverPlug&&this._attachedPlug.type!==""&&this._attachedPlug.type==this._type)switch(this._attachedPlug.type){default:case"weighted_hider":this._weight>this._attachedPlug.weight?this._attachedPlug.node.showNodes(this._attachedPlug.affectedNodes):this._weight<this._attachedPlug.weight&&this._node.showNodes(this._affectedNodes);break}if(this._attachedPlug=null,this._attachedPlugGUID=null,this._isOpen=!0,this._isReceiverPlug&&(this._isReceiverPlug=!1,this._node.checkIfEndNode()),!!this._dependencySku&&!(this._autoSpawnDependencyIfMissing==!1||this._isDependencySkuInteractive||this.stores.coreSceneStore.getState().configurationLoaded===!1))try{const _e=await this.stores.ghostStore.getState().actions.spawnGhostsForSkuID(this._dependencySku,!0);if(!_e)return;const Dt=_e.connectablePlugs;let Vt=!1;const Gt=this._isDependencySkuInteractive?this.isDependencySkuInteractive===1:!1;for(const zt of Dt){if(zt.receiverPlug.guid!==this._guid)continue;Vt=!0;const jt=await this.stores.itemStore.getState().actions.addItemBySkuID(this._dependencySku,Dt.indexOf(zt),!0,Gt);jt!==null&&this._node.addMyDependenciesGUID(jt)}Vt||await this.stores.ghostStore.getState().actions.clearAllGhosts()}catch{LOGGER.info({title:"The Plug has been removed!"})}}canAttachToPlug(_e){for(let Dt=0;Dt<this._connectsToPlugTypes.length;Dt++)if(_e._acceptedPlugTypes.includes(this._connectsToPlugTypes[Dt]))return!0;return!1}}let Node$1=class{#t="default";#i=!1;#n=!1;#s=!0;#r={};#c=!1;#o=[];constructor(_e,Dt,Vt=null,Gt,zt){this.stores=_e;let jt=_e.productDataStore.getState().productData;this._plugs=[],this._skuID=Dt,this._ref=null,this._dragging=!1,this._modelFunctions=null,this._transform=null,this.#t="default",this._overrideVariant=null,this._followsParent=jt[Dt].followsParent,this._categoryID=jt[Dt].categoryID,this._replace=jt[Dt].replace,this._swappable=jt[Dt].swappable,this._price=this.#l(),this._compareAtPrice=this.#a(),this.#i=jt[Dt]?.ignoreInCart,Vt?(this._guid=Vt.guid,this._isEndNode=Vt.isEndNode,this._overrideVariant=Vt.overrideVariant,this.generatePlugsWithData(Dt,Vt.plugs)):(this._guid=v4(),this._isEndNode=!0,this.generatePlugsForNode(Dt)),Gt&&Object.keys(Gt).map(Ht=>{if(jt[Dt].looks&&jt[Dt].looks.includes(Ht)){this.#t=Ht;return}})}get isRoot(){return this._skuID.toLowerCase()==="root"}updateGeometryVariant(_e,Dt){const Gt=this.stores.productDataStore.getState().categoryData.geometryVariants;let zt=null;if(Gt.map(Xt=>{Xt.id==_e&&(zt=Xt)}),!zt)return;const jt=zt.productsInCategory,Wt=zt.variants[Dt].productsToSwitch,qt=this.stores.itemStore.getState().itemsSpawned;jt.map(Xt=>{Xt.products.map(Kt=>{this.skuID===Kt&&Xt.products.map(Yt=>{Wt.map(Zt=>{if(Zt==Yt){const Jt=this.stores.productDataStore.getState().actions.getProductDataById(Zt);this.skuID=Jt.skuID;const nn=qt[this.guid];nn&&nn.itemData&&Object.keys(Jt).map(rn=>{nn.itemData[rn]=Jt[rn]}),this.hideNodes(Jt.geometriesToHide),this.showNodes(Jt.geometriesToShow),this.updatePricing(),this.resetInStock(),this.stores.inventoryStore.getState().actions.refreshInventory(qt)}})})})})}resetInStock(){this.#r={},this.#c=!0}setInStockForRef(_e){if(!this.ref)return!1;let Dt=this.ref.getObjectByName("GRP_RenderGeometry");return Dt?(Dt.inStock=_e,!0):!1}set inStock({variantName:_e,newValue:Dt}){if(this.#r[_e]&&this.#r[_e]==Dt||(this.#r[_e]=Dt,_e!==this.currentVariant&&this.#c===!1))return;const Vt=()=>{this.setInStockForRef(Dt)};Vt()||this.stores.coreSceneStore.getState().CORE_API.coreWCRef.addEventListener(this.guid+":modelLoaded",Vt,{once:!0})}get myDependenciesGUID(){return this.#o}set myDependenciesGUID(_e){this.#o=_e}get dragging(){return this._dragging}set dragging(_e){this._dragging=_e}addMyDependenciesGUID(_e){this.#o.push(_e)}get isDependent(){return this.#n}set isDependent(_e){this.#n=_e}get isInteractive(){return this.#s}set isInteractive(_e){this.#s=_e}update(_e){this._skuID=_e;const Dt=this.stores.productDataStore.getState().productData,Vt=Dt[_e]?.plugs;if(this.ignoreInCart=Dt[_e].ignoreInCart,!!Vt)for(let Gt=0;Gt<this._plugs.length;Gt++)for(let zt=0;zt<Vt.length;zt++)this._plugs[Gt].name==Vt[zt].name&&(this._plugs[Gt].acceptedPlugTypes=Vt[zt].acceptedPlugTypes,this._plugs[Gt].connectsToPlugTypes=Vt[zt].connectsToPlugTypes)}export(){let _e={};for(let Dt=0;Dt<this._plugs.length;Dt++){let Vt=this._plugs[Dt].export();Vt&&(_e[this._plugs[Dt].name]=Vt)}return{skuID:this._skuID,guid:this._guid,isEndNode:this._isEndNode,plugs:_e,overrideVariant:this._overrideVariant}}get node(){return this}get swappable(){return this._swappable}get replace(){return this._replace}get ignoreInCart(){return this.#i}set ignoreInCart(_e){this.#i=_e}get isTypeCombo(){const _e=this.whichPlugAreWeAttachedUsing();return _e.type=="comboPlug"&&_e.connectsToPlugTypes.length>0}get canRotate(){let _e=!0;if(this.isTypeCombo)return!1;if(!this._isEndNode){const Vt=this.whichNodesAreAttachedToUs();if(Vt.length>0){let Gt=!0;if(Vt.map(zt=>{zt.followsParent===!1&&(Gt=!1)}),!Gt)return!1}}let Dt=!1;for(let Vt=0;Vt<this.plugs.length;Vt++)if(!this.plugs[Vt].isOpen&&this.plugs[Vt].attachedPlug.isReceiverPlug){const Gt=this.plugs[Vt].attachedPlug.acceptedPlugTypes;for(let zt=0;zt<this.plugs.length;zt++)if(Vt!=zt)for(let jt=0;jt<this.plugs[zt].connectsToPlugTypes.length;jt++)Gt.includes(this.plugs[zt].connectsToPlugTypes[jt])&&(Dt=!0)}return _e=Dt,_e}hideNodes(_e){if(!this.ref)return!1;const Dt=this.ref.getObjectByName("GRP_RenderGeometry"),Vt=this.ref.getObjectByName("GRP_ProxyMesh");return _e.map(Gt=>{if(Dt){const zt=Dt.getObjectByName(Gt);zt&&(zt.visible=!1)}if(Vt){const zt=Vt.getObjectByName(Gt);zt&&(zt.visible=!1)}}),!0}showNodes(_e){if(!this.ref)return!1;const Dt=this.ref.getObjectByName("GRP_RenderGeometry"),Vt=this.ref.getObjectByName("GRP_ProxyMesh");return _e.map(Gt=>{if(Dt){const zt=Dt.getObjectByName(Gt);zt&&(zt.visible=!0)}if(Vt){const zt=Vt.getObjectByName(Gt);zt&&(zt.visible=!0)}}),!0}canConnectToPlugType(_e){let Dt=!1;return this._plugs.map(Vt=>{Vt.connectsToPlugTypes.map(Gt=>{Gt==_e&&(Dt=!0)})}),Dt}isConnectedToSkuID(_e){let Dt=!1;return this._plugs.map(Vt=>{if(Vt.isOpen||Dt===!0)return;let Gt=Vt.attachedPlug;!Gt&&Vt.attachedPlugGUID&&(Gt=this.stores.attachmentStore.getState().attachmentSystem.currentStructure.getPlugByGUID(Vt.attachedPlugGUID)),Gt.node.skuID==_e&&(Dt=!0)}),Dt}get isConnectedToRoot(){return this.isConnectedToSkuID("Root")}swapRoot(){if(!this.canSwapRoot)return;const Dt=this.stores.attachmentStore.getState().attachmentSystem.currentStructure,Vt=this.whichNodesAreAttachedToUs();let Gt=null;Vt.map(qt=>{qt.followsParent===!1&&(Gt=qt)});const zt=Gt.detachNodeFromReceiver();let jt=null;this._plugs.map(qt=>{qt.isOpen||qt.attachedPlug.node.skuID=="Root"&&(jt=qt.attachedPlug)});const Ht=this.detachNodeFromReceiver();let Wt=null;return Gt.plugs.map(qt=>{qt.connectsToPlugTypes.includes("root")&&(Wt=qt)}),Dt.connectPlugs({incomingPlug:Wt,receiverPlug:jt}),{neighborDetachedPlugs:zt,rootDetachedPlugs:Ht,neighborNode:Gt}}get canSwapRoot(){if(this.stores.coreSceneStore.getState().sceneSettings.swappableRoot===!1)return!1;let _e=!1;if(this.isConnectedToRoot&&!this._isEndNode){const Vt=this.whichNodesAreAttachedToUs();let Gt=0,zt=null;Vt.map(jt=>{jt.followsParent===!1&&(Gt++,zt=jt)}),Gt==1?zt.canConnectToPlugType("root")&&(_e=!0):Gt>0&&(_e=!1)}return _e}get canRemove(){let _e=!0;return this._isEndNode||(this.whichNodesAreAttachedToUs().map(Vt=>{Vt.followsParent===!1&&(_e=!1)}),_e||(_e=this.canSwapRoot)),_e}getComboPlugNodesAttachedToUs(){let _e=[];return this.whichNodesAreAttachedToUs().forEach(Vt=>{Vt.isTypeCombo&&_e.push(Vt);const Gt=Vt.getComboPlugNodesAttachedToUs();Gt.length>0&&(_e=_e.concat(Gt))}),_e}getAllBranchedNodesAttachedToUs(){let _e=[];const Dt=this.whichNodesAreAttachedToUs();for(let Vt=0;Vt<Dt.length;Vt++){_e.push(Dt[Vt]);const Gt=Dt[Vt].getAllBranchedNodesAttachedToUs();Gt.length>0&&(_e=_e.concat(Gt))}return _e}get canDrag(){let _e=!0;if(this.isTypeCombo)return!1;for(let Vt=0;Vt<this._plugs.length;Vt++)if(this._plugs[Vt].isOpen==!1&&this._plugs[Vt].attachedPlug.type=="comboPlug")return!1;const Dt=this.getComboPlugNodesAttachedToUs();if(Dt.length>0){const Vt=this.getAllBranchedNodesAttachedToUs();let Gt=!0;if(Dt.map(zt=>{const jt=zt.whichNodesIsThisComboPlugAttachedTo();let Ht=!0;if(jt.map(Wt=>{let qt=!1;if(Vt.map(Xt=>{Wt.guid===Xt.guid&&(qt=!0)}),qt==!1){Ht=!1;return}}),Ht==!1){Gt=!1;return}}),Gt==!1)return!1}return this._isEndNode||(this.whichNodesAreAttachedToUs().map(Gt=>{Gt.followsParent===!1&&(_e=!1)}),_e||(_e=this.canSwapRoot)),_e}get followsParent(){return this._followsParent}set followsParent(_e){this._followsParent=_e}resetFollowsParent(){const _e=this.stores.productDataStore.getState().productData;this._followsParent=_e[this.skuID].followsParent}get currentVariant(){return this.#t==="default"?this.stores.productDataStore.getState().actions.getProductDataById(this._skuID).lookDetails.default.id:this.#t}get price(){return this._price}set price(_e){this._price=_e}get compareAtPrice(){return this._compareAtPrice}set compareAtPrice(_e){this._compareAtPrice=_e}updateCompareAtPricing(){this._compareAtPrice=this.#a()}updatePricing(){this._price=this.#l()}#a(){let Dt=this.stores.productDataStore.getState().actions.getProductDataById(this._skuID).lookDetails[this.#t]?.compareAtPrice;return Dt||(Dt=0),Dt}#l(){let Dt=this.stores.productDataStore.getState().actions.getProductDataById(this._skuID).lookDetails[this.#t]?.price;return Dt||(Dt=0),Dt}set currentVariant(_e){this.#t=_e,this._price=this.#l(),this._compareAtPrice=this.#a()}get overrideVariant(){return this._overrideVariant}set overrideVariant(_e){this._overrideVariant=_e,this.#t=this._overrideVariant,this._price=this.#l(),this._compareAtPrice=this.#a()}get guid(){return this._guid}get skuID(){return this._skuID}set skuID(_e){this._skuID=_e}get plugs(){return this._plugs}get ref(){return this._ref}set ref(_e){this._ref=_e}get modelFunctions(){return this._modelFunctions}set modelFunctions(_e){this._modelFunctions=_e}checkGeometryVariant(){let _e=new CustomEvent(this._guid+":modelLoaded",{bubbles:!0,cancelable:!1,composed:!0});const Dt=this.stores.attachmentStore.getState().attachmentSystem;Dt.globalGeometryVariants&&Object.keys(Dt.globalGeometryVariants).map(Vt=>{this.updateGeometryVariant(Vt,Dt.globalGeometryVariants[Vt])}),_e.data={},this.stores.coreSceneStore.getState().CORE_API.coreWCRef?this.stores.coreSceneStore.getState().CORE_API.coreWCRef.dispatchEvent(_e):LOGGER.warn({title:"core web component not found!"})}get isEndNode(){return this._isEndNode}set isEndNode(_e){this._isEndNode=_e}get categoryID(){return this._categoryID}get transform(){return this._transform}set transform(_e){this._transform=_e}setModelVisibility(_e){_e?this._ref?.scale.set(1,1,1):this._ref.scale.set(0,0,0)}checkIfEndNode(){let _e=!0;for(let Dt=0;Dt<this._plugs.length;Dt++)this._plugs[Dt].isReceiverPlug&&(_e=!1);this.isEndNode=_e}whichNodesAreAttachedToUs(){const _e=[];for(let Dt=0;Dt<this._plugs.length;Dt++)this._plugs[Dt].isReceiverPlug&&_e.push(this._plugs[Dt].attachedPlug.node);return _e}whichPlugsAreAttachedToUs(){const _e=[];for(let Dt=0;Dt<this._plugs.length;Dt++)this._plugs[Dt].isReceiverPlug&&_e.push({receiverPlug:this._plugs[Dt],incomingPlug:this._plugs[Dt].attachedPlug});return _e}whichNodeAreWeAttachedTo(){let _e=null;for(const Dt of this._plugs)Dt?.attachedPlug?.isReceiverPlug&&(_e=Dt.attachedPlug.node);return _e}whichNodesIsThisComboPlugAttachedTo(){if(!this.isTypeCombo)return[];let _e=[];for(const Dt of this._plugs)Dt?.attachedPlug?.isReceiverPlug&&_e.push(Dt.attachedPlug.node);return _e}isReplaceableWithSkuIdOld(_e){const Vt=this.stores.productDataStore.getState().productData[_e]?.plugs;let Gt=0;if(!Vt)return!1;for(let zt=0;zt<this._plugs.length;zt++)for(let jt=0;jt<Vt.length;jt++)this._plugs[zt].name==Vt[jt].name&&Gt++;return Gt==this._plugs.length}isReplaceableWithSkuId(_e){const Vt=this.stores.productDataStore.getState().productData[_e]?.plugs;if(!Vt)return LOGGER.warn({title:`The new sku ${_e} is invalid for this experience to replace this node: `,details:this}),!1;let Gt=!1,zt=!0;const jt=this.whichPlugAreWeAttachedTo();for(const Wt of Vt)if(Gt=hasCommonElement(jt.acceptedPlugTypes,Wt.connectsToPlugTypes),Gt===!0)break;const Ht=this.whichPlugsAreAttachedToUs();for(const Wt of Ht)for(const qt of Vt)if(zt=hasCommonElement(qt.acceptedPlugTypes,Wt.connectsToPlugTypes),zt===!1)break;return Gt&&zt}getAllSkusThatCanReplaceMe(){let _e=[];const Dt=this.stores.productDataStore.getState().productData;return Object.keys(Dt).map(Vt=>{Vt!=this.skuID&&this.isReplaceableWithSkuId(Vt)&&_e.push(Vt)}),_e}whichPlugAreWeAttachedUsing(){for(let _e=0;_e<this._plugs.length;_e++){const Dt=this._plugs[_e];let Vt=Dt.attachedPlug;if(!Vt&&Dt.attachedPlugGUID&&(Vt=this.stores.attachmentStore.getState().attachmentSystem.currentStructure.getPlugByGUID(Dt.attachedPlugGUID)),!Dt.isOpen&&Vt.isReceiverPlug)return Dt}}whichPlugAreWeAttachedTo(){for(let _e=0;_e<this._plugs.length;_e++)if(!this._plugs[_e].isOpen&&this._plugs[_e].attachedPlug.isReceiverPlug)return this._plugs[_e].attachedPlug}getPlugWhichCanConnectToType(_e){for(const Dt of this._plugs)if(Dt.connectsToPlugTypes.includes(_e))return Dt;return null}getOpenPlugsWeCanAttachFrom(){let _e=[];if(this.whichNodeAreWeAttachedTo())return _e;for(let Dt=0;Dt<this._plugs.length;Dt++)this.plugs[Dt].isOpen&&this.plugs[Dt].connectsToPlugTypes.length>0&&_e.push(this._plugs[Dt]);return _e}getOpenPlugsFromNode(){let _e=[];for(let Dt=0;Dt<this._plugs.length;Dt++)this._plugs[Dt].isOpen&&this._plugs[Dt].acceptedPlugTypes.length>0&&_e.push(this._plugs[Dt]);return _e}generatePlugsForNode(_e){this._plugs=[];let Dt=this.stores.productDataStore.getState().productData[_e]?.plugs;if(Dt)for(let Vt=0;Vt<Dt.length;Vt++)if(Dt[Vt].type==="unvisualizedPlug"){const Gt=Dt[Vt]?.unvisualizedCount>=0?Dt[Vt].unvisualizedCount:1e3;for(let zt=0;zt<Gt;zt++){const jt=new Plug({...Dt[Vt],name:`${Dt[Vt].name}_${zt}`},this);this._plugs.push(jt)}}else{const Gt=new Plug(Dt[Vt],this);this._plugs.push(Gt)}}generatePlugsWithData(_e,Dt){const Vt=this.stores.productDataStore.getState().productData[_e]?.plugs;Vt&&Vt.forEach(Gt=>{if(Gt.type==="unvisualizedPlug"){const zt=Gt.unvisualizedCount&&Gt.unvisualizedCount>=0?Gt.unvisualizedCount:1e3;for(let jt=0;jt<zt;jt++){const Ht=new Plug({...Gt,name:`${Gt.name}_${jt}`},this,Dt[`${Gt.name}_${jt}`]);this._plugs.push(Ht)}}else{const zt=new Plug(Gt,this,Dt[Gt.name]);this._plugs.push(zt)}})}detachNodeFromReceiver(){for(let _e=0;_e<this.plugs.length;_e++)if(!this.plugs[_e].isOpen&&this.plugs[_e].attachedPlug.isReceiverPlug){const Dt={incomingPlug:this.plugs[_e],receiverPlug:this.plugs[_e].attachedPlug};return this.plugs[_e].attachedPlug.openPlug(),this.plugs[_e].openPlug(),Dt}}detachNodeCompletely(){for(let _e=0;_e<this._plugs.length;_e++)this._plugs[_e].isOpen||(this._plugs[_e].attachedPlug.openPlug(),this._plugs[_e].openPlug())}getPlugByName(_e){for(let Dt=0;Dt<this._plugs.length;Dt++)if(this._plugs[Dt].name==_e)return this._plugs[Dt];return null}getPlugByGUID(_e){for(let Dt=0;Dt<this._plugs.length;Dt++)if(this._plugs[Dt].guid==_e)return this._plugs[Dt];return null}async removeNode(){const _e=[];for(const Dt of this._plugs)if(!Dt.isOpen){if(Dt.type==="comboPlug"&&Dt.connectsToPlugTypes.length>0){Dt.attachedPlug.openPlug();continue}Dt.attachedPlug.isReceiverPlug?Dt.attachedPlug.openPlug():_e.push(Dt.attachedPlug.node.guid)}if(_e.length>0)for(const Dt of _e)this.stores.itemStore.getState().actions.addToRemoveItems(Dt);this.modelFunctions=null,this.ref=null}};const EPIGRAPH_CONFIGURATOR_CATEGORY="Epigraph - Configurator",CONFIGURATOR_LOADING={type:"event",category:EPIGRAPH_CONFIGURATOR_CATEGORY,action:"configuratorLoading",label:"",interaction:{nonInteraction:!0}},CONFIGURATOR_READY={type:"event",category:EPIGRAPH_CONFIGURATOR_CATEGORY,action:"configuratorReady",label:"",interaction:{nonInteraction:!0}},CONFIGURATOR_FAILED={type:"event",category:EPIGRAPH_CONFIGURATOR_CATEGORY,action:"configuratorFailed",label:"",interaction:{nonInteraction:!0}},CONFIGURATOR_REVIEW_CART_SHOWN={type:"event",category:EPIGRAPH_CONFIGURATOR_CATEGORY,action:"configuratorReviewCartShown",label:"",interaction:{nonInteraction:!1}},CONFIGURATOR_REVIEW_CART_HIDE={type:"event",category:EPIGRAPH_CONFIGURATOR_CATEGORY,action:"configuratorReviewCartHide",label:"",interaction:{nonInteraction:!1}},CONFIGURATOR_CHECKOUT={type:"event",category:EPIGRAPH_CONFIGURATOR_CATEGORY,action:"configuratorCheckout",label:"",interaction:{nonInteraction:!1}},CONFIGURATOR_CHECKOUT_ITEM={type:"event",category:EPIGRAPH_CONFIGURATOR_CATEGORY,action:"configuratorCheckoutItemDetails",label:"",interaction:{nonInteraction:!1}},CONFIGURATOR_GLOBAL_GEOMETRY_VARIANT_SWITCHED={type:"event",category:EPIGRAPH_CONFIGURATOR_CATEGORY,action:"configuratorGlobalGeometryVariantSwitched",label:"",interaction:{nonInteraction:!1}},CONFIGURATOR_GLOBAL_VARIANT_SWITCHED={type:"event",category:EPIGRAPH_CONFIGURATOR_CATEGORY,action:"configuratorGlobalVariantSwitched",label:"",interaction:{nonInteraction:!1}},CONFIGURATOR_LOCAL_VARIANT_SWITCHED={type:"event",category:EPIGRAPH_CONFIGURATOR_CATEGORY,action:"configuratorLocalVariantSwitched",label:"",interaction:{nonInteraction:!1}},CONFIGURATOR_LOAD_FROM_PRECONFIG={type:"event",category:EPIGRAPH_CONFIGURATOR_CATEGORY,action:"configuratorLoadFromPreConfiguration",label:"",interaction:{nonInteraction:!0}},CONFIGURATOR_PRECONFIGURATION_ITEM_ADDED={type:"event",category:EPIGRAPH_CONFIGURATOR_CATEGORY,action:"preconfigurationItemAdded",label:"",interaction:{nonInteraction:!0}},CONFIGURATOR_SCENE_RESTARTED={type:"event",category:EPIGRAPH_CONFIGURATOR_CATEGORY,action:"configuratorSceneRestarted",label:"",interaction:{nonInteraction:!1}},CONFIGURATOR_AR_REQUESTED={type:"event",category:EPIGRAPH_CONFIGURATOR_CATEGORY,action:"configuratorArRequested",label:"",interaction:{nonInteraction:!1}},CONFIGURATOR_ITEM_REMOVED={type:"event",category:EPIGRAPH_CONFIGURATOR_CATEGORY,action:"configuratorItemRemoved",label:"",interaction:{nonInteraction:!1}},CONFIGURATOR_ITEM_ADDED={type:"event",category:EPIGRAPH_CONFIGURATOR_CATEGORY,action:"configuratorItemAdded",label:"",interaction:{nonInteraction:!1}},CONFIGURATOR_INSTRUCTIONS_BTN_CLICKED={type:"event",category:EPIGRAPH_CONFIGURATOR_CATEGORY,action:"configuratorInstructionsBtnClicked",label:"",interaction:{nonInteraction:!1}},CONFIGURATOR_INSTRUCTIONS_COMPLETION_RATE={type:"event",category:EPIGRAPH_CONFIGURATOR_CATEGORY,action:"configuratorInstructionsStageCompletionRate",label:"",interaction:{nonInteraction:!1}},CONFIGURATOR_INSTRUCTIONS_SHOWN={type:"event",category:EPIGRAPH_CONFIGURATOR_CATEGORY,action:"configuratorInstructionsShow",label:"",interaction:{nonInteraction:!1}},CONFIGURATOR_DIMENSION_SHOWN={type:"event",category:EPIGRAPH_CONFIGURATOR_CATEGORY,action:"configuratorDimensionsBtnShow",label:"",interaction:{nonInteraction:!1}},CONFIGURATOR_DIMENSION_HIDE={type:"event",category:EPIGRAPH_CONFIGURATOR_CATEGORY,action:"configuratorDimensionsBtnHide",label:"",interaction:{nonInteraction:!1}},CONFIGURATOR_HOTSPOT_ENTER={type:"event",category:EPIGRAPH_CONFIGURATOR_CATEGORY,action:"configuratorHotspotEnter",label:"",interaction:{nonInteraction:!1}},CONFIGURATOR_HOTSPOT_EXIT={type:"event",category:EPIGRAPH_CONFIGURATOR_CATEGORY,action:"configuratorHotspotExit",label:"",interaction:{nonInteraction:!1}},CONFIGURATOR_SCENE_SHARED={type:"event",category:EPIGRAPH_CONFIGURATOR_CATEGORY,action:"configuratorSceneShared",label:"",interaction:{nonInteraction:!1}};/* @license
4636
+ `}class EventDispatcher{constructor(){this._listeners={}}addEventListener(_e,Dt){const Vt=this._listeners;return Vt[_e]===void 0&&(Vt[_e]=[]),Vt[_e].indexOf(Dt)===-1&&Vt[_e].push(Dt),this}removeEventListener(_e,Dt){if(this._listeners===void 0)return this;const Gt=this._listeners[_e];if(Gt!==void 0){const zt=Gt.indexOf(Dt);zt!==-1&&Gt.splice(zt,1)}return this}dispatchEvent(_e){if(this._listeners===void 0)return this;const Vt=this._listeners[_e.type];if(Vt!==void 0){const Gt=Vt.slice(0);for(let zt=0,jt=Gt.length;zt<jt;zt++)Gt[zt].call(this,_e)}return this}dispose(){for(const _e in this._listeners)delete this._listeners[_e]}}class GraphEdge extends EventDispatcher{constructor(_e,Dt,Vt,Gt={}){if(super(),this._name=void 0,this._parent=void 0,this._child=void 0,this._attributes=void 0,this._disposed=!1,this._name=_e,this._parent=Dt,this._child=Vt,this._attributes=Gt,!Dt.isOnGraph(Vt))throw new Error("Cannot connect disconnected graphs.")}getName(){return this._name}getParent(){return this._parent}getChild(){return this._child}setChild(_e){return this._child=_e,this}getAttributes(){return this._attributes}dispose(){this._disposed||(this._disposed=!0,this.dispatchEvent({type:"dispose",target:this}),super.dispose())}isDisposed(){return this._disposed}}class Graph extends EventDispatcher{constructor(..._e){super(..._e),this._emptySet=new Set,this._edges=new Set,this._parentEdges=new Map,this._childEdges=new Map}listEdges(){return Array.from(this._edges)}listParentEdges(_e){return Array.from(this._childEdges.get(_e)||this._emptySet)}listParents(_e){return this.listParentEdges(_e).map(Dt=>Dt.getParent())}listChildEdges(_e){return Array.from(this._parentEdges.get(_e)||this._emptySet)}listChildren(_e){return this.listChildEdges(_e).map(Dt=>Dt.getChild())}disconnectParents(_e,Dt){let Vt=this.listParentEdges(_e);return Dt&&(Vt=Vt.filter(Gt=>Dt(Gt.getParent()))),Vt.forEach(Gt=>Gt.dispose()),this}createEdge(_e,Dt,Vt,Gt){return this._registerEdge(new GraphEdge(_e,Dt,Vt,Gt))}_registerEdge(_e){this._edges.add(_e);const Dt=_e.getParent();this._parentEdges.has(Dt)||this._parentEdges.set(Dt,new Set),this._parentEdges.get(Dt).add(_e);const Vt=_e.getChild();return this._childEdges.has(Vt)||this._childEdges.set(Vt,new Set),this._childEdges.get(Vt).add(_e),_e.addEventListener("dispose",()=>this._removeEdge(_e)),_e}_removeEdge(_e){return this._edges.delete(_e),this._parentEdges.get(_e.getParent()).delete(_e),this._childEdges.get(_e.getChild()).delete(_e),this}}function _extends(){return _extends=Object.assign||function(kt){for(var _e=1;_e<arguments.length;_e++){var Dt=arguments[_e];for(var Vt in Dt)Object.prototype.hasOwnProperty.call(Dt,Vt)&&(kt[Vt]=Dt[Vt])}return kt},_extends.apply(this,arguments)}function isRef(kt){return kt instanceof GraphEdge}function isRefList(kt){return Array.isArray(kt)&&kt[0]instanceof GraphEdge}function isRefMap(kt){return!!(isPlainObject(kt)&&getFirstValue(kt)instanceof GraphEdge)}function getFirstValue(kt){for(const _e in kt)return kt[_e]}function isPlainObject(kt){return!!kt&&Object.getPrototypeOf(kt)===Object.prototype}const $attributes=Symbol("attributes"),$immutableKeys=Symbol("immutableKeys");class GraphNode extends EventDispatcher{constructor(_e){super(),this._disposed=!1,this.graph=void 0,this[$attributes]=void 0,this[$immutableKeys]=void 0,this.graph=_e,this[$immutableKeys]=new Set,this[$attributes]=this._createAttributes()}getDefaults(){return{}}_createAttributes(){const _e=this.getDefaults(),Dt={};for(const Vt in _e){const Gt=_e[Vt];if(Gt instanceof GraphNode){const zt=this.graph.createEdge(Vt,this,Gt);zt.addEventListener("dispose",()=>Gt.dispose()),this[$immutableKeys].add(Vt),Dt[Vt]=zt}else Dt[Vt]=Gt}return Dt}isOnGraph(_e){return this.graph===_e.graph}isDisposed(){return this._disposed}dispose(){this._disposed||(this.graph.listChildEdges(this).forEach(_e=>_e.dispose()),this.graph.disconnectParents(this),this._disposed=!0,this.dispatchEvent({type:"dispose"}))}detach(){return this.graph.disconnectParents(this),this}swap(_e,Dt){for(const Vt in this[$attributes]){const Gt=this[$attributes][Vt];if(isRef(Gt)){const zt=Gt;zt.getChild()===_e&&this.setRef(Vt,Dt,zt.getAttributes())}else if(isRefList(Gt)){const jt=Gt.find(Ht=>Ht.getChild()===_e);if(jt){const Ht=jt.getAttributes();this.removeRef(Vt,_e).addRef(Vt,Dt,Ht)}}else if(isRefMap(Gt)){const zt=Gt;for(const jt in zt){const Ht=zt[jt];Ht.getChild()===_e&&this.setRefMap(Vt,jt,Dt,Ht.getAttributes())}}}return this}get(_e){return this[$attributes][_e]}set(_e,Dt){return this[$attributes][_e]=Dt,this.dispatchEvent({type:"change",attribute:_e})}getRef(_e){const Dt=this[$attributes][_e];return Dt?Dt.getChild():null}setRef(_e,Dt,Vt){if(this[$immutableKeys].has(_e))throw new Error(`Cannot overwrite immutable attribute, "${_e}".`);const Gt=this[$attributes][_e];if(Gt&&Gt.dispose(),!Dt)return this;const zt=this.graph.createEdge(_e,this,Dt,Vt);return zt.addEventListener("dispose",()=>{delete this[$attributes][_e],this.dispatchEvent({type:"change",attribute:_e})}),this[$attributes][_e]=zt,this.dispatchEvent({type:"change",attribute:_e})}listRefs(_e){return this[$attributes][_e].map(Vt=>Vt.getChild())}addRef(_e,Dt,Vt){const Gt=this.graph.createEdge(_e,this,Dt,Vt),zt=this[$attributes][_e];return zt.push(Gt),Gt.addEventListener("dispose",()=>{let jt;for(;(jt=zt.indexOf(Gt))!==-1;)zt.splice(jt,1);this.dispatchEvent({type:"change",attribute:_e})}),this.dispatchEvent({type:"change",attribute:_e})}removeRef(_e,Dt){return this[$attributes][_e].filter(zt=>zt.getChild()===Dt).forEach(zt=>zt.dispose()),this}listRefMapKeys(_e){return Object.keys(this[$attributes][_e])}listRefMapValues(_e){return Object.values(this[$attributes][_e]).map(Dt=>Dt.getChild())}getRefMap(_e,Dt){const Vt=this[$attributes][_e];return Vt[Dt]?Vt[Dt].getChild():null}setRefMap(_e,Dt,Vt,Gt){const zt=this[$attributes][_e],jt=zt[Dt];if(jt&&jt.dispose(),!Vt)return this;Gt=Object.assign(Gt||{},{key:Dt});const Ht=this.graph.createEdge(_e,this,Vt,_extends({},Gt,{key:Dt}));return Ht.addEventListener("dispose",()=>{delete zt[Dt],this.dispatchEvent({type:"change",attribute:_e,key:Dt})}),zt[Dt]=Ht,this.dispatchEvent({type:"change",attribute:_e,key:Dt})}dispatchEvent(_e){return super.dispatchEvent(_extends({},_e,{target:this})),this.graph.dispatchEvent(_extends({},_e,{target:this,type:`node:${_e.type}`})),this}}const u="v3.7.3",c="@glb.bin";var h,f,l,d,g;(function(kt){kt.ACCESSOR="Accessor",kt.ANIMATION="Animation",kt.ANIMATION_CHANNEL="AnimationChannel",kt.ANIMATION_SAMPLER="AnimationSampler",kt.BUFFER="Buffer",kt.CAMERA="Camera",kt.MATERIAL="Material",kt.MESH="Mesh",kt.PRIMITIVE="Primitive",kt.PRIMITIVE_TARGET="PrimitiveTarget",kt.NODE="Node",kt.ROOT="Root",kt.SCENE="Scene",kt.SKIN="Skin",kt.TEXTURE="Texture",kt.TEXTURE_INFO="TextureInfo"})(h||(h={})),function(kt){kt.INTERLEAVED="interleaved",kt.SEPARATE="separate"}(f||(f={})),function(kt){kt.ARRAY_BUFFER="ARRAY_BUFFER",kt.ELEMENT_ARRAY_BUFFER="ELEMENT_ARRAY_BUFFER",kt.INVERSE_BIND_MATRICES="INVERSE_BIND_MATRICES",kt.OTHER="OTHER",kt.SPARSE="SPARSE"}(l||(l={})),function(kt){kt[kt.R=4096]="R",kt[kt.G=256]="G",kt[kt.B=16]="B",kt[kt.A=1]="A"}(d||(d={})),function(kt){kt.GLTF="GLTF",kt.GLB="GLB"}(g||(g={}));const p={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};var m,w=typeof Float32Array<"u"?Float32Array:Array;function y(kt){return Math.hypot(kt[0],kt[1],kt[2])}Math.hypot||(Math.hypot=function(){for(var kt=0,_e=arguments.length;_e--;)kt+=arguments[_e]*arguments[_e];return Math.sqrt(kt)}),m=new w(3),w!=Float32Array&&(m[0]=0,m[1]=0,m[2]=0);class E{static createBufferFromDataURI(_e){if(typeof Buffer>"u"){const Dt=atob(_e.split(",")[1]),Vt=new Uint8Array(Dt.length);for(let Gt=0;Gt<Dt.length;Gt++)Vt[Gt]=Dt.charCodeAt(Gt);return Vt}{const Dt=_e.split(",")[1],Vt=_e.indexOf("base64")>=0;return Buffer.from(Dt,Vt?"base64":"utf8")}}static encodeText(_e){return typeof TextEncoder<"u"?new TextEncoder().encode(_e):Buffer.from(_e)}static decodeText(_e){return typeof TextDecoder<"u"?new TextDecoder().decode(_e):Buffer.from(_e).toString("utf8")}static concat(_e){let Dt=0;for(const zt of _e)Dt+=zt.byteLength;const Vt=new Uint8Array(Dt);let Gt=0;for(const zt of _e)Vt.set(zt,Gt),Gt+=zt.byteLength;return Vt}static pad(_e,Dt=0){const Vt=this.padNumber(_e.byteLength);if(Vt===_e.byteLength)return _e;const Gt=new Uint8Array(Vt);if(Gt.set(_e),Dt!==0)for(let zt=_e.byteLength;zt<Vt;zt++)Gt[zt]=Dt;return Gt}static padNumber(_e){return 4*Math.ceil(_e/4)}static equals(_e,Dt){if(_e===Dt)return!0;if(_e.byteLength!==Dt.byteLength)return!1;let Vt=_e.byteLength;for(;Vt--;)if(_e[Vt]!==Dt[Vt])return!1;return!0}static toView(_e,Dt=0,Vt=1/0){return new Uint8Array(_e.buffer,_e.byteOffset+Dt,Math.min(_e.byteLength,Vt))}static assertView(_e){if(_e&&!ArrayBuffer.isView(_e))throw new Error(`Method requires Uint8Array parameter; received "${typeof _e}".`);return _e}}class S{static hexToFactor(_e,Dt){_e=Math.floor(_e);const Vt=Dt;return Vt[0]=(_e>>16&255)/255,Vt[1]=(_e>>8&255)/255,Vt[2]=(255&_e)/255,this.convertSRGBToLinear(Dt,Dt)}static factorToHex(_e){const Dt=[..._e],[Vt,Gt,zt]=this.convertLinearToSRGB(_e,Dt);return 255*Vt<<16^255*Gt<<8^255*zt<<0}static convertSRGBToLinear(_e,Dt){const Vt=_e,Gt=Dt;for(let zt=0;zt<3;zt++)Gt[zt]=Vt[zt]<.04045?.0773993808*Vt[zt]:Math.pow(.9478672986*Vt[zt]+.0521327014,2.4);return Dt}static convertLinearToSRGB(_e,Dt){const Vt=_e,Gt=Dt;for(let zt=0;zt<3;zt++)Gt[zt]=Vt[zt]<.0031308?12.92*Vt[zt]:1.055*Math.pow(Vt[zt],.41666)-.055;return Dt}}class M{match(_e){return _e.length>=8&&_e[0]===137&&_e[1]===80&&_e[2]===78&&_e[3]===71&&_e[4]===13&&_e[5]===10&&_e[6]===26&&_e[7]===10}getSize(_e){const Dt=new DataView(_e.buffer,_e.byteOffset);return E.decodeText(_e.slice(12,16))===M.PNG_FRIED_CHUNK_NAME?[Dt.getUint32(32,!1),Dt.getUint32(36,!1)]:[Dt.getUint32(16,!1),Dt.getUint32(20,!1)]}getChannels(_e){return 4}}M.PNG_FRIED_CHUNK_NAME="CgBI";class I{static registerFormat(_e,Dt){this.impls[_e]=Dt}static getMimeType(_e){for(const Dt in this.impls)if(this.impls[Dt].match(_e))return Dt;return null}static getSize(_e,Dt){return this.impls[Dt]?this.impls[Dt].getSize(_e):null}static getChannels(_e,Dt){return this.impls[Dt]?this.impls[Dt].getChannels(_e):null}static getVRAMByteLength(_e,Dt){if(!this.impls[Dt])return null;if(this.impls[Dt].getVRAMByteLength)return this.impls[Dt].getVRAMByteLength(_e);let Vt=0;const Gt=this.getSize(_e,Dt);if(!Gt)return null;for(;Gt[0]>1||Gt[1]>1;)Vt+=Gt[0]*Gt[1]*4,Gt[0]=Math.max(Math.floor(Gt[0]/2),1),Gt[1]=Math.max(Math.floor(Gt[1]/2),1);return Vt+=4,Vt}static mimeTypeToExtension(_e){return _e==="image/jpeg"?"jpg":_e.split("/").pop()}static extensionToMimeType(_e){return _e==="jpg"?"image/jpeg":_e?`image/${_e}`:""}}function R(kt,_e){if(_e>kt.byteLength)throw new TypeError("Corrupt JPG, exceeded buffer limits");if(kt.getUint8(_e)!==255)throw new TypeError("Invalid JPG, marker table corrupted");return kt}I.impls={"image/jpeg":new class{match(kt){return kt.length>=3&&kt[0]===255&&kt[1]===216&&kt[2]===255}getSize(kt){let _e,Dt,Vt=new DataView(kt.buffer,kt.byteOffset+4);for(;Vt.byteLength;){if(_e=Vt.getUint16(0,!1),R(Vt,_e),Dt=Vt.getUint8(_e+1),Dt===192||Dt===193||Dt===194)return[Vt.getUint16(_e+7,!1),Vt.getUint16(_e+5,!1)];Vt=new DataView(kt.buffer,Vt.byteOffset+_e+2)}throw new TypeError("Invalid JPG, no size found")}getChannels(kt){return 3}},"image/png":new M};class N{static basename(_e){const Dt=_e.split(/[\\/]/).pop();return Dt.substring(0,Dt.lastIndexOf("."))}static extension(_e){if(_e.startsWith("data:image/")){const Dt=_e.match(/data:(image\/\w+)/)[1];return I.mimeTypeToExtension(Dt)}return _e.startsWith("data:model/gltf+json")?"gltf":_e.startsWith("data:model/gltf-binary")?"glb":_e.startsWith("data:application/")?"bin":_e.split(/[\\/]/).pop().split(/[.]/).pop()}}function O(kt){return Object.prototype.toString.call(kt)==="[object Object]"}function C(kt){if(O(kt)===!1)return!1;const _e=kt.constructor;if(_e===void 0)return!0;const Dt=_e.prototype;return O(Dt)!==!1&&Object.prototype.hasOwnProperty.call(Dt,"isPrototypeOf")!==!1}var F,U;(function(kt){kt[kt.SILENT=4]="SILENT",kt[kt.ERROR=3]="ERROR",kt[kt.WARN=2]="WARN",kt[kt.INFO=1]="INFO",kt[kt.DEBUG=0]="DEBUG"})(U||(U={}));let B$1=class Ql{constructor(_e){this.verbosity=void 0,this.verbosity=_e}debug(_e){this.verbosity<=Ql.Verbosity.DEBUG&&console.debug(_e)}info(_e){this.verbosity<=Ql.Verbosity.INFO&&console.info(_e)}warn(_e){this.verbosity<=Ql.Verbosity.WARN&&console.warn(_e)}error(_e){this.verbosity<=Ql.Verbosity.ERROR&&console.error(_e)}};function P(kt,_e,Dt){var Vt=_e[0],Gt=_e[1],zt=_e[2],jt=_e[3],Ht=_e[4],Wt=_e[5],qt=_e[6],Xt=_e[7],Kt=_e[8],Yt=_e[9],Zt=_e[10],Jt=_e[11],nn=_e[12],rn=_e[13],Qt=_e[14],en=_e[15],tn=Dt[0],sn=Dt[1],cn=Dt[2],un=Dt[3];return kt[0]=tn*Vt+sn*Ht+cn*Kt+un*nn,kt[1]=tn*Gt+sn*Wt+cn*Yt+un*rn,kt[2]=tn*zt+sn*qt+cn*Zt+un*Qt,kt[3]=tn*jt+sn*Xt+cn*Jt+un*en,kt[4]=(tn=Dt[4])*Vt+(sn=Dt[5])*Ht+(cn=Dt[6])*Kt+(un=Dt[7])*nn,kt[5]=tn*Gt+sn*Wt+cn*Yt+un*rn,kt[6]=tn*zt+sn*qt+cn*Zt+un*Qt,kt[7]=tn*jt+sn*Xt+cn*Jt+un*en,kt[8]=(tn=Dt[8])*Vt+(sn=Dt[9])*Ht+(cn=Dt[10])*Kt+(un=Dt[11])*nn,kt[9]=tn*Gt+sn*Wt+cn*Yt+un*rn,kt[10]=tn*zt+sn*qt+cn*Zt+un*Qt,kt[11]=tn*jt+sn*Xt+cn*Jt+un*en,kt[12]=(tn=Dt[12])*Vt+(sn=Dt[13])*Ht+(cn=Dt[14])*Kt+(un=Dt[15])*nn,kt[13]=tn*Gt+sn*Wt+cn*Yt+un*rn,kt[14]=tn*zt+sn*qt+cn*Zt+un*Qt,kt[15]=tn*jt+sn*Xt+cn*Jt+un*en,kt}F=B$1,B$1.Verbosity=U,B$1.DEFAULT_INSTANCE=new F(F.Verbosity.INFO);class L{static identity(_e){return _e}static eq(_e,Dt,Vt=1e-5){if(_e.length!==Dt.length)return!1;for(let Gt=0;Gt<_e.length;Gt++)if(Math.abs(_e[Gt]-Dt[Gt])>Vt)return!1;return!0}static decodeNormalizedInt(_e,Dt){switch(Dt){case 5126:return _e;case 5123:return _e/65535;case 5121:return _e/255;case 5122:return Math.max(_e/32767,-1);case 5120:return Math.max(_e/127,-1);default:throw new Error("Invalid component type.")}}static denormalize(_e,Dt){return L.decodeNormalizedInt(_e,Dt)}static encodeNormalizedInt(_e,Dt){switch(Dt){case 5126:return _e;case 5123:return Math.round(65535*_e);case 5121:return Math.round(255*_e);case 5122:return Math.round(32767*_e);case 5120:return Math.round(127*_e);default:throw new Error("Invalid component type.")}}static normalize(_e,Dt){return L.encodeNormalizedInt(_e,Dt)}static decompose(_e,Dt,Vt,Gt){let zt=y([_e[0],_e[1],_e[2]]);const jt=y([_e[4],_e[5],_e[6]]),Ht=y([_e[8],_e[9],_e[10]]);var Wt,qt,Xt,Kt,Yt,Zt,Jt,nn,rn,Qt,en,tn,sn,cn,un,hn,fn;((qt=(Wt=_e)[0])*(Jt=Wt[5])-(Xt=Wt[1])*(Zt=Wt[4]))*((tn=Wt[10])*(fn=Wt[15])-(sn=Wt[11])*(hn=Wt[14]))-(qt*(nn=Wt[6])-(Kt=Wt[2])*Zt)*((en=Wt[9])*fn-sn*(un=Wt[13]))+(qt*(rn=Wt[7])-(Yt=Wt[3])*Zt)*(en*hn-tn*un)+(Xt*nn-Kt*Jt)*((Qt=Wt[8])*fn-sn*(cn=Wt[12]))-(Xt*rn-Yt*Jt)*(Qt*hn-tn*cn)+(Kt*rn-Yt*nn)*(Qt*un-en*cn)<0&&(zt=-zt),Dt[0]=_e[12],Dt[1]=_e[13],Dt[2]=_e[14];const pn=_e.slice(),dn=1/zt,mn=1/jt,vn=1/Ht;pn[0]*=dn,pn[1]*=dn,pn[2]*=dn,pn[4]*=mn,pn[5]*=mn,pn[6]*=mn,pn[8]*=vn,pn[9]*=vn,pn[10]*=vn,function(_n,En){var An=new w(3);(function(ar,zn){var ur=zn[4],Hn=zn[5],sr=zn[6],gr=zn[8],fr=zn[9],Un=zn[10];ar[0]=Math.hypot(zn[0],zn[1],zn[2]),ar[1]=Math.hypot(ur,Hn,sr),ar[2]=Math.hypot(gr,fr,Un)})(An,En);var Tn=1/An[0],Cn=1/An[1],yn=1/An[2],Sn=En[0]*Tn,wn=En[1]*Cn,xn=En[2]*yn,Rn=En[4]*Tn,Dn=En[5]*Cn,kn=En[6]*yn,Fn=En[8]*Tn,Pn=En[9]*Cn,Bn=En[10]*yn,qn=Sn+Dn+Bn,tr=0;qn>0?(tr=2*Math.sqrt(qn+1),_n[3]=.25*tr,_n[0]=(kn-Pn)/tr,_n[1]=(Fn-xn)/tr,_n[2]=(wn-Rn)/tr):Sn>Dn&&Sn>Bn?(tr=2*Math.sqrt(1+Sn-Dn-Bn),_n[3]=(kn-Pn)/tr,_n[0]=.25*tr,_n[1]=(wn+Rn)/tr,_n[2]=(Fn+xn)/tr):Dn>Bn?(tr=2*Math.sqrt(1+Dn-Sn-Bn),_n[3]=(Fn-xn)/tr,_n[0]=(wn+Rn)/tr,_n[1]=.25*tr,_n[2]=(kn+Pn)/tr):(tr=2*Math.sqrt(1+Bn-Sn-Dn),_n[3]=(wn-Rn)/tr,_n[0]=(Fn+xn)/tr,_n[1]=(kn+Pn)/tr,_n[2]=.25*tr)}(Vt,pn),Gt[0]=zt,Gt[1]=jt,Gt[2]=Ht}static compose(_e,Dt,Vt,Gt){const zt=Gt,jt=Dt[0],Ht=Dt[1],Wt=Dt[2],qt=Dt[3],Xt=jt+jt,Kt=Ht+Ht,Yt=Wt+Wt,Zt=jt*Xt,Jt=jt*Kt,nn=jt*Yt,rn=Ht*Kt,Qt=Ht*Yt,en=Wt*Yt,tn=qt*Xt,sn=qt*Kt,cn=qt*Yt,un=Vt[0],hn=Vt[1],fn=Vt[2];return zt[0]=(1-(rn+en))*un,zt[1]=(Jt+cn)*un,zt[2]=(nn-sn)*un,zt[3]=0,zt[4]=(Jt-cn)*hn,zt[5]=(1-(Zt+en))*hn,zt[6]=(Qt+tn)*hn,zt[7]=0,zt[8]=(nn+sn)*fn,zt[9]=(Qt-tn)*fn,zt[10]=(1-(Zt+rn))*fn,zt[11]=0,zt[12]=_e[0],zt[13]=_e[1],zt[14]=_e[2],zt[15]=1,zt}}function j(kt,_e){if(!!kt!=!!_e)return!1;const Dt=kt.getChild(),Vt=_e.getChild();return Dt===Vt||Dt.equals(Vt)}function D(kt,_e){if(!!kt!=!!_e||kt.length!==_e.length)return!1;for(let Dt=0;Dt<kt.length;Dt++){const Vt=kt[Dt],Gt=_e[Dt];if(Vt.getChild()!==Gt.getChild()&&!Vt.getChild().equals(Gt.getChild()))return!1}return!0}function _(kt,_e){if(!!kt!=!!_e)return!1;const Dt=Object.keys(kt),Vt=Object.keys(_e);if(Dt.length!==Vt.length)return!1;for(const Gt in kt){const zt=kt[Gt],jt=_e[Gt];if(!!zt!=!!jt)return!1;const Ht=zt.getChild(),Wt=jt.getChild();if(Ht!==Wt&&!Ht.equals(Wt))return!1}return!0}function k(kt,_e){if(kt===_e)return!0;if(!!kt!=!!_e||!kt||!_e||kt.length!==_e.length)return!1;for(let Dt=0;Dt<kt.length;Dt++)if(kt[Dt]!==_e[Dt])return!1;return!0}function z(kt,_e){if(kt===_e)return!0;if(!!kt!=!!_e)return!1;if(!C(kt)||!C(_e))return kt===_e;const Dt=kt,Vt=_e;let Gt,zt=0,jt=0;for(Gt in Dt)zt++;for(Gt in Vt)jt++;if(zt!==jt)return!1;for(Gt in Dt){const Ht=Dt[Gt],Wt=Vt[Gt];if(G(Ht)&&G(Wt)){if(!k(Ht,Wt))return!1}else if(C(Ht)&&C(Wt)){if(!z(Ht,Wt))return!1}else if(Ht!==Wt)return!1}return!0}function G(kt){return Array.isArray(kt)||ArrayBuffer.isView(kt)}const J=new Set,$=function(){let kt="";for(let _e=0;_e<6;_e++)kt+="23456789abdegjkmnpqrvwxyzABDEGJKMNPQRVWXYZ".charAt(Math.floor(42*Math.random()));return kt},V=function(){for(let kt=0;kt<999;kt++){const _e=$();if(!J.has(_e))return J.add(_e),_e}return""},W="https://null.example";let q$1=class{static dirname(_e){const Dt=_e.lastIndexOf("/");return Dt===-1?"./":_e.substring(0,Dt+1)}static basename(_e){return N.basename(new URL(_e,W).pathname)}static extension(_e){return N.extension(new URL(_e,W).pathname)}static resolve(_e,Dt){if(!this.isRelativePath(Dt))return Dt;const Vt=_e.split("/"),Gt=Dt.split("/");Vt.pop();for(let zt=0;zt<Gt.length;zt++)Gt[zt]!=="."&&(Gt[zt]===".."?Vt.pop():Vt.push(Gt[zt]));return Vt.join("/")}static isAbsoluteURL(_e){return this.PROTOCOL_REGEXP.test(_e)}static isRelativePath(_e){return!/^(?:[a-zA-Z]+:)?\//.test(_e)}};q$1.DEFAULT_INIT={},q$1.PROTOCOL_REGEXP=/^[a-zA-Z]+:\/\//;const H=kt=>kt,Y=new Set;let Z$1=class extends GraphNode{constructor(_e,Dt=""){super(_e),this[$attributes].name=Dt,this.init(),this.dispatchEvent({type:"create"})}getGraph(){return this.graph}getDefaults(){return Object.assign(super.getDefaults(),{name:"",extras:{}})}set(_e,Dt){return Array.isArray(Dt)&&(Dt=Dt.slice()),super.set(_e,Dt)}getName(){return this.get("name")}setName(_e){return this.set("name",_e)}getExtras(){return this.get("extras")}setExtras(_e){return this.set("extras",_e)}clone(){return new this.constructor(this.graph).copy(this,H)}copy(_e,Dt=H){for(const Vt in this[$attributes]){const Gt=this[$attributes][Vt];if(Gt instanceof GraphEdge)this[$immutableKeys].has(Vt)||Gt.dispose();else if(isRefList(Gt))for(const zt of Gt)zt.dispose();else if(isRefMap(Gt))for(const zt in Gt)Gt[zt].dispose()}for(const Vt in _e[$attributes]){const Gt=this[$attributes][Vt],zt=_e[$attributes][Vt];if(zt instanceof GraphEdge)this[$immutableKeys].has(Vt)?Gt.getChild().copy(Dt(zt.getChild()),Dt):this.setRef(Vt,Dt(zt.getChild()),zt.getAttributes());else if(isRefList(zt))for(const jt of zt)this.addRef(Vt,Dt(jt.getChild()),jt.getAttributes());else if(isRefMap(zt))for(const jt in zt){const Ht=zt[jt];this.setRefMap(Vt,jt,Dt(Ht.getChild()),Ht.getAttributes())}else this[$attributes][Vt]=C(zt)?JSON.parse(JSON.stringify(zt)):Array.isArray(zt)||zt instanceof ArrayBuffer||ArrayBuffer.isView(zt)?zt.slice():zt}return this}equals(_e,Dt=Y){if(this===_e)return!0;if(this.propertyType!==_e.propertyType)return!1;for(const Vt in this[$attributes]){if(Dt.has(Vt))continue;const Gt=this[$attributes][Vt],zt=_e[$attributes][Vt];if(isRef(Gt)||isRef(zt)){if(!j(Gt,zt))return!1}else if(isRefList(Gt)||isRefList(zt)){if(!D(Gt,zt))return!1}else if(isRefMap(Gt)||isRefMap(zt)){if(!_(Gt,zt))return!1}else if(C(Gt)||C(zt)){if(!z(Gt,zt))return!1}else if(G(Gt)||G(zt)){if(!k(Gt,zt))return!1}else if(Gt!==zt)return!1}return!0}detach(){return this.graph.disconnectParents(this,_e=>_e.propertyType!=="Root"),this}listParents(){return this.graph.listParents(this)}};class K extends Z$1{getDefaults(){return Object.assign(super.getDefaults(),{extensions:{}})}getExtension(_e){return this.getRefMap("extensions",_e)}setExtension(_e,Dt){return Dt&&Dt.t(this),this.setRefMap("extensions",_e,Dt)}listExtensions(){return this.listRefMapValues("extensions")}}class Q extends K{constructor(..._e){super(..._e),this.i=L.identity,this.o=L.identity}init(){this.propertyType=h.ACCESSOR}getDefaults(){return Object.assign(super.getDefaults(),{array:null,type:Q.Type.SCALAR,componentType:Q.ComponentType.FLOAT,normalized:!1,sparse:!1,buffer:null})}copy(_e,Dt=H){return super.copy(_e,Dt),this.i=_e.i,this.o=_e.o,this}static getElementSize(_e){switch(_e){case Q.Type.SCALAR:return 1;case Q.Type.VEC2:return 2;case Q.Type.VEC3:return 3;case Q.Type.VEC4:case Q.Type.MAT2:return 4;case Q.Type.MAT3:return 9;case Q.Type.MAT4:return 16;default:throw new Error("Unexpected type: "+_e)}}static getComponentSize(_e){switch(_e){case Q.ComponentType.BYTE:case Q.ComponentType.UNSIGNED_BYTE:return 1;case Q.ComponentType.SHORT:case Q.ComponentType.UNSIGNED_SHORT:return 2;case Q.ComponentType.UNSIGNED_INT:case Q.ComponentType.FLOAT:return 4;default:throw new Error("Unexpected component type: "+_e)}}getMinNormalized(_e){const Dt=this.getElementSize();this.getMin(_e);for(let Vt=0;Vt<Dt;Vt++)_e[Vt]=this.o(_e[Vt]);return _e}getMin(_e){const Dt=this.get("array"),Vt=this.getCount(),Gt=this.getElementSize();for(let zt=0;zt<Gt;zt++)_e[zt]=1/0;for(let zt=0;zt<Vt*Gt;zt+=Gt)for(let jt=0;jt<Gt;jt++){const Ht=Dt[zt+jt];Number.isFinite(Ht)&&(_e[jt]=Math.min(_e[jt],Ht))}return _e}getMaxNormalized(_e){const Dt=this.getElementSize();this.getMax(_e);for(let Vt=0;Vt<Dt;Vt++)_e[Vt]=this.o(_e[Vt]);return _e}getMax(_e){const Dt=this.get("array"),Vt=this.getCount(),Gt=this.getElementSize();for(let zt=0;zt<Gt;zt++)_e[zt]=-1/0;for(let zt=0;zt<Vt*Gt;zt+=Gt)for(let jt=0;jt<Gt;jt++){const Ht=Dt[zt+jt];Number.isFinite(Ht)&&(_e[jt]=Math.max(_e[jt],Ht))}return _e}getCount(){const _e=this.get("array");return _e?_e.length/this.getElementSize():0}getType(){return this.get("type")}setType(_e){return this.set("type",_e)}getElementSize(){return Q.getElementSize(this.get("type"))}getComponentSize(){return this.get("array").BYTES_PER_ELEMENT}getComponentType(){return this.get("componentType")}getNormalized(){return this.get("normalized")}setNormalized(_e){return this.set("normalized",_e),_e?(this.o=Dt=>L.decodeNormalizedInt(Dt,this.get("componentType")),this.i=Dt=>L.encodeNormalizedInt(Dt,this.get("componentType"))):(this.o=L.identity,this.i=L.identity),this}getScalar(_e){const Dt=this.getElementSize();return this.o(this.get("array")[_e*Dt])}setScalar(_e,Dt){return this.get("array")[_e*this.getElementSize()]=this.i(Dt),this}getElement(_e,Dt){const Vt=this.getElementSize(),Gt=this.get("array");for(let zt=0;zt<Vt;zt++)Dt[zt]=this.o(Gt[_e*Vt+zt]);return Dt}setElement(_e,Dt){const Vt=this.getElementSize(),Gt=this.get("array");for(let zt=0;zt<Vt;zt++)Gt[_e*Vt+zt]=this.i(Dt[zt]);return this}getSparse(){return this.get("sparse")}setSparse(_e){return this.set("sparse",_e)}getBuffer(){return this.getRef("buffer")}setBuffer(_e){return this.setRef("buffer",_e)}getArray(){return this.get("array")}setArray(_e){return this.set("componentType",_e?function(Dt){switch(Dt.constructor){case Float32Array:return Q.ComponentType.FLOAT;case Uint32Array:return Q.ComponentType.UNSIGNED_INT;case Uint16Array:return Q.ComponentType.UNSIGNED_SHORT;case Uint8Array:return Q.ComponentType.UNSIGNED_BYTE;case Int16Array:return Q.ComponentType.SHORT;case Int8Array:return Q.ComponentType.BYTE;default:throw new Error("Unknown accessor componentType.")}}(_e):Q.ComponentType.FLOAT),this.set("array",_e),this}getByteLength(){const _e=this.get("array");return _e?_e.byteLength:0}}Q.Type={SCALAR:"SCALAR",VEC2:"VEC2",VEC3:"VEC3",VEC4:"VEC4",MAT2:"MAT2",MAT3:"MAT3",MAT4:"MAT4"},Q.ComponentType={BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,UNSIGNED_INT:5125,FLOAT:5126};class X extends K{init(){this.propertyType=h.ANIMATION}getDefaults(){return Object.assign(super.getDefaults(),{channels:[],samplers:[]})}addChannel(_e){return this.addRef("channels",_e)}removeChannel(_e){return this.removeRef("channels",_e)}listChannels(){return this.listRefs("channels")}addSampler(_e){return this.addRef("samplers",_e)}removeSampler(_e){return this.removeRef("samplers",_e)}listSamplers(){return this.listRefs("samplers")}}class tt extends K{init(){this.propertyType=h.ANIMATION_CHANNEL}getDefaults(){return Object.assign(super.getDefaults(),{targetPath:null,targetNode:null,sampler:null})}getTargetPath(){return this.get("targetPath")}setTargetPath(_e){return this.set("targetPath",_e)}getTargetNode(){return this.getRef("targetNode")}setTargetNode(_e){return this.setRef("targetNode",_e)}getSampler(){return this.getRef("sampler")}setSampler(_e){return this.setRef("sampler",_e)}}tt.TargetPath={TRANSLATION:"translation",ROTATION:"rotation",SCALE:"scale",WEIGHTS:"weights"};class et extends K{init(){this.propertyType=h.ANIMATION_SAMPLER}getDefaultAttributes(){return Object.assign(super.getDefaults(),{interpolation:et.Interpolation.LINEAR,input:null,output:null})}getInterpolation(){return this.get("interpolation")}setInterpolation(_e){return this.set("interpolation",_e)}getInput(){return this.getRef("input")}setInput(_e){return this.setRef("input",_e,{usage:l.OTHER})}getOutput(){return this.getRef("output")}setOutput(_e){return this.setRef("output",_e,{usage:l.OTHER})}}et.Interpolation={LINEAR:"LINEAR",STEP:"STEP",CUBICSPLINE:"CUBICSPLINE"};class rt extends K{init(){this.propertyType=h.BUFFER}getDefaults(){return Object.assign(super.getDefaults(),{uri:""})}getURI(){return this.get("uri")}setURI(_e){return this.set("uri",_e)}}class st extends K{init(){this.propertyType=h.CAMERA}getDefaults(){return Object.assign(super.getDefaults(),{type:st.Type.PERSPECTIVE,znear:.1,zfar:100,aspectRatio:null,yfov:2*Math.PI*50/360,xmag:1,ymag:1})}getType(){return this.get("type")}setType(_e){return this.set("type",_e)}getZNear(){return this.get("znear")}setZNear(_e){return this.set("znear",_e)}getZFar(){return this.get("zfar")}setZFar(_e){return this.set("zfar",_e)}getAspectRatio(){return this.get("aspectRatio")}setAspectRatio(_e){return this.set("aspectRatio",_e)}getYFov(){return this.get("yfov")}setYFov(_e){return this.set("yfov",_e)}getXMag(){return this.get("xmag")}setXMag(_e){return this.set("xmag",_e)}getYMag(){return this.get("ymag")}setYMag(_e){return this.set("ymag",_e)}}st.Type={PERSPECTIVE:"perspective",ORTHOGRAPHIC:"orthographic"};class nt extends Z$1{t(_e){if(!this.parentTypes.includes(_e.propertyType))throw new Error(`Parent "${_e.propertyType}" invalid for child "${this.propertyType}".`)}}nt.EXTENSION_NAME=void 0;class it extends K{init(){this.propertyType=h.TEXTURE_INFO}getDefaults(){return Object.assign(super.getDefaults(),{texCoord:0,magFilter:null,minFilter:null,wrapS:it.WrapMode.REPEAT,wrapT:it.WrapMode.REPEAT})}getTexCoord(){return this.get("texCoord")}setTexCoord(_e){return this.set("texCoord",_e)}getMagFilter(){return this.get("magFilter")}setMagFilter(_e){return this.set("magFilter",_e)}getMinFilter(){return this.get("minFilter")}setMinFilter(_e){return this.set("minFilter",_e)}getWrapS(){return this.get("wrapS")}setWrapS(_e){return this.set("wrapS",_e)}getWrapT(){return this.get("wrapT")}setWrapT(_e){return this.set("wrapT",_e)}}it.WrapMode={CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,REPEAT:10497},it.MagFilter={NEAREST:9728,LINEAR:9729},it.MinFilter={NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987};const{R:ot,G:at,B:ut,A:ct}=d;class ht extends K{init(){this.propertyType=h.MATERIAL}getDefaults(){return Object.assign(super.getDefaults(),{alphaMode:ht.AlphaMode.OPAQUE,alphaCutoff:.5,doubleSided:!1,baseColorFactor:[1,1,1,1],baseColorTexture:null,baseColorTextureInfo:new it(this.graph,"baseColorTextureInfo"),emissiveFactor:[0,0,0],emissiveTexture:null,emissiveTextureInfo:new it(this.graph,"emissiveTextureInfo"),normalScale:1,normalTexture:null,normalTextureInfo:new it(this.graph,"normalTextureInfo"),occlusionStrength:1,occlusionTexture:null,occlusionTextureInfo:new it(this.graph,"occlusionTextureInfo"),roughnessFactor:1,metallicFactor:1,metallicRoughnessTexture:null,metallicRoughnessTextureInfo:new it(this.graph,"metallicRoughnessTextureInfo")})}getDoubleSided(){return this.get("doubleSided")}setDoubleSided(_e){return this.set("doubleSided",_e)}getAlpha(){return this.get("baseColorFactor")[3]}setAlpha(_e){const Dt=this.get("baseColorFactor").slice();return Dt[3]=_e,this.set("baseColorFactor",Dt)}getAlphaMode(){return this.get("alphaMode")}setAlphaMode(_e){return this.set("alphaMode",_e)}getAlphaCutoff(){return this.get("alphaCutoff")}setAlphaCutoff(_e){return this.set("alphaCutoff",_e)}getBaseColorFactor(){return this.get("baseColorFactor")}setBaseColorFactor(_e){return this.set("baseColorFactor",_e)}getBaseColorHex(){return S.factorToHex(this.get("baseColorFactor"))}setBaseColorHex(_e){const Dt=this.get("baseColorFactor").slice();return this.set("baseColorFactor",S.hexToFactor(_e,Dt))}getBaseColorTexture(){return this.getRef("baseColorTexture")}getBaseColorTextureInfo(){return this.getRef("baseColorTexture")?this.getRef("baseColorTextureInfo"):null}setBaseColorTexture(_e){return this.setRef("baseColorTexture",_e,{channels:ot|at|ut|ct,isColor:!0})}getEmissiveFactor(){return this.get("emissiveFactor")}setEmissiveFactor(_e){return this.set("emissiveFactor",_e)}getEmissiveHex(){return S.factorToHex(this.get("emissiveFactor"))}setEmissiveHex(_e){const Dt=this.get("emissiveFactor").slice();return this.set("emissiveFactor",S.hexToFactor(_e,Dt))}getEmissiveTexture(){return this.getRef("emissiveTexture")}getEmissiveTextureInfo(){return this.getRef("emissiveTexture")?this.getRef("emissiveTextureInfo"):null}setEmissiveTexture(_e){return this.setRef("emissiveTexture",_e,{channels:ot|at|ut,isColor:!0})}getNormalScale(){return this.get("normalScale")}setNormalScale(_e){return this.set("normalScale",_e)}getNormalTexture(){return this.getRef("normalTexture")}getNormalTextureInfo(){return this.getRef("normalTexture")?this.getRef("normalTextureInfo"):null}setNormalTexture(_e){return this.setRef("normalTexture",_e,{channels:ot|at|ut})}getOcclusionStrength(){return this.get("occlusionStrength")}setOcclusionStrength(_e){return this.set("occlusionStrength",_e)}getOcclusionTexture(){return this.getRef("occlusionTexture")}getOcclusionTextureInfo(){return this.getRef("occlusionTexture")?this.getRef("occlusionTextureInfo"):null}setOcclusionTexture(_e){return this.setRef("occlusionTexture",_e,{channels:ot})}getRoughnessFactor(){return this.get("roughnessFactor")}setRoughnessFactor(_e){return this.set("roughnessFactor",_e)}getMetallicFactor(){return this.get("metallicFactor")}setMetallicFactor(_e){return this.set("metallicFactor",_e)}getMetallicRoughnessTexture(){return this.getRef("metallicRoughnessTexture")}getMetallicRoughnessTextureInfo(){return this.getRef("metallicRoughnessTexture")?this.getRef("metallicRoughnessTextureInfo"):null}setMetallicRoughnessTexture(_e){return this.setRef("metallicRoughnessTexture",_e,{channels:at|ut})}}ht.AlphaMode={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};class ft extends K{init(){this.propertyType=h.MESH}getDefaults(){return Object.assign(super.getDefaults(),{weights:[],primitives:[]})}addPrimitive(_e){return this.addRef("primitives",_e)}removePrimitive(_e){return this.removeRef("primitives",_e)}listPrimitives(){return this.listRefs("primitives")}getWeights(){return this.get("weights")}setWeights(_e){return this.set("weights",_e)}}class lt extends K{constructor(..._e){super(..._e),this.u=null,this.h=new Set}init(){this.propertyType=h.NODE}getDefaults(){return Object.assign(super.getDefaults(),{translation:[0,0,0],rotation:[0,0,0,1],scale:[1,1,1],weights:[],camera:null,mesh:null,skin:null,children:[]})}copy(_e,Dt=H){if(Dt===H)throw new Error("Node cannot be copied.");return super.copy(_e,Dt)}getTranslation(){return this.get("translation")}getRotation(){return this.get("rotation")}getScale(){return this.get("scale")}setTranslation(_e){return this.set("translation",_e)}setRotation(_e){return this.set("rotation",_e)}setScale(_e){return this.set("scale",_e)}getMatrix(){return L.compose(this.get("translation"),this.get("rotation"),this.get("scale"),[])}setMatrix(_e){const Dt=this.get("translation").slice(),Vt=this.get("rotation").slice(),Gt=this.get("scale").slice();return L.decompose(_e,Dt,Vt,Gt),this.set("translation",Dt).set("rotation",Vt).set("scale",Gt)}getWorldTranslation(){const _e=[0,0,0];return L.decompose(this.getWorldMatrix(),_e,[0,0,0,1],[1,1,1]),_e}getWorldRotation(){const _e=[0,0,0,1];return L.decompose(this.getWorldMatrix(),[0,0,0],_e,[1,1,1]),_e}getWorldScale(){const _e=[1,1,1];return L.decompose(this.getWorldMatrix(),[0,0,0],[0,0,0,1],_e),_e}getWorldMatrix(){const _e=[];for(let Gt=this;Gt!=null;Gt=Gt.u)_e.push(Gt);let Dt;const Vt=_e.pop().getMatrix();for(;Dt=_e.pop();)P(Vt,Vt,Dt.getMatrix());return Vt}addChild(_e){if(_e.u&&_e.u.removeChild(_e),_e.h.size)for(const Vt of _e.h)Vt.removeChild(_e);this.addRef("children",_e),_e.u=this;const Dt=this[$attributes].children;return Dt[Dt.length-1].addEventListener("dispose",()=>_e.u=null),this}removeChild(_e){return this.removeRef("children",_e)}listChildren(){return this.listRefs("children")}getParent(){return this.u?this.u:this.listParents().find(_e=>_e.propertyType===h.SCENE)||null}getParentNode(){return this.u}getMesh(){return this.getRef("mesh")}setMesh(_e){return this.setRef("mesh",_e)}getCamera(){return this.getRef("camera")}setCamera(_e){return this.setRef("camera",_e)}getSkin(){return this.getRef("skin")}setSkin(_e){return this.setRef("skin",_e)}getWeights(){return this.get("weights")}setWeights(_e){return this.set("weights",_e)}traverse(_e){_e(this);for(const Dt of this.listChildren())Dt.traverse(_e);return this}}class dt extends K{init(){this.propertyType=h.PRIMITIVE}getDefaults(){return Object.assign(super.getDefaults(),{mode:dt.Mode.TRIANGLES,material:null,indices:null,attributes:{},targets:[]})}getIndices(){return this.getRef("indices")}setIndices(_e){return this.setRef("indices",_e,{usage:l.ELEMENT_ARRAY_BUFFER})}getAttribute(_e){return this.getRefMap("attributes",_e)}setAttribute(_e,Dt){return this.setRefMap("attributes",_e,Dt,{usage:l.ARRAY_BUFFER})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}getMaterial(){return this.getRef("material")}setMaterial(_e){return this.setRef("material",_e)}getMode(){return this.get("mode")}setMode(_e){return this.set("mode",_e)}listTargets(){return this.listRefs("targets")}addTarget(_e){return this.addRef("targets",_e)}removeTarget(_e){return this.removeRef("targets",_e)}}dt.Mode={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6};class gt extends Z$1{init(){this.propertyType=h.PRIMITIVE_TARGET}getDefaults(){return Object.assign(super.getDefaults(),{attributes:{}})}getAttribute(_e){return this.getRefMap("attributes",_e)}setAttribute(_e,Dt){return this.setRefMap("attributes",_e,Dt,{usage:l.ARRAY_BUFFER})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}}function pt(){return pt=Object.assign?Object.assign.bind():function(kt){for(var _e=1;_e<arguments.length;_e++){var Dt=arguments[_e];for(var Vt in Dt)Object.prototype.hasOwnProperty.call(Dt,Vt)&&(kt[Vt]=Dt[Vt])}return kt},pt.apply(this,arguments)}class mt extends K{init(){this.propertyType=h.SCENE}getDefaults(){return Object.assign(super.getDefaults(),{children:[]})}copy(_e,Dt=H){if(Dt===H)throw new Error("Scene cannot be copied.");return super.copy(_e,Dt)}addChild(_e){_e.u&&_e.u.removeChild(_e),this.addRef("children",_e),_e.h.add(this);const Dt=this[$attributes].children;return Dt[Dt.length-1].addEventListener("dispose",()=>_e.h.delete(this)),this}removeChild(_e){return this.removeRef("children",_e)}listChildren(){return this.listRefs("children")}traverse(_e){for(const Dt of this.listChildren())Dt.traverse(_e);return this}}class wt extends K{init(){this.propertyType=h.SKIN}getDefaults(){return Object.assign(super.getDefaults(),{skeleton:null,inverseBindMatrices:null,joints:[]})}getSkeleton(){return this.getRef("skeleton")}setSkeleton(_e){return this.setRef("skeleton",_e)}getInverseBindMatrices(){return this.getRef("inverseBindMatrices")}setInverseBindMatrices(_e){return this.setRef("inverseBindMatrices",_e,{usage:l.INVERSE_BIND_MATRICES})}addJoint(_e){return this.addRef("joints",_e)}removeJoint(_e){return this.removeRef("joints",_e)}listJoints(){return this.listRefs("joints")}}class yt extends K{init(){this.propertyType=h.TEXTURE}getDefaults(){return Object.assign(super.getDefaults(),{image:null,mimeType:"",uri:""})}getMimeType(){return this.get("mimeType")||I.extensionToMimeType(N.extension(this.get("uri")))}setMimeType(_e){return this.set("mimeType",_e)}getURI(){return this.get("uri")}setURI(_e){this.set("uri",_e);const Dt=I.extensionToMimeType(N.extension(_e));return Dt&&this.set("mimeType",Dt),this}getImage(){return this.get("image")}setImage(_e){return this.set("image",E.assertView(_e))}getSize(){const _e=this.get("image");return _e?I.getSize(_e,this.getMimeType()):null}}class vt extends K{init(){this.propertyType=h.ROOT}getDefaults(){return Object.assign(super.getDefaults(),{asset:{generator:`glTF-Transform ${u}`,version:"2.0"},defaultScene:null,accessors:[],animations:[],buffers:[],cameras:[],materials:[],meshes:[],nodes:[],scenes:[],skins:[],textures:[]})}constructor(_e){super(_e),this.l=new Set,_e.addEventListener("node:create",Dt=>{this.g(Dt.target)})}clone(){throw new Error("Root cannot be cloned.")}copy(_e,Dt=H){if(Dt===H)throw new Error("Root cannot be copied.");this.set("asset",pt({},_e.get("asset"))),this.setName(_e.getName()),this.setExtras(pt({},_e.getExtras())),this.setDefaultScene(_e.getDefaultScene()?Dt(_e.getDefaultScene()):null);for(const Vt of _e.listRefMapKeys("extensions")){const Gt=_e.getExtension(Vt);this.setExtension(Vt,Dt(Gt))}return this}g(_e){return _e instanceof mt?this.addRef("scenes",_e):_e instanceof lt?this.addRef("nodes",_e):_e instanceof st?this.addRef("cameras",_e):_e instanceof wt?this.addRef("skins",_e):_e instanceof ft?this.addRef("meshes",_e):_e instanceof ht?this.addRef("materials",_e):_e instanceof yt?this.addRef("textures",_e):_e instanceof X?this.addRef("animations",_e):_e instanceof Q?this.addRef("accessors",_e):_e instanceof rt&&this.addRef("buffers",_e),this}getAsset(){return this.get("asset")}listExtensionsUsed(){return Array.from(this.l)}listExtensionsRequired(){return this.listExtensionsUsed().filter(_e=>_e.isRequired())}p(_e){return this.l.add(_e),this}m(_e){return this.l.delete(_e),this}listScenes(){return this.listRefs("scenes")}setDefaultScene(_e){return this.setRef("defaultScene",_e)}getDefaultScene(){return this.getRef("defaultScene")}listNodes(){return this.listRefs("nodes")}listCameras(){return this.listRefs("cameras")}listSkins(){return this.listRefs("skins")}listMeshes(){return this.listRefs("meshes")}listMaterials(){return this.listRefs("materials")}listTextures(){return this.listRefs("textures")}listAnimations(){return this.listRefs("animations")}listAccessors(){return this.listRefs("accessors")}listBuffers(){return this.listRefs("buffers")}}class Tt{static fromGraph(_e){return Tt.v.get(_e)||null}constructor(){this.T=new Graph,this.S=new vt(this.T),this.M=B$1.DEFAULT_INSTANCE,Tt.v.set(this.T,this)}getRoot(){return this.S}getGraph(){return this.T}getLogger(){return this.M}setLogger(_e){return this.M=_e,this}clone(){return new Tt().setLogger(this.M).merge(this)}merge(_e){for(const zt of _e.getRoot().listExtensionsUsed()){const jt=this.createExtension(zt.constructor);zt.isRequired()&&jt.setRequired(!0)}const Dt=new Set,Vt=new Map;Dt.add(_e.S),Vt.set(_e.S,this.S);for(const zt of _e.T.listEdges())for(const jt of[zt.getParent(),zt.getChild()]){if(Dt.has(jt))continue;let Ht;Ht=jt.propertyType===h.TEXTURE_INFO?jt:new jt.constructor(this.T),Vt.set(jt,Ht),Dt.add(jt)}const Gt=zt=>{const jt=Vt.get(zt);if(!jt)throw new Error("Could resolve property.");return jt};for(const zt of Dt){const jt=Vt.get(zt);if(!jt)throw new Error("Could resolve property.");jt.propertyType!==h.TEXTURE_INFO&&jt.copy(zt,Gt)}return this}async transform(..._e){const Dt=_e.map(Vt=>Vt.name);for(const Vt of _e)await Vt(this,{stack:Dt});return this}createExtension(_e){const Dt=_e.EXTENSION_NAME;return this.getRoot().listExtensionsUsed().find(Vt=>Vt.extensionName===Dt)||new _e(this)}createScene(_e=""){return new mt(this.T,_e)}createNode(_e=""){return new lt(this.T,_e)}createCamera(_e=""){return new st(this.T,_e)}createSkin(_e=""){return new wt(this.T,_e)}createMesh(_e=""){return new ft(this.T,_e)}createPrimitive(){return new dt(this.T)}createPrimitiveTarget(_e=""){return new gt(this.T,_e)}createMaterial(_e=""){return new ht(this.T,_e)}createTexture(_e=""){return new yt(this.T,_e)}createAnimation(_e=""){return new X(this.T,_e)}createAnimationChannel(_e=""){return new tt(this.T,_e)}createAnimationSampler(_e=""){return new et(this.T,_e)}createAccessor(_e="",Dt=null){return Dt||(Dt=this.getRoot().listBuffers()[0]),new Q(this.T,_e).setBuffer(Dt)}createBuffer(_e=""){return new rt(this.T,_e)}}Tt.v=new WeakMap;class xt{constructor(_e){this.jsonDoc=void 0,this.buffers=[],this.bufferViews=[],this.bufferViewBuffers=[],this.accessors=[],this.textures=[],this.textureInfos=new Map,this.materials=[],this.meshes=[],this.cameras=[],this.nodes=[],this.skins=[],this.animations=[],this.scenes=[],this.jsonDoc=_e}setTextureInfo(_e,Dt){this.textureInfos.set(_e,Dt),Dt.texCoord!==void 0&&_e.setTexCoord(Dt.texCoord),Dt.extras!==void 0&&_e.setExtras(Dt.extras);const Vt=this.jsonDoc.json.textures[Dt.index];if(Vt.sampler===void 0)return;const Gt=this.jsonDoc.json.samplers[Vt.sampler];Gt.magFilter!==void 0&&_e.setMagFilter(Gt.magFilter),Gt.minFilter!==void 0&&_e.setMinFilter(Gt.minFilter),Gt.wrapS!==void 0&&_e.setWrapS(Gt.wrapS),Gt.wrapT!==void 0&&_e.setWrapT(Gt.wrapT)}}const At={logger:B$1.DEFAULT_INSTANCE,extensions:[],dependencies:{}};class Et{static read(_e,Dt=At){const Vt=pt({},At,Dt),{json:Gt}=_e,zt=new Tt().setLogger(Vt.logger);this.validate(_e,Vt);const jt=new xt(_e),Ht=Gt.asset,Wt=zt.getRoot().getAsset();Ht.copyright&&(Wt.copyright=Ht.copyright),Ht.extras&&(Wt.extras=Ht.extras),Gt.extras!==void 0&&zt.getRoot().setExtras(pt({},Gt.extras));const qt=Gt.extensionsUsed||[],Xt=Gt.extensionsRequired||[];for(const en of Vt.extensions)if(qt.includes(en.EXTENSION_NAME)){const tn=zt.createExtension(en).setRequired(Xt.includes(en.EXTENSION_NAME));for(const sn of tn.readDependencies)tn.install(sn,Vt.dependencies[sn])}const Kt=Gt.buffers||[];zt.getRoot().listExtensionsUsed().filter(en=>en.prereadTypes.includes(h.BUFFER)).forEach(en=>en.preread(jt,h.BUFFER)),jt.buffers=Kt.map(en=>{const tn=zt.createBuffer(en.name);return en.extras&&tn.setExtras(en.extras),en.uri&&en.uri.indexOf("__")!==0&&tn.setURI(en.uri),tn}),jt.bufferViewBuffers=(Gt.bufferViews||[]).map((en,tn)=>{if(!jt.bufferViews[tn]){const sn=_e.json.buffers[en.buffer];jt.bufferViews[tn]=E.toView(sn.uri?_e.resources[sn.uri]:_e.resources[c],en.byteOffset||0,en.byteLength)}return jt.buffers[en.buffer]});const Yt=Gt.accessors||[];jt.accessors=Yt.map(en=>{const tn=zt.createAccessor(en.name,jt.bufferViewBuffers[en.bufferView]).setType(en.type);return en.extras&&tn.setExtras(en.extras),en.normalized!==void 0&&tn.setNormalized(en.normalized),en.bufferView===void 0||tn.setArray(St(en,jt)),tn});const Zt=Gt.images||[],Jt=Gt.textures||[];zt.getRoot().listExtensionsUsed().filter(en=>en.prereadTypes.includes(h.TEXTURE)).forEach(en=>en.preread(jt,h.TEXTURE)),jt.textures=Zt.map(en=>{const tn=zt.createTexture(en.name);if(en.extras&&tn.setExtras(en.extras),en.bufferView!==void 0){const sn=Gt.bufferViews[en.bufferView],cn=_e.json.buffers[sn.buffer],un=sn.byteOffset||0,hn=(cn.uri?_e.resources[cn.uri]:_e.resources[c]).slice(un,un+sn.byteLength);tn.setImage(hn)}else en.uri!==void 0&&(tn.setImage(_e.resources[en.uri]),en.uri.indexOf("__")!==0&&tn.setURI(en.uri));if(en.mimeType!==void 0)tn.setMimeType(en.mimeType);else if(en.uri){const sn=N.extension(en.uri);tn.setMimeType(I.extensionToMimeType(sn))}return tn}),jt.materials=(Gt.materials||[]).map(en=>{const tn=zt.createMaterial(en.name);en.extras&&tn.setExtras(en.extras),en.alphaMode!==void 0&&tn.setAlphaMode(en.alphaMode),en.alphaCutoff!==void 0&&tn.setAlphaCutoff(en.alphaCutoff),en.doubleSided!==void 0&&tn.setDoubleSided(en.doubleSided);const sn=en.pbrMetallicRoughness||{};if(sn.baseColorFactor!==void 0&&tn.setBaseColorFactor(sn.baseColorFactor),en.emissiveFactor!==void 0&&tn.setEmissiveFactor(en.emissiveFactor),sn.metallicFactor!==void 0&&tn.setMetallicFactor(sn.metallicFactor),sn.roughnessFactor!==void 0&&tn.setRoughnessFactor(sn.roughnessFactor),sn.baseColorTexture!==void 0){const cn=sn.baseColorTexture;tn.setBaseColorTexture(jt.textures[Jt[cn.index].source]),jt.setTextureInfo(tn.getBaseColorTextureInfo(),cn)}if(en.emissiveTexture!==void 0){const cn=en.emissiveTexture;tn.setEmissiveTexture(jt.textures[Jt[cn.index].source]),jt.setTextureInfo(tn.getEmissiveTextureInfo(),cn)}if(en.normalTexture!==void 0){const cn=en.normalTexture;tn.setNormalTexture(jt.textures[Jt[cn.index].source]),jt.setTextureInfo(tn.getNormalTextureInfo(),cn),en.normalTexture.scale!==void 0&&tn.setNormalScale(en.normalTexture.scale)}if(en.occlusionTexture!==void 0){const cn=en.occlusionTexture;tn.setOcclusionTexture(jt.textures[Jt[cn.index].source]),jt.setTextureInfo(tn.getOcclusionTextureInfo(),cn),en.occlusionTexture.strength!==void 0&&tn.setOcclusionStrength(en.occlusionTexture.strength)}if(sn.metallicRoughnessTexture!==void 0){const cn=sn.metallicRoughnessTexture;tn.setMetallicRoughnessTexture(jt.textures[Jt[cn.index].source]),jt.setTextureInfo(tn.getMetallicRoughnessTextureInfo(),cn)}return tn});const nn=Gt.meshes||[];zt.getRoot().listExtensionsUsed().filter(en=>en.prereadTypes.includes(h.PRIMITIVE)).forEach(en=>en.preread(jt,h.PRIMITIVE)),jt.meshes=nn.map(en=>{const tn=zt.createMesh(en.name);return en.extras&&tn.setExtras(en.extras),en.weights!==void 0&&tn.setWeights(en.weights),(en.primitives||[]).forEach(sn=>{const cn=zt.createPrimitive();sn.extras&&cn.setExtras(sn.extras),sn.material!==void 0&&cn.setMaterial(jt.materials[sn.material]),sn.mode!==void 0&&cn.setMode(sn.mode);for(const[hn,fn]of Object.entries(sn.attributes||{}))cn.setAttribute(hn,jt.accessors[fn]);sn.indices!==void 0&&cn.setIndices(jt.accessors[sn.indices]);const un=en.extras&&en.extras.targetNames||[];(sn.targets||[]).forEach((hn,fn)=>{const pn=un[fn]||fn.toString(),dn=zt.createPrimitiveTarget(pn);for(const[mn,vn]of Object.entries(hn))dn.setAttribute(mn,jt.accessors[vn]);cn.addTarget(dn)}),tn.addPrimitive(cn)}),tn}),jt.cameras=(Gt.cameras||[]).map(en=>{const tn=zt.createCamera(en.name).setType(en.type);if(en.extras&&tn.setExtras(en.extras),en.type===st.Type.PERSPECTIVE){const sn=en.perspective;tn.setYFov(sn.yfov),tn.setZNear(sn.znear),sn.zfar!==void 0&&tn.setZFar(sn.zfar),sn.aspectRatio!==void 0&&tn.setAspectRatio(sn.aspectRatio)}else{const sn=en.orthographic;tn.setZNear(sn.znear).setZFar(sn.zfar).setXMag(sn.xmag).setYMag(sn.ymag)}return tn});const rn=Gt.nodes||[];zt.getRoot().listExtensionsUsed().filter(en=>en.prereadTypes.includes(h.NODE)).forEach(en=>en.preread(jt,h.NODE)),jt.nodes=rn.map(en=>{const tn=zt.createNode(en.name);if(en.extras&&tn.setExtras(en.extras),en.translation!==void 0&&tn.setTranslation(en.translation),en.rotation!==void 0&&tn.setRotation(en.rotation),en.scale!==void 0&&tn.setScale(en.scale),en.matrix!==void 0){const sn=[0,0,0],cn=[0,0,0,1],un=[1,1,1];L.decompose(en.matrix,sn,cn,un),tn.setTranslation(sn),tn.setRotation(cn),tn.setScale(un)}return en.weights!==void 0&&tn.setWeights(en.weights),tn}),jt.skins=(Gt.skins||[]).map(en=>{const tn=zt.createSkin(en.name);en.extras&&tn.setExtras(en.extras),en.inverseBindMatrices!==void 0&&tn.setInverseBindMatrices(jt.accessors[en.inverseBindMatrices]),en.skeleton!==void 0&&tn.setSkeleton(jt.nodes[en.skeleton]);for(const sn of en.joints)tn.addJoint(jt.nodes[sn]);return tn}),rn.map((en,tn)=>{const sn=jt.nodes[tn];(en.children||[]).forEach(cn=>sn.addChild(jt.nodes[cn])),en.mesh!==void 0&&sn.setMesh(jt.meshes[en.mesh]),en.camera!==void 0&&sn.setCamera(jt.cameras[en.camera]),en.skin!==void 0&&sn.setSkin(jt.skins[en.skin])}),jt.animations=(Gt.animations||[]).map(en=>{const tn=zt.createAnimation(en.name);en.extras&&tn.setExtras(en.extras);const sn=(en.samplers||[]).map(cn=>{const un=zt.createAnimationSampler().setInput(jt.accessors[cn.input]).setOutput(jt.accessors[cn.output]).setInterpolation(cn.interpolation||et.Interpolation.LINEAR);return cn.extras&&un.setExtras(cn.extras),tn.addSampler(un),un});return(en.channels||[]).forEach(cn=>{const un=zt.createAnimationChannel().setSampler(sn[cn.sampler]).setTargetPath(cn.target.path);cn.target.node!==void 0&&un.setTargetNode(jt.nodes[cn.target.node]),cn.extras&&un.setExtras(cn.extras),tn.addChannel(un)}),tn});const Qt=Gt.scenes||[];return zt.getRoot().listExtensionsUsed().filter(en=>en.prereadTypes.includes(h.SCENE)).forEach(en=>en.preread(jt,h.SCENE)),jt.scenes=Qt.map(en=>{const tn=zt.createScene(en.name);return en.extras&&tn.setExtras(en.extras),(en.nodes||[]).map(sn=>jt.nodes[sn]).forEach(sn=>tn.addChild(sn)),tn}),Gt.scene!==void 0&&zt.getRoot().setDefaultScene(jt.scenes[Gt.scene]),zt.getRoot().listExtensionsUsed().forEach(en=>en.read(jt)),Yt.forEach((en,tn)=>{const sn=jt.accessors[tn],cn=!!en.sparse,un=!en.bufferView&&!sn.getArray();(cn||un)&&sn.setSparse(!0).setArray(function(hn,fn){const pn=p[hn.componentType],dn=Q.getElementSize(hn.type);let mn;mn=hn.bufferView!==void 0?St(hn,fn):new pn(hn.count*dn);const vn=hn.sparse;if(!vn)return mn;const _n=vn.count,En=pt({},hn,vn.indices,{count:_n,type:"SCALAR"}),An=pt({},hn,vn.values,{count:_n}),Tn=St(En,fn),Cn=St(An,fn);for(let yn=0;yn<En.count;yn++)for(let Sn=0;Sn<dn;Sn++)mn[Tn[yn]*dn+Sn]=Cn[yn*dn+Sn];return mn}(en,jt))}),zt}static validate(_e,Dt){const Vt=_e.json;if(Vt.asset.version!=="2.0")throw new Error(`Unsupported glTF version, "${Vt.asset.version}".`);if(Vt.extensionsRequired){for(const Gt of Vt.extensionsRequired)if(!Dt.extensions.find(zt=>zt.EXTENSION_NAME===Gt))throw new Error(`Missing required extension, "${Gt}".`)}if(Vt.extensionsUsed)for(const Gt of Vt.extensionsUsed)Dt.extensions.find(zt=>zt.EXTENSION_NAME===Gt)||Dt.logger.warn(`Missing optional extension, "${Gt}".`)}}function St(kt,_e){const Dt=_e.bufferViews[kt.bufferView],Vt=_e.jsonDoc.json.bufferViews[kt.bufferView],Gt=p[kt.componentType],zt=Q.getElementSize(kt.type),jt=Gt.BYTES_PER_ELEMENT;if(Vt.byteStride!==void 0&&Vt.byteStride!==zt*jt)return function(Wt,qt){const Xt=qt.bufferViews[Wt.bufferView],Kt=qt.jsonDoc.json.bufferViews[Wt.bufferView],Yt=p[Wt.componentType],Zt=Q.getElementSize(Wt.type),Jt=Yt.BYTES_PER_ELEMENT,nn=Wt.byteOffset||0,rn=new Yt(Wt.count*Zt),Qt=new DataView(Xt.buffer,Xt.byteOffset,Xt.byteLength),en=Kt.byteStride;for(let tn=0;tn<Wt.count;tn++)for(let sn=0;sn<Zt;sn++){const cn=nn+tn*en+sn*Jt;let un;switch(Wt.componentType){case Q.ComponentType.FLOAT:un=Qt.getFloat32(cn,!0);break;case Q.ComponentType.UNSIGNED_INT:un=Qt.getUint32(cn,!0);break;case Q.ComponentType.UNSIGNED_SHORT:un=Qt.getUint16(cn,!0);break;case Q.ComponentType.UNSIGNED_BYTE:un=Qt.getUint8(cn);break;case Q.ComponentType.SHORT:un=Qt.getInt16(cn,!0);break;case Q.ComponentType.BYTE:un=Qt.getInt8(cn);break;default:throw new Error(`Unexpected componentType "${Wt.componentType}".`)}rn[tn*Zt+sn]=un}return rn}(kt,_e);const Ht=Dt.byteOffset+(kt.byteOffset||0);return new Gt(Dt.buffer.slice(Ht,Ht+kt.count*zt*jt))}var Mt;(function(kt){kt[kt.ARRAY_BUFFER=34962]="ARRAY_BUFFER",kt[kt.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER"})(Mt||(Mt={}));class It{constructor(_e,Dt,Vt){this.C=void 0,this.jsonDoc=void 0,this.options=void 0,this.accessorIndexMap=new Map,this.animationIndexMap=new Map,this.bufferIndexMap=new Map,this.cameraIndexMap=new Map,this.skinIndexMap=new Map,this.materialIndexMap=new Map,this.meshIndexMap=new Map,this.nodeIndexMap=new Map,this.imageIndexMap=new Map,this.textureDefIndexMap=new Map,this.textureInfoDefMap=new Map,this.samplerDefIndexMap=new Map,this.sceneIndexMap=new Map,this.imageBufferViews=[],this.otherBufferViews=new Map,this.otherBufferViewsIndexMap=new Map,this.extensionData={},this.bufferURIGenerator=void 0,this.imageURIGenerator=void 0,this.logger=void 0,this.F=new Map,this.accessorUsageGroupedByParent=new Set(["ARRAY_BUFFER"]),this.accessorParents=new Map,this.C=_e,this.jsonDoc=Dt,this.options=Vt;const Gt=_e.getRoot(),zt=Gt.listBuffers().length,jt=Gt.listTextures().length;this.bufferURIGenerator=new Rt(zt>1,()=>Vt.basename||"buffer"),this.imageURIGenerator=new Rt(jt>1,Ht=>function(Wt,qt){const Xt=Wt.getGraph().listParentEdges(qt).find(Kt=>Kt.getParent()!==Wt.getRoot());return Xt?Xt.getName().replace(/texture$/i,""):""}(_e,Ht)||Vt.basename||"texture"),this.logger=_e.getLogger()}createTextureInfoDef(_e,Dt){const Vt={magFilter:Dt.getMagFilter()||void 0,minFilter:Dt.getMinFilter()||void 0,wrapS:Dt.getWrapS(),wrapT:Dt.getWrapT()},Gt=JSON.stringify(Vt);this.samplerDefIndexMap.has(Gt)||(this.samplerDefIndexMap.set(Gt,this.jsonDoc.json.samplers.length),this.jsonDoc.json.samplers.push(Vt));const zt={source:this.imageIndexMap.get(_e),sampler:this.samplerDefIndexMap.get(Gt)},jt=JSON.stringify(zt);this.textureDefIndexMap.has(jt)||(this.textureDefIndexMap.set(jt,this.jsonDoc.json.textures.length),this.jsonDoc.json.textures.push(zt));const Ht={index:this.textureDefIndexMap.get(jt)};return Dt.getTexCoord()!==0&&(Ht.texCoord=Dt.getTexCoord()),Object.keys(Dt.getExtras()).length>0&&(Ht.extras=Dt.getExtras()),this.textureInfoDefMap.set(Dt,Ht),Ht}createPropertyDef(_e){const Dt={};return _e.getName()&&(Dt.name=_e.getName()),Object.keys(_e.getExtras()).length>0&&(Dt.extras=_e.getExtras()),Dt}createAccessorDef(_e){const Dt=this.createPropertyDef(_e);return Dt.type=_e.getType(),Dt.componentType=_e.getComponentType(),Dt.count=_e.getCount(),this.C.getGraph().listParentEdges(_e).some(Vt=>Vt.getName()==="attributes"&&Vt.getAttributes().key==="POSITION"||Vt.getName()==="input")&&(Dt.max=_e.getMax([]).map(Math.fround),Dt.min=_e.getMin([]).map(Math.fround)),_e.getNormalized()&&(Dt.normalized=_e.getNormalized()),Dt}createImageData(_e,Dt,Vt){if(this.options.format===g.GLB)this.imageBufferViews.push(Dt),_e.bufferView=this.jsonDoc.json.bufferViews.length,this.jsonDoc.json.bufferViews.push({buffer:0,byteOffset:-1,byteLength:Dt.byteLength});else{const Gt=I.mimeTypeToExtension(Vt.getMimeType());_e.uri=this.imageURIGenerator.createURI(Vt,Gt),this.jsonDoc.resources[_e.uri]=Dt}}getAccessorUsage(_e){const Dt=this.F.get(_e);if(Dt)return Dt;if(_e.getSparse())return l.SPARSE;for(const Vt of this.C.getGraph().listParentEdges(_e)){const{usage:Gt}=Vt.getAttributes();if(Gt)return Gt;Vt.getParent().propertyType!==h.ROOT&&this.logger.warn(`Missing attribute ".usage" on edge, "${Vt.getName()}".`)}return l.OTHER}addAccessorToUsageGroup(_e,Dt){const Vt=this.F.get(_e);if(Vt&&Vt!==Dt)throw new Error(`Accessor with usage "${Vt}" cannot be reused as "${Dt}".`);return this.F.set(_e,Dt),this}listAccessorUsageGroups(){const _e={};for(const[Dt,Vt]of Array.from(this.F.entries()))_e[Vt]=_e[Vt]||[],_e[Vt].push(Dt);return _e}}It.BufferViewTarget=Mt,It.BufferViewUsage=l,It.USAGE_TO_TARGET={[l.ARRAY_BUFFER]:Mt.ARRAY_BUFFER,[l.ELEMENT_ARRAY_BUFFER]:Mt.ELEMENT_ARRAY_BUFFER};class Rt{constructor(_e,Dt){this.multiple=void 0,this.basename=void 0,this.counter={},this.multiple=_e,this.basename=Dt}createURI(_e,Dt){if(_e.getURI())return _e.getURI();if(this.multiple){const Vt=this.basename(_e);return this.counter[Vt]=this.counter[Vt]||1,`${Vt}_${this.counter[Vt]++}.${Dt}`}return`${this.basename(_e)}.${Dt}`}}const{BufferViewUsage:Nt}=It,{UNSIGNED_INT:Ot,UNSIGNED_SHORT:Ct,UNSIGNED_BYTE:Ft}=Q.ComponentType;class Ut{static write(_e,Dt){const Vt=_e.getRoot(),Gt={asset:pt({generator:`glTF-Transform ${u}`},Vt.getAsset()),extras:pt({},Vt.getExtras())},zt={json:Gt,resources:{}},jt=new It(_e,zt,Dt),Ht=Dt.logger||B$1.DEFAULT_INSTANCE,Wt=new Set(Dt.extensions.map(rn=>rn.EXTENSION_NAME)),qt=_e.getRoot().listExtensionsUsed().filter(rn=>Wt.has(rn.extensionName)),Xt=_e.getRoot().listExtensionsRequired().filter(rn=>Wt.has(rn.extensionName));qt.length<_e.getRoot().listExtensionsUsed().length&&Ht.warn("Some extensions were not registered for I/O, and will not be written.");for(const rn of qt)for(const Qt of rn.writeDependencies)rn.install(Qt,Dt.dependencies[Qt]);function Kt(rn,Qt,en,tn){const sn=[];let cn=0;for(const hn of rn){const fn=jt.createAccessorDef(hn);fn.bufferView=Gt.bufferViews.length;const pn=hn.getArray(),dn=E.pad(E.toView(pn));fn.byteOffset=cn,cn+=dn.byteLength,sn.push(dn),jt.accessorIndexMap.set(hn,Gt.accessors.length),Gt.accessors.push(fn)}const un={buffer:Qt,byteOffset:en,byteLength:E.concat(sn).byteLength};return tn&&(un.target=tn),Gt.bufferViews.push(un),{buffers:sn,byteLength:cn}}function Yt(rn,Qt,en){const tn=rn[0].getCount();let sn=0;for(const fn of rn){const pn=jt.createAccessorDef(fn);pn.bufferView=Gt.bufferViews.length,pn.byteOffset=sn;const dn=fn.getElementSize(),mn=fn.getComponentSize();sn+=E.padNumber(dn*mn),jt.accessorIndexMap.set(fn,Gt.accessors.length),Gt.accessors.push(pn)}const cn=tn*sn,un=new ArrayBuffer(cn),hn=new DataView(un);for(let fn=0;fn<tn;fn++){let pn=0;for(const dn of rn){const mn=dn.getElementSize(),vn=dn.getComponentSize(),_n=dn.getComponentType(),En=dn.getArray();for(let An=0;An<mn;An++){const Tn=fn*sn+pn+An*vn,Cn=En[fn*mn+An];switch(_n){case Q.ComponentType.FLOAT:hn.setFloat32(Tn,Cn,!0);break;case Q.ComponentType.BYTE:hn.setInt8(Tn,Cn);break;case Q.ComponentType.SHORT:hn.setInt16(Tn,Cn,!0);break;case Q.ComponentType.UNSIGNED_BYTE:hn.setUint8(Tn,Cn);break;case Q.ComponentType.UNSIGNED_SHORT:hn.setUint16(Tn,Cn,!0);break;case Q.ComponentType.UNSIGNED_INT:hn.setUint32(Tn,Cn,!0);break;default:throw new Error("Unexpected component type: "+_n)}}pn+=E.padNumber(mn*vn)}}return Gt.bufferViews.push({buffer:Qt,byteOffset:en,byteLength:cn,byteStride:sn,target:It.BufferViewTarget.ARRAY_BUFFER}),{byteLength:cn,buffers:[new Uint8Array(un)]}}function Zt(rn,Qt,en){const tn=[];let sn=0;const cn=new Map;let un=-1/0;for(const _n of rn){const En=jt.createAccessorDef(_n);Gt.accessors.push(En),jt.accessorIndexMap.set(_n,Gt.accessors.length-1);const An=[],Tn=[],Cn=[],yn=new Array(_n.getElementSize()).fill(0);for(let Rn=0,Dn=_n.getCount();Rn<Dn;Rn++)if(_n.getElement(Rn,Cn),!L.eq(Cn,yn,0)){un=Math.max(Rn,un),An.push(Rn);for(let kn=0;kn<Cn.length;kn++)Tn.push(Cn[kn])}const Sn=An.length,wn={accessorDef:En,count:Sn};if(cn.set(_n,wn),Sn===0)continue;if(Sn>_n.getCount()/3){const Rn=(100*An.length/_n.getCount()).toFixed(1);Ht.warn(`Sparse accessor with many non-zero elements (${Rn}%) may increase file size.`)}const xn=p[_n.getComponentType()];wn.indices=An,wn.values=new xn(Tn)}if(!Number.isFinite(un))return{buffers:tn,byteLength:sn};const hn=un<255?Uint8Array:un<65535?Uint16Array:Uint32Array,fn=un<255?Ft:un<65535?Ct:Ot,pn={buffer:Qt,byteOffset:en+sn,byteLength:0};for(const _n of rn){const En=cn.get(_n);if(En.count===0)continue;En.indicesByteOffset=pn.byteLength;const An=E.pad(E.toView(new hn(En.indices)));tn.push(An),sn+=An.byteLength,pn.byteLength+=An.byteLength}Gt.bufferViews.push(pn);const dn=Gt.bufferViews.length-1,mn={buffer:Qt,byteOffset:en+sn,byteLength:0};for(const _n of rn){const En=cn.get(_n);if(En.count===0)continue;En.valuesByteOffset=mn.byteLength;const An=E.pad(E.toView(En.values));tn.push(An),sn+=An.byteLength,mn.byteLength+=An.byteLength}Gt.bufferViews.push(mn);const vn=Gt.bufferViews.length-1;for(const _n of rn){const En=cn.get(_n);En.count!==0&&(En.accessorDef.sparse={count:En.count,indices:{bufferView:dn,byteOffset:En.indicesByteOffset,componentType:fn},values:{bufferView:vn,byteOffset:En.valuesByteOffset}})}return{buffers:tn,byteLength:sn}}const Jt=new Map;for(const rn of _e.getGraph().listEdges()){if(rn.getParent()===Vt)continue;const Qt=rn.getChild();if(Qt instanceof Q){const en=Jt.get(Qt)||[];en.push(rn),Jt.set(Qt,en)}}if(Gt.accessors=[],Gt.bufferViews=[],Gt.samplers=[],Gt.textures=[],Gt.images=Vt.listTextures().map((rn,Qt)=>{const en=jt.createPropertyDef(rn);rn.getMimeType()&&(en.mimeType=rn.getMimeType());const tn=rn.getImage();return tn&&jt.createImageData(en,tn,rn),jt.imageIndexMap.set(rn,Qt),en}),qt.filter(rn=>rn.prewriteTypes.includes(h.ACCESSOR)).forEach(rn=>rn.prewrite(jt,h.ACCESSOR)),Vt.listAccessors().forEach(rn=>{const Qt=jt.accessorUsageGroupedByParent,en=jt.accessorParents;if(jt.accessorIndexMap.has(rn))return;const tn=Jt.get(rn)||[],sn=jt.getAccessorUsage(rn);if(jt.addAccessorToUsageGroup(rn,sn),Qt.has(sn)){const cn=tn[0].getParent(),un=en.get(cn)||new Set;un.add(rn),en.set(cn,un)}}),qt.filter(rn=>rn.prewriteTypes.includes(h.BUFFER)).forEach(rn=>rn.prewrite(jt,h.BUFFER)),(Vt.listAccessors().length>0||Vt.listTextures().length>0||jt.otherBufferViews.size>0)&&Vt.listBuffers().length===0)throw new Error("Buffer required for Document resources, but none was found.");Gt.buffers=[],Vt.listBuffers().forEach((rn,Qt)=>{const en=jt.createPropertyDef(rn),tn=jt.accessorUsageGroupedByParent,sn=jt.accessorParents,cn=rn.listParents().filter(mn=>mn instanceof Q),un=new Set(cn),hn=[],fn=Gt.buffers.length;let pn=0;const dn=jt.listAccessorUsageGroups();for(const mn in dn)if(tn.has(mn))for(const vn of Array.from(sn.values())){const _n=Array.from(vn).filter(En=>un.has(En)).filter(En=>jt.getAccessorUsage(En)===mn);if(_n.length)if(mn!==Nt.ARRAY_BUFFER||Dt.vertexLayout===f.INTERLEAVED){const En=mn===Nt.ARRAY_BUFFER?Yt(_n,fn,pn):Kt(_n,fn,pn);pn+=En.byteLength,hn.push(...En.buffers)}else for(const En of _n){const An=Yt([En],fn,pn);pn+=An.byteLength,hn.push(...An.buffers)}}else{const vn=dn[mn].filter(An=>un.has(An));if(!vn.length)continue;const _n=mn===Nt.ELEMENT_ARRAY_BUFFER?It.BufferViewTarget.ELEMENT_ARRAY_BUFFER:void 0,En=mn===Nt.SPARSE?Zt(vn,fn,pn):Kt(vn,fn,pn,_n);pn+=En.byteLength,hn.push(...En.buffers)}if(jt.imageBufferViews.length&&Qt===0){for(let mn=0;mn<jt.imageBufferViews.length;mn++)if(Gt.bufferViews[Gt.images[mn].bufferView].byteOffset=pn,pn+=jt.imageBufferViews[mn].byteLength,hn.push(jt.imageBufferViews[mn]),pn%8){const vn=8-pn%8;pn+=vn,hn.push(new Uint8Array(vn))}}if(jt.otherBufferViews.has(rn))for(const mn of jt.otherBufferViews.get(rn))Gt.bufferViews.push({buffer:fn,byteOffset:pn,byteLength:mn.byteLength}),jt.otherBufferViewsIndexMap.set(mn,Gt.bufferViews.length-1),pn+=mn.byteLength,hn.push(mn);if(pn){let mn;Dt.format===g.GLB?mn=c:(mn=jt.bufferURIGenerator.createURI(rn,"bin"),en.uri=mn),en.byteLength=pn,zt.resources[mn]=E.concat(hn)}Gt.buffers.push(en),jt.bufferIndexMap.set(rn,Qt)}),Vt.listAccessors().find(rn=>!rn.getBuffer())&&Ht.warn("Skipped writing one or more Accessors: no Buffer assigned."),Gt.materials=Vt.listMaterials().map((rn,Qt)=>{const en=jt.createPropertyDef(rn);if(rn.getAlphaMode()!==ht.AlphaMode.OPAQUE&&(en.alphaMode=rn.getAlphaMode()),rn.getAlphaMode()===ht.AlphaMode.MASK&&(en.alphaCutoff=rn.getAlphaCutoff()),rn.getDoubleSided()&&(en.doubleSided=!0),en.pbrMetallicRoughness={},L.eq(rn.getBaseColorFactor(),[1,1,1,1])||(en.pbrMetallicRoughness.baseColorFactor=rn.getBaseColorFactor()),L.eq(rn.getEmissiveFactor(),[0,0,0])||(en.emissiveFactor=rn.getEmissiveFactor()),rn.getRoughnessFactor()!==1&&(en.pbrMetallicRoughness.roughnessFactor=rn.getRoughnessFactor()),rn.getMetallicFactor()!==1&&(en.pbrMetallicRoughness.metallicFactor=rn.getMetallicFactor()),rn.getBaseColorTexture()){const tn=rn.getBaseColorTexture(),sn=rn.getBaseColorTextureInfo();en.pbrMetallicRoughness.baseColorTexture=jt.createTextureInfoDef(tn,sn)}if(rn.getEmissiveTexture()){const tn=rn.getEmissiveTexture(),sn=rn.getEmissiveTextureInfo();en.emissiveTexture=jt.createTextureInfoDef(tn,sn)}if(rn.getNormalTexture()){const tn=rn.getNormalTexture(),sn=rn.getNormalTextureInfo(),cn=jt.createTextureInfoDef(tn,sn);rn.getNormalScale()!==1&&(cn.scale=rn.getNormalScale()),en.normalTexture=cn}if(rn.getOcclusionTexture()){const tn=rn.getOcclusionTexture(),sn=rn.getOcclusionTextureInfo(),cn=jt.createTextureInfoDef(tn,sn);rn.getOcclusionStrength()!==1&&(cn.strength=rn.getOcclusionStrength()),en.occlusionTexture=cn}if(rn.getMetallicRoughnessTexture()){const tn=rn.getMetallicRoughnessTexture(),sn=rn.getMetallicRoughnessTextureInfo();en.pbrMetallicRoughness.metallicRoughnessTexture=jt.createTextureInfoDef(tn,sn)}return jt.materialIndexMap.set(rn,Qt),en}),Gt.meshes=Vt.listMeshes().map((rn,Qt)=>{const en=jt.createPropertyDef(rn);let tn=null;return en.primitives=rn.listPrimitives().map(sn=>{const cn={attributes:{}};cn.mode=sn.getMode();const un=sn.getMaterial();un&&(cn.material=jt.materialIndexMap.get(un)),Object.keys(sn.getExtras()).length&&(cn.extras=sn.getExtras());const hn=sn.getIndices();hn&&(cn.indices=jt.accessorIndexMap.get(hn));for(const fn of sn.listSemantics())cn.attributes[fn]=jt.accessorIndexMap.get(sn.getAttribute(fn));for(const fn of sn.listTargets()){const pn={};for(const dn of fn.listSemantics())pn[dn]=jt.accessorIndexMap.get(fn.getAttribute(dn));cn.targets=cn.targets||[],cn.targets.push(pn)}return sn.listTargets().length&&!tn&&(tn=sn.listTargets().map(fn=>fn.getName())),cn}),rn.getWeights().length&&(en.weights=rn.getWeights()),tn&&(en.extras=en.extras||{},en.extras.targetNames=tn),jt.meshIndexMap.set(rn,Qt),en}),Gt.cameras=Vt.listCameras().map((rn,Qt)=>{const en=jt.createPropertyDef(rn);if(en.type=rn.getType(),en.type===st.Type.PERSPECTIVE){en.perspective={znear:rn.getZNear(),zfar:rn.getZFar(),yfov:rn.getYFov()};const tn=rn.getAspectRatio();tn!==null&&(en.perspective.aspectRatio=tn)}else en.orthographic={znear:rn.getZNear(),zfar:rn.getZFar(),xmag:rn.getXMag(),ymag:rn.getYMag()};return jt.cameraIndexMap.set(rn,Qt),en}),Gt.nodes=Vt.listNodes().map((rn,Qt)=>{const en=jt.createPropertyDef(rn);return L.eq(rn.getTranslation(),[0,0,0])||(en.translation=rn.getTranslation()),L.eq(rn.getRotation(),[0,0,0,1])||(en.rotation=rn.getRotation()),L.eq(rn.getScale(),[1,1,1])||(en.scale=rn.getScale()),rn.getWeights().length&&(en.weights=rn.getWeights()),jt.nodeIndexMap.set(rn,Qt),en}),Gt.skins=Vt.listSkins().map((rn,Qt)=>{const en=jt.createPropertyDef(rn),tn=rn.getInverseBindMatrices();tn&&(en.inverseBindMatrices=jt.accessorIndexMap.get(tn));const sn=rn.getSkeleton();return sn&&(en.skeleton=jt.nodeIndexMap.get(sn)),en.joints=rn.listJoints().map(cn=>jt.nodeIndexMap.get(cn)),jt.skinIndexMap.set(rn,Qt),en}),Vt.listNodes().forEach((rn,Qt)=>{const en=Gt.nodes[Qt],tn=rn.getMesh();tn&&(en.mesh=jt.meshIndexMap.get(tn));const sn=rn.getCamera();sn&&(en.camera=jt.cameraIndexMap.get(sn));const cn=rn.getSkin();cn&&(en.skin=jt.skinIndexMap.get(cn)),rn.listChildren().length>0&&(en.children=rn.listChildren().map(un=>jt.nodeIndexMap.get(un)))}),Gt.animations=Vt.listAnimations().map((rn,Qt)=>{const en=jt.createPropertyDef(rn),tn=new Map;return en.samplers=rn.listSamplers().map((sn,cn)=>{const un=jt.createPropertyDef(sn);return un.input=jt.accessorIndexMap.get(sn.getInput()),un.output=jt.accessorIndexMap.get(sn.getOutput()),un.interpolation=sn.getInterpolation(),tn.set(sn,cn),un}),en.channels=rn.listChannels().map(sn=>{const cn=jt.createPropertyDef(sn);return cn.sampler=tn.get(sn.getSampler()),cn.target={node:jt.nodeIndexMap.get(sn.getTargetNode()),path:sn.getTargetPath()},cn}),jt.animationIndexMap.set(rn,Qt),en}),Gt.scenes=Vt.listScenes().map((rn,Qt)=>{const en=jt.createPropertyDef(rn);return en.nodes=rn.listChildren().map(tn=>jt.nodeIndexMap.get(tn)),jt.sceneIndexMap.set(rn,Qt),en});const nn=Vt.getDefaultScene();return nn&&(Gt.scene=Vt.listScenes().indexOf(nn)),Gt.extensionsUsed=qt.map(rn=>rn.extensionName),Gt.extensionsRequired=Xt.map(rn=>rn.extensionName),qt.forEach(rn=>rn.write(jt)),function(rn){const Qt=[];for(const en in rn){const tn=rn[en];(Array.isArray(tn)&&tn.length===0||tn===null||tn===""||tn&&typeof tn=="object"&&Object.keys(tn).length===0)&&Qt.push(en)}for(const en of Qt)delete rn[en]}(Gt),zt}}var Bt;(function(kt){kt[kt.JSON=1313821514]="JSON",kt[kt.BIN=5130562]="BIN"})(Bt||(Bt={}));class Pt{constructor(){this.M=B$1.DEFAULT_INSTANCE,this.l=new Set,this.U={},this.P=f.INTERLEAVED,this.lastReadBytes=0,this.lastWriteBytes=0}setLogger(_e){return this.M=_e,this}registerExtensions(_e){for(const Dt of _e)this.l.add(Dt),Dt.register();return this}registerDependencies(_e){return Object.assign(this.U,_e),this}setVertexLayout(_e){return this.P=_e,this}async read(_e){return await this.readJSON(await this.readAsJSON(_e))}async readAsJSON(_e){const Dt=await this.readURI(_e,"view");this.lastReadBytes=Dt.byteLength;const Vt=Lt(Dt)?this.L(Dt):{json:JSON.parse(E.decodeText(Dt)),resources:{}};return await this.j(Vt,this.dirname(_e)),this.D(Vt),Vt}async readJSON(_e){return _e=this._(_e),this.D(_e),Et.read(_e,{extensions:Array.from(this.l),dependencies:this.U,logger:this.M})}async binaryToJSON(_e){const Dt=this.L(E.assertView(_e));this.D(Dt);const Vt=Dt.json;if(Vt.buffers&&Vt.buffers.some(Gt=>function(zt,jt){return jt.uri!==void 0&&!(jt.uri in zt.resources)}(Dt,Gt)))throw new Error("Cannot resolve external buffers with binaryToJSON().");if(Vt.images&&Vt.images.some(Gt=>function(zt,jt){return jt.uri!==void 0&&!(jt.uri in zt.resources)&&jt.bufferView===void 0}(Dt,Gt)))throw new Error("Cannot resolve external images with binaryToJSON().");return Dt}async readBinary(_e){return this.readJSON(await this.binaryToJSON(E.assertView(_e)))}async writeJSON(_e,Dt={}){if(Dt.format===g.GLB&&_e.getRoot().listBuffers().length>1)throw new Error("GLB must have 0–1 buffers.");return Ut.write(_e,{format:Dt.format||g.GLTF,basename:Dt.basename||"",logger:this.M,vertexLayout:this.P,dependencies:pt({},this.U),extensions:Array.from(this.l)})}async writeBinary(_e){const{json:Dt,resources:Vt}=await this.writeJSON(_e,{format:g.GLB}),Gt=new Uint32Array([1179937895,2,12]),zt=JSON.stringify(Dt),jt=E.pad(E.encodeText(zt),32),Ht=E.toView(new Uint32Array([jt.byteLength,1313821514])),Wt=E.concat([Ht,jt]);Gt[Gt.length-1]+=Wt.byteLength;const qt=Object.values(Vt)[0];if(!qt||!qt.byteLength)return E.concat([E.toView(Gt),Wt]);const Xt=E.pad(qt,0),Kt=E.toView(new Uint32Array([Xt.byteLength,5130562])),Yt=E.concat([Kt,Xt]);return Gt[Gt.length-1]+=Yt.byteLength,E.concat([E.toView(Gt),Wt,Yt])}async j(_e,Dt){var Vt=this;const Gt=[..._e.json.images||[],..._e.json.buffers||[]].map(async function(zt){const jt=zt.uri;if(!jt||jt.match(/data:/))return Promise.resolve();_e.resources[jt]=await Vt.readURI(Vt.resolve(Dt,jt),"view"),Vt.lastReadBytes+=_e.resources[jt].byteLength});await Promise.all(Gt)}D(_e){function Dt(Vt){if(Vt.uri){if(Vt.uri in _e.resources)E.assertView(_e.resources[Vt.uri]);else if(Vt.uri.match(/data:/)){const Gt=`__${V()}.${N.extension(Vt.uri)}`;_e.resources[Gt]=E.createBufferFromDataURI(Vt.uri),Vt.uri=Gt}}}(_e.json.images||[]).forEach(Vt=>{if(Vt.bufferView===void 0&&Vt.uri===void 0)throw new Error("Missing resource URI or buffer view.");Dt(Vt)}),(_e.json.buffers||[]).forEach(Dt)}_(_e){const{images:Dt,buffers:Vt}=_e.json;return _e={json:pt({},_e.json),resources:pt({},_e.resources)},Dt&&(_e.json.images=Dt.map(Gt=>pt({},Gt))),Vt&&(_e.json.buffers=Vt.map(Gt=>pt({},Gt))),_e}L(_e){if(!Lt(_e))throw new Error("Invalid glTF 2.0 binary.");const Dt=new Uint32Array(_e.buffer,_e.byteOffset+12,2);if(Dt[1]!==Bt.JSON)throw new Error("Missing required GLB JSON chunk.");const Vt=Dt[0],Gt=E.decodeText(E.toView(_e,20,Vt)),zt=JSON.parse(Gt),jt=20+Vt;if(_e.byteLength<=jt)return{json:zt,resources:{}};const Ht=new Uint32Array(_e.buffer,_e.byteOffset+jt,2);if(Ht[1]!==Bt.BIN)throw new Error("Expected GLB BIN in second chunk.");const Wt=E.toView(_e,jt+8,Ht[0]);return{json:zt,resources:{[c]:Wt}}}}function Lt(kt){if(kt.byteLength<3*Uint32Array.BYTES_PER_ELEMENT)return!1;const _e=new Uint32Array(kt.buffer,kt.byteOffset,3);return _e[0]===1179937895&&_e[1]===2}class _t extends Pt{constructor(_e=q$1.DEFAULT_INIT){super(),this.J=void 0,this.J=_e}async readURI(_e,Dt){const Vt=await fetch(_e,this.J);switch(Dt){case"view":return new Uint8Array(await Vt.arrayBuffer());case"text":return Vt.text()}}resolve(_e,Dt){return q$1.resolve(_e,Dt)}dirname(_e){return q$1.dirname(_e)}}function q(){return q=Object.assign?Object.assign.bind():function(kt){for(var _e=1;_e<arguments.length;_e++){var Dt=arguments[_e];for(var Vt in Dt)Object.prototype.hasOwnProperty.call(Dt,Vt)&&(kt[Vt]=Dt[Vt])}return kt},q.apply(this,arguments)}function B(kt,_e){return Object.defineProperty(_e,"name",{value:kt}),_e}function Z(kt,_e){if(kt==null&&_e==null)return!0;if(kt==null||_e==null||kt.length!==_e.length)return!1;for(let Dt=0;Dt<kt.length;Dt++)if(kt[Dt]!==_e[Dt])return!1;return!0}var ae=typeof Float32Array<"u"?Float32Array:Array;function ge(){var kt=new ae(3);return ae!=Float32Array&&(kt[0]=0,kt[1]=0,kt[2]=0),kt}function Ae(){var kt=new ae(4);return ae!=Float32Array&&(kt[0]=0,kt[1]=0,kt[2]=0,kt[3]=0),kt}Math.hypot||(Math.hypot=function(){for(var kt=0,_e=arguments.length;_e--;)kt+=arguments[_e]*arguments[_e];return Math.sqrt(kt)}),ge(),Ae();const Te="dedup",ye={propertyTypes:[h.ACCESSOR,h.MESH,h.TEXTURE,h.MATERIAL,h.SKIN]};function Ee(kt=ye){const _e=q({},ye,kt),Dt=new Set(_e.propertyTypes);for(const Vt of _e.propertyTypes)if(!ye.propertyTypes.includes(Vt))throw new Error(`${Te}: Unsupported deduplication on type "${Vt}".`);return B(Te,Vt=>{const Gt=Vt.getLogger();Dt.has(h.ACCESSOR)&&function(zt){const jt=zt.getLogger(),Ht=new Map,Wt=new Map,qt=new Map,Xt=new Map,Kt=zt.getRoot().listMeshes();Kt.forEach(rn=>{rn.listPrimitives().forEach(Qt=>{Qt.listAttributes().forEach(en=>Yt(en,Wt)),Yt(Qt.getIndices(),Ht)})});for(const rn of zt.getRoot().listAnimations())for(const Qt of rn.listSamplers())Yt(Qt.getInput(),qt),Yt(Qt.getOutput(),Xt);function Yt(rn,Qt){if(!rn)return;const en=[rn.getCount(),rn.getType(),rn.getComponentType(),rn.getNormalized(),rn.getSparse()].join(":");let tn=Qt.get(en);tn||Qt.set(en,tn=new Set),tn.add(rn)}function Zt(rn,Qt){for(let en=0;en<rn.length;en++){const tn=rn[en],sn=E.toView(tn.getArray());if(!Qt.has(tn))for(let cn=en+1;cn<rn.length;cn++){const un=rn[cn];Qt.has(un)||E.equals(sn,E.toView(un.getArray()))&&Qt.set(un,tn)}}}let Jt=0;const nn=new Map;for(const rn of[Wt,Ht,qt,Xt])for(const Qt of rn.values())Jt+=Qt.size,Zt(Array.from(Qt),nn);jt.debug(`${Te}: Merged ${nn.size} of ${Jt} accessors.`),Kt.forEach(rn=>{rn.listPrimitives().forEach(Qt=>{Qt.listAttributes().forEach(tn=>{nn.has(tn)&&Qt.swap(tn,nn.get(tn))});const en=Qt.getIndices();en&&nn.has(en)&&Qt.swap(en,nn.get(en))})});for(const rn of zt.getRoot().listAnimations())for(const Qt of rn.listSamplers()){const en=Qt.getInput(),tn=Qt.getOutput();en&&nn.has(en)&&Qt.swap(en,nn.get(en)),tn&&nn.has(tn)&&Qt.swap(tn,nn.get(tn))}Array.from(nn.keys()).forEach(rn=>rn.dispose())}(Vt),Dt.has(h.TEXTURE)&&function(zt){const jt=zt.getLogger(),Ht=zt.getRoot(),Wt=Ht.listTextures(),qt=new Map;for(let Xt=0;Xt<Wt.length;Xt++){const Kt=Wt[Xt],Yt=Kt.getImage();if(!qt.has(Kt))for(let Zt=Xt+1;Zt<Wt.length;Zt++){const Jt=Wt[Zt],nn=Jt.getImage();if(qt.has(Jt)||Kt.getMimeType()!==Jt.getMimeType())continue;const rn=Kt.getSize(),Qt=Jt.getSize();rn&&Qt&&rn[0]===Qt[0]&&rn[1]===Qt[1]&&Yt&&nn&&E.equals(Yt,nn)&&qt.set(Jt,Kt)}}jt.debug(`${Te}: Merged ${qt.size} of ${Ht.listTextures().length} textures.`),Array.from(qt.entries()).forEach(([Xt,Kt])=>{Xt.listParents().forEach(Yt=>{Yt instanceof vt||Yt.swap(Xt,Kt)}),Xt.dispose()})}(Vt),Dt.has(h.MATERIAL)&&function(zt){const jt=zt.getLogger(),Ht=zt.getRoot().listMaterials(),Wt=new Map,qt=new Set(["name"]),Xt=new Map;for(let Kt=0;Kt<Ht.length;Kt++){const Yt=Ht[Kt];if(!Wt.has(Yt)&&!Me(Yt,Xt))for(let Zt=Kt+1;Zt<Ht.length;Zt++){const Jt=Ht[Zt];Wt.has(Jt)||Me(Jt,Xt)||Yt.equals(Jt,qt)&&Wt.set(Jt,Yt)}}jt.debug(`${Te}: Merged ${Wt.size} of ${Ht.length} materials.`),Array.from(Wt.entries()).forEach(([Kt,Yt])=>{Kt.listParents().forEach(Zt=>{Zt instanceof vt||Zt.swap(Kt,Yt)}),Kt.dispose()})}(Vt),Dt.has(h.MESH)&&function(zt){const jt=zt.getLogger(),Ht=zt.getRoot(),Wt=new Map;Ht.listAccessors().forEach((Kt,Yt)=>Wt.set(Kt,Yt)),Ht.listMaterials().forEach((Kt,Yt)=>Wt.set(Kt,Yt));const qt=Ht.listMeshes().length,Xt=new Map;for(const Kt of Ht.listMeshes()){const Yt=[];for(const Jt of Kt.listPrimitives())Yt.push(Se(Jt,Wt));const Zt=Yt.join(";");if(Xt.has(Zt)){const Jt=Xt.get(Zt);Kt.listParents().forEach(nn=>{nn.propertyType!==h.ROOT&&nn.swap(Kt,Jt)}),Kt.dispose()}else Xt.set(Zt,Kt)}jt.debug(`${Te}: Merged ${qt-Xt.size} of ${qt} meshes.`)}(Vt),Dt.has(h.SKIN)&&function(zt){const jt=zt.getLogger(),Ht=zt.getRoot().listSkins(),Wt=new Map,qt=new Set(["name","joints"]);for(let Xt=0;Xt<Ht.length;Xt++){const Kt=Ht[Xt];if(!Wt.has(Kt))for(let Yt=Xt+1;Yt<Ht.length;Yt++){const Zt=Ht[Yt];Wt.has(Zt)||Kt.equals(Zt,qt)&&Z(Kt.listJoints(),Zt.listJoints())&&Wt.set(Zt,Kt)}}jt.debug(`${Te}: Merged ${Wt.size} of ${Ht.length} skins.`),Array.from(Wt.entries()).forEach(([Xt,Kt])=>{Xt.listParents().forEach(Yt=>{Yt instanceof vt||Yt.swap(Xt,Kt)}),Xt.dispose()})}(Vt),Gt.debug(`${Te}: Complete.`)})}function Se(kt,_e){const Dt=[];for(const Vt of kt.listSemantics()){const Gt=kt.getAttribute(Vt);Dt.push(Vt+":"+_e.get(Gt))}if(kt instanceof dt){const Vt=kt.getIndices();Vt&&Dt.push("indices:"+_e.get(Vt));const Gt=kt.getMaterial();Gt&&Dt.push("material:"+_e.get(Gt)),Dt.push("mode:"+kt.getMode());for(const zt of kt.listTargets())Dt.push("target:"+Se(zt,_e))}return Dt.join(",")}function Me(kt,_e){if(_e.has(kt))return _e.get(kt);const Dt=kt.getGraph(),Vt=new Set,Gt=Dt.listParentEdges(kt);for(;Gt.length>0;){const zt=Gt.pop();if(zt.getAttributes().modifyChild===!0)return _e.set(kt,!0),!0;const jt=zt.getChild();if(!Vt.has(jt))for(const Ht of Dt.listChildEdges(jt))Gt.push(Ht)}return _e.set(kt,!1),!1}function we(kt){const _e=kt.getGraph(),Dt=new Set,Vt=new Set;return function Gt(zt){const jt=new Set;for(const Ht of _e.listChildEdges(zt))Ht.getChild()instanceof yt&&jt.add(Ht.getName()+"Info");for(const Ht of _e.listChildEdges(zt)){const Wt=Ht.getChild();Dt.has(Wt)||(Dt.add(Wt),Wt instanceof it&&jt.has(Ht.getName())?Vt.add(Wt):Wt instanceof nt&&Gt(Wt))}}(kt),Array.from(Vt)}const be="prune",Ne={propertyTypes:[h.NODE,h.SKIN,h.MESH,h.CAMERA,h.PRIMITIVE,h.PRIMITIVE_TARGET,h.ANIMATION,h.MATERIAL,h.TEXTURE,h.ACCESSOR,h.BUFFER],keepLeaves:!1,keepAttributes:!0};function Re(kt=Ne){const _e=q({},Ne,kt),Dt=new Set(_e.propertyTypes);return B(be,Vt=>{const Gt=Vt.getLogger(),zt=Vt.getRoot(),jt=Vt.getGraph(),Ht={};if(Dt.has(h.MESH))for(const Yt of zt.listMeshes())Yt.listPrimitives().length>0||(Yt.dispose(),Kt(Yt));if(Dt.has(h.NODE)&&!_e.keepLeaves&&zt.listScenes().forEach(function Yt(Zt){if(Zt.listChildren().forEach(Yt),Zt instanceof mt)return;const Jt=jt.listParentEdges(Zt).some(nn=>{const rn=nn.getParent().propertyType;return rn!==h.ROOT&&rn!==h.SCENE&&rn!==h.NODE});jt.listChildren(Zt).length!==0||Jt||(Zt.dispose(),Kt(Zt))}),Dt.has(h.NODE)&&zt.listNodes().forEach(Wt),Dt.has(h.SKIN)&&zt.listSkins().forEach(Wt),Dt.has(h.MESH)&&zt.listMeshes().forEach(Wt),Dt.has(h.CAMERA)&&zt.listCameras().forEach(Wt),Dt.has(h.PRIMITIVE)&&qt(jt,h.PRIMITIVE),Dt.has(h.PRIMITIVE_TARGET)&&qt(jt,h.PRIMITIVE_TARGET),!_e.keepAttributes&&Dt.has(h.ACCESSOR)){const Yt=new Map;for(const Zt of zt.listMeshes())for(const Jt of Zt.listPrimitives()){const nn=Jt.getMaterial(),rn=Ce(Jt,Oe(Vt,nn));Xt(Jt,rn),Jt.listTargets().forEach(Qt=>Xt(Qt,rn)),nn&&(Yt.has(nn)?Yt.get(nn).add(Jt):Yt.set(nn,new Set([Jt])))}for(const[Zt,Jt]of Yt)$e(Zt,Array.from(Jt))}if(Dt.has(h.ANIMATION))for(const Yt of zt.listAnimations()){for(const Zt of Yt.listChannels())Zt.getTargetNode()||(Zt.dispose(),Kt(Zt));if(Yt.listChannels().length)Yt.listSamplers().forEach(Wt);else{const Zt=Yt.listSamplers();Wt(Yt),Zt.forEach(Wt)}}if(Dt.has(h.MATERIAL)&&zt.listMaterials().forEach(Wt),Dt.has(h.TEXTURE)&&zt.listTextures().forEach(Wt),Dt.has(h.ACCESSOR)&&zt.listAccessors().forEach(Wt),Dt.has(h.BUFFER)&&zt.listBuffers().forEach(Wt),Object.keys(Ht).length){const Yt=Object.keys(Ht).map(Zt=>`${Zt} (${Ht[Zt]})`).join(", ");Gt.info(`${be}: Removed types... ${Yt}`)}else Gt.info(`${be}: No unused properties found.`);function Wt(Yt){Yt.listParents().filter(Zt=>!(Zt instanceof vt||Zt instanceof tt)).length||(Yt.dispose(),Kt(Yt))}function qt(Yt,Zt){Yt.listEdges().map(Jt=>Jt.getParent()).filter(Jt=>Jt.propertyType===Zt).forEach(Wt)}function Xt(Yt,Zt){for(const Jt of Zt)Yt.setAttribute(Jt,null)}function Kt(Yt){Ht[Yt.propertyType]=Ht[Yt.propertyType]||0,Ht[Yt.propertyType]++}Gt.debug(`${be}: Complete.`)})}function Ce(kt,_e){const Dt=[];for(const Vt of kt.listSemantics())Vt!=="TANGENT"||_e.has(Vt)?(Vt.startsWith("TEXCOORD_")&&!_e.has(Vt)||Vt.startsWith("COLOR_")&&Vt!=="COLOR_0")&&Dt.push(Vt):Dt.push(Vt);return Dt}function Oe(kt,_e,Dt=new Set){if(!_e)return Dt;const Vt=kt.getGraph().listChildEdges(_e),Gt=new Set;for(const zt of Vt)zt.getChild()instanceof yt&&Gt.add(zt.getName());for(const zt of Vt){const jt=zt.getName(),Ht=zt.getChild();Ht instanceof it&&Gt.has(jt.replace(/Info$/,""))&&Dt.add(`TEXCOORD_${Ht.getTexCoord()}`),Ht instanceof yt&&jt.match(/normalTexture/i)&&Dt.add("TANGENT"),Ht instanceof nt&&Oe(kt,Ht,Dt)}return Dt}function $e(kt,_e){const Dt=we(kt),Vt=new Set(Dt.map(Wt=>Wt.getTexCoord())),Gt=Array.from(Vt).sort(),zt=new Map(Gt.map((Wt,qt)=>[Wt,qt])),jt=new Map(Gt.map((Wt,qt)=>[`TEXCOORD_${Wt}`,`TEXCOORD_${qt}`]));for(const Wt of Dt){const qt=Wt.getTexCoord();Wt.setTexCoord(zt.get(qt))}for(const Wt of _e){const qt=Wt.listSemantics().filter(Xt=>Xt.startsWith("TEXCOORD_")).sort();Ht(Wt,qt),Wt.listTargets().forEach(Xt=>Ht(Xt,qt))}function Ht(Wt,qt){for(const Xt of qt){const Kt=Wt.getAttribute(Xt);if(!Kt)continue;const Yt=jt.get(Xt);Yt!==Xt&&(Wt.setAttribute(Yt,Kt),Wt.setAttribute(Xt,null))}}}tt.TargetPath;var Vn;function Xn(kt,_e,Dt){for(let Vt=0,Gt=Dt.length;Vt<Gt;Vt++)Dt[Vt]=kt[_e*Gt+Vt];return Dt}function Kn(kt,_e,Dt){for(let Vt=0,Gt=Dt.length;Vt<Gt;Vt++)kt[_e*Gt+Vt]=Dt[Vt]}function Jn(kt,_e,Dt=0){if(kt.length!==_e.length)return!1;for(let Vt=0;Vt<kt.length;Vt++)if(Math.abs(kt[Vt]-_e[Vt])>Dt)return!1;return!0}function Zn(kt,_e,Dt){return kt*(1-Dt)+_e*Dt}function Qn(kt,_e,Dt,Vt){for(let Gt=0;Gt<_e.length;Gt++)kt[Gt]=Zn(_e[Gt],Dt[Gt],Vt);return kt}function Yn(kt,_e,Dt,Vt){let Gt,zt,jt,Ht,Wt,qt=_e[0],Xt=_e[1],Kt=_e[2],Yt=_e[3],Zt=Dt[0],Jt=Dt[1],nn=Dt[2],rn=Dt[3];return zt=qt*Zt+Xt*Jt+Kt*nn+Yt*rn,zt<0&&(zt=-zt,Zt=-Zt,Jt=-Jt,nn=-nn,rn=-rn),1-zt>1e-6?(Gt=Math.acos(zt),jt=Math.sin(Gt),Ht=Math.sin((1-Vt)*Gt)/jt,Wt=Math.sin(Vt*Gt)/jt):(Ht=1-Vt,Wt=Vt),kt[0]=Ht*qt+Wt*Zt,kt[1]=Ht*Xt+Wt*Jt,kt[2]=Ht*Kt+Wt*nn,kt[3]=Ht*Yt+Wt*rn,kt}function eo(kt,_e){const Dt=function(Vt,Gt){return Vt[0]*Gt[0]+Vt[1]*Gt[1]+Vt[2]*Gt[2]+Vt[3]*Gt[3]}(kt,_e);return Math.acos(2*Dt*Dt-1)}(function(kt){kt[kt.STEP=0]="STEP",kt[kt.LERP=1]="LERP",kt[kt.SLERP=2]="SLERP"})(Vn||(Vn={}));Promise.resolve();var yo;(function(kt){kt.LANCZOS3="lanczos3",kt.LANCZOS2="lanczos2"})(yo||(yo={}));yo.LANCZOS3;yo.LANCZOS3;async function getCurrentScene(kt){return kt.coreSceneStore.getState().sceneRef}function calculateSceneCenter(kt){const _e=new Box3().setFromObject(kt),Dt=new Vector3;return _e.getCenter(Dt),Dt.y=_e.min.y,Dt}function getItemsGroupFromScene(kt){return kt.getObjectByName("#ITEMS")}function filterOnlyItems(kt){return getItemsGroupFromScene(kt).children}async function getSceneAsUsdzUrl(kt){kt.coreSceneStore.setState({frameLoop:"never"}),await wait(1e3);try{const _e=new USDZExporter,Dt=await getCurrentScene(kt),Vt=calculateSceneCenter(Dt);Dt.position.sub(Vt);const Gt=Dt.rotation.clone(),zt=kt.coreSceneStore.getState().sceneSettings.arTransforms.rotation;Dt.rotation.set(MathUtils.degToRad(zt[0]),MathUtils.degToRad(zt[1]),MathUtils.degToRad(zt[2])),Dt.updateMatrixWorld();const jt=kt.coreSceneStore.getState().sceneSettings.usdzPrecision,Ht=kt.coreSceneStore.getState().sceneSettings.usdzMaxTextureSize,Wt=await _e.parseAsync(Dt,jt,Ht),qt=new Blob([Wt],{type:"model/vnd.usdz+zip"}),Xt=URL.createObjectURL(qt);return Dt.position.add(Vt),Dt.rotation.set(Gt.x,Gt.y,Gt.z),kt.coreSceneStore.setState({frameLoop:"always"}),Xt}catch(_e){return LOGGER.error("Error exporting USDZ: "+_e),kt.coreSceneStore.setState({frameLoop:"always"}),null}}async function getSceneAsGLBUrl(kt){kt.coreSceneStore.setState({frameLoop:"never"}),await wait(1e3);try{const _e=new _t,Dt=new GLTFExporter,Vt=await getCurrentScene(kt),Gt=filterOnlyItems(Vt),zt=calculateSceneCenter(Vt);for(const Yt of Gt)Yt.position.sub(zt);const jt={binary:!0,forceIndices:!0,trs:!1,onlyVisible:!0,embedImages:!0,maxTextureSize:1024},Ht=await Dt.parseAsync(Gt,jt),Wt=await _e.readBinary(new Uint8Array(Ht));for(const Yt of Gt)Yt.position.add(zt);const qt=await optimiseGlb(Wt),Xt=await _e.writeBinary(qt),Kt=await saveArrayBufferAsURL(Xt);return kt.coreSceneStore.setState({frameLoop:"always"}),Kt}catch(_e){return LOGGER.error({title:"Error exporting GLB: "+_e}),kt.coreSceneStore.setState({frameLoop:"always"}),null}}async function optimiseGlb(kt){const Dt=kt.getRoot().listNodes();for(const Vt of Dt){Vt.setExtras({});const Gt=Vt.getName();(Gt==="GRP_ProxyMesh"||Gt==="GRP_LoadingPlaceholder")&&Vt.dispose()}return await kt.transform(Ee(),Re()),LOGGER.info({title:"GLB as json"}),LOGGER.info({title:kt.getRoot().listTextures()}),kt}async function saveArrayBufferAsURL(kt){const _e=new Blob([kt],{type:"application/gltf-buffer"});return LOGGER.info({title:"Approx scene GLB size: "+_e.size/1e6}),URL.createObjectURL(_e)}const byteToHex=[];for(let kt=0;kt<256;++kt)byteToHex.push((kt+256).toString(16).slice(1));function unsafeStringify(kt,_e=0){return(byteToHex[kt[_e+0]]+byteToHex[kt[_e+1]]+byteToHex[kt[_e+2]]+byteToHex[kt[_e+3]]+"-"+byteToHex[kt[_e+4]]+byteToHex[kt[_e+5]]+"-"+byteToHex[kt[_e+6]]+byteToHex[kt[_e+7]]+"-"+byteToHex[kt[_e+8]]+byteToHex[kt[_e+9]]+"-"+byteToHex[kt[_e+10]]+byteToHex[kt[_e+11]]+byteToHex[kt[_e+12]]+byteToHex[kt[_e+13]]+byteToHex[kt[_e+14]]+byteToHex[kt[_e+15]]).toLowerCase()}let getRandomValues;const rnds8=new Uint8Array(16);function rng(){if(!getRandomValues){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");getRandomValues=crypto.getRandomValues.bind(crypto)}return getRandomValues(rnds8)}const randomUUID=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),native={randomUUID};function v4(kt,_e,Dt){if(native.randomUUID&&!_e&&!kt)return native.randomUUID();kt=kt||{};const Vt=kt.random??kt.rng?.()??rng();if(Vt.length<16)throw new Error("Random bytes length must be >= 16");if(Vt[6]=Vt[6]&15|64,Vt[8]=Vt[8]&63|128,_e){if(Dt=Dt||0,Dt<0||Dt+16>_e.length)throw new RangeError(`UUID byte range ${Dt}:${Dt+15} is out of buffer bounds`);for(let Gt=0;Gt<16;++Gt)_e[Dt+Gt]=Vt[Gt];return _e}return unsafeStringify(Vt)}class Plug{constructor(_e,Dt,Vt=null){this.stores=Dt.stores,this._attachedPlug=null,this._name=_e.name,this._acceptedPlugTypes=_e.acceptedPlugTypes,this._affectedNodes=_e.affectedNodes,this._unvisualizedCount=_e.unvisualizedCount,this._weight=_e.weight,this._connectsToPlugTypes=_e.connectsToPlugTypes,this._dependencySku=_e.dependencySku,this._isDependencySkuInteractive=_e.isDependencySkuInteractive,this._autoSpawnDependencyIfMissing=_e.autoSpawnDependencyIfMissing,this._node=Dt,Vt?(this._comboPlugConnector=Vt.comboPlugConnector,this._guid=Vt.guid,this._isOpen=Vt.isOpen,this._type=Vt.type,this._isReceiverPlug=Vt.isReceiverPlug,this._attachedPlugGUID=Vt.attachedPlugGUID):(this._comboPlugConnector=!1,this._guid=v4(),this._isOpen=!0,this._type=_e.type,this._isReceiverPlug=!1,this._attachedPlugGUID=null)}export(){return this.isOpen?null:{guid:this._guid,type:this._type,isOpen:this._isOpen,comboPlugConnector:this._comboPlugConnector,attachedPlugGUID:this._attachedPlugGUID,isReceiverPlug:this._isReceiverPlug}}get node(){return this._node}set comboPlugConnector(_e){this._comboPlugConnector=_e}get comboPlugConnector(){return this._comboPlugConnector}get attachedPlug(){return this._attachedPlug}set attachedPlug(_e){this._attachedPlug=_e}get attachedNode(){return this._attachedPlug?this._attachedPlug.node:null}get attachedPlugGUID(){return this._attachedPlugGUID}set type(_e){this._type=_e}get type(){return this._type}get weight(){return this._weight}get unvisualizedCount(){return this.__unvisualizedCount}get affectedNodes(){return this._affectedNodes}get guid(){return this._guid}get isReceiverPlug(){return this._isReceiverPlug}get name(){return this._name}get acceptedPlugTypes(){return this._acceptedPlugTypes}set acceptedPlugTypes(_e){this._acceptedPlugTypes=_e}get connectsToPlugTypes(){return this._connectsToPlugTypes}set connectsToPlugTypes(_e){this._connectsToPlugTypes=_e}get isOpen(){return this._isOpen}get isOccupied(){return!this.isOpen}get dependencySku(){return this._dependencySku}get isDependencySkuInteractive(){return this._isDependencySkuInteractive}attachPlug(_e,Dt=!1){this._attachedPlug=_e,this._attachedPlugGUID=_e.guid,this._isOpen=!1,this._isReceiverPlug=Dt;const Vt=this,Gt=this._node;if(Gt.isConnectedToRoot&&Dt){const zt=Gt.whichPlugAreWeAttachedUsing();switch(_e.type){case"weighted_hider":zt.weight<Vt.weight&&(Gt.showNodes(zt.affectedNodes)||this.stores.coreSceneStore.getState().CORE_API.coreWCRef.addEventListener(Gt.guid+":modelLoaded",function(){Gt.showNodes(zt.affectedNodes)},{once:!0}));break}}if(Dt&&_e.type!==""&&_e.type==Vt._type)switch(_e.type){default:case"weighted_hider":Vt._weight>_e.weight?_e.node.hideNodes(_e.affectedNodes)||this.stores.coreSceneStore.getState().CORE_API.coreWCRef.addEventListener(_e.node.guid+":modelLoaded",function(){_e.node.hideNodes(_e.affectedNodes)},{once:!0}):Vt._weight<_e.weight&&(Gt.hideNodes(Vt._affectedNodes)||this.stores.coreSceneStore.getState().CORE_API.coreWCRef.addEventListener(Gt.guid+":modelLoaded",function(){Gt.hideNodes(Vt._affectedNodes)},{once:!0}));break}Dt&&(Gt.isEndNode=!1)}async openPlug(){if(this._comboPlugConnector&&(this._comboPlugConnector=!1),this._node.isConnectedToRoot){const _e=this._node.whichPlugAreWeAttachedUsing();if(_e&&this._guid!==_e.guid)switch(this.type){case"weighted_hider":_e.type==="weighted_hider"&&_e.weight<this.weight&&this._node.hideNodes(_e.affectedNodes);break}}if(this._isReceiverPlug&&this._attachedPlug.type!==""&&this._attachedPlug.type==this._type)switch(this._attachedPlug.type){default:case"weighted_hider":this._weight>this._attachedPlug.weight?this._attachedPlug.node.showNodes(this._attachedPlug.affectedNodes):this._weight<this._attachedPlug.weight&&this._node.showNodes(this._affectedNodes);break}if(this._attachedPlug=null,this._attachedPlugGUID=null,this._isOpen=!0,this._isReceiverPlug&&(this._isReceiverPlug=!1,this._node.checkIfEndNode()),!!this._dependencySku&&!(this._autoSpawnDependencyIfMissing==!1||this._isDependencySkuInteractive||this.stores.coreSceneStore.getState().configurationLoaded===!1))try{const _e=await this.stores.ghostStore.getState().actions.spawnGhostsForSkuID(this._dependencySku,!0);if(!_e)return;const Dt=_e.connectablePlugs;let Vt=!1;const Gt=this._isDependencySkuInteractive?this.isDependencySkuInteractive===1:!1;for(const zt of Dt){if(zt.receiverPlug.guid!==this._guid)continue;Vt=!0;const jt=await this.stores.itemStore.getState().actions.addItemBySkuID(this._dependencySku,Dt.indexOf(zt),!0,Gt);jt!==null&&this._node.addMyDependenciesGUID(jt)}Vt||await this.stores.ghostStore.getState().actions.clearAllGhosts()}catch{LOGGER.info({title:"The Plug has been removed!"})}}canAttachToPlug(_e){for(let Dt=0;Dt<this._connectsToPlugTypes.length;Dt++)if(_e._acceptedPlugTypes.includes(this._connectsToPlugTypes[Dt]))return!0;return!1}}let Node$1=class{#t="default";#i=!1;#n=!1;#s=!0;#r={};#c=!1;#o=[];constructor(_e,Dt,Vt=null,Gt,zt){this.stores=_e;let jt=_e.productDataStore.getState().productData;this._plugs=[],this._skuID=Dt,this._ref=null,this._dragging=!1,this._modelFunctions=null,this._transform=null,this.#t="default",this._overrideVariant=null,this._followsParent=jt[Dt].followsParent,this._categoryID=jt[Dt].categoryID,this._replace=jt[Dt].replace,this._swappable=jt[Dt].swappable,this._price=this.#l(),this._compareAtPrice=this.#a(),this.#i=jt[Dt]?.ignoreInCart,Vt?(this._guid=Vt.guid,this._isEndNode=Vt.isEndNode,this._overrideVariant=Vt.overrideVariant,this.generatePlugsWithData(Dt,Vt.plugs)):(this._guid=v4(),this._isEndNode=!0,this.generatePlugsForNode(Dt)),Gt&&Object.keys(Gt).map(Ht=>{if(jt[Dt].looks&&jt[Dt].looks.includes(Ht)){this.#t=Ht;return}})}get isRoot(){return this._skuID.toLowerCase()==="root"}updateGeometryVariant(_e,Dt){const Gt=this.stores.productDataStore.getState().categoryData.geometryVariants;let zt=null;if(Gt.map(Xt=>{Xt.id==_e&&(zt=Xt)}),!zt)return;const jt=zt.productsInCategory,Wt=zt.variants[Dt].productsToSwitch,qt=this.stores.itemStore.getState().itemsSpawned;jt.map(Xt=>{Xt.products.map(Kt=>{this.skuID===Kt&&Xt.products.map(Yt=>{Wt.map(Zt=>{if(Zt==Yt){const Jt=this.stores.productDataStore.getState().actions.getProductDataById(Zt);this.skuID=Jt.skuID;const nn=qt[this.guid];nn&&nn.itemData&&Object.keys(Jt).map(rn=>{nn.itemData[rn]=Jt[rn]}),this.hideNodes(Jt.geometriesToHide),this.showNodes(Jt.geometriesToShow),this.updatePricing(),this.resetInStock(),this.stores.inventoryStore.getState().actions.refreshInventory(qt)}})})})})}resetInStock(){this.#r={},this.#c=!0}setInStockForRef(_e){if(!this.ref)return!1;let Dt=this.ref.getObjectByName("GRP_RenderGeometry");return Dt?(Dt.inStock=_e,!0):!1}set inStock({variantName:_e,newValue:Dt}){if(this.#r[_e]&&this.#r[_e]==Dt||(this.#r[_e]=Dt,_e!==this.currentVariant&&this.#c===!1))return;const Vt=()=>{this.setInStockForRef(Dt)};Vt()||this.stores.coreSceneStore.getState().CORE_API.coreWCRef.addEventListener(this.guid+":modelLoaded",Vt,{once:!0})}get myDependenciesGUID(){return this.#o}set myDependenciesGUID(_e){this.#o=_e}get dragging(){return this._dragging}set dragging(_e){this._dragging=_e}addMyDependenciesGUID(_e){this.#o.push(_e)}get isDependent(){return this.#n}set isDependent(_e){this.#n=_e}get isInteractive(){return this.#s}set isInteractive(_e){this.#s=_e}update(_e){this._skuID=_e;const Dt=this.stores.productDataStore.getState().productData,Vt=Dt[_e]?.plugs;if(this.ignoreInCart=Dt[_e].ignoreInCart,!!Vt)for(let Gt=0;Gt<this._plugs.length;Gt++)for(let zt=0;zt<Vt.length;zt++)this._plugs[Gt].name==Vt[zt].name&&(this._plugs[Gt].acceptedPlugTypes=Vt[zt].acceptedPlugTypes,this._plugs[Gt].connectsToPlugTypes=Vt[zt].connectsToPlugTypes)}export(){let _e={};for(let Dt=0;Dt<this._plugs.length;Dt++){let Vt=this._plugs[Dt].export();Vt&&(_e[this._plugs[Dt].name]=Vt)}return{skuID:this._skuID,guid:this._guid,isEndNode:this._isEndNode,plugs:_e,overrideVariant:this._overrideVariant}}get node(){return this}get swappable(){return this._swappable}get replace(){return this._replace}get ignoreInCart(){return this.#i}set ignoreInCart(_e){this.#i=_e}get isTypeCombo(){const _e=this.whichPlugAreWeAttachedUsing();return _e.type=="comboPlug"&&_e.connectsToPlugTypes.length>0}get canRotate(){let _e=!0;if(this.isTypeCombo)return!1;if(!this._isEndNode){const Vt=this.whichNodesAreAttachedToUs();if(Vt.length>0){let Gt=!0;if(Vt.map(zt=>{zt.followsParent===!1&&(Gt=!1)}),!Gt)return!1}}let Dt=!1;for(let Vt=0;Vt<this.plugs.length;Vt++)if(!this.plugs[Vt].isOpen&&this.plugs[Vt].attachedPlug.isReceiverPlug){const Gt=this.plugs[Vt].attachedPlug.acceptedPlugTypes;for(let zt=0;zt<this.plugs.length;zt++)if(Vt!=zt)for(let jt=0;jt<this.plugs[zt].connectsToPlugTypes.length;jt++)Gt.includes(this.plugs[zt].connectsToPlugTypes[jt])&&(Dt=!0)}return _e=Dt,_e}hideNodes(_e){if(!this.ref)return!1;const Dt=this.ref.getObjectByName("GRP_RenderGeometry"),Vt=this.ref.getObjectByName("GRP_ProxyMesh");return _e.map(Gt=>{if(Dt){const zt=Dt.getObjectByName(Gt);zt&&(zt.visible=!1)}if(Vt){const zt=Vt.getObjectByName(Gt);zt&&(zt.visible=!1)}}),!0}showNodes(_e){if(!this.ref)return!1;const Dt=this.ref.getObjectByName("GRP_RenderGeometry"),Vt=this.ref.getObjectByName("GRP_ProxyMesh");return _e.map(Gt=>{if(Dt){const zt=Dt.getObjectByName(Gt);zt&&(zt.visible=!0)}if(Vt){const zt=Vt.getObjectByName(Gt);zt&&(zt.visible=!0)}}),!0}canConnectToPlugType(_e){let Dt=!1;return this._plugs.map(Vt=>{Vt.connectsToPlugTypes.map(Gt=>{Gt==_e&&(Dt=!0)})}),Dt}isConnectedToSkuID(_e){let Dt=!1;return this._plugs.map(Vt=>{if(Vt.isOpen||Dt===!0)return;let Gt=Vt.attachedPlug;!Gt&&Vt.attachedPlugGUID&&(Gt=this.stores.attachmentStore.getState().attachmentSystem.currentStructure.getPlugByGUID(Vt.attachedPlugGUID)),Gt.node.skuID==_e&&(Dt=!0)}),Dt}get isConnectedToRoot(){return this.isConnectedToSkuID("Root")}swapRoot(){if(!this.canSwapRoot)return;const Dt=this.stores.attachmentStore.getState().attachmentSystem.currentStructure,Vt=this.whichNodesAreAttachedToUs();let Gt=null;Vt.map(qt=>{qt.followsParent===!1&&(Gt=qt)});const zt=Gt.detachNodeFromReceiver();let jt=null;this._plugs.map(qt=>{qt.isOpen||qt.attachedPlug.node.skuID=="Root"&&(jt=qt.attachedPlug)});const Ht=this.detachNodeFromReceiver();let Wt=null;return Gt.plugs.map(qt=>{qt.connectsToPlugTypes.includes("root")&&(Wt=qt)}),Dt.connectPlugs({incomingPlug:Wt,receiverPlug:jt}),{neighborDetachedPlugs:zt,rootDetachedPlugs:Ht,neighborNode:Gt}}get canSwapRoot(){if(this.stores.coreSceneStore.getState().sceneSettings.swappableRoot===!1)return!1;let _e=!1;if(this.isConnectedToRoot&&!this._isEndNode){const Vt=this.whichNodesAreAttachedToUs();let Gt=0,zt=null;Vt.map(jt=>{jt.followsParent===!1&&(Gt++,zt=jt)}),Gt==1?zt.canConnectToPlugType("root")&&(_e=!0):Gt>0&&(_e=!1)}return _e}get canRemove(){let _e=!0;return this._isEndNode||(this.whichNodesAreAttachedToUs().map(Vt=>{Vt.followsParent===!1&&(_e=!1)}),_e||(_e=this.canSwapRoot)),_e}getComboPlugNodesAttachedToUs(){let _e=[];return this.whichNodesAreAttachedToUs().forEach(Vt=>{Vt.isTypeCombo&&_e.push(Vt);const Gt=Vt.getComboPlugNodesAttachedToUs();Gt.length>0&&(_e=_e.concat(Gt))}),_e}getAllBranchedNodesAttachedToUs(){let _e=[];const Dt=this.whichNodesAreAttachedToUs();for(let Vt=0;Vt<Dt.length;Vt++){_e.push(Dt[Vt]);const Gt=Dt[Vt].getAllBranchedNodesAttachedToUs();Gt.length>0&&(_e=_e.concat(Gt))}return _e}get canDrag(){let _e=!0;if(this.isTypeCombo)return!1;for(let Vt=0;Vt<this._plugs.length;Vt++)if(this._plugs[Vt].isOpen==!1&&this._plugs[Vt].attachedPlug.type=="comboPlug")return!1;const Dt=this.getComboPlugNodesAttachedToUs();if(Dt.length>0){const Vt=this.getAllBranchedNodesAttachedToUs();let Gt=!0;if(Dt.map(zt=>{const jt=zt.whichNodesIsThisComboPlugAttachedTo();let Ht=!0;if(jt.map(Wt=>{let qt=!1;if(Vt.map(Xt=>{Wt.guid===Xt.guid&&(qt=!0)}),qt==!1){Ht=!1;return}}),Ht==!1){Gt=!1;return}}),Gt==!1)return!1}return this._isEndNode||(this.whichNodesAreAttachedToUs().map(Gt=>{Gt.followsParent===!1&&(_e=!1)}),_e||(_e=this.canSwapRoot)),_e}get followsParent(){return this._followsParent}set followsParent(_e){this._followsParent=_e}resetFollowsParent(){const _e=this.stores.productDataStore.getState().productData;this._followsParent=_e[this.skuID].followsParent}get currentVariant(){return this.#t==="default"?this.stores.productDataStore.getState().actions.getProductDataById(this._skuID).lookDetails.default.id:this.#t}get price(){return this._price}set price(_e){this._price=_e}get compareAtPrice(){return this._compareAtPrice}set compareAtPrice(_e){this._compareAtPrice=_e}updateCompareAtPricing(){this._compareAtPrice=this.#a()}updatePricing(){this._price=this.#l()}#a(){let Dt=this.stores.productDataStore.getState().actions.getProductDataById(this._skuID).lookDetails[this.#t]?.compareAtPrice;return Dt||(Dt=0),Dt}#l(){let Dt=this.stores.productDataStore.getState().actions.getProductDataById(this._skuID).lookDetails[this.#t]?.price;return Dt||(Dt=0),Dt}set currentVariant(_e){this.#t=_e,this._price=this.#l(),this._compareAtPrice=this.#a()}get overrideVariant(){return this._overrideVariant}set overrideVariant(_e){this._overrideVariant=_e,this.#t=this._overrideVariant,this._price=this.#l(),this._compareAtPrice=this.#a()}get guid(){return this._guid}get skuID(){return this._skuID}set skuID(_e){this._skuID=_e}get plugs(){return this._plugs}get ref(){return this._ref}set ref(_e){this._ref=_e}get modelFunctions(){return this._modelFunctions}set modelFunctions(_e){this._modelFunctions=_e}checkGeometryVariant(){let _e=new CustomEvent(this._guid+":modelLoaded",{bubbles:!0,cancelable:!1,composed:!0});const Dt=this.stores.attachmentStore.getState().attachmentSystem;Dt.globalGeometryVariants&&Object.keys(Dt.globalGeometryVariants).map(Vt=>{this.updateGeometryVariant(Vt,Dt.globalGeometryVariants[Vt])}),_e.data={},this.stores.coreSceneStore.getState().CORE_API.coreWCRef?this.stores.coreSceneStore.getState().CORE_API.coreWCRef.dispatchEvent(_e):LOGGER.warn({title:"core web component not found!"})}get isEndNode(){return this._isEndNode}set isEndNode(_e){this._isEndNode=_e}get categoryID(){return this._categoryID}get transform(){return this._transform}set transform(_e){this._transform=_e}setModelVisibility(_e){_e?this._ref?.scale.set(1,1,1):this._ref.scale.set(0,0,0)}checkIfEndNode(){let _e=!0;for(let Dt=0;Dt<this._plugs.length;Dt++)this._plugs[Dt].isReceiverPlug&&(_e=!1);this.isEndNode=_e}whichNodesAreAttachedToUs(){const _e=[];for(let Dt=0;Dt<this._plugs.length;Dt++)this._plugs[Dt].isReceiverPlug&&_e.push(this._plugs[Dt].attachedPlug.node);return _e}whichPlugsAreAttachedToUs(){const _e=[];for(let Dt=0;Dt<this._plugs.length;Dt++)this._plugs[Dt].isReceiverPlug&&_e.push({receiverPlug:this._plugs[Dt],incomingPlug:this._plugs[Dt].attachedPlug});return _e}whichNodeAreWeAttachedTo(){let _e=null;for(const Dt of this._plugs)Dt?.attachedPlug?.isReceiverPlug&&(_e=Dt.attachedPlug.node);return _e}whichNodesIsThisComboPlugAttachedTo(){if(!this.isTypeCombo)return[];let _e=[];for(const Dt of this._plugs)Dt?.attachedPlug?.isReceiverPlug&&_e.push(Dt.attachedPlug.node);return _e}isReplaceableWithSkuIdOld(_e){const Vt=this.stores.productDataStore.getState().productData[_e]?.plugs;let Gt=0;if(!Vt)return!1;for(let zt=0;zt<this._plugs.length;zt++)for(let jt=0;jt<Vt.length;jt++)this._plugs[zt].name==Vt[jt].name&&Gt++;return Gt==this._plugs.length}isReplaceableWithSkuId(_e){const Vt=this.stores.productDataStore.getState().productData[_e]?.plugs;if(!Vt)return LOGGER.warn({title:`The new sku ${_e} is invalid for this experience to replace this node: `,details:this}),!1;let Gt=!1,zt=!0;const jt=this.whichPlugAreWeAttachedTo();for(const Wt of Vt)if(Gt=hasCommonElement(jt.acceptedPlugTypes,Wt.connectsToPlugTypes),Gt===!0)break;const Ht=this.whichPlugsAreAttachedToUs();for(const Wt of Ht)for(const qt of Vt)if(zt=hasCommonElement(qt.acceptedPlugTypes,Wt.connectsToPlugTypes),zt===!1)break;return Gt&&zt}getAllSkusThatCanReplaceMe(){let _e=[];const Dt=this.stores.productDataStore.getState().productData;return Object.keys(Dt).map(Vt=>{Vt!=this.skuID&&this.isReplaceableWithSkuId(Vt)&&_e.push(Vt)}),_e}whichPlugAreWeAttachedUsing(){for(let _e=0;_e<this._plugs.length;_e++){const Dt=this._plugs[_e];let Vt=Dt.attachedPlug;if(!Vt&&Dt.attachedPlugGUID&&(Vt=this.stores.attachmentStore.getState().attachmentSystem.currentStructure.getPlugByGUID(Dt.attachedPlugGUID)),!Dt.isOpen&&Vt.isReceiverPlug)return Dt}}whichPlugAreWeAttachedTo(){for(let _e=0;_e<this._plugs.length;_e++)if(!this._plugs[_e].isOpen&&this._plugs[_e].attachedPlug.isReceiverPlug)return this._plugs[_e].attachedPlug}getPlugWhichCanConnectToType(_e){for(const Dt of this._plugs)if(Dt.connectsToPlugTypes.includes(_e))return Dt;return null}getOpenPlugsWeCanAttachFrom(){let _e=[];if(this.whichNodeAreWeAttachedTo())return _e;for(let Dt=0;Dt<this._plugs.length;Dt++)this.plugs[Dt].isOpen&&this.plugs[Dt].connectsToPlugTypes.length>0&&_e.push(this._plugs[Dt]);return _e}getOpenPlugsFromNode(){let _e=[];for(let Dt=0;Dt<this._plugs.length;Dt++)this._plugs[Dt].isOpen&&this._plugs[Dt].acceptedPlugTypes.length>0&&_e.push(this._plugs[Dt]);return _e}generatePlugsForNode(_e){this._plugs=[];let Dt=this.stores.productDataStore.getState().productData[_e]?.plugs;if(Dt)for(let Vt=0;Vt<Dt.length;Vt++)if(Dt[Vt].type==="unvisualizedPlug"){const Gt=Dt[Vt]?.unvisualizedCount>=0?Dt[Vt].unvisualizedCount:1e3;for(let zt=0;zt<Gt;zt++){const jt=new Plug({...Dt[Vt],name:`${Dt[Vt].name}_${zt}`},this);this._plugs.push(jt)}}else{const Gt=new Plug(Dt[Vt],this);this._plugs.push(Gt)}}generatePlugsWithData(_e,Dt){const Vt=this.stores.productDataStore.getState().productData[_e]?.plugs;Vt&&Vt.forEach(Gt=>{if(Gt.type==="unvisualizedPlug"){const zt=Gt.unvisualizedCount&&Gt.unvisualizedCount>=0?Gt.unvisualizedCount:1e3;for(let jt=0;jt<zt;jt++){const Ht=new Plug({...Gt,name:`${Gt.name}_${jt}`},this,Dt[`${Gt.name}_${jt}`]);this._plugs.push(Ht)}}else{const zt=new Plug(Gt,this,Dt[Gt.name]);this._plugs.push(zt)}})}detachNodeFromReceiver(){for(let _e=0;_e<this.plugs.length;_e++)if(!this.plugs[_e].isOpen&&this.plugs[_e].attachedPlug.isReceiverPlug){const Dt={incomingPlug:this.plugs[_e],receiverPlug:this.plugs[_e].attachedPlug};return this.plugs[_e].attachedPlug.openPlug(),this.plugs[_e].openPlug(),Dt}}detachNodeCompletely(){for(let _e=0;_e<this._plugs.length;_e++)this._plugs[_e].isOpen||(this._plugs[_e].attachedPlug.openPlug(),this._plugs[_e].openPlug())}getPlugByName(_e){for(let Dt=0;Dt<this._plugs.length;Dt++)if(this._plugs[Dt].name==_e)return this._plugs[Dt];return null}getPlugByGUID(_e){for(let Dt=0;Dt<this._plugs.length;Dt++)if(this._plugs[Dt].guid==_e)return this._plugs[Dt];return null}async removeNode(){const _e=[];for(const Dt of this._plugs)if(!Dt.isOpen){if(Dt.type==="comboPlug"&&Dt.connectsToPlugTypes.length>0){Dt.attachedPlug.openPlug();continue}Dt.attachedPlug.isReceiverPlug?Dt.attachedPlug.openPlug():_e.push(Dt.attachedPlug.node.guid)}if(_e.length>0)for(const Dt of _e)this.stores.itemStore.getState().actions.addToRemoveItems(Dt);this.modelFunctions=null,this.ref=null}};const EPIGRAPH_CONFIGURATOR_CATEGORY="Epigraph - Configurator",CONFIGURATOR_LOADING={type:"event",category:EPIGRAPH_CONFIGURATOR_CATEGORY,action:"configuratorLoading",label:"",interaction:{nonInteraction:!0}},CONFIGURATOR_READY={type:"event",category:EPIGRAPH_CONFIGURATOR_CATEGORY,action:"configuratorReady",label:"",interaction:{nonInteraction:!0}},CONFIGURATOR_FAILED={type:"event",category:EPIGRAPH_CONFIGURATOR_CATEGORY,action:"configuratorFailed",label:"",interaction:{nonInteraction:!0}},CONFIGURATOR_REVIEW_CART_SHOWN={type:"event",category:EPIGRAPH_CONFIGURATOR_CATEGORY,action:"configuratorReviewCartShown",label:"",interaction:{nonInteraction:!1}},CONFIGURATOR_REVIEW_CART_HIDE={type:"event",category:EPIGRAPH_CONFIGURATOR_CATEGORY,action:"configuratorReviewCartHide",label:"",interaction:{nonInteraction:!1}},CONFIGURATOR_CHECKOUT={type:"event",category:EPIGRAPH_CONFIGURATOR_CATEGORY,action:"configuratorCheckout",label:"",interaction:{nonInteraction:!1}},CONFIGURATOR_CHECKOUT_ITEM={type:"event",category:EPIGRAPH_CONFIGURATOR_CATEGORY,action:"configuratorCheckoutItemDetails",label:"",interaction:{nonInteraction:!1}},CONFIGURATOR_GLOBAL_GEOMETRY_VARIANT_SWITCHED={type:"event",category:EPIGRAPH_CONFIGURATOR_CATEGORY,action:"configuratorGlobalGeometryVariantSwitched",label:"",interaction:{nonInteraction:!1}},CONFIGURATOR_GLOBAL_VARIANT_SWITCHED={type:"event",category:EPIGRAPH_CONFIGURATOR_CATEGORY,action:"configuratorGlobalVariantSwitched",label:"",interaction:{nonInteraction:!1}},CONFIGURATOR_LOCAL_VARIANT_SWITCHED={type:"event",category:EPIGRAPH_CONFIGURATOR_CATEGORY,action:"configuratorLocalVariantSwitched",label:"",interaction:{nonInteraction:!1}},CONFIGURATOR_LOAD_FROM_PRECONFIG={type:"event",category:EPIGRAPH_CONFIGURATOR_CATEGORY,action:"configuratorLoadFromPreConfiguration",label:"",interaction:{nonInteraction:!0}},CONFIGURATOR_PRECONFIGURATION_ITEM_ADDED={type:"event",category:EPIGRAPH_CONFIGURATOR_CATEGORY,action:"preconfigurationItemAdded",label:"",interaction:{nonInteraction:!0}},CONFIGURATOR_SCENE_RESTARTED={type:"event",category:EPIGRAPH_CONFIGURATOR_CATEGORY,action:"configuratorSceneRestarted",label:"",interaction:{nonInteraction:!1}},CONFIGURATOR_AR_REQUESTED={type:"event",category:EPIGRAPH_CONFIGURATOR_CATEGORY,action:"configuratorArRequested",label:"",interaction:{nonInteraction:!1}},CONFIGURATOR_ITEM_REMOVED={type:"event",category:EPIGRAPH_CONFIGURATOR_CATEGORY,action:"configuratorItemRemoved",label:"",interaction:{nonInteraction:!1}},CONFIGURATOR_ITEM_ADDED={type:"event",category:EPIGRAPH_CONFIGURATOR_CATEGORY,action:"configuratorItemAdded",label:"",interaction:{nonInteraction:!1}},CONFIGURATOR_INSTRUCTIONS_BTN_CLICKED={type:"event",category:EPIGRAPH_CONFIGURATOR_CATEGORY,action:"configuratorInstructionsBtnClicked",label:"",interaction:{nonInteraction:!1}},CONFIGURATOR_INSTRUCTIONS_COMPLETION_RATE={type:"event",category:EPIGRAPH_CONFIGURATOR_CATEGORY,action:"configuratorInstructionsStageCompletionRate",label:"",interaction:{nonInteraction:!1}},CONFIGURATOR_INSTRUCTIONS_SHOWN={type:"event",category:EPIGRAPH_CONFIGURATOR_CATEGORY,action:"configuratorInstructionsShow",label:"",interaction:{nonInteraction:!1}},CONFIGURATOR_DIMENSION_SHOWN={type:"event",category:EPIGRAPH_CONFIGURATOR_CATEGORY,action:"configuratorDimensionsBtnShow",label:"",interaction:{nonInteraction:!1}},CONFIGURATOR_DIMENSION_HIDE={type:"event",category:EPIGRAPH_CONFIGURATOR_CATEGORY,action:"configuratorDimensionsBtnHide",label:"",interaction:{nonInteraction:!1}},CONFIGURATOR_HOTSPOT_ENTER={type:"event",category:EPIGRAPH_CONFIGURATOR_CATEGORY,action:"configuratorHotspotEnter",label:"",interaction:{nonInteraction:!1}},CONFIGURATOR_HOTSPOT_EXIT={type:"event",category:EPIGRAPH_CONFIGURATOR_CATEGORY,action:"configuratorHotspotExit",label:"",interaction:{nonInteraction:!1}},CONFIGURATOR_SCENE_SHARED={type:"event",category:EPIGRAPH_CONFIGURATOR_CATEGORY,action:"configuratorSceneShared",label:"",interaction:{nonInteraction:!1}};/* @license
4637
4637
  * Copyright 2019 Google LLC. All Rights Reserved.
4638
4638
  * Licensed under the Apache License, Version 2.0 (the 'License');
4639
4639
  * you may not use this file except in compliance with the License.
@@ -4646,7 +4646,7 @@ ${zt.join(`
4646
4646
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4647
4647
  * See the License for the specific language governing permissions and
4648
4648
  * limitations under the License.
4649
- */const HAS_WEBXR_DEVICE_API=navigator.xr!=null&&self.XRSession!=null&&navigator.xr.isSessionSupported!=null;HAS_WEBXR_DEVICE_API&&self.XRSession.prototype.requestHitTestSource!=null;(()=>{const kt=navigator.userAgent||navigator.vendor||self.opera;let _e=!1;return(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(kt)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(kt.substr(0,4)))&&(_e=!0),_e})();const IS_IOS=/iPad|iPhone|iPod/.test(navigator.userAgent)&&!self.MSStream||navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1,IS_WKWEBVIEW=!!(window.webkit&&window.webkit.messageHandlers);(()=>{if(IS_IOS){if(IS_WKWEBVIEW)return!!/CriOS\/|EdgiOS\/|FxiOS\/|GSA\/|DuckDuckGo\//.test(navigator.userAgent);{const kt=document.createElement("a");return!!(kt.relList&&kt.relList.supports&&kt.relList.supports("ar"))}}else return!1})();class ConfiguratorCoreAPI{static forwardVector3=new Vector3(0,0,1);#t=!1;#i;#n;#s;#r;#c;#o;#a;#l;#v;#e;#g;#h=!0;#u;#f=!0;#d="";#p="";#m=null;epigraphAnalytics=null;EVENTS={UI:{PreloadScreen_Show:"preload:show",PreloadScreen_Hide:"preload:hide",ContextMenu_InfoBtnClicked:"infoButtonClicked_ContextMenu",ContextMenu_Show:"contextMenu:show",ContextMenu_Hide:"contextMenu:hide",UtilityMenu_Show:"utilityMenu:show",UtilityMenu_Hide:"utilityMenu:hide",ShareButton_Show:"shareButton:show",ShareButton_Hide:"shareButton:hide",ViewInYourSpaceButton_Show:"viewInYourSpace:show",ViewInYourSpaceButton_Hide:"viewInYourSpace:hide",ResetButton_Show:"resetBtn:show",ResetButton_Hide:"resetBtn:hide",DimensionsButton_Show:"dimensionsBtn:show",DimensionsButton_Hide:"dimensionsBtn:hide",Instructions_Show:"instructions:show",ReviewCart_Shown:"review-cart-shown",ReviewCart_Hidden:"review-cart-hidden"},SCENE:{Item_Added:"item:added",Item_Removed:"item:removed",Items_Updated:"items:updated",FittingSkuIds_Updated:"fittingSkuIds:updated",CartItems_Updated:"cartItems:updated",Hotspot_Enter:"hotspot:enter",Hotspot_Exit:"hotspot:exit",SavedConfiguration_Loaded:"loaded-saved-configuration",MaterialOverrides_Exists:"materialOverrideExists",Cart_Checkout:"cart:checkout",Cart_OutOfStock:"cart:outOfStock",Cart_StatusUpdated:"cart:statusUpdated",ReplaceableCategory_Updated:"replaceableCategory:updated",GlobalVariant_Updated:"globalVariant:updated",CategoryData_Updated:"categoryData:updated",GlobalGeometryVariant_Updated:"globalGeometryVariant:updated",Ghost_Loaded:"ghost:loaded",Model_Loaded:"model:loaded",Model_Removed:"model:removed",Scene_Cleared:"scene:cleared",Inventory_Updated:"inventory:updated",DraggingOnDrop_CollisionDetected:"draggingOnDrop:collisionDetected",ItemRemoveModalTriggered:"itemRemoveModal:triggered",ActionButton_Clicked:"actionButton:clicked",CartMessage_Update:"cartMessage:updated"},CONFIGURATION:{OnClickItem:"onClickItem",CameraDetails_Update:"cameraDetails:Update"}};constructor(_e,Dt,Vt=null){if(Dt.identifier!=="wc-epigraph-configurator-core")return LOGGER.error({title:"Invalid identifier on the 'wc-epigraph-configurator-core'. Unable to initialize the ConfiguratorCoreAPI class."}),null;this.stores=_e,Object.freeze(this.CORE_EVENTS),this.#r=Dt,this.#o=performance.now(),this.#s=Vt,this.#r.addEventListener(this.EVENTS.SCENE.CartItems_Updated,()=>{this.#u=void 0,this.#h=!0,this.#f=!0}),this.setupAnalyticsEventListeners(),this.#t=!0}set shadowRootRef(_e){this.#i=_e}get shadowRootRef(){return this.#i}set configuratorWCRef(_e){this.#c=_e}get configuratorWCRef(){return this.#c}set clientAccessKey(_e){this.#v=_e}get lastSharedConfigurationID(){return this.#u}set lastSharedConfigurationID(_e){this.#u=_e}set projectId(_e){this.#e=_e}get projectId(){return this.#e}set experienceId(_e){this.#g=_e}get experienceId(){return this.#g}get coreWCRef(){return this.#r}getResolvedAssetUrl(_e){return resolveAssetUrl(_e)}initializeAnalytics(_e,Dt=!1){const Vt=this.coreWCRef.consentPlugin??null,Gt=this.coreWCRef.consentIdentifier??null;if(this.epigraphAnalytics=new X$2(Vt,Gt),_e.gaMeasurementId!=="")try{this.epigraphAnalytics.addEventPlugin(new I$2(_e.gaMeasurementId,!1))}catch(zt){LOGGER.info({title:"Error initializing GA4 Analytics",details:zt})}_e.epgExperienceID!==void 0&&this.epigraphAnalytics.addEventPlugin(new C$2(_e.epgExperienceID,crypto.randomUUID(),"",!1,Dt))}get isReady(){return this.#t}get preloadProgress(){return this.#n}get categoryData(){return this.stores.productDataStore.getState().categoryData}get productData(){return this.stores.productDataStore.getState().productData}get lookData(){return this.stores.productDataStore.getState().lookData}get hotspotsData(){return this.stores.productDataStore.getState().hotspotsData}get sceneSettings(){return this.stores.coreSceneStore.getState().sceneSettings}get assetsData(){return this.stores.productDataStore.getState().assetsData}get isMobile(){return this.stores.coreSceneStore.getState().isMobile}get isScreenPortrait(){return this.stores.uiSceneStore.getState().isScreenPortrait}getDeviceState(){return this.stores.coreSceneStore.getState().actions.getDeviceState()}get hasSceneChanged(){return this.#h}set hasSceneChanged(_e){this.#h=_e}enableCart(){this.stores.coreSceneStore.getState().actions.enableCart()}disableCart(){this.stores.coreSceneStore.getState().actions.disableCart()}fireEvent(_e,Dt){let Vt=new CustomEvent(_e,{bubbles:!0,cancelable:!1,composed:!0});Vt.data=Dt,this.coreWCRef?this.coreWCRef.dispatchEvent(Vt):LOGGER.warn({title:"core web component not found!"})}setupAnalyticsEventListeners(){this.coreWCRef.addEventListener("coreApi:ready",_e=>{let Dt=Object.assign({},CONFIGURATOR_READY);const Vt=((performance.now()-this.#o)/1e3).toFixed(2);this.#a=Vt,Dt.event_label=`${this.#e}`,Dt.parameters={project_id:`${this.#e}`,load_time:Vt},this.sendAnalyticsEvent(Dt)}),this.coreWCRef.addEventListener("coreApi:failed",_e=>{let Dt=Object.assign({},CONFIGURATOR_FAILED);Dt.parameters={project_id:`${this.#e}`},Dt.event_label=`${this.#e}`,this.sendAnalyticsEvent(Dt)}),this.coreWCRef.addEventListener(this.EVENTS.SCENE.Item_Added,_e=>{LOGGER.info({title:"Add Item",details:_e});const Dt=_e.data.itemData.guid,zt=this.stores.attachmentStore.getState().attachmentSystem.currentStructure.getNodeByGUID(Dt)?.currentVariant,Ht={item_added:`${`${_e.data.itemData.skuID}(${zt})`}`,project_id:`${this.#e}`},Wt=this.stores.coreSceneStore.getState().preconfigurationLoaded==!1&&this.stores.coreSceneStore.getState().sceneHasDefaultConfigurationID==!1,qt=this.stores.coreSceneStore.getState().configurationLoaded==!1&&this.stores.coreSceneStore.getState().preconfigurationLoaded==!0&&this.stores.coreSceneStore.getState().configurationLoadedOnRestart==!0;if(Wt||qt){let Xt=Object.assign({},CONFIGURATOR_PRECONFIGURATION_ITEM_ADDED);Xt.parameters=Ht,this.sendAnalyticsEvent(Xt)}else{let Xt=Object.assign({},CONFIGURATOR_ITEM_ADDED);Xt.parameters=Ht,this.sendAnalyticsEvent(Xt)}}),this.coreWCRef.addEventListener(this.EVENTS.SCENE.Item_Removed,_e=>{if(LOGGER.info({title:"Remove Item"}),_e.data.itemData==null)return;const Dt=_e.data.itemData.skuID;let Vt=Object.assign({},CONFIGURATOR_ITEM_REMOVED);Vt.parameters={item_removed:`${Dt}`,project_id:`${this.#e}`},this.sendAnalyticsEvent(Vt)}),this.coreWCRef.addEventListener(this.EVENTS.SCENE.Hotspot_Enter,_e=>{let Dt=Object.assign({},CONFIGURATOR_HOTSPOT_ENTER);const Vt=_e.data.hotspot?.hotspotData?.title;Dt.parameters={hotspot_entered:`${this.sceneSettings.analyticsEventPrefix}${Vt||_e.data.hotspotAbsID}`,project_id:`${this.#e}`},this.sendAnalyticsEvent(Dt)}),this.coreWCRef.addEventListener(this.EVENTS.SCENE.Hotspot_Exit,_e=>{let Dt=Object.assign({},CONFIGURATOR_HOTSPOT_EXIT);const Vt=_e.data.hotspot?.hotspotData?.title;Dt.parameters={hotspot_exited:`${this.sceneSettings.analyticsEventPrefix}${Vt||_e.data.hotspotAbsID}`,project_id:`${this.#e}`,c_hotspot_time_spent:`${_e.data.hotspotTimeSpent}`},this.sendAnalyticsEvent(Dt)}),this.coreWCRef.addEventListener(this.EVENTS.SCENE.Cart_Checkout,_e=>{let Dt=0,Vt=0,Gt=0;_e.data.cartItems.forEach((jt,Ht)=>{Vt++,Gt+=jt.count,Dt+=jt.price;let Wt=Object.assign({},CONFIGURATOR_CHECKOUT_ITEM);Wt.parameters={client_product_id:jt.clientProductId,count_added_to_cart:jt.count,variant:`${jt.currentVariant}`,total_value:jt.price,epigraph_sku:`${jt.skuID}`,project_id:`${this.#e}`},this.sendAnalyticsEvent(Wt)});let zt=Object.assign({},CONFIGURATOR_CHECKOUT);zt.parameters={cart_total:Dt,unique_items_count:Vt,total_items:Gt,project_id:`${this.#e}`},this.sendAnalyticsEvent(zt)})}getPreconfigurationModuleData(){return this.stores.productDataStore.getState().categoryData.preconfiguration}setEmptySceneText(_e){const Dt=this.stores.coreSceneStore.getState().sceneSettings;Dt.emptySceneText=_e,this.stores.coreSceneStore.setState({sceneSettings:{...Dt}})}getSpawningRequirementForSkuID(_e){return this.stores.attachmentStore.getState().attachmentSystem.currentStructure.getSpawningRequirementForSkuID(_e)}getAllSkusThatCanReplaceGuid(_e){if(!this.stores.itemStore.getState().itemsSpawned[_e])return LOGGER.warn({title:"Item with guid: "+_e+" doesn't exist"}),[];const zt=this.stores.attachmentStore.getState().attachmentSystem.currentStructure.getNodeByGUID(_e);return zt?zt.getAllSkusThatCanReplaceMe():(LOGGER.warn({title:"Node with guid: "+_e+" doesn't exist"}),[])}getCartItems(){return this.stores.attachmentStore.getState().attachmentSystem.getCartItems()}async getCartItemsAsync(){return await this.stores.attachmentStore.getState().attachmentSystem.getCartItemsAsync()}checkout(_e=!1){const Dt=this.stores.attachmentStore.getState().attachmentSystem;this.#m=this.getSceneStructure();let Vt=Dt.getCartItems();return Vt=this.stores.dynamicHookStore.getState().hookOnCheckout(Vt,this),Vt==null?null:(LOGGER.warn({title:"CONFIGURATOR CHECKED OUT: "}),LOGGER.table(Vt),_e===!0||Vt.cartItems.find(Gt=>Gt.countUnavailable>0)===void 0?(this.fireEvent(this.EVENTS.SCENE.Cart_Checkout,Vt),this.alert({alertMsg:"Items from your configuration have been added to your cart.",alertTime:6e3,alertType:"success",alertLabel:"Success",alertId:"itemAdded"})):this.fireEvent(this.EVENTS.SCENE.Cart_OutOfStock,Vt),Vt)}async checkoutAsync(_e=!1){const Dt=this.stores.attachmentStore.getState().attachmentSystem;this.#m=this.getSceneStructure();let Vt=Dt.getCartItems();return Vt=await this.stores.dynamicHookStore.getState().hookOnCheckout(Vt,this),Vt==null?null:(LOGGER.warn({title:"CONFIGURATOR CHECKED OUT: "}),LOGGER.table(Vt),_e===!0||Vt.cartItems.find(Gt=>Gt.countUnavailable>0)===void 0?(this.fireEvent(this.EVENTS.SCENE.Cart_Checkout,Vt),this.alert({alertMsg:"Items from your configuration have been added to your cart.",alertTime:6e3,alertType:"success",alertLabel:"Success",alertId:"itemAdded"})):this.fireEvent(this.EVENTS.SCENE.Cart_OutOfStock,Vt),Vt)}async reloadCheckedoutScene(){if(!this.#m){LOGGER.info({title:"No data found since last checkout"});return}await this.loadSceneFromConfiguration(this.#m)}getCurrentItemsInReplaceableCategory(){return this.stores.attachmentStore.getState().attachmentSystem.currentStructure.getCurrentItemsInReplaceableCategory()}async getSceneAsGlbUrl(){return this.#f===!1?this.#d:(URL.revokeObjectURL(this.#d),this.#d=void 0,this.#d=await getSceneAsGLBUrl(this.stores),this.#f=!1,this.#d)}async getSceneAsUsdzUrl(){return this.#f===!1?this.#p:(URL.revokeObjectURL(this.#p),this.#p=void 0,this.#p=await getSceneAsUsdzUrl(this.stores),this.#f=!1,this.#p)}async generateShareableLink(_e=!1){if(!this.#h&&this.#u)LOGGER.info({title:"Reusing the cached configuration ID that was last saved..."});else{LOGGER.info({title:"Generating a new configuration ID..."});let zt=this.stores.attachmentStore.getState().actions.export(),jt=await this.stores.nexusApiInstance.postExperienceSaveAndShare(this.experienceId,zt);this.#u=jt.payload.save_id}const Dt=window.location.href;let Vt=new URL(Dt);_e===!0&&Vt.searchParams.set("launchInAR",!0),Vt.searchParams.set("projectId",this.projectId),Vt.searchParams.set("epgsharedconfigid",this.#u),this.#h=!1;let Gt=Object.assign({},CONFIGURATOR_SCENE_SHARED);return Gt.parameters={shared_url:`${Vt}`,project_id:`${this.#e}`},this.sendAnalyticsEvent(Gt),Vt.href}closeContextMenu(){this.stores.itemStore.getState().selectedItemData&&this.stores.itemStore.getState().actions.deselectItem()}updatePreloadProgress(_e){const Dt=this.#n;this.#n=_e;const Vt=new CustomEvent("preload:update",{detail:{progress:this.#n}});window.dispatchEvent(Vt),typeof this.#s=="function"&&this.#s(Dt,_e)}alert({alertMsg:_e,alertTime:Dt,alertType:Vt,alertLabel:Gt,persistant:zt=!1,alertId:jt}){this.stores.coreSceneStore.getState().actions.sendAlert({alertMsg:_e,alertTime:Dt,alertType:Vt,alertLabel:Gt,persistant:zt,alertId:jt})}removePersistantAlert(){this.stores.coreSceneStore.setState({persistantAlertData:null})}clickHotspot(_e){let Dt=this.coreWCRef.shadowRootRef.getElementById(_e);Dt&&Dt.click()}exitHotspot(){this.stores.hotspotStore.getState().actions.exitHotspot(!1)}isSystemBusy(){return this.stores.itemStore.getState().isBusy()}async spawnGhostsForSkuID(_e,Dt=!1,Vt){return this.isSystemBusy()?null:await this.stores.ghostStore.getState().actions.spawnGhostsForSkuID(_e,Dt,Vt)}removeAllGhosts(){if(this.stores.itemStore.getState().isBusy())return null;this.stores.ghostStore.getState().actions.clearAllGhosts()}printSceneHierarchy(_e=!1){const Dt=this.stores.coreSceneStore.getState().sceneRef;(function Vt(Gt){const zt=`${Gt.name} < ${Gt.type} >`;_e===!0?console.groupCollapsed(zt):console.group(zt),Gt.children.forEach(Vt),console.groupEnd()})(Dt)}getSceneItems(){const _e=this.stores.itemStore.getState().itemsSpawned;if(typeof _e!="object"){LOGGER.error({title:"There was an error while fetching the scene item count."});return}return _e}getSceneItemCount(){let _e;const Dt=this.stores.itemStore.getState().itemsSpawned;return typeof Dt!="object"&&LOGGER.error({title:"There was an error while fetching the scene item count."}),_e=Object.keys(Dt).length,_e}async spawnItemBySkuID(_e,Dt=!1){if(this.isSystemBusy())return null;const Vt=this.getActiveGhostData();return Vt&&Vt.skuID!==_e?null:(Dt===!0&&!Vt&&await this.spawnGhostsForSkuID(_e,!1,1),await this.stores.itemStore.getState().actions.addItemBySkuID(_e,0))}async spawnItemBySkuIDAndGhostIndex(_e,Dt=0){if(this.stores.itemStore.getState().isBusy())return null;let Vt=null;const Gt=this.getActiveGhostData();return Dt>=0&&Gt.count>Dt&&Gt.skuID==_e&&(Vt=await this.stores.itemStore.getState().actions.addItemBySkuID(_e,Dt)),Vt}async replaceItemBySkuId(_e,Dt){return await this.stores.itemStore.getState().actions.replaceGuidItemBySkuId(_e,Dt)}async replaceItemsBySkuId(_e,Dt){if(!Array.isArray(_e))throw new Error("guids parameter must be an array");try{for(const Vt of _e)await this.replaceItemBySkuId(Vt,Dt);return!0}catch(Vt){throw new Error(`Failed to replace items by SKU ID: ${Vt.message}`)}}async replaceAllItemsBySkuId(_e,Dt){const Vt=[],Gt=this.stores.itemStore.getState().itemsSpawned;Object.keys(Gt).map(zt=>{Gt[zt].itemData.skuID==_e&&Vt.push(zt)});try{for(const zt of Vt)await this.replaceItemBySkuId(zt,Dt);return!0}catch(zt){throw new Error(`Failed to replace items by SKU ID: ${zt.message}`)}}async removeItemByGUID(_e,Dt=!1){if(this.stores.itemStore.getState().isBusy())return null;const Gt=this.stores.attachmentStore.getState().attachmentSystem.currentStructure.getNodeByGUID(_e);return Dt===!1&&Gt.canSwapRoot===!0&&Gt.swapRoot(),await this.stores.itemStore.getState().actions.removeItemByGUID(_e)}triggerItemRemoveModal(_e){const Dt=this.getGuidItemAttachedDependencies(_e);Dt&&this.fireEvent(this.EVENTS.SCENE.ItemRemoveModalTriggered,Dt)}async updateFittingSkuIds(){await this.stores.attachmentStore.getState().actions.updateFittingSkuIds()}rotateItemByGUID(_e){this.stores.attachmentStore.getState().attachmentSystem.currentStructure.rotateNode(_e)}rotateSelectedItem(){const _e=this.stores.itemStore.getState().selectedItemData;if(!_e){LOGGER.info({title:"No current item selected to rotate"});return}const Dt=_e.itemData.guid;return this.stores.attachmentStore.getState().attachmentSystem.currentStructure.rotateNode(Dt),_e}removeLastItemBySkuId(_e){const Dt=this.stores.itemStore.getState().itemsSpawned,Vt=Object.keys(Dt);for(let Gt=Vt.length-1;Gt>=0;Gt--){const zt=Vt[Gt];if(Dt[zt].itemData.skuID===_e){this.doesGuidItemHaveAnAttachedDependency(zt)?(this.selectItemWithGUID(zt),this.triggerItemRemoveModal(zt)):this.removeItemByGUID(zt);break}}}async removeSelectedItem(){const _e=this.stores.itemStore.getState().selectedItemData;if(!_e){LOGGER.info({title:"No current item selected to delete"});return}const Dt=_e.itemData.guid;return this.stores.itemStore.getState().actions.deselectItem(),await this.removeItemByGUID(Dt),LOGGER.info({title:`Removed Item: ${Dt}`}),_e}refocus(){this.stores.coreSceneStore.getState().actions.triggerAutoFocus()}getActiveGhostData(){return this.stores.ghostStore.getState().ghostData}focusOnGhosts(){if(this.stores.ghostStore.getState().ghostParentRef===null){LOGGER.warn({title:"Ghost Parent Reference not found"});return}this.stores.ghostStore.getState().ghostParentRef.children.length<=0?this.stores.coreSceneStore.getState().actions.triggerAutoFocus():this.stores.coreSceneStore.getState().actions.triggerAutoFocus(this.stores.ghostStore.getState().ghostParentRef)}exitSelectedItem(){this.stores.itemStore.getState().actions.deselectItem()}getSelectedItemData(){return this.stores.itemStore.getState().selectedItemData}canSelectedItemRotate(){const _e=this.stores.attachmentStore.getState().attachmentSystem.currentStructure;let Dt=this.getSelectedItemData();return Dt?_e.getNodeByGUID(Dt.itemData.guid).canRotate:!1}canSelectedItemBeRemoved(){const _e=this.stores.attachmentStore.getState().attachmentSystem.currentStructure,Dt=this.getSelectedItemData();return Dt?_e.getNodeByGUID(Dt.itemData.guid).canRemove:!1}canSelectedItemDrag(){const _e=this.stores.attachmentStore.getState().attachmentSystem.currentStructure,Dt=this.getSelectedItemData();return Dt?_e.getNodeByGUID(Dt.itemData.guid).canDrag:!1}doesGuidItemHaveAnAttachedDependency(_e){let Dt=!0;const Gt=this.stores.attachmentStore.getState().attachmentSystem.currentStructure.getNodeByGUID(_e),zt=Gt.isEndNode;return Dt=!zt,zt||Gt.canSwapRoot&&Gt.whichNodesAreAttachedToUs().length==1&&(Dt=!1),Dt}getGuidItemAttachedDependencies(_e){const Dt=this.stores.attachmentStore.getState().attachmentSystem,Vt=this.stores.itemStore.getState().itemsSpawned,Gt=Dt.currentStructure.getNodeByGUID(_e);if(!Gt)return;let zt={[Gt.guid]:{...Vt[Gt.guid]}};return Gt.getAllBranchedNodesAttachedToUs().forEach(Ht=>{zt[Ht.guid]=Vt[Ht.guid]}),zt}doesSelectedItemHasAttachedDependency(){const _e=this.getSelectedItemData();return _e?this.doesGuidItemHaveAnAttachedDependency(_e.itemData.guid):!1}isSelectedItemAnEndNode(){const _e=this.stores.attachmentStore.getState().attachmentSystem.currentStructure,Dt=this.getSelectedItemData();return Dt?_e.getNodeByGUID(Dt.itemData.guid).isEndNode:!1}getCurrentSceneEnvMap(){return this.stores.lightStore.getState().envMapUrl}async switchGlobalGeometryVariant(_e,Dt){if(!_e){LOGGER.WARN({title:"Geometry Category: '"+_e+"' not valid!"});return}this.stores.itemStore.getState().selectedItemData&&this.stores.itemStore.getState().actions.deselectItem(),await this.stores.attachmentStore.getState().attachmentSystem.switchGlobalGeometryVariant(_e,Dt),await wait(1);let Vt=Object.assign({},CONFIGURATOR_GLOBAL_GEOMETRY_VARIANT_SWITCHED);Vt.parameters={variant:`${Dt}`,project_id:`${this.#e}`},this.sendAnalyticsEvent(Vt);const zt=this.stores.productDataStore.getState().categoryData.geometryVariants;let jt=null;if(zt.map(Wt=>{Wt.id==_e&&(jt=Wt)}),!jt)return;const Ht=jt.variants[Dt];this.alert({alertMsg:jt.label.charAt(0).toUpperCase()+jt.label.slice(1)+" was successfully switched to "+Ht.label.charAt(0).toUpperCase()+Ht.label.slice(1)+".",alertTime:3e3,alertType:"success",alertLabel:`${jt.label} Changed`,alertId:"geometryVariantChanged"})}async switchGlobalVariant(_e,Dt=""){if(!_e){LOGGER.WARN({title:"Look Category: '"+_e+"' not valid!"});return}this.stores.itemStore.getState().selectedItemData&&this.stores.itemStore.getState().actions.deselectItem(),LOGGER.info({title:`Changing Global Variant: Category: ${_e} Id: ${Dt}`}),await this.stores.attachmentStore.getState().attachmentSystem.switchGlobalVariant(_e,Dt),await wait(1);let Vt=Object.assign({},CONFIGURATOR_GLOBAL_VARIANT_SWITCHED);Vt.parameters={variant:`${Dt}`,project_id:`${this.#e}`},this.sendAnalyticsEvent(Vt)}async overrideSelectedItemMaterial(_e=""){return this.stores.itemStore.getState().selectedItemData?(await this.stores.itemStore.getState().actions.switchToVariant(this.stores.itemStore.getState().selectedItemData.itemData,_e,!0),!0):!1}async overrideItemMaterialByGuid(_e,Dt){const Vt=this.stores.itemStore.getState().itemsSpawned[_e];if(!Vt)return LOGGER.warn({title:"Item with guid: "+_e+" doesn't exist"}),!1;await this.stores.itemStore.getState().actions.switchToVariant(Vt.itemData,Dt,!0);let Gt=Object.assign({},CONFIGURATOR_LOCAL_VARIANT_SWITCHED);return Gt.parameters={variant:`${Dt}`,project_id:`${this.#e}`},this.sendAnalyticsEvent(Gt),!0}getSelectedItemColors(){let _e=[];if(this.getSelectedItemData()==null)return _e;let Vt=this.getSelectedItemData().itemData.looks;if(Vt){let Gt=this.stores.productDataStore.getState().lookData;Vt.map(zt=>{Gt.hasOwnProperty(zt)&&_e.push(Gt[zt])})}return _e}getCanvasSize(){return this.stores.coreSceneStore.getState().canvasSize}async removeAllVariantOverrides(){return this.stores.itemStore.getState().selectedItemData&&this.stores.itemStore.getState().actions.deselectItem(),await this.stores.attachmentStore.getState().attachmentSystem.removeAllVariantOverrides()}switchCursor(_e){this.stores.coreSceneStore&&this.stores.coreSceneStore.getState().actions.switchCursor(_e)}getSceneStructure(){return this.stores.attachmentStore.getState().actions.export()}getSceneStructureRaw(){return this.stores.attachmentStore.getState().attachmentSystem.currentStructure}getAllConnectionsInScene(){const _e=this.getSceneStructureRaw(),Dt=new Map;for(const Vt of _e.nodes)for(const Gt of Vt.plugs){if(!Gt.attachedPlugGUID)continue;const zt=[Gt.guid,Gt.attachedPlugGUID].sort().join();Dt.has(zt)||Dt.set(zt,{from:Gt,to:Gt.attachedPlug})}return Dt}async loadSceneFromConfiguration(_e){await this.stores.attachmentStore.getState().actions.loadStructure(_e)}async loadSceneFromConfigurationID(_e,Dt=!0){const Vt=await this.stores.attachmentStore.getState().actions.loadSavedStructureFromConfigID(_e);if(!Vt)return null;Dt===!0&&this.stores.attachmentStore.setState({defaultConfig:Vt});let Gt=Object.assign({},CONFIGURATOR_LOAD_FROM_PRECONFIG);Gt.label=`Preconfig ID: ${_e}`,await this.loadSceneFromConfiguration(Vt)}viewInYourSpace(){LOGGER.info({title:"View in your space called from the Core API"});let _e=Object.assign({},CONFIGURATOR_AR_REQUESTED);_e.label="AR Requested",_e.parameters={project_id:`${this.#e}`},this.sendAnalyticsEvent(_e),this.#r.epigraphViewInYourSpaceRef.onViewInYourSpaceButtonClicked()}async shareScene(){const _e=await this.generateShareableLink();let Dt=Object.assign({},CONFIGURATOR_SCENE_SHARED);return Dt.parameters={shared_url:`${_e}`,project_id:`${this.#e}`},this.sendAnalyticsEvent(Dt),_e}async clearScene(){return await this.stores.attachmentStore.getState().attachmentSystem.clear()}async restartScene(){LOGGER.info({title:"Restarting Scene."}),await this.stores.attachmentStore.getState().attachmentSystem.restart();let _e=Object.assign({},CONFIGURATOR_SCENE_RESTARTED);_e.label="Scene Restarted",_e.parameters={project_id:`${this.#e}`},this.sendAnalyticsEvent(_e)}areDimensionsVisible(){return this.stores.coreSceneStore.getState().showDimensions}getCurrentDimensions(){return this.stores.coreSceneStore.getState().boundData}getActiveHotspot(){return this.stores.hotspotStore.getState().activeHotspotData}reviewCartShown(){let _e=Object.assign({},CONFIGURATOR_REVIEW_CART_SHOWN);_e.label="Review Cart shown",_e.parameters={project_id:`${this.#e}`},this.fireEvent(this.EVENTS.UI.ReviewCart_Shown,_e),this.sendAnalyticsEvent(_e)}isGeometryVisibleForGUID(_e,Dt){const Vt={success:!1,result:!1},zt=this.stores.attachmentStore.getState().attachmentSystem.currentStructure.getNodeByGUID(Dt);return zt.ref&&zt.ref.traverse(jt=>{jt.name===_e&&(console.log(jt),Vt.success=!0,Vt.result=jt.visible)}),Vt}reviewCartHidden(){let _e=Object.assign({},CONFIGURATOR_REVIEW_CART_HIDE);_e.label="Review Cart hidden",_e.parameters={project_id:`${this.#e}`},this.fireEvent(this.EVENTS.UI.ReviewCart_Hidden,_e),this.sendAnalyticsEvent(_e)}sendShowInstructionsBtnAnalyticsEvent(){let _e=Object.assign({},CONFIGURATOR_INSTRUCTIONS_BTN_CLICKED);_e.parameters={project_id:`${this.#e}`},this.sendAnalyticsEvent(_e)}sendInstructionsAnalyticsCompletionRate(_e){let Dt=Date.now()-this.#l,Vt=Math.round(Dt/1e3);this.#l=Date.now();let Gt=Object.assign({},CONFIGURATOR_INSTRUCTIONS_COMPLETION_RATE);Gt.parameters={completion_rate:_e,time_spent:Vt,project_id:`${this.#e}`},this.sendAnalyticsEvent(Gt)}showInstructions(){this.fireEvent(this.EVENTS.UI.Instructions_Show),this.#l=Date.now();let _e=Object.assign({},CONFIGURATOR_INSTRUCTIONS_SHOWN);_e.label="Instructions shown",_e.parameters={project_id:`${this.#e}`},this.sendAnalyticsEvent(_e)}showDimensions(){this.stores.coreSceneStore.setState({showDimensions:!0});let _e=Object.assign({},CONFIGURATOR_DIMENSION_SHOWN);_e.label="Dimensions shown",_e.parameters={project_id:`${this.#e}`},this.sendAnalyticsEvent(_e)}hideDimensions(){this.stores.coreSceneStore.setState({showDimensions:!1});let _e=Object.assign({},CONFIGURATOR_DIMENSION_HIDE);_e.label="Dimensions hidden",_e.parameters={project_id:`${this.#e}`},this.sendAnalyticsEvent(_e)}areHotspotsVisible(){return this.stores.hotspotStore.getState().hotspotsVisibility}areHotspotsTemporarilyVisible(){return this.stores.hotspotStore.getState().hotspotsTempVisibility}showAllHotspots(_e=!1){this.stores.hotspotStore.getState().actions.switchHotspotsVisibility(!0,_e)}hideAllHotspots(_e=!1){this.stores.hotspotStore.getState().actions.switchHotspotsVisibility(!1,_e)}getFittingSkuIds(){return this.stores.attachmentStore.getState().attachmentSystem.getFittingSKUIDs()}selectItemWithGUID(_e){const Dt=this.stores.itemStore.getState().itemsSpawned,Vt=this.stores.attachmentStore.getState().attachmentSystem.currentStructure.getNodeByGUID(_e);this.stores.itemStore.getState().actions.setSelectedItemData({...Dt[_e],overrideVariant:Vt.overrideVariant,currentVariant:Vt.currentVariant,offsetX:0,offsetY:0})}async getCurrentCameraDetails(){return new Promise((_e,Dt)=>{this.coreWCRef.addEventListener(this.EVENTS.CONFIGURATION.CameraDetails_Update,Vt=>{_e(Vt.data)},{once:!0}),this.stores.cameraStore.getState().actions.triggerFetchingCamera()})}moveCamera(_e,Dt,Vt=!0){this.stores.hotspotStore.setState({isAnyHotspotActive:!0}),_e&&this.stores.cameraStore.setState({viewPointPosition:ArrToVec3(_e)}),Dt&&this.stores.cameraStore.setState({focusPointPosition:ArrToVec3(Dt)}),this.stores.cameraStore.setState({resetToLastPosition:Vt})}setEnvLightMap(_e){this.stores.lightStore.setState({envMapUrl:_e})}updateInventoryForAllProducts(_e){return this.stores.inventoryStore.getState().actions.updateInventoryForAllProducts(_e),this.getInventoryInfo()}getInventoryInfo(){return JSON.parse(JSON.stringify(this.stores.inventoryStore.getState().inventoryData))}updateCompareAtPricingForAllProducts(_e){this.stores.productDataStore.getState().actions.updateCompareAtPricingForAllProducts(_e);const Vt=this.stores.attachmentStore.getState().attachmentSystem.getCartItems();return Vt&&this.fireEvent(this.EVENTS.SCENE.CartItems_Updated,Vt),this.getCurrentCompareAtPricingInfo()}updatePricingForAllProducts(_e){this.stores.productDataStore.getState().actions.updatePricingForAllProducts(_e);const Vt=this.stores.attachmentStore.getState().attachmentSystem.getCartItems();return Vt&&this.fireEvent(this.EVENTS.SCENE.CartItems_Updated,Vt),this.getCurrentPricingInfo()}async updateCompareAtPricingForAllProductsAsync(_e){this.stores.productDataStore.getState().actions.updateCompareAtPricingForAllProducts(_e);const Vt=await this.stores.attachmentStore.getState().attachmentSystem.getCartItemsAsync();return Vt&&this.fireEvent(this.EVENTS.SCENE.CartItems_Updated,Vt),this.getCurrentCompareAtPricingInfo()}async updatePricingForAllProductsAsync(_e){this.stores.productDataStore.getState().actions.updatePricingForAllProducts(_e);const Vt=await this.stores.attachmentStore.getState().attachmentSystem.getCartItemsAsync();return Vt&&this.fireEvent(this.EVENTS.SCENE.CartItems_Updated,Vt),this.getCurrentPricingInfo()}updatePricingForProduct(_e,Dt,Vt){this.stores.productDataStore.getState().actions.updatePricingForProduct(_e,Dt,Vt);const zt=this.stores.attachmentStore.getState().attachmentSystem.getCartItems();return zt&&this.fireEvent(this.EVENTS.SCENE.CartItems_Updated,zt),this.getCurrentPricingInfo()}updateCompareAtPricingForProduct(_e,Dt,Vt){this.stores.productDataStore.getState().actions.updateCompareAtPricingForProduct(_e,Dt,Vt);const zt=this.stores.attachmentStore.getState().attachmentSystem.getCartItems();return zt&&this.fireEvent(this.EVENTS.SCENE.CartItems_Updated,zt),this.getCurrentCompareAtPricingInfo()}async updatePricingForProductAsync(_e,Dt,Vt){this.stores.productDataStore.getState().actions.updatePricingForProduct(_e,Dt,Vt);const zt=await this.stores.attachmentStore.getState().attachmentSystem.getCartItemsAsync();return zt&&this.fireEvent(this.EVENTS.SCENE.CartItems_Updated,zt),this.getCurrentPricingInfo()}async updateCompareAtPricingForProductAsync(_e,Dt,Vt){this.stores.productDataStore.getState().actions.updateCompareAtPricingForProduct(_e,Dt,Vt);const zt=await this.stores.attachmentStore.getState().attachmentSystem.getCartItemsAsync();return zt&&this.fireEvent(this.EVENTS.SCENE.CartItems_Updated,zt),this.getCurrentCompareAtPricingInfo()}getCurrentPricingInfo(){return this.stores.productDataStore.getState().actions.getCurrentPricingInfo()}getCurrentCompareAtPricingInfo(){return this.stores.productDataStore.getState().actions.getCurrentCompareAtPricingInfo()}async itemDragStart(_e){if(this.stores.itemStore.getState().isBusy())return null;this.stores.coreSceneStore.setState({hoveredGhostIndex:-1}),await this.removeAllGhosts(),this.stores.coreSceneStore.setState({itemDraggedSkuID:_e}),await this.spawnGhostsForSkuID(_e,!1)}async itemDragEnd(){if(this.stores.itemStore.getState().isBusy())return null;const _e=this.stores.coreSceneStore.getState().hoveredGhostIndex;_e!==-1?await this.stores.itemStore.getState().actions.addItemBySkuID(this.stores.coreSceneStore.getState().itemDraggedSkuID,_e):await this.removeAllGhosts(),this.stores.coreSceneStore.setState({itemDraggedSkuID:null,hoveredGhostIndex:-1})}async forceSpawnItem(_e,Dt){const Vt=this.stores.productDataStore.getState().productData,Gt=this.stores.attachmentStore.getState().attachmentSystem;if(!Gt)return;const zt=Gt.currentStructure;if(!zt)return;let jt=zt.getNodeByGUID(Dt);jt?(jt._skuID=_e,jt.generatePlugsForNode(_e)):(jt=new Node$1(this.stores,_e,{guid:Dt,isEndNode:!0,overrideVariant:null,plugs:Vt[_e].plugs}),zt.addNode(jt),zt.connectPlugs({incomingPlug:new Plug({name:"tempPlug",acceptedPlugTypes:[],connectsToPlugTypes:[]},jt),receiverPlug:zt.rootNode.plugs[0]}));const Ht=await this.stores.itemStore.getState().actions.addItemWithTransform({position:new Vector3(0,0,0),rotation:new Quaternion().identity()},_e,Dt);return await wait(1),Ht}async getScreenshotForCurrentCamera(_e){return await this.stores.coreSceneStore.getState().actions.requestNewScreenshot(null,_e)}async getScreenshotForCamera(_e,Dt){return await this.stores.coreSceneStore.getState().actions.requestNewScreenshot(_e,Dt)}async getAllPredefinedScreenshots(_e){const Dt=this.stores.coreSceneStore.getState().sceneSettings.screenshotCameras,Vt=[];for(const Gt of Dt){const zt=await this.stores.coreSceneStore.getState().actions.requestNewScreenshot(Gt,_e);Vt.push(zt)}return Vt}setCameraFocusPointPosition(_e){this.stores.cameraStore.setState({focusPointPosition:_e})}triggerFetchingCamera(){this.stores.cameraStore.getState().actions.triggerFetchingCamera()}async completeItemDrop(){await this.stores.coreSceneStore.getState().actions.completeDropItem()}revertItemDrop(){this.stores.coreSceneStore.getState().actions.revertDropItem()}getCameraFocusPointPosition(){return this.stores.cameraStore.getState().focusPointPosition}sendAnalyticsPageViewedEvent(){}sendAnalyticsEvent(_e){if(this.epigraphAnalytics!==null)try{this.epigraphAnalytics.sendEvent(_e)}catch{LOGGER.info()}}isIosDevice(){return IS_IOS}actionButtonClicked(_e){this.fireEvent(this.EVENTS.SCENE.ActionButton_Clicked,{data:_e.actionButton.data,skuID:_e.skuID,count:_e.count,price:_e.price,compareAtPrice:_e.compareAtPrice,countAvailable:_e.countAvailable,countUnavailable:_e.countUnavailable,currentVariant:_e.currentVariant})}setCartMessage(_e){this.fireEvent(this.EVENTS.SCENE.CartMessage_Update,{cartMessage:_e})}convertQuaternionToEuler(_e){return new Euler(0,0,0,"XYZ").setFromQuaternion(_e)}convertDegreeToRadians(_e){return MathUtils.degToRad(_e)}convertRadiansToDegree(_e){return MathUtils.radToDeg(_e)}createVector3(_e,Dt,Vt){return new Vector3(_e,Dt,Vt)}isFacingInDirection(_e,Dt){return ConfiguratorCoreAPI.forwardVector3.set(0,0,1),Dt.normalize(),ConfiguratorCoreAPI.forwardVector3.applyQuaternion(_e),ConfiguratorCoreAPI.forwardVector3.dot(Dt)>=0}}const EpigraphConfiguratorCore=reactExports.forwardRef(({customVersionId:kt,experienceId:_e,stores:Dt,viewInYourSpaceRef:Vt,configuratorWcRef:Gt,initialConfigId:zt,clientAccessKey:jt,consentPlugin:Ht,consentIdentifier:Wt,gaMeasurementId:qt,builderMode:Xt,id:Kt,disableCart:Yt,apiMode:Zt},Jt)=>{const[nn,rn]=reactExports.useState(null);reactExports.useEffect(()=>{Jt.current&&(Jt.current.identifier="wc-epigraph-configurator-core",Jt.current.epigraphViewInYourSpaceRef=void 0,Jt.current.initialConfigId="",Jt.current.clientAccessKey="",Jt.current.consentPlugin="",Jt.current.consentIdentifier="",Jt.current.gaMeasurementId="",Jt.current.configuratorWcRef=void 0,Jt.current.builderMode=!1,Jt.current.projectId="",Jt.current.api=null,Jt.current.api=new ConfiguratorCoreAPI(Dt,Jt.current),Dt.coreSceneStore.setState({CORE_API:Jt.current.api}),en(Jt.current))},[Jt]),reactExports.useEffect(()=>{Jt.current&&Vt&&(Vt.current&&(Jt.current.epigraphViewInYourSpaceRef=Vt.current),LOGGER.info({title:"ViewInYourSpace is now accessible from the core: "}))},[Jt,Vt]);const Qt=reactExports.useCallback(tn=>{Gt&&(tn.configuratorWCRef=Gt,tn.shadowRootRef=tn.configuratorWCRef.shadowRoot,tn.api.shadowRootRef=tn.shadowRootRef,tn.api.configuratorWCRef=tn.configuratorWCRef),kt&&(tn.customVersionId=kt),zt&&(tn.initialConfigId=zt),jt&&(tn.clientAccessKey=jt),Ht&&(tn.consentPlugin=Ht),Wt&&(tn.consentIdentifier=Wt),qt&&(tn.gaMeasurementId=qt),Xt&&(tn.builderMode=!0),LOGGER.group("Collected Web Component Attributes"),LOGGER.table({initialConfigId:tn.initialConfigId,clientAccessKey:tn.clientAccessKey,consentPlugin:tn.consentPlugin,consentIdentifier:tn.consentIdentifier,builderMode:tn.builderMode}),LOGGER.groupEnd()},[Xt,zt,qt,jt,Gt]),en=reactExports.useCallback(async tn=>{if(tn.coreReady===!0)return;Qt(tn);let sn=kt;!sn&&IS_DEV_ENV&&(sn="latest");let cn={};if(Zt==="input.json"?cn={payload:{project_id:"local-project",experience_id:"",configurator_data:await __vitePreload(()=>import("./input-afb87ea8.js"),[]),session_details:{environment:"development"}},report:"Local Input Json",success:!0}:jt?cn=await Dt.nexusApiInstance.getConfiguratorByClientAccessKey(jt,sn):cn=await Dt.nexusApiInstance.getConfiguratorByExperienceId(_e,sn),tn.validationPassed=cn.success,tn.validationPassed==!1){LOGGER.error({title:"Request from an invalidated source: "+window.location.href}),Dt.coreSceneStore.getState().CORE_API.fireEvent("coreApi:failed");return}Dt.nexusApiResponseEnvironment=cn.payload.session_details.environment,tn.projectId=cn.payload.project_id,tn.experienceId=cn.payload.experience_id,Dt.experienceId=cn.payload.experience_id,tn.api.projectId=tn.projectId,tn.api.experienceId=tn.experienceId;const un=cn.payload.configurator_data,hn={gaMeasurementId:tn.gaMeasurementId??void 0,epgExperienceID:tn.experienceId??void 0};Dt.coreSceneStore.getState().CORE_API.initializeAnalytics(hn,IS_DEV_ENV);let fn=Object.assign({},CONFIGURATOR_LOADING);fn.parameters={project_id:`${tn.projectId}`},Dt.coreSceneStore.getState().CORE_API.sendAnalyticsEvent(fn),LOGGER.info({title:"VALIDATION SUCCESSFUL!"}),tn.coreReady=!0;let pn=new URL(window.location).searchParams;pn.has("epgsharedconfigid")&&(tn.initialConfigId=pn.get("epgsharedconfigid")),rn({projectId:tn.projectId,parsedData:un,customVersionId:tn.customVersionId,clientAccessKey:tn.clientAccessKey,consentPlugin:tn.consentPlugin,consentIdentifier:tn.consentIdentifier,initialConfigId:tn.initialConfigId,builderMode:tn.builderMode})},[]);return reactExports.useEffect(()=>()=>{Dt.coreSceneStore.getState().CORE_API&&Dt.coreSceneStore.getState().CORE_API.fireEvent("coreApi:shutDown")},[]),jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsx("div",{id:Kt,ref:Jt,children:nn&&jsxRuntimeExports.jsx(App$1,{parsedData:nn.parsedData,stores:Dt,clientAccessKey:nn.clientAccessKey,consentPlugin:nn.consentPlugin,consentIdentifier:nn.consentIdentifier,initialConfigId:nn.initialConfigId,builderMode:nn.builderMode,disableCart:Yt!==void 0?Yt:!1})})})}),ViewInYourSpace=React.forwardRef((kt,_e)=>{const[Dt,Vt]=reactExports.useState(!1),[Gt,zt]=reactExports.useState(!1),jt=reactExports.useRef(null),Ht=reactExports.useRef(null),Wt=reactExports.useRef(null),qt=reactExports.useRef(null),Xt=reactExports.useRef(null),Kt=reactExports.useRef(null),Yt=reactExports.useRef(null),Zt=reactExports.useRef(null),Jt=reactExports.useRef(null),nn=reactExports.useRef(null),rn=kt.stores.uiSceneStore(qn=>qn.dialogPopupOpen),Qt=reactExports.useMemo(()=>`*Technical requirements: iOS Version ${_e?.current?.coreApi?.sceneSettings?.technicalRequirements?.minIosVersion??"11"} and later or Android 8 and later.`,[kt]),en=reactExports.useMemo(()=>`*Technical requirements: iOS Version ${_e?.current?.coreApi?.sceneSettings?.technicalRequirements?.minIosVersion??"11"} and later or Android 8 and later.`,[kt]),tn=()=>{kt["asset-src"]&&(_e.current.assetSrc=kt["asset-src"])};reactExports.useEffect(()=>{!_e.current||!jt.current||!Ht.current||!Wt.current||!qt.current||!Xt.current||!Kt.current||!Yt.current||!Zt.current||!Jt.current||!nn.current||(tn(),_e.current.getQRForURL=async(qn,tr)=>await Pn(qn,tr),_e.current.onViewInYourSpaceButtonClicked=async qn=>await yn(),_e.current.assetSrc="",_e.current.iosAssetSrc="",_e.current.arLink="",_e.current.coreApi=void 0,_e.current.arInProgress=!1,_e.current._modelViewerScriptSource="https://cdn.jsdelivr.net/npm/@google/model-viewer@2.x.x/dist/model-viewer.min.js",_e.current._modelViewer=null,_e.current._qrModalContainer=null,dn(),fn(),un(),_e.current._modelViewer.addEventListener("error",qn=>{Cn(qn)}),_e.current._viewInYourSpaceButton.addEventListener("click",qn=>{yn()}),_e.current.canLaunchAR=sn)},[_e,jt,Ht,Wt,qt,Xt,Kt,Yt,Zt,Jt,nn]);const sn=reactExports.useCallback(()=>_e.current._modelViewer.canActivateAR,[]);reactExports.useEffect(()=>{_e.current&&(kt["asset-src"]&&(_e.current.assetSrc=kt["asset-src"]),kt["core-api"]&&(_e.current.coreApi=kt["core-api"]),cn())},[_e,kt]);const cn=()=>{_e.current._modelViewer.setAttribute("src",_e.current.assetSrc),_e.current._modelViewer.setAttribute("ios-src",_e.current.iosAssetSrc),_e.current._modelViewer.style.display="none"},un=()=>{window.customElements.get("model-viewer")===void 0&&hn(),En(),cn(),_e.current._modelViewer.addEventListener("ar-status",qn=>{qn.detail.status==="session-started"?(_e.current._modelViewer.style.display="block",_e.current.arInProgress=!0):(qn.detail.status==="not-presenting"||qn.detail.status==="failed")&&(_e.current._modelViewer.style.display="none",_e.current.arInProgress=!1)})},hn=()=>{_e.current._modelViewerScriptElem=document.createElement("script"),_e.current._modelViewerScriptElem.setAttribute("type","module"),_e.current._modelViewerScriptElem.setAttribute("src",_e.current._modelViewerScriptSource),_e.current._modelViewerScriptElem.setAttribute("id","modelViewerScript"),document.head.appendChild(_e.current._modelViewerScriptElem)},fn=()=>{_e.current._qrModalContainer=qt.current,_e.current._qrCodeImage=Xt.current,_e.current._arLink=Kt.current,_e.current._qrLoader=Yt.current,_e.current.doneViewInYourSpaceBtn=Zt.current,_e.current.doneViewInYourSpaceBtn.addEventListener("click",()=>{pn(),Tn()})},pn=async()=>{if(_e.current._qrCodeImage!==null)for(;_e.current._qrCodeImage.firstChild;)_e.current._qrCodeImage.removeChild(_e.current._qrCodeImage.firstChild)},dn=()=>{_e.current.arDrawer=jt.current,_e.current._launchARButton=Ht.current,_e.current._modelDownloadLoader=Wt.current,_e.current._launchARButton.addEventListener("click",()=>{_e.current.arInProgress!==!0&&Rn()})},mn=()=>{_e.current._modelDownloadLoader.classList.remove("loader-hide")},vn=()=>{_e.current._modelDownloadLoader.classList.add("loader-hide")},_n=()=>{zt(!0),xn(),_e.current.arDrawer.show()},En=()=>{_e.current._modelViewer=Jt.current,_e.current._viewInYourSpaceButton=nn.current},An=()=>{Vt(!0),_e.current._qrModalContainer.show()},Tn=()=>{Vt(!1),_e.current._qrModalContainer.hide()},Cn=qn=>{console.error(`[VIEW-IN-YOUR-SPACE ERROR]: Asset load Errors!!
4649
+ */const HAS_WEBXR_DEVICE_API=navigator.xr!=null&&self.XRSession!=null&&navigator.xr.isSessionSupported!=null;HAS_WEBXR_DEVICE_API&&self.XRSession.prototype.requestHitTestSource!=null;(()=>{const kt=navigator.userAgent||navigator.vendor||self.opera;let _e=!1;return(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(kt)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(kt.substr(0,4)))&&(_e=!0),_e})();const IS_IOS=/iPad|iPhone|iPod/.test(navigator.userAgent)&&!self.MSStream||navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1,IS_WKWEBVIEW=!!(window.webkit&&window.webkit.messageHandlers);(()=>{if(IS_IOS){if(IS_WKWEBVIEW)return!!/CriOS\/|EdgiOS\/|FxiOS\/|GSA\/|DuckDuckGo\//.test(navigator.userAgent);{const kt=document.createElement("a");return!!(kt.relList&&kt.relList.supports&&kt.relList.supports("ar"))}}else return!1})();class ConfiguratorCoreAPI{static forwardVector3=new Vector3(0,0,1);#t=!1;#i;#n;#s;#r;#c;#o;#a;#l;#v;#e;#g;#h=!0;#u;#f=!0;#d="";#p="";#m=null;epigraphAnalytics=null;EVENTS={UI:{PreloadScreen_Show:"preload:show",PreloadScreen_Hide:"preload:hide",ContextMenu_InfoBtnClicked:"infoButtonClicked_ContextMenu",ContextMenu_Show:"contextMenu:show",ContextMenu_Hide:"contextMenu:hide",UtilityMenu_Show:"utilityMenu:show",UtilityMenu_Hide:"utilityMenu:hide",ShareButton_Show:"shareButton:show",ShareButton_Hide:"shareButton:hide",ViewInYourSpaceButton_Show:"viewInYourSpace:show",ViewInYourSpaceButton_Hide:"viewInYourSpace:hide",ResetButton_Show:"resetBtn:show",ResetButton_Hide:"resetBtn:hide",DimensionsButton_Show:"dimensionsBtn:show",DimensionsButton_Hide:"dimensionsBtn:hide",Instructions_Show:"instructions:show",ReviewCart_Shown:"review-cart-shown",ReviewCart_Hidden:"review-cart-hidden"},SCENE:{Item_Added:"item:added",Item_Removed:"item:removed",Items_Updated:"items:updated",FittingSkuIds_Updated:"fittingSkuIds:updated",CartItems_Updated:"cartItems:updated",Hotspot_Enter:"hotspot:enter",Hotspot_Exit:"hotspot:exit",SavedConfiguration_Loaded:"loaded-saved-configuration",MaterialOverrides_Exists:"materialOverrideExists",Cart_Checkout:"cart:checkout",Cart_OutOfStock:"cart:outOfStock",Cart_StatusUpdated:"cart:statusUpdated",ReplaceableCategory_Updated:"replaceableCategory:updated",GlobalVariant_Updated:"globalVariant:updated",CategoryData_Updated:"categoryData:updated",GlobalGeometryVariant_Updated:"globalGeometryVariant:updated",Ghost_Loaded:"ghost:loaded",Model_Loaded:"model:loaded",Model_Removed:"model:removed",Scene_Cleared:"scene:cleared",Inventory_Updated:"inventory:updated",DraggingOnDrop_CollisionDetected:"draggingOnDrop:collisionDetected",ItemRemoveModalTriggered:"itemRemoveModal:triggered",ActionButton_Clicked:"actionButton:clicked",CartMessage_Update:"cartMessage:updated"},CONFIGURATION:{OnClickItem:"onClickItem",CameraDetails_Update:"cameraDetails:Update"}};constructor(_e,Dt,Vt=null){if(Dt.identifier!=="wc-epigraph-configurator-core")return LOGGER.error({title:"Invalid identifier on the 'wc-epigraph-configurator-core'. Unable to initialize the ConfiguratorCoreAPI class."}),null;this.stores=_e,Object.freeze(this.CORE_EVENTS),this.#r=Dt,this.#o=performance.now(),this.#s=Vt,this.#r.addEventListener(this.EVENTS.SCENE.CartItems_Updated,()=>{this.#u=void 0,this.#h=!0,this.#f=!0}),this.setupAnalyticsEventListeners(),this.#t=!0}set shadowRootRef(_e){this.#i=_e}get shadowRootRef(){return this.#i}set configuratorWCRef(_e){this.#c=_e}get configuratorWCRef(){return this.#c}set clientAccessKey(_e){this.#v=_e}get lastSharedConfigurationID(){return this.#u}set lastSharedConfigurationID(_e){this.#u=_e}set projectId(_e){this.#e=_e}get projectId(){return this.#e}set experienceId(_e){this.#g=_e}get experienceId(){return this.#g}get coreWCRef(){return this.#r}getResolvedAssetUrl(_e){return resolveAssetUrl(_e)}initializeAnalytics(_e,Dt=!1){const Vt=this.coreWCRef.consentPlugin??null,Gt=this.coreWCRef.consentIdentifier??null;if(this.epigraphAnalytics=new S$3(Vt,Gt),_e.gaMeasurementId!=="")try{this.epigraphAnalytics.addEventPlugin(new I$2(_e.gaMeasurementId,!1))}catch(zt){LOGGER.info({title:"Error initializing GA4 Analytics",details:zt})}_e.epgExperienceID!==void 0&&this.epigraphAnalytics.addEventPlugin(new A$1(_e.epgExperienceID,crypto.randomUUID(),"",!1,Dt))}get isReady(){return this.#t}get preloadProgress(){return this.#n}get categoryData(){return this.stores.productDataStore.getState().categoryData}get productData(){return this.stores.productDataStore.getState().productData}get lookData(){return this.stores.productDataStore.getState().lookData}get hotspotsData(){return this.stores.productDataStore.getState().hotspotsData}get sceneSettings(){return this.stores.coreSceneStore.getState().sceneSettings}get assetsData(){return this.stores.productDataStore.getState().assetsData}get isMobile(){return this.stores.coreSceneStore.getState().isMobile}get isScreenPortrait(){return this.stores.uiSceneStore.getState().isScreenPortrait}getDeviceState(){return this.stores.coreSceneStore.getState().actions.getDeviceState()}get hasSceneChanged(){return this.#h}set hasSceneChanged(_e){this.#h=_e}enableCart(){this.stores.coreSceneStore.getState().actions.enableCart()}disableCart(){this.stores.coreSceneStore.getState().actions.disableCart()}fireEvent(_e,Dt){let Vt=new CustomEvent(_e,{bubbles:!0,cancelable:!1,composed:!0});Vt.data=Dt,this.coreWCRef?this.coreWCRef.dispatchEvent(Vt):LOGGER.warn({title:"core web component not found!"})}setupAnalyticsEventListeners(){this.coreWCRef.addEventListener("coreApi:ready",_e=>{let Dt=Object.assign({},CONFIGURATOR_READY);const Vt=((performance.now()-this.#o)/1e3).toFixed(2);this.#a=Vt,Dt.event_label=`${this.#e}`,Dt.parameters={project_id:`${this.#e}`,load_time:Vt},this.sendAnalyticsEvent(Dt)}),this.coreWCRef.addEventListener("coreApi:failed",_e=>{let Dt=Object.assign({},CONFIGURATOR_FAILED);Dt.parameters={project_id:`${this.#e}`},Dt.event_label=`${this.#e}`,this.sendAnalyticsEvent(Dt)}),this.coreWCRef.addEventListener(this.EVENTS.SCENE.Item_Added,_e=>{LOGGER.info({title:"Add Item",details:_e});const Dt=_e.data.itemData.guid,zt=this.stores.attachmentStore.getState().attachmentSystem.currentStructure.getNodeByGUID(Dt)?.currentVariant,Ht={item_added:`${`${_e.data.itemData.skuID}(${zt})`}`,project_id:`${this.#e}`},Wt=this.stores.coreSceneStore.getState().preconfigurationLoaded==!1&&this.stores.coreSceneStore.getState().sceneHasDefaultConfigurationID==!1,qt=this.stores.coreSceneStore.getState().configurationLoaded==!1&&this.stores.coreSceneStore.getState().preconfigurationLoaded==!0&&this.stores.coreSceneStore.getState().configurationLoadedOnRestart==!0;if(Wt||qt){let Xt=Object.assign({},CONFIGURATOR_PRECONFIGURATION_ITEM_ADDED);Xt.parameters=Ht,this.sendAnalyticsEvent(Xt)}else{let Xt=Object.assign({},CONFIGURATOR_ITEM_ADDED);Xt.parameters=Ht,this.sendAnalyticsEvent(Xt)}}),this.coreWCRef.addEventListener(this.EVENTS.SCENE.Item_Removed,_e=>{if(LOGGER.info({title:"Remove Item"}),_e.data.itemData==null)return;const Dt=_e.data.itemData.skuID;let Vt=Object.assign({},CONFIGURATOR_ITEM_REMOVED);Vt.parameters={item_removed:`${Dt}`,project_id:`${this.#e}`},this.sendAnalyticsEvent(Vt)}),this.coreWCRef.addEventListener(this.EVENTS.SCENE.Hotspot_Enter,_e=>{let Dt=Object.assign({},CONFIGURATOR_HOTSPOT_ENTER);const Vt=_e.data.hotspot?.hotspotData?.title;Dt.parameters={hotspot_entered:`${this.sceneSettings.analyticsEventPrefix}${Vt||_e.data.hotspotAbsID}`,project_id:`${this.#e}`},this.sendAnalyticsEvent(Dt)}),this.coreWCRef.addEventListener(this.EVENTS.SCENE.Hotspot_Exit,_e=>{let Dt=Object.assign({},CONFIGURATOR_HOTSPOT_EXIT);const Vt=_e.data.hotspot?.hotspotData?.title;Dt.parameters={hotspot_exited:`${this.sceneSettings.analyticsEventPrefix}${Vt||_e.data.hotspotAbsID}`,project_id:`${this.#e}`,c_hotspot_time_spent:`${_e.data.hotspotTimeSpent}`},this.sendAnalyticsEvent(Dt)}),this.coreWCRef.addEventListener(this.EVENTS.SCENE.Cart_Checkout,_e=>{let Dt=0,Vt=0,Gt=0;_e.data.cartItems.forEach((jt,Ht)=>{Vt++,Gt+=jt.count,Dt+=jt.price;let Wt=Object.assign({},CONFIGURATOR_CHECKOUT_ITEM);Wt.parameters={client_product_id:jt.clientProductId,count_added_to_cart:jt.count,variant:`${jt.currentVariant}`,total_value:jt.price,epigraph_sku:`${jt.skuID}`,project_id:`${this.#e}`},this.sendAnalyticsEvent(Wt)});let zt=Object.assign({},CONFIGURATOR_CHECKOUT);zt.parameters={cart_total:Dt,unique_items_count:Vt,total_items:Gt,project_id:`${this.#e}`},this.sendAnalyticsEvent(zt)})}getPreconfigurationModuleData(){return this.stores.productDataStore.getState().categoryData.preconfiguration}setEmptySceneText(_e){const Dt=this.stores.coreSceneStore.getState().sceneSettings;Dt.emptySceneText=_e,this.stores.coreSceneStore.setState({sceneSettings:{...Dt}})}getSpawningRequirementForSkuID(_e){return this.stores.attachmentStore.getState().attachmentSystem.currentStructure.getSpawningRequirementForSkuID(_e)}getAllSkusThatCanReplaceGuid(_e){if(!this.stores.itemStore.getState().itemsSpawned[_e])return LOGGER.warn({title:"Item with guid: "+_e+" doesn't exist"}),[];const zt=this.stores.attachmentStore.getState().attachmentSystem.currentStructure.getNodeByGUID(_e);return zt?zt.getAllSkusThatCanReplaceMe():(LOGGER.warn({title:"Node with guid: "+_e+" doesn't exist"}),[])}getCartItems(){return this.stores.attachmentStore.getState().attachmentSystem.getCartItems()}async getCartItemsAsync(){return await this.stores.attachmentStore.getState().attachmentSystem.getCartItemsAsync()}checkout(_e=!1){const Dt=this.stores.attachmentStore.getState().attachmentSystem;this.#m=this.getSceneStructure();let Vt=Dt.getCartItems();return Vt=this.stores.dynamicHookStore.getState().hookOnCheckout(Vt,this),Vt==null?null:(LOGGER.warn({title:"CONFIGURATOR CHECKED OUT: "}),LOGGER.table(Vt),_e===!0||Vt.cartItems.find(Gt=>Gt.countUnavailable>0)===void 0?(this.fireEvent(this.EVENTS.SCENE.Cart_Checkout,Vt),this.alert({alertMsg:"Items from your configuration have been added to your cart.",alertTime:6e3,alertType:"success",alertLabel:"Success",alertId:"itemAdded"})):this.fireEvent(this.EVENTS.SCENE.Cart_OutOfStock,Vt),Vt)}async checkoutAsync(_e=!1){const Dt=this.stores.attachmentStore.getState().attachmentSystem;this.#m=this.getSceneStructure();let Vt=Dt.getCartItems();return Vt=await this.stores.dynamicHookStore.getState().hookOnCheckout(Vt,this),Vt==null?null:(LOGGER.warn({title:"CONFIGURATOR CHECKED OUT: "}),LOGGER.table(Vt),_e===!0||Vt.cartItems.find(Gt=>Gt.countUnavailable>0)===void 0?(this.fireEvent(this.EVENTS.SCENE.Cart_Checkout,Vt),this.alert({alertMsg:"Items from your configuration have been added to your cart.",alertTime:6e3,alertType:"success",alertLabel:"Success",alertId:"itemAdded"})):this.fireEvent(this.EVENTS.SCENE.Cart_OutOfStock,Vt),Vt)}async reloadCheckedoutScene(){if(!this.#m){LOGGER.info({title:"No data found since last checkout"});return}await this.loadSceneFromConfiguration(this.#m)}getCurrentItemsInReplaceableCategory(){return this.stores.attachmentStore.getState().attachmentSystem.currentStructure.getCurrentItemsInReplaceableCategory()}async getSceneAsGlbUrl(){return this.#f===!1?this.#d:(URL.revokeObjectURL(this.#d),this.#d=void 0,this.#d=await getSceneAsGLBUrl(this.stores),this.#f=!1,this.#d)}async getSceneAsUsdzUrl(){return this.#f===!1?this.#p:(URL.revokeObjectURL(this.#p),this.#p=void 0,this.#p=await getSceneAsUsdzUrl(this.stores),this.#f=!1,this.#p)}async generateShareableLink(_e=!1){if(!this.#h&&this.#u)LOGGER.info({title:"Reusing the cached configuration ID that was last saved..."});else{LOGGER.info({title:"Generating a new configuration ID..."});let zt=this.stores.attachmentStore.getState().actions.export(),jt=await this.stores.nexusApiInstance.postExperienceSaveAndShare(this.experienceId,zt);this.#u=jt.payload.save_id}const Dt=window.location.href;let Vt=new URL(Dt);_e===!0&&Vt.searchParams.set("launchInAR",!0),Vt.searchParams.set("projectId",this.projectId),Vt.searchParams.set("epgsharedconfigid",this.#u),this.#h=!1;let Gt=Object.assign({},CONFIGURATOR_SCENE_SHARED);return Gt.parameters={shared_url:`${Vt}`,project_id:`${this.#e}`},this.sendAnalyticsEvent(Gt),Vt.href}closeContextMenu(){this.stores.itemStore.getState().selectedItemData&&this.stores.itemStore.getState().actions.deselectItem()}updatePreloadProgress(_e){const Dt=this.#n;this.#n=_e;const Vt=new CustomEvent("preload:update",{detail:{progress:this.#n}});window.dispatchEvent(Vt),typeof this.#s=="function"&&this.#s(Dt,_e)}alert({alertMsg:_e,alertTime:Dt,alertType:Vt,alertLabel:Gt,persistant:zt=!1,alertId:jt}){this.stores.coreSceneStore.getState().actions.sendAlert({alertMsg:_e,alertTime:Dt,alertType:Vt,alertLabel:Gt,persistant:zt,alertId:jt})}removePersistantAlert(){this.stores.coreSceneStore.setState({persistantAlertData:null})}clickHotspot(_e){let Dt=this.coreWCRef.shadowRootRef.getElementById(_e);Dt&&Dt.click()}exitHotspot(){this.stores.hotspotStore.getState().actions.exitHotspot(!1)}isSystemBusy(){return this.stores.itemStore.getState().isBusy()}async spawnGhostsForSkuID(_e,Dt=!1,Vt){return this.isSystemBusy()?null:await this.stores.ghostStore.getState().actions.spawnGhostsForSkuID(_e,Dt,Vt)}removeAllGhosts(){if(this.stores.itemStore.getState().isBusy())return null;this.stores.ghostStore.getState().actions.clearAllGhosts()}printSceneHierarchy(_e=!1){const Dt=this.stores.coreSceneStore.getState().sceneRef;(function Vt(Gt){const zt=`${Gt.name} < ${Gt.type} >`;_e===!0?console.groupCollapsed(zt):console.group(zt),Gt.children.forEach(Vt),console.groupEnd()})(Dt)}getSceneItems(){const _e=this.stores.itemStore.getState().itemsSpawned;if(typeof _e!="object"){LOGGER.error({title:"There was an error while fetching the scene item count."});return}return _e}getSceneItemCount(){let _e;const Dt=this.stores.itemStore.getState().itemsSpawned;return typeof Dt!="object"&&LOGGER.error({title:"There was an error while fetching the scene item count."}),_e=Object.keys(Dt).length,_e}async spawnItemBySkuID(_e,Dt=!1){if(this.isSystemBusy())return null;const Vt=this.getActiveGhostData();return Vt&&Vt.skuID!==_e?null:(Dt===!0&&!Vt&&await this.spawnGhostsForSkuID(_e,!1,1),await this.stores.itemStore.getState().actions.addItemBySkuID(_e,0))}async spawnItemBySkuIDAndGhostIndex(_e,Dt=0){if(this.stores.itemStore.getState().isBusy())return null;let Vt=null;const Gt=this.getActiveGhostData();return Dt>=0&&Gt.count>Dt&&Gt.skuID==_e&&(Vt=await this.stores.itemStore.getState().actions.addItemBySkuID(_e,Dt)),Vt}async replaceItemBySkuId(_e,Dt){return await this.stores.itemStore.getState().actions.replaceGuidItemBySkuId(_e,Dt)}async replaceItemsBySkuId(_e,Dt){if(!Array.isArray(_e))throw new Error("guids parameter must be an array");try{for(const Vt of _e)await this.replaceItemBySkuId(Vt,Dt);return!0}catch(Vt){throw new Error(`Failed to replace items by SKU ID: ${Vt.message}`)}}async replaceAllItemsBySkuId(_e,Dt){const Vt=[],Gt=this.stores.itemStore.getState().itemsSpawned;Object.keys(Gt).map(zt=>{Gt[zt].itemData.skuID==_e&&Vt.push(zt)});try{for(const zt of Vt)await this.replaceItemBySkuId(zt,Dt);return!0}catch(zt){throw new Error(`Failed to replace items by SKU ID: ${zt.message}`)}}async removeItemByGUID(_e,Dt=!1){if(this.stores.itemStore.getState().isBusy())return null;const Gt=this.stores.attachmentStore.getState().attachmentSystem.currentStructure.getNodeByGUID(_e);return Dt===!1&&Gt.canSwapRoot===!0&&Gt.swapRoot(),await this.stores.itemStore.getState().actions.removeItemByGUID(_e)}triggerItemRemoveModal(_e){const Dt=this.getGuidItemAttachedDependencies(_e);Dt&&this.fireEvent(this.EVENTS.SCENE.ItemRemoveModalTriggered,Dt)}async updateFittingSkuIds(){await this.stores.attachmentStore.getState().actions.updateFittingSkuIds()}rotateItemByGUID(_e){this.stores.attachmentStore.getState().attachmentSystem.currentStructure.rotateNode(_e)}rotateSelectedItem(){const _e=this.stores.itemStore.getState().selectedItemData;if(!_e){LOGGER.info({title:"No current item selected to rotate"});return}const Dt=_e.itemData.guid;return this.stores.attachmentStore.getState().attachmentSystem.currentStructure.rotateNode(Dt),_e}removeLastItemBySkuId(_e){const Dt=this.stores.itemStore.getState().itemsSpawned,Vt=Object.keys(Dt);for(let Gt=Vt.length-1;Gt>=0;Gt--){const zt=Vt[Gt];if(Dt[zt].itemData.skuID===_e){this.doesGuidItemHaveAnAttachedDependency(zt)?(this.selectItemWithGUID(zt),this.triggerItemRemoveModal(zt)):this.removeItemByGUID(zt);break}}}async removeSelectedItem(){const _e=this.stores.itemStore.getState().selectedItemData;if(!_e){LOGGER.info({title:"No current item selected to delete"});return}const Dt=_e.itemData.guid;return this.stores.itemStore.getState().actions.deselectItem(),await this.removeItemByGUID(Dt),LOGGER.info({title:`Removed Item: ${Dt}`}),_e}refocus(){this.stores.coreSceneStore.getState().actions.triggerAutoFocus()}getActiveGhostData(){return this.stores.ghostStore.getState().ghostData}focusOnGhosts(){if(this.stores.ghostStore.getState().ghostParentRef===null){LOGGER.warn({title:"Ghost Parent Reference not found"});return}this.stores.ghostStore.getState().ghostParentRef.children.length<=0?this.stores.coreSceneStore.getState().actions.triggerAutoFocus():this.stores.coreSceneStore.getState().actions.triggerAutoFocus(this.stores.ghostStore.getState().ghostParentRef)}exitSelectedItem(){this.stores.itemStore.getState().actions.deselectItem()}getSelectedItemData(){return this.stores.itemStore.getState().selectedItemData}canSelectedItemRotate(){const _e=this.stores.attachmentStore.getState().attachmentSystem.currentStructure;let Dt=this.getSelectedItemData();return Dt?_e.getNodeByGUID(Dt.itemData.guid).canRotate:!1}canSelectedItemBeRemoved(){const _e=this.stores.attachmentStore.getState().attachmentSystem.currentStructure,Dt=this.getSelectedItemData();return Dt?_e.getNodeByGUID(Dt.itemData.guid).canRemove:!1}canSelectedItemDrag(){const _e=this.stores.attachmentStore.getState().attachmentSystem.currentStructure,Dt=this.getSelectedItemData();return Dt?_e.getNodeByGUID(Dt.itemData.guid).canDrag:!1}doesGuidItemHaveAnAttachedDependency(_e){let Dt=!0;const Gt=this.stores.attachmentStore.getState().attachmentSystem.currentStructure.getNodeByGUID(_e),zt=Gt.isEndNode;return Dt=!zt,zt||Gt.canSwapRoot&&Gt.whichNodesAreAttachedToUs().length==1&&(Dt=!1),Dt}getGuidItemAttachedDependencies(_e){const Dt=this.stores.attachmentStore.getState().attachmentSystem,Vt=this.stores.itemStore.getState().itemsSpawned,Gt=Dt.currentStructure.getNodeByGUID(_e);if(!Gt)return;let zt={[Gt.guid]:{...Vt[Gt.guid]}};return Gt.getAllBranchedNodesAttachedToUs().forEach(Ht=>{zt[Ht.guid]=Vt[Ht.guid]}),zt}doesSelectedItemHasAttachedDependency(){const _e=this.getSelectedItemData();return _e?this.doesGuidItemHaveAnAttachedDependency(_e.itemData.guid):!1}isSelectedItemAnEndNode(){const _e=this.stores.attachmentStore.getState().attachmentSystem.currentStructure,Dt=this.getSelectedItemData();return Dt?_e.getNodeByGUID(Dt.itemData.guid).isEndNode:!1}getCurrentSceneEnvMap(){return this.stores.lightStore.getState().envMapUrl}async switchGlobalGeometryVariant(_e,Dt){if(!_e){LOGGER.WARN({title:"Geometry Category: '"+_e+"' not valid!"});return}this.stores.itemStore.getState().selectedItemData&&this.stores.itemStore.getState().actions.deselectItem(),await this.stores.attachmentStore.getState().attachmentSystem.switchGlobalGeometryVariant(_e,Dt),await wait(1);let Vt=Object.assign({},CONFIGURATOR_GLOBAL_GEOMETRY_VARIANT_SWITCHED);Vt.parameters={variant:`${Dt}`,project_id:`${this.#e}`},this.sendAnalyticsEvent(Vt);const zt=this.stores.productDataStore.getState().categoryData.geometryVariants;let jt=null;if(zt.map(Wt=>{Wt.id==_e&&(jt=Wt)}),!jt)return;const Ht=jt.variants[Dt];this.alert({alertMsg:jt.label.charAt(0).toUpperCase()+jt.label.slice(1)+" was successfully switched to "+Ht.label.charAt(0).toUpperCase()+Ht.label.slice(1)+".",alertTime:3e3,alertType:"success",alertLabel:`${jt.label} Changed`,alertId:"geometryVariantChanged"})}async switchGlobalVariant(_e,Dt=""){if(!_e){LOGGER.WARN({title:"Look Category: '"+_e+"' not valid!"});return}this.stores.itemStore.getState().selectedItemData&&this.stores.itemStore.getState().actions.deselectItem(),LOGGER.info({title:`Changing Global Variant: Category: ${_e} Id: ${Dt}`}),await this.stores.attachmentStore.getState().attachmentSystem.switchGlobalVariant(_e,Dt),await wait(1);let Vt=Object.assign({},CONFIGURATOR_GLOBAL_VARIANT_SWITCHED);Vt.parameters={variant:`${Dt}`,project_id:`${this.#e}`},this.sendAnalyticsEvent(Vt)}async overrideSelectedItemMaterial(_e=""){return this.stores.itemStore.getState().selectedItemData?(await this.stores.itemStore.getState().actions.switchToVariant(this.stores.itemStore.getState().selectedItemData.itemData,_e,!0),!0):!1}async overrideItemMaterialByGuid(_e,Dt){const Vt=this.stores.itemStore.getState().itemsSpawned[_e];if(!Vt)return LOGGER.warn({title:"Item with guid: "+_e+" doesn't exist"}),!1;await this.stores.itemStore.getState().actions.switchToVariant(Vt.itemData,Dt,!0);let Gt=Object.assign({},CONFIGURATOR_LOCAL_VARIANT_SWITCHED);return Gt.parameters={variant:`${Dt}`,project_id:`${this.#e}`},this.sendAnalyticsEvent(Gt),!0}getSelectedItemColors(){let _e=[];if(this.getSelectedItemData()==null)return _e;let Vt=this.getSelectedItemData().itemData.looks;if(Vt){let Gt=this.stores.productDataStore.getState().lookData;Vt.map(zt=>{Gt.hasOwnProperty(zt)&&_e.push(Gt[zt])})}return _e}getCanvasSize(){return this.stores.coreSceneStore.getState().canvasSize}async removeAllVariantOverrides(){return this.stores.itemStore.getState().selectedItemData&&this.stores.itemStore.getState().actions.deselectItem(),await this.stores.attachmentStore.getState().attachmentSystem.removeAllVariantOverrides()}switchCursor(_e){this.stores.coreSceneStore&&this.stores.coreSceneStore.getState().actions.switchCursor(_e)}getSceneStructure(){return this.stores.attachmentStore.getState().actions.export()}getSceneStructureRaw(){return this.stores.attachmentStore.getState().attachmentSystem.currentStructure}getAllConnectionsInScene(){const _e=this.getSceneStructureRaw(),Dt=new Map;for(const Vt of _e.nodes)for(const Gt of Vt.plugs){if(!Gt.attachedPlugGUID)continue;const zt=[Gt.guid,Gt.attachedPlugGUID].sort().join();Dt.has(zt)||Dt.set(zt,{from:Gt,to:Gt.attachedPlug})}return Dt}async loadSceneFromConfiguration(_e){await this.stores.attachmentStore.getState().actions.loadStructure(_e)}async loadSceneFromConfigurationID(_e,Dt=!0){const Vt=await this.stores.attachmentStore.getState().actions.loadSavedStructureFromConfigID(_e);if(!Vt)return null;Dt===!0&&this.stores.attachmentStore.setState({defaultConfig:Vt});let Gt=Object.assign({},CONFIGURATOR_LOAD_FROM_PRECONFIG);Gt.label=`Preconfig ID: ${_e}`,await this.loadSceneFromConfiguration(Vt)}viewInYourSpace(){LOGGER.info({title:"View in your space called from the Core API"});let _e=Object.assign({},CONFIGURATOR_AR_REQUESTED);_e.label="AR Requested",_e.parameters={project_id:`${this.#e}`},this.sendAnalyticsEvent(_e),this.#r.epigraphViewInYourSpaceRef.onViewInYourSpaceButtonClicked()}async shareScene(){const _e=await this.generateShareableLink();let Dt=Object.assign({},CONFIGURATOR_SCENE_SHARED);return Dt.parameters={shared_url:`${_e}`,project_id:`${this.#e}`},this.sendAnalyticsEvent(Dt),_e}async clearScene(){return await this.stores.attachmentStore.getState().attachmentSystem.clear()}async restartScene(){LOGGER.info({title:"Restarting Scene."}),await this.stores.attachmentStore.getState().attachmentSystem.restart();let _e=Object.assign({},CONFIGURATOR_SCENE_RESTARTED);_e.label="Scene Restarted",_e.parameters={project_id:`${this.#e}`},this.sendAnalyticsEvent(_e)}areDimensionsVisible(){return this.stores.coreSceneStore.getState().showDimensions}getCurrentDimensions(){return this.stores.coreSceneStore.getState().boundData}getActiveHotspot(){return this.stores.hotspotStore.getState().activeHotspotData}reviewCartShown(){let _e=Object.assign({},CONFIGURATOR_REVIEW_CART_SHOWN);_e.label="Review Cart shown",_e.parameters={project_id:`${this.#e}`},this.fireEvent(this.EVENTS.UI.ReviewCart_Shown,_e),this.sendAnalyticsEvent(_e)}isGeometryVisibleForGUID(_e,Dt){const Vt={success:!1,result:!1},zt=this.stores.attachmentStore.getState().attachmentSystem.currentStructure.getNodeByGUID(Dt);return zt.ref&&zt.ref.traverse(jt=>{jt.name===_e&&(console.log(jt),Vt.success=!0,Vt.result=jt.visible)}),Vt}reviewCartHidden(){let _e=Object.assign({},CONFIGURATOR_REVIEW_CART_HIDE);_e.label="Review Cart hidden",_e.parameters={project_id:`${this.#e}`},this.fireEvent(this.EVENTS.UI.ReviewCart_Hidden,_e),this.sendAnalyticsEvent(_e)}sendShowInstructionsBtnAnalyticsEvent(){let _e=Object.assign({},CONFIGURATOR_INSTRUCTIONS_BTN_CLICKED);_e.parameters={project_id:`${this.#e}`},this.sendAnalyticsEvent(_e)}sendInstructionsAnalyticsCompletionRate(_e){let Dt=Date.now()-this.#l,Vt=Math.round(Dt/1e3);this.#l=Date.now();let Gt=Object.assign({},CONFIGURATOR_INSTRUCTIONS_COMPLETION_RATE);Gt.parameters={completion_rate:_e,time_spent:Vt,project_id:`${this.#e}`},this.sendAnalyticsEvent(Gt)}showInstructions(){this.fireEvent(this.EVENTS.UI.Instructions_Show),this.#l=Date.now();let _e=Object.assign({},CONFIGURATOR_INSTRUCTIONS_SHOWN);_e.label="Instructions shown",_e.parameters={project_id:`${this.#e}`},this.sendAnalyticsEvent(_e)}showDimensions(){this.stores.coreSceneStore.setState({showDimensions:!0});let _e=Object.assign({},CONFIGURATOR_DIMENSION_SHOWN);_e.label="Dimensions shown",_e.parameters={project_id:`${this.#e}`},this.sendAnalyticsEvent(_e)}hideDimensions(){this.stores.coreSceneStore.setState({showDimensions:!1});let _e=Object.assign({},CONFIGURATOR_DIMENSION_HIDE);_e.label="Dimensions hidden",_e.parameters={project_id:`${this.#e}`},this.sendAnalyticsEvent(_e)}areHotspotsVisible(){return this.stores.hotspotStore.getState().hotspotsVisibility}areHotspotsTemporarilyVisible(){return this.stores.hotspotStore.getState().hotspotsTempVisibility}showAllHotspots(_e=!1){this.stores.hotspotStore.getState().actions.switchHotspotsVisibility(!0,_e)}hideAllHotspots(_e=!1){this.stores.hotspotStore.getState().actions.switchHotspotsVisibility(!1,_e)}getFittingSkuIds(){return this.stores.attachmentStore.getState().attachmentSystem.getFittingSKUIDs()}selectItemWithGUID(_e){const Dt=this.stores.itemStore.getState().itemsSpawned,Vt=this.stores.attachmentStore.getState().attachmentSystem.currentStructure.getNodeByGUID(_e);this.stores.itemStore.getState().actions.setSelectedItemData({...Dt[_e],overrideVariant:Vt.overrideVariant,currentVariant:Vt.currentVariant,offsetX:0,offsetY:0})}async getCurrentCameraDetails(){return new Promise((_e,Dt)=>{this.coreWCRef.addEventListener(this.EVENTS.CONFIGURATION.CameraDetails_Update,Vt=>{_e(Vt.data)},{once:!0}),this.stores.cameraStore.getState().actions.triggerFetchingCamera()})}moveCamera(_e,Dt,Vt=!0){this.stores.hotspotStore.setState({isAnyHotspotActive:!0}),_e&&this.stores.cameraStore.setState({viewPointPosition:ArrToVec3(_e)}),Dt&&this.stores.cameraStore.setState({focusPointPosition:ArrToVec3(Dt)}),this.stores.cameraStore.setState({resetToLastPosition:Vt})}setEnvLightMap(_e){this.stores.lightStore.setState({envMapUrl:_e})}updateInventoryForAllProducts(_e){return this.stores.inventoryStore.getState().actions.updateInventoryForAllProducts(_e),this.getInventoryInfo()}getInventoryInfo(){return JSON.parse(JSON.stringify(this.stores.inventoryStore.getState().inventoryData))}updateCompareAtPricingForAllProducts(_e){this.stores.productDataStore.getState().actions.updateCompareAtPricingForAllProducts(_e);const Vt=this.stores.attachmentStore.getState().attachmentSystem.getCartItems();return Vt&&this.fireEvent(this.EVENTS.SCENE.CartItems_Updated,Vt),this.getCurrentCompareAtPricingInfo()}updatePricingForAllProducts(_e){this.stores.productDataStore.getState().actions.updatePricingForAllProducts(_e);const Vt=this.stores.attachmentStore.getState().attachmentSystem.getCartItems();return Vt&&this.fireEvent(this.EVENTS.SCENE.CartItems_Updated,Vt),this.getCurrentPricingInfo()}async updateCompareAtPricingForAllProductsAsync(_e){this.stores.productDataStore.getState().actions.updateCompareAtPricingForAllProducts(_e);const Vt=await this.stores.attachmentStore.getState().attachmentSystem.getCartItemsAsync();return Vt&&this.fireEvent(this.EVENTS.SCENE.CartItems_Updated,Vt),this.getCurrentCompareAtPricingInfo()}async updatePricingForAllProductsAsync(_e){this.stores.productDataStore.getState().actions.updatePricingForAllProducts(_e);const Vt=await this.stores.attachmentStore.getState().attachmentSystem.getCartItemsAsync();return Vt&&this.fireEvent(this.EVENTS.SCENE.CartItems_Updated,Vt),this.getCurrentPricingInfo()}updatePricingForProduct(_e,Dt,Vt){this.stores.productDataStore.getState().actions.updatePricingForProduct(_e,Dt,Vt);const zt=this.stores.attachmentStore.getState().attachmentSystem.getCartItems();return zt&&this.fireEvent(this.EVENTS.SCENE.CartItems_Updated,zt),this.getCurrentPricingInfo()}updateCompareAtPricingForProduct(_e,Dt,Vt){this.stores.productDataStore.getState().actions.updateCompareAtPricingForProduct(_e,Dt,Vt);const zt=this.stores.attachmentStore.getState().attachmentSystem.getCartItems();return zt&&this.fireEvent(this.EVENTS.SCENE.CartItems_Updated,zt),this.getCurrentCompareAtPricingInfo()}async updatePricingForProductAsync(_e,Dt,Vt){this.stores.productDataStore.getState().actions.updatePricingForProduct(_e,Dt,Vt);const zt=await this.stores.attachmentStore.getState().attachmentSystem.getCartItemsAsync();return zt&&this.fireEvent(this.EVENTS.SCENE.CartItems_Updated,zt),this.getCurrentPricingInfo()}async updateCompareAtPricingForProductAsync(_e,Dt,Vt){this.stores.productDataStore.getState().actions.updateCompareAtPricingForProduct(_e,Dt,Vt);const zt=await this.stores.attachmentStore.getState().attachmentSystem.getCartItemsAsync();return zt&&this.fireEvent(this.EVENTS.SCENE.CartItems_Updated,zt),this.getCurrentCompareAtPricingInfo()}getCurrentPricingInfo(){return this.stores.productDataStore.getState().actions.getCurrentPricingInfo()}getCurrentCompareAtPricingInfo(){return this.stores.productDataStore.getState().actions.getCurrentCompareAtPricingInfo()}async itemDragStart(_e){if(this.stores.itemStore.getState().isBusy())return null;this.stores.coreSceneStore.setState({hoveredGhostIndex:-1}),await this.removeAllGhosts(),this.stores.coreSceneStore.setState({itemDraggedSkuID:_e}),await this.spawnGhostsForSkuID(_e,!1)}async itemDragEnd(){if(this.stores.itemStore.getState().isBusy())return null;const _e=this.stores.coreSceneStore.getState().hoveredGhostIndex;_e!==-1?await this.stores.itemStore.getState().actions.addItemBySkuID(this.stores.coreSceneStore.getState().itemDraggedSkuID,_e):await this.removeAllGhosts(),this.stores.coreSceneStore.setState({itemDraggedSkuID:null,hoveredGhostIndex:-1})}async forceSpawnItem(_e,Dt){const Vt=this.stores.productDataStore.getState().productData,Gt=this.stores.attachmentStore.getState().attachmentSystem;if(!Gt)return;const zt=Gt.currentStructure;if(!zt)return;let jt=zt.getNodeByGUID(Dt);jt?(jt._skuID=_e,jt.generatePlugsForNode(_e)):(jt=new Node$1(this.stores,_e,{guid:Dt,isEndNode:!0,overrideVariant:null,plugs:Vt[_e].plugs}),zt.addNode(jt),zt.connectPlugs({incomingPlug:new Plug({name:"tempPlug",acceptedPlugTypes:[],connectsToPlugTypes:[]},jt),receiverPlug:zt.rootNode.plugs[0]}));const Ht=await this.stores.itemStore.getState().actions.addItemWithTransform({position:new Vector3(0,0,0),rotation:new Quaternion().identity()},_e,Dt);return await wait(1),Ht}async getScreenshotForCurrentCamera(_e){return await this.stores.coreSceneStore.getState().actions.requestNewScreenshot(null,_e)}async getScreenshotForCamera(_e,Dt){return await this.stores.coreSceneStore.getState().actions.requestNewScreenshot(_e,Dt)}async getAllPredefinedScreenshots(_e){const Dt=this.stores.coreSceneStore.getState().sceneSettings.screenshotCameras,Vt=[];for(const Gt of Dt){const zt=await this.stores.coreSceneStore.getState().actions.requestNewScreenshot(Gt,_e);Vt.push(zt)}return Vt}setCameraFocusPointPosition(_e){this.stores.cameraStore.setState({focusPointPosition:_e})}triggerFetchingCamera(){this.stores.cameraStore.getState().actions.triggerFetchingCamera()}async completeItemDrop(){await this.stores.coreSceneStore.getState().actions.completeDropItem()}revertItemDrop(){this.stores.coreSceneStore.getState().actions.revertDropItem()}getCameraFocusPointPosition(){return this.stores.cameraStore.getState().focusPointPosition}sendAnalyticsPageViewedEvent(){}sendAnalyticsEvent(_e){if(this.epigraphAnalytics!==null)try{this.epigraphAnalytics.sendEvent(_e)}catch{LOGGER.info()}}isIosDevice(){return IS_IOS}actionButtonClicked(_e){this.fireEvent(this.EVENTS.SCENE.ActionButton_Clicked,{data:_e.actionButton.data,skuID:_e.skuID,count:_e.count,price:_e.price,compareAtPrice:_e.compareAtPrice,countAvailable:_e.countAvailable,countUnavailable:_e.countUnavailable,currentVariant:_e.currentVariant})}setCartMessage(_e){this.fireEvent(this.EVENTS.SCENE.CartMessage_Update,{cartMessage:_e})}convertQuaternionToEuler(_e){return new Euler(0,0,0,"XYZ").setFromQuaternion(_e)}convertDegreeToRadians(_e){return MathUtils.degToRad(_e)}convertRadiansToDegree(_e){return MathUtils.radToDeg(_e)}createVector3(_e,Dt,Vt){return new Vector3(_e,Dt,Vt)}isFacingInDirection(_e,Dt){return ConfiguratorCoreAPI.forwardVector3.set(0,0,1),Dt.normalize(),ConfiguratorCoreAPI.forwardVector3.applyQuaternion(_e),ConfiguratorCoreAPI.forwardVector3.dot(Dt)>=0}}const EpigraphConfiguratorCore=reactExports.forwardRef(({customVersionId:kt,experienceId:_e,stores:Dt,viewInYourSpaceRef:Vt,configuratorWcRef:Gt,initialConfigId:zt,clientAccessKey:jt,consentPlugin:Ht,consentIdentifier:Wt,gaMeasurementId:qt,builderMode:Xt,id:Kt,disableCart:Yt,apiMode:Zt},Jt)=>{const[nn,rn]=reactExports.useState(null);reactExports.useEffect(()=>{Jt.current&&(Jt.current.identifier="wc-epigraph-configurator-core",Jt.current.epigraphViewInYourSpaceRef=void 0,Jt.current.initialConfigId="",Jt.current.clientAccessKey="",Jt.current.consentPlugin="",Jt.current.consentIdentifier="",Jt.current.gaMeasurementId="",Jt.current.configuratorWcRef=void 0,Jt.current.builderMode=!1,Jt.current.projectId="",Jt.current.api=null,Jt.current.api=new ConfiguratorCoreAPI(Dt,Jt.current),Dt.coreSceneStore.setState({CORE_API:Jt.current.api}),en(Jt.current))},[Jt]),reactExports.useEffect(()=>{Jt.current&&Vt&&(Vt.current&&(Jt.current.epigraphViewInYourSpaceRef=Vt.current),LOGGER.info({title:"ViewInYourSpace is now accessible from the core: "}))},[Jt,Vt]);const Qt=reactExports.useCallback(tn=>{Gt&&(tn.configuratorWCRef=Gt,tn.shadowRootRef=tn.configuratorWCRef.shadowRoot,tn.api.shadowRootRef=tn.shadowRootRef,tn.api.configuratorWCRef=tn.configuratorWCRef),kt&&(tn.customVersionId=kt),zt&&(tn.initialConfigId=zt),jt&&(tn.clientAccessKey=jt),Ht&&(tn.consentPlugin=Ht),Wt&&(tn.consentIdentifier=Wt),qt&&(tn.gaMeasurementId=qt),Xt&&(tn.builderMode=!0),LOGGER.group("Collected Web Component Attributes"),LOGGER.table({initialConfigId:tn.initialConfigId,clientAccessKey:tn.clientAccessKey,consentPlugin:tn.consentPlugin,consentIdentifier:tn.consentIdentifier,builderMode:tn.builderMode}),LOGGER.groupEnd()},[Xt,zt,qt,jt,Gt]),en=reactExports.useCallback(async tn=>{if(tn.coreReady===!0)return;Qt(tn);let sn=kt;!sn&&IS_DEV_ENV&&(sn="latest");let cn={};if(Zt==="input.json"?cn={payload:{project_id:"local-project",experience_id:"",configurator_data:await __vitePreload(()=>import("./input-afb87ea8.js"),[]),session_details:{environment:"development"}},report:"Local Input Json",success:!0}:jt?cn=await Dt.nexusApiInstance.getConfiguratorByClientAccessKey(jt,sn):cn=await Dt.nexusApiInstance.getConfiguratorByExperienceId(_e,sn),tn.validationPassed=cn.success,tn.validationPassed==!1){LOGGER.error({title:"Request from an invalidated source: "+window.location.href}),Dt.coreSceneStore.getState().CORE_API.fireEvent("coreApi:failed");return}Dt.nexusApiResponseEnvironment=cn.payload.session_details.environment,tn.projectId=cn.payload.project_id,tn.experienceId=cn.payload.experience_id,Dt.experienceId=cn.payload.experience_id,tn.api.projectId=tn.projectId,tn.api.experienceId=tn.experienceId;const un=cn.payload.configurator_data,hn={gaMeasurementId:tn.gaMeasurementId??void 0,epgExperienceID:tn.experienceId??void 0};Dt.coreSceneStore.getState().CORE_API.initializeAnalytics(hn,IS_DEV_ENV);let fn=Object.assign({},CONFIGURATOR_LOADING);fn.parameters={project_id:`${tn.projectId}`},Dt.coreSceneStore.getState().CORE_API.sendAnalyticsEvent(fn),LOGGER.info({title:"VALIDATION SUCCESSFUL!"}),tn.coreReady=!0;let pn=new URL(window.location).searchParams;pn.has("epgsharedconfigid")&&(tn.initialConfigId=pn.get("epgsharedconfigid")),rn({projectId:tn.projectId,parsedData:un,customVersionId:tn.customVersionId,clientAccessKey:tn.clientAccessKey,consentPlugin:tn.consentPlugin,consentIdentifier:tn.consentIdentifier,initialConfigId:tn.initialConfigId,builderMode:tn.builderMode})},[]);return reactExports.useEffect(()=>()=>{Dt.coreSceneStore.getState().CORE_API&&Dt.coreSceneStore.getState().CORE_API.fireEvent("coreApi:shutDown")},[]),jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsx("div",{id:Kt,ref:Jt,children:nn&&jsxRuntimeExports.jsx(App$1,{parsedData:nn.parsedData,stores:Dt,clientAccessKey:nn.clientAccessKey,consentPlugin:nn.consentPlugin,consentIdentifier:nn.consentIdentifier,initialConfigId:nn.initialConfigId,builderMode:nn.builderMode,disableCart:Yt!==void 0?Yt:!1})})})}),ViewInYourSpace=React.forwardRef((kt,_e)=>{const[Dt,Vt]=reactExports.useState(!1),[Gt,zt]=reactExports.useState(!1),jt=reactExports.useRef(null),Ht=reactExports.useRef(null),Wt=reactExports.useRef(null),qt=reactExports.useRef(null),Xt=reactExports.useRef(null),Kt=reactExports.useRef(null),Yt=reactExports.useRef(null),Zt=reactExports.useRef(null),Jt=reactExports.useRef(null),nn=reactExports.useRef(null),rn=kt.stores.uiSceneStore(qn=>qn.dialogPopupOpen),Qt=reactExports.useMemo(()=>`*Technical requirements: iOS Version ${_e?.current?.coreApi?.sceneSettings?.technicalRequirements?.minIosVersion??"11"} and later or Android 8 and later.`,[kt]),en=reactExports.useMemo(()=>`*Technical requirements: iOS Version ${_e?.current?.coreApi?.sceneSettings?.technicalRequirements?.minIosVersion??"11"} and later or Android 8 and later.`,[kt]),tn=()=>{kt["asset-src"]&&(_e.current.assetSrc=kt["asset-src"])};reactExports.useEffect(()=>{!_e.current||!jt.current||!Ht.current||!Wt.current||!qt.current||!Xt.current||!Kt.current||!Yt.current||!Zt.current||!Jt.current||!nn.current||(tn(),_e.current.getQRForURL=async(qn,tr)=>await Pn(qn,tr),_e.current.onViewInYourSpaceButtonClicked=async qn=>await yn(),_e.current.assetSrc="",_e.current.iosAssetSrc="",_e.current.arLink="",_e.current.coreApi=void 0,_e.current.arInProgress=!1,_e.current._modelViewerScriptSource="https://cdn.jsdelivr.net/npm/@google/model-viewer@2.x.x/dist/model-viewer.min.js",_e.current._modelViewer=null,_e.current._qrModalContainer=null,dn(),fn(),un(),_e.current._modelViewer.addEventListener("error",qn=>{Cn(qn)}),_e.current._viewInYourSpaceButton.addEventListener("click",qn=>{yn()}),_e.current.canLaunchAR=sn)},[_e,jt,Ht,Wt,qt,Xt,Kt,Yt,Zt,Jt,nn]);const sn=reactExports.useCallback(()=>_e.current._modelViewer.canActivateAR,[]);reactExports.useEffect(()=>{_e.current&&(kt["asset-src"]&&(_e.current.assetSrc=kt["asset-src"]),kt["core-api"]&&(_e.current.coreApi=kt["core-api"]),cn())},[_e,kt]);const cn=()=>{_e.current._modelViewer.setAttribute("src",_e.current.assetSrc),_e.current._modelViewer.setAttribute("ios-src",_e.current.iosAssetSrc),_e.current._modelViewer.style.display="none"},un=()=>{window.customElements.get("model-viewer")===void 0&&hn(),En(),cn(),_e.current._modelViewer.addEventListener("ar-status",qn=>{qn.detail.status==="session-started"?(_e.current._modelViewer.style.display="block",_e.current.arInProgress=!0):(qn.detail.status==="not-presenting"||qn.detail.status==="failed")&&(_e.current._modelViewer.style.display="none",_e.current.arInProgress=!1)})},hn=()=>{_e.current._modelViewerScriptElem=document.createElement("script"),_e.current._modelViewerScriptElem.setAttribute("type","module"),_e.current._modelViewerScriptElem.setAttribute("src",_e.current._modelViewerScriptSource),_e.current._modelViewerScriptElem.setAttribute("id","modelViewerScript"),document.head.appendChild(_e.current._modelViewerScriptElem)},fn=()=>{_e.current._qrModalContainer=qt.current,_e.current._qrCodeImage=Xt.current,_e.current._arLink=Kt.current,_e.current._qrLoader=Yt.current,_e.current.doneViewInYourSpaceBtn=Zt.current,_e.current.doneViewInYourSpaceBtn.addEventListener("click",()=>{pn(),Tn()})},pn=async()=>{if(_e.current._qrCodeImage!==null)for(;_e.current._qrCodeImage.firstChild;)_e.current._qrCodeImage.removeChild(_e.current._qrCodeImage.firstChild)},dn=()=>{_e.current.arDrawer=jt.current,_e.current._launchARButton=Ht.current,_e.current._modelDownloadLoader=Wt.current,_e.current._launchARButton.addEventListener("click",()=>{_e.current.arInProgress!==!0&&Rn()})},mn=()=>{_e.current._modelDownloadLoader.classList.remove("loader-hide")},vn=()=>{_e.current._modelDownloadLoader.classList.add("loader-hide")},_n=()=>{zt(!0),xn(),_e.current.arDrawer.show()},En=()=>{_e.current._modelViewer=Jt.current,_e.current._viewInYourSpaceButton=nn.current},An=()=>{Vt(!0),_e.current._qrModalContainer.show()},Tn=()=>{Vt(!1),_e.current._qrModalContainer.hide()},Cn=qn=>{console.error(`[VIEW-IN-YOUR-SPACE ERROR]: Asset load Errors!!
4650
4650
  Make sure that the URL provided for the asset to be loaded is correct.`),console.error("==============================================================="),console.error(qn),console.error("===============================================================")},yn=qn=>{_e.current.canLaunchAR()===!0?Sn():Fn()},Sn=async qn=>{if(_n(),await wait(1e3),_e.current.coreApi.isIosDevice()){_e.current.iosAssetSrc=await _e.current.coreApi.getSceneAsUsdzUrl(kt.stores);const tr=`${GENERIC_PROJECT_ASSET_DATA_ROOT_URL}/3d-assets/proxy/null-product-proxy.glb`;_e.current.assetSrc=tr}else _e.current.assetSrc=await _e.current.coreApi.getSceneAsGlbUrl(kt.stores);cn(),wn()},wn=()=>{_e.current._launchARButton.disabled=!1,vn()},xn=()=>{_e.current._launchARButton.disabled=!0,mn()},Rn=()=>{_e.current._modelViewer.activateAR()},Dn=()=>{_e.current._qrLoader.classList.remove("loader-hide")},kn=()=>{_e.current._qrLoader.classList.add("loader-hide")},Fn=async()=>{_e.current._qrCodeImage.classList.add("img-hide"),_e.current._qrCodeImage.setAttribute("src",""),Dn(),An(),await Bn(_e.current._qrCodeImage),_e.current._qrCodeImage.classList.remove("img-hide"),kn()},Pn=async(qn,tr)=>{QrCreator$1.render({text:qn,radius:.25,ecLevel:"H",fill:"#000000",background:null,size:200},tr),await wait(250)},Bn=async qn=>{_e.current.arLink=await _e.current.coreApi.generateShareableLink(!0),await _e.current.getQRForURL(_e.current.arLink,qn)};return jsxRuntimeExports.jsxs("div",{...kt,ref:_e,children:[jsxRuntimeExports.jsxs("button",{tabIndex:rn?-1:0,id:"viewInYourSpaceButton",ref:nn,className:"viewInYourSpaceButton",children:[jsxRuntimeExports.jsx("img",{alt:"Close",src:"https://storage.googleapis.com/gsc-epigraph-design/product-assets/Icon/AR.svg",onError:qn=>{qn.target.src="https://placehold.co/150"}}),"VIEW IN YOUR SPACE"]}),jsxRuntimeExports.jsx("model-viewer",{ref:Jt,ar:!0,"ar-modes":"webxr scene-viewer quick-look","ar-scale":"fixed","ar-placement":kt.arplacement,src:"",alt:"Epigraph View In Your Space","camera-controls":!0,style:{visibility:"hidden"}}),jsxRuntimeExports.jsx(FullScreenModal,{stores:kt.stores,open:Gt,id:"arDrawer",ref:jt,children:jsxRuntimeExports.jsxs("div",{className:"launch-ar-content-container",children:[jsxRuntimeExports.jsx("div",{className:"launch-ar-modal-title",children:"View In Your Space®"}),jsxRuntimeExports.jsxs("div",{className:"launch-ar-bottom-content-container",children:[jsxRuntimeExports.jsx("div",{className:"launch-ar-modal-instruction",children:"Click the “Launch AR” button below to begin viewing this product in your space."}),jsxRuntimeExports.jsxs("div",{className:"launch-ar-button-container",children:[jsxRuntimeExports.jsx("img",{id:"modelDownloadLoader",ref:Wt,alt:"Loading...",draggable:"false",className:"spinner-loader",src:PUBLIC_DESIGN_ASSETS_ENDPOINT+"/Animation/Loading.svg",onError:qn=>{qn.target.src="https://placehold.co/150"}}),jsxRuntimeExports.jsx("button",{tabIndex:Gt?0:-1,className:"launch-ar-button",id:"launchARButton",ref:Ht,children:"Launch AR"})]}),jsxRuntimeExports.jsx("div",{className:"launch-ar-modal-requirement",children:en})]}),jsxRuntimeExports.jsxs("div",{id:"arSessionError",className:"launch-ar-modal-error launch-ar-modal-error-hide",children:[" ","Uh Oh! Looks like there was a problem while loading the AR session."," "]})]})}),jsxRuntimeExports.jsx(FullScreenModal,{stores:kt.stores,open:Dt,id:"qrModalContainer",ref:qt,onExit:pn,children:jsxRuntimeExports.jsxs("div",{className:"qr-content-container",children:[jsxRuntimeExports.jsxs("div",{className:"QR-Parent",children:[jsxRuntimeExports.jsx("div",{id:"qrCodeImage",ref:Xt,className:"qr-code-image"}),jsxRuntimeExports.jsx("img",{id:"qrLoader",ref:Yt,alt:"Loading...",draggable:"false",className:"spinner-loader",src:PUBLIC_DESIGN_ASSETS_ENDPOINT+"/Animation/Loading.svg",onError:qn=>{qn.target.src="https://placehold.co/150"}}),jsxRuntimeExports.jsx("div",{id:"arLink",ref:Kt})]}),jsxRuntimeExports.jsxs("div",{className:"QR-Content-Parent",children:[jsxRuntimeExports.jsx("div",{className:"qr-ar-modal-title",children:"Scan QR code"}),jsxRuntimeExports.jsxs("div",{className:"qr-ar-bottom-content-container",children:[jsxRuntimeExports.jsx("div",{className:"qr-ar-modal-instruction",children:"Using your mobile device camera, scan the QR code and follow the on-screen directions to view this item in your space."}),jsxRuntimeExports.jsx("div",{className:"launch-ar-button-container",children:jsxRuntimeExports.jsx("div",{role:"button","aria-label":"Done Button","aria-hidden":!Dt,tabIndex:Dt?0:-1,className:"launch-ar-button",id:"doneViewInYourSpaceBtn",ref:Zt,children:"Done"})}),jsxRuntimeExports.jsx("div",{className:"qr-ar-modal-requirement",children:Qt})]})]}),jsxRuntimeExports.jsxs("div",{id:"arSessionError",className:"launch-ar-modal-error launch-ar-modal-error-hide",children:[" ","Uh Oh! Looks like there was a problem while loading the AR session."," "]})]})})]})}),UI_LOCAL_STYLES=[{id:"variables",contents:StyleVariables},{id:"styles",contents:GenericStyles$1},{id:"accordion",contents:AccordionStyles},{id:"productFeaturesUI",contents:FeaturesUiStyles},{id:"sideMenuContent",contents:SideMenuContentStyles},{id:"build",contents:BuildStyles},{id:"mobile",contents:MobileStyles$1},{id:"bottomDrawer",contents:BottomDrawerStyles},{id:"fullScreenModal",contents:FullScreenModalStyles},{id:"viewInYourSpace",contents:ViewInYourSpaceStyles},{id:"instructionsModal",contents:InstructionsModalStyles}];function App({stores:kt,customVersionId:_e,experienceId:Dt,disableUI:Vt,disableCart:Gt,configuratorWcRef:zt,gaMeasurementId:jt}){const Ht=kt.itemStore(cn=>cn.itemsSpawned),Wt=reactExports.useRef(null),qt=reactExports.useRef(null),Xt=reactExports.useRef(null),Kt=kt.coreSceneStore(cn=>cn.coreReady),Yt=kt.uiSceneStore(cn=>cn.CORE_API),Zt=kt.uiSceneStore(cn=>cn.cssLoaded),Jt=kt.coreSceneStore(cn=>cn.sceneSettings?.arPlacement),nn=kt.uiSceneStore(cn=>cn.setCSSLoaded),rn=reactExports.useRef(null);addCoreEventListener(kt,"coreApi:ready",cn=>{const un=cn.categoryData.geometryVariants;Object.keys(kt.colorStore.getState().allActiveGeometryVariants).length==0&&un.map(fn=>kt.colorStore.getState().allActiveGeometryVariants[fn.id]=Object.keys(fn.variants)[0]);const hn=cn.categoryData.color;if(Object.keys(kt.colorStore.getState().allActiveVariants).length==0&&hn.map(fn=>kt.colorStore.getState().allActiveVariants[fn.id]=fn.looks[0]),cn.configuration&&cn.configuration.globalVariants){const fn=cn.configuration.globalVariants;Object.keys(fn).map(pn=>{kt.colorStore.getState().allActiveVariants[pn]=fn[pn]}),kt.colorStore.setState({allActiveVariants:{...kt.colorStore.getState().allActiveVariants}})}Xt.current.coreApi=Wt.current.api,kt.coreSceneStore.setState({coreReady:!0})}),addCoreEventListener(kt,"coreApi:failed",cn=>{zt.showHiccupScreen(`AUTHENTICATION FAILED FOR: ${window.location.href}`),kt.coreSceneStore.setState({coreReady:!1})}),reactExports.useEffect(()=>{Qt(Ht)},[Ht]),addCoreEventListener(kt,"globalGeometryVariant:updated",cn=>{kt.colorStore.setState({allActiveGeometryVariants:{...cn}});const un=kt.itemStore.getState().itemsSpawned;Qt(un)}),addCoreEventListener(kt,"globalVariant:updated",cn=>{kt.colorStore.setState({allActiveVariants:{...cn}})}),addCoreEventListener(kt,"cartMessage:updated",cn=>{kt.uiSceneStore.setState({cartMessage:cn.cartMessage})});const Qt=cn=>{let un=[],hn=[];const fn=kt.colorStore.getState().allActiveGeometryVariants;Object.keys(cn).map(pn=>{let dn=cn[pn];dn.hotspotsData&&dn.hotspotsData.map(mn=>{if(mn.geometryVariantID){let vn=!1;if(Object.keys(fn).map(_n=>{mn.geometryVariantID==fn[_n]&&(vn=!0)}),vn===!1)return}mn.categoryID!==""&&hn.includes(mn.categoryID)||(hn.push(mn.categoryID),un=[...un,{itemData:{...cn[pn].itemData},hotspotData:{...mn}}])})}),kt.uiSceneStore.setState({tabSpawnCount:un})};addCoreEventListener(kt,"cart:statusUpdated",cn=>{cn.disableCart!==void 0&&kt.uiSceneStore.setState({disableCart:cn.disableCart})}),addCoreEventListener(kt,"viewInYourSpace:hide",cn=>{kt.uiSceneStore.setState({viewInYourSpaceMenuBtnVisible:!1})}),addCoreEventListener(kt,"viewInYourSpace:show",cn=>{kt.uiSceneStore.setState({viewInYourSpaceMenuBtnVisible:!0})});const en=reactExports.useCallback(cn=>{let un=[];const hn=kt.productDataStore.getState().productData;cn.cartItems.forEach(fn=>{let pn={...fn},dn=hn[fn.skuID];pn.title=dn.lookDetails[fn.currentVariant].title,pn.subheading=dn.subheading,pn.subtitle=dn.lookDetails[fn.currentVariant].subtitle,pn.actionButton=dn.lookDetails[fn.currentVariant].actionButton,pn.thumbnails=dn.lookDetails[fn.currentVariant].thumbnails,un.push(pn)}),kt.cartStore.setState({cart:[...un]}),kt.cartStore.getState().actions.setCartTotalPrice(cn.details.total,cn.details.compareAtTotal)},[]),tn=reactExports.useCallback(async cn=>{if(!Yt)return;kt.uiSceneStore.setState({inventoryData:{...cn}});const un=await Yt.getCartItemsAsync();en(un)},[Yt]),sn=()=>(addCoreEventListener(kt,Yt.EVENTS.UI.PreloadScreen_Hide,()=>{zt.api.ui.hidePreloadScreen()}),addCoreEventListener(kt,Yt.EVENTS.UI.PreloadScreen_Show,()=>{zt.api.ui.showPreloadScreen()}),addCoreEventListener(kt,Yt.EVENTS.SCENE.CartItems_Updated,en),addCoreEventListener(kt,Yt.EVENTS.SCENE.Inventory_Updated,tn),jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{}));return reactExports.useEffect(()=>{const{current:cn}=Wt;cn&&(kt.uiSceneStore.setState({coreWCRef:cn}),zt.api.core=cn.api,zt.api.core.clientAccessKey=zt.clientAccessKey,zt.api.core.consentPlugin=zt.consentPlugin,zt.api.core.consentIdentifier=zt.consentIdentifier,kt.uiSceneStore.setState({CORE_API:cn.api}))},[Wt]),reactExports.useEffect(()=>{async function cn(){if(Zt===!1||Kt!==!0)return;const un=await Yt.getCartItemsAsync();en(un),zt.api.ui.hidePreloadScreen()}cn()},[Zt,Kt]),reactExports.useEffect(()=>{const{current:cn}=rn;if(!cn)return;let un=window.getComputedStyle(cn);kt.coreSceneStore.setState({dragImgElRef:cn});const hn=En=>{En.preventDefault();const An=kt.coreSceneStore.getState().mouseDownImgSrc;if(An){const Tn=kt.coreSceneStore.getState().pointerDownPos,Cn=kt.coreSceneStore.getState().moveThreshold,yn=kt.coreSceneStore.getState().mouseDragging,Sn=kt.coreSceneStore.getState().mouseDownSkuID;if(Math.abs(En.clientX-Tn)<=Cn)return;const xn={x:En.offsetX,y:En.offsetY},Rn=cn;Rn.src=An,Rn.style.opacity=.75,Rn.style.left=`calc(${xn.x}px - ${un.width})`,Rn.style.top=`calc(${xn.y}px - ${un.height})`,yn||(kt.coreSceneStore.setState({mouseDragging:!0}),kt.uiSceneStore.getState().CORE_API.itemDragStart(Sn))}},fn=()=>{if(kt.coreSceneStore.getState().mouseDownImgSrc){const An=kt.coreSceneStore.getState().mouseDragging,Tn=cn;Tn.style.opacity=0,An&&kt.uiSceneStore.getState().CORE_API.itemDragEnd(),kt.coreSceneStore.setState({mouseDownImgSrc:null,mouseDragging:!1})}},pn=En=>{const An=kt.coreSceneStore.getState().mouseDownImgSrc;if(An){const Tn=kt.coreSceneStore.getState().pointerDownPos,Cn=kt.coreSceneStore.getState().moveThreshold,yn=kt.coreSceneStore.getState().mouseDragging,Sn=kt.coreSceneStore.getState().mouseDownSkuID;if(En.preventDefault(),Math.abs(En.touches[0].clientX-kt.wcRef.offsetLeft-Tn)<=Cn)return;const xn={x:En.touches[0].clientX-kt.wcRef.offsetLeft,y:En.touches[0].clientY},Rn=cn.parentElement.getBoundingClientRect().top,Dn=cn;if(Dn.src=An,Dn.style.opacity=.75,Dn.style.left=`calc(${xn.x}px - ${un.width})`,Dn.style.top=`calc(${xn.y}px - ${Rn}px - ${un.height})`,!yn){kt.coreSceneStore.setState({mouseDragging:!0});const kn=qt.current.getElementsByClassName("mobileGrid");for(let Fn=0;Fn<kn.length;Fn++)kn[Fn].style="overflow-x:hidden !important";kt.uiSceneStore.getState().CORE_API.itemDragStart(Sn)}}},dn=()=>{if(kt.coreSceneStore.getState().mouseDownImgSrc){const An=kt.coreSceneStore.getState().mouseDragging,Tn=cn;if(Tn.style.left="0px",Tn.style.top="0px",Tn.style.opacity=0,An){kt.uiSceneStore.getState().CORE_API.itemDragEnd();const Cn=qt.current.getElementsByClassName("mobileGrid");for(let yn=0;yn<Cn.length;yn++)Cn[yn].style="overflow-x:auto !important"}kt.coreSceneStore.setState({mouseDownImgSrc:null,mouseDragging:!1})}},mn=window.matchMedia("(orientation: portrait)");function vn(En){kt.uiSceneStore.setState({isScreenPortrait:En.matches})}vn(mn);const _n=kt.wcRef;return _n.addEventListener("mousemove",hn),window.addEventListener("mouseup",fn),_n.addEventListener("touchmove",pn,{passive:!1}),window.addEventListener("touchend",dn),mn.addEventListener("change",vn),()=>{const En=kt.wcRef;En&&(En.removeEventListener("mousemove",hn),En.removeEventListener("touchmove",pn)),window.removeEventListener("mouseup",fn),window.removeEventListener("touchend",dn),mn.removeEventListener("change",vn)}},[rn,qt,Yt]),jsxRuntimeExports.jsxs("div",{className:"configuratorParentDiv",style:{background:kt.cameraStore.getState().cameraSettings.clearColour},ref:qt,children:[Kt&&jsxRuntimeExports.jsx(sn,{}),jsxRuntimeExports.jsx(StyleManager,{stores:kt,containerId:"uiStylesContainer",localStyles:UI_LOCAL_STYLES,dynamicStylesId:"uiStyles",setCSSLoaded:nn}),jsxRuntimeExports.jsx("img",{id:"dragImgElRef",ref:rn,alt:"A placeholder holder element used for drag and drop functionality.",style:{backgroundImage:"url(https://placehold.co/150)"},onError:cn=>{cn.target.src="https://placehold.co/150"}}),jsxRuntimeExports.jsx(EpigraphConfiguratorCore,{stores:kt,ref:Wt,id:"epigraphConfiguratorCore",customVersionId:_e,experienceId:Dt,viewInYourSpaceRef:Xt,gaMeasurementId:jt,...Gt&&{disableCart:""},configuratorWcRef:zt,initialConfigId:zt.initialConfigId,clientAccessKey:zt.clientAccessKey,consentPlugin:zt.consentPlugin,consentIdentifier:zt.consentIdentifier,apiMode:zt.apiMode}),jsxRuntimeExports.jsx(ViewInYourSpace,{stores:kt,ref:Xt,id:"viewInYourSpace",arplacement:Jt}),Kt&&Zt&&jsxRuntimeExports.jsx("div",{className:"uiContainer",children:jsxRuntimeExports.jsx(OverlayUIManager$1,{stores:kt,configuratorWcRef:zt,coreRef:Wt,viewInYourSpaceRef:Xt,disableUI:Vt})})]})}const PRELOAD_MUTED_CSS=document.createElement("template");PRELOAD_MUTED_CSS.innerHTML=`
4651
4651
  <style>
4652
4652
  .preload-main-container{
@@ -4793,4 +4793,4 @@ ${zt.join(`
4793
4793
  There was a problem while trying to initialise the configurator.
4794
4794
  </div>
4795
4795
  </div>
4796
- `;const createCoreSceneStore=kt=>{const _e=coreStoreCreator();return _e.setState({stores:kt}),_e},coreStoreCreator=()=>create((kt,_e)=>({stores:null,shadowRefreshKey:0,CORE_API:null,coreReady:void 0,frameloop:"always",hoveredGhostIndex:-1,itemDraggedSkuID:null,screenshotRenderer:new WebGLRenderer({antiAlias:!0,preserveDrawingBuffer:!0}),screenshotCamera:new PerspectiveCamera(75,1.33,.1,1e3),builderMode:!1,dragging:!1,bbox:null,draggingItemGUID:null,sceneRef:null,cssLoaded:!1,sceneHasDefaultConfigurationID:!1,configurationLoaded:!0,preconfigurationLoaded:!1,configurationLoadedOnRestart:!0,cursorParentRef:null,glContext:null,canvasTooltipText:"",canvasSize:{width:600,height:600},boundData:{center:new Vector3(0,0,0),size:new Vector3(0,0,0)},showDimensions:!1,autoFocusTrigger:0,cameraActive:!1,autoFocusRef:null,alertData:{},persistantAlertData:null,alertQueue:[],currentAlertData:null,alertSettings:null,draggingOnDropCollisionData:null,multipleTouchDetected:!1,isMobile:!1,isTouchDevice:!1,isTablet:!1,isDesktop:!0,isLandscape:!1,sceneSettings:{usdzMaxTextureSize:1024,usdzPrecision:7,swappableRoot:!0,ghostColorOnHoverWithDraggableUi:{r:153,g:252,b:0,a:1},preserveDrawingBuffer:!1,showSaveBtn:!0,showShareBtn:!0,showResetBtn:!0,showDimensionBtn:!0,showViewInYourSpaceBtn:!0,showDependencyOnHover:!1,showContextMenu:!0,showHotspotsBtn:!0,showInstructionsBtn:!1,showInstructionsOnStartup:!1,sceneScaleUnit:"ft",arPlacement:"floor",arTransforms:{position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]},currency:"$",disableDragDrop:!1,ignoreSpawningCollision:!1,disableCollider:!1,disableContextMenu:!1,ghostColor:{r:10,g:10,b:10,a:.2},technicalRequirements:{minIosVersion:"11"},ghostScale:[1,1,1],ghostAsWireframe:!1,draggableUI:!1,addFromInfoModal:!1,clickToAddUi:!0,accordionInBuildUi:!1,outOfStock_EmissiveColor:{r:250,g:50,b:0},outOfStock_EmissiveIntensity:.002,defaultConfigurationID:null,emptySceneText:null,emptySceneTextFontSize:"2rem",addToCartCTAText:"Add To Cart",ignoreCollisionPostDragging:!1,comboPlugDistanceThreshold:.05,disableCart:!1,dimensionColor:{r:0,g:0,b:0},disableLocalColorOverride:!1,analyticsEventPrefix:"",outlineSettings:{multisampling:10,visibleEdgeColor:new Color$1("#0f0").convertSRGBToLinear(),hiddenEdgeColor:new Color$1("#0f0").convertSRGBToLinear(),blur:3,width:1e3,edgeStrength:1e3,blendFunction:BlendFunction.ALPHA,pulseSpeed:0,xRay:!0},textSettings:{arButtonLabel:"AR",arHoverLabel:"View In Your Space",restartButtonLabel:"Restart",restartHoverLabel:"Restart",saveButtonLabel:"Save",saveHoverLabel:"Save",shareButtonLabel:"Share",shareHoverLabel:"Share",sizeButtonLabel:"Size",sizeHoverLabel:"Size",hotspotsButtonLabel:"Hotspots",hotspotsHoverLabel:"Hotspots",instructionsButtonLabel:"Instructions",instructionsHoverLabel:"Instructions",cartQuantityText:"Qty",reviewButtonText:"Review",cartHeadingText:"Review Products",buildTabHeadingText:"Build",colorTabHeadingText:"Color",featuresTabHeadingText:"Features",featuresTabEmptyText:"*Please add an item to the scene to see the features",tooltipEmptySceneText:"",tooltipInstructionText:"-Drag to rotate the camera-"},variantsTabOrder:{color:{enabled:!0,priority:1},geometryVariants:{enabled:!0,priority:2}},boundingBoxLeeway:.9,contactShadowVisibility:!0,measurementPrecision:2,disableAlerts:!1,focusCameraOnGhosts:!0,alertLevel:2999,alertControl:{default:!0,itemAdded:!0,geometryVariantChanged:!0,overridesRemoved:!0,materialVariantChanged:!0,itemRemoved:!0,itemRepositioned:!0,configurationSaved:!0,linkCopied:!0,outOfStock:!0,unvisualizedItemSpawn:!0},screenshotCameras:[{position:new Vector3(-2.5,.6,-5),rotation:new Vector3(-3.1097068566150314,-.6437852162982552,-3.122449778846033)},{position:new Vector3(3,1,-5),rotation:new Vector3(-.5,1,.5)}],instructionsSettings_desktop:[{header:"Add to Scene",description:"Click to add individual modules to the scene.",lottieURL:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_1A_Drag_Drop/Non-furniture_Step_1A.json"},{header:"Rearrange Modules",description:"Drag & drop individual modules in the scene to rearrange.",lottieURL:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_2/Non-furniture_Step_2.json"},{header:"Remove Modules",description:"Click to select and remove individual modules from the scene.",lottieURL:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_3/Non-furniture_Step_3.json"}],instructionsSettings_mobile:[{header:"Add to Scene",description:"Click to add individual modules to the scene.",lottieURL:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_1A_Drag_Drop_Mobile/Mobile_Non-furniture_Step_1A.json"},{header:"Rearrange Modules",description:"Drag & drop individual modules in the scene to rearrange.",lottieURL:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_2/Non-furniture_Step_2.json"},{header:"Remove Modules",description:"Tap to select and remove individual modules from the scene.",lottieURL:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_3/Non-furniture_Step_3.json"}],defaultInstructionsSettings:{step1_drag:{mobile:{header:"Add to Scene",description:"Drag & drop individual modules to add to the scene.",lottieURL:{furniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Furniture/Furniture_Step_1A_Drag_Drop_Mobile/Mobile_Furniture_Step_1A.json",nonFurniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_1A_Drag_Drop_Mobile/Mobile_Non-furniture_Step_1A.json"}},desktop:{header:"Add to Scene",description:"Drag & drop individual modules to add to the scene.",lottieURL:{furniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Furniture/Furniture_Step_1A_Drag_Drop/Furniture_Step_1A.json",nonFurniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_1A_Drag_Drop/Non-furniture_Step_1A.json"}}},step1_add:{mobile:{header:"Add to Scene",description:"Click to add individual modules to the scene.",lottieURL:{furniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Furniture/Furniture_Step_1B_Click_Add_Mobile/Mobile_Furniture_Step_1B.json",nonFurniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_1B_Click_Add_Mobile/Mobile_Non-furniture_Step_1B.json"}},desktop:{header:"Add to Scene",description:"Click to add individual modules to the scene.",lottieURL:{furniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Furniture/Furniture_Step_1B_Click_Add/Furniture_Step_1B.json",nonFurniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_1B_Click_Add/Non-furniture_Step_1B.json"}}},step2:{mobile:{header:"Rearrange Modules",description:"Drag & drop individual modules in the scene to rearrange.",lottieURL:{furniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Furniture/Furniture_Step_2/Furniture_Step_2.json",nonFurniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_2/Non-furniture_Step_2.json"}},desktop:{header:"Rearrange Modules",description:"Drag & drop individual modules in the scene to rearrange.",lottieURL:{furniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Furniture/Furniture_Step_2/Furniture_Step_2.json",nonFurniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_2/Non-furniture_Step_2.json"}}},step3:{mobile:{header:"Remove Modules",description:"Tap to select and remove individual modules from the scene.",lottieURL:{furniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Furniture/Furniture_Step_3/Furniture_Step_3.json",nonFurniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_3/Non-furniture_Step_3.json"}},desktop:{header:"Remove Modules",description:"Click to select and remove individual modules from the scene.",lottieURL:{furniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Furniture/Furniture_Step_3/Furniture_Step_3.json",nonFurniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_3/Non-furniture_Step_3.json"}}}}},setCSSLoaded:Dt=>{kt({cssLoaded:Dt})},actions:{refreshShadows:()=>{const{shadowRefreshKey:Dt}=_e();kt({shadowRefreshKey:Dt+1})},popFromAlertQueue:()=>{const{alertQueue:Dt}=_e();return Dt.shift(),kt({alertQueue:Dt}),Dt},addToAlertQueue:Dt=>{const{alertQueue:Vt,currentAlertData:Gt}=_e();return Vt.length>0&&Vt[Vt.length-1].alertId&&Dt.alertId===Vt[Vt.length-1].alertId||Vt.length==0&&Gt&&Gt.alertId&&Gt.alertId==Dt.alertId||(Vt.push(Dt),kt({alertQueue:Vt})),Vt},getDeviceState:()=>{const{isDesktop:Dt,isMobile:Vt,isTablet:Gt,isTouchDevice:zt,isLandscape:jt}=_e();return{isDesktop:Dt,isMobile:Vt,isTablet:Gt,isTouchDevice:zt,isLandscape:jt}},enableCart:()=>{const{sceneSettings:Dt,CORE_API:Vt,stores:Gt}=_e();Dt.disableCart=!1,Gt.inventoryStore.getState().actions.refreshInventory(Gt.itemStore.getState().itemsSpawned),Vt.fireEvent(Vt.EVENTS.SCENE.Cart_StatusUpdated,{disableCart:!1})},disableCart:()=>{const{sceneSettings:Dt,CORE_API:Vt,stores:Gt}=_e();Dt.disableCart=!0,Gt.inventoryStore.getState().actions.refreshInventory(Gt.itemStore.getState().itemsSpawned),Vt.fireEvent(Vt.EVENTS.SCENE.Cart_StatusUpdated,{disableCart:!0})},getSceneSettings:()=>{const{sceneSettings:Dt}=_e();return Dt},sendAlert:Dt=>{kt({alertData:{...Dt}})},switchCursor(Dt){const{cursorParentRef:Vt}=_e();if(!Vt)return;let Gt="";switch(Dt){default:case CURSORS.GRAB:Gt="grabCursor";break;case CURSORS.GRABBING:Gt="grabbingCursor";break;case CURSORS.BLOCKED:Gt="blockedCursor";break;case CURSORS.POINTER:Gt="pointerCursor";break;case CURSORS.MOVE:Gt="moveCursor";break}for(let zt=0;zt<Vt.classList.length;zt++)Vt.classList[zt].includes("Cursor")&&Vt.classList.remove(Vt.classList[zt]);Vt.classList.add(Gt)},setAlertSettings:Dt=>{kt({alertSettings:Dt})},async completeDropItem(){const{draggingOnDropCollisionData:Dt,CORE_API:Vt,stores:Gt}=_e(),zt=Gt.attachmentStore.getState().attachmentSystem,{node:jt,attachedChildrenGuids:Ht,collidingStatus:Wt,intersectingGhostObject:qt,initPosition:Xt,initRotation:Kt,detachedPlugs:Yt,attachedNodesToCurrentNode:Zt}=Dt;Vt.alert({alertMsg:"Item(s) have been removed",alertTime:7e3,alertType:"info",alertLabel:"Item(s) Removed",alertId:"itemRemoved"});for(const[Qt,en]of Ht.entries())Wt[Qt]===!0&&await Gt.itemStore.getState().actions.removeItemByGUID(en);const Jt=qt.userData;let nn=jt.getPlugByName(Jt.incomingPlugName),rn=zt.currentStructure.getPlugByGUID(Jt.receiverPlugGUID);jt.ref.position.set(qt.position.x,qt.position.y,qt.position.z),jt.ref.setRotationFromEuler(qt.rotation),jt.transform={position:qt.position,rotation:qt.quaternion},zt.currentStructure.connectPlugs({incomingPlug:nn,receiverPlug:rn}),Gt.ghostStore.getState().actions.clearAllGhosts(),Gt.itemStore.getState().actions.deselectItem(),Zt.map(Qt=>{jt.ref.parent.attach(Qt.ref),Qt.transform={position:Qt.ref.position,rotation:Qt.ref.quaternion},jt.dragging=!1,Qt.dragging=!1}),await Gt.attachmentStore.getState().actions.updateFittingSkuIds()},async revertDropItem(){const{draggingOnDropCollisionData:Dt,stores:Vt}=_e(),Gt=Vt.attachmentStore.getState().attachmentSystem,{node:zt,attachedChildrenGuids:jt,collidingStatus:Ht,intersectingGhostObject:Wt,initPosition:qt,initRotation:Xt,detachedPlugs:Kt,attachedNodesToCurrentNode:Yt}=Dt;CORE_API.alert({alertMsg:"Position of item"+zt.skuID+"is being moved to it's original position",alertTime:4e3,alertType:"info",alertLabel:"Repositioning",alertId:"itemRepositioned"});const Zt=Kt.neighbourDetachedPlugs;Zt&&(Kt.neighbourNode.detachNodeFromReceiver(),Gt.currentStructure.connectPlugs({incomingPlug:Zt.incomingPlug,receiverPlug:Zt.receiverPlug}));let Jt=Kt.rootDetachedPlugs.incomingPlug,nn=Kt.rootDetachedPlugs.receiverPlug;zt.ref.position.set(qt.x,qt.y,qt.z),zt.ref.setRotationFromEuler(Xt);let rn=new Quaternion().identity();zt.ref.getWorldQuaternion(rn),zt.transform={position:qt,rotation:rn},Gt.currentStructure.connectPlugs({incomingPlug:Jt,receiverPlug:nn}),Vt.ghostStore.getState().actions.clearAllGhosts(),Vt.itemStore.getState().actions.deselectItem(),Yt.map(Qt=>{zt.ref.parent.attach(Qt.ref),Qt.transform={position:Qt.ref.position,rotation:Qt.ref.quaternion},zt.dragging=!1,Qt.dragging=!1}),await Vt.attachmentStore.getState().actions.updateFittingSkuIds()},setCoreSettings:Dt=>{const{sceneSettings:Vt,isMobile:Gt,isTouchDevice:zt,isLandscape:jt,actions:Ht}=_e(),Wt=Gt===!0?"mobile":"desktop",qt=["showSave","showShare","showReset","showDimension","showHotspots","showInstructionsBtn","showViewInYourSpace","showContextMenu","showInstructionsOnStartup","draggableUI","clickToAddUi","textSettings","alertControl","variantsTabOrder","emptySceneTextFontSize","instructionsSettings"];for(const Xt of qt)if(Xt==="draggableUI"||Xt==="clickToAddUi"||Xt==="emptySceneTextFontSize"||Xt==="showInstructionsOnStartup"||Xt==="showInstructionsBtn"||Xt==="instructionsSettings"){const Yt=`${Xt}_${jt===!1&&zt===!0?"mobile":"desktop"}`;Dt[Yt]!==void 0?Vt[Xt]=Dt[Yt]:Vt[Yt]!==void 0&&(Vt[Xt]=Vt[Yt])}else if(Xt==="textSettings"||Xt==="variantsTabOrder"||Xt==="alertControl"||Xt==="outlineSettings"){if(Dt.hasOwnProperty(Xt)){let Kt=Vt[Xt];Object.keys(Kt).map(Yt=>{let Zt=Dt[Xt];Zt.hasOwnProperty(Yt)?(Yt==="visibleEdgeColor"||Yt==="hiddenEdgeColor")&&(Zt[Yt]=new Color$1(Zt[Yt]).convertSRGBToLinear()):Zt[Yt]=Kt[Yt]})}}else{const Kt=`${Xt}_${Wt}`;if(Dt[Kt]!==void 0){let Yt=`${Xt}Btn`;Xt=="showContextMenu"&&(Yt=`${Xt}`),Vt[Yt]=Dt[Kt]}}Dt.disableCart===!0&&Ht.disableCart(),Object.keys(Dt).map(Xt=>Vt[Xt]=Dt[Xt]),Vt.emptySceneText===null&&(Vt.emptySceneTextFontSize=Gt?"1.2rem":"1.5rem",Vt.draggableUI===!0?Vt.emptySceneText="Drag an item here to get started":Vt.emptySceneText="Select an item to get started"),kt({sceneSettings:{...Vt,ghostThreeColor:{r:Vt.ghostColor.r/255,g:Vt.ghostColor.g/255,b:Vt.ghostColor.b/255,a:Vt.ghostColor.a/255},draggableUiGhostThreeColorOnHover:{r:Vt.ghostColorOnHoverWithDraggableUi.r/255,g:Vt.ghostColorOnHoverWithDraggableUi.g/255,b:Vt.ghostColorOnHoverWithDraggableUi.b/255,a:Vt.ghostColorOnHoverWithDraggableUi.a/255}}})},triggerAutoFocus:(Dt=null)=>kt(Vt=>({autoFocusRef:Dt,autoFocusTrigger:Vt.autoFocusTrigger+1})),requestNewScreenshot:async(Dt,Vt)=>{const{CORE_API:Gt}=_e();return new Promise(async(zt,jt)=>{LOGGER.info({title:"Taking a screenshot"});const{screenshotRenderer:Ht,sceneRef:Wt,screenshotCamera:qt,canvasSize:Xt}=_e(),Kt=await Gt.getCurrentCameraDetails();if(Ht.setClearColor(16777215),qt.copy(Kt),Dt!==null&&(qt.position.copy(Dt.position),qt.rotation.copy(new Euler(Dt.rotation.x,Dt.rotation.y,Dt.rotation.z))),Vt==null?Ht.setSize(Xt.width,Xt.height):Ht.setSize(Vt.width,Vt.height),Ht.render(Wt.parent,qt),Ht.preserveDrawingBuffer===!1)LOGGER.warn({title:"Preserve Drawing Buffer must be enabled to take a screenshot. Please make sure to enable this within the project input data coreSettings"}),jt({success:!1,imageData:null});else{LOGGER.info({title:"Downloading the screenshot"});const Yt=Ht.domElement.toDataURL("image/png").replace("image/png","image/octet-stream");zt({success:!0,imageData:Yt})}})}}})),createProductDataStore=kt=>{const _e=productDataStoreCreator();return _e.setState({stores:kt}),_e},productDataStoreCreator=()=>create((kt,_e)=>({stores:null,productData:{},categoryData:{},lookData:{},hotspotsData:{},endpoints:{},assetsData:void 0,actions:{getCurrentCompareAtPricingInfo:()=>{const{productData:Dt}=_e();let Vt={};return Object.keys(Dt).map(Gt=>{if(Gt.toLowerCase()==="root")return;let zt=Dt[Gt].lookDetails,jt={};Object.keys(zt).map(Ht=>{Ht!="default"&&(jt[Ht]=zt[Ht].compareAtPrice)}),Vt[Gt]=jt}),Vt},getCurrentPricingInfo:()=>{const{productData:Dt}=_e();let Vt={};return Object.keys(Dt).map(Gt=>{if(Gt.toLowerCase()==="root")return;let zt=Dt[Gt].lookDetails,jt={};Object.keys(zt).map(Ht=>{Ht!="default"&&(jt[Ht]=zt[Ht].price)}),Vt[Gt]=jt}),Vt},updateCompareAtPricingForAllProducts:Dt=>{const{actions:Vt}=_e();Object.keys(Dt).map(Gt=>{let zt=Dt[Gt];Object.keys(zt).map(jt=>{Vt.updateCompareAtPricingForProduct(Gt,jt,zt[jt])})})},updatePricingForAllProducts:Dt=>{const{actions:Vt}=_e();Object.keys(Dt).map(Gt=>{let zt=Dt[Gt];Object.keys(zt).map(jt=>{Vt.updatePricingForProduct(Gt,jt,zt[jt])})})},updateCompareAtPricingForProduct:(Dt,Vt,Gt)=>{const{productData:zt,stores:jt}=_e();let Ht=zt[Dt];if(!Ht||!Ht.lookDetails)return;let Wt=Ht.lookDetails[Vt];if(!Wt)return;Wt.compareAtPrice=Gt,jt.attachmentStore.getState().attachmentSystem.currentStructure.getNodesBySKUID(Dt).map(Kt=>Kt.updateCompareAtPricing())},updatePricingForProduct:(Dt,Vt,Gt)=>{const{productData:zt,stores:jt}=_e();let Ht=zt[Dt];if(!Ht||!Ht.lookDetails)return;let Wt=Ht.lookDetails[Vt];if(!Wt)return;Wt.price=Gt,jt.attachmentStore.getState().attachmentSystem.currentStructure.getNodesBySKUID(Dt).map(Kt=>Kt.updatePricing())},setProductData:Dt=>{const{stores:Vt}=_e();let Gt={};Dt&&Object.keys(Dt).map(zt=>{const jt=Dt[zt];if(jt.skuID=zt,jt.skuID.toLowerCase()==="root"){jt.lookDetails={default:{title:"",description:"",productPageUrl:"",thumbnails:{high:"",low:""},price:0}},jt.defaultVariant="default";return}if(jt?.lookDetails){const Ht=jt.lookDetails;let Wt=Object.keys(jt.lookDetails);if(Wt.includes("default")){const Xt=Wt.indexOf("default");Wt.splice(Xt,1)}jt.looks=Wt,Object.keys(jt.lookDetails).map(Xt=>{let Kt=jt.lookDetails[Xt];Kt.inventory===void 0&&(Kt.inventory=DEFAULT_INVENTORY),Kt.price===void 0&&(Kt.price=DEFAULT_PRODUCT_PRICE),Kt.compareAtPrice===void 0&&(Kt.compareAtPrice=DEFAULT_PRODUCT_COMPARE_AT_PRICE),Gt[zt]={...Gt[zt],[Xt]:{inventory:DEFAULT_INVENTORY,inScene:[]}}});let qt=jt?.defaultVariant;qt||(LOGGER.warn({title:`No defaultVariant set for ${jt.skuID}. Attempting to auto resolve but the colour variants behaviour might be unexpected!`}),qt=Object.keys(jt.lookDetails).sort()[0],LOGGER.warn({title:"Auto resolved default look ID: "+qt})),Wt.includes(qt)?(jt.lookDetails.default=Ht[qt],jt.lookDetails.default.id=qt):(LOGGER.error({title:`Default look [ ${qt} ] doesn't exist for: ${zt}. Please make sure to select a default variant in Input Data for this project`}),jt.lookDetails.default=null)}}),LOGGER.info({title:"PRODUCT DATA: ",details:Dt}),Vt.inventoryStore.setState({inventoryData:Gt}),kt({productData:Dt})},setCategoryData:Dt=>{const{productData:Vt}=_e();Dt.geometryVariants!==void 0&&Dt.geometryVariants.map(Gt=>{Gt.defaultVariant===void 0&&Object.keys(Gt.variants).length>0&&(Gt.defaultVariant=Object.keys(Gt.variants)[0])}),Dt.color!==void 0&&Dt.color.map(Gt=>{(Gt.defaultLook===void 0&&Gt.looks.length>0||!Gt.looks.includes(Gt.defaultLook))&&(Gt.defaultLook=Gt.looks[0])}),kt({categoryData:Dt}),Dt.build!==void 0&&Dt.build.map(Gt=>{Gt.skus.map(zt=>{Vt[zt].categoryID=Gt.categoryID,Vt[zt].categoryLabel=Gt.label,Vt[zt].swappable=Gt.swappable?Gt.swappable:!1,Vt[zt].replace=Gt.replace})})},getProductDataById:Dt=>{const{productData:Vt}=_e();let Gt=null;return Vt[Dt]&&(Gt=Vt[Dt]),Gt},setLookData:Dt=>kt({lookData:Dt}),setHotspotsData:Dt=>{const{categoryData:Vt,productData:Gt}=_e();Vt.geometryVariants&&Object.keys(Dt).map(zt=>{Dt[zt].map(jt=>{jt.geometryVariantID&&Vt.geometryVariants.map(Ht=>{Object.keys(Ht.variants).map(Wt=>{jt.geometryVariantID==Wt&&Ht.productsInCategory.map(qt=>{let Xt=null;qt.products.map(Kt=>{Dt.hasOwnProperty(Kt)&&(Xt=Dt[Kt])}),qt.products.map(Kt=>{Dt.hasOwnProperty(Kt)||(Dt[Kt]=Xt)})})})})})}),kt({hotspotsData:Dt})},setAssetsData:Dt=>kt({assetsData:Dt})}})),createItemStore=kt=>{const _e=itemStoreCreator();return _e.setState({stores:kt}),_e},itemStoreCreator=()=>create((kt,_e)=>({stores:null,variantChangeAlert:!1,focusedGUID:null,removeItems:[],removeItemTrigger:!1,itemsSpawned:{},itemsCount:0,modelLoadedAlert:0,lastDeletedItemData:null,lastDeletedItemsData:[],hoveredItemRef:{},collidersRef:[],fittingSkuIds:[],filteredCollidersRef:[],selectedItemData:null,defaultSceneItemCount:0,busySpawningItem:!1,busyReplacingItem:!1,busySpawningDependency:!1,busyDraggingItem:!1,busyRemovingItem:!1,isBusy:()=>{const{busySpawningItem:Dt,busyReplacingItem:Vt,busySpawningDependency:Gt,busyDraggingItem:zt,busyRemovingItem:jt}=_e();return Dt||Vt||Gt||zt||jt},actions:{triggerModelLoaded:()=>{kt(Dt=>({modelLoadedAlert:Dt.modelLoadedAlert+1}))},triggerRemoveItem:()=>{kt(Dt=>({removeItemTrigger:!Dt.removeItemTrigger}))},addToRemoveItems:Dt=>{const{removeItems:Vt}=_e();Vt.push(Dt)},switchToVariant:async(Dt,Vt,Gt=!1)=>{const{variantChangeAlert:zt,stores:jt}=_e(),Ht=jt.productDataStore.getState().categoryData;let qt=jt.attachmentStore.getState().attachmentSystem.currentStructure.getNodeByGUID(Dt.guid);const Xt=jt.assetStore.getState().assets.items,Kt=qt.ref.getObjectByName("GRP_RenderGeometry");Xt[Dt.skuID].data||Ht.geometryVariants&&Ht.geometryVariants.map(Yt=>{Yt.productsInCategory.map(Zt=>{let Jt=!1;Zt.products.map(nn=>{nn==Dt.skuID&&(Jt=!0)}),Jt&&Zt.products.map(nn=>{const rn=jt.assetStore.getState().assets.items[nn].data;rn&&(jt.assetStore.getState().assets.items[Dt.skuID].data=rn)})})}),qt.modelFunctions&&(await qt.modelFunctions.selectVariant(Kt,Vt),Gt?(qt.overrideVariant=Vt,jt.coreSceneStore.getState().CORE_API.fireEvent(jt.coreSceneStore.getState().CORE_API.EVENTS.SCENE.MaterialOverrides_Exists,!0)):qt.currentVariant=Vt,kt({variantChangeAlert:!zt}))},clearAllItems:()=>{kt({itemsSpawned:{},itemsCount:0,lastDeletedItemsData:[],hoveredItemRef:[],collidersRef:[],filteredCollidersRef:[],selectedItemData:null})},setItemsSpawned:Dt=>{kt({itemsSpawned:Dt,itemsCount:Object.keys(Dt).length})},setHoveredItemRef:Dt=>kt({hoveredItemRef:Dt}),setCollidersRef:Dt=>{const{stores:Vt}=_e();kt({collidersRef:Dt});let Gt=[];for(let zt=0;zt<Dt.length;zt++)Dt[zt].current&&Gt.push(Dt[zt]);Vt.itemStore.setState({filteredCollidersRef:[...Gt]})},setSelectedItemData:Dt=>{const{selectedItemData:Vt,hoveredItemRef:Gt,actions:zt,stores:jt}=_e();Vt&&(delete Gt[Vt.itemData.guid],zt.setHoveredItemRef({...Gt})),kt({selectedItemData:{...Dt}}),jt.hotspotStore.getState().actions.switchHotspotsVisibility(!1,!0),jt.cameraStore.getState().actions.canCameraRotate(!1)},deselectItem:()=>{const{selectedItemData:Dt,stores:Vt}=_e();Dt&&Vt.coreSceneStore.getState().CORE_API.fireEvent(Vt.coreSceneStore.getState().CORE_API.EVENTS.UI.ContextMenu_Hide,Dt),kt(()=>({selectedItemData:null})),Vt.hotspotStore.getState().actions.switchHotspotsVisibility(!0,!0),Vt.cameraStore.getState().actions.canCameraRotate(!0),Vt.itemStore.getState().actions.setHoveredItemRef({})},removeItemByGUID:async Dt=>{const{itemsSpawned:Vt,actions:Gt,stores:zt}=_e();if(Vt.hasOwnProperty(Dt))return kt({busyRemovingItem:!0}),new Promise(async(jt,Ht)=>{const Wt=qt=>{Dt===qt.data.itemData.guid&&(kt({busyRemovingItem:!1}),jt(Dt))};zt.coreSceneStore.getState().CORE_API.coreWCRef.addEventListener(zt.coreSceneStore.getState().CORE_API.EVENTS.SCENE.Item_Removed,Wt,{once:!0}),Gt.addToRemoveItems(Dt),Gt.triggerRemoveItem()})},addItemBySkuID:async(Dt,Vt=0,Gt=!1,zt)=>{kt({busySpawningItem:!0});const{actions:jt,itemsSpawned:Ht,stores:Wt}=_e(),qt=Wt.productDataStore.getState().productData,Xt=Wt.productDataStore.getState().hotspotsData,Kt=Wt.attachmentStore.getState().attachmentSystem;let Yt=!0;const Zt=await new Promise(async(Jt,nn)=>{if(LOGGER.info({title:`Spawning item: ${Dt}`}),jt.deselectItem(),!qt[Dt]){LOGGER.warn({title:`Product not found: ${Dt}`}),Wt.coreSceneStore.getState().CORE_API.alert({alertMsg:Dt+": product not found!",alertTime:5e3,alertType:"warn",alertLabel:"Not Found"}),Yt=!1,nn(Dt+": product not found!");return}const rn=[...Wt.ghostStore.getState().ghostsTransform],Qt={...Wt.ghostStore.getState().ghostData};if(rn.length<=0){Wt.coreSceneStore.getState().CORE_API.alert({alertMsg:"Unable to add item to configuration",alertTime:6e3,alertType:"warn",alertLabel:"Action Unavailable"}),Yt=!1,nn("No available connections for this product to attach to");return}const en=tn=>{Dt===tn.data&&Jt(Qt.newNodes[Vt].guid)};if(Wt.coreSceneStore.getState().CORE_API.coreWCRef.addEventListener(Wt.coreSceneStore.getState().CORE_API.EVENTS.SCENE.Model_Loaded,en,{once:!0}),Qt.addItemOrSwap[Vt]=="replace")await replaceItem(kt,Wt,Ht,Qt.skuID,rn[Vt],Qt.newNodes[Vt]);else{Wt.ghostStore.getState().actions.clearAllGhosts();const tn=Qt.newNodes[Vt];tn.isDependent=Gt;let sn=!0;if(qt[Qt.skuID].hasOwnProperty("disableInteraction")){const fn=qt[Qt.skuID].disableInteraction;(fn==!0||fn==!1)&&(sn=!fn)}zt!=null&&(sn=zt),tn.isInteractive=sn;const{position:cn,rotation:un}=rn[Vt];tn.transform={position:cn,rotation:un},Kt.currentStructure.addNode(tn),Qt.connectablePlugs[Vt].receiverPlug.type=="unvisualizedPlug"&&Wt.coreSceneStore.getState().CORE_API.alert({alertMsg:"This product is not shown in your 3D configuration but can be found in your shopping list.",alertTime:3e3,alertType:"warn",alertLabel:"Internal Storage",persistant:!1,alertId:"unvisualizedItemSpawn"}),Qt.comboPlugs[Vt].length>0&&Qt.connectablePlugs[Vt].incomingPlug.type=="comboPlug"&&Qt.comboPlugs[Vt].map(fn=>{Kt.currentStructure.connectPlugs(fn)}),Qt.connectablePlugs[Vt].incomingPlug.comboPlugConnector=!0,Kt.currentStructure.connectPlugs(Qt.connectablePlugs[Vt]);const hn=await Wt.assetStore.getState().actions.loadProxyAsset(Qt.skuID,!0);LOGGER.info({title:"GHOST NEW NODE: ",details:tn}),Ht[tn.guid]={itemData:{proxyScene:hn.proxy.data.scene,guid:Qt.newNodes[Vt].guid,...qt[Qt.skuID],position:cn,rotation:un,hasItemLoaded:!1,isDependent:Gt,isInteractive:sn},hotspotsData:Xt[Qt.skuID],hotspotSpawned:!1},await wait(1),jt.setItemsSpawned({...Ht})}}).catch(Jt=>{LOGGER.error({title:Jt}),Yt=!1});if(Yt===!1)return kt({busySpawningItem:!1}),Zt;if(Wt.coreSceneStore.getState().preconfigurationLoaded&&Wt.coreSceneStore.getState().configurationLoaded){const Jt=await Kt.getCartItemsAsync();Jt&&Wt.coreSceneStore.getState().CORE_API.fireEvent(Wt.coreSceneStore.getState().CORE_API.EVENTS.SCENE.CartItems_Updated,Jt)}if(await jt.resolvePlugDependencyOnGUID(Zt),kt({busySpawningItem:!1}),!Gt){const Jt=Kt.currentStructure,nn=Jt.getNodeByGUID(Zt);Wt.dynamicHookStore.getState().hookOnSceneItemAdded(nn,Jt.nodes,Wt.coreSceneStore.getState().CORE_API),await Wt.attachmentStore.getState().actions.updateFittingSkuIds()}return Zt},async addItemWithTransform(Dt,Vt,Gt,zt=!0){const{actions:jt,itemsSpawned:Ht,defaultSceneItemCount:Wt,stores:qt}=_e(),Xt=qt.productDataStore.getState().productData,Kt=qt.productDataStore.getState().hotspotsData;return await new Promise(async(Zt,Jt)=>{if(jt.deselectItem(),!Xt[Vt]){qt.coreSceneStore.getState().CORE_API.alert({alertMsg:Vt+": product not found!",alertTime:5e3,alertType:"warn",alertLabel:"Not Found"}),Jt(Vt+": product not found!");return}const{position:nn,rotation:rn}=Dt;Ht[Gt]!=null&&(qt.hotspotStore.getState().actions.removeHotspotForItem({...Ht[Gt]}),delete Ht[Gt]);const Qt=tn=>{Vt.toLowerCase()==tn.data.toLowerCase()&&Zt(Gt)};qt.coreSceneStore.getState().CORE_API.coreWCRef.addEventListener(qt.coreSceneStore.getState().CORE_API.EVENTS.SCENE.Model_Loaded,Qt,{once:!0});const en=await qt.assetStore.getState().actions.loadProxyAsset(Vt,!0);if(en==null){Jt(Vt+": Asset not found!");return}await wait(1),Vt.toLowerCase()==="root"&&kt({defaultSceneItemCount:Wt+1}),Ht[Gt]={itemData:{proxyScene:en.proxy.data.scene,guid:Gt,...Xt[Vt],position:nn,rotation:rn,hasItemLoaded:!1,isInteractive:zt},hotspotsData:Kt[Vt],hotspotSpawned:!1},kt({itemsSpawned:{...Ht}})}).catch(Zt=>{LOGGER.info({title:Zt})})},async resolvePlugDependencyOnGUID(Dt){const{actions:Vt,itemsSpawned:Gt,defaultSceneItemCount:zt,stores:jt}=_e(),Ht=jt.productDataStore.getState().productData,Wt=jt.attachmentStore.getState().attachmentSystem,qt=Gt[Dt].itemData.skuID,Xt=Ht[qt]?.plugs;if(!Xt)return;let Kt=!1;for(const Yt of Xt)Yt?.dependencySku&&(Kt=!0);Kt&&(kt({busySpawningDependency:!0}),await new Promise(async(Yt,Zt)=>{const Jt=[];for(const nn of Xt){const rn=nn?.dependencySku;if(!rn)continue;const Qt=async()=>{LOGGER.info({title:`Found a dependency: ${rn} on the plug: ${nn.name}`});let en=!0;Ht[rn]&&Ht[rn].hasOwnProperty("ignoreSpawningCollisionAsDependency")&&(en=Ht[rn].ignoreSpawningCollisionAsDependency),nn.hasOwnProperty("ignoreSpawningCollision")&&(en=nn.ignoreSpawningCollision);let tn=jt.coreSceneStore.getState().sceneSettings.ignoreSpawningCollision;Ht[rn].hasOwnProperty("ignoreSpawningCollision")&&(tn=Ht[rn].ignoreSpawningCollision),Ht[rn].ignoreSpawningCollision=en,jt.ghostStore.setState({ghostVisibility:!1});const sn=await jt.ghostStore.getState().actions.spawnGhostsForSkuID(rn,en);if(Ht[rn].ignoreSpawningCollision=tn,!sn)return;const cn=Wt.currentStructure.getNodeByGUID(Dt),un=cn.getPlugByName(nn.name)?.guid,hn=nn?.isDependencySkuInteractive?nn.isDependencySkuInteractive===1:!1,fn=sn.connectablePlugs;let pn=-1;for(const mn of fn)mn.receiverPlug.guid===un&&(pn=fn.indexOf(mn));if(pn==-1){jt.ghostStore.getState().actions.clearAllGhosts();return}const dn=await Vt.addItemBySkuID(rn,pn,!0,hn);qt.toLowerCase()==="root"&&Ht[rn].ignoreInCart&&kt({defaultSceneItemCount:zt+1}),dn!==null&&cn.addMyDependenciesGUID(dn)};Jt.push(await Qt())}await Promise.all(Jt),Yt(!0)}),kt({busySpawningDependency:!1}))},async replaceGuidItemBySkuId(Dt,Vt){const{itemsSpawned:Gt,stores:zt}=_e();if(Gt[Dt]==null)return!1;const jt=zt.attachmentStore.getState().attachmentSystem.currentStructure,Ht=jt.getNodeByGUID(Dt);if(!Ht||!Ht.isReplaceableWithSkuId(Vt))return!1;LOGGER.info({title:"Replacing Item"});const qt=zt.productDataStore.getState().productData,Xt=zt.productDataStore.getState().hotspotsData;kt({busyReplacingItem:!0}),await new Promise(async(Kt,Yt)=>{const Zt=async()=>{LOGGER.info({title:"Removed old item with guid: "+Dt});const Jt=async Qt=>{Vt===Qt.data&&(jt.recalculateStructureFromNode(Ht.whichNodeAreWeAttachedTo()),await zt.attachmentStore.getState().actions.toggleStructureUpdated(),kt({busyReplacingItem:!1}),Kt(Ht.guid))};zt.coreSceneStore.getState().CORE_API.coreWCRef.addEventListener(zt.coreSceneStore.getState().CORE_API.EVENTS.SCENE.Model_Loaded,Jt,{once:!0});const nn=await zt.assetStore.getState().actions.loadProxyAsset(Vt,!0),rn={receiverPlug:Ht.whichPlugAreWeAttachedTo(),incomingPlug:Ht.whichPlugAreWeAttachedUsing()};jt.findItemTransform(rn),Gt[Dt]={itemData:{proxyScene:nn.proxy.data.scene,guid:Dt,...qt[Vt],position:Ht.transform.position,rotation:Ht.transform.rotation,hasItemLoaded:!1},hotspotsData:Xt[Vt],hotspotSpawned:!1},LOGGER.warn({title:"SWITCHING VARIANT: ",details:Ht.currentVariant}),zt.itemStore.setState({itemsSpawned:{...Gt}})};zt.hotspotStore.getState().actions.removeHotspotForItem({...Gt[Dt]}),delete Gt[Dt],Ht.update(Vt),zt.coreSceneStore.getState().CORE_API.coreWCRef.addEventListener(zt.coreSceneStore.getState().CORE_API.EVENTS.SCENE.Model_Removed,Zt,{once:!0})})}}}));async function replaceItem(kt,_e,Dt,Vt,Gt,zt){LOGGER.info({title:"Replacing Item"});const{position:jt,rotation:Ht}=Gt,Wt=_e.productDataStore.getState().productData,qt=_e.productDataStore.getState().hotspotsData,Xt=_e.attachmentStore.getState().attachmentSystem.currentStructure;return kt({busyReplacingItem:!0}),new Promise(async(Kt,Yt)=>{const Zt=async()=>{const Jt=await _e.assetStore.getState().actions.loadProxyAsset(Vt,!0),nn=async rn=>{Vt===rn.data&&(Xt.recalculateStructureFromNode(zt),await _e.attachmentStore.getState().actions.toggleStructureUpdated(),_e.ghostStore.getState().actions.clearAllGhosts(),kt({busyReplacingItem:!1}),Kt(zt.guid))};_e.coreSceneStore.getState().CORE_API.coreWCRef.addEventListener(_e.coreSceneStore.getState().CORE_API.EVENTS.SCENE.Model_Loaded,nn,{once:!0}),Dt[zt.guid]={itemData:{proxyScene:Jt.proxy.data.scene,guid:zt.guid,...Wt[Vt],position:jt,rotation:Ht,hasItemLoaded:!1},hotspotsData:qt[Vt],hotspotSpawned:!1},LOGGER.warn({title:"SWITCHING VARIANT: ",details:zt.currentVariant}),zt.currentVariant=zt.currentVariant,zt.transform=Gt,_e.itemStore.setState({itemsSpawned:{...Dt}})};_e.hotspotStore.getState().actions.removeHotspotForItem({...Dt[zt.guid]}),delete Dt[zt.guid],zt.update(Vt),_e.coreSceneStore.getState().CORE_API.coreWCRef.addEventListener(_e.coreSceneStore.getState().CORE_API.EVENTS.SCENE.Model_Removed,Zt,{once:!0})})}const createInventoryStore=kt=>{const _e=inventoryStoreCreator();return _e.setState({stores:kt}),_e},inventoryStoreCreator=()=>create((kt,_e)=>({stores:null,inventoryData:{},actions:{updateInventoryForAllProducts:Dt=>{const{actions:Vt,stores:Gt}=_e();Object.keys(Dt).map(zt=>{let jt=Dt[zt];Object.keys(jt).map(Ht=>{Vt.updateInventoryForProduct(zt,Ht,jt[Ht].inventory)})}),Vt.refreshInventory(Gt.itemStore.getState().itemsSpawned)},updateInventoryForProduct:(Dt,Vt,Gt)=>{const{inventoryData:zt}=_e();let jt=zt[Dt],Ht=jt[Vt];!jt||!Ht||(Ht.inventory=Gt)},_clearInScene:()=>{const{inventoryData:Dt}=_e();Object.keys(Dt).map(Vt=>{const Gt=Dt[Vt];Object.keys(Gt).map(zt=>{Gt[zt].inScene=[]})})},refreshInventory:Dt=>{if(!Dt)return;LOGGER.info({title:"Refreshing Inventory"});const{actions:Vt,inventoryData:Gt,stores:zt}=_e();Vt._clearInScene();const jt=zt.attachmentStore.getState().attachmentSystem;if(jt===null)return;const Ht=jt.currentStructure;if(Ht===null)return;Object.keys(Dt).map(Kt=>{const Yt=Ht.getNodeByGUID(Kt);if(!Yt)return;const Zt=Yt.overrideVariant?Yt.overrideVariant:Yt.currentVariant;if(!Zt)return;const Jt=Gt[Yt.skuID];if(!Jt||!Jt[Zt].inScene)return;Jt[Zt].inScene.push(Kt),zt.coreSceneStore.getState().sceneSettings.disableCart===!0?Yt.inStock={variantName:Zt,newValue:!0}:Jt[Zt].inScene.length>Jt[Zt].inventory?Yt.inStock={variantName:Zt,newValue:!1}:Yt.inStock={variantName:Zt,newValue:!0}});let Wt=!1;Object.keys(Gt).map(Kt=>{const Yt=Gt[Kt];Object.keys(Yt).map(Zt=>{Yt[Zt].countAvailable=Yt[Zt].inventory-Yt[Zt].inScene.length,Yt[Zt].countAvailable<0?(Yt[Zt].countUnavailable=Yt[Zt].countAvailable*-1,Yt[Zt].countAvailable=0,Wt=!0):Yt[Zt].countUnavailable=0})});const qt={alertMsg:"Some item(s) in configuration are out of stock",alertTime:7e3,alertType:"warn",alertLabel:"Stock Alert",persistant:!0,alertId:"outOfStock"},Xt=compareObjects(zt.coreSceneStore.getState().persistantAlertData,qt);Wt===!1&&Xt===!0&&zt.coreSceneStore.getState().CORE_API.removePersistantAlert(),zt.coreSceneStore.getState().CORE_API.fireEvent(zt.coreSceneStore.getState().CORE_API.EVENTS.SCENE.Inventory_Updated,Gt)}}})),createAssetStore=kt=>{const _e=assetStoreCreator();return _e.setState({stores:kt}),_e},assetStoreCreator=()=>create((kt,_e)=>({stores:null,assets:{items:{}},gltfLoader:null,dracoLoader:null,actions:{init(){const Dt=new DRACOLoader;Dt.setDecoderPath(`${ASSETS_SOURCE_ROOT}/external-libs/draco/`),Dt.setDecoderConfig({type:"js"});const Vt=new GLTFLoader;Vt.register(Gt=>new GLTFMaterialsVariantsExtension(Gt)),Vt.setDRACOLoader(Dt),kt({dracoLoader:Dt,gltfLoader:Vt})},async loadProxyAsset(Dt){const{assets:Vt,gltfLoader:Gt,stores:zt}=_e(),jt="proxy",Ht=Vt.items[Dt]=Vt.items[Dt]||{isLoaded:!1,errorLoading:!1,proxy:{isLoaded:!1,errorLoading:!1}},Wt=Ht.proxy;if(Wt.isLoaded)return Ht;if(Wt.errorLoading)throw new Error(`${jt} loading failed for: ${Dt}`);const qt=zt.productDataStore.getState().productData[Dt];if(!qt)throw new Error(`Data doesn't exist for ${Dt}`);const Xt=zt.coreSceneStore.getState().CORE_API.getResolvedAssetUrl(qt.colliderProxyGLTF);if(!Xt)return null;try{const Kt=await Gt.loadAsync(Xt,Yt=>{Wt.progress=Yt.loaded/Yt.total*100});return Wt.data=Kt,Wt.isLoaded=!0,Ht}catch(Kt){throw Wt.isLoaded=!1,Wt.errorLoading=!0,Wt.error=Kt,LOGGER.info({title:Xt}),new Error(`Couldn't load ${Dt}`)}},isProxyLoaded(Dt){const Vt=_e().assets.items[Dt];return Vt?Vt.proxy.isLoaded:!1}}}));class Structure{#t=!1;constructor(_e,Dt=null,Vt,Gt){if(this.stores=_e,this._nodes=[],this._rootNode=null,LOGGER.info({title:"preloadNodes",details:Dt}),this.setupHookOnSceneItemsUpdated(),Dt){LOGGER.info({title:"PRELOAD Length-----------------:"+Dt.length});for(let zt=0;zt<Dt.length;zt++){LOGGER.info({title:"FOUND PRELOAD-----------------"});const jt=Dt[zt].skuID;if(jt.toLowerCase()=="root"){const Wt=this.stores.itemStore.getState().itemsSpawned;Object.keys(Wt).length>0&&(Dt[zt].guid=Object.keys(Wt)[0])}let Ht=new Node$1(_e,jt,Dt[zt],Vt,Gt);jt.toLowerCase()=="root"&&(this._rootNode=Ht),this._nodes.push(Ht)}}else{const zt=new Node$1(_e,"Root",null,Vt,Gt);this._rootNode=zt,this._nodes.push(zt),this.stores.itemStore.getState().actions.addItemWithTransform({position:new Vector3(0,0,0),rotation:new Quaternion().identity()},"Root",this._rootNode.guid,!1)}this._boundingBoxLeeway=this.stores.coreSceneStore.getState().sceneSettings.boundingBoxLeeway}async setupHookOnSceneItemsUpdated(){const _e=this.stores.coreSceneStore.getState().CORE_API;this.stores.coreSceneStore.getState().CORE_API.coreWCRef.addEventListener(_e.EVENTS.SCENE.FittingSkuIds_Updated,()=>{this.stores.dynamicHookStore.getState().hookOnSceneItemsUpdated(this._nodes,_e)})}get nodes(){return this._nodes}get rootNode(){return this._rootNode}updatePricing(){for(let _e=0;_e<this._nodes.length;_e++)this._nodes[_e].updatePricing()}getCurrentItemsInReplaceableCategory(){let _e={};for(const Dt of this._nodes)Dt.replace&&(_e[Dt.categoryID]=Dt.skuID);return _e}recalculateStructureFromNode(_e){for(let Dt=0;Dt<_e.plugs.length;Dt++)if(!_e.plugs[Dt].isOpen&&_e.plugs[Dt].isReceiverPlug){const Vt=_e.plugs[Dt].attachedPlug.node,Gt={receiverPlug:_e.plugs[Dt],incomingPlug:_e.plugs[Dt].attachedPlug};if(Gt){const zt=this.findItemTransform(Gt);zt&&(Vt.ref.position.set(zt.position.x,zt.position.y,zt.position.z),zt.rotation.isQuaternion===!0?Vt.ref.setRotationFromQuaternion(zt.rotation):zt.rotation.isEuler===!0&&Vt.ref.setRotationFromEuler(zt.rotation),Vt.transform={position:zt.position,rotation:zt.rotation})}this.recalculateStructureFromNode(Vt)}}rotateNode(_e){const Dt=this.getNodeByGUID(_e);let Vt=null,Gt=null;for(let Ht=0;Ht<Dt.plugs.length;Ht++)if(!Gt&&!Dt.plugs[Ht].isOpen&&Dt.plugs[Ht].attachedPlug.isReceiverPlug){const Wt=Dt.plugs[Ht].attachedPlug.acceptedPlugTypes;Gt=Dt.plugs[Ht].attachedPlug;let qt=[];for(let Xt=Ht+1;Xt<Dt.plugs.length;Xt++)qt.push(Dt.plugs[Xt]);for(let Xt=0;Xt<Ht;Xt++)qt.push(Dt.plugs[Xt]);for(let Xt=0;Xt<qt.length;Xt++)for(let Kt=0;Kt<qt[Xt].connectsToPlugTypes.length;Kt++)Wt.includes(qt[Xt].connectsToPlugTypes[Kt])&&(Vt=qt[Xt])}if(!Vt)return;Dt.detachNodeFromReceiver();const{position:zt,rotation:jt}=this.findItemTransform({receiverPlug:Gt,incomingPlug:Vt});Dt.ref.position.set(zt.x,zt.y,zt.z),jt.isQuaternion===!0?Dt.ref.setRotationFromQuaternion(jt):jt.isEuler===!0&&Dt.ref.setRotationFromEuler(jt),Dt.transform={position:Dt.ref.position,rotation:jt},this.connectPlugs({receiverPlug:Gt,incomingPlug:Vt}),this.recalculateStructureFromNode(Dt)}async load(_e){this.resolvePlugConnections(_e),await this.respawnItems()}materialOverrideExists(){let _e=!1;return this.nodes.map(Dt=>{if(Dt.overrideVariant)return _e=!0,!0}),_e}async findGhostTransformForReplacement(_e,Dt){let Vt=[],Gt=[],zt=[];for(const Ht of Dt){if(Ht.skuID==_e)continue;const Wt=this.stores.attachmentStore.getState().attachmentSystem,qt=Ht.whichPlugAreWeAttachedTo(),Xt=Ht.whichPlugAreWeAttachedUsing(),Yt=new Node$1(this.stores,_e,null,Wt.globalVariants,Wt.globalGeometryVariants).getPlugByName(Xt.name);if(!Yt)continue;const Zt={incomingPlug:Yt,receiverPlug:qt},{position:Jt,rotation:nn}=this.findItemTransform(Zt);Jt&&nn&&(Gt.push({position:Jt,rotation:nn,incomingPlugName:Zt.incomingPlug.name,receiverPlugName:Zt.receiverPlug.name,incomingPlugGUID:Zt.incomingPlug.guid,receiverPlugGUID:Zt.receiverPlug.guid}),zt.push(Zt),Vt.push(Ht))}let jt={transforms:Gt,connectablePlugs:zt,newNodes:Vt};return jt=await this.stores.dynamicHookStore.getState().hookOnNewItemGhostsCollectedForReplacement(jt,this.stores.coreSceneStore.getState().CORE_API),jt}async findGhostTransforms(_e,Dt){const Vt=this.getOpenPlugs(),Gt=this.stores.coreSceneStore.getState().sceneSettings.comboPlugDistanceThreshold;if(Vt.length<=0)return{transforms:[]};const zt=this.stores.attachmentStore.getState().attachmentSystem,jt=this.stores.productDataStore.getState().productData,Ht=new Node$1(this.stores,_e,null,zt.globalVariants,zt.globalGeometryVariants),Wt=this.getConnectablePlugs(Ht,Vt);let qt=[];if(Wt.length<=0)return{transforms:[]};let Xt=[],Kt=[];const Yt=this.stores.assetStore.getState().assets.items[_e].proxy.data.scene;if(!Yt)return!1;let Zt=Yt.clone();for(let rn=0;rn<Wt.length;rn++){let Qt=Dt,{incomingPlug:en,receiverPlug:tn}=Wt[rn],sn=this.findItemTransform(Wt[rn]);if(!sn)continue;let{position:cn,rotation:un}=sn;if(!cn||!un)continue;Zt.position.set(cn.x,cn.y,cn.z),un.isQuaternion===!0?Zt.setRotationFromQuaternion(un):un.isEuler===!0&&Zt.setRotationFromEuler(un);let hn=[],fn=[];if(en.type=="comboPlug"){if(en.connectsToPlugTypes.length<=0)continue;const vn=en.connectsToPlugTypes[0];let _n=!1;if(Kt.map(Cn=>{_n===!0||Cn.length<=0||Cn.map(yn=>{_n===!0||yn.incomingPlug.guid!==en.guid||yn.incomingPlug.connectsToPlugTypes.includes(vn)&&(_n=!0)})}),_n===!0)continue;const An=en.node.plugs;let Tn=!0;if(An.map(Cn=>{if(Cn.type!=="comboPlug"||Cn.guid===en.guid||!Cn.connectsToPlugTypes.includes(vn))return;let yn=!1;if(Vt.map(Sn=>{if(tn.guid===Sn.guid||!Sn.acceptedPlugTypes.includes(vn)||!Sn.node.ref)return;let wn=new Vector3(0,0,0);const xn=Sn.node.ref.getObjectByName(""+Sn.name);if(!xn)return;xn.getWorldPosition(wn);let Rn=new Vector3(0,0,0);const Dn=Zt.getObjectByName(""+Cn.name);if(!Dn)return;Dn.getWorldPosition(Rn);const kn=wn.distanceTo(Rn);Math.abs(kn)<Gt&&(hn.push(tn.node.guid),hn.push(Sn.node.guid),fn.push({receiverPlug:Sn,incomingPlug:Cn}),yn=!0)}),yn==!1){Tn=!1;return}}),!Tn)continue}let pn=Qt;Array.isArray(Qt)===!0&&(pn=!1),hn.length>0&&(pn=!1,Array.isArray(Qt)===!0?hn.map(vn=>{Qt.push(vn)}):Qt=hn),jt[_e].hasOwnProperty("ignoreSpawningCollision")&&(pn=jt[_e].ignoreSpawningCollision),Wt[rn].receiverPlug.type=="unvisualizedPlug"&&(pn=!0),(pn?!1:this.isColliding(Ht.skuID,sn,Wt[rn].receiverPlug,Qt))||(Xt.push({position:cn,rotation:un,incomingPlugName:Wt[rn].incomingPlug.name,receiverPlugName:Wt[rn].receiverPlug.name,incomingPlugGUID:Wt[rn].incomingPlug.guid,receiverPlugGUID:Wt[rn].receiverPlug.guid}),qt.push(Wt[rn]),Kt.push(fn))}let Jt=[];for(let rn=0;rn<Xt.length;rn++)Jt.push(Ht);dispose3(Zt);let nn={transforms:Xt,newNodes:Jt,connectablePlugs:qt,comboPlugs:Kt};return nn=await this.stores.dynamicHookStore.getState().hookOnNewItemGhostsCollected(nn,this.stores.coreSceneStore.getState().CORE_API),nn}resolvePlugConnections(_e){for(let Dt=0;Dt<_e.length;Dt++)Object.keys(_e[Dt].plugs).map(Vt=>{let Gt=_e[Dt].plugs[Vt].guid,zt=this.getPlugInNodesByGUID(Gt);if(!zt||zt.attachedPlug)return;let jt=_e[Dt].plugs[Vt].attachedPlugGUID,Ht=this.getPlugInNodesByGUID(jt);Ht&&(Ht.attachedPlug||(zt.attachPlug(Ht,_e[Dt].plugs[Vt].isReceiverPlug),Ht.attachPlug(zt,!_e[Dt].plugs[Vt].isReceiverPlug)))});LOGGER.info({title:"RESOLVED PLUG CONNECTION: ",details:this})}async respawnItems(){let _e=[this.rootNode];for(let zt=0;zt<_e.length;zt++){let Ht=_e[zt].whichPlugsAreAttachedToUs();for(let Wt=0;Wt<Ht.length;Wt++){if(Ht[Wt].incomingPlug.type=="comboPlug"&&Ht[Wt].incomingPlug.connectsToPlugTypes.length>0&&!Ht[Wt].incomingPlug.comboPlugConnector)continue;let qt=this.findItemTransformForPreload(Ht[Wt],Ht[Wt].receiverPlug.node.transform);qt?await this.stores.itemStore.getState().actions.addItemWithTransform(qt,Ht[Wt].incomingPlug.node.skuID,Ht[Wt].incomingPlug.node.guid):LOGGER.warn({title:"Problem finding plug transform! "+Ht[Wt].name}),Ht[Wt].incomingPlug.node.transform=qt,_e.push(Ht[Wt].incomingPlug.node)}}const Dt=await this.stores.coreSceneStore.getState().CORE_API.getCartItemsAsync();this.stores.coreSceneStore.getState().CORE_API.fireEvent(this.stores.coreSceneStore.getState().CORE_API.EVENTS.SCENE.SavedConfiguration_Loaded,{...Dt}),this.stores.coreSceneStore.getState().actions.triggerAutoFocus(),this.stores.hotspotStore.getState().actions.checkHotspotHealth();const Vt=this.stores.coreSceneStore.getState().preconfigurationLoaded==!1&&this.stores.coreSceneStore.getState().sceneHasDefaultConfigurationID==!1,Gt=this.stores.coreSceneStore.getState().configurationLoaded==!1&&this.stores.coreSceneStore.getState().preconfigurationLoaded==!0&&this.stores.coreSceneStore.getState().configurationLoadedOnRestart==!0;if(Vt||Gt){let zt=Object.assign({},CONFIGURATOR_LOAD_FROM_PRECONFIG);zt.parameters={project_id:`${this.stores.coreSceneStore.getState().CORE_API.projectId}`,...Dt},this.stores.coreSceneStore.getState().CORE_API.sendAnalyticsEvent(zt)}}getPlugInNodesByGUID(_e){for(let Dt=0;Dt<this._nodes.length;Dt++){let Vt=this._nodes[Dt].getPlugByGUID(_e);if(Vt)return Vt}return null}export(){let _e=[];for(let Dt=0;Dt<this._nodes.length;Dt++){let Vt=this._nodes[Dt].export();Vt&&_e.push(Vt)}return _e}async clear(){return new Promise(async(_e,Dt)=>{!this._rootNode&&this._rootNode.isEndNode&&_e(!0);let Vt=null;const Gt=this._rootNode.whichNodesAreAttachedToUs();Gt.length>0&&(Vt=Gt[0]),this.#t=!0,this.stores.coreSceneStore.getState().CORE_API.coreWCRef.addEventListener(this.stores.coreSceneStore.getState().CORE_API.EVENTS.SCENE.Scene_Cleared,zt=>_e(zt.data),{once:!0}),Vt?this.stores.coreSceneStore.getState().CORE_API.removeItemByGUID(Vt.guid,!0):(await wait(500),_e(!0))})}getNodeByGUID(_e){for(let Dt=0;Dt<this._nodes.length;Dt++)if(this._nodes[Dt].guid==_e)return this._nodes[Dt];return null}getPlugByGUID(_e){for(const Dt of this._nodes){const Vt=Dt.getPlugByGUID(_e);if(Vt)return Vt}return null}findItemTransformForPreload(_e,Dt){let{receiverPlug:Vt,incomingPlug:Gt}=_e,zt=Vt,jt=Gt;if(zt.node.skuID=="Root")return this.findItemTransformRoot(_e);let Ht=null,Wt=null,qt=new Object3D,Xt=this.stores.assetStore.getState().assets.items[zt.node.skuID].proxy.data.scene.clone();qt.add(Xt);let{position:Kt,rotation:Yt}=Dt;if(Xt.position.set(Kt.x,Kt.y,Kt.z),Yt.isQuaternion===!0?Xt.setRotationFromQuaternion(Yt):Yt.isEuler===!0&&Xt.setRotationFromEuler(Yt),Wt=Xt,!Wt||(Ht=Wt.getObjectByName(zt.name),!Ht))return;let Zt=new Vector3(0,0,0);Ht.getWorldPosition(Zt);let Jt=new Quaternion().identity();Ht.getWorldQuaternion(Jt);let nn=new Object3D;Ht.add(nn);let rn=this.stores.assetStore.getState().assets.items[jt.node.skuID].proxy.data.scene.clone();rn.position.set(Zt.x,Zt.y,Zt.z),rn.applyQuaternion(Jt);let Qt=new Vector3;Qt.copy(Xt.up).applyQuaternion(Wt.quaternion);let en=new Vector3;en.copy(rn.up).applyQuaternion(Jt),en.negate();let tn=new Quaternion().setFromUnitVectors(Qt,en);Qt.round(),en.round();let sn=Qt.dot(en);sn!==1&&sn!==-1&&rn.applyQuaternion(tn);let cn=rn.getObjectByName(jt.name),un=new Quaternion().identity();cn.getWorldQuaternion(un);let hn=new Vector3(0,1,0);hn.applyQuaternion(un);let fn=new Vector3(0,1,0);fn.applyQuaternion(Jt),fn.negate();let pn=new Quaternion().setFromUnitVectors(hn,fn);if(hn.round(),fn.round(),hn.dot(fn)!==-1)rn.applyQuaternion(pn);else{let An=new Vector3(0,1,0),Tn=fn.dot(An);if(Tn!==1&&Tn!==-1)rn.rotateOnAxis(An,Math.PI);else{let Cn=new Vector3(0,0,1),yn=fn.dot(Cn);if(yn!==1&&yn!==-1)rn.rotateOnAxis(Cn,Math.PI);else{let Sn=new Vector3(1,0,0),wn=fn.dot(Sn);wn!==1&&wn!==-1&&rn.rotateOnAxis(Sn,Math.PI)}}}let mn=rn.getObjectByName(jt.name),vn=new Vector3(mn.position.x,mn.position.y,mn.position.z);rn.translateX(-vn.x),rn.translateY(-vn.y),rn.translateZ(-vn.z);let _n=new Vector3(0,0,0);rn.getWorldPosition(_n);let En=new Quaternion().identity();return rn.getWorldQuaternion(En),rn=null,{position:_n,rotation:En}}findItemTransformRoot(_e){let{receiverPlug:Dt,incomingPlug:Vt}=_e,Gt=Vt;const zt=new Object3D;let jt=zt,Ht=new Vector3(0,0,0);jt.getWorldPosition(Ht);let Wt=new Quaternion().identity(),qt=new Object3D;qt.position.set(0,0,0),zt.add(qt);let Xt=this.stores.assetStore.getState().assets.items[Gt.node.skuID].proxy.data.scene.clone();qt.attach(Xt),Xt.translateX(Ht.x),Xt.translateY(Ht.y),Xt.translateZ(Ht.z);let Kt=Xt.getObjectByName(Gt.name),Yt=new Quaternion().identity();Kt&&Kt.getWorldQuaternion(Yt);const Zt=new Vector3(0,1,0);Zt.applyQuaternion(Yt);const Jt=new Vector3(0,1,0);Jt.applyQuaternion(Wt);const nn=Jt.angleTo(Zt),rn=new Vector3(0,0,0);rn.crossVectors(Jt,Zt),rn.round(),rn.length()!==0&&Xt.rotateOnAxis(rn,nn);let Qt=new Matrix4().extractRotation(Xt.matrixWorld),en=new Vector3(0,0,0);Kt&&en.set(Kt.position.x,Kt.position.y,Kt.position.z),en.applyMatrix4(Qt),Xt.translateX(-en.x),Xt.translateY(-en.y),Xt.translateZ(-en.z);let tn=new Vector3(0,0,0);Xt.getWorldPosition(tn);let sn=new Quaternion().identity();return Xt.getWorldQuaternion(sn),qt.remove(Xt),qt=null,Xt=null,{position:tn,rotation:sn}}findItemTransform(_e){let{receiverPlug:Dt,incomingPlug:Vt}=_e,Gt=Dt,zt=Vt;if(Gt.node.isRoot)return this.findItemTransformRoot(_e);const jt=Gt.node.transform;if(!jt)return;const Ht=this.stores.assetStore.getState().assets.items[Gt.node.skuID].proxy.data.scene.clone(),Wt=new Object3D;Wt.position.set(jt.position.x,jt.position.y,jt.position.z),jt.rotation.isQuaternion===!0?Wt.setRotationFromQuaternion(jt.rotation):jt.rotation.isEuler===!0&&Wt.setRotationFromEuler(jt.rotation),Wt.add(Ht);let qt=Wt.getObjectByName(""+Gt.name);if(!qt){LOGGER.error({title:"Plug: "+Gt.name+" doesn't exist in "+Gt.node.skuID});return}let Xt=new Vector3(0,1,0);qt.getWorldPosition(Xt);let Kt=new Quaternion().identity();qt.getWorldQuaternion(Kt);let Yt=this.stores.assetStore.getState().assets.items[zt.node.skuID].proxy.data.scene.clone();Yt.position.set(Xt.x,Xt.y,Xt.z),Yt.applyQuaternion(Kt);let Zt=new Vector3;Zt.copy(Ht.up).applyQuaternion(Wt.quaternion);let Jt=new Vector3;Jt.copy(Yt.up).applyQuaternion(Kt),Jt.negate();let nn=new Quaternion().setFromUnitVectors(Zt,Jt);Zt.round(),Jt.round();let rn=Zt.dot(Jt);rn!==1&&rn!==-1&&Yt.applyQuaternion(nn);let Qt=Yt.getObjectByName(zt.name);if(!Qt){LOGGER.error({title:"Plug: "+zt.name+" doesn't exist in "+zt.node.skuID});return}let en=new Quaternion().identity();Qt.getWorldQuaternion(en);let tn=new Vector3(0,1,0);tn.applyQuaternion(en);let sn=new Vector3(0,1,0);sn.applyQuaternion(Kt),sn.negate();let cn=new Quaternion().setFromUnitVectors(tn,sn);if(tn.round(),sn.round(),tn.dot(sn)!==-1)Yt.applyQuaternion(cn);else{let mn=new Vector3(0,1,0),vn=sn.dot(mn);if(vn!==1&&vn!==-1)Yt.rotateOnAxis(mn,Math.PI);else{let _n=new Vector3(0,0,1),En=sn.dot(_n);if(En!==1&&En!==-1)Yt.rotateOnAxis(_n,Math.PI);else{let An=new Vector3(1,0,0),Tn=sn.dot(An);Tn!==1&&Tn!==-1&&Yt.rotateOnAxis(An,Math.PI)}}}let hn=Yt.getObjectByName(zt.name),fn=new Vector3(hn.position.x,hn.position.y,hn.position.z);Yt.translateX(-fn.x),Yt.translateY(-fn.y),Yt.translateZ(-fn.z);let pn=new Vector3(0,0,0);Yt.getWorldPosition(pn);let dn=new Quaternion().identity();return Yt.getWorldQuaternion(dn),Wt.remove(Ht),Yt=null,{position:pn,rotation:dn}}getSpawningRequirementForSkuID(_e){let Dt=[];const Vt=this.stores.productDataStore.getState().productData,Gt=Vt[_e];if(!Gt)return Dt;const zt=[];return Gt.plugs.map(jt=>{jt.connectsToPlugTypes.map(Ht=>{zt.push(Ht)})}),Object.keys(Vt).map(jt=>{for(let Ht=0;Ht<Vt[jt].plugs.length;Ht++){const Wt=Vt[jt].plugs[Ht].acceptedPlugTypes;for(let qt=0;qt<Wt.length;qt++)zt.map(Xt=>{Xt==Wt[qt]&&!Dt.includes(jt)&&Dt.push(jt)})}}),Dt}getConnectablePlugs(_e,Dt){let Vt=[],Gt=_e.getOpenPlugsWeCanAttachFrom();for(let zt=0;zt<Gt.length;zt++)for(let jt=0;jt<Dt.length;jt++){let Ht=!1;for(let qt=0;qt<Vt.length;qt++)if(Vt[qt].receiverPlug.guid==Dt[jt].guid&&Vt[qt].incomingPlug.type!="comboPlug"){Ht=!0;break}if(Ht)continue;Gt[zt].canAttachToPlug(Dt[jt])&&Vt.push({incomingPlug:Gt[zt],receiverPlug:Dt[jt]})}return Vt}getOpenPlugs(){let _e=[];return this._nodes.map(Dt=>{if(Dt.dragging===!0)return;let Vt=Dt.getOpenPlugsFromNode();_e=_e.concat(Vt)}),_e}checkCollisionForGUID(_e,Dt=[]){if(this.stores.coreSceneStore.getState().sceneSettings.disableCollider)return!1;const Vt=this.stores.itemStore.getState().itemsSpawned,Gt=this.stores.productDataStore.getState().productData;if(!Vt[_e])return!1;const jt=this.getNodeByGUID(_e);if(!jt||!jt.ref||Gt[jt.skuID].disableCollider)return!1;let Ht=new Vector3;jt.ref.getWorldPosition(Ht);let Wt=new Quaternion;jt.ref.getWorldQuaternion(Wt);const qt={position:Ht,rotation:Wt},Xt=jt.whichPlugAreWeAttachedTo();return Xt==null?!1:this.isColliding(jt.skuID,qt,Xt,Dt)}isColliding(_e,{position:Dt,rotation:Vt},Gt,zt=[]){const jt=this.stores.assetStore.getState().assets.items[_e].proxy.data.scene,Ht=this.stores.productDataStore.getState().productData;if(!jt)return!1;let Wt=jt.clone();Wt.position.set(Dt.x,Dt.y,Dt.z),Vt.isQuaternion===!0?Wt.setRotationFromQuaternion(Vt):Vt.isEuler===!0&&Wt.setRotationFromEuler(Vt);let qt=new Box3().setFromObject(Wt),Xt=new Vector3;qt.getCenter(Xt);let Kt=new Object3D;Kt.position.set(Xt.x,Xt.y,Xt.z),Kt.attach(Wt),Kt.scale.set(this._boundingBoxLeeway,this._boundingBoxLeeway,this._boundingBoxLeeway),qt=new Box3().setFromObject(Kt);const Yt=[];if(this._nodes.forEach(Jt=>{if(Gt.node.guid==Jt.guid||Array.isArray(zt)===!0&&zt.includes(Jt.guid)||!Jt.ref||(Ht[Jt.skuID].hasOwnProperty("disableCollider")?Ht[Jt.skuID].disableCollider:this.stores.coreSceneStore.getState().sceneSettings.disableCollider))return;const nn=Jt.ref.getObjectByName("GRP_ProxyMesh");nn&&Yt.push(nn)}),Yt.length<=0)return!1;let Zt=!1;return Yt.forEach(Jt=>{if(Zt)return;let nn=new Box3().setFromObject(Jt);if(qt.intersectsBox(nn)){Zt=!0;return}}),Kt.clear(),Wt=null,Kt=null,qt=null,Zt}boxOverlapPercent(_e,Dt){if(_e.containsBox(Dt)||Dt.containsBox(_e))return 100;if(!(_e.min.x<Dt.max.x||Dt.min.x<_e.max.x))return 0;let Vt=new Vector3(0,0,0);_e.getSize(Vt),Vt.x*Vt.y*Vt.z;let Gt=new Vector3(0,0,0);Dt.getSize(Gt),Gt.x*Gt.y*Gt.z}checkInsideOutCollision(_e,Dt,Vt){let Gt=Dt.position.clone(),zt=new Float32Array(Vt.attributes.position.array),jt=zt.length/3;for(let Ht=0;Ht<jt;Ht++){let Wt=new Vector3(zt[Ht*3],zt[Ht*3+1],zt[Ht*3+2]),qt=Wt.add(Dt.position);qt=Wt.applyQuaternion(Dt.quaternion);let Xt=qt.sub(Dt.position);const Yt=new Raycaster(Gt,Xt.clone().normalize()).intersectObjects(_e),Zt=Yt.length>0,Jt=Yt[0].distance<Xt.length();if(Zt&&Jt)return!0}return!1}addNode(_e){this._nodes.push(_e)}getFirstNodeByCategoryID(_e){for(let Dt=0;Dt<this._nodes.length;Dt++)if(this._nodes[Dt]._categoryID==_e)return this._nodes[Dt];return null}getNodesBySKUID(_e){let Dt=[];for(let Vt=0;Vt<this._nodes.length;Vt++)this._nodes[Vt].skuID==_e&&Dt.push(this._nodes[Vt]);return Dt}getNodesByCategoryID(_e){let Dt=[];for(let Vt=0;Vt<this._nodes.length;Vt++)this._nodes[Vt]._categoryID==_e&&Dt.push(this._nodes[Vt]);return Dt}async connectPlugs({incomingPlug:_e,receiverPlug:Dt}){_e.attachPlug(Dt,!1),Dt.attachPlug(_e,!0),await this.stores.attachmentStore.getState().actions.toggleStructureUpdated()}removeNodeByGUID(_e){for(let Dt=0;Dt<this._nodes.length;Dt++)if(this._nodes[Dt].guid==_e){this._nodes[Dt].removeNode(),this._nodes.splice(Dt,1);break}this._nodes.length==1&&this.#t&&this.stores.coreSceneStore.getState().CORE_API.fireEvent(this.stores.coreSceneStore.getState().CORE_API.EVENTS.SCENE.Scene_Cleared,!0),this.stores.attachmentStore.getState().actions.updateFittingSkuIds(),this.stores.attachmentStore.getState().actions.toggleStructureUpdated()}async removeNodeFromStructure(_e){for(let Dt=0;Dt<this._nodes.length;Dt++)if(this._nodes[Dt].guid==_e.guid){this._nodes.splice(Dt,1);break}await this.stores.attachmentStore.getState().actions.toggleStructureUpdated()}}class AttachmentSystem{constructor(_e){this._globalVariants={},this._globalGeometryVariants={},this.stores=_e,this.stores.productDataStore.getState().categoryData.geometryVariants.map(Dt=>{this._globalGeometryVariants[Dt.id]=Dt.defaultVariant}),this.stores.productDataStore.getState().categoryData.color.map(Dt=>{this._globalVariants[Dt.id]=Dt.defaultLook}),this._currentStructure=new Structure(this.stores,null,this._globalVariants,this._globalGeometryVariants);for(const[Dt,Vt]of Object.entries(this._globalVariants))this.switchGlobalVariant(Dt,Vt);for(const[Dt,Vt]of Object.entries(this._globalGeometryVariants))this.switchGlobalGeometryVariant(Dt,Vt)}get globalGeometryVariants(){return this._globalGeometryVariants}get globalVariants(){return this._globalVariants}get currentStructure(){return this._currentStructure}getClientProductId(_e,Dt){let Vt;return Vt=this.stores.productDataStore.getState()?.productData[_e]?.lookDetails[Dt],Vt?.clientProductId?Vt?.clientProductId:""}getCartItems(){let _e=[];const Dt=this.stores.inventoryStore.getState().inventoryData;let Vt=!1;this.currentStructure.nodes.map(Ht=>{if(Ht.skuID=="Root"||Ht.ignoreInCart===!0)return;let Wt=!1;if(_e.map(Kt=>{const Yt=Dt[Kt.skuID];if(Kt.skuID==Ht.skuID&&Kt.currentVariant==Ht.currentVariant){Kt.count++,Kt.countAvailable=Yt[Ht.currentVariant].countAvailable,Kt.countUnavailable=Yt[Ht.currentVariant].countUnavailable,Kt.price=Ht.price*Kt.count,Kt.compareAtPrice=Ht.compareAtPrice*Kt.count,Wt=!0;return}}),Wt===!0)return;let qt={};qt.skuID=Ht.skuID,qt.currentVariant=Ht.currentVariant,qt.clientProductId=this.getClientProductId(qt.skuID,qt.currentVariant),qt.count=1;const Xt=Dt[qt.skuID];qt.price=Ht.price,qt.compareAtPrice=Ht.compareAtPrice*qt.count,Ht.compareAtPrice>0&&(Vt=!0),qt.countAvailable=Xt[Ht.currentVariant].countAvailable,qt.countUnavailable=Xt[Ht.currentVariant].countUnavailable,_e.push(qt)});let Gt=0,zt=0;for(const Ht of _e)Gt=Gt+Ht.price,Vt&&(zt=zt+(Ht.compareAtPrice==0?Ht.price:Ht.compareAtPrice));return{cartItems:_e,details:{total:Gt.toFixed(2),compareAtTotal:zt}}}async getCartItemsAsync(){let _e=[];const Dt=this.stores.inventoryStore.getState().inventoryData;let Vt=!1;this.currentStructure.nodes.map(Ht=>{if(Ht.skuID=="Root"||Ht.ignoreInCart===!0)return;let Wt=!1;if(_e.map(Kt=>{const Yt=Dt[Kt.skuID];if(Kt.skuID==Ht.skuID&&Kt.currentVariant==Ht.currentVariant){Kt.count++,Kt.countAvailable=Yt[Ht.currentVariant].countAvailable,Kt.countUnavailable=Yt[Ht.currentVariant].countUnavailable,Kt.price=Ht.price*Kt.count,Kt.compareAtPrice=Ht.compareAtPrice*Kt.count,Wt=!0;return}}),Wt===!0)return;let qt={};qt.skuID=Ht.skuID,qt.currentVariant=Ht.currentVariant,qt.clientProductId=this.getClientProductId(qt.skuID,qt.currentVariant),qt.count=1;const Xt=Dt[qt.skuID];qt.price=Ht.price,qt.compareAtPrice=Ht.compareAtPrice*qt.count,qt.compareAtPrice>0&&(Vt=!0),qt.countAvailable=Xt[Ht.currentVariant].countAvailable,qt.countUnavailable=Xt[Ht.currentVariant].countUnavailable,_e.push(qt)}),_e=await this.stores.dynamicHookStore.getState().hookOnCartItemsCollected(_e,this.stores.coreSceneStore.getState().CORE_API);let Gt=0,zt=0;for(const Ht of _e)Gt=Gt+Ht.price,Vt&&(zt=zt+(Ht.compareAtPrice==0?Ht.price:Ht.compareAtPrice));return{cartItems:_e,details:{total:Gt.toFixed(2),compareAtTotal:zt.toFixed(2)}}}async getFittingSKUIDs(){if(!this.currentStructure)return[];const{productData:_e}=this.stores.productDataStore.getState(),{sceneSettings:Dt}=this.stores.coreSceneStore.getState(),{draggableUI:Vt,ignoreSpawningCollision:Gt}=Dt;if(!this.currentStructure)return[];const{openPlugTypes:zt,closedPlugTypes:jt,existingSkuids:Ht}=this.analyzeCurrentStructure();if(zt.size===0&&jt.size===0)return[];const Wt=this.findFittingSkuids(_e,zt,jt,Ht,Vt);return this.filterNonBlockedSkuids(Wt,_e,Gt)}analyzeCurrentStructure(){const _e=this.currentStructure.nodes,Dt=new Set,Vt=new Set,Gt=new Set;for(const zt of _e){Gt.add(zt.skuID);for(const jt of zt.plugs)jt.isOpen?jt.acceptedPlugTypes.forEach(Ht=>Dt.add(Ht)):jt.attachedPlug.node.replace&&jt.acceptedPlugTypes.forEach(Ht=>Vt.add(Ht))}return{openPlugTypes:Dt,closedPlugTypes:Vt,existingSkuids:Gt}}findFittingSkuids(_e,Dt,Vt,Gt,zt){const jt=new Set;for(const[Ht,Wt]of Object.entries(_e))if(Wt.plugs)for(const qt of Wt.plugs){for(const Xt of qt.connectsToPlugTypes)if((this.isClosedPlugFitting(Ht,Wt,Xt,Vt,Gt,zt)||this.isOpenPlugFitting(Wt,Xt,Dt))&&jt.add(Ht),jt.has(Ht))break;if(jt.has(Ht))break}return jt}isClosedPlugFitting(_e,Dt,Vt,Gt,zt,jt){if(!Gt.has(Vt)||!jt&&zt.has(_e))return!1;const Ht=this.currentStructure.getNodesByCategoryID(Dt.categoryID);for(const Wt of Ht)if(Wt.skuID!==_e&&this.isNodeCompatible(Wt,Dt))return!0;return!1}isNodeCompatible(_e,Dt){let Vt=!1;for(const Gt of _e.plugs)if(!Gt.isOpen&&Gt.isReceiverPlug&&(Vt=!0,this.isPlugCompatible(Gt,Dt.plugs)))return!0;return!Vt}isPlugCompatible(_e,Dt){return Dt.some(Vt=>Vt.name===_e.name&&_e.attachedPlug.connectsToPlugTypes.some(Gt=>Vt.acceptedPlugTypes.includes(Gt)))}isOpenPlugFitting(_e,Dt,Vt){if(!Vt.has(Dt))return!1;const Gt=this.currentStructure.getFirstNodeByCategoryID(_e.categoryID);return!Gt||!Gt.replace}async filterNonBlockedSkuids(_e,Dt,Vt){const Gt=[];for(const zt of _e)if(Dt[zt].replace)Gt.push(zt);else{const jt=await this.currentStructure.findGhostTransforms(zt,Vt);jt&&jt.transforms.length>0&&Gt.push(zt)}return Gt}async removeAllVariantOverrides(){let _e=this._currentStructure.nodes,Dt=this.stores.productDataStore.getState().productData,Vt=this.stores.itemStore.getState().itemsSpawned;return await _e.map(async Gt=>{if(!Gt.overrideVariant||(Gt.overrideVariant=null,!Dt[Gt.skuID].looks))return;let zt=null;Object.keys(this._globalVariants).map(jt=>{Dt[Gt.skuID].looks.includes(this._globalVariants[jt])&&zt==null&&(zt=this._globalVariants[jt])}),zt&&await this.stores.itemStore.getState().actions.switchToVariant(Vt[Gt.guid].itemData,zt)}),this.stores.coreSceneStore.getState().CORE_API.alert({alertMsg:"Changes to individual items in the scene have been cleared",alertTime:6e3,alertType:"info",alertLabel:"Overrides Removed",alertId:"overridesRemoved"}),this.stores.coreSceneStore.getState().CORE_API.fireEvent(this.stores.coreSceneStore.getState().CORE_API.EVENTS.SCENE.MaterialOverrides_Exists,!1),!0}async switchGlobalGeometryVariant(_e,Dt){const Gt=this.stores.productDataStore.getState().categoryData.geometryVariants;let zt=null;if(Gt.map(Yt=>{Yt.id==_e&&(zt=Yt)}),!zt)return;const jt=zt.productsInCategory,Wt=zt.variants[Dt].productsToSwitch,qt=this.stores.itemStore.getState().itemsSpawned;let Xt=this.stores.productDataStore.getState().categoryData;Wt.map(Yt=>{jt.map(Zt=>{let Jt=!1;Zt.products.map(nn=>{Yt==nn&&(Jt=!0)}),Jt&&Xt.build.map(nn=>{Zt.products.map(rn=>{nn.skus.map((Qt,en)=>{nn.skus[en]==rn&&(nn.skus[en]=Yt)})})})})}),this._currentStructure.nodes.map(Yt=>{jt.map(Zt=>{Zt.products.map(Jt=>{Yt.skuID==Jt&&Yt.ref!==null&&Zt.products.map(nn=>{Wt.map(rn=>{if(rn==nn){const Qt=this.stores.productDataStore.getState().actions.getProductDataById(rn);let en=Qt.geometriesToHide;Yt.plugs.map(sn=>{!sn.isOpen&&sn.attachedPlug&&sn.type=="weighted_hider"&&sn.attachedPlug.weight>sn.weight&&(en=en.concat(sn.affectedNodes))}),Yt.showNodes(Qt.geometriesToShow),Yt.hideNodes(en),Yt.skuID=rn;const tn=qt[Yt.guid];tn&&tn.itemData&&Object.keys(Qt).map(sn=>{tn.itemData[sn]=Qt[sn]}),Yt.resetInStock(),Yt.updatePricing()}})})})})}),this._globalGeometryVariants[_e]=Dt,this.stores.hotspotStore.getState().actions.checkHotspotHealth(),this.stores.inventoryStore.getState().actions.refreshInventory(qt),this.stores.productDataStore.setState({categoryData:Xt}),this.stores.coreSceneStore.getState().CORE_API.fireEvent(this.stores.coreSceneStore.getState().CORE_API.EVENTS.SCENE.CategoryData_Updated,Xt),this.stores.coreSceneStore.getState().CORE_API.fireEvent(this.stores.coreSceneStore.getState().CORE_API.EVENTS.SCENE.GlobalGeometryVariant_Updated,this._globalGeometryVariants);const Kt=await this.getCartItemsAsync();Kt&&this.stores.coreSceneStore.getState().CORE_API.fireEvent(this.stores.coreSceneStore.getState().CORE_API.EVENTS.SCENE.CartItems_Updated,Kt)}async switchGlobalVariant(_e,Dt){this._globalVariants[_e]=Dt;const Vt=this.stores.itemStore.getState().actions;let Gt=this.stores.itemStore.getState().itemsSpawned;for(let Wt=0;Wt<Object.keys(Gt).length;Wt++){let qt=Gt[Object.keys(Gt)[Wt]];if(qt.itemData.looks&&qt.itemData.looks.includes(Dt)){let Xt=this._currentStructure.getNodeByGUID(qt.itemData.guid);Xt&&!Xt.overrideVariant&&await Vt.switchToVariant(qt.itemData,Dt)}}const zt=this.stores.productDataStore.getState().lookData;this.stores.lightStore.getState().actions.processLookEnvMapOverride(Dt);const jt=_e;Object.keys(Gt).length>0&&this.stores.coreSceneStore.getState().CORE_API.alert({alertMsg:jt.charAt(0).toUpperCase()+jt.slice(1)+" was successfully switched to "+zt[Dt].label+".",alertTime:3e3,alertType:"success",alertLabel:`${jt} Changed`,alertId:"materialVariantChanged"}),this.stores.coreSceneStore.getState().CORE_API.fireEvent(this.stores.coreSceneStore.getState().CORE_API.EVENTS.SCENE.GlobalVariant_Updated,this._globalVariants),this.stores.itemStore.setState({variantChangeAlert:!this.stores.itemStore.getState().variantChangeAlert});const Ht=await this.getCartItemsAsync();Ht&&this.stores.coreSceneStore.getState().CORE_API.fireEvent(this.stores.coreSceneStore.getState().CORE_API.EVENTS.SCENE.CartItems_Updated,Ht)}async#t(_e){if(!_e)return;LOGGER.info({title:"Structure to load",details:_e}),delete this._currentStructure,this._globalVariants={..._e.globalVariants},this._globalGeometryVariants=_e.globalGeometryVariants?{..._e.globalGeometryVariants}:{};const Dt=[..._e.structure];this._currentStructure=new Structure(this.stores,Dt,this._globalVariants,this._globalGeometryVariants);for(const[Vt,Gt]of Object.entries(this._globalVariants))this.switchGlobalVariant(Vt,Gt);for(const[Vt,Gt]of Object.entries(this._globalGeometryVariants))this.switchGlobalGeometryVariant(Vt,Gt);LOGGER.info({title:"Structure Loading..."}),await this._currentStructure.load(Dt),LOGGER.info({title:"Structure Loaded."})}async loadStructure(_e){if(!_e)return;this.stores.coreSceneStore.getState().CORE_API.fireEvent(this.stores.coreSceneStore.getState().CORE_API.EVENTS.UI.PreloadScreen_Show),this.stores.coreSceneStore.setState({configurationLoaded:!1}),await wait(500),await this._currentStructure.clear(),await this.#t(_e),this.stores.coreSceneStore.getState().preconfigurationLoaded?this.stores.coreSceneStore.getState().CORE_API.fireEvent(this.stores.coreSceneStore.getState().CORE_API.EVENTS.UI.PreloadScreen_Hide):this.stores.coreSceneStore.setState({preconfigurationLoaded:!0}),this.stores.coreSceneStore.getState().configurationLoadedOnRestart||this.stores.coreSceneStore.setState({configurationLoadedOnRestart:!0}),this.stores.coreSceneStore.setState({configurationLoaded:!0}),await this.stores.attachmentStore.getState().actions.toggleStructureUpdated();const Dt=this.stores.itemStore.getState().itemsSpawned;this.stores.coreSceneStore.getState().CORE_API.fireEvent(this.stores.coreSceneStore.getState().CORE_API.EVENTS.SCENE.Items_Updated,{itemsSpawned:Dt}),this.stores.inventoryStore.getState().actions.refreshInventory(Dt),await this.stores.attachmentStore.getState().actions.updateFittingSkuIds()}export(){return{experienceId:this.stores.coreSceneStore.getState().CORE_API.experienceId,structure:this._currentStructure.export(),globalVariants:this._globalVariants,globalGeometryVariants:this._globalGeometryVariants}}async clear(){this.stores.coreSceneStore.getState().CORE_API.fireEvent(this.stores.coreSceneStore.getState().CORE_API.EVENTS.UI.PreloadScreen_Show),await this._currentStructure.clear(),this.stores.coreSceneStore.getState().CORE_API.fireEvent(this.stores.coreSceneStore.getState().CORE_API.EVENTS.UI.PreloadScreen_Hide)}async restart(){LOGGER.warn({title:"Restarting the Scene!!"}),this.stores.itemStore.getState().selectedItemData&&this.stores.itemStore.getState().actions.deselectItem();const _e=this.stores.attachmentStore.getState().defaultConfig;this.stores.coreSceneStore.setState({configurationLoaded:!1,configurationLoadedOnRestart:!1}),this.stores.coreSceneStore.getState().CORE_API.fireEvent(this.stores.coreSceneStore.getState().CORE_API.EVENTS.UI.PreloadScreen_Show),await wait(500),await this._currentStructure.clear(),await this.#t(_e),await this.stores.attachmentStore.getState().actions.toggleStructureUpdated(),this.stores.coreSceneStore.setState({configurationLoaded:!0,configurationLoadedOnRestart:!0}),this.stores.coreSceneStore.getState().CORE_API.fireEvent(this.stores.coreSceneStore.getState().CORE_API.EVENTS.UI.PreloadScreen_Hide);const Dt=this.stores.itemStore.getState().itemsSpawned;this.stores.coreSceneStore.getState().CORE_API.fireEvent(this.stores.coreSceneStore.getState().CORE_API.EVENTS.SCENE.Items_Updated,{itemsSpawned:Dt}),this.stores.inventoryStore.getState().actions.refreshInventory(Dt),await this.stores.attachmentStore.getState().actions.updateFittingSkuIds()}}const createAttachmentStore=kt=>{const _e=attachmentStoreCreator();return _e.setState({stores:kt}),_e},attachmentStoreCreator=()=>create((kt,_e)=>({stores:null,attachmentSystem:null,defaultConfig:null,structureUpdated:!1,colliderMeshRef:null,placeholderRef:null,draggingItem:null,snappingThreshold:.5,actions:{initializeAttachmentSystem:async Dt=>{const{actions:Vt,defaultConfig:Gt}=_e();LOGGER.info({title:"Initializing Attachment System!"});const zt=await new AttachmentSystem(Dt);kt({attachmentSystem:zt}),await Vt.updateFittingSkuIds(),await Vt.toggleStructureUpdated()},loadSavedStructureFromConfigID:async Dt=>{const{stores:Vt}=_e();LOGGER.info({title:"Fetching Structure Using ConfigID!"});let Gt="";Dt.length==20&&(Gt=FETCH_CONFIG_ENDPOINT_FB+Dt);let zt=null;return Gt!=""?zt=await getJSONFromEndpoint(Gt):zt=await Vt.nexusApiInstance.getExperienceSaveAndShare(Vt.experienceId,Dt),zt.success===!1?null:Dt.length==20?zt.data:zt.payload.save_data},loadDefaultStructure:async()=>{const{actions:Dt,defaultConfig:Vt}=_e();LOGGER.info({title:"Loading Default Structure!"}),await Dt.loadStructure(Vt)},updateFittingSkuIds:async()=>{const{stores:Dt,attachmentSystem:Vt}=_e();if(!Dt.coreSceneStore.getState().preconfigurationLoaded||!Dt.coreSceneStore.getState().configurationLoaded)return;const Gt=await Vt.getFittingSKUIDs();Gt&&(Dt.itemStore.setState({fittingSkuIds:[...Gt]}),Dt.coreSceneStore.getState().CORE_API.fireEvent(Dt.coreSceneStore.getState().CORE_API.EVENTS.SCENE.FittingSkuIds_Updated,{skuids:Gt}))},toggleStructureUpdated:async()=>{const{attachmentSystem:Dt,stores:Vt}=_e();if(kt(zt=>({structureUpdated:!zt.structureUpdated})),!Vt.coreSceneStore.getState().preconfigurationLoaded||!Vt.coreSceneStore.getState().configurationLoaded)return;Vt.coreSceneStore.getState().CORE_API.fireEvent(Vt.coreSceneStore.getState().CORE_API.EVENTS.SCENE.ReplaceableCategory_Updated,Dt.currentStructure.getCurrentItemsInReplaceableCategory());const Gt=await Dt.getCartItemsAsync();Gt&&Vt.coreSceneStore.getState().CORE_API.fireEvent(Vt.coreSceneStore.getState().CORE_API.EVENTS.SCENE.CartItems_Updated,Gt)},loadStructure:async Dt=>{const{attachmentSystem:Vt,stores:Gt}=_e();LOGGER.info({title:"Loading Structure!"}),Vt&&Gt.coreSceneStore.getState().configurationLoaded!==!1&&await Vt.loadStructure(Dt)},export:()=>{const{attachmentSystem:Dt}=_e();if(Dt)return Dt.export()}}})),createInfoStore=kt=>{const _e=infoStoreCreator();return _e.setState({stores:kt}),_e},infoStoreCreator=()=>create((kt,_e)=>({stores:null,infoObject:{},populateInfoObject:Dt=>{kt(Vt=>({infoObject:Dt}))},infoModalOpen:!1,updateInfoModalOpen:Dt=>{kt(Vt=>({infoModalOpen:Dt}))}})),createUIHotspotStore=kt=>{const _e=uiHotspotStoreCreator();return _e.setState({stores:kt}),_e},uiHotspotStoreCreator=()=>create((kt,_e)=>({stores:null,activeHotspotData:null,activeFeatureID:"",actions:{enterHotspotInFeaturesTab(Vt){const{stores:Gt}=_e();Gt.uiSceneStore.getState().sideMenuState!==2&&Gt.uiSceneStore.setState({sideMenuState:2}),kt({activeFeatureID:Vt})},exitHotspot(){kt({activeFeatureID:null})}}})),createColorStore=kt=>{const _e=colorStoreCreator();return _e.setState({stores:kt}),_e},colorStoreCreator=()=>create((kt,_e)=>({stores:null,allActiveVariants:{},allActiveGeometryVariants:{}})),arrayWithoutElementAtIndex=function(kt,_e){return kt.filter(function(Dt,Vt){return _e!==Vt})},updateQuantityAtIndex=function(kt,_e,Dt){let Vt=kt.slice();return Vt[_e].quantity=Dt,Vt},createCartStore=kt=>{const _e=cartStoreCreator();return _e.setState({stores:kt}),_e},cartStoreCreator=()=>create((kt,_e)=>({stores:null,cart:[],cartTotalPrice:0,cartTotalCompareAtPrice:0,deleteCartItem:Dt=>{kt(Vt=>({cart:arrayWithoutElementAtIndex(Vt.cart,Dt)}))},addToCart:Dt=>{kt(Vt=>({cart:[...Vt.cart,Dt]}))},updateQuantity:(Dt,Vt)=>{kt(Gt=>({cart:updateQuantityAtIndex(Gt.cart,Dt,Vt)}))},previewCartModalOpen:!1,togglePreviewCartModal:()=>{const{previewCartModalOpen:Dt,stores:Vt}=_e();Dt===!0?(Vt.uiSceneStore.getState().CORE_API.reviewCartHidden(),kt({previewCartModalOpen:!1,previewCartMinimized:!1})):(Vt.uiSceneStore.getState().CORE_API.reviewCartShown(),kt({previewCartModalOpen:!0}))},previewCartMinimized:!1,togglePreviewCartMinimized:()=>{const{previewCartMinimized:Dt,stores:Vt}=_e(),Gt=!Dt;kt({previewCartMinimized:Gt}),Vt&&Vt.uiSceneStore&&Vt.uiSceneStore.getState().setSideMenuOpen(!Gt)},actions:{setCartTotalPrice:(Dt,Vt)=>{kt(()=>({cartTotalPrice:Dt,cartTotalCompareAtPrice:Vt}))}}})),createLightStore=kt=>{const _e=lightStoreCreator();return _e.setState({stores:kt}),_e},lightStoreCreator=()=>create((kt,_e)=>({stores:null,defaultEnvMapUrl:"<@generic-project@>/env-map/neutral.hdr",envMapUrl:"",actions:{setEnvLightMap:Dt=>{kt(Vt=>({envMapUrl:Dt}))},processLookEnvMapOverride:Dt=>{const{envMapUrl:Vt,defaultEnvMapUrl:Gt,actions:zt,stores:jt}=_e(),Ht=jt.productDataStore.getState().lookData[Dt],Wt=Ht?.envMapOverride;if(!Ht||!Wt){zt.setEnvLightMap(Gt);return}if(Wt===Vt){LOGGER.info({title:`New Env Map Url is the same as the current ${Wt}`});return}zt.setEnvLightMap(Wt)}}})),createHotspotStore=kt=>{const _e=hotspotStoreCreator();return _e.setState({stores:kt}),_e},hotspotStoreCreator=()=>create((kt,_e)=>({stores:null,activeHotspotData:null,lastActiveHotspotData:null,isAnyHotspotActive:!1,hotspotsVisibility:!1,hotspotsTempVisibility:!0,hotspotsHealthCheck:!0,hotspotsSpawned:{},visitedHotspotsID:[],hotspotSpawnedForCategoryIDs:[],actions:{clearAllHotspots:()=>kt({isAnyHotspotActive:!1,activeHotspotData:null,lastActiveHotspotData:null,hotspotsSpawned:{}}),removeHotspotForItem(Dt){const{hotspotsSpawned:Vt}=_e();Object.keys(Vt).map(Gt=>{Vt[Gt].itemData.guid==Dt.itemData.guid&&delete Vt[Gt]}),kt({hotspotsSpawned:{...Vt}})},checkHotspotHealth(){const{hotspotsHealthCheck:Dt}=_e();kt({hotspotsHealthCheck:!Dt})},toggleHotspotVisibility(){const{hotspotsVisibility:Dt}=_e();kt({hotspotsVisibility:!Dt})},switchHotspotsVisibility(Dt,Vt=!1){kt(Vt===!0?{hotspotsTempVisibility:Dt}:{hotspotsVisibility:Dt})},clickHotspot(Dt,Vt,Gt,zt=!1){const{activeHotspotData:jt,stores:Ht}=_e();kt({lastActiveHotspotData:jt}),hotspotEnter(Ht,Dt,Vt,Gt);let qt=Ht.itemStore.getState().itemsSpawned[Gt].itemData.skuID;zt===!1&&(Ht.coreSceneStore.getState().CORE_API.fireEvent(Ht.coreSceneStore.getState().CORE_API.EVENTS.SCENE.Hotspot_Enter,{hotspotAbsID:generateHotspotAbsoluteID(qt,Dt),hotspot:jt}),Ht.coreSceneStore.getState().CORE_API.fireEvent(Ht.coreSceneStore.getState().CORE_API.EVENTS.UI.UtilityMenu_Hide))},exitHotspot(Dt=!1){const{activeHotspotData:Vt,isAnyHotspotActive:Gt,stores:zt}=_e();if(Gt&&kt({isAnyHotspotActive:!1}),!!Vt&&(kt({lastActiveHotspotData:Vt}),hotspotExit(zt),Dt===!1)){const jt=Math.round((performance.now()-_e().lastActiveHotspotData.hotspotEnterTime)/1e3);zt.coreSceneStore.getState().CORE_API.fireEvent(zt.coreSceneStore.getState().CORE_API.EVENTS.SCENE.Hotspot_Exit,{hotspot:_e().lastActiveHotspotData,hotspotTimeSpent:jt}),zt.coreSceneStore.getState().CORE_API.fireEvent(zt.coreSceneStore.getState().CORE_API.EVENTS.UI.UtilityMenu_Show)}}}}));function hotspotExit(kt){kt.hotspotStore.setState({activeHotspotData:null}),kt.coreSceneStore.getState().actions.triggerAutoFocus()}function hotspotEnter(kt,_e,Dt,Vt){let Gt=kt.hotspotStore.getState();const jt=kt.itemStore.getState().itemsSpawned;let Ht=Gt.visitedHotspotsID;const Wt=jt[Vt].hotspotsData.filter(un=>un.hotspotID==_e);if(!Wt||Wt.length<=0)return;const qt=Wt[0],Xt=jt[Vt].itemData.skuID+"_"+_e;let Yt=kt.attachmentStore.getState().attachmentSystem.currentStructure.getNodeByGUID(Vt),Zt=new Vector3(0,0,0);Yt&&Yt.ref&&Yt.ref.getWorldPosition(Zt);let Jt=new Quaternion().identity();Yt&&Yt.ref&&Yt.ref.getWorldQuaternion(Jt);let nn=qt.focusPointTransform,rn=ArrToVec3(nn);rn.applyQuaternion(Jt);let Qt=qt.viewPointTransform,en=ArrToVec3(Qt);en.applyQuaternion(Jt);let tn=addVector(Vec3ToArr(rn),Vec3ToArr(Zt)),sn=addVector(Vec3ToArr(en),Vec3ToArr(Zt));kt.cameraStore.setState({focusPointPosition:tn,viewPointPosition:sn}),kt.hotspotStore.setState({activeHotspotData:{hotspotData:{guid:Dt,...qt},itemData:{...jt[Vt],guid:Vt},domID:"rd_"+Xt,hotspotEnterTime:performance.now()},isAnyHotspotActive:!0}),Ht.includes(Xt)||(Ht.push(Xt),kt.hotspotStore.setState({visitedIDs:{...Ht}}))}var replacingNodes=null,swappableNodes=[];const createGhostStore=kt=>{const _e=ghostStoreCreator();return _e.setState({stores:kt}),_e},ghostStoreCreator=()=>create((kt,_e)=>({stores:null,ghostData:null,ghostsTransform:[],ghostVisibility:!0,ghostParentRef:null,ghostMaterial:null,actions:{spawnGhostsForSkuID:async(Dt,Vt=!1,Gt)=>{const{ghostData:zt,ghostsTransform:jt,stores:Ht}=_e();if(zt!==null||jt.length>0){LOGGER.info({title:"ghosts are already spawned for: "+zt.skuID});return}return await new Promise(async(qt,Xt)=>{let Kt={};const Yt=()=>{qt(Kt)};Ht.coreSceneStore.getState().CORE_API.coreWCRef.addEventListener(Ht.coreSceneStore.getState().CORE_API.EVENTS.SCENE.Ghost_Loaded,Yt,{once:!0});const Zt=Ht.productDataStore.getState().productData,Jt=Ht.attachmentStore.getState().attachmentSystem.currentStructure;replacingNodes=Jt.getNodesByCategoryID(Zt[Dt].categoryID);const nn=Ht.coreSceneStore.getState().sceneSettings.draggableUI,rn=await Jt.findGhostTransforms(Dt,Vt),Qt=nn?rn&&rn.transforms&&rn.transforms.length===0:!0;if(Zt[Dt].replace&&replacingNodes.length>0&&Qt)if(nn){const{newNodes:tn,transforms:sn,connectablePlugs:cn}=await Jt.findGhostTransformForReplacement(Dt,replacingNodes);if(sn==null||cn==null||sn.length<=0){LOGGER.error({title:"Couldn't Find Ghost transforms and connectablePlugs for "+Dt});return}let un=[];for(const hn of tn)hn.setModelVisibility(!1),un.push("replace");Kt.transforms=sn,Kt.newNodes=tn,Kt.connectablePlugs=cn,Kt.addItemOrSwap=un}else{const{newNodes:tn,transforms:sn,connectablePlugs:cn}=await Jt.findGhostTransformForReplacement(Dt,replacingNodes);if(sn==null&&cn==null){LOGGER.error({title:"Couldn't Find Ghost transforms and connectablePlugs for "+Dt});return}let un=[];for(const hn of tn)hn.setModelVisibility(!1),un.push("replace");Kt.transforms=sn,Kt.newNodes=tn,Kt.connectablePlugs=cn,Kt.addItemOrSwap=un}else{const{transforms:tn,newNodes:sn,connectablePlugs:cn,comboPlugs:un}=rn;let hn=tn,fn=cn,pn=sn,dn=[];for(let mn=0;mn<tn.length;mn++)dn.push("add");if(Zt[Dt].swappable&&!Ht.coreSceneStore.getState().dragging){swappableNodes=Jt.getNodesByCategoryID(Zt[Dt].categoryID);const mn=await Jt.findGhostTransformForReplacement(Dt,swappableNodes);if(mn.transforms)for(let vn=0;vn<mn.transforms.length;vn++)hn.push(mn.transforms[vn]),fn.push(mn.connectablePlugs[vn]),pn.push(mn.newNodes[vn]),dn.push("replace"),mn.newNodes[vn].setModelVisibility(!1)}Kt.transforms=hn,Kt.newNodes=pn,Kt.connectablePlugs=fn,Kt.comboPlugs=un,Kt.addItemOrSwap=dn}if(Kt.transforms.length<=0){Xt();return}const en=await Ht.assetStore.getState().actions.loadProxyAsset(Dt,!0);kt({ghostsTransform:Kt.transforms,ghostData:{proxyScene:en.proxy.data.scene,skuID:Dt,newNodes:Kt.newNodes,addItemOrSwap:Kt.addItemOrSwap,connectablePlugs:Kt.connectablePlugs,comboPlugs:Kt.comboPlugs,count:Gt||Kt.transforms.length}})})},clearAllGhosts:()=>{const{ghostsTransform:Dt}=_e();if(replacingNodes)for(const Vt of replacingNodes)Vt.setModelVisibility(!0);if(swappableNodes)for(let Vt=0;Vt<swappableNodes.length;Vt++)swappableNodes[Vt].setModelVisibility(!0);Dt.length<=0||kt({ghostVisibility:!0,ghostData:null,ghostsTransform:[]})}}})),createCameraStore=kt=>{const _e=cameraStoreCreator();return _e.setState({stores:kt}),_e},cameraStoreCreator=()=>create((kt,_e)=>({stores:null,focusPointPosition:new Vector3(0,0,0),sendCameraDetailsTrigger:!1,viewPointPosition:new Vector3(0,0,0),boundsMargin:0,savedState:!1,resetToLastPosition:!0,cameraControlsRef:null,userDragging:!1,disableAutoRotate:!1,cameraSettings:{truckSpeed:1,fov:35,dollySpeed:1,initialViewPointPosition:new Vector3(20,15,50),canZoom:!1,canPan:!1,minZoom:1,maxZoom:3,canAutoRotate:!1,autoRotateSpeed:.5,minPolarAngle:0,maxPolarAngle:180,clearColour:"white",zoomingMultiplier:0},actions:{canCameraRotate:Dt=>{const{cameraControlsRef:Vt}=_e();Vt&&(Dt===!0?(Vt.mouseButtons.left=CAMERA_ACTION.ROTATE,Vt.touches.one=CAMERA_ACTION.TOUCH_ROTATE):(Vt.mouseButtons.left=CAMERA_ACTION.NONE,Vt.touches.one=CAMERA_ACTION.NONE))},triggerFetchingCamera:()=>{kt(Dt=>({sendCameraDetailsTrigger:!Dt.sendCameraDetailsTrigger}))},setCameraSettings:Dt=>{const{cameraSettings:Vt,stores:Gt}=_e();Gt.coreSceneStore.getState().isMobile===!0&&Dt.zoomingMultiplier_mobile!==void 0?Dt.zoomingMultiplier=Dt.zoomingMultiplier_mobile:Dt.zoomingMultiplier_desktop!==void 0&&(Dt.zoomingMultiplier=Dt.zoomingMultiplier_desktop),Object.keys(Dt).map(jt=>Vt[jt]=Dt[jt]),kt({cameraSettings:{...Vt},viewPointPosition:ArrToVec3(Vt.initialViewPointPosition)})}}})),createUISceneStore=kt=>{const _e=uiSceneStoreCreator();return _e.setState({stores:kt}),_e},uiSceneStoreCreator=()=>create((kt,_e)=>({stores:null,CORE_API:null,sideMenuState:0,sideMenuOpen:!0,setSideMenuOpen:Dt=>kt({sideMenuOpen:Dt}),cssLoaded:!1,isScreenPortrait:!0,materialOverrideExists:!1,tabSpawnCount:[],coreWCRef:null,removeModalOpen:!1,outOfStockModalOpen:!1,disableCart:!1,inventoryData:{},cartMessage:"",loadConfigId:"",dialogPopupOpen:!1,viewInYourSpaceMenuBtnVisible:!1,loadConfigModalOpen:!1,setLoadConfigModalOpen:Dt=>kt({loadConfigModalOpen:Dt}),setOutOfStockModalOpen:Dt=>kt({outOfStockModalOpen:Dt}),setRemoveModalOpen:Dt=>kt({removeModalOpen:Dt}),moveModalOpen:!1,setMoveModalOpen:Dt=>kt({moveModalOpen:Dt}),setCSSLoaded:Dt=>{kt({cssLoaded:Dt})},setSideMenuState:Dt=>{kt(()=>({sideMenuState:Dt}));const{CORE_API:Vt}=_e();Dt!==2?Vt.exitHotspot():Vt.showAllHotspots()}})),createDynamicHookStore=kt=>{const _e=dynamicHookStoreCreator();return _e.setState({stores:kt}),_e},dynamicHookStoreCreator=()=>create((kt,_e)=>({hookOnCartItemsCollected:async(Dt,Vt)=>(LOGGER.info({title:"No hook provided: hookOnCartItemsCollected"}),Promise.resolve(Dt)),hookOnSceneItemsUpdated:async(Dt,Vt)=>(LOGGER.info({title:"No hook provided: hookOnSceneItemsUpdated"}),Promise.resolve()),hookOnNewItemGhostsCollected:async(Dt,Vt)=>(LOGGER.info({title:"No hook provided: hookOnNewItemGhostsCollected"}),Promise.resolve(Dt)),hookOnNewItemGhostsCollectedForReplacement:async(Dt,Vt)=>(LOGGER.info({title:"No hook provided: hookOnNewItemGhostsCollected"}),Promise.resolve(Dt)),hookOnSceneItemAdded:async(Dt,Vt,Gt)=>(LOGGER.info({title:"No hook provided: hookOnSceneItemAdded"}),Promise.resolve()),hookOnCheckout:async(Dt,Vt)=>(LOGGER.info({title:"No hook provided: hookOnSceneItemAdded"}),Promise.resolve(Dt))}));class STORES{experienceId="";uuid=null;wcRef=null;nexusApiResponseEnvironment="production";nexusApiInstance=null;productDataStore=null;coreSceneStore=null;inventoryStore=null;itemStore=null;assetStore=null;attachmentStore=null;lightStore=null;hotspotStore=null;ghostStore=null;cameraStore=null;infoStore=null;uiHotspotStore=null;colorStore=null;cartStore=null;uiSceneStore=null;constructor(_e){this.wcRef=_e,this.uuid=v4(),this.dynamicHookStore=createDynamicHookStore(this),this.productDataStore=createProductDataStore(this),this.coreSceneStore=createCoreSceneStore(this),this.inventoryStore=createInventoryStore(this),this.itemStore=createItemStore(this),this.assetStore=createAssetStore(this),this.attachmentStore=createAttachmentStore(this),this.lightStore=createLightStore(this),this.hotspotStore=createHotspotStore(this),this.ghostStore=createGhostStore(this),this.cameraStore=createCameraStore(this),this.infoStore=createInfoStore(this),this.uiHotspotStore=createUIHotspotStore(this),this.colorStore=createColorStore(this),this.cartStore=createCartStore(this),this.uiSceneStore=createUISceneStore(this)}setupNexusApiInstance(_e){let Dt=p$5.PRODUCTION;_e=="local"?Dt=p$5.LOCAL:_e==="staging"&&(Dt=p$5.STAGING);const Vt=window.location.href,Gt=window.epigraph?window.epigraph.epigraphSessionId:"no-session-id",zt="2.2.3",jt=g$3.generateXPath(this.wcRef);this.nexusApiInstance=new P$2(Dt,Vt,Gt,zt,jt)}}class EpigraphConfigurator extends h$5{#t=void 0;#i=null;#n=null;clientAccessKey=null;validationPassed=!1;projectID="";configID="default";customVersionId="";experienceId="";apiMode="production";gaMeasurementId="";#s=getUrlParameterByName("launchInAR")==="true";#r=!1;api={core:null,ui:null};stores=null;constructor(){let _e=s$2.PRODUCTION;super("2.2.3",_e),this.stores=new STORES(this),this.api.ui=this,this.shadowRoot||this.attachShadow({mode:"open"}),this.hasAttribute("launch-in-ar")&&(this.#s=!0),this.#c(),this.#o()}#c(){this.preloadDiv=document.createElement("div"),this.preloadDiv.id="preloadMainContainer",this.preloadDiv.classList.add("preload-main-container"),this.preloadDiv.classList.add("showPreload"),this.preloadDiv.appendChild(PRELOAD_MUTED_CSS.content.cloneNode(!0)),this.preloadDiv.appendChild(PRELOAD_HTML_TEMPLATE.content.cloneNode(!0)),this.shadowRoot.appendChild(this.preloadDiv);const _e=this.shadowRoot;this.#n=Dt=>{if(Dt.code=="Enter"){let Vt=_e.activeElement;Vt&&Vt.click()}},this.shadowRoot.addEventListener("keyup",this.#n)}#o(){this.hiccupUi=document.createElement("div"),this.hiccupUi.id="hiccupMainContainer",this.hiccupUi.classList.add("hiccup-ui-main-container"),this.hiccupUi.appendChild(HICCUP_MUTED_CSS.content.cloneNode(!0)),this.hiccupUi.appendChild(HICCUP_HTML_TEMPLATE.content.cloneNode(!0)),this.shadowRoot.appendChild(this.hiccupUi)}get configuratorWcId(){return this.#t}get launchInAr(){return this.#s}#a(){if(this.hasAttribute("id")?this.#t=this.getAttribute("id"):(this.setAttribute("id","epigraphConfiguratorWc"),this.#t=this.getAttribute("id")),this.hasAttribute("custom-version-id")&&(this.customVersionId=this.getAttribute("custom-version-id")),this.hasAttribute("experience-id")&&(this.experienceId=this.getAttribute("experience-id")),this.hasAttribute("api-mode")){const _e=this.getAttribute("api-mode");["local","staging","production"].includes(_e)&&(this.apiMode=_e)}this.stores.setupNexusApiInstance(this.apiMode),(this.hasAttribute("ga-measurement-id")||this.hasAttribute("ga-code"))&&(this.gaMeasurementId=this.getAttribute("ga-measurement-id")??this.getAttribute("ga-code")),this.clientAccessKey=this.getAttribute("client-access-key"),this.initialConfigId=this.getAttribute("initial-config-id"),this.consentPlugin=this.getAttribute("consent-plugin"),this.consentIdentifier=this.getAttribute("consent-identifier"),this.initialConfigId||(this.initialConfigId="default")}async connectedCallback(){if(this.#r===!0){console.warn("Tried to remount configurator. Blocking the process.");return}this.#a(),this.style.maxWidth="1440px",this.style.maxHeight="800px",this.style.overflow="hidden",this.style.width="100%",this.style.height="100%",this.style.position="relative",this.style.visibility="visible",this.style.display="flex";const _e=document.createElement("div");_e.id="configuratorContainer",_e.style.width="100%",_e.style.height="100%",_e.style.userSelect="none",_e.style.overflow="hidden",this.shadowRoot.appendChild(_e),this.#i=createRoot(_e),this.#i.render(jsxRuntimeExports.jsx(App,{stores:this.stores,customVersionId:this.customVersionId,experienceId:this.experienceId,disableUI:this.hasAttribute("disable-ui"),disableCart:this.hasAttribute("disable-cart"),configuratorWcRef:this,gaMeasurementId:this.gaMeasurementId},"Configurator-App")),this.#r=!0}disconnectedCallback(){for(this.#i&&(this.#i.unmount(),this.#i=null),this.#n&&(this.shadowRoot.removeEventListener("keyup",this.#n),this.#n=null),this.#t=void 0,this.clientAccessKey=null,this.validationPassed=!1,this.projectID="",this.configID="default",this.customVersionId="",this.gaMeasurementId="",this.#s=!1,this.#r=!1,this.api={core:null,ui:null},this.preloadDiv&&(this.preloadDiv.remove(),this.preloadDiv=null),this.hiccupUi&&(this.hiccupUi.remove(),this.hiccupUi=null);this.shadowRoot.firstChild;)this.shadowRoot.removeChild(this.shadowRoot.firstChild)}showPreloadScreen(){this.preloadDiv&&(this.preloadDiv.classList.remove("no-pointer-events"),this.preloadDiv.classList.add("showPreload"))}async hidePreloadScreen(){this.preloadDiv&&(this.preloadDiv.classList.remove("showPreload"),await wait(1e3),this.preloadDiv.classList.add("no-pointer-events"))}showHiccupScreen(){this.hiccupUi&&(this.hiccupUi.classList.remove("no-pointer-events"),this.hiccupUi.classList.add("show-hiccup"))}async hideHiccupScreen(){this.hiccupUi&&(this.hiccupUi.classList.remove("show-hiccup"),await wait(1e3),this.hiccupUi.classList.add("no-pointer-events"))}}window.customElements.define("epigraph-configurator",EpigraphConfigurator);
4796
+ `;const createCoreSceneStore=kt=>{const _e=coreStoreCreator();return _e.setState({stores:kt}),_e},coreStoreCreator=()=>create((kt,_e)=>({stores:null,shadowRefreshKey:0,CORE_API:null,coreReady:void 0,frameloop:"always",hoveredGhostIndex:-1,itemDraggedSkuID:null,screenshotRenderer:new WebGLRenderer({antiAlias:!0,preserveDrawingBuffer:!0}),screenshotCamera:new PerspectiveCamera(75,1.33,.1,1e3),builderMode:!1,dragging:!1,bbox:null,draggingItemGUID:null,sceneRef:null,cssLoaded:!1,sceneHasDefaultConfigurationID:!1,configurationLoaded:!0,preconfigurationLoaded:!1,configurationLoadedOnRestart:!0,cursorParentRef:null,glContext:null,canvasTooltipText:"",canvasSize:{width:600,height:600},boundData:{center:new Vector3(0,0,0),size:new Vector3(0,0,0)},showDimensions:!1,autoFocusTrigger:0,cameraActive:!1,autoFocusRef:null,alertData:{},persistantAlertData:null,alertQueue:[],currentAlertData:null,alertSettings:null,draggingOnDropCollisionData:null,multipleTouchDetected:!1,isMobile:!1,isTouchDevice:!1,isTablet:!1,isDesktop:!0,isLandscape:!1,sceneSettings:{usdzMaxTextureSize:1024,usdzPrecision:7,swappableRoot:!0,ghostColorOnHoverWithDraggableUi:{r:153,g:252,b:0,a:1},preserveDrawingBuffer:!1,showSaveBtn:!0,showShareBtn:!0,showResetBtn:!0,showDimensionBtn:!0,showViewInYourSpaceBtn:!0,showDependencyOnHover:!1,showContextMenu:!0,showHotspotsBtn:!0,showInstructionsBtn:!1,showInstructionsOnStartup:!1,sceneScaleUnit:"ft",arPlacement:"floor",arTransforms:{position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]},currency:"$",disableDragDrop:!1,ignoreSpawningCollision:!1,disableCollider:!1,disableContextMenu:!1,ghostColor:{r:10,g:10,b:10,a:.2},technicalRequirements:{minIosVersion:"11"},ghostScale:[1,1,1],ghostAsWireframe:!1,draggableUI:!1,addFromInfoModal:!1,clickToAddUi:!0,accordionInBuildUi:!1,outOfStock_EmissiveColor:{r:250,g:50,b:0},outOfStock_EmissiveIntensity:.002,defaultConfigurationID:null,emptySceneText:null,emptySceneTextFontSize:"2rem",addToCartCTAText:"Add To Cart",ignoreCollisionPostDragging:!1,comboPlugDistanceThreshold:.05,disableCart:!1,dimensionColor:{r:0,g:0,b:0},disableLocalColorOverride:!1,analyticsEventPrefix:"",outlineSettings:{multisampling:10,visibleEdgeColor:new Color$1("#0f0").convertSRGBToLinear(),hiddenEdgeColor:new Color$1("#0f0").convertSRGBToLinear(),blur:3,width:1e3,edgeStrength:1e3,blendFunction:BlendFunction.ALPHA,pulseSpeed:0,xRay:!0},textSettings:{arButtonLabel:"AR",arHoverLabel:"View In Your Space",restartButtonLabel:"Restart",restartHoverLabel:"Restart",saveButtonLabel:"Save",saveHoverLabel:"Save",shareButtonLabel:"Share",shareHoverLabel:"Share",sizeButtonLabel:"Size",sizeHoverLabel:"Size",hotspotsButtonLabel:"Hotspots",hotspotsHoverLabel:"Hotspots",instructionsButtonLabel:"Instructions",instructionsHoverLabel:"Instructions",cartQuantityText:"Qty",reviewButtonText:"Review",cartHeadingText:"Review Products",buildTabHeadingText:"Build",colorTabHeadingText:"Color",featuresTabHeadingText:"Features",featuresTabEmptyText:"*Please add an item to the scene to see the features",tooltipEmptySceneText:"",tooltipInstructionText:"-Drag to rotate the camera-"},variantsTabOrder:{color:{enabled:!0,priority:1},geometryVariants:{enabled:!0,priority:2}},boundingBoxLeeway:.9,contactShadowVisibility:!0,measurementPrecision:2,disableAlerts:!1,focusCameraOnGhosts:!0,alertLevel:2999,alertControl:{default:!0,itemAdded:!0,geometryVariantChanged:!0,overridesRemoved:!0,materialVariantChanged:!0,itemRemoved:!0,itemRepositioned:!0,configurationSaved:!0,linkCopied:!0,outOfStock:!0,unvisualizedItemSpawn:!0},screenshotCameras:[{position:new Vector3(-2.5,.6,-5),rotation:new Vector3(-3.1097068566150314,-.6437852162982552,-3.122449778846033)},{position:new Vector3(3,1,-5),rotation:new Vector3(-.5,1,.5)}],instructionsSettings_desktop:[{header:"Add to Scene",description:"Click to add individual modules to the scene.",lottieURL:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_1A_Drag_Drop/Non-furniture_Step_1A.json"},{header:"Rearrange Modules",description:"Drag & drop individual modules in the scene to rearrange.",lottieURL:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_2/Non-furniture_Step_2.json"},{header:"Remove Modules",description:"Click to select and remove individual modules from the scene.",lottieURL:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_3/Non-furniture_Step_3.json"}],instructionsSettings_mobile:[{header:"Add to Scene",description:"Click to add individual modules to the scene.",lottieURL:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_1A_Drag_Drop_Mobile/Mobile_Non-furniture_Step_1A.json"},{header:"Rearrange Modules",description:"Drag & drop individual modules in the scene to rearrange.",lottieURL:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_2/Non-furniture_Step_2.json"},{header:"Remove Modules",description:"Tap to select and remove individual modules from the scene.",lottieURL:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_3/Non-furniture_Step_3.json"}],defaultInstructionsSettings:{step1_drag:{mobile:{header:"Add to Scene",description:"Drag & drop individual modules to add to the scene.",lottieURL:{furniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Furniture/Furniture_Step_1A_Drag_Drop_Mobile/Mobile_Furniture_Step_1A.json",nonFurniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_1A_Drag_Drop_Mobile/Mobile_Non-furniture_Step_1A.json"}},desktop:{header:"Add to Scene",description:"Drag & drop individual modules to add to the scene.",lottieURL:{furniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Furniture/Furniture_Step_1A_Drag_Drop/Furniture_Step_1A.json",nonFurniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_1A_Drag_Drop/Non-furniture_Step_1A.json"}}},step1_add:{mobile:{header:"Add to Scene",description:"Click to add individual modules to the scene.",lottieURL:{furniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Furniture/Furniture_Step_1B_Click_Add_Mobile/Mobile_Furniture_Step_1B.json",nonFurniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_1B_Click_Add_Mobile/Mobile_Non-furniture_Step_1B.json"}},desktop:{header:"Add to Scene",description:"Click to add individual modules to the scene.",lottieURL:{furniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Furniture/Furniture_Step_1B_Click_Add/Furniture_Step_1B.json",nonFurniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_1B_Click_Add/Non-furniture_Step_1B.json"}}},step2:{mobile:{header:"Rearrange Modules",description:"Drag & drop individual modules in the scene to rearrange.",lottieURL:{furniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Furniture/Furniture_Step_2/Furniture_Step_2.json",nonFurniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_2/Non-furniture_Step_2.json"}},desktop:{header:"Rearrange Modules",description:"Drag & drop individual modules in the scene to rearrange.",lottieURL:{furniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Furniture/Furniture_Step_2/Furniture_Step_2.json",nonFurniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_2/Non-furniture_Step_2.json"}}},step3:{mobile:{header:"Remove Modules",description:"Tap to select and remove individual modules from the scene.",lottieURL:{furniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Furniture/Furniture_Step_3/Furniture_Step_3.json",nonFurniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_3/Non-furniture_Step_3.json"}},desktop:{header:"Remove Modules",description:"Click to select and remove individual modules from the scene.",lottieURL:{furniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Furniture/Furniture_Step_3/Furniture_Step_3.json",nonFurniture:"<@all-projects@>/common-assets/instructions-assets/lottie-animations/Non-Furniture/Non-furniture_Step_3/Non-furniture_Step_3.json"}}}}},setCSSLoaded:Dt=>{kt({cssLoaded:Dt})},actions:{refreshShadows:()=>{const{shadowRefreshKey:Dt}=_e();kt({shadowRefreshKey:Dt+1})},popFromAlertQueue:()=>{const{alertQueue:Dt}=_e();return Dt.shift(),kt({alertQueue:Dt}),Dt},addToAlertQueue:Dt=>{const{alertQueue:Vt,currentAlertData:Gt}=_e();return Vt.length>0&&Vt[Vt.length-1].alertId&&Dt.alertId===Vt[Vt.length-1].alertId||Vt.length==0&&Gt&&Gt.alertId&&Gt.alertId==Dt.alertId||(Vt.push(Dt),kt({alertQueue:Vt})),Vt},getDeviceState:()=>{const{isDesktop:Dt,isMobile:Vt,isTablet:Gt,isTouchDevice:zt,isLandscape:jt}=_e();return{isDesktop:Dt,isMobile:Vt,isTablet:Gt,isTouchDevice:zt,isLandscape:jt}},enableCart:()=>{const{sceneSettings:Dt,CORE_API:Vt,stores:Gt}=_e();Dt.disableCart=!1,Gt.inventoryStore.getState().actions.refreshInventory(Gt.itemStore.getState().itemsSpawned),Vt.fireEvent(Vt.EVENTS.SCENE.Cart_StatusUpdated,{disableCart:!1})},disableCart:()=>{const{sceneSettings:Dt,CORE_API:Vt,stores:Gt}=_e();Dt.disableCart=!0,Gt.inventoryStore.getState().actions.refreshInventory(Gt.itemStore.getState().itemsSpawned),Vt.fireEvent(Vt.EVENTS.SCENE.Cart_StatusUpdated,{disableCart:!0})},getSceneSettings:()=>{const{sceneSettings:Dt}=_e();return Dt},sendAlert:Dt=>{kt({alertData:{...Dt}})},switchCursor(Dt){const{cursorParentRef:Vt}=_e();if(!Vt)return;let Gt="";switch(Dt){default:case CURSORS.GRAB:Gt="grabCursor";break;case CURSORS.GRABBING:Gt="grabbingCursor";break;case CURSORS.BLOCKED:Gt="blockedCursor";break;case CURSORS.POINTER:Gt="pointerCursor";break;case CURSORS.MOVE:Gt="moveCursor";break}for(let zt=0;zt<Vt.classList.length;zt++)Vt.classList[zt].includes("Cursor")&&Vt.classList.remove(Vt.classList[zt]);Vt.classList.add(Gt)},setAlertSettings:Dt=>{kt({alertSettings:Dt})},async completeDropItem(){const{draggingOnDropCollisionData:Dt,CORE_API:Vt,stores:Gt}=_e(),zt=Gt.attachmentStore.getState().attachmentSystem,{node:jt,attachedChildrenGuids:Ht,collidingStatus:Wt,intersectingGhostObject:qt,initPosition:Xt,initRotation:Kt,detachedPlugs:Yt,attachedNodesToCurrentNode:Zt}=Dt;Vt.alert({alertMsg:"Item(s) have been removed",alertTime:7e3,alertType:"info",alertLabel:"Item(s) Removed",alertId:"itemRemoved"});for(const[Qt,en]of Ht.entries())Wt[Qt]===!0&&await Gt.itemStore.getState().actions.removeItemByGUID(en);const Jt=qt.userData;let nn=jt.getPlugByName(Jt.incomingPlugName),rn=zt.currentStructure.getPlugByGUID(Jt.receiverPlugGUID);jt.ref.position.set(qt.position.x,qt.position.y,qt.position.z),jt.ref.setRotationFromEuler(qt.rotation),jt.transform={position:qt.position,rotation:qt.quaternion},zt.currentStructure.connectPlugs({incomingPlug:nn,receiverPlug:rn}),Gt.ghostStore.getState().actions.clearAllGhosts(),Gt.itemStore.getState().actions.deselectItem(),Zt.map(Qt=>{jt.ref.parent.attach(Qt.ref),Qt.transform={position:Qt.ref.position,rotation:Qt.ref.quaternion},jt.dragging=!1,Qt.dragging=!1}),await Gt.attachmentStore.getState().actions.updateFittingSkuIds()},async revertDropItem(){const{draggingOnDropCollisionData:Dt,stores:Vt}=_e(),Gt=Vt.attachmentStore.getState().attachmentSystem,{node:zt,attachedChildrenGuids:jt,collidingStatus:Ht,intersectingGhostObject:Wt,initPosition:qt,initRotation:Xt,detachedPlugs:Kt,attachedNodesToCurrentNode:Yt}=Dt;CORE_API.alert({alertMsg:"Position of item"+zt.skuID+"is being moved to it's original position",alertTime:4e3,alertType:"info",alertLabel:"Repositioning",alertId:"itemRepositioned"});const Zt=Kt.neighbourDetachedPlugs;Zt&&(Kt.neighbourNode.detachNodeFromReceiver(),Gt.currentStructure.connectPlugs({incomingPlug:Zt.incomingPlug,receiverPlug:Zt.receiverPlug}));let Jt=Kt.rootDetachedPlugs.incomingPlug,nn=Kt.rootDetachedPlugs.receiverPlug;zt.ref.position.set(qt.x,qt.y,qt.z),zt.ref.setRotationFromEuler(Xt);let rn=new Quaternion().identity();zt.ref.getWorldQuaternion(rn),zt.transform={position:qt,rotation:rn},Gt.currentStructure.connectPlugs({incomingPlug:Jt,receiverPlug:nn}),Vt.ghostStore.getState().actions.clearAllGhosts(),Vt.itemStore.getState().actions.deselectItem(),Yt.map(Qt=>{zt.ref.parent.attach(Qt.ref),Qt.transform={position:Qt.ref.position,rotation:Qt.ref.quaternion},zt.dragging=!1,Qt.dragging=!1}),await Vt.attachmentStore.getState().actions.updateFittingSkuIds()},setCoreSettings:Dt=>{const{sceneSettings:Vt,isMobile:Gt,isTouchDevice:zt,isLandscape:jt,actions:Ht}=_e(),Wt=Gt===!0?"mobile":"desktop",qt=["showSave","showShare","showReset","showDimension","showHotspots","showInstructionsBtn","showViewInYourSpace","showContextMenu","showInstructionsOnStartup","draggableUI","clickToAddUi","textSettings","alertControl","variantsTabOrder","emptySceneTextFontSize","instructionsSettings"];for(const Xt of qt)if(Xt==="draggableUI"||Xt==="clickToAddUi"||Xt==="emptySceneTextFontSize"||Xt==="showInstructionsOnStartup"||Xt==="showInstructionsBtn"||Xt==="instructionsSettings"){const Yt=`${Xt}_${jt===!1&&zt===!0?"mobile":"desktop"}`;Dt[Yt]!==void 0?Vt[Xt]=Dt[Yt]:Vt[Yt]!==void 0&&(Vt[Xt]=Vt[Yt])}else if(Xt==="textSettings"||Xt==="variantsTabOrder"||Xt==="alertControl"||Xt==="outlineSettings"){if(Dt.hasOwnProperty(Xt)){let Kt=Vt[Xt];Object.keys(Kt).map(Yt=>{let Zt=Dt[Xt];Zt.hasOwnProperty(Yt)?(Yt==="visibleEdgeColor"||Yt==="hiddenEdgeColor")&&(Zt[Yt]=new Color$1(Zt[Yt]).convertSRGBToLinear()):Zt[Yt]=Kt[Yt]})}}else{const Kt=`${Xt}_${Wt}`;if(Dt[Kt]!==void 0){let Yt=`${Xt}Btn`;Xt=="showContextMenu"&&(Yt=`${Xt}`),Vt[Yt]=Dt[Kt]}}Dt.disableCart===!0&&Ht.disableCart(),Object.keys(Dt).map(Xt=>Vt[Xt]=Dt[Xt]),Vt.emptySceneText===null&&(Vt.emptySceneTextFontSize=Gt?"1.2rem":"1.5rem",Vt.draggableUI===!0?Vt.emptySceneText="Drag an item here to get started":Vt.emptySceneText="Select an item to get started"),kt({sceneSettings:{...Vt,ghostThreeColor:{r:Vt.ghostColor.r/255,g:Vt.ghostColor.g/255,b:Vt.ghostColor.b/255,a:Vt.ghostColor.a/255},draggableUiGhostThreeColorOnHover:{r:Vt.ghostColorOnHoverWithDraggableUi.r/255,g:Vt.ghostColorOnHoverWithDraggableUi.g/255,b:Vt.ghostColorOnHoverWithDraggableUi.b/255,a:Vt.ghostColorOnHoverWithDraggableUi.a/255}}})},triggerAutoFocus:(Dt=null)=>kt(Vt=>({autoFocusRef:Dt,autoFocusTrigger:Vt.autoFocusTrigger+1})),requestNewScreenshot:async(Dt,Vt)=>{const{CORE_API:Gt}=_e();return new Promise(async(zt,jt)=>{LOGGER.info({title:"Taking a screenshot"});const{screenshotRenderer:Ht,sceneRef:Wt,screenshotCamera:qt,canvasSize:Xt}=_e(),Kt=await Gt.getCurrentCameraDetails();if(Ht.setClearColor(16777215),qt.copy(Kt),Dt!==null&&(qt.position.copy(Dt.position),qt.rotation.copy(new Euler(Dt.rotation.x,Dt.rotation.y,Dt.rotation.z))),Vt==null?Ht.setSize(Xt.width,Xt.height):Ht.setSize(Vt.width,Vt.height),Ht.render(Wt.parent,qt),Ht.preserveDrawingBuffer===!1)LOGGER.warn({title:"Preserve Drawing Buffer must be enabled to take a screenshot. Please make sure to enable this within the project input data coreSettings"}),jt({success:!1,imageData:null});else{LOGGER.info({title:"Downloading the screenshot"});const Yt=Ht.domElement.toDataURL("image/png").replace("image/png","image/octet-stream");zt({success:!0,imageData:Yt})}})}}})),createProductDataStore=kt=>{const _e=productDataStoreCreator();return _e.setState({stores:kt}),_e},productDataStoreCreator=()=>create((kt,_e)=>({stores:null,productData:{},categoryData:{},lookData:{},hotspotsData:{},endpoints:{},assetsData:void 0,actions:{getCurrentCompareAtPricingInfo:()=>{const{productData:Dt}=_e();let Vt={};return Object.keys(Dt).map(Gt=>{if(Gt.toLowerCase()==="root")return;let zt=Dt[Gt].lookDetails,jt={};Object.keys(zt).map(Ht=>{Ht!="default"&&(jt[Ht]=zt[Ht].compareAtPrice)}),Vt[Gt]=jt}),Vt},getCurrentPricingInfo:()=>{const{productData:Dt}=_e();let Vt={};return Object.keys(Dt).map(Gt=>{if(Gt.toLowerCase()==="root")return;let zt=Dt[Gt].lookDetails,jt={};Object.keys(zt).map(Ht=>{Ht!="default"&&(jt[Ht]=zt[Ht].price)}),Vt[Gt]=jt}),Vt},updateCompareAtPricingForAllProducts:Dt=>{const{actions:Vt}=_e();Object.keys(Dt).map(Gt=>{let zt=Dt[Gt];Object.keys(zt).map(jt=>{Vt.updateCompareAtPricingForProduct(Gt,jt,zt[jt])})})},updatePricingForAllProducts:Dt=>{const{actions:Vt}=_e();Object.keys(Dt).map(Gt=>{let zt=Dt[Gt];Object.keys(zt).map(jt=>{Vt.updatePricingForProduct(Gt,jt,zt[jt])})})},updateCompareAtPricingForProduct:(Dt,Vt,Gt)=>{const{productData:zt,stores:jt}=_e();let Ht=zt[Dt];if(!Ht||!Ht.lookDetails)return;let Wt=Ht.lookDetails[Vt];if(!Wt)return;Wt.compareAtPrice=Gt,jt.attachmentStore.getState().attachmentSystem.currentStructure.getNodesBySKUID(Dt).map(Kt=>Kt.updateCompareAtPricing())},updatePricingForProduct:(Dt,Vt,Gt)=>{const{productData:zt,stores:jt}=_e();let Ht=zt[Dt];if(!Ht||!Ht.lookDetails)return;let Wt=Ht.lookDetails[Vt];if(!Wt)return;Wt.price=Gt,jt.attachmentStore.getState().attachmentSystem.currentStructure.getNodesBySKUID(Dt).map(Kt=>Kt.updatePricing())},setProductData:Dt=>{const{stores:Vt}=_e();let Gt={};Dt&&Object.keys(Dt).map(zt=>{const jt=Dt[zt];if(jt.skuID=zt,jt.skuID.toLowerCase()==="root"){jt.lookDetails={default:{title:"",description:"",productPageUrl:"",thumbnails:{high:"",low:""},price:0}},jt.defaultVariant="default";return}if(jt?.lookDetails){const Ht=jt.lookDetails;let Wt=Object.keys(jt.lookDetails);if(Wt.includes("default")){const Xt=Wt.indexOf("default");Wt.splice(Xt,1)}jt.looks=Wt,Object.keys(jt.lookDetails).map(Xt=>{let Kt=jt.lookDetails[Xt];Kt.inventory===void 0&&(Kt.inventory=DEFAULT_INVENTORY),Kt.price===void 0&&(Kt.price=DEFAULT_PRODUCT_PRICE),Kt.compareAtPrice===void 0&&(Kt.compareAtPrice=DEFAULT_PRODUCT_COMPARE_AT_PRICE),Gt[zt]={...Gt[zt],[Xt]:{inventory:DEFAULT_INVENTORY,inScene:[]}}});let qt=jt?.defaultVariant;qt||(LOGGER.warn({title:`No defaultVariant set for ${jt.skuID}. Attempting to auto resolve but the colour variants behaviour might be unexpected!`}),qt=Object.keys(jt.lookDetails).sort()[0],LOGGER.warn({title:"Auto resolved default look ID: "+qt})),Wt.includes(qt)?(jt.lookDetails.default=Ht[qt],jt.lookDetails.default.id=qt):(LOGGER.error({title:`Default look [ ${qt} ] doesn't exist for: ${zt}. Please make sure to select a default variant in Input Data for this project`}),jt.lookDetails.default=null)}}),LOGGER.info({title:"PRODUCT DATA: ",details:Dt}),Vt.inventoryStore.setState({inventoryData:Gt}),kt({productData:Dt})},setCategoryData:Dt=>{const{productData:Vt}=_e();Dt.geometryVariants!==void 0&&Dt.geometryVariants.map(Gt=>{Gt.defaultVariant===void 0&&Object.keys(Gt.variants).length>0&&(Gt.defaultVariant=Object.keys(Gt.variants)[0])}),Dt.color!==void 0&&Dt.color.map(Gt=>{(Gt.defaultLook===void 0&&Gt.looks.length>0||!Gt.looks.includes(Gt.defaultLook))&&(Gt.defaultLook=Gt.looks[0])}),kt({categoryData:Dt}),Dt.build!==void 0&&Dt.build.map(Gt=>{Gt.skus.map(zt=>{Vt[zt].categoryID=Gt.categoryID,Vt[zt].categoryLabel=Gt.label,Vt[zt].swappable=Gt.swappable?Gt.swappable:!1,Vt[zt].replace=Gt.replace})})},getProductDataById:Dt=>{const{productData:Vt}=_e();let Gt=null;return Vt[Dt]&&(Gt=Vt[Dt]),Gt},setLookData:Dt=>kt({lookData:Dt}),setHotspotsData:Dt=>{const{categoryData:Vt,productData:Gt}=_e();Vt.geometryVariants&&Object.keys(Dt).map(zt=>{Dt[zt].map(jt=>{jt.geometryVariantID&&Vt.geometryVariants.map(Ht=>{Object.keys(Ht.variants).map(Wt=>{jt.geometryVariantID==Wt&&Ht.productsInCategory.map(qt=>{let Xt=null;qt.products.map(Kt=>{Dt.hasOwnProperty(Kt)&&(Xt=Dt[Kt])}),qt.products.map(Kt=>{Dt.hasOwnProperty(Kt)||(Dt[Kt]=Xt)})})})})})}),kt({hotspotsData:Dt})},setAssetsData:Dt=>kt({assetsData:Dt})}})),createItemStore=kt=>{const _e=itemStoreCreator();return _e.setState({stores:kt}),_e},itemStoreCreator=()=>create((kt,_e)=>({stores:null,variantChangeAlert:!1,focusedGUID:null,removeItems:[],removeItemTrigger:!1,itemsSpawned:{},itemsCount:0,modelLoadedAlert:0,lastDeletedItemData:null,lastDeletedItemsData:[],hoveredItemRef:{},collidersRef:[],fittingSkuIds:[],filteredCollidersRef:[],selectedItemData:null,defaultSceneItemCount:0,busySpawningItem:!1,busyReplacingItem:!1,busySpawningDependency:!1,busyDraggingItem:!1,busyRemovingItem:!1,isBusy:()=>{const{busySpawningItem:Dt,busyReplacingItem:Vt,busySpawningDependency:Gt,busyDraggingItem:zt,busyRemovingItem:jt}=_e();return Dt||Vt||Gt||zt||jt},actions:{triggerModelLoaded:()=>{kt(Dt=>({modelLoadedAlert:Dt.modelLoadedAlert+1}))},triggerRemoveItem:()=>{kt(Dt=>({removeItemTrigger:!Dt.removeItemTrigger}))},addToRemoveItems:Dt=>{const{removeItems:Vt}=_e();Vt.push(Dt)},switchToVariant:async(Dt,Vt,Gt=!1)=>{const{variantChangeAlert:zt,stores:jt}=_e(),Ht=jt.productDataStore.getState().categoryData;let qt=jt.attachmentStore.getState().attachmentSystem.currentStructure.getNodeByGUID(Dt.guid);const Xt=jt.assetStore.getState().assets.items,Kt=qt.ref.getObjectByName("GRP_RenderGeometry");Xt[Dt.skuID].data||Ht.geometryVariants&&Ht.geometryVariants.map(Yt=>{Yt.productsInCategory.map(Zt=>{let Jt=!1;Zt.products.map(nn=>{nn==Dt.skuID&&(Jt=!0)}),Jt&&Zt.products.map(nn=>{const rn=jt.assetStore.getState().assets.items[nn].data;rn&&(jt.assetStore.getState().assets.items[Dt.skuID].data=rn)})})}),qt.modelFunctions&&(await qt.modelFunctions.selectVariant(Kt,Vt),Gt?(qt.overrideVariant=Vt,jt.coreSceneStore.getState().CORE_API.fireEvent(jt.coreSceneStore.getState().CORE_API.EVENTS.SCENE.MaterialOverrides_Exists,!0)):qt.currentVariant=Vt,kt({variantChangeAlert:!zt}))},clearAllItems:()=>{kt({itemsSpawned:{},itemsCount:0,lastDeletedItemsData:[],hoveredItemRef:[],collidersRef:[],filteredCollidersRef:[],selectedItemData:null})},setItemsSpawned:Dt=>{kt({itemsSpawned:Dt,itemsCount:Object.keys(Dt).length})},setHoveredItemRef:Dt=>kt({hoveredItemRef:Dt}),setCollidersRef:Dt=>{const{stores:Vt}=_e();kt({collidersRef:Dt});let Gt=[];for(let zt=0;zt<Dt.length;zt++)Dt[zt].current&&Gt.push(Dt[zt]);Vt.itemStore.setState({filteredCollidersRef:[...Gt]})},setSelectedItemData:Dt=>{const{selectedItemData:Vt,hoveredItemRef:Gt,actions:zt,stores:jt}=_e();Vt&&(delete Gt[Vt.itemData.guid],zt.setHoveredItemRef({...Gt})),kt({selectedItemData:{...Dt}}),jt.hotspotStore.getState().actions.switchHotspotsVisibility(!1,!0),jt.cameraStore.getState().actions.canCameraRotate(!1)},deselectItem:()=>{const{selectedItemData:Dt,stores:Vt}=_e();Dt&&Vt.coreSceneStore.getState().CORE_API.fireEvent(Vt.coreSceneStore.getState().CORE_API.EVENTS.UI.ContextMenu_Hide,Dt),kt(()=>({selectedItemData:null})),Vt.hotspotStore.getState().actions.switchHotspotsVisibility(!0,!0),Vt.cameraStore.getState().actions.canCameraRotate(!0),Vt.itemStore.getState().actions.setHoveredItemRef({})},removeItemByGUID:async Dt=>{const{itemsSpawned:Vt,actions:Gt,stores:zt}=_e();if(Vt.hasOwnProperty(Dt))return kt({busyRemovingItem:!0}),new Promise(async(jt,Ht)=>{const Wt=qt=>{Dt===qt.data.itemData.guid&&(kt({busyRemovingItem:!1}),jt(Dt))};zt.coreSceneStore.getState().CORE_API.coreWCRef.addEventListener(zt.coreSceneStore.getState().CORE_API.EVENTS.SCENE.Item_Removed,Wt,{once:!0}),Gt.addToRemoveItems(Dt),Gt.triggerRemoveItem()})},addItemBySkuID:async(Dt,Vt=0,Gt=!1,zt)=>{kt({busySpawningItem:!0});const{actions:jt,itemsSpawned:Ht,stores:Wt}=_e(),qt=Wt.productDataStore.getState().productData,Xt=Wt.productDataStore.getState().hotspotsData,Kt=Wt.attachmentStore.getState().attachmentSystem;let Yt=!0;const Zt=await new Promise(async(Jt,nn)=>{if(LOGGER.info({title:`Spawning item: ${Dt}`}),jt.deselectItem(),!qt[Dt]){LOGGER.warn({title:`Product not found: ${Dt}`}),Wt.coreSceneStore.getState().CORE_API.alert({alertMsg:Dt+": product not found!",alertTime:5e3,alertType:"warn",alertLabel:"Not Found"}),Yt=!1,nn(Dt+": product not found!");return}const rn=[...Wt.ghostStore.getState().ghostsTransform],Qt={...Wt.ghostStore.getState().ghostData};if(rn.length<=0){Wt.coreSceneStore.getState().CORE_API.alert({alertMsg:"Unable to add item to configuration",alertTime:6e3,alertType:"warn",alertLabel:"Action Unavailable"}),Yt=!1,nn("No available connections for this product to attach to");return}const en=tn=>{Dt===tn.data&&Jt(Qt.newNodes[Vt].guid)};if(Wt.coreSceneStore.getState().CORE_API.coreWCRef.addEventListener(Wt.coreSceneStore.getState().CORE_API.EVENTS.SCENE.Model_Loaded,en,{once:!0}),Qt.addItemOrSwap[Vt]=="replace")await replaceItem(kt,Wt,Ht,Qt.skuID,rn[Vt],Qt.newNodes[Vt]);else{Wt.ghostStore.getState().actions.clearAllGhosts();const tn=Qt.newNodes[Vt];tn.isDependent=Gt;let sn=!0;if(qt[Qt.skuID].hasOwnProperty("disableInteraction")){const fn=qt[Qt.skuID].disableInteraction;(fn==!0||fn==!1)&&(sn=!fn)}zt!=null&&(sn=zt),tn.isInteractive=sn;const{position:cn,rotation:un}=rn[Vt];tn.transform={position:cn,rotation:un},Kt.currentStructure.addNode(tn),Qt.connectablePlugs[Vt].receiverPlug.type=="unvisualizedPlug"&&Wt.coreSceneStore.getState().CORE_API.alert({alertMsg:"This product is not shown in your 3D configuration but can be found in your shopping list.",alertTime:3e3,alertType:"warn",alertLabel:"Internal Storage",persistant:!1,alertId:"unvisualizedItemSpawn"}),Qt.comboPlugs[Vt].length>0&&Qt.connectablePlugs[Vt].incomingPlug.type=="comboPlug"&&Qt.comboPlugs[Vt].map(fn=>{Kt.currentStructure.connectPlugs(fn)}),Qt.connectablePlugs[Vt].incomingPlug.comboPlugConnector=!0,Kt.currentStructure.connectPlugs(Qt.connectablePlugs[Vt]);const hn=await Wt.assetStore.getState().actions.loadProxyAsset(Qt.skuID,!0);LOGGER.info({title:"GHOST NEW NODE: ",details:tn}),Ht[tn.guid]={itemData:{proxyScene:hn.proxy.data.scene,guid:Qt.newNodes[Vt].guid,...qt[Qt.skuID],position:cn,rotation:un,hasItemLoaded:!1,isDependent:Gt,isInteractive:sn},hotspotsData:Xt[Qt.skuID],hotspotSpawned:!1},await wait(1),jt.setItemsSpawned({...Ht})}}).catch(Jt=>{LOGGER.error({title:Jt}),Yt=!1});if(Yt===!1)return kt({busySpawningItem:!1}),Zt;if(Wt.coreSceneStore.getState().preconfigurationLoaded&&Wt.coreSceneStore.getState().configurationLoaded){const Jt=await Kt.getCartItemsAsync();Jt&&Wt.coreSceneStore.getState().CORE_API.fireEvent(Wt.coreSceneStore.getState().CORE_API.EVENTS.SCENE.CartItems_Updated,Jt)}if(await jt.resolvePlugDependencyOnGUID(Zt),kt({busySpawningItem:!1}),!Gt){const Jt=Kt.currentStructure,nn=Jt.getNodeByGUID(Zt);Wt.dynamicHookStore.getState().hookOnSceneItemAdded(nn,Jt.nodes,Wt.coreSceneStore.getState().CORE_API),await Wt.attachmentStore.getState().actions.updateFittingSkuIds()}return Zt},async addItemWithTransform(Dt,Vt,Gt,zt=!0){const{actions:jt,itemsSpawned:Ht,defaultSceneItemCount:Wt,stores:qt}=_e(),Xt=qt.productDataStore.getState().productData,Kt=qt.productDataStore.getState().hotspotsData;return await new Promise(async(Zt,Jt)=>{if(jt.deselectItem(),!Xt[Vt]){qt.coreSceneStore.getState().CORE_API.alert({alertMsg:Vt+": product not found!",alertTime:5e3,alertType:"warn",alertLabel:"Not Found"}),Jt(Vt+": product not found!");return}const{position:nn,rotation:rn}=Dt;Ht[Gt]!=null&&(qt.hotspotStore.getState().actions.removeHotspotForItem({...Ht[Gt]}),delete Ht[Gt]);const Qt=tn=>{Vt.toLowerCase()==tn.data.toLowerCase()&&Zt(Gt)};qt.coreSceneStore.getState().CORE_API.coreWCRef.addEventListener(qt.coreSceneStore.getState().CORE_API.EVENTS.SCENE.Model_Loaded,Qt,{once:!0});const en=await qt.assetStore.getState().actions.loadProxyAsset(Vt,!0);if(en==null){Jt(Vt+": Asset not found!");return}await wait(1),Vt.toLowerCase()==="root"&&kt({defaultSceneItemCount:Wt+1}),Ht[Gt]={itemData:{proxyScene:en.proxy.data.scene,guid:Gt,...Xt[Vt],position:nn,rotation:rn,hasItemLoaded:!1,isInteractive:zt},hotspotsData:Kt[Vt],hotspotSpawned:!1},kt({itemsSpawned:{...Ht}})}).catch(Zt=>{LOGGER.info({title:Zt})})},async resolvePlugDependencyOnGUID(Dt){const{actions:Vt,itemsSpawned:Gt,defaultSceneItemCount:zt,stores:jt}=_e(),Ht=jt.productDataStore.getState().productData,Wt=jt.attachmentStore.getState().attachmentSystem,qt=Gt[Dt].itemData.skuID,Xt=Ht[qt]?.plugs;if(!Xt)return;let Kt=!1;for(const Yt of Xt)Yt?.dependencySku&&(Kt=!0);Kt&&(kt({busySpawningDependency:!0}),await new Promise(async(Yt,Zt)=>{const Jt=[];for(const nn of Xt){const rn=nn?.dependencySku;if(!rn)continue;const Qt=async()=>{LOGGER.info({title:`Found a dependency: ${rn} on the plug: ${nn.name}`});let en=!0;Ht[rn]&&Ht[rn].hasOwnProperty("ignoreSpawningCollisionAsDependency")&&(en=Ht[rn].ignoreSpawningCollisionAsDependency),nn.hasOwnProperty("ignoreSpawningCollision")&&(en=nn.ignoreSpawningCollision);let tn=jt.coreSceneStore.getState().sceneSettings.ignoreSpawningCollision;Ht[rn].hasOwnProperty("ignoreSpawningCollision")&&(tn=Ht[rn].ignoreSpawningCollision),Ht[rn].ignoreSpawningCollision=en,jt.ghostStore.setState({ghostVisibility:!1});const sn=await jt.ghostStore.getState().actions.spawnGhostsForSkuID(rn,en);if(Ht[rn].ignoreSpawningCollision=tn,!sn)return;const cn=Wt.currentStructure.getNodeByGUID(Dt),un=cn.getPlugByName(nn.name)?.guid,hn=nn?.isDependencySkuInteractive?nn.isDependencySkuInteractive===1:!1,fn=sn.connectablePlugs;let pn=-1;for(const mn of fn)mn.receiverPlug.guid===un&&(pn=fn.indexOf(mn));if(pn==-1){jt.ghostStore.getState().actions.clearAllGhosts();return}const dn=await Vt.addItemBySkuID(rn,pn,!0,hn);qt.toLowerCase()==="root"&&Ht[rn].ignoreInCart&&kt({defaultSceneItemCount:zt+1}),dn!==null&&cn.addMyDependenciesGUID(dn)};Jt.push(await Qt())}await Promise.all(Jt),Yt(!0)}),kt({busySpawningDependency:!1}))},async replaceGuidItemBySkuId(Dt,Vt){const{itemsSpawned:Gt,stores:zt}=_e();if(Gt[Dt]==null)return!1;const jt=zt.attachmentStore.getState().attachmentSystem.currentStructure,Ht=jt.getNodeByGUID(Dt);if(!Ht||!Ht.isReplaceableWithSkuId(Vt))return!1;LOGGER.info({title:"Replacing Item"});const qt=zt.productDataStore.getState().productData,Xt=zt.productDataStore.getState().hotspotsData;kt({busyReplacingItem:!0}),await new Promise(async(Kt,Yt)=>{const Zt=async()=>{LOGGER.info({title:"Removed old item with guid: "+Dt});const Jt=async Qt=>{Vt===Qt.data&&(jt.recalculateStructureFromNode(Ht.whichNodeAreWeAttachedTo()),await zt.attachmentStore.getState().actions.toggleStructureUpdated(),kt({busyReplacingItem:!1}),Kt(Ht.guid))};zt.coreSceneStore.getState().CORE_API.coreWCRef.addEventListener(zt.coreSceneStore.getState().CORE_API.EVENTS.SCENE.Model_Loaded,Jt,{once:!0});const nn=await zt.assetStore.getState().actions.loadProxyAsset(Vt,!0),rn={receiverPlug:Ht.whichPlugAreWeAttachedTo(),incomingPlug:Ht.whichPlugAreWeAttachedUsing()};jt.findItemTransform(rn),Gt[Dt]={itemData:{proxyScene:nn.proxy.data.scene,guid:Dt,...qt[Vt],position:Ht.transform.position,rotation:Ht.transform.rotation,hasItemLoaded:!1},hotspotsData:Xt[Vt],hotspotSpawned:!1},LOGGER.warn({title:"SWITCHING VARIANT: ",details:Ht.currentVariant}),zt.itemStore.setState({itemsSpawned:{...Gt}})};zt.hotspotStore.getState().actions.removeHotspotForItem({...Gt[Dt]}),delete Gt[Dt],Ht.update(Vt),zt.coreSceneStore.getState().CORE_API.coreWCRef.addEventListener(zt.coreSceneStore.getState().CORE_API.EVENTS.SCENE.Model_Removed,Zt,{once:!0})})}}}));async function replaceItem(kt,_e,Dt,Vt,Gt,zt){LOGGER.info({title:"Replacing Item"});const{position:jt,rotation:Ht}=Gt,Wt=_e.productDataStore.getState().productData,qt=_e.productDataStore.getState().hotspotsData,Xt=_e.attachmentStore.getState().attachmentSystem.currentStructure;return kt({busyReplacingItem:!0}),new Promise(async(Kt,Yt)=>{const Zt=async()=>{const Jt=await _e.assetStore.getState().actions.loadProxyAsset(Vt,!0),nn=async rn=>{Vt===rn.data&&(Xt.recalculateStructureFromNode(zt),await _e.attachmentStore.getState().actions.toggleStructureUpdated(),_e.ghostStore.getState().actions.clearAllGhosts(),kt({busyReplacingItem:!1}),Kt(zt.guid))};_e.coreSceneStore.getState().CORE_API.coreWCRef.addEventListener(_e.coreSceneStore.getState().CORE_API.EVENTS.SCENE.Model_Loaded,nn,{once:!0}),Dt[zt.guid]={itemData:{proxyScene:Jt.proxy.data.scene,guid:zt.guid,...Wt[Vt],position:jt,rotation:Ht,hasItemLoaded:!1},hotspotsData:qt[Vt],hotspotSpawned:!1},LOGGER.warn({title:"SWITCHING VARIANT: ",details:zt.currentVariant}),zt.currentVariant=zt.currentVariant,zt.transform=Gt,_e.itemStore.setState({itemsSpawned:{...Dt}})};_e.hotspotStore.getState().actions.removeHotspotForItem({...Dt[zt.guid]}),delete Dt[zt.guid],zt.update(Vt),_e.coreSceneStore.getState().CORE_API.coreWCRef.addEventListener(_e.coreSceneStore.getState().CORE_API.EVENTS.SCENE.Model_Removed,Zt,{once:!0})})}const createInventoryStore=kt=>{const _e=inventoryStoreCreator();return _e.setState({stores:kt}),_e},inventoryStoreCreator=()=>create((kt,_e)=>({stores:null,inventoryData:{},actions:{updateInventoryForAllProducts:Dt=>{const{actions:Vt,stores:Gt}=_e();Object.keys(Dt).map(zt=>{let jt=Dt[zt];Object.keys(jt).map(Ht=>{Vt.updateInventoryForProduct(zt,Ht,jt[Ht].inventory)})}),Vt.refreshInventory(Gt.itemStore.getState().itemsSpawned)},updateInventoryForProduct:(Dt,Vt,Gt)=>{const{inventoryData:zt}=_e();let jt=zt[Dt],Ht=jt[Vt];!jt||!Ht||(Ht.inventory=Gt)},_clearInScene:()=>{const{inventoryData:Dt}=_e();Object.keys(Dt).map(Vt=>{const Gt=Dt[Vt];Object.keys(Gt).map(zt=>{Gt[zt].inScene=[]})})},refreshInventory:Dt=>{if(!Dt)return;LOGGER.info({title:"Refreshing Inventory"});const{actions:Vt,inventoryData:Gt,stores:zt}=_e();Vt._clearInScene();const jt=zt.attachmentStore.getState().attachmentSystem;if(jt===null)return;const Ht=jt.currentStructure;if(Ht===null)return;Object.keys(Dt).map(Kt=>{const Yt=Ht.getNodeByGUID(Kt);if(!Yt)return;const Zt=Yt.overrideVariant?Yt.overrideVariant:Yt.currentVariant;if(!Zt)return;const Jt=Gt[Yt.skuID];if(!Jt||!Jt[Zt].inScene)return;Jt[Zt].inScene.push(Kt),zt.coreSceneStore.getState().sceneSettings.disableCart===!0?Yt.inStock={variantName:Zt,newValue:!0}:Jt[Zt].inScene.length>Jt[Zt].inventory?Yt.inStock={variantName:Zt,newValue:!1}:Yt.inStock={variantName:Zt,newValue:!0}});let Wt=!1;Object.keys(Gt).map(Kt=>{const Yt=Gt[Kt];Object.keys(Yt).map(Zt=>{Yt[Zt].countAvailable=Yt[Zt].inventory-Yt[Zt].inScene.length,Yt[Zt].countAvailable<0?(Yt[Zt].countUnavailable=Yt[Zt].countAvailable*-1,Yt[Zt].countAvailable=0,Wt=!0):Yt[Zt].countUnavailable=0})});const qt={alertMsg:"Some item(s) in configuration are out of stock",alertTime:7e3,alertType:"warn",alertLabel:"Stock Alert",persistant:!0,alertId:"outOfStock"},Xt=compareObjects(zt.coreSceneStore.getState().persistantAlertData,qt);Wt===!1&&Xt===!0&&zt.coreSceneStore.getState().CORE_API.removePersistantAlert(),zt.coreSceneStore.getState().CORE_API.fireEvent(zt.coreSceneStore.getState().CORE_API.EVENTS.SCENE.Inventory_Updated,Gt)}}})),createAssetStore=kt=>{const _e=assetStoreCreator();return _e.setState({stores:kt}),_e},assetStoreCreator=()=>create((kt,_e)=>({stores:null,assets:{items:{}},gltfLoader:null,dracoLoader:null,actions:{init(){const Dt=new DRACOLoader;Dt.setDecoderPath(`${ASSETS_SOURCE_ROOT}/external-libs/draco/`),Dt.setDecoderConfig({type:"js"});const Vt=new GLTFLoader;Vt.register(Gt=>new GLTFMaterialsVariantsExtension(Gt)),Vt.setDRACOLoader(Dt),kt({dracoLoader:Dt,gltfLoader:Vt})},async loadProxyAsset(Dt){const{assets:Vt,gltfLoader:Gt,stores:zt}=_e(),jt="proxy",Ht=Vt.items[Dt]=Vt.items[Dt]||{isLoaded:!1,errorLoading:!1,proxy:{isLoaded:!1,errorLoading:!1}},Wt=Ht.proxy;if(Wt.isLoaded)return Ht;if(Wt.errorLoading)throw new Error(`${jt} loading failed for: ${Dt}`);const qt=zt.productDataStore.getState().productData[Dt];if(!qt)throw new Error(`Data doesn't exist for ${Dt}`);const Xt=zt.coreSceneStore.getState().CORE_API.getResolvedAssetUrl(qt.colliderProxyGLTF);if(!Xt)return null;try{const Kt=await Gt.loadAsync(Xt,Yt=>{Wt.progress=Yt.loaded/Yt.total*100});return Wt.data=Kt,Wt.isLoaded=!0,Ht}catch(Kt){throw Wt.isLoaded=!1,Wt.errorLoading=!0,Wt.error=Kt,LOGGER.info({title:Xt}),new Error(`Couldn't load ${Dt}`)}},isProxyLoaded(Dt){const Vt=_e().assets.items[Dt];return Vt?Vt.proxy.isLoaded:!1}}}));class Structure{#t=!1;constructor(_e,Dt=null,Vt,Gt){if(this.stores=_e,this._nodes=[],this._rootNode=null,LOGGER.info({title:"preloadNodes",details:Dt}),this.setupHookOnSceneItemsUpdated(),Dt){LOGGER.info({title:"PRELOAD Length-----------------:"+Dt.length});for(let zt=0;zt<Dt.length;zt++){LOGGER.info({title:"FOUND PRELOAD-----------------"});const jt=Dt[zt].skuID;if(jt.toLowerCase()=="root"){const Wt=this.stores.itemStore.getState().itemsSpawned;Object.keys(Wt).length>0&&(Dt[zt].guid=Object.keys(Wt)[0])}let Ht=new Node$1(_e,jt,Dt[zt],Vt,Gt);jt.toLowerCase()=="root"&&(this._rootNode=Ht),this._nodes.push(Ht)}}else{const zt=new Node$1(_e,"Root",null,Vt,Gt);this._rootNode=zt,this._nodes.push(zt),this.stores.itemStore.getState().actions.addItemWithTransform({position:new Vector3(0,0,0),rotation:new Quaternion().identity()},"Root",this._rootNode.guid,!1)}this._boundingBoxLeeway=this.stores.coreSceneStore.getState().sceneSettings.boundingBoxLeeway}async setupHookOnSceneItemsUpdated(){const _e=this.stores.coreSceneStore.getState().CORE_API;this.stores.coreSceneStore.getState().CORE_API.coreWCRef.addEventListener(_e.EVENTS.SCENE.FittingSkuIds_Updated,()=>{this.stores.dynamicHookStore.getState().hookOnSceneItemsUpdated(this._nodes,_e)})}get nodes(){return this._nodes}get rootNode(){return this._rootNode}updatePricing(){for(let _e=0;_e<this._nodes.length;_e++)this._nodes[_e].updatePricing()}getCurrentItemsInReplaceableCategory(){let _e={};for(const Dt of this._nodes)Dt.replace&&(_e[Dt.categoryID]=Dt.skuID);return _e}recalculateStructureFromNode(_e){for(let Dt=0;Dt<_e.plugs.length;Dt++)if(!_e.plugs[Dt].isOpen&&_e.plugs[Dt].isReceiverPlug){const Vt=_e.plugs[Dt].attachedPlug.node,Gt={receiverPlug:_e.plugs[Dt],incomingPlug:_e.plugs[Dt].attachedPlug};if(Gt){const zt=this.findItemTransform(Gt);zt&&(Vt.ref.position.set(zt.position.x,zt.position.y,zt.position.z),zt.rotation.isQuaternion===!0?Vt.ref.setRotationFromQuaternion(zt.rotation):zt.rotation.isEuler===!0&&Vt.ref.setRotationFromEuler(zt.rotation),Vt.transform={position:zt.position,rotation:zt.rotation})}this.recalculateStructureFromNode(Vt)}}rotateNode(_e){const Dt=this.getNodeByGUID(_e);let Vt=null,Gt=null;for(let Ht=0;Ht<Dt.plugs.length;Ht++)if(!Gt&&!Dt.plugs[Ht].isOpen&&Dt.plugs[Ht].attachedPlug.isReceiverPlug){const Wt=Dt.plugs[Ht].attachedPlug.acceptedPlugTypes;Gt=Dt.plugs[Ht].attachedPlug;let qt=[];for(let Xt=Ht+1;Xt<Dt.plugs.length;Xt++)qt.push(Dt.plugs[Xt]);for(let Xt=0;Xt<Ht;Xt++)qt.push(Dt.plugs[Xt]);for(let Xt=0;Xt<qt.length;Xt++)for(let Kt=0;Kt<qt[Xt].connectsToPlugTypes.length;Kt++)Wt.includes(qt[Xt].connectsToPlugTypes[Kt])&&(Vt=qt[Xt])}if(!Vt)return;Dt.detachNodeFromReceiver();const{position:zt,rotation:jt}=this.findItemTransform({receiverPlug:Gt,incomingPlug:Vt});Dt.ref.position.set(zt.x,zt.y,zt.z),jt.isQuaternion===!0?Dt.ref.setRotationFromQuaternion(jt):jt.isEuler===!0&&Dt.ref.setRotationFromEuler(jt),Dt.transform={position:Dt.ref.position,rotation:jt},this.connectPlugs({receiverPlug:Gt,incomingPlug:Vt}),this.recalculateStructureFromNode(Dt)}async load(_e){this.resolvePlugConnections(_e),await this.respawnItems()}materialOverrideExists(){let _e=!1;return this.nodes.map(Dt=>{if(Dt.overrideVariant)return _e=!0,!0}),_e}async findGhostTransformForReplacement(_e,Dt){let Vt=[],Gt=[],zt=[];for(const Ht of Dt){if(Ht.skuID==_e)continue;const Wt=this.stores.attachmentStore.getState().attachmentSystem,qt=Ht.whichPlugAreWeAttachedTo(),Xt=Ht.whichPlugAreWeAttachedUsing(),Yt=new Node$1(this.stores,_e,null,Wt.globalVariants,Wt.globalGeometryVariants).getPlugByName(Xt.name);if(!Yt)continue;const Zt={incomingPlug:Yt,receiverPlug:qt},{position:Jt,rotation:nn}=this.findItemTransform(Zt);Jt&&nn&&(Gt.push({position:Jt,rotation:nn,incomingPlugName:Zt.incomingPlug.name,receiverPlugName:Zt.receiverPlug.name,incomingPlugGUID:Zt.incomingPlug.guid,receiverPlugGUID:Zt.receiverPlug.guid}),zt.push(Zt),Vt.push(Ht))}let jt={transforms:Gt,connectablePlugs:zt,newNodes:Vt};return jt=await this.stores.dynamicHookStore.getState().hookOnNewItemGhostsCollectedForReplacement(jt,this.stores.coreSceneStore.getState().CORE_API),jt}async findGhostTransforms(_e,Dt){const Vt=this.getOpenPlugs(),Gt=this.stores.coreSceneStore.getState().sceneSettings.comboPlugDistanceThreshold;if(Vt.length<=0)return{transforms:[]};const zt=this.stores.attachmentStore.getState().attachmentSystem,jt=this.stores.productDataStore.getState().productData,Ht=new Node$1(this.stores,_e,null,zt.globalVariants,zt.globalGeometryVariants),Wt=this.getConnectablePlugs(Ht,Vt);let qt=[];if(Wt.length<=0)return{transforms:[]};let Xt=[],Kt=[];const Yt=this.stores.assetStore.getState().assets.items[_e].proxy.data.scene;if(!Yt)return!1;let Zt=Yt.clone();for(let rn=0;rn<Wt.length;rn++){let Qt=Dt,{incomingPlug:en,receiverPlug:tn}=Wt[rn],sn=this.findItemTransform(Wt[rn]);if(!sn)continue;let{position:cn,rotation:un}=sn;if(!cn||!un)continue;Zt.position.set(cn.x,cn.y,cn.z),un.isQuaternion===!0?Zt.setRotationFromQuaternion(un):un.isEuler===!0&&Zt.setRotationFromEuler(un);let hn=[],fn=[];if(en.type=="comboPlug"){if(en.connectsToPlugTypes.length<=0)continue;const vn=en.connectsToPlugTypes[0];let _n=!1;if(Kt.map(Cn=>{_n===!0||Cn.length<=0||Cn.map(yn=>{_n===!0||yn.incomingPlug.guid!==en.guid||yn.incomingPlug.connectsToPlugTypes.includes(vn)&&(_n=!0)})}),_n===!0)continue;const An=en.node.plugs;let Tn=!0;if(An.map(Cn=>{if(Cn.type!=="comboPlug"||Cn.guid===en.guid||!Cn.connectsToPlugTypes.includes(vn))return;let yn=!1;if(Vt.map(Sn=>{if(tn.guid===Sn.guid||!Sn.acceptedPlugTypes.includes(vn)||!Sn.node.ref)return;let wn=new Vector3(0,0,0);const xn=Sn.node.ref.getObjectByName(""+Sn.name);if(!xn)return;xn.getWorldPosition(wn);let Rn=new Vector3(0,0,0);const Dn=Zt.getObjectByName(""+Cn.name);if(!Dn)return;Dn.getWorldPosition(Rn);const kn=wn.distanceTo(Rn);Math.abs(kn)<Gt&&(hn.push(tn.node.guid),hn.push(Sn.node.guid),fn.push({receiverPlug:Sn,incomingPlug:Cn}),yn=!0)}),yn==!1){Tn=!1;return}}),!Tn)continue}let pn=Qt;Array.isArray(Qt)===!0&&(pn=!1),hn.length>0&&(pn=!1,Array.isArray(Qt)===!0?hn.map(vn=>{Qt.push(vn)}):Qt=hn),jt[_e].hasOwnProperty("ignoreSpawningCollision")&&(pn=jt[_e].ignoreSpawningCollision),Wt[rn].receiverPlug.type=="unvisualizedPlug"&&(pn=!0),(pn?!1:this.isColliding(Ht.skuID,sn,Wt[rn].receiverPlug,Qt))||(Xt.push({position:cn,rotation:un,incomingPlugName:Wt[rn].incomingPlug.name,receiverPlugName:Wt[rn].receiverPlug.name,incomingPlugGUID:Wt[rn].incomingPlug.guid,receiverPlugGUID:Wt[rn].receiverPlug.guid}),qt.push(Wt[rn]),Kt.push(fn))}let Jt=[];for(let rn=0;rn<Xt.length;rn++)Jt.push(Ht);dispose3(Zt);let nn={transforms:Xt,newNodes:Jt,connectablePlugs:qt,comboPlugs:Kt};return nn=await this.stores.dynamicHookStore.getState().hookOnNewItemGhostsCollected(nn,this.stores.coreSceneStore.getState().CORE_API),nn}resolvePlugConnections(_e){for(let Dt=0;Dt<_e.length;Dt++)Object.keys(_e[Dt].plugs).map(Vt=>{let Gt=_e[Dt].plugs[Vt].guid,zt=this.getPlugInNodesByGUID(Gt);if(!zt||zt.attachedPlug)return;let jt=_e[Dt].plugs[Vt].attachedPlugGUID,Ht=this.getPlugInNodesByGUID(jt);Ht&&(Ht.attachedPlug||(zt.attachPlug(Ht,_e[Dt].plugs[Vt].isReceiverPlug),Ht.attachPlug(zt,!_e[Dt].plugs[Vt].isReceiverPlug)))});LOGGER.info({title:"RESOLVED PLUG CONNECTION: ",details:this})}async respawnItems(){let _e=[this.rootNode];for(let zt=0;zt<_e.length;zt++){let Ht=_e[zt].whichPlugsAreAttachedToUs();for(let Wt=0;Wt<Ht.length;Wt++){if(Ht[Wt].incomingPlug.type=="comboPlug"&&Ht[Wt].incomingPlug.connectsToPlugTypes.length>0&&!Ht[Wt].incomingPlug.comboPlugConnector)continue;let qt=this.findItemTransformForPreload(Ht[Wt],Ht[Wt].receiverPlug.node.transform);if(qt){const Xt=Ht[Wt].receiverPlug,Kt=Ht[Wt].incomingPlug.node,Yt=Xt.dependencySku===Kt.skuID;let Zt=!0;Yt&&(Zt=Xt.isDependencySkuInteractive===1,Kt.isDependent=!0,Kt.isInteractive=Zt,Xt.node.addMyDependenciesGUID(Kt.guid)),await this.stores.itemStore.getState().actions.addItemWithTransform(qt,Kt.skuID,Kt.guid,Zt)}else LOGGER.warn({title:"Problem finding plug transform! "+Ht[Wt].name});Ht[Wt].incomingPlug.node.transform=qt,_e.push(Ht[Wt].incomingPlug.node)}}const Dt=await this.stores.coreSceneStore.getState().CORE_API.getCartItemsAsync();this.stores.coreSceneStore.getState().CORE_API.fireEvent(this.stores.coreSceneStore.getState().CORE_API.EVENTS.SCENE.SavedConfiguration_Loaded,{...Dt}),this.stores.coreSceneStore.getState().actions.triggerAutoFocus(),this.stores.hotspotStore.getState().actions.checkHotspotHealth();const Vt=this.stores.coreSceneStore.getState().preconfigurationLoaded==!1&&this.stores.coreSceneStore.getState().sceneHasDefaultConfigurationID==!1,Gt=this.stores.coreSceneStore.getState().configurationLoaded==!1&&this.stores.coreSceneStore.getState().preconfigurationLoaded==!0&&this.stores.coreSceneStore.getState().configurationLoadedOnRestart==!0;if(Vt||Gt){let zt=Object.assign({},CONFIGURATOR_LOAD_FROM_PRECONFIG);zt.parameters={project_id:`${this.stores.coreSceneStore.getState().CORE_API.projectId}`,...Dt},this.stores.coreSceneStore.getState().CORE_API.sendAnalyticsEvent(zt)}}getPlugInNodesByGUID(_e){for(let Dt=0;Dt<this._nodes.length;Dt++){let Vt=this._nodes[Dt].getPlugByGUID(_e);if(Vt)return Vt}return null}export(){let _e=[];for(let Dt=0;Dt<this._nodes.length;Dt++){let Vt=this._nodes[Dt].export();Vt&&_e.push(Vt)}return _e}async clear(){return new Promise(async(_e,Dt)=>{!this._rootNode&&this._rootNode.isEndNode&&_e(!0);let Vt=null;const Gt=this._rootNode.whichNodesAreAttachedToUs();Gt.length>0&&(Vt=Gt[0]),this.#t=!0,this.stores.coreSceneStore.getState().CORE_API.coreWCRef.addEventListener(this.stores.coreSceneStore.getState().CORE_API.EVENTS.SCENE.Scene_Cleared,zt=>_e(zt.data),{once:!0}),Vt?this.stores.coreSceneStore.getState().CORE_API.removeItemByGUID(Vt.guid,!0):(await wait(500),_e(!0))})}getNodeByGUID(_e){for(let Dt=0;Dt<this._nodes.length;Dt++)if(this._nodes[Dt].guid==_e)return this._nodes[Dt];return null}getPlugByGUID(_e){for(const Dt of this._nodes){const Vt=Dt.getPlugByGUID(_e);if(Vt)return Vt}return null}findItemTransformForPreload(_e,Dt){let{receiverPlug:Vt,incomingPlug:Gt}=_e,zt=Vt,jt=Gt;if(zt.node.skuID=="Root")return this.findItemTransformRoot(_e);let Ht=null,Wt=null,qt=new Object3D,Xt=this.stores.assetStore.getState().assets.items[zt.node.skuID].proxy.data.scene.clone();qt.add(Xt);let{position:Kt,rotation:Yt}=Dt;if(Xt.position.set(Kt.x,Kt.y,Kt.z),Yt.isQuaternion===!0?Xt.setRotationFromQuaternion(Yt):Yt.isEuler===!0&&Xt.setRotationFromEuler(Yt),Wt=Xt,!Wt||(Ht=Wt.getObjectByName(zt.name),!Ht))return;let Zt=new Vector3(0,0,0);Ht.getWorldPosition(Zt);let Jt=new Quaternion().identity();Ht.getWorldQuaternion(Jt);let nn=new Object3D;Ht.add(nn);let rn=this.stores.assetStore.getState().assets.items[jt.node.skuID].proxy.data.scene.clone();rn.position.set(Zt.x,Zt.y,Zt.z),rn.applyQuaternion(Jt);let Qt=new Vector3;Qt.copy(Xt.up).applyQuaternion(Wt.quaternion);let en=new Vector3;en.copy(rn.up).applyQuaternion(Jt),en.negate();let tn=new Quaternion().setFromUnitVectors(Qt,en);Qt.round(),en.round();let sn=Qt.dot(en);sn!==1&&sn!==-1&&rn.applyQuaternion(tn);let cn=rn.getObjectByName(jt.name),un=new Quaternion().identity();cn.getWorldQuaternion(un);let hn=new Vector3(0,1,0);hn.applyQuaternion(un);let fn=new Vector3(0,1,0);fn.applyQuaternion(Jt),fn.negate();let pn=new Quaternion().setFromUnitVectors(hn,fn);if(hn.round(),fn.round(),hn.dot(fn)!==-1)rn.applyQuaternion(pn);else{let An=new Vector3(0,1,0),Tn=fn.dot(An);if(Tn!==1&&Tn!==-1)rn.rotateOnAxis(An,Math.PI);else{let Cn=new Vector3(0,0,1),yn=fn.dot(Cn);if(yn!==1&&yn!==-1)rn.rotateOnAxis(Cn,Math.PI);else{let Sn=new Vector3(1,0,0),wn=fn.dot(Sn);wn!==1&&wn!==-1&&rn.rotateOnAxis(Sn,Math.PI)}}}let mn=rn.getObjectByName(jt.name),vn=new Vector3(mn.position.x,mn.position.y,mn.position.z);rn.translateX(-vn.x),rn.translateY(-vn.y),rn.translateZ(-vn.z);let _n=new Vector3(0,0,0);rn.getWorldPosition(_n);let En=new Quaternion().identity();return rn.getWorldQuaternion(En),rn=null,{position:_n,rotation:En}}findItemTransformRoot(_e){let{receiverPlug:Dt,incomingPlug:Vt}=_e,Gt=Vt;const zt=new Object3D;let jt=zt,Ht=new Vector3(0,0,0);jt.getWorldPosition(Ht);let Wt=new Quaternion().identity(),qt=new Object3D;qt.position.set(0,0,0),zt.add(qt);let Xt=this.stores.assetStore.getState().assets.items[Gt.node.skuID].proxy.data.scene.clone();qt.attach(Xt),Xt.translateX(Ht.x),Xt.translateY(Ht.y),Xt.translateZ(Ht.z);let Kt=Xt.getObjectByName(Gt.name),Yt=new Quaternion().identity();Kt&&Kt.getWorldQuaternion(Yt);const Zt=new Vector3(0,1,0);Zt.applyQuaternion(Yt);const Jt=new Vector3(0,1,0);Jt.applyQuaternion(Wt);const nn=Jt.angleTo(Zt),rn=new Vector3(0,0,0);rn.crossVectors(Jt,Zt),rn.round(),rn.length()!==0&&Xt.rotateOnAxis(rn,nn);let Qt=new Matrix4().extractRotation(Xt.matrixWorld),en=new Vector3(0,0,0);Kt&&en.set(Kt.position.x,Kt.position.y,Kt.position.z),en.applyMatrix4(Qt),Xt.translateX(-en.x),Xt.translateY(-en.y),Xt.translateZ(-en.z);let tn=new Vector3(0,0,0);Xt.getWorldPosition(tn);let sn=new Quaternion().identity();return Xt.getWorldQuaternion(sn),qt.remove(Xt),qt=null,Xt=null,{position:tn,rotation:sn}}findItemTransform(_e){let{receiverPlug:Dt,incomingPlug:Vt}=_e,Gt=Dt,zt=Vt;if(Gt.node.isRoot)return this.findItemTransformRoot(_e);const jt=Gt.node.transform;if(!jt)return;const Ht=this.stores.assetStore.getState().assets.items[Gt.node.skuID].proxy.data.scene.clone(),Wt=new Object3D;Wt.position.set(jt.position.x,jt.position.y,jt.position.z),jt.rotation.isQuaternion===!0?Wt.setRotationFromQuaternion(jt.rotation):jt.rotation.isEuler===!0&&Wt.setRotationFromEuler(jt.rotation),Wt.add(Ht);let qt=Wt.getObjectByName(""+Gt.name);if(!qt){LOGGER.error({title:"Plug: "+Gt.name+" doesn't exist in "+Gt.node.skuID});return}let Xt=new Vector3(0,1,0);qt.getWorldPosition(Xt);let Kt=new Quaternion().identity();qt.getWorldQuaternion(Kt);let Yt=this.stores.assetStore.getState().assets.items[zt.node.skuID].proxy.data.scene.clone();Yt.position.set(Xt.x,Xt.y,Xt.z),Yt.applyQuaternion(Kt);let Zt=new Vector3;Zt.copy(Ht.up).applyQuaternion(Wt.quaternion);let Jt=new Vector3;Jt.copy(Yt.up).applyQuaternion(Kt),Jt.negate();let nn=new Quaternion().setFromUnitVectors(Zt,Jt);Zt.round(),Jt.round();let rn=Zt.dot(Jt);rn!==1&&rn!==-1&&Yt.applyQuaternion(nn);let Qt=Yt.getObjectByName(zt.name);if(!Qt){LOGGER.error({title:"Plug: "+zt.name+" doesn't exist in "+zt.node.skuID});return}let en=new Quaternion().identity();Qt.getWorldQuaternion(en);let tn=new Vector3(0,1,0);tn.applyQuaternion(en);let sn=new Vector3(0,1,0);sn.applyQuaternion(Kt),sn.negate();let cn=new Quaternion().setFromUnitVectors(tn,sn);if(tn.round(),sn.round(),tn.dot(sn)!==-1)Yt.applyQuaternion(cn);else{let mn=new Vector3(0,1,0),vn=sn.dot(mn);if(vn!==1&&vn!==-1)Yt.rotateOnAxis(mn,Math.PI);else{let _n=new Vector3(0,0,1),En=sn.dot(_n);if(En!==1&&En!==-1)Yt.rotateOnAxis(_n,Math.PI);else{let An=new Vector3(1,0,0),Tn=sn.dot(An);Tn!==1&&Tn!==-1&&Yt.rotateOnAxis(An,Math.PI)}}}let hn=Yt.getObjectByName(zt.name),fn=new Vector3(hn.position.x,hn.position.y,hn.position.z);Yt.translateX(-fn.x),Yt.translateY(-fn.y),Yt.translateZ(-fn.z);let pn=new Vector3(0,0,0);Yt.getWorldPosition(pn);let dn=new Quaternion().identity();return Yt.getWorldQuaternion(dn),Wt.remove(Ht),Yt=null,{position:pn,rotation:dn}}getSpawningRequirementForSkuID(_e){let Dt=[];const Vt=this.stores.productDataStore.getState().productData,Gt=Vt[_e];if(!Gt)return Dt;const zt=[];return Gt.plugs.map(jt=>{jt.connectsToPlugTypes.map(Ht=>{zt.push(Ht)})}),Object.keys(Vt).map(jt=>{for(let Ht=0;Ht<Vt[jt].plugs.length;Ht++){const Wt=Vt[jt].plugs[Ht].acceptedPlugTypes;for(let qt=0;qt<Wt.length;qt++)zt.map(Xt=>{Xt==Wt[qt]&&!Dt.includes(jt)&&Dt.push(jt)})}}),Dt}getConnectablePlugs(_e,Dt){let Vt=[],Gt=_e.getOpenPlugsWeCanAttachFrom();for(let zt=0;zt<Gt.length;zt++)for(let jt=0;jt<Dt.length;jt++){let Ht=!1;for(let qt=0;qt<Vt.length;qt++)if(Vt[qt].receiverPlug.guid==Dt[jt].guid&&Vt[qt].incomingPlug.type!="comboPlug"){Ht=!0;break}if(Ht)continue;Gt[zt].canAttachToPlug(Dt[jt])&&Vt.push({incomingPlug:Gt[zt],receiverPlug:Dt[jt]})}return Vt}getOpenPlugs(){let _e=[];return this._nodes.map(Dt=>{if(Dt.dragging===!0)return;let Vt=Dt.getOpenPlugsFromNode();_e=_e.concat(Vt)}),_e}checkCollisionForGUID(_e,Dt=[]){if(this.stores.coreSceneStore.getState().sceneSettings.disableCollider)return!1;const Vt=this.stores.itemStore.getState().itemsSpawned,Gt=this.stores.productDataStore.getState().productData;if(!Vt[_e])return!1;const jt=this.getNodeByGUID(_e);if(!jt||!jt.ref||Gt[jt.skuID].disableCollider)return!1;let Ht=new Vector3;jt.ref.getWorldPosition(Ht);let Wt=new Quaternion;jt.ref.getWorldQuaternion(Wt);const qt={position:Ht,rotation:Wt},Xt=jt.whichPlugAreWeAttachedTo();return Xt==null?!1:this.isColliding(jt.skuID,qt,Xt,Dt)}isColliding(_e,{position:Dt,rotation:Vt},Gt,zt=[]){const jt=this.stores.assetStore.getState().assets.items[_e].proxy.data.scene,Ht=this.stores.productDataStore.getState().productData;if(!jt)return!1;let Wt=jt.clone();Wt.position.set(Dt.x,Dt.y,Dt.z),Vt.isQuaternion===!0?Wt.setRotationFromQuaternion(Vt):Vt.isEuler===!0&&Wt.setRotationFromEuler(Vt);let qt=new Box3().setFromObject(Wt),Xt=new Vector3;qt.getCenter(Xt);let Kt=new Object3D;Kt.position.set(Xt.x,Xt.y,Xt.z),Kt.attach(Wt),Kt.scale.set(this._boundingBoxLeeway,this._boundingBoxLeeway,this._boundingBoxLeeway),qt=new Box3().setFromObject(Kt);const Yt=[];if(this._nodes.forEach(Jt=>{if(Gt.node.guid==Jt.guid||Array.isArray(zt)===!0&&zt.includes(Jt.guid)||!Jt.ref||(Ht[Jt.skuID].hasOwnProperty("disableCollider")?Ht[Jt.skuID].disableCollider:this.stores.coreSceneStore.getState().sceneSettings.disableCollider))return;const nn=Jt.ref.getObjectByName("GRP_ProxyMesh");nn&&Yt.push(nn)}),Yt.length<=0)return!1;let Zt=!1;return Yt.forEach(Jt=>{if(Zt)return;let nn=new Box3().setFromObject(Jt);if(qt.intersectsBox(nn)){Zt=!0;return}}),Kt.clear(),Wt=null,Kt=null,qt=null,Zt}boxOverlapPercent(_e,Dt){if(_e.containsBox(Dt)||Dt.containsBox(_e))return 100;if(!(_e.min.x<Dt.max.x||Dt.min.x<_e.max.x))return 0;let Vt=new Vector3(0,0,0);_e.getSize(Vt),Vt.x*Vt.y*Vt.z;let Gt=new Vector3(0,0,0);Dt.getSize(Gt),Gt.x*Gt.y*Gt.z}checkInsideOutCollision(_e,Dt,Vt){let Gt=Dt.position.clone(),zt=new Float32Array(Vt.attributes.position.array),jt=zt.length/3;for(let Ht=0;Ht<jt;Ht++){let Wt=new Vector3(zt[Ht*3],zt[Ht*3+1],zt[Ht*3+2]),qt=Wt.add(Dt.position);qt=Wt.applyQuaternion(Dt.quaternion);let Xt=qt.sub(Dt.position);const Yt=new Raycaster(Gt,Xt.clone().normalize()).intersectObjects(_e),Zt=Yt.length>0,Jt=Yt[0].distance<Xt.length();if(Zt&&Jt)return!0}return!1}addNode(_e){this._nodes.push(_e)}getFirstNodeByCategoryID(_e){for(let Dt=0;Dt<this._nodes.length;Dt++)if(this._nodes[Dt]._categoryID==_e)return this._nodes[Dt];return null}getNodesBySKUID(_e){let Dt=[];for(let Vt=0;Vt<this._nodes.length;Vt++)this._nodes[Vt].skuID==_e&&Dt.push(this._nodes[Vt]);return Dt}getNodesByCategoryID(_e){let Dt=[];for(let Vt=0;Vt<this._nodes.length;Vt++)this._nodes[Vt]._categoryID==_e&&Dt.push(this._nodes[Vt]);return Dt}async connectPlugs({incomingPlug:_e,receiverPlug:Dt}){_e.attachPlug(Dt,!1),Dt.attachPlug(_e,!0),await this.stores.attachmentStore.getState().actions.toggleStructureUpdated()}removeNodeByGUID(_e){for(let Dt=0;Dt<this._nodes.length;Dt++)if(this._nodes[Dt].guid==_e){this._nodes[Dt].removeNode(),this._nodes.splice(Dt,1);break}this._nodes.length==1&&this.#t&&this.stores.coreSceneStore.getState().CORE_API.fireEvent(this.stores.coreSceneStore.getState().CORE_API.EVENTS.SCENE.Scene_Cleared,!0),this.stores.attachmentStore.getState().actions.updateFittingSkuIds(),this.stores.attachmentStore.getState().actions.toggleStructureUpdated()}async removeNodeFromStructure(_e){for(let Dt=0;Dt<this._nodes.length;Dt++)if(this._nodes[Dt].guid==_e.guid){this._nodes.splice(Dt,1);break}await this.stores.attachmentStore.getState().actions.toggleStructureUpdated()}}class AttachmentSystem{constructor(_e){this._globalVariants={},this._globalGeometryVariants={},this.stores=_e,this.stores.productDataStore.getState().categoryData.geometryVariants.map(Dt=>{this._globalGeometryVariants[Dt.id]=Dt.defaultVariant}),this.stores.productDataStore.getState().categoryData.color.map(Dt=>{this._globalVariants[Dt.id]=Dt.defaultLook}),this._currentStructure=new Structure(this.stores,null,this._globalVariants,this._globalGeometryVariants);for(const[Dt,Vt]of Object.entries(this._globalVariants))this.switchGlobalVariant(Dt,Vt);for(const[Dt,Vt]of Object.entries(this._globalGeometryVariants))this.switchGlobalGeometryVariant(Dt,Vt)}get globalGeometryVariants(){return this._globalGeometryVariants}get globalVariants(){return this._globalVariants}get currentStructure(){return this._currentStructure}getClientProductId(_e,Dt){let Vt;return Vt=this.stores.productDataStore.getState()?.productData[_e]?.lookDetails[Dt],Vt?.clientProductId?Vt?.clientProductId:""}getCartItems(){let _e=[];const Dt=this.stores.inventoryStore.getState().inventoryData;let Vt=!1;this.currentStructure.nodes.map(Ht=>{if(Ht.skuID=="Root"||Ht.ignoreInCart===!0)return;let Wt=!1;if(_e.map(Kt=>{const Yt=Dt[Kt.skuID];if(Kt.skuID==Ht.skuID&&Kt.currentVariant==Ht.currentVariant){Kt.count++,Kt.countAvailable=Yt[Ht.currentVariant].countAvailable,Kt.countUnavailable=Yt[Ht.currentVariant].countUnavailable,Kt.price=Ht.price*Kt.count,Kt.compareAtPrice=Ht.compareAtPrice*Kt.count,Wt=!0;return}}),Wt===!0)return;let qt={};qt.skuID=Ht.skuID,qt.currentVariant=Ht.currentVariant,qt.clientProductId=this.getClientProductId(qt.skuID,qt.currentVariant),qt.count=1;const Xt=Dt[qt.skuID];qt.price=Ht.price,qt.compareAtPrice=Ht.compareAtPrice*qt.count,Ht.compareAtPrice>0&&(Vt=!0),qt.countAvailable=Xt[Ht.currentVariant].countAvailable,qt.countUnavailable=Xt[Ht.currentVariant].countUnavailable,_e.push(qt)});let Gt=0,zt=0;for(const Ht of _e)Gt=Gt+Ht.price,Vt&&(zt=zt+(Ht.compareAtPrice==0?Ht.price:Ht.compareAtPrice));return{cartItems:_e,details:{total:Gt.toFixed(2),compareAtTotal:zt}}}async getCartItemsAsync(){let _e=[];const Dt=this.stores.inventoryStore.getState().inventoryData;let Vt=!1;this.currentStructure.nodes.map(Ht=>{if(Ht.skuID=="Root"||Ht.ignoreInCart===!0)return;let Wt=!1;if(_e.map(Kt=>{const Yt=Dt[Kt.skuID];if(Kt.skuID==Ht.skuID&&Kt.currentVariant==Ht.currentVariant){Kt.count++,Kt.countAvailable=Yt[Ht.currentVariant].countAvailable,Kt.countUnavailable=Yt[Ht.currentVariant].countUnavailable,Kt.price=Ht.price*Kt.count,Kt.compareAtPrice=Ht.compareAtPrice*Kt.count,Wt=!0;return}}),Wt===!0)return;let qt={};qt.skuID=Ht.skuID,qt.currentVariant=Ht.currentVariant,qt.clientProductId=this.getClientProductId(qt.skuID,qt.currentVariant),qt.count=1;const Xt=Dt[qt.skuID];qt.price=Ht.price,qt.compareAtPrice=Ht.compareAtPrice*qt.count,qt.compareAtPrice>0&&(Vt=!0),qt.countAvailable=Xt[Ht.currentVariant].countAvailable,qt.countUnavailable=Xt[Ht.currentVariant].countUnavailable,_e.push(qt)}),_e=await this.stores.dynamicHookStore.getState().hookOnCartItemsCollected(_e,this.stores.coreSceneStore.getState().CORE_API);let Gt=0,zt=0;for(const Ht of _e)Gt=Gt+Ht.price,Vt&&(zt=zt+(Ht.compareAtPrice==0?Ht.price:Ht.compareAtPrice));return{cartItems:_e,details:{total:Gt.toFixed(2),compareAtTotal:zt.toFixed(2)}}}async getFittingSKUIDs(){if(!this.currentStructure)return[];const{productData:_e}=this.stores.productDataStore.getState(),{sceneSettings:Dt}=this.stores.coreSceneStore.getState(),{draggableUI:Vt,ignoreSpawningCollision:Gt}=Dt;if(!this.currentStructure)return[];const{openPlugTypes:zt,closedPlugTypes:jt,existingSkuids:Ht}=this.analyzeCurrentStructure();if(zt.size===0&&jt.size===0)return[];const Wt=this.findFittingSkuids(_e,zt,jt,Ht,Vt);return this.filterNonBlockedSkuids(Wt,_e,Gt)}analyzeCurrentStructure(){const _e=this.currentStructure.nodes,Dt=new Set,Vt=new Set,Gt=new Set;for(const zt of _e){Gt.add(zt.skuID);for(const jt of zt.plugs)jt.isOpen?jt.acceptedPlugTypes.forEach(Ht=>Dt.add(Ht)):jt.attachedPlug.node.replace&&jt.acceptedPlugTypes.forEach(Ht=>Vt.add(Ht))}return{openPlugTypes:Dt,closedPlugTypes:Vt,existingSkuids:Gt}}findFittingSkuids(_e,Dt,Vt,Gt,zt){const jt=new Set;for(const[Ht,Wt]of Object.entries(_e))if(Wt.plugs)for(const qt of Wt.plugs){for(const Xt of qt.connectsToPlugTypes)if((this.isClosedPlugFitting(Ht,Wt,Xt,Vt,Gt,zt)||this.isOpenPlugFitting(Wt,Xt,Dt))&&jt.add(Ht),jt.has(Ht))break;if(jt.has(Ht))break}return jt}isClosedPlugFitting(_e,Dt,Vt,Gt,zt,jt){if(!Gt.has(Vt)||!jt&&zt.has(_e))return!1;const Ht=this.currentStructure.getNodesByCategoryID(Dt.categoryID);for(const Wt of Ht)if(Wt.skuID!==_e&&this.isNodeCompatible(Wt,Dt))return!0;return!1}isNodeCompatible(_e,Dt){let Vt=!1;for(const Gt of _e.plugs)if(!Gt.isOpen&&Gt.isReceiverPlug&&(Vt=!0,this.isPlugCompatible(Gt,Dt.plugs)))return!0;return!Vt}isPlugCompatible(_e,Dt){return Dt.some(Vt=>Vt.name===_e.name&&_e.attachedPlug.connectsToPlugTypes.some(Gt=>Vt.acceptedPlugTypes.includes(Gt)))}isOpenPlugFitting(_e,Dt,Vt){if(!Vt.has(Dt))return!1;const Gt=this.currentStructure.getFirstNodeByCategoryID(_e.categoryID);return!Gt||!Gt.replace}async filterNonBlockedSkuids(_e,Dt,Vt){const Gt=[];for(const zt of _e)if(Dt[zt].replace)Gt.push(zt);else{const jt=await this.currentStructure.findGhostTransforms(zt,Vt);jt&&jt.transforms.length>0&&Gt.push(zt)}return Gt}async removeAllVariantOverrides(){let _e=this._currentStructure.nodes,Dt=this.stores.productDataStore.getState().productData,Vt=this.stores.itemStore.getState().itemsSpawned;return await _e.map(async Gt=>{if(!Gt.overrideVariant||(Gt.overrideVariant=null,!Dt[Gt.skuID].looks))return;let zt=null;Object.keys(this._globalVariants).map(jt=>{Dt[Gt.skuID].looks.includes(this._globalVariants[jt])&&zt==null&&(zt=this._globalVariants[jt])}),zt&&await this.stores.itemStore.getState().actions.switchToVariant(Vt[Gt.guid].itemData,zt)}),this.stores.coreSceneStore.getState().CORE_API.alert({alertMsg:"Changes to individual items in the scene have been cleared",alertTime:6e3,alertType:"info",alertLabel:"Overrides Removed",alertId:"overridesRemoved"}),this.stores.coreSceneStore.getState().CORE_API.fireEvent(this.stores.coreSceneStore.getState().CORE_API.EVENTS.SCENE.MaterialOverrides_Exists,!1),!0}async switchGlobalGeometryVariant(_e,Dt){const Gt=this.stores.productDataStore.getState().categoryData.geometryVariants;let zt=null;if(Gt.map(Yt=>{Yt.id==_e&&(zt=Yt)}),!zt)return;const jt=zt.productsInCategory,Wt=zt.variants[Dt].productsToSwitch,qt=this.stores.itemStore.getState().itemsSpawned;let Xt=this.stores.productDataStore.getState().categoryData;Wt.map(Yt=>{jt.map(Zt=>{let Jt=!1;Zt.products.map(nn=>{Yt==nn&&(Jt=!0)}),Jt&&Xt.build.map(nn=>{Zt.products.map(rn=>{nn.skus.map((Qt,en)=>{nn.skus[en]==rn&&(nn.skus[en]=Yt)})})})})}),this._currentStructure.nodes.map(Yt=>{jt.map(Zt=>{Zt.products.map(Jt=>{Yt.skuID==Jt&&Yt.ref!==null&&Zt.products.map(nn=>{Wt.map(rn=>{if(rn==nn){const Qt=this.stores.productDataStore.getState().actions.getProductDataById(rn);let en=Qt.geometriesToHide;Yt.plugs.map(sn=>{!sn.isOpen&&sn.attachedPlug&&sn.type=="weighted_hider"&&sn.attachedPlug.weight>sn.weight&&(en=en.concat(sn.affectedNodes))}),Yt.showNodes(Qt.geometriesToShow),Yt.hideNodes(en),Yt.skuID=rn;const tn=qt[Yt.guid];tn&&tn.itemData&&Object.keys(Qt).map(sn=>{tn.itemData[sn]=Qt[sn]}),Yt.resetInStock(),Yt.updatePricing()}})})})})}),this._globalGeometryVariants[_e]=Dt,this.stores.hotspotStore.getState().actions.checkHotspotHealth(),this.stores.inventoryStore.getState().actions.refreshInventory(qt),this.stores.productDataStore.setState({categoryData:Xt}),this.stores.coreSceneStore.getState().CORE_API.fireEvent(this.stores.coreSceneStore.getState().CORE_API.EVENTS.SCENE.CategoryData_Updated,Xt),this.stores.coreSceneStore.getState().CORE_API.fireEvent(this.stores.coreSceneStore.getState().CORE_API.EVENTS.SCENE.GlobalGeometryVariant_Updated,this._globalGeometryVariants);const Kt=await this.getCartItemsAsync();Kt&&this.stores.coreSceneStore.getState().CORE_API.fireEvent(this.stores.coreSceneStore.getState().CORE_API.EVENTS.SCENE.CartItems_Updated,Kt)}async switchGlobalVariant(_e,Dt){this._globalVariants[_e]=Dt;const Vt=this.stores.itemStore.getState().actions;let Gt=this.stores.itemStore.getState().itemsSpawned;for(let Wt=0;Wt<Object.keys(Gt).length;Wt++){let qt=Gt[Object.keys(Gt)[Wt]];if(qt.itemData.looks&&qt.itemData.looks.includes(Dt)){let Xt=this._currentStructure.getNodeByGUID(qt.itemData.guid);Xt&&!Xt.overrideVariant&&await Vt.switchToVariant(qt.itemData,Dt)}}const zt=this.stores.productDataStore.getState().lookData;this.stores.lightStore.getState().actions.processLookEnvMapOverride(Dt);const jt=_e;Object.keys(Gt).length>0&&this.stores.coreSceneStore.getState().CORE_API.alert({alertMsg:jt.charAt(0).toUpperCase()+jt.slice(1)+" was successfully switched to "+zt[Dt].label+".",alertTime:3e3,alertType:"success",alertLabel:`${jt} Changed`,alertId:"materialVariantChanged"}),this.stores.coreSceneStore.getState().CORE_API.fireEvent(this.stores.coreSceneStore.getState().CORE_API.EVENTS.SCENE.GlobalVariant_Updated,this._globalVariants),this.stores.itemStore.setState({variantChangeAlert:!this.stores.itemStore.getState().variantChangeAlert});const Ht=await this.getCartItemsAsync();Ht&&this.stores.coreSceneStore.getState().CORE_API.fireEvent(this.stores.coreSceneStore.getState().CORE_API.EVENTS.SCENE.CartItems_Updated,Ht)}async#t(_e){if(!_e)return;LOGGER.info({title:"Structure to load",details:_e}),delete this._currentStructure,this._globalVariants={..._e.globalVariants},this._globalGeometryVariants=_e.globalGeometryVariants?{..._e.globalGeometryVariants}:{};const Dt=[..._e.structure];this._currentStructure=new Structure(this.stores,Dt,this._globalVariants,this._globalGeometryVariants);for(const[Vt,Gt]of Object.entries(this._globalVariants))this.switchGlobalVariant(Vt,Gt);for(const[Vt,Gt]of Object.entries(this._globalGeometryVariants))this.switchGlobalGeometryVariant(Vt,Gt);LOGGER.info({title:"Structure Loading..."}),await this._currentStructure.load(Dt),LOGGER.info({title:"Structure Loaded."})}async loadStructure(_e){if(!_e)return;this.stores.coreSceneStore.getState().CORE_API.fireEvent(this.stores.coreSceneStore.getState().CORE_API.EVENTS.UI.PreloadScreen_Show),this.stores.coreSceneStore.setState({configurationLoaded:!1}),await wait(500),await this._currentStructure.clear(),await this.#t(_e),this.stores.coreSceneStore.getState().preconfigurationLoaded?this.stores.coreSceneStore.getState().CORE_API.fireEvent(this.stores.coreSceneStore.getState().CORE_API.EVENTS.UI.PreloadScreen_Hide):this.stores.coreSceneStore.setState({preconfigurationLoaded:!0}),this.stores.coreSceneStore.getState().configurationLoadedOnRestart||this.stores.coreSceneStore.setState({configurationLoadedOnRestart:!0}),this.stores.coreSceneStore.setState({configurationLoaded:!0}),await this.stores.attachmentStore.getState().actions.toggleStructureUpdated();const Dt=this.stores.itemStore.getState().itemsSpawned;this.stores.coreSceneStore.getState().CORE_API.fireEvent(this.stores.coreSceneStore.getState().CORE_API.EVENTS.SCENE.Items_Updated,{itemsSpawned:Dt}),this.stores.inventoryStore.getState().actions.refreshInventory(Dt),await this.stores.attachmentStore.getState().actions.updateFittingSkuIds()}export(){return{experienceId:this.stores.coreSceneStore.getState().CORE_API.experienceId,structure:this._currentStructure.export(),globalVariants:this._globalVariants,globalGeometryVariants:this._globalGeometryVariants}}async clear(){this.stores.coreSceneStore.getState().CORE_API.fireEvent(this.stores.coreSceneStore.getState().CORE_API.EVENTS.UI.PreloadScreen_Show),await this._currentStructure.clear(),this.stores.coreSceneStore.getState().CORE_API.fireEvent(this.stores.coreSceneStore.getState().CORE_API.EVENTS.UI.PreloadScreen_Hide)}async restart(){LOGGER.warn({title:"Restarting the Scene!!"}),this.stores.itemStore.getState().selectedItemData&&this.stores.itemStore.getState().actions.deselectItem();const _e=this.stores.attachmentStore.getState().defaultConfig;this.stores.coreSceneStore.setState({configurationLoaded:!1,configurationLoadedOnRestart:!1}),this.stores.coreSceneStore.getState().CORE_API.fireEvent(this.stores.coreSceneStore.getState().CORE_API.EVENTS.UI.PreloadScreen_Show),await wait(500),await this._currentStructure.clear(),await this.#t(_e),await this.stores.attachmentStore.getState().actions.toggleStructureUpdated(),this.stores.coreSceneStore.setState({configurationLoaded:!0,configurationLoadedOnRestart:!0}),this.stores.coreSceneStore.getState().CORE_API.fireEvent(this.stores.coreSceneStore.getState().CORE_API.EVENTS.UI.PreloadScreen_Hide);const Dt=this.stores.itemStore.getState().itemsSpawned;this.stores.coreSceneStore.getState().CORE_API.fireEvent(this.stores.coreSceneStore.getState().CORE_API.EVENTS.SCENE.Items_Updated,{itemsSpawned:Dt}),this.stores.inventoryStore.getState().actions.refreshInventory(Dt),await this.stores.attachmentStore.getState().actions.updateFittingSkuIds()}}const createAttachmentStore=kt=>{const _e=attachmentStoreCreator();return _e.setState({stores:kt}),_e},attachmentStoreCreator=()=>create((kt,_e)=>({stores:null,attachmentSystem:null,defaultConfig:null,structureUpdated:!1,colliderMeshRef:null,placeholderRef:null,draggingItem:null,snappingThreshold:.5,actions:{initializeAttachmentSystem:async Dt=>{const{actions:Vt,defaultConfig:Gt}=_e();LOGGER.info({title:"Initializing Attachment System!"});const zt=await new AttachmentSystem(Dt);kt({attachmentSystem:zt}),await Vt.updateFittingSkuIds(),await Vt.toggleStructureUpdated()},loadSavedStructureFromConfigID:async Dt=>{const{stores:Vt}=_e();LOGGER.info({title:"Fetching Structure Using ConfigID!"});let Gt="";Dt.length==20&&(Gt=FETCH_CONFIG_ENDPOINT_FB+Dt);let zt=null;return Gt!=""?zt=await getJSONFromEndpoint(Gt):zt=await Vt.nexusApiInstance.getExperienceSaveAndShare(Vt.experienceId,Dt),zt.success===!1?null:Dt.length==20?zt.data:zt.payload.save_data},loadDefaultStructure:async()=>{const{actions:Dt,defaultConfig:Vt}=_e();LOGGER.info({title:"Loading Default Structure!"}),await Dt.loadStructure(Vt)},updateFittingSkuIds:async()=>{const{stores:Dt,attachmentSystem:Vt}=_e();if(!Dt.coreSceneStore.getState().preconfigurationLoaded||!Dt.coreSceneStore.getState().configurationLoaded)return;const Gt=await Vt.getFittingSKUIDs();Gt&&(Dt.itemStore.setState({fittingSkuIds:[...Gt]}),Dt.coreSceneStore.getState().CORE_API.fireEvent(Dt.coreSceneStore.getState().CORE_API.EVENTS.SCENE.FittingSkuIds_Updated,{skuids:Gt}))},toggleStructureUpdated:async()=>{const{attachmentSystem:Dt,stores:Vt}=_e();if(kt(zt=>({structureUpdated:!zt.structureUpdated})),!Vt.coreSceneStore.getState().preconfigurationLoaded||!Vt.coreSceneStore.getState().configurationLoaded)return;Vt.coreSceneStore.getState().CORE_API.fireEvent(Vt.coreSceneStore.getState().CORE_API.EVENTS.SCENE.ReplaceableCategory_Updated,Dt.currentStructure.getCurrentItemsInReplaceableCategory());const Gt=await Dt.getCartItemsAsync();Gt&&Vt.coreSceneStore.getState().CORE_API.fireEvent(Vt.coreSceneStore.getState().CORE_API.EVENTS.SCENE.CartItems_Updated,Gt)},loadStructure:async Dt=>{const{attachmentSystem:Vt,stores:Gt}=_e();LOGGER.info({title:"Loading Structure!"}),Vt&&Gt.coreSceneStore.getState().configurationLoaded!==!1&&await Vt.loadStructure(Dt)},export:()=>{const{attachmentSystem:Dt}=_e();if(Dt)return Dt.export()}}})),createInfoStore=kt=>{const _e=infoStoreCreator();return _e.setState({stores:kt}),_e},infoStoreCreator=()=>create((kt,_e)=>({stores:null,infoObject:{},populateInfoObject:Dt=>{kt(Vt=>({infoObject:Dt}))},infoModalOpen:!1,updateInfoModalOpen:Dt=>{kt(Vt=>({infoModalOpen:Dt}))}})),createUIHotspotStore=kt=>{const _e=uiHotspotStoreCreator();return _e.setState({stores:kt}),_e},uiHotspotStoreCreator=()=>create((kt,_e)=>({stores:null,activeHotspotData:null,activeFeatureID:"",actions:{enterHotspotInFeaturesTab(Vt){const{stores:Gt}=_e();Gt.uiSceneStore.getState().sideMenuState!==2&&Gt.uiSceneStore.setState({sideMenuState:2}),kt({activeFeatureID:Vt})},exitHotspot(){kt({activeFeatureID:null})}}})),createColorStore=kt=>{const _e=colorStoreCreator();return _e.setState({stores:kt}),_e},colorStoreCreator=()=>create((kt,_e)=>({stores:null,allActiveVariants:{},allActiveGeometryVariants:{}})),arrayWithoutElementAtIndex=function(kt,_e){return kt.filter(function(Dt,Vt){return _e!==Vt})},updateQuantityAtIndex=function(kt,_e,Dt){let Vt=kt.slice();return Vt[_e].quantity=Dt,Vt},createCartStore=kt=>{const _e=cartStoreCreator();return _e.setState({stores:kt}),_e},cartStoreCreator=()=>create((kt,_e)=>({stores:null,cart:[],cartTotalPrice:0,cartTotalCompareAtPrice:0,deleteCartItem:Dt=>{kt(Vt=>({cart:arrayWithoutElementAtIndex(Vt.cart,Dt)}))},addToCart:Dt=>{kt(Vt=>({cart:[...Vt.cart,Dt]}))},updateQuantity:(Dt,Vt)=>{kt(Gt=>({cart:updateQuantityAtIndex(Gt.cart,Dt,Vt)}))},previewCartModalOpen:!1,togglePreviewCartModal:()=>{const{previewCartModalOpen:Dt,stores:Vt}=_e();Dt===!0?(Vt.uiSceneStore.getState().CORE_API.reviewCartHidden(),kt({previewCartModalOpen:!1,previewCartMinimized:!1})):(Vt.uiSceneStore.getState().CORE_API.reviewCartShown(),kt({previewCartModalOpen:!0}))},previewCartMinimized:!1,togglePreviewCartMinimized:()=>{const{previewCartMinimized:Dt,stores:Vt}=_e(),Gt=!Dt;kt({previewCartMinimized:Gt}),Vt&&Vt.uiSceneStore&&Vt.uiSceneStore.getState().setSideMenuOpen(!Gt)},actions:{setCartTotalPrice:(Dt,Vt)=>{kt(()=>({cartTotalPrice:Dt,cartTotalCompareAtPrice:Vt}))}}})),createLightStore=kt=>{const _e=lightStoreCreator();return _e.setState({stores:kt}),_e},lightStoreCreator=()=>create((kt,_e)=>({stores:null,defaultEnvMapUrl:"<@generic-project@>/env-map/neutral.hdr",envMapUrl:"",actions:{setEnvLightMap:Dt=>{kt(Vt=>({envMapUrl:Dt}))},processLookEnvMapOverride:Dt=>{const{envMapUrl:Vt,defaultEnvMapUrl:Gt,actions:zt,stores:jt}=_e(),Ht=jt.productDataStore.getState().lookData[Dt],Wt=Ht?.envMapOverride;if(!Ht||!Wt){zt.setEnvLightMap(Gt);return}if(Wt===Vt){LOGGER.info({title:`New Env Map Url is the same as the current ${Wt}`});return}zt.setEnvLightMap(Wt)}}})),createHotspotStore=kt=>{const _e=hotspotStoreCreator();return _e.setState({stores:kt}),_e},hotspotStoreCreator=()=>create((kt,_e)=>({stores:null,activeHotspotData:null,lastActiveHotspotData:null,isAnyHotspotActive:!1,hotspotsVisibility:!1,hotspotsTempVisibility:!0,hotspotsHealthCheck:!0,hotspotsSpawned:{},visitedHotspotsID:[],hotspotSpawnedForCategoryIDs:[],actions:{clearAllHotspots:()=>kt({isAnyHotspotActive:!1,activeHotspotData:null,lastActiveHotspotData:null,hotspotsSpawned:{}}),removeHotspotForItem(Dt){const{hotspotsSpawned:Vt}=_e();Object.keys(Vt).map(Gt=>{Vt[Gt].itemData.guid==Dt.itemData.guid&&delete Vt[Gt]}),kt({hotspotsSpawned:{...Vt}})},checkHotspotHealth(){const{hotspotsHealthCheck:Dt}=_e();kt({hotspotsHealthCheck:!Dt})},toggleHotspotVisibility(){const{hotspotsVisibility:Dt}=_e();kt({hotspotsVisibility:!Dt})},switchHotspotsVisibility(Dt,Vt=!1){kt(Vt===!0?{hotspotsTempVisibility:Dt}:{hotspotsVisibility:Dt})},clickHotspot(Dt,Vt,Gt,zt=!1){const{activeHotspotData:jt,stores:Ht}=_e();kt({lastActiveHotspotData:jt}),hotspotEnter(Ht,Dt,Vt,Gt);let qt=Ht.itemStore.getState().itemsSpawned[Gt].itemData.skuID;zt===!1&&(Ht.coreSceneStore.getState().CORE_API.fireEvent(Ht.coreSceneStore.getState().CORE_API.EVENTS.SCENE.Hotspot_Enter,{hotspotAbsID:generateHotspotAbsoluteID(qt,Dt),hotspot:jt}),Ht.coreSceneStore.getState().CORE_API.fireEvent(Ht.coreSceneStore.getState().CORE_API.EVENTS.UI.UtilityMenu_Hide))},exitHotspot(Dt=!1){const{activeHotspotData:Vt,isAnyHotspotActive:Gt,stores:zt}=_e();if(Gt&&kt({isAnyHotspotActive:!1}),!!Vt&&(kt({lastActiveHotspotData:Vt}),hotspotExit(zt),Dt===!1)){const jt=Math.round((performance.now()-_e().lastActiveHotspotData.hotspotEnterTime)/1e3);zt.coreSceneStore.getState().CORE_API.fireEvent(zt.coreSceneStore.getState().CORE_API.EVENTS.SCENE.Hotspot_Exit,{hotspot:_e().lastActiveHotspotData,hotspotTimeSpent:jt}),zt.coreSceneStore.getState().CORE_API.fireEvent(zt.coreSceneStore.getState().CORE_API.EVENTS.UI.UtilityMenu_Show)}}}}));function hotspotExit(kt){kt.hotspotStore.setState({activeHotspotData:null}),kt.coreSceneStore.getState().actions.triggerAutoFocus()}function hotspotEnter(kt,_e,Dt,Vt){let Gt=kt.hotspotStore.getState();const jt=kt.itemStore.getState().itemsSpawned;let Ht=Gt.visitedHotspotsID;const Wt=jt[Vt].hotspotsData.filter(un=>un.hotspotID==_e);if(!Wt||Wt.length<=0)return;const qt=Wt[0],Xt=jt[Vt].itemData.skuID+"_"+_e;let Yt=kt.attachmentStore.getState().attachmentSystem.currentStructure.getNodeByGUID(Vt),Zt=new Vector3(0,0,0);Yt&&Yt.ref&&Yt.ref.getWorldPosition(Zt);let Jt=new Quaternion().identity();Yt&&Yt.ref&&Yt.ref.getWorldQuaternion(Jt);let nn=qt.focusPointTransform,rn=ArrToVec3(nn);rn.applyQuaternion(Jt);let Qt=qt.viewPointTransform,en=ArrToVec3(Qt);en.applyQuaternion(Jt);let tn=addVector(Vec3ToArr(rn),Vec3ToArr(Zt)),sn=addVector(Vec3ToArr(en),Vec3ToArr(Zt));kt.cameraStore.setState({focusPointPosition:tn,viewPointPosition:sn}),kt.hotspotStore.setState({activeHotspotData:{hotspotData:{guid:Dt,...qt},itemData:{...jt[Vt],guid:Vt},domID:"rd_"+Xt,hotspotEnterTime:performance.now()},isAnyHotspotActive:!0}),Ht.includes(Xt)||(Ht.push(Xt),kt.hotspotStore.setState({visitedIDs:{...Ht}}))}var replacingNodes=null,swappableNodes=[];const createGhostStore=kt=>{const _e=ghostStoreCreator();return _e.setState({stores:kt}),_e},ghostStoreCreator=()=>create((kt,_e)=>({stores:null,ghostData:null,ghostsTransform:[],ghostVisibility:!0,ghostParentRef:null,ghostMaterial:null,actions:{spawnGhostsForSkuID:async(Dt,Vt=!1,Gt)=>{const{ghostData:zt,ghostsTransform:jt,stores:Ht}=_e();if(zt!==null||jt.length>0){LOGGER.info({title:"ghosts are already spawned for: "+zt.skuID});return}return await new Promise(async(qt,Xt)=>{let Kt={};const Yt=()=>{qt(Kt)};Ht.coreSceneStore.getState().CORE_API.coreWCRef.addEventListener(Ht.coreSceneStore.getState().CORE_API.EVENTS.SCENE.Ghost_Loaded,Yt,{once:!0});const Zt=Ht.productDataStore.getState().productData,Jt=Ht.attachmentStore.getState().attachmentSystem.currentStructure;replacingNodes=Jt.getNodesByCategoryID(Zt[Dt].categoryID);const nn=Ht.coreSceneStore.getState().sceneSettings.draggableUI,rn=await Jt.findGhostTransforms(Dt,Vt),Qt=nn?rn&&rn.transforms&&rn.transforms.length===0:!0;if(Zt[Dt].replace&&replacingNodes.length>0&&Qt)if(nn){const{newNodes:tn,transforms:sn,connectablePlugs:cn}=await Jt.findGhostTransformForReplacement(Dt,replacingNodes);if(sn==null||cn==null||sn.length<=0){LOGGER.error({title:"Couldn't Find Ghost transforms and connectablePlugs for "+Dt});return}let un=[];for(const hn of tn)hn.setModelVisibility(!1),un.push("replace");Kt.transforms=sn,Kt.newNodes=tn,Kt.connectablePlugs=cn,Kt.addItemOrSwap=un}else{const{newNodes:tn,transforms:sn,connectablePlugs:cn}=await Jt.findGhostTransformForReplacement(Dt,replacingNodes);if(sn==null&&cn==null){LOGGER.error({title:"Couldn't Find Ghost transforms and connectablePlugs for "+Dt});return}let un=[];for(const hn of tn)hn.setModelVisibility(!1),un.push("replace");Kt.transforms=sn,Kt.newNodes=tn,Kt.connectablePlugs=cn,Kt.addItemOrSwap=un}else{const{transforms:tn,newNodes:sn,connectablePlugs:cn,comboPlugs:un}=rn;let hn=tn,fn=cn,pn=sn,dn=[];for(let mn=0;mn<tn.length;mn++)dn.push("add");if(Zt[Dt].swappable&&!Ht.coreSceneStore.getState().dragging){swappableNodes=Jt.getNodesByCategoryID(Zt[Dt].categoryID);const mn=await Jt.findGhostTransformForReplacement(Dt,swappableNodes);if(mn.transforms)for(let vn=0;vn<mn.transforms.length;vn++)hn.push(mn.transforms[vn]),fn.push(mn.connectablePlugs[vn]),pn.push(mn.newNodes[vn]),dn.push("replace"),mn.newNodes[vn].setModelVisibility(!1)}Kt.transforms=hn,Kt.newNodes=pn,Kt.connectablePlugs=fn,Kt.comboPlugs=un,Kt.addItemOrSwap=dn}if(Kt.transforms.length<=0){Xt();return}const en=await Ht.assetStore.getState().actions.loadProxyAsset(Dt,!0);kt({ghostsTransform:Kt.transforms,ghostData:{proxyScene:en.proxy.data.scene,skuID:Dt,newNodes:Kt.newNodes,addItemOrSwap:Kt.addItemOrSwap,connectablePlugs:Kt.connectablePlugs,comboPlugs:Kt.comboPlugs,count:Gt||Kt.transforms.length}})})},clearAllGhosts:()=>{const{ghostsTransform:Dt}=_e();if(replacingNodes)for(const Vt of replacingNodes)Vt.setModelVisibility(!0);if(swappableNodes)for(let Vt=0;Vt<swappableNodes.length;Vt++)swappableNodes[Vt].setModelVisibility(!0);Dt.length<=0||kt({ghostVisibility:!0,ghostData:null,ghostsTransform:[]})}}})),createCameraStore=kt=>{const _e=cameraStoreCreator();return _e.setState({stores:kt}),_e},cameraStoreCreator=()=>create((kt,_e)=>({stores:null,focusPointPosition:new Vector3(0,0,0),sendCameraDetailsTrigger:!1,viewPointPosition:new Vector3(0,0,0),boundsMargin:0,savedState:!1,resetToLastPosition:!0,cameraControlsRef:null,userDragging:!1,disableAutoRotate:!1,cameraSettings:{truckSpeed:1,fov:35,dollySpeed:1,initialViewPointPosition:new Vector3(20,15,50),canZoom:!1,canPan:!1,minZoom:1,maxZoom:3,canAutoRotate:!1,autoRotateSpeed:.5,minPolarAngle:0,maxPolarAngle:180,clearColour:"white",zoomingMultiplier:0},actions:{canCameraRotate:Dt=>{const{cameraControlsRef:Vt}=_e();Vt&&(Dt===!0?(Vt.mouseButtons.left=CAMERA_ACTION.ROTATE,Vt.touches.one=CAMERA_ACTION.TOUCH_ROTATE):(Vt.mouseButtons.left=CAMERA_ACTION.NONE,Vt.touches.one=CAMERA_ACTION.NONE))},triggerFetchingCamera:()=>{kt(Dt=>({sendCameraDetailsTrigger:!Dt.sendCameraDetailsTrigger}))},setCameraSettings:Dt=>{const{cameraSettings:Vt,stores:Gt}=_e();Gt.coreSceneStore.getState().isMobile===!0&&Dt.zoomingMultiplier_mobile!==void 0?Dt.zoomingMultiplier=Dt.zoomingMultiplier_mobile:Dt.zoomingMultiplier_desktop!==void 0&&(Dt.zoomingMultiplier=Dt.zoomingMultiplier_desktop),Object.keys(Dt).map(jt=>Vt[jt]=Dt[jt]),kt({cameraSettings:{...Vt},viewPointPosition:ArrToVec3(Vt.initialViewPointPosition)})}}})),createUISceneStore=kt=>{const _e=uiSceneStoreCreator();return _e.setState({stores:kt}),_e},uiSceneStoreCreator=()=>create((kt,_e)=>({stores:null,CORE_API:null,sideMenuState:0,sideMenuOpen:!0,setSideMenuOpen:Dt=>kt({sideMenuOpen:Dt}),cssLoaded:!1,isScreenPortrait:!0,materialOverrideExists:!1,tabSpawnCount:[],coreWCRef:null,removeModalOpen:!1,outOfStockModalOpen:!1,disableCart:!1,inventoryData:{},cartMessage:"",loadConfigId:"",dialogPopupOpen:!1,viewInYourSpaceMenuBtnVisible:!1,loadConfigModalOpen:!1,setLoadConfigModalOpen:Dt=>kt({loadConfigModalOpen:Dt}),setOutOfStockModalOpen:Dt=>kt({outOfStockModalOpen:Dt}),setRemoveModalOpen:Dt=>kt({removeModalOpen:Dt}),moveModalOpen:!1,setMoveModalOpen:Dt=>kt({moveModalOpen:Dt}),setCSSLoaded:Dt=>{kt({cssLoaded:Dt})},setSideMenuState:Dt=>{kt(()=>({sideMenuState:Dt}));const{CORE_API:Vt}=_e();Dt!==2?Vt.exitHotspot():Vt.showAllHotspots()}})),createDynamicHookStore=kt=>{const _e=dynamicHookStoreCreator();return _e.setState({stores:kt}),_e},dynamicHookStoreCreator=()=>create((kt,_e)=>({hookOnCartItemsCollected:async(Dt,Vt)=>(LOGGER.info({title:"No hook provided: hookOnCartItemsCollected"}),Promise.resolve(Dt)),hookOnSceneItemsUpdated:async(Dt,Vt)=>(LOGGER.info({title:"No hook provided: hookOnSceneItemsUpdated"}),Promise.resolve()),hookOnNewItemGhostsCollected:async(Dt,Vt)=>(LOGGER.info({title:"No hook provided: hookOnNewItemGhostsCollected"}),Promise.resolve(Dt)),hookOnNewItemGhostsCollectedForReplacement:async(Dt,Vt)=>(LOGGER.info({title:"No hook provided: hookOnNewItemGhostsCollected"}),Promise.resolve(Dt)),hookOnSceneItemAdded:async(Dt,Vt,Gt)=>(LOGGER.info({title:"No hook provided: hookOnSceneItemAdded"}),Promise.resolve()),hookOnCheckout:async(Dt,Vt)=>(LOGGER.info({title:"No hook provided: hookOnSceneItemAdded"}),Promise.resolve(Dt))}));class STORES{experienceId="";uuid=null;wcRef=null;nexusApiResponseEnvironment="production";nexusApiInstance=null;productDataStore=null;coreSceneStore=null;inventoryStore=null;itemStore=null;assetStore=null;attachmentStore=null;lightStore=null;hotspotStore=null;ghostStore=null;cameraStore=null;infoStore=null;uiHotspotStore=null;colorStore=null;cartStore=null;uiSceneStore=null;constructor(_e){this.wcRef=_e,this.uuid=v4(),this.dynamicHookStore=createDynamicHookStore(this),this.productDataStore=createProductDataStore(this),this.coreSceneStore=createCoreSceneStore(this),this.inventoryStore=createInventoryStore(this),this.itemStore=createItemStore(this),this.assetStore=createAssetStore(this),this.attachmentStore=createAttachmentStore(this),this.lightStore=createLightStore(this),this.hotspotStore=createHotspotStore(this),this.ghostStore=createGhostStore(this),this.cameraStore=createCameraStore(this),this.infoStore=createInfoStore(this),this.uiHotspotStore=createUIHotspotStore(this),this.colorStore=createColorStore(this),this.cartStore=createCartStore(this),this.uiSceneStore=createUISceneStore(this)}setupNexusApiInstance(_e){let Dt=p$5.PRODUCTION;_e=="local"?Dt=p$5.LOCAL:_e==="staging"&&(Dt=p$5.STAGING);const Vt=window.location.href,Gt=window.epigraph?window.epigraph.epigraphSessionId:"no-session-id",zt="2.2.4",jt=g$3.generateXPath(this.wcRef);this.nexusApiInstance=new P$2(Dt,Vt,Gt,zt,jt)}}class EpigraphConfigurator extends h$5{#t=void 0;#i=null;#n=null;clientAccessKey=null;validationPassed=!1;projectID="";configID="default";customVersionId="";experienceId="";apiMode="production";gaMeasurementId="";#s=getUrlParameterByName("launchInAR")==="true";#r=!1;api={core:null,ui:null};stores=null;constructor(){let _e=s$2.PRODUCTION;super("2.2.4",_e),this.stores=new STORES(this),this.api.ui=this,this.shadowRoot||this.attachShadow({mode:"open"}),this.hasAttribute("launch-in-ar")&&(this.#s=!0),this.#c(),this.#o()}#c(){this.preloadDiv=document.createElement("div"),this.preloadDiv.id="preloadMainContainer",this.preloadDiv.classList.add("preload-main-container"),this.preloadDiv.classList.add("showPreload"),this.preloadDiv.appendChild(PRELOAD_MUTED_CSS.content.cloneNode(!0)),this.preloadDiv.appendChild(PRELOAD_HTML_TEMPLATE.content.cloneNode(!0)),this.shadowRoot.appendChild(this.preloadDiv);const _e=this.shadowRoot;this.#n=Dt=>{if(Dt.code=="Enter"){let Vt=_e.activeElement;Vt&&Vt.click()}},this.shadowRoot.addEventListener("keyup",this.#n)}#o(){this.hiccupUi=document.createElement("div"),this.hiccupUi.id="hiccupMainContainer",this.hiccupUi.classList.add("hiccup-ui-main-container"),this.hiccupUi.appendChild(HICCUP_MUTED_CSS.content.cloneNode(!0)),this.hiccupUi.appendChild(HICCUP_HTML_TEMPLATE.content.cloneNode(!0)),this.shadowRoot.appendChild(this.hiccupUi)}get configuratorWcId(){return this.#t}get launchInAr(){return this.#s}#a(){if(this.hasAttribute("id")?this.#t=this.getAttribute("id"):(this.setAttribute("id","epigraphConfiguratorWc"),this.#t=this.getAttribute("id")),this.hasAttribute("custom-version-id")&&(this.customVersionId=this.getAttribute("custom-version-id")),this.hasAttribute("experience-id")&&(this.experienceId=this.getAttribute("experience-id")),this.hasAttribute("api-mode")){const _e=this.getAttribute("api-mode");["local","staging","production"].includes(_e)&&(this.apiMode=_e)}this.stores.setupNexusApiInstance(this.apiMode),(this.hasAttribute("ga-measurement-id")||this.hasAttribute("ga-code"))&&(this.gaMeasurementId=this.getAttribute("ga-measurement-id")??this.getAttribute("ga-code")),this.clientAccessKey=this.getAttribute("client-access-key"),this.initialConfigId=this.getAttribute("initial-config-id"),this.consentPlugin=this.getAttribute("consent-plugin"),this.consentIdentifier=this.getAttribute("consent-identifier"),this.initialConfigId||(this.initialConfigId="default")}async connectedCallback(){if(this.#r===!0){console.warn("Tried to remount configurator. Blocking the process.");return}this.#a(),this.style.maxWidth="1440px",this.style.maxHeight="800px",this.style.overflow="hidden",this.style.width="100%",this.style.height="100%",this.style.position="relative",this.style.visibility="visible",this.style.display="flex";const _e=document.createElement("div");_e.id="configuratorContainer",_e.style.width="100%",_e.style.height="100%",_e.style.userSelect="none",_e.style.overflow="hidden",this.shadowRoot.appendChild(_e),this.#i=createRoot(_e),this.#i.render(jsxRuntimeExports.jsx(App,{stores:this.stores,customVersionId:this.customVersionId,experienceId:this.experienceId,disableUI:this.hasAttribute("disable-ui"),disableCart:this.hasAttribute("disable-cart"),configuratorWcRef:this,gaMeasurementId:this.gaMeasurementId},"Configurator-App")),this.#r=!0}disconnectedCallback(){for(this.#i&&(this.#i.unmount(),this.#i=null),this.#n&&(this.shadowRoot.removeEventListener("keyup",this.#n),this.#n=null),this.#t=void 0,this.clientAccessKey=null,this.validationPassed=!1,this.projectID="",this.configID="default",this.customVersionId="",this.gaMeasurementId="",this.#s=!1,this.#r=!1,this.api={core:null,ui:null},this.preloadDiv&&(this.preloadDiv.remove(),this.preloadDiv=null),this.hiccupUi&&(this.hiccupUi.remove(),this.hiccupUi=null);this.shadowRoot.firstChild;)this.shadowRoot.removeChild(this.shadowRoot.firstChild)}showPreloadScreen(){this.preloadDiv&&(this.preloadDiv.classList.remove("no-pointer-events"),this.preloadDiv.classList.add("showPreload"))}async hidePreloadScreen(){this.preloadDiv&&(this.preloadDiv.classList.remove("showPreload"),await wait(1e3),this.preloadDiv.classList.add("no-pointer-events"))}showHiccupScreen(){this.hiccupUi&&(this.hiccupUi.classList.remove("no-pointer-events"),this.hiccupUi.classList.add("show-hiccup"))}async hideHiccupScreen(){this.hiccupUi&&(this.hiccupUi.classList.remove("show-hiccup"),await wait(1e3),this.hiccupUi.classList.add("no-pointer-events"))}}window.customElements.define("epigraph-configurator",EpigraphConfigurator);