shop-components 0.3.5 → 0.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/shop-components.cjs +3 -3
- package/dist/shop-components.mjs +13 -4
- package/package.json +1 -1
package/dist/shop-components.cjs
CHANGED
|
@@ -3703,7 +3703,7 @@ ${t.name}`)}break}}}}else a.texture_lod=0}};J=new WeakMap,ve=new WeakMap,ai=new
|
|
|
3703
3703
|
* goldfirestudios.com
|
|
3704
3704
|
*
|
|
3705
3705
|
* MIT License
|
|
3706
|
-
*/(function(){HowlerGlobal.prototype._pos=[0,0,0],HowlerGlobal.prototype._orientation=[0,0,-1,0,1,0],HowlerGlobal.prototype.stereo=function(t){var i=this;if(!i.ctx||!i.ctx.listener)return i;for(var s=i._howls.length-1;s>=0;s--)i._howls[s].stereo(t);return i},HowlerGlobal.prototype.pos=function(t,i,s){var a=this;if(!a.ctx||!a.ctx.listener)return a;if(i=typeof i!="number"?a._pos[1]:i,s=typeof s!="number"?a._pos[2]:s,typeof t=="number")a._pos=[t,i,s],typeof a.ctx.listener.positionX<"u"?(a.ctx.listener.positionX.setTargetAtTime(a._pos[0],Howler.ctx.currentTime,.1),a.ctx.listener.positionY.setTargetAtTime(a._pos[1],Howler.ctx.currentTime,.1),a.ctx.listener.positionZ.setTargetAtTime(a._pos[2],Howler.ctx.currentTime,.1)):a.ctx.listener.setPosition(a._pos[0],a._pos[1],a._pos[2]);else return a._pos;return a},HowlerGlobal.prototype.orientation=function(t,i,s,a,o,c){var u=this;if(!u.ctx||!u.ctx.listener)return u;var f=u._orientation;if(i=typeof i!="number"?f[1]:i,s=typeof s!="number"?f[2]:s,a=typeof a!="number"?f[3]:a,o=typeof o!="number"?f[4]:o,c=typeof c!="number"?f[5]:c,typeof t=="number")u._orientation=[t,i,s,a,o,c],typeof u.ctx.listener.forwardX<"u"?(u.ctx.listener.forwardX.setTargetAtTime(t,Howler.ctx.currentTime,.1),u.ctx.listener.forwardY.setTargetAtTime(i,Howler.ctx.currentTime,.1),u.ctx.listener.forwardZ.setTargetAtTime(s,Howler.ctx.currentTime,.1),u.ctx.listener.upX.setTargetAtTime(a,Howler.ctx.currentTime,.1),u.ctx.listener.upY.setTargetAtTime(o,Howler.ctx.currentTime,.1),u.ctx.listener.upZ.setTargetAtTime(c,Howler.ctx.currentTime,.1)):u.ctx.listener.setOrientation(t,i,s,a,o,c);else return f;return u},Howl.prototype.init=function(t){return function(i){var s=this;return s._orientation=i.orientation||[1,0,0],s._stereo=i.stereo||null,s._pos=i.pos||null,s._pannerAttr={coneInnerAngle:typeof i.coneInnerAngle<"u"?i.coneInnerAngle:360,coneOuterAngle:typeof i.coneOuterAngle<"u"?i.coneOuterAngle:360,coneOuterGain:typeof i.coneOuterGain<"u"?i.coneOuterGain:0,distanceModel:typeof i.distanceModel<"u"?i.distanceModel:"inverse",maxDistance:typeof i.maxDistance<"u"?i.maxDistance:1e4,panningModel:typeof i.panningModel<"u"?i.panningModel:"HRTF",refDistance:typeof i.refDistance<"u"?i.refDistance:1,rolloffFactor:typeof i.rolloffFactor<"u"?i.rolloffFactor:1},s._onstereo=i.onstereo?[{fn:i.onstereo}]:[],s._onpos=i.onpos?[{fn:i.onpos}]:[],s._onorientation=i.onorientation?[{fn:i.onorientation}]:[],t.call(this,i)}}(Howl.prototype.init),Howl.prototype.stereo=function(t,i){var s=this;if(!s._webAudio)return s;if(s._state!=="loaded")return s._queue.push({event:"stereo",action:function(){s.stereo(t,i)}}),s;var a=typeof Howler.ctx.createStereoPanner>"u"?"spatial":"stereo";if(typeof i>"u")if(typeof t=="number")s._stereo=t,s._pos=[t,0,0];else return s._stereo;for(var o=s._getSoundIds(i),c=0;c<o.length;c++){var u=s._soundById(o[c]);if(u)if(typeof t=="number")u._stereo=t,u._pos=[t,0,0],u._node&&(u._pannerAttr.panningModel="equalpower",(!u._panner||!u._panner.pan)&&e(u,a),a==="spatial"?typeof u._panner.positionX<"u"?(u._panner.positionX.setValueAtTime(t,Howler.ctx.currentTime),u._panner.positionY.setValueAtTime(0,Howler.ctx.currentTime),u._panner.positionZ.setValueAtTime(0,Howler.ctx.currentTime)):u._panner.setPosition(t,0,0):u._panner.pan.setValueAtTime(t,Howler.ctx.currentTime)),s._emit("stereo",u._id);else return u._stereo}return s},Howl.prototype.pos=function(t,i,s,a){var o=this;if(!o._webAudio)return o;if(o._state!=="loaded")return o._queue.push({event:"pos",action:function(){o.pos(t,i,s,a)}}),o;if(i=typeof i!="number"?0:i,s=typeof s!="number"?-.5:s,typeof a>"u")if(typeof t=="number")o._pos=[t,i,s];else return o._pos;for(var c=o._getSoundIds(a),u=0;u<c.length;u++){var f=o._soundById(c[u]);if(f)if(typeof t=="number")f._pos=[t,i,s],f._node&&((!f._panner||f._panner.pan)&&e(f,"spatial"),typeof f._panner.positionX<"u"?(f._panner.positionX.setValueAtTime(t,Howler.ctx.currentTime),f._panner.positionY.setValueAtTime(i,Howler.ctx.currentTime),f._panner.positionZ.setValueAtTime(s,Howler.ctx.currentTime)):f._panner.setPosition(t,i,s)),o._emit("pos",f._id);else return f._pos}return o},Howl.prototype.orientation=function(t,i,s,a){var o=this;if(!o._webAudio)return o;if(o._state!=="loaded")return o._queue.push({event:"orientation",action:function(){o.orientation(t,i,s,a)}}),o;if(i=typeof i!="number"?o._orientation[1]:i,s=typeof s!="number"?o._orientation[2]:s,typeof a>"u")if(typeof t=="number")o._orientation=[t,i,s];else return o._orientation;for(var c=o._getSoundIds(a),u=0;u<c.length;u++){var f=o._soundById(c[u]);if(f)if(typeof t=="number")f._orientation=[t,i,s],f._node&&(f._panner||(f._pos||(f._pos=o._pos||[0,0,-.5]),e(f,"spatial")),typeof f._panner.orientationX<"u"?(f._panner.orientationX.setValueAtTime(t,Howler.ctx.currentTime),f._panner.orientationY.setValueAtTime(i,Howler.ctx.currentTime),f._panner.orientationZ.setValueAtTime(s,Howler.ctx.currentTime)):f._panner.setOrientation(t,i,s)),o._emit("orientation",f._id);else return f._orientation}return o},Howl.prototype.pannerAttr=function(){var t=this,i=arguments,s,a,o;if(!t._webAudio)return t;if(i.length===0)return t._pannerAttr;if(i.length===1)if(typeof i[0]=="object")s=i[0],typeof a>"u"&&(s.pannerAttr||(s.pannerAttr={coneInnerAngle:s.coneInnerAngle,coneOuterAngle:s.coneOuterAngle,coneOuterGain:s.coneOuterGain,distanceModel:s.distanceModel,maxDistance:s.maxDistance,refDistance:s.refDistance,rolloffFactor:s.rolloffFactor,panningModel:s.panningModel}),t._pannerAttr={coneInnerAngle:typeof s.pannerAttr.coneInnerAngle<"u"?s.pannerAttr.coneInnerAngle:t._coneInnerAngle,coneOuterAngle:typeof s.pannerAttr.coneOuterAngle<"u"?s.pannerAttr.coneOuterAngle:t._coneOuterAngle,coneOuterGain:typeof s.pannerAttr.coneOuterGain<"u"?s.pannerAttr.coneOuterGain:t._coneOuterGain,distanceModel:typeof s.pannerAttr.distanceModel<"u"?s.pannerAttr.distanceModel:t._distanceModel,maxDistance:typeof s.pannerAttr.maxDistance<"u"?s.pannerAttr.maxDistance:t._maxDistance,refDistance:typeof s.pannerAttr.refDistance<"u"?s.pannerAttr.refDistance:t._refDistance,rolloffFactor:typeof s.pannerAttr.rolloffFactor<"u"?s.pannerAttr.rolloffFactor:t._rolloffFactor,panningModel:typeof s.pannerAttr.panningModel<"u"?s.pannerAttr.panningModel:t._panningModel});else return o=t._soundById(parseInt(i[0],10)),o?o._pannerAttr:t._pannerAttr;else i.length===2&&(s=i[0],a=parseInt(i[1],10));for(var c=t._getSoundIds(a),u=0;u<c.length;u++)if(o=t._soundById(c[u]),o){var f=o._pannerAttr;f={coneInnerAngle:typeof s.coneInnerAngle<"u"?s.coneInnerAngle:f.coneInnerAngle,coneOuterAngle:typeof s.coneOuterAngle<"u"?s.coneOuterAngle:f.coneOuterAngle,coneOuterGain:typeof s.coneOuterGain<"u"?s.coneOuterGain:f.coneOuterGain,distanceModel:typeof s.distanceModel<"u"?s.distanceModel:f.distanceModel,maxDistance:typeof s.maxDistance<"u"?s.maxDistance:f.maxDistance,refDistance:typeof s.refDistance<"u"?s.refDistance:f.refDistance,rolloffFactor:typeof s.rolloffFactor<"u"?s.rolloffFactor:f.rolloffFactor,panningModel:typeof s.panningModel<"u"?s.panningModel:f.panningModel};var p=o._panner;p||(o._pos||(o._pos=t._pos||[0,0,-.5]),e(o,"spatial"),p=o._panner),p.coneInnerAngle=f.coneInnerAngle,p.coneOuterAngle=f.coneOuterAngle,p.coneOuterGain=f.coneOuterGain,p.distanceModel=f.distanceModel,p.maxDistance=f.maxDistance,p.refDistance=f.refDistance,p.rolloffFactor=f.rolloffFactor,p.panningModel=f.panningModel}return t},Sound.prototype.init=function(t){return function(){var i=this,s=i._parent;i._orientation=s._orientation,i._stereo=s._stereo,i._pos=s._pos,i._pannerAttr=s._pannerAttr,t.call(this),i._stereo?s.stereo(i._stereo):i._pos&&s.pos(i._pos[0],i._pos[1],i._pos[2],i._id)}}(Sound.prototype.init),Sound.prototype.reset=function(t){return function(){var i=this,s=i._parent;return i._orientation=s._orientation,i._stereo=s._stereo,i._pos=s._pos,i._pannerAttr=s._pannerAttr,i._stereo?s.stereo(i._stereo):i._pos?s.pos(i._pos[0],i._pos[1],i._pos[2],i._id):i._panner&&(i._panner.disconnect(0),i._panner=void 0,s._refreshBuffer(i)),t.call(this)}}(Sound.prototype.reset);var e=function(t,i){i=i||"spatial",i==="spatial"?(t._panner=Howler.ctx.createPanner(),t._panner.coneInnerAngle=t._pannerAttr.coneInnerAngle,t._panner.coneOuterAngle=t._pannerAttr.coneOuterAngle,t._panner.coneOuterGain=t._pannerAttr.coneOuterGain,t._panner.distanceModel=t._pannerAttr.distanceModel,t._panner.maxDistance=t._pannerAttr.maxDistance,t._panner.refDistance=t._pannerAttr.refDistance,t._panner.rolloffFactor=t._pannerAttr.rolloffFactor,t._panner.panningModel=t._pannerAttr.panningModel,typeof t._panner.positionX<"u"?(t._panner.positionX.setValueAtTime(t._pos[0],Howler.ctx.currentTime),t._panner.positionY.setValueAtTime(t._pos[1],Howler.ctx.currentTime),t._panner.positionZ.setValueAtTime(t._pos[2],Howler.ctx.currentTime)):t._panner.setPosition(t._pos[0],t._pos[1],t._pos[2]),typeof t._panner.orientationX<"u"?(t._panner.orientationX.setValueAtTime(t._orientation[0],Howler.ctx.currentTime),t._panner.orientationY.setValueAtTime(t._orientation[1],Howler.ctx.currentTime),t._panner.orientationZ.setValueAtTime(t._orientation[2],Howler.ctx.currentTime)):t._panner.setOrientation(t._orientation[0],t._orientation[1],t._orientation[2])):(t._panner=Howler.ctx.createStereoPanner(),t._panner.pan.setValueAtTime(t._stereo,Howler.ctx.currentTime)),t._panner.connect(t._node),t._paused||t._parent.pause(t._id,!0).play(t._id,!0)}})()})(Rr);const za="data:audio/mpeg;base64,SUQzBAAAAAAAI1RTU0UAAAAPAAADTGF2ZjU4LjQxLjEwMAAAAAAAAAAAAAAA//NwwAAAAAAAAAAAAEluZm8AAAAPAAAAFAAACOAAICAgICwsLCwsNzc3NzdDQ0NDQ09PT09PW1tbW1tmZmZmZnJycnJyfn5+fn6KioqKipWVlZWVoaGhoaGtra2trbm5ubm5xcXFxcXQ0NDQ0Nzc3Nzc6Ojo6Oj09PT09P//////AAAAAExhdmM1OC43NQAAAAAAAAAAAAAAACQCwAAAAAAAAAjgTZykiAAAAAAAAAAAAAAAAAD/80DEABJhFmQCwwYUIDsKrsHAWBMRyeJYliQJBg5RYsWU/W3z/8OLc/3AAAQiIAIjv+7vUCJXd4jucQABAE3lwffiDBD+JC58oCH8H/1h/WH//1HPwTUMFrULH9ELKxULyTodFKYbO//zQsQRFFkScKDSRhyGWpIFpG91I7Fi/F6D2RWwN6TN/t9CiVSG5wMw74ogYcHoEwTFyMmTf4KkxEwmRfjXIYv1tpIOZRv/3O9ibtjR6gYmbGCgQ+Fk0mfSmybOX1cf78g7D6nP6qxCgf/zQMQbF+EacktaSABfy+3JKszHdMgcwwcl/kNFIuAo0I0DD1fWVs/crTSTTRInof3cmIwyLBwGQqCSLq7hyvtRPBB4aFyyXHov9X///7UXKqoIIcgcHict89/0y+n+nf/C0DIjB/+P//NCxBYZU9q0AYpoAHNyXSLn/+EjEbJclC4eJT//8e5aMAWeE4////wvAyAvYjZLjAD0Lg9D0kCU/////zwwBdJcYAehKBIwtYyx6FyXC4XP//////x7l83NDpfqd6gAcA/+wu9A2FGg//NAxAwXCnsq/5M4AhQKAOwmRvQRhjhOe5S8UkAmVHpU8IVU3lwejjIcayXOOceGwjf+D05I8oAu2x382o1ZHHV//31NU4441lmqcv///+RNGrUJKImnTf//iVYK1UZquoZESSy3egH/80LEChchBtMfyzAAk191v20qimbuNqavb211BthJKSJAG2aucbdLeVFVmRjZEVvzOggIwuUFDgvEZA7UeuUqNMLOraDQ5CVCk5m9BsmT3kbNrBdolcFSsqXGwQTWyYUX2wEDEgKkvZb/80DECRYRUpWsikYY1HXLbDZksYxtCHBShdHt/DgYCOM6r8AmUSpfGZYzH7ARMBCj1JtmY/hmwoGio0XBUShoklC5GsNeDR38RQ6d01DyrENtqp6mCJ5GJUckmpUBaIgYK6C0fPjmUf/zQsQLFil+cajTBhydxPRO4mLMWWSGQF2qa1f3PPlHQDJdzCxnwgkzB1SQohrpNRYRgtobv07tBLUFc27jQdWoQY0JNpiMJy654enBVoqnQR571uq/i9rpL1oAqAupJATLLk5L+QT3Kf/zQMQOE9D2bWFaGACZyWQZdt1rd3OVY8s/y2dBlg0m12PFzdFSlYrboY6gMOE1hJp7iFqmDcopF8F2OKEPnktdThRLoy9iuyj//0vD4+qf///++38OsIIFFhpEFZMC4s+gZmilJz1X//NCxBkaW8allZI4AWPWKBoLFWrwfuYvukbk4Rt9tBuJYOBoWpfzfjQaNMp//+OGEzzzDIif3+n/4PBIEt5hjDc9zxv/////nseeNDHGg0MQwxBEFn//////4TpB9d/s9thcHddpssFg//NAxAsVCT8GX5BAAigUAPBBdOBaKEIpaajR1VyCNH/gAwAfjRX8G7B4zfx0HANA8BpjQ6FhfqKxRBQURleGbrufzJywVGVfRdOz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aYkmmQGRpnCsAMAEB4tQrXVA0VOiINSMWfljtMTHsRdZ3iL/V1neW6zvLf/zQsQnDSAiMFXMGADWd4i6zvEX+W/yzud5ZUxBTUUzLjEwMFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVQ==";let Va=class{constructor(){this.sound=new Rr.Howl({src:[za]})}play(){this.sound.play()}};const xe=n=>{var e,t;if(typeof n.destroy=="function"){n.destroy();return}for(;n.children.length>0;)xe(n.children[0]),(e=n.children[0])==null||e.removeFromParent();if(n instanceof d.Mesh)try{(t=n.geometry)==null||t.dispose()}catch{}};function Ua(n){return new d.Vector3(n[0],n[1],n[2])}function Ha(){let n=3,e=Math.max(1/window.devicePixelRatio,.5);return window.innerWidth/window.innerHeight<.65&&(n=4,e=1/window.devicePixelRatio),{tiles:n,renderScale:e}}function Na(n){let e=!1,t=!1,i=!1,s=1/0,a=1/0,o=1/0,c=-1/0,u=-1/0,f=-1/0,p=0,r=0;return n.traverse(h=>{if(h.isMesh&&h.geometry){const g=h;if(g.userData.ignoreSize||g.material.userData.isLOGO)return;g.geometry.computeBoundingBox();let _=g.geometry.attributes.position;const m=g.geometry.morphAttributes.position;let v=g.morphTargetInfluences;const y=Object.keys(g.morphTargetDictionary||{});y.includes("width")&&(t=!0),y.includes("length")&&(e=!0),y.includes("height")&&(i=!0);for(let x=0;x<_.count;x++){let w=_.getX(x),b=_.getY(x),A=_.getZ(x);r=Math.max(b,r),m&&v&&m.forEach((I,C)=>{const P=v&&v[C]||0;w+=I.getX(x)*P,b+=I.getY(x)*P,A+=I.getZ(x)*P}),w<s&&(s=w),b<a&&(a=b),A<o&&(o=A),w>c&&(c=w),b>u&&(u=b),A>f&&(f=A);const T=Math.sqrt(w*w+b*b);T>p&&(p=T)}}}),{box:new d.Box3(new d.Vector3(s,a,o),new d.Vector3(c,u,f)),maxRadius:p,height:r,hasWidth:t,hasLength:e,hasHeight:i}}function Wa(n,e,t=null){let i=0;return function(){let s=t||this,a=arguments;clearTimeout(i),i=window.setTimeout(function(){n.apply(s,a)},e)}}class Ga{constructor(e,t,i){this.length=e,this.width=t,this.height=i}}const Ws=n=>{var i;let e=0,t=0;if(n.geometry){n.geometry.computeBoundingBox();const s=new d.Vector3;(i=n.geometry.boundingBox)==null||i.getSize(s),s.y?(t=s.y,!s.x&&s.z?e=s.z:s.x&&!s.z?e=s.x:s.x&&s.z&&(e=s.z)):(e=s.z,t=s.x)}return{width:e,height:t}};function cs(){var e;if(typeof navigator>"u")return!1;if(qa())return!0;const n=(e=navigator.userAgent)==null?void 0:e.toLowerCase();return/iphone|ipad|ipod|android|mobile|blackberry|iemobile|opera mini/.test(n)}function qa(){try{if(typeof wx<"u"&&wx.getSystemInfo||typeof my<"u"&&my.alert||typeof tt<"u"&&tt.getSystemInfo||typeof swan<"u"&&swan.getSystemInfo)return!0}catch{}return!1}const Pr=new hn.GLTFExporter,lt=new ln.GLTFLoader,ui=new cn.DRACOLoader;let st="./draco/";try{st=new URL("./draco/",typeof document>"u"?require("url").pathToFileURL(__filename).href:ot&&ot.src||new URL("shop-components.cjs",document.baseURI).href).href}catch{st="./draco/"}typeof window<"u"&&window.dracoPath&&(st=window.dracoPath);ui.setDecoderConfig({type:"wasm"});ui.setDecoderPath(st.endsWith("/")?st:`${st}/`);ui.preload();lt.setDRACOLoader(ui);const ja=new un.DRACOExporter,Gs=[115,103,108,98];function Ya(n,e,t){const i=JSON.stringify(e),s=new TextEncoder().encode(i),a=new Uint8Array([115,103,108,98]),o=new Uint8Array(2);o[0]=t>>8,o[1]=t&255;const c=new Uint8Array(4);c[0]=s.length>>24,c[1]=s.length>>16&255,c[2]=s.length>>8&255,c[3]=s.length&255;const u=new Uint8Array(n),f=a.length+o.length+c.length+s.length+u.length,p=new Uint8Array(f);let r=0;return p.set(a,r),r+=a.length,p.set(o,r),r+=o.length,p.set(c,r),r+=c.length,p.set(s,r),r+=s.length,p.set(u,r),p.buffer}function Qa(n){const e=new Uint8Array(n.slice(0,4));let t=!0;for(let r=0;r<Gs.length;r++)if(e[r]!==Gs[r]){t=!1;break}if(!t)throw new Error("Invalid file format");const s=new DataView(n,4,2).getUint16(0,!1),o=new DataView(n,6,4).getUint32(0,!1),c=new Uint8Array(n.slice(10,10+o)),u=new TextDecoder().decode(c),f=JSON.parse(u),p=n.slice(10+o);return{version:s,jsonDescription:f,glbContent:p}}class ni{constructor(e){this.props=e,this.cache=new Map}load(e,t,i,s){if(this.props.useCache&&this.cache.has(e)){t(this.cache.get(e));return}const a=this;fetch(e).then(o=>{if(!o.ok){s==null||s(new ErrorEvent("NetworkError",{message:"NetworkError for "+e+": "+o.statusText}));return}return o.arrayBuffer()}).then(async o=>{o||s==null||s(new ErrorEvent("Error",{message:"Not a valid sglb file."}));try{const c=a.parse(o);if(!c.glbContent){s==null||s(new ErrorEvent("Error",{message:"No glb content."}));return}const u=Hi(c.glbContent,"model/gltf-binary"),f=await lt.loadAsync(u);URL.revokeObjectURL(u),c.glbContent=void 0,c.glb=f.scene,o=void 0,this.cache.set(e,c),t(c)}catch(c){s==null||s(new ErrorEvent("Error",{message:c==null?void 0:c.message}))}}).catch(o=>{s==null||s(new ErrorEvent("Error",{message:o.message}))})}async loadAsync(e){if(this.props.useCache&&this.cache.has(e))return this.cache.get(e);try{const t=await fetch(e);if(!t.ok)throw new Error(`NetworkError for ${e}: ${t.statusText}`);const i=await t.arrayBuffer();if(!i)throw new Error("Not a valid sglb file.");const s=this.parse(i);if(!s.glbContent)throw new Error("No GLB content.");const a=Hi(s.glbContent,"model/gltf-binary");console.log(a);const o=await lt.loadAsync(a);return URL.revokeObjectURL(a),s.glbContent=void 0,s.glb=o.scene,this.cache.set(e,s),s}catch(t){throw t}}parse(e){return Qa(e)}clear(){[...this.cache.values()]}}const Za=`*{box-sizing:border-box}.slot-item-container.is-mobile .main{pointer-events:none;border-width:1px;opacity:.8}.slot-item-container.is-mobile .main.focus{width:18px!important;height:18px!important;border-width:2px;opacity:1}.slot-item-container.is-mobile .main.filled{opacity:1;border-width:1px;width:14px!important;height:14px!important;background-image:none;border-radius:50%}.slot-item-container.is-mobile .main.to-be-installed{opacity:1;pointer-events:auto;width:38px!important;height:38px!important;border-color:#000;border-width:1px;background-image:url("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20fill='none'%20version='1.1'%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%3e%3cg%3e%3cg%3e%3cpath%20d='M20,10.75L0,10.75L0,9.25L20,9.25L20,10.75Z'%20fill-rule='evenodd'%20fill='%23000000'%20fill-opacity='1'/%3e%3c/g%3e%3cg%20transform='matrix(0,1,1,0,10,-10)'%3e%3cpath%20d='M30,0.75L10,0.75L10,-0.75L30,-0.75L30,0.75Z'%20fill-rule='evenodd'%20fill='%23000000'%20fill-opacity='1'/%3e%3c/g%3e%3c/g%3e%3c/svg%3e");background-size:20px auto;background-repeat:no-repeat;background-position:center;background-color:#fff9}.slot-item-container.is-mobile .main.to-be-installed+.info{pointer-events:auto;overflow:visible;width:auto}.slot-item-container.is-mobile .main.to-be-installed.filled{opacity:1;border-width:2px;width:18px!important;height:18px!important;background-image:none;border-radius:50%;border-color:#00ff95}.slot-item-container.is-mobile .main.to-be-installed.to-be-replaced{opacity:1;border-width:1px;pointer-events:auto;width:38px!important;height:38px!important;border-radius:50%;background-image:url("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20fill='none'%20version='1.1'%20width='40'%20height='40'%20viewBox='0%200%2040%2040'%3e%3cdefs%3e%3cclipPath%20id='master_svg0_504_014299'%3e%3crect%20x='0'%20y='0'%20width='40'%20height='40'%20rx='20'/%3e%3c/clipPath%3e%3c/defs%3e%3cg%20clip-path='url(%23master_svg0_504_014299)'%3e%3cg%3e%3cg%3e%3cpath%20d='M31.695414,17L26.009501,10.74549544L24.899591,11.75450456L28.304586,15.5L8.75,15.5L8.75,17L31.695414,17Z'%20fill-rule='evenodd'%20fill='%23000000'%20fill-opacity='1'/%3e%3c/g%3e%3cg%3e%3cpath%20d='M8.3045862,23L13.9904997,29.2545042L15.10041,28.2454953L11.6954139,24.5L31.25,24.5L31.25,23L8.3045862,23Z'%20fill-rule='evenodd'%20fill='%23000000'%20fill-opacity='1'/%3e%3c/g%3e%3c/g%3e%3c/g%3e%3c/svg%3e");background-size:38px auto;border-color:#000}.slot-item-container.is-mobile .info{left:100%;margin-top:0;margin-left:4px}.slot-item-container.is-mobile .info .name-wrapper{margin-top:0;border-radius:0;background:#000;color:#fff}.slot-item-container.is-mobile .info>img{display:none}.slot-item-container .main{pointer-events:auto;cursor:pointer;font-size:12px;color:#fff;width:22px;height:22px;background:#fff0;border:1.5px solid #fff;border-radius:0;transition:background .2s,width .14s,height .14s,border .14s}.slot-item-container .main.disable{cursor:not-allowed}.slot-item-container .main.drag-over{border-color:red}.slot-item-container .main.can-install{position:relative;width:44px;height:44px;background:#0066ff1a;border-color:#06f}.slot-item-container .main.filled{border-color:#00ff95;border-radius:50%}.slot-item-container .main.selected{border-width:4px}.slot-item-container .main.selected+.info{pointer-events:auto;overflow:visible;width:auto}.slot-item-container .main.focus{border-color:#000}.slot-item-container .main.focus+.info{pointer-events:auto;overflow:visible;width:auto}.slot-item-container .main.has-error{border-color:red}.slot-item-container .main.hidden{display:none}.slot-item-container .main.hidden+.info{display:none}.slot-item-container .main:after{pointer-events:none;content:attr(data-name);transition:all .2s .3s;opacity:0;position:absolute;left:50%;bottom:100%;transform:translate3d(-50%,5px,0);white-space:nowrap;font-size:12px;color:#000;padding:2px 8px;border-radius:2px;background:#fff}.slot-item-container .main:hover{background:#ffffff80}.slot-item-container .main:hover+.info{pointer-events:auto;overflow:visible;width:auto}.slot-item-container .name{position:relative}.slot-item-container .name-wrapper{margin-top:-10px;white-space:nowrap;font-size:12px;color:#fff;padding:2px 8px;background:#000}.slot-item-container .functions-wrapper{z-index:20000;position:absolute;left:0;top:100%}.slot-item-container .functions-wrapper>.functions{display:inline-block;min-width:100px;padding:6px 0;border-left:1px solid #00ff95;border-radius:0 2px 2px 0;background:#0003;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px)}.slot-item-container .functions-wrapper>.functions .btn-add{cursor:pointer;padding:2px 0;margin:0 8px;display:flex;justify-content:center;align-content:center;align-items:center;border:1px dashed #eee;font-size:12px;color:#eee;border-radius:2px;-webkit-backdrop-filter:none;backdrop-filter:none;background:#00050a80}.slot-item-container .functions-wrapper>.functions .btn-add.btn-not-allowed{cursor:not-allowed}.slot-item-container .functions-wrapper>.functions .function{display:flex;justify-content:space-between;white-space:nowrap;margin-bottom:6px;padding:0 8px;font-size:12px;color:#fff}.slot-item-container .functions-wrapper>.functions .function span{margin-right:4px}.slot-item-container .functions-wrapper>.functions .function .btn-remove{pointer-events:none;opacity:0;cursor:pointer;align-self:center;margin-right:0;height:14px;width:14px;background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAACnSURBVEiJxZaxFcMgDETPTuUtWCWTM4pZAq5RojRpnOfEyEKxSnh3HySeBEhNjZJJTRgUG89GyZWilbKOgJCaKmWtFG2UvFnwQr56jYAcengg3dozELPGIjh96x6hu26/DIa9vD0jq/nUA3nikQEkAOW9nACUGbf7skxlX2mIj1Ob0jK76QdxbYpGFNlk3rPnNndDQltFaLMLbdehAyd8ZP5l6Ed+W17xG7oN9QkytAAAAABJRU5ErkJggg==) center no-repeat;background-size:10px 10px}.slot-item-container .functions-wrapper>.functions .function:hover .btn-remove{pointer-events:auto;opacity:1;transform:scale(1.2)}.slot-item-container .device-name{position:relative;margin:2px 0;display:flex;min-width:120px;align-items:center;align-content:center;justify-content:space-between;white-space:nowrap;height:30px;padding:0 8px;font-size:14px;font-weight:700;color:#000;background:#fff}.slot-item-container .device-name .device-logo{margin-left:-8px;margin-right:4px;width:30px;height:30px;object-fit:contain}.slot-item-container .device-name span{display:block;white-space:nowrap;text-overflow:ellipsis;overflow:hidden;max-width:250px}.slot-item-container .device-name .btn-close{margin-left:8px;cursor:pointer;height:20px;width:20px;background:url("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20fill='none'%20version='1.1'%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%3e%3cdefs%3e%3cclipPath%20id='master_svg0_504_017509'%3e%3crect%20x='0'%20y='0'%20width='20'%20height='20'%20rx='0'/%3e%3c/clipPath%3e%3c/defs%3e%3cg%20clip-path='url(%23master_svg0_504_017509)'%3e%3cg%3e%3cpath%20d='M4.375,16.875L4.375,4.375L15.625,4.375L15.625,16.875L4.375,16.875ZM14.375,5.625L5.625,5.625L5.625,15.625L14.375,15.625L14.375,5.625Z'%20fill-rule='evenodd'%20fill='%23999999'%20fill-opacity='1'/%3e%3c/g%3e%3cg%3e%3cpath%20d='M8.125,12.1875L8.125,8.125L9.375,8.125L9.375,12.1875L8.125,12.1875Z'%20fill-rule='evenodd'%20fill='%23999999'%20fill-opacity='1'/%3e%3c/g%3e%3cg%3e%3cpath%20d='M10.625,12.1875L10.625,8.125L11.875,8.125L11.875,12.1875L10.625,12.1875Z'%20fill-rule='evenodd'%20fill='%23999999'%20fill-opacity='1'/%3e%3c/g%3e%3cg%3e%3cpath%20d='M16.875,5.625L3.125,5.625L3.125,4.375L16.875,4.375L16.875,5.625Z'%20fill-rule='evenodd'%20fill='%23999999'%20fill-opacity='1'/%3e%3c/g%3e%3cg%3e%3cpath%20d='M6.4446528999999995,5.625L13.545177899999999,5.625L11.8665838,2.5L8.15767372,2.5L6.4446528999999995,5.625ZM11.4548223,4.3749999L8.5553472,4.3749999L8.8979512,3.75L11.1191032,3.75L11.4548223,4.3749999Z'%20fill-rule='evenodd'%20fill='%23999999'%20fill-opacity='1'/%3e%3c/g%3e%3c/g%3e%3c/svg%3e") center no-repeat;background-size:100% auto}.slot-item-container .device-name.empty{color:#000c;font-weight:400}.slot-item-container .device-name.empty .btn-close{display:none}.slot-item-container .device-name.empty:before{height:0}.slot-item-container .all-functions{opacity:0;pointer-events:none;min-width:80px;position:absolute;left:-10px;margin-left:100%;bottom:0;padding:6px 0;background:#fff;transition:all .3s}.slot-item-container .all-functions.show{opacity:1;pointer-events:auto;left:16px}.slot-item-container .all-functions label{margin-left:8px;margin-bottom:20px;color:#444e69;font-size:14px}.slot-item-container .all-functions .btn-close{cursor:pointer;position:absolute;right:7px;top:7px;height:16px;width:16px;background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAB4SURBVDiNpZPLEYAgDAUXe6MuoK4UpwdBwQkQJDcyb9+QnxORCOC9jyxE4Y78DiWxAIcmISKnxaSrtZhMNSOB+ZeacAS7ngl3k1JOBSBpk1INPib0YHjH+Du2S1DhlSZOYbPJ1iLtrLKrG2a9yJopYzTD8Jx+ArgAylOzjm1WpDwAAAAASUVORK5CYII=) center no-repeat;background-size:10px 10px}.slot-item-container .all-functions .functions{display:inline-block;max-height:200px;overflow-x:hidden;overflow-y:auto}.slot-item-container .all-functions .functions::-webkit-scrollbar{width:4px}.slot-item-container .all-functions .functions::-webkit-scrollbar-track{background-color:#fff}.slot-item-container .all-functions .functions::-webkit-scrollbar-thumb{background:#787878;border-radius:25px}.slot-item-container .all-functions .function{display:flex;justify-content:space-between;white-space:nowrap;padding:5px 10px;font-size:12px;color:#787878}.slot-item-container .all-functions .function span{display:flex;align-content:center;align-items:center;margin-right:4px}.slot-item-container .all-functions .function:hover{background:#444e6933}.slot-item-container .all-functions .btn-add{cursor:pointer;width:16px;font-size:16px;text-align:center;font-style:normal}.slot-item-container .info{overflow:hidden;margin-left:-2px;margin-top:-19px;position:absolute;left:100%;top:50%;transform:translateY(-50%);width:0;display:flex;align-items:flex-start;transition:all .3s}.slot-item-container .info>img{flex:0 0 auto;width:53px;height:29px}`,Xa="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGsAAAA7CAYAAAB8MXT7AAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAGTSURBVHic7dxLbQNBEIThnigADGEhxAwcBoZgCIZgBoZgCIZgCIaQMIgZVC4daw/xXPLoqdX/3fbW0milUtfutMCdpCkiLhEx1U6CLkkvkt4k7atnQYekfR7US/Us6JB0yIOaqmfBA5JWks6SrhzUwCRN+TYdq2dBx+ygDtWzoEPSNg9qVz0LOmZBgsQ3sqUkvufqAf6SpFVEnCPiFhHr1tqteCR8hyBhYrY6OlTPgo5cHX1I2lbPgo6lBInFk3Rc+uroqXqAn8ogcc3H19bae+U8eIDEZ0LSJoMEZeHIWB2ZIPEZoCw0QVlogsRnYlYWsjoaGUHCRK6OOKiRfa2OMvWtqufBAwQJE5SFJmZl4aZ6FnSQ+Azk6mjxZeFv+/fycfbDWrTW1pSFgyLxmcjVEWXh6CgLTZD4DMzKwguro4ERJEywOjIhaUdZaIAgYYKy0ABloQkSnwlxKZUHcSmVBxKfgVwdnSgLB8d35iZIfCYoC01QFpog8Y3rftFWrotO+cilVKMiSJigLDSS30hQFhr4BEcKZN0LNhDxAAAAAElFTkSuQmCC",qs={name:"",isMobile:!1},Ka={"&":"&","<":"<",">":">",'"':""","'":"'"};function _t(n){return n==null?"":String(n).replace(/[&<>"']/g,e=>Ka[e])}function js(...n){return n.filter(Boolean).join(" ")}class Dr extends HTMLElement{constructor(e){super(),this._size=12,this._showDialog=!1,this._selected=!1,this._focused=!1,this._toBeInstalled=!1,this._toBeReplaced=!1,this._hasError=!1,this._canInstall=!1,this._hide=!1,this._disable=!1,this._filled=!1,this._allFunctions=[],this._functions=[],this._deviceName="",this._deviceLogo="",this._renderQueued=!1,this._needsRender=!0,this.attachShadow({mode:"open"}),this._props={...qs,...e??{}},this.handleShadowClick=this.handleShadowClick.bind(this),this.shadowRoot.addEventListener("click",this.handleShadowClick),this.render()}connectedCallback(){this._needsRender&&(this._needsRender=!1,this.render())}get props(){return this._props}set props(e){this._props={...qs,...e},this.scheduleRender()}get slot(){return this._slot}set slot(e){this._slot=e,this.scheduleRender()}get selected(){return this._selected}set selected(e){const t=!!e;this._selected!==t&&(this._selected=t,this.scheduleRender())}get focused(){return this._focused}set focused(e){const t=!!e;this._focused!==t&&(this._focused=t,this.scheduleRender())}get toBeInstalled(){return this._toBeInstalled}set toBeInstalled(e){const t=!!e;this._toBeInstalled!==t&&(this._toBeInstalled=t,this.scheduleRender())}get toBeReplaced(){return this._toBeReplaced}set toBeReplaced(e){const t=!!e;this._toBeReplaced!==t&&(this._toBeReplaced=t,this.scheduleRender())}get hasError(){return this._hasError}set hasError(e){const t=!!e;this._hasError!==t&&(this._hasError=t,this.scheduleRender())}get canInstall(){return this._canInstall}set canInstall(e){var s;const t=!!e,i=(s=this.shadowRoot)==null?void 0:s.querySelector(".main");i&&(e?i.classList.add("can-install"):i.classList.remove("can-install")),this._canInstall!==t&&(this._canInstall=t,this.scheduleRender())}get hide(){return this._hide}set hide(e){const t=!!e;this._hide!==t&&(this._hide=t,this.scheduleRender())}get disable(){return this._disable}set disable(e){const t=!!e;this._disable!==t&&(this._disable=t,this.scheduleRender())}get filled(){return this._filled}set filled(e){const t=!!e;this._filled!==t&&(this._filled=t,this.scheduleRender())}get allFunctions(){return[...this._allFunctions]}set allFunctions(e){this._allFunctions=Array.isArray(e)?[...e]:[],this.hasMoreFunctions||(this._showDialog=!1),this.scheduleRender()}get functions(){return[...this._functions]}set functions(e){this._functions=Array.isArray(e)?[...e]:[],this.hasMoreFunctions||(this._showDialog=!1),this.scheduleRender()}get deviceName(){return this._deviceName}set deviceName(e){this._deviceName=e??"",this.scheduleRender()}get deviceLogo(){return this._deviceLogo}set deviceLogo(e){this._deviceLogo=e??"",this.scheduleRender()}get hasMoreFunctions(){return this._allFunctions.some(e=>!this._functions.includes(e))}setSize(e=12){var s;const t=Number.isFinite(e)?Number(e):12,i=(s=this.shadowRoot)==null?void 0:s.querySelector(".main");if(i){i.style.width=i.style.height=`${e}px`;return}this._size!==t&&(this._size=t,this.scheduleRender())}removeDevice(){var e,t;this._showDialog=!1,this.scheduleRender(),(t=(e=this._props).onRemove)==null||t.call(e)}addFunction(e){this.dispatchEvent(new CustomEvent("function-added",{detail:e}))}scheduleRender(){if(!this.isConnected){this._needsRender=!0;return}this._renderQueued||(this._renderQueued=!0,queueMicrotask(()=>{this._renderQueued=!1,this.render()}))}render(){var p;if(!this.shadowRoot)return;const e=js("slot-item-container",this._props.isMobile&&"is-mobile"),t=js("main",this._selected&&"selected",this._focused&&"focus",this._toBeInstalled&&"to-be-installed",this._toBeReplaced&&"to-be-replaced",this._hasError&&"has-error",this._canInstall&&"can-install",this._hide&&"hidden",this._disable&&"disable",this._filled&&"filled"),i=this._functions.map(r=>{const l=_t(r);return`<div class="function" data-function="${l}"><span>${l}</span><i class="btn btn-remove" data-action="remove-function" data-function="${l}"></i></div>`}).join(""),s=this._allFunctions.filter(r=>!this._functions.includes(r)),a=this._allFunctions.length?`<div class="functions">${i}${`<div class="btn btn-add ${this.hasMoreFunctions?"":"btn-not-allowed"}" data-action="toggle-dialog">+添加</div>`}</div>`:"",o=s.length?`<div class="all-functions ${this._showDialog?"show":""}">
|
|
3706
|
+
*/(function(){HowlerGlobal.prototype._pos=[0,0,0],HowlerGlobal.prototype._orientation=[0,0,-1,0,1,0],HowlerGlobal.prototype.stereo=function(t){var i=this;if(!i.ctx||!i.ctx.listener)return i;for(var s=i._howls.length-1;s>=0;s--)i._howls[s].stereo(t);return i},HowlerGlobal.prototype.pos=function(t,i,s){var a=this;if(!a.ctx||!a.ctx.listener)return a;if(i=typeof i!="number"?a._pos[1]:i,s=typeof s!="number"?a._pos[2]:s,typeof t=="number")a._pos=[t,i,s],typeof a.ctx.listener.positionX<"u"?(a.ctx.listener.positionX.setTargetAtTime(a._pos[0],Howler.ctx.currentTime,.1),a.ctx.listener.positionY.setTargetAtTime(a._pos[1],Howler.ctx.currentTime,.1),a.ctx.listener.positionZ.setTargetAtTime(a._pos[2],Howler.ctx.currentTime,.1)):a.ctx.listener.setPosition(a._pos[0],a._pos[1],a._pos[2]);else return a._pos;return a},HowlerGlobal.prototype.orientation=function(t,i,s,a,o,c){var u=this;if(!u.ctx||!u.ctx.listener)return u;var f=u._orientation;if(i=typeof i!="number"?f[1]:i,s=typeof s!="number"?f[2]:s,a=typeof a!="number"?f[3]:a,o=typeof o!="number"?f[4]:o,c=typeof c!="number"?f[5]:c,typeof t=="number")u._orientation=[t,i,s,a,o,c],typeof u.ctx.listener.forwardX<"u"?(u.ctx.listener.forwardX.setTargetAtTime(t,Howler.ctx.currentTime,.1),u.ctx.listener.forwardY.setTargetAtTime(i,Howler.ctx.currentTime,.1),u.ctx.listener.forwardZ.setTargetAtTime(s,Howler.ctx.currentTime,.1),u.ctx.listener.upX.setTargetAtTime(a,Howler.ctx.currentTime,.1),u.ctx.listener.upY.setTargetAtTime(o,Howler.ctx.currentTime,.1),u.ctx.listener.upZ.setTargetAtTime(c,Howler.ctx.currentTime,.1)):u.ctx.listener.setOrientation(t,i,s,a,o,c);else return f;return u},Howl.prototype.init=function(t){return function(i){var s=this;return s._orientation=i.orientation||[1,0,0],s._stereo=i.stereo||null,s._pos=i.pos||null,s._pannerAttr={coneInnerAngle:typeof i.coneInnerAngle<"u"?i.coneInnerAngle:360,coneOuterAngle:typeof i.coneOuterAngle<"u"?i.coneOuterAngle:360,coneOuterGain:typeof i.coneOuterGain<"u"?i.coneOuterGain:0,distanceModel:typeof i.distanceModel<"u"?i.distanceModel:"inverse",maxDistance:typeof i.maxDistance<"u"?i.maxDistance:1e4,panningModel:typeof i.panningModel<"u"?i.panningModel:"HRTF",refDistance:typeof i.refDistance<"u"?i.refDistance:1,rolloffFactor:typeof i.rolloffFactor<"u"?i.rolloffFactor:1},s._onstereo=i.onstereo?[{fn:i.onstereo}]:[],s._onpos=i.onpos?[{fn:i.onpos}]:[],s._onorientation=i.onorientation?[{fn:i.onorientation}]:[],t.call(this,i)}}(Howl.prototype.init),Howl.prototype.stereo=function(t,i){var s=this;if(!s._webAudio)return s;if(s._state!=="loaded")return s._queue.push({event:"stereo",action:function(){s.stereo(t,i)}}),s;var a=typeof Howler.ctx.createStereoPanner>"u"?"spatial":"stereo";if(typeof i>"u")if(typeof t=="number")s._stereo=t,s._pos=[t,0,0];else return s._stereo;for(var o=s._getSoundIds(i),c=0;c<o.length;c++){var u=s._soundById(o[c]);if(u)if(typeof t=="number")u._stereo=t,u._pos=[t,0,0],u._node&&(u._pannerAttr.panningModel="equalpower",(!u._panner||!u._panner.pan)&&e(u,a),a==="spatial"?typeof u._panner.positionX<"u"?(u._panner.positionX.setValueAtTime(t,Howler.ctx.currentTime),u._panner.positionY.setValueAtTime(0,Howler.ctx.currentTime),u._panner.positionZ.setValueAtTime(0,Howler.ctx.currentTime)):u._panner.setPosition(t,0,0):u._panner.pan.setValueAtTime(t,Howler.ctx.currentTime)),s._emit("stereo",u._id);else return u._stereo}return s},Howl.prototype.pos=function(t,i,s,a){var o=this;if(!o._webAudio)return o;if(o._state!=="loaded")return o._queue.push({event:"pos",action:function(){o.pos(t,i,s,a)}}),o;if(i=typeof i!="number"?0:i,s=typeof s!="number"?-.5:s,typeof a>"u")if(typeof t=="number")o._pos=[t,i,s];else return o._pos;for(var c=o._getSoundIds(a),u=0;u<c.length;u++){var f=o._soundById(c[u]);if(f)if(typeof t=="number")f._pos=[t,i,s],f._node&&((!f._panner||f._panner.pan)&&e(f,"spatial"),typeof f._panner.positionX<"u"?(f._panner.positionX.setValueAtTime(t,Howler.ctx.currentTime),f._panner.positionY.setValueAtTime(i,Howler.ctx.currentTime),f._panner.positionZ.setValueAtTime(s,Howler.ctx.currentTime)):f._panner.setPosition(t,i,s)),o._emit("pos",f._id);else return f._pos}return o},Howl.prototype.orientation=function(t,i,s,a){var o=this;if(!o._webAudio)return o;if(o._state!=="loaded")return o._queue.push({event:"orientation",action:function(){o.orientation(t,i,s,a)}}),o;if(i=typeof i!="number"?o._orientation[1]:i,s=typeof s!="number"?o._orientation[2]:s,typeof a>"u")if(typeof t=="number")o._orientation=[t,i,s];else return o._orientation;for(var c=o._getSoundIds(a),u=0;u<c.length;u++){var f=o._soundById(c[u]);if(f)if(typeof t=="number")f._orientation=[t,i,s],f._node&&(f._panner||(f._pos||(f._pos=o._pos||[0,0,-.5]),e(f,"spatial")),typeof f._panner.orientationX<"u"?(f._panner.orientationX.setValueAtTime(t,Howler.ctx.currentTime),f._panner.orientationY.setValueAtTime(i,Howler.ctx.currentTime),f._panner.orientationZ.setValueAtTime(s,Howler.ctx.currentTime)):f._panner.setOrientation(t,i,s)),o._emit("orientation",f._id);else return f._orientation}return o},Howl.prototype.pannerAttr=function(){var t=this,i=arguments,s,a,o;if(!t._webAudio)return t;if(i.length===0)return t._pannerAttr;if(i.length===1)if(typeof i[0]=="object")s=i[0],typeof a>"u"&&(s.pannerAttr||(s.pannerAttr={coneInnerAngle:s.coneInnerAngle,coneOuterAngle:s.coneOuterAngle,coneOuterGain:s.coneOuterGain,distanceModel:s.distanceModel,maxDistance:s.maxDistance,refDistance:s.refDistance,rolloffFactor:s.rolloffFactor,panningModel:s.panningModel}),t._pannerAttr={coneInnerAngle:typeof s.pannerAttr.coneInnerAngle<"u"?s.pannerAttr.coneInnerAngle:t._coneInnerAngle,coneOuterAngle:typeof s.pannerAttr.coneOuterAngle<"u"?s.pannerAttr.coneOuterAngle:t._coneOuterAngle,coneOuterGain:typeof s.pannerAttr.coneOuterGain<"u"?s.pannerAttr.coneOuterGain:t._coneOuterGain,distanceModel:typeof s.pannerAttr.distanceModel<"u"?s.pannerAttr.distanceModel:t._distanceModel,maxDistance:typeof s.pannerAttr.maxDistance<"u"?s.pannerAttr.maxDistance:t._maxDistance,refDistance:typeof s.pannerAttr.refDistance<"u"?s.pannerAttr.refDistance:t._refDistance,rolloffFactor:typeof s.pannerAttr.rolloffFactor<"u"?s.pannerAttr.rolloffFactor:t._rolloffFactor,panningModel:typeof s.pannerAttr.panningModel<"u"?s.pannerAttr.panningModel:t._panningModel});else return o=t._soundById(parseInt(i[0],10)),o?o._pannerAttr:t._pannerAttr;else i.length===2&&(s=i[0],a=parseInt(i[1],10));for(var c=t._getSoundIds(a),u=0;u<c.length;u++)if(o=t._soundById(c[u]),o){var f=o._pannerAttr;f={coneInnerAngle:typeof s.coneInnerAngle<"u"?s.coneInnerAngle:f.coneInnerAngle,coneOuterAngle:typeof s.coneOuterAngle<"u"?s.coneOuterAngle:f.coneOuterAngle,coneOuterGain:typeof s.coneOuterGain<"u"?s.coneOuterGain:f.coneOuterGain,distanceModel:typeof s.distanceModel<"u"?s.distanceModel:f.distanceModel,maxDistance:typeof s.maxDistance<"u"?s.maxDistance:f.maxDistance,refDistance:typeof s.refDistance<"u"?s.refDistance:f.refDistance,rolloffFactor:typeof s.rolloffFactor<"u"?s.rolloffFactor:f.rolloffFactor,panningModel:typeof s.panningModel<"u"?s.panningModel:f.panningModel};var p=o._panner;p||(o._pos||(o._pos=t._pos||[0,0,-.5]),e(o,"spatial"),p=o._panner),p.coneInnerAngle=f.coneInnerAngle,p.coneOuterAngle=f.coneOuterAngle,p.coneOuterGain=f.coneOuterGain,p.distanceModel=f.distanceModel,p.maxDistance=f.maxDistance,p.refDistance=f.refDistance,p.rolloffFactor=f.rolloffFactor,p.panningModel=f.panningModel}return t},Sound.prototype.init=function(t){return function(){var i=this,s=i._parent;i._orientation=s._orientation,i._stereo=s._stereo,i._pos=s._pos,i._pannerAttr=s._pannerAttr,t.call(this),i._stereo?s.stereo(i._stereo):i._pos&&s.pos(i._pos[0],i._pos[1],i._pos[2],i._id)}}(Sound.prototype.init),Sound.prototype.reset=function(t){return function(){var i=this,s=i._parent;return i._orientation=s._orientation,i._stereo=s._stereo,i._pos=s._pos,i._pannerAttr=s._pannerAttr,i._stereo?s.stereo(i._stereo):i._pos?s.pos(i._pos[0],i._pos[1],i._pos[2],i._id):i._panner&&(i._panner.disconnect(0),i._panner=void 0,s._refreshBuffer(i)),t.call(this)}}(Sound.prototype.reset);var e=function(t,i){i=i||"spatial",i==="spatial"?(t._panner=Howler.ctx.createPanner(),t._panner.coneInnerAngle=t._pannerAttr.coneInnerAngle,t._panner.coneOuterAngle=t._pannerAttr.coneOuterAngle,t._panner.coneOuterGain=t._pannerAttr.coneOuterGain,t._panner.distanceModel=t._pannerAttr.distanceModel,t._panner.maxDistance=t._pannerAttr.maxDistance,t._panner.refDistance=t._pannerAttr.refDistance,t._panner.rolloffFactor=t._pannerAttr.rolloffFactor,t._panner.panningModel=t._pannerAttr.panningModel,typeof t._panner.positionX<"u"?(t._panner.positionX.setValueAtTime(t._pos[0],Howler.ctx.currentTime),t._panner.positionY.setValueAtTime(t._pos[1],Howler.ctx.currentTime),t._panner.positionZ.setValueAtTime(t._pos[2],Howler.ctx.currentTime)):t._panner.setPosition(t._pos[0],t._pos[1],t._pos[2]),typeof t._panner.orientationX<"u"?(t._panner.orientationX.setValueAtTime(t._orientation[0],Howler.ctx.currentTime),t._panner.orientationY.setValueAtTime(t._orientation[1],Howler.ctx.currentTime),t._panner.orientationZ.setValueAtTime(t._orientation[2],Howler.ctx.currentTime)):t._panner.setOrientation(t._orientation[0],t._orientation[1],t._orientation[2])):(t._panner=Howler.ctx.createStereoPanner(),t._panner.pan.setValueAtTime(t._stereo,Howler.ctx.currentTime)),t._panner.connect(t._node),t._paused||t._parent.pause(t._id,!0).play(t._id,!0)}})()})(Rr);const za="data:audio/mpeg;base64,SUQzBAAAAAAAI1RTU0UAAAAPAAADTGF2ZjU4LjQxLjEwMAAAAAAAAAAAAAAA//NwwAAAAAAAAAAAAEluZm8AAAAPAAAAFAAACOAAICAgICwsLCwsNzc3NzdDQ0NDQ09PT09PW1tbW1tmZmZmZnJycnJyfn5+fn6KioqKipWVlZWVoaGhoaGtra2trbm5ubm5xcXFxcXQ0NDQ0Nzc3Nzc6Ojo6Oj09PT09P//////AAAAAEx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E1zc+f1lPc0ZudtdFDr4LLpoSwwGkpVO+oD6Tlb3HsYL7d+R1//td2LQMNF//NAxEwTaP5xYqJMCFlqIwAbEoCJNDEp9/3itYVbV6Yx/v0nuLdzyy50qHQw3cafmKlb6zBo0yXeRMnQG5J4jE7j4PFAkTSpQ9pexojMMsL0PIqP/Z1Xp/TpnVZZ27eWtNWRSSSyWyz/80LEWRSo1nDhWhgAlsstlkskgADyNOHqG5rlhLnSyI0a5oClU7uw0JnJQq2kTMBUYADEskGQ9wdHohh2xMKnCubKTIdyRgT83NEIrcfJpJOL3fV7l9cyXXJwJRDGpJLTZJF1+3OPUX3/80DEYiVyorJfmlgDRVRdYm21rHJXTVH0+ajd35ouiSF1tVcmLGnFummxbrhsXfHNzcf/2qgd/7XhppiSaYkmmQGRpnCsAMAEB4tQrXVA0VOiINSMWfljtMTHsRdZ3iL/V1neW6zvLf/zQsQnDSAiMFXMGADWd4i6zvEX+W/yzud5ZUxBTUUzLjEwMFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVQ==";let Va=class{constructor(){this.sound=new Rr.Howl({src:[za]})}play(){this.sound.play()}};const xe=n=>{var e,t;if(typeof n.destroy=="function"){n.destroy();return}for(;n.children.length>0;)xe(n.children[0]),(e=n.children[0])==null||e.removeFromParent();if(n instanceof d.Mesh)try{(t=n.geometry)==null||t.dispose()}catch{}};function Ua(n){return new d.Vector3(n[0],n[1],n[2])}function Ha(){let n=3,e=Math.max(1/window.devicePixelRatio,.5);return window.innerWidth/window.innerHeight<.65&&(n=4,e=1/window.devicePixelRatio),{tiles:n,renderScale:e}}function Na(n){let e=!1,t=!1,i=!1,s=1/0,a=1/0,o=1/0,c=-1/0,u=-1/0,f=-1/0,p=0,r=0;return n.traverse(h=>{if(h.isMesh&&h.geometry){const g=h;if(g.userData.ignoreSize||g.material.userData.isLOGO)return;g.geometry.computeBoundingBox();let _=g.geometry.attributes.position;const m=g.geometry.morphAttributes.position;let v=g.morphTargetInfluences;const y=Object.keys(g.morphTargetDictionary||{});y.includes("width")&&(t=!0),y.includes("length")&&(e=!0),y.includes("height")&&(i=!0);for(let x=0;x<_.count;x++){let w=_.getX(x),b=_.getY(x),A=_.getZ(x);r=Math.max(b,r),m&&v&&m.forEach((I,C)=>{const P=v&&v[C]||0;w+=I.getX(x)*P,b+=I.getY(x)*P,A+=I.getZ(x)*P}),w<s&&(s=w),b<a&&(a=b),A<o&&(o=A),w>c&&(c=w),b>u&&(u=b),A>f&&(f=A);const T=Math.sqrt(w*w+b*b);T>p&&(p=T)}}}),{box:new d.Box3(new d.Vector3(s,a,o),new d.Vector3(c,u,f)),maxRadius:p,height:r,hasWidth:t,hasLength:e,hasHeight:i}}function Wa(n,e,t=null){let i=0;return function(){let s=t||this,a=arguments;clearTimeout(i),i=window.setTimeout(function(){n.apply(s,a)},e)}}class Ga{constructor(e,t,i){this.length=e,this.width=t,this.height=i}}const Ws=n=>{var i;let e=0,t=0;if(n.geometry){n.geometry.computeBoundingBox();const s=new d.Vector3;(i=n.geometry.boundingBox)==null||i.getSize(s),s.y?(t=s.y,!s.x&&s.z?e=s.z:s.x&&!s.z?e=s.x:s.x&&s.z&&(e=s.z)):(e=s.z,t=s.x)}return{width:e,height:t}};function cs(){var e;if(typeof navigator>"u")return!1;if(qa())return!0;const n=(e=navigator.userAgent)==null?void 0:e.toLowerCase();return/iphone|ipad|ipod|android|mobile|blackberry|iemobile|opera mini/.test(n)}function qa(){try{if(typeof wx<"u"&&wx.getSystemInfo||typeof my<"u"&&my.alert||typeof tt<"u"&&tt.getSystemInfo||typeof swan<"u"&&swan.getSystemInfo)return!0}catch{}return!1}const Pr=new hn.GLTFExporter,lt=new ln.GLTFLoader,ui=new cn.DRACOLoader;let st="./draco/";try{st=new URL("./draco/",typeof document>"u"?require("url").pathToFileURL(__filename).href:ot&&ot.src||new URL("shop-components.cjs",document.baseURI).href).href}catch{st="./draco/"}typeof window<"u"&&window.dracoPath&&(st=window.dracoPath);ui.setDecoderConfig({type:"wasm"});ui.setDecoderPath(st.endsWith("/")?st:`${st}/`);ui.preload();lt.setDRACOLoader(ui);const ja=new un.DRACOExporter,Gs=[115,103,108,98];function Ya(n,e,t){const i=JSON.stringify(e),s=new TextEncoder().encode(i),a=new Uint8Array([115,103,108,98]),o=new Uint8Array(2);o[0]=t>>8,o[1]=t&255;const c=new Uint8Array(4);c[0]=s.length>>24,c[1]=s.length>>16&255,c[2]=s.length>>8&255,c[3]=s.length&255;const u=new Uint8Array(n),f=a.length+o.length+c.length+s.length+u.length,p=new Uint8Array(f);let r=0;return p.set(a,r),r+=a.length,p.set(o,r),r+=o.length,p.set(c,r),r+=c.length,p.set(s,r),r+=s.length,p.set(u,r),p.buffer}function Qa(n){const e=new Uint8Array(n.slice(0,4));let t=!0;for(let r=0;r<Gs.length;r++)if(e[r]!==Gs[r]){t=!1;break}if(!t)throw new Error("Invalid file format");const s=new DataView(n,4,2).getUint16(0,!1),o=new DataView(n,6,4).getUint32(0,!1),c=new Uint8Array(n.slice(10,10+o)),u=new TextDecoder().decode(c),f=JSON.parse(u),p=n.slice(10+o);return{version:s,jsonDescription:f,glbContent:p}}class ni{constructor(e){this.props=e,this.cache=new Map}load(e,t,i,s){if(this.props.useCache&&this.cache.has(e)){t(this.cache.get(e));return}const a=this;fetch(e).then(o=>{if(!o.ok){s==null||s(new ErrorEvent("NetworkError",{message:"NetworkError for "+e+": "+o.statusText}));return}return o.arrayBuffer()}).then(async o=>{o||s==null||s(new ErrorEvent("Error",{message:"Not a valid sglb file."}));try{const c=a.parse(o);if(!c.glbContent){s==null||s(new ErrorEvent("Error",{message:"No glb content."}));return}const u=Hi(c.glbContent,"model/gltf-binary"),f=await lt.loadAsync(u);URL.revokeObjectURL(u),c.glbContent=void 0,c.glb=f.scene,o=void 0,this.cache.set(e,c),t(c)}catch(c){s==null||s(new ErrorEvent("Error",{message:c==null?void 0:c.message}))}}).catch(o=>{s==null||s(new ErrorEvent("Error",{message:o.message}))})}async loadAsync(e){if(this.props.useCache&&this.cache.has(e))return this.cache.get(e);try{const t=await fetch(e);if(!t.ok)throw new Error(`NetworkError for ${e}: ${t.statusText}`);const i=await t.arrayBuffer();if(!i)throw new Error("Not a valid sglb file.");const s=this.parse(i);if(!s.glbContent)throw new Error("No GLB content.");const a=Hi(s.glbContent,"model/gltf-binary");console.log(a);const o=await lt.loadAsync(a);return URL.revokeObjectURL(a),s.glbContent=void 0,s.glb=o.scene,this.cache.set(e,s),s}catch(t){throw t}}parse(e){return Qa(e)}clear(){[...this.cache.values()]}}const Za=`*{box-sizing:border-box}.slot-item-container.is-mobile .main{pointer-events:none;border-width:1px;opacity:.8}.slot-item-container.is-mobile .main.focus{width:18px!important;height:18px!important;border-width:2px;opacity:1}.slot-item-container.is-mobile .main.filled{opacity:1;border-width:1px;width:14px!important;height:14px!important;background-image:none;border-radius:50%}.slot-item-container.is-mobile .main.to-be-installed{opacity:1;pointer-events:auto;width:38px!important;height:38px!important;border-color:#000;border-width:1px;background-image:url("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20fill='none'%20version='1.1'%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%3e%3cg%3e%3cg%3e%3cpath%20d='M20,10.75L0,10.75L0,9.25L20,9.25L20,10.75Z'%20fill-rule='evenodd'%20fill='%23000000'%20fill-opacity='1'/%3e%3c/g%3e%3cg%20transform='matrix(0,1,1,0,10,-10)'%3e%3cpath%20d='M30,0.75L10,0.75L10,-0.75L30,-0.75L30,0.75Z'%20fill-rule='evenodd'%20fill='%23000000'%20fill-opacity='1'/%3e%3c/g%3e%3c/g%3e%3c/svg%3e");background-size:20px auto;background-repeat:no-repeat;background-position:center;background-color:#fff9}.slot-item-container.is-mobile .main.to-be-installed+.info{pointer-events:auto;overflow:visible;width:auto}.slot-item-container.is-mobile .main.to-be-installed.filled{opacity:1;border-width:2px;width:18px!important;height:18px!important;background-image:none;border-radius:50%;border-color:#00ff95}.slot-item-container.is-mobile .main.to-be-installed.to-be-replaced{opacity:1;border-width:1px;pointer-events:auto;width:38px!important;height:38px!important;border-radius:50%;background-image:url("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20fill='none'%20version='1.1'%20width='40'%20height='40'%20viewBox='0%200%2040%2040'%3e%3cdefs%3e%3cclipPath%20id='master_svg0_504_014299'%3e%3crect%20x='0'%20y='0'%20width='40'%20height='40'%20rx='20'/%3e%3c/clipPath%3e%3c/defs%3e%3cg%20clip-path='url(%23master_svg0_504_014299)'%3e%3cg%3e%3cg%3e%3cpath%20d='M31.695414,17L26.009501,10.74549544L24.899591,11.75450456L28.304586,15.5L8.75,15.5L8.75,17L31.695414,17Z'%20fill-rule='evenodd'%20fill='%23000000'%20fill-opacity='1'/%3e%3c/g%3e%3cg%3e%3cpath%20d='M8.3045862,23L13.9904997,29.2545042L15.10041,28.2454953L11.6954139,24.5L31.25,24.5L31.25,23L8.3045862,23Z'%20fill-rule='evenodd'%20fill='%23000000'%20fill-opacity='1'/%3e%3c/g%3e%3c/g%3e%3c/g%3e%3c/svg%3e");background-size:38px auto;border-color:#000}.slot-item-container.is-mobile .info{left:100%;margin-top:0;margin-left:4px}.slot-item-container.is-mobile .info .name-wrapper{margin-top:0;border-radius:0;background:#000;color:#fff}.slot-item-container.is-mobile .info>img{display:none}.slot-item-container .main{pointer-events:auto;cursor:pointer;font-size:12px;color:#fff;width:22px;height:22px;background:#fff0;border:1.5px solid #fff;border-radius:0;transition:background .2s,width .14s,height .14s,border .14s}.slot-item-container .main.disable{cursor:not-allowed}.slot-item-container .main.drag-over{border-color:red}.slot-item-container .main.can-install{position:relative;width:44px;height:44px;background:#0066ff1a;border-color:#06f}.slot-item-container .main.filled{border-color:#00ff95;border-radius:50%}.slot-item-container .main.selected{border-width:4px}.slot-item-container .main.selected+.info{pointer-events:auto;overflow:visible;width:auto}.slot-item-container .main.focus{border-color:#000}.slot-item-container .main.focus+.info{pointer-events:auto;overflow:visible;width:auto}.slot-item-container .main.has-error{border-color:red}.slot-item-container .main.hidden{display:none}.slot-item-container .main.hidden+.info{display:none}.slot-item-container .main:after{pointer-events:none;content:attr(data-name);transition:all .2s .3s;opacity:0;position:absolute;left:50%;bottom:100%;transform:translate3d(-50%,5px,0);white-space:nowrap;font-size:12px;color:#000;padding:2px 8px;border-radius:2px;background:#fff}.slot-item-container .main:hover{background:#ffffff80}.slot-item-container .main:hover+.info{pointer-events:auto;overflow:visible;width:auto}.slot-item-container .name{position:relative}.slot-item-container .name-wrapper{margin-top:-10px;white-space:nowrap;font-size:12px;color:#fff;padding:2px 8px;background:#000}.slot-item-container .functions-wrapper{z-index:20000;position:absolute;left:0;top:100%}.slot-item-container .functions-wrapper>.functions{display:inline-block;min-width:100px;padding:6px 0;border-left:1px solid #00ff95;border-radius:0 2px 2px 0;background:#0003;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px)}.slot-item-container .functions-wrapper>.functions .btn-add{cursor:pointer;padding:2px 0;margin:0 8px;display:flex;justify-content:center;align-content:center;align-items:center;border:1px dashed #eee;font-size:12px;color:#eee;border-radius:2px;-webkit-backdrop-filter:none;backdrop-filter:none;background:#00050a80}.slot-item-container .functions-wrapper>.functions .btn-add.btn-not-allowed{cursor:not-allowed}.slot-item-container .functions-wrapper>.functions .function{display:flex;justify-content:space-between;white-space:nowrap;margin-bottom:6px;padding:0 8px;font-size:12px;color:#fff}.slot-item-container .functions-wrapper>.functions .function span{margin-right:4px}.slot-item-container .functions-wrapper>.functions .function .btn-remove{pointer-events:none;opacity:0;cursor:pointer;align-self:center;margin-right:0;height:14px;width:14px;background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAACnSURBVEiJxZaxFcMgDETPTuUtWCWTM4pZAq5RojRpnOfEyEKxSnh3HySeBEhNjZJJTRgUG89GyZWilbKOgJCaKmWtFG2UvFnwQr56jYAcengg3dozELPGIjh96x6hu26/DIa9vD0jq/nUA3nikQEkAOW9nACUGbf7skxlX2mIj1Ob0jK76QdxbYpGFNlk3rPnNndDQltFaLMLbdehAyd8ZP5l6Ed+W17xG7oN9QkytAAAAABJRU5ErkJggg==) center no-repeat;background-size:10px 10px}.slot-item-container .functions-wrapper>.functions .function:hover .btn-remove{pointer-events:auto;opacity:1;transform:scale(1.2)}.slot-item-container .device-name{position:relative;margin:2px 0;display:flex;min-width:120px;align-items:center;align-content:center;justify-content:space-between;white-space:nowrap;height:30px;padding:0 8px;font-size:14px;font-weight:700;color:#000;background:#fff}.slot-item-container .device-name .device-logo{margin-left:-8px;margin-right:4px;width:30px;height:30px;object-fit:contain}.slot-item-container .device-name span{display:block;white-space:nowrap;text-overflow:ellipsis;overflow:hidden;max-width:250px}.slot-item-container .device-name .btn-close{margin-left:8px;cursor:pointer;height:20px;width:20px;background:url("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20fill='none'%20version='1.1'%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%3e%3cdefs%3e%3cclipPath%20id='master_svg0_504_017509'%3e%3crect%20x='0'%20y='0'%20width='20'%20height='20'%20rx='0'/%3e%3c/clipPath%3e%3c/defs%3e%3cg%20clip-path='url(%23master_svg0_504_017509)'%3e%3cg%3e%3cpath%20d='M4.375,16.875L4.375,4.375L15.625,4.375L15.625,16.875L4.375,16.875ZM14.375,5.625L5.625,5.625L5.625,15.625L14.375,15.625L14.375,5.625Z'%20fill-rule='evenodd'%20fill='%23999999'%20fill-opacity='1'/%3e%3c/g%3e%3cg%3e%3cpath%20d='M8.125,12.1875L8.125,8.125L9.375,8.125L9.375,12.1875L8.125,12.1875Z'%20fill-rule='evenodd'%20fill='%23999999'%20fill-opacity='1'/%3e%3c/g%3e%3cg%3e%3cpath%20d='M10.625,12.1875L10.625,8.125L11.875,8.125L11.875,12.1875L10.625,12.1875Z'%20fill-rule='evenodd'%20fill='%23999999'%20fill-opacity='1'/%3e%3c/g%3e%3cg%3e%3cpath%20d='M16.875,5.625L3.125,5.625L3.125,4.375L16.875,4.375L16.875,5.625Z'%20fill-rule='evenodd'%20fill='%23999999'%20fill-opacity='1'/%3e%3c/g%3e%3cg%3e%3cpath%20d='M6.4446528999999995,5.625L13.545177899999999,5.625L11.8665838,2.5L8.15767372,2.5L6.4446528999999995,5.625ZM11.4548223,4.3749999L8.5553472,4.3749999L8.8979512,3.75L11.1191032,3.75L11.4548223,4.3749999Z'%20fill-rule='evenodd'%20fill='%23999999'%20fill-opacity='1'/%3e%3c/g%3e%3c/g%3e%3c/svg%3e") center no-repeat;background-size:100% auto}.slot-item-container .device-name.empty{color:#000c;font-weight:400}.slot-item-container .device-name.empty .btn-close{display:none}.slot-item-container .device-name.empty:before{height:0}.slot-item-container .all-functions{opacity:0;pointer-events:none;min-width:80px;position:absolute;left:-10px;margin-left:100%;bottom:0;padding:6px 0;background:#fff;transition:all .3s}.slot-item-container .all-functions.show{opacity:1;pointer-events:auto;left:16px}.slot-item-container .all-functions label{margin-left:8px;margin-bottom:20px;color:#444e69;font-size:14px}.slot-item-container .all-functions .btn-close{cursor:pointer;position:absolute;right:7px;top:7px;height:16px;width:16px;background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAB4SURBVDiNpZPLEYAgDAUXe6MuoK4UpwdBwQkQJDcyb9+QnxORCOC9jyxE4Y78DiWxAIcmISKnxaSrtZhMNSOB+ZeacAS7ngl3k1JOBSBpk1INPib0YHjH+Du2S1DhlSZOYbPJ1iLtrLKrG2a9yJopYzTD8Jx+ArgAylOzjm1WpDwAAAAASUVORK5CYII=) center no-repeat;background-size:10px 10px}.slot-item-container .all-functions .functions{display:inline-block;max-height:200px;overflow-x:hidden;overflow-y:auto}.slot-item-container .all-functions .functions::-webkit-scrollbar{width:4px}.slot-item-container .all-functions .functions::-webkit-scrollbar-track{background-color:#fff}.slot-item-container .all-functions .functions::-webkit-scrollbar-thumb{background:#787878;border-radius:25px}.slot-item-container .all-functions .function{display:flex;justify-content:space-between;white-space:nowrap;padding:5px 10px;font-size:12px;color:#787878}.slot-item-container .all-functions .function span{display:flex;align-content:center;align-items:center;margin-right:4px}.slot-item-container .all-functions .function:hover{background:#444e6933}.slot-item-container .all-functions .btn-add{cursor:pointer;width:16px;font-size:16px;text-align:center;font-style:normal}.slot-item-container .info{overflow:hidden;margin-left:-2px;margin-top:-19px;position:absolute;left:100%;top:50%;transform:translateY(-50%);width:0;display:flex;align-items:flex-start;transition:all .3s}.slot-item-container .info>img{flex:0 0 auto;width:53px;height:29px}`,Xa="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGsAAAA7CAYAAAB8MXT7AAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAGTSURBVHic7dxLbQNBEIThnigADGEhxAwcBoZgCIZgBoZgCIZgCIaQMIgZVC4daw/xXPLoqdX/3fbW0milUtfutMCdpCkiLhEx1U6CLkkvkt4k7atnQYekfR7US/Us6JB0yIOaqmfBA5JWks6SrhzUwCRN+TYdq2dBx+ygDtWzoEPSNg9qVz0LOmZBgsQ3sqUkvufqAf6SpFVEnCPiFhHr1tqteCR8hyBhYrY6OlTPgo5cHX1I2lbPgo6lBInFk3Rc+uroqXqAn8ogcc3H19bae+U8eIDEZ0LSJoMEZeHIWB2ZIPEZoCw0QVlogsRnYlYWsjoaGUHCRK6OOKiRfa2OMvWtqufBAwQJE5SFJmZl4aZ6FnSQ+Azk6mjxZeFv+/fycfbDWrTW1pSFgyLxmcjVEWXh6CgLTZD4DMzKwguro4ERJEywOjIhaUdZaIAgYYKy0ABloQkSnwlxKZUHcSmVBxKfgVwdnSgLB8d35iZIfCYoC01QFpog8Y3rftFWrotO+cilVKMiSJigLDSS30hQFhr4BEcKZN0LNhDxAAAAAElFTkSuQmCC",qs={name:"",isMobile:!1},Ka={"&":"&","<":"<",">":">",'"':""","'":"'"};function _t(n){return n==null?"":String(n).replace(/[&<>"']/g,e=>Ka[e])}function js(...n){return n.filter(Boolean).join(" ")}class Dr extends HTMLElement{constructor(e){super(),this._size=12,this._showDialog=!1,this._selected=!1,this._focused=!1,this._toBeInstalled=!1,this._toBeReplaced=!1,this._hasError=!1,this._canInstall=!1,this._hide=!1,this._disable=!1,this._filled=!1,this._allFunctions=[],this._functions=[],this._deviceName="",this._deviceLogo="",this._renderQueued=!1,this._needsRender=!0,this.attachShadow({mode:"open"}),this._props={...qs,...e??{}},this.handleShadowClick=this.handleShadowClick.bind(this),this.shadowRoot.addEventListener("click",this.handleShadowClick),this.render()}connectedCallback(){this._needsRender&&(this._needsRender=!1,this.render())}get props(){return this._props}set props(e){this._props={...qs,...e},this.scheduleRender()}get slot(){return this._slot}set slot(e){this._slot=e,this.scheduleRender()}get selected(){return this._selected}set selected(e){const t=!!e;this._selected!==t&&(this._selected=t,this.scheduleRender())}get focused(){return this._focused}set focused(e){const t=!!e;this._focused!==t&&(this._focused=t,this.scheduleRender())}get toBeInstalled(){return this._toBeInstalled}set toBeInstalled(e){const t=!!e;this._toBeInstalled!==t&&(this._toBeInstalled=t,this.scheduleRender())}get toBeReplaced(){return this._toBeReplaced}set toBeReplaced(e){const t=!!e;this._toBeReplaced!==t&&(this._toBeReplaced=t,this.scheduleRender())}get hasError(){return this._hasError}set hasError(e){const t=!!e;this._hasError!==t&&(this._hasError=t,this.scheduleRender())}get canInstall(){return this._canInstall}set canInstall(e){var s;const t=!!e,i=(s=this.shadowRoot)==null?void 0:s.querySelector(".main");if(i){e?i.classList.add("can-install"):i.classList.remove("can-install");return}this._canInstall!==t&&(this._canInstall=t,this.scheduleRender())}get hide(){return this._hide}set hide(e){const t=!!e;this._hide!==t&&(this._hide=t,this.scheduleRender())}get disable(){return this._disable}set disable(e){const t=!!e;this._disable!==t&&(this._disable=t,this.scheduleRender())}get filled(){return this._filled}set filled(e){var s;const t=!!e,i=(s=this.shadowRoot)==null?void 0:s.querySelector(".main");if(i){e?i.classList.add("filled"):i.classList.remove("filled");return}this._filled!==t&&(this._filled=t,this.scheduleRender())}get allFunctions(){return[...this._allFunctions]}set allFunctions(e){this._allFunctions=Array.isArray(e)?[...e]:[],this.hasMoreFunctions||(this._showDialog=!1),this.scheduleRender()}get functions(){return[...this._functions]}set functions(e){this._functions=Array.isArray(e)?[...e]:[],this.hasMoreFunctions||(this._showDialog=!1),this.scheduleRender()}get deviceName(){return this._deviceName}set deviceName(e){this._deviceName=e??"",this.scheduleRender()}get deviceLogo(){return this._deviceLogo}set deviceLogo(e){this._deviceLogo=e??"",this.scheduleRender()}get hasMoreFunctions(){return this._allFunctions.some(e=>!this._functions.includes(e))}setSize(e=12){var s;const t=Number.isFinite(e)?Number(e):12,i=(s=this.shadowRoot)==null?void 0:s.querySelector(".main");if(i){i.style.width=i.style.height=`${e}px`;return}this._size!==t&&(this._size=t,this.scheduleRender())}removeDevice(){var e,t;this._showDialog=!1,this.scheduleRender(),(t=(e=this._props).onRemove)==null||t.call(e)}addFunction(e){this.dispatchEvent(new CustomEvent("function-added",{detail:e}))}scheduleRender(){if(!this.isConnected){this._needsRender=!0;return}this._renderQueued||(this._renderQueued=!0,queueMicrotask(()=>{this._renderQueued=!1,this.render()}))}render(){var p;if(!this.shadowRoot)return;const e=js("slot-item-container",this._props.isMobile&&"is-mobile"),t=js("main",this._selected&&"selected",this._focused&&"focus",this._toBeInstalled&&"to-be-installed",this._toBeReplaced&&"to-be-replaced",this._hasError&&"has-error",this._canInstall&&"can-install",this._hide&&"hidden",this._disable&&"disable",this._filled&&"filled"),i=this._functions.map(r=>{const l=_t(r);return`<div class="function" data-function="${l}"><span>${l}</span><i class="btn btn-remove" data-action="remove-function" data-function="${l}"></i></div>`}).join(""),s=this._allFunctions.filter(r=>!this._functions.includes(r)),a=this._allFunctions.length?`<div class="functions">${i}${`<div class="btn btn-add ${this.hasMoreFunctions?"":"btn-not-allowed"}" data-action="toggle-dialog">+添加</div>`}</div>`:"",o=s.length?`<div class="all-functions ${this._showDialog?"show":""}">
|
|
3707
3707
|
<label>添加功能<i class="btn btn-close" data-action="toggle-dialog"></i></label>
|
|
3708
3708
|
<div class="functions">
|
|
3709
3709
|
${s.map(r=>{const l=_t(r);return`<div class="function"><span>${l}</span><i class="btn btn-add" data-action="add-function" data-function="${l}">+</i></div>`}).join("")}
|
|
@@ -3728,7 +3728,7 @@ ${t.name}`)}break}}}}else a.texture_lod=0}};J=new WeakMap,ve=new WeakMap,ai=new
|
|
|
3728
3728
|
</div>
|
|
3729
3729
|
</div>
|
|
3730
3730
|
</div>
|
|
3731
|
-
`,this._needsRender=!1}handleShadowClick(e){const t=e.target;if(!t)return;t.closest(".info")&&(e.preventDefault(),e.stopPropagation());const i=t.closest("[data-action]");if(!i)return;const s=i.getAttribute("data-action");if(s)switch(e.preventDefault(),e.stopPropagation(),s){case"remove-device":this.removeDevice();break;case"remove-function":{const a=i.getAttribute("data-function");a&&this.dispatchEvent(new CustomEvent("function-removed",{detail:a}));break}case"toggle-dialog":if(!this.hasMoreFunctions)return;this._showDialog=!this._showDialog,this.scheduleRender();break;case"add-function":{const a=i.getAttribute("data-function");a&&(this.dispatchEvent(new CustomEvent("function-added",{detail:a})),this._showDialog=!1,this.scheduleRender());break}}}}customElements.get("slot-item")||customElements.define("slot-item",Dr);const q={ON_DROP:"slot-on-drop",ON_DEVICE_DELETED:"slot-on-device-deleted",ON_DEVICE_REPLACED:"slot-on-device-replaced",ON_BEFORE_SELECTED:"slot-on-before-selected",ON_SELECTED:"slot-on-selected",ON_ADD_BUTTON_CLICKED:"slot-add-button-clicked",ON_DEVICE_SELECTED:"slot-on-device-selected",ON_DROP_ERROR:"slot-on-drop-error",ON_ERROR_STATE_CHANGE:"slot-on-error-state-change",ON_FUNCTION_REMOVED:"slot-on-function-removed",ON_FUNCTION_ADDED:"slot-on-function-added"};class Wi extends fe.CSS2DObject{constructor(e){const t=document.createElement("div");super(t),this.props=e,this._emitter=new ct,this._slotContainer=new d.Group,this._bracketSlots=[],this._hasError=!1,this.useBracket=!1,this.addEventListener=this._emitter.addListener.bind(this._emitter),this.removeEventListener=this._emitter.removeListener.bind(this._emitter),this._canInstall=!1,this._loading=!1,this._selected=!1,this._deviceSelected=!1,this._focused=!1,this._toBeInstalled=!1,this._toBeReplaced=!1,this._allFunctions=new Set,this._functions=new Set,this._timer=0,this._parentPos=new d.Vector3,this._wrapper=new d.Group,this._showSlot=!0,this._isMirror=!1,this._preventDefaults=i=>{i.preventDefault(),i.stopPropagation()},this.getWP=this._slotContainer.getWorldPosition.bind(this._slotContainer),this._showSlot=typeof e.show=="boolean"?e.show:!0,this.name=e.name,this._isMirror=e.isMirror,this._slotUI=new Dr({name:e.name,isMobile:e.isMobile,onRemove:()=>{this.clearSlot(),this._emitter.emit(q.ON_DEVICE_DELETED)}}),this._slotUI.slot=this,this._slotUI.hide=!this._showSlot||this.isMirror,t.append(this._slotUI),this._parentPos.copy(this.props.slot.position),this._slotUI.addEventListener("function-removed",({detail:i})=>{this.removeFunction(i)}),this._slotUI.addEventListener("function-added",({detail:i})=>{this.addFunction(i)}),this.add(this._slotContainer),this.props.slot.add(this),setTimeout(()=>{var i;(i=this.props.slot.parent)==null||i.add(this._wrapper),this._wrapper.add(this.props.slot)},10),["dragenter","dragover","dragleave","drop"].forEach(i=>{t.addEventListener(i,this._preventDefaults,!1)}),t.addEventListener("click",i=>{i.preventDefault(),i.stopPropagation(),this.toBeInstalled?this._emitter.emit(q.ON_ADD_BUTTON_CLICKED):this.selected=!this.selected}),t.addEventListener("dragover",i=>{if(i.preventDefault(),i.dataTransfer.dropEffect="copy",!this._canInstall){i.dataTransfer&&(i.dataTransfer.dropEffect="none");return}}),t.addEventListener("drop",async i=>{var a;if(i.preventDefault(),i.stopPropagation(),!this._canInstall)return;const s=(a=i.dataTransfer)==null?void 0:a.getData("application/json");if(s){const o=JSON.parse(s);try{await this.install(o),this._emitter.emit(q.ON_DROP,this)}catch(c){this._emitter.emit(q.ON_DROP_ERROR,c)}}else this._emitter.emit(q.ON_DROP_ERROR,new Error("No device info"))})}get hasDevice(){return this._slotContainer.children.length>0}get isMirror(){return this._isMirror}shapeKeyChanged(e,t){var i;if(this.props.follows.has(e)){const s=this.props.follows.get(e);if(s){let a="x";["height","mast"].includes(e)?a="y":["width","liftOuterWidth"].includes(e)&&(a="z");const o=((i=this.props.slot)==null?void 0:i.position[a])>0?1:-1;this._wrapper.position[a]=(t-s.origin)*s.scale*o}}}async loadGlb(e){const i=await new ni({useCache:!0}).loadAsync(e);if(i.glb)return i.glb.clone(!0)}async installBracket(e){const i=await new ni({useCache:!0}).loadAsync(e);if(!i.glb)return;const s=i.glb.clone(!0);s.traverse(a=>{a.userData.isBracket=!0}),this.useBracket=!0,this._slotContainer.add(s)}async install(e){if(!this._loading){this._loading=!0;try{const t=await this.loadGlb(e.url);if(!t)throw new Error(`Fail to load device from: ${e.url}`);if(t.traverse(i=>{i.userData.isDevice=!0}),this.isMirror&&t.scale.set(1,1,-1),e.bracketUrl){const i=await this.loadGlb(e.bracketUrl);if(i)this.clearSlot(),this._emitter.emit(q.ON_DEVICE_REPLACED),i.traverse(s=>{s.name.startsWith("Slot")&&this._bracketSlots.push(s),s.userData.isBracket=!0}),this._slotContainer.add(i);else throw new Error(`Fail to load bracket from: ${e.bracketUrl}`);this._bracketSlots.forEach(s=>{s.add(t)})}else this.clearSlot(),this._emitter.emit(q.ON_DEVICE_REPLACED),this._slotContainer.add(t);this.mirrorTarget&&this.mirrorTarget.install(e),this.deviceInfo=e,this._slotUI.deviceLogo=e.logo||"",this._slotUI.deviceName=e.name,this._slotUI.filled=!0,this.holeTarget&&(this.holeTarget.visible=!1)}catch(t){throw t}finally{this._loading=!1}}}get device(){return this._slotContainer.children.length?this._slotContainer.children[0]:null}get allFunctions(){return[...this._allFunctions]}set allFunctions(e){this._functions.forEach(t=>{e.includes(t)||this._functions.delete(t)}),this._allFunctions=new Set(e),this._slotUI.allFunctions=e}get functions(){return[...this._functions]}addFunction(e){this._allFunctions.has(e)&&(this._functions.add(e),this._slotUI.functions=[...this.functions],this._emitter.emit(q.ON_FUNCTION_ADDED,e))}removeFunction(e){this._functions.has(e)&&(this._functions.delete(e),this._slotUI.functions=[...this.functions],this._emitter.emit(q.ON_FUNCTION_REMOVED,e))}clearFunctions(){this._functions.forEach(e=>this.removeFunction(e))}addFunctions(e){e.forEach(t=>this.addFunction(t)),this._slotUI.functions=this.functions}changeName(e){var t;this.name=e,this.props.slot.userData.name=e,this.props.name=e,(t=this.element)==null||t.setAttribute("data-name",this.props.name)}clearSlot(){this._bracketSlots=[],this._slotContainer.children.forEach(e=>{e.removeFromParent(),xe(e)}),this._slotUI.filled=!1,this.deviceInfo=void 0,this._slotUI.deviceName="",this._slotUI.deviceLogo="",this.holeTarget&&(this.holeTarget.visible=!0),this.mirrorTarget&&this.mirrorTarget.clearSlot()}get disabled(){return this._slotUI.disable}enable(){this.show(),this._slotUI.disable=!1}disable(){this._slotUI.disable=!0,this.hide()}hide(){this._slotUI.hide=!0}show(){this.isMirror||this.disabled||(this._slotUI.hide=!1)}get selected(){return this._selected}get focused(){return this._focused}set focused(e){this._focused=e,this._slotUI.focused=e}get toBeInstalled(){return this._toBeInstalled}set toBeInstalled(e){this._toBeInstalled=e,this._slotUI.toBeInstalled=e}get toBeReplaced(){return this._toBeReplaced}set toBeReplaced(e){this._toBeReplaced=e,this._slotUI.toBeReplaced=e}set selected(e){this.disabled||(e&&this._emitter.emit(q.ON_BEFORE_SELECTED,e),this._selected=e,this._slotUI.selected=e,this._emitter.emit(q.ON_SELECTED,e),this.element.style.zIndex="100",this.selected?this.renderOrder=1/0:this.renderOrder=1)}get deviceSelected(){return this._deviceSelected}set deviceSelected(e){this._deviceSelected=e,this._emitter.emit(q.ON_DEVICE_SELECTED,e)}get error(){return this._hasError}set error(e){this._loading&&setTimeout(()=>{this.error=e},100),this._hasError=e,this._slotUI.hasError=e,this._emitter.emit(q.ON_ERROR_STATE_CHANGE,e)}getCanInstall(){return this._canInstall}canInstall(e){this._canInstall=e,this._slotUI.canInstall=e}dispose(){cancelAnimationFrame(this._timer),["dragenter","dragover","dragleave","drop"].forEach(e=>{this.element.addEventListener(e,this._preventDefaults,!1)}),this.clearSlot(),this._emitter.removeAllListeners(),xe(this._slotContainer),this.element.remove()}render(e){const t=this.element.style.transform,i=/translate\(-?\d*\.?\d*%?,?\s-?\d*\.?\d*%?\)\s*translate\((-?\d*\.?\d*)px,\s*(-?\d*\.?\d*)px\)/.exec(t);if(!i)return;const s=new d.Vector2(parseFloat(i[1]),parseFloat(i[2])),a=e.mousePos.distanceTo(s);let o=this.props.isMobile?12:18,c=38,u=30;if(this._canInstall&&(o=34,c=60,u=60),a<u){let f=(u-a)*1+o;a<20&&(f=c),f>c&&(f=c),this._slotUI.setSize(f)}else this._slotUI.setSize(o)}clone(e){return new d.Group}}class Ja extends fe.CSS2DObject{constructor(e){const t=document.createElement("div");super(t),this._text=document.createElement("div");const i=cs(),s=i?"#ddd":"#eee";this.element.style.pointerEvents="auto",this.element.style.padding=i?"2px 6px":"3px 12px",this.element.style.borderTop=`1px solid ${s}`,this.element.style.borderBottom=this.element.style.borderTop;const a="6px",o=document.createElement("div");o.style.pointerEvents="none",Object.assign(o.style,{pointerEvents:"none",borderLeft:`1px solid ${s}`,borderRight:`1px solid ${s}`,position:"absolute",left:"0",top:"0",boxSizing:"border-box",height:a,width:"100%"}),this.element.append(o);const c=document.createElement("div");c.style.pointerEvents="none",Object.assign(c.style,{pointerEvents:"none",borderLeft:`1px solid ${s}`,borderRight:`1px solid ${s}`,position:"absolute",left:"0",bottom:"0",boxSizing:"border-box",height:a,width:"100%"}),this.element.append(c),this._text.style.fontSize=i?"10px":"14px",this._text.style.font="SF Pro SC,SF Pro Text,SF Pro Icons,PingFang SC,Helvetica Neue,Helvetica,Arial,sans-serif",this._text.style.color="#fff",this._text.style.fontWeight="500",this._text.style.transition="all .16s",this._text.innerText=e,this.element.append(this._text),this._text.addEventListener("pointermove",()=>{var u;o.style.borderColor=c.style.borderColor=this.element.style.borderColor="#666",this._text.style.color="#000",(u=this.onPointMove)==null||u.call(this)}),this._text.addEventListener("pointerleave",()=>{var u;o.style.borderColor=c.style.borderColor=this.element.style.borderColor=s,this._text.style.transform="scale(1)",this._text.style.color="#fff",(u=this.onPointLeave)==null||u.call(this)})}set text(e){this._text.innerText=e}dispose(){this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}}class ti extends d.Group{constructor(e,t=!0,i=!0){super(),this._startWith=e,this._showText=t,this.useStartEnd=i,this._line2Length=.01,this._line=new d.LineSegments(new d.BufferGeometry,new d.LineBasicMaterial({color:"#666",linewidth:2})),this._line2=new d.LineSegments(new d.BufferGeometry,new d.LineBasicMaterial({color:"#666",linewidth:2})),this._text=new Ja(""),this._line.frustumCulled=!1,this.add(this._line,this._line2),this._showText&&(this.add(this._text),this._text.onPointMove=()=>{this._line.material.color.set("#000"),this._line2.material.color.set("#000")},this._text.onPointLeave=()=>{this._line.material.color.set("#666"),this._line2.material.color.set("#666")})}updateMaterial(e){this._line.material=e}reset(){var e;(e=this._line.geometry)==null||e.dispose(),this._line.computeLineDistances()}update(e,t,i=0){var h,g;(h=this._line.geometry)==null||h.dispose(),this._line.geometry.setFromPoints([e,t]),this._line.computeLineDistances();const s=this._line2Length+i*.02,a=new d.Vector3().subVectors(t,e).normalize();let o;Math.abs(a.z)>Math.abs(a.x)&&Math.abs(a.z)>Math.abs(a.y)?o=new d.Vector3(-a.y,a.x,0):Math.abs(a.y)>Math.abs(a.x)?o=new d.Vector3(1,0,0):o=new d.Vector3(0,1,0),o.length()<.001&&(Math.abs(a.x)<.9?o=new d.Vector3(1,0,0):o=new d.Vector3(0,1,0)),o.normalize();const c=new d.Vector3().addVectors(e,o.clone().multiplyScalar(s)),u=new d.Vector3().addVectors(e,o.clone().multiplyScalar(-s)),f=new d.Vector3().addVectors(t,o.clone().multiplyScalar(s)),p=new d.Vector3().addVectors(t,o.clone().multiplyScalar(-s));(g=this._line2.geometry)==null||g.dispose(),this._line2.geometry=new d.BufferGeometry,this._line2.geometry.setFromPoints([c,u,f,p]),this._line2.computeLineDistances();const r=e.distanceTo(t);this._startWith?this._text.text=`${this._startWith}${(r*1e3).toFixed(0)} mm`:this._text.text=`${(r*1e3).toFixed(0)} mm`;const l=new d.Vector3;l.addVectors(e,t).multiplyScalar(.5),this._text.position.copy(l),this.useStartEnd||(this._line2.visible=!1)}destroy(){this._text.dispose(),this.children.forEach(e=>xe(e)),this.removeFromParent()}}class Lr extends d.Object3D{constructor(e,t){super(),this.radius=e,this._text=new $a(""),this._line=new ti(void 0,!1,!1),this._box=new d.Mesh,this._arc=new dn.Line2,this._previousPosition=null,this._updateTimer=null,this._updateDelay=300,this._accumulatedAngle=0,this._lastAngle=null,this._line.updateMaterial(new d.LineDashedMaterial({color:"#555",dashSize:.06,gapSize:.06})),this._line.renderOrder=0,this._box.geometry=new d.RingGeometry(e,e+.003,128),this._box.material=new d.MeshBasicMaterial({color:"#666",side:d.DoubleSide}),this._arc.geometry=new vs.LineGeometry,this._arc.geometry.setPositions([0,0,0,0,0,0]),this._arc.geometry.instanceCount=0,this._arc.material=new pn.LineMaterial({color:"#eee",linewidth:2,resolution:new d.Vector2(window.innerWidth,window.innerHeight)}),this._arc.visible=!1,this._arc.rotateX(-Math.PI/2),this.position.y=t,this._arc.position.y=.001,this.add(this._box),this.add(this._arc),this.add(this._line),this.add(this._text)}hide(){this._text.hide(),this._line.visible=!1,this._arc.visible=!1}show(){this._text.show(),this._line.visible=!0}dispose(){this._updateTimer&&(clearTimeout(this._updateTimer),this._updateTimer=null),this._box.geometry&&this._box.geometry.dispose(),this._arc.geometry&&this._arc.geometry.dispose(),this._arc.visible=!1,this._previousPosition=null}update(e){var t;this.radius=e,(t=this._box.geometry)==null||t.dispose(),this._box.geometry=new d.RingGeometry(e,e+.003,128),this._line.updateMaterial(new d.LineDashedMaterial({color:"#555",dashSize:.06*e,gapSize:.06*e})),this._text.update((e*1e3).toFixed(0))}change(e){const t=e.clone();t.setZ(0),t.normalize().multiplyScalar(this.radius),this._text.position.set(t.x,t.y,t.z),this._text.updateColor("#eee"),this._line.update(t,new d.Vector3),this._previousPosition&&this._updateArc(this._previousPosition,t),this._updateTimer&&clearTimeout(this._updateTimer),this._updateTimer=setTimeout(()=>{this._previousPosition=null,this._accumulatedAngle=0,this._lastAngle=null,this._clearArc(),this._updateTimer=null},this._updateDelay),this._previousPosition||(this._previousPosition=t.clone(),this._lastAngle=Math.atan2(t.y,t.x),this._accumulatedAngle=0)}_updateArc(e,t){const i=Math.atan2(t.y,t.x);if(this._lastAngle!==null){let u=i-this._lastAngle;u>Math.PI?u-=2*Math.PI:u<-Math.PI&&(u+=2*Math.PI),this._accumulatedAngle+=u}if(this._lastAngle=i,Math.abs(this._accumulatedAngle)<.01){this._arc.visible=!1;return}const s=Math.atan2(e.y,e.x),a=s+this._accumulatedAngle;let o=.006*this.radius;o<.003&&(o=.003),o>.006&&(o=.006);const c=this._createArcGeometry(s,a,this.radius+o);this._arc.geometry&&this._arc.geometry.dispose(),this._arc.geometry=c,this._arc.visible=!0}_clearArc(){this._text.updateColor(),this._arc.geometry&&(this._arc.geometry.setPositions([0,0,0,0,0,0]),this._arc.geometry.instanceCount=0,this._arc.computeLineDistances()),this._arc.visible=!1}_createArcGeometry(e,t,i){const s=[],a=t-e,o=Math.max(128,Math.floor(Math.abs(a)/(Math.PI/128))),c=a/o;for(let f=0;f<=o;f++){const p=e+f*c,r=Math.cos(p),l=Math.sin(p);s.push(i*r,0,i*l)}const u=new vs.LineGeometry;return u.setPositions(s),u.instanceCount=Math.max(0,s.length/3-1),u}}class $a extends fe.CSS2DObject{constructor(e){const t=document.createElement("div");super(t),this._wrapper=document.createElement("div"),this._circle=document.createElement("div");const i=cs();this._wrapper.style.fontSize=i?"10px":"11px",this._wrapper.style.color="#fff",this._wrapper.style.whiteSpace="nowrap",this._wrapper.style.position="absolute",this._wrapper.style.transform="translateX(-50%)",this._wrapper.style.top="6px",this._wrapper.style.font="SF Pro SC,SF Pro Text,SF Pro Icons,PingFang SC,Helvetica Neue,Helvetica,Arial,sans-serif";const s=this._circle;s.style.position="relative",s.style.zIndex="10",s.style.width=s.style.height="5px",s.style.borderRadius="50%",s.style.background="#666",t.append(this._wrapper,s),this.update(e)}show(){this.element.style.display="block"}hide(){this.element.style.display="none"}update(e){this._wrapper.innerText="旋转半径:"+e+" mm",this.updateColor("#eee")}updateColor(e="#666"){this._circle.style.background=e}}const el="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADgAAAAUCAYAAADY6P5TAAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAEvSURBVFiFzZdbFYMwEEQroRKQgAQkVEIlICEOkFAJlRAJSIgEJNx+sPS0nGxIaOhyv3nM7mTmwOViDHAFesADD+BqrakKQAcMwMQ3AWis9e1C3HLASJoAdNZ6sxG3/MZQMZy1dhWgFbfWRzDGlFjAwFlyyXdh5OD5OIqykBgBy1yiF0aMUQaJugLclOcEoP3nULmFgQgeyCwOoJGBYrijByspDM98ZIszJAt8Ks8dag/VUFYYLtetjHdruRz5JZf8WBg1Ae7KcgOluaSsMAKJwqgJ6Vz2WzcvhZHjVlFh1ESG1DQ67SYtyGs8OwujNpTkUtw4nVtbyLK1XDafF3aKW90Z3EpBbi5lE0u9n3qoNTKk9rHh3heZqqwA8Vw6a11VkVwuPK31HALzb5pfovYC2xSs5LCDIUcAAAAASUVORK5CYII=",tl="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAKCAYAAACngj4SAAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAChSURBVDiNrdJbFYMwEIRhJFQCEpCAhEqIhDhBAlKQgAQkIOHrSziHpmkbLvua7P4zO9s0FYUeM0b0NT2nC9FnLQho7wQ9M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eBK6qFx4caQUUrHeEEyGBfM6FB/1PIA9fh7wJIfFESKA4vuYRF8wf/fs699iAOfNWU9r3LCxc17nHBrzJDhciS4fqplKY6gMYwIlW04NXFuxfV1LlHsBS+BrHWtJnSbWkVtLfknZVVW1zjQuYit4+1Ejain1oVARGBv4OKG74taSd2PiBn3oBsVb3Jmurw36yzzW2pSIwCuABciPpkwgQLNSZgIj7QZtrbOgQGAXyAGkk/aVux1mr23F2kr5J2rLzYMr8iKVah228UVc97CR9VbeNU0EUhsCYgNDCWqvbwRr/0VZdgOzEDoZChe230SEgpMP2uxUtpkkgMCbKDxds1LWxUpjsddgJW1HGY2Qn3tzUOrRYU/XAdjlRBMaMnAkR6bidtZPU8m4O7+VrDisdt06l43Boq6raZRkgBkdgzJyHSOoXx0X1Vl018l2HxUWCBEe8Yqj9tla3DaX7O3XbTmortVQO80ZgLFCYBFKQfAz39+omgr1obS2GL0KndlLaHtJjMRjSGwuqhgUiMHDkREWyCt+3OoRJqkxa8c6yeP66xttH/5pe3/S67tS9tjtJe4IBEYGBi4UwWek4TFLF0uplhbIPj+9peQ0vhMEqfP0Uvq91/Lq0IhTwGwgMDKb3Lnalw7vY9H0tDw4dqhPpUK1IIVy0wIDxduGpWy3pD70MhpWO/1/uJP2jEA5UfxgKgYFRhQmx1vGk99F/JT6WbvverfXf3aubHJM23E+/27//wqUT6htXPk1jTeoz9//Q6UCIf9/q5X/zd/WqNXGQAkZGYKB4YaLuf43300QsvZy8+9+/9fhrzoVP+8pjMdjiY0eBRiWA0v0fPGR4m68wwtkAAAAASUVORK5CYII=";class Qs extends fe.CSS2DObject{constructor(e,t){const i=document.createElement("div");super(i),this.props=e,this.amr=t,this._direction=1,this._controllingRotate=!1,this._controlling=!1,this._startAt=0,this._looper=0,this._initial=0,this._canRotate=!1,this._emitter=new ct,this.addListener=this._emitter.addListener.bind(this._emitter),this.removeListener=this._emitter.removeListener.bind(this._emitter),this._update=()=>{if(this._looper=requestAnimationFrame(this._update),this._controlling){let c=(Date.now()-this._startAt)/200;c>4&&(c=4);let u=this._initial+.005*c*this._direction;if(u>this.props.max||u<this.props.min){this.mechanism&&(u<this.props.min?(this.mechanism.position.setZ(this.props.min),this._emitter.emit("change",this.props.min)):u>this.props.max&&(this.mechanism.position.setZ(this.props.max),this._emitter.emit("change",this.props.max)));return}if(this._initial=u,!this.mechanism)return;this.mechanism.position.setZ(u),this._emitter.emit("change",u)}};const s=cs();e.userData&&e.userData.target&&(this.name=e.userData.target.name,t.traverse(c=>{c.name===e.userData.target.name&&(this.mechanism=c)})),i.style.fontSize="30px",i.style.color="#0066FF",i.style.cursor="pointer",i.style.pointerEvents="auto";const a=document.createElement("div");a.style.position="absolute",a.style.left="0",a.style.transform="translateX(-50%) rotate(-180deg)",a.style.marginBottom="5px",a.style.width=a.style.height=s?"34px":"44px",a.style.background=`url(${Ys}) center no-repeat`,a.style.backgroundSize="100% auto",a.setAttribute("data-direction","up"),a.style.transition="all .2s";const o=document.createElement("div");if(o.style.position="absolute",o.style.left="0",o.style.transform="translateX(-50%)",a.style.bottom=o.style.top="8px",o.style.width=o.style.height=a.style.width,o.style.background=`url(${Ys}) center no-repeat`,o.style.backgroundSize="100% auto",o.style.transition="all .2s",o.setAttribute("data-direction","down"),Array.from([a,o]).forEach(c=>{s||c.addEventListener("mousemove",()=>{c.style.filter="invert(100%)"}),c.addEventListener("mouseleave",()=>{c.style.filter=""}),c.addEventListener("pointerdown",()=>{this.mechanism&&(c.style.filter="invert(100%)",this._controlling=!0,this._startAt=Date.now(),this._initial=this.mechanism.position.z,this._direction=c.getAttribute("data-direction")==="up"?1:-1,this._update())}),c.addEventListener("pointerup",()=>{this._controlling=!1,cancelAnimationFrame(this._looper),c.style.filter=""}),c.addEventListener("pointerleave",()=>{this._controlling=!1,cancelAnimationFrame(this._looper),c.style.filter=""})}),e.userData&&(this._canRotate=e.userData.canRotate,this._canRotate)){const{rotateTarget:c,rotateDuration:u,rotateStep:f,rotateMax:p,rotateMin:r}=e.userData;let l;if(c&&(t.traverse(h=>{h.name===c.name&&(l=h)}),l)){const h=document.createElement("div");h.style.background=`url(${il}) center no-repeat`,h.style.backgroundSize="100% auto",h.style.position="absolute",h.style.top="-50%",h.style.left="-50%",h.style.width=s?"140px":"160px",h.style.height=s?"70px":"80px",h.style.transform="translateX(-50%) translateY(-50%)",i.append(h);const g=document.createElement("div");g.style.background=`url(${tl}) center no-repeat`,g.style.backgroundSize="100% auto",g.style.width=g.style.height=s?"20px":"26px",g.style.position="absolute",g.style.top="0",g.style.transform="translateY(-50%)",g.style.marginBottom="5px",g.setAttribute("data-direction","left"),i.append(g);const _=document.createElement("div");_.style.background=`url(${el}) center no-repeat`,_.style.backgroundSize="100% auto",_.style.width=_.style.height=s?"20px":"26px",_.style.position="absolute",g.style.left=_.style.right=s?"62px":"69px",_.style.top="0",_.style.transform="translateY(-50%)",_.style.marginBottom="5px",_.setAttribute("data-direction","right"),i.append(_),Array.from([g,_]).forEach(m=>{s||m.addEventListener("mousemove",()=>{m.style.filter="invert(100%)"}),m.addEventListener("mouseleave",()=>{m.style.filter=""}),m.addEventListener("pointerdown",()=>{if(this._timer&&this._timer.isPlaying())return;m.style.filter="invert(100%)",this._controllingRotate=!0,this._startAt=Date.now(),this._direction=m.getAttribute("data-direction")==="left"?1:-1;let v=f/180*Math.PI*this._direction+l.rotation.z;v>p/180*Math.PI?v=p/180*Math.PI:v<r/180*Math.PI&&(v=r/180*Math.PI),this._timer=new It(l.rotation).to({z:v}).duration(u).start(),this._update()}),m.addEventListener("pointerup",()=>{this._controllingRotate=!1,cancelAnimationFrame(this._looper),m.style.filter=""}),m.addEventListener("pointerleave",()=>{this._controllingRotate=!1,cancelAnimationFrame(this._looper),m.style.filter=""})})}}i.append(a,o),this.scale.set(.01,.01,.01),this.matrixAutoUpdate=!1,this.updateMatrix()}hide(){this.element.style.display="none",this.traverse(e=>{e.visible=!1,e instanceof fe.CSS2DObject&&(e.element.style.visibility="hidden")}),this.visible=!1}show(){this.element.style.display="auto",this.traverse(e=>{e.visible=!0,e instanceof fe.CSS2DObject&&(e.element.style.visibility="visible")}),this.visible=!0}dispose(){this._emitter.removeAllListeners(),cancelAnimationFrame(this._looper),this.element.remove()}}class sl extends mn.CSS3DObject{constructor(e){const t=document.createElement("div");super(t),this.props=e,this._scale=.01,this._emitter=new ct,this.addEventListener=this._emitter.on.bind(this._emitter),this.removeEventListener=this._emitter.on.bind(this._emitter),this._mouseStart=new d.Vector2,this._targetSize=new d.Vector2,this._caches=[],this._sizeFlag="width",this._direction=1,this._lines=[],this._pointerdown=u=>{const{pageX:f,pageY:p}=u;this.endNode.setPointerCapture(u.pointerId),this._mouseStart.set(f,p),this._targetSize.setX(parseFloat(this.endNode.parentElement.style.width)),this._targetSize.setY(parseFloat(this.endNode.parentElement.style.height))},this._pointermove=u=>{if(!this._mouseStart.x)return;const{pageX:f,pageY:p}=u;let r=f-this._mouseStart.x,l=r+this._targetSize.x;this._sizeFlag==="height"&&(r=p-this._mouseStart.y,l=r*this._direction+this._targetSize.y);const h=l%10;l=l-h,r=(l-this._targetSize.x)*this._direction,this._sizeFlag==="height"&&(r=(l-this._targetSize.y)*this._direction),this._textNode.innerText=(l/100).toFixed(2)+" m",this.endNode.parentElement.style[this._sizeFlag]=`${l}px`},this._pointercancel=u=>{this.endNode.releasePointerCapture(u.pointerId),this._mouseStart.set(0,0)};const{start:i,end:s}=e,a=s.distanceTo(i);this.props.axios==="z"?this.props.axios="y":this.props.axios==="y"&&(this.props.axios="z"),this.props.axios==="y"&&(this._sizeFlag="height");const o=document.createElement("div");o.style.position="absolute",o.style.left="0",o.style.bottom="0",t.append(o),this._textNode=document.createElement("div"),this._textNode.innerText=a.toFixed(2)+" m",o.append(this._textNode);const c=document.createElement("div");this.endNode=c,c.style.position="absolute",c.style.left="auto",c.style.right="0",c.style.width="4px",c.style.height="4px",c.style.background="#0066FF",c.style.borderRadius="50%",c.style.margin="-2px -2px 0 0",c.style.cursor="pointer",o.append(c),this.scale.set(this._scale,this._scale,this._scale),t.style.fontSize="6px",t.style.color="#fff",o.style[this._sizeFlag]=a*100+"px",o.style.textAlign="center",this._sizeFlag==="height"?(o.style.borderLeft="0.1px dashed #fff",o.style.display="flex",o.style.alignItems="center",o.style.justifyContent="center",o.style.whiteSpace="nowrap",c.style.top="0",c.style.left="0",c.style.right="auto",c.style.margin="-2px 0 0 -2px"):o.style.borderBottom="0.1px dashed #fff",c.addEventListener("pointerdown",this._pointerdown),c.addEventListener("pointermove",this._pointermove),c.addEventListener("pointerup",this._pointercancel),s[this.props.axios]<i[this.props.axios]?this.rotateY(Math.PI):this._direction=-1}_getIndexByAxios(){return this.props.axios==="y"?1:this.props.axios==="z"?2:0}dispose(){this._lines.forEach(e=>e.dispose()),this._emitter.removeAllListeners(),this.endNode.removeEventListener("pointerdown",this._pointerdown),this.endNode.removeEventListener("pointermove",this._pointermove),this.endNode.removeEventListener("pointerup",this._pointercancel),this.element.remove(),this._caches.forEach(e=>e.clear()),this._caches=[]}}class rl extends d.Object3D{constructor(){super(),this._box3=new d.Box3,this._line11=new ti("长:"),this._line12=new ti("宽:"),this._line13=new ti("高:"),this._outline=new Lr(0,0),this._radius=0,this._hasWidthConfig=!1,this._hasLengthConfig=!1,this._hasHeightConfig=!1,this.follow="",this.followOrigin=0,this.followScale=1,this.originOffset=0,this.translateCache=0,this.head=0,this.tail=0,this._change=()=>{if(!this._app)return;const e=this._app.camera;e&&this._outline.change(e.position)},this.add(this._outline,this._line11,this._line12,this._line13)}get hasSizeConfig(){return{length:this._hasLengthConfig,width:this._hasWidthConfig,height:this._hasHeightConfig}}get size(){return this._box3.clone()}get radius(){return this._radius}init(e){this._app=e,this._app.controls.addEventListener("change",this._change)}reset(){this.hide(),this._line11.reset()}generate(e,t=0){e&&(this._object=e),this.update(t)}show(e=!0){const t=[this._line11,this._line12,this._line13];e&&(this.visible=!0,this._outline.visible=!0,this._outline.show(),t.push(this._outline)),t.forEach(i=>{i.traverse(s=>{s.visible=!0,s instanceof fe.CSS2DObject&&(s.element.style.visibility="visible")})})}hide(e=!0){const t=[this._line11,this._line12,this._line13];e&&(this.visible=!1,this._outline.visible=!1,this._outline.hide(),t.push(this._outline)),t.forEach(i=>{i.traverse(s=>{s.visible=!1,s instanceof fe.CSS2DObject&&(s.element.style.visibility="hidden")})})}destroy(){var e;(e=this._app)==null||e.controls.removeEventListener("change",this._change),this._line11.destroy(),this._line12.destroy(),this._line13.destroy()}update(e=0){if(!this._object)return;const t=this._object,{box:i,maxRadius:s,hasLength:a,hasHeight:o,hasWidth:c}=Na(t);this.tail=Math.abs(i.min.x),this.head=Math.abs(i.max.x),this._hasWidthConfig=c,this._hasLengthConfig=a,this._hasHeightConfig=o,this._box3.copy(i),this._radius=s,this.follow&&e&&(this.originOffset=(this.followOrigin-e)*this.followScale),this._outline.update(this._radius),this._change();const u=this._box3.min.x,f=this._box3.max.x,p=this._box3.min.z,r=this._box3.max.z,l=this._box3.min.y,h=this._box3.max.y;let g=.2;const _=new d.Vector3(u,h,0),m=new d.Vector3(f,h,0);this._line11.update(_.clone().sub(new d.Vector3(0,-g/1.8,0)),m.clone().sub(new d.Vector3(0,-g/1.8,0)),this._radius);const v=new d.Vector3(f,l,0);this._line12.update(m.clone().add(new d.Vector3(g,0,0)),v.clone().add(new d.Vector3(g,0,0)),this._radius);const y=new d.Vector3(u,h,p),x=new d.Vector3(u,h,r),w=y.clone();w.y-=g/6;const b=x.clone();b.y-=g/6,this._line13.update(w,b,this._radius)}}class Zs extends d.Object3D{constructor(e=.6,t=.4,i=.2){super(),this.isGoods=!0,this._generate(e,t,i)}updateSize(e=.1,t=.1,i=.1){this._generate(e,t,i)}clearAll(){xe(this)}hide(){this.traverse(e=>e.visible=!1)}show(){this.traverse(e=>e.visible=!0)}_generate(e,t,i){this.clearAll();const s=new d.Mesh(new d.BoxGeometry(e,t,i),new d.MeshBasicMaterial({color:new d.Color("#0f5fd5"),transparent:!0,opacity:.4}));s.geometry.translate(0,0,i/2);const a=new d.EdgesGeometry(s.geometry),o=new d.LineDashedMaterial({color:new d.Color("#000"),dashSize:.015,gapSize:.015}),c=new d.LineSegments(a,o);c.computeLineDistances(),this.add(s,c)}}const nl="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAALSURBVAiZY2AAAgAABQABYlUyiAAAAABJRU5ErkJggg==";class Gi{constructor(e){this._props=e,this.name="",this.transparentTexture=us.load(nl),this._offscreen=new OffscreenCanvas(0,0),this._defaults={...e},this.target=e.target,this.parent=this.target.parent,this.reset()}get imageSize(){return this._props.imageSize}get size(){return this._props.size}get defaultConfigs(){return{canvasWidth:200,canvasHeight:200,scaleX:1,scaleY:1,x:0,y:0,ox:0,oy:0,url:this._defaults.imageUrl}}clear(){this.change()}change(e,t=new d.Vector2(1,1),i=new d.Vector2){this.imageUrl=e;let s;if(e){const a=new Image;a.crossOrigin="anonymous",a.src=e,a.onload=async()=>{var f;let o=window.devicePixelRatio*2;this._offscreen.width=a.width+o,this._offscreen.height=a.height+o;const c=this._offscreen.getContext("2d");c==null||c.clearRect(0,0,this._offscreen.width,this._offscreen.height),c==null||c.drawImage(a,o/2,o/2,a.width,a.height),s=new d.Texture(this._offscreen),s.minFilter=1003,s.colorSpace=d.SRGBColorSpace,s.wrapS=s.wrapT=d.ClampToEdgeWrapping,s.repeat.set(1/t.x,1/t.y),s.offset.set(i.x,i.y),s.flipY=!1,s.needsUpdate=!0;const u=this._props.target;u.material&&((f=u.material.map)==null||f.dispose(),s?(u.material.map=s,u.material.opacity=1):(u.material.map=this.transparentTexture,u.material.opacity=0))}}else{const a=this._props.target;a.material&&(a.material.map=this.transparentTexture)}}reset(){this._props=this._defaults,this.name=this._props.name,this.imageUrl=this._props.imageUrl,this.target=this._props.target,this.change(this.imageUrl||"")}dispose(){this._offscreen=null}}function ol(n){return n.type?n.type==="Mesh":n.isMesh}const us=new d.TextureLoader;us.crossOrigin="anonymous";class Er extends d.Object3D{constructor(e){super(),this._props=e,this._emitter=new ct,this.addEventListener=this._emitter.addListener.bind(this._emitter),this._container=new d.Group,this.lines=new d.Group,this._clips=[],this._actionsMap=new Map,this._animationClock=new d.Clock,this.sizeBox=new rl,this._goodsSize=new Ga(0,0,0),this._slots=[],this._logos=[],this._skins=[],this._levels=new Map,this._bodyOpacity=1,this._masts=new Map,this._liftMaxHeight=0,this._jackMaxHeight=0,this._forkMaxHeight=0,this.controllers=[],this.goods=[],this._breathLights=[],this._shelves=new Map,this._shelfMaxLevel=1,this._url="",this._showController=!0,this._showSlots=!0,this._shapeKeys=new Map,this._shapeKeyTimer=0,this._shapeKeyCache="",this._materialsCache=new Map,this.opacityCache=void 0,this.actions=[],this._url=e.url||"",this._url&&this.load(this._url).then(),this.add(this._container,this.lines),this._props.showSizeBox&&this.add(this.sizeBox),this.showController=typeof e.showController=="boolean"?e.showController:!0,this._showSlots=typeof e.showSlots=="boolean"?e.showSlots:!0}get shapeKeys(){return this._shapeKeys}get size(){const e=this.sizeBox.size.getSize(new d.Vector3);return{width:e.z,length:e.x,height:e.y}}get goodsSize(){return this._goodsSize}get showController(){return this._showController}set showController(e){this._showController=e,this.controllers.forEach(t=>e?t.show():t.hide())}get slots(){return this._slots}get logos(){return this._logos}get skins(){return this._skins}get bodyOpacity(){return this._bodyOpacity}get fork(){return this._fork}get forkHeight(){var e;return((e=this._fork)==null?void 0:e.position.z)||0}get liftHeight(){var e;return((e=this._lift)==null?void 0:e.position.z)||0}get jack(){return this._jack}get jackHeight(){var e;return((e=this._jack)==null?void 0:e.position.z)||0}get lift(){return this._lift}set bodyOpacity(e){this._bodyOpacity=e,e<1?this._materialsCache.forEach(t=>{t.mat.transparent=!0,t.mat.opacity=e,t.mat.metalness=0,t.mat.roughness=1,t.mat.color=new d.Color("#3859be"),t.mat.needsUpdate=!0}):this._materialsCache.forEach(t=>{t.mat.transparent=t.transparent,t.mat.opacity=t.opacity,t.mat.metalness=t.metalness,t.mat.roughness=t.roughness,t.mat.color=t.color,t.mat.needsUpdate=!0})}init(e){this._app=e,this.sizeBox.init(e),this._onTicker&&this._app.renderer.domElement.removeEventListener("ticker",this._onTicker),this._onTicker=()=>{if(this._mixer){const t=this._animationClock.getDelta();this._mixer.update(t)}else this._animationClock.getDelta()},this._app.renderer.domElement.addEventListener("ticker",this._onTicker),this.addEventListener("shape-key-changed",(t,i)=>{this._slots.forEach(s=>s.shapeKeyChanged(t,i)),this.sizeBox.follow===t?(this.sizeBox.generate(this._container,i),this.sizeBox.originOffset&&(this._container.traverse(s=>{s instanceof d.Mesh&&!s.userData.isDevice&&!s.userData.isBracket&&s.geometry.translate(this.sizeBox.originOffset-this.sizeBox.translateCache,0,0),s instanceof Wi&&!s.props.slot.userData.ignoreOriginChanged&&s.parent&&s.parent.position.add(new d.Vector3(this.sizeBox.originOffset-this.sizeBox.translateCache,0,0))}),this.sizeBox.translateCache=this.sizeBox.originOffset,this.sizeBox.generate(this._container))):this.sizeBox.generate(this._container),["width","length","height"].includes(t)&&this._emitter.emit("size-changed",t,i)})}async load(e,t=""){this._url=e,this.name||(this.name=e.substring(e.lastIndexOf("/")+1,e.lastIndexOf("."))),!e.startsWith("blob")&&e.endsWith(".sglb");let i,s;if(t==="glb"||e.endsWith(".glb")){let o=await lt.loadAsync(e);i=o.scene,s=o.animations||[]}else{const c=await new ni({useCache:!0}).loadAsync(e);if(!c.glb)return;i=c.glb}const a=vn.clone(i);this._generateAmr(a,s),i=null,this._emitter.emit("amr-loaded")}changeSkin(e,t){e&&(e.change(t),this._app&&this._app.usePathTracing&&(this._app.sampleCount=0,this._app.usePathTracing&&(this._app.pathTracer.pausePathTracing=!1,this._app.pathTracer.updateMaterials())))}changeLogo(e,t){e.change(t.url,new d.Vector2(t.scaleX,t.scaleY),new d.Vector2(t.ox,t.oy))}setShapeKey(e,t,i=!0){i&&this._shapeKeyTimer&&e===this._shapeKeyCache&&clearTimeout(this._shapeKeyTimer),this._shapeKeyCache=e,this._shapeKeyTimer=window.setTimeout(()=>{this._container.traverse(s=>{if(!Object.keys(s.morphTargetDictionary||{}).includes(e))return;let a=t;s.userData[`origin_${e}`]&&(a-=s.userData[`origin_${e}`]);const o=s.morphTargetDictionary[e];s.morphTargetInfluences&&(s.morphTargetInfluences[o]=a),s instanceof d.Mesh&&s.geometry.translate(0,0,1e-5)}),i&&this._emitter.emit("shape-key-changed",e,t)},100)}_generateAmr(e,t){this._modelRoot=e,this._actionsMap.clear(),this.actions=[],this._clips=[],t&&t.length&&(this._mixer=new d.AnimationMixer(e),this._clips=t,t.forEach(i=>{const s=this._mixer.clipAction(i);this._actionsMap.set(i.name,s)}),this.actions=t.map(i=>i.name)),e.traverse(i=>{i.userData.isShelf&&(this._shelf=i),i.userData.isFork&&(this._fork=i),i.userData.isMast&&i.userData.mastLevel&&this._masts.set(i.userData.mastLevel,i),i.userData.isJack&&(this._jack=i),i.userData.isLift&&(this._lift=i),Object.keys(i.morphTargetDictionary||{}).forEach(s=>{let a=i.morphTargetInfluences[i.morphTargetDictionary[s]];i.userData[`origin_${s}`]&&(a+=i.userData[`origin_${s}`]),this._shapeKeys.has(s)||this._shapeKeys.set(s,a)})}),e.traverse(i=>{if(i instanceof d.Mesh){if(i.castShadow=!0,i.receiveShadow=!0,i.material)if(Array.isArray(i.material))i.material.forEach(a=>{a.userData.changeColor&&(this.skins.find(o=>o.name===a.userData.name)||this.skins.push(new es({name:a.userData.name,target:a})))});else{if(i.material.userData.isBreathLight&&i.material.emissiveIntensity){i.material.emissive||(i.material.emissive=new d.Color(16777215)),i.material.emissiveIntensity=2,i.material.toneMapped=!1;const a=1e3,o=new ye.Tween(i.material).to({emissiveIntensity:.2}).easing(ye.Easing.Quintic.InOut).duration(a),c=new ye.Tween(i.material).to({emissiveIntensity:2}).easing(ye.Easing.Quintic.InOut).duration(a);o.onComplete(()=>c.start()),c.onComplete(()=>o.start()),o.start(),this._breathLights.push(o,c)}i.material.userData.changeColor&&(this.skins.find(a=>a.name===i.material.userData.name)||this.skins.push(new es({name:i.material.userData.name,target:i.material})))}if(i.material)if(Array.isArray(i.material))i.material.forEach(o=>{if(o.userData.isLOGO){i.material.transparent=!0;let c;const u={width:0,height:0};i.material.map&&i.material.map.image&&(u.width=i.material.map.image.width,u.height=i.material.map.image.height,c=Ni(i.material.map.image));const f=new Gi({name:o.userData.name,target:i,size:Ws(i),imageSize:u,imageUrl:c});this._logos.push(f)}o.userData.isTransparent&&(o.transparent=!0),this._materialsCache.set(o.uuid,{opacity:o.opacity,transparent:o.transparent,roughness:o.roughness,metalness:o.metalness,color:o.color,mat:o})});else{const a=i.material;if(a.userData.isLOGO){i.material.transparent=!0;let o;const c={width:0,height:0};i.material.map&&i.material.map.image&&(c.width=i.material.map.image.width,c.height=i.material.map.image.height,o=Ni(i.material.map.image));const u=new Gi({name:a.userData.name,target:i,size:Ws(i),imageSize:c,imageUrl:o});this._logos.push(u)}a.userData.isTransparent&&(a.transparent=!0),this._materialsCache.set(a.uuid,{opacity:a.opacity,transparent:a.transparent,roughness:a.roughness,metalness:a.metalness,color:a.color,mat:a})}}this.generateController(i,e),this.generateDimension(i,e);const s=this.generateSlot(i,e);s&&this._slots.push(s),i.userData.isOrigin&&Object.keys(i.userData).forEach(o=>{if(o.startsWith("follow_")){const c=o.replace("follow_","");this.shapeKeys.has(c)&&(this.sizeBox.follow=c,this.sizeBox.followOrigin=this._shapeKeys.get(c)||0,this.sizeBox.followScale=i.userData[o])}})}),this.slots.forEach(i=>{i.props.mirrorTarget&&(i.mirrorTarget=this.slots.find(s=>s.props.slot.name===i.props.mirrorTarget))}),e.updateMatrixWorld(!0),this._container.add(e),this.sizeBox.generate(e),this.sizeBox.show()}setHeight(e){this.setShapeKey("height",e)}setWeight(e){this.setShapeKey("width",e)}setLength(e){this.setShapeKey("length",e)}limitValue(e){this.name==="SFL-CDD14"&&(e>1.6?this.setShapeKey("mast",1):this.setShapeKey("mast",0)),["SFL-CDD20","SFL-CDD20-Y"].includes(this.name)&&(e>1.6?this.setShapeKey("mast",1):this.setShapeKey("mast",0)),this.name==="SFL-CDD15"&&(e>2.43?this.setShapeKey("mast",1):this.setShapeKey("mast",0)),["SFL-CPD20-Y","SFL-CPD30-Y"].includes(this.name)&&(e>3.5?this.setShapeKey("mast",2):e>3?this.setShapeKey("mast",1):this.setShapeKey("mast",0))}setForkHeight(e){if(this._fork){if(e>this._forkMaxHeight&&(e=this._forkMaxHeight),this._fork.position.z=e,this._masts.size===1){const t=this._masts.get(2),i=(t==null?void 0:t.userData.startHeight)||.1;t&&(t.position.z=(e-i)*.5)}this._emitter.emit("fork-height-change",e)}}setForkMaxHeight(e){this._fork&&(this._forkMaxHeight=e,this.limitValue(e),this.controllers.forEach(t=>{t.name.toLowerCase().includes("fork")&&(t.props.max=e)}),this._fork&&this.forkHeight>this._forkMaxHeight&&this.setForkHeight(e))}setLiftHeight(e){this._lift&&(e>this._liftMaxHeight&&(e=this._liftMaxHeight),this._lift.position.z=e)}getLiftMaxHeight(){return this._liftMaxHeight}setLiftMaxHeight(e){if(!this._lift)return;this._liftMaxHeight=e,this.limitValue(e),this.controllers.forEach(a=>{a.name.toLowerCase().includes("lift")&&(a.props.max=e)}),this.liftHeight>this._liftMaxHeight&&this.setLiftHeight(e);let t=.46;this.levelOffset&&(t=this.levelOffset+.1);let i=e+t;const s=this.getShelfMinHeight()+t||0;i<s&&(i=s),this.setHeight(i)}setJackMaxHeight(e){this._jack&&(this._jackMaxHeight=e,this.limitValue(e),this.controllers.forEach(t=>{t.name.toLowerCase().includes("jack")&&(t.props.max=e)}),this.jackHeight>this._jackMaxHeight&&this.setJackHeight(e))}setJackHeight(e){this._jack&&(e>this._jackMaxHeight&&(e=this._jackMaxHeight),requestAnimationFrame(()=>{this.setShapeKey("jackHeight",e,!1)}),this._jack.position.z=e)}setLevel(e){}setGoodsSize(e){this._goodsSize.length=e.length,this._goodsSize.width=e.width,this._goodsSize.height=e.height,this.setShelfLevel(this._shelfMaxLevel)}getShelfMinHeight(){const e=this.levelOffset,t=this._shelfMaxLevel,i=this._shelves.get(0);return i?i.position.z+e*t+.1:0}getShelfMaxShelfHeight(){const e=this.levelOffset,t=this._shelfMaxLevel,i=this._shelves.get(0);if(i)return i.position.z+e*(t-1)}get levelOffset(){return this._goodsSize.height+.2}setShapeKeyToMesh(e,t,i){if(!Object.keys(e.morphTargetDictionary||{}).includes(t))return;const s=e.morphTargetDictionary[t];e.morphTargetInfluences&&(e.morphTargetInfluences[s]=i),e.geometry.translate(0,0,1e-5)}setShelfLevel(e=3){var s;if(!this._shelf)return;this._shelfMaxLevel=e;const t=this.levelOffset;this._shelves.delete(0),this._shelves.forEach(a=>{xe(a),a.parent&&a.removeFromParent()}),this.goods=[],this._shelves.clear(),this._shelves.set(0,this._shelf);for(let a=1;a<e;a++){if(!this._shelf)return;this._shelf.traverse(u=>{ol(u)&&(this.setShapeKeyToMesh(u,"goodsWidth",this._goodsSize.width),this.setShapeKeyToMesh(u,"goodsLength",this._goodsSize.length))});const o=this._shelf.clone(!0);o.position.z+=t*a,this._shelves.set(a,o),(s=this._shelf.parent)==null||s.add(o);let c;if(o.traverse(u=>{u.userData.isShelfContainer&&(c=u)}),(this.shapeKeys.has("goodsLength")||this.shapeKeys.has("goodsWidth"))&&(c==null||c.position.setX((c==null?void 0:c.position.x)-this._goodsSize.length/2)),c){const u=new Zs(this._goodsSize.length,this._goodsSize.width,this._goodsSize.height);if(c.add(u),this.goods.push(u),a===1){const f=new Zs(this._goodsSize.length,this._goodsSize.width,this._goodsSize.height);f.position.z-=t,c.add(f),this.goods.push(f)}}}const i=this.getShelfMinHeight()||0;this._liftMaxHeight<i&&this.setLiftMaxHeight(i)}generateOuterLine(){this.traverse(e=>{if(e.userData.isOuterObject){const t=this.sizeBox.radius;this._outline?this._outline.update(t):(this._outline=new Lr(t,0),this.add(this._outline))}})}generateController(e,t){if(this.showController){if(e.userData.isForkController&&e.userData.target){const i=e.userData.target.name,{min:s,max:a}=e.userData;let o;if(t.traverse(u=>{u.name===i&&(o=u)}),!o)return;const c=new Qs({name:"",target:i,default:0,min:s,max:a},o);e.add(c)}else if(e.userData.isController&&e.userData.target){const i=e.userData.target.name,{min:s,max:a}=e.userData;let o;if(t.traverse(u=>{u.name===i&&(o=u)}),!o)return;const c=new Qs({name:"",userData:e.userData,target:e.userData.key,default:0,min:s||0,max:a||1},o);e.add(c),this.controllers.push(c),(o.userData.isFork||o.userData.isLift||o.userData.isJack)&&(this._forkMaxHeight=a||1,this._liftMaxHeight=a||1,this._jackMaxHeight=a||1,c.addListener("change",u=>{this.setForkHeight(u),this.setLiftHeight(u),this.setJackHeight(u)}))}}}generateDimension(e,t){if(e.userData.isDimension){const i=e.userData.divider,s=Ua(e.userData.startOrigin),a=e.userData.axios;let o,c;if(a==="x"?(o=new d.Vector3(e.userData.start-e.position.x,0,0),c=o.clone().setX(e.userData.end-e.position.x)):a==="z"?(o=new d.Vector3(0,e.userData.start-e.position.y,0),c=o.clone().setY(e.userData.end-e.position.y)):(o=new d.Vector3(0,0,e.userData.start-e.position.z),c=o.clone().setZ(e.userData.end-e.position.z)),!Object.keys(e.userData).flatMap(r=>r.startsWith("target")?e.userData[r].name:[]).length)return;const p=new sl({start:o,end:c,startOrigin:s,axios:a,divider:i});e.add(p)}}generateSlot(e,t){var i,s;if(e.userData.isSlot){const a=e.userData.name,o=e.userData.isMirror,c=(i=e.userData.mirrorSlot)==null?void 0:i.name;if(a){const u=e.userData.holeTarget&&e.userData.holeTarget.name;let f;u&&t.traverse(h=>{h.name===u&&(f=h)});const p=new Map;Object.keys(e.userData).forEach(h=>{if(h.startsWith("follow_")){const g=h.split("_")[1];if(g){let _=e.userData[h];p.set(g,{scale:_,origin:this.shapeKeys.get(g)||0})}}});const r=(s=this._app)==null?void 0:s.props.isMobile,l=new Wi({name:a,follows:p,slot:e,show:this._showSlots,isMirror:o,mirrorTarget:c,isMobile:r});return l.holeTarget=f,l.addEventListener(q.ON_DROP,h=>{this._app&&this._app.props.useSound&&this._app.sound.play()}),l.addEventListener(q.ON_BEFORE_SELECTED,h=>{this._slots.forEach(g=>{g.selected&&(g.selected=!1)})}),l.addEventListener(q.ON_ERROR_STATE_CHANGE,h=>{if(this._app)if(this._app._outlinePassError.selectedObjects=this._app._outlinePassError.selectedObjects.filter(g=>!!g.parent),h){if(l.device){if(this._app._outlinePassError.selectedObjects.find(_=>{var m;return _.parent==((m=l.device)==null?void 0:m.parent)}))return;this._app._outlinePassError.selectedObjects=[l.device,...this._app._outlinePassError.selectedObjects]}}else l.device&&(this._app._outlinePassError.selectedObjects=this._app._outlinePassError.selectedObjects.filter(g=>{var _;return g.parent!=((_=l.device)==null?void 0:_.parent)}))}),l}}}clean(){this._emitter.removeAllListeners(),this.controllers.forEach(e=>e.dispose()),this.controllers=[],xe(this._container),this._levels.forEach(e=>e.destroy()),this._levels.clear(),this._slots=[],this._logos=[],this._skins=[],this._materialsCache.clear(),this.opacityCache=void 0,this._breathLights.forEach(e=>e.stop()),this._breathLights=[],this.sizeBox.reset(),this._mixer&&this._mixer.stopAllAction(),this._mixer=void 0,this._clips=[],this._actionsMap.clear(),this.actions=[],this._app&&this._onTicker&&this._app.renderer.domElement.removeEventListener("ticker",this._onTicker),this._onTicker=void 0}destroy(){this.clean(),this.sizeBox.destroy()}playAction(e,t=!0,i){const s=this._actionsMap.get(e);return!s||!this._mixer?Promise.reject(new Error(`Action "${e}" not found or mixer not initialized.`)):(t&&s.reset(),this._actionsMap.forEach((a,o)=>{o!==e&&a.stop()}),s.enabled=!0,s.paused=!1,s.setLoop(d.LoopOnce,0),s.setEffectiveTimeScale((i==null?void 0:i.timeScale)??1),s.setEffectiveWeight(1),s.clampWhenFinished=(i==null?void 0:i.clampWhenFinished)??!0,i!=null&&i.fadeIn&&i.fadeIn>0&&s.fadeIn(i.fadeIn),new Promise(a=>{const o=c=>{var u;c.action===s&&((u=this._mixer)==null||u.removeEventListener("finished",o),a())};this._mixer.addEventListener("finished",o),s.play()}))}pauseAction(e){const t=this._actionsMap.get(e);t&&(t.paused=!0)}}const Fr=0,al=1,ll=2,Xs=2,Ti=1.25,Ks=1,Pt=6*4+4+4,hi=65535,cl=Math.pow(2,-24),Si=Symbol("SKIP_GENERATION");function ul(n){return n.index?n.index.count:n.attributes.position.count}function ut(n){return ul(n)/3}function hl(n,e=ArrayBuffer){return n>65535?new Uint32Array(new e(4*n)):new Uint16Array(new e(2*n))}function fl(n,e){if(!n.index){const t=n.attributes.position.count,i=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,s=hl(t,i);n.setIndex(new d.BufferAttribute(s,1));for(let a=0;a<t;a++)s[a]=a}}function Br(n){const e=ut(n),t=n.drawRange,i=t.start/3,s=(t.start+t.count)/3,a=Math.max(0,i),o=Math.min(e,s)-a;return[{offset:Math.floor(a),count:Math.floor(o)}]}function kr(n){if(!n.groups||!n.groups.length)return Br(n);const e=[],t=new Set,i=n.drawRange,s=i.start/3,a=(i.start+i.count)/3;for(const c of n.groups){const u=c.start/3,f=(c.start+c.count)/3;t.add(Math.max(s,u)),t.add(Math.min(a,f))}const o=Array.from(t.values()).sort((c,u)=>c-u);for(let c=0;c<o.length-1;c++){const u=o[c],f=o[c+1];e.push({offset:Math.floor(u),count:Math.floor(f-u)})}return e}function dl(n){if(n.groups.length===0)return!1;const e=ut(n),t=kr(n).sort((a,o)=>a.offset-o.offset),i=t[t.length-1];i.count=Math.min(e-i.offset,i.count);let s=0;return t.forEach(({count:a})=>s+=a),e!==s}function Mi(n,e,t,i,s){let a=1/0,o=1/0,c=1/0,u=-1/0,f=-1/0,p=-1/0,r=1/0,l=1/0,h=1/0,g=-1/0,_=-1/0,m=-1/0;for(let v=e*6,y=(e+t)*6;v<y;v+=6){const x=n[v+0],w=n[v+1],b=x-w,A=x+w;b<a&&(a=b),A>u&&(u=A),x<r&&(r=x),x>g&&(g=x);const T=n[v+2],I=n[v+3],C=T-I,P=T+I;C<o&&(o=C),P>f&&(f=P),T<l&&(l=T),T>_&&(_=T);const D=n[v+4],S=n[v+5],M=D-S,R=D+S;M<c&&(c=M),R>p&&(p=R),D<h&&(h=D),D>m&&(m=D)}i[0]=a,i[1]=o,i[2]=c,i[3]=u,i[4]=f,i[5]=p,s[0]=r,s[1]=l,s[2]=h,s[3]=g,s[4]=_,s[5]=m}function pl(n,e=null,t=null,i=null){const s=n.attributes.position,a=n.index?n.index.array:null,o=ut(n),c=s.normalized;let u;e===null?(u=new Float32Array(o*6*4),t=0,i=o):(u=e,t=t||0,i=i||o);const f=s.array,p=s.offset||0;let r=3;s.isInterleavedBufferAttribute&&(r=s.data.stride);const l=["getX","getY","getZ"];for(let h=t;h<t+i;h++){const g=h*3,_=h*6;let m=g+0,v=g+1,y=g+2;a&&(m=a[m],v=a[v],y=a[y]),c||(m=m*r+p,v=v*r+p,y=y*r+p);for(let x=0;x<3;x++){let w,b,A;c?(w=s[l[x]](m),b=s[l[x]](v),A=s[l[x]](y)):(w=f[m+x],b=f[v+x],A=f[y+x]);let T=w;b<T&&(T=b),A<T&&(T=A);let I=w;b>I&&(I=b),A>I&&(I=A);const C=(I-T)/2,P=x*2;u[_+P+0]=T+C,u[_+P+1]=C+(Math.abs(T)+C)*cl}}return u}function N(n,e,t){return t.min.x=e[n],t.min.y=e[n+1],t.min.z=e[n+2],t.max.x=e[n+3],t.max.y=e[n+4],t.max.z=e[n+5],t}function Js(n){let e=-1,t=-1/0;for(let i=0;i<3;i++){const s=n[i+3]-n[i];s>t&&(t=s,e=i)}return e}function $s(n,e){e.set(n)}function er(n,e,t){let i,s;for(let a=0;a<3;a++){const o=a+3;i=n[a],s=e[a],t[a]=i<s?i:s,i=n[o],s=e[o],t[o]=i>s?i:s}}function Ut(n,e,t){for(let i=0;i<3;i++){const s=e[n+2*i],a=e[n+2*i+1],o=s-a,c=s+a;o<t[i]&&(t[i]=o),c>t[i+3]&&(t[i+3]=c)}}function yt(n){const e=n[3]-n[0],t=n[4]-n[1],i=n[5]-n[2];return 2*(e*t+t*i+i*e)}const me=32,ml=(n,e)=>n.candidate-e.candidate,Te=new Array(me).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),Ht=new Float32Array(6);function gl(n,e,t,i,s,a){let o=-1,c=0;if(a===Fr)o=Js(e),o!==-1&&(c=(e[o]+e[o+3])/2);else if(a===al)o=Js(n),o!==-1&&(c=vl(t,i,s,o));else if(a===ll){const u=yt(n);let f=Ti*s;const p=i*6,r=(i+s)*6;for(let l=0;l<3;l++){const h=e[l],m=(e[l+3]-h)/me;if(s<me/4){const v=[...Te];v.length=s;let y=0;for(let w=p;w<r;w+=6,y++){const b=v[y];b.candidate=t[w+2*l],b.count=0;const{bounds:A,leftCacheBounds:T,rightCacheBounds:I}=b;for(let C=0;C<3;C++)I[C]=1/0,I[C+3]=-1/0,T[C]=1/0,T[C+3]=-1/0,A[C]=1/0,A[C+3]=-1/0;Ut(w,t,A)}v.sort(ml);let x=s;for(let w=0;w<x;w++){const b=v[w];for(;w+1<x&&v[w+1].candidate===b.candidate;)v.splice(w+1,1),x--}for(let w=p;w<r;w+=6){const b=t[w+2*l];for(let A=0;A<x;A++){const T=v[A];b>=T.candidate?Ut(w,t,T.rightCacheBounds):(Ut(w,t,T.leftCacheBounds),T.count++)}}for(let w=0;w<x;w++){const b=v[w],A=b.count,T=s-b.count,I=b.leftCacheBounds,C=b.rightCacheBounds;let P=0;A!==0&&(P=yt(I)/u);let D=0;T!==0&&(D=yt(C)/u);const S=Ks+Ti*(P*A+D*T);S<f&&(o=l,f=S,c=b.candidate)}}else{for(let x=0;x<me;x++){const w=Te[x];w.count=0,w.candidate=h+m+x*m;const b=w.bounds;for(let A=0;A<3;A++)b[A]=1/0,b[A+3]=-1/0}for(let x=p;x<r;x+=6){let A=~~((t[x+2*l]-h)/m);A>=me&&(A=me-1);const T=Te[A];T.count++,Ut(x,t,T.bounds)}const v=Te[me-1];$s(v.bounds,v.rightCacheBounds);for(let x=me-2;x>=0;x--){const w=Te[x],b=Te[x+1];er(w.bounds,b.rightCacheBounds,w.rightCacheBounds)}let y=0;for(let x=0;x<me-1;x++){const w=Te[x],b=w.count,A=w.bounds,I=Te[x+1].rightCacheBounds;b!==0&&(y===0?$s(A,Ht):er(A,Ht,Ht)),y+=b;let C=0,P=0;y!==0&&(C=yt(Ht)/u);const D=s-y;D!==0&&(P=yt(I)/u);const S=Ks+Ti*(C*y+P*D);S<f&&(o=l,f=S,c=w.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${a} used.`);return{axis:o,pos:c}}function vl(n,e,t,i){let s=0;for(let a=e,o=e+t;a<o;a++)s+=n[a*6+i*2];return s/t}class Ci{constructor(){this.boundingData=new Float32Array(6)}}function _l(n,e,t,i,s,a){let o=i,c=i+s-1;const u=a.pos,f=a.axis*2;for(;;){for(;o<=c&&t[o*6+f]<u;)o++;for(;o<=c&&t[c*6+f]>=u;)c--;if(o<c){for(let p=0;p<3;p++){let r=e[o*3+p];e[o*3+p]=e[c*3+p],e[c*3+p]=r}for(let p=0;p<6;p++){let r=t[o*6+p];t[o*6+p]=t[c*6+p],t[c*6+p]=r}o++,c--}else return o}}function yl(n,e,t,i,s,a){let o=i,c=i+s-1;const u=a.pos,f=a.axis*2;for(;;){for(;o<=c&&t[o*6+f]<u;)o++;for(;o<=c&&t[c*6+f]>=u;)c--;if(o<c){let p=n[o];n[o]=n[c],n[c]=p;for(let r=0;r<6;r++){let l=t[o*6+r];t[o*6+r]=t[c*6+r],t[c*6+r]=l}o++,c--}else return o}}function K(n,e){return e[n+15]===65535}function ee(n,e){return e[n+6]}function te(n,e){return e[n+14]}function ie(n){return n+8}function se(n,e){return e[n+6]}function Or(n,e){return e[n+7]}let zr,Mt,ii,Vr;const xl=Math.pow(2,32);function qi(n){return"count"in n?1:1+qi(n.left)+qi(n.right)}function wl(n,e,t){return zr=new Float32Array(t),Mt=new Uint32Array(t),ii=new Uint16Array(t),Vr=new Uint8Array(t),ji(n,e)}function ji(n,e){const t=n/4,i=n/2,s="count"in e,a=e.boundingData;for(let o=0;o<6;o++)zr[t+o]=a[o];if(s)if(e.buffer){const o=e.buffer;Vr.set(new Uint8Array(o),n);for(let c=n,u=n+o.byteLength;c<u;c+=Pt){const f=c/2;K(f,ii)||(Mt[c/4+6]+=t)}return n+o.byteLength}else{const o=e.offset,c=e.count;return Mt[t+6]=o,ii[i+14]=c,ii[i+15]=hi,n+Pt}else{const o=e.left,c=e.right,u=e.splitAxis;let f;if(f=ji(n+Pt,o),f/4>xl)throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return Mt[t+6]=f/4,f=ji(f,c),Mt[t+7]=u,f}}function bl(n,e){const t=(n.index?n.index.count:n.attributes.position.count)/3,i=t>2**16,s=i?4:2,a=e?new SharedArrayBuffer(t*s):new ArrayBuffer(t*s),o=i?new Uint32Array(a):new Uint16Array(a);for(let c=0,u=o.length;c<u;c++)o[c]=c;return o}function Al(n,e,t,i,s){const{maxDepth:a,verbose:o,maxLeafTris:c,strategy:u,onProgress:f,indirect:p}=s,r=n._indirectBuffer,l=n.geometry,h=l.index?l.index.array:null,g=p?yl:_l,_=ut(l),m=new Float32Array(6);let v=!1;const y=new Ci;return Mi(e,t,i,y.boundingData,m),w(y,t,i,m),y;function x(b){f&&f(b/_)}function w(b,A,T,I=null,C=0){if(!v&&C>=a&&(v=!0,o&&(console.warn(`MeshBVH: Max depth of ${a} reached when generating BVH. Consider increasing maxDepth.`),console.warn(l))),T<=c||C>=a)return x(A+T),b.offset=A,b.count=T,b;const P=gl(b.boundingData,I,e,A,T,u);if(P.axis===-1)return x(A+T),b.offset=A,b.count=T,b;const D=g(r,h,e,A,T,P);if(D===A||D===A+T)x(A+T),b.offset=A,b.count=T;else{b.splitAxis=P.axis;const S=new Ci,M=A,R=D-A;b.left=S,Mi(e,M,R,S.boundingData,m),w(S,M,R,m,C+1);const E=new Ci,F=D,O=T-R;b.right=E,Mi(e,F,O,E.boundingData,m),w(E,F,O,m,C+1)}return b}}function Tl(n,e){const t=n.geometry;e.indirect&&(n._indirectBuffer=bl(t,e.useSharedArrayBuffer),dl(t)&&!e.verbose&&console.warn('MeshBVH: Provided geometry contains groups that do not fully span the vertex contents while using the "indirect" option. BVH may incorrectly report intersections on unrendered portions of the geometry.')),n._indirectBuffer||fl(t,e);const i=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,s=pl(t),a=e.indirect?Br(t):kr(t);n._roots=a.map(o=>{const c=Al(n,s,o.offset,o.count,e),u=qi(c),f=new i(Pt*u);return wl(0,c,f),f})}class we{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let i=1/0,s=-1/0;for(let a=0,o=e.length;a<o;a++){const u=e[a][t];i=u<i?u:i,s=u>s?u:s}this.min=i,this.max=s}setFromPoints(e,t){let i=1/0,s=-1/0;for(let a=0,o=t.length;a<o;a++){const c=t[a],u=e.dot(c);i=u<i?u:i,s=u>s?u:s}this.min=i,this.max=s}isSeparated(e){return this.min>e.max||e.min>this.max}}we.prototype.setFromBox=function(){const n=new d.Vector3;return function(t,i){const s=i.min,a=i.max;let o=1/0,c=-1/0;for(let u=0;u<=1;u++)for(let f=0;f<=1;f++)for(let p=0;p<=1;p++){n.x=s.x*u+a.x*(1-u),n.y=s.y*f+a.y*(1-f),n.z=s.z*p+a.z*(1-p);const r=t.dot(n);o=Math.min(r,o),c=Math.max(r,c)}this.min=o,this.max=c}}();const Sl=function(){const n=new d.Vector3,e=new d.Vector3,t=new d.Vector3;return function(s,a,o){const c=s.start,u=n,f=a.start,p=e;t.subVectors(c,f),n.subVectors(s.end,s.start),e.subVectors(a.end,a.start);const r=t.dot(p),l=p.dot(u),h=p.dot(p),g=t.dot(u),m=u.dot(u)*h-l*l;let v,y;m!==0?v=(r*l-g*h)/m:v=0,y=(r+v*l)/h,o.x=v,o.y=y}}(),hs=function(){const n=new d.Vector2,e=new d.Vector3,t=new d.Vector3;return function(s,a,o,c){Sl(s,a,n);let u=n.x,f=n.y;if(u>=0&&u<=1&&f>=0&&f<=1){s.at(u,o),a.at(f,c);return}else if(u>=0&&u<=1){f<0?a.at(0,c):a.at(1,c),s.closestPointToPoint(c,!0,o);return}else if(f>=0&&f<=1){u<0?s.at(0,o):s.at(1,o),a.closestPointToPoint(o,!0,c);return}else{let p;u<0?p=s.start:p=s.end;let r;f<0?r=a.start:r=a.end;const l=e,h=t;if(s.closestPointToPoint(r,!0,e),a.closestPointToPoint(p,!0,t),l.distanceToSquared(r)<=h.distanceToSquared(p)){o.copy(l),c.copy(r);return}else{o.copy(p),c.copy(h);return}}}}(),Ml=function(){const n=new d.Vector3,e=new d.Vector3,t=new d.Plane,i=new d.Line3;return function(a,o){const{radius:c,center:u}=a,{a:f,b:p,c:r}=o;if(i.start=f,i.end=p,i.closestPointToPoint(u,!0,n).distanceTo(u)<=c||(i.start=f,i.end=r,i.closestPointToPoint(u,!0,n).distanceTo(u)<=c)||(i.start=p,i.end=r,i.closestPointToPoint(u,!0,n).distanceTo(u)<=c))return!0;const _=o.getPlane(t);if(Math.abs(_.distanceToPoint(u))<=c){const v=_.projectPoint(u,e);if(o.containsPoint(v))return!0}return!1}}(),Cl=1e-15;function Ii(n){return Math.abs(n)<Cl}class ce extends d.Triangle{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new d.Vector3),this.satBounds=new Array(4).fill().map(()=>new we),this.points=[this.a,this.b,this.c],this.sphere=new d.Sphere,this.plane=new d.Plane,this.needsUpdate=!0}intersectsSphere(e){return Ml(e,this)}update(){const e=this.a,t=this.b,i=this.c,s=this.points,a=this.satAxes,o=this.satBounds,c=a[0],u=o[0];this.getNormal(c),u.setFromPoints(c,s);const f=a[1],p=o[1];f.subVectors(e,t),p.setFromPoints(f,s);const r=a[2],l=o[2];r.subVectors(t,i),l.setFromPoints(r,s);const h=a[3],g=o[3];h.subVectors(i,e),g.setFromPoints(h,s),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(c,e),this.needsUpdate=!1}}ce.prototype.closestPointToSegment=function(){const n=new d.Vector3,e=new d.Vector3,t=new d.Line3;return function(s,a=null,o=null){const{start:c,end:u}=s,f=this.points;let p,r=1/0;for(let l=0;l<3;l++){const h=(l+1)%3;t.start.copy(f[l]),t.end.copy(f[h]),hs(t,s,n,e),p=n.distanceToSquared(e),p<r&&(r=p,a&&a.copy(n),o&&o.copy(e))}return this.closestPointToPoint(c,n),p=c.distanceToSquared(n),p<r&&(r=p,a&&a.copy(n),o&&o.copy(c)),this.closestPointToPoint(u,n),p=u.distanceToSquared(n),p<r&&(r=p,a&&a.copy(n),o&&o.copy(u)),Math.sqrt(r)}}();ce.prototype.intersectsTriangle=function(){const n=new ce,e=new Array(3),t=new Array(3),i=new we,s=new we,a=new d.Vector3,o=new d.Vector3,c=new d.Vector3,u=new d.Vector3,f=new d.Vector3,p=new d.Line3,r=new d.Line3,l=new d.Line3,h=new d.Vector3;function g(_,m,v){const y=_.points;let x=0,w=-1;for(let b=0;b<3;b++){const{start:A,end:T}=p;A.copy(y[b]),T.copy(y[(b+1)%3]),p.delta(o);const I=Ii(m.distanceToPoint(A));if(Ii(m.normal.dot(o))&&I){v.copy(p),x=2;break}const C=m.intersectLine(p,h);if(!C&&I&&h.copy(A),(C||I)&&!Ii(h.distanceTo(T))){if(x<=1)(x===1?v.start:v.end).copy(h),I&&(w=x);else if(x>=2){(w===1?v.start:v.end).copy(h),x=2;break}if(x++,x===2&&w===-1)break}}return x}return function(m,v=null,y=!1){this.needsUpdate&&this.update(),m.isExtendedTriangle?m.needsUpdate&&m.update():(n.copy(m),n.update(),m=n);const x=this.plane,w=m.plane;if(Math.abs(x.normal.dot(w.normal))>1-1e-10){const b=this.satBounds,A=this.satAxes;t[0]=m.a,t[1]=m.b,t[2]=m.c;for(let C=0;C<4;C++){const P=b[C],D=A[C];if(i.setFromPoints(D,t),P.isSeparated(i))return!1}const T=m.satBounds,I=m.satAxes;e[0]=this.a,e[1]=this.b,e[2]=this.c;for(let C=0;C<4;C++){const P=T[C],D=I[C];if(i.setFromPoints(D,e),P.isSeparated(i))return!1}for(let C=0;C<4;C++){const P=A[C];for(let D=0;D<4;D++){const S=I[D];if(a.crossVectors(P,S),i.setFromPoints(a,e),s.setFromPoints(a,t),i.isSeparated(s))return!1}}return v&&(y||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),v.start.set(0,0,0),v.end.set(0,0,0)),!0}else{const b=g(this,w,r);if(b===1&&m.containsPoint(r.end))return v&&(v.start.copy(r.end),v.end.copy(r.end)),!0;if(b!==2)return!1;const A=g(m,x,l);if(A===1&&this.containsPoint(l.end))return v&&(v.start.copy(l.end),v.end.copy(l.end)),!0;if(A!==2)return!1;if(r.delta(c),l.delta(u),c.dot(u)<0){let M=l.start;l.start=l.end,l.end=M}const T=r.start.dot(c),I=r.end.dot(c),C=l.start.dot(c),P=l.end.dot(c),D=I<C,S=T<P;return T!==P&&C!==I&&D===S?!1:(v&&(f.subVectors(r.start,l.start),f.dot(c)>0?v.start.copy(r.start):v.start.copy(l.start),f.subVectors(r.end,l.end),f.dot(c)<0?v.end.copy(r.end):v.end.copy(l.end)),!0)}}}();ce.prototype.distanceToPoint=function(){const n=new d.Vector3;return function(t){return this.closestPointToPoint(t,n),t.distanceTo(n)}}();ce.prototype.distanceToTriangle=function(){const n=new d.Vector3,e=new d.Vector3,t=["a","b","c"],i=new d.Line3,s=new d.Line3;return function(o,c=null,u=null){const f=c||u?i:null;if(this.intersectsTriangle(o,f))return(c||u)&&(c&&f.getCenter(c),u&&f.getCenter(u)),0;let p=1/0;for(let r=0;r<3;r++){let l;const h=t[r],g=o[h];this.closestPointToPoint(g,n),l=g.distanceToSquared(n),l<p&&(p=l,c&&c.copy(n),u&&u.copy(g));const _=this[h];o.closestPointToPoint(_,n),l=_.distanceToSquared(n),l<p&&(p=l,c&&c.copy(_),u&&u.copy(n))}for(let r=0;r<3;r++){const l=t[r],h=t[(r+1)%3];i.set(this[l],this[h]);for(let g=0;g<3;g++){const _=t[g],m=t[(g+1)%3];s.set(o[_],o[m]),hs(i,s,n,e);const v=n.distanceToSquared(e);v<p&&(p=v,c&&c.copy(n),u&&u.copy(e))}}return Math.sqrt(p)}}();class Q{constructor(e,t,i){this.isOrientedBox=!0,this.min=new d.Vector3,this.max=new d.Vector3,this.matrix=new d.Matrix4,this.invMatrix=new d.Matrix4,this.points=new Array(8).fill().map(()=>new d.Vector3),this.satAxes=new Array(3).fill().map(()=>new d.Vector3),this.satBounds=new Array(3).fill().map(()=>new we),this.alignedSatBounds=new Array(3).fill().map(()=>new we),this.needsUpdate=!1,e&&this.min.copy(e),t&&this.max.copy(t),i&&this.matrix.copy(i)}set(e,t,i){this.min.copy(e),this.max.copy(t),this.matrix.copy(i),this.needsUpdate=!0}copy(e){this.min.copy(e.min),this.max.copy(e.max),this.matrix.copy(e.matrix),this.needsUpdate=!0}}Q.prototype.update=function(){return function(){const e=this.matrix,t=this.min,i=this.max,s=this.points;for(let f=0;f<=1;f++)for(let p=0;p<=1;p++)for(let r=0;r<=1;r++){const l=1*f|2*p|4*r,h=s[l];h.x=f?i.x:t.x,h.y=p?i.y:t.y,h.z=r?i.z:t.z,h.applyMatrix4(e)}const a=this.satBounds,o=this.satAxes,c=s[0];for(let f=0;f<3;f++){const p=o[f],r=a[f],l=1<<f,h=s[l];p.subVectors(c,h),r.setFromPoints(p,s)}const u=this.alignedSatBounds;u[0].setFromPointsField(s,"x"),u[1].setFromPointsField(s,"y"),u[2].setFromPointsField(s,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}();Q.prototype.intersectsBox=function(){const n=new we;return function(t){this.needsUpdate&&this.update();const i=t.min,s=t.max,a=this.satBounds,o=this.satAxes,c=this.alignedSatBounds;if(n.min=i.x,n.max=s.x,c[0].isSeparated(n)||(n.min=i.y,n.max=s.y,c[1].isSeparated(n))||(n.min=i.z,n.max=s.z,c[2].isSeparated(n)))return!1;for(let u=0;u<3;u++){const f=o[u],p=a[u];if(n.setFromBox(f,t),p.isSeparated(n))return!1}return!0}}();Q.prototype.intersectsTriangle=function(){const n=new ce,e=new Array(3),t=new we,i=new we,s=new d.Vector3;return function(o){this.needsUpdate&&this.update(),o.isExtendedTriangle?o.needsUpdate&&o.update():(n.copy(o),n.update(),o=n);const c=this.satBounds,u=this.satAxes;e[0]=o.a,e[1]=o.b,e[2]=o.c;for(let l=0;l<3;l++){const h=c[l],g=u[l];if(t.setFromPoints(g,e),h.isSeparated(t))return!1}const f=o.satBounds,p=o.satAxes,r=this.points;for(let l=0;l<3;l++){const h=f[l],g=p[l];if(t.setFromPoints(g,r),h.isSeparated(t))return!1}for(let l=0;l<3;l++){const h=u[l];for(let g=0;g<4;g++){const _=p[g];if(s.crossVectors(h,_),t.setFromPoints(s,e),i.setFromPoints(s,r),t.isSeparated(i))return!1}}return!0}}();Q.prototype.closestPointToPoint=function(){return function(e,t){return this.needsUpdate&&this.update(),t.copy(e).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),t}}();Q.prototype.distanceToPoint=function(){const n=new d.Vector3;return function(t){return this.closestPointToPoint(t,n),t.distanceTo(n)}}();Q.prototype.distanceToBox=function(){const n=["x","y","z"],e=new Array(12).fill().map(()=>new d.Line3),t=new Array(12).fill().map(()=>new d.Line3),i=new d.Vector3,s=new d.Vector3;return function(o,c=0,u=null,f=null){if(this.needsUpdate&&this.update(),this.intersectsBox(o))return(u||f)&&(o.getCenter(s),this.closestPointToPoint(s,i),o.closestPointToPoint(i,s),u&&u.copy(i),f&&f.copy(s)),0;const p=c*c,r=o.min,l=o.max,h=this.points;let g=1/0;for(let m=0;m<8;m++){const v=h[m];s.copy(v).clamp(r,l);const y=v.distanceToSquared(s);if(y<g&&(g=y,u&&u.copy(v),f&&f.copy(s),y<p))return Math.sqrt(y)}let _=0;for(let m=0;m<3;m++)for(let v=0;v<=1;v++)for(let y=0;y<=1;y++){const x=(m+1)%3,w=(m+2)%3,b=v<<x|y<<w,A=1<<m|v<<x|y<<w,T=h[b],I=h[A];e[_].set(T,I);const P=n[m],D=n[x],S=n[w],M=t[_],R=M.start,E=M.end;R[P]=r[P],R[D]=v?r[D]:l[D],R[S]=y?r[S]:l[D],E[P]=l[P],E[D]=v?r[D]:l[D],E[S]=y?r[S]:l[D],_++}for(let m=0;m<=1;m++)for(let v=0;v<=1;v++)for(let y=0;y<=1;y++){s.x=m?l.x:r.x,s.y=v?l.y:r.y,s.z=y?l.z:r.z,this.closestPointToPoint(s,i);const x=s.distanceToSquared(i);if(x<g&&(g=x,u&&u.copy(i),f&&f.copy(s),x<p))return Math.sqrt(x)}for(let m=0;m<12;m++){const v=e[m];for(let y=0;y<12;y++){const x=t[y];hs(v,x,i,s);const w=i.distanceToSquared(s);if(w<g&&(g=w,u&&u.copy(i),f&&f.copy(s),w<p))return Math.sqrt(w)}}return Math.sqrt(g)}}();class fs{constructor(e){this._getNewPrimitive=e,this._primitives=[]}getPrimitive(){const e=this._primitives;return e.length===0?this._getNewPrimitive():e.pop()}releasePrimitive(e){this._primitives.push(e)}}class Il extends fs{constructor(){super(()=>new ce)}}const re=new Il;class Rl{constructor(){this.float32Array=null,this.uint16Array=null,this.uint32Array=null;const e=[];let t=null;this.setBuffer=i=>{t&&e.push(t),t=i,this.float32Array=new Float32Array(i),this.uint16Array=new Uint16Array(i),this.uint32Array=new Uint32Array(i)},this.clearBuffer=()=>{t=null,this.float32Array=null,this.uint16Array=null,this.uint32Array=null,e.length!==0&&this.setBuffer(e.pop())}}}const U=new Rl;let Re,et;const He=[],Nt=new fs(()=>new d.Box3);function Pl(n,e,t,i,s,a){Re=Nt.getPrimitive(),et=Nt.getPrimitive(),He.push(Re,et),U.setBuffer(n._roots[e]);const o=Yi(0,n.geometry,t,i,s,a);U.clearBuffer(),Nt.releasePrimitive(Re),Nt.releasePrimitive(et),He.pop(),He.pop();const c=He.length;return c>0&&(et=He[c-1],Re=He[c-2]),o}function Yi(n,e,t,i,s=null,a=0,o=0){const{float32Array:c,uint16Array:u,uint32Array:f}=U;let p=n*2;if(K(p,u)){const l=ee(n,f),h=te(p,u);return N(n,c,Re),i(l,h,!1,o,a+n,Re)}else{let P=function(S){const{uint16Array:M,uint32Array:R}=U;let E=S*2;for(;!K(E,M);)S=ie(S),E=S*2;return ee(S,R)},D=function(S){const{uint16Array:M,uint32Array:R}=U;let E=S*2;for(;!K(E,M);)S=se(S,R),E=S*2;return ee(S,R)+te(E,M)};const l=ie(n),h=se(n,f);let g=l,_=h,m,v,y,x;if(s&&(y=Re,x=et,N(g,c,y),N(_,c,x),m=s(y),v=s(x),v<m)){g=h,_=l;const S=m;m=v,v=S,y=x}y||(y=Re,N(g,c,y));const w=K(g*2,u),b=t(y,w,m,o+1,a+g);let A;if(b===Xs){const S=P(g),R=D(g)-S;A=i(S,R,!0,o+1,a+g,y)}else A=b&&Yi(g,e,t,i,s,a,o+1);if(A)return!0;x=et,N(_,c,x);const T=K(_*2,u),I=t(x,T,v,o+1,a+_);let C;if(I===Xs){const S=P(_),R=D(_)-S;C=i(S,R,!0,o+1,a+_,x)}else C=I&&Yi(_,e,t,i,s,a,o+1);return!!C}}const xt=new d.Vector3,Ri=new d.Vector3;function Dl(n,e,t={},i=0,s=1/0){const a=i*i,o=s*s;let c=1/0,u=null;if(n.shapecast({boundsTraverseOrder:p=>(xt.copy(e).clamp(p.min,p.max),xt.distanceToSquared(e)),intersectsBounds:(p,r,l)=>l<c&&l<o,intersectsTriangle:(p,r)=>{p.closestPointToPoint(e,xt);const l=e.distanceToSquared(xt);return l<c&&(Ri.copy(xt),c=l,u=r),l<a}}),c===1/0)return null;const f=Math.sqrt(c);return t.point?t.point.copy(Ri):t.point=Ri.clone(),t.distance=f,t.faceIndex=u,t}const Ne=new d.Vector3,We=new d.Vector3,Ge=new d.Vector3,Wt=new d.Vector2,Gt=new d.Vector2,qt=new d.Vector2,tr=new d.Vector3,ir=new d.Vector3,sr=new d.Vector3,jt=new d.Vector3;function Ll(n,e,t,i,s,a,o,c){let u;if(a===d.BackSide?u=n.intersectTriangle(i,t,e,!0,s):u=n.intersectTriangle(e,t,i,a!==d.DoubleSide,s),u===null)return null;const f=n.origin.distanceTo(s);return f<o||f>c?null:{distance:f,point:s.clone()}}function El(n,e,t,i,s,a,o,c,u,f,p){Ne.fromBufferAttribute(e,a),We.fromBufferAttribute(e,o),Ge.fromBufferAttribute(e,c);const r=Ll(n,Ne,We,Ge,jt,u,f,p);if(r){i&&(Wt.fromBufferAttribute(i,a),Gt.fromBufferAttribute(i,o),qt.fromBufferAttribute(i,c),r.uv=d.Triangle.getInterpolation(jt,Ne,We,Ge,Wt,Gt,qt,new d.Vector2)),s&&(Wt.fromBufferAttribute(s,a),Gt.fromBufferAttribute(s,o),qt.fromBufferAttribute(s,c),r.uv1=d.Triangle.getInterpolation(jt,Ne,We,Ge,Wt,Gt,qt,new d.Vector2)),t&&(tr.fromBufferAttribute(t,a),ir.fromBufferAttribute(t,o),sr.fromBufferAttribute(t,c),r.normal=d.Triangle.getInterpolation(jt,Ne,We,Ge,tr,ir,sr,new d.Vector3),r.normal.dot(n.direction)>0&&r.normal.multiplyScalar(-1));const l={a,b:o,c,normal:new d.Vector3,materialIndex:0};d.Triangle.getNormal(Ne,We,Ge,l.normal),r.face=l,r.faceIndex=a}return r}function fi(n,e,t,i,s,a,o){const c=i*3;let u=c+0,f=c+1,p=c+2;const r=n.index;n.index&&(u=r.getX(u),f=r.getX(f),p=r.getX(p));const{position:l,normal:h,uv:g,uv1:_}=n.attributes,m=El(t,l,h,g,_,u,f,p,e,a,o);return m?(m.faceIndex=i,s&&s.push(m),m):null}function G(n,e,t,i){const s=n.a,a=n.b,o=n.c;let c=e,u=e+1,f=e+2;t&&(c=t.getX(c),u=t.getX(u),f=t.getX(f)),s.x=i.getX(c),s.y=i.getY(c),s.z=i.getZ(c),a.x=i.getX(u),a.y=i.getY(u),a.z=i.getZ(u),o.x=i.getX(f),o.y=i.getY(f),o.z=i.getZ(f)}function Fl(n,e,t,i,s,a,o,c){const{geometry:u,_indirectBuffer:f}=n;for(let p=i,r=i+s;p<r;p++)fi(u,e,t,p,a,o,c)}function Bl(n,e,t,i,s,a,o){const{geometry:c,_indirectBuffer:u}=n;let f=1/0,p=null;for(let r=i,l=i+s;r<l;r++){let h;h=fi(c,e,t,r,null,a,o),h&&h.distance<f&&(p=h,f=h.distance)}return p}function kl(n,e,t,i,s,a,o){const{geometry:c}=t,{index:u}=c,f=c.attributes.position;for(let p=n,r=e+n;p<r;p++){let l;if(l=p,G(o,l*3,u,f),o.needsUpdate=!0,i(o,l,s,a))return!0}return!1}function Ol(n,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=n.geometry,i=t.index?t.index.array:null,s=t.attributes.position;let a,o,c,u,f=0;const p=n._roots;for(let l=0,h=p.length;l<h;l++)a=p[l],o=new Uint32Array(a),c=new Uint16Array(a),u=new Float32Array(a),r(0,f),f+=a.byteLength;function r(l,h,g=!1){const _=l*2;if(c[_+15]===hi){const v=o[l+6],y=c[_+14];let x=1/0,w=1/0,b=1/0,A=-1/0,T=-1/0,I=-1/0;for(let C=3*v,P=3*(v+y);C<P;C++){let D=i[C];const S=s.getX(D),M=s.getY(D),R=s.getZ(D);S<x&&(x=S),S>A&&(A=S),M<w&&(w=M),M>T&&(T=M),R<b&&(b=R),R>I&&(I=R)}return u[l+0]!==x||u[l+1]!==w||u[l+2]!==b||u[l+3]!==A||u[l+4]!==T||u[l+5]!==I?(u[l+0]=x,u[l+1]=w,u[l+2]=b,u[l+3]=A,u[l+4]=T,u[l+5]=I,!0):!1}else{const v=l+8,y=o[l+6],x=v+h,w=y+h;let b=g,A=!1,T=!1;e?b||(A=e.has(x),T=e.has(w),b=!A&&!T):(A=!0,T=!0);const I=b||A,C=b||T;let P=!1;I&&(P=r(v,h,b));let D=!1;C&&(D=r(y,h,b));const S=P||D;if(S)for(let M=0;M<3;M++){const R=v+M,E=y+M,F=u[R],O=u[R+3],H=u[E],W=u[E+3];u[l+M]=F<H?F:H,u[l+M+3]=O>W?O:W}return S}}}function Pe(n,e,t,i,s){let a,o,c,u,f,p;const r=1/t.direction.x,l=1/t.direction.y,h=1/t.direction.z,g=t.origin.x,_=t.origin.y,m=t.origin.z;let v=e[n],y=e[n+3],x=e[n+1],w=e[n+3+1],b=e[n+2],A=e[n+3+2];return r>=0?(a=(v-g)*r,o=(y-g)*r):(a=(y-g)*r,o=(v-g)*r),l>=0?(c=(x-_)*l,u=(w-_)*l):(c=(w-_)*l,u=(x-_)*l),a>u||c>o||((c>a||isNaN(a))&&(a=c),(u<o||isNaN(o))&&(o=u),h>=0?(f=(b-m)*h,p=(A-m)*h):(f=(A-m)*h,p=(b-m)*h),a>p||f>o)?!1:((f>a||a!==a)&&(a=f),(p<o||o!==o)&&(o=p),a<=s&&o>=i)}function zl(n,e,t,i,s,a,o,c){const{geometry:u,_indirectBuffer:f}=n;for(let p=i,r=i+s;p<r;p++){let l=f?f[p]:p;fi(u,e,t,l,a,o,c)}}function Vl(n,e,t,i,s,a,o){const{geometry:c,_indirectBuffer:u}=n;let f=1/0,p=null;for(let r=i,l=i+s;r<l;r++){let h;h=fi(c,e,t,u?u[r]:r,null,a,o),h&&h.distance<f&&(p=h,f=h.distance)}return p}function Ul(n,e,t,i,s,a,o){const{geometry:c}=t,{index:u}=c,f=c.attributes.position;for(let p=n,r=e+n;p<r;p++){let l;if(l=t.resolveTriangleIndex(p),G(o,l*3,u,f),o.needsUpdate=!0,i(o,l,s,a))return!0}return!1}function Hl(n,e,t,i,s,a,o){U.setBuffer(n._roots[e]),Qi(0,n,t,i,s,a,o),U.clearBuffer()}function Qi(n,e,t,i,s,a,o){const{float32Array:c,uint16Array:u,uint32Array:f}=U,p=n*2;if(K(p,u)){const l=ee(n,f),h=te(p,u);Fl(e,t,i,l,h,s,a,o)}else{const l=ie(n);Pe(l,c,i,a,o)&&Qi(l,e,t,i,s,a,o);const h=se(n,f);Pe(h,c,i,a,o)&&Qi(h,e,t,i,s,a,o)}}const Nl=["x","y","z"];function Wl(n,e,t,i,s,a){U.setBuffer(n._roots[e]);const o=Zi(0,n,t,i,s,a);return U.clearBuffer(),o}function Zi(n,e,t,i,s,a){const{float32Array:o,uint16Array:c,uint32Array:u}=U;let f=n*2;if(K(f,c)){const r=ee(n,u),l=te(f,c);return Bl(e,t,i,r,l,s,a)}else{const r=Or(n,u),l=Nl[r],g=i.direction[l]>=0;let _,m;g?(_=ie(n),m=se(n,u)):(_=se(n,u),m=ie(n));const y=Pe(_,o,i,s,a)?Zi(_,e,t,i,s,a):null;if(y){const b=y.point[l];if(g?b<=o[m+r]:b>=o[m+r+3])return y}const w=Pe(m,o,i,s,a)?Zi(m,e,t,i,s,a):null;return y&&w?y.distance<=w.distance?y:w:y||w||null}}const Yt=new d.Box3,qe=new ce,je=new ce,wt=new d.Matrix4,rr=new Q,Qt=new Q;function Gl(n,e,t,i){U.setBuffer(n._roots[e]);const s=Xi(0,n,t,i);return U.clearBuffer(),s}function Xi(n,e,t,i,s=null){const{float32Array:a,uint16Array:o,uint32Array:c}=U;let u=n*2;if(s===null&&(t.boundingBox||t.computeBoundingBox(),rr.set(t.boundingBox.min,t.boundingBox.max,i),s=rr),K(u,o)){const p=e.geometry,r=p.index,l=p.attributes.position,h=t.index,g=t.attributes.position,_=ee(n,c),m=te(u,o);if(wt.copy(i).invert(),t.boundsTree)return N(n,a,Qt),Qt.matrix.copy(wt),Qt.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:y=>Qt.intersectsBox(y),intersectsTriangle:y=>{y.a.applyMatrix4(i),y.b.applyMatrix4(i),y.c.applyMatrix4(i),y.needsUpdate=!0;for(let x=_*3,w=(m+_)*3;x<w;x+=3)if(G(je,x,r,l),je.needsUpdate=!0,y.intersectsTriangle(je))return!0;return!1}});for(let v=_*3,y=(m+_)*3;v<y;v+=3){G(qe,v,r,l),qe.a.applyMatrix4(wt),qe.b.applyMatrix4(wt),qe.c.applyMatrix4(wt),qe.needsUpdate=!0;for(let x=0,w=h.count;x<w;x+=3)if(G(je,x,h,g),je.needsUpdate=!0,qe.intersectsTriangle(je))return!0}}else{const p=n+8,r=c[n+6];return N(p,a,Yt),!!(s.intersectsBox(Yt)&&Xi(p,e,t,i,s)||(N(r,a,Yt),s.intersectsBox(Yt)&&Xi(r,e,t,i,s)))}}const Zt=new d.Matrix4,Pi=new Q,bt=new Q,ql=new d.Vector3,jl=new d.Vector3,Yl=new d.Vector3,Ql=new d.Vector3;function Zl(n,e,t,i={},s={},a=0,o=1/0){e.boundingBox||e.computeBoundingBox(),Pi.set(e.boundingBox.min,e.boundingBox.max,t),Pi.needsUpdate=!0;const c=n.geometry,u=c.attributes.position,f=c.index,p=e.attributes.position,r=e.index,l=re.getPrimitive(),h=re.getPrimitive();let g=ql,_=jl,m=null,v=null;s&&(m=Yl,v=Ql);let y=1/0,x=null,w=null;return Zt.copy(t).invert(),bt.matrix.copy(Zt),n.shapecast({boundsTraverseOrder:b=>Pi.distanceToBox(b),intersectsBounds:(b,A,T)=>T<y&&T<o?(A&&(bt.min.copy(b.min),bt.max.copy(b.max),bt.needsUpdate=!0),!0):!1,intersectsRange:(b,A)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:I=>bt.distanceToBox(I),intersectsBounds:(I,C,P)=>P<y&&P<o,intersectsRange:(I,C)=>{for(let P=I,D=I+C;P<D;P++){G(h,3*P,r,p),h.a.applyMatrix4(t),h.b.applyMatrix4(t),h.c.applyMatrix4(t),h.needsUpdate=!0;for(let S=b,M=b+A;S<M;S++){G(l,3*S,f,u),l.needsUpdate=!0;const R=l.distanceToTriangle(h,g,m);if(R<y&&(_.copy(g),v&&v.copy(m),y=R,x=S,w=P),R<a)return!0}}}});{const T=ut(e);for(let I=0,C=T;I<C;I++){G(h,3*I,r,p),h.a.applyMatrix4(t),h.b.applyMatrix4(t),h.c.applyMatrix4(t),h.needsUpdate=!0;for(let P=b,D=b+A;P<D;P++){G(l,3*P,f,u),l.needsUpdate=!0;const S=l.distanceToTriangle(h,g,m);if(S<y&&(_.copy(g),v&&v.copy(m),y=S,x=P,w=I),S<a)return!0}}}}}),re.releasePrimitive(l),re.releasePrimitive(h),y===1/0?null:(i.point?i.point.copy(_):i.point=_.clone(),i.distance=y,i.faceIndex=x,s&&(s.point?s.point.copy(v):s.point=v.clone(),s.point.applyMatrix4(Zt),_.applyMatrix4(Zt),s.distance=_.sub(s.point).length(),s.faceIndex=w),i)}function Xl(n,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=n.geometry,i=t.index?t.index.array:null,s=t.attributes.position;let a,o,c,u,f=0;const p=n._roots;for(let l=0,h=p.length;l<h;l++)a=p[l],o=new Uint32Array(a),c=new Uint16Array(a),u=new Float32Array(a),r(0,f),f+=a.byteLength;function r(l,h,g=!1){const _=l*2;if(c[_+15]===hi){const v=o[l+6],y=c[_+14];let x=1/0,w=1/0,b=1/0,A=-1/0,T=-1/0,I=-1/0;for(let C=v,P=v+y;C<P;C++){const D=3*n.resolveTriangleIndex(C);for(let S=0;S<3;S++){let M=D+S;M=i?i[M]:M;const R=s.getX(M),E=s.getY(M),F=s.getZ(M);R<x&&(x=R),R>A&&(A=R),E<w&&(w=E),E>T&&(T=E),F<b&&(b=F),F>I&&(I=F)}}return u[l+0]!==x||u[l+1]!==w||u[l+2]!==b||u[l+3]!==A||u[l+4]!==T||u[l+5]!==I?(u[l+0]=x,u[l+1]=w,u[l+2]=b,u[l+3]=A,u[l+4]=T,u[l+5]=I,!0):!1}else{const v=l+8,y=o[l+6],x=v+h,w=y+h;let b=g,A=!1,T=!1;e?b||(A=e.has(x),T=e.has(w),b=!A&&!T):(A=!0,T=!0);const I=b||A,C=b||T;let P=!1;I&&(P=r(v,h,b));let D=!1;C&&(D=r(y,h,b));const S=P||D;if(S)for(let M=0;M<3;M++){const R=v+M,E=y+M,F=u[R],O=u[R+3],H=u[E],W=u[E+3];u[l+M]=F<H?F:H,u[l+M+3]=O>W?O:W}return S}}}function Kl(n,e,t,i,s,a,o){U.setBuffer(n._roots[e]),Ki(0,n,t,i,s,a,o),U.clearBuffer()}function Ki(n,e,t,i,s,a,o){const{float32Array:c,uint16Array:u,uint32Array:f}=U,p=n*2;if(K(p,u)){const l=ee(n,f),h=te(p,u);zl(e,t,i,l,h,s,a,o)}else{const l=ie(n);Pe(l,c,i,a,o)&&Ki(l,e,t,i,s,a,o);const h=se(n,f);Pe(h,c,i,a,o)&&Ki(h,e,t,i,s,a,o)}}const Jl=["x","y","z"];function $l(n,e,t,i,s,a){U.setBuffer(n._roots[e]);const o=Ji(0,n,t,i,s,a);return U.clearBuffer(),o}function Ji(n,e,t,i,s,a){const{float32Array:o,uint16Array:c,uint32Array:u}=U;let f=n*2;if(K(f,c)){const r=ee(n,u),l=te(f,c);return Vl(e,t,i,r,l,s,a)}else{const r=Or(n,u),l=Jl[r],g=i.direction[l]>=0;let _,m;g?(_=ie(n),m=se(n,u)):(_=se(n,u),m=ie(n));const y=Pe(_,o,i,s,a)?Ji(_,e,t,i,s,a):null;if(y){const b=y.point[l];if(g?b<=o[m+r]:b>=o[m+r+3])return y}const w=Pe(m,o,i,s,a)?Ji(m,e,t,i,s,a):null;return y&&w?y.distance<=w.distance?y:w:y||w||null}}const Xt=new d.Box3,Ye=new ce,Qe=new ce,At=new d.Matrix4,nr=new Q,Kt=new Q;function ec(n,e,t,i){U.setBuffer(n._roots[e]);const s=$i(0,n,t,i);return U.clearBuffer(),s}function $i(n,e,t,i,s=null){const{float32Array:a,uint16Array:o,uint32Array:c}=U;let u=n*2;if(s===null&&(t.boundingBox||t.computeBoundingBox(),nr.set(t.boundingBox.min,t.boundingBox.max,i),s=nr),K(u,o)){const p=e.geometry,r=p.index,l=p.attributes.position,h=t.index,g=t.attributes.position,_=ee(n,c),m=te(u,o);if(At.copy(i).invert(),t.boundsTree)return N(n,a,Kt),Kt.matrix.copy(At),Kt.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:y=>Kt.intersectsBox(y),intersectsTriangle:y=>{y.a.applyMatrix4(i),y.b.applyMatrix4(i),y.c.applyMatrix4(i),y.needsUpdate=!0;for(let x=_,w=m+_;x<w;x++)if(G(Qe,3*e.resolveTriangleIndex(x),r,l),Qe.needsUpdate=!0,y.intersectsTriangle(Qe))return!0;return!1}});for(let v=_,y=m+_;v<y;v++){const x=e.resolveTriangleIndex(v);G(Ye,3*x,r,l),Ye.a.applyMatrix4(At),Ye.b.applyMatrix4(At),Ye.c.applyMatrix4(At),Ye.needsUpdate=!0;for(let w=0,b=h.count;w<b;w+=3)if(G(Qe,w,h,g),Qe.needsUpdate=!0,Ye.intersectsTriangle(Qe))return!0}}else{const p=n+8,r=c[n+6];return N(p,a,Xt),!!(s.intersectsBox(Xt)&&$i(p,e,t,i,s)||(N(r,a,Xt),s.intersectsBox(Xt)&&$i(r,e,t,i,s)))}}const Jt=new d.Matrix4,Di=new Q,Tt=new Q,tc=new d.Vector3,ic=new d.Vector3,sc=new d.Vector3,rc=new d.Vector3;function nc(n,e,t,i={},s={},a=0,o=1/0){e.boundingBox||e.computeBoundingBox(),Di.set(e.boundingBox.min,e.boundingBox.max,t),Di.needsUpdate=!0;const c=n.geometry,u=c.attributes.position,f=c.index,p=e.attributes.position,r=e.index,l=re.getPrimitive(),h=re.getPrimitive();let g=tc,_=ic,m=null,v=null;s&&(m=sc,v=rc);let y=1/0,x=null,w=null;return Jt.copy(t).invert(),Tt.matrix.copy(Jt),n.shapecast({boundsTraverseOrder:b=>Di.distanceToBox(b),intersectsBounds:(b,A,T)=>T<y&&T<o?(A&&(Tt.min.copy(b.min),Tt.max.copy(b.max),Tt.needsUpdate=!0),!0):!1,intersectsRange:(b,A)=>{if(e.boundsTree){const T=e.boundsTree;return T.shapecast({boundsTraverseOrder:I=>Tt.distanceToBox(I),intersectsBounds:(I,C,P)=>P<y&&P<o,intersectsRange:(I,C)=>{for(let P=I,D=I+C;P<D;P++){const S=T.resolveTriangleIndex(P);G(h,3*S,r,p),h.a.applyMatrix4(t),h.b.applyMatrix4(t),h.c.applyMatrix4(t),h.needsUpdate=!0;for(let M=b,R=b+A;M<R;M++){const E=n.resolveTriangleIndex(M);G(l,3*E,f,u),l.needsUpdate=!0;const F=l.distanceToTriangle(h,g,m);if(F<y&&(_.copy(g),v&&v.copy(m),y=F,x=M,w=P),F<a)return!0}}}})}else{const T=ut(e);for(let I=0,C=T;I<C;I++){G(h,3*I,r,p),h.a.applyMatrix4(t),h.b.applyMatrix4(t),h.c.applyMatrix4(t),h.needsUpdate=!0;for(let P=b,D=b+A;P<D;P++){const S=n.resolveTriangleIndex(P);G(l,3*S,f,u),l.needsUpdate=!0;const M=l.distanceToTriangle(h,g,m);if(M<y&&(_.copy(g),v&&v.copy(m),y=M,x=P,w=I),M<a)return!0}}}}}),re.releasePrimitive(l),re.releasePrimitive(h),y===1/0?null:(i.point?i.point.copy(_):i.point=_.clone(),i.distance=y,i.faceIndex=x,s&&(s.point?s.point.copy(v):s.point=v.clone(),s.point.applyMatrix4(Jt),_.applyMatrix4(Jt),s.distance=_.sub(s.point).length(),s.faceIndex=w),i)}function oc(){return typeof SharedArrayBuffer<"u"}const Dt=new U.constructor,oi=new U.constructor,Me=new fs(()=>new d.Box3),Ze=new d.Box3,Xe=new d.Box3,Li=new d.Box3,Ei=new d.Box3;let Fi=!1;function ac(n,e,t,i){if(Fi)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");Fi=!0;const s=n._roots,a=e._roots;let o,c=0,u=0;const f=new d.Matrix4().copy(t).invert();for(let p=0,r=s.length;p<r;p++){Dt.setBuffer(s[p]),u=0;const l=Me.getPrimitive();N(0,Dt.float32Array,l),l.applyMatrix4(f);for(let h=0,g=a.length;h<g&&(oi.setBuffer(a[p]),o=ae(0,0,t,f,i,c,u,0,0,l),oi.clearBuffer(),u+=a[h].length,!o);h++);if(Me.releasePrimitive(l),Dt.clearBuffer(),c+=s[p].length,o)break}return Fi=!1,o}function ae(n,e,t,i,s,a=0,o=0,c=0,u=0,f=null,p=!1){let r,l;p?(r=oi,l=Dt):(r=Dt,l=oi);const h=r.float32Array,g=r.uint32Array,_=r.uint16Array,m=l.float32Array,v=l.uint32Array,y=l.uint16Array,x=n*2,w=e*2,b=K(x,_),A=K(w,y);let T=!1;if(A&&b)p?T=s(ee(e,v),te(e*2,y),ee(n,g),te(n*2,_),u,o+e,c,a+n):T=s(ee(n,g),te(n*2,_),ee(e,v),te(e*2,y),c,a+n,u,o+e);else if(A){const I=Me.getPrimitive();N(e,m,I),I.applyMatrix4(t);const C=ie(n),P=se(n,g);N(C,h,Ze),N(P,h,Xe);const D=I.intersectsBox(Ze),S=I.intersectsBox(Xe);T=D&&ae(e,C,i,t,s,o,a,u,c+1,I,!p)||S&&ae(e,P,i,t,s,o,a,u,c+1,I,!p),Me.releasePrimitive(I)}else{const I=ie(e),C=se(e,v);N(I,m,Li),N(C,m,Ei);const P=f.intersectsBox(Li),D=f.intersectsBox(Ei);if(P&&D)T=ae(n,I,t,i,s,a,o,c,u+1,f,p)||ae(n,C,t,i,s,a,o,c,u+1,f,p);else if(P)if(b)T=ae(n,I,t,i,s,a,o,c,u+1,f,p);else{const S=Me.getPrimitive();S.copy(Li).applyMatrix4(t);const M=ie(n),R=se(n,g);N(M,h,Ze),N(R,h,Xe);const E=S.intersectsBox(Ze),F=S.intersectsBox(Xe);T=E&&ae(I,M,i,t,s,o,a,u,c+1,S,!p)||F&&ae(I,R,i,t,s,o,a,u,c+1,S,!p),Me.releasePrimitive(S)}else if(D)if(b)T=ae(n,C,t,i,s,a,o,c,u+1,f,p);else{const S=Me.getPrimitive();S.copy(Ei).applyMatrix4(t);const M=ie(n),R=se(n,g);N(M,h,Ze),N(R,h,Xe);const E=S.intersectsBox(Ze),F=S.intersectsBox(Xe);T=E&&ae(C,M,i,t,s,o,a,u,c+1,S,!p)||F&&ae(C,R,i,t,s,o,a,u,c+1,S,!p),Me.releasePrimitive(S)}}return T}const $t=new Q,or=new d.Box3,lc={strategy:Fr,maxDepth:40,maxLeafTris:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0};class ds{static serialize(e,t={}){t={cloneBuffers:!0,...t};const i=e.geometry,s=e._roots,a=e._indirectBuffer,o=i.getIndex();let c;return t.cloneBuffers?c={roots:s.map(u=>u.slice()),index:o?o.array.slice():null,indirectBuffer:a?a.slice():null}:c={roots:s,index:o?o.array:null,indirectBuffer:a},c}static deserialize(e,t,i={}){i={setIndex:!0,indirect:!!e.indirectBuffer,...i};const{index:s,roots:a,indirectBuffer:o}=e,c=new ds(t,{...i,[Si]:!0});if(c._roots=a,c._indirectBuffer=o||null,i.setIndex){const u=t.getIndex();if(u===null){const f=new d.BufferAttribute(e.index,1,!1);t.setIndex(f)}else u.array!==s&&(u.array.set(s),u.needsUpdate=!0)}return c}get indirect(){return!!this._indirectBuffer}constructor(e,t={}){if(e.isBufferGeometry){if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(t=Object.assign({...lc,[Si]:!1},t),t.useSharedArrayBuffer&&!oc())throw new Error("MeshBVH: SharedArrayBuffer is not available.");this.geometry=e,this._roots=null,this._indirectBuffer=null,t[Si]||(Tl(this,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new d.Box3))),this.resolveTriangleIndex=t.indirect?i=>this._indirectBuffer[i]:i=>i}refit(e=null){return(this.indirect?Xl:Ol)(this,e)}traverse(e,t=0){const i=this._roots[t],s=new Uint32Array(i),a=new Uint16Array(i);o(0);function o(c,u=0){const f=c*2,p=a[f+15]===hi;if(p){const r=s[c+6],l=a[f+14];e(u,p,new Float32Array(i,c*4,6),r,l)}else{const r=c+Pt/4,l=s[c+6],h=s[c+7];e(u,p,new Float32Array(i,c*4,6),h)||(o(r,u+1),o(l,u+1))}}}raycast(e,t=d.FrontSide,i=0,s=1/0){const a=this._roots,o=this.geometry,c=[],u=t.isMaterial,f=Array.isArray(t),p=o.groups,r=u?t.side:t,l=this.indirect?Kl:Hl;for(let h=0,g=a.length;h<g;h++){const _=f?t[p[h].materialIndex].side:r,m=c.length;if(l(this,h,_,e,c,i,s),f){const v=p[h].materialIndex;for(let y=m,x=c.length;y<x;y++)c[y].face.materialIndex=v}}return c}raycastFirst(e,t=d.FrontSide,i=0,s=1/0){const a=this._roots,o=this.geometry,c=t.isMaterial,u=Array.isArray(t);let f=null;const p=o.groups,r=c?t.side:t,l=this.indirect?$l:Wl;for(let h=0,g=a.length;h<g;h++){const _=u?t[p[h].materialIndex].side:r,m=l(this,h,_,e,i,s);m!=null&&(f==null||m.distance<f.distance)&&(f=m,u&&(m.face.materialIndex=p[h].materialIndex))}return f}intersectsGeometry(e,t){let i=!1;const s=this._roots,a=this.indirect?ec:Gl;for(let o=0,c=s.length;o<c&&(i=a(this,o,e,t),!i);o++);return i}shapecast(e){const t=re.getPrimitive(),i=this.indirect?Ul:kl;let{boundsTraverseOrder:s,intersectsBounds:a,intersectsRange:o,intersectsTriangle:c}=e;if(o&&c){const r=o;o=(l,h,g,_,m)=>r(l,h,g,_,m)?!0:i(l,h,this,c,g,_,t)}else o||(c?o=(r,l,h,g)=>i(r,l,this,c,h,g,t):o=(r,l,h)=>h);let u=!1,f=0;const p=this._roots;for(let r=0,l=p.length;r<l;r++){const h=p[r];if(u=Pl(this,r,a,o,s,f),u)break;f+=h.byteLength}return re.releasePrimitive(t),u}bvhcast(e,t,i){let{intersectsRanges:s,intersectsTriangles:a}=i;const o=re.getPrimitive(),c=this.geometry.index,u=this.geometry.attributes.position,f=this.indirect?g=>{const _=this.resolveTriangleIndex(g);G(o,_*3,c,u)}:g=>{G(o,g*3,c,u)},p=re.getPrimitive(),r=e.geometry.index,l=e.geometry.attributes.position,h=e.indirect?g=>{const _=e.resolveTriangleIndex(g);G(p,_*3,r,l)}:g=>{G(p,g*3,r,l)};if(a){const g=(_,m,v,y,x,w,b,A)=>{for(let T=v,I=v+y;T<I;T++){h(T),p.a.applyMatrix4(t),p.b.applyMatrix4(t),p.c.applyMatrix4(t),p.needsUpdate=!0;for(let C=_,P=_+m;C<P;C++)if(f(C),o.needsUpdate=!0,a(o,p,C,T,x,w,b,A))return!0}return!1};if(s){const _=s;s=function(m,v,y,x,w,b,A,T){return _(m,v,y,x,w,b,A,T)?!0:g(m,v,y,x,w,b,A,T)}}else s=g}return ac(this,e,t,s)}intersectsBox(e,t){return $t.set(e.min,e.max,t),$t.needsUpdate=!0,this.shapecast({intersectsBounds:i=>$t.intersectsBox(i),intersectsTriangle:i=>$t.intersectsTriangle(i)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,i={},s={},a=0,o=1/0){return(this.indirect?nc:Zl)(this,e,t,i,s,a,o)}closestPointToPoint(e,t={},i=0,s=1/0){return Dl(this,e,t,i,s)}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(i=>{N(0,new Float32Array(i),or),e.union(or)}),e}}class cc{constructor(e){this.name="WorkerBase",this.running=!1,this.worker=e,this.worker.onerror=t=>{throw t.message?new Error(`${this.name}: Could not create Web Worker with error "${t.message}"`):new Error(`${this.name}: Could not create Web Worker.`)}}runTask(){}generate(...e){if(this.running)throw new Error("GenerateMeshBVHWorker: Already running job.");if(this.worker===null)throw new Error("GenerateMeshBVHWorker: Worker has been disposed.");this.running=!0;const t=this.runTask(this.worker,...e);return t.finally(()=>{this.running=!1}),t}dispose(){this.worker.terminate(),this.worker=null}}class uc extends cc{constructor(e){const t=new Worker(e||new URL("data:text/javascript;base64,aW1wb3J0IHsKCUJ1ZmZlckdlb21ldHJ5LAoJQnVmZmVyQXR0cmlidXRlLAp9IGZyb20gJ3RocmVlJzsKaW1wb3J0IHsgTWVzaEJWSCB9IGZyb20gJy4uL2NvcmUvTWVzaEJWSC5qcyc7Cgpvbm1lc3NhZ2UgPSAoIHsgZGF0YSB9ICkgPT4gewoKCWxldCBwcmV2VGltZSA9IHBlcmZvcm1hbmNlLm5vdygpOwoJZnVuY3Rpb24gb25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KCQl9ICk7CgoJfQoKfTsK",typeof document>"u"?require("url").pathToFileURL(__filename).href:ot&&ot.src||new URL("shop-components.cjs",document.baseURI).href),{type:"module"});super(t),this.name="GenerateMeshBVHWorker"}runTask(e,t,i={}){return new Promise((s,a)=>{if(t.getAttribute("position").isInterleavedBufferAttribute||t.index&&t.index.isInterleavedBufferAttribute)throw new Error("GenerateMeshBVHWorker: InterleavedBufferAttribute are not supported for the geometry attributes.");e.onerror=f=>{a(new Error(`GenerateMeshBVHWorker: ${f.message}`))},e.onmessage=f=>{const{data:p}=f;if(p.error)a(new Error(p.error)),e.onmessage=null;else if(p.serialized){const{serialized:r,position:l}=p,h=ds.deserialize(r,t,{setIndex:!1}),g=Object.assign({setBoundingBox:!0},i);if(t.attributes.position.array=l,r.index)if(t.index)t.index.array=r.index;else{const _=new d.BufferAttribute(r.index,1,!1);t.setIndex(_)}g.setBoundingBox&&(t.boundingBox=h.getBoundingBox(new d.Box3)),i.onProgress&&i.onProgress(p.progress),s(h),e.onmessage=null}else i.onProgress&&i.onProgress(p.progress)};const o=t.index?t.index.array:null,c=t.attributes.position.array,u=[c];o&&u.push(o),e.postMessage({index:o,position:c,options:{...i,onProgress:null,includedProgressCallback:!!i.onProgress,groups:[...t.groups]}},u.map(f=>f.buffer).filter(f=>typeof SharedArrayBuffer>"u"||!(f instanceof SharedArrayBuffer)))})}}class hc{constructor(e,t){this.lock=!1,this.lockX=!1,this.lockY=!1,this.invRotMat=new d.Matrix4,this.mouse=new d.Vector3,this.rotateStart=new d.Vector2,this.rotateEnd=new d.Vector2,this.rotateDelta=new d.Vector2,this.selectedAxis=null,this.isDragging=!1,this.context=null,this.orbitState=!0,this._animator=0,this._emitter=new ct,this.addListener=this._emitter.addListener.bind(this._emitter),this.removeAllListeners=this._emitter.removeAllListeners.bind(this._emitter),this._text=document.createElement("div"),this._textTimer=0,this._update=()=>{this.lock||(this._textTimer&&(window.clearTimeout(this._textTimer),this._textTimer=0),this._textTimer=window.setTimeout(()=>{this._text.style.opacity="0"},800),this.camera.updateMatrix(),this.invRotMat.extractRotation(this.camera.matrix).invert(),this.axes.forEach(s=>{this.setAxisPosition(s)}),this.axes.sort((s,a)=>s.position.z>a.position.z?1:-1),this.drawLayers(!0),this._text.style.opacity="1",this._text.innerText=this.camera.position.distanceTo(this.orbit.target).toFixed(2)+" m")},this.updateMouseFromEvent=s=>{this.rect=this.domElement.getBoundingClientRect();const a=this.domElement.width/this.domElement.clientWidth,o=this.domElement.height/this.domElement.clientHeight,{left:c,top:u}=this.rect;this.mouse.set((s.clientX-c)*a,(s.clientY-u)*o,0)},this.updateSelectedAxisUnderMouse=()=>{this.selectedAxis=null,this.axes.forEach(s=>{this.mouse.distanceTo(s.position)<s.size&&(this.selectedAxis=s)})},this.onPointerDown=s=>{this.rotateStart.set(s.clientX,s.clientY),this.updateMouseFromEvent(s),this.updateSelectedAxisUnderMouse(),this.orbitState=this.orbit.enabled,this.orbit.enabled=!1,window.addEventListener("pointermove",this.onDrag,!1),window.addEventListener("pointerup",this.onPointerUp,!1)},this.onPointerUp=()=>{this.domElement.style.backgroundColor="#FFF0",setTimeout(()=>this.isDragging=!1,0),this.domElement.classList.remove("dragging"),this.orbit.enabled=this.orbitState,window.removeEventListener("pointermove",this.onDrag,!1),window.removeEventListener("pointerup",this.onPointerUp,!1)},this.onPointerEnter=()=>{this.domElement.style.backgroundColor="#FFF3",this.rect=this.domElement.getBoundingClientRect()},this.onPointerMove=s=>{if(this.lock||this.isDragging)return;const a=this.selectedAxis;s&&(this.updateMouseFromEvent(s),this.updateSelectedAxisUnderMouse()),a!==this.selectedAxis&&this.drawLayers()},this.onDrag=s=>{this.lock||(this.isDragging||this.domElement.classList.add("dragging"),this.isDragging=!0,this.selectedAxis=null,this.rotateEnd.set(s.clientX,s.clientY),this.rotateDelta.subVectors(this.rotateEnd,this.rotateStart).multiplyScalar(.5),this.rotateStart.copy(this.rotateEnd),this.orbit.update())},this.onMouseClick=s=>{if(this.lock||(this.updateMouseFromEvent(s),this.updateSelectedAxisUnderMouse(),this.isDragging||!this.selectedAxis))return;this._animator&&cancelAnimationFrame(this._animator);const a=this.selectedAxis.direction.clone();this.camera.lookAt(0,0,0);const o=this.camera.position.distanceTo(this.orbit.target);a.multiplyScalar(o),this.selectedAxis.axis==="z"?a.setZ(this.orbit.target.z+o):this.selectedAxis.axis==="-z"?a.setZ(this.orbit.target.z-o):a.setZ(this.orbit.target.z);const c=500,u=performance.now(),f=1,p=this.selectedAxis.axis,r=()=>{const h=performance.now()-u,g=Math.min(h/c,f);if(this.camera.position.lerp(a,g),this.orbit.update(),g!==f){this._animator=window.requestAnimationFrame(r);return}else this._animator=0,this.onPointerMove(void 0),this._emitter.emit("axis-select-end",p);this.onPointerMove(void 0)};this._emitter.emit("axis-select-start",p),r()},this.drawCircle=(s,a=10,o="#FF0000")=>{this.context&&(this.context.beginPath(),this.context.rect(s.x-a,s.y-a,a*2,a*2),this.context.fillStyle=o,this.context.fill(),this.context.closePath())},this.drawLine=(s,a,o=1,c="#FF0000")=>{this.context&&(this.context.beginPath(),this.context.moveTo(s.x,s.y),this.context.lineTo(a.x,a.y),this.context.lineWidth=o,this.context.strokeStyle=c,this.context.stroke(),this.context.closePath())},this.drawLayers=(s=!1)=>{this.context&&(s&&this.context.clearRect(0,0,this.domElement.width,this.domElement.height),this.axes.forEach(a=>{const o=this.selectedAxis===a,c=a.position.z>=-.01?a.color[0]:a.color[1];if(a.line&&this.drawLine(this.center,a.position,a.line,c),this.drawCircle(a.position,a.size,o?"#0066ff":c),a.label){const u=a.axis==="-x"?this.options.fontSize-3:this.options.fontSize;this.context.font=[this.options.fontWeight,u+"px",this.options.fontFamily].join(" "),this.context.fillStyle=this.options.fontColor,this.context.textBaseline="middle",this.context.textAlign="center",this.context.fillText(a.label,a.position.x,a.position.y)}}))},this.setAxisPosition=s=>{const a=s.direction.clone().applyMatrix4(this.invRotMat),o=s.size;s.position.set(a.x*(this.center.x-o/2-this.options.padding)+this.center.x,this.center.y-a.y*(this.center.y-o/2-this.options.padding),a.z)};const i={offset:new d.Vector2,size:90,padding:8,bubbleSizePrimary:8,bubbleSizeSecondary:6,lineWidth:2,fontSize:11,fontFamily:"arial",fontWeight:"normal",fontColor:"#fff",className:"orbit-controls-gizmo",colors:{x:["#f35f5f","#902525"],y:["#78da2f","#71ae45"],z:["#1d92fa","#d0d1d1"]}};this.options={...i,...t},this.orbit=e,this.camera=e.object,this.center=new d.Vector3(this.options.size/2,this.options.size/2,0),this.axes=this.createAxes(),this.domElement=this.createCanvas(this.options),this.orbit.addEventListener("change",this._update),this._text.style.cssText=`
|
|
3731
|
+
`,this._needsRender=!1}handleShadowClick(e){const t=e.target;if(!t)return;t.closest(".info")&&(e.preventDefault(),e.stopPropagation());const i=t.closest("[data-action]");if(!i)return;const s=i.getAttribute("data-action");if(s)switch(e.preventDefault(),e.stopPropagation(),s){case"remove-device":this.removeDevice();break;case"remove-function":{const a=i.getAttribute("data-function");a&&this.dispatchEvent(new CustomEvent("function-removed",{detail:a}));break}case"toggle-dialog":if(!this.hasMoreFunctions)return;this._showDialog=!this._showDialog,this.scheduleRender();break;case"add-function":{const a=i.getAttribute("data-function");a&&(this.dispatchEvent(new CustomEvent("function-added",{detail:a})),this._showDialog=!1,this.scheduleRender());break}}}}customElements.get("slot-item")||customElements.define("slot-item",Dr);const q={ON_DROP:"slot-on-drop",ON_DEVICE_DELETED:"slot-on-device-deleted",ON_DEVICE_REPLACED:"slot-on-device-replaced",ON_BEFORE_SELECTED:"slot-on-before-selected",ON_SELECTED:"slot-on-selected",ON_ADD_BUTTON_CLICKED:"slot-add-button-clicked",ON_DEVICE_SELECTED:"slot-on-device-selected",ON_DROP_ERROR:"slot-on-drop-error",ON_ERROR_STATE_CHANGE:"slot-on-error-state-change",ON_FUNCTION_REMOVED:"slot-on-function-removed",ON_FUNCTION_ADDED:"slot-on-function-added"};class Wi extends fe.CSS2DObject{constructor(e){const t=document.createElement("div");super(t),this.props=e,this._emitter=new ct,this._slotContainer=new d.Group,this._bracketSlots=[],this._hasError=!1,this.useBracket=!1,this.addEventListener=this._emitter.addListener.bind(this._emitter),this.removeEventListener=this._emitter.removeListener.bind(this._emitter),this._canInstall=!1,this._loading=!1,this._selected=!1,this._deviceSelected=!1,this._focused=!1,this._toBeInstalled=!1,this._toBeReplaced=!1,this._allFunctions=new Set,this._functions=new Set,this._timer=0,this._parentPos=new d.Vector3,this._wrapper=new d.Group,this._showSlot=!0,this._isMirror=!1,this._preventDefaults=i=>{i.preventDefault(),i.stopPropagation()},this.getWP=this._slotContainer.getWorldPosition.bind(this._slotContainer),this._showSlot=typeof e.show=="boolean"?e.show:!0,this.name=e.name,this._isMirror=e.isMirror,this._slotUI=new Dr({name:e.name,isMobile:e.isMobile,onRemove:()=>{this.clearSlot(),this._emitter.emit(q.ON_DEVICE_DELETED)}}),this._slotUI.slot=this,this._slotUI.hide=!this._showSlot||this.isMirror,t.append(this._slotUI),this._parentPos.copy(this.props.slot.position),this._slotUI.addEventListener("function-removed",({detail:i})=>{this.removeFunction(i)}),this._slotUI.addEventListener("function-added",({detail:i})=>{this.addFunction(i)}),this.add(this._slotContainer),this.props.slot.add(this),setTimeout(()=>{var i;(i=this.props.slot.parent)==null||i.add(this._wrapper),this._wrapper.add(this.props.slot)},10),["dragenter","dragover","dragleave","drop"].forEach(i=>{t.addEventListener(i,this._preventDefaults,!1)}),t.addEventListener("click",i=>{i.preventDefault(),i.stopPropagation(),this.toBeInstalled?this._emitter.emit(q.ON_ADD_BUTTON_CLICKED):this.selected=!this.selected}),t.addEventListener("dragover",i=>{if(i.preventDefault(),i.dataTransfer.dropEffect="copy",!this._canInstall){i.dataTransfer&&(i.dataTransfer.dropEffect="none");return}}),t.addEventListener("drop",async i=>{var a;if(i.preventDefault(),i.stopPropagation(),!this._canInstall)return;const s=(a=i.dataTransfer)==null?void 0:a.getData("application/json");if(s){const o=JSON.parse(s);try{await this.install(o),this._emitter.emit(q.ON_DROP,this)}catch(c){this._emitter.emit(q.ON_DROP_ERROR,c)}}else this._emitter.emit(q.ON_DROP_ERROR,new Error("No device info"))})}get hasDevice(){return this._slotContainer.children.length>0}get isMirror(){return this._isMirror}shapeKeyChanged(e,t){var i;if(this.props.follows.has(e)){const s=this.props.follows.get(e);if(s){let a="x";["height","mast"].includes(e)?a="z":["width","liftOuterWidth"].includes(e)&&(a="y");const o=((i=this.props.slot)==null?void 0:i.position[a])>0?1:-1;this._wrapper.position[a]=(t-s.origin)*s.scale*o}}}async loadGlb(e){const i=await new ni({useCache:!0}).loadAsync(e);if(i.glb)return i.glb.clone(!0)}async installBracket(e){const i=await new ni({useCache:!0}).loadAsync(e);if(!i.glb)return;const s=i.glb.clone(!0);s.traverse(a=>{a.userData.isBracket=!0}),this.useBracket=!0,this._slotContainer.add(s)}async install(e){if(!this._loading){this._loading=!0;try{const t=await this.loadGlb(e.url);if(!t)throw new Error(`Fail to load device from: ${e.url}`);if(t.traverse(i=>{i.userData.isDevice=!0}),this.isMirror&&t.scale.set(1,1,-1),e.bracketUrl){const i=await this.loadGlb(e.bracketUrl);if(i)this.clearSlot(),this._emitter.emit(q.ON_DEVICE_REPLACED),i.traverse(s=>{s.name.startsWith("Slot")&&this._bracketSlots.push(s),s.userData.isBracket=!0}),this._slotContainer.add(i);else throw new Error(`Fail to load bracket from: ${e.bracketUrl}`);this._bracketSlots.forEach(s=>{s.add(t)})}else this.clearSlot(),this._emitter.emit(q.ON_DEVICE_REPLACED),this._slotContainer.add(t);this.mirrorTarget&&this.mirrorTarget.install(e),this.deviceInfo=e,this._slotUI.deviceLogo=e.logo||"",this._slotUI.deviceName=e.name,this._slotUI.filled=!0,this.holeTarget&&(this.holeTarget.visible=!1)}catch(t){throw t}finally{this._loading=!1}}}get device(){return this._slotContainer.children.length?this._slotContainer.children[0]:null}get allFunctions(){return[...this._allFunctions]}set allFunctions(e){this._functions.forEach(t=>{e.includes(t)||this._functions.delete(t)}),this._allFunctions=new Set(e),this._slotUI.allFunctions=e}get functions(){return[...this._functions]}addFunction(e){this._allFunctions.has(e)&&(this._functions.add(e),this._slotUI.functions=[...this.functions],this._emitter.emit(q.ON_FUNCTION_ADDED,e))}removeFunction(e){this._functions.has(e)&&(this._functions.delete(e),this._slotUI.functions=[...this.functions],this._emitter.emit(q.ON_FUNCTION_REMOVED,e))}clearFunctions(){this._functions.forEach(e=>this.removeFunction(e))}addFunctions(e){e.forEach(t=>this.addFunction(t)),this._slotUI.functions=this.functions}changeName(e){var t;this.name=e,this.props.slot.userData.name=e,this.props.name=e,(t=this.element)==null||t.setAttribute("data-name",this.props.name)}clearSlot(){this._bracketSlots=[],this._slotContainer.children.forEach(e=>{e.removeFromParent(),xe(e)}),this._slotUI.filled=!1,this.deviceInfo=void 0,this._slotUI.deviceName="",this._slotUI.deviceLogo="",this.holeTarget&&(this.holeTarget.visible=!0),this.mirrorTarget&&this.mirrorTarget.clearSlot()}get disabled(){return this._slotUI.disable}enable(){this.show(),this._slotUI.disable=!1}disable(){this._slotUI.disable=!0,this.hide()}hide(){this._slotUI.hide=!0}show(){this.isMirror||this.disabled||(this._slotUI.hide=!1)}get selected(){return this._selected}get focused(){return this._focused}set focused(e){this._focused=e,this._slotUI.focused=e}get toBeInstalled(){return this._toBeInstalled}set toBeInstalled(e){this._toBeInstalled=e,this._slotUI.toBeInstalled=e}get toBeReplaced(){return this._toBeReplaced}set toBeReplaced(e){this._toBeReplaced=e,this._slotUI.toBeReplaced=e}set selected(e){this.disabled||(e&&this._emitter.emit(q.ON_BEFORE_SELECTED,e),this._selected=e,this._slotUI.selected=e,this._emitter.emit(q.ON_SELECTED,e),this.element.style.zIndex="100",this.selected?this.renderOrder=1/0:this.renderOrder=1)}get deviceSelected(){return this._deviceSelected}set deviceSelected(e){this._deviceSelected=e,this._emitter.emit(q.ON_DEVICE_SELECTED,e)}get error(){return this._hasError}set error(e){this._loading&&setTimeout(()=>{this.error=e},100),this._hasError=e,this._slotUI.hasError=e,this._emitter.emit(q.ON_ERROR_STATE_CHANGE,e)}getCanInstall(){return this._canInstall}canInstall(e){this._canInstall=e,this._slotUI.canInstall=e}dispose(){cancelAnimationFrame(this._timer),["dragenter","dragover","dragleave","drop"].forEach(e=>{this.element.addEventListener(e,this._preventDefaults,!1)}),this.clearSlot(),this._emitter.removeAllListeners(),xe(this._slotContainer),this.element.remove()}render(e){const t=this.element.style.transform,i=/translate\(-?\d*\.?\d*%?,?\s-?\d*\.?\d*%?\)\s*translate\((-?\d*\.?\d*)px,\s*(-?\d*\.?\d*)px\)/.exec(t);if(!i)return;const s=new d.Vector2(parseFloat(i[1]),parseFloat(i[2])),a=e.mousePos.distanceTo(s);let o=this.props.isMobile?12:18,c=38,u=30;if(this._canInstall&&(o=34,c=60,u=60),a<u){let f=(u-a)*1+o;a<20&&(f=c),f>c&&(f=c),this._slotUI.setSize(f)}else this._slotUI.setSize(o)}clone(e){return new d.Group}}class Ja extends fe.CSS2DObject{constructor(e){const t=document.createElement("div");super(t),this._text=document.createElement("div");const i=cs(),s=i?"#ddd":"#eee";this.element.style.pointerEvents="auto",this.element.style.padding=i?"2px 6px":"3px 12px",this.element.style.borderTop=`1px solid ${s}`,this.element.style.borderBottom=this.element.style.borderTop;const a="6px",o=document.createElement("div");o.style.pointerEvents="none",Object.assign(o.style,{pointerEvents:"none",borderLeft:`1px solid ${s}`,borderRight:`1px solid ${s}`,position:"absolute",left:"0",top:"0",boxSizing:"border-box",height:a,width:"100%"}),this.element.append(o);const c=document.createElement("div");c.style.pointerEvents="none",Object.assign(c.style,{pointerEvents:"none",borderLeft:`1px solid ${s}`,borderRight:`1px solid ${s}`,position:"absolute",left:"0",bottom:"0",boxSizing:"border-box",height:a,width:"100%"}),this.element.append(c),this._text.style.fontSize=i?"10px":"14px",this._text.style.font="SF Pro SC,SF Pro Text,SF Pro Icons,PingFang SC,Helvetica Neue,Helvetica,Arial,sans-serif",this._text.style.color="#fff",this._text.style.fontWeight="500",this._text.style.transition="all .16s",this._text.innerText=e,this.element.append(this._text),this._text.addEventListener("pointermove",()=>{var u;o.style.borderColor=c.style.borderColor=this.element.style.borderColor="#666",this._text.style.color="#000",(u=this.onPointMove)==null||u.call(this)}),this._text.addEventListener("pointerleave",()=>{var u;o.style.borderColor=c.style.borderColor=this.element.style.borderColor=s,this._text.style.transform="scale(1)",this._text.style.color="#fff",(u=this.onPointLeave)==null||u.call(this)})}set text(e){this._text.innerText=e}dispose(){this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}}class ti extends d.Group{constructor(e,t=!0,i=!0){super(),this._startWith=e,this._showText=t,this.useStartEnd=i,this._line2Length=.01,this._line=new d.LineSegments(new d.BufferGeometry,new d.LineBasicMaterial({color:"#666",linewidth:2})),this._line2=new d.LineSegments(new d.BufferGeometry,new d.LineBasicMaterial({color:"#666",linewidth:2})),this._text=new Ja(""),this._line.frustumCulled=!1,this.add(this._line,this._line2),this._showText&&(this.add(this._text),this._text.onPointMove=()=>{this._line.material.color.set("#000"),this._line2.material.color.set("#000")},this._text.onPointLeave=()=>{this._line.material.color.set("#666"),this._line2.material.color.set("#666")})}updateMaterial(e){this._line.material=e}reset(){var e;(e=this._line.geometry)==null||e.dispose(),this._line.computeLineDistances()}update(e,t,i=0){var h,g;(h=this._line.geometry)==null||h.dispose(),this._line.geometry.setFromPoints([e,t]),this._line.computeLineDistances();const s=this._line2Length+i*.02,a=new d.Vector3().subVectors(t,e).normalize();let o;Math.abs(a.z)>Math.abs(a.x)&&Math.abs(a.z)>Math.abs(a.y)?o=new d.Vector3(-a.y,a.x,0):Math.abs(a.y)>Math.abs(a.x)?o=new d.Vector3(1,0,0):o=new d.Vector3(0,1,0),o.length()<.001&&(Math.abs(a.x)<.9?o=new d.Vector3(1,0,0):o=new d.Vector3(0,1,0)),o.normalize();const c=new d.Vector3().addVectors(e,o.clone().multiplyScalar(s)),u=new d.Vector3().addVectors(e,o.clone().multiplyScalar(-s)),f=new d.Vector3().addVectors(t,o.clone().multiplyScalar(s)),p=new d.Vector3().addVectors(t,o.clone().multiplyScalar(-s));(g=this._line2.geometry)==null||g.dispose(),this._line2.geometry=new d.BufferGeometry,this._line2.geometry.setFromPoints([c,u,f,p]),this._line2.computeLineDistances();const r=e.distanceTo(t);this._startWith?this._text.text=`${this._startWith}${(r*1e3).toFixed(0)} mm`:this._text.text=`${(r*1e3).toFixed(0)} mm`;const l=new d.Vector3;l.addVectors(e,t).multiplyScalar(.5),this._text.position.copy(l),this.useStartEnd||(this._line2.visible=!1)}destroy(){this._text.dispose(),this.children.forEach(e=>xe(e)),this.removeFromParent()}}class Lr extends d.Object3D{constructor(e,t){super(),this.radius=e,this._text=new $a(""),this._line=new ti(void 0,!1,!1),this._box=new d.Mesh,this._arc=new dn.Line2,this._previousPosition=null,this._updateTimer=null,this._updateDelay=300,this._accumulatedAngle=0,this._lastAngle=null,this._line.updateMaterial(new d.LineDashedMaterial({color:"#555",dashSize:.06,gapSize:.06})),this._line.renderOrder=0,this._box.geometry=new d.RingGeometry(e,e+.003,128),this._box.material=new d.MeshBasicMaterial({color:"#666",side:d.DoubleSide}),this._arc.geometry=new vs.LineGeometry,this._arc.geometry.setPositions([0,0,0,0,0,0]),this._arc.geometry.instanceCount=0,this._arc.material=new pn.LineMaterial({color:"#eee",linewidth:2,resolution:new d.Vector2(window.innerWidth,window.innerHeight)}),this._arc.visible=!1,this._arc.rotateX(-Math.PI/2),this.position.y=t,this._arc.position.y=.001,this.add(this._box),this.add(this._arc),this.add(this._line),this.add(this._text)}hide(){this._text.hide(),this._line.visible=!1,this._arc.visible=!1}show(){this._text.show(),this._line.visible=!0}dispose(){this._updateTimer&&(clearTimeout(this._updateTimer),this._updateTimer=null),this._box.geometry&&this._box.geometry.dispose(),this._arc.geometry&&this._arc.geometry.dispose(),this._arc.visible=!1,this._previousPosition=null}update(e){var t;this.radius=e,(t=this._box.geometry)==null||t.dispose(),this._box.geometry=new d.RingGeometry(e,e+.003,128),this._line.updateMaterial(new d.LineDashedMaterial({color:"#555",dashSize:.06*e,gapSize:.06*e})),this._text.update((e*1e3).toFixed(0))}change(e){const t=e.clone();t.setZ(0),t.normalize().multiplyScalar(this.radius),this._text.position.set(t.x,t.y,t.z),this._text.updateColor("#eee"),this._line.update(t,new d.Vector3),this._previousPosition&&this._updateArc(this._previousPosition,t),this._updateTimer&&clearTimeout(this._updateTimer),this._updateTimer=setTimeout(()=>{this._previousPosition=null,this._accumulatedAngle=0,this._lastAngle=null,this._clearArc(),this._updateTimer=null},this._updateDelay),this._previousPosition||(this._previousPosition=t.clone(),this._lastAngle=Math.atan2(t.y,t.x),this._accumulatedAngle=0)}_updateArc(e,t){const i=Math.atan2(t.y,t.x);if(this._lastAngle!==null){let u=i-this._lastAngle;u>Math.PI?u-=2*Math.PI:u<-Math.PI&&(u+=2*Math.PI),this._accumulatedAngle+=u}if(this._lastAngle=i,Math.abs(this._accumulatedAngle)<.01){this._arc.visible=!1;return}const s=Math.atan2(e.y,e.x),a=s+this._accumulatedAngle;let o=.006*this.radius;o<.003&&(o=.003),o>.006&&(o=.006);const c=this._createArcGeometry(s,a,this.radius+o);this._arc.geometry&&this._arc.geometry.dispose(),this._arc.geometry=c,this._arc.visible=!0}_clearArc(){this._text.updateColor(),this._arc.geometry&&(this._arc.geometry.setPositions([0,0,0,0,0,0]),this._arc.geometry.instanceCount=0,this._arc.computeLineDistances()),this._arc.visible=!1}_createArcGeometry(e,t,i){const s=[],a=t-e,o=Math.max(128,Math.floor(Math.abs(a)/(Math.PI/128))),c=a/o;for(let f=0;f<=o;f++){const p=e+f*c,r=Math.cos(p),l=Math.sin(p);s.push(i*r,0,i*l)}const u=new vs.LineGeometry;return u.setPositions(s),u.instanceCount=Math.max(0,s.length/3-1),u}}class $a extends fe.CSS2DObject{constructor(e){const t=document.createElement("div");super(t),this._wrapper=document.createElement("div"),this._circle=document.createElement("div");const i=cs();this._wrapper.style.fontSize=i?"10px":"11px",this._wrapper.style.color="#fff",this._wrapper.style.whiteSpace="nowrap",this._wrapper.style.position="absolute",this._wrapper.style.transform="translateX(-50%)",this._wrapper.style.top="6px",this._wrapper.style.font="SF Pro SC,SF Pro Text,SF Pro Icons,PingFang SC,Helvetica Neue,Helvetica,Arial,sans-serif";const s=this._circle;s.style.position="relative",s.style.zIndex="10",s.style.width=s.style.height="5px",s.style.borderRadius="50%",s.style.background="#666",t.append(this._wrapper,s),this.update(e)}show(){this.element.style.display="block"}hide(){this.element.style.display="none"}update(e){this._wrapper.innerText="旋转半径:"+e+" mm",this.updateColor("#eee")}updateColor(e="#666"){this._circle.style.background=e}}const el="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADgAAAAUCAYAAADY6P5TAAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAEvSURBVFiFzZdbFYMwEEQroRKQgAQkVEIlICEOkFAJlRAJSIgEJNx+sPS0nGxIaOhyv3nM7mTmwOViDHAFesADD+BqrakKQAcMwMQ3AWis9e1C3HLASJoAdNZ6sxG3/MZQMZy1dhWgFbfWRzDGlFjAwFlyyXdh5OD5OIqykBgBy1yiF0aMUQaJugLclOcEoP3nULmFgQgeyCwOoJGBYrijByspDM98ZIszJAt8Ks8dag/VUFYYLtetjHdruRz5JZf8WBg1Ae7KcgOluaSsMAKJwqgJ6Vz2WzcvhZHjVlFh1ESG1DQ67SYtyGs8OwujNpTkUtw4nVtbyLK1XDafF3aKW90Z3EpBbi5lE0u9n3qoNTKk9rHh3heZqqwA8Vw6a11VkVwuPK31HALzb5pfovYC2xSs5LCDIUcAAAAASUVORK5CYII=",tl="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAKCAYAAACngj4SAAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAChSURBVDiNrdJbFYMwEIRhJFQCEpCAhEqIhDhBAlKQgAQkIOHrSziHpmkbLvua7P4zO9s0FYUeM0b0NT2nC9FnLQho7wQ9MOwgQ3K4ZPDrrtGmFcKKkL0HTAXXw2HX6HYuFnR/hMWC6ykX+W1AzJqq1abDGguux6LoPK9aUGFOm1Y+F+Bh+7DlsSKehRXgn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XFuxfV1LlHsBS+BrHWtJnSbWkVtLfknZVVW1zjQuYit4+1Ejain1oVARGBv4OKG74taSd2PiBn3oBsVb3Jmurw36yzzW2pSIwCuABciPpkwgQLNSZgIj7QZtrbOgQGAXyAGkk/aVux1mr23F2kr5J2rLzYMr8iKVah228UVc97CR9VbeNU0EUhsCYgNDCWqvbwRr/0VZdgOzEDoZChe230SEgpMP2uxUtpkkgMCbKDxds1LWxUpjsddgJW1HGY2Qn3tzUOrRYU/XAdjlRBMaMnAkR6bidtZPU8m4O7+VrDisdt06l43Boq6raZRkgBkdgzJyHSOoXx0X1Vl018l2HxUWCBEe8Yqj9tla3DaX7O3XbTmortVQO80ZgLFCYBFKQfAz39+omgr1obS2GL0KndlLaHtJjMRjSGwuqhgUiMHDkREWyCt+3OoRJqkxa8c6yeP66xttH/5pe3/S67tS9tjtJe4IBEYGBi4UwWek4TFLF0uplhbIPj+9peQ0vhMEqfP0Uvq91/Lq0IhTwGwgMDKb3Lnalw7vY9H0tDw4dqhPpUK1IIVy0wIDxduGpWy3pD70MhpWO/1/uJP2jEA5UfxgKgYFRhQmx1vGk99F/JT6WbvverfXf3aubHJM23E+/27//wqUT6htXPk1jTeoz9//Q6UCIf9/q5X/zd/WqNXGQAkZGYKB4YaLuf43300QsvZy8+9+/9fhrzoVP+8pjMdjiY0eBRiWA0v0fPGR4m68wwtkAAAAASUVORK5CYII=";class Qs extends fe.CSS2DObject{constructor(e,t){const i=document.createElement("div");super(i),this.props=e,this.amr=t,this._direction=1,this._controllingRotate=!1,this._controlling=!1,this._startAt=0,this._looper=0,this._initial=0,this._canRotate=!1,this._emitter=new ct,this.addListener=this._emitter.addListener.bind(this._emitter),this.removeListener=this._emitter.removeListener.bind(this._emitter),this._update=()=>{if(this._looper=requestAnimationFrame(this._update),this._controlling){let c=(Date.now()-this._startAt)/200;c>4&&(c=4);let u=this._initial+.005*c*this._direction;if(u>this.props.max||u<this.props.min){this.mechanism&&(u<this.props.min?(this.mechanism.position.setZ(this.props.min),this._emitter.emit("change",this.props.min)):u>this.props.max&&(this.mechanism.position.setZ(this.props.max),this._emitter.emit("change",this.props.max)));return}if(this._initial=u,!this.mechanism)return;this.mechanism.position.setZ(u),this._emitter.emit("change",u)}};const s=cs();e.userData&&e.userData.target&&(this.name=e.userData.target.name,t.traverse(c=>{c.name===e.userData.target.name&&(this.mechanism=c)})),i.style.fontSize="30px",i.style.color="#0066FF",i.style.cursor="pointer",i.style.pointerEvents="auto";const a=document.createElement("div");a.style.position="absolute",a.style.left="0",a.style.transform="translateX(-50%) rotate(-180deg)",a.style.marginBottom="5px",a.style.width=a.style.height=s?"34px":"44px",a.style.background=`url(${Ys}) center no-repeat`,a.style.backgroundSize="100% auto",a.setAttribute("data-direction","up"),a.style.transition="all .2s";const o=document.createElement("div");if(o.style.position="absolute",o.style.left="0",o.style.transform="translateX(-50%)",a.style.bottom=o.style.top="8px",o.style.width=o.style.height=a.style.width,o.style.background=`url(${Ys}) center no-repeat`,o.style.backgroundSize="100% auto",o.style.transition="all .2s",o.setAttribute("data-direction","down"),Array.from([a,o]).forEach(c=>{s||c.addEventListener("mousemove",()=>{c.style.filter="invert(100%)"}),c.addEventListener("mouseleave",()=>{c.style.filter=""}),c.addEventListener("pointerdown",()=>{this.mechanism&&(c.style.filter="invert(100%)",this._controlling=!0,this._startAt=Date.now(),this._initial=this.mechanism.position.z,this._direction=c.getAttribute("data-direction")==="up"?1:-1,this._update())}),c.addEventListener("pointerup",()=>{this._controlling=!1,cancelAnimationFrame(this._looper),c.style.filter=""}),c.addEventListener("pointerleave",()=>{this._controlling=!1,cancelAnimationFrame(this._looper),c.style.filter=""})}),e.userData&&(this._canRotate=e.userData.canRotate,this._canRotate)){const{rotateTarget:c,rotateDuration:u,rotateStep:f,rotateMax:p,rotateMin:r}=e.userData;let l;if(c&&(t.traverse(h=>{h.name===c.name&&(l=h)}),l)){const h=document.createElement("div");h.style.background=`url(${il}) center no-repeat`,h.style.backgroundSize="100% auto",h.style.position="absolute",h.style.top="-50%",h.style.left="-50%",h.style.width=s?"140px":"160px",h.style.height=s?"70px":"80px",h.style.transform="translateX(-50%) translateY(-50%)",i.append(h);const g=document.createElement("div");g.style.background=`url(${tl}) center no-repeat`,g.style.backgroundSize="100% auto",g.style.width=g.style.height=s?"20px":"26px",g.style.position="absolute",g.style.top="0",g.style.transform="translateY(-50%)",g.style.marginBottom="5px",g.setAttribute("data-direction","left"),i.append(g);const _=document.createElement("div");_.style.background=`url(${el}) center no-repeat`,_.style.backgroundSize="100% auto",_.style.width=_.style.height=s?"20px":"26px",_.style.position="absolute",g.style.left=_.style.right=s?"62px":"69px",_.style.top="0",_.style.transform="translateY(-50%)",_.style.marginBottom="5px",_.setAttribute("data-direction","right"),i.append(_),Array.from([g,_]).forEach(m=>{s||m.addEventListener("mousemove",()=>{m.style.filter="invert(100%)"}),m.addEventListener("mouseleave",()=>{m.style.filter=""}),m.addEventListener("pointerdown",()=>{if(this._timer&&this._timer.isPlaying())return;m.style.filter="invert(100%)",this._controllingRotate=!0,this._startAt=Date.now(),this._direction=m.getAttribute("data-direction")==="left"?1:-1;let v=f/180*Math.PI*this._direction+l.rotation.z;v>p/180*Math.PI?v=p/180*Math.PI:v<r/180*Math.PI&&(v=r/180*Math.PI),this._timer=new It(l.rotation).to({z:v}).duration(u).start(),this._update()}),m.addEventListener("pointerup",()=>{this._controllingRotate=!1,cancelAnimationFrame(this._looper),m.style.filter=""}),m.addEventListener("pointerleave",()=>{this._controllingRotate=!1,cancelAnimationFrame(this._looper),m.style.filter=""})})}}i.append(a,o),this.scale.set(.01,.01,.01),this.matrixAutoUpdate=!1,this.updateMatrix()}hide(){this.element.style.display="none",this.traverse(e=>{e.visible=!1,e instanceof fe.CSS2DObject&&(e.element.style.visibility="hidden")}),this.visible=!1}show(){this.element.style.display="auto",this.traverse(e=>{e.visible=!0,e instanceof fe.CSS2DObject&&(e.element.style.visibility="visible")}),this.visible=!0}dispose(){this._emitter.removeAllListeners(),cancelAnimationFrame(this._looper),this.element.remove()}}class sl extends mn.CSS3DObject{constructor(e){const t=document.createElement("div");super(t),this.props=e,this._scale=.01,this._emitter=new ct,this.addEventListener=this._emitter.on.bind(this._emitter),this.removeEventListener=this._emitter.on.bind(this._emitter),this._mouseStart=new d.Vector2,this._targetSize=new d.Vector2,this._caches=[],this._sizeFlag="width",this._direction=1,this._lines=[],this._pointerdown=u=>{const{pageX:f,pageY:p}=u;this.endNode.setPointerCapture(u.pointerId),this._mouseStart.set(f,p),this._targetSize.setX(parseFloat(this.endNode.parentElement.style.width)),this._targetSize.setY(parseFloat(this.endNode.parentElement.style.height))},this._pointermove=u=>{if(!this._mouseStart.x)return;const{pageX:f,pageY:p}=u;let r=f-this._mouseStart.x,l=r+this._targetSize.x;this._sizeFlag==="height"&&(r=p-this._mouseStart.y,l=r*this._direction+this._targetSize.y);const h=l%10;l=l-h,r=(l-this._targetSize.x)*this._direction,this._sizeFlag==="height"&&(r=(l-this._targetSize.y)*this._direction),this._textNode.innerText=(l/100).toFixed(2)+" m",this.endNode.parentElement.style[this._sizeFlag]=`${l}px`},this._pointercancel=u=>{this.endNode.releasePointerCapture(u.pointerId),this._mouseStart.set(0,0)};const{start:i,end:s}=e,a=s.distanceTo(i);this.props.axios==="z"?this.props.axios="y":this.props.axios==="y"&&(this.props.axios="z"),this.props.axios==="y"&&(this._sizeFlag="height");const o=document.createElement("div");o.style.position="absolute",o.style.left="0",o.style.bottom="0",t.append(o),this._textNode=document.createElement("div"),this._textNode.innerText=a.toFixed(2)+" m",o.append(this._textNode);const c=document.createElement("div");this.endNode=c,c.style.position="absolute",c.style.left="auto",c.style.right="0",c.style.width="4px",c.style.height="4px",c.style.background="#0066FF",c.style.borderRadius="50%",c.style.margin="-2px -2px 0 0",c.style.cursor="pointer",o.append(c),this.scale.set(this._scale,this._scale,this._scale),t.style.fontSize="6px",t.style.color="#fff",o.style[this._sizeFlag]=a*100+"px",o.style.textAlign="center",this._sizeFlag==="height"?(o.style.borderLeft="0.1px dashed #fff",o.style.display="flex",o.style.alignItems="center",o.style.justifyContent="center",o.style.whiteSpace="nowrap",c.style.top="0",c.style.left="0",c.style.right="auto",c.style.margin="-2px 0 0 -2px"):o.style.borderBottom="0.1px dashed #fff",c.addEventListener("pointerdown",this._pointerdown),c.addEventListener("pointermove",this._pointermove),c.addEventListener("pointerup",this._pointercancel),s[this.props.axios]<i[this.props.axios]?this.rotateY(Math.PI):this._direction=-1}_getIndexByAxios(){return this.props.axios==="y"?1:this.props.axios==="z"?2:0}dispose(){this._lines.forEach(e=>e.dispose()),this._emitter.removeAllListeners(),this.endNode.removeEventListener("pointerdown",this._pointerdown),this.endNode.removeEventListener("pointermove",this._pointermove),this.endNode.removeEventListener("pointerup",this._pointercancel),this.element.remove(),this._caches.forEach(e=>e.clear()),this._caches=[]}}class rl extends d.Object3D{constructor(){super(),this._box3=new d.Box3,this._line11=new ti("长:"),this._line12=new ti("宽:"),this._line13=new ti("高:"),this._outline=new Lr(0,0),this._radius=0,this._hasWidthConfig=!1,this._hasLengthConfig=!1,this._hasHeightConfig=!1,this.follow="",this.followOrigin=0,this.followScale=1,this.originOffset=0,this.translateCache=0,this.head=0,this.tail=0,this._change=()=>{if(!this._app)return;const e=this._app.camera;e&&this._outline.change(e.position)},this.add(this._outline,this._line11,this._line12,this._line13)}get hasSizeConfig(){return{length:this._hasLengthConfig,width:this._hasWidthConfig,height:this._hasHeightConfig}}get size(){return this._box3.clone()}get radius(){return this._radius}init(e){this._app=e,this._app.controls.addEventListener("change",this._change)}reset(){this.hide(),this._line11.reset()}generate(e,t=0){e&&(this._object=e),this.update(t)}show(e=!0){const t=[this._line11,this._line12,this._line13];e&&(this.visible=!0,this._outline.visible=!0,this._outline.show(),t.push(this._outline)),t.forEach(i=>{i.traverse(s=>{s.visible=!0,s instanceof fe.CSS2DObject&&(s.element.style.visibility="visible")})})}hide(e=!0){const t=[this._line11,this._line12,this._line13];e&&(this.visible=!1,this._outline.visible=!1,this._outline.hide(),t.push(this._outline)),t.forEach(i=>{i.traverse(s=>{s.visible=!1,s instanceof fe.CSS2DObject&&(s.element.style.visibility="hidden")})})}destroy(){var e;(e=this._app)==null||e.controls.removeEventListener("change",this._change),this._line11.destroy(),this._line12.destroy(),this._line13.destroy()}update(e=0){if(!this._object)return;const t=this._object,{box:i,maxRadius:s,hasLength:a,hasHeight:o,hasWidth:c}=Na(t);this.tail=Math.abs(i.min.x),this.head=Math.abs(i.max.x),this._hasWidthConfig=c,this._hasLengthConfig=a,this._hasHeightConfig=o,this._box3.copy(i),this._radius=s,this.follow&&e&&(this.originOffset=(this.followOrigin-e)*this.followScale),this._outline.update(this._radius),this._change();const u=this._box3.min.x,f=this._box3.max.x,p=this._box3.min.z,r=this._box3.max.z,l=this._box3.min.y,h=this._box3.max.y;let g=.2;const _=new d.Vector3(u,h,0),m=new d.Vector3(f,h,0);this._line11.update(_.clone().sub(new d.Vector3(0,-g/1.8,0)),m.clone().sub(new d.Vector3(0,-g/1.8,0)),this._radius);const v=new d.Vector3(f,l,0);this._line12.update(m.clone().add(new d.Vector3(g,0,0)),v.clone().add(new d.Vector3(g,0,0)),this._radius);const y=new d.Vector3(u,h,p),x=new d.Vector3(u,h,r),w=y.clone();w.y-=g/6;const b=x.clone();b.y-=g/6,this._line13.update(w,b,this._radius)}}class Zs extends d.Object3D{constructor(e=.6,t=.4,i=.2){super(),this.isGoods=!0,this._generate(e,t,i)}updateSize(e=.1,t=.1,i=.1){this._generate(e,t,i)}clearAll(){xe(this)}hide(){this.traverse(e=>e.visible=!1)}show(){this.traverse(e=>e.visible=!0)}_generate(e,t,i){this.clearAll();const s=new d.Mesh(new d.BoxGeometry(e,t,i),new d.MeshBasicMaterial({color:new d.Color("#0f5fd5"),transparent:!0,opacity:.4}));s.geometry.translate(0,0,i/2);const a=new d.EdgesGeometry(s.geometry),o=new d.LineDashedMaterial({color:new d.Color("#000"),dashSize:.015,gapSize:.015}),c=new d.LineSegments(a,o);c.computeLineDistances(),this.add(s,c)}}const nl="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAALSURBVAiZY2AAAgAABQABYlUyiAAAAABJRU5ErkJggg==";class Gi{constructor(e){this._props=e,this.name="",this.transparentTexture=us.load(nl),this._offscreen=new OffscreenCanvas(0,0),this._defaults={...e},this.target=e.target,this.parent=this.target.parent,this.reset()}get imageSize(){return this._props.imageSize}get size(){return this._props.size}get defaultConfigs(){return{canvasWidth:200,canvasHeight:200,scaleX:1,scaleY:1,x:0,y:0,ox:0,oy:0,url:this._defaults.imageUrl}}clear(){this.change()}change(e,t=new d.Vector2(1,1),i=new d.Vector2){this.imageUrl=e;let s;if(e){const a=new Image;a.crossOrigin="anonymous",a.src=e,a.onload=async()=>{var f;let o=window.devicePixelRatio*2;this._offscreen.width=a.width+o,this._offscreen.height=a.height+o;const c=this._offscreen.getContext("2d");c==null||c.clearRect(0,0,this._offscreen.width,this._offscreen.height),c==null||c.drawImage(a,o/2,o/2,a.width,a.height),s=new d.Texture(this._offscreen),s.minFilter=1003,s.colorSpace=d.SRGBColorSpace,s.wrapS=s.wrapT=d.ClampToEdgeWrapping,s.repeat.set(1/t.x,1/t.y),s.offset.set(i.x,i.y),s.flipY=!1,s.needsUpdate=!0;const u=this._props.target;u.material&&((f=u.material.map)==null||f.dispose(),s?(u.material.map=s,u.material.opacity=1):(u.material.map=this.transparentTexture,u.material.opacity=0))}}else{const a=this._props.target;a.material&&(a.material.map=this.transparentTexture)}}reset(){this._props=this._defaults,this.name=this._props.name,this.imageUrl=this._props.imageUrl,this.target=this._props.target,this.change(this.imageUrl||"")}dispose(){this._offscreen=null}}function ol(n){return n.type?n.type==="Mesh":n.isMesh}const us=new d.TextureLoader;us.crossOrigin="anonymous";class Er extends d.Object3D{constructor(e){super(),this._props=e,this._emitter=new ct,this.addEventListener=this._emitter.addListener.bind(this._emitter),this._container=new d.Group,this.lines=new d.Group,this._clips=[],this._actionsMap=new Map,this._animationClock=new d.Clock,this.sizeBox=new rl,this._goodsSize=new Ga(0,0,0),this._slots=[],this._logos=[],this._skins=[],this._levels=new Map,this._bodyOpacity=1,this._masts=new Map,this._liftMaxHeight=0,this._jackMaxHeight=0,this._forkMaxHeight=0,this.controllers=[],this.goods=[],this._breathLights=[],this._shelves=new Map,this._shelfMaxLevel=1,this._url="",this._showController=!0,this._showSlots=!0,this._shapeKeys=new Map,this._shapeKeyTimer=0,this._shapeKeyCache="",this._materialsCache=new Map,this.opacityCache=void 0,this.actions=[],this._url=e.url||"",this._url&&this.load(this._url).then(),this.add(this._container,this.lines),this._props.showSizeBox&&this.add(this.sizeBox),this.showController=typeof e.showController=="boolean"?e.showController:!0,this._showSlots=typeof e.showSlots=="boolean"?e.showSlots:!0}get shapeKeys(){return this._shapeKeys}get size(){const e=this.sizeBox.size.getSize(new d.Vector3);return{width:e.z,length:e.x,height:e.y}}get goodsSize(){return this._goodsSize}get showController(){return this._showController}set showController(e){this._showController=e,this.controllers.forEach(t=>e?t.show():t.hide())}get slots(){return this._slots}get logos(){return this._logos}get skins(){return this._skins}get bodyOpacity(){return this._bodyOpacity}get fork(){return this._fork}get forkHeight(){var e;return((e=this._fork)==null?void 0:e.position.z)||0}get liftHeight(){var e;return((e=this._lift)==null?void 0:e.position.z)||0}get jack(){return this._jack}get jackHeight(){var e;return((e=this._jack)==null?void 0:e.position.z)||0}get lift(){return this._lift}set bodyOpacity(e){this._bodyOpacity=e,e<1?this._materialsCache.forEach(t=>{t.mat.transparent=!0,t.mat.opacity=e,t.mat.metalness=0,t.mat.roughness=1,t.mat.color=new d.Color("#3859be"),t.mat.needsUpdate=!0}):this._materialsCache.forEach(t=>{t.mat.transparent=t.transparent,t.mat.opacity=t.opacity,t.mat.metalness=t.metalness,t.mat.roughness=t.roughness,t.mat.color=t.color,t.mat.needsUpdate=!0})}init(e){this._app=e,this.sizeBox.init(e),this._onTicker&&this._app.renderer.domElement.removeEventListener("ticker",this._onTicker),this._onTicker=()=>{if(this._mixer){const t=this._animationClock.getDelta();this._mixer.update(t)}else this._animationClock.getDelta()},this._app.renderer.domElement.addEventListener("ticker",this._onTicker),this.addEventListener("shape-key-changed",(t,i)=>{this._slots.forEach(s=>s.shapeKeyChanged(t,i)),this.sizeBox.follow===t?(this.sizeBox.generate(this._container,i),this.sizeBox.originOffset&&(this._container.traverse(s=>{s instanceof d.Mesh&&!s.userData.isDevice&&!s.userData.isBracket&&s.geometry.translate(this.sizeBox.originOffset-this.sizeBox.translateCache,0,0),s instanceof Wi&&!s.props.slot.userData.ignoreOriginChanged&&s.parent&&s.parent.position.add(new d.Vector3(this.sizeBox.originOffset-this.sizeBox.translateCache,0,0))}),this.sizeBox.translateCache=this.sizeBox.originOffset,this.sizeBox.generate(this._container))):this.sizeBox.generate(this._container),["width","length","height"].includes(t)&&this._emitter.emit("size-changed",t,i)})}async load(e,t=""){this._url=e,this.name||(this.name=e.substring(e.lastIndexOf("/")+1,e.lastIndexOf("."))),!e.startsWith("blob")&&e.endsWith(".sglb");let i,s;if(t==="glb"||e.endsWith(".glb")){let o=await lt.loadAsync(e);i=o.scene,s=o.animations||[]}else{const c=await new ni({useCache:!0}).loadAsync(e);if(!c.glb)return;i=c.glb}const a=vn.clone(i);this._generateAmr(a,s),i=null,this._emitter.emit("amr-loaded")}changeSkin(e,t){e&&(e.change(t),this._app&&this._app.usePathTracing&&(this._app.sampleCount=0,this._app.usePathTracing&&(this._app.pathTracer.pausePathTracing=!1,this._app.pathTracer.updateMaterials())))}changeLogo(e,t){e.change(t.url,new d.Vector2(t.scaleX,t.scaleY),new d.Vector2(t.ox,t.oy))}setShapeKey(e,t,i=!0){i&&this._shapeKeyTimer&&e===this._shapeKeyCache&&clearTimeout(this._shapeKeyTimer),this._shapeKeyCache=e,this._shapeKeyTimer=window.setTimeout(()=>{this._container.traverse(s=>{if(!Object.keys(s.morphTargetDictionary||{}).includes(e))return;let a=t;s.userData[`origin_${e}`]&&(a-=s.userData[`origin_${e}`]);const o=s.morphTargetDictionary[e];s.morphTargetInfluences&&(s.morphTargetInfluences[o]=a),s instanceof d.Mesh&&s.geometry.translate(0,0,1e-5)}),i&&this._emitter.emit("shape-key-changed",e,t)},100)}_generateAmr(e,t){this._modelRoot=e,this._actionsMap.clear(),this.actions=[],this._clips=[],t&&t.length&&(this._mixer=new d.AnimationMixer(e),this._clips=t,t.forEach(i=>{const s=this._mixer.clipAction(i);this._actionsMap.set(i.name,s)}),this.actions=t.map(i=>i.name)),e.traverse(i=>{i.userData.isShelf&&(this._shelf=i),i.userData.isFork&&(this._fork=i),i.userData.isMast&&i.userData.mastLevel&&this._masts.set(i.userData.mastLevel,i),i.userData.isJack&&(this._jack=i),i.userData.isLift&&(this._lift=i),Object.keys(i.morphTargetDictionary||{}).forEach(s=>{let a=i.morphTargetInfluences[i.morphTargetDictionary[s]];i.userData[`origin_${s}`]&&(a+=i.userData[`origin_${s}`]),this._shapeKeys.has(s)||this._shapeKeys.set(s,a)})}),e.traverse(i=>{if(i instanceof d.Mesh){if(i.castShadow=!0,i.receiveShadow=!0,i.material)if(Array.isArray(i.material))i.material.forEach(a=>{a.userData.changeColor&&(this.skins.find(o=>o.name===a.userData.name)||this.skins.push(new es({name:a.userData.name,target:a})))});else{if(i.material.userData.isBreathLight&&i.material.emissiveIntensity){i.material.emissive||(i.material.emissive=new d.Color(16777215)),i.material.emissiveIntensity=2,i.material.toneMapped=!1;const a=1e3,o=new ye.Tween(i.material).to({emissiveIntensity:.2}).easing(ye.Easing.Quintic.InOut).duration(a),c=new ye.Tween(i.material).to({emissiveIntensity:2}).easing(ye.Easing.Quintic.InOut).duration(a);o.onComplete(()=>c.start()),c.onComplete(()=>o.start()),o.start(),this._breathLights.push(o,c)}i.material.userData.changeColor&&(this.skins.find(a=>a.name===i.material.userData.name)||this.skins.push(new es({name:i.material.userData.name,target:i.material})))}if(i.material)if(Array.isArray(i.material))i.material.forEach(o=>{if(o.userData.isLOGO){i.material.transparent=!0;let c;const u={width:0,height:0};i.material.map&&i.material.map.image&&(u.width=i.material.map.image.width,u.height=i.material.map.image.height,c=Ni(i.material.map.image));const f=new Gi({name:o.userData.name,target:i,size:Ws(i),imageSize:u,imageUrl:c});this._logos.push(f)}o.userData.isTransparent&&(o.transparent=!0),this._materialsCache.set(o.uuid,{opacity:o.opacity,transparent:o.transparent,roughness:o.roughness,metalness:o.metalness,color:o.color,mat:o})});else{const a=i.material;if(a.userData.isLOGO){i.material.transparent=!0;let o;const c={width:0,height:0};i.material.map&&i.material.map.image&&(c.width=i.material.map.image.width,c.height=i.material.map.image.height,o=Ni(i.material.map.image));const u=new Gi({name:a.userData.name,target:i,size:Ws(i),imageSize:c,imageUrl:o});this._logos.push(u)}a.userData.isTransparent&&(a.transparent=!0),this._materialsCache.set(a.uuid,{opacity:a.opacity,transparent:a.transparent,roughness:a.roughness,metalness:a.metalness,color:a.color,mat:a})}}this.generateController(i,e),this.generateDimension(i,e);const s=this.generateSlot(i,e);s&&this._slots.push(s),i.userData.isOrigin&&Object.keys(i.userData).forEach(o=>{if(o.startsWith("follow_")){const c=o.replace("follow_","");this.shapeKeys.has(c)&&(this.sizeBox.follow=c,this.sizeBox.followOrigin=this._shapeKeys.get(c)||0,this.sizeBox.followScale=i.userData[o])}})}),this.slots.forEach(i=>{i.props.mirrorTarget&&(i.mirrorTarget=this.slots.find(s=>s.props.slot.name===i.props.mirrorTarget))}),e.updateMatrixWorld(!0),this._container.add(e),this.sizeBox.generate(e),this.sizeBox.show()}setHeight(e){this.setShapeKey("height",e)}setWeight(e){this.setShapeKey("width",e)}setLength(e){this.setShapeKey("length",e)}limitValue(e){this.name==="SFL-CDD14"&&(e>1.6?this.setShapeKey("mast",1):this.setShapeKey("mast",0)),["SFL-CDD20","SFL-CDD20-Y"].includes(this.name)&&(e>1.6?this.setShapeKey("mast",1):this.setShapeKey("mast",0)),this.name==="SFL-CDD15"&&(e>2.43?this.setShapeKey("mast",1):this.setShapeKey("mast",0)),["SFL-CPD20-Y","SFL-CPD30-Y"].includes(this.name)&&(e>3.5?this.setShapeKey("mast",2):e>3?this.setShapeKey("mast",1):this.setShapeKey("mast",0))}setForkHeight(e){if(this._fork){if(e>this._forkMaxHeight&&(e=this._forkMaxHeight),this._fork.position.z=e,this._masts.size===1){const t=this._masts.get(2),i=(t==null?void 0:t.userData.startHeight)||.1;t&&(t.position.z=(e-i)*.5)}this._emitter.emit("fork-height-change",e)}}setForkMaxHeight(e){this._fork&&(this._forkMaxHeight=e,this.limitValue(e),this.controllers.forEach(t=>{t.name.toLowerCase().includes("fork")&&(t.props.max=e)}),this._fork&&this.forkHeight>this._forkMaxHeight&&this.setForkHeight(e))}setLiftHeight(e){this._lift&&(e>this._liftMaxHeight&&(e=this._liftMaxHeight),this._lift.position.z=e)}getLiftMaxHeight(){return this._liftMaxHeight}setLiftMaxHeight(e){if(!this._lift)return;this._liftMaxHeight=e,this.limitValue(e),this.controllers.forEach(a=>{a.name.toLowerCase().includes("lift")&&(a.props.max=e)}),this.liftHeight>this._liftMaxHeight&&this.setLiftHeight(e);let t=.46;this.levelOffset&&(t=this.levelOffset+.1);let i=e+t;const s=this.getShelfMinHeight()+t||0;i<s&&(i=s),this.setHeight(i)}setJackMaxHeight(e){this._jack&&(this._jackMaxHeight=e,this.limitValue(e),this.controllers.forEach(t=>{t.name.toLowerCase().includes("jack")&&(t.props.max=e)}),this.jackHeight>this._jackMaxHeight&&this.setJackHeight(e))}setJackHeight(e){this._jack&&(e>this._jackMaxHeight&&(e=this._jackMaxHeight),requestAnimationFrame(()=>{this.setShapeKey("jackHeight",e,!1)}),this._jack.position.z=e)}setLevel(e){}setGoodsSize(e){this._goodsSize.length=e.length,this._goodsSize.width=e.width,this._goodsSize.height=e.height,this.setShelfLevel(this._shelfMaxLevel)}getShelfMinHeight(){const e=this.levelOffset,t=this._shelfMaxLevel,i=this._shelves.get(0);return i?i.position.z+e*t+.1:0}getShelfMaxShelfHeight(){const e=this.levelOffset,t=this._shelfMaxLevel,i=this._shelves.get(0);if(i)return i.position.z+e*(t-1)}get levelOffset(){return this._goodsSize.height+.2}setShapeKeyToMesh(e,t,i){if(!Object.keys(e.morphTargetDictionary||{}).includes(t))return;const s=e.morphTargetDictionary[t];e.morphTargetInfluences&&(e.morphTargetInfluences[s]=i),e.geometry.translate(0,0,1e-5)}setShelfLevel(e=3){var s;if(!this._shelf)return;this._shelfMaxLevel=e;const t=this.levelOffset;this._shelves.delete(0),this._shelves.forEach(a=>{xe(a),a.parent&&a.removeFromParent()}),this.goods=[],this._shelves.clear(),this._shelves.set(0,this._shelf);for(let a=1;a<e;a++){if(!this._shelf)return;this._shelf.traverse(u=>{ol(u)&&(this.setShapeKeyToMesh(u,"goodsWidth",this._goodsSize.width),this.setShapeKeyToMesh(u,"goodsLength",this._goodsSize.length))});const o=this._shelf.clone(!0);o.position.z+=t*a,this._shelves.set(a,o),(s=this._shelf.parent)==null||s.add(o);let c;if(o.traverse(u=>{u.userData.isShelfContainer&&(c=u)}),(this.shapeKeys.has("goodsLength")||this.shapeKeys.has("goodsWidth"))&&(c==null||c.position.setX((c==null?void 0:c.position.x)-this._goodsSize.length/2)),c){const u=new Zs(this._goodsSize.length,this._goodsSize.width,this._goodsSize.height);if(c.add(u),this.goods.push(u),a===1){const f=new Zs(this._goodsSize.length,this._goodsSize.width,this._goodsSize.height);f.position.z-=t,c.add(f),this.goods.push(f)}}}const i=this.getShelfMinHeight()||0;this._liftMaxHeight<i&&this.setLiftMaxHeight(i)}generateOuterLine(){this.traverse(e=>{if(e.userData.isOuterObject){const t=this.sizeBox.radius;this._outline?this._outline.update(t):(this._outline=new Lr(t,0),this.add(this._outline))}})}generateController(e,t){if(this.showController){if(e.userData.isForkController&&e.userData.target){const i=e.userData.target.name,{min:s,max:a}=e.userData;let o;if(t.traverse(u=>{u.name===i&&(o=u)}),!o)return;const c=new Qs({name:"",target:i,default:0,min:s,max:a},o);e.add(c)}else if(e.userData.isController&&e.userData.target){const i=e.userData.target.name,{min:s,max:a}=e.userData;let o;if(t.traverse(u=>{u.name===i&&(o=u)}),!o)return;const c=new Qs({name:"",userData:e.userData,target:e.userData.key,default:0,min:s||0,max:a||1},o);e.add(c),this.controllers.push(c),(o.userData.isFork||o.userData.isLift||o.userData.isJack)&&(this._forkMaxHeight=a||1,this._liftMaxHeight=a||1,this._jackMaxHeight=a||1,c.addListener("change",u=>{this.setForkHeight(u),this.setLiftHeight(u),this.setJackHeight(u)}))}}}generateDimension(e,t){if(e.userData.isDimension){const i=e.userData.divider,s=Ua(e.userData.startOrigin),a=e.userData.axios;let o,c;if(a==="x"?(o=new d.Vector3(e.userData.start-e.position.x,0,0),c=o.clone().setX(e.userData.end-e.position.x)):a==="z"?(o=new d.Vector3(0,e.userData.start-e.position.y,0),c=o.clone().setY(e.userData.end-e.position.y)):(o=new d.Vector3(0,0,e.userData.start-e.position.z),c=o.clone().setZ(e.userData.end-e.position.z)),!Object.keys(e.userData).flatMap(r=>r.startsWith("target")?e.userData[r].name:[]).length)return;const p=new sl({start:o,end:c,startOrigin:s,axios:a,divider:i});e.add(p)}}generateSlot(e,t){var i,s;if(e.userData.isSlot){const a=e.userData.name,o=e.userData.isMirror,c=(i=e.userData.mirrorSlot)==null?void 0:i.name;if(a){const u=e.userData.holeTarget&&e.userData.holeTarget.name;let f;u&&t.traverse(h=>{h.name===u&&(f=h)});const p=new Map;Object.keys(e.userData).forEach(h=>{if(h.startsWith("follow_")){const g=h.split("_")[1];if(g){let _=e.userData[h];p.set(g,{scale:_,origin:this.shapeKeys.get(g)||0})}}});const r=(s=this._app)==null?void 0:s.props.isMobile,l=new Wi({name:a,follows:p,slot:e,show:this._showSlots,isMirror:o,mirrorTarget:c,isMobile:r});return l.holeTarget=f,l.addEventListener(q.ON_DROP,h=>{this._app&&this._app.props.useSound&&this._app.sound.play()}),l.addEventListener(q.ON_BEFORE_SELECTED,h=>{this._slots.forEach(g=>{g.selected&&(g.selected=!1)})}),l.addEventListener(q.ON_ERROR_STATE_CHANGE,h=>{if(this._app)if(this._app._outlinePassError.selectedObjects=this._app._outlinePassError.selectedObjects.filter(g=>!!g.parent),h){if(l.device){if(this._app._outlinePassError.selectedObjects.find(_=>{var m;return _.parent==((m=l.device)==null?void 0:m.parent)}))return;this._app._outlinePassError.selectedObjects=[l.device,...this._app._outlinePassError.selectedObjects]}}else l.device&&(this._app._outlinePassError.selectedObjects=this._app._outlinePassError.selectedObjects.filter(g=>{var _;return g.parent!=((_=l.device)==null?void 0:_.parent)}))}),l}}}clean(){this._emitter.removeAllListeners(),this.controllers.forEach(e=>e.dispose()),this.controllers=[],xe(this._container),this._levels.forEach(e=>e.destroy()),this._levels.clear(),this._slots=[],this._logos=[],this._skins=[],this._materialsCache.clear(),this.opacityCache=void 0,this._breathLights.forEach(e=>e.stop()),this._breathLights=[],this.sizeBox.reset(),this._mixer&&this._mixer.stopAllAction(),this._mixer=void 0,this._clips=[],this._actionsMap.clear(),this.actions=[],this._app&&this._onTicker&&this._app.renderer.domElement.removeEventListener("ticker",this._onTicker),this._onTicker=void 0}destroy(){this.clean(),this.sizeBox.destroy()}playAction(e,t=!0,i){const s=this._actionsMap.get(e);return!s||!this._mixer?Promise.reject(new Error(`Action "${e}" not found or mixer not initialized.`)):(t&&s.reset(),this._actionsMap.forEach((a,o)=>{o!==e&&a.stop()}),s.enabled=!0,s.paused=!1,s.setLoop(d.LoopOnce,0),s.setEffectiveTimeScale((i==null?void 0:i.timeScale)??1),s.setEffectiveWeight(1),s.clampWhenFinished=(i==null?void 0:i.clampWhenFinished)??!0,i!=null&&i.fadeIn&&i.fadeIn>0&&s.fadeIn(i.fadeIn),new Promise(a=>{const o=c=>{var u;c.action===s&&((u=this._mixer)==null||u.removeEventListener("finished",o),a())};this._mixer.addEventListener("finished",o),s.play()}))}pauseAction(e){const t=this._actionsMap.get(e);t&&(t.paused=!0)}}const Fr=0,al=1,ll=2,Xs=2,Ti=1.25,Ks=1,Pt=6*4+4+4,hi=65535,cl=Math.pow(2,-24),Si=Symbol("SKIP_GENERATION");function ul(n){return n.index?n.index.count:n.attributes.position.count}function ut(n){return ul(n)/3}function hl(n,e=ArrayBuffer){return n>65535?new Uint32Array(new e(4*n)):new Uint16Array(new e(2*n))}function fl(n,e){if(!n.index){const t=n.attributes.position.count,i=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,s=hl(t,i);n.setIndex(new d.BufferAttribute(s,1));for(let a=0;a<t;a++)s[a]=a}}function Br(n){const e=ut(n),t=n.drawRange,i=t.start/3,s=(t.start+t.count)/3,a=Math.max(0,i),o=Math.min(e,s)-a;return[{offset:Math.floor(a),count:Math.floor(o)}]}function kr(n){if(!n.groups||!n.groups.length)return Br(n);const e=[],t=new Set,i=n.drawRange,s=i.start/3,a=(i.start+i.count)/3;for(const c of n.groups){const u=c.start/3,f=(c.start+c.count)/3;t.add(Math.max(s,u)),t.add(Math.min(a,f))}const o=Array.from(t.values()).sort((c,u)=>c-u);for(let c=0;c<o.length-1;c++){const u=o[c],f=o[c+1];e.push({offset:Math.floor(u),count:Math.floor(f-u)})}return e}function dl(n){if(n.groups.length===0)return!1;const e=ut(n),t=kr(n).sort((a,o)=>a.offset-o.offset),i=t[t.length-1];i.count=Math.min(e-i.offset,i.count);let s=0;return t.forEach(({count:a})=>s+=a),e!==s}function Mi(n,e,t,i,s){let a=1/0,o=1/0,c=1/0,u=-1/0,f=-1/0,p=-1/0,r=1/0,l=1/0,h=1/0,g=-1/0,_=-1/0,m=-1/0;for(let v=e*6,y=(e+t)*6;v<y;v+=6){const x=n[v+0],w=n[v+1],b=x-w,A=x+w;b<a&&(a=b),A>u&&(u=A),x<r&&(r=x),x>g&&(g=x);const T=n[v+2],I=n[v+3],C=T-I,P=T+I;C<o&&(o=C),P>f&&(f=P),T<l&&(l=T),T>_&&(_=T);const D=n[v+4],S=n[v+5],M=D-S,R=D+S;M<c&&(c=M),R>p&&(p=R),D<h&&(h=D),D>m&&(m=D)}i[0]=a,i[1]=o,i[2]=c,i[3]=u,i[4]=f,i[5]=p,s[0]=r,s[1]=l,s[2]=h,s[3]=g,s[4]=_,s[5]=m}function pl(n,e=null,t=null,i=null){const s=n.attributes.position,a=n.index?n.index.array:null,o=ut(n),c=s.normalized;let u;e===null?(u=new Float32Array(o*6*4),t=0,i=o):(u=e,t=t||0,i=i||o);const f=s.array,p=s.offset||0;let r=3;s.isInterleavedBufferAttribute&&(r=s.data.stride);const l=["getX","getY","getZ"];for(let h=t;h<t+i;h++){const g=h*3,_=h*6;let m=g+0,v=g+1,y=g+2;a&&(m=a[m],v=a[v],y=a[y]),c||(m=m*r+p,v=v*r+p,y=y*r+p);for(let x=0;x<3;x++){let w,b,A;c?(w=s[l[x]](m),b=s[l[x]](v),A=s[l[x]](y)):(w=f[m+x],b=f[v+x],A=f[y+x]);let T=w;b<T&&(T=b),A<T&&(T=A);let I=w;b>I&&(I=b),A>I&&(I=A);const C=(I-T)/2,P=x*2;u[_+P+0]=T+C,u[_+P+1]=C+(Math.abs(T)+C)*cl}}return u}function N(n,e,t){return t.min.x=e[n],t.min.y=e[n+1],t.min.z=e[n+2],t.max.x=e[n+3],t.max.y=e[n+4],t.max.z=e[n+5],t}function Js(n){let e=-1,t=-1/0;for(let i=0;i<3;i++){const s=n[i+3]-n[i];s>t&&(t=s,e=i)}return e}function $s(n,e){e.set(n)}function er(n,e,t){let i,s;for(let a=0;a<3;a++){const o=a+3;i=n[a],s=e[a],t[a]=i<s?i:s,i=n[o],s=e[o],t[o]=i>s?i:s}}function Ut(n,e,t){for(let i=0;i<3;i++){const s=e[n+2*i],a=e[n+2*i+1],o=s-a,c=s+a;o<t[i]&&(t[i]=o),c>t[i+3]&&(t[i+3]=c)}}function yt(n){const e=n[3]-n[0],t=n[4]-n[1],i=n[5]-n[2];return 2*(e*t+t*i+i*e)}const me=32,ml=(n,e)=>n.candidate-e.candidate,Te=new Array(me).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),Ht=new Float32Array(6);function gl(n,e,t,i,s,a){let o=-1,c=0;if(a===Fr)o=Js(e),o!==-1&&(c=(e[o]+e[o+3])/2);else if(a===al)o=Js(n),o!==-1&&(c=vl(t,i,s,o));else if(a===ll){const u=yt(n);let f=Ti*s;const p=i*6,r=(i+s)*6;for(let l=0;l<3;l++){const h=e[l],m=(e[l+3]-h)/me;if(s<me/4){const v=[...Te];v.length=s;let y=0;for(let w=p;w<r;w+=6,y++){const b=v[y];b.candidate=t[w+2*l],b.count=0;const{bounds:A,leftCacheBounds:T,rightCacheBounds:I}=b;for(let C=0;C<3;C++)I[C]=1/0,I[C+3]=-1/0,T[C]=1/0,T[C+3]=-1/0,A[C]=1/0,A[C+3]=-1/0;Ut(w,t,A)}v.sort(ml);let x=s;for(let w=0;w<x;w++){const b=v[w];for(;w+1<x&&v[w+1].candidate===b.candidate;)v.splice(w+1,1),x--}for(let w=p;w<r;w+=6){const b=t[w+2*l];for(let A=0;A<x;A++){const T=v[A];b>=T.candidate?Ut(w,t,T.rightCacheBounds):(Ut(w,t,T.leftCacheBounds),T.count++)}}for(let w=0;w<x;w++){const b=v[w],A=b.count,T=s-b.count,I=b.leftCacheBounds,C=b.rightCacheBounds;let P=0;A!==0&&(P=yt(I)/u);let D=0;T!==0&&(D=yt(C)/u);const S=Ks+Ti*(P*A+D*T);S<f&&(o=l,f=S,c=b.candidate)}}else{for(let x=0;x<me;x++){const w=Te[x];w.count=0,w.candidate=h+m+x*m;const b=w.bounds;for(let A=0;A<3;A++)b[A]=1/0,b[A+3]=-1/0}for(let x=p;x<r;x+=6){let A=~~((t[x+2*l]-h)/m);A>=me&&(A=me-1);const T=Te[A];T.count++,Ut(x,t,T.bounds)}const v=Te[me-1];$s(v.bounds,v.rightCacheBounds);for(let x=me-2;x>=0;x--){const w=Te[x],b=Te[x+1];er(w.bounds,b.rightCacheBounds,w.rightCacheBounds)}let y=0;for(let x=0;x<me-1;x++){const w=Te[x],b=w.count,A=w.bounds,I=Te[x+1].rightCacheBounds;b!==0&&(y===0?$s(A,Ht):er(A,Ht,Ht)),y+=b;let C=0,P=0;y!==0&&(C=yt(Ht)/u);const D=s-y;D!==0&&(P=yt(I)/u);const S=Ks+Ti*(C*y+P*D);S<f&&(o=l,f=S,c=w.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${a} used.`);return{axis:o,pos:c}}function vl(n,e,t,i){let s=0;for(let a=e,o=e+t;a<o;a++)s+=n[a*6+i*2];return s/t}class Ci{constructor(){this.boundingData=new Float32Array(6)}}function _l(n,e,t,i,s,a){let o=i,c=i+s-1;const u=a.pos,f=a.axis*2;for(;;){for(;o<=c&&t[o*6+f]<u;)o++;for(;o<=c&&t[c*6+f]>=u;)c--;if(o<c){for(let p=0;p<3;p++){let r=e[o*3+p];e[o*3+p]=e[c*3+p],e[c*3+p]=r}for(let p=0;p<6;p++){let r=t[o*6+p];t[o*6+p]=t[c*6+p],t[c*6+p]=r}o++,c--}else return o}}function yl(n,e,t,i,s,a){let o=i,c=i+s-1;const u=a.pos,f=a.axis*2;for(;;){for(;o<=c&&t[o*6+f]<u;)o++;for(;o<=c&&t[c*6+f]>=u;)c--;if(o<c){let p=n[o];n[o]=n[c],n[c]=p;for(let r=0;r<6;r++){let l=t[o*6+r];t[o*6+r]=t[c*6+r],t[c*6+r]=l}o++,c--}else return o}}function K(n,e){return e[n+15]===65535}function ee(n,e){return e[n+6]}function te(n,e){return e[n+14]}function ie(n){return n+8}function se(n,e){return e[n+6]}function Or(n,e){return e[n+7]}let zr,Mt,ii,Vr;const xl=Math.pow(2,32);function qi(n){return"count"in n?1:1+qi(n.left)+qi(n.right)}function wl(n,e,t){return zr=new Float32Array(t),Mt=new Uint32Array(t),ii=new Uint16Array(t),Vr=new Uint8Array(t),ji(n,e)}function ji(n,e){const t=n/4,i=n/2,s="count"in e,a=e.boundingData;for(let o=0;o<6;o++)zr[t+o]=a[o];if(s)if(e.buffer){const o=e.buffer;Vr.set(new Uint8Array(o),n);for(let c=n,u=n+o.byteLength;c<u;c+=Pt){const f=c/2;K(f,ii)||(Mt[c/4+6]+=t)}return n+o.byteLength}else{const o=e.offset,c=e.count;return Mt[t+6]=o,ii[i+14]=c,ii[i+15]=hi,n+Pt}else{const o=e.left,c=e.right,u=e.splitAxis;let f;if(f=ji(n+Pt,o),f/4>xl)throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return Mt[t+6]=f/4,f=ji(f,c),Mt[t+7]=u,f}}function bl(n,e){const t=(n.index?n.index.count:n.attributes.position.count)/3,i=t>2**16,s=i?4:2,a=e?new SharedArrayBuffer(t*s):new ArrayBuffer(t*s),o=i?new Uint32Array(a):new Uint16Array(a);for(let c=0,u=o.length;c<u;c++)o[c]=c;return o}function Al(n,e,t,i,s){const{maxDepth:a,verbose:o,maxLeafTris:c,strategy:u,onProgress:f,indirect:p}=s,r=n._indirectBuffer,l=n.geometry,h=l.index?l.index.array:null,g=p?yl:_l,_=ut(l),m=new Float32Array(6);let v=!1;const y=new Ci;return Mi(e,t,i,y.boundingData,m),w(y,t,i,m),y;function x(b){f&&f(b/_)}function w(b,A,T,I=null,C=0){if(!v&&C>=a&&(v=!0,o&&(console.warn(`MeshBVH: Max depth of ${a} reached when generating BVH. Consider increasing maxDepth.`),console.warn(l))),T<=c||C>=a)return x(A+T),b.offset=A,b.count=T,b;const P=gl(b.boundingData,I,e,A,T,u);if(P.axis===-1)return x(A+T),b.offset=A,b.count=T,b;const D=g(r,h,e,A,T,P);if(D===A||D===A+T)x(A+T),b.offset=A,b.count=T;else{b.splitAxis=P.axis;const S=new Ci,M=A,R=D-A;b.left=S,Mi(e,M,R,S.boundingData,m),w(S,M,R,m,C+1);const E=new Ci,F=D,O=T-R;b.right=E,Mi(e,F,O,E.boundingData,m),w(E,F,O,m,C+1)}return b}}function Tl(n,e){const t=n.geometry;e.indirect&&(n._indirectBuffer=bl(t,e.useSharedArrayBuffer),dl(t)&&!e.verbose&&console.warn('MeshBVH: Provided geometry contains groups that do not fully span the vertex contents while using the "indirect" option. BVH may incorrectly report intersections on unrendered portions of the geometry.')),n._indirectBuffer||fl(t,e);const i=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,s=pl(t),a=e.indirect?Br(t):kr(t);n._roots=a.map(o=>{const c=Al(n,s,o.offset,o.count,e),u=qi(c),f=new i(Pt*u);return wl(0,c,f),f})}class we{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let i=1/0,s=-1/0;for(let a=0,o=e.length;a<o;a++){const u=e[a][t];i=u<i?u:i,s=u>s?u:s}this.min=i,this.max=s}setFromPoints(e,t){let i=1/0,s=-1/0;for(let a=0,o=t.length;a<o;a++){const c=t[a],u=e.dot(c);i=u<i?u:i,s=u>s?u:s}this.min=i,this.max=s}isSeparated(e){return this.min>e.max||e.min>this.max}}we.prototype.setFromBox=function(){const n=new d.Vector3;return function(t,i){const s=i.min,a=i.max;let o=1/0,c=-1/0;for(let u=0;u<=1;u++)for(let f=0;f<=1;f++)for(let p=0;p<=1;p++){n.x=s.x*u+a.x*(1-u),n.y=s.y*f+a.y*(1-f),n.z=s.z*p+a.z*(1-p);const r=t.dot(n);o=Math.min(r,o),c=Math.max(r,c)}this.min=o,this.max=c}}();const Sl=function(){const n=new d.Vector3,e=new d.Vector3,t=new d.Vector3;return function(s,a,o){const c=s.start,u=n,f=a.start,p=e;t.subVectors(c,f),n.subVectors(s.end,s.start),e.subVectors(a.end,a.start);const r=t.dot(p),l=p.dot(u),h=p.dot(p),g=t.dot(u),m=u.dot(u)*h-l*l;let v,y;m!==0?v=(r*l-g*h)/m:v=0,y=(r+v*l)/h,o.x=v,o.y=y}}(),hs=function(){const n=new d.Vector2,e=new d.Vector3,t=new d.Vector3;return function(s,a,o,c){Sl(s,a,n);let u=n.x,f=n.y;if(u>=0&&u<=1&&f>=0&&f<=1){s.at(u,o),a.at(f,c);return}else if(u>=0&&u<=1){f<0?a.at(0,c):a.at(1,c),s.closestPointToPoint(c,!0,o);return}else if(f>=0&&f<=1){u<0?s.at(0,o):s.at(1,o),a.closestPointToPoint(o,!0,c);return}else{let p;u<0?p=s.start:p=s.end;let r;f<0?r=a.start:r=a.end;const l=e,h=t;if(s.closestPointToPoint(r,!0,e),a.closestPointToPoint(p,!0,t),l.distanceToSquared(r)<=h.distanceToSquared(p)){o.copy(l),c.copy(r);return}else{o.copy(p),c.copy(h);return}}}}(),Ml=function(){const n=new d.Vector3,e=new d.Vector3,t=new d.Plane,i=new d.Line3;return function(a,o){const{radius:c,center:u}=a,{a:f,b:p,c:r}=o;if(i.start=f,i.end=p,i.closestPointToPoint(u,!0,n).distanceTo(u)<=c||(i.start=f,i.end=r,i.closestPointToPoint(u,!0,n).distanceTo(u)<=c)||(i.start=p,i.end=r,i.closestPointToPoint(u,!0,n).distanceTo(u)<=c))return!0;const _=o.getPlane(t);if(Math.abs(_.distanceToPoint(u))<=c){const v=_.projectPoint(u,e);if(o.containsPoint(v))return!0}return!1}}(),Cl=1e-15;function Ii(n){return Math.abs(n)<Cl}class ce extends d.Triangle{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new d.Vector3),this.satBounds=new Array(4).fill().map(()=>new we),this.points=[this.a,this.b,this.c],this.sphere=new d.Sphere,this.plane=new d.Plane,this.needsUpdate=!0}intersectsSphere(e){return Ml(e,this)}update(){const e=this.a,t=this.b,i=this.c,s=this.points,a=this.satAxes,o=this.satBounds,c=a[0],u=o[0];this.getNormal(c),u.setFromPoints(c,s);const f=a[1],p=o[1];f.subVectors(e,t),p.setFromPoints(f,s);const r=a[2],l=o[2];r.subVectors(t,i),l.setFromPoints(r,s);const h=a[3],g=o[3];h.subVectors(i,e),g.setFromPoints(h,s),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(c,e),this.needsUpdate=!1}}ce.prototype.closestPointToSegment=function(){const n=new d.Vector3,e=new d.Vector3,t=new d.Line3;return function(s,a=null,o=null){const{start:c,end:u}=s,f=this.points;let p,r=1/0;for(let l=0;l<3;l++){const h=(l+1)%3;t.start.copy(f[l]),t.end.copy(f[h]),hs(t,s,n,e),p=n.distanceToSquared(e),p<r&&(r=p,a&&a.copy(n),o&&o.copy(e))}return this.closestPointToPoint(c,n),p=c.distanceToSquared(n),p<r&&(r=p,a&&a.copy(n),o&&o.copy(c)),this.closestPointToPoint(u,n),p=u.distanceToSquared(n),p<r&&(r=p,a&&a.copy(n),o&&o.copy(u)),Math.sqrt(r)}}();ce.prototype.intersectsTriangle=function(){const n=new ce,e=new Array(3),t=new Array(3),i=new we,s=new we,a=new d.Vector3,o=new d.Vector3,c=new d.Vector3,u=new d.Vector3,f=new d.Vector3,p=new d.Line3,r=new d.Line3,l=new d.Line3,h=new d.Vector3;function g(_,m,v){const y=_.points;let x=0,w=-1;for(let b=0;b<3;b++){const{start:A,end:T}=p;A.copy(y[b]),T.copy(y[(b+1)%3]),p.delta(o);const I=Ii(m.distanceToPoint(A));if(Ii(m.normal.dot(o))&&I){v.copy(p),x=2;break}const C=m.intersectLine(p,h);if(!C&&I&&h.copy(A),(C||I)&&!Ii(h.distanceTo(T))){if(x<=1)(x===1?v.start:v.end).copy(h),I&&(w=x);else if(x>=2){(w===1?v.start:v.end).copy(h),x=2;break}if(x++,x===2&&w===-1)break}}return x}return function(m,v=null,y=!1){this.needsUpdate&&this.update(),m.isExtendedTriangle?m.needsUpdate&&m.update():(n.copy(m),n.update(),m=n);const x=this.plane,w=m.plane;if(Math.abs(x.normal.dot(w.normal))>1-1e-10){const b=this.satBounds,A=this.satAxes;t[0]=m.a,t[1]=m.b,t[2]=m.c;for(let C=0;C<4;C++){const P=b[C],D=A[C];if(i.setFromPoints(D,t),P.isSeparated(i))return!1}const T=m.satBounds,I=m.satAxes;e[0]=this.a,e[1]=this.b,e[2]=this.c;for(let C=0;C<4;C++){const P=T[C],D=I[C];if(i.setFromPoints(D,e),P.isSeparated(i))return!1}for(let C=0;C<4;C++){const P=A[C];for(let D=0;D<4;D++){const S=I[D];if(a.crossVectors(P,S),i.setFromPoints(a,e),s.setFromPoints(a,t),i.isSeparated(s))return!1}}return v&&(y||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),v.start.set(0,0,0),v.end.set(0,0,0)),!0}else{const b=g(this,w,r);if(b===1&&m.containsPoint(r.end))return v&&(v.start.copy(r.end),v.end.copy(r.end)),!0;if(b!==2)return!1;const A=g(m,x,l);if(A===1&&this.containsPoint(l.end))return v&&(v.start.copy(l.end),v.end.copy(l.end)),!0;if(A!==2)return!1;if(r.delta(c),l.delta(u),c.dot(u)<0){let M=l.start;l.start=l.end,l.end=M}const T=r.start.dot(c),I=r.end.dot(c),C=l.start.dot(c),P=l.end.dot(c),D=I<C,S=T<P;return T!==P&&C!==I&&D===S?!1:(v&&(f.subVectors(r.start,l.start),f.dot(c)>0?v.start.copy(r.start):v.start.copy(l.start),f.subVectors(r.end,l.end),f.dot(c)<0?v.end.copy(r.end):v.end.copy(l.end)),!0)}}}();ce.prototype.distanceToPoint=function(){const n=new d.Vector3;return function(t){return this.closestPointToPoint(t,n),t.distanceTo(n)}}();ce.prototype.distanceToTriangle=function(){const n=new d.Vector3,e=new d.Vector3,t=["a","b","c"],i=new d.Line3,s=new d.Line3;return function(o,c=null,u=null){const f=c||u?i:null;if(this.intersectsTriangle(o,f))return(c||u)&&(c&&f.getCenter(c),u&&f.getCenter(u)),0;let p=1/0;for(let r=0;r<3;r++){let l;const h=t[r],g=o[h];this.closestPointToPoint(g,n),l=g.distanceToSquared(n),l<p&&(p=l,c&&c.copy(n),u&&u.copy(g));const _=this[h];o.closestPointToPoint(_,n),l=_.distanceToSquared(n),l<p&&(p=l,c&&c.copy(_),u&&u.copy(n))}for(let r=0;r<3;r++){const l=t[r],h=t[(r+1)%3];i.set(this[l],this[h]);for(let g=0;g<3;g++){const _=t[g],m=t[(g+1)%3];s.set(o[_],o[m]),hs(i,s,n,e);const v=n.distanceToSquared(e);v<p&&(p=v,c&&c.copy(n),u&&u.copy(e))}}return Math.sqrt(p)}}();class Q{constructor(e,t,i){this.isOrientedBox=!0,this.min=new d.Vector3,this.max=new d.Vector3,this.matrix=new d.Matrix4,this.invMatrix=new d.Matrix4,this.points=new Array(8).fill().map(()=>new d.Vector3),this.satAxes=new Array(3).fill().map(()=>new d.Vector3),this.satBounds=new Array(3).fill().map(()=>new we),this.alignedSatBounds=new Array(3).fill().map(()=>new we),this.needsUpdate=!1,e&&this.min.copy(e),t&&this.max.copy(t),i&&this.matrix.copy(i)}set(e,t,i){this.min.copy(e),this.max.copy(t),this.matrix.copy(i),this.needsUpdate=!0}copy(e){this.min.copy(e.min),this.max.copy(e.max),this.matrix.copy(e.matrix),this.needsUpdate=!0}}Q.prototype.update=function(){return function(){const e=this.matrix,t=this.min,i=this.max,s=this.points;for(let f=0;f<=1;f++)for(let p=0;p<=1;p++)for(let r=0;r<=1;r++){const l=1*f|2*p|4*r,h=s[l];h.x=f?i.x:t.x,h.y=p?i.y:t.y,h.z=r?i.z:t.z,h.applyMatrix4(e)}const a=this.satBounds,o=this.satAxes,c=s[0];for(let f=0;f<3;f++){const p=o[f],r=a[f],l=1<<f,h=s[l];p.subVectors(c,h),r.setFromPoints(p,s)}const u=this.alignedSatBounds;u[0].setFromPointsField(s,"x"),u[1].setFromPointsField(s,"y"),u[2].setFromPointsField(s,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}();Q.prototype.intersectsBox=function(){const n=new we;return function(t){this.needsUpdate&&this.update();const i=t.min,s=t.max,a=this.satBounds,o=this.satAxes,c=this.alignedSatBounds;if(n.min=i.x,n.max=s.x,c[0].isSeparated(n)||(n.min=i.y,n.max=s.y,c[1].isSeparated(n))||(n.min=i.z,n.max=s.z,c[2].isSeparated(n)))return!1;for(let u=0;u<3;u++){const f=o[u],p=a[u];if(n.setFromBox(f,t),p.isSeparated(n))return!1}return!0}}();Q.prototype.intersectsTriangle=function(){const n=new ce,e=new Array(3),t=new we,i=new we,s=new d.Vector3;return function(o){this.needsUpdate&&this.update(),o.isExtendedTriangle?o.needsUpdate&&o.update():(n.copy(o),n.update(),o=n);const c=this.satBounds,u=this.satAxes;e[0]=o.a,e[1]=o.b,e[2]=o.c;for(let l=0;l<3;l++){const h=c[l],g=u[l];if(t.setFromPoints(g,e),h.isSeparated(t))return!1}const f=o.satBounds,p=o.satAxes,r=this.points;for(let l=0;l<3;l++){const h=f[l],g=p[l];if(t.setFromPoints(g,r),h.isSeparated(t))return!1}for(let l=0;l<3;l++){const h=u[l];for(let g=0;g<4;g++){const _=p[g];if(s.crossVectors(h,_),t.setFromPoints(s,e),i.setFromPoints(s,r),t.isSeparated(i))return!1}}return!0}}();Q.prototype.closestPointToPoint=function(){return function(e,t){return this.needsUpdate&&this.update(),t.copy(e).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),t}}();Q.prototype.distanceToPoint=function(){const n=new d.Vector3;return function(t){return this.closestPointToPoint(t,n),t.distanceTo(n)}}();Q.prototype.distanceToBox=function(){const n=["x","y","z"],e=new Array(12).fill().map(()=>new d.Line3),t=new Array(12).fill().map(()=>new d.Line3),i=new d.Vector3,s=new d.Vector3;return function(o,c=0,u=null,f=null){if(this.needsUpdate&&this.update(),this.intersectsBox(o))return(u||f)&&(o.getCenter(s),this.closestPointToPoint(s,i),o.closestPointToPoint(i,s),u&&u.copy(i),f&&f.copy(s)),0;const p=c*c,r=o.min,l=o.max,h=this.points;let g=1/0;for(let m=0;m<8;m++){const v=h[m];s.copy(v).clamp(r,l);const y=v.distanceToSquared(s);if(y<g&&(g=y,u&&u.copy(v),f&&f.copy(s),y<p))return Math.sqrt(y)}let _=0;for(let m=0;m<3;m++)for(let v=0;v<=1;v++)for(let y=0;y<=1;y++){const x=(m+1)%3,w=(m+2)%3,b=v<<x|y<<w,A=1<<m|v<<x|y<<w,T=h[b],I=h[A];e[_].set(T,I);const P=n[m],D=n[x],S=n[w],M=t[_],R=M.start,E=M.end;R[P]=r[P],R[D]=v?r[D]:l[D],R[S]=y?r[S]:l[D],E[P]=l[P],E[D]=v?r[D]:l[D],E[S]=y?r[S]:l[D],_++}for(let m=0;m<=1;m++)for(let v=0;v<=1;v++)for(let y=0;y<=1;y++){s.x=m?l.x:r.x,s.y=v?l.y:r.y,s.z=y?l.z:r.z,this.closestPointToPoint(s,i);const x=s.distanceToSquared(i);if(x<g&&(g=x,u&&u.copy(i),f&&f.copy(s),x<p))return Math.sqrt(x)}for(let m=0;m<12;m++){const v=e[m];for(let y=0;y<12;y++){const x=t[y];hs(v,x,i,s);const w=i.distanceToSquared(s);if(w<g&&(g=w,u&&u.copy(i),f&&f.copy(s),w<p))return Math.sqrt(w)}}return Math.sqrt(g)}}();class fs{constructor(e){this._getNewPrimitive=e,this._primitives=[]}getPrimitive(){const e=this._primitives;return e.length===0?this._getNewPrimitive():e.pop()}releasePrimitive(e){this._primitives.push(e)}}class Il extends fs{constructor(){super(()=>new ce)}}const re=new Il;class Rl{constructor(){this.float32Array=null,this.uint16Array=null,this.uint32Array=null;const e=[];let t=null;this.setBuffer=i=>{t&&e.push(t),t=i,this.float32Array=new Float32Array(i),this.uint16Array=new Uint16Array(i),this.uint32Array=new Uint32Array(i)},this.clearBuffer=()=>{t=null,this.float32Array=null,this.uint16Array=null,this.uint32Array=null,e.length!==0&&this.setBuffer(e.pop())}}}const U=new Rl;let Re,et;const He=[],Nt=new fs(()=>new d.Box3);function Pl(n,e,t,i,s,a){Re=Nt.getPrimitive(),et=Nt.getPrimitive(),He.push(Re,et),U.setBuffer(n._roots[e]);const o=Yi(0,n.geometry,t,i,s,a);U.clearBuffer(),Nt.releasePrimitive(Re),Nt.releasePrimitive(et),He.pop(),He.pop();const c=He.length;return c>0&&(et=He[c-1],Re=He[c-2]),o}function Yi(n,e,t,i,s=null,a=0,o=0){const{float32Array:c,uint16Array:u,uint32Array:f}=U;let p=n*2;if(K(p,u)){const l=ee(n,f),h=te(p,u);return N(n,c,Re),i(l,h,!1,o,a+n,Re)}else{let P=function(S){const{uint16Array:M,uint32Array:R}=U;let E=S*2;for(;!K(E,M);)S=ie(S),E=S*2;return ee(S,R)},D=function(S){const{uint16Array:M,uint32Array:R}=U;let E=S*2;for(;!K(E,M);)S=se(S,R),E=S*2;return ee(S,R)+te(E,M)};const l=ie(n),h=se(n,f);let g=l,_=h,m,v,y,x;if(s&&(y=Re,x=et,N(g,c,y),N(_,c,x),m=s(y),v=s(x),v<m)){g=h,_=l;const S=m;m=v,v=S,y=x}y||(y=Re,N(g,c,y));const w=K(g*2,u),b=t(y,w,m,o+1,a+g);let A;if(b===Xs){const S=P(g),R=D(g)-S;A=i(S,R,!0,o+1,a+g,y)}else A=b&&Yi(g,e,t,i,s,a,o+1);if(A)return!0;x=et,N(_,c,x);const T=K(_*2,u),I=t(x,T,v,o+1,a+_);let C;if(I===Xs){const S=P(_),R=D(_)-S;C=i(S,R,!0,o+1,a+_,x)}else C=I&&Yi(_,e,t,i,s,a,o+1);return!!C}}const xt=new d.Vector3,Ri=new d.Vector3;function Dl(n,e,t={},i=0,s=1/0){const a=i*i,o=s*s;let c=1/0,u=null;if(n.shapecast({boundsTraverseOrder:p=>(xt.copy(e).clamp(p.min,p.max),xt.distanceToSquared(e)),intersectsBounds:(p,r,l)=>l<c&&l<o,intersectsTriangle:(p,r)=>{p.closestPointToPoint(e,xt);const l=e.distanceToSquared(xt);return l<c&&(Ri.copy(xt),c=l,u=r),l<a}}),c===1/0)return null;const f=Math.sqrt(c);return t.point?t.point.copy(Ri):t.point=Ri.clone(),t.distance=f,t.faceIndex=u,t}const Ne=new d.Vector3,We=new d.Vector3,Ge=new d.Vector3,Wt=new d.Vector2,Gt=new d.Vector2,qt=new d.Vector2,tr=new d.Vector3,ir=new d.Vector3,sr=new d.Vector3,jt=new d.Vector3;function Ll(n,e,t,i,s,a,o,c){let u;if(a===d.BackSide?u=n.intersectTriangle(i,t,e,!0,s):u=n.intersectTriangle(e,t,i,a!==d.DoubleSide,s),u===null)return null;const f=n.origin.distanceTo(s);return f<o||f>c?null:{distance:f,point:s.clone()}}function El(n,e,t,i,s,a,o,c,u,f,p){Ne.fromBufferAttribute(e,a),We.fromBufferAttribute(e,o),Ge.fromBufferAttribute(e,c);const r=Ll(n,Ne,We,Ge,jt,u,f,p);if(r){i&&(Wt.fromBufferAttribute(i,a),Gt.fromBufferAttribute(i,o),qt.fromBufferAttribute(i,c),r.uv=d.Triangle.getInterpolation(jt,Ne,We,Ge,Wt,Gt,qt,new d.Vector2)),s&&(Wt.fromBufferAttribute(s,a),Gt.fromBufferAttribute(s,o),qt.fromBufferAttribute(s,c),r.uv1=d.Triangle.getInterpolation(jt,Ne,We,Ge,Wt,Gt,qt,new d.Vector2)),t&&(tr.fromBufferAttribute(t,a),ir.fromBufferAttribute(t,o),sr.fromBufferAttribute(t,c),r.normal=d.Triangle.getInterpolation(jt,Ne,We,Ge,tr,ir,sr,new d.Vector3),r.normal.dot(n.direction)>0&&r.normal.multiplyScalar(-1));const l={a,b:o,c,normal:new d.Vector3,materialIndex:0};d.Triangle.getNormal(Ne,We,Ge,l.normal),r.face=l,r.faceIndex=a}return r}function fi(n,e,t,i,s,a,o){const c=i*3;let u=c+0,f=c+1,p=c+2;const r=n.index;n.index&&(u=r.getX(u),f=r.getX(f),p=r.getX(p));const{position:l,normal:h,uv:g,uv1:_}=n.attributes,m=El(t,l,h,g,_,u,f,p,e,a,o);return m?(m.faceIndex=i,s&&s.push(m),m):null}function G(n,e,t,i){const s=n.a,a=n.b,o=n.c;let c=e,u=e+1,f=e+2;t&&(c=t.getX(c),u=t.getX(u),f=t.getX(f)),s.x=i.getX(c),s.y=i.getY(c),s.z=i.getZ(c),a.x=i.getX(u),a.y=i.getY(u),a.z=i.getZ(u),o.x=i.getX(f),o.y=i.getY(f),o.z=i.getZ(f)}function Fl(n,e,t,i,s,a,o,c){const{geometry:u,_indirectBuffer:f}=n;for(let p=i,r=i+s;p<r;p++)fi(u,e,t,p,a,o,c)}function Bl(n,e,t,i,s,a,o){const{geometry:c,_indirectBuffer:u}=n;let f=1/0,p=null;for(let r=i,l=i+s;r<l;r++){let h;h=fi(c,e,t,r,null,a,o),h&&h.distance<f&&(p=h,f=h.distance)}return p}function kl(n,e,t,i,s,a,o){const{geometry:c}=t,{index:u}=c,f=c.attributes.position;for(let p=n,r=e+n;p<r;p++){let l;if(l=p,G(o,l*3,u,f),o.needsUpdate=!0,i(o,l,s,a))return!0}return!1}function Ol(n,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=n.geometry,i=t.index?t.index.array:null,s=t.attributes.position;let a,o,c,u,f=0;const p=n._roots;for(let l=0,h=p.length;l<h;l++)a=p[l],o=new Uint32Array(a),c=new Uint16Array(a),u=new Float32Array(a),r(0,f),f+=a.byteLength;function r(l,h,g=!1){const _=l*2;if(c[_+15]===hi){const v=o[l+6],y=c[_+14];let x=1/0,w=1/0,b=1/0,A=-1/0,T=-1/0,I=-1/0;for(let C=3*v,P=3*(v+y);C<P;C++){let D=i[C];const S=s.getX(D),M=s.getY(D),R=s.getZ(D);S<x&&(x=S),S>A&&(A=S),M<w&&(w=M),M>T&&(T=M),R<b&&(b=R),R>I&&(I=R)}return u[l+0]!==x||u[l+1]!==w||u[l+2]!==b||u[l+3]!==A||u[l+4]!==T||u[l+5]!==I?(u[l+0]=x,u[l+1]=w,u[l+2]=b,u[l+3]=A,u[l+4]=T,u[l+5]=I,!0):!1}else{const v=l+8,y=o[l+6],x=v+h,w=y+h;let b=g,A=!1,T=!1;e?b||(A=e.has(x),T=e.has(w),b=!A&&!T):(A=!0,T=!0);const I=b||A,C=b||T;let P=!1;I&&(P=r(v,h,b));let D=!1;C&&(D=r(y,h,b));const S=P||D;if(S)for(let M=0;M<3;M++){const R=v+M,E=y+M,F=u[R],O=u[R+3],H=u[E],W=u[E+3];u[l+M]=F<H?F:H,u[l+M+3]=O>W?O:W}return S}}}function Pe(n,e,t,i,s){let a,o,c,u,f,p;const r=1/t.direction.x,l=1/t.direction.y,h=1/t.direction.z,g=t.origin.x,_=t.origin.y,m=t.origin.z;let v=e[n],y=e[n+3],x=e[n+1],w=e[n+3+1],b=e[n+2],A=e[n+3+2];return r>=0?(a=(v-g)*r,o=(y-g)*r):(a=(y-g)*r,o=(v-g)*r),l>=0?(c=(x-_)*l,u=(w-_)*l):(c=(w-_)*l,u=(x-_)*l),a>u||c>o||((c>a||isNaN(a))&&(a=c),(u<o||isNaN(o))&&(o=u),h>=0?(f=(b-m)*h,p=(A-m)*h):(f=(A-m)*h,p=(b-m)*h),a>p||f>o)?!1:((f>a||a!==a)&&(a=f),(p<o||o!==o)&&(o=p),a<=s&&o>=i)}function zl(n,e,t,i,s,a,o,c){const{geometry:u,_indirectBuffer:f}=n;for(let p=i,r=i+s;p<r;p++){let l=f?f[p]:p;fi(u,e,t,l,a,o,c)}}function Vl(n,e,t,i,s,a,o){const{geometry:c,_indirectBuffer:u}=n;let f=1/0,p=null;for(let r=i,l=i+s;r<l;r++){let h;h=fi(c,e,t,u?u[r]:r,null,a,o),h&&h.distance<f&&(p=h,f=h.distance)}return p}function Ul(n,e,t,i,s,a,o){const{geometry:c}=t,{index:u}=c,f=c.attributes.position;for(let p=n,r=e+n;p<r;p++){let l;if(l=t.resolveTriangleIndex(p),G(o,l*3,u,f),o.needsUpdate=!0,i(o,l,s,a))return!0}return!1}function Hl(n,e,t,i,s,a,o){U.setBuffer(n._roots[e]),Qi(0,n,t,i,s,a,o),U.clearBuffer()}function Qi(n,e,t,i,s,a,o){const{float32Array:c,uint16Array:u,uint32Array:f}=U,p=n*2;if(K(p,u)){const l=ee(n,f),h=te(p,u);Fl(e,t,i,l,h,s,a,o)}else{const l=ie(n);Pe(l,c,i,a,o)&&Qi(l,e,t,i,s,a,o);const h=se(n,f);Pe(h,c,i,a,o)&&Qi(h,e,t,i,s,a,o)}}const Nl=["x","y","z"];function Wl(n,e,t,i,s,a){U.setBuffer(n._roots[e]);const o=Zi(0,n,t,i,s,a);return U.clearBuffer(),o}function Zi(n,e,t,i,s,a){const{float32Array:o,uint16Array:c,uint32Array:u}=U;let f=n*2;if(K(f,c)){const r=ee(n,u),l=te(f,c);return Bl(e,t,i,r,l,s,a)}else{const r=Or(n,u),l=Nl[r],g=i.direction[l]>=0;let _,m;g?(_=ie(n),m=se(n,u)):(_=se(n,u),m=ie(n));const y=Pe(_,o,i,s,a)?Zi(_,e,t,i,s,a):null;if(y){const b=y.point[l];if(g?b<=o[m+r]:b>=o[m+r+3])return y}const w=Pe(m,o,i,s,a)?Zi(m,e,t,i,s,a):null;return y&&w?y.distance<=w.distance?y:w:y||w||null}}const Yt=new d.Box3,qe=new ce,je=new ce,wt=new d.Matrix4,rr=new Q,Qt=new Q;function Gl(n,e,t,i){U.setBuffer(n._roots[e]);const s=Xi(0,n,t,i);return U.clearBuffer(),s}function Xi(n,e,t,i,s=null){const{float32Array:a,uint16Array:o,uint32Array:c}=U;let u=n*2;if(s===null&&(t.boundingBox||t.computeBoundingBox(),rr.set(t.boundingBox.min,t.boundingBox.max,i),s=rr),K(u,o)){const p=e.geometry,r=p.index,l=p.attributes.position,h=t.index,g=t.attributes.position,_=ee(n,c),m=te(u,o);if(wt.copy(i).invert(),t.boundsTree)return N(n,a,Qt),Qt.matrix.copy(wt),Qt.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:y=>Qt.intersectsBox(y),intersectsTriangle:y=>{y.a.applyMatrix4(i),y.b.applyMatrix4(i),y.c.applyMatrix4(i),y.needsUpdate=!0;for(let x=_*3,w=(m+_)*3;x<w;x+=3)if(G(je,x,r,l),je.needsUpdate=!0,y.intersectsTriangle(je))return!0;return!1}});for(let v=_*3,y=(m+_)*3;v<y;v+=3){G(qe,v,r,l),qe.a.applyMatrix4(wt),qe.b.applyMatrix4(wt),qe.c.applyMatrix4(wt),qe.needsUpdate=!0;for(let x=0,w=h.count;x<w;x+=3)if(G(je,x,h,g),je.needsUpdate=!0,qe.intersectsTriangle(je))return!0}}else{const p=n+8,r=c[n+6];return N(p,a,Yt),!!(s.intersectsBox(Yt)&&Xi(p,e,t,i,s)||(N(r,a,Yt),s.intersectsBox(Yt)&&Xi(r,e,t,i,s)))}}const Zt=new d.Matrix4,Pi=new Q,bt=new Q,ql=new d.Vector3,jl=new d.Vector3,Yl=new d.Vector3,Ql=new d.Vector3;function Zl(n,e,t,i={},s={},a=0,o=1/0){e.boundingBox||e.computeBoundingBox(),Pi.set(e.boundingBox.min,e.boundingBox.max,t),Pi.needsUpdate=!0;const c=n.geometry,u=c.attributes.position,f=c.index,p=e.attributes.position,r=e.index,l=re.getPrimitive(),h=re.getPrimitive();let g=ql,_=jl,m=null,v=null;s&&(m=Yl,v=Ql);let y=1/0,x=null,w=null;return Zt.copy(t).invert(),bt.matrix.copy(Zt),n.shapecast({boundsTraverseOrder:b=>Pi.distanceToBox(b),intersectsBounds:(b,A,T)=>T<y&&T<o?(A&&(bt.min.copy(b.min),bt.max.copy(b.max),bt.needsUpdate=!0),!0):!1,intersectsRange:(b,A)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:I=>bt.distanceToBox(I),intersectsBounds:(I,C,P)=>P<y&&P<o,intersectsRange:(I,C)=>{for(let P=I,D=I+C;P<D;P++){G(h,3*P,r,p),h.a.applyMatrix4(t),h.b.applyMatrix4(t),h.c.applyMatrix4(t),h.needsUpdate=!0;for(let S=b,M=b+A;S<M;S++){G(l,3*S,f,u),l.needsUpdate=!0;const R=l.distanceToTriangle(h,g,m);if(R<y&&(_.copy(g),v&&v.copy(m),y=R,x=S,w=P),R<a)return!0}}}});{const T=ut(e);for(let I=0,C=T;I<C;I++){G(h,3*I,r,p),h.a.applyMatrix4(t),h.b.applyMatrix4(t),h.c.applyMatrix4(t),h.needsUpdate=!0;for(let P=b,D=b+A;P<D;P++){G(l,3*P,f,u),l.needsUpdate=!0;const S=l.distanceToTriangle(h,g,m);if(S<y&&(_.copy(g),v&&v.copy(m),y=S,x=P,w=I),S<a)return!0}}}}}),re.releasePrimitive(l),re.releasePrimitive(h),y===1/0?null:(i.point?i.point.copy(_):i.point=_.clone(),i.distance=y,i.faceIndex=x,s&&(s.point?s.point.copy(v):s.point=v.clone(),s.point.applyMatrix4(Zt),_.applyMatrix4(Zt),s.distance=_.sub(s.point).length(),s.faceIndex=w),i)}function Xl(n,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=n.geometry,i=t.index?t.index.array:null,s=t.attributes.position;let a,o,c,u,f=0;const p=n._roots;for(let l=0,h=p.length;l<h;l++)a=p[l],o=new Uint32Array(a),c=new Uint16Array(a),u=new Float32Array(a),r(0,f),f+=a.byteLength;function r(l,h,g=!1){const _=l*2;if(c[_+15]===hi){const v=o[l+6],y=c[_+14];let x=1/0,w=1/0,b=1/0,A=-1/0,T=-1/0,I=-1/0;for(let C=v,P=v+y;C<P;C++){const D=3*n.resolveTriangleIndex(C);for(let S=0;S<3;S++){let M=D+S;M=i?i[M]:M;const R=s.getX(M),E=s.getY(M),F=s.getZ(M);R<x&&(x=R),R>A&&(A=R),E<w&&(w=E),E>T&&(T=E),F<b&&(b=F),F>I&&(I=F)}}return u[l+0]!==x||u[l+1]!==w||u[l+2]!==b||u[l+3]!==A||u[l+4]!==T||u[l+5]!==I?(u[l+0]=x,u[l+1]=w,u[l+2]=b,u[l+3]=A,u[l+4]=T,u[l+5]=I,!0):!1}else{const v=l+8,y=o[l+6],x=v+h,w=y+h;let b=g,A=!1,T=!1;e?b||(A=e.has(x),T=e.has(w),b=!A&&!T):(A=!0,T=!0);const I=b||A,C=b||T;let P=!1;I&&(P=r(v,h,b));let D=!1;C&&(D=r(y,h,b));const S=P||D;if(S)for(let M=0;M<3;M++){const R=v+M,E=y+M,F=u[R],O=u[R+3],H=u[E],W=u[E+3];u[l+M]=F<H?F:H,u[l+M+3]=O>W?O:W}return S}}}function Kl(n,e,t,i,s,a,o){U.setBuffer(n._roots[e]),Ki(0,n,t,i,s,a,o),U.clearBuffer()}function Ki(n,e,t,i,s,a,o){const{float32Array:c,uint16Array:u,uint32Array:f}=U,p=n*2;if(K(p,u)){const l=ee(n,f),h=te(p,u);zl(e,t,i,l,h,s,a,o)}else{const l=ie(n);Pe(l,c,i,a,o)&&Ki(l,e,t,i,s,a,o);const h=se(n,f);Pe(h,c,i,a,o)&&Ki(h,e,t,i,s,a,o)}}const Jl=["x","y","z"];function $l(n,e,t,i,s,a){U.setBuffer(n._roots[e]);const o=Ji(0,n,t,i,s,a);return U.clearBuffer(),o}function Ji(n,e,t,i,s,a){const{float32Array:o,uint16Array:c,uint32Array:u}=U;let f=n*2;if(K(f,c)){const r=ee(n,u),l=te(f,c);return Vl(e,t,i,r,l,s,a)}else{const r=Or(n,u),l=Jl[r],g=i.direction[l]>=0;let _,m;g?(_=ie(n),m=se(n,u)):(_=se(n,u),m=ie(n));const y=Pe(_,o,i,s,a)?Ji(_,e,t,i,s,a):null;if(y){const b=y.point[l];if(g?b<=o[m+r]:b>=o[m+r+3])return y}const w=Pe(m,o,i,s,a)?Ji(m,e,t,i,s,a):null;return y&&w?y.distance<=w.distance?y:w:y||w||null}}const Xt=new d.Box3,Ye=new ce,Qe=new ce,At=new d.Matrix4,nr=new Q,Kt=new Q;function ec(n,e,t,i){U.setBuffer(n._roots[e]);const s=$i(0,n,t,i);return U.clearBuffer(),s}function $i(n,e,t,i,s=null){const{float32Array:a,uint16Array:o,uint32Array:c}=U;let u=n*2;if(s===null&&(t.boundingBox||t.computeBoundingBox(),nr.set(t.boundingBox.min,t.boundingBox.max,i),s=nr),K(u,o)){const p=e.geometry,r=p.index,l=p.attributes.position,h=t.index,g=t.attributes.position,_=ee(n,c),m=te(u,o);if(At.copy(i).invert(),t.boundsTree)return N(n,a,Kt),Kt.matrix.copy(At),Kt.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:y=>Kt.intersectsBox(y),intersectsTriangle:y=>{y.a.applyMatrix4(i),y.b.applyMatrix4(i),y.c.applyMatrix4(i),y.needsUpdate=!0;for(let x=_,w=m+_;x<w;x++)if(G(Qe,3*e.resolveTriangleIndex(x),r,l),Qe.needsUpdate=!0,y.intersectsTriangle(Qe))return!0;return!1}});for(let v=_,y=m+_;v<y;v++){const x=e.resolveTriangleIndex(v);G(Ye,3*x,r,l),Ye.a.applyMatrix4(At),Ye.b.applyMatrix4(At),Ye.c.applyMatrix4(At),Ye.needsUpdate=!0;for(let w=0,b=h.count;w<b;w+=3)if(G(Qe,w,h,g),Qe.needsUpdate=!0,Ye.intersectsTriangle(Qe))return!0}}else{const p=n+8,r=c[n+6];return N(p,a,Xt),!!(s.intersectsBox(Xt)&&$i(p,e,t,i,s)||(N(r,a,Xt),s.intersectsBox(Xt)&&$i(r,e,t,i,s)))}}const Jt=new d.Matrix4,Di=new Q,Tt=new Q,tc=new d.Vector3,ic=new d.Vector3,sc=new d.Vector3,rc=new d.Vector3;function nc(n,e,t,i={},s={},a=0,o=1/0){e.boundingBox||e.computeBoundingBox(),Di.set(e.boundingBox.min,e.boundingBox.max,t),Di.needsUpdate=!0;const c=n.geometry,u=c.attributes.position,f=c.index,p=e.attributes.position,r=e.index,l=re.getPrimitive(),h=re.getPrimitive();let g=tc,_=ic,m=null,v=null;s&&(m=sc,v=rc);let y=1/0,x=null,w=null;return Jt.copy(t).invert(),Tt.matrix.copy(Jt),n.shapecast({boundsTraverseOrder:b=>Di.distanceToBox(b),intersectsBounds:(b,A,T)=>T<y&&T<o?(A&&(Tt.min.copy(b.min),Tt.max.copy(b.max),Tt.needsUpdate=!0),!0):!1,intersectsRange:(b,A)=>{if(e.boundsTree){const T=e.boundsTree;return T.shapecast({boundsTraverseOrder:I=>Tt.distanceToBox(I),intersectsBounds:(I,C,P)=>P<y&&P<o,intersectsRange:(I,C)=>{for(let P=I,D=I+C;P<D;P++){const S=T.resolveTriangleIndex(P);G(h,3*S,r,p),h.a.applyMatrix4(t),h.b.applyMatrix4(t),h.c.applyMatrix4(t),h.needsUpdate=!0;for(let M=b,R=b+A;M<R;M++){const E=n.resolveTriangleIndex(M);G(l,3*E,f,u),l.needsUpdate=!0;const F=l.distanceToTriangle(h,g,m);if(F<y&&(_.copy(g),v&&v.copy(m),y=F,x=M,w=P),F<a)return!0}}}})}else{const T=ut(e);for(let I=0,C=T;I<C;I++){G(h,3*I,r,p),h.a.applyMatrix4(t),h.b.applyMatrix4(t),h.c.applyMatrix4(t),h.needsUpdate=!0;for(let P=b,D=b+A;P<D;P++){const S=n.resolveTriangleIndex(P);G(l,3*S,f,u),l.needsUpdate=!0;const M=l.distanceToTriangle(h,g,m);if(M<y&&(_.copy(g),v&&v.copy(m),y=M,x=P,w=I),M<a)return!0}}}}}),re.releasePrimitive(l),re.releasePrimitive(h),y===1/0?null:(i.point?i.point.copy(_):i.point=_.clone(),i.distance=y,i.faceIndex=x,s&&(s.point?s.point.copy(v):s.point=v.clone(),s.point.applyMatrix4(Jt),_.applyMatrix4(Jt),s.distance=_.sub(s.point).length(),s.faceIndex=w),i)}function oc(){return typeof SharedArrayBuffer<"u"}const Dt=new U.constructor,oi=new U.constructor,Me=new fs(()=>new d.Box3),Ze=new d.Box3,Xe=new d.Box3,Li=new d.Box3,Ei=new d.Box3;let Fi=!1;function ac(n,e,t,i){if(Fi)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");Fi=!0;const s=n._roots,a=e._roots;let o,c=0,u=0;const f=new d.Matrix4().copy(t).invert();for(let p=0,r=s.length;p<r;p++){Dt.setBuffer(s[p]),u=0;const l=Me.getPrimitive();N(0,Dt.float32Array,l),l.applyMatrix4(f);for(let h=0,g=a.length;h<g&&(oi.setBuffer(a[p]),o=ae(0,0,t,f,i,c,u,0,0,l),oi.clearBuffer(),u+=a[h].length,!o);h++);if(Me.releasePrimitive(l),Dt.clearBuffer(),c+=s[p].length,o)break}return Fi=!1,o}function ae(n,e,t,i,s,a=0,o=0,c=0,u=0,f=null,p=!1){let r,l;p?(r=oi,l=Dt):(r=Dt,l=oi);const h=r.float32Array,g=r.uint32Array,_=r.uint16Array,m=l.float32Array,v=l.uint32Array,y=l.uint16Array,x=n*2,w=e*2,b=K(x,_),A=K(w,y);let T=!1;if(A&&b)p?T=s(ee(e,v),te(e*2,y),ee(n,g),te(n*2,_),u,o+e,c,a+n):T=s(ee(n,g),te(n*2,_),ee(e,v),te(e*2,y),c,a+n,u,o+e);else if(A){const I=Me.getPrimitive();N(e,m,I),I.applyMatrix4(t);const C=ie(n),P=se(n,g);N(C,h,Ze),N(P,h,Xe);const D=I.intersectsBox(Ze),S=I.intersectsBox(Xe);T=D&&ae(e,C,i,t,s,o,a,u,c+1,I,!p)||S&&ae(e,P,i,t,s,o,a,u,c+1,I,!p),Me.releasePrimitive(I)}else{const I=ie(e),C=se(e,v);N(I,m,Li),N(C,m,Ei);const P=f.intersectsBox(Li),D=f.intersectsBox(Ei);if(P&&D)T=ae(n,I,t,i,s,a,o,c,u+1,f,p)||ae(n,C,t,i,s,a,o,c,u+1,f,p);else if(P)if(b)T=ae(n,I,t,i,s,a,o,c,u+1,f,p);else{const S=Me.getPrimitive();S.copy(Li).applyMatrix4(t);const M=ie(n),R=se(n,g);N(M,h,Ze),N(R,h,Xe);const E=S.intersectsBox(Ze),F=S.intersectsBox(Xe);T=E&&ae(I,M,i,t,s,o,a,u,c+1,S,!p)||F&&ae(I,R,i,t,s,o,a,u,c+1,S,!p),Me.releasePrimitive(S)}else if(D)if(b)T=ae(n,C,t,i,s,a,o,c,u+1,f,p);else{const S=Me.getPrimitive();S.copy(Ei).applyMatrix4(t);const M=ie(n),R=se(n,g);N(M,h,Ze),N(R,h,Xe);const E=S.intersectsBox(Ze),F=S.intersectsBox(Xe);T=E&&ae(C,M,i,t,s,o,a,u,c+1,S,!p)||F&&ae(C,R,i,t,s,o,a,u,c+1,S,!p),Me.releasePrimitive(S)}}return T}const $t=new Q,or=new d.Box3,lc={strategy:Fr,maxDepth:40,maxLeafTris:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0};class ds{static serialize(e,t={}){t={cloneBuffers:!0,...t};const i=e.geometry,s=e._roots,a=e._indirectBuffer,o=i.getIndex();let c;return t.cloneBuffers?c={roots:s.map(u=>u.slice()),index:o?o.array.slice():null,indirectBuffer:a?a.slice():null}:c={roots:s,index:o?o.array:null,indirectBuffer:a},c}static deserialize(e,t,i={}){i={setIndex:!0,indirect:!!e.indirectBuffer,...i};const{index:s,roots:a,indirectBuffer:o}=e,c=new ds(t,{...i,[Si]:!0});if(c._roots=a,c._indirectBuffer=o||null,i.setIndex){const u=t.getIndex();if(u===null){const f=new d.BufferAttribute(e.index,1,!1);t.setIndex(f)}else u.array!==s&&(u.array.set(s),u.needsUpdate=!0)}return c}get indirect(){return!!this._indirectBuffer}constructor(e,t={}){if(e.isBufferGeometry){if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(t=Object.assign({...lc,[Si]:!1},t),t.useSharedArrayBuffer&&!oc())throw new Error("MeshBVH: SharedArrayBuffer is not available.");this.geometry=e,this._roots=null,this._indirectBuffer=null,t[Si]||(Tl(this,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new d.Box3))),this.resolveTriangleIndex=t.indirect?i=>this._indirectBuffer[i]:i=>i}refit(e=null){return(this.indirect?Xl:Ol)(this,e)}traverse(e,t=0){const i=this._roots[t],s=new Uint32Array(i),a=new Uint16Array(i);o(0);function o(c,u=0){const f=c*2,p=a[f+15]===hi;if(p){const r=s[c+6],l=a[f+14];e(u,p,new Float32Array(i,c*4,6),r,l)}else{const r=c+Pt/4,l=s[c+6],h=s[c+7];e(u,p,new Float32Array(i,c*4,6),h)||(o(r,u+1),o(l,u+1))}}}raycast(e,t=d.FrontSide,i=0,s=1/0){const a=this._roots,o=this.geometry,c=[],u=t.isMaterial,f=Array.isArray(t),p=o.groups,r=u?t.side:t,l=this.indirect?Kl:Hl;for(let h=0,g=a.length;h<g;h++){const _=f?t[p[h].materialIndex].side:r,m=c.length;if(l(this,h,_,e,c,i,s),f){const v=p[h].materialIndex;for(let y=m,x=c.length;y<x;y++)c[y].face.materialIndex=v}}return c}raycastFirst(e,t=d.FrontSide,i=0,s=1/0){const a=this._roots,o=this.geometry,c=t.isMaterial,u=Array.isArray(t);let f=null;const p=o.groups,r=c?t.side:t,l=this.indirect?$l:Wl;for(let h=0,g=a.length;h<g;h++){const _=u?t[p[h].materialIndex].side:r,m=l(this,h,_,e,i,s);m!=null&&(f==null||m.distance<f.distance)&&(f=m,u&&(m.face.materialIndex=p[h].materialIndex))}return f}intersectsGeometry(e,t){let i=!1;const s=this._roots,a=this.indirect?ec:Gl;for(let o=0,c=s.length;o<c&&(i=a(this,o,e,t),!i);o++);return i}shapecast(e){const t=re.getPrimitive(),i=this.indirect?Ul:kl;let{boundsTraverseOrder:s,intersectsBounds:a,intersectsRange:o,intersectsTriangle:c}=e;if(o&&c){const r=o;o=(l,h,g,_,m)=>r(l,h,g,_,m)?!0:i(l,h,this,c,g,_,t)}else o||(c?o=(r,l,h,g)=>i(r,l,this,c,h,g,t):o=(r,l,h)=>h);let u=!1,f=0;const p=this._roots;for(let r=0,l=p.length;r<l;r++){const h=p[r];if(u=Pl(this,r,a,o,s,f),u)break;f+=h.byteLength}return re.releasePrimitive(t),u}bvhcast(e,t,i){let{intersectsRanges:s,intersectsTriangles:a}=i;const o=re.getPrimitive(),c=this.geometry.index,u=this.geometry.attributes.position,f=this.indirect?g=>{const _=this.resolveTriangleIndex(g);G(o,_*3,c,u)}:g=>{G(o,g*3,c,u)},p=re.getPrimitive(),r=e.geometry.index,l=e.geometry.attributes.position,h=e.indirect?g=>{const _=e.resolveTriangleIndex(g);G(p,_*3,r,l)}:g=>{G(p,g*3,r,l)};if(a){const g=(_,m,v,y,x,w,b,A)=>{for(let T=v,I=v+y;T<I;T++){h(T),p.a.applyMatrix4(t),p.b.applyMatrix4(t),p.c.applyMatrix4(t),p.needsUpdate=!0;for(let C=_,P=_+m;C<P;C++)if(f(C),o.needsUpdate=!0,a(o,p,C,T,x,w,b,A))return!0}return!1};if(s){const _=s;s=function(m,v,y,x,w,b,A,T){return _(m,v,y,x,w,b,A,T)?!0:g(m,v,y,x,w,b,A,T)}}else s=g}return ac(this,e,t,s)}intersectsBox(e,t){return $t.set(e.min,e.max,t),$t.needsUpdate=!0,this.shapecast({intersectsBounds:i=>$t.intersectsBox(i),intersectsTriangle:i=>$t.intersectsTriangle(i)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,i={},s={},a=0,o=1/0){return(this.indirect?nc:Zl)(this,e,t,i,s,a,o)}closestPointToPoint(e,t={},i=0,s=1/0){return Dl(this,e,t,i,s)}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(i=>{N(0,new Float32Array(i),or),e.union(or)}),e}}class cc{constructor(e){this.name="WorkerBase",this.running=!1,this.worker=e,this.worker.onerror=t=>{throw t.message?new Error(`${this.name}: Could not create Web Worker with error "${t.message}"`):new Error(`${this.name}: Could not create Web Worker.`)}}runTask(){}generate(...e){if(this.running)throw new Error("GenerateMeshBVHWorker: Already running job.");if(this.worker===null)throw new Error("GenerateMeshBVHWorker: Worker has been disposed.");this.running=!0;const t=this.runTask(this.worker,...e);return t.finally(()=>{this.running=!1}),t}dispose(){this.worker.terminate(),this.worker=null}}class uc extends cc{constructor(e){const t=new Worker(e||new URL("data:text/javascript;base64,aW1wb3J0IHsKCUJ1ZmZlckdlb21ldHJ5LAoJQnVmZmVyQXR0cmlidXRlLAp9IGZyb20gJ3RocmVlJzsKaW1wb3J0IHsgTWVzaEJWSCB9IGZyb20gJy4uL2NvcmUvTWVzaEJWSC5qcyc7Cgpvbm1lc3NhZ2UgPSAoIHsgZGF0YSB9ICkgPT4gewoKCWxldCBwcmV2VGltZSA9IHBlcmZvcm1hbmNlLm5vdygpOwoJZnVuY3Rpb24gb25Qcm9ncmVzc0NhbGxiYWNrKCBwcm9ncmVzcyApIHsKCgkJLy8gYWNjb3VudCBmb3IgZXJyb3IKCQlwcm9ncmVzcyA9IE1hdGgub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YWxJbmRleCApOwoKCQkJfQoKCQl9CgoJCWNvbnN0IGJ2aCA9IG5ldyBNZXNoQlZIKCBnZW9tZXRyeSwgb3B0aW9ucyApOwoJCWNvbnN0IHNlcmlhbGl6ZWQgPSBNZXNoQlZILnNlcmlhbGl6ZSggYnZoLCB7IGNvcHlJbmRleEJ1ZmZlcjogZmFsc2UgfSApOwoJCWxldCB0b1RyYW5zZmVyID0gWyBwb3NpdGlvbi5idWZmZXIsIC4uLnNlcmlhbGl6ZWQucm9vdHMgXTsKCQlpZiAoIHNlcmlhbGl6ZWQuaW5kZXggKSB7CgoJCQl0b1RyYW5zZmVyLnB1c2goIHNlcmlhbGl6ZWQuaW5kZXguYnVmZmVyICk7CgoJCX0KCgkJdG9UcmFuc2ZlciA9IHRvVHJhbnNmZXIuZmlsdGVyKCB2ID0+ICggdHlwZW9mIFNoYXJlZEFycmF5QnVmZmVyID09PSAndW5kZWZpbmVkJyApIHx8ICEgKCB2IGluc3RhbmNlb2YgU2hhcmVkQXJyYXlCdWZmZXIgKSApOwoKCQlpZiAoIGJ2aC5faW5kaXJlY3RCdWZmZXIgKSB7CgoJCQl0b1RyYW5zZmVyLnB1c2goIHNlcmlhbGl6ZWQuaW5kaXJlY3RCdWZmZXIuYnVmZmVyICk7CgoJCX0KCgkJcG9zdE1lc3NhZ2UoIHsKCgkJCWVycm9yOiBudWxsLAoJCQlzZXJpYWxpemVkLAoJCQlwb3NpdGlvbiwKCQkJcHJvZ3Jlc3M6IDEsCgoJCX0sIHRvVHJhbnNmZXIgKTsKCgl9IGNhdGNoICggZXJyb3IgKSB7CgoJCXBvc3RNZXNzYWdlKCB7CgoJCQllcnJvciwKCQkJc2VyaWFsaXplZDogbnVsbCwKCQkJcG9zaXRpb246IG51bGwsCgkJCXByb2dyZXNzOiAxLAoKCQl9ICk7CgoJfQoKfTsK",typeof document>"u"?require("url").pathToFileURL(__filename).href:ot&&ot.src||new URL("shop-components.cjs",document.baseURI).href),{type:"module"});super(t),this.name="GenerateMeshBVHWorker"}runTask(e,t,i={}){return new Promise((s,a)=>{if(t.getAttribute("position").isInterleavedBufferAttribute||t.index&&t.index.isInterleavedBufferAttribute)throw new Error("GenerateMeshBVHWorker: InterleavedBufferAttribute are not supported for the geometry attributes.");e.onerror=f=>{a(new Error(`GenerateMeshBVHWorker: ${f.message}`))},e.onmessage=f=>{const{data:p}=f;if(p.error)a(new Error(p.error)),e.onmessage=null;else if(p.serialized){const{serialized:r,position:l}=p,h=ds.deserialize(r,t,{setIndex:!1}),g=Object.assign({setBoundingBox:!0},i);if(t.attributes.position.array=l,r.index)if(t.index)t.index.array=r.index;else{const _=new d.BufferAttribute(r.index,1,!1);t.setIndex(_)}g.setBoundingBox&&(t.boundingBox=h.getBoundingBox(new d.Box3)),i.onProgress&&i.onProgress(p.progress),s(h),e.onmessage=null}else i.onProgress&&i.onProgress(p.progress)};const o=t.index?t.index.array:null,c=t.attributes.position.array,u=[c];o&&u.push(o),e.postMessage({index:o,position:c,options:{...i,onProgress:null,includedProgressCallback:!!i.onProgress,groups:[...t.groups]}},u.map(f=>f.buffer).filter(f=>typeof SharedArrayBuffer>"u"||!(f instanceof SharedArrayBuffer)))})}}class hc{constructor(e,t){this.lock=!1,this.lockX=!1,this.lockY=!1,this.invRotMat=new d.Matrix4,this.mouse=new d.Vector3,this.rotateStart=new d.Vector2,this.rotateEnd=new d.Vector2,this.rotateDelta=new d.Vector2,this.selectedAxis=null,this.isDragging=!1,this.context=null,this.orbitState=!0,this._animator=0,this._emitter=new ct,this.addListener=this._emitter.addListener.bind(this._emitter),this.removeAllListeners=this._emitter.removeAllListeners.bind(this._emitter),this._text=document.createElement("div"),this._textTimer=0,this._update=()=>{this.lock||(this._textTimer&&(window.clearTimeout(this._textTimer),this._textTimer=0),this._textTimer=window.setTimeout(()=>{this._text.style.opacity="0"},800),this.camera.updateMatrix(),this.invRotMat.extractRotation(this.camera.matrix).invert(),this.axes.forEach(s=>{this.setAxisPosition(s)}),this.axes.sort((s,a)=>s.position.z>a.position.z?1:-1),this.drawLayers(!0),this._text.style.opacity="1",this._text.innerText=this.camera.position.distanceTo(this.orbit.target).toFixed(2)+" m")},this.updateMouseFromEvent=s=>{this.rect=this.domElement.getBoundingClientRect();const a=this.domElement.width/this.domElement.clientWidth,o=this.domElement.height/this.domElement.clientHeight,{left:c,top:u}=this.rect;this.mouse.set((s.clientX-c)*a,(s.clientY-u)*o,0)},this.updateSelectedAxisUnderMouse=()=>{this.selectedAxis=null,this.axes.forEach(s=>{this.mouse.distanceTo(s.position)<s.size&&(this.selectedAxis=s)})},this.onPointerDown=s=>{this.rotateStart.set(s.clientX,s.clientY),this.updateMouseFromEvent(s),this.updateSelectedAxisUnderMouse(),this.orbitState=this.orbit.enabled,this.orbit.enabled=!1,window.addEventListener("pointermove",this.onDrag,!1),window.addEventListener("pointerup",this.onPointerUp,!1)},this.onPointerUp=()=>{this.domElement.style.backgroundColor="#FFF0",setTimeout(()=>this.isDragging=!1,0),this.domElement.classList.remove("dragging"),this.orbit.enabled=this.orbitState,window.removeEventListener("pointermove",this.onDrag,!1),window.removeEventListener("pointerup",this.onPointerUp,!1)},this.onPointerEnter=()=>{this.domElement.style.backgroundColor="#FFF3",this.rect=this.domElement.getBoundingClientRect()},this.onPointerMove=s=>{if(this.lock||this.isDragging)return;const a=this.selectedAxis;s&&(this.updateMouseFromEvent(s),this.updateSelectedAxisUnderMouse()),a!==this.selectedAxis&&this.drawLayers()},this.onDrag=s=>{this.lock||(this.isDragging||this.domElement.classList.add("dragging"),this.isDragging=!0,this.selectedAxis=null,this.rotateEnd.set(s.clientX,s.clientY),this.rotateDelta.subVectors(this.rotateEnd,this.rotateStart).multiplyScalar(.5),this.rotateStart.copy(this.rotateEnd),this.orbit.update())},this.onMouseClick=s=>{if(this.lock||(this.updateMouseFromEvent(s),this.updateSelectedAxisUnderMouse(),this.isDragging||!this.selectedAxis))return;this._animator&&cancelAnimationFrame(this._animator);const a=this.selectedAxis.direction.clone();this.camera.lookAt(0,0,0);const o=this.camera.position.distanceTo(this.orbit.target);a.multiplyScalar(o),this.selectedAxis.axis==="z"?a.setZ(this.orbit.target.z+o):this.selectedAxis.axis==="-z"?a.setZ(this.orbit.target.z-o):a.setZ(this.orbit.target.z);const c=500,u=performance.now(),f=1,p=this.selectedAxis.axis,r=()=>{const h=performance.now()-u,g=Math.min(h/c,f);if(this.camera.position.lerp(a,g),this.orbit.update(),g!==f){this._animator=window.requestAnimationFrame(r);return}else this._animator=0,this.onPointerMove(void 0),this._emitter.emit("axis-select-end",p);this.onPointerMove(void 0)};this._emitter.emit("axis-select-start",p),r()},this.drawCircle=(s,a=10,o="#FF0000")=>{this.context&&(this.context.beginPath(),this.context.rect(s.x-a,s.y-a,a*2,a*2),this.context.fillStyle=o,this.context.fill(),this.context.closePath())},this.drawLine=(s,a,o=1,c="#FF0000")=>{this.context&&(this.context.beginPath(),this.context.moveTo(s.x,s.y),this.context.lineTo(a.x,a.y),this.context.lineWidth=o,this.context.strokeStyle=c,this.context.stroke(),this.context.closePath())},this.drawLayers=(s=!1)=>{this.context&&(s&&this.context.clearRect(0,0,this.domElement.width,this.domElement.height),this.axes.forEach(a=>{const o=this.selectedAxis===a,c=a.position.z>=-.01?a.color[0]:a.color[1];if(a.line&&this.drawLine(this.center,a.position,a.line,c),this.drawCircle(a.position,a.size,o?"#0066ff":c),a.label){const u=a.axis==="-x"?this.options.fontSize-3:this.options.fontSize;this.context.font=[this.options.fontWeight,u+"px",this.options.fontFamily].join(" "),this.context.fillStyle=this.options.fontColor,this.context.textBaseline="middle",this.context.textAlign="center",this.context.fillText(a.label,a.position.x,a.position.y)}}))},this.setAxisPosition=s=>{const a=s.direction.clone().applyMatrix4(this.invRotMat),o=s.size;s.position.set(a.x*(this.center.x-o/2-this.options.padding)+this.center.x,this.center.y-a.y*(this.center.y-o/2-this.options.padding),a.z)};const i={offset:new d.Vector2,size:90,padding:8,bubbleSizePrimary:8,bubbleSizeSecondary:6,lineWidth:2,fontSize:11,fontFamily:"arial",fontWeight:"normal",fontColor:"#fff",className:"orbit-controls-gizmo",colors:{x:["#f35f5f","#902525"],y:["#78da2f","#71ae45"],z:["#1d92fa","#d0d1d1"]}};this.options={...i,...t},this.orbit=e,this.camera=e.object,this.center=new d.Vector3(this.options.size/2,this.options.size/2,0),this.axes=this.createAxes(),this.domElement=this.createCanvas(this.options),this.orbit.addEventListener("change",this._update),this._text.style.cssText=`
|
|
3732
3732
|
transition: all 0.8s ease-in-out;
|
|
3733
3733
|
color: rgb(68, 78, 105);
|
|
3734
3734
|
position: absolute;
|
|
@@ -3797,4 +3797,4 @@ vec3 texelOld = texture2D(previousShadowMap, vUv).rgb;
|
|
|
3797
3797
|
user-select: none;
|
|
3798
3798
|
touch-action: none;
|
|
3799
3799
|
-webkit-touch-callout: none;
|
|
3800
|
-
`),this._controlsGizmo&&this._controlsGizmo.appendTo(e),this.stats.dom.style.bottom="0",this.stats.dom.style.top="auto",this.resize(),this._resizeObserver=new ResizeObserver(this.resize.bind(this)),this._resizeObserver.observe(e)}add(e){this._container.add(e)}updatePosition(){}removeFromParent(){var t;const e=this.renderer.domElement.parentElement;e&&((t=this._resizeObserver)==null||t.unobserve(e),e.removeChild(this.renderer.domElement))}clean(){this.amr.clean(),this._progressShadow.clear()}destroy(){var t,i,s;this._destroyed=!0,this._rafId!==null&&(cancelAnimationFrame(this._rafId),this._rafId=null),this._clock.stop(),(t=this._controlsGizmo)==null||t.destroy(),this.amr.destroy(),this.amr.removeFromParent(),this._progressShadow.destroy(),ye.removeAll(),this.stats.dom.remove(),this._emitter.removeAllListeners(),(i=this._fitAnimation)==null||i.stop(),window.removeEventListener("drag",this._drag),document.removeEventListener("wheel",this._detectTrackpad),window.removeEventListener("pointermove",this._pointermove),this.renderer.domElement.removeEventListener("pointerdown",this._pointerdown);const e=this.renderer.domElement.parentElement;e&&((s=this._resizeObserver)==null||s.unobserve(e)),this.controls.dispose(),this.renderer.domElement.remove(),this.renderer.dispose(),this._composer.dispose(),xe(this.scene),this.scene.clear()}}class Nr{constructor(e){this.deps=e,this.canvas=null,this.pixelBuffer=null,this.orthoCamera=new d.OrthographicCamera(-1,1,1,-1,.1,1e3),this.orthoCamera.position.set(0,0,5),this.perspectiveCamera=new d.PerspectiveCamera(45,1,.1,2e3)}async capture(e){var g,_,m,v,y,x;const t=this.deps.renderer,i=(e==null?void 0:e.subject)??this.deps.subject;if(!i)throw new Error("TriViewCapture: subject is required.");const s=new d.Vector2;t.getSize(s);const a=((g=e==null?void 0:e.size)==null?void 0:g.width)??Math.round(s.x),o=((_=e==null?void 0:e.size)==null?void 0:_.height)??Math.round(s.y),c=(e==null?void 0:e.margin)??.15,u=(e==null?void 0:e.includeOverlay)??!1,f=a/o||1,p=this.resolveViews(e==null?void 0:e.views),r=new d.WebGLRenderTarget(a,o,{format:d.RGBAFormat,type:d.UnsignedByteType});r.texture.colorSpace=d.SRGBColorSpace,r.texture.generateMipmaps=!1,r.depthBuffer=!0;const l=this.storeRendererState(t),h={};try{(v=(m=this.deps).onBeforeCapture)==null||v.call(m);const w=this.computeBounds(i);this.applyRendererState(t,a,o,e==null?void 0:e.backgroundColor);for(const b of p){const A=this.configureCamera(w,b,f,c,a,o);t.setRenderTarget(r),t.clear(!0,!0,!0),t.render(this.deps.scene,A),u&&this.deps.overlayScene&&(t.clearDepth(),t.render(this.deps.overlayScene,A));const T=this.readPixels(t,r,a,o);h[b.key]=T}}finally{r.dispose(),this.restoreRendererState(t,l),(x=(y=this.deps).onAfterCapture)==null||x.call(y)}return h}resolveViews(e){return e&&e.length?e.map(t=>({key:t.key,direction:t.direction.clone(),up:t.up.clone(),plane:t.plane})):[{key:"top",direction:new d.Vector3(0,0,1),up:new d.Vector3(0,1,0),plane:{width:"x",height:"y",depth:"z"}},{key:"front",direction:new d.Vector3(0,-1,0),up:new d.Vector3(0,0,1),plane:{width:"x",height:"z",depth:"y"}},{key:"side",direction:new d.Vector3(1,0,0),up:new d.Vector3(0,0,1),plane:{width:"y",height:"z",depth:"x"}},{key:"perspective",direction:new d.Vector3(1,1,1),up:new d.Vector3(0,0,1),plane:{width:"x",height:"z",depth:"y"},mode:"perspective",fov:39.6}]}computeBounds(e){const t=new d.Box3,i=new d.Box3,s=new d.Vector3,a=new d.Vector3,o=new d.Sphere;return e.updateMatrixWorld(!0),e.traverse(c=>{if(!c.visible)return;const f=c.geometry;if(!f)return;f.boundingBox||f.computeBoundingBox();const p=f.boundingBox;p&&(i.copy(p).applyMatrix4(c.matrixWorld),t.union(i))}),t.isEmpty()?(t.setFromCenterAndSize(s,new d.Vector3(.001,.001,.001)),a.set(.001,.001,.001),o.center.copy(s),o.radius=.001):(t.getCenter(s),t.getSize(a),t.getBoundingSphere(o)),(!Number.isFinite(o.radius)||o.radius<=0)&&(o.radius=Math.max(a.length()*.5,.001)),{box:t,center:s,size:a,sphere:o}}configureCamera(e,t,i,s,a,o){const c=t.direction.clone().normalize();c.lengthSq()===0&&c.set(0,0,1);const u=t.up.clone().normalize();if(Math.abs(u.dot(c))>.999&&(u.set(0,0,1),Math.abs(u.dot(c))>.999&&u.set(0,1,0)),(t.mode??"orthographic")==="perspective"){const w=this.perspectiveCamera,b=t.fov??45,A=d.MathUtils.degToRad(b),T=Math.max(Math.tan(A/2),1e-4),I=Math.max(T*(i||1),1e-4),C=this.getPerspectiveDirection(t,e.size).normalize(),P=new d.Vector3().crossVectors(C,u).normalize();P.lengthSq()<1e-6&&P.set(1,0,0);const D=new d.Vector3().crossVectors(P,C).normalize(),S=Math.max(e.size.x*.5,1e-4),M=Math.max(e.size.y*.5,1e-4),R=Math.max(e.size.z*.5,1e-4),E=[new d.Vector3(-S,-M,-R),new d.Vector3(-S,-M,R),new d.Vector3(-S,M,-R),new d.Vector3(-S,M,R),new d.Vector3(S,-M,-R),new d.Vector3(S,-M,R),new d.Vector3(S,M,-R),new d.Vector3(S,M,R)];let F=0,O=-1/0;for(const j of E){const Y=P.dot(j),pe=D.dot(j),ht=C.dot(j);O=Math.max(O,ht);const di=ht+Math.abs(Y)/I,ft=ht+Math.abs(pe)/T;F=Math.max(F,di,ft)}F=Math.max(F,O+.1);const H=F*(1+s);let W=1/0;for(const j of E){const Y=C.dot(j),pe=H-Y;pe>.001&&(W=Math.min(W,pe))}return w.fov=b,w.aspect=i||a/Math.max(o,1),w.near=Math.max(.1,Number.isFinite(W)?W*.5:H*.1),w.far=Math.max(w.near+1,H+e.sphere.radius*3),w.position.copy(e.center).add(C.clone().multiplyScalar(H)),w.up.copy(D),w.lookAt(e.center),w.updateProjectionMatrix(),w.updateMatrixWorld(!0),w}const p=this.orthoCamera,r=e.size,l=e.center,h=Math.max(r[t.plane.width]*.5,.01),g=Math.max(r[t.plane.height]*.5,.01),_=Math.max(r[t.plane.depth]*.5,.01);let m=h*(1+s),v=g*(1+s);m/i>v?v=m/i:m=v*i;const y=_*(1+s)+Math.max(m,v),x=l.clone().add(c.multiplyScalar(y));return p.left=-m,p.right=m,p.top=v,p.bottom=-v,p.near=.1,p.far=y*4,p.zoom=1,p.position.copy(x),p.up.copy(u),p.lookAt(l),p.updateProjectionMatrix(),p.updateMatrixWorld(!0),p}getPerspectiveDirection(e,t){const i=e.direction.clone();i.lengthSq()===0&&i.set(1,1,1);const s=new d.Vector3(Math.abs(i.x)||1,Math.abs(i.y)||1,Math.abs(i.z)||1),a=new d.Vector3(Math.sign(i.x||1),Math.sign(i.y||1),Math.sign(i.z||1)),o=.25,c=new d.Vector3(Math.max(o,s.x)*Math.max(t.x,.001),Math.max(o,s.y)*Math.max(t.y,.001),0),u=Math.max((t.x+t.y)*.5,.001),f=Math.max(t.z,.001),p=Math.max(o,s.z),r=f*.5+u*.5;return c.z=p*r,c.multiply(a),c}storeRendererState(e){const t=new d.Vector2;e.getSize(t);const i=new d.Vector4;e.getViewport(i);const s=new d.Vector4;e.getScissor(s);const a=e.getClearColor(new d.Color),o=e.getClearAlpha();return{size:t,pixelRatio:e.getPixelRatio(),viewport:i,scissor:s,scissorTest:e.getScissorTest(),autoClear:e.autoClear,target:e.getRenderTarget(),clearColor:a,clearAlpha:o}}applyRendererState(e,t,i,s){if(e.setPixelRatio(1),e.setSize(t,i,!1),e.setViewport(0,0,t,i),e.setScissor(0,0,t,i),e.setScissorTest(!1),e.autoClear=!0,s!==void 0)if(s===null){const a=e.getClearColor(new d.Color);e.setClearColor(a,0)}else s instanceof d.Color?e.setClearColor(s,1):e.setClearColor(new d.Color(s),1);else{const a=e.getClearColor(new d.Color);e.setClearColor(a,0)}}restoreRendererState(e,t){e.setPixelRatio(t.pixelRatio),e.setSize(t.size.x,t.size.y,!1),e.setViewport(t.viewport.x,t.viewport.y,t.viewport.z,t.viewport.w),e.setScissor(t.scissor.x,t.scissor.y,t.scissor.z,t.scissor.w),e.setScissorTest(t.scissorTest),e.autoClear=t.autoClear,e.setRenderTarget(t.target),e.setClearColor(t.clearColor,t.clearAlpha)}readPixels(e,t,i,s){const a=i*s*4;(!this.pixelBuffer||this.pixelBuffer.length!==a)&&(this.pixelBuffer=new Uint8Array(a)),e.readRenderTargetPixels(t,0,0,i,s,this.pixelBuffer);const o=this.ensureCanvas(i,s),c=o.getContext("2d");if(!c)throw new Error("TriViewCapture: failed to get 2D context.");const u=c.createImageData(i,s),f=u.data,p=this.pixelBuffer;for(let r=0;r<s;r+=1){const h=(s-r-1)*i*4,g=r*i*4;f.set(p.subarray(h,h+i*4),g)}return c.putImageData(u,0,0),o.toDataURL("image/png")}ensureCanvas(e,t){if(typeof document>"u")throw new Error("TriViewCapture: document is not available in this environment.");return this.canvas||(this.canvas=document.createElement("canvas")),(this.canvas.width!==e||this.canvas.height!==t)&&(this.canvas.width=e,this.canvas.height=t),this.canvas}}const bc="shop-components",Ac="0.3.4",Tc="Shop components",Sc="dist/shop-components.umd.js",Mc="dist/shop-components.mjs",Cc="dist/main.d.ts",Ic={dts:"tsc --emitDeclarationOnly & tsc & storybook build -o dist",dev:"vite dev",build:"vite build",v:"auto-changelog -p && git add CHANGELOG.md"},Rc=["dist","package.json"],Pc=[],Dc="machengda<machengda@seer-group.com>",Lc="ISC",Ec={"@needle-tools/gltf-progressive":"^3.3.5","auto-changelog":"^2.4.0",vite:"5.1.6","vite-plugin-dts":"^3.7.3"},Fc={"string-width":"4.2.3"},Bc={"@nodetoy/three-nodetoy":"^0.1.36","@tweakpane/core":"^2.0.3","@tweenjs/tween.js":"^23.1.2","@types/bezier-js":"^4.1.1","@types/howler":"^2.2.11","@types/three":"0.180.0","bezier-js":"^6.1.4",eventemitter3:"^5.0.1",howler:"^2.2.4","stats-fps.js":"0.0.6",stylus:"^0.63.0",terser:"^5.44.0",three:"^0.180.0","three-gpu-pathtracer":"^0.0.23","three-mesh-bvh":"^0.7.5","troika-three-text":"^0.49.1",tweakpane:"^4.0.3"},kc={name:bc,version:Ac,description:Tc,main:Sc,module:Mc,types:Cc,scripts:Ic,files:Rc,keywords:Pc,author:Dc,license:Lc,devDependencies:Ec,resolutions:Fc,dependencies:Bc};function lr(){const n="Nebular Engin",e=kc.version,t=`%c ${n} %c v${e} `;console.log(t,"background:#111827;color:#ffffff;padding:4px 10px;border-radius:4px 0 0 4px;font-weight:700;","background:#10B981;color:#ffffff;padding:4px 10px;border-radius:0 4px 4px 0;font-weight:700;")}const cr="__SHOP_COMPONENTS_BANNER_PRINTED__";try{const n=globalThis;n[cr]||(n[cr]=!0,lr())}catch{lr()}exports.Amr=Er;exports.Logo=Gi;exports.SGLBLoader=ni;exports.SLOT_EVENTS=q;exports.Scene3D=wc;exports.Skin=es;exports.Slot=Wi;exports.SlotState=Hr;exports.TriViewCapture=Nr;exports.arrayBufferToUrl=Hi;exports.calculateArrayAverage=Cr;exports.calculateFocalLength=Oa;exports.createSGLBFile=Ya;exports.downloadBlob=ka;exports.dracoExporter=ja;exports.font=_c;exports.gltfExporter=Pr;exports.gltfLoader=lt;exports.imageBitmapToUrl=Ni;exports.isAppleDevice=Ir;exports.textureLoader=us;
|
|
3800
|
+
`),this._controlsGizmo&&this._controlsGizmo.appendTo(e),this.stats.dom.style.bottom="0",this.stats.dom.style.top="auto",this.resize(),this._resizeObserver=new ResizeObserver(this.resize.bind(this)),this._resizeObserver.observe(e)}add(e){this._container.add(e)}updatePosition(){}removeFromParent(){var t;const e=this.renderer.domElement.parentElement;e&&((t=this._resizeObserver)==null||t.unobserve(e),e.removeChild(this.renderer.domElement))}clean(){this.amr.clean(),this._progressShadow.clear()}destroy(){var t,i,s;this._destroyed=!0,this._rafId!==null&&(cancelAnimationFrame(this._rafId),this._rafId=null),this._clock.stop(),(t=this._controlsGizmo)==null||t.destroy(),this.amr.destroy(),this.amr.removeFromParent(),this._progressShadow.destroy(),ye.removeAll(),this.stats.dom.remove(),this._emitter.removeAllListeners(),(i=this._fitAnimation)==null||i.stop(),window.removeEventListener("drag",this._drag),document.removeEventListener("wheel",this._detectTrackpad),window.removeEventListener("pointermove",this._pointermove),this.renderer.domElement.removeEventListener("pointerdown",this._pointerdown);const e=this.renderer.domElement.parentElement;e&&((s=this._resizeObserver)==null||s.unobserve(e)),this.controls.dispose(),this.renderer.domElement.remove(),this.renderer.dispose(),this._composer.dispose(),xe(this.scene),this.scene.clear()}}class Nr{constructor(e){this.deps=e,this.canvas=null,this.pixelBuffer=null,this.orthoCamera=new d.OrthographicCamera(-1,1,1,-1,.1,1e3),this.orthoCamera.position.set(0,0,5),this.perspectiveCamera=new d.PerspectiveCamera(45,1,.1,2e3)}async capture(e){var g,_,m,v,y,x;const t=this.deps.renderer,i=(e==null?void 0:e.subject)??this.deps.subject;if(!i)throw new Error("TriViewCapture: subject is required.");const s=new d.Vector2;t.getSize(s);const a=((g=e==null?void 0:e.size)==null?void 0:g.width)??Math.round(s.x),o=((_=e==null?void 0:e.size)==null?void 0:_.height)??Math.round(s.y),c=(e==null?void 0:e.margin)??.15,u=(e==null?void 0:e.includeOverlay)??!1,f=a/o||1,p=this.resolveViews(e==null?void 0:e.views),r=new d.WebGLRenderTarget(a,o,{format:d.RGBAFormat,type:d.UnsignedByteType});r.texture.colorSpace=d.SRGBColorSpace,r.texture.generateMipmaps=!1,r.depthBuffer=!0;const l=this.storeRendererState(t),h={};try{(v=(m=this.deps).onBeforeCapture)==null||v.call(m);const w=this.computeBounds(i);this.applyRendererState(t,a,o,e==null?void 0:e.backgroundColor);for(const b of p){const A=this.configureCamera(w,b,f,c,a,o);t.setRenderTarget(r),t.clear(!0,!0,!0),t.render(this.deps.scene,A),u&&this.deps.overlayScene&&(t.clearDepth(),t.render(this.deps.overlayScene,A));const T=this.readPixels(t,r,a,o);h[b.key]=T}}finally{r.dispose(),this.restoreRendererState(t,l),(x=(y=this.deps).onAfterCapture)==null||x.call(y)}return h}resolveViews(e){return e&&e.length?e.map(t=>({key:t.key,direction:t.direction.clone(),up:t.up.clone(),plane:t.plane})):[{key:"top",direction:new d.Vector3(0,0,1),up:new d.Vector3(0,1,0),plane:{width:"x",height:"y",depth:"z"}},{key:"front",direction:new d.Vector3(0,-1,0),up:new d.Vector3(0,0,1),plane:{width:"x",height:"z",depth:"y"}},{key:"side",direction:new d.Vector3(1,0,0),up:new d.Vector3(0,0,1),plane:{width:"y",height:"z",depth:"x"}},{key:"perspective",direction:new d.Vector3(1,1,1),up:new d.Vector3(0,0,1),plane:{width:"x",height:"z",depth:"y"},mode:"perspective",fov:39.6}]}computeBounds(e){const t=new d.Box3,i=new d.Box3,s=new d.Vector3,a=new d.Vector3,o=new d.Sphere;return e.updateMatrixWorld(!0),e.traverse(c=>{if(!c.visible)return;const f=c.geometry;if(!f)return;f.boundingBox||f.computeBoundingBox();const p=f.boundingBox;p&&(i.copy(p).applyMatrix4(c.matrixWorld),t.union(i))}),t.isEmpty()?(t.setFromCenterAndSize(s,new d.Vector3(.001,.001,.001)),a.set(.001,.001,.001),o.center.copy(s),o.radius=.001):(t.getCenter(s),t.getSize(a),t.getBoundingSphere(o)),(!Number.isFinite(o.radius)||o.radius<=0)&&(o.radius=Math.max(a.length()*.5,.001)),{box:t,center:s,size:a,sphere:o}}configureCamera(e,t,i,s,a,o){const c=t.direction.clone().normalize();c.lengthSq()===0&&c.set(0,0,1);const u=t.up.clone().normalize();if(Math.abs(u.dot(c))>.999&&(u.set(0,0,1),Math.abs(u.dot(c))>.999&&u.set(0,1,0)),(t.mode??"orthographic")==="perspective"){const w=this.perspectiveCamera,b=t.fov??45,A=d.MathUtils.degToRad(b),T=Math.max(Math.tan(A/2),1e-4),I=Math.max(T*(i||1),1e-4),C=this.getPerspectiveDirection(t,e.size).normalize(),P=new d.Vector3().crossVectors(C,u).normalize();P.lengthSq()<1e-6&&P.set(1,0,0);const D=new d.Vector3().crossVectors(P,C).normalize(),S=Math.max(e.size.x*.5,1e-4),M=Math.max(e.size.y*.5,1e-4),R=Math.max(e.size.z*.5,1e-4),E=[new d.Vector3(-S,-M,-R),new d.Vector3(-S,-M,R),new d.Vector3(-S,M,-R),new d.Vector3(-S,M,R),new d.Vector3(S,-M,-R),new d.Vector3(S,-M,R),new d.Vector3(S,M,-R),new d.Vector3(S,M,R)];let F=0,O=-1/0;for(const j of E){const Y=P.dot(j),pe=D.dot(j),ht=C.dot(j);O=Math.max(O,ht);const di=ht+Math.abs(Y)/I,ft=ht+Math.abs(pe)/T;F=Math.max(F,di,ft)}F=Math.max(F,O+.1);const H=F*(1+s);let W=1/0;for(const j of E){const Y=C.dot(j),pe=H-Y;pe>.001&&(W=Math.min(W,pe))}return w.fov=b,w.aspect=i||a/Math.max(o,1),w.near=Math.max(.1,Number.isFinite(W)?W*.5:H*.1),w.far=Math.max(w.near+1,H+e.sphere.radius*3),w.position.copy(e.center).add(C.clone().multiplyScalar(H)),w.up.copy(D),w.lookAt(e.center),w.updateProjectionMatrix(),w.updateMatrixWorld(!0),w}const p=this.orthoCamera,r=e.size,l=e.center,h=Math.max(r[t.plane.width]*.5,.01),g=Math.max(r[t.plane.height]*.5,.01),_=Math.max(r[t.plane.depth]*.5,.01);let m=h*(1+s),v=g*(1+s);m/i>v?v=m/i:m=v*i;const y=_*(1+s)+Math.max(m,v),x=l.clone().add(c.multiplyScalar(y));return p.left=-m,p.right=m,p.top=v,p.bottom=-v,p.near=.1,p.far=y*4,p.zoom=1,p.position.copy(x),p.up.copy(u),p.lookAt(l),p.updateProjectionMatrix(),p.updateMatrixWorld(!0),p}getPerspectiveDirection(e,t){const i=e.direction.clone();i.lengthSq()===0&&i.set(1,1,1);const s=new d.Vector3(Math.abs(i.x)||1,Math.abs(i.y)||1,Math.abs(i.z)||1),a=new d.Vector3(Math.sign(i.x||1),Math.sign(i.y||1),Math.sign(i.z||1)),o=.25,c=new d.Vector3(Math.max(o,s.x)*Math.max(t.x,.001),Math.max(o,s.y)*Math.max(t.y,.001),0),u=Math.max((t.x+t.y)*.5,.001),f=Math.max(t.z,.001),p=Math.max(o,s.z),r=f*.5+u*.5;return c.z=p*r,c.multiply(a),c}storeRendererState(e){const t=new d.Vector2;e.getSize(t);const i=new d.Vector4;e.getViewport(i);const s=new d.Vector4;e.getScissor(s);const a=e.getClearColor(new d.Color),o=e.getClearAlpha();return{size:t,pixelRatio:e.getPixelRatio(),viewport:i,scissor:s,scissorTest:e.getScissorTest(),autoClear:e.autoClear,target:e.getRenderTarget(),clearColor:a,clearAlpha:o}}applyRendererState(e,t,i,s){if(e.setPixelRatio(1),e.setSize(t,i,!1),e.setViewport(0,0,t,i),e.setScissor(0,0,t,i),e.setScissorTest(!1),e.autoClear=!0,s!==void 0)if(s===null){const a=e.getClearColor(new d.Color);e.setClearColor(a,0)}else s instanceof d.Color?e.setClearColor(s,1):e.setClearColor(new d.Color(s),1);else{const a=e.getClearColor(new d.Color);e.setClearColor(a,0)}}restoreRendererState(e,t){e.setPixelRatio(t.pixelRatio),e.setSize(t.size.x,t.size.y,!1),e.setViewport(t.viewport.x,t.viewport.y,t.viewport.z,t.viewport.w),e.setScissor(t.scissor.x,t.scissor.y,t.scissor.z,t.scissor.w),e.setScissorTest(t.scissorTest),e.autoClear=t.autoClear,e.setRenderTarget(t.target),e.setClearColor(t.clearColor,t.clearAlpha)}readPixels(e,t,i,s){const a=i*s*4;(!this.pixelBuffer||this.pixelBuffer.length!==a)&&(this.pixelBuffer=new Uint8Array(a)),e.readRenderTargetPixels(t,0,0,i,s,this.pixelBuffer);const o=this.ensureCanvas(i,s),c=o.getContext("2d");if(!c)throw new Error("TriViewCapture: failed to get 2D context.");const u=c.createImageData(i,s),f=u.data,p=this.pixelBuffer;for(let r=0;r<s;r+=1){const h=(s-r-1)*i*4,g=r*i*4;f.set(p.subarray(h,h+i*4),g)}return c.putImageData(u,0,0),o.toDataURL("image/png")}ensureCanvas(e,t){if(typeof document>"u")throw new Error("TriViewCapture: document is not available in this environment.");return this.canvas||(this.canvas=document.createElement("canvas")),(this.canvas.width!==e||this.canvas.height!==t)&&(this.canvas.width=e,this.canvas.height=t),this.canvas}}const bc="shop-components",Ac="0.3.7",Tc="Shop components",Sc="dist/shop-components.umd.js",Mc="dist/shop-components.mjs",Cc="dist/main.d.ts",Ic={dts:"tsc --emitDeclarationOnly & tsc & storybook build -o dist",dev:"vite dev",build:"vite build",v:"auto-changelog -p && git add CHANGELOG.md"},Rc=["dist","package.json"],Pc=[],Dc="machengda<machengda@seer-group.com>",Lc="ISC",Ec={"@needle-tools/gltf-progressive":"^3.3.5","auto-changelog":"^2.4.0",vite:"5.1.6","vite-plugin-dts":"^3.7.3"},Fc={"string-width":"4.2.3"},Bc={"@nodetoy/three-nodetoy":"^0.1.36","@tweakpane/core":"^2.0.3","@tweenjs/tween.js":"^23.1.2","@types/bezier-js":"^4.1.1","@types/howler":"^2.2.11","@types/three":"0.180.0","bezier-js":"^6.1.4",eventemitter3:"^5.0.1",howler:"^2.2.4","stats-fps.js":"0.0.6",stylus:"^0.63.0",terser:"^5.44.0",three:"^0.180.0","three-gpu-pathtracer":"^0.0.23","three-mesh-bvh":"^0.7.5","troika-three-text":"^0.49.1",tweakpane:"^4.0.3"},kc={name:bc,version:Ac,description:Tc,main:Sc,module:Mc,types:Cc,scripts:Ic,files:Rc,keywords:Pc,author:Dc,license:Lc,devDependencies:Ec,resolutions:Fc,dependencies:Bc};function lr(){const n="Nebular Engin",e=kc.version,t=`%c ${n} %c v${e} `;console.log(t,"background:#111827;color:#ffffff;padding:4px 10px;border-radius:4px 0 0 4px;font-weight:700;","background:#10B981;color:#ffffff;padding:4px 10px;border-radius:0 4px 4px 0;font-weight:700;")}const cr="__SHOP_COMPONENTS_BANNER_PRINTED__";try{const n=globalThis;n[cr]||(n[cr]=!0,lr())}catch{lr()}exports.Amr=Er;exports.Logo=Gi;exports.SGLBLoader=ni;exports.SLOT_EVENTS=q;exports.Scene3D=wc;exports.Skin=es;exports.Slot=Wi;exports.SlotState=Hr;exports.TriViewCapture=Nr;exports.arrayBufferToUrl=Hi;exports.calculateArrayAverage=Cr;exports.calculateFocalLength=Oa;exports.createSGLBFile=Ya;exports.downloadBlob=ka;exports.dracoExporter=ja;exports.font=_c;exports.gltfExporter=Pr;exports.gltfLoader=lt;exports.imageBitmapToUrl=Ni;exports.isAppleDevice=Ir;exports.textureLoader=us;
|
package/dist/shop-components.mjs
CHANGED
|
@@ -8986,7 +8986,11 @@ class bn extends HTMLElement {
|
|
|
8986
8986
|
set canInstall(e) {
|
|
8987
8987
|
var s;
|
|
8988
8988
|
const t = !!e, i = (s = this.shadowRoot) == null ? void 0 : s.querySelector(".main");
|
|
8989
|
-
|
|
8989
|
+
if (i) {
|
|
8990
|
+
e ? i.classList.add("can-install") : i.classList.remove("can-install");
|
|
8991
|
+
return;
|
|
8992
|
+
}
|
|
8993
|
+
this._canInstall !== t && (this._canInstall = t, this.scheduleRender());
|
|
8990
8994
|
}
|
|
8991
8995
|
get hide() {
|
|
8992
8996
|
return this._hide;
|
|
@@ -9006,7 +9010,12 @@ class bn extends HTMLElement {
|
|
|
9006
9010
|
return this._filled;
|
|
9007
9011
|
}
|
|
9008
9012
|
set filled(e) {
|
|
9009
|
-
|
|
9013
|
+
var s;
|
|
9014
|
+
const t = !!e, i = (s = this.shadowRoot) == null ? void 0 : s.querySelector(".main");
|
|
9015
|
+
if (i) {
|
|
9016
|
+
e ? i.classList.add("filled") : i.classList.remove("filled");
|
|
9017
|
+
return;
|
|
9018
|
+
}
|
|
9010
9019
|
this._filled !== t && (this._filled = t, this.scheduleRender());
|
|
9011
9020
|
}
|
|
9012
9021
|
get allFunctions() {
|
|
@@ -9211,7 +9220,7 @@ class Lr extends Be {
|
|
|
9211
9220
|
const s = this.props.follows.get(e);
|
|
9212
9221
|
if (s) {
|
|
9213
9222
|
let a = "x";
|
|
9214
|
-
["height", "mast"].includes(e) ? a = "
|
|
9223
|
+
["height", "mast"].includes(e) ? a = "z" : ["width", "liftOuterWidth"].includes(e) && (a = "y");
|
|
9215
9224
|
const o = ((i = this.props.slot) == null ? void 0 : i.position[a]) > 0 ? 1 : -1;
|
|
9216
9225
|
this._wrapper.position[a] = (t - s.origin) * s.scale * o;
|
|
9217
9226
|
}
|
|
@@ -13226,7 +13235,7 @@ class Fu {
|
|
|
13226
13235
|
return this.canvas || (this.canvas = document.createElement("canvas")), (this.canvas.width !== e || this.canvas.height !== t) && (this.canvas.width = e, this.canvas.height = t), this.canvas;
|
|
13227
13236
|
}
|
|
13228
13237
|
}
|
|
13229
|
-
const Bu = "shop-components", Ou = "0.3.
|
|
13238
|
+
const Bu = "shop-components", Ou = "0.3.7", zu = "Shop components", Uu = "dist/shop-components.umd.js", Hu = "dist/shop-components.mjs", Nu = "dist/main.d.ts", Wu = {
|
|
13230
13239
|
dts: "tsc --emitDeclarationOnly & tsc & storybook build -o dist",
|
|
13231
13240
|
dev: "vite dev",
|
|
13232
13241
|
build: "vite build",
|