@qaecy/cue-ui 0.0.15 → 0.0.17
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/236.js +1 -0
- package/269.js +1 -1
- package/284.js +1 -0
- package/371.js +1 -0
- package/418.js +1 -1
- package/{160.js → 419.js} +1 -1
- package/443.js +1 -0
- package/560.js +1 -1
- package/570.js +1 -0
- package/598.js +1 -1
- package/60.js +1 -0
- package/710.js +1 -1
- package/741.js +1 -1
- package/774.js +1 -0
- package/83.js +1 -0
- package/common.js +1 -1
- package/index.js +1 -1
- package/main.js +1 -1
- package/package.json +1 -1
- package/styles.css +1 -0
- package/141.js +0 -1
- package/21.js +0 -1
- package/266.js +0 -1
- package/28.js +0 -1
- package/280.js +0 -1
- package/378.js +0 -1
- package/63.js +0 -1
- package/734.js +0 -1
- package/754.js +0 -1
- package/769.js +0 -1
- package/927.js +0 -1
- package/941.js +0 -1
package/{160.js → 419.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(self.webpackChunkcue_ui=self.webpackChunkcue_ui||[]).push([[160],{8781(xn,Ke,ht){ht.d(Ke,{BIMFragmentsViewer:()=>Ch});var tt=ht(5802),lt=ht(7705),bt=ht(2271),Bt=ht(8807),H=ht(467),dt=ht(8158),b=ht(4701),Fe=(ht(3973),ht(2085));const B=Object.freeze({NONE:0,ROTATE:1,TRUCK:2,SCREEN_PAN:4,OFFSET:8,DOLLY:16,ZOOM:32,TOUCH_ROTATE:64,TOUCH_TRUCK:128,TOUCH_SCREEN_PAN:256,TOUCH_OFFSET:512,TOUCH_DOLLY:1024,TOUCH_ZOOM:2048,TOUCH_DOLLY_TRUCK:4096,TOUCH_DOLLY_SCREEN_PAN:8192,TOUCH_DOLLY_OFFSET:16384,TOUCH_DOLLY_ROTATE:32768,TOUCH_ZOOM_TRUCK:65536,TOUCH_ZOOM_OFFSET:131072,TOUCH_ZOOM_SCREEN_PAN:262144,TOUCH_ZOOM_ROTATE:524288});function ae(o){return o.isPerspectiveCamera}function le(o){return o.isOrthographicCamera}const ve=2*Math.PI,Cn=Math.PI/2,Je=Math.PI/180;function ne(o,e,t){return Math.max(e,Math.min(t,o))}function Et(o,e=1e-5){return Math.abs(o)<e}function wt(o,e,t=1e-5){return Et(o-e,t)}function Tn(o,e){return Math.round(o/e)*e}function ti(o){return isFinite(o)?o:o<0?-Number.MAX_VALUE:Number.MAX_VALUE}function ei(o){return Math.abs(o)<Number.MAX_VALUE?o:o*(1/0)}function Pi(o,e,t,i,s=1/0,n){const r=2/(i=Math.max(1e-4,i)),a=r*n,l=1/(1+a+.48*a*a+.235*a*a*a);let c=o-e;const u=e,h=s*i;c=ne(c,-h,h),e=o-c;const f=(t.value+r*c)*n;t.value=(t.value-r*f)*l;let d=e+(c+f)*l;return u-o>0==d>u&&(d=u,t.value=(d-u)/n),d}function Pn(o,e,t,i,s=1/0,n,r){const a=2/(i=Math.max(1e-4,i)),l=a*n,c=1/(1+l+.48*l*l+.235*l*l*l);let u=e.x,h=e.y,f=e.z,d=o.x-u,y=o.y-h,g=o.z-f;const _=u,m=h,x=f,T=s*i,P=d*d+y*y+g*g;if(P>T*T){const R=Math.sqrt(P);d=d/R*T,y=y/R*T,g=g/R*T}u=o.x-d,h=o.y-y,f=o.z-g;const I=(t.x+a*d)*n,M=(t.y+a*y)*n,z=(t.z+a*g)*n;return t.x=(t.x-a*I)*c,t.y=(t.y-a*M)*c,t.z=(t.z-a*z)*c,r.x=u+(d+I)*c,r.y=h+(y+M)*c,r.z=f+(g+z)*c,(_-o.x)*(r.x-_)+(m-o.y)*(r.y-m)+(x-o.z)*(r.z-x)>0&&(r.x=_,r.y=m,r.z=x,t.x=(r.x-_)/n,t.y=(r.y-m)/n,t.z=(r.z-x)/n),r}function ds(o,e){e.set(0,0),o.forEach(t=>{e.x+=t.clientX,e.y+=t.clientY}),e.x/=o.length,e.y/=o.length}function fs(o,e){return!!le(o)&&(console.warn(`${e} is not supported in OrthographicCamera`),!0)}class Po{_listeners={};addEventListener(e,t){const i=this._listeners;void 0===i[e]&&(i[e]=[]),-1===i[e].indexOf(t)&&i[e].push(t)}hasEventListener(e,t){const i=this._listeners;return void 0!==i[e]&&-1!==i[e].indexOf(t)}removeEventListener(e,t){const s=this._listeners[e];if(void 0!==s){const n=s.indexOf(t);-1!==n&&s.splice(n,1)}}removeAllEventListeners(e){e?Array.isArray(this._listeners[e])&&(this._listeners[e].length=0):this._listeners={}}dispatchEvent(e){const i=this._listeners[e.type];if(void 0!==i){e.target=this;const s=i.slice(0);for(let n=0,r=s.length;n<r;n++)s[n].call(this,e)}}}const Ai=1/8,Mo=/Mac/.test(globalThis?.navigator?.platform);let ct,An,Mi,ps,Zt,ft,yt,De,ii,ce,ue,Ae,Mn,Sn,qt,Ne,Re,In,ms,On,gs,_s,Si;class Vt extends Po{static install(e){ct=e.THREE,An=Object.freeze(new ct.Vector3(0,0,0)),Mi=Object.freeze(new ct.Vector3(0,1,0)),ps=Object.freeze(new ct.Vector3(0,0,1)),Zt=new ct.Vector2,ft=new ct.Vector3,yt=new ct.Vector3,De=new ct.Vector3,ii=new ct.Vector3,ce=new ct.Vector3,ue=new ct.Vector3,Ae=new ct.Vector3,Mn=new ct.Vector3,Sn=new ct.Vector3,qt=new ct.Spherical,Ne=new ct.Spherical,Re=new ct.Box3,In=new ct.Box3,ms=new ct.Sphere,On=new ct.Quaternion,gs=new ct.Quaternion,_s=new ct.Matrix4,Si=new ct.Raycaster}static get ACTION(){return B}minPolarAngle=0;maxPolarAngle=Math.PI;minAzimuthAngle=-1/0;maxAzimuthAngle=1/0;minDistance=Number.EPSILON;maxDistance=1/0;infinityDolly=!1;minZoom=.01;maxZoom=1/0;smoothTime=.25;draggingSmoothTime=.125;maxSpeed=1/0;azimuthRotateSpeed=1;polarRotateSpeed=1;dollySpeed=1;dollyDragInverted=!1;truckSpeed=2;dollyToCursor=!1;dragToOffset=!1;boundaryFriction=0;restThreshold=.01;colliderMeshes=[];mouseButtons;touches;cancel=()=>{};lockPointer;unlockPointer;_enabled=!0;_camera;_yAxisUpSpace;_yAxisUpSpaceInverse;_state=B.NONE;_domElement;_viewport=null;_target;_targetEnd;_focalOffset;_focalOffsetEnd;_spherical;_sphericalEnd;_lastDistance;_zoom;_zoomEnd;_lastZoom;_cameraUp0;_target0;_position0;_zoom0;_focalOffset0;_dollyControlCoord;_changedDolly=0;_changedZoom=0;_nearPlaneCorners;_hasRested=!0;_boundary;_boundaryEnclosesCamera=!1;_needsUpdate=!0;_updatedLastTime=!1;_elementRect=new DOMRect;_isDragging=!1;_dragNeedsUpdate=!0;_activePointers=[];_lockedPointer=null;_interactiveArea=new DOMRect(0,0,1,1);_isUserControllingRotate=!1;_isUserControllingDolly=!1;_isUserControllingTruck=!1;_isUserControllingOffset=!1;_isUserControllingZoom=!1;_lastDollyDirection=0;_thetaVelocity={value:0};_phiVelocity={value:0};_radiusVelocity={value:0};_targetVelocity=new ct.Vector3;_focalOffsetVelocity=new ct.Vector3;_zoomVelocity={value:0};set verticalDragToForward(e){console.warn("camera-controls: `verticalDragToForward` was removed. Use `mouseButtons.left = CameraControls.ACTION.SCREEN_PAN` instead.")}constructor(e,t){super(),typeof ct>"u"&&console.error("camera-controls: `THREE` is undefined. You must first run `CameraControls.install( { THREE: THREE } )`. Check the docs for further information."),this._camera=e,this._yAxisUpSpace=(new ct.Quaternion).setFromUnitVectors(this._camera.up,Mi),this._yAxisUpSpaceInverse=this._yAxisUpSpace.clone().invert(),this._state=B.NONE,this._target=new ct.Vector3,this._targetEnd=this._target.clone(),this._focalOffset=new ct.Vector3,this._focalOffsetEnd=this._focalOffset.clone(),this._spherical=(new ct.Spherical).setFromVector3(ft.copy(this._camera.position).applyQuaternion(this._yAxisUpSpace)),this._sphericalEnd=this._spherical.clone(),this._lastDistance=this._spherical.radius,this._zoom=this._camera.zoom,this._zoomEnd=this._zoom,this._lastZoom=this._zoom,this._nearPlaneCorners=[new ct.Vector3,new ct.Vector3,new ct.Vector3,new ct.Vector3],this._updateNearPlaneCorners(),this._boundary=new ct.Box3(new ct.Vector3(-1/0,-1/0,-1/0),new ct.Vector3(1/0,1/0,1/0)),this._cameraUp0=this._camera.up.clone(),this._target0=this._target.clone(),this._position0=this._camera.position.clone(),this._zoom0=this._zoom,this._focalOffset0=this._focalOffset.clone(),this._dollyControlCoord=new ct.Vector2,this.mouseButtons={left:B.ROTATE,middle:B.DOLLY,right:B.TRUCK,wheel:ae(this._camera)?B.DOLLY:le(this._camera)?B.ZOOM:B.NONE},this.touches={one:B.TOUCH_ROTATE,two:ae(this._camera)?B.TOUCH_DOLLY_TRUCK:le(this._camera)?B.TOUCH_ZOOM_TRUCK:B.NONE,three:B.TOUCH_TRUCK};const i=new ct.Vector2,s=new ct.Vector2,n=new ct.Vector2,r=m=>{if(!this._enabled||!this._domElement)return;if(0!==this._interactiveArea.left||0!==this._interactiveArea.top||1!==this._interactiveArea.width||1!==this._interactiveArea.height){const E=this._domElement.getBoundingClientRect(),P=m.clientX/E.width,I=m.clientY/E.height;if(P<this._interactiveArea.left||P>this._interactiveArea.right||I<this._interactiveArea.top||I>this._interactiveArea.bottom)return}const x="mouse"!==m.pointerType?null:1&~m.buttons?4&~m.buttons?2&~m.buttons?null:2:4:1;if(null!==x){const E=this._findPointerByMouseButton(x);E&&this._disposePointer(E)}(1&~m.buttons||!this._lockedPointer)&&(this._activePointers.push({pointerId:m.pointerId,clientX:m.clientX,clientY:m.clientY,deltaX:0,deltaY:0,mouseButton:x}),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",l),this._domElement.ownerDocument.addEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",l),this._isDragging=!0,f(m))},a=m=>{m.cancelable&&m.preventDefault();const T=this._lockedPointer||this._findPointerById(m.pointerId);if(T){if(T.clientX=m.clientX,T.clientY=m.clientY,T.deltaX=m.movementX,T.deltaY=m.movementY,this._state=0,"touch"===m.pointerType)switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three}else(!this._isDragging&&this._lockedPointer||this._isDragging&&!(1&~m.buttons))&&(this._state=this._state|this.mouseButtons.left),this._isDragging&&!(4&~m.buttons)&&(this._state=this._state|this.mouseButtons.middle),this._isDragging&&!(2&~m.buttons)&&(this._state=this._state|this.mouseButtons.right);d()}},l=m=>{const x=this._findPointerById(m.pointerId);if(!x||x!==this._lockedPointer){if(x&&this._disposePointer(x),"touch"===m.pointerType)switch(this._activePointers.length){case 0:this._state=B.NONE;break;case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three}else this._state=B.NONE;y()}};let c=-1;const u=m=>{if(!this._domElement||!this._enabled||this.mouseButtons.wheel===B.NONE)return;if(0!==this._interactiveArea.left||0!==this._interactiveArea.top||1!==this._interactiveArea.width||1!==this._interactiveArea.height){const M=this._domElement.getBoundingClientRect(),z=m.clientX/M.width,O=m.clientY/M.height;if(z<this._interactiveArea.left||z>this._interactiveArea.right||O<this._interactiveArea.top||O>this._interactiveArea.bottom)return}if(m.preventDefault(),this.dollyToCursor||this.mouseButtons.wheel===B.ROTATE||this.mouseButtons.wheel===B.TRUCK){const M=performance.now();c-M<1e3&&this._getClientRect(this._elementRect),c=M}const x=Mo?-1:-3,T=1!==m.deltaMode||m.ctrlKey?m.deltaY/(10*x):m.deltaY/x,E=this.dollyToCursor?(m.clientX-this._elementRect.x)/this._elementRect.width*2-1:0,P=this.dollyToCursor?(m.clientY-this._elementRect.y)/this._elementRect.height*-2+1:0;switch(m.ctrlKey?B.ZOOM:this.mouseButtons.wheel){case B.ROTATE:this._rotateInternal(m.deltaX,m.deltaY),this._isUserControllingRotate=!0;break;case B.TRUCK:this._truckInternal(m.deltaX,m.deltaY,!1,!1),this._isUserControllingTruck=!0;break;case B.SCREEN_PAN:this._truckInternal(m.deltaX,m.deltaY,!1,!0),this._isUserControllingTruck=!0;break;case B.OFFSET:this._truckInternal(m.deltaX,m.deltaY,!0,!1),this._isUserControllingOffset=!0;break;case B.DOLLY:this._dollyInternal(-T,E,P),this._isUserControllingDolly=!0;break;case B.ZOOM:this._zoomInternal(-T,E,P),this._isUserControllingZoom=!0}this.dispatchEvent({type:"control"})},h=m=>{if(this._domElement&&this._enabled){if(this.mouseButtons.right===Vt.ACTION.NONE){const x=m instanceof PointerEvent?m.pointerId:0,T=this._findPointerById(x);return T&&this._disposePointer(T),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),void this._domElement.ownerDocument.removeEventListener("pointerup",l)}m.preventDefault()}},f=m=>{if(this._enabled){if(ds(this._activePointers,Zt),this._getClientRect(this._elementRect),i.copy(Zt),s.copy(Zt),this._activePointers.length>=2){const T=Zt.x-this._activePointers[1].clientX,E=Zt.y-this._activePointers[1].clientY,P=Math.sqrt(T*T+E*E);n.set(0,P),s.set(.5*(this._activePointers[0].clientX+this._activePointers[1].clientX),.5*(this._activePointers[0].clientY+this._activePointers[1].clientY))}if(this._state=0,m)if("pointerType"in m&&"touch"===m.pointerType)switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three}else!this._lockedPointer&&!(1&~m.buttons)&&(this._state=this._state|this.mouseButtons.left),!(4&~m.buttons)&&(this._state=this._state|this.mouseButtons.middle),!(2&~m.buttons)&&(this._state=this._state|this.mouseButtons.right);else this._lockedPointer&&(this._state=this._state|this.mouseButtons.left);((this._state&B.ROTATE)===B.ROTATE||(this._state&B.TOUCH_ROTATE)===B.TOUCH_ROTATE||(this._state&B.TOUCH_DOLLY_ROTATE)===B.TOUCH_DOLLY_ROTATE||(this._state&B.TOUCH_ZOOM_ROTATE)===B.TOUCH_ZOOM_ROTATE)&&(this._sphericalEnd.theta=this._spherical.theta,this._sphericalEnd.phi=this._spherical.phi,this._thetaVelocity.value=0,this._phiVelocity.value=0),((this._state&B.TRUCK)===B.TRUCK||(this._state&B.SCREEN_PAN)===B.SCREEN_PAN||(this._state&B.TOUCH_TRUCK)===B.TOUCH_TRUCK||(this._state&B.TOUCH_SCREEN_PAN)===B.TOUCH_SCREEN_PAN||(this._state&B.TOUCH_DOLLY_TRUCK)===B.TOUCH_DOLLY_TRUCK||(this._state&B.TOUCH_DOLLY_SCREEN_PAN)===B.TOUCH_DOLLY_SCREEN_PAN||(this._state&B.TOUCH_ZOOM_TRUCK)===B.TOUCH_ZOOM_TRUCK||(this._state&B.TOUCH_ZOOM_SCREEN_PAN)===B.TOUCH_DOLLY_SCREEN_PAN)&&(this._targetEnd.copy(this._target),this._targetVelocity.set(0,0,0)),((this._state&B.DOLLY)===B.DOLLY||(this._state&B.TOUCH_DOLLY)===B.TOUCH_DOLLY||(this._state&B.TOUCH_DOLLY_TRUCK)===B.TOUCH_DOLLY_TRUCK||(this._state&B.TOUCH_DOLLY_SCREEN_PAN)===B.TOUCH_DOLLY_SCREEN_PAN||(this._state&B.TOUCH_DOLLY_OFFSET)===B.TOUCH_DOLLY_OFFSET||(this._state&B.TOUCH_DOLLY_ROTATE)===B.TOUCH_DOLLY_ROTATE)&&(this._sphericalEnd.radius=this._spherical.radius,this._radiusVelocity.value=0),((this._state&B.ZOOM)===B.ZOOM||(this._state&B.TOUCH_ZOOM)===B.TOUCH_ZOOM||(this._state&B.TOUCH_ZOOM_TRUCK)===B.TOUCH_ZOOM_TRUCK||(this._state&B.TOUCH_ZOOM_SCREEN_PAN)===B.TOUCH_ZOOM_SCREEN_PAN||(this._state&B.TOUCH_ZOOM_OFFSET)===B.TOUCH_ZOOM_OFFSET||(this._state&B.TOUCH_ZOOM_ROTATE)===B.TOUCH_ZOOM_ROTATE)&&(this._zoomEnd=this._zoom,this._zoomVelocity.value=0),((this._state&B.OFFSET)===B.OFFSET||(this._state&B.TOUCH_OFFSET)===B.TOUCH_OFFSET||(this._state&B.TOUCH_DOLLY_OFFSET)===B.TOUCH_DOLLY_OFFSET||(this._state&B.TOUCH_ZOOM_OFFSET)===B.TOUCH_ZOOM_OFFSET)&&(this._focalOffsetEnd.copy(this._focalOffset),this._focalOffsetVelocity.set(0,0,0)),this.dispatchEvent({type:"controlstart"})}},d=()=>{if(!this._enabled||!this._dragNeedsUpdate)return;this._dragNeedsUpdate=!1,ds(this._activePointers,Zt);const x=this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement?this._lockedPointer||this._activePointers[0]:null,T=x?-x.deltaX:s.x-Zt.x,E=x?-x.deltaY:s.y-Zt.y;if(s.copy(Zt),((this._state&B.ROTATE)===B.ROTATE||(this._state&B.TOUCH_ROTATE)===B.TOUCH_ROTATE||(this._state&B.TOUCH_DOLLY_ROTATE)===B.TOUCH_DOLLY_ROTATE||(this._state&B.TOUCH_ZOOM_ROTATE)===B.TOUCH_ZOOM_ROTATE)&&(this._rotateInternal(T,E),this._isUserControllingRotate=!0),(this._state&B.DOLLY)===B.DOLLY||(this._state&B.ZOOM)===B.ZOOM){const P=this.dollyToCursor?(i.x-this._elementRect.x)/this._elementRect.width*2-1:0,I=this.dollyToCursor?(i.y-this._elementRect.y)/this._elementRect.height*-2+1:0,M=this.dollyDragInverted?-1:1;(this._state&B.DOLLY)===B.DOLLY?(this._dollyInternal(M*E*Ai,P,I),this._isUserControllingDolly=!0):(this._zoomInternal(M*E*Ai,P,I),this._isUserControllingZoom=!0)}if((this._state&B.TOUCH_DOLLY)===B.TOUCH_DOLLY||(this._state&B.TOUCH_ZOOM)===B.TOUCH_ZOOM||(this._state&B.TOUCH_DOLLY_TRUCK)===B.TOUCH_DOLLY_TRUCK||(this._state&B.TOUCH_ZOOM_TRUCK)===B.TOUCH_ZOOM_TRUCK||(this._state&B.TOUCH_DOLLY_SCREEN_PAN)===B.TOUCH_DOLLY_SCREEN_PAN||(this._state&B.TOUCH_ZOOM_SCREEN_PAN)===B.TOUCH_ZOOM_SCREEN_PAN||(this._state&B.TOUCH_DOLLY_OFFSET)===B.TOUCH_DOLLY_OFFSET||(this._state&B.TOUCH_ZOOM_OFFSET)===B.TOUCH_ZOOM_OFFSET||(this._state&B.TOUCH_DOLLY_ROTATE)===B.TOUCH_DOLLY_ROTATE||(this._state&B.TOUCH_ZOOM_ROTATE)===B.TOUCH_ZOOM_ROTATE){const P=Zt.x-this._activePointers[1].clientX,I=Zt.y-this._activePointers[1].clientY,M=Math.sqrt(P*P+I*I),z=n.y-M;n.set(0,M);const O=this.dollyToCursor?(s.x-this._elementRect.x)/this._elementRect.width*2-1:0,D=this.dollyToCursor?(s.y-this._elementRect.y)/this._elementRect.height*-2+1:0;(this._state&B.TOUCH_DOLLY)===B.TOUCH_DOLLY||(this._state&B.TOUCH_DOLLY_ROTATE)===B.TOUCH_DOLLY_ROTATE||(this._state&B.TOUCH_DOLLY_TRUCK)===B.TOUCH_DOLLY_TRUCK||(this._state&B.TOUCH_DOLLY_SCREEN_PAN)===B.TOUCH_DOLLY_SCREEN_PAN||(this._state&B.TOUCH_DOLLY_OFFSET)===B.TOUCH_DOLLY_OFFSET?(this._dollyInternal(z*Ai,O,D),this._isUserControllingDolly=!0):(this._zoomInternal(z*Ai,O,D),this._isUserControllingZoom=!0)}((this._state&B.TRUCK)===B.TRUCK||(this._state&B.TOUCH_TRUCK)===B.TOUCH_TRUCK||(this._state&B.TOUCH_DOLLY_TRUCK)===B.TOUCH_DOLLY_TRUCK||(this._state&B.TOUCH_ZOOM_TRUCK)===B.TOUCH_ZOOM_TRUCK)&&(this._truckInternal(T,E,!1,!1),this._isUserControllingTruck=!0),((this._state&B.SCREEN_PAN)===B.SCREEN_PAN||(this._state&B.TOUCH_SCREEN_PAN)===B.TOUCH_SCREEN_PAN||(this._state&B.TOUCH_DOLLY_SCREEN_PAN)===B.TOUCH_DOLLY_SCREEN_PAN||(this._state&B.TOUCH_ZOOM_SCREEN_PAN)===B.TOUCH_ZOOM_SCREEN_PAN)&&(this._truckInternal(T,E,!1,!0),this._isUserControllingTruck=!0),((this._state&B.OFFSET)===B.OFFSET||(this._state&B.TOUCH_OFFSET)===B.TOUCH_OFFSET||(this._state&B.TOUCH_DOLLY_OFFSET)===B.TOUCH_DOLLY_OFFSET||(this._state&B.TOUCH_ZOOM_OFFSET)===B.TOUCH_ZOOM_OFFSET)&&(this._truckInternal(T,E,!0,!1),this._isUserControllingOffset=!0),this.dispatchEvent({type:"control"})},y=()=>{ds(this._activePointers,Zt),s.copy(Zt),this._dragNeedsUpdate=!1,(0===this._activePointers.length||1===this._activePointers.length&&this._activePointers[0]===this._lockedPointer)&&(this._isDragging=!1),0===this._activePointers.length&&this._domElement&&(this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",l),this.dispatchEvent({type:"controlend"}))};this.lockPointer=()=>{!this._enabled||!this._domElement||(this.cancel(),this._lockedPointer={pointerId:-1,clientX:0,clientY:0,deltaX:0,deltaY:0,mouseButton:null},this._activePointers.push(this._lockedPointer),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",l),this._domElement.requestPointerLock(),this._domElement.ownerDocument.addEventListener("pointerlockchange",g),this._domElement.ownerDocument.addEventListener("pointerlockerror",_),this._domElement.ownerDocument.addEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",l),f())},this.unlockPointer=()=>{null!==this._lockedPointer&&(this._disposePointer(this._lockedPointer),this._lockedPointer=null),this._domElement?.ownerDocument.exitPointerLock(),this._domElement?.ownerDocument.removeEventListener("pointerlockchange",g),this._domElement?.ownerDocument.removeEventListener("pointerlockerror",_),this.cancel()};const g=()=>{this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement||this.unlockPointer()},_=()=>{this.unlockPointer()};this._addAllEventListeners=m=>{this._domElement=m,this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none",this._domElement.addEventListener("pointerdown",r),this._domElement.addEventListener("pointercancel",l),this._domElement.addEventListener("wheel",u,{passive:!1}),this._domElement.addEventListener("contextmenu",h)},this._removeAllEventListeners=()=>{this._domElement&&(this._domElement.style.touchAction="",this._domElement.style.userSelect="",this._domElement.style.webkitUserSelect="",this._domElement.removeEventListener("pointerdown",r),this._domElement.removeEventListener("pointercancel",l),this._domElement.removeEventListener("wheel",u,{passive:!1}),this._domElement.removeEventListener("contextmenu",h),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",l),this._domElement.ownerDocument.removeEventListener("pointerlockchange",g),this._domElement.ownerDocument.removeEventListener("pointerlockerror",_))},this.cancel=()=>{this._state!==B.NONE&&(this._state=B.NONE,this._activePointers.length=0,y())},t&&this.connect(t),this.update(0)}get camera(){return this._camera}set camera(e){this._camera=e,this.updateCameraUp(),this._camera.updateProjectionMatrix(),this._updateNearPlaneCorners(),this._needsUpdate=!0}get enabled(){return this._enabled}set enabled(e){this._enabled=e,this._domElement&&(e?(this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none"):(this.cancel(),this._domElement.style.touchAction="",this._domElement.style.userSelect="",this._domElement.style.webkitUserSelect=""))}get active(){return!this._hasRested}get currentAction(){return this._state}get distance(){return this._spherical.radius}set distance(e){this._spherical.radius===e&&this._sphericalEnd.radius===e||(this._spherical.radius=e,this._sphericalEnd.radius=e,this._needsUpdate=!0)}get azimuthAngle(){return this._spherical.theta}set azimuthAngle(e){this._spherical.theta===e&&this._sphericalEnd.theta===e||(this._spherical.theta=e,this._sphericalEnd.theta=e,this._needsUpdate=!0)}get polarAngle(){return this._spherical.phi}set polarAngle(e){this._spherical.phi===e&&this._sphericalEnd.phi===e||(this._spherical.phi=e,this._sphericalEnd.phi=e,this._needsUpdate=!0)}get boundaryEnclosesCamera(){return this._boundaryEnclosesCamera}set boundaryEnclosesCamera(e){this._boundaryEnclosesCamera=e,this._needsUpdate=!0}set interactiveArea(e){this._interactiveArea.width=ne(e.width,0,1),this._interactiveArea.height=ne(e.height,0,1),this._interactiveArea.x=ne(e.x,0,1-this._interactiveArea.width),this._interactiveArea.y=ne(e.y,0,1-this._interactiveArea.height)}addEventListener(e,t){super.addEventListener(e,t)}removeEventListener(e,t){super.removeEventListener(e,t)}rotate(e,t,i=!1){return this.rotateTo(this._sphericalEnd.theta+e,this._sphericalEnd.phi+t,i)}rotateAzimuthTo(e,t=!1){return this.rotateTo(e,this._sphericalEnd.phi,t)}rotatePolarTo(e,t=!1){return this.rotateTo(this._sphericalEnd.theta,e,t)}rotateTo(e,t,i=!1){this._isUserControllingRotate=!1;const s=ne(e,this.minAzimuthAngle,this.maxAzimuthAngle),n=ne(t,this.minPolarAngle,this.maxPolarAngle);this._sphericalEnd.theta=s,this._sphericalEnd.phi=n,this._sphericalEnd.makeSafe(),this._needsUpdate=!0,i||(this._spherical.theta=this._sphericalEnd.theta,this._spherical.phi=this._sphericalEnd.phi);const r=!i||wt(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&wt(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold);return this._createOnRestPromise(r)}dolly(e,t=!1){return this.dollyTo(this._sphericalEnd.radius-e,t)}dollyTo(e,t=!1){return this._isUserControllingDolly=!1,this._lastDollyDirection=0,this._changedDolly=0,this._dollyToNoClamp(ne(e,this.minDistance,this.maxDistance),t)}_dollyToNoClamp(e,t=!1){const i=this._sphericalEnd.radius;if(this.colliderMeshes.length>=1){const r=this._collisionTest(),a=wt(r,this._spherical.radius);if(!(i>e)&&a)return Promise.resolve();this._sphericalEnd.radius=Math.min(e,r)}else this._sphericalEnd.radius=e;this._needsUpdate=!0,t||(this._spherical.radius=this._sphericalEnd.radius);const n=!t||wt(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(n)}dollyInFixed(e,t=!1){this._targetEnd.add(this._getCameraDirection(ii).multiplyScalar(e)),t||this._target.copy(this._targetEnd);const i=!t||wt(this._target.x,this._targetEnd.x,this.restThreshold)&&wt(this._target.y,this._targetEnd.y,this.restThreshold)&&wt(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(i)}zoom(e,t=!1){return this.zoomTo(this._zoomEnd+e,t)}zoomTo(e,t=!1){this._isUserControllingZoom=!1,this._zoomEnd=ne(e,this.minZoom,this.maxZoom),this._needsUpdate=!0,t||(this._zoom=this._zoomEnd);const i=!t||wt(this._zoom,this._zoomEnd,this.restThreshold);return this._changedZoom=0,this._createOnRestPromise(i)}pan(e,t,i=!1){return console.warn("`pan` has been renamed to `truck`"),this.truck(e,t,i)}truck(e,t,i=!1){this._camera.updateMatrix(),ce.setFromMatrixColumn(this._camera.matrix,0),ue.setFromMatrixColumn(this._camera.matrix,1),ce.multiplyScalar(e),ue.multiplyScalar(-t);const s=ft.copy(ce).add(ue),n=yt.copy(this._targetEnd).add(s);return this.moveTo(n.x,n.y,n.z,i)}forward(e,t=!1){ft.setFromMatrixColumn(this._camera.matrix,0),ft.crossVectors(this._camera.up,ft),ft.multiplyScalar(e);const i=yt.copy(this._targetEnd).add(ft);return this.moveTo(i.x,i.y,i.z,t)}elevate(e,t=!1){return ft.copy(this._camera.up).multiplyScalar(e),this.moveTo(this._targetEnd.x+ft.x,this._targetEnd.y+ft.y,this._targetEnd.z+ft.z,t)}moveTo(e,t,i,s=!1){this._isUserControllingTruck=!1;const n=ft.set(e,t,i).sub(this._targetEnd);this._encloseToBoundary(this._targetEnd,n,this.boundaryFriction),this._needsUpdate=!0,s||this._target.copy(this._targetEnd);const r=!s||wt(this._target.x,this._targetEnd.x,this.restThreshold)&&wt(this._target.y,this._targetEnd.y,this.restThreshold)&&wt(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(r)}lookInDirectionOf(e,t,i,s=!1){const a=ft.set(e,t,i).sub(this._targetEnd).normalize().multiplyScalar(-this._sphericalEnd.radius).add(this._targetEnd);return this.setPosition(a.x,a.y,a.z,s)}fitToBox(e,t,{cover:i=!1,paddingLeft:s=0,paddingRight:n=0,paddingBottom:r=0,paddingTop:a=0}={}){const l=[],c=e.isBox3?Re.copy(e):Re.setFromObject(e);c.isEmpty()&&(console.warn("camera-controls: fitTo() cannot be used with an empty box. Aborting"),Promise.resolve());const u=Tn(this._sphericalEnd.theta,Cn),h=Tn(this._sphericalEnd.phi,Cn);l.push(this.rotateTo(u,h,t));const f=ft.setFromSpherical(this._sphericalEnd).normalize(),d=On.setFromUnitVectors(f,ps),y=wt(Math.abs(f.y),1);y&&d.multiply(gs.setFromAxisAngle(Mi,u)),d.multiply(this._yAxisUpSpaceInverse);const g=In.makeEmpty();yt.copy(c.min).applyQuaternion(d),g.expandByPoint(yt),yt.copy(c.min).setX(c.max.x).applyQuaternion(d),g.expandByPoint(yt),yt.copy(c.min).setY(c.max.y).applyQuaternion(d),g.expandByPoint(yt),yt.copy(c.max).setZ(c.min.z).applyQuaternion(d),g.expandByPoint(yt),yt.copy(c.min).setZ(c.max.z).applyQuaternion(d),g.expandByPoint(yt),yt.copy(c.max).setY(c.min.y).applyQuaternion(d),g.expandByPoint(yt),yt.copy(c.max).setX(c.min.x).applyQuaternion(d),g.expandByPoint(yt),yt.copy(c.max).applyQuaternion(d),g.expandByPoint(yt),g.min.x-=s,g.min.y-=r,g.max.x+=n,g.max.y+=a,d.setFromUnitVectors(ps,f),y&&d.premultiply(gs.invert()),d.premultiply(this._yAxisUpSpace);const _=g.getSize(ft),m=g.getCenter(yt).applyQuaternion(d);if(ae(this._camera)){const x=this.getDistanceToFitBox(_.x,_.y,_.z,i);l.push(this.moveTo(m.x,m.y,m.z,t)),l.push(this.dollyTo(x,t)),l.push(this.setFocalOffset(0,0,0,t))}else if(le(this._camera)){const x=this._camera,T=x.right-x.left,E=x.top-x.bottom,P=i?Math.max(T/_.x,E/_.y):Math.min(T/_.x,E/_.y);l.push(this.moveTo(m.x,m.y,m.z,t)),l.push(this.zoomTo(P,t)),l.push(this.setFocalOffset(0,0,0,t))}return Promise.all(l)}fitToSphere(e,t){const i=[],n="isObject3D"in e?Vt.createBoundingSphere(e,ms):ms.copy(e);if(i.push(this.moveTo(n.center.x,n.center.y,n.center.z,t)),ae(this._camera)){const r=this.getDistanceToFitSphere(n.radius);i.push(this.dollyTo(r,t))}else if(le(this._camera)){const l=2*n.radius,c=Math.min((this._camera.right-this._camera.left)/l,(this._camera.top-this._camera.bottom)/l);i.push(this.zoomTo(c,t))}return i.push(this.setFocalOffset(0,0,0,t)),Promise.all(i)}setLookAt(e,t,i,s,n,r,a=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=0,this._changedDolly=0;const l=yt.set(s,n,r),c=ft.set(e,t,i);this._targetEnd.copy(l),this._sphericalEnd.setFromVector3(c.sub(l).applyQuaternion(this._yAxisUpSpace)),this._needsUpdate=!0,a||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const u=!a||wt(this._target.x,this._targetEnd.x,this.restThreshold)&&wt(this._target.y,this._targetEnd.y,this.restThreshold)&&wt(this._target.z,this._targetEnd.z,this.restThreshold)&&wt(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&wt(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&wt(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(u)}lerp(e,t,i,s=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=0,this._changedDolly=0;const n=ft.set(...e.target);if("spherical"in e)qt.set(...e.spherical);else{const h=yt.set(...e.position);qt.setFromVector3(h.sub(n).applyQuaternion(this._yAxisUpSpace))}const r=De.set(...t.target);if("spherical"in t)Ne.set(...t.spherical);else{const h=yt.set(...t.position);Ne.setFromVector3(h.sub(r).applyQuaternion(this._yAxisUpSpace))}this._targetEnd.copy(n.lerp(r,i)),this._sphericalEnd.set(qt.radius+(Ne.radius-qt.radius)*i,qt.phi+(Ne.phi-qt.phi)*i,qt.theta+(Ne.theta-qt.theta)*i),this._needsUpdate=!0,s||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const u=!s||wt(this._target.x,this._targetEnd.x,this.restThreshold)&&wt(this._target.y,this._targetEnd.y,this.restThreshold)&&wt(this._target.z,this._targetEnd.z,this.restThreshold)&&wt(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&wt(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&wt(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(u)}lerpLookAt(e,t,i,s,n,r,a,l,c,u,h,f,d,y=!1){return this.lerp({position:[e,t,i],target:[s,n,r]},{position:[a,l,c],target:[u,h,f]},d,y)}setPosition(e,t,i,s=!1){return this.setLookAt(e,t,i,this._targetEnd.x,this._targetEnd.y,this._targetEnd.z,s)}setTarget(e,t,i,s=!1){const n=this.getPosition(ft),r=this.setLookAt(n.x,n.y,n.z,e,t,i,s);return this._sphericalEnd.phi=ne(this._sphericalEnd.phi,this.minPolarAngle,this.maxPolarAngle),r}setFocalOffset(e,t,i,s=!1){this._isUserControllingOffset=!1,this._focalOffsetEnd.set(e,t,i),this._needsUpdate=!0,s||this._focalOffset.copy(this._focalOffsetEnd);const n=!s||wt(this._focalOffset.x,this._focalOffsetEnd.x,this.restThreshold)&&wt(this._focalOffset.y,this._focalOffsetEnd.y,this.restThreshold)&&wt(this._focalOffset.z,this._focalOffsetEnd.z,this.restThreshold);return this._createOnRestPromise(n)}setOrbitPoint(e,t,i){this._camera.updateMatrixWorld(),ce.setFromMatrixColumn(this._camera.matrixWorldInverse,0),ue.setFromMatrixColumn(this._camera.matrixWorldInverse,1),Ae.setFromMatrixColumn(this._camera.matrixWorldInverse,2);const s=ft.set(e,t,i),n=s.distanceTo(this._camera.position),r=s.sub(this._camera.position);ce.multiplyScalar(r.x),ue.multiplyScalar(r.y),Ae.multiplyScalar(r.z),ft.copy(ce).add(ue).add(Ae),ft.z=ft.z+n,this.dollyTo(n,!1),this.setFocalOffset(-ft.x,ft.y,-ft.z,!1),this.moveTo(e,t,i,!1)}setBoundary(e){if(!e)return this._boundary.min.set(-1/0,-1/0,-1/0),this._boundary.max.set(1/0,1/0,1/0),void(this._needsUpdate=!0);this._boundary.copy(e),this._boundary.clampPoint(this._targetEnd,this._targetEnd),this._needsUpdate=!0}setViewport(e,t,i,s){null!==e?(this._viewport=this._viewport||new ct.Vector4,"number"==typeof e?this._viewport.set(e,t,i,s):this._viewport.copy(e)):this._viewport=null}getDistanceToFitBox(e,t,i,s=!1){if(fs(this._camera,"getDistanceToFitBox"))return this._spherical.radius;const n=e/t,r=this._camera.getEffectiveFOV()*Je,a=this._camera.aspect;return.5*((s?n>a:n<a)?t:e/a)/Math.tan(.5*r)+.5*i}getDistanceToFitSphere(e){if(fs(this._camera,"getDistanceToFitSphere"))return this._spherical.radius;const t=this._camera.getEffectiveFOV()*Je,i=2*Math.atan(Math.tan(.5*t)*this._camera.aspect);return e/Math.sin(.5*(1<this._camera.aspect?t:i))}getTarget(e,t=!0){return(e&&e.isVector3?e:new ct.Vector3).copy(t?this._targetEnd:this._target)}getPosition(e,t=!0){return(e&&e.isVector3?e:new ct.Vector3).setFromSpherical(t?this._sphericalEnd:this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(t?this._targetEnd:this._target)}getSpherical(e,t=!0){return(e||new ct.Spherical).copy(t?this._sphericalEnd:this._spherical)}getFocalOffset(e,t=!0){return(e&&e.isVector3?e:new ct.Vector3).copy(t?this._focalOffsetEnd:this._focalOffset)}normalizeRotations(){return this._sphericalEnd.theta=(this._sphericalEnd.theta%ve+ve)%ve,this._sphericalEnd.theta>Math.PI&&(this._sphericalEnd.theta-=ve),this._spherical.theta+=ve*Math.round((this._sphericalEnd.theta-this._spherical.theta)/ve),this}stop(){this._focalOffset.copy(this._focalOffsetEnd),this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd),this._zoom=this._zoomEnd}reset(e=!1){if(!wt(this._camera.up.x,this._cameraUp0.x)||!wt(this._camera.up.y,this._cameraUp0.y)||!wt(this._camera.up.z,this._cameraUp0.z)){this._camera.up.copy(this._cameraUp0);const i=this.getPosition(ft);this.updateCameraUp(),this.setPosition(i.x,i.y,i.z)}const t=[this.setLookAt(this._position0.x,this._position0.y,this._position0.z,this._target0.x,this._target0.y,this._target0.z,e),this.setFocalOffset(this._focalOffset0.x,this._focalOffset0.y,this._focalOffset0.z,e),this.zoomTo(this._zoom0,e)];return Promise.all(t)}saveState(){this._cameraUp0.copy(this._camera.up),this.getTarget(this._target0),this.getPosition(this._position0),this._zoom0=this._zoom,this._focalOffset0.copy(this._focalOffset)}updateCameraUp(){this._yAxisUpSpace.setFromUnitVectors(this._camera.up,Mi),this._yAxisUpSpaceInverse.copy(this._yAxisUpSpace).invert()}applyCameraUp(){const e=ft.subVectors(this._target,this._camera.position).normalize(),t=yt.crossVectors(e,this._camera.up);this._camera.up.crossVectors(t,e).normalize(),this._camera.updateMatrixWorld();const i=this.getPosition(ft);this.updateCameraUp(),this.setPosition(i.x,i.y,i.z)}update(e){const t=this._sphericalEnd.theta-this._spherical.theta,i=this._sphericalEnd.phi-this._spherical.phi,s=this._sphericalEnd.radius-this._spherical.radius,n=Mn.subVectors(this._targetEnd,this._target),r=Sn.subVectors(this._focalOffsetEnd,this._focalOffset),a=this._zoomEnd-this._zoom;if(Et(t)?(this._thetaVelocity.value=0,this._spherical.theta=this._sphericalEnd.theta):(this._spherical.theta=Pi(this._spherical.theta,this._sphericalEnd.theta,this._thetaVelocity,this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime,1/0,e),this._needsUpdate=!0),Et(i)?(this._phiVelocity.value=0,this._spherical.phi=this._sphericalEnd.phi):(this._spherical.phi=Pi(this._spherical.phi,this._sphericalEnd.phi,this._phiVelocity,this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime,1/0,e),this._needsUpdate=!0),Et(s)?(this._radiusVelocity.value=0,this._spherical.radius=this._sphericalEnd.radius):(this._spherical.radius=Pi(this._spherical.radius,this._sphericalEnd.radius,this._radiusVelocity,this._isUserControllingDolly?this.draggingSmoothTime:this.smoothTime,this.maxSpeed,e),this._needsUpdate=!0),Et(n.x)&&Et(n.y)&&Et(n.z)?(this._targetVelocity.set(0,0,0),this._target.copy(this._targetEnd)):(Pn(this._target,this._targetEnd,this._targetVelocity,this._isUserControllingTruck?this.draggingSmoothTime:this.smoothTime,this.maxSpeed,e,this._target),this._needsUpdate=!0),Et(r.x)&&Et(r.y)&&Et(r.z)?(this._focalOffsetVelocity.set(0,0,0),this._focalOffset.copy(this._focalOffsetEnd)):(Pn(this._focalOffset,this._focalOffsetEnd,this._focalOffsetVelocity,this._isUserControllingOffset?this.draggingSmoothTime:this.smoothTime,this.maxSpeed,e,this._focalOffset),this._needsUpdate=!0),Et(a)?(this._zoomVelocity.value=0,this._zoom=this._zoomEnd):this._zoom=Pi(this._zoom,this._zoomEnd,this._zoomVelocity,this._isUserControllingZoom?this.draggingSmoothTime:this.smoothTime,1/0,e),this.dollyToCursor)if(ae(this._camera)&&0!==this._changedDolly){const h=this._spherical.radius-this._lastDistance,f=this._camera,d=this._getCameraDirection(ii),y=ft.copy(d).cross(f.up).normalize();0===y.lengthSq()&&(y.x=1);const g=yt.crossVectors(y,d),_=this._sphericalEnd.radius*Math.tan(f.getEffectiveFOV()*Je*.5),x=(this._sphericalEnd.radius-h-this._sphericalEnd.radius)/this._sphericalEnd.radius,T=De.copy(this._targetEnd).add(y.multiplyScalar(this._dollyControlCoord.x*_*f.aspect)).add(g.multiplyScalar(this._dollyControlCoord.y*_)),E=ft.copy(this._targetEnd).lerp(T,x);if(this.infinityDolly&&(1===this._lastDollyDirection&&this._spherical.radius<=this.minDistance||-1===this._lastDollyDirection&&this.maxDistance<=this._spherical.radius)){this._sphericalEnd.radius-=h,this._spherical.radius-=h;const z=yt.copy(d).multiplyScalar(-h);E.add(z)}this._boundary.clampPoint(E,E);const M=yt.subVectors(E,this._targetEnd);this._targetEnd.copy(E),this._target.add(M),this._changedDolly-=h,Et(this._changedDolly)&&(this._changedDolly=0)}else if(le(this._camera)&&0!==this._changedZoom){const h=this._zoom-this._lastZoom,f=this._camera,d=ft.set(this._dollyControlCoord.x,this._dollyControlCoord.y,(f.near+f.far)/(f.near-f.far)).unproject(f),y=yt.set(0,0,-1).applyQuaternion(f.quaternion),g=De.copy(d).add(y.multiplyScalar(-d.dot(f.up))),m=-(this._zoom-h-this._zoom)/this._zoom,x=this._getCameraDirection(ii),T=this._targetEnd.dot(x),E=ft.copy(this._targetEnd).lerp(g,m),P=E.dot(x),I=x.multiplyScalar(P-T);E.sub(I),this._boundary.clampPoint(E,E);const M=yt.subVectors(E,this._targetEnd);this._targetEnd.copy(E),this._target.add(M),this._changedZoom-=h,Et(this._changedZoom)&&(this._changedZoom=0)}this._camera.zoom!==this._zoom&&(this._camera.zoom=this._zoom,this._camera.updateProjectionMatrix(),this._updateNearPlaneCorners(),this._needsUpdate=!0),this._dragNeedsUpdate=!0;const l=this._collisionTest();this._spherical.radius=Math.min(this._spherical.radius,l),this._spherical.makeSafe(),this._camera.position.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(this._target),this._camera.lookAt(this._target),(!Et(this._focalOffset.x)||!Et(this._focalOffset.y)||!Et(this._focalOffset.z))&&(this._camera.matrix.compose(this._camera.position,this._camera.quaternion,this._camera.scale),ce.setFromMatrixColumn(this._camera.matrix,0),ue.setFromMatrixColumn(this._camera.matrix,1),Ae.setFromMatrixColumn(this._camera.matrix,2),ce.multiplyScalar(this._focalOffset.x),ue.multiplyScalar(-this._focalOffset.y),Ae.multiplyScalar(this._focalOffset.z),ft.copy(ce).add(ue).add(Ae),this._camera.position.add(ft),this._camera.updateMatrixWorld()),this._boundaryEnclosesCamera&&this._encloseToBoundary(this._camera.position.copy(this._target),ft.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse),1);const u=this._needsUpdate;return u&&!this._updatedLastTime?(this._hasRested=!1,this.dispatchEvent({type:"wake"}),this.dispatchEvent({type:"update"})):u?(this.dispatchEvent({type:"update"}),Et(t,this.restThreshold)&&Et(i,this.restThreshold)&&Et(s,this.restThreshold)&&Et(n.x,this.restThreshold)&&Et(n.y,this.restThreshold)&&Et(n.z,this.restThreshold)&&Et(r.x,this.restThreshold)&&Et(r.y,this.restThreshold)&&Et(r.z,this.restThreshold)&&Et(a,this.restThreshold)&&!this._hasRested&&(this._hasRested=!0,this.dispatchEvent({type:"rest"}))):!u&&this._updatedLastTime&&this.dispatchEvent({type:"sleep"}),this._lastDistance=this._spherical.radius,this._lastZoom=this._zoom,this._updatedLastTime=u,this._needsUpdate=!1,u}toJSON(){return JSON.stringify({enabled:this._enabled,minDistance:this.minDistance,maxDistance:ti(this.maxDistance),minZoom:this.minZoom,maxZoom:ti(this.maxZoom),minPolarAngle:this.minPolarAngle,maxPolarAngle:ti(this.maxPolarAngle),minAzimuthAngle:ti(this.minAzimuthAngle),maxAzimuthAngle:ti(this.maxAzimuthAngle),smoothTime:this.smoothTime,draggingSmoothTime:this.draggingSmoothTime,dollySpeed:this.dollySpeed,truckSpeed:this.truckSpeed,dollyToCursor:this.dollyToCursor,target:this._targetEnd.toArray(),position:ft.setFromSpherical(this._sphericalEnd).add(this._targetEnd).toArray(),zoom:this._zoomEnd,focalOffset:this._focalOffsetEnd.toArray(),target0:this._target0.toArray(),position0:this._position0.toArray(),zoom0:this._zoom0,focalOffset0:this._focalOffset0.toArray()})}fromJSON(e,t=!1){const i=JSON.parse(e);this.enabled=i.enabled,this.minDistance=i.minDistance,this.maxDistance=ei(i.maxDistance),this.minZoom=i.minZoom,this.maxZoom=ei(i.maxZoom),this.minPolarAngle=i.minPolarAngle,this.maxPolarAngle=ei(i.maxPolarAngle),this.minAzimuthAngle=ei(i.minAzimuthAngle),this.maxAzimuthAngle=ei(i.maxAzimuthAngle),this.smoothTime=i.smoothTime,this.draggingSmoothTime=i.draggingSmoothTime,this.dollySpeed=i.dollySpeed,this.truckSpeed=i.truckSpeed,this.dollyToCursor=i.dollyToCursor,this._target0.fromArray(i.target0),this._position0.fromArray(i.position0),this._zoom0=i.zoom0,this._focalOffset0.fromArray(i.focalOffset0),this.moveTo(i.target[0],i.target[1],i.target[2],t),qt.setFromVector3(ft.fromArray(i.position).sub(this._targetEnd).applyQuaternion(this._yAxisUpSpace)),this.rotateTo(qt.theta,qt.phi,t),this.dollyTo(qt.radius,t),this.zoomTo(i.zoom,t),this.setFocalOffset(i.focalOffset[0],i.focalOffset[1],i.focalOffset[2],t),this._needsUpdate=!0}connect(e){this._domElement?console.warn("camera-controls is already connected."):(e.setAttribute("data-camera-controls-version","3.1.2"),this._addAllEventListeners(e),this._getClientRect(this._elementRect))}disconnect(){this.cancel(),this._removeAllEventListeners(),this._domElement&&(this._domElement.removeAttribute("data-camera-controls-version"),this._domElement=void 0)}dispose(){this.removeAllEventListeners(),this.disconnect()}_getTargetDirection(e){return e.setFromSpherical(this._spherical).divideScalar(this._spherical.radius).applyQuaternion(this._yAxisUpSpaceInverse)}_getCameraDirection(e){return this._getTargetDirection(e).negate()}_findPointerById(e){return this._activePointers.find(t=>t.pointerId===e)}_findPointerByMouseButton(e){return this._activePointers.find(t=>t.mouseButton===e)}_disposePointer(e){this._activePointers.splice(this._activePointers.indexOf(e),1)}_encloseToBoundary(e,t,i){const s=t.lengthSq();if(0===s)return e;const n=yt.copy(t).add(e),a=this._boundary.clampPoint(n,De).sub(n),l=a.lengthSq();if(0===l)return e.add(t);if(l===s)return e;if(0===i)return e.add(t).add(a);{const c=1+i*l/t.dot(a);return e.add(yt.copy(t).multiplyScalar(c)).add(a.multiplyScalar(1-i))}}_updateNearPlaneCorners(){if(ae(this._camera)){const e=this._camera,t=e.near,i=e.getEffectiveFOV()*Je,s=Math.tan(.5*i)*t,n=s*e.aspect;this._nearPlaneCorners[0].set(-n,-s,0),this._nearPlaneCorners[1].set(n,-s,0),this._nearPlaneCorners[2].set(n,s,0),this._nearPlaneCorners[3].set(-n,s,0)}else if(le(this._camera)){const e=this._camera,t=1/e.zoom,i=e.left*t,s=e.right*t,n=e.top*t,r=e.bottom*t;this._nearPlaneCorners[0].set(i,n,0),this._nearPlaneCorners[1].set(s,n,0),this._nearPlaneCorners[2].set(s,r,0),this._nearPlaneCorners[3].set(i,r,0)}}_truckInternal=(e,t,i,s)=>{let n,r;if(ae(this._camera)){const a=ft.copy(this._camera.position).sub(this._target),l=this._camera.getEffectiveFOV()*Je,c=a.length()*Math.tan(.5*l);n=this.truckSpeed*e*c/this._elementRect.height,r=this.truckSpeed*t*c/this._elementRect.height}else{if(!le(this._camera))return;{const a=this._camera;n=this.truckSpeed*e*(a.right-a.left)/a.zoom/this._elementRect.width,r=this.truckSpeed*t*(a.top-a.bottom)/a.zoom/this._elementRect.height}}s?(i?this.setFocalOffset(this._focalOffsetEnd.x+n,this._focalOffsetEnd.y,this._focalOffsetEnd.z,!0):this.truck(n,0,!0),this.forward(-r,!0)):i?this.setFocalOffset(this._focalOffsetEnd.x+n,this._focalOffsetEnd.y+r,this._focalOffsetEnd.z,!0):this.truck(n,r,!0)};_rotateInternal=(e,t)=>{this.rotate(ve*this.azimuthRotateSpeed*e/this._elementRect.height,ve*this.polarRotateSpeed*t/this._elementRect.height,!0)};_dollyInternal=(e,t,i)=>{const s=Math.pow(.95,-e*this.dollySpeed),n=this._sphericalEnd.radius,r=this._sphericalEnd.radius*s,a=ne(r,this.minDistance,this.maxDistance),l=a-r;this.infinityDolly&&this.dollyToCursor?this._dollyToNoClamp(r,!0):this.infinityDolly&&!this.dollyToCursor?(this.dollyInFixed(l,!0),this._dollyToNoClamp(a,!0)):this._dollyToNoClamp(a,!0),this.dollyToCursor&&(this._changedDolly+=(this.infinityDolly?r:a)-n,this._dollyControlCoord.set(t,i)),this._lastDollyDirection=Math.sign(-e)};_zoomInternal=(e,t,i)=>{const s=Math.pow(.95,e*this.dollySpeed),n=this._zoom,r=this._zoom*s;this.zoomTo(r,!0),this.dollyToCursor&&(this._changedZoom+=r-n,this._dollyControlCoord.set(t,i))};_collisionTest(){let e=1/0;if(!(this.colliderMeshes.length>=1)||fs(this._camera,"_collisionTest"))return e;const i=this._getTargetDirection(ii);_s.lookAt(An,i,this._camera.up);for(let s=0;s<4;s++){const n=yt.copy(this._nearPlaneCorners[s]);n.applyMatrix4(_s);const r=De.addVectors(this._target,n);Si.set(r,i),Si.far=this._spherical.radius+1;const a=Si.intersectObjects(this.colliderMeshes);0!==a.length&&a[0].distance<e&&(e=a[0].distance)}return e}_getClientRect(e){if(!this._domElement)return;const t=this._domElement.getBoundingClientRect();return e.x=t.left,e.y=t.top,this._viewport?(e.x+=this._viewport.x,e.y+=t.height-this._viewport.w-this._viewport.y,e.width=this._viewport.z,e.height=this._viewport.w):(e.width=t.width,e.height=t.height),e}_createOnRestPromise(e){return e?Promise.resolve():(this._hasRested=!1,this.dispatchEvent({type:"transitionstart"}),new Promise(t=>{const i=()=>{this.removeEventListener("rest",i),t()};this.addEventListener("rest",i)}))}_addAllEventListeners(e){}_removeAllEventListeners(){}get dampingFactor(){return console.warn(".dampingFactor has been deprecated. use smoothTime (in seconds) instead."),0}set dampingFactor(e){console.warn(".dampingFactor has been deprecated. use smoothTime (in seconds) instead.")}get draggingDampingFactor(){return console.warn(".draggingDampingFactor has been deprecated. use draggingSmoothTime (in seconds) instead."),0}set draggingDampingFactor(e){console.warn(".draggingDampingFactor has been deprecated. use draggingSmoothTime (in seconds) instead.")}static createBoundingSphere(e,t=new ct.Sphere){const i=t,s=i.center;Re.makeEmpty(),e.traverseVisible(r=>{r.isMesh&&Re.expandByObject(r)}),Re.getCenter(s);let n=0;return e.traverseVisible(r=>{if(!r.isMesh)return;const a=r;if(!a.geometry)return;const l=a.geometry.clone();l.applyMatrix4(a.matrixWorld);const u=l.attributes.position;for(let h=0,f=u.count;h<f;h++)ft.fromBufferAttribute(u,h),n=Math.max(n,s.distanceToSquared(ft))}),i.radius=Math.sqrt(n),i}}var Io=Object.defineProperty,w=(o,e,t)=>(((o,e,t)=>{e in o?Io(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t})(o,"symbol"!=typeof e?e+"":e,t),t);class X{constructor(){w(this,"enabled",!0),w(this,"trigger",e=>{if(!this.enabled)return;const t=this.handlers.slice(0);for(const i of t)i(e)}),w(this,"handlers",[])}add(e){this.handlers.push(e)}remove(e){this.handlers=this.handlers.filter(t=>t!==e)}reset(){this.handlers.length=0}}class ys{constructor(e){w(this,"isDisposeable",()=>"dispose"in this&&"onDisposed"in this),w(this,"isResizeable",()=>"resize"in this&&"getSize"in this),w(this,"isUpdateable",()=>"onAfterUpdate"in this&&"onBeforeUpdate"in this&&"update"in this),w(this,"isHideable",()=>"visible"in this),w(this,"isConfigurable",()=>"setup"in this&&"config"in this&&"onSetup"in this),w(this,"isSerializable",()=>"import"in this&&"export"in this),this.components=e}}class Pt extends ys{}class vs extends ys{constructor(e){super(e),w(this,"worlds",new dt.jp),w(this,"onWorldChanged",new X),w(this,"_currentWorld",null),this.onWorldChanged.add(({world:t,action:i})=>{"removed"===i&&this.worlds.delete(t.uuid)})}set currentWorld(e){this._currentWorld=e}get currentWorld(){return this._currentWorld}}class ko extends vs{constructor(){super(...arguments),w(this,"hasCameraControls",()=>"controls"in this)}}const kn=class _n extends Pt{constructor(e){super(e),w(this,"_disposedComponents",new Set),w(this,"enabled",!0),e.add(_n.uuid,this)}get(){return this._disposedComponents}destroy(e,t=!0,i=!0){e.removeFromParent();const s=e;s.dispose&&s.dispose(),this.disposeGeometryAndMaterials(e,t),i&&s.children&&s.children.length&&this.disposeChildren(s),e.children.length=0}disposeGeometry(e){e.boundsTree&&e.disposeBoundsTree&&e.disposeBoundsTree(),e.dispose()}disposeGeometryAndMaterials(e,t){const i=e;i.geometry&&this.disposeGeometry(i.geometry),t&&i.material&&_n.disposeMaterial(i),i.material=[],i.geometry=null}disposeChildren(e){for(const t of e.children)this.destroy(t)}static disposeMaterial(e){if(e.material)if(Array.isArray(e.material))for(const t of e.material)t.dispose();else e.material.dispose()}};w(kn,"uuid","76e9cd8e-ad8f-4753-9ef6-cbc60f7247fe");let si=kn;class Fo extends vs{constructor(e){super(e),w(this,"onDisposed",new X),w(this,"directionalLights",new Map),w(this,"ambientLights",new Map)}dispose(){const e=this.components.get(si);for(const t of this.three.children)t.geometry&&e.destroy(t);this.deleteAllLights(),this.three.children=[],this.onDisposed.trigger(),this.onDisposed.reset()}deleteAllLights(){for(const[,e]of this.directionalLights)e.removeFromParent(),e.target.removeFromParent(),e.dispose();this.directionalLights.clear();for(const[,e]of this.ambientLights)e.removeFromParent(),e.dispose();this.ambientLights.clear()}}Set;const bs=class Rt{static create(){const e=4294967295*Math.random()|0,t=4294967295*Math.random()|0,i=4294967295*Math.random()|0,s=4294967295*Math.random()|0;return`${Rt._lut[255&e]+Rt._lut[e>>8&255]+Rt._lut[e>>16&255]+Rt._lut[e>>24&255]}-${Rt._lut[255&t]}${Rt._lut[t>>8&255]}-${Rt._lut[t>>16&15|64]}${Rt._lut[t>>24&255]}-${Rt._lut[63&i|128]}${Rt._lut[i>>8&255]}-${Rt._lut[i>>16&255]}${Rt._lut[i>>24&255]}${Rt._lut[255&s]}${Rt._lut[s>>8&255]}${Rt._lut[s>>16&255]}${Rt._lut[s>>24&255]}`.toLowerCase()}static validate(e){if(!Rt._pattern.test(e))throw new Error(`${e} is not a valid UUID v4.\n\n- If you're the tool creator, you can take one from https://www.uuidgenerator.net/.\n\n- If you're using a platform tool, verify the uuid isn't misspelled or contact the tool creator.`)}};w(bs,"_pattern",/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$/),w(bs,"_lut",["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"]);let Wt=bs;const zn=":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",Ro=new RegExp("^["+zn+"]["+zn+"\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$");function Fn(o,e){const t=[];let i=e.exec(o);for(;i;){const s=[];s.startIndex=e.lastIndex-i[0].length;const n=i.length;for(let r=0;r<n;r++)s.push(i[r]);t.push(s),i=e.exec(o)}return t}const Ii=function(o){const e=Ro.exec(o);return!(null===e||typeof e>"u")},Lo={allowBooleanAttributes:!1,unpairedTags:[]};function Dn(o){return" "===o||"\t"===o||"\n"===o||"\r"===o}function Nn(o,e){const t=e;for(;e<o.length;e++)if("?"==o[e]||" "==o[e]){const i=o.substr(t,e-t);if(e>5&&"xml"===i)return kt("InvalidXml","XML declaration allowed only at the start of the document.",jt(o,e));if("?"==o[e]&&">"==o[e+1]){e++;break}continue}return e}function Rn(o,e){if(o.length>e+5&&"-"===o[e+1]&&"-"===o[e+2]){for(e+=3;e<o.length;e++)if("-"===o[e]&&"-"===o[e+1]&&">"===o[e+2]){e+=2;break}}else if(o.length>e+8&&"D"===o[e+1]&&"O"===o[e+2]&&"C"===o[e+3]&&"T"===o[e+4]&&"Y"===o[e+5]&&"P"===o[e+6]&&"E"===o[e+7]){let t=1;for(e+=8;e<o.length;e++)if("<"===o[e])t++;else if(">"===o[e]&&(t--,0===t))break}else if(o.length>e+9&&"["===o[e+1]&&"C"===o[e+2]&&"D"===o[e+3]&&"A"===o[e+4]&&"T"===o[e+5]&&"A"===o[e+6]&&"["===o[e+7])for(e+=8;e<o.length;e++)if("]"===o[e]&&"]"===o[e+1]&&">"===o[e+2]){e+=2;break}return e}function jo(o,e){let t="",i="",s=!1;for(;e<o.length;e++){if('"'===o[e]||"'"===o[e])""===i?i=o[e]:i!==o[e]||(i="");else if(">"===o[e]&&""===i){s=!0;break}t+=o[e]}return""===i&&{value:t,index:e,tagClosed:s}}const Ho=new RegExp("(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['\"])(([\\s\\S])*?)\\5)?","g");function Bn(o,e){const t=Fn(o,Ho),i={};for(let s=0;s<t.length;s++){if(0===t[s][1].length)return kt("InvalidAttr","Attribute '"+t[s][2]+"' has no space in starting.",ni(t[s]));if(void 0!==t[s][3]&&void 0===t[s][4])return kt("InvalidAttr","Attribute '"+t[s][2]+"' is without value.",ni(t[s]));if(void 0===t[s][3]&&!e.allowBooleanAttributes)return kt("InvalidAttr","boolean attribute '"+t[s][2]+"' is not allowed.",ni(t[s]));const n=t[s][2];if(!Wo(n))return kt("InvalidAttr","Attribute '"+n+"' is an invalid name.",ni(t[s]));if(i.hasOwnProperty(n))return kt("InvalidAttr","Attribute '"+n+"' is repeated.",ni(t[s]));i[n]=1}return!0}function Zo(o,e){if(";"===o[++e])return-1;if("#"===o[e])return function Yo(o,e){let t=/\d/;for("x"===o[e]&&(e++,t=/[\da-fA-F]/);e<o.length;e++){if(";"===o[e])return e;if(!o[e].match(t))break}return-1}(o,++e);let t=0;for(;e<o.length;e++,t++)if(!(o[e].match(/\w/)&&t<20)){if(";"===o[e])break;return-1}return e}function kt(o,e,t){return{err:{code:o,msg:e,line:t.line||t,col:t.col}}}function Wo(o){return Ii(o)}function Go(o){return Ii(o)}function jt(o,e){const t=o.substring(0,e).split(/\r?\n/);return{line:t.length,col:t[t.length-1].length+1}}function ni(o){return o.startIndex+o[1].length}const qo={preserveOrder:!1,attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,removeNSPrefix:!1,allowBooleanAttributes:!1,parseTagValue:!0,parseAttributeValue:!1,trimValues:!0,cdataPropName:!1,numberParseOptions:{hex:!0,leadingZeros:!0,eNotation:!0},tagValueProcessor:function(o,e){return e},attributeValueProcessor:function(o,e){return e},stopNodes:[],alwaysCreateTextNode:!1,isArray:()=>!1,commentPropName:!1,unpairedTags:[],processEntities:!0,htmlEntities:!1,ignoreDeclaration:!1,ignorePiTags:!1,transformTagName:!1,transformAttributeName:!1,updateTag:function(o,e,t){return o},captureMetaData:!1};function Ln(o){return"boolean"==typeof o?{enabled:o,maxEntitySize:1e4,maxExpansionDepth:10,maxTotalExpansions:1e3,maxExpandedLength:1e5,allowedTags:null,tagFilter:null}:"object"==typeof o&&null!==o?{enabled:!1!==o.enabled,maxEntitySize:o.maxEntitySize??1e4,maxExpansionDepth:o.maxExpansionDepth??10,maxTotalExpansions:o.maxTotalExpansions??1e3,maxExpandedLength:o.maxExpandedLength??1e5,allowedTags:o.allowedTags??null,tagFilter:o.tagFilter??null}:Ln(!0)}const Xo=function(o){const e=Object.assign({},qo,o);return e.processEntities=Ln(e.processEntities),e};let Oi;Oi="function"!=typeof Symbol?"@@xmlMetadata":Symbol("XML Node Metadata");class Me{constructor(e){this.tagname=e,this.child=[],this[":@"]={}}add(e,t){"__proto__"===e&&(e="#__proto__"),this.child.push({[e]:t})}addChild(e,t){"__proto__"===e.tagname&&(e.tagname="#__proto__"),e[":@"]&&Object.keys(e[":@"]).length>0?this.child.push({[e.tagname]:e.child,":@":e[":@"]}):this.child.push({[e.tagname]:e.child}),void 0!==t&&(this.child[this.child.length-1][Oi]={startIndex:t})}static getMetaDataSymbol(){return Oi}}class Qo{constructor(e){this.suppressValidationErr=!e,this.options=e}readDocType(e,t){const i={};if("O"!==e[t+3]||"C"!==e[t+4]||"T"!==e[t+5]||"Y"!==e[t+6]||"P"!==e[t+7]||"E"!==e[t+8])throw new Error("Invalid Tag instead of DOCTYPE");{t+=9;let s=1,n=!1,r=!1,a="";for(;t<e.length;t++)if("<"!==e[t]||r)if(">"===e[t]){if(r?"-"===e[t-1]&&"-"===e[t-2]&&(r=!1,s--):s--,0===s)break}else"["===e[t]?n=!0:a+=e[t];else{if(n&&Se(e,"!ENTITY",t)){let l,c;if(t+=7,[l,c,t]=this.readEntityExp(e,t+1,this.suppressValidationErr),-1===c.indexOf("&")){const u=l.replace(/[.\-+*:]/g,"\\.");i[l]={regx:RegExp(`&${u};`,"g"),val:c}}}else if(n&&Se(e,"!ELEMENT",t)){t+=8;const{index:l}=this.readElementExp(e,t+1);t=l}else if(n&&Se(e,"!ATTLIST",t))t+=8;else if(n&&Se(e,"!NOTATION",t)){t+=9;const{index:l}=this.readNotationExp(e,t+1,this.suppressValidationErr);t=l}else{if(!Se(e,"!--",t))throw new Error("Invalid DOCTYPE");r=!0}s++,a=""}if(0!==s)throw new Error("Unclosed DOCTYPE")}return{entities:i,i:t}}readEntityExp(e,t){t=Gt(e,t);let i="";for(;t<e.length&&!/\s/.test(e[t])&&'"'!==e[t]&&"'"!==e[t];)i+=e[t],t++;if(ri(i),t=Gt(e,t),!this.suppressValidationErr){if("SYSTEM"===e.substring(t,t+6).toUpperCase())throw new Error("External entities are not supported");if("%"===e[t])throw new Error("Parameter entities are not supported")}let s="";if([t,s]=this.readIdentifierVal(e,t,"entity"),!1!==this.options.enabled&&this.options.maxEntitySize&&s.length>this.options.maxEntitySize)throw new Error(`Entity "${i}" size (${s.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`);return[i,s,--t]}readNotationExp(e,t){t=Gt(e,t);let i="";for(;t<e.length&&!/\s/.test(e[t]);)i+=e[t],t++;!this.suppressValidationErr&&ri(i),t=Gt(e,t);const s=e.substring(t,t+6).toUpperCase();if(!this.suppressValidationErr&&"SYSTEM"!==s&&"PUBLIC"!==s)throw new Error(`Expected SYSTEM or PUBLIC, found "${s}"`);t=Gt(e,t+=s.length);let n=null,r=null;if("PUBLIC"===s)[t,n]=this.readIdentifierVal(e,t,"publicIdentifier"),('"'===e[t=Gt(e,t)]||"'"===e[t])&&([t,r]=this.readIdentifierVal(e,t,"systemIdentifier"));else if("SYSTEM"===s&&([t,r]=this.readIdentifierVal(e,t,"systemIdentifier"),!this.suppressValidationErr&&!r))throw new Error("Missing mandatory system identifier for SYSTEM notation");return{notationName:i,publicIdentifier:n,systemIdentifier:r,index:--t}}readIdentifierVal(e,t,i){let s="";const n=e[t];if('"'!==n&&"'"!==n)throw new Error(`Expected quoted string, found "${n}"`);for(t++;t<e.length&&e[t]!==n;)s+=e[t],t++;if(e[t]!==n)throw new Error(`Unterminated ${i} value`);return[++t,s]}readElementExp(e,t){t=Gt(e,t);let i="";for(;t<e.length&&!/\s/.test(e[t]);)i+=e[t],t++;if(!this.suppressValidationErr&&!Ii(i))throw new Error(`Invalid element name: "${i}"`);let s="";if("E"===e[t=Gt(e,t)]&&Se(e,"MPTY",t))t+=4;else if("A"===e[t]&&Se(e,"NY",t))t+=2;else if("("===e[t]){for(t++;t<e.length&&")"!==e[t];)s+=e[t],t++;if(")"!==e[t])throw new Error("Unterminated content model")}else if(!this.suppressValidationErr)throw new Error(`Invalid Element Expression, found "${e[t]}"`);return{elementName:i,contentModel:s.trim(),index:t}}readAttlistExp(e,t){t=Gt(e,t);let i="";for(;t<e.length&&!/\s/.test(e[t]);)i+=e[t],t++;ri(i),t=Gt(e,t);let s="";for(;t<e.length&&!/\s/.test(e[t]);)s+=e[t],t++;if(!ri(s))throw new Error(`Invalid attribute name: "${s}"`);t=Gt(e,t);let n="";if("NOTATION"===e.substring(t,t+8).toUpperCase()){if(n="NOTATION","("!==e[t=Gt(e,t+=8)])throw new Error(`Expected '(', found "${e[t]}"`);t++;let a=[];for(;t<e.length&&")"!==e[t];){let l="";for(;t<e.length&&"|"!==e[t]&&")"!==e[t];)l+=e[t],t++;if(l=l.trim(),!ri(l))throw new Error(`Invalid notation name: "${l}"`);a.push(l),"|"===e[t]&&(t++,t=Gt(e,t))}if(")"!==e[t])throw new Error("Unterminated list of notations");t++,n+=" ("+a.join("|")+")"}else{for(;t<e.length&&!/\s/.test(e[t]);)n+=e[t],t++;if(!this.suppressValidationErr&&!["CDATA","ID","IDREF","IDREFS","ENTITY","ENTITIES","NMTOKEN","NMTOKENS"].includes(n.toUpperCase()))throw new Error(`Invalid attribute type: "${n}"`)}t=Gt(e,t);let r="";return"#REQUIRED"===e.substring(t,t+8).toUpperCase()?(r="#REQUIRED",t+=8):"#IMPLIED"===e.substring(t,t+7).toUpperCase()?(r="#IMPLIED",t+=7):[t,r]=this.readIdentifierVal(e,t,"ATTLIST"),{elementName:i,attributeName:s,attributeType:n,defaultValue:r,index:t}}}const Gt=(o,e)=>{for(;e<o.length&&/\s/.test(o[e]);)e++;return e};function Se(o,e,t){for(let i=0;i<e.length;i++)if(e[i]!==o[t+i+1])return!1;return!0}function ri(o){if(Ii(o))return o;throw new Error(`Invalid entity name ${o}`)}const Ko=/^[-+]?0x[a-fA-F0-9]+$/,Jo=/^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/,ta={hex:!0,leadingZeros:!0,decimalPoint:".",eNotation:!0};const ia=/^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/;function Vn(o){return"function"==typeof o?o:Array.isArray(o)?e=>{for(const t of o)if("string"==typeof t&&e===t||t instanceof RegExp&&t.test(e))return!0}:()=>!1}class oa{constructor(e){if(this.options=e,this.currentNode=null,this.tagsNodeStack=[],this.docTypeEntities={},this.lastEntities={apos:{regex:/&(apos|#39|#x27);/g,val:"'"},gt:{regex:/&(gt|#62|#x3E);/g,val:">"},lt:{regex:/&(lt|#60|#x3C);/g,val:"<"},quot:{regex:/&(quot|#34|#x22);/g,val:'"'}},this.ampEntity={regex:/&(amp|#38|#x26);/g,val:"&"},this.htmlEntities={space:{regex:/&(nbsp|#160);/g,val:" "},cent:{regex:/&(cent|#162);/g,val:"\xa2"},pound:{regex:/&(pound|#163);/g,val:"\xa3"},yen:{regex:/&(yen|#165);/g,val:"\xa5"},euro:{regex:/&(euro|#8364);/g,val:"\u20ac"},copyright:{regex:/&(copy|#169);/g,val:"\xa9"},reg:{regex:/&(reg|#174);/g,val:"\xae"},inr:{regex:/&(inr|#8377);/g,val:"\u20b9"},num_dec:{regex:/&#([0-9]{1,7});/g,val:(t,i)=>Un(i,10,"&#")},num_hex:{regex:/&#x([0-9a-fA-F]{1,6});/g,val:(t,i)=>Un(i,16,"&#x")}},this.addExternalEntities=aa,this.parseXml=da,this.parseTextData=la,this.resolveNameSpace=ca,this.buildAttributesMap=ha,this.isItStopNode=ga,this.replaceEntitiesValue=pa,this.readStopNodeData=ya,this.saveTextToParentTag=ma,this.addChild=fa,this.ignoreAttributesFn=Vn(this.options.ignoreAttributes),this.entityExpansionCount=0,this.currentExpandedLength=0,this.options.stopNodes&&this.options.stopNodes.length>0){this.stopNodesExact=new Set,this.stopNodesWildcard=new Set;for(let t=0;t<this.options.stopNodes.length;t++){const i=this.options.stopNodes[t];"string"==typeof i&&(i.startsWith("*.")?this.stopNodesWildcard.add(i.substring(2)):this.stopNodesExact.add(i))}}}}function aa(o){const e=Object.keys(o);for(let t=0;t<e.length;t++){const i=e[t],s=i.replace(/[.\-+*:]/g,"\\.");this.lastEntities[i]={regex:new RegExp("&"+s+";","g"),val:o[i]}}}function la(o,e,t,i,s,n,r){if(void 0!==o&&(this.options.trimValues&&!i&&(o=o.trim()),o.length>0)){r||(o=this.replaceEntitiesValue(o,e,t));const a=this.options.tagValueProcessor(e,o,t,s,n);return null==a?o:typeof a!=typeof o||a!==o?a:this.options.trimValues||o.trim()===o?xs(o,this.options.parseTagValue,this.options.numberParseOptions):o}}function ca(o){if(this.options.removeNSPrefix){const e=o.split(":"),t="/"===o.charAt(0)?"/":"";if("xmlns"===e[0])return"";2===e.length&&(o=t+e[1])}return o}const ua=new RegExp("([^\\s=]+)\\s*(=\\s*(['\"])([\\s\\S]*?)\\3)?","gm");function ha(o,e,t){if(!0!==this.options.ignoreAttributes&&"string"==typeof o){const i=Fn(o,ua),s=i.length,n={};for(let r=0;r<s;r++){const a=this.resolveNameSpace(i[r][1]);if(this.ignoreAttributesFn(a,e))continue;let l=i[r][4],c=this.options.attributeNamePrefix+a;if(a.length)if(this.options.transformAttributeName&&(c=this.options.transformAttributeName(c)),"__proto__"===c&&(c="#__proto__"),void 0!==l){this.options.trimValues&&(l=l.trim()),l=this.replaceEntitiesValue(l,t,e);const u=this.options.attributeValueProcessor(a,l,e);n[c]=null==u?l:typeof u!=typeof l||u!==l?u:xs(l,this.options.parseAttributeValue,this.options.numberParseOptions)}else this.options.allowBooleanAttributes&&(n[c]=!0)}if(!Object.keys(n).length)return;if(this.options.attributesGroupName){const r={};return r[this.options.attributesGroupName]=n,r}return n}}const da=function(o){o=o.replace(/\r\n?/g,"\n");const e=new Me("!xml");let t=e,i="",s="";this.entityExpansionCount=0,this.currentExpandedLength=0;const n=new Qo(this.options.processEntities);for(let r=0;r<o.length;r++)if("<"===o[r])if("/"===o[r+1]){const l=Ie(o,">",r,"Closing Tag is not closed.");let c=o.substring(r+2,l).trim();if(this.options.removeNSPrefix){const f=c.indexOf(":");-1!==f&&(c=c.substr(f+1))}this.options.transformTagName&&(c=this.options.transformTagName(c)),t&&(i=this.saveTextToParentTag(i,t,s));const u=s.substring(s.lastIndexOf(".")+1);if(c&&-1!==this.options.unpairedTags.indexOf(c))throw new Error(`Unpaired tag can not be used as closing tag: </${c}>`);let h=0;u&&-1!==this.options.unpairedTags.indexOf(u)?(h=s.lastIndexOf(".",s.lastIndexOf(".")-1),this.tagsNodeStack.pop()):h=s.lastIndexOf("."),s=s.substring(0,h),t=this.tagsNodeStack.pop(),i="",r=l}else if("?"===o[r+1]){let l=ws(o,r,!1,"?>");if(!l)throw new Error("Pi Tag is not closed.");if(i=this.saveTextToParentTag(i,t,s),!(this.options.ignoreDeclaration&&"?xml"===l.tagName||this.options.ignorePiTags)){const c=new Me(l.tagName);c.add(this.options.textNodeName,""),l.tagName!==l.tagExp&&l.attrExpPresent&&(c[":@"]=this.buildAttributesMap(l.tagExp,s,l.tagName)),this.addChild(t,c,s,r)}r=l.closeIndex+1}else if("!--"===o.substr(r+1,3)){const l=Ie(o,"--\x3e",r+4,"Comment is not closed.");if(this.options.commentPropName){const c=o.substring(r+4,l-2);i=this.saveTextToParentTag(i,t,s),t.add(this.options.commentPropName,[{[this.options.textNodeName]:c}])}r=l}else if("!D"===o.substr(r+1,2)){const l=n.readDocType(o,r);this.docTypeEntities=l.entities,r=l.i}else if("!["===o.substr(r+1,2)){const l=Ie(o,"]]>",r,"CDATA is not closed.")-2,c=o.substring(r+9,l);i=this.saveTextToParentTag(i,t,s);let u=this.parseTextData(c,t.tagname,s,!0,!1,!0,!0);null==u&&(u=""),this.options.cdataPropName?t.add(this.options.cdataPropName,[{[this.options.textNodeName]:c}]):t.add(this.options.textNodeName,u),r=l+2}else{let l=ws(o,r,this.options.removeNSPrefix),c=l.tagName;const u=l.rawTagName;let h=l.tagExp,f=l.attrExpPresent,d=l.closeIndex;if(this.options.transformTagName){const _=this.options.transformTagName(c);h===c&&(h=_),c=_}t&&i&&"!xml"!==t.tagname&&(i=this.saveTextToParentTag(i,t,s,!1)),t&&-1!==this.options.unpairedTags.indexOf(t.tagname)&&(t=this.tagsNodeStack.pop(),s=s.substring(0,s.lastIndexOf("."))),c!==e.tagname&&(s+=s?"."+c:c);const g=r;if(this.isItStopNode(this.stopNodesExact,this.stopNodesWildcard,s,c)){let _="";if(h.length>0&&h.lastIndexOf("/")===h.length-1)"/"===c[c.length-1]?(c=c.substr(0,c.length-1),s=s.substr(0,s.length-1),h=c):h=h.substr(0,h.length-1),r=l.closeIndex;else if(-1!==this.options.unpairedTags.indexOf(c))r=l.closeIndex;else{const x=this.readStopNodeData(o,u,d+1);if(!x)throw new Error(`Unexpected end of ${u}`);r=x.i,_=x.tagContent}const m=new Me(c);c!==h&&f&&(m[":@"]=this.buildAttributesMap(h,s,c)),_&&(_=this.parseTextData(_,c,s,!0,f,!0,!0)),s=s.substr(0,s.lastIndexOf(".")),m.add(this.options.textNodeName,_),this.addChild(t,m,s,g)}else{if(h.length>0&&h.lastIndexOf("/")===h.length-1){if("/"===c[c.length-1]?(c=c.substr(0,c.length-1),s=s.substr(0,s.length-1),h=c):h=h.substr(0,h.length-1),this.options.transformTagName){const m=this.options.transformTagName(c);h===c&&(h=m),c=m}const _=new Me(c);c!==h&&f&&(_[":@"]=this.buildAttributesMap(h,s,c)),this.addChild(t,_,s,g),s=s.substr(0,s.lastIndexOf("."))}else{const _=new Me(c);this.tagsNodeStack.push(t),c!==h&&f&&(_[":@"]=this.buildAttributesMap(h,s,c)),this.addChild(t,_,s,g),t=_}i="",r=d}}else i+=o[r];return e.child};function fa(o,e,t,i){this.options.captureMetaData||(i=void 0);const s=this.options.updateTag(e.tagname,t,e[":@"]);!1===s||("string"==typeof s&&(e.tagname=s),o.addChild(e,i))}const pa=function(o,e,t){if(-1===o.indexOf("&"))return o;const i=this.options.processEntities;if(!i.enabled||i.allowedTags&&!i.allowedTags.includes(e)||i.tagFilter&&!i.tagFilter(e,t))return o;for(let s in this.docTypeEntities){const n=this.docTypeEntities[s],r=o.match(n.regx);if(r){if(this.entityExpansionCount+=r.length,i.maxTotalExpansions&&this.entityExpansionCount>i.maxTotalExpansions)throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${i.maxTotalExpansions}`);const a=o.length;if(o=o.replace(n.regx,n.val),i.maxExpandedLength&&(this.currentExpandedLength+=o.length-a,this.currentExpandedLength>i.maxExpandedLength))throw new Error(`Total expanded content size exceeded: ${this.currentExpandedLength} > ${i.maxExpandedLength}`)}}if(-1===o.indexOf("&"))return o;for(let s in this.lastEntities){const n=this.lastEntities[s];o=o.replace(n.regex,n.val)}if(-1===o.indexOf("&"))return o;if(this.options.htmlEntities)for(let s in this.htmlEntities){const n=this.htmlEntities[s];o=o.replace(n.regex,n.val)}return o.replace(this.ampEntity.regex,this.ampEntity.val)};function ma(o,e,t,i){return o&&(void 0===i&&(i=0===e.child.length),void 0!==(o=this.parseTextData(o,e.tagname,t,!1,!!e[":@"]&&0!==Object.keys(e[":@"]).length,i))&&""!==o&&e.add(this.options.textNodeName,o),o=""),o}function ga(o,e,t,i){return!!(e&&e.has(i)||o&&o.has(t))}function Ie(o,e,t,i){const s=o.indexOf(e,t);if(-1===s)throw new Error(i);return s+e.length-1}function ws(o,e,t,i=">"){const s=function _a(o,e,t=">"){let i,s="";for(let n=e;n<o.length;n++){let r=o[n];if(i)r===i&&(i="");else if('"'===r||"'"===r)i=r;else if(r===t[0]){if(!t[1])return{data:s,index:n};if(o[n+1]===t[1])return{data:s,index:n}}else"\t"===r&&(r=" ");s+=r}}(o,e+1,i);if(!s)return;let n=s.data;const r=s.index,a=n.search(/\s/);let l=n,c=!0;-1!==a&&(l=n.substring(0,a),n=n.substring(a+1).trimStart());const u=l;if(t){const h=l.indexOf(":");-1!==h&&(l=l.substr(h+1),c=l!==s.data.substr(h+1))}return{tagName:l,tagExp:n,closeIndex:r,attrExpPresent:c,rawTagName:u}}function ya(o,e,t){const i=t;let s=1;for(;t<o.length;t++)if("<"===o[t])if("/"===o[t+1]){const n=Ie(o,">",t,`${e} is not closed`);if(o.substring(t+2,n).trim()===e&&(s--,0===s))return{tagContent:o.substring(i,t),i:n};t=n}else if("?"===o[t+1])t=Ie(o,"?>",t+1,"StopNode is not closed.");else if("!--"===o.substr(t+1,3))t=Ie(o,"--\x3e",t+3,"StopNode is not closed.");else if("!["===o.substr(t+1,2))t=Ie(o,"]]>",t,"StopNode is not closed.")-2;else{const n=ws(o,t,">");n&&((n&&n.tagName)===e&&"/"!==n.tagExp[n.tagExp.length-1]&&s++,t=n.closeIndex)}}function xs(o,e,t){if(e&&"string"==typeof o){const i=o.trim();return"true"===i||"false"!==i&&function ea(o,e={}){if(e=Object.assign({},ta,e),!o||"string"!=typeof o)return o;let t=o.trim();if(void 0!==e.skipLike&&e.skipLike.test(t))return o;if("0"===o)return 0;if(e.hex&&Ko.test(t))return function ra(o,e){if(parseInt)return parseInt(o,e);if(Number.parseInt)return Number.parseInt(o,e);if(window&&window.parseInt)return window.parseInt(o,e);throw new Error("parseInt, Number.parseInt, window.parseInt are not supported")}(t,16);if(t.includes("e")||t.includes("E"))return function sa(o,e,t){if(!t.eNotation)return o;const i=e.match(ia);if(i){let s=i[1]||"";const n=-1===i[3].indexOf("e")?"E":"e",r=i[2],a=s?o[r.length+1]===n:o[r.length]===n;return r.length>1&&a?o:1!==r.length||!i[3].startsWith(`.${n}`)&&i[3][0]!==n?t.leadingZeros&&!a?(e=(i[1]||"")+i[3],Number(e)):o:Number(e)}return o}(o,t,e);{const i=Jo.exec(t);if(i){const s=i[1]||"",n=i[2];let r=function na(o){return o&&-1!==o.indexOf(".")&&("."===(o=o.replace(/0+$/,""))?o="0":"."===o[0]?o="0"+o:"."===o[o.length-1]&&(o=o.substring(0,o.length-1))),o}(i[3]);if(!e.leadingZeros&&(n.length>1||1===n.length&&!(s?"."===o[n.length+1]:"."===o[n.length])))return o;{const l=Number(t),c=String(l);if(0===l)return l;if(-1!==c.search(/[eE]/))return e.eNotation?l:o;if(-1!==t.indexOf("."))return"0"===c||c===r||c===`${s}${r}`?l:o;let u=n?r:t;return n?u===c||s+u===c?l:o:u===c||u===s+c?l:o}}return o}}(o,t)}return function Bo(o){return typeof o<"u"}(o)?o:""}function Un(o,e,t){const i=Number.parseInt(o,e);return i>=0&&i<=1114111?String.fromCodePoint(i):t+o+";"}const Cs=Me.getMetaDataSymbol();function va(o,e){return $n(o,e)}function $n(o,e,t){let i;const s={};for(let n=0;n<o.length;n++){const r=o[n],a=ba(r);let l="";if(l=void 0===t?a:t+"."+a,a===e.textNodeName)void 0===i?i=r[a]:i+=""+r[a];else{if(void 0===a)continue;if(r[a]){let c=$n(r[a],e,l);const u=xa(c,e);void 0!==r[Cs]&&(c[Cs]=r[Cs]),r[":@"]?wa(c,r[":@"],l,e):1!==Object.keys(c).length||void 0===c[e.textNodeName]||e.alwaysCreateTextNode?0===Object.keys(c).length&&(e.alwaysCreateTextNode?c[e.textNodeName]="":c=""):c=c[e.textNodeName],void 0!==s[a]&&s.hasOwnProperty(a)?(Array.isArray(s[a])||(s[a]=[s[a]]),s[a].push(c)):s[a]=e.isArray(a,l,u)?[c]:c}}}return"string"==typeof i?i.length>0&&(s[e.textNodeName]=i):void 0!==i&&(s[e.textNodeName]=i),s}function ba(o){const e=Object.keys(o);for(let t=0;t<e.length;t++){const i=e[t];if(":@"!==i)return i}}function wa(o,e,t,i){if(e){const s=Object.keys(e),n=s.length;for(let r=0;r<n;r++){const a=s[r];o[a]=i.isArray(a,t+"."+a,!0,!0)?[e[a]]:e[a]}}}function xa(o,e){const{textNodeName:t}=e,i=Object.keys(o).length;return!(0!==i&&(1!==i||!o[t]&&"boolean"!=typeof o[t]&&0!==o[t]))}class Es{constructor(e){this.externalEntities={},this.options=Xo(e)}parse(e,t){if("string"!=typeof e&&e.toString)e=e.toString();else if("string"!=typeof e)throw new Error("XML data is accepted in String or Bytes[] form.");if(t){!0===t&&(t={});const n=function Vo(o,e){e=Object.assign({},Lo,e);const t=[];let i=!1,s=!1;"\ufeff"===o[0]&&(o=o.substr(1));for(let n=0;n<o.length;n++)if("<"===o[n]&&"?"===o[n+1]){if(n+=2,n=Nn(o,n),n.err)return n}else{if("<"!==o[n]){if(Dn(o[n]))continue;return kt("InvalidChar","char '"+o[n]+"' is not expected.",jt(o,n))}{let r=n;if(n++,"!"===o[n]){n=Rn(o,n);continue}{let a=!1;"/"===o[n]&&(a=!0,n++);let l="";for(;n<o.length&&">"!==o[n]&&" "!==o[n]&&"\t"!==o[n]&&"\n"!==o[n]&&"\r"!==o[n];n++)l+=o[n];if(l=l.trim(),"/"===l[l.length-1]&&(l=l.substring(0,l.length-1),n--),!Go(l)){let h;return h=0===l.trim().length?"Invalid space after '<'.":"Tag '"+l+"' is an invalid name.",kt("InvalidTag",h,jt(o,n))}const c=jo(o,n);if(!1===c)return kt("InvalidAttr","Attributes for '"+l+"' have open quote.",jt(o,n));let u=c.value;if(n=c.index,"/"===u[u.length-1]){const h=n-u.length;u=u.substring(0,u.length-1);const f=Bn(u,e);if(!0!==f)return kt(f.err.code,f.err.msg,jt(o,h+f.err.line));i=!0}else if(a){if(!c.tagClosed)return kt("InvalidTag","Closing tag '"+l+"' doesn't have proper closing.",jt(o,n));if(u.trim().length>0)return kt("InvalidTag","Closing tag '"+l+"' can't have attributes or invalid starting.",jt(o,r));if(0===t.length)return kt("InvalidTag","Closing tag '"+l+"' has not been opened.",jt(o,r));{const h=t.pop();if(l!==h.tagName){let f=jt(o,h.tagStartPos);return kt("InvalidTag","Expected closing tag '"+h.tagName+"' (opened in line "+f.line+", col "+f.col+") instead of closing tag '"+l+"'.",jt(o,r))}0==t.length&&(s=!0)}}else{const h=Bn(u,e);if(!0!==h)return kt(h.err.code,h.err.msg,jt(o,n-u.length+h.err.line));if(!0===s)return kt("InvalidXml","Multiple possible root nodes found.",jt(o,n));-1!==e.unpairedTags.indexOf(l)||t.push({tagName:l,tagStartPos:r}),i=!0}for(n++;n<o.length;n++)if("<"===o[n]){if("!"===o[n+1]){n++,n=Rn(o,n);continue}if("?"!==o[n+1])break;if(n=Nn(o,++n),n.err)return n}else if("&"===o[n]){const h=Zo(o,n);if(-1==h)return kt("InvalidChar","char '&' is not expected.",jt(o,n));n=h}else if(!0===s&&!Dn(o[n]))return kt("InvalidXml","Extra text at the end",jt(o,n));"<"===o[n]&&n--}}}return i?1==t.length?kt("InvalidTag","Unclosed tag '"+t[0].tagName+"'.",jt(o,t[0].tagStartPos)):!(t.length>0)||kt("InvalidXml","Invalid '"+JSON.stringify(t.map(n=>n.tagName),null,4).replace(/\r?\n/g,"")+"' found.",{line:1,col:1}):kt("InvalidXml","Start tag expected.",1)}(e,t);if(!0!==n)throw Error(`${n.err.msg}:${n.err.line}:${n.err.col}`)}const i=new oa(this.options);i.addExternalEntities(this.externalEntities);const s=i.parseXml(e);return this.options.preserveOrder||void 0===s?s:va(s,this.options)}addEntity(e,t){if(-1!==t.indexOf("&"))throw new Error("Entity value can't have '&'");if(-1!==e.indexOf("&")||-1!==e.indexOf(";"))throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '
'");if("&"===t)throw new Error("An entity with value '&' is not permitted");this.externalEntities[e]=t}static getMetaDataSymbol(){return Me.getMetaDataSymbol()}}function Ea(o,e){let t="";return e.format&&e.indentBy.length>0&&(t="\n"),jn(o,e,"",t)}function jn(o,e,t,i){let s="",n=!1;for(let r=0;r<o.length;r++){const a=o[r],l=Ta(a);if(void 0===l)continue;let c="";if(c=0===t.length?l:`${t}.${l}`,l===e.textNodeName){let y=a[l];Pa(c,e)||(y=e.tagValueProcessor(l,y),y=Yn(y,e)),n&&(s+=i),s+=y,n=!1;continue}if(l===e.cdataPropName){n&&(s+=i),s+=`<![CDATA[${a[l][0][e.textNodeName]}]]>`,n=!1;continue}if(l===e.commentPropName){s+=i+`\x3c!--${a[l][0][e.textNodeName]}--\x3e`,n=!0;continue}if("?"===l[0]){const y=Hn(a[":@"],e);let _=a[l][0][e.textNodeName];_=0!==_.length?" "+_:"",s+=("?xml"===l?"":i)+`<${l}${_}${y}?>`,n=!0;continue}let u=i;""!==u&&(u+=e.indentBy);const f=i+`<${l}${Hn(a[":@"],e)}`,d=jn(a[l],e,c,u);-1!==e.unpairedTags.indexOf(l)?s+=e.suppressUnpairedNode?f+">":f+"/>":d&&0!==d.length||!e.suppressEmptyNode?d&&d.endsWith(">")?s+=f+`>${d}${i}</${l}>`:(s+=f+">",d&&""!==i&&(d.includes("/>")||d.includes("</"))?s+=i+e.indentBy+d+i:s+=d,s+=`</${l}>`):s+=f+"/>",n=!0}return s}function Ta(o){const e=Object.keys(o);for(let t=0;t<e.length;t++){const i=e[t];if(o.hasOwnProperty(i)&&":@"!==i)return i}}function Hn(o,e){let t="";if(o&&!e.ignoreAttributes)for(let i in o){if(!o.hasOwnProperty(i))continue;let s=e.attributeValueProcessor(i,o[i]);s=Yn(s,e),t+=!0===s&&e.suppressBooleanAttributes?` ${i.substr(e.attributeNamePrefix.length)}`:` ${i.substr(e.attributeNamePrefix.length)}="${s}"`}return t}function Pa(o,e){let t=(o=o.substr(0,o.length-e.textNodeName.length-1)).substr(o.lastIndexOf(".")+1);for(let i in e.stopNodes)if(e.stopNodes[i]===o||e.stopNodes[i]==="*."+t)return!0;return!1}function Yn(o,e){if(o&&o.length>0&&e.processEntities)for(let t=0;t<e.entities.length;t++){const i=e.entities[t];o=o.replace(i.regex,i.val)}return o}const Aa={attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,cdataPropName:!1,format:!1,indentBy:" ",suppressEmptyNode:!1,suppressUnpairedNode:!0,suppressBooleanAttributes:!0,tagValueProcessor:function(o,e){return e},attributeValueProcessor:function(o,e){return e},preserveOrder:!1,commentPropName:!1,unpairedTags:[],entities:[{regex:new RegExp("&","g"),val:"&"},{regex:new RegExp(">","g"),val:">"},{regex:new RegExp("<","g"),val:"<"},{regex:new RegExp("'","g"),val:"'"},{regex:new RegExp('"',"g"),val:"""}],processEntities:!0,stopNodes:[],oneListGroup:!1};function be(o){this.options=Object.assign({},Aa,o),!0===this.options.ignoreAttributes||this.options.attributesGroupName?this.isAttribute=function(){return!1}:(this.ignoreAttributesFn=Vn(this.options.ignoreAttributes),this.attrPrefixLen=this.options.attributeNamePrefix.length,this.isAttribute=Ia),this.processTextOrObjNode=Ma,this.options.format?(this.indentate=Sa,this.tagEndChar=">\n",this.newLine="\n"):(this.indentate=function(){return""},this.tagEndChar=">",this.newLine="")}function Ma(o,e,t,i){const s=this.j2x(o,t+1,i.concat(e));return void 0!==o[this.options.textNodeName]&&1===Object.keys(o).length?this.buildTextValNode(o[this.options.textNodeName],e,s.attrStr,t):this.buildObjectNode(s.val,e,s.attrStr,t)}function Sa(o){return this.options.indentBy.repeat(o)}function Ia(o){return!(!o.startsWith(this.options.attributeNamePrefix)||o===this.options.textNodeName)&&o.substr(this.attrPrefixLen)}be.prototype.build=function(o){return this.options.preserveOrder?Ea(o,this.options):(Array.isArray(o)&&this.options.arrayNodeName&&this.options.arrayNodeName.length>1&&(o={[this.options.arrayNodeName]:o}),this.j2x(o,0,[]).val)},be.prototype.j2x=function(o,e,t){let i="",s="";const n=t.join(".");for(let r in o)if(Object.prototype.hasOwnProperty.call(o,r))if(typeof o[r]>"u")this.isAttribute(r)&&(s+="");else if(null===o[r])this.isAttribute(r)||r===this.options.cdataPropName?s+="":s+="?"===r[0]?this.indentate(e)+"<"+r+"?"+this.tagEndChar:this.indentate(e)+"<"+r+"/"+this.tagEndChar;else if(o[r]instanceof Date)s+=this.buildTextValNode(o[r],r,"",e);else if("object"!=typeof o[r]){const a=this.isAttribute(r);if(a&&!this.ignoreAttributesFn(a,n))i+=this.buildAttrPairStr(a,""+o[r]);else if(!a)if(r===this.options.textNodeName){let l=this.options.tagValueProcessor(r,""+o[r]);s+=this.replaceEntitiesValue(l)}else s+=this.buildTextValNode(o[r],r,"",e)}else if(Array.isArray(o[r])){const a=o[r].length;let l="",c="";for(let u=0;u<a;u++){const h=o[r][u];if(!(typeof h>"u"))if(null===h)s+="?"===r[0]?this.indentate(e)+"<"+r+"?"+this.tagEndChar:this.indentate(e)+"<"+r+"/"+this.tagEndChar;else if("object"==typeof h)if(this.options.oneListGroup){const f=this.j2x(h,e+1,t.concat(r));l+=f.val,this.options.attributesGroupName&&h.hasOwnProperty(this.options.attributesGroupName)&&(c+=f.attrStr)}else l+=this.processTextOrObjNode(h,r,e,t);else if(this.options.oneListGroup){let f=this.options.tagValueProcessor(r,h);f=this.replaceEntitiesValue(f),l+=f}else l+=this.buildTextValNode(h,r,"",e)}this.options.oneListGroup&&(l=this.buildObjectNode(l,r,c,e)),s+=l}else if(this.options.attributesGroupName&&r===this.options.attributesGroupName){const a=Object.keys(o[r]),l=a.length;for(let c=0;c<l;c++)i+=this.buildAttrPairStr(a[c],""+o[r][a[c]])}else s+=this.processTextOrObjNode(o[r],r,e,t);return{attrStr:i,val:s}},be.prototype.buildAttrPairStr=function(o,e){return e=this.options.attributeValueProcessor(o,""+e),e=this.replaceEntitiesValue(e),this.options.suppressBooleanAttributes&&"true"===e?" "+o:" "+o+'="'+e+'"'},be.prototype.buildObjectNode=function(o,e,t,i){if(""===o)return"?"===e[0]?this.indentate(i)+"<"+e+t+"?"+this.tagEndChar:this.indentate(i)+"<"+e+t+this.closeTag(e)+this.tagEndChar;{let s="</"+e+this.tagEndChar,n="";return"?"===e[0]&&(n="?",s=""),!t&&""!==t||-1!==o.indexOf("<")?!1!==this.options.commentPropName&&e===this.options.commentPropName&&0===n.length?this.indentate(i)+`\x3c!--${o}--\x3e`+this.newLine:this.indentate(i)+"<"+e+t+n+this.tagEndChar+o+this.indentate(i)+s:this.indentate(i)+"<"+e+t+n+">"+o+s}},be.prototype.closeTag=function(o){let e="";return-1!==this.options.unpairedTags.indexOf(o)?this.options.suppressUnpairedNode||(e="/"):e=this.options.suppressEmptyNode?"/":`></${o}`,e},be.prototype.buildTextValNode=function(o,e,t,i){if(!1!==this.options.cdataPropName&&e===this.options.cdataPropName)return this.indentate(i)+`<![CDATA[${o}]]>`+this.newLine;if(!1!==this.options.commentPropName&&e===this.options.commentPropName)return this.indentate(i)+`\x3c!--${o}--\x3e`+this.newLine;if("?"===e[0])return this.indentate(i)+"<"+e+t+"?"+this.tagEndChar;{let s=this.options.tagValueProcessor(e,o);return s=this.replaceEntitiesValue(s),""===s?this.indentate(i)+"<"+e+t+this.closeTag(e)+this.tagEndChar:this.indentate(i)+"<"+e+t+">"+s+"</"+e+this.tagEndChar}},be.prototype.replaceEntitiesValue=function(o){if(o&&o.length>0&&this.options.processEntities)for(let e=0;e<this.options.entities.length;e++){const t=this.options.entities[e];o=o.replace(t.regex,t.val)}return o};class ki{}w(ki,"parser",new Es({allowBooleanAttributes:!0,attributeNamePrefix:"",ignoreAttributes:!1,ignoreDeclaration:!0,ignorePiTags:!0,numberParseOptions:{leadingZeros:!0,hex:!0},parseAttributeValue:!0,preserveOrder:!1,processEntities:!1,removeNSPrefix:!0,trimValues:!0})),w(ki,"builder",new be({attributeNamePrefix:"$",ignoreAttributes:!1,suppressBooleanAttributes:!1}));class Ft{static join(e){const t={};for(const i of e)for(const s in i)if(t[s])for(const n of i[s])t[s].add(n);else t[s]=new Set(i[s]);return t}static intersect(e){if(0===e.length)return{};let t=Ft.clone(e[0]);for(let i=1;i<e.length;i++){const s=e[i],n={};for(const r in t)if(s[r]){const a=new Set;for(const l of t[r])s[r].has(l)&&a.add(l);a.size>0&&(n[r]=a)}t=n}return t}static clone(e){const t={};for(const i in e)t[i]=new Set(e[i]);return t}static remove(e,t,i=!1){i&&(e=Ft.clone(e));for(const s in t)if(e[s]){for(const n of t[s])e[s].delete(n);0===e[s].size&&delete e[s]}}static add(e,t,i=!1){i&&(e=Ft.clone(e));for(const s in t)if(e[s])for(const n of t[s])e[s].add(n);else e[s]=new Set(t[s])}static append(e,t,...i){let s=e[t];s||(s=new Set,e[t]=s);for(const n of i)s.add(n)}static isEqual(e,t){const i=Object.keys(e),s=Object.keys(t);if(i.length!==s.length)return!1;for(const n of i){if(!t[n]||e[n].size!==t[n].size)return!1;for(const r of e[n])if(!t[n].has(r))return!1}return!0}static isEmpty(e){return 0===Object.values(e).reduce((i,s)=>i+s.size,0)}static toRaw(e){const t={};for(const i in e)t[i]=Array.from(e[i]);return t}static fromRaw(e){const t={};for(const i in e)t[i]=new Set(e[i]);return t}}Map;class Ts{static isEntry(e){return new Set(["Boolean","Color","Text","Number","Select","Vector3","TextSet","None"]).has(e.type)}static copySchema(e,t={}){for(const i in e){const s=e[i];this.isEntry(s)?t[i]=this.copyEntry(s):(t[i]={},this.copySchema(s,t[i]))}return t}static copyEntry(e){if("Boolean"===e.type)return{type:e.type,value:e.value};if("Color"===e.type)return{type:e.type,value:e.value.clone()};if("Text"===e.type)return{type:e.type,value:e.value};if("Number"===e.type)return{type:e.type,value:e.value,min:e.min,max:e.max,interpolable:e.interpolable};if("Select"===e.type)return{type:e.type,value:e.value,multiple:e.multiple,options:new Set(e.options)};if("Vector3"===e.type)return{type:e.type,value:e.value.clone()};if("TextSet"===e.type)return{type:e.type,value:new Set(e.value)};if("None"===e.type)return{type:e.type,value:e.value};throw new Error("Invalid entry!")}}class oi{constructor(e,t,i,s){w(this,"_component"),w(this,"name"),w(this,"uuid"),this._component=e,this.name=i,this.uuid=s??Wt.create(),t.get(zi).list.set(this.uuid,this)}get controls(){return Ts.copySchema(this._config)}set(e){for(const t in e)t in this&&(this[t]=e[t].value)}export(e=this._config,t={}){for(const i in e){const s=e[i];if(Ts.isEntry(s))if("Color"===s.type){const{r,g:a,b:l}=s.value;t[i]={...s,value:{r,g:a,b:l}}}else if("Vector3"===s.type){const{x:r,y:a,z:l}=s.value;t[i]={...s,value:{x:r,y:a,z:l}}}else if("TextSet"===s.type){const r=Array.from(s.value);t[i]={...s,value:r}}else if("Select"===s.type){const r=Array.from(s.options);t[i]={...s,options:r}}else t[i]={...s};else t[i]={},this.export(s,t[i])}return t}import(e,t={},i=!0){for(const s in e){const n=e[s];if(Ts.isEntry(n))if("Color"===n.type){const{r:a,g:l,b:c}=n.value;t[s]={...n,value:new b.Q1f(a,l,c)}}else if("Vector3"===n.type){const{x:a,y:l,z:c}=n.value;t[s]={...n,value:new b.Pq0(a,l,c)}}else t[s]="TextSet"===n.type?{...n,value:new Set(n.value)}:"Select"===n.type?{...n,options:new Set(n.options)}:{...n};else t[s]={},this.import(n,t[s],!1)}i&&this.set(t)}}const Zn=class po extends Pt{constructor(e){super(e),w(this,"list",new dt.jp),w(this,"enabled",!0),e.add(po.uuid,this)}};w(Zn,"uuid","b8c764e0-6b24-4e77-9a32-35fa728ee5b4");let zi=Zn;class Wn{constructor(e){w(this,"_event"),w(this,"_position",new b.I9Y),w(this,"onDisposed",new X),w(this,"updateMouseInfo",t=>{this._event=t}),this.dom=e,this.setupEvents(!0)}get position(){return this.updatePosition(!1),this._position.clone()}get rawPosition(){return this.updatePosition(!0),this._position.clone()}dispose(){this.setupEvents(!1),this.onDisposed.trigger(),this.onDisposed.reset()}updatePosition(e){if(this._event){const t=this.dom.getBoundingClientRect();this._position.x=this.getPositionX(t,this._event,e),this._position.y=this.getPositionY(t,this._event,e)}}getPositionY(e,t,i){const s=this.getDataObject(t);return i?s.clientY:-(s.clientY-e.top)/(e.bottom-e.top)*2+1}getPositionX(e,t,i){const s=this.getDataObject(t);return i?s.clientX:(s.clientX-e.left)/(e.right-e.left)*2-1}getDataObject(e){return e instanceof MouseEvent?e:e.touches[0]}setupEvents(e){e?(this.dom.addEventListener("pointermove",this.updateMouseInfo),this.dom.addEventListener("touchstart",this.updateMouseInfo)):(this.dom.removeEventListener("pointermove",this.updateMouseInfo),this.dom.removeEventListener("touchstart",this.updateMouseInfo))}}const Gn=class mo extends Pt{constructor(e){super(e),w(this,"onDisposed",new X),w(this,"onBeforeDispose",new X),w(this,"onFragmentsLoaded",new X),w(this,"baseCoordinationModel",""),w(this,"baseCoordinationMatrix",new b.kn4),w(this,"enabled",!0),w(this,"_core"),this.components.add(mo.uuid,this)}get initialized(){return!!this._core}get list(){return this.core.models.list}get core(){if(!this._core)throw new Error("FragmentsManager not initialized. Call init() first.");return this._core}get _hasCoordinationModel(){return""!==this.baseCoordinationModel}dispose(){this.onBeforeDispose.trigger(),this._core&&(this.core.dispose(),this._core=void 0),this.baseCoordinationModel="",this.onFragmentsLoaded.reset(),this.onDisposed.trigger(),this.onDisposed.reset()}init(e,t){var i=this;this._core=new dt._i(e,t),this.core.onModelLoaded.add((0,H.A)(function*(){if(i._hasCoordinationModel)return;const s=[...i.list.values()][0];s&&(i.baseCoordinationModel=s.modelId,i.baseCoordinationMatrix=yield s.getCoordinationMatrix())})),this.list.onItemDeleted.add(()=>{this.list.size>0||(this.baseCoordinationModel="",this.baseCoordinationMatrix=new b.kn4)})}raycast(e){var t=this;return(0,H.A)(function*(){const i=[];for(const r of t.core.models.list.values())if(e.snappingClasses&&e.snappingClasses.length>0){const a=yield r.raycastWithSnapping(e);if(a&&a.length>0)i.push(a[0]);else{const l=yield r.raycast(e);l&&i.push(l)}}else{const a=yield r.raycast(e);a&&i.push(a)}if(yield Promise.all(i),0===i.length)return;let s=i[0],n=s.distance;for(let r=1;r<i.length;r++)i[r].distance<n&&(n=i[r].distance,s=i[r]);return s})()}getPositions(e){var t=this;return(0,H.A)(function*(){const i=[],s=function(){var r=(0,H.A)(function*(a,l){const c=yield a.getPositions(l);for(const u of c)i.push(u)});return function(l,c){return r.apply(this,arguments)}}(),n=[];for(const r in e){const a=t.core.models.list.get(r);a&&n.push(s(a,Array.from(e[r])))}return yield Promise.all(n),i})()}getBBoxes(e){var t=this;return(0,H.A)(function*(){const i=[],s=function(){var r=(0,H.A)(function*(a,l){const c=yield a.getBoxes(l);if(c)for(const u of c)i.push(u)});return function(l,c){return r.apply(this,arguments)}}(),n=[];for(const r in e){const a=t.core.models.list.get(r);a&&n.push(s(a,Array.from(e[r])))}return yield Promise.all(n),i})()}highlight(e,t){var i=this;return(0,H.A)(function*(){yield i.forEachModel(t,"highlight",e)})()}getData(e,t){var i=this;return(0,H.A)(function*(){const s={};for(const[n,r]of Object.entries(e)){const a=i.list.get(n);if(!a)continue;if(0===r.size){s[n]=[];continue}const l=yield a.getItemsData([...r],t);s[n]=l}return s})()}resetHighlight(e){var t=this;return(0,H.A)(function*(){yield t.forEachModel(e,"resetHighlight")})()}forEachModel(e,t,...i){var s=this;return(0,H.A)(function*(){const n={};if(e)for(const a in e)n[a]=Array.from(e[a]);else for(const a of s.core.models.list.keys())n[a]=void 0;const r=[];for(const a in n){const l=s.core.models.list.get(a);if(l){const u=l[t](n[a],...i);r.push(u)}}yield Promise.all(r)})()}guidsToModelIdMap(e){var t=this;return(0,H.A)(function*(){const i={};for(const[s,n]of t.list){const r=(yield n.getLocalIdsByGuids([...e])).filter(a=>null!==a);i[s]=new Set(r)}return i})()}modelIdMapToGuids(e){var t=this;return(0,H.A)(function*(){const i=[];for(const[s,n]of Object.entries(e)){const r=t.list.get(s);if(!r)continue;const a=(yield r.getGuidsByLocalIds([...n])).filter(l=>null!==l);i.push(...a)}return i})()}applyBaseCoordinateSystem(e,t){const i=new b.kn4;return t&&i.copy(t.clone()).invert(),i.multiply(this.baseCoordinationMatrix),e.applyMatrix4(i),i}};w(Gn,"uuid","fef46874-46a3-461b-8c44-2922ab77c806");let ut=Gn;class Oa{constructor(){w(this,"wasm",{path:"",absolute:!1,logLevel:Fe.LogLevel.LOG_LEVEL_OFF}),w(this,"webIfc",{COORDINATE_TO_ORIGIN:!0}),w(this,"autoSetWasm",!0),w(this,"customLocateFileHandler",null)}}w(class yn extends Pt{constructor(e){super(e),w(this,"onDisposed",new X),w(this,"onIfcStartedLoading",new X),w(this,"onIfcImporterInitialized",new X),w(this,"onSetup",new X),w(this,"settings",new Oa),w(this,"webIfc",new Fe.IfcAPI),w(this,"enabled",!0),this.components.add(yn.uuid,this)}dispose(){this.webIfc=null,this.onDisposed.trigger(yn.uuid),this.onDisposed.reset()}setup(e){var t=this;return(0,H.A)(function*(){t.settings={...t.settings,...e},t.settings.autoSetWasm&&(yield t.autoSetWasm()),t.onSetup.trigger()})()}load(e,t,i,s){var n=this;return(0,H.A)(function*(){const r=n.components.get(ut);if(!r.initialized)throw new Error("You need to initialize fragments first.");n.settings.autoSetWasm&&(yield n.autoSetWasm()),r.core.settings.autoCoordinate=t;const a=new dt.$X;a.wasm.path=n.settings.wasm.path,a.wasm.absolute=n.settings.wasm.absolute,a.webIfcSettings=n.settings.webIfc,n.onIfcImporterInitialized.trigger(a),s?.instanceCallback&&s.instanceCallback(a);const l=yield a.process({...s?.processData,bytes:e});return yield r.core.load(l,{modelId:i,userData:s?.userData})})()}readIfcFile(e){var t=this;return(0,H.A)(function*(){const{path:i,absolute:s,logLevel:n}=t.settings.wasm;return t.webIfc.SetWasmPath(i,s),yield t.webIfc.Init(t.settings.customLocateFileHandler||void 0),n&&t.webIfc.SetLogLevel(n),t.webIfc.OpenModel(e,t.settings.webIfc)})()}cleanUp(){try{this.webIfc.Dispose()}catch{console.log("Web-ifc wasn't disposed.")}this.webIfc=null,this.webIfc=new Fe.IfcAPI}autoSetWasm(){var e=this;return(0,H.A)(function*(){const t=yield fetch(`https://unpkg.com/@thatopen/components@${Gs.release}/package.json`);if(!t.ok)return void console.warn("Couldn't get openbim-components package.json. Set wasm settings manually.");const i=yield t.json();"web-ifc"in i.peerDependencies?(e.settings.wasm.path=`https://unpkg.com/web-ifc@${i.peerDependencies["web-ifc"]}/`,e.settings.wasm.absolute=!0):console.warn("Couldn't get web-ifc from peer dependencies in openbim-components. Set wasm settings manually.")})()}},"uuid","a659add7-1418-4771-a0d6-7d4d438e4624");const qn=class go extends Pt{constructor(e){super(e),w(this,"enabled",!0),this.components.add(go.uuid,this)}set(e,t){var i=this;return(0,H.A)(function*(){const s=i.components.get(ut),n=[];if(t)for(const[r,a]of Object.entries(t)){const l=s.list.get(r);l&&n.push(l.setVisible([...a],e))}else for(const r of s.list.values())n.push(r.setVisible(void 0,e));yield Promise.all(n),yield s.core.update(!0)})()}isolate(e){var t=this;return(0,H.A)(function*(){yield Promise.all([t.set(!1),t.set(!0,e)])})()}toggle(e){var t=this;return(0,H.A)(function*(){const i=[],s=t.components.get(ut);for(const[n,r]of Object.entries(e)){const a=s.list.get(n);a&&i.push(a.toggleVisible([...r]))}yield Promise.all(i),yield s.core.update(!0)})()}getVisibilityMap(e,t){var i=this;return(0,H.A)(function*(){const s=[],n=[],r=i.components.get(ut);if(t)for(const c of t){const u=r.list.get(c);u&&(s.push(u.modelId),n.push(u.getItemsByVisibility(e)))}else for(const c of r.list.values())s.push(c.modelId),n.push(c.getItemsByVisibility(e));const a=yield Promise.all(n),l={};for(const[c,u]of s.entries())l[u]=a[c];return l})()}};w(qn,"uuid","dd9ccf2d-8a21-4821-b7f6-2949add16a29");let ka=qn;const Xn=class vn extends Pt{constructor(e){super(e),w(this,"enabled",!0),w(this,"onDisposed",new X),w(this,"list",new dt.PG),this.components.add(vn.uuid,this)}dispose(e=!0){this.list.clear(),this.onDisposed.trigger(vn.uuid),e&&(this.onDisposed.reset(),this.list.eventsEnabled=!1,this.list.dispose())}get(){const e=new b.NRn;for(const t of this.list)e.union(t);return e}addFromModelIdMap(e){var t=this;return(0,H.A)(function*(){const i=t.components.get(ut),s=new b.NRn;for(const[n,r]of Object.entries(e)){const a=i.list.get(n);if(!a)continue;const l=yield a.getMergedBox([...r]);s.union(l)}t.list.add(s)})()}addFromModels(e){const t=this.components.get(ut);for(const[i,s]of t.list)e&&!e.some(n=>n.test(i))||this.list.add(s.box)}getCenter(e){var t=this;return(0,H.A)(function*(){t.list.clear(),yield t.addFromModelIdMap(e);const i=t.get();t.list.clear();const s=new b.Pq0;return i.getCenter(s),s})()}getCameraOrientation(e){var t=this;return(0,H.A)(function*(i,s=1){const n=t.components.get(ut);t.list.clear();for(const[h,f]of n.list)t.list.add(f.box);const r=t.get();t.list.clear();const a=new b.Pq0;r.getCenter(a);const l=new b.Pq0;r.getSize(l);const c=Math.max(l.x,l.y,l.z)*s,u=new b.Pq0;switch(i){case"front":default:u.set(a.x,a.y,a.z+c);break;case"back":u.set(a.x,a.y,a.z-c);break;case"left":u.set(a.x-c,a.y,a.z);break;case"right":u.set(a.x+c,a.y,a.z);break;case"top":u.set(a.x,a.y+c,a.z);break;case"bottom":u.set(a.x,a.y-c,a.z)}return{position:u,target:a}}).apply(this,arguments)}};w(Xn,"uuid","d1444724-dba6-4cdd-a0c7-68ee1450d166");let Qn=Xn;class za{constructor(e,t){w(this,"name","Query"),w(this,"customData",{}),w(this,"_components"),w(this,"_queries",[]),w(this,"_aggregation","exclusive"),w(this,"result",null),w(this,"cache",!0),w(this,"serializeQueryParameters",i=>{var s;return{categories:null==(s=i.categories)?void 0:s.map(r=>r.source),attributes:i.attributes?{aggregation:i.attributes.aggregation,queries:i.attributes.queries.map(this.serializeAttributeQuery)}:void 0,relation:i.relation?{name:i.relation.name,query:i.relation.query?this.serializeQueryParameters(i.relation.query):void 0}:void 0}}),w(this,"deserializeQueryParameters",i=>{var s;return{categories:null==(s=i.categories)?void 0:s.map(r=>new RegExp(r)),attributes:i.attributes?{aggregation:i.attributes.aggregation,queries:i.attributes.queries.map(this.deserializeAttributeQuery)}:void 0,relation:i.relation?{name:i.relation.name,query:i.relation.query?this.deserializeQueryParameters(i.relation.query):void 0}:void 0}}),this._components=e,this.queries=t}set queries(e){this._queries=e,this.clearCache()}get queries(){return this._queries}set aggregation(e){e!==this._aggregation&&this.clearCache(),this._aggregation=e}get aggregation(){return this._aggregation}test(e){var t=this;return(0,H.A)(function*(){const{modelIds:i,force:s}={force:!1,...e};if(t.result&&!s)return t.result;const r=yield t._components.get(ai).getItems(t.queries,{modelIds:i,aggregation:t.aggregation});return t.cache&&(t.result=r),r})()}clearCache(){this.result=null}serializeAttributeQuery(e){let t;return t=Array.isArray(e.value)?e.value.map(s=>s.source):e.value instanceof RegExp?e.value.source:e.value,{name:e.name.source,value:t,type:e.type instanceof RegExp?e.type.source:e.type,negate:e.negate,itemIds:e.itemIds}}toJSON(){return{guid:this._components.get(ai).list.getKey(this)??Wt.create(),name:this.name,customData:this.customData,queries:this.queries.map(this.serializeQueryParameters),aggregation:this.aggregation,cache:this.cache}}deserializeAttributeQuery(e){let t;return t=Array.isArray(e.value)?e.value.map(s=>new RegExp(s)):"string"==typeof e.value?new RegExp(e.value):e.value,{name:new RegExp(e.name),value:t,type:e.type?new RegExp(e.type):void 0,negate:e.negate,itemIds:e.itemIds}}fromJSON(e){return this.name=e.name,this.customData=e.customData,this.aggregation=e.aggregation,this.cache=e.cache,this.queries=e.queries.map(this.deserializeQueryParameters),this}}const Kn=class _o extends Pt{constructor(e){super(e),w(this,"enabled",!0),w(this,"list",new dt.jp),e.add(_o.uuid,this)}getItems(e,t){var i=this;return(0,H.A)(function*(){let s;if(t){const{modelIds:c,items:u}=t;if(u){const h=Object.keys(u);h.length>0&&(s=h.map(f=>new RegExp(`^${f}$`)))}else c&&(s=c)}const n=t?.aggregation??"exclusive",r=i.components.get(ut),a=yield Promise.all(e.map(function(){var c=(0,H.A)(function*(u){const h={};return yield Promise.all(Array.from(r.list).map(function(){var f=(0,H.A)(function*([d,y]){var g;if(s&&!s.some(x=>x.test(d)))return;const _=null==(g=t?.items)?void 0:g[d],m=yield y.getItemsByQuery(u,{localIds:_?[..._]:void 0});h[d]=new Set(m)});return function(d){return f.apply(this,arguments)}}())),h});return function(u){return c.apply(this,arguments)}}()));return"inclusive"===n?Ft.join(a):Ft.intersect(a)})()}create(e,t){const i=new za(this.components,t);return this.list.set(e,i),i}addFromCategories(e){var t=this;return(0,H.A)(function*(){const i=new Set,s=t.components.get(ut);for(const[n,r]of s.list){if(e&&!e.some(c=>c.test(n)))continue;const a=(yield r.getItemsWithGeometryCategories()).filter(c=>null!==c),l=new Set(a);for(const c of l)t.list.has(c)||(t.create(c,[{categories:[new RegExp(`^${c}$`)]}]),i.add(c))}return[...i]})()}import(e){const{data:t}=e,i=[];if(!t)return i;for(const s of t){const n=this.create(s.guid,[]);n.fromJSON(s),i.push(n)}return i}export(){const e=[];for(const[t,i]of this.list.entries()){const n={...i.toJSON(),name:t};e.push(n)}return{data:e}}};w(Kn,"uuid","0da7ad77-f734-42ca-942f-a074adfd1e3a");let ai=Kn;w(class yo extends Pt{constructor(e){var t;super(e),t=this,w(this,"enabled",!0),w(this,"onDisposed",new X),w(this,"list",new dt.jp),w(this,"defaultSaveFunction",s=>"value"in s.Name?s.Name.value:null),w(this,"onBeforeFragmentsDispose",function(){var s=(0,H.A)(function*(n){const{key:r,value:a}=n,l=yield a.getLocalIds(),c={[r]:new Set(l)};t.removeItems(c)});return function(n){return s.apply(this,arguments)}}()),e.add(yo.uuid,this),this.setupEvents(),e.get(ut).list.onBeforeDelete.add(this.onBeforeFragmentsDispose)}setupEvents(){this.list.onBeforeDelete.add(({value:e})=>e.dispose())}getClassificationGroups(e){let t=this.list.get(e);return t||(t=new dt.jp,this.list.set(e,t)),t}getModelItems(e,t,i){const{map:s}=this.getGroupData(e,t);let n=s[i];return n||(n=new Set,s[i]=n),n}getGroupData(e,t){const i=this.components.get(ai),s=this.getClassificationGroups(e);let n=s.get(t);return n||(n={map:{},get:()=>new Promise(r=>{if(n)if(n.query){const{name:a,config:l}=n.query,c=i.list.get(a);if(!c)throw new Error("Classifier: the query name associated with the group doesn't exist in the ItemsFinder component");c.test(l).then(u=>{if(!n)return void r({});const h=Ft.join([u,n.map]);r(h)})}else r(n.map);else r({})})},s.set(t,n)),n}aggregateItems(e,t,i){var s=this;return(0,H.A)(function*(){const n=i?.data??void 0,r=i?.aggregationCallback??s.defaultSaveFunction,a=s.components.get(ut),c=yield s.components.get(ai).getItems([t],{modelIds:i?.modelIds});for(const[u,h]of Object.entries(c)){const f=a.list.get(u);if(!f)continue;const d=(g,..._)=>{const m=s.getModelItems(e,g,u);for(const x of _)m.add(x)},y=yield f.getItemsData([...h],n);for(const g of y)r(g,d)}})()}addGroupItems(e,t,i){const{map:s}=this.getGroupData(e,t);Ft.add(s,i)}setGroupQuery(e,t,i){this.getGroupData(e,t).query=i}find(e){var t=this;return(0,H.A)(function*(){const i=[];for(const[n,r]of Object.entries(e)){const a=[],l=t.list.get(n);if(!l)continue;for(const u of r){const h=l.get(u);if(!h)continue;const f=yield h.get();a.push(f)}const c=Ft.join(a);i.push(c)}return Ft.intersect(i)})()}aggregateItemRelations(e,t,i,s){var n=this;return(0,H.A)(function*(){const r=s?.attribute??"Name",a={relations:{[i]:{attributes:!0,relations:!1}}};yield n.aggregateItems(e,t,{modelIds:s?.modelIds,data:a,aggregationCallback:(l,c)=>{if(!l?.[r])return;const u=l[r];if(!("value"in u))return;const h=l[i];if(Array.isArray(h))for(const f of h)"value"in f._localId&&c(u.value,f._localId.value)}})})()}byIfcBuildingStorey(e){var t=this;return(0,H.A)(function*(){yield t.aggregateItemRelations(e?.classificationName??"Storeys",{categories:[/BUILDINGSTOREY/]},"ContainsElements",{modelIds:e?.modelIds})})()}byCategory(e){var t=this;return(0,H.A)(function*(){const s=yield t.components.get(ai).addFromCategories(e?.modelIds);for(const n of s)t.setGroupQuery(e?.classificationName??"Categories",n,{name:n})})()}dispose(){this.list.clear(),this.components.get(ut).list.onBeforeDelete.remove(this.onBeforeFragmentsDispose),this.onDisposed.trigger()}removeItems(e,t){if(t&&t.classificationName){const i=this.list.get(t.classificationName);if(!i||t.groupName&&!i.get(t.groupName))return;for(const[,s]of i)Ft.remove(s.map,e);return}for(const[,i]of this.list.entries())for(const[,s]of i)Ft.remove(s.map,e)}byModel(e){var t=this;return(0,H.A)(function*(){const i=t.components.get(ut),s=e?.classificationName??"Models";for(const[n,r]of i.list){if(e&&e.modelIds&&!e.modelIds.some(c=>c.test(n)))continue;const a=yield r.getItemsIdsWithGeometry(),l={[n]:new Set(a)};t.getGroupData(s,n),t.addGroupItems(s,n,l)}})()}},"uuid","e25a7f3c-46c4-4a14-9d3d-5115f24ebeb7");class Fa{constructor(e,t){w(this,"enabled",!0),w(this,"components"),w(this,"onDisposed",new X),w(this,"mouse"),w(this,"world"),w(this,"debugMode",!1),w(this,"colorToModelId",new Map),w(this,"modelIdToColor",new Map),w(this,"renderTarget"),w(this,"renderTargetSize",new b.I9Y),w(this,"debugCanvas"),w(this,"debugContainer"),w(this,"colorMaterials",new Map),w(this,"originalMaterials",new Map),w(this,"originalLodColors",new Map),w(this,"colorsNeedUpdate",!0);const i=t.renderer;if(!i)throw new Error("A renderer is needed for the FastModelPicker to work!");this.world=t,this.mouse=new Wn(i.three.domElement),this.components=e,this.setupRenderTarget(),this.setupFragmentListeners()}setupFragmentListeners(){const e=this.components.get(ut);e.list.onItemSet.add(()=>{this.colorsNeedUpdate=!0}),e.list.onItemDeleted.add(()=>{this.colorsNeedUpdate=!0})}setupRenderTarget(){const t=this.world.renderer.three.getSize(new b.I9Y);this.renderTargetSize.copy(t),this.renderTarget=new b.nWS(t.x,t.y),this.renderTarget.texture.format=b.GWd,this.renderTarget.texture.type=b.OUM,this.debugMode&&this.setupDebugCanvas(),this.world.renderer.onResize.add(i=>{this.renderTargetSize.copy(i),this.renderTarget.setSize(i.x,i.y),this.debugCanvas&&(this.debugCanvas.width=i.x,this.debugCanvas.height=i.y)})}setupDebugCanvas(){if(this.debugCanvas)return;const e=this.world.renderer.three.getSize(new b.I9Y);this.debugContainer=document.createElement("div"),this.debugContainer.style.position="fixed",this.debugContainer.style.top="10px",this.debugContainer.style.right="10px",this.debugContainer.style.width="300px",this.debugContainer.style.height="300px",this.debugContainer.style.border="2px solid #fff",this.debugContainer.style.backgroundColor="#000",this.debugContainer.style.zIndex="10000",this.debugContainer.style.pointerEvents="none",this.debugCanvas=document.createElement("canvas"),this.debugCanvas.width=e.x,this.debugCanvas.height=e.y,this.debugCanvas.style.width="100%",this.debugCanvas.style.height="100%",this.debugCanvas.style.imageRendering="pixelated",this.debugContainer.appendChild(this.debugCanvas),document.body.appendChild(this.debugContainer)}generateColorForModel(e){let t=0;for(let a=0;a<e.length;a++)t=(t<<5)-t+e.charCodeAt(a),t&=t;let i=Math.abs(t)%16777215;return 0===i&&(i=1),new b.Q1f((i>>16&255||1)/255,(i>>8&255||1)/255,(255&i||1)/255)}colorToId(e){return Math.round(255*e.r)<<16|Math.round(255*e.g)<<8|Math.round(255*e.b)}assignColors(){const e=this.components.get(ut);if(e.initialized){if(!this.colorsNeedUpdate){const t=new Set(e.list.keys()),i=new Set(this.modelIdToColor.keys());(t.size!==i.size||[...t].some(s=>!i.has(s)))&&(this.colorsNeedUpdate=!0)}if(this.colorsNeedUpdate){this.colorToModelId.clear(),this.modelIdToColor.clear();for(const t of this.colorMaterials.values())t.dispose();this.colorMaterials.clear();for(const[t]of e.list){const i=this.generateColorForModel(t),s=this.colorToId(i);this.colorToModelId.set(s,t),this.modelIdToColor.set(t,i);const n=new b.V9B({color:i,depthTest:!0,depthWrite:!0});this.colorMaterials.set(t,n)}this.colorsNeedUpdate=!1}}}applyColorMaterials(){const e=this.components.get(ut);if(e.initialized)for(const[t,i]of e.list){const s=this.colorMaterials.get(t);s&&i.object.traverse(n=>{if(n instanceof b.eaF){if("isLODGeometry"in n.geometry){const a=n.material[0].uniforms.lodColor;return this.originalLodColors.has(a)||this.originalLodColors.set(a,a.value),void(a.value=s.color)}this.originalMaterials.has(n)||this.originalMaterials.set(n,n.material),n.material=s}})}}restoreOriginalMaterials(){for(const[e,t]of this.originalMaterials)e.material=t;for(const[e,t]of this.originalLodColors)e.value=t;this.originalMaterials.clear()}renderColorCoded(){if(!this.renderTarget||!this.world.renderer)throw new Error("Render target not initialized!");const e=this.world.renderer.three,t=this.world.scene.three,i=this.world.camera.three,s=e.getRenderTarget(),n=e.autoClear,r=new b.Q1f,a=e.getClearAlpha();e.getClearColor(r),this.applyColorMaterials(),e.setRenderTarget(this.renderTarget),e.autoClear=!0,e.setClearColor(0,1),e.clear(!0,!0,!1),e.render(t,i),e.setRenderTarget(s),e.autoClear=n,e.setClearColor(r,a),this.restoreOriginalMaterials(),this.debugMode&&this.debugCanvas&&this.updateDebugCanvas()}updateDebugCanvas(){if(!this.debugCanvas||!this.renderTarget||!this.world.renderer)return;const e=this.world.renderer.three,t=this.renderTargetSize,i=new Uint8Array(t.x*t.y*4);e.readRenderTargetPixels(this.renderTarget,0,0,t.x,t.y,i);const s=this.debugCanvas.getContext("2d");if(!s)return;const n=s.createImageData(t.x,t.y),r=4*t.x;for(let a=0;a<t.y;a++){const u=a*r,h=(t.y-1-a)*r;n.data.set(i.subarray(u,u+r),h)}s.putImageData(n,0,0)}getModelAt(e){var t=this;return(0,H.A)(function*(){if(!t.renderTarget||!t.world.renderer)throw new Error("Render target not initialized!");const i=t.components.get(ut);if(!i.initialized||0===i.list.size)return null;t.assignColors(),t.renderColorCoded();const s=e||t.mouse.position,n=t.renderTargetSize,r=Math.floor(.5*(s.x+1)*n.x),a=Math.floor(.5*(s.y+1)*(n.y-1)),l=Math.max(0,Math.min(n.x-1,r)),c=Math.max(0,Math.min(n.y-1,a)),u=t.world.renderer.three,h=new Uint8Array(4);return u.readRenderTargetPixels(t.renderTarget,l,c,1,1,h),t.colorToModelId.get(h[0]<<16|h[1]<<8|h[2])||null})()}setDebugMode(e){this.debugMode=e,e?this.setupDebugCanvas():this.removeDebugCanvas()}removeDebugCanvas(){this.debugContainer&&(this.debugContainer.remove(),this.debugContainer=void 0,this.debugCanvas=void 0)}dispose(){this.mouse.dispose(),this.removeDebugCanvas();for(const e of this.colorMaterials.values())e.dispose();this.colorMaterials.clear(),this.renderTarget&&this.renderTarget.dispose(),this.colorToModelId.clear(),this.modelIdToColor.clear(),this.originalMaterials.clear(),this.originalLodColors.clear(),this.onDisposed.trigger(),this.onDisposed.reset()}}const Jn=class vo extends Pt{constructor(e){super(e),w(this,"enabled",!0),w(this,"list",new Map),w(this,"onDisposed",new X),e.add(vo.uuid,this)}get(e){if(this.list.has(e.uuid))return this.list.get(e.uuid);const t=new Fa(this.components,e);return this.list.set(e.uuid,t),e.onDisposed.add(()=>{this.delete(e)}),t}delete(e){const t=this.list.get(e.uuid);t&&t.dispose(),this.list.delete(e.uuid)}dispose(){for(const[e,t]of this.list)t.dispose();this.list.clear(),this.onDisposed.trigger()}};w(Jn,"uuid","4a82430c-7ff2-49ea-9401-60807502dad6");let Da=Jn;class Na{constructor(e,t){w(this,"enabled",!0),w(this,"components"),w(this,"onDisposed",new X),w(this,"mouse"),w(this,"three",new b.tBo),w(this,"world"),w(this,"useFastModelPicking",!1);const i=t.renderer;if(!i)throw new Error("A renderer is needed for the raycaster to work!");this.world=t,this.mouse=new Wn(i.three.domElement),this.components=e}dispose(){this.mouse.dispose(),this.onDisposed.trigger(),this.onDisposed.reset()}castRayToObjects(e=Array.from(this.world.meshes),t=this.mouse.position){if(!this.world)throw new Error("A world is needed to cast rays!");return this.three.setFromCamera(t,this.world.camera.three),this.intersect(e)}castRay(e){var t=this;return(0,H.A)(function*(){const i=e?.snappingClasses,s=e?.items??Array.from(t.world.meshes),n=e?.position??t.mouse.position;if(!t.world)throw new Error("A world is needed to cast rays!");const r=t.world.camera.three,a=t.components.get(ut),l=t.world.renderer.three.domElement,c=t.mouse.rawPosition;let u=null;if(a.initialized){if(t.useFastModelPicking){const y=yield t.components.get(Da).get(t.world).getModelAt(n);if(y){const g=a.list.get(y);if(g)if(i&&i.length>0){const _=yield g.raycastWithSnapping({camera:r,dom:l,mouse:c,snappingClasses:i});u=_&&_.length>0?_[0]:yield g.raycast({camera:r,dom:l,mouse:c})}else u=yield g.raycast({camera:r,dom:l,mouse:c})}}else u=yield a.raycast({camera:r,dom:l,mouse:c,snappingClasses:i});if(0===s.length)return u}t.three.setFromCamera(n,r);const h=t.intersect(s);return u?h&&h.distance<u.distance?h:u:h})()}castRayFromVector(e,t,i=Array.from(this.world.meshes)){return this.three.set(e,t),this.intersect(i)}intersect(e=Array.from(this.world.meshes)){const t=this.three.intersectObjects(e),i=this.filterClippingPlanes(t);return i.length>0?i[0]:null}filterClippingPlanes(e){if(!this.world.renderer)throw new Error("Renderer not found!");const t=this.world.renderer.three;if(!t.clippingPlanes)return e;const i=t.clippingPlanes;return e.length<=0||!i||i?.length<=0?e:e.filter(s=>i.every(n=>n.distanceToPoint(s.point)>0))}}const tr=class bo extends Pt{constructor(e){super(e),w(this,"enabled",!0),w(this,"list",new Map),w(this,"onDisposed",new X),e.add(bo.uuid,this)}get(e){if(this.list.has(e.uuid))return this.list.get(e.uuid);const t=new Na(this.components,e);return this.list.set(e.uuid,t),e.onDisposed.add(()=>{this.delete(e)}),t}delete(e){const t=this.list.get(e.uuid);t&&t.dispose(),this.list.delete(e.uuid)}dispose(){for(const[e,t]of this.list)t.dispose();this.list.clear(),this.onDisposed.trigger()}};w(tr,"uuid","d5d8bdf0-db25-4952-b951-b643af207ace");let Fi=tr;class Ra extends ys{constructor(){var e;super(...arguments),e=this,w(this,"onCameraChanged",new X),w(this,"meshes",new Set),w(this,"onAfterUpdate",new X),w(this,"onBeforeUpdate",new X),w(this,"onDisposed",new X),w(this,"isDisposing",!1),w(this,"enabled",!0),w(this,"_dynamicAnchor",!1),w(this,"uuid",Wt.create()),w(this,"name"),w(this,"_scene"),w(this,"_camera"),w(this,"_renderer",null),w(this,"onPointerDown",function(){var t=(0,H.A)(function*(i){if(!e.camera.hasCameraControls())throw new Error("World: can't set dynamic anchor if the camera doesn't have controls.");const n=yield e.components.get(Fi).get(e).castRay();n&&n.point&&0===i.button&&e.camera.controls.setOrbitPoint(n.point.x,n.point.y,n.point.z)});return function(i){return t.apply(this,arguments)}}()),w(this,"_defaultCamera")}set dynamicAnchor(e){var t;const i=null==(t=this.renderer)?void 0:t.three.domElement.parentElement;if(!i)throw new Error("World: the renderer must have a parentElement to set dynamic anchoring.");e?(this.camera.controls&&(this.camera.controls.minDistance=.01),i.addEventListener("pointerdown",this.onPointerDown)):i.removeEventListener("pointerdown",this.onPointerDown)}get dynamicAnchor(){return this._dynamicAnchor}get defaultCamera(){if(!this._defaultCamera)throw new Error("World: there is no default camera defined.");return this._defaultCamera}set defaultCamera(e){this._defaultCamera=e}get scene(){if(!this._scene)throw new Error("No scene initialized!");return this._scene}set scene(e){this._scene=e,e.worlds.set(this.uuid,this),e.currentWorld=this,e.onWorldChanged.trigger({world:this,action:"added"})}get camera(){if(!this._camera)throw new Error("No camera initialized!");return this._camera}set camera(e){this._camera||(this.defaultCamera=e),this._camera=e,e.currentWorld=this,this.onCameraChanged.trigger(e)}get renderer(){return this._renderer}set renderer(e){this._renderer=e,e&&(e.worlds.set(this.uuid,this),e.currentWorld=this,e.onWorldChanged.trigger({world:this,action:"added"}))}useDefaultCamera(){this.camera=this.defaultCamera}update(e){this.enabled&&(!this._scene||!this._camera||(this.scene.currentWorld=this,this.camera.currentWorld=this,this.renderer&&(this.renderer.currentWorld=this),this.onBeforeUpdate.trigger(),this.scene.isUpdateable()&&this.scene.update(e),this.camera.isUpdateable()&&this.camera.update(e),this.renderer&&this.renderer.update(e),this.onAfterUpdate.trigger()))}dispose(e=!0){if(this.enabled=!1,this.isDisposing=!0,this.scene.onWorldChanged.trigger({world:this,action:"removed"}),this.camera.onWorldChanged.trigger({world:this,action:"removed"}),this.renderer&&this.renderer.onWorldChanged.trigger({world:this,action:"removed"}),e){const i=this.components.get(si);this.scene.dispose(),this.camera.isDisposeable()&&this.camera.dispose(),this.renderer&&this.renderer.dispose();for(const s of this.meshes)i.destroy(s);this.meshes.clear()}this._scene=null,this._camera=null,this._renderer=null,this.components.get(Ps).list.delete(this.uuid),this.onDisposed.trigger(),this.onDisposed.reset()}}class Ba{constructor(e,t){w(this,"_list"),w(this,"_scene"),this._list=e,this._scene=t}get color(){return this._list.directionalLight.color.value}set color(e){this._list.directionalLight.color.value=e;for(const[,t]of this._scene.directionalLights)t.color.copy(e)}get intensity(){return this._list.directionalLight.intensity.value}set intensity(e){this._list.directionalLight.intensity.value=e;for(const[,t]of this._scene.directionalLights)t.intensity=e}get position(){return this._list.directionalLight.position.value.clone()}set position(e){this._list.directionalLight.position.value=e;for(const[,t]of this._scene.directionalLights)t.position.copy(e)}}class La{constructor(e,t){w(this,"_list"),w(this,"_scene"),this._list=e,this._scene=t}get color(){return this._list.ambientLight.color.value}set color(e){this._list.ambientLight.color.value=e;for(const[,t]of this._scene.ambientLights)t.color.copy(e)}get intensity(){return this._list.ambientLight.intensity.value}set intensity(e){this._list.ambientLight.intensity.value=e;for(const[,t]of this._scene.ambientLights)t.intensity=e}}class Va extends oi{constructor(){super(...arguments),w(this,"_config",{backgroundColor:{value:new b.Q1f,type:"Color"},ambientLight:{color:{type:"Color",value:new b.Q1f},intensity:{type:"Number",interpolable:!0,min:0,max:10,value:2}},directionalLight:{color:{type:"Color",value:new b.Q1f},intensity:{type:"Number",interpolable:!0,min:0,max:10,value:2},position:{type:"Vector3",value:new b.Pq0}}}),w(this,"ambientLight",new La(this._config,this._component)),w(this,"directionalLight",new Ba(this._config,this._component))}get backgroundColor(){return this._config.backgroundColor.value}set backgroundColor(e){this._config.backgroundColor.value=e,this._component.three.background=e}}class er extends Fo{constructor(e){super(e),w(this,"onSetup",new X),w(this,"isSetup",!1),w(this,"three"),w(this,"config",new Va(this,this.components,"Scene")),w(this,"_defaultConfig",{backgroundColor:new b.Q1f(2107698),directionalLight:{color:new b.Q1f("white"),intensity:1.5,position:new b.Pq0(5,10,3)},ambientLight:{color:new b.Q1f("white"),intensity:1}}),this.three=new b.Z58,this.three.background=new b.Q1f(2107698)}setup(e){const t={...this._defaultConfig,...e};this.config.backgroundColor=t.backgroundColor;const i=t.ambientLight;this.config.ambientLight.color=i.color,this.config.ambientLight.intensity=i.intensity;const s=t.directionalLight;this.config.directionalLight.color=s.color,this.config.directionalLight.intensity=s.intensity,this.config.directionalLight.position=s.position,this.deleteAllLights();const{color:n,intensity:r}=this.config.directionalLight,a=new b.ZyN(n,r);a.position.copy(s.position);const{color:l,intensity:c}=this.config.directionalLight,u=new b.$p8(l,c);this.three.add(a,u),this.directionalLights.set(a.uuid,a),this.ambientLights.set(u.uuid,u),this.isSetup=!0,this.onSetup.trigger()}dispose(){super.dispose(),this.components.get(zi).list.delete(this.config.uuid)}}class li extends ko{constructor(e){super(e),w(this,"onBeforeUpdate",new X),w(this,"onAfterUpdate",new X),w(this,"onAspectUpdated",new X),w(this,"onDisposed",new X),w(this,"three"),w(this,"_resizeObserver",null),w(this,"_allControls",new Map),w(this,"updateAspect",()=>{var t;if(this.currentWorld&&this.currentWorld.renderer){if(this.three instanceof b.qUd)return void this.onAspectUpdated.trigger();if(null!=(t=this.currentWorld.renderer)&&t.isResizeable()){const i=this.currentWorld.renderer.getSize();this.three.aspect=i.width/i.height,this.three.updateProjectionMatrix(),this.onAspectUpdated.trigger()}}}),this.three=this.setupCamera(),this.worlds.onItemSet.add(({value:t})=>{const i=this.newCameraControls();this.setupEvents(!0),this._allControls.set(t.uuid,i)}),this.worlds.onBeforeDelete.add(({value:t})=>{var i;const s=this._allControls.get(t.uuid);s&&(s.dispose(),this._allControls.delete(t.uuid)),null==(i=this._resizeObserver)||i.disconnect()})}get controls(){if(!this.currentWorld)throw new Error("This camera needs a world to work!");const e=this._allControls.get(this.currentWorld.uuid);if(!e)throw new Error("Controls not found!");return e}get enabled(){return null!==this.currentWorld&&this.controls.enabled}set enabled(e){null!==this.currentWorld&&(this.controls.enabled=e)}set currentWorld(e){super.currentWorld=e,e&&(this.worlds.get(e.uuid)||this.worlds.set(e.uuid,e))}get currentWorld(){return this._currentWorld}dispose(){this.setupEvents(!1),this.onAspectUpdated.reset(),this.onBeforeUpdate.reset(),this.onAfterUpdate.reset(),this.three.removeFromParent(),this.onDisposed.trigger(),this.onDisposed.reset();for(const[e,t]of this._allControls)t.dispose();this.worlds.clear()}fitToItems(e){var t=this;return(0,H.A)(function*(){const i=yield t.getItemsBounding(e);yield t.controls.fitToSphere(i,!0)})()}setOrbitToItems(e){var t=this;return(0,H.A)(function*(){const i=yield t.getItemsBounding(e);t.controls.setOrbitPoint(i.center.x,i.center.y,i.center.z)})()}update(e){this.enabled&&(this.onBeforeUpdate.trigger(this),this.controls.update(e),this.onAfterUpdate.trigger(this))}getItemsBounding(e){var t=this;return(0,H.A)(function*(){const i=t.components.get(ut),s=t.components.get(Qn);s.list.clear();const n=new b.iyt;if(e)yield s.addFromModelIdMap(e);else for(const[,r]of i.list)s.list.add(r.box);return s.get().getBoundingSphere(n),s.list.clear(),n})()}setupCamera(){const e=window.innerWidth/window.innerHeight,t=new b.ubm(60,e,1,1e3);return t.position.set(50,50,50),t.lookAt(new b.Pq0(0,0,0)),t}newCameraControls(){if(!this.currentWorld)throw new Error("This camera needs a world to work!");if(!this.currentWorld.renderer)throw new Error("This camera needs a renderer to work!");Vt.install({THREE:li.getSubsetOfThree()});const{domElement:e}=this.currentWorld.renderer.three,t=new Vt(this.three,e);return t.smoothTime=.2,t.dollyToCursor=!0,t.infinityDolly=!0,t.minDistance=6,t}setupEvents(e){if(this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=null),e){if(!this.currentWorld)throw new Error("This camera needs a world to work!");if(!this.currentWorld.renderer)throw new Error("This camera needs a renderer to work!");const{domElement:t}=this.currentWorld.renderer.three;this._resizeObserver=new ResizeObserver(this.updateAspect),this._resizeObserver.observe(t)}}static getSubsetOfThree(){return{MOUSE:b.kBv,Vector2:b.I9Y,Vector3:b.Pq0,Vector4:b.IUQ,Quaternion:b.PTz,Matrix4:b.kn4,Spherical:b.YHV,Box3:b.NRn,Sphere:b.iyt,Raycaster:b.tBo,MathUtils:b.cj9}}}const ir=class wo extends Pt{constructor(e){super(e),w(this,"onAfterUpdate",new X),w(this,"onBeforeUpdate",new X),w(this,"onDisposed",new X),w(this,"list",new dt.jp),w(this,"enabled",!0),e.add(wo.uuid,this)}create(){const e=new Ra(this.components),t=e.uuid;if(this.list.has(t))throw new Error("There is already a world with this name!");return this.list.set(t,e),e}delete(e){if(!this.list.has(e.uuid))throw new Error("The provided world is not found in the list!");this.list.delete(e.uuid),e.dispose()}dispose(){this.enabled=!1;for(const[e,t]of this.list)t.dispose();this.list.clear(),this.onDisposed.trigger()}update(e){if(this.enabled)for(const[t,i]of this.list)i.update(e)}};w(ir,"uuid","fdb61dc4-2ec1-4966-b83d-54ea795fad4a");let Ps=ir;class $a extends oi{constructor(){super(...arguments),w(this,"_config",{visible:{value:!0,type:"Boolean"},color:{value:new b.Q1f,type:"Color"},primarySize:{type:"Number",interpolable:!0,value:1,min:0,max:1e3},secondarySize:{type:"Number",interpolable:!0,value:10,min:0,max:1e3},distance:{type:"Number",interpolable:!0,value:500,min:0,max:500}})}get visible(){return this._config.visible.value}set visible(e){this._config.visible.value=e,this._component.visible=e}get color(){return this._config.color.value}set color(e){this._config.color.value=e,this._component.material.uniforms.uColor.value=e,this._component.material.uniformsNeedUpdate=!0}get primarySize(){return this._config.primarySize.value}set primarySize(e){this._config.primarySize.value=e,this._component.material.uniforms.uSize1.value=e,this._component.material.uniformsNeedUpdate=!0}get secondarySize(){return this._config.secondarySize.value}set secondarySize(e){this._config.secondarySize.value=e,this._component.material.uniforms.uSize2.value=e,this._component.material.uniformsNeedUpdate=!0}get distance(){return this._config.distance.value}set distance(e){this._config.distance.value=e,this._component.material.uniforms.uDistance.value=e,this._component.material.uniformsNeedUpdate=!0}}class ja{constructor(e,t){w(this,"onDisposed",new X),w(this,"onSetup",new X),w(this,"isSetup",!1),w(this,"world"),w(this,"components"),w(this,"config"),w(this,"_defaultConfig",{visible:!0,color:new b.Q1f(12303291),primarySize:1,secondarySize:10,distance:500}),w(this,"three"),w(this,"_fade",3),w(this,"updateZoom",()=>{this.world.camera instanceof li&&(this.material.uniforms.uZoom.value=this.world.camera.three.zoom)}),this.world=t;const{color:i,primarySize:s,secondarySize:n,distance:r}=this._defaultConfig;this.components=e,this.config=new $a(this,this.components,"Grid");const a=new b.bdM(2,2,1,1),l=new b.BKk({side:b.$EB,uniforms:{uSize1:{value:s},uSize2:{value:n},uColor:{value:i},uDistance:{value:r},uFade:{value:this._fade},uZoom:{value:1}},transparent:!0,vertexShader:"\n \n varying vec3 worldPosition;\n \n uniform float uDistance;\n \n void main() {\n \n vec3 pos = position.xzy * uDistance;\n pos.xz += cameraPosition.xz;\n \n worldPosition = pos;\n \n gl_Position = projectionMatrix * modelViewMatrix * vec4(pos, 1.0);\n \n }\n ",fragmentShader:"\n \n varying vec3 worldPosition;\n \n uniform float uZoom;\n uniform float uFade;\n uniform float uSize1;\n uniform float uSize2;\n uniform vec3 uColor;\n uniform float uDistance;\n \n \n \n float getGrid(float size) {\n \n vec2 r = worldPosition.xz / size;\n \n \n vec2 grid = abs(fract(r - 0.5) - 0.5) / fwidth(r);\n float line = min(grid.x, grid.y);\n \n \n return 1.0 - min(line, 1.0);\n }\n \n void main() {\n \n \n float d = 1.0 - min(distance(cameraPosition.xz, worldPosition.xz) / uDistance, 1.0);\n \n float g1 = getGrid(uSize1);\n float g2 = getGrid(uSize2);\n \n // Ortho camera fades the grid away when zooming out\n float minZoom = step(0.2, uZoom);\n float zoomFactor = pow(min(uZoom, 1.), 2.) * minZoom;\n \n gl_FragColor = vec4(uColor.rgb, mix(g2, g1, g1) * pow(d, uFade));\n gl_FragColor.a = mix(0.5 * gl_FragColor.a, gl_FragColor.a, g2) * zoomFactor;\n \n if ( gl_FragColor.a <= 0.0 ) discard;\n \n \n }\n \n ",extensions:{derivatives:!0}});this.three=new b.eaF(a,l),this.three.frustumCulled=!1,t.scene.three.add(this.three),this.setupEvents(!0)}get visible(){return this.three.visible}set visible(e){this.three.visible=e,e?this.world.scene.three.add(this.three):this.three.removeFromParent()}get material(){return this.three.material}get fade(){return 3===this._fade}set fade(e){this._fade=e?3:0,this.material.uniforms.uFade.value=this._fade}setup(e){const t={...this._defaultConfig,...e};this.config.visible=!0,this.config.color=t.color,this.config.primarySize=t.primarySize,this.config.secondarySize=t.secondarySize,this.config.distance=t.distance,this.isSetup=!0,this.onSetup.trigger()}dispose(){this.setupEvents(!1),this.components.get(zi).list.delete(this.config.uuid),this.components.get(si).destroy(this.three),this.onDisposed.trigger(),this.onDisposed.reset(),this.world=null,this.components=null}setupEvents(e){if(this.world.isDisposing||!(this.world.camera instanceof li))return;const t=this.world.camera.controls;e?t.addEventListener("update",this.updateZoom):t.removeEventListener("update",this.updateZoom)}}w(class xo extends Pt{constructor(e){super(e),w(this,"list",new Map),w(this,"onDisposed",new X),w(this,"enabled",!0),e.add(xo.uuid,this)}create(e){if(this.list.has(e.uuid))throw new Error("This world already has a grid!");const t=new ja(this.components,e);return this.list.set(e.uuid,t),e.onDisposed.add(()=>{this.delete(e)}),t}delete(e){const t=this.list.get(e.uuid);t&&t.dispose(),this.list.delete(e.uuid)}dispose(){for(const[e,t]of this.list)t.dispose();this.list.clear(),this.onDisposed.trigger(),this.onDisposed.reset()}},"uuid","d1e814d5-b81c-4452-87a2-f039375e0489");const Ni=65535,Za=Math.pow(2,-24),Ms=Symbol("SKIP_GENERATION");function Be(o){return function Wa(o){return o.index?o.index.count:o.attributes.position.count}(o)/3}function or(o){const e=Be(o),t=o.drawRange,s=(t.start+t.count)/3,n=Math.max(0,t.start/3),r=Math.min(e,s)-n;return[{offset:Math.floor(n),count:Math.floor(r)}]}function ar(o){if(!o.groups||!o.groups.length)return or(o);const e=[],t=new Set,i=o.drawRange,s=i.start/3,n=(i.start+i.count)/3;for(const a of o.groups){const c=(a.start+a.count)/3;t.add(Math.max(s,a.start/3)),t.add(Math.min(n,c))}const r=Array.from(t.values()).sort((a,l)=>a-l);for(let a=0;a<r.length-1;a++){const l=r[a],c=r[a+1];e.push({offset:Math.floor(l),count:Math.floor(c-l)})}return e}function It(o,e,t){return t.min.x=e[o],t.min.y=e[o+1],t.min.z=e[o+2],t.max.x=e[o+3],t.max.y=e[o+4],t.max.z=e[o+5],t}function lr(o){let e=-1,t=-1/0;for(let i=0;i<3;i++){const s=o[i+3]-o[i];s>t&&(t=s,e=i)}return e}function cr(o,e){e.set(o)}function ur(o,e,t){let i,s;for(let n=0;n<3;n++){const r=n+3;i=o[n],s=e[n],t[n]=i<s?i:s,i=o[r],s=e[r],t[r]=i>s?i:s}}function Ri(o,e,t){for(let i=0;i<3;i++){const s=e[o+2*i],n=e[o+2*i+1],r=s-n,a=s+n;r<t[i]&&(t[i]=r),a>t[i+3]&&(t[i+3]=a)}}function ci(o){const e=o[3]-o[0],t=o[4]-o[1],i=o[5]-o[2];return 2*(e*t+t*i+i*e)}function Ss(o,e,t,i,s=null){let n=1/0,r=1/0,a=1/0,l=-1/0,c=-1/0,u=-1/0,h=1/0,f=1/0,d=1/0,y=-1/0,g=-1/0,_=-1/0;const m=null!==s;for(let x=6*e,T=6*(e+t);x<T;x+=6){const E=o[x+0],P=o[x+1],I=E-P,M=E+P;I<n&&(n=I),M>l&&(l=M),m&&E<h&&(h=E),m&&E>y&&(y=E);const z=o[x+2],O=o[x+3],D=z-O,Z=z+O;D<r&&(r=D),Z>c&&(c=Z),m&&z<f&&(f=z),m&&z>g&&(g=z);const A=o[x+4],F=o[x+5],v=A-F,R=A+F;v<a&&(a=v),R>u&&(u=R),m&&A<d&&(d=A),m&&A>_&&(_=A)}i[0]=n,i[1]=r,i[2]=a,i[3]=l,i[4]=c,i[5]=u,m&&(s[0]=h,s[1]=f,s[2]=d,s[3]=y,s[4]=g,s[5]=_)}const tl=(o,e)=>o.candidate-e.candidate,we=new Array(32).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),Bi=new Float32Array(6);class Li{constructor(){}}function sl(o,e,t,i,s,n){let r=i,a=i+s-1;const l=n.pos,c=2*n.axis;for(;;){for(;r<=a&&t[6*r+c]<l;)r++;for(;r<=a&&t[6*a+c]>=l;)a--;if(!(r<a))return r;for(let u=0;u<3;u++){let h=e[3*r+u];e[3*r+u]=e[3*a+u],e[3*a+u]=h}for(let u=0;u<6;u++){let h=t[6*r+u];t[6*r+u]=t[6*a+u],t[6*a+u]=h}r++,a--}}function nl(o,e,t,i,s,n){let r=i,a=i+s-1;const l=n.pos,c=2*n.axis;for(;;){for(;r<=a&&t[6*r+c]<l;)r++;for(;r<=a&&t[6*a+c]>=l;)a--;if(!(r<a))return r;{let u=o[r];o[r]=o[a],o[a]=u;for(let h=0;h<6;h++){let f=t[6*r+h];t[6*r+h]=t[6*a+h],t[6*a+h]=f}r++,a--}}}function al(o,e){const t=o.geometry;e.indirect&&(o._indirectBuffer=function rl(o,e){const t=(o.index?o.index.count:o.attributes.position.count)/3,i=t>65536,s=i?4:2,n=e?new SharedArrayBuffer(t*s):new ArrayBuffer(t*s),r=i?new Uint32Array(n):new Uint16Array(n);for(let a=0,l=r.length;a<l;a++)r[a]=a;return r}(t,e.useSharedArrayBuffer),function Xa(o){if(0===o.groups.length)return!1;const e=Be(o),t=ar(o).sort((n,r)=>n.offset-r.offset),i=t[t.length-1];i.count=Math.min(e-i.offset,i.count);let s=0;return t.forEach(({count:n})=>s+=n),e!==s}(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.')),o._indirectBuffer||function qa(o,e){if(!o.index){const t=o.attributes.position.count,s=function Ga(o,e=ArrayBuffer){return o>65535?new Uint32Array(new e(4*o)):new Uint16Array(new e(2*o))}(t,e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer);o.setIndex(new b.THS(s,1));for(let n=0;n<t;n++)s[n]=n}}(t,e);const i=function ol(o,e){const t=o.geometry,i=t.index?t.index.array:null,s=e.maxDepth,n=e.verbose,r=e.maxLeafTris,a=e.strategy,l=e.onProgress,c=Be(t),u=o._indirectBuffer;let h=!1;const f=new Float32Array(6),d=new Float32Array(6),y=function Ja(o,e){!function Qa(o){o[0]=o[1]=o[2]=1/0,o[3]=o[4]=o[5]=-1/0}(e);const t=o.attributes.position,i=o.index?o.index.array:null,s=Be(o),n=new Float32Array(6*s),r=t.normalized,a=t.array,l=t.offset||0;let c=3;t.isInterleavedBufferAttribute&&(c=t.data.stride);const u=["getX","getY","getZ"];for(let h=0;h<s;h++){const f=3*h,d=6*h;let y=f+0,g=f+1,_=f+2;i&&(y=i[y],g=i[g],_=i[_]),r||(y=y*c+l,g=g*c+l,_=_*c+l);for(let m=0;m<3;m++){let x,T,E;r?(x=t[u[m]](y),T=t[u[m]](g),E=t[u[m]](_)):(x=a[y+m],T=a[g+m],E=a[_+m]);let P=x;T<P&&(P=T),E<P&&(P=E);let I=x;T>I&&(I=T),E>I&&(I=E);const M=(I-P)/2,z=2*m;n[d+z+0]=P+M,n[d+z+1]=M+(Math.abs(P)+M)*Za,P<e[m]&&(e[m]=P),I>e[m+3]&&(e[m+3]=I)}}return n}(t,f),g=e.indirect?nl:sl,_=[],m=e.indirect?or(t):ar(t);if(1===m.length){const E=m[0],P=new Li;P.boundingData=f,function Ka(o,e,t,i){let s=1/0,n=1/0,r=1/0,a=-1/0,l=-1/0,c=-1/0;for(let u=6*e,h=6*(e+t);u<h;u+=6){const f=o[u+0];f<s&&(s=f),f>a&&(a=f);const d=o[u+2];d<n&&(n=d),d>l&&(l=d);const y=o[u+4];y<r&&(r=y),y>c&&(c=y)}i[0]=s,i[1]=n,i[2]=r,i[3]=a,i[4]=l,i[5]=c}(y,E.offset,E.count,d),T(P,E.offset,E.count,d),_.push(P)}else for(let E of m){const P=new Li;P.boundingData=new Float32Array(6),Ss(y,E.offset,E.count,P.boundingData,d),T(P,E.offset,E.count,d),_.push(P)}return _;function x(E){l&&l(E/c)}function T(E,P,I,M=null,z=0){if(!h&&z>=s&&(h=!0,n&&(console.warn(`MeshBVH: Max depth of ${s} reached when generating BVH. Consider increasing maxDepth.`),console.warn(t))),I<=r||z>=s)return x(P+I),E.offset=P,E.count=I,E;const O=function el(o,e,t,i,s,n){let r=-1,a=0;if(0===n)r=lr(e),-1!==r&&(a=(e[r]+e[r+3])/2);else if(1===n)r=lr(o),-1!==r&&(a=function il(o,e,t,i){let s=0;for(let n=e,r=e+t;n<r;n++)s+=o[6*n+2*i];return s/t}(t,i,s,r));else if(2===n){const l=ci(o);let c=1.25*s;const u=6*i,h=6*(i+s);for(let f=0;f<3;f++){const d=e[f],_=(e[f+3]-d)/32;if(s<8){const m=[...we];m.length=s;let x=0;for(let E=u;E<h;E+=6,x++){const P=m[x];P.candidate=t[E+2*f],P.count=0;const{bounds:I,leftCacheBounds:M,rightCacheBounds:z}=P;for(let O=0;O<3;O++)z[O]=1/0,z[O+3]=-1/0,M[O]=1/0,M[O+3]=-1/0,I[O]=1/0,I[O+3]=-1/0;Ri(E,t,I)}m.sort(tl);let T=s;for(let E=0;E<T;E++){const P=m[E];for(;E+1<T&&m[E+1].candidate===P.candidate;)m.splice(E+1,1),T--}for(let E=u;E<h;E+=6){const P=t[E+2*f];for(let I=0;I<T;I++){const M=m[I];P>=M.candidate?Ri(E,t,M.rightCacheBounds):(Ri(E,t,M.leftCacheBounds),M.count++)}}for(let E=0;E<T;E++){const P=m[E],I=P.count,M=s-P.count,O=P.rightCacheBounds;let D=0;0!==I&&(D=ci(P.leftCacheBounds)/l);let Z=0;0!==M&&(Z=ci(O)/l);const A=1+1.25*(D*I+Z*M);A<c&&(r=f,c=A,a=P.candidate)}}else{for(let T=0;T<32;T++){const E=we[T];E.count=0,E.candidate=d+_+T*_;const P=E.bounds;for(let I=0;I<3;I++)P[I]=1/0,P[I+3]=-1/0}for(let T=u;T<h;T+=6){let I=~~((t[T+2*f]-d)/_);I>=32&&(I=31);const M=we[I];M.count++,Ri(T,t,M.bounds)}const m=we[31];cr(m.bounds,m.rightCacheBounds);for(let T=30;T>=0;T--){const E=we[T];ur(E.bounds,we[T+1].rightCacheBounds,E.rightCacheBounds)}let x=0;for(let T=0;T<31;T++){const E=we[T],P=E.count,I=E.bounds,z=we[T+1].rightCacheBounds;0!==P&&(0===x?cr(I,Bi):ur(I,Bi,Bi)),x+=P;let O=0,D=0;0!==x&&(O=ci(Bi)/l);const Z=s-x;0!==Z&&(D=ci(z)/l);const A=1+1.25*(O*x+D*Z);A<c&&(r=f,c=A,a=E.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${n} used.`);return{axis:r,pos:a}}(E.boundingData,M,y,P,I,a);if(-1===O.axis)return x(P+I),E.offset=P,E.count=I,E;const D=g(u,i,y,P,I,O);if(D===P||D===P+I)x(P+I),E.offset=P,E.count=I;else{E.splitAxis=O.axis;const Z=new Li,A=P,F=D-P;E.left=Z,Z.boundingData=new Float32Array(6),Ss(y,A,F,Z.boundingData,d),T(Z,A,F,d,z+1);const v=new Li,R=D,Q=I-F;E.right=v,v.boundingData=new Float32Array(6),Ss(y,R,Q,v.boundingData,d),T(v,R,Q,d,z+1)}return E}}(o,e);let s,n,r;const a=[],l=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;for(let h=0;h<i.length;h++){const f=i[h],y=new l(32*c(f));s=new Float32Array(y),n=new Uint32Array(y),r=new Uint16Array(y),u(0,f),a.push(y)}return void(o._roots=a);function c(h){return h.count?1:1+c(h.left)+c(h.right)}function u(h,f){const d=h/4,y=h/2,g=!!f.count,_=f.boundingData;for(let m=0;m<6;m++)s[d+m]=_[m];if(g){const x=f.count;return n[d+6]=f.offset,r[y+14]=x,r[y+15]=Ni,h+32}{const x=f.right,T=f.splitAxis;let E;if(E=u(h+32,f.left),E/4>Math.pow(2,32))throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return n[d+6]=E/4,E=u(E,x),n[d+7]=T,E}}}class ge{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let i=1/0,s=-1/0;for(let n=0,r=e.length;n<r;n++){const l=e[n][t];i=l<i?l:i,s=l>s?l:s}this.min=i,this.max=s}setFromPoints(e,t){let i=1/0,s=-1/0;for(let n=0,r=t.length;n<r;n++){const l=e.dot(t[n]);i=l<i?l:i,s=l>s?l:s}this.min=i,this.max=s}isSeparated(e){return this.min>e.max||e.min>this.max}}ge.prototype.setFromBox=function(){const o=new b.Pq0;return function(t,i){const s=i.min,n=i.max;let r=1/0,a=-1/0;for(let l=0;l<=1;l++)for(let c=0;c<=1;c++)for(let u=0;u<=1;u++){o.x=s.x*l+n.x*(1-l),o.y=s.y*c+n.y*(1-c),o.z=s.z*u+n.z*(1-u);const h=t.dot(o);r=Math.min(h,r),a=Math.max(h,a)}this.min=r,this.max=a}}();const ll=function(){const o=new b.Pq0,e=new b.Pq0,t=new b.Pq0;return function(s,n,r){const l=o,u=e;t.subVectors(s.start,n.start),o.subVectors(s.end,s.start),e.subVectors(n.end,n.start);const h=t.dot(u),f=u.dot(l),d=u.dot(u),y=t.dot(l),_=l.dot(l)*d-f*f;let m,x;m=0!==_?(h*f-y*d)/_:0,x=(h+m*f)/d,r.x=m,r.y=x}}(),Is=function(){const o=new b.I9Y,e=new b.Pq0,t=new b.Pq0;return function(s,n,r,a){ll(s,n,o);let l=o.x,c=o.y;if(l>=0&&l<=1&&c>=0&&c<=1)return s.at(l,r),void n.at(c,a);if(l>=0&&l<=1)return n.at(c<0?0:1,a),void s.closestPointToPoint(a,!0,r);if(c>=0&&c<=1)return s.at(l<0?0:1,r),void n.closestPointToPoint(r,!0,a);{let u,h;u=l<0?s.start:s.end,h=c<0?n.start:n.end;const f=e,d=t;return s.closestPointToPoint(h,!0,e),n.closestPointToPoint(u,!0,t),f.distanceToSquared(h)<=d.distanceToSquared(u)?(r.copy(f),void a.copy(h)):(r.copy(u),void a.copy(d))}}}(),cl=function(){const o=new b.Pq0,e=new b.Pq0,t=new b.Zcv,i=new b.cZY;return function(n,r){const{radius:a,center:l}=n,{a:c,b:u,c:h}=r;if(i.start=c,i.end=u,i.closestPointToPoint(l,!0,o).distanceTo(l)<=a||(i.start=c,i.end=h,i.closestPointToPoint(l,!0,o).distanceTo(l)<=a)||(i.start=u,i.end=h,i.closestPointToPoint(l,!0,o).distanceTo(l)<=a))return!0;const g=r.getPlane(t);if(Math.abs(g.distanceToPoint(l))<=a){const m=g.projectPoint(l,e);if(r.containsPoint(m))return!0}return!1}}();function Os(o){return Math.abs(o)<1e-15}class re extends b.lMl{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new b.Pq0),this.satBounds=new Array(4).fill().map(()=>new ge),this.points=[this.a,this.b,this.c],this.sphere=new b.iyt,this.plane=new b.Zcv,this.needsUpdate=!0}intersectsSphere(e){return cl(e,this)}update(){const e=this.a,t=this.b,i=this.c,s=this.points,n=this.satAxes,r=this.satBounds,a=n[0],l=r[0];this.getNormal(a),l.setFromPoints(a,s);const c=n[1],u=r[1];c.subVectors(e,t),u.setFromPoints(c,s);const h=n[2],f=r[2];h.subVectors(t,i),f.setFromPoints(h,s);const d=n[3],y=r[3];d.subVectors(i,e),y.setFromPoints(d,s),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(a,e),this.needsUpdate=!1}}re.prototype.closestPointToSegment=function(){const o=new b.Pq0,e=new b.Pq0,t=new b.cZY;return function(s,n=null,r=null){const{start:a,end:l}=s,c=this.points;let u,h=1/0;for(let f=0;f<3;f++){const d=(f+1)%3;t.start.copy(c[f]),t.end.copy(c[d]),Is(t,s,o,e),u=o.distanceToSquared(e),u<h&&(h=u,n&&n.copy(o),r&&r.copy(e))}return this.closestPointToPoint(a,o),u=a.distanceToSquared(o),u<h&&(h=u,n&&n.copy(o),r&&r.copy(a)),this.closestPointToPoint(l,o),u=l.distanceToSquared(o),u<h&&(h=u,n&&n.copy(o),r&&r.copy(l)),Math.sqrt(h)}}(),re.prototype.intersectsTriangle=function(){const o=new re,e=new Array(3),t=new Array(3),i=new ge,s=new ge,n=new b.Pq0,r=new b.Pq0,a=new b.Pq0,l=new b.Pq0,c=new b.Pq0,u=new b.cZY,h=new b.cZY,f=new b.cZY,d=new b.Pq0;function y(g,_,m){const x=g.points;let T=0,E=-1;for(let P=0;P<3;P++){const{start:I,end:M}=u;I.copy(x[P]),M.copy(x[(P+1)%3]),u.delta(r);const z=Os(_.distanceToPoint(I));if(Os(_.normal.dot(r))&&z){m.copy(u),T=2;break}const O=_.intersectLine(u,d);if(!O&&z&&d.copy(I),(O||z)&&!Os(d.distanceTo(M))){if(T<=1)(1===T?m.start:m.end).copy(d),z&&(E=T);else if(T>=2){(1===E?m.start:m.end).copy(d),T=2;break}if(T++,2===T&&-1===E)break}}return T}return function(_,m=null,x=!1){this.needsUpdate&&this.update(),_.isExtendedTriangle?_.needsUpdate&&_.update():(o.copy(_),o.update(),_=o);const T=this.plane,E=_.plane;if(Math.abs(T.normal.dot(E.normal))>1-1e-10){const P=this.satBounds,I=this.satAxes;t[0]=_.a,t[1]=_.b,t[2]=_.c;for(let O=0;O<4;O++){const D=P[O];if(i.setFromPoints(I[O],t),D.isSeparated(i))return!1}const M=_.satBounds,z=_.satAxes;e[0]=this.a,e[1]=this.b,e[2]=this.c;for(let O=0;O<4;O++){const D=M[O];if(i.setFromPoints(z[O],e),D.isSeparated(i))return!1}for(let O=0;O<4;O++){const D=I[O];for(let Z=0;Z<4;Z++)if(n.crossVectors(D,z[Z]),i.setFromPoints(n,e),s.setFromPoints(n,t),i.isSeparated(s))return!1}return m&&(x||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),m.start.set(0,0,0),m.end.set(0,0,0)),!0}{const P=y(this,E,h);if(1===P&&_.containsPoint(h.end))return m&&(m.start.copy(h.end),m.end.copy(h.end)),!0;if(2!==P)return!1;const I=y(_,T,f);if(1===I&&this.containsPoint(f.end))return m&&(m.start.copy(f.end),m.end.copy(f.end)),!0;if(2!==I)return!1;if(h.delta(a),f.delta(l),a.dot(l)<0){let F=f.start;f.start=f.end,f.end=F}const M=h.start.dot(a),z=h.end.dot(a),O=f.start.dot(a),D=f.end.dot(a);return(M===D||O===z||z<O!=M<D)&&(m&&(c.subVectors(h.start,f.start),c.dot(a)>0?m.start.copy(h.start):m.start.copy(f.start),c.subVectors(h.end,f.end),c.dot(a)<0?m.end.copy(h.end):m.end.copy(f.end)),!0)}}}(),re.prototype.distanceToPoint=function(){const o=new b.Pq0;return function(t){return this.closestPointToPoint(t,o),t.distanceTo(o)}}(),re.prototype.distanceToTriangle=function(){const o=new b.Pq0,e=new b.Pq0,t=["a","b","c"],i=new b.cZY,s=new b.cZY;return function(r,a=null,l=null){const c=a||l?i:null;if(this.intersectsTriangle(r,c))return(a||l)&&(a&&c.getCenter(a),l&&c.getCenter(l)),0;let u=1/0;for(let h=0;h<3;h++){let f;const d=t[h],y=r[d];this.closestPointToPoint(y,o),f=y.distanceToSquared(o),f<u&&(u=f,a&&a.copy(o),l&&l.copy(y));const g=this[d];r.closestPointToPoint(g,o),f=g.distanceToSquared(o),f<u&&(u=f,a&&a.copy(g),l&&l.copy(o))}for(let h=0;h<3;h++){i.set(this[t[h]],this[t[(h+1)%3]]);for(let y=0;y<3;y++){s.set(r[t[y]],r[t[(y+1)%3]]),Is(i,s,o,e);const m=o.distanceToSquared(e);m<u&&(u=m,a&&a.copy(o),l&&l.copy(e))}}return Math.sqrt(u)}}();class Ht{constructor(e,t,i){this.isOrientedBox=!0,this.min=new b.Pq0,this.max=new b.Pq0,this.matrix=new b.kn4,this.invMatrix=new b.kn4,this.points=new Array(8).fill().map(()=>new b.Pq0),this.satAxes=new Array(3).fill().map(()=>new b.Pq0),this.satBounds=new Array(3).fill().map(()=>new ge),this.alignedSatBounds=new Array(3).fill().map(()=>new ge),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}}Ht.prototype.update=function(){return function(){const e=this.matrix,t=this.min,i=this.max,s=this.points;for(let c=0;c<=1;c++)for(let u=0;u<=1;u++)for(let h=0;h<=1;h++){const d=s[1*c|2*u|4*h];d.x=c?i.x:t.x,d.y=u?i.y:t.y,d.z=h?i.z:t.z,d.applyMatrix4(e)}const n=this.satBounds,r=this.satAxes,a=s[0];for(let c=0;c<3;c++){const u=r[c],h=n[c];u.subVectors(a,s[1<<c]),h.setFromPoints(u,s)}const l=this.alignedSatBounds;l[0].setFromPointsField(s,"x"),l[1].setFromPointsField(s,"y"),l[2].setFromPointsField(s,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}(),Ht.prototype.intersectsBox=function(){const o=new ge;return function(t){this.needsUpdate&&this.update();const i=t.min,s=t.max,n=this.satBounds,r=this.satAxes,a=this.alignedSatBounds;if(o.min=i.x,o.max=s.x,a[0].isSeparated(o)||(o.min=i.y,o.max=s.y,a[1].isSeparated(o))||(o.min=i.z,o.max=s.z,a[2].isSeparated(o)))return!1;for(let l=0;l<3;l++){const u=n[l];if(o.setFromBox(r[l],t),u.isSeparated(o))return!1}return!0}}(),Ht.prototype.intersectsTriangle=function(){const o=new re,e=new Array(3),t=new ge,i=new ge,s=new b.Pq0;return function(r){this.needsUpdate&&this.update(),r.isExtendedTriangle?r.needsUpdate&&r.update():(o.copy(r),o.update(),r=o);const a=this.satBounds,l=this.satAxes;e[0]=r.a,e[1]=r.b,e[2]=r.c;for(let f=0;f<3;f++){const d=a[f];if(t.setFromPoints(l[f],e),d.isSeparated(t))return!1}const c=r.satBounds,u=r.satAxes,h=this.points;for(let f=0;f<3;f++){const d=c[f];if(t.setFromPoints(u[f],h),d.isSeparated(t))return!1}for(let f=0;f<3;f++){const d=l[f];for(let y=0;y<4;y++)if(s.crossVectors(d,u[y]),t.setFromPoints(s,e),i.setFromPoints(s,h),t.isSeparated(i))return!1}return!0}}(),Ht.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}}(),Ht.prototype.distanceToPoint=function(){const o=new b.Pq0;return function(t){return this.closestPointToPoint(t,o),t.distanceTo(o)}}(),Ht.prototype.distanceToBox=function(){const o=["x","y","z"],e=new Array(12).fill().map(()=>new b.cZY),t=new Array(12).fill().map(()=>new b.cZY),i=new b.Pq0,s=new b.Pq0;return function(r,a=0,l=null,c=null){if(this.needsUpdate&&this.update(),this.intersectsBox(r))return(l||c)&&(r.getCenter(s),this.closestPointToPoint(s,i),r.closestPointToPoint(i,s),l&&l.copy(i),c&&c.copy(s)),0;const u=a*a,h=r.min,f=r.max,d=this.points;let y=1/0;for(let _=0;_<8;_++){const m=d[_];s.copy(m).clamp(h,f);const x=m.distanceToSquared(s);if(x<y&&(y=x,l&&l.copy(m),c&&c.copy(s),x<u))return Math.sqrt(x)}let g=0;for(let _=0;_<3;_++)for(let m=0;m<=1;m++)for(let x=0;x<=1;x++){const T=(_+1)%3,E=(_+2)%3;e[g].set(d[m<<T|x<<E],d[1<<_|m<<T|x<<E]);const D=o[_],Z=o[T],A=o[E],F=t[g],v=F.start,R=F.end;v[D]=h[D],v[Z]=m?h[Z]:f[Z],v[A]=x?h[A]:f[Z],R[D]=f[D],R[Z]=m?h[Z]:f[Z],R[A]=x?h[A]:f[Z],g++}for(let _=0;_<=1;_++)for(let m=0;m<=1;m++)for(let x=0;x<=1;x++){s.x=_?f.x:h.x,s.y=m?f.y:h.y,s.z=x?f.z:h.z,this.closestPointToPoint(s,i);const T=s.distanceToSquared(i);if(T<y&&(y=T,l&&l.copy(i),c&&c.copy(s),T<u))return Math.sqrt(T)}for(let _=0;_<12;_++){const m=e[_];for(let x=0;x<12;x++){Is(m,t[x],i,s);const E=i.distanceToSquared(s);if(E<y&&(y=E,l&&l.copy(i),c&&c.copy(s),E<u))return Math.sqrt(E)}}return Math.sqrt(y)}}();class ks{constructor(e){this._getNewPrimitive=e,this._primitives=[]}getPrimitive(){const e=this._primitives;return 0===e.length?this._getNewPrimitive():e.pop()}releasePrimitive(e){this._primitives.push(e)}}class hl extends ks{constructor(){super(()=>new re)}}const Kt=new hl;function Xt(o,e){return 65535===e[o+15]}function Qt(o,e){return e[o+6]}function Jt(o,e){return e[o+14]}function te(o){return o+8}function ee(o,e){return e[o+6]}function hr(o,e){return e[o+7]}const At=new class dl{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,0!==e.length&&this.setBuffer(e.pop())}}};let xe,Le;const Ve=[],Vi=new ks(()=>new b.NRn);function fl(o,e,t,i,s,n){xe=Vi.getPrimitive(),Le=Vi.getPrimitive(),Ve.push(xe,Le),At.setBuffer(o._roots[e]);const r=zs(0,o.geometry,t,i,s,n);At.clearBuffer(),Vi.releasePrimitive(xe),Vi.releasePrimitive(Le),Ve.pop(),Ve.pop();const a=Ve.length;return a>0&&(Le=Ve[a-1],xe=Ve[a-2]),r}function zs(o,e,t,i,s=null,n=0,r=0){const{float32Array:a,uint16Array:l,uint32Array:c}=At;let u=2*o;if(Xt(u,l)){const f=Qt(o,c),d=Jt(u,l);return It(o,a,xe),i(f,d,!1,r,n+o,xe)}{let f=function(A){const{uint16Array:F,uint32Array:v}=At;let R=2*A;for(;!Xt(R,F);)R=2*(A=te(A));return Qt(A,v)},d=function(A){const{uint16Array:F,uint32Array:v}=At;let R=2*A;for(;!Xt(R,F);)R=2*(A=ee(A,v));return Qt(A,v)+Jt(R,F)};const y=te(o),g=ee(o,c);let x,T,E,P,_=y,m=g;if(s&&(E=xe,P=Le,It(_,a,E),It(m,a,P),x=s(E),T=s(P),T<x)){_=g,m=y;const A=x;x=T,T=A,E=P}E||(E=xe,It(_,a,E));const M=t(E,Xt(2*_,l),x,r+1,n+_);let z;if(2===M){const A=f(_);z=i(A,d(_)-A,!0,r+1,n+_,E)}else z=M&&zs(_,e,t,i,s,n,r+1);if(z)return!0;P=Le,It(m,a,P);const D=t(P,Xt(2*m,l),T,r+1,n+m);let Z;if(2===D){const A=f(m);Z=i(A,d(m)-A,!0,r+1,n+m,P)}else Z=D&&zs(m,e,t,i,s,n,r+1);return!!Z}}const ui=new b.Pq0,Fs=new b.Pq0,Ue=new b.Pq0,$e=new b.Pq0,je=new b.Pq0,Ui=new b.I9Y,$i=new b.I9Y,ji=new b.I9Y,dr=new b.Pq0,fr=new b.Pq0,pr=new b.Pq0,Hi=new b.Pq0;function Yi(o,e,t,i,s){const n=3*i;let r=n+0,a=n+1,l=n+2;const c=o.index;o.index&&(r=c.getX(r),a=c.getX(a),l=c.getX(l));const{position:u,normal:h,uv:f,uv1:d}=o.attributes,y=function gl(o,e,t,i,s,n,r,a,l){Ue.fromBufferAttribute(e,n),$e.fromBufferAttribute(e,r),je.fromBufferAttribute(e,a);const c=function ml(o,e,t,i,s,n){let r;return r=n===b.hsX?o.intersectTriangle(i,t,e,!0,s):o.intersectTriangle(e,t,i,n!==b.$EB,s),null===r?null:{distance:o.origin.distanceTo(s),point:s.clone()}}(o,Ue,$e,je,Hi,l);if(c){i&&(Ui.fromBufferAttribute(i,n),$i.fromBufferAttribute(i,r),ji.fromBufferAttribute(i,a),c.uv=b.lMl.getInterpolation(Hi,Ue,$e,je,Ui,$i,ji,new b.I9Y)),s&&(Ui.fromBufferAttribute(s,n),$i.fromBufferAttribute(s,r),ji.fromBufferAttribute(s,a),c.uv1=b.lMl.getInterpolation(Hi,Ue,$e,je,Ui,$i,ji,new b.I9Y)),t&&(dr.fromBufferAttribute(t,n),fr.fromBufferAttribute(t,r),pr.fromBufferAttribute(t,a),c.normal=b.lMl.getInterpolation(Hi,Ue,$e,je,dr,fr,pr,new b.Pq0),c.normal.dot(o.direction)>0&&c.normal.multiplyScalar(-1));const u={a:n,b:r,c:a,normal:new b.Pq0,materialIndex:0};b.lMl.getNormal(Ue,$e,je,u.normal),c.face=u,c.faceIndex=n}return c}(t,u,h,f,d,r,a,l,e);return y?(y.faceIndex=i,s&&s.push(y),y):null}function Dt(o,e,t,i){const s=o.a,n=o.b,r=o.c;let a=e,l=e+1,c=e+2;t&&(a=t.getX(a),l=t.getX(l),c=t.getX(c)),s.x=i.getX(a),s.y=i.getY(a),s.z=i.getZ(a),n.x=i.getX(l),n.y=i.getY(l),n.z=i.getZ(l),r.x=i.getX(c),r.y=i.getY(c),r.z=i.getZ(c)}function vl(o,e,t,i,s,n,r){const{geometry:a}=t,{index:l}=a,c=a.attributes.position;for(let u=o,h=e+o;u<h;u++){let f;if(f=u,Dt(r,3*f,l,c),r.needsUpdate=!0,i(r,f,s,n))return!0}return!1}function bl(o,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=o.geometry,i=t.index?t.index.array:null,s=t.attributes.position;let n,r,a,l,c=0;const u=o._roots;for(let f=0,d=u.length;f<d;f++)n=u[f],r=new Uint32Array(n),a=new Uint16Array(n),l=new Float32Array(n),h(0,c),c+=n.byteLength;function h(f,d,y=!1){const g=2*f;if(a[g+15]===Ni){const m=r[f+6];let T=1/0,E=1/0,P=1/0,I=-1/0,M=-1/0,z=-1/0;for(let O=3*m,D=3*(m+a[g+14]);O<D;O++){let Z=i[O];const A=s.getX(Z),F=s.getY(Z),v=s.getZ(Z);A<T&&(T=A),A>I&&(I=A),F<E&&(E=F),F>M&&(M=F),v<P&&(P=v),v>z&&(z=v)}return(l[f+0]!==T||l[f+1]!==E||l[f+2]!==P||l[f+3]!==I||l[f+4]!==M||l[f+5]!==z)&&(l[f+0]=T,l[f+1]=E,l[f+2]=P,l[f+3]=I,l[f+4]=M,l[f+5]=z,!0)}{const m=f+8,x=r[f+6],E=x+d;let P=y,I=!1,M=!1;e?P||(I=e.has(m+d),M=e.has(E),P=!I&&!M):(I=!0,M=!0);const O=P||M;let D=!1;(P||I)&&(D=h(m,d,P));let Z=!1;O&&(Z=h(x,d,P));const A=D||Z;if(A)for(let F=0;F<3;F++){const v=m+F,R=x+F,Q=l[v],j=l[v+3],rt=l[R],Y=l[R+3];l[f+F]=Q<rt?Q:rt,l[f+F+3]=j>Y?j:Y}return A}}}const mr=new b.NRn;function Ce(o,e,t,i){return It(o,e,mr),t.intersectBox(mr,i)}function Cl(o,e,t,i,s,n,r){const{geometry:a}=t,{index:l}=a,c=a.attributes.position;for(let u=o,h=e+o;u<h;u++){let f;if(f=t.resolveTriangleIndex(u),Dt(r,3*f,l,c),r.needsUpdate=!0,i(r,f,s,n))return!0}return!1}const gr=new b.Pq0;function El(o,e,t,i,s){At.setBuffer(o._roots[e]),Ds(0,o,t,i,s),At.clearBuffer()}function Ds(o,e,t,i,s){const{float32Array:n,uint16Array:r,uint32Array:a}=At,l=2*o;if(Xt(l,r))!function _l(o,e,t,i,s,n){const{geometry:r}=o;for(let l=i,c=i+s;l<c;l++)Yi(r,e,t,l,n)}(e,t,i,Qt(o,a),Jt(l,r),s);else{const u=te(o);Ce(u,n,i,gr)&&Ds(u,e,t,i,s);const h=ee(o,a);Ce(h,n,i,gr)&&Ds(h,e,t,i,s)}}const _r=new b.Pq0,Tl=["x","y","z"];function Pl(o,e,t,i){At.setBuffer(o._roots[e]);const s=Ns(0,o,t,i);return At.clearBuffer(),s}function Ns(o,e,t,i){const{float32Array:s,uint16Array:n,uint32Array:r}=At;let a=2*o;if(Xt(a,n))return function yl(o,e,t,i,s){const{geometry:n}=o;let a=1/0,l=null;for(let c=i,u=i+s;c<u;c++){let h;h=Yi(n,e,t,c),h&&h.distance<a&&(l=h,a=h.distance)}return l}(e,t,i,Qt(o,r),Jt(a,n));{const c=hr(o,r),u=Tl[c],f=i.direction[u]>=0;let d,y;f?(d=te(o),y=ee(o,r)):(d=ee(o,r),y=te(o));const _=Ce(d,s,i,_r)?Ns(d,e,t,i):null;if(_){const T=_.point[u];if(f?T<=s[y+c]:T>=s[y+c+3])return _}const x=Ce(y,s,i,_r)?Ns(y,e,t,i):null;return _&&x?_.distance<=x.distance?_:x:_||x||null}}const Zi=new b.NRn,He=new re,Ye=new re,hi=new b.kn4,yr=new Ht,Wi=new Ht;function Al(o,e,t,i){At.setBuffer(o._roots[e]);const s=Rs(0,o,t,i);return At.clearBuffer(),s}function Rs(o,e,t,i,s=null){const{float32Array:n,uint16Array:r,uint32Array:a}=At;let l=2*o;if(null===s&&(t.boundingBox||t.computeBoundingBox(),yr.set(t.boundingBox.min,t.boundingBox.max,i),s=yr),!Xt(l,r)){const u=o+8,h=a[o+6];return It(u,n,Zi),!!(s.intersectsBox(Zi)&&Rs(u,e,t,i,s)||(It(h,n,Zi),s.intersectsBox(Zi)&&Rs(h,e,t,i,s)))}{const u=e.geometry,h=u.index,f=u.attributes.position,d=t.index,y=t.attributes.position,g=Qt(o,a),_=Jt(l,r);if(hi.copy(i).invert(),t.boundsTree)return It(o,n,Wi),Wi.matrix.copy(hi),Wi.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:x=>Wi.intersectsBox(x),intersectsTriangle:x=>{x.a.applyMatrix4(i),x.b.applyMatrix4(i),x.c.applyMatrix4(i),x.needsUpdate=!0;for(let T=3*g,E=3*(_+g);T<E;T+=3)if(Dt(Ye,T,h,f),Ye.needsUpdate=!0,x.intersectsTriangle(Ye))return!0;return!1}});for(let m=3*g,x=3*(_+g);m<x;m+=3){Dt(He,m,h,f),He.a.applyMatrix4(hi),He.b.applyMatrix4(hi),He.c.applyMatrix4(hi),He.needsUpdate=!0;for(let T=0,E=d.count;T<E;T+=3)if(Dt(Ye,T,d,y),Ye.needsUpdate=!0,He.intersectsTriangle(Ye))return!0}}}const Gi=new b.kn4,Bs=new Ht,di=new Ht,Ml=new b.Pq0,Sl=new b.Pq0,Il=new b.Pq0,Ol=new b.Pq0;function kl(o,e,t,i={},s={},n=0,r=1/0){e.boundingBox||e.computeBoundingBox(),Bs.set(e.boundingBox.min,e.boundingBox.max,t),Bs.needsUpdate=!0;const a=o.geometry,l=a.attributes.position,c=a.index,u=e.attributes.position,h=e.index,f=Kt.getPrimitive(),d=Kt.getPrimitive();let y=Ml,g=Sl,_=null,m=null;s&&(_=Il,m=Ol);let x=1/0,T=null,E=null;return Gi.copy(t).invert(),di.matrix.copy(Gi),o.shapecast({boundsTraverseOrder:P=>Bs.distanceToBox(P),intersectsBounds:(P,I,M)=>M<x&&M<r&&(I&&(di.min.copy(P.min),di.max.copy(P.max),di.needsUpdate=!0),!0),intersectsRange:(P,I)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:z=>di.distanceToBox(z),intersectsBounds:(z,O,D)=>D<x&&D<r,intersectsRange:(z,O)=>{for(let D=z,Z=z+O;D<Z;D++){Dt(d,3*D,h,u),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let A=P,F=P+I;A<F;A++){Dt(f,3*A,c,l),f.needsUpdate=!0;const v=f.distanceToTriangle(d,y,_);if(v<x&&(g.copy(y),m&&m.copy(_),x=v,T=A,E=D),v<n)return!0}}}});for(let z=0,O=Be(e);z<O;z++){Dt(d,3*z,h,u),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let D=P,Z=P+I;D<Z;D++){Dt(f,3*D,c,l),f.needsUpdate=!0;const A=f.distanceToTriangle(d,y,_);if(A<x&&(g.copy(y),m&&m.copy(_),x=A,T=D,E=z),A<n)return!0}}}}),Kt.releasePrimitive(f),Kt.releasePrimitive(d),x===1/0?null:(i.point?i.point.copy(g):i.point=g.clone(),i.distance=x,i.faceIndex=T,s&&(s.point?s.point.copy(m):s.point=m.clone(),s.point.applyMatrix4(Gi),g.applyMatrix4(Gi),s.distance=g.sub(s.point).length(),s.faceIndex=E),i)}function zl(o,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=o.geometry,i=t.index?t.index.array:null,s=t.attributes.position;let n,r,a,l,c=0;const u=o._roots;for(let f=0,d=u.length;f<d;f++)n=u[f],r=new Uint32Array(n),a=new Uint16Array(n),l=new Float32Array(n),h(0,c),c+=n.byteLength;function h(f,d,y=!1){const g=2*f;if(a[g+15]===Ni){const m=r[f+6];let T=1/0,E=1/0,P=1/0,I=-1/0,M=-1/0,z=-1/0;for(let O=m,D=m+a[g+14];O<D;O++){const Z=3*o.resolveTriangleIndex(O);for(let A=0;A<3;A++){let F=Z+A;F=i?i[F]:F;const v=s.getX(F),R=s.getY(F),Q=s.getZ(F);v<T&&(T=v),v>I&&(I=v),R<E&&(E=R),R>M&&(M=R),Q<P&&(P=Q),Q>z&&(z=Q)}}return(l[f+0]!==T||l[f+1]!==E||l[f+2]!==P||l[f+3]!==I||l[f+4]!==M||l[f+5]!==z)&&(l[f+0]=T,l[f+1]=E,l[f+2]=P,l[f+3]=I,l[f+4]=M,l[f+5]=z,!0)}{const m=f+8,x=r[f+6],E=x+d;let P=y,I=!1,M=!1;e?P||(I=e.has(m+d),M=e.has(E),P=!I&&!M):(I=!0,M=!0);const O=P||M;let D=!1;(P||I)&&(D=h(m,d,P));let Z=!1;O&&(Z=h(x,d,P));const A=D||Z;if(A)for(let F=0;F<3;F++){const v=m+F,R=x+F,Q=l[v],j=l[v+3],rt=l[R],Y=l[R+3];l[f+F]=Q<rt?Q:rt,l[f+F+3]=j>Y?j:Y}return A}}}const vr=new b.Pq0;function Fl(o,e,t,i,s){At.setBuffer(o._roots[e]),Ls(0,o,t,i,s),At.clearBuffer()}function Ls(o,e,t,i,s){const{float32Array:n,uint16Array:r,uint32Array:a}=At,l=2*o;if(Xt(l,r))!function wl(o,e,t,i,s,n){const{geometry:r,_indirectBuffer:a}=o;for(let l=i,c=i+s;l<c;l++)Yi(r,e,t,a?a[l]:l,n)}(e,t,i,Qt(o,a),Jt(l,r),s);else{const u=te(o);Ce(u,n,i,vr)&&Ls(u,e,t,i,s);const h=ee(o,a);Ce(h,n,i,vr)&&Ls(h,e,t,i,s)}}const br=new b.Pq0,Dl=["x","y","z"];function Nl(o,e,t,i){At.setBuffer(o._roots[e]);const s=Vs(0,o,t,i);return At.clearBuffer(),s}function Vs(o,e,t,i){const{float32Array:s,uint16Array:n,uint32Array:r}=At;let a=2*o;if(Xt(a,n))return function xl(o,e,t,i,s){const{geometry:n,_indirectBuffer:r}=o;let a=1/0,l=null;for(let c=i,u=i+s;c<u;c++){let h;h=Yi(n,e,t,r?r[c]:c),h&&h.distance<a&&(l=h,a=h.distance)}return l}(e,t,i,Qt(o,r),Jt(a,n));{const c=hr(o,r),u=Dl[c],f=i.direction[u]>=0;let d,y;f?(d=te(o),y=ee(o,r)):(d=ee(o,r),y=te(o));const _=Ce(d,s,i,br)?Vs(d,e,t,i):null;if(_){const T=_.point[u];if(f?T<=s[y+c]:T>=s[y+c+3])return _}const x=Ce(y,s,i,br)?Vs(y,e,t,i):null;return _&&x?_.distance<=x.distance?_:x:_||x||null}}const qi=new b.NRn,Ze=new re,We=new re,fi=new b.kn4,wr=new Ht,Xi=new Ht;function Rl(o,e,t,i){At.setBuffer(o._roots[e]);const s=Us(0,o,t,i);return At.clearBuffer(),s}function Us(o,e,t,i,s=null){const{float32Array:n,uint16Array:r,uint32Array:a}=At;let l=2*o;if(null===s&&(t.boundingBox||t.computeBoundingBox(),wr.set(t.boundingBox.min,t.boundingBox.max,i),s=wr),!Xt(l,r)){const u=o+8,h=a[o+6];return It(u,n,qi),!!(s.intersectsBox(qi)&&Us(u,e,t,i,s)||(It(h,n,qi),s.intersectsBox(qi)&&Us(h,e,t,i,s)))}{const u=e.geometry,h=u.index,f=u.attributes.position,d=t.index,y=t.attributes.position,g=Qt(o,a),_=Jt(l,r);if(fi.copy(i).invert(),t.boundsTree)return It(o,n,Xi),Xi.matrix.copy(fi),Xi.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:x=>Xi.intersectsBox(x),intersectsTriangle:x=>{x.a.applyMatrix4(i),x.b.applyMatrix4(i),x.c.applyMatrix4(i),x.needsUpdate=!0;for(let T=g,E=_+g;T<E;T++)if(Dt(We,3*e.resolveTriangleIndex(T),h,f),We.needsUpdate=!0,x.intersectsTriangle(We))return!0;return!1}});for(let m=g,x=_+g;m<x;m++){const T=e.resolveTriangleIndex(m);Dt(Ze,3*T,h,f),Ze.a.applyMatrix4(fi),Ze.b.applyMatrix4(fi),Ze.c.applyMatrix4(fi),Ze.needsUpdate=!0;for(let E=0,P=d.count;E<P;E+=3)if(Dt(We,E,d,y),We.needsUpdate=!0,Ze.intersectsTriangle(We))return!0}}}const Qi=new b.kn4,$s=new Ht,pi=new Ht,Bl=new b.Pq0,Ll=new b.Pq0,Vl=new b.Pq0,Ul=new b.Pq0;function $l(o,e,t,i={},s={},n=0,r=1/0){e.boundingBox||e.computeBoundingBox(),$s.set(e.boundingBox.min,e.boundingBox.max,t),$s.needsUpdate=!0;const a=o.geometry,l=a.attributes.position,c=a.index,u=e.attributes.position,h=e.index,f=Kt.getPrimitive(),d=Kt.getPrimitive();let y=Bl,g=Ll,_=null,m=null;s&&(_=Vl,m=Ul);let x=1/0,T=null,E=null;return Qi.copy(t).invert(),pi.matrix.copy(Qi),o.shapecast({boundsTraverseOrder:P=>$s.distanceToBox(P),intersectsBounds:(P,I,M)=>M<x&&M<r&&(I&&(pi.min.copy(P.min),pi.max.copy(P.max),pi.needsUpdate=!0),!0),intersectsRange:(P,I)=>{if(e.boundsTree){const M=e.boundsTree;return M.shapecast({boundsTraverseOrder:z=>pi.distanceToBox(z),intersectsBounds:(z,O,D)=>D<x&&D<r,intersectsRange:(z,O)=>{for(let D=z,Z=z+O;D<Z;D++){const A=M.resolveTriangleIndex(D);Dt(d,3*A,h,u),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let F=P,v=P+I;F<v;F++){const R=o.resolveTriangleIndex(F);Dt(f,3*R,c,l),f.needsUpdate=!0;const Q=f.distanceToTriangle(d,y,_);if(Q<x&&(g.copy(y),m&&m.copy(_),x=Q,T=F,E=D),Q<n)return!0}}}})}for(let z=0,O=Be(e);z<O;z++){Dt(d,3*z,h,u),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let D=P,Z=P+I;D<Z;D++){const A=o.resolveTriangleIndex(D);Dt(f,3*A,c,l),f.needsUpdate=!0;const F=f.distanceToTriangle(d,y,_);if(F<x&&(g.copy(y),m&&m.copy(_),x=F,T=D,E=z),F<n)return!0}}}}),Kt.releasePrimitive(f),Kt.releasePrimitive(d),x===1/0?null:(i.point?i.point.copy(g):i.point=g.clone(),i.distance=x,i.faceIndex=T,s&&(s.point?s.point.copy(m):s.point=m.clone(),s.point.applyMatrix4(Qi),g.applyMatrix4(Qi),s.distance=g.sub(s.point).length(),s.faceIndex=E),i)}const mi=new At.constructor,Ki=new At.constructor,Ee=new ks(()=>new b.NRn),Ge=new b.NRn,qe=new b.NRn,js=new b.NRn,Hs=new b.NRn;let Ys=!1;function oe(o,e,t,i,s,n=0,r=0,a=0,l=0,c=null,u=!1){let h,f;u?(h=Ki,f=mi):(h=mi,f=Ki);const d=h.float32Array,y=h.uint32Array,g=h.uint16Array,_=f.float32Array,m=f.uint32Array,x=f.uint16Array,E=2*e,P=Xt(2*o,g),I=Xt(E,x);let M=!1;if(I&&P)M=u?s(Qt(e,m),Jt(2*e,x),Qt(o,y),Jt(2*o,g),l,r+e,a,n+o):s(Qt(o,y),Jt(2*o,g),Qt(e,m),Jt(2*e,x),a,n+o,l,r+e);else if(I){const z=Ee.getPrimitive();It(e,_,z),z.applyMatrix4(t);const O=te(o),D=ee(o,y);It(O,d,Ge),It(D,d,qe);const Z=z.intersectsBox(Ge),A=z.intersectsBox(qe);M=Z&&oe(e,O,i,t,s,r,n,l,a+1,z,!u)||A&&oe(e,D,i,t,s,r,n,l,a+1,z,!u),Ee.releasePrimitive(z)}else{const z=te(e),O=ee(e,m);It(z,_,js),It(O,_,Hs);const D=c.intersectsBox(js),Z=c.intersectsBox(Hs);if(D&&Z)M=oe(o,z,t,i,s,n,r,a,l+1,c,u)||oe(o,O,t,i,s,n,r,a,l+1,c,u);else if(D)if(P)M=oe(o,z,t,i,s,n,r,a,l+1,c,u);else{const A=Ee.getPrimitive();A.copy(js).applyMatrix4(t);const F=te(o),v=ee(o,y);It(F,d,Ge),It(v,d,qe);const R=A.intersectsBox(Ge),Q=A.intersectsBox(qe);M=R&&oe(z,F,i,t,s,r,n,l,a+1,A,!u)||Q&&oe(z,v,i,t,s,r,n,l,a+1,A,!u),Ee.releasePrimitive(A)}else if(Z)if(P)M=oe(o,O,t,i,s,n,r,a,l+1,c,u);else{const A=Ee.getPrimitive();A.copy(Hs).applyMatrix4(t);const F=te(o),v=ee(o,y);It(F,d,Ge),It(v,d,qe);const R=A.intersectsBox(Ge),Q=A.intersectsBox(qe);M=R&&oe(O,F,i,t,s,r,n,l,a+1,A,!u)||Q&&oe(O,v,i,t,s,r,n,l,a+1,A,!u),Ee.releasePrimitive(A)}}return M}const Ji=new Ht,xr=new b.NRn;class Zs{static serialize(e,t={}){t={cloneBuffers:!0,...t};const s=e._roots,n=e._indirectBuffer,r=e.geometry.getIndex();let a;return a=t.cloneBuffers?{roots:s.map(l=>l.slice()),index:r.array.slice(),indirectBuffer:n?n.slice():null}:{roots:s,index:r.array,indirectBuffer:n},a}static deserialize(e,t,i={}){i={setIndex:!0,indirect:!!e.indirectBuffer,...i};const{index:s,roots:n,indirectBuffer:r}=e,a=new Zs(t,{...i,[Ms]:!0});if(a._roots=n,a._indirectBuffer=r||null,i.setIndex){const l=t.getIndex();if(null===l){const c=new b.THS(e.index,1,!1);t.setIndex(c)}else l.array!==s&&(l.array.set(s),l.needsUpdate=!0)}return a}get indirect(){return!!this._indirectBuffer}constructor(e,t={}){if(!e.isBufferGeometry)throw new Error("MeshBVH: Only BufferGeometries are supported.");if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.");if((t=Object.assign({strategy:0,maxDepth:40,maxLeafTris:10,verbose:!0,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,[Ms]:!1},t)).useSharedArrayBuffer&&!function jl(){return typeof SharedArrayBuffer<"u"}())throw new Error("MeshBVH: SharedArrayBuffer is not available.");this.geometry=e,this._roots=null,this._indirectBuffer=null,t[Ms]||(al(this,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new b.NRn)));const{_indirectBuffer:i}=this;this.resolveTriangleIndex=t.indirect?s=>i[s]:s=>s}refit(e=null){return(this.indirect?zl:bl)(this,e)}traverse(e,t=0){const i=this._roots[t],s=new Uint32Array(i),n=new Uint16Array(i);!function r(a,l=0){const c=2*a,u=n[c+15]===Ni;if(u){const h=s[a+6],f=n[c+14];e(l,u,new Float32Array(i,4*a,6),h,f)}else{const h=a+8,f=s[a+6],d=s[a+7];e(l,u,new Float32Array(i,4*a,6),d)||(r(h,l+1),r(f,l+1))}}(0)}raycast(e,t=b.hB5){const i=this._roots,s=this.geometry,n=[],r=t.isMaterial,a=Array.isArray(t),l=s.groups,c=r?t.side:t,u=this.indirect?Fl:El;for(let h=0,f=i.length;h<f;h++){const y=n.length;if(u(this,h,a?t[l[h].materialIndex].side:c,e,n),a){const g=l[h].materialIndex;for(let _=y,m=n.length;_<m;_++)n[_].face.materialIndex=g}}return n}raycastFirst(e,t=b.hB5){const i=this._roots,s=this.geometry,n=t.isMaterial,r=Array.isArray(t);let a=null;const l=s.groups,c=n?t.side:t,u=this.indirect?Nl:Pl;for(let h=0,f=i.length;h<f;h++){const y=u(this,h,r?t[l[h].materialIndex].side:c,e);null!=y&&(null==a||y.distance<a.distance)&&(a=y,r&&(y.face.materialIndex=l[h].materialIndex))}return a}intersectsGeometry(e,t){let i=!1;const n=this.indirect?Rl:Al;for(let r=0,a=this._roots.length;r<a&&(i=n(this,r,e,t),!i);r++);return i}shapecast(e){const t=Kt.getPrimitive(),i=this.indirect?Cl:vl;let{boundsTraverseOrder:s,intersectsBounds:n,intersectsRange:r,intersectsTriangle:a}=e;if(r&&a){const h=r;r=(f,d,y,g,_)=>!!h(f,d,y,g,_)||i(f,d,this,a,y,g,t)}else r||(r=a?(h,f,d,y)=>i(h,f,this,a,d,y,t):(h,f,d)=>d);let l=!1,c=0;const u=this._roots;for(let h=0,f=u.length;h<f;h++){const d=u[h];if(l=fl(this,h,n,r,s,c),l)break;c+=d.byteLength}return Kt.releasePrimitive(t),l}bvhcast(e,t,i){let{intersectsRanges:s,intersectsTriangles:n}=i;const r=Kt.getPrimitive(),a=this.geometry.index,l=this.geometry.attributes.position,c=this.indirect?y=>{const g=this.resolveTriangleIndex(y);Dt(r,3*g,a,l)}:y=>{Dt(r,3*y,a,l)},u=Kt.getPrimitive(),h=e.geometry.index,f=e.geometry.attributes.position,d=e.indirect?y=>{const g=e.resolveTriangleIndex(y);Dt(u,3*g,h,f)}:y=>{Dt(u,3*y,h,f)};if(n){const y=(g,_,m,x,T,E,P,I)=>{for(let M=m,z=m+x;M<z;M++){d(M),u.a.applyMatrix4(t),u.b.applyMatrix4(t),u.c.applyMatrix4(t),u.needsUpdate=!0;for(let O=g,D=g+_;O<D;O++)if(c(O),r.needsUpdate=!0,n(r,u,O,M,T,E,P,I))return!0}return!1};if(s){const g=s;s=function(_,m,x,T,E,P,I,M){return!!g(_,m,x,T,E,P,I,M)||y(_,m,x,T,E,P,I,M)}}else s=y}return function Hl(o,e,t,i){if(Ys)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");Ys=!0;const s=o._roots,n=e._roots;let r,a=0,l=0;const c=(new b.kn4).copy(t).invert();for(let u=0,h=s.length;u<h;u++){mi.setBuffer(s[u]),l=0;const f=Ee.getPrimitive();It(0,mi.float32Array,f),f.applyMatrix4(c);for(let d=0,y=n.length;d<y&&(Ki.setBuffer(n[u]),r=oe(0,0,t,c,i,a,l,0,0,f),Ki.clearBuffer(),l+=n[d].length,!r);d++);if(Ee.releasePrimitive(f),mi.clearBuffer(),a+=s[u].length,r)break}return Ys=!1,r}(this,e,t,s)}intersectsBox(e,t){return Ji.set(e.min,e.max,t),Ji.needsUpdate=!0,this.shapecast({intersectsBounds:i=>Ji.intersectsBox(i),intersectsTriangle:i=>Ji.intersectsTriangle(i)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,i={},s={},n=0,r=1/0){return(this.indirect?$l:kl)(this,e,t,i,s,n,r)}closestPointToPoint(e,t={},i=0,s=1/0){return function pl(o,e,t={},i=0,s=1/0){const n=i*i,r=s*s;let a=1/0,l=null;if(o.shapecast({boundsTraverseOrder:u=>(ui.copy(e).clamp(u.min,u.max),ui.distanceToSquared(e)),intersectsBounds:(u,h,f)=>f<a&&f<r,intersectsTriangle:(u,h)=>{u.closestPointToPoint(e,ui);const f=e.distanceToSquared(ui);return f<a&&(Fs.copy(ui),a=f,l=h),f<n}}),a===1/0)return null;const c=Math.sqrt(a);return t.point?t.point.copy(Fs):t.point=Fs.clone(),t.distance=c,t.faceIndex=l,t}(this,e,t,i,s)}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(i=>{It(0,new Float32Array(i),xr),e.union(xr)}),e}}function Cr(o,e,t){return null===o||(o.point.applyMatrix4(e.matrixWorld),o.distance=o.point.distanceTo(t.ray.origin),o.object=e,o.distance<t.near||o.distance>t.far)?null:o}const Ws=new b.RlV,Er=new b.kn4,Yl=b.eaF.prototype.raycast;function Zl(o,e){if(this.geometry.boundsTree){if(void 0===this.material)return;Er.copy(this.matrixWorld).invert(),Ws.copy(o.ray).applyMatrix4(Er);const t=this.geometry.boundsTree;if(!0===o.firstHitOnly){const i=Cr(t.raycastFirst(Ws,this.material),this,o);i&&e.push(i)}else{const i=t.raycast(Ws,this.material);for(let s=0,n=i.length;s<n;s++){const r=Cr(i[s],this,o);r&&e.push(r)}}}else Yl.call(this,o,e)}function Wl(o){return this.boundsTree=new Zs(this,o),this.boundsTree}function Gl(){this.boundsTree=null}const Tr=class Co{constructor(){w(this,"onDisposed",new X),w(this,"list",new dt.jp),w(this,"enabled",!1),w(this,"_clock"),w(this,"onInit",new X),w(this,"update",()=>{if(!this.enabled)return;const e=this._clock.getDelta();for(const[t,i]of this.list)i.enabled&&i.isUpdateable()&&i.update(e);requestAnimationFrame(this.update)}),this._clock=new b.zD7,Co.setupBVH()}add(e,t){if(this.list.has(e))throw new Error("You're trying to add a component that already exists in the components instance. Use Components.get() instead.");Wt.validate(e),this.list.set(e,t)}get(e){var t;const i=e.uuid;if(!this.list.has(i)){const s=new e(this);return null!=(t=s.isDisposeable)&&t.call(s)&&s.onDisposed.add(()=>this.list.delete(i)),this.list.has(i)||this.add(i,s),s}return this.list.get(i)}init(){this.enabled=!0;for(const[e,t]of this.list.entries())t.enabled=!0;this._clock.start(),this.update(),this.onInit.trigger()}dispose(){let e;this.enabled=!1;for(const[t,i]of this.list)i.enabled=!1,t!==ut.uuid?i.isDisposeable()&&i.dispose():e=i;e?.dispose(),this._clock.stop(),this.onDisposed.trigger()}static setupBVH(){b.LoY.prototype.computeBoundsTree=Wl,b.LoY.prototype.disposeBoundsTree=Gl,b.eaF.prototype.raycast=Zl}};w(Tr,"release","2.4.3");let Gs=Tr;class ql{constructor(e){w(this,"enabled",!1),w(this,"id","FirstPerson"),this.camera=e}set(e){if(this.enabled=e,e){if("Perspective"!==this.camera.projection.current)return void this.camera.set("Orbit");this.setupFirstPersonCamera()}}setupFirstPersonCamera(){const e=this.camera.controls,t=new b.Pq0;e.distance--,e.getPosition(t),e.minDistance=1,e.maxDistance=1,e.distance=1,e.moveTo(t.x,t.y,t.z),e.truckSpeed=50,e.mouseButtons.wheel=Vt.ACTION.DOLLY,e.touches.two=Vt.ACTION.TOUCH_ZOOM_TRUCK}}class Xl{constructor(e){w(this,"enabled",!0),w(this,"id","Orbit"),this.camera=e,this.activateOrbitControls()}set(e){this.enabled=e,e&&this.activateOrbitControls()}activateOrbitControls(){const e=this.camera.controls;e.minDistance=1,e.maxDistance=300;const t=new b.Pq0;e.getPosition(t);const i=t.length();e.distance=i,e.truckSpeed=2;const{rotation:s}=this.camera.three,n=new b.Pq0(0,0,-1).applyEuler(s),r=t.addScaledVector(n,i);e.moveTo(r.x,r.y,r.z)}}class Ql{constructor(e){w(this,"enabled",!1),w(this,"id","Plan"),w(this,"mouseAction1"),w(this,"mouseAction2"),w(this,"mouseInitialized",!1),w(this,"defaultAzimuthSpeed"),w(this,"defaultPolarSpeed"),this.camera=e,this.defaultAzimuthSpeed=e.controls.azimuthRotateSpeed,this.defaultPolarSpeed=e.controls.polarRotateSpeed}set(e){this.enabled=e;const t=this.camera.controls;t.azimuthRotateSpeed=e?0:this.defaultAzimuthSpeed,t.polarRotateSpeed=e?0:this.defaultPolarSpeed,this.mouseInitialized||(this.mouseAction1=t.touches.one,this.mouseAction2=t.touches.two,this.mouseInitialized=!0),e?(t.mouseButtons.left=Vt.ACTION.TRUCK,t.touches.one=Vt.ACTION.TOUCH_TRUCK,t.touches.two=Vt.ACTION.TOUCH_ZOOM):(t.mouseButtons.left=Vt.ACTION.ROTATE,t.touches.one=this.mouseAction1,t.touches.two=this.mouseAction2)}}class Kl{constructor(e){w(this,"onChanged",new X),w(this,"current","Perspective"),w(this,"camera"),w(this,"matchOrthoDistanceEnabled",!1),w(this,"_component"),w(this,"_previousDistance",-1),this._component=e,this.camera=e.three}set(e){var t=this;return(0,H.A)(function*(){t.current!==e&&("Orthographic"===e?t.setOrthoCamera():yield t.setPerspectiveCamera(),t.onChanged.trigger(t.camera))})()}toggle(){var e=this;return(0,H.A)(function*(){const i="Perspective"===e.current?"Orthographic":"Perspective";yield e.set(i)})()}setOrthoCamera(){if(null===this._component.mode||"FirstPerson"===this._component.mode.id)return;this._previousDistance=this._component.controls.distance,this._component.controls.distance=200;const e=this.getPerspectiveDims();if(!e)return;const{width:t,height:i}=e;this.setupOrthoCamera(i,t),this.camera=this._component.threeOrtho,this.current="Orthographic"}getPerspectiveDims(){const e=this._component.currentWorld;if(!e||!e.renderer)return null;const t=new b.Pq0;this._component.threePersp.getWorldDirection(t);const i=new b.Pq0;this._component.controls.getTarget(i);const n=i.clone().sub(this._component.threePersp.position).dot(t),r=e.renderer.getSize(),a=r.x/r.y,c=2*n*Math.atan(this._component.threePersp.fov*(Math.PI/180)/2);return{width:c*a,height:c}}setupOrthoCamera(e,t){this._component.controls.mouseButtons.wheel=Vt.ACTION.ZOOM,this._component.controls.mouseButtons.middle=Vt.ACTION.ZOOM;const i=this._component.threePersp,s=this._component.threeOrtho;s.zoom=1,s.left=t/-2,s.right=t/2,s.top=e/2,s.bottom=e/-2,s.updateProjectionMatrix(),s.position.copy(i.position),s.quaternion.copy(i.quaternion),this._component.controls.camera=s}getDistance(){const t=this._component.threeOrtho;return(t.top-t.bottom)/t.zoom/(2*Math.atan(this._component.threePersp.fov*(Math.PI/180)/2))}setPerspectiveCamera(){var e=this;return(0,H.A)(function*(){e._component.controls.mouseButtons.wheel=Vt.ACTION.DOLLY,e._component.controls.mouseButtons.middle=Vt.ACTION.DOLLY;const t=e._component.threePersp,i=e._component.threeOrtho;t.position.copy(i.position),t.quaternion.copy(i.quaternion),e._component.controls.mouseButtons.wheel=Vt.ACTION.DOLLY,e._component.controls.distance=e.matchOrthoDistanceEnabled?e.getDistance():e._previousDistance,yield e._component.controls.zoomTo(1),t.updateProjectionMatrix(),e._component.controls.camera=t,e.camera=t,e.current="Perspective"})()}}class qs extends li{constructor(e){super(e),w(this,"projection"),w(this,"threeOrtho"),w(this,"threePersp"),w(this,"_userInputButtons",{}),w(this,"_frustumSize",50),w(this,"_navigationModes",new Map),w(this,"_mode",null),w(this,"previousSize",null),this.threePersp=this.three,this.threeOrtho=this.newOrthoCamera(),this.projection=new Kl(this),this.onAspectUpdated.add(()=>{this.setOrthoPerspCameraAspect()}),this.projection.onChanged.add(t=>{this.three=t,this.updateAspect()}),this.worlds.onItemSet.add(()=>{this._navigationModes.clear(),this._navigationModes.set("Orbit",new Xl(this)),this._navigationModes.set("FirstPerson",new ql(this)),this._navigationModes.set("Plan",new Ql(this)),this._mode=this._navigationModes.get("Orbit"),this.mode.set(!0,{preventTargetAdjustment:!0}),this.currentWorld&&this.currentWorld.renderer&&(this.previousSize=this.currentWorld.renderer.getSize().clone())}),this.worlds.onItemDeleted.add(()=>{this._navigationModes.clear()})}get mode(){if(!this._mode)throw new Error("Mode not found, camera not initialized");return this._mode}dispose(){super.dispose(),this.threeOrtho.removeFromParent()}set(e){if(null!==this.mode&&this.mode.id!==e){if(this.mode.set(!1),!this._navigationModes.has(e))throw new Error("The specified mode does not exist!");this._mode=this._navigationModes.get(e),this.mode.set(!0)}}fit(e){var t=this;return(0,H.A)(function*(i,s=1.5){if(!t.enabled)return;const n=Number.MAX_VALUE,r=Number.MIN_VALUE,a=new b.Pq0(n,n,n),l=new b.Pq0(r,r,r);for(const g of i){const _=(new b.NRn).setFromObject(g);_.min.x<a.x&&(a.x=_.min.x),_.min.y<a.y&&(a.y=_.min.y),_.min.z<a.z&&(a.z=_.min.z),_.max.x>l.x&&(l.x=_.max.x),_.max.y>l.y&&(l.y=_.max.y),_.max.z>l.z&&(l.z=_.max.z)}const c=new b.NRn(a,l),u=t.components.get(ut);if(u.initialized)for(const[,g]of u.list){const _=g.box;_.min.x<a.x&&(a.x=_.min.x),_.min.y<a.y&&(a.y=_.min.y),_.min.z<a.z&&(a.z=_.min.z),_.max.x>l.x&&(l.x=_.max.x),_.max.y>l.y&&(l.y=_.max.y),_.max.z>l.z&&(l.z=_.max.z)}const h=new b.Pq0;c.getSize(h);const f=new b.Pq0;c.getCenter(f);const d=Math.max(h.x,h.y,h.z)*s,y=new b.iyt(f,d);yield t.controls.fitToSphere(y,!0)}).apply(this,arguments)}setUserInput(e){e?this.enableUserInput():this.disableUserInput()}addCustomNavigationMode(e){this._navigationModes.set(e.id,e)}disableUserInput(){this._userInputButtons.left=this.controls.mouseButtons.left,this._userInputButtons.right=this.controls.mouseButtons.right,this._userInputButtons.middle=this.controls.mouseButtons.middle,this._userInputButtons.wheel=this.controls.mouseButtons.wheel,this.controls.mouseButtons.left=0,this.controls.mouseButtons.right=0,this.controls.mouseButtons.middle=0,this.controls.mouseButtons.wheel=0}enableUserInput(){0!==Object.keys(this._userInputButtons).length&&(this.controls.mouseButtons.left=this._userInputButtons.left,this.controls.mouseButtons.right=this._userInputButtons.right,this.controls.mouseButtons.middle=this._userInputButtons.middle,this.controls.mouseButtons.wheel=this._userInputButtons.wheel)}newOrthoCamera(){const e=window.innerWidth/window.innerHeight;return new b.qUd(this._frustumSize*e/-2,this._frustumSize*e/2,this._frustumSize/2,this._frustumSize/-2,.1,1e3)}setOrthoPerspCameraAspect(){if(!this.currentWorld||!this.currentWorld.renderer||!this.previousSize)return;const e=this.currentWorld.renderer.getSize(),r=this.threeOrtho.top*(e.y/this.previousSize.y),a=this.threeOrtho.right*(e.x/this.previousSize.x);this.threeOrtho.left=-a,this.threeOrtho.right=a,this.threeOrtho.top=r,this.threeOrtho.bottom=-r,this.threeOrtho.updateProjectionMatrix(),this.previousSize.copy(e)}}var ts=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Jl(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}function es(o){throw new Error('Could not dynamically require "'+o+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Pr={exports:{}};Pr.exports=function t(i,s,n){function r(c,u){if(!s[c]){if(!i[c]){if(!u&&es)return es(c);if(a)return a(c,!0);var f=new Error("Cannot find module '"+c+"'");throw f.code="MODULE_NOT_FOUND",f}var d=s[c]={exports:{}};i[c][0].call(d.exports,function(y){return r(i[c][1][y]||y)},d,d.exports,t,i,s,n)}return s[c].exports}for(var a=es,l=0;l<n.length;l++)r(n[l]);return r}({1:[function(t,i,s){var n=t("./utils"),r=t("./support"),a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";s.encode=function(l){for(var c,u,h,d,y,g,_=[],m=0,x=l.length,T=x,E="string"!==n.getTypeOf(l);m<l.length;)T=x-m,h=E?(c=l[m++],u=m<x?l[m++]:0,m<x?l[m++]:0):(c=l.charCodeAt(m++),u=m<x?l.charCodeAt(m++):0,m<x?l.charCodeAt(m++):0),d=(3&c)<<4|u>>4,y=1<T?(15&u)<<2|h>>6:64,g=2<T?63&h:64,_.push(a.charAt(c>>2)+a.charAt(d)+a.charAt(y)+a.charAt(g));return _.join("")},s.decode=function(l){var c,u,h,f,d,y,g=0,_=0,m="data:";if(l.substr(0,5)===m)throw new Error("Invalid base64 input, it looks like a data url.");var x,T=3*(l=l.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(l.charAt(l.length-1)===a.charAt(64)&&T--,l.charAt(l.length-2)===a.charAt(64)&&T--,T%1!=0)throw new Error("Invalid base64 input, bad content length.");for(x=r.uint8array?new Uint8Array(0|T):new Array(0|T);g<l.length;)c=a.indexOf(l.charAt(g++))<<2|(f=a.indexOf(l.charAt(g++)))>>4,u=(15&f)<<4|(d=a.indexOf(l.charAt(g++)))>>2,h=(3&d)<<6|(y=a.indexOf(l.charAt(g++))),x[_++]=c,64!==d&&(x[_++]=u),64!==y&&(x[_++]=h);return x}},{"./support":30,"./utils":32}],2:[function(t,i,s){var n=t("./external"),r=t("./stream/DataWorker"),a=t("./stream/Crc32Probe"),l=t("./stream/DataLengthProbe");function c(u,h,f,d,y){this.compressedSize=u,this.uncompressedSize=h,this.crc32=f,this.compression=d,this.compressedContent=y}c.prototype={getContentWorker:function(){var u=new r(n.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new l("data_length")),h=this;return u.on("end",function(){if(this.streamInfo.data_length!==h.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),u},getCompressedWorker:function(){return new r(n.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},c.createWorkerFrom=function(u,h,f){return u.pipe(new a).pipe(new l("uncompressedSize")).pipe(h.compressWorker(f)).pipe(new l("compressedSize")).withStreamInfo("compression",h)},i.exports=c},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(t,i,s){var n=t("./stream/GenericWorker");s.STORE={magic:"\0\0",compressWorker:function(){return new n("STORE compression")},uncompressWorker:function(){return new n("STORE decompression")}},s.DEFLATE=t("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(t,i,s){var n=t("./utils"),r=function(){for(var a,l=[],c=0;c<256;c++){a=c;for(var u=0;u<8;u++)a=1&a?3988292384^a>>>1:a>>>1;l[c]=a}return l}();i.exports=function(a,l){return void 0!==a&&a.length?"string"!==n.getTypeOf(a)?function(c,u,h){var d=r,y=0+h;c^=-1;for(var g=0;g<y;g++)c=c>>>8^d[255&(c^u[g])];return-1^c}(0|l,a,a.length):function(c,u,h){var d=r,y=0+h;c^=-1;for(var g=0;g<y;g++)c=c>>>8^d[255&(c^u.charCodeAt(g))];return-1^c}(0|l,a,a.length):0}},{"./utils":32}],5:[function(t,i,s){s.base64=!1,s.binary=!1,s.dir=!1,s.createFolders=!0,s.date=null,s.compression=null,s.compressionOptions=null,s.comment=null,s.unixPermissions=null,s.dosPermissions=null},{}],6:[function(t,i,s){var n;n=typeof Promise<"u"?Promise:t("lie"),i.exports={Promise:n}},{lie:37}],7:[function(t,i,s){var n=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",r=t("pako"),a=t("./utils"),l=t("./stream/GenericWorker"),c=n?"uint8array":"array";function u(h,f){l.call(this,"FlateWorker/"+h),this._pako=null,this._pakoAction=h,this._pakoOptions=f,this.meta={}}s.magic="\b\0",a.inherits(u,l),u.prototype.processChunk=function(h){this.meta=h.meta,null===this._pako&&this._createPako(),this._pako.push(a.transformTo(c,h.data),!1)},u.prototype.flush=function(){l.prototype.flush.call(this),null===this._pako&&this._createPako(),this._pako.push([],!0)},u.prototype.cleanUp=function(){l.prototype.cleanUp.call(this),this._pako=null},u.prototype._createPako=function(){this._pako=new r[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var h=this;this._pako.onData=function(f){h.push({data:f,meta:h.meta})}},s.compressWorker=function(h){return new u("Deflate",h)},s.uncompressWorker=function(){return new u("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(t,i,s){function n(d,y){var g,_="";for(g=0;g<y;g++)_+=String.fromCharCode(255&d),d>>>=8;return _}function r(d,y,g,_,m,x){var T,E,P=d.file,I=d.compression,M=x!==c.utf8encode,z=a.transformTo("string",x(P.name)),O=a.transformTo("string",c.utf8encode(P.name)),D=P.comment,Z=a.transformTo("string",x(D)),A=a.transformTo("string",c.utf8encode(D)),F=O.length!==P.name.length,v=A.length!==D.length,R="",Q="",j="",rt=P.dir,Y=P.date,ot={crc32:0,compressedSize:0,uncompressedSize:0};y&&!g||(ot.crc32=d.crc32,ot.compressedSize=d.compressedSize,ot.uncompressedSize=d.uncompressedSize);var L=0;y&&(L|=8),M||!F&&!v||(L|=2048);var K,Ot,V=0,st=0;rt&&(V|=16),"UNIX"===m?(st=798,V|=(Ot=K=P.unixPermissions,K||(Ot=rt?16893:33204),(65535&Ot)<<16)):(st=20,V|=function(K){return 63&(K||0)}(P.dosPermissions)),T=Y.getUTCHours(),T<<=6,T|=Y.getUTCMinutes(),T<<=5,T|=Y.getUTCSeconds()/2,E=Y.getUTCFullYear()-1980,E<<=4,E|=Y.getUTCMonth()+1,E<<=5,E|=Y.getUTCDate(),F&&(Q=n(1,1)+n(u(z),4)+O,R+="up"+n(Q.length,2)+Q),v&&(j=n(1,1)+n(u(Z),4)+A,R+="uc"+n(j.length,2)+j);var it="";return it+="\n\0",it+=n(L,2),it+=I.magic,it+=n(T,2),it+=n(E,2),it+=n(ot.crc32,4),it+=n(ot.compressedSize,4),it+=n(ot.uncompressedSize,4),it+=n(z.length,2),it+=n(R.length,2),{fileRecord:h.LOCAL_FILE_HEADER+it+z+R,dirRecord:h.CENTRAL_FILE_HEADER+n(st,2)+it+n(Z.length,2)+"\0\0\0\0"+n(V,4)+n(_,4)+z+R+Z}}var a=t("../utils"),l=t("../stream/GenericWorker"),c=t("../utf8"),u=t("../crc32"),h=t("../signature");function f(d,y,g,_){l.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=y,this.zipPlatform=g,this.encodeFileName=_,this.streamFiles=d,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}a.inherits(f,l),f.prototype.push=function(d){var y=d.meta.percent||0,g=this.entriesCount,_=this._sources.length;this.accumulate?this.contentBuffer.push(d):(this.bytesWritten+=d.data.length,l.prototype.push.call(this,{data:d.data,meta:{currentFile:this.currentFile,percent:g?(y+100*(g-_-1))/g:100}}))},f.prototype.openedSource=function(d){this.currentSourceOffset=this.bytesWritten,this.currentFile=d.file.name;var y=this.streamFiles&&!d.file.dir;if(y){var g=r(d,y,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:g.fileRecord,meta:{percent:0}})}else this.accumulate=!0},f.prototype.closedSource=function(d){this.accumulate=!1;var _,y=this.streamFiles&&!d.file.dir,g=r(d,y,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(g.dirRecord),y)this.push({data:(_=d,h.DATA_DESCRIPTOR+n(_.crc32,4)+n(_.compressedSize,4)+n(_.uncompressedSize,4)),meta:{percent:100}});else for(this.push({data:g.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},f.prototype.flush=function(){for(var d=this.bytesWritten,y=0;y<this.dirRecords.length;y++)this.push({data:this.dirRecords[y],meta:{percent:100}});var m,x,T,I,_=(m=this.dirRecords.length,x=this.bytesWritten-d,T=d,I=a.transformTo("string",(0,this.encodeFileName)(this.zipComment)),h.CENTRAL_DIRECTORY_END+"\0\0\0\0"+n(m,2)+n(m,2)+n(x,4)+n(T,4)+n(I.length,2)+I);this.push({data:_,meta:{percent:100}})},f.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},f.prototype.registerPrevious=function(d){this._sources.push(d);var y=this;return d.on("data",function(g){y.processChunk(g)}),d.on("end",function(){y.closedSource(y.previous.streamInfo),y._sources.length?y.prepareNextSource():y.end()}),d.on("error",function(g){y.error(g)}),this},f.prototype.resume=function(){return!!l.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},f.prototype.error=function(d){var y=this._sources;if(!l.prototype.error.call(this,d))return!1;for(var g=0;g<y.length;g++)try{y[g].error(d)}catch{}return!0},f.prototype.lock=function(){l.prototype.lock.call(this);for(var d=this._sources,y=0;y<d.length;y++)d[y].lock()},i.exports=f},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(t,i,s){var n=t("../compressions"),r=t("./ZipFileWorker");s.generateWorker=function(a,l,c){var u=new r(l.streamFiles,c,l.platform,l.encodeFileName),h=0;try{a.forEach(function(f,d){h++;var y=function(x,T){var E=x||T,P=n[E];if(!P)throw new Error(E+" is not a valid compression method !");return P}(d.options.compression,l.compression),_=d.dir,m=d.date;d._compressWorker(y,d.options.compressionOptions||l.compressionOptions||{}).withStreamInfo("file",{name:f,dir:_,date:m,comment:d.comment||"",unixPermissions:d.unixPermissions,dosPermissions:d.dosPermissions}).pipe(u)}),u.entriesCount=h}catch(f){u.error(f)}return u}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(t,i,s){function n(){if(!(this instanceof n))return new n;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var r=new n;for(var a in this)"function"!=typeof this[a]&&(r[a]=this[a]);return r}}(n.prototype=t("./object")).loadAsync=t("./load"),n.support=t("./support"),n.defaults=t("./defaults"),n.version="3.10.1",n.loadAsync=function(r,a){return(new n).loadAsync(r,a)},n.external=t("./external"),i.exports=n},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(t,i,s){var n=t("./utils"),r=t("./external"),a=t("./utf8"),l=t("./zipEntries"),c=t("./stream/Crc32Probe"),u=t("./nodejsUtils");function h(f){return new r.Promise(function(d,y){var g=f.decompressed.getContentWorker().pipe(new c);g.on("error",function(_){y(_)}).on("end",function(){g.streamInfo.crc32!==f.decompressed.crc32?y(new Error("Corrupted zip : CRC32 mismatch")):d()}).resume()})}i.exports=function(f,d){var y=this;return d=n.extend(d||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:a.utf8decode}),u.isNode&&u.isStream(f)?r.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):n.prepareContent("the loaded zip file",f,!0,d.optimizedBinaryString,d.base64).then(function(g){var _=new l(d);return _.load(g),_}).then(function(g){var _=[r.Promise.resolve(g)],m=g.files;if(d.checkCRC32)for(var x=0;x<m.length;x++)_.push(h(m[x]));return r.Promise.all(_)}).then(function(g){for(var _=g.shift(),m=_.files,x=0;x<m.length;x++){var T=m[x],E=T.fileNameStr,P=n.resolve(T.fileNameStr);y.file(P,T.decompressed,{binary:!0,optimizedBinaryString:!0,date:T.date,dir:T.dir,comment:T.fileCommentStr.length?T.fileCommentStr:null,unixPermissions:T.unixPermissions,dosPermissions:T.dosPermissions,createFolders:d.createFolders}),T.dir||(y.file(P).unsafeOriginalName=E)}return _.zipComment.length&&(y.comment=_.zipComment),y})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(t,i,s){var n=t("../utils"),r=t("../stream/GenericWorker");function a(l,c){r.call(this,"Nodejs stream input adapter for "+l),this._upstreamEnded=!1,this._bindStream(c)}n.inherits(a,r),a.prototype._bindStream=function(l){var c=this;(this._stream=l).pause(),l.on("data",function(u){c.push({data:u,meta:{percent:0}})}).on("error",function(u){c.isPaused?this.generatedError=u:c.error(u)}).on("end",function(){c.isPaused?c._upstreamEnded=!0:c.end()})},a.prototype.pause=function(){return!!r.prototype.pause.call(this)&&(this._stream.pause(),!0)},a.prototype.resume=function(){return!!r.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},i.exports=a},{"../stream/GenericWorker":28,"../utils":32}],13:[function(t,i,s){var n=t("readable-stream").Readable;function r(a,l,c){n.call(this,l),this._helper=a;var u=this;a.on("data",function(h,f){u.push(h)||u._helper.pause(),c&&c(f)}).on("error",function(h){u.emit("error",h)}).on("end",function(){u.push(null)})}t("../utils").inherits(r,n),r.prototype._read=function(){this._helper.resume()},i.exports=r},{"../utils":32,"readable-stream":16}],14:[function(t,i,s){i.exports={isNode:typeof Buffer<"u",newBufferFrom:function(n,r){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(n,r);if("number"==typeof n)throw new Error('The "data" argument must not be a number');return new Buffer(n,r)},allocBuffer:function(n){if(Buffer.alloc)return Buffer.alloc(n);var r=new Buffer(n);return r.fill(0),r},isBuffer:function(n){return Buffer.isBuffer(n)},isStream:function(n){return n&&"function"==typeof n.on&&"function"==typeof n.pause&&"function"==typeof n.resume}}},{}],15:[function(t,i,s){function n(P,I,M){var z,O=a.getTypeOf(I),D=a.extend(M||{},u);D.date=D.date||new Date,null!==D.compression&&(D.compression=D.compression.toUpperCase()),"string"==typeof D.unixPermissions&&(D.unixPermissions=parseInt(D.unixPermissions,8)),D.unixPermissions&&16384&D.unixPermissions&&(D.dir=!0),D.dosPermissions&&16&D.dosPermissions&&(D.dir=!0),D.dir&&(P=m(P)),D.createFolders&&(z=_(P))&&x.call(this,z,!0),M&&void 0!==M.binary||(D.binary=!("string"===O&&!1===D.binary&&!1===D.base64)),(I instanceof h&&0===I.uncompressedSize||D.dir||!I||0===I.length)&&(D.base64=!1,D.binary=!0,I="",D.compression="STORE",O="string");var A;A=I instanceof h||I instanceof l?I:y.isNode&&y.isStream(I)?new g(P,I):a.prepareContent(P,I,D.binary,D.optimizedBinaryString,D.base64);var F=new f(P,A,D);this.files[P]=F}var r=t("./utf8"),a=t("./utils"),l=t("./stream/GenericWorker"),c=t("./stream/StreamHelper"),u=t("./defaults"),h=t("./compressedObject"),f=t("./zipObject"),d=t("./generate"),y=t("./nodejsUtils"),g=t("./nodejs/NodejsStreamInputAdapter"),_=function(P){"/"===P.slice(-1)&&(P=P.substring(0,P.length-1));var I=P.lastIndexOf("/");return 0<I?P.substring(0,I):""},m=function(P){return"/"!==P.slice(-1)&&(P+="/"),P},x=function(P,I){return I=void 0!==I?I:u.createFolders,P=m(P),this.files[P]||n.call(this,P,null,{dir:!0,createFolders:I}),this.files[P]};function T(P){return"[object RegExp]"===Object.prototype.toString.call(P)}var E={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(P){var I,M,z;for(I in this.files)z=this.files[I],(M=I.slice(this.root.length,I.length))&&I.slice(0,this.root.length)===this.root&&P(M,z)},filter:function(P){var I=[];return this.forEach(function(M,z){P(M,z)&&I.push(z)}),I},file:function(P,I,M){if(1!==arguments.length)return n.call(this,P=this.root+P,I,M),this;if(T(P)){var z=P;return this.filter(function(D,Z){return!Z.dir&&z.test(D)})}var O=this.files[this.root+P];return O&&!O.dir?O:null},folder:function(P){if(!P)return this;if(T(P))return this.filter(function(O,D){return D.dir&&P.test(O)});var M=x.call(this,this.root+P),z=this.clone();return z.root=M.name,z},remove:function(P){var I=this.files[P=this.root+P];if(I||("/"!==P.slice(-1)&&(P+="/"),I=this.files[P]),I&&!I.dir)delete this.files[P];else for(var M=this.filter(function(O,D){return D.name.slice(0,P.length)===P}),z=0;z<M.length;z++)delete this.files[M[z].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(P){var I,M={};try{if((M=a.extend(P||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:r.utf8encode})).type=M.type.toLowerCase(),M.compression=M.compression.toUpperCase(),"binarystring"===M.type&&(M.type="string"),!M.type)throw new Error("No output type specified.");a.checkSupport(M.type),"darwin"!==M.platform&&"freebsd"!==M.platform&&"linux"!==M.platform&&"sunos"!==M.platform||(M.platform="UNIX"),"win32"===M.platform&&(M.platform="DOS"),I=d.generateWorker(this,M,M.comment||this.comment||"")}catch(O){(I=new l("error")).error(O)}return new c(I,M.type||"string",M.mimeType)},generateAsync:function(P,I){return this.generateInternalStream(P).accumulate(I)},generateNodeStream:function(P,I){return(P=P||{}).type||(P.type="nodebuffer"),this.generateInternalStream(P).toNodejsStream(I)}};i.exports=E},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(t,i,s){i.exports=t("stream")},{stream:void 0}],17:[function(t,i,s){var n=t("./DataReader");function r(a){n.call(this,a);for(var l=0;l<this.data.length;l++)a[l]=255&a[l]}t("../utils").inherits(r,n),r.prototype.byteAt=function(a){return this.data[this.zero+a]},r.prototype.lastIndexOfSignature=function(a){for(var l=a.charCodeAt(0),c=a.charCodeAt(1),u=a.charCodeAt(2),h=a.charCodeAt(3),f=this.length-4;0<=f;--f)if(this.data[f]===l&&this.data[f+1]===c&&this.data[f+2]===u&&this.data[f+3]===h)return f-this.zero;return-1},r.prototype.readAndCheckSignature=function(a){var l=a.charCodeAt(0),c=a.charCodeAt(1),u=a.charCodeAt(2),h=a.charCodeAt(3),f=this.readData(4);return l===f[0]&&c===f[1]&&u===f[2]&&h===f[3]},r.prototype.readData=function(a){if(this.checkOffset(a),0===a)return[];var l=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},i.exports=r},{"../utils":32,"./DataReader":18}],18:[function(t,i,s){var n=t("../utils");function r(a){this.data=a,this.length=a.length,this.index=0,this.zero=0}r.prototype={checkOffset:function(a){this.checkIndex(this.index+a)},checkIndex:function(a){if(this.length<this.zero+a||a<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+a+"). Corrupted zip ?")},setIndex:function(a){this.checkIndex(a),this.index=a},skip:function(a){this.setIndex(this.index+a)},byteAt:function(){},readInt:function(a){var l,c=0;for(this.checkOffset(a),l=this.index+a-1;l>=this.index;l--)c=(c<<8)+this.byteAt(l);return this.index+=a,c},readString:function(a){return n.transformTo("string",this.readData(a))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var a=this.readInt(4);return new Date(Date.UTC(1980+(a>>25&127),(a>>21&15)-1,a>>16&31,a>>11&31,a>>5&63,(31&a)<<1))}},i.exports=r},{"../utils":32}],19:[function(t,i,s){var n=t("./Uint8ArrayReader");function r(a){n.call(this,a)}t("../utils").inherits(r,n),r.prototype.readData=function(a){this.checkOffset(a);var l=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},i.exports=r},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(t,i,s){var n=t("./DataReader");function r(a){n.call(this,a)}t("../utils").inherits(r,n),r.prototype.byteAt=function(a){return this.data.charCodeAt(this.zero+a)},r.prototype.lastIndexOfSignature=function(a){return this.data.lastIndexOf(a)-this.zero},r.prototype.readAndCheckSignature=function(a){return a===this.readData(4)},r.prototype.readData=function(a){this.checkOffset(a);var l=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},i.exports=r},{"../utils":32,"./DataReader":18}],21:[function(t,i,s){var n=t("./ArrayReader");function r(a){n.call(this,a)}t("../utils").inherits(r,n),r.prototype.readData=function(a){if(this.checkOffset(a),0===a)return new Uint8Array(0);var l=this.data.subarray(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},i.exports=r},{"../utils":32,"./ArrayReader":17}],22:[function(t,i,s){var n=t("../utils"),r=t("../support"),a=t("./ArrayReader"),l=t("./StringReader"),c=t("./NodeBufferReader"),u=t("./Uint8ArrayReader");i.exports=function(h){var f=n.getTypeOf(h);return n.checkSupport(f),"string"!==f||r.uint8array?"nodebuffer"===f?new c(h):r.uint8array?new u(n.transformTo("uint8array",h)):new a(n.transformTo("array",h)):new l(h)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(t,i,s){s.LOCAL_FILE_HEADER="PK\x03\x04",s.CENTRAL_FILE_HEADER="PK\x01\x02",s.CENTRAL_DIRECTORY_END="PK\x05\x06",s.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x06\x07",s.ZIP64_CENTRAL_DIRECTORY_END="PK\x06\x06",s.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(t,i,s){var n=t("./GenericWorker"),r=t("../utils");function a(l){n.call(this,"ConvertWorker to "+l),this.destType=l}r.inherits(a,n),a.prototype.processChunk=function(l){this.push({data:r.transformTo(this.destType,l.data),meta:l.meta})},i.exports=a},{"../utils":32,"./GenericWorker":28}],25:[function(t,i,s){var n=t("./GenericWorker"),r=t("../crc32");function a(){n.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}t("../utils").inherits(a,n),a.prototype.processChunk=function(l){this.streamInfo.crc32=r(l.data,this.streamInfo.crc32||0),this.push(l)},i.exports=a},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(t,i,s){var n=t("../utils"),r=t("./GenericWorker");function a(l){r.call(this,"DataLengthProbe for "+l),this.propName=l,this.withStreamInfo(l,0)}n.inherits(a,r),a.prototype.processChunk=function(l){l&&(this.streamInfo[this.propName]=(this.streamInfo[this.propName]||0)+l.data.length),r.prototype.processChunk.call(this,l)},i.exports=a},{"../utils":32,"./GenericWorker":28}],27:[function(t,i,s){var n=t("../utils"),r=t("./GenericWorker");function a(l){r.call(this,"DataWorker");var c=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,l.then(function(u){c.dataIsReady=!0,c.data=u,c.max=u&&u.length||0,c.type=n.getTypeOf(u),c.isPaused||c._tickAndRepeat()},function(u){c.error(u)})}n.inherits(a,r),a.prototype.cleanUp=function(){r.prototype.cleanUp.call(this),this.data=null},a.prototype.resume=function(){return!!r.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,n.delay(this._tickAndRepeat,[],this)),!0)},a.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(n.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},a.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var l=null,c=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":l=this.data.substring(this.index,c);break;case"uint8array":l=this.data.subarray(this.index,c);break;case"array":case"nodebuffer":l=this.data.slice(this.index,c)}return this.index=c,this.push({data:l,meta:{percent:this.max?this.index/this.max*100:0}})},i.exports=a},{"../utils":32,"./GenericWorker":28}],28:[function(t,i,s){function n(r){this.name=r||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}n.prototype={push:function(r){this.emit("data",r)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(r){this.emit("error",r)}return!0},error:function(r){return!this.isFinished&&(this.isPaused?this.generatedError=r:(this.isFinished=!0,this.emit("error",r),this.previous&&this.previous.error(r),this.cleanUp()),!0)},on:function(r,a){return this._listeners[r].push(a),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(r,a){if(this._listeners[r])for(var l=0;l<this._listeners[r].length;l++)this._listeners[r][l].call(this,a)},pipe:function(r){return r.registerPrevious(this)},registerPrevious:function(r){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=r.streamInfo,this.mergeStreamInfo(),this.previous=r;var a=this;return r.on("data",function(l){a.processChunk(l)}),r.on("end",function(){a.end()}),r.on("error",function(l){a.error(l)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var r=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),r=!0),this.previous&&this.previous.resume(),!r},flush:function(){},processChunk:function(r){this.push(r)},withStreamInfo:function(r,a){return this.extraStreamInfo[r]=a,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var r in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,r)&&(this.streamInfo[r]=this.extraStreamInfo[r])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var r="Worker "+this.name;return this.previous?this.previous+" -> "+r:r}},i.exports=n},{}],29:[function(t,i,s){var n=t("../utils"),r=t("./ConvertWorker"),a=t("./GenericWorker"),l=t("../base64"),c=t("../support"),u=t("../external"),h=null;if(c.nodestream)try{h=t("../nodejs/NodejsStreamOutputAdapter")}catch{}function d(y,g,_){var m=g;switch(g){case"blob":case"arraybuffer":m="uint8array";break;case"base64":m="string"}try{this._internalType=m,this._outputType=g,this._mimeType=_,n.checkSupport(m),this._worker=y.pipe(new r(m)),y.lock()}catch(x){this._worker=new a("error"),this._worker.error(x)}}d.prototype={accumulate:function(y){return function f(y,g){return new u.Promise(function(_,m){var x=[],T=y._internalType,E=y._outputType,P=y._mimeType;y.on("data",function(I,M){x.push(I),g&&g(M)}).on("error",function(I){x=[],m(I)}).on("end",function(){try{var I=function(M,z,O){switch(M){case"blob":return n.newBlob(n.transformTo("arraybuffer",z),O);case"base64":return l.encode(z);default:return n.transformTo(M,z)}}(E,function(M,z){var O,D=0,Z=null,A=0;for(O=0;O<z.length;O++)A+=z[O].length;switch(M){case"string":return z.join("");case"array":return Array.prototype.concat.apply([],z);case"uint8array":for(Z=new Uint8Array(A),O=0;O<z.length;O++)Z.set(z[O],D),D+=z[O].length;return Z;case"nodebuffer":return Buffer.concat(z);default:throw new Error("concat : unsupported type '"+M+"'")}}(T,x),P);_(I)}catch(M){m(M)}x=[]}).resume()})}(this,y)},on:function(y,g){var _=this;return this._worker.on(y,"data"===y?function(m){g.call(_,m.data,m.meta)}:function(){n.delay(g,arguments,_)}),this},resume:function(){return n.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(y){if(n.checkSupport("nodestream"),"nodebuffer"!==this._outputType)throw new Error(this._outputType+" is not supported by this method");return new h(this,{objectMode:"nodebuffer"!==this._outputType},y)}},i.exports=d},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(t,i,s){if(s.base64=!0,s.array=!0,s.string=!0,s.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",s.nodebuffer=typeof Buffer<"u",s.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")s.blob=!1;else{var n=new ArrayBuffer(0);try{s.blob=0===new Blob([n],{type:"application/zip"}).size}catch{try{var r=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);r.append(n),s.blob=0===r.getBlob("application/zip").size}catch{s.blob=!1}}}try{s.nodestream=!!t("readable-stream").Readable}catch{s.nodestream=!1}},{"readable-stream":16}],31:[function(t,i,s){for(var n=t("./utils"),r=t("./support"),a=t("./nodejsUtils"),l=t("./stream/GenericWorker"),c=new Array(256),u=0;u<256;u++)c[u]=252<=u?6:248<=u?5:240<=u?4:224<=u?3:192<=u?2:1;function h(){l.call(this,"utf-8 decode"),this.leftOver=null}function f(){l.call(this,"utf-8 encode")}c[254]=c[254]=1,s.utf8encode=function(d){return r.nodebuffer?a.newBufferFrom(d,"utf-8"):function(y){var g,_,m,x,T,E=y.length,P=0;for(x=0;x<E;x++)55296==(64512&(_=y.charCodeAt(x)))&&x+1<E&&56320==(64512&(m=y.charCodeAt(x+1)))&&(_=65536+(_-55296<<10)+(m-56320),x++),P+=_<128?1:_<2048?2:_<65536?3:4;for(g=r.uint8array?new Uint8Array(P):new Array(P),x=T=0;T<P;x++)55296==(64512&(_=y.charCodeAt(x)))&&x+1<E&&56320==(64512&(m=y.charCodeAt(x+1)))&&(_=65536+(_-55296<<10)+(m-56320),x++),_<128?g[T++]=_:(_<2048?g[T++]=192|_>>>6:(_<65536?g[T++]=224|_>>>12:(g[T++]=240|_>>>18,g[T++]=128|_>>>12&63),g[T++]=128|_>>>6&63),g[T++]=128|63&_);return g}(d)},s.utf8decode=function(d){return r.nodebuffer?n.transformTo("nodebuffer",d).toString("utf-8"):function(y){var g,_,m,x,T=y.length,E=new Array(2*T);for(g=_=0;g<T;)if((m=y[g++])<128)E[_++]=m;else if(4<(x=c[m]))E[_++]=65533,g+=x-1;else{for(m&=2===x?31:3===x?15:7;1<x&&g<T;)m=m<<6|63&y[g++],x--;1<x?E[_++]=65533:m<65536?E[_++]=m:(E[_++]=55296|(m-=65536)>>10&1023,E[_++]=56320|1023&m)}return E.length!==_&&(E.subarray?E=E.subarray(0,_):E.length=_),n.applyFromCharCode(E)}(d=n.transformTo(r.uint8array?"uint8array":"array",d))},n.inherits(h,l),h.prototype.processChunk=function(d){var y=n.transformTo(r.uint8array?"uint8array":"array",d.data);if(this.leftOver&&this.leftOver.length){if(r.uint8array){var g=y;(y=new Uint8Array(g.length+this.leftOver.length)).set(this.leftOver,0),y.set(g,this.leftOver.length)}else y=this.leftOver.concat(y);this.leftOver=null}var _=function(x,T){var E;for((T=T||x.length)>x.length&&(T=x.length),E=T-1;0<=E&&128==(192&x[E]);)E--;return E<0||0===E?T:E+c[x[E]]>T?E:T}(y),m=y;_!==y.length&&(r.uint8array?(m=y.subarray(0,_),this.leftOver=y.subarray(_,y.length)):(m=y.slice(0,_),this.leftOver=y.slice(_,y.length))),this.push({data:s.utf8decode(m),meta:d.meta})},h.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:s.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},s.Utf8DecodeWorker=h,n.inherits(f,l),f.prototype.processChunk=function(d){this.push({data:s.utf8encode(d.data),meta:d.meta})},s.Utf8EncodeWorker=f},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(t,i,s){var n=t("./support"),r=t("./base64"),a=t("./nodejsUtils"),l=t("./external");function c(g){return g}function u(g,_){for(var m=0;m<g.length;++m)_[m]=255&g.charCodeAt(m);return _}t("setimmediate"),s.newBlob=function(g,_){s.checkSupport("blob");try{return new Blob([g],{type:_})}catch{try{var m=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return m.append(g),m.getBlob(_)}catch{throw new Error("Bug : can't construct the Blob.")}}};var h={stringifyByChunk:function(g,_,m){var x=[],T=0,E=g.length;if(E<=m)return String.fromCharCode.apply(null,g);for(;T<E;)x.push(String.fromCharCode.apply(null,"array"===_||"nodebuffer"===_?g.slice(T,Math.min(T+m,E)):g.subarray(T,Math.min(T+m,E)))),T+=m;return x.join("")},stringifyByChar:function(g){for(var _="",m=0;m<g.length;m++)_+=String.fromCharCode(g[m]);return _},applyCanBeUsed:{uint8array:function(){try{return n.uint8array&&1===String.fromCharCode.apply(null,new Uint8Array(1)).length}catch{return!1}}(),nodebuffer:function(){try{return n.nodebuffer&&1===String.fromCharCode.apply(null,a.allocBuffer(1)).length}catch{return!1}}()}};function f(g){var _=65536,m=s.getTypeOf(g),x=!0;if("uint8array"===m?x=h.applyCanBeUsed.uint8array:"nodebuffer"===m&&(x=h.applyCanBeUsed.nodebuffer),x)for(;1<_;)try{return h.stringifyByChunk(g,m,_)}catch{_=Math.floor(_/2)}return h.stringifyByChar(g)}function d(g,_){for(var m=0;m<g.length;m++)_[m]=g[m];return _}s.applyFromCharCode=f;var y={};y.string={string:c,array:function(g){return u(g,new Array(g.length))},arraybuffer:function(g){return y.string.uint8array(g).buffer},uint8array:function(g){return u(g,new Uint8Array(g.length))},nodebuffer:function(g){return u(g,a.allocBuffer(g.length))}},y.array={string:f,array:c,arraybuffer:function(g){return new Uint8Array(g).buffer},uint8array:function(g){return new Uint8Array(g)},nodebuffer:function(g){return a.newBufferFrom(g)}},y.arraybuffer={string:function(g){return f(new Uint8Array(g))},array:function(g){return d(new Uint8Array(g),new Array(g.byteLength))},arraybuffer:c,uint8array:function(g){return new Uint8Array(g)},nodebuffer:function(g){return a.newBufferFrom(new Uint8Array(g))}},y.uint8array={string:f,array:function(g){return d(g,new Array(g.length))},arraybuffer:function(g){return g.buffer},uint8array:c,nodebuffer:function(g){return a.newBufferFrom(g)}},y.nodebuffer={string:f,array:function(g){return d(g,new Array(g.length))},arraybuffer:function(g){return y.nodebuffer.uint8array(g).buffer},uint8array:function(g){return d(g,new Uint8Array(g.length))},nodebuffer:c},s.transformTo=function(g,_){if(_=_||"",!g)return _;s.checkSupport(g);var m=s.getTypeOf(_);return y[m][g](_)},s.resolve=function(g){for(var _=g.split("/"),m=[],x=0;x<_.length;x++){var T=_[x];"."===T||""===T&&0!==x&&x!==_.length-1||(".."===T?m.pop():m.push(T))}return m.join("/")},s.getTypeOf=function(g){return"string"==typeof g?"string":"[object Array]"===Object.prototype.toString.call(g)?"array":n.nodebuffer&&a.isBuffer(g)?"nodebuffer":n.uint8array&&g instanceof Uint8Array?"uint8array":n.arraybuffer&&g instanceof ArrayBuffer?"arraybuffer":void 0},s.checkSupport=function(g){if(!n[g.toLowerCase()])throw new Error(g+" is not supported by this platform")},s.MAX_VALUE_16BITS=65535,s.MAX_VALUE_32BITS=-1,s.pretty=function(g){var _,m,x="";for(m=0;m<(g||"").length;m++)x+="\\x"+((_=g.charCodeAt(m))<16?"0":"")+_.toString(16).toUpperCase();return x},s.delay=function(g,_,m){setImmediate(function(){g.apply(m||null,_||[])})},s.inherits=function(g,_){function m(){}m.prototype=_.prototype,g.prototype=new m},s.extend=function(){var g,_,m={};for(g=0;g<arguments.length;g++)for(_ in arguments[g])Object.prototype.hasOwnProperty.call(arguments[g],_)&&void 0===m[_]&&(m[_]=arguments[g][_]);return m},s.prepareContent=function(g,_,m,x,T){return l.Promise.resolve(_).then(function(E){return n.blob&&(E instanceof Blob||-1!==["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(E)))&&typeof FileReader<"u"?new l.Promise(function(P,I){var M=new FileReader;M.onload=function(z){P(z.target.result)},M.onerror=function(z){I(z.target.error)},M.readAsArrayBuffer(E)}):E}).then(function(E){var I,P=s.getTypeOf(E);return P?("arraybuffer"===P?E=s.transformTo("uint8array",E):"string"===P&&(T?E=r.decode(E):m&&!0!==x&&(E=u(I=E,n.uint8array?new Uint8Array(I.length):new Array(I.length)))),E):l.Promise.reject(new Error("Can't read the data of '"+g+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(t,i,s){var n=t("./reader/readerFor"),r=t("./utils"),a=t("./signature"),l=t("./zipEntry"),c=t("./support");function u(h){this.files=[],this.loadOptions=h}u.prototype={checkSignature:function(h){if(!this.reader.readAndCheckSignature(h)){this.reader.index-=4;var f=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+r.pretty(f)+", expected "+r.pretty(h)+")")}},isSignature:function(h,f){var d=this.reader.index;this.reader.setIndex(h);var y=this.reader.readString(4)===f;return this.reader.setIndex(d),y},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var h=this.reader.readData(this.zipCommentLength),d=r.transformTo(c.uint8array?"uint8array":"array",h);this.zipComment=this.loadOptions.decodeFileName(d)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var h,f,d,y=this.zip64EndOfCentralSize-44;0<y;)h=this.reader.readInt(2),f=this.reader.readInt(4),d=this.reader.readData(f),this.zip64ExtensibleData[h]={id:h,length:f,value:d}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var h,f;for(h=0;h<this.files.length;h++)this.reader.setIndex((f=this.files[h]).localHeaderOffset),this.checkSignature(a.LOCAL_FILE_HEADER),f.readLocalPart(this.reader),f.handleUTF8(),f.processAttributes()},readCentralDir:function(){var h;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(a.CENTRAL_FILE_HEADER);)(h=new l({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(h);if(this.centralDirRecords!==this.files.length&&0!==this.centralDirRecords&&0===this.files.length)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var h=this.reader.lastIndexOfSignature(a.CENTRAL_DIRECTORY_END);if(h<0)throw this.isSignature(0,a.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(h);var f=h;if(this.checkSignature(a.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===r.MAX_VALUE_16BITS||this.diskWithCentralDirStart===r.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===r.MAX_VALUE_16BITS||this.centralDirRecords===r.MAX_VALUE_16BITS||this.centralDirSize===r.MAX_VALUE_32BITS||this.centralDirOffset===r.MAX_VALUE_32BITS){if(this.zip64=!0,(h=this.reader.lastIndexOfSignature(a.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(h),this.checkSignature(a.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,a.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(a.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(a.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var d=this.centralDirOffset+this.centralDirSize;this.zip64&&(d+=20,d+=12+this.zip64EndOfCentralSize);var y=f-d;if(0<y)this.isSignature(f,a.CENTRAL_FILE_HEADER)||(this.reader.zero=y);else if(y<0)throw new Error("Corrupted zip: missing "+Math.abs(y)+" bytes.")},prepareReader:function(h){this.reader=n(h)},load:function(h){this.prepareReader(h),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},i.exports=u},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(t,i,s){var n=t("./reader/readerFor"),r=t("./utils"),a=t("./compressedObject"),l=t("./crc32"),c=t("./utf8"),u=t("./compressions"),h=t("./support");function f(d,y){this.options=d,this.loadOptions=y}f.prototype={isEncrypted:function(){return!(1&~this.bitFlag)},useUTF8:function(){return!(2048&~this.bitFlag)},readLocalPart:function(d){var y,g;if(d.skip(22),this.fileNameLength=d.readInt(2),g=d.readInt(2),this.fileName=d.readData(this.fileNameLength),d.skip(g),-1===this.compressedSize||-1===this.uncompressedSize)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if(null===(y=function(_){for(var m in u)if(Object.prototype.hasOwnProperty.call(u,m)&&u[m].magic===_)return u[m];return null}(this.compressionMethod)))throw new Error("Corrupted zip : compression "+r.pretty(this.compressionMethod)+" unknown (inner file : "+r.transformTo("string",this.fileName)+")");this.decompressed=new a(this.compressedSize,this.uncompressedSize,this.crc32,y,d.readData(this.compressedSize))},readCentralPart:function(d){this.versionMadeBy=d.readInt(2),d.skip(2),this.bitFlag=d.readInt(2),this.compressionMethod=d.readString(2),this.date=d.readDate(),this.crc32=d.readInt(4),this.compressedSize=d.readInt(4),this.uncompressedSize=d.readInt(4);var y=d.readInt(2);if(this.extraFieldsLength=d.readInt(2),this.fileCommentLength=d.readInt(2),this.diskNumberStart=d.readInt(2),this.internalFileAttributes=d.readInt(2),this.externalFileAttributes=d.readInt(4),this.localHeaderOffset=d.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");d.skip(y),this.readExtraFields(d),this.parseZIP64ExtraField(d),this.fileComment=d.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var d=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),0==d&&(this.dosPermissions=63&this.externalFileAttributes),3==d&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||"/"!==this.fileNameStr.slice(-1)||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var d=n(this.extraFields[1].value);this.uncompressedSize===r.MAX_VALUE_32BITS&&(this.uncompressedSize=d.readInt(8)),this.compressedSize===r.MAX_VALUE_32BITS&&(this.compressedSize=d.readInt(8)),this.localHeaderOffset===r.MAX_VALUE_32BITS&&(this.localHeaderOffset=d.readInt(8)),this.diskNumberStart===r.MAX_VALUE_32BITS&&(this.diskNumberStart=d.readInt(4))}},readExtraFields:function(d){var y,g,_,m=d.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});d.index+4<m;)y=d.readInt(2),g=d.readInt(2),_=d.readData(g),this.extraFields[y]={id:y,length:g,value:_};d.setIndex(m)},handleUTF8:function(){var d=h.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=c.utf8decode(this.fileName),this.fileCommentStr=c.utf8decode(this.fileComment);else{var y=this.findExtraFieldUnicodePath();if(null!==y)this.fileNameStr=y;else{var g=r.transformTo(d,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(g)}var _=this.findExtraFieldUnicodeComment();if(null!==_)this.fileCommentStr=_;else{var m=r.transformTo(d,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(m)}}},findExtraFieldUnicodePath:function(){var d=this.extraFields[28789];if(d){var y=n(d.value);return 1!==y.readInt(1)||l(this.fileName)!==y.readInt(4)?null:c.utf8decode(y.readData(d.length-5))}return null},findExtraFieldUnicodeComment:function(){var d=this.extraFields[25461];if(d){var y=n(d.value);return 1!==y.readInt(1)||l(this.fileComment)!==y.readInt(4)?null:c.utf8decode(y.readData(d.length-5))}return null}},i.exports=f},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(t,i,s){function n(y,g,_){this.name=y,this.dir=_.dir,this.date=_.date,this.comment=_.comment,this.unixPermissions=_.unixPermissions,this.dosPermissions=_.dosPermissions,this._data=g,this._dataBinary=_.binary,this.options={compression:_.compression,compressionOptions:_.compressionOptions}}var r=t("./stream/StreamHelper"),a=t("./stream/DataWorker"),l=t("./utf8"),c=t("./compressedObject"),u=t("./stream/GenericWorker");n.prototype={internalStream:function(y){var g=null,_="string";try{if(!y)throw new Error("No output type specified.");var m="string"===(_=y.toLowerCase())||"text"===_;"binarystring"!==_&&"text"!==_||(_="string"),g=this._decompressWorker();var x=!this._dataBinary;x&&!m&&(g=g.pipe(new l.Utf8EncodeWorker)),!x&&m&&(g=g.pipe(new l.Utf8DecodeWorker))}catch(T){(g=new u("error")).error(T)}return new r(g,_,"")},async:function(y,g){return this.internalStream(y).accumulate(g)},nodeStream:function(y,g){return this.internalStream(y||"nodebuffer").toNodejsStream(g)},_compressWorker:function(y,g){if(this._data instanceof c&&this._data.compression.magic===y.magic)return this._data.getCompressedWorker();var _=this._decompressWorker();return this._dataBinary||(_=_.pipe(new l.Utf8EncodeWorker)),c.createWorkerFrom(_,y,g)},_decompressWorker:function(){return this._data instanceof c?this._data.getContentWorker():this._data instanceof u?this._data:new a(this._data)}};for(var h=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],f=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},d=0;d<h.length;d++)n.prototype[h[d]]=f;i.exports=n},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(t,i,s){(function(n){var r,a,l=n.MutationObserver||n.WebKitMutationObserver;if(l){var c=0,u=new l(y),h=n.document.createTextNode("");u.observe(h,{characterData:!0}),r=function(){h.data=c=++c%2}}else if(n.setImmediate||void 0===n.MessageChannel)r="document"in n&&"onreadystatechange"in n.document.createElement("script")?function(){var g=n.document.createElement("script");g.onreadystatechange=function(){y(),g.onreadystatechange=null,g.parentNode.removeChild(g),g=null},n.document.documentElement.appendChild(g)}:function(){setTimeout(y,0)};else{var f=new n.MessageChannel;f.port1.onmessage=y,r=function(){f.port2.postMessage(0)}}var d=[];function y(){var g,_;a=!0;for(var m=d.length;m;){for(_=d,d=[],g=-1;++g<m;)_[g]();m=d.length}a=!1}i.exports=function(g){1!==d.push(g)||a||r()}}).call(this,typeof ts<"u"?ts:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(t,i,s){var n=t("immediate");function r(){}var a={},l=["REJECTED"],c=["FULFILLED"],u=["PENDING"];function h(m){if("function"!=typeof m)throw new TypeError("resolver must be a function");this.state=u,this.queue=[],this.outcome=void 0,m!==r&&g(this,m)}function f(m,x,T){this.promise=m,"function"==typeof x&&(this.onFulfilled=x,this.callFulfilled=this.otherCallFulfilled),"function"==typeof T&&(this.onRejected=T,this.callRejected=this.otherCallRejected)}function d(m,x,T){n(function(){var E;try{E=x(T)}catch(P){return a.reject(m,P)}E===m?a.reject(m,new TypeError("Cannot resolve promise with itself")):a.resolve(m,E)})}function y(m){var x=m&&m.then;if(m&&("object"==typeof m||"function"==typeof m)&&"function"==typeof x)return function(){x.apply(m,arguments)}}function g(m,x){var T=!1;function E(M){T||(T=!0,a.reject(m,M))}function P(M){T||(T=!0,a.resolve(m,M))}var I=_(function(){x(P,E)});"error"===I.status&&E(I.value)}function _(m,x){var T={};try{T.value=m(x),T.status="success"}catch(E){T.status="error",T.value=E}return T}(i.exports=h).prototype.finally=function(m){if("function"!=typeof m)return this;var x=this.constructor;return this.then(function(T){return x.resolve(m()).then(function(){return T})},function(T){return x.resolve(m()).then(function(){throw T})})},h.prototype.catch=function(m){return this.then(null,m)},h.prototype.then=function(m,x){if("function"!=typeof m&&this.state===c||"function"!=typeof x&&this.state===l)return this;var T=new this.constructor(r);return this.state!==u?d(T,this.state===c?m:x,this.outcome):this.queue.push(new f(T,m,x)),T},f.prototype.callFulfilled=function(m){a.resolve(this.promise,m)},f.prototype.otherCallFulfilled=function(m){d(this.promise,this.onFulfilled,m)},f.prototype.callRejected=function(m){a.reject(this.promise,m)},f.prototype.otherCallRejected=function(m){d(this.promise,this.onRejected,m)},a.resolve=function(m,x){var T=_(y,x);if("error"===T.status)return a.reject(m,T.value);var E=T.value;if(E)g(m,E);else{m.state=c,m.outcome=x;for(var P=-1,I=m.queue.length;++P<I;)m.queue[P].callFulfilled(x)}return m},a.reject=function(m,x){m.state=l,m.outcome=x;for(var T=-1,E=m.queue.length;++T<E;)m.queue[T].callRejected(x);return m},h.resolve=function(m){return m instanceof this?m:a.resolve(new this(r),m)},h.reject=function(m){var x=new this(r);return a.reject(x,m)},h.all=function(m){var x=this;if("[object Array]"!==Object.prototype.toString.call(m))return this.reject(new TypeError("must be an array"));var T=m.length,E=!1;if(!T)return this.resolve([]);for(var P=new Array(T),I=0,M=-1,z=new this(r);++M<T;)O(m[M],M);return z;function O(D,Z){x.resolve(D).then(function(A){P[Z]=A,++I!==T||E||(E=!0,a.resolve(z,P))},function(A){E||(E=!0,a.reject(z,A))})}},h.race=function(m){if("[object Array]"!==Object.prototype.toString.call(m))return this.reject(new TypeError("must be an array"));var T=m.length,E=!1;if(!T)return this.resolve([]);for(var P=-1,I=new this(r);++P<T;)this.resolve(m[P]).then(function(z){E||(E=!0,a.resolve(I,z))},function(z){E||(E=!0,a.reject(I,z))});return I}},{immediate:36}],38:[function(t,i,s){var n={};(0,t("./lib/utils/common").assign)(n,t("./lib/deflate"),t("./lib/inflate"),t("./lib/zlib/constants")),i.exports=n},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(t,i,s){var n=t("./zlib/deflate"),r=t("./utils/common"),a=t("./utils/strings"),l=t("./zlib/messages"),c=t("./zlib/zstream"),u=Object.prototype.toString;function g(m){if(!(this instanceof g))return new g(m);this.options=r.assign({level:-1,method:8,chunkSize:16384,windowBits:15,memLevel:8,strategy:0,to:""},m||{});var x=this.options;x.raw&&0<x.windowBits?x.windowBits=-x.windowBits:x.gzip&&0<x.windowBits&&x.windowBits<16&&(x.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new c,this.strm.avail_out=0;var T=n.deflateInit2(this.strm,x.level,x.method,x.windowBits,x.memLevel,x.strategy);if(0!==T)throw new Error(l[T]);if(x.header&&n.deflateSetHeader(this.strm,x.header),x.dictionary){var E;if(E="string"==typeof x.dictionary?a.string2buf(x.dictionary):"[object ArrayBuffer]"===u.call(x.dictionary)?new Uint8Array(x.dictionary):x.dictionary,0!==(T=n.deflateSetDictionary(this.strm,E)))throw new Error(l[T]);this._dict_set=!0}}function _(m,x){var T=new g(x);if(T.push(m,!0),T.err)throw T.msg||l[T.err];return T.result}g.prototype.push=function(m,x){var T,E,P=this.strm,I=this.options.chunkSize;if(this.ended)return!1;E=x===~~x?x:!0===x?4:0,P.input="string"==typeof m?a.string2buf(m):"[object ArrayBuffer]"===u.call(m)?new Uint8Array(m):m,P.next_in=0,P.avail_in=P.input.length;do{if(0===P.avail_out&&(P.output=new r.Buf8(I),P.next_out=0,P.avail_out=I),1!==(T=n.deflate(P,E))&&0!==T)return this.onEnd(T),!(this.ended=!0);0!==P.avail_out&&(0!==P.avail_in||4!==E&&2!==E)||this.onData("string"===this.options.to?a.buf2binstring(r.shrinkBuf(P.output,P.next_out)):r.shrinkBuf(P.output,P.next_out))}while((0<P.avail_in||0===P.avail_out)&&1!==T);return 4===E?(T=n.deflateEnd(this.strm),this.onEnd(T),this.ended=!0,0===T):2!==E||(this.onEnd(0),!(P.avail_out=0))},g.prototype.onData=function(m){this.chunks.push(m)},g.prototype.onEnd=function(m){0===m&&(this.result="string"===this.options.to?this.chunks.join(""):r.flattenChunks(this.chunks)),this.chunks=[],this.err=m,this.msg=this.strm.msg},s.Deflate=g,s.deflate=_,s.deflateRaw=function(m,x){return(x=x||{}).raw=!0,_(m,x)},s.gzip=function(m,x){return(x=x||{}).gzip=!0,_(m,x)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(t,i,s){var n=t("./zlib/inflate"),r=t("./utils/common"),a=t("./utils/strings"),l=t("./zlib/constants"),c=t("./zlib/messages"),u=t("./zlib/zstream"),h=t("./zlib/gzheader"),f=Object.prototype.toString;function d(g){if(!(this instanceof d))return new d(g);this.options=r.assign({chunkSize:16384,windowBits:0,to:""},g||{});var _=this.options;_.raw&&0<=_.windowBits&&_.windowBits<16&&(_.windowBits=-_.windowBits,0===_.windowBits&&(_.windowBits=-15)),!(0<=_.windowBits&&_.windowBits<16)||g&&g.windowBits||(_.windowBits+=32),15<_.windowBits&&_.windowBits<48&&!(15&_.windowBits)&&(_.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new u,this.strm.avail_out=0;var m=n.inflateInit2(this.strm,_.windowBits);if(m!==l.Z_OK)throw new Error(c[m]);this.header=new h,n.inflateGetHeader(this.strm,this.header)}function y(g,_){var m=new d(_);if(m.push(g,!0),m.err)throw m.msg||c[m.err];return m.result}d.prototype.push=function(g,_){var m,x,T,E,P,I,M=this.strm,z=this.options.chunkSize,O=this.options.dictionary,D=!1;if(this.ended)return!1;x=_===~~_?_:!0===_?l.Z_FINISH:l.Z_NO_FLUSH,M.input="string"==typeof g?a.binstring2buf(g):"[object ArrayBuffer]"===f.call(g)?new Uint8Array(g):g,M.next_in=0,M.avail_in=M.input.length;do{if(0===M.avail_out&&(M.output=new r.Buf8(z),M.next_out=0,M.avail_out=z),(m=n.inflate(M,l.Z_NO_FLUSH))===l.Z_NEED_DICT&&O&&(I="string"==typeof O?a.string2buf(O):"[object ArrayBuffer]"===f.call(O)?new Uint8Array(O):O,m=n.inflateSetDictionary(this.strm,I)),m===l.Z_BUF_ERROR&&!0===D&&(m=l.Z_OK,D=!1),m!==l.Z_STREAM_END&&m!==l.Z_OK)return this.onEnd(m),!(this.ended=!0);M.next_out&&(0!==M.avail_out&&m!==l.Z_STREAM_END&&(0!==M.avail_in||x!==l.Z_FINISH&&x!==l.Z_SYNC_FLUSH)||("string"===this.options.to?(T=a.utf8border(M.output,M.next_out),E=M.next_out-T,P=a.buf2string(M.output,T),M.next_out=E,M.avail_out=z-E,E&&r.arraySet(M.output,M.output,T,E,0),this.onData(P)):this.onData(r.shrinkBuf(M.output,M.next_out)))),0===M.avail_in&&0===M.avail_out&&(D=!0)}while((0<M.avail_in||0===M.avail_out)&&m!==l.Z_STREAM_END);return m===l.Z_STREAM_END&&(x=l.Z_FINISH),x===l.Z_FINISH?(m=n.inflateEnd(this.strm),this.onEnd(m),this.ended=!0,m===l.Z_OK):x!==l.Z_SYNC_FLUSH||(this.onEnd(l.Z_OK),!(M.avail_out=0))},d.prototype.onData=function(g){this.chunks.push(g)},d.prototype.onEnd=function(g){g===l.Z_OK&&(this.result="string"===this.options.to?this.chunks.join(""):r.flattenChunks(this.chunks)),this.chunks=[],this.err=g,this.msg=this.strm.msg},s.Inflate=d,s.inflate=y,s.inflateRaw=function(g,_){return(_=_||{}).raw=!0,y(g,_)},s.ungzip=y},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(t,i,s){var n=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";s.assign=function(l){for(var c=Array.prototype.slice.call(arguments,1);c.length;){var u=c.shift();if(u){if("object"!=typeof u)throw new TypeError(u+"must be non-object");for(var h in u)u.hasOwnProperty(h)&&(l[h]=u[h])}}return l},s.shrinkBuf=function(l,c){return l.length===c?l:l.subarray?l.subarray(0,c):(l.length=c,l)};var r={arraySet:function(l,c,u,h,f){if(c.subarray&&l.subarray)l.set(c.subarray(u,u+h),f);else for(var d=0;d<h;d++)l[f+d]=c[u+d]},flattenChunks:function(l){var c,u,h,f,d,y;for(c=h=0,u=l.length;c<u;c++)h+=l[c].length;for(y=new Uint8Array(h),c=f=0,u=l.length;c<u;c++)y.set(d=l[c],f),f+=d.length;return y}},a={arraySet:function(l,c,u,h,f){for(var d=0;d<h;d++)l[f+d]=c[u+d]},flattenChunks:function(l){return[].concat.apply([],l)}};s.setTyped=function(l){l?(s.Buf8=Uint8Array,s.Buf16=Uint16Array,s.Buf32=Int32Array,s.assign(s,r)):(s.Buf8=Array,s.Buf16=Array,s.Buf32=Array,s.assign(s,a))},s.setTyped(n)},{}],42:[function(t,i,s){var n=t("./common"),r=!0,a=!0;try{String.fromCharCode.apply(null,[0])}catch{r=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{a=!1}for(var l=new n.Buf8(256),c=0;c<256;c++)l[c]=252<=c?6:248<=c?5:240<=c?4:224<=c?3:192<=c?2:1;function u(h,f){if(f<65537&&(h.subarray&&a||!h.subarray&&r))return String.fromCharCode.apply(null,n.shrinkBuf(h,f));for(var d="",y=0;y<f;y++)d+=String.fromCharCode(h[y]);return d}l[254]=l[254]=1,s.string2buf=function(h){var f,d,y,g,_,m=h.length,x=0;for(g=0;g<m;g++)55296==(64512&(d=h.charCodeAt(g)))&&g+1<m&&56320==(64512&(y=h.charCodeAt(g+1)))&&(d=65536+(d-55296<<10)+(y-56320),g++),x+=d<128?1:d<2048?2:d<65536?3:4;for(f=new n.Buf8(x),g=_=0;_<x;g++)55296==(64512&(d=h.charCodeAt(g)))&&g+1<m&&56320==(64512&(y=h.charCodeAt(g+1)))&&(d=65536+(d-55296<<10)+(y-56320),g++),d<128?f[_++]=d:(d<2048?f[_++]=192|d>>>6:(d<65536?f[_++]=224|d>>>12:(f[_++]=240|d>>>18,f[_++]=128|d>>>12&63),f[_++]=128|d>>>6&63),f[_++]=128|63&d);return f},s.buf2binstring=function(h){return u(h,h.length)},s.binstring2buf=function(h){for(var f=new n.Buf8(h.length),d=0,y=f.length;d<y;d++)f[d]=h.charCodeAt(d);return f},s.buf2string=function(h,f){var d,y,g,_,m=f||h.length,x=new Array(2*m);for(d=y=0;d<m;)if((g=h[d++])<128)x[y++]=g;else if(4<(_=l[g]))x[y++]=65533,d+=_-1;else{for(g&=2===_?31:3===_?15:7;1<_&&d<m;)g=g<<6|63&h[d++],_--;1<_?x[y++]=65533:g<65536?x[y++]=g:(x[y++]=55296|(g-=65536)>>10&1023,x[y++]=56320|1023&g)}return u(x,y)},s.utf8border=function(h,f){var d;for((f=f||h.length)>h.length&&(f=h.length),d=f-1;0<=d&&128==(192&h[d]);)d--;return d<0||0===d?f:d+l[h[d]]>f?d:f}},{"./common":41}],43:[function(t,i,s){i.exports=function(n,r,a,l){for(var c=65535&n,u=n>>>16&65535,h=0;0!==a;){for(a-=h=2e3<a?2e3:a;u=u+(c=c+r[l++]|0)|0,--h;);c%=65521,u%=65521}return c|u<<16}},{}],44:[function(t,i,s){i.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(t,i,s){var n=function(){for(var r,a=[],l=0;l<256;l++){r=l;for(var c=0;c<8;c++)r=1&r?3988292384^r>>>1:r>>>1;a[l]=r}return a}();i.exports=function(r,a,l,c){var u=n,h=c+l;r^=-1;for(var f=c;f<h;f++)r=r>>>8^u[255&(r^a[f])];return-1^r}},{}],46:[function(t,i,s){var n,r=t("../utils/common"),a=t("./trees"),l=t("./adler32"),c=t("./crc32"),u=t("./messages"),y=-2,D=258,Z=262,F=113;function rt(C,W){return C.msg=u[W],W}function Y(C){return(C<<1)-(4<C?9:0)}function ot(C){for(var W=C.length;0<=--W;)C[W]=0}function L(C){var W=C.state,$=W.pending;$>C.avail_out&&($=C.avail_out),0!==$&&(r.arraySet(C.output,W.pending_buf,W.pending_out,$,C.next_out),C.next_out+=$,W.pending_out+=$,C.total_out+=$,C.avail_out-=$,W.pending-=$,0===W.pending&&(W.pending_out=0))}function V(C,W){a._tr_flush_block(C,0<=C.block_start?C.block_start:-1,C.strstart-C.block_start,W),C.block_start=C.strstart,L(C.strm)}function st(C,W){C.pending_buf[C.pending++]=W}function it(C,W){C.pending_buf[C.pending++]=W>>>8&255,C.pending_buf[C.pending++]=255&W}function K(C,W){var $,k,S=C.max_chain_length,N=C.strstart,G=C.prev_length,q=C.nice_match,U=C.strstart>C.w_size-Z?C.strstart-(C.w_size-Z):0,J=C.window,nt=C.w_mask,et=C.prev,at=C.strstart+D,Tt=J[N+G-1],gt=J[N+G];C.prev_length>=C.good_match&&(S>>=2),q>C.lookahead&&(q=C.lookahead);do{if(J[($=W)+G]===gt&&J[$+G-1]===Tt&&J[$]===J[N]&&J[++$]===J[N+1]){N+=2,$++;do{}while(J[++N]===J[++$]&&J[++N]===J[++$]&&J[++N]===J[++$]&&J[++N]===J[++$]&&J[++N]===J[++$]&&J[++N]===J[++$]&&J[++N]===J[++$]&&J[++N]===J[++$]&&N<at);if(k=D-(at-N),N=at-D,G<k){if(C.match_start=W,q<=(G=k))break;Tt=J[N+G-1],gt=J[N+G]}}}while((W=et[W&nt])>U&&0!=--S);return G<=C.lookahead?G:C.lookahead}function vt(C){var W,$,k,S,N,G,q,U,J,nt,et=C.w_size;do{if(S=C.window_size-C.lookahead-C.strstart,C.strstart>=et+(et-Z)){for(r.arraySet(C.window,C.window,et,et,0),C.match_start-=et,C.strstart-=et,C.block_start-=et,W=$=C.hash_size;k=C.head[--W],C.head[W]=et<=k?k-et:0,--$;);for(W=$=et;k=C.prev[--W],C.prev[W]=et<=k?k-et:0,--$;);S+=et}if(0===C.strm.avail_in)break;if(q=C.window,U=C.strstart+C.lookahead,nt=void 0,(J=S)<(nt=(G=C.strm).avail_in)&&(nt=J),$=0===nt?0:(G.avail_in-=nt,r.arraySet(q,G.input,G.next_in,nt,U),1===G.state.wrap?G.adler=l(G.adler,q,nt,U):2===G.state.wrap&&(G.adler=c(G.adler,q,nt,U)),G.next_in+=nt,G.total_in+=nt,nt),C.lookahead+=$,C.lookahead+C.insert>=3)for(C.ins_h=C.window[N=C.strstart-C.insert],C.ins_h=(C.ins_h<<C.hash_shift^C.window[N+1])&C.hash_mask;C.insert&&(C.ins_h=(C.ins_h<<C.hash_shift^C.window[N+3-1])&C.hash_mask,C.prev[N&C.w_mask]=C.head[C.ins_h],C.head[C.ins_h]=N,N++,C.insert--,!(C.lookahead+C.insert<3)););}while(C.lookahead<Z&&0!==C.strm.avail_in)}function Ot(C,W){for(var $,k;;){if(C.lookahead<Z){if(vt(C),C.lookahead<Z&&0===W)return 1;if(0===C.lookahead)break}if($=0,C.lookahead>=3&&(C.ins_h=(C.ins_h<<C.hash_shift^C.window[C.strstart+3-1])&C.hash_mask,$=C.prev[C.strstart&C.w_mask]=C.head[C.ins_h],C.head[C.ins_h]=C.strstart),0!==$&&C.strstart-$<=C.w_size-Z&&(C.match_length=K(C,$)),C.match_length>=3)if(k=a._tr_tally(C,C.strstart-C.match_start,C.match_length-3),C.lookahead-=C.match_length,C.match_length<=C.max_lazy_match&&C.lookahead>=3){for(C.match_length--;C.strstart++,C.ins_h=(C.ins_h<<C.hash_shift^C.window[C.strstart+3-1])&C.hash_mask,$=C.prev[C.strstart&C.w_mask]=C.head[C.ins_h],C.head[C.ins_h]=C.strstart,0!=--C.match_length;);C.strstart++}else C.strstart+=C.match_length,C.match_length=0,C.ins_h=C.window[C.strstart],C.ins_h=(C.ins_h<<C.hash_shift^C.window[C.strstart+1])&C.hash_mask;else k=a._tr_tally(C,0,C.window[C.strstart]),C.lookahead--,C.strstart++;if(k&&(V(C,!1),0===C.strm.avail_out))return 1}return C.insert=C.strstart<2?C.strstart:2,4===W?(V(C,!0),0===C.strm.avail_out?3:4):C.last_lit&&(V(C,!1),0===C.strm.avail_out)?1:2}function pt(C,W){for(var $,k,S;;){if(C.lookahead<Z){if(vt(C),C.lookahead<Z&&0===W)return 1;if(0===C.lookahead)break}if($=0,C.lookahead>=3&&(C.ins_h=(C.ins_h<<C.hash_shift^C.window[C.strstart+3-1])&C.hash_mask,$=C.prev[C.strstart&C.w_mask]=C.head[C.ins_h],C.head[C.ins_h]=C.strstart),C.prev_length=C.match_length,C.prev_match=C.match_start,C.match_length=2,0!==$&&C.prev_length<C.max_lazy_match&&C.strstart-$<=C.w_size-Z&&(C.match_length=K(C,$),C.match_length<=5&&(1===C.strategy||3===C.match_length&&4096<C.strstart-C.match_start)&&(C.match_length=2)),C.prev_length>=3&&C.match_length<=C.prev_length){for(S=C.strstart+C.lookahead-3,k=a._tr_tally(C,C.strstart-1-C.prev_match,C.prev_length-3),C.lookahead-=C.prev_length-1,C.prev_length-=2;++C.strstart<=S&&(C.ins_h=(C.ins_h<<C.hash_shift^C.window[C.strstart+3-1])&C.hash_mask,$=C.prev[C.strstart&C.w_mask]=C.head[C.ins_h],C.head[C.ins_h]=C.strstart),0!=--C.prev_length;);if(C.match_available=0,C.match_length=2,C.strstart++,k&&(V(C,!1),0===C.strm.avail_out))return 1}else if(C.match_available){if((k=a._tr_tally(C,0,C.window[C.strstart-1]))&&V(C,!1),C.strstart++,C.lookahead--,0===C.strm.avail_out)return 1}else C.match_available=1,C.strstart++,C.lookahead--}return C.match_available&&(k=a._tr_tally(C,0,C.window[C.strstart-1]),C.match_available=0),C.insert=C.strstart<2?C.strstart:2,4===W?(V(C,!0),0===C.strm.avail_out?3:4):C.last_lit&&(V(C,!1),0===C.strm.avail_out)?1:2}function mt(C,W,$,k,S){this.good_length=C,this.max_lazy=W,this.nice_length=$,this.max_chain=k,this.func=S}function St(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=8,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new r.Buf16(1146),this.dyn_dtree=new r.Buf16(122),this.bl_tree=new r.Buf16(78),ot(this.dyn_ltree),ot(this.dyn_dtree),ot(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new r.Buf16(16),this.heap=new r.Buf16(573),ot(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new r.Buf16(573),ot(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function Ct(C){var W;return C&&C.state?(C.total_in=C.total_out=0,C.data_type=2,(W=C.state).pending=0,W.pending_out=0,W.wrap<0&&(W.wrap=-W.wrap),W.status=W.wrap?42:F,C.adler=2===W.wrap?0:1,W.last_flush=0,a._tr_init(W),0):rt(C,y)}function Yt(C){var $,W=Ct(C);return 0===W&&(($=C.state).window_size=2*$.w_size,ot($.head),$.max_lazy_match=n[$.level].max_lazy,$.good_match=n[$.level].good_length,$.nice_match=n[$.level].nice_length,$.max_chain_length=n[$.level].max_chain,$.strstart=0,$.block_start=0,$.lookahead=0,$.insert=0,$.match_length=$.prev_length=2,$.match_available=0,$.ins_h=0),W}function $t(C,W,$,k,S,N){if(!C)return y;var G=1;if(-1===W&&(W=6),k<0?(G=0,k=-k):15<k&&(G=2,k-=16),S<1||9<S||8!==$||k<8||15<k||W<0||9<W||N<0||4<N)return rt(C,y);8===k&&(k=9);var q=new St;return(C.state=q).strm=C,q.wrap=G,q.gzhead=null,q.w_bits=k,q.w_size=1<<q.w_bits,q.w_mask=q.w_size-1,q.hash_bits=S+7,q.hash_size=1<<q.hash_bits,q.hash_mask=q.hash_size-1,q.hash_shift=~~((q.hash_bits+3-1)/3),q.window=new r.Buf8(2*q.w_size),q.head=new r.Buf16(q.hash_size),q.prev=new r.Buf16(q.w_size),q.lit_bufsize=1<<S+6,q.pending_buf_size=4*q.lit_bufsize,q.pending_buf=new r.Buf8(q.pending_buf_size),q.d_buf=1*q.lit_bufsize,q.l_buf=3*q.lit_bufsize,q.level=W,q.strategy=N,q.method=$,Yt(C)}n=[new mt(0,0,0,0,function(C,W){var $=65535;for($>C.pending_buf_size-5&&($=C.pending_buf_size-5);;){if(C.lookahead<=1){if(vt(C),0===C.lookahead&&0===W)return 1;if(0===C.lookahead)break}C.strstart+=C.lookahead,C.lookahead=0;var k=C.block_start+$;if((0===C.strstart||C.strstart>=k)&&(C.lookahead=C.strstart-k,C.strstart=k,V(C,!1),0===C.strm.avail_out)||C.strstart-C.block_start>=C.w_size-Z&&(V(C,!1),0===C.strm.avail_out))return 1}return C.insert=0,4===W?(V(C,!0),0===C.strm.avail_out?3:4):(C.strstart>C.block_start&&V(C,!1),1)}),new mt(4,4,8,4,Ot),new mt(4,5,16,8,Ot),new mt(4,6,32,32,Ot),new mt(4,4,16,16,pt),new mt(8,16,32,32,pt),new mt(8,16,128,128,pt),new mt(8,32,128,256,pt),new mt(32,128,258,1024,pt),new mt(32,258,258,4096,pt)],s.deflateInit=function(C,W){return $t(C,W,8,15,8,0)},s.deflateInit2=$t,s.deflateReset=Yt,s.deflateResetKeep=Ct,s.deflateSetHeader=function(C,W){return C&&C.state?2!==C.state.wrap?y:(C.state.gzhead=W,0):y},s.deflate=function(C,W){var $,k,S,N;if(!C||!C.state||5<W||W<0)return C?rt(C,y):y;if(k=C.state,!C.output||!C.input&&0!==C.avail_in||666===k.status&&4!==W)return rt(C,0===C.avail_out?-5:y);if(k.strm=C,$=k.last_flush,k.last_flush=W,42===k.status)if(2===k.wrap)C.adler=0,st(k,31),st(k,139),st(k,8),k.gzhead?(st(k,(k.gzhead.text?1:0)+(k.gzhead.hcrc?2:0)+(k.gzhead.extra?4:0)+(k.gzhead.name?8:0)+(k.gzhead.comment?16:0)),st(k,255&k.gzhead.time),st(k,k.gzhead.time>>8&255),st(k,k.gzhead.time>>16&255),st(k,k.gzhead.time>>24&255),st(k,9===k.level?2:2<=k.strategy||k.level<2?4:0),st(k,255&k.gzhead.os),k.gzhead.extra&&k.gzhead.extra.length&&(st(k,255&k.gzhead.extra.length),st(k,k.gzhead.extra.length>>8&255)),k.gzhead.hcrc&&(C.adler=c(C.adler,k.pending_buf,k.pending,0)),k.gzindex=0,k.status=69):(st(k,0),st(k,0),st(k,0),st(k,0),st(k,0),st(k,9===k.level?2:2<=k.strategy||k.level<2?4:0),st(k,3),k.status=F);else{var G=8+(k.w_bits-8<<4)<<8;G|=(2<=k.strategy||k.level<2?0:k.level<6?1:6===k.level?2:3)<<6,0!==k.strstart&&(G|=32),G+=31-G%31,k.status=F,it(k,G),0!==k.strstart&&(it(k,C.adler>>>16),it(k,65535&C.adler)),C.adler=1}if(69===k.status)if(k.gzhead.extra){for(S=k.pending;k.gzindex<(65535&k.gzhead.extra.length)&&(k.pending!==k.pending_buf_size||(k.gzhead.hcrc&&k.pending>S&&(C.adler=c(C.adler,k.pending_buf,k.pending-S,S)),L(C),S=k.pending,k.pending!==k.pending_buf_size));)st(k,255&k.gzhead.extra[k.gzindex]),k.gzindex++;k.gzhead.hcrc&&k.pending>S&&(C.adler=c(C.adler,k.pending_buf,k.pending-S,S)),k.gzindex===k.gzhead.extra.length&&(k.gzindex=0,k.status=73)}else k.status=73;if(73===k.status)if(k.gzhead.name){S=k.pending;do{if(k.pending===k.pending_buf_size&&(k.gzhead.hcrc&&k.pending>S&&(C.adler=c(C.adler,k.pending_buf,k.pending-S,S)),L(C),S=k.pending,k.pending===k.pending_buf_size)){N=1;break}N=k.gzindex<k.gzhead.name.length?255&k.gzhead.name.charCodeAt(k.gzindex++):0,st(k,N)}while(0!==N);k.gzhead.hcrc&&k.pending>S&&(C.adler=c(C.adler,k.pending_buf,k.pending-S,S)),0===N&&(k.gzindex=0,k.status=91)}else k.status=91;if(91===k.status)if(k.gzhead.comment){S=k.pending;do{if(k.pending===k.pending_buf_size&&(k.gzhead.hcrc&&k.pending>S&&(C.adler=c(C.adler,k.pending_buf,k.pending-S,S)),L(C),S=k.pending,k.pending===k.pending_buf_size)){N=1;break}N=k.gzindex<k.gzhead.comment.length?255&k.gzhead.comment.charCodeAt(k.gzindex++):0,st(k,N)}while(0!==N);k.gzhead.hcrc&&k.pending>S&&(C.adler=c(C.adler,k.pending_buf,k.pending-S,S)),0===N&&(k.status=103)}else k.status=103;if(103===k.status&&(k.gzhead.hcrc?(k.pending+2>k.pending_buf_size&&L(C),k.pending+2<=k.pending_buf_size&&(st(k,255&C.adler),st(k,C.adler>>8&255),C.adler=0,k.status=F)):k.status=F),0!==k.pending){if(L(C),0===C.avail_out)return k.last_flush=-1,0}else if(0===C.avail_in&&Y(W)<=Y($)&&4!==W)return rt(C,-5);if(666===k.status&&0!==C.avail_in)return rt(C,-5);if(0!==C.avail_in||0!==k.lookahead||0!==W&&666!==k.status){var q=2===k.strategy?function(U,J){for(var nt;;){if(0===U.lookahead&&(vt(U),0===U.lookahead)){if(0===J)return 1;break}if(U.match_length=0,nt=a._tr_tally(U,0,U.window[U.strstart]),U.lookahead--,U.strstart++,nt&&(V(U,!1),0===U.strm.avail_out))return 1}return U.insert=0,4===J?(V(U,!0),0===U.strm.avail_out?3:4):U.last_lit&&(V(U,!1),0===U.strm.avail_out)?1:2}(k,W):3===k.strategy?function(U,J){for(var nt,et,at,Tt,gt=U.window;;){if(U.lookahead<=D){if(vt(U),U.lookahead<=D&&0===J)return 1;if(0===U.lookahead)break}if(U.match_length=0,U.lookahead>=3&&0<U.strstart&&(et=gt[at=U.strstart-1])===gt[++at]&&et===gt[++at]&&et===gt[++at]){Tt=U.strstart+D;do{}while(et===gt[++at]&&et===gt[++at]&&et===gt[++at]&&et===gt[++at]&&et===gt[++at]&&et===gt[++at]&&et===gt[++at]&&et===gt[++at]&&at<Tt);U.match_length=D-(Tt-at),U.match_length>U.lookahead&&(U.match_length=U.lookahead)}if(U.match_length>=3?(nt=a._tr_tally(U,1,U.match_length-3),U.lookahead-=U.match_length,U.strstart+=U.match_length,U.match_length=0):(nt=a._tr_tally(U,0,U.window[U.strstart]),U.lookahead--,U.strstart++),nt&&(V(U,!1),0===U.strm.avail_out))return 1}return U.insert=0,4===J?(V(U,!0),0===U.strm.avail_out?3:4):U.last_lit&&(V(U,!1),0===U.strm.avail_out)?1:2}(k,W):n[k.level].func(k,W);if(3!==q&&4!==q||(k.status=666),1===q||3===q)return 0===C.avail_out&&(k.last_flush=-1),0;if(2===q&&(1===W?a._tr_align(k):5!==W&&(a._tr_stored_block(k,0,0,!1),3===W&&(ot(k.head),0===k.lookahead&&(k.strstart=0,k.block_start=0,k.insert=0))),L(C),0===C.avail_out))return k.last_flush=-1,0}return 4!==W?0:k.wrap<=0?1:(2===k.wrap?(st(k,255&C.adler),st(k,C.adler>>8&255),st(k,C.adler>>16&255),st(k,C.adler>>24&255),st(k,255&C.total_in),st(k,C.total_in>>8&255),st(k,C.total_in>>16&255),st(k,C.total_in>>24&255)):(it(k,C.adler>>>16),it(k,65535&C.adler)),L(C),0<k.wrap&&(k.wrap=-k.wrap),0!==k.pending?0:1)},s.deflateEnd=function(C){var W;return C&&C.state?42!==(W=C.state.status)&&69!==W&&73!==W&&91!==W&&103!==W&&W!==F&&666!==W?rt(C,y):(C.state=null,W===F?rt(C,-3):0):y},s.deflateSetDictionary=function(C,W){var $,k,S,N,G,q,U,J,nt=W.length;if(!C||!C.state||2===(N=($=C.state).wrap)||1===N&&42!==$.status||$.lookahead)return y;for(1===N&&(C.adler=l(C.adler,W,nt,0)),$.wrap=0,nt>=$.w_size&&(0===N&&(ot($.head),$.strstart=0,$.block_start=0,$.insert=0),J=new r.Buf8($.w_size),r.arraySet(J,W,nt-$.w_size,$.w_size,0),W=J,nt=$.w_size),G=C.avail_in,q=C.next_in,U=C.input,C.avail_in=nt,C.next_in=0,C.input=W,vt($);$.lookahead>=3;){for(k=$.strstart,S=$.lookahead-2;$.ins_h=($.ins_h<<$.hash_shift^$.window[k+3-1])&$.hash_mask,$.prev[k&$.w_mask]=$.head[$.ins_h],$.head[$.ins_h]=k,k++,--S;);$.strstart=k,$.lookahead=2,vt($)}return $.strstart+=$.lookahead,$.block_start=$.strstart,$.insert=$.lookahead,$.lookahead=0,$.match_length=$.prev_length=2,$.match_available=0,C.next_in=q,C.input=U,C.avail_in=G,$.wrap=N,0},s.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(t,i,s){i.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(t,i,s){i.exports=function(n,r){var a,l,c,u,h,f,d,y,g,_,m,x,T,E,P,I,M,z,O,D,Z,A,F,v,R;v=n.input,c=(l=n.next_in)+(n.avail_in-5),R=n.output,h=(u=n.next_out)-(r-n.avail_out),f=u+(n.avail_out-257),d=(a=n.state).dmax,y=a.wsize,g=a.whave,_=a.wnext,m=a.window,x=a.hold,T=a.bits,E=a.lencode,P=a.distcode,I=(1<<a.lenbits)-1,M=(1<<a.distbits)-1;t:do{T<15&&(x+=v[l++]<<T,x+=v[l++]<<(T+=8),T+=8),z=E[x&I];e:for(;;){if(x>>>=O=z>>>24,T-=O,0==(O=z>>>16&255))R[u++]=65535&z;else{if(!(16&O)){if(!(64&O)){z=E[(65535&z)+(x&(1<<O)-1)];continue e}if(32&O){a.mode=12;break t}n.msg="invalid literal/length code",a.mode=30;break t}D=65535&z,(O&=15)&&(T<O&&(x+=v[l++]<<T,T+=8),D+=x&(1<<O)-1,x>>>=O,T-=O),T<15&&(x+=v[l++]<<T,x+=v[l++]<<(T+=8),T+=8),z=P[x&M];i:for(;;){if(x>>>=O=z>>>24,T-=O,!(16&(O=z>>>16&255))){if(!(64&O)){z=P[(65535&z)+(x&(1<<O)-1)];continue i}n.msg="invalid distance code",a.mode=30;break t}if(Z=65535&z,T<(O&=15)&&(x+=v[l++]<<T,(T+=8)<O&&(x+=v[l++]<<T,T+=8)),d<(Z+=x&(1<<O)-1)){n.msg="invalid distance too far back",a.mode=30;break t}if(x>>>=O,T-=O,(O=u-h)<Z){if(g<(O=Z-O)&&a.sane){n.msg="invalid distance too far back",a.mode=30;break t}if(F=m,(A=0)===_){if(A+=y-O,O<D){for(D-=O;R[u++]=m[A++],--O;);A=u-Z,F=R}}else if(_<O){if(A+=y+_-O,(O-=_)<D){for(D-=O;R[u++]=m[A++],--O;);if(A=0,_<D){for(D-=O=_;R[u++]=m[A++],--O;);A=u-Z,F=R}}}else if(A+=_-O,O<D){for(D-=O;R[u++]=m[A++],--O;);A=u-Z,F=R}for(;2<D;)R[u++]=F[A++],R[u++]=F[A++],R[u++]=F[A++],D-=3;D&&(R[u++]=F[A++],1<D&&(R[u++]=F[A++]))}else{for(A=u-Z;R[u++]=R[A++],R[u++]=R[A++],R[u++]=R[A++],2<(D-=3););D&&(R[u++]=R[A++],1<D&&(R[u++]=R[A++]))}break}}break}}while(l<c&&u<f);l-=D=T>>3,x&=(1<<(T-=D<<3))-1,n.next_in=l,n.next_out=u,n.avail_in=l<c?c-l+5:5-(l-c),n.avail_out=u<f?f-u+257:257-(u-f),a.hold=x,a.bits=T}},{}],49:[function(t,i,s){var n=t("../utils/common"),r=t("./adler32"),a=t("./crc32"),l=t("./inffast"),c=t("./inftrees"),d=-2;function m(A){return(A>>>24&255)+(A>>>8&65280)+((65280&A)<<8)+((255&A)<<24)}function x(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new n.Buf16(320),this.work=new n.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function T(A){var F;return A&&A.state?(A.total_in=A.total_out=(F=A.state).total=0,A.msg="",F.wrap&&(A.adler=1&F.wrap),F.mode=1,F.last=0,F.havedict=0,F.dmax=32768,F.head=null,F.hold=0,F.bits=0,F.lencode=F.lendyn=new n.Buf32(852),F.distcode=F.distdyn=new n.Buf32(592),F.sane=1,F.back=-1,0):d}function E(A){var F;return A&&A.state?((F=A.state).wsize=0,F.whave=0,F.wnext=0,T(A)):d}function P(A,F){var v,R;return A&&A.state?(R=A.state,F<0?(v=0,F=-F):(v=1+(F>>4),F<48&&(F&=15)),F&&(F<8||15<F)?d:(null!==R.window&&R.wbits!==F&&(R.window=null),R.wrap=v,R.wbits=F,E(A))):d}function I(A,F){var v,R;return A?(R=new x,(A.state=R).window=null,0!==(v=P(A,F))&&(A.state=null),v):d}var M,z,O=!0;function D(A){if(O){var F;for(M=new n.Buf32(512),z=new n.Buf32(32),F=0;F<144;)A.lens[F++]=8;for(;F<256;)A.lens[F++]=9;for(;F<280;)A.lens[F++]=7;for(;F<288;)A.lens[F++]=8;for(c(1,A.lens,0,288,M,0,A.work,{bits:9}),F=0;F<32;)A.lens[F++]=5;c(2,A.lens,0,32,z,0,A.work,{bits:5}),O=!1}A.lencode=M,A.lenbits=9,A.distcode=z,A.distbits=5}function Z(A,F,v,R){var Q,j=A.state;return null===j.window&&(j.wsize=1<<j.wbits,j.wnext=0,j.whave=0,j.window=new n.Buf8(j.wsize)),R>=j.wsize?(n.arraySet(j.window,F,v-j.wsize,j.wsize,0),j.wnext=0,j.whave=j.wsize):(R<(Q=j.wsize-j.wnext)&&(Q=R),n.arraySet(j.window,F,v-R,Q,j.wnext),(R-=Q)?(n.arraySet(j.window,F,v-R,R,0),j.wnext=R,j.whave=j.wsize):(j.wnext+=Q,j.wnext===j.wsize&&(j.wnext=0),j.whave<j.wsize&&(j.whave+=Q))),0}s.inflateReset=E,s.inflateReset2=P,s.inflateResetKeep=T,s.inflateInit=function(A){return I(A,15)},s.inflateInit2=I,s.inflate=function(A,F){var v,R,Q,j,rt,Y,ot,L,V,st,it,K,vt,Ot,pt,mt,St,Ct,Yt,$t,C,W,$,k,S=0,N=new n.Buf8(4),G=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!A||!A.state||!A.output||!A.input&&0!==A.avail_in)return d;12===(v=A.state).mode&&(v.mode=13),rt=A.next_out,Q=A.output,j=A.next_in,R=A.input,L=v.hold,V=v.bits,st=Y=A.avail_in,it=ot=A.avail_out,W=0;t:for(;;)switch(v.mode){case 1:if(0===v.wrap){v.mode=13;break}for(;V<16;){if(0===Y)break t;Y--,L+=R[j++]<<V,V+=8}if(2&v.wrap&&35615===L){N[v.check=0]=255&L,N[1]=L>>>8&255,v.check=a(v.check,N,2,0),V=L=0,v.mode=2;break}if(v.flags=0,v.head&&(v.head.done=!1),!(1&v.wrap)||(((255&L)<<8)+(L>>8))%31){A.msg="incorrect header check",v.mode=30;break}if(8!=(15&L)){A.msg="unknown compression method",v.mode=30;break}if(V-=4,C=8+(15&(L>>>=4)),0===v.wbits)v.wbits=C;else if(C>v.wbits){A.msg="invalid window size",v.mode=30;break}v.dmax=1<<C,A.adler=v.check=1,v.mode=512&L?10:12,V=L=0;break;case 2:for(;V<16;){if(0===Y)break t;Y--,L+=R[j++]<<V,V+=8}if(v.flags=L,8!=(255&v.flags)){A.msg="unknown compression method",v.mode=30;break}if(57344&v.flags){A.msg="unknown header flags set",v.mode=30;break}v.head&&(v.head.text=L>>8&1),512&v.flags&&(N[0]=255&L,N[1]=L>>>8&255,v.check=a(v.check,N,2,0)),V=L=0,v.mode=3;case 3:for(;V<32;){if(0===Y)break t;Y--,L+=R[j++]<<V,V+=8}v.head&&(v.head.time=L),512&v.flags&&(N[0]=255&L,N[1]=L>>>8&255,N[2]=L>>>16&255,N[3]=L>>>24&255,v.check=a(v.check,N,4,0)),V=L=0,v.mode=4;case 4:for(;V<16;){if(0===Y)break t;Y--,L+=R[j++]<<V,V+=8}v.head&&(v.head.xflags=255&L,v.head.os=L>>8),512&v.flags&&(N[0]=255&L,N[1]=L>>>8&255,v.check=a(v.check,N,2,0)),V=L=0,v.mode=5;case 5:if(1024&v.flags){for(;V<16;){if(0===Y)break t;Y--,L+=R[j++]<<V,V+=8}v.length=L,v.head&&(v.head.extra_len=L),512&v.flags&&(N[0]=255&L,N[1]=L>>>8&255,v.check=a(v.check,N,2,0)),V=L=0}else v.head&&(v.head.extra=null);v.mode=6;case 6:if(1024&v.flags&&(Y<(K=v.length)&&(K=Y),K&&(v.head&&(C=v.head.extra_len-v.length,v.head.extra||(v.head.extra=new Array(v.head.extra_len)),n.arraySet(v.head.extra,R,j,K,C)),512&v.flags&&(v.check=a(v.check,R,K,j)),Y-=K,j+=K,v.length-=K),v.length))break t;v.length=0,v.mode=7;case 7:if(2048&v.flags){if(0===Y)break t;for(K=0;C=R[j+K++],v.head&&C&&v.length<65536&&(v.head.name+=String.fromCharCode(C)),C&&K<Y;);if(512&v.flags&&(v.check=a(v.check,R,K,j)),Y-=K,j+=K,C)break t}else v.head&&(v.head.name=null);v.length=0,v.mode=8;case 8:if(4096&v.flags){if(0===Y)break t;for(K=0;C=R[j+K++],v.head&&C&&v.length<65536&&(v.head.comment+=String.fromCharCode(C)),C&&K<Y;);if(512&v.flags&&(v.check=a(v.check,R,K,j)),Y-=K,j+=K,C)break t}else v.head&&(v.head.comment=null);v.mode=9;case 9:if(512&v.flags){for(;V<16;){if(0===Y)break t;Y--,L+=R[j++]<<V,V+=8}if(L!==(65535&v.check)){A.msg="header crc mismatch",v.mode=30;break}V=L=0}v.head&&(v.head.hcrc=v.flags>>9&1,v.head.done=!0),A.adler=v.check=0,v.mode=12;break;case 10:for(;V<32;){if(0===Y)break t;Y--,L+=R[j++]<<V,V+=8}A.adler=v.check=m(L),V=L=0,v.mode=11;case 11:if(0===v.havedict)return A.next_out=rt,A.avail_out=ot,A.next_in=j,A.avail_in=Y,v.hold=L,v.bits=V,2;A.adler=v.check=1,v.mode=12;case 12:if(5===F||6===F)break t;case 13:if(v.last){L>>>=7&V,V-=7&V,v.mode=27;break}for(;V<3;){if(0===Y)break t;Y--,L+=R[j++]<<V,V+=8}switch(v.last=1&L,V-=1,3&(L>>>=1)){case 0:v.mode=14;break;case 1:if(D(v),v.mode=20,6!==F)break;L>>>=2,V-=2;break t;case 2:v.mode=17;break;case 3:A.msg="invalid block type",v.mode=30}L>>>=2,V-=2;break;case 14:for(L>>>=7&V,V-=7&V;V<32;){if(0===Y)break t;Y--,L+=R[j++]<<V,V+=8}if((65535&L)!=(L>>>16^65535)){A.msg="invalid stored block lengths",v.mode=30;break}if(v.length=65535&L,V=L=0,v.mode=15,6===F)break t;case 15:v.mode=16;case 16:if(K=v.length){if(Y<K&&(K=Y),ot<K&&(K=ot),0===K)break t;n.arraySet(Q,R,j,K,rt),Y-=K,j+=K,ot-=K,rt+=K,v.length-=K;break}v.mode=12;break;case 17:for(;V<14;){if(0===Y)break t;Y--,L+=R[j++]<<V,V+=8}if(v.nlen=257+(31&L),V-=5,v.ndist=1+(31&(L>>>=5)),V-=5,v.ncode=4+(15&(L>>>=5)),L>>>=4,V-=4,286<v.nlen||30<v.ndist){A.msg="too many length or distance symbols",v.mode=30;break}v.have=0,v.mode=18;case 18:for(;v.have<v.ncode;){for(;V<3;){if(0===Y)break t;Y--,L+=R[j++]<<V,V+=8}v.lens[G[v.have++]]=7&L,L>>>=3,V-=3}for(;v.have<19;)v.lens[G[v.have++]]=0;if(v.lencode=v.lendyn,v.lenbits=7,W=c(0,v.lens,0,19,v.lencode,0,v.work,$={bits:v.lenbits}),v.lenbits=$.bits,W){A.msg="invalid code lengths set",v.mode=30;break}v.have=0,v.mode=19;case 19:for(;v.have<v.nlen+v.ndist;){for(;mt=(S=v.lencode[L&(1<<v.lenbits)-1])>>>16&255,St=65535&S,!((pt=S>>>24)<=V);){if(0===Y)break t;Y--,L+=R[j++]<<V,V+=8}if(St<16)L>>>=pt,V-=pt,v.lens[v.have++]=St;else{if(16===St){for(k=pt+2;V<k;){if(0===Y)break t;Y--,L+=R[j++]<<V,V+=8}if(L>>>=pt,V-=pt,0===v.have){A.msg="invalid bit length repeat",v.mode=30;break}C=v.lens[v.have-1],K=3+(3&L),L>>>=2,V-=2}else if(17===St){for(k=pt+3;V<k;){if(0===Y)break t;Y--,L+=R[j++]<<V,V+=8}V-=pt,C=0,K=3+(7&(L>>>=pt)),L>>>=3,V-=3}else{for(k=pt+7;V<k;){if(0===Y)break t;Y--,L+=R[j++]<<V,V+=8}V-=pt,C=0,K=11+(127&(L>>>=pt)),L>>>=7,V-=7}if(v.have+K>v.nlen+v.ndist){A.msg="invalid bit length repeat",v.mode=30;break}for(;K--;)v.lens[v.have++]=C}}if(30===v.mode)break;if(0===v.lens[256]){A.msg="invalid code -- missing end-of-block",v.mode=30;break}if(v.lenbits=9,W=c(1,v.lens,0,v.nlen,v.lencode,0,v.work,$={bits:v.lenbits}),v.lenbits=$.bits,W){A.msg="invalid literal/lengths set",v.mode=30;break}if(v.distbits=6,v.distcode=v.distdyn,W=c(2,v.lens,v.nlen,v.ndist,v.distcode,0,v.work,$={bits:v.distbits}),v.distbits=$.bits,W){A.msg="invalid distances set",v.mode=30;break}if(v.mode=20,6===F)break t;case 20:v.mode=21;case 21:if(6<=Y&&258<=ot){A.next_out=rt,A.avail_out=ot,A.next_in=j,A.avail_in=Y,v.hold=L,v.bits=V,l(A,it),rt=A.next_out,Q=A.output,ot=A.avail_out,j=A.next_in,R=A.input,Y=A.avail_in,L=v.hold,V=v.bits,12===v.mode&&(v.back=-1);break}for(v.back=0;mt=(S=v.lencode[L&(1<<v.lenbits)-1])>>>16&255,St=65535&S,!((pt=S>>>24)<=V);){if(0===Y)break t;Y--,L+=R[j++]<<V,V+=8}if(mt&&!(240&mt)){for(Ct=pt,Yt=mt,$t=St;mt=(S=v.lencode[$t+((L&(1<<Ct+Yt)-1)>>Ct)])>>>16&255,St=65535&S,!(Ct+(pt=S>>>24)<=V);){if(0===Y)break t;Y--,L+=R[j++]<<V,V+=8}L>>>=Ct,V-=Ct,v.back+=Ct}if(L>>>=pt,V-=pt,v.back+=pt,v.length=St,0===mt){v.mode=26;break}if(32&mt){v.back=-1,v.mode=12;break}if(64&mt){A.msg="invalid literal/length code",v.mode=30;break}v.extra=15&mt,v.mode=22;case 22:if(v.extra){for(k=v.extra;V<k;){if(0===Y)break t;Y--,L+=R[j++]<<V,V+=8}v.length+=L&(1<<v.extra)-1,L>>>=v.extra,V-=v.extra,v.back+=v.extra}v.was=v.length,v.mode=23;case 23:for(;mt=(S=v.distcode[L&(1<<v.distbits)-1])>>>16&255,St=65535&S,!((pt=S>>>24)<=V);){if(0===Y)break t;Y--,L+=R[j++]<<V,V+=8}if(!(240&mt)){for(Ct=pt,Yt=mt,$t=St;mt=(S=v.distcode[$t+((L&(1<<Ct+Yt)-1)>>Ct)])>>>16&255,St=65535&S,!(Ct+(pt=S>>>24)<=V);){if(0===Y)break t;Y--,L+=R[j++]<<V,V+=8}L>>>=Ct,V-=Ct,v.back+=Ct}if(L>>>=pt,V-=pt,v.back+=pt,64&mt){A.msg="invalid distance code",v.mode=30;break}v.offset=St,v.extra=15&mt,v.mode=24;case 24:if(v.extra){for(k=v.extra;V<k;){if(0===Y)break t;Y--,L+=R[j++]<<V,V+=8}v.offset+=L&(1<<v.extra)-1,L>>>=v.extra,V-=v.extra,v.back+=v.extra}if(v.offset>v.dmax){A.msg="invalid distance too far back",v.mode=30;break}v.mode=25;case 25:if(0===ot)break t;if(v.offset>(K=it-ot)){if((K=v.offset-K)>v.whave&&v.sane){A.msg="invalid distance too far back",v.mode=30;break}vt=K>v.wnext?v.wsize-(K-=v.wnext):v.wnext-K,K>v.length&&(K=v.length),Ot=v.window}else Ot=Q,vt=rt-v.offset,K=v.length;for(ot<K&&(K=ot),ot-=K,v.length-=K;Q[rt++]=Ot[vt++],--K;);0===v.length&&(v.mode=21);break;case 26:if(0===ot)break t;Q[rt++]=v.length,ot--,v.mode=21;break;case 27:if(v.wrap){for(;V<32;){if(0===Y)break t;Y--,L|=R[j++]<<V,V+=8}if(A.total_out+=it-=ot,v.total+=it,it&&(A.adler=v.check=v.flags?a(v.check,Q,it,rt-it):r(v.check,Q,it,rt-it)),it=ot,(v.flags?L:m(L))!==v.check){A.msg="incorrect data check",v.mode=30;break}V=L=0}v.mode=28;case 28:if(v.wrap&&v.flags){for(;V<32;){if(0===Y)break t;Y--,L+=R[j++]<<V,V+=8}if(L!==(4294967295&v.total)){A.msg="incorrect length check",v.mode=30;break}V=L=0}v.mode=29;case 29:W=1;break t;case 30:W=-3;break t;case 31:return-4;default:return d}return A.next_out=rt,A.avail_out=ot,A.next_in=j,A.avail_in=Y,v.hold=L,v.bits=V,(v.wsize||it!==A.avail_out&&v.mode<30&&(v.mode<27||4!==F))&&Z(A,A.output,A.next_out,it-A.avail_out)?(v.mode=31,-4):(it-=A.avail_out,A.total_in+=st-=A.avail_in,A.total_out+=it,v.total+=it,v.wrap&&it&&(A.adler=v.check=v.flags?a(v.check,Q,it,A.next_out-it):r(v.check,Q,it,A.next_out-it)),A.data_type=v.bits+(v.last?64:0)+(12===v.mode?128:0)+(20===v.mode||15===v.mode?256:0),(0==st&&0===it||4===F)&&0===W&&(W=-5),W)},s.inflateEnd=function(A){if(!A||!A.state)return d;var F=A.state;return F.window&&(F.window=null),A.state=null,0},s.inflateGetHeader=function(A,F){var v;return A&&A.state&&2&(v=A.state).wrap?((v.head=F).done=!1,0):d},s.inflateSetDictionary=function(A,F){var v,R=F.length;return A&&A.state?0!==(v=A.state).wrap&&11!==v.mode?d:11===v.mode&&r(1,F,R,0)!==v.check?-3:Z(A,F,R,R)?(v.mode=31,-4):(v.havedict=1,0):d},s.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(t,i,s){var n=t("../utils/common"),r=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],a=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],l=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],c=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];i.exports=function(u,h,f,d,y,g,_,m){var x,T,E,P,I,M,z,O,D,Z=m.bits,A=0,F=0,v=0,R=0,Q=0,j=0,rt=0,Y=0,ot=0,L=0,V=null,st=0,it=new n.Buf16(16),K=new n.Buf16(16),vt=null,Ot=0;for(A=0;A<=15;A++)it[A]=0;for(F=0;F<d;F++)it[h[f+F]]++;for(Q=Z,R=15;1<=R&&0===it[R];R--);if(R<Q&&(Q=R),0===R)return y[g++]=20971520,y[g++]=20971520,m.bits=1,0;for(v=1;v<R&&0===it[v];v++);for(Q<v&&(Q=v),A=Y=1;A<=15;A++)if(Y<<=1,(Y-=it[A])<0)return-1;if(0<Y&&(0===u||1!==R))return-1;for(K[1]=0,A=1;A<15;A++)K[A+1]=K[A]+it[A];for(F=0;F<d;F++)0!==h[f+F]&&(_[K[h[f+F]]++]=F);if(M=0===u?(V=vt=_,19):1===u?(V=r,st-=257,vt=a,Ot-=257,256):(V=l,vt=c,-1),A=v,I=g,rt=F=L=0,E=-1,P=(ot=1<<(j=Q))-1,1===u&&852<ot||2===u&&592<ot)return 1;for(;;){for(z=A-rt,D=_[F]<M?(O=0,_[F]):_[F]>M?(O=vt[Ot+_[F]],V[st+_[F]]):(O=96,0),x=1<<A-rt,v=T=1<<j;y[I+(L>>rt)+(T-=x)]=z<<24|O<<16|D,0!==T;);for(x=1<<A-1;L&x;)x>>=1;if(0!==x?(L&=x-1,L+=x):L=0,F++,0==--it[A]){if(A===R)break;A=h[f+_[F]]}if(Q<A&&(L&P)!==E){for(0===rt&&(rt=Q),I+=v,Y=1<<(j=A-rt);j+rt<R&&!((Y-=it[j+rt])<=0);)j++,Y<<=1;if(ot+=1<<j,1===u&&852<ot||2===u&&592<ot)return 1;y[E=L&P]=Q<<24|j<<16|I-g}}return 0!==L&&(y[I+L]=A-rt<<24|64<<16),m.bits=Q,0}},{"../utils/common":41}],51:[function(t,i,s){i.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(t,i,s){var n=t("../utils/common");function l(S){for(var N=S.length;0<=--N;)S[N]=0}var h=256,f=286,d=30,_=15,M=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],z=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],O=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],D=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],Z=new Array(576);l(Z);var A=new Array(60);l(A);var F=new Array(512);l(F);var v=new Array(256);l(v);var R=new Array(29);l(R);var Q,j,rt,Y=new Array(d);function ot(S,N,G,q,U){this.static_tree=S,this.extra_bits=N,this.extra_base=G,this.elems=q,this.max_length=U,this.has_stree=S&&S.length}function L(S,N){this.dyn_tree=S,this.max_code=0,this.stat_desc=N}function V(S){return S<256?F[S]:F[256+(S>>>7)]}function st(S,N){S.pending_buf[S.pending++]=255&N,S.pending_buf[S.pending++]=N>>>8&255}function it(S,N,G){S.bi_valid>16-G?(S.bi_buf|=N<<S.bi_valid&65535,st(S,S.bi_buf),S.bi_buf=N>>16-S.bi_valid,S.bi_valid+=G-16):(S.bi_buf|=N<<S.bi_valid&65535,S.bi_valid+=G)}function K(S,N,G){it(S,G[2*N],G[2*N+1])}function vt(S,N){for(var G=0;G|=1&S,S>>>=1,G<<=1,0<--N;);return G>>>1}function Ot(S,N,G){var q,U,J=new Array(16),nt=0;for(q=1;q<=_;q++)J[q]=nt=nt+G[q-1]<<1;for(U=0;U<=N;U++){var et=S[2*U+1];0!==et&&(S[2*U]=vt(J[et]++,et))}}function pt(S){var N;for(N=0;N<f;N++)S.dyn_ltree[2*N]=0;for(N=0;N<d;N++)S.dyn_dtree[2*N]=0;for(N=0;N<19;N++)S.bl_tree[2*N]=0;S.dyn_ltree[512]=1,S.opt_len=S.static_len=0,S.last_lit=S.matches=0}function mt(S){8<S.bi_valid?st(S,S.bi_buf):0<S.bi_valid&&(S.pending_buf[S.pending++]=S.bi_buf),S.bi_buf=0,S.bi_valid=0}function St(S,N,G,q){var U=2*N,J=2*G;return S[U]<S[J]||S[U]===S[J]&&q[N]<=q[G]}function Ct(S,N,G){for(var q=S.heap[G],U=G<<1;U<=S.heap_len&&(U<S.heap_len&&St(N,S.heap[U+1],S.heap[U],S.depth)&&U++,!St(N,q,S.heap[U],S.depth));)S.heap[G]=S.heap[U],G=U,U<<=1;S.heap[G]=q}function Yt(S,N,G){var q,U,J,nt,et=0;if(0!==S.last_lit)for(;q=S.pending_buf[S.d_buf+2*et]<<8|S.pending_buf[S.d_buf+2*et+1],U=S.pending_buf[S.l_buf+et],et++,0===q?K(S,U,N):(K(S,(J=v[U])+h+1,N),0!==(nt=M[J])&&it(S,U-=R[J],nt),K(S,J=V(--q),G),0!==(nt=z[J])&&it(S,q-=Y[J],nt)),et<S.last_lit;);K(S,256,N)}function $t(S,N){var G,q,U,J=N.dyn_tree,nt=N.stat_desc.static_tree,et=N.stat_desc.has_stree,at=N.stat_desc.elems,Tt=-1;for(S.heap_len=0,S.heap_max=573,G=0;G<at;G++)0!==J[2*G]?(S.heap[++S.heap_len]=Tt=G,S.depth[G]=0):J[2*G+1]=0;for(;S.heap_len<2;)J[2*(U=S.heap[++S.heap_len]=Tt<2?++Tt:0)]=1,S.depth[U]=0,S.opt_len--,et&&(S.static_len-=nt[2*U+1]);for(N.max_code=Tt,G=S.heap_len>>1;1<=G;G--)Ct(S,J,G);for(U=at;G=S.heap[1],S.heap[1]=S.heap[S.heap_len--],Ct(S,J,1),q=S.heap[1],S.heap[--S.heap_max]=G,S.heap[--S.heap_max]=q,J[2*U]=J[2*G]+J[2*q],S.depth[U]=(S.depth[G]>=S.depth[q]?S.depth[G]:S.depth[q])+1,J[2*G+1]=J[2*q+1]=U,S.heap[1]=U++,Ct(S,J,1),2<=S.heap_len;);S.heap[--S.heap_max]=S.heap[1],function(gt,se){var xi,fe,Ci,zt,cs,gn,ye=se.dyn_tree,ho=se.max_code,Eh=se.stat_desc.static_tree,Th=se.stat_desc.has_stree,Ph=se.stat_desc.extra_bits,fo=se.stat_desc.extra_base,Ei=se.stat_desc.max_length,us=0;for(zt=0;zt<=_;zt++)gt.bl_count[zt]=0;for(ye[2*gt.heap[gt.heap_max]+1]=0,xi=gt.heap_max+1;xi<573;xi++)Ei<(zt=ye[2*ye[2*(fe=gt.heap[xi])+1]+1]+1)&&(zt=Ei,us++),ye[2*fe+1]=zt,ho<fe||(gt.bl_count[zt]++,cs=0,fo<=fe&&(cs=Ph[fe-fo]),gt.opt_len+=(gn=ye[2*fe])*(zt+cs),Th&&(gt.static_len+=gn*(Eh[2*fe+1]+cs)));if(0!==us){do{for(zt=Ei-1;0===gt.bl_count[zt];)zt--;gt.bl_count[zt]--,gt.bl_count[zt+1]+=2,gt.bl_count[Ei]--,us-=2}while(0<us);for(zt=Ei;0!==zt;zt--)for(fe=gt.bl_count[zt];0!==fe;)ho<(Ci=gt.heap[--xi])||(ye[2*Ci+1]!==zt&&(gt.opt_len+=(zt-ye[2*Ci+1])*ye[2*Ci],ye[2*Ci+1]=zt),fe--)}}(S,N),Ot(J,Tt,S.bl_count)}function C(S,N,G){var q,U,J=-1,nt=N[1],et=0,at=7,Tt=4;for(0===nt&&(at=138,Tt=3),N[2*(G+1)+1]=65535,q=0;q<=G;q++)U=nt,nt=N[2*(q+1)+1],++et<at&&U===nt||(et<Tt?S.bl_tree[2*U]+=et:0!==U?(U!==J&&S.bl_tree[2*U]++,S.bl_tree[32]++):et<=10?S.bl_tree[34]++:S.bl_tree[36]++,J=U,Tt=(et=0)===nt?(at=138,3):U===nt?(at=6,3):(at=7,4))}function W(S,N,G){var q,U,J=-1,nt=N[1],et=0,at=7,Tt=4;for(0===nt&&(at=138,Tt=3),q=0;q<=G;q++)if(U=nt,nt=N[2*(q+1)+1],!(++et<at&&U===nt)){if(et<Tt)for(;K(S,U,S.bl_tree),0!=--et;);else 0!==U?(U!==J&&(K(S,U,S.bl_tree),et--),K(S,16,S.bl_tree),it(S,et-3,2)):et<=10?(K(S,17,S.bl_tree),it(S,et-3,3)):(K(S,18,S.bl_tree),it(S,et-11,7));J=U,Tt=(et=0)===nt?(at=138,3):U===nt?(at=6,3):(at=7,4)}}l(Y);var $=!1;function k(S,N,G,q){var U,J,nt;it(S,0+(q?1:0),3),J=N,nt=G,mt(U=S),st(U,nt),st(U,~nt),n.arraySet(U.pending_buf,U.window,J,nt,U.pending),U.pending+=nt}s._tr_init=function(S){$||(function(){var N,G,q,U,J,nt=new Array(16);for(U=q=0;U<28;U++)for(R[U]=q,N=0;N<1<<M[U];N++)v[q++]=U;for(v[q-1]=U,U=J=0;U<16;U++)for(Y[U]=J,N=0;N<1<<z[U];N++)F[J++]=U;for(J>>=7;U<d;U++)for(Y[U]=J<<7,N=0;N<1<<z[U]-7;N++)F[256+J++]=U;for(G=0;G<=_;G++)nt[G]=0;for(N=0;N<=143;)Z[2*N+1]=8,N++,nt[8]++;for(;N<=255;)Z[2*N+1]=9,N++,nt[9]++;for(;N<=279;)Z[2*N+1]=7,N++,nt[7]++;for(;N<=287;)Z[2*N+1]=8,N++,nt[8]++;for(Ot(Z,287,nt),N=0;N<d;N++)A[2*N+1]=5,A[2*N]=vt(N,5);Q=new ot(Z,M,257,f,_),j=new ot(A,z,0,d,_),rt=new ot(new Array(0),O,0,19,7)}(),$=!0),S.l_desc=new L(S.dyn_ltree,Q),S.d_desc=new L(S.dyn_dtree,j),S.bl_desc=new L(S.bl_tree,rt),S.bi_buf=0,S.bi_valid=0,pt(S)},s._tr_stored_block=k,s._tr_flush_block=function(S,N,G,q){var U,J,nt=0;0<S.level?(2===S.strm.data_type&&(S.strm.data_type=function(et){var at,Tt=4093624447;for(at=0;at<=31;at++,Tt>>>=1)if(1&Tt&&0!==et.dyn_ltree[2*at])return 0;if(0!==et.dyn_ltree[18]||0!==et.dyn_ltree[20]||0!==et.dyn_ltree[26])return 1;for(at=32;at<h;at++)if(0!==et.dyn_ltree[2*at])return 1;return 0}(S)),$t(S,S.l_desc),$t(S,S.d_desc),nt=function(et){var at;for(C(et,et.dyn_ltree,et.l_desc.max_code),C(et,et.dyn_dtree,et.d_desc.max_code),$t(et,et.bl_desc),at=18;3<=at&&0===et.bl_tree[2*D[at]+1];at--);return et.opt_len+=3*(at+1)+5+5+4,at}(S),(J=S.static_len+3+7>>>3)<=(U=S.opt_len+3+7>>>3)&&(U=J)):U=J=G+5,G+4<=U&&-1!==N?k(S,N,G,q):4===S.strategy||J===U?(it(S,2+(q?1:0),3),Yt(S,Z,A)):(it(S,4+(q?1:0),3),function(et,at,Tt,gt){var se;for(it(et,at-257,5),it(et,Tt-1,5),it(et,gt-4,4),se=0;se<gt;se++)it(et,et.bl_tree[2*D[se]+1],3);W(et,et.dyn_ltree,at-1),W(et,et.dyn_dtree,Tt-1)}(S,S.l_desc.max_code+1,S.d_desc.max_code+1,nt+1),Yt(S,S.dyn_ltree,S.dyn_dtree)),pt(S),q&&mt(S)},s._tr_tally=function(S,N,G){return S.pending_buf[S.d_buf+2*S.last_lit]=N>>>8&255,S.pending_buf[S.d_buf+2*S.last_lit+1]=255&N,S.pending_buf[S.l_buf+S.last_lit]=255&G,S.last_lit++,0===N?S.dyn_ltree[2*G]++:(S.matches++,N--,S.dyn_ltree[2*(v[G]+h+1)]++,S.dyn_dtree[2*V(N)]++),S.last_lit===S.lit_bufsize-1},s._tr_align=function(S){var N;it(S,2,3),K(S,256,Z),16===(N=S).bi_valid?(st(N,N.bi_buf),N.bi_buf=0,N.bi_valid=0):8<=N.bi_valid&&(N.pending_buf[N.pending++]=255&N.bi_buf,N.bi_buf>>=8,N.bi_valid-=8)}},{"../utils/common":41}],53:[function(t,i,s){i.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(t,i,s){(function(n){!function(r){if(!r.setImmediate){var l,c,u,h,f=1,d={},y=!1,g=r.document,_=Object.getPrototypeOf&&Object.getPrototypeOf(r);_=_&&_.setTimeout?_:r,l="[object process]"==={}.toString.call(r.process)?function(E){process.nextTick(function(){x(E)})}:function(){if(r.postMessage&&!r.importScripts){var E=!0,P=r.onmessage;return r.onmessage=function(){E=!1},r.postMessage("","*"),r.onmessage=P,E}}()?(h="setImmediate$"+Math.random()+"$",r.addEventListener?r.addEventListener("message",T,!1):r.attachEvent("onmessage",T),function(E){r.postMessage(h+E,"*")}):r.MessageChannel?((u=new MessageChannel).port1.onmessage=function(E){x(E.data)},function(E){u.port2.postMessage(E)}):g&&"onreadystatechange"in g.createElement("script")?(c=g.documentElement,function(E){var P=g.createElement("script");P.onreadystatechange=function(){x(E),P.onreadystatechange=null,c.removeChild(P),P=null},c.appendChild(P)}):function(E){setTimeout(x,0,E)},_.setImmediate=function(E){"function"!=typeof E&&(E=new Function(""+E));for(var P=new Array(arguments.length-1),I=0;I<P.length;I++)P[I]=arguments[I+1];return d[f]={callback:E,args:P},l(f),f++},_.clearImmediate=m}function m(E){delete d[E]}function x(E){if(y)setTimeout(x,0,E);else{var P=d[E];if(P){y=!0;try{!function(I){var M=I.callback,z=I.args;switch(z.length){case 0:M();break;case 1:M(z[0]);break;case 2:M(z[0],z[1]);break;case 3:M(z[0],z[1],z[2]);break;default:M.apply(void 0,z)}}(P)}finally{m(E),y=!1}}}}function T(E){E.source===r&&"string"==typeof E.data&&0===E.data.indexOf(h)&&x(+E.data.slice(h.length))}}(typeof self>"u"?void 0===n?this:n:self)}).call(this,typeof ts<"u"?ts:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10);const Ar=Jl(Pr.exports);class Xs{constructor(e,t){w(this,"date",new Date),w(this,"author"),w(this,"guid",Wt.create()),w(this,"viewpoint"),w(this,"modifiedAuthor"),w(this,"modifiedDate"),w(this,"topic"),w(this,"_components"),w(this,"_comment",""),this._components=e,this._comment=t;const i=this._components.get(Nt);this.author=i.config.author}set comment(e){var t;const i=this._components.get(Nt);this._comment=e,this.modifiedDate=new Date,this.modifiedAuthor=i.config.author,null==(t=this.topic)||t.comments.set(this.guid,this)}get comment(){return this._comment}toJSON(){var e,t;const i={guid:this.guid,date:this.date.toISOString(),author:this.author,comment:this.comment,topic_guid:null==(e=this.topic)?void 0:e.guid,viewpoint_guid:this.viewpoint,modified_date:null==(t=this.modifiedDate)?void 0:t.toISOString(),modified_author:this.modifiedAuthor};for(const[s,n]of Object.entries(i))void 0===n&&delete i[s];return i}}const Mr=class Pe{constructor(e){w(this,"guid",Wt.create()),w(this,"title",Pe.default.title),w(this,"creationDate",new Date),w(this,"creationAuthor",""),w(this,"viewpoints",new dt.PG),w(this,"relatedTopics",new dt.PG),w(this,"comments",new dt.jp),w(this,"documentReferences",new dt.PG),w(this,"customData",{}),w(this,"description"),w(this,"serverAssignedId"),w(this,"dueDate"),w(this,"modifiedAuthor"),w(this,"modifiedDate"),w(this,"index"),w(this,"_type",Pe.default.type),w(this,"_status",Pe.default.status),w(this,"_priority",Pe.default.priority),w(this,"_stage",Pe.default.stage),w(this,"_assignedTo",Pe.default.assignedTo),w(this,"_labels",Pe.default.labels??new Set),w(this,"_components"),this._components=e;const t=e.get(Nt);this.creationAuthor=t.config.author,this.relatedTopics.guard=i=>i!==this.guid}set type(e){const t=this._components.get(Nt),{strict:i,types:s}=t.config;(!i||s.has(e))&&(this._type=e)}get type(){return this._type}set status(e){const t=this._components.get(Nt),{strict:i,statuses:s}=t.config;(!i||s.has(e))&&(this._status=e)}get status(){return this._status}set priority(e){const t=this._components.get(Nt);if(e){const{strict:i,priorities:s}=t.config;if(i&&!s.has(e))return;this._priority=e}else this._priority=e}get priority(){return this._priority}set stage(e){const t=this._components.get(Nt);if(e){const{strict:i,stages:s}=t.config;if(i&&!s.has(e))return;this._stage=e}else this._stage=e}get stage(){return this._stage}set assignedTo(e){const t=this._components.get(Nt);if(e){const{strict:i,users:s}=t.config;if(i&&!s.has(e))return;this._assignedTo=e}else this._assignedTo=e}get assignedTo(){return this._assignedTo}set labels(e){const t=this._components.get(Nt),{strict:i,labels:s}=t.config;if(i){const n=new Set;for(const r of e)(!i||s.has(r))&&n.add(r);this._labels=n}else this._labels=e}get labels(){return this._labels}get _managerVersion(){return this._components.get(Nt).config.version}set(e){const t=e,i=this;for(const n in e)"guid"!==n&&n in this&&(i[n]=t[n]);return this._components.get(Nt).list.set(this.guid,this),this}createComment(e,t){const i=new Xs(this._components,e);return i.viewpoint=t,i.topic=this,this.comments.set(i.guid,i),i}createLabelTags(){const e=[...this.labels];if(this._components.get(Nt).config.exportCustomDataAsLabels)for(const i in this.customData){const s=this.customData[i];"string"==typeof s&&e.push(s)}return e}createCommentTags(){return[...this.comments.values()].map(e=>{var t;return{$Guid:e.guid,Date:e.date.toISOString(),Author:e.author,Comment:e.comment,ModifiedAuthor:e.modifiedAuthor,ModifiedDate:null==(t=e.modifiedDate)?void 0:t.toISOString(),Viewpoint:e.viewpoint?{$Guid:e.viewpoint}:void 0}})}createViewpointTags(){const e=this._components.get(_e);return[...this.viewpoints].map(i=>e.list.get(i)).filter(i=>i).map(i=>{const s={$Guid:i.guid,Viewpoint:`${i.title??i.guid}.bcfv`};if(e.snapshots.get(i.snapshot)){const r=e.getSnapshotExtension(i.snapshot);s.Snapshot=`${i.snapshot}.${r}`}return s})}createRelatedTopicTags(){return[...this.relatedTopics].map(e=>({$Guid:e}))}createDocumentReferencesTag(e=this._managerVersion){const t=[];if("3"!==e&&"2.1"!==e)return t;const i=this._components.get(Nt);for(const s of this.documentReferences){const n=i.documents.get(s);if(!n)continue;let r={$Guid:Wt.create(),Description:n.description};"2.1"===e&&(r={...r,$isExternal:"external"===n.type||void 0,ReferencedDocument:"external"===n.type?n.url:`../${n.fileName}`}),"3"===e&&(r={...r,DocumentGuid:"internal"===n.type?s:void 0,Url:"external"===n.type?n.url:void 0}),Object.keys(r).length>0&&t.push(r)}return t}toJSON(){var e,t;const i={guid:this.guid,server_assigned_id:this.serverAssignedId,topic_type:this.type,topic_status:this.status,title:this.title,priority:this.priority,index:this.index,labels:[...this.labels],creation_date:this.creationDate.toISOString(),creation_author:this.creationAuthor,modified_date:null==(e=this.modifiedDate)?void 0:e.toISOString(),modified_author:this.modifiedAuthor,assigned_to:this.assignedTo,stage:this.stage,description:this.description,due_date:null==(t=this.dueDate)?void 0:t.toISOString(),comments:[...this.comments].map(([r,a])=>a.toJSON()),relatedTopics:[...this.relatedTopics].map(r=>({related_topic_guid:r}))},s=this._components.get(_e);for(const r of this.viewpoints){const a=s.list.get(r);a&&(i.viewpoints||(i.viewpoints=[]),i.viewpoints.push(a.toJSON()))}const n=this._components.get(Nt);for(const r of this.documentReferences){const a=n.documents.get(r);a&&(i.document_references||(i.document_references=[]),i.document_references.push("external"===a.type?{guid:Wt.create(),description:a.description,url:a.url}:{guid:Wt.create(),description:a.description,document_guid:r}))}for(const[r,a]of Object.entries(i))(void 0===a||Array.isArray(a)&&0===a.length)&&delete i[r];return i}serialize(){var e,t;const i=this._managerVersion,s={$Guid:this.guid,$TopicType:this.type,$TopicStatus:this.status,$ServerAssignedId:this.serverAssignedId,Title:this.title,CreationAuthor:this.creationAuthor,CreationDate:this.creationDate.toISOString(),Priority:this.priority,Index:"2.1"===i?this.index:void 0,ModifiedDate:null==(e=this.modifiedDate)?void 0:e.toISOString(),ModifiedAuthor:this.modifiedAuthor,DueDate:null==(t=this.dueDate)?void 0:t.toISOString(),AssignedTo:this.assignedTo,Description:this.description,Stage:this.stage,DocumentReferences:"3"===i?{DocumentReference:this.createDocumentReferencesTag(i)}:void 0,RelatedTopics:"3"===i?{RelatedTopic:this.createRelatedTopicTags()}:void 0,RelatedTopic:"2.1"===i?this.createRelatedTopicTags():void 0,Labels:"3"===i?{Label:this.createLabelTags()}:void 0,Viewpoints:"3"===i?{ViewPoint:this.createViewpointTags()}:void 0,Comments:"3"===i?{Comment:this.createCommentTags()}:void 0};"2.1"===i&&(s.Labels=this.createLabelTags(),s.DocumentReference=this.createDocumentReferencesTag(i));const n={Markup:{Topic:s}};return"2.1"===i&&(n.Markup.Viewpoints=this.createViewpointTags(),n.Markup.Comment=this.createCommentTags()),`<?xml version="1.0" encoding="UTF-8"?>\n ${ki.builder.build(n)}`}};w(Mr,"default",{title:"BCF Topic",type:"Issue",status:"Active"});let Sr=Mr;class ic extends oi{constructor(){super(...arguments),w(this,"_config",{version:{type:"Select",options:new Set(["2.1","3"]),multiple:!1,value:""},author:{type:"Text",value:""},types:{type:"TextSet",value:new Set},statuses:{type:"TextSet",value:new Set},priorities:{type:"TextSet",value:new Set},labels:{type:"TextSet",value:new Set},stages:{type:"TextSet",value:new Set},users:{type:"TextSet",value:new Set},includeSelectionTag:{type:"Boolean",value:!1},updateExtensionsOnImport:{type:"Boolean",value:!1},strict:{type:"Boolean",value:!1},includeAllExtensionsOnExport:{type:"Boolean",value:!1},fallbackVersionOnImport:{type:"Select",multiple:!1,options:new Set(["2.1","3"]),value:""},ignoreIncompleteTopicsOnImport:{type:"Boolean",value:!1},exportCustomDataAsLabels:{type:"Boolean",value:!1}})}get version(){return this._config.version.value}set version(e){this._config.version.value=e}get author(){return this._config.author.value}set author(e){this._config.author.value=e}get types(){return this._config.types.value}set types(e){this._config.types.value=e}get statuses(){return this._config.statuses.value}set statuses(e){this._config.statuses.value=e}get priorities(){return this._config.priorities.value}set priorities(e){this._config.priorities.value=e}get labels(){return this._config.labels.value}set labels(e){this._config.labels.value=e}get stages(){return this._config.stages.value}set stages(e){this._config.stages.value=e}get users(){return this._config.users.value}set users(e){this._config.users.value=e}get includeSelectionTag(){return this._config.includeSelectionTag.value}set includeSelectionTag(e){this._config.includeSelectionTag.value=e}get updateExtensionsOnImport(){return this._config.updateExtensionsOnImport.value}set updateExtensionsOnImport(e){this._config.updateExtensionsOnImport.value=e}get strict(){return this._config.strict.value}set strict(e){this._config.strict.value=e}get includeAllExtensionsOnExport(){return this._config.includeAllExtensionsOnExport.value}set includeAllExtensionsOnExport(e){this._config.includeAllExtensionsOnExport.value=e}get fallbackVersionOnImport(){return this._config.fallbackVersionOnImport.value}set fallbackVersionOnImport(e){this._config.fallbackVersionOnImport.value=e}get ignoreIncompleteTopicsOnImport(){return this._config.ignoreIncompleteTopicsOnImport.value}set ignoreIncompleteTopicsOnImport(e){this._config.ignoreIncompleteTopicsOnImport.value=e}get exportCustomDataAsLabels(){return this._config.exportCustomDataAsLabels.value}set exportCustomDataAsLabels(e){this._config.exportCustomDataAsLabels.value=e}}const Qs=class Ti extends Pt{constructor(){super(...arguments),w(this,"enabled",!1),w(this,"_defaultConfig",{author:"jhon.doe@example.com",version:"2.1",types:new Set(["Clash","Failure","Fault","Inquiry","Issue","Remark","Request"]),statuses:new Set(["Active","In Progress","Done","In Review","Closed"]),priorities:new Set(["On hold","Minor","Normal","Major","Critical"]),labels:new Set,stages:new Set,users:new Set,includeSelectionTag:!1,updateExtensionsOnImport:!0,strict:!1,includeAllExtensionsOnExport:!0,fallbackVersionOnImport:"2.1",ignoreIncompleteTopicsOnImport:!1,exportCustomDataAsLabels:!1}),w(this,"config",new ic(this,this.components,"BCF Topics",Ti.uuid)),w(this,"list",new dt.jp),w(this,"documents",new dt.jp),w(this,"onSetup",new X),w(this,"isSetup",!1),w(this,"onBCFImported",new X),w(this,"onDisposed",new X)}setup(e){if(this.isSetup)return;const t={...this._defaultConfig,...e};this.config.version=t.version,this.config.author=t.author,this.config.types=t.types,this.config.statuses=t.statuses,this.config.priorities=t.priorities,this.config.labels=t.labels,this.config.stages=t.stages,this.config.users=t.users,this.config.includeSelectionTag=t.includeSelectionTag,this.config.updateExtensionsOnImport=t.updateExtensionsOnImport,this.config.strict=t.strict,this.config.includeAllExtensionsOnExport=t.includeAllExtensionsOnExport,this.config.fallbackVersionOnImport=t.fallbackVersionOnImport||"",this.config.ignoreIncompleteTopicsOnImport=t.ignoreIncompleteTopicsOnImport,this.isSetup=!0,this.enabled=!0,this.onSetup.trigger()}create(e){const t=new Sr(this.components);return e?(t.guid=e.guid??t.guid,t.set(e)):this.list.set(t.guid,t),t}dispose(){this.list.dispose(),this.onDisposed.trigger(),this.onDisposed.reset()}get usedTypes(){const e=[...this.list].map(([t,i])=>i.type);return new Set(e)}get usedStatuses(){const e=[...this.list].map(([t,i])=>i.status);return new Set(e)}get usedPriorities(){const e=[...this.list].map(([t,i])=>i.priority).filter(t=>t);return new Set(e)}get usedStages(){const e=[...this.list].map(([t,i])=>i.stage).filter(t=>t);return new Set(e)}get usedUsers(){const e=[];for(const[t,i]of this.list){e.push(i.creationAuthor),i.assignedTo&&e.push(i.assignedTo),i.modifiedAuthor&&e.push(i.modifiedAuthor);for(const[s,n]of i.comments)e.push(n.author),n.modifiedAuthor&&e.push(n.modifiedAuthor)}return new Set(e)}get usedLabels(){const e=[];for(const[t,i]of this.list)e.push(...i.labels);return new Set(e)}updateExtensions(){for(const[e,t]of this.list){for(const i of t.labels)this.config.labels.add(i);this.config.types.add(t.type),t.priority&&this.config.priorities.add(t.priority),t.stage&&this.config.stages.add(t.stage),this.config.statuses.add(t.status),this.config.users.add(t.creationAuthor),t.assignedTo&&this.config.users.add(t.assignedTo),t.modifiedAuthor&&this.config.users.add(t.modifiedAuthor);for(const[i,s]of t.comments)this.config.users.add(s.author),s.modifiedAuthor&&this.config.users.add(s.modifiedAuthor)}}updateViewpointReferences(){const e=this.components.get(_e);for(const[t,i]of this.list)for(const s of i.viewpoints)e.list.has(s)||i.viewpoints.delete(s)}export(){var e=this;return(0,H.A)(function*(t=e.list.values()){const i=new Ar;i.file("bcf.version",`<?xml version="1.0" encoding="UTF-8"?>\n <Version VersionId="${e.config.version}" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/buildingSMART/BCF-XML/release_3_0/Schemas/version.xsd"\n xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">\n </Version>`);for(const[r,a]of e.documents.entries())"external"!==a.type&&i.file("2.1"===e.config.version?a.fileName:`documents/${r}`,a.data);if("3"===e.config.version){const r=[];for(const[a,l]of e.documents.entries()){const{type:c,description:u}=l;"external"!==c&&r.push(`<Document Guid="${a}">\n <Filename>${l.fileName}</Filename>\n ${u?`<Description>${u}</Description>`:""}\n </Document>`)}r.length>0&&i.file("documents.xml",`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n <DocumentInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="documents.xsd">\n <Documents>\n ${r.join("\n")}\n </Documents>\n </DocumentInfo>`)}i.file("bcf.extensions",e.serializeExtensions());const s=e.components.get(_e);for(const r of t){const a=i.folder(r.guid);a.file("markup.bcf",r.serialize());for(const l of r.viewpoints){const c=s.list.get(l);if(!c)continue;a.file(`${c.title??c.guid}.bcfv`,yield c.serialize());const h=s.snapshots.get(c.snapshot);if(!h)continue;const f=h?c.snapshot:c.guid,d=s.getSnapshotExtension(c.snapshot);a.file(`${f}.${d}`,h,{binary:!0})}}return yield i.generateAsync({type:"blob"})}).apply(this,arguments)}serializeExtensions(){const e=[...this.config.types].map(a=>`<TopicType>${a}</TopicType>`).join("\n"),t=[...this.config.statuses].map(a=>`<TopicStatus>${a}</TopicStatus>`).join("\n"),i=[...this.config.priorities].map(a=>`<Priority>${a}</Priority>`).join("\n"),s=[...this.config.labels].map(a=>`<TopicLabel>${a}</TopicLabel>`).join("\n"),n=[...this.config.stages].map(a=>`<Stage>${a}</Stage>`).join("\n"),r=[...this.config.users].map(a=>`<User>${a}</User>`).join("\n");return`\n <?xml version="1.0" encoding="UTF-8"?>\n <Extensions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="your-schema-location.xsd">\n ${0!==e.length?`<TopicTypes>\n${e}\n</TopicTypes>`:""}\n ${0!==t.length?`<TopicStatuses>\n${t}\n</TopicStatuses>`:""}\n ${0!==i.length?`<Priorities>\n${i}\n</Priorities>`:""}\n ${0!==s.length?`<TopicLabels>\n${s}\n</TopicLabels>`:""}\n ${0!==n.length?`<Stages>\n${n}\n</Stages>`:""}\n ${0!==r.length?`<Users>\n${r}\n</Users>`:""}\n </Extensions>\n `}processMarkupComment(e){const{Guid:t,Date:i,Author:s,Comment:n,Viewpoint:r}=e;if(!(t&&i&&s&&(Xs||r)))return null;const a=new Xs(this.components,n??"");return a.guid=t,a.date=new Date(i),a.author=s,a.viewpoint=r?.Guid,a.modifiedAuthor=e.ModifiedAuthor,a.modifiedDate=e.ModifiedDate?new Date(e.ModifiedDate):void 0,a}getMarkupComments(e,t){var i;let s;if("2.1"===t&&(s=e.Comment),"3"===t&&(s=null==(i=e.Topic.Comments)?void 0:i.Comment),!s)return[];s=Array.isArray(s)?s:[s];const n=s.map(a=>this.processMarkupComment(a)).filter(a=>a);return Array.isArray(n)?n:[n]}getMarkupLabels(e,t){var i;let s;return"2.1"===t&&(s=e.Topic.Labels),"3"===t&&(s=null==(i=e.Topic.Labels)?void 0:i.Label),s?Array.isArray(s)?s:[s]:[]}getMarkupViewpoints(e,t){var i;let s;return"2.1"===t&&(s=e.Viewpoints),"3"===t&&(s=null==(i=e.Topic.Viewpoints)?void 0:i.ViewPoint),s?(s=Array.isArray(s)?s:[s],s):[]}getMarkupRelatedTopics(e,t){var i;let s;return"2.1"===t&&(s=e.Topic.RelatedTopic),"3"===t&&(s=null==(i=e.Topic.RelatedTopics)?void 0:i.RelatedTopic),s?(Array.isArray(s)?s:[s]).map(r=>r.Guid):[]}getMarkupDocumentReferences(e,t){var i;let s;return"2.1"===t&&(s=e.Topic.DocumentReference),"3"===t&&(s=null==(i=e.Topic.DocumentReferences)?void 0:i.DocumentReference),s?Array.isArray(s)?s:[s]:[]}load(e){var t=this;return(0,H.A)(function*(){var i,s,n;const{fallbackVersionOnImport:r,ignoreIncompleteTopicsOnImport:a,updateExtensionsOnImport:l}=t.config,c=new Ar;yield c.loadAsync(e);const u=Object.values(c.files);let h=r;const f=u.find(E=>E.name.endsWith(".version"));if(f){const E=yield f.async("string"),P=Ti.xmlParser.parse(E).Version.VersionId;h=String(P)}if(!h||"2.1"!==h&&"3"!==h)throw new Error(`BCFTopics: ${h} is not supported.`);const d=u.find(E=>E.name.endsWith(".extensions"));if(l&&d){const E=yield d.async("string");((o,e)=>{if(""===e.trim())return;const t=Nt.xmlParser.parse(e).Extensions;if(!t)return;const{Priorities:i,TopicStatuses:s,TopicTypes:n,Users:r}=t;if(i&&i.Priority){const a=Array.isArray(i.Priority)?i.Priority:[i.Priority];for(const l of a)o.config.priorities.add(l)}if(s&&s.TopicStatus){const a=Array.isArray(s.TopicStatus)?s.TopicStatus:[s.TopicStatus];for(const l of a)o.config.statuses.add(l)}if(n&&n.TopicType){const a=Array.isArray(n.TopicType)?n.TopicType:[n.TopicType];for(const l of a)o.config.types.add(l)}if(r&&r.User){const a=Array.isArray(r.User)?r.User:[r.User];for(const l of a)o.config.users.add(l)}})(t,E)}const y=[],g=t.components.get(_e),_=u.filter(E=>E.name.endsWith(".bcfv"));for(const E of _){const P=yield E.async("string"),I=Ti.xmlParser.parse(P).VisualizationInfo;if(!I){console.warn("Missing VisualizationInfo in Viewpoint");continue}const M={},{Guid:z,ClippingPlanes:O,Components:D,OrthogonalCamera:Z,PerspectiveCamera:A}=I;if(z&&(M.guid=z),D){const v={selection:[],coloring:[],visibility:{default_visibility:!1,exceptions:[],view_setup_hints:{spaces_visible:!1,space_boundaries_visible:!1,openings_visible:!1}}};M.components=v;const{Selection:R,Visibility:Q}=D;if(R&&R.Component){const Y=Array.isArray(R.Component)?R.Component:[R.Component];v.selection=Y.map(ot=>ot.IfcGuid?{ifc_guid:ot.IfcGuid}:null).filter(ot=>null!==ot)}if(Q&&"DefaultVisibility"in Q&&(v.visibility.default_visibility=Q.DefaultVisibility),Q&&Q.Exceptions&&"Component"in Q.Exceptions){const{Component:Y}=Q.Exceptions,ot=Array.isArray(Y)?Y:[Y];v.visibility.exceptions=ot.map(L=>L.IfcGuid?{ifc_guid:L.IfcGuid}:null).filter(L=>null!==L)}let j;"2.1"===h&&(j=D.ViewSetupHints),"3"===h&&(j=null==(i=D.Visibility)?void 0:i.ViewSetupHints),j&&("OpeningsVisible"in j&&(v.visibility.view_setup_hints.openings_visible=j.OpeningsVisible),"SpacesVisible"in j&&(v.visibility.view_setup_hints.spaces_visible=j.SpacesVisible),"SpaceBoundariesVisible"in j&&(v.visibility.view_setup_hints.space_boundaries_visible=j.SpaceBoundariesVisible));const{Coloring:rt}=D;if(rt&&rt.Color){const Y=Array.isArray(rt.Color)?rt.Color:[rt.Color];for(const ot of Y){const{Color:L,Component:V}=ot;if(6!==L.length&&8!==L.length)continue;const st=6===L.length?L:L.slice(2),K=(Array.isArray(V)?V:[V]).map(vt=>vt.IfcGuid?{ifc_guid:vt.IfcGuid}:null).filter(vt=>null!==vt);v.coloring.push({color:st,components:K})}}}if(Z||A){const v=I.PerspectiveCamera??I.OrthogonalCamera,{CameraViewPoint:R,CameraDirection:Q}=v,j=new b.Pq0(Number(R.X),Number(R.Z),Number(-R.Y)),rt=new b.Pq0(Number(Q.X),Number(Q.Z),Number(-Q.Y)),Y={camera_view_point:{x:j.x,y:j.y,z:j.z},camera_direction:{x:rt.x,y:rt.y,z:rt.z},aspect_ratio:"AspectRatio"in v?v.AspectRatio:1,camera_up_vector:{x:0,y:0,z:0}};"ViewToWorldScale"in v&&(M.orthogonal_camera={...Y,view_to_world_scale:v.ViewToWorldScale}),"FieldOfView"in v&&(M.perspective_camera={...Y,field_of_view:v.FieldOfView})}if(O){const R=(Array.isArray(O.ClippingPlane)?O.ClippingPlane:[O.ClippingPlane]).map(({Location:Q,Direction:j})=>({location:{x:Q.x,y:Q.y,z:Q.z},direction:{x:j.x,y:j.y,z:j.z}}));M.clipping_planes=R}const F=new Br(t.components,M);y.push(F)}const m={},x=[],T=u.filter(E=>E.name.endsWith(".bcf"));for(const E of T){const P=yield E.async("string"),I=Ti.xmlParser.parse(P).Markup,M=I.Topic,{Guid:z,TopicType:O,TopicStatus:D,Title:Z,CreationDate:A,CreationAuthor:F}=M;if(a&&!(z&&O&&D&&Z&&A&&F))continue;const v=new Sr(t.components);v.guid=z??v.guid;const R=t.getMarkupRelatedTopics(I,h);m[v.guid]=new Set(R),v.type=O??v.type,v.status=D??v.status,v.title=Z??v.title,v.creationDate=A?new Date(A):v.creationDate,v.creationAuthor=F??v.creationAuthor,v.serverAssignedId=M.ServerAssignedId,v.priority=M.Priority,v.index=M.Index,v.modifiedDate=M.ModifiedDate?new Date(M.ModifiedDate):void 0,v.modifiedAuthor=M.ModifiedAuthor,v.dueDate=M.DueDate?new Date(M.DueDate):void 0,v.assignedTo=M.AssignedTo,v.description=M.Description,v.stage=M.Stage;const Q=t.getMarkupLabels(I,h);for(const st of Q)v.labels.add(st);const j=t.getMarkupComments(I,h);for(const st of j)v.comments.set(st.guid,st);const rt=t.getMarkupViewpoints(I,h);for(const st of rt){if(!st||!st.Guid)continue;const it=g.list.get(st.Guid);if(!it)continue;v.viewpoints.add(it.guid);const K=`${v.guid}/${st.Snapshot}`,vt=u.find(({name:Ot})=>Ot===K);if(vt){const Ot=yield vt.async("arraybuffer"),pt=new Uint8Array(Ot);g.snapshots.set(it.guid,pt),it.snapshot=it.guid??null}}const Y=t.getMarkupDocumentReferences(I,h),ot=u.find(st=>"documents.xml"===st.name);let L=[];const V=yield ot?.async("string");if(V){const st=null==(n=null==(s=ki.parser.parse(V).DocumentInfo)?void 0:s.Documents)?void 0:n.Document;L=Array.isArray(st)?st:[st]}for(const st of Y){const{Description:it,DocumentGuid:K,Url:vt,isExternal:Ot,ReferencedDocument:pt}=st;if(K&&L.length>0){const mt=L.find(({Guid:C})=>C===K),St=u.find(C=>C.name.endsWith(K)),Ct=yield St?.async("uint8array");if(!mt||!Ct)continue;const{Description:Yt,Filename:$t}=mt;t.documents.set(K,{type:"internal",fileName:$t,description:Yt,data:Ct}),v.documentReferences.add(K)}if(vt){const mt=t.documents.add({type:"external",url:vt,description:it});v.documentReferences.add(mt)}if(pt){let mt=null;if(Ot)mt=t.documents.add({type:"external",url:pt,description:it});else{const St=pt.split("/"),Ct=St[St.length-1],Yt=u.find(C=>C.name.endsWith(Ct)),$t=yield Yt?.async("uint8array");if(!$t)continue;mt=t.documents.add({type:"internal",fileName:Ct,data:$t,description:it})}v.documentReferences.add(mt)}}t.list.set(v.guid,v),x.push(v)}for(const E in m){const P=t.list.get(E);if(!P)continue;const I=m[E];for(const M of I)P.relatedTopics.add(M)}return t.onBCFImported.trigger(x),{viewpoints:y,topics:x}})()}};w(Qs,"uuid","de977976-e4f6-4e4f-a01a-204727839802"),w(Qs,"xmlParser",new Es({allowBooleanAttributes:!0,attributeNamePrefix:"",ignoreAttributes:!1,ignoreDeclaration:!0,ignorePiTags:!0,numberParseOptions:{leadingZeros:!0,hex:!0},parseAttributeValue:!0,preserveOrder:!1,processEntities:!1,removeNSPrefix:!0,trimValues:!0}));let Nt=Qs;const Oe=new b.tBo,Ut=new b.Pq0,Te=new b.Pq0,Mt=new b.PTz,Ir={X:new b.Pq0(1,0,0),Y:new b.Pq0(0,1,0),Z:new b.Pq0(0,0,1)},Ks={type:"change"},Or={type:"mouseDown",mode:null},kr={type:"mouseUp",mode:null},zr={type:"objectChange"};class sc extends b.H2z{constructor(e,t=null){super(void 0,t);const i=new cc(this);this._root=i;const s=new uc;this._gizmo=s,i.add(s);const n=new hc;this._plane=n,i.add(n);const r=this;function a(T,E){let P=E;Object.defineProperty(r,T,{get:function(){return void 0!==P?P:E},set:function(I){P!==I&&(P=I,n[T]=I,s[T]=I,r.dispatchEvent({type:T+"-changed",value:I}),r.dispatchEvent(Ks))}}),r[T]=E,n[T]=E,s[T]=E}a("camera",e),a("object",void 0),a("enabled",!0),a("axis",null),a("mode","translate"),a("translationSnap",null),a("rotationSnap",null),a("scaleSnap",null),a("space","world"),a("size",1),a("dragging",!1),a("showX",!0),a("showY",!0),a("showZ",!0),a("minX",-1/0),a("maxX",1/0),a("minY",-1/0),a("maxY",1/0),a("minZ",-1/0),a("maxZ",1/0);const l=new b.Pq0,c=new b.Pq0,u=new b.PTz,h=new b.PTz,f=new b.Pq0,d=new b.PTz,y=new b.Pq0,g=new b.Pq0,_=new b.Pq0,x=new b.Pq0;a("worldPosition",l),a("worldPositionStart",c),a("worldQuaternion",u),a("worldQuaternionStart",h),a("cameraPosition",f),a("cameraQuaternion",d),a("pointStart",y),a("pointEnd",g),a("rotationAxis",_),a("rotationAngle",0),a("eye",x),this._offset=new b.Pq0,this._startNorm=new b.Pq0,this._endNorm=new b.Pq0,this._cameraScale=new b.Pq0,this._parentPosition=new b.Pq0,this._parentQuaternion=new b.PTz,this._parentQuaternionInv=new b.PTz,this._parentScale=new b.Pq0,this._worldScaleStart=new b.Pq0,this._worldQuaternionInv=new b.PTz,this._worldScale=new b.Pq0,this._positionStart=new b.Pq0,this._quaternionStart=new b.PTz,this._scaleStart=new b.Pq0,this._getPointer=nc.bind(this),this._onPointerDown=oc.bind(this),this._onPointerHover=rc.bind(this),this._onPointerMove=ac.bind(this),this._onPointerUp=lc.bind(this),null!==t&&this.connect(t)}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointermove",this._onPointerHover),this.domElement.addEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerHover),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="auto"}getHelper(){return this._root}pointerHover(e){if(void 0===this.object||!0===this.dragging)return;null!==e&&Oe.setFromCamera(e,this.camera);const t=Js(this._gizmo.picker[this.mode],Oe);this.axis=t?t.object.name:null}pointerDown(e){if(void 0!==this.object&&!0!==this.dragging&&(null==e||0===e.button)&&null!==this.axis){null!==e&&Oe.setFromCamera(e,this.camera);const t=Js(this._plane,Oe,!0);t&&(this.object.updateMatrixWorld(),this.object.parent.updateMatrixWorld(),this._positionStart.copy(this.object.position),this._quaternionStart.copy(this.object.quaternion),this._scaleStart.copy(this.object.scale),this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this._worldScaleStart),this.pointStart.copy(t.point).sub(this.worldPositionStart)),this.dragging=!0,Or.mode=this.mode,this.dispatchEvent(Or)}}pointerMove(e){const t=this.axis,i=this.mode,s=this.object;let n=this.space;if("scale"===i?n="local":("E"===t||"XYZE"===t||"XYZ"===t)&&(n="world"),void 0===s||null===t||!1===this.dragging||null!==e&&-1!==e.button)return;null!==e&&Oe.setFromCamera(e,this.camera);const r=Js(this._plane,Oe,!0);if(r){if(this.pointEnd.copy(r.point).sub(this.worldPositionStart),"translate"===i)this._offset.copy(this.pointEnd).sub(this.pointStart),"local"===n&&"XYZ"!==t&&this._offset.applyQuaternion(this._worldQuaternionInv),-1===t.indexOf("X")&&(this._offset.x=0),-1===t.indexOf("Y")&&(this._offset.y=0),-1===t.indexOf("Z")&&(this._offset.z=0),"local"===n&&"XYZ"!==t?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),s.position.copy(this._offset).add(this._positionStart),this.translationSnap&&("local"===n&&(s.position.applyQuaternion(Mt.copy(this._quaternionStart).invert()),-1!==t.search("X")&&(s.position.x=Math.round(s.position.x/this.translationSnap)*this.translationSnap),-1!==t.search("Y")&&(s.position.y=Math.round(s.position.y/this.translationSnap)*this.translationSnap),-1!==t.search("Z")&&(s.position.z=Math.round(s.position.z/this.translationSnap)*this.translationSnap),s.position.applyQuaternion(this._quaternionStart)),"world"===n&&(s.parent&&s.position.add(Ut.setFromMatrixPosition(s.parent.matrixWorld)),-1!==t.search("X")&&(s.position.x=Math.round(s.position.x/this.translationSnap)*this.translationSnap),-1!==t.search("Y")&&(s.position.y=Math.round(s.position.y/this.translationSnap)*this.translationSnap),-1!==t.search("Z")&&(s.position.z=Math.round(s.position.z/this.translationSnap)*this.translationSnap),s.parent&&s.position.sub(Ut.setFromMatrixPosition(s.parent.matrixWorld)))),s.position.x=Math.max(this.minX,Math.min(this.maxX,s.position.x)),s.position.y=Math.max(this.minY,Math.min(this.maxY,s.position.y)),s.position.z=Math.max(this.minZ,Math.min(this.maxZ,s.position.z));else if("scale"===i){if(-1!==t.search("XYZ")){let a=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(a*=-1),Te.set(a,a,a)}else Ut.copy(this.pointStart),Te.copy(this.pointEnd),Ut.applyQuaternion(this._worldQuaternionInv),Te.applyQuaternion(this._worldQuaternionInv),Te.divide(Ut),-1===t.search("X")&&(Te.x=1),-1===t.search("Y")&&(Te.y=1),-1===t.search("Z")&&(Te.z=1);s.scale.copy(this._scaleStart).multiply(Te),this.scaleSnap&&(-1!==t.search("X")&&(s.scale.x=Math.round(s.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),-1!==t.search("Y")&&(s.scale.y=Math.round(s.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),-1!==t.search("Z")&&(s.scale.z=Math.round(s.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if("rotate"===i){this._offset.copy(this.pointEnd).sub(this.pointStart);const a=20/this.worldPosition.distanceTo(Ut.setFromMatrixPosition(this.camera.matrixWorld));let l=!1;"XYZE"===t?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(Ut.copy(this.rotationAxis).cross(this.eye))*a):("X"===t||"Y"===t||"Z"===t)&&(this.rotationAxis.copy(Ir[t]),Ut.copy(Ir[t]),"local"===n&&Ut.applyQuaternion(this.worldQuaternion),Ut.cross(this.eye),0===Ut.length()?l=!0:this.rotationAngle=this._offset.dot(Ut.normalize())*a),("E"===t||l)&&(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this._startNorm.copy(this.pointStart).normalize(),this._endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this._endNorm.cross(this._startNorm).dot(this.eye)<0?1:-1),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),"local"===n&&"E"!==t&&"XYZE"!==t?(s.quaternion.copy(this._quaternionStart),s.quaternion.multiply(Mt.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),s.quaternion.copy(Mt.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),s.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(Ks),this.dispatchEvent(zr)}}pointerUp(e){null!==e&&0!==e.button||(this.dragging&&null!==this.axis&&(kr.mode=this.mode,this.dispatchEvent(kr)),this.dragging=!1,this.axis=null)}dispose(){this.disconnect(),this._root.dispose()}attach(e){return this.object=e,this._root.visible=!0,this}detach(){return this.object=void 0,this.axis=null,this._root.visible=!1,this}reset(){this.enabled&&this.dragging&&(this.object.position.copy(this._positionStart),this.object.quaternion.copy(this._quaternionStart),this.object.scale.copy(this._scaleStart),this.dispatchEvent(Ks),this.dispatchEvent(zr),this.pointStart.copy(this.pointEnd))}getRaycaster(){return Oe}getMode(){return this.mode}setMode(e){this.mode=e}setTranslationSnap(e){this.translationSnap=e}setRotationSnap(e){this.rotationSnap=e}setScaleSnap(e){this.scaleSnap=e}setSize(e){this.size=e}setSpace(e){this.space=e}}function nc(o){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:o.button};{const e=this.domElement.getBoundingClientRect();return{x:(o.clientX-e.left)/e.width*2-1,y:-(o.clientY-e.top)/e.height*2+1,button:o.button}}}function rc(o){if(this.enabled)switch(o.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(o))}}function oc(o){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(o.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(o)),this.pointerDown(this._getPointer(o)))}function ac(o){this.enabled&&this.pointerMove(this._getPointer(o))}function lc(o){this.enabled&&(this.domElement.releasePointerCapture(o.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(o)))}function Js(o,e,t){const i=e.intersectObject(o,!0);for(let s=0;s<i.length;s++)if(i[s].object.visible||t)return i[s];return!1}const is=new b.O9p,xt=new b.Pq0(0,1,0),Fr=new b.Pq0(0,0,0),Dr=new b.kn4,ss=new b.PTz,ns=new b.PTz,he=new b.Pq0,Nr=new b.kn4,gi=new b.Pq0(1,0,0),ke=new b.Pq0(0,1,0),_i=new b.Pq0(0,0,1),rs=new b.Pq0,yi=new b.Pq0,vi=new b.Pq0;class cc extends b.B69{constructor(e){super(),this.isTransformControlsRoot=!0,this.controls=e,this.visible=!1}updateMatrixWorld(e){const t=this.controls;void 0!==t.object&&(t.object.updateMatrixWorld(),null===t.object.parent?console.error("TransformControls: The attached 3D object must be a part of the scene graph."):t.object.parent.matrixWorld.decompose(t._parentPosition,t._parentQuaternion,t._parentScale),t.object.matrixWorld.decompose(t.worldPosition,t.worldQuaternion,t._worldScale),t._parentQuaternionInv.copy(t._parentQuaternion).invert(),t._worldQuaternionInv.copy(t.worldQuaternion).invert()),t.camera.updateMatrixWorld(),t.camera.matrixWorld.decompose(t.cameraPosition,t.cameraQuaternion,t._cameraScale),t.camera.isOrthographicCamera?t.camera.getWorldDirection(t.eye).negate():t.eye.copy(t.cameraPosition).sub(t.worldPosition).normalize(),super.updateMatrixWorld(e)}dispose(){this.traverse(function(e){e.geometry&&e.geometry.dispose(),e.material&&e.material.dispose()})}}class uc extends b.B69{constructor(){super(),this.isTransformControlsGizmo=!0,this.type="TransformControlsGizmo";const e=new b.V9B({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),t=new b.mrM({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),i=e.clone();i.opacity=.15;const s=t.clone();s.opacity=.5;const n=e.clone();n.color.setHex(16711680);const r=e.clone();r.color.setHex(65280);const a=e.clone();a.color.setHex(255);const l=e.clone();l.color.setHex(16711680),l.opacity=.5;const c=e.clone();c.color.setHex(65280),c.opacity=.5;const u=e.clone();u.color.setHex(255),u.opacity=.5;const h=e.clone();h.opacity=.25;const f=e.clone();f.color.setHex(16776960),f.opacity=.25,e.clone().color.setHex(16776960);const y=e.clone();y.color.setHex(7895160);const g=new b.Ho_(0,.04,.1,12);g.translate(0,.05,0);const _=new b.iNn(.08,.08,.08);_.translate(0,.04,0);const m=new b.LoY;m.setAttribute("position",new b.qtW([0,0,0,1,0,0],3));const x=new b.Ho_(.0075,.0075,.5,3);function T(R,Q){const j=new b.O3Y(R,.0075,3,64,Q*Math.PI*2);return j.rotateY(Math.PI/2),j.rotateX(Math.PI/2),j}x.translate(0,.25,0);const P={X:[[new b.eaF(g,n),[.5,0,0],[0,0,-Math.PI/2]],[new b.eaF(g,n),[-.5,0,0],[0,0,Math.PI/2]],[new b.eaF(x,n),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new b.eaF(g,r),[0,.5,0]],[new b.eaF(g,r),[0,-.5,0],[Math.PI,0,0]],[new b.eaF(x,r)]],Z:[[new b.eaF(g,a),[0,0,.5],[Math.PI/2,0,0]],[new b.eaF(g,a),[0,0,-.5],[-Math.PI/2,0,0]],[new b.eaF(x,a),null,[Math.PI/2,0,0]]],XYZ:[[new b.eaF(new b.Ufg(.1,0),h.clone()),[0,0,0]]],XY:[[new b.eaF(new b.iNn(.15,.15,.01),u.clone()),[.15,.15,0]]],YZ:[[new b.eaF(new b.iNn(.15,.15,.01),l.clone()),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new b.eaF(new b.iNn(.15,.15,.01),c.clone()),[.15,0,.15],[-Math.PI/2,0,0]]]},I={X:[[new b.eaF(new b.Ho_(.2,0,.6,4),i),[.3,0,0],[0,0,-Math.PI/2]],[new b.eaF(new b.Ho_(.2,0,.6,4),i),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new b.eaF(new b.Ho_(.2,0,.6,4),i),[0,.3,0]],[new b.eaF(new b.Ho_(.2,0,.6,4),i),[0,-.3,0],[0,0,Math.PI]]],Z:[[new b.eaF(new b.Ho_(.2,0,.6,4),i),[0,0,.3],[Math.PI/2,0,0]],[new b.eaF(new b.Ho_(.2,0,.6,4),i),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new b.eaF(new b.Ufg(.2,0),i)]],XY:[[new b.eaF(new b.iNn(.2,.2,.01),i),[.15,.15,0]]],YZ:[[new b.eaF(new b.iNn(.2,.2,.01),i),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new b.eaF(new b.iNn(.2,.2,.01),i),[.15,0,.15],[-Math.PI/2,0,0]]]},M={START:[[new b.eaF(new b.Ufg(.01,2),s),null,null,null,"helper"]],END:[[new b.eaF(new b.Ufg(.01,2),s),null,null,null,"helper"]],DELTA:[[new b.N1A(function E(){const R=new b.LoY;return R.setAttribute("position",new b.qtW([0,0,0,1,1,1],3)),R}(),s),null,null,null,"helper"]],X:[[new b.N1A(m,s.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new b.N1A(m,s.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new b.N1A(m,s.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},z={XYZE:[[new b.eaF(T(.5,1),y),null,[0,Math.PI/2,0]]],X:[[new b.eaF(T(.5,.5),n)]],Y:[[new b.eaF(T(.5,.5),r),null,[0,0,-Math.PI/2]]],Z:[[new b.eaF(T(.5,.5),a),null,[0,Math.PI/2,0]]],E:[[new b.eaF(T(.75,1),f),null,[0,Math.PI/2,0]]]},O={AXIS:[[new b.N1A(m,s.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},D={XYZE:[[new b.eaF(new b.Gu$(.25,10,8),i)]],X:[[new b.eaF(new b.O3Y(.5,.1,4,24),i),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new b.eaF(new b.O3Y(.5,.1,4,24),i),[0,0,0],[Math.PI/2,0,0]]],Z:[[new b.eaF(new b.O3Y(.5,.1,4,24),i),[0,0,0],[0,0,-Math.PI/2]]],E:[[new b.eaF(new b.O3Y(.75,.1,2,24),i)]]},Z={X:[[new b.eaF(_,n),[.5,0,0],[0,0,-Math.PI/2]],[new b.eaF(x,n),[0,0,0],[0,0,-Math.PI/2]],[new b.eaF(_,n),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new b.eaF(_,r),[0,.5,0]],[new b.eaF(x,r)],[new b.eaF(_,r),[0,-.5,0],[0,0,Math.PI]]],Z:[[new b.eaF(_,a),[0,0,.5],[Math.PI/2,0,0]],[new b.eaF(x,a),[0,0,0],[Math.PI/2,0,0]],[new b.eaF(_,a),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new b.eaF(new b.iNn(.15,.15,.01),u),[.15,.15,0]]],YZ:[[new b.eaF(new b.iNn(.15,.15,.01),l),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new b.eaF(new b.iNn(.15,.15,.01),c),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new b.eaF(new b.iNn(.1,.1,.1),h.clone())]]},A={X:[[new b.eaF(new b.Ho_(.2,0,.6,4),i),[.3,0,0],[0,0,-Math.PI/2]],[new b.eaF(new b.Ho_(.2,0,.6,4),i),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new b.eaF(new b.Ho_(.2,0,.6,4),i),[0,.3,0]],[new b.eaF(new b.Ho_(.2,0,.6,4),i),[0,-.3,0],[0,0,Math.PI]]],Z:[[new b.eaF(new b.Ho_(.2,0,.6,4),i),[0,0,.3],[Math.PI/2,0,0]],[new b.eaF(new b.Ho_(.2,0,.6,4),i),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new b.eaF(new b.iNn(.2,.2,.01),i),[.15,.15,0]]],YZ:[[new b.eaF(new b.iNn(.2,.2,.01),i),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new b.eaF(new b.iNn(.2,.2,.01),i),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new b.eaF(new b.iNn(.2,.2,.2),i),[0,0,0]]]},F={X:[[new b.N1A(m,s.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new b.N1A(m,s.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new b.N1A(m,s.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function v(R){const Q=new b.B69;for(const j in R)for(let rt=R[j].length;rt--;){const Y=R[j][rt][0].clone(),ot=R[j][rt][1],L=R[j][rt][2],V=R[j][rt][3],st=R[j][rt][4];Y.name=j,Y.tag=st,ot&&Y.position.set(ot[0],ot[1],ot[2]),L&&Y.rotation.set(L[0],L[1],L[2]),V&&Y.scale.set(V[0],V[1],V[2]),Y.updateMatrix();const it=Y.geometry.clone();it.applyMatrix4(Y.matrix),Y.geometry=it,Y.renderOrder=1/0,Y.position.set(0,0,0),Y.rotation.set(0,0,0),Y.scale.set(1,1,1),Q.add(Y)}return Q}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=v(P)),this.add(this.gizmo.rotate=v(z)),this.add(this.gizmo.scale=v(Z)),this.add(this.picker.translate=v(I)),this.add(this.picker.rotate=v(D)),this.add(this.picker.scale=v(A)),this.add(this.helper.translate=v(M)),this.add(this.helper.rotate=v(O)),this.add(this.helper.scale=v(F)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(e){const i="local"===("scale"===this.mode?"local":this.space)?this.worldQuaternion:ns;this.gizmo.translate.visible="translate"===this.mode,this.gizmo.rotate.visible="rotate"===this.mode,this.gizmo.scale.visible="scale"===this.mode,this.helper.translate.visible="translate"===this.mode,this.helper.rotate.visible="rotate"===this.mode,this.helper.scale.visible="scale"===this.mode;let s=[];s=s.concat(this.picker[this.mode].children),s=s.concat(this.gizmo[this.mode].children),s=s.concat(this.helper[this.mode].children);for(let n=0;n<s.length;n++){const r=s[n];let a;r.visible=!0,r.rotation.set(0,0,0),r.position.copy(this.worldPosition),a=this.camera.isOrthographicCamera?(this.camera.top-this.camera.bottom)/this.camera.zoom:this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),r.scale.set(1,1,1).multiplyScalar(a*this.size/4),"helper"!==r.tag?(r.quaternion.copy(i),"translate"===this.mode||"scale"===this.mode?("X"===r.name&&Math.abs(xt.copy(gi).applyQuaternion(i).dot(this.eye))>.99&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),"Y"===r.name&&Math.abs(xt.copy(ke).applyQuaternion(i).dot(this.eye))>.99&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),"Z"===r.name&&Math.abs(xt.copy(_i).applyQuaternion(i).dot(this.eye))>.99&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),"XY"===r.name&&Math.abs(xt.copy(_i).applyQuaternion(i).dot(this.eye))<.2&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),"YZ"===r.name&&Math.abs(xt.copy(gi).applyQuaternion(i).dot(this.eye))<.2&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),"XZ"===r.name&&Math.abs(xt.copy(ke).applyQuaternion(i).dot(this.eye))<.2&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1)):"rotate"===this.mode&&(ss.copy(i),xt.copy(this.eye).applyQuaternion(Mt.copy(i).invert()),-1!==r.name.search("E")&&r.quaternion.setFromRotationMatrix(Dr.lookAt(this.eye,Fr,ke)),"X"===r.name&&(Mt.setFromAxisAngle(gi,Math.atan2(-xt.y,xt.z)),Mt.multiplyQuaternions(ss,Mt),r.quaternion.copy(Mt)),"Y"===r.name&&(Mt.setFromAxisAngle(ke,Math.atan2(xt.x,xt.z)),Mt.multiplyQuaternions(ss,Mt),r.quaternion.copy(Mt)),"Z"===r.name&&(Mt.setFromAxisAngle(_i,Math.atan2(xt.y,xt.x)),Mt.multiplyQuaternions(ss,Mt),r.quaternion.copy(Mt))),r.visible=r.visible&&(-1===r.name.indexOf("X")||this.showX),r.visible=r.visible&&(-1===r.name.indexOf("Y")||this.showY),r.visible=r.visible&&(-1===r.name.indexOf("Z")||this.showZ),r.visible=r.visible&&(-1===r.name.indexOf("E")||this.showX&&this.showY&&this.showZ),r.material._color=r.material._color||r.material.color.clone(),r.material._opacity=r.material._opacity||r.material.opacity,r.material.color.copy(r.material._color),r.material.opacity=r.material._opacity,this.enabled&&this.axis&&(r.name===this.axis||this.axis.split("").some(function(l){return r.name===l}))&&(r.material.color.setHex(16776960),r.material.opacity=1)):(r.visible=!1,"AXIS"===r.name?(r.visible=!!this.axis,"X"===this.axis&&(Mt.setFromEuler(is.set(0,0,0)),r.quaternion.copy(i).multiply(Mt),Math.abs(xt.copy(gi).applyQuaternion(i).dot(this.eye))>.9&&(r.visible=!1)),"Y"===this.axis&&(Mt.setFromEuler(is.set(0,0,Math.PI/2)),r.quaternion.copy(i).multiply(Mt),Math.abs(xt.copy(ke).applyQuaternion(i).dot(this.eye))>.9&&(r.visible=!1)),"Z"===this.axis&&(Mt.setFromEuler(is.set(0,Math.PI/2,0)),r.quaternion.copy(i).multiply(Mt),Math.abs(xt.copy(_i).applyQuaternion(i).dot(this.eye))>.9&&(r.visible=!1)),"XYZE"===this.axis&&(Mt.setFromEuler(is.set(0,Math.PI/2,0)),xt.copy(this.rotationAxis),r.quaternion.setFromRotationMatrix(Dr.lookAt(Fr,xt,ke)),r.quaternion.multiply(Mt),r.visible=this.dragging),"E"===this.axis&&(r.visible=!1)):"START"===r.name?(r.position.copy(this.worldPositionStart),r.visible=this.dragging):"END"===r.name?(r.position.copy(this.worldPosition),r.visible=this.dragging):"DELTA"===r.name?(r.position.copy(this.worldPositionStart),r.quaternion.copy(this.worldQuaternionStart),Ut.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),Ut.applyQuaternion(this.worldQuaternionStart.clone().invert()),r.scale.copy(Ut),r.visible=this.dragging):(r.quaternion.copy(i),r.position.copy(this.dragging?this.worldPositionStart:this.worldPosition),this.axis&&(r.visible=-1!==this.axis.search(r.name))))}super.updateMatrixWorld(e)}}class hc extends b.eaF{constructor(){super(new b.bdM(1e5,1e5,2,2),new b.V9B({visible:!1,wireframe:!0,side:b.$EB,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type="TransformControlsPlane"}updateMatrixWorld(e){let t=this.space;switch(this.position.copy(this.worldPosition),"scale"===this.mode&&(t="local"),rs.copy(gi).applyQuaternion("local"===t?this.worldQuaternion:ns),yi.copy(ke).applyQuaternion("local"===t?this.worldQuaternion:ns),vi.copy(_i).applyQuaternion("local"===t?this.worldQuaternion:ns),xt.copy(yi),this.mode){case"translate":case"scale":switch(this.axis){case"X":xt.copy(this.eye).cross(rs),he.copy(rs).cross(xt);break;case"Y":xt.copy(this.eye).cross(yi),he.copy(yi).cross(xt);break;case"Z":xt.copy(this.eye).cross(vi),he.copy(vi).cross(xt);break;case"XY":he.copy(vi);break;case"YZ":he.copy(rs);break;case"XZ":xt.copy(vi),he.copy(yi);break;case"XYZ":case"E":he.set(0,0,0)}break;default:he.set(0,0,0)}0===he.length()?this.quaternion.copy(this.cameraQuaternion):(Nr.lookAt(Ut.set(0,0,0),he,xt),this.quaternion.setFromRotationMatrix(Nr)),super.updateMatrixWorld(e)}}class tn{constructor(e,t,i,s,n,r=5,a=!0){var l;if(w(this,"onDraggingStarted",new X),w(this,"onDraggingEnded",new X),w(this,"onDisposed",new X),w(this,"normal"),w(this,"origin"),w(this,"three",new b.Zcv),w(this,"components"),w(this,"world"),w(this,"type","default"),w(this,"_title","Clipping Plane"),w(this,"_helper"),w(this,"_visible",!0),w(this,"_enabled",!0),w(this,"_controlsActive",!1),w(this,"_arrowBoundBox",new b.eaF),w(this,"_planeMesh"),w(this,"_controls"),w(this,"_hiddenMaterial",new b.V9B({visible:!1})),w(this,"_sizeMultiplier",5),w(this,"_autoScale",!0),w(this,"_visibilityBeforeDisabled",!0),w(this,"notifyManager",()=>{const c=this.components.get(Xe),u=c.list.getKey(this);u&&c.list.set(u,this)}),w(this,"update",()=>{this._enabled&&(this.three.setFromNormalAndCoplanarPoint(this.normal,this._helper.position),this.updateScale())}),w(this,"updateScale",()=>{var c;if(!this.autoScale)return;const u=null==(c=this.world.camera)?void 0:c.three;if(!(u&&u instanceof b.ubm))return;const h=new b.Pq0;u.getWorldPosition(h);const d=h.distanceTo(this._helper.position)/7*this._sizeMultiplier;this._planeMesh.scale.set(d,d,d)}),w(this,"changeDrag",c=>{this._visible=!c.value,this.preventCameraMovement(),this.notifyDraggingChanged(c)}),this.components=e,this.world=t,!t.renderer)throw new Error("The given world must have a renderer!");this.normal=s,this.origin=i,this._sizeMultiplier=r,t.renderer.setPlane(!0,this.three),this._planeMesh=tn.newPlaneMesh(r,n),this._helper=this.newHelper(),this._controls=this.newTransformControls(),this.three.setFromNormalAndCoplanarPoint(s,i),a&&this.toggleControls(!0),this.updateScale(),null!=(l=t.camera)&&l.controls&&t.camera.controls.addEventListener("update",this.updateScale)}set title(e){this._title=e,this.notifyManager()}get title(){return this._title}get autoScale(){return this._autoScale}set autoScale(e){this._autoScale=e,e&&this.updateScale()}get enabled(){return this._enabled}set enabled(e){if(!this.world.isDisposing){if(!this.world.renderer)throw new Error("No renderer found for clipping plane!");this._enabled=e,e?this.visible=this._visibilityBeforeDisabled:(this._visibilityBeforeDisabled=this.visible,this.visible=!1),this.world.renderer.setPlane(e,this.three),this.notifyManager()}}get visible(){return this._visible}set visible(e){this._visible=e,this._controls.getHelper().visible=e,this._helper.visible=e,this.toggleControls(e),this.notifyManager()}get meshes(){return[this._planeMesh,this._arrowBoundBox]}get planeMaterial(){return this._planeMesh.material}set planeMaterial(e){this._planeMesh.material=e}get size(){return this._sizeMultiplier}set size(e){this._sizeMultiplier=e,this.autoScale?this.updateScale():this._planeMesh.scale.set(e,e,e)}get helper(){return this._helper}get controls(){return this._controls}setFromNormalAndCoplanarPoint(e,t){this.reset(),this.normal.equals(e)||(this.normal.copy(e),this._helper.lookAt(e)),this.origin.copy(t),this._helper.position.copy(t),this._helper.updateMatrix(),this.update()}dispose(){var e;this._enabled=!1,null!=(e=this.world.camera)&&e.controls&&this.world.camera.controls.removeEventListener("update",this.updateScale),this.onDraggingStarted.reset(),this.onDraggingEnded.reset(),this._helper.removeFromParent(),this.world.renderer&&this.world.renderer.setPlane(!1,this.three),this._arrowBoundBox.removeFromParent(),this._arrowBoundBox.geometry.dispose(),this._planeMesh.geometry.dispose(),this._controls.getHelper().removeFromParent(),this._controls.dispose(),this.onDisposed.trigger(),this.onDisposed.reset()}reset(){const e=new b.Pq0(1,0,0),t=new b.Pq0;this.normal.equals(e)||(this.normal.copy(e),this._helper.lookAt(e)),this.origin.copy(t),this._helper.position.copy(t),this._helper.updateMatrix()}toggleControls(e){if(e){if(this._controlsActive)return;this._controls.addEventListener("change",this.update),this._controls.addEventListener("dragging-changed",this.changeDrag)}else this._controls.removeEventListener("change",this.update),this._controls.removeEventListener("dragging-changed",this.changeDrag);this._controlsActive=e}newTransformControls(){if(!this.world.renderer)throw new Error("No renderer found for clipping plane!");const i=new sc(this.world.camera.three,this.world.renderer.three.domElement);return this.initializeControls(i),this.world.scene.three.add(i.getHelper()),i}initializeControls(e){e.attach(this._helper),e.showX=!1,e.showY=!1,e.setSpace("local"),this.createArrowBoundingBox(),e.getHelper().children[0].children[0].add(this._arrowBoundBox)}createArrowBoundingBox(){this._arrowBoundBox.geometry=new b.Ho_(.18,.18,1.2),this._arrowBoundBox.material=this._hiddenMaterial,this._arrowBoundBox.rotateX(Math.PI/2),this._arrowBoundBox.updateMatrix(),this._arrowBoundBox.geometry.applyMatrix4(this._arrowBoundBox.matrix)}notifyDraggingChanged(e){e.value?this.onDraggingStarted.trigger():this.onDraggingEnded.trigger()}preventCameraMovement(){this.world.camera.enabled=this._visible}newHelper(){const e=new b.B69;return e.lookAt(this.normal),e.position.copy(this.origin),this._planeMesh.position.z+=.01,e.add(this._planeMesh),this.world.scene.three.add(e),e}static newPlaneMesh(e,t){const i=new b.bdM(1),s=new b.eaF(i,t);return s.scale.set(e,e,e),s}}class dc extends oi{constructor(){super(...arguments),w(this,"_config",{enabled:{value:!0,type:"Boolean"},visible:{value:!0,type:"Boolean"},color:{value:new b.Q1f,type:"Color"},opacity:{type:"Number",interpolable:!0,value:1,min:0,max:1},size:{type:"Number",interpolable:!0,value:2,min:0,max:100}})}get enabled(){return this._config.enabled.value}set enabled(e){this._config.enabled.value=e,this._component.enabled=e}get visible(){return this._config.visible.value}set visible(e){this._config.visible.value=e,this._component.visible=e}get color(){return this._config.color.value}set color(e){this._config.color.value=e,this._component.material.color.copy(e)}get opacity(){return this._config.opacity.value}set opacity(e){this._config.opacity.value=e,this._component.material.opacity=e}get size(){return this._config.size.value}set size(e){this._config.size.value=e,this._component.size=e}}const Rr=class hs extends Pt{constructor(e){super(e),w(this,"onSetup",new X),w(this,"onBeforeDrag",new X),w(this,"onAfterDrag",new X),w(this,"onBeforeCreate",new X),w(this,"onBeforeCancel",new X),w(this,"onAfterCancel",new X),w(this,"onBeforeDelete",new X),w(this,"onAfterCreate",new X),w(this,"onAfterDelete",new X),w(this,"onDisposed",new X),w(this,"isSetup",!1),w(this,"orthogonalY",!1),w(this,"toleranceOrthogonalY",.7),w(this,"autoScalePlanes",!0),w(this,"Type",tn),w(this,"list",new dt.jp),w(this,"config",new dc(this,this.components,"Clipper",hs.uuid)),w(this,"_defaultConfig",{color:new b.Q1f(12255487),opacity:.2,size:2}),w(this,"_material",new b.V9B({color:12255487,side:b.$EB,transparent:!0,opacity:.2})),w(this,"_size",5),w(this,"_enabled",!1),w(this,"_visible",!0),w(this,"onStateChanged",new X),this.components.add(hs.uuid,this),this.setEvents()}get enabled(){return this._enabled}set enabled(e){this._enabled=e,this.onStateChanged.trigger(["enabled"])}get visible(){return this._visible}set visible(e){this._visible=e;for(const[t,i]of this.list)i.visible=e;this.onStateChanged.trigger(["visibility"])}get material(){return this._material}set material(e){this._material=e;for(const[t,i]of this.list)i.planeMaterial=e;this.onStateChanged.trigger(["material"])}get size(){return this._size}set size(e){this._size=e;for(const[t,i]of this.list)i.size=e;this.onStateChanged.trigger(["size"])}setEvents(){this.list.onBeforeDelete.add(({value:e})=>{if(!e.world.renderer)throw new Error("Renderer not found for this plane's world!");e.world.renderer.setPlane(!1,e.three),e.dispose(),this.updateMaterialsAndPlanes(),this.onAfterDelete.trigger(e)})}dispose(){this._enabled=!1,this.components.get(zi).list.delete(this.config.uuid),this.list.clear(),this._material.dispose(),this.onBeforeCreate.reset(),this.onBeforeCancel.reset(),this.onBeforeDelete.reset(),this.onBeforeDrag.reset(),this.onAfterCreate.reset(),this.onAfterCancel.reset(),this.onAfterDelete.reset(),this.onAfterDrag.reset(),this.onDisposed.trigger(hs.uuid),this.onDisposed.reset()}create(e){var t=this;return(0,H.A)(function*(){const n=yield t.components.get(Fi).get(e).castRay();return n?t.createPlaneFromIntersection(e,n):null})()}createFromNormalAndCoplanarPoint(e,t,i){const s=this.newPlane(e,i,t);return this.updateMaterialsAndPlanes(),s}delete(e,t){var i=this;return(0,H.A)(function*(){if(!t){const s=yield i.pickPlane(e);if(!s)return;t=i.list.getKey(s)}t&&i.list.delete(t)})()}deleteAll(e){for(const[t,i]of this.list)(!e||e.has(i.type))&&this.list.delete(t)}setup(e){const t={...this._defaultConfig,...e};this.config.color=t.color,this.config.opacity=t.opacity,this.config.size=t.size,this.isSetup=!0,this.onSetup.trigger()}pickPlane(e){const i=this.components.get(Fi).get(e),s=this.getAllPlaneMeshes(),n=i.castRayToObjects(s);if(n){const r=n.object;return[...this.list.values()].find(a=>a.meshes.includes(r))}}getAllPlaneMeshes(){const e=[];for(const[t,i]of this.list)e.push(...i.meshes);return e}createPlaneFromIntersection(e,t){var i;if(!e.renderer)throw new Error("The given world must have a renderer!");const s=t.point.distanceTo(new b.Pq0(0,0,0)),n=t.normal||(null==(i=t.face)?void 0:i.normal);if(!s||!n)return null;const r=this.getWorldNormal(t,n),a=this.newPlane(e,t.point,r.negate()),l=this.list.get(a);return l.visible=this._visible,l.size=this._size,e.renderer.setPlane(!0,l.three),this.updateMaterialsAndPlanes(),l}getWorldNormal(e,t){const i=e.object;let s=e.object.matrixWorld.clone();if(i instanceof b.ZLX&&void 0!==e.instanceId){const l=new b.kn4;i.getMatrixAt(e.instanceId,l),s=l.multiply(s)}const r=(new b.dwI).getNormalMatrix(s),a=t.clone().applyMatrix3(r).normalize();return this.normalizePlaneDirectionY(a),a}normalizePlaneDirectionY(e){this.orthogonalY&&(e.y>this.toleranceOrthogonalY&&(e.x=0,e.y=1,e.z=0),e.y<-this.toleranceOrthogonalY&&(e.x=0,e.y=-1,e.z=0))}newPlane(e,t,i){const s=new this.Type(this.components,e,t,i,this._material);s.autoScale=this.autoScalePlanes,s.onDraggingStarted.add(()=>this.onBeforeDrag.trigger(s)),s.onDraggingEnded.add(()=>this.onAfterDrag.trigger(s));const n=Wt.create();return this.list.set(n,s),this.onAfterCreate.trigger(s),n}updateMaterialsAndPlanes(){const e=this.components.get(Ps);for(const[t,i]of e.list){if(!i.renderer)continue;i.renderer.updateClippingPlanes();const{clippingPlanes:s}=i.renderer;for(const n of i.meshes)if(n.material)if(Array.isArray(n.material))for(const r of n.material)r.clippingPlanes=s;else n.material.clippingPlanes=s}}};w(Rr,"uuid","66290bc5-18c4-4cd1-9379-2e17a0617611");let Xe=Rr;class Br{constructor(e,t){w(this,"title"),w(this,"guid",Wt.create()),w(this,"clippingPlanes",new dt.PG),w(this,"camera",{aspect_ratio:1,field_of_view:60,camera_direction:{x:0,y:0,z:0},camera_view_point:{x:0,y:0,z:0},camera_up_vector:{x:0,y:1,z:0}}),w(this,"customData",{}),w(this,"exceptionComponents",new dt.PG),w(this,"selectionComponents",new dt.PG),w(this,"componentColors",new dt.jp),w(this,"spacesVisible",!1),w(this,"spaceBoundariesVisible",!1),w(this,"openingsVisible",!1),w(this,"defaultVisibility",!0),w(this,"snapshot",this.guid),w(this,"_components"),w(this,"_world",null),w(this,"notifyUpdate",()=>{this._components.get(_e).list.set(this.guid,this)}),this._components=e,t&&(this.guid=t.guid??this.guid,this.set(t)),this.setEvents()}getSelectionMap(){var e=this;return(0,H.A)(function*(){return yield e._components.get(ut).guidsToModelIdMap([...e.selectionComponents])})()}getExceptionMap(){var e=this;return(0,H.A)(function*(){return yield e._components.get(ut).guidsToModelIdMap([...e.exceptionComponents])})()}get projection(){return"field_of_view"in this.camera?"Perspective":"Orthographic"}get position(){const e=this._components.get(ut),{camera_view_point:t}=this.camera,{x:i,y:s,z:n}=t,r=new b.Pq0(i,s,n);return e.applyBaseCoordinateSystem(r,new b.kn4),r}set position(e){const t=e.clone(),i=this._components.get(ut);e.clone().applyMatrix4(i.baseCoordinationMatrix.clone().invert()),this.camera.camera_view_point={x:t.x,y:t.y,z:t.z}}get direction(){const{camera_direction:e}=this.camera,{x:t,y:i,z:s}=e;return new b.Pq0(t,i,s)}set world(e){this._world=e}get world(){return this._world}get _managerVersion(){return this._components.get(Nt).config.version}get topics(){return[...this._components.get(Nt).list.values()].filter(s=>s.viewpoints.has(this.guid))}setEvents(){this.selectionComponents.onUpdated.add(this.notifyUpdate),this.exceptionComponents.onUpdated.add(this.notifyUpdate),this.clippingPlanes.onUpdated.add(this.notifyUpdate),this.componentColors.onItemSet.add(this.notifyUpdate),this.componentColors.onItemDeleted.add(this.notifyUpdate),this.componentColors.onItemUpdated.add(this.notifyUpdate),this.componentColors.onCleared.add(this.notifyUpdate)}set(e){this.title=e.title;const{components:t,perspective_camera:i,orthogonal_camera:s,clipping_planes:n}=e;if(t){const{selection:r,visibility:a,coloring:l}=t;if(r){this.selectionComponents.clear();for(const{ifc_guid:c}of r)c&&this.selectionComponents.add(c)}if(a){const{default_visibility:c,exceptions:u,view_setup_hints:h}=a;if(void 0!==c&&(this.defaultVisibility=c),u){this.exceptionComponents.clear();for(const{ifc_guid:f}of u)f&&this.exceptionComponents.add(f)}if(h){const{spaces_visible:f,space_boundaries_visible:d,openings_visible:y}=h;void 0!==f&&(this.spacesVisible=f),void 0!==d&&(this.spaceBoundariesVisible=d),void 0!==y&&(this.openingsVisible=y)}}if(l){this.componentColors.clear();for(const c of l){const{color:u,components:h}=c,f=h.map(d=>d.ifc_guid).filter(d=>null!==d);this.componentColors.set(u,f)}}}if((i||s)&&(this.camera=i??s),n&&this.world){const r=this._components.get(Xe);for(const a of n){const{location:l,direction:c}=a,u=new b.Pq0(l.x,l.z,-l.y),h=new b.Pq0(c.x,c.z,-c.y),f=r.createFromNormalAndCoplanarPoint(this.world,h,u);this.clippingPlanes.add(f),r.list.get(f).enabled=!1,r.list.get(f).visible=!1}}this.notifyUpdate()}go(e){var t=this;return(0,H.A)(function*(){if(!t.world)return;const{camera:i}=t.world;if(!(i instanceof qs))throw new Error("Viewpoint: the world's camera component must be of type OrthoPerspectiveCamera to switch between perspective and orthographic projections.");const{transition:s,applyClippings:n,applyVisibility:r,clippingsVisibility:a}={transition:!0,applyClippings:!0,applyVisibility:!0,clippingsVisibility:!0,...e};i.projection.set(t.projection);const l=new b.Pq0(t.camera.camera_view_point.x,t.camera.camera_view_point.y,t.camera.camera_view_point.z),c=new b.Pq0(t.camera.camera_direction.x,t.camera.camera_direction.y,t.camera.camera_direction.z);if(l.equals(new b.Pq0)&&c.equals(new b.Pq0))return;const u=t.position,h=t.direction,d={x:u.x+80*h.x,y:u.y+80*h.y,z:u.z+80*h.z},y=[];n&&t.setClippingState(!0),r&&y.push(t.applyVisibility()),t.setClippingVisibility(a),y.push(i.controls.setLookAt(u.x,u.y,u.z,d.x,d.y,d.z,s)),yield Promise.all(y)})()}updateCamera(){var e=this;return(0,H.A)(function*(t=!0){return new Promise(i=>{if(!e.world)return void i(!1);const{camera:s,renderer:n}=e.world;if(!n)throw new Error("Viewpoint: the world needs to have a renderer!");if(!s.hasCameraControls())throw new Error("Viewpoint: world's camera need camera controls!");const r=new b.Pq0;s.controls.getPosition(r);const a=s.three,l=new b.Pq0(0,0,-1).applyEuler(a.rotation),{width:c,height:u}=n.getSize();let h=c/u;Number.isNaN(h)&&(h=1);const f=e._components.get(ut);r.applyMatrix4(f.baseCoordinationMatrix.clone().invert());const d={aspect_ratio:h,camera_view_point:{x:r.x,y:r.y,z:r.z},camera_direction:{x:l.x,y:l.y,z:l.z},camera_up_vector:{x:0,y:1,z:0}};if(a instanceof b.ubm?e.camera={...d,field_of_view:a.fov}:a instanceof b.qUd&&(e.camera={...d,view_to_world_scale:a.top-a.bottom}),t){const y=e._components.get(_e),g=n.three.domElement;n.three.render(e.world.scene.three,s.three),g.toBlob(function(){var _=(0,H.A)(function*(m){if(m){const x=yield m.arrayBuffer(),T=new Uint8Array(x);y.snapshots.set(e.guid,T)}e.notifyUpdate(),i(!0)});return function(m){return _.apply(this,arguments)}}())}else e.notifyUpdate(),i(!0)})}).apply(this,arguments)}takeSnapshot(){var e=this;return new Promise(t=>{if(!this.world)return void t(!1);const{camera:i,renderer:s}=this.world;if(!s)throw new Error("Viewpoint: the world needs to have a renderer!");const n=this._components.get(_e),r=s.three.domElement;s.three.render(this.world.scene.three,i.three),r.toBlob(function(){var a=(0,H.A)(function*(l){if(l){const c=yield l.arrayBuffer(),u=new Uint8Array(c);n.snapshots.set(e.guid,u)}e.notifyUpdate(),t(!0)});return function(l){return a.apply(this,arguments)}}())})}updateClippingPlanes(){this.clippingPlanes.clear();const e=this._components.get(Xe);for(const[t,i]of e.list)i.enabled&&this.clippingPlanes.add(t)}applyVisibility(){var e=this;return(0,H.A)(function*(){const t=e._components.get(ka);t.set(e.defaultVisibility);const i=yield e.getExceptionMap();t.set(!e.defaultVisibility,i);const s=yield e.getSelectionMap();t.set(!0,s)})()}setColorizationState(e){var t=this;return(0,H.A)(function*(){const i=t._components.get(ut),s=[];if(e)for(const[n,r]of t.componentColors){const a=`#${n}`,l=yield i.guidsToModelIdMap(r);for(const[c,u]of Object.entries(l)){const h=i.list.get(c);h&&s.push(h.highlight([...u],{customId:a,color:new b.Q1f(a),renderedFaces:dt.eB.ONE,opacity:1,transparent:!1}))}}else for(const[n,r]of t.componentColors){const a=yield i.guidsToModelIdMap(r);for(const[l,c]of Object.entries(a)){const u=i.list.get(l);u&&s.push(u.resetHighlight([...c]))}}s.push(i.core.update(!0)),yield Promise.all(s)})()}setClippingState(e){const t=this._components.get(Xe);for(const[i,s]of t.list)s.enabled=e&&this.clippingPlanes.has(i)}setClippingVisibility(e){const t=this._components.get(Xe);for(const i of this.clippingPlanes){const s=t.list.get(i);s&&(s.visible=e)}}createComponentTags(e){var t=this;return(0,H.A)(function*(){var i;const s=t._components.get(ut);let r="";if(t._components.get(Nt).config.includeSelectionTag){const a="selection"===e?yield t.getSelectionMap():yield t.getExceptionMap();for(const l in a){const c=s.list.get(l);if(!c)continue;const u=a[l];for(const h of u){const f=c.getItem(h),d=yield f.getGuid();if(!d)continue;const y=null==(i=yield f.getAttributes())?void 0:i.getValue("Tag");let g=null;y&&(g=`AuthoringToolId="${y}"`),r+=`\n<Component IfcGuid="${d}" ${g??""} />`}}}else r=[...t.selectionComponents].map(a=>`<Component IfcGuid="${a}" />`).join("\n");return r})()}createColorTags(){let e="";for(const[t,i]of this.componentColors.entries())e+=`<Color Color="${t}">\n${i.map(n=>`\n<Component IfcGuid="${n}" />`).join("\n")}\n</Color>`;return 0!==e.length?`<Coloring>\n${e}\n</Coloring>`:"<Coloring />"}toJSON(){const e=this._components.get(Xe),t={guid:this.guid,components:{selection:[...this.selectionComponents].map(n=>({ifc_guid:n,authoring_tool_id:null})),coloring:[...this.componentColors].map(([n,r])=>({color:n,components:r.map(a=>({ifc_guid:a,authoring_tool_id:null}))})),visibility:{default_visibility:this.defaultVisibility,exceptions:[...this.exceptionComponents].map(n=>({ifc_guid:n,authoring_tool_id:null})),view_setup_hints:{spaces_visible:this.spacesVisible,space_boundaries_visible:this.spaceBoundariesVisible,openings_visible:this.openingsVisible}}},clipping_planes:[...this.clippingPlanes].map(n=>{const r=e.list.get(n);if(!r)return null;const a=r._controls.worldPosition??r.origin,{normal:l}=r;return{location:{x:a.x,y:-a.z,z:a.y},direction:{x:l.x,y:-l.z,z:l.y}}}).filter(n=>null!==n)};"field_of_view"in this.camera?t.perspective_camera=this.camera:t.orthogonal_camera=this.camera;const i=this._components.get(_e),s=i.snapshots.get(this.snapshot);if(s){const n=s.toString(),r=btoa(n),a=i.getSnapshotExtension(this.snapshot);t.snapshot={snapshot_type:a,snapshot_data:r}}return t}serialize(){var e=this;return(0,H.A)(function*(t=e._managerVersion){const i=e._components.get(ut),s=e.position;s.applyMatrix4(i.baseCoordinationMatrix.clone().invert());const n=e.direction;n.normalize();const r=(new b.kn4).makeRotationX(Math.PI/2),a=n.clone().applyMatrix4(r);a.normalize();const l=`<CameraViewPoint>\n <X>${s.x}</X>\n <Y>${-s.z}</Y>\n <Z>${s.y}</Z>\n </CameraViewPoint>`,c=`<CameraDirection>\n <X>${n.x}</X>\n <Y>${-n.z}</Y>\n <Z>${n.y}</Z>\n </CameraDirection>`,u=`<CameraUpVector>\n <X>${a.x}</X>\n <Y>${-a.z}</Y>\n <Z>${a.y}</Z>\n </CameraUpVector>`,h=`<AspectRatio>${e.camera.aspect_ratio}</AspectRatio>`;let f="";"view_to_world_scale"in e.camera?f=`<OrthogonalCamera>\n ${l}\n ${c}\n ${u}\n ${h}\n <ViewToWorldScale>${e.camera.view_to_world_scale}</ViewToWorldScale>\n </OrthogonalCamera>`:"field_of_view"in e.camera&&(f=`<PerspectiveCamera>\n ${l}\n ${c}\n ${u}\n ${h}\n <FieldOfView>${e.camera.field_of_view}</FieldOfView>\n </PerspectiveCamera>`);const d=`<ViewSetupHints SpacesVisible="${e.spacesVisible??!1}" SpaceBoundariesVisible="${e.spaceBoundariesVisible??!1}" OpeningsVisible="${e.openingsVisible??!1}" />`,y=(yield e.createComponentTags("selection")).trim(),g=(yield e.createComponentTags("exception")).trim(),_=e.createColorTags();return`<?xml version="1.0" encoding="UTF-8"?>\n <VisualizationInfo Guid="${e.guid}">\n <Components>\n ${"2.1"===t?d:""}\n ${0!==y.length?`<Selection>${y}</Selection>`:""}\n <Visibility DefaultVisibility="${e.defaultVisibility}">\n ${"3"===t?d:""}\n ${0!==g.length?`<Exceptions>${g}</Exceptions>`:""}\n </Visibility>\n ${_}\n </Components>\n ${f}\n </VisualizationInfo>`}).apply(this,arguments)}}class fc extends oi{constructor(){super(...arguments),w(this,"_config",{overwriteColors:{value:!1,type:"Boolean"}})}get overwriteColors(){return this._config.overwriteColors.value}set overwriteColors(e){this._config.overwriteColors.value=e}}const Lr=class bn extends Pt{constructor(e){super(e),w(this,"enabled",!0),w(this,"world",null),w(this,"list",new dt.jp),w(this,"snapshots",new dt.jp),w(this,"isSetup",!1),w(this,"onSetup",new X),w(this,"config",new fc(this,this.components,"Viewpoints",bn.uuid)),w(this,"onDisposed",new X),e.add(bn.uuid,this)}create(e){const t=new Br(this.components,e);return t.world=this.world,e||this.list.set(t.guid,t),t}getSnapshotExtension(e){let t="jpeg";const i=this.snapshots.get(e);if(!i)return t;const s=i.subarray(0,4);let n="";for(let r=0;r<s.length;r++)n+=s[r].toString(16);return n.startsWith("89504e47")&&(t="png"),n.startsWith("ffd8ffe")&&(t="jpeg"),t}setup(){}dispose(){this.list.dispose(),this.onDisposed.trigger(),this.onDisposed.reset()}};w(Lr,"uuid","ee867824-a796-408d-8aa0-4e5962a83c66");let _e=Lr;class Vr{constructor(e,t){w(this,"_components"),w(this,"_cameraOffset",10),w(this,"_planeHelper"),w(this,"_farPlaneHelper"),w(this,"_cameraHelper"),w(this,"onStateChanged",new X),w(this,"onUpdated",new X),w(this,"onDisposed",new X),w(this,"camera"),w(this,"plane",new b.Zcv),w(this,"farPlane",new b.Zcv),w(this,"id",Wt.create()),w(this,"_open",!1),w(this,"_range",pc.defaultRange),w(this,"_world",null),w(this,"_helpersVisible",!1),w(this,"_planesEnabled",!1),this._components=e,this.camera=new qs(this._components);const{threeOrtho:i}=this.camera;if(t?.id&&(this.id=t.id),t?.normal&&t?.point){const{normal:s,point:n}=t;this.plane.setFromNormalAndCoplanarPoint(s,n)}this._cameraHelper=new b.WTh(i),this._planeHelper=new b.ZM4(this.plane,50),this._farPlaneHelper=new b.ZM4(this.farPlane,50),this.farPlaneHelperColor=new b.Q1f("blue"),this.update()}get _planeNormalOpposite(){return this.plane.normal.clone().negate()}get _planePosition(){return this.plane.normal.clone().multiplyScalar(-this.plane.constant)}get _cameraPosition(){return this._planePosition.addScaledVector(this._planeNormalOpposite,this._cameraOffset)}set open(e){this._open=e,this.onStateChanged.trigger(["open"])}get open(){return this._open}set planeHelperColor(e){!Array.isArray(this._planeHelper.material)&&"color"in this._planeHelper.material&&this._planeHelper.material.color instanceof b.Q1f&&(this._planeHelper.material.color=e)}set farPlaneHelperColor(e){!Array.isArray(this._farPlaneHelper.material)&&"color"in this._farPlaneHelper.material&&this._farPlaneHelper.material.color instanceof b.Q1f&&(this._farPlaneHelper.material.color=e)}set range(e){this._range=e,this.update()}get range(){return this._range}set distance(e){this.plane.constant=e,this.update()}get distance(){return this.plane.constant}set world(e){this._world=e,this.camera.currentWorld=e,e&&(this.camera.projection.set("Orthographic"),this.camera.set("Plan"),this.camera.controls.dollySpeed=6,this.camera.controls.restThreshold=.005,this.update())}get world(){return this._world}set helpersVisible(e){if(!e)return this._helpersVisible=e,this._planeHelper.removeFromParent(),this._farPlaneHelper.removeFromParent(),void this._cameraHelper.removeFromParent();this.world&&(this._helpersVisible=e,this.world.scene.three.add(this._planeHelper,this._farPlaneHelper))}get helpersVisible(){return this._helpersVisible}set planesEnabled(e){const{world:t}=this;if(!t)return;const{renderer:i}=t;i&&(i.setPlane(e,this.plane),i.setPlane(e,this.farPlane),this._planesEnabled=e)}get planesEnabled(){return this._planesEnabled}dispose(){this.helpersVisible=!1;const e=this._components.get(si);e.destroy(this._planeHelper),e.destroy(this._farPlaneHelper),e.destroy(this._cameraHelper),this.camera.dispose(),this.onDisposed.trigger()}update(){if(this.world){const e=this._cameraPosition,t=this._planePosition;this.camera.controls.setLookAt(e.x,e.y,e.z,t.x,t.y,t.z,!1)}this.farPlane.normal.copy(this._planeNormalOpposite),this.farPlane.constant=this.range-this.plane.constant,this.onUpdated.trigger()}flip(){this.plane.normal.negate(),this.update()}}const en=class Eo extends Pt{constructor(e){super(e),w(this,"list",new dt.jp),w(this,"enabled",!0),w(this,"world",null),w(this,"_fragmentsUpdateEvent",()=>{this.components.get(ut).core.update(!0)}),e.add(Eo.uuid,this),this.setupEvents()}get hasOpenViews(){return[...this.list.values()].some(e=>e.open)}setupEvents(){this.list.onBeforeDelete.add(({key:e,value:t})=>{t.open&&this.close(e),t.dispose()})}create(e,t,i){const s=new Vr(this.components,{id:i?.id,normal:e,point:t});return s.world=i?.world??this.world,this.list.set(s.id,s),s}createFromPlane(e,t){const i=new Vr(this.components,{id:t?.id});return i.plane.copy(e),i.update(),i.world=t?.world??this.world,this.list.set(i.id,i),i}createFromIfcStoreys(e){var t=this;return(0,H.A)(function*(){const i=[],s=t.components.get(ut),n=void 0===e?.offset?.25:e.offset;for(const[r,a]of s.list){if(e&&e.modelIds&&!e.modelIds.some(f=>f.test(r)))continue;const l=Object.values(yield a.getItemsOfCategories([/BUILDINGSTOREY/])).flat();if(0===l.length)continue;const c=yield a.getItemsData(l),[,u]=yield a.getCoordinates(),h=new b.Pq0(0,-1,0);for(const f of c){if(!("value"in f.Name)||!("value"in f.Elevation))continue;const{value:d}=f.Name;if(e?.storeyNames&&!e.storeyNames.some(m=>m.test(d)))continue;const g=new b.Zcv(h,f.Elevation.value+u+n),_=t.createFromPlane(g,{id:d,world:e?.world});i.push(_)}}return i})()}createElevations(e){const t=[],i=this.components.get(ut),s=void 0!==e?.combine&&e.combine,n=e?.namingCallback??(a=>({front:s?"Front":`${a}: Front`,back:s?"Back":`${a}: Back`,left:s?"Left":`${a}: Left`,right:s?"Right":`${a}: Right`}));let r=[];for(const[a,l]of i.list)e&&e.modelIds&&!e.modelIds.some(c=>c.test(a))||r.push({id:a,box:l.box});if(0===r.length)return t;if(s){const a=this.components.get(Qn);a.list.clear(),a.list.add(...r.map(c=>c.box)),r=[{id:"combined",box:a.get()}]}for(const{id:a,box:l}of r){const{min:c,max:u}=l,h=Math.abs(u.x-c.x),f=Math.abs(u.z-c.z),d=new b.Pq0;l.getCenter(d);const y=new b.Zcv(new b.Pq0(0,0,-1),u.z),g=new b.Zcv(new b.Pq0(0,0,1),-c.z),_=new b.Zcv(new b.Pq0(-1,0,0),u.x),m=new b.Zcv(new b.Pq0(1,0,0),-c.x),{front:x,back:T,left:E,right:P}=n(a),I=this.createFromPlane(y,{id:x,world:e?.world});I.range=f;const M=this.createFromPlane(g,{id:T,world:e?.world});M.range=f;const z=this.createFromPlane(_,{id:E,world:e?.world});z.range=h;const O=this.createFromPlane(m,{id:P,world:e?.world});O.range=h,t.push(I,M,z,O)}return t}open(e){const t=this.list.get(e);if(!t)throw new Error(`Views: the view with id ${e} doesn't exist.`);if(t.open)return;const{world:i}=t;if(!i)throw new Error(`Views: no world found for view with id ${e}.`);const{renderer:s}=i;if(!s)throw new Error(`Views: no renderer found for world with id ${i.uuid}.`);for(const[,n]of this.list)n.world===i&&this.close(n.id);s.setPlane(!0,t.plane),s.setPlane(!0,t.farPlane),t.camera.controls.addEventListener("rest",this._fragmentsUpdateEvent),i.camera=t.camera,t.open=!0}close(e){let t;if(t=e?this.list.get(e):[...this.list.values()].find(n=>n.open),e&&!t)throw new Error(`Views: the view with id ${e} doesn't exist.`);if(!t||!t.open)return;const{world:i}=t;if(!i)throw new Error(`Views: no world found for view with id ${e}.`);const{renderer:s}=i;if(!s)throw new Error(`Views: no renderer found for world with id ${i.uuid}.`);s.setPlane(!1,t.plane),s.setPlane(!1,t.farPlane),t.camera.controls.removeEventListener("rest",this._fragmentsUpdateEvent),i.useDefaultCamera(),t.open=!1}};w(en,"uuid","fb22f1f5-6598-4664-a11d-de8963ae420f"),w(en,"defaultRange",15);let pc=en;class Qe{constructor(e){w(this,"cardinality","required"),w(this,"instructions"),w(this,"evalRequirement",(t,i,s,n)=>{const r={parameter:s,currentValue:t,requiredValue:i,pass:!1};n&&this.addCheckResult(r,n);let a=!1;if("simple"===i.type&&(a=t===i.parameter),"enumeration"===i.type&&(a=i.parameter.includes(t)),"pattern"===i.type&&(a=new RegExp(i.parameter).test(String(t))),"length"===i.type){const{min:l,length:c,max:u}=i.parameter;void 0!==c&&(a=String(t).length===c),void 0!==l&&(a=String(t).length>=l),void 0!==u&&(a=String(t).length<=u)}if("bounds"===i.type&&"number"==typeof t){const{min:l,minInclusive:c,max:u,maxInclusive:h}=i.parameter;let f=!0,d=!0;void 0!==l&&(f=c?t>=l:t>l),void 0!==u&&(d=h?t<=u:t<u),a=f&&d}return"prohibited"===this.cardinality&&(a=!a),"optional"===this.cardinality&&(a=!0),r.pass=a,r.pass}),this._components=e}addCheckResult(e,t){const i=t.findIndex(({parameter:s})=>s===e.parameter);-1!==i?t[i]=e:t.push(e)}getItemChecks(e,t,i,s){if(!("value"in i._localId)||"number"!=typeof i._localId.value)return null;let n=e.get(t);n||(n=new dt.jp,e.set(t,n));let r=n.get(i._localId.value);if(r&&s&&!r.pass)return null;if(!r){const c=[];r={guid:Array.isArray(i._guid)?void 0:i._guid.value,pass:!1,checks:c},Object.defineProperty(r,"pass",{get:()=>c.every(({pass:u})=>u)}),n.set(i._localId.value,r)}const a=[],l={facetType:this.facetType,cardinality:this.cardinality,checks:a,pass:!1};return Object.defineProperty(l,"pass",{get:()=>a.every(({pass:c})=>c)}),r.checks.push(l),l.checks}}const de=(o,e)=>{let t="";if(!e)return t;if("simple"===e.type&&(t=`<simpleValue>${e.parameter}</simpleValue>`),"enumeration"===e.type&&(t=`<xs:restriction base="xs:string">\n ${e.parameter.map(n=>`<xs:enumeration value="${n}" />`).join("\n")}\n </xs:restriction>`),"pattern"===e.type&&(t=`<xs:restriction base="xs:string">\n <xs:pattern value="${e.parameter}" />\n </xs:restriction>`),"bounds"===e.type){const{min:s,minInclusive:n,max:r,maxInclusive:a}=e.parameter;let l="";void 0!==s&&(l=`<xs:min${n?"Inclusive":"Exclusive"} value="${s}">`);let c="";void 0!==r&&(c=`<xs:max${a?"Inclusive":"Exclusive"} value="${r}">`),t=`<xs:restriction base="xs:double">\n ${l}\n ${c}\n </xs:restriction>`}if("length"===e.type){const{length:s,min:n,max:r}=e.parameter;let a="";void 0!==s&&void 0===n&&void 0===r&&(a=`<xs:length value="${s}" />`);let l="";void 0!==n&&void 0===s&&(l=`<xs:minLength value="${n}" />`);let c="";void 0!==r&&void 0===s&&(c=`<xs:maxLength value="${r}" />`),t=`<xs:restriction base="xs:string">\n ${a}\n ${l}\n ${c}\n </xs:restriction>`}return`<${o[0].toLowerCase()+o.slice(1)}>\n ${t}\n </${o[0].toLowerCase()+o.slice(1)}>`};class vc extends Qe{constructor(e,t){super(e),w(this,"facetType","Attribute"),w(this,"name"),w(this,"value"),this.name=t}serialize(e){const t=de("Name",this.name),i=de("Value",this.value);let s="";return"requirement"===e&&(s+=`cardinality="${this.cardinality}"`,s+=this.instructions?`instructions="${this.instructions}"`:""),`<attribute ${s}>\n ${t}\n ${i}\n</attribute>`}getEntities(){return(0,H.A)(function*(){})()}test(e,t){var i=this;return(0,H.A)(function*(s,n,r={skipIfFails:!0}){const a=i._components.get(ut);for(const[l,c]of Object.entries(s)){const u=a.list.get(l);if(!u)continue;const h=yield u.getItemsData([...c]);for(const f of h){const d=i.getItemChecks(n,l,f,r.skipIfFails);if(!d)continue;const g=Object.keys(f).filter(m=>{const x=i.evalRequirement(m,i.name,"Name");if(!x)return!1;const T=f[m];return!!Array.isArray(T)||(null===T||null===T.value?"optional"===i.cardinality||"prohibited"===i.cardinality:!(Array.isArray(T.value)&&0===T.value.length||"string"==typeof T.value&&""===T.value.trim())&&x)}),_=g.length>0;if(d.push({parameter:"Name",currentValue:_?g[0]:null,requiredValue:i.name,pass:"prohibited"===i.cardinality?!_:_}),i.value)if(g[0]){const m=f[g[0]];Array.isArray(m)||Array.isArray(m.value)?d.push({parameter:"Value",currentValue:null,requiredValue:i.value,pass:"prohibited"===i.cardinality}):i.evalRequirement(m.value,i.value,"Value",d)}else d.push({parameter:"Value",currentValue:null,requiredValue:i.value,pass:"prohibited"===i.cardinality})}}}).apply(this,arguments)}}class bc extends Qe{constructor(e,t){super(e),w(this,"facetType","Classification"),w(this,"system"),w(this,"value"),w(this,"uri"),this.system=t}serialize(e){const t=de("System",this.system),i=de("Value",this.value);let s="";return"requirement"===e&&(s+=`cardinality="${this.cardinality}"`,s+=this.uri?`uri=${this.uri}`:"",s+=this.instructions?`instructions="${this.instructions}"`:""),`<classification ${s}>\n ${t}\n ${i}\n</classification>`}getEntities(e,t){return(0,H.A)(function*(){})()}test(e,t){return(0,H.A)(function*(){})()}}class rn extends Qe{constructor(e,t){super(e),w(this,"facetType","Entity"),w(this,"name"),w(this,"predefinedType"),this.name=t}serialize(e){const t=de("Name",this.name),i=de("Name",this.predefinedType);let s="";return"requirement"===e&&(s+=`cardinality="${this.cardinality}"`,s+=this.instructions?`instructions="${this.instructions}"`:""),`<entity ${s}>\n ${t}\n ${i}\n</entity>`}getEntities(e,t){var i=this;return(0,H.A)(function*(){const s=i._components.get(ut),n=new Map;for(const[a,l]of s.list){if(!e.find(h=>h.test(a)))continue;const u=yield l.getCategories();for(const h of u){if(!(yield i.evalName(h)))continue;let d=n.get(a);d||(d=[],n.set(a,d)),d.push(h)}}const r={};if(yield Promise.all(Array.from(n.entries()).map(function(){var a=(0,H.A)(function*([l,c]){const u=s.list.get(l);if(!u)return;const h=c.map(y=>new RegExp(`^${y}$`)),f=yield u.getItemsOfCategories(h),d=Object.values(f).flat();r[l]=new Set(d)});return function(l){return a.apply(this,arguments)}}())),i.predefinedType)for(const[a,l]of Object.entries(r)){const c=s.list.get(a);if(!c)continue;const u=yield c.getItemsData([...l]);for(const h of u)"value"in h._localId&&(yield i.evalPredefinedType(a,h))&&Ft.append(t,a,h._localId.value)}else Ft.add(t,r)})()}test(e,t,i){var s=this;return(0,H.A)(function*(){const n=s._components.get(ut);for(const[r,a]of Object.entries(e)){const l=n.list.get(r);if(!l)continue;const c=yield l.getItemsData([...a]);for(const u of c){if(!("value"in u._category))continue;const h=s.getItemChecks(t,r,u,i.skipIfFails);h&&(yield s.evalName(u._category.value,h),yield s.evalPredefinedType(r,u,h))}}})()}evalName(e,t){var i=this;return(0,H.A)(function*(){return i.evalRequirement(e,i.name,"Name",t)})()}evalPredefinedType(e,t,i){var s=this;return(0,H.A)(function*(){if(!s.predefinedType||!("value"in t.PredefinedType))return null;const n="string"==typeof s.predefinedType.parameter&&"USERDEFINED"===s.predefinedType.parameter;let r=t.PredefinedType.value;if("USERDEFINED"===r&&!n){const c=Object.keys(t).find(u=>/^((?!Predefined).)*Type$/.test(u));if(c){const u=t[c];"value"in u&&(r=u.value)}else r="USERDEFINED"}if(!r){const c=s._components.get(ut).list.get(e);if(c&&"value"in t._localId){const[u]=yield c.getItemsData([t._localId.value],{relations:{IsTypedBy:{attributes:!0,relations:!1}}});if(Array.isArray(u.IsTypedBy)){const h=u.IsTypedBy[0];if(h&&"value"in h.PredefinedType&&(r=h.PredefinedType.value,"USERDEFINED"===r&&!n)){const d=Object.keys(h).find(y=>/^((?!Predefined).)*Type$/.test(y));if(d){const y=h[d];"value"in y&&(r=y.value)}else r="USERDEFINED"}}}}return s.evalRequirement(r,s.predefinedType,"PredefinedType",i)})()}}class wc extends Qe{constructor(e,t,i){super(e),w(this,"facetType","Property"),w(this,"propertySet"),w(this,"baseName"),w(this,"value"),w(this,"dataType"),w(this,"uri"),w(this,"_unsupportedTypes",["IFCCOMPLEXPROPERTY","IFCPHYSICALCOMPLEXQUANTITY"]),this.propertySet=t,this.baseName=i}serialize(e){const t=de("PropertySet",this.propertySet),i=de("BaseName",this.baseName),s=de("Value",this.value);let r="";return"requirement"===e&&(r+=`cardinality="${this.cardinality}"`,r+=this.uri?`uri=${this.uri}`:"",r+=this.instructions?`instructions="${this.instructions}"`:""),`<property ${this.dataType?`dataType=${this.dataType}`:""} ${r}>\n ${t}\n ${i}\n ${s}\n</property>`}getEntities(e,t){var i=this;return(0,H.A)(function*(){const s=i._components.get(ut);for(const[n,r]of s.list){if(!e.find(h=>h.test(n)))continue;const l=yield r.getItemsOfCategories([/PROPERTYSET/,/ELEMENTQUANTITY/]),c=Object.values(l).flat();if(0===c.length)continue;const u=yield r.getItemsData(c,{relations:{HasProperties:{attributes:!0,relations:!1},DefinesOcurrence:{attributes:!0,relations:!1}}});for(const h of u){if(!("value"in h._localId&&"value"in h._category&&"value"in h.Name&&Array.isArray(h.DefinesOcurrence)&&i.evalRequirement(h.Name.value,i.propertySet,"PropertySet")))continue;let d;if("IFCPROPERTYSET"===h._category.value&&(d="HasProperties"),"IFCELEMENTQUANTITY"===h._category.value&&(d="Quantities"),!d)continue;const y=h[d];if(Array.isArray(y))for(const g of y){const _=Object.keys(g),m=_.find(P=>/Name/.test(P));if(!m||!("value"in g[m]))continue;const x=g[m];if(!("value"in x)||!i.evalRequirement(x.value,i.baseName,"BaseName"))continue;if(i.value){const P=_.find(z=>/Value/.test(z));if(!P)continue;const I=g[P];if(!("value"in I)||!i.evalRequirement(I.value,i.value,"Value"))continue}const E=h.DefinesOcurrence.map(P=>"value"in P._localId&&"number"==typeof P._localId.value?P._localId.value:null).filter(P=>null!==P);Ft.append(t,n,...E)}}}})()}test(e,t){var i=this;return(0,H.A)(function*(s,n,r={skipIfFails:!0}){const a=i._components.get(ut);for(const[l,c]of Object.entries(s)){const u=a.list.get(l);if(!u)continue;const h=yield u.getItemsData([...c],{relations:{IsDefinedBy:{attributes:!0,relations:!0},IsTypedBy:{attributes:!0,relations:!1},HasPropertySets:{attributes:!0,relations:!0},DefinesOcurrence:{attributes:!1,relations:!1}}});for(const f of h){const d=i.getItemChecks(n,l,f,r.skipIfFails);if(!d)continue;const g=(yield i.getPsets(f)).filter(_=>!(!("value"in _.Name)||!i.evalRequirement(_.Name.value,i.propertySet,"PropertySet")||(d.push({currentValue:_.Name.value,parameter:"PropertySet",pass:!0,requiredValue:i.propertySet}),0)));if(0!==g.length)for(const _ of g){const m=i.getPropertyListName(_);if(!m)continue;const x=_[m];if(!Array.isArray(x)){d.push({currentValue:null,parameter:"BaseName",pass:!1,requiredValue:i.baseName});continue}const T=x.filter(E=>!(!("value"in E._category)||!("value"in E.Name)||i._unsupportedTypes.includes(E._category.value)||!i.evalRequirement(E.Name.value,i.baseName,"BaseName")||(d.push({currentValue:E.Name.value,parameter:"BaseName",pass:!0,requiredValue:i.baseName}),0)));if(0!==T.length)for(const E of T)i.evalValue(E,d),i.evalDataType(E,d),i.evalURI();else d.push({currentValue:null,parameter:"BaseName",pass:!1,requiredValue:i.baseName})}else d.push({currentValue:null,parameter:"PropertySet",pass:!1,requiredValue:i.propertySet})}}}).apply(this,arguments)}getPropertyListName(e){let t;return"value"in e._category&&("IFCPROPERTYSET"===e._category.value&&(t="HasProperties"),"IFCELEMENTQUANTITY"===e._category.value&&(t="Quantities")),t}getValueKey(e){return Object.keys(e).find(t=>/Value/.test(t)||/Values/.test(t))}getTypePsets(e){if(!Array.isArray(e.IsTypedBy))return[];const[t]=e.IsTypedBy;return t&&Array.isArray(t.HasPropertySets)?t.HasPropertySets:[]}getPsets(e){var t=this;return(0,H.A)(function*(){const i=t.getTypePsets(e);if(!Array.isArray(e.IsDefinedBy))return i;const s=[];for(const n of e.IsDefinedBy){if(!("value"in n.Name))continue;const r=n.Name.value,a=t.getPropertyListName(n);if(!r||!a)continue;const l=i.find(c=>"value"in c.Name&&c.Name.value===r);if(l&&Array.isArray(l.HasProperties)&&Array.isArray(n.HasProperties))for(const c of l.HasProperties){if(!("value"in c.Name))continue;const u=c.Name.value;n.HasProperties.find(f=>"value"in f.Name&&f.Name.value===u)||n.HasProperties.push(c)}s.push(n)}return s})()}evalValue(e,t){const i=this.getValueKey(e),s=e[i];if(!("value"in s))return!1;if(this.value){if(!i)return t?.push({parameter:"Value",currentValue:null,pass:!1,requiredValue:this.value}),!1;const n=structuredClone(this.value);return"IFCLABEL"===s.type&&"simple"===n.type&&(n.parameter=String(n.parameter)),this.evalRequirement(s.value,n,"Value",t)}return!i||"string"!=typeof s.value||""!==s.value.trim()||(t?.push({parameter:"Value",currentValue:"",pass:!1,requiredValue:this.value}),!1)}evalDataType(e,t){if(!this.dataType)return!0;const i=this.getValueKey(e);return i&&"value"in e[i]?this.evalRequirement(e[i].type??null,{type:"simple",parameter:this.dataType},"DataType",t):(t?.push({parameter:"DataType",currentValue:null,pass:!1,requiredValue:this.dataType}),!1)}evalURI(){return!0}}class xc extends Qe{constructor(){super(...arguments),w(this,"_ifcMaterialEntities",[/^IFCMATERIALLAYERSETUSAGE$/,/^IFCMATERIALCONSTITUENTSET$/,/^IFCMATERIAL$/,/^IFCMATERIALLIST$/]),w(this,"facetType","Material"),w(this,"value"),w(this,"uri")}serialize(e){if(!this.value||!this.uri)return"<material />";const t=de("Value",this.value);let i="";return"requirement"===e&&(i+=`cardinality="${this.cardinality}"`,i+=this.uri?`uri=${this.uri}`:"",i+=this.instructions?`instructions="${this.instructions}"`:""),`<material ${i}>\n ${t}\n</material>`}getEntities(e,t){var i=this;return(0,H.A)(function*(){const s=i._components.get(ut);for(const[n,r]of s.list){if(!e.find(h=>h.test(n)))continue;const l=yield r.getItemsOfCategories(i._ifcMaterialEntities),c=Object.values(l).flat();if(0===c.length)continue;const u=yield r.getItemsData(c,{relations:{AssociatedTo:{attributes:!0,relations:!1},MaterialConstituents:{attributes:!0,relations:!0},ForLayerSet:{attributes:!0,relations:!0},MaterialLayers:{attributes:!0,relations:!0},Materials:{attributes:!0,relations:!1}}});for(const h of u){if(!("value"in h._localId&&"value"in h._category&&Array.isArray(h.AssociatedTo)&&i.hasValidMaterial(h)))continue;const d=h.AssociatedTo.map(y=>"value"in y._localId&&y._localId.value?y._localId.value:null).filter(y=>null!==y);Ft.append(t,n,...d)}}})()}test(e,t){var i=this;return(0,H.A)(function*(s,n,r={skipIfFails:!0}){const a=i._components.get(ut);for(const[l,c]of Object.entries(s)){const u=a.list.get(l);if(!u)continue;const h=yield u.getItemsData([[...c][0]],{relations:{AssociatedTo:{attributes:!1,relations:!1},HasAssociations:{attributes:!0,relations:!0},MaterialConstituents:{attributes:!0,relations:!0},ForLayerSet:{attributes:!0,relations:!0},MaterialLayers:{attributes:!0,relations:!0},Materials:{attributes:!0,relations:!1}}});for(const f of h){const d=i.getItemChecks(n,l,f,r.skipIfFails);if(d){if(!Array.isArray(f.HasAssociations)){d.push({parameter:null,currentValue:null,requiredValue:i.value,pass:!1});continue}for(const y of f.HasAssociations)if(i._ifcMaterialEntities.some(_=>"value"in y._category&&_.test(y._category.value))&&i.hasValidMaterial(y,d))break}}}}).apply(this,arguments)}hasValidMaterial(e,t){let i=!1;if("value"in e._category&&"IFCMATERIAL"===e._category.value)this.evalValue(e,t)&&(i=!0);else for(const[s,n]of Object.entries(e))if(["ForLayerSet","MaterialLayers","Material","MaterialConstituents","Materials"].includes(s)&&Array.isArray(n))for(const r of n)if("value"in r._category&&"IFCMATERIAL"===r._category.value){if(this.evalValue(r,t)){i=!0;break}}else if(this.hasValidMaterial(r)){i=!0;break}return i}evalValue(e,t){if(!this.value)return t?.push({parameter:null,currentValue:e.Name&&"value"in e.Name?e.Name.value:null,pass:!0}),!0;if(!("value"in e._category)||"IFCMATERIAL"!==e._category.value)return null;let i=!1;return e.Name&&"value"in e.Name&&(i=this.evalRequirement(e.Name.value,this.value,"Value",t)),i||(e.Category&&"value"in e.Category&&(i=this.evalRequirement(e.Category.value,this.value,"Value",t)),i)}}class Cc extends Qe{constructor(e,t){super(e),w(this,"facetType","PartOf"),w(this,"_entityFacet"),w(this,"_entity"),w(this,"relation"),w(this,"cardinality","required"),this._entity=t,this._entityFacet=new rn(e,t.name),this._entityFacet.predefinedType=t.predefinedType}set entity(e){this._entity=e;const{name:t,predefinedType:i}=e;this._entityFacet=new rn(this._components,t),this._entityFacet.predefinedType=i}get entity(){return this._entity}serialize(){return""}getEntities(e,t){return(0,H.A)(function*(){})()}test(e){return(0,H.A)(function*(){})()}}class Ec{constructor(e,t,i){w(this,"name"),w(this,"ifcVersion",new Set),w(this,"identifier",Wt.create()),w(this,"description"),w(this,"instructions"),w(this,"requirementsDescription"),w(this,"applicability",new dt.PG),w(this,"requirements",new dt.PG),w(this,"components"),this.components=e,this.name=t;for(const s of i)this.ifcVersion.add(s)}set(e){const t=e,i=this;for(const n in e)"identifier"!==n&&n in this&&(i[n]=t[n]);return this.components.get(Tc).list.set(this.identifier,this),this}test(e){var t=this;return(0,H.A)(function*(i,s={skipIfFails:!0}){const n=new dt.jp;if(0===t.requirements.size)return n;const r={},a=[];for(const c of t.applicability)a.push(c.getEntities(i,r));yield Promise.all(a);const l=[];for(const c of t.requirements)l.push(c.test(r,n,s));return yield Promise.all(l),n}).apply(this,arguments)}serialize(){const e=`name="${this.name}"`,t=this.identifier?`identifier="${this.identifier}"`:"",i=this.description?`description="${this.description}"`:"",s=this.instructions?`instructions="${this.instructions}"`:"";return`<specification ifcVersion="${[...this.ifcVersion].join(" ")}" ${e} ${t} ${i} ${s}>\n <applicability minOccurs="1" maxOccurs="unbounded">\n ${[...this.applicability].map(r=>r.serialize("applicability")).join("\n")}\n </applicability>\n <requirements>\n ${[...this.requirements].map(r=>r.serialize("requirement")).join("\n")}\n </requirements>\n </specification>`}}const ie=o=>{if(!o)return;const e={};if("simpleValue"in o&&(e.type="simple",e.parameter=o.simpleValue),"restriction"in o){const t=o.restriction,i=Object.keys(t);if("pattern"in t&&(e.type="pattern",e.parameter=t.pattern.value),"enumeration"in t){e.type="enumeration";const s=t.enumeration.map(({value:n})=>t.base.includes("string")?String(n):t.base.includes("integer")||t.base.includes("double")?Number(n):n);e.parameter=s}if(i.some(s=>["minInclusive","minExclusive","maxInclusive","maxExclusive"].includes(s))){e.type="bounds";const s={},n=i.find(a=>a.includes("min")),r=i.find(a=>a.includes("max"));n&&(s.minInclusive="minInclusive"===n,s.min=t[n].value),r&&(s.maxInclusive="maxInclusive"===r,s.max=t[r].value),e.parameter=s}if(i.some(s=>["minLength","length","maxLength"].includes(s))){e.type="length";const s={};void 0!==t.length&&(s.length=t.length.value),void 0!==t.minLength&&(s.min=t.minLength.value),void 0!==t.maxLength&&(s.max=t.maxLength.value),e.parameter=s}}return void 0!==e.parameter?e:void 0},Ur=(o,e)=>{const t=[];for(const i of e){const n=ie(i.name);if(!n)continue;const r=new rn(o,n);i.cardinality&&(r.cardinality=i.cardinality),r.predefinedType=ie(i.predefinedType),r.instructions=i.instructions,t.push(r)}return t},$r=(o,e)=>{const t=[];for(const i of e){const n=ie(i.name);if(!n)continue;const r=new vc(o,n);i.cardinality&&(r.cardinality=i.cardinality),r.value=ie(i.value),r.instructions=i.instructions,t.push(r)}return t},jr=(o,e)=>{const t=[];for(const i of e){const s=new xc(o);i.cardinality&&(s.cardinality=i.cardinality);const n=ie(i.value);"enumeration"===n?.type&&Array.isArray(n.parameter)&&(n.parameter=n.parameter.map(String)),s.value=n,s.uri=i.uri,s.instructions=i.instructions,t.push(s)}return t},Hr=(o,e)=>{const t=[];for(const i of e){const n=i.baseName,r=ie(i.propertySet),a=ie(n);if(!a||!r)continue;const l=new wc(o,r,a);i.cardinality&&(l.cardinality=i.cardinality);const c=ie(i.value);l.value=c,l.dataType=i.dataType,l.uri=i.uri,l.instructions=i.instructions,t.push(l)}return t},Yr=(o,e)=>{const t=[];for(const i of e){const n=ie(i.system);if(!n)continue;const r=new bc(o,n);i.cardinality&&(r.cardinality=i.cardinality);const a=ie(i.value);"simple"===a?.type&&(a.parameter=String(a.parameter)),"enumeration"===a?.type&&Array.isArray(a.parameter)&&(a.parameter=a.parameter.map(String)),r.value=a,r.uri=i.uri,r.instructions=i.instructions,t.push(r)}return t},Zr=(o,e)=>{const t=[];for(const i of e){const s=ie(i.entity.name);if(!s)continue;const n=ie(i.entity.predefinedType),r=new Cc(o,{name:s,predefinedType:n});r.relation=i.relation,i.cardinality&&(r.cardinality=i.cardinality),r.instructions=i.instructions,t.push(r)}return t},on=class wn extends Pt{constructor(e){super(e),w(this,"enabled",!0),w(this,"IDSInfo"),w(this,"list",new dt.jp),e.add(wn.uuid,this)}getModelIdMap(e){const t={},i={};for(const[s,n]of e){const a=[...n].filter(([,u])=>u.pass).map(([u])=>u);Ft.append(t,s,...a);const c=[...n].filter(([,u])=>!u.pass).map(([u])=>u);Ft.append(i,s,...c)}return{pass:t,fail:i}}create(e,t,i){const s=new Ec(this.components,e,t);return i&&(s.identifier=i),this.list.set(s.identifier,s),s}load(e){const t=[],i=wn.xmlParser.parse(e).ids,{specifications:s,info:n}=i;if(this.IDSInfo={...n},s&&s.specification){const r=Array.isArray(s.specification)?s.specification:[s.specification];for(const a of r){const{name:l,ifcVersion:c,description:u,instructions:h,identifier:f}=a;if(!l||!c)continue;const d=[],y=[],{applicability:g,requirements:_}=a;if(g){const{maxOccurs:T,...E}=g,P=Array.isArray(E)?E:[E];for(const I of P)for(const M in I){const z=Array.isArray(I[M])?I[M]:[I[M]];if("entity"===M){const O=Ur(this.components,z);d.push(...O)}if("attribute"===M){const O=$r(this.components,z);d.push(...O)}if("material"===M){const O=jr(this.components,z);d.push(...O)}if("classification"===M){const O=Yr(this.components,z);d.push(...O)}if("property"===M){const O=Hr(this.components,z);d.push(...O)}if("partOf"===M){const O=Zr(this.components,z);d.push(...O)}}}let m;if(_){const{maxOccurs:T,...E}=_;m=_.description;const P=Array.isArray(E)?E:[E];for(const I of P)for(const M in I){const z=Array.isArray(I[M])?I[M]:[I[M]];if("entity"===M){const O=Ur(this.components,z);y.push(...O)}if("attribute"===M){const O=$r(this.components,z);y.push(...O)}if("material"===M){const O=jr(this.components,z);y.push(...O)}if("classification"===M){const O=Yr(this.components,z);y.push(...O)}if("property"===M){const O=Hr(this.components,z);y.push(...O)}if("partOf"===M){const O=Zr(this.components,z);y.push(...O)}}}const x=this.create(l,c.split(/\s+/),f);x.description=u,x.instructions=h,x.requirementsDescription=m,x.applicability.add(...d),x.requirements.add(...y),t.push(x)}}return t}export(e,t=this.list.values()){const i=t??this.list;return`<ids xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://standards.buildingsmart.org/IDS http://standards.buildingsmart.org/IDS/1.0/ids.xsd" xmlns:ids="http://standards.buildingsmart.org/IDS">\n \x3c!-- Made with That Open Engine ${Gs.release} (https://github.com/thatopen/engine_components) --\x3e\n <info>\n <title>${e.title}</title>\n ${e.copyright?`<copyright>${e.copyright}</copyright>`:""}\n ${e.version?`<version>${e.version}</version>`:""}\n ${e.description?`<description>${e.description}</description>`:""}\n ${e.author?`<author>${e.author}</author>`:""}\n ${e.date?`<date>${e.date.toISOString().split("T")[0]}</date>`:""}\n ${e.purpose?`<purpose>${e.purpose}</purpose>`:""}\n ${e.milestone?`<milestone>${e.milestone}</milestone>`:""}\n </info>\n <specifications>\n ${[...i].map(n=>n.serialize()).join("\n")}\n </specifications>\n</ids>`}};w(on,"uuid","9f0b9f78-9b2e-481a-b766-2fbfd01f342c"),w(on,"xmlParser",new Es({allowBooleanAttributes:!0,attributeNamePrefix:"",ignoreAttributes:!1,ignoreDeclaration:!0,ignorePiTags:!0,numberParseOptions:{leadingZeros:!0,hex:!0},parseAttributeValue:!0,preserveOrder:!1,processEntities:!1,removeNSPrefix:!0,trimValues:!0}));let Tc=on;w(class To extends Pt{constructor(e){super(e),w(this,"enabled",!0),e.add(To.uuid,this)}static distanceFromPointToLine(e,t,i,s=!1){const n=new b.cZY,r=new b.Pq0;return n.set(t,i),n.closestPointToPoint(e,s,r),r.distanceTo(e)}round(e){e.x=Math.trunc(1e3*e.x)/1e3,e.y=Math.trunc(1e3*e.y)/1e3,e.z=Math.trunc(1e3*e.z)/1e3}getVolumeFromFragments(e){var t=this;return(0,H.A)(function*(){return console.warn("getVolumeFromFragments is deprecated. Use getItemsVolume instead."),t.getItemsVolume(e)})()}getItemsVolume(e){var t=this;return(0,H.A)(function*(){let i=0;const s=t.components.get(ut);for(const[n,r]of Object.entries(e)){const a=s.list.get(n);a&&(i+=(yield a.getItemsVolume([...r])))}return i})()}static convertUnits(e,t,i,s=2){const n={m:1,cm:.01,mm:.001,km:1e3,m2:1,cm2:1e-4,mm2:1e-6,km2:1e6,m3:1,cm3:1e-6,mm3:1e-9,km3:1e9};if(!n[t]||!n[i])throw new Error("Invalid units provided for conversion.");if(!Number.isInteger(s)||s<0||s>5)throw new Error("Precision must be an integer between 0 and 5.");const l=10**s;return Math.round(e*(n[t]/n[i])*l)/l}},"uuid","267ca032-672f-4cb0-afa9-d24e904f39d6");let Wr=(()=>{class o extends Pt{static uuid="ab45d0a7-feea-4afc-927c-80832dae76dd";enabled=!0;_fragments=null;set fragments(t){this._fragments=t}geometries=new dt.jp;get(t,i){var s=this;return(0,H.A)(function*(){const{material:n,coordinate:r,applyTransformation:a}={coordinate:!0,applyTransformation:!0,...i},l=new dt.jp;for(const[c,u]of Object.entries(t)){const h=s._fragments.models.list.get(c);if(!h)continue;const f=s.getModelMeshes(c);for(const d of u){let y=l.get(c);y||(y=new dt.jp,l.set(c,y));let g=f.get(d);if(g&&g.length>0){const x=[];for(const[,{geometry:T}]of g.entries()){const E=yield s.createMesh(h,T,{material:n,applyTransformation:a,coordinate:r});x.push(E)}y.set(d,x);continue}g=[],f.set(d,g);const[_]=yield h.getItemsGeometry([d]);if(!_)continue;const m=[];for(const x of _){const T=s.createGeometry(x);if(!T)continue;const{geometry:E}=T;g.push(T);const P=yield s.createMesh(h,E,{material:n,applyTransformation:a,coordinate:r});m.push(P)}y.set(d,m)}}return l})()}getModelMeshes(t){let i=this.geometries.get(t);return i||(i=new dt.jp,this.geometries.set(t,i)),i}remove(t=[...this.geometries.keys()]){for(const i of t){const s=this.geometries.get(i);if(s){for(const[,n]of s)for(const{geometry:r}of n)r.dispose();this.geometries.delete(i)}}}onDisposed=new X;dispose(t=!0){this.remove(),t&&this.geometries.dispose(),this.onDisposed.trigger(o.uuid)}getMeshesFromResult(t){const i=[];for(const s of t.values())for(const n of s.values())i.push(...n);return i}createGeometry(t){const{positions:i,indices:s,normals:n,transform:r}=t;if(!(i&&s&&n))return null;const a=new b.LoY;return a.setAttribute("position",new b.THS(i,3)),a.setAttribute("normal",new b.THS(n,3,!0)),a.setIndex(new b.THS(s,1)),a.applyMatrix4(r),{geometry:a,transform:r}}createMesh(t,i,s){var n=this;return(0,H.A)(function*(){const{material:r,applyTransformation:a,coordinate:l}={applyTransformation:!0,coordinate:!0,...s},c=n.components.get(ut),u=new b.eaF(i,r);if(u.applyMatrix4(t.object.matrixWorld),a||u.position.set(0,0,0),l&&c.baseCoordinationModel!==t.modelId){const h=yield t.getCoordinationMatrix();c.applyBaseCoordinateSystem(u,h)}return u})()}}return o})(),an=(()=>{class o extends Pt{static uuid="2695289f-e6c1-4980-919e-88b7591d7ea3";enabled=!0;originalColors=new Map;_ghostColor=new b.Q1f("white");_ghostedMaterials=[];set ghostColor(t){this._ghostColor=t}_ghostApplied=!1;get ghostApplied(){return this._ghostApplied}_world;set world(t){this._world=t,this._initEventListeners()}get ghostedMaterials(){return this._ghostedMaterials}_fragments;set fragments(t){this._fragments=t,this._initEventListeners()}onDisposed=new X;constructor(t){super(t)}dispose(){this.onDisposed.trigger(o.uuid),this._ghostedMaterials=[]}setModelTransparent(t){const i=[...t.models.materials.list.values()];for(const s of i){if(s.userData.customId)continue;let n;n="color"in s?s.color.getHex():s.lodColor.getHex(),this.originalColors.set(s,{color:n,transparent:s.transparent,opacity:s.opacity}),s.transparent=!0,s.opacity=.05,s.needsUpdate=!0,"color"in s?s.color=this._ghostColor:s.lodColor=this._ghostColor,this._ghostedMaterials.push(s)}this._ghostApplied=!0}restoreModelMaterials(){for(const[t,i]of this.originalColors){const{color:s,transparent:n,opacity:r}=i;t.transparent=n,t.opacity=r,"color"in t?t.color.setHex(s):t.lodColor.setHex(s),t.needsUpdate=!0}this.originalColors.clear(),this._ghostedMaterials=[],this._ghostApplied=!1}toggleGhost(t){this.originalColors.size?this.restoreModelMaterials():this.setModelTransparent(t)}_initEventListeners(){void 0!==this._world&&void 0!==this._fragments&&(this._world.camera.controls.addEventListener("rest",()=>{this.enabled?this.setModelTransparent(this._fragments):this.restoreModelMaterials()}),this._fragments.models.list.onItemSet.add(({value:t})=>{console.log(`Model ${t.modelId} is ready`),setTimeout(()=>{this.enabled?(console.log("GHOST"),this.setModelTransparent(this._fragments)):this.restoreModelMaterials()},1500)}))}}return o})(),Gr=(()=>{class o extends Pt{static uuid="3abd8228-7bff-4ff6-ac30-53f97bdc8ae6";enabled=!0;_fragments;_isolated={};_hidden={};_colorOverrides={};_overrides={};onDisposed=new X;constructor(t){super(t)}set fragments(t){this._fragments=t}_world;set world(t){this._world=t}get colorOverrides(){return this._colorOverrides}applyModelOverrides(t,i){var s=this;return(0,H.A)(function*(){s._overrides[t.modelId]=i,yield s._applyModelOverrides(t)})()}update(t){var i=this;return(0,H.A)(function*(){(void 0===t?i.fragments.models.list:[t]).forEach(n=>{i._appendOnModel(n)})})()}setNonColoredVisibility(t){var i=this;return(0,H.A)(function*(){if(void 0===i._fragments)return;const s=i._colorOverrides;console.log(s);for(const n of Object.keys(s)){const r=i._fragments.models.list.get(n);if(void 0===r)return;t?yield i._setVisibilityAll(r,!0):(yield i._setVisibilityAll(r,!1),r.setVisible([...s[n]],!0))}})()}dispose(){this.onDisposed.trigger(o.uuid)}_getLocalIdsByType(t,i){var s=this;return(0,H.A)(function*(){if(void 0===s._fragments)return null;const n=yield t.getItemsOfCategories(i);return new Set([...Object.values(n).flat()])})()}_applyModelOverrides(t){var i=this;return(0,H.A)(function*(){if(void 0!==i._fragments&&void 0!==i._overrides[t.modelId]){try{yield Promise.all([i._updateIsolatedMap(t),i._updateHiddenMap(t),i._updateColorOverrides(t)])}catch(n){console.log(n)}t&&i._appendOnModel(t)}})()}_appendOnModel(t){var i=this;return(0,H.A)(function*(){const s=i._overrides[t.modelId];if(void 0===s)return;const n=i._isolated[t.modelId],r=i._hidden[t.modelId];n?.size?(yield i._setVisibilityAll(t,!1),t?.setVisible([...n],!0)):r?.size&&t?.setVisible([...r],!1);for(const a of s.colorOverrides){const l={color:new b.Q1f(a.color),renderedFaces:dt.eB.TWO,opacity:a.opacity,transparent:!1,customId:`${t.modelId}_${a.color}`};yield t.highlight(a.ids,l)}})()}_updateIsolatedMap(t){var i=this;return(0,H.A)(function*(){const s=t.modelId,n=i._overrides[s];if(i._isolated[s]=new Set,n.isolatedTypes.length){const r=yield i._getLocalIdsByType(t,n.isolatedTypes);r&&r.forEach(a=>i._isolated[s].add(a))}n.isolated.length&&n.isolated.forEach(r=>i._isolated[s].add(r))})()}_updateHiddenMap(t){var i=this;return(0,H.A)(function*(){const s=t.modelId,n=i._overrides[s];if(i._hidden[s]=new Set,n.hiddenTypes.length){const r=yield i._getLocalIdsByType(t,n.hiddenTypes);r&&r.forEach(a=>i._hidden[s].add(a))}n.hidden.length&&n.hidden.forEach(r=>i._hidden[s].add(r))})()}_updateColorOverrides(t){var i=this;return(0,H.A)(function*(){const s=t.modelId;i._colorOverrides[t.modelId]=new Set,i._overrides[s].colorOverrides.forEach(r=>{r.ids.forEach(a=>i._colorOverrides[t.modelId].add(a))})})()}_setVisibilityAll=function(){var t=(0,H.A)(function*(i,s){const r=(yield i.getItemsWithGeometry()).map(l=>l.getLocalId()),a=(yield Promise.all(r)).filter(l=>null!==l);yield i.setVisible(a,s)});return function(i,s){return t.apply(this,arguments)}}()}return o})();const qr=(o,e)=>{const t={...o};return Object.keys(e).forEach(i=>{t[i]=new Set([...t[i]||[],...e[i]])}),t},Xr=function(){var o=(0,H.A)(function*(e,t,i,s={}){const n=[];for(const[,l]of t.models.list){const c=yield l.raycast(i);if(c){const u={};u[l.modelId]=new Set,u[l.modelId].add(c.localId),n.push({...c,idMap:u})}}if(0===n.length)return Qr(t,s,!0),null;let r=n[0],a=r.distance;for(let l=1;l<n.length;l++)n[l].distance<a&&(a=n[l].distance,console.log(a),r=n[l]);return e.get(an).ghostApplied&&!((o,e)=>{if(null===e)return!1;let t=!1;return Object.keys(o).forEach(i=>{e[i].forEach(s=>{o[i].has(s)&&(t=!0)})}),t})(e.get(Gr).colorOverrides,r.idMap)?(Qr(t,s=qr(s,r.idMap),!1),Xr(e,t,i,s)):r});return function(t,i,s){return o.apply(this,arguments)}}();function Qr(o,e,t){for(const i of Object.keys(e))o.models.list.get(i)?.setVisible([...e[i]],t)}class Sc{hoveredElement=new X}let ln=(()=>{class o extends Pt{static uuid="26fbd870-b1b2-4b71-b747-4063d484de1b";HOVERER_OPACITY_KEY="_maxHoverOpacity";_hoverTimeout=null;_meshes=new dt.PG;_localId=null;_fadeAnimation=null;_world=null;_fragments=null;set world(t){if(t){this._world=t,this.setupEvents(!0);for(const i of this._meshes)t.scene.three.add(i)}else{this.setupEvents(!1),this._world=null;for(const i of this._meshes)i.removeFromParent()}}get world(){return this._world}events=new Sc;set fragments(t){this._fragments=t}_enabled=!1;set enabled(t){this.setupEvents(t),this._enabled=t}get enabled(){return this._enabled}_material=new b.V9B({color:16777215,transparent:!0,opacity:.5,depthTest:!1,userData:{[this.HOVERER_OPACITY_KEY]:.5}});set material(t){t.userData[this.HOVERER_OPACITY_KEY]=t.opacity;for(const i of this._meshes)i.material=t;this._material.dispose(),this._material=t}get material(){return this._material}onDisposed=new X;duration=200;animation=!0;constructor(t){super(t),t.add(o.uuid,this),this._meshes.onBeforeDelete.add(i=>{i.removeFromParent(),i.geometry.dispose(),this._setCursor(!1)}),this._meshes.onItemAdded.add(i=>{this.world&&(this._setCursor(!0),this.world.scene.three.add(i))}),this._meshes.onCleared.add(()=>{this._localId=null,this._hoverTimeout&&(clearTimeout(this._hoverTimeout),this._hoverTimeout=null)})}setupEvents(t){if(!this.world||this.world.isDisposing)return;if(!this.world.renderer)throw new Error("The given world doesn't have a renderer!");const i=this.world.renderer.three.domElement;i.removeEventListener("mousemove",this.onMouseMove),i.removeEventListener("mouseleave",this.onMouseMove),t&&(i.addEventListener("mousemove",this.onMouseMove),i.addEventListener("mouseleave",this.onMouseLeave))}mouseStopTimeout=null;onMouseMove=t=>{null!==this.mouseStopTimeout&&clearTimeout(this.mouseStopTimeout),this.mouseStopTimeout=window.setTimeout(()=>this.hover(t),50)};onMouseLeave=()=>{this._meshes.clear()};animate=()=>{if(!(this._fadeAnimation&&this.animation&&this.material.transparent))return;const{startTime:t,duration:i,fadeIn:s}=this._fadeAnimation,n=Date.now()-t,r=Math.min(n/i,1),l=this.material.userData[this.HOVERER_OPACITY_KEY];this.material.opacity=(s?r:1-r)*(void 0!==l?l:1),r<1?requestAnimationFrame(this.animate):(s||this._meshes.clear(),this._fadeAnimation=null)};hover(t){var i=this;return(0,H.A)(function*(){if(!i.enabled||!i.world||!i._fragments)return;const s=new b.I9Y(t.clientX,t.clientY),n=yield Xr(i.components,i._fragments,{camera:i.world.camera.three,mouse:s,dom:i.world.renderer.three.domElement});if(!n)return i._meshes.clear(),void i.events.hoveredElement.trigger(null);if(i.components.get(an).ghostApplied&&!(yield n.fragments.getHighlightItemIds()).includes(n.localId))return console.log("Not a highlighted object!"),void i.events.hoveredElement.trigger(null);i.events.hoveredElement.trigger(n);const{fragments:r,localId:a}=n;i._localId!==a&&(i._meshes.clear(),i._localId=a,i._hoverTimeout=window.setTimeout((0,H.A)(function*(){const l={[r.modelId]:new Set([a])},c=i.components.get(Wr);c.fragments=i._fragments;const u=yield c.get(l);for(const[,h]of u.entries()){const f=[...h.values()].flat();for(const d of f)d.material=i.material,d.position.set(0,0,0),d.rotation.set(0,0,0),d.scale.set(1,1,1),d.applyMatrix4(r.object.matrixWorld),i._meshes.add(d)}i._fadeAnimation={startTime:Date.now(),duration:i.duration,fadeIn:!0},i.animate()}),100))})()}_setCursor(t){const i=this._world.renderer?.three.domElement;i&&(i.style.cursor=t?"pointer":"default")}clear(){this._meshes.clear()}dispose(){this._enabled=!1,this._meshes.clear(),this._fadeAnimation=null,this._hoverTimeout=null,this.onDisposed.trigger()}}return o})();var Ic=ht(9595);const Oc=function(){var o=(0,H.A)(function*(e,t){const i=Object.keys(t)[0];if(i&&e.models.list.get(i)){const s=e.models.list.get(i),[n]=yield s.getItemsData([...t[i]],{attributesDefault:!1,attributes:["Name","NominalValue"],relations:{IsDefinedBy:{attributes:!0,relations:!0},DefinesOcurrence:{attributes:!1,relations:!1}}});return n||null}return null});return function(t,i){return o.apply(this,arguments)}}();var cn=ht(1452);class kc{clickedElement=new X;clickedCanvas=new X;selection=new X}let Kr=(()=>{class o extends Pt{static uuid="b7e0b697-172f-43db-b530-d775a2a34d55";HIGHLIGHT_ID="cue_selection";enabled=!0;multiSelect=!1;resetOnCanvasClick=!0;_fragments=null;set fragments(t){this._fragments=t}hoveredElement=null;selectedElements=null;set styles(t){const i=this.components.get(cn.TF);i.fillOpacity=t.fillOpacity,i.fillColor=t.fillColor,i.color=t.outlineColor}onDisposed=new X;events=new kc;constructor(t){super(t),this._initEventListeners()}dispose(){this.hoveredElement=null,this.selectedElements=null,this.onDisposed.trigger(o.uuid)}_initEventListeners(){var t=this;this.components.get(ln).events.hoveredElement.add(function(){var n=(0,H.A)(function*(r){if(!r)return void(t.hoveredElement=null);const a=r.localId,l=r.fragments.modelId;t.hoveredElement={[l]:new Set([a])}});return function(r){return n.apply(this,arguments)}}()),Ic.B.getInstance().events.addListener("shortPressedLeft",(0,H.A)(function*(){if(!t.enabled)return;const n=t.components.get(cn.TF);n.clean();const r=t.hoveredElement;if(!r)return t.resetOnCanvasClick&&(t.selectedElements=null,t.events.selection.trigger(null),n.clean()),void t.events.clickedCanvas.trigger();const a=yield Oc(t._fragments,r);a&&t.events.clickedElement.trigger(a);const l=Object.keys(r)[0],c=[...r[l]][0];let u=t.selectedElements?Object.assign({},t.selectedElements):null;u=t.multiSelect?u?t.resetOnCanvasClick&&u&&u[l]?.has(c)?((o,e)=>{const t={...o};return Object.keys(e).forEach(i=>{const s=e[i];t[i]&&(t[i]=new Set([...t[i]||[]].filter(n=>!s.has(n))),0===t[i].size&&delete t[i])}),0===Object.keys(t).length?null:t})(u,r):qr(u,r):r:t.resetOnCanvasClick&&u&&u[l]?.has(c)?null:r,t.selectedElements=u,t.events.selection.trigger(u),u?n.addItems(u):n.clean()}))}}return o})(),zc=(()=>{class o extends Pt{_world;_fragments;set world(t){this._world=t,t&&this.getRenderer().postproduction.excludedObjectsPass.addExcludedMaterial(this._points.material)}get world(){return this._world}set fragments(t){this._fragments=t}styles=new dt.PG;outlinePositions=!1;_mesh=null;get _points(){return this._mesh||(this._mesh=new b.ONl(new b.LoY,new b.BH$({size:10,sizeAttenuation:!1,depthTest:!1}))),this._mesh}get enabled(){return!(!this.world||this.world.isDisposing)&&this.getRenderer().postproduction.outlinesEnabled}set enabled(t){this.world&&!this.world.isDisposing&&(this.getRenderer().postproduction.outlinesEnabled=t,this.outlinePositions&&(this._points.material.color=this.color,this.world.scene.three.add(this._points)))}get color(){return this.getRenderer().postproduction.outlinePass.outlineColor}set color(t){this.getRenderer().postproduction.outlinePass.outlineColor.copy(t),this._points.material.color.copy(t)}get thickness(){return this.getRenderer().postproduction.outlinePass.thickness}set thickness(t){this.getRenderer().postproduction.outlinePass.thickness=t}get fillColor(){return this.getRenderer().postproduction.outlinePass.fillColor}set fillColor(t){this.getRenderer().postproduction.outlinePass.fillColor.copy(t)}get fillOpacity(){return this.getRenderer().postproduction.outlinePass.fillOpacity}set fillOpacity(t){this.getRenderer().postproduction.outlinePass.fillOpacity=t}onDisposed=new X;static uuid="2fd3bcc5-b3b6-4ded-9f64-f47a02854a10";_meshes=[];_map={};_activeStyles=new Set;constructor(t){super(t),t.add(o.uuid,this)}update(){var t=this;return(0,H.A)(function*(i=t._map){if(i===t._map&&t.cleanMeshes(),t.outlinePositions&&t.updatePoints(),0===Object.keys(i).length)return;const n=t.getRenderer().postproduction.outlinePass,a=yield t.components.get(Wr).get(i);for(const l of Object.keys(i)){const c=t._fragments?.models.list.get(l);if(c)for(const[,u]of a.entries()){const h=[...u.values()].flat();for(const f of h)f.position.set(0,0,0),f.rotation.set(0,0,0),f.scale.set(1,1,1),f.applyMatrix4(c.object.matrixWorld),t._meshes.push(f),n.scene.add(f)}}}).apply(this,arguments)}addItems(t){var i=this;return(0,H.A)(function*(){Ft.add(i._map,t),yield i.update(t)})()}removeItems(t){var i=this;return(0,H.A)(function*(){Ft.remove(i._map,t),yield i.update()})()}clean(){this._map={},this._activeStyles.clear(),this.cleanMeshes(),this._mesh&&this.components.get(si).destroy(this._mesh,!0,!0),this._mesh=null}dispose(){this.styles.clear(),this.clean(),this.onDisposed.trigger(o.uuid)}cleanMeshes(){for(const t of this._meshes)t.removeFromParent();this._meshes=[]}updatePoints(){var t=this;return(0,H.A)(function*(){let i=0;for(const[,r]of Object.entries(t._map))i+=r.size;t._points.geometry.setAttribute("position",new b.qtW(new Float32Array(3*i),3));const n=yield t.components.get(ut).getPositions(t._map);for(let r=0;r<n.length;r++){const{x:a,y:l,z:c}=n[r];t._points.geometry.attributes.position.array[3*r]=a,t._points.geometry.attributes.position.array[3*r+1]=l,t._points.geometry.attributes.position.array[3*r+2]=c}t._points.geometry.attributes.position.needsUpdate=!0})()}getRenderer(){if(!this.world)throw new Error("You must set a world to use the outliner!");const t=this.world.renderer;if(!t.postproduction)throw new Error("The world given to the outliner must use the postproduction renderer.");return t}}return o})();var Nc=ht(893);function Rc(o){return un.apply(this,arguments)}function un(){return(un=(0,H.A)(function*(o){console.warn("Set double sided is not implemented"),console.log(o)})).apply(this,arguments)}const Lc=(o,e,t="./js/worker.mjs")=>{const i=new dt._i(function Bc(o){try{const e=new URL(o,window.location.href);if(e.origin!==window.location.origin){const t=new Blob([`import '${e.href}';`],{type:"text/javascript"});return URL.createObjectURL(t)}}catch{}return o}(t)),s=o.get(Gr);return s.fragments=i,s.world=e,e.camera.controls.addEventListener("rest",()=>i.update(!0)),e.camera.controls.addEventListener("update",()=>i.update()),i.models.list.onItemSet.add(function(){var n=(0,H.A)(function*({value:r}){const a=r.object.userData.overrides;r.useCamera(e.camera.three),e.scene.three.add(r.object),io(a)&&(r.object.visible=!1,yield Uc(1),yield s.applyModelOverrides(r,a),r.object.visible=!0),yield i.update(!0),r.object.visible=!0,io(a)||(yield s.applyModelOverrides(r,a),yield i.update(!0)),yield i.update(!0)});return function(r){return n.apply(this,arguments)}}()),e.onCameraChanged.add(n=>{for(const[,r]of i.models.list)r.useCamera(n.three);i.update(!0)}),i},Vc=function(){var o=(0,H.A)(function*(e,t,i){void 0===i&&(i=eo(e));const s=t.map(a=>a.id),n=t.filter(a=>!i.includes(a.id)).filter(a=>!0===a.visible),r=i.filter(a=>!s.includes(a));return n.length&&(console.info(`Loading ${n.length} model(s)`),yield Jr(e,n)),r.length&&(console.info(`Disposing ${n.length} model(s)`),yield to(e,r)),[...e.models.list.values()]});return function(t,i,s){return o.apply(this,arguments)}}(),Jr=function(){var o=(0,H.A)(function*(e,t){const i=[];for(const s of t)try{console.info(`Loading ${s.name} (${s.id})...`);const r=yield(yield fetch(s.fileURL)).arrayBuffer();console.info("Got model buffer...");const a=yield e.load(r,{modelId:s.id,userData:{overrides:s.overrides}});console.info("Model loaded into fragments..."),s.makeAllMaterialsDoubleSided&&(yield Rc(a)),yield e.update(),i.push(a),s.visible=!0,console.info(`\u2705 ${s.name} (${s.id}) loaded`)}catch(n){console.error(`\u274c Error loading model ${s.name} (${s.id}): `,n)}return i});return function(t,i){return o.apply(this,arguments)}}(),to=function(){var o=(0,H.A)(function*(e,t){void 0===t&&(t=eo(e));const i=[];for(const s of t)i.push(e.disposeModel(s));yield Promise.all(i)});return function(t,i){return o.apply(this,arguments)}}(),eo=o=>[...o.models?.list.values()].map(i=>i.modelId),io=o=>!(!o.isolated.length&&!o.isolatedTypes.length),Uc=function(){var o=(0,H.A)(function*(e){return new Promise(t=>setTimeout(()=>t(),e))});return function(t){return o.apply(this,arguments)}}(),$c={"#e2f552":"accent","#2859e1":"primary","#1744c2":"secondary","#ffffff":"default","#8394b0":"fade"},jc={accent:new b.Q1f("#2859e1"),primary:new b.Q1f("#1744c2"),secondary:new b.Q1f("#2859e1"),default:new b.Q1f("#e2f552"),fade:new b.Q1f("#e2f552")},Hc={accent:new b.Q1f("#e2f552"),primary:new b.Q1f("#1744c2"),secondary:new b.Q1f("#1744c2"),default:new b.Q1f("#1744c2"),fade:new b.Q1f("#1744c2")},Yc={accent:new b.Q1f("#2859e1"),primary:new b.Q1f("#e2f552"),secondary:new b.Q1f("#e2f552"),default:new b.Q1f("#e2f552"),fade:new b.Q1f("#e2f552")},Wc=o=>{const e=new b.Q1f(o),i=.299*e.r+.587*e.g+.114*e.b>.5?.75:1.25;return new b.Q1f(Math.min(e.r*i,1),Math.min(e.g*i,1),Math.min(e.b*i,1))};function Gc(o){let e="";return e=o.LongName?.value?o.LongName.value:o.Name?.value?o.Name.value:o.type||"(no name)",`${e} [${o._category.value}]`}function so(o,e,t){return hn.apply(this,arguments)}function hn(){return(hn=(0,H.A)(function*(o,e,t){console.log(e);const i=yield o.getItemsData(e,{relations:{Decomposes:{attributes:!0,relations:!0}}});console.log(i),void 0===t.children&&(t.children=[]);for(const s of i){const n=[];for(const r of s.Decomposes||[]){const a=r._localId.value,l=yield o.getItemsData([a],{relations:{IsDecomposedBy:{attributes:!0,relations:!0}}});console.log(l);const c={id:a,label:Gc(r)};yield so(o,[a],c),n.push(c)}t.children.push(...n)}})).apply(this,arguments)}function dn(){return(dn=(0,H.A)(function*(o,e){const t=yield o.getItemsOfCategories([/IFCSITE/]),i={label:e,children:[]};yield so(o,t.IFCSITE,i),console.log(i)})).apply(this,arguments)}let fn=(()=>{class o{_workerUrl=(0,tt.WQX)(Nc.g);_container=(0,tt.vPA)(void 0);modelsAreLoading=(0,tt.vPA)(!1);settings=(0,tt.vPA)(new Bt.R_);_previousHighlights=null;raycastResult=(0,tt.vPA)(null);hoveredElement=(0,bt.EW)(()=>{const t=this.raycastResult()?.localId??null,i=this.raycastResult()?.fragments.modelId??null;return i&&t?{[i]:new Set([t])}:null},{equal:(t,i)=>((o,e)=>{if(!o&&!e)return!0;if(!o||!e)return!1;const t=Object.keys(o),i=Object.keys(e);if(t.length!==i.length||t[0]!==i[0])return!1;const s=o[t[0]],n=e[i[0]];if(s.size!==n.size)return!1;const r=Array.from(s.values()),a=Array.from(n.values());return r[0]===a[0]})(t,i)});clickedElement=(0,tt.vPA)(null);selectedElements=(0,tt.vPA)(null);init(t){this._container.set(t)}_colorDef=(0,bt.EW)(()=>{const t=this._container();if(t)return(o=>{const t=window.getComputedStyle(o).getPropertyValue("--background-color"),i=$c[t];return{hoverColor:jc[i]??new b.Q1f("#e2f552"),selectionColor:Hc[i]??new b.Q1f("#1744c2"),selectionOutlineColor:Yc[i]??new b.Q1f("#e2f552"),ghostColor:Wc(t)}})(t)});_loadedModels=(0,tt.vPA)([]);_components=(0,bt.EW)(()=>{if(void 0!==this._container())return console.info("Building components..."),new Gs});_world=(0,bt.EW)(()=>{const t=this._components(),i=this._container();if(void 0!==t&&void 0!==i)return console.info("Setting up scene..."),((o,e)=>{const i=o.get(Ps).create();i.scene=new er(o),i.scene.setup(),i.scene.three.background=null,i.renderer=new cn.Hs(o,e);const{postproduction:s}=i.renderer;return i.camera=new qs(o),o.init(),i.scene.setup(),s.enabled=!0,i.scene.three.background=null,i.camera.controls.restThreshold=.25,i})(t,i)});_fragments=(0,bt.EW)(()=>{const t=this._world();if(void 0===t)return;const i=this._components();return void 0!==i?(console.info("Setting up fragments..."),Lc(i,t,this._workerUrl)):void 0});viewerReady=(0,bt.EW)(()=>!(void 0===this._components()||void 0===this._world()||void 0===this._fragments()));get loadedModels(){return this._loadedModels}constructor(){(0,tt.QZP)(()=>{this.viewerReady()&&(console.info("Initializing event listeners..."),this._initEventListeners(),console.info("BIM Fragments Viewer is ready"))}),(0,tt.QZP)(()=>{const t=this.settings(),i=this._world(),s=this._components(),n=this._fragments(),r=this._colorDef();void 0===t||void 0===i||void 0===s||void 0===n||void 0===r||this.viewerReady()&&(((o,e,t,i,s)=>{t.dynamicAnchor=o.dynamicAnchor;const n=t.renderer?.postproduction;if(n&&(n.enabled=o.postProductionSettings.enabled,n.style=o.postProductionSettings.style),o.clickEnabled){const r=e.get(ln);r.world=t,r.fragments=i,r.enabled=!0,r.material=new b.V9B({color:s.hoverColor,transparent:!0,opacity:.5,depthTest:!1});const a=e.get(zc);a.world=t,a.fragments=i,a.enabled=!0;const l=e.get(Kr);l.enabled=!0,l.fragments=i,l.multiSelect=o.multiSelect,l.styles={fillColor:s.selectionColor,outlineColor:s.selectionOutlineColor,fillOpacity:.5}}if(o.applyGhosting){const r=e.get(an);r.enabled=!0,r.ghostColor=s.ghostColor,r.fragments=i,r.world=t}console.info("Settings updated")})(t,s,i,n,r),console.info("Settings updated"))})}dispose(){var t=this;return(0,H.A)(function*(){yield t.disposeModels()})()}loadFragmentFiles(t){var i=this;return(0,H.A)(function*(){console.log("LOAD FRAGMENTS");const s=i._fragments();if(void 0===s)throw new Error("Fragments not available");i.modelsAreLoading.set(!0);const n=yield Jr(s,t);i._loadedModels.update(()=>[...n]),console.log("YYY"),console.log(n),i.modelsAreLoading.set(!1)})()}disposeModels(t){var i=this;return(0,H.A)(function*(){const s=t?t.map(r=>r.id):void 0,n=i._fragments();if(void 0===n)throw new Error("Fragments not available");yield to(n,s),void 0!==t&&t.forEach(r=>r.visible=!1)})()}updateModels(t){var i=this;return(0,H.A)(function*(){const s=i._fragments();if(void 0===s)throw new Error("Fragments not available");const n=yield Vc(s,t);i._loadedModels.update(()=>[...n])})()}getSpatialStructure(t){var i=this;return(0,H.A)(function*(){const s=i._fragments()?.models.list.get(t.id);return void 0!==s&&function qc(o,e){dn.apply(this,arguments)}(s,t.name),s?.getSpatialStructure()})()}updateAspectRatio(){this._world()?.renderer?.resize(),this._world()?.camera.updateAspect()}_initEventListeners(){var t=this;const i=this._components().get(Kr);i.events.clickedElement.add(n=>{const r=this.hoveredElement();null!==r&&this.clickedElement.update(()=>({itemData:n,element:r}))}),i.events.clickedCanvas.add(()=>{this.clickedElement.update(()=>null)}),i.events.selection.add(n=>{this.selectedElements.update(()=>n)}),this._components().get(ln).events.hoveredElement.add(function(){var n=(0,H.A)(function*(r){t.raycastResult.update(()=>r)});return function(r){return n.apply(this,arguments)}}()),this._fragments().models.list.onItemSet.add(()=>{})}static \u0275fac=function(i){return new(i||o)};static \u0275prov=tt.jDH({token:o,factory:o.\u0275fac,providedIn:"root"})}return o})();var no=ht(7023),Xc=ht(5970),ze=ht(5381),pn=ht(5187),bi=ht(1696),os=ht(3319),p=ht(5547);function Qc(o,e){if(1&o){const t=p.RV6();p.j41(0,"cue-flexcontainer",3)(1,"cue-button",5),p.bIt("click",function(){tt.eBV(t);const s=p.XpG();return tt.Njj(s.zoomOut())}),p.nrm(2,"cue-button-icon",6),p.k0s(),p.j41(3,"cue-button",5),p.bIt("click",function(){tt.eBV(t);const s=p.XpG();return tt.Njj(s.zoomIn())}),p.nrm(4,"cue-button-icon",7),p.k0s(),p.j41(5,"cue-button",5),p.bIt("click",function(){tt.eBV(t);const s=p.XpG();return tt.Njj(s.zoomFit())}),p.nrm(6,"cue-button-icon",8),p.k0s()()}}function Kc(o,e){if(1&o){const t=p.RV6();p.j41(0,"cue-button",5),p.bIt("click",function(){tt.eBV(t);const s=p.XpG();return tt.Njj(s.toggleLayersVisible())}),p.nrm(1,"cue-button-icon",9),p.k0s()}if(2&o){const t=p.XpG();p.AVh("border-left",t.options().displayZoom&&t.displayDecompositionTree())}}let Jc=(()=>{class o{settings=(0,lt.hFB)(new Bt.R_);options=(0,bt.EW)(()=>this.settings().toolbar);selectMenuPositions=(0,bt.EW)(()=>"top"===this.options().position?"bottomleft":"topleft");displayDecompositionTree=(0,bt.EW)(()=>void 0!==this.options().displayDecompositionTree);zoomIn(){}zoomOut(){}zoomFit(){}toggleLayersVisible(){}static \u0275fac=function(i){return new(i||o)};static \u0275cmp=p.VBU({type:o,selectors:[["cue-bim-fragments-toolbar"]],inputs:{settings:[1,"settings"]},decls:5,vars:3,consts:[["align","center",1,"container"],[1,"toolbar",3,"padded"],["align","center"],["align","center","gap","s"],["size","xs","variant","tertiary",3,"border-left"],["size","xs","variant","tertiary",3,"click"],["icon","zoom-out"],["icon","zoom-in"],["icon","zoom-fit"],["icon","tree"]],template:function(i,s){1&i&&(p.j41(0,"cue-flexcontainer",0)(1,"cue-card",1)(2,"cue-flexcontainer",2),p.nVh(3,Qc,7,0,"cue-flexcontainer",3),p.nVh(4,Kc,2,2,"cue-button",4),p.k0s()()()),2&i&&(p.R7$(),p.Y8G("padded",!1),p.R7$(2),p.vxM(s.options().displayZoom?3:-1),p.R7$(),p.vxM(s.displayDecompositionTree()?4:-1))},dependencies:[ze.n,pn.Card,bi.$,os.a],styles:[".container[_ngcontent-%COMP%]{height:100%;pointer-events:none}.toolbar[_ngcontent-%COMP%]{pointer-events:all;padding:5px 10px}.border-left[_ngcontent-%COMP%]{border-left:1px solid;padding-left:12px}"],changeDetection:0})}return o})();var tu=ht(8359),eu=ht(6939),iu=ht(63),mn=ht(7089),as=ht(356),ls=ht(6279);const su=()=>({position:"bottomleft"}),ro=(o,e)=>e.label||o;function nu(o,e){if(1&o){const t=p.RV6();p.j41(0,"cue-menu-item",4),p.bIt("click",function(){const s=tt.eBV(t).$implicit;return tt.Njj(s.action())}),p.EFF(1),p.k0s()}if(2&o){const t=e.$implicit;p.Y8G("selected",t.selected),p.R7$(),p.JRh(t.label)}}function ru(o,e){if(1&o&&(p.j41(0,"cue-menu-wrap"),p.Z7z(1,nu,2,2,"cue-menu-item",3,ro),p.k0s()),2&o){const t=p.XpG();p.R7$(),p.Dyx(t.contextMenuItems())}}function ou(o,e){if(1&o){const t=p.RV6();p.j41(0,"cue-button",5),p.bIt("click",function(s){const n=tt.eBV(t).$implicit,r=p.XpG();return tt.Njj(r.handleClick(s,n))}),p.nrm(1,"cue-button-icon",6),p.k0s()}if(2&o){const t=e.$implicit,i=p.XpG(),s=p.sdS(1);p.Y8G("cueTooltip",t.label)("variant",t.variant?t.variant:i.variant())("size",i.size())("cueContextMenu",s)("contextMenuData",p.lJ4(7,su))("cueContextEnabled",void 0!==t.contextMenuItems&&t.contextMenuItems.length>0),p.R7$(),p.Y8G("icon",t.icon)}}let au=(()=>{class o{items=lt.hFB.required();noGap=(0,lt.hFB)(!0);direction=(0,lt.hFB)("row");size=(0,lt.hFB)("xs");variant=(0,lt.hFB)("tertiary");mouseEnter=(0,lt.CGW)();mouseLeave=(0,lt.CGW)();contextMenuItems=(0,tt.vPA)([]);handleClick(t,i){t.stopPropagation(),i.contextMenuItems&&i.contextMenuItems.length>0?this.contextMenuItems.set(i.contextMenuItems):i.action&&(this.contextMenuItems.set([]),i.action())}static \u0275fac=function(i){return new(i||o)};static \u0275cmp=p.VBU({type:o,selectors:[["cue-entity-menu"]],inputs:{items:[1,"items"],noGap:[1,"noGap"],direction:[1,"direction"],size:[1,"size"],variant:[1,"variant"]},outputs:{mouseEnter:"mouseEnter",mouseLeave:"mouseLeave"},decls:5,vars:2,consts:[["contextMenu",""],["gap","s","justify","end",2,"width","100%",3,"mouseenter","mouseleave","direction","noGap"],["trigger","leftclick",3,"cueTooltip","variant","size","cueContextMenu","contextMenuData","cueContextEnabled"],[3,"selected"],[3,"click","selected"],["trigger","leftclick",3,"click","cueTooltip","variant","size","cueContextMenu","contextMenuData","cueContextEnabled"],[3,"icon"]],template:function(i,s){1&i&&(p.DNE(0,ru,3,0,"ng-template",null,0,p.C5r),p.j41(2,"cue-flexcontainer",1),p.bIt("mouseenter",function(){return s.mouseEnter.emit()})("mouseleave",function(){return s.mouseLeave.emit()}),p.Z7z(3,ou,2,8,"cue-button",2,ro),p.k0s()),2&i&&(p.R7$(2),p.Y8G("direction",s.direction())("noGap",s.noGap()),p.R7$(),p.Dyx(s.items()))},dependencies:[ze.n,bi.$,mn.d,os.a,no.Q,as.M,ls.D],encapsulation:2,changeDetection:0})}return o})(),lu=(()=>{class o{_targetEl=(0,tt.WQX)(p.aKT);_overlay=(0,tt.WQX)(iu.hJ);_overlayRef;_isOverlayHovered=!1;_subscriptions;display=(0,lt.hFB)("on-hover");menuItems=lt.hFB.required();menuEnabled=(0,lt.hFB)(!0);onMouseEnter(){if("on-hover"===this.display()){if(!this.menuItems().length)return void this.removeOverlayMenu();this.appendOverlayMenu()}}onMouseLeave(){this._checkShouldRemoveOverlay()}appendOverlayMenu(){if(!this.menuItems().length||this._overlayRef)return;const t=this._overlay.create({positionStrategy:this._overlay.position().flexibleConnectedTo(this._targetEl).withPositions([{originX:"end",originY:"center",overlayX:"start",overlayY:"center",offsetX:2,offsetY:0}])});this._overlayRef=t;const i=window.getComputedStyle(this._targetEl.nativeElement).color;t.overlayElement.style.color=i;const s=new eu.A8(au),n=t.attach(s);n.instance.items=this.menuItems,this._subscriptions&&this._subscriptions.unsubscribe(),this._subscriptions=new tu.yU,this._subscriptions.add(n.instance.mouseEnter.subscribe(()=>{this._isOverlayHovered=!0})),this._subscriptions.add(n.instance.mouseLeave.subscribe(()=>{this._isOverlayHovered=!1,this._checkShouldRemoveOverlay()}))}removeOverlayMenu(){this._overlayRef&&(this._subscriptions&&(this._subscriptions.unsubscribe(),this._subscriptions=void 0),this._overlayRef.detach(),this._overlayRef.dispose(),this._overlayRef=void 0)}_checkShouldRemoveOverlay(){setTimeout(()=>{this._isOverlayHovered||this.removeOverlayMenu()},300)}static \u0275fac=function(i){return new(i||o)};static \u0275dir=p.FsC({type:o,selectors:[["","cueEntityMenu",""]],hostBindings:function(i,s){1&i&&p.bIt("mouseenter",function(){return s.onMouseEnter()})("mouseleave",function(){return s.onMouseLeave()})},inputs:{display:[1,"display"],menuItems:[1,"menuItems"],menuEnabled:[1,"menuEnabled"]}})}return o})();var wi=ht(2245);let cu=(()=>{class o{entityMenuDirective;size=(0,lt.hFB)("m");key=lt.hFB.required();val=lt.geq.required();options=(0,lt.hFB)([]);suffix=(0,lt.hFB)("");valueChange=(0,lt.CGW)();editModeEnabled=(0,tt.vPA)(!1);valueChanged=(0,bt.EW)(()=>this.val()!==this.newValue());newValue=(0,bt.uu)(()=>this.val());labelSize=(0,bt.EW)(()=>{switch(this.size()){case"s":return"xs";case"m":return"s";case"l":return"m";case"xl":return"l"}});onKeyPress(t){this.editModeEnabled()&&("Escape"===t.key?(this._reset(),t.stopPropagation()):"Enter"===t.key&&this._emitChange())}saveCancelMenu=(0,bt.EW)(()=>{const t=[{icon:"close",label:"Cancel",action:()=>this._reset()}];return this.valueChanged()&&t.push({icon:"save",label:"Save",action:()=>this._emitChange()}),t});selectionChange(t){this.newValue.set(t?.toString()??"")}inputChange(t){this.newValue.set(t)}_emitChange(){this.valueChange.emit(this.newValue()),this.val.set(this.newValue()),this.editModeEnabled.set(!1)}_reset(){this.newValue.set(this.val()),this.editModeEnabled.set(!1)}static \u0275fac=function(i){return new(i||o)};static \u0275cmp=p.VBU({type:o,selectors:[["cue-key-val"]],viewQuery:function(i,s){if(1&i&&p.GBs(lu,5),2&i){let n;p.mGM(n=p.lsd())&&(s.entityMenuDirective=n.first)}},hostBindings:function(i,s){1&i&&p.bIt("keydown",function(r){return s.onKeyPress(r)},p.EBC)},inputs:{size:[1,"size"],key:[1,"key"],val:[1,"val"],options:[1,"options"],suffix:[1,"suffix"]},outputs:{val:"valChange",valueChange:"valueChange"},decls:8,vars:5,consts:[[1,"key-val-container"],[3,"size"],[1,"value-content"]],template:function(i,s){1&i&&(p.j41(0,"dl",0)(1,"dt")(2,"cue-typography",1),p.EFF(3),p.k0s()(),p.j41(4,"dd")(5,"cue-typography",1)(6,"span",2),p.EFF(7),p.k0s()()()()),2&i&&(p.R7$(2),p.Y8G("size",s.labelSize()),p.R7$(),p.JRh(s.key()),p.R7$(2),p.Y8G("size",s.size()),p.R7$(2),p.Lme("",s.val()," ",s.suffix()))},dependencies:[wi.o],styles:[".key-val-container[_ngcontent-%COMP%]{margin:0;display:flex;flex-direction:column;gap:var(--cue-grid-gap-s, 8px)}dt[_ngcontent-%COMP%], dd[_ngcontent-%COMP%]{margin:0}.read-mode-container[_ngcontent-%COMP%]{display:inline-flex;align-items:center;width:100%;position:relative}.read-mode-container.interactive[_ngcontent-%COMP%]:hover{cursor:pointer}.value-content[_ngcontent-%COMP%]{flex:1}[_nghost-%COMP%]{color:var(--cue-typography-text-color, inherit)}dt[_ngcontent-%COMP%] cue-typography[_ngcontent-%COMP%], dd[_ngcontent-%COMP%] cue-typography[_ngcontent-%COMP%], .value-content[_ngcontent-%COMP%]{color:var(--cue-typography-text-color, inherit)!important}dt[_ngcontent-%COMP%] cue-typography[_ngcontent-%COMP%] div[_ngcontent-%COMP%], dd[_ngcontent-%COMP%] cue-typography[_ngcontent-%COMP%] div[_ngcontent-%COMP%]{color:var(--cue-typography-text-color, inherit)!important}[_ngcontent-%COMP%]:deep(cue-svg-icon), [_ngcontent-%COMP%]:deep(cue-entity-menu cue-svg-icon){color:var(--cue-icon-color, inherit)!important}.dirty-indicator[_ngcontent-%COMP%]{opacity:.8;margin-left:4px;color:var(--cue-typography-text-color, inherit)!important;font-weight:700;font-size:.4em;transform:translateY(-1em)}"]})}return o})();const uu=["*"];let hu=(()=>{class o{static \u0275fac=function(i){return new(i||o)};static \u0275cmp=p.VBU({type:o,selectors:[["cue-key-val-list"]],ngContentSelectors:uu,decls:2,vars:0,consts:[[1,"key-val-list"]],template:function(i,s){1&i&&(p.NAR(),p.rj2(0,"div",0),p.SdG(1),p.eux())},styles:[".key-val-list[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:var(--cue-grid-gap-s)}"]})}return o})();function du(o,e){if(1&o&&p.nrm(0,"cue-key-val",3),2&o){const t=p.XpG();p.Y8G("val",t.name)}}function fu(o,e){if(1&o&&p.nrm(0,"cue-key-val",5),2&o){const t=e.$implicit;p.Y8G("key",t.label)("val",t.value)}}function pu(o,e){if(1&o&&(p.j41(0,"cue-typography",4),p.EFF(1),p.k0s(),p.j41(2,"cue-key-val-list"),p.Z7z(3,fu,1,2,"cue-key-val",5,p.Vm6),p.k0s()),2&o){const t=e.$implicit;p.R7$(),p.JRh(t.psetName),p.R7$(2),p.Dyx(t.props)}}function mu(o,e){if(1&o&&p.Z7z(0,pu,5,1,null,null,p.Vm6),2&o){const t=p.XpG();p.Dyx(t.psets)}}function gu(o,e){if(1&o&&(p.nVh(0,du,1,1,"cue-key-val",3),p.nVh(1,mu,2,0)),2&o){const t=e;p.vxM(t.name?0:-1),p.R7$(),p.vxM(t.psets.length>0?1:-1)}}function _u(o,e){if(1&o&&(p.j41(0,"cue-card",1)(1,"cue-flexcontainer",2),p.nVh(2,gu,2,2),p.k0s()()),2&o){let t;const i=p.XpG();p.Y8G("padded",!1)("scrollable",!0),p.R7$(2),p.vxM((t=i.props())?2:-1,t)}}function yu(o,e){if(1&o&&p.nrm(0,"cue-key-val",3),2&o){const t=p.XpG();p.Y8G("val",t.name)}}function vu(o,e){if(1&o&&p.nrm(0,"cue-key-val",5),2&o){const t=e.$implicit;p.Y8G("key",t.label)("val",t.value)}}function bu(o,e){if(1&o&&(p.j41(0,"cue-typography",4),p.EFF(1),p.k0s(),p.j41(2,"cue-key-val-list"),p.Z7z(3,vu,1,2,"cue-key-val",5,p.Vm6),p.k0s()),2&o){const t=e.$implicit;p.R7$(),p.JRh(t.psetName),p.R7$(2),p.Dyx(t.props)}}function wu(o,e){if(1&o&&p.Z7z(0,bu,5,1,null,null,p.Vm6),2&o){const t=p.XpG();p.Dyx(t.psets)}}function xu(o,e){if(1&o&&(p.nVh(0,yu,1,1,"cue-key-val",3),p.nVh(1,wu,2,0)),2&o){const t=e;p.vxM(t.name?0:-1),p.R7$(),p.vxM(t.psets.length>0?1:-1)}}function Cu(o,e){if(1&o&&(p.j41(0,"cue-flexcontainer",2),p.nVh(1,xu,2,2),p.k0s()),2&o){let t;const i=p.XpG();p.R7$(),p.vxM((t=i.props())?1:-1,t)}}let Eu=(()=>{class o{element=lt.hFB.required();wrapInCard=(0,lt.hFB)(!0);props=(0,bt.EW)(()=>{const t=this.element().itemData,i=this.formatItemPsets(t.IsDefinedBy||[]);return{name:t.Name?.value||"No name",psets:i}});formatItemPsets(t){const i=[];for(const[,s]of t.entries()){const{Name:n,HasProperties:r}=s;if(!("value"in n)||!Array.isArray(r))continue;const a=[];for(const[,l]of r.entries()){const{Name:c,NominalValue:u}=l;if(!("value"in c)||!("value"in u))continue;const h=c.value,f=u.value;h&&void 0!==f&&a.push({label:h,value:f.toString()})}i.push({psetName:n.value,props:a})}return i}static \u0275fac=function(i){return new(i||o)};static \u0275cmp=p.VBU({type:o,selectors:[["cue-bim-fragments-props-viewer"]],inputs:{element:[1,"element"],wrapInCard:[1,"wrapInCard"]},decls:3,vars:1,consts:[["direction","column","justify","start",1,"container"],[1,"card",3,"padded","scrollable"],["align","start","direction","column"],["key","Name",3,"val"],["size","s","weight","semibold"],[3,"key","val"]],template:function(i,s){1&i&&(p.j41(0,"cue-flexcontainer",0),p.nVh(1,_u,3,3,"cue-card",1)(2,Cu,2,1,"cue-flexcontainer",2),p.k0s()),2&i&&(p.R7$(),p.vxM(s.wrapInCard()?1:2))},dependencies:[ze.n,pn.Card,cu,hu,wi.o],styles:[".container[_ngcontent-%COMP%]{height:100%;pointer-events:none}.card[_ngcontent-%COMP%]{pointer-events:all;max-height:100%;width:300px;flex:1 1}.border-left[_ngcontent-%COMP%]{border-left:1px solid;padding-left:12px}"],changeDetection:0})}return o})();var oo=ht(9769);let Tu=(()=>{class o{selectedItem=(0,tt.vPA)(void 0);static \u0275fac=function(i){return new(i||o)};static \u0275prov=tt.jDH({token:o,factory:o.\u0275fac,providedIn:"root"})}return o})();var Pu=ht(5448),ao=ht(6117);const lo=(o,e)=>e.path;function Au(o,e){if(1&o){const t=p.RV6();p.j41(0,"cue-menu-item",7),p.bIt("click",function(s){const n=tt.eBV(t).$implicit,r=p.XpG(2);return tt.Njj(r.navigateTo(s,n.path))}),p.EFF(1),p.k0s()}if(2&o){const t=e.$implicit;p.R7$(),p.SpI(" ",t.name," ")}}function Mu(o,e){if(1&o&&(p.j41(0,"cue-flexcontainer",2)(1,"cue-menu")(2,"cue-button",4,0)(4,"cue-button-label"),p.EFF(5,"..."),p.k0s()(),p.j41(6,"cue-menu-wrap",5),p.Z7z(7,Au,2,1,"cue-menu-item",null,lo),p.k0s()(),p.j41(9,"cue-typography",6),p.EFF(10," \u203a "),p.k0s()()),2&o){const t=p.XpG();p.R7$(2),p.Y8G("size",t.buttonSize())("cueTooltip",t.hiddenPartsTooltip()),p.R7$(5),p.Dyx(t.hidddenParts()),p.R7$(2),p.Y8G("size",t.size())}}function Su(o,e){if(1&o&&(p.j41(0,"cue-typography",6),p.EFF(1," \u203a "),p.k0s()),2&o){const t=p.XpG(2);p.Y8G("size",t.size())}}function Iu(o,e){if(1&o){const t=p.RV6();p.j41(0,"cue-flexcontainer",8),p.bIt("click",function(s){const n=tt.eBV(t),r=n.$implicit,a=n.$index,l=n.$count,c=p.XpG();return tt.Njj(a!==l-1&&!c.buttonMode()&&c.navigateTo(s,r.path))}),p.j41(1,"cue-typography",9),p.EFF(2),p.k0s(),p.nVh(3,Su,2,1,"cue-typography",6),p.k0s()}if(2&o){const t=e.$implicit,i=e.$index,s=e.$count,n=p.XpG();p.AVh("clickable",i!==s-1&&n.updatePathOnClick()&&!n.buttonMode()),p.R7$(),p.AVh("full-length",n.nameFullLength()),p.Y8G("size",n.size())("weight",i===s-1?"medium":"regular")("title",t.name),p.R7$(),p.SpI(" ",t.name," "),p.R7$(),p.vxM(i!==s-1?3:-1)}}let Ou=(()=>{class o{path=lt.geq.required();size=(0,lt.hFB)("xs");rootName=(0,lt.hFB)(null);maxVisibleParts=(0,lt.hFB)(3);nameFullLength=(0,lt.hFB)(!1);updatePathOnClick=(0,lt.hFB)(!0);buttonMode=(0,lt.hFB)(!1);buttonSize=(0,bt.EW)(()=>{switch(this.size()){case"xs":case"s":default:return"s";case"m":case"l":case"xl":return"m"}});get sizeAttribute(){return this.size()}get buttonModeClass(){return this.buttonMode()}onHostClick(t){this.buttonMode()&&(t.stopPropagation(),this.clickedPath.emit(this.path()))}pathChange=(0,lt.CGW)();clickedPath=(0,lt.CGW)();allBreadcrumbParts=(0,bt.EW)(()=>{const t=this.path().split("/").filter(r=>""!==r),i=[],s=this.rootName();null!==s&&i.push({name:s,path:"/"});let n="";for(const r of t)n+=`/${r}`,i.push({name:r,path:n.endsWith("/")?n:`${n}/`});return i});shouldShowEllipsis=(0,bt.EW)(()=>this.allBreadcrumbParts().length>this.maxVisibleParts());visibleBreadcrumbParts=(0,bt.EW)(()=>{const t=this.allBreadcrumbParts(),i=this.maxVisibleParts();return t.length<=i?t:t.slice(-i)});hidddenParts=(0,bt.EW)(()=>{const t=this.allBreadcrumbParts(),i=this.maxVisibleParts();return t.length<=i?[]:t.slice(0,-i)});hiddenPartsTooltip=(0,bt.EW)(()=>{const t=this.hidddenParts();return 0===t.length?"":`${t.map(i=>i.name).join(" \u203a ")}`});navigateTo(t,i){console.log("Navigating to:",i),t.stopImmediatePropagation(),t.stopPropagation(),t.preventDefault(),this.clickedPath.emit(i),this.updatePathOnClick()&&(this.path.set(i),this.pathChange.emit(i))}static \u0275fac=function(i){return new(i||o)};static \u0275cmp=p.VBU({type:o,selectors:[["cue-breadcrumb"]],hostVars:3,hostBindings:function(i,s){1&i&&p.bIt("click",function(r){return s.onHostClick(r)}),2&i&&(p.BMQ("size",s.sizeAttribute),p.AVh("button-mode",s.buttonModeClass))},inputs:{path:[1,"path"],size:[1,"size"],rootName:[1,"rootName"],maxVisibleParts:[1,"maxVisibleParts"],nameFullLength:[1,"nameFullLength"],updatePathOnClick:[1,"updatePathOnClick"],buttonMode:[1,"buttonMode"]},outputs:{path:"pathChange",pathChange:"pathChange",clickedPath:"clickedPath"},decls:4,vars:1,consts:[["trigger",""],["direction","row","gap","s","align","center"],["direction","row","gap","s","align","center",1,"ellipsis-container"],["direction","row","gap","s",3,"clickable"],["trigger","","variant","ghost",3,"size","cueTooltip"],["menu",""],["weight","semibold",3,"size"],[3,"click"],["direction","row","gap","s",3,"click"],[1,"breadcrumb-text",3,"size","weight","title"]],template:function(i,s){1&i&&(p.j41(0,"cue-flexcontainer",1),p.nVh(1,Mu,11,3,"cue-flexcontainer",2),p.Z7z(2,Iu,4,9,"cue-flexcontainer",3,lo),p.k0s()),2&i&&(p.R7$(),p.vxM(s.shouldShowEllipsis()?1:-1),p.R7$(),p.Dyx(s.visibleBreadcrumbParts()))},dependencies:[oo.MD,wi.o,ze.n,bi.$,Pu.L,mn.d,ao.W,as.M,ls.D],styles:['.clickable[_ngcontent-%COMP%]{cursor:pointer}.clickable[_ngcontent-%COMP%]:hover{text-decoration:underline}.separator[_ngcontent-%COMP%]{color:#666;padding:0 4px}.full-length[_ngcontent-%COMP%]{max-width:none!important}.full-length[_ngcontent-%COMP%] > div[_ngcontent-%COMP%]{max-width:none!important;overflow:visible!important;text-overflow:unset!important;white-space:normal!important}.breadcrumb-text[_ngcontent-%COMP%]:not(.full-length){max-width:100px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;display:block}.breadcrumb-text[_ngcontent-%COMP%]:not(.full-length) > div[_ngcontent-%COMP%]{max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.ellipsis-container[_ngcontent-%COMP%]{cursor:default;display:flex;align-items:center}.ellipsis-text[_ngcontent-%COMP%]{color:#666;font-style:italic;line-height:1;display:flex;align-items:center;text-align:center;vertical-align:middle;justify-content:center;height:100%;min-height:1em}.ellipsis-text[_ngcontent-%COMP%] span[_ngcontent-%COMP%]{display:inline-block!important}.ellipsis-text[_ngcontent-%COMP%] *{display:flex!important;align-items:center!important;justify-content:center!important;height:100%!important;line-height:1!important}.button-mode[_nghost-%COMP%]{cursor:pointer}[size="xs"][_nghost-%COMP%] .breadcrumb-text[_ngcontent-%COMP%]:not(.full-length){max-width:70px}[size="s"][_nghost-%COMP%] .breadcrumb-text[_ngcontent-%COMP%]:not(.full-length){max-width:80px}[size="m"][_nghost-%COMP%] .breadcrumb-text[_ngcontent-%COMP%]:not(.full-length){max-width:100px}[size="l"][_nghost-%COMP%] .breadcrumb-text[_ngcontent-%COMP%]:not(.full-length){max-width:120px}[size="xl"][_nghost-%COMP%] .breadcrumb-text[_ngcontent-%COMP%]:not(.full-length){max-width:150px}']})}return o})();var ku=ht(29);const zu=()=>[],Fu=()=>({}),Du=(o,e)=>e.label;function Nu(o,e){if(1&o&&p.nrm(0,"cue-svg-icon",17),2&o){const t=p.XpG().$implicit;p.Y8G("name",t.icon)}}function Ru(o,e){if(1&o){const t=p.RV6();p.j41(0,"cue-menu-item",16),p.bIt("click",function(){const s=tt.eBV(t).$implicit;return tt.Njj(s.action())}),p.nVh(1,Nu,1,1,"cue-svg-icon",17),p.EFF(2),p.k0s()}if(2&o){const t=e.$implicit;p.Y8G("tooltip",t.tooltip??""),p.R7$(),p.vxM(t.icon?1:-1),p.R7$(),p.SpI(" ",t.label," ")}}function Bu(o,e){if(1&o&&(p.j41(0,"cue-menu",11),p.bIt("click",function(i){return i.stopPropagation()}),p.j41(1,"cue-button",12),p.nrm(2,"cue-button-icon",13),p.k0s(),p.j41(3,"cue-menu-wrap",14),p.Z7z(4,Ru,3,3,"cue-menu-item",15,Du),p.k0s()()),2&o){const t=p.XpG().$implicit;p.R7$(),p.Y8G("cueTooltip",t.tooltip??""),p.R7$(),p.Y8G("icon",t.icon),p.R7$(2),p.Dyx(t.menuItems)}}function Lu(o,e){if(1&o){const t=p.RV6();p.j41(0,"cue-button",18),p.bIt("click",function(s){return tt.eBV(t),p.XpG().$implicit.action(),tt.Njj(s.stopPropagation())}),p.nrm(1,"cue-button-icon",13),p.k0s()}if(2&o){const t=p.XpG().$implicit;p.Y8G("cueTooltip",t.tooltip??""),p.R7$(),p.Y8G("icon",t.icon)}}function Vu(o,e){if(1&o&&p.nVh(0,Bu,6,2,"cue-menu")(1,Lu,2,2,"cue-button",10),2&o){const t=e.$implicit;p.vxM(null!=t.menuItems&&t.menuItems.length?0:t.action?1:-1)}}function Uu(o,e){if(1&o&&(p.j41(0,"cue-flexcontainer",3),p.Z7z(1,Vu,2,1,null,null,p.Vm6),p.k0s()),2&o){const t=p.XpG().$implicit;p.R7$(),p.Dyx(t.buttons)}}function $u(o,e){if(1&o&&(p.j41(0,"cue-typography",20),p.EFF(1),p.k0s()),2&o){const t=p.XpG(2).$implicit;p.R7$(),p.JRh(t.subLabel)}}function ju(o,e){if(1&o&&(p.j41(0,"div",4)(1,"cue-typography",19),p.EFF(2),p.k0s(),p.nVh(3,$u,2,1,"cue-typography",20),p.k0s()),2&o){const t=p.XpG().$implicit,i=p.XpG();p.R7$(),p.Y8G("weight",i.isSelected(t)?"semibold":"regular")("size",i.size()),p.R7$(),p.JRh(t.label),p.R7$(),p.vxM(t.subLabel?3:-1)}}function Hu(o,e){if(1&o&&p.nrm(0,"cue-breadcrumb",6),2&o){const t=p.XpG().$implicit,i=p.XpG();p.Y8G("maxVisibleParts",5)("path",t.label)("size",i.size())("nameFullLength",!0)("updatePathOnClick",!1)}}function Yu(o,e){if(1&o&&p.nrm(0,"cue-svg-icon",21),2&o){const t=p.XpG().$implicit,i=p.XpG();p.AVh("expanded",i.isExpanded(t))}}function Zu(o,e){if(1&o&&(p.j41(0,"div",8),p.nrm(1,"cue-tree-menu",22),p.k0s()),2&o){const t=p.XpG().$implicit,i=p.XpG();p.R7$(),p.Y8G("items",t.children||p.lJ4(2,zu))("size",i.size())}}function Wu(o,e){if(1&o&&(p.j41(0,"div",23),p.bIt("click",function(i){return i.stopPropagation()}),p.eu8(1,24),p.k0s()),2&o){const t=p.XpG().$implicit;p.R7$(),p.Y8G("ngTemplateOutlet",t.contentTemplate)("ngTemplateOutletContext",t.templateContext??p.lJ4(2,Fu))}}function Gu(o,e){if(1&o){const t=p.RV6();p.j41(0,"li",1)(1,"cue-flexcontainer",2),p.bIt("click",function(){const s=tt.eBV(t).$implicit,n=p.XpG();return tt.Njj(n.handleItemClick(s))}),p.nVh(2,Uu,3,0,"cue-flexcontainer",3),p.nVh(3,ju,4,4,"div",4),p.nrm(4,"span",5),p.nVh(5,Hu,1,5,"cue-breadcrumb",6),p.nVh(6,Yu,1,2,"cue-svg-icon",7),p.k0s(),p.nVh(7,Zu,2,3,"div",8),p.nVh(8,Wu,2,3,"div",9),p.k0s()}if(2&o){const t=e.$implicit,i=p.XpG();p.R7$(),p.AVh("has-children",i.hasChildren(t)),p.R7$(),p.vxM(null!=t.buttons&&t.buttons.length?2:-1),p.R7$(),p.vxM(void 0===t.type||"text"===t.type?3:-1),p.R7$(2),p.vxM("breadcrumb"===t.type?5:-1),p.R7$(),p.vxM(i.hasChildren(t)?6:-1),p.R7$(),p.vxM(i.hasChildren(t)&&i.isExpanded(t)?7:-1),p.R7$(),p.vxM(t.contentTemplate?8:-1)}}let qu=(()=>{class o{_service=(0,tt.WQX)(Tu);items=(0,lt.geq)([]);size=(0,lt.hFB)("m");collapseOnSelect=(0,lt.hFB)(!1);initialExpandDepth=(0,lt.hFB)(-1);expandedItems=new Set;selectionChanged=(0,lt.CGW)();onItemsChange=(0,tt.QZP)(()=>{this.collapseOnSelect()||this._initialExpandSelected()});onSelectionChange=(0,tt.QZP)(()=>{const t=this._service.selectedItem();void 0!==t&&this.selectionChanged.emit(t)});ngOnDestroy(){this.items.update(()=>[])}handleItemClick(t){if(this.hasChildren(t)){this.expandedItems.has(t)?this.expandedItems.delete(t):this.expandedItems.add(t);const i=this._service.selectedItem();void 0!==i&&(i.selected=!1),t.selected=!0,this._service.selectedItem.set(t)}else this._setSelected(t),this._update()}hasChildren(t){return!!t.children&&t.children.length>0}isExpanded(t){return this.expandedItems.has(t)}isSelected(t){return t.selected}_setSelected(t){const i=this._service.selectedItem();void 0!==i&&(i.selected=!1),t.selected=!0}_update(){this.items.update(()=>[...this.items()])}_initialExpandSelected(){this.expandedItems.clear();const t=this.initialExpandDepth(),i=(s,n=[],r=0)=>{for(const a of s){if(t>=0&&r<=t&&this.hasChildren(a)&&this.expandedItems.add(a),a.selected){this._service.selectedItem.set(a);for(const l of n)this.expandedItems.add(l)}a.children&&a.children.length>0&&i(a.children,[...n,a],r+1)}};i(this.items()??[])}static \u0275fac=function(i){return new(i||o)};static \u0275cmp=p.VBU({type:o,selectors:[["cue-tree-menu"]],inputs:{items:[1,"items"],size:[1,"size"],collapseOnSelect:[1,"collapseOnSelect"],initialExpandDepth:[1,"initialExpandDepth"]},outputs:{items:"itemsChange",selectionChanged:"selectionChanged"},decls:3,vars:0,consts:[[1,"menu"],[1,"menu-item"],["justify","start","align","center","gap","s",1,"menu-item-header",3,"click"],["gap","s","align","center"],[2,"display","flex","flex-direction","row","align-items","baseline","gap","6px"],[2,"flex","1"],[3,"maxVisibleParts","path","size","nameFullLength","updatePathOnClick"],["name","arrow-dropdown",1,"menu-item-arrow",3,"expanded"],[1,"submenu"],[1,"menu-item-content"],["size","xs","variant","ghost","tooltipPlacement","right",3,"cueTooltip"],[3,"click"],["trigger","","size","xs","variant","ghost","tooltipPlacement","right",3,"cueTooltip"],[3,"icon"],["menu",""],[3,"tooltip"],[3,"click","tooltip"],["before","",3,"name"],["size","xs","variant","ghost","tooltipPlacement","right",3,"click","cueTooltip"],[3,"weight","size"],["size","xs",2,"opacity","0.6"],["name","arrow-dropdown",1,"menu-item-arrow"],[3,"items","size"],[1,"menu-item-content",3,"click"],[3,"ngTemplateOutlet","ngTemplateOutletContext"]],template:function(i,s){1&i&&(p.j41(0,"ul",0),p.Z7z(1,Gu,9,8,"li",1,p.Vm6),p.k0s()),2&i&&(p.R7$(),p.Dyx(s.items()))},dependencies:[o,wi.o,ze.n,Ou,bi.$,os.a,ku.A,mn.d,oo.T3,ao.W,ls.D,as.M],styles:[".menu[_ngcontent-%COMP%]{list-style:none;padding:0;margin:0}.menu-item[_ngcontent-%COMP%]{cursor:pointer;-webkit-user-select:none;user-select:none}.menu-item-header[_ngcontent-%COMP%]{padding:8px 16px;transition:background-color .2s}.menu-item-header[_ngcontent-%COMP%]:hover{background-color:var(--cue-color-green);color:var(--cue-color-black)}.menu-item-header[_ngcontent-%COMP%]:hover *{color:var(--cue-color-black);fill:var(--cue-color-black)}.menu-item-header.has-children[_ngcontent-%COMP%]{font-weight:700}.menu-item-arrow[_ngcontent-%COMP%]{transition:transform .2s;flex-shrink:0}.menu-item-arrow.expanded[_ngcontent-%COMP%]{transform:rotate(180deg)}.submenu[_ngcontent-%COMP%]{padding-left:16px;border-left:1px solid}"]})}return o})(),Xu=(()=>{class o{_service=(0,tt.WQX)(fn);type=(0,lt.hFB)("spatial");models=lt.geq.required();treeItems=(0,tt.vPA)([]);constructor(){var t=this;(0,tt.QZP)((0,H.A)(function*(){if(!t._service.loadedModels().length)return;console.log(t._service.loadedModels());const i=yield Promise.all(t.models().map(n=>t.getSpatialStructure(n)));console.log("Model Trees:",i);const s=[];t.models().forEach(n=>{s.push({label:n.name,buttons:[{icon:n.visible?"view-inactive":"view-active",action:()=>t.toggleVisibility(n)}]})}),t.treeItems.update(()=>[...s])}))}toggleVisibility(t){var i=this;return(0,H.A)(function*(){t.visible?(yield i._service.disposeModels([t]),console.log(`Model ${t.name} (${t.id}) disposed`)):yield i._service.loadFragmentFiles([t]),i.models.update(()=>[...i.models()])})()}getSpatialStructure(t){var i=this;return(0,H.A)(function*(){const s=yield i._service.getSpatialStructure(t);if(s)return{label:s.category,children:s.children?.map(n=>({label:n.name,children:n.children?.map(r=>({label:r.name}))}))}})()}static \u0275fac=function(i){return new(i||o)};static \u0275cmp=p.VBU({type:o,selectors:[["cue-bim-fragments-tree-viewer"]],inputs:{type:[1,"type"],models:[1,"models"]},outputs:{models:"modelsChange"},decls:1,vars:1,consts:[["size","s",3,"items"]],template:function(i,s){1&i&&p.nrm(0,"cue-tree-menu",0),2&i&&p.Y8G("items",s.treeItems())},dependencies:[qu],styles:[".container[_ngcontent-%COMP%]{height:100%;pointer-events:none}.card[_ngcontent-%COMP%]{pointer-events:all;max-height:100%;width:300px;flex:1 1}.border-left[_ngcontent-%COMP%]{border-left:1px solid;padding-left:12px}"],changeDetection:0})}return o})();var Qu=ht(6034);const co=(o,e)=>e.id;function Ku(o,e){1&o&&(p.j41(0,"cue-typography",4),p.EFF(1,"Loading..."),p.k0s())}function Ju(o,e){if(1&o){const t=p.RV6();p.j41(0,"cue-typography",4),p.EFF(1),p.k0s(),p.j41(2,"cue-button",6),p.bIt("click",function(){const s=tt.eBV(t).$implicit,n=p.XpG(3);return tt.Njj(n.toggleVisibility(s))}),p.nrm(3,"cue-button-icon",7),p.k0s()}if(2&o){const t=e.$implicit;p.R7$(),p.JRh(t.name),p.R7$(2),p.Y8G("icon",t.visible?"view-inactive":"view-active")}}function th(o,e){if(1&o&&(p.j41(0,"cue-flexcontainer",5),p.Z7z(1,Ju,4,2,null,null,co),p.k0s()),2&o){const t=p.XpG(2);p.R7$(),p.Dyx(t.models())}}function eh(o,e){if(1&o){const t=p.RV6();p.j41(0,"cue-typography",3),p.EFF(1),p.k0s(),p.j41(2,"cue-bim-fragments-tree-viewer",8),p.mxI("modelsChange",function(s){tt.eBV(t);const n=p.XpG(2);return p.DH7(n.models,s)||(n.models=s),tt.Njj(s)}),p.k0s()}if(2&o){const t=p.XpG(2);p.R7$(),p.JRh(t.treeLabel()),p.R7$(),p.R50("models",t.models)}}function ih(o,e){if(1&o&&(p.j41(0,"cue-draggable-card",0)(1,"cue-flexcontainer",1)(2,"cue-flexcontainer",2)(3,"cue-typography",3),p.EFF(4,"Models"),p.k0s(),p.nVh(5,Ku,2,0,"cue-typography",4)(6,th,3,0,"cue-flexcontainer",5),p.k0s(),p.nVh(7,eh,3,2),p.k0s()()),2&o){const t=p.XpG();p.Y8G("padded",!1),p.R7$(5),p.vxM(t.modelsAreLoading()?5:6),p.R7$(2),p.vxM(t.displayDecompositionTree()?7:-1)}}function sh(o,e){1&o&&(p.j41(0,"cue-typography",4),p.EFF(1,"Loading..."),p.k0s())}function nh(o,e){if(1&o){const t=p.RV6();p.j41(0,"cue-typography",4),p.EFF(1),p.k0s(),p.j41(2,"cue-button",6),p.bIt("click",function(){const s=tt.eBV(t).$implicit,n=p.XpG(3);return tt.Njj(n.toggleVisibility(s))}),p.nrm(3,"cue-button-icon",7),p.k0s()}if(2&o){const t=e.$implicit;p.R7$(),p.JRh(t.name),p.R7$(2),p.Y8G("icon",t.visible?"view-inactive":"view-active")}}function rh(o,e){if(1&o&&(p.j41(0,"cue-flexcontainer",5),p.Z7z(1,nh,4,2,null,null,co),p.k0s()),2&o){const t=p.XpG(2);p.R7$(),p.Dyx(t.models())}}function oh(o,e){if(1&o){const t=p.RV6();p.j41(0,"cue-typography",3),p.EFF(1),p.k0s(),p.j41(2,"cue-bim-fragments-tree-viewer",8),p.mxI("modelsChange",function(s){tt.eBV(t);const n=p.XpG(2);return p.DH7(n.models,s)||(n.models=s),tt.Njj(s)}),p.k0s()}if(2&o){const t=p.XpG(2);p.R7$(),p.JRh(t.treeLabel()),p.R7$(),p.R50("models",t.models)}}function ah(o,e){if(1&o&&(p.j41(0,"cue-flexcontainer",1)(1,"cue-flexcontainer",2)(2,"cue-typography",3),p.EFF(3,"Models"),p.k0s(),p.nVh(4,sh,2,0,"cue-typography",4)(5,rh,3,0,"cue-flexcontainer",5),p.k0s(),p.nVh(6,oh,3,2),p.k0s()),2&o){const t=p.XpG();p.R7$(4),p.vxM(t.modelsAreLoading()?4:5),p.R7$(2),p.vxM(t.displayDecompositionTree()?6:-1)}}let lh=(()=>{class o{_service=(0,tt.WQX)(fn);models=lt.geq.required();draggable=(0,lt.hFB)(!0);modelsAreLoading=this._service.modelsAreLoading;displayDecompositionTree=(0,bt.EW)(()=>void 0!==this._service.settings().toolbar.displayDecompositionTree);treeLabel=(0,bt.EW)(()=>"spatial"===this._service.settings().toolbar.displayDecompositionTree?"Spatial Decomposition":"System Decomposition");toggleVisibility(t){var i=this;return(0,H.A)(function*(){console.log("TOGGLE VISIBILITY",t),t.visible?(yield i._service.disposeModels([t]),console.log(`Model ${t.name} (${t.id}) disposed`)):yield i._service.loadFragmentFiles([t]),i.models.update(()=>[...i.models()])})()}static \u0275fac=function(i){return new(i||o)};static \u0275cmp=p.VBU({type:o,selectors:[["cue-bim-fragments-visibility-menu"]],inputs:{models:[1,"models"],draggable:[1,"draggable"]},outputs:{models:"modelsChange"},decls:2,vars:1,consts:[["margin","0",1,"draggable",3,"padded"],["direction","column","gap","l",2,"padding","0 10px 10px 10px"],["align","start","direction","column",2,"width","100%"],["size","s","weight","semibold"],["size","s"],["direction","row","justify","space-between","align","center",2,"width","100%"],["size","xs",3,"click"],[3,"icon"],[3,"modelsChange","models"]],template:function(i,s){1&i&&p.nVh(0,ih,8,3,"cue-draggable-card",0)(1,ah,7,2,"cue-flexcontainer",1),2&i&&p.vxM(s.draggable()?0:1)},dependencies:[Qu.y,wi.o,ze.n,bi.$,os.a,Xu],styles:[".draggable[_ngcontent-%COMP%]{z-index:101}"],changeDetection:0})}return o})();const ch=["bimViewer"],uo=()=>({position:"bottomleft"}),uh=(o,e)=>e.label;function hh(o,e){if(1&o){const t=p.RV6();p.j41(0,"cue-menu-item",4),p.bIt("click",function(){const s=tt.eBV(t).$implicit;return tt.Njj(s.action())}),p.EFF(1),p.k0s()}if(2&o){const t=e.$implicit;p.R7$(),p.JRh(t.label)}}function dh(o,e){if(1&o&&(p.j41(0,"cue-menu-wrap"),p.Z7z(1,hh,2,1,"cue-menu-item",null,uh),p.k0s()),2&o){const t=p.XpG();p.R7$(),p.Dyx(t.contextMenuItems())}}function fh(o,e){if(1&o){const t=p.RV6();p.j41(0,"cue-bim-fragments-visibility-menu",13),p.mxI("modelsChange",function(s){tt.eBV(t);const n=p.XpG(2);return p.DH7(n.models,s)||(n.models=s),tt.Njj(s)}),p.k0s()}if(2&o){const t=p.XpG(2);p.R50("models",t.models),p.Y8G("draggable",!1)}}function ph(o,e){if(1&o&&p.nrm(0,"cue-bim-fragments-toolbar",15),2&o){const t=p.XpG(3),i=p.r8f(3);p.Aen(t.toolbarStyle()),p.Y8G("settings",i)}}function mh(o,e){1&o&&p.nVh(0,ph,1,3,"cue-bim-fragments-toolbar",14),2&o&&p.vxM(e.hidden?-1:0)}function gh(o,e){if(1&o&&(p.j41(0,"cue-card",16),p.nrm(1,"cue-bim-fragments-props-viewer",17),p.k0s()),2&o){const t=p.XpG(2);p.AVh("hidden",null===t.$clickedElement()),p.R7$(),p.Y8G("element",e)("wrapInCard",!1)}}function _h(o,e){if(1&o){const t=p.RV6();p.j41(0,"cue-card",5),p.nVh(1,fh,1,2,"cue-bim-fragments-visibility-menu",6),p.k0s(),p.j41(2,"div",7)(3,"cue-card",8)(4,"div",9,1),p.bIt("resized",function(){tt.eBV(t);const s=p.XpG();return tt.Njj(s.onResized())})("windowResized",function(){tt.eBV(t);const s=p.XpG();return tt.Njj(s.onResized())}),p.k0s(),p.nVh(6,mh,1,1),p.k0s(),p.j41(7,"a",10),p.EFF(8,"Powered by "),p.j41(9,"span",11),p.EFF(10,"ThatOpen"),p.k0s()()(),p.nVh(11,gh,2,4,"cue-card",12)}if(2&o){let t,i;const s=p.XpG(),n=p.sdS(1),r=p.r8f(3);p.R7$(),p.vxM(r.showModelList&&s.models().length?1:-1),p.R7$(3),p.Y8G("cueContextMenu",n)("contextMenuData",p.lJ4(6,uo))("cueContextEnabled",null!==s.$hoveredElement()),p.R7$(2),p.vxM((t=r.toolbar)?6:-1,t),p.R7$(5),p.vxM((i=s.$clickedElement())?11:-1,i)}}function yh(o,e){if(1&o&&p.nrm(0,"cue-bim-fragments-toolbar",15),2&o){const t=p.XpG(3),i=p.r8f(3);p.Aen(t.toolbarStyle()),p.Y8G("settings",i)}}function vh(o,e){1&o&&p.nVh(0,yh,1,3,"cue-bim-fragments-toolbar",14),2&o&&p.vxM(e.hidden?-1:0)}function bh(o,e){1&o&&(p.j41(0,"div",19),p.nrm(1,"cue-bim-fragments-props-viewer",21),p.k0s()),2&o&&(p.R7$(),p.Y8G("element",e))}function wh(o,e){if(1&o){const t=p.RV6();p.j41(0,"cue-bim-fragments-visibility-menu",22),p.mxI("modelsChange",function(s){tt.eBV(t);const n=p.XpG(2);return p.DH7(n.models,s)||(n.models=s),tt.Njj(s)}),p.k0s()}if(2&o){const t=p.XpG(2);p.R50("models",t.models)}}function xh(o,e){if(1&o){const t=p.RV6();p.j41(0,"div",18,1),p.bIt("resized",function(){tt.eBV(t);const s=p.XpG();return tt.Njj(s.onResized())}),p.nVh(2,vh,1,1),p.nVh(3,bh,2,1,"div",19),p.nVh(4,wh,1,1,"cue-bim-fragments-visibility-menu",20),p.j41(5,"a",10),p.EFF(6,"Powered by "),p.j41(7,"span",11),p.EFF(8,"ThatOpen"),p.k0s()()()}if(2&o){let t,i;const s=p.XpG(),n=p.sdS(1),r=p.r8f(3);p.Y8G("cueContextMenu",n)("contextMenuData",p.lJ4(6,uo))("cueContextEnabled",null!==s.$hoveredElement()),p.R7$(2),p.vxM((t=r.toolbar)?2:-1,t),p.R7$(),p.vxM((i=s.$clickedElement())?3:-1,i),p.R7$(),p.vxM(r.showModelList&&s.models().length?4:-1)}}let Ch=(()=>{class o{_service=(0,tt.WQX)(fn);data=(0,lt.hFB)(void 0);settings=(0,lt.hFB)(new Bt.R_);clickedElement=(0,lt.CGW)();hoveredElement=(0,lt.CGW)();selectedElements=(0,lt.CGW)();$hoveredElement=(0,tt.vPA)(null);$clickedElement=(0,tt.vPA)(null);models=(0,bt.uu)(()=>this.data()?.models??[]);detailedView=(0,bt.EW)(()=>!0===this.settings().detailedViewEnabled);toolbarStyle=(0,bt.EW)(()=>{const t=this.settings().toolbar;return{position:"absolute",left:t.margin,right:t.margin,["top"===t.position?"top":"bottom"]:t.margin,"z-index":"10",display:"flex","justify-content":"center"}});contextMenuItems=(0,bt.EW)(()=>{const t=[];return this.settings().showPropertiesOnClick&&(console.log("ADDING PROPERTIES MENU ITEM"),t.push({label:"Show Properties",action:()=>{this.$clickedElement.update(()=>this._service.clickedElement())}})),this.settings().elementClickOptions&&t.push(...this.settings().elementClickOptions),t});viewerReady=this._service.viewerReady;onClickElement=(0,tt.QZP)(()=>{this._service.clickedElement()||this.$clickedElement.set(null),this.clickedElement.emit(this._service.clickedElement())});onHoverElement=(0,tt.QZP)(()=>{this.$hoveredElement.set(this._service.hoveredElement()),this.hoveredElement.emit(this._service.hoveredElement())});onSelectionChange=(0,tt.QZP)(()=>{this.selectedElements.emit(this._service.selectedElements())});set bimViewer(t){t&&this._service.init(t.nativeElement)}loadFilesOnData=(0,tt.QZP)(()=>{const t=this.models();console.log(t),this.viewerReady()&&t.length&&(console.info("Loading models:",t),this._service.updateModels(t))});setSettings=(0,tt.QZP)(()=>this._service.settings.update(()=>Object.assign({},this.settings())));ngOnDestroy(){this._service.dispose()}onResized(){this._service.updateAspectRatio()}static \u0275fac=function(i){return new(i||o)};static \u0275cmp=p.VBU({type:o,selectors:[["cue-bim-fragments-viewer"]],viewQuery:function(i,s){if(1&i&&p.GBs(ch,5),2&i){let n;p.mGM(n=p.lsd())&&(s.bimViewer=n.first)}},inputs:{data:[1,"data"],settings:[1,"settings"]},outputs:{clickedElement:"clickedElement",hoveredElement:"hoveredElement",selectedElements:"selectedElements"},decls:6,vars:2,consts:[["hoveringElement",""],["bimViewer",""],["direction","row",2,"flex","1 1","height","100%"],["cueResized","","trigger","leftclick",2,"height","100%","width","100%","position","relative",3,"cueContextMenu","contextMenuData","cueContextEnabled"],[3,"click"],["variant","primary",2,"flex","0 0 250px","min-width","0","display","flex","flex-direction","column","gap","0.5rem","padding","0.5rem"],[3,"models","draggable"],[2,"flex","1 1 0","min-width","0","min-height","0","position","relative","display","flex"],[2,"flex","1 1 0","min-width","0","display","flex"],["cueResized","","trigger","leftclick",2,"height","100%","width","100%","min-width","0","min-height","0","flex","1 1 0",3,"resized","windowResized","cueContextMenu","contextMenuData","cueContextEnabled"],["href","https://thatopen.com","target","_blank","rel","noopener noreferrer",1,"bim-viewer-credits"],[2,"font-weight","800"],["variant","accent",2,"flex","0 0 250px","min-width","0","display","flex","flex-direction","column","gap","0.5rem","padding","0.5rem",3,"hidden"],[3,"modelsChange","models","draggable"],[3,"settings","style"],[3,"settings"],["variant","accent",2,"flex","0 0 250px","min-width","0","display","flex","flex-direction","column","gap","0.5rem","padding","0.5rem"],[2,"flex","1 1","min-height","0",3,"element","wrapInCard"],["cueResized","","trigger","leftclick",2,"height","100%","width","100%","position","relative",3,"resized","cueContextMenu","contextMenuData","cueContextEnabled"],[1,"viewer-popup","props-popup"],[3,"models"],[3,"element"],[3,"modelsChange","models"]],template:function(i,s){1&i&&(p.DNE(0,dh,3,0,"ng-template",null,0,p.C5r),p.j41(2,"cue-flexcontainer",2),p.SS7(3),p.nVh(4,_h,12,7)(5,xh,9,7,"div",3),p.k0s()),2&i&&(p.R7$(3),p.bH3(s.settings()),p.R7$(),p.vxM(s.detailedView()?4:5))},dependencies:[Xc.C,as.M,ls.D,ze.n,pn.Card,no.Q,Jc,Eu,lh],styles:['@import"https://fonts.googleapis.com/css2?family=Sora:wght@400;700;800&display=swap";[_nghost-%COMP%]{display:contents}.viewer-popup[_ngcontent-%COMP%]{position:absolute;z-index:100}.props-popup[_ngcontent-%COMP%]{top:8px;right:8px;bottom:8px;width:300px}.hidden[_ngcontent-%COMP%]{display:none;color:red}.bim-viewer-credits[_ngcontent-%COMP%]{position:absolute;bottom:0;left:0;font-family:Sora,sans-serif;font-size:10px;line-height:1;color:#000000bf;background:#ffffffbf;padding:2px 5px;border-radius:3px;text-decoration:none;z-index:1000;pointer-events:auto}.bim-viewer-credits[_ngcontent-%COMP%]:hover{color:#000;background:#ffffffe6}'],changeDetection:0})}return o})()},5187(xn,Ke,ht){ht.d(Ke,{Card:()=>b});var tt=ht(7705),lt=ht(2271),bt=ht(5970),Bt=ht(5547);const H=["*"];let b=(()=>{class pe{style=(0,tt.hFB)("");variant=(0,tt.hFB)("default");shadow=(0,tt.hFB)(!1);padded=(0,tt.hFB)(!0);scrollable=(0,tt.hFB)(!1);maxHeight=(0,tt.hFB)(void 0);maxContentHeight=(0,tt.hFB)(!1);isScrollable=(0,lt.EW)(()=>this.scrollable()||void 0!==this.maxHeight());getClass=(0,lt.EW)(()=>`variant-${this.variant()}`);getStyles=(0,lt.EW)(()=>{const _t="fade"===this.variant()?"neutral":this.variant(),B=[`\n color: var(--cue-${_t}Contrast);\n --background-color: var(--cue-${_t});\n background-color: var(--background-color);\n max-height: ${this.maxHeight()??"none"};\n position: ${this.isScrollable()?"relative":void 0};\n min-height: ${this.isScrollable()?void 0:"fit-content"};\n `];return"fade"===this.variant()&&B.push(`\n background-image: linear-gradient(to bottom,var(--cue-${_t}),var(--cue-main-background));\n `),B.push(this.style()),B.join("")});innerDisplay=(0,lt.EW)(()=>this.isScrollable()?"block":"contents");onResize(_t){if(!this.maxContentHeight())return;const B=Array.from(_t.element.children).reduce((Lt,ae)=>ae.getBoundingClientRect().height+Lt,0);_t.element.parentElement.style.maxHeight=`calc(${B}px + var(--cue-card-padding-y) * 2 + 2px)`}static \u0275fac=function(B){return new(B||pe)};static \u0275cmp=Bt.VBU({type:pe,selectors:[["cue-card"]],hostVars:8,hostBindings:function(B,Lt){2&B&&(Bt.Aen(Lt.getStyles()),Bt.HbH(Lt.getClass()),Bt.AVh("padded",Lt.padded())("shadow",Lt.shadow()))},inputs:{style:[1,"style"],variant:[1,"variant"],shadow:[1,"shadow"],padded:[1,"padded"],scrollable:[1,"scrollable"],maxHeight:[1,"maxHeight"],maxContentHeight:[1,"maxContentHeight"]},ngContentSelectors:H,decls:2,vars:2,consts:[["cueResized","",1,"inner",3,"resized"]],template:function(B,Lt){1&B&&(Bt.NAR(),Bt.j41(0,"div",0),Bt.bIt("resized",function(le){return Lt.onResize(le)}),Bt.SdG(1),Bt.k0s()),2&B&&Bt.xc7("display",Lt.innerDisplay())},dependencies:[bt.C],styles:["[_nghost-%COMP%]{display:block;border-radius:var(--cue-card-border-radius);border:1px solid var(--cue-card-border-color);box-sizing:border-box;overflow:hidden;--cue-scrollbar-thumb-color: var(--cue-color-lightgray)}.padded[_nghost-%COMP%]{padding:var(--cue-card-padding-y) var(--cue-card-padding-x)}.shadow[_nghost-%COMP%]{box-shadow:var(--cue-card-box-shadow)}.variant-default[_nghost-%COMP%]{--cue-paginator-text-color: var(--cue-paginator-text-color);--cue-input-border-bottom-color: var(--cue-main-foreground);--cue-input-placeholder-color: var(--cue-color-darkmidgray);--cue-input-label-color: var(--cue-main-foreground);--cue-input-value-color: var(--cue-main-foreground);--cue-stepper-border-color: var(--cue-main-foreground);--cue-stepper-fill-color: var(--cue-main-foreground);--cue-stepper-connector-color: var(--cue-main-foreground)}body.dark .variant-default[_nghost-%COMP%]{--cue-scrollbar-thumb-color: var(--cue-color-midgray);--cue-paginator-text-color: var(--cue-color-midgray)}.variant-secondary[_nghost-%COMP%], .variant-primary[_nghost-%COMP%]{--cue-button-primary-focus-color: var(--cue-color-ultralightgray);--cue-button-primary-foreground: var(--cue-color-blue);--cue-button-primary-border-color: var(--cue-color-ultralightgray);--cue-button-primary-background: var(--cue-color-ultralightgray);--cue-button-primary-disabled-foreground: var(--cue-color-midgray);--cue-button-primary-disabled-background: var(--cue-color-lightgray);--cue-button-primary-disabled-border-color: var(--cue-color-lightgray);--cue-button-secondary-disabled-foreground: var(--cue-color-midgray);--cue-button-secondary-disabled-border-color: var(--cue-color-midgray);--cue-input-value-color: var(--cue-color-ultralightgray);--cue-input-label-color: var(--cue-color-ultralightgray);--cue-input-placeholder-color: var(--cue-color-lightgray);--cue-input-border-bottom-color: var(--cue-color-ultralightgray);--cue-input-switch-background: rgba(255, 255, 255, .25);--cue-input-switch-checked-background: var(--cue-color-green);--cue-input-switch-checked-indicator-background: var(--cue-color-darkgray);--cue-stepper-border-color: var(--cue-color-ultralightgray);--cue-stepper-fill-color: var(--cue-color-ultralightgray);--cue-stepper-connector-color: var(--cue-color-ultralightgray);--cue-table-text-color: var(--cue-color-ultralightgray);--cue-table-secondary-text-color: var(--cue-color-lightgray);--cue-table-row-border-bottom-color: var(--cue-color-ultralightgray);--cue-chart-text-color: var(--cue-color-ultralightgray);--cue-paginator-text-color: var(--cue-color-ultralightgray)}:is(.variant-secondary[_nghost-%COMP%], .variant-primary[_nghost-%COMP%]) .ag-cell{--cue-input-value-color: var(--cue-table-text-color);--cue-input-placeholder-color: var(--cue-table-secondary-text-color)}.variant-secondary[_nghost-%COMP%]{--cue-input-switch-checked-background: var(--cue-color-blue);--cue-chart-border-background-color: var(--cue-secondary)}.variant-accent[_nghost-%COMP%]{--cue-chart-border-background-color: var(--cue-accent);--cue-chart-text-color: var(--cue-color-darkgray);--cue-chart-text-color-select: var(--cue-color-darkmidgray);--cue-input-value-color: var(--cue-color-darkgray);--cue-input-label-color: var(--cue-color-darkgray);--cue-input-placeholder-color: var(--cue-color-darkmidgray);--cue-input-border-bottom-color: var(--cue-color-darkgray);--cue-input-border-color: var(--cue-color-darkgray);--cue-stepper-border-color: var(--cue-color-darkgray);--cue-stepper-fill-color: var(--cue-color-darkgray);--cue-stepper-connector-color: var(--cue-color-darkgray)}.variant-primary[_nghost-%COMP%]{--cue-chart-border-background-color: var(--cue-primary);--cue-chart-text-color: var(--cue-color-ultralightgray);--cue-chart-text-color-select: var(--cue-color-lightgray)}[_nghost-%COMP%] > .inner[_ngcontent-%COMP%]{position:absolute;inset:var(--cue-card-padding-y) 0 0 var(--cue-card-padding-x);overflow:auto;padding-right:var(--cue-card-padding-x);padding-bottom:var(--cue-card-padding-y);scrollbar-width:thin;scrollbar-color:var(--cue-scrollbar-thumb-color) transparent}[_nghost-%COMP%] > .inner[_ngcontent-%COMP%]::-webkit-scrollbar{width:4px;height:4px}[_nghost-%COMP%] > .inner[_ngcontent-%COMP%]::-webkit-scrollbar-thumb{background-color:var(--cue-scrollbar-thumb-color);border-radius:2px}[_nghost-%COMP%] > .inner[_ngcontent-%COMP%]::-webkit-scrollbar-track{background:transparent}"]})}return pe})()},5964(xn,Ke,ht){ht.d(Ke,{p:()=>bt});var tt=ht(9974),lt=ht(4360);function bt(Bt,H){return(0,tt.N)((dt,b)=>{let pe=0;dt.subscribe((0,lt._)(b,Fe=>Bt.call(H,Fe,pe++)&&b.next(Fe)))})}}}]);
|
|
1
|
+
"use strict";(self.webpackChunkcue_ui=self.webpackChunkcue_ui||[]).push([[419],{6419(mu,xo,_t){_t.d(xo,{BIMFragmentsViewer:()=>uu});var st=_t(5802),bt=_t(7705),Mt=_t(2271),rs=_t(8807),H=_t(467),ft=_t(8158),b=_t(4701),os=(_t(3973),_t(2085));const V=Object.freeze({NONE:0,ROTATE:1,TRUCK:2,SCREEN_PAN:4,OFFSET:8,DOLLY:16,ZOOM:32,TOUCH_ROTATE:64,TOUCH_TRUCK:128,TOUCH_SCREEN_PAN:256,TOUCH_OFFSET:512,TOUCH_DOLLY:1024,TOUCH_ZOOM:2048,TOUCH_DOLLY_TRUCK:4096,TOUCH_DOLLY_SCREEN_PAN:8192,TOUCH_DOLLY_OFFSET:16384,TOUCH_DOLLY_ROTATE:32768,TOUCH_ZOOM_TRUCK:65536,TOUCH_ZOOM_OFFSET:131072,TOUCH_ZOOM_SCREEN_PAN:262144,TOUCH_ZOOM_ROTATE:524288});function Ce(o){return o.isPerspectiveCamera}function pe(o){return o.isOrthographicCamera}const me=2*Math.PI,wn=Math.PI/2,Ge=Math.PI/180;function ie(o,e,t){return Math.max(e,Math.min(t,o))}function xt(o,e=1e-5){return Math.abs(o)<e}function yt(o,e,t=1e-5){return xt(o-e,t)}function xn(o,e){return Math.round(o/e)*e}function Xe(o){return isFinite(o)?o:o<0?-Number.MAX_VALUE:Number.MAX_VALUE}function Qe(o){return Math.abs(o)<Number.MAX_VALUE?o:o*(1/0)}function wi(o,e,t,i,s=1/0,n){const r=2/(i=Math.max(1e-4,i)),a=r*n,l=1/(1+a+.48*a*a+.235*a*a*a);let c=o-e;const h=e,u=s*i;c=ie(c,-u,u),e=o-c;const f=(t.value+r*c)*n;t.value=(t.value-r*f)*l;let d=e+(c+f)*l;return h-o>0==d>h&&(d=h,t.value=(d-h)/n),d}function Cn(o,e,t,i,s=1/0,n,r){const a=2/(i=Math.max(1e-4,i)),l=a*n,c=1/(1+l+.48*l*l+.235*l*l*l);let h=e.x,u=e.y,f=e.z,d=o.x-h,y=o.y-u,g=o.z-f;const _=h,p=u,x=f,E=s*i,A=d*d+y*y+g*g;if(A>E*E){const R=Math.sqrt(A);d=d/R*E,y=y/R*E,g=g/R*E}h=o.x-d,u=o.y-y,f=o.z-g;const M=(t.x+a*d)*n,S=(t.y+a*y)*n,z=(t.z+a*g)*n;return t.x=(t.x-a*M)*c,t.y=(t.y-a*S)*c,t.z=(t.z-a*z)*c,r.x=h+(d+M)*c,r.y=u+(y+S)*c,r.z=f+(g+z)*c,(_-o.x)*(r.x-_)+(p-o.y)*(r.y-p)+(x-o.z)*(r.z-x)>0&&(r.x=_,r.y=p,r.z=x,t.x=(r.x-_)/n,t.y=(r.y-p)/n,t.z=(r.z-x)/n),r}function as(o,e){e.set(0,0),o.forEach(t=>{e.x+=t.clientX,e.y+=t.clientY}),e.x/=o.length,e.y/=o.length}function ls(o,e){return!!pe(o)&&(console.warn(`${e} is not supported in OrthographicCamera`),!0)}class Co{_listeners={};addEventListener(e,t){const i=this._listeners;void 0===i[e]&&(i[e]=[]),-1===i[e].indexOf(t)&&i[e].push(t)}hasEventListener(e,t){const i=this._listeners;return void 0!==i[e]&&-1!==i[e].indexOf(t)}removeEventListener(e,t){const s=this._listeners[e];if(void 0!==s){const n=s.indexOf(t);-1!==n&&s.splice(n,1)}}removeAllEventListeners(e){e?Array.isArray(this._listeners[e])&&(this._listeners[e].length=0):this._listeners={}}dispatchEvent(e){const i=this._listeners[e.type];if(void 0!==i){e.target=this;const s=i.slice(0);for(let n=0,r=s.length;n<r;n++)s[n].call(this,e)}}}const bi=1/8,Eo=/Mac/.test(globalThis?.navigator?.platform);let lt,Tn,xi,cs,Ht,ht,mt,Oe,Ke,re,oe,Te,En,An,Wt,ke,ze,Pn,hs,Sn,us,ds,Ci;class Bt extends Co{static install(e){lt=e.THREE,Tn=Object.freeze(new lt.Vector3(0,0,0)),xi=Object.freeze(new lt.Vector3(0,1,0)),cs=Object.freeze(new lt.Vector3(0,0,1)),Ht=new lt.Vector2,ht=new lt.Vector3,mt=new lt.Vector3,Oe=new lt.Vector3,Ke=new lt.Vector3,re=new lt.Vector3,oe=new lt.Vector3,Te=new lt.Vector3,En=new lt.Vector3,An=new lt.Vector3,Wt=new lt.Spherical,ke=new lt.Spherical,ze=new lt.Box3,Pn=new lt.Box3,hs=new lt.Sphere,Sn=new lt.Quaternion,us=new lt.Quaternion,ds=new lt.Matrix4,Ci=new lt.Raycaster}static get ACTION(){return V}minPolarAngle=0;maxPolarAngle=Math.PI;minAzimuthAngle=-1/0;maxAzimuthAngle=1/0;minDistance=Number.EPSILON;maxDistance=1/0;infinityDolly=!1;minZoom=.01;maxZoom=1/0;smoothTime=.25;draggingSmoothTime=.125;maxSpeed=1/0;azimuthRotateSpeed=1;polarRotateSpeed=1;dollySpeed=1;dollyDragInverted=!1;truckSpeed=2;dollyToCursor=!1;dragToOffset=!1;boundaryFriction=0;restThreshold=.01;colliderMeshes=[];mouseButtons;touches;cancel=()=>{};lockPointer;unlockPointer;_enabled=!0;_camera;_yAxisUpSpace;_yAxisUpSpaceInverse;_state=V.NONE;_domElement;_viewport=null;_target;_targetEnd;_focalOffset;_focalOffsetEnd;_spherical;_sphericalEnd;_lastDistance;_zoom;_zoomEnd;_lastZoom;_cameraUp0;_target0;_position0;_zoom0;_focalOffset0;_dollyControlCoord;_changedDolly=0;_changedZoom=0;_nearPlaneCorners;_hasRested=!0;_boundary;_boundaryEnclosesCamera=!1;_needsUpdate=!0;_updatedLastTime=!1;_elementRect=new DOMRect;_isDragging=!1;_dragNeedsUpdate=!0;_activePointers=[];_lockedPointer=null;_interactiveArea=new DOMRect(0,0,1,1);_isUserControllingRotate=!1;_isUserControllingDolly=!1;_isUserControllingTruck=!1;_isUserControllingOffset=!1;_isUserControllingZoom=!1;_lastDollyDirection=0;_thetaVelocity={value:0};_phiVelocity={value:0};_radiusVelocity={value:0};_targetVelocity=new lt.Vector3;_focalOffsetVelocity=new lt.Vector3;_zoomVelocity={value:0};set verticalDragToForward(e){console.warn("camera-controls: `verticalDragToForward` was removed. Use `mouseButtons.left = CameraControls.ACTION.SCREEN_PAN` instead.")}constructor(e,t){super(),typeof lt>"u"&&console.error("camera-controls: `THREE` is undefined. You must first run `CameraControls.install( { THREE: THREE } )`. Check the docs for further information."),this._camera=e,this._yAxisUpSpace=(new lt.Quaternion).setFromUnitVectors(this._camera.up,xi),this._yAxisUpSpaceInverse=this._yAxisUpSpace.clone().invert(),this._state=V.NONE,this._target=new lt.Vector3,this._targetEnd=this._target.clone(),this._focalOffset=new lt.Vector3,this._focalOffsetEnd=this._focalOffset.clone(),this._spherical=(new lt.Spherical).setFromVector3(ht.copy(this._camera.position).applyQuaternion(this._yAxisUpSpace)),this._sphericalEnd=this._spherical.clone(),this._lastDistance=this._spherical.radius,this._zoom=this._camera.zoom,this._zoomEnd=this._zoom,this._lastZoom=this._zoom,this._nearPlaneCorners=[new lt.Vector3,new lt.Vector3,new lt.Vector3,new lt.Vector3],this._updateNearPlaneCorners(),this._boundary=new lt.Box3(new lt.Vector3(-1/0,-1/0,-1/0),new lt.Vector3(1/0,1/0,1/0)),this._cameraUp0=this._camera.up.clone(),this._target0=this._target.clone(),this._position0=this._camera.position.clone(),this._zoom0=this._zoom,this._focalOffset0=this._focalOffset.clone(),this._dollyControlCoord=new lt.Vector2,this.mouseButtons={left:V.ROTATE,middle:V.DOLLY,right:V.TRUCK,wheel:Ce(this._camera)?V.DOLLY:pe(this._camera)?V.ZOOM:V.NONE},this.touches={one:V.TOUCH_ROTATE,two:Ce(this._camera)?V.TOUCH_DOLLY_TRUCK:pe(this._camera)?V.TOUCH_ZOOM_TRUCK:V.NONE,three:V.TOUCH_TRUCK};const i=new lt.Vector2,s=new lt.Vector2,n=new lt.Vector2,r=p=>{if(!this._enabled||!this._domElement)return;if(0!==this._interactiveArea.left||0!==this._interactiveArea.top||1!==this._interactiveArea.width||1!==this._interactiveArea.height){const T=this._domElement.getBoundingClientRect(),A=p.clientX/T.width,M=p.clientY/T.height;if(A<this._interactiveArea.left||A>this._interactiveArea.right||M<this._interactiveArea.top||M>this._interactiveArea.bottom)return}const x="mouse"!==p.pointerType?null:1&~p.buttons?4&~p.buttons?2&~p.buttons?null:2:4:1;if(null!==x){const T=this._findPointerByMouseButton(x);T&&this._disposePointer(T)}(1&~p.buttons||!this._lockedPointer)&&(this._activePointers.push({pointerId:p.pointerId,clientX:p.clientX,clientY:p.clientY,deltaX:0,deltaY:0,mouseButton:x}),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",l),this._domElement.ownerDocument.addEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",l),this._isDragging=!0,f(p))},a=p=>{p.cancelable&&p.preventDefault();const E=this._lockedPointer||this._findPointerById(p.pointerId);if(E){if(E.clientX=p.clientX,E.clientY=p.clientY,E.deltaX=p.movementX,E.deltaY=p.movementY,this._state=0,"touch"===p.pointerType)switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three}else(!this._isDragging&&this._lockedPointer||this._isDragging&&!(1&~p.buttons))&&(this._state=this._state|this.mouseButtons.left),this._isDragging&&!(4&~p.buttons)&&(this._state=this._state|this.mouseButtons.middle),this._isDragging&&!(2&~p.buttons)&&(this._state=this._state|this.mouseButtons.right);d()}},l=p=>{const x=this._findPointerById(p.pointerId);if(!x||x!==this._lockedPointer){if(x&&this._disposePointer(x),"touch"===p.pointerType)switch(this._activePointers.length){case 0:this._state=V.NONE;break;case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three}else this._state=V.NONE;y()}};let c=-1;const h=p=>{if(!this._domElement||!this._enabled||this.mouseButtons.wheel===V.NONE)return;if(0!==this._interactiveArea.left||0!==this._interactiveArea.top||1!==this._interactiveArea.width||1!==this._interactiveArea.height){const S=this._domElement.getBoundingClientRect(),z=p.clientX/S.width,O=p.clientY/S.height;if(z<this._interactiveArea.left||z>this._interactiveArea.right||O<this._interactiveArea.top||O>this._interactiveArea.bottom)return}if(p.preventDefault(),this.dollyToCursor||this.mouseButtons.wheel===V.ROTATE||this.mouseButtons.wheel===V.TRUCK){const S=performance.now();c-S<1e3&&this._getClientRect(this._elementRect),c=S}const x=Eo?-1:-3,E=1!==p.deltaMode||p.ctrlKey?p.deltaY/(10*x):p.deltaY/x,T=this.dollyToCursor?(p.clientX-this._elementRect.x)/this._elementRect.width*2-1:0,A=this.dollyToCursor?(p.clientY-this._elementRect.y)/this._elementRect.height*-2+1:0;switch(p.ctrlKey?V.ZOOM:this.mouseButtons.wheel){case V.ROTATE:this._rotateInternal(p.deltaX,p.deltaY),this._isUserControllingRotate=!0;break;case V.TRUCK:this._truckInternal(p.deltaX,p.deltaY,!1,!1),this._isUserControllingTruck=!0;break;case V.SCREEN_PAN:this._truckInternal(p.deltaX,p.deltaY,!1,!0),this._isUserControllingTruck=!0;break;case V.OFFSET:this._truckInternal(p.deltaX,p.deltaY,!0,!1),this._isUserControllingOffset=!0;break;case V.DOLLY:this._dollyInternal(-E,T,A),this._isUserControllingDolly=!0;break;case V.ZOOM:this._zoomInternal(-E,T,A),this._isUserControllingZoom=!0}this.dispatchEvent({type:"control"})},u=p=>{if(this._domElement&&this._enabled){if(this.mouseButtons.right===Bt.ACTION.NONE){const x=p instanceof PointerEvent?p.pointerId:0,E=this._findPointerById(x);return E&&this._disposePointer(E),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),void this._domElement.ownerDocument.removeEventListener("pointerup",l)}p.preventDefault()}},f=p=>{if(this._enabled){if(as(this._activePointers,Ht),this._getClientRect(this._elementRect),i.copy(Ht),s.copy(Ht),this._activePointers.length>=2){const E=Ht.x-this._activePointers[1].clientX,T=Ht.y-this._activePointers[1].clientY,A=Math.sqrt(E*E+T*T);n.set(0,A),s.set(.5*(this._activePointers[0].clientX+this._activePointers[1].clientX),.5*(this._activePointers[0].clientY+this._activePointers[1].clientY))}if(this._state=0,p)if("pointerType"in p&&"touch"===p.pointerType)switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three}else!this._lockedPointer&&!(1&~p.buttons)&&(this._state=this._state|this.mouseButtons.left),!(4&~p.buttons)&&(this._state=this._state|this.mouseButtons.middle),!(2&~p.buttons)&&(this._state=this._state|this.mouseButtons.right);else this._lockedPointer&&(this._state=this._state|this.mouseButtons.left);((this._state&V.ROTATE)===V.ROTATE||(this._state&V.TOUCH_ROTATE)===V.TOUCH_ROTATE||(this._state&V.TOUCH_DOLLY_ROTATE)===V.TOUCH_DOLLY_ROTATE||(this._state&V.TOUCH_ZOOM_ROTATE)===V.TOUCH_ZOOM_ROTATE)&&(this._sphericalEnd.theta=this._spherical.theta,this._sphericalEnd.phi=this._spherical.phi,this._thetaVelocity.value=0,this._phiVelocity.value=0),((this._state&V.TRUCK)===V.TRUCK||(this._state&V.SCREEN_PAN)===V.SCREEN_PAN||(this._state&V.TOUCH_TRUCK)===V.TOUCH_TRUCK||(this._state&V.TOUCH_SCREEN_PAN)===V.TOUCH_SCREEN_PAN||(this._state&V.TOUCH_DOLLY_TRUCK)===V.TOUCH_DOLLY_TRUCK||(this._state&V.TOUCH_DOLLY_SCREEN_PAN)===V.TOUCH_DOLLY_SCREEN_PAN||(this._state&V.TOUCH_ZOOM_TRUCK)===V.TOUCH_ZOOM_TRUCK||(this._state&V.TOUCH_ZOOM_SCREEN_PAN)===V.TOUCH_DOLLY_SCREEN_PAN)&&(this._targetEnd.copy(this._target),this._targetVelocity.set(0,0,0)),((this._state&V.DOLLY)===V.DOLLY||(this._state&V.TOUCH_DOLLY)===V.TOUCH_DOLLY||(this._state&V.TOUCH_DOLLY_TRUCK)===V.TOUCH_DOLLY_TRUCK||(this._state&V.TOUCH_DOLLY_SCREEN_PAN)===V.TOUCH_DOLLY_SCREEN_PAN||(this._state&V.TOUCH_DOLLY_OFFSET)===V.TOUCH_DOLLY_OFFSET||(this._state&V.TOUCH_DOLLY_ROTATE)===V.TOUCH_DOLLY_ROTATE)&&(this._sphericalEnd.radius=this._spherical.radius,this._radiusVelocity.value=0),((this._state&V.ZOOM)===V.ZOOM||(this._state&V.TOUCH_ZOOM)===V.TOUCH_ZOOM||(this._state&V.TOUCH_ZOOM_TRUCK)===V.TOUCH_ZOOM_TRUCK||(this._state&V.TOUCH_ZOOM_SCREEN_PAN)===V.TOUCH_ZOOM_SCREEN_PAN||(this._state&V.TOUCH_ZOOM_OFFSET)===V.TOUCH_ZOOM_OFFSET||(this._state&V.TOUCH_ZOOM_ROTATE)===V.TOUCH_ZOOM_ROTATE)&&(this._zoomEnd=this._zoom,this._zoomVelocity.value=0),((this._state&V.OFFSET)===V.OFFSET||(this._state&V.TOUCH_OFFSET)===V.TOUCH_OFFSET||(this._state&V.TOUCH_DOLLY_OFFSET)===V.TOUCH_DOLLY_OFFSET||(this._state&V.TOUCH_ZOOM_OFFSET)===V.TOUCH_ZOOM_OFFSET)&&(this._focalOffsetEnd.copy(this._focalOffset),this._focalOffsetVelocity.set(0,0,0)),this.dispatchEvent({type:"controlstart"})}},d=()=>{if(!this._enabled||!this._dragNeedsUpdate)return;this._dragNeedsUpdate=!1,as(this._activePointers,Ht);const x=this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement?this._lockedPointer||this._activePointers[0]:null,E=x?-x.deltaX:s.x-Ht.x,T=x?-x.deltaY:s.y-Ht.y;if(s.copy(Ht),((this._state&V.ROTATE)===V.ROTATE||(this._state&V.TOUCH_ROTATE)===V.TOUCH_ROTATE||(this._state&V.TOUCH_DOLLY_ROTATE)===V.TOUCH_DOLLY_ROTATE||(this._state&V.TOUCH_ZOOM_ROTATE)===V.TOUCH_ZOOM_ROTATE)&&(this._rotateInternal(E,T),this._isUserControllingRotate=!0),(this._state&V.DOLLY)===V.DOLLY||(this._state&V.ZOOM)===V.ZOOM){const A=this.dollyToCursor?(i.x-this._elementRect.x)/this._elementRect.width*2-1:0,M=this.dollyToCursor?(i.y-this._elementRect.y)/this._elementRect.height*-2+1:0,S=this.dollyDragInverted?-1:1;(this._state&V.DOLLY)===V.DOLLY?(this._dollyInternal(S*T*bi,A,M),this._isUserControllingDolly=!0):(this._zoomInternal(S*T*bi,A,M),this._isUserControllingZoom=!0)}if((this._state&V.TOUCH_DOLLY)===V.TOUCH_DOLLY||(this._state&V.TOUCH_ZOOM)===V.TOUCH_ZOOM||(this._state&V.TOUCH_DOLLY_TRUCK)===V.TOUCH_DOLLY_TRUCK||(this._state&V.TOUCH_ZOOM_TRUCK)===V.TOUCH_ZOOM_TRUCK||(this._state&V.TOUCH_DOLLY_SCREEN_PAN)===V.TOUCH_DOLLY_SCREEN_PAN||(this._state&V.TOUCH_ZOOM_SCREEN_PAN)===V.TOUCH_ZOOM_SCREEN_PAN||(this._state&V.TOUCH_DOLLY_OFFSET)===V.TOUCH_DOLLY_OFFSET||(this._state&V.TOUCH_ZOOM_OFFSET)===V.TOUCH_ZOOM_OFFSET||(this._state&V.TOUCH_DOLLY_ROTATE)===V.TOUCH_DOLLY_ROTATE||(this._state&V.TOUCH_ZOOM_ROTATE)===V.TOUCH_ZOOM_ROTATE){const A=Ht.x-this._activePointers[1].clientX,M=Ht.y-this._activePointers[1].clientY,S=Math.sqrt(A*A+M*M),z=n.y-S;n.set(0,S);const O=this.dollyToCursor?(s.x-this._elementRect.x)/this._elementRect.width*2-1:0,N=this.dollyToCursor?(s.y-this._elementRect.y)/this._elementRect.height*-2+1:0;(this._state&V.TOUCH_DOLLY)===V.TOUCH_DOLLY||(this._state&V.TOUCH_DOLLY_ROTATE)===V.TOUCH_DOLLY_ROTATE||(this._state&V.TOUCH_DOLLY_TRUCK)===V.TOUCH_DOLLY_TRUCK||(this._state&V.TOUCH_DOLLY_SCREEN_PAN)===V.TOUCH_DOLLY_SCREEN_PAN||(this._state&V.TOUCH_DOLLY_OFFSET)===V.TOUCH_DOLLY_OFFSET?(this._dollyInternal(z*bi,O,N),this._isUserControllingDolly=!0):(this._zoomInternal(z*bi,O,N),this._isUserControllingZoom=!0)}((this._state&V.TRUCK)===V.TRUCK||(this._state&V.TOUCH_TRUCK)===V.TOUCH_TRUCK||(this._state&V.TOUCH_DOLLY_TRUCK)===V.TOUCH_DOLLY_TRUCK||(this._state&V.TOUCH_ZOOM_TRUCK)===V.TOUCH_ZOOM_TRUCK)&&(this._truckInternal(E,T,!1,!1),this._isUserControllingTruck=!0),((this._state&V.SCREEN_PAN)===V.SCREEN_PAN||(this._state&V.TOUCH_SCREEN_PAN)===V.TOUCH_SCREEN_PAN||(this._state&V.TOUCH_DOLLY_SCREEN_PAN)===V.TOUCH_DOLLY_SCREEN_PAN||(this._state&V.TOUCH_ZOOM_SCREEN_PAN)===V.TOUCH_ZOOM_SCREEN_PAN)&&(this._truckInternal(E,T,!1,!0),this._isUserControllingTruck=!0),((this._state&V.OFFSET)===V.OFFSET||(this._state&V.TOUCH_OFFSET)===V.TOUCH_OFFSET||(this._state&V.TOUCH_DOLLY_OFFSET)===V.TOUCH_DOLLY_OFFSET||(this._state&V.TOUCH_ZOOM_OFFSET)===V.TOUCH_ZOOM_OFFSET)&&(this._truckInternal(E,T,!0,!1),this._isUserControllingOffset=!0),this.dispatchEvent({type:"control"})},y=()=>{as(this._activePointers,Ht),s.copy(Ht),this._dragNeedsUpdate=!1,(0===this._activePointers.length||1===this._activePointers.length&&this._activePointers[0]===this._lockedPointer)&&(this._isDragging=!1),0===this._activePointers.length&&this._domElement&&(this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",l),this.dispatchEvent({type:"controlend"}))};this.lockPointer=()=>{!this._enabled||!this._domElement||(this.cancel(),this._lockedPointer={pointerId:-1,clientX:0,clientY:0,deltaX:0,deltaY:0,mouseButton:null},this._activePointers.push(this._lockedPointer),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",l),this._domElement.requestPointerLock(),this._domElement.ownerDocument.addEventListener("pointerlockchange",g),this._domElement.ownerDocument.addEventListener("pointerlockerror",_),this._domElement.ownerDocument.addEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",l),f())},this.unlockPointer=()=>{null!==this._lockedPointer&&(this._disposePointer(this._lockedPointer),this._lockedPointer=null),this._domElement?.ownerDocument.exitPointerLock(),this._domElement?.ownerDocument.removeEventListener("pointerlockchange",g),this._domElement?.ownerDocument.removeEventListener("pointerlockerror",_),this.cancel()};const g=()=>{this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement||this.unlockPointer()},_=()=>{this.unlockPointer()};this._addAllEventListeners=p=>{this._domElement=p,this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none",this._domElement.addEventListener("pointerdown",r),this._domElement.addEventListener("pointercancel",l),this._domElement.addEventListener("wheel",h,{passive:!1}),this._domElement.addEventListener("contextmenu",u)},this._removeAllEventListeners=()=>{this._domElement&&(this._domElement.style.touchAction="",this._domElement.style.userSelect="",this._domElement.style.webkitUserSelect="",this._domElement.removeEventListener("pointerdown",r),this._domElement.removeEventListener("pointercancel",l),this._domElement.removeEventListener("wheel",h,{passive:!1}),this._domElement.removeEventListener("contextmenu",u),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",l),this._domElement.ownerDocument.removeEventListener("pointerlockchange",g),this._domElement.ownerDocument.removeEventListener("pointerlockerror",_))},this.cancel=()=>{this._state!==V.NONE&&(this._state=V.NONE,this._activePointers.length=0,y())},t&&this.connect(t),this.update(0)}get camera(){return this._camera}set camera(e){this._camera=e,this.updateCameraUp(),this._camera.updateProjectionMatrix(),this._updateNearPlaneCorners(),this._needsUpdate=!0}get enabled(){return this._enabled}set enabled(e){this._enabled=e,this._domElement&&(e?(this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none"):(this.cancel(),this._domElement.style.touchAction="",this._domElement.style.userSelect="",this._domElement.style.webkitUserSelect=""))}get active(){return!this._hasRested}get currentAction(){return this._state}get distance(){return this._spherical.radius}set distance(e){this._spherical.radius===e&&this._sphericalEnd.radius===e||(this._spherical.radius=e,this._sphericalEnd.radius=e,this._needsUpdate=!0)}get azimuthAngle(){return this._spherical.theta}set azimuthAngle(e){this._spherical.theta===e&&this._sphericalEnd.theta===e||(this._spherical.theta=e,this._sphericalEnd.theta=e,this._needsUpdate=!0)}get polarAngle(){return this._spherical.phi}set polarAngle(e){this._spherical.phi===e&&this._sphericalEnd.phi===e||(this._spherical.phi=e,this._sphericalEnd.phi=e,this._needsUpdate=!0)}get boundaryEnclosesCamera(){return this._boundaryEnclosesCamera}set boundaryEnclosesCamera(e){this._boundaryEnclosesCamera=e,this._needsUpdate=!0}set interactiveArea(e){this._interactiveArea.width=ie(e.width,0,1),this._interactiveArea.height=ie(e.height,0,1),this._interactiveArea.x=ie(e.x,0,1-this._interactiveArea.width),this._interactiveArea.y=ie(e.y,0,1-this._interactiveArea.height)}addEventListener(e,t){super.addEventListener(e,t)}removeEventListener(e,t){super.removeEventListener(e,t)}rotate(e,t,i=!1){return this.rotateTo(this._sphericalEnd.theta+e,this._sphericalEnd.phi+t,i)}rotateAzimuthTo(e,t=!1){return this.rotateTo(e,this._sphericalEnd.phi,t)}rotatePolarTo(e,t=!1){return this.rotateTo(this._sphericalEnd.theta,e,t)}rotateTo(e,t,i=!1){this._isUserControllingRotate=!1;const s=ie(e,this.minAzimuthAngle,this.maxAzimuthAngle),n=ie(t,this.minPolarAngle,this.maxPolarAngle);this._sphericalEnd.theta=s,this._sphericalEnd.phi=n,this._sphericalEnd.makeSafe(),this._needsUpdate=!0,i||(this._spherical.theta=this._sphericalEnd.theta,this._spherical.phi=this._sphericalEnd.phi);const r=!i||yt(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&yt(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold);return this._createOnRestPromise(r)}dolly(e,t=!1){return this.dollyTo(this._sphericalEnd.radius-e,t)}dollyTo(e,t=!1){return this._isUserControllingDolly=!1,this._lastDollyDirection=0,this._changedDolly=0,this._dollyToNoClamp(ie(e,this.minDistance,this.maxDistance),t)}_dollyToNoClamp(e,t=!1){const i=this._sphericalEnd.radius;if(this.colliderMeshes.length>=1){const r=this._collisionTest(),a=yt(r,this._spherical.radius);if(!(i>e)&&a)return Promise.resolve();this._sphericalEnd.radius=Math.min(e,r)}else this._sphericalEnd.radius=e;this._needsUpdate=!0,t||(this._spherical.radius=this._sphericalEnd.radius);const n=!t||yt(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(n)}dollyInFixed(e,t=!1){this._targetEnd.add(this._getCameraDirection(Ke).multiplyScalar(e)),t||this._target.copy(this._targetEnd);const i=!t||yt(this._target.x,this._targetEnd.x,this.restThreshold)&&yt(this._target.y,this._targetEnd.y,this.restThreshold)&&yt(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(i)}zoom(e,t=!1){return this.zoomTo(this._zoomEnd+e,t)}zoomTo(e,t=!1){this._isUserControllingZoom=!1,this._zoomEnd=ie(e,this.minZoom,this.maxZoom),this._needsUpdate=!0,t||(this._zoom=this._zoomEnd);const i=!t||yt(this._zoom,this._zoomEnd,this.restThreshold);return this._changedZoom=0,this._createOnRestPromise(i)}pan(e,t,i=!1){return console.warn("`pan` has been renamed to `truck`"),this.truck(e,t,i)}truck(e,t,i=!1){this._camera.updateMatrix(),re.setFromMatrixColumn(this._camera.matrix,0),oe.setFromMatrixColumn(this._camera.matrix,1),re.multiplyScalar(e),oe.multiplyScalar(-t);const s=ht.copy(re).add(oe),n=mt.copy(this._targetEnd).add(s);return this.moveTo(n.x,n.y,n.z,i)}forward(e,t=!1){ht.setFromMatrixColumn(this._camera.matrix,0),ht.crossVectors(this._camera.up,ht),ht.multiplyScalar(e);const i=mt.copy(this._targetEnd).add(ht);return this.moveTo(i.x,i.y,i.z,t)}elevate(e,t=!1){return ht.copy(this._camera.up).multiplyScalar(e),this.moveTo(this._targetEnd.x+ht.x,this._targetEnd.y+ht.y,this._targetEnd.z+ht.z,t)}moveTo(e,t,i,s=!1){this._isUserControllingTruck=!1;const n=ht.set(e,t,i).sub(this._targetEnd);this._encloseToBoundary(this._targetEnd,n,this.boundaryFriction),this._needsUpdate=!0,s||this._target.copy(this._targetEnd);const r=!s||yt(this._target.x,this._targetEnd.x,this.restThreshold)&&yt(this._target.y,this._targetEnd.y,this.restThreshold)&&yt(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(r)}lookInDirectionOf(e,t,i,s=!1){const a=ht.set(e,t,i).sub(this._targetEnd).normalize().multiplyScalar(-this._sphericalEnd.radius).add(this._targetEnd);return this.setPosition(a.x,a.y,a.z,s)}fitToBox(e,t,{cover:i=!1,paddingLeft:s=0,paddingRight:n=0,paddingBottom:r=0,paddingTop:a=0}={}){const l=[],c=e.isBox3?ze.copy(e):ze.setFromObject(e);c.isEmpty()&&(console.warn("camera-controls: fitTo() cannot be used with an empty box. Aborting"),Promise.resolve());const h=xn(this._sphericalEnd.theta,wn),u=xn(this._sphericalEnd.phi,wn);l.push(this.rotateTo(h,u,t));const f=ht.setFromSpherical(this._sphericalEnd).normalize(),d=Sn.setFromUnitVectors(f,cs),y=yt(Math.abs(f.y),1);y&&d.multiply(us.setFromAxisAngle(xi,h)),d.multiply(this._yAxisUpSpaceInverse);const g=Pn.makeEmpty();mt.copy(c.min).applyQuaternion(d),g.expandByPoint(mt),mt.copy(c.min).setX(c.max.x).applyQuaternion(d),g.expandByPoint(mt),mt.copy(c.min).setY(c.max.y).applyQuaternion(d),g.expandByPoint(mt),mt.copy(c.max).setZ(c.min.z).applyQuaternion(d),g.expandByPoint(mt),mt.copy(c.min).setZ(c.max.z).applyQuaternion(d),g.expandByPoint(mt),mt.copy(c.max).setY(c.min.y).applyQuaternion(d),g.expandByPoint(mt),mt.copy(c.max).setX(c.min.x).applyQuaternion(d),g.expandByPoint(mt),mt.copy(c.max).applyQuaternion(d),g.expandByPoint(mt),g.min.x-=s,g.min.y-=r,g.max.x+=n,g.max.y+=a,d.setFromUnitVectors(cs,f),y&&d.premultiply(us.invert()),d.premultiply(this._yAxisUpSpace);const _=g.getSize(ht),p=g.getCenter(mt).applyQuaternion(d);if(Ce(this._camera)){const x=this.getDistanceToFitBox(_.x,_.y,_.z,i);l.push(this.moveTo(p.x,p.y,p.z,t)),l.push(this.dollyTo(x,t)),l.push(this.setFocalOffset(0,0,0,t))}else if(pe(this._camera)){const x=this._camera,E=x.right-x.left,T=x.top-x.bottom,A=i?Math.max(E/_.x,T/_.y):Math.min(E/_.x,T/_.y);l.push(this.moveTo(p.x,p.y,p.z,t)),l.push(this.zoomTo(A,t)),l.push(this.setFocalOffset(0,0,0,t))}return Promise.all(l)}fitToSphere(e,t){const i=[],n="isObject3D"in e?Bt.createBoundingSphere(e,hs):hs.copy(e);if(i.push(this.moveTo(n.center.x,n.center.y,n.center.z,t)),Ce(this._camera)){const r=this.getDistanceToFitSphere(n.radius);i.push(this.dollyTo(r,t))}else if(pe(this._camera)){const l=2*n.radius,c=Math.min((this._camera.right-this._camera.left)/l,(this._camera.top-this._camera.bottom)/l);i.push(this.zoomTo(c,t))}return i.push(this.setFocalOffset(0,0,0,t)),Promise.all(i)}setLookAt(e,t,i,s,n,r,a=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=0,this._changedDolly=0;const l=mt.set(s,n,r),c=ht.set(e,t,i);this._targetEnd.copy(l),this._sphericalEnd.setFromVector3(c.sub(l).applyQuaternion(this._yAxisUpSpace)),this._needsUpdate=!0,a||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const h=!a||yt(this._target.x,this._targetEnd.x,this.restThreshold)&&yt(this._target.y,this._targetEnd.y,this.restThreshold)&&yt(this._target.z,this._targetEnd.z,this.restThreshold)&&yt(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&yt(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&yt(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(h)}lerp(e,t,i,s=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=0,this._changedDolly=0;const n=ht.set(...e.target);if("spherical"in e)Wt.set(...e.spherical);else{const u=mt.set(...e.position);Wt.setFromVector3(u.sub(n).applyQuaternion(this._yAxisUpSpace))}const r=Oe.set(...t.target);if("spherical"in t)ke.set(...t.spherical);else{const u=mt.set(...t.position);ke.setFromVector3(u.sub(r).applyQuaternion(this._yAxisUpSpace))}this._targetEnd.copy(n.lerp(r,i)),this._sphericalEnd.set(Wt.radius+(ke.radius-Wt.radius)*i,Wt.phi+(ke.phi-Wt.phi)*i,Wt.theta+(ke.theta-Wt.theta)*i),this._needsUpdate=!0,s||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const h=!s||yt(this._target.x,this._targetEnd.x,this.restThreshold)&&yt(this._target.y,this._targetEnd.y,this.restThreshold)&&yt(this._target.z,this._targetEnd.z,this.restThreshold)&&yt(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&yt(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&yt(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(h)}lerpLookAt(e,t,i,s,n,r,a,l,c,h,u,f,d,y=!1){return this.lerp({position:[e,t,i],target:[s,n,r]},{position:[a,l,c],target:[h,u,f]},d,y)}setPosition(e,t,i,s=!1){return this.setLookAt(e,t,i,this._targetEnd.x,this._targetEnd.y,this._targetEnd.z,s)}setTarget(e,t,i,s=!1){const n=this.getPosition(ht),r=this.setLookAt(n.x,n.y,n.z,e,t,i,s);return this._sphericalEnd.phi=ie(this._sphericalEnd.phi,this.minPolarAngle,this.maxPolarAngle),r}setFocalOffset(e,t,i,s=!1){this._isUserControllingOffset=!1,this._focalOffsetEnd.set(e,t,i),this._needsUpdate=!0,s||this._focalOffset.copy(this._focalOffsetEnd);const n=!s||yt(this._focalOffset.x,this._focalOffsetEnd.x,this.restThreshold)&&yt(this._focalOffset.y,this._focalOffsetEnd.y,this.restThreshold)&&yt(this._focalOffset.z,this._focalOffsetEnd.z,this.restThreshold);return this._createOnRestPromise(n)}setOrbitPoint(e,t,i){this._camera.updateMatrixWorld(),re.setFromMatrixColumn(this._camera.matrixWorldInverse,0),oe.setFromMatrixColumn(this._camera.matrixWorldInverse,1),Te.setFromMatrixColumn(this._camera.matrixWorldInverse,2);const s=ht.set(e,t,i),n=s.distanceTo(this._camera.position),r=s.sub(this._camera.position);re.multiplyScalar(r.x),oe.multiplyScalar(r.y),Te.multiplyScalar(r.z),ht.copy(re).add(oe).add(Te),ht.z=ht.z+n,this.dollyTo(n,!1),this.setFocalOffset(-ht.x,ht.y,-ht.z,!1),this.moveTo(e,t,i,!1)}setBoundary(e){if(!e)return this._boundary.min.set(-1/0,-1/0,-1/0),this._boundary.max.set(1/0,1/0,1/0),void(this._needsUpdate=!0);this._boundary.copy(e),this._boundary.clampPoint(this._targetEnd,this._targetEnd),this._needsUpdate=!0}setViewport(e,t,i,s){null!==e?(this._viewport=this._viewport||new lt.Vector4,"number"==typeof e?this._viewport.set(e,t,i,s):this._viewport.copy(e)):this._viewport=null}getDistanceToFitBox(e,t,i,s=!1){if(ls(this._camera,"getDistanceToFitBox"))return this._spherical.radius;const n=e/t,r=this._camera.getEffectiveFOV()*Ge,a=this._camera.aspect;return.5*((s?n>a:n<a)?t:e/a)/Math.tan(.5*r)+.5*i}getDistanceToFitSphere(e){if(ls(this._camera,"getDistanceToFitSphere"))return this._spherical.radius;const t=this._camera.getEffectiveFOV()*Ge,i=2*Math.atan(Math.tan(.5*t)*this._camera.aspect);return e/Math.sin(.5*(1<this._camera.aspect?t:i))}getTarget(e,t=!0){return(e&&e.isVector3?e:new lt.Vector3).copy(t?this._targetEnd:this._target)}getPosition(e,t=!0){return(e&&e.isVector3?e:new lt.Vector3).setFromSpherical(t?this._sphericalEnd:this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(t?this._targetEnd:this._target)}getSpherical(e,t=!0){return(e||new lt.Spherical).copy(t?this._sphericalEnd:this._spherical)}getFocalOffset(e,t=!0){return(e&&e.isVector3?e:new lt.Vector3).copy(t?this._focalOffsetEnd:this._focalOffset)}normalizeRotations(){return this._sphericalEnd.theta=(this._sphericalEnd.theta%me+me)%me,this._sphericalEnd.theta>Math.PI&&(this._sphericalEnd.theta-=me),this._spherical.theta+=me*Math.round((this._sphericalEnd.theta-this._spherical.theta)/me),this}stop(){this._focalOffset.copy(this._focalOffsetEnd),this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd),this._zoom=this._zoomEnd}reset(e=!1){if(!yt(this._camera.up.x,this._cameraUp0.x)||!yt(this._camera.up.y,this._cameraUp0.y)||!yt(this._camera.up.z,this._cameraUp0.z)){this._camera.up.copy(this._cameraUp0);const i=this.getPosition(ht);this.updateCameraUp(),this.setPosition(i.x,i.y,i.z)}const t=[this.setLookAt(this._position0.x,this._position0.y,this._position0.z,this._target0.x,this._target0.y,this._target0.z,e),this.setFocalOffset(this._focalOffset0.x,this._focalOffset0.y,this._focalOffset0.z,e),this.zoomTo(this._zoom0,e)];return Promise.all(t)}saveState(){this._cameraUp0.copy(this._camera.up),this.getTarget(this._target0),this.getPosition(this._position0),this._zoom0=this._zoom,this._focalOffset0.copy(this._focalOffset)}updateCameraUp(){this._yAxisUpSpace.setFromUnitVectors(this._camera.up,xi),this._yAxisUpSpaceInverse.copy(this._yAxisUpSpace).invert()}applyCameraUp(){const e=ht.subVectors(this._target,this._camera.position).normalize(),t=mt.crossVectors(e,this._camera.up);this._camera.up.crossVectors(t,e).normalize(),this._camera.updateMatrixWorld();const i=this.getPosition(ht);this.updateCameraUp(),this.setPosition(i.x,i.y,i.z)}update(e){const t=this._sphericalEnd.theta-this._spherical.theta,i=this._sphericalEnd.phi-this._spherical.phi,s=this._sphericalEnd.radius-this._spherical.radius,n=En.subVectors(this._targetEnd,this._target),r=An.subVectors(this._focalOffsetEnd,this._focalOffset),a=this._zoomEnd-this._zoom;if(xt(t)?(this._thetaVelocity.value=0,this._spherical.theta=this._sphericalEnd.theta):(this._spherical.theta=wi(this._spherical.theta,this._sphericalEnd.theta,this._thetaVelocity,this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime,1/0,e),this._needsUpdate=!0),xt(i)?(this._phiVelocity.value=0,this._spherical.phi=this._sphericalEnd.phi):(this._spherical.phi=wi(this._spherical.phi,this._sphericalEnd.phi,this._phiVelocity,this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime,1/0,e),this._needsUpdate=!0),xt(s)?(this._radiusVelocity.value=0,this._spherical.radius=this._sphericalEnd.radius):(this._spherical.radius=wi(this._spherical.radius,this._sphericalEnd.radius,this._radiusVelocity,this._isUserControllingDolly?this.draggingSmoothTime:this.smoothTime,this.maxSpeed,e),this._needsUpdate=!0),xt(n.x)&&xt(n.y)&&xt(n.z)?(this._targetVelocity.set(0,0,0),this._target.copy(this._targetEnd)):(Cn(this._target,this._targetEnd,this._targetVelocity,this._isUserControllingTruck?this.draggingSmoothTime:this.smoothTime,this.maxSpeed,e,this._target),this._needsUpdate=!0),xt(r.x)&&xt(r.y)&&xt(r.z)?(this._focalOffsetVelocity.set(0,0,0),this._focalOffset.copy(this._focalOffsetEnd)):(Cn(this._focalOffset,this._focalOffsetEnd,this._focalOffsetVelocity,this._isUserControllingOffset?this.draggingSmoothTime:this.smoothTime,this.maxSpeed,e,this._focalOffset),this._needsUpdate=!0),xt(a)?(this._zoomVelocity.value=0,this._zoom=this._zoomEnd):this._zoom=wi(this._zoom,this._zoomEnd,this._zoomVelocity,this._isUserControllingZoom?this.draggingSmoothTime:this.smoothTime,1/0,e),this.dollyToCursor)if(Ce(this._camera)&&0!==this._changedDolly){const u=this._spherical.radius-this._lastDistance,f=this._camera,d=this._getCameraDirection(Ke),y=ht.copy(d).cross(f.up).normalize();0===y.lengthSq()&&(y.x=1);const g=mt.crossVectors(y,d),_=this._sphericalEnd.radius*Math.tan(f.getEffectiveFOV()*Ge*.5),x=(this._sphericalEnd.radius-u-this._sphericalEnd.radius)/this._sphericalEnd.radius,E=Oe.copy(this._targetEnd).add(y.multiplyScalar(this._dollyControlCoord.x*_*f.aspect)).add(g.multiplyScalar(this._dollyControlCoord.y*_)),T=ht.copy(this._targetEnd).lerp(E,x);if(this.infinityDolly&&(1===this._lastDollyDirection&&this._spherical.radius<=this.minDistance||-1===this._lastDollyDirection&&this.maxDistance<=this._spherical.radius)){this._sphericalEnd.radius-=u,this._spherical.radius-=u;const z=mt.copy(d).multiplyScalar(-u);T.add(z)}this._boundary.clampPoint(T,T);const S=mt.subVectors(T,this._targetEnd);this._targetEnd.copy(T),this._target.add(S),this._changedDolly-=u,xt(this._changedDolly)&&(this._changedDolly=0)}else if(pe(this._camera)&&0!==this._changedZoom){const u=this._zoom-this._lastZoom,f=this._camera,d=ht.set(this._dollyControlCoord.x,this._dollyControlCoord.y,(f.near+f.far)/(f.near-f.far)).unproject(f),y=mt.set(0,0,-1).applyQuaternion(f.quaternion),g=Oe.copy(d).add(y.multiplyScalar(-d.dot(f.up))),p=-(this._zoom-u-this._zoom)/this._zoom,x=this._getCameraDirection(Ke),E=this._targetEnd.dot(x),T=ht.copy(this._targetEnd).lerp(g,p),A=T.dot(x),M=x.multiplyScalar(A-E);T.sub(M),this._boundary.clampPoint(T,T);const S=mt.subVectors(T,this._targetEnd);this._targetEnd.copy(T),this._target.add(S),this._changedZoom-=u,xt(this._changedZoom)&&(this._changedZoom=0)}this._camera.zoom!==this._zoom&&(this._camera.zoom=this._zoom,this._camera.updateProjectionMatrix(),this._updateNearPlaneCorners(),this._needsUpdate=!0),this._dragNeedsUpdate=!0;const l=this._collisionTest();this._spherical.radius=Math.min(this._spherical.radius,l),this._spherical.makeSafe(),this._camera.position.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(this._target),this._camera.lookAt(this._target),(!xt(this._focalOffset.x)||!xt(this._focalOffset.y)||!xt(this._focalOffset.z))&&(this._camera.matrix.compose(this._camera.position,this._camera.quaternion,this._camera.scale),re.setFromMatrixColumn(this._camera.matrix,0),oe.setFromMatrixColumn(this._camera.matrix,1),Te.setFromMatrixColumn(this._camera.matrix,2),re.multiplyScalar(this._focalOffset.x),oe.multiplyScalar(-this._focalOffset.y),Te.multiplyScalar(this._focalOffset.z),ht.copy(re).add(oe).add(Te),this._camera.position.add(ht),this._camera.updateMatrixWorld()),this._boundaryEnclosesCamera&&this._encloseToBoundary(this._camera.position.copy(this._target),ht.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse),1);const h=this._needsUpdate;return h&&!this._updatedLastTime?(this._hasRested=!1,this.dispatchEvent({type:"wake"}),this.dispatchEvent({type:"update"})):h?(this.dispatchEvent({type:"update"}),xt(t,this.restThreshold)&&xt(i,this.restThreshold)&&xt(s,this.restThreshold)&&xt(n.x,this.restThreshold)&&xt(n.y,this.restThreshold)&&xt(n.z,this.restThreshold)&&xt(r.x,this.restThreshold)&&xt(r.y,this.restThreshold)&&xt(r.z,this.restThreshold)&&xt(a,this.restThreshold)&&!this._hasRested&&(this._hasRested=!0,this.dispatchEvent({type:"rest"}))):!h&&this._updatedLastTime&&this.dispatchEvent({type:"sleep"}),this._lastDistance=this._spherical.radius,this._lastZoom=this._zoom,this._updatedLastTime=h,this._needsUpdate=!1,h}toJSON(){return JSON.stringify({enabled:this._enabled,minDistance:this.minDistance,maxDistance:Xe(this.maxDistance),minZoom:this.minZoom,maxZoom:Xe(this.maxZoom),minPolarAngle:this.minPolarAngle,maxPolarAngle:Xe(this.maxPolarAngle),minAzimuthAngle:Xe(this.minAzimuthAngle),maxAzimuthAngle:Xe(this.maxAzimuthAngle),smoothTime:this.smoothTime,draggingSmoothTime:this.draggingSmoothTime,dollySpeed:this.dollySpeed,truckSpeed:this.truckSpeed,dollyToCursor:this.dollyToCursor,target:this._targetEnd.toArray(),position:ht.setFromSpherical(this._sphericalEnd).add(this._targetEnd).toArray(),zoom:this._zoomEnd,focalOffset:this._focalOffsetEnd.toArray(),target0:this._target0.toArray(),position0:this._position0.toArray(),zoom0:this._zoom0,focalOffset0:this._focalOffset0.toArray()})}fromJSON(e,t=!1){const i=JSON.parse(e);this.enabled=i.enabled,this.minDistance=i.minDistance,this.maxDistance=Qe(i.maxDistance),this.minZoom=i.minZoom,this.maxZoom=Qe(i.maxZoom),this.minPolarAngle=i.minPolarAngle,this.maxPolarAngle=Qe(i.maxPolarAngle),this.minAzimuthAngle=Qe(i.minAzimuthAngle),this.maxAzimuthAngle=Qe(i.maxAzimuthAngle),this.smoothTime=i.smoothTime,this.draggingSmoothTime=i.draggingSmoothTime,this.dollySpeed=i.dollySpeed,this.truckSpeed=i.truckSpeed,this.dollyToCursor=i.dollyToCursor,this._target0.fromArray(i.target0),this._position0.fromArray(i.position0),this._zoom0=i.zoom0,this._focalOffset0.fromArray(i.focalOffset0),this.moveTo(i.target[0],i.target[1],i.target[2],t),Wt.setFromVector3(ht.fromArray(i.position).sub(this._targetEnd).applyQuaternion(this._yAxisUpSpace)),this.rotateTo(Wt.theta,Wt.phi,t),this.dollyTo(Wt.radius,t),this.zoomTo(i.zoom,t),this.setFocalOffset(i.focalOffset[0],i.focalOffset[1],i.focalOffset[2],t),this._needsUpdate=!0}connect(e){this._domElement?console.warn("camera-controls is already connected."):(e.setAttribute("data-camera-controls-version","3.1.2"),this._addAllEventListeners(e),this._getClientRect(this._elementRect))}disconnect(){this.cancel(),this._removeAllEventListeners(),this._domElement&&(this._domElement.removeAttribute("data-camera-controls-version"),this._domElement=void 0)}dispose(){this.removeAllEventListeners(),this.disconnect()}_getTargetDirection(e){return e.setFromSpherical(this._spherical).divideScalar(this._spherical.radius).applyQuaternion(this._yAxisUpSpaceInverse)}_getCameraDirection(e){return this._getTargetDirection(e).negate()}_findPointerById(e){return this._activePointers.find(t=>t.pointerId===e)}_findPointerByMouseButton(e){return this._activePointers.find(t=>t.mouseButton===e)}_disposePointer(e){this._activePointers.splice(this._activePointers.indexOf(e),1)}_encloseToBoundary(e,t,i){const s=t.lengthSq();if(0===s)return e;const n=mt.copy(t).add(e),a=this._boundary.clampPoint(n,Oe).sub(n),l=a.lengthSq();if(0===l)return e.add(t);if(l===s)return e;if(0===i)return e.add(t).add(a);{const c=1+i*l/t.dot(a);return e.add(mt.copy(t).multiplyScalar(c)).add(a.multiplyScalar(1-i))}}_updateNearPlaneCorners(){if(Ce(this._camera)){const e=this._camera,t=e.near,i=e.getEffectiveFOV()*Ge,s=Math.tan(.5*i)*t,n=s*e.aspect;this._nearPlaneCorners[0].set(-n,-s,0),this._nearPlaneCorners[1].set(n,-s,0),this._nearPlaneCorners[2].set(n,s,0),this._nearPlaneCorners[3].set(-n,s,0)}else if(pe(this._camera)){const e=this._camera,t=1/e.zoom,i=e.left*t,s=e.right*t,n=e.top*t,r=e.bottom*t;this._nearPlaneCorners[0].set(i,n,0),this._nearPlaneCorners[1].set(s,n,0),this._nearPlaneCorners[2].set(s,r,0),this._nearPlaneCorners[3].set(i,r,0)}}_truckInternal=(e,t,i,s)=>{let n,r;if(Ce(this._camera)){const a=ht.copy(this._camera.position).sub(this._target),l=this._camera.getEffectiveFOV()*Ge,c=a.length()*Math.tan(.5*l);n=this.truckSpeed*e*c/this._elementRect.height,r=this.truckSpeed*t*c/this._elementRect.height}else{if(!pe(this._camera))return;{const a=this._camera;n=this.truckSpeed*e*(a.right-a.left)/a.zoom/this._elementRect.width,r=this.truckSpeed*t*(a.top-a.bottom)/a.zoom/this._elementRect.height}}s?(i?this.setFocalOffset(this._focalOffsetEnd.x+n,this._focalOffsetEnd.y,this._focalOffsetEnd.z,!0):this.truck(n,0,!0),this.forward(-r,!0)):i?this.setFocalOffset(this._focalOffsetEnd.x+n,this._focalOffsetEnd.y+r,this._focalOffsetEnd.z,!0):this.truck(n,r,!0)};_rotateInternal=(e,t)=>{this.rotate(me*this.azimuthRotateSpeed*e/this._elementRect.height,me*this.polarRotateSpeed*t/this._elementRect.height,!0)};_dollyInternal=(e,t,i)=>{const s=Math.pow(.95,-e*this.dollySpeed),n=this._sphericalEnd.radius,r=this._sphericalEnd.radius*s,a=ie(r,this.minDistance,this.maxDistance),l=a-r;this.infinityDolly&&this.dollyToCursor?this._dollyToNoClamp(r,!0):this.infinityDolly&&!this.dollyToCursor?(this.dollyInFixed(l,!0),this._dollyToNoClamp(a,!0)):this._dollyToNoClamp(a,!0),this.dollyToCursor&&(this._changedDolly+=(this.infinityDolly?r:a)-n,this._dollyControlCoord.set(t,i)),this._lastDollyDirection=Math.sign(-e)};_zoomInternal=(e,t,i)=>{const s=Math.pow(.95,e*this.dollySpeed),n=this._zoom,r=this._zoom*s;this.zoomTo(r,!0),this.dollyToCursor&&(this._changedZoom+=r-n,this._dollyControlCoord.set(t,i))};_collisionTest(){let e=1/0;if(!(this.colliderMeshes.length>=1)||ls(this._camera,"_collisionTest"))return e;const i=this._getTargetDirection(Ke);ds.lookAt(Tn,i,this._camera.up);for(let s=0;s<4;s++){const n=mt.copy(this._nearPlaneCorners[s]);n.applyMatrix4(ds);const r=Oe.addVectors(this._target,n);Ci.set(r,i),Ci.far=this._spherical.radius+1;const a=Ci.intersectObjects(this.colliderMeshes);0!==a.length&&a[0].distance<e&&(e=a[0].distance)}return e}_getClientRect(e){if(!this._domElement)return;const t=this._domElement.getBoundingClientRect();return e.x=t.left,e.y=t.top,this._viewport?(e.x+=this._viewport.x,e.y+=t.height-this._viewport.w-this._viewport.y,e.width=this._viewport.z,e.height=this._viewport.w):(e.width=t.width,e.height=t.height),e}_createOnRestPromise(e){return e?Promise.resolve():(this._hasRested=!1,this.dispatchEvent({type:"transitionstart"}),new Promise(t=>{const i=()=>{this.removeEventListener("rest",i),t()};this.addEventListener("rest",i)}))}_addAllEventListeners(e){}_removeAllEventListeners(){}get dampingFactor(){return console.warn(".dampingFactor has been deprecated. use smoothTime (in seconds) instead."),0}set dampingFactor(e){console.warn(".dampingFactor has been deprecated. use smoothTime (in seconds) instead.")}get draggingDampingFactor(){return console.warn(".draggingDampingFactor has been deprecated. use draggingSmoothTime (in seconds) instead."),0}set draggingDampingFactor(e){console.warn(".draggingDampingFactor has been deprecated. use draggingSmoothTime (in seconds) instead.")}static createBoundingSphere(e,t=new lt.Sphere){const i=t,s=i.center;ze.makeEmpty(),e.traverseVisible(r=>{r.isMesh&&ze.expandByObject(r)}),ze.getCenter(s);let n=0;return e.traverseVisible(r=>{if(!r.isMesh)return;const a=r;if(!a.geometry)return;const l=a.geometry.clone();l.applyMatrix4(a.matrixWorld);const h=l.attributes.position;for(let u=0,f=h.count;u<f;u++)ht.fromBufferAttribute(h,u),n=Math.max(n,s.distanceToSquared(ht))}),i.radius=Math.sqrt(n),i}}var Po=Object.defineProperty,w=(o,e,t)=>(((o,e,t)=>{e in o?Po(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t})(o,"symbol"!=typeof e?e+"":e,t),t);class X{constructor(){w(this,"enabled",!0),w(this,"trigger",e=>{if(!this.enabled)return;const t=this.handlers.slice(0);for(const i of t)i(e)}),w(this,"handlers",[])}add(e){this.handlers.push(e)}remove(e){this.handlers=this.handlers.filter(t=>t!==e)}reset(){this.handlers.length=0}}class fs{constructor(e){w(this,"isDisposeable",()=>"dispose"in this&&"onDisposed"in this),w(this,"isResizeable",()=>"resize"in this&&"getSize"in this),w(this,"isUpdateable",()=>"onAfterUpdate"in this&&"onBeforeUpdate"in this&&"update"in this),w(this,"isHideable",()=>"visible"in this),w(this,"isConfigurable",()=>"setup"in this&&"config"in this&&"onSetup"in this),w(this,"isSerializable",()=>"import"in this&&"export"in this),this.components=e}}class Tt extends fs{}class ps extends fs{constructor(e){super(e),w(this,"worlds",new ft.jp),w(this,"onWorldChanged",new X),w(this,"_currentWorld",null),this.onWorldChanged.add(({world:t,action:i})=>{"removed"===i&&this.worlds.delete(t.uuid)})}set currentWorld(e){this._currentWorld=e}get currentWorld(){return this._currentWorld}}class Io extends ps{constructor(){super(...arguments),w(this,"hasCameraControls",()=>"controls"in this)}}const In=class pn extends Tt{constructor(e){super(e),w(this,"_disposedComponents",new Set),w(this,"enabled",!0),e.add(pn.uuid,this)}get(){return this._disposedComponents}destroy(e,t=!0,i=!0){e.removeFromParent();const s=e;s.dispose&&s.dispose(),this.disposeGeometryAndMaterials(e,t),i&&s.children&&s.children.length&&this.disposeChildren(s),e.children.length=0}disposeGeometry(e){e.boundsTree&&e.disposeBoundsTree&&e.disposeBoundsTree(),e.dispose()}disposeGeometryAndMaterials(e,t){const i=e;i.geometry&&this.disposeGeometry(i.geometry),t&&i.material&&pn.disposeMaterial(i),i.material=[],i.geometry=null}disposeChildren(e){for(const t of e.children)this.destroy(t)}static disposeMaterial(e){if(e.material)if(Array.isArray(e.material))for(const t of e.material)t.dispose();else e.material.dispose()}};w(In,"uuid","76e9cd8e-ad8f-4753-9ef6-cbc60f7247fe");let Je=In;class Oo extends ps{constructor(e){super(e),w(this,"onDisposed",new X),w(this,"directionalLights",new Map),w(this,"ambientLights",new Map)}dispose(){const e=this.components.get(Je);for(const t of this.three.children)t.geometry&&e.destroy(t);this.deleteAllLights(),this.three.children=[],this.onDisposed.trigger(),this.onDisposed.reset()}deleteAllLights(){for(const[,e]of this.directionalLights)e.removeFromParent(),e.target.removeFromParent(),e.dispose();this.directionalLights.clear();for(const[,e]of this.ambientLights)e.removeFromParent(),e.dispose();this.ambientLights.clear()}}Set;const ms=class Rt{static create(){const e=4294967295*Math.random()|0,t=4294967295*Math.random()|0,i=4294967295*Math.random()|0,s=4294967295*Math.random()|0;return`${Rt._lut[255&e]+Rt._lut[e>>8&255]+Rt._lut[e>>16&255]+Rt._lut[e>>24&255]}-${Rt._lut[255&t]}${Rt._lut[t>>8&255]}-${Rt._lut[t>>16&15|64]}${Rt._lut[t>>24&255]}-${Rt._lut[63&i|128]}${Rt._lut[i>>8&255]}-${Rt._lut[i>>16&255]}${Rt._lut[i>>24&255]}${Rt._lut[255&s]}${Rt._lut[s>>8&255]}${Rt._lut[s>>16&255]}${Rt._lut[s>>24&255]}`.toLowerCase()}static validate(e){if(!Rt._pattern.test(e))throw new Error(`${e} is not a valid UUID v4.\n\n- If you're the tool creator, you can take one from https://www.uuidgenerator.net/.\n\n- If you're using a platform tool, verify the uuid isn't misspelled or contact the tool creator.`)}};w(ms,"_pattern",/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$/),w(ms,"_lut",["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"]);let Yt=ms;const Mn=":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",Fo=new RegExp("^["+Mn+"]["+Mn+"\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$");function On(o,e){const t=[];let i=e.exec(o);for(;i;){const s=[];s.startIndex=e.lastIndex-i[0].length;const n=i.length;for(let r=0;r<n;r++)s.push(i[r]);t.push(s),i=e.exec(o)}return t}const Ti=function(o){const e=Fo.exec(o);return!(null===e||typeof e>"u")},Do={allowBooleanAttributes:!1,unpairedTags:[]};function kn(o){return" "===o||"\t"===o||"\n"===o||"\r"===o}function zn(o,e){const t=e;for(;e<o.length;e++)if("?"==o[e]||" "==o[e]){const i=o.substr(t,e-t);if(e>5&&"xml"===i)return kt("InvalidXml","XML declaration allowed only at the start of the document.",Ut(o,e));if("?"==o[e]&&">"==o[e+1]){e++;break}continue}return e}function Fn(o,e){if(o.length>e+5&&"-"===o[e+1]&&"-"===o[e+2]){for(e+=3;e<o.length;e++)if("-"===o[e]&&"-"===o[e+1]&&">"===o[e+2]){e+=2;break}}else if(o.length>e+8&&"D"===o[e+1]&&"O"===o[e+2]&&"C"===o[e+3]&&"T"===o[e+4]&&"Y"===o[e+5]&&"P"===o[e+6]&&"E"===o[e+7]){let t=1;for(e+=8;e<o.length;e++)if("<"===o[e])t++;else if(">"===o[e]&&(t--,0===t))break}else if(o.length>e+9&&"["===o[e+1]&&"C"===o[e+2]&&"D"===o[e+3]&&"A"===o[e+4]&&"T"===o[e+5]&&"A"===o[e+6]&&"["===o[e+7])for(e+=8;e<o.length;e++)if("]"===o[e]&&"]"===o[e+1]&&">"===o[e+2]){e+=2;break}return e}function Vo(o,e){let t="",i="",s=!1;for(;e<o.length;e++){if('"'===o[e]||"'"===o[e])""===i?i=o[e]:i!==o[e]||(i="");else if(">"===o[e]&&""===i){s=!0;break}t+=o[e]}return""===i&&{value:t,index:e,tagClosed:s}}const Uo=new RegExp("(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['\"])(([\\s\\S])*?)\\5)?","g");function Nn(o,e){const t=On(o,Uo),i={};for(let s=0;s<t.length;s++){if(0===t[s][1].length)return kt("InvalidAttr","Attribute '"+t[s][2]+"' has no space in starting.",ti(t[s]));if(void 0!==t[s][3]&&void 0===t[s][4])return kt("InvalidAttr","Attribute '"+t[s][2]+"' is without value.",ti(t[s]));if(void 0===t[s][3]&&!e.allowBooleanAttributes)return kt("InvalidAttr","boolean attribute '"+t[s][2]+"' is not allowed.",ti(t[s]));const n=t[s][2];if(!Ho(n))return kt("InvalidAttr","Attribute '"+n+"' is an invalid name.",ti(t[s]));if(i.hasOwnProperty(n))return kt("InvalidAttr","Attribute '"+n+"' is repeated.",ti(t[s]));i[n]=1}return!0}function jo(o,e){if(";"===o[++e])return-1;if("#"===o[e])return function $o(o,e){let t=/\d/;for("x"===o[e]&&(e++,t=/[\da-fA-F]/);e<o.length;e++){if(";"===o[e])return e;if(!o[e].match(t))break}return-1}(o,++e);let t=0;for(;e<o.length;e++,t++)if(!(o[e].match(/\w/)&&t<20)){if(";"===o[e])break;return-1}return e}function kt(o,e,t){return{err:{code:o,msg:e,line:t.line||t,col:t.col}}}function Ho(o){return Ti(o)}function Yo(o){return Ti(o)}function Ut(o,e){const t=o.substring(0,e).split(/\r?\n/);return{line:t.length,col:t[t.length-1].length+1}}function ti(o){return o.startIndex+o[1].length}const Zo={preserveOrder:!1,attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,removeNSPrefix:!1,allowBooleanAttributes:!1,parseTagValue:!0,parseAttributeValue:!1,trimValues:!0,cdataPropName:!1,numberParseOptions:{hex:!0,leadingZeros:!0,eNotation:!0},tagValueProcessor:function(o,e){return e},attributeValueProcessor:function(o,e){return e},stopNodes:[],alwaysCreateTextNode:!1,isArray:()=>!1,commentPropName:!1,unpairedTags:[],processEntities:!0,htmlEntities:!1,ignoreDeclaration:!1,ignorePiTags:!1,transformTagName:!1,transformAttributeName:!1,updateTag:function(o,e,t){return o},captureMetaData:!1};function Dn(o){return"boolean"==typeof o?{enabled:o,maxEntitySize:1e4,maxExpansionDepth:10,maxTotalExpansions:1e3,maxExpandedLength:1e5,allowedTags:null,tagFilter:null}:"object"==typeof o&&null!==o?{enabled:!1!==o.enabled,maxEntitySize:o.maxEntitySize??1e4,maxExpansionDepth:o.maxExpansionDepth??10,maxTotalExpansions:o.maxTotalExpansions??1e3,maxExpandedLength:o.maxExpandedLength??1e5,allowedTags:o.allowedTags??null,tagFilter:o.tagFilter??null}:Dn(!0)}const Wo=function(o){const e=Object.assign({},Zo,o);return e.processEntities=Dn(e.processEntities),e};let Ei;Ei="function"!=typeof Symbol?"@@xmlMetadata":Symbol("XML Node Metadata");class Ee{constructor(e){this.tagname=e,this.child=[],this[":@"]={}}add(e,t){"__proto__"===e&&(e="#__proto__"),this.child.push({[e]:t})}addChild(e,t){"__proto__"===e.tagname&&(e.tagname="#__proto__"),e[":@"]&&Object.keys(e[":@"]).length>0?this.child.push({[e.tagname]:e.child,":@":e[":@"]}):this.child.push({[e.tagname]:e.child}),void 0!==t&&(this.child[this.child.length-1][Ei]={startIndex:t})}static getMetaDataSymbol(){return Ei}}class qo{constructor(e){this.suppressValidationErr=!e,this.options=e}readDocType(e,t){const i={};if("O"!==e[t+3]||"C"!==e[t+4]||"T"!==e[t+5]||"Y"!==e[t+6]||"P"!==e[t+7]||"E"!==e[t+8])throw new Error("Invalid Tag instead of DOCTYPE");{t+=9;let s=1,n=!1,r=!1,a="";for(;t<e.length;t++)if("<"!==e[t]||r)if(">"===e[t]){if(r?"-"===e[t-1]&&"-"===e[t-2]&&(r=!1,s--):s--,0===s)break}else"["===e[t]?n=!0:a+=e[t];else{if(n&&Ae(e,"!ENTITY",t)){let l,c;if(t+=7,[l,c,t]=this.readEntityExp(e,t+1,this.suppressValidationErr),-1===c.indexOf("&")){const h=l.replace(/[.\-+*:]/g,"\\.");i[l]={regx:RegExp(`&${h};`,"g"),val:c}}}else if(n&&Ae(e,"!ELEMENT",t)){t+=8;const{index:l}=this.readElementExp(e,t+1);t=l}else if(n&&Ae(e,"!ATTLIST",t))t+=8;else if(n&&Ae(e,"!NOTATION",t)){t+=9;const{index:l}=this.readNotationExp(e,t+1,this.suppressValidationErr);t=l}else{if(!Ae(e,"!--",t))throw new Error("Invalid DOCTYPE");r=!0}s++,a=""}if(0!==s)throw new Error("Unclosed DOCTYPE")}return{entities:i,i:t}}readEntityExp(e,t){t=Zt(e,t);let i="";for(;t<e.length&&!/\s/.test(e[t])&&'"'!==e[t]&&"'"!==e[t];)i+=e[t],t++;if(ei(i),t=Zt(e,t),!this.suppressValidationErr){if("SYSTEM"===e.substring(t,t+6).toUpperCase())throw new Error("External entities are not supported");if("%"===e[t])throw new Error("Parameter entities are not supported")}let s="";if([t,s]=this.readIdentifierVal(e,t,"entity"),!1!==this.options.enabled&&this.options.maxEntitySize&&s.length>this.options.maxEntitySize)throw new Error(`Entity "${i}" size (${s.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`);return[i,s,--t]}readNotationExp(e,t){t=Zt(e,t);let i="";for(;t<e.length&&!/\s/.test(e[t]);)i+=e[t],t++;!this.suppressValidationErr&&ei(i),t=Zt(e,t);const s=e.substring(t,t+6).toUpperCase();if(!this.suppressValidationErr&&"SYSTEM"!==s&&"PUBLIC"!==s)throw new Error(`Expected SYSTEM or PUBLIC, found "${s}"`);t=Zt(e,t+=s.length);let n=null,r=null;if("PUBLIC"===s)[t,n]=this.readIdentifierVal(e,t,"publicIdentifier"),('"'===e[t=Zt(e,t)]||"'"===e[t])&&([t,r]=this.readIdentifierVal(e,t,"systemIdentifier"));else if("SYSTEM"===s&&([t,r]=this.readIdentifierVal(e,t,"systemIdentifier"),!this.suppressValidationErr&&!r))throw new Error("Missing mandatory system identifier for SYSTEM notation");return{notationName:i,publicIdentifier:n,systemIdentifier:r,index:--t}}readIdentifierVal(e,t,i){let s="";const n=e[t];if('"'!==n&&"'"!==n)throw new Error(`Expected quoted string, found "${n}"`);for(t++;t<e.length&&e[t]!==n;)s+=e[t],t++;if(e[t]!==n)throw new Error(`Unterminated ${i} value`);return[++t,s]}readElementExp(e,t){t=Zt(e,t);let i="";for(;t<e.length&&!/\s/.test(e[t]);)i+=e[t],t++;if(!this.suppressValidationErr&&!Ti(i))throw new Error(`Invalid element name: "${i}"`);let s="";if("E"===e[t=Zt(e,t)]&&Ae(e,"MPTY",t))t+=4;else if("A"===e[t]&&Ae(e,"NY",t))t+=2;else if("("===e[t]){for(t++;t<e.length&&")"!==e[t];)s+=e[t],t++;if(")"!==e[t])throw new Error("Unterminated content model")}else if(!this.suppressValidationErr)throw new Error(`Invalid Element Expression, found "${e[t]}"`);return{elementName:i,contentModel:s.trim(),index:t}}readAttlistExp(e,t){t=Zt(e,t);let i="";for(;t<e.length&&!/\s/.test(e[t]);)i+=e[t],t++;ei(i),t=Zt(e,t);let s="";for(;t<e.length&&!/\s/.test(e[t]);)s+=e[t],t++;if(!ei(s))throw new Error(`Invalid attribute name: "${s}"`);t=Zt(e,t);let n="";if("NOTATION"===e.substring(t,t+8).toUpperCase()){if(n="NOTATION","("!==e[t=Zt(e,t+=8)])throw new Error(`Expected '(', found "${e[t]}"`);t++;let a=[];for(;t<e.length&&")"!==e[t];){let l="";for(;t<e.length&&"|"!==e[t]&&")"!==e[t];)l+=e[t],t++;if(l=l.trim(),!ei(l))throw new Error(`Invalid notation name: "${l}"`);a.push(l),"|"===e[t]&&(t++,t=Zt(e,t))}if(")"!==e[t])throw new Error("Unterminated list of notations");t++,n+=" ("+a.join("|")+")"}else{for(;t<e.length&&!/\s/.test(e[t]);)n+=e[t],t++;if(!this.suppressValidationErr&&!["CDATA","ID","IDREF","IDREFS","ENTITY","ENTITIES","NMTOKEN","NMTOKENS"].includes(n.toUpperCase()))throw new Error(`Invalid attribute type: "${n}"`)}t=Zt(e,t);let r="";return"#REQUIRED"===e.substring(t,t+8).toUpperCase()?(r="#REQUIRED",t+=8):"#IMPLIED"===e.substring(t,t+7).toUpperCase()?(r="#IMPLIED",t+=7):[t,r]=this.readIdentifierVal(e,t,"ATTLIST"),{elementName:i,attributeName:s,attributeType:n,defaultValue:r,index:t}}}const Zt=(o,e)=>{for(;e<o.length&&/\s/.test(o[e]);)e++;return e};function Ae(o,e,t){for(let i=0;i<e.length;i++)if(e[i]!==o[t+i+1])return!1;return!0}function ei(o){if(Ti(o))return o;throw new Error(`Invalid entity name ${o}`)}const Go=/^[-+]?0x[a-fA-F0-9]+$/,Xo=/^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/,Qo={hex:!0,leadingZeros:!0,decimalPoint:".",eNotation:!0};const Jo=/^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/;function Rn(o){return"function"==typeof o?o:Array.isArray(o)?e=>{for(const t of o)if("string"==typeof t&&e===t||t instanceof RegExp&&t.test(e))return!0}:()=>!1}class sa{constructor(e){if(this.options=e,this.currentNode=null,this.tagsNodeStack=[],this.docTypeEntities={},this.lastEntities={apos:{regex:/&(apos|#39|#x27);/g,val:"'"},gt:{regex:/&(gt|#62|#x3E);/g,val:">"},lt:{regex:/&(lt|#60|#x3C);/g,val:"<"},quot:{regex:/&(quot|#34|#x22);/g,val:'"'}},this.ampEntity={regex:/&(amp|#38|#x26);/g,val:"&"},this.htmlEntities={space:{regex:/&(nbsp|#160);/g,val:" "},cent:{regex:/&(cent|#162);/g,val:"\xa2"},pound:{regex:/&(pound|#163);/g,val:"\xa3"},yen:{regex:/&(yen|#165);/g,val:"\xa5"},euro:{regex:/&(euro|#8364);/g,val:"\u20ac"},copyright:{regex:/&(copy|#169);/g,val:"\xa9"},reg:{regex:/&(reg|#174);/g,val:"\xae"},inr:{regex:/&(inr|#8377);/g,val:"\u20b9"},num_dec:{regex:/&#([0-9]{1,7});/g,val:(t,i)=>Bn(i,10,"&#")},num_hex:{regex:/&#x([0-9a-fA-F]{1,6});/g,val:(t,i)=>Bn(i,16,"&#x")}},this.addExternalEntities=na,this.parseXml=ca,this.parseTextData=ra,this.resolveNameSpace=oa,this.buildAttributesMap=la,this.isItStopNode=fa,this.replaceEntitiesValue=ua,this.readStopNodeData=ma,this.saveTextToParentTag=da,this.addChild=ha,this.ignoreAttributesFn=Rn(this.options.ignoreAttributes),this.entityExpansionCount=0,this.currentExpandedLength=0,this.options.stopNodes&&this.options.stopNodes.length>0){this.stopNodesExact=new Set,this.stopNodesWildcard=new Set;for(let t=0;t<this.options.stopNodes.length;t++){const i=this.options.stopNodes[t];"string"==typeof i&&(i.startsWith("*.")?this.stopNodesWildcard.add(i.substring(2)):this.stopNodesExact.add(i))}}}}function na(o){const e=Object.keys(o);for(let t=0;t<e.length;t++){const i=e[t],s=i.replace(/[.\-+*:]/g,"\\.");this.lastEntities[i]={regex:new RegExp("&"+s+";","g"),val:o[i]}}}function ra(o,e,t,i,s,n,r){if(void 0!==o&&(this.options.trimValues&&!i&&(o=o.trim()),o.length>0)){r||(o=this.replaceEntitiesValue(o,e,t));const a=this.options.tagValueProcessor(e,o,t,s,n);return null==a?o:typeof a!=typeof o||a!==o?a:this.options.trimValues||o.trim()===o?_s(o,this.options.parseTagValue,this.options.numberParseOptions):o}}function oa(o){if(this.options.removeNSPrefix){const e=o.split(":"),t="/"===o.charAt(0)?"/":"";if("xmlns"===e[0])return"";2===e.length&&(o=t+e[1])}return o}const aa=new RegExp("([^\\s=]+)\\s*(=\\s*(['\"])([\\s\\S]*?)\\3)?","gm");function la(o,e,t){if(!0!==this.options.ignoreAttributes&&"string"==typeof o){const i=On(o,aa),s=i.length,n={};for(let r=0;r<s;r++){const a=this.resolveNameSpace(i[r][1]);if(this.ignoreAttributesFn(a,e))continue;let l=i[r][4],c=this.options.attributeNamePrefix+a;if(a.length)if(this.options.transformAttributeName&&(c=this.options.transformAttributeName(c)),"__proto__"===c&&(c="#__proto__"),void 0!==l){this.options.trimValues&&(l=l.trim()),l=this.replaceEntitiesValue(l,t,e);const h=this.options.attributeValueProcessor(a,l,e);n[c]=null==h?l:typeof h!=typeof l||h!==l?h:_s(l,this.options.parseAttributeValue,this.options.numberParseOptions)}else this.options.allowBooleanAttributes&&(n[c]=!0)}if(!Object.keys(n).length)return;if(this.options.attributesGroupName){const r={};return r[this.options.attributesGroupName]=n,r}return n}}const ca=function(o){o=o.replace(/\r\n?/g,"\n");const e=new Ee("!xml");let t=e,i="",s="";this.entityExpansionCount=0,this.currentExpandedLength=0;const n=new qo(this.options.processEntities);for(let r=0;r<o.length;r++)if("<"===o[r])if("/"===o[r+1]){const l=Pe(o,">",r,"Closing Tag is not closed.");let c=o.substring(r+2,l).trim();if(this.options.removeNSPrefix){const f=c.indexOf(":");-1!==f&&(c=c.substr(f+1))}this.options.transformTagName&&(c=this.options.transformTagName(c)),t&&(i=this.saveTextToParentTag(i,t,s));const h=s.substring(s.lastIndexOf(".")+1);if(c&&-1!==this.options.unpairedTags.indexOf(c))throw new Error(`Unpaired tag can not be used as closing tag: </${c}>`);let u=0;h&&-1!==this.options.unpairedTags.indexOf(h)?(u=s.lastIndexOf(".",s.lastIndexOf(".")-1),this.tagsNodeStack.pop()):u=s.lastIndexOf("."),s=s.substring(0,u),t=this.tagsNodeStack.pop(),i="",r=l}else if("?"===o[r+1]){let l=gs(o,r,!1,"?>");if(!l)throw new Error("Pi Tag is not closed.");if(i=this.saveTextToParentTag(i,t,s),!(this.options.ignoreDeclaration&&"?xml"===l.tagName||this.options.ignorePiTags)){const c=new Ee(l.tagName);c.add(this.options.textNodeName,""),l.tagName!==l.tagExp&&l.attrExpPresent&&(c[":@"]=this.buildAttributesMap(l.tagExp,s,l.tagName)),this.addChild(t,c,s,r)}r=l.closeIndex+1}else if("!--"===o.substr(r+1,3)){const l=Pe(o,"--\x3e",r+4,"Comment is not closed.");if(this.options.commentPropName){const c=o.substring(r+4,l-2);i=this.saveTextToParentTag(i,t,s),t.add(this.options.commentPropName,[{[this.options.textNodeName]:c}])}r=l}else if("!D"===o.substr(r+1,2)){const l=n.readDocType(o,r);this.docTypeEntities=l.entities,r=l.i}else if("!["===o.substr(r+1,2)){const l=Pe(o,"]]>",r,"CDATA is not closed.")-2,c=o.substring(r+9,l);i=this.saveTextToParentTag(i,t,s);let h=this.parseTextData(c,t.tagname,s,!0,!1,!0,!0);null==h&&(h=""),this.options.cdataPropName?t.add(this.options.cdataPropName,[{[this.options.textNodeName]:c}]):t.add(this.options.textNodeName,h),r=l+2}else{let l=gs(o,r,this.options.removeNSPrefix),c=l.tagName;const h=l.rawTagName;let u=l.tagExp,f=l.attrExpPresent,d=l.closeIndex;if(this.options.transformTagName){const _=this.options.transformTagName(c);u===c&&(u=_),c=_}t&&i&&"!xml"!==t.tagname&&(i=this.saveTextToParentTag(i,t,s,!1)),t&&-1!==this.options.unpairedTags.indexOf(t.tagname)&&(t=this.tagsNodeStack.pop(),s=s.substring(0,s.lastIndexOf("."))),c!==e.tagname&&(s+=s?"."+c:c);const g=r;if(this.isItStopNode(this.stopNodesExact,this.stopNodesWildcard,s,c)){let _="";if(u.length>0&&u.lastIndexOf("/")===u.length-1)"/"===c[c.length-1]?(c=c.substr(0,c.length-1),s=s.substr(0,s.length-1),u=c):u=u.substr(0,u.length-1),r=l.closeIndex;else if(-1!==this.options.unpairedTags.indexOf(c))r=l.closeIndex;else{const x=this.readStopNodeData(o,h,d+1);if(!x)throw new Error(`Unexpected end of ${h}`);r=x.i,_=x.tagContent}const p=new Ee(c);c!==u&&f&&(p[":@"]=this.buildAttributesMap(u,s,c)),_&&(_=this.parseTextData(_,c,s,!0,f,!0,!0)),s=s.substr(0,s.lastIndexOf(".")),p.add(this.options.textNodeName,_),this.addChild(t,p,s,g)}else{if(u.length>0&&u.lastIndexOf("/")===u.length-1){if("/"===c[c.length-1]?(c=c.substr(0,c.length-1),s=s.substr(0,s.length-1),u=c):u=u.substr(0,u.length-1),this.options.transformTagName){const p=this.options.transformTagName(c);u===c&&(u=p),c=p}const _=new Ee(c);c!==u&&f&&(_[":@"]=this.buildAttributesMap(u,s,c)),this.addChild(t,_,s,g),s=s.substr(0,s.lastIndexOf("."))}else{const _=new Ee(c);this.tagsNodeStack.push(t),c!==u&&f&&(_[":@"]=this.buildAttributesMap(u,s,c)),this.addChild(t,_,s,g),t=_}i="",r=d}}else i+=o[r];return e.child};function ha(o,e,t,i){this.options.captureMetaData||(i=void 0);const s=this.options.updateTag(e.tagname,t,e[":@"]);!1===s||("string"==typeof s&&(e.tagname=s),o.addChild(e,i))}const ua=function(o,e,t){if(-1===o.indexOf("&"))return o;const i=this.options.processEntities;if(!i.enabled||i.allowedTags&&!i.allowedTags.includes(e)||i.tagFilter&&!i.tagFilter(e,t))return o;for(let s in this.docTypeEntities){const n=this.docTypeEntities[s],r=o.match(n.regx);if(r){if(this.entityExpansionCount+=r.length,i.maxTotalExpansions&&this.entityExpansionCount>i.maxTotalExpansions)throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${i.maxTotalExpansions}`);const a=o.length;if(o=o.replace(n.regx,n.val),i.maxExpandedLength&&(this.currentExpandedLength+=o.length-a,this.currentExpandedLength>i.maxExpandedLength))throw new Error(`Total expanded content size exceeded: ${this.currentExpandedLength} > ${i.maxExpandedLength}`)}}if(-1===o.indexOf("&"))return o;for(let s in this.lastEntities){const n=this.lastEntities[s];o=o.replace(n.regex,n.val)}if(-1===o.indexOf("&"))return o;if(this.options.htmlEntities)for(let s in this.htmlEntities){const n=this.htmlEntities[s];o=o.replace(n.regex,n.val)}return o.replace(this.ampEntity.regex,this.ampEntity.val)};function da(o,e,t,i){return o&&(void 0===i&&(i=0===e.child.length),void 0!==(o=this.parseTextData(o,e.tagname,t,!1,!!e[":@"]&&0!==Object.keys(e[":@"]).length,i))&&""!==o&&e.add(this.options.textNodeName,o),o=""),o}function fa(o,e,t,i){return!!(e&&e.has(i)||o&&o.has(t))}function Pe(o,e,t,i){const s=o.indexOf(e,t);if(-1===s)throw new Error(i);return s+e.length-1}function gs(o,e,t,i=">"){const s=function pa(o,e,t=">"){let i,s="";for(let n=e;n<o.length;n++){let r=o[n];if(i)r===i&&(i="");else if('"'===r||"'"===r)i=r;else if(r===t[0]){if(!t[1])return{data:s,index:n};if(o[n+1]===t[1])return{data:s,index:n}}else"\t"===r&&(r=" ");s+=r}}(o,e+1,i);if(!s)return;let n=s.data;const r=s.index,a=n.search(/\s/);let l=n,c=!0;-1!==a&&(l=n.substring(0,a),n=n.substring(a+1).trimStart());const h=l;if(t){const u=l.indexOf(":");-1!==u&&(l=l.substr(u+1),c=l!==s.data.substr(u+1))}return{tagName:l,tagExp:n,closeIndex:r,attrExpPresent:c,rawTagName:h}}function ma(o,e,t){const i=t;let s=1;for(;t<o.length;t++)if("<"===o[t])if("/"===o[t+1]){const n=Pe(o,">",t,`${e} is not closed`);if(o.substring(t+2,n).trim()===e&&(s--,0===s))return{tagContent:o.substring(i,t),i:n};t=n}else if("?"===o[t+1])t=Pe(o,"?>",t+1,"StopNode is not closed.");else if("!--"===o.substr(t+1,3))t=Pe(o,"--\x3e",t+3,"StopNode is not closed.");else if("!["===o.substr(t+1,2))t=Pe(o,"]]>",t,"StopNode is not closed.")-2;else{const n=gs(o,t,">");n&&((n&&n.tagName)===e&&"/"!==n.tagExp[n.tagExp.length-1]&&s++,t=n.closeIndex)}}function _s(o,e,t){if(e&&"string"==typeof o){const i=o.trim();return"true"===i||"false"!==i&&function Ko(o,e={}){if(e=Object.assign({},Qo,e),!o||"string"!=typeof o)return o;let t=o.trim();if(void 0!==e.skipLike&&e.skipLike.test(t))return o;if("0"===o)return 0;if(e.hex&&Go.test(t))return function ia(o,e){if(parseInt)return parseInt(o,e);if(Number.parseInt)return Number.parseInt(o,e);if(window&&window.parseInt)return window.parseInt(o,e);throw new Error("parseInt, Number.parseInt, window.parseInt are not supported")}(t,16);if(t.includes("e")||t.includes("E"))return function ta(o,e,t){if(!t.eNotation)return o;const i=e.match(Jo);if(i){let s=i[1]||"";const n=-1===i[3].indexOf("e")?"E":"e",r=i[2],a=s?o[r.length+1]===n:o[r.length]===n;return r.length>1&&a?o:1!==r.length||!i[3].startsWith(`.${n}`)&&i[3][0]!==n?t.leadingZeros&&!a?(e=(i[1]||"")+i[3],Number(e)):o:Number(e)}return o}(o,t,e);{const i=Xo.exec(t);if(i){const s=i[1]||"",n=i[2];let r=function ea(o){return o&&-1!==o.indexOf(".")&&("."===(o=o.replace(/0+$/,""))?o="0":"."===o[0]?o="0"+o:"."===o[o.length-1]&&(o=o.substring(0,o.length-1))),o}(i[3]);if(!e.leadingZeros&&(n.length>1||1===n.length&&!(s?"."===o[n.length+1]:"."===o[n.length])))return o;{const l=Number(t),c=String(l);if(0===l)return l;if(-1!==c.search(/[eE]/))return e.eNotation?l:o;if(-1!==t.indexOf("."))return"0"===c||c===r||c===`${s}${r}`?l:o;let h=n?r:t;return n?h===c||s+h===c?l:o:h===c||h===s+c?l:o}}return o}}(o,t)}return function No(o){return typeof o<"u"}(o)?o:""}function Bn(o,e,t){const i=Number.parseInt(o,e);return i>=0&&i<=1114111?String.fromCodePoint(i):t+o+";"}const ys=Ee.getMetaDataSymbol();function ga(o,e){return Ln(o,e)}function Ln(o,e,t){let i;const s={};for(let n=0;n<o.length;n++){const r=o[n],a=_a(r);let l="";if(l=void 0===t?a:t+"."+a,a===e.textNodeName)void 0===i?i=r[a]:i+=""+r[a];else{if(void 0===a)continue;if(r[a]){let c=Ln(r[a],e,l);const h=va(c,e);void 0!==r[ys]&&(c[ys]=r[ys]),r[":@"]?ya(c,r[":@"],l,e):1!==Object.keys(c).length||void 0===c[e.textNodeName]||e.alwaysCreateTextNode?0===Object.keys(c).length&&(e.alwaysCreateTextNode?c[e.textNodeName]="":c=""):c=c[e.textNodeName],void 0!==s[a]&&s.hasOwnProperty(a)?(Array.isArray(s[a])||(s[a]=[s[a]]),s[a].push(c)):s[a]=e.isArray(a,l,h)?[c]:c}}}return"string"==typeof i?i.length>0&&(s[e.textNodeName]=i):void 0!==i&&(s[e.textNodeName]=i),s}function _a(o){const e=Object.keys(o);for(let t=0;t<e.length;t++){const i=e[t];if(":@"!==i)return i}}function ya(o,e,t,i){if(e){const s=Object.keys(e),n=s.length;for(let r=0;r<n;r++){const a=s[r];o[a]=i.isArray(a,t+"."+a,!0,!0)?[e[a]]:e[a]}}}function va(o,e){const{textNodeName:t}=e,i=Object.keys(o).length;return!(0!==i&&(1!==i||!o[t]&&"boolean"!=typeof o[t]&&0!==o[t]))}class vs{constructor(e){this.externalEntities={},this.options=Wo(e)}parse(e,t){if("string"!=typeof e&&e.toString)e=e.toString();else if("string"!=typeof e)throw new Error("XML data is accepted in String or Bytes[] form.");if(t){!0===t&&(t={});const n=function Ro(o,e){e=Object.assign({},Do,e);const t=[];let i=!1,s=!1;"\ufeff"===o[0]&&(o=o.substr(1));for(let n=0;n<o.length;n++)if("<"===o[n]&&"?"===o[n+1]){if(n+=2,n=zn(o,n),n.err)return n}else{if("<"!==o[n]){if(kn(o[n]))continue;return kt("InvalidChar","char '"+o[n]+"' is not expected.",Ut(o,n))}{let r=n;if(n++,"!"===o[n]){n=Fn(o,n);continue}{let a=!1;"/"===o[n]&&(a=!0,n++);let l="";for(;n<o.length&&">"!==o[n]&&" "!==o[n]&&"\t"!==o[n]&&"\n"!==o[n]&&"\r"!==o[n];n++)l+=o[n];if(l=l.trim(),"/"===l[l.length-1]&&(l=l.substring(0,l.length-1),n--),!Yo(l)){let u;return u=0===l.trim().length?"Invalid space after '<'.":"Tag '"+l+"' is an invalid name.",kt("InvalidTag",u,Ut(o,n))}const c=Vo(o,n);if(!1===c)return kt("InvalidAttr","Attributes for '"+l+"' have open quote.",Ut(o,n));let h=c.value;if(n=c.index,"/"===h[h.length-1]){const u=n-h.length;h=h.substring(0,h.length-1);const f=Nn(h,e);if(!0!==f)return kt(f.err.code,f.err.msg,Ut(o,u+f.err.line));i=!0}else if(a){if(!c.tagClosed)return kt("InvalidTag","Closing tag '"+l+"' doesn't have proper closing.",Ut(o,n));if(h.trim().length>0)return kt("InvalidTag","Closing tag '"+l+"' can't have attributes or invalid starting.",Ut(o,r));if(0===t.length)return kt("InvalidTag","Closing tag '"+l+"' has not been opened.",Ut(o,r));{const u=t.pop();if(l!==u.tagName){let f=Ut(o,u.tagStartPos);return kt("InvalidTag","Expected closing tag '"+u.tagName+"' (opened in line "+f.line+", col "+f.col+") instead of closing tag '"+l+"'.",Ut(o,r))}0==t.length&&(s=!0)}}else{const u=Nn(h,e);if(!0!==u)return kt(u.err.code,u.err.msg,Ut(o,n-h.length+u.err.line));if(!0===s)return kt("InvalidXml","Multiple possible root nodes found.",Ut(o,n));-1!==e.unpairedTags.indexOf(l)||t.push({tagName:l,tagStartPos:r}),i=!0}for(n++;n<o.length;n++)if("<"===o[n]){if("!"===o[n+1]){n++,n=Fn(o,n);continue}if("?"!==o[n+1])break;if(n=zn(o,++n),n.err)return n}else if("&"===o[n]){const u=jo(o,n);if(-1==u)return kt("InvalidChar","char '&' is not expected.",Ut(o,n));n=u}else if(!0===s&&!kn(o[n]))return kt("InvalidXml","Extra text at the end",Ut(o,n));"<"===o[n]&&n--}}}return i?1==t.length?kt("InvalidTag","Unclosed tag '"+t[0].tagName+"'.",Ut(o,t[0].tagStartPos)):!(t.length>0)||kt("InvalidXml","Invalid '"+JSON.stringify(t.map(n=>n.tagName),null,4).replace(/\r?\n/g,"")+"' found.",{line:1,col:1}):kt("InvalidXml","Start tag expected.",1)}(e,t);if(!0!==n)throw Error(`${n.err.msg}:${n.err.line}:${n.err.col}`)}const i=new sa(this.options);i.addExternalEntities(this.externalEntities);const s=i.parseXml(e);return this.options.preserveOrder||void 0===s?s:ga(s,this.options)}addEntity(e,t){if(-1!==t.indexOf("&"))throw new Error("Entity value can't have '&'");if(-1!==e.indexOf("&")||-1!==e.indexOf(";"))throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '
'");if("&"===t)throw new Error("An entity with value '&' is not permitted");this.externalEntities[e]=t}static getMetaDataSymbol(){return Ee.getMetaDataSymbol()}}function ba(o,e){let t="";return e.format&&e.indentBy.length>0&&(t="\n"),Vn(o,e,"",t)}function Vn(o,e,t,i){let s="",n=!1;for(let r=0;r<o.length;r++){const a=o[r],l=xa(a);if(void 0===l)continue;let c="";if(c=0===t.length?l:`${t}.${l}`,l===e.textNodeName){let y=a[l];Ca(c,e)||(y=e.tagValueProcessor(l,y),y=$n(y,e)),n&&(s+=i),s+=y,n=!1;continue}if(l===e.cdataPropName){n&&(s+=i),s+=`<![CDATA[${a[l][0][e.textNodeName]}]]>`,n=!1;continue}if(l===e.commentPropName){s+=i+`\x3c!--${a[l][0][e.textNodeName]}--\x3e`,n=!0;continue}if("?"===l[0]){const y=Un(a[":@"],e);let _=a[l][0][e.textNodeName];_=0!==_.length?" "+_:"",s+=("?xml"===l?"":i)+`<${l}${_}${y}?>`,n=!0;continue}let h=i;""!==h&&(h+=e.indentBy);const f=i+`<${l}${Un(a[":@"],e)}`,d=Vn(a[l],e,c,h);-1!==e.unpairedTags.indexOf(l)?s+=e.suppressUnpairedNode?f+">":f+"/>":d&&0!==d.length||!e.suppressEmptyNode?d&&d.endsWith(">")?s+=f+`>${d}${i}</${l}>`:(s+=f+">",d&&""!==i&&(d.includes("/>")||d.includes("</"))?s+=i+e.indentBy+d+i:s+=d,s+=`</${l}>`):s+=f+"/>",n=!0}return s}function xa(o){const e=Object.keys(o);for(let t=0;t<e.length;t++){const i=e[t];if(o.hasOwnProperty(i)&&":@"!==i)return i}}function Un(o,e){let t="";if(o&&!e.ignoreAttributes)for(let i in o){if(!o.hasOwnProperty(i))continue;let s=e.attributeValueProcessor(i,o[i]);s=$n(s,e),t+=!0===s&&e.suppressBooleanAttributes?` ${i.substr(e.attributeNamePrefix.length)}`:` ${i.substr(e.attributeNamePrefix.length)}="${s}"`}return t}function Ca(o,e){let t=(o=o.substr(0,o.length-e.textNodeName.length-1)).substr(o.lastIndexOf(".")+1);for(let i in e.stopNodes)if(e.stopNodes[i]===o||e.stopNodes[i]==="*."+t)return!0;return!1}function $n(o,e){if(o&&o.length>0&&e.processEntities)for(let t=0;t<e.entities.length;t++){const i=e.entities[t];o=o.replace(i.regex,i.val)}return o}const Ta={attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,cdataPropName:!1,format:!1,indentBy:" ",suppressEmptyNode:!1,suppressUnpairedNode:!0,suppressBooleanAttributes:!0,tagValueProcessor:function(o,e){return e},attributeValueProcessor:function(o,e){return e},preserveOrder:!1,commentPropName:!1,unpairedTags:[],entities:[{regex:new RegExp("&","g"),val:"&"},{regex:new RegExp(">","g"),val:">"},{regex:new RegExp("<","g"),val:"<"},{regex:new RegExp("'","g"),val:"'"},{regex:new RegExp('"',"g"),val:"""}],processEntities:!0,stopNodes:[],oneListGroup:!1};function ge(o){this.options=Object.assign({},Ta,o),!0===this.options.ignoreAttributes||this.options.attributesGroupName?this.isAttribute=function(){return!1}:(this.ignoreAttributesFn=Rn(this.options.ignoreAttributes),this.attrPrefixLen=this.options.attributeNamePrefix.length,this.isAttribute=Pa),this.processTextOrObjNode=Ea,this.options.format?(this.indentate=Aa,this.tagEndChar=">\n",this.newLine="\n"):(this.indentate=function(){return""},this.tagEndChar=">",this.newLine="")}function Ea(o,e,t,i){const s=this.j2x(o,t+1,i.concat(e));return void 0!==o[this.options.textNodeName]&&1===Object.keys(o).length?this.buildTextValNode(o[this.options.textNodeName],e,s.attrStr,t):this.buildObjectNode(s.val,e,s.attrStr,t)}function Aa(o){return this.options.indentBy.repeat(o)}function Pa(o){return!(!o.startsWith(this.options.attributeNamePrefix)||o===this.options.textNodeName)&&o.substr(this.attrPrefixLen)}ge.prototype.build=function(o){return this.options.preserveOrder?ba(o,this.options):(Array.isArray(o)&&this.options.arrayNodeName&&this.options.arrayNodeName.length>1&&(o={[this.options.arrayNodeName]:o}),this.j2x(o,0,[]).val)},ge.prototype.j2x=function(o,e,t){let i="",s="";const n=t.join(".");for(let r in o)if(Object.prototype.hasOwnProperty.call(o,r))if(typeof o[r]>"u")this.isAttribute(r)&&(s+="");else if(null===o[r])this.isAttribute(r)||r===this.options.cdataPropName?s+="":s+="?"===r[0]?this.indentate(e)+"<"+r+"?"+this.tagEndChar:this.indentate(e)+"<"+r+"/"+this.tagEndChar;else if(o[r]instanceof Date)s+=this.buildTextValNode(o[r],r,"",e);else if("object"!=typeof o[r]){const a=this.isAttribute(r);if(a&&!this.ignoreAttributesFn(a,n))i+=this.buildAttrPairStr(a,""+o[r]);else if(!a)if(r===this.options.textNodeName){let l=this.options.tagValueProcessor(r,""+o[r]);s+=this.replaceEntitiesValue(l)}else s+=this.buildTextValNode(o[r],r,"",e)}else if(Array.isArray(o[r])){const a=o[r].length;let l="",c="";for(let h=0;h<a;h++){const u=o[r][h];if(!(typeof u>"u"))if(null===u)s+="?"===r[0]?this.indentate(e)+"<"+r+"?"+this.tagEndChar:this.indentate(e)+"<"+r+"/"+this.tagEndChar;else if("object"==typeof u)if(this.options.oneListGroup){const f=this.j2x(u,e+1,t.concat(r));l+=f.val,this.options.attributesGroupName&&u.hasOwnProperty(this.options.attributesGroupName)&&(c+=f.attrStr)}else l+=this.processTextOrObjNode(u,r,e,t);else if(this.options.oneListGroup){let f=this.options.tagValueProcessor(r,u);f=this.replaceEntitiesValue(f),l+=f}else l+=this.buildTextValNode(u,r,"",e)}this.options.oneListGroup&&(l=this.buildObjectNode(l,r,c,e)),s+=l}else if(this.options.attributesGroupName&&r===this.options.attributesGroupName){const a=Object.keys(o[r]),l=a.length;for(let c=0;c<l;c++)i+=this.buildAttrPairStr(a[c],""+o[r][a[c]])}else s+=this.processTextOrObjNode(o[r],r,e,t);return{attrStr:i,val:s}},ge.prototype.buildAttrPairStr=function(o,e){return e=this.options.attributeValueProcessor(o,""+e),e=this.replaceEntitiesValue(e),this.options.suppressBooleanAttributes&&"true"===e?" "+o:" "+o+'="'+e+'"'},ge.prototype.buildObjectNode=function(o,e,t,i){if(""===o)return"?"===e[0]?this.indentate(i)+"<"+e+t+"?"+this.tagEndChar:this.indentate(i)+"<"+e+t+this.closeTag(e)+this.tagEndChar;{let s="</"+e+this.tagEndChar,n="";return"?"===e[0]&&(n="?",s=""),!t&&""!==t||-1!==o.indexOf("<")?!1!==this.options.commentPropName&&e===this.options.commentPropName&&0===n.length?this.indentate(i)+`\x3c!--${o}--\x3e`+this.newLine:this.indentate(i)+"<"+e+t+n+this.tagEndChar+o+this.indentate(i)+s:this.indentate(i)+"<"+e+t+n+">"+o+s}},ge.prototype.closeTag=function(o){let e="";return-1!==this.options.unpairedTags.indexOf(o)?this.options.suppressUnpairedNode||(e="/"):e=this.options.suppressEmptyNode?"/":`></${o}`,e},ge.prototype.buildTextValNode=function(o,e,t,i){if(!1!==this.options.cdataPropName&&e===this.options.cdataPropName)return this.indentate(i)+`<![CDATA[${o}]]>`+this.newLine;if(!1!==this.options.commentPropName&&e===this.options.commentPropName)return this.indentate(i)+`\x3c!--${o}--\x3e`+this.newLine;if("?"===e[0])return this.indentate(i)+"<"+e+t+"?"+this.tagEndChar;{let s=this.options.tagValueProcessor(e,o);return s=this.replaceEntitiesValue(s),""===s?this.indentate(i)+"<"+e+t+this.closeTag(e)+this.tagEndChar:this.indentate(i)+"<"+e+t+">"+s+"</"+e+this.tagEndChar}},ge.prototype.replaceEntitiesValue=function(o){if(o&&o.length>0&&this.options.processEntities)for(let e=0;e<this.options.entities.length;e++){const t=this.options.entities[e];o=o.replace(t.regex,t.val)}return o};class Ai{}w(Ai,"parser",new vs({allowBooleanAttributes:!0,attributeNamePrefix:"",ignoreAttributes:!1,ignoreDeclaration:!0,ignorePiTags:!0,numberParseOptions:{leadingZeros:!0,hex:!0},parseAttributeValue:!0,preserveOrder:!1,processEntities:!1,removeNSPrefix:!0,trimValues:!0})),w(Ai,"builder",new ge({attributeNamePrefix:"$",ignoreAttributes:!1,suppressBooleanAttributes:!1}));class Ft{static join(e){const t={};for(const i of e)for(const s in i)if(t[s])for(const n of i[s])t[s].add(n);else t[s]=new Set(i[s]);return t}static intersect(e){if(0===e.length)return{};let t=Ft.clone(e[0]);for(let i=1;i<e.length;i++){const s=e[i],n={};for(const r in t)if(s[r]){const a=new Set;for(const l of t[r])s[r].has(l)&&a.add(l);a.size>0&&(n[r]=a)}t=n}return t}static clone(e){const t={};for(const i in e)t[i]=new Set(e[i]);return t}static remove(e,t,i=!1){i&&(e=Ft.clone(e));for(const s in t)if(e[s]){for(const n of t[s])e[s].delete(n);0===e[s].size&&delete e[s]}}static add(e,t,i=!1){i&&(e=Ft.clone(e));for(const s in t)if(e[s])for(const n of t[s])e[s].add(n);else e[s]=new Set(t[s])}static append(e,t,...i){let s=e[t];s||(s=new Set,e[t]=s);for(const n of i)s.add(n)}static isEqual(e,t){const i=Object.keys(e),s=Object.keys(t);if(i.length!==s.length)return!1;for(const n of i){if(!t[n]||e[n].size!==t[n].size)return!1;for(const r of e[n])if(!t[n].has(r))return!1}return!0}static isEmpty(e){return 0===Object.values(e).reduce((i,s)=>i+s.size,0)}static toRaw(e){const t={};for(const i in e)t[i]=Array.from(e[i]);return t}static fromRaw(e){const t={};for(const i in e)t[i]=new Set(e[i]);return t}}Map;class ws{static isEntry(e){return new Set(["Boolean","Color","Text","Number","Select","Vector3","TextSet","None"]).has(e.type)}static copySchema(e,t={}){for(const i in e){const s=e[i];this.isEntry(s)?t[i]=this.copyEntry(s):(t[i]={},this.copySchema(s,t[i]))}return t}static copyEntry(e){if("Boolean"===e.type)return{type:e.type,value:e.value};if("Color"===e.type)return{type:e.type,value:e.value.clone()};if("Text"===e.type)return{type:e.type,value:e.value};if("Number"===e.type)return{type:e.type,value:e.value,min:e.min,max:e.max,interpolable:e.interpolable};if("Select"===e.type)return{type:e.type,value:e.value,multiple:e.multiple,options:new Set(e.options)};if("Vector3"===e.type)return{type:e.type,value:e.value.clone()};if("TextSet"===e.type)return{type:e.type,value:new Set(e.value)};if("None"===e.type)return{type:e.type,value:e.value};throw new Error("Invalid entry!")}}class ii{constructor(e,t,i,s){w(this,"_component"),w(this,"name"),w(this,"uuid"),this._component=e,this.name=i,this.uuid=s??Yt.create(),t.get(Pi).list.set(this.uuid,this)}get controls(){return ws.copySchema(this._config)}set(e){for(const t in e)t in this&&(this[t]=e[t].value)}export(e=this._config,t={}){for(const i in e){const s=e[i];if(ws.isEntry(s))if("Color"===s.type){const{r,g:a,b:l}=s.value;t[i]={...s,value:{r,g:a,b:l}}}else if("Vector3"===s.type){const{x:r,y:a,z:l}=s.value;t[i]={...s,value:{x:r,y:a,z:l}}}else if("TextSet"===s.type){const r=Array.from(s.value);t[i]={...s,value:r}}else if("Select"===s.type){const r=Array.from(s.options);t[i]={...s,options:r}}else t[i]={...s};else t[i]={},this.export(s,t[i])}return t}import(e,t={},i=!0){for(const s in e){const n=e[s];if(ws.isEntry(n))if("Color"===n.type){const{r:a,g:l,b:c}=n.value;t[s]={...n,value:new b.Q1f(a,l,c)}}else if("Vector3"===n.type){const{x:a,y:l,z:c}=n.value;t[s]={...n,value:new b.Pq0(a,l,c)}}else t[s]="TextSet"===n.type?{...n,value:new Set(n.value)}:"Select"===n.type?{...n,options:new Set(n.options)}:{...n};else t[s]={},this.import(n,t[s],!1)}i&&this.set(t)}}const jn=class co extends Tt{constructor(e){super(e),w(this,"list",new ft.jp),w(this,"enabled",!0),e.add(co.uuid,this)}};w(jn,"uuid","b8c764e0-6b24-4e77-9a32-35fa728ee5b4");let Pi=jn;class Hn{constructor(e){w(this,"_event"),w(this,"_position",new b.I9Y),w(this,"onDisposed",new X),w(this,"updateMouseInfo",t=>{this._event=t}),this.dom=e,this.setupEvents(!0)}get position(){return this.updatePosition(!1),this._position.clone()}get rawPosition(){return this.updatePosition(!0),this._position.clone()}dispose(){this.setupEvents(!1),this.onDisposed.trigger(),this.onDisposed.reset()}updatePosition(e){if(this._event){const t=this.dom.getBoundingClientRect();this._position.x=this.getPositionX(t,this._event,e),this._position.y=this.getPositionY(t,this._event,e)}}getPositionY(e,t,i){const s=this.getDataObject(t);return i?s.clientY:-(s.clientY-e.top)/(e.bottom-e.top)*2+1}getPositionX(e,t,i){const s=this.getDataObject(t);return i?s.clientX:(s.clientX-e.left)/(e.right-e.left)*2-1}getDataObject(e){return e instanceof MouseEvent?e:e.touches[0]}setupEvents(e){e?(this.dom.addEventListener("pointermove",this.updateMouseInfo),this.dom.addEventListener("touchstart",this.updateMouseInfo)):(this.dom.removeEventListener("pointermove",this.updateMouseInfo),this.dom.removeEventListener("touchstart",this.updateMouseInfo))}}const Yn=class ho extends Tt{constructor(e){super(e),w(this,"onDisposed",new X),w(this,"onBeforeDispose",new X),w(this,"onFragmentsLoaded",new X),w(this,"baseCoordinationModel",""),w(this,"baseCoordinationMatrix",new b.kn4),w(this,"enabled",!0),w(this,"_core"),this.components.add(ho.uuid,this)}get initialized(){return!!this._core}get list(){return this.core.models.list}get core(){if(!this._core)throw new Error("FragmentsManager not initialized. Call init() first.");return this._core}get _hasCoordinationModel(){return""!==this.baseCoordinationModel}dispose(){this.onBeforeDispose.trigger(),this._core&&(this.core.dispose(),this._core=void 0),this.baseCoordinationModel="",this.onFragmentsLoaded.reset(),this.onDisposed.trigger(),this.onDisposed.reset()}init(e,t){var i=this;this._core=new ft._i(e,t),this.core.onModelLoaded.add((0,H.A)(function*(){if(i._hasCoordinationModel)return;const s=[...i.list.values()][0];s&&(i.baseCoordinationModel=s.modelId,i.baseCoordinationMatrix=yield s.getCoordinationMatrix())})),this.list.onItemDeleted.add(()=>{this.list.size>0||(this.baseCoordinationModel="",this.baseCoordinationMatrix=new b.kn4)})}raycast(e){var t=this;return(0,H.A)(function*(){const i=[];for(const r of t.core.models.list.values())if(e.snappingClasses&&e.snappingClasses.length>0){const a=yield r.raycastWithSnapping(e);if(a&&a.length>0)i.push(a[0]);else{const l=yield r.raycast(e);l&&i.push(l)}}else{const a=yield r.raycast(e);a&&i.push(a)}if(yield Promise.all(i),0===i.length)return;let s=i[0],n=s.distance;for(let r=1;r<i.length;r++)i[r].distance<n&&(n=i[r].distance,s=i[r]);return s})()}getPositions(e){var t=this;return(0,H.A)(function*(){const i=[],s=function(){var r=(0,H.A)(function*(a,l){const c=yield a.getPositions(l);for(const h of c)i.push(h)});return function(l,c){return r.apply(this,arguments)}}(),n=[];for(const r in e){const a=t.core.models.list.get(r);a&&n.push(s(a,Array.from(e[r])))}return yield Promise.all(n),i})()}getBBoxes(e){var t=this;return(0,H.A)(function*(){const i=[],s=function(){var r=(0,H.A)(function*(a,l){const c=yield a.getBoxes(l);if(c)for(const h of c)i.push(h)});return function(l,c){return r.apply(this,arguments)}}(),n=[];for(const r in e){const a=t.core.models.list.get(r);a&&n.push(s(a,Array.from(e[r])))}return yield Promise.all(n),i})()}highlight(e,t){var i=this;return(0,H.A)(function*(){yield i.forEachModel(t,"highlight",e)})()}getData(e,t){var i=this;return(0,H.A)(function*(){const s={};for(const[n,r]of Object.entries(e)){const a=i.list.get(n);if(!a)continue;if(0===r.size){s[n]=[];continue}const l=yield a.getItemsData([...r],t);s[n]=l}return s})()}resetHighlight(e){var t=this;return(0,H.A)(function*(){yield t.forEachModel(e,"resetHighlight")})()}forEachModel(e,t,...i){var s=this;return(0,H.A)(function*(){const n={};if(e)for(const a in e)n[a]=Array.from(e[a]);else for(const a of s.core.models.list.keys())n[a]=void 0;const r=[];for(const a in n){const l=s.core.models.list.get(a);if(l){const h=l[t](n[a],...i);r.push(h)}}yield Promise.all(r)})()}guidsToModelIdMap(e){var t=this;return(0,H.A)(function*(){const i={};for(const[s,n]of t.list){const r=(yield n.getLocalIdsByGuids([...e])).filter(a=>null!==a);i[s]=new Set(r)}return i})()}modelIdMapToGuids(e){var t=this;return(0,H.A)(function*(){const i=[];for(const[s,n]of Object.entries(e)){const r=t.list.get(s);if(!r)continue;const a=(yield r.getGuidsByLocalIds([...n])).filter(l=>null!==l);i.push(...a)}return i})()}applyBaseCoordinateSystem(e,t){const i=new b.kn4;return t&&i.copy(t.clone()).invert(),i.multiply(this.baseCoordinationMatrix),e.applyMatrix4(i),i}};w(Yn,"uuid","fef46874-46a3-461b-8c44-2922ab77c806");let ct=Yn;class Sa{constructor(){w(this,"wasm",{path:"",absolute:!1,logLevel:os.LogLevel.LOG_LEVEL_OFF}),w(this,"webIfc",{COORDINATE_TO_ORIGIN:!0}),w(this,"autoSetWasm",!0),w(this,"customLocateFileHandler",null)}}w(class mn extends Tt{constructor(e){super(e),w(this,"onDisposed",new X),w(this,"onIfcStartedLoading",new X),w(this,"onIfcImporterInitialized",new X),w(this,"onSetup",new X),w(this,"settings",new Sa),w(this,"webIfc",new os.IfcAPI),w(this,"enabled",!0),this.components.add(mn.uuid,this)}dispose(){this.webIfc=null,this.onDisposed.trigger(mn.uuid),this.onDisposed.reset()}setup(e){var t=this;return(0,H.A)(function*(){t.settings={...t.settings,...e},t.settings.autoSetWasm&&(yield t.autoSetWasm()),t.onSetup.trigger()})()}load(e,t,i,s){var n=this;return(0,H.A)(function*(){const r=n.components.get(ct);if(!r.initialized)throw new Error("You need to initialize fragments first.");n.settings.autoSetWasm&&(yield n.autoSetWasm()),r.core.settings.autoCoordinate=t;const a=new ft.$X;a.wasm.path=n.settings.wasm.path,a.wasm.absolute=n.settings.wasm.absolute,a.webIfcSettings=n.settings.webIfc,n.onIfcImporterInitialized.trigger(a),s?.instanceCallback&&s.instanceCallback(a);const l=yield a.process({...s?.processData,bytes:e});return yield r.core.load(l,{modelId:i,userData:s?.userData})})()}readIfcFile(e){var t=this;return(0,H.A)(function*(){const{path:i,absolute:s,logLevel:n}=t.settings.wasm;return t.webIfc.SetWasmPath(i,s),yield t.webIfc.Init(t.settings.customLocateFileHandler||void 0),n&&t.webIfc.SetLogLevel(n),t.webIfc.OpenModel(e,t.settings.webIfc)})()}cleanUp(){try{this.webIfc.Dispose()}catch{console.log("Web-ifc wasn't disposed.")}this.webIfc=null,this.webIfc=new os.IfcAPI}autoSetWasm(){var e=this;return(0,H.A)(function*(){const t=yield fetch(`https://unpkg.com/@thatopen/components@${js.release}/package.json`);if(!t.ok)return void console.warn("Couldn't get openbim-components package.json. Set wasm settings manually.");const i=yield t.json();"web-ifc"in i.peerDependencies?(e.settings.wasm.path=`https://unpkg.com/web-ifc@${i.peerDependencies["web-ifc"]}/`,e.settings.wasm.absolute=!0):console.warn("Couldn't get web-ifc from peer dependencies in openbim-components. Set wasm settings manually.")})()}},"uuid","a659add7-1418-4771-a0d6-7d4d438e4624");const Zn=class uo extends Tt{constructor(e){super(e),w(this,"enabled",!0),this.components.add(uo.uuid,this)}set(e,t){var i=this;return(0,H.A)(function*(){const s=i.components.get(ct),n=[];if(t)for(const[r,a]of Object.entries(t)){const l=s.list.get(r);l&&n.push(l.setVisible([...a],e))}else for(const r of s.list.values())n.push(r.setVisible(void 0,e));yield Promise.all(n),yield s.core.update(!0)})()}isolate(e){var t=this;return(0,H.A)(function*(){yield Promise.all([t.set(!1),t.set(!0,e)])})()}toggle(e){var t=this;return(0,H.A)(function*(){const i=[],s=t.components.get(ct);for(const[n,r]of Object.entries(e)){const a=s.list.get(n);a&&i.push(a.toggleVisible([...r]))}yield Promise.all(i),yield s.core.update(!0)})()}getVisibilityMap(e,t){var i=this;return(0,H.A)(function*(){const s=[],n=[],r=i.components.get(ct);if(t)for(const c of t){const h=r.list.get(c);h&&(s.push(h.modelId),n.push(h.getItemsByVisibility(e)))}else for(const c of r.list.values())s.push(c.modelId),n.push(c.getItemsByVisibility(e));const a=yield Promise.all(n),l={};for(const[c,h]of s.entries())l[h]=a[c];return l})()}};w(Zn,"uuid","dd9ccf2d-8a21-4821-b7f6-2949add16a29");let Ia=Zn;const Wn=class gn extends Tt{constructor(e){super(e),w(this,"enabled",!0),w(this,"onDisposed",new X),w(this,"list",new ft.PG),this.components.add(gn.uuid,this)}dispose(e=!0){this.list.clear(),this.onDisposed.trigger(gn.uuid),e&&(this.onDisposed.reset(),this.list.eventsEnabled=!1,this.list.dispose())}get(){const e=new b.NRn;for(const t of this.list)e.union(t);return e}addFromModelIdMap(e){var t=this;return(0,H.A)(function*(){const i=t.components.get(ct),s=new b.NRn;for(const[n,r]of Object.entries(e)){const a=i.list.get(n);if(!a)continue;const l=yield a.getMergedBox([...r]);s.union(l)}t.list.add(s)})()}addFromModels(e){const t=this.components.get(ct);for(const[i,s]of t.list)e&&!e.some(n=>n.test(i))||this.list.add(s.box)}getCenter(e){var t=this;return(0,H.A)(function*(){t.list.clear(),yield t.addFromModelIdMap(e);const i=t.get();t.list.clear();const s=new b.Pq0;return i.getCenter(s),s})()}getCameraOrientation(e){var t=this;return(0,H.A)(function*(i,s=1){const n=t.components.get(ct);t.list.clear();for(const[u,f]of n.list)t.list.add(f.box);const r=t.get();t.list.clear();const a=new b.Pq0;r.getCenter(a);const l=new b.Pq0;r.getSize(l);const c=Math.max(l.x,l.y,l.z)*s,h=new b.Pq0;switch(i){case"front":default:h.set(a.x,a.y,a.z+c);break;case"back":h.set(a.x,a.y,a.z-c);break;case"left":h.set(a.x-c,a.y,a.z);break;case"right":h.set(a.x+c,a.y,a.z);break;case"top":h.set(a.x,a.y+c,a.z);break;case"bottom":h.set(a.x,a.y-c,a.z)}return{position:h,target:a}}).apply(this,arguments)}};w(Wn,"uuid","d1444724-dba6-4cdd-a0c7-68ee1450d166");let qn=Wn;class Ma{constructor(e,t){w(this,"name","Query"),w(this,"customData",{}),w(this,"_components"),w(this,"_queries",[]),w(this,"_aggregation","exclusive"),w(this,"result",null),w(this,"cache",!0),w(this,"serializeQueryParameters",i=>{var s;return{categories:null==(s=i.categories)?void 0:s.map(r=>r.source),attributes:i.attributes?{aggregation:i.attributes.aggregation,queries:i.attributes.queries.map(this.serializeAttributeQuery)}:void 0,relation:i.relation?{name:i.relation.name,query:i.relation.query?this.serializeQueryParameters(i.relation.query):void 0}:void 0}}),w(this,"deserializeQueryParameters",i=>{var s;return{categories:null==(s=i.categories)?void 0:s.map(r=>new RegExp(r)),attributes:i.attributes?{aggregation:i.attributes.aggregation,queries:i.attributes.queries.map(this.deserializeAttributeQuery)}:void 0,relation:i.relation?{name:i.relation.name,query:i.relation.query?this.deserializeQueryParameters(i.relation.query):void 0}:void 0}}),this._components=e,this.queries=t}set queries(e){this._queries=e,this.clearCache()}get queries(){return this._queries}set aggregation(e){e!==this._aggregation&&this.clearCache(),this._aggregation=e}get aggregation(){return this._aggregation}test(e){var t=this;return(0,H.A)(function*(){const{modelIds:i,force:s}={force:!1,...e};if(t.result&&!s)return t.result;const r=yield t._components.get(si).getItems(t.queries,{modelIds:i,aggregation:t.aggregation});return t.cache&&(t.result=r),r})()}clearCache(){this.result=null}serializeAttributeQuery(e){let t;return t=Array.isArray(e.value)?e.value.map(s=>s.source):e.value instanceof RegExp?e.value.source:e.value,{name:e.name.source,value:t,type:e.type instanceof RegExp?e.type.source:e.type,negate:e.negate,itemIds:e.itemIds}}toJSON(){return{guid:this._components.get(si).list.getKey(this)??Yt.create(),name:this.name,customData:this.customData,queries:this.queries.map(this.serializeQueryParameters),aggregation:this.aggregation,cache:this.cache}}deserializeAttributeQuery(e){let t;return t=Array.isArray(e.value)?e.value.map(s=>new RegExp(s)):"string"==typeof e.value?new RegExp(e.value):e.value,{name:new RegExp(e.name),value:t,type:e.type?new RegExp(e.type):void 0,negate:e.negate,itemIds:e.itemIds}}fromJSON(e){return this.name=e.name,this.customData=e.customData,this.aggregation=e.aggregation,this.cache=e.cache,this.queries=e.queries.map(this.deserializeQueryParameters),this}}const Gn=class fo extends Tt{constructor(e){super(e),w(this,"enabled",!0),w(this,"list",new ft.jp),e.add(fo.uuid,this)}getItems(e,t){var i=this;return(0,H.A)(function*(){let s;if(t){const{modelIds:c,items:h}=t;if(h){const u=Object.keys(h);u.length>0&&(s=u.map(f=>new RegExp(`^${f}$`)))}else c&&(s=c)}const n=t?.aggregation??"exclusive",r=i.components.get(ct),a=yield Promise.all(e.map(function(){var c=(0,H.A)(function*(h){const u={};return yield Promise.all(Array.from(r.list).map(function(){var f=(0,H.A)(function*([d,y]){var g;if(s&&!s.some(x=>x.test(d)))return;const _=null==(g=t?.items)?void 0:g[d],p=yield y.getItemsByQuery(h,{localIds:_?[..._]:void 0});u[d]=new Set(p)});return function(d){return f.apply(this,arguments)}}())),u});return function(h){return c.apply(this,arguments)}}()));return"inclusive"===n?Ft.join(a):Ft.intersect(a)})()}create(e,t){const i=new Ma(this.components,t);return this.list.set(e,i),i}addFromCategories(e){var t=this;return(0,H.A)(function*(){const i=new Set,s=t.components.get(ct);for(const[n,r]of s.list){if(e&&!e.some(c=>c.test(n)))continue;const a=(yield r.getItemsWithGeometryCategories()).filter(c=>null!==c),l=new Set(a);for(const c of l)t.list.has(c)||(t.create(c,[{categories:[new RegExp(`^${c}$`)]}]),i.add(c))}return[...i]})()}import(e){const{data:t}=e,i=[];if(!t)return i;for(const s of t){const n=this.create(s.guid,[]);n.fromJSON(s),i.push(n)}return i}export(){const e=[];for(const[t,i]of this.list.entries()){const n={...i.toJSON(),name:t};e.push(n)}return{data:e}}};w(Gn,"uuid","0da7ad77-f734-42ca-942f-a074adfd1e3a");let si=Gn;w(class po extends Tt{constructor(e){var t;super(e),t=this,w(this,"enabled",!0),w(this,"onDisposed",new X),w(this,"list",new ft.jp),w(this,"defaultSaveFunction",s=>"value"in s.Name?s.Name.value:null),w(this,"onBeforeFragmentsDispose",function(){var s=(0,H.A)(function*(n){const{key:r,value:a}=n,l=yield a.getLocalIds(),c={[r]:new Set(l)};t.removeItems(c)});return function(n){return s.apply(this,arguments)}}()),e.add(po.uuid,this),this.setupEvents(),e.get(ct).list.onBeforeDelete.add(this.onBeforeFragmentsDispose)}setupEvents(){this.list.onBeforeDelete.add(({value:e})=>e.dispose())}getClassificationGroups(e){let t=this.list.get(e);return t||(t=new ft.jp,this.list.set(e,t)),t}getModelItems(e,t,i){const{map:s}=this.getGroupData(e,t);let n=s[i];return n||(n=new Set,s[i]=n),n}getGroupData(e,t){const i=this.components.get(si),s=this.getClassificationGroups(e);let n=s.get(t);return n||(n={map:{},get:()=>new Promise(r=>{if(n)if(n.query){const{name:a,config:l}=n.query,c=i.list.get(a);if(!c)throw new Error("Classifier: the query name associated with the group doesn't exist in the ItemsFinder component");c.test(l).then(h=>{if(!n)return void r({});const u=Ft.join([h,n.map]);r(u)})}else r(n.map);else r({})})},s.set(t,n)),n}aggregateItems(e,t,i){var s=this;return(0,H.A)(function*(){const n=i?.data??void 0,r=i?.aggregationCallback??s.defaultSaveFunction,a=s.components.get(ct),c=yield s.components.get(si).getItems([t],{modelIds:i?.modelIds});for(const[h,u]of Object.entries(c)){const f=a.list.get(h);if(!f)continue;const d=(g,..._)=>{const p=s.getModelItems(e,g,h);for(const x of _)p.add(x)},y=yield f.getItemsData([...u],n);for(const g of y)r(g,d)}})()}addGroupItems(e,t,i){const{map:s}=this.getGroupData(e,t);Ft.add(s,i)}setGroupQuery(e,t,i){this.getGroupData(e,t).query=i}find(e){var t=this;return(0,H.A)(function*(){const i=[];for(const[n,r]of Object.entries(e)){const a=[],l=t.list.get(n);if(!l)continue;for(const h of r){const u=l.get(h);if(!u)continue;const f=yield u.get();a.push(f)}const c=Ft.join(a);i.push(c)}return Ft.intersect(i)})()}aggregateItemRelations(e,t,i,s){var n=this;return(0,H.A)(function*(){const r=s?.attribute??"Name",a={relations:{[i]:{attributes:!0,relations:!1}}};yield n.aggregateItems(e,t,{modelIds:s?.modelIds,data:a,aggregationCallback:(l,c)=>{if(!l?.[r])return;const h=l[r];if(!("value"in h))return;const u=l[i];if(Array.isArray(u))for(const f of u)"value"in f._localId&&c(h.value,f._localId.value)}})})()}byIfcBuildingStorey(e){var t=this;return(0,H.A)(function*(){yield t.aggregateItemRelations(e?.classificationName??"Storeys",{categories:[/BUILDINGSTOREY/]},"ContainsElements",{modelIds:e?.modelIds})})()}byCategory(e){var t=this;return(0,H.A)(function*(){const s=yield t.components.get(si).addFromCategories(e?.modelIds);for(const n of s)t.setGroupQuery(e?.classificationName??"Categories",n,{name:n})})()}dispose(){this.list.clear(),this.components.get(ct).list.onBeforeDelete.remove(this.onBeforeFragmentsDispose),this.onDisposed.trigger()}removeItems(e,t){if(t&&t.classificationName){const i=this.list.get(t.classificationName);if(!i||t.groupName&&!i.get(t.groupName))return;for(const[,s]of i)Ft.remove(s.map,e);return}for(const[,i]of this.list.entries())for(const[,s]of i)Ft.remove(s.map,e)}byModel(e){var t=this;return(0,H.A)(function*(){const i=t.components.get(ct),s=e?.classificationName??"Models";for(const[n,r]of i.list){if(e&&e.modelIds&&!e.modelIds.some(c=>c.test(n)))continue;const a=yield r.getItemsIdsWithGeometry(),l={[n]:new Set(a)};t.getGroupData(s,n),t.addGroupItems(s,n,l)}})()}},"uuid","e25a7f3c-46c4-4a14-9d3d-5115f24ebeb7");class Oa{constructor(e,t){w(this,"enabled",!0),w(this,"components"),w(this,"onDisposed",new X),w(this,"mouse"),w(this,"world"),w(this,"debugMode",!1),w(this,"colorToModelId",new Map),w(this,"modelIdToColor",new Map),w(this,"renderTarget"),w(this,"renderTargetSize",new b.I9Y),w(this,"debugCanvas"),w(this,"debugContainer"),w(this,"colorMaterials",new Map),w(this,"originalMaterials",new Map),w(this,"originalLodColors",new Map),w(this,"colorsNeedUpdate",!0);const i=t.renderer;if(!i)throw new Error("A renderer is needed for the FastModelPicker to work!");this.world=t,this.mouse=new Hn(i.three.domElement),this.components=e,this.setupRenderTarget(),this.setupFragmentListeners()}setupFragmentListeners(){const e=this.components.get(ct);e.list.onItemSet.add(()=>{this.colorsNeedUpdate=!0}),e.list.onItemDeleted.add(()=>{this.colorsNeedUpdate=!0})}setupRenderTarget(){const t=this.world.renderer.three.getSize(new b.I9Y);this.renderTargetSize.copy(t),this.renderTarget=new b.nWS(t.x,t.y),this.renderTarget.texture.format=b.GWd,this.renderTarget.texture.type=b.OUM,this.debugMode&&this.setupDebugCanvas(),this.world.renderer.onResize.add(i=>{this.renderTargetSize.copy(i),this.renderTarget.setSize(i.x,i.y),this.debugCanvas&&(this.debugCanvas.width=i.x,this.debugCanvas.height=i.y)})}setupDebugCanvas(){if(this.debugCanvas)return;const e=this.world.renderer.three.getSize(new b.I9Y);this.debugContainer=document.createElement("div"),this.debugContainer.style.position="fixed",this.debugContainer.style.top="10px",this.debugContainer.style.right="10px",this.debugContainer.style.width="300px",this.debugContainer.style.height="300px",this.debugContainer.style.border="2px solid #fff",this.debugContainer.style.backgroundColor="#000",this.debugContainer.style.zIndex="10000",this.debugContainer.style.pointerEvents="none",this.debugCanvas=document.createElement("canvas"),this.debugCanvas.width=e.x,this.debugCanvas.height=e.y,this.debugCanvas.style.width="100%",this.debugCanvas.style.height="100%",this.debugCanvas.style.imageRendering="pixelated",this.debugContainer.appendChild(this.debugCanvas),document.body.appendChild(this.debugContainer)}generateColorForModel(e){let t=0;for(let a=0;a<e.length;a++)t=(t<<5)-t+e.charCodeAt(a),t&=t;let i=Math.abs(t)%16777215;return 0===i&&(i=1),new b.Q1f((i>>16&255||1)/255,(i>>8&255||1)/255,(255&i||1)/255)}colorToId(e){return Math.round(255*e.r)<<16|Math.round(255*e.g)<<8|Math.round(255*e.b)}assignColors(){const e=this.components.get(ct);if(e.initialized){if(!this.colorsNeedUpdate){const t=new Set(e.list.keys()),i=new Set(this.modelIdToColor.keys());(t.size!==i.size||[...t].some(s=>!i.has(s)))&&(this.colorsNeedUpdate=!0)}if(this.colorsNeedUpdate){this.colorToModelId.clear(),this.modelIdToColor.clear();for(const t of this.colorMaterials.values())t.dispose();this.colorMaterials.clear();for(const[t]of e.list){const i=this.generateColorForModel(t),s=this.colorToId(i);this.colorToModelId.set(s,t),this.modelIdToColor.set(t,i);const n=new b.V9B({color:i,depthTest:!0,depthWrite:!0});this.colorMaterials.set(t,n)}this.colorsNeedUpdate=!1}}}applyColorMaterials(){const e=this.components.get(ct);if(e.initialized)for(const[t,i]of e.list){const s=this.colorMaterials.get(t);s&&i.object.traverse(n=>{if(n instanceof b.eaF){if("isLODGeometry"in n.geometry){const a=n.material[0].uniforms.lodColor;return this.originalLodColors.has(a)||this.originalLodColors.set(a,a.value),void(a.value=s.color)}this.originalMaterials.has(n)||this.originalMaterials.set(n,n.material),n.material=s}})}}restoreOriginalMaterials(){for(const[e,t]of this.originalMaterials)e.material=t;for(const[e,t]of this.originalLodColors)e.value=t;this.originalMaterials.clear()}renderColorCoded(){if(!this.renderTarget||!this.world.renderer)throw new Error("Render target not initialized!");const e=this.world.renderer.three,t=this.world.scene.three,i=this.world.camera.three,s=e.getRenderTarget(),n=e.autoClear,r=new b.Q1f,a=e.getClearAlpha();e.getClearColor(r),this.applyColorMaterials(),e.setRenderTarget(this.renderTarget),e.autoClear=!0,e.setClearColor(0,1),e.clear(!0,!0,!1),e.render(t,i),e.setRenderTarget(s),e.autoClear=n,e.setClearColor(r,a),this.restoreOriginalMaterials(),this.debugMode&&this.debugCanvas&&this.updateDebugCanvas()}updateDebugCanvas(){if(!this.debugCanvas||!this.renderTarget||!this.world.renderer)return;const e=this.world.renderer.three,t=this.renderTargetSize,i=new Uint8Array(t.x*t.y*4);e.readRenderTargetPixels(this.renderTarget,0,0,t.x,t.y,i);const s=this.debugCanvas.getContext("2d");if(!s)return;const n=s.createImageData(t.x,t.y),r=4*t.x;for(let a=0;a<t.y;a++){const h=a*r,u=(t.y-1-a)*r;n.data.set(i.subarray(h,h+r),u)}s.putImageData(n,0,0)}getModelAt(e){var t=this;return(0,H.A)(function*(){if(!t.renderTarget||!t.world.renderer)throw new Error("Render target not initialized!");const i=t.components.get(ct);if(!i.initialized||0===i.list.size)return null;t.assignColors(),t.renderColorCoded();const s=e||t.mouse.position,n=t.renderTargetSize,r=Math.floor(.5*(s.x+1)*n.x),a=Math.floor(.5*(s.y+1)*(n.y-1)),l=Math.max(0,Math.min(n.x-1,r)),c=Math.max(0,Math.min(n.y-1,a)),h=t.world.renderer.three,u=new Uint8Array(4);return h.readRenderTargetPixels(t.renderTarget,l,c,1,1,u),t.colorToModelId.get(u[0]<<16|u[1]<<8|u[2])||null})()}setDebugMode(e){this.debugMode=e,e?this.setupDebugCanvas():this.removeDebugCanvas()}removeDebugCanvas(){this.debugContainer&&(this.debugContainer.remove(),this.debugContainer=void 0,this.debugCanvas=void 0)}dispose(){this.mouse.dispose(),this.removeDebugCanvas();for(const e of this.colorMaterials.values())e.dispose();this.colorMaterials.clear(),this.renderTarget&&this.renderTarget.dispose(),this.colorToModelId.clear(),this.modelIdToColor.clear(),this.originalMaterials.clear(),this.originalLodColors.clear(),this.onDisposed.trigger(),this.onDisposed.reset()}}const Xn=class mo extends Tt{constructor(e){super(e),w(this,"enabled",!0),w(this,"list",new Map),w(this,"onDisposed",new X),e.add(mo.uuid,this)}get(e){if(this.list.has(e.uuid))return this.list.get(e.uuid);const t=new Oa(this.components,e);return this.list.set(e.uuid,t),e.onDisposed.add(()=>{this.delete(e)}),t}delete(e){const t=this.list.get(e.uuid);t&&t.dispose(),this.list.delete(e.uuid)}dispose(){for(const[e,t]of this.list)t.dispose();this.list.clear(),this.onDisposed.trigger()}};w(Xn,"uuid","4a82430c-7ff2-49ea-9401-60807502dad6");let ka=Xn;class za{constructor(e,t){w(this,"enabled",!0),w(this,"components"),w(this,"onDisposed",new X),w(this,"mouse"),w(this,"three",new b.tBo),w(this,"world"),w(this,"useFastModelPicking",!1);const i=t.renderer;if(!i)throw new Error("A renderer is needed for the raycaster to work!");this.world=t,this.mouse=new Hn(i.three.domElement),this.components=e}dispose(){this.mouse.dispose(),this.onDisposed.trigger(),this.onDisposed.reset()}castRayToObjects(e=Array.from(this.world.meshes),t=this.mouse.position){if(!this.world)throw new Error("A world is needed to cast rays!");return this.three.setFromCamera(t,this.world.camera.three),this.intersect(e)}castRay(e){var t=this;return(0,H.A)(function*(){const i=e?.snappingClasses,s=e?.items??Array.from(t.world.meshes),n=e?.position??t.mouse.position;if(!t.world)throw new Error("A world is needed to cast rays!");const r=t.world.camera.three,a=t.components.get(ct),l=t.world.renderer.three.domElement,c=t.mouse.rawPosition;let h=null;if(a.initialized){if(t.useFastModelPicking){const y=yield t.components.get(ka).get(t.world).getModelAt(n);if(y){const g=a.list.get(y);if(g)if(i&&i.length>0){const _=yield g.raycastWithSnapping({camera:r,dom:l,mouse:c,snappingClasses:i});h=_&&_.length>0?_[0]:yield g.raycast({camera:r,dom:l,mouse:c})}else h=yield g.raycast({camera:r,dom:l,mouse:c})}}else h=yield a.raycast({camera:r,dom:l,mouse:c,snappingClasses:i});if(0===s.length)return h}t.three.setFromCamera(n,r);const u=t.intersect(s);return h?u&&u.distance<h.distance?u:h:u})()}castRayFromVector(e,t,i=Array.from(this.world.meshes)){return this.three.set(e,t),this.intersect(i)}intersect(e=Array.from(this.world.meshes)){const t=this.three.intersectObjects(e),i=this.filterClippingPlanes(t);return i.length>0?i[0]:null}filterClippingPlanes(e){if(!this.world.renderer)throw new Error("Renderer not found!");const t=this.world.renderer.three;if(!t.clippingPlanes)return e;const i=t.clippingPlanes;return e.length<=0||!i||i?.length<=0?e:e.filter(s=>i.every(n=>n.distanceToPoint(s.point)>0))}}const Qn=class go extends Tt{constructor(e){super(e),w(this,"enabled",!0),w(this,"list",new Map),w(this,"onDisposed",new X),e.add(go.uuid,this)}get(e){if(this.list.has(e.uuid))return this.list.get(e.uuid);const t=new za(this.components,e);return this.list.set(e.uuid,t),e.onDisposed.add(()=>{this.delete(e)}),t}delete(e){const t=this.list.get(e.uuid);t&&t.dispose(),this.list.delete(e.uuid)}dispose(){for(const[e,t]of this.list)t.dispose();this.list.clear(),this.onDisposed.trigger()}};w(Qn,"uuid","d5d8bdf0-db25-4952-b951-b643af207ace");let Si=Qn;class Fa extends fs{constructor(){var e;super(...arguments),e=this,w(this,"onCameraChanged",new X),w(this,"meshes",new Set),w(this,"onAfterUpdate",new X),w(this,"onBeforeUpdate",new X),w(this,"onDisposed",new X),w(this,"isDisposing",!1),w(this,"enabled",!0),w(this,"_dynamicAnchor",!1),w(this,"uuid",Yt.create()),w(this,"name"),w(this,"_scene"),w(this,"_camera"),w(this,"_renderer",null),w(this,"onPointerDown",function(){var t=(0,H.A)(function*(i){if(!e.camera.hasCameraControls())throw new Error("World: can't set dynamic anchor if the camera doesn't have controls.");const n=yield e.components.get(Si).get(e).castRay();n&&n.point&&0===i.button&&e.camera.controls.setOrbitPoint(n.point.x,n.point.y,n.point.z)});return function(i){return t.apply(this,arguments)}}()),w(this,"_defaultCamera")}set dynamicAnchor(e){var t;const i=null==(t=this.renderer)?void 0:t.three.domElement.parentElement;if(!i)throw new Error("World: the renderer must have a parentElement to set dynamic anchoring.");e?(this.camera.controls&&(this.camera.controls.minDistance=.01),i.addEventListener("pointerdown",this.onPointerDown)):i.removeEventListener("pointerdown",this.onPointerDown)}get dynamicAnchor(){return this._dynamicAnchor}get defaultCamera(){if(!this._defaultCamera)throw new Error("World: there is no default camera defined.");return this._defaultCamera}set defaultCamera(e){this._defaultCamera=e}get scene(){if(!this._scene)throw new Error("No scene initialized!");return this._scene}set scene(e){this._scene=e,e.worlds.set(this.uuid,this),e.currentWorld=this,e.onWorldChanged.trigger({world:this,action:"added"})}get camera(){if(!this._camera)throw new Error("No camera initialized!");return this._camera}set camera(e){this._camera||(this.defaultCamera=e),this._camera=e,e.currentWorld=this,this.onCameraChanged.trigger(e)}get renderer(){return this._renderer}set renderer(e){this._renderer=e,e&&(e.worlds.set(this.uuid,this),e.currentWorld=this,e.onWorldChanged.trigger({world:this,action:"added"}))}useDefaultCamera(){this.camera=this.defaultCamera}update(e){this.enabled&&(!this._scene||!this._camera||(this.scene.currentWorld=this,this.camera.currentWorld=this,this.renderer&&(this.renderer.currentWorld=this),this.onBeforeUpdate.trigger(),this.scene.isUpdateable()&&this.scene.update(e),this.camera.isUpdateable()&&this.camera.update(e),this.renderer&&this.renderer.update(e),this.onAfterUpdate.trigger()))}dispose(e=!0){if(this.enabled=!1,this.isDisposing=!0,this.scene.onWorldChanged.trigger({world:this,action:"removed"}),this.camera.onWorldChanged.trigger({world:this,action:"removed"}),this.renderer&&this.renderer.onWorldChanged.trigger({world:this,action:"removed"}),e){const i=this.components.get(Je);this.scene.dispose(),this.camera.isDisposeable()&&this.camera.dispose(),this.renderer&&this.renderer.dispose();for(const s of this.meshes)i.destroy(s);this.meshes.clear()}this._scene=null,this._camera=null,this._renderer=null,this.components.get(bs).list.delete(this.uuid),this.onDisposed.trigger(),this.onDisposed.reset()}}class Na{constructor(e,t){w(this,"_list"),w(this,"_scene"),this._list=e,this._scene=t}get color(){return this._list.directionalLight.color.value}set color(e){this._list.directionalLight.color.value=e;for(const[,t]of this._scene.directionalLights)t.color.copy(e)}get intensity(){return this._list.directionalLight.intensity.value}set intensity(e){this._list.directionalLight.intensity.value=e;for(const[,t]of this._scene.directionalLights)t.intensity=e}get position(){return this._list.directionalLight.position.value.clone()}set position(e){this._list.directionalLight.position.value=e;for(const[,t]of this._scene.directionalLights)t.position.copy(e)}}class Da{constructor(e,t){w(this,"_list"),w(this,"_scene"),this._list=e,this._scene=t}get color(){return this._list.ambientLight.color.value}set color(e){this._list.ambientLight.color.value=e;for(const[,t]of this._scene.ambientLights)t.color.copy(e)}get intensity(){return this._list.ambientLight.intensity.value}set intensity(e){this._list.ambientLight.intensity.value=e;for(const[,t]of this._scene.ambientLights)t.intensity=e}}class Ra extends ii{constructor(){super(...arguments),w(this,"_config",{backgroundColor:{value:new b.Q1f,type:"Color"},ambientLight:{color:{type:"Color",value:new b.Q1f},intensity:{type:"Number",interpolable:!0,min:0,max:10,value:2}},directionalLight:{color:{type:"Color",value:new b.Q1f},intensity:{type:"Number",interpolable:!0,min:0,max:10,value:2},position:{type:"Vector3",value:new b.Pq0}}}),w(this,"ambientLight",new Da(this._config,this._component)),w(this,"directionalLight",new Na(this._config,this._component))}get backgroundColor(){return this._config.backgroundColor.value}set backgroundColor(e){this._config.backgroundColor.value=e,this._component.three.background=e}}class Kn extends Oo{constructor(e){super(e),w(this,"onSetup",new X),w(this,"isSetup",!1),w(this,"three"),w(this,"config",new Ra(this,this.components,"Scene")),w(this,"_defaultConfig",{backgroundColor:new b.Q1f(2107698),directionalLight:{color:new b.Q1f("white"),intensity:1.5,position:new b.Pq0(5,10,3)},ambientLight:{color:new b.Q1f("white"),intensity:1}}),this.three=new b.Z58,this.three.background=new b.Q1f(2107698)}setup(e){const t={...this._defaultConfig,...e};this.config.backgroundColor=t.backgroundColor;const i=t.ambientLight;this.config.ambientLight.color=i.color,this.config.ambientLight.intensity=i.intensity;const s=t.directionalLight;this.config.directionalLight.color=s.color,this.config.directionalLight.intensity=s.intensity,this.config.directionalLight.position=s.position,this.deleteAllLights();const{color:n,intensity:r}=this.config.directionalLight,a=new b.ZyN(n,r);a.position.copy(s.position);const{color:l,intensity:c}=this.config.directionalLight,h=new b.$p8(l,c);this.three.add(a,h),this.directionalLights.set(a.uuid,a),this.ambientLights.set(h.uuid,h),this.isSetup=!0,this.onSetup.trigger()}dispose(){super.dispose(),this.components.get(Pi).list.delete(this.config.uuid)}}class ni extends Io{constructor(e){super(e),w(this,"onBeforeUpdate",new X),w(this,"onAfterUpdate",new X),w(this,"onAspectUpdated",new X),w(this,"onDisposed",new X),w(this,"three"),w(this,"_resizeObserver",null),w(this,"_allControls",new Map),w(this,"updateAspect",()=>{var t;if(this.currentWorld&&this.currentWorld.renderer){if(this.three instanceof b.qUd)return void this.onAspectUpdated.trigger();if(null!=(t=this.currentWorld.renderer)&&t.isResizeable()){const i=this.currentWorld.renderer.getSize();this.three.aspect=i.width/i.height,this.three.updateProjectionMatrix(),this.onAspectUpdated.trigger()}}}),this.three=this.setupCamera(),this.worlds.onItemSet.add(({value:t})=>{const i=this.newCameraControls();this.setupEvents(!0),this._allControls.set(t.uuid,i)}),this.worlds.onBeforeDelete.add(({value:t})=>{var i;const s=this._allControls.get(t.uuid);s&&(s.dispose(),this._allControls.delete(t.uuid)),null==(i=this._resizeObserver)||i.disconnect()})}get controls(){if(!this.currentWorld)throw new Error("This camera needs a world to work!");const e=this._allControls.get(this.currentWorld.uuid);if(!e)throw new Error("Controls not found!");return e}get enabled(){return null!==this.currentWorld&&this.controls.enabled}set enabled(e){null!==this.currentWorld&&(this.controls.enabled=e)}set currentWorld(e){super.currentWorld=e,e&&(this.worlds.get(e.uuid)||this.worlds.set(e.uuid,e))}get currentWorld(){return this._currentWorld}dispose(){this.setupEvents(!1),this.onAspectUpdated.reset(),this.onBeforeUpdate.reset(),this.onAfterUpdate.reset(),this.three.removeFromParent(),this.onDisposed.trigger(),this.onDisposed.reset();for(const[e,t]of this._allControls)t.dispose();this.worlds.clear()}fitToItems(e){var t=this;return(0,H.A)(function*(){const i=yield t.getItemsBounding(e);yield t.controls.fitToSphere(i,!0)})()}setOrbitToItems(e){var t=this;return(0,H.A)(function*(){const i=yield t.getItemsBounding(e);t.controls.setOrbitPoint(i.center.x,i.center.y,i.center.z)})()}update(e){this.enabled&&(this.onBeforeUpdate.trigger(this),this.controls.update(e),this.onAfterUpdate.trigger(this))}getItemsBounding(e){var t=this;return(0,H.A)(function*(){const i=t.components.get(ct),s=t.components.get(qn);s.list.clear();const n=new b.iyt;if(e)yield s.addFromModelIdMap(e);else for(const[,r]of i.list)s.list.add(r.box);return s.get().getBoundingSphere(n),s.list.clear(),n})()}setupCamera(){const e=window.innerWidth/window.innerHeight,t=new b.ubm(60,e,1,1e3);return t.position.set(50,50,50),t.lookAt(new b.Pq0(0,0,0)),t}newCameraControls(){if(!this.currentWorld)throw new Error("This camera needs a world to work!");if(!this.currentWorld.renderer)throw new Error("This camera needs a renderer to work!");Bt.install({THREE:ni.getSubsetOfThree()});const{domElement:e}=this.currentWorld.renderer.three,t=new Bt(this.three,e);return t.smoothTime=.2,t.dollyToCursor=!0,t.infinityDolly=!0,t.minDistance=6,t}setupEvents(e){if(this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=null),e){if(!this.currentWorld)throw new Error("This camera needs a world to work!");if(!this.currentWorld.renderer)throw new Error("This camera needs a renderer to work!");const{domElement:t}=this.currentWorld.renderer.three;this._resizeObserver=new ResizeObserver(this.updateAspect),this._resizeObserver.observe(t)}}static getSubsetOfThree(){return{MOUSE:b.kBv,Vector2:b.I9Y,Vector3:b.Pq0,Vector4:b.IUQ,Quaternion:b.PTz,Matrix4:b.kn4,Spherical:b.YHV,Box3:b.NRn,Sphere:b.iyt,Raycaster:b.tBo,MathUtils:b.cj9}}}const Jn=class _o extends Tt{constructor(e){super(e),w(this,"onAfterUpdate",new X),w(this,"onBeforeUpdate",new X),w(this,"onDisposed",new X),w(this,"list",new ft.jp),w(this,"enabled",!0),e.add(_o.uuid,this)}create(){const e=new Fa(this.components),t=e.uuid;if(this.list.has(t))throw new Error("There is already a world with this name!");return this.list.set(t,e),e}delete(e){if(!this.list.has(e.uuid))throw new Error("The provided world is not found in the list!");this.list.delete(e.uuid),e.dispose()}dispose(){this.enabled=!1;for(const[e,t]of this.list)t.dispose();this.list.clear(),this.onDisposed.trigger()}update(e){if(this.enabled)for(const[t,i]of this.list)i.update(e)}};w(Jn,"uuid","fdb61dc4-2ec1-4966-b83d-54ea795fad4a");let bs=Jn;class La extends ii{constructor(){super(...arguments),w(this,"_config",{visible:{value:!0,type:"Boolean"},color:{value:new b.Q1f,type:"Color"},primarySize:{type:"Number",interpolable:!0,value:1,min:0,max:1e3},secondarySize:{type:"Number",interpolable:!0,value:10,min:0,max:1e3},distance:{type:"Number",interpolable:!0,value:500,min:0,max:500}})}get visible(){return this._config.visible.value}set visible(e){this._config.visible.value=e,this._component.visible=e}get color(){return this._config.color.value}set color(e){this._config.color.value=e,this._component.material.uniforms.uColor.value=e,this._component.material.uniformsNeedUpdate=!0}get primarySize(){return this._config.primarySize.value}set primarySize(e){this._config.primarySize.value=e,this._component.material.uniforms.uSize1.value=e,this._component.material.uniformsNeedUpdate=!0}get secondarySize(){return this._config.secondarySize.value}set secondarySize(e){this._config.secondarySize.value=e,this._component.material.uniforms.uSize2.value=e,this._component.material.uniformsNeedUpdate=!0}get distance(){return this._config.distance.value}set distance(e){this._config.distance.value=e,this._component.material.uniforms.uDistance.value=e,this._component.material.uniformsNeedUpdate=!0}}class Va{constructor(e,t){w(this,"onDisposed",new X),w(this,"onSetup",new X),w(this,"isSetup",!1),w(this,"world"),w(this,"components"),w(this,"config"),w(this,"_defaultConfig",{visible:!0,color:new b.Q1f(12303291),primarySize:1,secondarySize:10,distance:500}),w(this,"three"),w(this,"_fade",3),w(this,"updateZoom",()=>{this.world.camera instanceof ni&&(this.material.uniforms.uZoom.value=this.world.camera.three.zoom)}),this.world=t;const{color:i,primarySize:s,secondarySize:n,distance:r}=this._defaultConfig;this.components=e,this.config=new La(this,this.components,"Grid");const a=new b.bdM(2,2,1,1),l=new b.BKk({side:b.$EB,uniforms:{uSize1:{value:s},uSize2:{value:n},uColor:{value:i},uDistance:{value:r},uFade:{value:this._fade},uZoom:{value:1}},transparent:!0,vertexShader:"\n \n varying vec3 worldPosition;\n \n uniform float uDistance;\n \n void main() {\n \n vec3 pos = position.xzy * uDistance;\n pos.xz += cameraPosition.xz;\n \n worldPosition = pos;\n \n gl_Position = projectionMatrix * modelViewMatrix * vec4(pos, 1.0);\n \n }\n ",fragmentShader:"\n \n varying vec3 worldPosition;\n \n uniform float uZoom;\n uniform float uFade;\n uniform float uSize1;\n uniform float uSize2;\n uniform vec3 uColor;\n uniform float uDistance;\n \n \n \n float getGrid(float size) {\n \n vec2 r = worldPosition.xz / size;\n \n \n vec2 grid = abs(fract(r - 0.5) - 0.5) / fwidth(r);\n float line = min(grid.x, grid.y);\n \n \n return 1.0 - min(line, 1.0);\n }\n \n void main() {\n \n \n float d = 1.0 - min(distance(cameraPosition.xz, worldPosition.xz) / uDistance, 1.0);\n \n float g1 = getGrid(uSize1);\n float g2 = getGrid(uSize2);\n \n // Ortho camera fades the grid away when zooming out\n float minZoom = step(0.2, uZoom);\n float zoomFactor = pow(min(uZoom, 1.), 2.) * minZoom;\n \n gl_FragColor = vec4(uColor.rgb, mix(g2, g1, g1) * pow(d, uFade));\n gl_FragColor.a = mix(0.5 * gl_FragColor.a, gl_FragColor.a, g2) * zoomFactor;\n \n if ( gl_FragColor.a <= 0.0 ) discard;\n \n \n }\n \n ",extensions:{derivatives:!0}});this.three=new b.eaF(a,l),this.three.frustumCulled=!1,t.scene.three.add(this.three),this.setupEvents(!0)}get visible(){return this.three.visible}set visible(e){this.three.visible=e,e?this.world.scene.three.add(this.three):this.three.removeFromParent()}get material(){return this.three.material}get fade(){return 3===this._fade}set fade(e){this._fade=e?3:0,this.material.uniforms.uFade.value=this._fade}setup(e){const t={...this._defaultConfig,...e};this.config.visible=!0,this.config.color=t.color,this.config.primarySize=t.primarySize,this.config.secondarySize=t.secondarySize,this.config.distance=t.distance,this.isSetup=!0,this.onSetup.trigger()}dispose(){this.setupEvents(!1),this.components.get(Pi).list.delete(this.config.uuid),this.components.get(Je).destroy(this.three),this.onDisposed.trigger(),this.onDisposed.reset(),this.world=null,this.components=null}setupEvents(e){if(this.world.isDisposing||!(this.world.camera instanceof ni))return;const t=this.world.camera.controls;e?t.addEventListener("update",this.updateZoom):t.removeEventListener("update",this.updateZoom)}}w(class yo extends Tt{constructor(e){super(e),w(this,"list",new Map),w(this,"onDisposed",new X),w(this,"enabled",!0),e.add(yo.uuid,this)}create(e){if(this.list.has(e.uuid))throw new Error("This world already has a grid!");const t=new Va(this.components,e);return this.list.set(e.uuid,t),e.onDisposed.add(()=>{this.delete(e)}),t}delete(e){const t=this.list.get(e.uuid);t&&t.dispose(),this.list.delete(e.uuid)}dispose(){for(const[e,t]of this.list)t.dispose();this.list.clear(),this.onDisposed.trigger(),this.onDisposed.reset()}},"uuid","d1e814d5-b81c-4452-87a2-f039375e0489");const Mi=65535,ja=Math.pow(2,-24),Cs=Symbol("SKIP_GENERATION");function Fe(o){return function Ha(o){return o.index?o.index.count:o.attributes.position.count}(o)/3}function sr(o){const e=Fe(o),t=o.drawRange,s=(t.start+t.count)/3,n=Math.max(0,t.start/3),r=Math.min(e,s)-n;return[{offset:Math.floor(n),count:Math.floor(r)}]}function nr(o){if(!o.groups||!o.groups.length)return sr(o);const e=[],t=new Set,i=o.drawRange,s=i.start/3,n=(i.start+i.count)/3;for(const a of o.groups){const c=(a.start+a.count)/3;t.add(Math.max(s,a.start/3)),t.add(Math.min(n,c))}const r=Array.from(t.values()).sort((a,l)=>a-l);for(let a=0;a<r.length-1;a++){const l=r[a],c=r[a+1];e.push({offset:Math.floor(l),count:Math.floor(c-l)})}return e}function It(o,e,t){return t.min.x=e[o],t.min.y=e[o+1],t.min.z=e[o+2],t.max.x=e[o+3],t.max.y=e[o+4],t.max.z=e[o+5],t}function rr(o){let e=-1,t=-1/0;for(let i=0;i<3;i++){const s=o[i+3]-o[i];s>t&&(t=s,e=i)}return e}function or(o,e){e.set(o)}function ar(o,e,t){let i,s;for(let n=0;n<3;n++){const r=n+3;i=o[n],s=e[n],t[n]=i<s?i:s,i=o[r],s=e[r],t[r]=i>s?i:s}}function Oi(o,e,t){for(let i=0;i<3;i++){const s=e[o+2*i],n=e[o+2*i+1],r=s-n,a=s+n;r<t[i]&&(t[i]=r),a>t[i+3]&&(t[i+3]=a)}}function ri(o){const e=o[3]-o[0],t=o[4]-o[1],i=o[5]-o[2];return 2*(e*t+t*i+i*e)}function Ts(o,e,t,i,s=null){let n=1/0,r=1/0,a=1/0,l=-1/0,c=-1/0,h=-1/0,u=1/0,f=1/0,d=1/0,y=-1/0,g=-1/0,_=-1/0;const p=null!==s;for(let x=6*e,E=6*(e+t);x<E;x+=6){const T=o[x+0],A=o[x+1],M=T-A,S=T+A;M<n&&(n=M),S>l&&(l=S),p&&T<u&&(u=T),p&&T>y&&(y=T);const z=o[x+2],O=o[x+3],N=z-O,Z=z+O;N<r&&(r=N),Z>c&&(c=Z),p&&z<f&&(f=z),p&&z>g&&(g=z);const P=o[x+4],F=o[x+5],v=P-F,R=P+F;v<a&&(a=v),R>h&&(h=R),p&&P<d&&(d=P),p&&P>_&&(_=P)}i[0]=n,i[1]=r,i[2]=a,i[3]=l,i[4]=c,i[5]=h,p&&(s[0]=u,s[1]=f,s[2]=d,s[3]=y,s[4]=g,s[5]=_)}const Qa=(o,e)=>o.candidate-e.candidate,_e=new Array(32).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),ki=new Float32Array(6);class zi{constructor(){}}function tl(o,e,t,i,s,n){let r=i,a=i+s-1;const l=n.pos,c=2*n.axis;for(;;){for(;r<=a&&t[6*r+c]<l;)r++;for(;r<=a&&t[6*a+c]>=l;)a--;if(!(r<a))return r;for(let h=0;h<3;h++){let u=e[3*r+h];e[3*r+h]=e[3*a+h],e[3*a+h]=u}for(let h=0;h<6;h++){let u=t[6*r+h];t[6*r+h]=t[6*a+h],t[6*a+h]=u}r++,a--}}function el(o,e,t,i,s,n){let r=i,a=i+s-1;const l=n.pos,c=2*n.axis;for(;;){for(;r<=a&&t[6*r+c]<l;)r++;for(;r<=a&&t[6*a+c]>=l;)a--;if(!(r<a))return r;{let h=o[r];o[r]=o[a],o[a]=h;for(let u=0;u<6;u++){let f=t[6*r+u];t[6*r+u]=t[6*a+u],t[6*a+u]=f}r++,a--}}}function nl(o,e){const t=o.geometry;e.indirect&&(o._indirectBuffer=function il(o,e){const t=(o.index?o.index.count:o.attributes.position.count)/3,i=t>65536,s=i?4:2,n=e?new SharedArrayBuffer(t*s):new ArrayBuffer(t*s),r=i?new Uint32Array(n):new Uint16Array(n);for(let a=0,l=r.length;a<l;a++)r[a]=a;return r}(t,e.useSharedArrayBuffer),function Wa(o){if(0===o.groups.length)return!1;const e=Fe(o),t=nr(o).sort((n,r)=>n.offset-r.offset),i=t[t.length-1];i.count=Math.min(e-i.offset,i.count);let s=0;return t.forEach(({count:n})=>s+=n),e!==s}(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.')),o._indirectBuffer||function Za(o,e){if(!o.index){const t=o.attributes.position.count,s=function Ya(o,e=ArrayBuffer){return o>65535?new Uint32Array(new e(4*o)):new Uint16Array(new e(2*o))}(t,e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer);o.setIndex(new b.THS(s,1));for(let n=0;n<t;n++)s[n]=n}}(t,e);const i=function sl(o,e){const t=o.geometry,i=t.index?t.index.array:null,s=e.maxDepth,n=e.verbose,r=e.maxLeafTris,a=e.strategy,l=e.onProgress,c=Fe(t),h=o._indirectBuffer;let u=!1;const f=new Float32Array(6),d=new Float32Array(6),y=function Xa(o,e){!function qa(o){o[0]=o[1]=o[2]=1/0,o[3]=o[4]=o[5]=-1/0}(e);const t=o.attributes.position,i=o.index?o.index.array:null,s=Fe(o),n=new Float32Array(6*s),r=t.normalized,a=t.array,l=t.offset||0;let c=3;t.isInterleavedBufferAttribute&&(c=t.data.stride);const h=["getX","getY","getZ"];for(let u=0;u<s;u++){const f=3*u,d=6*u;let y=f+0,g=f+1,_=f+2;i&&(y=i[y],g=i[g],_=i[_]),r||(y=y*c+l,g=g*c+l,_=_*c+l);for(let p=0;p<3;p++){let x,E,T;r?(x=t[h[p]](y),E=t[h[p]](g),T=t[h[p]](_)):(x=a[y+p],E=a[g+p],T=a[_+p]);let A=x;E<A&&(A=E),T<A&&(A=T);let M=x;E>M&&(M=E),T>M&&(M=T);const S=(M-A)/2,z=2*p;n[d+z+0]=A+S,n[d+z+1]=S+(Math.abs(A)+S)*ja,A<e[p]&&(e[p]=A),M>e[p+3]&&(e[p+3]=M)}}return n}(t,f),g=e.indirect?el:tl,_=[],p=e.indirect?sr(t):nr(t);if(1===p.length){const T=p[0],A=new zi;A.boundingData=f,function Ga(o,e,t,i){let s=1/0,n=1/0,r=1/0,a=-1/0,l=-1/0,c=-1/0;for(let h=6*e,u=6*(e+t);h<u;h+=6){const f=o[h+0];f<s&&(s=f),f>a&&(a=f);const d=o[h+2];d<n&&(n=d),d>l&&(l=d);const y=o[h+4];y<r&&(r=y),y>c&&(c=y)}i[0]=s,i[1]=n,i[2]=r,i[3]=a,i[4]=l,i[5]=c}(y,T.offset,T.count,d),E(A,T.offset,T.count,d),_.push(A)}else for(let T of p){const A=new zi;A.boundingData=new Float32Array(6),Ts(y,T.offset,T.count,A.boundingData,d),E(A,T.offset,T.count,d),_.push(A)}return _;function x(T){l&&l(T/c)}function E(T,A,M,S=null,z=0){if(!u&&z>=s&&(u=!0,n&&(console.warn(`MeshBVH: Max depth of ${s} reached when generating BVH. Consider increasing maxDepth.`),console.warn(t))),M<=r||z>=s)return x(A+M),T.offset=A,T.count=M,T;const O=function Ka(o,e,t,i,s,n){let r=-1,a=0;if(0===n)r=rr(e),-1!==r&&(a=(e[r]+e[r+3])/2);else if(1===n)r=rr(o),-1!==r&&(a=function Ja(o,e,t,i){let s=0;for(let n=e,r=e+t;n<r;n++)s+=o[6*n+2*i];return s/t}(t,i,s,r));else if(2===n){const l=ri(o);let c=1.25*s;const h=6*i,u=6*(i+s);for(let f=0;f<3;f++){const d=e[f],_=(e[f+3]-d)/32;if(s<8){const p=[..._e];p.length=s;let x=0;for(let T=h;T<u;T+=6,x++){const A=p[x];A.candidate=t[T+2*f],A.count=0;const{bounds:M,leftCacheBounds:S,rightCacheBounds:z}=A;for(let O=0;O<3;O++)z[O]=1/0,z[O+3]=-1/0,S[O]=1/0,S[O+3]=-1/0,M[O]=1/0,M[O+3]=-1/0;Oi(T,t,M)}p.sort(Qa);let E=s;for(let T=0;T<E;T++){const A=p[T];for(;T+1<E&&p[T+1].candidate===A.candidate;)p.splice(T+1,1),E--}for(let T=h;T<u;T+=6){const A=t[T+2*f];for(let M=0;M<E;M++){const S=p[M];A>=S.candidate?Oi(T,t,S.rightCacheBounds):(Oi(T,t,S.leftCacheBounds),S.count++)}}for(let T=0;T<E;T++){const A=p[T],M=A.count,S=s-A.count,O=A.rightCacheBounds;let N=0;0!==M&&(N=ri(A.leftCacheBounds)/l);let Z=0;0!==S&&(Z=ri(O)/l);const P=1+1.25*(N*M+Z*S);P<c&&(r=f,c=P,a=A.candidate)}}else{for(let E=0;E<32;E++){const T=_e[E];T.count=0,T.candidate=d+_+E*_;const A=T.bounds;for(let M=0;M<3;M++)A[M]=1/0,A[M+3]=-1/0}for(let E=h;E<u;E+=6){let M=~~((t[E+2*f]-d)/_);M>=32&&(M=31);const S=_e[M];S.count++,Oi(E,t,S.bounds)}const p=_e[31];or(p.bounds,p.rightCacheBounds);for(let E=30;E>=0;E--){const T=_e[E];ar(T.bounds,_e[E+1].rightCacheBounds,T.rightCacheBounds)}let x=0;for(let E=0;E<31;E++){const T=_e[E],A=T.count,M=T.bounds,z=_e[E+1].rightCacheBounds;0!==A&&(0===x?or(M,ki):ar(M,ki,ki)),x+=A;let O=0,N=0;0!==x&&(O=ri(ki)/l);const Z=s-x;0!==Z&&(N=ri(z)/l);const P=1+1.25*(O*x+N*Z);P<c&&(r=f,c=P,a=T.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${n} used.`);return{axis:r,pos:a}}(T.boundingData,S,y,A,M,a);if(-1===O.axis)return x(A+M),T.offset=A,T.count=M,T;const N=g(h,i,y,A,M,O);if(N===A||N===A+M)x(A+M),T.offset=A,T.count=M;else{T.splitAxis=O.axis;const Z=new zi,P=A,F=N-A;T.left=Z,Z.boundingData=new Float32Array(6),Ts(y,P,F,Z.boundingData,d),E(Z,P,F,d,z+1);const v=new zi,R=N,Q=M-F;T.right=v,v.boundingData=new Float32Array(6),Ts(y,R,Q,v.boundingData,d),E(v,R,Q,d,z+1)}return T}}(o,e);let s,n,r;const a=[],l=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;for(let u=0;u<i.length;u++){const f=i[u],y=new l(32*c(f));s=new Float32Array(y),n=new Uint32Array(y),r=new Uint16Array(y),h(0,f),a.push(y)}return void(o._roots=a);function c(u){return u.count?1:1+c(u.left)+c(u.right)}function h(u,f){const d=u/4,y=u/2,g=!!f.count,_=f.boundingData;for(let p=0;p<6;p++)s[d+p]=_[p];if(g){const x=f.count;return n[d+6]=f.offset,r[y+14]=x,r[y+15]=Mi,u+32}{const x=f.right,E=f.splitAxis;let T;if(T=h(u+32,f.left),T/4>Math.pow(2,32))throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return n[d+6]=T/4,T=h(T,x),n[d+7]=E,T}}}class ue{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let i=1/0,s=-1/0;for(let n=0,r=e.length;n<r;n++){const l=e[n][t];i=l<i?l:i,s=l>s?l:s}this.min=i,this.max=s}setFromPoints(e,t){let i=1/0,s=-1/0;for(let n=0,r=t.length;n<r;n++){const l=e.dot(t[n]);i=l<i?l:i,s=l>s?l:s}this.min=i,this.max=s}isSeparated(e){return this.min>e.max||e.min>this.max}}ue.prototype.setFromBox=function(){const o=new b.Pq0;return function(t,i){const s=i.min,n=i.max;let r=1/0,a=-1/0;for(let l=0;l<=1;l++)for(let c=0;c<=1;c++)for(let h=0;h<=1;h++){o.x=s.x*l+n.x*(1-l),o.y=s.y*c+n.y*(1-c),o.z=s.z*h+n.z*(1-h);const u=t.dot(o);r=Math.min(u,r),a=Math.max(u,a)}this.min=r,this.max=a}}();const rl=function(){const o=new b.Pq0,e=new b.Pq0,t=new b.Pq0;return function(s,n,r){const l=o,h=e;t.subVectors(s.start,n.start),o.subVectors(s.end,s.start),e.subVectors(n.end,n.start);const u=t.dot(h),f=h.dot(l),d=h.dot(h),y=t.dot(l),_=l.dot(l)*d-f*f;let p,x;p=0!==_?(u*f-y*d)/_:0,x=(u+p*f)/d,r.x=p,r.y=x}}(),Es=function(){const o=new b.I9Y,e=new b.Pq0,t=new b.Pq0;return function(s,n,r,a){rl(s,n,o);let l=o.x,c=o.y;if(l>=0&&l<=1&&c>=0&&c<=1)return s.at(l,r),void n.at(c,a);if(l>=0&&l<=1)return n.at(c<0?0:1,a),void s.closestPointToPoint(a,!0,r);if(c>=0&&c<=1)return s.at(l<0?0:1,r),void n.closestPointToPoint(r,!0,a);{let h,u;h=l<0?s.start:s.end,u=c<0?n.start:n.end;const f=e,d=t;return s.closestPointToPoint(u,!0,e),n.closestPointToPoint(h,!0,t),f.distanceToSquared(u)<=d.distanceToSquared(h)?(r.copy(f),void a.copy(u)):(r.copy(h),void a.copy(d))}}}(),ol=function(){const o=new b.Pq0,e=new b.Pq0,t=new b.Zcv,i=new b.cZY;return function(n,r){const{radius:a,center:l}=n,{a:c,b:h,c:u}=r;if(i.start=c,i.end=h,i.closestPointToPoint(l,!0,o).distanceTo(l)<=a||(i.start=c,i.end=u,i.closestPointToPoint(l,!0,o).distanceTo(l)<=a)||(i.start=h,i.end=u,i.closestPointToPoint(l,!0,o).distanceTo(l)<=a))return!0;const g=r.getPlane(t);if(Math.abs(g.distanceToPoint(l))<=a){const p=g.projectPoint(l,e);if(r.containsPoint(p))return!0}return!1}}();function As(o){return Math.abs(o)<1e-15}class se extends b.lMl{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new b.Pq0),this.satBounds=new Array(4).fill().map(()=>new ue),this.points=[this.a,this.b,this.c],this.sphere=new b.iyt,this.plane=new b.Zcv,this.needsUpdate=!0}intersectsSphere(e){return ol(e,this)}update(){const e=this.a,t=this.b,i=this.c,s=this.points,n=this.satAxes,r=this.satBounds,a=n[0],l=r[0];this.getNormal(a),l.setFromPoints(a,s);const c=n[1],h=r[1];c.subVectors(e,t),h.setFromPoints(c,s);const u=n[2],f=r[2];u.subVectors(t,i),f.setFromPoints(u,s);const d=n[3],y=r[3];d.subVectors(i,e),y.setFromPoints(d,s),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(a,e),this.needsUpdate=!1}}se.prototype.closestPointToSegment=function(){const o=new b.Pq0,e=new b.Pq0,t=new b.cZY;return function(s,n=null,r=null){const{start:a,end:l}=s,c=this.points;let h,u=1/0;for(let f=0;f<3;f++){const d=(f+1)%3;t.start.copy(c[f]),t.end.copy(c[d]),Es(t,s,o,e),h=o.distanceToSquared(e),h<u&&(u=h,n&&n.copy(o),r&&r.copy(e))}return this.closestPointToPoint(a,o),h=a.distanceToSquared(o),h<u&&(u=h,n&&n.copy(o),r&&r.copy(a)),this.closestPointToPoint(l,o),h=l.distanceToSquared(o),h<u&&(u=h,n&&n.copy(o),r&&r.copy(l)),Math.sqrt(u)}}(),se.prototype.intersectsTriangle=function(){const o=new se,e=new Array(3),t=new Array(3),i=new ue,s=new ue,n=new b.Pq0,r=new b.Pq0,a=new b.Pq0,l=new b.Pq0,c=new b.Pq0,h=new b.cZY,u=new b.cZY,f=new b.cZY,d=new b.Pq0;function y(g,_,p){const x=g.points;let E=0,T=-1;for(let A=0;A<3;A++){const{start:M,end:S}=h;M.copy(x[A]),S.copy(x[(A+1)%3]),h.delta(r);const z=As(_.distanceToPoint(M));if(As(_.normal.dot(r))&&z){p.copy(h),E=2;break}const O=_.intersectLine(h,d);if(!O&&z&&d.copy(M),(O||z)&&!As(d.distanceTo(S))){if(E<=1)(1===E?p.start:p.end).copy(d),z&&(T=E);else if(E>=2){(1===T?p.start:p.end).copy(d),E=2;break}if(E++,2===E&&-1===T)break}}return E}return function(_,p=null,x=!1){this.needsUpdate&&this.update(),_.isExtendedTriangle?_.needsUpdate&&_.update():(o.copy(_),o.update(),_=o);const E=this.plane,T=_.plane;if(Math.abs(E.normal.dot(T.normal))>1-1e-10){const A=this.satBounds,M=this.satAxes;t[0]=_.a,t[1]=_.b,t[2]=_.c;for(let O=0;O<4;O++){const N=A[O];if(i.setFromPoints(M[O],t),N.isSeparated(i))return!1}const S=_.satBounds,z=_.satAxes;e[0]=this.a,e[1]=this.b,e[2]=this.c;for(let O=0;O<4;O++){const N=S[O];if(i.setFromPoints(z[O],e),N.isSeparated(i))return!1}for(let O=0;O<4;O++){const N=M[O];for(let Z=0;Z<4;Z++)if(n.crossVectors(N,z[Z]),i.setFromPoints(n,e),s.setFromPoints(n,t),i.isSeparated(s))return!1}return p&&(x||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),p.start.set(0,0,0),p.end.set(0,0,0)),!0}{const A=y(this,T,u);if(1===A&&_.containsPoint(u.end))return p&&(p.start.copy(u.end),p.end.copy(u.end)),!0;if(2!==A)return!1;const M=y(_,E,f);if(1===M&&this.containsPoint(f.end))return p&&(p.start.copy(f.end),p.end.copy(f.end)),!0;if(2!==M)return!1;if(u.delta(a),f.delta(l),a.dot(l)<0){let F=f.start;f.start=f.end,f.end=F}const S=u.start.dot(a),z=u.end.dot(a),O=f.start.dot(a),N=f.end.dot(a);return(S===N||O===z||z<O!=S<N)&&(p&&(c.subVectors(u.start,f.start),c.dot(a)>0?p.start.copy(u.start):p.start.copy(f.start),c.subVectors(u.end,f.end),c.dot(a)<0?p.end.copy(u.end):p.end.copy(f.end)),!0)}}}(),se.prototype.distanceToPoint=function(){const o=new b.Pq0;return function(t){return this.closestPointToPoint(t,o),t.distanceTo(o)}}(),se.prototype.distanceToTriangle=function(){const o=new b.Pq0,e=new b.Pq0,t=["a","b","c"],i=new b.cZY,s=new b.cZY;return function(r,a=null,l=null){const c=a||l?i:null;if(this.intersectsTriangle(r,c))return(a||l)&&(a&&c.getCenter(a),l&&c.getCenter(l)),0;let h=1/0;for(let u=0;u<3;u++){let f;const d=t[u],y=r[d];this.closestPointToPoint(y,o),f=y.distanceToSquared(o),f<h&&(h=f,a&&a.copy(o),l&&l.copy(y));const g=this[d];r.closestPointToPoint(g,o),f=g.distanceToSquared(o),f<h&&(h=f,a&&a.copy(g),l&&l.copy(o))}for(let u=0;u<3;u++){i.set(this[t[u]],this[t[(u+1)%3]]);for(let y=0;y<3;y++){s.set(r[t[y]],r[t[(y+1)%3]]),Es(i,s,o,e);const p=o.distanceToSquared(e);p<h&&(h=p,a&&a.copy(o),l&&l.copy(e))}}return Math.sqrt(h)}}();class $t{constructor(e,t,i){this.isOrientedBox=!0,this.min=new b.Pq0,this.max=new b.Pq0,this.matrix=new b.kn4,this.invMatrix=new b.kn4,this.points=new Array(8).fill().map(()=>new b.Pq0),this.satAxes=new Array(3).fill().map(()=>new b.Pq0),this.satBounds=new Array(3).fill().map(()=>new ue),this.alignedSatBounds=new Array(3).fill().map(()=>new ue),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}}$t.prototype.update=function(){return function(){const e=this.matrix,t=this.min,i=this.max,s=this.points;for(let c=0;c<=1;c++)for(let h=0;h<=1;h++)for(let u=0;u<=1;u++){const d=s[1*c|2*h|4*u];d.x=c?i.x:t.x,d.y=h?i.y:t.y,d.z=u?i.z:t.z,d.applyMatrix4(e)}const n=this.satBounds,r=this.satAxes,a=s[0];for(let c=0;c<3;c++){const h=r[c],u=n[c];h.subVectors(a,s[1<<c]),u.setFromPoints(h,s)}const l=this.alignedSatBounds;l[0].setFromPointsField(s,"x"),l[1].setFromPointsField(s,"y"),l[2].setFromPointsField(s,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}(),$t.prototype.intersectsBox=function(){const o=new ue;return function(t){this.needsUpdate&&this.update();const i=t.min,s=t.max,n=this.satBounds,r=this.satAxes,a=this.alignedSatBounds;if(o.min=i.x,o.max=s.x,a[0].isSeparated(o)||(o.min=i.y,o.max=s.y,a[1].isSeparated(o))||(o.min=i.z,o.max=s.z,a[2].isSeparated(o)))return!1;for(let l=0;l<3;l++){const h=n[l];if(o.setFromBox(r[l],t),h.isSeparated(o))return!1}return!0}}(),$t.prototype.intersectsTriangle=function(){const o=new se,e=new Array(3),t=new ue,i=new ue,s=new b.Pq0;return function(r){this.needsUpdate&&this.update(),r.isExtendedTriangle?r.needsUpdate&&r.update():(o.copy(r),o.update(),r=o);const a=this.satBounds,l=this.satAxes;e[0]=r.a,e[1]=r.b,e[2]=r.c;for(let f=0;f<3;f++){const d=a[f];if(t.setFromPoints(l[f],e),d.isSeparated(t))return!1}const c=r.satBounds,h=r.satAxes,u=this.points;for(let f=0;f<3;f++){const d=c[f];if(t.setFromPoints(h[f],u),d.isSeparated(t))return!1}for(let f=0;f<3;f++){const d=l[f];for(let y=0;y<4;y++)if(s.crossVectors(d,h[y]),t.setFromPoints(s,e),i.setFromPoints(s,u),t.isSeparated(i))return!1}return!0}}(),$t.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}}(),$t.prototype.distanceToPoint=function(){const o=new b.Pq0;return function(t){return this.closestPointToPoint(t,o),t.distanceTo(o)}}(),$t.prototype.distanceToBox=function(){const o=["x","y","z"],e=new Array(12).fill().map(()=>new b.cZY),t=new Array(12).fill().map(()=>new b.cZY),i=new b.Pq0,s=new b.Pq0;return function(r,a=0,l=null,c=null){if(this.needsUpdate&&this.update(),this.intersectsBox(r))return(l||c)&&(r.getCenter(s),this.closestPointToPoint(s,i),r.closestPointToPoint(i,s),l&&l.copy(i),c&&c.copy(s)),0;const h=a*a,u=r.min,f=r.max,d=this.points;let y=1/0;for(let _=0;_<8;_++){const p=d[_];s.copy(p).clamp(u,f);const x=p.distanceToSquared(s);if(x<y&&(y=x,l&&l.copy(p),c&&c.copy(s),x<h))return Math.sqrt(x)}let g=0;for(let _=0;_<3;_++)for(let p=0;p<=1;p++)for(let x=0;x<=1;x++){const E=(_+1)%3,T=(_+2)%3;e[g].set(d[p<<E|x<<T],d[1<<_|p<<E|x<<T]);const N=o[_],Z=o[E],P=o[T],F=t[g],v=F.start,R=F.end;v[N]=u[N],v[Z]=p?u[Z]:f[Z],v[P]=x?u[P]:f[Z],R[N]=f[N],R[Z]=p?u[Z]:f[Z],R[P]=x?u[P]:f[Z],g++}for(let _=0;_<=1;_++)for(let p=0;p<=1;p++)for(let x=0;x<=1;x++){s.x=_?f.x:u.x,s.y=p?f.y:u.y,s.z=x?f.z:u.z,this.closestPointToPoint(s,i);const E=s.distanceToSquared(i);if(E<y&&(y=E,l&&l.copy(i),c&&c.copy(s),E<h))return Math.sqrt(E)}for(let _=0;_<12;_++){const p=e[_];for(let x=0;x<12;x++){Es(p,t[x],i,s);const T=i.distanceToSquared(s);if(T<y&&(y=T,l&&l.copy(i),c&&c.copy(s),T<h))return Math.sqrt(T)}}return Math.sqrt(y)}}();class Ps{constructor(e){this._getNewPrimitive=e,this._primitives=[]}getPrimitive(){const e=this._primitives;return 0===e.length?this._getNewPrimitive():e.pop()}releasePrimitive(e){this._primitives.push(e)}}class ll extends Ps{constructor(){super(()=>new se)}}const Xt=new ll;function qt(o,e){return 65535===e[o+15]}function Gt(o,e){return e[o+6]}function Qt(o,e){return e[o+14]}function Kt(o){return o+8}function Jt(o,e){return e[o+6]}function lr(o,e){return e[o+7]}const Et=new class cl{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,0!==e.length&&this.setBuffer(e.pop())}}};let ye,Ne;const De=[],Fi=new Ps(()=>new b.NRn);function hl(o,e,t,i,s,n){ye=Fi.getPrimitive(),Ne=Fi.getPrimitive(),De.push(ye,Ne),Et.setBuffer(o._roots[e]);const r=Ss(0,o.geometry,t,i,s,n);Et.clearBuffer(),Fi.releasePrimitive(ye),Fi.releasePrimitive(Ne),De.pop(),De.pop();const a=De.length;return a>0&&(Ne=De[a-1],ye=De[a-2]),r}function Ss(o,e,t,i,s=null,n=0,r=0){const{float32Array:a,uint16Array:l,uint32Array:c}=Et;let h=2*o;if(qt(h,l)){const f=Gt(o,c),d=Qt(h,l);return It(o,a,ye),i(f,d,!1,r,n+o,ye)}{let f=function(P){const{uint16Array:F,uint32Array:v}=Et;let R=2*P;for(;!qt(R,F);)R=2*(P=Kt(P));return Gt(P,v)},d=function(P){const{uint16Array:F,uint32Array:v}=Et;let R=2*P;for(;!qt(R,F);)R=2*(P=Jt(P,v));return Gt(P,v)+Qt(R,F)};const y=Kt(o),g=Jt(o,c);let x,E,T,A,_=y,p=g;if(s&&(T=ye,A=Ne,It(_,a,T),It(p,a,A),x=s(T),E=s(A),E<x)){_=g,p=y;const P=x;x=E,E=P,T=A}T||(T=ye,It(_,a,T));const S=t(T,qt(2*_,l),x,r+1,n+_);let z;if(2===S){const P=f(_);z=i(P,d(_)-P,!0,r+1,n+_,T)}else z=S&&Ss(_,e,t,i,s,n,r+1);if(z)return!0;A=Ne,It(p,a,A);const N=t(A,qt(2*p,l),E,r+1,n+p);let Z;if(2===N){const P=f(p);Z=i(P,d(p)-P,!0,r+1,n+p,A)}else Z=N&&Ss(p,e,t,i,s,n,r+1);return!!Z}}const oi=new b.Pq0,Is=new b.Pq0,Re=new b.Pq0,Be=new b.Pq0,Le=new b.Pq0,Ni=new b.I9Y,Di=new b.I9Y,Ri=new b.I9Y,cr=new b.Pq0,hr=new b.Pq0,ur=new b.Pq0,Bi=new b.Pq0;function Li(o,e,t,i,s){const n=3*i;let r=n+0,a=n+1,l=n+2;const c=o.index;o.index&&(r=c.getX(r),a=c.getX(a),l=c.getX(l));const{position:h,normal:u,uv:f,uv1:d}=o.attributes,y=function fl(o,e,t,i,s,n,r,a,l){Re.fromBufferAttribute(e,n),Be.fromBufferAttribute(e,r),Le.fromBufferAttribute(e,a);const c=function dl(o,e,t,i,s,n){let r;return r=n===b.hsX?o.intersectTriangle(i,t,e,!0,s):o.intersectTriangle(e,t,i,n!==b.$EB,s),null===r?null:{distance:o.origin.distanceTo(s),point:s.clone()}}(o,Re,Be,Le,Bi,l);if(c){i&&(Ni.fromBufferAttribute(i,n),Di.fromBufferAttribute(i,r),Ri.fromBufferAttribute(i,a),c.uv=b.lMl.getInterpolation(Bi,Re,Be,Le,Ni,Di,Ri,new b.I9Y)),s&&(Ni.fromBufferAttribute(s,n),Di.fromBufferAttribute(s,r),Ri.fromBufferAttribute(s,a),c.uv1=b.lMl.getInterpolation(Bi,Re,Be,Le,Ni,Di,Ri,new b.I9Y)),t&&(cr.fromBufferAttribute(t,n),hr.fromBufferAttribute(t,r),ur.fromBufferAttribute(t,a),c.normal=b.lMl.getInterpolation(Bi,Re,Be,Le,cr,hr,ur,new b.Pq0),c.normal.dot(o.direction)>0&&c.normal.multiplyScalar(-1));const h={a:n,b:r,c:a,normal:new b.Pq0,materialIndex:0};b.lMl.getNormal(Re,Be,Le,h.normal),c.face=h,c.faceIndex=n}return c}(t,h,u,f,d,r,a,l,e);return y?(y.faceIndex=i,s&&s.push(y),y):null}function Nt(o,e,t,i){const s=o.a,n=o.b,r=o.c;let a=e,l=e+1,c=e+2;t&&(a=t.getX(a),l=t.getX(l),c=t.getX(c)),s.x=i.getX(a),s.y=i.getY(a),s.z=i.getZ(a),n.x=i.getX(l),n.y=i.getY(l),n.z=i.getZ(l),r.x=i.getX(c),r.y=i.getY(c),r.z=i.getZ(c)}function gl(o,e,t,i,s,n,r){const{geometry:a}=t,{index:l}=a,c=a.attributes.position;for(let h=o,u=e+o;h<u;h++){let f;if(f=h,Nt(r,3*f,l,c),r.needsUpdate=!0,i(r,f,s,n))return!0}return!1}function _l(o,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=o.geometry,i=t.index?t.index.array:null,s=t.attributes.position;let n,r,a,l,c=0;const h=o._roots;for(let f=0,d=h.length;f<d;f++)n=h[f],r=new Uint32Array(n),a=new Uint16Array(n),l=new Float32Array(n),u(0,c),c+=n.byteLength;function u(f,d,y=!1){const g=2*f;if(a[g+15]===Mi){const p=r[f+6];let E=1/0,T=1/0,A=1/0,M=-1/0,S=-1/0,z=-1/0;for(let O=3*p,N=3*(p+a[g+14]);O<N;O++){let Z=i[O];const P=s.getX(Z),F=s.getY(Z),v=s.getZ(Z);P<E&&(E=P),P>M&&(M=P),F<T&&(T=F),F>S&&(S=F),v<A&&(A=v),v>z&&(z=v)}return(l[f+0]!==E||l[f+1]!==T||l[f+2]!==A||l[f+3]!==M||l[f+4]!==S||l[f+5]!==z)&&(l[f+0]=E,l[f+1]=T,l[f+2]=A,l[f+3]=M,l[f+4]=S,l[f+5]=z,!0)}{const p=f+8,x=r[f+6],T=x+d;let A=y,M=!1,S=!1;e?A||(M=e.has(p+d),S=e.has(T),A=!M&&!S):(M=!0,S=!0);const O=A||S;let N=!1;(A||M)&&(N=u(p,d,A));let Z=!1;O&&(Z=u(x,d,A));const P=N||Z;if(P)for(let F=0;F<3;F++){const v=p+F,R=x+F,Q=l[v],j=l[v+3],rt=l[R],Y=l[R+3];l[f+F]=Q<rt?Q:rt,l[f+F+3]=j>Y?j:Y}return P}}}const dr=new b.NRn;function ve(o,e,t,i){return It(o,e,dr),t.intersectBox(dr,i)}function wl(o,e,t,i,s,n,r){const{geometry:a}=t,{index:l}=a,c=a.attributes.position;for(let h=o,u=e+o;h<u;h++){let f;if(f=t.resolveTriangleIndex(h),Nt(r,3*f,l,c),r.needsUpdate=!0,i(r,f,s,n))return!0}return!1}const fr=new b.Pq0;function bl(o,e,t,i,s){Et.setBuffer(o._roots[e]),Ms(0,o,t,i,s),Et.clearBuffer()}function Ms(o,e,t,i,s){const{float32Array:n,uint16Array:r,uint32Array:a}=Et,l=2*o;if(qt(l,r))!function pl(o,e,t,i,s,n){const{geometry:r}=o;for(let l=i,c=i+s;l<c;l++)Li(r,e,t,l,n)}(e,t,i,Gt(o,a),Qt(l,r),s);else{const h=Kt(o);ve(h,n,i,fr)&&Ms(h,e,t,i,s);const u=Jt(o,a);ve(u,n,i,fr)&&Ms(u,e,t,i,s)}}const pr=new b.Pq0,xl=["x","y","z"];function Cl(o,e,t,i){Et.setBuffer(o._roots[e]);const s=Os(0,o,t,i);return Et.clearBuffer(),s}function Os(o,e,t,i){const{float32Array:s,uint16Array:n,uint32Array:r}=Et;let a=2*o;if(qt(a,n))return function ml(o,e,t,i,s){const{geometry:n}=o;let a=1/0,l=null;for(let c=i,h=i+s;c<h;c++){let u;u=Li(n,e,t,c),u&&u.distance<a&&(l=u,a=u.distance)}return l}(e,t,i,Gt(o,r),Qt(a,n));{const c=lr(o,r),h=xl[c],f=i.direction[h]>=0;let d,y;f?(d=Kt(o),y=Jt(o,r)):(d=Jt(o,r),y=Kt(o));const _=ve(d,s,i,pr)?Os(d,e,t,i):null;if(_){const E=_.point[h];if(f?E<=s[y+c]:E>=s[y+c+3])return _}const x=ve(y,s,i,pr)?Os(y,e,t,i):null;return _&&x?_.distance<=x.distance?_:x:_||x||null}}const Vi=new b.NRn,Ve=new se,Ue=new se,ai=new b.kn4,mr=new $t,Ui=new $t;function Tl(o,e,t,i){Et.setBuffer(o._roots[e]);const s=ks(0,o,t,i);return Et.clearBuffer(),s}function ks(o,e,t,i,s=null){const{float32Array:n,uint16Array:r,uint32Array:a}=Et;let l=2*o;if(null===s&&(t.boundingBox||t.computeBoundingBox(),mr.set(t.boundingBox.min,t.boundingBox.max,i),s=mr),!qt(l,r)){const h=o+8,u=a[o+6];return It(h,n,Vi),!!(s.intersectsBox(Vi)&&ks(h,e,t,i,s)||(It(u,n,Vi),s.intersectsBox(Vi)&&ks(u,e,t,i,s)))}{const h=e.geometry,u=h.index,f=h.attributes.position,d=t.index,y=t.attributes.position,g=Gt(o,a),_=Qt(l,r);if(ai.copy(i).invert(),t.boundsTree)return It(o,n,Ui),Ui.matrix.copy(ai),Ui.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:x=>Ui.intersectsBox(x),intersectsTriangle:x=>{x.a.applyMatrix4(i),x.b.applyMatrix4(i),x.c.applyMatrix4(i),x.needsUpdate=!0;for(let E=3*g,T=3*(_+g);E<T;E+=3)if(Nt(Ue,E,u,f),Ue.needsUpdate=!0,x.intersectsTriangle(Ue))return!0;return!1}});for(let p=3*g,x=3*(_+g);p<x;p+=3){Nt(Ve,p,u,f),Ve.a.applyMatrix4(ai),Ve.b.applyMatrix4(ai),Ve.c.applyMatrix4(ai),Ve.needsUpdate=!0;for(let E=0,T=d.count;E<T;E+=3)if(Nt(Ue,E,d,y),Ue.needsUpdate=!0,Ve.intersectsTriangle(Ue))return!0}}}const $i=new b.kn4,zs=new $t,li=new $t,El=new b.Pq0,Al=new b.Pq0,Pl=new b.Pq0,Sl=new b.Pq0;function Il(o,e,t,i={},s={},n=0,r=1/0){e.boundingBox||e.computeBoundingBox(),zs.set(e.boundingBox.min,e.boundingBox.max,t),zs.needsUpdate=!0;const a=o.geometry,l=a.attributes.position,c=a.index,h=e.attributes.position,u=e.index,f=Xt.getPrimitive(),d=Xt.getPrimitive();let y=El,g=Al,_=null,p=null;s&&(_=Pl,p=Sl);let x=1/0,E=null,T=null;return $i.copy(t).invert(),li.matrix.copy($i),o.shapecast({boundsTraverseOrder:A=>zs.distanceToBox(A),intersectsBounds:(A,M,S)=>S<x&&S<r&&(M&&(li.min.copy(A.min),li.max.copy(A.max),li.needsUpdate=!0),!0),intersectsRange:(A,M)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:z=>li.distanceToBox(z),intersectsBounds:(z,O,N)=>N<x&&N<r,intersectsRange:(z,O)=>{for(let N=z,Z=z+O;N<Z;N++){Nt(d,3*N,u,h),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let P=A,F=A+M;P<F;P++){Nt(f,3*P,c,l),f.needsUpdate=!0;const v=f.distanceToTriangle(d,y,_);if(v<x&&(g.copy(y),p&&p.copy(_),x=v,E=P,T=N),v<n)return!0}}}});for(let z=0,O=Fe(e);z<O;z++){Nt(d,3*z,u,h),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let N=A,Z=A+M;N<Z;N++){Nt(f,3*N,c,l),f.needsUpdate=!0;const P=f.distanceToTriangle(d,y,_);if(P<x&&(g.copy(y),p&&p.copy(_),x=P,E=N,T=z),P<n)return!0}}}}),Xt.releasePrimitive(f),Xt.releasePrimitive(d),x===1/0?null:(i.point?i.point.copy(g):i.point=g.clone(),i.distance=x,i.faceIndex=E,s&&(s.point?s.point.copy(p):s.point=p.clone(),s.point.applyMatrix4($i),g.applyMatrix4($i),s.distance=g.sub(s.point).length(),s.faceIndex=T),i)}function Ml(o,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=o.geometry,i=t.index?t.index.array:null,s=t.attributes.position;let n,r,a,l,c=0;const h=o._roots;for(let f=0,d=h.length;f<d;f++)n=h[f],r=new Uint32Array(n),a=new Uint16Array(n),l=new Float32Array(n),u(0,c),c+=n.byteLength;function u(f,d,y=!1){const g=2*f;if(a[g+15]===Mi){const p=r[f+6];let E=1/0,T=1/0,A=1/0,M=-1/0,S=-1/0,z=-1/0;for(let O=p,N=p+a[g+14];O<N;O++){const Z=3*o.resolveTriangleIndex(O);for(let P=0;P<3;P++){let F=Z+P;F=i?i[F]:F;const v=s.getX(F),R=s.getY(F),Q=s.getZ(F);v<E&&(E=v),v>M&&(M=v),R<T&&(T=R),R>S&&(S=R),Q<A&&(A=Q),Q>z&&(z=Q)}}return(l[f+0]!==E||l[f+1]!==T||l[f+2]!==A||l[f+3]!==M||l[f+4]!==S||l[f+5]!==z)&&(l[f+0]=E,l[f+1]=T,l[f+2]=A,l[f+3]=M,l[f+4]=S,l[f+5]=z,!0)}{const p=f+8,x=r[f+6],T=x+d;let A=y,M=!1,S=!1;e?A||(M=e.has(p+d),S=e.has(T),A=!M&&!S):(M=!0,S=!0);const O=A||S;let N=!1;(A||M)&&(N=u(p,d,A));let Z=!1;O&&(Z=u(x,d,A));const P=N||Z;if(P)for(let F=0;F<3;F++){const v=p+F,R=x+F,Q=l[v],j=l[v+3],rt=l[R],Y=l[R+3];l[f+F]=Q<rt?Q:rt,l[f+F+3]=j>Y?j:Y}return P}}}const gr=new b.Pq0;function Ol(o,e,t,i,s){Et.setBuffer(o._roots[e]),Fs(0,o,t,i,s),Et.clearBuffer()}function Fs(o,e,t,i,s){const{float32Array:n,uint16Array:r,uint32Array:a}=Et,l=2*o;if(qt(l,r))!function yl(o,e,t,i,s,n){const{geometry:r,_indirectBuffer:a}=o;for(let l=i,c=i+s;l<c;l++)Li(r,e,t,a?a[l]:l,n)}(e,t,i,Gt(o,a),Qt(l,r),s);else{const h=Kt(o);ve(h,n,i,gr)&&Fs(h,e,t,i,s);const u=Jt(o,a);ve(u,n,i,gr)&&Fs(u,e,t,i,s)}}const _r=new b.Pq0,kl=["x","y","z"];function zl(o,e,t,i){Et.setBuffer(o._roots[e]);const s=Ns(0,o,t,i);return Et.clearBuffer(),s}function Ns(o,e,t,i){const{float32Array:s,uint16Array:n,uint32Array:r}=Et;let a=2*o;if(qt(a,n))return function vl(o,e,t,i,s){const{geometry:n,_indirectBuffer:r}=o;let a=1/0,l=null;for(let c=i,h=i+s;c<h;c++){let u;u=Li(n,e,t,r?r[c]:c),u&&u.distance<a&&(l=u,a=u.distance)}return l}(e,t,i,Gt(o,r),Qt(a,n));{const c=lr(o,r),h=kl[c],f=i.direction[h]>=0;let d,y;f?(d=Kt(o),y=Jt(o,r)):(d=Jt(o,r),y=Kt(o));const _=ve(d,s,i,_r)?Ns(d,e,t,i):null;if(_){const E=_.point[h];if(f?E<=s[y+c]:E>=s[y+c+3])return _}const x=ve(y,s,i,_r)?Ns(y,e,t,i):null;return _&&x?_.distance<=x.distance?_:x:_||x||null}}const ji=new b.NRn,$e=new se,je=new se,ci=new b.kn4,yr=new $t,Hi=new $t;function Fl(o,e,t,i){Et.setBuffer(o._roots[e]);const s=Ds(0,o,t,i);return Et.clearBuffer(),s}function Ds(o,e,t,i,s=null){const{float32Array:n,uint16Array:r,uint32Array:a}=Et;let l=2*o;if(null===s&&(t.boundingBox||t.computeBoundingBox(),yr.set(t.boundingBox.min,t.boundingBox.max,i),s=yr),!qt(l,r)){const h=o+8,u=a[o+6];return It(h,n,ji),!!(s.intersectsBox(ji)&&Ds(h,e,t,i,s)||(It(u,n,ji),s.intersectsBox(ji)&&Ds(u,e,t,i,s)))}{const h=e.geometry,u=h.index,f=h.attributes.position,d=t.index,y=t.attributes.position,g=Gt(o,a),_=Qt(l,r);if(ci.copy(i).invert(),t.boundsTree)return It(o,n,Hi),Hi.matrix.copy(ci),Hi.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:x=>Hi.intersectsBox(x),intersectsTriangle:x=>{x.a.applyMatrix4(i),x.b.applyMatrix4(i),x.c.applyMatrix4(i),x.needsUpdate=!0;for(let E=g,T=_+g;E<T;E++)if(Nt(je,3*e.resolveTriangleIndex(E),u,f),je.needsUpdate=!0,x.intersectsTriangle(je))return!0;return!1}});for(let p=g,x=_+g;p<x;p++){const E=e.resolveTriangleIndex(p);Nt($e,3*E,u,f),$e.a.applyMatrix4(ci),$e.b.applyMatrix4(ci),$e.c.applyMatrix4(ci),$e.needsUpdate=!0;for(let T=0,A=d.count;T<A;T+=3)if(Nt(je,T,d,y),je.needsUpdate=!0,$e.intersectsTriangle(je))return!0}}}const Yi=new b.kn4,Rs=new $t,hi=new $t,Nl=new b.Pq0,Dl=new b.Pq0,Rl=new b.Pq0,Bl=new b.Pq0;function Ll(o,e,t,i={},s={},n=0,r=1/0){e.boundingBox||e.computeBoundingBox(),Rs.set(e.boundingBox.min,e.boundingBox.max,t),Rs.needsUpdate=!0;const a=o.geometry,l=a.attributes.position,c=a.index,h=e.attributes.position,u=e.index,f=Xt.getPrimitive(),d=Xt.getPrimitive();let y=Nl,g=Dl,_=null,p=null;s&&(_=Rl,p=Bl);let x=1/0,E=null,T=null;return Yi.copy(t).invert(),hi.matrix.copy(Yi),o.shapecast({boundsTraverseOrder:A=>Rs.distanceToBox(A),intersectsBounds:(A,M,S)=>S<x&&S<r&&(M&&(hi.min.copy(A.min),hi.max.copy(A.max),hi.needsUpdate=!0),!0),intersectsRange:(A,M)=>{if(e.boundsTree){const S=e.boundsTree;return S.shapecast({boundsTraverseOrder:z=>hi.distanceToBox(z),intersectsBounds:(z,O,N)=>N<x&&N<r,intersectsRange:(z,O)=>{for(let N=z,Z=z+O;N<Z;N++){const P=S.resolveTriangleIndex(N);Nt(d,3*P,u,h),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let F=A,v=A+M;F<v;F++){const R=o.resolveTriangleIndex(F);Nt(f,3*R,c,l),f.needsUpdate=!0;const Q=f.distanceToTriangle(d,y,_);if(Q<x&&(g.copy(y),p&&p.copy(_),x=Q,E=F,T=N),Q<n)return!0}}}})}for(let z=0,O=Fe(e);z<O;z++){Nt(d,3*z,u,h),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let N=A,Z=A+M;N<Z;N++){const P=o.resolveTriangleIndex(N);Nt(f,3*P,c,l),f.needsUpdate=!0;const F=f.distanceToTriangle(d,y,_);if(F<x&&(g.copy(y),p&&p.copy(_),x=F,E=N,T=z),F<n)return!0}}}}),Xt.releasePrimitive(f),Xt.releasePrimitive(d),x===1/0?null:(i.point?i.point.copy(g):i.point=g.clone(),i.distance=x,i.faceIndex=E,s&&(s.point?s.point.copy(p):s.point=p.clone(),s.point.applyMatrix4(Yi),g.applyMatrix4(Yi),s.distance=g.sub(s.point).length(),s.faceIndex=T),i)}const ui=new Et.constructor,Zi=new Et.constructor,we=new Ps(()=>new b.NRn),He=new b.NRn,Ye=new b.NRn,Bs=new b.NRn,Ls=new b.NRn;let Vs=!1;function ne(o,e,t,i,s,n=0,r=0,a=0,l=0,c=null,h=!1){let u,f;h?(u=Zi,f=ui):(u=ui,f=Zi);const d=u.float32Array,y=u.uint32Array,g=u.uint16Array,_=f.float32Array,p=f.uint32Array,x=f.uint16Array,T=2*e,A=qt(2*o,g),M=qt(T,x);let S=!1;if(M&&A)S=h?s(Gt(e,p),Qt(2*e,x),Gt(o,y),Qt(2*o,g),l,r+e,a,n+o):s(Gt(o,y),Qt(2*o,g),Gt(e,p),Qt(2*e,x),a,n+o,l,r+e);else if(M){const z=we.getPrimitive();It(e,_,z),z.applyMatrix4(t);const O=Kt(o),N=Jt(o,y);It(O,d,He),It(N,d,Ye);const Z=z.intersectsBox(He),P=z.intersectsBox(Ye);S=Z&&ne(e,O,i,t,s,r,n,l,a+1,z,!h)||P&&ne(e,N,i,t,s,r,n,l,a+1,z,!h),we.releasePrimitive(z)}else{const z=Kt(e),O=Jt(e,p);It(z,_,Bs),It(O,_,Ls);const N=c.intersectsBox(Bs),Z=c.intersectsBox(Ls);if(N&&Z)S=ne(o,z,t,i,s,n,r,a,l+1,c,h)||ne(o,O,t,i,s,n,r,a,l+1,c,h);else if(N)if(A)S=ne(o,z,t,i,s,n,r,a,l+1,c,h);else{const P=we.getPrimitive();P.copy(Bs).applyMatrix4(t);const F=Kt(o),v=Jt(o,y);It(F,d,He),It(v,d,Ye);const R=P.intersectsBox(He),Q=P.intersectsBox(Ye);S=R&&ne(z,F,i,t,s,r,n,l,a+1,P,!h)||Q&&ne(z,v,i,t,s,r,n,l,a+1,P,!h),we.releasePrimitive(P)}else if(Z)if(A)S=ne(o,O,t,i,s,n,r,a,l+1,c,h);else{const P=we.getPrimitive();P.copy(Ls).applyMatrix4(t);const F=Kt(o),v=Jt(o,y);It(F,d,He),It(v,d,Ye);const R=P.intersectsBox(He),Q=P.intersectsBox(Ye);S=R&&ne(O,F,i,t,s,r,n,l,a+1,P,!h)||Q&&ne(O,v,i,t,s,r,n,l,a+1,P,!h),we.releasePrimitive(P)}}return S}const Wi=new $t,vr=new b.NRn;class Us{static serialize(e,t={}){t={cloneBuffers:!0,...t};const s=e._roots,n=e._indirectBuffer,r=e.geometry.getIndex();let a;return a=t.cloneBuffers?{roots:s.map(l=>l.slice()),index:r.array.slice(),indirectBuffer:n?n.slice():null}:{roots:s,index:r.array,indirectBuffer:n},a}static deserialize(e,t,i={}){i={setIndex:!0,indirect:!!e.indirectBuffer,...i};const{index:s,roots:n,indirectBuffer:r}=e,a=new Us(t,{...i,[Cs]:!0});if(a._roots=n,a._indirectBuffer=r||null,i.setIndex){const l=t.getIndex();if(null===l){const c=new b.THS(e.index,1,!1);t.setIndex(c)}else l.array!==s&&(l.array.set(s),l.needsUpdate=!0)}return a}get indirect(){return!!this._indirectBuffer}constructor(e,t={}){if(!e.isBufferGeometry)throw new Error("MeshBVH: Only BufferGeometries are supported.");if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.");if((t=Object.assign({strategy:0,maxDepth:40,maxLeafTris:10,verbose:!0,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,[Cs]:!1},t)).useSharedArrayBuffer&&!function Vl(){return typeof SharedArrayBuffer<"u"}())throw new Error("MeshBVH: SharedArrayBuffer is not available.");this.geometry=e,this._roots=null,this._indirectBuffer=null,t[Cs]||(nl(this,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new b.NRn)));const{_indirectBuffer:i}=this;this.resolveTriangleIndex=t.indirect?s=>i[s]:s=>s}refit(e=null){return(this.indirect?Ml:_l)(this,e)}traverse(e,t=0){const i=this._roots[t],s=new Uint32Array(i),n=new Uint16Array(i);!function r(a,l=0){const c=2*a,h=n[c+15]===Mi;if(h){const u=s[a+6],f=n[c+14];e(l,h,new Float32Array(i,4*a,6),u,f)}else{const u=a+8,f=s[a+6],d=s[a+7];e(l,h,new Float32Array(i,4*a,6),d)||(r(u,l+1),r(f,l+1))}}(0)}raycast(e,t=b.hB5){const i=this._roots,s=this.geometry,n=[],r=t.isMaterial,a=Array.isArray(t),l=s.groups,c=r?t.side:t,h=this.indirect?Ol:bl;for(let u=0,f=i.length;u<f;u++){const y=n.length;if(h(this,u,a?t[l[u].materialIndex].side:c,e,n),a){const g=l[u].materialIndex;for(let _=y,p=n.length;_<p;_++)n[_].face.materialIndex=g}}return n}raycastFirst(e,t=b.hB5){const i=this._roots,s=this.geometry,n=t.isMaterial,r=Array.isArray(t);let a=null;const l=s.groups,c=n?t.side:t,h=this.indirect?zl:Cl;for(let u=0,f=i.length;u<f;u++){const y=h(this,u,r?t[l[u].materialIndex].side:c,e);null!=y&&(null==a||y.distance<a.distance)&&(a=y,r&&(y.face.materialIndex=l[u].materialIndex))}return a}intersectsGeometry(e,t){let i=!1;const n=this.indirect?Fl:Tl;for(let r=0,a=this._roots.length;r<a&&(i=n(this,r,e,t),!i);r++);return i}shapecast(e){const t=Xt.getPrimitive(),i=this.indirect?wl:gl;let{boundsTraverseOrder:s,intersectsBounds:n,intersectsRange:r,intersectsTriangle:a}=e;if(r&&a){const u=r;r=(f,d,y,g,_)=>!!u(f,d,y,g,_)||i(f,d,this,a,y,g,t)}else r||(r=a?(u,f,d,y)=>i(u,f,this,a,d,y,t):(u,f,d)=>d);let l=!1,c=0;const h=this._roots;for(let u=0,f=h.length;u<f;u++){const d=h[u];if(l=hl(this,u,n,r,s,c),l)break;c+=d.byteLength}return Xt.releasePrimitive(t),l}bvhcast(e,t,i){let{intersectsRanges:s,intersectsTriangles:n}=i;const r=Xt.getPrimitive(),a=this.geometry.index,l=this.geometry.attributes.position,c=this.indirect?y=>{const g=this.resolveTriangleIndex(y);Nt(r,3*g,a,l)}:y=>{Nt(r,3*y,a,l)},h=Xt.getPrimitive(),u=e.geometry.index,f=e.geometry.attributes.position,d=e.indirect?y=>{const g=e.resolveTriangleIndex(y);Nt(h,3*g,u,f)}:y=>{Nt(h,3*y,u,f)};if(n){const y=(g,_,p,x,E,T,A,M)=>{for(let S=p,z=p+x;S<z;S++){d(S),h.a.applyMatrix4(t),h.b.applyMatrix4(t),h.c.applyMatrix4(t),h.needsUpdate=!0;for(let O=g,N=g+_;O<N;O++)if(c(O),r.needsUpdate=!0,n(r,h,O,S,E,T,A,M))return!0}return!1};if(s){const g=s;s=function(_,p,x,E,T,A,M,S){return!!g(_,p,x,E,T,A,M,S)||y(_,p,x,E,T,A,M,S)}}else s=y}return function Ul(o,e,t,i){if(Vs)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");Vs=!0;const s=o._roots,n=e._roots;let r,a=0,l=0;const c=(new b.kn4).copy(t).invert();for(let h=0,u=s.length;h<u;h++){ui.setBuffer(s[h]),l=0;const f=we.getPrimitive();It(0,ui.float32Array,f),f.applyMatrix4(c);for(let d=0,y=n.length;d<y&&(Zi.setBuffer(n[h]),r=ne(0,0,t,c,i,a,l,0,0,f),Zi.clearBuffer(),l+=n[d].length,!r);d++);if(we.releasePrimitive(f),ui.clearBuffer(),a+=s[h].length,r)break}return Vs=!1,r}(this,e,t,s)}intersectsBox(e,t){return Wi.set(e.min,e.max,t),Wi.needsUpdate=!0,this.shapecast({intersectsBounds:i=>Wi.intersectsBox(i),intersectsTriangle:i=>Wi.intersectsTriangle(i)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,i={},s={},n=0,r=1/0){return(this.indirect?Ll:Il)(this,e,t,i,s,n,r)}closestPointToPoint(e,t={},i=0,s=1/0){return function ul(o,e,t={},i=0,s=1/0){const n=i*i,r=s*s;let a=1/0,l=null;if(o.shapecast({boundsTraverseOrder:h=>(oi.copy(e).clamp(h.min,h.max),oi.distanceToSquared(e)),intersectsBounds:(h,u,f)=>f<a&&f<r,intersectsTriangle:(h,u)=>{h.closestPointToPoint(e,oi);const f=e.distanceToSquared(oi);return f<a&&(Is.copy(oi),a=f,l=u),f<n}}),a===1/0)return null;const c=Math.sqrt(a);return t.point?t.point.copy(Is):t.point=Is.clone(),t.distance=c,t.faceIndex=l,t}(this,e,t,i,s)}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(i=>{It(0,new Float32Array(i),vr),e.union(vr)}),e}}function wr(o,e,t){return null===o||(o.point.applyMatrix4(e.matrixWorld),o.distance=o.point.distanceTo(t.ray.origin),o.object=e,o.distance<t.near||o.distance>t.far)?null:o}const $s=new b.RlV,br=new b.kn4,$l=b.eaF.prototype.raycast;function jl(o,e){if(this.geometry.boundsTree){if(void 0===this.material)return;br.copy(this.matrixWorld).invert(),$s.copy(o.ray).applyMatrix4(br);const t=this.geometry.boundsTree;if(!0===o.firstHitOnly){const i=wr(t.raycastFirst($s,this.material),this,o);i&&e.push(i)}else{const i=t.raycast($s,this.material);for(let s=0,n=i.length;s<n;s++){const r=wr(i[s],this,o);r&&e.push(r)}}}else $l.call(this,o,e)}function Hl(o){return this.boundsTree=new Us(this,o),this.boundsTree}function Yl(){this.boundsTree=null}const xr=class vo{constructor(){w(this,"onDisposed",new X),w(this,"list",new ft.jp),w(this,"enabled",!1),w(this,"_clock"),w(this,"onInit",new X),w(this,"update",()=>{if(!this.enabled)return;const e=this._clock.getDelta();for(const[t,i]of this.list)i.enabled&&i.isUpdateable()&&i.update(e);requestAnimationFrame(this.update)}),this._clock=new b.zD7,vo.setupBVH()}add(e,t){if(this.list.has(e))throw new Error("You're trying to add a component that already exists in the components instance. Use Components.get() instead.");Yt.validate(e),this.list.set(e,t)}get(e){var t;const i=e.uuid;if(!this.list.has(i)){const s=new e(this);return null!=(t=s.isDisposeable)&&t.call(s)&&s.onDisposed.add(()=>this.list.delete(i)),this.list.has(i)||this.add(i,s),s}return this.list.get(i)}init(){this.enabled=!0;for(const[e,t]of this.list.entries())t.enabled=!0;this._clock.start(),this.update(),this.onInit.trigger()}dispose(){let e;this.enabled=!1;for(const[t,i]of this.list)i.enabled=!1,t!==ct.uuid?i.isDisposeable()&&i.dispose():e=i;e?.dispose(),this._clock.stop(),this.onDisposed.trigger()}static setupBVH(){b.LoY.prototype.computeBoundsTree=Hl,b.LoY.prototype.disposeBoundsTree=Yl,b.eaF.prototype.raycast=jl}};w(xr,"release","2.4.3");let js=xr;class Zl{constructor(e){w(this,"enabled",!1),w(this,"id","FirstPerson"),this.camera=e}set(e){if(this.enabled=e,e){if("Perspective"!==this.camera.projection.current)return void this.camera.set("Orbit");this.setupFirstPersonCamera()}}setupFirstPersonCamera(){const e=this.camera.controls,t=new b.Pq0;e.distance--,e.getPosition(t),e.minDistance=1,e.maxDistance=1,e.distance=1,e.moveTo(t.x,t.y,t.z),e.truckSpeed=50,e.mouseButtons.wheel=Bt.ACTION.DOLLY,e.touches.two=Bt.ACTION.TOUCH_ZOOM_TRUCK}}class Wl{constructor(e){w(this,"enabled",!0),w(this,"id","Orbit"),this.camera=e,this.activateOrbitControls()}set(e){this.enabled=e,e&&this.activateOrbitControls()}activateOrbitControls(){const e=this.camera.controls;e.minDistance=1,e.maxDistance=300;const t=new b.Pq0;e.getPosition(t);const i=t.length();e.distance=i,e.truckSpeed=2;const{rotation:s}=this.camera.three,n=new b.Pq0(0,0,-1).applyEuler(s),r=t.addScaledVector(n,i);e.moveTo(r.x,r.y,r.z)}}class ql{constructor(e){w(this,"enabled",!1),w(this,"id","Plan"),w(this,"mouseAction1"),w(this,"mouseAction2"),w(this,"mouseInitialized",!1),w(this,"defaultAzimuthSpeed"),w(this,"defaultPolarSpeed"),this.camera=e,this.defaultAzimuthSpeed=e.controls.azimuthRotateSpeed,this.defaultPolarSpeed=e.controls.polarRotateSpeed}set(e){this.enabled=e;const t=this.camera.controls;t.azimuthRotateSpeed=e?0:this.defaultAzimuthSpeed,t.polarRotateSpeed=e?0:this.defaultPolarSpeed,this.mouseInitialized||(this.mouseAction1=t.touches.one,this.mouseAction2=t.touches.two,this.mouseInitialized=!0),e?(t.mouseButtons.left=Bt.ACTION.TRUCK,t.touches.one=Bt.ACTION.TOUCH_TRUCK,t.touches.two=Bt.ACTION.TOUCH_ZOOM):(t.mouseButtons.left=Bt.ACTION.ROTATE,t.touches.one=this.mouseAction1,t.touches.two=this.mouseAction2)}}class Gl{constructor(e){w(this,"onChanged",new X),w(this,"current","Perspective"),w(this,"camera"),w(this,"matchOrthoDistanceEnabled",!1),w(this,"_component"),w(this,"_previousDistance",-1),this._component=e,this.camera=e.three}set(e){var t=this;return(0,H.A)(function*(){t.current!==e&&("Orthographic"===e?t.setOrthoCamera():yield t.setPerspectiveCamera(),t.onChanged.trigger(t.camera))})()}toggle(){var e=this;return(0,H.A)(function*(){const i="Perspective"===e.current?"Orthographic":"Perspective";yield e.set(i)})()}setOrthoCamera(){if(null===this._component.mode||"FirstPerson"===this._component.mode.id)return;this._previousDistance=this._component.controls.distance,this._component.controls.distance=200;const e=this.getPerspectiveDims();if(!e)return;const{width:t,height:i}=e;this.setupOrthoCamera(i,t),this.camera=this._component.threeOrtho,this.current="Orthographic"}getPerspectiveDims(){const e=this._component.currentWorld;if(!e||!e.renderer)return null;const t=new b.Pq0;this._component.threePersp.getWorldDirection(t);const i=new b.Pq0;this._component.controls.getTarget(i);const n=i.clone().sub(this._component.threePersp.position).dot(t),r=e.renderer.getSize(),a=r.x/r.y,c=2*n*Math.atan(this._component.threePersp.fov*(Math.PI/180)/2);return{width:c*a,height:c}}setupOrthoCamera(e,t){this._component.controls.mouseButtons.wheel=Bt.ACTION.ZOOM,this._component.controls.mouseButtons.middle=Bt.ACTION.ZOOM;const i=this._component.threePersp,s=this._component.threeOrtho;s.zoom=1,s.left=t/-2,s.right=t/2,s.top=e/2,s.bottom=e/-2,s.updateProjectionMatrix(),s.position.copy(i.position),s.quaternion.copy(i.quaternion),this._component.controls.camera=s}getDistance(){const t=this._component.threeOrtho;return(t.top-t.bottom)/t.zoom/(2*Math.atan(this._component.threePersp.fov*(Math.PI/180)/2))}setPerspectiveCamera(){var e=this;return(0,H.A)(function*(){e._component.controls.mouseButtons.wheel=Bt.ACTION.DOLLY,e._component.controls.mouseButtons.middle=Bt.ACTION.DOLLY;const t=e._component.threePersp,i=e._component.threeOrtho;t.position.copy(i.position),t.quaternion.copy(i.quaternion),e._component.controls.mouseButtons.wheel=Bt.ACTION.DOLLY,e._component.controls.distance=e.matchOrthoDistanceEnabled?e.getDistance():e._previousDistance,yield e._component.controls.zoomTo(1),t.updateProjectionMatrix(),e._component.controls.camera=t,e.camera=t,e.current="Perspective"})()}}class Hs extends ni{constructor(e){super(e),w(this,"projection"),w(this,"threeOrtho"),w(this,"threePersp"),w(this,"_userInputButtons",{}),w(this,"_frustumSize",50),w(this,"_navigationModes",new Map),w(this,"_mode",null),w(this,"previousSize",null),this.threePersp=this.three,this.threeOrtho=this.newOrthoCamera(),this.projection=new Gl(this),this.onAspectUpdated.add(()=>{this.setOrthoPerspCameraAspect()}),this.projection.onChanged.add(t=>{this.three=t,this.updateAspect()}),this.worlds.onItemSet.add(()=>{this._navigationModes.clear(),this._navigationModes.set("Orbit",new Wl(this)),this._navigationModes.set("FirstPerson",new Zl(this)),this._navigationModes.set("Plan",new ql(this)),this._mode=this._navigationModes.get("Orbit"),this.mode.set(!0,{preventTargetAdjustment:!0}),this.currentWorld&&this.currentWorld.renderer&&(this.previousSize=this.currentWorld.renderer.getSize().clone())}),this.worlds.onItemDeleted.add(()=>{this._navigationModes.clear()})}get mode(){if(!this._mode)throw new Error("Mode not found, camera not initialized");return this._mode}dispose(){super.dispose(),this.threeOrtho.removeFromParent()}set(e){if(null!==this.mode&&this.mode.id!==e){if(this.mode.set(!1),!this._navigationModes.has(e))throw new Error("The specified mode does not exist!");this._mode=this._navigationModes.get(e),this.mode.set(!0)}}fit(e){var t=this;return(0,H.A)(function*(i,s=1.5){if(!t.enabled)return;const n=Number.MAX_VALUE,r=Number.MIN_VALUE,a=new b.Pq0(n,n,n),l=new b.Pq0(r,r,r);for(const g of i){const _=(new b.NRn).setFromObject(g);_.min.x<a.x&&(a.x=_.min.x),_.min.y<a.y&&(a.y=_.min.y),_.min.z<a.z&&(a.z=_.min.z),_.max.x>l.x&&(l.x=_.max.x),_.max.y>l.y&&(l.y=_.max.y),_.max.z>l.z&&(l.z=_.max.z)}const c=new b.NRn(a,l),h=t.components.get(ct);if(h.initialized)for(const[,g]of h.list){const _=g.box;_.min.x<a.x&&(a.x=_.min.x),_.min.y<a.y&&(a.y=_.min.y),_.min.z<a.z&&(a.z=_.min.z),_.max.x>l.x&&(l.x=_.max.x),_.max.y>l.y&&(l.y=_.max.y),_.max.z>l.z&&(l.z=_.max.z)}const u=new b.Pq0;c.getSize(u);const f=new b.Pq0;c.getCenter(f);const d=Math.max(u.x,u.y,u.z)*s,y=new b.iyt(f,d);yield t.controls.fitToSphere(y,!0)}).apply(this,arguments)}setUserInput(e){e?this.enableUserInput():this.disableUserInput()}addCustomNavigationMode(e){this._navigationModes.set(e.id,e)}disableUserInput(){this._userInputButtons.left=this.controls.mouseButtons.left,this._userInputButtons.right=this.controls.mouseButtons.right,this._userInputButtons.middle=this.controls.mouseButtons.middle,this._userInputButtons.wheel=this.controls.mouseButtons.wheel,this.controls.mouseButtons.left=0,this.controls.mouseButtons.right=0,this.controls.mouseButtons.middle=0,this.controls.mouseButtons.wheel=0}enableUserInput(){0!==Object.keys(this._userInputButtons).length&&(this.controls.mouseButtons.left=this._userInputButtons.left,this.controls.mouseButtons.right=this._userInputButtons.right,this.controls.mouseButtons.middle=this._userInputButtons.middle,this.controls.mouseButtons.wheel=this._userInputButtons.wheel)}newOrthoCamera(){const e=window.innerWidth/window.innerHeight;return new b.qUd(this._frustumSize*e/-2,this._frustumSize*e/2,this._frustumSize/2,this._frustumSize/-2,.1,1e3)}setOrthoPerspCameraAspect(){if(!this.currentWorld||!this.currentWorld.renderer||!this.previousSize)return;const e=this.currentWorld.renderer.getSize(),r=this.threeOrtho.top*(e.y/this.previousSize.y),a=this.threeOrtho.right*(e.x/this.previousSize.x);this.threeOrtho.left=-a,this.threeOrtho.right=a,this.threeOrtho.top=r,this.threeOrtho.bottom=-r,this.threeOrtho.updateProjectionMatrix(),this.previousSize.copy(e)}}var qi=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Xl(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}function Gi(o){throw new Error('Could not dynamically require "'+o+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Cr={exports:{}};Cr.exports=function t(i,s,n){function r(c,h){if(!s[c]){if(!i[c]){if(!h&&Gi)return Gi(c);if(a)return a(c,!0);var f=new Error("Cannot find module '"+c+"'");throw f.code="MODULE_NOT_FOUND",f}var d=s[c]={exports:{}};i[c][0].call(d.exports,function(y){return r(i[c][1][y]||y)},d,d.exports,t,i,s,n)}return s[c].exports}for(var a=Gi,l=0;l<n.length;l++)r(n[l]);return r}({1:[function(t,i,s){var n=t("./utils"),r=t("./support"),a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";s.encode=function(l){for(var c,h,u,d,y,g,_=[],p=0,x=l.length,E=x,T="string"!==n.getTypeOf(l);p<l.length;)E=x-p,u=T?(c=l[p++],h=p<x?l[p++]:0,p<x?l[p++]:0):(c=l.charCodeAt(p++),h=p<x?l.charCodeAt(p++):0,p<x?l.charCodeAt(p++):0),d=(3&c)<<4|h>>4,y=1<E?(15&h)<<2|u>>6:64,g=2<E?63&u:64,_.push(a.charAt(c>>2)+a.charAt(d)+a.charAt(y)+a.charAt(g));return _.join("")},s.decode=function(l){var c,h,u,f,d,y,g=0,_=0,p="data:";if(l.substr(0,5)===p)throw new Error("Invalid base64 input, it looks like a data url.");var x,E=3*(l=l.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(l.charAt(l.length-1)===a.charAt(64)&&E--,l.charAt(l.length-2)===a.charAt(64)&&E--,E%1!=0)throw new Error("Invalid base64 input, bad content length.");for(x=r.uint8array?new Uint8Array(0|E):new Array(0|E);g<l.length;)c=a.indexOf(l.charAt(g++))<<2|(f=a.indexOf(l.charAt(g++)))>>4,h=(15&f)<<4|(d=a.indexOf(l.charAt(g++)))>>2,u=(3&d)<<6|(y=a.indexOf(l.charAt(g++))),x[_++]=c,64!==d&&(x[_++]=h),64!==y&&(x[_++]=u);return x}},{"./support":30,"./utils":32}],2:[function(t,i,s){var n=t("./external"),r=t("./stream/DataWorker"),a=t("./stream/Crc32Probe"),l=t("./stream/DataLengthProbe");function c(h,u,f,d,y){this.compressedSize=h,this.uncompressedSize=u,this.crc32=f,this.compression=d,this.compressedContent=y}c.prototype={getContentWorker:function(){var h=new r(n.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new l("data_length")),u=this;return h.on("end",function(){if(this.streamInfo.data_length!==u.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),h},getCompressedWorker:function(){return new r(n.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},c.createWorkerFrom=function(h,u,f){return h.pipe(new a).pipe(new l("uncompressedSize")).pipe(u.compressWorker(f)).pipe(new l("compressedSize")).withStreamInfo("compression",u)},i.exports=c},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(t,i,s){var n=t("./stream/GenericWorker");s.STORE={magic:"\0\0",compressWorker:function(){return new n("STORE compression")},uncompressWorker:function(){return new n("STORE decompression")}},s.DEFLATE=t("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(t,i,s){var n=t("./utils"),r=function(){for(var a,l=[],c=0;c<256;c++){a=c;for(var h=0;h<8;h++)a=1&a?3988292384^a>>>1:a>>>1;l[c]=a}return l}();i.exports=function(a,l){return void 0!==a&&a.length?"string"!==n.getTypeOf(a)?function(c,h,u){var d=r,y=0+u;c^=-1;for(var g=0;g<y;g++)c=c>>>8^d[255&(c^h[g])];return-1^c}(0|l,a,a.length):function(c,h,u){var d=r,y=0+u;c^=-1;for(var g=0;g<y;g++)c=c>>>8^d[255&(c^h.charCodeAt(g))];return-1^c}(0|l,a,a.length):0}},{"./utils":32}],5:[function(t,i,s){s.base64=!1,s.binary=!1,s.dir=!1,s.createFolders=!0,s.date=null,s.compression=null,s.compressionOptions=null,s.comment=null,s.unixPermissions=null,s.dosPermissions=null},{}],6:[function(t,i,s){var n;n=typeof Promise<"u"?Promise:t("lie"),i.exports={Promise:n}},{lie:37}],7:[function(t,i,s){var n=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",r=t("pako"),a=t("./utils"),l=t("./stream/GenericWorker"),c=n?"uint8array":"array";function h(u,f){l.call(this,"FlateWorker/"+u),this._pako=null,this._pakoAction=u,this._pakoOptions=f,this.meta={}}s.magic="\b\0",a.inherits(h,l),h.prototype.processChunk=function(u){this.meta=u.meta,null===this._pako&&this._createPako(),this._pako.push(a.transformTo(c,u.data),!1)},h.prototype.flush=function(){l.prototype.flush.call(this),null===this._pako&&this._createPako(),this._pako.push([],!0)},h.prototype.cleanUp=function(){l.prototype.cleanUp.call(this),this._pako=null},h.prototype._createPako=function(){this._pako=new r[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var u=this;this._pako.onData=function(f){u.push({data:f,meta:u.meta})}},s.compressWorker=function(u){return new h("Deflate",u)},s.uncompressWorker=function(){return new h("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(t,i,s){function n(d,y){var g,_="";for(g=0;g<y;g++)_+=String.fromCharCode(255&d),d>>>=8;return _}function r(d,y,g,_,p,x){var E,T,A=d.file,M=d.compression,S=x!==c.utf8encode,z=a.transformTo("string",x(A.name)),O=a.transformTo("string",c.utf8encode(A.name)),N=A.comment,Z=a.transformTo("string",x(N)),P=a.transformTo("string",c.utf8encode(N)),F=O.length!==A.name.length,v=P.length!==N.length,R="",Q="",j="",rt=A.dir,Y=A.date,ot={crc32:0,compressedSize:0,uncompressedSize:0};y&&!g||(ot.crc32=d.crc32,ot.compressedSize=d.compressedSize,ot.uncompressedSize=d.uncompressedSize);var B=0;y&&(B|=8),S||!F&&!v||(B|=2048);var K,Ot,L=0,it=0;rt&&(L|=16),"UNIX"===p?(it=798,L|=(Ot=K=A.unixPermissions,K||(Ot=rt?16893:33204),(65535&Ot)<<16)):(it=20,L|=function(K){return 63&(K||0)}(A.dosPermissions)),E=Y.getUTCHours(),E<<=6,E|=Y.getUTCMinutes(),E<<=5,E|=Y.getUTCSeconds()/2,T=Y.getUTCFullYear()-1980,T<<=4,T|=Y.getUTCMonth()+1,T<<=5,T|=Y.getUTCDate(),F&&(Q=n(1,1)+n(h(z),4)+O,R+="up"+n(Q.length,2)+Q),v&&(j=n(1,1)+n(h(Z),4)+P,R+="uc"+n(j.length,2)+j);var et="";return et+="\n\0",et+=n(B,2),et+=M.magic,et+=n(E,2),et+=n(T,2),et+=n(ot.crc32,4),et+=n(ot.compressedSize,4),et+=n(ot.uncompressedSize,4),et+=n(z.length,2),et+=n(R.length,2),{fileRecord:u.LOCAL_FILE_HEADER+et+z+R,dirRecord:u.CENTRAL_FILE_HEADER+n(it,2)+et+n(Z.length,2)+"\0\0\0\0"+n(L,4)+n(_,4)+z+R+Z}}var a=t("../utils"),l=t("../stream/GenericWorker"),c=t("../utf8"),h=t("../crc32"),u=t("../signature");function f(d,y,g,_){l.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=y,this.zipPlatform=g,this.encodeFileName=_,this.streamFiles=d,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}a.inherits(f,l),f.prototype.push=function(d){var y=d.meta.percent||0,g=this.entriesCount,_=this._sources.length;this.accumulate?this.contentBuffer.push(d):(this.bytesWritten+=d.data.length,l.prototype.push.call(this,{data:d.data,meta:{currentFile:this.currentFile,percent:g?(y+100*(g-_-1))/g:100}}))},f.prototype.openedSource=function(d){this.currentSourceOffset=this.bytesWritten,this.currentFile=d.file.name;var y=this.streamFiles&&!d.file.dir;if(y){var g=r(d,y,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:g.fileRecord,meta:{percent:0}})}else this.accumulate=!0},f.prototype.closedSource=function(d){this.accumulate=!1;var _,y=this.streamFiles&&!d.file.dir,g=r(d,y,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(g.dirRecord),y)this.push({data:(_=d,u.DATA_DESCRIPTOR+n(_.crc32,4)+n(_.compressedSize,4)+n(_.uncompressedSize,4)),meta:{percent:100}});else for(this.push({data:g.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},f.prototype.flush=function(){for(var d=this.bytesWritten,y=0;y<this.dirRecords.length;y++)this.push({data:this.dirRecords[y],meta:{percent:100}});var p,x,E,M,_=(p=this.dirRecords.length,x=this.bytesWritten-d,E=d,M=a.transformTo("string",(0,this.encodeFileName)(this.zipComment)),u.CENTRAL_DIRECTORY_END+"\0\0\0\0"+n(p,2)+n(p,2)+n(x,4)+n(E,4)+n(M.length,2)+M);this.push({data:_,meta:{percent:100}})},f.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},f.prototype.registerPrevious=function(d){this._sources.push(d);var y=this;return d.on("data",function(g){y.processChunk(g)}),d.on("end",function(){y.closedSource(y.previous.streamInfo),y._sources.length?y.prepareNextSource():y.end()}),d.on("error",function(g){y.error(g)}),this},f.prototype.resume=function(){return!!l.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},f.prototype.error=function(d){var y=this._sources;if(!l.prototype.error.call(this,d))return!1;for(var g=0;g<y.length;g++)try{y[g].error(d)}catch{}return!0},f.prototype.lock=function(){l.prototype.lock.call(this);for(var d=this._sources,y=0;y<d.length;y++)d[y].lock()},i.exports=f},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(t,i,s){var n=t("../compressions"),r=t("./ZipFileWorker");s.generateWorker=function(a,l,c){var h=new r(l.streamFiles,c,l.platform,l.encodeFileName),u=0;try{a.forEach(function(f,d){u++;var y=function(x,E){var T=x||E,A=n[T];if(!A)throw new Error(T+" is not a valid compression method !");return A}(d.options.compression,l.compression),_=d.dir,p=d.date;d._compressWorker(y,d.options.compressionOptions||l.compressionOptions||{}).withStreamInfo("file",{name:f,dir:_,date:p,comment:d.comment||"",unixPermissions:d.unixPermissions,dosPermissions:d.dosPermissions}).pipe(h)}),h.entriesCount=u}catch(f){h.error(f)}return h}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(t,i,s){function n(){if(!(this instanceof n))return new n;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var r=new n;for(var a in this)"function"!=typeof this[a]&&(r[a]=this[a]);return r}}(n.prototype=t("./object")).loadAsync=t("./load"),n.support=t("./support"),n.defaults=t("./defaults"),n.version="3.10.1",n.loadAsync=function(r,a){return(new n).loadAsync(r,a)},n.external=t("./external"),i.exports=n},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(t,i,s){var n=t("./utils"),r=t("./external"),a=t("./utf8"),l=t("./zipEntries"),c=t("./stream/Crc32Probe"),h=t("./nodejsUtils");function u(f){return new r.Promise(function(d,y){var g=f.decompressed.getContentWorker().pipe(new c);g.on("error",function(_){y(_)}).on("end",function(){g.streamInfo.crc32!==f.decompressed.crc32?y(new Error("Corrupted zip : CRC32 mismatch")):d()}).resume()})}i.exports=function(f,d){var y=this;return d=n.extend(d||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:a.utf8decode}),h.isNode&&h.isStream(f)?r.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):n.prepareContent("the loaded zip file",f,!0,d.optimizedBinaryString,d.base64).then(function(g){var _=new l(d);return _.load(g),_}).then(function(g){var _=[r.Promise.resolve(g)],p=g.files;if(d.checkCRC32)for(var x=0;x<p.length;x++)_.push(u(p[x]));return r.Promise.all(_)}).then(function(g){for(var _=g.shift(),p=_.files,x=0;x<p.length;x++){var E=p[x],T=E.fileNameStr,A=n.resolve(E.fileNameStr);y.file(A,E.decompressed,{binary:!0,optimizedBinaryString:!0,date:E.date,dir:E.dir,comment:E.fileCommentStr.length?E.fileCommentStr:null,unixPermissions:E.unixPermissions,dosPermissions:E.dosPermissions,createFolders:d.createFolders}),E.dir||(y.file(A).unsafeOriginalName=T)}return _.zipComment.length&&(y.comment=_.zipComment),y})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(t,i,s){var n=t("../utils"),r=t("../stream/GenericWorker");function a(l,c){r.call(this,"Nodejs stream input adapter for "+l),this._upstreamEnded=!1,this._bindStream(c)}n.inherits(a,r),a.prototype._bindStream=function(l){var c=this;(this._stream=l).pause(),l.on("data",function(h){c.push({data:h,meta:{percent:0}})}).on("error",function(h){c.isPaused?this.generatedError=h:c.error(h)}).on("end",function(){c.isPaused?c._upstreamEnded=!0:c.end()})},a.prototype.pause=function(){return!!r.prototype.pause.call(this)&&(this._stream.pause(),!0)},a.prototype.resume=function(){return!!r.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},i.exports=a},{"../stream/GenericWorker":28,"../utils":32}],13:[function(t,i,s){var n=t("readable-stream").Readable;function r(a,l,c){n.call(this,l),this._helper=a;var h=this;a.on("data",function(u,f){h.push(u)||h._helper.pause(),c&&c(f)}).on("error",function(u){h.emit("error",u)}).on("end",function(){h.push(null)})}t("../utils").inherits(r,n),r.prototype._read=function(){this._helper.resume()},i.exports=r},{"../utils":32,"readable-stream":16}],14:[function(t,i,s){i.exports={isNode:typeof Buffer<"u",newBufferFrom:function(n,r){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(n,r);if("number"==typeof n)throw new Error('The "data" argument must not be a number');return new Buffer(n,r)},allocBuffer:function(n){if(Buffer.alloc)return Buffer.alloc(n);var r=new Buffer(n);return r.fill(0),r},isBuffer:function(n){return Buffer.isBuffer(n)},isStream:function(n){return n&&"function"==typeof n.on&&"function"==typeof n.pause&&"function"==typeof n.resume}}},{}],15:[function(t,i,s){function n(A,M,S){var z,O=a.getTypeOf(M),N=a.extend(S||{},h);N.date=N.date||new Date,null!==N.compression&&(N.compression=N.compression.toUpperCase()),"string"==typeof N.unixPermissions&&(N.unixPermissions=parseInt(N.unixPermissions,8)),N.unixPermissions&&16384&N.unixPermissions&&(N.dir=!0),N.dosPermissions&&16&N.dosPermissions&&(N.dir=!0),N.dir&&(A=p(A)),N.createFolders&&(z=_(A))&&x.call(this,z,!0),S&&void 0!==S.binary||(N.binary=!("string"===O&&!1===N.binary&&!1===N.base64)),(M instanceof u&&0===M.uncompressedSize||N.dir||!M||0===M.length)&&(N.base64=!1,N.binary=!0,M="",N.compression="STORE",O="string");var P;P=M instanceof u||M instanceof l?M:y.isNode&&y.isStream(M)?new g(A,M):a.prepareContent(A,M,N.binary,N.optimizedBinaryString,N.base64);var F=new f(A,P,N);this.files[A]=F}var r=t("./utf8"),a=t("./utils"),l=t("./stream/GenericWorker"),c=t("./stream/StreamHelper"),h=t("./defaults"),u=t("./compressedObject"),f=t("./zipObject"),d=t("./generate"),y=t("./nodejsUtils"),g=t("./nodejs/NodejsStreamInputAdapter"),_=function(A){"/"===A.slice(-1)&&(A=A.substring(0,A.length-1));var M=A.lastIndexOf("/");return 0<M?A.substring(0,M):""},p=function(A){return"/"!==A.slice(-1)&&(A+="/"),A},x=function(A,M){return M=void 0!==M?M:h.createFolders,A=p(A),this.files[A]||n.call(this,A,null,{dir:!0,createFolders:M}),this.files[A]};function E(A){return"[object RegExp]"===Object.prototype.toString.call(A)}var T={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(A){var M,S,z;for(M in this.files)z=this.files[M],(S=M.slice(this.root.length,M.length))&&M.slice(0,this.root.length)===this.root&&A(S,z)},filter:function(A){var M=[];return this.forEach(function(S,z){A(S,z)&&M.push(z)}),M},file:function(A,M,S){if(1!==arguments.length)return n.call(this,A=this.root+A,M,S),this;if(E(A)){var z=A;return this.filter(function(N,Z){return!Z.dir&&z.test(N)})}var O=this.files[this.root+A];return O&&!O.dir?O:null},folder:function(A){if(!A)return this;if(E(A))return this.filter(function(O,N){return N.dir&&A.test(O)});var S=x.call(this,this.root+A),z=this.clone();return z.root=S.name,z},remove:function(A){var M=this.files[A=this.root+A];if(M||("/"!==A.slice(-1)&&(A+="/"),M=this.files[A]),M&&!M.dir)delete this.files[A];else for(var S=this.filter(function(O,N){return N.name.slice(0,A.length)===A}),z=0;z<S.length;z++)delete this.files[S[z].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(A){var M,S={};try{if((S=a.extend(A||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:r.utf8encode})).type=S.type.toLowerCase(),S.compression=S.compression.toUpperCase(),"binarystring"===S.type&&(S.type="string"),!S.type)throw new Error("No output type specified.");a.checkSupport(S.type),"darwin"!==S.platform&&"freebsd"!==S.platform&&"linux"!==S.platform&&"sunos"!==S.platform||(S.platform="UNIX"),"win32"===S.platform&&(S.platform="DOS"),M=d.generateWorker(this,S,S.comment||this.comment||"")}catch(O){(M=new l("error")).error(O)}return new c(M,S.type||"string",S.mimeType)},generateAsync:function(A,M){return this.generateInternalStream(A).accumulate(M)},generateNodeStream:function(A,M){return(A=A||{}).type||(A.type="nodebuffer"),this.generateInternalStream(A).toNodejsStream(M)}};i.exports=T},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(t,i,s){i.exports=t("stream")},{stream:void 0}],17:[function(t,i,s){var n=t("./DataReader");function r(a){n.call(this,a);for(var l=0;l<this.data.length;l++)a[l]=255&a[l]}t("../utils").inherits(r,n),r.prototype.byteAt=function(a){return this.data[this.zero+a]},r.prototype.lastIndexOfSignature=function(a){for(var l=a.charCodeAt(0),c=a.charCodeAt(1),h=a.charCodeAt(2),u=a.charCodeAt(3),f=this.length-4;0<=f;--f)if(this.data[f]===l&&this.data[f+1]===c&&this.data[f+2]===h&&this.data[f+3]===u)return f-this.zero;return-1},r.prototype.readAndCheckSignature=function(a){var l=a.charCodeAt(0),c=a.charCodeAt(1),h=a.charCodeAt(2),u=a.charCodeAt(3),f=this.readData(4);return l===f[0]&&c===f[1]&&h===f[2]&&u===f[3]},r.prototype.readData=function(a){if(this.checkOffset(a),0===a)return[];var l=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},i.exports=r},{"../utils":32,"./DataReader":18}],18:[function(t,i,s){var n=t("../utils");function r(a){this.data=a,this.length=a.length,this.index=0,this.zero=0}r.prototype={checkOffset:function(a){this.checkIndex(this.index+a)},checkIndex:function(a){if(this.length<this.zero+a||a<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+a+"). Corrupted zip ?")},setIndex:function(a){this.checkIndex(a),this.index=a},skip:function(a){this.setIndex(this.index+a)},byteAt:function(){},readInt:function(a){var l,c=0;for(this.checkOffset(a),l=this.index+a-1;l>=this.index;l--)c=(c<<8)+this.byteAt(l);return this.index+=a,c},readString:function(a){return n.transformTo("string",this.readData(a))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var a=this.readInt(4);return new Date(Date.UTC(1980+(a>>25&127),(a>>21&15)-1,a>>16&31,a>>11&31,a>>5&63,(31&a)<<1))}},i.exports=r},{"../utils":32}],19:[function(t,i,s){var n=t("./Uint8ArrayReader");function r(a){n.call(this,a)}t("../utils").inherits(r,n),r.prototype.readData=function(a){this.checkOffset(a);var l=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},i.exports=r},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(t,i,s){var n=t("./DataReader");function r(a){n.call(this,a)}t("../utils").inherits(r,n),r.prototype.byteAt=function(a){return this.data.charCodeAt(this.zero+a)},r.prototype.lastIndexOfSignature=function(a){return this.data.lastIndexOf(a)-this.zero},r.prototype.readAndCheckSignature=function(a){return a===this.readData(4)},r.prototype.readData=function(a){this.checkOffset(a);var l=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},i.exports=r},{"../utils":32,"./DataReader":18}],21:[function(t,i,s){var n=t("./ArrayReader");function r(a){n.call(this,a)}t("../utils").inherits(r,n),r.prototype.readData=function(a){if(this.checkOffset(a),0===a)return new Uint8Array(0);var l=this.data.subarray(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},i.exports=r},{"../utils":32,"./ArrayReader":17}],22:[function(t,i,s){var n=t("../utils"),r=t("../support"),a=t("./ArrayReader"),l=t("./StringReader"),c=t("./NodeBufferReader"),h=t("./Uint8ArrayReader");i.exports=function(u){var f=n.getTypeOf(u);return n.checkSupport(f),"string"!==f||r.uint8array?"nodebuffer"===f?new c(u):r.uint8array?new h(n.transformTo("uint8array",u)):new a(n.transformTo("array",u)):new l(u)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(t,i,s){s.LOCAL_FILE_HEADER="PK\x03\x04",s.CENTRAL_FILE_HEADER="PK\x01\x02",s.CENTRAL_DIRECTORY_END="PK\x05\x06",s.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x06\x07",s.ZIP64_CENTRAL_DIRECTORY_END="PK\x06\x06",s.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(t,i,s){var n=t("./GenericWorker"),r=t("../utils");function a(l){n.call(this,"ConvertWorker to "+l),this.destType=l}r.inherits(a,n),a.prototype.processChunk=function(l){this.push({data:r.transformTo(this.destType,l.data),meta:l.meta})},i.exports=a},{"../utils":32,"./GenericWorker":28}],25:[function(t,i,s){var n=t("./GenericWorker"),r=t("../crc32");function a(){n.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}t("../utils").inherits(a,n),a.prototype.processChunk=function(l){this.streamInfo.crc32=r(l.data,this.streamInfo.crc32||0),this.push(l)},i.exports=a},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(t,i,s){var n=t("../utils"),r=t("./GenericWorker");function a(l){r.call(this,"DataLengthProbe for "+l),this.propName=l,this.withStreamInfo(l,0)}n.inherits(a,r),a.prototype.processChunk=function(l){l&&(this.streamInfo[this.propName]=(this.streamInfo[this.propName]||0)+l.data.length),r.prototype.processChunk.call(this,l)},i.exports=a},{"../utils":32,"./GenericWorker":28}],27:[function(t,i,s){var n=t("../utils"),r=t("./GenericWorker");function a(l){r.call(this,"DataWorker");var c=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,l.then(function(h){c.dataIsReady=!0,c.data=h,c.max=h&&h.length||0,c.type=n.getTypeOf(h),c.isPaused||c._tickAndRepeat()},function(h){c.error(h)})}n.inherits(a,r),a.prototype.cleanUp=function(){r.prototype.cleanUp.call(this),this.data=null},a.prototype.resume=function(){return!!r.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,n.delay(this._tickAndRepeat,[],this)),!0)},a.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(n.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},a.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var l=null,c=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":l=this.data.substring(this.index,c);break;case"uint8array":l=this.data.subarray(this.index,c);break;case"array":case"nodebuffer":l=this.data.slice(this.index,c)}return this.index=c,this.push({data:l,meta:{percent:this.max?this.index/this.max*100:0}})},i.exports=a},{"../utils":32,"./GenericWorker":28}],28:[function(t,i,s){function n(r){this.name=r||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}n.prototype={push:function(r){this.emit("data",r)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(r){this.emit("error",r)}return!0},error:function(r){return!this.isFinished&&(this.isPaused?this.generatedError=r:(this.isFinished=!0,this.emit("error",r),this.previous&&this.previous.error(r),this.cleanUp()),!0)},on:function(r,a){return this._listeners[r].push(a),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(r,a){if(this._listeners[r])for(var l=0;l<this._listeners[r].length;l++)this._listeners[r][l].call(this,a)},pipe:function(r){return r.registerPrevious(this)},registerPrevious:function(r){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=r.streamInfo,this.mergeStreamInfo(),this.previous=r;var a=this;return r.on("data",function(l){a.processChunk(l)}),r.on("end",function(){a.end()}),r.on("error",function(l){a.error(l)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var r=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),r=!0),this.previous&&this.previous.resume(),!r},flush:function(){},processChunk:function(r){this.push(r)},withStreamInfo:function(r,a){return this.extraStreamInfo[r]=a,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var r in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,r)&&(this.streamInfo[r]=this.extraStreamInfo[r])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var r="Worker "+this.name;return this.previous?this.previous+" -> "+r:r}},i.exports=n},{}],29:[function(t,i,s){var n=t("../utils"),r=t("./ConvertWorker"),a=t("./GenericWorker"),l=t("../base64"),c=t("../support"),h=t("../external"),u=null;if(c.nodestream)try{u=t("../nodejs/NodejsStreamOutputAdapter")}catch{}function d(y,g,_){var p=g;switch(g){case"blob":case"arraybuffer":p="uint8array";break;case"base64":p="string"}try{this._internalType=p,this._outputType=g,this._mimeType=_,n.checkSupport(p),this._worker=y.pipe(new r(p)),y.lock()}catch(x){this._worker=new a("error"),this._worker.error(x)}}d.prototype={accumulate:function(y){return function f(y,g){return new h.Promise(function(_,p){var x=[],E=y._internalType,T=y._outputType,A=y._mimeType;y.on("data",function(M,S){x.push(M),g&&g(S)}).on("error",function(M){x=[],p(M)}).on("end",function(){try{var M=function(S,z,O){switch(S){case"blob":return n.newBlob(n.transformTo("arraybuffer",z),O);case"base64":return l.encode(z);default:return n.transformTo(S,z)}}(T,function(S,z){var O,N=0,Z=null,P=0;for(O=0;O<z.length;O++)P+=z[O].length;switch(S){case"string":return z.join("");case"array":return Array.prototype.concat.apply([],z);case"uint8array":for(Z=new Uint8Array(P),O=0;O<z.length;O++)Z.set(z[O],N),N+=z[O].length;return Z;case"nodebuffer":return Buffer.concat(z);default:throw new Error("concat : unsupported type '"+S+"'")}}(E,x),A);_(M)}catch(S){p(S)}x=[]}).resume()})}(this,y)},on:function(y,g){var _=this;return this._worker.on(y,"data"===y?function(p){g.call(_,p.data,p.meta)}:function(){n.delay(g,arguments,_)}),this},resume:function(){return n.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(y){if(n.checkSupport("nodestream"),"nodebuffer"!==this._outputType)throw new Error(this._outputType+" is not supported by this method");return new u(this,{objectMode:"nodebuffer"!==this._outputType},y)}},i.exports=d},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(t,i,s){if(s.base64=!0,s.array=!0,s.string=!0,s.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",s.nodebuffer=typeof Buffer<"u",s.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")s.blob=!1;else{var n=new ArrayBuffer(0);try{s.blob=0===new Blob([n],{type:"application/zip"}).size}catch{try{var r=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);r.append(n),s.blob=0===r.getBlob("application/zip").size}catch{s.blob=!1}}}try{s.nodestream=!!t("readable-stream").Readable}catch{s.nodestream=!1}},{"readable-stream":16}],31:[function(t,i,s){for(var n=t("./utils"),r=t("./support"),a=t("./nodejsUtils"),l=t("./stream/GenericWorker"),c=new Array(256),h=0;h<256;h++)c[h]=252<=h?6:248<=h?5:240<=h?4:224<=h?3:192<=h?2:1;function u(){l.call(this,"utf-8 decode"),this.leftOver=null}function f(){l.call(this,"utf-8 encode")}c[254]=c[254]=1,s.utf8encode=function(d){return r.nodebuffer?a.newBufferFrom(d,"utf-8"):function(y){var g,_,p,x,E,T=y.length,A=0;for(x=0;x<T;x++)55296==(64512&(_=y.charCodeAt(x)))&&x+1<T&&56320==(64512&(p=y.charCodeAt(x+1)))&&(_=65536+(_-55296<<10)+(p-56320),x++),A+=_<128?1:_<2048?2:_<65536?3:4;for(g=r.uint8array?new Uint8Array(A):new Array(A),x=E=0;E<A;x++)55296==(64512&(_=y.charCodeAt(x)))&&x+1<T&&56320==(64512&(p=y.charCodeAt(x+1)))&&(_=65536+(_-55296<<10)+(p-56320),x++),_<128?g[E++]=_:(_<2048?g[E++]=192|_>>>6:(_<65536?g[E++]=224|_>>>12:(g[E++]=240|_>>>18,g[E++]=128|_>>>12&63),g[E++]=128|_>>>6&63),g[E++]=128|63&_);return g}(d)},s.utf8decode=function(d){return r.nodebuffer?n.transformTo("nodebuffer",d).toString("utf-8"):function(y){var g,_,p,x,E=y.length,T=new Array(2*E);for(g=_=0;g<E;)if((p=y[g++])<128)T[_++]=p;else if(4<(x=c[p]))T[_++]=65533,g+=x-1;else{for(p&=2===x?31:3===x?15:7;1<x&&g<E;)p=p<<6|63&y[g++],x--;1<x?T[_++]=65533:p<65536?T[_++]=p:(T[_++]=55296|(p-=65536)>>10&1023,T[_++]=56320|1023&p)}return T.length!==_&&(T.subarray?T=T.subarray(0,_):T.length=_),n.applyFromCharCode(T)}(d=n.transformTo(r.uint8array?"uint8array":"array",d))},n.inherits(u,l),u.prototype.processChunk=function(d){var y=n.transformTo(r.uint8array?"uint8array":"array",d.data);if(this.leftOver&&this.leftOver.length){if(r.uint8array){var g=y;(y=new Uint8Array(g.length+this.leftOver.length)).set(this.leftOver,0),y.set(g,this.leftOver.length)}else y=this.leftOver.concat(y);this.leftOver=null}var _=function(x,E){var T;for((E=E||x.length)>x.length&&(E=x.length),T=E-1;0<=T&&128==(192&x[T]);)T--;return T<0||0===T?E:T+c[x[T]]>E?T:E}(y),p=y;_!==y.length&&(r.uint8array?(p=y.subarray(0,_),this.leftOver=y.subarray(_,y.length)):(p=y.slice(0,_),this.leftOver=y.slice(_,y.length))),this.push({data:s.utf8decode(p),meta:d.meta})},u.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:s.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},s.Utf8DecodeWorker=u,n.inherits(f,l),f.prototype.processChunk=function(d){this.push({data:s.utf8encode(d.data),meta:d.meta})},s.Utf8EncodeWorker=f},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(t,i,s){var n=t("./support"),r=t("./base64"),a=t("./nodejsUtils"),l=t("./external");function c(g){return g}function h(g,_){for(var p=0;p<g.length;++p)_[p]=255&g.charCodeAt(p);return _}t("setimmediate"),s.newBlob=function(g,_){s.checkSupport("blob");try{return new Blob([g],{type:_})}catch{try{var p=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return p.append(g),p.getBlob(_)}catch{throw new Error("Bug : can't construct the Blob.")}}};var u={stringifyByChunk:function(g,_,p){var x=[],E=0,T=g.length;if(T<=p)return String.fromCharCode.apply(null,g);for(;E<T;)x.push(String.fromCharCode.apply(null,"array"===_||"nodebuffer"===_?g.slice(E,Math.min(E+p,T)):g.subarray(E,Math.min(E+p,T)))),E+=p;return x.join("")},stringifyByChar:function(g){for(var _="",p=0;p<g.length;p++)_+=String.fromCharCode(g[p]);return _},applyCanBeUsed:{uint8array:function(){try{return n.uint8array&&1===String.fromCharCode.apply(null,new Uint8Array(1)).length}catch{return!1}}(),nodebuffer:function(){try{return n.nodebuffer&&1===String.fromCharCode.apply(null,a.allocBuffer(1)).length}catch{return!1}}()}};function f(g){var _=65536,p=s.getTypeOf(g),x=!0;if("uint8array"===p?x=u.applyCanBeUsed.uint8array:"nodebuffer"===p&&(x=u.applyCanBeUsed.nodebuffer),x)for(;1<_;)try{return u.stringifyByChunk(g,p,_)}catch{_=Math.floor(_/2)}return u.stringifyByChar(g)}function d(g,_){for(var p=0;p<g.length;p++)_[p]=g[p];return _}s.applyFromCharCode=f;var y={};y.string={string:c,array:function(g){return h(g,new Array(g.length))},arraybuffer:function(g){return y.string.uint8array(g).buffer},uint8array:function(g){return h(g,new Uint8Array(g.length))},nodebuffer:function(g){return h(g,a.allocBuffer(g.length))}},y.array={string:f,array:c,arraybuffer:function(g){return new Uint8Array(g).buffer},uint8array:function(g){return new Uint8Array(g)},nodebuffer:function(g){return a.newBufferFrom(g)}},y.arraybuffer={string:function(g){return f(new Uint8Array(g))},array:function(g){return d(new Uint8Array(g),new Array(g.byteLength))},arraybuffer:c,uint8array:function(g){return new Uint8Array(g)},nodebuffer:function(g){return a.newBufferFrom(new Uint8Array(g))}},y.uint8array={string:f,array:function(g){return d(g,new Array(g.length))},arraybuffer:function(g){return g.buffer},uint8array:c,nodebuffer:function(g){return a.newBufferFrom(g)}},y.nodebuffer={string:f,array:function(g){return d(g,new Array(g.length))},arraybuffer:function(g){return y.nodebuffer.uint8array(g).buffer},uint8array:function(g){return d(g,new Uint8Array(g.length))},nodebuffer:c},s.transformTo=function(g,_){if(_=_||"",!g)return _;s.checkSupport(g);var p=s.getTypeOf(_);return y[p][g](_)},s.resolve=function(g){for(var _=g.split("/"),p=[],x=0;x<_.length;x++){var E=_[x];"."===E||""===E&&0!==x&&x!==_.length-1||(".."===E?p.pop():p.push(E))}return p.join("/")},s.getTypeOf=function(g){return"string"==typeof g?"string":"[object Array]"===Object.prototype.toString.call(g)?"array":n.nodebuffer&&a.isBuffer(g)?"nodebuffer":n.uint8array&&g instanceof Uint8Array?"uint8array":n.arraybuffer&&g instanceof ArrayBuffer?"arraybuffer":void 0},s.checkSupport=function(g){if(!n[g.toLowerCase()])throw new Error(g+" is not supported by this platform")},s.MAX_VALUE_16BITS=65535,s.MAX_VALUE_32BITS=-1,s.pretty=function(g){var _,p,x="";for(p=0;p<(g||"").length;p++)x+="\\x"+((_=g.charCodeAt(p))<16?"0":"")+_.toString(16).toUpperCase();return x},s.delay=function(g,_,p){setImmediate(function(){g.apply(p||null,_||[])})},s.inherits=function(g,_){function p(){}p.prototype=_.prototype,g.prototype=new p},s.extend=function(){var g,_,p={};for(g=0;g<arguments.length;g++)for(_ in arguments[g])Object.prototype.hasOwnProperty.call(arguments[g],_)&&void 0===p[_]&&(p[_]=arguments[g][_]);return p},s.prepareContent=function(g,_,p,x,E){return l.Promise.resolve(_).then(function(T){return n.blob&&(T instanceof Blob||-1!==["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(T)))&&typeof FileReader<"u"?new l.Promise(function(A,M){var S=new FileReader;S.onload=function(z){A(z.target.result)},S.onerror=function(z){M(z.target.error)},S.readAsArrayBuffer(T)}):T}).then(function(T){var M,A=s.getTypeOf(T);return A?("arraybuffer"===A?T=s.transformTo("uint8array",T):"string"===A&&(E?T=r.decode(T):p&&!0!==x&&(T=h(M=T,n.uint8array?new Uint8Array(M.length):new Array(M.length)))),T):l.Promise.reject(new Error("Can't read the data of '"+g+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(t,i,s){var n=t("./reader/readerFor"),r=t("./utils"),a=t("./signature"),l=t("./zipEntry"),c=t("./support");function h(u){this.files=[],this.loadOptions=u}h.prototype={checkSignature:function(u){if(!this.reader.readAndCheckSignature(u)){this.reader.index-=4;var f=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+r.pretty(f)+", expected "+r.pretty(u)+")")}},isSignature:function(u,f){var d=this.reader.index;this.reader.setIndex(u);var y=this.reader.readString(4)===f;return this.reader.setIndex(d),y},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var u=this.reader.readData(this.zipCommentLength),d=r.transformTo(c.uint8array?"uint8array":"array",u);this.zipComment=this.loadOptions.decodeFileName(d)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var u,f,d,y=this.zip64EndOfCentralSize-44;0<y;)u=this.reader.readInt(2),f=this.reader.readInt(4),d=this.reader.readData(f),this.zip64ExtensibleData[u]={id:u,length:f,value:d}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var u,f;for(u=0;u<this.files.length;u++)this.reader.setIndex((f=this.files[u]).localHeaderOffset),this.checkSignature(a.LOCAL_FILE_HEADER),f.readLocalPart(this.reader),f.handleUTF8(),f.processAttributes()},readCentralDir:function(){var u;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(a.CENTRAL_FILE_HEADER);)(u=new l({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(u);if(this.centralDirRecords!==this.files.length&&0!==this.centralDirRecords&&0===this.files.length)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var u=this.reader.lastIndexOfSignature(a.CENTRAL_DIRECTORY_END);if(u<0)throw this.isSignature(0,a.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(u);var f=u;if(this.checkSignature(a.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===r.MAX_VALUE_16BITS||this.diskWithCentralDirStart===r.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===r.MAX_VALUE_16BITS||this.centralDirRecords===r.MAX_VALUE_16BITS||this.centralDirSize===r.MAX_VALUE_32BITS||this.centralDirOffset===r.MAX_VALUE_32BITS){if(this.zip64=!0,(u=this.reader.lastIndexOfSignature(a.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(u),this.checkSignature(a.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,a.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(a.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(a.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var d=this.centralDirOffset+this.centralDirSize;this.zip64&&(d+=20,d+=12+this.zip64EndOfCentralSize);var y=f-d;if(0<y)this.isSignature(f,a.CENTRAL_FILE_HEADER)||(this.reader.zero=y);else if(y<0)throw new Error("Corrupted zip: missing "+Math.abs(y)+" bytes.")},prepareReader:function(u){this.reader=n(u)},load:function(u){this.prepareReader(u),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},i.exports=h},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(t,i,s){var n=t("./reader/readerFor"),r=t("./utils"),a=t("./compressedObject"),l=t("./crc32"),c=t("./utf8"),h=t("./compressions"),u=t("./support");function f(d,y){this.options=d,this.loadOptions=y}f.prototype={isEncrypted:function(){return!(1&~this.bitFlag)},useUTF8:function(){return!(2048&~this.bitFlag)},readLocalPart:function(d){var y,g;if(d.skip(22),this.fileNameLength=d.readInt(2),g=d.readInt(2),this.fileName=d.readData(this.fileNameLength),d.skip(g),-1===this.compressedSize||-1===this.uncompressedSize)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if(null===(y=function(_){for(var p in h)if(Object.prototype.hasOwnProperty.call(h,p)&&h[p].magic===_)return h[p];return null}(this.compressionMethod)))throw new Error("Corrupted zip : compression "+r.pretty(this.compressionMethod)+" unknown (inner file : "+r.transformTo("string",this.fileName)+")");this.decompressed=new a(this.compressedSize,this.uncompressedSize,this.crc32,y,d.readData(this.compressedSize))},readCentralPart:function(d){this.versionMadeBy=d.readInt(2),d.skip(2),this.bitFlag=d.readInt(2),this.compressionMethod=d.readString(2),this.date=d.readDate(),this.crc32=d.readInt(4),this.compressedSize=d.readInt(4),this.uncompressedSize=d.readInt(4);var y=d.readInt(2);if(this.extraFieldsLength=d.readInt(2),this.fileCommentLength=d.readInt(2),this.diskNumberStart=d.readInt(2),this.internalFileAttributes=d.readInt(2),this.externalFileAttributes=d.readInt(4),this.localHeaderOffset=d.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");d.skip(y),this.readExtraFields(d),this.parseZIP64ExtraField(d),this.fileComment=d.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var d=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),0==d&&(this.dosPermissions=63&this.externalFileAttributes),3==d&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||"/"!==this.fileNameStr.slice(-1)||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var d=n(this.extraFields[1].value);this.uncompressedSize===r.MAX_VALUE_32BITS&&(this.uncompressedSize=d.readInt(8)),this.compressedSize===r.MAX_VALUE_32BITS&&(this.compressedSize=d.readInt(8)),this.localHeaderOffset===r.MAX_VALUE_32BITS&&(this.localHeaderOffset=d.readInt(8)),this.diskNumberStart===r.MAX_VALUE_32BITS&&(this.diskNumberStart=d.readInt(4))}},readExtraFields:function(d){var y,g,_,p=d.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});d.index+4<p;)y=d.readInt(2),g=d.readInt(2),_=d.readData(g),this.extraFields[y]={id:y,length:g,value:_};d.setIndex(p)},handleUTF8:function(){var d=u.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=c.utf8decode(this.fileName),this.fileCommentStr=c.utf8decode(this.fileComment);else{var y=this.findExtraFieldUnicodePath();if(null!==y)this.fileNameStr=y;else{var g=r.transformTo(d,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(g)}var _=this.findExtraFieldUnicodeComment();if(null!==_)this.fileCommentStr=_;else{var p=r.transformTo(d,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(p)}}},findExtraFieldUnicodePath:function(){var d=this.extraFields[28789];if(d){var y=n(d.value);return 1!==y.readInt(1)||l(this.fileName)!==y.readInt(4)?null:c.utf8decode(y.readData(d.length-5))}return null},findExtraFieldUnicodeComment:function(){var d=this.extraFields[25461];if(d){var y=n(d.value);return 1!==y.readInt(1)||l(this.fileComment)!==y.readInt(4)?null:c.utf8decode(y.readData(d.length-5))}return null}},i.exports=f},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(t,i,s){function n(y,g,_){this.name=y,this.dir=_.dir,this.date=_.date,this.comment=_.comment,this.unixPermissions=_.unixPermissions,this.dosPermissions=_.dosPermissions,this._data=g,this._dataBinary=_.binary,this.options={compression:_.compression,compressionOptions:_.compressionOptions}}var r=t("./stream/StreamHelper"),a=t("./stream/DataWorker"),l=t("./utf8"),c=t("./compressedObject"),h=t("./stream/GenericWorker");n.prototype={internalStream:function(y){var g=null,_="string";try{if(!y)throw new Error("No output type specified.");var p="string"===(_=y.toLowerCase())||"text"===_;"binarystring"!==_&&"text"!==_||(_="string"),g=this._decompressWorker();var x=!this._dataBinary;x&&!p&&(g=g.pipe(new l.Utf8EncodeWorker)),!x&&p&&(g=g.pipe(new l.Utf8DecodeWorker))}catch(E){(g=new h("error")).error(E)}return new r(g,_,"")},async:function(y,g){return this.internalStream(y).accumulate(g)},nodeStream:function(y,g){return this.internalStream(y||"nodebuffer").toNodejsStream(g)},_compressWorker:function(y,g){if(this._data instanceof c&&this._data.compression.magic===y.magic)return this._data.getCompressedWorker();var _=this._decompressWorker();return this._dataBinary||(_=_.pipe(new l.Utf8EncodeWorker)),c.createWorkerFrom(_,y,g)},_decompressWorker:function(){return this._data instanceof c?this._data.getContentWorker():this._data instanceof h?this._data:new a(this._data)}};for(var u=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],f=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},d=0;d<u.length;d++)n.prototype[u[d]]=f;i.exports=n},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(t,i,s){(function(n){var r,a,l=n.MutationObserver||n.WebKitMutationObserver;if(l){var c=0,h=new l(y),u=n.document.createTextNode("");h.observe(u,{characterData:!0}),r=function(){u.data=c=++c%2}}else if(n.setImmediate||void 0===n.MessageChannel)r="document"in n&&"onreadystatechange"in n.document.createElement("script")?function(){var g=n.document.createElement("script");g.onreadystatechange=function(){y(),g.onreadystatechange=null,g.parentNode.removeChild(g),g=null},n.document.documentElement.appendChild(g)}:function(){setTimeout(y,0)};else{var f=new n.MessageChannel;f.port1.onmessage=y,r=function(){f.port2.postMessage(0)}}var d=[];function y(){var g,_;a=!0;for(var p=d.length;p;){for(_=d,d=[],g=-1;++g<p;)_[g]();p=d.length}a=!1}i.exports=function(g){1!==d.push(g)||a||r()}}).call(this,typeof qi<"u"?qi:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(t,i,s){var n=t("immediate");function r(){}var a={},l=["REJECTED"],c=["FULFILLED"],h=["PENDING"];function u(p){if("function"!=typeof p)throw new TypeError("resolver must be a function");this.state=h,this.queue=[],this.outcome=void 0,p!==r&&g(this,p)}function f(p,x,E){this.promise=p,"function"==typeof x&&(this.onFulfilled=x,this.callFulfilled=this.otherCallFulfilled),"function"==typeof E&&(this.onRejected=E,this.callRejected=this.otherCallRejected)}function d(p,x,E){n(function(){var T;try{T=x(E)}catch(A){return a.reject(p,A)}T===p?a.reject(p,new TypeError("Cannot resolve promise with itself")):a.resolve(p,T)})}function y(p){var x=p&&p.then;if(p&&("object"==typeof p||"function"==typeof p)&&"function"==typeof x)return function(){x.apply(p,arguments)}}function g(p,x){var E=!1;function T(S){E||(E=!0,a.reject(p,S))}function A(S){E||(E=!0,a.resolve(p,S))}var M=_(function(){x(A,T)});"error"===M.status&&T(M.value)}function _(p,x){var E={};try{E.value=p(x),E.status="success"}catch(T){E.status="error",E.value=T}return E}(i.exports=u).prototype.finally=function(p){if("function"!=typeof p)return this;var x=this.constructor;return this.then(function(E){return x.resolve(p()).then(function(){return E})},function(E){return x.resolve(p()).then(function(){throw E})})},u.prototype.catch=function(p){return this.then(null,p)},u.prototype.then=function(p,x){if("function"!=typeof p&&this.state===c||"function"!=typeof x&&this.state===l)return this;var E=new this.constructor(r);return this.state!==h?d(E,this.state===c?p:x,this.outcome):this.queue.push(new f(E,p,x)),E},f.prototype.callFulfilled=function(p){a.resolve(this.promise,p)},f.prototype.otherCallFulfilled=function(p){d(this.promise,this.onFulfilled,p)},f.prototype.callRejected=function(p){a.reject(this.promise,p)},f.prototype.otherCallRejected=function(p){d(this.promise,this.onRejected,p)},a.resolve=function(p,x){var E=_(y,x);if("error"===E.status)return a.reject(p,E.value);var T=E.value;if(T)g(p,T);else{p.state=c,p.outcome=x;for(var A=-1,M=p.queue.length;++A<M;)p.queue[A].callFulfilled(x)}return p},a.reject=function(p,x){p.state=l,p.outcome=x;for(var E=-1,T=p.queue.length;++E<T;)p.queue[E].callRejected(x);return p},u.resolve=function(p){return p instanceof this?p:a.resolve(new this(r),p)},u.reject=function(p){var x=new this(r);return a.reject(x,p)},u.all=function(p){var x=this;if("[object Array]"!==Object.prototype.toString.call(p))return this.reject(new TypeError("must be an array"));var E=p.length,T=!1;if(!E)return this.resolve([]);for(var A=new Array(E),M=0,S=-1,z=new this(r);++S<E;)O(p[S],S);return z;function O(N,Z){x.resolve(N).then(function(P){A[Z]=P,++M!==E||T||(T=!0,a.resolve(z,A))},function(P){T||(T=!0,a.reject(z,P))})}},u.race=function(p){if("[object Array]"!==Object.prototype.toString.call(p))return this.reject(new TypeError("must be an array"));var E=p.length,T=!1;if(!E)return this.resolve([]);for(var A=-1,M=new this(r);++A<E;)this.resolve(p[A]).then(function(z){T||(T=!0,a.resolve(M,z))},function(z){T||(T=!0,a.reject(M,z))});return M}},{immediate:36}],38:[function(t,i,s){var n={};(0,t("./lib/utils/common").assign)(n,t("./lib/deflate"),t("./lib/inflate"),t("./lib/zlib/constants")),i.exports=n},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(t,i,s){var n=t("./zlib/deflate"),r=t("./utils/common"),a=t("./utils/strings"),l=t("./zlib/messages"),c=t("./zlib/zstream"),h=Object.prototype.toString;function g(p){if(!(this instanceof g))return new g(p);this.options=r.assign({level:-1,method:8,chunkSize:16384,windowBits:15,memLevel:8,strategy:0,to:""},p||{});var x=this.options;x.raw&&0<x.windowBits?x.windowBits=-x.windowBits:x.gzip&&0<x.windowBits&&x.windowBits<16&&(x.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new c,this.strm.avail_out=0;var E=n.deflateInit2(this.strm,x.level,x.method,x.windowBits,x.memLevel,x.strategy);if(0!==E)throw new Error(l[E]);if(x.header&&n.deflateSetHeader(this.strm,x.header),x.dictionary){var T;if(T="string"==typeof x.dictionary?a.string2buf(x.dictionary):"[object ArrayBuffer]"===h.call(x.dictionary)?new Uint8Array(x.dictionary):x.dictionary,0!==(E=n.deflateSetDictionary(this.strm,T)))throw new Error(l[E]);this._dict_set=!0}}function _(p,x){var E=new g(x);if(E.push(p,!0),E.err)throw E.msg||l[E.err];return E.result}g.prototype.push=function(p,x){var E,T,A=this.strm,M=this.options.chunkSize;if(this.ended)return!1;T=x===~~x?x:!0===x?4:0,A.input="string"==typeof p?a.string2buf(p):"[object ArrayBuffer]"===h.call(p)?new Uint8Array(p):p,A.next_in=0,A.avail_in=A.input.length;do{if(0===A.avail_out&&(A.output=new r.Buf8(M),A.next_out=0,A.avail_out=M),1!==(E=n.deflate(A,T))&&0!==E)return this.onEnd(E),!(this.ended=!0);0!==A.avail_out&&(0!==A.avail_in||4!==T&&2!==T)||this.onData("string"===this.options.to?a.buf2binstring(r.shrinkBuf(A.output,A.next_out)):r.shrinkBuf(A.output,A.next_out))}while((0<A.avail_in||0===A.avail_out)&&1!==E);return 4===T?(E=n.deflateEnd(this.strm),this.onEnd(E),this.ended=!0,0===E):2!==T||(this.onEnd(0),!(A.avail_out=0))},g.prototype.onData=function(p){this.chunks.push(p)},g.prototype.onEnd=function(p){0===p&&(this.result="string"===this.options.to?this.chunks.join(""):r.flattenChunks(this.chunks)),this.chunks=[],this.err=p,this.msg=this.strm.msg},s.Deflate=g,s.deflate=_,s.deflateRaw=function(p,x){return(x=x||{}).raw=!0,_(p,x)},s.gzip=function(p,x){return(x=x||{}).gzip=!0,_(p,x)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(t,i,s){var n=t("./zlib/inflate"),r=t("./utils/common"),a=t("./utils/strings"),l=t("./zlib/constants"),c=t("./zlib/messages"),h=t("./zlib/zstream"),u=t("./zlib/gzheader"),f=Object.prototype.toString;function d(g){if(!(this instanceof d))return new d(g);this.options=r.assign({chunkSize:16384,windowBits:0,to:""},g||{});var _=this.options;_.raw&&0<=_.windowBits&&_.windowBits<16&&(_.windowBits=-_.windowBits,0===_.windowBits&&(_.windowBits=-15)),!(0<=_.windowBits&&_.windowBits<16)||g&&g.windowBits||(_.windowBits+=32),15<_.windowBits&&_.windowBits<48&&!(15&_.windowBits)&&(_.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new h,this.strm.avail_out=0;var p=n.inflateInit2(this.strm,_.windowBits);if(p!==l.Z_OK)throw new Error(c[p]);this.header=new u,n.inflateGetHeader(this.strm,this.header)}function y(g,_){var p=new d(_);if(p.push(g,!0),p.err)throw p.msg||c[p.err];return p.result}d.prototype.push=function(g,_){var p,x,E,T,A,M,S=this.strm,z=this.options.chunkSize,O=this.options.dictionary,N=!1;if(this.ended)return!1;x=_===~~_?_:!0===_?l.Z_FINISH:l.Z_NO_FLUSH,S.input="string"==typeof g?a.binstring2buf(g):"[object ArrayBuffer]"===f.call(g)?new Uint8Array(g):g,S.next_in=0,S.avail_in=S.input.length;do{if(0===S.avail_out&&(S.output=new r.Buf8(z),S.next_out=0,S.avail_out=z),(p=n.inflate(S,l.Z_NO_FLUSH))===l.Z_NEED_DICT&&O&&(M="string"==typeof O?a.string2buf(O):"[object ArrayBuffer]"===f.call(O)?new Uint8Array(O):O,p=n.inflateSetDictionary(this.strm,M)),p===l.Z_BUF_ERROR&&!0===N&&(p=l.Z_OK,N=!1),p!==l.Z_STREAM_END&&p!==l.Z_OK)return this.onEnd(p),!(this.ended=!0);S.next_out&&(0!==S.avail_out&&p!==l.Z_STREAM_END&&(0!==S.avail_in||x!==l.Z_FINISH&&x!==l.Z_SYNC_FLUSH)||("string"===this.options.to?(E=a.utf8border(S.output,S.next_out),T=S.next_out-E,A=a.buf2string(S.output,E),S.next_out=T,S.avail_out=z-T,T&&r.arraySet(S.output,S.output,E,T,0),this.onData(A)):this.onData(r.shrinkBuf(S.output,S.next_out)))),0===S.avail_in&&0===S.avail_out&&(N=!0)}while((0<S.avail_in||0===S.avail_out)&&p!==l.Z_STREAM_END);return p===l.Z_STREAM_END&&(x=l.Z_FINISH),x===l.Z_FINISH?(p=n.inflateEnd(this.strm),this.onEnd(p),this.ended=!0,p===l.Z_OK):x!==l.Z_SYNC_FLUSH||(this.onEnd(l.Z_OK),!(S.avail_out=0))},d.prototype.onData=function(g){this.chunks.push(g)},d.prototype.onEnd=function(g){g===l.Z_OK&&(this.result="string"===this.options.to?this.chunks.join(""):r.flattenChunks(this.chunks)),this.chunks=[],this.err=g,this.msg=this.strm.msg},s.Inflate=d,s.inflate=y,s.inflateRaw=function(g,_){return(_=_||{}).raw=!0,y(g,_)},s.ungzip=y},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(t,i,s){var n=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";s.assign=function(l){for(var c=Array.prototype.slice.call(arguments,1);c.length;){var h=c.shift();if(h){if("object"!=typeof h)throw new TypeError(h+"must be non-object");for(var u in h)h.hasOwnProperty(u)&&(l[u]=h[u])}}return l},s.shrinkBuf=function(l,c){return l.length===c?l:l.subarray?l.subarray(0,c):(l.length=c,l)};var r={arraySet:function(l,c,h,u,f){if(c.subarray&&l.subarray)l.set(c.subarray(h,h+u),f);else for(var d=0;d<u;d++)l[f+d]=c[h+d]},flattenChunks:function(l){var c,h,u,f,d,y;for(c=u=0,h=l.length;c<h;c++)u+=l[c].length;for(y=new Uint8Array(u),c=f=0,h=l.length;c<h;c++)y.set(d=l[c],f),f+=d.length;return y}},a={arraySet:function(l,c,h,u,f){for(var d=0;d<u;d++)l[f+d]=c[h+d]},flattenChunks:function(l){return[].concat.apply([],l)}};s.setTyped=function(l){l?(s.Buf8=Uint8Array,s.Buf16=Uint16Array,s.Buf32=Int32Array,s.assign(s,r)):(s.Buf8=Array,s.Buf16=Array,s.Buf32=Array,s.assign(s,a))},s.setTyped(n)},{}],42:[function(t,i,s){var n=t("./common"),r=!0,a=!0;try{String.fromCharCode.apply(null,[0])}catch{r=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{a=!1}for(var l=new n.Buf8(256),c=0;c<256;c++)l[c]=252<=c?6:248<=c?5:240<=c?4:224<=c?3:192<=c?2:1;function h(u,f){if(f<65537&&(u.subarray&&a||!u.subarray&&r))return String.fromCharCode.apply(null,n.shrinkBuf(u,f));for(var d="",y=0;y<f;y++)d+=String.fromCharCode(u[y]);return d}l[254]=l[254]=1,s.string2buf=function(u){var f,d,y,g,_,p=u.length,x=0;for(g=0;g<p;g++)55296==(64512&(d=u.charCodeAt(g)))&&g+1<p&&56320==(64512&(y=u.charCodeAt(g+1)))&&(d=65536+(d-55296<<10)+(y-56320),g++),x+=d<128?1:d<2048?2:d<65536?3:4;for(f=new n.Buf8(x),g=_=0;_<x;g++)55296==(64512&(d=u.charCodeAt(g)))&&g+1<p&&56320==(64512&(y=u.charCodeAt(g+1)))&&(d=65536+(d-55296<<10)+(y-56320),g++),d<128?f[_++]=d:(d<2048?f[_++]=192|d>>>6:(d<65536?f[_++]=224|d>>>12:(f[_++]=240|d>>>18,f[_++]=128|d>>>12&63),f[_++]=128|d>>>6&63),f[_++]=128|63&d);return f},s.buf2binstring=function(u){return h(u,u.length)},s.binstring2buf=function(u){for(var f=new n.Buf8(u.length),d=0,y=f.length;d<y;d++)f[d]=u.charCodeAt(d);return f},s.buf2string=function(u,f){var d,y,g,_,p=f||u.length,x=new Array(2*p);for(d=y=0;d<p;)if((g=u[d++])<128)x[y++]=g;else if(4<(_=l[g]))x[y++]=65533,d+=_-1;else{for(g&=2===_?31:3===_?15:7;1<_&&d<p;)g=g<<6|63&u[d++],_--;1<_?x[y++]=65533:g<65536?x[y++]=g:(x[y++]=55296|(g-=65536)>>10&1023,x[y++]=56320|1023&g)}return h(x,y)},s.utf8border=function(u,f){var d;for((f=f||u.length)>u.length&&(f=u.length),d=f-1;0<=d&&128==(192&u[d]);)d--;return d<0||0===d?f:d+l[u[d]]>f?d:f}},{"./common":41}],43:[function(t,i,s){i.exports=function(n,r,a,l){for(var c=65535&n,h=n>>>16&65535,u=0;0!==a;){for(a-=u=2e3<a?2e3:a;h=h+(c=c+r[l++]|0)|0,--u;);c%=65521,h%=65521}return c|h<<16}},{}],44:[function(t,i,s){i.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(t,i,s){var n=function(){for(var r,a=[],l=0;l<256;l++){r=l;for(var c=0;c<8;c++)r=1&r?3988292384^r>>>1:r>>>1;a[l]=r}return a}();i.exports=function(r,a,l,c){var h=n,u=c+l;r^=-1;for(var f=c;f<u;f++)r=r>>>8^h[255&(r^a[f])];return-1^r}},{}],46:[function(t,i,s){var n,r=t("../utils/common"),a=t("./trees"),l=t("./adler32"),c=t("./crc32"),h=t("./messages"),y=-2,N=258,Z=262,F=113;function rt(C,W){return C.msg=h[W],W}function Y(C){return(C<<1)-(4<C?9:0)}function ot(C){for(var W=C.length;0<=--W;)C[W]=0}function B(C){var W=C.state,$=W.pending;$>C.avail_out&&($=C.avail_out),0!==$&&(r.arraySet(C.output,W.pending_buf,W.pending_out,$,C.next_out),C.next_out+=$,W.pending_out+=$,C.total_out+=$,C.avail_out-=$,W.pending-=$,0===W.pending&&(W.pending_out=0))}function L(C,W){a._tr_flush_block(C,0<=C.block_start?C.block_start:-1,C.strstart-C.block_start,W),C.block_start=C.strstart,B(C.strm)}function it(C,W){C.pending_buf[C.pending++]=W}function et(C,W){C.pending_buf[C.pending++]=W>>>8&255,C.pending_buf[C.pending++]=255&W}function K(C,W){var $,k,I=C.max_chain_length,D=C.strstart,q=C.prev_length,G=C.nice_match,U=C.strstart>C.w_size-Z?C.strstart-(C.w_size-Z):0,J=C.window,nt=C.w_mask,tt=C.prev,at=C.strstart+N,Ct=J[D+q-1],pt=J[D+q];C.prev_length>=C.good_match&&(I>>=2),G>C.lookahead&&(G=C.lookahead);do{if(J[($=W)+q]===pt&&J[$+q-1]===Ct&&J[$]===J[D]&&J[++$]===J[D+1]){D+=2,$++;do{}while(J[++D]===J[++$]&&J[++D]===J[++$]&&J[++D]===J[++$]&&J[++D]===J[++$]&&J[++D]===J[++$]&&J[++D]===J[++$]&&J[++D]===J[++$]&&J[++D]===J[++$]&&D<at);if(k=N-(at-D),D=at-N,q<k){if(C.match_start=W,G<=(q=k))break;Ct=J[D+q-1],pt=J[D+q]}}}while((W=tt[W&nt])>U&&0!=--I);return q<=C.lookahead?q:C.lookahead}function gt(C){var W,$,k,I,D,q,G,U,J,nt,tt=C.w_size;do{if(I=C.window_size-C.lookahead-C.strstart,C.strstart>=tt+(tt-Z)){for(r.arraySet(C.window,C.window,tt,tt,0),C.match_start-=tt,C.strstart-=tt,C.block_start-=tt,W=$=C.hash_size;k=C.head[--W],C.head[W]=tt<=k?k-tt:0,--$;);for(W=$=tt;k=C.prev[--W],C.prev[W]=tt<=k?k-tt:0,--$;);I+=tt}if(0===C.strm.avail_in)break;if(G=C.window,U=C.strstart+C.lookahead,nt=void 0,(J=I)<(nt=(q=C.strm).avail_in)&&(nt=J),$=0===nt?0:(q.avail_in-=nt,r.arraySet(G,q.input,q.next_in,nt,U),1===q.state.wrap?q.adler=l(q.adler,G,nt,U):2===q.state.wrap&&(q.adler=c(q.adler,G,nt,U)),q.next_in+=nt,q.total_in+=nt,nt),C.lookahead+=$,C.lookahead+C.insert>=3)for(C.ins_h=C.window[D=C.strstart-C.insert],C.ins_h=(C.ins_h<<C.hash_shift^C.window[D+1])&C.hash_mask;C.insert&&(C.ins_h=(C.ins_h<<C.hash_shift^C.window[D+3-1])&C.hash_mask,C.prev[D&C.w_mask]=C.head[C.ins_h],C.head[C.ins_h]=D,D++,C.insert--,!(C.lookahead+C.insert<3)););}while(C.lookahead<Z&&0!==C.strm.avail_in)}function Ot(C,W){for(var $,k;;){if(C.lookahead<Z){if(gt(C),C.lookahead<Z&&0===W)return 1;if(0===C.lookahead)break}if($=0,C.lookahead>=3&&(C.ins_h=(C.ins_h<<C.hash_shift^C.window[C.strstart+3-1])&C.hash_mask,$=C.prev[C.strstart&C.w_mask]=C.head[C.ins_h],C.head[C.ins_h]=C.strstart),0!==$&&C.strstart-$<=C.w_size-Z&&(C.match_length=K(C,$)),C.match_length>=3)if(k=a._tr_tally(C,C.strstart-C.match_start,C.match_length-3),C.lookahead-=C.match_length,C.match_length<=C.max_lazy_match&&C.lookahead>=3){for(C.match_length--;C.strstart++,C.ins_h=(C.ins_h<<C.hash_shift^C.window[C.strstart+3-1])&C.hash_mask,$=C.prev[C.strstart&C.w_mask]=C.head[C.ins_h],C.head[C.ins_h]=C.strstart,0!=--C.match_length;);C.strstart++}else C.strstart+=C.match_length,C.match_length=0,C.ins_h=C.window[C.strstart],C.ins_h=(C.ins_h<<C.hash_shift^C.window[C.strstart+1])&C.hash_mask;else k=a._tr_tally(C,0,C.window[C.strstart]),C.lookahead--,C.strstart++;if(k&&(L(C,!1),0===C.strm.avail_out))return 1}return C.insert=C.strstart<2?C.strstart:2,4===W?(L(C,!0),0===C.strm.avail_out?3:4):C.last_lit&&(L(C,!1),0===C.strm.avail_out)?1:2}function ut(C,W){for(var $,k,I;;){if(C.lookahead<Z){if(gt(C),C.lookahead<Z&&0===W)return 1;if(0===C.lookahead)break}if($=0,C.lookahead>=3&&(C.ins_h=(C.ins_h<<C.hash_shift^C.window[C.strstart+3-1])&C.hash_mask,$=C.prev[C.strstart&C.w_mask]=C.head[C.ins_h],C.head[C.ins_h]=C.strstart),C.prev_length=C.match_length,C.prev_match=C.match_start,C.match_length=2,0!==$&&C.prev_length<C.max_lazy_match&&C.strstart-$<=C.w_size-Z&&(C.match_length=K(C,$),C.match_length<=5&&(1===C.strategy||3===C.match_length&&4096<C.strstart-C.match_start)&&(C.match_length=2)),C.prev_length>=3&&C.match_length<=C.prev_length){for(I=C.strstart+C.lookahead-3,k=a._tr_tally(C,C.strstart-1-C.prev_match,C.prev_length-3),C.lookahead-=C.prev_length-1,C.prev_length-=2;++C.strstart<=I&&(C.ins_h=(C.ins_h<<C.hash_shift^C.window[C.strstart+3-1])&C.hash_mask,$=C.prev[C.strstart&C.w_mask]=C.head[C.ins_h],C.head[C.ins_h]=C.strstart),0!=--C.prev_length;);if(C.match_available=0,C.match_length=2,C.strstart++,k&&(L(C,!1),0===C.strm.avail_out))return 1}else if(C.match_available){if((k=a._tr_tally(C,0,C.window[C.strstart-1]))&&L(C,!1),C.strstart++,C.lookahead--,0===C.strm.avail_out)return 1}else C.match_available=1,C.strstart++,C.lookahead--}return C.match_available&&(k=a._tr_tally(C,0,C.window[C.strstart-1]),C.match_available=0),C.insert=C.strstart<2?C.strstart:2,4===W?(L(C,!0),0===C.strm.avail_out?3:4):C.last_lit&&(L(C,!1),0===C.strm.avail_out)?1:2}function dt(C,W,$,k,I){this.good_length=C,this.max_lazy=W,this.nice_length=$,this.max_chain=k,this.func=I}function Pt(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=8,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new r.Buf16(1146),this.dyn_dtree=new r.Buf16(122),this.bl_tree=new r.Buf16(78),ot(this.dyn_ltree),ot(this.dyn_dtree),ot(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new r.Buf16(16),this.heap=new r.Buf16(573),ot(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new r.Buf16(573),ot(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function wt(C){var W;return C&&C.state?(C.total_in=C.total_out=0,C.data_type=2,(W=C.state).pending=0,W.pending_out=0,W.wrap<0&&(W.wrap=-W.wrap),W.status=W.wrap?42:F,C.adler=2===W.wrap?0:1,W.last_flush=0,a._tr_init(W),0):rt(C,y)}function jt(C){var $,W=wt(C);return 0===W&&(($=C.state).window_size=2*$.w_size,ot($.head),$.max_lazy_match=n[$.level].max_lazy,$.good_match=n[$.level].good_length,$.nice_match=n[$.level].nice_length,$.max_chain_length=n[$.level].max_chain,$.strstart=0,$.block_start=0,$.lookahead=0,$.insert=0,$.match_length=$.prev_length=2,$.match_available=0,$.ins_h=0),W}function Vt(C,W,$,k,I,D){if(!C)return y;var q=1;if(-1===W&&(W=6),k<0?(q=0,k=-k):15<k&&(q=2,k-=16),I<1||9<I||8!==$||k<8||15<k||W<0||9<W||D<0||4<D)return rt(C,y);8===k&&(k=9);var G=new Pt;return(C.state=G).strm=C,G.wrap=q,G.gzhead=null,G.w_bits=k,G.w_size=1<<G.w_bits,G.w_mask=G.w_size-1,G.hash_bits=I+7,G.hash_size=1<<G.hash_bits,G.hash_mask=G.hash_size-1,G.hash_shift=~~((G.hash_bits+3-1)/3),G.window=new r.Buf8(2*G.w_size),G.head=new r.Buf16(G.hash_size),G.prev=new r.Buf16(G.w_size),G.lit_bufsize=1<<I+6,G.pending_buf_size=4*G.lit_bufsize,G.pending_buf=new r.Buf8(G.pending_buf_size),G.d_buf=1*G.lit_bufsize,G.l_buf=3*G.lit_bufsize,G.level=W,G.strategy=D,G.method=$,jt(C)}n=[new dt(0,0,0,0,function(C,W){var $=65535;for($>C.pending_buf_size-5&&($=C.pending_buf_size-5);;){if(C.lookahead<=1){if(gt(C),0===C.lookahead&&0===W)return 1;if(0===C.lookahead)break}C.strstart+=C.lookahead,C.lookahead=0;var k=C.block_start+$;if((0===C.strstart||C.strstart>=k)&&(C.lookahead=C.strstart-k,C.strstart=k,L(C,!1),0===C.strm.avail_out)||C.strstart-C.block_start>=C.w_size-Z&&(L(C,!1),0===C.strm.avail_out))return 1}return C.insert=0,4===W?(L(C,!0),0===C.strm.avail_out?3:4):(C.strstart>C.block_start&&L(C,!1),1)}),new dt(4,4,8,4,Ot),new dt(4,5,16,8,Ot),new dt(4,6,32,32,Ot),new dt(4,4,16,16,ut),new dt(8,16,32,32,ut),new dt(8,16,128,128,ut),new dt(8,32,128,256,ut),new dt(32,128,258,1024,ut),new dt(32,258,258,4096,ut)],s.deflateInit=function(C,W){return Vt(C,W,8,15,8,0)},s.deflateInit2=Vt,s.deflateReset=jt,s.deflateResetKeep=wt,s.deflateSetHeader=function(C,W){return C&&C.state?2!==C.state.wrap?y:(C.state.gzhead=W,0):y},s.deflate=function(C,W){var $,k,I,D;if(!C||!C.state||5<W||W<0)return C?rt(C,y):y;if(k=C.state,!C.output||!C.input&&0!==C.avail_in||666===k.status&&4!==W)return rt(C,0===C.avail_out?-5:y);if(k.strm=C,$=k.last_flush,k.last_flush=W,42===k.status)if(2===k.wrap)C.adler=0,it(k,31),it(k,139),it(k,8),k.gzhead?(it(k,(k.gzhead.text?1:0)+(k.gzhead.hcrc?2:0)+(k.gzhead.extra?4:0)+(k.gzhead.name?8:0)+(k.gzhead.comment?16:0)),it(k,255&k.gzhead.time),it(k,k.gzhead.time>>8&255),it(k,k.gzhead.time>>16&255),it(k,k.gzhead.time>>24&255),it(k,9===k.level?2:2<=k.strategy||k.level<2?4:0),it(k,255&k.gzhead.os),k.gzhead.extra&&k.gzhead.extra.length&&(it(k,255&k.gzhead.extra.length),it(k,k.gzhead.extra.length>>8&255)),k.gzhead.hcrc&&(C.adler=c(C.adler,k.pending_buf,k.pending,0)),k.gzindex=0,k.status=69):(it(k,0),it(k,0),it(k,0),it(k,0),it(k,0),it(k,9===k.level?2:2<=k.strategy||k.level<2?4:0),it(k,3),k.status=F);else{var q=8+(k.w_bits-8<<4)<<8;q|=(2<=k.strategy||k.level<2?0:k.level<6?1:6===k.level?2:3)<<6,0!==k.strstart&&(q|=32),q+=31-q%31,k.status=F,et(k,q),0!==k.strstart&&(et(k,C.adler>>>16),et(k,65535&C.adler)),C.adler=1}if(69===k.status)if(k.gzhead.extra){for(I=k.pending;k.gzindex<(65535&k.gzhead.extra.length)&&(k.pending!==k.pending_buf_size||(k.gzhead.hcrc&&k.pending>I&&(C.adler=c(C.adler,k.pending_buf,k.pending-I,I)),B(C),I=k.pending,k.pending!==k.pending_buf_size));)it(k,255&k.gzhead.extra[k.gzindex]),k.gzindex++;k.gzhead.hcrc&&k.pending>I&&(C.adler=c(C.adler,k.pending_buf,k.pending-I,I)),k.gzindex===k.gzhead.extra.length&&(k.gzindex=0,k.status=73)}else k.status=73;if(73===k.status)if(k.gzhead.name){I=k.pending;do{if(k.pending===k.pending_buf_size&&(k.gzhead.hcrc&&k.pending>I&&(C.adler=c(C.adler,k.pending_buf,k.pending-I,I)),B(C),I=k.pending,k.pending===k.pending_buf_size)){D=1;break}D=k.gzindex<k.gzhead.name.length?255&k.gzhead.name.charCodeAt(k.gzindex++):0,it(k,D)}while(0!==D);k.gzhead.hcrc&&k.pending>I&&(C.adler=c(C.adler,k.pending_buf,k.pending-I,I)),0===D&&(k.gzindex=0,k.status=91)}else k.status=91;if(91===k.status)if(k.gzhead.comment){I=k.pending;do{if(k.pending===k.pending_buf_size&&(k.gzhead.hcrc&&k.pending>I&&(C.adler=c(C.adler,k.pending_buf,k.pending-I,I)),B(C),I=k.pending,k.pending===k.pending_buf_size)){D=1;break}D=k.gzindex<k.gzhead.comment.length?255&k.gzhead.comment.charCodeAt(k.gzindex++):0,it(k,D)}while(0!==D);k.gzhead.hcrc&&k.pending>I&&(C.adler=c(C.adler,k.pending_buf,k.pending-I,I)),0===D&&(k.status=103)}else k.status=103;if(103===k.status&&(k.gzhead.hcrc?(k.pending+2>k.pending_buf_size&&B(C),k.pending+2<=k.pending_buf_size&&(it(k,255&C.adler),it(k,C.adler>>8&255),C.adler=0,k.status=F)):k.status=F),0!==k.pending){if(B(C),0===C.avail_out)return k.last_flush=-1,0}else if(0===C.avail_in&&Y(W)<=Y($)&&4!==W)return rt(C,-5);if(666===k.status&&0!==C.avail_in)return rt(C,-5);if(0!==C.avail_in||0!==k.lookahead||0!==W&&666!==k.status){var G=2===k.strategy?function(U,J){for(var nt;;){if(0===U.lookahead&&(gt(U),0===U.lookahead)){if(0===J)return 1;break}if(U.match_length=0,nt=a._tr_tally(U,0,U.window[U.strstart]),U.lookahead--,U.strstart++,nt&&(L(U,!1),0===U.strm.avail_out))return 1}return U.insert=0,4===J?(L(U,!0),0===U.strm.avail_out?3:4):U.last_lit&&(L(U,!1),0===U.strm.avail_out)?1:2}(k,W):3===k.strategy?function(U,J){for(var nt,tt,at,Ct,pt=U.window;;){if(U.lookahead<=N){if(gt(U),U.lookahead<=N&&0===J)return 1;if(0===U.lookahead)break}if(U.match_length=0,U.lookahead>=3&&0<U.strstart&&(tt=pt[at=U.strstart-1])===pt[++at]&&tt===pt[++at]&&tt===pt[++at]){Ct=U.strstart+N;do{}while(tt===pt[++at]&&tt===pt[++at]&&tt===pt[++at]&&tt===pt[++at]&&tt===pt[++at]&&tt===pt[++at]&&tt===pt[++at]&&tt===pt[++at]&&at<Ct);U.match_length=N-(Ct-at),U.match_length>U.lookahead&&(U.match_length=U.lookahead)}if(U.match_length>=3?(nt=a._tr_tally(U,1,U.match_length-3),U.lookahead-=U.match_length,U.strstart+=U.match_length,U.match_length=0):(nt=a._tr_tally(U,0,U.window[U.strstart]),U.lookahead--,U.strstart++),nt&&(L(U,!1),0===U.strm.avail_out))return 1}return U.insert=0,4===J?(L(U,!0),0===U.strm.avail_out?3:4):U.last_lit&&(L(U,!1),0===U.strm.avail_out)?1:2}(k,W):n[k.level].func(k,W);if(3!==G&&4!==G||(k.status=666),1===G||3===G)return 0===C.avail_out&&(k.last_flush=-1),0;if(2===G&&(1===W?a._tr_align(k):5!==W&&(a._tr_stored_block(k,0,0,!1),3===W&&(ot(k.head),0===k.lookahead&&(k.strstart=0,k.block_start=0,k.insert=0))),B(C),0===C.avail_out))return k.last_flush=-1,0}return 4!==W?0:k.wrap<=0?1:(2===k.wrap?(it(k,255&C.adler),it(k,C.adler>>8&255),it(k,C.adler>>16&255),it(k,C.adler>>24&255),it(k,255&C.total_in),it(k,C.total_in>>8&255),it(k,C.total_in>>16&255),it(k,C.total_in>>24&255)):(et(k,C.adler>>>16),et(k,65535&C.adler)),B(C),0<k.wrap&&(k.wrap=-k.wrap),0!==k.pending?0:1)},s.deflateEnd=function(C){var W;return C&&C.state?42!==(W=C.state.status)&&69!==W&&73!==W&&91!==W&&103!==W&&W!==F&&666!==W?rt(C,y):(C.state=null,W===F?rt(C,-3):0):y},s.deflateSetDictionary=function(C,W){var $,k,I,D,q,G,U,J,nt=W.length;if(!C||!C.state||2===(D=($=C.state).wrap)||1===D&&42!==$.status||$.lookahead)return y;for(1===D&&(C.adler=l(C.adler,W,nt,0)),$.wrap=0,nt>=$.w_size&&(0===D&&(ot($.head),$.strstart=0,$.block_start=0,$.insert=0),J=new r.Buf8($.w_size),r.arraySet(J,W,nt-$.w_size,$.w_size,0),W=J,nt=$.w_size),q=C.avail_in,G=C.next_in,U=C.input,C.avail_in=nt,C.next_in=0,C.input=W,gt($);$.lookahead>=3;){for(k=$.strstart,I=$.lookahead-2;$.ins_h=($.ins_h<<$.hash_shift^$.window[k+3-1])&$.hash_mask,$.prev[k&$.w_mask]=$.head[$.ins_h],$.head[$.ins_h]=k,k++,--I;);$.strstart=k,$.lookahead=2,gt($)}return $.strstart+=$.lookahead,$.block_start=$.strstart,$.insert=$.lookahead,$.lookahead=0,$.match_length=$.prev_length=2,$.match_available=0,C.next_in=G,C.input=U,C.avail_in=q,$.wrap=D,0},s.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(t,i,s){i.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(t,i,s){i.exports=function(n,r){var a,l,c,h,u,f,d,y,g,_,p,x,E,T,A,M,S,z,O,N,Z,P,F,v,R;v=n.input,c=(l=n.next_in)+(n.avail_in-5),R=n.output,u=(h=n.next_out)-(r-n.avail_out),f=h+(n.avail_out-257),d=(a=n.state).dmax,y=a.wsize,g=a.whave,_=a.wnext,p=a.window,x=a.hold,E=a.bits,T=a.lencode,A=a.distcode,M=(1<<a.lenbits)-1,S=(1<<a.distbits)-1;t:do{E<15&&(x+=v[l++]<<E,x+=v[l++]<<(E+=8),E+=8),z=T[x&M];e:for(;;){if(x>>>=O=z>>>24,E-=O,0==(O=z>>>16&255))R[h++]=65535&z;else{if(!(16&O)){if(!(64&O)){z=T[(65535&z)+(x&(1<<O)-1)];continue e}if(32&O){a.mode=12;break t}n.msg="invalid literal/length code",a.mode=30;break t}N=65535&z,(O&=15)&&(E<O&&(x+=v[l++]<<E,E+=8),N+=x&(1<<O)-1,x>>>=O,E-=O),E<15&&(x+=v[l++]<<E,x+=v[l++]<<(E+=8),E+=8),z=A[x&S];i:for(;;){if(x>>>=O=z>>>24,E-=O,!(16&(O=z>>>16&255))){if(!(64&O)){z=A[(65535&z)+(x&(1<<O)-1)];continue i}n.msg="invalid distance code",a.mode=30;break t}if(Z=65535&z,E<(O&=15)&&(x+=v[l++]<<E,(E+=8)<O&&(x+=v[l++]<<E,E+=8)),d<(Z+=x&(1<<O)-1)){n.msg="invalid distance too far back",a.mode=30;break t}if(x>>>=O,E-=O,(O=h-u)<Z){if(g<(O=Z-O)&&a.sane){n.msg="invalid distance too far back",a.mode=30;break t}if(F=p,(P=0)===_){if(P+=y-O,O<N){for(N-=O;R[h++]=p[P++],--O;);P=h-Z,F=R}}else if(_<O){if(P+=y+_-O,(O-=_)<N){for(N-=O;R[h++]=p[P++],--O;);if(P=0,_<N){for(N-=O=_;R[h++]=p[P++],--O;);P=h-Z,F=R}}}else if(P+=_-O,O<N){for(N-=O;R[h++]=p[P++],--O;);P=h-Z,F=R}for(;2<N;)R[h++]=F[P++],R[h++]=F[P++],R[h++]=F[P++],N-=3;N&&(R[h++]=F[P++],1<N&&(R[h++]=F[P++]))}else{for(P=h-Z;R[h++]=R[P++],R[h++]=R[P++],R[h++]=R[P++],2<(N-=3););N&&(R[h++]=R[P++],1<N&&(R[h++]=R[P++]))}break}}break}}while(l<c&&h<f);l-=N=E>>3,x&=(1<<(E-=N<<3))-1,n.next_in=l,n.next_out=h,n.avail_in=l<c?c-l+5:5-(l-c),n.avail_out=h<f?f-h+257:257-(h-f),a.hold=x,a.bits=E}},{}],49:[function(t,i,s){var n=t("../utils/common"),r=t("./adler32"),a=t("./crc32"),l=t("./inffast"),c=t("./inftrees"),d=-2;function p(P){return(P>>>24&255)+(P>>>8&65280)+((65280&P)<<8)+((255&P)<<24)}function x(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new n.Buf16(320),this.work=new n.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function E(P){var F;return P&&P.state?(P.total_in=P.total_out=(F=P.state).total=0,P.msg="",F.wrap&&(P.adler=1&F.wrap),F.mode=1,F.last=0,F.havedict=0,F.dmax=32768,F.head=null,F.hold=0,F.bits=0,F.lencode=F.lendyn=new n.Buf32(852),F.distcode=F.distdyn=new n.Buf32(592),F.sane=1,F.back=-1,0):d}function T(P){var F;return P&&P.state?((F=P.state).wsize=0,F.whave=0,F.wnext=0,E(P)):d}function A(P,F){var v,R;return P&&P.state?(R=P.state,F<0?(v=0,F=-F):(v=1+(F>>4),F<48&&(F&=15)),F&&(F<8||15<F)?d:(null!==R.window&&R.wbits!==F&&(R.window=null),R.wrap=v,R.wbits=F,T(P))):d}function M(P,F){var v,R;return P?(R=new x,(P.state=R).window=null,0!==(v=A(P,F))&&(P.state=null),v):d}var S,z,O=!0;function N(P){if(O){var F;for(S=new n.Buf32(512),z=new n.Buf32(32),F=0;F<144;)P.lens[F++]=8;for(;F<256;)P.lens[F++]=9;for(;F<280;)P.lens[F++]=7;for(;F<288;)P.lens[F++]=8;for(c(1,P.lens,0,288,S,0,P.work,{bits:9}),F=0;F<32;)P.lens[F++]=5;c(2,P.lens,0,32,z,0,P.work,{bits:5}),O=!1}P.lencode=S,P.lenbits=9,P.distcode=z,P.distbits=5}function Z(P,F,v,R){var Q,j=P.state;return null===j.window&&(j.wsize=1<<j.wbits,j.wnext=0,j.whave=0,j.window=new n.Buf8(j.wsize)),R>=j.wsize?(n.arraySet(j.window,F,v-j.wsize,j.wsize,0),j.wnext=0,j.whave=j.wsize):(R<(Q=j.wsize-j.wnext)&&(Q=R),n.arraySet(j.window,F,v-R,Q,j.wnext),(R-=Q)?(n.arraySet(j.window,F,v-R,R,0),j.wnext=R,j.whave=j.wsize):(j.wnext+=Q,j.wnext===j.wsize&&(j.wnext=0),j.whave<j.wsize&&(j.whave+=Q))),0}s.inflateReset=T,s.inflateReset2=A,s.inflateResetKeep=E,s.inflateInit=function(P){return M(P,15)},s.inflateInit2=M,s.inflate=function(P,F){var v,R,Q,j,rt,Y,ot,B,L,it,et,K,gt,Ot,ut,dt,Pt,wt,jt,Vt,C,W,$,k,I=0,D=new n.Buf8(4),q=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!P||!P.state||!P.output||!P.input&&0!==P.avail_in)return d;12===(v=P.state).mode&&(v.mode=13),rt=P.next_out,Q=P.output,j=P.next_in,R=P.input,B=v.hold,L=v.bits,it=Y=P.avail_in,et=ot=P.avail_out,W=0;t:for(;;)switch(v.mode){case 1:if(0===v.wrap){v.mode=13;break}for(;L<16;){if(0===Y)break t;Y--,B+=R[j++]<<L,L+=8}if(2&v.wrap&&35615===B){D[v.check=0]=255&B,D[1]=B>>>8&255,v.check=a(v.check,D,2,0),L=B=0,v.mode=2;break}if(v.flags=0,v.head&&(v.head.done=!1),!(1&v.wrap)||(((255&B)<<8)+(B>>8))%31){P.msg="incorrect header check",v.mode=30;break}if(8!=(15&B)){P.msg="unknown compression method",v.mode=30;break}if(L-=4,C=8+(15&(B>>>=4)),0===v.wbits)v.wbits=C;else if(C>v.wbits){P.msg="invalid window size",v.mode=30;break}v.dmax=1<<C,P.adler=v.check=1,v.mode=512&B?10:12,L=B=0;break;case 2:for(;L<16;){if(0===Y)break t;Y--,B+=R[j++]<<L,L+=8}if(v.flags=B,8!=(255&v.flags)){P.msg="unknown compression method",v.mode=30;break}if(57344&v.flags){P.msg="unknown header flags set",v.mode=30;break}v.head&&(v.head.text=B>>8&1),512&v.flags&&(D[0]=255&B,D[1]=B>>>8&255,v.check=a(v.check,D,2,0)),L=B=0,v.mode=3;case 3:for(;L<32;){if(0===Y)break t;Y--,B+=R[j++]<<L,L+=8}v.head&&(v.head.time=B),512&v.flags&&(D[0]=255&B,D[1]=B>>>8&255,D[2]=B>>>16&255,D[3]=B>>>24&255,v.check=a(v.check,D,4,0)),L=B=0,v.mode=4;case 4:for(;L<16;){if(0===Y)break t;Y--,B+=R[j++]<<L,L+=8}v.head&&(v.head.xflags=255&B,v.head.os=B>>8),512&v.flags&&(D[0]=255&B,D[1]=B>>>8&255,v.check=a(v.check,D,2,0)),L=B=0,v.mode=5;case 5:if(1024&v.flags){for(;L<16;){if(0===Y)break t;Y--,B+=R[j++]<<L,L+=8}v.length=B,v.head&&(v.head.extra_len=B),512&v.flags&&(D[0]=255&B,D[1]=B>>>8&255,v.check=a(v.check,D,2,0)),L=B=0}else v.head&&(v.head.extra=null);v.mode=6;case 6:if(1024&v.flags&&(Y<(K=v.length)&&(K=Y),K&&(v.head&&(C=v.head.extra_len-v.length,v.head.extra||(v.head.extra=new Array(v.head.extra_len)),n.arraySet(v.head.extra,R,j,K,C)),512&v.flags&&(v.check=a(v.check,R,K,j)),Y-=K,j+=K,v.length-=K),v.length))break t;v.length=0,v.mode=7;case 7:if(2048&v.flags){if(0===Y)break t;for(K=0;C=R[j+K++],v.head&&C&&v.length<65536&&(v.head.name+=String.fromCharCode(C)),C&&K<Y;);if(512&v.flags&&(v.check=a(v.check,R,K,j)),Y-=K,j+=K,C)break t}else v.head&&(v.head.name=null);v.length=0,v.mode=8;case 8:if(4096&v.flags){if(0===Y)break t;for(K=0;C=R[j+K++],v.head&&C&&v.length<65536&&(v.head.comment+=String.fromCharCode(C)),C&&K<Y;);if(512&v.flags&&(v.check=a(v.check,R,K,j)),Y-=K,j+=K,C)break t}else v.head&&(v.head.comment=null);v.mode=9;case 9:if(512&v.flags){for(;L<16;){if(0===Y)break t;Y--,B+=R[j++]<<L,L+=8}if(B!==(65535&v.check)){P.msg="header crc mismatch",v.mode=30;break}L=B=0}v.head&&(v.head.hcrc=v.flags>>9&1,v.head.done=!0),P.adler=v.check=0,v.mode=12;break;case 10:for(;L<32;){if(0===Y)break t;Y--,B+=R[j++]<<L,L+=8}P.adler=v.check=p(B),L=B=0,v.mode=11;case 11:if(0===v.havedict)return P.next_out=rt,P.avail_out=ot,P.next_in=j,P.avail_in=Y,v.hold=B,v.bits=L,2;P.adler=v.check=1,v.mode=12;case 12:if(5===F||6===F)break t;case 13:if(v.last){B>>>=7&L,L-=7&L,v.mode=27;break}for(;L<3;){if(0===Y)break t;Y--,B+=R[j++]<<L,L+=8}switch(v.last=1&B,L-=1,3&(B>>>=1)){case 0:v.mode=14;break;case 1:if(N(v),v.mode=20,6!==F)break;B>>>=2,L-=2;break t;case 2:v.mode=17;break;case 3:P.msg="invalid block type",v.mode=30}B>>>=2,L-=2;break;case 14:for(B>>>=7&L,L-=7&L;L<32;){if(0===Y)break t;Y--,B+=R[j++]<<L,L+=8}if((65535&B)!=(B>>>16^65535)){P.msg="invalid stored block lengths",v.mode=30;break}if(v.length=65535&B,L=B=0,v.mode=15,6===F)break t;case 15:v.mode=16;case 16:if(K=v.length){if(Y<K&&(K=Y),ot<K&&(K=ot),0===K)break t;n.arraySet(Q,R,j,K,rt),Y-=K,j+=K,ot-=K,rt+=K,v.length-=K;break}v.mode=12;break;case 17:for(;L<14;){if(0===Y)break t;Y--,B+=R[j++]<<L,L+=8}if(v.nlen=257+(31&B),L-=5,v.ndist=1+(31&(B>>>=5)),L-=5,v.ncode=4+(15&(B>>>=5)),B>>>=4,L-=4,286<v.nlen||30<v.ndist){P.msg="too many length or distance symbols",v.mode=30;break}v.have=0,v.mode=18;case 18:for(;v.have<v.ncode;){for(;L<3;){if(0===Y)break t;Y--,B+=R[j++]<<L,L+=8}v.lens[q[v.have++]]=7&B,B>>>=3,L-=3}for(;v.have<19;)v.lens[q[v.have++]]=0;if(v.lencode=v.lendyn,v.lenbits=7,W=c(0,v.lens,0,19,v.lencode,0,v.work,$={bits:v.lenbits}),v.lenbits=$.bits,W){P.msg="invalid code lengths set",v.mode=30;break}v.have=0,v.mode=19;case 19:for(;v.have<v.nlen+v.ndist;){for(;dt=(I=v.lencode[B&(1<<v.lenbits)-1])>>>16&255,Pt=65535&I,!((ut=I>>>24)<=L);){if(0===Y)break t;Y--,B+=R[j++]<<L,L+=8}if(Pt<16)B>>>=ut,L-=ut,v.lens[v.have++]=Pt;else{if(16===Pt){for(k=ut+2;L<k;){if(0===Y)break t;Y--,B+=R[j++]<<L,L+=8}if(B>>>=ut,L-=ut,0===v.have){P.msg="invalid bit length repeat",v.mode=30;break}C=v.lens[v.have-1],K=3+(3&B),B>>>=2,L-=2}else if(17===Pt){for(k=ut+3;L<k;){if(0===Y)break t;Y--,B+=R[j++]<<L,L+=8}L-=ut,C=0,K=3+(7&(B>>>=ut)),B>>>=3,L-=3}else{for(k=ut+7;L<k;){if(0===Y)break t;Y--,B+=R[j++]<<L,L+=8}L-=ut,C=0,K=11+(127&(B>>>=ut)),B>>>=7,L-=7}if(v.have+K>v.nlen+v.ndist){P.msg="invalid bit length repeat",v.mode=30;break}for(;K--;)v.lens[v.have++]=C}}if(30===v.mode)break;if(0===v.lens[256]){P.msg="invalid code -- missing end-of-block",v.mode=30;break}if(v.lenbits=9,W=c(1,v.lens,0,v.nlen,v.lencode,0,v.work,$={bits:v.lenbits}),v.lenbits=$.bits,W){P.msg="invalid literal/lengths set",v.mode=30;break}if(v.distbits=6,v.distcode=v.distdyn,W=c(2,v.lens,v.nlen,v.ndist,v.distcode,0,v.work,$={bits:v.distbits}),v.distbits=$.bits,W){P.msg="invalid distances set",v.mode=30;break}if(v.mode=20,6===F)break t;case 20:v.mode=21;case 21:if(6<=Y&&258<=ot){P.next_out=rt,P.avail_out=ot,P.next_in=j,P.avail_in=Y,v.hold=B,v.bits=L,l(P,et),rt=P.next_out,Q=P.output,ot=P.avail_out,j=P.next_in,R=P.input,Y=P.avail_in,B=v.hold,L=v.bits,12===v.mode&&(v.back=-1);break}for(v.back=0;dt=(I=v.lencode[B&(1<<v.lenbits)-1])>>>16&255,Pt=65535&I,!((ut=I>>>24)<=L);){if(0===Y)break t;Y--,B+=R[j++]<<L,L+=8}if(dt&&!(240&dt)){for(wt=ut,jt=dt,Vt=Pt;dt=(I=v.lencode[Vt+((B&(1<<wt+jt)-1)>>wt)])>>>16&255,Pt=65535&I,!(wt+(ut=I>>>24)<=L);){if(0===Y)break t;Y--,B+=R[j++]<<L,L+=8}B>>>=wt,L-=wt,v.back+=wt}if(B>>>=ut,L-=ut,v.back+=ut,v.length=Pt,0===dt){v.mode=26;break}if(32&dt){v.back=-1,v.mode=12;break}if(64&dt){P.msg="invalid literal/length code",v.mode=30;break}v.extra=15&dt,v.mode=22;case 22:if(v.extra){for(k=v.extra;L<k;){if(0===Y)break t;Y--,B+=R[j++]<<L,L+=8}v.length+=B&(1<<v.extra)-1,B>>>=v.extra,L-=v.extra,v.back+=v.extra}v.was=v.length,v.mode=23;case 23:for(;dt=(I=v.distcode[B&(1<<v.distbits)-1])>>>16&255,Pt=65535&I,!((ut=I>>>24)<=L);){if(0===Y)break t;Y--,B+=R[j++]<<L,L+=8}if(!(240&dt)){for(wt=ut,jt=dt,Vt=Pt;dt=(I=v.distcode[Vt+((B&(1<<wt+jt)-1)>>wt)])>>>16&255,Pt=65535&I,!(wt+(ut=I>>>24)<=L);){if(0===Y)break t;Y--,B+=R[j++]<<L,L+=8}B>>>=wt,L-=wt,v.back+=wt}if(B>>>=ut,L-=ut,v.back+=ut,64&dt){P.msg="invalid distance code",v.mode=30;break}v.offset=Pt,v.extra=15&dt,v.mode=24;case 24:if(v.extra){for(k=v.extra;L<k;){if(0===Y)break t;Y--,B+=R[j++]<<L,L+=8}v.offset+=B&(1<<v.extra)-1,B>>>=v.extra,L-=v.extra,v.back+=v.extra}if(v.offset>v.dmax){P.msg="invalid distance too far back",v.mode=30;break}v.mode=25;case 25:if(0===ot)break t;if(v.offset>(K=et-ot)){if((K=v.offset-K)>v.whave&&v.sane){P.msg="invalid distance too far back",v.mode=30;break}gt=K>v.wnext?v.wsize-(K-=v.wnext):v.wnext-K,K>v.length&&(K=v.length),Ot=v.window}else Ot=Q,gt=rt-v.offset,K=v.length;for(ot<K&&(K=ot),ot-=K,v.length-=K;Q[rt++]=Ot[gt++],--K;);0===v.length&&(v.mode=21);break;case 26:if(0===ot)break t;Q[rt++]=v.length,ot--,v.mode=21;break;case 27:if(v.wrap){for(;L<32;){if(0===Y)break t;Y--,B|=R[j++]<<L,L+=8}if(P.total_out+=et-=ot,v.total+=et,et&&(P.adler=v.check=v.flags?a(v.check,Q,et,rt-et):r(v.check,Q,et,rt-et)),et=ot,(v.flags?B:p(B))!==v.check){P.msg="incorrect data check",v.mode=30;break}L=B=0}v.mode=28;case 28:if(v.wrap&&v.flags){for(;L<32;){if(0===Y)break t;Y--,B+=R[j++]<<L,L+=8}if(B!==(4294967295&v.total)){P.msg="incorrect length check",v.mode=30;break}L=B=0}v.mode=29;case 29:W=1;break t;case 30:W=-3;break t;case 31:return-4;default:return d}return P.next_out=rt,P.avail_out=ot,P.next_in=j,P.avail_in=Y,v.hold=B,v.bits=L,(v.wsize||et!==P.avail_out&&v.mode<30&&(v.mode<27||4!==F))&&Z(P,P.output,P.next_out,et-P.avail_out)?(v.mode=31,-4):(et-=P.avail_out,P.total_in+=it-=P.avail_in,P.total_out+=et,v.total+=et,v.wrap&&et&&(P.adler=v.check=v.flags?a(v.check,Q,et,P.next_out-et):r(v.check,Q,et,P.next_out-et)),P.data_type=v.bits+(v.last?64:0)+(12===v.mode?128:0)+(20===v.mode||15===v.mode?256:0),(0==it&&0===et||4===F)&&0===W&&(W=-5),W)},s.inflateEnd=function(P){if(!P||!P.state)return d;var F=P.state;return F.window&&(F.window=null),P.state=null,0},s.inflateGetHeader=function(P,F){var v;return P&&P.state&&2&(v=P.state).wrap?((v.head=F).done=!1,0):d},s.inflateSetDictionary=function(P,F){var v,R=F.length;return P&&P.state?0!==(v=P.state).wrap&&11!==v.mode?d:11===v.mode&&r(1,F,R,0)!==v.check?-3:Z(P,F,R,R)?(v.mode=31,-4):(v.havedict=1,0):d},s.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(t,i,s){var n=t("../utils/common"),r=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],a=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],l=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],c=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];i.exports=function(h,u,f,d,y,g,_,p){var x,E,T,A,M,S,z,O,N,Z=p.bits,P=0,F=0,v=0,R=0,Q=0,j=0,rt=0,Y=0,ot=0,B=0,L=null,it=0,et=new n.Buf16(16),K=new n.Buf16(16),gt=null,Ot=0;for(P=0;P<=15;P++)et[P]=0;for(F=0;F<d;F++)et[u[f+F]]++;for(Q=Z,R=15;1<=R&&0===et[R];R--);if(R<Q&&(Q=R),0===R)return y[g++]=20971520,y[g++]=20971520,p.bits=1,0;for(v=1;v<R&&0===et[v];v++);for(Q<v&&(Q=v),P=Y=1;P<=15;P++)if(Y<<=1,(Y-=et[P])<0)return-1;if(0<Y&&(0===h||1!==R))return-1;for(K[1]=0,P=1;P<15;P++)K[P+1]=K[P]+et[P];for(F=0;F<d;F++)0!==u[f+F]&&(_[K[u[f+F]]++]=F);if(S=0===h?(L=gt=_,19):1===h?(L=r,it-=257,gt=a,Ot-=257,256):(L=l,gt=c,-1),P=v,M=g,rt=F=B=0,T=-1,A=(ot=1<<(j=Q))-1,1===h&&852<ot||2===h&&592<ot)return 1;for(;;){for(z=P-rt,N=_[F]<S?(O=0,_[F]):_[F]>S?(O=gt[Ot+_[F]],L[it+_[F]]):(O=96,0),x=1<<P-rt,v=E=1<<j;y[M+(B>>rt)+(E-=x)]=z<<24|O<<16|N,0!==E;);for(x=1<<P-1;B&x;)x>>=1;if(0!==x?(B&=x-1,B+=x):B=0,F++,0==--et[P]){if(P===R)break;P=u[f+_[F]]}if(Q<P&&(B&A)!==T){for(0===rt&&(rt=Q),M+=v,Y=1<<(j=P-rt);j+rt<R&&!((Y-=et[j+rt])<=0);)j++,Y<<=1;if(ot+=1<<j,1===h&&852<ot||2===h&&592<ot)return 1;y[T=B&A]=Q<<24|j<<16|M-g}}return 0!==B&&(y[M+B]=P-rt<<24|64<<16),p.bits=Q,0}},{"../utils/common":41}],51:[function(t,i,s){i.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(t,i,s){var n=t("../utils/common");function l(I){for(var D=I.length;0<=--D;)I[D]=0}var u=256,f=286,d=30,_=15,S=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],z=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],O=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],N=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],Z=new Array(576);l(Z);var P=new Array(60);l(P);var F=new Array(512);l(F);var v=new Array(256);l(v);var R=new Array(29);l(R);var Q,j,rt,Y=new Array(d);function ot(I,D,q,G,U){this.static_tree=I,this.extra_bits=D,this.extra_base=q,this.elems=G,this.max_length=U,this.has_stree=I&&I.length}function B(I,D){this.dyn_tree=I,this.max_code=0,this.stat_desc=D}function L(I){return I<256?F[I]:F[256+(I>>>7)]}function it(I,D){I.pending_buf[I.pending++]=255&D,I.pending_buf[I.pending++]=D>>>8&255}function et(I,D,q){I.bi_valid>16-q?(I.bi_buf|=D<<I.bi_valid&65535,it(I,I.bi_buf),I.bi_buf=D>>16-I.bi_valid,I.bi_valid+=q-16):(I.bi_buf|=D<<I.bi_valid&65535,I.bi_valid+=q)}function K(I,D,q){et(I,q[2*D],q[2*D+1])}function gt(I,D){for(var q=0;q|=1&I,I>>>=1,q<<=1,0<--D;);return q>>>1}function Ot(I,D,q){var G,U,J=new Array(16),nt=0;for(G=1;G<=_;G++)J[G]=nt=nt+q[G-1]<<1;for(U=0;U<=D;U++){var tt=I[2*U+1];0!==tt&&(I[2*U]=gt(J[tt]++,tt))}}function ut(I){var D;for(D=0;D<f;D++)I.dyn_ltree[2*D]=0;for(D=0;D<d;D++)I.dyn_dtree[2*D]=0;for(D=0;D<19;D++)I.bl_tree[2*D]=0;I.dyn_ltree[512]=1,I.opt_len=I.static_len=0,I.last_lit=I.matches=0}function dt(I){8<I.bi_valid?it(I,I.bi_buf):0<I.bi_valid&&(I.pending_buf[I.pending++]=I.bi_buf),I.bi_buf=0,I.bi_valid=0}function Pt(I,D,q,G){var U=2*D,J=2*q;return I[U]<I[J]||I[U]===I[J]&&G[D]<=G[q]}function wt(I,D,q){for(var G=I.heap[q],U=q<<1;U<=I.heap_len&&(U<I.heap_len&&Pt(D,I.heap[U+1],I.heap[U],I.depth)&&U++,!Pt(D,G,I.heap[U],I.depth));)I.heap[q]=I.heap[U],q=U,U<<=1;I.heap[q]=G}function jt(I,D,q){var G,U,J,nt,tt=0;if(0!==I.last_lit)for(;G=I.pending_buf[I.d_buf+2*tt]<<8|I.pending_buf[I.d_buf+2*tt+1],U=I.pending_buf[I.l_buf+tt],tt++,0===G?K(I,U,D):(K(I,(J=v[U])+u+1,D),0!==(nt=S[J])&&et(I,U-=R[J],nt),K(I,J=L(--G),q),0!==(nt=z[J])&&et(I,G-=Y[J],nt)),tt<I.last_lit;);K(I,256,D)}function Vt(I,D){var q,G,U,J=D.dyn_tree,nt=D.stat_desc.static_tree,tt=D.stat_desc.has_stree,at=D.stat_desc.elems,Ct=-1;for(I.heap_len=0,I.heap_max=573,q=0;q<at;q++)0!==J[2*q]?(I.heap[++I.heap_len]=Ct=q,I.depth[q]=0):J[2*q+1]=0;for(;I.heap_len<2;)J[2*(U=I.heap[++I.heap_len]=Ct<2?++Ct:0)]=1,I.depth[U]=0,I.opt_len--,tt&&(I.static_len-=nt[2*U+1]);for(D.max_code=Ct,q=I.heap_len>>1;1<=q;q--)wt(I,J,q);for(U=at;q=I.heap[1],I.heap[1]=I.heap[I.heap_len--],wt(I,J,1),G=I.heap[1],I.heap[--I.heap_max]=q,I.heap[--I.heap_max]=G,J[2*U]=J[2*q]+J[2*G],I.depth[U]=(I.depth[q]>=I.depth[G]?I.depth[q]:I.depth[G])+1,J[2*q+1]=J[2*G+1]=U,I.heap[1]=U++,wt(I,J,1),2<=I.heap_len;);I.heap[--I.heap_max]=I.heap[1],function(pt,ee){var gi,ce,_i,zt,is,fn,fe=ee.dyn_tree,ao=ee.max_code,du=ee.stat_desc.static_tree,fu=ee.stat_desc.has_stree,pu=ee.stat_desc.extra_bits,lo=ee.stat_desc.extra_base,yi=ee.stat_desc.max_length,ss=0;for(zt=0;zt<=_;zt++)pt.bl_count[zt]=0;for(fe[2*pt.heap[pt.heap_max]+1]=0,gi=pt.heap_max+1;gi<573;gi++)yi<(zt=fe[2*fe[2*(ce=pt.heap[gi])+1]+1]+1)&&(zt=yi,ss++),fe[2*ce+1]=zt,ao<ce||(pt.bl_count[zt]++,is=0,lo<=ce&&(is=pu[ce-lo]),pt.opt_len+=(fn=fe[2*ce])*(zt+is),fu&&(pt.static_len+=fn*(du[2*ce+1]+is)));if(0!==ss){do{for(zt=yi-1;0===pt.bl_count[zt];)zt--;pt.bl_count[zt]--,pt.bl_count[zt+1]+=2,pt.bl_count[yi]--,ss-=2}while(0<ss);for(zt=yi;0!==zt;zt--)for(ce=pt.bl_count[zt];0!==ce;)ao<(_i=pt.heap[--gi])||(fe[2*_i+1]!==zt&&(pt.opt_len+=(zt-fe[2*_i+1])*fe[2*_i],fe[2*_i+1]=zt),ce--)}}(I,D),Ot(J,Ct,I.bl_count)}function C(I,D,q){var G,U,J=-1,nt=D[1],tt=0,at=7,Ct=4;for(0===nt&&(at=138,Ct=3),D[2*(q+1)+1]=65535,G=0;G<=q;G++)U=nt,nt=D[2*(G+1)+1],++tt<at&&U===nt||(tt<Ct?I.bl_tree[2*U]+=tt:0!==U?(U!==J&&I.bl_tree[2*U]++,I.bl_tree[32]++):tt<=10?I.bl_tree[34]++:I.bl_tree[36]++,J=U,Ct=(tt=0)===nt?(at=138,3):U===nt?(at=6,3):(at=7,4))}function W(I,D,q){var G,U,J=-1,nt=D[1],tt=0,at=7,Ct=4;for(0===nt&&(at=138,Ct=3),G=0;G<=q;G++)if(U=nt,nt=D[2*(G+1)+1],!(++tt<at&&U===nt)){if(tt<Ct)for(;K(I,U,I.bl_tree),0!=--tt;);else 0!==U?(U!==J&&(K(I,U,I.bl_tree),tt--),K(I,16,I.bl_tree),et(I,tt-3,2)):tt<=10?(K(I,17,I.bl_tree),et(I,tt-3,3)):(K(I,18,I.bl_tree),et(I,tt-11,7));J=U,Ct=(tt=0)===nt?(at=138,3):U===nt?(at=6,3):(at=7,4)}}l(Y);var $=!1;function k(I,D,q,G){var U,J,nt;et(I,0+(G?1:0),3),J=D,nt=q,dt(U=I),it(U,nt),it(U,~nt),n.arraySet(U.pending_buf,U.window,J,nt,U.pending),U.pending+=nt}s._tr_init=function(I){$||(function(){var D,q,G,U,J,nt=new Array(16);for(U=G=0;U<28;U++)for(R[U]=G,D=0;D<1<<S[U];D++)v[G++]=U;for(v[G-1]=U,U=J=0;U<16;U++)for(Y[U]=J,D=0;D<1<<z[U];D++)F[J++]=U;for(J>>=7;U<d;U++)for(Y[U]=J<<7,D=0;D<1<<z[U]-7;D++)F[256+J++]=U;for(q=0;q<=_;q++)nt[q]=0;for(D=0;D<=143;)Z[2*D+1]=8,D++,nt[8]++;for(;D<=255;)Z[2*D+1]=9,D++,nt[9]++;for(;D<=279;)Z[2*D+1]=7,D++,nt[7]++;for(;D<=287;)Z[2*D+1]=8,D++,nt[8]++;for(Ot(Z,287,nt),D=0;D<d;D++)P[2*D+1]=5,P[2*D]=gt(D,5);Q=new ot(Z,S,257,f,_),j=new ot(P,z,0,d,_),rt=new ot(new Array(0),O,0,19,7)}(),$=!0),I.l_desc=new B(I.dyn_ltree,Q),I.d_desc=new B(I.dyn_dtree,j),I.bl_desc=new B(I.bl_tree,rt),I.bi_buf=0,I.bi_valid=0,ut(I)},s._tr_stored_block=k,s._tr_flush_block=function(I,D,q,G){var U,J,nt=0;0<I.level?(2===I.strm.data_type&&(I.strm.data_type=function(tt){var at,Ct=4093624447;for(at=0;at<=31;at++,Ct>>>=1)if(1&Ct&&0!==tt.dyn_ltree[2*at])return 0;if(0!==tt.dyn_ltree[18]||0!==tt.dyn_ltree[20]||0!==tt.dyn_ltree[26])return 1;for(at=32;at<u;at++)if(0!==tt.dyn_ltree[2*at])return 1;return 0}(I)),Vt(I,I.l_desc),Vt(I,I.d_desc),nt=function(tt){var at;for(C(tt,tt.dyn_ltree,tt.l_desc.max_code),C(tt,tt.dyn_dtree,tt.d_desc.max_code),Vt(tt,tt.bl_desc),at=18;3<=at&&0===tt.bl_tree[2*N[at]+1];at--);return tt.opt_len+=3*(at+1)+5+5+4,at}(I),(J=I.static_len+3+7>>>3)<=(U=I.opt_len+3+7>>>3)&&(U=J)):U=J=q+5,q+4<=U&&-1!==D?k(I,D,q,G):4===I.strategy||J===U?(et(I,2+(G?1:0),3),jt(I,Z,P)):(et(I,4+(G?1:0),3),function(tt,at,Ct,pt){var ee;for(et(tt,at-257,5),et(tt,Ct-1,5),et(tt,pt-4,4),ee=0;ee<pt;ee++)et(tt,tt.bl_tree[2*N[ee]+1],3);W(tt,tt.dyn_ltree,at-1),W(tt,tt.dyn_dtree,Ct-1)}(I,I.l_desc.max_code+1,I.d_desc.max_code+1,nt+1),jt(I,I.dyn_ltree,I.dyn_dtree)),ut(I),G&&dt(I)},s._tr_tally=function(I,D,q){return I.pending_buf[I.d_buf+2*I.last_lit]=D>>>8&255,I.pending_buf[I.d_buf+2*I.last_lit+1]=255&D,I.pending_buf[I.l_buf+I.last_lit]=255&q,I.last_lit++,0===D?I.dyn_ltree[2*q]++:(I.matches++,D--,I.dyn_ltree[2*(v[q]+u+1)]++,I.dyn_dtree[2*L(D)]++),I.last_lit===I.lit_bufsize-1},s._tr_align=function(I){var D;et(I,2,3),K(I,256,Z),16===(D=I).bi_valid?(it(D,D.bi_buf),D.bi_buf=0,D.bi_valid=0):8<=D.bi_valid&&(D.pending_buf[D.pending++]=255&D.bi_buf,D.bi_buf>>=8,D.bi_valid-=8)}},{"../utils/common":41}],53:[function(t,i,s){i.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(t,i,s){(function(n){!function(r){if(!r.setImmediate){var l,c,h,u,f=1,d={},y=!1,g=r.document,_=Object.getPrototypeOf&&Object.getPrototypeOf(r);_=_&&_.setTimeout?_:r,l="[object process]"==={}.toString.call(r.process)?function(T){process.nextTick(function(){x(T)})}:function(){if(r.postMessage&&!r.importScripts){var T=!0,A=r.onmessage;return r.onmessage=function(){T=!1},r.postMessage("","*"),r.onmessage=A,T}}()?(u="setImmediate$"+Math.random()+"$",r.addEventListener?r.addEventListener("message",E,!1):r.attachEvent("onmessage",E),function(T){r.postMessage(u+T,"*")}):r.MessageChannel?((h=new MessageChannel).port1.onmessage=function(T){x(T.data)},function(T){h.port2.postMessage(T)}):g&&"onreadystatechange"in g.createElement("script")?(c=g.documentElement,function(T){var A=g.createElement("script");A.onreadystatechange=function(){x(T),A.onreadystatechange=null,c.removeChild(A),A=null},c.appendChild(A)}):function(T){setTimeout(x,0,T)},_.setImmediate=function(T){"function"!=typeof T&&(T=new Function(""+T));for(var A=new Array(arguments.length-1),M=0;M<A.length;M++)A[M]=arguments[M+1];return d[f]={callback:T,args:A},l(f),f++},_.clearImmediate=p}function p(T){delete d[T]}function x(T){if(y)setTimeout(x,0,T);else{var A=d[T];if(A){y=!0;try{!function(M){var S=M.callback,z=M.args;switch(z.length){case 0:S();break;case 1:S(z[0]);break;case 2:S(z[0],z[1]);break;case 3:S(z[0],z[1],z[2]);break;default:S.apply(void 0,z)}}(A)}finally{p(T),y=!1}}}}function E(T){T.source===r&&"string"==typeof T.data&&0===T.data.indexOf(u)&&x(+T.data.slice(u.length))}}(typeof self>"u"?void 0===n?this:n:self)}).call(this,typeof qi<"u"?qi:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10);const Tr=Xl(Cr.exports);class Ys{constructor(e,t){w(this,"date",new Date),w(this,"author"),w(this,"guid",Yt.create()),w(this,"viewpoint"),w(this,"modifiedAuthor"),w(this,"modifiedDate"),w(this,"topic"),w(this,"_components"),w(this,"_comment",""),this._components=e,this._comment=t;const i=this._components.get(Dt);this.author=i.config.author}set comment(e){var t;const i=this._components.get(Dt);this._comment=e,this.modifiedDate=new Date,this.modifiedAuthor=i.config.author,null==(t=this.topic)||t.comments.set(this.guid,this)}get comment(){return this._comment}toJSON(){var e,t;const i={guid:this.guid,date:this.date.toISOString(),author:this.author,comment:this.comment,topic_guid:null==(e=this.topic)?void 0:e.guid,viewpoint_guid:this.viewpoint,modified_date:null==(t=this.modifiedDate)?void 0:t.toISOString(),modified_author:this.modifiedAuthor};for(const[s,n]of Object.entries(i))void 0===n&&delete i[s];return i}}const Er=class xe{constructor(e){w(this,"guid",Yt.create()),w(this,"title",xe.default.title),w(this,"creationDate",new Date),w(this,"creationAuthor",""),w(this,"viewpoints",new ft.PG),w(this,"relatedTopics",new ft.PG),w(this,"comments",new ft.jp),w(this,"documentReferences",new ft.PG),w(this,"customData",{}),w(this,"description"),w(this,"serverAssignedId"),w(this,"dueDate"),w(this,"modifiedAuthor"),w(this,"modifiedDate"),w(this,"index"),w(this,"_type",xe.default.type),w(this,"_status",xe.default.status),w(this,"_priority",xe.default.priority),w(this,"_stage",xe.default.stage),w(this,"_assignedTo",xe.default.assignedTo),w(this,"_labels",xe.default.labels??new Set),w(this,"_components"),this._components=e;const t=e.get(Dt);this.creationAuthor=t.config.author,this.relatedTopics.guard=i=>i!==this.guid}set type(e){const t=this._components.get(Dt),{strict:i,types:s}=t.config;(!i||s.has(e))&&(this._type=e)}get type(){return this._type}set status(e){const t=this._components.get(Dt),{strict:i,statuses:s}=t.config;(!i||s.has(e))&&(this._status=e)}get status(){return this._status}set priority(e){const t=this._components.get(Dt);if(e){const{strict:i,priorities:s}=t.config;if(i&&!s.has(e))return;this._priority=e}else this._priority=e}get priority(){return this._priority}set stage(e){const t=this._components.get(Dt);if(e){const{strict:i,stages:s}=t.config;if(i&&!s.has(e))return;this._stage=e}else this._stage=e}get stage(){return this._stage}set assignedTo(e){const t=this._components.get(Dt);if(e){const{strict:i,users:s}=t.config;if(i&&!s.has(e))return;this._assignedTo=e}else this._assignedTo=e}get assignedTo(){return this._assignedTo}set labels(e){const t=this._components.get(Dt),{strict:i,labels:s}=t.config;if(i){const n=new Set;for(const r of e)(!i||s.has(r))&&n.add(r);this._labels=n}else this._labels=e}get labels(){return this._labels}get _managerVersion(){return this._components.get(Dt).config.version}set(e){const t=e,i=this;for(const n in e)"guid"!==n&&n in this&&(i[n]=t[n]);return this._components.get(Dt).list.set(this.guid,this),this}createComment(e,t){const i=new Ys(this._components,e);return i.viewpoint=t,i.topic=this,this.comments.set(i.guid,i),i}createLabelTags(){const e=[...this.labels];if(this._components.get(Dt).config.exportCustomDataAsLabels)for(const i in this.customData){const s=this.customData[i];"string"==typeof s&&e.push(s)}return e}createCommentTags(){return[...this.comments.values()].map(e=>{var t;return{$Guid:e.guid,Date:e.date.toISOString(),Author:e.author,Comment:e.comment,ModifiedAuthor:e.modifiedAuthor,ModifiedDate:null==(t=e.modifiedDate)?void 0:t.toISOString(),Viewpoint:e.viewpoint?{$Guid:e.viewpoint}:void 0}})}createViewpointTags(){const e=this._components.get(de);return[...this.viewpoints].map(i=>e.list.get(i)).filter(i=>i).map(i=>{const s={$Guid:i.guid,Viewpoint:`${i.title??i.guid}.bcfv`};if(e.snapshots.get(i.snapshot)){const r=e.getSnapshotExtension(i.snapshot);s.Snapshot=`${i.snapshot}.${r}`}return s})}createRelatedTopicTags(){return[...this.relatedTopics].map(e=>({$Guid:e}))}createDocumentReferencesTag(e=this._managerVersion){const t=[];if("3"!==e&&"2.1"!==e)return t;const i=this._components.get(Dt);for(const s of this.documentReferences){const n=i.documents.get(s);if(!n)continue;let r={$Guid:Yt.create(),Description:n.description};"2.1"===e&&(r={...r,$isExternal:"external"===n.type||void 0,ReferencedDocument:"external"===n.type?n.url:`../${n.fileName}`}),"3"===e&&(r={...r,DocumentGuid:"internal"===n.type?s:void 0,Url:"external"===n.type?n.url:void 0}),Object.keys(r).length>0&&t.push(r)}return t}toJSON(){var e,t;const i={guid:this.guid,server_assigned_id:this.serverAssignedId,topic_type:this.type,topic_status:this.status,title:this.title,priority:this.priority,index:this.index,labels:[...this.labels],creation_date:this.creationDate.toISOString(),creation_author:this.creationAuthor,modified_date:null==(e=this.modifiedDate)?void 0:e.toISOString(),modified_author:this.modifiedAuthor,assigned_to:this.assignedTo,stage:this.stage,description:this.description,due_date:null==(t=this.dueDate)?void 0:t.toISOString(),comments:[...this.comments].map(([r,a])=>a.toJSON()),relatedTopics:[...this.relatedTopics].map(r=>({related_topic_guid:r}))},s=this._components.get(de);for(const r of this.viewpoints){const a=s.list.get(r);a&&(i.viewpoints||(i.viewpoints=[]),i.viewpoints.push(a.toJSON()))}const n=this._components.get(Dt);for(const r of this.documentReferences){const a=n.documents.get(r);a&&(i.document_references||(i.document_references=[]),i.document_references.push("external"===a.type?{guid:Yt.create(),description:a.description,url:a.url}:{guid:Yt.create(),description:a.description,document_guid:r}))}for(const[r,a]of Object.entries(i))(void 0===a||Array.isArray(a)&&0===a.length)&&delete i[r];return i}serialize(){var e,t;const i=this._managerVersion,s={$Guid:this.guid,$TopicType:this.type,$TopicStatus:this.status,$ServerAssignedId:this.serverAssignedId,Title:this.title,CreationAuthor:this.creationAuthor,CreationDate:this.creationDate.toISOString(),Priority:this.priority,Index:"2.1"===i?this.index:void 0,ModifiedDate:null==(e=this.modifiedDate)?void 0:e.toISOString(),ModifiedAuthor:this.modifiedAuthor,DueDate:null==(t=this.dueDate)?void 0:t.toISOString(),AssignedTo:this.assignedTo,Description:this.description,Stage:this.stage,DocumentReferences:"3"===i?{DocumentReference:this.createDocumentReferencesTag(i)}:void 0,RelatedTopics:"3"===i?{RelatedTopic:this.createRelatedTopicTags()}:void 0,RelatedTopic:"2.1"===i?this.createRelatedTopicTags():void 0,Labels:"3"===i?{Label:this.createLabelTags()}:void 0,Viewpoints:"3"===i?{ViewPoint:this.createViewpointTags()}:void 0,Comments:"3"===i?{Comment:this.createCommentTags()}:void 0};"2.1"===i&&(s.Labels=this.createLabelTags(),s.DocumentReference=this.createDocumentReferencesTag(i));const n={Markup:{Topic:s}};return"2.1"===i&&(n.Markup.Viewpoints=this.createViewpointTags(),n.Markup.Comment=this.createCommentTags()),`<?xml version="1.0" encoding="UTF-8"?>\n ${Ai.builder.build(n)}`}};w(Er,"default",{title:"BCF Topic",type:"Issue",status:"Active"});let Ar=Er;class Jl extends ii{constructor(){super(...arguments),w(this,"_config",{version:{type:"Select",options:new Set(["2.1","3"]),multiple:!1,value:""},author:{type:"Text",value:""},types:{type:"TextSet",value:new Set},statuses:{type:"TextSet",value:new Set},priorities:{type:"TextSet",value:new Set},labels:{type:"TextSet",value:new Set},stages:{type:"TextSet",value:new Set},users:{type:"TextSet",value:new Set},includeSelectionTag:{type:"Boolean",value:!1},updateExtensionsOnImport:{type:"Boolean",value:!1},strict:{type:"Boolean",value:!1},includeAllExtensionsOnExport:{type:"Boolean",value:!1},fallbackVersionOnImport:{type:"Select",multiple:!1,options:new Set(["2.1","3"]),value:""},ignoreIncompleteTopicsOnImport:{type:"Boolean",value:!1},exportCustomDataAsLabels:{type:"Boolean",value:!1}})}get version(){return this._config.version.value}set version(e){this._config.version.value=e}get author(){return this._config.author.value}set author(e){this._config.author.value=e}get types(){return this._config.types.value}set types(e){this._config.types.value=e}get statuses(){return this._config.statuses.value}set statuses(e){this._config.statuses.value=e}get priorities(){return this._config.priorities.value}set priorities(e){this._config.priorities.value=e}get labels(){return this._config.labels.value}set labels(e){this._config.labels.value=e}get stages(){return this._config.stages.value}set stages(e){this._config.stages.value=e}get users(){return this._config.users.value}set users(e){this._config.users.value=e}get includeSelectionTag(){return this._config.includeSelectionTag.value}set includeSelectionTag(e){this._config.includeSelectionTag.value=e}get updateExtensionsOnImport(){return this._config.updateExtensionsOnImport.value}set updateExtensionsOnImport(e){this._config.updateExtensionsOnImport.value=e}get strict(){return this._config.strict.value}set strict(e){this._config.strict.value=e}get includeAllExtensionsOnExport(){return this._config.includeAllExtensionsOnExport.value}set includeAllExtensionsOnExport(e){this._config.includeAllExtensionsOnExport.value=e}get fallbackVersionOnImport(){return this._config.fallbackVersionOnImport.value}set fallbackVersionOnImport(e){this._config.fallbackVersionOnImport.value=e}get ignoreIncompleteTopicsOnImport(){return this._config.ignoreIncompleteTopicsOnImport.value}set ignoreIncompleteTopicsOnImport(e){this._config.ignoreIncompleteTopicsOnImport.value=e}get exportCustomDataAsLabels(){return this._config.exportCustomDataAsLabels.value}set exportCustomDataAsLabels(e){this._config.exportCustomDataAsLabels.value=e}}const Zs=class vi extends Tt{constructor(){super(...arguments),w(this,"enabled",!1),w(this,"_defaultConfig",{author:"jhon.doe@example.com",version:"2.1",types:new Set(["Clash","Failure","Fault","Inquiry","Issue","Remark","Request"]),statuses:new Set(["Active","In Progress","Done","In Review","Closed"]),priorities:new Set(["On hold","Minor","Normal","Major","Critical"]),labels:new Set,stages:new Set,users:new Set,includeSelectionTag:!1,updateExtensionsOnImport:!0,strict:!1,includeAllExtensionsOnExport:!0,fallbackVersionOnImport:"2.1",ignoreIncompleteTopicsOnImport:!1,exportCustomDataAsLabels:!1}),w(this,"config",new Jl(this,this.components,"BCF Topics",vi.uuid)),w(this,"list",new ft.jp),w(this,"documents",new ft.jp),w(this,"onSetup",new X),w(this,"isSetup",!1),w(this,"onBCFImported",new X),w(this,"onDisposed",new X)}setup(e){if(this.isSetup)return;const t={...this._defaultConfig,...e};this.config.version=t.version,this.config.author=t.author,this.config.types=t.types,this.config.statuses=t.statuses,this.config.priorities=t.priorities,this.config.labels=t.labels,this.config.stages=t.stages,this.config.users=t.users,this.config.includeSelectionTag=t.includeSelectionTag,this.config.updateExtensionsOnImport=t.updateExtensionsOnImport,this.config.strict=t.strict,this.config.includeAllExtensionsOnExport=t.includeAllExtensionsOnExport,this.config.fallbackVersionOnImport=t.fallbackVersionOnImport||"",this.config.ignoreIncompleteTopicsOnImport=t.ignoreIncompleteTopicsOnImport,this.isSetup=!0,this.enabled=!0,this.onSetup.trigger()}create(e){const t=new Ar(this.components);return e?(t.guid=e.guid??t.guid,t.set(e)):this.list.set(t.guid,t),t}dispose(){this.list.dispose(),this.onDisposed.trigger(),this.onDisposed.reset()}get usedTypes(){const e=[...this.list].map(([t,i])=>i.type);return new Set(e)}get usedStatuses(){const e=[...this.list].map(([t,i])=>i.status);return new Set(e)}get usedPriorities(){const e=[...this.list].map(([t,i])=>i.priority).filter(t=>t);return new Set(e)}get usedStages(){const e=[...this.list].map(([t,i])=>i.stage).filter(t=>t);return new Set(e)}get usedUsers(){const e=[];for(const[t,i]of this.list){e.push(i.creationAuthor),i.assignedTo&&e.push(i.assignedTo),i.modifiedAuthor&&e.push(i.modifiedAuthor);for(const[s,n]of i.comments)e.push(n.author),n.modifiedAuthor&&e.push(n.modifiedAuthor)}return new Set(e)}get usedLabels(){const e=[];for(const[t,i]of this.list)e.push(...i.labels);return new Set(e)}updateExtensions(){for(const[e,t]of this.list){for(const i of t.labels)this.config.labels.add(i);this.config.types.add(t.type),t.priority&&this.config.priorities.add(t.priority),t.stage&&this.config.stages.add(t.stage),this.config.statuses.add(t.status),this.config.users.add(t.creationAuthor),t.assignedTo&&this.config.users.add(t.assignedTo),t.modifiedAuthor&&this.config.users.add(t.modifiedAuthor);for(const[i,s]of t.comments)this.config.users.add(s.author),s.modifiedAuthor&&this.config.users.add(s.modifiedAuthor)}}updateViewpointReferences(){const e=this.components.get(de);for(const[t,i]of this.list)for(const s of i.viewpoints)e.list.has(s)||i.viewpoints.delete(s)}export(){var e=this;return(0,H.A)(function*(t=e.list.values()){const i=new Tr;i.file("bcf.version",`<?xml version="1.0" encoding="UTF-8"?>\n <Version VersionId="${e.config.version}" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/buildingSMART/BCF-XML/release_3_0/Schemas/version.xsd"\n xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">\n </Version>`);for(const[r,a]of e.documents.entries())"external"!==a.type&&i.file("2.1"===e.config.version?a.fileName:`documents/${r}`,a.data);if("3"===e.config.version){const r=[];for(const[a,l]of e.documents.entries()){const{type:c,description:h}=l;"external"!==c&&r.push(`<Document Guid="${a}">\n <Filename>${l.fileName}</Filename>\n ${h?`<Description>${h}</Description>`:""}\n </Document>`)}r.length>0&&i.file("documents.xml",`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n <DocumentInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="documents.xsd">\n <Documents>\n ${r.join("\n")}\n </Documents>\n </DocumentInfo>`)}i.file("bcf.extensions",e.serializeExtensions());const s=e.components.get(de);for(const r of t){const a=i.folder(r.guid);a.file("markup.bcf",r.serialize());for(const l of r.viewpoints){const c=s.list.get(l);if(!c)continue;a.file(`${c.title??c.guid}.bcfv`,yield c.serialize());const u=s.snapshots.get(c.snapshot);if(!u)continue;const f=u?c.snapshot:c.guid,d=s.getSnapshotExtension(c.snapshot);a.file(`${f}.${d}`,u,{binary:!0})}}return yield i.generateAsync({type:"blob"})}).apply(this,arguments)}serializeExtensions(){const e=[...this.config.types].map(a=>`<TopicType>${a}</TopicType>`).join("\n"),t=[...this.config.statuses].map(a=>`<TopicStatus>${a}</TopicStatus>`).join("\n"),i=[...this.config.priorities].map(a=>`<Priority>${a}</Priority>`).join("\n"),s=[...this.config.labels].map(a=>`<TopicLabel>${a}</TopicLabel>`).join("\n"),n=[...this.config.stages].map(a=>`<Stage>${a}</Stage>`).join("\n"),r=[...this.config.users].map(a=>`<User>${a}</User>`).join("\n");return`\n <?xml version="1.0" encoding="UTF-8"?>\n <Extensions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="your-schema-location.xsd">\n ${0!==e.length?`<TopicTypes>\n${e}\n</TopicTypes>`:""}\n ${0!==t.length?`<TopicStatuses>\n${t}\n</TopicStatuses>`:""}\n ${0!==i.length?`<Priorities>\n${i}\n</Priorities>`:""}\n ${0!==s.length?`<TopicLabels>\n${s}\n</TopicLabels>`:""}\n ${0!==n.length?`<Stages>\n${n}\n</Stages>`:""}\n ${0!==r.length?`<Users>\n${r}\n</Users>`:""}\n </Extensions>\n `}processMarkupComment(e){const{Guid:t,Date:i,Author:s,Comment:n,Viewpoint:r}=e;if(!(t&&i&&s&&(Ys||r)))return null;const a=new Ys(this.components,n??"");return a.guid=t,a.date=new Date(i),a.author=s,a.viewpoint=r?.Guid,a.modifiedAuthor=e.ModifiedAuthor,a.modifiedDate=e.ModifiedDate?new Date(e.ModifiedDate):void 0,a}getMarkupComments(e,t){var i;let s;if("2.1"===t&&(s=e.Comment),"3"===t&&(s=null==(i=e.Topic.Comments)?void 0:i.Comment),!s)return[];s=Array.isArray(s)?s:[s];const n=s.map(a=>this.processMarkupComment(a)).filter(a=>a);return Array.isArray(n)?n:[n]}getMarkupLabels(e,t){var i;let s;return"2.1"===t&&(s=e.Topic.Labels),"3"===t&&(s=null==(i=e.Topic.Labels)?void 0:i.Label),s?Array.isArray(s)?s:[s]:[]}getMarkupViewpoints(e,t){var i;let s;return"2.1"===t&&(s=e.Viewpoints),"3"===t&&(s=null==(i=e.Topic.Viewpoints)?void 0:i.ViewPoint),s?(s=Array.isArray(s)?s:[s],s):[]}getMarkupRelatedTopics(e,t){var i;let s;return"2.1"===t&&(s=e.Topic.RelatedTopic),"3"===t&&(s=null==(i=e.Topic.RelatedTopics)?void 0:i.RelatedTopic),s?(Array.isArray(s)?s:[s]).map(r=>r.Guid):[]}getMarkupDocumentReferences(e,t){var i;let s;return"2.1"===t&&(s=e.Topic.DocumentReference),"3"===t&&(s=null==(i=e.Topic.DocumentReferences)?void 0:i.DocumentReference),s?Array.isArray(s)?s:[s]:[]}load(e){var t=this;return(0,H.A)(function*(){var i,s,n;const{fallbackVersionOnImport:r,ignoreIncompleteTopicsOnImport:a,updateExtensionsOnImport:l}=t.config,c=new Tr;yield c.loadAsync(e);const h=Object.values(c.files);let u=r;const f=h.find(T=>T.name.endsWith(".version"));if(f){const T=yield f.async("string"),A=vi.xmlParser.parse(T).Version.VersionId;u=String(A)}if(!u||"2.1"!==u&&"3"!==u)throw new Error(`BCFTopics: ${u} is not supported.`);const d=h.find(T=>T.name.endsWith(".extensions"));if(l&&d){const T=yield d.async("string");((o,e)=>{if(""===e.trim())return;const t=Dt.xmlParser.parse(e).Extensions;if(!t)return;const{Priorities:i,TopicStatuses:s,TopicTypes:n,Users:r}=t;if(i&&i.Priority){const a=Array.isArray(i.Priority)?i.Priority:[i.Priority];for(const l of a)o.config.priorities.add(l)}if(s&&s.TopicStatus){const a=Array.isArray(s.TopicStatus)?s.TopicStatus:[s.TopicStatus];for(const l of a)o.config.statuses.add(l)}if(n&&n.TopicType){const a=Array.isArray(n.TopicType)?n.TopicType:[n.TopicType];for(const l of a)o.config.types.add(l)}if(r&&r.User){const a=Array.isArray(r.User)?r.User:[r.User];for(const l of a)o.config.users.add(l)}})(t,T)}const y=[],g=t.components.get(de),_=h.filter(T=>T.name.endsWith(".bcfv"));for(const T of _){const A=yield T.async("string"),M=vi.xmlParser.parse(A).VisualizationInfo;if(!M){console.warn("Missing VisualizationInfo in Viewpoint");continue}const S={},{Guid:z,ClippingPlanes:O,Components:N,OrthogonalCamera:Z,PerspectiveCamera:P}=M;if(z&&(S.guid=z),N){const v={selection:[],coloring:[],visibility:{default_visibility:!1,exceptions:[],view_setup_hints:{spaces_visible:!1,space_boundaries_visible:!1,openings_visible:!1}}};S.components=v;const{Selection:R,Visibility:Q}=N;if(R&&R.Component){const Y=Array.isArray(R.Component)?R.Component:[R.Component];v.selection=Y.map(ot=>ot.IfcGuid?{ifc_guid:ot.IfcGuid}:null).filter(ot=>null!==ot)}if(Q&&"DefaultVisibility"in Q&&(v.visibility.default_visibility=Q.DefaultVisibility),Q&&Q.Exceptions&&"Component"in Q.Exceptions){const{Component:Y}=Q.Exceptions,ot=Array.isArray(Y)?Y:[Y];v.visibility.exceptions=ot.map(B=>B.IfcGuid?{ifc_guid:B.IfcGuid}:null).filter(B=>null!==B)}let j;"2.1"===u&&(j=N.ViewSetupHints),"3"===u&&(j=null==(i=N.Visibility)?void 0:i.ViewSetupHints),j&&("OpeningsVisible"in j&&(v.visibility.view_setup_hints.openings_visible=j.OpeningsVisible),"SpacesVisible"in j&&(v.visibility.view_setup_hints.spaces_visible=j.SpacesVisible),"SpaceBoundariesVisible"in j&&(v.visibility.view_setup_hints.space_boundaries_visible=j.SpaceBoundariesVisible));const{Coloring:rt}=N;if(rt&&rt.Color){const Y=Array.isArray(rt.Color)?rt.Color:[rt.Color];for(const ot of Y){const{Color:B,Component:L}=ot;if(6!==B.length&&8!==B.length)continue;const it=6===B.length?B:B.slice(2),K=(Array.isArray(L)?L:[L]).map(gt=>gt.IfcGuid?{ifc_guid:gt.IfcGuid}:null).filter(gt=>null!==gt);v.coloring.push({color:it,components:K})}}}if(Z||P){const v=M.PerspectiveCamera??M.OrthogonalCamera,{CameraViewPoint:R,CameraDirection:Q}=v,j=new b.Pq0(Number(R.X),Number(R.Z),Number(-R.Y)),rt=new b.Pq0(Number(Q.X),Number(Q.Z),Number(-Q.Y)),Y={camera_view_point:{x:j.x,y:j.y,z:j.z},camera_direction:{x:rt.x,y:rt.y,z:rt.z},aspect_ratio:"AspectRatio"in v?v.AspectRatio:1,camera_up_vector:{x:0,y:0,z:0}};"ViewToWorldScale"in v&&(S.orthogonal_camera={...Y,view_to_world_scale:v.ViewToWorldScale}),"FieldOfView"in v&&(S.perspective_camera={...Y,field_of_view:v.FieldOfView})}if(O){const R=(Array.isArray(O.ClippingPlane)?O.ClippingPlane:[O.ClippingPlane]).map(({Location:Q,Direction:j})=>({location:{x:Q.x,y:Q.y,z:Q.z},direction:{x:j.x,y:j.y,z:j.z}}));S.clipping_planes=R}const F=new Nr(t.components,S);y.push(F)}const p={},x=[],E=h.filter(T=>T.name.endsWith(".bcf"));for(const T of E){const A=yield T.async("string"),M=vi.xmlParser.parse(A).Markup,S=M.Topic,{Guid:z,TopicType:O,TopicStatus:N,Title:Z,CreationDate:P,CreationAuthor:F}=S;if(a&&!(z&&O&&N&&Z&&P&&F))continue;const v=new Ar(t.components);v.guid=z??v.guid;const R=t.getMarkupRelatedTopics(M,u);p[v.guid]=new Set(R),v.type=O??v.type,v.status=N??v.status,v.title=Z??v.title,v.creationDate=P?new Date(P):v.creationDate,v.creationAuthor=F??v.creationAuthor,v.serverAssignedId=S.ServerAssignedId,v.priority=S.Priority,v.index=S.Index,v.modifiedDate=S.ModifiedDate?new Date(S.ModifiedDate):void 0,v.modifiedAuthor=S.ModifiedAuthor,v.dueDate=S.DueDate?new Date(S.DueDate):void 0,v.assignedTo=S.AssignedTo,v.description=S.Description,v.stage=S.Stage;const Q=t.getMarkupLabels(M,u);for(const it of Q)v.labels.add(it);const j=t.getMarkupComments(M,u);for(const it of j)v.comments.set(it.guid,it);const rt=t.getMarkupViewpoints(M,u);for(const it of rt){if(!it||!it.Guid)continue;const et=g.list.get(it.Guid);if(!et)continue;v.viewpoints.add(et.guid);const K=`${v.guid}/${it.Snapshot}`,gt=h.find(({name:Ot})=>Ot===K);if(gt){const Ot=yield gt.async("arraybuffer"),ut=new Uint8Array(Ot);g.snapshots.set(et.guid,ut),et.snapshot=et.guid??null}}const Y=t.getMarkupDocumentReferences(M,u),ot=h.find(it=>"documents.xml"===it.name);let B=[];const L=yield ot?.async("string");if(L){const it=null==(n=null==(s=Ai.parser.parse(L).DocumentInfo)?void 0:s.Documents)?void 0:n.Document;B=Array.isArray(it)?it:[it]}for(const it of Y){const{Description:et,DocumentGuid:K,Url:gt,isExternal:Ot,ReferencedDocument:ut}=it;if(K&&B.length>0){const dt=B.find(({Guid:C})=>C===K),Pt=h.find(C=>C.name.endsWith(K)),wt=yield Pt?.async("uint8array");if(!dt||!wt)continue;const{Description:jt,Filename:Vt}=dt;t.documents.set(K,{type:"internal",fileName:Vt,description:jt,data:wt}),v.documentReferences.add(K)}if(gt){const dt=t.documents.add({type:"external",url:gt,description:et});v.documentReferences.add(dt)}if(ut){let dt=null;if(Ot)dt=t.documents.add({type:"external",url:ut,description:et});else{const Pt=ut.split("/"),wt=Pt[Pt.length-1],jt=h.find(C=>C.name.endsWith(wt)),Vt=yield jt?.async("uint8array");if(!Vt)continue;dt=t.documents.add({type:"internal",fileName:wt,data:Vt,description:et})}v.documentReferences.add(dt)}}t.list.set(v.guid,v),x.push(v)}for(const T in p){const A=t.list.get(T);if(!A)continue;const M=p[T];for(const S of M)A.relatedTopics.add(S)}return t.onBCFImported.trigger(x),{viewpoints:y,topics:x}})()}};w(Zs,"uuid","de977976-e4f6-4e4f-a01a-204727839802"),w(Zs,"xmlParser",new vs({allowBooleanAttributes:!0,attributeNamePrefix:"",ignoreAttributes:!1,ignoreDeclaration:!0,ignorePiTags:!0,numberParseOptions:{leadingZeros:!0,hex:!0},parseAttributeValue:!0,preserveOrder:!1,processEntities:!1,removeNSPrefix:!0,trimValues:!0}));let Dt=Zs;const Se=new b.tBo,Lt=new b.Pq0,be=new b.Pq0,At=new b.PTz,Pr={X:new b.Pq0(1,0,0),Y:new b.Pq0(0,1,0),Z:new b.Pq0(0,0,1)},Ws={type:"change"},Sr={type:"mouseDown",mode:null},Ir={type:"mouseUp",mode:null},Mr={type:"objectChange"};class tc extends b.H2z{constructor(e,t=null){super(void 0,t);const i=new oc(this);this._root=i;const s=new ac;this._gizmo=s,i.add(s);const n=new lc;this._plane=n,i.add(n);const r=this;function a(E,T){let A=T;Object.defineProperty(r,E,{get:function(){return void 0!==A?A:T},set:function(M){A!==M&&(A=M,n[E]=M,s[E]=M,r.dispatchEvent({type:E+"-changed",value:M}),r.dispatchEvent(Ws))}}),r[E]=T,n[E]=T,s[E]=T}a("camera",e),a("object",void 0),a("enabled",!0),a("axis",null),a("mode","translate"),a("translationSnap",null),a("rotationSnap",null),a("scaleSnap",null),a("space","world"),a("size",1),a("dragging",!1),a("showX",!0),a("showY",!0),a("showZ",!0),a("minX",-1/0),a("maxX",1/0),a("minY",-1/0),a("maxY",1/0),a("minZ",-1/0),a("maxZ",1/0);const l=new b.Pq0,c=new b.Pq0,h=new b.PTz,u=new b.PTz,f=new b.Pq0,d=new b.PTz,y=new b.Pq0,g=new b.Pq0,_=new b.Pq0,x=new b.Pq0;a("worldPosition",l),a("worldPositionStart",c),a("worldQuaternion",h),a("worldQuaternionStart",u),a("cameraPosition",f),a("cameraQuaternion",d),a("pointStart",y),a("pointEnd",g),a("rotationAxis",_),a("rotationAngle",0),a("eye",x),this._offset=new b.Pq0,this._startNorm=new b.Pq0,this._endNorm=new b.Pq0,this._cameraScale=new b.Pq0,this._parentPosition=new b.Pq0,this._parentQuaternion=new b.PTz,this._parentQuaternionInv=new b.PTz,this._parentScale=new b.Pq0,this._worldScaleStart=new b.Pq0,this._worldQuaternionInv=new b.PTz,this._worldScale=new b.Pq0,this._positionStart=new b.Pq0,this._quaternionStart=new b.PTz,this._scaleStart=new b.Pq0,this._getPointer=ec.bind(this),this._onPointerDown=sc.bind(this),this._onPointerHover=ic.bind(this),this._onPointerMove=nc.bind(this),this._onPointerUp=rc.bind(this),null!==t&&this.connect(t)}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointermove",this._onPointerHover),this.domElement.addEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerHover),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="auto"}getHelper(){return this._root}pointerHover(e){if(void 0===this.object||!0===this.dragging)return;null!==e&&Se.setFromCamera(e,this.camera);const t=qs(this._gizmo.picker[this.mode],Se);this.axis=t?t.object.name:null}pointerDown(e){if(void 0!==this.object&&!0!==this.dragging&&(null==e||0===e.button)&&null!==this.axis){null!==e&&Se.setFromCamera(e,this.camera);const t=qs(this._plane,Se,!0);t&&(this.object.updateMatrixWorld(),this.object.parent.updateMatrixWorld(),this._positionStart.copy(this.object.position),this._quaternionStart.copy(this.object.quaternion),this._scaleStart.copy(this.object.scale),this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this._worldScaleStart),this.pointStart.copy(t.point).sub(this.worldPositionStart)),this.dragging=!0,Sr.mode=this.mode,this.dispatchEvent(Sr)}}pointerMove(e){const t=this.axis,i=this.mode,s=this.object;let n=this.space;if("scale"===i?n="local":("E"===t||"XYZE"===t||"XYZ"===t)&&(n="world"),void 0===s||null===t||!1===this.dragging||null!==e&&-1!==e.button)return;null!==e&&Se.setFromCamera(e,this.camera);const r=qs(this._plane,Se,!0);if(r){if(this.pointEnd.copy(r.point).sub(this.worldPositionStart),"translate"===i)this._offset.copy(this.pointEnd).sub(this.pointStart),"local"===n&&"XYZ"!==t&&this._offset.applyQuaternion(this._worldQuaternionInv),-1===t.indexOf("X")&&(this._offset.x=0),-1===t.indexOf("Y")&&(this._offset.y=0),-1===t.indexOf("Z")&&(this._offset.z=0),"local"===n&&"XYZ"!==t?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),s.position.copy(this._offset).add(this._positionStart),this.translationSnap&&("local"===n&&(s.position.applyQuaternion(At.copy(this._quaternionStart).invert()),-1!==t.search("X")&&(s.position.x=Math.round(s.position.x/this.translationSnap)*this.translationSnap),-1!==t.search("Y")&&(s.position.y=Math.round(s.position.y/this.translationSnap)*this.translationSnap),-1!==t.search("Z")&&(s.position.z=Math.round(s.position.z/this.translationSnap)*this.translationSnap),s.position.applyQuaternion(this._quaternionStart)),"world"===n&&(s.parent&&s.position.add(Lt.setFromMatrixPosition(s.parent.matrixWorld)),-1!==t.search("X")&&(s.position.x=Math.round(s.position.x/this.translationSnap)*this.translationSnap),-1!==t.search("Y")&&(s.position.y=Math.round(s.position.y/this.translationSnap)*this.translationSnap),-1!==t.search("Z")&&(s.position.z=Math.round(s.position.z/this.translationSnap)*this.translationSnap),s.parent&&s.position.sub(Lt.setFromMatrixPosition(s.parent.matrixWorld)))),s.position.x=Math.max(this.minX,Math.min(this.maxX,s.position.x)),s.position.y=Math.max(this.minY,Math.min(this.maxY,s.position.y)),s.position.z=Math.max(this.minZ,Math.min(this.maxZ,s.position.z));else if("scale"===i){if(-1!==t.search("XYZ")){let a=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(a*=-1),be.set(a,a,a)}else Lt.copy(this.pointStart),be.copy(this.pointEnd),Lt.applyQuaternion(this._worldQuaternionInv),be.applyQuaternion(this._worldQuaternionInv),be.divide(Lt),-1===t.search("X")&&(be.x=1),-1===t.search("Y")&&(be.y=1),-1===t.search("Z")&&(be.z=1);s.scale.copy(this._scaleStart).multiply(be),this.scaleSnap&&(-1!==t.search("X")&&(s.scale.x=Math.round(s.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),-1!==t.search("Y")&&(s.scale.y=Math.round(s.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),-1!==t.search("Z")&&(s.scale.z=Math.round(s.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if("rotate"===i){this._offset.copy(this.pointEnd).sub(this.pointStart);const a=20/this.worldPosition.distanceTo(Lt.setFromMatrixPosition(this.camera.matrixWorld));let l=!1;"XYZE"===t?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(Lt.copy(this.rotationAxis).cross(this.eye))*a):("X"===t||"Y"===t||"Z"===t)&&(this.rotationAxis.copy(Pr[t]),Lt.copy(Pr[t]),"local"===n&&Lt.applyQuaternion(this.worldQuaternion),Lt.cross(this.eye),0===Lt.length()?l=!0:this.rotationAngle=this._offset.dot(Lt.normalize())*a),("E"===t||l)&&(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this._startNorm.copy(this.pointStart).normalize(),this._endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this._endNorm.cross(this._startNorm).dot(this.eye)<0?1:-1),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),"local"===n&&"E"!==t&&"XYZE"!==t?(s.quaternion.copy(this._quaternionStart),s.quaternion.multiply(At.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),s.quaternion.copy(At.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),s.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(Ws),this.dispatchEvent(Mr)}}pointerUp(e){null!==e&&0!==e.button||(this.dragging&&null!==this.axis&&(Ir.mode=this.mode,this.dispatchEvent(Ir)),this.dragging=!1,this.axis=null)}dispose(){this.disconnect(),this._root.dispose()}attach(e){return this.object=e,this._root.visible=!0,this}detach(){return this.object=void 0,this.axis=null,this._root.visible=!1,this}reset(){this.enabled&&this.dragging&&(this.object.position.copy(this._positionStart),this.object.quaternion.copy(this._quaternionStart),this.object.scale.copy(this._scaleStart),this.dispatchEvent(Ws),this.dispatchEvent(Mr),this.pointStart.copy(this.pointEnd))}getRaycaster(){return Se}getMode(){return this.mode}setMode(e){this.mode=e}setTranslationSnap(e){this.translationSnap=e}setRotationSnap(e){this.rotationSnap=e}setScaleSnap(e){this.scaleSnap=e}setSize(e){this.size=e}setSpace(e){this.space=e}}function ec(o){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:o.button};{const e=this.domElement.getBoundingClientRect();return{x:(o.clientX-e.left)/e.width*2-1,y:-(o.clientY-e.top)/e.height*2+1,button:o.button}}}function ic(o){if(this.enabled)switch(o.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(o))}}function sc(o){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(o.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(o)),this.pointerDown(this._getPointer(o)))}function nc(o){this.enabled&&this.pointerMove(this._getPointer(o))}function rc(o){this.enabled&&(this.domElement.releasePointerCapture(o.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(o)))}function qs(o,e,t){const i=e.intersectObject(o,!0);for(let s=0;s<i.length;s++)if(i[s].object.visible||t)return i[s];return!1}const Xi=new b.O9p,vt=new b.Pq0(0,1,0),Or=new b.Pq0(0,0,0),kr=new b.kn4,Qi=new b.PTz,Ki=new b.PTz,ae=new b.Pq0,zr=new b.kn4,di=new b.Pq0(1,0,0),Ie=new b.Pq0(0,1,0),fi=new b.Pq0(0,0,1),Ji=new b.Pq0,pi=new b.Pq0,mi=new b.Pq0;class oc extends b.B69{constructor(e){super(),this.isTransformControlsRoot=!0,this.controls=e,this.visible=!1}updateMatrixWorld(e){const t=this.controls;void 0!==t.object&&(t.object.updateMatrixWorld(),null===t.object.parent?console.error("TransformControls: The attached 3D object must be a part of the scene graph."):t.object.parent.matrixWorld.decompose(t._parentPosition,t._parentQuaternion,t._parentScale),t.object.matrixWorld.decompose(t.worldPosition,t.worldQuaternion,t._worldScale),t._parentQuaternionInv.copy(t._parentQuaternion).invert(),t._worldQuaternionInv.copy(t.worldQuaternion).invert()),t.camera.updateMatrixWorld(),t.camera.matrixWorld.decompose(t.cameraPosition,t.cameraQuaternion,t._cameraScale),t.camera.isOrthographicCamera?t.camera.getWorldDirection(t.eye).negate():t.eye.copy(t.cameraPosition).sub(t.worldPosition).normalize(),super.updateMatrixWorld(e)}dispose(){this.traverse(function(e){e.geometry&&e.geometry.dispose(),e.material&&e.material.dispose()})}}class ac extends b.B69{constructor(){super(),this.isTransformControlsGizmo=!0,this.type="TransformControlsGizmo";const e=new b.V9B({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),t=new b.mrM({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),i=e.clone();i.opacity=.15;const s=t.clone();s.opacity=.5;const n=e.clone();n.color.setHex(16711680);const r=e.clone();r.color.setHex(65280);const a=e.clone();a.color.setHex(255);const l=e.clone();l.color.setHex(16711680),l.opacity=.5;const c=e.clone();c.color.setHex(65280),c.opacity=.5;const h=e.clone();h.color.setHex(255),h.opacity=.5;const u=e.clone();u.opacity=.25;const f=e.clone();f.color.setHex(16776960),f.opacity=.25,e.clone().color.setHex(16776960);const y=e.clone();y.color.setHex(7895160);const g=new b.Ho_(0,.04,.1,12);g.translate(0,.05,0);const _=new b.iNn(.08,.08,.08);_.translate(0,.04,0);const p=new b.LoY;p.setAttribute("position",new b.qtW([0,0,0,1,0,0],3));const x=new b.Ho_(.0075,.0075,.5,3);function E(R,Q){const j=new b.O3Y(R,.0075,3,64,Q*Math.PI*2);return j.rotateY(Math.PI/2),j.rotateX(Math.PI/2),j}x.translate(0,.25,0);const A={X:[[new b.eaF(g,n),[.5,0,0],[0,0,-Math.PI/2]],[new b.eaF(g,n),[-.5,0,0],[0,0,Math.PI/2]],[new b.eaF(x,n),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new b.eaF(g,r),[0,.5,0]],[new b.eaF(g,r),[0,-.5,0],[Math.PI,0,0]],[new b.eaF(x,r)]],Z:[[new b.eaF(g,a),[0,0,.5],[Math.PI/2,0,0]],[new b.eaF(g,a),[0,0,-.5],[-Math.PI/2,0,0]],[new b.eaF(x,a),null,[Math.PI/2,0,0]]],XYZ:[[new b.eaF(new b.Ufg(.1,0),u.clone()),[0,0,0]]],XY:[[new b.eaF(new b.iNn(.15,.15,.01),h.clone()),[.15,.15,0]]],YZ:[[new b.eaF(new b.iNn(.15,.15,.01),l.clone()),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new b.eaF(new b.iNn(.15,.15,.01),c.clone()),[.15,0,.15],[-Math.PI/2,0,0]]]},M={X:[[new b.eaF(new b.Ho_(.2,0,.6,4),i),[.3,0,0],[0,0,-Math.PI/2]],[new b.eaF(new b.Ho_(.2,0,.6,4),i),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new b.eaF(new b.Ho_(.2,0,.6,4),i),[0,.3,0]],[new b.eaF(new b.Ho_(.2,0,.6,4),i),[0,-.3,0],[0,0,Math.PI]]],Z:[[new b.eaF(new b.Ho_(.2,0,.6,4),i),[0,0,.3],[Math.PI/2,0,0]],[new b.eaF(new b.Ho_(.2,0,.6,4),i),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new b.eaF(new b.Ufg(.2,0),i)]],XY:[[new b.eaF(new b.iNn(.2,.2,.01),i),[.15,.15,0]]],YZ:[[new b.eaF(new b.iNn(.2,.2,.01),i),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new b.eaF(new b.iNn(.2,.2,.01),i),[.15,0,.15],[-Math.PI/2,0,0]]]},S={START:[[new b.eaF(new b.Ufg(.01,2),s),null,null,null,"helper"]],END:[[new b.eaF(new b.Ufg(.01,2),s),null,null,null,"helper"]],DELTA:[[new b.N1A(function T(){const R=new b.LoY;return R.setAttribute("position",new b.qtW([0,0,0,1,1,1],3)),R}(),s),null,null,null,"helper"]],X:[[new b.N1A(p,s.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new b.N1A(p,s.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new b.N1A(p,s.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},z={XYZE:[[new b.eaF(E(.5,1),y),null,[0,Math.PI/2,0]]],X:[[new b.eaF(E(.5,.5),n)]],Y:[[new b.eaF(E(.5,.5),r),null,[0,0,-Math.PI/2]]],Z:[[new b.eaF(E(.5,.5),a),null,[0,Math.PI/2,0]]],E:[[new b.eaF(E(.75,1),f),null,[0,Math.PI/2,0]]]},O={AXIS:[[new b.N1A(p,s.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},N={XYZE:[[new b.eaF(new b.Gu$(.25,10,8),i)]],X:[[new b.eaF(new b.O3Y(.5,.1,4,24),i),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new b.eaF(new b.O3Y(.5,.1,4,24),i),[0,0,0],[Math.PI/2,0,0]]],Z:[[new b.eaF(new b.O3Y(.5,.1,4,24),i),[0,0,0],[0,0,-Math.PI/2]]],E:[[new b.eaF(new b.O3Y(.75,.1,2,24),i)]]},Z={X:[[new b.eaF(_,n),[.5,0,0],[0,0,-Math.PI/2]],[new b.eaF(x,n),[0,0,0],[0,0,-Math.PI/2]],[new b.eaF(_,n),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new b.eaF(_,r),[0,.5,0]],[new b.eaF(x,r)],[new b.eaF(_,r),[0,-.5,0],[0,0,Math.PI]]],Z:[[new b.eaF(_,a),[0,0,.5],[Math.PI/2,0,0]],[new b.eaF(x,a),[0,0,0],[Math.PI/2,0,0]],[new b.eaF(_,a),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new b.eaF(new b.iNn(.15,.15,.01),h),[.15,.15,0]]],YZ:[[new b.eaF(new b.iNn(.15,.15,.01),l),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new b.eaF(new b.iNn(.15,.15,.01),c),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new b.eaF(new b.iNn(.1,.1,.1),u.clone())]]},P={X:[[new b.eaF(new b.Ho_(.2,0,.6,4),i),[.3,0,0],[0,0,-Math.PI/2]],[new b.eaF(new b.Ho_(.2,0,.6,4),i),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new b.eaF(new b.Ho_(.2,0,.6,4),i),[0,.3,0]],[new b.eaF(new b.Ho_(.2,0,.6,4),i),[0,-.3,0],[0,0,Math.PI]]],Z:[[new b.eaF(new b.Ho_(.2,0,.6,4),i),[0,0,.3],[Math.PI/2,0,0]],[new b.eaF(new b.Ho_(.2,0,.6,4),i),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new b.eaF(new b.iNn(.2,.2,.01),i),[.15,.15,0]]],YZ:[[new b.eaF(new b.iNn(.2,.2,.01),i),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new b.eaF(new b.iNn(.2,.2,.01),i),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new b.eaF(new b.iNn(.2,.2,.2),i),[0,0,0]]]},F={X:[[new b.N1A(p,s.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new b.N1A(p,s.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new b.N1A(p,s.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function v(R){const Q=new b.B69;for(const j in R)for(let rt=R[j].length;rt--;){const Y=R[j][rt][0].clone(),ot=R[j][rt][1],B=R[j][rt][2],L=R[j][rt][3],it=R[j][rt][4];Y.name=j,Y.tag=it,ot&&Y.position.set(ot[0],ot[1],ot[2]),B&&Y.rotation.set(B[0],B[1],B[2]),L&&Y.scale.set(L[0],L[1],L[2]),Y.updateMatrix();const et=Y.geometry.clone();et.applyMatrix4(Y.matrix),Y.geometry=et,Y.renderOrder=1/0,Y.position.set(0,0,0),Y.rotation.set(0,0,0),Y.scale.set(1,1,1),Q.add(Y)}return Q}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=v(A)),this.add(this.gizmo.rotate=v(z)),this.add(this.gizmo.scale=v(Z)),this.add(this.picker.translate=v(M)),this.add(this.picker.rotate=v(N)),this.add(this.picker.scale=v(P)),this.add(this.helper.translate=v(S)),this.add(this.helper.rotate=v(O)),this.add(this.helper.scale=v(F)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(e){const i="local"===("scale"===this.mode?"local":this.space)?this.worldQuaternion:Ki;this.gizmo.translate.visible="translate"===this.mode,this.gizmo.rotate.visible="rotate"===this.mode,this.gizmo.scale.visible="scale"===this.mode,this.helper.translate.visible="translate"===this.mode,this.helper.rotate.visible="rotate"===this.mode,this.helper.scale.visible="scale"===this.mode;let s=[];s=s.concat(this.picker[this.mode].children),s=s.concat(this.gizmo[this.mode].children),s=s.concat(this.helper[this.mode].children);for(let n=0;n<s.length;n++){const r=s[n];let a;r.visible=!0,r.rotation.set(0,0,0),r.position.copy(this.worldPosition),a=this.camera.isOrthographicCamera?(this.camera.top-this.camera.bottom)/this.camera.zoom:this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),r.scale.set(1,1,1).multiplyScalar(a*this.size/4),"helper"!==r.tag?(r.quaternion.copy(i),"translate"===this.mode||"scale"===this.mode?("X"===r.name&&Math.abs(vt.copy(di).applyQuaternion(i).dot(this.eye))>.99&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),"Y"===r.name&&Math.abs(vt.copy(Ie).applyQuaternion(i).dot(this.eye))>.99&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),"Z"===r.name&&Math.abs(vt.copy(fi).applyQuaternion(i).dot(this.eye))>.99&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),"XY"===r.name&&Math.abs(vt.copy(fi).applyQuaternion(i).dot(this.eye))<.2&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),"YZ"===r.name&&Math.abs(vt.copy(di).applyQuaternion(i).dot(this.eye))<.2&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),"XZ"===r.name&&Math.abs(vt.copy(Ie).applyQuaternion(i).dot(this.eye))<.2&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1)):"rotate"===this.mode&&(Qi.copy(i),vt.copy(this.eye).applyQuaternion(At.copy(i).invert()),-1!==r.name.search("E")&&r.quaternion.setFromRotationMatrix(kr.lookAt(this.eye,Or,Ie)),"X"===r.name&&(At.setFromAxisAngle(di,Math.atan2(-vt.y,vt.z)),At.multiplyQuaternions(Qi,At),r.quaternion.copy(At)),"Y"===r.name&&(At.setFromAxisAngle(Ie,Math.atan2(vt.x,vt.z)),At.multiplyQuaternions(Qi,At),r.quaternion.copy(At)),"Z"===r.name&&(At.setFromAxisAngle(fi,Math.atan2(vt.y,vt.x)),At.multiplyQuaternions(Qi,At),r.quaternion.copy(At))),r.visible=r.visible&&(-1===r.name.indexOf("X")||this.showX),r.visible=r.visible&&(-1===r.name.indexOf("Y")||this.showY),r.visible=r.visible&&(-1===r.name.indexOf("Z")||this.showZ),r.visible=r.visible&&(-1===r.name.indexOf("E")||this.showX&&this.showY&&this.showZ),r.material._color=r.material._color||r.material.color.clone(),r.material._opacity=r.material._opacity||r.material.opacity,r.material.color.copy(r.material._color),r.material.opacity=r.material._opacity,this.enabled&&this.axis&&(r.name===this.axis||this.axis.split("").some(function(l){return r.name===l}))&&(r.material.color.setHex(16776960),r.material.opacity=1)):(r.visible=!1,"AXIS"===r.name?(r.visible=!!this.axis,"X"===this.axis&&(At.setFromEuler(Xi.set(0,0,0)),r.quaternion.copy(i).multiply(At),Math.abs(vt.copy(di).applyQuaternion(i).dot(this.eye))>.9&&(r.visible=!1)),"Y"===this.axis&&(At.setFromEuler(Xi.set(0,0,Math.PI/2)),r.quaternion.copy(i).multiply(At),Math.abs(vt.copy(Ie).applyQuaternion(i).dot(this.eye))>.9&&(r.visible=!1)),"Z"===this.axis&&(At.setFromEuler(Xi.set(0,Math.PI/2,0)),r.quaternion.copy(i).multiply(At),Math.abs(vt.copy(fi).applyQuaternion(i).dot(this.eye))>.9&&(r.visible=!1)),"XYZE"===this.axis&&(At.setFromEuler(Xi.set(0,Math.PI/2,0)),vt.copy(this.rotationAxis),r.quaternion.setFromRotationMatrix(kr.lookAt(Or,vt,Ie)),r.quaternion.multiply(At),r.visible=this.dragging),"E"===this.axis&&(r.visible=!1)):"START"===r.name?(r.position.copy(this.worldPositionStart),r.visible=this.dragging):"END"===r.name?(r.position.copy(this.worldPosition),r.visible=this.dragging):"DELTA"===r.name?(r.position.copy(this.worldPositionStart),r.quaternion.copy(this.worldQuaternionStart),Lt.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),Lt.applyQuaternion(this.worldQuaternionStart.clone().invert()),r.scale.copy(Lt),r.visible=this.dragging):(r.quaternion.copy(i),r.position.copy(this.dragging?this.worldPositionStart:this.worldPosition),this.axis&&(r.visible=-1!==this.axis.search(r.name))))}super.updateMatrixWorld(e)}}class lc extends b.eaF{constructor(){super(new b.bdM(1e5,1e5,2,2),new b.V9B({visible:!1,wireframe:!0,side:b.$EB,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type="TransformControlsPlane"}updateMatrixWorld(e){let t=this.space;switch(this.position.copy(this.worldPosition),"scale"===this.mode&&(t="local"),Ji.copy(di).applyQuaternion("local"===t?this.worldQuaternion:Ki),pi.copy(Ie).applyQuaternion("local"===t?this.worldQuaternion:Ki),mi.copy(fi).applyQuaternion("local"===t?this.worldQuaternion:Ki),vt.copy(pi),this.mode){case"translate":case"scale":switch(this.axis){case"X":vt.copy(this.eye).cross(Ji),ae.copy(Ji).cross(vt);break;case"Y":vt.copy(this.eye).cross(pi),ae.copy(pi).cross(vt);break;case"Z":vt.copy(this.eye).cross(mi),ae.copy(mi).cross(vt);break;case"XY":ae.copy(mi);break;case"YZ":ae.copy(Ji);break;case"XZ":vt.copy(mi),ae.copy(pi);break;case"XYZ":case"E":ae.set(0,0,0)}break;default:ae.set(0,0,0)}0===ae.length()?this.quaternion.copy(this.cameraQuaternion):(zr.lookAt(Lt.set(0,0,0),ae,vt),this.quaternion.setFromRotationMatrix(zr)),super.updateMatrixWorld(e)}}class Gs{constructor(e,t,i,s,n,r=5,a=!0){var l;if(w(this,"onDraggingStarted",new X),w(this,"onDraggingEnded",new X),w(this,"onDisposed",new X),w(this,"normal"),w(this,"origin"),w(this,"three",new b.Zcv),w(this,"components"),w(this,"world"),w(this,"type","default"),w(this,"_title","Clipping Plane"),w(this,"_helper"),w(this,"_visible",!0),w(this,"_enabled",!0),w(this,"_controlsActive",!1),w(this,"_arrowBoundBox",new b.eaF),w(this,"_planeMesh"),w(this,"_controls"),w(this,"_hiddenMaterial",new b.V9B({visible:!1})),w(this,"_sizeMultiplier",5),w(this,"_autoScale",!0),w(this,"_visibilityBeforeDisabled",!0),w(this,"notifyManager",()=>{const c=this.components.get(Ze),h=c.list.getKey(this);h&&c.list.set(h,this)}),w(this,"update",()=>{this._enabled&&(this.three.setFromNormalAndCoplanarPoint(this.normal,this._helper.position),this.updateScale())}),w(this,"updateScale",()=>{var c;if(!this.autoScale)return;const h=null==(c=this.world.camera)?void 0:c.three;if(!(h&&h instanceof b.ubm))return;const u=new b.Pq0;h.getWorldPosition(u);const d=u.distanceTo(this._helper.position)/7*this._sizeMultiplier;this._planeMesh.scale.set(d,d,d)}),w(this,"changeDrag",c=>{this._visible=!c.value,this.preventCameraMovement(),this.notifyDraggingChanged(c)}),this.components=e,this.world=t,!t.renderer)throw new Error("The given world must have a renderer!");this.normal=s,this.origin=i,this._sizeMultiplier=r,t.renderer.setPlane(!0,this.three),this._planeMesh=Gs.newPlaneMesh(r,n),this._helper=this.newHelper(),this._controls=this.newTransformControls(),this.three.setFromNormalAndCoplanarPoint(s,i),a&&this.toggleControls(!0),this.updateScale(),null!=(l=t.camera)&&l.controls&&t.camera.controls.addEventListener("update",this.updateScale)}set title(e){this._title=e,this.notifyManager()}get title(){return this._title}get autoScale(){return this._autoScale}set autoScale(e){this._autoScale=e,e&&this.updateScale()}get enabled(){return this._enabled}set enabled(e){if(!this.world.isDisposing){if(!this.world.renderer)throw new Error("No renderer found for clipping plane!");this._enabled=e,e?this.visible=this._visibilityBeforeDisabled:(this._visibilityBeforeDisabled=this.visible,this.visible=!1),this.world.renderer.setPlane(e,this.three),this.notifyManager()}}get visible(){return this._visible}set visible(e){this._visible=e,this._controls.getHelper().visible=e,this._helper.visible=e,this.toggleControls(e),this.notifyManager()}get meshes(){return[this._planeMesh,this._arrowBoundBox]}get planeMaterial(){return this._planeMesh.material}set planeMaterial(e){this._planeMesh.material=e}get size(){return this._sizeMultiplier}set size(e){this._sizeMultiplier=e,this.autoScale?this.updateScale():this._planeMesh.scale.set(e,e,e)}get helper(){return this._helper}get controls(){return this._controls}setFromNormalAndCoplanarPoint(e,t){this.reset(),this.normal.equals(e)||(this.normal.copy(e),this._helper.lookAt(e)),this.origin.copy(t),this._helper.position.copy(t),this._helper.updateMatrix(),this.update()}dispose(){var e;this._enabled=!1,null!=(e=this.world.camera)&&e.controls&&this.world.camera.controls.removeEventListener("update",this.updateScale),this.onDraggingStarted.reset(),this.onDraggingEnded.reset(),this._helper.removeFromParent(),this.world.renderer&&this.world.renderer.setPlane(!1,this.three),this._arrowBoundBox.removeFromParent(),this._arrowBoundBox.geometry.dispose(),this._planeMesh.geometry.dispose(),this._controls.getHelper().removeFromParent(),this._controls.dispose(),this.onDisposed.trigger(),this.onDisposed.reset()}reset(){const e=new b.Pq0(1,0,0),t=new b.Pq0;this.normal.equals(e)||(this.normal.copy(e),this._helper.lookAt(e)),this.origin.copy(t),this._helper.position.copy(t),this._helper.updateMatrix()}toggleControls(e){if(e){if(this._controlsActive)return;this._controls.addEventListener("change",this.update),this._controls.addEventListener("dragging-changed",this.changeDrag)}else this._controls.removeEventListener("change",this.update),this._controls.removeEventListener("dragging-changed",this.changeDrag);this._controlsActive=e}newTransformControls(){if(!this.world.renderer)throw new Error("No renderer found for clipping plane!");const i=new tc(this.world.camera.three,this.world.renderer.three.domElement);return this.initializeControls(i),this.world.scene.three.add(i.getHelper()),i}initializeControls(e){e.attach(this._helper),e.showX=!1,e.showY=!1,e.setSpace("local"),this.createArrowBoundingBox(),e.getHelper().children[0].children[0].add(this._arrowBoundBox)}createArrowBoundingBox(){this._arrowBoundBox.geometry=new b.Ho_(.18,.18,1.2),this._arrowBoundBox.material=this._hiddenMaterial,this._arrowBoundBox.rotateX(Math.PI/2),this._arrowBoundBox.updateMatrix(),this._arrowBoundBox.geometry.applyMatrix4(this._arrowBoundBox.matrix)}notifyDraggingChanged(e){e.value?this.onDraggingStarted.trigger():this.onDraggingEnded.trigger()}preventCameraMovement(){this.world.camera.enabled=this._visible}newHelper(){const e=new b.B69;return e.lookAt(this.normal),e.position.copy(this.origin),this._planeMesh.position.z+=.01,e.add(this._planeMesh),this.world.scene.three.add(e),e}static newPlaneMesh(e,t){const i=new b.bdM(1),s=new b.eaF(i,t);return s.scale.set(e,e,e),s}}class cc extends ii{constructor(){super(...arguments),w(this,"_config",{enabled:{value:!0,type:"Boolean"},visible:{value:!0,type:"Boolean"},color:{value:new b.Q1f,type:"Color"},opacity:{type:"Number",interpolable:!0,value:1,min:0,max:1},size:{type:"Number",interpolable:!0,value:2,min:0,max:100}})}get enabled(){return this._config.enabled.value}set enabled(e){this._config.enabled.value=e,this._component.enabled=e}get visible(){return this._config.visible.value}set visible(e){this._config.visible.value=e,this._component.visible=e}get color(){return this._config.color.value}set color(e){this._config.color.value=e,this._component.material.color.copy(e)}get opacity(){return this._config.opacity.value}set opacity(e){this._config.opacity.value=e,this._component.material.opacity=e}get size(){return this._config.size.value}set size(e){this._config.size.value=e,this._component.size=e}}const Fr=class ns extends Tt{constructor(e){super(e),w(this,"onSetup",new X),w(this,"onBeforeDrag",new X),w(this,"onAfterDrag",new X),w(this,"onBeforeCreate",new X),w(this,"onBeforeCancel",new X),w(this,"onAfterCancel",new X),w(this,"onBeforeDelete",new X),w(this,"onAfterCreate",new X),w(this,"onAfterDelete",new X),w(this,"onDisposed",new X),w(this,"isSetup",!1),w(this,"orthogonalY",!1),w(this,"toleranceOrthogonalY",.7),w(this,"autoScalePlanes",!0),w(this,"Type",Gs),w(this,"list",new ft.jp),w(this,"config",new cc(this,this.components,"Clipper",ns.uuid)),w(this,"_defaultConfig",{color:new b.Q1f(12255487),opacity:.2,size:2}),w(this,"_material",new b.V9B({color:12255487,side:b.$EB,transparent:!0,opacity:.2})),w(this,"_size",5),w(this,"_enabled",!1),w(this,"_visible",!0),w(this,"onStateChanged",new X),this.components.add(ns.uuid,this),this.setEvents()}get enabled(){return this._enabled}set enabled(e){this._enabled=e,this.onStateChanged.trigger(["enabled"])}get visible(){return this._visible}set visible(e){this._visible=e;for(const[t,i]of this.list)i.visible=e;this.onStateChanged.trigger(["visibility"])}get material(){return this._material}set material(e){this._material=e;for(const[t,i]of this.list)i.planeMaterial=e;this.onStateChanged.trigger(["material"])}get size(){return this._size}set size(e){this._size=e;for(const[t,i]of this.list)i.size=e;this.onStateChanged.trigger(["size"])}setEvents(){this.list.onBeforeDelete.add(({value:e})=>{if(!e.world.renderer)throw new Error("Renderer not found for this plane's world!");e.world.renderer.setPlane(!1,e.three),e.dispose(),this.updateMaterialsAndPlanes(),this.onAfterDelete.trigger(e)})}dispose(){this._enabled=!1,this.components.get(Pi).list.delete(this.config.uuid),this.list.clear(),this._material.dispose(),this.onBeforeCreate.reset(),this.onBeforeCancel.reset(),this.onBeforeDelete.reset(),this.onBeforeDrag.reset(),this.onAfterCreate.reset(),this.onAfterCancel.reset(),this.onAfterDelete.reset(),this.onAfterDrag.reset(),this.onDisposed.trigger(ns.uuid),this.onDisposed.reset()}create(e){var t=this;return(0,H.A)(function*(){const n=yield t.components.get(Si).get(e).castRay();return n?t.createPlaneFromIntersection(e,n):null})()}createFromNormalAndCoplanarPoint(e,t,i){const s=this.newPlane(e,i,t);return this.updateMaterialsAndPlanes(),s}delete(e,t){var i=this;return(0,H.A)(function*(){if(!t){const s=yield i.pickPlane(e);if(!s)return;t=i.list.getKey(s)}t&&i.list.delete(t)})()}deleteAll(e){for(const[t,i]of this.list)(!e||e.has(i.type))&&this.list.delete(t)}setup(e){const t={...this._defaultConfig,...e};this.config.color=t.color,this.config.opacity=t.opacity,this.config.size=t.size,this.isSetup=!0,this.onSetup.trigger()}pickPlane(e){const i=this.components.get(Si).get(e),s=this.getAllPlaneMeshes(),n=i.castRayToObjects(s);if(n){const r=n.object;return[...this.list.values()].find(a=>a.meshes.includes(r))}}getAllPlaneMeshes(){const e=[];for(const[t,i]of this.list)e.push(...i.meshes);return e}createPlaneFromIntersection(e,t){var i;if(!e.renderer)throw new Error("The given world must have a renderer!");const s=t.point.distanceTo(new b.Pq0(0,0,0)),n=t.normal||(null==(i=t.face)?void 0:i.normal);if(!s||!n)return null;const r=this.getWorldNormal(t,n),a=this.newPlane(e,t.point,r.negate()),l=this.list.get(a);return l.visible=this._visible,l.size=this._size,e.renderer.setPlane(!0,l.three),this.updateMaterialsAndPlanes(),l}getWorldNormal(e,t){const i=e.object;let s=e.object.matrixWorld.clone();if(i instanceof b.ZLX&&void 0!==e.instanceId){const l=new b.kn4;i.getMatrixAt(e.instanceId,l),s=l.multiply(s)}const r=(new b.dwI).getNormalMatrix(s),a=t.clone().applyMatrix3(r).normalize();return this.normalizePlaneDirectionY(a),a}normalizePlaneDirectionY(e){this.orthogonalY&&(e.y>this.toleranceOrthogonalY&&(e.x=0,e.y=1,e.z=0),e.y<-this.toleranceOrthogonalY&&(e.x=0,e.y=-1,e.z=0))}newPlane(e,t,i){const s=new this.Type(this.components,e,t,i,this._material);s.autoScale=this.autoScalePlanes,s.onDraggingStarted.add(()=>this.onBeforeDrag.trigger(s)),s.onDraggingEnded.add(()=>this.onAfterDrag.trigger(s));const n=Yt.create();return this.list.set(n,s),this.onAfterCreate.trigger(s),n}updateMaterialsAndPlanes(){const e=this.components.get(bs);for(const[t,i]of e.list){if(!i.renderer)continue;i.renderer.updateClippingPlanes();const{clippingPlanes:s}=i.renderer;for(const n of i.meshes)if(n.material)if(Array.isArray(n.material))for(const r of n.material)r.clippingPlanes=s;else n.material.clippingPlanes=s}}};w(Fr,"uuid","66290bc5-18c4-4cd1-9379-2e17a0617611");let Ze=Fr;class Nr{constructor(e,t){w(this,"title"),w(this,"guid",Yt.create()),w(this,"clippingPlanes",new ft.PG),w(this,"camera",{aspect_ratio:1,field_of_view:60,camera_direction:{x:0,y:0,z:0},camera_view_point:{x:0,y:0,z:0},camera_up_vector:{x:0,y:1,z:0}}),w(this,"customData",{}),w(this,"exceptionComponents",new ft.PG),w(this,"selectionComponents",new ft.PG),w(this,"componentColors",new ft.jp),w(this,"spacesVisible",!1),w(this,"spaceBoundariesVisible",!1),w(this,"openingsVisible",!1),w(this,"defaultVisibility",!0),w(this,"snapshot",this.guid),w(this,"_components"),w(this,"_world",null),w(this,"notifyUpdate",()=>{this._components.get(de).list.set(this.guid,this)}),this._components=e,t&&(this.guid=t.guid??this.guid,this.set(t)),this.setEvents()}getSelectionMap(){var e=this;return(0,H.A)(function*(){return yield e._components.get(ct).guidsToModelIdMap([...e.selectionComponents])})()}getExceptionMap(){var e=this;return(0,H.A)(function*(){return yield e._components.get(ct).guidsToModelIdMap([...e.exceptionComponents])})()}get projection(){return"field_of_view"in this.camera?"Perspective":"Orthographic"}get position(){const e=this._components.get(ct),{camera_view_point:t}=this.camera,{x:i,y:s,z:n}=t,r=new b.Pq0(i,s,n);return e.applyBaseCoordinateSystem(r,new b.kn4),r}set position(e){const t=e.clone(),i=this._components.get(ct);e.clone().applyMatrix4(i.baseCoordinationMatrix.clone().invert()),this.camera.camera_view_point={x:t.x,y:t.y,z:t.z}}get direction(){const{camera_direction:e}=this.camera,{x:t,y:i,z:s}=e;return new b.Pq0(t,i,s)}set world(e){this._world=e}get world(){return this._world}get _managerVersion(){return this._components.get(Dt).config.version}get topics(){return[...this._components.get(Dt).list.values()].filter(s=>s.viewpoints.has(this.guid))}setEvents(){this.selectionComponents.onUpdated.add(this.notifyUpdate),this.exceptionComponents.onUpdated.add(this.notifyUpdate),this.clippingPlanes.onUpdated.add(this.notifyUpdate),this.componentColors.onItemSet.add(this.notifyUpdate),this.componentColors.onItemDeleted.add(this.notifyUpdate),this.componentColors.onItemUpdated.add(this.notifyUpdate),this.componentColors.onCleared.add(this.notifyUpdate)}set(e){this.title=e.title;const{components:t,perspective_camera:i,orthogonal_camera:s,clipping_planes:n}=e;if(t){const{selection:r,visibility:a,coloring:l}=t;if(r){this.selectionComponents.clear();for(const{ifc_guid:c}of r)c&&this.selectionComponents.add(c)}if(a){const{default_visibility:c,exceptions:h,view_setup_hints:u}=a;if(void 0!==c&&(this.defaultVisibility=c),h){this.exceptionComponents.clear();for(const{ifc_guid:f}of h)f&&this.exceptionComponents.add(f)}if(u){const{spaces_visible:f,space_boundaries_visible:d,openings_visible:y}=u;void 0!==f&&(this.spacesVisible=f),void 0!==d&&(this.spaceBoundariesVisible=d),void 0!==y&&(this.openingsVisible=y)}}if(l){this.componentColors.clear();for(const c of l){const{color:h,components:u}=c,f=u.map(d=>d.ifc_guid).filter(d=>null!==d);this.componentColors.set(h,f)}}}if((i||s)&&(this.camera=i??s),n&&this.world){const r=this._components.get(Ze);for(const a of n){const{location:l,direction:c}=a,h=new b.Pq0(l.x,l.z,-l.y),u=new b.Pq0(c.x,c.z,-c.y),f=r.createFromNormalAndCoplanarPoint(this.world,u,h);this.clippingPlanes.add(f),r.list.get(f).enabled=!1,r.list.get(f).visible=!1}}this.notifyUpdate()}go(e){var t=this;return(0,H.A)(function*(){if(!t.world)return;const{camera:i}=t.world;if(!(i instanceof Hs))throw new Error("Viewpoint: the world's camera component must be of type OrthoPerspectiveCamera to switch between perspective and orthographic projections.");const{transition:s,applyClippings:n,applyVisibility:r,clippingsVisibility:a}={transition:!0,applyClippings:!0,applyVisibility:!0,clippingsVisibility:!0,...e};i.projection.set(t.projection);const l=new b.Pq0(t.camera.camera_view_point.x,t.camera.camera_view_point.y,t.camera.camera_view_point.z),c=new b.Pq0(t.camera.camera_direction.x,t.camera.camera_direction.y,t.camera.camera_direction.z);if(l.equals(new b.Pq0)&&c.equals(new b.Pq0))return;const h=t.position,u=t.direction,d={x:h.x+80*u.x,y:h.y+80*u.y,z:h.z+80*u.z},y=[];n&&t.setClippingState(!0),r&&y.push(t.applyVisibility()),t.setClippingVisibility(a),y.push(i.controls.setLookAt(h.x,h.y,h.z,d.x,d.y,d.z,s)),yield Promise.all(y)})()}updateCamera(){var e=this;return(0,H.A)(function*(t=!0){return new Promise(i=>{if(!e.world)return void i(!1);const{camera:s,renderer:n}=e.world;if(!n)throw new Error("Viewpoint: the world needs to have a renderer!");if(!s.hasCameraControls())throw new Error("Viewpoint: world's camera need camera controls!");const r=new b.Pq0;s.controls.getPosition(r);const a=s.three,l=new b.Pq0(0,0,-1).applyEuler(a.rotation),{width:c,height:h}=n.getSize();let u=c/h;Number.isNaN(u)&&(u=1);const f=e._components.get(ct);r.applyMatrix4(f.baseCoordinationMatrix.clone().invert());const d={aspect_ratio:u,camera_view_point:{x:r.x,y:r.y,z:r.z},camera_direction:{x:l.x,y:l.y,z:l.z},camera_up_vector:{x:0,y:1,z:0}};if(a instanceof b.ubm?e.camera={...d,field_of_view:a.fov}:a instanceof b.qUd&&(e.camera={...d,view_to_world_scale:a.top-a.bottom}),t){const y=e._components.get(de),g=n.three.domElement;n.three.render(e.world.scene.three,s.three),g.toBlob(function(){var _=(0,H.A)(function*(p){if(p){const x=yield p.arrayBuffer(),E=new Uint8Array(x);y.snapshots.set(e.guid,E)}e.notifyUpdate(),i(!0)});return function(p){return _.apply(this,arguments)}}())}else e.notifyUpdate(),i(!0)})}).apply(this,arguments)}takeSnapshot(){var e=this;return new Promise(t=>{if(!this.world)return void t(!1);const{camera:i,renderer:s}=this.world;if(!s)throw new Error("Viewpoint: the world needs to have a renderer!");const n=this._components.get(de),r=s.three.domElement;s.three.render(this.world.scene.three,i.three),r.toBlob(function(){var a=(0,H.A)(function*(l){if(l){const c=yield l.arrayBuffer(),h=new Uint8Array(c);n.snapshots.set(e.guid,h)}e.notifyUpdate(),t(!0)});return function(l){return a.apply(this,arguments)}}())})}updateClippingPlanes(){this.clippingPlanes.clear();const e=this._components.get(Ze);for(const[t,i]of e.list)i.enabled&&this.clippingPlanes.add(t)}applyVisibility(){var e=this;return(0,H.A)(function*(){const t=e._components.get(Ia);t.set(e.defaultVisibility);const i=yield e.getExceptionMap();t.set(!e.defaultVisibility,i);const s=yield e.getSelectionMap();t.set(!0,s)})()}setColorizationState(e){var t=this;return(0,H.A)(function*(){const i=t._components.get(ct),s=[];if(e)for(const[n,r]of t.componentColors){const a=`#${n}`,l=yield i.guidsToModelIdMap(r);for(const[c,h]of Object.entries(l)){const u=i.list.get(c);u&&s.push(u.highlight([...h],{customId:a,color:new b.Q1f(a),renderedFaces:ft.eB.ONE,opacity:1,transparent:!1}))}}else for(const[n,r]of t.componentColors){const a=yield i.guidsToModelIdMap(r);for(const[l,c]of Object.entries(a)){const h=i.list.get(l);h&&s.push(h.resetHighlight([...c]))}}s.push(i.core.update(!0)),yield Promise.all(s)})()}setClippingState(e){const t=this._components.get(Ze);for(const[i,s]of t.list)s.enabled=e&&this.clippingPlanes.has(i)}setClippingVisibility(e){const t=this._components.get(Ze);for(const i of this.clippingPlanes){const s=t.list.get(i);s&&(s.visible=e)}}createComponentTags(e){var t=this;return(0,H.A)(function*(){var i;const s=t._components.get(ct);let r="";if(t._components.get(Dt).config.includeSelectionTag){const a="selection"===e?yield t.getSelectionMap():yield t.getExceptionMap();for(const l in a){const c=s.list.get(l);if(!c)continue;const h=a[l];for(const u of h){const f=c.getItem(u),d=yield f.getGuid();if(!d)continue;const y=null==(i=yield f.getAttributes())?void 0:i.getValue("Tag");let g=null;y&&(g=`AuthoringToolId="${y}"`),r+=`\n<Component IfcGuid="${d}" ${g??""} />`}}}else r=[...t.selectionComponents].map(a=>`<Component IfcGuid="${a}" />`).join("\n");return r})()}createColorTags(){let e="";for(const[t,i]of this.componentColors.entries())e+=`<Color Color="${t}">\n${i.map(n=>`\n<Component IfcGuid="${n}" />`).join("\n")}\n</Color>`;return 0!==e.length?`<Coloring>\n${e}\n</Coloring>`:"<Coloring />"}toJSON(){const e=this._components.get(Ze),t={guid:this.guid,components:{selection:[...this.selectionComponents].map(n=>({ifc_guid:n,authoring_tool_id:null})),coloring:[...this.componentColors].map(([n,r])=>({color:n,components:r.map(a=>({ifc_guid:a,authoring_tool_id:null}))})),visibility:{default_visibility:this.defaultVisibility,exceptions:[...this.exceptionComponents].map(n=>({ifc_guid:n,authoring_tool_id:null})),view_setup_hints:{spaces_visible:this.spacesVisible,space_boundaries_visible:this.spaceBoundariesVisible,openings_visible:this.openingsVisible}}},clipping_planes:[...this.clippingPlanes].map(n=>{const r=e.list.get(n);if(!r)return null;const a=r._controls.worldPosition??r.origin,{normal:l}=r;return{location:{x:a.x,y:-a.z,z:a.y},direction:{x:l.x,y:-l.z,z:l.y}}}).filter(n=>null!==n)};"field_of_view"in this.camera?t.perspective_camera=this.camera:t.orthogonal_camera=this.camera;const i=this._components.get(de),s=i.snapshots.get(this.snapshot);if(s){const n=s.toString(),r=btoa(n),a=i.getSnapshotExtension(this.snapshot);t.snapshot={snapshot_type:a,snapshot_data:r}}return t}serialize(){var e=this;return(0,H.A)(function*(t=e._managerVersion){const i=e._components.get(ct),s=e.position;s.applyMatrix4(i.baseCoordinationMatrix.clone().invert());const n=e.direction;n.normalize();const r=(new b.kn4).makeRotationX(Math.PI/2),a=n.clone().applyMatrix4(r);a.normalize();const l=`<CameraViewPoint>\n <X>${s.x}</X>\n <Y>${-s.z}</Y>\n <Z>${s.y}</Z>\n </CameraViewPoint>`,c=`<CameraDirection>\n <X>${n.x}</X>\n <Y>${-n.z}</Y>\n <Z>${n.y}</Z>\n </CameraDirection>`,h=`<CameraUpVector>\n <X>${a.x}</X>\n <Y>${-a.z}</Y>\n <Z>${a.y}</Z>\n </CameraUpVector>`,u=`<AspectRatio>${e.camera.aspect_ratio}</AspectRatio>`;let f="";"view_to_world_scale"in e.camera?f=`<OrthogonalCamera>\n ${l}\n ${c}\n ${h}\n ${u}\n <ViewToWorldScale>${e.camera.view_to_world_scale}</ViewToWorldScale>\n </OrthogonalCamera>`:"field_of_view"in e.camera&&(f=`<PerspectiveCamera>\n ${l}\n ${c}\n ${h}\n ${u}\n <FieldOfView>${e.camera.field_of_view}</FieldOfView>\n </PerspectiveCamera>`);const d=`<ViewSetupHints SpacesVisible="${e.spacesVisible??!1}" SpaceBoundariesVisible="${e.spaceBoundariesVisible??!1}" OpeningsVisible="${e.openingsVisible??!1}" />`,y=(yield e.createComponentTags("selection")).trim(),g=(yield e.createComponentTags("exception")).trim(),_=e.createColorTags();return`<?xml version="1.0" encoding="UTF-8"?>\n <VisualizationInfo Guid="${e.guid}">\n <Components>\n ${"2.1"===t?d:""}\n ${0!==y.length?`<Selection>${y}</Selection>`:""}\n <Visibility DefaultVisibility="${e.defaultVisibility}">\n ${"3"===t?d:""}\n ${0!==g.length?`<Exceptions>${g}</Exceptions>`:""}\n </Visibility>\n ${_}\n </Components>\n ${f}\n </VisualizationInfo>`}).apply(this,arguments)}}class hc extends ii{constructor(){super(...arguments),w(this,"_config",{overwriteColors:{value:!1,type:"Boolean"}})}get overwriteColors(){return this._config.overwriteColors.value}set overwriteColors(e){this._config.overwriteColors.value=e}}const Dr=class _n extends Tt{constructor(e){super(e),w(this,"enabled",!0),w(this,"world",null),w(this,"list",new ft.jp),w(this,"snapshots",new ft.jp),w(this,"isSetup",!1),w(this,"onSetup",new X),w(this,"config",new hc(this,this.components,"Viewpoints",_n.uuid)),w(this,"onDisposed",new X),e.add(_n.uuid,this)}create(e){const t=new Nr(this.components,e);return t.world=this.world,e||this.list.set(t.guid,t),t}getSnapshotExtension(e){let t="jpeg";const i=this.snapshots.get(e);if(!i)return t;const s=i.subarray(0,4);let n="";for(let r=0;r<s.length;r++)n+=s[r].toString(16);return n.startsWith("89504e47")&&(t="png"),n.startsWith("ffd8ffe")&&(t="jpeg"),t}setup(){}dispose(){this.list.dispose(),this.onDisposed.trigger(),this.onDisposed.reset()}};w(Dr,"uuid","ee867824-a796-408d-8aa0-4e5962a83c66");let de=Dr;class Rr{constructor(e,t){w(this,"_components"),w(this,"_cameraOffset",10),w(this,"_planeHelper"),w(this,"_farPlaneHelper"),w(this,"_cameraHelper"),w(this,"onStateChanged",new X),w(this,"onUpdated",new X),w(this,"onDisposed",new X),w(this,"camera"),w(this,"plane",new b.Zcv),w(this,"farPlane",new b.Zcv),w(this,"id",Yt.create()),w(this,"_open",!1),w(this,"_range",uc.defaultRange),w(this,"_world",null),w(this,"_helpersVisible",!1),w(this,"_planesEnabled",!1),this._components=e,this.camera=new Hs(this._components);const{threeOrtho:i}=this.camera;if(t?.id&&(this.id=t.id),t?.normal&&t?.point){const{normal:s,point:n}=t;this.plane.setFromNormalAndCoplanarPoint(s,n)}this._cameraHelper=new b.WTh(i),this._planeHelper=new b.ZM4(this.plane,50),this._farPlaneHelper=new b.ZM4(this.farPlane,50),this.farPlaneHelperColor=new b.Q1f("blue"),this.update()}get _planeNormalOpposite(){return this.plane.normal.clone().negate()}get _planePosition(){return this.plane.normal.clone().multiplyScalar(-this.plane.constant)}get _cameraPosition(){return this._planePosition.addScaledVector(this._planeNormalOpposite,this._cameraOffset)}set open(e){this._open=e,this.onStateChanged.trigger(["open"])}get open(){return this._open}set planeHelperColor(e){!Array.isArray(this._planeHelper.material)&&"color"in this._planeHelper.material&&this._planeHelper.material.color instanceof b.Q1f&&(this._planeHelper.material.color=e)}set farPlaneHelperColor(e){!Array.isArray(this._farPlaneHelper.material)&&"color"in this._farPlaneHelper.material&&this._farPlaneHelper.material.color instanceof b.Q1f&&(this._farPlaneHelper.material.color=e)}set range(e){this._range=e,this.update()}get range(){return this._range}set distance(e){this.plane.constant=e,this.update()}get distance(){return this.plane.constant}set world(e){this._world=e,this.camera.currentWorld=e,e&&(this.camera.projection.set("Orthographic"),this.camera.set("Plan"),this.camera.controls.dollySpeed=6,this.camera.controls.restThreshold=.005,this.update())}get world(){return this._world}set helpersVisible(e){if(!e)return this._helpersVisible=e,this._planeHelper.removeFromParent(),this._farPlaneHelper.removeFromParent(),void this._cameraHelper.removeFromParent();this.world&&(this._helpersVisible=e,this.world.scene.three.add(this._planeHelper,this._farPlaneHelper))}get helpersVisible(){return this._helpersVisible}set planesEnabled(e){const{world:t}=this;if(!t)return;const{renderer:i}=t;i&&(i.setPlane(e,this.plane),i.setPlane(e,this.farPlane),this._planesEnabled=e)}get planesEnabled(){return this._planesEnabled}dispose(){this.helpersVisible=!1;const e=this._components.get(Je);e.destroy(this._planeHelper),e.destroy(this._farPlaneHelper),e.destroy(this._cameraHelper),this.camera.dispose(),this.onDisposed.trigger()}update(){if(this.world){const e=this._cameraPosition,t=this._planePosition;this.camera.controls.setLookAt(e.x,e.y,e.z,t.x,t.y,t.z,!1)}this.farPlane.normal.copy(this._planeNormalOpposite),this.farPlane.constant=this.range-this.plane.constant,this.onUpdated.trigger()}flip(){this.plane.normal.negate(),this.update()}}const Xs=class wo extends Tt{constructor(e){super(e),w(this,"list",new ft.jp),w(this,"enabled",!0),w(this,"world",null),w(this,"_fragmentsUpdateEvent",()=>{this.components.get(ct).core.update(!0)}),e.add(wo.uuid,this),this.setupEvents()}get hasOpenViews(){return[...this.list.values()].some(e=>e.open)}setupEvents(){this.list.onBeforeDelete.add(({key:e,value:t})=>{t.open&&this.close(e),t.dispose()})}create(e,t,i){const s=new Rr(this.components,{id:i?.id,normal:e,point:t});return s.world=i?.world??this.world,this.list.set(s.id,s),s}createFromPlane(e,t){const i=new Rr(this.components,{id:t?.id});return i.plane.copy(e),i.update(),i.world=t?.world??this.world,this.list.set(i.id,i),i}createFromIfcStoreys(e){var t=this;return(0,H.A)(function*(){const i=[],s=t.components.get(ct),n=void 0===e?.offset?.25:e.offset;for(const[r,a]of s.list){if(e&&e.modelIds&&!e.modelIds.some(f=>f.test(r)))continue;const l=Object.values(yield a.getItemsOfCategories([/BUILDINGSTOREY/])).flat();if(0===l.length)continue;const c=yield a.getItemsData(l),[,h]=yield a.getCoordinates(),u=new b.Pq0(0,-1,0);for(const f of c){if(!("value"in f.Name)||!("value"in f.Elevation))continue;const{value:d}=f.Name;if(e?.storeyNames&&!e.storeyNames.some(p=>p.test(d)))continue;const g=new b.Zcv(u,f.Elevation.value+h+n),_=t.createFromPlane(g,{id:d,world:e?.world});i.push(_)}}return i})()}createElevations(e){const t=[],i=this.components.get(ct),s=void 0!==e?.combine&&e.combine,n=e?.namingCallback??(a=>({front:s?"Front":`${a}: Front`,back:s?"Back":`${a}: Back`,left:s?"Left":`${a}: Left`,right:s?"Right":`${a}: Right`}));let r=[];for(const[a,l]of i.list)e&&e.modelIds&&!e.modelIds.some(c=>c.test(a))||r.push({id:a,box:l.box});if(0===r.length)return t;if(s){const a=this.components.get(qn);a.list.clear(),a.list.add(...r.map(c=>c.box)),r=[{id:"combined",box:a.get()}]}for(const{id:a,box:l}of r){const{min:c,max:h}=l,u=Math.abs(h.x-c.x),f=Math.abs(h.z-c.z),d=new b.Pq0;l.getCenter(d);const y=new b.Zcv(new b.Pq0(0,0,-1),h.z),g=new b.Zcv(new b.Pq0(0,0,1),-c.z),_=new b.Zcv(new b.Pq0(-1,0,0),h.x),p=new b.Zcv(new b.Pq0(1,0,0),-c.x),{front:x,back:E,left:T,right:A}=n(a),M=this.createFromPlane(y,{id:x,world:e?.world});M.range=f;const S=this.createFromPlane(g,{id:E,world:e?.world});S.range=f;const z=this.createFromPlane(_,{id:T,world:e?.world});z.range=u;const O=this.createFromPlane(p,{id:A,world:e?.world});O.range=u,t.push(M,S,z,O)}return t}open(e){const t=this.list.get(e);if(!t)throw new Error(`Views: the view with id ${e} doesn't exist.`);if(t.open)return;const{world:i}=t;if(!i)throw new Error(`Views: no world found for view with id ${e}.`);const{renderer:s}=i;if(!s)throw new Error(`Views: no renderer found for world with id ${i.uuid}.`);for(const[,n]of this.list)n.world===i&&this.close(n.id);s.setPlane(!0,t.plane),s.setPlane(!0,t.farPlane),t.camera.controls.addEventListener("rest",this._fragmentsUpdateEvent),i.camera=t.camera,t.open=!0}close(e){let t;if(t=e?this.list.get(e):[...this.list.values()].find(n=>n.open),e&&!t)throw new Error(`Views: the view with id ${e} doesn't exist.`);if(!t||!t.open)return;const{world:i}=t;if(!i)throw new Error(`Views: no world found for view with id ${e}.`);const{renderer:s}=i;if(!s)throw new Error(`Views: no renderer found for world with id ${i.uuid}.`);s.setPlane(!1,t.plane),s.setPlane(!1,t.farPlane),t.camera.controls.removeEventListener("rest",this._fragmentsUpdateEvent),i.useDefaultCamera(),t.open=!1}};w(Xs,"uuid","fb22f1f5-6598-4664-a11d-de8963ae420f"),w(Xs,"defaultRange",15);let uc=Xs;class We{constructor(e){w(this,"cardinality","required"),w(this,"instructions"),w(this,"evalRequirement",(t,i,s,n)=>{const r={parameter:s,currentValue:t,requiredValue:i,pass:!1};n&&this.addCheckResult(r,n);let a=!1;if("simple"===i.type&&(a=t===i.parameter),"enumeration"===i.type&&(a=i.parameter.includes(t)),"pattern"===i.type&&(a=new RegExp(i.parameter).test(String(t))),"length"===i.type){const{min:l,length:c,max:h}=i.parameter;void 0!==c&&(a=String(t).length===c),void 0!==l&&(a=String(t).length>=l),void 0!==h&&(a=String(t).length<=h)}if("bounds"===i.type&&"number"==typeof t){const{min:l,minInclusive:c,max:h,maxInclusive:u}=i.parameter;let f=!0,d=!0;void 0!==l&&(f=c?t>=l:t>l),void 0!==h&&(d=u?t<=h:t<h),a=f&&d}return"prohibited"===this.cardinality&&(a=!a),"optional"===this.cardinality&&(a=!0),r.pass=a,r.pass}),this._components=e}addCheckResult(e,t){const i=t.findIndex(({parameter:s})=>s===e.parameter);-1!==i?t[i]=e:t.push(e)}getItemChecks(e,t,i,s){if(!("value"in i._localId)||"number"!=typeof i._localId.value)return null;let n=e.get(t);n||(n=new ft.jp,e.set(t,n));let r=n.get(i._localId.value);if(r&&s&&!r.pass)return null;if(!r){const c=[];r={guid:Array.isArray(i._guid)?void 0:i._guid.value,pass:!1,checks:c},Object.defineProperty(r,"pass",{get:()=>c.every(({pass:h})=>h)}),n.set(i._localId.value,r)}const a=[],l={facetType:this.facetType,cardinality:this.cardinality,checks:a,pass:!1};return Object.defineProperty(l,"pass",{get:()=>a.every(({pass:c})=>c)}),r.checks.push(l),l.checks}}const le=(o,e)=>{let t="";if(!e)return t;if("simple"===e.type&&(t=`<simpleValue>${e.parameter}</simpleValue>`),"enumeration"===e.type&&(t=`<xs:restriction base="xs:string">\n ${e.parameter.map(n=>`<xs:enumeration value="${n}" />`).join("\n")}\n </xs:restriction>`),"pattern"===e.type&&(t=`<xs:restriction base="xs:string">\n <xs:pattern value="${e.parameter}" />\n </xs:restriction>`),"bounds"===e.type){const{min:s,minInclusive:n,max:r,maxInclusive:a}=e.parameter;let l="";void 0!==s&&(l=`<xs:min${n?"Inclusive":"Exclusive"} value="${s}">`);let c="";void 0!==r&&(c=`<xs:max${a?"Inclusive":"Exclusive"} value="${r}">`),t=`<xs:restriction base="xs:double">\n ${l}\n ${c}\n </xs:restriction>`}if("length"===e.type){const{length:s,min:n,max:r}=e.parameter;let a="";void 0!==s&&void 0===n&&void 0===r&&(a=`<xs:length value="${s}" />`);let l="";void 0!==n&&void 0===s&&(l=`<xs:minLength value="${n}" />`);let c="";void 0!==r&&void 0===s&&(c=`<xs:maxLength value="${r}" />`),t=`<xs:restriction base="xs:string">\n ${a}\n ${l}\n ${c}\n </xs:restriction>`}return`<${o[0].toLowerCase()+o.slice(1)}>\n ${t}\n </${o[0].toLowerCase()+o.slice(1)}>`};class gc extends We{constructor(e,t){super(e),w(this,"facetType","Attribute"),w(this,"name"),w(this,"value"),this.name=t}serialize(e){const t=le("Name",this.name),i=le("Value",this.value);let s="";return"requirement"===e&&(s+=`cardinality="${this.cardinality}"`,s+=this.instructions?`instructions="${this.instructions}"`:""),`<attribute ${s}>\n ${t}\n ${i}\n</attribute>`}getEntities(){return(0,H.A)(function*(){})()}test(e,t){var i=this;return(0,H.A)(function*(s,n,r={skipIfFails:!0}){const a=i._components.get(ct);for(const[l,c]of Object.entries(s)){const h=a.list.get(l);if(!h)continue;const u=yield h.getItemsData([...c]);for(const f of u){const d=i.getItemChecks(n,l,f,r.skipIfFails);if(!d)continue;const g=Object.keys(f).filter(p=>{const x=i.evalRequirement(p,i.name,"Name");if(!x)return!1;const E=f[p];return!!Array.isArray(E)||(null===E||null===E.value?"optional"===i.cardinality||"prohibited"===i.cardinality:!(Array.isArray(E.value)&&0===E.value.length||"string"==typeof E.value&&""===E.value.trim())&&x)}),_=g.length>0;if(d.push({parameter:"Name",currentValue:_?g[0]:null,requiredValue:i.name,pass:"prohibited"===i.cardinality?!_:_}),i.value)if(g[0]){const p=f[g[0]];Array.isArray(p)||Array.isArray(p.value)?d.push({parameter:"Value",currentValue:null,requiredValue:i.value,pass:"prohibited"===i.cardinality}):i.evalRequirement(p.value,i.value,"Value",d)}else d.push({parameter:"Value",currentValue:null,requiredValue:i.value,pass:"prohibited"===i.cardinality})}}}).apply(this,arguments)}}class _c extends We{constructor(e,t){super(e),w(this,"facetType","Classification"),w(this,"system"),w(this,"value"),w(this,"uri"),this.system=t}serialize(e){const t=le("System",this.system),i=le("Value",this.value);let s="";return"requirement"===e&&(s+=`cardinality="${this.cardinality}"`,s+=this.uri?`uri=${this.uri}`:"",s+=this.instructions?`instructions="${this.instructions}"`:""),`<classification ${s}>\n ${t}\n ${i}\n</classification>`}getEntities(e,t){return(0,H.A)(function*(){})()}test(e,t){return(0,H.A)(function*(){})()}}class Js extends We{constructor(e,t){super(e),w(this,"facetType","Entity"),w(this,"name"),w(this,"predefinedType"),this.name=t}serialize(e){const t=le("Name",this.name),i=le("Name",this.predefinedType);let s="";return"requirement"===e&&(s+=`cardinality="${this.cardinality}"`,s+=this.instructions?`instructions="${this.instructions}"`:""),`<entity ${s}>\n ${t}\n ${i}\n</entity>`}getEntities(e,t){var i=this;return(0,H.A)(function*(){const s=i._components.get(ct),n=new Map;for(const[a,l]of s.list){if(!e.find(u=>u.test(a)))continue;const h=yield l.getCategories();for(const u of h){if(!(yield i.evalName(u)))continue;let d=n.get(a);d||(d=[],n.set(a,d)),d.push(u)}}const r={};if(yield Promise.all(Array.from(n.entries()).map(function(){var a=(0,H.A)(function*([l,c]){const h=s.list.get(l);if(!h)return;const u=c.map(y=>new RegExp(`^${y}$`)),f=yield h.getItemsOfCategories(u),d=Object.values(f).flat();r[l]=new Set(d)});return function(l){return a.apply(this,arguments)}}())),i.predefinedType)for(const[a,l]of Object.entries(r)){const c=s.list.get(a);if(!c)continue;const h=yield c.getItemsData([...l]);for(const u of h)"value"in u._localId&&(yield i.evalPredefinedType(a,u))&&Ft.append(t,a,u._localId.value)}else Ft.add(t,r)})()}test(e,t,i){var s=this;return(0,H.A)(function*(){const n=s._components.get(ct);for(const[r,a]of Object.entries(e)){const l=n.list.get(r);if(!l)continue;const c=yield l.getItemsData([...a]);for(const h of c){if(!("value"in h._category))continue;const u=s.getItemChecks(t,r,h,i.skipIfFails);u&&(yield s.evalName(h._category.value,u),yield s.evalPredefinedType(r,h,u))}}})()}evalName(e,t){var i=this;return(0,H.A)(function*(){return i.evalRequirement(e,i.name,"Name",t)})()}evalPredefinedType(e,t,i){var s=this;return(0,H.A)(function*(){if(!s.predefinedType||!("value"in t.PredefinedType))return null;const n="string"==typeof s.predefinedType.parameter&&"USERDEFINED"===s.predefinedType.parameter;let r=t.PredefinedType.value;if("USERDEFINED"===r&&!n){const c=Object.keys(t).find(h=>/^((?!Predefined).)*Type$/.test(h));if(c){const h=t[c];"value"in h&&(r=h.value)}else r="USERDEFINED"}if(!r){const c=s._components.get(ct).list.get(e);if(c&&"value"in t._localId){const[h]=yield c.getItemsData([t._localId.value],{relations:{IsTypedBy:{attributes:!0,relations:!1}}});if(Array.isArray(h.IsTypedBy)){const u=h.IsTypedBy[0];if(u&&"value"in u.PredefinedType&&(r=u.PredefinedType.value,"USERDEFINED"===r&&!n)){const d=Object.keys(u).find(y=>/^((?!Predefined).)*Type$/.test(y));if(d){const y=u[d];"value"in y&&(r=y.value)}else r="USERDEFINED"}}}}return s.evalRequirement(r,s.predefinedType,"PredefinedType",i)})()}}class yc extends We{constructor(e,t,i){super(e),w(this,"facetType","Property"),w(this,"propertySet"),w(this,"baseName"),w(this,"value"),w(this,"dataType"),w(this,"uri"),w(this,"_unsupportedTypes",["IFCCOMPLEXPROPERTY","IFCPHYSICALCOMPLEXQUANTITY"]),this.propertySet=t,this.baseName=i}serialize(e){const t=le("PropertySet",this.propertySet),i=le("BaseName",this.baseName),s=le("Value",this.value);let r="";return"requirement"===e&&(r+=`cardinality="${this.cardinality}"`,r+=this.uri?`uri=${this.uri}`:"",r+=this.instructions?`instructions="${this.instructions}"`:""),`<property ${this.dataType?`dataType=${this.dataType}`:""} ${r}>\n ${t}\n ${i}\n ${s}\n</property>`}getEntities(e,t){var i=this;return(0,H.A)(function*(){const s=i._components.get(ct);for(const[n,r]of s.list){if(!e.find(u=>u.test(n)))continue;const l=yield r.getItemsOfCategories([/PROPERTYSET/,/ELEMENTQUANTITY/]),c=Object.values(l).flat();if(0===c.length)continue;const h=yield r.getItemsData(c,{relations:{HasProperties:{attributes:!0,relations:!1},DefinesOcurrence:{attributes:!0,relations:!1}}});for(const u of h){if(!("value"in u._localId&&"value"in u._category&&"value"in u.Name&&Array.isArray(u.DefinesOcurrence)&&i.evalRequirement(u.Name.value,i.propertySet,"PropertySet")))continue;let d;if("IFCPROPERTYSET"===u._category.value&&(d="HasProperties"),"IFCELEMENTQUANTITY"===u._category.value&&(d="Quantities"),!d)continue;const y=u[d];if(Array.isArray(y))for(const g of y){const _=Object.keys(g),p=_.find(A=>/Name/.test(A));if(!p||!("value"in g[p]))continue;const x=g[p];if(!("value"in x)||!i.evalRequirement(x.value,i.baseName,"BaseName"))continue;if(i.value){const A=_.find(z=>/Value/.test(z));if(!A)continue;const M=g[A];if(!("value"in M)||!i.evalRequirement(M.value,i.value,"Value"))continue}const T=u.DefinesOcurrence.map(A=>"value"in A._localId&&"number"==typeof A._localId.value?A._localId.value:null).filter(A=>null!==A);Ft.append(t,n,...T)}}}})()}test(e,t){var i=this;return(0,H.A)(function*(s,n,r={skipIfFails:!0}){const a=i._components.get(ct);for(const[l,c]of Object.entries(s)){const h=a.list.get(l);if(!h)continue;const u=yield h.getItemsData([...c],{relations:{IsDefinedBy:{attributes:!0,relations:!0},IsTypedBy:{attributes:!0,relations:!1},HasPropertySets:{attributes:!0,relations:!0},DefinesOcurrence:{attributes:!1,relations:!1}}});for(const f of u){const d=i.getItemChecks(n,l,f,r.skipIfFails);if(!d)continue;const g=(yield i.getPsets(f)).filter(_=>!(!("value"in _.Name)||!i.evalRequirement(_.Name.value,i.propertySet,"PropertySet")||(d.push({currentValue:_.Name.value,parameter:"PropertySet",pass:!0,requiredValue:i.propertySet}),0)));if(0!==g.length)for(const _ of g){const p=i.getPropertyListName(_);if(!p)continue;const x=_[p];if(!Array.isArray(x)){d.push({currentValue:null,parameter:"BaseName",pass:!1,requiredValue:i.baseName});continue}const E=x.filter(T=>!(!("value"in T._category)||!("value"in T.Name)||i._unsupportedTypes.includes(T._category.value)||!i.evalRequirement(T.Name.value,i.baseName,"BaseName")||(d.push({currentValue:T.Name.value,parameter:"BaseName",pass:!0,requiredValue:i.baseName}),0)));if(0!==E.length)for(const T of E)i.evalValue(T,d),i.evalDataType(T,d),i.evalURI();else d.push({currentValue:null,parameter:"BaseName",pass:!1,requiredValue:i.baseName})}else d.push({currentValue:null,parameter:"PropertySet",pass:!1,requiredValue:i.propertySet})}}}).apply(this,arguments)}getPropertyListName(e){let t;return"value"in e._category&&("IFCPROPERTYSET"===e._category.value&&(t="HasProperties"),"IFCELEMENTQUANTITY"===e._category.value&&(t="Quantities")),t}getValueKey(e){return Object.keys(e).find(t=>/Value/.test(t)||/Values/.test(t))}getTypePsets(e){if(!Array.isArray(e.IsTypedBy))return[];const[t]=e.IsTypedBy;return t&&Array.isArray(t.HasPropertySets)?t.HasPropertySets:[]}getPsets(e){var t=this;return(0,H.A)(function*(){const i=t.getTypePsets(e);if(!Array.isArray(e.IsDefinedBy))return i;const s=[];for(const n of e.IsDefinedBy){if(!("value"in n.Name))continue;const r=n.Name.value,a=t.getPropertyListName(n);if(!r||!a)continue;const l=i.find(c=>"value"in c.Name&&c.Name.value===r);if(l&&Array.isArray(l.HasProperties)&&Array.isArray(n.HasProperties))for(const c of l.HasProperties){if(!("value"in c.Name))continue;const h=c.Name.value;n.HasProperties.find(f=>"value"in f.Name&&f.Name.value===h)||n.HasProperties.push(c)}s.push(n)}return s})()}evalValue(e,t){const i=this.getValueKey(e),s=e[i];if(!("value"in s))return!1;if(this.value){if(!i)return t?.push({parameter:"Value",currentValue:null,pass:!1,requiredValue:this.value}),!1;const n=structuredClone(this.value);return"IFCLABEL"===s.type&&"simple"===n.type&&(n.parameter=String(n.parameter)),this.evalRequirement(s.value,n,"Value",t)}return!i||"string"!=typeof s.value||""!==s.value.trim()||(t?.push({parameter:"Value",currentValue:"",pass:!1,requiredValue:this.value}),!1)}evalDataType(e,t){if(!this.dataType)return!0;const i=this.getValueKey(e);return i&&"value"in e[i]?this.evalRequirement(e[i].type??null,{type:"simple",parameter:this.dataType},"DataType",t):(t?.push({parameter:"DataType",currentValue:null,pass:!1,requiredValue:this.dataType}),!1)}evalURI(){return!0}}class vc extends We{constructor(){super(...arguments),w(this,"_ifcMaterialEntities",[/^IFCMATERIALLAYERSETUSAGE$/,/^IFCMATERIALCONSTITUENTSET$/,/^IFCMATERIAL$/,/^IFCMATERIALLIST$/]),w(this,"facetType","Material"),w(this,"value"),w(this,"uri")}serialize(e){if(!this.value||!this.uri)return"<material />";const t=le("Value",this.value);let i="";return"requirement"===e&&(i+=`cardinality="${this.cardinality}"`,i+=this.uri?`uri=${this.uri}`:"",i+=this.instructions?`instructions="${this.instructions}"`:""),`<material ${i}>\n ${t}\n</material>`}getEntities(e,t){var i=this;return(0,H.A)(function*(){const s=i._components.get(ct);for(const[n,r]of s.list){if(!e.find(u=>u.test(n)))continue;const l=yield r.getItemsOfCategories(i._ifcMaterialEntities),c=Object.values(l).flat();if(0===c.length)continue;const h=yield r.getItemsData(c,{relations:{AssociatedTo:{attributes:!0,relations:!1},MaterialConstituents:{attributes:!0,relations:!0},ForLayerSet:{attributes:!0,relations:!0},MaterialLayers:{attributes:!0,relations:!0},Materials:{attributes:!0,relations:!1}}});for(const u of h){if(!("value"in u._localId&&"value"in u._category&&Array.isArray(u.AssociatedTo)&&i.hasValidMaterial(u)))continue;const d=u.AssociatedTo.map(y=>"value"in y._localId&&y._localId.value?y._localId.value:null).filter(y=>null!==y);Ft.append(t,n,...d)}}})()}test(e,t){var i=this;return(0,H.A)(function*(s,n,r={skipIfFails:!0}){const a=i._components.get(ct);for(const[l,c]of Object.entries(s)){const h=a.list.get(l);if(!h)continue;const u=yield h.getItemsData([[...c][0]],{relations:{AssociatedTo:{attributes:!1,relations:!1},HasAssociations:{attributes:!0,relations:!0},MaterialConstituents:{attributes:!0,relations:!0},ForLayerSet:{attributes:!0,relations:!0},MaterialLayers:{attributes:!0,relations:!0},Materials:{attributes:!0,relations:!1}}});for(const f of u){const d=i.getItemChecks(n,l,f,r.skipIfFails);if(d){if(!Array.isArray(f.HasAssociations)){d.push({parameter:null,currentValue:null,requiredValue:i.value,pass:!1});continue}for(const y of f.HasAssociations)if(i._ifcMaterialEntities.some(_=>"value"in y._category&&_.test(y._category.value))&&i.hasValidMaterial(y,d))break}}}}).apply(this,arguments)}hasValidMaterial(e,t){let i=!1;if("value"in e._category&&"IFCMATERIAL"===e._category.value)this.evalValue(e,t)&&(i=!0);else for(const[s,n]of Object.entries(e))if(["ForLayerSet","MaterialLayers","Material","MaterialConstituents","Materials"].includes(s)&&Array.isArray(n))for(const r of n)if("value"in r._category&&"IFCMATERIAL"===r._category.value){if(this.evalValue(r,t)){i=!0;break}}else if(this.hasValidMaterial(r)){i=!0;break}return i}evalValue(e,t){if(!this.value)return t?.push({parameter:null,currentValue:e.Name&&"value"in e.Name?e.Name.value:null,pass:!0}),!0;if(!("value"in e._category)||"IFCMATERIAL"!==e._category.value)return null;let i=!1;return e.Name&&"value"in e.Name&&(i=this.evalRequirement(e.Name.value,this.value,"Value",t)),i||(e.Category&&"value"in e.Category&&(i=this.evalRequirement(e.Category.value,this.value,"Value",t)),i)}}class wc extends We{constructor(e,t){super(e),w(this,"facetType","PartOf"),w(this,"_entityFacet"),w(this,"_entity"),w(this,"relation"),w(this,"cardinality","required"),this._entity=t,this._entityFacet=new Js(e,t.name),this._entityFacet.predefinedType=t.predefinedType}set entity(e){this._entity=e;const{name:t,predefinedType:i}=e;this._entityFacet=new Js(this._components,t),this._entityFacet.predefinedType=i}get entity(){return this._entity}serialize(){return""}getEntities(e,t){return(0,H.A)(function*(){})()}test(e){return(0,H.A)(function*(){})()}}class bc{constructor(e,t,i){w(this,"name"),w(this,"ifcVersion",new Set),w(this,"identifier",Yt.create()),w(this,"description"),w(this,"instructions"),w(this,"requirementsDescription"),w(this,"applicability",new ft.PG),w(this,"requirements",new ft.PG),w(this,"components"),this.components=e,this.name=t;for(const s of i)this.ifcVersion.add(s)}set(e){const t=e,i=this;for(const n in e)"identifier"!==n&&n in this&&(i[n]=t[n]);return this.components.get(xc).list.set(this.identifier,this),this}test(e){var t=this;return(0,H.A)(function*(i,s={skipIfFails:!0}){const n=new ft.jp;if(0===t.requirements.size)return n;const r={},a=[];for(const c of t.applicability)a.push(c.getEntities(i,r));yield Promise.all(a);const l=[];for(const c of t.requirements)l.push(c.test(r,n,s));return yield Promise.all(l),n}).apply(this,arguments)}serialize(){const e=`name="${this.name}"`,t=this.identifier?`identifier="${this.identifier}"`:"",i=this.description?`description="${this.description}"`:"",s=this.instructions?`instructions="${this.instructions}"`:"";return`<specification ifcVersion="${[...this.ifcVersion].join(" ")}" ${e} ${t} ${i} ${s}>\n <applicability minOccurs="1" maxOccurs="unbounded">\n ${[...this.applicability].map(r=>r.serialize("applicability")).join("\n")}\n </applicability>\n <requirements>\n ${[...this.requirements].map(r=>r.serialize("requirement")).join("\n")}\n </requirements>\n </specification>`}}const te=o=>{if(!o)return;const e={};if("simpleValue"in o&&(e.type="simple",e.parameter=o.simpleValue),"restriction"in o){const t=o.restriction,i=Object.keys(t);if("pattern"in t&&(e.type="pattern",e.parameter=t.pattern.value),"enumeration"in t){e.type="enumeration";const s=t.enumeration.map(({value:n})=>t.base.includes("string")?String(n):t.base.includes("integer")||t.base.includes("double")?Number(n):n);e.parameter=s}if(i.some(s=>["minInclusive","minExclusive","maxInclusive","maxExclusive"].includes(s))){e.type="bounds";const s={},n=i.find(a=>a.includes("min")),r=i.find(a=>a.includes("max"));n&&(s.minInclusive="minInclusive"===n,s.min=t[n].value),r&&(s.maxInclusive="maxInclusive"===r,s.max=t[r].value),e.parameter=s}if(i.some(s=>["minLength","length","maxLength"].includes(s))){e.type="length";const s={};void 0!==t.length&&(s.length=t.length.value),void 0!==t.minLength&&(s.min=t.minLength.value),void 0!==t.maxLength&&(s.max=t.maxLength.value),e.parameter=s}}return void 0!==e.parameter?e:void 0},Br=(o,e)=>{const t=[];for(const i of e){const n=te(i.name);if(!n)continue;const r=new Js(o,n);i.cardinality&&(r.cardinality=i.cardinality),r.predefinedType=te(i.predefinedType),r.instructions=i.instructions,t.push(r)}return t},Lr=(o,e)=>{const t=[];for(const i of e){const n=te(i.name);if(!n)continue;const r=new gc(o,n);i.cardinality&&(r.cardinality=i.cardinality),r.value=te(i.value),r.instructions=i.instructions,t.push(r)}return t},Vr=(o,e)=>{const t=[];for(const i of e){const s=new vc(o);i.cardinality&&(s.cardinality=i.cardinality);const n=te(i.value);"enumeration"===n?.type&&Array.isArray(n.parameter)&&(n.parameter=n.parameter.map(String)),s.value=n,s.uri=i.uri,s.instructions=i.instructions,t.push(s)}return t},Ur=(o,e)=>{const t=[];for(const i of e){const n=i.baseName,r=te(i.propertySet),a=te(n);if(!a||!r)continue;const l=new yc(o,r,a);i.cardinality&&(l.cardinality=i.cardinality);const c=te(i.value);l.value=c,l.dataType=i.dataType,l.uri=i.uri,l.instructions=i.instructions,t.push(l)}return t},$r=(o,e)=>{const t=[];for(const i of e){const n=te(i.system);if(!n)continue;const r=new _c(o,n);i.cardinality&&(r.cardinality=i.cardinality);const a=te(i.value);"simple"===a?.type&&(a.parameter=String(a.parameter)),"enumeration"===a?.type&&Array.isArray(a.parameter)&&(a.parameter=a.parameter.map(String)),r.value=a,r.uri=i.uri,r.instructions=i.instructions,t.push(r)}return t},jr=(o,e)=>{const t=[];for(const i of e){const s=te(i.entity.name);if(!s)continue;const n=te(i.entity.predefinedType),r=new wc(o,{name:s,predefinedType:n});r.relation=i.relation,i.cardinality&&(r.cardinality=i.cardinality),r.instructions=i.instructions,t.push(r)}return t},tn=class yn extends Tt{constructor(e){super(e),w(this,"enabled",!0),w(this,"IDSInfo"),w(this,"list",new ft.jp),e.add(yn.uuid,this)}getModelIdMap(e){const t={},i={};for(const[s,n]of e){const a=[...n].filter(([,h])=>h.pass).map(([h])=>h);Ft.append(t,s,...a);const c=[...n].filter(([,h])=>!h.pass).map(([h])=>h);Ft.append(i,s,...c)}return{pass:t,fail:i}}create(e,t,i){const s=new bc(this.components,e,t);return i&&(s.identifier=i),this.list.set(s.identifier,s),s}load(e){const t=[],i=yn.xmlParser.parse(e).ids,{specifications:s,info:n}=i;if(this.IDSInfo={...n},s&&s.specification){const r=Array.isArray(s.specification)?s.specification:[s.specification];for(const a of r){const{name:l,ifcVersion:c,description:h,instructions:u,identifier:f}=a;if(!l||!c)continue;const d=[],y=[],{applicability:g,requirements:_}=a;if(g){const{maxOccurs:E,...T}=g,A=Array.isArray(T)?T:[T];for(const M of A)for(const S in M){const z=Array.isArray(M[S])?M[S]:[M[S]];if("entity"===S){const O=Br(this.components,z);d.push(...O)}if("attribute"===S){const O=Lr(this.components,z);d.push(...O)}if("material"===S){const O=Vr(this.components,z);d.push(...O)}if("classification"===S){const O=$r(this.components,z);d.push(...O)}if("property"===S){const O=Ur(this.components,z);d.push(...O)}if("partOf"===S){const O=jr(this.components,z);d.push(...O)}}}let p;if(_){const{maxOccurs:E,...T}=_;p=_.description;const A=Array.isArray(T)?T:[T];for(const M of A)for(const S in M){const z=Array.isArray(M[S])?M[S]:[M[S]];if("entity"===S){const O=Br(this.components,z);y.push(...O)}if("attribute"===S){const O=Lr(this.components,z);y.push(...O)}if("material"===S){const O=Vr(this.components,z);y.push(...O)}if("classification"===S){const O=$r(this.components,z);y.push(...O)}if("property"===S){const O=Ur(this.components,z);y.push(...O)}if("partOf"===S){const O=jr(this.components,z);y.push(...O)}}}const x=this.create(l,c.split(/\s+/),f);x.description=h,x.instructions=u,x.requirementsDescription=p,x.applicability.add(...d),x.requirements.add(...y),t.push(x)}}return t}export(e,t=this.list.values()){const i=t??this.list;return`<ids xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://standards.buildingsmart.org/IDS http://standards.buildingsmart.org/IDS/1.0/ids.xsd" xmlns:ids="http://standards.buildingsmart.org/IDS">\n \x3c!-- Made with That Open Engine ${js.release} (https://github.com/thatopen/engine_components) --\x3e\n <info>\n <title>${e.title}</title>\n ${e.copyright?`<copyright>${e.copyright}</copyright>`:""}\n ${e.version?`<version>${e.version}</version>`:""}\n ${e.description?`<description>${e.description}</description>`:""}\n ${e.author?`<author>${e.author}</author>`:""}\n ${e.date?`<date>${e.date.toISOString().split("T")[0]}</date>`:""}\n ${e.purpose?`<purpose>${e.purpose}</purpose>`:""}\n ${e.milestone?`<milestone>${e.milestone}</milestone>`:""}\n </info>\n <specifications>\n ${[...i].map(n=>n.serialize()).join("\n")}\n </specifications>\n</ids>`}};w(tn,"uuid","9f0b9f78-9b2e-481a-b766-2fbfd01f342c"),w(tn,"xmlParser",new vs({allowBooleanAttributes:!0,attributeNamePrefix:"",ignoreAttributes:!1,ignoreDeclaration:!0,ignorePiTags:!0,numberParseOptions:{leadingZeros:!0,hex:!0},parseAttributeValue:!0,preserveOrder:!1,processEntities:!1,removeNSPrefix:!0,trimValues:!0}));let xc=tn;w(class bo extends Tt{constructor(e){super(e),w(this,"enabled",!0),e.add(bo.uuid,this)}static distanceFromPointToLine(e,t,i,s=!1){const n=new b.cZY,r=new b.Pq0;return n.set(t,i),n.closestPointToPoint(e,s,r),r.distanceTo(e)}round(e){e.x=Math.trunc(1e3*e.x)/1e3,e.y=Math.trunc(1e3*e.y)/1e3,e.z=Math.trunc(1e3*e.z)/1e3}getVolumeFromFragments(e){var t=this;return(0,H.A)(function*(){return console.warn("getVolumeFromFragments is deprecated. Use getItemsVolume instead."),t.getItemsVolume(e)})()}getItemsVolume(e){var t=this;return(0,H.A)(function*(){let i=0;const s=t.components.get(ct);for(const[n,r]of Object.entries(e)){const a=s.list.get(n);a&&(i+=(yield a.getItemsVolume([...r])))}return i})()}static convertUnits(e,t,i,s=2){const n={m:1,cm:.01,mm:.001,km:1e3,m2:1,cm2:1e-4,mm2:1e-6,km2:1e6,m3:1,cm3:1e-6,mm3:1e-9,km3:1e9};if(!n[t]||!n[i])throw new Error("Invalid units provided for conversion.");if(!Number.isInteger(s)||s<0||s>5)throw new Error("Precision must be an integer between 0 and 5.");const l=10**s;return Math.round(e*(n[t]/n[i])*l)/l}},"uuid","267ca032-672f-4cb0-afa9-d24e904f39d6");let Hr=(()=>{class o extends Tt{static uuid="ab45d0a7-feea-4afc-927c-80832dae76dd";enabled=!0;_fragments=null;set fragments(t){this._fragments=t}geometries=new ft.jp;get(t,i){var s=this;return(0,H.A)(function*(){const{material:n,coordinate:r,applyTransformation:a}={coordinate:!0,applyTransformation:!0,...i},l=new ft.jp;for(const[c,h]of Object.entries(t)){const u=s._fragments.models.list.get(c);if(!u)continue;const f=s.getModelMeshes(c);for(const d of h){let y=l.get(c);y||(y=new ft.jp,l.set(c,y));let g=f.get(d);if(g&&g.length>0){const x=[];for(const[,{geometry:E}]of g.entries()){const T=yield s.createMesh(u,E,{material:n,applyTransformation:a,coordinate:r});x.push(T)}y.set(d,x);continue}g=[],f.set(d,g);const[_]=yield u.getItemsGeometry([d]);if(!_)continue;const p=[];for(const x of _){const E=s.createGeometry(x);if(!E)continue;const{geometry:T}=E;g.push(E);const A=yield s.createMesh(u,T,{material:n,applyTransformation:a,coordinate:r});p.push(A)}y.set(d,p)}}return l})()}getModelMeshes(t){let i=this.geometries.get(t);return i||(i=new ft.jp,this.geometries.set(t,i)),i}remove(t=[...this.geometries.keys()]){for(const i of t){const s=this.geometries.get(i);if(s){for(const[,n]of s)for(const{geometry:r}of n)r.dispose();this.geometries.delete(i)}}}onDisposed=new X;dispose(t=!0){this.remove(),t&&this.geometries.dispose(),this.onDisposed.trigger(o.uuid)}getMeshesFromResult(t){const i=[];for(const s of t.values())for(const n of s.values())i.push(...n);return i}createGeometry(t){const{positions:i,indices:s,normals:n,transform:r}=t;if(!(i&&s&&n))return null;const a=new b.LoY;return a.setAttribute("position",new b.THS(i,3)),a.setAttribute("normal",new b.THS(n,3,!0)),a.setIndex(new b.THS(s,1)),a.applyMatrix4(r),{geometry:a,transform:r}}createMesh(t,i,s){var n=this;return(0,H.A)(function*(){const{material:r,applyTransformation:a,coordinate:l}={applyTransformation:!0,coordinate:!0,...s},c=n.components.get(ct),h=new b.eaF(i,r);if(h.applyMatrix4(t.object.matrixWorld),a||h.position.set(0,0,0),l&&c.baseCoordinationModel!==t.modelId){const u=yield t.getCoordinationMatrix();c.applyBaseCoordinateSystem(h,u)}return h})()}}return o})(),en=(()=>{class o extends Tt{static uuid="2695289f-e6c1-4980-919e-88b7591d7ea3";enabled=!0;originalColors=new Map;_ghostColor=new b.Q1f("white");_ghostedMaterials=[];set ghostColor(t){this._ghostColor=t}_ghostApplied=!1;get ghostApplied(){return this._ghostApplied}_world;set world(t){this._world=t,this._initEventListeners()}get ghostedMaterials(){return this._ghostedMaterials}_fragments;set fragments(t){this._fragments=t,this._initEventListeners()}onDisposed=new X;constructor(t){super(t)}dispose(){this.onDisposed.trigger(o.uuid),this._ghostedMaterials=[]}setModelTransparent(t){const i=[...t.models.materials.list.values()];for(const s of i){if(s.userData.customId)continue;let n;n="color"in s?s.color.getHex():s.lodColor.getHex(),this.originalColors.set(s,{color:n,transparent:s.transparent,opacity:s.opacity}),s.transparent=!0,s.opacity=.05,s.needsUpdate=!0,"color"in s?s.color=this._ghostColor:s.lodColor=this._ghostColor,this._ghostedMaterials.push(s)}this._ghostApplied=!0}restoreModelMaterials(){for(const[t,i]of this.originalColors){const{color:s,transparent:n,opacity:r}=i;t.transparent=n,t.opacity=r,"color"in t?t.color.setHex(s):t.lodColor.setHex(s),t.needsUpdate=!0}this.originalColors.clear(),this._ghostedMaterials=[],this._ghostApplied=!1}toggleGhost(t){this.originalColors.size?this.restoreModelMaterials():this.setModelTransparent(t)}_initEventListeners(){void 0!==this._world&&void 0!==this._fragments&&(this._world.camera.controls.addEventListener("rest",()=>{this.enabled?this.setModelTransparent(this._fragments):this.restoreModelMaterials()}),this._fragments.models.list.onItemSet.add(({value:t})=>{console.log(`Model ${t.modelId} is ready`),setTimeout(()=>{this.enabled?(console.log("GHOST"),this.setModelTransparent(this._fragments)):this.restoreModelMaterials()},1500)}))}}return o})(),Yr=(()=>{class o extends Tt{static uuid="3abd8228-7bff-4ff6-ac30-53f97bdc8ae6";enabled=!0;_fragments;_isolated={};_hidden={};_colorOverrides={};_overrides={};onDisposed=new X;constructor(t){super(t)}set fragments(t){this._fragments=t}_world;set world(t){this._world=t}get colorOverrides(){return this._colorOverrides}applyModelOverrides(t,i){var s=this;return(0,H.A)(function*(){s._overrides[t.modelId]=i,yield s._applyModelOverrides(t)})()}update(t){var i=this;return(0,H.A)(function*(){(void 0===t?i.fragments.models.list:[t]).forEach(n=>{i._appendOnModel(n)})})()}setNonColoredVisibility(t){var i=this;return(0,H.A)(function*(){if(void 0===i._fragments)return;const s=i._colorOverrides;console.log(s);for(const n of Object.keys(s)){const r=i._fragments.models.list.get(n);if(void 0===r)return;t?yield i._setVisibilityAll(r,!0):(yield i._setVisibilityAll(r,!1),r.setVisible([...s[n]],!0))}})()}dispose(){this.onDisposed.trigger(o.uuid)}_getLocalIdsByType(t,i){var s=this;return(0,H.A)(function*(){if(void 0===s._fragments)return null;const n=yield t.getItemsOfCategories(i);return new Set([...Object.values(n).flat()])})()}_applyModelOverrides(t){var i=this;return(0,H.A)(function*(){if(void 0!==i._fragments&&void 0!==i._overrides[t.modelId]){try{yield Promise.all([i._updateIsolatedMap(t),i._updateHiddenMap(t),i._updateColorOverrides(t)])}catch(n){console.log(n)}t&&i._appendOnModel(t)}})()}_appendOnModel(t){var i=this;return(0,H.A)(function*(){const s=i._overrides[t.modelId];if(void 0===s)return;const n=i._isolated[t.modelId],r=i._hidden[t.modelId];n?.size?(yield i._setVisibilityAll(t,!1),t?.setVisible([...n],!0)):r?.size&&t?.setVisible([...r],!1);for(const a of s.colorOverrides){const l={color:new b.Q1f(a.color),renderedFaces:ft.eB.TWO,opacity:a.opacity,transparent:!1,customId:`${t.modelId}_${a.color}`};yield t.highlight(a.ids,l)}})()}_updateIsolatedMap(t){var i=this;return(0,H.A)(function*(){const s=t.modelId,n=i._overrides[s];if(i._isolated[s]=new Set,n.isolatedTypes.length){const r=yield i._getLocalIdsByType(t,n.isolatedTypes);r&&r.forEach(a=>i._isolated[s].add(a))}n.isolated.length&&n.isolated.forEach(r=>i._isolated[s].add(r))})()}_updateHiddenMap(t){var i=this;return(0,H.A)(function*(){const s=t.modelId,n=i._overrides[s];if(i._hidden[s]=new Set,n.hiddenTypes.length){const r=yield i._getLocalIdsByType(t,n.hiddenTypes);r&&r.forEach(a=>i._hidden[s].add(a))}n.hidden.length&&n.hidden.forEach(r=>i._hidden[s].add(r))})()}_updateColorOverrides(t){var i=this;return(0,H.A)(function*(){const s=t.modelId;i._colorOverrides[t.modelId]=new Set,i._overrides[s].colorOverrides.forEach(r=>{r.ids.forEach(a=>i._colorOverrides[t.modelId].add(a))})})()}_setVisibilityAll=function(){var t=(0,H.A)(function*(i,s){const r=(yield i.getItemsWithGeometry()).map(l=>l.getLocalId()),a=(yield Promise.all(r)).filter(l=>null!==l);yield i.setVisible(a,s)});return function(i,s){return t.apply(this,arguments)}}()}return o})();const Zr=(o,e)=>{const t={...o};return Object.keys(e).forEach(i=>{t[i]=new Set([...t[i]||[],...e[i]])}),t},Wr=function(){var o=(0,H.A)(function*(e,t,i,s={}){const n=[];for(const[,l]of t.models.list){const c=yield l.raycast(i);if(c){const h={};h[l.modelId]=new Set,h[l.modelId].add(c.localId),n.push({...c,idMap:h})}}if(0===n.length)return qr(t,s,!0),null;let r=n[0],a=r.distance;for(let l=1;l<n.length;l++)n[l].distance<a&&(a=n[l].distance,console.log(a),r=n[l]);return e.get(en).ghostApplied&&!((o,e)=>{if(null===e)return!1;let t=!1;return Object.keys(o).forEach(i=>{e[i].forEach(s=>{o[i].has(s)&&(t=!0)})}),t})(e.get(Yr).colorOverrides,r.idMap)?(qr(t,s=Zr(s,r.idMap),!1),Wr(e,t,i,s)):r});return function(t,i,s){return o.apply(this,arguments)}}();function qr(o,e,t){for(const i of Object.keys(e))o.models.list.get(i)?.setVisible([...e[i]],t)}class Ac{hoveredElement=new X}let sn=(()=>{class o extends Tt{static uuid="26fbd870-b1b2-4b71-b747-4063d484de1b";HOVERER_OPACITY_KEY="_maxHoverOpacity";_hoverTimeout=null;_meshes=new ft.PG;_localId=null;_fadeAnimation=null;_world=null;_fragments=null;set world(t){if(t){this._world=t,this.setupEvents(!0);for(const i of this._meshes)t.scene.three.add(i)}else{this.setupEvents(!1),this._world=null;for(const i of this._meshes)i.removeFromParent()}}get world(){return this._world}events=new Ac;set fragments(t){this._fragments=t}_enabled=!1;set enabled(t){this.setupEvents(t),this._enabled=t}get enabled(){return this._enabled}_material=new b.V9B({color:16777215,transparent:!0,opacity:.5,depthTest:!1,userData:{[this.HOVERER_OPACITY_KEY]:.5}});set material(t){t.userData[this.HOVERER_OPACITY_KEY]=t.opacity;for(const i of this._meshes)i.material=t;this._material.dispose(),this._material=t}get material(){return this._material}onDisposed=new X;duration=200;animation=!0;constructor(t){super(t),t.add(o.uuid,this),this._meshes.onBeforeDelete.add(i=>{i.removeFromParent(),i.geometry.dispose(),this._setCursor(!1)}),this._meshes.onItemAdded.add(i=>{this.world&&(this._setCursor(!0),this.world.scene.three.add(i))}),this._meshes.onCleared.add(()=>{this._localId=null,this._hoverTimeout&&(clearTimeout(this._hoverTimeout),this._hoverTimeout=null)})}setupEvents(t){if(!this.world||this.world.isDisposing)return;if(!this.world.renderer)throw new Error("The given world doesn't have a renderer!");const i=this.world.renderer.three.domElement;i.removeEventListener("mousemove",this.onMouseMove),i.removeEventListener("mouseleave",this.onMouseMove),t&&(i.addEventListener("mousemove",this.onMouseMove),i.addEventListener("mouseleave",this.onMouseLeave))}mouseStopTimeout=null;onMouseMove=t=>{null!==this.mouseStopTimeout&&clearTimeout(this.mouseStopTimeout),this.mouseStopTimeout=window.setTimeout(()=>this.hover(t),50)};onMouseLeave=()=>{this._meshes.clear()};animate=()=>{if(!(this._fadeAnimation&&this.animation&&this.material.transparent))return;const{startTime:t,duration:i,fadeIn:s}=this._fadeAnimation,n=Date.now()-t,r=Math.min(n/i,1),l=this.material.userData[this.HOVERER_OPACITY_KEY];this.material.opacity=(s?r:1-r)*(void 0!==l?l:1),r<1?requestAnimationFrame(this.animate):(s||this._meshes.clear(),this._fadeAnimation=null)};hover(t){var i=this;return(0,H.A)(function*(){if(!i.enabled||!i.world||!i._fragments)return;const s=new b.I9Y(t.clientX,t.clientY),n=yield Wr(i.components,i._fragments,{camera:i.world.camera.three,mouse:s,dom:i.world.renderer.three.domElement});if(!n)return i._meshes.clear(),void i.events.hoveredElement.trigger(null);if(i.components.get(en).ghostApplied&&!(yield n.fragments.getHighlightItemIds()).includes(n.localId))return console.log("Not a highlighted object!"),void i.events.hoveredElement.trigger(null);i.events.hoveredElement.trigger(n);const{fragments:r,localId:a}=n;i._localId!==a&&(i._meshes.clear(),i._localId=a,i._hoverTimeout=window.setTimeout((0,H.A)(function*(){const l={[r.modelId]:new Set([a])},c=i.components.get(Hr);c.fragments=i._fragments;const h=yield c.get(l);for(const[,u]of h.entries()){const f=[...u.values()].flat();for(const d of f)d.material=i.material,d.position.set(0,0,0),d.rotation.set(0,0,0),d.scale.set(1,1,1),d.applyMatrix4(r.object.matrixWorld),i._meshes.add(d)}i._fadeAnimation={startTime:Date.now(),duration:i.duration,fadeIn:!0},i.animate()}),100))})()}_setCursor(t){const i=this._world.renderer?.three.domElement;i&&(i.style.cursor=t?"pointer":"default")}clear(){this._meshes.clear()}dispose(){this._enabled=!1,this._meshes.clear(),this._fadeAnimation=null,this._hoverTimeout=null,this.onDisposed.trigger()}}return o})();var Pc=_t(9595);const Sc=function(){var o=(0,H.A)(function*(e,t){const i=Object.keys(t)[0];if(i&&e.models.list.get(i)){const s=e.models.list.get(i),[n]=yield s.getItemsData([...t[i]],{attributesDefault:!1,attributes:["Name","NominalValue"],relations:{IsDefinedBy:{attributes:!0,relations:!0},DefinesOcurrence:{attributes:!1,relations:!1}}});return n||null}return null});return function(t,i){return o.apply(this,arguments)}}();var nn=_t(1452);class Ic{clickedElement=new X;clickedCanvas=new X;selection=new X}let Gr=(()=>{class o extends Tt{static uuid="b7e0b697-172f-43db-b530-d775a2a34d55";HIGHLIGHT_ID="cue_selection";enabled=!0;multiSelect=!1;resetOnCanvasClick=!0;_fragments=null;set fragments(t){this._fragments=t}hoveredElement=null;selectedElements=null;set styles(t){const i=this.components.get(nn.TF);i.fillOpacity=t.fillOpacity,i.fillColor=t.fillColor,i.color=t.outlineColor}onDisposed=new X;events=new Ic;constructor(t){super(t),this._initEventListeners()}dispose(){this.hoveredElement=null,this.selectedElements=null,this.onDisposed.trigger(o.uuid)}_initEventListeners(){var t=this;this.components.get(sn).events.hoveredElement.add(function(){var n=(0,H.A)(function*(r){if(!r)return void(t.hoveredElement=null);const a=r.localId,l=r.fragments.modelId;t.hoveredElement={[l]:new Set([a])}});return function(r){return n.apply(this,arguments)}}()),Pc.B.getInstance().events.addListener("shortPressedLeft",(0,H.A)(function*(){if(!t.enabled)return;const n=t.components.get(nn.TF);n.clean();const r=t.hoveredElement;if(!r)return t.resetOnCanvasClick&&(t.selectedElements=null,t.events.selection.trigger(null),n.clean()),void t.events.clickedCanvas.trigger();const a=yield Sc(t._fragments,r);a&&t.events.clickedElement.trigger(a);const l=Object.keys(r)[0],c=[...r[l]][0];let h=t.selectedElements?Object.assign({},t.selectedElements):null;h=t.multiSelect?h?t.resetOnCanvasClick&&h&&h[l]?.has(c)?((o,e)=>{const t={...o};return Object.keys(e).forEach(i=>{const s=e[i];t[i]&&(t[i]=new Set([...t[i]||[]].filter(n=>!s.has(n))),0===t[i].size&&delete t[i])}),0===Object.keys(t).length?null:t})(h,r):Zr(h,r):r:t.resetOnCanvasClick&&h&&h[l]?.has(c)?null:r,t.selectedElements=h,t.events.selection.trigger(h),h?n.addItems(h):n.clean()}))}}return o})(),Mc=(()=>{class o extends Tt{_world;_fragments;set world(t){this._world=t,t&&this.getRenderer().postproduction.excludedObjectsPass.addExcludedMaterial(this._points.material)}get world(){return this._world}set fragments(t){this._fragments=t}styles=new ft.PG;outlinePositions=!1;_mesh=null;get _points(){return this._mesh||(this._mesh=new b.ONl(new b.LoY,new b.BH$({size:10,sizeAttenuation:!1,depthTest:!1}))),this._mesh}get enabled(){return!(!this.world||this.world.isDisposing)&&this.getRenderer().postproduction.outlinesEnabled}set enabled(t){this.world&&!this.world.isDisposing&&(this.getRenderer().postproduction.outlinesEnabled=t,this.outlinePositions&&(this._points.material.color=this.color,this.world.scene.three.add(this._points)))}get color(){return this.getRenderer().postproduction.outlinePass.outlineColor}set color(t){this.getRenderer().postproduction.outlinePass.outlineColor.copy(t),this._points.material.color.copy(t)}get thickness(){return this.getRenderer().postproduction.outlinePass.thickness}set thickness(t){this.getRenderer().postproduction.outlinePass.thickness=t}get fillColor(){return this.getRenderer().postproduction.outlinePass.fillColor}set fillColor(t){this.getRenderer().postproduction.outlinePass.fillColor.copy(t)}get fillOpacity(){return this.getRenderer().postproduction.outlinePass.fillOpacity}set fillOpacity(t){this.getRenderer().postproduction.outlinePass.fillOpacity=t}onDisposed=new X;static uuid="2fd3bcc5-b3b6-4ded-9f64-f47a02854a10";_meshes=[];_map={};_activeStyles=new Set;constructor(t){super(t),t.add(o.uuid,this)}update(){var t=this;return(0,H.A)(function*(i=t._map){if(i===t._map&&t.cleanMeshes(),t.outlinePositions&&t.updatePoints(),0===Object.keys(i).length)return;const n=t.getRenderer().postproduction.outlinePass,a=yield t.components.get(Hr).get(i);for(const l of Object.keys(i)){const c=t._fragments?.models.list.get(l);if(c)for(const[,h]of a.entries()){const u=[...h.values()].flat();for(const f of u)f.position.set(0,0,0),f.rotation.set(0,0,0),f.scale.set(1,1,1),f.applyMatrix4(c.object.matrixWorld),t._meshes.push(f),n.scene.add(f)}}}).apply(this,arguments)}addItems(t){var i=this;return(0,H.A)(function*(){Ft.add(i._map,t),yield i.update(t)})()}removeItems(t){var i=this;return(0,H.A)(function*(){Ft.remove(i._map,t),yield i.update()})()}clean(){this._map={},this._activeStyles.clear(),this.cleanMeshes(),this._mesh&&this.components.get(Je).destroy(this._mesh,!0,!0),this._mesh=null}dispose(){this.styles.clear(),this.clean(),this.onDisposed.trigger(o.uuid)}cleanMeshes(){for(const t of this._meshes)t.removeFromParent();this._meshes=[]}updatePoints(){var t=this;return(0,H.A)(function*(){let i=0;for(const[,r]of Object.entries(t._map))i+=r.size;t._points.geometry.setAttribute("position",new b.qtW(new Float32Array(3*i),3));const n=yield t.components.get(ct).getPositions(t._map);for(let r=0;r<n.length;r++){const{x:a,y:l,z:c}=n[r];t._points.geometry.attributes.position.array[3*r]=a,t._points.geometry.attributes.position.array[3*r+1]=l,t._points.geometry.attributes.position.array[3*r+2]=c}t._points.geometry.attributes.position.needsUpdate=!0})()}getRenderer(){if(!this.world)throw new Error("You must set a world to use the outliner!");const t=this.world.renderer;if(!t.postproduction)throw new Error("The world given to the outliner must use the postproduction renderer.");return t}}return o})();var zc=_t(893);function Fc(o){return rn.apply(this,arguments)}function rn(){return(rn=(0,H.A)(function*(o){console.warn("Set double sided is not implemented"),console.log(o)})).apply(this,arguments)}const Dc=(o,e,t="./js/worker.mjs")=>{const i=new ft._i(function Nc(o){try{const e=new URL(o,window.location.href);if(e.origin!==window.location.origin){const t=new Blob([`import '${e.href}';`],{type:"text/javascript"});return URL.createObjectURL(t)}}catch{}return o}(t)),s=o.get(Yr);return s.fragments=i,s.world=e,e.camera.controls.addEventListener("rest",()=>i.update(!0)),e.camera.controls.addEventListener("update",()=>i.update()),i.models.list.onItemSet.add(function(){var n=(0,H.A)(function*({value:r}){const a=r.object.userData.overrides;r.useCamera(e.camera.three),e.scene.three.add(r.object),Jr(a)&&(r.object.visible=!1,yield Bc(1),yield s.applyModelOverrides(r,a),r.object.visible=!0),yield i.update(!0),r.object.visible=!0,Jr(a)||(yield s.applyModelOverrides(r,a),yield i.update(!0)),yield i.update(!0)});return function(r){return n.apply(this,arguments)}}()),e.onCameraChanged.add(n=>{for(const[,r]of i.models.list)r.useCamera(n.three);i.update(!0)}),i},Rc=function(){var o=(0,H.A)(function*(e,t,i){void 0===i&&(i=Kr(e));const s=t.map(a=>a.id),n=t.filter(a=>!i.includes(a.id)).filter(a=>!0===a.visible),r=i.filter(a=>!s.includes(a));return n.length&&(console.info(`Loading ${n.length} model(s)`),yield Xr(e,n)),r.length&&(console.info(`Disposing ${n.length} model(s)`),yield Qr(e,r)),[...e.models.list.values()]});return function(t,i,s){return o.apply(this,arguments)}}(),Xr=function(){var o=(0,H.A)(function*(e,t){const i=[];for(const s of t)try{console.info(`Loading ${s.name} (${s.id})...`);const r=yield(yield fetch(s.fileURL)).arrayBuffer();console.info("Got model buffer...");const a=yield e.load(r,{modelId:s.id,userData:{overrides:s.overrides}});console.info("Model loaded into fragments..."),s.makeAllMaterialsDoubleSided&&(yield Fc(a)),yield e.update(),i.push(a),s.visible=!0,console.info(`\u2705 ${s.name} (${s.id}) loaded`)}catch(n){console.error(`\u274c Error loading model ${s.name} (${s.id}): `,n)}return i});return function(t,i){return o.apply(this,arguments)}}(),Qr=function(){var o=(0,H.A)(function*(e,t){void 0===t&&(t=Kr(e));const i=[];for(const s of t)i.push(e.disposeModel(s));yield Promise.all(i)});return function(t,i){return o.apply(this,arguments)}}(),Kr=o=>[...o.models?.list.values()].map(i=>i.modelId),Jr=o=>!(!o.isolated.length&&!o.isolatedTypes.length),Bc=function(){var o=(0,H.A)(function*(e){return new Promise(t=>setTimeout(()=>t(),e))});return function(t){return o.apply(this,arguments)}}(),Lc={"#e2f552":"accent","#2859e1":"primary","#1744c2":"secondary","#ffffff":"default","#8394b0":"fade"},Vc={accent:new b.Q1f("#2859e1"),primary:new b.Q1f("#1744c2"),secondary:new b.Q1f("#2859e1"),default:new b.Q1f("#e2f552"),fade:new b.Q1f("#e2f552")},Uc={accent:new b.Q1f("#e2f552"),primary:new b.Q1f("#1744c2"),secondary:new b.Q1f("#1744c2"),default:new b.Q1f("#1744c2"),fade:new b.Q1f("#1744c2")},$c={accent:new b.Q1f("#2859e1"),primary:new b.Q1f("#e2f552"),secondary:new b.Q1f("#e2f552"),default:new b.Q1f("#e2f552"),fade:new b.Q1f("#e2f552")},Hc=o=>{const e=new b.Q1f(o),i=.299*e.r+.587*e.g+.114*e.b>.5?.75:1.25;return new b.Q1f(Math.min(e.r*i,1),Math.min(e.g*i,1),Math.min(e.b*i,1))};function Yc(o){let e="";return e=o.LongName?.value?o.LongName.value:o.Name?.value?o.Name.value:o.type||"(no name)",`${e} [${o._category.value}]`}function to(o,e,t){return on.apply(this,arguments)}function on(){return(on=(0,H.A)(function*(o,e,t){console.log(e);const i=yield o.getItemsData(e,{relations:{Decomposes:{attributes:!0,relations:!0}}});console.log(i),void 0===t.children&&(t.children=[]);for(const s of i){const n=[];for(const r of s.Decomposes||[]){const a=r._localId.value,l=yield o.getItemsData([a],{relations:{IsDecomposedBy:{attributes:!0,relations:!0}}});console.log(l);const c={id:a,label:Yc(r)};yield to(o,[a],c),n.push(c)}t.children.push(...n)}})).apply(this,arguments)}function an(){return(an=(0,H.A)(function*(o,e){const t=yield o.getItemsOfCategories([/IFCSITE/]),i={label:e,children:[]};yield to(o,t.IFCSITE,i),console.log(i)})).apply(this,arguments)}let ln=(()=>{class o{_workerUrl=(0,st.WQX)(zc.g);_container=(0,st.vPA)(void 0);modelsAreLoading=(0,st.vPA)(!1);settings=(0,st.vPA)(new rs.R_);_previousHighlights=null;raycastResult=(0,st.vPA)(null);hoveredElement=(0,Mt.EW)(()=>{const t=this.raycastResult()?.localId??null,i=this.raycastResult()?.fragments.modelId??null;return i&&t?{[i]:new Set([t])}:null},{equal:(t,i)=>((o,e)=>{if(!o&&!e)return!0;if(!o||!e)return!1;const t=Object.keys(o),i=Object.keys(e);if(t.length!==i.length||t[0]!==i[0])return!1;const s=o[t[0]],n=e[i[0]];if(s.size!==n.size)return!1;const r=Array.from(s.values()),a=Array.from(n.values());return r[0]===a[0]})(t,i)});clickedElement=(0,st.vPA)(null);selectedElements=(0,st.vPA)(null);init(t){this._container.set(t)}_colorDef=(0,Mt.EW)(()=>{const t=this._container();if(t)return(o=>{const t=window.getComputedStyle(o).getPropertyValue("--background-color"),i=Lc[t];return{hoverColor:Vc[i]??new b.Q1f("#e2f552"),selectionColor:Uc[i]??new b.Q1f("#1744c2"),selectionOutlineColor:$c[i]??new b.Q1f("#e2f552"),ghostColor:Hc(t)}})(t)});_loadedModels=(0,st.vPA)([]);_components=(0,Mt.EW)(()=>{if(void 0!==this._container())return console.info("Building components..."),new js});_world=(0,Mt.EW)(()=>{const t=this._components(),i=this._container();if(void 0!==t&&void 0!==i)return console.info("Setting up scene..."),((o,e)=>{const i=o.get(bs).create();i.scene=new Kn(o),i.scene.setup(),i.scene.three.background=null,i.renderer=new nn.Hs(o,e);const{postproduction:s}=i.renderer;return i.camera=new Hs(o),o.init(),i.scene.setup(),s.enabled=!0,i.scene.three.background=null,i.camera.controls.restThreshold=.25,i})(t,i)});_fragments=(0,Mt.EW)(()=>{const t=this._world();if(void 0===t)return;const i=this._components();return void 0!==i?(console.info("Setting up fragments..."),Dc(i,t,this._workerUrl)):void 0});viewerReady=(0,Mt.EW)(()=>!(void 0===this._components()||void 0===this._world()||void 0===this._fragments()));get loadedModels(){return this._loadedModels}constructor(){(0,st.QZP)(()=>{this.viewerReady()&&(console.info("Initializing event listeners..."),this._initEventListeners(),console.info("BIM Fragments Viewer is ready"))}),(0,st.QZP)(()=>{const t=this.settings(),i=this._world(),s=this._components(),n=this._fragments(),r=this._colorDef();void 0===t||void 0===i||void 0===s||void 0===n||void 0===r||this.viewerReady()&&(((o,e,t,i,s)=>{t.dynamicAnchor=o.dynamicAnchor;const n=t.renderer?.postproduction;if(n&&(n.enabled=o.postProductionSettings.enabled,n.style=o.postProductionSettings.style),o.clickEnabled){const r=e.get(sn);r.world=t,r.fragments=i,r.enabled=!0,r.material=new b.V9B({color:s.hoverColor,transparent:!0,opacity:.5,depthTest:!1});const a=e.get(Mc);a.world=t,a.fragments=i,a.enabled=!0;const l=e.get(Gr);l.enabled=!0,l.fragments=i,l.multiSelect=o.multiSelect,l.styles={fillColor:s.selectionColor,outlineColor:s.selectionOutlineColor,fillOpacity:.5}}if(o.applyGhosting){const r=e.get(en);r.enabled=!0,r.ghostColor=s.ghostColor,r.fragments=i,r.world=t}console.info("Settings updated")})(t,s,i,n,r),console.info("Settings updated"))})}dispose(){var t=this;return(0,H.A)(function*(){yield t.disposeModels()})()}loadFragmentFiles(t){var i=this;return(0,H.A)(function*(){console.log("LOAD FRAGMENTS");const s=i._fragments();if(void 0===s)throw new Error("Fragments not available");i.modelsAreLoading.set(!0);const n=yield Xr(s,t);i._loadedModels.update(()=>[...n]),console.log("YYY"),console.log(n),i.modelsAreLoading.set(!1)})()}disposeModels(t){var i=this;return(0,H.A)(function*(){const s=t?t.map(r=>r.id):void 0,n=i._fragments();if(void 0===n)throw new Error("Fragments not available");yield Qr(n,s),void 0!==t&&t.forEach(r=>r.visible=!1)})()}updateModels(t){var i=this;return(0,H.A)(function*(){const s=i._fragments();if(void 0===s)throw new Error("Fragments not available");const n=yield Rc(s,t);i._loadedModels.update(()=>[...n])})()}getSpatialStructure(t){var i=this;return(0,H.A)(function*(){const s=i._fragments()?.models.list.get(t.id);return void 0!==s&&function Zc(o,e){an.apply(this,arguments)}(s,t.name),s?.getSpatialStructure()})()}updateAspectRatio(){this._world()?.renderer?.resize(),this._world()?.camera.updateAspect()}_initEventListeners(){var t=this;const i=this._components().get(Gr);i.events.clickedElement.add(n=>{const r=this.hoveredElement();null!==r&&this.clickedElement.update(()=>({itemData:n,element:r}))}),i.events.clickedCanvas.add(()=>{this.clickedElement.update(()=>null)}),i.events.selection.add(n=>{this.selectedElements.update(()=>n)}),this._components().get(sn).events.hoveredElement.add(function(){var n=(0,H.A)(function*(r){t.raycastResult.update(()=>r)});return function(r){return n.apply(this,arguments)}}()),this._fragments().models.list.onItemSet.add(()=>{})}static \u0275fac=function(i){return new(i||o)};static \u0275prov=st.jDH({token:o,factory:o.\u0275fac,providedIn:"root"})}return o})();var Wc=_t(7023),qc=_t(5970),qe=_t(5381),cn=_t(5187),ts=_t(1696),hn=_t(3319),m=_t(5547);function Gc(o,e){if(1&o){const t=m.RV6();m.j41(0,"cue-flexcontainer",3)(1,"cue-button",5),m.bIt("click",function(){st.eBV(t);const s=m.XpG();return st.Njj(s.zoomOut())}),m.nrm(2,"cue-button-icon",6),m.k0s(),m.j41(3,"cue-button",5),m.bIt("click",function(){st.eBV(t);const s=m.XpG();return st.Njj(s.zoomIn())}),m.nrm(4,"cue-button-icon",7),m.k0s(),m.j41(5,"cue-button",5),m.bIt("click",function(){st.eBV(t);const s=m.XpG();return st.Njj(s.zoomFit())}),m.nrm(6,"cue-button-icon",8),m.k0s()()}}function Xc(o,e){if(1&o){const t=m.RV6();m.j41(0,"cue-button",5),m.bIt("click",function(){st.eBV(t);const s=m.XpG();return st.Njj(s.toggleLayersVisible())}),m.nrm(1,"cue-button-icon",9),m.k0s()}if(2&o){const t=m.XpG();m.AVh("border-left",t.options().displayZoom&&t.displayDecompositionTree())}}let Qc=(()=>{class o{settings=(0,bt.hFB)(new rs.R_);options=(0,Mt.EW)(()=>this.settings().toolbar);selectMenuPositions=(0,Mt.EW)(()=>"top"===this.options().position?"bottomleft":"topleft");displayDecompositionTree=(0,Mt.EW)(()=>void 0!==this.options().displayDecompositionTree);zoomIn(){}zoomOut(){}zoomFit(){}toggleLayersVisible(){}static \u0275fac=function(i){return new(i||o)};static \u0275cmp=m.VBU({type:o,selectors:[["cue-bim-fragments-toolbar"]],inputs:{settings:[1,"settings"]},decls:5,vars:3,consts:[["align","center",1,"container"],[1,"toolbar",3,"padded"],["align","center"],["align","center","gap","s"],["size","xs","variant","tertiary",3,"border-left"],["size","xs","variant","tertiary",3,"click"],["icon","zoom-out"],["icon","zoom-in"],["icon","zoom-fit"],["icon","tree"]],template:function(i,s){1&i&&(m.j41(0,"cue-flexcontainer",0)(1,"cue-card",1)(2,"cue-flexcontainer",2),m.nVh(3,Gc,7,0,"cue-flexcontainer",3),m.nVh(4,Xc,2,2,"cue-button",4),m.k0s()()()),2&i&&(m.R7$(),m.Y8G("padded",!1),m.R7$(2),m.vxM(s.options().displayZoom?3:-1),m.R7$(),m.vxM(s.displayDecompositionTree()?4:-1))},dependencies:[qe.n,cn.Card,ts.$,hn.a],styles:[".container[_ngcontent-%COMP%]{height:100%;pointer-events:none}.toolbar[_ngcontent-%COMP%]{pointer-events:all;padding:5px 10px}.border-left[_ngcontent-%COMP%]{border-left:1px solid;padding-left:12px}"],changeDetection:0})}return o})();var Kc=_t(9421),Jc=_t(1024),es=_t(2245);function th(o,e){if(1&o&&m.nrm(0,"cue-key-val",3),2&o){const t=m.XpG();m.Y8G("val",t.name)}}function eh(o,e){if(1&o&&m.nrm(0,"cue-key-val",5),2&o){const t=e.$implicit;m.Y8G("key",t.label)("val",t.value)}}function ih(o,e){if(1&o&&(m.j41(0,"cue-typography",4),m.EFF(1),m.k0s(),m.j41(2,"cue-key-val-list"),m.Z7z(3,eh,1,2,"cue-key-val",5,m.Vm6),m.k0s()),2&o){const t=e.$implicit;m.R7$(),m.JRh(t.psetName),m.R7$(2),m.Dyx(t.props)}}function sh(o,e){if(1&o&&m.Z7z(0,ih,5,1,null,null,m.Vm6),2&o){const t=m.XpG();m.Dyx(t.psets)}}function nh(o,e){if(1&o&&(m.nVh(0,th,1,1,"cue-key-val",3),m.nVh(1,sh,2,0)),2&o){const t=e;m.vxM(t.name?0:-1),m.R7$(),m.vxM(t.psets.length>0?1:-1)}}function rh(o,e){if(1&o&&(m.j41(0,"cue-card",1)(1,"cue-flexcontainer",2),m.nVh(2,nh,2,2),m.k0s()()),2&o){let t;const i=m.XpG();m.Y8G("padded",!1)("scrollable",!0),m.R7$(2),m.vxM((t=i.props())?2:-1,t)}}function oh(o,e){if(1&o&&m.nrm(0,"cue-key-val",3),2&o){const t=m.XpG();m.Y8G("val",t.name)}}function ah(o,e){if(1&o&&m.nrm(0,"cue-key-val",5),2&o){const t=e.$implicit;m.Y8G("key",t.label)("val",t.value)}}function lh(o,e){if(1&o&&(m.j41(0,"cue-typography",4),m.EFF(1),m.k0s(),m.j41(2,"cue-key-val-list"),m.Z7z(3,ah,1,2,"cue-key-val",5,m.Vm6),m.k0s()),2&o){const t=e.$implicit;m.R7$(),m.JRh(t.psetName),m.R7$(2),m.Dyx(t.props)}}function ch(o,e){if(1&o&&m.Z7z(0,lh,5,1,null,null,m.Vm6),2&o){const t=m.XpG();m.Dyx(t.psets)}}function hh(o,e){if(1&o&&(m.nVh(0,oh,1,1,"cue-key-val",3),m.nVh(1,ch,2,0)),2&o){const t=e;m.vxM(t.name?0:-1),m.R7$(),m.vxM(t.psets.length>0?1:-1)}}function uh(o,e){if(1&o&&(m.j41(0,"cue-flexcontainer",2),m.nVh(1,hh,2,2),m.k0s()),2&o){let t;const i=m.XpG();m.R7$(),m.vxM((t=i.props())?1:-1,t)}}let dh=(()=>{class o{element=bt.hFB.required();wrapInCard=(0,bt.hFB)(!0);props=(0,Mt.EW)(()=>{const t=this.element().itemData,i=this.formatItemPsets(t.IsDefinedBy||[]);return{name:t.Name?.value||"No name",psets:i}});formatItemPsets(t){const i=[];for(const[,s]of t.entries()){const{Name:n,HasProperties:r}=s;if(!("value"in n)||!Array.isArray(r))continue;const a=[];for(const[,l]of r.entries()){const{Name:c,NominalValue:h}=l;if(!("value"in c)||!("value"in h))continue;const u=c.value,f=h.value;u&&void 0!==f&&a.push({label:u,value:f.toString()})}i.push({psetName:n.value,props:a})}return i}static \u0275fac=function(i){return new(i||o)};static \u0275cmp=m.VBU({type:o,selectors:[["cue-bim-fragments-props-viewer"]],inputs:{element:[1,"element"],wrapInCard:[1,"wrapInCard"]},decls:3,vars:1,consts:[["direction","column","justify","start",1,"container"],[1,"card",3,"padded","scrollable"],["align","start","direction","column"],["key","Name",3,"val"],["size","s","weight","semibold"],[3,"key","val"]],template:function(i,s){1&i&&(m.j41(0,"cue-flexcontainer",0),m.nVh(1,rh,3,3,"cue-card",1)(2,uh,2,1,"cue-flexcontainer",2),m.k0s()),2&i&&(m.R7$(),m.vxM(s.wrapInCard()?1:2))},dependencies:[qe.n,cn.Card,Kc.F,Jc.p,es.o],styles:[".container[_ngcontent-%COMP%]{height:100%;pointer-events:none}.card[_ngcontent-%COMP%]{pointer-events:all;max-height:100%;width:300px;flex:1 1}.border-left[_ngcontent-%COMP%]{border-left:1px solid;padding-left:12px}"],changeDetection:0})}return o})();var eo=_t(9769);let fh=(()=>{class o{selectedItem=(0,st.vPA)(void 0);static \u0275fac=function(i){return new(i||o)};static \u0275prov=st.jDH({token:o,factory:o.\u0275fac,providedIn:"root"})}return o})();var io=_t(7089),ph=_t(5448),so=_t(6117),un=_t(356),dn=_t(6279);const no=(o,e)=>e.path;function mh(o,e){if(1&o){const t=m.RV6();m.j41(0,"cue-menu-item",7),m.bIt("click",function(s){const n=st.eBV(t).$implicit,r=m.XpG(2);return st.Njj(r.navigateTo(s,n.path))}),m.EFF(1),m.k0s()}if(2&o){const t=e.$implicit;m.R7$(),m.SpI(" ",t.name," ")}}function gh(o,e){if(1&o&&(m.j41(0,"cue-flexcontainer",2)(1,"cue-menu")(2,"cue-button",4,0)(4,"cue-button-label"),m.EFF(5,"..."),m.k0s()(),m.j41(6,"cue-menu-wrap",5),m.Z7z(7,mh,2,1,"cue-menu-item",null,no),m.k0s()(),m.j41(9,"cue-typography",6),m.EFF(10," \u203a "),m.k0s()()),2&o){const t=m.XpG();m.R7$(2),m.Y8G("size",t.buttonSize())("cueTooltip",t.hiddenPartsTooltip()),m.R7$(5),m.Dyx(t.hidddenParts()),m.R7$(2),m.Y8G("size",t.size())}}function _h(o,e){if(1&o&&(m.j41(0,"cue-typography",6),m.EFF(1," \u203a "),m.k0s()),2&o){const t=m.XpG(2);m.Y8G("size",t.size())}}function yh(o,e){if(1&o){const t=m.RV6();m.j41(0,"cue-flexcontainer",8),m.bIt("click",function(s){const n=st.eBV(t),r=n.$implicit,a=n.$index,l=n.$count,c=m.XpG();return st.Njj(a!==l-1&&!c.buttonMode()&&c.navigateTo(s,r.path))}),m.j41(1,"cue-typography",9),m.EFF(2),m.k0s(),m.nVh(3,_h,2,1,"cue-typography",6),m.k0s()}if(2&o){const t=e.$implicit,i=e.$index,s=e.$count,n=m.XpG();m.AVh("clickable",i!==s-1&&n.updatePathOnClick()&&!n.buttonMode()),m.R7$(),m.AVh("full-length",n.nameFullLength()),m.Y8G("size",n.size())("weight",i===s-1?"medium":"regular")("title",t.name),m.R7$(),m.SpI(" ",t.name," "),m.R7$(),m.vxM(i!==s-1?3:-1)}}let vh=(()=>{class o{path=bt.geq.required();size=(0,bt.hFB)("xs");rootName=(0,bt.hFB)(null);maxVisibleParts=(0,bt.hFB)(3);nameFullLength=(0,bt.hFB)(!1);updatePathOnClick=(0,bt.hFB)(!0);buttonMode=(0,bt.hFB)(!1);buttonSize=(0,Mt.EW)(()=>{switch(this.size()){case"xs":case"s":default:return"s";case"m":case"l":case"xl":return"m"}});get sizeAttribute(){return this.size()}get buttonModeClass(){return this.buttonMode()}onHostClick(t){this.buttonMode()&&(t.stopPropagation(),this.clickedPath.emit(this.path()))}pathChange=(0,bt.CGW)();clickedPath=(0,bt.CGW)();allBreadcrumbParts=(0,Mt.EW)(()=>{const t=this.path().split("/").filter(r=>""!==r),i=[],s=this.rootName();null!==s&&i.push({name:s,path:"/"});let n="";for(const r of t)n+=`/${r}`,i.push({name:r,path:n.endsWith("/")?n:`${n}/`});return i});shouldShowEllipsis=(0,Mt.EW)(()=>this.allBreadcrumbParts().length>this.maxVisibleParts());visibleBreadcrumbParts=(0,Mt.EW)(()=>{const t=this.allBreadcrumbParts(),i=this.maxVisibleParts();return t.length<=i?t:t.slice(-i)});hidddenParts=(0,Mt.EW)(()=>{const t=this.allBreadcrumbParts(),i=this.maxVisibleParts();return t.length<=i?[]:t.slice(0,-i)});hiddenPartsTooltip=(0,Mt.EW)(()=>{const t=this.hidddenParts();return 0===t.length?"":`${t.map(i=>i.name).join(" \u203a ")}`});navigateTo(t,i){console.log("Navigating to:",i),t.stopImmediatePropagation(),t.stopPropagation(),t.preventDefault(),this.clickedPath.emit(i),this.updatePathOnClick()&&(this.path.set(i),this.pathChange.emit(i))}static \u0275fac=function(i){return new(i||o)};static \u0275cmp=m.VBU({type:o,selectors:[["cue-breadcrumb"]],hostVars:3,hostBindings:function(i,s){1&i&&m.bIt("click",function(r){return s.onHostClick(r)}),2&i&&(m.BMQ("size",s.sizeAttribute),m.AVh("button-mode",s.buttonModeClass))},inputs:{path:[1,"path"],size:[1,"size"],rootName:[1,"rootName"],maxVisibleParts:[1,"maxVisibleParts"],nameFullLength:[1,"nameFullLength"],updatePathOnClick:[1,"updatePathOnClick"],buttonMode:[1,"buttonMode"]},outputs:{path:"pathChange",pathChange:"pathChange",clickedPath:"clickedPath"},decls:4,vars:1,consts:[["trigger",""],["direction","row","gap","s","align","center"],["direction","row","gap","s","align","center",1,"ellipsis-container"],["direction","row","gap","s",3,"clickable"],["trigger","","variant","ghost",3,"size","cueTooltip"],["menu",""],["weight","semibold",3,"size"],[3,"click"],["direction","row","gap","s",3,"click"],[1,"breadcrumb-text",3,"size","weight","title"]],template:function(i,s){1&i&&(m.j41(0,"cue-flexcontainer",1),m.nVh(1,gh,11,3,"cue-flexcontainer",2),m.Z7z(2,yh,4,9,"cue-flexcontainer",3,no),m.k0s()),2&i&&(m.R7$(),m.vxM(s.shouldShowEllipsis()?1:-1),m.R7$(),m.Dyx(s.visibleBreadcrumbParts()))},dependencies:[eo.MD,es.o,qe.n,ts.$,ph.L,io.d,so.W,un.M,dn.D],styles:['.clickable[_ngcontent-%COMP%]{cursor:pointer}.clickable[_ngcontent-%COMP%]:hover{text-decoration:underline}.separator[_ngcontent-%COMP%]{color:#666;padding:0 4px}.full-length[_ngcontent-%COMP%]{max-width:none!important}.full-length[_ngcontent-%COMP%] > div[_ngcontent-%COMP%]{max-width:none!important;overflow:visible!important;text-overflow:unset!important;white-space:normal!important}.breadcrumb-text[_ngcontent-%COMP%]:not(.full-length){max-width:100px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;display:block}.breadcrumb-text[_ngcontent-%COMP%]:not(.full-length) > div[_ngcontent-%COMP%]{max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.ellipsis-container[_ngcontent-%COMP%]{cursor:default;display:flex;align-items:center}.ellipsis-text[_ngcontent-%COMP%]{color:#666;font-style:italic;line-height:1;display:flex;align-items:center;text-align:center;vertical-align:middle;justify-content:center;height:100%;min-height:1em}.ellipsis-text[_ngcontent-%COMP%] span[_ngcontent-%COMP%]{display:inline-block!important}.ellipsis-text[_ngcontent-%COMP%] *{display:flex!important;align-items:center!important;justify-content:center!important;height:100%!important;line-height:1!important}.button-mode[_nghost-%COMP%]{cursor:pointer}[size="xs"][_nghost-%COMP%] .breadcrumb-text[_ngcontent-%COMP%]:not(.full-length){max-width:70px}[size="s"][_nghost-%COMP%] .breadcrumb-text[_ngcontent-%COMP%]:not(.full-length){max-width:80px}[size="m"][_nghost-%COMP%] .breadcrumb-text[_ngcontent-%COMP%]:not(.full-length){max-width:100px}[size="l"][_nghost-%COMP%] .breadcrumb-text[_ngcontent-%COMP%]:not(.full-length){max-width:120px}[size="xl"][_nghost-%COMP%] .breadcrumb-text[_ngcontent-%COMP%]:not(.full-length){max-width:150px}']})}return o})();var wh=_t(29);const bh=()=>[],xh=()=>({}),Ch=(o,e)=>e.label;function Th(o,e){if(1&o&&m.nrm(0,"cue-svg-icon",17),2&o){const t=m.XpG().$implicit;m.Y8G("name",t.icon)}}function Eh(o,e){if(1&o){const t=m.RV6();m.j41(0,"cue-menu-item",16),m.bIt("click",function(){const s=st.eBV(t).$implicit;return st.Njj(s.action())}),m.nVh(1,Th,1,1,"cue-svg-icon",17),m.EFF(2),m.k0s()}if(2&o){const t=e.$implicit;m.Y8G("tooltip",t.tooltip??""),m.R7$(),m.vxM(t.icon?1:-1),m.R7$(),m.SpI(" ",t.label," ")}}function Ah(o,e){if(1&o&&(m.j41(0,"cue-menu",11),m.bIt("click",function(i){return i.stopPropagation()}),m.j41(1,"cue-button",12),m.nrm(2,"cue-button-icon",13),m.k0s(),m.j41(3,"cue-menu-wrap",14),m.Z7z(4,Eh,3,3,"cue-menu-item",15,Ch),m.k0s()()),2&o){const t=m.XpG().$implicit;m.R7$(),m.Y8G("cueTooltip",t.tooltip??""),m.R7$(),m.Y8G("icon",t.icon),m.R7$(2),m.Dyx(t.menuItems)}}function Ph(o,e){if(1&o){const t=m.RV6();m.j41(0,"cue-button",18),m.bIt("click",function(s){return st.eBV(t),m.XpG().$implicit.action(),st.Njj(s.stopPropagation())}),m.nrm(1,"cue-button-icon",13),m.k0s()}if(2&o){const t=m.XpG().$implicit;m.Y8G("cueTooltip",t.tooltip??""),m.R7$(),m.Y8G("icon",t.icon)}}function Sh(o,e){if(1&o&&m.nVh(0,Ah,6,2,"cue-menu")(1,Ph,2,2,"cue-button",10),2&o){const t=e.$implicit;m.vxM(null!=t.menuItems&&t.menuItems.length?0:t.action?1:-1)}}function Ih(o,e){if(1&o&&(m.j41(0,"cue-flexcontainer",3),m.Z7z(1,Sh,2,1,null,null,m.Vm6),m.k0s()),2&o){const t=m.XpG().$implicit;m.R7$(),m.Dyx(t.buttons)}}function Mh(o,e){if(1&o&&(m.j41(0,"cue-typography",20),m.EFF(1),m.k0s()),2&o){const t=m.XpG(2).$implicit;m.R7$(),m.JRh(t.subLabel)}}function Oh(o,e){if(1&o&&(m.j41(0,"div",4)(1,"cue-typography",19),m.EFF(2),m.k0s(),m.nVh(3,Mh,2,1,"cue-typography",20),m.k0s()),2&o){const t=m.XpG().$implicit,i=m.XpG();m.R7$(),m.Y8G("weight",i.isSelected(t)?"semibold":"regular")("size",i.size()),m.R7$(),m.JRh(t.label),m.R7$(),m.vxM(t.subLabel?3:-1)}}function kh(o,e){if(1&o&&m.nrm(0,"cue-breadcrumb",6),2&o){const t=m.XpG().$implicit,i=m.XpG();m.Y8G("maxVisibleParts",5)("path",t.label)("size",i.size())("nameFullLength",!0)("updatePathOnClick",!1)}}function zh(o,e){if(1&o&&m.nrm(0,"cue-svg-icon",21),2&o){const t=m.XpG().$implicit,i=m.XpG();m.AVh("expanded",i.isExpanded(t))}}function Fh(o,e){if(1&o&&(m.j41(0,"div",8),m.nrm(1,"cue-tree-menu",22),m.k0s()),2&o){const t=m.XpG().$implicit,i=m.XpG();m.R7$(),m.Y8G("items",t.children||m.lJ4(2,bh))("size",i.size())}}function Nh(o,e){if(1&o&&(m.j41(0,"div",23),m.bIt("click",function(i){return i.stopPropagation()}),m.eu8(1,24),m.k0s()),2&o){const t=m.XpG().$implicit;m.R7$(),m.Y8G("ngTemplateOutlet",t.contentTemplate)("ngTemplateOutletContext",t.templateContext??m.lJ4(2,xh))}}function Dh(o,e){if(1&o){const t=m.RV6();m.j41(0,"li",1)(1,"cue-flexcontainer",2),m.bIt("click",function(){const s=st.eBV(t).$implicit,n=m.XpG();return st.Njj(n.handleItemClick(s))}),m.nVh(2,Ih,3,0,"cue-flexcontainer",3),m.nVh(3,Oh,4,4,"div",4),m.nrm(4,"span",5),m.nVh(5,kh,1,5,"cue-breadcrumb",6),m.nVh(6,zh,1,2,"cue-svg-icon",7),m.k0s(),m.nVh(7,Fh,2,3,"div",8),m.nVh(8,Nh,2,3,"div",9),m.k0s()}if(2&o){const t=e.$implicit,i=m.XpG();m.R7$(),m.AVh("has-children",i.hasChildren(t)),m.R7$(),m.vxM(null!=t.buttons&&t.buttons.length?2:-1),m.R7$(),m.vxM(void 0===t.type||"text"===t.type?3:-1),m.R7$(2),m.vxM("breadcrumb"===t.type?5:-1),m.R7$(),m.vxM(i.hasChildren(t)?6:-1),m.R7$(),m.vxM(i.hasChildren(t)&&i.isExpanded(t)?7:-1),m.R7$(),m.vxM(t.contentTemplate?8:-1)}}let Rh=(()=>{class o{_service=(0,st.WQX)(fh);items=(0,bt.geq)([]);size=(0,bt.hFB)("m");collapseOnSelect=(0,bt.hFB)(!1);initialExpandDepth=(0,bt.hFB)(-1);expandedItems=new Set;selectionChanged=(0,bt.CGW)();onItemsChange=(0,st.QZP)(()=>{this.collapseOnSelect()||this._initialExpandSelected()});onSelectionChange=(0,st.QZP)(()=>{const t=this._service.selectedItem();void 0!==t&&this.selectionChanged.emit(t)});ngOnDestroy(){this.items.update(()=>[])}handleItemClick(t){if(this.hasChildren(t)){this.expandedItems.has(t)?this.expandedItems.delete(t):this.expandedItems.add(t);const i=this._service.selectedItem();void 0!==i&&(i.selected=!1),t.selected=!0,this._service.selectedItem.set(t)}else this._setSelected(t),this._update()}hasChildren(t){return!!t.children&&t.children.length>0}isExpanded(t){return this.expandedItems.has(t)}isSelected(t){return t.selected}_setSelected(t){const i=this._service.selectedItem();void 0!==i&&(i.selected=!1),t.selected=!0}_update(){this.items.update(()=>[...this.items()])}_initialExpandSelected(){this.expandedItems.clear();const t=this.initialExpandDepth(),i=(s,n=[],r=0)=>{for(const a of s){if(t>=0&&r<=t&&this.hasChildren(a)&&this.expandedItems.add(a),a.selected){this._service.selectedItem.set(a);for(const l of n)this.expandedItems.add(l)}a.children&&a.children.length>0&&i(a.children,[...n,a],r+1)}};i(this.items()??[])}static \u0275fac=function(i){return new(i||o)};static \u0275cmp=m.VBU({type:o,selectors:[["cue-tree-menu"]],inputs:{items:[1,"items"],size:[1,"size"],collapseOnSelect:[1,"collapseOnSelect"],initialExpandDepth:[1,"initialExpandDepth"]},outputs:{items:"itemsChange",selectionChanged:"selectionChanged"},decls:3,vars:0,consts:[[1,"menu"],[1,"menu-item"],["justify","start","align","center","gap","s",1,"menu-item-header",3,"click"],["gap","s","align","center"],[2,"display","flex","flex-direction","row","align-items","baseline","gap","6px"],[2,"flex","1"],[3,"maxVisibleParts","path","size","nameFullLength","updatePathOnClick"],["name","arrow-dropdown",1,"menu-item-arrow",3,"expanded"],[1,"submenu"],[1,"menu-item-content"],["size","xs","variant","ghost","tooltipPlacement","right",3,"cueTooltip"],[3,"click"],["trigger","","size","xs","variant","ghost","tooltipPlacement","right",3,"cueTooltip"],[3,"icon"],["menu",""],[3,"tooltip"],[3,"click","tooltip"],["before","",3,"name"],["size","xs","variant","ghost","tooltipPlacement","right",3,"click","cueTooltip"],[3,"weight","size"],["size","xs",2,"opacity","0.6"],["name","arrow-dropdown",1,"menu-item-arrow"],[3,"items","size"],[1,"menu-item-content",3,"click"],[3,"ngTemplateOutlet","ngTemplateOutletContext"]],template:function(i,s){1&i&&(m.j41(0,"ul",0),m.Z7z(1,Dh,9,8,"li",1,m.Vm6),m.k0s()),2&i&&(m.R7$(),m.Dyx(s.items()))},dependencies:[o,es.o,qe.n,vh,ts.$,hn.a,wh.A,io.d,eo.T3,so.W,dn.D,un.M],styles:[".menu[_ngcontent-%COMP%]{list-style:none;padding:0;margin:0}.menu-item[_ngcontent-%COMP%]{cursor:pointer;-webkit-user-select:none;user-select:none}.menu-item-header[_ngcontent-%COMP%]{padding:8px 16px;transition:background-color .2s}.menu-item-header[_ngcontent-%COMP%]:hover{background-color:var(--cue-color-green);color:var(--cue-color-black)}.menu-item-header[_ngcontent-%COMP%]:hover *{color:var(--cue-color-black);fill:var(--cue-color-black)}.menu-item-header.has-children[_ngcontent-%COMP%]{font-weight:700}.menu-item-arrow[_ngcontent-%COMP%]{transition:transform .2s;flex-shrink:0}.menu-item-arrow.expanded[_ngcontent-%COMP%]{transform:rotate(180deg)}.submenu[_ngcontent-%COMP%]{padding-left:16px;border-left:1px solid}"]})}return o})(),Bh=(()=>{class o{_service=(0,st.WQX)(ln);type=(0,bt.hFB)("spatial");models=bt.geq.required();treeItems=(0,st.vPA)([]);constructor(){var t=this;(0,st.QZP)((0,H.A)(function*(){if(!t._service.loadedModels().length)return;console.log(t._service.loadedModels());const i=yield Promise.all(t.models().map(n=>t.getSpatialStructure(n)));console.log("Model Trees:",i);const s=[];t.models().forEach(n=>{s.push({label:n.name,buttons:[{icon:n.visible?"view-inactive":"view-active",action:()=>t.toggleVisibility(n)}]})}),t.treeItems.update(()=>[...s])}))}toggleVisibility(t){var i=this;return(0,H.A)(function*(){t.visible?(yield i._service.disposeModels([t]),console.log(`Model ${t.name} (${t.id}) disposed`)):yield i._service.loadFragmentFiles([t]),i.models.update(()=>[...i.models()])})()}getSpatialStructure(t){var i=this;return(0,H.A)(function*(){const s=yield i._service.getSpatialStructure(t);if(s)return{label:s.category,children:s.children?.map(n=>({label:n.name,children:n.children?.map(r=>({label:r.name}))}))}})()}static \u0275fac=function(i){return new(i||o)};static \u0275cmp=m.VBU({type:o,selectors:[["cue-bim-fragments-tree-viewer"]],inputs:{type:[1,"type"],models:[1,"models"]},outputs:{models:"modelsChange"},decls:1,vars:1,consts:[["size","s",3,"items"]],template:function(i,s){1&i&&m.nrm(0,"cue-tree-menu",0),2&i&&m.Y8G("items",s.treeItems())},dependencies:[Rh],styles:[".container[_ngcontent-%COMP%]{height:100%;pointer-events:none}.card[_ngcontent-%COMP%]{pointer-events:all;max-height:100%;width:300px;flex:1 1}.border-left[_ngcontent-%COMP%]{border-left:1px solid;padding-left:12px}"],changeDetection:0})}return o})();var Lh=_t(6034);const ro=(o,e)=>e.id;function Vh(o,e){1&o&&(m.j41(0,"cue-typography",4),m.EFF(1,"Loading..."),m.k0s())}function Uh(o,e){if(1&o){const t=m.RV6();m.j41(0,"cue-typography",4),m.EFF(1),m.k0s(),m.j41(2,"cue-button",6),m.bIt("click",function(){const s=st.eBV(t).$implicit,n=m.XpG(3);return st.Njj(n.toggleVisibility(s))}),m.nrm(3,"cue-button-icon",7),m.k0s()}if(2&o){const t=e.$implicit;m.R7$(),m.JRh(t.name),m.R7$(2),m.Y8G("icon",t.visible?"view-inactive":"view-active")}}function $h(o,e){if(1&o&&(m.j41(0,"cue-flexcontainer",5),m.Z7z(1,Uh,4,2,null,null,ro),m.k0s()),2&o){const t=m.XpG(2);m.R7$(),m.Dyx(t.models())}}function jh(o,e){if(1&o){const t=m.RV6();m.j41(0,"cue-typography",3),m.EFF(1),m.k0s(),m.j41(2,"cue-bim-fragments-tree-viewer",8),m.mxI("modelsChange",function(s){st.eBV(t);const n=m.XpG(2);return m.DH7(n.models,s)||(n.models=s),st.Njj(s)}),m.k0s()}if(2&o){const t=m.XpG(2);m.R7$(),m.JRh(t.treeLabel()),m.R7$(),m.R50("models",t.models)}}function Hh(o,e){if(1&o&&(m.j41(0,"cue-draggable-card",0)(1,"cue-flexcontainer",1)(2,"cue-flexcontainer",2)(3,"cue-typography",3),m.EFF(4,"Models"),m.k0s(),m.nVh(5,Vh,2,0,"cue-typography",4)(6,$h,3,0,"cue-flexcontainer",5),m.k0s(),m.nVh(7,jh,3,2),m.k0s()()),2&o){const t=m.XpG();m.Y8G("padded",!1),m.R7$(5),m.vxM(t.modelsAreLoading()?5:6),m.R7$(2),m.vxM(t.displayDecompositionTree()?7:-1)}}function Yh(o,e){1&o&&(m.j41(0,"cue-typography",4),m.EFF(1,"Loading..."),m.k0s())}function Zh(o,e){if(1&o){const t=m.RV6();m.j41(0,"cue-typography",4),m.EFF(1),m.k0s(),m.j41(2,"cue-button",6),m.bIt("click",function(){const s=st.eBV(t).$implicit,n=m.XpG(3);return st.Njj(n.toggleVisibility(s))}),m.nrm(3,"cue-button-icon",7),m.k0s()}if(2&o){const t=e.$implicit;m.R7$(),m.JRh(t.name),m.R7$(2),m.Y8G("icon",t.visible?"view-inactive":"view-active")}}function Wh(o,e){if(1&o&&(m.j41(0,"cue-flexcontainer",5),m.Z7z(1,Zh,4,2,null,null,ro),m.k0s()),2&o){const t=m.XpG(2);m.R7$(),m.Dyx(t.models())}}function qh(o,e){if(1&o){const t=m.RV6();m.j41(0,"cue-typography",3),m.EFF(1),m.k0s(),m.j41(2,"cue-bim-fragments-tree-viewer",8),m.mxI("modelsChange",function(s){st.eBV(t);const n=m.XpG(2);return m.DH7(n.models,s)||(n.models=s),st.Njj(s)}),m.k0s()}if(2&o){const t=m.XpG(2);m.R7$(),m.JRh(t.treeLabel()),m.R7$(),m.R50("models",t.models)}}function Gh(o,e){if(1&o&&(m.j41(0,"cue-flexcontainer",1)(1,"cue-flexcontainer",2)(2,"cue-typography",3),m.EFF(3,"Models"),m.k0s(),m.nVh(4,Yh,2,0,"cue-typography",4)(5,Wh,3,0,"cue-flexcontainer",5),m.k0s(),m.nVh(6,qh,3,2),m.k0s()),2&o){const t=m.XpG();m.R7$(4),m.vxM(t.modelsAreLoading()?4:5),m.R7$(2),m.vxM(t.displayDecompositionTree()?6:-1)}}let Xh=(()=>{class o{_service=(0,st.WQX)(ln);models=bt.geq.required();draggable=(0,bt.hFB)(!0);modelsAreLoading=this._service.modelsAreLoading;displayDecompositionTree=(0,Mt.EW)(()=>void 0!==this._service.settings().toolbar.displayDecompositionTree);treeLabel=(0,Mt.EW)(()=>"spatial"===this._service.settings().toolbar.displayDecompositionTree?"Spatial Decomposition":"System Decomposition");toggleVisibility(t){var i=this;return(0,H.A)(function*(){console.log("TOGGLE VISIBILITY",t),t.visible?(yield i._service.disposeModels([t]),console.log(`Model ${t.name} (${t.id}) disposed`)):yield i._service.loadFragmentFiles([t]),i.models.update(()=>[...i.models()])})()}static \u0275fac=function(i){return new(i||o)};static \u0275cmp=m.VBU({type:o,selectors:[["cue-bim-fragments-visibility-menu"]],inputs:{models:[1,"models"],draggable:[1,"draggable"]},outputs:{models:"modelsChange"},decls:2,vars:1,consts:[["margin","0",1,"draggable",3,"padded"],["direction","column","gap","l",2,"padding","0 10px 10px 10px"],["align","start","direction","column",2,"width","100%"],["size","s","weight","semibold"],["size","s"],["direction","row","justify","space-between","align","center",2,"width","100%"],["size","xs",3,"click"],[3,"icon"],[3,"modelsChange","models"]],template:function(i,s){1&i&&m.nVh(0,Hh,8,3,"cue-draggable-card",0)(1,Gh,7,2,"cue-flexcontainer",1),2&i&&m.vxM(s.draggable()?0:1)},dependencies:[Lh.y,es.o,qe.n,ts.$,hn.a,Bh],styles:[".draggable[_ngcontent-%COMP%]{z-index:101}"],changeDetection:0})}return o})();const Qh=["bimViewer"],oo=()=>({position:"bottomleft"}),Kh=(o,e)=>e.label;function Jh(o,e){if(1&o){const t=m.RV6();m.j41(0,"cue-menu-item",4),m.bIt("click",function(){const s=st.eBV(t).$implicit;return st.Njj(s.action())}),m.EFF(1),m.k0s()}if(2&o){const t=e.$implicit;m.R7$(),m.JRh(t.label)}}function tu(o,e){if(1&o&&(m.j41(0,"cue-menu-wrap"),m.Z7z(1,Jh,2,1,"cue-menu-item",null,Kh),m.k0s()),2&o){const t=m.XpG();m.R7$(),m.Dyx(t.contextMenuItems())}}function eu(o,e){if(1&o){const t=m.RV6();m.j41(0,"cue-bim-fragments-visibility-menu",13),m.mxI("modelsChange",function(s){st.eBV(t);const n=m.XpG(2);return m.DH7(n.models,s)||(n.models=s),st.Njj(s)}),m.k0s()}if(2&o){const t=m.XpG(2);m.R50("models",t.models),m.Y8G("draggable",!1)}}function iu(o,e){if(1&o&&m.nrm(0,"cue-bim-fragments-toolbar",15),2&o){const t=m.XpG(3),i=m.r8f(3);m.Aen(t.toolbarStyle()),m.Y8G("settings",i)}}function su(o,e){1&o&&m.nVh(0,iu,1,3,"cue-bim-fragments-toolbar",14),2&o&&m.vxM(e.hidden?-1:0)}function nu(o,e){if(1&o&&(m.j41(0,"cue-card",16),m.nrm(1,"cue-bim-fragments-props-viewer",17),m.k0s()),2&o){const t=m.XpG(2);m.AVh("hidden",null===t.$clickedElement()),m.R7$(),m.Y8G("element",e)("wrapInCard",!1)}}function ru(o,e){if(1&o){const t=m.RV6();m.j41(0,"cue-card",5),m.nVh(1,eu,1,2,"cue-bim-fragments-visibility-menu",6),m.k0s(),m.j41(2,"div",7)(3,"cue-card",8)(4,"div",9,1),m.bIt("resized",function(){st.eBV(t);const s=m.XpG();return st.Njj(s.onResized())})("windowResized",function(){st.eBV(t);const s=m.XpG();return st.Njj(s.onResized())}),m.k0s(),m.nVh(6,su,1,1),m.k0s(),m.j41(7,"a",10),m.EFF(8,"Powered by "),m.j41(9,"span",11),m.EFF(10,"ThatOpen"),m.k0s()()(),m.nVh(11,nu,2,4,"cue-card",12)}if(2&o){let t,i;const s=m.XpG(),n=m.sdS(1),r=m.r8f(3);m.R7$(),m.vxM(r.showModelList&&s.models().length?1:-1),m.R7$(3),m.Y8G("cueContextMenu",n)("contextMenuData",m.lJ4(6,oo))("cueContextEnabled",null!==s.$hoveredElement()),m.R7$(2),m.vxM((t=r.toolbar)?6:-1,t),m.R7$(5),m.vxM((i=s.$clickedElement())?11:-1,i)}}function ou(o,e){if(1&o&&m.nrm(0,"cue-bim-fragments-toolbar",15),2&o){const t=m.XpG(3),i=m.r8f(3);m.Aen(t.toolbarStyle()),m.Y8G("settings",i)}}function au(o,e){1&o&&m.nVh(0,ou,1,3,"cue-bim-fragments-toolbar",14),2&o&&m.vxM(e.hidden?-1:0)}function lu(o,e){1&o&&(m.j41(0,"div",19),m.nrm(1,"cue-bim-fragments-props-viewer",21),m.k0s()),2&o&&(m.R7$(),m.Y8G("element",e))}function cu(o,e){if(1&o){const t=m.RV6();m.j41(0,"cue-bim-fragments-visibility-menu",22),m.mxI("modelsChange",function(s){st.eBV(t);const n=m.XpG(2);return m.DH7(n.models,s)||(n.models=s),st.Njj(s)}),m.k0s()}if(2&o){const t=m.XpG(2);m.R50("models",t.models)}}function hu(o,e){if(1&o){const t=m.RV6();m.j41(0,"div",18,1),m.bIt("resized",function(){st.eBV(t);const s=m.XpG();return st.Njj(s.onResized())}),m.nVh(2,au,1,1),m.nVh(3,lu,2,1,"div",19),m.nVh(4,cu,1,1,"cue-bim-fragments-visibility-menu",20),m.j41(5,"a",10),m.EFF(6,"Powered by "),m.j41(7,"span",11),m.EFF(8,"ThatOpen"),m.k0s()()()}if(2&o){let t,i;const s=m.XpG(),n=m.sdS(1),r=m.r8f(3);m.Y8G("cueContextMenu",n)("contextMenuData",m.lJ4(6,oo))("cueContextEnabled",null!==s.$hoveredElement()),m.R7$(2),m.vxM((t=r.toolbar)?2:-1,t),m.R7$(),m.vxM((i=s.$clickedElement())?3:-1,i),m.R7$(),m.vxM(r.showModelList&&s.models().length?4:-1)}}let uu=(()=>{class o{_service=(0,st.WQX)(ln);data=(0,bt.hFB)(void 0);settings=(0,bt.hFB)(new rs.R_);clickedElement=(0,bt.CGW)();hoveredElement=(0,bt.CGW)();selectedElements=(0,bt.CGW)();$hoveredElement=(0,st.vPA)(null);$clickedElement=(0,st.vPA)(null);models=(0,Mt.uu)(()=>this.data()?.models??[]);detailedView=(0,Mt.EW)(()=>!0===this.settings().detailedViewEnabled);toolbarStyle=(0,Mt.EW)(()=>{const t=this.settings().toolbar;return{position:"absolute",left:t.margin,right:t.margin,["top"===t.position?"top":"bottom"]:t.margin,"z-index":"10",display:"flex","justify-content":"center"}});contextMenuItems=(0,Mt.EW)(()=>{const t=[];return this.settings().showPropertiesOnClick&&(console.log("ADDING PROPERTIES MENU ITEM"),t.push({label:"Show Properties",action:()=>{this.$clickedElement.update(()=>this._service.clickedElement())}})),this.settings().elementClickOptions&&t.push(...this.settings().elementClickOptions),t});viewerReady=this._service.viewerReady;onClickElement=(0,st.QZP)(()=>{this._service.clickedElement()||this.$clickedElement.set(null),this.clickedElement.emit(this._service.clickedElement())});onHoverElement=(0,st.QZP)(()=>{this.$hoveredElement.set(this._service.hoveredElement()),this.hoveredElement.emit(this._service.hoveredElement())});onSelectionChange=(0,st.QZP)(()=>{this.selectedElements.emit(this._service.selectedElements())});set bimViewer(t){t&&this._service.init(t.nativeElement)}loadFilesOnData=(0,st.QZP)(()=>{const t=this.models();console.log(t),this.viewerReady()&&t.length&&(console.info("Loading models:",t),this._service.updateModels(t))});setSettings=(0,st.QZP)(()=>this._service.settings.update(()=>Object.assign({},this.settings())));ngOnDestroy(){this._service.dispose()}onResized(){this._service.updateAspectRatio()}static \u0275fac=function(i){return new(i||o)};static \u0275cmp=m.VBU({type:o,selectors:[["cue-bim-fragments-viewer"]],viewQuery:function(i,s){if(1&i&&m.GBs(Qh,5),2&i){let n;m.mGM(n=m.lsd())&&(s.bimViewer=n.first)}},inputs:{data:[1,"data"],settings:[1,"settings"]},outputs:{clickedElement:"clickedElement",hoveredElement:"hoveredElement",selectedElements:"selectedElements"},decls:6,vars:2,consts:[["hoveringElement",""],["bimViewer",""],["direction","row",2,"flex","1 1","height","100%"],["cueResized","","trigger","leftclick",2,"height","100%","width","100%","position","relative",3,"cueContextMenu","contextMenuData","cueContextEnabled"],[3,"click"],["variant","primary",2,"flex","0 0 250px","min-width","0","display","flex","flex-direction","column","gap","0.5rem","padding","0.5rem"],[3,"models","draggable"],[2,"flex","1 1 0","min-width","0","min-height","0","position","relative","display","flex"],[2,"flex","1 1 0","min-width","0","display","flex"],["cueResized","","trigger","leftclick",2,"height","100%","width","100%","min-width","0","min-height","0","flex","1 1 0",3,"resized","windowResized","cueContextMenu","contextMenuData","cueContextEnabled"],["href","https://thatopen.com","target","_blank","rel","noopener noreferrer",1,"bim-viewer-credits"],[2,"font-weight","800"],["variant","accent",2,"flex","0 0 250px","min-width","0","display","flex","flex-direction","column","gap","0.5rem","padding","0.5rem",3,"hidden"],[3,"modelsChange","models","draggable"],[3,"settings","style"],[3,"settings"],["variant","accent",2,"flex","0 0 250px","min-width","0","display","flex","flex-direction","column","gap","0.5rem","padding","0.5rem"],[2,"flex","1 1","min-height","0",3,"element","wrapInCard"],["cueResized","","trigger","leftclick",2,"height","100%","width","100%","position","relative",3,"resized","cueContextMenu","contextMenuData","cueContextEnabled"],[1,"viewer-popup","props-popup"],[3,"models"],[3,"element"],[3,"modelsChange","models"]],template:function(i,s){1&i&&(m.DNE(0,tu,3,0,"ng-template",null,0,m.C5r),m.j41(2,"cue-flexcontainer",2),m.SS7(3),m.nVh(4,ru,12,7)(5,hu,9,7,"div",3),m.k0s()),2&i&&(m.R7$(3),m.bH3(s.settings()),m.R7$(),m.vxM(s.detailedView()?4:5))},dependencies:[qc.C,un.M,dn.D,qe.n,cn.Card,Wc.Q,Qc,dh,Xh],styles:['@import"https://fonts.googleapis.com/css2?family=Sora:wght@400;700;800&display=swap";[_nghost-%COMP%]{display:contents}.viewer-popup[_ngcontent-%COMP%]{position:absolute;z-index:100}.props-popup[_ngcontent-%COMP%]{top:8px;right:8px;bottom:8px;width:300px}.hidden[_ngcontent-%COMP%]{display:none;color:red}.bim-viewer-credits[_ngcontent-%COMP%]{position:absolute;bottom:0;left:0;font-family:Sora,sans-serif;font-size:10px;line-height:1;color:#000000bf;background:#ffffffbf;padding:2px 5px;border-radius:3px;text-decoration:none;z-index:1000;pointer-events:auto}.bim-viewer-credits[_ngcontent-%COMP%]:hover{color:#000;background:#ffffffe6}'],changeDetection:0})}return o})()}}]);
|