@thatopen/components 2.4.10 → 3.1.0
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/README.md +92 -92
- package/dist/index.cjs +18407 -25922
- package/dist/index.d.ts +4537 -6
- package/dist/index.min.cjs +3 -3
- package/dist/index.min.mjs +3 -3
- package/dist/index.mjs +18409 -25924
- package/package.json +58 -61
- package/dist/core/Clipper/index.d.ts +0 -142
- package/dist/core/Clipper/src/clipper-config.d.ts +0 -33
- package/dist/core/Clipper/src/index.d.ts +0 -1
- package/dist/core/Clipper/src/simple-plane.d.ts +0 -99
- package/dist/core/Components/index.d.ts +0 -93
- package/dist/core/ConfigManager/index.d.ts +0 -21
- package/dist/core/ConfigManager/src/configurator.d.ts +0 -13
- package/dist/core/ConfigManager/src/index.d.ts +0 -1
- package/dist/core/Cullers/index.d.ts +0 -56
- package/dist/core/Cullers/src/culler-renderer-config.d.ts +0 -74
- package/dist/core/Cullers/src/culler-renderer.d.ts +0 -76
- package/dist/core/Cullers/src/index.d.ts +0 -3
- package/dist/core/Cullers/src/mesh-culler-renderer.d.ts +0 -59
- package/dist/core/Cullers/src/screen-culler-helper.d.ts +0 -1
- package/dist/core/Disposer/index.d.ts +0 -45
- package/dist/core/Grids/index.d.ts +0 -46
- package/dist/core/Grids/src/index.d.ts +0 -2
- package/dist/core/Grids/src/simple-grid-config.d.ts +0 -80
- package/dist/core/Grids/src/simple-grid.d.ts +0 -48
- package/dist/core/MiniMap/index.d.ts +0 -50
- package/dist/core/MiniMap/src/index.d.ts +0 -2
- package/dist/core/MiniMap/src/mini-map-config.d.ts +0 -112
- package/dist/core/MiniMap/src/mini-map.d.ts +0 -100
- package/dist/core/OrthoPerspectiveCamera/index.d.ts +0 -65
- package/dist/core/OrthoPerspectiveCamera/src/first-person-mode.d.ts +0 -16
- package/dist/core/OrthoPerspectiveCamera/src/index.d.ts +0 -5
- package/dist/core/OrthoPerspectiveCamera/src/orbit-mode.d.ts +0 -16
- package/dist/core/OrthoPerspectiveCamera/src/plan-mode.d.ts +0 -20
- package/dist/core/OrthoPerspectiveCamera/src/projections.d.ts +0 -45
- package/dist/core/OrthoPerspectiveCamera/src/types.d.ts +0 -26
- package/dist/core/Raycasters/index.d.ts +0 -43
- package/dist/core/Raycasters/src/index.d.ts +0 -2
- package/dist/core/Raycasters/src/mouse.d.ts +0 -24
- package/dist/core/Raycasters/src/simple-raycaster.d.ts +0 -54
- package/dist/core/ShadowedScene/index.d.ts +0 -57
- package/dist/core/ShadowedScene/src/distance-renderer.d.ts +0 -67
- package/dist/core/ShadowedScene/src/index.d.ts +0 -1
- package/dist/core/Types/index.d.ts +0 -1
- package/dist/core/Types/src/async-event.d.ts +0 -32
- package/dist/core/Types/src/base-camera.d.ts +0 -28
- package/dist/core/Types/src/base-renderer.d.ts +0 -65
- package/dist/core/Types/src/base-scene.d.ts +0 -25
- package/dist/core/Types/src/base-world-item.d.ts +0 -23
- package/dist/core/Types/src/base.d.ts +0 -19
- package/dist/core/Types/src/component-with-ui.d.ts +0 -18
- package/dist/core/Types/src/component.d.ts +0 -13
- package/dist/core/Types/src/config-types.d.ts +0 -47
- package/dist/core/Types/src/data-map.d.ts +0 -73
- package/dist/core/Types/src/data-set.d.ts +0 -58
- package/dist/core/Types/src/event-manager.d.ts +0 -30
- package/dist/core/Types/src/event.d.ts +0 -32
- package/dist/core/Types/src/index.d.ts +0 -15
- package/dist/core/Types/src/interfaces.d.ts +0 -117
- package/dist/core/Types/src/world.d.ts +0 -34
- package/dist/core/Viewpoints/index.d.ts +0 -38
- package/dist/core/Viewpoints/src/index.d.ts +0 -2
- package/dist/core/Viewpoints/src/types.d.ts +0 -36
- package/dist/core/Viewpoints/src/viewpoint.d.ts +0 -197
- package/dist/core/Viewpoints/src/viewpoints-config.d.ts +0 -23
- package/dist/core/Worlds/index.d.ts +0 -54
- package/dist/core/Worlds/src/index.d.ts +0 -5
- package/dist/core/Worlds/src/simple-camera.d.ts +0 -62
- package/dist/core/Worlds/src/simple-renderer.d.ts +0 -54
- package/dist/core/Worlds/src/simple-scene-config.d.ts +0 -59
- package/dist/core/Worlds/src/simple-scene.d.ts +0 -25
- package/dist/core/Worlds/src/simple-world.d.ts +0 -79
- package/dist/core/index.d.ts +0 -13
- package/dist/fragments/BoundingBoxer/index.d.ts +0 -208
- package/dist/fragments/Classifier/index.d.ts +0 -197
- package/dist/fragments/Exploder/index.d.ts +0 -50
- package/dist/fragments/FragmentsManager/index.d.ts +0 -152
- package/dist/fragments/Hider/index.d.ts +0 -38
- package/dist/fragments/IfcGeometryTiler/index.d.ts +0 -103
- package/dist/fragments/IfcGeometryTiler/src/base-types.d.ts +0 -29
- package/dist/fragments/IfcGeometryTiler/src/index.d.ts +0 -2
- package/dist/fragments/IfcGeometryTiler/src/streaming-settings.d.ts +0 -20
- package/dist/fragments/IfcLoader/index.d.ts +0 -116
- package/dist/fragments/IfcLoader/src/civil-reader.d.ts +0 -15
- package/dist/fragments/IfcLoader/src/ifc-fragment-settings.d.ts +0 -41
- package/dist/fragments/IfcLoader/src/ifc-metadata-reader.d.ts +0 -5
- package/dist/fragments/IfcLoader/src/index.d.ts +0 -5
- package/dist/fragments/IfcLoader/src/spatial-ids-finder.d.ts +0 -5
- package/dist/fragments/IfcLoader/src/spatial-structure.d.ts +0 -8
- package/dist/fragments/IfcLoader/src/transform-helper.d.ts +0 -5
- package/dist/fragments/IfcLoader/src/units.d.ts +0 -10
- package/dist/fragments/IfcPropertiesTiler/index.d.ts +0 -66
- package/dist/fragments/IfcPropertiesTiler/src/index.d.ts +0 -1
- package/dist/fragments/IfcPropertiesTiler/src/streaming-settings.d.ts +0 -11
- package/dist/fragments/index.d.ts +0 -8
- package/dist/ifc/IfcFinder/index.d.ts +0 -50
- package/dist/ifc/IfcFinder/src/ifc-basic-query.d.ts +0 -35
- package/dist/ifc/IfcFinder/src/ifc-finder-query.d.ts +0 -96
- package/dist/ifc/IfcFinder/src/ifc-property-query.d.ts +0 -36
- package/dist/ifc/IfcFinder/src/ifc-query-group.d.ts +0 -69
- package/dist/ifc/IfcFinder/src/index.d.ts +0 -4
- package/dist/ifc/IfcFinder/src/types.d.ts +0 -84
- package/dist/ifc/IfcIsolator/index.d.ts +0 -24
- package/dist/ifc/IfcJsonExporter/index.d.ts +0 -26
- package/dist/ifc/IfcJsonExporter/src/ifc-geometry-types.d.ts +0 -4
- package/dist/ifc/IfcJsonExporter/src/index.d.ts +0 -1
- package/dist/ifc/IfcPropertiesManager/index.d.ts +0 -289
- package/dist/ifc/IfcPropertiesManager/src/index.d.ts +0 -3
- package/dist/ifc/IfcPropertiesManager/src/rel-attrs.d.ts +0 -7
- package/dist/ifc/IfcPropertiesManager/src/rel-names.d.ts +0 -3
- package/dist/ifc/IfcPropertiesManager/src/types.d.ts +0 -18
- package/dist/ifc/IfcRelationsIndexer/index.d.ts +0 -195
- package/dist/ifc/IfcRelationsIndexer/src/index.d.ts +0 -2
- package/dist/ifc/IfcRelationsIndexer/src/newVersion.d.ts +0 -51
- package/dist/ifc/IfcRelationsIndexer/src/relToAttributesMap.d.ts +0 -5
- package/dist/ifc/IfcRelationsIndexer/src/types.d.ts +0 -73
- package/dist/ifc/Utils/ifc-categories.d.ts +0 -7
- package/dist/ifc/Utils/ifc-category-case.d.ts +0 -3
- package/dist/ifc/Utils/ifc-category-map.d.ts +0 -6
- package/dist/ifc/Utils/ifc-elements-map.d.ts +0 -11
- package/dist/ifc/Utils/index.d.ts +0 -5
- package/dist/ifc/Utils/properties-utils.d.ts +0 -25
- package/dist/ifc/index.d.ts +0 -6
- package/dist/measurement/MeasurementUtils/index.d.ts +0 -105
- package/dist/measurement/index.d.ts +0 -1
- package/dist/namespace.d.ts +0 -6018
- package/dist/openbim/BCFTopics/index.d.ts +0 -114
- package/dist/openbim/BCFTopics/src/Comment.d.ts +0 -40
- package/dist/openbim/BCFTopics/src/Topic.d.ts +0 -127
- package/dist/openbim/BCFTopics/src/bcf-topics-config.d.ts +0 -121
- package/dist/openbim/BCFTopics/src/importers/extensions.d.ts +0 -2
- package/dist/openbim/BCFTopics/src/importers/index.d.ts +0 -1
- package/dist/openbim/BCFTopics/src/index.d.ts +0 -5
- package/dist/openbim/BCFTopics/src/types.d.ts +0 -19
- package/dist/openbim/IDSSpecifications/index.d.ts +0 -60
- package/dist/openbim/IDSSpecifications/src/Specification.d.ts +0 -40
- package/dist/openbim/IDSSpecifications/src/exporters/parameter.d.ts +0 -2
- package/dist/openbim/IDSSpecifications/src/facets/Attribute.d.ts +0 -13
- package/dist/openbim/IDSSpecifications/src/facets/Classification.d.ts +0 -21
- package/dist/openbim/IDSSpecifications/src/facets/Entity.d.ts +0 -15
- package/dist/openbim/IDSSpecifications/src/facets/Facet.d.ts +0 -26
- package/dist/openbim/IDSSpecifications/src/facets/Material.d.ts +0 -10
- package/dist/openbim/IDSSpecifications/src/facets/PartOf.d.ts +0 -26
- package/dist/openbim/IDSSpecifications/src/facets/Property.d.ts +0 -25
- package/dist/openbim/IDSSpecifications/src/facets/index.d.ts +0 -5
- package/dist/openbim/IDSSpecifications/src/importers/attribute.d.ts +0 -3
- package/dist/openbim/IDSSpecifications/src/importers/classification.d.ts +0 -3
- package/dist/openbim/IDSSpecifications/src/importers/entity.d.ts +0 -3
- package/dist/openbim/IDSSpecifications/src/importers/index.d.ts +0 -3
- package/dist/openbim/IDSSpecifications/src/importers/parameter.d.ts +0 -2
- package/dist/openbim/IDSSpecifications/src/importers/property.d.ts +0 -3
- package/dist/openbim/IDSSpecifications/src/index.d.ts +0 -3
- package/dist/openbim/IDSSpecifications/src/types.d.ts +0 -70
- package/dist/openbim/index.d.ts +0 -2
- package/dist/utils/bbox.d.ts +0 -7
- package/dist/utils/geometry.d.ts +0 -1
- package/dist/utils/index.d.ts +0 -6
- package/dist/utils/materials.d.ts +0 -4
- package/dist/utils/section-generator.d.ts +0 -31
- package/dist/utils/uuid.d.ts +0 -6
- package/dist/utils/vertex-picker.d.ts +0 -116
package/dist/index.min.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
var e=Object.defineProperty,t=(t,i,s)=>(((t,i,s)=>{i in t?e(t,i,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[i]=s})(t,"symbol"!=typeof i?i+"":i,s),s);import*as i from"three";import{BufferAttribute as s,Vector3 as n,Vector2 as r,Plane as o,Line3 as a,Triangle as c,Sphere as l,Matrix4 as h,Box3 as u,BackSide as I,DoubleSide as d,FrontSide as E,Mesh as f,Ray as p,Raycaster as C,Quaternion as T,Controls as m,Euler as R,Object3D as g,MeshBasicMaterial as A,LineBasicMaterial as F,CylinderGeometry as S,BoxGeometry as O,BufferGeometry as N,Float32BufferAttribute as y,OctahedronGeometry as _,Line as L,SphereGeometry as P,TorusGeometry as w,PlaneGeometry as v}from"three";import*as M from"@thatopen/fragments";import{FragmentsGroup as D,Serializer as b}from"@thatopen/fragments";import*as x from"web-ifc";const U=1.25,B=65535,V=Math.pow(2,-24),Y=Symbol("SKIP_GENERATION");function G(e){return function(e){return e.index?e.index.count:e.attributes.position.count}(e)/3}function z(e,t){if(!e.index){const i=e.attributes.position.count,n=function(e,t=ArrayBuffer){return e>65535?new Uint32Array(new t(4*e)):new Uint16Array(new t(2*e))}(i,t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer);e.setIndex(new s(n,1));for(let e=0;e<i;e++)n[e]=e}}function k(e){const t=G(e),i=e.drawRange,s=i.start/3,n=(i.start+i.count)/3,r=Math.max(0,s),o=Math.min(t,n)-r;return[{offset:Math.floor(r),count:Math.floor(o)}]}function H(e){if(!e.groups||!e.groups.length)return k(e);const t=[],i=new Set,s=e.drawRange,n=s.start/3,r=(s.start+s.count)/3;for(const t of e.groups){const e=t.start/3,s=(t.start+t.count)/3;i.add(Math.max(n,e)),i.add(Math.min(r,s))}const o=Array.from(i.values()).sort(((e,t)=>e-t));for(let e=0;e<o.length-1;e++){const i=o[e],s=o[e+1];t.push({offset:Math.floor(i),count:Math.floor(s-i)})}return t}function W(e,t,i){return i.min.x=t[e],i.min.y=t[e+1],i.min.z=t[e+2],i.max.x=t[e+3],i.max.y=t[e+4],i.max.z=t[e+5],i}function X(e){let t=-1,i=-1/0;for(let s=0;s<3;s++){const n=e[s+3]-e[s];n>i&&(i=n,t=s)}return t}function Z(e,t){t.set(e)}function $(e,t,i){let s,n;for(let r=0;r<3;r++){const o=r+3;s=e[r],n=t[r],i[r]=s<n?s:n,s=e[o],n=t[o],i[o]=s>n?s:n}}function j(e,t,i){for(let s=0;s<3;s++){const n=t[e+2*s],r=t[e+2*s+1],o=n-r,a=n+r;o<i[s]&&(i[s]=o),a>i[s+3]&&(i[s+3]=a)}}function q(e){const t=e[3]-e[0],i=e[4]-e[1],s=e[5]-e[2];return 2*(t*i+i*s+s*t)}function Q(e,t,i,s,n=null){let r=1/0,o=1/0,a=1/0,c=-1/0,l=-1/0,h=-1/0,u=1/0,I=1/0,d=1/0,E=-1/0,f=-1/0,p=-1/0;const C=null!==n;for(let s=6*t,n=6*(t+i);s<n;s+=6){const t=e[s+0],i=e[s+1],n=t-i,T=t+i;n<r&&(r=n),T>c&&(c=T),C&&t<u&&(u=t),C&&t>E&&(E=t);const m=e[s+2],R=e[s+3],g=m-R,A=m+R;g<o&&(o=g),A>l&&(l=A),C&&m<I&&(I=m),C&&m>f&&(f=m);const F=e[s+4],S=e[s+5],O=F-S,N=F+S;O<a&&(a=O),N>h&&(h=N),C&&F<d&&(d=F),C&&F>p&&(p=F)}s[0]=r,s[1]=o,s[2]=a,s[3]=c,s[4]=l,s[5]=h,C&&(n[0]=u,n[1]=I,n[2]=d,n[3]=E,n[4]=f,n[5]=p)}const K=32,J=(e,t)=>e.candidate-t.candidate,ee=new Array(K).fill().map((()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0}))),te=new Float32Array(6);class ie{constructor(){}}function se(e,t,i,s,n,r){let o=s,a=s+n-1;const c=r.pos,l=2*r.axis;for(;;){for(;o<=a&&i[6*o+l]<c;)o++;for(;o<=a&&i[6*a+l]>=c;)a--;if(!(o<a))return o;for(let e=0;e<3;e++){let i=t[3*o+e];t[3*o+e]=t[3*a+e],t[3*a+e]=i}for(let e=0;e<6;e++){let t=i[6*o+e];i[6*o+e]=i[6*a+e],i[6*a+e]=t}o++,a--}}function ne(e,t,i,s,n,r){let o=s,a=s+n-1;const c=r.pos,l=2*r.axis;for(;;){for(;o<=a&&i[6*o+l]<c;)o++;for(;o<=a&&i[6*a+l]>=c;)a--;if(!(o<a))return o;{let t=e[o];e[o]=e[a],e[a]=t;for(let e=0;e<6;e++){let t=i[6*o+e];i[6*o+e]=i[6*a+e],i[6*a+e]=t}o++,a--}}}function re(e,t){const i=e.geometry,s=i.index?i.index.array:null,n=t.maxDepth,r=t.verbose,o=t.maxLeafTris,a=t.strategy,c=t.onProgress,l=G(i),h=e._indirectBuffer;let u=!1;const I=new Float32Array(6),d=new Float32Array(6),E=function(e,t){var i;(i=t)[0]=i[1]=i[2]=1/0,i[3]=i[4]=i[5]=-1/0;const s=e.attributes.position,n=e.index?e.index.array:null,r=G(e),o=new Float32Array(6*r),a=s.normalized,c=s.array,l=s.offset||0;let h=3;s.isInterleavedBufferAttribute&&(h=s.data.stride);const u=["getX","getY","getZ"];for(let e=0;e<r;e++){const i=3*e,r=6*e;let I=i+0,d=i+1,E=i+2;n&&(I=n[I],d=n[d],E=n[E]),a||(I=I*h+l,d=d*h+l,E=E*h+l);for(let e=0;e<3;e++){let i,n,l;a?(i=s[u[e]](I),n=s[u[e]](d),l=s[u[e]](E)):(i=c[I+e],n=c[d+e],l=c[E+e]);let h=i;n<h&&(h=n),l<h&&(h=l);let f=i;n>f&&(f=n),l>f&&(f=l);const p=(f-h)/2,C=2*e;o[r+C+0]=h+p,o[r+C+1]=p+(Math.abs(h)+p)*V,h<t[e]&&(t[e]=h),f>t[e+3]&&(t[e+3]=f)}}return o}(i,I),f=t.indirect?ne:se,p=[],C=t.indirect?k(i):H(i);if(1===C.length){const e=C[0],t=new ie;t.boundingData=I,function(e,t,i,s){let n=1/0,r=1/0,o=1/0,a=-1/0,c=-1/0,l=-1/0;for(let s=6*t,h=6*(t+i);s<h;s+=6){const t=e[s+0];t<n&&(n=t),t>a&&(a=t);const i=e[s+2];i<r&&(r=i),i>c&&(c=i);const h=e[s+4];h<o&&(o=h),h>l&&(l=h)}s[0]=n,s[1]=r,s[2]=o,s[3]=a,s[4]=c,s[5]=l}(E,e.offset,e.count,d),m(t,e.offset,e.count,d),p.push(t)}else for(let e of C){const t=new ie;t.boundingData=new Float32Array(6),Q(E,e.offset,e.count,t.boundingData,d),m(t,e.offset,e.count,d),p.push(t)}return p;function T(e){c&&c(e/l)}function m(e,t,c,l=null,I=0){if(!u&&I>=n&&(u=!0,r&&(console.warn(`MeshBVH: Max depth of ${n} reached when generating BVH. Consider increasing maxDepth.`),console.warn(i))),c<=o||I>=n)return T(t+c),e.offset=t,e.count=c,e;const p=function(e,t,i,s,n,r){let o=-1,a=0;if(0===r)o=X(t),-1!==o&&(a=(t[o]+t[o+3])/2);else if(1===r)o=X(e),-1!==o&&(a=function(e,t,i,s){let n=0;for(let r=t,o=t+i;r<o;r++)n+=e[6*r+2*s];return n/i}(i,s,n,o));else if(2===r){const r=q(e);let c=U*n;const l=6*s,h=6*(s+n);for(let e=0;e<3;e++){const s=t[e],u=(t[e+3]-s)/K;if(n<8){const t=[...ee];t.length=n;let s=0;for(let n=l;n<h;n+=6,s++){const r=t[s];r.candidate=i[n+2*e],r.count=0;const{bounds:o,leftCacheBounds:a,rightCacheBounds:c}=r;for(let e=0;e<3;e++)c[e]=1/0,c[e+3]=-1/0,a[e]=1/0,a[e+3]=-1/0,o[e]=1/0,o[e+3]=-1/0;j(n,i,o)}t.sort(J);let u=n;for(let e=0;e<u;e++){const i=t[e];for(;e+1<u&&t[e+1].candidate===i.candidate;)t.splice(e+1,1),u--}for(let s=l;s<h;s+=6){const n=i[s+2*e];for(let e=0;e<u;e++){const r=t[e];n>=r.candidate?j(s,i,r.rightCacheBounds):(j(s,i,r.leftCacheBounds),r.count++)}}for(let i=0;i<u;i++){const s=t[i],l=s.count,h=n-s.count,u=s.leftCacheBounds,I=s.rightCacheBounds;let d=0;0!==l&&(d=q(u)/r);let E=0;0!==h&&(E=q(I)/r);const f=1+U*(d*l+E*h);f<c&&(o=e,c=f,a=s.candidate)}}else{for(let e=0;e<K;e++){const t=ee[e];t.count=0,t.candidate=s+u+e*u;const i=t.bounds;for(let e=0;e<3;e++)i[e]=1/0,i[e+3]=-1/0}for(let t=l;t<h;t+=6){let n=~~((i[t+2*e]-s)/u);n>=K&&(n=31);const r=ee[n];r.count++,j(t,i,r.bounds)}const t=ee[31];Z(t.bounds,t.rightCacheBounds);for(let e=30;e>=0;e--){const t=ee[e],i=ee[e+1];$(t.bounds,i.rightCacheBounds,t.rightCacheBounds)}let I=0;for(let t=0;t<31;t++){const i=ee[t],s=i.count,l=i.bounds,h=ee[t+1].rightCacheBounds;0!==s&&(0===I?Z(l,te):$(l,te,te)),I+=s;let u=0,d=0;0!==I&&(u=q(te)/r);const E=n-I;0!==E&&(d=q(h)/r);const f=1+U*(u*I+d*E);f<c&&(o=e,c=f,a=i.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${r} used.`);return{axis:o,pos:a}}(e.boundingData,l,E,t,c,a);if(-1===p.axis)return T(t+c),e.offset=t,e.count=c,e;const C=f(h,s,E,t,c,p);if(C===t||C===t+c)T(t+c),e.offset=t,e.count=c;else{e.splitAxis=p.axis;const i=new ie,s=t,n=C-t;e.left=i,i.boundingData=new Float32Array(6),Q(E,s,n,i.boundingData,d),m(i,s,n,d,I+1);const r=new ie,o=C,a=c-n;e.right=r,r.boundingData=new Float32Array(6),Q(E,o,a,r.boundingData,d),m(r,o,a,d,I+1)}return e}}function oe(e,t){const i=e.geometry;t.indirect&&(e._indirectBuffer=function(e,t){const i=(e.index?e.index.count:e.attributes.position.count)/3,s=i>65536,n=s?4:2,r=t?new SharedArrayBuffer(i*n):new ArrayBuffer(i*n),o=s?new Uint32Array(r):new Uint16Array(r);for(let e=0,t=o.length;e<t;e++)o[e]=e;return o}(i,t.useSharedArrayBuffer),function(e){if(0===e.groups.length)return!1;const t=G(e),i=H(e).sort(((e,t)=>e.offset-t.offset)),s=i[i.length-1];s.count=Math.min(t-s.offset,s.count);let n=0;return i.forEach((({count:e})=>n+=e)),t!==n}(i)&&!t.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.')),e._indirectBuffer||z(i,t);const s=re(e,t);let n,r,o;const a=[],c=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;for(let e=0;e<s.length;e++){const t=s[e];const i=new c(32*l(t));n=new Float32Array(i),r=new Uint32Array(i),o=new Uint16Array(i),h(0,t),a.push(i)}return void(e._roots=a);function l(e){return e.count?1:1+l(e.left)+l(e.right)}function h(e,t){const i=e/4,s=e/2,a=!!t.count,c=t.boundingData;for(let e=0;e<6;e++)n[i+e]=c[e];if(a){const n=t.offset,a=t.count;return r[i+6]=n,o[s+14]=a,o[s+15]=B,e+32}{const s=t.left,n=t.right,o=t.splitAxis;let a;if(a=h(e+32,s),a/4>Math.pow(2,32))throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return r[i+6]=a/4,a=h(a,n),r[i+7]=o,a}}}class ae{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 r=e[n][t];i=r<i?r:i,s=r>s?r: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 r=t[n],o=e.dot(r);i=o<i?o:i,s=o>s?o:s}this.min=i,this.max=s}isSeparated(e){return this.min>e.max||e.min>this.max}}ae.prototype.setFromBox=function(){const e=new n;return function(t,i){const s=i.min,n=i.max;let r=1/0,o=-1/0;for(let i=0;i<=1;i++)for(let a=0;a<=1;a++)for(let c=0;c<=1;c++){e.x=s.x*i+n.x*(1-i),e.y=s.y*a+n.y*(1-a),e.z=s.z*c+n.z*(1-c);const l=t.dot(e);r=Math.min(l,r),o=Math.max(l,o)}this.min=r,this.max=o}}();const ce=function(){const e=new n,t=new n,i=new n;return function(s,n,r){const o=s.start,a=e,c=n.start,l=t;i.subVectors(o,c),e.subVectors(s.end,s.start),t.subVectors(n.end,n.start);const h=i.dot(l),u=l.dot(a),I=l.dot(l),d=i.dot(a),E=a.dot(a)*I-u*u;let f,p;f=0!==E?(h*u-d*I)/E:0,p=(h+f*u)/I,r.x=f,r.y=p}}(),le=function(){const e=new r,t=new n,i=new n;return function(s,n,r,o){ce(s,n,e);let a=e.x,c=e.y;if(a>=0&&a<=1&&c>=0&&c<=1)return s.at(a,r),void n.at(c,o);if(a>=0&&a<=1)return c<0?n.at(0,o):n.at(1,o),void s.closestPointToPoint(o,!0,r);if(c>=0&&c<=1)return a<0?s.at(0,r):s.at(1,r),void n.closestPointToPoint(r,!0,o);{let e,l;e=a<0?s.start:s.end,l=c<0?n.start:n.end;const h=t,u=i;return s.closestPointToPoint(l,!0,t),n.closestPointToPoint(e,!0,i),h.distanceToSquared(l)<=u.distanceToSquared(e)?(r.copy(h),void o.copy(l)):(r.copy(e),void o.copy(u))}}}(),he=function(){const e=new n,t=new n,i=new o,s=new a;return function(n,r){const{radius:o,center:a}=n,{a:c,b:l,c:h}=r;s.start=c,s.end=l;if(s.closestPointToPoint(a,!0,e).distanceTo(a)<=o)return!0;s.start=c,s.end=h;if(s.closestPointToPoint(a,!0,e).distanceTo(a)<=o)return!0;s.start=l,s.end=h;if(s.closestPointToPoint(a,!0,e).distanceTo(a)<=o)return!0;const u=r.getPlane(i);if(Math.abs(u.distanceToPoint(a))<=o){const e=u.projectPoint(a,t);if(r.containsPoint(e))return!0}return!1}}();function ue(e){return Math.abs(e)<1e-15}class Ie extends c{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map((()=>new n)),this.satBounds=new Array(4).fill().map((()=>new ae)),this.points=[this.a,this.b,this.c],this.sphere=new l,this.plane=new o,this.needsUpdate=!0}intersectsSphere(e){return he(e,this)}update(){const e=this.a,t=this.b,i=this.c,s=this.points,n=this.satAxes,r=this.satBounds,o=n[0],a=r[0];this.getNormal(o),a.setFromPoints(o,s);const c=n[1],l=r[1];c.subVectors(e,t),l.setFromPoints(c,s);const h=n[2],u=r[2];h.subVectors(t,i),u.setFromPoints(h,s);const I=n[3],d=r[3];I.subVectors(i,e),d.setFromPoints(I,s),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(o,e),this.needsUpdate=!1}}Ie.prototype.closestPointToSegment=function(){const e=new n,t=new n,i=new a;return function(s,n=null,r=null){const{start:o,end:a}=s,c=this.points;let l,h=1/0;for(let o=0;o<3;o++){const a=(o+1)%3;i.start.copy(c[o]),i.end.copy(c[a]),le(i,s,e,t),l=e.distanceToSquared(t),l<h&&(h=l,n&&n.copy(e),r&&r.copy(t))}return this.closestPointToPoint(o,e),l=o.distanceToSquared(e),l<h&&(h=l,n&&n.copy(e),r&&r.copy(o)),this.closestPointToPoint(a,e),l=a.distanceToSquared(e),l<h&&(h=l,n&&n.copy(e),r&&r.copy(a)),Math.sqrt(h)}}(),Ie.prototype.intersectsTriangle=function(){const e=new Ie,t=new Array(3),i=new Array(3),s=new ae,r=new ae,o=new n,c=new n,l=new n,h=new n,u=new n,I=new a,d=new a,E=new a,f=new n;function p(e,t,i){const s=e.points;let n=0,r=-1;for(let e=0;e<3;e++){const{start:o,end:a}=I;o.copy(s[e]),a.copy(s[(e+1)%3]),I.delta(c);const l=ue(t.distanceToPoint(o));if(ue(t.normal.dot(c))&&l){i.copy(I),n=2;break}const h=t.intersectLine(I,f);if(!h&&l&&f.copy(o),(h||l)&&!ue(f.distanceTo(a))){if(n<=1){(1===n?i.start:i.end).copy(f),l&&(r=n)}else if(n>=2){(1===r?i.start:i.end).copy(f),n=2;break}if(n++,2===n&&-1===r)break}}return n}return function(n,a=null,c=!1){this.needsUpdate&&this.update(),n.isExtendedTriangle?n.needsUpdate&&n.update():(e.copy(n),e.update(),n=e);const I=this.plane,f=n.plane;if(Math.abs(I.normal.dot(f.normal))>1-1e-10){const e=this.satBounds,l=this.satAxes;i[0]=n.a,i[1]=n.b,i[2]=n.c;for(let t=0;t<4;t++){const n=e[t],r=l[t];if(s.setFromPoints(r,i),n.isSeparated(s))return!1}const h=n.satBounds,u=n.satAxes;t[0]=this.a,t[1]=this.b,t[2]=this.c;for(let e=0;e<4;e++){const i=h[e],n=u[e];if(s.setFromPoints(n,t),i.isSeparated(s))return!1}for(let e=0;e<4;e++){const n=l[e];for(let e=0;e<4;e++){const a=u[e];if(o.crossVectors(n,a),s.setFromPoints(o,t),r.setFromPoints(o,i),s.isSeparated(r))return!1}}return a&&(c||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),a.start.set(0,0,0),a.end.set(0,0,0)),!0}{const e=p(this,f,d);if(1===e&&n.containsPoint(d.end))return a&&(a.start.copy(d.end),a.end.copy(d.end)),!0;if(2!==e)return!1;const t=p(n,I,E);if(1===t&&this.containsPoint(E.end))return a&&(a.start.copy(E.end),a.end.copy(E.end)),!0;if(2!==t)return!1;if(d.delta(l),E.delta(h),l.dot(h)<0){let e=E.start;E.start=E.end,E.end=e}const i=d.start.dot(l),s=d.end.dot(l),r=E.start.dot(l),o=E.end.dot(l);return(i===o||r===s||s<r!==i<o)&&(a&&(u.subVectors(d.start,E.start),u.dot(l)>0?a.start.copy(d.start):a.start.copy(E.start),u.subVectors(d.end,E.end),u.dot(l)<0?a.end.copy(d.end):a.end.copy(E.end)),!0)}}}(),Ie.prototype.distanceToPoint=function(){const e=new n;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}(),Ie.prototype.distanceToTriangle=function(){const e=new n,t=new n,i=["a","b","c"],s=new a,r=new a;return function(n,o=null,a=null){const c=o||a?s:null;if(this.intersectsTriangle(n,c))return(o||a)&&(o&&c.getCenter(o),a&&c.getCenter(a)),0;let l=1/0;for(let t=0;t<3;t++){let s;const r=i[t],c=n[r];this.closestPointToPoint(c,e),s=c.distanceToSquared(e),s<l&&(l=s,o&&o.copy(e),a&&a.copy(c));const h=this[r];n.closestPointToPoint(h,e),s=h.distanceToSquared(e),s<l&&(l=s,o&&o.copy(h),a&&a.copy(e))}for(let c=0;c<3;c++){const h=i[c],u=i[(c+1)%3];s.set(this[h],this[u]);for(let c=0;c<3;c++){const h=i[c],u=i[(c+1)%3];r.set(n[h],n[u]),le(s,r,e,t);const I=e.distanceToSquared(t);I<l&&(l=I,o&&o.copy(e),a&&a.copy(t))}}return Math.sqrt(l)}}();class de{constructor(e,t,i){this.isOrientedBox=!0,this.min=new n,this.max=new n,this.matrix=new h,this.invMatrix=new h,this.points=new Array(8).fill().map((()=>new n)),this.satAxes=new Array(3).fill().map((()=>new n)),this.satBounds=new Array(3).fill().map((()=>new ae)),this.alignedSatBounds=new Array(3).fill().map((()=>new ae)),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}}de.prototype.update=function(){return function(){const e=this.matrix,t=this.min,i=this.max,s=this.points;for(let n=0;n<=1;n++)for(let r=0;r<=1;r++)for(let o=0;o<=1;o++){const a=s[1*n|2*r|4*o];a.x=n?i.x:t.x,a.y=r?i.y:t.y,a.z=o?i.z:t.z,a.applyMatrix4(e)}const n=this.satBounds,r=this.satAxes,o=s[0];for(let e=0;e<3;e++){const t=r[e],i=n[e],a=s[1<<e];t.subVectors(o,a),i.setFromPoints(t,s)}const a=this.alignedSatBounds;a[0].setFromPointsField(s,"x"),a[1].setFromPointsField(s,"y"),a[2].setFromPointsField(s,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}(),de.prototype.intersectsBox=function(){const e=new ae;return function(t){this.needsUpdate&&this.update();const i=t.min,s=t.max,n=this.satBounds,r=this.satAxes,o=this.alignedSatBounds;if(e.min=i.x,e.max=s.x,o[0].isSeparated(e))return!1;if(e.min=i.y,e.max=s.y,o[1].isSeparated(e))return!1;if(e.min=i.z,e.max=s.z,o[2].isSeparated(e))return!1;for(let i=0;i<3;i++){const s=r[i],o=n[i];if(e.setFromBox(s,t),o.isSeparated(e))return!1}return!0}}(),de.prototype.intersectsTriangle=function(){const e=new Ie,t=new Array(3),i=new ae,s=new ae,r=new n;return function(n){this.needsUpdate&&this.update(),n.isExtendedTriangle?n.needsUpdate&&n.update():(e.copy(n),e.update(),n=e);const o=this.satBounds,a=this.satAxes;t[0]=n.a,t[1]=n.b,t[2]=n.c;for(let e=0;e<3;e++){const s=o[e],n=a[e];if(i.setFromPoints(n,t),s.isSeparated(i))return!1}const c=n.satBounds,l=n.satAxes,h=this.points;for(let e=0;e<3;e++){const t=c[e],s=l[e];if(i.setFromPoints(s,h),t.isSeparated(i))return!1}for(let e=0;e<3;e++){const n=a[e];for(let e=0;e<4;e++){const o=l[e];if(r.crossVectors(n,o),i.setFromPoints(r,t),s.setFromPoints(r,h),i.isSeparated(s))return!1}}return!0}}(),de.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}}(),de.prototype.distanceToPoint=function(){const e=new n;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}(),de.prototype.distanceToBox=function(){const e=["x","y","z"],t=new Array(12).fill().map((()=>new a)),i=new Array(12).fill().map((()=>new a)),s=new n,r=new n;return function(n,o=0,a=null,c=null){if(this.needsUpdate&&this.update(),this.intersectsBox(n))return(a||c)&&(n.getCenter(r),this.closestPointToPoint(r,s),n.closestPointToPoint(s,r),a&&a.copy(s),c&&c.copy(r)),0;const l=o*o,h=n.min,u=n.max,I=this.points;let d=1/0;for(let e=0;e<8;e++){const t=I[e];r.copy(t).clamp(h,u);const i=t.distanceToSquared(r);if(i<d&&(d=i,a&&a.copy(t),c&&c.copy(r),i<l))return Math.sqrt(i)}let E=0;for(let s=0;s<3;s++)for(let n=0;n<=1;n++)for(let r=0;r<=1;r++){const o=(s+1)%3,a=(s+2)%3,c=1<<s|n<<o|r<<a,l=I[n<<o|r<<a],d=I[c];t[E].set(l,d);const f=e[s],p=e[o],C=e[a],T=i[E],m=T.start,R=T.end;m[f]=h[f],m[p]=n?h[p]:u[p],m[C]=r?h[C]:u[p],R[f]=u[f],R[p]=n?h[p]:u[p],R[C]=r?h[C]:u[p],E++}for(let e=0;e<=1;e++)for(let t=0;t<=1;t++)for(let i=0;i<=1;i++){r.x=e?u.x:h.x,r.y=t?u.y:h.y,r.z=i?u.z:h.z,this.closestPointToPoint(r,s);const n=r.distanceToSquared(s);if(n<d&&(d=n,a&&a.copy(s),c&&c.copy(r),n<l))return Math.sqrt(n)}for(let e=0;e<12;e++){const n=t[e];for(let e=0;e<12;e++){const t=i[e];le(n,t,s,r);const o=s.distanceToSquared(r);if(o<d&&(d=o,a&&a.copy(s),c&&c.copy(r),o<l))return Math.sqrt(o)}}return Math.sqrt(d)}}();class Ee{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 fe extends Ee{constructor(){super((()=>new Ie))}}const pe=new fe;function Ce(e,t){return 65535===t[e+15]}function Te(e,t){return t[e+6]}function me(e,t){return t[e+14]}function Re(e){return e+8}function ge(e,t){return t[e+6]}function Ae(e,t){return t[e+7]}const Fe=new class{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 Se,Oe;const Ne=[],ye=new Ee((()=>new u));function _e(e,t,i,s,n,r){Se=ye.getPrimitive(),Oe=ye.getPrimitive(),Ne.push(Se,Oe),Fe.setBuffer(e._roots[t]);const o=Le(0,e.geometry,i,s,n,r);Fe.clearBuffer(),ye.releasePrimitive(Se),ye.releasePrimitive(Oe),Ne.pop(),Ne.pop();const a=Ne.length;return a>0&&(Oe=Ne[a-1],Se=Ne[a-2]),o}function Le(e,t,i,s,n=null,r=0,o=0){const{float32Array:a,uint16Array:c,uint32Array:l}=Fe;let h=2*e;if(Ce(h,c)){const t=Te(e,l),i=me(h,c);return W(e,a,Se),s(t,i,!1,o,r+e,Se)}{let h=function(e){const{uint16Array:t,uint32Array:i}=Fe;let s=2*e;for(;!Ce(s,t);)s=2*(e=Re(e));return Te(e,i)},u=function(e){const{uint16Array:t,uint32Array:i}=Fe;let s=2*e;for(;!Ce(s,t);)s=2*(e=ge(e,i));return Te(e,i)+me(s,t)};const I=Re(e),d=ge(e,l);let E,f,p,C,T=I,m=d;if(n&&(p=Se,C=Oe,W(T,a,p),W(m,a,C),E=n(p),f=n(C),f<E)){T=d,m=I;const e=E;E=f,f=e,p=C}p||(p=Se,W(T,a,p));const R=i(p,Ce(2*T,c),E,o+1,r+T);let g;if(2===R){const e=h(T);g=s(e,u(T)-e,!0,o+1,r+T,p)}else g=R&&Le(T,t,i,s,n,r,o+1);if(g)return!0;C=Oe,W(m,a,C);const A=i(C,Ce(2*m,c),f,o+1,r+m);let F;if(2===A){const e=h(m);F=s(e,u(m)-e,!0,o+1,r+m,C)}else F=A&&Le(m,t,i,s,n,r,o+1);return!!F}}const Pe=new n,we=new n;const ve=new n,Me=new n,De=new n,be=new r,xe=new r,Ue=new r,Be=new n,Ve=new n,Ye=new n,Ge=new n;function ze(e,t,i,s,o,a,l,h,u){ve.fromBufferAttribute(t,a),Me.fromBufferAttribute(t,l),De.fromBufferAttribute(t,h);const E=function(e,t,i,s,n,r){let o;return o=r===I?e.intersectTriangle(s,i,t,!0,n):e.intersectTriangle(t,i,s,r!==d,n),null===o?null:{distance:e.origin.distanceTo(n),point:n.clone()}}(e,ve,Me,De,Ge,u);if(E){s&&(be.fromBufferAttribute(s,a),xe.fromBufferAttribute(s,l),Ue.fromBufferAttribute(s,h),E.uv=c.getInterpolation(Ge,ve,Me,De,be,xe,Ue,new r)),o&&(be.fromBufferAttribute(o,a),xe.fromBufferAttribute(o,l),Ue.fromBufferAttribute(o,h),E.uv1=c.getInterpolation(Ge,ve,Me,De,be,xe,Ue,new r)),i&&(Be.fromBufferAttribute(i,a),Ve.fromBufferAttribute(i,l),Ye.fromBufferAttribute(i,h),E.normal=c.getInterpolation(Ge,ve,Me,De,Be,Ve,Ye,new n),E.normal.dot(e.direction)>0&&E.normal.multiplyScalar(-1));const t={a:a,b:l,c:h,normal:new n,materialIndex:0};c.getNormal(ve,Me,De,t.normal),E.face=t,E.faceIndex=a}return E}function ke(e,t,i,s,n){const r=3*s;let o=r+0,a=r+1,c=r+2;const l=e.index;e.index&&(o=l.getX(o),a=l.getX(a),c=l.getX(c));const{position:h,normal:u,uv:I,uv1:d}=e.attributes,E=ze(i,h,u,I,d,o,a,c,t);return E?(E.faceIndex=s,n&&n.push(E),E):null}function He(e,t,i,s){const n=e.a,r=e.b,o=e.c;let a=t,c=t+1,l=t+2;i&&(a=i.getX(a),c=i.getX(c),l=i.getX(l)),n.x=s.getX(a),n.y=s.getY(a),n.z=s.getZ(a),r.x=s.getX(c),r.y=s.getY(c),r.z=s.getZ(c),o.x=s.getX(l),o.y=s.getY(l),o.z=s.getZ(l)}function We(e,t,i,s,n,r,o){const{geometry:a}=i,{index:c}=a,l=a.attributes.position;for(let i=e,a=t+e;i<a;i++){let e;if(e=i,He(o,3*e,c,l),o.needsUpdate=!0,s(o,e,n,r))return!0}return!1}function Xe(e,t=null){t&&Array.isArray(t)&&(t=new Set(t));const i=e.geometry,s=i.index?i.index.array:null,n=i.attributes.position;let r,o,a,c,l=0;const h=e._roots;for(let e=0,t=h.length;e<t;e++)r=h[e],o=new Uint32Array(r),a=new Uint16Array(r),c=new Float32Array(r),u(0,l),l+=r.byteLength;function u(e,i,r=!1){const l=2*e;if(a[l+15]===B){const t=o[e+6];let i=1/0,r=1/0,h=1/0,u=-1/0,I=-1/0,d=-1/0;for(let e=3*t,o=3*(t+a[l+14]);e<o;e++){let t=s[e];const o=n.getX(t),a=n.getY(t),c=n.getZ(t);o<i&&(i=o),o>u&&(u=o),a<r&&(r=a),a>I&&(I=a),c<h&&(h=c),c>d&&(d=c)}return(c[e+0]!==i||c[e+1]!==r||c[e+2]!==h||c[e+3]!==u||c[e+4]!==I||c[e+5]!==d)&&(c[e+0]=i,c[e+1]=r,c[e+2]=h,c[e+3]=u,c[e+4]=I,c[e+5]=d,!0)}{const s=e+8,n=o[e+6],a=s+i,l=n+i;let h=r,I=!1,d=!1;t?h||(I=t.has(a),d=t.has(l),h=!I&&!d):(I=!0,d=!0);const E=h||d;let f=!1;(h||I)&&(f=u(s,i,h));let p=!1;E&&(p=u(n,i,h));const C=f||p;if(C)for(let t=0;t<3;t++){const i=s+t,r=n+t,o=c[i],a=c[i+3],l=c[r],h=c[r+3];c[e+t]=o<l?o:l,c[e+t+3]=a>h?a:h}return C}}}const Ze=new u;function $e(e,t,i,s){return W(e,t,Ze),i.intersectBox(Ze,s)}function je(e,t,i,s,n,r,o){const{geometry:a}=i,{index:c}=a,l=a.attributes.position;for(let a=e,h=t+e;a<h;a++){let e;if(e=i.resolveTriangleIndex(a),He(o,3*e,c,l),o.needsUpdate=!0,s(o,e,n,r))return!0}return!1}const qe=new n;function Qe(e,t,i,s,n){Fe.setBuffer(e._roots[t]),Ke(0,e,i,s,n),Fe.clearBuffer()}function Ke(e,t,i,s,n){const{float32Array:r,uint16Array:o,uint32Array:a}=Fe,c=2*e;if(Ce(c,o)){!function(e,t,i,s,n,r){const{geometry:o,_indirectBuffer:a}=e;for(let e=s,a=s+n;e<a;e++)ke(o,t,i,e,r)}(t,i,s,Te(e,a),me(c,o),n)}else{const o=Re(e);$e(o,r,s,qe)&&Ke(o,t,i,s,n);const c=ge(e,a);$e(c,r,s,qe)&&Ke(c,t,i,s,n)}}const Je=new n,et=["x","y","z"];function tt(e,t,i,s){Fe.setBuffer(e._roots[t]);const n=it(0,e,i,s);return Fe.clearBuffer(),n}function it(e,t,i,s){const{float32Array:n,uint16Array:r,uint32Array:o}=Fe;let a=2*e;if(Ce(a,r)){return function(e,t,i,s,n){const{geometry:r,_indirectBuffer:o}=e;let a=1/0,c=null;for(let e=s,o=s+n;e<o;e++){let s;s=ke(r,t,i,e),s&&s.distance<a&&(c=s,a=s.distance)}return c}(t,i,s,Te(e,o),me(a,r))}{const r=Ae(e,o),a=et[r],c=s.direction[a]>=0;let l,h;c?(l=Re(e),h=ge(e,o)):(l=ge(e,o),h=Re(e));const u=$e(l,n,s,Je)?it(l,t,i,s):null;if(u){const e=u.point[a];if(c?e<=n[h+r]:e>=n[h+r+3])return u}const I=$e(h,n,s,Je)?it(h,t,i,s):null;return u&&I?u.distance<=I.distance?u:I:u||I||null}}const st=new u,nt=new Ie,rt=new Ie,ot=new h,at=new de,ct=new de;function lt(e,t,i,s){Fe.setBuffer(e._roots[t]);const n=ht(0,e,i,s);return Fe.clearBuffer(),n}function ht(e,t,i,s,n=null){const{float32Array:r,uint16Array:o,uint32Array:a}=Fe;let c=2*e;null===n&&(i.boundingBox||i.computeBoundingBox(),at.set(i.boundingBox.min,i.boundingBox.max,s),n=at);if(!Ce(c,o)){const o=e+8,c=a[e+6];W(o,r,st);if(n.intersectsBox(st)&&ht(o,t,i,s,n))return!0;W(c,r,st);return!!(n.intersectsBox(st)&&ht(c,t,i,s,n))}{const n=t.geometry,l=n.index,h=n.attributes.position,u=i.index,I=i.attributes.position,d=Te(e,a),E=me(c,o);if(ot.copy(s).invert(),i.boundsTree){W(e,r,ct),ct.matrix.copy(ot),ct.needsUpdate=!0;return i.boundsTree.shapecast({intersectsBounds:e=>ct.intersectsBox(e),intersectsTriangle:e=>{e.a.applyMatrix4(s),e.b.applyMatrix4(s),e.c.applyMatrix4(s),e.needsUpdate=!0;for(let t=3*d,i=3*(E+d);t<i;t+=3)if(He(rt,t,l,h),rt.needsUpdate=!0,e.intersectsTriangle(rt))return!0;return!1}})}for(let e=3*d,t=3*(E+d);e<t;e+=3){He(nt,e,l,h),nt.a.applyMatrix4(ot),nt.b.applyMatrix4(ot),nt.c.applyMatrix4(ot),nt.needsUpdate=!0;for(let e=0,t=u.count;e<t;e+=3)if(He(rt,e,u,I),rt.needsUpdate=!0,nt.intersectsTriangle(rt))return!0}}}const ut=new h,It=new de,dt=new de,Et=new n,ft=new n,pt=new n,Ct=new n;function Tt(e,t,i,s={},n={},r=0,o=1/0){t.boundingBox||t.computeBoundingBox(),It.set(t.boundingBox.min,t.boundingBox.max,i),It.needsUpdate=!0;const a=e.geometry,c=a.attributes.position,l=a.index,h=t.attributes.position,u=t.index,I=pe.getPrimitive(),d=pe.getPrimitive();let E=Et,f=ft,p=null,C=null;n&&(p=pt,C=Ct);let T=1/0,m=null,R=null;return ut.copy(i).invert(),dt.matrix.copy(ut),e.shapecast({boundsTraverseOrder:e=>It.distanceToBox(e),intersectsBounds:(e,t,i)=>i<T&&i<o&&(t&&(dt.min.copy(e.min),dt.max.copy(e.max),dt.needsUpdate=!0),!0),intersectsRange:(e,s)=>{if(t.boundsTree){return t.boundsTree.shapecast({boundsTraverseOrder:e=>dt.distanceToBox(e),intersectsBounds:(e,t,i)=>i<T&&i<o,intersectsRange:(t,n)=>{for(let o=t,a=t+n;o<a;o++){He(d,3*o,u,h),d.a.applyMatrix4(i),d.b.applyMatrix4(i),d.c.applyMatrix4(i),d.needsUpdate=!0;for(let t=e,i=e+s;t<i;t++){He(I,3*t,l,c),I.needsUpdate=!0;const e=I.distanceToTriangle(d,E,p);if(e<T&&(f.copy(E),C&&C.copy(p),T=e,m=t,R=o),e<r)return!0}}}})}for(let n=0,o=G(t);n<o;n++){He(d,3*n,u,h),d.a.applyMatrix4(i),d.b.applyMatrix4(i),d.c.applyMatrix4(i),d.needsUpdate=!0;for(let t=e,i=e+s;t<i;t++){He(I,3*t,l,c),I.needsUpdate=!0;const e=I.distanceToTriangle(d,E,p);if(e<T&&(f.copy(E),C&&C.copy(p),T=e,m=t,R=n),e<r)return!0}}}}),pe.releasePrimitive(I),pe.releasePrimitive(d),T===1/0?null:(s.point?s.point.copy(f):s.point=f.clone(),s.distance=T,s.faceIndex=m,n&&(n.point?n.point.copy(C):n.point=C.clone(),n.point.applyMatrix4(ut),f.applyMatrix4(ut),n.distance=f.sub(n.point).length(),n.faceIndex=R),s)}function mt(e,t=null){t&&Array.isArray(t)&&(t=new Set(t));const i=e.geometry,s=i.index?i.index.array:null,n=i.attributes.position;let r,o,a,c,l=0;const h=e._roots;for(let e=0,t=h.length;e<t;e++)r=h[e],o=new Uint32Array(r),a=new Uint16Array(r),c=new Float32Array(r),u(0,l),l+=r.byteLength;function u(i,r,l=!1){const h=2*i;if(a[h+15]===B){const t=o[i+6];let r=1/0,l=1/0,u=1/0,I=-1/0,d=-1/0,E=-1/0;for(let i=t,o=t+a[h+14];i<o;i++){const t=3*e.resolveTriangleIndex(i);for(let e=0;e<3;e++){let i=t+e;i=s?s[i]:i;const o=n.getX(i),a=n.getY(i),c=n.getZ(i);o<r&&(r=o),o>I&&(I=o),a<l&&(l=a),a>d&&(d=a),c<u&&(u=c),c>E&&(E=c)}}return(c[i+0]!==r||c[i+1]!==l||c[i+2]!==u||c[i+3]!==I||c[i+4]!==d||c[i+5]!==E)&&(c[i+0]=r,c[i+1]=l,c[i+2]=u,c[i+3]=I,c[i+4]=d,c[i+5]=E,!0)}{const e=i+8,s=o[i+6],n=e+r,a=s+r;let h=l,I=!1,d=!1;t?h||(I=t.has(n),d=t.has(a),h=!I&&!d):(I=!0,d=!0);const E=h||d;let f=!1;(h||I)&&(f=u(e,r,h));let p=!1;E&&(p=u(s,r,h));const C=f||p;if(C)for(let t=0;t<3;t++){const n=e+t,r=s+t,o=c[n],a=c[n+3],l=c[r],h=c[r+3];c[i+t]=o<l?o:l,c[i+t+3]=a>h?a:h}return C}}}const Rt=new n;function gt(e,t,i,s,n){Fe.setBuffer(e._roots[t]),At(0,e,i,s,n),Fe.clearBuffer()}function At(e,t,i,s,n){const{float32Array:r,uint16Array:o,uint32Array:a}=Fe,c=2*e;if(Ce(c,o)){!function(e,t,i,s,n,r){const{geometry:o,_indirectBuffer:a}=e;for(let e=s,c=s+n;e<c;e++)ke(o,t,i,a?a[e]:e,r)}(t,i,s,Te(e,a),me(c,o),n)}else{const o=Re(e);$e(o,r,s,Rt)&&At(o,t,i,s,n);const c=ge(e,a);$e(c,r,s,Rt)&&At(c,t,i,s,n)}}const Ft=new n,St=["x","y","z"];function Ot(e,t,i,s){Fe.setBuffer(e._roots[t]);const n=Nt(0,e,i,s);return Fe.clearBuffer(),n}function Nt(e,t,i,s){const{float32Array:n,uint16Array:r,uint32Array:o}=Fe;let a=2*e;if(Ce(a,r)){return function(e,t,i,s,n){const{geometry:r,_indirectBuffer:o}=e;let a=1/0,c=null;for(let e=s,l=s+n;e<l;e++){let s;s=ke(r,t,i,o?o[e]:e),s&&s.distance<a&&(c=s,a=s.distance)}return c}(t,i,s,Te(e,o),me(a,r))}{const r=Ae(e,o),a=St[r],c=s.direction[a]>=0;let l,h;c?(l=Re(e),h=ge(e,o)):(l=ge(e,o),h=Re(e));const u=$e(l,n,s,Ft)?Nt(l,t,i,s):null;if(u){const e=u.point[a];if(c?e<=n[h+r]:e>=n[h+r+3])return u}const I=$e(h,n,s,Ft)?Nt(h,t,i,s):null;return u&&I?u.distance<=I.distance?u:I:u||I||null}}const yt=new u,_t=new Ie,Lt=new Ie,Pt=new h,wt=new de,vt=new de;function Mt(e,t,i,s){Fe.setBuffer(e._roots[t]);const n=Dt(0,e,i,s);return Fe.clearBuffer(),n}function Dt(e,t,i,s,n=null){const{float32Array:r,uint16Array:o,uint32Array:a}=Fe;let c=2*e;null===n&&(i.boundingBox||i.computeBoundingBox(),wt.set(i.boundingBox.min,i.boundingBox.max,s),n=wt);if(!Ce(c,o)){const o=e+8,c=a[e+6];W(o,r,yt);if(n.intersectsBox(yt)&&Dt(o,t,i,s,n))return!0;W(c,r,yt);return!!(n.intersectsBox(yt)&&Dt(c,t,i,s,n))}{const n=t.geometry,l=n.index,h=n.attributes.position,u=i.index,I=i.attributes.position,d=Te(e,a),E=me(c,o);if(Pt.copy(s).invert(),i.boundsTree){W(e,r,vt),vt.matrix.copy(Pt),vt.needsUpdate=!0;return i.boundsTree.shapecast({intersectsBounds:e=>vt.intersectsBox(e),intersectsTriangle:e=>{e.a.applyMatrix4(s),e.b.applyMatrix4(s),e.c.applyMatrix4(s),e.needsUpdate=!0;for(let i=d,s=E+d;i<s;i++)if(He(Lt,3*t.resolveTriangleIndex(i),l,h),Lt.needsUpdate=!0,e.intersectsTriangle(Lt))return!0;return!1}})}for(let e=d,i=E+d;e<i;e++){const i=t.resolveTriangleIndex(e);He(_t,3*i,l,h),_t.a.applyMatrix4(Pt),_t.b.applyMatrix4(Pt),_t.c.applyMatrix4(Pt),_t.needsUpdate=!0;for(let e=0,t=u.count;e<t;e+=3)if(He(Lt,e,u,I),Lt.needsUpdate=!0,_t.intersectsTriangle(Lt))return!0}}}const bt=new h,xt=new de,Ut=new de,Bt=new n,Vt=new n,Yt=new n,Gt=new n;function zt(e,t,i,s={},n={},r=0,o=1/0){t.boundingBox||t.computeBoundingBox(),xt.set(t.boundingBox.min,t.boundingBox.max,i),xt.needsUpdate=!0;const a=e.geometry,c=a.attributes.position,l=a.index,h=t.attributes.position,u=t.index,I=pe.getPrimitive(),d=pe.getPrimitive();let E=Bt,f=Vt,p=null,C=null;n&&(p=Yt,C=Gt);let T=1/0,m=null,R=null;return bt.copy(i).invert(),Ut.matrix.copy(bt),e.shapecast({boundsTraverseOrder:e=>xt.distanceToBox(e),intersectsBounds:(e,t,i)=>i<T&&i<o&&(t&&(Ut.min.copy(e.min),Ut.max.copy(e.max),Ut.needsUpdate=!0),!0),intersectsRange:(s,n)=>{if(t.boundsTree){const a=t.boundsTree;return a.shapecast({boundsTraverseOrder:e=>Ut.distanceToBox(e),intersectsBounds:(e,t,i)=>i<T&&i<o,intersectsRange:(t,o)=>{for(let g=t,A=t+o;g<A;g++){const t=a.resolveTriangleIndex(g);He(d,3*t,u,h),d.a.applyMatrix4(i),d.b.applyMatrix4(i),d.c.applyMatrix4(i),d.needsUpdate=!0;for(let t=s,i=s+n;t<i;t++){const i=e.resolveTriangleIndex(t);He(I,3*i,l,c),I.needsUpdate=!0;const s=I.distanceToTriangle(d,E,p);if(s<T&&(f.copy(E),C&&C.copy(p),T=s,m=t,R=g),s<r)return!0}}}})}for(let o=0,a=G(t);o<a;o++){He(d,3*o,u,h),d.a.applyMatrix4(i),d.b.applyMatrix4(i),d.c.applyMatrix4(i),d.needsUpdate=!0;for(let t=s,i=s+n;t<i;t++){const i=e.resolveTriangleIndex(t);He(I,3*i,l,c),I.needsUpdate=!0;const s=I.distanceToTriangle(d,E,p);if(s<T&&(f.copy(E),C&&C.copy(p),T=s,m=t,R=o),s<r)return!0}}}}),pe.releasePrimitive(I),pe.releasePrimitive(d),T===1/0?null:(s.point?s.point.copy(f):s.point=f.clone(),s.distance=T,s.faceIndex=m,n&&(n.point?n.point.copy(C):n.point=C.clone(),n.point.applyMatrix4(bt),f.applyMatrix4(bt),n.distance=f.sub(n.point).length(),n.faceIndex=R),s)}const kt=new Fe.constructor,Ht=new Fe.constructor,Wt=new Ee((()=>new u)),Xt=new u,Zt=new u,$t=new u,jt=new u;let qt=!1;function Qt(e,t,i,s,n,r=0,o=0,a=0,c=0,l=null,h=!1){let u,I;h?(u=Ht,I=kt):(u=kt,I=Ht);const d=u.float32Array,E=u.uint32Array,f=u.uint16Array,p=I.float32Array,C=I.uint32Array,T=I.uint16Array,m=2*t,R=Ce(2*e,f),g=Ce(m,T);let A=!1;if(g&&R)A=h?n(Te(t,C),me(2*t,T),Te(e,E),me(2*e,f),c,o+t,a,r+e):n(Te(e,E),me(2*e,f),Te(t,C),me(2*t,T),a,r+e,c,o+t);else if(g){const l=Wt.getPrimitive();W(t,p,l),l.applyMatrix4(i);const u=Re(e),I=ge(e,E);W(u,d,Xt),W(I,d,Zt);const f=l.intersectsBox(Xt),C=l.intersectsBox(Zt);A=f&&Qt(t,u,s,i,n,o,r,c,a+1,l,!h)||C&&Qt(t,I,s,i,n,o,r,c,a+1,l,!h),Wt.releasePrimitive(l)}else{const u=Re(t),I=ge(t,C);W(u,p,$t),W(I,p,jt);const f=l.intersectsBox($t),T=l.intersectsBox(jt);if(f&&T)A=Qt(e,u,i,s,n,r,o,a,c+1,l,h)||Qt(e,I,i,s,n,r,o,a,c+1,l,h);else if(f)if(R)A=Qt(e,u,i,s,n,r,o,a,c+1,l,h);else{const t=Wt.getPrimitive();t.copy($t).applyMatrix4(i);const l=Re(e),I=ge(e,E);W(l,d,Xt),W(I,d,Zt);const f=t.intersectsBox(Xt),p=t.intersectsBox(Zt);A=f&&Qt(u,l,s,i,n,o,r,c,a+1,t,!h)||p&&Qt(u,I,s,i,n,o,r,c,a+1,t,!h),Wt.releasePrimitive(t)}else if(T)if(R)A=Qt(e,I,i,s,n,r,o,a,c+1,l,h);else{const t=Wt.getPrimitive();t.copy(jt).applyMatrix4(i);const l=Re(e),u=ge(e,E);W(l,d,Xt),W(u,d,Zt);const f=t.intersectsBox(Xt),p=t.intersectsBox(Zt);A=f&&Qt(I,l,s,i,n,o,r,c,a+1,t,!h)||p&&Qt(I,u,s,i,n,o,r,c,a+1,t,!h),Wt.releasePrimitive(t)}}return A}const Kt=new de,Jt=new u;class ei{static serialize(e,t={}){t={cloneBuffers:!0,...t};const i=e.geometry,s=e._roots,n=e._indirectBuffer,r=i.getIndex();let o;return o=t.cloneBuffers?{roots:s.map((e=>e.slice())),index:r.array.slice(),indirectBuffer:n?n.slice():null}:{roots:s,index:r.array,indirectBuffer:n},o}static deserialize(e,t,i={}){i={setIndex:!0,indirect:Boolean(e.indirectBuffer),...i};const{index:n,roots:r,indirectBuffer:o}=e,a=new ei(t,{...i,[Y]:!0});if(a._roots=r,a._indirectBuffer=o||null,i.setIndex){const i=t.getIndex();if(null===i){const i=new s(e.index,1,!1);t.setIndex(i)}else i.array!==n&&(i.array.set(n),i.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,[Y]:!1},t)).useSharedArrayBuffer&&"undefined"==typeof SharedArrayBuffer)throw new Error("MeshBVH: SharedArrayBuffer is not available.");this.geometry=e,this._roots=null,this._indirectBuffer=null,t[Y]||(oe(this,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new u)));const{_indirectBuffer:i}=this;this.resolveTriangleIndex=t.indirect?e=>i[e]:e=>e}refit(e=null){return(this.indirect?mt:Xe)(this,e)}traverse(e,t=0){const i=this._roots[t],s=new Uint32Array(i),n=new Uint16Array(i);!function t(r,o=0){const a=2*r,c=n[a+15]===B;if(c){const t=s[r+6],l=n[a+14];e(o,c,new Float32Array(i,4*r,6),t,l)}else{const n=r+8,a=s[r+6],l=s[r+7];e(o,c,new Float32Array(i,4*r,6),l)||(t(n,o+1),t(a,o+1))}}(0)}raycast(e,t=E){const i=this._roots,s=this.geometry,n=[],r=t.isMaterial,o=Array.isArray(t),a=s.groups,c=r?t.side:t,l=this.indirect?gt:Qe;for(let s=0,r=i.length;s<r;s++){const i=o?t[a[s].materialIndex].side:c,r=n.length;if(l(this,s,i,e,n),o){const e=a[s].materialIndex;for(let t=r,i=n.length;t<i;t++)n[t].face.materialIndex=e}}return n}raycastFirst(e,t=E){const i=this._roots,s=this.geometry,n=t.isMaterial,r=Array.isArray(t);let o=null;const a=s.groups,c=n?t.side:t,l=this.indirect?Ot:tt;for(let s=0,n=i.length;s<n;s++){const i=l(this,s,r?t[a[s].materialIndex].side:c,e);null!=i&&(null==o||i.distance<o.distance)&&(o=i,r&&(i.face.materialIndex=a[s].materialIndex))}return o}intersectsGeometry(e,t){let i=!1;const s=this._roots,n=this.indirect?Mt:lt;for(let r=0,o=s.length;r<o&&(i=n(this,r,e,t),!i);r++);return i}shapecast(e){const t=pe.getPrimitive(),i=this.indirect?je:We;let{boundsTraverseOrder:s,intersectsBounds:n,intersectsRange:r,intersectsTriangle:o}=e;if(r&&o){const e=r;r=(s,n,r,a,c)=>!!e(s,n,r,a,c)||i(s,n,this,o,r,a,t)}else r||(r=o?(e,s,n,r)=>i(e,s,this,o,n,r,t):(e,t,i)=>i);let a=!1,c=0;const l=this._roots;for(let e=0,t=l.length;e<t;e++){const t=l[e];if(a=_e(this,e,n,r,s,c),a)break;c+=t.byteLength}return pe.releasePrimitive(t),a}bvhcast(e,t,i){let{intersectsRanges:s,intersectsTriangles:n}=i;const r=pe.getPrimitive(),o=this.geometry.index,a=this.geometry.attributes.position,c=this.indirect?e=>{const t=this.resolveTriangleIndex(e);He(r,3*t,o,a)}:e=>{He(r,3*e,o,a)},l=pe.getPrimitive(),u=e.geometry.index,I=e.geometry.attributes.position,d=e.indirect?t=>{const i=e.resolveTriangleIndex(t);He(l,3*i,u,I)}:e=>{He(l,3*e,u,I)};if(n){const e=(e,i,s,o,a,h,u,I)=>{for(let E=s,f=s+o;E<f;E++){d(E),l.a.applyMatrix4(t),l.b.applyMatrix4(t),l.c.applyMatrix4(t),l.needsUpdate=!0;for(let t=e,s=e+i;t<s;t++)if(c(t),r.needsUpdate=!0,n(r,l,t,E,a,h,u,I))return!0}return!1};if(s){const t=s;s=function(i,s,n,r,o,a,c,l){return!!t(i,s,n,r,o,a,c,l)||e(i,s,n,r,o,a,c,l)}}else s=e}return function(e,t,i,s){if(qt)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");qt=!0;const n=e._roots,r=t._roots;let o,a=0,c=0;const l=(new h).copy(i).invert();for(let e=0,t=n.length;e<t;e++){kt.setBuffer(n[e]),c=0;const t=Wt.getPrimitive();W(0,kt.float32Array,t),t.applyMatrix4(l);for(let n=0,h=r.length;n<h&&(Ht.setBuffer(r[e]),o=Qt(0,0,i,l,s,a,c,0,0,t),Ht.clearBuffer(),c+=r[n].length,!o);n++);if(Wt.releasePrimitive(t),kt.clearBuffer(),a+=n[e].length,o)break}return qt=!1,o}(this,e,t,s)}intersectsBox(e,t){return Kt.set(e.min,e.max,t),Kt.needsUpdate=!0,this.shapecast({intersectsBounds:e=>Kt.intersectsBox(e),intersectsTriangle:e=>Kt.intersectsTriangle(e)})}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?zt:Tt)(this,e,t,i,s,n,r)}closestPointToPoint(e,t={},i=0,s=1/0){return function(e,t,i={},s=0,n=1/0){const r=s*s,o=n*n;let a=1/0,c=null;if(e.shapecast({boundsTraverseOrder:e=>(Pe.copy(t).clamp(e.min,e.max),Pe.distanceToSquared(t)),intersectsBounds:(e,t,i)=>i<a&&i<o,intersectsTriangle:(e,i)=>{e.closestPointToPoint(t,Pe);const s=t.distanceToSquared(Pe);return s<a&&(we.copy(Pe),a=s,c=i),s<r}}),a===1/0)return null;const l=Math.sqrt(a);return i.point?i.point.copy(we):i.point=we.clone(),i.distance=l,i.faceIndex=c,i}(this,e,t,i,s)}getBoundingBox(e){e.makeEmpty();return this._roots.forEach((t=>{W(0,new Float32Array(t),Jt),e.union(Jt)})),e}}function ti(e,t,i){return null===e?null:(e.point.applyMatrix4(t.matrixWorld),e.distance=e.point.distanceTo(i.ray.origin),e.object=t,e.distance<i.near||e.distance>i.far?null:e)}const ii=new p,si=new h,ni=f.prototype.raycast;function ri(e,t){if(this.geometry.boundsTree){if(void 0===this.material)return;si.copy(this.matrixWorld).invert(),ii.copy(e.ray).applyMatrix4(si);const i=this.geometry.boundsTree;if(!0===e.firstHitOnly){const s=ti(i.raycastFirst(ii,this.material),this,e);s&&t.push(s)}else{const s=i.raycast(ii,this.material);for(let i=0,n=s.length;i<n;i++){const n=ti(s[i],this,e);n&&t.push(n)}}}else ni.call(this,e,t)}function oi(e){return this.boundsTree=new ei(this,e),this.boundsTree}function ai(){this.boundsTree=null}class ci{constructor(){t(this,"enabled",!0),t(this,"trigger",(e=>{if(!this.enabled)return;const t=this.handlers.slice(0);for(const i of t)i(e)})),t(this,"handlers",[])}add(e){this.handlers.push(e)}remove(e){this.handlers=this.handlers.filter((t=>t!==e))}reset(){this.handlers.length=0}}class li{constructor(){t(this,"enabled",!0),t(this,"trigger",(async e=>{if(!this.enabled)return;const t=this.handlers.slice(0);for(const i of t)await i(e)})),t(this,"handlers",[])}add(e){this.handlers.push(e)}remove(e){this.handlers=this.handlers.filter((t=>t!==e))}reset(){this.handlers.length=0}}class hi{constructor(e){t(this,"isDisposeable",(()=>"dispose"in this&&"onDisposed"in this)),t(this,"isResizeable",(()=>"resize"in this&&"getSize"in this)),t(this,"isUpdateable",(()=>"onAfterUpdate"in this&&"onBeforeUpdate"in this&&"update"in this)),t(this,"isHideable",(()=>"visible"in this)),t(this,"isConfigurable",(()=>"setup"in this&&"config"in this&&"onSetup"in this)),this.components=e}}class ui extends hi{}class Ii extends hi{constructor(e){super(e),t(this,"worlds",new Map),t(this,"onWorldChanged",new ci),t(this,"currentWorld",null),this.onWorldChanged.add((({world:e,action:t})=>{"removed"===t&&this.worlds.delete(e.uuid)}))}}class di extends Ii{constructor(){super(...arguments),t(this,"hasCameraControls",(()=>"controls"in this))}}class Ei extends Ii{constructor(){super(...arguments),t(this,"onAfterUpdate",new ci),t(this,"onBeforeUpdate",new ci),t(this,"onDisposed",new ci),t(this,"onResize",new ci),t(this,"onClippingPlanesUpdated",new ci),t(this,"clippingPlanes",[])}updateClippingPlanes(){this.onClippingPlanesUpdated.trigger()}setPlane(e,t,i){t.isLocal=i;const s=this.clippingPlanes.indexOf(t);e&&-1===s?this.clippingPlanes.push(t):!e&&s>-1&&this.clippingPlanes.splice(s,1),this.three.clippingPlanes=this.clippingPlanes.filter((e=>!e.isLocal))}}const fi=class e extends ui{constructor(i){super(i),t(this,"_disposedComponents",new Set),t(this,"enabled",!0),i.add(e.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(t,i){const s=t;s.geometry&&this.disposeGeometry(s.geometry),i&&s.material&&e.disposeMaterial(s),s.material=[],s.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()}};t(fi,"uuid","76e9cd8e-ad8f-4753-9ef6-cbc60f7247fe");let pi=fi;class Ci extends Ii{constructor(e){super(e),t(this,"onDisposed",new ci),t(this,"directionalLights",new Map),t(this,"ambientLights",new Map)}dispose(){const e=this.components.get(pi);for(const t of this.three.children){const i=t;i.geometry&&e.destroy(i)}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()}}class Ti extends Set{constructor(e){super(e),t(this,"onItemAdded",new ci),t(this,"onItemDeleted",new ci),t(this,"onCleared",new ci),t(this,"guard",(()=>!0))}clear(){super.clear(),this.onCleared.trigger()}add(...e){for(const t of e){if(this.has(t))continue;this.guard(t)&&(super.add(t),this.onItemAdded||(this.onItemAdded=new ci),this.onItemAdded.trigger(t))}return this}delete(e){const t=super.delete(e);return t&&this.onItemDeleted.trigger(),t}dispose(){this.clear(),this.onItemAdded.reset(),this.onItemDeleted.reset(),this.onCleared.reset()}}class mi extends Map{constructor(e){super(e),t(this,"onItemSet",new ci),t(this,"onItemUpdated",new ci),t(this,"onItemDeleted",new ci),t(this,"onCleared",new ci),t(this,"guard",(()=>!0))}clear(){super.clear(),this.onCleared.trigger()}set(e,t){const i=this.has(e);if(!(this.guard??(()=>!0))(e,t))return this;const s=super.set(e,t);return i?(this.onItemUpdated||(this.onItemUpdated=new ci),this.onItemUpdated.trigger({key:e,value:t})):(this.onItemSet||(this.onItemSet=new ci),this.onItemSet.trigger({key:e,value:t})),s}delete(e){const t=super.delete(e);return t&&this.onItemDeleted.trigger(e),t}dispose(){this.clear(),this.onItemSet.reset(),this.onItemDeleted.reset(),this.onCleared.reset()}}class Ri extends ui{}class gi{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){const t=e;return{type:t.type,value:t.value}}if("Color"===e.type){const t=e;return{type:t.type,value:t.value.clone()}}if("Text"===e.type){const t=e;return{type:t.type,value:t.value}}if("Number"===e.type){const t=e;return{type:t.type,value:t.value,min:t.min,max:t.max,interpolable:t.interpolable}}if("Select"===e.type){const t=e;return{type:t.type,value:t.value,multiple:t.multiple,options:new Set(t.options)}}if("Vector3"===e.type){const t=e;return{type:t.type,value:t.value.clone()}}if("TextSet"===e.type){const t=e;return{type:t.type,value:new Set(t.value)}}if("None"===e.type){const t=e;return{type:t.type,value:t.value}}throw new Error("Invalid entry!")}}class Ai{constructor(){t(this,"list",new Set)}add(e){for(const t of e)this.list.add(t)}remove(e){for(const t of e)this.list.delete(t)}set(e){for(const t of this.list)t.enabled=e}reset(){for(const e of this.list)e.reset()}}const Fi=new n,Si=new a,Oi=new o,Ni=new n,yi=new c;class _i{constructor(){this.tolerance=-1,this.faces=[],this.newFaces=[],this.assigned=new vi,this.unassigned=new vi,this.vertices=[]}setFromPoints(e){if(e.length>=4){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.vertices.push(new wi(e[t]));this._compute()}return this}setFromObject(e){const t=[];return e.updateMatrixWorld(!0),e.traverse((function(e){const i=e.geometry;if(void 0!==i){const s=i.attributes.position;if(void 0!==s)for(let i=0,r=s.count;i<r;i++){const r=new n;r.fromBufferAttribute(s,i).applyMatrix4(e.matrixWorld),t.push(r)}}})),this.setFromPoints(t)}containsPoint(e){const t=this.faces;for(let i=0,s=t.length;i<s;i++){if(t[i].distanceToPoint(e)>this.tolerance)return!1}return!0}intersectRay(e,t){const i=this.faces;let s=-1/0,n=1/0;for(let t=0,r=i.length;t<r;t++){const r=i[t],o=r.distanceToPoint(e.origin),a=r.normal.dot(e.direction);if(o>0&&a>=0)return null;const c=0!==a?-o/a:0;if(!(c<=0)&&(a>0?n=Math.min(c,n):s=Math.max(c,s),s>n))return null}return s!==-1/0?e.at(s,t):e.at(n,t),t}intersectsRay(e){return null!==this.intersectRay(e,Fi)}makeEmpty(){return this.faces=[],this.vertices=[],this}_addVertexToFace(e,t){return e.face=t,null===t.outside?this.assigned.append(e):this.assigned.insertBefore(t.outside,e),t.outside=e,this}_removeVertexFromFace(e,t){return e===t.outside&&(null!==e.next&&e.next.face===t?t.outside=e.next:t.outside=null),this.assigned.remove(e),this}_removeAllVerticesFromFace(e){if(null!==e.outside){const t=e.outside;let i=e.outside;for(;null!==i.next&&i.next.face===e;)i=i.next;return this.assigned.removeSubList(t,i),t.prev=i.next=null,e.outside=null,t}}_deleteFaceVertices(e,t){const i=this._removeAllVerticesFromFace(e);if(void 0!==i)if(void 0===t)this.unassigned.appendChain(i);else{let e=i;do{const i=e.next;t.distanceToPoint(e.point)>this.tolerance?this._addVertexToFace(e,t):this.unassigned.append(e),e=i}while(null!==e)}return this}_resolveUnassignedPoints(e){if(!1===this.unassigned.isEmpty()){let t=this.unassigned.first();do{const i=t.next;let s=this.tolerance,n=null;for(let i=0;i<e.length;i++){const r=e[i];if(0===r.mark){const e=r.distanceToPoint(t.point);if(e>s&&(s=e,n=r),s>1e3*this.tolerance)break}}null!==n&&this._addVertexToFace(t,n),t=i}while(null!==t)}return this}_computeExtremes(){const e=new n,t=new n,i=[],s=[];for(let e=0;e<3;e++)i[e]=s[e]=this.vertices[0];e.copy(this.vertices[0].point),t.copy(this.vertices[0].point);for(let n=0,r=this.vertices.length;n<r;n++){const r=this.vertices[n],o=r.point;for(let t=0;t<3;t++)o.getComponent(t)<e.getComponent(t)&&(e.setComponent(t,o.getComponent(t)),i[t]=r);for(let e=0;e<3;e++)o.getComponent(e)>t.getComponent(e)&&(t.setComponent(e,o.getComponent(e)),s[e]=r)}return this.tolerance=3*Number.EPSILON*(Math.max(Math.abs(e.x),Math.abs(t.x))+Math.max(Math.abs(e.y),Math.abs(t.y))+Math.max(Math.abs(e.z),Math.abs(t.z))),{min:i,max:s}}_computeInitialHull(){const e=this.vertices,t=this._computeExtremes(),i=t.min,s=t.max;let n=0,r=0;for(let e=0;e<3;e++){const t=s[e].point.getComponent(e)-i[e].point.getComponent(e);t>n&&(n=t,r=e)}const o=i[r],a=s[r];let c,l;n=0,Si.set(o.point,a.point);for(let t=0,i=this.vertices.length;t<i;t++){const i=e[t];if(i!==o&&i!==a){Si.closestPointToPoint(i.point,!0,Ni);const e=Ni.distanceToSquared(i.point);e>n&&(n=e,c=i)}}n=-1,Oi.setFromCoplanarPoints(o.point,a.point,c.point);for(let t=0,i=this.vertices.length;t<i;t++){const i=e[t];if(i!==o&&i!==a&&i!==c){const e=Math.abs(Oi.distanceToPoint(i.point));e>n&&(n=e,l=i)}}const h=[];if(Oi.distanceToPoint(l.point)<0){h.push(Li.create(o,a,c),Li.create(l,a,o),Li.create(l,c,a),Li.create(l,o,c));for(let e=0;e<3;e++){const t=(e+1)%3;h[e+1].getEdge(2).setTwin(h[0].getEdge(t)),h[e+1].getEdge(1).setTwin(h[t+1].getEdge(0))}}else{h.push(Li.create(o,c,a),Li.create(l,o,a),Li.create(l,a,c),Li.create(l,c,o));for(let e=0;e<3;e++){const t=(e+1)%3;h[e+1].getEdge(2).setTwin(h[0].getEdge((3-e)%3)),h[e+1].getEdge(0).setTwin(h[t+1].getEdge(1))}}for(let e=0;e<4;e++)this.faces.push(h[e]);for(let t=0,i=e.length;t<i;t++){const i=e[t];if(i!==o&&i!==a&&i!==c&&i!==l){n=this.tolerance;let e=null;for(let t=0;t<4;t++){const s=this.faces[t].distanceToPoint(i.point);s>n&&(n=s,e=this.faces[t])}null!==e&&this._addVertexToFace(i,e)}}return this}_reindexFaces(){const e=[];for(let t=0;t<this.faces.length;t++){const i=this.faces[t];0===i.mark&&e.push(i)}return this.faces=e,this}_nextVertexToAdd(){if(!1===this.assigned.isEmpty()){let e,t=0;const i=this.assigned.first().face;let s=i.outside;do{const n=i.distanceToPoint(s.point);n>t&&(t=n,e=s),s=s.next}while(null!==s&&s.face===i);return e}}_computeHorizon(e,t,i,s){let n;this._deleteFaceVertices(i),i.mark=1,n=null===t?t=i.getEdge(0):t.next;do{const t=n.twin,i=t.face;0===i.mark&&(i.distanceToPoint(e)>this.tolerance?this._computeHorizon(e,t,i,s):s.push(n)),n=n.next}while(n!==t);return this}_addAdjoiningFace(e,t){const i=Li.create(e,t.tail(),t.head());return this.faces.push(i),i.getEdge(-1).setTwin(t.twin),i.getEdge(0)}_addNewFaces(e,t){this.newFaces=[];let i=null,s=null;for(let n=0;n<t.length;n++){const r=t[n],o=this._addAdjoiningFace(e,r);null===i?i=o:o.next.setTwin(s),this.newFaces.push(o.face),s=o}return i.next.setTwin(s),this}_addVertexToHull(e){const t=[];return this.unassigned.clear(),this._removeVertexFromFace(e,e.face),this._computeHorizon(e.point,null,e.face,t),this._addNewFaces(e,t),this._resolveUnassignedPoints(this.newFaces),this}_cleanup(){return this.assigned.clear(),this.unassigned.clear(),this.newFaces=[],this}_compute(){let e;for(this._computeInitialHull();void 0!==(e=this._nextVertexToAdd());)this._addVertexToHull(e);return this._reindexFaces(),this._cleanup(),this}}class Li{constructor(){this.normal=new n,this.midpoint=new n,this.area=0,this.constant=0,this.outside=null,this.mark=0,this.edge=null}static create(e,t,i){const s=new Li,n=new Pi(e,s),r=new Pi(t,s),o=new Pi(i,s);return n.next=o.prev=r,r.next=n.prev=o,o.next=r.prev=n,s.edge=n,s.compute()}getEdge(e){let t=this.edge;for(;e>0;)t=t.next,e--;for(;e<0;)t=t.prev,e++;return t}compute(){const e=this.edge.tail(),t=this.edge.head(),i=this.edge.next.head();return yi.set(e.point,t.point,i.point),yi.getNormal(this.normal),yi.getMidpoint(this.midpoint),this.area=yi.getArea(),this.constant=this.normal.dot(this.midpoint),this}distanceToPoint(e){return this.normal.dot(e)-this.constant}}class Pi{constructor(e,t){this.vertex=e,this.prev=null,this.next=null,this.twin=null,this.face=t}head(){return this.vertex}tail(){return this.prev?this.prev.vertex:null}length(){const e=this.head(),t=this.tail();return null!==t?t.point.distanceTo(e.point):-1}lengthSquared(){const e=this.head(),t=this.tail();return null!==t?t.point.distanceToSquared(e.point):-1}setTwin(e){return this.twin=e,e.twin=this,this}}class wi{constructor(e){this.point=e,this.prev=null,this.next=null,this.face=null}}class vi{constructor(){this.head=null,this.tail=null}first(){return this.head}last(){return this.tail}clear(){return this.head=this.tail=null,this}insertBefore(e,t){return t.prev=e.prev,t.next=e,null===t.prev?this.head=t:t.prev.next=t,e.prev=t,this}insertAfter(e,t){return t.prev=e,t.next=e.next,null===t.next?this.tail=t:t.next.prev=t,e.next=t,this}append(e){return null===this.head?this.head=e:this.tail.next=e,e.prev=this.tail,e.next=null,this.tail=e,this}appendChain(e){for(null===this.head?this.head=e:this.tail.next=e,e.prev=this.tail;null!==e.next;)e=e.next;return this.tail=e,this}remove(e){return null===e.prev?this.head=e.next:e.prev.next=e.next,null===e.next?this.tail=e.prev:e.next.prev=e.prev,this}removeSubList(e,t){return null===e.prev?this.head=t.next:e.prev.next=t.next,null===t.next?this.tail=e.prev:t.next.prev=e.prev,this}isEmpty(){return null===this.head}}const Mi=[2,2,1],Di=[1,0,0];function bi(e,t){return 3*e+t}function xi(e){const t=e.elements;let i=0;for(let e=0;e<3;e++){const s=t[bi(Mi[e],Di[e])];i+=2*s*s}return Math.sqrt(i)}function Ui(e,t){let i=0,s=1;const n=e.elements;for(let e=0;e<3;e++){const t=Math.abs(n[bi(Mi[e],Di[e])]);t>i&&(i=t,s=e)}let r=1,o=0;const a=Di[s],c=Mi[s];if(Math.abs(n[bi(c,a)])>Number.EPSILON){const e=(n[bi(c,c)]-n[bi(a,a)])/2/n[bi(c,a)];let t;t=e<0?-1/(-e+Math.sqrt(1+e*e)):1/(e+Math.sqrt(1+e*e)),r=1/Math.sqrt(1+t*t),o=t*r}return t.identity(),t.elements[bi(a,a)]=r,t.elements[bi(c,c)]=r,t.elements[bi(c,a)]=o,t.elements[bi(a,c)]=-o,t}function Bi(e,t){let s=0,n=0;t.unitary.identity(),t.diagonal.copy(e);const r=t.unitary,o=t.diagonal,a=new i.Matrix3,c=new i.Matrix3,l=Number.EPSILON*function(e){const t=e.elements;let i=0;for(let e=0;e<9;e++)i+=t[e]*t[e];return Math.sqrt(i)}(o);for(;n<10&&xi(o)>l;)Ui(o,a),c.copy(a).transpose(),o.multiply(a),o.premultiply(c),r.multiply(a),++s>2&&(n++,s=0);return t}function Vi(e){const t=[];for(let s=0;s<e.length-2;s+=3){const n=e[s],r=e[s+1],o=e[s+2];t.push(new i.Vector3(n,r,o))}const s=new _i;s.setFromPoints(t);const n={unitary:new i.Matrix3,diagonal:new i.Matrix3},r=s.faces,o=[],a=[];for(let e=0,t=r.length;e<t;e++){const t=r[e];let i=t.edge;o.length=0;do{o.push(i),i=i.next}while(i!==t.edge);for(let e=1,t=o.length-2;e<=t;e++){const t=o[0].vertex,i=o[e+0].vertex,s=o[e+1].vertex;a.push(t.point.x,t.point.y,t.point.z),a.push(i.point.x,i.point.y,i.point.z),a.push(s.point.x,s.point.y,s.point.z)}}const c=new i.Vector3,l=new i.Vector3,h=new i.Vector3,u=new i.Vector3,I=new i.Vector3,d=new i.Vector3,E=new i.Vector3,f=new i.Vector3;let p=0,C=0,T=0,m=0,R=0,g=0,A=0;for(let e=0,t=a.length;e<t;e+=9){c.fromArray(a,e),l.fromArray(a,e+3),h.fromArray(a,e+6),E.set(0,0,0),E.add(c).add(l).add(h).divideScalar(3),u.subVectors(l,c),I.subVectors(h,c);const t=d.crossVectors(u,I).length()/2;f.add(d.copy(E).multiplyScalar(t)),p+=t,C+=(9*E.x*E.x+c.x*c.x+l.x*l.x+h.x*h.x)*(t/12),T+=(9*E.x*E.y+c.x*c.y+l.x*l.y+h.x*h.y)*(t/12),m+=(9*E.x*E.z+c.x*c.z+l.x*l.z+h.x*h.z)*(t/12),R+=(9*E.y*E.y+c.y*c.y+l.y*l.y+h.y*h.y)*(t/12),g+=(9*E.y*E.z+c.y*c.z+l.y*l.z+h.y*h.z)*(t/12),A+=(9*E.z*E.z+c.z*c.z+l.z*l.z+h.z*h.z)*(t/12)}f.divideScalar(p),C/=p,T/=p,m/=p,R/=p,g/=p,A/=p,C-=f.x*f.x,T-=f.x*f.y,m-=f.x*f.z,R-=f.y*f.y,g-=f.y*f.z,A-=f.z*f.z;const F=new i.Matrix3;F.elements[0]=C,F.elements[1]=T,F.elements[2]=m,F.elements[3]=T,F.elements[4]=R,F.elements[5]=g,F.elements[6]=m,F.elements[7]=g,F.elements[8]=A,Bi(F,n);const S=n.unitary,O=new i.Vector3,N=new i.Vector3,y=new i.Vector3;S.extractBasis(O,N,y);let _=-1/0,L=-1/0,P=-1/0,w=1/0,v=1/0,M=1/0;for(let e=0,i=t.length;e<i;e++){const i=t[e];_=Math.max(O.dot(i),_),L=Math.max(N.dot(i),L),P=Math.max(y.dot(i),P),w=Math.min(O.dot(i),w),v=Math.min(N.dot(i),v),M=Math.min(y.dot(i),M)}O.multiplyScalar(.5*(w+_)),N.multiplyScalar(.5*(v+L)),y.multiplyScalar(.5*(M+P));const D=new i.Vector3,b=new i.Vector3,x=new i.Matrix3;D.add(O).add(N).add(y),b.x=_-w,b.y=L-v,b.z=P-M,b.multiplyScalar(.5),x.copy(S);const{x:U,y:B,z:V}=b,Y=new i.Matrix4;Y.makeScale(2*U,2*B,2*V);const G=new i.Matrix4;G.makeTranslation(-U,-B,-V);const z=new i.Matrix4;z.makeTranslation(D.x,D.y,D.z);const k=new i.Matrix4;k.setFromMatrix3(x);const H=new i.Matrix4;return H.multiply(z),H.multiply(k),H.multiply(G),H.multiply(Y),{center:D,halfSizes:b,rotation:x,transformation:H}}function Yi(e,t,i){const s=[e[0]-t[0],e[1]-t[1],e[2]-t[2]];return i[0]*s[0]+i[1]*s[1]+i[2]*s[2]>0}class Gi{static isTransparent(e){return e.transparent&&e.opacity<1}}const zi=class e{static create(){const t=4294967295*Math.random()|0,i=4294967295*Math.random()|0,s=4294967295*Math.random()|0,n=4294967295*Math.random()|0;return`${e._lut[255&t]+e._lut[t>>8&255]+e._lut[t>>16&255]+e._lut[t>>24&255]}-${e._lut[255&i]}${e._lut[i>>8&255]}-${e._lut[i>>16&15|64]}${e._lut[i>>24&255]}-${e._lut[63&s|128]}${e._lut[s>>8&255]}-${e._lut[s>>16&255]}${e._lut[s>>24&255]}${e._lut[255&n]}${e._lut[n>>8&255]}${e._lut[n>>16&255]}${e._lut[n>>24&255]}`.toLowerCase()}static validate(t){if(!e._pattern.test(t))throw new Error(`${t} 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.`)}};t(zi,"_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}$/),t(zi,"_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 ki=zi;class Hi extends ui{constructor(e,i){super(e),t(this,"onDisposed",new ci),t(this,"onVertexFound",new ci),t(this,"onVertexLost",new ci),t(this,"onEnabled",new ci),t(this,"components"),t(this,"workingPlane",null),t(this,"_pickedPoint",null),t(this,"_config"),t(this,"_enabled",!1),this.components=e,this.config={snapDistance:.25,showOnlyVertex:!1,...i},this.enabled=!1}set enabled(e){this._enabled=e,e||(this._pickedPoint=null),this.onEnabled.trigger(e)}get enabled(){return this._enabled}set config(e){this._config={...this._config,...e}}get config(){return this._config}dispose(){this.onVertexFound.reset(),this.onVertexLost.reset(),this.components=null,this.onDisposed.trigger(),this.onDisposed.reset()}get(e){if(!this.enabled)return this._pickedPoint;const t=this.components.get(Wn).get(e).castRay();if(!t)return null!==this._pickedPoint&&(this.onVertexLost.trigger(),this._pickedPoint=null),this._pickedPoint;const i=this.getClosestVertex(t);if(!i)return null!==this._pickedPoint&&(this.onVertexLost.trigger(),this._pickedPoint=null),this._pickedPoint;return!this.workingPlane||Math.abs(this.workingPlane.distanceToPoint(i))<.001?(null!==this._pickedPoint&&this._pickedPoint.equals(i)||(this._pickedPoint=i.clone(),this.onVertexFound.trigger(this._pickedPoint)),this._pickedPoint):(this._pickedPoint=null,this._pickedPoint)}getClosestVertex(e){let t=new i.Vector3,s=!1,n=Number.MAX_SAFE_INTEGER;const r=this.getVertices(e);if(null===r)return null;for(const i of r){if(!i)continue;const r=e.point.distanceTo(i);r>n||r>this._config.snapDistance||(s=!0,t=i,n=e.point.distanceTo(i))}return s?t:this.config.showOnlyVertex?null:e.point}getVertices(e){const t=e.object;if(!e.face||!t)return null;const s=t.geometry,n=new i.Matrix4,{instanceId:r}=e,o=void 0!==r,a=t instanceof i.InstancedMesh;return a&&o&&t.getMatrixAt(r,n),[this.getVertex(e.face.a,s),this.getVertex(e.face.b,s),this.getVertex(e.face.c,s)].map((e=>(e&&(a&&o&&e.applyMatrix4(n),e.applyMatrix4(t.matrixWorld)),e)))}getVertex(e,t){if(void 0===e)return null;const s=t.attributes.position;return new i.Vector3(s.getX(e),s.getY(e),s.getZ(e))}}var Wi="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Xi(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Zi={exports:{}};function $i(e,t,i){i=i||2;var s,n,r,o,a,c,l,h=t&&t.length,u=h?t[0]*i:e.length,I=ji(e,0,u,i,!0),d=[];if(!I||I.next===I.prev)return d;if(h&&(I=function(e,t,i,s){var n,r,o,a=[];for(n=0,r=t.length;n<r;n++)(o=ji(e,t[n]*s,n<r-1?t[n+1]*s:e.length,s,!1))===o.next&&(o.steiner=!0),a.push(os(o));for(a.sort(is),n=0;n<a.length;n++)i=ss(a[n],i);return i}(e,t,I,i)),e.length>80*i){s=r=e[0],n=o=e[1];for(var E=i;E<u;E+=i)(a=e[E])<s&&(s=a),(c=e[E+1])<n&&(n=c),a>r&&(r=a),c>o&&(o=c);l=0!==(l=Math.max(r-s,o-n))?32767/l:0}return Qi(I,d,i,s,n,l,0),d}function ji(e,t,i,s,n){var r,o;if(n===ms(e,t,i,s)>0)for(r=t;r<i;r+=s)o=ps(r,e[r],e[r+1],o);else for(r=i-s;r>=t;r-=s)o=ps(r,e[r],e[r+1],o);return o&&hs(o,o.next)&&(Cs(o),o=o.next),o}function qi(e,t){if(!e)return e;t||(t=e);var i,s=e;do{if(i=!1,s.steiner||!hs(s,s.next)&&0!==ls(s.prev,s,s.next))s=s.next;else{if(Cs(s),(s=t=s.prev)===s.next)break;i=!0}}while(i||s!==t);return t}function Qi(e,t,i,s,n,r,o){if(e){!o&&r&&function(e,t,i,s){var n=e;do{0===n.z&&(n.z=rs(n.x,n.y,t,i,s)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next}while(n!==e);n.prevZ.nextZ=null,n.prevZ=null,function(e){var t,i,s,n,r,o,a,c,l=1;do{for(i=e,e=null,r=null,o=0;i;){for(o++,s=i,a=0,t=0;t<l&&(a++,s=s.nextZ);t++);for(c=l;a>0||c>0&&s;)0!==a&&(0===c||!s||i.z<=s.z)?(n=i,i=i.nextZ,a--):(n=s,s=s.nextZ,c--),r?r.nextZ=n:e=n,n.prevZ=r,r=n;i=s}r.nextZ=null,l*=2}while(o>1)}(n)}(e,s,n,r);for(var a,c,l=e;e.prev!==e.next;)if(a=e.prev,c=e.next,r?Ji(e,s,n,r):Ki(e))t.push(a.i/i|0),t.push(e.i/i|0),t.push(c.i/i|0),Cs(e),e=c.next,l=c.next;else if((e=c)===l){o?1===o?Qi(e=es(qi(e),t,i),t,i,s,n,r,2):2===o&&ts(e,t,i,s,n,r):Qi(qi(e),t,i,s,n,r,1);break}}}function Ki(e){var t=e.prev,i=e,s=e.next;if(ls(t,i,s)>=0)return!1;for(var n=t.x,r=i.x,o=s.x,a=t.y,c=i.y,l=s.y,h=n<r?n<o?n:o:r<o?r:o,u=a<c?a<l?a:l:c<l?c:l,I=n>r?n>o?n:o:r>o?r:o,d=a>c?a>l?a:l:c>l?c:l,E=s.next;E!==t;){if(E.x>=h&&E.x<=I&&E.y>=u&&E.y<=d&&as(n,a,r,c,o,l,E.x,E.y)&&ls(E.prev,E,E.next)>=0)return!1;E=E.next}return!0}function Ji(e,t,i,s){var n=e.prev,r=e,o=e.next;if(ls(n,r,o)>=0)return!1;for(var a=n.x,c=r.x,l=o.x,h=n.y,u=r.y,I=o.y,d=a<c?a<l?a:l:c<l?c:l,E=h<u?h<I?h:I:u<I?u:I,f=a>c?a>l?a:l:c>l?c:l,p=h>u?h>I?h:I:u>I?u:I,C=rs(d,E,t,i,s),T=rs(f,p,t,i,s),m=e.prevZ,R=e.nextZ;m&&m.z>=C&&R&&R.z<=T;){if(m.x>=d&&m.x<=f&&m.y>=E&&m.y<=p&&m!==n&&m!==o&&as(a,h,c,u,l,I,m.x,m.y)&&ls(m.prev,m,m.next)>=0)return!1;if(m=m.prevZ,R.x>=d&&R.x<=f&&R.y>=E&&R.y<=p&&R!==n&&R!==o&&as(a,h,c,u,l,I,R.x,R.y)&&ls(R.prev,R,R.next)>=0)return!1;R=R.nextZ}for(;m&&m.z>=C;){if(m.x>=d&&m.x<=f&&m.y>=E&&m.y<=p&&m!==n&&m!==o&&as(a,h,c,u,l,I,m.x,m.y)&&ls(m.prev,m,m.next)>=0)return!1;m=m.prevZ}for(;R&&R.z<=T;){if(R.x>=d&&R.x<=f&&R.y>=E&&R.y<=p&&R!==n&&R!==o&&as(a,h,c,u,l,I,R.x,R.y)&&ls(R.prev,R,R.next)>=0)return!1;R=R.nextZ}return!0}function es(e,t,i){var s=e;do{var n=s.prev,r=s.next.next;!hs(n,r)&&us(n,s,s.next,r)&&Es(n,r)&&Es(r,n)&&(t.push(n.i/i|0),t.push(s.i/i|0),t.push(r.i/i|0),Cs(s),Cs(s.next),s=e=r),s=s.next}while(s!==e);return qi(s)}function ts(e,t,i,s,n,r){var o=e;do{for(var a=o.next.next;a!==o.prev;){if(o.i!==a.i&&cs(o,a)){var c=fs(o,a);return o=qi(o,o.next),c=qi(c,c.next),Qi(o,t,i,s,n,r,0),void Qi(c,t,i,s,n,r,0)}a=a.next}o=o.next}while(o!==e)}function is(e,t){return e.x-t.x}function ss(e,t){var i=function(e,t){var i,s=t,n=e.x,r=e.y,o=-1/0;do{if(r<=s.y&&r>=s.next.y&&s.next.y!==s.y){var a=s.x+(r-s.y)*(s.next.x-s.x)/(s.next.y-s.y);if(a<=n&&a>o&&(o=a,i=s.x<s.next.x?s:s.next,a===n))return i}s=s.next}while(s!==t);if(!i)return null;var c,l=i,h=i.x,u=i.y,I=1/0;s=i;do{n>=s.x&&s.x>=h&&n!==s.x&&as(r<u?n:o,r,h,u,r<u?o:n,r,s.x,s.y)&&(c=Math.abs(r-s.y)/(n-s.x),Es(s,e)&&(c<I||c===I&&(s.x>i.x||s.x===i.x&&ns(i,s)))&&(i=s,I=c)),s=s.next}while(s!==l);return i}(e,t);if(!i)return t;var s=fs(i,e);return qi(s,s.next),qi(i,i.next)}function ns(e,t){return ls(e.prev,e,t.prev)<0&&ls(t.next,e,e.next)<0}function rs(e,t,i,s,n){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-i)*n|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-s)*n|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function os(e){var t=e,i=e;do{(t.x<i.x||t.x===i.x&&t.y<i.y)&&(i=t),t=t.next}while(t!==e);return i}function as(e,t,i,s,n,r,o,a){return(n-o)*(t-a)>=(e-o)*(r-a)&&(e-o)*(s-a)>=(i-o)*(t-a)&&(i-o)*(r-a)>=(n-o)*(s-a)}function cs(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){var i=e;do{if(i.i!==e.i&&i.next.i!==e.i&&i.i!==t.i&&i.next.i!==t.i&&us(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}(e,t)&&(Es(e,t)&&Es(t,e)&&function(e,t){var i=e,s=!1,n=(e.x+t.x)/2,r=(e.y+t.y)/2;do{i.y>r!=i.next.y>r&&i.next.y!==i.y&&n<(i.next.x-i.x)*(r-i.y)/(i.next.y-i.y)+i.x&&(s=!s),i=i.next}while(i!==e);return s}(e,t)&&(ls(e.prev,e,t.prev)||ls(e,t.prev,t))||hs(e,t)&&ls(e.prev,e,e.next)>0&&ls(t.prev,t,t.next)>0)}function ls(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function hs(e,t){return e.x===t.x&&e.y===t.y}function us(e,t,i,s){var n=ds(ls(e,t,i)),r=ds(ls(e,t,s)),o=ds(ls(i,s,e)),a=ds(ls(i,s,t));return n!==r&&o!==a||(!(0!==n||!Is(e,i,t))||(!(0!==r||!Is(e,s,t))||(!(0!==o||!Is(i,e,s))||!(0!==a||!Is(i,t,s)))))}function Is(e,t,i){return t.x<=Math.max(e.x,i.x)&&t.x>=Math.min(e.x,i.x)&&t.y<=Math.max(e.y,i.y)&&t.y>=Math.min(e.y,i.y)}function ds(e){return e>0?1:e<0?-1:0}function Es(e,t){return ls(e.prev,e,e.next)<0?ls(e,t,e.next)>=0&&ls(e,e.prev,t)>=0:ls(e,t,e.prev)<0||ls(e,e.next,t)<0}function fs(e,t){var i=new Ts(e.i,e.x,e.y),s=new Ts(t.i,t.x,t.y),n=e.next,r=t.prev;return e.next=t,t.prev=e,i.next=n,n.prev=i,s.next=i,i.prev=s,r.next=s,s.prev=r,s}function ps(e,t,i,s){var n=new Ts(e,t,i);return s?(n.next=s.next,n.prev=s,s.next.prev=n,s.next=n):(n.prev=n,n.next=n),n}function Cs(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function Ts(e,t,i){this.i=e,this.x=t,this.y=i,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function ms(e,t,i,s){for(var n=0,r=t,o=i-s;r<i;r+=s)n+=(e[o]-e[r])*(e[r+1]+e[o+1]),o=r;return n}Zi.exports=$i,Zi.exports.default=$i,$i.deviation=function(e,t,i,s){var n=t&&t.length,r=n?t[0]*i:e.length,o=Math.abs(ms(e,0,r,i));if(n)for(var a=0,c=t.length;a<c;a++){var l=t[a]*i,h=a<c-1?t[a+1]*i:e.length;o-=Math.abs(ms(e,l,h,i))}var u=0;for(a=0;a<s.length;a+=3){var I=s[a]*i,d=s[a+1]*i,E=s[a+2]*i;u+=Math.abs((e[I]-e[E])*(e[d+1]-e[I+1])-(e[I]-e[d])*(e[E+1]-e[I+1]))}return 0===o&&0===u?0:Math.abs((u-o)/o)},$i.flatten=function(e){for(var t=e[0][0].length,i={vertices:[],holes:[],dimensions:t},s=0,n=0;n<e.length;n++){for(var r=0;r<e[n].length;r++)for(var o=0;o<t;o++)i.vertices.push(e[n][r][o]);n>0&&(s+=e[n-1].length,i.holes.push(s))}return i};const Rs=Xi(Zi.exports);class gs extends ui{constructor(){super(...arguments),t(this,"enabled",!0),t(this,"_inverseMatrix",new i.Matrix4),t(this,"_localPlane",new i.Plane),t(this,"_tempLine",new i.Line3),t(this,"_tempVector",new i.Vector3),t(this,"_plane"),t(this,"_plane2DCoordinateSystem",new i.Matrix4),t(this,"_precission",1e4),t(this,"_planeAxis")}get plane(){if(!this._plane)throw new Error("Plane not set");return this._plane}set plane(e){this._plane=e}createEdges(e){const{meshes:t,posAttr:s}=e;let n=0;s.array.fill(0);const r=[];let o=0;const a=new i.Mesh;for(const e of t)if(e.geometry){if(e.geometry.boundsTree||e.geometry.computeBoundsTree(),!e.geometry.boundsTree)throw new Error("Bounds tree not found for edges generation.");if(e instanceof i.InstancedMesh){if(0===e.count)continue;const t=e;for(let c=0;c<t.count;c++){a.geometry=e.geometry,a.matrix.copy(e.matrix);const l=new i.Matrix4;t.getMatrixAt(c,l),a.applyMatrix4(l),a.applyMatrix4(e.matrixWorld),a.updateMatrix(),a.updateMatrixWorld(),this._inverseMatrix.copy(a.matrixWorld).invert(),this._localPlane.copy(this.plane).applyMatrix4(this._inverseMatrix),n=this.shapecast(a,s,n),n!==o&&(r.push(n),o=n)}}else this._inverseMatrix.copy(e.matrixWorld).invert(),this._localPlane.copy(this.plane).applyMatrix4(this._inverseMatrix),n=this.shapecast(e,s,n),n!==o&&(r.push(n),o=n)}return{indexes:r,index:n}}createFills(e,t){this.updatePlane2DCoordinateSystem();const i=[];let s=0;for(let n=0;n<t.length;n++){const r=t[n],o=[];for(let e=s;e<r;e+=2)o.push(3*e);const a=this.computeFill(o,e);for(const e of a)i.push(e);s=r}return i}computeFill(e,t){const i=new Map,s={},n=new Map;let r=0;const o=new Map,a=new Map,c=new Set,l=this._precission;for(let h=0;h<e.length;h++){const u=e[h];let I=0,d=0,E=0,f=0;const p=t[u],C=t[u+1],T=t[u+2],m=t[u+3],R=t[u+4],g=t[u+5];if(this._tempVector.set(p,C,T),this._tempVector.applyMatrix4(this._plane2DCoordinateSystem),I=Math.trunc(this._tempVector.x*l)/l,d=Math.trunc(this._tempVector.y*l)/l,this._tempVector.set(m,R,g),this._tempVector.applyMatrix4(this._plane2DCoordinateSystem),E=Math.trunc(this._tempVector.x*l)/l,f=Math.trunc(this._tempVector.y*l)/l,I===E&&d===f)continue;const A=`${I}|${d}`,F=`${E}|${f}`;i.has(A)||i.set(A,u/3),i.has(F)||i.set(F,u/3+1);const S=i.get(A),O=i.get(F);s[S]=[I,d],s[O]=[E,f];const N=a.has(S),y=o.has(S),_=a.has(O),L=o.has(O);if(!(N||y||_||L))a.set(S,r),o.set(O,r),c.add(r),n.set(r,[S,O]),r++;else if(N&&L){const e=a.get(S),t=o.get(O);if(e!==t){const i=n.get(t),s=n.get(e);if(!i||!s)continue;n.delete(e),c.delete(e),o.set(s[s.length-1],t),o.delete(i[i.length-1]);for(const e of s)i.push(e)}else c.delete(t);a.delete(S),o.delete(O)}else if(y&&_){const e=a.get(O),t=o.get(S);if(e!==t){const i=n.get(t),s=n.get(e);if(!i||!s)continue;n.delete(e),c.delete(e),o.set(s[s.length-1],t),o.delete(i[i.length-1]);for(const e of s)i.push(e)}else c.delete(t);a.delete(O),o.delete(S)}else if(N&&_){const e=a.get(O),t=a.get(S),i=n.get(t),s=n.get(e);if(!i||!s)continue;n.delete(e),c.delete(e),a.delete(i[0]),a.delete(s[0]),o.delete(s[s.length-1]),a.set(s[s.length-1],t),s.reverse(),i.splice(0,0,...s)}else if(y&&L){const e=o.get(O),t=o.get(S),i=n.get(t),s=n.get(e);if(!i||!s)continue;n.delete(e),c.delete(e),o.delete(i[i.length-1]),o.delete(s[s.length-1]),a.delete(s[0]),o.set(s[0],t),s.reverse(),i.push(...s)}else if(N){const e=a.get(S),t=n.get(e);if(!t)continue;t.unshift(O),a.delete(S),a.set(O,e)}else if(y){const e=o.get(S),t=n.get(e);if(!t)continue;t.push(O),o.delete(S),o.set(O,e)}else if(_){const e=a.get(O),t=n.get(e);if(!t)continue;t.unshift(S),a.delete(O),a.set(S,e)}else if(L){const e=o.get(O),t=n.get(e);if(!t)continue;t.push(S),o.delete(O),o.set(S,e)}}const h=[];for(const[e,t]of n){if(c.has(e))continue;const i=[],n=new Map;let r=0;for(const e of t){const t=s[e];i.push(t[0],t[1]),n.set(r++,e)}const o=Rs(i);for(const e of o){const t=n.get(e);if(void 0===t)throw new Error("Map error!");h.push(t)}}return h}updatePlane2DCoordinateSystem(){this._plane2DCoordinateSystem=new i.Matrix4;const e=new i.Vector3(1,0,0),t=new i.Vector3(0,1,0),s=this.plane.normal,n=new i.Vector3;this.plane.coplanarPoint(n),"x"===this._planeAxis?e.crossVectors(t,s):"y"===this._planeAxis?t.crossVectors(s,e):"z"===this._planeAxis||(e.crossVectors(t,s).normalize(),t.crossVectors(s,e)),this._plane2DCoordinateSystem.fromArray([e.x,e.y,e.z,0,t.x,t.y,t.z,0,s.x,s.y,s.z,0,n.x,n.y,n.z,1]),this._plane2DCoordinateSystem.invert()}shapecast(e,t,i){return e.geometry.boundsTree.shapecast({intersectsBounds:e=>this._localPlane.intersectsBox(e),intersectsTriangle:s=>{let n=0;if(this._tempLine.start.copy(s.a),this._tempLine.end.copy(s.b),this._localPlane.intersectLine(this._tempLine,this._tempVector)){const s=this._tempVector.applyMatrix4(e.matrixWorld);t.setXYZ(i,s.x,s.y,s.z),n++,i++}if(this._tempLine.start.copy(s.b),this._tempLine.end.copy(s.c),this._localPlane.intersectLine(this._tempLine,this._tempVector)){const s=this._tempVector.applyMatrix4(e.matrixWorld);t.setXYZ(i,s.x,s.y,s.z),n++,i++}if(this._tempLine.start.copy(s.c),this._tempLine.end.copy(s.a),this._localPlane.intersectLine(this._tempLine,this._tempVector)){const s=this._tempVector.applyMatrix4(e.matrixWorld);t.setXYZ(i,s.x,s.y,s.z),n++,i++}2!==n&&(i-=n)}}),i}}t(gs,"uuid","1a193b87-6376-46c8-9e65-62a1576fdb64");const As=class e{constructor(){t(this,"onDisposed",new ci),t(this,"list",new Map),t(this,"enabled",!1),t(this,"_clock"),t(this,"onInit",new ci),t(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 i.Clock,e.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.");ki.validate(e),this.list.set(e,t)}get(e){const t=e.uuid;if(!this.list.has(t)){const i=new e(this);return this.list.has(t)||this.add(t,i),i}return this.list.get(t)}init(){this.enabled=!0,this._clock.start(),this.update(),this.onInit.trigger()}dispose(){this.enabled=!1;for(const[e,t]of this.list)t.enabled=!1,t.isDisposeable()&&t.dispose();this._clock.stop(),this.onDisposed.trigger(),this.onDisposed.reset()}static setupBVH(){i.BufferGeometry.prototype.computeBoundsTree=oi,i.BufferGeometry.prototype.disposeBoundsTree=ai,i.Mesh.prototype.raycast=ri}};t(As,"release","2.4.10");let Fs=As;class Ss extends hi{constructor(){super(...arguments),t(this,"meshes",new Set),t(this,"onAfterUpdate",new ci),t(this,"onBeforeUpdate",new ci),t(this,"onDisposed",new ci),t(this,"isDisposing",!1),t(this,"enabled",!0),t(this,"uuid",ki.create()),t(this,"name"),t(this,"_scene"),t(this,"_camera"),t(this,"_renderer",null)}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=e,e.worlds.set(this.uuid,this),e.currentWorld=this,e.onWorldChanged.trigger({world:this,action:"added"})}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"}))}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 e=this.components.get(pi);this.scene.dispose(),this.camera.isDisposeable()&&this.camera.dispose(),this.renderer&&this.renderer.dispose();for(const t of this.meshes)e.destroy(t);this.meshes.clear()}this._scene=null,this._camera=null,this._renderer=null;this.components.get(vn).list.delete(this.uuid),this.onDisposed.trigger(),this.onDisposed.reset()}}class Os{constructor(e,i,s,n){t(this,"_component"),t(this,"name"),t(this,"uuid"),this._component=e,this.name=s,this.uuid=n??ki.create();i.get(ys).list.set(this.uuid,this)}get controls(){return gi.copySchema(this._config)}set(e){for(const t in e)if(t in this){this[t]=e[t].value}}export(e=this._config,t={}){for(const i in e){const s=e[i];if(gi.isEntry(s))if("Color"===s.type){const{r:e,g:n,b:r}=s.value;t[i]={...s,value:{r:e,g:n,b:r}}}else if("Vector3"===s.type){const{x:e,y:n,z:r}=s.value;t[i]={...s,value:{x:e,y:n,z:r}}}else if("TextSet"===s.type){const e=Array.from(s.value);t[i]={...s,value:e}}else if("Select"===s.type){const e=Array.from(s.options);t[i]={...s,options:e}}else t[i]={...s};else t[i]={},this.export(s,t[i])}return t}import(e,t={},s=!0){for(const s in e){const n=e[s];if(gi.isEntry(n))if("Color"===n.type){const{r:e,g:r,b:o}=n.value;t[s]={...n,value:new i.Color(e,r,o)}}else if("Vector3"===n.type){const{x:e,y:r,z:o}=n.value;t[s]={...n,value:new i.Vector3(e,r,o)}}else"TextSet"===n.type?t[s]={...n,value:new Set(n.value)}:"Select"===n.type?t[s]={...n,options:new Set(n.options)}:t[s]={...n};else t[s]={},this.import(n,t[s],!1)}s&&this.set(t)}}const Ns=class e extends ui{constructor(i){super(i),t(this,"list",new mi),t(this,"enabled",!0),i.add(e.uuid,this)}};t(Ns,"uuid","b8c764e0-6b24-4e77-9a32-35fa728ee5b4");let ys=Ns;class _s{constructor(e,i){t(this,"_list"),t(this,"_scene"),this._list=e,this._scene=i}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 Ls{constructor(e,i){t(this,"_list"),t(this,"_scene"),this._list=e,this._scene=i}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 Ps extends Os{constructor(){super(...arguments),t(this,"_config",{backgroundColor:{value:new i.Color,type:"Color"},ambientLight:{color:{type:"Color",value:new i.Color},intensity:{type:"Number",interpolable:!0,min:0,max:10,value:2}},directionalLight:{color:{type:"Color",value:new i.Color},intensity:{type:"Number",interpolable:!0,min:0,max:10,value:2},position:{type:"Vector3",value:new i.Vector3}}}),t(this,"ambientLight",new Ls(this._config,this._component)),t(this,"directionalLight",new _s(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 ws extends Ci{constructor(e){super(e),t(this,"onSetup",new ci),t(this,"isSetup",!1),t(this,"three"),t(this,"config",new Ps(this,this.components,"Scene")),t(this,"_defaultConfig",{backgroundColor:new i.Color(2107698),directionalLight:{color:new i.Color("white"),intensity:1.5,position:new i.Vector3(5,10,3)},ambientLight:{color:new i.Color("white"),intensity:1}}),this.three=new i.Scene,this.three.background=new i.Color(2107698)}setup(e){const t={...this._defaultConfig,...e};this.config.backgroundColor=t.backgroundColor;const s=t.ambientLight;this.config.ambientLight.color=s.color,this.config.ambientLight.intensity=s.intensity;const n=t.directionalLight;this.config.directionalLight.color=n.color,this.config.directionalLight.intensity=n.intensity,this.config.directionalLight.position=n.position,this.deleteAllLights();const{color:r,intensity:o}=this.config.directionalLight,a=new i.DirectionalLight(r,o);a.position.copy(n.position);const{color:c,intensity:l}=this.config.directionalLight,h=new i.AmbientLight(c,l);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(ys).list.delete(this.config.uuid)}}class vs extends Ei{constructor(e,s,n){super(e),t(this,"enabled",!0),t(this,"container"),t(this,"three"),t(this,"_canvas"),t(this,"_parameters"),t(this,"_resizeObserver",null),t(this,"onContainerUpdated",new ci),t(this,"_resizing",!1),t(this,"resize",(e=>{if(this._resizing)return;this._resizing=!0,this.onContainerUpdated.trigger();const t=e?e.x:this.container.clientWidth,s=e?e.y:this.container.clientHeight;this.three.setSize(t,s),this.onResize.trigger(new i.Vector2(t,s)),this._resizing=!1})),t(this,"resizeEvent",(()=>{this.resize()})),t(this,"onContextLost",(e=>{e.preventDefault(),this.enabled=!1})),t(this,"onContextBack",(()=>{this.three.setRenderTarget(null),this.three.dispose(),this.three=new i.WebGLRenderer({canvas:this._canvas,antialias:!0,alpha:!0,...this._parameters}),this.enabled=!0})),this.container=s,this._parameters=n,this.three=new i.WebGLRenderer({antialias:!0,alpha:!0,...n}),this.three.setPixelRatio(Math.min(window.devicePixelRatio,2)),this.setupRenderer(),this.setupEvents(!0),this.resize(),this._canvas=this.three.domElement;const r=this.three.getContext(),{canvas:o}=r;o.addEventListener("webglcontextlost",this.onContextLost,!1),o.addEventListener("webglcontextrestored",this.onContextBack,!1)}update(){if(!this.enabled||!this.currentWorld)return;this.onBeforeUpdate.trigger(this);const e=this.currentWorld.scene.three,t=this.currentWorld.camera.three;this.three.render(e,t),this.onAfterUpdate.trigger(this)}dispose(){this.enabled=!1,this.setupEvents(!1),this.three.domElement.remove(),this.three.forceContextLoss(),this.three.dispose(),this.onResize.reset(),this.onAfterUpdate.reset(),this.onBeforeUpdate.reset(),this.onDisposed.trigger(),this.onDisposed.reset()}getSize(){return new i.Vector2(this.three.domElement.clientWidth,this.three.domElement.clientHeight)}setupEvents(e){const t=this.three.domElement.parentElement;if(!t)throw new Error("This renderer needs to have an HTML container!");this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=null),window.removeEventListener("resize",this.resizeEvent),e&&(this._resizeObserver=new ResizeObserver(this.resizeEvent),this._resizeObserver.observe(t),window.addEventListener("resize",this.resizeEvent))}setupRenderer(){this.three.localClippingEnabled=!0,this.container&&this.container.appendChild(this.three.domElement),this.onContainerUpdated.trigger()}}
|
|
1
|
+
var t=Object.defineProperty,e=(e,i,s)=>(((e,i,s)=>{i in e?t(e,i,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[i]=s})(e,"symbol"!=typeof i?i+"":i,s),s);import*as i from"@thatopen/fragments";import{DataMap as s,FragmentsModels as n}from"@thatopen/fragments";import*as r from"three";import{BufferAttribute as o,Vector3 as a,Plane as l,Line3 as h,Vector2 as c,Triangle as d,Sphere as u,Matrix4 as p,Box3 as f,BackSide as m,DoubleSide as g,FrontSide as _,Ray as y,Mesh as w,Controls as v,Quaternion as b,Raycaster as x,Object3D as E,MeshBasicMaterial as T,LineBasicMaterial as C,CylinderGeometry as S,BoxGeometry as A,BufferGeometry as O,Float32BufferAttribute as P,OctahedronGeometry as I,Line as k,TorusGeometry as D,SphereGeometry as z,Euler as M,PlaneGeometry as B}from"three";import*as N from"web-ifc";class U{constructor(){e(this,"enabled",!0),e(this,"trigger",t=>{if(!this.enabled)return;const e=this.handlers.slice(0);for(const i of e)i(t)}),e(this,"handlers",[])}add(t){this.handlers.push(t)}remove(t){this.handlers=this.handlers.filter(e=>e!==t)}reset(){this.handlers.length=0}}class L{constructor(){e(this,"enabled",!0),e(this,"trigger",async t=>{if(!this.enabled)return;const e=this.handlers.slice(0);for(const i of e)await i(t)}),e(this,"handlers",[])}add(t){this.handlers.push(t)}remove(t){this.handlers=this.handlers.filter(e=>e!==t)}reset(){this.handlers.length=0}}class R{constructor(t){e(this,"isDisposeable",()=>"dispose"in this&&"onDisposed"in this),e(this,"isResizeable",()=>"resize"in this&&"getSize"in this),e(this,"isUpdateable",()=>"onAfterUpdate"in this&&"onBeforeUpdate"in this&&"update"in this),e(this,"isHideable",()=>"visible"in this),e(this,"isConfigurable",()=>"setup"in this&&"config"in this&&"onSetup"in this),this.components=t}}class F extends R{}class V extends R{constructor(t){super(t),e(this,"worlds",new s),e(this,"onWorldChanged",new U),e(this,"_currentWorld",null),this.onWorldChanged.add(({world:t,action:e})=>{"removed"===e&&this.worlds.delete(t.uuid)})}set currentWorld(t){this._currentWorld=t}get currentWorld(){return this._currentWorld}}class j extends V{constructor(){super(...arguments),e(this,"hasCameraControls",()=>"controls"in this)}}class Z extends V{constructor(){super(...arguments),e(this,"onAfterUpdate",new U),e(this,"onBeforeUpdate",new U),e(this,"onDisposed",new U),e(this,"onResize",new U),e(this,"onClippingPlanesUpdated",new U),e(this,"clippingPlanes",[])}updateClippingPlanes(){this.onClippingPlanesUpdated.trigger()}setPlane(t,e,i){e.isLocal=i;const s=this.clippingPlanes.indexOf(e);t&&-1===s?this.clippingPlanes.push(e):!t&&s>-1&&this.clippingPlanes.splice(s,1),this.three.clippingPlanes=this.clippingPlanes.filter(t=>!t.isLocal)}}const H=class t extends F{constructor(i){super(i),e(this,"_disposedComponents",new Set),e(this,"enabled",!0),i.add(t.uuid,this)}get(){return this._disposedComponents}destroy(t,e=!0,i=!0){t.removeFromParent();const s=t;s.dispose&&s.dispose(),this.disposeGeometryAndMaterials(t,e),i&&s.children&&s.children.length&&this.disposeChildren(s),t.children.length=0}disposeGeometry(t){t.boundsTree&&t.disposeBoundsTree&&t.disposeBoundsTree(),t.dispose()}disposeGeometryAndMaterials(e,i){const s=e;s.geometry&&this.disposeGeometry(s.geometry),i&&s.material&&t.disposeMaterial(s),s.material=[],s.geometry=null}disposeChildren(t){for(const e of t.children)this.destroy(e)}static disposeMaterial(t){if(t.material)if(Array.isArray(t.material))for(const e of t.material)e.dispose();else t.material.dispose()}};e(H,"uuid","76e9cd8e-ad8f-4753-9ef6-cbc60f7247fe");let $=H;class W extends V{constructor(t){super(t),e(this,"onDisposed",new U),e(this,"directionalLights",new Map),e(this,"ambientLights",new Map)}dispose(){const t=this.components.get($);for(const e of this.three.children){const i=e;i.geometry&&t.destroy(i)}this.deleteAllLights(),this.three.children=[],this.onDisposed.trigger(),this.onDisposed.reset()}deleteAllLights(){for(const[,t]of this.directionalLights)t.removeFromParent(),t.target.removeFromParent(),t.dispose();this.directionalLights.clear();for(const[,t]of this.ambientLights)t.removeFromParent(),t.dispose();this.ambientLights.clear()}}class Y extends Set{constructor(t){super(t),e(this,"onItemAdded",new U),e(this,"onItemDeleted",new U),e(this,"onCleared",new U),e(this,"guard",()=>!0)}clear(){super.clear(),this.onCleared.trigger()}add(...t){for(const e of t){if(this.has(e))continue;this.guard(e)&&(super.add(e),this.onItemAdded||(this.onItemAdded=new U),this.onItemAdded.trigger(e))}return this}delete(t){const e=super.delete(t);return e&&this.onItemDeleted.trigger(),e}dispose(){this.clear(),this.onItemAdded.reset(),this.onItemDeleted.reset(),this.onCleared.reset()}}const X=class t{static create(){const e=4294967295*Math.random()|0,i=4294967295*Math.random()|0,s=4294967295*Math.random()|0,n=4294967295*Math.random()|0;return`${t._lut[255&e]+t._lut[e>>8&255]+t._lut[e>>16&255]+t._lut[e>>24&255]}-${t._lut[255&i]}${t._lut[i>>8&255]}-${t._lut[i>>16&15|64]}${t._lut[i>>24&255]}-${t._lut[63&s|128]}${t._lut[s>>8&255]}-${t._lut[s>>16&255]}${t._lut[s>>24&255]}${t._lut[255&n]}${t._lut[n>>8&255]}${t._lut[n>>16&255]}${t._lut[n>>24&255]}`.toLowerCase()}static validate(e){if(!t._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.`)}};e(X,"_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}$/),e(X,"_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 q=X;var G="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Q(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var K={},J={};!function(t){const e=":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",i="["+e+"]["+(e+"\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040")+"]*",s=new RegExp("^"+i+"$");t.isExist=function(t){return void 0!==t},t.isEmptyObject=function(t){return 0===Object.keys(t).length},t.merge=function(t,e,i){if(e){const s=Object.keys(e),n=s.length;for(let r=0;r<n;r++)t[s[r]]="strict"===i?[e[s[r]]]:e[s[r]]}},t.getValue=function(e){return t.isExist(e)?e:""},t.isName=function(t){const e=s.exec(t);return!(null==e)},t.getAllMatches=function(t,e){const i=[];let s=e.exec(t);for(;s;){const n=[];n.startIndex=e.lastIndex-s[0].length;const r=s.length;for(let t=0;t<r;t++)n.push(s[t]);i.push(n),s=e.exec(t)}return i},t.nameRegexp=i}(J);const tt=J,et={allowBooleanAttributes:!1,unpairedTags:[]};function it(t){return" "===t||"\t"===t||"\n"===t||"\r"===t}function st(t,e){const i=e;for(;e<t.length;e++)if("?"==t[e]||" "==t[e]){const s=t.substr(i,e-i);if(e>5&&"xml"===s)return dt("InvalidXml","XML declaration allowed only at the start of the document.",ft(t,e));if("?"==t[e]&&">"==t[e+1]){e++;break}continue}return e}function nt(t,e){if(t.length>e+5&&"-"===t[e+1]&&"-"===t[e+2]){for(e+=3;e<t.length;e++)if("-"===t[e]&&"-"===t[e+1]&&">"===t[e+2]){e+=2;break}}else if(t.length>e+8&&"D"===t[e+1]&&"O"===t[e+2]&&"C"===t[e+3]&&"T"===t[e+4]&&"Y"===t[e+5]&&"P"===t[e+6]&&"E"===t[e+7]){let i=1;for(e+=8;e<t.length;e++)if("<"===t[e])i++;else if(">"===t[e]&&(i--,0===i))break}else if(t.length>e+9&&"["===t[e+1]&&"C"===t[e+2]&&"D"===t[e+3]&&"A"===t[e+4]&&"T"===t[e+5]&&"A"===t[e+6]&&"["===t[e+7])for(e+=8;e<t.length;e++)if("]"===t[e]&&"]"===t[e+1]&&">"===t[e+2]){e+=2;break}return e}K.validate=function(t,e){e=Object.assign({},et,e);const i=[];let s=!1,n=!1;"\ufeff"===t[0]&&(t=t.substr(1));for(let r=0;r<t.length;r++)if("<"===t[r]&&"?"===t[r+1]){if(r+=2,r=st(t,r),r.err)return r}else{if("<"!==t[r]){if(it(t[r]))continue;return dt("InvalidChar","char '"+t[r]+"' is not expected.",ft(t,r))}{let o=r;if(r++,"!"===t[r]){r=nt(t,r);continue}{let a=!1;"/"===t[r]&&(a=!0,r++);let l="";for(;r<t.length&&">"!==t[r]&&" "!==t[r]&&"\t"!==t[r]&&"\n"!==t[r]&&"\r"!==t[r];r++)l+=t[r];if(l=l.trim(),"/"===l[l.length-1]&&(l=l.substring(0,l.length-1),r--),!pt(l)){let e;return e=0===l.trim().length?"Invalid space after '<'.":"Tag '"+l+"' is an invalid name.",dt("InvalidTag",e,ft(t,r))}const h=at(t,r);if(!1===h)return dt("InvalidAttr","Attributes for '"+l+"' have open quote.",ft(t,r));let c=h.value;if(r=h.index,"/"===c[c.length-1]){const i=r-c.length;c=c.substring(0,c.length-1);const n=ht(c,e);if(!0!==n)return dt(n.err.code,n.err.msg,ft(t,i+n.err.line));s=!0}else if(a){if(!h.tagClosed)return dt("InvalidTag","Closing tag '"+l+"' doesn't have proper closing.",ft(t,r));if(c.trim().length>0)return dt("InvalidTag","Closing tag '"+l+"' can't have attributes or invalid starting.",ft(t,o));if(0===i.length)return dt("InvalidTag","Closing tag '"+l+"' has not been opened.",ft(t,o));{const e=i.pop();if(l!==e.tagName){let i=ft(t,e.tagStartPos);return dt("InvalidTag","Expected closing tag '"+e.tagName+"' (opened in line "+i.line+", col "+i.col+") instead of closing tag '"+l+"'.",ft(t,o))}0==i.length&&(n=!0)}}else{const a=ht(c,e);if(!0!==a)return dt(a.err.code,a.err.msg,ft(t,r-c.length+a.err.line));if(!0===n)return dt("InvalidXml","Multiple possible root nodes found.",ft(t,r));-1!==e.unpairedTags.indexOf(l)||i.push({tagName:l,tagStartPos:o}),s=!0}for(r++;r<t.length;r++)if("<"===t[r]){if("!"===t[r+1]){r++,r=nt(t,r);continue}if("?"!==t[r+1])break;if(r=st(t,++r),r.err)return r}else if("&"===t[r]){const e=ct(t,r);if(-1==e)return dt("InvalidChar","char '&' is not expected.",ft(t,r));r=e}else if(!0===n&&!it(t[r]))return dt("InvalidXml","Extra text at the end",ft(t,r));"<"===t[r]&&r--}}}return s?1==i.length?dt("InvalidTag","Unclosed tag '"+i[0].tagName+"'.",ft(t,i[0].tagStartPos)):!(i.length>0)||dt("InvalidXml","Invalid '"+JSON.stringify(i.map(t=>t.tagName),null,4).replace(/\r?\n/g,"")+"' found.",{line:1,col:1}):dt("InvalidXml","Start tag expected.",1)};const rt='"',ot="'";function at(t,e){let i="",s="",n=!1;for(;e<t.length;e++){if(t[e]===rt||t[e]===ot)""===s?s=t[e]:s!==t[e]||(s="");else if(">"===t[e]&&""===s){n=!0;break}i+=t[e]}return""===s&&{value:i,index:e,tagClosed:n}}const lt=new RegExp("(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['\"])(([\\s\\S])*?)\\5)?","g");function ht(t,e){const i=tt.getAllMatches(t,lt),s={};for(let t=0;t<i.length;t++){if(0===i[t][1].length)return dt("InvalidAttr","Attribute '"+i[t][2]+"' has no space in starting.",mt(i[t]));if(void 0!==i[t][3]&&void 0===i[t][4])return dt("InvalidAttr","Attribute '"+i[t][2]+"' is without value.",mt(i[t]));if(void 0===i[t][3]&&!e.allowBooleanAttributes)return dt("InvalidAttr","boolean attribute '"+i[t][2]+"' is not allowed.",mt(i[t]));const n=i[t][2];if(!ut(n))return dt("InvalidAttr","Attribute '"+n+"' is an invalid name.",mt(i[t]));if(s.hasOwnProperty(n))return dt("InvalidAttr","Attribute '"+n+"' is repeated.",mt(i[t]));s[n]=1}return!0}function ct(t,e){if(";"===t[++e])return-1;if("#"===t[e])return function(t,e){let i=/\d/;for("x"===t[e]&&(e++,i=/[\da-fA-F]/);e<t.length;e++){if(";"===t[e])return e;if(!t[e].match(i))break}return-1}(t,++e);let i=0;for(;e<t.length;e++,i++)if(!(t[e].match(/\w/)&&i<20)){if(";"===t[e])break;return-1}return e}function dt(t,e,i){return{err:{code:t,msg:e,line:i.line||i,col:i.col}}}function ut(t){return tt.isName(t)}function pt(t){return tt.isName(t)}function ft(t,e){const i=t.substring(0,e).split(/\r?\n/);return{line:i.length,col:i[i.length-1].length+1}}function mt(t){return t.startIndex+t[1].length}var gt={};const _t={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(t,e){return e},attributeValueProcessor:function(t,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(t,e,i){return t}};gt.buildOptions=function(t){return Object.assign({},_t,t)},gt.defaultOptions=_t;const yt=J;function wt(t,e){let i="";for(;e<t.length&&"'"!==t[e]&&'"'!==t[e];e++)i+=t[e];if(i=i.trim(),-1!==i.indexOf(" "))throw new Error("External entites are not supported");const s=t[e++];let n="";for(;e<t.length&&t[e]!==s;e++)n+=t[e];return[i,n,e]}function vt(t,e){return"!"===t[e+1]&&"-"===t[e+2]&&"-"===t[e+3]}function bt(t,e){return"!"===t[e+1]&&"E"===t[e+2]&&"N"===t[e+3]&&"T"===t[e+4]&&"I"===t[e+5]&&"T"===t[e+6]&&"Y"===t[e+7]}function xt(t,e){return"!"===t[e+1]&&"E"===t[e+2]&&"L"===t[e+3]&&"E"===t[e+4]&&"M"===t[e+5]&&"E"===t[e+6]&&"N"===t[e+7]&&"T"===t[e+8]}function Et(t,e){return"!"===t[e+1]&&"A"===t[e+2]&&"T"===t[e+3]&&"T"===t[e+4]&&"L"===t[e+5]&&"I"===t[e+6]&&"S"===t[e+7]&&"T"===t[e+8]}function Tt(t,e){return"!"===t[e+1]&&"N"===t[e+2]&&"O"===t[e+3]&&"T"===t[e+4]&&"A"===t[e+5]&&"T"===t[e+6]&&"I"===t[e+7]&&"O"===t[e+8]&&"N"===t[e+9]}function Ct(t){if(yt.isName(t))return t;throw new Error(`Invalid entity name ${t}`)}const St=/^[-+]?0x[a-fA-F0-9]+$/,At=/^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/,Ot={hex:!0,leadingZeros:!0,decimalPoint:".",eNotation:!0};const Pt=J,It=class{constructor(t){this.tagname=t,this.child=[],this[":@"]={}}add(t,e){"__proto__"===t&&(t="#__proto__"),this.child.push({[t]:e})}addChild(t){"__proto__"===t.tagname&&(t.tagname="#__proto__"),t[":@"]&&Object.keys(t[":@"]).length>0?this.child.push({[t.tagname]:t.child,":@":t[":@"]}):this.child.push({[t.tagname]:t.child})}},kt=function(t,e){const i={};if("O"!==t[e+3]||"C"!==t[e+4]||"T"!==t[e+5]||"Y"!==t[e+6]||"P"!==t[e+7]||"E"!==t[e+8])throw new Error("Invalid Tag instead of DOCTYPE");{e+=9;let s=1,n=!1,r=!1,o="";for(;e<t.length;e++)if("<"!==t[e]||r)if(">"===t[e]){if(r?"-"===t[e-1]&&"-"===t[e-2]&&(r=!1,s--):s--,0===s)break}else"["===t[e]?n=!0:o+=t[e];else{if(n&&bt(t,e))e+=7,[entityName,val,e]=wt(t,e+1),-1===val.indexOf("&")&&(i[Ct(entityName)]={regx:RegExp(`&${entityName};`,"g"),val:val});else if(n&&xt(t,e))e+=8;else if(n&&Et(t,e))e+=8;else if(n&&Tt(t,e))e+=9;else{if(!vt)throw new Error("Invalid DOCTYPE");r=!0}s++,o=""}if(0!==s)throw new Error("Unclosed DOCTYPE")}return{entities:i,i:e}},Dt=function(t,e={}){if(e=Object.assign({},Ot,e),!t||"string"!=typeof t)return t;let i=t.trim();if(void 0!==e.skipLike&&e.skipLike.test(i))return t;if("0"===t)return 0;if(e.hex&&St.test(i))return function(t,e){if(parseInt)return parseInt(t,e);if(Number.parseInt)return Number.parseInt(t,e);if(window&&window.parseInt)return window.parseInt(t,e);throw new Error("parseInt, Number.parseInt, window.parseInt are not supported")}(i,16);if(-1!==i.search(/[eE]/)){const s=i.match(/^([-\+])?(0*)([0-9]*(\.[0-9]*)?[eE][-\+]?[0-9]+)$/);if(s){if(e.leadingZeros)i=(s[1]||"")+s[3];else if("0"!==s[2]||"."!==s[3][0])return t;return e.eNotation?Number(i):t}return t}{const s=At.exec(i);if(s){const n=s[1],r=s[2];let o=function(t){if(t&&-1!==t.indexOf("."))return"."===(t=t.replace(/0+$/,""))?t="0":"."===t[0]?t="0"+t:"."===t[t.length-1]&&(t=t.substr(0,t.length-1)),t;return t}(s[3]);if(!e.leadingZeros&&r.length>0&&n&&"."!==i[2])return t;if(!e.leadingZeros&&r.length>0&&!n&&"."!==i[1])return t;if(e.leadingZeros&&r===t)return 0;{const s=Number(i),a=""+s;return-1!==a.search(/[eE]/)?e.eNotation?s:t:-1!==i.indexOf(".")?"0"===a&&""===o||a===o||n&&a==="-"+o?s:t:r?o===a||n+o===a?s:t:i===a||i===n+a?s:t}}return t}};function zt(t){const e=Object.keys(t);for(let i=0;i<e.length;i++){const s=e[i];this.lastEntities[s]={regex:new RegExp("&"+s+";","g"),val:t[s]}}}function Mt(t,e,i,s,n,r,o){if(void 0!==t&&(this.options.trimValues&&!s&&(t=t.trim()),t.length>0)){o||(t=this.replaceEntitiesValue(t));const s=this.options.tagValueProcessor(e,t,i,n,r);if(null==s)return t;if(typeof s!=typeof t||s!==t)return s;if(this.options.trimValues)return Wt(t,this.options.parseTagValue,this.options.numberParseOptions);return t.trim()===t?Wt(t,this.options.parseTagValue,this.options.numberParseOptions):t}}function Bt(t){if(this.options.removeNSPrefix){const e=t.split(":"),i="/"===t.charAt(0)?"/":"";if("xmlns"===e[0])return"";2===e.length&&(t=i+e[1])}return t}const Nt=new RegExp("([^\\s=]+)\\s*(=\\s*(['\"])([\\s\\S]*?)\\3)?","gm");function Ut(t,e,i){if(!this.options.ignoreAttributes&&"string"==typeof t){const i=Pt.getAllMatches(t,Nt),s=i.length,n={};for(let t=0;t<s;t++){const s=this.resolveNameSpace(i[t][1]);let r=i[t][4],o=this.options.attributeNamePrefix+s;if(s.length)if(this.options.transformAttributeName&&(o=this.options.transformAttributeName(o)),"__proto__"===o&&(o="#__proto__"),void 0!==r){this.options.trimValues&&(r=r.trim()),r=this.replaceEntitiesValue(r);const t=this.options.attributeValueProcessor(s,r,e);n[o]=null==t?r:typeof t!=typeof r||t!==r?t:Wt(r,this.options.parseAttributeValue,this.options.numberParseOptions)}else this.options.allowBooleanAttributes&&(n[o]=!0)}if(!Object.keys(n).length)return;if(this.options.attributesGroupName){const t={};return t[this.options.attributesGroupName]=n,t}return n}}const Lt=function(t){t=t.replace(/\r\n?/g,"\n");const e=new It("!xml");let i=e,s="",n="";for(let r=0;r<t.length;r++){if("<"===t[r])if("/"===t[r+1]){const e=Zt(t,">",r,"Closing Tag is not closed.");let o=t.substring(r+2,e).trim();if(this.options.removeNSPrefix){const t=o.indexOf(":");-1!==t&&(o=o.substr(t+1))}this.options.transformTagName&&(o=this.options.transformTagName(o)),i&&(s=this.saveTextToParentTag(s,i,n));const a=n.substring(n.lastIndexOf(".")+1);if(o&&-1!==this.options.unpairedTags.indexOf(o))throw new Error(`Unpaired tag can not be used as closing tag: </${o}>`);let l=0;a&&-1!==this.options.unpairedTags.indexOf(a)?(l=n.lastIndexOf(".",n.lastIndexOf(".")-1),this.tagsNodeStack.pop()):l=n.lastIndexOf("."),n=n.substring(0,l),i=this.tagsNodeStack.pop(),s="",r=e}else if("?"===t[r+1]){let e=Ht(t,r,!1,"?>");if(!e)throw new Error("Pi Tag is not closed.");if(s=this.saveTextToParentTag(s,i,n),this.options.ignoreDeclaration&&"?xml"===e.tagName||this.options.ignorePiTags);else{const t=new It(e.tagName);t.add(this.options.textNodeName,""),e.tagName!==e.tagExp&&e.attrExpPresent&&(t[":@"]=this.buildAttributesMap(e.tagExp,n,e.tagName)),this.addChild(i,t,n)}r=e.closeIndex+1}else if("!--"===t.substr(r+1,3)){const e=Zt(t,"--\x3e",r+4,"Comment is not closed.");if(this.options.commentPropName){const o=t.substring(r+4,e-2);s=this.saveTextToParentTag(s,i,n),i.add(this.options.commentPropName,[{[this.options.textNodeName]:o}])}r=e}else if("!D"===t.substr(r+1,2)){const e=kt(t,r);this.docTypeEntities=e.entities,r=e.i}else if("!["===t.substr(r+1,2)){const e=Zt(t,"]]>",r,"CDATA is not closed.")-2,o=t.substring(r+9,e);s=this.saveTextToParentTag(s,i,n);let a=this.parseTextData(o,i.tagname,n,!0,!1,!0,!0);null==a&&(a=""),this.options.cdataPropName?i.add(this.options.cdataPropName,[{[this.options.textNodeName]:o}]):i.add(this.options.textNodeName,a),r=e+2}else{let o=Ht(t,r,this.options.removeNSPrefix),a=o.tagName;const l=o.rawTagName;let h=o.tagExp,c=o.attrExpPresent,d=o.closeIndex;this.options.transformTagName&&(a=this.options.transformTagName(a)),i&&s&&"!xml"!==i.tagname&&(s=this.saveTextToParentTag(s,i,n,!1));const u=i;if(u&&-1!==this.options.unpairedTags.indexOf(u.tagname)&&(i=this.tagsNodeStack.pop(),n=n.substring(0,n.lastIndexOf("."))),a!==e.tagname&&(n+=n?"."+a:a),this.isItStopNode(this.options.stopNodes,n,a)){let e="";if(h.length>0&&h.lastIndexOf("/")===h.length-1)"/"===a[a.length-1]?(a=a.substr(0,a.length-1),n=n.substr(0,n.length-1),h=a):h=h.substr(0,h.length-1),r=o.closeIndex;else if(-1!==this.options.unpairedTags.indexOf(a))r=o.closeIndex;else{const i=this.readStopNodeData(t,l,d+1);if(!i)throw new Error(`Unexpected end of ${l}`);r=i.i,e=i.tagContent}const s=new It(a);a!==h&&c&&(s[":@"]=this.buildAttributesMap(h,n,a)),e&&(e=this.parseTextData(e,a,n,!0,c,!0,!0)),n=n.substr(0,n.lastIndexOf(".")),s.add(this.options.textNodeName,e),this.addChild(i,s,n)}else{if(h.length>0&&h.lastIndexOf("/")===h.length-1){"/"===a[a.length-1]?(a=a.substr(0,a.length-1),n=n.substr(0,n.length-1),h=a):h=h.substr(0,h.length-1),this.options.transformTagName&&(a=this.options.transformTagName(a));const t=new It(a);a!==h&&c&&(t[":@"]=this.buildAttributesMap(h,n,a)),this.addChild(i,t,n),n=n.substr(0,n.lastIndexOf("."))}else{const t=new It(a);this.tagsNodeStack.push(i),a!==h&&c&&(t[":@"]=this.buildAttributesMap(h,n,a)),this.addChild(i,t,n),i=t}s="",r=d}}else s+=t[r]}return e.child};function Rt(t,e,i){const s=this.options.updateTag(e.tagname,i,e[":@"]);!1===s||("string"==typeof s?(e.tagname=s,t.addChild(e)):t.addChild(e))}const Ft=function(t){if(this.options.processEntities){for(let e in this.docTypeEntities){const i=this.docTypeEntities[e];t=t.replace(i.regx,i.val)}for(let e in this.lastEntities){const i=this.lastEntities[e];t=t.replace(i.regex,i.val)}if(this.options.htmlEntities)for(let e in this.htmlEntities){const i=this.htmlEntities[e];t=t.replace(i.regex,i.val)}t=t.replace(this.ampEntity.regex,this.ampEntity.val)}return t};function Vt(t,e,i,s){return t&&(void 0===s&&(s=0===Object.keys(e.child).length),void 0!==(t=this.parseTextData(t,e.tagname,i,!1,!!e[":@"]&&0!==Object.keys(e[":@"]).length,s))&&""!==t&&e.add(this.options.textNodeName,t),t=""),t}function jt(t,e,i){const s="*."+i;for(const i in t){const n=t[i];if(s===n||e===n)return!0}return!1}function Zt(t,e,i,s){const n=t.indexOf(e,i);if(-1===n)throw new Error(s);return n+e.length-1}function Ht(t,e,i,s=">"){const n=function(t,e,i=">"){let s,n="";for(let r=e;r<t.length;r++){let e=t[r];if(s)e===s&&(s="");else if('"'===e||"'"===e)s=e;else if(e===i[0]){if(!i[1])return{data:n,index:r};if(t[r+1]===i[1])return{data:n,index:r}}else"\t"===e&&(e=" ");n+=e}}(t,e+1,s);if(!n)return;let r=n.data;const o=n.index,a=r.search(/\s/);let l=r,h=!0;-1!==a&&(l=r.substring(0,a),r=r.substring(a+1).trimStart());const c=l;if(i){const t=l.indexOf(":");-1!==t&&(l=l.substr(t+1),h=l!==n.data.substr(t+1))}return{tagName:l,tagExp:r,closeIndex:o,attrExpPresent:h,rawTagName:c}}function $t(t,e,i){const s=i;let n=1;for(;i<t.length;i++)if("<"===t[i])if("/"===t[i+1]){const r=Zt(t,">",i,`${e} is not closed`);if(t.substring(i+2,r).trim()===e&&(n--,0===n))return{tagContent:t.substring(s,i),i:r};i=r}else if("?"===t[i+1]){i=Zt(t,"?>",i+1,"StopNode is not closed.")}else if("!--"===t.substr(i+1,3)){i=Zt(t,"--\x3e",i+3,"StopNode is not closed.")}else if("!["===t.substr(i+1,2)){i=Zt(t,"]]>",i,"StopNode is not closed.")-2}else{const s=Ht(t,i,">");if(s){(s&&s.tagName)===e&&"/"!==s.tagExp[s.tagExp.length-1]&&n++,i=s.closeIndex}}}function Wt(t,e,i){if(e&&"string"==typeof t){const e=t.trim();return"true"===e||"false"!==e&&Dt(t,i)}return Pt.isExist(t)?t:""}var Yt=class{constructor(t){this.options=t,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:"¢"},pound:{regex:/&(pound|#163);/g,val:"£"},yen:{regex:/&(yen|#165);/g,val:"¥"},euro:{regex:/&(euro|#8364);/g,val:"€"},copyright:{regex:/&(copy|#169);/g,val:"©"},reg:{regex:/&(reg|#174);/g,val:"®"},inr:{regex:/&(inr|#8377);/g,val:"₹"},num_dec:{regex:/&#([0-9]{1,7});/g,val:(t,e)=>String.fromCharCode(Number.parseInt(e,10))},num_hex:{regex:/&#x([0-9a-fA-F]{1,6});/g,val:(t,e)=>String.fromCharCode(Number.parseInt(e,16))}},this.addExternalEntities=zt,this.parseXml=Lt,this.parseTextData=Mt,this.resolveNameSpace=Bt,this.buildAttributesMap=Ut,this.isItStopNode=jt,this.replaceEntitiesValue=Ft,this.readStopNodeData=$t,this.saveTextToParentTag=Vt,this.addChild=Rt}},Xt={};function qt(t,e,i){let s;const n={};for(let r=0;r<t.length;r++){const o=t[r],a=Gt(o);let l="";if(l=void 0===i?a:i+"."+a,a===e.textNodeName)void 0===s?s=o[a]:s+=""+o[a];else{if(void 0===a)continue;if(o[a]){let t=qt(o[a],e,l);const i=Kt(t,e);o[":@"]?Qt(t,o[":@"],l,e):1!==Object.keys(t).length||void 0===t[e.textNodeName]||e.alwaysCreateTextNode?0===Object.keys(t).length&&(e.alwaysCreateTextNode?t[e.textNodeName]="":t=""):t=t[e.textNodeName],void 0!==n[a]&&n.hasOwnProperty(a)?(Array.isArray(n[a])||(n[a]=[n[a]]),n[a].push(t)):e.isArray(a,l,i)?n[a]=[t]:n[a]=t}}}return"string"==typeof s?s.length>0&&(n[e.textNodeName]=s):void 0!==s&&(n[e.textNodeName]=s),n}function Gt(t){const e=Object.keys(t);for(let t=0;t<e.length;t++){const i=e[t];if(":@"!==i)return i}}function Qt(t,e,i,s){if(e){const n=Object.keys(e),r=n.length;for(let o=0;o<r;o++){const r=n[o];s.isArray(r,i+"."+r,!0,!0)?t[r]=[e[r]]:t[r]=e[r]}}}function Kt(t,e){const{textNodeName:i}=e,s=Object.keys(t).length;return 0===s||!(1!==s||!t[i]&&"boolean"!=typeof t[i]&&0!==t[i])}Xt.prettify=function(t,e){return qt(t,e)};const{buildOptions:Jt}=gt,te=Yt,{prettify:ee}=Xt,ie=K;var se=class{constructor(t){this.externalEntities={},this.options=Jt(t)}parse(t,e){if("string"==typeof t);else{if(!t.toString)throw new Error("XML data is accepted in String or Bytes[] form.");t=t.toString()}if(e){!0===e&&(e={});const i=ie.validate(t,e);if(!0!==i)throw Error(`${i.err.msg}:${i.err.line}:${i.err.col}`)}const i=new te(this.options);i.addExternalEntities(this.externalEntities);const s=i.parseXml(t);return this.options.preserveOrder||void 0===s?s:ee(s,this.options)}addEntity(t,e){if(-1!==e.indexOf("&"))throw new Error("Entity value can't have '&'");if(-1!==t.indexOf("&")||-1!==t.indexOf(";"))throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '
'");if("&"===e)throw new Error("An entity with value '&' is not permitted");this.externalEntities[t]=e}};function ne(t,e,i,s){let n="",r=!1;for(let o=0;o<t.length;o++){const a=t[o],l=re(a);if(void 0===l)continue;let h="";if(h=0===i.length?l:`${i}.${l}`,l===e.textNodeName){let t=a[l];ae(h,e)||(t=e.tagValueProcessor(l,t),t=le(t,e)),r&&(n+=s),n+=t,r=!1;continue}if(l===e.cdataPropName){r&&(n+=s),n+=`<![CDATA[${a[l][0][e.textNodeName]}]]>`,r=!1;continue}if(l===e.commentPropName){n+=s+`\x3c!--${a[l][0][e.textNodeName]}--\x3e`,r=!0;continue}if("?"===l[0]){const t=oe(a[":@"],e),i="?xml"===l?"":s;let o=a[l][0][e.textNodeName];o=0!==o.length?" "+o:"",n+=i+`<${l}${o}${t}?>`,r=!0;continue}let c=s;""!==c&&(c+=e.indentBy);const d=s+`<${l}${oe(a[":@"],e)}`,u=ne(a[l],e,h,c);-1!==e.unpairedTags.indexOf(l)?e.suppressUnpairedNode?n+=d+">":n+=d+"/>":u&&0!==u.length||!e.suppressEmptyNode?u&&u.endsWith(">")?n+=d+`>${u}${s}</${l}>`:(n+=d+">",u&&""!==s&&(u.includes("/>")||u.includes("</"))?n+=s+e.indentBy+u+s:n+=u,n+=`</${l}>`):n+=d+"/>",r=!0}return n}function re(t){const e=Object.keys(t);for(let i=0;i<e.length;i++){const s=e[i];if(t.hasOwnProperty(s)&&":@"!==s)return s}}function oe(t,e){let i="";if(t&&!e.ignoreAttributes)for(let s in t){if(!t.hasOwnProperty(s))continue;let n=e.attributeValueProcessor(s,t[s]);n=le(n,e),!0===n&&e.suppressBooleanAttributes?i+=` ${s.substr(e.attributeNamePrefix.length)}`:i+=` ${s.substr(e.attributeNamePrefix.length)}="${n}"`}return i}function ae(t,e){let i=(t=t.substr(0,t.length-e.textNodeName.length-1)).substr(t.lastIndexOf(".")+1);for(let s in e.stopNodes)if(e.stopNodes[s]===t||e.stopNodes[s]==="*."+i)return!0;return!1}function le(t,e){if(t&&t.length>0&&e.processEntities)for(let i=0;i<e.entities.length;i++){const s=e.entities[i];t=t.replace(s.regex,s.val)}return t}const he=function(t,e){let i="";return e.format&&e.indentBy.length>0&&(i="\n"),ne(t,e,"",i)},ce={attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,cdataPropName:!1,format:!1,indentBy:" ",suppressEmptyNode:!1,suppressUnpairedNode:!0,suppressBooleanAttributes:!0,tagValueProcessor:function(t,e){return e},attributeValueProcessor:function(t,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 de(t){this.options=Object.assign({},ce,t),this.options.ignoreAttributes||this.options.attributesGroupName?this.isAttribute=function(){return!1}:(this.attrPrefixLen=this.options.attributeNamePrefix.length,this.isAttribute=fe),this.processTextOrObjNode=ue,this.options.format?(this.indentate=pe,this.tagEndChar=">\n",this.newLine="\n"):(this.indentate=function(){return""},this.tagEndChar=">",this.newLine="")}function ue(t,e,i){const s=this.j2x(t,i+1);return void 0!==t[this.options.textNodeName]&&1===Object.keys(t).length?this.buildTextValNode(t[this.options.textNodeName],e,s.attrStr,i):this.buildObjectNode(s.val,e,s.attrStr,i)}function pe(t){return this.options.indentBy.repeat(t)}function fe(t){return!(!t.startsWith(this.options.attributeNamePrefix)||t===this.options.textNodeName)&&t.substr(this.attrPrefixLen)}de.prototype.build=function(t){return this.options.preserveOrder?he(t,this.options):(Array.isArray(t)&&this.options.arrayNodeName&&this.options.arrayNodeName.length>1&&(t={[this.options.arrayNodeName]:t}),this.j2x(t,0).val)},de.prototype.j2x=function(t,e){let i="",s="";for(let n in t)if(Object.prototype.hasOwnProperty.call(t,n))if(void 0===t[n])this.isAttribute(n)&&(s+="");else if(null===t[n])this.isAttribute(n)?s+="":"?"===n[0]?s+=this.indentate(e)+"<"+n+"?"+this.tagEndChar:s+=this.indentate(e)+"<"+n+"/"+this.tagEndChar;else if(t[n]instanceof Date)s+=this.buildTextValNode(t[n],n,"",e);else if("object"!=typeof t[n]){const r=this.isAttribute(n);if(r)i+=this.buildAttrPairStr(r,""+t[n]);else if(n===this.options.textNodeName){let e=this.options.tagValueProcessor(n,""+t[n]);s+=this.replaceEntitiesValue(e)}else s+=this.buildTextValNode(t[n],n,"",e)}else if(Array.isArray(t[n])){const i=t[n].length;let r="",o="";for(let a=0;a<i;a++){const i=t[n][a];if(void 0===i);else if(null===i)"?"===n[0]?s+=this.indentate(e)+"<"+n+"?"+this.tagEndChar:s+=this.indentate(e)+"<"+n+"/"+this.tagEndChar;else if("object"==typeof i)if(this.options.oneListGroup){const t=this.j2x(i,e+1);r+=t.val,this.options.attributesGroupName&&i.hasOwnProperty(this.options.attributesGroupName)&&(o+=t.attrStr)}else r+=this.processTextOrObjNode(i,n,e);else if(this.options.oneListGroup){let t=this.options.tagValueProcessor(n,i);t=this.replaceEntitiesValue(t),r+=t}else r+=this.buildTextValNode(i,n,"",e)}this.options.oneListGroup&&(r=this.buildObjectNode(r,n,o,e)),s+=r}else if(this.options.attributesGroupName&&n===this.options.attributesGroupName){const e=Object.keys(t[n]),s=e.length;for(let r=0;r<s;r++)i+=this.buildAttrPairStr(e[r],""+t[n][e[r]])}else s+=this.processTextOrObjNode(t[n],n,e);return{attrStr:i,val:s}},de.prototype.buildAttrPairStr=function(t,e){return e=this.options.attributeValueProcessor(t,""+e),e=this.replaceEntitiesValue(e),this.options.suppressBooleanAttributes&&"true"===e?" "+t:" "+t+'="'+e+'"'},de.prototype.buildObjectNode=function(t,e,i,s){if(""===t)return"?"===e[0]?this.indentate(s)+"<"+e+i+"?"+this.tagEndChar:this.indentate(s)+"<"+e+i+this.closeTag(e)+this.tagEndChar;{let n="</"+e+this.tagEndChar,r="";return"?"===e[0]&&(r="?",n=""),!i&&""!==i||-1!==t.indexOf("<")?!1!==this.options.commentPropName&&e===this.options.commentPropName&&0===r.length?this.indentate(s)+`\x3c!--${t}--\x3e`+this.newLine:this.indentate(s)+"<"+e+i+r+this.tagEndChar+t+this.indentate(s)+n:this.indentate(s)+"<"+e+i+r+">"+t+n}},de.prototype.closeTag=function(t){let e="";return-1!==this.options.unpairedTags.indexOf(t)?this.options.suppressUnpairedNode||(e="/"):e=this.options.suppressEmptyNode?"/":`></${t}`,e},de.prototype.buildTextValNode=function(t,e,i,s){if(!1!==this.options.cdataPropName&&e===this.options.cdataPropName)return this.indentate(s)+`<![CDATA[${t}]]>`+this.newLine;if(!1!==this.options.commentPropName&&e===this.options.commentPropName)return this.indentate(s)+`\x3c!--${t}--\x3e`+this.newLine;if("?"===e[0])return this.indentate(s)+"<"+e+i+"?"+this.tagEndChar;{let n=this.options.tagValueProcessor(e,t);return n=this.replaceEntitiesValue(n),""===n?this.indentate(s)+"<"+e+i+this.closeTag(e)+this.tagEndChar:this.indentate(s)+"<"+e+i+">"+n+"</"+e+this.tagEndChar}},de.prototype.replaceEntitiesValue=function(t){if(t&&t.length>0&&this.options.processEntities)for(let e=0;e<this.options.entities.length;e++){const i=this.options.entities[e];t=t.replace(i.regex,i.val)}return t};var me={XMLParser:se,XMLValidator:K,XMLBuilder:de};class ge{}e(ge,"parser",new me.XMLParser({allowBooleanAttributes:!0,attributeNamePrefix:"",ignoreAttributes:!1,ignoreDeclaration:!0,ignorePiTags:!0,numberParseOptions:{leadingZeros:!0,hex:!0},parseAttributeValue:!0,preserveOrder:!1,processEntities:!1,removeNSPrefix:!0,trimValues:!0})),e(ge,"builder",new me.XMLBuilder({attributeNamePrefix:"$",ignoreAttributes:!1,suppressBooleanAttributes:!1}));class _e extends F{constructor(t,i){super(t),e(this,"onDisposed",new U),e(this,"onVertexFound",new U),e(this,"onVertexLost",new U),e(this,"onEnabled",new U),e(this,"components"),e(this,"workingPlane",null),e(this,"_pickedPoint",null),e(this,"_config"),e(this,"_enabled",!1),this.components=t,this.config={snapDistance:.25,showOnlyVertex:!1,...i},this.enabled=!1}set enabled(t){this._enabled=t,t||(this._pickedPoint=null),this.onEnabled.trigger(t)}get enabled(){return this._enabled}set config(t){this._config={...this._config,...t}}get config(){return this._config}dispose(){this.onVertexFound.reset(),this.onVertexLost.reset(),this.components=null,this.onDisposed.trigger(),this.onDisposed.reset()}async get(t){if(!this.enabled)return this._pickedPoint;const e=this.components.get(je).get(t),i=await e.castRay();if(!i)return null!==this._pickedPoint&&(this.onVertexLost.trigger(),this._pickedPoint=null),this._pickedPoint;const s=i.point;return null!==this._pickedPoint&&this._pickedPoint.equals(s)||(this._pickedPoint=s.clone(),this.onVertexFound.trigger(this._pickedPoint)),this._pickedPoint}}class ye{static join(t){const e={};for(const i of t)for(const t in i)if(e[t])for(const s of i[t])e[t].add(s);else e[t]=new Set(i[t]);return e}static intersect(t){if(0===t.length)return{};let e=ye.clone(t[0]);for(let i=1;i<t.length;i++){const s=t[i],n={};for(const t in e)if(s[t]){const i=new Set;for(const n of e[t])s[t].has(n)&&i.add(n);i.size>0&&(n[t]=i)}e=n}return e}static clone(t){const e={};for(const i in t)e[i]=new Set(t[i]);return e}static remove(t,e,i=!1){i&&(t=ye.clone(t));for(const i in e)if(t[i]){for(const s of e[i])t[i].delete(s);0===t[i].size&&delete t[i]}}static add(t,e,i=!1){i&&(t=ye.clone(t));for(const i in e)if(t[i])for(const s of e[i])t[i].add(s);else t[i]=new Set(e[i])}static append(t,e,...i){let s=t[e];s||(s=new Set,t[e]=s);for(const t of i)s.add(t)}static isEqual(t,e){const i=Object.keys(t),s=Object.keys(e);if(i.length!==s.length)return!1;for(const s of i){if(!e[s])return!1;if(t[s].size!==e[s].size)return!1;for(const i of t[s])if(!e[s].has(i))return!1}return!0}static isEmpty(t){return 0===Object.values(t).reduce((t,e)=>t+e.size,0)}static toRaw(t){const e={};for(const i in t)e[i]=Array.from(t[i]);return e}static fromRaw(t){const e={};for(const i in t)e[i]=new Set(t[i]);return e}}class we extends Map{constructor(t){super(t),e(this,"onItemSet",new U),e(this,"onItemUpdated",new U),e(this,"onItemDeleted",new U),e(this,"onCleared",new U),e(this,"guard",()=>!0)}clear(){super.clear(),this.onCleared.trigger()}set(t,e){const i=this.has(t);if(!(this.guard??(()=>!0))(t,e))return this;const s=super.set(t,e);return i?(this.onItemUpdated||(this.onItemUpdated=new U),this.onItemUpdated.trigger({key:t,value:e})):(this.onItemSet||(this.onItemSet=new U),this.onItemSet.trigger({key:t,value:e})),s}add(t){const e=q.create();return this.set(e,t),e}delete(t){const e=super.delete(t);return e&&this.onItemDeleted.trigger(t),e}dispose(){this.clear(),this.onItemSet.reset(),this.onItemDeleted.reset(),this.onCleared.reset()}}class ve{static isEntry(t){return new Set(["Boolean","Color","Text","Number","Select","Vector3","TextSet","None"]).has(t.type)}static copySchema(t,e={}){for(const i in t){const s=t[i];this.isEntry(s)?e[i]=this.copyEntry(s):(e[i]={},this.copySchema(s,e[i]))}return e}static copyEntry(t){if("Boolean"===t.type){const e=t;return{type:e.type,value:e.value}}if("Color"===t.type){const e=t;return{type:e.type,value:e.value.clone()}}if("Text"===t.type){const e=t;return{type:e.type,value:e.value}}if("Number"===t.type){const e=t;return{type:e.type,value:e.value,min:e.min,max:e.max,interpolable:e.interpolable}}if("Select"===t.type){const e=t;return{type:e.type,value:e.value,multiple:e.multiple,options:new Set(e.options)}}if("Vector3"===t.type){const e=t;return{type:e.type,value:e.value.clone()}}if("TextSet"===t.type){const e=t;return{type:e.type,value:new Set(e.value)}}if("None"===t.type){const e=t;return{type:e.type,value:e.value}}throw new Error("Invalid entry!")}}class be{constructor(){e(this,"list",new Set)}add(t){for(const e of t)this.list.add(e)}remove(t){for(const e of t)this.list.delete(e)}set(t){for(const e of this.list)e.enabled=t}reset(){for(const t of this.list)t.reset()}}class xe{constructor(t,i,s,n){e(this,"_component"),e(this,"name"),e(this,"uuid"),this._component=t,this.name=s,this.uuid=n??q.create();i.get(Te).list.set(this.uuid,this)}get controls(){return ve.copySchema(this._config)}set(t){for(const e in t)if(e in this){this[e]=t[e].value}}export(t=this._config,e={}){for(const i in t){const s=t[i];if(ve.isEntry(s))if("Color"===s.type){const{r:t,g:n,b:r}=s.value;e[i]={...s,value:{r:t,g:n,b:r}}}else if("Vector3"===s.type){const{x:t,y:n,z:r}=s.value;e[i]={...s,value:{x:t,y:n,z:r}}}else if("TextSet"===s.type){const t=Array.from(s.value);e[i]={...s,value:t}}else if("Select"===s.type){const t=Array.from(s.options);e[i]={...s,options:t}}else e[i]={...s};else e[i]={},this.export(s,e[i])}return e}import(t,e={},i=!0){for(const i in t){const s=t[i];if(ve.isEntry(s))if("Color"===s.type){const{r:t,g:n,b:o}=s.value;e[i]={...s,value:new r.Color(t,n,o)}}else if("Vector3"===s.type){const{x:t,y:n,z:o}=s.value;e[i]={...s,value:new r.Vector3(t,n,o)}}else"TextSet"===s.type?e[i]={...s,value:new Set(s.value)}:"Select"===s.type?e[i]={...s,options:new Set(s.options)}:e[i]={...s};else e[i]={},this.import(s,e[i],!1)}i&&this.set(e)}}const Ee=class t extends F{constructor(i){super(i),e(this,"list",new we),e(this,"enabled",!0),i.add(t.uuid,this)}};e(Ee,"uuid","b8c764e0-6b24-4e77-9a32-35fa728ee5b4");let Te=Ee;class Ce{constructor(t){e(this,"_event"),e(this,"_position",new r.Vector2),e(this,"onDisposed",new U),e(this,"updateMouseInfo",t=>{this._event=t}),this.dom=t,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(t){if(this._event){const e=this.dom.getBoundingClientRect();this._position.x=this.getPositionX(e,this._event,t),this._position.y=this.getPositionY(e,this._event,t)}}getPositionY(t,e,i){const s=this.getDataObject(e);return i?s.clientY:-(s.clientY-t.top)/(t.bottom-t.top)*2+1}getPositionX(t,e,i){const s=this.getDataObject(e);return i?s.clientX:(s.clientX-t.left)/(t.right-t.left)*2-1}getDataObject(t){return t instanceof MouseEvent?t:t.touches[0]}setupEvents(t){t?(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 Se=class t extends F{constructor(i){super(i),e(this,"onDisposed",new U),e(this,"onFragmentsLoaded",new U),e(this,"baseCoordinationModel",""),e(this,"baseCoordinationMatrix",new r.Matrix4),e(this,"enabled",!0),e(this,"initialized",!1),e(this,"_core"),this.components.add(t.uuid,this)}get list(){return this.core.models.list}get core(){if(!this._core)throw new Error("FragmentsManager not initialized. Call init() first.");return this._core}dispose(){this._core&&(this.core.dispose(),this._core=void 0),this.baseCoordinationModel="",this.onFragmentsLoaded.reset(),this.onDisposed.trigger(),this.onDisposed.reset()}init(t){this._core=new n(t),this.initialized=!0,this.core.onModelLoaded.add(async t=>{1===this.list.size&&(this.baseCoordinationModel=t.modelId,this.baseCoordinationMatrix=await t.getCoordinationMatrix())}),this.list.onItemDeleted.add(()=>{this.list.size>0||(this.baseCoordinationModel="",this.baseCoordinationMatrix=new r.Matrix4)})}async raycast(t){const e=[];for(const i of this.core.models.list.values())if(t.snappingClasses&&t.snappingClasses.length>0){const s=await i.raycastWithSnapping(t);if(s&&s.length>0)e.push(s[0]);else{const s=await i.raycast(t);s&&e.push(s)}}else{const s=await i.raycast(t);s&&e.push(s)}if(await Promise.all(e),0===e.length)return;let i=e[0],s=i.distance;for(let t=1;t<e.length;t++)e[t].distance<s&&(s=e[t].distance,i=e[t]);return i}async getPositions(t){const e=[],i=async(t,i)=>{const s=await t.getPositions(i);for(const t of s)e.push(t)},s=[];for(const e in t){const n=this.core.models.list.get(e);n&&s.push(i(n,Array.from(t[e])))}return await Promise.all(s),e}async getBBoxes(t){const e=[],i=async(t,i)=>{const s=await t.getBoxes(i);if(s)for(const t of s)e.push(t)},s=[];for(const e in t){const n=this.core.models.list.get(e);n&&s.push(i(n,Array.from(t[e])))}return await Promise.all(s),e}async highlight(t,e){await this.forEachModel(e,"highlight",t)}async getData(t,e){const i={};for(const[s,n]of Object.entries(t)){const t=this.list.get(s);if(!t)continue;const r=await t.getItemsData([...n],e);i[s]=r}return i}async resetHighlight(t){await this.forEachModel(t,"resetHighlight")}async forEachModel(t,e,...i){const s={};if(t)for(const e in t){const i=t[e];s[e]=Array.from(i)}else for(const t of this.core.models.list.keys())s[t]=void 0;const n=[];for(const t in s){const r=this.core.models.list.get(t);if(r){const o=s[t],a=r[e](o,...i);n.push(a)}}await Promise.all(n)}async guidsToModelIdMap(t){const e={};for(const[i,s]of this.list){const n=(await s.getLocalIdsByGuids([...t])).filter(t=>null!==t);e[i]=new Set(n)}return e}async modelIdMapToGuids(t){const e=[];for(const[i,s]of Object.entries(t)){const t=this.list.get(i);if(!t)continue;const n=(await t.getGuidsByLocalIds([...s])).filter(t=>null!==t);e.push(...n)}return e}applyBaseCoordinateSystem(t,e){const i=new r.Matrix4;return e&&i.copy(e.clone()).invert(),i.multiply(this.baseCoordinationMatrix),t.applyMatrix4(i),i}};e(Se,"uuid","fef46874-46a3-461b-8c44-2922ab77c806");let Ae=Se;class Oe{constructor(){e(this,"wasm",{path:"",absolute:!1,logLevel:N.LogLevel.LOG_LEVEL_OFF}),e(this,"webIfc",{COORDINATE_TO_ORIGIN:!0}),e(this,"autoSetWasm",!0),e(this,"customLocateFileHandler",null)}}const Pe=class t extends F{constructor(i){super(i),e(this,"onDisposed",new U),e(this,"onIfcStartedLoading",new U),e(this,"onSetup",new U),e(this,"settings",new Oe),e(this,"webIfc",new N.IfcAPI),e(this,"enabled",!0),this.components.add(t.uuid,this)}dispose(){this.webIfc=null,this.onDisposed.trigger(t.uuid),this.onDisposed.reset()}async setup(t){this.settings={...this.settings,...t},this.settings.autoSetWasm&&await this.autoSetWasm(),this.onSetup.trigger()}async load(t,e,s,n){const r=this.components.get(Ae);if(!r.initialized)throw new Error("You need to initialize fragments first.");this.settings.autoSetWasm&&await this.autoSetWasm(),r.core.settings.autoCoordinate=e;const o=new i.IfcImporter;o.wasm.path=this.settings.wasm.path,o.wasm.absolute=this.settings.wasm.absolute,(null==n?void 0:n.instanceCallback)&&n.instanceCallback(o);const a=await o.process({...null==n?void 0:n.processData,bytes:t});return await r.core.load(a,{modelId:s,userData:null==n?void 0:n.userData})}async readIfcFile(t){const{path:e,absolute:i,logLevel:s}=this.settings.wasm;return this.webIfc.SetWasmPath(e,i),await this.webIfc.Init(this.settings.customLocateFileHandler||void 0),s&&this.webIfc.SetLogLevel(s),this.webIfc.OpenModel(t,this.settings.webIfc)}cleanUp(){try{this.webIfc.Dispose()}catch(t){console.log("Web-ifc wasn't disposed.")}this.webIfc=null,this.webIfc=new N.IfcAPI}async autoSetWasm(){const t=await fetch(`https://unpkg.com/@thatopen/components@${Sr.release}/package.json`);if(!t.ok)return void console.warn("Couldn't get openbim-components package.json. Set wasm settings manually.");const e=await t.json();if("web-ifc"in e.peerDependencies){const t=e.peerDependencies["web-ifc"];this.settings.wasm.path=`https://unpkg.com/web-ifc@${t}/`,this.settings.wasm.absolute=!0}else console.warn("Couldn't get web-ifc from peer dependencies in openbim-components. Set wasm settings manually.")}};e(Pe,"uuid","a659add7-1418-4771-a0d6-7d4d438e4624");let Ie=Pe;const ke=class t extends F{constructor(i){super(i),e(this,"enabled",!0),this.components.add(t.uuid,this)}async set(t,e){const i=this.components.get(Ae),s=[];if(e)for(const[n,r]of Object.entries(e)){const e=i.list.get(n);e&&s.push(e.setVisible([...r],t))}else for(const e of i.list.values())s.push(e.setVisible(void 0,t));await Promise.all(s),await i.core.update(!0)}async isolate(t){await Promise.all([this.set(!1),this.set(!0,t)])}async toggle(t){const e=[],i=this.components.get(Ae);for(const[s,n]of Object.entries(t)){const t=i.list.get(s);t&&e.push(t.toggleVisible([...n]))}await Promise.all(e),await i.core.update(!0)}async getVisibilityMap(t,e){const i=[],s=[],n=this.components.get(Ae);if(e)for(const r of e){const e=n.list.get(r);e&&(i.push(e.modelId),s.push(e.getItemsByVisibility(t)))}else for(const e of n.list.values())i.push(e.modelId),s.push(e.getItemsByVisibility(t));const r=await Promise.all(s),o={};for(const[t,e]of i.entries())o[e]=r[t];return o}};e(ke,"uuid","dd9ccf2d-8a21-4821-b7f6-2949add16a29");let De=ke;const ze=class t extends F{constructor(s){super(s),e(this,"enabled",!0),e(this,"onDisposed",new U),e(this,"list",new i.DataSet),this.components.add(t.uuid,this)}dispose(e=!0){this.list.clear(),this.onDisposed.trigger(t.uuid),e&&(this.onDisposed.reset(),this.list.eventsEnabled=!1,this.list.dispose())}get(){const t=new r.Box3;for(const e of this.list)t.union(e);return t}async addFromModelIdMap(t){const e=this.components.get(Ae),i=new r.Box3;for(const[s,n]of Object.entries(t)){const t=e.list.get(s);if(!t)continue;const r=await t.getMergedBox([...n]);i.union(r)}this.list.add(i)}addFromModels(t){const e=this.components.get(Ae);for(const[i,s]of e.list)t&&!t.some(t=>t.test(i))||this.list.add(s.box)}async getCenter(t){this.list.clear(),await this.addFromModelIdMap(t);const e=this.get();this.list.clear();const i=new r.Vector3;return e.getCenter(i),i}async getCameraOrientation(t,e=1){const i=this.components.get(Ae);this.list.clear();for(const[t,e]of i.list)this.list.add(e.box);const s=this.get();this.list.clear();const n=new r.Vector3;s.getCenter(n);const o=new r.Vector3;s.getSize(o);const a=Math.max(o.x,o.y,o.z)*e,l=new r.Vector3;switch(t){case"front":default:l.set(n.x,n.y,n.z+a);break;case"back":l.set(n.x,n.y,n.z-a);break;case"left":l.set(n.x-a,n.y,n.z);break;case"right":l.set(n.x+a,n.y,n.z);break;case"top":l.set(n.x,n.y+a,n.z);break;case"bottom":l.set(n.x,n.y-a,n.z)}return{position:l,target:n}}};e(ze,"uuid","d1444724-dba6-4cdd-a0c7-68ee1450d166");let Me=ze;class Be{constructor(t,i){e(this,"description"),e(this,"_components"),e(this,"_queries",[]),e(this,"_aggregation","exclusive"),e(this,"result",null),e(this,"cache",!0),e(this,"serializeQueryParameters",t=>{var e;return{categories:null==(e=t.categories)?void 0:e.map(t=>t.source),attributes:t.attributes?{aggregation:t.attributes.aggregation,queries:t.attributes.queries.map(this.serializeAttributeQuery)}:void 0,relation:t.relation?{name:t.relation.name,query:t.relation.query?this.serializeQueryParameters(t.relation.query):void 0}:void 0}}),e(this,"deserializeQueryParameters",t=>{var e;return{categories:null==(e=t.categories)?void 0:e.map(t=>new RegExp(t)),attributes:t.attributes?{aggregation:t.attributes.aggregation,queries:t.attributes.queries.map(this.deserializeAttributeQuery)}:void 0,relation:t.relation?{name:t.relation.name,query:t.relation.query?this.deserializeQueryParameters(t.relation.query):void 0}:void 0}}),this._components=t,this.queries=i}set queries(t){this._queries=t,this.clearCache()}get queries(){return this._queries}set aggregation(t){t!==this._aggregation&&this.clearCache(),this._aggregation=t}get aggregation(){return this._aggregation}async test(t){const{modelIds:e,force:i}={force:!1,...t};if(this.result&&!i)return this.result;const s=this._components.get(Ue),n=await s.getItems(this.queries,{modelIds:e,aggregation:this.aggregation});return this.cache&&(this.result=n),n}clearCache(){this.result=null}serializeAttributeQuery(t){let e;e=Array.isArray(t.value)?t.value.map(t=>t.source):t.value instanceof RegExp?t.value.source:t.value;return{name:t.name.source,value:e,type:t.type instanceof RegExp?t.type.source:t.type,negate:t.negate,itemIds:t.itemIds}}toJSON(){return{name:"Finder Query",description:this.description,queries:this.queries.map(this.serializeQueryParameters),aggregation:this.aggregation,cache:this.cache}}deserializeAttributeQuery(t){let e;e=Array.isArray(t.value)?t.value.map(t=>new RegExp(t)):"string"==typeof t.value?new RegExp(t.value):t.value;return{name:new RegExp(t.name),value:e,type:t.type?new RegExp(t.type):void 0,negate:t.negate,itemIds:t.itemIds}}fromJSON(t){return this.description=t.description,this.aggregation=t.aggregation,this.cache=t.cache,this.queries=t.queries.map(this.deserializeQueryParameters),this}}const Ne=class t extends F{constructor(s){super(s),e(this,"enabled",!0),e(this,"list",new i.DataMap),s.add(t.uuid,this)}async getItems(t,e){const{modelIds:i}=e??{},s=(null==e?void 0:e.aggregation)??"exclusive",n=this.components.get(Ae),r=await Promise.all(t.map(async t=>{const e={};return await Promise.all(Array.from(n.list).map(async([s,n])=>{if(i&&!i.some(t=>t.test(s)))return;const r=await n.getItemsByQuery(t);e[s]=new Set(r)})),e}));return"inclusive"===s?ye.join(r):ye.intersect(r)}create(t,e){const i=new Be(this.components,e);return this.list.set(t,i),i}async addFromCategories(t){const e=new Set,i=this.components.get(Ae);for(const[s,n]of i.list){if(t&&!t.some(t=>t.test(s)))continue;const i=(await n.getItemsWithGeometryCategories()).filter(t=>null!==t),r=new Set(i);for(const t of r)this.list.has(t)||(this.create(t,[{categories:[new RegExp(`^${t}$`)]}]),e.add(t))}return[...e]}import(t){const{data:e}=t,i=[];if(!e)return i;for(const t of e){const{name:e,description:s,queries:n,aggregation:r,cache:o}=t,a=this.create(e,[]);a.fromJSON({description:s,queries:n,aggregation:r,cache:o}),i.push(a)}return i}export(){const t=[];for(const[e,i]of this.list.entries()){const s={...i.toJSON(),name:e};t.push(s)}return{data:t}}};e(Ne,"uuid","0da7ad77-f734-42ca-942f-a074adfd1e3a");let Ue=Ne;const Le=class t extends F{constructor(s){super(s),e(this,"enabled",!0),e(this,"onDisposed",new U),e(this,"list",new i.DataMap),e(this,"defaultSaveFunction",t=>"value"in t.Name?t.Name.value:null),e(this,"onBeforeFragmentsDispose",async t=>{const{key:e,value:i}=t,s=await i.getLocalIds(),n={[e]:new Set(s)};this.removeItems(n)}),s.add(t.uuid,this),this.setupEvents();s.get(Ae).list.onBeforeDelete.add(this.onBeforeFragmentsDispose)}setupEvents(){this.list.onBeforeDelete.add(({value:t})=>t.dispose())}getClassificationGroups(t){let e=this.list.get(t);return e||(e=new i.DataMap,this.list.set(t,e)),e}getModelItems(t,e,i){const{map:s}=this.getGroupData(t,e);let n=s[i];return n||(n=new Set,s[i]=n),n}getGroupData(t,e){const i=this.components.get(Ue),s=this.getClassificationGroups(t);let n=s.get(e);return n||(n={map:{},get:()=>new Promise(t=>{if(n)if(n.query){const{name:e,config:s}=n.query,r=i.list.get(e);if(!r)throw new Error("Classifier: the query name associated with the group doesn't exist in the ItemsFinder component");r.test(s).then(e=>{if(!n)return void t({});const i=ye.join([e,n.map]);t(i)})}else t(n.map);else t({})})},s.set(e,n)),n}async aggregateItems(t,e,i){const s=(null==i?void 0:i.data)??void 0,n=(null==i?void 0:i.aggregationCallback)??this.defaultSaveFunction,r=this.components.get(Ae),o=this.components.get(Ue),a=await o.getItems([e],{modelIds:null==i?void 0:i.modelIds});for(const[e,i]of Object.entries(a)){const o=r.list.get(e);if(!o)continue;const a=(i,...s)=>{const n=this.getModelItems(t,i,e);for(const t of s)n.add(t)},l=await o.getItemsData([...i],s);for(const t of l)n(t,a)}}addGroupItems(t,e,i){const{map:s}=this.getGroupData(t,e);ye.add(s,i)}setGroupQuery(t,e,i){this.getGroupData(t,e).query=i}async find(t){const e=[];for(const[i,s]of Object.entries(t)){const t=[],n=this.list.get(i);if(!n)continue;for(const e of s){const i=n.get(e);if(!i)continue;const s=await i.get();t.push(s)}const r=ye.join(t);e.push(r)}return ye.intersect(e)}async aggregateItemRelations(t,e,i,s){const n=(null==s?void 0:s.attribute)??"Name",r={relations:{[i]:{attributes:!0,relations:!1}}};await this.aggregateItems(t,e,{modelIds:null==s?void 0:s.modelIds,data:r,aggregationCallback:(t,e)=>{if(!(null==t?void 0:t[n]))return;const s=t[n];if(!("value"in s))return;const r=t[i];if(Array.isArray(r))for(const t of r)"value"in t._localId&&e(s.value,t._localId.value)}})}async byIfcBuildingStorey(t){await this.aggregateItemRelations((null==t?void 0:t.classificationName)??"Storeys",{categories:[/BUILDINGSTOREY/]},"ContainsElements",{modelIds:null==t?void 0:t.modelIds})}async byCategory(t){const e=this.components.get(Ue),i=await e.addFromCategories(null==t?void 0:t.modelIds);for(const e of i)this.setGroupQuery((null==t?void 0:t.classificationName)??"Categories",e,{name:e})}dispose(){this.list.clear();this.components.get(Ae).list.onBeforeDelete.remove(this.onBeforeFragmentsDispose),this.onDisposed.trigger()}removeItems(t,e){if(e&&e.classificationName){const i=this.list.get(e.classificationName);if(!i)return;if(e.groupName){if(!i.get(e.groupName))return}for(const[,e]of i)ye.remove(e.map,t);return}for(const[,e]of this.list.entries())for(const[,i]of e)ye.remove(i.map,t)}async byModel(t){const e=this.components.get(Ae),i=(null==t?void 0:t.classificationName)??"Models";for(const[s,n]of e.list){if(t&&t.modelIds&&!t.modelIds.some(t=>t.test(s)))continue;const e=await n.getItemsIdsWithGeometry(),r={[s]:new Set(e)};this.getGroupData(i,s),this.addGroupItems(i,s,r)}}};e(Le,"uuid","e25a7f3c-46c4-4a14-9d3d-5115f24ebeb7");let Re=Le;class Fe{constructor(t,i){e(this,"enabled",!0),e(this,"components"),e(this,"onDisposed",new U),e(this,"mouse"),e(this,"three",new r.Raycaster),e(this,"world");const s=i.renderer;if(!s)throw new Error("A renderer is needed for the raycaster to work!");this.world=i,this.mouse=new Ce(s.three.domElement),this.components=t}dispose(){this.mouse.dispose(),this.onDisposed.trigger(),this.onDisposed.reset()}castRayToObjects(t=Array.from(this.world.meshes),e=this.mouse.position){if(!this.world)throw new Error("A world is needed to cast rays!");const i=this.world.camera.three;return this.three.setFromCamera(e,i),this.intersect(t)}async castRay(t){const e=null==t?void 0:t.snappingClasses,i=(null==t?void 0:t.items)??Array.from(this.world.meshes),s=(null==t?void 0:t.position)??this.mouse.position;if(!this.world)throw new Error("A world is needed to cast rays!");const n=this.world.camera.three,r=this.components.get(Ae),o=this.world.renderer.three.domElement,a=this.mouse.rawPosition;let l=null;if(r.initialized&&(l=await r.raycast({camera:n,dom:o,mouse:a,snappingClasses:e}),0===i.length))return l;this.three.setFromCamera(s,n);const h=this.intersect(i);return l?h&&h.distance<l.distance?h:l:h}intersect(t=Array.from(this.world.meshes)){const e=this.three.intersectObjects(t),i=this.filterClippingPlanes(e);return i.length>0?i[0]:null}filterClippingPlanes(t){if(!this.world.renderer)throw new Error("Renderer not found!");const e=this.world.renderer.three;if(!e.clippingPlanes)return t;const i=e.clippingPlanes;return t.length<=0||!i||(null==i?void 0:i.length)<=0?t:t.filter(t=>i.every(e=>e.distanceToPoint(t.point)>0))}}const Ve=class t extends F{constructor(i){super(i),e(this,"enabled",!0),e(this,"list",new Map),e(this,"onDisposed",new U),i.add(t.uuid,this)}get(t){if(this.list.has(t.uuid))return this.list.get(t.uuid);const e=new Fe(this.components,t);return this.list.set(t.uuid,e),t.onDisposed.add(()=>{this.delete(t)}),e}delete(t){const e=this.list.get(t.uuid);e&&e.dispose(),this.list.delete(t.uuid)}dispose(){for(const[t,e]of this.list)e.dispose();this.list.clear(),this.onDisposed.trigger()}};e(Ve,"uuid","d5d8bdf0-db25-4952-b951-b643af207ace");let je=Ve;class Ze extends R{constructor(){super(...arguments),e(this,"onCameraChanged",new U),e(this,"meshes",new Set),e(this,"onAfterUpdate",new U),e(this,"onBeforeUpdate",new U),e(this,"onDisposed",new U),e(this,"isDisposing",!1),e(this,"enabled",!0),e(this,"_dynamicAnchor",!1),e(this,"uuid",q.create()),e(this,"name"),e(this,"_scene"),e(this,"_camera"),e(this,"_renderer",null),e(this,"onPointerDown",async t=>{if(!this.camera.hasCameraControls())throw new Error("World: can't set dynamic anchor if the camera doesn't have controls.");const e=this.components.get(je).get(this),i=await e.castRay();i&&i.point&&0===t.button&&this.camera.controls.setOrbitPoint(i.point.x,i.point.y,i.point.z)}),e(this,"_defaultCamera")}set dynamicAnchor(t){var e;const i=null==(e=this.renderer)?void 0:e.three.domElement.parentElement;if(!i)throw new Error("World: the renderer must have a parentElement to set dynamic anchoring.");t?(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(t){this._defaultCamera=t}get scene(){if(!this._scene)throw new Error("No scene initialized!");return this._scene}set scene(t){this._scene=t,t.worlds.set(this.uuid,this),t.currentWorld=this,t.onWorldChanged.trigger({world:this,action:"added"})}get camera(){if(!this._camera)throw new Error("No camera initialized!");return this._camera}set camera(t){this._camera||(this.defaultCamera=t),this._camera=t,t.currentWorld=this,this.onCameraChanged.trigger(t)}get renderer(){return this._renderer}set renderer(t){this._renderer=t,t&&(t.worlds.set(this.uuid,this),t.currentWorld=this,t.onWorldChanged.trigger({world:this,action:"added"}))}useDefaultCamera(){this.camera=this.defaultCamera}update(t){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(t),this.camera.isUpdateable()&&this.camera.update(t),this.renderer&&this.renderer.update(t),this.onAfterUpdate.trigger())}dispose(t=!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"}),t){const t=this.components.get($);this.scene.dispose(),this.camera.isDisposeable()&&this.camera.dispose(),this.renderer&&this.renderer.dispose();for(const e of this.meshes)t.destroy(e);this.meshes.clear()}this._scene=null,this._camera=null,this._renderer=null;this.components.get(Yi).list.delete(this.uuid),this.onDisposed.trigger(),this.onDisposed.reset()}}class He{constructor(t,i){e(this,"_list"),e(this,"_scene"),this._list=t,this._scene=i}get color(){return this._list.directionalLight.color.value}set color(t){this._list.directionalLight.color.value=t;for(const[,e]of this._scene.directionalLights)e.color.copy(t)}get intensity(){return this._list.directionalLight.intensity.value}set intensity(t){this._list.directionalLight.intensity.value=t;for(const[,e]of this._scene.directionalLights)e.intensity=t}get position(){return this._list.directionalLight.position.value.clone()}set position(t){this._list.directionalLight.position.value=t;for(const[,e]of this._scene.directionalLights)e.position.copy(t)}}class $e{constructor(t,i){e(this,"_list"),e(this,"_scene"),this._list=t,this._scene=i}get color(){return this._list.ambientLight.color.value}set color(t){this._list.ambientLight.color.value=t;for(const[,e]of this._scene.ambientLights)e.color.copy(t)}get intensity(){return this._list.ambientLight.intensity.value}set intensity(t){this._list.ambientLight.intensity.value=t;for(const[,e]of this._scene.ambientLights)e.intensity=t}}class We extends xe{constructor(){super(...arguments),e(this,"_config",{backgroundColor:{value:new r.Color,type:"Color"},ambientLight:{color:{type:"Color",value:new r.Color},intensity:{type:"Number",interpolable:!0,min:0,max:10,value:2}},directionalLight:{color:{type:"Color",value:new r.Color},intensity:{type:"Number",interpolable:!0,min:0,max:10,value:2},position:{type:"Vector3",value:new r.Vector3}}}),e(this,"ambientLight",new $e(this._config,this._component)),e(this,"directionalLight",new He(this._config,this._component))}get backgroundColor(){return this._config.backgroundColor.value}set backgroundColor(t){this._config.backgroundColor.value=t,this._component.three.background=t}}class Ye extends W{constructor(t){super(t),e(this,"onSetup",new U),e(this,"isSetup",!1),e(this,"three"),e(this,"config",new We(this,this.components,"Scene")),e(this,"_defaultConfig",{backgroundColor:new r.Color(2107698),directionalLight:{color:new r.Color("white"),intensity:1.5,position:new r.Vector3(5,10,3)},ambientLight:{color:new r.Color("white"),intensity:1}}),this.three=new r.Scene,this.three.background=new r.Color(2107698)}setup(t){const e={...this._defaultConfig,...t};this.config.backgroundColor=e.backgroundColor;const i=e.ambientLight;this.config.ambientLight.color=i.color,this.config.ambientLight.intensity=i.intensity;const s=e.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:o}=this.config.directionalLight,a=new r.DirectionalLight(n,o);a.position.copy(s.position);const{color:l,intensity:h}=this.config.directionalLight,c=new r.AmbientLight(l,h);this.three.add(a,c),this.directionalLights.set(a.uuid,a),this.ambientLights.set(c.uuid,c),this.isSetup=!0,this.onSetup.trigger()}dispose(){super.dispose();this.components.get(Te).list.delete(this.config.uuid)}}class Xe extends Z{constructor(t,i,s){super(t),e(this,"enabled",!0),e(this,"container"),e(this,"three"),e(this,"_canvas"),e(this,"_parameters"),e(this,"_resizeObserver",null),e(this,"onContainerUpdated",new U),e(this,"_resizing",!1),e(this,"resize",t=>{if(this._resizing)return;this._resizing=!0,this.onContainerUpdated.trigger();const e=t?t.x:this.container.clientWidth,i=t?t.y:this.container.clientHeight;this.three.setSize(e,i),this.onResize.trigger(new r.Vector2(e,i)),this._resizing=!1}),e(this,"resizeEvent",()=>{this.resize()}),e(this,"onContextLost",t=>{t.preventDefault(),this.enabled=!1}),e(this,"onContextBack",()=>{this.three.setRenderTarget(null),this.three.dispose(),this.three=new r.WebGLRenderer({canvas:this._canvas,antialias:!0,alpha:!0,...this._parameters}),this.enabled=!0}),this.container=i,this._parameters=s,this.three=new r.WebGLRenderer({antialias:!0,alpha:!0,...s}),this.three.setPixelRatio(Math.min(window.devicePixelRatio,2)),this.setupRenderer(),this.setupEvents(!0),this.resize(),this._canvas=this.three.domElement;const n=this.three.getContext(),{canvas:o}=n;o.addEventListener("webglcontextlost",this.onContextLost,!1),o.addEventListener("webglcontextrestored",this.onContextBack,!1)}update(){if(!this.enabled||!this.currentWorld)return;this.onBeforeUpdate.trigger(this);const t=this.currentWorld.scene.three,e=this.currentWorld.camera.three;this.three.render(t,e),this.onAfterUpdate.trigger(this)}dispose(){this.enabled=!1,this.setupEvents(!1),this.three.domElement.remove(),this.three.forceContextLoss(),this.three.dispose(),this.onResize.reset(),this.onAfterUpdate.reset(),this.onBeforeUpdate.reset(),this.onDisposed.trigger(),this.onDisposed.reset()}getSize(){return new r.Vector2(this.three.domElement.clientWidth,this.three.domElement.clientHeight)}setupEvents(t){const e=this.three.domElement.parentElement;if(!e)throw new Error("This renderer needs to have an HTML container!");this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=null),window.removeEventListener("resize",this.resizeEvent),t&&(this._resizeObserver=new ResizeObserver(this.resizeEvent),this._resizeObserver.observe(e),window.addEventListener("resize",this.resizeEvent))}setupRenderer(){this.three.localClippingEnabled=!0,this.container&&this.container.appendChild(this.three.domElement),this.onContainerUpdated.trigger()}}
|
|
2
2
|
/*!
|
|
3
3
|
* camera-controls
|
|
4
4
|
* https://github.com/yomotsu/camera-controls
|
|
5
5
|
* (c) 2017 @yomotsu
|
|
6
6
|
* Released under the MIT License.
|
|
7
|
-
*/const Ms=1,Ds=2,bs=4,xs=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}),Us=0,Bs=1,Vs=-1;function Ys(e){return e.isPerspectiveCamera}function Gs(e){return e.isOrthographicCamera}const zs=2*Math.PI,ks=Math.PI/2,Hs=Math.PI/180;function Ws(e,t,i){return Math.max(t,Math.min(i,e))}function Xs(e,t=1e-5){return Math.abs(e)<t}function Zs(e,t,i=1e-5){return Xs(e-t,i)}function $s(e,t){return Math.round(e/t)*t}function js(e){return isFinite(e)?e:e<0?-Number.MAX_VALUE:Number.MAX_VALUE}function qs(e){return Math.abs(e)<Number.MAX_VALUE?e:e*(1/0)}function Qs(e,t,i,s,n=1/0,r){const o=2/(s=Math.max(1e-4,s)),a=o*r,c=1/(1+a+.48*a*a+.235*a*a*a);let l=e-t;const h=t,u=n*s;l=Ws(l,-u,u),t=e-l;const I=(i.value+o*l)*r;i.value=(i.value-o*I)*c;let d=t+(l+I)*c;return h-e>0==d>h&&(d=h,i.value=(d-h)/r),d}function Ks(e,t,i,s,n=1/0,r,o){const a=2/(s=Math.max(1e-4,s)),c=a*r,l=1/(1+c+.48*c*c+.235*c*c*c);let h=t.x,u=t.y,I=t.z,d=e.x-h,E=e.y-u,f=e.z-I;const p=h,C=u,T=I,m=n*s,R=d*d+E*E+f*f;if(R>m*m){const e=Math.sqrt(R);d=d/e*m,E=E/e*m,f=f/e*m}h=e.x-d,u=e.y-E,I=e.z-f;const g=(i.x+a*d)*r,A=(i.y+a*E)*r,F=(i.z+a*f)*r;i.x=(i.x-a*g)*l,i.y=(i.y-a*A)*l,i.z=(i.z-a*F)*l,o.x=h+(d+g)*l,o.y=u+(E+A)*l,o.z=I+(f+F)*l;const S=p-e.x,O=C-e.y,N=T-e.z;return S*(o.x-p)+O*(o.y-C)+N*(o.z-T)>0&&(o.x=p,o.y=C,o.z=T,i.x=(o.x-p)/r,i.y=(o.y-C)/r,i.z=(o.z-T)/r),o}function Js(e,t){t.set(0,0),e.forEach((e=>{t.x+=e.clientX,t.y+=e.clientY})),t.x/=e.length,t.y/=e.length}function en(e,t){return!!Gs(e)&&(console.warn(`${t} is not supported in OrthographicCamera`),!0)}class tn{constructor(){this._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 i=this._listeners[e];if(void 0!==i){const e=i.indexOf(t);-1!==e&&i.splice(e,1)}}removeAllEventListeners(e){e?Array.isArray(this._listeners[e])&&(this._listeners[e].length=0):this._listeners={}}dispatchEvent(e){const t=this._listeners[e.type];if(void 0!==t){e.target=this;const i=t.slice(0);for(let t=0,s=i.length;t<s;t++)i[t].call(this,e)}}}var sn;const nn=1/8,rn=/Mac/.test(null===(sn=null===globalThis||void 0===globalThis?void 0:globalThis.navigator)||void 0===sn?void 0:sn.platform);let on,an,cn,ln,hn,un,In,dn,En,fn,pn,Cn,Tn,mn,Rn,gn,An,Fn,Sn,On,Nn,yn,_n;class Ln extends tn{static install(e){on=e.THREE,an=Object.freeze(new on.Vector3(0,0,0)),cn=Object.freeze(new on.Vector3(0,1,0)),ln=Object.freeze(new on.Vector3(0,0,1)),hn=new on.Vector2,un=new on.Vector3,In=new on.Vector3,dn=new on.Vector3,En=new on.Vector3,fn=new on.Vector3,pn=new on.Vector3,Cn=new on.Vector3,Tn=new on.Vector3,mn=new on.Vector3,Rn=new on.Spherical,gn=new on.Spherical,An=new on.Box3,Fn=new on.Box3,Sn=new on.Sphere,On=new on.Quaternion,Nn=new on.Quaternion,yn=new on.Matrix4,_n=new on.Raycaster}static get ACTION(){return xs}set verticalDragToForward(e){console.warn("camera-controls: `verticalDragToForward` was removed. Use `mouseButtons.left = CameraControls.ACTION.SCREEN_PAN` instead.")}constructor(e,t){super(),this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.minDistance=Number.EPSILON,this.maxDistance=1/0,this.infinityDolly=!1,this.minZoom=.01,this.maxZoom=1/0,this.smoothTime=.25,this.draggingSmoothTime=.125,this.maxSpeed=1/0,this.azimuthRotateSpeed=1,this.polarRotateSpeed=1,this.dollySpeed=1,this.dollyDragInverted=!1,this.truckSpeed=2,this.dollyToCursor=!1,this.dragToOffset=!1,this.boundaryFriction=0,this.restThreshold=.01,this.colliderMeshes=[],this.cancel=()=>{},this._enabled=!0,this._state=xs.NONE,this._viewport=null,this._changedDolly=0,this._changedZoom=0,this._hasRested=!0,this._boundaryEnclosesCamera=!1,this._needsUpdate=!0,this._updatedLastTime=!1,this._elementRect=new DOMRect,this._isDragging=!1,this._dragNeedsUpdate=!0,this._activePointers=[],this._lockedPointer=null,this._interactiveArea=new DOMRect(0,0,1,1),this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._isUserControllingOffset=!1,this._isUserControllingZoom=!1,this._lastDollyDirection=Us,this._thetaVelocity={value:0},this._phiVelocity={value:0},this._radiusVelocity={value:0},this._targetVelocity=new on.Vector3,this._focalOffsetVelocity=new on.Vector3,this._zoomVelocity={value:0},this._truckInternal=(e,t,i,s)=>{let n,r;if(Ys(this._camera)){const i=un.copy(this._camera.position).sub(this._target),s=this._camera.getEffectiveFOV()*Hs,o=i.length()*Math.tan(.5*s);n=this.truckSpeed*e*o/this._elementRect.height,r=this.truckSpeed*t*o/this._elementRect.height}else{if(!Gs(this._camera))return;{const i=this._camera;n=this.truckSpeed*e*(i.right-i.left)/i.zoom/this._elementRect.width,r=this.truckSpeed*t*(i.top-i.bottom)/i.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)},this._rotateInternal=(e,t)=>{const i=zs*this.azimuthRotateSpeed*e/this._elementRect.height,s=zs*this.polarRotateSpeed*t/this._elementRect.height;this.rotate(i,s,!0)},this._dollyInternal=(e,t,i)=>{const s=Math.pow(.95,-e*this.dollySpeed),n=this._sphericalEnd.radius,r=this._sphericalEnd.radius*s,o=Ws(r,this.minDistance,this.maxDistance),a=o-r;this.infinityDolly&&this.dollyToCursor?this._dollyToNoClamp(r,!0):this.infinityDolly&&!this.dollyToCursor?(this.dollyInFixed(a,!0),this._dollyToNoClamp(o,!0)):this._dollyToNoClamp(o,!0),this.dollyToCursor&&(this._changedDolly+=(this.infinityDolly?r:o)-n,this._dollyControlCoord.set(t,i)),this._lastDollyDirection=Math.sign(-e)},this._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))},void 0===on&&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 on.Quaternion).setFromUnitVectors(this._camera.up,cn),this._yAxisUpSpaceInverse=this._yAxisUpSpace.clone().invert(),this._state=xs.NONE,this._target=new on.Vector3,this._targetEnd=this._target.clone(),this._focalOffset=new on.Vector3,this._focalOffsetEnd=this._focalOffset.clone(),this._spherical=(new on.Spherical).setFromVector3(un.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 on.Vector3,new on.Vector3,new on.Vector3,new on.Vector3],this._updateNearPlaneCorners(),this._boundary=new on.Box3(new on.Vector3(-1/0,-1/0,-1/0),new on.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 on.Vector2,this.mouseButtons={left:xs.ROTATE,middle:xs.DOLLY,right:xs.TRUCK,wheel:Ys(this._camera)?xs.DOLLY:Gs(this._camera)?xs.ZOOM:xs.NONE},this.touches={one:xs.TOUCH_ROTATE,two:Ys(this._camera)?xs.TOUCH_DOLLY_TRUCK:Gs(this._camera)?xs.TOUCH_ZOOM_TRUCK:xs.NONE,three:xs.TOUCH_TRUCK};const i=new on.Vector2,s=new on.Vector2,n=new on.Vector2,r=e=>{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(),i=e.clientX/t.width,s=e.clientY/t.height;if(i<this._interactiveArea.left||i>this._interactiveArea.right||s<this._interactiveArea.top||s>this._interactiveArea.bottom)return}const t="mouse"!==e.pointerType?null:(e.buttons&Ms)===Ms?Ms:(e.buttons&bs)===bs?bs:(e.buttons&Ds)===Ds?Ds:null;if(null!==t){const e=this._findPointerByMouseButton(t);e&&this._disposePointer(e)}if((e.buttons&Ms)===Ms&&this._lockedPointer)return;const i={pointerId:e.pointerId,clientX:e.clientX,clientY:e.clientY,deltaX:0,deltaY:0,mouseButton:t};this._activePointers.push(i),this._domElement.ownerDocument.removeEventListener("pointermove",o,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",a),this._domElement.ownerDocument.addEventListener("pointermove",o,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",a),this._isDragging=!0,u(e)},o=e=>{e.cancelable&&e.preventDefault();const t=e.pointerId,i=this._lockedPointer||this._findPointerById(t);if(i){if(i.clientX=e.clientX,i.clientY=e.clientY,i.deltaX=e.movementX,i.deltaY=e.movementY,this._state=0,"touch"===e.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&&(e.buttons&Ms)===Ms)&&(this._state=this._state|this.mouseButtons.left),this._isDragging&&(e.buttons&bs)===bs&&(this._state=this._state|this.mouseButtons.middle),this._isDragging&&(e.buttons&Ds)===Ds&&(this._state=this._state|this.mouseButtons.right);I()}},a=e=>{const t=this._findPointerById(e.pointerId);if(!t||t!==this._lockedPointer){if(t&&this._disposePointer(t),"touch"===e.pointerType)switch(this._activePointers.length){case 0:this._state=xs.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=xs.NONE;d()}};let c=-1;const l=e=>{if(!this._domElement)return;if(!this._enabled||this.mouseButtons.wheel===xs.NONE)return;if(0!==this._interactiveArea.left||0!==this._interactiveArea.top||1!==this._interactiveArea.width||1!==this._interactiveArea.height){const t=this._domElement.getBoundingClientRect(),i=e.clientX/t.width,s=e.clientY/t.height;if(i<this._interactiveArea.left||i>this._interactiveArea.right||s<this._interactiveArea.top||s>this._interactiveArea.bottom)return}if(e.preventDefault(),this.dollyToCursor||this.mouseButtons.wheel===xs.ROTATE||this.mouseButtons.wheel===xs.TRUCK){const e=performance.now();c-e<1e3&&this._getClientRect(this._elementRect),c=e}const t=rn?-1:-3,i=1===e.deltaMode||e.ctrlKey?e.deltaY/t:e.deltaY/(10*t),s=this.dollyToCursor?(e.clientX-this._elementRect.x)/this._elementRect.width*2-1:0,n=this.dollyToCursor?(e.clientY-this._elementRect.y)/this._elementRect.height*-2+1:0;switch(this.mouseButtons.wheel){case xs.ROTATE:this._rotateInternal(e.deltaX,e.deltaY),this._isUserControllingRotate=!0;break;case xs.TRUCK:this._truckInternal(e.deltaX,e.deltaY,!1,!1),this._isUserControllingTruck=!0;break;case xs.SCREEN_PAN:this._truckInternal(e.deltaX,e.deltaY,!1,!0),this._isUserControllingTruck=!0;break;case xs.OFFSET:this._truckInternal(e.deltaX,e.deltaY,!0,!1),this._isUserControllingOffset=!0;break;case xs.DOLLY:this._dollyInternal(-i,s,n),this._isUserControllingDolly=!0;break;case xs.ZOOM:this._zoomInternal(-i,s,n),this._isUserControllingZoom=!0}this.dispatchEvent({type:"control"})},h=e=>{if(this._domElement&&this._enabled){if(this.mouseButtons.right===Ln.ACTION.NONE){const t=e instanceof PointerEvent?e.pointerId:0,i=this._findPointerById(t);return i&&this._disposePointer(i),this._domElement.ownerDocument.removeEventListener("pointermove",o,{passive:!1}),void this._domElement.ownerDocument.removeEventListener("pointerup",a)}e.preventDefault()}},u=e=>{if(!this._enabled)return;Js(this._activePointers,hn),this._getClientRect(this._elementRect),i.copy(hn),s.copy(hn);if(this._activePointers.length>=2){const e=hn.x-this._activePointers[1].clientX,t=hn.y-this._activePointers[1].clientY,i=Math.sqrt(e*e+t*t);n.set(0,i);const r=.5*(this._activePointers[0].clientX+this._activePointers[1].clientX),o=.5*(this._activePointers[0].clientY+this._activePointers[1].clientY);s.set(r,o)}if(this._state=0,e)if("pointerType"in e&&"touch"===e.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||(e.buttons&Ms)!==Ms||(this._state=this._state|this.mouseButtons.left),(e.buttons&bs)===bs&&(this._state=this._state|this.mouseButtons.middle),(e.buttons&Ds)===Ds&&(this._state=this._state|this.mouseButtons.right);else this._lockedPointer&&(this._state=this._state|this.mouseButtons.left);(this._state&xs.ROTATE)!==xs.ROTATE&&(this._state&xs.TOUCH_ROTATE)!==xs.TOUCH_ROTATE&&(this._state&xs.TOUCH_DOLLY_ROTATE)!==xs.TOUCH_DOLLY_ROTATE&&(this._state&xs.TOUCH_ZOOM_ROTATE)!==xs.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&xs.TRUCK)!==xs.TRUCK&&(this._state&xs.SCREEN_PAN)!==xs.SCREEN_PAN&&(this._state&xs.TOUCH_TRUCK)!==xs.TOUCH_TRUCK&&(this._state&xs.TOUCH_SCREEN_PAN)!==xs.TOUCH_SCREEN_PAN&&(this._state&xs.TOUCH_DOLLY_TRUCK)!==xs.TOUCH_DOLLY_TRUCK&&(this._state&xs.TOUCH_DOLLY_SCREEN_PAN)!==xs.TOUCH_DOLLY_SCREEN_PAN&&(this._state&xs.TOUCH_ZOOM_TRUCK)!==xs.TOUCH_ZOOM_TRUCK&&(this._state&xs.TOUCH_ZOOM_SCREEN_PAN)!==xs.TOUCH_DOLLY_SCREEN_PAN||(this._targetEnd.copy(this._target),this._targetVelocity.set(0,0,0)),(this._state&xs.DOLLY)!==xs.DOLLY&&(this._state&xs.TOUCH_DOLLY)!==xs.TOUCH_DOLLY&&(this._state&xs.TOUCH_DOLLY_TRUCK)!==xs.TOUCH_DOLLY_TRUCK&&(this._state&xs.TOUCH_DOLLY_SCREEN_PAN)!==xs.TOUCH_DOLLY_SCREEN_PAN&&(this._state&xs.TOUCH_DOLLY_OFFSET)!==xs.TOUCH_DOLLY_OFFSET&&(this._state&xs.TOUCH_DOLLY_ROTATE)!==xs.TOUCH_DOLLY_ROTATE||(this._sphericalEnd.radius=this._spherical.radius,this._radiusVelocity.value=0),(this._state&xs.ZOOM)!==xs.ZOOM&&(this._state&xs.TOUCH_ZOOM)!==xs.TOUCH_ZOOM&&(this._state&xs.TOUCH_ZOOM_TRUCK)!==xs.TOUCH_ZOOM_TRUCK&&(this._state&xs.TOUCH_ZOOM_SCREEN_PAN)!==xs.TOUCH_ZOOM_SCREEN_PAN&&(this._state&xs.TOUCH_ZOOM_OFFSET)!==xs.TOUCH_ZOOM_OFFSET&&(this._state&xs.TOUCH_ZOOM_ROTATE)!==xs.TOUCH_ZOOM_ROTATE||(this._zoomEnd=this._zoom,this._zoomVelocity.value=0),(this._state&xs.OFFSET)!==xs.OFFSET&&(this._state&xs.TOUCH_OFFSET)!==xs.TOUCH_OFFSET&&(this._state&xs.TOUCH_DOLLY_OFFSET)!==xs.TOUCH_DOLLY_OFFSET&&(this._state&xs.TOUCH_ZOOM_OFFSET)!==xs.TOUCH_ZOOM_OFFSET||(this._focalOffsetEnd.copy(this._focalOffset),this._focalOffsetVelocity.set(0,0,0)),this.dispatchEvent({type:"controlstart"})},I=()=>{if(!this._enabled||!this._dragNeedsUpdate)return;this._dragNeedsUpdate=!1,Js(this._activePointers,hn);const e=this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement?this._lockedPointer||this._activePointers[0]:null,t=e?-e.deltaX:s.x-hn.x,r=e?-e.deltaY:s.y-hn.y;if(s.copy(hn),(this._state&xs.ROTATE)!==xs.ROTATE&&(this._state&xs.TOUCH_ROTATE)!==xs.TOUCH_ROTATE&&(this._state&xs.TOUCH_DOLLY_ROTATE)!==xs.TOUCH_DOLLY_ROTATE&&(this._state&xs.TOUCH_ZOOM_ROTATE)!==xs.TOUCH_ZOOM_ROTATE||(this._rotateInternal(t,r),this._isUserControllingRotate=!0),(this._state&xs.DOLLY)===xs.DOLLY||(this._state&xs.ZOOM)===xs.ZOOM){const e=this.dollyToCursor?(i.x-this._elementRect.x)/this._elementRect.width*2-1:0,t=this.dollyToCursor?(i.y-this._elementRect.y)/this._elementRect.height*-2+1:0,s=this.dollyDragInverted?-1:1;(this._state&xs.DOLLY)===xs.DOLLY?(this._dollyInternal(s*r*nn,e,t),this._isUserControllingDolly=!0):(this._zoomInternal(s*r*nn,e,t),this._isUserControllingZoom=!0)}if((this._state&xs.TOUCH_DOLLY)===xs.TOUCH_DOLLY||(this._state&xs.TOUCH_ZOOM)===xs.TOUCH_ZOOM||(this._state&xs.TOUCH_DOLLY_TRUCK)===xs.TOUCH_DOLLY_TRUCK||(this._state&xs.TOUCH_ZOOM_TRUCK)===xs.TOUCH_ZOOM_TRUCK||(this._state&xs.TOUCH_DOLLY_SCREEN_PAN)===xs.TOUCH_DOLLY_SCREEN_PAN||(this._state&xs.TOUCH_ZOOM_SCREEN_PAN)===xs.TOUCH_ZOOM_SCREEN_PAN||(this._state&xs.TOUCH_DOLLY_OFFSET)===xs.TOUCH_DOLLY_OFFSET||(this._state&xs.TOUCH_ZOOM_OFFSET)===xs.TOUCH_ZOOM_OFFSET||(this._state&xs.TOUCH_DOLLY_ROTATE)===xs.TOUCH_DOLLY_ROTATE||(this._state&xs.TOUCH_ZOOM_ROTATE)===xs.TOUCH_ZOOM_ROTATE){const e=hn.x-this._activePointers[1].clientX,t=hn.y-this._activePointers[1].clientY,i=Math.sqrt(e*e+t*t),r=n.y-i;n.set(0,i);const o=this.dollyToCursor?(s.x-this._elementRect.x)/this._elementRect.width*2-1:0,a=this.dollyToCursor?(s.y-this._elementRect.y)/this._elementRect.height*-2+1:0;(this._state&xs.TOUCH_DOLLY)===xs.TOUCH_DOLLY||(this._state&xs.TOUCH_DOLLY_ROTATE)===xs.TOUCH_DOLLY_ROTATE||(this._state&xs.TOUCH_DOLLY_TRUCK)===xs.TOUCH_DOLLY_TRUCK||(this._state&xs.TOUCH_DOLLY_SCREEN_PAN)===xs.TOUCH_DOLLY_SCREEN_PAN||(this._state&xs.TOUCH_DOLLY_OFFSET)===xs.TOUCH_DOLLY_OFFSET?(this._dollyInternal(r*nn,o,a),this._isUserControllingDolly=!0):(this._zoomInternal(r*nn,o,a),this._isUserControllingZoom=!0)}(this._state&xs.TRUCK)!==xs.TRUCK&&(this._state&xs.TOUCH_TRUCK)!==xs.TOUCH_TRUCK&&(this._state&xs.TOUCH_DOLLY_TRUCK)!==xs.TOUCH_DOLLY_TRUCK&&(this._state&xs.TOUCH_ZOOM_TRUCK)!==xs.TOUCH_ZOOM_TRUCK||(this._truckInternal(t,r,!1,!1),this._isUserControllingTruck=!0),(this._state&xs.SCREEN_PAN)!==xs.SCREEN_PAN&&(this._state&xs.TOUCH_SCREEN_PAN)!==xs.TOUCH_SCREEN_PAN&&(this._state&xs.TOUCH_DOLLY_SCREEN_PAN)!==xs.TOUCH_DOLLY_SCREEN_PAN&&(this._state&xs.TOUCH_ZOOM_SCREEN_PAN)!==xs.TOUCH_ZOOM_SCREEN_PAN||(this._truckInternal(t,r,!1,!0),this._isUserControllingTruck=!0),(this._state&xs.OFFSET)!==xs.OFFSET&&(this._state&xs.TOUCH_OFFSET)!==xs.TOUCH_OFFSET&&(this._state&xs.TOUCH_DOLLY_OFFSET)!==xs.TOUCH_DOLLY_OFFSET&&(this._state&xs.TOUCH_ZOOM_OFFSET)!==xs.TOUCH_ZOOM_OFFSET||(this._truckInternal(t,r,!0,!1),this._isUserControllingOffset=!0),this.dispatchEvent({type:"control"})},d=()=>{Js(this._activePointers,hn),s.copy(hn),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",o,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",a),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",o,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",a),this._domElement.requestPointerLock(),this._domElement.ownerDocument.addEventListener("pointerlockchange",E),this._domElement.ownerDocument.addEventListener("pointerlockerror",f),this._domElement.ownerDocument.addEventListener("pointermove",o,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",a),u())},this.unlockPointer=()=>{var e,t,i;null!==this._lockedPointer&&(this._disposePointer(this._lockedPointer),this._lockedPointer=null),null===(e=this._domElement)||void 0===e||e.ownerDocument.exitPointerLock(),null===(t=this._domElement)||void 0===t||t.ownerDocument.removeEventListener("pointerlockchange",E),null===(i=this._domElement)||void 0===i||i.ownerDocument.removeEventListener("pointerlockerror",f),this.cancel()};const E=()=>{this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement||this.unlockPointer()},f=()=>{this.unlockPointer()};this._addAllEventListeners=e=>{this._domElement=e,this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none",this._domElement.addEventListener("pointerdown",r),this._domElement.addEventListener("pointercancel",a),this._domElement.addEventListener("wheel",l,{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",a),this._domElement.removeEventListener("wheel",l,{passive:!1}),this._domElement.removeEventListener("contextmenu",h),this._domElement.ownerDocument.removeEventListener("pointermove",o,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",a),this._domElement.ownerDocument.removeEventListener("pointerlockchange",E),this._domElement.ownerDocument.removeEventListener("pointerlockerror",f))},this.cancel=()=>{this._state!==xs.NONE&&(this._state=xs.NONE,this._activePointers.length=0,d())},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=Ws(e.width,0,1),this._interactiveArea.height=Ws(e.height,0,1),this._interactiveArea.x=Ws(e.x,0,1-this._interactiveArea.width),this._interactiveArea.y=Ws(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=Ws(e,this.minAzimuthAngle,this.maxAzimuthAngle),n=Ws(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||Zs(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&Zs(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=Us,this._changedDolly=0,this._dollyToNoClamp(Ws(e,this.minDistance,this.maxDistance),t)}_dollyToNoClamp(e,t=!1){const i=this._sphericalEnd.radius;if(this.colliderMeshes.length>=1){const t=this._collisionTest(),s=Zs(t,this._spherical.radius);if(!(i>e)&&s)return Promise.resolve();this._sphericalEnd.radius=Math.min(e,t)}else this._sphericalEnd.radius=e;this._needsUpdate=!0,t||(this._spherical.radius=this._sphericalEnd.radius);const s=!t||Zs(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(s)}dollyInFixed(e,t=!1){this._targetEnd.add(this._getCameraDirection(En).multiplyScalar(e)),t||this._target.copy(this._targetEnd);const i=!t||Zs(this._target.x,this._targetEnd.x,this.restThreshold)&&Zs(this._target.y,this._targetEnd.y,this.restThreshold)&&Zs(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=Ws(e,this.minZoom,this.maxZoom),this._needsUpdate=!0,t||(this._zoom=this._zoomEnd);const i=!t||Zs(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(),fn.setFromMatrixColumn(this._camera.matrix,0),pn.setFromMatrixColumn(this._camera.matrix,1),fn.multiplyScalar(e),pn.multiplyScalar(-t);const s=un.copy(fn).add(pn),n=In.copy(this._targetEnd).add(s);return this.moveTo(n.x,n.y,n.z,i)}forward(e,t=!1){un.setFromMatrixColumn(this._camera.matrix,0),un.crossVectors(this._camera.up,un),un.multiplyScalar(e);const i=In.copy(this._targetEnd).add(un);return this.moveTo(i.x,i.y,i.z,t)}elevate(e,t=!1){return un.copy(this._camera.up).multiplyScalar(e),this.moveTo(this._targetEnd.x+un.x,this._targetEnd.y+un.y,this._targetEnd.z+un.z,t)}moveTo(e,t,i,s=!1){this._isUserControllingTruck=!1;const n=un.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||Zs(this._target.x,this._targetEnd.x,this.restThreshold)&&Zs(this._target.y,this._targetEnd.y,this.restThreshold)&&Zs(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(r)}lookInDirectionOf(e,t,i,s=!1){const n=un.set(e,t,i).sub(this._targetEnd).normalize().multiplyScalar(-this._sphericalEnd.radius).add(this._targetEnd);return this.setPosition(n.x,n.y,n.z,s)}fitToBox(e,t,{cover:i=!1,paddingLeft:s=0,paddingRight:n=0,paddingBottom:r=0,paddingTop:o=0}={}){const a=[],c=e.isBox3?An.copy(e):An.setFromObject(e);c.isEmpty()&&(console.warn("camera-controls: fitTo() cannot be used with an empty box. Aborting"),Promise.resolve());const l=$s(this._sphericalEnd.theta,ks),h=$s(this._sphericalEnd.phi,ks);a.push(this.rotateTo(l,h,t));const u=un.setFromSpherical(this._sphericalEnd).normalize(),I=On.setFromUnitVectors(u,ln),d=Zs(Math.abs(u.y),1);d&&I.multiply(Nn.setFromAxisAngle(cn,l)),I.multiply(this._yAxisUpSpaceInverse);const E=Fn.makeEmpty();In.copy(c.min).applyQuaternion(I),E.expandByPoint(In),In.copy(c.min).setX(c.max.x).applyQuaternion(I),E.expandByPoint(In),In.copy(c.min).setY(c.max.y).applyQuaternion(I),E.expandByPoint(In),In.copy(c.max).setZ(c.min.z).applyQuaternion(I),E.expandByPoint(In),In.copy(c.min).setZ(c.max.z).applyQuaternion(I),E.expandByPoint(In),In.copy(c.max).setY(c.min.y).applyQuaternion(I),E.expandByPoint(In),In.copy(c.max).setX(c.min.x).applyQuaternion(I),E.expandByPoint(In),In.copy(c.max).applyQuaternion(I),E.expandByPoint(In),E.min.x-=s,E.min.y-=r,E.max.x+=n,E.max.y+=o,I.setFromUnitVectors(ln,u),d&&I.premultiply(Nn.invert()),I.premultiply(this._yAxisUpSpace);const f=E.getSize(un),p=E.getCenter(In).applyQuaternion(I);if(Ys(this._camera)){const e=this.getDistanceToFitBox(f.x,f.y,f.z,i);a.push(this.moveTo(p.x,p.y,p.z,t)),a.push(this.dollyTo(e,t)),a.push(this.setFocalOffset(0,0,0,t))}else if(Gs(this._camera)){const e=this._camera,s=e.right-e.left,n=e.top-e.bottom,r=i?Math.max(s/f.x,n/f.y):Math.min(s/f.x,n/f.y);a.push(this.moveTo(p.x,p.y,p.z,t)),a.push(this.zoomTo(r,t)),a.push(this.setFocalOffset(0,0,0,t))}return Promise.all(a)}fitToSphere(e,t){const i=[],s="isObject3D"in e?Ln.createBoundingSphere(e,Sn):Sn.copy(e);if(i.push(this.moveTo(s.center.x,s.center.y,s.center.z,t)),Ys(this._camera)){const e=this.getDistanceToFitSphere(s.radius);i.push(this.dollyTo(e,t))}else if(Gs(this._camera)){const e=this._camera.right-this._camera.left,n=this._camera.top-this._camera.bottom,r=2*s.radius,o=Math.min(e/r,n/r);i.push(this.zoomTo(o,t))}return i.push(this.setFocalOffset(0,0,0,t)),Promise.all(i)}setLookAt(e,t,i,s,n,r,o=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=Us,this._changedDolly=0;const a=In.set(s,n,r),c=un.set(e,t,i);this._targetEnd.copy(a),this._sphericalEnd.setFromVector3(c.sub(a).applyQuaternion(this._yAxisUpSpace)),this.normalizeRotations(),this._needsUpdate=!0,o||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const l=!o||Zs(this._target.x,this._targetEnd.x,this.restThreshold)&&Zs(this._target.y,this._targetEnd.y,this.restThreshold)&&Zs(this._target.z,this._targetEnd.z,this.restThreshold)&&Zs(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&Zs(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&Zs(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(l)}lerpLookAt(e,t,i,s,n,r,o,a,c,l,h,u,I,d=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=Us,this._changedDolly=0;const E=un.set(s,n,r),f=In.set(e,t,i);Rn.setFromVector3(f.sub(E).applyQuaternion(this._yAxisUpSpace));const p=dn.set(l,h,u),C=In.set(o,a,c);gn.setFromVector3(C.sub(p).applyQuaternion(this._yAxisUpSpace)),this._targetEnd.copy(E.lerp(p,I));const T=gn.theta-Rn.theta,m=gn.phi-Rn.phi,R=gn.radius-Rn.radius;this._sphericalEnd.set(Rn.radius+R*I,Rn.phi+m*I,Rn.theta+T*I),this.normalizeRotations(),this._needsUpdate=!0,d||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const g=!d||Zs(this._target.x,this._targetEnd.x,this.restThreshold)&&Zs(this._target.y,this._targetEnd.y,this.restThreshold)&&Zs(this._target.z,this._targetEnd.z,this.restThreshold)&&Zs(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&Zs(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&Zs(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(g)}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(un),r=this.setLookAt(n.x,n.y,n.z,e,t,i,s);return this._sphericalEnd.phi=Ws(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||Zs(this._focalOffset.x,this._focalOffsetEnd.x,this.restThreshold)&&Zs(this._focalOffset.y,this._focalOffsetEnd.y,this.restThreshold)&&Zs(this._focalOffset.z,this._focalOffsetEnd.z,this.restThreshold);return this._createOnRestPromise(n)}setOrbitPoint(e,t,i){this._camera.updateMatrixWorld(),fn.setFromMatrixColumn(this._camera.matrixWorldInverse,0),pn.setFromMatrixColumn(this._camera.matrixWorldInverse,1),Cn.setFromMatrixColumn(this._camera.matrixWorldInverse,2);const s=un.set(e,t,i),n=s.distanceTo(this._camera.position),r=s.sub(this._camera.position);fn.multiplyScalar(r.x),pn.multiplyScalar(r.y),Cn.multiplyScalar(r.z),un.copy(fn).add(pn).add(Cn),un.z=un.z+n,this.dollyTo(n,!1),this.setFocalOffset(-un.x,un.y,-un.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 on.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(en(this._camera,"getDistanceToFitBox"))return this._spherical.radius;const n=e/t,r=this._camera.getEffectiveFOV()*Hs,o=this._camera.aspect;return.5*((s?n>o:n<o)?t:e/o)/Math.tan(.5*r)+.5*i}getDistanceToFitSphere(e){if(en(this._camera,"getDistanceToFitSphere"))return this._spherical.radius;const t=this._camera.getEffectiveFOV()*Hs,i=2*Math.atan(Math.tan(.5*t)*this._camera.aspect),s=1<this._camera.aspect?t:i;return e/Math.sin(.5*s)}getTarget(e,t=!0){return(e&&e.isVector3?e:new on.Vector3).copy(t?this._targetEnd:this._target)}getPosition(e,t=!0){return(e&&e.isVector3?e:new on.Vector3).setFromSpherical(t?this._sphericalEnd:this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(t?this._targetEnd:this._target)}getSpherical(e,t=!0){return(e||new on.Spherical).copy(t?this._sphericalEnd:this._spherical)}getFocalOffset(e,t=!0){return(e&&e.isVector3?e:new on.Vector3).copy(t?this._focalOffsetEnd:this._focalOffset)}normalizeRotations(){this._sphericalEnd.theta=this._sphericalEnd.theta%zs,this._sphericalEnd.theta<0&&(this._sphericalEnd.theta+=zs),this._spherical.theta+=zs*Math.round((this._sphericalEnd.theta-this._spherical.theta)/zs)}stop(){this._focalOffset.copy(this._focalOffsetEnd),this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd),this._zoom=this._zoomEnd}reset(e=!1){if(!Zs(this._camera.up.x,this._cameraUp0.x)||!Zs(this._camera.up.y,this._cameraUp0.y)||!Zs(this._camera.up.z,this._cameraUp0.z)){this._camera.up.copy(this._cameraUp0);const e=this.getPosition(un);this.updateCameraUp(),this.setPosition(e.x,e.y,e.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,cn),this._yAxisUpSpaceInverse.copy(this._yAxisUpSpace).invert()}applyCameraUp(){const e=un.subVectors(this._target,this._camera.position).normalize(),t=In.crossVectors(e,this._camera.up);this._camera.up.crossVectors(t,e).normalize(),this._camera.updateMatrixWorld();const i=this.getPosition(un);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=Tn.subVectors(this._targetEnd,this._target),r=mn.subVectors(this._focalOffsetEnd,this._focalOffset),o=this._zoomEnd-this._zoom;if(Xs(t))this._thetaVelocity.value=0,this._spherical.theta=this._sphericalEnd.theta;else{const t=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.theta=Qs(this._spherical.theta,this._sphericalEnd.theta,this._thetaVelocity,t,1/0,e),this._needsUpdate=!0}if(Xs(i))this._phiVelocity.value=0,this._spherical.phi=this._sphericalEnd.phi;else{const t=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.phi=Qs(this._spherical.phi,this._sphericalEnd.phi,this._phiVelocity,t,1/0,e),this._needsUpdate=!0}if(Xs(s))this._radiusVelocity.value=0,this._spherical.radius=this._sphericalEnd.radius;else{const t=this._isUserControllingDolly?this.draggingSmoothTime:this.smoothTime;this._spherical.radius=Qs(this._spherical.radius,this._sphericalEnd.radius,this._radiusVelocity,t,this.maxSpeed,e),this._needsUpdate=!0}if(Xs(n.x)&&Xs(n.y)&&Xs(n.z))this._targetVelocity.set(0,0,0),this._target.copy(this._targetEnd);else{const t=this._isUserControllingTruck?this.draggingSmoothTime:this.smoothTime;Ks(this._target,this._targetEnd,this._targetVelocity,t,this.maxSpeed,e,this._target),this._needsUpdate=!0}if(Xs(r.x)&&Xs(r.y)&&Xs(r.z))this._focalOffsetVelocity.set(0,0,0),this._focalOffset.copy(this._focalOffsetEnd);else{const t=this._isUserControllingOffset?this.draggingSmoothTime:this.smoothTime;Ks(this._focalOffset,this._focalOffsetEnd,this._focalOffsetVelocity,t,this.maxSpeed,e,this._focalOffset),this._needsUpdate=!0}if(Xs(o))this._zoomVelocity.value=0,this._zoom=this._zoomEnd;else{const t=this._isUserControllingZoom?this.draggingSmoothTime:this.smoothTime;this._zoom=Qs(this._zoom,this._zoomEnd,this._zoomVelocity,t,1/0,e)}if(this.dollyToCursor)if(Ys(this._camera)&&0!==this._changedDolly){const e=this._spherical.radius-this._lastDistance,t=this._camera,i=this._getCameraDirection(En),s=un.copy(i).cross(t.up).normalize();0===s.lengthSq()&&(s.x=1);const n=In.crossVectors(s,i),r=this._sphericalEnd.radius*Math.tan(t.getEffectiveFOV()*Hs*.5),o=(this._sphericalEnd.radius-e-this._sphericalEnd.radius)/this._sphericalEnd.radius,a=dn.copy(this._targetEnd).add(s.multiplyScalar(this._dollyControlCoord.x*r*t.aspect)).add(n.multiplyScalar(this._dollyControlCoord.y*r)),c=un.copy(this._targetEnd).lerp(a,o),l=this._lastDollyDirection===Bs&&this._spherical.radius<=this.minDistance,h=this._lastDollyDirection===Vs&&this.maxDistance<=this._spherical.radius;if(this.infinityDolly&&(l||h)){this._sphericalEnd.radius-=e,this._spherical.radius-=e;const t=In.copy(i).multiplyScalar(-e);c.add(t)}this._boundary.clampPoint(c,c);const u=In.subVectors(c,this._targetEnd);this._targetEnd.copy(c),this._target.add(u),this._changedDolly-=e,Xs(this._changedDolly)&&(this._changedDolly=0)}else if(Gs(this._camera)&&0!==this._changedZoom){const e=this._zoom-this._lastZoom,t=this._camera,i=un.set(this._dollyControlCoord.x,this._dollyControlCoord.y,(t.near+t.far)/(t.near-t.far)).unproject(t),s=In.set(0,0,-1).applyQuaternion(t.quaternion),n=dn.copy(i).add(s.multiplyScalar(-i.dot(t.up))),r=-(this._zoom-e-this._zoom)/this._zoom,o=this._getCameraDirection(En),a=this._targetEnd.dot(o),c=un.copy(this._targetEnd).lerp(n,r),l=c.dot(o),h=o.multiplyScalar(l-a);c.sub(h),this._boundary.clampPoint(c,c);const u=In.subVectors(c,this._targetEnd);this._targetEnd.copy(c),this._target.add(u),this._changedZoom-=e,Xs(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 a=this._collisionTest();this._spherical.radius=Math.min(this._spherical.radius,a),this._spherical.makeSafe(),this._camera.position.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(this._target),this._camera.lookAt(this._target);(!Xs(this._focalOffset.x)||!Xs(this._focalOffset.y)||!Xs(this._focalOffset.z))&&(fn.setFromMatrixColumn(this._camera.matrix,0),pn.setFromMatrixColumn(this._camera.matrix,1),Cn.setFromMatrixColumn(this._camera.matrix,2),fn.multiplyScalar(this._focalOffset.x),pn.multiplyScalar(-this._focalOffset.y),Cn.multiplyScalar(this._focalOffset.z),un.copy(fn).add(pn).add(Cn),this._camera.position.add(un),this._camera.updateMatrixWorld()),this._boundaryEnclosesCamera&&this._encloseToBoundary(this._camera.position.copy(this._target),un.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse),1);const c=this._needsUpdate;return c&&!this._updatedLastTime?(this._hasRested=!1,this.dispatchEvent({type:"wake"}),this.dispatchEvent({type:"update"})):c?(this.dispatchEvent({type:"update"}),Xs(t,this.restThreshold)&&Xs(i,this.restThreshold)&&Xs(s,this.restThreshold)&&Xs(n.x,this.restThreshold)&&Xs(n.y,this.restThreshold)&&Xs(n.z,this.restThreshold)&&Xs(r.x,this.restThreshold)&&Xs(r.y,this.restThreshold)&&Xs(r.z,this.restThreshold)&&Xs(o,this.restThreshold)&&!this._hasRested&&(this._hasRested=!0,this.dispatchEvent({type:"rest"}))):!c&&this._updatedLastTime&&this.dispatchEvent({type:"sleep"}),this._lastDistance=this._spherical.radius,this._lastZoom=this._zoom,this._updatedLastTime=c,this._needsUpdate=!1,c}toJSON(){return JSON.stringify({enabled:this._enabled,minDistance:this.minDistance,maxDistance:js(this.maxDistance),minZoom:this.minZoom,maxZoom:js(this.maxZoom),minPolarAngle:this.minPolarAngle,maxPolarAngle:js(this.maxPolarAngle),minAzimuthAngle:js(this.minAzimuthAngle),maxAzimuthAngle:js(this.maxAzimuthAngle),smoothTime:this.smoothTime,draggingSmoothTime:this.draggingSmoothTime,dollySpeed:this.dollySpeed,truckSpeed:this.truckSpeed,dollyToCursor:this.dollyToCursor,target:this._targetEnd.toArray(),position:un.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=qs(i.maxDistance),this.minZoom=i.minZoom,this.maxZoom=qs(i.maxZoom),this.minPolarAngle=i.minPolarAngle,this.maxPolarAngle=qs(i.maxPolarAngle),this.minAzimuthAngle=qs(i.minAzimuthAngle),this.maxAzimuthAngle=qs(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),Rn.setFromVector3(un.fromArray(i.position).sub(this._targetEnd).applyQuaternion(this._yAxisUpSpace)),this.rotateTo(Rn.theta,Rn.phi,t),this.dollyTo(Rn.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","2.10.1"),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=In.copy(t).add(e),r=this._boundary.clampPoint(n,dn).sub(n),o=r.lengthSq();if(0===o)return e.add(t);if(o===s)return e;if(0===i)return e.add(t).add(r);{const s=1+i*o/t.dot(r);return e.add(In.copy(t).multiplyScalar(s)).add(r.multiplyScalar(1-i))}}_updateNearPlaneCorners(){if(Ys(this._camera)){const e=this._camera,t=e.near,i=e.getEffectiveFOV()*Hs,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(Gs(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)}}_collisionTest(){let e=1/0;if(!(this.colliderMeshes.length>=1))return e;if(en(this._camera,"_collisionTest"))return e;const t=this._getTargetDirection(En);yn.lookAt(an,t,this._camera.up);for(let i=0;i<4;i++){const s=In.copy(this._nearPlaneCorners[i]);s.applyMatrix4(yn);const n=dn.addVectors(this._target,s);_n.set(n,t),_n.far=this._spherical.radius+1;const r=_n.intersectObjects(this.colliderMeshes);0!==r.length&&r[0].distance<e&&(e=r[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((e=>{const t=()=>{this.removeEventListener("rest",t),e()};this.addEventListener("rest",t)})))}_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 on.Sphere){const i=t,s=i.center;An.makeEmpty(),e.traverseVisible((e=>{e.isMesh&&An.expandByObject(e)})),An.getCenter(s);let n=0;return e.traverseVisible((e=>{if(!e.isMesh)return;const t=e;if(!t.geometry)return;const i=t.geometry.clone();i.applyMatrix4(t.matrixWorld);const r=i.attributes.position;for(let e=0,t=r.count;e<t;e++)un.fromBufferAttribute(r,e),n=Math.max(n,s.distanceToSquared(un))})),i.radius=Math.sqrt(n),i}}class Pn extends di{constructor(e){super(e),t(this,"onBeforeUpdate",new ci),t(this,"onAfterUpdate",new ci),t(this,"onAspectUpdated",new ci),t(this,"onDisposed",new ci),t(this,"three"),t(this,"_allControls",new Map),t(this,"updateAspect",(()=>{var e;if(this.currentWorld&&this.currentWorld.renderer)if(this.three instanceof i.OrthographicCamera)this.onAspectUpdated.trigger();else if(null==(e=this.currentWorld.renderer)?void 0:e.isResizeable()){const e=this.currentWorld.renderer.getSize();this.three.aspect=e.width/e.height,this.three.updateProjectionMatrix(),this.onAspectUpdated.trigger()}})),this.three=this.setupCamera(),this.setupEvents(!0),this.onWorldChanged.add((({action:e,world:t})=>{if("added"===e){const e=this.newCameraControls();this._allControls.set(t.uuid,e)}if("removed"===e){const e=this._allControls.get(t.uuid);e&&(e.dispose(),this._allControls.delete(t.uuid))}}))}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)}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()}update(e){this.enabled&&(this.onBeforeUpdate.trigger(this),this.controls.update(e),this.onAfterUpdate.trigger(this))}setupCamera(){const e=window.innerWidth/window.innerHeight,t=new i.PerspectiveCamera(60,e,1,1e3);return t.position.set(50,50,50),t.lookAt(new i.Vector3(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!");Ln.install({THREE:Pn.getSubsetOfThree()});const{domElement:e}=this.currentWorld.renderer.three,t=new Ln(this.three,e);return t.smoothTime=.2,t.dollyToCursor=!0,t.infinityDolly=!0,t.minDistance=6,t}setupEvents(e){e?window.addEventListener("resize",this.updateAspect):window.removeEventListener("resize",this.updateAspect)}static getSubsetOfThree(){return{MOUSE:i.MOUSE,Vector2:i.Vector2,Vector3:i.Vector3,Vector4:i.Vector4,Quaternion:i.Quaternion,Matrix4:i.Matrix4,Spherical:i.Spherical,Box3:i.Box3,Sphere:i.Sphere,Raycaster:i.Raycaster,MathUtils:i.MathUtils}}}const wn=class e extends ui{constructor(i){super(i),t(this,"onAfterUpdate",new ci),t(this,"onBeforeUpdate",new ci),t(this,"onDisposed",new ci),t(this,"list",new mi),t(this,"enabled",!0),i.add(e.uuid,this)}create(){const e=new Ss(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)}};t(wn,"uuid","fdb61dc4-2ec1-4966-b83d-54ea795fad4a");let vn=wn;async function Mn(e,t,i,s,n,r,o){const a=e.fenceSync(e.SYNC_GPU_COMMANDS_COMPLETE,0);e.flush(),await function(e,t,i,s){return new Promise(((n,r)=>{!function o(){const a=e.clientWaitSync(t,i,0);a!==e.WAIT_FAILED?a!==e.TIMEOUT_EXPIRED?n():setTimeout(o,s):r()}()}))}(e,a,0,10),e.deleteSync(a),e.bindBuffer(t,i),e.getBufferSubData(t,s,n,r,o),e.bindBuffer(t,null)}async function Dn(e,t,i,s,n,r,o,a){const c=e.createBuffer();return e.bindBuffer(e.PIXEL_PACK_BUFFER,c),e.bufferData(e.PIXEL_PACK_BUFFER,a.byteLength,e.STREAM_READ),e.readPixels(t,i,s,n,r,o,0),e.bindBuffer(e.PIXEL_PACK_BUFFER,null),await Mn(e,e.PIXEL_PACK_BUFFER,c,0,a),e.deleteBuffer(c),a}class bn extends Os{constructor(){super(...arguments),t(this,"_config",{enabled:{value:!0,type:"Boolean"},width:{type:"Number",interpolable:!0,value:512,min:32,max:1024},height:{type:"Number",interpolable:!0,value:512,min:32,max:1024},autoUpdate:{value:!0,type:"Boolean"},renderDebugFrame:{value:!1,type:"Boolean"},updateInterval:{type:"Number",interpolable:!0,value:1,min:0,max:1},threshold:{type:"Number",interpolable:!0,value:100,min:1,max:512}}),t(this,"_interval",null)}get enabled(){return this._config.enabled.value}set enabled(e){this._config.enabled.value=e,this._component.enabled=e}get width(){return this._config.width.value}set width(e){this.setWidthHeight(e,this.height)}get height(){return this._config.height.value}set height(e){this.setWidthHeight(this.width,e)}get autoUpdate(){return this._config.autoUpdate.value}set autoUpdate(e){this.setAutoAndInterval(e,this.updateInterval)}get updateInterval(){return this._config.updateInterval.value}set updateInterval(e){this.setAutoAndInterval(this.autoUpdate,e)}get renderDebugFrame(){return this._config.renderDebugFrame.value}set renderDebugFrame(e){this._config.renderDebugFrame.value=e}get threshold(){return this._config.threshold.value}set threshold(e){this._config.threshold.value=e}setWidthHeight(e,t){if(e<=0||t<=0)throw new Error("The width and height of the culler renderer must be more than 0!");this._config.width.value=e,this._config.height.value=t,this.resetRenderTarget()}setAutoAndInterval(e,t){if(t<=0)throw new Error("The updateInterval of the culler renderer must be more than 0!");this._config.autoUpdate.value=e,this._config.updateInterval.value=t,this.resetInterval(e)}resetRenderTarget(){this._component.renderTarget.dispose(),this._component.renderTarget=new i.WebGLRenderTarget(this.width,this.height),this._component.bufferSize=this.width*this.height*4,this._component.buffer=new Uint8Array(this._component.bufferSize)}resetInterval(e){null!==this._interval&&window.clearInterval(this._interval),e&&(this._interval=window.setInterval((async()=>{this._component.preventUpdate||await this._component.updateVisibility()}),this.updateInterval))}}class xn{constructor(e,s){if(t(this,"onSetup",new ci),t(this,"onDisposed",new ci),t(this,"onViewUpdated",new li),t(this,"enabled",!0),t(this,"needsUpdate",!1),t(this,"components"),t(this,"renderTarget",new i.WebGLRenderTarget),t(this,"bufferSize",1),t(this,"buffer",new Uint8Array),t(this,"preventUpdate",!1),t(this,"config"),t(this,"isSetup",!1),t(this,"world"),t(this,"renderer"),t(this,"_defaultConfig",{enabled:!0,height:512,width:512,updateInterval:1e3,autoUpdate:!0,renderDebugFrame:!1,threshold:100}),t(this,"worker"),t(this,"scene",new i.Scene),t(this,"_availableColor",1),t(this,"_isWorkerBusy",!1),t(this,"updateVisibility",(async e=>{if(!this.enabled)return;if(!this.needsUpdate&&!e)return;if(this._isWorkerBusy)return;this._isWorkerBusy=!0;const t=this.world.camera.three;t.updateMatrix();const{width:i,height:s}=this.config;this.renderer.setSize(i,s),this.renderer.setRenderTarget(this.renderTarget),this.renderer.render(this.scene,t);const n=this.renderer.getContext();await Dn(n,0,0,i,s,n.RGBA,n.UNSIGNED_BYTE,this.buffer),this.renderer.setRenderTarget(null),this.config.renderDebugFrame&&this.renderer.render(this.scene,t),this.worker.postMessage({buffer:this.buffer}),this.needsUpdate=!1})),!s.renderer)throw new Error("The given world must have a renderer!");this.components=e,this.config=new bn(this,this.components,"Culler renderer"),this.world=s,this.renderer=new i.WebGLRenderer,this.renderer.clippingPlanes=s.renderer.clippingPlanes;const n=new Blob(['\n addEventListener("message", (event) => {\n const { buffer } = event.data;\n const colors = new Map();\n for (let i = 0; i < buffer.length; i += 4) {\n const r = buffer[i];\n const g = buffer[i + 1];\n const b = buffer[i + 2];\n const code = "" + r + "-" + g + "-" + b;\n if(colors.has(code)) {\n colors.set(code, colors.get(code) + 1);\n } else {\n colors.set(code, 1);\n }\n }\n postMessage({ colors });\n });\n '],{type:"application/javascript"});this.worker=new Worker(URL.createObjectURL(n)),this.setup()}dispose(){this.enabled=!1,this.config.autoUpdate=!1;this.components.get(ys).list.delete(this.config.uuid);for(const e of this.scene.children)e.removeFromParent();this.onViewUpdated.reset(),this.worker.terminate(),this.renderer.forceContextLoss(),this.renderer.dispose(),this.renderTarget.dispose(),this.buffer=null,this.onDisposed.reset()}setup(e){const t={...this._defaultConfig,...e},{width:i,height:s}=t;this.config.setWidthHeight(i,s);const{updateInterval:n,autoUpdate:r}=t;this.config.setAutoAndInterval(r,n),this.config.threshold=t.threshold,this.isSetup=!0,this.onSetup.trigger()}getAvailableColor(){let e=BigInt(this._availableColor.toString());const t=[];do{t.unshift(Number(e%256n)),e/=256n}while(e);for(;3!==t.length;)t.unshift(0);const[i,s,n]=t;return{r:i,g:s,b:n,code:`${i}-${s}-${n}`}}increaseColor(){16777216!==this._availableColor?this._availableColor++:console.warn("Color can't be increased over 256 x 256 x 256!")}decreaseColor(){1!==this._availableColor?this._availableColor--:console.warn("Color can't be decreased under 0!")}}class Un extends xn{constructor(e,s){super(e,s),t(this,"onViewUpdated",new ci),t(this,"colorMeshes",new Map),t(this,"_colorCodeMeshMap",new Map),t(this,"_meshIDColorCodeMap",new Map),t(this,"_currentVisibleMeshes",new Set),t(this,"_recentlyHiddenMeshes",new Set),t(this,"_transparentMat",new i.MeshBasicMaterial({transparent:!0,opacity:0})),t(this,"handleWorkerMessage",(async e=>{if(this.preventUpdate)return;const t=e.data.colors;this._recentlyHiddenMeshes=new Set(this._currentVisibleMeshes),this._currentVisibleMeshes.clear();for(const[e,i]of t){if(i<this.config.threshold)continue;const t=this._colorCodeMeshMap.get(e);t&&(this._currentVisibleMeshes.add(t),this._recentlyHiddenMeshes.delete(t))}this.onViewUpdated.trigger({seen:this._currentVisibleMeshes,unseen:this._recentlyHiddenMeshes}),this._isWorkerBusy=!1})),this.worker.addEventListener("message",this.handleWorkerMessage),this.onViewUpdated.add((({seen:e,unseen:t})=>{for(const t of e)t.visible=!0;for(const e of t)e.visible=!1}))}get threshold(){return this.config.threshold}set threshold(e){this.config.threshold=e}dispose(){super.dispose(),this._currentVisibleMeshes.clear(),this._recentlyHiddenMeshes.clear(),this._meshIDColorCodeMap.clear(),this._transparentMat.dispose(),this._colorCodeMeshMap.clear();const e=this.components.get(pi);for(const t in this.colorMeshes){const i=this.colorMeshes.get(t);i&&e.destroy(i,!0)}this.colorMeshes.clear()}add(e){if(!this.enabled)return;if(this.preventUpdate)return void console.log("Culler processing not finished yet.");this.preventUpdate=!0;const t=e instanceof i.InstancedMesh,{geometry:s,material:n}=e,{colorMaterial:r,code:o}=this.getAvailableMaterial();let a;if(Array.isArray(n)){let e=!0;const t=[];for(const i of n)Gi.isTransparent(i)?t.push(this._transparentMat):(e=!1,t.push(r));if(e)return r.dispose(),void(this.preventUpdate=!1);a=t}else{if(Gi.isTransparent(n))return r.dispose(),void(this.preventUpdate=!1);a=r}this._colorCodeMeshMap.set(o,e),this._meshIDColorCodeMap.set(e.uuid,o);const c=t?e.count:1,l=new i.InstancedMesh(s,a,c);t?l.instanceMatrix=e.instanceMatrix:l.setMatrixAt(0,new i.Matrix4),e.visible=!1,e.updateWorldMatrix(!0,!1),l.applyMatrix4(e.matrixWorld),l.updateMatrix(),this.scene.add(l),this.colorMeshes.set(e.uuid,l),this.increaseColor(),this.preventUpdate=!1}remove(e){if(this.preventUpdate)return void console.log("Culler processing not finished yet.");this.preventUpdate=!0;const t=this.components.get(pi);this._currentVisibleMeshes.delete(e),this._recentlyHiddenMeshes.delete(e);const i=this.colorMeshes.get(e.uuid),s=this._meshIDColorCodeMap.get(e.uuid);i&&s?(this._colorCodeMeshMap.delete(s),this._meshIDColorCodeMap.delete(e.uuid),this.colorMeshes.delete(e.uuid),i.geometry=void 0,i.material=[],t.destroy(i,!0),this._recentlyHiddenMeshes.delete(e),this._currentVisibleMeshes.delete(e),this.preventUpdate=!1):this.preventUpdate=!1}updateInstanced(e){for(const t of e){const e=this.colorMeshes.get(t.uuid);e&&(e.count=t.count)}}getAvailableMaterial(){const{r:e,g:t,b:s,code:n}=this.getAvailableColor(),r=i.ColorManagement.enabled;i.ColorManagement.enabled=!1;const o=new i.Color(`rgb(${e}, ${t}, ${s})`);if(!this.world.renderer)throw new Error("Renderer not found in the world!");const a=this.world.renderer.clippingPlanes,c=new i.MeshBasicMaterial({color:o,clippingPlanes:a,side:i.DoubleSide});return i.ColorManagement.enabled=r,{colorMaterial:c,code:n}}}const Bn=class e extends ui{constructor(i){super(i),t(this,"onDisposed",new ci),t(this,"_enabled",!0),t(this,"list",new Map),i.add(e.uuid,this)}get enabled(){return this._enabled}set enabled(e){this._enabled=e;for(const[t,i]of this.list)i.enabled=e}create(e){if(this.list.has(e.uuid))return this.list.get(e.uuid);const t=new Un(this.components,e);return this.list.set(e.uuid,t),t}delete(e){const t=this.list.get(e.uuid);t&&t.dispose(),this.list.delete(e.uuid)}dispose(){this.enabled=!1,this.onDisposed.trigger(e.uuid),this.onDisposed.reset();for(const[e,t]of this.list)t.dispose();this.list.clear()}updateInstanced(e){for(const[,t]of this.list)t.updateInstanced(e)}};t(Bn,"uuid","69f2a50d-c266-44fc-b1bd-fa4d34be89e6");let Vn=Bn;class Yn{constructor(e,s){if(t(this,"onDisposed",new ci),t(this,"onDistanceComputed",new ci),t(this,"excludedObjects",new Set),t(this,"enabled",!0),t(this,"renderDebugFrame",!1),t(this,"components"),t(this,"scene",new i.Scene),t(this,"camera",new i.OrthographicCamera(-1,1,1,-1,0,1)),t(this,"depthMaterial"),t(this,"world"),t(this,"renderer"),t(this,"worker"),t(this,"_width",512),t(this,"_height",512),t(this,"_postQuad"),t(this,"tempRT"),t(this,"resultRT"),t(this,"bufferSize"),t(this,"_buffer"),t(this,"_isWorkerBusy",!1),t(this,"compute",(async()=>{if(!this.enabled||this.world.isDisposing)return;if(this._isWorkerBusy)return;this._isWorkerBusy=!0,this.world.camera.three.updateMatrix(),this.renderer.setSize(this._width,this._height),this.renderer.setRenderTarget(this.tempRT);const e="visibilityBeforeDistanceCheck";for(const t of this.excludedObjects)t.userData[e]=t.visible,t.visible=!1;this.renderer.render(this.world.scene.three,this.world.camera.three);for(const t of this.excludedObjects)void 0!==t.userData[e]&&(t.visible=t.userData[e]);this.depthMaterial.uniforms.tDiffuse.value=this.tempRT.texture,this.depthMaterial.uniforms.tDepth.value=this.tempRT.depthTexture,this.renderer.setRenderTarget(this.resultRT),this.renderer.render(this.scene,this.camera);const t=this.renderer.getContext();try{await Dn(t,0,0,this._width,this._height,t.RGBA,t.UNSIGNED_BYTE,this._buffer)}catch(e){return this.renderer.setRenderTarget(null),void(this._isWorkerBusy=!1)}this.renderer.setRenderTarget(null),this.renderDebugFrame&&this.renderer.render(this.scene,this.camera),this.worker.postMessage({buffer:this._buffer})})),t(this,"handleWorkerMessage",(e=>{if(!this.enabled||this.world.isDisposing)return;const t=e.data.colors;let s=Number.MAX_VALUE;for(const e of t)0!==e&&e<s&&(s=e);const n=this.world.camera.three||i.OrthographicCamera,r=-1*(s/255-1)*(n.far-n.near),o=Math.min(r,n.far);this.onDistanceComputed.trigger(o),this._isWorkerBusy=!1})),!s.renderer)throw new Error("The given world must have a renderer!");this.components=e,this.world=s;const n=s.camera.three;this.renderer=new i.WebGLRenderer,this.tempRT=new i.WebGLRenderTarget(this._width,this._height),this.bufferSize=this._width*this._height*4,this._buffer=new Uint8Array(this.bufferSize),this.tempRT.texture.minFilter=i.NearestFilter,this.tempRT.texture.magFilter=i.NearestFilter,this.tempRT.stencilBuffer=!1,this.tempRT.samples=0,this.tempRT.depthTexture=new i.DepthTexture(this._width,this._height),this.tempRT.depthTexture.format=i.DepthFormat,this.tempRT.depthTexture.type=i.UnsignedShortType,this.resultRT=new i.WebGLRenderTarget(this._width,this._height),this.depthMaterial=new i.ShaderMaterial({vertexShader:"\nvarying vec2 vUv;\n\nvoid main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}\n ",fragmentShader:"\n#include <packing>\n\nvarying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform sampler2D tDepth;\nuniform float cameraNear;\nuniform float cameraFar;\n\n\nfloat readDepth( sampler2D depthSampler, vec2 coord ) {\n float fragCoordZ = texture2D( depthSampler, coord ).x;\n float viewZ = perspectiveDepthToViewZ( fragCoordZ, cameraNear, cameraFar );\n return viewZToOrthographicDepth( viewZ, cameraNear, cameraFar );\n}\n\nvoid main() {\n //vec3 diffuse = texture2D( tDiffuse, vUv ).rgb;\n float depth = readDepth( tDepth, vUv );\n\n gl_FragColor.rgb = 1.0 - vec3( depth );\n gl_FragColor.a = 1.0;\n}\n ",uniforms:{cameraNear:{value:n.near},cameraFar:{value:n.far},tDiffuse:{value:null},tDepth:{value:null}}});const r=new i.PlaneGeometry(2,2);this._postQuad=new i.Mesh(r,this.depthMaterial),this.scene.add(this._postQuad),this.renderer.clippingPlanes=s.renderer.clippingPlanes;const o=new Blob(['\n addEventListener("message", (event) => {\n const { buffer } = event.data;\n const colors = new Set();\n for (let i = 0; i < buffer.length; i += 4) {\n const r = buffer[i];\n colors.add(r);\n }\n postMessage({ colors });\n });\n '],{type:"application/javascript"});this.worker=new Worker(URL.createObjectURL(o)),this.worker.addEventListener("message",this.handleWorkerMessage)}dispose(){this.enabled=!1,this.onDistanceComputed.reset(),this.worker.terminate(),this.renderer.forceContextLoss(),this.renderer.dispose(),this.tempRT.dispose(),this.resultRT.dispose();const e=[...this.scene.children];this.excludedObjects.clear();for(const t of e)t.removeFromParent();this._postQuad.geometry.dispose(),this._postQuad.removeFromParent(),this._buffer=null,this.onDisposed.reset()}}class Gn extends ws{constructor(){super(...arguments),t(this,"_distanceRenderer"),t(this,"autoBias",!0),t(this,"_defaultShadowConfig",{cascade:1,resolution:512}),t(this,"_lightsWithShadow",new Map),t(this,"_isComputingShadows",!1),t(this,"_shadowsEnabled",!0),t(this,"_bias",0),t(this,"recomputeShadows",(e=>{if(!this._shadowsEnabled)return;this.autoBias&&(this.bias=e/-1e5);if(e*=1.5,!this.currentWorld)throw new Error("A world needs to be assigned to the scene before computing shadows!");if(!this._lightsWithShadow.size)throw new Error("No shadows found!");const t=this.currentWorld.camera.three;if(!(t instanceof i.PerspectiveCamera||t instanceof i.OrthographicCamera))throw new Error("Invalid camera type!");const s=new i.Vector3;t.getWorldDirection(s);let n=e;const r=new i.Vector3;r.copy(this.config.directionalLight.position),r.normalize();for(const[e,o]of this._lightsWithShadow){const a=this.directionalLights.get(o);if(!a)throw new Error("Light not found.");const c=new i.Vector3;c.copy(s);const l=e===this._lightsWithShadow.size-1,h=l?n/2:2*n/3;c.multiplyScalar(h),c.add(t.position);const u=n-h,I=new i.Vector3;I.copy(r),I.multiplyScalar(u),a.target.position.copy(c),a.position.copy(c),a.position.add(I),a.shadow.camera.right=u,a.shadow.camera.left=-u,a.shadow.camera.top=u,a.shadow.camera.bottom=-u,a.shadow.camera.far=2*u,a.shadow.camera.updateProjectionMatrix(),a.shadow.camera.updateMatrix(),l||(n/=3)}this._isComputingShadows=!1}))}get bias(){return this._bias}set bias(e){this._bias=e;for(const[,t]of this._lightsWithShadow){const i=this.directionalLights.get(t);i&&(i.shadow.bias=e)}}get shadowsEnabled(){return this._shadowsEnabled}set shadowsEnabled(e){this._shadowsEnabled=e;for(const[,t]of this.directionalLights)t.castShadow=e}get distanceRenderer(){if(!this._distanceRenderer)throw new Error("You must set up this component before accessing the distance renderer!");return this._distanceRenderer}setup(e){super.setup(e);const t={...this._defaultConfig,...this._defaultShadowConfig,...e};if(t.cascade<=0)throw new Error("Config.shadows.cascade must be a natural number greater than 0!");if(t.cascade>1)throw new Error("Multiple shadows not supported yet!");if(!this.currentWorld)throw new Error("A world needs to be assigned to the scene before setting it up!");for(const[,e]of this.directionalLights)e.target.removeFromParent(),e.removeFromParent(),e.dispose();this.directionalLights.clear(),this._distanceRenderer||(this._distanceRenderer=new Yn(this.components,this.currentWorld),this._distanceRenderer.onDistanceComputed.add(this.recomputeShadows)),this._lightsWithShadow.clear();for(let e=0;e<t.cascade;e++){const s=new i.DirectionalLight;s.intensity=this.config.directionalLight.intensity,s.color=this.config.directionalLight.color,s.position.copy(this.config.directionalLight.position),s.shadow.mapSize.width=t.resolution,s.shadow.mapSize.height=t.resolution,this.three.add(s,s.target),this.directionalLights.set(s.uuid,s),this._lightsWithShadow.set(e,s.uuid),s.castShadow=!0,s.shadow.bias=this._bias}}dispose(){super.dispose(),this._distanceRenderer&&this._distanceRenderer.dispose(),this._lightsWithShadow.clear()}async updateShadows(){!this._isComputingShadows&&this._shadowsEnabled&&(this._isComputingShadows=!0,await this.distanceRenderer.compute())}}class zn{constructor(e){t(this,"_event"),t(this,"_position",new i.Vector2),t(this,"onDisposed",new ci),t(this,"updateMouseInfo",(e=>{this._event=e})),this.dom=e,this.setupEvents(!0)}get position(){if(this._event){const e=this.dom.getBoundingClientRect();this._position.x=this.getPositionX(e,this._event),this._position.y=this.getPositionY(e,this._event)}return this._position}dispose(){this.setupEvents(!1),this.onDisposed.trigger(),this.onDisposed.reset()}getPositionY(e,t){return-(this.getDataObject(t).clientY-e.top)/(e.bottom-e.top)*2+1}getPositionX(e,t){return(this.getDataObject(t).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))}}class kn{constructor(e,s){t(this,"enabled",!0),t(this,"components"),t(this,"onDisposed",new ci),t(this,"mouse"),t(this,"three",new i.Raycaster),t(this,"world");const n=s.renderer;if(!n)throw new Error("A renderer is needed for the raycaster to work!");this.world=s,this.mouse=new zn(n.three.domElement),this.components=e}dispose(){this.mouse.dispose(),this.onDisposed.trigger(),this.onDisposed.reset()}castRay(e=Array.from(this.world.meshes),t=this.mouse.position){if(!this.world)throw new Error("A world is needed to cast rays!");const i=this.world.camera.three;return this.three.setFromCamera(t,i),this.intersect(e)}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||(null==i?void 0:i.length)<=0?e:e.filter((e=>i.every((t=>t.distanceToPoint(e.point)>0))))}}const Hn=class e extends ui{constructor(i){super(i),t(this,"enabled",!0),t(this,"list",new Map),t(this,"onDisposed",new ci),i.add(e.uuid,this)}get(e){if(this.list.has(e.uuid))return this.list.get(e.uuid);const t=new kn(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()}};t(Hn,"uuid","d5d8bdf0-db25-4952-b951-b643af207ace");let Wn=Hn;class Xn extends Os{constructor(){super(...arguments),t(this,"_config",{visible:{value:!0,type:"Boolean"},color:{value:new i.Color,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 Zn{constructor(e,s){t(this,"onDisposed",new ci),t(this,"onSetup",new ci),t(this,"isSetup",!1),t(this,"world"),t(this,"components"),t(this,"config"),t(this,"_defaultConfig",{visible:!0,color:new i.Color(12303291),primarySize:1,secondarySize:10,distance:500}),t(this,"three"),t(this,"_fade",3),t(this,"updateZoom",(()=>{this.world.camera instanceof Pn&&(this.material.uniforms.uZoom.value=this.world.camera.three.zoom)})),this.world=s;const{color:n,primarySize:r,secondarySize:o,distance:a}=this._defaultConfig;this.components=e,this.config=new Xn(this,this.components,"Grid");const c=new i.PlaneGeometry(2,2,1,1),l=new i.ShaderMaterial({side:i.DoubleSide,uniforms:{uSize1:{value:r},uSize2:{value:o},uColor:{value:n},uDistance:{value:a},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:{}});this.three=new i.Mesh(c,l),this.three.frustumCulled=!1,s.scene.three.add(this.three),this.setupEvents(!0)}get visible(){return this.three.visible}set visible(e){if(e){this.world.scene.three.add(this.three)}else 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(ys).list.delete(this.config.uuid);this.components.get(pi).destroy(this.three),this.onDisposed.trigger(),this.onDisposed.reset(),this.world=null,this.components=null}setupEvents(e){if(this.world.isDisposing)return;if(!(this.world.camera instanceof Pn))return;const t=this.world.camera.controls;e?t.addEventListener("update",this.updateZoom):t.removeEventListener("update",this.updateZoom)}}const $n=class e extends ui{constructor(i){super(i),t(this,"list",new Map),t(this,"onDisposed",new ci),t(this,"enabled",!0),i.add(e.uuid,this)}create(e){if(this.list.has(e.uuid))throw new Error("This world already has a grid!");const t=new Zn(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()}};t($n,"uuid","d1e814d5-b81c-4452-87a2-f039375e0489");let jn=$n;const qn=new C,Qn=new n,Kn=new n,Jn=new T,er={X:new n(1,0,0),Y:new n(0,1,0),Z:new n(0,0,1)},tr={type:"change"},ir={type:"mouseDown",mode:null},sr={type:"mouseUp",mode:null},nr={type:"objectChange"};class rr extends m{constructor(e,t=null){super(void 0,t);const i=new Nr(this);this._root=i;const s=new yr;this._gizmo=s,i.add(s);const r=new _r;this._plane=r,i.add(r);const o=this;function a(e,t){let i=t;Object.defineProperty(o,e,{get:function(){return void 0!==i?i:t},set:function(t){i!==t&&(i=t,r[e]=t,s[e]=t,o.dispatchEvent({type:e+"-changed",value:t}),o.dispatchEvent(tr))}}),o[e]=t,r[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 c=new n,l=new n,h=new T,u=new T,I=new n,d=new T,E=new n,f=new n,p=new n,C=new n;a("worldPosition",c),a("worldPositionStart",l),a("worldQuaternion",h),a("worldQuaternionStart",u),a("cameraPosition",I),a("cameraQuaternion",d),a("pointStart",E),a("pointEnd",f),a("rotationAxis",p),a("rotationAngle",0),a("eye",C),this._offset=new n,this._startNorm=new n,this._endNorm=new n,this._cameraScale=new n,this._parentPosition=new n,this._parentQuaternion=new T,this._parentQuaternionInv=new T,this._parentScale=new n,this._worldScaleStart=new n,this._worldQuaternionInv=new T,this._worldScale=new n,this._positionStart=new n,this._quaternionStart=new T,this._scaleStart=new n,this._getPointer=or.bind(this),this._onPointerDown=cr.bind(this),this._onPointerHover=ar.bind(this),this._onPointerMove=lr.bind(this),this._onPointerUp=hr.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&&qn.setFromCamera(e,this.camera);const t=ur(this._gizmo.picker[this.mode],qn);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&&qn.setFromCamera(e,this.camera);const t=ur(this._plane,qn,!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,ir.mode=this.mode,this.dispatchEvent(ir)}}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&&qn.setFromCamera(e,this.camera);const r=ur(this._plane,qn,!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(Jn.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(Qn.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(Qn.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 e=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(e*=-1),Kn.set(e,e,e)}else Qn.copy(this.pointStart),Kn.copy(this.pointEnd),Qn.applyQuaternion(this._worldQuaternionInv),Kn.applyQuaternion(this._worldQuaternionInv),Kn.divide(Qn),-1===t.search("X")&&(Kn.x=1),-1===t.search("Y")&&(Kn.y=1),-1===t.search("Z")&&(Kn.z=1);s.scale.copy(this._scaleStart).multiply(Kn),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 e=20/this.worldPosition.distanceTo(Qn.setFromMatrixPosition(this.camera.matrixWorld));let i=!1;"XYZE"===t?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(Qn.copy(this.rotationAxis).cross(this.eye))*e):"X"!==t&&"Y"!==t&&"Z"!==t||(this.rotationAxis.copy(er[t]),Qn.copy(er[t]),"local"===n&&Qn.applyQuaternion(this.worldQuaternion),Qn.cross(this.eye),0===Qn.length()?i=!0:this.rotationAngle=this._offset.dot(Qn.normalize())*e),("E"===t||i)&&(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(Jn.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),s.quaternion.copy(Jn.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),s.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(tr),this.dispatchEvent(nr)}}pointerUp(e){null!==e&&0!==e.button||(this.dragging&&null!==this.axis&&(sr.mode=this.mode,this.dispatchEvent(sr)),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(tr),this.dispatchEvent(nr),this.pointStart.copy(this.pointEnd))}getRaycaster(){return qn}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 or(e){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:e.button};{const t=this.domElement.getBoundingClientRect();return{x:(e.clientX-t.left)/t.width*2-1,y:-(e.clientY-t.top)/t.height*2+1,button:e.button}}}function ar(e){if(this.enabled)switch(e.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(e))}}function cr(e){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(e.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(e)),this.pointerDown(this._getPointer(e)))}function lr(e){this.enabled&&this.pointerMove(this._getPointer(e))}function hr(e){this.enabled&&(this.domElement.releasePointerCapture(e.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(e)))}function ur(e,t,i){const s=t.intersectObject(e,!0);for(let e=0;e<s.length;e++)if(s[e].object.visible||i)return s[e];return!1}const Ir=new R,dr=new n(0,1,0),Er=new n(0,0,0),fr=new h,pr=new T,Cr=new T,Tr=new n,mr=new h,Rr=new n(1,0,0),gr=new n(0,1,0),Ar=new n(0,0,1),Fr=new n,Sr=new n,Or=new n;class Nr extends g{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 yr extends g{constructor(){super(),this.isTransformControlsGizmo=!0,this.type="TransformControlsGizmo";const e=new A({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),t=new F({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 o=e.clone();o.color.setHex(255);const a=e.clone();a.color.setHex(16711680),a.opacity=.5;const c=e.clone();c.color.setHex(65280),c.opacity=.5;const l=e.clone();l.color.setHex(255),l.opacity=.5;const h=e.clone();h.opacity=.25;const u=e.clone();u.color.setHex(16776960),u.opacity=.25;e.clone().color.setHex(16776960);const I=e.clone();I.color.setHex(7895160);const d=new S(0,.04,.1,12);d.translate(0,.05,0);const E=new O(.08,.08,.08);E.translate(0,.04,0);const p=new N;p.setAttribute("position",new y([0,0,0,1,0,0],3));const C=new S(.0075,.0075,.5,3);function T(e,t){const i=new w(e,.0075,3,64,t*Math.PI*2);return i.rotateY(Math.PI/2),i.rotateX(Math.PI/2),i}C.translate(0,.25,0);const m={X:[[new f(d,n),[.5,0,0],[0,0,-Math.PI/2]],[new f(d,n),[-.5,0,0],[0,0,Math.PI/2]],[new f(C,n),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new f(d,r),[0,.5,0]],[new f(d,r),[0,-.5,0],[Math.PI,0,0]],[new f(C,r)]],Z:[[new f(d,o),[0,0,.5],[Math.PI/2,0,0]],[new f(d,o),[0,0,-.5],[-Math.PI/2,0,0]],[new f(C,o),null,[Math.PI/2,0,0]]],XYZ:[[new f(new _(.1,0),h.clone()),[0,0,0]]],XY:[[new f(new O(.15,.15,.01),l.clone()),[.15,.15,0]]],YZ:[[new f(new O(.15,.15,.01),a.clone()),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new f(new O(.15,.15,.01),c.clone()),[.15,0,.15],[-Math.PI/2,0,0]]]},R={X:[[new f(new S(.2,0,.6,4),i),[.3,0,0],[0,0,-Math.PI/2]],[new f(new S(.2,0,.6,4),i),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new f(new S(.2,0,.6,4),i),[0,.3,0]],[new f(new S(.2,0,.6,4),i),[0,-.3,0],[0,0,Math.PI]]],Z:[[new f(new S(.2,0,.6,4),i),[0,0,.3],[Math.PI/2,0,0]],[new f(new S(.2,0,.6,4),i),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new f(new _(.2,0),i)]],XY:[[new f(new O(.2,.2,.01),i),[.15,.15,0]]],YZ:[[new f(new O(.2,.2,.01),i),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new f(new O(.2,.2,.01),i),[.15,0,.15],[-Math.PI/2,0,0]]]},v={START:[[new f(new _(.01,2),s),null,null,null,"helper"]],END:[[new f(new _(.01,2),s),null,null,null,"helper"]],DELTA:[[new L(function(){const e=new N;return e.setAttribute("position",new y([0,0,0,1,1,1],3)),e}(),s),null,null,null,"helper"]],X:[[new L(p,s.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new L(p,s.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new L(p,s.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},M={XYZE:[[new f(T(.5,1),I),null,[0,Math.PI/2,0]]],X:[[new f(T(.5,.5),n)]],Y:[[new f(T(.5,.5),r),null,[0,0,-Math.PI/2]]],Z:[[new f(T(.5,.5),o),null,[0,Math.PI/2,0]]],E:[[new f(T(.75,1),u),null,[0,Math.PI/2,0]]]},D={AXIS:[[new L(p,s.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},b={XYZE:[[new f(new P(.25,10,8),i)]],X:[[new f(new w(.5,.1,4,24),i),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new f(new w(.5,.1,4,24),i),[0,0,0],[Math.PI/2,0,0]]],Z:[[new f(new w(.5,.1,4,24),i),[0,0,0],[0,0,-Math.PI/2]]],E:[[new f(new w(.75,.1,2,24),i)]]},x={X:[[new f(E,n),[.5,0,0],[0,0,-Math.PI/2]],[new f(C,n),[0,0,0],[0,0,-Math.PI/2]],[new f(E,n),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new f(E,r),[0,.5,0]],[new f(C,r)],[new f(E,r),[0,-.5,0],[0,0,Math.PI]]],Z:[[new f(E,o),[0,0,.5],[Math.PI/2,0,0]],[new f(C,o),[0,0,0],[Math.PI/2,0,0]],[new f(E,o),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new f(new O(.15,.15,.01),l),[.15,.15,0]]],YZ:[[new f(new O(.15,.15,.01),a),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new f(new O(.15,.15,.01),c),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new f(new O(.1,.1,.1),h.clone())]]},U={X:[[new f(new S(.2,0,.6,4),i),[.3,0,0],[0,0,-Math.PI/2]],[new f(new S(.2,0,.6,4),i),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new f(new S(.2,0,.6,4),i),[0,.3,0]],[new f(new S(.2,0,.6,4),i),[0,-.3,0],[0,0,Math.PI]]],Z:[[new f(new S(.2,0,.6,4),i),[0,0,.3],[Math.PI/2,0,0]],[new f(new S(.2,0,.6,4),i),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new f(new O(.2,.2,.01),i),[.15,.15,0]]],YZ:[[new f(new O(.2,.2,.01),i),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new f(new O(.2,.2,.01),i),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new f(new O(.2,.2,.2),i),[0,0,0]]]},B={X:[[new L(p,s.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new L(p,s.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new L(p,s.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function V(e){const t=new g;for(const i in e)for(let s=e[i].length;s--;){const n=e[i][s][0].clone(),r=e[i][s][1],o=e[i][s][2],a=e[i][s][3],c=e[i][s][4];n.name=i,n.tag=c,r&&n.position.set(r[0],r[1],r[2]),o&&n.rotation.set(o[0],o[1],o[2]),a&&n.scale.set(a[0],a[1],a[2]),n.updateMatrix();const l=n.geometry.clone();l.applyMatrix4(n.matrix),n.geometry=l,n.renderOrder=1/0,n.position.set(0,0,0),n.rotation.set(0,0,0),n.scale.set(1,1,1),t.add(n)}return t}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=V(m)),this.add(this.gizmo.rotate=V(M)),this.add(this.gizmo.scale=V(x)),this.add(this.picker.translate=V(R)),this.add(this.picker.rotate=V(b)),this.add(this.picker.scale=V(U)),this.add(this.helper.translate=V(v)),this.add(this.helper.rotate=V(D)),this.add(this.helper.scale=V(B)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(e){const t="local"===("scale"===this.mode?"local":this.space)?this.worldQuaternion:Cr;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 i=[];i=i.concat(this.picker[this.mode].children),i=i.concat(this.gizmo[this.mode].children),i=i.concat(this.helper[this.mode].children);for(let e=0;e<i.length;e++){const s=i[e];let n;if(s.visible=!0,s.rotation.set(0,0,0),s.position.copy(this.worldPosition),n=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),s.scale.set(1,1,1).multiplyScalar(n*this.size/4),"helper"!==s.tag){if(s.quaternion.copy(t),"translate"===this.mode||"scale"===this.mode){const e=.99,i=.2;"X"===s.name&&Math.abs(dr.copy(Rr).applyQuaternion(t).dot(this.eye))>e&&(s.scale.set(1e-10,1e-10,1e-10),s.visible=!1),"Y"===s.name&&Math.abs(dr.copy(gr).applyQuaternion(t).dot(this.eye))>e&&(s.scale.set(1e-10,1e-10,1e-10),s.visible=!1),"Z"===s.name&&Math.abs(dr.copy(Ar).applyQuaternion(t).dot(this.eye))>e&&(s.scale.set(1e-10,1e-10,1e-10),s.visible=!1),"XY"===s.name&&Math.abs(dr.copy(Ar).applyQuaternion(t).dot(this.eye))<i&&(s.scale.set(1e-10,1e-10,1e-10),s.visible=!1),"YZ"===s.name&&Math.abs(dr.copy(Rr).applyQuaternion(t).dot(this.eye))<i&&(s.scale.set(1e-10,1e-10,1e-10),s.visible=!1),"XZ"===s.name&&Math.abs(dr.copy(gr).applyQuaternion(t).dot(this.eye))<i&&(s.scale.set(1e-10,1e-10,1e-10),s.visible=!1)}else"rotate"===this.mode&&(pr.copy(t),dr.copy(this.eye).applyQuaternion(Jn.copy(t).invert()),-1!==s.name.search("E")&&s.quaternion.setFromRotationMatrix(fr.lookAt(this.eye,Er,gr)),"X"===s.name&&(Jn.setFromAxisAngle(Rr,Math.atan2(-dr.y,dr.z)),Jn.multiplyQuaternions(pr,Jn),s.quaternion.copy(Jn)),"Y"===s.name&&(Jn.setFromAxisAngle(gr,Math.atan2(dr.x,dr.z)),Jn.multiplyQuaternions(pr,Jn),s.quaternion.copy(Jn)),"Z"===s.name&&(Jn.setFromAxisAngle(Ar,Math.atan2(dr.y,dr.x)),Jn.multiplyQuaternions(pr,Jn),s.quaternion.copy(Jn)));s.visible=s.visible&&(-1===s.name.indexOf("X")||this.showX),s.visible=s.visible&&(-1===s.name.indexOf("Y")||this.showY),s.visible=s.visible&&(-1===s.name.indexOf("Z")||this.showZ),s.visible=s.visible&&(-1===s.name.indexOf("E")||this.showX&&this.showY&&this.showZ),s.material._color=s.material._color||s.material.color.clone(),s.material._opacity=s.material._opacity||s.material.opacity,s.material.color.copy(s.material._color),s.material.opacity=s.material._opacity,this.enabled&&this.axis&&(s.name===this.axis||this.axis.split("").some((function(e){return s.name===e})))&&(s.material.color.setHex(16776960),s.material.opacity=1)}else s.visible=!1,"AXIS"===s.name?(s.visible=!!this.axis,"X"===this.axis&&(Jn.setFromEuler(Ir.set(0,0,0)),s.quaternion.copy(t).multiply(Jn),Math.abs(dr.copy(Rr).applyQuaternion(t).dot(this.eye))>.9&&(s.visible=!1)),"Y"===this.axis&&(Jn.setFromEuler(Ir.set(0,0,Math.PI/2)),s.quaternion.copy(t).multiply(Jn),Math.abs(dr.copy(gr).applyQuaternion(t).dot(this.eye))>.9&&(s.visible=!1)),"Z"===this.axis&&(Jn.setFromEuler(Ir.set(0,Math.PI/2,0)),s.quaternion.copy(t).multiply(Jn),Math.abs(dr.copy(Ar).applyQuaternion(t).dot(this.eye))>.9&&(s.visible=!1)),"XYZE"===this.axis&&(Jn.setFromEuler(Ir.set(0,Math.PI/2,0)),dr.copy(this.rotationAxis),s.quaternion.setFromRotationMatrix(fr.lookAt(Er,dr,gr)),s.quaternion.multiply(Jn),s.visible=this.dragging),"E"===this.axis&&(s.visible=!1)):"START"===s.name?(s.position.copy(this.worldPositionStart),s.visible=this.dragging):"END"===s.name?(s.position.copy(this.worldPosition),s.visible=this.dragging):"DELTA"===s.name?(s.position.copy(this.worldPositionStart),s.quaternion.copy(this.worldQuaternionStart),Qn.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),Qn.applyQuaternion(this.worldQuaternionStart.clone().invert()),s.scale.copy(Qn),s.visible=this.dragging):(s.quaternion.copy(t),this.dragging?s.position.copy(this.worldPositionStart):s.position.copy(this.worldPosition),this.axis&&(s.visible=-1!==this.axis.search(s.name)))}super.updateMatrixWorld(e)}}class _r extends f{constructor(){super(new v(1e5,1e5,2,2),new A({visible:!1,wireframe:!0,side:d,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"),Fr.copy(Rr).applyQuaternion("local"===t?this.worldQuaternion:Cr),Sr.copy(gr).applyQuaternion("local"===t?this.worldQuaternion:Cr),Or.copy(Ar).applyQuaternion("local"===t?this.worldQuaternion:Cr),dr.copy(Sr),this.mode){case"translate":case"scale":switch(this.axis){case"X":dr.copy(this.eye).cross(Fr),Tr.copy(Fr).cross(dr);break;case"Y":dr.copy(this.eye).cross(Sr),Tr.copy(Sr).cross(dr);break;case"Z":dr.copy(this.eye).cross(Or),Tr.copy(Or).cross(dr);break;case"XY":Tr.copy(Or);break;case"YZ":Tr.copy(Fr);break;case"XZ":dr.copy(Or),Tr.copy(Sr);break;case"XYZ":case"E":Tr.set(0,0,0)}break;default:Tr.set(0,0,0)}0===Tr.length()?this.quaternion.copy(this.cameraQuaternion):(mr.lookAt(Qn.set(0,0,0),Tr,dr),this.quaternion.setFromRotationMatrix(mr)),super.updateMatrixWorld(e)}}class Lr{constructor(e,s,n,r,o,a=5,c=!0){if(t(this,"onDraggingStarted",new ci),t(this,"onDraggingEnded",new ci),t(this,"onDisposed",new ci),t(this,"normal"),t(this,"origin"),t(this,"three",new i.Plane),t(this,"components"),t(this,"world"),t(this,"type","default"),t(this,"_helper"),t(this,"_visible",!0),t(this,"_enabled",!0),t(this,"_controlsActive",!1),t(this,"_arrowBoundBox",new i.Mesh),t(this,"_planeMesh"),t(this,"_controls"),t(this,"_hiddenMaterial",new i.MeshBasicMaterial({visible:!1})),t(this,"update",(()=>{this._enabled&&this.three.setFromNormalAndCoplanarPoint(this.normal,this._helper.position)})),t(this,"changeDrag",(e=>{this._visible=!e.value,this.preventCameraMovement(),this.notifyDraggingChanged(e)})),this.components=e,this.world=s,!s.renderer)throw new Error("The given world must have a renderer!");this.normal=r,this.origin=n,s.renderer.setPlane(!0,this.three),this._planeMesh=Lr.newPlaneMesh(a,o),this._helper=this.newHelper(),this._controls=this.newTransformControls(),this.three.setFromNormalAndCoplanarPoint(r,n),c&&this.toggleControls(!0)}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,this.world.renderer.setPlane(e,this.three)}}get visible(){return this._visible}set visible(e){this._visible=e,this._controls.object.visible=e,this._helper.visible=e,this.toggleControls(e)}get meshes(){return[this._planeMesh,this._arrowBoundBox]}get planeMaterial(){return this._planeMesh.material}set planeMaterial(e){this._planeMesh.material=e}get size(){return this._planeMesh.scale.x}set size(e){this._planeMesh.scale.set(e,e,e)}get helper(){return this._helper}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(){this._enabled=!1,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.object.removeFromParent(),this._controls.dispose(),this.onDisposed.trigger(),this.onDisposed.reset()}reset(){const e=new i.Vector3(1,0,0),t=new i.Vector3;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 e=this.world.camera.three,t=this.world.renderer.three.domElement,i=new rr(e,t);return this.initializeControls(i),this.world.scene.three.add(i.object),i}initializeControls(e){e.attach(this._helper),e.showX=!1,e.showY=!1,e.setSpace("local"),this.createArrowBoundingBox(),e.object.children[0].children[0].add(this._arrowBoundBox)}createArrowBoundingBox(){this._arrowBoundBox.geometry=new i.CylinderGeometry(.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 i.Object3D;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 s=new i.PlaneGeometry(1),n=new i.Mesh(s,t);return n.scale.set(e,e,e),n}}class Pr extends Os{constructor(){super(...arguments),t(this,"_config",{enabled:{value:!0,type:"Boolean"},visible:{value:!0,type:"Boolean"},color:{value:new i.Color,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 wr=class e extends ui{constructor(s){super(s),t(this,"onSetup",new ci),t(this,"onBeforeDrag",new ci),t(this,"onAfterDrag",new ci),t(this,"onBeforeCreate",new ci),t(this,"onBeforeCancel",new ci),t(this,"onAfterCancel",new ci),t(this,"onBeforeDelete",new ci),t(this,"onAfterCreate",new ci),t(this,"onAfterDelete",new ci),t(this,"onDisposed",new ci),t(this,"isSetup",!1),t(this,"orthogonalY",!1),t(this,"toleranceOrthogonalY",.7),t(this,"Type",Lr),t(this,"list",[]),t(this,"config",new Pr(this,this.components,"Clipper",e.uuid)),t(this,"_defaultConfig",{color:new i.Color(12255487),opacity:.2,size:2}),t(this,"_material",new i.MeshBasicMaterial({color:12255487,side:i.DoubleSide,transparent:!0,opacity:.2})),t(this,"_size",5),t(this,"_enabled",!1),t(this,"_visible",!0),t(this,"_onStartDragging",(()=>{this.onBeforeDrag.trigger()})),t(this,"_onEndDragging",(()=>{this.onAfterDrag.trigger()})),this.components.add(e.uuid,this)}get enabled(){return this._enabled}set enabled(e){this._enabled=e;for(const t of this.list)t.enabled=e;this.updateMaterialsAndPlanes()}get visible(){return this._visible}set visible(e){this._visible=e;for(const t of this.list)t.visible=e}get material(){return this._material}set material(e){this._material=e;for(const t of this.list)t.planeMaterial=e}get size(){return this._size}set size(e){this._size=e;for(const t of this.list)t.size=e}dispose(){this._enabled=!1;this.components.get(ys).list.delete(this.config.uuid);for(const e of this.list)e.dispose();this.list.length=0,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(e.uuid),this.onDisposed.reset()}create(e){const t=this.components.get(Wn).get(e).castRay();return t?this.createPlaneFromIntersection(e,t):null}createFromNormalAndCoplanarPoint(e,t,i){const s=this.newPlane(e,i,t);return this.updateMaterialsAndPlanes(),s}delete(e,t){t||(t=this.pickPlane(e)),t&&this.deletePlane(t)}deleteAll(e){const t=[...this.list];for(const i of t)if(!e||e.has(i.type)){this.delete(i.world,i);const e=this.list.indexOf(i);-1!==e&&this.list.splice(e,1)}}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()}deletePlane(e){const t=this.list.indexOf(e);if(-1!==t){if(this.list.splice(t,1),!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)}}pickPlane(e){const t=this.components.get(Wn).get(e),i=this.getAllPlaneMeshes(),s=t.castRay(i);if(s){const e=s.object;return this.list.find((t=>t.meshes.includes(e)))}}getAllPlaneMeshes(){const e=[];for(const t of this.list)e.push(...t.meshes);return e}createPlaneFromIntersection(e,t){var s;if(!e.renderer)throw new Error("The given world must have a renderer!");const n=t.point.distanceTo(new i.Vector3(0,0,0)),r=null==(s=t.face)?void 0:s.normal;if(!n||!r)return null;const o=this.getWorldNormal(t,r),a=this.newPlane(e,t.point,o.negate());return a.visible=this._visible,a.size=this._size,e.renderer.setPlane(!0,a.three),this.updateMaterialsAndPlanes(),a}getWorldNormal(e,t){const s=e.object;let n=e.object.matrixWorld.clone();if(s instanceof i.InstancedMesh&&void 0!==e.instanceId){const t=new i.Matrix4;s.getMatrixAt(e.instanceId,t),n=t.multiply(n)}const r=(new i.Matrix3).getNormalMatrix(n),o=t.clone().applyMatrix3(r).normalize();return this.normalizePlaneDirectionY(o),o}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);return s.onDraggingStarted.add(this._onStartDragging),s.onDraggingEnded.add(this._onEndDragging),this.list.push(s),this.onAfterCreate.trigger(s),s}updateMaterialsAndPlanes(){const e=this.components.get(vn);for(const[t,i]of e.list){if(!i.renderer)continue;i.renderer.updateClippingPlanes();const{clippingPlanes:e}=i.renderer;for(const t of i.meshes)if(t.material)if(Array.isArray(t.material))for(const i of t.material)i.clippingPlanes=e;else t.material.clippingPlanes=e}}};t(wr,"uuid","66290bc5-18c4-4cd1-9379-2e17a0617611");let vr=wr;class Mr{constructor(e){t(this,"enabled",!1),t(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 i.Vector3;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=Ln.ACTION.DOLLY,e.touches.two=Ln.ACTION.TOUCH_ZOOM_TRUCK}}class Dr{constructor(e){t(this,"enabled",!0),t(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 i.Vector3;e.getPosition(t);const s=t.length();e.distance=s,e.truckSpeed=2;const{rotation:n}=this.camera.three,r=new i.Vector3(0,0,-1).applyEuler(n),o=t.addScaledVector(r,s);e.moveTo(o.x,o.y,o.z)}}class br{constructor(e){t(this,"enabled",!1),t(this,"id","Plan"),t(this,"mouseAction1"),t(this,"mouseAction2"),t(this,"mouseInitialized",!1),t(this,"defaultAzimuthSpeed"),t(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=Ln.ACTION.TRUCK,t.touches.one=Ln.ACTION.TOUCH_TRUCK,t.touches.two=Ln.ACTION.TOUCH_ZOOM):(t.mouseButtons.left=Ln.ACTION.ROTATE,t.touches.one=this.mouseAction1,t.touches.two=this.mouseAction2)}}class xr{constructor(e){t(this,"onChanged",new ci),t(this,"current","Perspective"),t(this,"camera"),t(this,"matchOrthoDistanceEnabled",!1),t(this,"_component"),t(this,"_previousDistance",-1),this._component=e,this.camera=e.three}async set(e){this.current!==e&&("Orthographic"===e?this.setOrthoCamera():await this.setPerspectiveCamera(),this.onChanged.trigger(this.camera))}async toggle(){const e="Perspective"===this.current?"Orthographic":"Perspective";await this.set(e)}setOrthoCamera(){if(null===this._component.mode)return;if("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 i.Vector3;this._component.threePersp.getWorldDirection(t);const s=new i.Vector3;this._component.controls.getTarget(s);const n=s.clone().sub(this._component.threePersp.position).dot(t),r=e.renderer.getSize(),o=r.x/r.y,a=this._component.threePersp,c=2*n*Math.atan(a.fov*(Math.PI/180)/2);return{width:c*o,height:c}}setupOrthoCamera(e,t){this._component.controls.mouseButtons.wheel=Ln.ACTION.ZOOM,this._component.controls.mouseButtons.middle=Ln.ACTION.ZOOM,this._component.controls.touches.two=Ln.ACTION.TOUCH_ZOOM_TRUCK,this._component.controls.touches.three=Ln.ACTION.TOUCH_ZOOM_TRUCK,this._component.controls.dollySpeed=5;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 e=this._component.threePersp,t=this._component.threeOrtho;return(t.top-t.bottom)/t.zoom/(2*Math.atan(e.fov*(Math.PI/180)/2))}async setPerspectiveCamera(){this._component.controls.mouseButtons.wheel=Ln.ACTION.DOLLY,this._component.controls.mouseButtons.middle=Ln.ACTION.DOLLY;const e=this._component.threePersp,t=this._component.threeOrtho;e.position.copy(t.position),e.quaternion.copy(t.quaternion),this._component.controls.mouseButtons.wheel=Ln.ACTION.DOLLY,this._component.controls.touches.two=Ln.ACTION.TOUCH_DOLLY_TRUCK,this._component.controls.touches.three=Ln.ACTION.TOUCH_DOLLY_TRUCK,this._component.controls.dollySpeed=5,this.matchOrthoDistanceEnabled?this._component.controls.distance=this.getDistance():this._component.controls.distance=this._previousDistance,await this._component.controls.zoomTo(1),e.updateProjectionMatrix(),this._component.controls.camera=e,this.camera=e,this.current="Perspective"}}class Ur extends Pn{constructor(e){super(e),t(this,"projection"),t(this,"threeOrtho"),t(this,"threePersp"),t(this,"_userInputButtons",{}),t(this,"_frustumSize",50),t(this,"_navigationModes",new Map),t(this,"_mode",null),t(this,"previousSize",null),this.threePersp=this.three,this.threeOrtho=this.newOrthoCamera(),this.projection=new xr(this),this.onAspectUpdated.add((()=>{this.setOrthoPerspCameraAspect()})),this.projection.onChanged.add((e=>{this.three=e,this.updateAspect()})),this.onWorldChanged.add((({action:e})=>{"added"===e&&(this._navigationModes.clear(),this._navigationModes.set("Orbit",new Dr(this)),this._navigationModes.set("FirstPerson",new Mr(this)),this._navigationModes.set("Plan",new br(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()))}))}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)}}async fit(e,t=1.5){if(!this.enabled)return;const s=Number.MAX_VALUE,n=Number.MIN_VALUE,r=new i.Vector3(s,s,s),o=new i.Vector3(n,n,n);for(const t of e){const e=(new i.Box3).setFromObject(t);e.min.x<r.x&&(r.x=e.min.x),e.min.y<r.y&&(r.y=e.min.y),e.min.z<r.z&&(r.z=e.min.z),e.max.x>o.x&&(o.x=e.max.x),e.max.y>o.y&&(o.y=e.max.y),e.max.z>o.z&&(o.z=e.max.z)}const a=new i.Box3(r,o),c=new i.Vector3;a.getSize(c);const l=new i.Vector3;a.getCenter(l);const h=Math.max(c.x,c.y,c.z)*t,u=new i.Sphere(l,h);await this.controls.fitToSphere(u,!0)}setUserInput(e){e?this.enableUserInput():this.disableUserInput()}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 i.OrthographicCamera(this._frustumSize*e/-2,this._frustumSize*e/2,this._frustumSize/2,this._frustumSize/-2,.1,1e3)}setOrthoPerspCameraAspect(){if(!this.currentWorld||!this.currentWorld.renderer)return;if(!this.previousSize)return;const e=this.currentWorld.renderer.getSize(),t=this.threeOrtho.top,i=this.threeOrtho.right,s=t*(e.y/this.previousSize.y),n=i*(e.x/this.previousSize.x);this.threeOrtho.left=-n,this.threeOrtho.right=n,this.threeOrtho.top=s,this.threeOrtho.bottom=-s,this.threeOrtho.updateProjectionMatrix(),this.previousSize.copy(e)}}const Br=new Map([[x.IFCRELAGGREGATES,{forRelated:"Decomposes",forRelating:"IsDecomposedBy"}],[x.IFCRELASSOCIATESMATERIAL,{forRelated:"HasAssociations",forRelating:"AssociatedTo"}],[x.IFCRELASSOCIATESCLASSIFICATION,{forRelated:"HasAssociations",forRelating:"ClassificationForObjects"}],[x.IFCRELASSIGNSTOGROUP,{forRelated:"HasAssignments",forRelating:"IsGroupedBy"}],[x.IFCRELDEFINESBYPROPERTIES,{forRelated:"IsDefinedBy",forRelating:"DefinesOcurrence"}],[x.IFCRELDEFINESBYTYPE,{forRelated:"IsTypedBy",forRelating:"Types"}],[x.IFCRELDEFINESBYTEMPLATE,{forRelated:"IsDefinedBy",forRelating:"Defines"}],[x.IFCRELCONTAINEDINSPATIALSTRUCTURE,{forRelated:"ContainedInStructure",forRelating:"ContainsElements"}],[x.IFCRELFLOWCONTROLELEMENTS,{forRelated:"AssignedToFlowElement",forRelating:"HasControlElements"}],[x.IFCRELCONNECTSELEMENTS,{forRelated:"ConnectedFrom",forRelating:"ConnectedTo"}],[x.IFCRELASSIGNSTOPRODUCT,{forRelated:"HasAssignments",forRelating:"ReferencedBy"}],[x.IFCRELDECLARES,{forRelated:"HasContext",forRelating:"Declares"}],[x.IFCRELASSIGNSTOCONTROL,{forRelated:"HasAssignments",forRelating:"Controls"}],[x.IFCRELNESTS,{forRelated:"Nests",forRelating:"IsNestedBy"}],[x.IFCRELASSOCIATESDOCUMENT,{forRelated:"HasAssociations",forRelating:"DocumentRefForObjects"}]]),Vr={103090709:"IFCPROJECT",4097777520:"IFCSITE",4031249490:"IFCBUILDING",3124254112:"IFCBUILDINGSTOREY",3856911033:"IFCSPACE",1674181508:"IFCANNOTATION",25142252:"IFCCONTROLLER",32344328:"IFCBOILER",76236018:"IFCLAMP",90941305:"IFCPUMP",177149247:"IFCAIRTERMINALBOX",182646315:"IFCFLOWINSTRUMENT",263784265:"IFCFURNISHINGELEMENT",264262732:"IFCELECTRICGENERATOR",277319702:"IFCAUDIOVISUALAPPLIANCE",310824031:"IFCPIPEFITTING",331165859:"IFCSTAIR",342316401:"IFCDUCTFITTING",377706215:"IFCMECHANICALFASTENER",395920057:"IFCDOOR",402227799:"IFCELECTRICMOTOR",413509423:"IFCSYSTEMFURNITUREELEMENT",484807127:"IFCEVAPORATOR",486154966:"IFCWINDOWSTANDARDCASE",629592764:"IFCLIGHTFIXTURE",630975310:"IFCUNITARYCONTROLELEMENT",635142910:"IFCCABLECARRIERFITTING",639361253:"IFCCOIL",647756555:"IFCFASTENER",707683696:"IFCFLOWSTORAGEDEVICE",738039164:"IFCPROTECTIVEDEVICE",753842376:"IFCBEAM",812556717:"IFCTANK",819412036:"IFCFILTER",843113511:"IFCCOLUMN",862014818:"IFCELECTRICDISTRIBUTIONBOARD",900683007:"IFCFOOTING",905975707:"IFCCOLUMNSTANDARDCASE",926996030:"IFCVOIDINGFEATURE",979691226:"IFCREINFORCINGBAR",987401354:"IFCFLOWSEGMENT",1003880860:"IFCELECTRICTIMECONTROL",1051757585:"IFCCABLEFITTING",1052013943:"IFCDISTRIBUTIONCHAMBERELEMENT",1062813311:"IFCDISTRIBUTIONCONTROLELEMENT",1073191201:"IFCMEMBER",1095909175:"IFCBUILDINGELEMENTPROXY",1156407060:"IFCPLATESTANDARDCASE",1162798199:"IFCSWITCHINGDEVICE",1329646415:"IFCSHADINGDEVICE",1335981549:"IFCDISCRETEACCESSORY",1360408905:"IFCDUCTSILENCER",1404847402:"IFCSTACKTERMINAL",1426591983:"IFCFIRESUPPRESSIONTERMINAL",1437502449:"IFCMEDICALDEVICE",1509553395:"IFCFURNITURE",1529196076:"IFCSLAB",1620046519:"IFCTRANSPORTELEMENT",1634111441:"IFCAIRTERMINAL",1658829314:"IFCENERGYCONVERSIONDEVICE",1677625105:"IFCCIVILELEMENT",1687234759:"IFCPILE",1904799276:"IFCELECTRICAPPLIANCE",1911478936:"IFCMEMBERSTANDARDCASE",1945004755:"IFCDISTRIBUTIONELEMENT",1973544240:"IFCCOVERING",1999602285:"IFCSPACEHEATER",2016517767:"IFCROOF",2056796094:"IFCAIRTOAIRHEATRECOVERY",2058353004:"IFCFLOWCONTROLLER",2068733104:"IFCHUMIDIFIER",2176052936:"IFCJUNCTIONBOX",2188021234:"IFCFLOWMETER",2223149337:"IFCFLOWTERMINAL",2262370178:"IFCRAILING",2272882330:"IFCCONDENSER",2295281155:"IFCPROTECTIVEDEVICETRIPPINGUNIT",2320036040:"IFCREINFORCINGMESH",2347447852:"IFCTENDONANCHOR",2391383451:"IFCVIBRATIONISOLATOR",2391406946:"IFCWALL",2474470126:"IFCMOTORCONNECTION",2769231204:"IFCVIRTUALELEMENT",2814081492:"IFCENGINE",2906023776:"IFCBEAMSTANDARDCASE",2938176219:"IFCBURNER",2979338954:"IFCBUILDINGELEMENTPART",3024970846:"IFCRAMP",3026737570:"IFCTUBEBUNDLE",3027962421:"IFCSLABSTANDARDCASE",3040386961:"IFCDISTRIBUTIONFLOWELEMENT",3053780830:"IFCSANITARYTERMINAL",3079942009:"IFCOPENINGSTANDARDCASE",3087945054:"IFCALARM",3101698114:"IFCSURFACEFEATURE",3127900445:"IFCSLABELEMENTEDCASE",3132237377:"IFCFLOWMOVINGDEVICE",3171933400:"IFCPLATE",3221913625:"IFCCOMMUNICATIONSAPPLIANCE",3242481149:"IFCDOORSTANDARDCASE",3283111854:"IFCRAMPFLIGHT",3296154744:"IFCCHIMNEY",3304561284:"IFCWINDOW",3310460725:"IFCELECTRICFLOWSTORAGEDEVICE",3319311131:"IFCHEATEXCHANGER",3415622556:"IFCFAN",3420628829:"IFCSOLARDEVICE",3493046030:"IFCGEOGRAPHICELEMENT",3495092785:"IFCCURTAINWALL",3508470533:"IFCFLOWTREATMENTDEVICE",3512223829:"IFCWALLSTANDARDCASE",3518393246:"IFCDUCTSEGMENT",3571504051:"IFCCOMPRESSOR",3588315303:"IFCOPENINGELEMENT",3612865200:"IFCPIPESEGMENT",3640358203:"IFCCOOLINGTOWER",3651124850:"IFCPROJECTIONELEMENT",3694346114:"IFCOUTLET",3747195512:"IFCEVAPORATIVECOOLER",3758799889:"IFCCABLECARRIERSEGMENT",3824725483:"IFCTENDON",3825984169:"IFCTRANSFORMER",3902619387:"IFCCHILLER",4074379575:"IFCDAMPER",4086658281:"IFCSENSOR",4123344466:"IFCELEMENTASSEMBLY",4136498852:"IFCCOOLEDBEAM",4156078855:"IFCWALLELEMENTEDCASE",4175244083:"IFCINTERCEPTOR",4207607924:"IFCVALVE",4217484030:"IFCCABLESEGMENT",4237592921:"IFCWASTETERMINAL",4252922144:"IFCSTAIRFLIGHT",4278956645:"IFCFLOWFITTING",4288193352:"IFCACTUATOR",4292641817:"IFCUNITARYEQUIPMENT",3009204131:"IFCGRID"};class Yr{getAll(e,t){const i={},s=Object.keys(Vr).map((e=>parseInt(e,10)));for(let n=0;n<s.length;n++){const r=s[n],o=e.GetLineIDsWithType(t,r),a=o.size();for(let e=0;e<a;e++)i[o.get(e)]=r}return i}}const Gr={950732822:"IFCURIREFERENCE",4075327185:"IFCTIME",1209108979:"IFCTEMPERATURERATEOFCHANGEMEASURE",3457685358:"IFCSOUNDPRESSURELEVELMEASURE",4157543285:"IFCSOUNDPOWERLEVELMEASURE",2798247006:"IFCPROPERTYSETDEFINITIONSET",1790229001:"IFCPOSITIVEINTEGER",525895558:"IFCNONNEGATIVELENGTHMEASURE",1774176899:"IFCLINEINDEX",1275358634:"IFCLANGUAGEID",2541165894:"IFCDURATION",3701338814:"IFCDAYINWEEKNUMBER",2195413836:"IFCDATETIME",937566702:"IFCDATE",1683019596:"IFCCARDINALPOINTREFERENCE",2314439260:"IFCBINARY",1500781891:"IFCAREADENSITYMEASURE",3683503648:"IFCARCINDEX",4065007721:"IFCYEARNUMBER",1718600412:"IFCWARPINGMOMENTMEASURE",51269191:"IFCWARPINGCONSTANTMEASURE",2593997549:"IFCVOLUMETRICFLOWRATEMEASURE",3458127941:"IFCVOLUMEMEASURE",3345633955:"IFCVAPORPERMEABILITYMEASURE",1278329552:"IFCTORQUEMEASURE",2591213694:"IFCTIMESTAMP",2726807636:"IFCTIMEMEASURE",743184107:"IFCTHERMODYNAMICTEMPERATUREMEASURE",2016195849:"IFCTHERMALTRANSMITTANCEMEASURE",857959152:"IFCTHERMALRESISTANCEMEASURE",2281867870:"IFCTHERMALEXPANSIONCOEFFICIENTMEASURE",2645777649:"IFCTHERMALCONDUCTIVITYMEASURE",232962298:"IFCTHERMALADMITTANCEMEASURE",296282323:"IFCTEXTTRANSFORMATION",603696268:"IFCTEXTFONTNAME",3490877962:"IFCTEXTDECORATION",1460886941:"IFCTEXTALIGNMENT",2801250643:"IFCTEXT",58845555:"IFCTEMPERATUREGRADIENTMEASURE",361837227:"IFCSPECULARROUGHNESS",2757832317:"IFCSPECULAREXPONENT",3477203348:"IFCSPECIFICHEATCAPACITYMEASURE",993287707:"IFCSOUNDPRESSUREMEASURE",846465480:"IFCSOUNDPOWERMEASURE",3471399674:"IFCSOLIDANGLEMEASURE",408310005:"IFCSHEARMODULUSMEASURE",2190458107:"IFCSECTIONALAREAINTEGRALMEASURE",3467162246:"IFCSECTIONMODULUSMEASURE",2766185779:"IFCSECONDINMINUTE",3211557302:"IFCROTATIONALSTIFFNESSMEASURE",1755127002:"IFCROTATIONALMASSMEASURE",2133746277:"IFCROTATIONALFREQUENCYMEASURE",200335297:"IFCREAL",96294661:"IFCRATIOMEASURE",3972513137:"IFCRADIOACTIVITYMEASURE",3665567075:"IFCPRESSUREMEASURE",2169031380:"IFCPRESENTABLETEXT",1364037233:"IFCPOWERMEASURE",1245737093:"IFCPOSITIVERATIOMEASURE",3054510233:"IFCPOSITIVEPLANEANGLEMEASURE",2815919920:"IFCPOSITIVELENGTHMEASURE",4042175685:"IFCPLANEANGLEMEASURE",2642773653:"IFCPLANARFORCEMEASURE",2260317790:"IFCPARAMETERVALUE",929793134:"IFCPHMEASURE",2395907400:"IFCNUMERICMEASURE",2095195183:"IFCNORMALISEDRATIOMEASURE",765770214:"IFCMONTHINYEARNUMBER",2615040989:"IFCMONETARYMEASURE",3114022597:"IFCMOMENTOFINERTIAMEASURE",1648970520:"IFCMOLECULARWEIGHTMEASURE",3177669450:"IFCMOISTUREDIFFUSIVITYMEASURE",1753493141:"IFCMODULUSOFSUBGRADEREACTIONMEASURE",1052454078:"IFCMODULUSOFROTATIONALSUBGRADEREACTIONMEASURE",2173214787:"IFCMODULUSOFLINEARSUBGRADEREACTIONMEASURE",3341486342:"IFCMODULUSOFELASTICITYMEASURE",102610177:"IFCMINUTEINHOUR",3531705166:"IFCMASSPERLENGTHMEASURE",3124614049:"IFCMASSMEASURE",4017473158:"IFCMASSFLOWRATEMEASURE",1477762836:"IFCMASSDENSITYMEASURE",2486716878:"IFCMAGNETICFLUXMEASURE",286949696:"IFCMAGNETICFLUXDENSITYMEASURE",151039812:"IFCLUMINOUSINTENSITYMEASURE",2755797622:"IFCLUMINOUSINTENSITYDISTRIBUTIONMEASURE",2095003142:"IFCLUMINOUSFLUXMEASURE",503418787:"IFCLOGICAL",3086160713:"IFCLINEARVELOCITYMEASURE",1307019551:"IFCLINEARSTIFFNESSMEASURE",2128979029:"IFCLINEARMOMENTMEASURE",191860431:"IFCLINEARFORCEMEASURE",1243674935:"IFCLENGTHMEASURE",3258342251:"IFCLABEL",2054016361:"IFCKINEMATICVISCOSITYMEASURE",3192672207:"IFCISOTHERMALMOISTURECAPACITYMEASURE",3686016028:"IFCIONCONCENTRATIONMEASURE",3809634241:"IFCINTEGERCOUNTRATEMEASURE",1939436016:"IFCINTEGER",2679005408:"IFCINDUCTANCEMEASURE",3358199106:"IFCILLUMINANCEMEASURE",983778844:"IFCIDENTIFIER",2589826445:"IFCHOURINDAY",1158859006:"IFCHEATINGVALUEMEASURE",3113092358:"IFCHEATFLUXDENSITYMEASURE",3064340077:"IFCGLOBALLYUNIQUEID",3044325142:"IFCFREQUENCYMEASURE",1361398929:"IFCFORCEMEASURE",2590844177:"IFCFONTWEIGHT",2715512545:"IFCFONTVARIANT",1102727119:"IFCFONTSTYLE",2078135608:"IFCENERGYMEASURE",2506197118:"IFCELECTRICVOLTAGEMEASURE",2951915441:"IFCELECTRICRESISTANCEMEASURE",3790457270:"IFCELECTRICCURRENTMEASURE",2093906313:"IFCELECTRICCONDUCTANCEMEASURE",3818826038:"IFCELECTRICCHARGEMEASURE",1827137117:"IFCELECTRICCAPACITANCEMEASURE",69416015:"IFCDYNAMICVISCOSITYMEASURE",524656162:"IFCDOSEEQUIVALENTMEASURE",4134073009:"IFCDIMENSIONCOUNT",1514641115:"IFCDESCRIPTIVEMEASURE",300323983:"IFCDAYLIGHTSAVINGHOUR",86635668:"IFCDAYINMONTHNUMBER",94842927:"IFCCURVATUREMEASURE",1778710042:"IFCCOUNTMEASURE",3238673880:"IFCCONTEXTDEPENDENTMEASURE",3812528620:"IFCCOMPOUNDPLANEANGLEMEASURE",2991860651:"IFCCOMPLEXNUMBER",1867003952:"IFCBOXALIGNMENT",2735952531:"IFCBOOLEAN",2650437152:"IFCAREAMEASURE",632304761:"IFCANGULARVELOCITYMEASURE",360377573:"IFCAMOUNTOFSUBSTANCEMEASURE",4182062534:"IFCACCELERATIONMEASURE",3699917729:"IFCABSORBEDDOSEMEASURE",1971632696:"IFCGEOSLICE",2680139844:"IFCGEOMODEL",24726584:"IFCELECTRICFLOWTREATMENTDEVICE",3693000487:"IFCDISTRIBUTIONBOARD",3460952963:"IFCCONVEYORSEGMENT",3999819293:"IFCCAISSONFOUNDATION",3314249567:"IFCBOREHOLE",4196446775:"IFCBEARING",325726236:"IFCALIGNMENT",3425753595:"IFCTRACKELEMENT",991950508:"IFCSIGNAL",3798194928:"IFCREINFORCEDSOIL",3290496277:"IFCRAIL",1383356374:"IFCPAVEMENT",2182337498:"IFCNAVIGATIONELEMENT",234836483:"IFCMOORINGDEVICE",2078563270:"IFCMOBILETELECOMMUNICATIONSAPPLIANCE",1638804497:"IFCLIQUIDTERMINAL",1154579445:"IFCLINEARPOSITIONINGELEMENT",2696325953:"IFCKERB",2713699986:"IFCGEOTECHNICALASSEMBLY",2142170206:"IFCELECTRICFLOWTREATMENTDEVICETYPE",3376911765:"IFCEARTHWORKSFILL",1077100507:"IFCEARTHWORKSELEMENT",3071239417:"IFCEARTHWORKSCUT",479945903:"IFCDISTRIBUTIONBOARDTYPE",3426335179:"IFCDEEPFOUNDATION",1502416096:"IFCCOURSE",2940368186:"IFCCONVEYORSEGMENTTYPE",3203706013:"IFCCAISSONFOUNDATIONTYPE",3862327254:"IFCBUILTSYSTEM",1876633798:"IFCBUILTELEMENT",963979645:"IFCBRIDGEPART",644574406:"IFCBRIDGE",3649138523:"IFCBEARINGTYPE",1662888072:"IFCALIGNMENTVERTICAL",317615605:"IFCALIGNMENTSEGMENT",1545765605:"IFCALIGNMENTHORIZONTAL",4266260250:"IFCALIGNMENTCANT",3956297820:"IFCVIBRATIONDAMPERTYPE",1530820697:"IFCVIBRATIONDAMPER",840318589:"IFCVEHICLE",1953115116:"IFCTRANSPORTATIONDEVICE",618700268:"IFCTRACKELEMENTTYPE",2281632017:"IFCTENDONCONDUITTYPE",3663046924:"IFCTENDONCONDUIT",42703149:"IFCSINESPIRAL",1894708472:"IFCSIGNALTYPE",3599934289:"IFCSIGNTYPE",33720170:"IFCSIGN",1027922057:"IFCSEVENTHORDERPOLYNOMIALSPIRAL",544395925:"IFCSEGMENTEDREFERENCECURVE",3649235739:"IFCSECONDORDERPOLYNOMIALSPIRAL",550521510:"IFCROADPART",146592293:"IFCROAD",3818125796:"IFCRELADHERESTOELEMENT",4021432810:"IFCREFERENT",1891881377:"IFCRAILWAYPART",3992365140:"IFCRAILWAY",1763565496:"IFCRAILTYPE",1946335990:"IFCPOSITIONINGELEMENT",514975943:"IFCPAVEMENTTYPE",506776471:"IFCNAVIGATIONELEMENTTYPE",710110818:"IFCMOORINGDEVICETYPE",1950438474:"IFCMOBILETELECOMMUNICATIONSAPPLIANCETYPE",976884017:"IFCMARINEPART",525669439:"IFCMARINEFACILITY",1770583370:"IFCLIQUIDTERMINALTYPE",2176059722:"IFCLINEARELEMENT",679976338:"IFCKERBTYPE",3948183225:"IFCIMPACTPROTECTIONDEVICETYPE",2568555532:"IFCIMPACTPROTECTIONDEVICE",2898700619:"IFCGRADIENTCURVE",1594536857:"IFCGEOTECHNICALSTRATUM",4230923436:"IFCGEOTECHNICALELEMENT",4228831410:"IFCFACILITYPARTCOMMON",1310830890:"IFCFACILITYPART",24185140:"IFCFACILITY",4234616927:"IFCDIRECTRIXDERIVEDREFERENCESWEPTAREASOLID",1306400036:"IFCDEEPFOUNDATIONTYPE",4189326743:"IFCCOURSETYPE",2000195564:"IFCCOSINESPIRAL",3497074424:"IFCCLOTHOID",1626504194:"IFCBUILTELEMENTTYPE",3651464721:"IFCVEHICLETYPE",1229763772:"IFCTRIANGULATEDIRREGULARNETWORK",3665877780:"IFCTRANSPORTATIONDEVICETYPE",782932809:"IFCTHIRDORDERPOLYNOMIALSPIRAL",2735484536:"IFCSPIRAL",1356537516:"IFCSECTIONEDSURFACE",1290935644:"IFCSECTIONEDSOLIDHORIZONTAL",1862484736:"IFCSECTIONEDSOLID",1441486842:"IFCRELPOSITIONS",1033248425:"IFCRELASSOCIATESPROFILEDEF",3381221214:"IFCPOLYNOMIALCURVE",2485787929:"IFCOFFSETCURVEBYDISTANCES",590820931:"IFCOFFSETCURVE",3465909080:"IFCINDEXEDPOLYGONALTEXTUREMAP",593015953:"IFCDIRECTRIXCURVESWEPTAREASOLID",4212018352:"IFCCURVESEGMENT",3425423356:"IFCAXIS2PLACEMENTLINEAR",823603102:"IFCSEGMENT",2165702409:"IFCPOINTBYDISTANCEEXPRESSION",182550632:"IFCOPENCROSSPROFILEDEF",388784114:"IFCLINEARPLACEMENT",536804194:"IFCALIGNMENTHORIZONTALSEGMENT",3752311538:"IFCALIGNMENTCANTSEGMENT",1010789467:"IFCTEXTURECOORDINATEINDICESWITHVOIDS",222769930:"IFCTEXTURECOORDINATEINDICES",2691318326:"IFCQUANTITYNUMBER",3633395639:"IFCALIGNMENTVERTICALSEGMENT",2879124712:"IFCALIGNMENTPARAMETERSEGMENT",25142252:"IFCCONTROLLER",3087945054:"IFCALARM",4288193352:"IFCACTUATOR",630975310:"IFCUNITARYCONTROLELEMENT",4086658281:"IFCSENSOR",2295281155:"IFCPROTECTIVEDEVICETRIPPINGUNIT",182646315:"IFCFLOWINSTRUMENT",1426591983:"IFCFIRESUPPRESSIONTERMINAL",819412036:"IFCFILTER",3415622556:"IFCFAN",1003880860:"IFCELECTRICTIMECONTROL",402227799:"IFCELECTRICMOTOR",264262732:"IFCELECTRICGENERATOR",3310460725:"IFCELECTRICFLOWSTORAGEDEVICE",862014818:"IFCELECTRICDISTRIBUTIONBOARD",1904799276:"IFCELECTRICAPPLIANCE",1360408905:"IFCDUCTSILENCER",3518393246:"IFCDUCTSEGMENT",342316401:"IFCDUCTFITTING",562808652:"IFCDISTRIBUTIONCIRCUIT",4074379575:"IFCDAMPER",3640358203:"IFCCOOLINGTOWER",4136498852:"IFCCOOLEDBEAM",2272882330:"IFCCONDENSER",3571504051:"IFCCOMPRESSOR",3221913625:"IFCCOMMUNICATIONSAPPLIANCE",639361253:"IFCCOIL",3902619387:"IFCCHILLER",4217484030:"IFCCABLESEGMENT",1051757585:"IFCCABLEFITTING",3758799889:"IFCCABLECARRIERSEGMENT",635142910:"IFCCABLECARRIERFITTING",2938176219:"IFCBURNER",32344328:"IFCBOILER",2906023776:"IFCBEAMSTANDARDCASE",277319702:"IFCAUDIOVISUALAPPLIANCE",2056796094:"IFCAIRTOAIRHEATRECOVERY",177149247:"IFCAIRTERMINALBOX",1634111441:"IFCAIRTERMINAL",486154966:"IFCWINDOWSTANDARDCASE",4237592921:"IFCWASTETERMINAL",4156078855:"IFCWALLELEMENTEDCASE",4207607924:"IFCVALVE",4292641817:"IFCUNITARYEQUIPMENT",3179687236:"IFCUNITARYCONTROLELEMENTTYPE",3026737570:"IFCTUBEBUNDLE",3825984169:"IFCTRANSFORMER",812556717:"IFCTANK",1162798199:"IFCSWITCHINGDEVICE",385403989:"IFCSTRUCTURALLOADCASE",1404847402:"IFCSTACKTERMINAL",1999602285:"IFCSPACEHEATER",3420628829:"IFCSOLARDEVICE",3027962421:"IFCSLABSTANDARDCASE",3127900445:"IFCSLABELEMENTEDCASE",1329646415:"IFCSHADINGDEVICE",3053780830:"IFCSANITARYTERMINAL",2572171363:"IFCREINFORCINGBARTYPE",1232101972:"IFCRATIONALBSPLINECURVEWITHKNOTS",90941305:"IFCPUMP",655969474:"IFCPROTECTIVEDEVICETRIPPINGUNITTYPE",738039164:"IFCPROTECTIVEDEVICE",1156407060:"IFCPLATESTANDARDCASE",3612865200:"IFCPIPESEGMENT",310824031:"IFCPIPEFITTING",3694346114:"IFCOUTLET",144952367:"IFCOUTERBOUNDARYCURVE",2474470126:"IFCMOTORCONNECTION",1911478936:"IFCMEMBERSTANDARDCASE",1437502449:"IFCMEDICALDEVICE",629592764:"IFCLIGHTFIXTURE",76236018:"IFCLAMP",2176052936:"IFCJUNCTIONBOX",4175244083:"IFCINTERCEPTOR",2068733104:"IFCHUMIDIFIER",3319311131:"IFCHEATEXCHANGER",2188021234:"IFCFLOWMETER",1209101575:"IFCEXTERNALSPATIALELEMENT",484807127:"IFCEVAPORATOR",3747195512:"IFCEVAPORATIVECOOLER",2814081492:"IFCENGINE",2417008758:"IFCELECTRICDISTRIBUTIONBOARDTYPE",3242481149:"IFCDOORSTANDARDCASE",3205830791:"IFCDISTRIBUTIONSYSTEM",400855858:"IFCCOMMUNICATIONSAPPLIANCETYPE",905975707:"IFCCOLUMNSTANDARDCASE",1677625105:"IFCCIVILELEMENT",3296154744:"IFCCHIMNEY",2674252688:"IFCCABLEFITTINGTYPE",2188180465:"IFCBURNERTYPE",1177604601:"IFCBUILDINGSYSTEM",39481116:"IFCBUILDINGELEMENTPARTTYPE",1136057603:"IFCBOUNDARYCURVE",2461110595:"IFCBSPLINECURVEWITHKNOTS",1532957894:"IFCAUDIOVISUALAPPLIANCETYPE",4088093105:"IFCWORKCALENDAR",4009809668:"IFCWINDOWTYPE",926996030:"IFCVOIDINGFEATURE",2391383451:"IFCVIBRATIONISOLATOR",2415094496:"IFCTENDONTYPE",3081323446:"IFCTENDONANCHORTYPE",413509423:"IFCSYSTEMFURNITUREELEMENT",3101698114:"IFCSURFACEFEATURE",3657597509:"IFCSTRUCTURALSURFACEACTION",2757150158:"IFCSTRUCTURALCURVEREACTION",1004757350:"IFCSTRUCTURALCURVEACTION",338393293:"IFCSTAIRTYPE",1072016465:"IFCSOLARDEVICETYPE",4074543187:"IFCSHADINGDEVICETYPE",2157484638:"IFCSEAMCURVE",2781568857:"IFCROOFTYPE",2310774935:"IFCREINFORCINGMESHTYPE",964333572:"IFCREINFORCINGELEMENTTYPE",683857671:"IFCRATIONALBSPLINESURFACEWITHKNOTS",1469900589:"IFCRAMPTYPE",2839578677:"IFCPOLYGONALFACESET",1158309216:"IFCPILETYPE",3079942009:"IFCOPENINGSTANDARDCASE",1114901282:"IFCMEDICALDEVICETYPE",3113134337:"IFCINTERSECTIONCURVE",3946677679:"IFCINTERCEPTORTYPE",2571569899:"IFCINDEXEDPOLYCURVE",3493046030:"IFCGEOGRAPHICELEMENT",1509553395:"IFCFURNITURE",1893162501:"IFCFOOTINGTYPE",2853485674:"IFCEXTERNALSPATIALSTRUCTUREELEMENT",4148101412:"IFCEVENT",132023988:"IFCENGINETYPE",2397081782:"IFCELEMENTASSEMBLYTYPE",2323601079:"IFCDOORTYPE",1213902940:"IFCCYLINDRICALSURFACE",1525564444:"IFCCONSTRUCTIONPRODUCTRESOURCETYPE",4105962743:"IFCCONSTRUCTIONMATERIALRESOURCETYPE",2185764099:"IFCCONSTRUCTIONEQUIPMENTRESOURCETYPE",15328376:"IFCCOMPOSITECURVEONSURFACE",3875453745:"IFCCOMPLEXPROPERTYTEMPLATE",3893394355:"IFCCIVILELEMENTTYPE",2197970202:"IFCCHIMNEYTYPE",167062518:"IFCBSPLINESURFACEWITHKNOTS",2887950389:"IFCBSPLINESURFACE",2603310189:"IFCADVANCEDBREPWITHVOIDS",1635779807:"IFCADVANCEDBREP",2916149573:"IFCTRIANGULATEDFACESET",1935646853:"IFCTOROIDALSURFACE",2387106220:"IFCTESSELLATEDFACESET",3206491090:"IFCTASKTYPE",699246055:"IFCSURFACECURVE",4095615324:"IFCSUBCONTRACTRESOURCETYPE",603775116:"IFCSTRUCTURALSURFACEREACTION",4015995234:"IFCSPHERICALSURFACE",2481509218:"IFCSPATIALZONETYPE",463610769:"IFCSPATIALZONE",710998568:"IFCSPATIALELEMENTTYPE",1412071761:"IFCSPATIALELEMENT",3663146110:"IFCSIMPLEPROPERTYTEMPLATE",3243963512:"IFCREVOLVEDAREASOLIDTAPERED",816062949:"IFCREPARAMETRISEDCOMPOSITECURVESEGMENT",1521410863:"IFCRELSPACEBOUNDARY2NDLEVEL",3523091289:"IFCRELSPACEBOUNDARY1STLEVEL",427948657:"IFCRELINTERFERESELEMENTS",307848117:"IFCRELDEFINESBYTEMPLATE",1462361463:"IFCRELDEFINESBYOBJECT",2565941209:"IFCRELDECLARES",1027710054:"IFCRELASSIGNSTOGROUPBYFACTOR",3521284610:"IFCPROPERTYTEMPLATE",492091185:"IFCPROPERTYSETTEMPLATE",653396225:"IFCPROJECTLIBRARY",569719735:"IFCPROCEDURETYPE",3967405729:"IFCPREDEFINEDPROPERTYSET",1682466193:"IFCPCURVE",428585644:"IFCLABORRESOURCETYPE",2294589976:"IFCINDEXEDPOLYGONALFACEWITHVOIDS",178912537:"IFCINDEXEDPOLYGONALFACE",4095422895:"IFCGEOGRAPHICELEMENTTYPE",2652556860:"IFCFIXEDREFERENCESWEPTAREASOLID",2804161546:"IFCEXTRUDEDAREASOLIDTAPERED",4024345920:"IFCEVENTTYPE",2629017746:"IFCCURVEBOUNDEDSURFACE",1815067380:"IFCCREWRESOURCETYPE",3419103109:"IFCCONTEXT",2574617495:"IFCCONSTRUCTIONRESOURCETYPE",2059837836:"IFCCARTESIANPOINTLIST3D",1675464909:"IFCCARTESIANPOINTLIST2D",574549367:"IFCCARTESIANPOINTLIST",3406155212:"IFCADVANCEDFACE",3698973494:"IFCTYPERESOURCE",3736923433:"IFCTYPEPROCESS",901063453:"IFCTESSELLATEDITEM",1096409881:"IFCSWEPTDISKSOLIDPOLYGONAL",1042787934:"IFCRESOURCETIME",1608871552:"IFCRESOURCECONSTRAINTRELATIONSHIP",2943643501:"IFCRESOURCEAPPROVALRELATIONSHIP",2090586900:"IFCQUANTITYSET",1482703590:"IFCPROPERTYTEMPLATEDEFINITION",3778827333:"IFCPREDEFINEDPROPERTIES",2998442950:"IFCMIRROREDPROFILEDEF",853536259:"IFCMATERIALRELATIONSHIP",3404854881:"IFCMATERIALPROFILESETUSAGETAPERING",3079605661:"IFCMATERIALPROFILESETUSAGE",2852063980:"IFCMATERIALCONSTITUENTSET",3708119e3:"IFCMATERIALCONSTITUENT",1585845231:"IFCLAGTIME",2133299955:"IFCINDEXEDTRIANGLETEXTUREMAP",1437953363:"IFCINDEXEDTEXTUREMAP",3570813810:"IFCINDEXEDCOLOURMAP",1437805879:"IFCEXTERNALREFERENCERELATIONSHIP",297599258:"IFCEXTENDEDPROPERTIES",211053100:"IFCEVENTTIME",2713554722:"IFCCONVERSIONBASEDUNITWITHOFFSET",3285139300:"IFCCOLOURRGBLIST",1236880293:"IFCWORKTIME",1199560280:"IFCTIMEPERIOD",3611470254:"IFCTEXTUREVERTEXLIST",2771591690:"IFCTASKTIMERECURRING",1549132990:"IFCTASKTIME",2043862942:"IFCTABLECOLUMN",2934153892:"IFCSURFACEREINFORCEMENTAREA",609421318:"IFCSTRUCTURALLOADORRESULT",3478079324:"IFCSTRUCTURALLOADCONFIGURATION",1054537805:"IFCSCHEDULINGTIME",2439245199:"IFCRESOURCELEVELRELATIONSHIP",2433181523:"IFCREFERENCE",3915482550:"IFCRECURRENCEPATTERN",986844984:"IFCPROPERTYABSTRACTION",3843373140:"IFCPROJECTEDCRS",677532197:"IFCPRESENTATIONITEM",1507914824:"IFCMATERIALUSAGEDEFINITION",552965576:"IFCMATERIALPROFILEWITHOFFSETS",164193824:"IFCMATERIALPROFILESET",2235152071:"IFCMATERIALPROFILE",1847252529:"IFCMATERIALLAYERWITHOFFSETS",760658860:"IFCMATERIALDEFINITION",3057273783:"IFCMAPCONVERSION",4294318154:"IFCEXTERNALINFORMATION",1466758467:"IFCCOORDINATEREFERENCESYSTEM",1785450214:"IFCCOORDINATEOPERATION",775493141:"IFCCONNECTIONVOLUMEGEOMETRY",979691226:"IFCREINFORCINGBAR",3700593921:"IFCELECTRICDISTRIBUTIONPOINT",1062813311:"IFCDISTRIBUTIONCONTROLELEMENT",1052013943:"IFCDISTRIBUTIONCHAMBERELEMENT",578613899:"IFCCONTROLLERTYPE",2454782716:"IFCCHAMFEREDGEFEATURE",753842376:"IFCBEAM",3001207471:"IFCALARMTYPE",2874132201:"IFCACTUATORTYPE",3304561284:"IFCWINDOW",3512223829:"IFCWALLSTANDARDCASE",2391406946:"IFCWALL",3313531582:"IFCVIBRATIONISOLATORTYPE",2347447852:"IFCTENDONANCHOR",3824725483:"IFCTENDON",2515109513:"IFCSTRUCTURALANALYSISMODEL",4252922144:"IFCSTAIRFLIGHT",331165859:"IFCSTAIR",1529196076:"IFCSLAB",1783015770:"IFCSENSORTYPE",1376911519:"IFCROUNDEDEDGEFEATURE",2016517767:"IFCROOF",2320036040:"IFCREINFORCINGMESH",3027567501:"IFCREINFORCINGELEMENT",3055160366:"IFCRATIONALBEZIERCURVE",3283111854:"IFCRAMPFLIGHT",3024970846:"IFCRAMP",2262370178:"IFCRAILING",3171933400:"IFCPLATE",1687234759:"IFCPILE",1073191201:"IFCMEMBER",900683007:"IFCFOOTING",3508470533:"IFCFLOWTREATMENTDEVICE",2223149337:"IFCFLOWTERMINAL",707683696:"IFCFLOWSTORAGEDEVICE",987401354:"IFCFLOWSEGMENT",3132237377:"IFCFLOWMOVINGDEVICE",4037862832:"IFCFLOWINSTRUMENTTYPE",4278956645:"IFCFLOWFITTING",2058353004:"IFCFLOWCONTROLLER",4222183408:"IFCFIRESUPPRESSIONTERMINALTYPE",1810631287:"IFCFILTERTYPE",346874300:"IFCFANTYPE",1658829314:"IFCENERGYCONVERSIONDEVICE",857184966:"IFCELECTRICALELEMENT",1634875225:"IFCELECTRICALCIRCUIT",712377611:"IFCELECTRICTIMECONTROLTYPE",1217240411:"IFCELECTRICMOTORTYPE",1365060375:"IFCELECTRICHEATERTYPE",1534661035:"IFCELECTRICGENERATORTYPE",3277789161:"IFCELECTRICFLOWSTORAGEDEVICETYPE",663422040:"IFCELECTRICAPPLIANCETYPE",855621170:"IFCEDGEFEATURE",2030761528:"IFCDUCTSILENCERTYPE",3760055223:"IFCDUCTSEGMENTTYPE",869906466:"IFCDUCTFITTINGTYPE",395920057:"IFCDOOR",3041715199:"IFCDISTRIBUTIONPORT",3040386961:"IFCDISTRIBUTIONFLOWELEMENT",1945004755:"IFCDISTRIBUTIONELEMENT",2063403501:"IFCDISTRIBUTIONCONTROLELEMENTTYPE",1599208980:"IFCDISTRIBUTIONCHAMBERELEMENTTYPE",2635815018:"IFCDISCRETEACCESSORYTYPE",1335981549:"IFCDISCRETEACCESSORY",4147604152:"IFCDIAMETERDIMENSION",3961806047:"IFCDAMPERTYPE",3495092785:"IFCCURTAINWALL",1973544240:"IFCCOVERING",2954562838:"IFCCOOLINGTOWERTYPE",335055490:"IFCCOOLEDBEAMTYPE",488727124:"IFCCONSTRUCTIONPRODUCTRESOURCE",1060000209:"IFCCONSTRUCTIONMATERIALRESOURCE",3898045240:"IFCCONSTRUCTIONEQUIPMENTRESOURCE",1163958913:"IFCCONDITIONCRITERION",2188551683:"IFCCONDITION",2816379211:"IFCCONDENSERTYPE",3850581409:"IFCCOMPRESSORTYPE",843113511:"IFCCOLUMN",2301859152:"IFCCOILTYPE",2611217952:"IFCCIRCLE",2951183804:"IFCCHILLERTYPE",1285652485:"IFCCABLESEGMENTTYPE",3293546465:"IFCCABLECARRIERSEGMENTTYPE",395041908:"IFCCABLECARRIERFITTINGTYPE",1909888760:"IFCBUILDINGELEMENTPROXYTYPE",1095909175:"IFCBUILDINGELEMENTPROXY",2979338954:"IFCBUILDINGELEMENTPART",52481810:"IFCBUILDINGELEMENTCOMPONENT",3299480353:"IFCBUILDINGELEMENT",231477066:"IFCBOILERTYPE",1916977116:"IFCBEZIERCURVE",819618141:"IFCBEAMTYPE",1967976161:"IFCBSPLINECURVE",3460190687:"IFCASSET",2470393545:"IFCANGULARDIMENSION",1871374353:"IFCAIRTOAIRHEATRECOVERYTYPE",3352864051:"IFCAIRTERMINALTYPE",1411407467:"IFCAIRTERMINALBOXTYPE",3821786052:"IFCACTIONREQUEST",1213861670:"IFC2DCOMPOSITECURVE",1033361043:"IFCZONE",3342526732:"IFCWORKSCHEDULE",4218914973:"IFCWORKPLAN",1028945134:"IFCWORKCONTROL",1133259667:"IFCWASTETERMINALTYPE",1898987631:"IFCWALLTYPE",2769231204:"IFCVIRTUALELEMENT",728799441:"IFCVALVETYPE",1911125066:"IFCUNITARYEQUIPMENTTYPE",1600972822:"IFCTUBEBUNDLETYPE",3593883385:"IFCTRIMMEDCURVE",1620046519:"IFCTRANSPORTELEMENT",1692211062:"IFCTRANSFORMERTYPE",1637806684:"IFCTIMESERIESSCHEDULE",5716631:"IFCTANKTYPE",2254336722:"IFCSYSTEM",2315554128:"IFCSWITCHINGDEVICETYPE",148013059:"IFCSUBCONTRACTRESOURCE",1975003073:"IFCSTRUCTURALSURFACECONNECTION",2986769608:"IFCSTRUCTURALRESULTGROUP",1235345126:"IFCSTRUCTURALPOINTREACTION",734778138:"IFCSTRUCTURALPOINTCONNECTION",2082059205:"IFCSTRUCTURALPOINTACTION",3987759626:"IFCSTRUCTURALPLANARACTIONVARYING",1621171031:"IFCSTRUCTURALPLANARACTION",1252848954:"IFCSTRUCTURALLOADGROUP",1721250024:"IFCSTRUCTURALLINEARACTIONVARYING",1807405624:"IFCSTRUCTURALLINEARACTION",2445595289:"IFCSTRUCTURALCURVEMEMBERVARYING",214636428:"IFCSTRUCTURALCURVEMEMBER",4243806635:"IFCSTRUCTURALCURVECONNECTION",1179482911:"IFCSTRUCTURALCONNECTION",682877961:"IFCSTRUCTURALACTION",1039846685:"IFCSTAIRFLIGHTTYPE",3112655638:"IFCSTACKTERMINALTYPE",3812236995:"IFCSPACETYPE",652456506:"IFCSPACEPROGRAM",1305183839:"IFCSPACEHEATERTYPE",3856911033:"IFCSPACE",2533589738:"IFCSLABTYPE",4097777520:"IFCSITE",4105383287:"IFCSERVICELIFE",3517283431:"IFCSCHEDULETIMECONTROL",1768891740:"IFCSANITARYTERMINALTYPE",2863920197:"IFCRELASSIGNSTASKS",160246688:"IFCRELAGGREGATES",2324767716:"IFCRAMPFLIGHTTYPE",2893384427:"IFCRAILINGTYPE",3248260540:"IFCRADIUSDIMENSION",2250791053:"IFCPUMPTYPE",1842657554:"IFCPROTECTIVEDEVICETYPE",3651124850:"IFCPROJECTIONELEMENT",3642467123:"IFCPROJECTORDERRECORD",2904328755:"IFCPROJECTORDER",2744685151:"IFCPROCEDURE",3740093272:"IFCPORT",3724593414:"IFCPOLYLINE",4017108033:"IFCPLATETYPE",4231323485:"IFCPIPESEGMENTTYPE",804291784:"IFCPIPEFITTINGTYPE",3327091369:"IFCPERMIT",2382730787:"IFCPERFORMANCEHISTORY",2837617999:"IFCOUTLETTYPE",3425660407:"IFCORDERACTION",3588315303:"IFCOPENINGELEMENT",4143007308:"IFCOCCUPANT",1916936684:"IFCMOVE",977012517:"IFCMOTORCONNECTIONTYPE",3181161470:"IFCMEMBERTYPE",2108223431:"IFCMECHANICALFASTENERTYPE",377706215:"IFCMECHANICALFASTENER",2506943328:"IFCLINEARDIMENSION",1161773419:"IFCLIGHTFIXTURETYPE",1051575348:"IFCLAMPTYPE",3827777499:"IFCLABORRESOURCE",4288270099:"IFCJUNCTIONBOXTYPE",2391368822:"IFCINVENTORY",1806887404:"IFCHUMIDIFIERTYPE",1251058090:"IFCHEATEXCHANGERTYPE",2706460486:"IFCGROUP",3009204131:"IFCGRID",200128114:"IFCGASTERMINALTYPE",814719939:"IFCFURNITURESTANDARD",263784265:"IFCFURNISHINGELEMENT",3009222698:"IFCFLOWTREATMENTDEVICETYPE",2297155007:"IFCFLOWTERMINALTYPE",1339347760:"IFCFLOWSTORAGEDEVICETYPE",1834744321:"IFCFLOWSEGMENTTYPE",1482959167:"IFCFLOWMOVINGDEVICETYPE",3815607619:"IFCFLOWMETERTYPE",3198132628:"IFCFLOWFITTINGTYPE",3907093117:"IFCFLOWCONTROLLERTYPE",1287392070:"IFCFEATUREELEMENTSUBTRACTION",2143335405:"IFCFEATUREELEMENTADDITION",2827207264:"IFCFEATUREELEMENT",2489546625:"IFCFASTENERTYPE",647756555:"IFCFASTENER",3737207727:"IFCFACETEDBREPWITHVOIDS",807026263:"IFCFACETEDBREP",3390157468:"IFCEVAPORATORTYPE",3174744832:"IFCEVAPORATIVECOOLERTYPE",3272907226:"IFCEQUIPMENTSTANDARD",1962604670:"IFCEQUIPMENTELEMENT",2107101300:"IFCENERGYCONVERSIONDEVICETYPE",1704287377:"IFCELLIPSE",2590856083:"IFCELEMENTCOMPONENTTYPE",1623761950:"IFCELEMENTCOMPONENT",4123344466:"IFCELEMENTASSEMBLY",1758889154:"IFCELEMENT",360485395:"IFCELECTRICALBASEPROPERTIES",3849074793:"IFCDISTRIBUTIONFLOWELEMENTTYPE",3256556792:"IFCDISTRIBUTIONELEMENTTYPE",681481545:"IFCDIMENSIONCURVEDIRECTEDCALLOUT",1457835157:"IFCCURTAINWALLTYPE",3295246426:"IFCCREWRESOURCE",1916426348:"IFCCOVERINGTYPE",1419761937:"IFCCOSTSCHEDULE",3895139033:"IFCCOSTITEM",3293443760:"IFCCONTROL",2559216714:"IFCCONSTRUCTIONRESOURCE",2510884976:"IFCCONIC",3732776249:"IFCCOMPOSITECURVE",300633059:"IFCCOLUMNTYPE",2937912522:"IFCCIRCLEHOLLOWPROFILEDEF",3124254112:"IFCBUILDINGSTOREY",1950629157:"IFCBUILDINGELEMENTTYPE",4031249490:"IFCBUILDING",1260505505:"IFCBOUNDEDCURVE",3649129432:"IFCBOOLEANCLIPPINGRESULT",1334484129:"IFCBLOCK",3207858831:"IFCASYMMETRICISHAPEPROFILEDEF",1674181508:"IFCANNOTATION",2296667514:"IFCACTOR",2097647324:"IFCTRANSPORTELEMENTTYPE",3473067441:"IFCTASK",1580310250:"IFCSYSTEMFURNITUREELEMENTTYPE",4124788165:"IFCSURFACEOFREVOLUTION",2809605785:"IFCSURFACEOFLINEAREXTRUSION",2028607225:"IFCSURFACECURVESWEPTAREASOLID",4070609034:"IFCSTRUCTUREDDIMENSIONCALLOUT",2218152070:"IFCSTRUCTURALSURFACEMEMBERVARYING",3979015343:"IFCSTRUCTURALSURFACEMEMBER",3689010777:"IFCSTRUCTURALREACTION",530289379:"IFCSTRUCTURALMEMBER",3136571912:"IFCSTRUCTURALITEM",3544373492:"IFCSTRUCTURALACTIVITY",451544542:"IFCSPHERE",3893378262:"IFCSPATIALSTRUCTUREELEMENTTYPE",2706606064:"IFCSPATIALSTRUCTUREELEMENT",3626867408:"IFCRIGHTCIRCULARCYLINDER",4158566097:"IFCRIGHTCIRCULARCONE",1856042241:"IFCREVOLVEDAREASOLID",2914609552:"IFCRESOURCE",1401173127:"IFCRELVOIDSELEMENT",3451746338:"IFCRELSPACEBOUNDARY",366585022:"IFCRELSERVICESBUILDINGS",4122056220:"IFCRELSEQUENCE",1058617721:"IFCRELSCHEDULESCOSTITEMS",1245217292:"IFCRELREFERENCEDINSPATIALSTRUCTURE",750771296:"IFCRELPROJECTSELEMENT",202636808:"IFCRELOVERRIDESPROPERTIES",2051452291:"IFCRELOCCUPIESSPACES",3268803585:"IFCRELNESTS",4189434867:"IFCRELINTERACTIONREQUIREMENTS",279856033:"IFCRELFLOWCONTROLELEMENTS",3940055652:"IFCRELFILLSELEMENT",781010003:"IFCRELDEFINESBYTYPE",4186316022:"IFCRELDEFINESBYPROPERTIES",693640335:"IFCRELDEFINES",2551354335:"IFCRELDECOMPOSES",2802773753:"IFCRELCOVERSSPACES",886880790:"IFCRELCOVERSBLDGELEMENTS",3242617779:"IFCRELCONTAINEDINSPATIALSTRUCTURE",3678494232:"IFCRELCONNECTSWITHREALIZINGELEMENTS",504942748:"IFCRELCONNECTSWITHECCENTRICITY",1638771189:"IFCRELCONNECTSSTRUCTURALMEMBER",3912681535:"IFCRELCONNECTSSTRUCTURALELEMENT",2127690289:"IFCRELCONNECTSSTRUCTURALACTIVITY",3190031847:"IFCRELCONNECTSPORTS",4201705270:"IFCRELCONNECTSPORTTOELEMENT",3945020480:"IFCRELCONNECTSPATHELEMENTS",1204542856:"IFCRELCONNECTSELEMENTS",826625072:"IFCRELCONNECTS",2851387026:"IFCRELASSOCIATESPROFILEPROPERTIES",2655215786:"IFCRELASSOCIATESMATERIAL",3840914261:"IFCRELASSOCIATESLIBRARY",982818633:"IFCRELASSOCIATESDOCUMENT",2728634034:"IFCRELASSOCIATESCONSTRAINT",919958153:"IFCRELASSOCIATESCLASSIFICATION",4095574036:"IFCRELASSOCIATESAPPROVAL",1327628568:"IFCRELASSOCIATESAPPLIEDVALUE",1865459582:"IFCRELASSOCIATES",205026976:"IFCRELASSIGNSTORESOURCE",3372526763:"IFCRELASSIGNSTOPROJECTORDER",2857406711:"IFCRELASSIGNSTOPRODUCT",4278684876:"IFCRELASSIGNSTOPROCESS",1307041759:"IFCRELASSIGNSTOGROUP",2495723537:"IFCRELASSIGNSTOCONTROL",1683148259:"IFCRELASSIGNSTOACTOR",3939117080:"IFCRELASSIGNS",3454111270:"IFCRECTANGULARTRIMMEDSURFACE",2798486643:"IFCRECTANGULARPYRAMID",2770003689:"IFCRECTANGLEHOLLOWPROFILEDEF",3219374653:"IFCPROXY",1451395588:"IFCPROPERTYSET",4194566429:"IFCPROJECTIONCURVE",103090709:"IFCPROJECT",4208778838:"IFCPRODUCT",2945172077:"IFCPROCESS",220341763:"IFCPLANE",603570806:"IFCPLANARBOX",3566463478:"IFCPERMEABLECOVERINGPROPERTIES",3505215534:"IFCOFFSETCURVE3D",3388369263:"IFCOFFSETCURVE2D",3888040117:"IFCOBJECT",1425443689:"IFCMANIFOLDSOLIDBREP",1281925730:"IFCLINE",572779678:"IFCLSHAPEPROFILEDEF",1484403080:"IFCISHAPEPROFILEDEF",987898635:"IFCGEOMETRICCURVESET",1268542332:"IFCFURNITURETYPE",4238390223:"IFCFURNISHINGELEMENTTYPE",3455213021:"IFCFLUIDFLOWPROPERTIES",315944413:"IFCFILLAREASTYLETILES",4203026998:"IFCFILLAREASTYLETILESYMBOLWITHSTYLE",374418227:"IFCFILLAREASTYLEHATCHING",2047409740:"IFCFACEBASEDSURFACEMODEL",477187591:"IFCEXTRUDEDAREASOLID",80994333:"IFCENERGYPROPERTIES",2835456948:"IFCELLIPSEPROFILEDEF",2777663545:"IFCELEMENTARYSURFACE",339256511:"IFCELEMENTTYPE",1883228015:"IFCELEMENTQUANTITY",1472233963:"IFCEDGELOOP",4006246654:"IFCDRAUGHTINGPREDEFINEDCURVEFONT",445594917:"IFCDRAUGHTINGPREDEFINEDCOLOUR",3073041342:"IFCDRAUGHTINGCALLOUT",526551008:"IFCDOORSTYLE",1714330368:"IFCDOORPANELPROPERTIES",2963535650:"IFCDOORLININGPROPERTIES",32440307:"IFCDIRECTION",4054601972:"IFCDIMENSIONCURVETERMINATOR",606661476:"IFCDIMENSIONCURVE",693772133:"IFCDEFINEDSYMBOL",2827736869:"IFCCURVEBOUNDEDPLANE",2601014836:"IFCCURVE",2147822146:"IFCCSGSOLID",2506170314:"IFCCSGPRIMITIVE3D",194851669:"IFCCRANERAILFSHAPEPROFILEDEF",4133800736:"IFCCRANERAILASHAPEPROFILEDEF",2485617015:"IFCCOMPOSITECURVESEGMENT",2205249479:"IFCCLOSEDSHELL",1383045692:"IFCCIRCLEPROFILEDEF",1416205885:"IFCCARTESIANTRANSFORMATIONOPERATOR3DNONUNIFORM",3331915920:"IFCCARTESIANTRANSFORMATIONOPERATOR3D",3486308946:"IFCCARTESIANTRANSFORMATIONOPERATOR2DNONUNIFORM",3749851601:"IFCCARTESIANTRANSFORMATIONOPERATOR2D",59481748:"IFCCARTESIANTRANSFORMATIONOPERATOR",1123145078:"IFCCARTESIANPOINT",2898889636:"IFCCSHAPEPROFILEDEF",2713105998:"IFCBOXEDHALFSPACE",2581212453:"IFCBOUNDINGBOX",4182860854:"IFCBOUNDEDSURFACE",2736907675:"IFCBOOLEANRESULT",2740243338:"IFCAXIS2PLACEMENT3D",3125803723:"IFCAXIS2PLACEMENT2D",4261334040:"IFCAXIS1PLACEMENT",1302238472:"IFCANNOTATIONSURFACE",2265737646:"IFCANNOTATIONFILLAREAOCCURRENCE",669184980:"IFCANNOTATIONFILLAREA",3288037868:"IFCANNOTATIONCURVEOCCURRENCE",2543172580:"IFCZSHAPEPROFILEDEF",1299126871:"IFCWINDOWSTYLE",512836454:"IFCWINDOWPANELPROPERTIES",336235671:"IFCWINDOWLININGPROPERTIES",2759199220:"IFCVERTEXLOOP",1417489154:"IFCVECTOR",427810014:"IFCUSHAPEPROFILEDEF",2347495698:"IFCTYPEPRODUCT",1628702193:"IFCTYPEOBJECT",1345879162:"IFCTWODIRECTIONREPEATFACTOR",2715220739:"IFCTRAPEZIUMPROFILEDEF",3124975700:"IFCTEXTLITERALWITHEXTENT",4282788508:"IFCTEXTLITERAL",3028897424:"IFCTERMINATORSYMBOL",3071757647:"IFCTSHAPEPROFILEDEF",230924584:"IFCSWEPTSURFACE",1260650574:"IFCSWEPTDISKSOLID",2247615214:"IFCSWEPTAREASOLID",1878645084:"IFCSURFACESTYLERENDERING",2513912981:"IFCSURFACE",2233826070:"IFCSUBEDGE",3653947884:"IFCSTRUCTURALSTEELPROFILEPROPERTIES",3843319758:"IFCSTRUCTURALPROFILEPROPERTIES",1190533807:"IFCSTRUCTURALLOADSINGLEFORCEWARPING",1597423693:"IFCSTRUCTURALLOADSINGLEFORCE",1973038258:"IFCSTRUCTURALLOADSINGLEDISPLACEMENTDISTORTION",2473145415:"IFCSTRUCTURALLOADSINGLEDISPLACEMENT",2668620305:"IFCSTRUCTURALLOADPLANARFORCE",1595516126:"IFCSTRUCTURALLOADLINEARFORCE",390701378:"IFCSPACETHERMALLOADPROPERTIES",1202362311:"IFCSOUNDVALUE",2485662743:"IFCSOUNDPROPERTIES",723233188:"IFCSOLIDMODEL",2609359061:"IFCSLIPPAGECONNECTIONCONDITION",4124623270:"IFCSHELLBASEDSURFACEMODEL",2411513650:"IFCSERVICELIFEFACTOR",1509187699:"IFCSECTIONEDSPINE",2778083089:"IFCROUNDEDRECTANGLEPROFILEDEF",478536968:"IFCRELATIONSHIP",3765753017:"IFCREINFORCEMENTDEFINITIONPROPERTIES",3413951693:"IFCREGULARTIMESERIES",3615266464:"IFCRECTANGLEPROFILEDEF",110355661:"IFCPROPERTYTABLEVALUE",3650150729:"IFCPROPERTYSINGLEVALUE",3357820518:"IFCPROPERTYSETDEFINITION",941946838:"IFCPROPERTYREFERENCEVALUE",2752243245:"IFCPROPERTYLISTVALUE",4166981789:"IFCPROPERTYENUMERATEDVALUE",1680319473:"IFCPROPERTYDEFINITION",871118103:"IFCPROPERTYBOUNDEDVALUE",673634403:"IFCPRODUCTDEFINITIONSHAPE",179317114:"IFCPREDEFINEDPOINTMARKERSYMBOL",433424934:"IFCPREDEFINEDDIMENSIONSYMBOL",2559016684:"IFCPREDEFINEDCURVEFONT",759155922:"IFCPREDEFINEDCOLOUR",2775532180:"IFCPOLYGONALBOUNDEDHALFSPACE",2924175390:"IFCPOLYLOOP",1423911732:"IFCPOINTONSURFACE",4022376103:"IFCPOINTONCURVE",2067069095:"IFCPOINT",1663979128:"IFCPLANAREXTENT",2004835150:"IFCPLACEMENT",597895409:"IFCPIXELTEXTURE",3021840470:"IFCPHYSICALCOMPLEXQUANTITY",2519244187:"IFCPATH",2529465313:"IFCPARAMETERIZEDPROFILEDEF",1029017970:"IFCORIENTEDEDGE",2665983363:"IFCOPENSHELL",2833995503:"IFCONEDIRECTIONREPEATFACTOR",219451334:"IFCOBJECTDEFINITION",1430189142:"IFCMECHANICALCONCRETEMATERIALPROPERTIES",2022407955:"IFCMATERIALDEFINITIONREPRESENTATION",2347385850:"IFCMAPPEDITEM",1008929658:"IFCLOOP",2624227202:"IFCLOCALPLACEMENT",3422422726:"IFCLIGHTSOURCESPOT",1520743889:"IFCLIGHTSOURCEPOSITIONAL",4266656042:"IFCLIGHTSOURCEGONIOMETRIC",2604431987:"IFCLIGHTSOURCEDIRECTIONAL",125510826:"IFCLIGHTSOURCEAMBIENT",1402838566:"IFCLIGHTSOURCE",3741457305:"IFCIRREGULARTIMESERIES",3905492369:"IFCIMAGETEXTURE",2445078500:"IFCHYGROSCOPICMATERIALPROPERTIES",812098782:"IFCHALFSPACESOLID",178086475:"IFCGRIDPLACEMENT",3590301190:"IFCGEOMETRICSET",4142052618:"IFCGEOMETRICREPRESENTATIONSUBCONTEXT",2453401579:"IFCGEOMETRICREPRESENTATIONITEM",3448662350:"IFCGEOMETRICREPRESENTATIONCONTEXT",1446786286:"IFCGENERALPROFILEPROPERTIES",803998398:"IFCGENERALMATERIALPROPERTIES",3857492461:"IFCFUELPROPERTIES",738692330:"IFCFILLAREASTYLE",4219587988:"IFCFAILURECONNECTIONCONDITION",3008276851:"IFCFACESURFACE",803316827:"IFCFACEOUTERBOUND",1809719519:"IFCFACEBOUND",2556980723:"IFCFACE",1860660968:"IFCEXTENDEDMATERIALPROPERTIES",476780140:"IFCEDGECURVE",3900360178:"IFCEDGE",4170525392:"IFCDRAUGHTINGPREDEFINEDTEXTFONT",3732053477:"IFCDOCUMENTREFERENCE",1694125774:"IFCDIMENSIONPAIR",2273265877:"IFCDIMENSIONCALLOUTRELATIONSHIP",3632507154:"IFCDERIVEDPROFILEDEF",3800577675:"IFCCURVESTYLE",2889183280:"IFCCONVERSIONBASEDUNIT",3050246964:"IFCCONTEXTDEPENDENTUNIT",45288368:"IFCCONNECTIONPOINTECCENTRICITY",1981873012:"IFCCONNECTIONCURVEGEOMETRY",370225590:"IFCCONNECTEDFACESET",1485152156:"IFCCOMPOSITEPROFILEDEF",2542286263:"IFCCOMPLEXPROPERTY",776857604:"IFCCOLOURRGB",647927063:"IFCCLASSIFICATIONREFERENCE",3150382593:"IFCCENTERLINEPROFILEDEF",616511568:"IFCBLOBTEXTURE",2705031697:"IFCARBITRARYPROFILEDEFWITHVOIDS",1310608509:"IFCARBITRARYOPENPROFILEDEF",3798115385:"IFCARBITRARYCLOSEDPROFILEDEF",2297822566:"IFCANNOTATIONTEXTOCCURRENCE",3612888222:"IFCANNOTATIONSYMBOLOCCURRENCE",962685235:"IFCANNOTATIONSURFACEOCCURRENCE",2442683028:"IFCANNOTATIONOCCURRENCE",1065908215:"IFCWATERPROPERTIES",891718957:"IFCVIRTUALGRIDINTERSECTION",1907098498:"IFCVERTEXPOINT",3304826586:"IFCVERTEXBASEDTEXTUREMAP",2799835756:"IFCVERTEX",180925521:"IFCUNITASSIGNMENT",1735638870:"IFCTOPOLOGYREPRESENTATION",1377556343:"IFCTOPOLOGICALREPRESENTATIONITEM",581633288:"IFCTIMESERIESVALUE",1718945513:"IFCTIMESERIESREFERENCERELATIONSHIP",3101149627:"IFCTIMESERIES",3317419933:"IFCTHERMALMATERIALPROPERTIES",1210645708:"IFCTEXTUREVERTEX",2552916305:"IFCTEXTUREMAP",1742049831:"IFCTEXTURECOORDINATEGENERATOR",280115917:"IFCTEXTURECOORDINATE",1484833681:"IFCTEXTSTYLEWITHBOXCHARACTERISTICS",1640371178:"IFCTEXTSTYLETEXTMODEL",2636378356:"IFCTEXTSTYLEFORDEFINEDFONT",1983826977:"IFCTEXTSTYLEFONTMODEL",1447204868:"IFCTEXTSTYLE",912023232:"IFCTELECOMADDRESS",531007025:"IFCTABLEROW",985171141:"IFCTABLE",1290481447:"IFCSYMBOLSTYLE",626085974:"IFCSURFACETEXTURE",1351298697:"IFCSURFACESTYLEWITHTEXTURES",846575682:"IFCSURFACESTYLESHADING",1607154358:"IFCSURFACESTYLEREFRACTION",3303107099:"IFCSURFACESTYLELIGHTING",1300840506:"IFCSURFACESTYLE",3049322572:"IFCSTYLEDREPRESENTATION",3958052878:"IFCSTYLEDITEM",2830218821:"IFCSTYLEMODEL",3408363356:"IFCSTRUCTURALLOADTEMPERATURE",2525727697:"IFCSTRUCTURALLOADSTATIC",2162789131:"IFCSTRUCTURALLOAD",2273995522:"IFCSTRUCTURALCONNECTIONCONDITION",3692461612:"IFCSIMPLEPROPERTY",4240577450:"IFCSHAPEREPRESENTATION",3982875396:"IFCSHAPEMODEL",867548509:"IFCSHAPEASPECT",4165799628:"IFCSECTIONREINFORCEMENTPROPERTIES",2042790032:"IFCSECTIONPROPERTIES",448429030:"IFCSIUNIT",2341007311:"IFCROOT",3679540991:"IFCRIBPLATEPROFILEPROPERTIES",1660063152:"IFCREPRESENTATIONMAP",3008791417:"IFCREPRESENTATIONITEM",3377609919:"IFCREPRESENTATIONCONTEXT",1076942058:"IFCREPRESENTATION",1222501353:"IFCRELAXATION",1580146022:"IFCREINFORCEMENTBARPROPERTIES",2692823254:"IFCREFERENCESVALUEDOCUMENT",825690147:"IFCQUANTITYWEIGHT",2405470396:"IFCQUANTITYVOLUME",3252649465:"IFCQUANTITYTIME",931644368:"IFCQUANTITYLENGTH",2093928680:"IFCQUANTITYCOUNT",2044713172:"IFCQUANTITYAREA",3710013099:"IFCPROPERTYENUMERATION",148025276:"IFCPROPERTYDEPENDENCYRELATIONSHIP",3896028662:"IFCPROPERTYCONSTRAINTRELATIONSHIP",2598011224:"IFCPROPERTY",2802850158:"IFCPROFILEPROPERTIES",3958567839:"IFCPROFILEDEF",2267347899:"IFCPRODUCTSOFCOMBUSTIONPROPERTIES",2095639259:"IFCPRODUCTREPRESENTATION",2417041796:"IFCPRESENTATIONSTYLEASSIGNMENT",3119450353:"IFCPRESENTATIONSTYLE",1304840413:"IFCPRESENTATIONLAYERWITHSTYLE",2022622350:"IFCPRESENTATIONLAYERASSIGNMENT",1775413392:"IFCPREDEFINEDTEXTFONT",3213052703:"IFCPREDEFINEDTERMINATORSYMBOL",990879717:"IFCPREDEFINEDSYMBOL",3727388367:"IFCPREDEFINEDITEM",3355820592:"IFCPOSTALADDRESS",2226359599:"IFCPHYSICALSIMPLEQUANTITY",2483315170:"IFCPHYSICALQUANTITY",101040310:"IFCPERSONANDORGANIZATION",2077209135:"IFCPERSON",1207048766:"IFCOWNERHISTORY",1411181986:"IFCORGANIZATIONRELATIONSHIP",4251960020:"IFCORGANIZATION",1227763645:"IFCOPTICALMATERIALPROPERTIES",2251480897:"IFCOBJECTIVE",3701648758:"IFCOBJECTPLACEMENT",1918398963:"IFCNAMEDUNIT",2706619895:"IFCMONETARYUNIT",3368373690:"IFCMETRIC",677618848:"IFCMECHANICALSTEELMATERIALPROPERTIES",4256014907:"IFCMECHANICALMATERIALPROPERTIES",2597039031:"IFCMEASUREWITHUNIT",3265635763:"IFCMATERIALPROPERTIES",2199411900:"IFCMATERIALLIST",1303795690:"IFCMATERIALLAYERSETUSAGE",3303938423:"IFCMATERIALLAYERSET",248100487:"IFCMATERIALLAYER",1847130766:"IFCMATERIALCLASSIFICATIONRELATIONSHIP",1838606355:"IFCMATERIAL",30780891:"IFCLOCALTIME",1566485204:"IFCLIGHTINTENSITYDISTRIBUTION",4162380809:"IFCLIGHTDISTRIBUTIONDATA",3452421091:"IFCLIBRARYREFERENCE",2655187982:"IFCLIBRARYINFORMATION",3020489413:"IFCIRREGULARTIMESERIESVALUE",852622518:"IFCGRIDAXIS",3548104201:"IFCEXTERNALLYDEFINEDTEXTFONT",3207319532:"IFCEXTERNALLYDEFINEDSYMBOL",1040185647:"IFCEXTERNALLYDEFINEDSURFACESTYLE",2242383968:"IFCEXTERNALLYDEFINEDHATCHSTYLE",3200245327:"IFCEXTERNALREFERENCE",1648886627:"IFCENVIRONMENTALIMPACTVALUE",3796139169:"IFCDRAUGHTINGCALLOUTRELATIONSHIP",770865208:"IFCDOCUMENTINFORMATIONRELATIONSHIP",1154170062:"IFCDOCUMENTINFORMATION",1376555844:"IFCDOCUMENTELECTRONICFORMAT",2949456006:"IFCDIMENSIONALEXPONENTS",1045800335:"IFCDERIVEDUNITELEMENT",1765591967:"IFCDERIVEDUNIT",1072939445:"IFCDATEANDTIME",3510044353:"IFCCURVESTYLEFONTPATTERN",2367409068:"IFCCURVESTYLEFONTANDSCALING",1105321065:"IFCCURVESTYLEFONT",539742890:"IFCCURRENCYRELATIONSHIP",602808272:"IFCCOSTVALUE",1065062679:"IFCCOORDINATEDUNIVERSALTIMEOFFSET",347226245:"IFCCONSTRAINTRELATIONSHIP",613356794:"IFCCONSTRAINTCLASSIFICATIONRELATIONSHIP",1658513725:"IFCCONSTRAINTAGGREGATIONRELATIONSHIP",1959218052:"IFCCONSTRAINT",2732653382:"IFCCONNECTIONSURFACEGEOMETRY",4257277454:"IFCCONNECTIONPORTGEOMETRY",2614616156:"IFCCONNECTIONPOINTGEOMETRY",2859738748:"IFCCONNECTIONGEOMETRY",3264961684:"IFCCOLOURSPECIFICATION",3639012971:"IFCCLASSIFICATIONNOTATIONFACET",938368621:"IFCCLASSIFICATIONNOTATION",1098599126:"IFCCLASSIFICATIONITEMRELATIONSHIP",1767535486:"IFCCLASSIFICATIONITEM",747523909:"IFCCLASSIFICATION",622194075:"IFCCALENDARDATE",2069777674:"IFCBOUNDARYNODECONDITIONWARPING",1387855156:"IFCBOUNDARYNODECONDITION",3367102660:"IFCBOUNDARYFACECONDITION",1560379544:"IFCBOUNDARYEDGECONDITION",4037036970:"IFCBOUNDARYCONDITION",3869604511:"IFCAPPROVALRELATIONSHIP",390851274:"IFCAPPROVALPROPERTYRELATIONSHIP",2080292479:"IFCAPPROVALACTORRELATIONSHIP",130549933:"IFCAPPROVAL",1110488051:"IFCAPPLIEDVALUERELATIONSHIP",411424972:"IFCAPPLIEDVALUE",639542469:"IFCAPPLICATION",618182010:"IFCADDRESS",3630933823:"IFCACTORROLE",599546466:"FILE_DESCRIPTION",1390159747:"FILE_NAME",1109904537:"FILE_SCHEMA"};class zr{static async getUnits(e){var t,i,s;const{IFCUNITASSIGNMENT:n}=x,r=await e.getAllPropertiesOfType(n);if(!r)return 1;const o=Object.keys(r),a=r[parseInt(o[0],10)];for(const n of a.Units){if(void 0===n.value||null===n.value)continue;const r=await e.getProperties(n.value);if(!r||!r.UnitType||!r.UnitType.value)continue;if("LENGTHUNIT"!==r.UnitType.value)continue;let o=1,a=1;return"METRE"===r.Name.value&&(a=1),"FOOT"===r.Name.value&&(a=.3048),"MILLI"===(null==(t=r.Prefix)?void 0:t.value)?o=.001:"CENTI"===(null==(i=r.Prefix)?void 0:i.value)?o=.01:"DECI"===(null==(s=r.Prefix)?void 0:s.value)&&(o=.1),a*o}return 1}static async findItemByGuid(e,t){var i;const s=e.getAllPropertiesIDs();for(const n of s){const s=await e.getProperties(n);if(s&&(null==(i=s.GlobalId)?void 0:i.value)===t)return s}return null}static async getRelationMap(e,t,i){var s;const n=i??(async()=>{}),r={},o=e.getAllPropertiesIDs();for(const i of o){const o=await e.getProperties(i);if(!o)continue;const a=o.type===t,c=Object.keys(o).find((e=>e.startsWith("Relating"))),l=Object.keys(o).find((e=>e.startsWith("Related")));if(!(a&&c&&l))continue;const h=await e.getProperties(null==(s=o[c])?void 0:s.value),u=o[l];if(!h||!u)continue;if(!u||!Array.isArray(u))continue;const I=u.map((e=>e.value));await n(h.expressID,I),r[h.expressID]=I}return r}static async getQsetQuantities(e,t,i){const s=i??(()=>{}),n=await e.getProperties(t);if(!n||n.type!==x.IFCELEMENTQUANTITY)return null;return(n.Quantities??[{}]).map((e=>(e.value&&s(e.value),e.value))).filter((e=>null!==e))}static async getPsetProps(e,t,i){const s=i??(()=>{}),n=await e.getProperties(t);if(!n||n.type!==x.IFCPROPERTYSET)return null;return(n.HasProperties??[{}]).map((e=>(e.value&&s(e.value),e.value))).filter((e=>null!==e))}static async getPsetRel(e,t){var i;if(!await e.getProperties(t))return null;const s=await e.getAllPropertiesOfType(x.IFCRELDEFINESBYPROPERTIES);if(!s)return null;const n=Object.values(s);let r=null;for(const e of n)(null==(i=e.RelatingPropertyDefinition)?void 0:i.value)===t&&(r=e.expressID);return r}static async getQsetRel(e,t){return zr.getPsetRel(e,t)}static async getEntityName(e,t){var i;const s=await e.getProperties(t);if(!s)return{key:null,name:null};const n=Object.keys(s).find((e=>e.endsWith("Name")))??null;return{key:n,name:n?null==(i=s[n])?void 0:i.value:null}}static async getQuantityValue(e,t){const i=await e.getProperties(t);if(!i)return{key:null,value:null};const s=Object.keys(i).find((e=>e.endsWith("Value")))??null;let n;return n=null===s||void 0===i[s]||null===i[s]?null:i[s].value,{key:s,value:n}}static isRel(e){return Gr[e].startsWith("IFCREL")}static async attributeExists(e,t,i){const s=await e.getProperties(t);return!!s&&Object.keys(s).includes(i)}static async groupEntitiesByType(e,t){var i;const s=new Map;for(const n of t){const t=await e.getProperties(n);if(!t)continue;const r=t.type;s.get(r)||s.set(r,new Set),null==(i=s.get(r))||i.add(n)}return s}}const kr={IFCURIREFERENCE:"IfcUriReference",IFCTIME:"IfcTime",IFCTEMPERATURERATEOFCHANGEMEASURE:"IfcTemperatureRateOfChangeMeasure",IFCSOUNDPRESSURELEVELMEASURE:"IfcSoundPressureLevelMeasure",IFCSOUNDPOWERLEVELMEASURE:"IfcSoundPowerLevelMeasure",IFCPROPERTYSETDEFINITIONSET:"IfcPropertySetDefinitionSet",IFCPOSITIVEINTEGER:"IfcPositiveInteger",IFCNONNEGATIVELENGTHMEASURE:"IfcNonNegativeLengthMeasure",IFCLINEINDEX:"IfcLineIndex",IFCLANGUAGEID:"IfcLanguageId",IFCDURATION:"IfcDuration",IFCDAYINWEEKNUMBER:"IfcDayInWeekNumber",IFCDATETIME:"IfcDateTime",IFCDATE:"IfcDate",IFCCARDINALPOINTREFERENCE:"IfcCardinalPointReference",IFCBINARY:"IfcBinary",IFCAREADENSITYMEASURE:"IfcAreaDensityMeasure",IFCARCINDEX:"IfcArcIndex",IFCYEARNUMBER:"IfcYearNumber",IFCWARPINGMOMENTMEASURE:"IfcWarpingMomentMeasure",IFCWARPINGCONSTANTMEASURE:"IfcWarpingConstantMeasure",IFCVOLUMETRICFLOWRATEMEASURE:"IfcVolumetricFlowRateMeasure",IFCVOLUMEMEASURE:"IfcVolumeMeasure",IFCVAPORPERMEABILITYMEASURE:"IfcVaporPermeabilityMeasure",IFCTORQUEMEASURE:"IfcTorqueMeasure",IFCTIMESTAMP:"IfcTimestamp",IFCTIMEMEASURE:"IfcTimeMeasure",IFCTHERMODYNAMICTEMPERATUREMEASURE:"IfcThermodynamicTemperatureMeasure",IFCTHERMALTRANSMITTANCEMEASURE:"IfcThermalTransmittanceMeasure",IFCTHERMALRESISTANCEMEASURE:"IfcThermalResistanceMeasure",IFCTHERMALEXPANSIONCOEFFICIENTMEASURE:"IfcThermalExpansionCoefficientMeasure",IFCTHERMALCONDUCTIVITYMEASURE:"IfcThermalConductivityMeasure",IFCTHERMALADMITTANCEMEASURE:"IfcThermalAdmittanceMeasure",IFCTEXTTRANSFORMATION:"IfcTextTransformation",IFCTEXTFONTNAME:"IfcTextFontName",IFCTEXTDECORATION:"IfcTextDecoration",IFCTEXTALIGNMENT:"IfcTextAlignment",IFCTEXT:"IfcText",IFCTEMPERATUREGRADIENTMEASURE:"IfcTemperatureGradientMeasure",IFCSPECULARROUGHNESS:"IfcSpecularRoughness",IFCSPECULAREXPONENT:"IfcSpecularExponent",IFCSPECIFICHEATCAPACITYMEASURE:"IfcSpecificHeatCapacityMeasure",IFCSOUNDPRESSUREMEASURE:"IfcSoundPressureMeasure",IFCSOUNDPOWERMEASURE:"IfcSoundPowerMeasure",IFCSOLIDANGLEMEASURE:"IfcSolidAngleMeasure",IFCSHEARMODULUSMEASURE:"IfcShearModulusMeasure",IFCSECTIONALAREAINTEGRALMEASURE:"IfcSectionalAreaIntegralMeasure",IFCSECTIONMODULUSMEASURE:"IfcSectionModulusMeasure",IFCSECONDINMINUTE:"IfcSecondInMinute",IFCROTATIONALSTIFFNESSMEASURE:"IfcRotationalStiffnessMeasure",IFCROTATIONALMASSMEASURE:"IfcRotationalMassMeasure",IFCROTATIONALFREQUENCYMEASURE:"IfcRotationalFrequencyMeasure",IFCREAL:"IfcReal",IFCRATIOMEASURE:"IfcRatioMeasure",IFCRADIOACTIVITYMEASURE:"IfcRadioactivityMeasure",IFCPRESSUREMEASURE:"IfcPressureMeasure",IFCPRESENTABLETEXT:"IfcPresentableText",IFCPOWERMEASURE:"IfcPowerMeasure",IFCPOSITIVERATIOMEASURE:"IfcPositiveRatioMeasure",IFCPOSITIVEPLANEANGLEMEASURE:"IfcPositivePlaneAngleMeasure",IFCPOSITIVELENGTHMEASURE:"IfcPositiveLengthMeasure",IFCPLANEANGLEMEASURE:"IfcPlaneAngleMeasure",IFCPLANARFORCEMEASURE:"IfcPlanarForceMeasure",IFCPARAMETERVALUE:"IfcParameterValue",IFCPHMEASURE:"IfcPhMeasure",IFCNUMERICMEASURE:"IfcNumericMeasure",IFCNORMALISEDRATIOMEASURE:"IfcNormalisedRatioMeasure",IFCMONTHINYEARNUMBER:"IfcMonthInYearNumber",IFCMONETARYMEASURE:"IfcMonetaryMeasure",IFCMOMENTOFINERTIAMEASURE:"IfcMomentOfInertiaMeasure",IFCMOLECULARWEIGHTMEASURE:"IfcMolecularWeightMeasure",IFCMOISTUREDIFFUSIVITYMEASURE:"IfcMoistureDiffusivityMeasure",IFCMODULUSOFSUBGRADEREACTIONMEASURE:"IfcModulusOfSubgradeReactionMeasure",IFCMODULUSOFROTATIONALSUBGRADEREACTIONMEASURE:"IfcModulusOfRotationalSubgradeReactionMeasure",IFCMODULUSOFLINEARSUBGRADEREACTIONMEASURE:"IfcModulusOfLinearSubgradeReactionMeasure",IFCMODULUSOFELASTICITYMEASURE:"IfcModulusOfElasticityMeasure",IFCMINUTEINHOUR:"IfcMinuteInHour",IFCMASSPERLENGTHMEASURE:"IfcMassPerLengthMeasure",IFCMASSMEASURE:"IfcMassMeasure",IFCMASSFLOWRATEMEASURE:"IfcMassFlowRateMeasure",IFCMASSDENSITYMEASURE:"IfcMassDensityMeasure",IFCMAGNETICFLUXMEASURE:"IfcMagneticFluxMeasure",IFCMAGNETICFLUXDENSITYMEASURE:"IfcMagneticFluxDensityMeasure",IFCLUMINOUSINTENSITYMEASURE:"IfcLuminousIntensityMeasure",IFCLUMINOUSINTENSITYDISTRIBUTIONMEASURE:"IfcLuminousIntensityDistributionMeasure",IFCLUMINOUSFLUXMEASURE:"IfcLuminousFluxMeasure",IFCLOGICAL:"IfcLogical",IFCLINEARVELOCITYMEASURE:"IfcLinearVelocityMeasure",IFCLINEARSTIFFNESSMEASURE:"IfcLinearStiffnessMeasure",IFCLINEARMOMENTMEASURE:"IfcLinearMomentMeasure",IFCLINEARFORCEMEASURE:"IfcLinearForceMeasure",IFCLENGTHMEASURE:"IfcLengthMeasure",IFCLABEL:"IfcLabel",IFCKINEMATICVISCOSITYMEASURE:"IfcKinematicViscosityMeasure",IFCISOTHERMALMOISTURECAPACITYMEASURE:"IfcIsothermalMoistureCapacityMeasure",IFCIONCONCENTRATIONMEASURE:"IfcIonConcentrationMeasure",IFCINTEGERCOUNTRATEMEASURE:"IfcIntegerCountRateMeasure",IFCINTEGER:"IfcInteger",IFCINDUCTANCEMEASURE:"IfcInductanceMeasure",IFCILLUMINANCEMEASURE:"IfcIlluminanceMeasure",IFCIDENTIFIER:"IfcIdentifier",IFCHOURINDAY:"IfcHourInDay",IFCHEATINGVALUEMEASURE:"IfcHeatingValueMeasure",IFCHEATFLUXDENSITYMEASURE:"IfcHeatFluxDensityMeasure",IFCGLOBALLYUNIQUEID:"IfcGloballyUniqueId",IFCFREQUENCYMEASURE:"IfcFrequencyMeasure",IFCFORCEMEASURE:"IfcForceMeasure",IFCFONTWEIGHT:"IfcFontWeight",IFCFONTVARIANT:"IfcFontVariant",IFCFONTSTYLE:"IfcFontStyle",IFCENERGYMEASURE:"IfcEnergyMeasure",IFCELECTRICVOLTAGEMEASURE:"IfcElectricVoltageMeasure",IFCELECTRICRESISTANCEMEASURE:"IfcElectricResistanceMeasure",IFCELECTRICCURRENTMEASURE:"IfcElectricCurrentMeasure",IFCELECTRICCONDUCTANCEMEASURE:"IfcElectricConductanceMeasure",IFCELECTRICCHARGEMEASURE:"IfcElectricChargeMeasure",IFCELECTRICCAPACITANCEMEASURE:"IfcElectricCapacitanceMeasure",IFCDYNAMICVISCOSITYMEASURE:"IfcDynamicViscosityMeasure",IFCDOSEEQUIVALENTMEASURE:"IfcDoseEquivalentMeasure",IFCDIMENSIONCOUNT:"IfcDimensionCount",IFCDESCRIPTIVEMEASURE:"IfcDescriptiveMeasure",IFCDAYLIGHTSAVINGHOUR:"IfcDaylightSavingHour",IFCDAYINMONTHNUMBER:"IfcDayInMonthNumber",IFCCURVATUREMEASURE:"IfcCurvatureMeasure",IFCCOUNTMEASURE:"IfcCountMeasure",IFCCONTEXTDEPENDENTMEASURE:"IfcContextDependentMeasure",IFCCOMPOUNDPLANEANGLEMEASURE:"IfcCompoundPlaneAngleMeasure",IFCCOMPLEXNUMBER:"IfcComplexNumber",IFCBOXALIGNMENT:"IfcBoxAlignment",IFCBOOLEAN:"IfcBoolean",IFCAREAMEASURE:"IfcAreaMeasure",IFCANGULARVELOCITYMEASURE:"IfcAngularVelocityMeasure",IFCAMOUNTOFSUBSTANCEMEASURE:"IfcAmountOfSubstanceMeasure",IFCACCELERATIONMEASURE:"IfcAccelerationMeasure",IFCABSORBEDDOSEMEASURE:"IfcAbsorbedDoseMeasure",IFCGEOSLICE:"IfcGeoSlice",IFCGEOMODEL:"IfcGeoModel",IFCELECTRICFLOWTREATMENTDEVICE:"IfcElectricFlowTreatmentDevice",IFCDISTRIBUTIONBOARD:"IfcDistributionBoard",IFCCONVEYORSEGMENT:"IfcConveyorSegment",IFCCAISSONFOUNDATION:"IfcCaissonFoundation",IFCBOREHOLE:"IfcBorehole",IFCBEARING:"IfcBearing",IFCALIGNMENT:"IfcAlignment",IFCTRACKELEMENT:"IfcTrackElement",IFCSIGNAL:"IfcSignal",IFCREINFORCEDSOIL:"IfcReinforcedSoil",IFCRAIL:"IfcRail",IFCPAVEMENT:"IfcPavement",IFCNAVIGATIONELEMENT:"IfcNavigationElement",IFCMOORINGDEVICE:"IfcMooringDevice",IFCMOBILETELECOMMUNICATIONSAPPLIANCE:"IfcMobileTelecommunicationsAppliance",IFCLIQUIDTERMINAL:"IfcLiquidTerminal",IFCLINEARPOSITIONINGELEMENT:"IfcLinearPositioningElement",IFCKERB:"IfcKerb",IFCGEOTECHNICALASSEMBLY:"IfcGeotechnicalAssembly",IFCELECTRICFLOWTREATMENTDEVICETYPE:"IfcElectricFlowTreatmentDeviceType",IFCEARTHWORKSFILL:"IfcEarthworksFill",IFCEARTHWORKSELEMENT:"IfcEarthworksElement",IFCEARTHWORKSCUT:"IfcEarthworksCut",IFCDISTRIBUTIONBOARDTYPE:"IfcDistributionBoardType",IFCDEEPFOUNDATION:"IfcDeepFoundation",IFCCOURSE:"IfcCourse",IFCCONVEYORSEGMENTTYPE:"IfcConveyorSegmentType",IFCCAISSONFOUNDATIONTYPE:"IfcCaissonFoundationType",IFCBUILTSYSTEM:"IfcBuiltSystem",IFCBUILTELEMENT:"IfcBuiltElement",IFCBRIDGEPART:"IfcBridgePart",IFCBRIDGE:"IfcBridge",IFCBEARINGTYPE:"IfcBearingType",IFCALIGNMENTVERTICAL:"IfcAlignmentVertical",IFCALIGNMENTSEGMENT:"IfcAlignmentSegment",IFCALIGNMENTHORIZONTAL:"IfcAlignmentHorizontal",IFCALIGNMENTCANT:"IfcAlignmentCant",IFCVIBRATIONDAMPERTYPE:"IfcVibrationDamperType",IFCVIBRATIONDAMPER:"IfcVibrationDamper",IFCVEHICLE:"IfcVehicle",IFCTRANSPORTATIONDEVICE:"IfcTransportationDevice",IFCTRACKELEMENTTYPE:"IfcTrackElementType",IFCTENDONCONDUITTYPE:"IfcTendonConduitType",IFCTENDONCONDUIT:"IfcTendonConduit",IFCSINESPIRAL:"IfcSineSpiral",IFCSIGNALTYPE:"IfcSignalType",IFCSIGNTYPE:"IfcSignType",IFCSIGN:"IfcSign",IFCSEVENTHORDERPOLYNOMIALSPIRAL:"IfcSeventhOrderPolynomialSpiral",IFCSEGMENTEDREFERENCECURVE:"IfcSegmentedReferenceCurve",IFCSECONDORDERPOLYNOMIALSPIRAL:"IfcSecondOrderPolynomialSpiral",IFCROADPART:"IfcRoadPart",IFCROAD:"IfcRoad",IFCRELADHERESTOELEMENT:"IfcRelAdheresToElement",IFCREFERENT:"IfcReferent",IFCRAILWAYPART:"IfcRailwayPart",IFCRAILWAY:"IfcRailway",IFCRAILTYPE:"IfcRailType",IFCPOSITIONINGELEMENT:"IfcPositioningElement",IFCPAVEMENTTYPE:"IfcPavementType",IFCNAVIGATIONELEMENTTYPE:"IfcNavigationElementType",IFCMOORINGDEVICETYPE:"IfcMooringDeviceType",IFCMOBILETELECOMMUNICATIONSAPPLIANCETYPE:"IfcMobileTelecommunicationsApplianceType",IFCMARINEPART:"IfcMarinePart",IFCMARINEFACILITY:"IfcMarineFacility",IFCLIQUIDTERMINALTYPE:"IfcLiquidTerminalType",IFCLINEARELEMENT:"IfcLinearElement",IFCKERBTYPE:"IfcKerbType",IFCIMPACTPROTECTIONDEVICETYPE:"IfcImpactProtectionDeviceType",IFCIMPACTPROTECTIONDEVICE:"IfcImpactProtectionDevice",IFCGRADIENTCURVE:"IfcGradientCurve",IFCGEOTECHNICALSTRATUM:"IfcGeotechnicalStratum",IFCGEOTECHNICALELEMENT:"IfcGeotechnicalElement",IFCFACILITYPARTCOMMON:"IfcFacilityPartCommon",IFCFACILITYPART:"IfcFacilityPart",IFCFACILITY:"IfcFacility",IFCDIRECTRIXDERIVEDREFERENCESWEPTAREASOLID:"IfcDirectrixDerivedReferenceSweptAreaSolid",IFCDEEPFOUNDATIONTYPE:"IfcDeepFoundationType",IFCCOURSETYPE:"IfcCourseType",IFCCOSINESPIRAL:"IfcCosineSpiral",IFCCLOTHOID:"IfcClothoid",IFCBUILTELEMENTTYPE:"IfcBuiltElementType",IFCVEHICLETYPE:"IfcVehicleType",IFCTRIANGULATEDIRREGULARNETWORK:"IfcTriangulatedIrregularNetwork",IFCTRANSPORTATIONDEVICETYPE:"IfcTransportationDeviceType",IFCTHIRDORDERPOLYNOMIALSPIRAL:"IfcThirdOrderPolynomialSpiral",IFCSPIRAL:"IfcSpiral",IFCSECTIONEDSURFACE:"IfcSectionedSurface",IFCSECTIONEDSOLIDHORIZONTAL:"IfcSectionedSolidHorizontal",IFCSECTIONEDSOLID:"IfcSectionedSolid",IFCRELPOSITIONS:"IfcRelPositions",IFCRELASSOCIATESPROFILEDEF:"IfcRelAssociatesProfileDef",IFCPOLYNOMIALCURVE:"IfcPolynomialCurve",IFCOFFSETCURVEBYDISTANCES:"IfcOffsetCurveByDistances",IFCOFFSETCURVE:"IfcOffsetCurve",IFCINDEXEDPOLYGONALTEXTUREMAP:"IfcIndexedPolygonalTextureMap",IFCDIRECTRIXCURVESWEPTAREASOLID:"IfcDirectrixCurveSweptAreaSolid",IFCCURVESEGMENT:"IfcCurveSegment",IFCAXIS2PLACEMENTLINEAR:"IfcAxis2PlacementLinear",IFCSEGMENT:"IfcSegment",IFCPOINTBYDISTANCEEXPRESSION:"IfcPointByDistanceExpression",IFCOPENCROSSPROFILEDEF:"IfcOpenCrossProfileDef",IFCLINEARPLACEMENT:"IfcLinearPlacement",IFCALIGNMENTHORIZONTALSEGMENT:"IfcAlignmentHorizontalSegment",IFCALIGNMENTCANTSEGMENT:"IfcAlignmentCantSegment",IFCTEXTURECOORDINATEINDICESWITHVOIDS:"IfcTextureCoordinateIndicesWithVoids",IFCTEXTURECOORDINATEINDICES:"IfcTextureCoordinateIndices",IFCQUANTITYNUMBER:"IfcQuantityNumber",IFCALIGNMENTVERTICALSEGMENT:"IfcAlignmentVerticalSegment",IFCALIGNMENTPARAMETERSEGMENT:"IfcAlignmentParameterSegment",IFCCONTROLLER:"IfcController",IFCALARM:"IfcAlarm",IFCACTUATOR:"IfcActuator",IFCUNITARYCONTROLELEMENT:"IfcUnitaryControlElement",IFCSENSOR:"IfcSensor",IFCPROTECTIVEDEVICETRIPPINGUNIT:"IfcProtectiveDeviceTrippingUnit",IFCFLOWINSTRUMENT:"IfcFlowInstrument",IFCFIRESUPPRESSIONTERMINAL:"IfcFireSuppressionTerminal",IFCFILTER:"IfcFilter",IFCFAN:"IfcFan",IFCELECTRICTIMECONTROL:"IfcElectricTimeControl",IFCELECTRICMOTOR:"IfcElectricMotor",IFCELECTRICGENERATOR:"IfcElectricGenerator",IFCELECTRICFLOWSTORAGEDEVICE:"IfcElectricFlowStorageDevice",IFCELECTRICDISTRIBUTIONBOARD:"IfcElectricDistributionBoard",IFCELECTRICAPPLIANCE:"IfcElectricAppliance",IFCDUCTSILENCER:"IfcDuctSilencer",IFCDUCTSEGMENT:"IfcDuctSegment",IFCDUCTFITTING:"IfcDuctFitting",IFCDISTRIBUTIONCIRCUIT:"IfcDistributionCircuit",IFCDAMPER:"IfcDamper",IFCCOOLINGTOWER:"IfcCoolingTower",IFCCOOLEDBEAM:"IfcCooledBeam",IFCCONDENSER:"IfcCondenser",IFCCOMPRESSOR:"IfcCompressor",IFCCOMMUNICATIONSAPPLIANCE:"IfcCommunicationsAppliance",IFCCOIL:"IfcCoil",IFCCHILLER:"IfcChiller",IFCCABLESEGMENT:"IfcCableSegment",IFCCABLEFITTING:"IfcCableFitting",IFCCABLECARRIERSEGMENT:"IfcCableCarrierSegment",IFCCABLECARRIERFITTING:"IfcCableCarrierFitting",IFCBURNER:"IfcBurner",IFCBOILER:"IfcBoiler",IFCBEAMSTANDARDCASE:"IfcBeamStandardCase",IFCAUDIOVISUALAPPLIANCE:"IfcAudioVisualAppliance",IFCAIRTOAIRHEATRECOVERY:"IfcAirToAirHeatRecovery",IFCAIRTERMINALBOX:"IfcAirTerminalBox",IFCAIRTERMINAL:"IfcAirTerminal",IFCWINDOWSTANDARDCASE:"IfcWindowStandardCase",IFCWASTETERMINAL:"IfcWasteTerminal",IFCWALLELEMENTEDCASE:"IfcWallElementedCase",IFCVALVE:"IfcValve",IFCUNITARYEQUIPMENT:"IfcUnitaryEquipment",IFCUNITARYCONTROLELEMENTTYPE:"IfcUnitaryControlElementType",IFCTUBEBUNDLE:"IfcTubeBundle",IFCTRANSFORMER:"IfcTransformer",IFCTANK:"IfcTank",IFCSWITCHINGDEVICE:"IfcSwitchingDevice",IFCSTRUCTURALLOADCASE:"IfcStructuralLoadCase",IFCSTACKTERMINAL:"IfcStackTerminal",IFCSPACEHEATER:"IfcSpaceHeater",IFCSOLARDEVICE:"IfcSolarDevice",IFCSLABSTANDARDCASE:"IfcSlabStandardCase",IFCSLABELEMENTEDCASE:"IfcSlabElementedCase",IFCSHADINGDEVICE:"IfcShadingDevice",IFCSANITARYTERMINAL:"IfcSanitaryTerminal",IFCREINFORCINGBARTYPE:"IfcReinforcingBarType",IFCRATIONALBSPLINECURVEWITHKNOTS:"IfcRationalBSplineCurveWithKnots",IFCPUMP:"IfcPump",IFCPROTECTIVEDEVICETRIPPINGUNITTYPE:"IfcProtectiveDeviceTrippingUnitType",IFCPROTECTIVEDEVICE:"IfcProtectiveDevice",IFCPLATESTANDARDCASE:"IfcPlateStandardCase",IFCPIPESEGMENT:"IfcPipeSegment",IFCPIPEFITTING:"IfcPipeFitting",IFCOUTLET:"IfcOutlet",IFCOUTERBOUNDARYCURVE:"IfcOuterBoundaryCurve",IFCMOTORCONNECTION:"IfcMotorConnection",IFCMEMBERSTANDARDCASE:"IfcMemberStandardCase",IFCMEDICALDEVICE:"IfcMedicalDevice",IFCLIGHTFIXTURE:"IfcLightFixture",IFCLAMP:"IfcLamp",IFCJUNCTIONBOX:"IfcJunctionBox",IFCINTERCEPTOR:"IfcInterceptor",IFCHUMIDIFIER:"IfcHumidifier",IFCHEATEXCHANGER:"IfcHeatExchanger",IFCFLOWMETER:"IfcFlowMeter",IFCEXTERNALSPATIALELEMENT:"IfcExternalSpatialElement",IFCEVAPORATOR:"IfcEvaporator",IFCEVAPORATIVECOOLER:"IfcEvaporativeCooler",IFCENGINE:"IfcEngine",IFCELECTRICDISTRIBUTIONBOARDTYPE:"IfcElectricDistributionBoardType",IFCDOORSTANDARDCASE:"IfcDoorStandardCase",IFCDISTRIBUTIONSYSTEM:"IfcDistributionSystem",IFCCOMMUNICATIONSAPPLIANCETYPE:"IfcCommunicationsApplianceType",IFCCOLUMNSTANDARDCASE:"IfcColumnStandardCase",IFCCIVILELEMENT:"IfcCivilElement",IFCCHIMNEY:"IfcChimney",IFCCABLEFITTINGTYPE:"IfcCableFittingType",IFCBURNERTYPE:"IfcBurnerType",IFCBUILDINGSYSTEM:"IfcBuildingSystem",IFCBUILDINGELEMENTPARTTYPE:"IfcBuildingElementPartType",IFCBOUNDARYCURVE:"IfcBoundaryCurve",IFCBSPLINECURVEWITHKNOTS:"IfcBSplineCurveWithKnots",IFCAUDIOVISUALAPPLIANCETYPE:"IfcAudioVisualApplianceType",IFCWORKCALENDAR:"IfcWorkCalendar",IFCWINDOWTYPE:"IfcWindowType",IFCVOIDINGFEATURE:"IfcVoidingFeature",IFCVIBRATIONISOLATOR:"IfcVibrationIsolator",IFCTENDONTYPE:"IfcTendonType",IFCTENDONANCHORTYPE:"IfcTendonAnchorType",IFCSYSTEMFURNITUREELEMENT:"IfcSystemFurnitureElement",IFCSURFACEFEATURE:"IfcSurfaceFeature",IFCSTRUCTURALSURFACEACTION:"IfcStructuralSurfaceAction",IFCSTRUCTURALCURVEREACTION:"IfcStructuralCurveReaction",IFCSTRUCTURALCURVEACTION:"IfcStructuralCurveAction",IFCSTAIRTYPE:"IfcStairType",IFCSOLARDEVICETYPE:"IfcSolarDeviceType",IFCSHADINGDEVICETYPE:"IfcShadingDeviceType",IFCSEAMCURVE:"IfcSeamCurve",IFCROOFTYPE:"IfcRoofType",IFCREINFORCINGMESHTYPE:"IfcReinforcingMeshType",IFCREINFORCINGELEMENTTYPE:"IfcReinforcingElementType",IFCRATIONALBSPLINESURFACEWITHKNOTS:"IfcRationalBSplineSurfaceWithKnots",IFCRAMPTYPE:"IfcRampType",IFCPOLYGONALFACESET:"IfcPolygonalFaceSet",IFCPILETYPE:"IfcPileType",IFCOPENINGSTANDARDCASE:"IfcOpeningStandardCase",IFCMEDICALDEVICETYPE:"IfcMedicalDeviceType",IFCINTERSECTIONCURVE:"IfcIntersectionCurve",IFCINTERCEPTORTYPE:"IfcInterceptorType",IFCINDEXEDPOLYCURVE:"IfcIndexedPolyCurve",IFCGEOGRAPHICELEMENT:"IfcGeographicElement",IFCFURNITURE:"IfcFurniture",IFCFOOTINGTYPE:"IfcFootingType",IFCEXTERNALSPATIALSTRUCTUREELEMENT:"IfcExternalSpatialStructureElement",IFCEVENT:"IfcEvent",IFCENGINETYPE:"IfcEngineType",IFCELEMENTASSEMBLYTYPE:"IfcElementAssemblyType",IFCDOORTYPE:"IfcDoorType",IFCCYLINDRICALSURFACE:"IfcCylindricalSurface",IFCCONSTRUCTIONPRODUCTRESOURCETYPE:"IfcConstructionProductResourceType",IFCCONSTRUCTIONMATERIALRESOURCETYPE:"IfcConstructionMaterialResourceType",IFCCONSTRUCTIONEQUIPMENTRESOURCETYPE:"IfcConstructionEquipmentResourceType",IFCCOMPOSITECURVEONSURFACE:"IfcCompositeCurveOnSurface",IFCCOMPLEXPROPERTYTEMPLATE:"IfcComplexPropertyTemplate",IFCCIVILELEMENTTYPE:"IfcCivilElementType",IFCCHIMNEYTYPE:"IfcChimneyType",IFCBSPLINESURFACEWITHKNOTS:"IfcBSplineSurfaceWithKnots",IFCBSPLINESURFACE:"IfcBSplineSurface",IFCADVANCEDBREPWITHVOIDS:"IfcAdvancedBrepWithVoids",IFCADVANCEDBREP:"IfcAdvancedBrep",IFCTRIANGULATEDFACESET:"IfcTriangulatedFaceSet",IFCTOROIDALSURFACE:"IfcToroidalSurface",IFCTESSELLATEDFACESET:"IfcTessellatedFaceSet",IFCTASKTYPE:"IfcTaskType",IFCSURFACECURVE:"IfcSurfaceCurve",IFCSUBCONTRACTRESOURCETYPE:"IfcSubContractResourceType",IFCSTRUCTURALSURFACEREACTION:"IfcStructuralSurfaceReaction",IFCSPHERICALSURFACE:"IfcSphericalSurface",IFCSPATIALZONETYPE:"IfcSpatialZoneType",IFCSPATIALZONE:"IfcSpatialZone",IFCSPATIALELEMENTTYPE:"IfcSpatialElementType",IFCSPATIALELEMENT:"IfcSpatialElement",IFCSIMPLEPROPERTYTEMPLATE:"IfcSimplePropertyTemplate",IFCREVOLVEDAREASOLIDTAPERED:"IfcRevolvedAreaSolidTapered",IFCREPARAMETRISEDCOMPOSITECURVESEGMENT:"IfcReparametrisedCompositeCurveSegment",IFCRELSPACEBOUNDARY2NDLEVEL:"IfcRelSpaceBoundary2ndLevel",IFCRELSPACEBOUNDARY1STLEVEL:"IfcRelSpaceBoundary1stLevel",IFCRELINTERFERESELEMENTS:"IfcRelInterferesElements",IFCRELDEFINESBYTEMPLATE:"IfcRelDefinesByTemplate",IFCRELDEFINESBYOBJECT:"IfcRelDefinesByObject",IFCRELDECLARES:"IfcRelDeclares",IFCRELASSIGNSTOGROUPBYFACTOR:"IfcRelAssignsToGroupByFactor",IFCPROPERTYTEMPLATE:"IfcPropertyTemplate",IFCPROPERTYSETTEMPLATE:"IfcPropertySetTemplate",IFCPROJECTLIBRARY:"IfcProjectLibrary",IFCPROCEDURETYPE:"IfcProcedureType",IFCPREDEFINEDPROPERTYSET:"IfcPredefinedPropertySet",IFCPCURVE:"IfcPCurve",IFCLABORRESOURCETYPE:"IfcLaborResourceType",IFCINDEXEDPOLYGONALFACEWITHVOIDS:"IfcIndexedPolygonalFaceWithVoids",IFCINDEXEDPOLYGONALFACE:"IfcIndexedPolygonalFace",IFCGEOGRAPHICELEMENTTYPE:"IfcGeographicElementType",IFCFIXEDREFERENCESWEPTAREASOLID:"IfcFixedReferenceSweptAreaSolid",IFCEXTRUDEDAREASOLIDTAPERED:"IfcExtrudedAreaSolidTapered",IFCEVENTTYPE:"IfcEventType",IFCCURVEBOUNDEDSURFACE:"IfcCurveBoundedSurface",IFCCREWRESOURCETYPE:"IfcCrewResourceType",IFCCONTEXT:"IfcContext",IFCCONSTRUCTIONRESOURCETYPE:"IfcConstructionResourceType",IFCCARTESIANPOINTLIST3D:"IfcCartesianPointList3D",IFCCARTESIANPOINTLIST2D:"IfcCartesianPointList2D",IFCCARTESIANPOINTLIST:"IfcCartesianPointList",IFCADVANCEDFACE:"IfcAdvancedFace",IFCTYPERESOURCE:"IfcTypeResource",IFCTYPEPROCESS:"IfcTypeProcess",IFCTESSELLATEDITEM:"IfcTessellatedItem",IFCSWEPTDISKSOLIDPOLYGONAL:"IfcSweptDiskSolidPolygonal",IFCRESOURCETIME:"IfcResourceTime",IFCRESOURCECONSTRAINTRELATIONSHIP:"IfcResourceConstraintRelationship",IFCRESOURCEAPPROVALRELATIONSHIP:"IfcResourceApprovalRelationship",IFCQUANTITYSET:"IfcQuantitySet",IFCPROPERTYTEMPLATEDEFINITION:"IfcPropertyTemplateDefinition",IFCPREDEFINEDPROPERTIES:"IfcPredefinedProperties",IFCMIRROREDPROFILEDEF:"IfcMirroredProfileDef",IFCMATERIALRELATIONSHIP:"IfcMaterialRelationship",IFCMATERIALPROFILESETUSAGETAPERING:"IfcMaterialProfileSetUsageTapering",IFCMATERIALPROFILESETUSAGE:"IfcMaterialProfileSetUsage",IFCMATERIALCONSTITUENTSET:"IfcMaterialConstituentSet",IFCMATERIALCONSTITUENT:"IfcMaterialConstituent",IFCLAGTIME:"IfcLagTime",IFCINDEXEDTRIANGLETEXTUREMAP:"IfcIndexedTriangleTextureMap",IFCINDEXEDTEXTUREMAP:"IfcIndexedTextureMap",IFCINDEXEDCOLOURMAP:"IfcIndexedColourMap",IFCEXTERNALREFERENCERELATIONSHIP:"IfcExternalReferenceRelationship",IFCEXTENDEDPROPERTIES:"IfcExtendedProperties",IFCEVENTTIME:"IfcEventTime",IFCCONVERSIONBASEDUNITWITHOFFSET:"IfcConversionBasedUnitWithOffset",IFCCOLOURRGBLIST:"IfcColourRgbList",IFCWORKTIME:"IfcWorkTime",IFCTIMEPERIOD:"IfcTimePeriod",IFCTEXTUREVERTEXLIST:"IfcTextureVertexList",IFCTASKTIMERECURRING:"IfcTaskTimeRecurring",IFCTASKTIME:"IfcTaskTime",IFCTABLECOLUMN:"IfcTableColumn",IFCSURFACEREINFORCEMENTAREA:"IfcSurfaceReinforcementArea",IFCSTRUCTURALLOADORRESULT:"IfcStructuralLoadOrResult",IFCSTRUCTURALLOADCONFIGURATION:"IfcStructuralLoadConfiguration",IFCSCHEDULINGTIME:"IfcSchedulingTime",IFCRESOURCELEVELRELATIONSHIP:"IfcResourceLevelRelationship",IFCREFERENCE:"IfcReference",IFCRECURRENCEPATTERN:"IfcRecurrencePattern",IFCPROPERTYABSTRACTION:"IfcPropertyAbstraction",IFCPROJECTEDCRS:"IfcProjectedCrs",IFCPRESENTATIONITEM:"IfcPresentationItem",IFCMATERIALUSAGEDEFINITION:"IfcMaterialUsageDefinition",IFCMATERIALPROFILEWITHOFFSETS:"IfcMaterialProfileWithOffsets",IFCMATERIALPROFILESET:"IfcMaterialProfileSet",IFCMATERIALPROFILE:"IfcMaterialProfile",IFCMATERIALLAYERWITHOFFSETS:"IfcMaterialLayerWithOffsets",IFCMATERIALDEFINITION:"IfcMaterialDefinition",IFCMAPCONVERSION:"IfcMapConversion",IFCEXTERNALINFORMATION:"IfcExternalInformation",IFCCOORDINATEREFERENCESYSTEM:"IfcCoordinateReferenceSystem",IFCCOORDINATEOPERATION:"IfcCoordinateOperation",IFCCONNECTIONVOLUMEGEOMETRY:"IfcConnectionVolumeGeometry",IFCREINFORCINGBAR:"IfcReinforcingBar",IFCELECTRICDISTRIBUTIONPOINT:"IfcElectricDistributionPoint",IFCDISTRIBUTIONCONTROLELEMENT:"IfcDistributionControlElement",IFCDISTRIBUTIONCHAMBERELEMENT:"IfcDistributionChamberElement",IFCCONTROLLERTYPE:"IfcControllerType",IFCCHAMFEREDGEFEATURE:"IfcChamferEdgeFeature",IFCBEAM:"IfcBeam",IFCALARMTYPE:"IfcAlarmType",IFCACTUATORTYPE:"IfcActuatorType",IFCWINDOW:"IfcWindow",IFCWALLSTANDARDCASE:"IfcWallStandardCase",IFCWALL:"IfcWall",IFCVIBRATIONISOLATORTYPE:"IfcVibrationIsolatorType",IFCTENDONANCHOR:"IfcTendonAnchor",IFCTENDON:"IfcTendon",IFCSTRUCTURALANALYSISMODEL:"IfcStructuralAnalysisModel",IFCSTAIRFLIGHT:"IfcStairFlight",IFCSTAIR:"IfcStair",IFCSLAB:"IfcSlab",IFCSENSORTYPE:"IfcSensorType",IFCROUNDEDEDGEFEATURE:"IfcRoundedEdgeFeature",IFCROOF:"IfcRoof",IFCREINFORCINGMESH:"IfcReinforcingMesh",IFCREINFORCINGELEMENT:"IfcReinforcingElement",IFCRATIONALBEZIERCURVE:"IfcRationalBezierCurve",IFCRAMPFLIGHT:"IfcRampFlight",IFCRAMP:"IfcRamp",IFCRAILING:"IfcRailing",IFCPLATE:"IfcPlate",IFCPILE:"IfcPile",IFCMEMBER:"IfcMember",IFCFOOTING:"IfcFooting",IFCFLOWTREATMENTDEVICE:"IfcFlowTreatmentDevice",IFCFLOWTERMINAL:"IfcFlowTerminal",IFCFLOWSTORAGEDEVICE:"IfcFlowStorageDevice",IFCFLOWSEGMENT:"IfcFlowSegment",IFCFLOWMOVINGDEVICE:"IfcFlowMovingDevice",IFCFLOWINSTRUMENTTYPE:"IfcFlowInstrumentType",IFCFLOWFITTING:"IfcFlowFitting",IFCFLOWCONTROLLER:"IfcFlowController",IFCFIRESUPPRESSIONTERMINALTYPE:"IfcFireSuppressionTerminalType",IFCFILTERTYPE:"IfcFilterType",IFCFANTYPE:"IfcFanType",IFCENERGYCONVERSIONDEVICE:"IfcEnergyConversionDevice",IFCELECTRICALELEMENT:"IfcElectricalElement",IFCELECTRICALCIRCUIT:"IfcElectricalCircuit",IFCELECTRICTIMECONTROLTYPE:"IfcElectricTimeControlType",IFCELECTRICMOTORTYPE:"IfcElectricMotorType",IFCELECTRICHEATERTYPE:"IfcElectricHeaterType",IFCELECTRICGENERATORTYPE:"IfcElectricGeneratorType",IFCELECTRICFLOWSTORAGEDEVICETYPE:"IfcElectricFlowStorageDeviceType",IFCELECTRICAPPLIANCETYPE:"IfcElectricApplianceType",IFCEDGEFEATURE:"IfcEdgeFeature",IFCDUCTSILENCERTYPE:"IfcDuctSilencerType",IFCDUCTSEGMENTTYPE:"IfcDuctSegmentType",IFCDUCTFITTINGTYPE:"IfcDuctFittingType",IFCDOOR:"IfcDoor",IFCDISTRIBUTIONPORT:"IfcDistributionPort",IFCDISTRIBUTIONFLOWELEMENT:"IfcDistributionFlowElement",IFCDISTRIBUTIONELEMENT:"IfcDistributionElement",IFCDISTRIBUTIONCONTROLELEMENTTYPE:"IfcDistributionControlElementType",IFCDISTRIBUTIONCHAMBERELEMENTTYPE:"IfcDistributionChamberElementType",IFCDISCRETEACCESSORYTYPE:"IfcDiscreteAccessoryType",IFCDISCRETEACCESSORY:"IfcDiscreteAccessory",IFCDIAMETERDIMENSION:"IfcDiameterDimension",IFCDAMPERTYPE:"IfcDamperType",IFCCURTAINWALL:"IfcCurtainWall",IFCCOVERING:"IfcCovering",IFCCOOLINGTOWERTYPE:"IfcCoolingTowerType",IFCCOOLEDBEAMTYPE:"IfcCooledBeamType",IFCCONSTRUCTIONPRODUCTRESOURCE:"IfcConstructionProductResource",IFCCONSTRUCTIONMATERIALRESOURCE:"IfcConstructionMaterialResource",IFCCONSTRUCTIONEQUIPMENTRESOURCE:"IfcConstructionEquipmentResource",IFCCONDITIONCRITERION:"IfcConditionCriterion",IFCCONDITION:"IfcCondition",IFCCONDENSERTYPE:"IfcCondenserType",IFCCOMPRESSORTYPE:"IfcCompressorType",IFCCOLUMN:"IfcColumn",IFCCOILTYPE:"IfcCoilType",IFCCIRCLE:"IfcCircle",IFCCHILLERTYPE:"IfcChillerType",IFCCABLESEGMENTTYPE:"IfcCableSegmentType",IFCCABLECARRIERSEGMENTTYPE:"IfcCableCarrierSegmentType",IFCCABLECARRIERFITTINGTYPE:"IfcCableCarrierFittingType",IFCBUILDINGELEMENTPROXYTYPE:"IfcBuildingElementProxyType",IFCBUILDINGELEMENTPROXY:"IfcBuildingElementProxy",IFCBUILDINGELEMENTPART:"IfcBuildingElementPart",IFCBUILDINGELEMENTCOMPONENT:"IfcBuildingElementComponent",IFCBUILDINGELEMENT:"IfcBuildingElement",IFCBOILERTYPE:"IfcBoilerType",IFCBEZIERCURVE:"IfcBezierCurve",IFCBEAMTYPE:"IfcBeamType",IFCBSPLINECURVE:"IfcBSplineCurve",IFCASSET:"IfcAsset",IFCANGULARDIMENSION:"IfcAngularDimension",IFCAIRTOAIRHEATRECOVERYTYPE:"IfcAirToAirHeatRecoveryType",IFCAIRTERMINALTYPE:"IfcAirTerminalType",IFCAIRTERMINALBOXTYPE:"IfcAirTerminalBoxType",IFCACTIONREQUEST:"IfcActionRequest",IFC2DCOMPOSITECURVE:"Ifc2DCompositeCurve",IFCZONE:"IfcZone",IFCWORKSCHEDULE:"IfcWorkSchedule",IFCWORKPLAN:"IfcWorkPlan",IFCWORKCONTROL:"IfcWorkControl",IFCWASTETERMINALTYPE:"IfcWasteTerminalType",IFCWALLTYPE:"IfcWallType",IFCVIRTUALELEMENT:"IfcVirtualElement",IFCVALVETYPE:"IfcValveType",IFCUNITARYEQUIPMENTTYPE:"IfcUnitaryEquipmentType",IFCTUBEBUNDLETYPE:"IfcTubeBundleType",IFCTRIMMEDCURVE:"IfcTrimmedCurve",IFCTRANSPORTELEMENT:"IfcTransportElement",IFCTRANSFORMERTYPE:"IfcTransformerType",IFCTIMESERIESSCHEDULE:"IfcTimeSeriesSchedule",IFCTANKTYPE:"IfcTankType",IFCSYSTEM:"IfcSystem",IFCSWITCHINGDEVICETYPE:"IfcSwitchingDeviceType",IFCSUBCONTRACTRESOURCE:"IfcSubContractResource",IFCSTRUCTURALSURFACECONNECTION:"IfcStructuralSurfaceConnection",IFCSTRUCTURALRESULTGROUP:"IfcStructuralResultGroup",IFCSTRUCTURALPOINTREACTION:"IfcStructuralPointReaction",IFCSTRUCTURALPOINTCONNECTION:"IfcStructuralPointConnection",IFCSTRUCTURALPOINTACTION:"IfcStructuralPointAction",IFCSTRUCTURALPLANARACTIONVARYING:"IfcStructuralPlanarActionVarying",IFCSTRUCTURALPLANARACTION:"IfcStructuralPlanarAction",IFCSTRUCTURALLOADGROUP:"IfcStructuralLoadGroup",IFCSTRUCTURALLINEARACTIONVARYING:"IfcStructuralLinearActionVarying",IFCSTRUCTURALLINEARACTION:"IfcStructuralLinearAction",IFCSTRUCTURALCURVEMEMBERVARYING:"IfcStructuralCurveMemberVarying",IFCSTRUCTURALCURVEMEMBER:"IfcStructuralCurveMember",IFCSTRUCTURALCURVECONNECTION:"IfcStructuralCurveConnection",IFCSTRUCTURALCONNECTION:"IfcStructuralConnection",IFCSTRUCTURALACTION:"IfcStructuralAction",IFCSTAIRFLIGHTTYPE:"IfcStairFlightType",IFCSTACKTERMINALTYPE:"IfcStackTerminalType",IFCSPACETYPE:"IfcSpaceType",IFCSPACEPROGRAM:"IfcSpaceProgram",IFCSPACEHEATERTYPE:"IfcSpaceHeaterType",IFCSPACE:"IfcSpace",IFCSLABTYPE:"IfcSlabType",IFCSITE:"IfcSite",IFCSERVICELIFE:"IfcServiceLife",IFCSCHEDULETIMECONTROL:"IfcScheduleTimeControl",IFCSANITARYTERMINALTYPE:"IfcSanitaryTerminalType",IFCRELASSIGNSTASKS:"IfcRelAssignsTasks",IFCRELAGGREGATES:"IfcRelAggregates",IFCRAMPFLIGHTTYPE:"IfcRampFlightType",IFCRAILINGTYPE:"IfcRailingType",IFCRADIUSDIMENSION:"IfcRadiusDimension",IFCPUMPTYPE:"IfcPumpType",IFCPROTECTIVEDEVICETYPE:"IfcProtectiveDeviceType",IFCPROJECTIONELEMENT:"IfcProjectionElement",IFCPROJECTORDERRECORD:"IfcProjectOrderRecord",IFCPROJECTORDER:"IfcProjectOrder",IFCPROCEDURE:"IfcProcedure",IFCPORT:"IfcPort",IFCPOLYLINE:"IfcPolyline",IFCPLATETYPE:"IfcPlateType",IFCPIPESEGMENTTYPE:"IfcPipeSegmentType",IFCPIPEFITTINGTYPE:"IfcPipeFittingType",IFCPERMIT:"IfcPermit",IFCPERFORMANCEHISTORY:"IfcPerformanceHistory",IFCOUTLETTYPE:"IfcOutletType",IFCORDERACTION:"IfcOrderAction",IFCOPENINGELEMENT:"IfcOpeningElement",IFCOCCUPANT:"IfcOccupant",IFCMOVE:"IfcMove",IFCMOTORCONNECTIONTYPE:"IfcMotorConnectionType",IFCMEMBERTYPE:"IfcMemberType",IFCMECHANICALFASTENERTYPE:"IfcMechanicalFastenerType",IFCMECHANICALFASTENER:"IfcMechanicalFastener",IFCLINEARDIMENSION:"IfcLinearDimension",IFCLIGHTFIXTURETYPE:"IfcLightFixtureType",IFCLAMPTYPE:"IfcLampType",IFCLABORRESOURCE:"IfcLaborResource",IFCJUNCTIONBOXTYPE:"IfcJunctionBoxType",IFCINVENTORY:"IfcInventory",IFCHUMIDIFIERTYPE:"IfcHumidifierType",IFCHEATEXCHANGERTYPE:"IfcHeatExchangerType",IFCGROUP:"IfcGroup",IFCGRID:"IfcGrid",IFCGASTERMINALTYPE:"IfcGasTerminalType",IFCFURNITURESTANDARD:"IfcFurnitureStandard",IFCFURNISHINGELEMENT:"IfcFurnishingElement",IFCFLOWTREATMENTDEVICETYPE:"IfcFlowTreatmentDeviceType",IFCFLOWTERMINALTYPE:"IfcFlowTerminalType",IFCFLOWSTORAGEDEVICETYPE:"IfcFlowStorageDeviceType",IFCFLOWSEGMENTTYPE:"IfcFlowSegmentType",IFCFLOWMOVINGDEVICETYPE:"IfcFlowMovingDeviceType",IFCFLOWMETERTYPE:"IfcFlowMeterType",IFCFLOWFITTINGTYPE:"IfcFlowFittingType",IFCFLOWCONTROLLERTYPE:"IfcFlowControllerType",IFCFEATUREELEMENTSUBTRACTION:"IfcFeatureElementSubtraction",IFCFEATUREELEMENTADDITION:"IfcFeatureElementAddition",IFCFEATUREELEMENT:"IfcFeatureElement",IFCFASTENERTYPE:"IfcFastenerType",IFCFASTENER:"IfcFastener",IFCFACETEDBREPWITHVOIDS:"IfcFacetedBrepWithVoids",IFCFACETEDBREP:"IfcFacetedBrep",IFCEVAPORATORTYPE:"IfcEvaporatorType",IFCEVAPORATIVECOOLERTYPE:"IfcEvaporativeCoolerType",IFCEQUIPMENTSTANDARD:"IfcEquipmentStandard",IFCEQUIPMENTELEMENT:"IfcEquipmentElement",IFCENERGYCONVERSIONDEVICETYPE:"IfcEnergyConversionDeviceType",IFCELLIPSE:"IfcEllipse",IFCELEMENTCOMPONENTTYPE:"IfcElementComponentType",IFCELEMENTCOMPONENT:"IfcElementComponent",IFCELEMENTASSEMBLY:"IfcElementAssembly",IFCELEMENT:"IfcElement",IFCELECTRICALBASEPROPERTIES:"IfcElectricalBaseProperties",IFCDISTRIBUTIONFLOWELEMENTTYPE:"IfcDistributionFlowElementType",IFCDISTRIBUTIONELEMENTTYPE:"IfcDistributionElementType",IFCDIMENSIONCURVEDIRECTEDCALLOUT:"IfcDimensionCurveDirectedCallout",IFCCURTAINWALLTYPE:"IfcCurtainWallType",IFCCREWRESOURCE:"IfcCrewResource",IFCCOVERINGTYPE:"IfcCoveringType",IFCCOSTSCHEDULE:"IfcCostSchedule",IFCCOSTITEM:"IfcCostItem",IFCCONTROL:"IfcControl",IFCCONSTRUCTIONRESOURCE:"IfcConstructionResource",IFCCONIC:"IfcConic",IFCCOMPOSITECURVE:"IfcCompositeCurve",IFCCOLUMNTYPE:"IfcColumnType",IFCCIRCLEHOLLOWPROFILEDEF:"IfcCircleHollowProfileDef",IFCBUILDINGSTOREY:"IfcBuildingStorey",IFCBUILDINGELEMENTTYPE:"IfcBuildingElementType",IFCBUILDING:"IfcBuilding",IFCBOUNDEDCURVE:"IfcBoundedCurve",IFCBOOLEANCLIPPINGRESULT:"IfcBooleanClippingResult",IFCBLOCK:"IfcBlock",IFCASYMMETRICISHAPEPROFILEDEF:"IfcAsymmetricIShapeProfileDef",IFCANNOTATION:"IfcAnnotation",IFCACTOR:"IfcActor",IFCTRANSPORTELEMENTTYPE:"IfcTransportElementType",IFCTASK:"IfcTask",IFCSYSTEMFURNITUREELEMENTTYPE:"IfcSystemFurnitureElementType",IFCSURFACEOFREVOLUTION:"IfcSurfaceOfRevolution",IFCSURFACEOFLINEAREXTRUSION:"IfcSurfaceOfLinearExtrusion",IFCSURFACECURVESWEPTAREASOLID:"IfcSurfaceCurveSweptAreaSolid",IFCSTRUCTUREDDIMENSIONCALLOUT:"IfcStructuredDimensionCallout",IFCSTRUCTURALSURFACEMEMBERVARYING:"IfcStructuralSurfaceMemberVarying",IFCSTRUCTURALSURFACEMEMBER:"IfcStructuralSurfaceMember",IFCSTRUCTURALREACTION:"IfcStructuralReaction",IFCSTRUCTURALMEMBER:"IfcStructuralMember",IFCSTRUCTURALITEM:"IfcStructuralItem",IFCSTRUCTURALACTIVITY:"IfcStructuralActivity",IFCSPHERE:"IfcSphere",IFCSPATIALSTRUCTUREELEMENTTYPE:"IfcSpatialStructureElementType",IFCSPATIALSTRUCTUREELEMENT:"IfcSpatialStructureElement",IFCRIGHTCIRCULARCYLINDER:"IfcRightCircularCylinder",IFCRIGHTCIRCULARCONE:"IfcRightCircularCone",IFCREVOLVEDAREASOLID:"IfcRevolvedAreaSolid",IFCRESOURCE:"IfcResource",IFCRELVOIDSELEMENT:"IfcRelVoidsElement",IFCRELSPACEBOUNDARY:"IfcRelSpaceBoundary",IFCRELSERVICESBUILDINGS:"IfcRelServicesBuildings",IFCRELSEQUENCE:"IfcRelSequence",IFCRELSCHEDULESCOSTITEMS:"IfcRelSchedulesCostItems",IFCRELREFERENCEDINSPATIALSTRUCTURE:"IfcRelReferencedInSpatialStructure",IFCRELPROJECTSELEMENT:"IfcRelProjectsElement",IFCRELOVERRIDESPROPERTIES:"IfcRelOverridesProperties",IFCRELOCCUPIESSPACES:"IfcRelOccupiesSpaces",IFCRELNESTS:"IfcRelNests",IFCRELINTERACTIONREQUIREMENTS:"IfcRelInteractionRequirements",IFCRELFLOWCONTROLELEMENTS:"IfcRelFlowControlElements",IFCRELFILLSELEMENT:"IfcRelFillsElement",IFCRELDEFINESBYTYPE:"IfcRelDefinesByType",IFCRELDEFINESBYPROPERTIES:"IfcRelDefinesByProperties",IFCRELDEFINES:"IfcRelDefines",IFCRELDECOMPOSES:"IfcRelDecomposes",IFCRELCOVERSSPACES:"IfcRelCoversSpaces",IFCRELCOVERSBLDGELEMENTS:"IfcRelCoversBldgElements",IFCRELCONTAINEDINSPATIALSTRUCTURE:"IfcRelContainedInSpatialStructure",IFCRELCONNECTSWITHREALIZINGELEMENTS:"IfcRelConnectsWithRealizingElements",IFCRELCONNECTSWITHECCENTRICITY:"IfcRelConnectsWithEccentricity",IFCRELCONNECTSSTRUCTURALMEMBER:"IfcRelConnectsStructuralMember",IFCRELCONNECTSSTRUCTURALELEMENT:"IfcRelConnectsStructuralElement",IFCRELCONNECTSSTRUCTURALACTIVITY:"IfcRelConnectsStructuralActivity",IFCRELCONNECTSPORTS:"IfcRelConnectsPorts",IFCRELCONNECTSPORTTOELEMENT:"IfcRelConnectsPortToElement",IFCRELCONNECTSPATHELEMENTS:"IfcRelConnectsPathElements",IFCRELCONNECTSELEMENTS:"IfcRelConnectsElements",IFCRELCONNECTS:"IfcRelConnects",IFCRELASSOCIATESPROFILEPROPERTIES:"IfcRelAssociatesProfileProperties",IFCRELASSOCIATESMATERIAL:"IfcRelAssociatesMaterial",IFCRELASSOCIATESLIBRARY:"IfcRelAssociatesLibrary",IFCRELASSOCIATESDOCUMENT:"IfcRelAssociatesDocument",IFCRELASSOCIATESCONSTRAINT:"IfcRelAssociatesConstraint",IFCRELASSOCIATESCLASSIFICATION:"IfcRelAssociatesClassification",IFCRELASSOCIATESAPPROVAL:"IfcRelAssociatesApproval",IFCRELASSOCIATESAPPLIEDVALUE:"IfcRelAssociatesAppliedValue",IFCRELASSOCIATES:"IfcRelAssociates",IFCRELASSIGNSTORESOURCE:"IfcRelAssignsToResource",IFCRELASSIGNSTOPROJECTORDER:"IfcRelAssignsToProjectOrder",IFCRELASSIGNSTOPRODUCT:"IfcRelAssignsToProduct",IFCRELASSIGNSTOPROCESS:"IfcRelAssignsToProcess",IFCRELASSIGNSTOGROUP:"IfcRelAssignsToGroup",IFCRELASSIGNSTOCONTROL:"IfcRelAssignsToControl",IFCRELASSIGNSTOACTOR:"IfcRelAssignsToActor",IFCRELASSIGNS:"IfcRelAssigns",IFCRECTANGULARTRIMMEDSURFACE:"IfcRectangularTrimmedSurface",IFCRECTANGULARPYRAMID:"IfcRectangularPyramid",IFCRECTANGLEHOLLOWPROFILEDEF:"IfcRectangleHollowProfileDef",IFCPROXY:"IfcProxy",IFCPROPERTYSET:"IfcPropertySet",IFCPROJECTIONCURVE:"IfcProjectionCurve",IFCPROJECT:"IfcProject",IFCPRODUCT:"IfcProduct",IFCPROCESS:"IfcProcess",IFCPLANE:"IfcPlane",IFCPLANARBOX:"IfcPlanarBox",IFCPERMEABLECOVERINGPROPERTIES:"IfcPermeableCoveringProperties",IFCOFFSETCURVE3D:"IfcOffsetCurve3D",IFCOFFSETCURVE2D:"IfcOffsetCurve2D",IFCOBJECT:"IfcObject",IFCMANIFOLDSOLIDBREP:"IfcManifoldSolidBrep",IFCLINE:"IfcLine",IFCLSHAPEPROFILEDEF:"IfcLShapeProfileDef",IFCISHAPEPROFILEDEF:"IfcIShapeProfileDef",IFCGEOMETRICCURVESET:"IfcGeometricCurveSet",IFCFURNITURETYPE:"IfcFurnitureType",IFCFURNISHINGELEMENTTYPE:"IfcFurnishingElementType",IFCFLUIDFLOWPROPERTIES:"IfcFluidFlowProperties",IFCFILLAREASTYLETILES:"IfcFillAreaStyleTiles",IFCFILLAREASTYLETILESYMBOLWITHSTYLE:"IfcFillAreaStyleTileSymbolWithStyle",IFCFILLAREASTYLEHATCHING:"IfcFillAreaStyleHatching",IFCFACEBASEDSURFACEMODEL:"IfcFaceBasedSurfaceModel",IFCEXTRUDEDAREASOLID:"IfcExtrudedAreaSolid",IFCENERGYPROPERTIES:"IfcEnergyProperties",IFCELLIPSEPROFILEDEF:"IfcEllipseProfileDef",IFCELEMENTARYSURFACE:"IfcElementarySurface",IFCELEMENTTYPE:"IfcElementType",IFCELEMENTQUANTITY:"IfcElementQuantity",IFCEDGELOOP:"IfcEdgeLoop",IFCDRAUGHTINGPREDEFINEDCURVEFONT:"IfcDraughtingPredefinedCurveFont",IFCDRAUGHTINGPREDEFINEDCOLOUR:"IfcDraughtingPredefinedColour",IFCDRAUGHTINGCALLOUT:"IfcDraughtingCallout",IFCDOORSTYLE:"IfcDoorStyle",IFCDOORPANELPROPERTIES:"IfcDoorPanelProperties",IFCDOORLININGPROPERTIES:"IfcDoorLiningProperties",IFCDIRECTION:"IfcDirection",IFCDIMENSIONCURVETERMINATOR:"IfcDimensionCurveTerminator",IFCDIMENSIONCURVE:"IfcDimensionCurve",IFCDEFINEDSYMBOL:"IfcDefinedSymbol",IFCCURVEBOUNDEDPLANE:"IfcCurveBoundedPlane",IFCCURVE:"IfcCurve",IFCCSGSOLID:"IfcCsgSolid",IFCCSGPRIMITIVE3D:"IfcCsgPrimitive3D",IFCCRANERAILFSHAPEPROFILEDEF:"IfcCraneRailFShapeProfileDef",IFCCRANERAILASHAPEPROFILEDEF:"IfcCraneRailAShapeProfileDef",IFCCOMPOSITECURVESEGMENT:"IfcCompositeCurveSegment",IFCCLOSEDSHELL:"IfcClosedShell",IFCCIRCLEPROFILEDEF:"IfcCircleProfileDef",IFCCARTESIANTRANSFORMATIONOPERATOR3DNONUNIFORM:"IfcCartesianTransformationOperator3DNonUniform",IFCCARTESIANTRANSFORMATIONOPERATOR3D:"IfcCartesianTransformationOperator3D",IFCCARTESIANTRANSFORMATIONOPERATOR2DNONUNIFORM:"IfcCartesianTransformationOperator2DNonUniform",IFCCARTESIANTRANSFORMATIONOPERATOR2D:"IfcCartesianTransformationOperator2D",IFCCARTESIANTRANSFORMATIONOPERATOR:"IfcCartesianTransformationOperator",IFCCARTESIANPOINT:"IfcCartesianPoint",IFCCSHAPEPROFILEDEF:"IfcCShapeProfileDef",IFCBOXEDHALFSPACE:"IfcBoxedHalfSpace",IFCBOUNDINGBOX:"IfcBoundingBox",IFCBOUNDEDSURFACE:"IfcBoundedSurface",IFCBOOLEANRESULT:"IfcBooleanResult",IFCAXIS2PLACEMENT3D:"IfcAxis2Placement3D",IFCAXIS2PLACEMENT2D:"IfcAxis2Placement2D",IFCAXIS1PLACEMENT:"IfcAxis1Placement",IFCANNOTATIONSURFACE:"IfcAnnotationSurface",IFCANNOTATIONFILLAREAOCCURRENCE:"IfcAnnotationFillAreaOccurrence",IFCANNOTATIONFILLAREA:"IfcAnnotationFillArea",IFCANNOTATIONCURVEOCCURRENCE:"IfcAnnotationCurveOccurrence",IFCZSHAPEPROFILEDEF:"IfcZShapeProfileDef",IFCWINDOWSTYLE:"IfcWindowStyle",IFCWINDOWPANELPROPERTIES:"IfcWindowPanelProperties",IFCWINDOWLININGPROPERTIES:"IfcWindowLiningProperties",IFCVERTEXLOOP:"IfcVertexLoop",IFCVECTOR:"IfcVector",IFCUSHAPEPROFILEDEF:"IfcUShapeProfileDef",IFCTYPEPRODUCT:"IfcTypeProduct",IFCTYPEOBJECT:"IfcTypeObject",IFCTWODIRECTIONREPEATFACTOR:"IfcTwoDirectionRepeatFactor",IFCTRAPEZIUMPROFILEDEF:"IfcTrapeziumProfileDef",IFCTEXTLITERALWITHEXTENT:"IfcTextLiteralWithExtent",IFCTEXTLITERAL:"IfcTextLiteral",IFCTERMINATORSYMBOL:"IfcTerminatorSymbol",IFCTSHAPEPROFILEDEF:"IfcTShapeProfileDef",IFCSWEPTSURFACE:"IfcSweptSurface",IFCSWEPTDISKSOLID:"IfcSweptDiskSolid",IFCSWEPTAREASOLID:"IfcSweptAreaSolid",IFCSURFACESTYLERENDERING:"IfcSurfaceStyleRendering",IFCSURFACE:"IfcSurface",IFCSUBEDGE:"IfcSubedge",IFCSTRUCTURALSTEELPROFILEPROPERTIES:"IfcStructuralSteelProfileProperties",IFCSTRUCTURALPROFILEPROPERTIES:"IfcStructuralProfileProperties",IFCSTRUCTURALLOADSINGLEFORCEWARPING:"IfcStructuralLoadSingleForceWarping",IFCSTRUCTURALLOADSINGLEFORCE:"IfcStructuralLoadSingleForce",IFCSTRUCTURALLOADSINGLEDISPLACEMENTDISTORTION:"IfcStructuralLoadSingleDisplacementDistortion",IFCSTRUCTURALLOADSINGLEDISPLACEMENT:"IfcStructuralLoadSingleDisplacement",IFCSTRUCTURALLOADPLANARFORCE:"IfcStructuralLoadPlanarForce",IFCSTRUCTURALLOADLINEARFORCE:"IfcStructuralLoadLinearForce",IFCSPACETHERMALLOADPROPERTIES:"IfcSpaceThermalLoadProperties",IFCSOUNDVALUE:"IfcSoundValue",IFCSOUNDPROPERTIES:"IfcSoundProperties",IFCSOLIDMODEL:"IfcSolidModel",IFCSLIPPAGECONNECTIONCONDITION:"IfcSlippageConnectionCondition",IFCSHELLBASEDSURFACEMODEL:"IfcShellBasedSurfaceModel",IFCSERVICELIFEFACTOR:"IfcServiceLifeFactor",IFCSECTIONEDSPINE:"IfcSectionedSpine",IFCROUNDEDRECTANGLEPROFILEDEF:"IfcRoundedRectangleProfileDef",IFCRELATIONSHIP:"IfcRelationship",IFCREINFORCEMENTDEFINITIONPROPERTIES:"IfcReinforcementDefinitionProperties",IFCREGULARTIMESERIES:"IfcRegularTimeSeries",IFCRECTANGLEPROFILEDEF:"IfcRectangleProfileDef",IFCPROPERTYTABLEVALUE:"IfcPropertyTableValue",IFCPROPERTYSINGLEVALUE:"IfcPropertySingleValue",IFCPROPERTYSETDEFINITION:"IfcPropertySetDefinition",IFCPROPERTYREFERENCEVALUE:"IfcPropertyReferenceValue",IFCPROPERTYLISTVALUE:"IfcPropertyListValue",IFCPROPERTYENUMERATEDVALUE:"IfcPropertyEnumeratedValue",IFCPROPERTYDEFINITION:"IfcPropertyDefinition",IFCPROPERTYBOUNDEDVALUE:"IfcPropertyBoundedValue",IFCPRODUCTDEFINITIONSHAPE:"IfcProductDefinitionShape",IFCPREDEFINEDPOINTMARKERSYMBOL:"IfcPredefinedPointMarkerSymbol",IFCPREDEFINEDDIMENSIONSYMBOL:"IfcPredefinedDimensionSymbol",IFCPREDEFINEDCURVEFONT:"IfcPredefinedCurveFont",IFCPREDEFINEDCOLOUR:"IfcPredefinedColour",IFCPOLYGONALBOUNDEDHALFSPACE:"IfcPolygonalBoundedHalfSpace",IFCPOLYLOOP:"IfcPolyLoop",IFCPOINTONSURFACE:"IfcPointOnSurface",IFCPOINTONCURVE:"IfcPointOnCurve",IFCPOINT:"IfcPoint",IFCPLANAREXTENT:"IfcPlanarExtent",IFCPLACEMENT:"IfcPlacement",IFCPIXELTEXTURE:"IfcPixelTexture",IFCPHYSICALCOMPLEXQUANTITY:"IfcPhysicalComplexQuantity",IFCPATH:"IfcPath",IFCPARAMETERIZEDPROFILEDEF:"IfcParameterizedProfileDef",IFCORIENTEDEDGE:"IfcOrientedEdge",IFCOPENSHELL:"IfcOpenShell",IFCONEDIRECTIONREPEATFACTOR:"IfcOneDirectionRepeatFactor",IFCOBJECTDEFINITION:"IfcObjectDefinition",IFCMECHANICALCONCRETEMATERIALPROPERTIES:"IfcMechanicalConcreteMaterialProperties",IFCMATERIALDEFINITIONREPRESENTATION:"IfcMaterialDefinitionRepresentation",IFCMAPPEDITEM:"IfcMappedItem",IFCLOOP:"IfcLoop",IFCLOCALPLACEMENT:"IfcLocalPlacement",IFCLIGHTSOURCESPOT:"IfcLightSourceSpot",IFCLIGHTSOURCEPOSITIONAL:"IfcLightSourcePositional",IFCLIGHTSOURCEGONIOMETRIC:"IfcLightSourceGoniometric",IFCLIGHTSOURCEDIRECTIONAL:"IfcLightSourceDirectional",IFCLIGHTSOURCEAMBIENT:"IfcLightSourceAmbient",IFCLIGHTSOURCE:"IfcLightSource",IFCIRREGULARTIMESERIES:"IfcIrregularTimeSeries",IFCIMAGETEXTURE:"IfcImageTexture",IFCHYGROSCOPICMATERIALPROPERTIES:"IfcHygroscopicMaterialProperties",IFCHALFSPACESOLID:"IfcHalfSpaceSolid",IFCGRIDPLACEMENT:"IfcGridPlacement",IFCGEOMETRICSET:"IfcGeometricSet",IFCGEOMETRICREPRESENTATIONSUBCONTEXT:"IfcGeometricRepresentationSubContext",IFCGEOMETRICREPRESENTATIONITEM:"IfcGeometricRepresentationItem",IFCGEOMETRICREPRESENTATIONCONTEXT:"IfcGeometricRepresentationContext",IFCGENERALPROFILEPROPERTIES:"IfcGeneralProfileProperties",IFCGENERALMATERIALPROPERTIES:"IfcGeneralMaterialProperties",IFCFUELPROPERTIES:"IfcFuelProperties",IFCFILLAREASTYLE:"IfcFillAreaStyle",IFCFAILURECONNECTIONCONDITION:"IfcFailureConnectionCondition",IFCFACESURFACE:"IfcFaceSurface",IFCFACEOUTERBOUND:"IfcFaceOuterBound",IFCFACEBOUND:"IfcFaceBound",IFCFACE:"IfcFace",IFCEXTENDEDMATERIALPROPERTIES:"IfcExtendedMaterialProperties",IFCEDGECURVE:"IfcEdgeCurve",IFCEDGE:"IfcEdge",IFCDRAUGHTINGPREDEFINEDTEXTFONT:"IfcDraughtingPredefinedTextFont",IFCDOCUMENTREFERENCE:"IfcDocumentReference",IFCDIMENSIONPAIR:"IfcDimensionPair",IFCDIMENSIONCALLOUTRELATIONSHIP:"IfcDimensionCalloutRelationship",IFCDERIVEDPROFILEDEF:"IfcDerivedProfileDef",IFCCURVESTYLE:"IfcCurveStyle",IFCCONVERSIONBASEDUNIT:"IfcConversionBasedUnit",IFCCONTEXTDEPENDENTUNIT:"IfcContextDependentUnit",IFCCONNECTIONPOINTECCENTRICITY:"IfcConnectionPointEccentricity",IFCCONNECTIONCURVEGEOMETRY:"IfcConnectionCurveGeometry",IFCCONNECTEDFACESET:"IfcConnectedFaceSet",IFCCOMPOSITEPROFILEDEF:"IfcCompositeProfileDef",IFCCOMPLEXPROPERTY:"IfcComplexProperty",IFCCOLOURRGB:"IfcColourRgb",IFCCLASSIFICATIONREFERENCE:"IfcClassificationReference",IFCCENTERLINEPROFILEDEF:"IfcCenterLineProfileDef",IFCBLOBTEXTURE:"IfcBlobTexture",IFCARBITRARYPROFILEDEFWITHVOIDS:"IfcArbitraryProfileDefWithVoids",IFCARBITRARYOPENPROFILEDEF:"IfcArbitraryOpenProfileDef",IFCARBITRARYCLOSEDPROFILEDEF:"IfcArbitraryClosedProfileDef",IFCANNOTATIONTEXTOCCURRENCE:"IfcAnnotationTextOccurrence",IFCANNOTATIONSYMBOLOCCURRENCE:"IfcAnnotationSymbolOccurrence",IFCANNOTATIONSURFACEOCCURRENCE:"IfcAnnotationSurfaceOccurrence",IFCANNOTATIONOCCURRENCE:"IfcAnnotationOccurrence",IFCWATERPROPERTIES:"IfcWaterProperties",IFCVIRTUALGRIDINTERSECTION:"IfcVirtualGridIntersection",IFCVERTEXPOINT:"IfcVertexPoint",IFCVERTEXBASEDTEXTUREMAP:"IfcVertexBasedTextureMap",IFCVERTEX:"IfcVertex",IFCUNITASSIGNMENT:"IfcUnitAssignment",IFCTOPOLOGYREPRESENTATION:"IfcTopologyRepresentation",IFCTOPOLOGICALREPRESENTATIONITEM:"IfcTopologicalRepresentationItem",IFCTIMESERIESVALUE:"IfcTimeSeriesValue",IFCTIMESERIESREFERENCERELATIONSHIP:"IfcTimeSeriesReferenceRelationship",IFCTIMESERIES:"IfcTimeSeries",IFCTHERMALMATERIALPROPERTIES:"IfcThermalMaterialProperties",IFCTEXTUREVERTEX:"IfcTextureVertex",IFCTEXTUREMAP:"IfcTextureMap",IFCTEXTURECOORDINATEGENERATOR:"IfcTextureCoordinateGenerator",IFCTEXTURECOORDINATE:"IfcTextureCoordinate",IFCTEXTSTYLEWITHBOXCHARACTERISTICS:"IfcTextStyleWithBoxCharacteristics",IFCTEXTSTYLETEXTMODEL:"IfcTextStyleTextModel",IFCTEXTSTYLEFORDEFINEDFONT:"IfcTextStyleForDefinedFont",IFCTEXTSTYLEFONTMODEL:"IfcTextStyleFontModel",IFCTEXTSTYLE:"IfcTextStyle",IFCTELECOMADDRESS:"IfcTelecomAddress",IFCTABLEROW:"IfcTableRow",IFCTABLE:"IfcTable",IFCSYMBOLSTYLE:"IfcSymbolStyle",IFCSURFACETEXTURE:"IfcSurfaceTexture",IFCSURFACESTYLEWITHTEXTURES:"IfcSurfaceStyleWithTextures",IFCSURFACESTYLESHADING:"IfcSurfaceStyleShading",IFCSURFACESTYLEREFRACTION:"IfcSurfaceStyleRefraction",IFCSURFACESTYLELIGHTING:"IfcSurfaceStyleLighting",IFCSURFACESTYLE:"IfcSurfaceStyle",IFCSTYLEDREPRESENTATION:"IfcStyledRepresentation",IFCSTYLEDITEM:"IfcStyledItem",IFCSTYLEMODEL:"IfcStyleModel",IFCSTRUCTURALLOADTEMPERATURE:"IfcStructuralLoadTemperature",IFCSTRUCTURALLOADSTATIC:"IfcStructuralLoadStatic",IFCSTRUCTURALLOAD:"IfcStructuralLoad",IFCSTRUCTURALCONNECTIONCONDITION:"IfcStructuralConnectionCondition",IFCSIMPLEPROPERTY:"IfcSimpleProperty",IFCSHAPEREPRESENTATION:"IfcShapeRepresentation",IFCSHAPEMODEL:"IfcShapeModel",IFCSHAPEASPECT:"IfcShapeAspect",IFCSECTIONREINFORCEMENTPROPERTIES:"IfcSectionReinforcementProperties",IFCSECTIONPROPERTIES:"IfcSectionProperties",IFCSIUNIT:"IfcSIUnit",IFCROOT:"IfcRoot",IFCRIBPLATEPROFILEPROPERTIES:"IfcRibPlateProfileProperties",IFCREPRESENTATIONMAP:"IfcRepresentationMap",IFCREPRESENTATIONITEM:"IfcRepresentationItem",IFCREPRESENTATIONCONTEXT:"IfcRepresentationContext",IFCREPRESENTATION:"IfcRepresentation",IFCRELAXATION:"IfcRelaxation",IFCREINFORCEMENTBARPROPERTIES:"IfcReinforcementBarProperties",IFCREFERENCESVALUEDOCUMENT:"IfcReferencesValueDocument",IFCQUANTITYWEIGHT:"IfcQuantityWeight",IFCQUANTITYVOLUME:"IfcQuantityVolume",IFCQUANTITYTIME:"IfcQuantityTime",IFCQUANTITYLENGTH:"IfcQuantityLength",IFCQUANTITYCOUNT:"IfcQuantityCount",IFCQUANTITYAREA:"IfcQuantityArea",IFCPROPERTYENUMERATION:"IfcPropertyEnumeration",IFCPROPERTYDEPENDENCYRELATIONSHIP:"IfcPropertyDependencyRelationship",IFCPROPERTYCONSTRAINTRELATIONSHIP:"IfcPropertyConstraintRelationship",IFCPROPERTY:"IfcProperty",IFCPROFILEPROPERTIES:"IfcProfileProperties",IFCPROFILEDEF:"IfcProfileDef",IFCPRODUCTSOFCOMBUSTIONPROPERTIES:"IfcProductsOfCombustionProperties",IFCPRODUCTREPRESENTATION:"IfcProductRepresentation",IFCPRESENTATIONSTYLEASSIGNMENT:"IfcPresentationStyleAssignment",IFCPRESENTATIONSTYLE:"IfcPresentationStyle",IFCPRESENTATIONLAYERWITHSTYLE:"IfcPresentationLayerWithStyle",IFCPRESENTATIONLAYERASSIGNMENT:"IfcPresentationLayerAssignment",IFCPREDEFINEDTEXTFONT:"IfcPredefinedTextFont",IFCPREDEFINEDTERMINATORSYMBOL:"IfcPredefinedTerminatorSymbol",IFCPREDEFINEDSYMBOL:"IfcPredefinedSymbol",IFCPREDEFINEDITEM:"IfcPredefinedItem",IFCPOSTALADDRESS:"IfcPostalAddress",IFCPHYSICALSIMPLEQUANTITY:"IfcPhysicalSimpleQuantity",IFCPHYSICALQUANTITY:"IfcPhysicalQuantity",IFCPERSONANDORGANIZATION:"IfcPersonAndOrganization",IFCPERSON:"IfcPerson",IFCOWNERHISTORY:"IfcOwnerHistory",IFCORGANIZATIONRELATIONSHIP:"IfcOrganizationRelationship",IFCORGANIZATION:"IfcOrganization",IFCOPTICALMATERIALPROPERTIES:"IfcOpticalMaterialProperties",IFCOBJECTIVE:"IfcObjective",IFCOBJECTPLACEMENT:"IfcObjectPlacement",IFCNAMEDUNIT:"IfcNamedUnit",IFCMONETARYUNIT:"IfcMonetaryUnit",IFCMETRIC:"IfcMetric",IFCMECHANICALSTEELMATERIALPROPERTIES:"IfcMechanicalSteelMaterialProperties",IFCMECHANICALMATERIALPROPERTIES:"IfcMechanicalMaterialProperties",IFCMEASUREWITHUNIT:"IfcMeasureWithUnit",IFCMATERIALPROPERTIES:"IfcMaterialProperties",IFCMATERIALLIST:"IfcMaterialList",IFCMATERIALLAYERSETUSAGE:"IfcMaterialLayerSetUsage",IFCMATERIALLAYERSET:"IfcMaterialLayerSet",IFCMATERIALLAYER:"IfcMaterialLayer",IFCMATERIALCLASSIFICATIONRELATIONSHIP:"IfcMaterialClassificationRelationship",IFCMATERIAL:"IfcMaterial",IFCLOCALTIME:"IfcLocalTime",IFCLIGHTINTENSITYDISTRIBUTION:"IfcLightIntensityDistribution",IFCLIGHTDISTRIBUTIONDATA:"IfcLightDistributionData",IFCLIBRARYREFERENCE:"IfcLibraryReference",IFCLIBRARYINFORMATION:"IfcLibraryInformation",IFCIRREGULARTIMESERIESVALUE:"IfcIrregularTimeSeriesValue",IFCGRIDAXIS:"IfcGridAxis",IFCEXTERNALLYDEFINEDTEXTFONT:"IfcExternallyDefinedTextFont",IFCEXTERNALLYDEFINEDSYMBOL:"IfcExternallyDefinedSymbol",IFCEXTERNALLYDEFINEDSURFACESTYLE:"IfcExternallyDefinedSurfaceStyle",IFCEXTERNALLYDEFINEDHATCHSTYLE:"IfcExternallyDefinedHatchStyle",IFCEXTERNALREFERENCE:"IfcExternalReference",IFCENVIRONMENTALIMPACTVALUE:"IfcEnvironmentalImpactValue",IFCDRAUGHTINGCALLOUTRELATIONSHIP:"IfcDraughtingCalloutRelationship",IFCDOCUMENTINFORMATIONRELATIONSHIP:"IfcDocumentInformationRelationship",IFCDOCUMENTINFORMATION:"IfcDocumentInformation",IFCDOCUMENTELECTRONICFORMAT:"IfcDocumentElectronicFormat",IFCDIMENSIONALEXPONENTS:"IfcDimensionalExponents",IFCDERIVEDUNITELEMENT:"IfcDerivedUnitElement",IFCDERIVEDUNIT:"IfcDerivedUnit",IFCDATEANDTIME:"IfcDateAndTime",IFCCURVESTYLEFONTPATTERN:"IfcCurveStyleFontPattern",IFCCURVESTYLEFONTANDSCALING:"IfcCurveStyleFontAndScaling",IFCCURVESTYLEFONT:"IfcCurveStyleFont",IFCCURRENCYRELATIONSHIP:"IfcCurrencyRelationship",IFCCOSTVALUE:"IfcCostValue",IFCCOORDINATEDUNIVERSALTIMEOFFSET:"IfcCoordinatedUniversalTimeOffset",IFCCONSTRAINTRELATIONSHIP:"IfcConstraintRelationship",IFCCONSTRAINTCLASSIFICATIONRELATIONSHIP:"IfcConstraintClassificationRelationship",IFCCONSTRAINTAGGREGATIONRELATIONSHIP:"IfcConstraintAggregationRelationship",IFCCONSTRAINT:"IfcConstraint",IFCCONNECTIONSURFACEGEOMETRY:"IfcConnectionSurfaceGeometry",IFCCONNECTIONPORTGEOMETRY:"IfcConnectionPortGeometry",IFCCONNECTIONPOINTGEOMETRY:"IfcConnectionPointGeometry",IFCCONNECTIONGEOMETRY:"IfcConnectionGeometry",IFCCOLOURSPECIFICATION:"IfcColourSpecification",IFCCLASSIFICATIONNOTATIONFACET:"IfcClassificationNotationFacet",IFCCLASSIFICATIONNOTATION:"IfcClassificationNotation",IFCCLASSIFICATIONITEMRELATIONSHIP:"IfcClassificationItemRelationship",IFCCLASSIFICATIONITEM:"IfcClassificationItem",IFCCLASSIFICATION:"IfcClassification",IFCCALENDARDATE:"IfcCalendarDate",IFCBOUNDARYNODECONDITIONWARPING:"IfcBoundaryNodeConditionWarping",IFCBOUNDARYNODECONDITION:"IfcBoundaryNodeCondition",IFCBOUNDARYFACECONDITION:"IfcBoundaryFaceCondition",IFCBOUNDARYEDGECONDITION:"IfcBoundaryEdgeCondition",IFCBOUNDARYCONDITION:"IfcBoundaryCondition",IFCAPPROVALRELATIONSHIP:"IfcApprovalRelationship",IFCAPPROVALPROPERTYRELATIONSHIP:"IfcApprovalPropertyRelationship",IFCAPPROVALACTORRELATIONSHIP:"IfcApprovalActorRelationship",IFCAPPROVAL:"IfcApproval",IFCAPPLIEDVALUERELATIONSHIP:"IfcAppliedValueRelationship",IFCAPPLIEDVALUE:"IfcAppliedValue",IFCAPPLICATION:"IfcApplication",IFCADDRESS:"IfcAddress",IFCACTORROLE:"IfcActorRole"};class Hr{constructor(){t(this,"factor",1),t(this,"complement",1)}apply(e){const t=this.getScaleMatrix().multiply(e);e.copy(t)}setUp(e){var t,i,s;this.factor=1;const n=this.getLengthUnits(e);if(!n)return;const r=null==n,o=void 0===n.Name||null===n.Name;r||o||("FOOT"===n.Name.value&&(this.factor=.3048),"MILLI"===(null==(t=n.Prefix)?void 0:t.value)?this.complement=.001:("CENTI"===(null==(i=n.Prefix)?void 0:i.value)||"DECI"===(null==(s=n.Prefix)?void 0:s.value))&&(this.complement=.01))}getLengthUnits(e){try{const t=e.GetLineIDsWithType(0,x.IFCUNITASSIGNMENT).get(0),i=e.GetLine(0,t);for(const t of i.Units){if(!t||null===t.value||void 0===t.value)continue;const i=e.GetLine(0,t.value);if(i.UnitType&&"LENGTHUNIT"===i.UnitType.value)return i}return null}catch(e){return console.log("Could not get units"),null}}getScaleMatrix(){const e=this.factor;return(new i.Matrix4).fromArray([e,0,0,0,0,e,0,0,0,0,e,0,0,0,0,1])}}class Wr{constructor(){t(this,"itemsByFloor",{}),t(this,"_units",new Hr)}setUp(e){this._units.setUp(e),this.cleanUp();try{const t=e.GetLineIDsWithType(0,x.IFCRELCONTAINEDINSPATIALSTRUCTURE),i=new Set,s=e.GetLineIDsWithType(0,x.IFCSPACE);for(let e=0;e<s.size();e++)i.add(s.get(e));const n=e.GetLineIDsWithType(0,x.IFCRELAGGREGATES),r=n.size();for(let t=0;t<r;t++){const s=n.get(t),r=e.GetLine(0,s);if(!r||!r.RelatingObject||!r.RelatedObjects)continue;const o=r.RelatingObject.value,a=r.RelatedObjects;for(const e of a){const t=e.value;i.has(t)&&(this.itemsByFloor[t]=o)}}const o={},a=t.size();for(let s=0;s<a;s++){const n=t.get(s),r=e.GetLine(0,n);if(!r||!r.RelatingStructure||!r.RelatedElements)continue;const a=r.RelatingStructure.value,c=r.RelatedElements;if(i.has(a))for(const e of c){o[a]||(o[a]=[]);const t=e.value;o[a].push(t)}else for(const e of c){const t=e.value;this.itemsByFloor[t]=a}}for(const e in o){const t=this.itemsByFloor[e];if(void 0!==t){const i=o[e];for(const e of i)this.itemsByFloor[e]=t}}for(let t=0;t<r;t++){const i=n.get(t),s=e.GetLine(0,i);if(!s||!s.RelatingObject||!s.RelatedObjects)continue;const r=s.RelatingObject.value,o=s.RelatedObjects;for(const e of o){const t=e.value,i=this.itemsByFloor[r];void 0!==i&&(this.itemsByFloor[t]=i)}}}catch(e){console.log("Could not get floors.")}}cleanUp(){this.itemsByFloor={}}}class Xr{constructor(){t(this,"includeProperties",!0),t(this,"optionalCategories",[x.IFCSPACE]),t(this,"wasm",{path:"",absolute:!1,logLevel:x.LogLevel.LOG_LEVEL_OFF}),t(this,"excludedCategories",new Set),t(this,"includedCategories",new Set),t(this,"saveLocations",!1),t(this,"webIfc",{COORDINATE_TO_ORIGIN:!0}),t(this,"autoSetWasm",!0),t(this,"customLocateFileHandler",null)}}class Zr{constructor(){t(this,"defLineMat",new i.LineBasicMaterial({color:16777215}))}read(e){const t={IfcAlignment:e.GetAllAlignments(0),IfcCrossSection2D:e.GetAllCrossSections2D(0),IfcCrossSection3D:e.GetAllCrossSections3D(0)};return this.get(t)}get(e){if(e.IfcAlignment){const t=new Map;for(const i of e.IfcAlignment){const e=new M.AlignmentObject;e.absolute=this.getCurves(i.curve3D,e),e.horizontal=this.getCurves(i.horizontal,e),e.vertical=this.getCurves(i.vertical,e),t.set(t.size,e)}return{alignments:t,coordinationMatrix:new i.Matrix4}}}getCurves(e,t){const s=[];let n=0;for(const r of e){const e={};if(r.data)for(const t of r.data){const[i,s]=t.split(": "),n=parseFloat(s);e[i]=n||s}const{points:o}=r,a=new Float32Array(3*o.length);for(let e=0;e<o.length;e++){const{x:t,y:i,z:s}=o[e];a[3*e]=t,a[3*e+1]=i,a[3*e+2]=s||0}const c=new i.BufferAttribute(a,3),l=new i.EdgesGeometry;l.setAttribute("position",c);const h=new M.CurveMesh(n,e,t,l,this.defLineMat);s.push(h.curve),n++}return s}}class $r{getNameInfo(e){var t;const i={},{arguments:s}=e.GetHeaderLine(0,x.FILE_NAME)||{};if(!s)return i;const[n,r,o,a,c,l,h]=s;if((null==n?void 0:n.value)&&(i.name=n.value),(null==r?void 0:r.value)&&(i.creationDate=new Date(r.value)),o){i.author={};const[e,t]=o;(null==e?void 0:e.value)&&(i.author.name=e.value),(null==t?void 0:t.value)&&(i.author.email=t.value)}return a&&(null==(t=a[0])?void 0:t.value)&&(i.organization=a[0].value),(null==c?void 0:c.value)&&(i.preprocessorVersion=null==c?void 0:c.value),(null==l?void 0:l.value)&&(i.originatingSystem=null==l?void 0:l.value),(null==h?void 0:h.value)&&(i.authorization=null==h?void 0:h.value),i}getDescriptionInfo(e){var t;const i={},{arguments:s}=e.GetHeaderLine(0,x.FILE_DESCRIPTION)||{};if(!s)return i;const[n,r]=s;if(Array.isArray(n)&&(null==(t=n[0])?void 0:t.value)){const e=n[0].value.match(/\[([^\]]+)\]/);e&&e[1]&&(i.viewDefinition=e[1])}return(null==r?void 0:r.value)&&(i.implementationLevel=r.value),i}}class jr{static get(e,t){const i=[x.IFCPROJECT,x.IFCSITE,x.IFCBUILDING,x.IFCBUILDINGSTOREY,x.IFCSPACE,x.IFCROAD,x.IFCFACILITY,x.IFCFACILITYPART,x.IFCBRIDGE],s=e.data;for(const e of i){const i=t.GetLineIDsWithType(0,e),n=i.size();for(let t=0;t<n;t++){const n=i.get(t);s.has(n)||s.set(n,[[],[0,e]])}}}}const qr=new Set([1123145078,574549367,1675464909,2059837836,3798115385,32440307,3125803723,3207858831,2740243338,2624227202,4240577450,3615266464,3724593414,220341763,477187591,1878645084,1300840506,3303107099,1607154358,1878645084,846575682,1351298697,2417041796,3049322572,3331915920,1416205885,776857604,3285139300,3958052878,2827736869,2732653382,673634403,3448662350,4142052618,2924175390,803316827,2556980723,1809719519,2205249479,807026263,3737207727,1660063152,2347385850,2705031697,3732776249,2485617015,2611217952,1704287377,2937912522,2770003689,1281925730,1484403080,3448662350,4142052618,3800577675,4006246654,3590301190,1383045692,2775532180,2047409740,370225590,3593883385,2665983363,4124623270,812098782,3649129432,987898635,1105321065,3510044353,1635779807,2603310189,3406155212,1310608509,4261334040,2736907675,3649129432,1136057603,1260505505,4182860854,2713105998,2898889636,59481748,3749851601,3486308946,3150382593,1062206242,3264961684,15328376,1485152156,370225590,1981873012,2859738748,45288368,2614616156,2732653382,775493141,2147822146,2601014836,2629017746,1186437898,2367409068,1213902940,3632507154,3900360178,476780140,1472233963,2804161546,3008276851,738692330,374418227,315944413,3905492369,3570813810,2571569899,178912537,2294589976,1437953363,2133299955,572779678,3092502836,388784114,2624227202,1425443689,3057273783,2347385850,1682466193,2519244187,2839578677,3958567839,2513912981,2830218821,427810014,2916149573]),Qr=class e extends ui{constructor(i){super(i),t(this,"enabled",!0),i.add(e.uuid,this)}async export(e,t,i=!1,s=!0){const n={},r=new Set(e.GetIfcEntityList(t)),o=new Set([x.IFCPROJECT,x.IFCSITE,x.IFCBUILDING,x.IFCBUILDINGSTOREY,x.IFCSPACE]);for(const e of o)r.add(e);for(const a of r){if(qr.has(a))continue;const r=o.has(a)&&s,c=e.GetLineIDsWithType(t,a);for(const t of c)try{const s=e.GetLine(0,t,r,i);n[s.expressID]=s}catch(e){console.log(`Could not get property ${t}, with recursive ${r} and indirect ${i}.`)}}return n}};t(Qr,"uuid","b32c4332-cd67-436e-ba7f-196646c7a635");let Kr=Qr;const Jr=class e extends ui{constructor(s){super(s),t(this,"onDisposed",new ci),t(this,"onIfcStartedLoading",new ci),t(this,"onSetup",new ci),t(this,"settings",new Xr),t(this,"webIfc",new x.IfcAPI),t(this,"enabled",!0),t(this,"_material",new i.MeshLambertMaterial),t(this,"_spatialTree",new Wr),t(this,"_metaData",new $r),t(this,"_fragmentInstances",new Map),t(this,"_civil",new Zr),t(this,"_visitedFragments",new Map),t(this,"_materialT",new i.MeshLambertMaterial({transparent:!0,opacity:.5})),this.components.add(e.uuid,this),this.settings.excludedCategories.add(x.IFCOPENINGELEMENT)}dispose(){this.webIfc=null,this.onDisposed.trigger(e.uuid),this.onDisposed.reset()}async setup(e){this.settings={...this.settings,...e},this.settings.autoSetWasm&&await this.autoSetWasm(),this.onSetup.trigger()}async load(e,t=!0,i=""){const s=performance.now();this.onIfcStartedLoading.trigger(),await this.readIfcFile(e);const n=await this.getAllGeometries();n.name=i;const r=this.components.get(Kr),o=await r.export(this.webIfc,0);n.setLocalProperties(o);const a=this.components.get(co);a.groups.set(n.uuid,n);for(const e of n.items)a.list.set(e.id,e),e.mesh.uuid=e.id,e.group=n;a.onFragmentsLoaded.trigger(n),t&&a.coordinate([n]);for(const[e]of n.data){const t=o[e];if(!t||!t.GlobalId)continue;const i=t.GlobalId.value||t.GlobalId;n.globalToExpressIDs.set(i,e)}return jr.get(n,this.webIfc),this.cleanUp(),console.log(`Streaming the IFC took ${performance.now()-s} ms!`),n}async readIfcFile(e){const{path:t,absolute:i,logLevel:s}=this.settings.wasm;return this.webIfc.SetWasmPath(t,i),await this.webIfc.Init(this.settings.customLocateFileHandler||void 0),s&&this.webIfc.SetLogLevel(s),this.webIfc.OpenModel(e,this.settings.webIfc)}cleanUp(){try{this.webIfc.Dispose()}catch(e){console.log("Web-ifc wasn't disposed.")}this.webIfc=null,this.webIfc=new x.IfcAPI,this._visitedFragments.clear(),this._fragmentInstances.clear()}async getAllGeometries(){this._spatialTree.setUp(this.webIfc);const e=this.webIfc.GetIfcEntityList(0),t=new M.FragmentsGroup;t.ifcMetadata={name:"",description:"",...this._metaData.getNameInfo(this.webIfc),...this._metaData.getDescriptionInfo(this.webIfc),schema:this.webIfc.GetModelSchema(0)||"IFC2X3",maxExpressID:this.webIfc.GetMaxExpressID(0)};const i=[];for(const s of e){if(!this.webIfc.IsIfcElement(s)&&s!==x.IFCSPACE)continue;const e=this.settings.includedCategories;if(e.size>0&&!e.has(s))continue;if(this.settings.excludedCategories.has(s))continue;const n=this.webIfc.GetLineIDsWithType(0,s),r=n.size();for(let e=0;e<r;e++){const r=n.get(e);i.push(r);const o=this._spatialTree.itemsByFloor[r]||0;t.data.set(r,[[],[o,s]])}}this._spatialTree.cleanUp(),this.webIfc.StreamMeshes(0,i,(e=>{this.getMesh(e,t)}));for(const e of this._visitedFragments){const{index:i,fragment:s}=e[1];t.keyFragments.set(i,s.id)}for(const e of t.items){const t=this._fragmentInstances.get(e.id);if(!t)throw new Error("Fragment not found!");const i=[];for(const[e,s]of t)i.push(s);e.add(i)}const s=this.webIfc.GetCoordinationMatrix(0);return t.coordinationMatrix.fromArray(s),t.civilData=this._civil.read(this.webIfc),t}getMesh(e,t){const s=e.geometries.size(),n=e.expressID;for(let r=0;r<s;r++){const s=e.geometries.get(r),{x:o,y:a,z:c,w:l}=s.color,h=1!==l,{geometryExpressID:u}=s,I=`${u}-${h}`;if(!this._visitedFragments.has(I)){const e=this.getGeometry(this.webIfc,u),i=h?this._materialT:this._material,s=new M.Fragment(e,i,1);t.add(s.mesh),t.items.push(s);const n=this._visitedFragments.size;this._visitedFragments.set(I,{index:n,fragment:s})}const d=(new i.Color).setRGB(o,a,c,"srgb"),E=new i.Matrix4;E.fromArray(s.flatTransformation);const f=this._visitedFragments.get(I);if(void 0===f)throw new Error("Error getting geometry data for streaming!");const p=t.data.get(n);if(!p)throw new Error("Data not found!");p[0].push(f.index);const{fragment:C}=f;this._fragmentInstances.has(C.id)||this._fragmentInstances.set(C.id,new Map);const T=this._fragmentInstances.get(C.id);if(!T)throw new Error("Instances not found!");if(T.has(n)){const e=T.get(n);if(!e)throw new Error("Instance not found!");e.transforms.push(E),e.colors&&e.colors.push(d)}else T.set(n,{id:n,transforms:[E],colors:[d]})}}getGeometry(e,t){const s=e.GetGeometry(0,t),n=e.GetIndexArray(s.GetIndexData(),s.GetIndexDataSize()),r=e.GetVertexArray(s.GetVertexData(),s.GetVertexDataSize()),o=new Float32Array(r.length/2),a=new Float32Array(r.length/2);for(let e=0;e<r.length;e+=6)o[e/2]=r[e],o[e/2+1]=r[e+1],o[e/2+2]=r[e+2],a[e/2]=r[e+3],a[e/2+1]=r[e+4],a[e/2+2]=r[e+5];const c=new i.BufferGeometry,l=new i.BufferAttribute(o,3),h=new i.BufferAttribute(a,3);return c.setAttribute("position",l),c.setAttribute("normal",h),c.setIndex(Array.from(n)),s.delete(),c}async autoSetWasm(){const e=await fetch(`https://unpkg.com/@thatopen/components@${Fs.release}/package.json`);if(!e.ok)return void console.warn("Couldn't get openbim-components package.json. Set wasm settings manually.");const t=await e.json();if("web-ifc"in t.peerDependencies){const e=t.peerDependencies["web-ifc"];this.settings.wasm.path=`https://unpkg.com/web-ifc@${e}/`,this.settings.wasm.absolute=!0}else console.warn("Couldn't get web-ifc from peer dependencies in openbim-components. Set wasm settings manually.")}};t(Jr,"uuid","a659add7-1418-4771-a0d6-7d4d438e4624");let eo=Jr;const to={IfcRelAssignsToControl:{related:5,relating:7},IfcRelAssignsToGroup:{related:5,relating:7},IfcRelAssignsToProduct:{related:5,relating:7},IfcRelAssociatesClassification:{related:5,relating:6},IfcRelAssociatesMaterial:{related:5,relating:6},IfcRelAssociatesDocument:{related:5,relating:6},IfcRelContainedInSpatialStructure:{related:5,relating:6},IfcRelFlowControlElements:{related:5,relating:6},IfcRelConnectsElements:{related:7,relating:6},IfcRelDeclares:{related:6,relating:5},IfcRelAggregates:{related:6,relating:5},IfcRelNests:{related:6,relating:5},IfcRelDefinesByProperties:{related:5,relating:6},IfcRelDefinesByType:{related:5,relating:6},IfcRelDefinesByTemplate:{related:5,relating:6}},io={[x.IFCRELASSIGNSTOCONTROL]:"IfcRelAssignsToControl",[x.IFCRELASSIGNSTOGROUP]:"IfcRelAssignsToGroup",[x.IFCRELASSIGNSTOPRODUCT]:"IfcRelAssignsToProduct",[x.IFCRELASSOCIATESCLASSIFICATION]:"IfcRelAssociatesClassification",[x.IFCRELASSOCIATESMATERIAL]:"IfcRelAssociatesMaterial",[x.IFCRELASSOCIATESDOCUMENT]:"IfcRelAssociatesDocument",[x.IFCRELCONTAINEDINSPATIALSTRUCTURE]:"IfcRelContainedInSpatialStructure",[x.IFCRELCONNECTSELEMENTS]:"IfcRelConnectsElements",[x.IFCRELFLOWCONTROLELEMENTS]:"IfcRelFlowControlElements",[x.IFCRELDECLARES]:"IfcRelDeclares",[x.IFCRELAGGREGATES]:"IfcRelAggregates",[x.IFCRELNESTS]:"IfcRelNests",[x.IFCRELDEFINESBYPROPERTIES]:"IfcRelDefinesByProperties",[x.IFCRELDEFINESBYTYPE]:"IfcRelDefinesByType",[x.IFCRELDEFINESBYTEMPLATE]:"IfcRelDefinesByTemplate"},so=class e extends ui{constructor(i){super(i),t(this,"onDisposed",new ci),t(this,"onRequestFile",new ci),t(this,"ifcToExport",null),t(this,"onElementToPset",new ci),t(this,"onPropToPset",new ci),t(this,"onPsetRemoved",new ci),t(this,"onDataChanged",new ci),t(this,"wasm",{path:"/",absolute:!1}),t(this,"enabled",!0),t(this,"attributeListeners",{}),t(this,"selectedModel"),t(this,"changeMap",{}),this.components.add(e.uuid,this)}dispose(){this.selectedModel=void 0,this.attributeListeners={},this.changeMap={},this.onElementToPset.reset(),this.onPropToPset.reset(),this.onPsetRemoved.reset(),this.onDataChanged.reset(),this.onDisposed.trigger(e.uuid),this.onDisposed.reset()}static getIFCSchema(e){const t=e.ifcMetadata.schema;if(!t)throw new Error("IFC Schema not found");return t.startsWith("IFC2X3")?"IFC2X3":t.startsWith("IFC4")&&""===t.replace("IFC4","")?"IFC4":t.startsWith("IFC4X3")?"IFC4X3":t}async setData(e,...t){for(const i of t){const{expressID:t}=i;t&&-1!==t||(i.expressID=this.getNewExpressID(e)),await e.setProperties(i.expressID,i),this.registerChange(e,i.expressID)}}async newPset(t,i,s){const n=e.getIFCSchema(t),{handle:r}=await this.getOwnerHistory(t),o=this.newGUID(t),a=new x[n].IfcLabel(i),c=s?new x[n].IfcText(s):null,l=new x[n].IfcPropertySet(o,r,a,c,[]);return l.expressID=this.getNewExpressID(t),await this.setData(t,l),{pset:l}}async removePset(e,...t){for(const i of t){const t=await e.getProperties(i);if((null==t?void 0:t.type)!==x.IFCPROPERTYSET)continue;const s=await zr.getPsetRel(e,i);if(s&&(await e.setProperties(s,null),this.registerChange(e,s)),t){for(const i of t.HasProperties)await e.setProperties(i.value,null);await e.setProperties(i,null),this.onPsetRemoved.trigger({model:e,psetID:i}),this.registerChange(e,i)}}}newSingleStringProperty(e,t,i,s){return this.newSingleProperty(e,t,i,s)}newSingleNumericProperty(e,t,i,s){return this.newSingleProperty(e,t,i,s)}newSingleBooleanProperty(e,t,i,s){return this.newSingleProperty(e,t,i,s)}async removePsetProp(e,t,i){const s=await e.getProperties(t),n=await e.getProperties(i);s&&n&&s.type===x.IFCPROPERTYSET&&n&&(s.HasProperties=s.HasProperties.filter((e=>e.value!==i)),await e.setProperties(i,null),this.registerChange(e,t,i))}addElementToPset(e,t,...i){this.components.get(oo).addEntitiesRelation(e,t,{type:x.IFCRELDEFINESBYPROPERTIES,inv:"DefinesOcurrence"},...i)}async addPropToPset(e,t,...i){const s=await e.getProperties(t);if(s){for(const n of i){if(s.HasProperties.includes(n))continue;const i=new x.Handle(n);s.HasProperties.push(i),this.onPropToPset.trigger({model:e,psetID:t,propID:n})}this.registerChange(e,t)}}async createIfcRel(t,i,s,n){const r=io[i];if(!r)throw new Error(`IfcPropertiesManager: ${r} is unsoported.`);const o=e.getIFCSchema(t),a=to[r],c=x[o][r];if(!a||!c)throw new Error(`IfcPropertiesManager: ${r} is unsoported.`);const l=[new x[o].IfcGloballyUniqueId(ki.create())],{related:h,relating:u}=a,I=[...new Set(n)].map((e=>new x.Handle(e))),d=(e,t)=>{for(let i=e;i<t-1;i++)l.push(null)};h<u?(d(1,h),l.push(I),d(h,u),l.push(new x.Handle(s))):(d(1,u),d(u,h),l.push(new x.Handle(s)),l.push(I));const E=new c(...l);return await this.setData(t,E),E}async saveToIfc(e,t){const i=this.components.get(eo),s=i.webIfc,n=await i.readIfcFile(t),r=this.components.get(oo);await r.applyRelationChanges();const o=this.changeMap[e.uuid]??[];for(const t of o){const i=await e.getProperties(t);if(i)s.WriteLine(n,i);else{s.GetLine(n,t)&&s.DeleteLine(n,t)}}const a=s.SaveModel(n);return i.webIfc.CloseModel(n),i.cleanUp(),a}async getEntityRef(e,t){const i=await e.getAllPropertiesOfType(t);if(!i)return null;const s=[];for(const e in i){const t=new x.Handle(Number(e));s.push(t)}return s}async setAttributeListener(e,t,i){this.attributeListeners[e.uuid]||(this.attributeListeners[e.uuid]={});const s=this.attributeListeners[e.uuid][t]?this.attributeListeners[e.uuid][t][i]:null;if(s)return s;const n=await e.getProperties(t);if(!n)throw new Error(`Entity with expressID ${t} doesn't exists.`);const r=n[i];if(Array.isArray(r)||!r)throw new Error(`Attribute ${i} is array or null, and it can't have a listener.`);const o=r.value;if(void 0===o||null==o)throw new Error(`Attribute ${i} has a badly defined handle.`);const a=new ci;return Object.defineProperty(n[i],"value",{get(){return this._value},async set(e){this._value=e,a.trigger(e)}}),n[i].value=o,this.attributeListeners[e.uuid][t]||(this.attributeListeners[e.uuid][t]={}),this.attributeListeners[e.uuid][t][i]=a,a}getNewExpressID(e){return e.ifcMetadata.maxExpressID++,e.ifcMetadata.maxExpressID}newGUID(t){const i=e.getIFCSchema(t);return new x[i].IfcGloballyUniqueId(ki.create())}async getOwnerHistory(e){const t=await e.getAllPropertiesOfType(x.IFCOWNERHISTORY);if(!t)throw new Error("No OwnerHistory was found.");const i=t[Object.keys(t).map((e=>parseInt(e,10)))[0]];return{entity:i,handle:new x.Handle(i.expressID)}}registerChange(e,...t){this.changeMap[e.uuid]||(this.changeMap[e.uuid]=new Set);for(const i of t)this.changeMap[e.uuid].add(i),this.onDataChanged.trigger({model:e,expressID:i})}async newSingleProperty(t,i,s,n){const r=e.getIFCSchema(t),o=new x[r].IfcIdentifier(s),a=new x[r][i](n),c=new x[r].IfcPropertySingleValue(o,null,a,null);return c.expressID=this.getNewExpressID(t),await this.setData(t,c),c}};t(so,"uuid","58c2d9f0-183c-48d6-a402-dfcf5b9a34df");let no=so;const ro=class e extends ui{constructor(i){super(i),t(this,"onDisposed",new ci),t(this,"onRelationsIndexed",new ci),t(this,"relationMaps",{}),t(this,"enabled",!0),t(this,"_relToAttributesMap",Br),t(this,"_inverseAttributes",["IsDecomposedBy","Decomposes","AssociatedTo","HasAssociations","ClassificationForObjects","IsGroupedBy","HasAssignments","IsDefinedBy","DefinesOcurrence","IsTypedBy","Types","Defines","ContainedInStructure","ContainsElements","HasControlElements","AssignedToFlowElement","ConnectedTo","ConnectedFrom","ReferencedBy","Declares","HasContext","Controls","IsNestedBy","Nests","DocumentRefForObjects"]),t(this,"_ifcRels",[x.IFCRELAGGREGATES,x.IFCRELASSOCIATESMATERIAL,x.IFCRELASSOCIATESCLASSIFICATION,x.IFCRELASSIGNSTOGROUP,x.IFCRELDEFINESBYPROPERTIES,x.IFCRELDEFINESBYTYPE,x.IFCRELDEFINESBYTEMPLATE,x.IFCRELCONTAINEDINSPATIALSTRUCTURE,x.IFCRELFLOWCONTROLELEMENTS,x.IFCRELCONNECTSELEMENTS,x.IFCRELASSIGNSTOPRODUCT,x.IFCRELDECLARES,x.IFCRELASSIGNSTOCONTROL,x.IFCRELNESTS,x.IFCRELASSOCIATESDOCUMENT]),t(this,"onFragmentsDisposed",(e=>{delete this.relationMaps[e.groupID]})),t(this,"_changeMap",{}),t(this,"onEntitiesRelated",new ci),this.components.add(e.uuid,this);i.get(co).onFragmentsDisposed.add(this.onFragmentsDisposed)}indexRelations(e,t,i,s){const n=Object.keys(t).find((e=>e.startsWith("Relating"))),r=Object.keys(t).find((e=>e.startsWith("Related")));if(!n||!r)return;const o=t[n].value,a=t[r].map((e=>e.value)),c=this.getEntityRelations(e,o,s);for(const e of a)c.push(e);for(const t of a){this.getEntityRelations(e,t,i).push(o)}}getAttributeIndex(e){const t=this._inverseAttributes.indexOf(e);if(-1===t)throw new Error(`IfcRelationsIndexer: ${e} is not a valid IFC Inverse Attribute name or its not supported yet by this component.`);return t}setRelationMap(e,t){this.relationMaps[e.uuid]=t,this.onRelationsIndexed.trigger({modelID:e.uuid,relationsMap:t})}async process(e,t){if(!e.hasProperties)throw new Error("FragmentsGroup properties not found");let i=this.relationMaps[e.uuid];i||(i=new Map,this.relationMaps[e.uuid]=i);const s=e.getLocalProperties();if(!s)return i;const n=(null==t?void 0:t.relationsToProcess)??this._ifcRels;for(const[e,t]of Object.entries(s)){if(!n.includes(t.type))continue;const e=this._relToAttributesMap.get(t.type);if(!e)continue;const{forRelated:s,forRelating:r}=e;this.indexRelations(i,t,s,r)}return this.setRelationMap(e,i),i}async processFromWebIfc(e,t){const i=new Map;for(const s of this._ifcRels){const n=this._relToAttributesMap.get(s);if(!n)continue;const{forRelated:r,forRelating:o}=n,a=e.GetLineIDsWithType(t,s);for(let s=0;s<a.size();s++){const n=await e.properties.getItemProperties(t,a.get(s));this.indexRelations(i,n,r,o)}}return this.onRelationsIndexed.trigger({modelID:t.toString(),relationsMap:i}),i}getEntityRelations(e,t,i){const s=this.getAttributeIndex(i);let n;if(n=e instanceof D?this.relationMaps[e.uuid]:"string"==typeof e?this.relationMaps[e]:e,!n&&(e instanceof D||"string"==typeof e)){n=new Map;const t=e instanceof D?e.uuid:e;this.relationMaps[t]=n}let r=n.get(t);r||(r=new Map,n.set(t,r));let o=r.get(s);return o||(o=[],r.set(s,o)),o}serializeRelations(e){const t={};for(const[i,s]of e.entries()){t[i]||(t[i]={});for(const[e,n]of s.entries())t[i][e]=n}return JSON.stringify(t)}serializeModelRelations(e){const t=this.relationMaps[e.uuid];if(!t)return null;return this.serializeRelations(t)}serializeAllRelations(){const e={};for(const t in this.relationMaps){const i=this.relationMaps[t],s={};for(const[e,t]of i.entries()){s[e]||(s[e]={});for(const[i,n]of t.entries())s[e][i]=n}e[t]=s}return JSON.stringify(e)}getRelationsMapFromJSON(e){const t=JSON.parse(e),i=new Map;for(const e in t){const s=t[e],n=new Map;for(const e in s)n.set(Number(e),s[e]);i.set(Number(e),n)}return i}dispose(){this.relationMaps={};this.components.get(co).onFragmentsDisposed.remove(this.onFragmentsDisposed),this.onDisposed.trigger(e.uuid),this.onDisposed.reset()}getEntitiesWithRelation(e,t,i){const s=this.relationMaps[e.uuid];if(!s)throw new Error("IfcRelationsIndexer: the model relations are not indexed!");const n=new Set;for(const[e,r]of s){const s=this.getAttributeIndex(t),o=r.get(s);o&&o.includes(i)&&n.add(e)}return n}addEntityRelations(e,t,i,...s){const n=this.getEntityRelations(e,t,i);if(n)n.push(...s);else{const n=this.getAttributeIndex(i),r=this.relationMaps[e.uuid].get(t);null==r||r.set(n,s)}}async applyRelationChanges(){const e=this.components.get(co),t=this.components.get(no);for(const i in this._changeMap){const s=e.groups.get(i);if(!s)continue;const n=this._changeMap[i];for(const[e,i]of n)for(const[n,r]of i){const{related:i,relID:o}=r;if(o){const e=await s.getProperties(o);if(!e)continue;const r=Object.keys(e),a=r.find((e=>e.startsWith("Related"))),c=r.find((e=>e.startsWith("Relating")));if(!a||!c)continue;e[a]=[...i].map((e=>new x.Handle(e))),e[c]=new x.Handle(n),await t.setData(s,e)}else{const o=await t.createIfcRel(s,e,n,[...i]);if(!o)continue;r.relID=o.expressID}}}}addEntitiesRelation(e,t,i,...s){const{type:n,inv:r}=i;let o=this.relationMaps[e.uuid];if(o||(o=new Map,this.relationMaps[e.uuid]=o),!this._ifcRels.includes(n))return;const a=Br.get(n);if(!a)return;const{forRelated:c,forRelating:l}=a;if(c!==r&&l!==r)return;let h=this._changeMap[e.uuid];h||(h=new mi,this._changeMap[e.uuid]=h);const u=l===r?[t]:s,I=c===r?[t]:s;let d=h.get(n);d||(d=new mi,d.onItemSet.add((()=>this.onEntitiesRelated.trigger({invAttribute:r,relType:n,relatingIDs:u,relatedIDs:I}))),d.onItemUpdated.add((()=>this.onEntitiesRelated.trigger({invAttribute:r,relType:n,relatingIDs:u,relatedIDs:I}))),h.set(n,d));for(const e of u){let t=d.get(e);t||(t={related:new Ti},d.set(e,t)),t.related.add(...I)}for(const t of u){this.getEntityRelations(e,t,l).push(...I)}for(const t of I){this.getEntityRelations(e,t,c).push(...u)}}getEntityChildren(e,t,i=new Set){i.add(t);if(void 0===this.relationMaps[e.uuid])throw new Error("The provided model has no indices. You have to generate them first.");const s=this.getEntityRelations(e,t,"IsDecomposedBy");if(s)for(const t of s)this.getEntityChildren(e,t,i);const n=this.getEntityRelations(e,t,"ContainsElements");if(n)for(const t of n)this.getEntityChildren(e,t,i);return i}};t(ro,"uuid","23a889ab-83b3-44a4-8bee-ead83438370b");let oo=ro;const ao=class e extends ui{constructor(s){super(s),t(this,"onDisposed",new ci),t(this,"onFragmentsLoaded",new ci),t(this,"onFragmentsDisposed",new ci),t(this,"list",new mi),t(this,"groups",new mi),t(this,"baseCoordinationModel",""),t(this,"baseCoordinationMatrix",new i.Matrix4),t(this,"enabled",!0),t(this,"_loader",new b),this.components.add(e.uuid,this)}get meshes(){const e=[];for(const[t,i]of this.list)e.push(i.mesh);return e}dispose(){for(const[e,t]of this.groups)t.dispose(!0);this.baseCoordinationModel="",this.groups.clear(),this.list.clear(),this.onFragmentsLoaded.reset(),this.onFragmentsDisposed.reset(),this.onDisposed.trigger(),this.onDisposed.reset()}disposeGroup(e){const{uuid:t}=e,s=[];for(const t of e.items)s.push(t.id),this.list.delete(t.id);e.dispose(!0),this.groups.delete(e.uuid),0===this.groups.size&&(this.baseCoordinationModel="",this.baseCoordinationMatrix=new i.Matrix4),this.onFragmentsDisposed.trigger({groupID:t,fragmentIDs:s})}load(e,t){const i={coordinate:!0,...t},{coordinate:s,name:n,properties:r,relationsMap:o}=i,a=this._loader.import(e);t&&(a.isStreamed=t.isStreamed||!1),n&&(a.name=n);for(const e of a.items)e.group=a,this.list.set(e.id,e);if(s&&this.coordinate([a]),this.groups.set(a.uuid,a),r&&a.setLocalProperties(r),o){this.components.get(oo).setRelationMap(a,o)}return this.onFragmentsLoaded.trigger(a),a}export(e){return this._loader.export(e)}getModelIdMap(e){const t={};for(const i in e){const s=this.list.get(i);if(!s||!s.group)continue;const n=s.group;n.uuid in t||(t[n.uuid]=new Set);const r=e[i];for(const e of r)t[n.uuid].add(e)}return t}modelIdToFragmentIdMap(e){let t={};for(const i in e){const s=this.groups.get(i);if(!s)continue;const n=e[i],r=s.getFragmentMap(n);t={...t,...r}}return t}guidToFragmentIdMap(e){const t={};for(const[i,s]of this.groups){i in t||(t[i]=new Set);for(const n of e){const e=s.globalToExpressIDs.get(n);e&&t[i].add(e)}}return this.modelIdToFragmentIdMap(t)}fragmentIdMapToGuids(e){const t=[],i=this.getModelIdMap(e);for(const e in i){const s=this.groups.get(e);if(!s)continue;const n=i[e];for(const e of n)for(const[i,n]of s.globalToExpressIDs.entries())if(n===e){t.push(i);break}}return t}coordinate(e=Array.from(this.groups.values())){if(0===this.baseCoordinationModel.length){const t=e.pop();if(!t)return;this.baseCoordinationModel=t.uuid,this.baseCoordinationMatrix=t.coordinationMatrix.clone()}if(e.length)for(const t of e)t.coordinationMatrix.equals(this.baseCoordinationMatrix)||(t.position.set(0,0,0),t.rotation.set(0,0,0),t.scale.set(1,1,1),t.updateMatrix(),this.applyBaseCoordinateSystem(t,t.coordinationMatrix))}applyBaseCoordinateSystem(e,t){t&&e.applyMatrix4(t.clone().invert()),e.applyMatrix4(this.baseCoordinationMatrix)}clone(e,t){const i=e.cloneGroup(t);this.groups.set(i.uuid,i);for(const e of i.items)this.list.set(e.id,e);return i}};t(ao,"uuid","fef46874-46a3-461b-8c44-2922ab77c806");let co=ao;function lo(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var ho={exports:{}};
|
|
7
|
+
*/const qe=1,Ge=2,Qe=4,Ke=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}),Je=0,ti=1,ei=-1;function ii(t){return t.isPerspectiveCamera}function si(t){return t.isOrthographicCamera}const ni=2*Math.PI,ri=Math.PI/2,oi=Math.PI/180;function ai(t,e,i){return Math.max(e,Math.min(i,t))}function li(t,e=1e-5){return Math.abs(t)<e}function hi(t,e,i=1e-5){return li(t-e,i)}function ci(t,e){return Math.round(t/e)*e}function di(t){return isFinite(t)?t:t<0?-Number.MAX_VALUE:Number.MAX_VALUE}function ui(t){return Math.abs(t)<Number.MAX_VALUE?t:t*(1/0)}function pi(t,e,i,s,n=1/0,r){const o=2/(s=Math.max(1e-4,s)),a=o*r,l=1/(1+a+.48*a*a+.235*a*a*a);let h=t-e;const c=e,d=n*s;h=ai(h,-d,d),e=t-h;const u=(i.value+o*h)*r;i.value=(i.value-o*u)*l;let p=e+(h+u)*l;return c-t>0==p>c&&(p=c,i.value=(p-c)/r),p}function fi(t,e,i,s,n=1/0,r,o){const a=2/(s=Math.max(1e-4,s)),l=a*r,h=1/(1+l+.48*l*l+.235*l*l*l);let c=e.x,d=e.y,u=e.z,p=t.x-c,f=t.y-d,m=t.z-u;const g=c,_=d,y=u,w=n*s,v=p*p+f*f+m*m;if(v>w*w){const t=Math.sqrt(v);p=p/t*w,f=f/t*w,m=m/t*w}c=t.x-p,d=t.y-f,u=t.z-m;const b=(i.x+a*p)*r,x=(i.y+a*f)*r,E=(i.z+a*m)*r;i.x=(i.x-a*b)*h,i.y=(i.y-a*x)*h,i.z=(i.z-a*E)*h,o.x=c+(p+b)*h,o.y=d+(f+x)*h,o.z=u+(m+E)*h;const T=g-t.x,C=_-t.y,S=y-t.z;return T*(o.x-g)+C*(o.y-_)+S*(o.z-y)>0&&(o.x=g,o.y=_,o.z=y,i.x=(o.x-g)/r,i.y=(o.y-_)/r,i.z=(o.z-y)/r),o}function mi(t,e){e.set(0,0),t.forEach(t=>{e.x+=t.clientX,e.y+=t.clientY}),e.x/=t.length,e.y/=t.length}function gi(t,e){return!!si(t)&&(console.warn(`${e} is not supported in OrthographicCamera`),!0)}class _i{constructor(){this._listeners={}}addEventListener(t,e){const i=this._listeners;void 0===i[t]&&(i[t]=[]),-1===i[t].indexOf(e)&&i[t].push(e)}hasEventListener(t,e){const i=this._listeners;return void 0!==i[t]&&-1!==i[t].indexOf(e)}removeEventListener(t,e){const i=this._listeners[t];if(void 0!==i){const t=i.indexOf(e);-1!==t&&i.splice(t,1)}}removeAllEventListeners(t){t?Array.isArray(this._listeners[t])&&(this._listeners[t].length=0):this._listeners={}}dispatchEvent(t){const e=this._listeners[t.type];if(void 0!==e){t.target=this;const i=e.slice(0);for(let e=0,s=i.length;e<s;e++)i[e].call(this,t)}}}var yi;const wi=1/8,vi=/Mac/.test(null===(yi=null===globalThis||void 0===globalThis?void 0:globalThis.navigator)||void 0===yi?void 0:yi.platform);let bi,xi,Ei,Ti,Ci,Si,Ai,Oi,Pi,Ii,ki,Di,zi,Mi,Bi,Ni,Ui,Li,Ri,Fi,Vi,ji,Zi;class Hi extends _i{static install(t){bi=t.THREE,xi=Object.freeze(new bi.Vector3(0,0,0)),Ei=Object.freeze(new bi.Vector3(0,1,0)),Ti=Object.freeze(new bi.Vector3(0,0,1)),Ci=new bi.Vector2,Si=new bi.Vector3,Ai=new bi.Vector3,Oi=new bi.Vector3,Pi=new bi.Vector3,Ii=new bi.Vector3,ki=new bi.Vector3,Di=new bi.Vector3,zi=new bi.Vector3,Mi=new bi.Vector3,Bi=new bi.Spherical,Ni=new bi.Spherical,Ui=new bi.Box3,Li=new bi.Box3,Ri=new bi.Sphere,Fi=new bi.Quaternion,Vi=new bi.Quaternion,ji=new bi.Matrix4,Zi=new bi.Raycaster}static get ACTION(){return Ke}set verticalDragToForward(t){console.warn("camera-controls: `verticalDragToForward` was removed. Use `mouseButtons.left = CameraControls.ACTION.SCREEN_PAN` instead.")}constructor(t,e){super(),this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.minDistance=Number.EPSILON,this.maxDistance=1/0,this.infinityDolly=!1,this.minZoom=.01,this.maxZoom=1/0,this.smoothTime=.25,this.draggingSmoothTime=.125,this.maxSpeed=1/0,this.azimuthRotateSpeed=1,this.polarRotateSpeed=1,this.dollySpeed=1,this.dollyDragInverted=!1,this.truckSpeed=2,this.dollyToCursor=!1,this.dragToOffset=!1,this.boundaryFriction=0,this.restThreshold=.01,this.colliderMeshes=[],this.cancel=()=>{},this._enabled=!0,this._state=Ke.NONE,this._viewport=null,this._changedDolly=0,this._changedZoom=0,this._hasRested=!0,this._boundaryEnclosesCamera=!1,this._needsUpdate=!0,this._updatedLastTime=!1,this._elementRect=new DOMRect,this._isDragging=!1,this._dragNeedsUpdate=!0,this._activePointers=[],this._lockedPointer=null,this._interactiveArea=new DOMRect(0,0,1,1),this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._isUserControllingOffset=!1,this._isUserControllingZoom=!1,this._lastDollyDirection=Je,this._thetaVelocity={value:0},this._phiVelocity={value:0},this._radiusVelocity={value:0},this._targetVelocity=new bi.Vector3,this._focalOffsetVelocity=new bi.Vector3,this._zoomVelocity={value:0},this._truckInternal=(t,e,i,s)=>{let n,r;if(ii(this._camera)){const i=Si.copy(this._camera.position).sub(this._target),s=this._camera.getEffectiveFOV()*oi,o=i.length()*Math.tan(.5*s);n=this.truckSpeed*t*o/this._elementRect.height,r=this.truckSpeed*e*o/this._elementRect.height}else{if(!si(this._camera))return;{const i=this._camera;n=this.truckSpeed*t*(i.right-i.left)/i.zoom/this._elementRect.width,r=this.truckSpeed*e*(i.top-i.bottom)/i.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)},this._rotateInternal=(t,e)=>{const i=ni*this.azimuthRotateSpeed*t/this._elementRect.height,s=ni*this.polarRotateSpeed*e/this._elementRect.height;this.rotate(i,s,!0)},this._dollyInternal=(t,e,i)=>{const s=Math.pow(.95,-t*this.dollySpeed),n=this._sphericalEnd.radius,r=this._sphericalEnd.radius*s,o=ai(r,this.minDistance,this.maxDistance),a=o-r;this.infinityDolly&&this.dollyToCursor?this._dollyToNoClamp(r,!0):this.infinityDolly&&!this.dollyToCursor?(this.dollyInFixed(a,!0),this._dollyToNoClamp(o,!0)):this._dollyToNoClamp(o,!0),this.dollyToCursor&&(this._changedDolly+=(this.infinityDolly?r:o)-n,this._dollyControlCoord.set(e,i)),this._lastDollyDirection=Math.sign(-t)},this._zoomInternal=(t,e,i)=>{const s=Math.pow(.95,t*this.dollySpeed),n=this._zoom,r=this._zoom*s;this.zoomTo(r,!0),this.dollyToCursor&&(this._changedZoom+=r-n,this._dollyControlCoord.set(e,i))},void 0===bi&&console.error("camera-controls: `THREE` is undefined. You must first run `CameraControls.install( { THREE: THREE } )`. Check the docs for further information."),this._camera=t,this._yAxisUpSpace=(new bi.Quaternion).setFromUnitVectors(this._camera.up,Ei),this._yAxisUpSpaceInverse=this._yAxisUpSpace.clone().invert(),this._state=Ke.NONE,this._target=new bi.Vector3,this._targetEnd=this._target.clone(),this._focalOffset=new bi.Vector3,this._focalOffsetEnd=this._focalOffset.clone(),this._spherical=(new bi.Spherical).setFromVector3(Si.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 bi.Vector3,new bi.Vector3,new bi.Vector3,new bi.Vector3],this._updateNearPlaneCorners(),this._boundary=new bi.Box3(new bi.Vector3(-1/0,-1/0,-1/0),new bi.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 bi.Vector2,this.mouseButtons={left:Ke.ROTATE,middle:Ke.DOLLY,right:Ke.TRUCK,wheel:ii(this._camera)?Ke.DOLLY:si(this._camera)?Ke.ZOOM:Ke.NONE},this.touches={one:Ke.TOUCH_ROTATE,two:ii(this._camera)?Ke.TOUCH_DOLLY_TRUCK:si(this._camera)?Ke.TOUCH_ZOOM_TRUCK:Ke.NONE,three:Ke.TOUCH_TRUCK};const i=new bi.Vector2,s=new bi.Vector2,n=new bi.Vector2,r=t=>{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(),i=t.clientX/e.width,s=t.clientY/e.height;if(i<this._interactiveArea.left||i>this._interactiveArea.right||s<this._interactiveArea.top||s>this._interactiveArea.bottom)return}const e="mouse"!==t.pointerType?null:(t.buttons&qe)===qe?qe:(t.buttons&Qe)===Qe?Qe:(t.buttons&Ge)===Ge?Ge:null;if(null!==e){const t=this._findPointerByMouseButton(e);t&&this._disposePointer(t)}if((t.buttons&qe)===qe&&this._lockedPointer)return;const i={pointerId:t.pointerId,clientX:t.clientX,clientY:t.clientY,deltaX:0,deltaY:0,mouseButton:e};this._activePointers.push(i),this._domElement.ownerDocument.removeEventListener("pointermove",o,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",a),this._domElement.ownerDocument.addEventListener("pointermove",o,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",a),this._isDragging=!0,d(t)},o=t=>{t.cancelable&&t.preventDefault();const e=t.pointerId,i=this._lockedPointer||this._findPointerById(e);if(i){if(i.clientX=t.clientX,i.clientY=t.clientY,i.deltaX=t.movementX,i.deltaY=t.movementY,this._state=0,"touch"===t.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&&(t.buttons&qe)===qe)&&(this._state=this._state|this.mouseButtons.left),this._isDragging&&(t.buttons&Qe)===Qe&&(this._state=this._state|this.mouseButtons.middle),this._isDragging&&(t.buttons&Ge)===Ge&&(this._state=this._state|this.mouseButtons.right);u()}},a=t=>{const e=this._findPointerById(t.pointerId);if(!e||e!==this._lockedPointer){if(e&&this._disposePointer(e),"touch"===t.pointerType)switch(this._activePointers.length){case 0:this._state=Ke.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=Ke.NONE;p()}};let l=-1;const h=t=>{if(!this._domElement)return;if(!this._enabled||this.mouseButtons.wheel===Ke.NONE)return;if(0!==this._interactiveArea.left||0!==this._interactiveArea.top||1!==this._interactiveArea.width||1!==this._interactiveArea.height){const e=this._domElement.getBoundingClientRect(),i=t.clientX/e.width,s=t.clientY/e.height;if(i<this._interactiveArea.left||i>this._interactiveArea.right||s<this._interactiveArea.top||s>this._interactiveArea.bottom)return}if(t.preventDefault(),this.dollyToCursor||this.mouseButtons.wheel===Ke.ROTATE||this.mouseButtons.wheel===Ke.TRUCK){const t=performance.now();l-t<1e3&&this._getClientRect(this._elementRect),l=t}const e=vi?-1:-3,i=1===t.deltaMode||t.ctrlKey?t.deltaY/e:t.deltaY/(10*e),s=this.dollyToCursor?(t.clientX-this._elementRect.x)/this._elementRect.width*2-1:0,n=this.dollyToCursor?(t.clientY-this._elementRect.y)/this._elementRect.height*-2+1:0;switch(this.mouseButtons.wheel){case Ke.ROTATE:this._rotateInternal(t.deltaX,t.deltaY),this._isUserControllingRotate=!0;break;case Ke.TRUCK:this._truckInternal(t.deltaX,t.deltaY,!1,!1),this._isUserControllingTruck=!0;break;case Ke.SCREEN_PAN:this._truckInternal(t.deltaX,t.deltaY,!1,!0),this._isUserControllingTruck=!0;break;case Ke.OFFSET:this._truckInternal(t.deltaX,t.deltaY,!0,!1),this._isUserControllingOffset=!0;break;case Ke.DOLLY:this._dollyInternal(-i,s,n),this._isUserControllingDolly=!0;break;case Ke.ZOOM:this._zoomInternal(-i,s,n),this._isUserControllingZoom=!0}this.dispatchEvent({type:"control"})},c=t=>{if(this._domElement&&this._enabled){if(this.mouseButtons.right===Hi.ACTION.NONE){const e=t instanceof PointerEvent?t.pointerId:0,i=this._findPointerById(e);return i&&this._disposePointer(i),this._domElement.ownerDocument.removeEventListener("pointermove",o,{passive:!1}),void this._domElement.ownerDocument.removeEventListener("pointerup",a)}t.preventDefault()}},d=t=>{if(!this._enabled)return;mi(this._activePointers,Ci),this._getClientRect(this._elementRect),i.copy(Ci),s.copy(Ci);if(this._activePointers.length>=2){const t=Ci.x-this._activePointers[1].clientX,e=Ci.y-this._activePointers[1].clientY,i=Math.sqrt(t*t+e*e);n.set(0,i);const r=.5*(this._activePointers[0].clientX+this._activePointers[1].clientX),o=.5*(this._activePointers[0].clientY+this._activePointers[1].clientY);s.set(r,o)}if(this._state=0,t)if("pointerType"in t&&"touch"===t.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||(t.buttons&qe)!==qe||(this._state=this._state|this.mouseButtons.left),(t.buttons&Qe)===Qe&&(this._state=this._state|this.mouseButtons.middle),(t.buttons&Ge)===Ge&&(this._state=this._state|this.mouseButtons.right);else this._lockedPointer&&(this._state=this._state|this.mouseButtons.left);(this._state&Ke.ROTATE)!==Ke.ROTATE&&(this._state&Ke.TOUCH_ROTATE)!==Ke.TOUCH_ROTATE&&(this._state&Ke.TOUCH_DOLLY_ROTATE)!==Ke.TOUCH_DOLLY_ROTATE&&(this._state&Ke.TOUCH_ZOOM_ROTATE)!==Ke.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&Ke.TRUCK)!==Ke.TRUCK&&(this._state&Ke.SCREEN_PAN)!==Ke.SCREEN_PAN&&(this._state&Ke.TOUCH_TRUCK)!==Ke.TOUCH_TRUCK&&(this._state&Ke.TOUCH_SCREEN_PAN)!==Ke.TOUCH_SCREEN_PAN&&(this._state&Ke.TOUCH_DOLLY_TRUCK)!==Ke.TOUCH_DOLLY_TRUCK&&(this._state&Ke.TOUCH_DOLLY_SCREEN_PAN)!==Ke.TOUCH_DOLLY_SCREEN_PAN&&(this._state&Ke.TOUCH_ZOOM_TRUCK)!==Ke.TOUCH_ZOOM_TRUCK&&(this._state&Ke.TOUCH_ZOOM_SCREEN_PAN)!==Ke.TOUCH_DOLLY_SCREEN_PAN||(this._targetEnd.copy(this._target),this._targetVelocity.set(0,0,0)),(this._state&Ke.DOLLY)!==Ke.DOLLY&&(this._state&Ke.TOUCH_DOLLY)!==Ke.TOUCH_DOLLY&&(this._state&Ke.TOUCH_DOLLY_TRUCK)!==Ke.TOUCH_DOLLY_TRUCK&&(this._state&Ke.TOUCH_DOLLY_SCREEN_PAN)!==Ke.TOUCH_DOLLY_SCREEN_PAN&&(this._state&Ke.TOUCH_DOLLY_OFFSET)!==Ke.TOUCH_DOLLY_OFFSET&&(this._state&Ke.TOUCH_DOLLY_ROTATE)!==Ke.TOUCH_DOLLY_ROTATE||(this._sphericalEnd.radius=this._spherical.radius,this._radiusVelocity.value=0),(this._state&Ke.ZOOM)!==Ke.ZOOM&&(this._state&Ke.TOUCH_ZOOM)!==Ke.TOUCH_ZOOM&&(this._state&Ke.TOUCH_ZOOM_TRUCK)!==Ke.TOUCH_ZOOM_TRUCK&&(this._state&Ke.TOUCH_ZOOM_SCREEN_PAN)!==Ke.TOUCH_ZOOM_SCREEN_PAN&&(this._state&Ke.TOUCH_ZOOM_OFFSET)!==Ke.TOUCH_ZOOM_OFFSET&&(this._state&Ke.TOUCH_ZOOM_ROTATE)!==Ke.TOUCH_ZOOM_ROTATE||(this._zoomEnd=this._zoom,this._zoomVelocity.value=0),(this._state&Ke.OFFSET)!==Ke.OFFSET&&(this._state&Ke.TOUCH_OFFSET)!==Ke.TOUCH_OFFSET&&(this._state&Ke.TOUCH_DOLLY_OFFSET)!==Ke.TOUCH_DOLLY_OFFSET&&(this._state&Ke.TOUCH_ZOOM_OFFSET)!==Ke.TOUCH_ZOOM_OFFSET||(this._focalOffsetEnd.copy(this._focalOffset),this._focalOffsetVelocity.set(0,0,0)),this.dispatchEvent({type:"controlstart"})},u=()=>{if(!this._enabled||!this._dragNeedsUpdate)return;this._dragNeedsUpdate=!1,mi(this._activePointers,Ci);const t=this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement?this._lockedPointer||this._activePointers[0]:null,e=t?-t.deltaX:s.x-Ci.x,r=t?-t.deltaY:s.y-Ci.y;if(s.copy(Ci),(this._state&Ke.ROTATE)!==Ke.ROTATE&&(this._state&Ke.TOUCH_ROTATE)!==Ke.TOUCH_ROTATE&&(this._state&Ke.TOUCH_DOLLY_ROTATE)!==Ke.TOUCH_DOLLY_ROTATE&&(this._state&Ke.TOUCH_ZOOM_ROTATE)!==Ke.TOUCH_ZOOM_ROTATE||(this._rotateInternal(e,r),this._isUserControllingRotate=!0),(this._state&Ke.DOLLY)===Ke.DOLLY||(this._state&Ke.ZOOM)===Ke.ZOOM){const t=this.dollyToCursor?(i.x-this._elementRect.x)/this._elementRect.width*2-1:0,e=this.dollyToCursor?(i.y-this._elementRect.y)/this._elementRect.height*-2+1:0,s=this.dollyDragInverted?-1:1;(this._state&Ke.DOLLY)===Ke.DOLLY?(this._dollyInternal(s*r*wi,t,e),this._isUserControllingDolly=!0):(this._zoomInternal(s*r*wi,t,e),this._isUserControllingZoom=!0)}if((this._state&Ke.TOUCH_DOLLY)===Ke.TOUCH_DOLLY||(this._state&Ke.TOUCH_ZOOM)===Ke.TOUCH_ZOOM||(this._state&Ke.TOUCH_DOLLY_TRUCK)===Ke.TOUCH_DOLLY_TRUCK||(this._state&Ke.TOUCH_ZOOM_TRUCK)===Ke.TOUCH_ZOOM_TRUCK||(this._state&Ke.TOUCH_DOLLY_SCREEN_PAN)===Ke.TOUCH_DOLLY_SCREEN_PAN||(this._state&Ke.TOUCH_ZOOM_SCREEN_PAN)===Ke.TOUCH_ZOOM_SCREEN_PAN||(this._state&Ke.TOUCH_DOLLY_OFFSET)===Ke.TOUCH_DOLLY_OFFSET||(this._state&Ke.TOUCH_ZOOM_OFFSET)===Ke.TOUCH_ZOOM_OFFSET||(this._state&Ke.TOUCH_DOLLY_ROTATE)===Ke.TOUCH_DOLLY_ROTATE||(this._state&Ke.TOUCH_ZOOM_ROTATE)===Ke.TOUCH_ZOOM_ROTATE){const t=Ci.x-this._activePointers[1].clientX,e=Ci.y-this._activePointers[1].clientY,i=Math.sqrt(t*t+e*e),r=n.y-i;n.set(0,i);const o=this.dollyToCursor?(s.x-this._elementRect.x)/this._elementRect.width*2-1:0,a=this.dollyToCursor?(s.y-this._elementRect.y)/this._elementRect.height*-2+1:0;(this._state&Ke.TOUCH_DOLLY)===Ke.TOUCH_DOLLY||(this._state&Ke.TOUCH_DOLLY_ROTATE)===Ke.TOUCH_DOLLY_ROTATE||(this._state&Ke.TOUCH_DOLLY_TRUCK)===Ke.TOUCH_DOLLY_TRUCK||(this._state&Ke.TOUCH_DOLLY_SCREEN_PAN)===Ke.TOUCH_DOLLY_SCREEN_PAN||(this._state&Ke.TOUCH_DOLLY_OFFSET)===Ke.TOUCH_DOLLY_OFFSET?(this._dollyInternal(r*wi,o,a),this._isUserControllingDolly=!0):(this._zoomInternal(r*wi,o,a),this._isUserControllingZoom=!0)}(this._state&Ke.TRUCK)!==Ke.TRUCK&&(this._state&Ke.TOUCH_TRUCK)!==Ke.TOUCH_TRUCK&&(this._state&Ke.TOUCH_DOLLY_TRUCK)!==Ke.TOUCH_DOLLY_TRUCK&&(this._state&Ke.TOUCH_ZOOM_TRUCK)!==Ke.TOUCH_ZOOM_TRUCK||(this._truckInternal(e,r,!1,!1),this._isUserControllingTruck=!0),(this._state&Ke.SCREEN_PAN)!==Ke.SCREEN_PAN&&(this._state&Ke.TOUCH_SCREEN_PAN)!==Ke.TOUCH_SCREEN_PAN&&(this._state&Ke.TOUCH_DOLLY_SCREEN_PAN)!==Ke.TOUCH_DOLLY_SCREEN_PAN&&(this._state&Ke.TOUCH_ZOOM_SCREEN_PAN)!==Ke.TOUCH_ZOOM_SCREEN_PAN||(this._truckInternal(e,r,!1,!0),this._isUserControllingTruck=!0),(this._state&Ke.OFFSET)!==Ke.OFFSET&&(this._state&Ke.TOUCH_OFFSET)!==Ke.TOUCH_OFFSET&&(this._state&Ke.TOUCH_DOLLY_OFFSET)!==Ke.TOUCH_DOLLY_OFFSET&&(this._state&Ke.TOUCH_ZOOM_OFFSET)!==Ke.TOUCH_ZOOM_OFFSET||(this._truckInternal(e,r,!0,!1),this._isUserControllingOffset=!0),this.dispatchEvent({type:"control"})},p=()=>{mi(this._activePointers,Ci),s.copy(Ci),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",o,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",a),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",o,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",a),this._domElement.requestPointerLock(),this._domElement.ownerDocument.addEventListener("pointerlockchange",f),this._domElement.ownerDocument.addEventListener("pointerlockerror",m),this._domElement.ownerDocument.addEventListener("pointermove",o,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",a),d())},this.unlockPointer=()=>{var t,e,i;null!==this._lockedPointer&&(this._disposePointer(this._lockedPointer),this._lockedPointer=null),null===(t=this._domElement)||void 0===t||t.ownerDocument.exitPointerLock(),null===(e=this._domElement)||void 0===e||e.ownerDocument.removeEventListener("pointerlockchange",f),null===(i=this._domElement)||void 0===i||i.ownerDocument.removeEventListener("pointerlockerror",m),this.cancel()};const f=()=>{this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement||this.unlockPointer()},m=()=>{this.unlockPointer()};this._addAllEventListeners=t=>{this._domElement=t,this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none",this._domElement.addEventListener("pointerdown",r),this._domElement.addEventListener("pointercancel",a),this._domElement.addEventListener("wheel",h,{passive:!1}),this._domElement.addEventListener("contextmenu",c)},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",a),this._domElement.removeEventListener("wheel",h,{passive:!1}),this._domElement.removeEventListener("contextmenu",c),this._domElement.ownerDocument.removeEventListener("pointermove",o,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",a),this._domElement.ownerDocument.removeEventListener("pointerlockchange",f),this._domElement.ownerDocument.removeEventListener("pointerlockerror",m))},this.cancel=()=>{this._state!==Ke.NONE&&(this._state=Ke.NONE,this._activePointers.length=0,p())},e&&this.connect(e),this.update(0)}get camera(){return this._camera}set camera(t){this._camera=t,this.updateCameraUp(),this._camera.updateProjectionMatrix(),this._updateNearPlaneCorners(),this._needsUpdate=!0}get enabled(){return this._enabled}set enabled(t){this._enabled=t,this._domElement&&(t?(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(t){this._spherical.radius===t&&this._sphericalEnd.radius===t||(this._spherical.radius=t,this._sphericalEnd.radius=t,this._needsUpdate=!0)}get azimuthAngle(){return this._spherical.theta}set azimuthAngle(t){this._spherical.theta===t&&this._sphericalEnd.theta===t||(this._spherical.theta=t,this._sphericalEnd.theta=t,this._needsUpdate=!0)}get polarAngle(){return this._spherical.phi}set polarAngle(t){this._spherical.phi===t&&this._sphericalEnd.phi===t||(this._spherical.phi=t,this._sphericalEnd.phi=t,this._needsUpdate=!0)}get boundaryEnclosesCamera(){return this._boundaryEnclosesCamera}set boundaryEnclosesCamera(t){this._boundaryEnclosesCamera=t,this._needsUpdate=!0}set interactiveArea(t){this._interactiveArea.width=ai(t.width,0,1),this._interactiveArea.height=ai(t.height,0,1),this._interactiveArea.x=ai(t.x,0,1-this._interactiveArea.width),this._interactiveArea.y=ai(t.y,0,1-this._interactiveArea.height)}addEventListener(t,e){super.addEventListener(t,e)}removeEventListener(t,e){super.removeEventListener(t,e)}rotate(t,e,i=!1){return this.rotateTo(this._sphericalEnd.theta+t,this._sphericalEnd.phi+e,i)}rotateAzimuthTo(t,e=!1){return this.rotateTo(t,this._sphericalEnd.phi,e)}rotatePolarTo(t,e=!1){return this.rotateTo(this._sphericalEnd.theta,t,e)}rotateTo(t,e,i=!1){this._isUserControllingRotate=!1;const s=ai(t,this.minAzimuthAngle,this.maxAzimuthAngle),n=ai(e,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||hi(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&hi(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold);return this._createOnRestPromise(r)}dolly(t,e=!1){return this.dollyTo(this._sphericalEnd.radius-t,e)}dollyTo(t,e=!1){return this._isUserControllingDolly=!1,this._lastDollyDirection=Je,this._changedDolly=0,this._dollyToNoClamp(ai(t,this.minDistance,this.maxDistance),e)}_dollyToNoClamp(t,e=!1){const i=this._sphericalEnd.radius;if(this.colliderMeshes.length>=1){const e=this._collisionTest(),s=hi(e,this._spherical.radius);if(!(i>t)&&s)return Promise.resolve();this._sphericalEnd.radius=Math.min(t,e)}else this._sphericalEnd.radius=t;this._needsUpdate=!0,e||(this._spherical.radius=this._sphericalEnd.radius);const s=!e||hi(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(s)}dollyInFixed(t,e=!1){this._targetEnd.add(this._getCameraDirection(Pi).multiplyScalar(t)),e||this._target.copy(this._targetEnd);const i=!e||hi(this._target.x,this._targetEnd.x,this.restThreshold)&&hi(this._target.y,this._targetEnd.y,this.restThreshold)&&hi(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(i)}zoom(t,e=!1){return this.zoomTo(this._zoomEnd+t,e)}zoomTo(t,e=!1){this._isUserControllingZoom=!1,this._zoomEnd=ai(t,this.minZoom,this.maxZoom),this._needsUpdate=!0,e||(this._zoom=this._zoomEnd);const i=!e||hi(this._zoom,this._zoomEnd,this.restThreshold);return this._changedZoom=0,this._createOnRestPromise(i)}pan(t,e,i=!1){return console.warn("`pan` has been renamed to `truck`"),this.truck(t,e,i)}truck(t,e,i=!1){this._camera.updateMatrix(),Ii.setFromMatrixColumn(this._camera.matrix,0),ki.setFromMatrixColumn(this._camera.matrix,1),Ii.multiplyScalar(t),ki.multiplyScalar(-e);const s=Si.copy(Ii).add(ki),n=Ai.copy(this._targetEnd).add(s);return this.moveTo(n.x,n.y,n.z,i)}forward(t,e=!1){Si.setFromMatrixColumn(this._camera.matrix,0),Si.crossVectors(this._camera.up,Si),Si.multiplyScalar(t);const i=Ai.copy(this._targetEnd).add(Si);return this.moveTo(i.x,i.y,i.z,e)}elevate(t,e=!1){return Si.copy(this._camera.up).multiplyScalar(t),this.moveTo(this._targetEnd.x+Si.x,this._targetEnd.y+Si.y,this._targetEnd.z+Si.z,e)}moveTo(t,e,i,s=!1){this._isUserControllingTruck=!1;const n=Si.set(t,e,i).sub(this._targetEnd);this._encloseToBoundary(this._targetEnd,n,this.boundaryFriction),this._needsUpdate=!0,s||this._target.copy(this._targetEnd);const r=!s||hi(this._target.x,this._targetEnd.x,this.restThreshold)&&hi(this._target.y,this._targetEnd.y,this.restThreshold)&&hi(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(r)}lookInDirectionOf(t,e,i,s=!1){const n=Si.set(t,e,i).sub(this._targetEnd).normalize().multiplyScalar(-this._sphericalEnd.radius).add(this._targetEnd);return this.setPosition(n.x,n.y,n.z,s)}fitToBox(t,e,{cover:i=!1,paddingLeft:s=0,paddingRight:n=0,paddingBottom:r=0,paddingTop:o=0}={}){const a=[],l=t.isBox3?Ui.copy(t):Ui.setFromObject(t);l.isEmpty()&&(console.warn("camera-controls: fitTo() cannot be used with an empty box. Aborting"),Promise.resolve());const h=ci(this._sphericalEnd.theta,ri),c=ci(this._sphericalEnd.phi,ri);a.push(this.rotateTo(h,c,e));const d=Si.setFromSpherical(this._sphericalEnd).normalize(),u=Fi.setFromUnitVectors(d,Ti),p=hi(Math.abs(d.y),1);p&&u.multiply(Vi.setFromAxisAngle(Ei,h)),u.multiply(this._yAxisUpSpaceInverse);const f=Li.makeEmpty();Ai.copy(l.min).applyQuaternion(u),f.expandByPoint(Ai),Ai.copy(l.min).setX(l.max.x).applyQuaternion(u),f.expandByPoint(Ai),Ai.copy(l.min).setY(l.max.y).applyQuaternion(u),f.expandByPoint(Ai),Ai.copy(l.max).setZ(l.min.z).applyQuaternion(u),f.expandByPoint(Ai),Ai.copy(l.min).setZ(l.max.z).applyQuaternion(u),f.expandByPoint(Ai),Ai.copy(l.max).setY(l.min.y).applyQuaternion(u),f.expandByPoint(Ai),Ai.copy(l.max).setX(l.min.x).applyQuaternion(u),f.expandByPoint(Ai),Ai.copy(l.max).applyQuaternion(u),f.expandByPoint(Ai),f.min.x-=s,f.min.y-=r,f.max.x+=n,f.max.y+=o,u.setFromUnitVectors(Ti,d),p&&u.premultiply(Vi.invert()),u.premultiply(this._yAxisUpSpace);const m=f.getSize(Si),g=f.getCenter(Ai).applyQuaternion(u);if(ii(this._camera)){const t=this.getDistanceToFitBox(m.x,m.y,m.z,i);a.push(this.moveTo(g.x,g.y,g.z,e)),a.push(this.dollyTo(t,e)),a.push(this.setFocalOffset(0,0,0,e))}else if(si(this._camera)){const t=this._camera,s=t.right-t.left,n=t.top-t.bottom,r=i?Math.max(s/m.x,n/m.y):Math.min(s/m.x,n/m.y);a.push(this.moveTo(g.x,g.y,g.z,e)),a.push(this.zoomTo(r,e)),a.push(this.setFocalOffset(0,0,0,e))}return Promise.all(a)}fitToSphere(t,e){const i=[],s="isObject3D"in t?Hi.createBoundingSphere(t,Ri):Ri.copy(t);if(i.push(this.moveTo(s.center.x,s.center.y,s.center.z,e)),ii(this._camera)){const t=this.getDistanceToFitSphere(s.radius);i.push(this.dollyTo(t,e))}else if(si(this._camera)){const t=this._camera.right-this._camera.left,n=this._camera.top-this._camera.bottom,r=2*s.radius,o=Math.min(t/r,n/r);i.push(this.zoomTo(o,e))}return i.push(this.setFocalOffset(0,0,0,e)),Promise.all(i)}setLookAt(t,e,i,s,n,r,o=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=Je,this._changedDolly=0;const a=Ai.set(s,n,r),l=Si.set(t,e,i);this._targetEnd.copy(a),this._sphericalEnd.setFromVector3(l.sub(a).applyQuaternion(this._yAxisUpSpace)),this.normalizeRotations(),this._needsUpdate=!0,o||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const h=!o||hi(this._target.x,this._targetEnd.x,this.restThreshold)&&hi(this._target.y,this._targetEnd.y,this.restThreshold)&&hi(this._target.z,this._targetEnd.z,this.restThreshold)&&hi(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&hi(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&hi(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(h)}lerpLookAt(t,e,i,s,n,r,o,a,l,h,c,d,u,p=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=Je,this._changedDolly=0;const f=Si.set(s,n,r),m=Ai.set(t,e,i);Bi.setFromVector3(m.sub(f).applyQuaternion(this._yAxisUpSpace));const g=Oi.set(h,c,d),_=Ai.set(o,a,l);Ni.setFromVector3(_.sub(g).applyQuaternion(this._yAxisUpSpace)),this._targetEnd.copy(f.lerp(g,u));const y=Ni.theta-Bi.theta,w=Ni.phi-Bi.phi,v=Ni.radius-Bi.radius;this._sphericalEnd.set(Bi.radius+v*u,Bi.phi+w*u,Bi.theta+y*u),this.normalizeRotations(),this._needsUpdate=!0,p||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const b=!p||hi(this._target.x,this._targetEnd.x,this.restThreshold)&&hi(this._target.y,this._targetEnd.y,this.restThreshold)&&hi(this._target.z,this._targetEnd.z,this.restThreshold)&&hi(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&hi(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&hi(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(b)}setPosition(t,e,i,s=!1){return this.setLookAt(t,e,i,this._targetEnd.x,this._targetEnd.y,this._targetEnd.z,s)}setTarget(t,e,i,s=!1){const n=this.getPosition(Si),r=this.setLookAt(n.x,n.y,n.z,t,e,i,s);return this._sphericalEnd.phi=ai(this._sphericalEnd.phi,this.minPolarAngle,this.maxPolarAngle),r}setFocalOffset(t,e,i,s=!1){this._isUserControllingOffset=!1,this._focalOffsetEnd.set(t,e,i),this._needsUpdate=!0,s||this._focalOffset.copy(this._focalOffsetEnd);const n=!s||hi(this._focalOffset.x,this._focalOffsetEnd.x,this.restThreshold)&&hi(this._focalOffset.y,this._focalOffsetEnd.y,this.restThreshold)&&hi(this._focalOffset.z,this._focalOffsetEnd.z,this.restThreshold);return this._createOnRestPromise(n)}setOrbitPoint(t,e,i){this._camera.updateMatrixWorld(),Ii.setFromMatrixColumn(this._camera.matrixWorldInverse,0),ki.setFromMatrixColumn(this._camera.matrixWorldInverse,1),Di.setFromMatrixColumn(this._camera.matrixWorldInverse,2);const s=Si.set(t,e,i),n=s.distanceTo(this._camera.position),r=s.sub(this._camera.position);Ii.multiplyScalar(r.x),ki.multiplyScalar(r.y),Di.multiplyScalar(r.z),Si.copy(Ii).add(ki).add(Di),Si.z=Si.z+n,this.dollyTo(n,!1),this.setFocalOffset(-Si.x,Si.y,-Si.z,!1),this.moveTo(t,e,i,!1)}setBoundary(t){if(!t)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(t),this._boundary.clampPoint(this._targetEnd,this._targetEnd),this._needsUpdate=!0}setViewport(t,e,i,s){null!==t?(this._viewport=this._viewport||new bi.Vector4,"number"==typeof t?this._viewport.set(t,e,i,s):this._viewport.copy(t)):this._viewport=null}getDistanceToFitBox(t,e,i,s=!1){if(gi(this._camera,"getDistanceToFitBox"))return this._spherical.radius;const n=t/e,r=this._camera.getEffectiveFOV()*oi,o=this._camera.aspect;return.5*((s?n>o:n<o)?e:t/o)/Math.tan(.5*r)+.5*i}getDistanceToFitSphere(t){if(gi(this._camera,"getDistanceToFitSphere"))return this._spherical.radius;const e=this._camera.getEffectiveFOV()*oi,i=2*Math.atan(Math.tan(.5*e)*this._camera.aspect),s=1<this._camera.aspect?e:i;return t/Math.sin(.5*s)}getTarget(t,e=!0){return(t&&t.isVector3?t:new bi.Vector3).copy(e?this._targetEnd:this._target)}getPosition(t,e=!0){return(t&&t.isVector3?t:new bi.Vector3).setFromSpherical(e?this._sphericalEnd:this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(e?this._targetEnd:this._target)}getSpherical(t,e=!0){return(t||new bi.Spherical).copy(e?this._sphericalEnd:this._spherical)}getFocalOffset(t,e=!0){return(t&&t.isVector3?t:new bi.Vector3).copy(e?this._focalOffsetEnd:this._focalOffset)}normalizeRotations(){this._sphericalEnd.theta=this._sphericalEnd.theta%ni,this._sphericalEnd.theta<0&&(this._sphericalEnd.theta+=ni),this._spherical.theta+=ni*Math.round((this._sphericalEnd.theta-this._spherical.theta)/ni)}stop(){this._focalOffset.copy(this._focalOffsetEnd),this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd),this._zoom=this._zoomEnd}reset(t=!1){if(!hi(this._camera.up.x,this._cameraUp0.x)||!hi(this._camera.up.y,this._cameraUp0.y)||!hi(this._camera.up.z,this._cameraUp0.z)){this._camera.up.copy(this._cameraUp0);const t=this.getPosition(Si);this.updateCameraUp(),this.setPosition(t.x,t.y,t.z)}const e=[this.setLookAt(this._position0.x,this._position0.y,this._position0.z,this._target0.x,this._target0.y,this._target0.z,t),this.setFocalOffset(this._focalOffset0.x,this._focalOffset0.y,this._focalOffset0.z,t),this.zoomTo(this._zoom0,t)];return Promise.all(e)}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,Ei),this._yAxisUpSpaceInverse.copy(this._yAxisUpSpace).invert()}applyCameraUp(){const t=Si.subVectors(this._target,this._camera.position).normalize(),e=Ai.crossVectors(t,this._camera.up);this._camera.up.crossVectors(e,t).normalize(),this._camera.updateMatrixWorld();const i=this.getPosition(Si);this.updateCameraUp(),this.setPosition(i.x,i.y,i.z)}update(t){const e=this._sphericalEnd.theta-this._spherical.theta,i=this._sphericalEnd.phi-this._spherical.phi,s=this._sphericalEnd.radius-this._spherical.radius,n=zi.subVectors(this._targetEnd,this._target),r=Mi.subVectors(this._focalOffsetEnd,this._focalOffset),o=this._zoomEnd-this._zoom;if(li(e))this._thetaVelocity.value=0,this._spherical.theta=this._sphericalEnd.theta;else{const e=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.theta=pi(this._spherical.theta,this._sphericalEnd.theta,this._thetaVelocity,e,1/0,t),this._needsUpdate=!0}if(li(i))this._phiVelocity.value=0,this._spherical.phi=this._sphericalEnd.phi;else{const e=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.phi=pi(this._spherical.phi,this._sphericalEnd.phi,this._phiVelocity,e,1/0,t),this._needsUpdate=!0}if(li(s))this._radiusVelocity.value=0,this._spherical.radius=this._sphericalEnd.radius;else{const e=this._isUserControllingDolly?this.draggingSmoothTime:this.smoothTime;this._spherical.radius=pi(this._spherical.radius,this._sphericalEnd.radius,this._radiusVelocity,e,this.maxSpeed,t),this._needsUpdate=!0}if(li(n.x)&&li(n.y)&&li(n.z))this._targetVelocity.set(0,0,0),this._target.copy(this._targetEnd);else{const e=this._isUserControllingTruck?this.draggingSmoothTime:this.smoothTime;fi(this._target,this._targetEnd,this._targetVelocity,e,this.maxSpeed,t,this._target),this._needsUpdate=!0}if(li(r.x)&&li(r.y)&&li(r.z))this._focalOffsetVelocity.set(0,0,0),this._focalOffset.copy(this._focalOffsetEnd);else{const e=this._isUserControllingOffset?this.draggingSmoothTime:this.smoothTime;fi(this._focalOffset,this._focalOffsetEnd,this._focalOffsetVelocity,e,this.maxSpeed,t,this._focalOffset),this._needsUpdate=!0}if(li(o))this._zoomVelocity.value=0,this._zoom=this._zoomEnd;else{const e=this._isUserControllingZoom?this.draggingSmoothTime:this.smoothTime;this._zoom=pi(this._zoom,this._zoomEnd,this._zoomVelocity,e,1/0,t)}if(this.dollyToCursor)if(ii(this._camera)&&0!==this._changedDolly){const t=this._spherical.radius-this._lastDistance,e=this._camera,i=this._getCameraDirection(Pi),s=Si.copy(i).cross(e.up).normalize();0===s.lengthSq()&&(s.x=1);const n=Ai.crossVectors(s,i),r=this._sphericalEnd.radius*Math.tan(e.getEffectiveFOV()*oi*.5),o=(this._sphericalEnd.radius-t-this._sphericalEnd.radius)/this._sphericalEnd.radius,a=Oi.copy(this._targetEnd).add(s.multiplyScalar(this._dollyControlCoord.x*r*e.aspect)).add(n.multiplyScalar(this._dollyControlCoord.y*r)),l=Si.copy(this._targetEnd).lerp(a,o),h=this._lastDollyDirection===ti&&this._spherical.radius<=this.minDistance,c=this._lastDollyDirection===ei&&this.maxDistance<=this._spherical.radius;if(this.infinityDolly&&(h||c)){this._sphericalEnd.radius-=t,this._spherical.radius-=t;const e=Ai.copy(i).multiplyScalar(-t);l.add(e)}this._boundary.clampPoint(l,l);const d=Ai.subVectors(l,this._targetEnd);this._targetEnd.copy(l),this._target.add(d),this._changedDolly-=t,li(this._changedDolly)&&(this._changedDolly=0)}else if(si(this._camera)&&0!==this._changedZoom){const t=this._zoom-this._lastZoom,e=this._camera,i=Si.set(this._dollyControlCoord.x,this._dollyControlCoord.y,(e.near+e.far)/(e.near-e.far)).unproject(e),s=Ai.set(0,0,-1).applyQuaternion(e.quaternion),n=Oi.copy(i).add(s.multiplyScalar(-i.dot(e.up))),r=-(this._zoom-t-this._zoom)/this._zoom,o=this._getCameraDirection(Pi),a=this._targetEnd.dot(o),l=Si.copy(this._targetEnd).lerp(n,r),h=l.dot(o),c=o.multiplyScalar(h-a);l.sub(c),this._boundary.clampPoint(l,l);const d=Ai.subVectors(l,this._targetEnd);this._targetEnd.copy(l),this._target.add(d),this._changedZoom-=t,li(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 a=this._collisionTest();this._spherical.radius=Math.min(this._spherical.radius,a),this._spherical.makeSafe(),this._camera.position.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(this._target),this._camera.lookAt(this._target);(!li(this._focalOffset.x)||!li(this._focalOffset.y)||!li(this._focalOffset.z))&&(Ii.setFromMatrixColumn(this._camera.matrix,0),ki.setFromMatrixColumn(this._camera.matrix,1),Di.setFromMatrixColumn(this._camera.matrix,2),Ii.multiplyScalar(this._focalOffset.x),ki.multiplyScalar(-this._focalOffset.y),Di.multiplyScalar(this._focalOffset.z),Si.copy(Ii).add(ki).add(Di),this._camera.position.add(Si),this._camera.updateMatrixWorld()),this._boundaryEnclosesCamera&&this._encloseToBoundary(this._camera.position.copy(this._target),Si.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse),1);const l=this._needsUpdate;return l&&!this._updatedLastTime?(this._hasRested=!1,this.dispatchEvent({type:"wake"}),this.dispatchEvent({type:"update"})):l?(this.dispatchEvent({type:"update"}),li(e,this.restThreshold)&&li(i,this.restThreshold)&&li(s,this.restThreshold)&&li(n.x,this.restThreshold)&&li(n.y,this.restThreshold)&&li(n.z,this.restThreshold)&&li(r.x,this.restThreshold)&&li(r.y,this.restThreshold)&&li(r.z,this.restThreshold)&&li(o,this.restThreshold)&&!this._hasRested&&(this._hasRested=!0,this.dispatchEvent({type:"rest"}))):!l&&this._updatedLastTime&&this.dispatchEvent({type:"sleep"}),this._lastDistance=this._spherical.radius,this._lastZoom=this._zoom,this._updatedLastTime=l,this._needsUpdate=!1,l}toJSON(){return JSON.stringify({enabled:this._enabled,minDistance:this.minDistance,maxDistance:di(this.maxDistance),minZoom:this.minZoom,maxZoom:di(this.maxZoom),minPolarAngle:this.minPolarAngle,maxPolarAngle:di(this.maxPolarAngle),minAzimuthAngle:di(this.minAzimuthAngle),maxAzimuthAngle:di(this.maxAzimuthAngle),smoothTime:this.smoothTime,draggingSmoothTime:this.draggingSmoothTime,dollySpeed:this.dollySpeed,truckSpeed:this.truckSpeed,dollyToCursor:this.dollyToCursor,target:this._targetEnd.toArray(),position:Si.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(t,e=!1){const i=JSON.parse(t);this.enabled=i.enabled,this.minDistance=i.minDistance,this.maxDistance=ui(i.maxDistance),this.minZoom=i.minZoom,this.maxZoom=ui(i.maxZoom),this.minPolarAngle=i.minPolarAngle,this.maxPolarAngle=ui(i.maxPolarAngle),this.minAzimuthAngle=ui(i.minAzimuthAngle),this.maxAzimuthAngle=ui(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],e),Bi.setFromVector3(Si.fromArray(i.position).sub(this._targetEnd).applyQuaternion(this._yAxisUpSpace)),this.rotateTo(Bi.theta,Bi.phi,e),this.dollyTo(Bi.radius,e),this.zoomTo(i.zoom,e),this.setFocalOffset(i.focalOffset[0],i.focalOffset[1],i.focalOffset[2],e),this._needsUpdate=!0}connect(t){this._domElement?console.warn("camera-controls is already connected."):(t.setAttribute("data-camera-controls-version","2.10.1"),this._addAllEventListeners(t),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(t){return t.setFromSpherical(this._spherical).divideScalar(this._spherical.radius).applyQuaternion(this._yAxisUpSpaceInverse)}_getCameraDirection(t){return this._getTargetDirection(t).negate()}_findPointerById(t){return this._activePointers.find(e=>e.pointerId===t)}_findPointerByMouseButton(t){return this._activePointers.find(e=>e.mouseButton===t)}_disposePointer(t){this._activePointers.splice(this._activePointers.indexOf(t),1)}_encloseToBoundary(t,e,i){const s=e.lengthSq();if(0===s)return t;const n=Ai.copy(e).add(t),r=this._boundary.clampPoint(n,Oi).sub(n),o=r.lengthSq();if(0===o)return t.add(e);if(o===s)return t;if(0===i)return t.add(e).add(r);{const s=1+i*o/e.dot(r);return t.add(Ai.copy(e).multiplyScalar(s)).add(r.multiplyScalar(1-i))}}_updateNearPlaneCorners(){if(ii(this._camera)){const t=this._camera,e=t.near,i=t.getEffectiveFOV()*oi,s=Math.tan(.5*i)*e,n=s*t.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(si(this._camera)){const t=this._camera,e=1/t.zoom,i=t.left*e,s=t.right*e,n=t.top*e,r=t.bottom*e;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)}}_collisionTest(){let t=1/0;if(!(this.colliderMeshes.length>=1))return t;if(gi(this._camera,"_collisionTest"))return t;const e=this._getTargetDirection(Pi);ji.lookAt(xi,e,this._camera.up);for(let i=0;i<4;i++){const s=Ai.copy(this._nearPlaneCorners[i]);s.applyMatrix4(ji);const n=Oi.addVectors(this._target,s);Zi.set(n,e),Zi.far=this._spherical.radius+1;const r=Zi.intersectObjects(this.colliderMeshes);0!==r.length&&r[0].distance<t&&(t=r[0].distance)}return t}_getClientRect(t){if(!this._domElement)return;const e=this._domElement.getBoundingClientRect();return t.x=e.left,t.y=e.top,this._viewport?(t.x+=this._viewport.x,t.y+=e.height-this._viewport.w-this._viewport.y,t.width=this._viewport.z,t.height=this._viewport.w):(t.width=e.width,t.height=e.height),t}_createOnRestPromise(t){return t?Promise.resolve():(this._hasRested=!1,this.dispatchEvent({type:"transitionstart"}),new Promise(t=>{const e=()=>{this.removeEventListener("rest",e),t()};this.addEventListener("rest",e)}))}_addAllEventListeners(t){}_removeAllEventListeners(){}get dampingFactor(){return console.warn(".dampingFactor has been deprecated. use smoothTime (in seconds) instead."),0}set dampingFactor(t){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(t){console.warn(".draggingDampingFactor has been deprecated. use draggingSmoothTime (in seconds) instead.")}static createBoundingSphere(t,e=new bi.Sphere){const i=e,s=i.center;Ui.makeEmpty(),t.traverseVisible(t=>{t.isMesh&&Ui.expandByObject(t)}),Ui.getCenter(s);let n=0;return t.traverseVisible(t=>{if(!t.isMesh)return;const e=t;if(!e.geometry)return;const i=e.geometry.clone();i.applyMatrix4(e.matrixWorld);const r=i.attributes.position;for(let t=0,e=r.count;t<e;t++)Si.fromBufferAttribute(r,t),n=Math.max(n,s.distanceToSquared(Si))}),i.radius=Math.sqrt(n),i}}class $i extends j{constructor(t){super(t),e(this,"onBeforeUpdate",new U),e(this,"onAfterUpdate",new U),e(this,"onAspectUpdated",new U),e(this,"onDisposed",new U),e(this,"three"),e(this,"_allControls",new Map),e(this,"updateAspect",()=>{var t;if(this.currentWorld&&this.currentWorld.renderer)if(this.three instanceof r.OrthographicCamera)this.onAspectUpdated.trigger();else if(null==(t=this.currentWorld.renderer)?void 0:t.isResizeable()){const t=this.currentWorld.renderer.getSize();this.three.aspect=t.width/t.height,this.three.updateProjectionMatrix(),this.onAspectUpdated.trigger()}}),this.three=this.setupCamera(),this.setupEvents(!0),this.worlds.onItemSet.add(({value:t})=>{const e=this.newCameraControls();this._allControls.set(t.uuid,e)}),this.worlds.onBeforeDelete.add(({value:t})=>{const e=this._allControls.get(t.uuid);e&&(e.dispose(),this._allControls.delete(t.uuid))})}get controls(){if(!this.currentWorld)throw new Error("This camera needs a world to work!");const t=this._allControls.get(this.currentWorld.uuid);if(!t)throw new Error("Controls not found!");return t}get enabled(){return null!==this.currentWorld&&this.controls.enabled}set enabled(t){null!==this.currentWorld&&(this.controls.enabled=t)}set currentWorld(t){if(super.currentWorld=t,!t)return;this.worlds.get(t.uuid)||this.worlds.set(t.uuid,t)}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[t,e]of this._allControls)e.dispose();this.worlds.clear()}async fitToItems(t){const e=await this.getItemsBounding(t);await this.controls.fitToSphere(e,!0)}async setOrbitToItems(t){const e=await this.getItemsBounding(t);this.controls.setOrbitPoint(e.center.x,e.center.y,e.center.z)}update(t){this.enabled&&(this.onBeforeUpdate.trigger(this),this.controls.update(t),this.onAfterUpdate.trigger(this))}async getItemsBounding(t){const e=this.components.get(Ae),i=this.components.get(Me);i.list.clear();const s=new r.Sphere;if(t)await i.addFromModelIdMap(t);else for(const[,t]of e.list)i.list.add(t.box);return i.get().getBoundingSphere(s),i.list.clear(),s}setupCamera(){const t=window.innerWidth/window.innerHeight,e=new r.PerspectiveCamera(60,t,1,1e3);return e.position.set(50,50,50),e.lookAt(new r.Vector3(0,0,0)),e}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!");Hi.install({THREE:$i.getSubsetOfThree()});const{domElement:t}=this.currentWorld.renderer.three,e=new Hi(this.three,t);return e.smoothTime=.2,e.dollyToCursor=!0,e.infinityDolly=!0,e.minDistance=6,e}setupEvents(t){t?window.addEventListener("resize",this.updateAspect):window.removeEventListener("resize",this.updateAspect)}static getSubsetOfThree(){return{MOUSE:r.MOUSE,Vector2:r.Vector2,Vector3:r.Vector3,Vector4:r.Vector4,Quaternion:r.Quaternion,Matrix4:r.Matrix4,Spherical:r.Spherical,Box3:r.Box3,Sphere:r.Sphere,Raycaster:r.Raycaster,MathUtils:r.MathUtils}}}const Wi=class t extends F{constructor(i){super(i),e(this,"onAfterUpdate",new U),e(this,"onBeforeUpdate",new U),e(this,"onDisposed",new U),e(this,"list",new we),e(this,"enabled",!0),i.add(t.uuid,this)}create(){const t=new Ze(this.components),e=t.uuid;if(this.list.has(e))throw new Error("There is already a world with this name!");return this.list.set(e,t),t}delete(t){if(!this.list.has(t.uuid))throw new Error("The provided world is not found in the list!");this.list.delete(t.uuid),t.dispose()}dispose(){this.enabled=!1;for(const[t,e]of this.list)e.dispose();this.list.clear(),this.onDisposed.trigger()}update(t){if(this.enabled)for(const[e,i]of this.list)i.update(t)}};e(Wi,"uuid","fdb61dc4-2ec1-4966-b83d-54ea795fad4a");let Yi=Wi;class Xi extends xe{constructor(){super(...arguments),e(this,"_config",{visible:{value:!0,type:"Boolean"},color:{value:new r.Color,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(t){this._config.visible.value=t,this._component.visible=t}get color(){return this._config.color.value}set color(t){this._config.color.value=t,this._component.material.uniforms.uColor.value=t,this._component.material.uniformsNeedUpdate=!0}get primarySize(){return this._config.primarySize.value}set primarySize(t){this._config.primarySize.value=t,this._component.material.uniforms.uSize1.value=t,this._component.material.uniformsNeedUpdate=!0}get secondarySize(){return this._config.secondarySize.value}set secondarySize(t){this._config.secondarySize.value=t,this._component.material.uniforms.uSize2.value=t,this._component.material.uniformsNeedUpdate=!0}get distance(){return this._config.distance.value}set distance(t){this._config.distance.value=t,this._component.material.uniforms.uDistance.value=t,this._component.material.uniformsNeedUpdate=!0}}class qi{constructor(t,i){e(this,"onDisposed",new U),e(this,"onSetup",new U),e(this,"isSetup",!1),e(this,"world"),e(this,"components"),e(this,"config"),e(this,"_defaultConfig",{visible:!0,color:new r.Color(12303291),primarySize:1,secondarySize:10,distance:500}),e(this,"three"),e(this,"_fade",3),e(this,"updateZoom",()=>{this.world.camera instanceof $i&&(this.material.uniforms.uZoom.value=this.world.camera.three.zoom)}),this.world=i;const{color:s,primarySize:n,secondarySize:o,distance:a}=this._defaultConfig;this.components=t,this.config=new Xi(this,this.components,"Grid");const l=new r.PlaneGeometry(2,2,1,1),h=new r.ShaderMaterial({side:r.DoubleSide,uniforms:{uSize1:{value:n},uSize2:{value:o},uColor:{value:s},uDistance:{value:a},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 r.Mesh(l,h),this.three.frustumCulled=!1,i.scene.three.add(this.three),this.setupEvents(!0)}get visible(){return this.three.visible}set visible(t){if(this.three.visible=t,t){this.world.scene.three.add(this.three)}else this.three.removeFromParent()}get material(){return this.three.material}get fade(){return 3===this._fade}set fade(t){this._fade=t?3:0,this.material.uniforms.uFade.value=this._fade}setup(t){const e={...this._defaultConfig,...t};this.config.visible=!0,this.config.color=e.color,this.config.primarySize=e.primarySize,this.config.secondarySize=e.secondarySize,this.config.distance=e.distance,this.isSetup=!0,this.onSetup.trigger()}dispose(){this.setupEvents(!1);this.components.get(Te).list.delete(this.config.uuid);this.components.get($).destroy(this.three),this.onDisposed.trigger(),this.onDisposed.reset(),this.world=null,this.components=null}setupEvents(t){if(this.world.isDisposing)return;if(!(this.world.camera instanceof $i))return;const e=this.world.camera.controls;t?e.addEventListener("update",this.updateZoom):e.removeEventListener("update",this.updateZoom)}}const Gi=class t extends F{constructor(i){super(i),e(this,"list",new Map),e(this,"onDisposed",new U),e(this,"enabled",!0),i.add(t.uuid,this)}create(t){if(this.list.has(t.uuid))throw new Error("This world already has a grid!");const e=new qi(this.components,t);return this.list.set(t.uuid,e),t.onDisposed.add(()=>{this.delete(t)}),e}delete(t){const e=this.list.get(t.uuid);e&&e.dispose(),this.list.delete(t.uuid)}dispose(){for(const[t,e]of this.list)e.dispose();this.list.clear(),this.onDisposed.trigger(),this.onDisposed.reset()}};e(Gi,"uuid","d1e814d5-b81c-4452-87a2-f039375e0489");let Qi=Gi;const Ki=1.25,Ji=65535,ts=Math.pow(2,-24),es=Symbol("SKIP_GENERATION");function is(t){return function(t){return t.index?t.index.count:t.attributes.position.count}(t)/3}function ss(t,e){if(!t.index){const i=t.attributes.position.count,s=function(t,e=ArrayBuffer){return t>65535?new Uint32Array(new e(4*t)):new Uint16Array(new e(2*t))}(i,e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer);t.setIndex(new o(s,1));for(let t=0;t<i;t++)s[t]=t}}function ns(t){const e=is(t),i=t.drawRange,s=i.start/3,n=(i.start+i.count)/3,r=Math.max(0,s),o=Math.min(e,n)-r;return[{offset:Math.floor(r),count:Math.floor(o)}]}function rs(t){if(!t.groups||!t.groups.length)return ns(t);const e=[],i=new Set,s=t.drawRange,n=s.start/3,r=(s.start+s.count)/3;for(const e of t.groups){const t=e.start/3,s=(e.start+e.count)/3;i.add(Math.max(n,t)),i.add(Math.min(r,s))}const o=Array.from(i.values()).sort((t,e)=>t-e);for(let t=0;t<o.length-1;t++){const i=o[t],s=o[t+1];e.push({offset:Math.floor(i),count:Math.floor(s-i)})}return e}function os(t,e,i){return i.min.x=e[t],i.min.y=e[t+1],i.min.z=e[t+2],i.max.x=e[t+3],i.max.y=e[t+4],i.max.z=e[t+5],i}function as(t){let e=-1,i=-1/0;for(let s=0;s<3;s++){const n=t[s+3]-t[s];n>i&&(i=n,e=s)}return e}function ls(t,e){e.set(t)}function hs(t,e,i){let s,n;for(let r=0;r<3;r++){const o=r+3;s=t[r],n=e[r],i[r]=s<n?s:n,s=t[o],n=e[o],i[o]=s>n?s:n}}function cs(t,e,i){for(let s=0;s<3;s++){const n=e[t+2*s],r=e[t+2*s+1],o=n-r,a=n+r;o<i[s]&&(i[s]=o),a>i[s+3]&&(i[s+3]=a)}}function ds(t){const e=t[3]-t[0],i=t[4]-t[1],s=t[5]-t[2];return 2*(e*i+i*s+s*e)}function us(t,e,i,s,n=null){let r=1/0,o=1/0,a=1/0,l=-1/0,h=-1/0,c=-1/0,d=1/0,u=1/0,p=1/0,f=-1/0,m=-1/0,g=-1/0;const _=null!==n;for(let s=6*e,n=6*(e+i);s<n;s+=6){const e=t[s+0],i=t[s+1],n=e-i,y=e+i;n<r&&(r=n),y>l&&(l=y),_&&e<d&&(d=e),_&&e>f&&(f=e);const w=t[s+2],v=t[s+3],b=w-v,x=w+v;b<o&&(o=b),x>h&&(h=x),_&&w<u&&(u=w),_&&w>m&&(m=w);const E=t[s+4],T=t[s+5],C=E-T,S=E+T;C<a&&(a=C),S>c&&(c=S),_&&E<p&&(p=E),_&&E>g&&(g=E)}s[0]=r,s[1]=o,s[2]=a,s[3]=l,s[4]=h,s[5]=c,_&&(n[0]=d,n[1]=u,n[2]=p,n[3]=f,n[4]=m,n[5]=g)}const ps=32,fs=(t,e)=>t.candidate-e.candidate,ms=new Array(ps).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),gs=new Float32Array(6);class _s{constructor(){}}function ys(t,e,i,s,n,r){let o=s,a=s+n-1;const l=r.pos,h=2*r.axis;for(;;){for(;o<=a&&i[6*o+h]<l;)o++;for(;o<=a&&i[6*a+h]>=l;)a--;if(!(o<a))return o;for(let t=0;t<3;t++){let i=e[3*o+t];e[3*o+t]=e[3*a+t],e[3*a+t]=i}for(let t=0;t<6;t++){let e=i[6*o+t];i[6*o+t]=i[6*a+t],i[6*a+t]=e}o++,a--}}function ws(t,e,i,s,n,r){let o=s,a=s+n-1;const l=r.pos,h=2*r.axis;for(;;){for(;o<=a&&i[6*o+h]<l;)o++;for(;o<=a&&i[6*a+h]>=l;)a--;if(!(o<a))return o;{let e=t[o];t[o]=t[a],t[a]=e;for(let t=0;t<6;t++){let e=i[6*o+t];i[6*o+t]=i[6*a+t],i[6*a+t]=e}o++,a--}}}function vs(t,e){const i=t.geometry,s=i.index?i.index.array:null,n=e.maxDepth,r=e.verbose,o=e.maxLeafTris,a=e.strategy,l=e.onProgress,h=is(i),c=t._indirectBuffer;let d=!1;const u=new Float32Array(6),p=new Float32Array(6),f=function(t,e){var i;(i=e)[0]=i[1]=i[2]=1/0,i[3]=i[4]=i[5]=-1/0;const s=t.attributes.position,n=t.index?t.index.array:null,r=is(t),o=new Float32Array(6*r),a=s.normalized,l=s.array,h=s.offset||0;let c=3;s.isInterleavedBufferAttribute&&(c=s.data.stride);const d=["getX","getY","getZ"];for(let t=0;t<r;t++){const i=3*t,r=6*t;let u=i+0,p=i+1,f=i+2;n&&(u=n[u],p=n[p],f=n[f]),a||(u=u*c+h,p=p*c+h,f=f*c+h);for(let t=0;t<3;t++){let i,n,h;a?(i=s[d[t]](u),n=s[d[t]](p),h=s[d[t]](f)):(i=l[u+t],n=l[p+t],h=l[f+t]);let c=i;n<c&&(c=n),h<c&&(c=h);let m=i;n>m&&(m=n),h>m&&(m=h);const g=(m-c)/2,_=2*t;o[r+_+0]=c+g,o[r+_+1]=g+(Math.abs(c)+g)*ts,c<e[t]&&(e[t]=c),m>e[t+3]&&(e[t+3]=m)}}return o}(i,u),m=e.indirect?ws:ys,g=[],_=e.indirect?ns(i):rs(i);if(1===_.length){const t=_[0],e=new _s;e.boundingData=u,function(t,e,i,s){let n=1/0,r=1/0,o=1/0,a=-1/0,l=-1/0,h=-1/0;for(let s=6*e,c=6*(e+i);s<c;s+=6){const e=t[s+0];e<n&&(n=e),e>a&&(a=e);const i=t[s+2];i<r&&(r=i),i>l&&(l=i);const c=t[s+4];c<o&&(o=c),c>h&&(h=c)}s[0]=n,s[1]=r,s[2]=o,s[3]=a,s[4]=l,s[5]=h}(f,t.offset,t.count,p),w(e,t.offset,t.count,p),g.push(e)}else for(let t of _){const e=new _s;e.boundingData=new Float32Array(6),us(f,t.offset,t.count,e.boundingData,p),w(e,t.offset,t.count,p),g.push(e)}return g;function y(t){l&&l(t/h)}function w(t,e,l,h=null,u=0){if(!d&&u>=n&&(d=!0,r&&(console.warn(`MeshBVH: Max depth of ${n} reached when generating BVH. Consider increasing maxDepth.`),console.warn(i))),l<=o||u>=n)return y(e+l),t.offset=e,t.count=l,t;const g=function(t,e,i,s,n,r){let o=-1,a=0;if(0===r)o=as(e),-1!==o&&(a=(e[o]+e[o+3])/2);else if(1===r)o=as(t),-1!==o&&(a=function(t,e,i,s){let n=0;for(let r=e,o=e+i;r<o;r++)n+=t[6*r+2*s];return n/i}(i,s,n,o));else if(2===r){const r=ds(t);let l=Ki*n;const h=6*s,c=6*(s+n);for(let t=0;t<3;t++){const s=e[t],d=(e[t+3]-s)/ps;if(n<8){const e=[...ms];e.length=n;let s=0;for(let n=h;n<c;n+=6,s++){const r=e[s];r.candidate=i[n+2*t],r.count=0;const{bounds:o,leftCacheBounds:a,rightCacheBounds:l}=r;for(let t=0;t<3;t++)l[t]=1/0,l[t+3]=-1/0,a[t]=1/0,a[t+3]=-1/0,o[t]=1/0,o[t+3]=-1/0;cs(n,i,o)}e.sort(fs);let d=n;for(let t=0;t<d;t++){const i=e[t];for(;t+1<d&&e[t+1].candidate===i.candidate;)e.splice(t+1,1),d--}for(let s=h;s<c;s+=6){const n=i[s+2*t];for(let t=0;t<d;t++){const r=e[t];n>=r.candidate?cs(s,i,r.rightCacheBounds):(cs(s,i,r.leftCacheBounds),r.count++)}}for(let i=0;i<d;i++){const s=e[i],h=s.count,c=n-s.count,d=s.leftCacheBounds,u=s.rightCacheBounds;let p=0;0!==h&&(p=ds(d)/r);let f=0;0!==c&&(f=ds(u)/r);const m=1+Ki*(p*h+f*c);m<l&&(o=t,l=m,a=s.candidate)}}else{for(let t=0;t<ps;t++){const e=ms[t];e.count=0,e.candidate=s+d+t*d;const i=e.bounds;for(let t=0;t<3;t++)i[t]=1/0,i[t+3]=-1/0}for(let e=h;e<c;e+=6){let n=~~((i[e+2*t]-s)/d);n>=ps&&(n=31);const r=ms[n];r.count++,cs(e,i,r.bounds)}const e=ms[31];ls(e.bounds,e.rightCacheBounds);for(let t=30;t>=0;t--){const e=ms[t],i=ms[t+1];hs(e.bounds,i.rightCacheBounds,e.rightCacheBounds)}let u=0;for(let e=0;e<31;e++){const i=ms[e],s=i.count,h=i.bounds,c=ms[e+1].rightCacheBounds;0!==s&&(0===u?ls(h,gs):hs(h,gs,gs)),u+=s;let d=0,p=0;0!==u&&(d=ds(gs)/r);const f=n-u;0!==f&&(p=ds(c)/r);const m=1+Ki*(d*u+p*f);m<l&&(o=t,l=m,a=i.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${r} used.`);return{axis:o,pos:a}}(t.boundingData,h,f,e,l,a);if(-1===g.axis)return y(e+l),t.offset=e,t.count=l,t;const _=m(c,s,f,e,l,g);if(_===e||_===e+l)y(e+l),t.offset=e,t.count=l;else{t.splitAxis=g.axis;const i=new _s,s=e,n=_-e;t.left=i,i.boundingData=new Float32Array(6),us(f,s,n,i.boundingData,p),w(i,s,n,p,u+1);const r=new _s,o=_,a=l-n;t.right=r,r.boundingData=new Float32Array(6),us(f,o,a,r.boundingData,p),w(r,o,a,p,u+1)}return t}}function bs(t,e){const i=t.geometry;e.indirect&&(t._indirectBuffer=function(t,e){const i=(t.index?t.index.count:t.attributes.position.count)/3,s=i>65536,n=s?4:2,r=e?new SharedArrayBuffer(i*n):new ArrayBuffer(i*n),o=s?new Uint32Array(r):new Uint16Array(r);for(let t=0,e=o.length;t<e;t++)o[t]=t;return o}(i,e.useSharedArrayBuffer),function(t){if(0===t.groups.length)return!1;const e=is(t),i=rs(t).sort((t,e)=>t.offset-e.offset),s=i[i.length-1];s.count=Math.min(e-s.offset,s.count);let n=0;return i.forEach(({count:t})=>n+=t),e!==n}(i)&&!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.')),t._indirectBuffer||ss(i,e);const s=vs(t,e);let n,r,o;const a=[],l=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;for(let t=0;t<s.length;t++){const e=s[t];const i=new l(32*h(e));n=new Float32Array(i),r=new Uint32Array(i),o=new Uint16Array(i),c(0,e),a.push(i)}return void(t._roots=a);function h(t){return t.count?1:1+h(t.left)+h(t.right)}function c(t,e){const i=t/4,s=t/2,a=!!e.count,l=e.boundingData;for(let t=0;t<6;t++)n[i+t]=l[t];if(a){const n=e.offset,a=e.count;return r[i+6]=n,o[s+14]=a,o[s+15]=Ji,t+32}{const s=e.left,n=e.right,o=e.splitAxis;let a;if(a=c(t+32,s),a/4>Math.pow(2,32))throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return r[i+6]=a/4,a=c(a,n),r[i+7]=o,a}}}class xs{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(t,e){let i=1/0,s=-1/0;for(let n=0,r=t.length;n<r;n++){const r=t[n][e];i=r<i?r:i,s=r>s?r:s}this.min=i,this.max=s}setFromPoints(t,e){let i=1/0,s=-1/0;for(let n=0,r=e.length;n<r;n++){const r=e[n],o=t.dot(r);i=o<i?o:i,s=o>s?o:s}this.min=i,this.max=s}isSeparated(t){return this.min>t.max||t.min>this.max}}xs.prototype.setFromBox=function(){const t=new a;return function(e,i){const s=i.min,n=i.max;let r=1/0,o=-1/0;for(let i=0;i<=1;i++)for(let a=0;a<=1;a++)for(let l=0;l<=1;l++){t.x=s.x*i+n.x*(1-i),t.y=s.y*a+n.y*(1-a),t.z=s.z*l+n.z*(1-l);const h=e.dot(t);r=Math.min(h,r),o=Math.max(h,o)}this.min=r,this.max=o}}();const Es=function(){const t=new a,e=new a,i=new a;return function(s,n,r){const o=s.start,a=t,l=n.start,h=e;i.subVectors(o,l),t.subVectors(s.end,s.start),e.subVectors(n.end,n.start);const c=i.dot(h),d=h.dot(a),u=h.dot(h),p=i.dot(a),f=a.dot(a)*u-d*d;let m,g;m=0!==f?(c*d-p*u)/f:0,g=(c+m*d)/u,r.x=m,r.y=g}}(),Ts=function(){const t=new c,e=new a,i=new a;return function(s,n,r,o){Es(s,n,t);let a=t.x,l=t.y;if(a>=0&&a<=1&&l>=0&&l<=1)return s.at(a,r),void n.at(l,o);if(a>=0&&a<=1)return l<0?n.at(0,o):n.at(1,o),void s.closestPointToPoint(o,!0,r);if(l>=0&&l<=1)return a<0?s.at(0,r):s.at(1,r),void n.closestPointToPoint(r,!0,o);{let t,h;t=a<0?s.start:s.end,h=l<0?n.start:n.end;const c=e,d=i;return s.closestPointToPoint(h,!0,e),n.closestPointToPoint(t,!0,i),c.distanceToSquared(h)<=d.distanceToSquared(t)?(r.copy(c),void o.copy(h)):(r.copy(t),void o.copy(d))}}}(),Cs=function(){const t=new a,e=new a,i=new l,s=new h;return function(n,r){const{radius:o,center:a}=n,{a:l,b:h,c:c}=r;s.start=l,s.end=h;if(s.closestPointToPoint(a,!0,t).distanceTo(a)<=o)return!0;s.start=l,s.end=c;if(s.closestPointToPoint(a,!0,t).distanceTo(a)<=o)return!0;s.start=h,s.end=c;if(s.closestPointToPoint(a,!0,t).distanceTo(a)<=o)return!0;const d=r.getPlane(i);if(Math.abs(d.distanceToPoint(a))<=o){const t=d.projectPoint(a,e);if(r.containsPoint(t))return!0}return!1}}();function Ss(t){return Math.abs(t)<1e-15}class As extends d{constructor(...t){super(...t),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new a),this.satBounds=new Array(4).fill().map(()=>new xs),this.points=[this.a,this.b,this.c],this.sphere=new u,this.plane=new l,this.needsUpdate=!0}intersectsSphere(t){return Cs(t,this)}update(){const t=this.a,e=this.b,i=this.c,s=this.points,n=this.satAxes,r=this.satBounds,o=n[0],a=r[0];this.getNormal(o),a.setFromPoints(o,s);const l=n[1],h=r[1];l.subVectors(t,e),h.setFromPoints(l,s);const c=n[2],d=r[2];c.subVectors(e,i),d.setFromPoints(c,s);const u=n[3],p=r[3];u.subVectors(i,t),p.setFromPoints(u,s),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(o,t),this.needsUpdate=!1}}As.prototype.closestPointToSegment=function(){const t=new a,e=new a,i=new h;return function(s,n=null,r=null){const{start:o,end:a}=s,l=this.points;let h,c=1/0;for(let o=0;o<3;o++){const a=(o+1)%3;i.start.copy(l[o]),i.end.copy(l[a]),Ts(i,s,t,e),h=t.distanceToSquared(e),h<c&&(c=h,n&&n.copy(t),r&&r.copy(e))}return this.closestPointToPoint(o,t),h=o.distanceToSquared(t),h<c&&(c=h,n&&n.copy(t),r&&r.copy(o)),this.closestPointToPoint(a,t),h=a.distanceToSquared(t),h<c&&(c=h,n&&n.copy(t),r&&r.copy(a)),Math.sqrt(c)}}(),As.prototype.intersectsTriangle=function(){const t=new As,e=new Array(3),i=new Array(3),s=new xs,n=new xs,r=new a,o=new a,l=new a,c=new a,d=new a,u=new h,p=new h,f=new h,m=new a;function g(t,e,i){const s=t.points;let n=0,r=-1;for(let t=0;t<3;t++){const{start:a,end:l}=u;a.copy(s[t]),l.copy(s[(t+1)%3]),u.delta(o);const h=Ss(e.distanceToPoint(a));if(Ss(e.normal.dot(o))&&h){i.copy(u),n=2;break}const c=e.intersectLine(u,m);if(!c&&h&&m.copy(a),(c||h)&&!Ss(m.distanceTo(l))){if(n<=1){(1===n?i.start:i.end).copy(m),h&&(r=n)}else if(n>=2){(1===r?i.start:i.end).copy(m),n=2;break}if(n++,2===n&&-1===r)break}}return n}return function(o,a=null,h=!1){this.needsUpdate&&this.update(),o.isExtendedTriangle?o.needsUpdate&&o.update():(t.copy(o),t.update(),o=t);const u=this.plane,m=o.plane;if(Math.abs(u.normal.dot(m.normal))>1-1e-10){const t=this.satBounds,l=this.satAxes;i[0]=o.a,i[1]=o.b,i[2]=o.c;for(let e=0;e<4;e++){const n=t[e],r=l[e];if(s.setFromPoints(r,i),n.isSeparated(s))return!1}const c=o.satBounds,d=o.satAxes;e[0]=this.a,e[1]=this.b,e[2]=this.c;for(let t=0;t<4;t++){const i=c[t],n=d[t];if(s.setFromPoints(n,e),i.isSeparated(s))return!1}for(let t=0;t<4;t++){const o=l[t];for(let t=0;t<4;t++){const a=d[t];if(r.crossVectors(o,a),s.setFromPoints(r,e),n.setFromPoints(r,i),s.isSeparated(n))return!1}}return a&&(h||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),a.start.set(0,0,0),a.end.set(0,0,0)),!0}{const t=g(this,m,p);if(1===t&&o.containsPoint(p.end))return a&&(a.start.copy(p.end),a.end.copy(p.end)),!0;if(2!==t)return!1;const e=g(o,u,f);if(1===e&&this.containsPoint(f.end))return a&&(a.start.copy(f.end),a.end.copy(f.end)),!0;if(2!==e)return!1;if(p.delta(l),f.delta(c),l.dot(c)<0){let t=f.start;f.start=f.end,f.end=t}const i=p.start.dot(l),s=p.end.dot(l),n=f.start.dot(l),r=f.end.dot(l);return(i===r||n===s||s<n!==i<r)&&(a&&(d.subVectors(p.start,f.start),d.dot(l)>0?a.start.copy(p.start):a.start.copy(f.start),d.subVectors(p.end,f.end),d.dot(l)<0?a.end.copy(p.end):a.end.copy(f.end)),!0)}}}(),As.prototype.distanceToPoint=function(){const t=new a;return function(e){return this.closestPointToPoint(e,t),e.distanceTo(t)}}(),As.prototype.distanceToTriangle=function(){const t=new a,e=new a,i=["a","b","c"],s=new h,n=new h;return function(r,o=null,a=null){const l=o||a?s:null;if(this.intersectsTriangle(r,l))return(o||a)&&(o&&l.getCenter(o),a&&l.getCenter(a)),0;let h=1/0;for(let e=0;e<3;e++){let s;const n=i[e],l=r[n];this.closestPointToPoint(l,t),s=l.distanceToSquared(t),s<h&&(h=s,o&&o.copy(t),a&&a.copy(l));const c=this[n];r.closestPointToPoint(c,t),s=c.distanceToSquared(t),s<h&&(h=s,o&&o.copy(c),a&&a.copy(t))}for(let l=0;l<3;l++){const c=i[l],d=i[(l+1)%3];s.set(this[c],this[d]);for(let l=0;l<3;l++){const c=i[l],d=i[(l+1)%3];n.set(r[c],r[d]),Ts(s,n,t,e);const u=t.distanceToSquared(e);u<h&&(h=u,o&&o.copy(t),a&&a.copy(e))}}return Math.sqrt(h)}}();class Os{constructor(t,e,i){this.isOrientedBox=!0,this.min=new a,this.max=new a,this.matrix=new p,this.invMatrix=new p,this.points=new Array(8).fill().map(()=>new a),this.satAxes=new Array(3).fill().map(()=>new a),this.satBounds=new Array(3).fill().map(()=>new xs),this.alignedSatBounds=new Array(3).fill().map(()=>new xs),this.needsUpdate=!1,t&&this.min.copy(t),e&&this.max.copy(e),i&&this.matrix.copy(i)}set(t,e,i){this.min.copy(t),this.max.copy(e),this.matrix.copy(i),this.needsUpdate=!0}copy(t){this.min.copy(t.min),this.max.copy(t.max),this.matrix.copy(t.matrix),this.needsUpdate=!0}}Os.prototype.update=function(){return function(){const t=this.matrix,e=this.min,i=this.max,s=this.points;for(let n=0;n<=1;n++)for(let r=0;r<=1;r++)for(let o=0;o<=1;o++){const a=s[1*n|2*r|4*o];a.x=n?i.x:e.x,a.y=r?i.y:e.y,a.z=o?i.z:e.z,a.applyMatrix4(t)}const n=this.satBounds,r=this.satAxes,o=s[0];for(let t=0;t<3;t++){const e=r[t],i=n[t],a=s[1<<t];e.subVectors(o,a),i.setFromPoints(e,s)}const a=this.alignedSatBounds;a[0].setFromPointsField(s,"x"),a[1].setFromPointsField(s,"y"),a[2].setFromPointsField(s,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}(),Os.prototype.intersectsBox=function(){const t=new xs;return function(e){this.needsUpdate&&this.update();const i=e.min,s=e.max,n=this.satBounds,r=this.satAxes,o=this.alignedSatBounds;if(t.min=i.x,t.max=s.x,o[0].isSeparated(t))return!1;if(t.min=i.y,t.max=s.y,o[1].isSeparated(t))return!1;if(t.min=i.z,t.max=s.z,o[2].isSeparated(t))return!1;for(let i=0;i<3;i++){const s=r[i],o=n[i];if(t.setFromBox(s,e),o.isSeparated(t))return!1}return!0}}(),Os.prototype.intersectsTriangle=function(){const t=new As,e=new Array(3),i=new xs,s=new xs,n=new a;return function(r){this.needsUpdate&&this.update(),r.isExtendedTriangle?r.needsUpdate&&r.update():(t.copy(r),t.update(),r=t);const o=this.satBounds,a=this.satAxes;e[0]=r.a,e[1]=r.b,e[2]=r.c;for(let t=0;t<3;t++){const s=o[t],n=a[t];if(i.setFromPoints(n,e),s.isSeparated(i))return!1}const l=r.satBounds,h=r.satAxes,c=this.points;for(let t=0;t<3;t++){const e=l[t],s=h[t];if(i.setFromPoints(s,c),e.isSeparated(i))return!1}for(let t=0;t<3;t++){const r=a[t];for(let t=0;t<4;t++){const o=h[t];if(n.crossVectors(r,o),i.setFromPoints(n,e),s.setFromPoints(n,c),i.isSeparated(s))return!1}}return!0}}(),Os.prototype.closestPointToPoint=function(){return function(t,e){return this.needsUpdate&&this.update(),e.copy(t).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),e}}(),Os.prototype.distanceToPoint=function(){const t=new a;return function(e){return this.closestPointToPoint(e,t),e.distanceTo(t)}}(),Os.prototype.distanceToBox=function(){const t=["x","y","z"],e=new Array(12).fill().map(()=>new h),i=new Array(12).fill().map(()=>new h),s=new a,n=new a;return function(r,o=0,a=null,l=null){if(this.needsUpdate&&this.update(),this.intersectsBox(r))return(a||l)&&(r.getCenter(n),this.closestPointToPoint(n,s),r.closestPointToPoint(s,n),a&&a.copy(s),l&&l.copy(n)),0;const h=o*o,c=r.min,d=r.max,u=this.points;let p=1/0;for(let t=0;t<8;t++){const e=u[t];n.copy(e).clamp(c,d);const i=e.distanceToSquared(n);if(i<p&&(p=i,a&&a.copy(e),l&&l.copy(n),i<h))return Math.sqrt(i)}let f=0;for(let s=0;s<3;s++)for(let n=0;n<=1;n++)for(let r=0;r<=1;r++){const o=(s+1)%3,a=(s+2)%3,l=1<<s|n<<o|r<<a,h=u[n<<o|r<<a],p=u[l];e[f].set(h,p);const m=t[s],g=t[o],_=t[a],y=i[f],w=y.start,v=y.end;w[m]=c[m],w[g]=n?c[g]:d[g],w[_]=r?c[_]:d[g],v[m]=d[m],v[g]=n?c[g]:d[g],v[_]=r?c[_]:d[g],f++}for(let t=0;t<=1;t++)for(let e=0;e<=1;e++)for(let i=0;i<=1;i++){n.x=t?d.x:c.x,n.y=e?d.y:c.y,n.z=i?d.z:c.z,this.closestPointToPoint(n,s);const r=n.distanceToSquared(s);if(r<p&&(p=r,a&&a.copy(s),l&&l.copy(n),r<h))return Math.sqrt(r)}for(let t=0;t<12;t++){const r=e[t];for(let t=0;t<12;t++){const e=i[t];Ts(r,e,s,n);const o=s.distanceToSquared(n);if(o<p&&(p=o,a&&a.copy(s),l&&l.copy(n),o<h))return Math.sqrt(o)}}return Math.sqrt(p)}}();class Ps{constructor(t){this._getNewPrimitive=t,this._primitives=[]}getPrimitive(){const t=this._primitives;return 0===t.length?this._getNewPrimitive():t.pop()}releasePrimitive(t){this._primitives.push(t)}}class Is extends Ps{constructor(){super(()=>new As)}}const ks=new Is;function Ds(t,e){return 65535===e[t+15]}function zs(t,e){return e[t+6]}function Ms(t,e){return e[t+14]}function Bs(t){return t+8}function Ns(t,e){return e[t+6]}function Us(t,e){return e[t+7]}function Ls(t){return t}const Rs=new class{constructor(){this.float32Array=null,this.uint16Array=null,this.uint32Array=null;const t=[];let e=null;this.setBuffer=i=>{e&&t.push(e),e=i,this.float32Array=new Float32Array(i),this.uint16Array=new Uint16Array(i),this.uint32Array=new Uint32Array(i)},this.clearBuffer=()=>{e=null,this.float32Array=null,this.uint16Array=null,this.uint32Array=null,0!==t.length&&this.setBuffer(t.pop())}}};let Fs,Vs;const js=[],Zs=new Ps(()=>new f);function Hs(t,e,i,s,n,r){Fs=Zs.getPrimitive(),Vs=Zs.getPrimitive(),js.push(Fs,Vs),Rs.setBuffer(t._roots[e]);const o=$s(0,t.geometry,i,s,n,r);Rs.clearBuffer(),Zs.releasePrimitive(Fs),Zs.releasePrimitive(Vs),js.pop(),js.pop();const a=js.length;return a>0&&(Vs=js[a-1],Fs=js[a-2]),o}function $s(t,e,i,s,n=null,r=0,o=0){const{float32Array:a,uint16Array:l,uint32Array:h}=Rs;let c=2*t;if(Ds(c,l)){const e=zs(t,h),i=Ms(c,l);return os(t,a,Fs),s(e,i,!1,o,r+t,Fs)}{let c=function(t){const{uint16Array:e,uint32Array:i}=Rs;let s=2*t;for(;!Ds(s,e);)s=2*(t=Bs(t));return zs(t,i)},d=function(t){const{uint16Array:e,uint32Array:i}=Rs;let s=2*t;for(;!Ds(s,e);)s=2*(t=Ns(t,i));return zs(t,i)+Ms(s,e)};const u=Bs(t),p=Ns(t,h);let f,m,g,_,y=u,w=p;if(n&&(g=Fs,_=Vs,os(y,a,g),os(w,a,_),f=n(g),m=n(_),m<f)){y=p,w=u;const t=f;f=m,m=t,g=_}g||(g=Fs,os(y,a,g));const v=i(g,Ds(2*y,l),f,o+1,r+y);let b;if(2===v){const t=c(y);b=s(t,d(y)-t,!0,o+1,r+y,g)}else b=v&&$s(y,e,i,s,n,r,o+1);if(b)return!0;_=Vs,os(w,a,_);const x=i(_,Ds(2*w,l),m,o+1,r+w);let E;if(2===x){const t=c(w);E=s(t,d(w)-t,!0,o+1,r+w,_)}else E=x&&$s(w,e,i,s,n,r,o+1);return!!E}}const Ws=new a,Ys=new a;const Xs=new a,qs=new a,Gs=new a,Qs=new c,Ks=new c,Js=new c,tn=new a,en=new a,sn=new a,nn=new a;function rn(t,e,i,s,n,r,o,l,h){Xs.fromBufferAttribute(e,r),qs.fromBufferAttribute(e,o),Gs.fromBufferAttribute(e,l);const u=function(t,e,i,s,n,r){let o;return o=r===m?t.intersectTriangle(s,i,e,!0,n):t.intersectTriangle(e,i,s,r!==g,n),null===o?null:{distance:t.origin.distanceTo(n),point:n.clone()}}(t,Xs,qs,Gs,nn,h);if(u){s&&(Qs.fromBufferAttribute(s,r),Ks.fromBufferAttribute(s,o),Js.fromBufferAttribute(s,l),u.uv=d.getInterpolation(nn,Xs,qs,Gs,Qs,Ks,Js,new c)),n&&(Qs.fromBufferAttribute(n,r),Ks.fromBufferAttribute(n,o),Js.fromBufferAttribute(n,l),u.uv1=d.getInterpolation(nn,Xs,qs,Gs,Qs,Ks,Js,new c)),i&&(tn.fromBufferAttribute(i,r),en.fromBufferAttribute(i,o),sn.fromBufferAttribute(i,l),u.normal=d.getInterpolation(nn,Xs,qs,Gs,tn,en,sn,new a),u.normal.dot(t.direction)>0&&u.normal.multiplyScalar(-1));const e={a:r,b:o,c:l,normal:new a,materialIndex:0};d.getNormal(Xs,qs,Gs,e.normal),u.face=e,u.faceIndex=r}return u}function on(t,e,i,s,n){const r=3*s;let o=r+0,a=r+1,l=r+2;const h=t.index;t.index&&(o=h.getX(o),a=h.getX(a),l=h.getX(l));const{position:c,normal:d,uv:u,uv1:p}=t.attributes,f=rn(i,c,d,u,p,o,a,l,e);return f?(f.faceIndex=s,n&&n.push(f),f):null}function an(t,e,i,s){const n=t.a,r=t.b,o=t.c;let a=e,l=e+1,h=e+2;i&&(a=i.getX(a),l=i.getX(l),h=i.getX(h)),n.x=s.getX(a),n.y=s.getY(a),n.z=s.getZ(a),r.x=s.getX(l),r.y=s.getY(l),r.z=s.getZ(l),o.x=s.getX(h),o.y=s.getY(h),o.z=s.getZ(h)}function ln(t,e,i,s,n,r,o){const{geometry:a}=i,{index:l}=a,h=a.attributes.position;for(let i=t,a=e+t;i<a;i++){let t;if(t=i,an(o,3*t,l,h),o.needsUpdate=!0,s(o,t,n,r))return!0}return!1}function hn(t,e=null){e&&Array.isArray(e)&&(e=new Set(e));const i=t.geometry,s=i.index?i.index.array:null,n=i.attributes.position;let r,o,a,l,h=0;const c=t._roots;for(let t=0,e=c.length;t<e;t++)r=c[t],o=new Uint32Array(r),a=new Uint16Array(r),l=new Float32Array(r),d(0,h),h+=r.byteLength;function d(t,i,r=!1){const h=2*t;if(a[h+15]===Ji){const e=o[t+6];let i=1/0,r=1/0,c=1/0,d=-1/0,u=-1/0,p=-1/0;for(let t=3*e,o=3*(e+a[h+14]);t<o;t++){let e=s[t];const o=n.getX(e),a=n.getY(e),l=n.getZ(e);o<i&&(i=o),o>d&&(d=o),a<r&&(r=a),a>u&&(u=a),l<c&&(c=l),l>p&&(p=l)}return(l[t+0]!==i||l[t+1]!==r||l[t+2]!==c||l[t+3]!==d||l[t+4]!==u||l[t+5]!==p)&&(l[t+0]=i,l[t+1]=r,l[t+2]=c,l[t+3]=d,l[t+4]=u,l[t+5]=p,!0)}{const s=t+8,n=o[t+6],a=s+i,h=n+i;let c=r,u=!1,p=!1;e?c||(u=e.has(a),p=e.has(h),c=!u&&!p):(u=!0,p=!0);const f=c||p;let m=!1;(c||u)&&(m=d(s,i,c));let g=!1;f&&(g=d(n,i,c));const _=m||g;if(_)for(let e=0;e<3;e++){const i=s+e,r=n+e,o=l[i],a=l[i+3],h=l[r],c=l[r+3];l[t+e]=o<h?o:h,l[t+e+3]=a>c?a:c}return _}}}const cn=new f;function dn(t,e,i,s){return os(t,e,cn),i.intersectBox(cn,s)}function un(t,e,i,s,n,r,o){const{geometry:a}=i,{index:l}=a,h=a.attributes.position;for(let a=t,c=e+t;a<c;a++){let t;if(t=i.resolveTriangleIndex(a),an(o,3*t,l,h),o.needsUpdate=!0,s(o,t,n,r))return!0}return!1}const pn=new a;function fn(t,e,i,s,n){Rs.setBuffer(t._roots[e]),mn(0,t,i,s,n),Rs.clearBuffer()}function mn(t,e,i,s,n){const{float32Array:r,uint16Array:o,uint32Array:a}=Rs,l=2*t;if(Ds(l,o)){!function(t,e,i,s,n,r){const{geometry:o,_indirectBuffer:a}=t;for(let t=s,a=s+n;t<a;t++)on(o,e,i,t,r)}(e,i,s,zs(t,a),Ms(l,o),n)}else{const o=Bs(t);dn(o,r,s,pn)&&mn(o,e,i,s,n);const l=Ns(t,a);dn(l,r,s,pn)&&mn(l,e,i,s,n)}}const gn=new a,_n=["x","y","z"];function yn(t,e,i,s){Rs.setBuffer(t._roots[e]);const n=wn(0,t,i,s);return Rs.clearBuffer(),n}function wn(t,e,i,s){const{float32Array:n,uint16Array:r,uint32Array:o}=Rs;let a=2*t;if(Ds(a,r)){return function(t,e,i,s,n){const{geometry:r,_indirectBuffer:o}=t;let a=1/0,l=null;for(let t=s,o=s+n;t<o;t++){let s;s=on(r,e,i,t),s&&s.distance<a&&(l=s,a=s.distance)}return l}(e,i,s,zs(t,o),Ms(a,r))}{const r=Us(t,o),a=_n[r],l=s.direction[a]>=0;let h,c;l?(h=Bs(t),c=Ns(t,o)):(h=Ns(t,o),c=Bs(t));const d=dn(h,n,s,gn)?wn(h,e,i,s):null;if(d){const t=d.point[a];if(l?t<=n[c+r]:t>=n[c+r+3])return d}const u=dn(c,n,s,gn)?wn(c,e,i,s):null;return d&&u?d.distance<=u.distance?d:u:d||u||null}}const vn=new f,bn=new As,xn=new As,En=new p,Tn=new Os,Cn=new Os;function Sn(t,e,i,s){Rs.setBuffer(t._roots[e]);const n=An(0,t,i,s);return Rs.clearBuffer(),n}function An(t,e,i,s,n=null){const{float32Array:r,uint16Array:o,uint32Array:a}=Rs;let l=2*t;null===n&&(i.boundingBox||i.computeBoundingBox(),Tn.set(i.boundingBox.min,i.boundingBox.max,s),n=Tn);if(!Ds(l,o)){const o=t+8,l=a[t+6];os(o,r,vn);if(n.intersectsBox(vn)&&An(o,e,i,s,n))return!0;os(l,r,vn);return!!(n.intersectsBox(vn)&&An(l,e,i,s,n))}{const n=e.geometry,h=n.index,c=n.attributes.position,d=i.index,u=i.attributes.position,p=zs(t,a),f=Ms(l,o);if(En.copy(s).invert(),i.boundsTree){os(t,r,Cn),Cn.matrix.copy(En),Cn.needsUpdate=!0;return i.boundsTree.shapecast({intersectsBounds:t=>Cn.intersectsBox(t),intersectsTriangle:t=>{t.a.applyMatrix4(s),t.b.applyMatrix4(s),t.c.applyMatrix4(s),t.needsUpdate=!0;for(let e=3*p,i=3*(f+p);e<i;e+=3)if(an(xn,e,h,c),xn.needsUpdate=!0,t.intersectsTriangle(xn))return!0;return!1}})}for(let t=3*p,e=3*(f+p);t<e;t+=3){an(bn,t,h,c),bn.a.applyMatrix4(En),bn.b.applyMatrix4(En),bn.c.applyMatrix4(En),bn.needsUpdate=!0;for(let t=0,e=d.count;t<e;t+=3)if(an(xn,t,d,u),xn.needsUpdate=!0,bn.intersectsTriangle(xn))return!0}}}const On=new p,Pn=new Os,In=new Os,kn=new a,Dn=new a,zn=new a,Mn=new a;function Bn(t,e,i,s={},n={},r=0,o=1/0){e.boundingBox||e.computeBoundingBox(),Pn.set(e.boundingBox.min,e.boundingBox.max,i),Pn.needsUpdate=!0;const a=t.geometry,l=a.attributes.position,h=a.index,c=e.attributes.position,d=e.index,u=ks.getPrimitive(),p=ks.getPrimitive();let f=kn,m=Dn,g=null,_=null;n&&(g=zn,_=Mn);let y=1/0,w=null,v=null;return On.copy(i).invert(),In.matrix.copy(On),t.shapecast({boundsTraverseOrder:t=>Pn.distanceToBox(t),intersectsBounds:(t,e,i)=>i<y&&i<o&&(e&&(In.min.copy(t.min),In.max.copy(t.max),In.needsUpdate=!0),!0),intersectsRange:(t,s)=>{if(e.boundsTree){return e.boundsTree.shapecast({boundsTraverseOrder:t=>In.distanceToBox(t),intersectsBounds:(t,e,i)=>i<y&&i<o,intersectsRange:(e,n)=>{for(let o=e,a=e+n;o<a;o++){an(p,3*o,d,c),p.a.applyMatrix4(i),p.b.applyMatrix4(i),p.c.applyMatrix4(i),p.needsUpdate=!0;for(let e=t,i=t+s;e<i;e++){an(u,3*e,h,l),u.needsUpdate=!0;const t=u.distanceToTriangle(p,f,g);if(t<y&&(m.copy(f),_&&_.copy(g),y=t,w=e,v=o),t<r)return!0}}}})}for(let n=0,o=is(e);n<o;n++){an(p,3*n,d,c),p.a.applyMatrix4(i),p.b.applyMatrix4(i),p.c.applyMatrix4(i),p.needsUpdate=!0;for(let e=t,i=t+s;e<i;e++){an(u,3*e,h,l),u.needsUpdate=!0;const t=u.distanceToTriangle(p,f,g);if(t<y&&(m.copy(f),_&&_.copy(g),y=t,w=e,v=n),t<r)return!0}}}}),ks.releasePrimitive(u),ks.releasePrimitive(p),y===1/0?null:(s.point?s.point.copy(m):s.point=m.clone(),s.distance=y,s.faceIndex=w,n&&(n.point?n.point.copy(_):n.point=_.clone(),n.point.applyMatrix4(On),m.applyMatrix4(On),n.distance=m.sub(n.point).length(),n.faceIndex=v),s)}function Nn(t,e=null){e&&Array.isArray(e)&&(e=new Set(e));const i=t.geometry,s=i.index?i.index.array:null,n=i.attributes.position;let r,o,a,l,h=0;const c=t._roots;for(let t=0,e=c.length;t<e;t++)r=c[t],o=new Uint32Array(r),a=new Uint16Array(r),l=new Float32Array(r),d(0,h),h+=r.byteLength;function d(i,r,h=!1){const c=2*i;if(a[c+15]===Ji){const e=o[i+6];let r=1/0,h=1/0,d=1/0,u=-1/0,p=-1/0,f=-1/0;for(let i=e,o=e+a[c+14];i<o;i++){const e=3*t.resolveTriangleIndex(i);for(let t=0;t<3;t++){let i=e+t;i=s?s[i]:i;const o=n.getX(i),a=n.getY(i),l=n.getZ(i);o<r&&(r=o),o>u&&(u=o),a<h&&(h=a),a>p&&(p=a),l<d&&(d=l),l>f&&(f=l)}}return(l[i+0]!==r||l[i+1]!==h||l[i+2]!==d||l[i+3]!==u||l[i+4]!==p||l[i+5]!==f)&&(l[i+0]=r,l[i+1]=h,l[i+2]=d,l[i+3]=u,l[i+4]=p,l[i+5]=f,!0)}{const t=i+8,s=o[i+6],n=t+r,a=s+r;let c=h,u=!1,p=!1;e?c||(u=e.has(n),p=e.has(a),c=!u&&!p):(u=!0,p=!0);const f=c||p;let m=!1;(c||u)&&(m=d(t,r,c));let g=!1;f&&(g=d(s,r,c));const _=m||g;if(_)for(let e=0;e<3;e++){const n=t+e,r=s+e,o=l[n],a=l[n+3],h=l[r],c=l[r+3];l[i+e]=o<h?o:h,l[i+e+3]=a>c?a:c}return _}}}const Un=new a;function Ln(t,e,i,s,n){Rs.setBuffer(t._roots[e]),Rn(0,t,i,s,n),Rs.clearBuffer()}function Rn(t,e,i,s,n){const{float32Array:r,uint16Array:o,uint32Array:a}=Rs,l=2*t;if(Ds(l,o)){!function(t,e,i,s,n,r){const{geometry:o,_indirectBuffer:a}=t;for(let t=s,l=s+n;t<l;t++)on(o,e,i,a?a[t]:t,r)}(e,i,s,zs(t,a),Ms(l,o),n)}else{const o=Bs(t);dn(o,r,s,Un)&&Rn(o,e,i,s,n);const l=Ns(t,a);dn(l,r,s,Un)&&Rn(l,e,i,s,n)}}const Fn=new a,Vn=["x","y","z"];function jn(t,e,i,s){Rs.setBuffer(t._roots[e]);const n=Zn(0,t,i,s);return Rs.clearBuffer(),n}function Zn(t,e,i,s){const{float32Array:n,uint16Array:r,uint32Array:o}=Rs;let a=2*t;if(Ds(a,r)){return function(t,e,i,s,n){const{geometry:r,_indirectBuffer:o}=t;let a=1/0,l=null;for(let t=s,h=s+n;t<h;t++){let s;s=on(r,e,i,o?o[t]:t),s&&s.distance<a&&(l=s,a=s.distance)}return l}(e,i,s,zs(t,o),Ms(a,r))}{const r=Us(t,o),a=Vn[r],l=s.direction[a]>=0;let h,c;l?(h=Bs(t),c=Ns(t,o)):(h=Ns(t,o),c=Bs(t));const d=dn(h,n,s,Fn)?Zn(h,e,i,s):null;if(d){const t=d.point[a];if(l?t<=n[c+r]:t>=n[c+r+3])return d}const u=dn(c,n,s,Fn)?Zn(c,e,i,s):null;return d&&u?d.distance<=u.distance?d:u:d||u||null}}const Hn=new f,$n=new As,Wn=new As,Yn=new p,Xn=new Os,qn=new Os;function Gn(t,e,i,s){Rs.setBuffer(t._roots[e]);const n=Qn(0,t,i,s);return Rs.clearBuffer(),n}function Qn(t,e,i,s,n=null){const{float32Array:r,uint16Array:o,uint32Array:a}=Rs;let l=2*t;null===n&&(i.boundingBox||i.computeBoundingBox(),Xn.set(i.boundingBox.min,i.boundingBox.max,s),n=Xn);if(!Ds(l,o)){const o=t+8,l=a[t+6];os(o,r,Hn);if(n.intersectsBox(Hn)&&Qn(o,e,i,s,n))return!0;os(l,r,Hn);return!!(n.intersectsBox(Hn)&&Qn(l,e,i,s,n))}{const n=e.geometry,h=n.index,c=n.attributes.position,d=i.index,u=i.attributes.position,p=zs(t,a),f=Ms(l,o);if(Yn.copy(s).invert(),i.boundsTree){os(t,r,qn),qn.matrix.copy(Yn),qn.needsUpdate=!0;return i.boundsTree.shapecast({intersectsBounds:t=>qn.intersectsBox(t),intersectsTriangle:t=>{t.a.applyMatrix4(s),t.b.applyMatrix4(s),t.c.applyMatrix4(s),t.needsUpdate=!0;for(let i=p,s=f+p;i<s;i++)if(an(Wn,3*e.resolveTriangleIndex(i),h,c),Wn.needsUpdate=!0,t.intersectsTriangle(Wn))return!0;return!1}})}for(let t=p,i=f+p;t<i;t++){const i=e.resolveTriangleIndex(t);an($n,3*i,h,c),$n.a.applyMatrix4(Yn),$n.b.applyMatrix4(Yn),$n.c.applyMatrix4(Yn),$n.needsUpdate=!0;for(let t=0,e=d.count;t<e;t+=3)if(an(Wn,t,d,u),Wn.needsUpdate=!0,$n.intersectsTriangle(Wn))return!0}}}const Kn=new p,Jn=new Os,tr=new Os,er=new a,ir=new a,sr=new a,nr=new a;function rr(t,e,i,s={},n={},r=0,o=1/0){e.boundingBox||e.computeBoundingBox(),Jn.set(e.boundingBox.min,e.boundingBox.max,i),Jn.needsUpdate=!0;const a=t.geometry,l=a.attributes.position,h=a.index,c=e.attributes.position,d=e.index,u=ks.getPrimitive(),p=ks.getPrimitive();let f=er,m=ir,g=null,_=null;n&&(g=sr,_=nr);let y=1/0,w=null,v=null;return Kn.copy(i).invert(),tr.matrix.copy(Kn),t.shapecast({boundsTraverseOrder:t=>Jn.distanceToBox(t),intersectsBounds:(t,e,i)=>i<y&&i<o&&(e&&(tr.min.copy(t.min),tr.max.copy(t.max),tr.needsUpdate=!0),!0),intersectsRange:(s,n)=>{if(e.boundsTree){const a=e.boundsTree;return a.shapecast({boundsTraverseOrder:t=>tr.distanceToBox(t),intersectsBounds:(t,e,i)=>i<y&&i<o,intersectsRange:(e,o)=>{for(let b=e,x=e+o;b<x;b++){const e=a.resolveTriangleIndex(b);an(p,3*e,d,c),p.a.applyMatrix4(i),p.b.applyMatrix4(i),p.c.applyMatrix4(i),p.needsUpdate=!0;for(let e=s,i=s+n;e<i;e++){const i=t.resolveTriangleIndex(e);an(u,3*i,h,l),u.needsUpdate=!0;const s=u.distanceToTriangle(p,f,g);if(s<y&&(m.copy(f),_&&_.copy(g),y=s,w=e,v=b),s<r)return!0}}}})}for(let o=0,a=is(e);o<a;o++){an(p,3*o,d,c),p.a.applyMatrix4(i),p.b.applyMatrix4(i),p.c.applyMatrix4(i),p.needsUpdate=!0;for(let e=s,i=s+n;e<i;e++){const i=t.resolveTriangleIndex(e);an(u,3*i,h,l),u.needsUpdate=!0;const s=u.distanceToTriangle(p,f,g);if(s<y&&(m.copy(f),_&&_.copy(g),y=s,w=e,v=o),s<r)return!0}}}}),ks.releasePrimitive(u),ks.releasePrimitive(p),y===1/0?null:(s.point?s.point.copy(m):s.point=m.clone(),s.distance=y,s.faceIndex=w,n&&(n.point?n.point.copy(_):n.point=_.clone(),n.point.applyMatrix4(Kn),m.applyMatrix4(Kn),n.distance=m.sub(n.point).length(),n.faceIndex=v),s)}const or=new Rs.constructor,ar=new Rs.constructor,lr=new Ps(()=>new f),hr=new f,cr=new f,dr=new f,ur=new f;let pr=!1;function fr(t,e,i,s,n,r=0,o=0,a=0,l=0,h=null,c=!1){let d,u;c?(d=ar,u=or):(d=or,u=ar);const p=d.float32Array,f=d.uint32Array,m=d.uint16Array,g=u.float32Array,_=u.uint32Array,y=u.uint16Array,w=2*e,v=Ds(2*t,m),b=Ds(w,y);let x=!1;if(b&&v)x=c?n(zs(e,_),Ms(2*e,y),zs(t,f),Ms(2*t,m),l,o+e,a,r+t):n(zs(t,f),Ms(2*t,m),zs(e,_),Ms(2*e,y),a,r+t,l,o+e);else if(b){const h=lr.getPrimitive();os(e,g,h),h.applyMatrix4(i);const d=Bs(t),u=Ns(t,f);os(d,p,hr),os(u,p,cr);const m=h.intersectsBox(hr),_=h.intersectsBox(cr);x=m&&fr(e,d,s,i,n,o,r,l,a+1,h,!c)||_&&fr(e,u,s,i,n,o,r,l,a+1,h,!c),lr.releasePrimitive(h)}else{const d=Bs(e),u=Ns(e,_);os(d,g,dr),os(u,g,ur);const m=h.intersectsBox(dr),y=h.intersectsBox(ur);if(m&&y)x=fr(t,d,i,s,n,r,o,a,l+1,h,c)||fr(t,u,i,s,n,r,o,a,l+1,h,c);else if(m)if(v)x=fr(t,d,i,s,n,r,o,a,l+1,h,c);else{const e=lr.getPrimitive();e.copy(dr).applyMatrix4(i);const h=Bs(t),u=Ns(t,f);os(h,p,hr),os(u,p,cr);const m=e.intersectsBox(hr),g=e.intersectsBox(cr);x=m&&fr(d,h,s,i,n,o,r,l,a+1,e,!c)||g&&fr(d,u,s,i,n,o,r,l,a+1,e,!c),lr.releasePrimitive(e)}else if(y)if(v)x=fr(t,u,i,s,n,r,o,a,l+1,h,c);else{const e=lr.getPrimitive();e.copy(ur).applyMatrix4(i);const h=Bs(t),d=Ns(t,f);os(h,p,hr),os(d,p,cr);const m=e.intersectsBox(hr),g=e.intersectsBox(cr);x=m&&fr(u,h,s,i,n,o,r,l,a+1,e,!c)||g&&fr(u,d,s,i,n,o,r,l,a+1,e,!c),lr.releasePrimitive(e)}}return x}const mr=new Os,gr=new f;class _r{static serialize(t,e={}){e={cloneBuffers:!0,...e};const i=t.geometry,s=t._roots,n=t._indirectBuffer,r=i.getIndex();let o;return o=e.cloneBuffers?{roots:s.map(t=>t.slice()),index:r.array.slice(),indirectBuffer:n?n.slice():null}:{roots:s,index:r.array,indirectBuffer:n},o}static deserialize(t,e,i={}){i={setIndex:!0,indirect:Boolean(t.indirectBuffer),...i};const{index:s,roots:n,indirectBuffer:r}=t,a=new _r(e,{...i,[es]:!0});if(a._roots=n,a._indirectBuffer=r||null,i.setIndex){const i=e.getIndex();if(null===i){const i=new o(t.index,1,!1);e.setIndex(i)}else i.array!==s&&(i.array.set(s),i.needsUpdate=!0)}return a}get indirect(){return!!this._indirectBuffer}constructor(t,e={}){if(!t.isBufferGeometry)throw new Error("MeshBVH: Only BufferGeometries are supported.");if(t.index&&t.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.");if((e=Object.assign({strategy:0,maxDepth:40,maxLeafTris:10,verbose:!0,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,[es]:!1},e)).useSharedArrayBuffer&&"undefined"==typeof SharedArrayBuffer)throw new Error("MeshBVH: SharedArrayBuffer is not available.");this.geometry=t,this._roots=null,this._indirectBuffer=null,e[es]||(bs(this,e),!t.boundingBox&&e.setBoundingBox&&(t.boundingBox=this.getBoundingBox(new f)));const{_indirectBuffer:i}=this;this.resolveTriangleIndex=e.indirect?t=>i[t]:t=>t}refit(t=null){return(this.indirect?Nn:hn)(this,t)}traverse(t,e=0){const i=this._roots[e],s=new Uint32Array(i),n=new Uint16Array(i);!function e(r,o=0){const a=2*r,l=n[a+15]===Ji;if(l){const e=s[r+6],h=n[a+14];t(o,l,new Float32Array(i,4*r,6),e,h)}else{const n=r+8,a=s[r+6],h=s[r+7];t(o,l,new Float32Array(i,4*r,6),h)||(e(n,o+1),e(a,o+1))}}(0)}raycast(t,e=_){const i=this._roots,s=this.geometry,n=[],r=e.isMaterial,o=Array.isArray(e),a=s.groups,l=r?e.side:e,h=this.indirect?Ln:fn;for(let s=0,r=i.length;s<r;s++){const i=o?e[a[s].materialIndex].side:l,r=n.length;if(h(this,s,i,t,n),o){const t=a[s].materialIndex;for(let e=r,i=n.length;e<i;e++)n[e].face.materialIndex=t}}return n}raycastFirst(t,e=_){const i=this._roots,s=this.geometry,n=e.isMaterial,r=Array.isArray(e);let o=null;const a=s.groups,l=n?e.side:e,h=this.indirect?jn:yn;for(let s=0,n=i.length;s<n;s++){const i=h(this,s,r?e[a[s].materialIndex].side:l,t);null!=i&&(null==o||i.distance<o.distance)&&(o=i,r&&(i.face.materialIndex=a[s].materialIndex))}return o}intersectsGeometry(t,e){let i=!1;const s=this._roots,n=this.indirect?Gn:Sn;for(let r=0,o=s.length;r<o&&(i=n(this,r,t,e),!i);r++);return i}shapecast(t){const e=ks.getPrimitive(),i=this.indirect?un:ln;let{boundsTraverseOrder:s,intersectsBounds:n,intersectsRange:r,intersectsTriangle:o}=t;if(r&&o){const t=r;r=(s,n,r,a,l)=>!!t(s,n,r,a,l)||i(s,n,this,o,r,a,e)}else r||(r=o?(t,s,n,r)=>i(t,s,this,o,n,r,e):(t,e,i)=>i);let a=!1,l=0;const h=this._roots;for(let t=0,e=h.length;t<e;t++){const e=h[t];if(a=Hs(this,t,n,r,s,l),a)break;l+=e.byteLength}return ks.releasePrimitive(e),a}bvhcast(t,e,i){let{intersectsRanges:s,intersectsTriangles:n}=i;const r=ks.getPrimitive(),o=this.geometry.index,a=this.geometry.attributes.position,l=this.indirect?t=>{const e=this.resolveTriangleIndex(t);an(r,3*e,o,a)}:t=>{an(r,3*t,o,a)},h=ks.getPrimitive(),c=t.geometry.index,d=t.geometry.attributes.position,u=t.indirect?e=>{const i=t.resolveTriangleIndex(e);an(h,3*i,c,d)}:t=>{an(h,3*t,c,d)};if(n){const t=(t,i,s,o,a,c,d,p)=>{for(let f=s,m=s+o;f<m;f++){u(f),h.a.applyMatrix4(e),h.b.applyMatrix4(e),h.c.applyMatrix4(e),h.needsUpdate=!0;for(let e=t,s=t+i;e<s;e++)if(l(e),r.needsUpdate=!0,n(r,h,e,f,a,c,d,p))return!0}return!1};if(s){const e=s;s=function(i,s,n,r,o,a,l,h){return!!e(i,s,n,r,o,a,l,h)||t(i,s,n,r,o,a,l,h)}}else s=t}return function(t,e,i,s){if(pr)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");pr=!0;const n=t._roots,r=e._roots;let o,a=0,l=0;const h=(new p).copy(i).invert();for(let t=0,e=n.length;t<e;t++){or.setBuffer(n[t]),l=0;const e=lr.getPrimitive();os(Ls(0),or.float32Array,e),e.applyMatrix4(h);for(let n=0,c=r.length;n<c&&(ar.setBuffer(r[t]),o=fr(0,0,i,h,s,a,l,0,0,e),ar.clearBuffer(),l+=r[n].length,!o);n++);if(lr.releasePrimitive(e),or.clearBuffer(),a+=n[t].length,o)break}return pr=!1,o}(this,t,e,s)}intersectsBox(t,e){return mr.set(t.min,t.max,e),mr.needsUpdate=!0,this.shapecast({intersectsBounds:t=>mr.intersectsBox(t),intersectsTriangle:t=>mr.intersectsTriangle(t)})}intersectsSphere(t){return this.shapecast({intersectsBounds:e=>t.intersectsBox(e),intersectsTriangle:e=>e.intersectsSphere(t)})}closestPointToGeometry(t,e,i={},s={},n=0,r=1/0){return(this.indirect?rr:Bn)(this,t,e,i,s,n,r)}closestPointToPoint(t,e={},i=0,s=1/0){return function(t,e,i={},s=0,n=1/0){const r=s*s,o=n*n;let a=1/0,l=null;if(t.shapecast({boundsTraverseOrder:t=>(Ws.copy(e).clamp(t.min,t.max),Ws.distanceToSquared(e)),intersectsBounds:(t,e,i)=>i<a&&i<o,intersectsTriangle:(t,i)=>{t.closestPointToPoint(e,Ws);const s=e.distanceToSquared(Ws);return s<a&&(Ys.copy(Ws),a=s,l=i),s<r}}),a===1/0)return null;const h=Math.sqrt(a);return i.point?i.point.copy(Ys):i.point=Ys.clone(),i.distance=h,i.faceIndex=l,i}(this,t,e,i,s)}getBoundingBox(t){t.makeEmpty();return this._roots.forEach(e=>{os(0,new Float32Array(e),gr),t.union(gr)}),t}}function yr(t,e,i){return null===t?null:(t.point.applyMatrix4(e.matrixWorld),t.distance=t.point.distanceTo(i.ray.origin),t.object=e,t.distance<i.near||t.distance>i.far?null:t)}const wr=new y,vr=new p,br=w.prototype.raycast;function xr(t,e){if(this.geometry.boundsTree){if(void 0===this.material)return;vr.copy(this.matrixWorld).invert(),wr.copy(t.ray).applyMatrix4(vr);const i=this.geometry.boundsTree;if(!0===t.firstHitOnly){const s=yr(i.raycastFirst(wr,this.material),this,t);s&&e.push(s)}else{const s=i.raycast(wr,this.material);for(let i=0,n=s.length;i<n;i++){const n=yr(s[i],this,t);n&&e.push(n)}}}else br.call(this,t,e)}function Er(t){return this.boundsTree=new _r(this,t),this.boundsTree}function Tr(){this.boundsTree=null}const Cr=class t{constructor(){e(this,"onDisposed",new U),e(this,"list",new Map),e(this,"enabled",!1),e(this,"_clock"),e(this,"onInit",new U),e(this,"update",()=>{if(!this.enabled)return;const t=this._clock.getDelta();for(const[e,i]of this.list)i.enabled&&i.isUpdateable()&&i.update(t);requestAnimationFrame(this.update)}),this._clock=new r.Clock,t.setupBVH()}add(t,e){if(this.list.has(t))throw new Error("You're trying to add a component that already exists in the components instance. Use Components.get() instead.");q.validate(t),this.list.set(t,e)}get(t){const e=t.uuid;if(!this.list.has(e)){const i=new t(this);return i.isDisposeable()&&i.onDisposed.add(()=>this.list.delete(e)),this.list.has(e)||this.add(e,i),i}return this.list.get(e)}init(){this.enabled=!0;for(const[t,e]of this.list.entries())e.enabled=!0;this._clock.start(),this.update(),this.onInit.trigger()}dispose(){let t;this.enabled=!1;for(const[e,i]of this.list)i.enabled=!1,e!==Ae.uuid?i.isDisposeable()&&i.dispose():t=i;null==t||t.dispose(),this._clock.stop(),this.onDisposed.trigger()}static setupBVH(){r.BufferGeometry.prototype.computeBoundsTree=Er,r.BufferGeometry.prototype.disposeBoundsTree=Tr,r.Mesh.prototype.raycast=xr}};e(Cr,"release","2.4.3");let Sr=Cr;class Ar{constructor(t){e(this,"enabled",!1),e(this,"id","FirstPerson"),this.camera=t}set(t){if(this.enabled=t,t){if("Perspective"!==this.camera.projection.current)return void this.camera.set("Orbit");this.setupFirstPersonCamera()}}setupFirstPersonCamera(){const t=this.camera.controls,e=new r.Vector3;t.distance--,t.getPosition(e),t.minDistance=1,t.maxDistance=1,t.distance=1,t.moveTo(e.x,e.y,e.z),t.truckSpeed=50,t.mouseButtons.wheel=Hi.ACTION.DOLLY,t.touches.two=Hi.ACTION.TOUCH_ZOOM_TRUCK}}class Or{constructor(t){e(this,"enabled",!0),e(this,"id","Orbit"),this.camera=t,this.activateOrbitControls()}set(t){this.enabled=t,t&&this.activateOrbitControls()}activateOrbitControls(){const t=this.camera.controls;t.minDistance=1,t.maxDistance=300;const e=new r.Vector3;t.getPosition(e);const i=e.length();t.distance=i,t.truckSpeed=2;const{rotation:s}=this.camera.three,n=new r.Vector3(0,0,-1).applyEuler(s),o=e.addScaledVector(n,i);t.moveTo(o.x,o.y,o.z)}}class Pr{constructor(t){e(this,"enabled",!1),e(this,"id","Plan"),e(this,"mouseAction1"),e(this,"mouseAction2"),e(this,"mouseInitialized",!1),e(this,"defaultAzimuthSpeed"),e(this,"defaultPolarSpeed"),this.camera=t,this.defaultAzimuthSpeed=t.controls.azimuthRotateSpeed,this.defaultPolarSpeed=t.controls.polarRotateSpeed}set(t){this.enabled=t;const e=this.camera.controls;e.azimuthRotateSpeed=t?0:this.defaultAzimuthSpeed,e.polarRotateSpeed=t?0:this.defaultPolarSpeed,this.mouseInitialized||(this.mouseAction1=e.touches.one,this.mouseAction2=e.touches.two,this.mouseInitialized=!0),t?(e.mouseButtons.left=Hi.ACTION.TRUCK,e.touches.one=Hi.ACTION.TOUCH_TRUCK,e.touches.two=Hi.ACTION.TOUCH_ZOOM):(e.mouseButtons.left=Hi.ACTION.ROTATE,e.touches.one=this.mouseAction1,e.touches.two=this.mouseAction2)}}class Ir{constructor(t){e(this,"onChanged",new U),e(this,"current","Perspective"),e(this,"camera"),e(this,"matchOrthoDistanceEnabled",!1),e(this,"_component"),e(this,"_previousDistance",-1),this._component=t,this.camera=t.three}async set(t){this.current!==t&&("Orthographic"===t?this.setOrthoCamera():await this.setPerspectiveCamera(),this.onChanged.trigger(this.camera))}async toggle(){const t="Perspective"===this.current?"Orthographic":"Perspective";await this.set(t)}setOrthoCamera(){if(null===this._component.mode)return;if("FirstPerson"===this._component.mode.id)return;this._previousDistance=this._component.controls.distance,this._component.controls.distance=200;const t=this.getPerspectiveDims();if(!t)return;const{width:e,height:i}=t;this.setupOrthoCamera(i,e),this.camera=this._component.threeOrtho,this.current="Orthographic"}getPerspectiveDims(){const t=this._component.currentWorld;if(!t||!t.renderer)return null;const e=new r.Vector3;this._component.threePersp.getWorldDirection(e);const i=new r.Vector3;this._component.controls.getTarget(i);const s=i.clone().sub(this._component.threePersp.position).dot(e),n=t.renderer.getSize(),o=n.x/n.y,a=this._component.threePersp,l=2*s*Math.atan(a.fov*(Math.PI/180)/2);return{width:l*o,height:l}}setupOrthoCamera(t,e){this._component.controls.mouseButtons.wheel=Hi.ACTION.ZOOM,this._component.controls.mouseButtons.middle=Hi.ACTION.ZOOM;const i=this._component.threePersp,s=this._component.threeOrtho;s.zoom=1,s.left=e/-2,s.right=e/2,s.top=t/2,s.bottom=t/-2,s.updateProjectionMatrix(),s.position.copy(i.position),s.quaternion.copy(i.quaternion),this._component.controls.camera=s}getDistance(){const t=this._component.threePersp,e=this._component.threeOrtho;return(e.top-e.bottom)/e.zoom/(2*Math.atan(t.fov*(Math.PI/180)/2))}async setPerspectiveCamera(){this._component.controls.mouseButtons.wheel=Hi.ACTION.DOLLY,this._component.controls.mouseButtons.middle=Hi.ACTION.DOLLY;const t=this._component.threePersp,e=this._component.threeOrtho;t.position.copy(e.position),t.quaternion.copy(e.quaternion),this._component.controls.mouseButtons.wheel=Hi.ACTION.DOLLY,this.matchOrthoDistanceEnabled?this._component.controls.distance=this.getDistance():this._component.controls.distance=this._previousDistance,await this._component.controls.zoomTo(1),t.updateProjectionMatrix(),this._component.controls.camera=t,this.camera=t,this.current="Perspective"}}class kr extends $i{constructor(t){super(t),e(this,"projection"),e(this,"threeOrtho"),e(this,"threePersp"),e(this,"_userInputButtons",{}),e(this,"_frustumSize",50),e(this,"_navigationModes",new Map),e(this,"_mode",null),e(this,"previousSize",null),this.threePersp=this.three,this.threeOrtho=this.newOrthoCamera(),this.projection=new Ir(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 Or(this)),this._navigationModes.set("FirstPerson",new Ar(this)),this._navigationModes.set("Plan",new Pr(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(t){if(null!==this.mode&&this.mode.id!==t){if(this.mode.set(!1),!this._navigationModes.has(t))throw new Error("The specified mode does not exist!");this._mode=this._navigationModes.get(t),this.mode.set(!0)}}async fit(t,e=1.5){if(!this.enabled)return;const i=Number.MAX_VALUE,s=Number.MIN_VALUE,n=new r.Vector3(i,i,i),o=new r.Vector3(s,s,s);for(const e of t){const t=(new r.Box3).setFromObject(e);t.min.x<n.x&&(n.x=t.min.x),t.min.y<n.y&&(n.y=t.min.y),t.min.z<n.z&&(n.z=t.min.z),t.max.x>o.x&&(o.x=t.max.x),t.max.y>o.y&&(o.y=t.max.y),t.max.z>o.z&&(o.z=t.max.z)}const a=new r.Box3(n,o),l=this.components.get(Ae);if(l.initialized)for(const[,t]of l.list){const e=t.box;e.min.x<n.x&&(n.x=e.min.x),e.min.y<n.y&&(n.y=e.min.y),e.min.z<n.z&&(n.z=e.min.z),e.max.x>o.x&&(o.x=e.max.x),e.max.y>o.y&&(o.y=e.max.y),e.max.z>o.z&&(o.z=e.max.z)}const h=new r.Vector3;a.getSize(h);const c=new r.Vector3;a.getCenter(c);const d=Math.max(h.x,h.y,h.z)*e,u=new r.Sphere(c,d);await this.controls.fitToSphere(u,!0)}setUserInput(t){t?this.enableUserInput():this.disableUserInput()}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 t=window.innerWidth/window.innerHeight;return new r.OrthographicCamera(this._frustumSize*t/-2,this._frustumSize*t/2,this._frustumSize/2,this._frustumSize/-2,.1,1e3)}setOrthoPerspCameraAspect(){if(!this.currentWorld||!this.currentWorld.renderer)return;if(!this.previousSize)return;const t=this.currentWorld.renderer.getSize(),e=this.threeOrtho.top,i=this.threeOrtho.right,s=e*(t.y/this.previousSize.y),n=i*(t.x/this.previousSize.x);this.threeOrtho.left=-n,this.threeOrtho.right=n,this.threeOrtho.top=s,this.threeOrtho.bottom=-s,this.threeOrtho.updateProjectionMatrix(),this.previousSize.copy(t)}}function Dr(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var zr={exports:{}};
|
|
8
8
|
/*!
|
|
9
9
|
|
|
10
10
|
JSZip v3.10.1 - A JavaScript class for generating and reading zip files
|
|
@@ -15,4 +15,4 @@ Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/js
|
|
|
15
15
|
|
|
16
16
|
JSZip uses the library pako released under the MIT license :
|
|
17
17
|
https://github.com/nodeca/pako/blob/main/LICENSE
|
|
18
|
-
*/const uo=Xi(ho.exports=function e(t,i,s){function n(o,a){if(!i[o]){if(!t[o]){if(!a&&lo)return lo(o);if(r)return r(o,!0);var c=new Error("Cannot find module '"+o+"'");throw c.code="MODULE_NOT_FOUND",c}var l=i[o]={exports:{}};t[o][0].call(l.exports,(function(e){return n(t[o][1][e]||e)}),l,l.exports,e,t,i,s)}return i[o].exports}for(var r=lo,o=0;o<s.length;o++)n(s[o]);return n}({1:[function(e,t,i){var s=e("./utils"),n=e("./support"),r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";i.encode=function(e){for(var t,i,n,o,a,c,l,h=[],u=0,I=e.length,d=I,E="string"!==s.getTypeOf(e);u<e.length;)d=I-u,n=E?(t=e[u++],i=u<I?e[u++]:0,u<I?e[u++]:0):(t=e.charCodeAt(u++),i=u<I?e.charCodeAt(u++):0,u<I?e.charCodeAt(u++):0),o=t>>2,a=(3&t)<<4|i>>4,c=1<d?(15&i)<<2|n>>6:64,l=2<d?63&n:64,h.push(r.charAt(o)+r.charAt(a)+r.charAt(c)+r.charAt(l));return h.join("")},i.decode=function(e){var t,i,s,o,a,c,l=0,h=0,u="data:";if(e.substr(0,u.length)===u)throw new Error("Invalid base64 input, it looks like a data url.");var I,d=3*(e=e.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(e.charAt(e.length-1)===r.charAt(64)&&d--,e.charAt(e.length-2)===r.charAt(64)&&d--,d%1!=0)throw new Error("Invalid base64 input, bad content length.");for(I=n.uint8array?new Uint8Array(0|d):new Array(0|d);l<e.length;)t=r.indexOf(e.charAt(l++))<<2|(o=r.indexOf(e.charAt(l++)))>>4,i=(15&o)<<4|(a=r.indexOf(e.charAt(l++)))>>2,s=(3&a)<<6|(c=r.indexOf(e.charAt(l++))),I[h++]=t,64!==a&&(I[h++]=i),64!==c&&(I[h++]=s);return I}},{"./support":30,"./utils":32}],2:[function(e,t,i){var s=e("./external"),n=e("./stream/DataWorker"),r=e("./stream/Crc32Probe"),o=e("./stream/DataLengthProbe");function a(e,t,i,s,n){this.compressedSize=e,this.uncompressedSize=t,this.crc32=i,this.compression=s,this.compressedContent=n}a.prototype={getContentWorker:function(){var e=new n(s.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new o("data_length")),t=this;return e.on("end",(function(){if(this.streamInfo.data_length!==t.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")})),e},getCompressedWorker:function(){return new n(s.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},a.createWorkerFrom=function(e,t,i){return e.pipe(new r).pipe(new o("uncompressedSize")).pipe(t.compressWorker(i)).pipe(new o("compressedSize")).withStreamInfo("compression",t)},t.exports=a},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(e,t,i){var s=e("./stream/GenericWorker");i.STORE={magic:"\0\0",compressWorker:function(){return new s("STORE compression")},uncompressWorker:function(){return new s("STORE decompression")}},i.DEFLATE=e("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(e,t,i){var s=e("./utils"),n=function(){for(var e,t=[],i=0;i<256;i++){e=i;for(var s=0;s<8;s++)e=1&e?3988292384^e>>>1:e>>>1;t[i]=e}return t}();t.exports=function(e,t){return void 0!==e&&e.length?"string"!==s.getTypeOf(e)?function(e,t,i,s){var r=n,o=s+i;e^=-1;for(var a=s;a<o;a++)e=e>>>8^r[255&(e^t[a])];return~e}(0|t,e,e.length,0):function(e,t,i,s){var r=n,o=s+i;e^=-1;for(var a=s;a<o;a++)e=e>>>8^r[255&(e^t.charCodeAt(a))];return~e}(0|t,e,e.length,0):0}},{"./utils":32}],5:[function(e,t,i){i.base64=!1,i.binary=!1,i.dir=!1,i.createFolders=!0,i.date=null,i.compression=null,i.compressionOptions=null,i.comment=null,i.unixPermissions=null,i.dosPermissions=null},{}],6:[function(e,t,i){var s=null;s="undefined"!=typeof Promise?Promise:e("lie"),t.exports={Promise:s}},{lie:37}],7:[function(e,t,i){var s="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Uint32Array,n=e("pako"),r=e("./utils"),o=e("./stream/GenericWorker"),a=s?"uint8array":"array";function c(e,t){o.call(this,"FlateWorker/"+e),this._pako=null,this._pakoAction=e,this._pakoOptions=t,this.meta={}}i.magic="\b\0",r.inherits(c,o),c.prototype.processChunk=function(e){this.meta=e.meta,null===this._pako&&this._createPako(),this._pako.push(r.transformTo(a,e.data),!1)},c.prototype.flush=function(){o.prototype.flush.call(this),null===this._pako&&this._createPako(),this._pako.push([],!0)},c.prototype.cleanUp=function(){o.prototype.cleanUp.call(this),this._pako=null},c.prototype._createPako=function(){this._pako=new n[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var e=this;this._pako.onData=function(t){e.push({data:t,meta:e.meta})}},i.compressWorker=function(e){return new c("Deflate",e)},i.uncompressWorker=function(){return new c("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(e,t,i){function s(e,t){var i,s="";for(i=0;i<t;i++)s+=String.fromCharCode(255&e),e>>>=8;return s}function n(e,t,i,n,o,h){var u,I,d=e.file,E=e.compression,f=h!==a.utf8encode,p=r.transformTo("string",h(d.name)),C=r.transformTo("string",a.utf8encode(d.name)),T=d.comment,m=r.transformTo("string",h(T)),R=r.transformTo("string",a.utf8encode(T)),g=C.length!==d.name.length,A=R.length!==T.length,F="",S="",O="",N=d.dir,y=d.date,_={crc32:0,compressedSize:0,uncompressedSize:0};t&&!i||(_.crc32=e.crc32,_.compressedSize=e.compressedSize,_.uncompressedSize=e.uncompressedSize);var L=0;t&&(L|=8),f||!g&&!A||(L|=2048);var P,w,v,M=0,D=0;N&&(M|=16),"UNIX"===o?(D=798,M|=(P=d.unixPermissions,w=N,v=P,P||(v=w?16893:33204),(65535&v)<<16)):(D=20,M|=function(e){return 63&(e||0)}(d.dosPermissions)),u=y.getUTCHours(),u<<=6,u|=y.getUTCMinutes(),u<<=5,u|=y.getUTCSeconds()/2,I=y.getUTCFullYear()-1980,I<<=4,I|=y.getUTCMonth()+1,I<<=5,I|=y.getUTCDate(),g&&(S=s(1,1)+s(c(p),4)+C,F+="up"+s(S.length,2)+S),A&&(O=s(1,1)+s(c(m),4)+R,F+="uc"+s(O.length,2)+O);var b="";return b+="\n\0",b+=s(L,2),b+=E.magic,b+=s(u,2),b+=s(I,2),b+=s(_.crc32,4),b+=s(_.compressedSize,4),b+=s(_.uncompressedSize,4),b+=s(p.length,2),b+=s(F.length,2),{fileRecord:l.LOCAL_FILE_HEADER+b+p+F,dirRecord:l.CENTRAL_FILE_HEADER+s(D,2)+b+s(m.length,2)+"\0\0\0\0"+s(M,4)+s(n,4)+p+F+m}}var r=e("../utils"),o=e("../stream/GenericWorker"),a=e("../utf8"),c=e("../crc32"),l=e("../signature");function h(e,t,i,s){o.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=t,this.zipPlatform=i,this.encodeFileName=s,this.streamFiles=e,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}r.inherits(h,o),h.prototype.push=function(e){var t=e.meta.percent||0,i=this.entriesCount,s=this._sources.length;this.accumulate?this.contentBuffer.push(e):(this.bytesWritten+=e.data.length,o.prototype.push.call(this,{data:e.data,meta:{currentFile:this.currentFile,percent:i?(t+100*(i-s-1))/i:100}}))},h.prototype.openedSource=function(e){this.currentSourceOffset=this.bytesWritten,this.currentFile=e.file.name;var t=this.streamFiles&&!e.file.dir;if(t){var i=n(e,t,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:i.fileRecord,meta:{percent:0}})}else this.accumulate=!0},h.prototype.closedSource=function(e){this.accumulate=!1;var t,i=this.streamFiles&&!e.file.dir,r=n(e,i,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(r.dirRecord),i)this.push({data:(t=e,l.DATA_DESCRIPTOR+s(t.crc32,4)+s(t.compressedSize,4)+s(t.uncompressedSize,4)),meta:{percent:100}});else for(this.push({data:r.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},h.prototype.flush=function(){for(var e=this.bytesWritten,t=0;t<this.dirRecords.length;t++)this.push({data:this.dirRecords[t],meta:{percent:100}});var i,n,o,a,c,h,u=this.bytesWritten-e,I=(i=this.dirRecords.length,n=u,o=e,a=this.zipComment,c=this.encodeFileName,h=r.transformTo("string",c(a)),l.CENTRAL_DIRECTORY_END+"\0\0\0\0"+s(i,2)+s(i,2)+s(n,4)+s(o,4)+s(h.length,2)+h);this.push({data:I,meta:{percent:100}})},h.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},h.prototype.registerPrevious=function(e){this._sources.push(e);var t=this;return e.on("data",(function(e){t.processChunk(e)})),e.on("end",(function(){t.closedSource(t.previous.streamInfo),t._sources.length?t.prepareNextSource():t.end()})),e.on("error",(function(e){t.error(e)})),this},h.prototype.resume=function(){return!!o.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},h.prototype.error=function(e){var t=this._sources;if(!o.prototype.error.call(this,e))return!1;for(var i=0;i<t.length;i++)try{t[i].error(e)}catch(e){}return!0},h.prototype.lock=function(){o.prototype.lock.call(this);for(var e=this._sources,t=0;t<e.length;t++)e[t].lock()},t.exports=h},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(e,t,i){var s=e("../compressions"),n=e("./ZipFileWorker");i.generateWorker=function(e,t,i){var r=new n(t.streamFiles,i,t.platform,t.encodeFileName),o=0;try{e.forEach((function(e,i){o++;var n=function(e,t){var i=e||t,n=s[i];if(!n)throw new Error(i+" is not a valid compression method !");return n}(i.options.compression,t.compression),a=i.options.compressionOptions||t.compressionOptions||{},c=i.dir,l=i.date;i._compressWorker(n,a).withStreamInfo("file",{name:e,dir:c,date:l,comment:i.comment||"",unixPermissions:i.unixPermissions,dosPermissions:i.dosPermissions}).pipe(r)})),r.entriesCount=o}catch(e){r.error(e)}return r}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(e,t,i){function s(){if(!(this instanceof s))return new s;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 e=new s;for(var t in this)"function"!=typeof this[t]&&(e[t]=this[t]);return e}}(s.prototype=e("./object")).loadAsync=e("./load"),s.support=e("./support"),s.defaults=e("./defaults"),s.version="3.10.1",s.loadAsync=function(e,t){return(new s).loadAsync(e,t)},s.external=e("./external"),t.exports=s},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(e,t,i){var s=e("./utils"),n=e("./external"),r=e("./utf8"),o=e("./zipEntries"),a=e("./stream/Crc32Probe"),c=e("./nodejsUtils");function l(e){return new n.Promise((function(t,i){var s=e.decompressed.getContentWorker().pipe(new a);s.on("error",(function(e){i(e)})).on("end",(function(){s.streamInfo.crc32!==e.decompressed.crc32?i(new Error("Corrupted zip : CRC32 mismatch")):t()})).resume()}))}t.exports=function(e,t){var i=this;return t=s.extend(t||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:r.utf8decode}),c.isNode&&c.isStream(e)?n.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):s.prepareContent("the loaded zip file",e,!0,t.optimizedBinaryString,t.base64).then((function(e){var i=new o(t);return i.load(e),i})).then((function(e){var i=[n.Promise.resolve(e)],s=e.files;if(t.checkCRC32)for(var r=0;r<s.length;r++)i.push(l(s[r]));return n.Promise.all(i)})).then((function(e){for(var n=e.shift(),r=n.files,o=0;o<r.length;o++){var a=r[o],c=a.fileNameStr,l=s.resolve(a.fileNameStr);i.file(l,a.decompressed,{binary:!0,optimizedBinaryString:!0,date:a.date,dir:a.dir,comment:a.fileCommentStr.length?a.fileCommentStr:null,unixPermissions:a.unixPermissions,dosPermissions:a.dosPermissions,createFolders:t.createFolders}),a.dir||(i.file(l).unsafeOriginalName=c)}return n.zipComment.length&&(i.comment=n.zipComment),i}))}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(e,t,i){var s=e("../utils"),n=e("../stream/GenericWorker");function r(e,t){n.call(this,"Nodejs stream input adapter for "+e),this._upstreamEnded=!1,this._bindStream(t)}s.inherits(r,n),r.prototype._bindStream=function(e){var t=this;(this._stream=e).pause(),e.on("data",(function(e){t.push({data:e,meta:{percent:0}})})).on("error",(function(e){t.isPaused?this.generatedError=e:t.error(e)})).on("end",(function(){t.isPaused?t._upstreamEnded=!0:t.end()}))},r.prototype.pause=function(){return!!n.prototype.pause.call(this)&&(this._stream.pause(),!0)},r.prototype.resume=function(){return!!n.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},t.exports=r},{"../stream/GenericWorker":28,"../utils":32}],13:[function(e,t,i){var s=e("readable-stream").Readable;function n(e,t,i){s.call(this,t),this._helper=e;var n=this;e.on("data",(function(e,t){n.push(e)||n._helper.pause(),i&&i(t)})).on("error",(function(e){n.emit("error",e)})).on("end",(function(){n.push(null)}))}e("../utils").inherits(n,s),n.prototype._read=function(){this._helper.resume()},t.exports=n},{"../utils":32,"readable-stream":16}],14:[function(e,t,i){t.exports={isNode:"undefined"!=typeof Buffer,newBufferFrom:function(e,t){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(e,t);if("number"==typeof e)throw new Error('The "data" argument must not be a number');return new Buffer(e,t)},allocBuffer:function(e){if(Buffer.alloc)return Buffer.alloc(e);var t=new Buffer(e);return t.fill(0),t},isBuffer:function(e){return Buffer.isBuffer(e)},isStream:function(e){return e&&"function"==typeof e.on&&"function"==typeof e.pause&&"function"==typeof e.resume}}},{}],15:[function(e,t,i){function s(e,t,i){var s,n=r.getTypeOf(t),a=r.extend(i||{},c);a.date=a.date||new Date,null!==a.compression&&(a.compression=a.compression.toUpperCase()),"string"==typeof a.unixPermissions&&(a.unixPermissions=parseInt(a.unixPermissions,8)),a.unixPermissions&&16384&a.unixPermissions&&(a.dir=!0),a.dosPermissions&&16&a.dosPermissions&&(a.dir=!0),a.dir&&(e=f(e)),a.createFolders&&(s=E(e))&&p.call(this,s,!0);var u="string"===n&&!1===a.binary&&!1===a.base64;i&&void 0!==i.binary||(a.binary=!u),(t instanceof l&&0===t.uncompressedSize||a.dir||!t||0===t.length)&&(a.base64=!1,a.binary=!0,t="",a.compression="STORE",n="string");var C=null;C=t instanceof l||t instanceof o?t:I.isNode&&I.isStream(t)?new d(e,t):r.prepareContent(e,t,a.binary,a.optimizedBinaryString,a.base64);var T=new h(e,C,a);this.files[e]=T}var n=e("./utf8"),r=e("./utils"),o=e("./stream/GenericWorker"),a=e("./stream/StreamHelper"),c=e("./defaults"),l=e("./compressedObject"),h=e("./zipObject"),u=e("./generate"),I=e("./nodejsUtils"),d=e("./nodejs/NodejsStreamInputAdapter"),E=function(e){"/"===e.slice(-1)&&(e=e.substring(0,e.length-1));var t=e.lastIndexOf("/");return 0<t?e.substring(0,t):""},f=function(e){return"/"!==e.slice(-1)&&(e+="/"),e},p=function(e,t){return t=void 0!==t?t:c.createFolders,e=f(e),this.files[e]||s.call(this,e,null,{dir:!0,createFolders:t}),this.files[e]};function C(e){return"[object RegExp]"===Object.prototype.toString.call(e)}var T={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(e){var t,i,s;for(t in this.files)s=this.files[t],(i=t.slice(this.root.length,t.length))&&t.slice(0,this.root.length)===this.root&&e(i,s)},filter:function(e){var t=[];return this.forEach((function(i,s){e(i,s)&&t.push(s)})),t},file:function(e,t,i){if(1!==arguments.length)return e=this.root+e,s.call(this,e,t,i),this;if(C(e)){var n=e;return this.filter((function(e,t){return!t.dir&&n.test(e)}))}var r=this.files[this.root+e];return r&&!r.dir?r:null},folder:function(e){if(!e)return this;if(C(e))return this.filter((function(t,i){return i.dir&&e.test(t)}));var t=this.root+e,i=p.call(this,t),s=this.clone();return s.root=i.name,s},remove:function(e){e=this.root+e;var t=this.files[e];if(t||("/"!==e.slice(-1)&&(e+="/"),t=this.files[e]),t&&!t.dir)delete this.files[e];else for(var i=this.filter((function(t,i){return i.name.slice(0,e.length)===e})),s=0;s<i.length;s++)delete this.files[i[s].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(e){var t,i={};try{if((i=r.extend(e||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:n.utf8encode})).type=i.type.toLowerCase(),i.compression=i.compression.toUpperCase(),"binarystring"===i.type&&(i.type="string"),!i.type)throw new Error("No output type specified.");r.checkSupport(i.type),"darwin"!==i.platform&&"freebsd"!==i.platform&&"linux"!==i.platform&&"sunos"!==i.platform||(i.platform="UNIX"),"win32"===i.platform&&(i.platform="DOS");var s=i.comment||this.comment||"";t=u.generateWorker(this,i,s)}catch(e){(t=new o("error")).error(e)}return new a(t,i.type||"string",i.mimeType)},generateAsync:function(e,t){return this.generateInternalStream(e).accumulate(t)},generateNodeStream:function(e,t){return(e=e||{}).type||(e.type="nodebuffer"),this.generateInternalStream(e).toNodejsStream(t)}};t.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(e,t,i){t.exports=e("stream")},{stream:void 0}],17:[function(e,t,i){var s=e("./DataReader");function n(e){s.call(this,e);for(var t=0;t<this.data.length;t++)e[t]=255&e[t]}e("../utils").inherits(n,s),n.prototype.byteAt=function(e){return this.data[this.zero+e]},n.prototype.lastIndexOfSignature=function(e){for(var t=e.charCodeAt(0),i=e.charCodeAt(1),s=e.charCodeAt(2),n=e.charCodeAt(3),r=this.length-4;0<=r;--r)if(this.data[r]===t&&this.data[r+1]===i&&this.data[r+2]===s&&this.data[r+3]===n)return r-this.zero;return-1},n.prototype.readAndCheckSignature=function(e){var t=e.charCodeAt(0),i=e.charCodeAt(1),s=e.charCodeAt(2),n=e.charCodeAt(3),r=this.readData(4);return t===r[0]&&i===r[1]&&s===r[2]&&n===r[3]},n.prototype.readData=function(e){if(this.checkOffset(e),0===e)return[];var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=n},{"../utils":32,"./DataReader":18}],18:[function(e,t,i){var s=e("../utils");function n(e){this.data=e,this.length=e.length,this.index=0,this.zero=0}n.prototype={checkOffset:function(e){this.checkIndex(this.index+e)},checkIndex:function(e){if(this.length<this.zero+e||e<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+e+"). Corrupted zip ?")},setIndex:function(e){this.checkIndex(e),this.index=e},skip:function(e){this.setIndex(this.index+e)},byteAt:function(){},readInt:function(e){var t,i=0;for(this.checkOffset(e),t=this.index+e-1;t>=this.index;t--)i=(i<<8)+this.byteAt(t);return this.index+=e,i},readString:function(e){return s.transformTo("string",this.readData(e))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var e=this.readInt(4);return new Date(Date.UTC(1980+(e>>25&127),(e>>21&15)-1,e>>16&31,e>>11&31,e>>5&63,(31&e)<<1))}},t.exports=n},{"../utils":32}],19:[function(e,t,i){var s=e("./Uint8ArrayReader");function n(e){s.call(this,e)}e("../utils").inherits(n,s),n.prototype.readData=function(e){this.checkOffset(e);var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=n},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(e,t,i){var s=e("./DataReader");function n(e){s.call(this,e)}e("../utils").inherits(n,s),n.prototype.byteAt=function(e){return this.data.charCodeAt(this.zero+e)},n.prototype.lastIndexOfSignature=function(e){return this.data.lastIndexOf(e)-this.zero},n.prototype.readAndCheckSignature=function(e){return e===this.readData(4)},n.prototype.readData=function(e){this.checkOffset(e);var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=n},{"../utils":32,"./DataReader":18}],21:[function(e,t,i){var s=e("./ArrayReader");function n(e){s.call(this,e)}e("../utils").inherits(n,s),n.prototype.readData=function(e){if(this.checkOffset(e),0===e)return new Uint8Array(0);var t=this.data.subarray(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=n},{"../utils":32,"./ArrayReader":17}],22:[function(e,t,i){var s=e("../utils"),n=e("../support"),r=e("./ArrayReader"),o=e("./StringReader"),a=e("./NodeBufferReader"),c=e("./Uint8ArrayReader");t.exports=function(e){var t=s.getTypeOf(e);return s.checkSupport(t),"string"!==t||n.uint8array?"nodebuffer"===t?new a(e):n.uint8array?new c(s.transformTo("uint8array",e)):new r(s.transformTo("array",e)):new o(e)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(e,t,i){i.LOCAL_FILE_HEADER="PK",i.CENTRAL_FILE_HEADER="PK",i.CENTRAL_DIRECTORY_END="PK",i.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK",i.ZIP64_CENTRAL_DIRECTORY_END="PK",i.DATA_DESCRIPTOR="PK\b"},{}],24:[function(e,t,i){var s=e("./GenericWorker"),n=e("../utils");function r(e){s.call(this,"ConvertWorker to "+e),this.destType=e}n.inherits(r,s),r.prototype.processChunk=function(e){this.push({data:n.transformTo(this.destType,e.data),meta:e.meta})},t.exports=r},{"../utils":32,"./GenericWorker":28}],25:[function(e,t,i){var s=e("./GenericWorker"),n=e("../crc32");function r(){s.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}e("../utils").inherits(r,s),r.prototype.processChunk=function(e){this.streamInfo.crc32=n(e.data,this.streamInfo.crc32||0),this.push(e)},t.exports=r},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(e,t,i){var s=e("../utils"),n=e("./GenericWorker");function r(e){n.call(this,"DataLengthProbe for "+e),this.propName=e,this.withStreamInfo(e,0)}s.inherits(r,n),r.prototype.processChunk=function(e){if(e){var t=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=t+e.data.length}n.prototype.processChunk.call(this,e)},t.exports=r},{"../utils":32,"./GenericWorker":28}],27:[function(e,t,i){var s=e("../utils"),n=e("./GenericWorker");function r(e){n.call(this,"DataWorker");var t=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,e.then((function(e){t.dataIsReady=!0,t.data=e,t.max=e&&e.length||0,t.type=s.getTypeOf(e),t.isPaused||t._tickAndRepeat()}),(function(e){t.error(e)}))}s.inherits(r,n),r.prototype.cleanUp=function(){n.prototype.cleanUp.call(this),this.data=null},r.prototype.resume=function(){return!!n.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,s.delay(this._tickAndRepeat,[],this)),!0)},r.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(s.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},r.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var e=null,t=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":e=this.data.substring(this.index,t);break;case"uint8array":e=this.data.subarray(this.index,t);break;case"array":case"nodebuffer":e=this.data.slice(this.index,t)}return this.index=t,this.push({data:e,meta:{percent:this.max?this.index/this.max*100:0}})},t.exports=r},{"../utils":32,"./GenericWorker":28}],28:[function(e,t,i){function s(e){this.name=e||"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}s.prototype={push:function(e){this.emit("data",e)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(e){this.emit("error",e)}return!0},error:function(e){return!this.isFinished&&(this.isPaused?this.generatedError=e:(this.isFinished=!0,this.emit("error",e),this.previous&&this.previous.error(e),this.cleanUp()),!0)},on:function(e,t){return this._listeners[e].push(t),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(e,t){if(this._listeners[e])for(var i=0;i<this._listeners[e].length;i++)this._listeners[e][i].call(this,t)},pipe:function(e){return e.registerPrevious(this)},registerPrevious:function(e){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=e.streamInfo,this.mergeStreamInfo(),this.previous=e;var t=this;return e.on("data",(function(e){t.processChunk(e)})),e.on("end",(function(){t.end()})),e.on("error",(function(e){t.error(e)})),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 e=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),e=!0),this.previous&&this.previous.resume(),!e},flush:function(){},processChunk:function(e){this.push(e)},withStreamInfo:function(e,t){return this.extraStreamInfo[e]=t,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var e in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,e)&&(this.streamInfo[e]=this.extraStreamInfo[e])},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 e="Worker "+this.name;return this.previous?this.previous+" -> "+e:e}},t.exports=s},{}],29:[function(e,t,i){var s=e("../utils"),n=e("./ConvertWorker"),r=e("./GenericWorker"),o=e("../base64"),a=e("../support"),c=e("../external"),l=null;if(a.nodestream)try{l=e("../nodejs/NodejsStreamOutputAdapter")}catch(e){}function h(e,t){return new c.Promise((function(i,n){var r=[],a=e._internalType,c=e._outputType,l=e._mimeType;e.on("data",(function(e,i){r.push(e),t&&t(i)})).on("error",(function(e){r=[],n(e)})).on("end",(function(){try{var e=function(e,t,i){switch(e){case"blob":return s.newBlob(s.transformTo("arraybuffer",t),i);case"base64":return o.encode(t);default:return s.transformTo(e,t)}}(c,function(e,t){var i,s=0,n=null,r=0;for(i=0;i<t.length;i++)r+=t[i].length;switch(e){case"string":return t.join("");case"array":return Array.prototype.concat.apply([],t);case"uint8array":for(n=new Uint8Array(r),i=0;i<t.length;i++)n.set(t[i],s),s+=t[i].length;return n;case"nodebuffer":return Buffer.concat(t);default:throw new Error("concat : unsupported type '"+e+"'")}}(a,r),l);i(e)}catch(e){n(e)}r=[]})).resume()}))}function u(e,t,i){var o=t;switch(t){case"blob":case"arraybuffer":o="uint8array";break;case"base64":o="string"}try{this._internalType=o,this._outputType=t,this._mimeType=i,s.checkSupport(o),this._worker=e.pipe(new n(o)),e.lock()}catch(e){this._worker=new r("error"),this._worker.error(e)}}u.prototype={accumulate:function(e){return h(this,e)},on:function(e,t){var i=this;return"data"===e?this._worker.on(e,(function(e){t.call(i,e.data,e.meta)})):this._worker.on(e,(function(){s.delay(t,arguments,i)})),this},resume:function(){return s.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(e){if(s.checkSupport("nodestream"),"nodebuffer"!==this._outputType)throw new Error(this._outputType+" is not supported by this method");return new l(this,{objectMode:"nodebuffer"!==this._outputType},e)}},t.exports=u},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(e,t,i){if(i.base64=!0,i.array=!0,i.string=!0,i.arraybuffer="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8Array,i.nodebuffer="undefined"!=typeof Buffer,i.uint8array="undefined"!=typeof Uint8Array,"undefined"==typeof ArrayBuffer)i.blob=!1;else{var s=new ArrayBuffer(0);try{i.blob=0===new Blob([s],{type:"application/zip"}).size}catch(e){try{var n=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);n.append(s),i.blob=0===n.getBlob("application/zip").size}catch(e){i.blob=!1}}}try{i.nodestream=!!e("readable-stream").Readable}catch(e){i.nodestream=!1}},{"readable-stream":16}],31:[function(e,t,i){for(var s=e("./utils"),n=e("./support"),r=e("./nodejsUtils"),o=e("./stream/GenericWorker"),a=new Array(256),c=0;c<256;c++)a[c]=252<=c?6:248<=c?5:240<=c?4:224<=c?3:192<=c?2:1;function l(){o.call(this,"utf-8 decode"),this.leftOver=null}function h(){o.call(this,"utf-8 encode")}a[254]=a[254]=1,i.utf8encode=function(e){return n.nodebuffer?r.newBufferFrom(e,"utf-8"):function(e){var t,i,s,r,o,a=e.length,c=0;for(r=0;r<a;r++)55296==(64512&(i=e.charCodeAt(r)))&&r+1<a&&56320==(64512&(s=e.charCodeAt(r+1)))&&(i=65536+(i-55296<<10)+(s-56320),r++),c+=i<128?1:i<2048?2:i<65536?3:4;for(t=n.uint8array?new Uint8Array(c):new Array(c),r=o=0;o<c;r++)55296==(64512&(i=e.charCodeAt(r)))&&r+1<a&&56320==(64512&(s=e.charCodeAt(r+1)))&&(i=65536+(i-55296<<10)+(s-56320),r++),i<128?t[o++]=i:(i<2048?t[o++]=192|i>>>6:(i<65536?t[o++]=224|i>>>12:(t[o++]=240|i>>>18,t[o++]=128|i>>>12&63),t[o++]=128|i>>>6&63),t[o++]=128|63&i);return t}(e)},i.utf8decode=function(e){return n.nodebuffer?s.transformTo("nodebuffer",e).toString("utf-8"):function(e){var t,i,n,r,o=e.length,c=new Array(2*o);for(t=i=0;t<o;)if((n=e[t++])<128)c[i++]=n;else if(4<(r=a[n]))c[i++]=65533,t+=r-1;else{for(n&=2===r?31:3===r?15:7;1<r&&t<o;)n=n<<6|63&e[t++],r--;1<r?c[i++]=65533:n<65536?c[i++]=n:(n-=65536,c[i++]=55296|n>>10&1023,c[i++]=56320|1023&n)}return c.length!==i&&(c.subarray?c=c.subarray(0,i):c.length=i),s.applyFromCharCode(c)}(e=s.transformTo(n.uint8array?"uint8array":"array",e))},s.inherits(l,o),l.prototype.processChunk=function(e){var t=s.transformTo(n.uint8array?"uint8array":"array",e.data);if(this.leftOver&&this.leftOver.length){if(n.uint8array){var r=t;(t=new Uint8Array(r.length+this.leftOver.length)).set(this.leftOver,0),t.set(r,this.leftOver.length)}else t=this.leftOver.concat(t);this.leftOver=null}var o=function(e,t){var i;for((t=t||e.length)>e.length&&(t=e.length),i=t-1;0<=i&&128==(192&e[i]);)i--;return i<0||0===i?t:i+a[e[i]]>t?i:t}(t),c=t;o!==t.length&&(n.uint8array?(c=t.subarray(0,o),this.leftOver=t.subarray(o,t.length)):(c=t.slice(0,o),this.leftOver=t.slice(o,t.length))),this.push({data:i.utf8decode(c),meta:e.meta})},l.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:i.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},i.Utf8DecodeWorker=l,s.inherits(h,o),h.prototype.processChunk=function(e){this.push({data:i.utf8encode(e.data),meta:e.meta})},i.Utf8EncodeWorker=h},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(e,t,i){var s=e("./support"),n=e("./base64"),r=e("./nodejsUtils"),o=e("./external");function a(e){return e}function c(e,t){for(var i=0;i<e.length;++i)t[i]=255&e.charCodeAt(i);return t}e("setimmediate"),i.newBlob=function(e,t){i.checkSupport("blob");try{return new Blob([e],{type:t})}catch(i){try{var s=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return s.append(e),s.getBlob(t)}catch(e){throw new Error("Bug : can't construct the Blob.")}}};var l={stringifyByChunk:function(e,t,i){var s=[],n=0,r=e.length;if(r<=i)return String.fromCharCode.apply(null,e);for(;n<r;)"array"===t||"nodebuffer"===t?s.push(String.fromCharCode.apply(null,e.slice(n,Math.min(n+i,r)))):s.push(String.fromCharCode.apply(null,e.subarray(n,Math.min(n+i,r)))),n+=i;return s.join("")},stringifyByChar:function(e){for(var t="",i=0;i<e.length;i++)t+=String.fromCharCode(e[i]);return t},applyCanBeUsed:{uint8array:function(){try{return s.uint8array&&1===String.fromCharCode.apply(null,new Uint8Array(1)).length}catch(e){return!1}}(),nodebuffer:function(){try{return s.nodebuffer&&1===String.fromCharCode.apply(null,r.allocBuffer(1)).length}catch(e){return!1}}()}};function h(e){var t=65536,s=i.getTypeOf(e),n=!0;if("uint8array"===s?n=l.applyCanBeUsed.uint8array:"nodebuffer"===s&&(n=l.applyCanBeUsed.nodebuffer),n)for(;1<t;)try{return l.stringifyByChunk(e,s,t)}catch(e){t=Math.floor(t/2)}return l.stringifyByChar(e)}function u(e,t){for(var i=0;i<e.length;i++)t[i]=e[i];return t}i.applyFromCharCode=h;var I={};I.string={string:a,array:function(e){return c(e,new Array(e.length))},arraybuffer:function(e){return I.string.uint8array(e).buffer},uint8array:function(e){return c(e,new Uint8Array(e.length))},nodebuffer:function(e){return c(e,r.allocBuffer(e.length))}},I.array={string:h,array:a,arraybuffer:function(e){return new Uint8Array(e).buffer},uint8array:function(e){return new Uint8Array(e)},nodebuffer:function(e){return r.newBufferFrom(e)}},I.arraybuffer={string:function(e){return h(new Uint8Array(e))},array:function(e){return u(new Uint8Array(e),new Array(e.byteLength))},arraybuffer:a,uint8array:function(e){return new Uint8Array(e)},nodebuffer:function(e){return r.newBufferFrom(new Uint8Array(e))}},I.uint8array={string:h,array:function(e){return u(e,new Array(e.length))},arraybuffer:function(e){return e.buffer},uint8array:a,nodebuffer:function(e){return r.newBufferFrom(e)}},I.nodebuffer={string:h,array:function(e){return u(e,new Array(e.length))},arraybuffer:function(e){return I.nodebuffer.uint8array(e).buffer},uint8array:function(e){return u(e,new Uint8Array(e.length))},nodebuffer:a},i.transformTo=function(e,t){if(t=t||"",!e)return t;i.checkSupport(e);var s=i.getTypeOf(t);return I[s][e](t)},i.resolve=function(e){for(var t=e.split("/"),i=[],s=0;s<t.length;s++){var n=t[s];"."===n||""===n&&0!==s&&s!==t.length-1||(".."===n?i.pop():i.push(n))}return i.join("/")},i.getTypeOf=function(e){return"string"==typeof e?"string":"[object Array]"===Object.prototype.toString.call(e)?"array":s.nodebuffer&&r.isBuffer(e)?"nodebuffer":s.uint8array&&e instanceof Uint8Array?"uint8array":s.arraybuffer&&e instanceof ArrayBuffer?"arraybuffer":void 0},i.checkSupport=function(e){if(!s[e.toLowerCase()])throw new Error(e+" is not supported by this platform")},i.MAX_VALUE_16BITS=65535,i.MAX_VALUE_32BITS=-1,i.pretty=function(e){var t,i,s="";for(i=0;i<(e||"").length;i++)s+="\\x"+((t=e.charCodeAt(i))<16?"0":"")+t.toString(16).toUpperCase();return s},i.delay=function(e,t,i){setImmediate((function(){e.apply(i||null,t||[])}))},i.inherits=function(e,t){function i(){}i.prototype=t.prototype,e.prototype=new i},i.extend=function(){var e,t,i={};for(e=0;e<arguments.length;e++)for(t in arguments[e])Object.prototype.hasOwnProperty.call(arguments[e],t)&&void 0===i[t]&&(i[t]=arguments[e][t]);return i},i.prepareContent=function(e,t,r,a,l){return o.Promise.resolve(t).then((function(e){return s.blob&&(e instanceof Blob||-1!==["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(e)))&&"undefined"!=typeof FileReader?new o.Promise((function(t,i){var s=new FileReader;s.onload=function(e){t(e.target.result)},s.onerror=function(e){i(e.target.error)},s.readAsArrayBuffer(e)})):e})).then((function(t){var h,u=i.getTypeOf(t);return u?("arraybuffer"===u?t=i.transformTo("uint8array",t):"string"===u&&(l?t=n.decode(t):r&&!0!==a&&(t=c(h=t,s.uint8array?new Uint8Array(h.length):new Array(h.length)))),t):o.Promise.reject(new Error("Can't read the data of '"+e+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))}))}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(e,t,i){var s=e("./reader/readerFor"),n=e("./utils"),r=e("./signature"),o=e("./zipEntry"),a=e("./support");function c(e){this.files=[],this.loadOptions=e}c.prototype={checkSignature:function(e){if(!this.reader.readAndCheckSignature(e)){this.reader.index-=4;var t=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+n.pretty(t)+", expected "+n.pretty(e)+")")}},isSignature:function(e,t){var i=this.reader.index;this.reader.setIndex(e);var s=this.reader.readString(4)===t;return this.reader.setIndex(i),s},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 e=this.reader.readData(this.zipCommentLength),t=a.uint8array?"uint8array":"array",i=n.transformTo(t,e);this.zipComment=this.loadOptions.decodeFileName(i)},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 e,t,i,s=this.zip64EndOfCentralSize-44;0<s;)e=this.reader.readInt(2),t=this.reader.readInt(4),i=this.reader.readData(t),this.zip64ExtensibleData[e]={id:e,length:t,value:i}},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 e,t;for(e=0;e<this.files.length;e++)t=this.files[e],this.reader.setIndex(t.localHeaderOffset),this.checkSignature(r.LOCAL_FILE_HEADER),t.readLocalPart(this.reader),t.handleUTF8(),t.processAttributes()},readCentralDir:function(){var e;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(r.CENTRAL_FILE_HEADER);)(e=new o({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(e);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 e=this.reader.lastIndexOfSignature(r.CENTRAL_DIRECTORY_END);if(e<0)throw this.isSignature(0,r.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(e);var t=e;if(this.checkSignature(r.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===n.MAX_VALUE_16BITS||this.diskWithCentralDirStart===n.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===n.MAX_VALUE_16BITS||this.centralDirRecords===n.MAX_VALUE_16BITS||this.centralDirSize===n.MAX_VALUE_32BITS||this.centralDirOffset===n.MAX_VALUE_32BITS){if(this.zip64=!0,(e=this.reader.lastIndexOfSignature(r.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(e),this.checkSignature(r.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,r.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(r.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(r.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var i=this.centralDirOffset+this.centralDirSize;this.zip64&&(i+=20,i+=12+this.zip64EndOfCentralSize);var s=t-i;if(0<s)this.isSignature(t,r.CENTRAL_FILE_HEADER)||(this.reader.zero=s);else if(s<0)throw new Error("Corrupted zip: missing "+Math.abs(s)+" bytes.")},prepareReader:function(e){this.reader=s(e)},load:function(e){this.prepareReader(e),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},t.exports=c},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(e,t,i){var s=e("./reader/readerFor"),n=e("./utils"),r=e("./compressedObject"),o=e("./crc32"),a=e("./utf8"),c=e("./compressions"),l=e("./support");function h(e,t){this.options=e,this.loadOptions=t}h.prototype={isEncrypted:function(){return!(1&~this.bitFlag)},useUTF8:function(){return!(2048&~this.bitFlag)},readLocalPart:function(e){var t,i;if(e.skip(22),this.fileNameLength=e.readInt(2),i=e.readInt(2),this.fileName=e.readData(this.fileNameLength),e.skip(i),-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===(t=function(e){for(var t in c)if(Object.prototype.hasOwnProperty.call(c,t)&&c[t].magic===e)return c[t];return null}(this.compressionMethod)))throw new Error("Corrupted zip : compression "+n.pretty(this.compressionMethod)+" unknown (inner file : "+n.transformTo("string",this.fileName)+")");this.decompressed=new r(this.compressedSize,this.uncompressedSize,this.crc32,t,e.readData(this.compressedSize))},readCentralPart:function(e){this.versionMadeBy=e.readInt(2),e.skip(2),this.bitFlag=e.readInt(2),this.compressionMethod=e.readString(2),this.date=e.readDate(),this.crc32=e.readInt(4),this.compressedSize=e.readInt(4),this.uncompressedSize=e.readInt(4);var t=e.readInt(2);if(this.extraFieldsLength=e.readInt(2),this.fileCommentLength=e.readInt(2),this.diskNumberStart=e.readInt(2),this.internalFileAttributes=e.readInt(2),this.externalFileAttributes=e.readInt(4),this.localHeaderOffset=e.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");e.skip(t),this.readExtraFields(e),this.parseZIP64ExtraField(e),this.fileComment=e.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var e=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),0==e&&(this.dosPermissions=63&this.externalFileAttributes),3==e&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||"/"!==this.fileNameStr.slice(-1)||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var e=s(this.extraFields[1].value);this.uncompressedSize===n.MAX_VALUE_32BITS&&(this.uncompressedSize=e.readInt(8)),this.compressedSize===n.MAX_VALUE_32BITS&&(this.compressedSize=e.readInt(8)),this.localHeaderOffset===n.MAX_VALUE_32BITS&&(this.localHeaderOffset=e.readInt(8)),this.diskNumberStart===n.MAX_VALUE_32BITS&&(this.diskNumberStart=e.readInt(4))}},readExtraFields:function(e){var t,i,s,n=e.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});e.index+4<n;)t=e.readInt(2),i=e.readInt(2),s=e.readData(i),this.extraFields[t]={id:t,length:i,value:s};e.setIndex(n)},handleUTF8:function(){var e=l.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=a.utf8decode(this.fileName),this.fileCommentStr=a.utf8decode(this.fileComment);else{var t=this.findExtraFieldUnicodePath();if(null!==t)this.fileNameStr=t;else{var i=n.transformTo(e,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(i)}var s=this.findExtraFieldUnicodeComment();if(null!==s)this.fileCommentStr=s;else{var r=n.transformTo(e,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(r)}}},findExtraFieldUnicodePath:function(){var e=this.extraFields[28789];if(e){var t=s(e.value);return 1!==t.readInt(1)||o(this.fileName)!==t.readInt(4)?null:a.utf8decode(t.readData(e.length-5))}return null},findExtraFieldUnicodeComment:function(){var e=this.extraFields[25461];if(e){var t=s(e.value);return 1!==t.readInt(1)||o(this.fileComment)!==t.readInt(4)?null:a.utf8decode(t.readData(e.length-5))}return null}},t.exports=h},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(e,t,i){function s(e,t,i){this.name=e,this.dir=i.dir,this.date=i.date,this.comment=i.comment,this.unixPermissions=i.unixPermissions,this.dosPermissions=i.dosPermissions,this._data=t,this._dataBinary=i.binary,this.options={compression:i.compression,compressionOptions:i.compressionOptions}}var n=e("./stream/StreamHelper"),r=e("./stream/DataWorker"),o=e("./utf8"),a=e("./compressedObject"),c=e("./stream/GenericWorker");s.prototype={internalStream:function(e){var t=null,i="string";try{if(!e)throw new Error("No output type specified.");var s="string"===(i=e.toLowerCase())||"text"===i;"binarystring"!==i&&"text"!==i||(i="string"),t=this._decompressWorker();var r=!this._dataBinary;r&&!s&&(t=t.pipe(new o.Utf8EncodeWorker)),!r&&s&&(t=t.pipe(new o.Utf8DecodeWorker))}catch(e){(t=new c("error")).error(e)}return new n(t,i,"")},async:function(e,t){return this.internalStream(e).accumulate(t)},nodeStream:function(e,t){return this.internalStream(e||"nodebuffer").toNodejsStream(t)},_compressWorker:function(e,t){if(this._data instanceof a&&this._data.compression.magic===e.magic)return this._data.getCompressedWorker();var i=this._decompressWorker();return this._dataBinary||(i=i.pipe(new o.Utf8EncodeWorker)),a.createWorkerFrom(i,e,t)},_decompressWorker:function(){return this._data instanceof a?this._data.getContentWorker():this._data instanceof c?this._data:new r(this._data)}};for(var l=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],h=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},u=0;u<l.length;u++)s.prototype[l[u]]=h;t.exports=s},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(e,t,i){(function(e){var i,s,n=e.MutationObserver||e.WebKitMutationObserver;if(n){var r=0,o=new n(h),a=e.document.createTextNode("");o.observe(a,{characterData:!0}),i=function(){a.data=r=++r%2}}else if(e.setImmediate||void 0===e.MessageChannel)i="document"in e&&"onreadystatechange"in e.document.createElement("script")?function(){var t=e.document.createElement("script");t.onreadystatechange=function(){h(),t.onreadystatechange=null,t.parentNode.removeChild(t),t=null},e.document.documentElement.appendChild(t)}:function(){setTimeout(h,0)};else{var c=new e.MessageChannel;c.port1.onmessage=h,i=function(){c.port2.postMessage(0)}}var l=[];function h(){var e,t;s=!0;for(var i=l.length;i;){for(t=l,l=[],e=-1;++e<i;)t[e]();i=l.length}s=!1}t.exports=function(e){1!==l.push(e)||s||i()}}).call(this,void 0!==Wi?Wi:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],37:[function(e,t,i){var s=e("immediate");function n(){}var r={},o=["REJECTED"],a=["FULFILLED"],c=["PENDING"];function l(e){if("function"!=typeof e)throw new TypeError("resolver must be a function");this.state=c,this.queue=[],this.outcome=void 0,e!==n&&d(this,e)}function h(e,t,i){this.promise=e,"function"==typeof t&&(this.onFulfilled=t,this.callFulfilled=this.otherCallFulfilled),"function"==typeof i&&(this.onRejected=i,this.callRejected=this.otherCallRejected)}function u(e,t,i){s((function(){var s;try{s=t(i)}catch(t){return r.reject(e,t)}s===e?r.reject(e,new TypeError("Cannot resolve promise with itself")):r.resolve(e,s)}))}function I(e){var t=e&&e.then;if(e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof t)return function(){t.apply(e,arguments)}}function d(e,t){var i=!1;function s(t){i||(i=!0,r.reject(e,t))}function n(t){i||(i=!0,r.resolve(e,t))}var o=E((function(){t(n,s)}));"error"===o.status&&s(o.value)}function E(e,t){var i={};try{i.value=e(t),i.status="success"}catch(e){i.status="error",i.value=e}return i}(t.exports=l).prototype.finally=function(e){if("function"!=typeof e)return this;var t=this.constructor;return this.then((function(i){return t.resolve(e()).then((function(){return i}))}),(function(i){return t.resolve(e()).then((function(){throw i}))}))},l.prototype.catch=function(e){return this.then(null,e)},l.prototype.then=function(e,t){if("function"!=typeof e&&this.state===a||"function"!=typeof t&&this.state===o)return this;var i=new this.constructor(n);return this.state!==c?u(i,this.state===a?e:t,this.outcome):this.queue.push(new h(i,e,t)),i},h.prototype.callFulfilled=function(e){r.resolve(this.promise,e)},h.prototype.otherCallFulfilled=function(e){u(this.promise,this.onFulfilled,e)},h.prototype.callRejected=function(e){r.reject(this.promise,e)},h.prototype.otherCallRejected=function(e){u(this.promise,this.onRejected,e)},r.resolve=function(e,t){var i=E(I,t);if("error"===i.status)return r.reject(e,i.value);var s=i.value;if(s)d(e,s);else{e.state=a,e.outcome=t;for(var n=-1,o=e.queue.length;++n<o;)e.queue[n].callFulfilled(t)}return e},r.reject=function(e,t){e.state=o,e.outcome=t;for(var i=-1,s=e.queue.length;++i<s;)e.queue[i].callRejected(t);return e},l.resolve=function(e){return e instanceof this?e:r.resolve(new this(n),e)},l.reject=function(e){var t=new this(n);return r.reject(t,e)},l.all=function(e){var t=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var i=e.length,s=!1;if(!i)return this.resolve([]);for(var o=new Array(i),a=0,c=-1,l=new this(n);++c<i;)h(e[c],c);return l;function h(e,n){t.resolve(e).then((function(e){o[n]=e,++a!==i||s||(s=!0,r.resolve(l,o))}),(function(e){s||(s=!0,r.reject(l,e))}))}},l.race=function(e){var t=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var i=e.length,s=!1;if(!i)return this.resolve([]);for(var o,a=-1,c=new this(n);++a<i;)o=e[a],t.resolve(o).then((function(e){s||(s=!0,r.resolve(c,e))}),(function(e){s||(s=!0,r.reject(c,e))}));return c}},{immediate:36}],38:[function(e,t,i){var s={};(0,e("./lib/utils/common").assign)(s,e("./lib/deflate"),e("./lib/inflate"),e("./lib/zlib/constants")),t.exports=s},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(e,t,i){var s=e("./zlib/deflate"),n=e("./utils/common"),r=e("./utils/strings"),o=e("./zlib/messages"),a=e("./zlib/zstream"),c=Object.prototype.toString,l=0,h=-1,u=0,I=8;function d(e){if(!(this instanceof d))return new d(e);this.options=n.assign({level:h,method:I,chunkSize:16384,windowBits:15,memLevel:8,strategy:u,to:""},e||{});var t=this.options;t.raw&&0<t.windowBits?t.windowBits=-t.windowBits:t.gzip&&0<t.windowBits&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new a,this.strm.avail_out=0;var i=s.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(i!==l)throw new Error(o[i]);if(t.header&&s.deflateSetHeader(this.strm,t.header),t.dictionary){var E;if(E="string"==typeof t.dictionary?r.string2buf(t.dictionary):"[object ArrayBuffer]"===c.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,(i=s.deflateSetDictionary(this.strm,E))!==l)throw new Error(o[i]);this._dict_set=!0}}function E(e,t){var i=new d(t);if(i.push(e,!0),i.err)throw i.msg||o[i.err];return i.result}d.prototype.push=function(e,t){var i,o,a=this.strm,h=this.options.chunkSize;if(this.ended)return!1;o=t===~~t?t:!0===t?4:0,"string"==typeof e?a.input=r.string2buf(e):"[object ArrayBuffer]"===c.call(e)?a.input=new Uint8Array(e):a.input=e,a.next_in=0,a.avail_in=a.input.length;do{if(0===a.avail_out&&(a.output=new n.Buf8(h),a.next_out=0,a.avail_out=h),1!==(i=s.deflate(a,o))&&i!==l)return this.onEnd(i),!(this.ended=!0);0!==a.avail_out&&(0!==a.avail_in||4!==o&&2!==o)||("string"===this.options.to?this.onData(r.buf2binstring(n.shrinkBuf(a.output,a.next_out))):this.onData(n.shrinkBuf(a.output,a.next_out)))}while((0<a.avail_in||0===a.avail_out)&&1!==i);return 4===o?(i=s.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===l):2!==o||(this.onEnd(l),!(a.avail_out=0))},d.prototype.onData=function(e){this.chunks.push(e)},d.prototype.onEnd=function(e){e===l&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=n.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},i.Deflate=d,i.deflate=E,i.deflateRaw=function(e,t){return(t=t||{}).raw=!0,E(e,t)},i.gzip=function(e,t){return(t=t||{}).gzip=!0,E(e,t)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(e,t,i){var s=e("./zlib/inflate"),n=e("./utils/common"),r=e("./utils/strings"),o=e("./zlib/constants"),a=e("./zlib/messages"),c=e("./zlib/zstream"),l=e("./zlib/gzheader"),h=Object.prototype.toString;function u(e){if(!(this instanceof u))return new u(e);this.options=n.assign({chunkSize:16384,windowBits:0,to:""},e||{});var t=this.options;t.raw&&0<=t.windowBits&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(0<=t.windowBits&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),15<t.windowBits&&t.windowBits<48&&!(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new c,this.strm.avail_out=0;var i=s.inflateInit2(this.strm,t.windowBits);if(i!==o.Z_OK)throw new Error(a[i]);this.header=new l,s.inflateGetHeader(this.strm,this.header)}function I(e,t){var i=new u(t);if(i.push(e,!0),i.err)throw i.msg||a[i.err];return i.result}u.prototype.push=function(e,t){var i,a,c,l,u,I,d=this.strm,E=this.options.chunkSize,f=this.options.dictionary,p=!1;if(this.ended)return!1;a=t===~~t?t:!0===t?o.Z_FINISH:o.Z_NO_FLUSH,"string"==typeof e?d.input=r.binstring2buf(e):"[object ArrayBuffer]"===h.call(e)?d.input=new Uint8Array(e):d.input=e,d.next_in=0,d.avail_in=d.input.length;do{if(0===d.avail_out&&(d.output=new n.Buf8(E),d.next_out=0,d.avail_out=E),(i=s.inflate(d,o.Z_NO_FLUSH))===o.Z_NEED_DICT&&f&&(I="string"==typeof f?r.string2buf(f):"[object ArrayBuffer]"===h.call(f)?new Uint8Array(f):f,i=s.inflateSetDictionary(this.strm,I)),i===o.Z_BUF_ERROR&&!0===p&&(i=o.Z_OK,p=!1),i!==o.Z_STREAM_END&&i!==o.Z_OK)return this.onEnd(i),!(this.ended=!0);d.next_out&&(0!==d.avail_out&&i!==o.Z_STREAM_END&&(0!==d.avail_in||a!==o.Z_FINISH&&a!==o.Z_SYNC_FLUSH)||("string"===this.options.to?(c=r.utf8border(d.output,d.next_out),l=d.next_out-c,u=r.buf2string(d.output,c),d.next_out=l,d.avail_out=E-l,l&&n.arraySet(d.output,d.output,c,l,0),this.onData(u)):this.onData(n.shrinkBuf(d.output,d.next_out)))),0===d.avail_in&&0===d.avail_out&&(p=!0)}while((0<d.avail_in||0===d.avail_out)&&i!==o.Z_STREAM_END);return i===o.Z_STREAM_END&&(a=o.Z_FINISH),a===o.Z_FINISH?(i=s.inflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===o.Z_OK):a!==o.Z_SYNC_FLUSH||(this.onEnd(o.Z_OK),!(d.avail_out=0))},u.prototype.onData=function(e){this.chunks.push(e)},u.prototype.onEnd=function(e){e===o.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=n.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},i.Inflate=u,i.inflate=I,i.inflateRaw=function(e,t){return(t=t||{}).raw=!0,I(e,t)},i.ungzip=I},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(e,t,i){var s="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;i.assign=function(e){for(var t=Array.prototype.slice.call(arguments,1);t.length;){var i=t.shift();if(i){if("object"!=typeof i)throw new TypeError(i+"must be non-object");for(var s in i)i.hasOwnProperty(s)&&(e[s]=i[s])}}return e},i.shrinkBuf=function(e,t){return e.length===t?e:e.subarray?e.subarray(0,t):(e.length=t,e)};var n={arraySet:function(e,t,i,s,n){if(t.subarray&&e.subarray)e.set(t.subarray(i,i+s),n);else for(var r=0;r<s;r++)e[n+r]=t[i+r]},flattenChunks:function(e){var t,i,s,n,r,o;for(t=s=0,i=e.length;t<i;t++)s+=e[t].length;for(o=new Uint8Array(s),t=n=0,i=e.length;t<i;t++)r=e[t],o.set(r,n),n+=r.length;return o}},r={arraySet:function(e,t,i,s,n){for(var r=0;r<s;r++)e[n+r]=t[i+r]},flattenChunks:function(e){return[].concat.apply([],e)}};i.setTyped=function(e){e?(i.Buf8=Uint8Array,i.Buf16=Uint16Array,i.Buf32=Int32Array,i.assign(i,n)):(i.Buf8=Array,i.Buf16=Array,i.Buf32=Array,i.assign(i,r))},i.setTyped(s)},{}],42:[function(e,t,i){var s=e("./common"),n=!0,r=!0;try{String.fromCharCode.apply(null,[0])}catch(e){n=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){r=!1}for(var o=new s.Buf8(256),a=0;a<256;a++)o[a]=252<=a?6:248<=a?5:240<=a?4:224<=a?3:192<=a?2:1;function c(e,t){if(t<65537&&(e.subarray&&r||!e.subarray&&n))return String.fromCharCode.apply(null,s.shrinkBuf(e,t));for(var i="",o=0;o<t;o++)i+=String.fromCharCode(e[o]);return i}o[254]=o[254]=1,i.string2buf=function(e){var t,i,n,r,o,a=e.length,c=0;for(r=0;r<a;r++)55296==(64512&(i=e.charCodeAt(r)))&&r+1<a&&56320==(64512&(n=e.charCodeAt(r+1)))&&(i=65536+(i-55296<<10)+(n-56320),r++),c+=i<128?1:i<2048?2:i<65536?3:4;for(t=new s.Buf8(c),r=o=0;o<c;r++)55296==(64512&(i=e.charCodeAt(r)))&&r+1<a&&56320==(64512&(n=e.charCodeAt(r+1)))&&(i=65536+(i-55296<<10)+(n-56320),r++),i<128?t[o++]=i:(i<2048?t[o++]=192|i>>>6:(i<65536?t[o++]=224|i>>>12:(t[o++]=240|i>>>18,t[o++]=128|i>>>12&63),t[o++]=128|i>>>6&63),t[o++]=128|63&i);return t},i.buf2binstring=function(e){return c(e,e.length)},i.binstring2buf=function(e){for(var t=new s.Buf8(e.length),i=0,n=t.length;i<n;i++)t[i]=e.charCodeAt(i);return t},i.buf2string=function(e,t){var i,s,n,r,a=t||e.length,l=new Array(2*a);for(i=s=0;i<a;)if((n=e[i++])<128)l[s++]=n;else if(4<(r=o[n]))l[s++]=65533,i+=r-1;else{for(n&=2===r?31:3===r?15:7;1<r&&i<a;)n=n<<6|63&e[i++],r--;1<r?l[s++]=65533:n<65536?l[s++]=n:(n-=65536,l[s++]=55296|n>>10&1023,l[s++]=56320|1023&n)}return c(l,s)},i.utf8border=function(e,t){var i;for((t=t||e.length)>e.length&&(t=e.length),i=t-1;0<=i&&128==(192&e[i]);)i--;return i<0||0===i?t:i+o[e[i]]>t?i:t}},{"./common":41}],43:[function(e,t,i){t.exports=function(e,t,i,s){for(var n=65535&e,r=e>>>16&65535,o=0;0!==i;){for(i-=o=2e3<i?2e3:i;r=r+(n=n+t[s++]|0)|0,--o;);n%=65521,r%=65521}return n|r<<16}},{}],44:[function(e,t,i){t.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(e,t,i){var s=function(){for(var e,t=[],i=0;i<256;i++){e=i;for(var s=0;s<8;s++)e=1&e?3988292384^e>>>1:e>>>1;t[i]=e}return t}();t.exports=function(e,t,i,n){var r=s,o=n+i;e^=-1;for(var a=n;a<o;a++)e=e>>>8^r[255&(e^t[a])];return~e}},{}],46:[function(e,t,i){var s,n=e("../utils/common"),r=e("./trees"),o=e("./adler32"),a=e("./crc32"),c=e("./messages"),l=0,h=4,u=0,I=-2,d=-1,E=4,f=2,p=8,C=9,T=286,m=30,R=19,g=2*T+1,A=15,F=3,S=258,O=S+F+1,N=42,y=113,_=1,L=2,P=3,w=4;function v(e,t){return e.msg=c[t],t}function M(e){return(e<<1)-(4<e?9:0)}function D(e){for(var t=e.length;0<=--t;)e[t]=0}function b(e){var t=e.state,i=t.pending;i>e.avail_out&&(i=e.avail_out),0!==i&&(n.arraySet(e.output,t.pending_buf,t.pending_out,i,e.next_out),e.next_out+=i,t.pending_out+=i,e.total_out+=i,e.avail_out-=i,t.pending-=i,0===t.pending&&(t.pending_out=0))}function x(e,t){r._tr_flush_block(e,0<=e.block_start?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,b(e.strm)}function U(e,t){e.pending_buf[e.pending++]=t}function B(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function V(e,t){var i,s,n=e.max_chain_length,r=e.strstart,o=e.prev_length,a=e.nice_match,c=e.strstart>e.w_size-O?e.strstart-(e.w_size-O):0,l=e.window,h=e.w_mask,u=e.prev,I=e.strstart+S,d=l[r+o-1],E=l[r+o];e.prev_length>=e.good_match&&(n>>=2),a>e.lookahead&&(a=e.lookahead);do{if(l[(i=t)+o]===E&&l[i+o-1]===d&&l[i]===l[r]&&l[++i]===l[r+1]){r+=2,i++;do{}while(l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&r<I);if(s=S-(I-r),r=I-S,o<s){if(e.match_start=t,a<=(o=s))break;d=l[r+o-1],E=l[r+o]}}}while((t=u[t&h])>c&&0!=--n);return o<=e.lookahead?o:e.lookahead}function Y(e){var t,i,s,r,c,l,h,u,I,d,E=e.w_size;do{if(r=e.window_size-e.lookahead-e.strstart,e.strstart>=E+(E-O)){for(n.arraySet(e.window,e.window,E,E,0),e.match_start-=E,e.strstart-=E,e.block_start-=E,t=i=e.hash_size;s=e.head[--t],e.head[t]=E<=s?s-E:0,--i;);for(t=i=E;s=e.prev[--t],e.prev[t]=E<=s?s-E:0,--i;);r+=E}if(0===e.strm.avail_in)break;if(l=e.strm,h=e.window,u=e.strstart+e.lookahead,d=void 0,(I=r)<(d=l.avail_in)&&(d=I),i=0===d?0:(l.avail_in-=d,n.arraySet(h,l.input,l.next_in,d,u),1===l.state.wrap?l.adler=o(l.adler,h,d,u):2===l.state.wrap&&(l.adler=a(l.adler,h,d,u)),l.next_in+=d,l.total_in+=d,d),e.lookahead+=i,e.lookahead+e.insert>=F)for(c=e.strstart-e.insert,e.ins_h=e.window[c],e.ins_h=(e.ins_h<<e.hash_shift^e.window[c+1])&e.hash_mask;e.insert&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[c+F-1])&e.hash_mask,e.prev[c&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=c,c++,e.insert--,!(e.lookahead+e.insert<F)););}while(e.lookahead<O&&0!==e.strm.avail_in)}function G(e,t){for(var i,s;;){if(e.lookahead<O){if(Y(e),e.lookahead<O&&t===l)return _;if(0===e.lookahead)break}if(i=0,e.lookahead>=F&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+F-1])&e.hash_mask,i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==i&&e.strstart-i<=e.w_size-O&&(e.match_length=V(e,i)),e.match_length>=F)if(s=r._tr_tally(e,e.strstart-e.match_start,e.match_length-F),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=F){for(e.match_length--;e.strstart++,e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+F-1])&e.hash_mask,i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart,0!=--e.match_length;);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+1])&e.hash_mask;else s=r._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(s&&(x(e,!1),0===e.strm.avail_out))return _}return e.insert=e.strstart<F-1?e.strstart:F-1,t===h?(x(e,!0),0===e.strm.avail_out?P:w):e.last_lit&&(x(e,!1),0===e.strm.avail_out)?_:L}function z(e,t){for(var i,s,n;;){if(e.lookahead<O){if(Y(e),e.lookahead<O&&t===l)return _;if(0===e.lookahead)break}if(i=0,e.lookahead>=F&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+F-1])&e.hash_mask,i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=F-1,0!==i&&e.prev_length<e.max_lazy_match&&e.strstart-i<=e.w_size-O&&(e.match_length=V(e,i),e.match_length<=5&&(1===e.strategy||e.match_length===F&&4096<e.strstart-e.match_start)&&(e.match_length=F-1)),e.prev_length>=F&&e.match_length<=e.prev_length){for(n=e.strstart+e.lookahead-F,s=r._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-F),e.lookahead-=e.prev_length-1,e.prev_length-=2;++e.strstart<=n&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+F-1])&e.hash_mask,i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!=--e.prev_length;);if(e.match_available=0,e.match_length=F-1,e.strstart++,s&&(x(e,!1),0===e.strm.avail_out))return _}else if(e.match_available){if((s=r._tr_tally(e,0,e.window[e.strstart-1]))&&x(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return _}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(s=r._tr_tally(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<F-1?e.strstart:F-1,t===h?(x(e,!0),0===e.strm.avail_out?P:w):e.last_lit&&(x(e,!1),0===e.strm.avail_out)?_:L}function k(e,t,i,s,n){this.good_length=e,this.max_lazy=t,this.nice_length=i,this.max_chain=s,this.func=n}function H(){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=p,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 n.Buf16(2*g),this.dyn_dtree=new n.Buf16(2*(2*m+1)),this.bl_tree=new n.Buf16(2*(2*R+1)),D(this.dyn_ltree),D(this.dyn_dtree),D(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new n.Buf16(A+1),this.heap=new n.Buf16(2*T+1),D(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new n.Buf16(2*T+1),D(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 W(e){var t;return e&&e.state?(e.total_in=e.total_out=0,e.data_type=f,(t=e.state).pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?N:y,e.adler=2===t.wrap?0:1,t.last_flush=l,r._tr_init(t),u):v(e,I)}function X(e){var t,i=W(e);return i===u&&((t=e.state).window_size=2*t.w_size,D(t.head),t.max_lazy_match=s[t.level].max_lazy,t.good_match=s[t.level].good_length,t.nice_match=s[t.level].nice_length,t.max_chain_length=s[t.level].max_chain,t.strstart=0,t.block_start=0,t.lookahead=0,t.insert=0,t.match_length=t.prev_length=F-1,t.match_available=0,t.ins_h=0),i}function Z(e,t,i,s,r,o){if(!e)return I;var a=1;if(t===d&&(t=6),s<0?(a=0,s=-s):15<s&&(a=2,s-=16),r<1||C<r||i!==p||s<8||15<s||t<0||9<t||o<0||E<o)return v(e,I);8===s&&(s=9);var c=new H;return(e.state=c).strm=e,c.wrap=a,c.gzhead=null,c.w_bits=s,c.w_size=1<<c.w_bits,c.w_mask=c.w_size-1,c.hash_bits=r+7,c.hash_size=1<<c.hash_bits,c.hash_mask=c.hash_size-1,c.hash_shift=~~((c.hash_bits+F-1)/F),c.window=new n.Buf8(2*c.w_size),c.head=new n.Buf16(c.hash_size),c.prev=new n.Buf16(c.w_size),c.lit_bufsize=1<<r+6,c.pending_buf_size=4*c.lit_bufsize,c.pending_buf=new n.Buf8(c.pending_buf_size),c.d_buf=1*c.lit_bufsize,c.l_buf=3*c.lit_bufsize,c.level=t,c.strategy=o,c.method=i,X(e)}s=[new k(0,0,0,0,(function(e,t){var i=65535;for(i>e.pending_buf_size-5&&(i=e.pending_buf_size-5);;){if(e.lookahead<=1){if(Y(e),0===e.lookahead&&t===l)return _;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;var s=e.block_start+i;if((0===e.strstart||e.strstart>=s)&&(e.lookahead=e.strstart-s,e.strstart=s,x(e,!1),0===e.strm.avail_out))return _;if(e.strstart-e.block_start>=e.w_size-O&&(x(e,!1),0===e.strm.avail_out))return _}return e.insert=0,t===h?(x(e,!0),0===e.strm.avail_out?P:w):(e.strstart>e.block_start&&(x(e,!1),e.strm.avail_out),_)})),new k(4,4,8,4,G),new k(4,5,16,8,G),new k(4,6,32,32,G),new k(4,4,16,16,z),new k(8,16,32,32,z),new k(8,16,128,128,z),new k(8,32,128,256,z),new k(32,128,258,1024,z),new k(32,258,258,4096,z)],i.deflateInit=function(e,t){return Z(e,t,p,15,8,0)},i.deflateInit2=Z,i.deflateReset=X,i.deflateResetKeep=W,i.deflateSetHeader=function(e,t){return e&&e.state?2!==e.state.wrap?I:(e.state.gzhead=t,u):I},i.deflate=function(e,t){var i,n,o,c;if(!e||!e.state||5<t||t<0)return e?v(e,I):I;if(n=e.state,!e.output||!e.input&&0!==e.avail_in||666===n.status&&t!==h)return v(e,0===e.avail_out?-5:I);if(n.strm=e,i=n.last_flush,n.last_flush=t,n.status===N)if(2===n.wrap)e.adler=0,U(n,31),U(n,139),U(n,8),n.gzhead?(U(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),U(n,255&n.gzhead.time),U(n,n.gzhead.time>>8&255),U(n,n.gzhead.time>>16&255),U(n,n.gzhead.time>>24&255),U(n,9===n.level?2:2<=n.strategy||n.level<2?4:0),U(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(U(n,255&n.gzhead.extra.length),U(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=a(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69):(U(n,0),U(n,0),U(n,0),U(n,0),U(n,0),U(n,9===n.level?2:2<=n.strategy||n.level<2?4:0),U(n,3),n.status=y);else{var d=p+(n.w_bits-8<<4)<<8;d|=(2<=n.strategy||n.level<2?0:n.level<6?1:6===n.level?2:3)<<6,0!==n.strstart&&(d|=32),d+=31-d%31,n.status=y,B(n,d),0!==n.strstart&&(B(n,e.adler>>>16),B(n,65535&e.adler)),e.adler=1}if(69===n.status)if(n.gzhead.extra){for(o=n.pending;n.gzindex<(65535&n.gzhead.extra.length)&&(n.pending!==n.pending_buf_size||(n.gzhead.hcrc&&n.pending>o&&(e.adler=a(e.adler,n.pending_buf,n.pending-o,o)),b(e),o=n.pending,n.pending!==n.pending_buf_size));)U(n,255&n.gzhead.extra[n.gzindex]),n.gzindex++;n.gzhead.hcrc&&n.pending>o&&(e.adler=a(e.adler,n.pending_buf,n.pending-o,o)),n.gzindex===n.gzhead.extra.length&&(n.gzindex=0,n.status=73)}else n.status=73;if(73===n.status)if(n.gzhead.name){o=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>o&&(e.adler=a(e.adler,n.pending_buf,n.pending-o,o)),b(e),o=n.pending,n.pending===n.pending_buf_size)){c=1;break}c=n.gzindex<n.gzhead.name.length?255&n.gzhead.name.charCodeAt(n.gzindex++):0,U(n,c)}while(0!==c);n.gzhead.hcrc&&n.pending>o&&(e.adler=a(e.adler,n.pending_buf,n.pending-o,o)),0===c&&(n.gzindex=0,n.status=91)}else n.status=91;if(91===n.status)if(n.gzhead.comment){o=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>o&&(e.adler=a(e.adler,n.pending_buf,n.pending-o,o)),b(e),o=n.pending,n.pending===n.pending_buf_size)){c=1;break}c=n.gzindex<n.gzhead.comment.length?255&n.gzhead.comment.charCodeAt(n.gzindex++):0,U(n,c)}while(0!==c);n.gzhead.hcrc&&n.pending>o&&(e.adler=a(e.adler,n.pending_buf,n.pending-o,o)),0===c&&(n.status=103)}else n.status=103;if(103===n.status&&(n.gzhead.hcrc?(n.pending+2>n.pending_buf_size&&b(e),n.pending+2<=n.pending_buf_size&&(U(n,255&e.adler),U(n,e.adler>>8&255),e.adler=0,n.status=y)):n.status=y),0!==n.pending){if(b(e),0===e.avail_out)return n.last_flush=-1,u}else if(0===e.avail_in&&M(t)<=M(i)&&t!==h)return v(e,-5);if(666===n.status&&0!==e.avail_in)return v(e,-5);if(0!==e.avail_in||0!==n.lookahead||t!==l&&666!==n.status){var E=2===n.strategy?function(e,t){for(var i;;){if(0===e.lookahead&&(Y(e),0===e.lookahead)){if(t===l)return _;break}if(e.match_length=0,i=r._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,i&&(x(e,!1),0===e.strm.avail_out))return _}return e.insert=0,t===h?(x(e,!0),0===e.strm.avail_out?P:w):e.last_lit&&(x(e,!1),0===e.strm.avail_out)?_:L}(n,t):3===n.strategy?function(e,t){for(var i,s,n,o,a=e.window;;){if(e.lookahead<=S){if(Y(e),e.lookahead<=S&&t===l)return _;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=F&&0<e.strstart&&(s=a[n=e.strstart-1])===a[++n]&&s===a[++n]&&s===a[++n]){o=e.strstart+S;do{}while(s===a[++n]&&s===a[++n]&&s===a[++n]&&s===a[++n]&&s===a[++n]&&s===a[++n]&&s===a[++n]&&s===a[++n]&&n<o);e.match_length=S-(o-n),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=F?(i=r._tr_tally(e,1,e.match_length-F),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(i=r._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),i&&(x(e,!1),0===e.strm.avail_out))return _}return e.insert=0,t===h?(x(e,!0),0===e.strm.avail_out?P:w):e.last_lit&&(x(e,!1),0===e.strm.avail_out)?_:L}(n,t):s[n.level].func(n,t);if(E!==P&&E!==w||(n.status=666),E===_||E===P)return 0===e.avail_out&&(n.last_flush=-1),u;if(E===L&&(1===t?r._tr_align(n):5!==t&&(r._tr_stored_block(n,0,0,!1),3===t&&(D(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),b(e),0===e.avail_out))return n.last_flush=-1,u}return t!==h?u:n.wrap<=0?1:(2===n.wrap?(U(n,255&e.adler),U(n,e.adler>>8&255),U(n,e.adler>>16&255),U(n,e.adler>>24&255),U(n,255&e.total_in),U(n,e.total_in>>8&255),U(n,e.total_in>>16&255),U(n,e.total_in>>24&255)):(B(n,e.adler>>>16),B(n,65535&e.adler)),b(e),0<n.wrap&&(n.wrap=-n.wrap),0!==n.pending?u:1)},i.deflateEnd=function(e){var t;return e&&e.state?(t=e.state.status)!==N&&69!==t&&73!==t&&91!==t&&103!==t&&t!==y&&666!==t?v(e,I):(e.state=null,t===y?v(e,-3):u):I},i.deflateSetDictionary=function(e,t){var i,s,r,a,c,l,h,d,E=t.length;if(!e||!e.state)return I;if(2===(a=(i=e.state).wrap)||1===a&&i.status!==N||i.lookahead)return I;for(1===a&&(e.adler=o(e.adler,t,E,0)),i.wrap=0,E>=i.w_size&&(0===a&&(D(i.head),i.strstart=0,i.block_start=0,i.insert=0),d=new n.Buf8(i.w_size),n.arraySet(d,t,E-i.w_size,i.w_size,0),t=d,E=i.w_size),c=e.avail_in,l=e.next_in,h=e.input,e.avail_in=E,e.next_in=0,e.input=t,Y(i);i.lookahead>=F;){for(s=i.strstart,r=i.lookahead-(F-1);i.ins_h=(i.ins_h<<i.hash_shift^i.window[s+F-1])&i.hash_mask,i.prev[s&i.w_mask]=i.head[i.ins_h],i.head[i.ins_h]=s,s++,--r;);i.strstart=s,i.lookahead=F-1,Y(i)}return i.strstart+=i.lookahead,i.block_start=i.strstart,i.insert=i.lookahead,i.lookahead=0,i.match_length=i.prev_length=F-1,i.match_available=0,e.next_in=l,e.input=h,e.avail_in=c,i.wrap=a,u},i.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(e,t,i){t.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(e,t,i){t.exports=function(e,t){var i,s,n,r,o,a,c,l,h,u,I,d,E,f,p,C,T,m,R,g,A,F,S,O,N;i=e.state,s=e.next_in,O=e.input,n=s+(e.avail_in-5),r=e.next_out,N=e.output,o=r-(t-e.avail_out),a=r+(e.avail_out-257),c=i.dmax,l=i.wsize,h=i.whave,u=i.wnext,I=i.window,d=i.hold,E=i.bits,f=i.lencode,p=i.distcode,C=(1<<i.lenbits)-1,T=(1<<i.distbits)-1;e:do{E<15&&(d+=O[s++]<<E,E+=8,d+=O[s++]<<E,E+=8),m=f[d&C];t:for(;;){if(d>>>=R=m>>>24,E-=R,0==(R=m>>>16&255))N[r++]=65535&m;else{if(!(16&R)){if(!(64&R)){m=f[(65535&m)+(d&(1<<R)-1)];continue t}if(32&R){i.mode=12;break e}e.msg="invalid literal/length code",i.mode=30;break e}g=65535&m,(R&=15)&&(E<R&&(d+=O[s++]<<E,E+=8),g+=d&(1<<R)-1,d>>>=R,E-=R),E<15&&(d+=O[s++]<<E,E+=8,d+=O[s++]<<E,E+=8),m=p[d&T];i:for(;;){if(d>>>=R=m>>>24,E-=R,!(16&(R=m>>>16&255))){if(!(64&R)){m=p[(65535&m)+(d&(1<<R)-1)];continue i}e.msg="invalid distance code",i.mode=30;break e}if(A=65535&m,E<(R&=15)&&(d+=O[s++]<<E,(E+=8)<R&&(d+=O[s++]<<E,E+=8)),c<(A+=d&(1<<R)-1)){e.msg="invalid distance too far back",i.mode=30;break e}if(d>>>=R,E-=R,(R=r-o)<A){if(h<(R=A-R)&&i.sane){e.msg="invalid distance too far back",i.mode=30;break e}if(S=I,(F=0)===u){if(F+=l-R,R<g){for(g-=R;N[r++]=I[F++],--R;);F=r-A,S=N}}else if(u<R){if(F+=l+u-R,(R-=u)<g){for(g-=R;N[r++]=I[F++],--R;);if(F=0,u<g){for(g-=R=u;N[r++]=I[F++],--R;);F=r-A,S=N}}}else if(F+=u-R,R<g){for(g-=R;N[r++]=I[F++],--R;);F=r-A,S=N}for(;2<g;)N[r++]=S[F++],N[r++]=S[F++],N[r++]=S[F++],g-=3;g&&(N[r++]=S[F++],1<g&&(N[r++]=S[F++]))}else{for(F=r-A;N[r++]=N[F++],N[r++]=N[F++],N[r++]=N[F++],2<(g-=3););g&&(N[r++]=N[F++],1<g&&(N[r++]=N[F++]))}break}}break}}while(s<n&&r<a);s-=g=E>>3,d&=(1<<(E-=g<<3))-1,e.next_in=s,e.next_out=r,e.avail_in=s<n?n-s+5:5-(s-n),e.avail_out=r<a?a-r+257:257-(r-a),i.hold=d,i.bits=E}},{}],49:[function(e,t,i){var s=e("../utils/common"),n=e("./adler32"),r=e("./crc32"),o=e("./inffast"),a=e("./inftrees"),c=1,l=2,h=0,u=-2,I=1,d=852,E=592;function f(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function p(){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 s.Buf16(320),this.work=new s.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function C(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=I,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new s.Buf32(d),t.distcode=t.distdyn=new s.Buf32(E),t.sane=1,t.back=-1,h):u}function T(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,C(e)):u}function m(e,t){var i,s;return e&&e.state?(s=e.state,t<0?(i=0,t=-t):(i=1+(t>>4),t<48&&(t&=15)),t&&(t<8||15<t)?u:(null!==s.window&&s.wbits!==t&&(s.window=null),s.wrap=i,s.wbits=t,T(e))):u}function R(e,t){var i,s;return e?(s=new p,(e.state=s).window=null,(i=m(e,t))!==h&&(e.state=null),i):u}var g,A,F=!0;function S(e){if(F){var t;for(g=new s.Buf32(512),A=new s.Buf32(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(a(c,e.lens,0,288,g,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;a(l,e.lens,0,32,A,0,e.work,{bits:5}),F=!1}e.lencode=g,e.lenbits=9,e.distcode=A,e.distbits=5}function O(e,t,i,n){var r,o=e.state;return null===o.window&&(o.wsize=1<<o.wbits,o.wnext=0,o.whave=0,o.window=new s.Buf8(o.wsize)),n>=o.wsize?(s.arraySet(o.window,t,i-o.wsize,o.wsize,0),o.wnext=0,o.whave=o.wsize):(n<(r=o.wsize-o.wnext)&&(r=n),s.arraySet(o.window,t,i-n,r,o.wnext),(n-=r)?(s.arraySet(o.window,t,i-n,n,0),o.wnext=n,o.whave=o.wsize):(o.wnext+=r,o.wnext===o.wsize&&(o.wnext=0),o.whave<o.wsize&&(o.whave+=r))),0}i.inflateReset=T,i.inflateReset2=m,i.inflateResetKeep=C,i.inflateInit=function(e){return R(e,15)},i.inflateInit2=R,i.inflate=function(e,t){var i,d,E,p,C,T,m,R,g,A,F,N,y,_,L,P,w,v,M,D,b,x,U,B,V=0,Y=new s.Buf8(4),G=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!e||!e.state||!e.output||!e.input&&0!==e.avail_in)return u;12===(i=e.state).mode&&(i.mode=13),C=e.next_out,E=e.output,m=e.avail_out,p=e.next_in,d=e.input,T=e.avail_in,R=i.hold,g=i.bits,A=T,F=m,x=h;e:for(;;)switch(i.mode){case I:if(0===i.wrap){i.mode=13;break}for(;g<16;){if(0===T)break e;T--,R+=d[p++]<<g,g+=8}if(2&i.wrap&&35615===R){Y[i.check=0]=255&R,Y[1]=R>>>8&255,i.check=r(i.check,Y,2,0),g=R=0,i.mode=2;break}if(i.flags=0,i.head&&(i.head.done=!1),!(1&i.wrap)||(((255&R)<<8)+(R>>8))%31){e.msg="incorrect header check",i.mode=30;break}if(8!=(15&R)){e.msg="unknown compression method",i.mode=30;break}if(g-=4,b=8+(15&(R>>>=4)),0===i.wbits)i.wbits=b;else if(b>i.wbits){e.msg="invalid window size",i.mode=30;break}i.dmax=1<<b,e.adler=i.check=1,i.mode=512&R?10:12,g=R=0;break;case 2:for(;g<16;){if(0===T)break e;T--,R+=d[p++]<<g,g+=8}if(i.flags=R,8!=(255&i.flags)){e.msg="unknown compression method",i.mode=30;break}if(57344&i.flags){e.msg="unknown header flags set",i.mode=30;break}i.head&&(i.head.text=R>>8&1),512&i.flags&&(Y[0]=255&R,Y[1]=R>>>8&255,i.check=r(i.check,Y,2,0)),g=R=0,i.mode=3;case 3:for(;g<32;){if(0===T)break e;T--,R+=d[p++]<<g,g+=8}i.head&&(i.head.time=R),512&i.flags&&(Y[0]=255&R,Y[1]=R>>>8&255,Y[2]=R>>>16&255,Y[3]=R>>>24&255,i.check=r(i.check,Y,4,0)),g=R=0,i.mode=4;case 4:for(;g<16;){if(0===T)break e;T--,R+=d[p++]<<g,g+=8}i.head&&(i.head.xflags=255&R,i.head.os=R>>8),512&i.flags&&(Y[0]=255&R,Y[1]=R>>>8&255,i.check=r(i.check,Y,2,0)),g=R=0,i.mode=5;case 5:if(1024&i.flags){for(;g<16;){if(0===T)break e;T--,R+=d[p++]<<g,g+=8}i.length=R,i.head&&(i.head.extra_len=R),512&i.flags&&(Y[0]=255&R,Y[1]=R>>>8&255,i.check=r(i.check,Y,2,0)),g=R=0}else i.head&&(i.head.extra=null);i.mode=6;case 6:if(1024&i.flags&&(T<(N=i.length)&&(N=T),N&&(i.head&&(b=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Array(i.head.extra_len)),s.arraySet(i.head.extra,d,p,N,b)),512&i.flags&&(i.check=r(i.check,d,N,p)),T-=N,p+=N,i.length-=N),i.length))break e;i.length=0,i.mode=7;case 7:if(2048&i.flags){if(0===T)break e;for(N=0;b=d[p+N++],i.head&&b&&i.length<65536&&(i.head.name+=String.fromCharCode(b)),b&&N<T;);if(512&i.flags&&(i.check=r(i.check,d,N,p)),T-=N,p+=N,b)break e}else i.head&&(i.head.name=null);i.length=0,i.mode=8;case 8:if(4096&i.flags){if(0===T)break e;for(N=0;b=d[p+N++],i.head&&b&&i.length<65536&&(i.head.comment+=String.fromCharCode(b)),b&&N<T;);if(512&i.flags&&(i.check=r(i.check,d,N,p)),T-=N,p+=N,b)break e}else i.head&&(i.head.comment=null);i.mode=9;case 9:if(512&i.flags){for(;g<16;){if(0===T)break e;T--,R+=d[p++]<<g,g+=8}if(R!==(65535&i.check)){e.msg="header crc mismatch",i.mode=30;break}g=R=0}i.head&&(i.head.hcrc=i.flags>>9&1,i.head.done=!0),e.adler=i.check=0,i.mode=12;break;case 10:for(;g<32;){if(0===T)break e;T--,R+=d[p++]<<g,g+=8}e.adler=i.check=f(R),g=R=0,i.mode=11;case 11:if(0===i.havedict)return e.next_out=C,e.avail_out=m,e.next_in=p,e.avail_in=T,i.hold=R,i.bits=g,2;e.adler=i.check=1,i.mode=12;case 12:if(5===t||6===t)break e;case 13:if(i.last){R>>>=7&g,g-=7&g,i.mode=27;break}for(;g<3;){if(0===T)break e;T--,R+=d[p++]<<g,g+=8}switch(i.last=1&R,g-=1,3&(R>>>=1)){case 0:i.mode=14;break;case 1:if(S(i),i.mode=20,6!==t)break;R>>>=2,g-=2;break e;case 2:i.mode=17;break;case 3:e.msg="invalid block type",i.mode=30}R>>>=2,g-=2;break;case 14:for(R>>>=7&g,g-=7&g;g<32;){if(0===T)break e;T--,R+=d[p++]<<g,g+=8}if((65535&R)!=(R>>>16^65535)){e.msg="invalid stored block lengths",i.mode=30;break}if(i.length=65535&R,g=R=0,i.mode=15,6===t)break e;case 15:i.mode=16;case 16:if(N=i.length){if(T<N&&(N=T),m<N&&(N=m),0===N)break e;s.arraySet(E,d,p,N,C),T-=N,p+=N,m-=N,C+=N,i.length-=N;break}i.mode=12;break;case 17:for(;g<14;){if(0===T)break e;T--,R+=d[p++]<<g,g+=8}if(i.nlen=257+(31&R),R>>>=5,g-=5,i.ndist=1+(31&R),R>>>=5,g-=5,i.ncode=4+(15&R),R>>>=4,g-=4,286<i.nlen||30<i.ndist){e.msg="too many length or distance symbols",i.mode=30;break}i.have=0,i.mode=18;case 18:for(;i.have<i.ncode;){for(;g<3;){if(0===T)break e;T--,R+=d[p++]<<g,g+=8}i.lens[G[i.have++]]=7&R,R>>>=3,g-=3}for(;i.have<19;)i.lens[G[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,U={bits:i.lenbits},x=a(0,i.lens,0,19,i.lencode,0,i.work,U),i.lenbits=U.bits,x){e.msg="invalid code lengths set",i.mode=30;break}i.have=0,i.mode=19;case 19:for(;i.have<i.nlen+i.ndist;){for(;P=(V=i.lencode[R&(1<<i.lenbits)-1])>>>16&255,w=65535&V,!((L=V>>>24)<=g);){if(0===T)break e;T--,R+=d[p++]<<g,g+=8}if(w<16)R>>>=L,g-=L,i.lens[i.have++]=w;else{if(16===w){for(B=L+2;g<B;){if(0===T)break e;T--,R+=d[p++]<<g,g+=8}if(R>>>=L,g-=L,0===i.have){e.msg="invalid bit length repeat",i.mode=30;break}b=i.lens[i.have-1],N=3+(3&R),R>>>=2,g-=2}else if(17===w){for(B=L+3;g<B;){if(0===T)break e;T--,R+=d[p++]<<g,g+=8}g-=L,b=0,N=3+(7&(R>>>=L)),R>>>=3,g-=3}else{for(B=L+7;g<B;){if(0===T)break e;T--,R+=d[p++]<<g,g+=8}g-=L,b=0,N=11+(127&(R>>>=L)),R>>>=7,g-=7}if(i.have+N>i.nlen+i.ndist){e.msg="invalid bit length repeat",i.mode=30;break}for(;N--;)i.lens[i.have++]=b}}if(30===i.mode)break;if(0===i.lens[256]){e.msg="invalid code -- missing end-of-block",i.mode=30;break}if(i.lenbits=9,U={bits:i.lenbits},x=a(c,i.lens,0,i.nlen,i.lencode,0,i.work,U),i.lenbits=U.bits,x){e.msg="invalid literal/lengths set",i.mode=30;break}if(i.distbits=6,i.distcode=i.distdyn,U={bits:i.distbits},x=a(l,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,U),i.distbits=U.bits,x){e.msg="invalid distances set",i.mode=30;break}if(i.mode=20,6===t)break e;case 20:i.mode=21;case 21:if(6<=T&&258<=m){e.next_out=C,e.avail_out=m,e.next_in=p,e.avail_in=T,i.hold=R,i.bits=g,o(e,F),C=e.next_out,E=e.output,m=e.avail_out,p=e.next_in,d=e.input,T=e.avail_in,R=i.hold,g=i.bits,12===i.mode&&(i.back=-1);break}for(i.back=0;P=(V=i.lencode[R&(1<<i.lenbits)-1])>>>16&255,w=65535&V,!((L=V>>>24)<=g);){if(0===T)break e;T--,R+=d[p++]<<g,g+=8}if(P&&!(240&P)){for(v=L,M=P,D=w;P=(V=i.lencode[D+((R&(1<<v+M)-1)>>v)])>>>16&255,w=65535&V,!(v+(L=V>>>24)<=g);){if(0===T)break e;T--,R+=d[p++]<<g,g+=8}R>>>=v,g-=v,i.back+=v}if(R>>>=L,g-=L,i.back+=L,i.length=w,0===P){i.mode=26;break}if(32&P){i.back=-1,i.mode=12;break}if(64&P){e.msg="invalid literal/length code",i.mode=30;break}i.extra=15&P,i.mode=22;case 22:if(i.extra){for(B=i.extra;g<B;){if(0===T)break e;T--,R+=d[p++]<<g,g+=8}i.length+=R&(1<<i.extra)-1,R>>>=i.extra,g-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=23;case 23:for(;P=(V=i.distcode[R&(1<<i.distbits)-1])>>>16&255,w=65535&V,!((L=V>>>24)<=g);){if(0===T)break e;T--,R+=d[p++]<<g,g+=8}if(!(240&P)){for(v=L,M=P,D=w;P=(V=i.distcode[D+((R&(1<<v+M)-1)>>v)])>>>16&255,w=65535&V,!(v+(L=V>>>24)<=g);){if(0===T)break e;T--,R+=d[p++]<<g,g+=8}R>>>=v,g-=v,i.back+=v}if(R>>>=L,g-=L,i.back+=L,64&P){e.msg="invalid distance code",i.mode=30;break}i.offset=w,i.extra=15&P,i.mode=24;case 24:if(i.extra){for(B=i.extra;g<B;){if(0===T)break e;T--,R+=d[p++]<<g,g+=8}i.offset+=R&(1<<i.extra)-1,R>>>=i.extra,g-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){e.msg="invalid distance too far back",i.mode=30;break}i.mode=25;case 25:if(0===m)break e;if(N=F-m,i.offset>N){if((N=i.offset-N)>i.whave&&i.sane){e.msg="invalid distance too far back",i.mode=30;break}y=N>i.wnext?(N-=i.wnext,i.wsize-N):i.wnext-N,N>i.length&&(N=i.length),_=i.window}else _=E,y=C-i.offset,N=i.length;for(m<N&&(N=m),m-=N,i.length-=N;E[C++]=_[y++],--N;);0===i.length&&(i.mode=21);break;case 26:if(0===m)break e;E[C++]=i.length,m--,i.mode=21;break;case 27:if(i.wrap){for(;g<32;){if(0===T)break e;T--,R|=d[p++]<<g,g+=8}if(F-=m,e.total_out+=F,i.total+=F,F&&(e.adler=i.check=i.flags?r(i.check,E,F,C-F):n(i.check,E,F,C-F)),F=m,(i.flags?R:f(R))!==i.check){e.msg="incorrect data check",i.mode=30;break}g=R=0}i.mode=28;case 28:if(i.wrap&&i.flags){for(;g<32;){if(0===T)break e;T--,R+=d[p++]<<g,g+=8}if(R!==(4294967295&i.total)){e.msg="incorrect length check",i.mode=30;break}g=R=0}i.mode=29;case 29:x=1;break e;case 30:x=-3;break e;case 31:return-4;default:return u}return e.next_out=C,e.avail_out=m,e.next_in=p,e.avail_in=T,i.hold=R,i.bits=g,(i.wsize||F!==e.avail_out&&i.mode<30&&(i.mode<27||4!==t))&&O(e,e.output,e.next_out,F-e.avail_out)?(i.mode=31,-4):(A-=e.avail_in,F-=e.avail_out,e.total_in+=A,e.total_out+=F,i.total+=F,i.wrap&&F&&(e.adler=i.check=i.flags?r(i.check,E,F,e.next_out-F):n(i.check,E,F,e.next_out-F)),e.data_type=i.bits+(i.last?64:0)+(12===i.mode?128:0)+(20===i.mode||15===i.mode?256:0),(0==A&&0===F||4===t)&&x===h&&(x=-5),x)},i.inflateEnd=function(e){if(!e||!e.state)return u;var t=e.state;return t.window&&(t.window=null),e.state=null,h},i.inflateGetHeader=function(e,t){var i;return e&&e.state&&2&(i=e.state).wrap?((i.head=t).done=!1,h):u},i.inflateSetDictionary=function(e,t){var i,s=t.length;return e&&e.state?0!==(i=e.state).wrap&&11!==i.mode?u:11===i.mode&&n(1,t,s,0)!==i.check?-3:O(e,t,s,s)?(i.mode=31,-4):(i.havedict=1,h):u},i.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(e,t,i){var s=e("../utils/common"),n=[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],r=[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],o=[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],a=[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];t.exports=function(e,t,i,c,l,h,u,I){var d,E,f,p,C,T,m,R,g,A=I.bits,F=0,S=0,O=0,N=0,y=0,_=0,L=0,P=0,w=0,v=0,M=null,D=0,b=new s.Buf16(16),x=new s.Buf16(16),U=null,B=0;for(F=0;F<=15;F++)b[F]=0;for(S=0;S<c;S++)b[t[i+S]]++;for(y=A,N=15;1<=N&&0===b[N];N--);if(N<y&&(y=N),0===N)return l[h++]=20971520,l[h++]=20971520,I.bits=1,0;for(O=1;O<N&&0===b[O];O++);for(y<O&&(y=O),F=P=1;F<=15;F++)if(P<<=1,(P-=b[F])<0)return-1;if(0<P&&(0===e||1!==N))return-1;for(x[1]=0,F=1;F<15;F++)x[F+1]=x[F]+b[F];for(S=0;S<c;S++)0!==t[i+S]&&(u[x[t[i+S]]++]=S);if(T=0===e?(M=U=u,19):1===e?(M=n,D-=257,U=r,B-=257,256):(M=o,U=a,-1),F=O,C=h,L=S=v=0,f=-1,p=(w=1<<(_=y))-1,1===e&&852<w||2===e&&592<w)return 1;for(;;){for(m=F-L,g=u[S]<T?(R=0,u[S]):u[S]>T?(R=U[B+u[S]],M[D+u[S]]):(R=96,0),d=1<<F-L,O=E=1<<_;l[C+(v>>L)+(E-=d)]=m<<24|R<<16|g,0!==E;);for(d=1<<F-1;v&d;)d>>=1;if(0!==d?(v&=d-1,v+=d):v=0,S++,0==--b[F]){if(F===N)break;F=t[i+u[S]]}if(y<F&&(v&p)!==f){for(0===L&&(L=y),C+=O,P=1<<(_=F-L);_+L<N&&!((P-=b[_+L])<=0);)_++,P<<=1;if(w+=1<<_,1===e&&852<w||2===e&&592<w)return 1;l[f=v&p]=y<<24|_<<16|C-h}}return 0!==v&&(l[C+v]=F-L<<24|64<<16),I.bits=y,0}},{"../utils/common":41}],51:[function(e,t,i){t.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(e,t,i){var s=e("../utils/common"),n=0,r=1;function o(e){for(var t=e.length;0<=--t;)e[t]=0}var a=0,c=29,l=256,h=l+1+c,u=30,I=19,d=2*h+1,E=15,f=16,p=7,C=256,T=16,m=17,R=18,g=[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],A=[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],F=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],S=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],O=new Array(2*(h+2));o(O);var N=new Array(2*u);o(N);var y=new Array(512);o(y);var _=new Array(256);o(_);var L=new Array(c);o(L);var P,w,v,M=new Array(u);function D(e,t,i,s,n){this.static_tree=e,this.extra_bits=t,this.extra_base=i,this.elems=s,this.max_length=n,this.has_stree=e&&e.length}function b(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function x(e){return e<256?y[e]:y[256+(e>>>7)]}function U(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function B(e,t,i){e.bi_valid>f-i?(e.bi_buf|=t<<e.bi_valid&65535,U(e,e.bi_buf),e.bi_buf=t>>f-e.bi_valid,e.bi_valid+=i-f):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=i)}function V(e,t,i){B(e,i[2*t],i[2*t+1])}function Y(e,t){for(var i=0;i|=1&e,e>>>=1,i<<=1,0<--t;);return i>>>1}function G(e,t,i){var s,n,r=new Array(E+1),o=0;for(s=1;s<=E;s++)r[s]=o=o+i[s-1]<<1;for(n=0;n<=t;n++){var a=e[2*n+1];0!==a&&(e[2*n]=Y(r[a]++,a))}}function z(e){var t;for(t=0;t<h;t++)e.dyn_ltree[2*t]=0;for(t=0;t<u;t++)e.dyn_dtree[2*t]=0;for(t=0;t<I;t++)e.bl_tree[2*t]=0;e.dyn_ltree[2*C]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0}function k(e){8<e.bi_valid?U(e,e.bi_buf):0<e.bi_valid&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0}function H(e,t,i,s){var n=2*t,r=2*i;return e[n]<e[r]||e[n]===e[r]&&s[t]<=s[i]}function W(e,t,i){for(var s=e.heap[i],n=i<<1;n<=e.heap_len&&(n<e.heap_len&&H(t,e.heap[n+1],e.heap[n],e.depth)&&n++,!H(t,s,e.heap[n],e.depth));)e.heap[i]=e.heap[n],i=n,n<<=1;e.heap[i]=s}function X(e,t,i){var s,n,r,o,a=0;if(0!==e.last_lit)for(;s=e.pending_buf[e.d_buf+2*a]<<8|e.pending_buf[e.d_buf+2*a+1],n=e.pending_buf[e.l_buf+a],a++,0===s?V(e,n,t):(V(e,(r=_[n])+l+1,t),0!==(o=g[r])&&B(e,n-=L[r],o),V(e,r=x(--s),i),0!==(o=A[r])&&B(e,s-=M[r],o)),a<e.last_lit;);V(e,C,t)}function Z(e,t){var i,s,n,r=t.dyn_tree,o=t.stat_desc.static_tree,a=t.stat_desc.has_stree,c=t.stat_desc.elems,l=-1;for(e.heap_len=0,e.heap_max=d,i=0;i<c;i++)0!==r[2*i]?(e.heap[++e.heap_len]=l=i,e.depth[i]=0):r[2*i+1]=0;for(;e.heap_len<2;)r[2*(n=e.heap[++e.heap_len]=l<2?++l:0)]=1,e.depth[n]=0,e.opt_len--,a&&(e.static_len-=o[2*n+1]);for(t.max_code=l,i=e.heap_len>>1;1<=i;i--)W(e,r,i);for(n=c;i=e.heap[1],e.heap[1]=e.heap[e.heap_len--],W(e,r,1),s=e.heap[1],e.heap[--e.heap_max]=i,e.heap[--e.heap_max]=s,r[2*n]=r[2*i]+r[2*s],e.depth[n]=(e.depth[i]>=e.depth[s]?e.depth[i]:e.depth[s])+1,r[2*i+1]=r[2*s+1]=n,e.heap[1]=n++,W(e,r,1),2<=e.heap_len;);e.heap[--e.heap_max]=e.heap[1],function(e,t){var i,s,n,r,o,a,c=t.dyn_tree,l=t.max_code,h=t.stat_desc.static_tree,u=t.stat_desc.has_stree,I=t.stat_desc.extra_bits,f=t.stat_desc.extra_base,p=t.stat_desc.max_length,C=0;for(r=0;r<=E;r++)e.bl_count[r]=0;for(c[2*e.heap[e.heap_max]+1]=0,i=e.heap_max+1;i<d;i++)p<(r=c[2*c[2*(s=e.heap[i])+1]+1]+1)&&(r=p,C++),c[2*s+1]=r,l<s||(e.bl_count[r]++,o=0,f<=s&&(o=I[s-f]),a=c[2*s],e.opt_len+=a*(r+o),u&&(e.static_len+=a*(h[2*s+1]+o)));if(0!==C){do{for(r=p-1;0===e.bl_count[r];)r--;e.bl_count[r]--,e.bl_count[r+1]+=2,e.bl_count[p]--,C-=2}while(0<C);for(r=p;0!==r;r--)for(s=e.bl_count[r];0!==s;)l<(n=e.heap[--i])||(c[2*n+1]!==r&&(e.opt_len+=(r-c[2*n+1])*c[2*n],c[2*n+1]=r),s--)}}(e,t),G(r,l,e.bl_count)}function $(e,t,i){var s,n,r=-1,o=t[1],a=0,c=7,l=4;for(0===o&&(c=138,l=3),t[2*(i+1)+1]=65535,s=0;s<=i;s++)n=o,o=t[2*(s+1)+1],++a<c&&n===o||(a<l?e.bl_tree[2*n]+=a:0!==n?(n!==r&&e.bl_tree[2*n]++,e.bl_tree[2*T]++):a<=10?e.bl_tree[2*m]++:e.bl_tree[2*R]++,r=n,l=(a=0)===o?(c=138,3):n===o?(c=6,3):(c=7,4))}function j(e,t,i){var s,n,r=-1,o=t[1],a=0,c=7,l=4;for(0===o&&(c=138,l=3),s=0;s<=i;s++)if(n=o,o=t[2*(s+1)+1],!(++a<c&&n===o)){if(a<l)for(;V(e,n,e.bl_tree),0!=--a;);else 0!==n?(n!==r&&(V(e,n,e.bl_tree),a--),V(e,T,e.bl_tree),B(e,a-3,2)):a<=10?(V(e,m,e.bl_tree),B(e,a-3,3)):(V(e,R,e.bl_tree),B(e,a-11,7));r=n,l=(a=0)===o?(c=138,3):n===o?(c=6,3):(c=7,4)}}o(M);var q=!1;function Q(e,t,i,n){var r,o,c;B(e,(a<<1)+(n?1:0),3),o=t,c=i,k(r=e),U(r,c),U(r,~c),s.arraySet(r.pending_buf,r.window,o,c,r.pending),r.pending+=c}i._tr_init=function(e){q||(function(){var e,t,i,s,n,r=new Array(E+1);for(s=i=0;s<c-1;s++)for(L[s]=i,e=0;e<1<<g[s];e++)_[i++]=s;for(_[i-1]=s,s=n=0;s<16;s++)for(M[s]=n,e=0;e<1<<A[s];e++)y[n++]=s;for(n>>=7;s<u;s++)for(M[s]=n<<7,e=0;e<1<<A[s]-7;e++)y[256+n++]=s;for(t=0;t<=E;t++)r[t]=0;for(e=0;e<=143;)O[2*e+1]=8,e++,r[8]++;for(;e<=255;)O[2*e+1]=9,e++,r[9]++;for(;e<=279;)O[2*e+1]=7,e++,r[7]++;for(;e<=287;)O[2*e+1]=8,e++,r[8]++;for(G(O,h+1,r),e=0;e<u;e++)N[2*e+1]=5,N[2*e]=Y(e,5);P=new D(O,g,l+1,h,E),w=new D(N,A,0,u,E),v=new D(new Array(0),F,0,I,p)}(),q=!0),e.l_desc=new b(e.dyn_ltree,P),e.d_desc=new b(e.dyn_dtree,w),e.bl_desc=new b(e.bl_tree,v),e.bi_buf=0,e.bi_valid=0,z(e)},i._tr_stored_block=Q,i._tr_flush_block=function(e,t,i,s){var o,a,c=0;0<e.level?(2===e.strm.data_type&&(e.strm.data_type=function(e){var t,i=4093624447;for(t=0;t<=31;t++,i>>>=1)if(1&i&&0!==e.dyn_ltree[2*t])return n;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return r;for(t=32;t<l;t++)if(0!==e.dyn_ltree[2*t])return r;return n}(e)),Z(e,e.l_desc),Z(e,e.d_desc),c=function(e){var t;for($(e,e.dyn_ltree,e.l_desc.max_code),$(e,e.dyn_dtree,e.d_desc.max_code),Z(e,e.bl_desc),t=I-1;3<=t&&0===e.bl_tree[2*S[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t}(e),o=e.opt_len+3+7>>>3,(a=e.static_len+3+7>>>3)<=o&&(o=a)):o=a=i+5,i+4<=o&&-1!==t?Q(e,t,i,s):4===e.strategy||a===o?(B(e,2+(s?1:0),3),X(e,O,N)):(B(e,4+(s?1:0),3),function(e,t,i,s){var n;for(B(e,t-257,5),B(e,i-1,5),B(e,s-4,4),n=0;n<s;n++)B(e,e.bl_tree[2*S[n]+1],3);j(e,e.dyn_ltree,t-1),j(e,e.dyn_dtree,i-1)}(e,e.l_desc.max_code+1,e.d_desc.max_code+1,c+1),X(e,e.dyn_ltree,e.dyn_dtree)),z(e),s&&k(e)},i._tr_tally=function(e,t,i){return e.pending_buf[e.d_buf+2*e.last_lit]=t>>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&i,e.last_lit++,0===t?e.dyn_ltree[2*i]++:(e.matches++,t--,e.dyn_ltree[2*(_[i]+l+1)]++,e.dyn_dtree[2*x(t)]++),e.last_lit===e.lit_bufsize-1},i._tr_align=function(e){var t;B(e,2,3),V(e,C,O),16===(t=e).bi_valid?(U(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):8<=t.bi_valid&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)}},{"../utils/common":41}],53:[function(e,t,i){t.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(e,t,i){(function(e){!function(e,t){if(!e.setImmediate){var i,s,n,r,o=1,a={},c=!1,l=e.document,h=Object.getPrototypeOf&&Object.getPrototypeOf(e);h=h&&h.setTimeout?h:e,i="[object process]"==={}.toString.call(e.process)?function(e){process.nextTick((function(){I(e)}))}:function(){if(e.postMessage&&!e.importScripts){var t=!0,i=e.onmessage;return e.onmessage=function(){t=!1},e.postMessage("","*"),e.onmessage=i,t}}()?(r="setImmediate$"+Math.random()+"$",e.addEventListener?e.addEventListener("message",d,!1):e.attachEvent("onmessage",d),function(t){e.postMessage(r+t,"*")}):e.MessageChannel?((n=new MessageChannel).port1.onmessage=function(e){I(e.data)},function(e){n.port2.postMessage(e)}):l&&"onreadystatechange"in l.createElement("script")?(s=l.documentElement,function(e){var t=l.createElement("script");t.onreadystatechange=function(){I(e),t.onreadystatechange=null,s.removeChild(t),t=null},s.appendChild(t)}):function(e){setTimeout(I,0,e)},h.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=new Array(arguments.length-1),s=0;s<t.length;s++)t[s]=arguments[s+1];var n={callback:e,args:t};return a[o]=n,i(o),o++},h.clearImmediate=u}function u(e){delete a[e]}function I(e){if(c)setTimeout(I,0,e);else{var i=a[e];if(i){c=!0;try{!function(e){var i=e.callback,s=e.args;switch(s.length){case 0:i();break;case 1:i(s[0]);break;case 2:i(s[0],s[1]);break;case 3:i(s[0],s[1],s[2]);break;default:i.apply(t,s)}}(i)}finally{u(e),c=!1}}}}function d(t){t.source===e&&"string"==typeof t.data&&0===t.data.indexOf(r)&&I(+t.data.slice(r.length))}}("undefined"==typeof self?void 0===e?this:e:self)}).call(this,void 0!==Wi?Wi:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[10])(10));var Io={},Eo={};!function(e){const t=":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",i="["+t+"]["+(t+"\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040")+"]*",s=new RegExp("^"+i+"$");e.isExist=function(e){return void 0!==e},e.isEmptyObject=function(e){return 0===Object.keys(e).length},e.merge=function(e,t,i){if(t){const s=Object.keys(t),n=s.length;for(let r=0;r<n;r++)e[s[r]]="strict"===i?[t[s[r]]]:t[s[r]]}},e.getValue=function(t){return e.isExist(t)?t:""},e.isName=function(e){const t=s.exec(e);return!(null==t)},e.getAllMatches=function(e,t){const i=[];let s=t.exec(e);for(;s;){const n=[];n.startIndex=t.lastIndex-s[0].length;const r=s.length;for(let e=0;e<r;e++)n.push(s[e]);i.push(n),s=t.exec(e)}return i},e.nameRegexp=i}(Eo);const fo=Eo,po={allowBooleanAttributes:!1,unpairedTags:[]};function Co(e){return" "===e||"\t"===e||"\n"===e||"\r"===e}function To(e,t){const i=t;for(;t<e.length;t++)if("?"!=e[t]&&" "!=e[t]);else{const s=e.substr(i,t-i);if(t>5&&"xml"===s)return No("InvalidXml","XML declaration allowed only at the start of the document.",_o(e,t));if("?"==e[t]&&">"==e[t+1]){t++;break}}return t}function mo(e,t){if(e.length>t+5&&"-"===e[t+1]&&"-"===e[t+2]){for(t+=3;t<e.length;t++)if("-"===e[t]&&"-"===e[t+1]&&">"===e[t+2]){t+=2;break}}else if(e.length>t+8&&"D"===e[t+1]&&"O"===e[t+2]&&"C"===e[t+3]&&"T"===e[t+4]&&"Y"===e[t+5]&&"P"===e[t+6]&&"E"===e[t+7]){let i=1;for(t+=8;t<e.length;t++)if("<"===e[t])i++;else if(">"===e[t]&&(i--,0===i))break}else if(e.length>t+9&&"["===e[t+1]&&"C"===e[t+2]&&"D"===e[t+3]&&"A"===e[t+4]&&"T"===e[t+5]&&"A"===e[t+6]&&"["===e[t+7])for(t+=8;t<e.length;t++)if("]"===e[t]&&"]"===e[t+1]&&">"===e[t+2]){t+=2;break}return t}Io.validate=function(e,t){t=Object.assign({},po,t);const i=[];let s=!1,n=!1;"\ufeff"===e[0]&&(e=e.substr(1));for(let o=0;o<e.length;o++)if("<"===e[o]&&"?"===e[o+1]){if(o+=2,o=To(e,o),o.err)return o}else{if("<"!==e[o]){if(Co(e[o]))continue;return No("InvalidChar","char '"+e[o]+"' is not expected.",_o(e,o))}{let a=o;if(o++,"!"===e[o]){o=mo(e,o);continue}{let c=!1;"/"===e[o]&&(c=!0,o++);let l="";for(;o<e.length&&">"!==e[o]&&" "!==e[o]&&"\t"!==e[o]&&"\n"!==e[o]&&"\r"!==e[o];o++)l+=e[o];if(l=l.trim(),"/"===l[l.length-1]&&(l=l.substring(0,l.length-1),o--),r=l,!fo.isName(r)){let t;return t=0===l.trim().length?"Invalid space after '<'.":"Tag '"+l+"' is an invalid name.",No("InvalidTag",t,_o(e,o))}const h=Ao(e,o);if(!1===h)return No("InvalidAttr","Attributes for '"+l+"' have open quote.",_o(e,o));let u=h.value;if(o=h.index,"/"===u[u.length-1]){const i=o-u.length;u=u.substring(0,u.length-1);const n=So(u,t);if(!0!==n)return No(n.err.code,n.err.msg,_o(e,i+n.err.line));s=!0}else if(c){if(!h.tagClosed)return No("InvalidTag","Closing tag '"+l+"' doesn't have proper closing.",_o(e,o));if(u.trim().length>0)return No("InvalidTag","Closing tag '"+l+"' can't have attributes or invalid starting.",_o(e,a));if(0===i.length)return No("InvalidTag","Closing tag '"+l+"' has not been opened.",_o(e,a));{const t=i.pop();if(l!==t.tagName){let i=_o(e,t.tagStartPos);return No("InvalidTag","Expected closing tag '"+t.tagName+"' (opened in line "+i.line+", col "+i.col+") instead of closing tag '"+l+"'.",_o(e,a))}0==i.length&&(n=!0)}}else{const r=So(u,t);if(!0!==r)return No(r.err.code,r.err.msg,_o(e,o-u.length+r.err.line));if(!0===n)return No("InvalidXml","Multiple possible root nodes found.",_o(e,o));-1!==t.unpairedTags.indexOf(l)||i.push({tagName:l,tagStartPos:a}),s=!0}for(o++;o<e.length;o++)if("<"===e[o]){if("!"===e[o+1]){o++,o=mo(e,o);continue}if("?"!==e[o+1])break;if(o=To(e,++o),o.err)return o}else if("&"===e[o]){const t=Oo(e,o);if(-1==t)return No("InvalidChar","char '&' is not expected.",_o(e,o));o=t}else if(!0===n&&!Co(e[o]))return No("InvalidXml","Extra text at the end",_o(e,o));"<"===e[o]&&o--}}}var r;return s?1==i.length?No("InvalidTag","Unclosed tag '"+i[0].tagName+"'.",_o(e,i[0].tagStartPos)):!(i.length>0)||No("InvalidXml","Invalid '"+JSON.stringify(i.map((e=>e.tagName)),null,4).replace(/\r?\n/g,"")+"' found.",{line:1,col:1}):No("InvalidXml","Start tag expected.",1)};const Ro='"',go="'";function Ao(e,t){let i="",s="",n=!1;for(;t<e.length;t++){if(e[t]===Ro||e[t]===go)""===s?s=e[t]:s!==e[t]||(s="");else if(">"===e[t]&&""===s){n=!0;break}i+=e[t]}return""===s&&{value:i,index:t,tagClosed:n}}const Fo=new RegExp("(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['\"])(([\\s\\S])*?)\\5)?","g");function So(e,t){const i=fo.getAllMatches(e,Fo),s={};for(let e=0;e<i.length;e++){if(0===i[e][1].length)return No("InvalidAttr","Attribute '"+i[e][2]+"' has no space in starting.",Lo(i[e]));if(void 0!==i[e][3]&&void 0===i[e][4])return No("InvalidAttr","Attribute '"+i[e][2]+"' is without value.",Lo(i[e]));if(void 0===i[e][3]&&!t.allowBooleanAttributes)return No("InvalidAttr","boolean attribute '"+i[e][2]+"' is not allowed.",Lo(i[e]));const n=i[e][2];if(!yo(n))return No("InvalidAttr","Attribute '"+n+"' is an invalid name.",Lo(i[e]));if(s.hasOwnProperty(n))return No("InvalidAttr","Attribute '"+n+"' is repeated.",Lo(i[e]));s[n]=1}return!0}function Oo(e,t){if(";"===e[++t])return-1;if("#"===e[t])return function(e,t){let i=/\d/;for("x"===e[t]&&(t++,i=/[\da-fA-F]/);t<e.length;t++){if(";"===e[t])return t;if(!e[t].match(i))break}return-1}(e,++t);let i=0;for(;t<e.length;t++,i++)if(!(e[t].match(/\w/)&&i<20)){if(";"===e[t])break;return-1}return t}function No(e,t,i){return{err:{code:e,msg:t,line:i.line||i,col:i.col}}}function yo(e){return fo.isName(e)}function _o(e,t){const i=e.substring(0,t).split(/\r?\n/);return{line:i.length,col:i[i.length-1].length+1}}function Lo(e){return e.startIndex+e[1].length}var Po={};const wo={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(e,t){return t},attributeValueProcessor:function(e,t){return t},stopNodes:[],alwaysCreateTextNode:!1,isArray:()=>!1,commentPropName:!1,unpairedTags:[],processEntities:!0,htmlEntities:!1,ignoreDeclaration:!1,ignorePiTags:!1,transformTagName:!1,transformAttributeName:!1,updateTag:function(e,t,i){return e}};Po.buildOptions=function(e){return Object.assign({},wo,e)},Po.defaultOptions=wo;var vo=class{constructor(e){this.tagname=e,this.child=[],this[":@"]={}}add(e,t){"__proto__"===e&&(e="#__proto__"),this.child.push({[e]:t})}addChild(e){"__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})}};const Mo=Eo;function Do(e,t){let i="";for(;t<e.length&&"'"!==e[t]&&'"'!==e[t];t++)i+=e[t];if(i=i.trim(),-1!==i.indexOf(" "))throw new Error("External entites are not supported");const s=e[t++];let n="";for(;t<e.length&&e[t]!==s;t++)n+=e[t];return[i,n,t]}function bo(e,t){return"!"===e[t+1]&&"E"===e[t+2]&&"N"===e[t+3]&&"T"===e[t+4]&&"I"===e[t+5]&&"T"===e[t+6]&&"Y"===e[t+7]}function xo(e,t){return"!"===e[t+1]&&"E"===e[t+2]&&"L"===e[t+3]&&"E"===e[t+4]&&"M"===e[t+5]&&"E"===e[t+6]&&"N"===e[t+7]&&"T"===e[t+8]}function Uo(e,t){return"!"===e[t+1]&&"A"===e[t+2]&&"T"===e[t+3]&&"T"===e[t+4]&&"L"===e[t+5]&&"I"===e[t+6]&&"S"===e[t+7]&&"T"===e[t+8]}function Bo(e,t){return"!"===e[t+1]&&"N"===e[t+2]&&"O"===e[t+3]&&"T"===e[t+4]&&"A"===e[t+5]&&"T"===e[t+6]&&"I"===e[t+7]&&"O"===e[t+8]&&"N"===e[t+9]}function Vo(e){if(Mo.isName(e))return e;throw new Error(`Invalid entity name ${e}`)}var Yo=function(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,o="";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:o+=e[t];else n&&bo(e,t)?(t+=7,[entityName,val,t]=Do(e,t+1),-1===val.indexOf("&")&&(i[Vo(entityName)]={regx:RegExp(`&${entityName};`,"g"),val:val})):n&&xo(e,t)||n&&Uo(e,t)?t+=8:n&&Bo(e,t)?t+=9:r=!0,s++,o="";if(0!==s)throw new Error("Unclosed DOCTYPE")}return{entities:i,i:t}};const Go=/^[-+]?0x[a-fA-F0-9]+$/,zo=/^([\-\+])?(0*)(\.[0-9]+([eE]\-?[0-9]+)?|[0-9]+(\.[0-9]+([eE]\-?[0-9]+)?)?)$/;!Number.parseInt&&window.parseInt&&(Number.parseInt=window.parseInt),!Number.parseFloat&&window.parseFloat&&(Number.parseFloat=window.parseFloat);const ko={hex:!0,leadingZeros:!0,decimalPoint:".",eNotation:!0};const Ho=Eo,Wo=vo,Xo=Yo,Zo=function(e,t={}){if(t=Object.assign({},ko,t),!e||"string"!=typeof e)return e;let i=e.trim();if(void 0!==t.skipLike&&t.skipLike.test(i))return e;if(t.hex&&Go.test(i))return Number.parseInt(i,16);{const s=zo.exec(i);if(s){const n=s[1],r=s[2];let o=function(e){if(e&&-1!==e.indexOf("."))return"."===(e=e.replace(/0+$/,""))?e="0":"."===e[0]?e="0"+e:"."===e[e.length-1]&&(e=e.substr(0,e.length-1)),e;return e}(s[3]);const a=s[4]||s[6];if(!t.leadingZeros&&r.length>0&&n&&"."!==i[2])return e;if(!t.leadingZeros&&r.length>0&&!n&&"."!==i[1])return e;{const s=Number(i),c=""+s;return-1!==c.search(/[eE]/)||a?t.eNotation?s:e:-1!==i.indexOf(".")?"0"===c&&""===o||c===o||n&&c==="-"+o?s:e:r?o===c||n+o===c?s:e:i===c||i===n+c?s:e}}return e}};function $o(e){const t=Object.keys(e);for(let i=0;i<t.length;i++){const s=t[i];this.lastEntities[s]={regex:new RegExp("&"+s+";","g"),val:e[s]}}}function jo(e,t,i,s,n,r,o){if(void 0!==e&&(this.options.trimValues&&!s&&(e=e.trim()),e.length>0)){o||(e=this.replaceEntitiesValue(e));const s=this.options.tagValueProcessor(t,e,i,n,r);if(null==s)return e;if(typeof s!=typeof e||s!==e)return s;if(this.options.trimValues)return aa(e,this.options.parseTagValue,this.options.numberParseOptions);return e.trim()===e?aa(e,this.options.parseTagValue,this.options.numberParseOptions):e}}function qo(e){if(this.options.removeNSPrefix){const t=e.split(":"),i="/"===e.charAt(0)?"/":"";if("xmlns"===t[0])return"";2===t.length&&(e=i+t[1])}return e}const Qo=new RegExp("([^\\s=]+)\\s*(=\\s*(['\"])([\\s\\S]*?)\\3)?","gm");function Ko(e,t,i){if(!this.options.ignoreAttributes&&"string"==typeof e){const i=Ho.getAllMatches(e,Qo),s=i.length,n={};for(let e=0;e<s;e++){const s=this.resolveNameSpace(i[e][1]);let r=i[e][4],o=this.options.attributeNamePrefix+s;if(s.length)if(this.options.transformAttributeName&&(o=this.options.transformAttributeName(o)),"__proto__"===o&&(o="#__proto__"),void 0!==r){this.options.trimValues&&(r=r.trim()),r=this.replaceEntitiesValue(r);const e=this.options.attributeValueProcessor(s,r,t);n[o]=null==e?r:typeof e!=typeof r||e!==r?e:aa(r,this.options.parseAttributeValue,this.options.numberParseOptions)}else this.options.allowBooleanAttributes&&(n[o]=!0)}if(!Object.keys(n).length)return;if(this.options.attributesGroupName){const e={};return e[this.options.attributesGroupName]=n,e}return n}}const Jo=function(e){e=e.replace(/\r\n?/g,"\n");const t=new Wo("!xml");let i=t,s="",n="";for(let r=0;r<e.length;r++){if("<"===e[r])if("/"===e[r+1]){const t=na(e,">",r,"Closing Tag is not closed.");let o=e.substring(r+2,t).trim();if(this.options.removeNSPrefix){const e=o.indexOf(":");-1!==e&&(o=o.substr(e+1))}this.options.transformTagName&&(o=this.options.transformTagName(o)),i&&(s=this.saveTextToParentTag(s,i,n));const a=n.substring(n.lastIndexOf(".")+1);if(o&&-1!==this.options.unpairedTags.indexOf(o))throw new Error(`Unpaired tag can not be used as closing tag: </${o}>`);let c=0;a&&-1!==this.options.unpairedTags.indexOf(a)?(c=n.lastIndexOf(".",n.lastIndexOf(".")-1),this.tagsNodeStack.pop()):c=n.lastIndexOf("."),n=n.substring(0,c),i=this.tagsNodeStack.pop(),s="",r=t}else if("?"===e[r+1]){let t=ra(e,r,!1,"?>");if(!t)throw new Error("Pi Tag is not closed.");if(s=this.saveTextToParentTag(s,i,n),this.options.ignoreDeclaration&&"?xml"===t.tagName||this.options.ignorePiTags);else{const e=new Wo(t.tagName);e.add(this.options.textNodeName,""),t.tagName!==t.tagExp&&t.attrExpPresent&&(e[":@"]=this.buildAttributesMap(t.tagExp,n,t.tagName)),this.addChild(i,e,n)}r=t.closeIndex+1}else if("!--"===e.substr(r+1,3)){const t=na(e,"--\x3e",r+4,"Comment is not closed.");if(this.options.commentPropName){const o=e.substring(r+4,t-2);s=this.saveTextToParentTag(s,i,n),i.add(this.options.commentPropName,[{[this.options.textNodeName]:o}])}r=t}else if("!D"===e.substr(r+1,2)){const t=Xo(e,r);this.docTypeEntities=t.entities,r=t.i}else if("!["===e.substr(r+1,2)){const t=na(e,"]]>",r,"CDATA is not closed.")-2,o=e.substring(r+9,t);s=this.saveTextToParentTag(s,i,n);let a=this.parseTextData(o,i.tagname,n,!0,!1,!0,!0);null==a&&(a=""),this.options.cdataPropName?i.add(this.options.cdataPropName,[{[this.options.textNodeName]:o}]):i.add(this.options.textNodeName,a),r=t+2}else{let o=ra(e,r,this.options.removeNSPrefix),a=o.tagName;const c=o.rawTagName;let l=o.tagExp,h=o.attrExpPresent,u=o.closeIndex;this.options.transformTagName&&(a=this.options.transformTagName(a)),i&&s&&"!xml"!==i.tagname&&(s=this.saveTextToParentTag(s,i,n,!1));const I=i;if(I&&-1!==this.options.unpairedTags.indexOf(I.tagname)&&(i=this.tagsNodeStack.pop(),n=n.substring(0,n.lastIndexOf("."))),a!==t.tagname&&(n+=n?"."+a:a),this.isItStopNode(this.options.stopNodes,n,a)){let t="";if(l.length>0&&l.lastIndexOf("/")===l.length-1)"/"===a[a.length-1]?(a=a.substr(0,a.length-1),n=n.substr(0,n.length-1),l=a):l=l.substr(0,l.length-1),r=o.closeIndex;else if(-1!==this.options.unpairedTags.indexOf(a))r=o.closeIndex;else{const i=this.readStopNodeData(e,c,u+1);if(!i)throw new Error(`Unexpected end of ${c}`);r=i.i,t=i.tagContent}const s=new Wo(a);a!==l&&h&&(s[":@"]=this.buildAttributesMap(l,n,a)),t&&(t=this.parseTextData(t,a,n,!0,h,!0,!0)),n=n.substr(0,n.lastIndexOf(".")),s.add(this.options.textNodeName,t),this.addChild(i,s,n)}else{if(l.length>0&&l.lastIndexOf("/")===l.length-1){"/"===a[a.length-1]?(a=a.substr(0,a.length-1),n=n.substr(0,n.length-1),l=a):l=l.substr(0,l.length-1),this.options.transformTagName&&(a=this.options.transformTagName(a));const e=new Wo(a);a!==l&&h&&(e[":@"]=this.buildAttributesMap(l,n,a)),this.addChild(i,e,n),n=n.substr(0,n.lastIndexOf("."))}else{const e=new Wo(a);this.tagsNodeStack.push(i),a!==l&&h&&(e[":@"]=this.buildAttributesMap(l,n,a)),this.addChild(i,e,n),i=e}s="",r=u}}else s+=e[r]}return t.child};function ea(e,t,i){const s=this.options.updateTag(t.tagname,i,t[":@"]);!1===s||("string"==typeof s?(t.tagname=s,e.addChild(t)):e.addChild(t))}const ta=function(e){if(this.options.processEntities){for(let t in this.docTypeEntities){const i=this.docTypeEntities[t];e=e.replace(i.regx,i.val)}for(let t in this.lastEntities){const i=this.lastEntities[t];e=e.replace(i.regex,i.val)}if(this.options.htmlEntities)for(let t in this.htmlEntities){const i=this.htmlEntities[t];e=e.replace(i.regex,i.val)}e=e.replace(this.ampEntity.regex,this.ampEntity.val)}return e};function ia(e,t,i,s){return e&&(void 0===s&&(s=0===Object.keys(t.child).length),void 0!==(e=this.parseTextData(e,t.tagname,i,!1,!!t[":@"]&&0!==Object.keys(t[":@"]).length,s))&&""!==e&&t.add(this.options.textNodeName,e),e=""),e}function sa(e,t,i){const s="*."+i;for(const i in e){const n=e[i];if(s===n||t===n)return!0}return!1}function na(e,t,i,s){const n=e.indexOf(t,i);if(-1===n)throw new Error(s);return n+t.length-1}function ra(e,t,i,s=">"){const n=function(e,t,i=">"){let s,n="";for(let r=t;r<e.length;r++){let t=e[r];if(s)t===s&&(s="");else if('"'===t||"'"===t)s=t;else if(t===i[0]){if(!i[1])return{data:n,index:r};if(e[r+1]===i[1])return{data:n,index:r}}else"\t"===t&&(t=" ");n+=t}}(e,t+1,s);if(!n)return;let r=n.data;const o=n.index,a=r.search(/\s/);let c=r,l=!0;-1!==a&&(c=r.substring(0,a),r=r.substring(a+1).trimStart());const h=c;if(i){const e=c.indexOf(":");-1!==e&&(c=c.substr(e+1),l=c!==n.data.substr(e+1))}return{tagName:c,tagExp:r,closeIndex:o,attrExpPresent:l,rawTagName:h}}function oa(e,t,i){const s=i;let n=1;for(;i<e.length;i++)if("<"===e[i])if("/"===e[i+1]){const r=na(e,">",i,`${t} is not closed`);if(e.substring(i+2,r).trim()===t&&(n--,0===n))return{tagContent:e.substring(s,i),i:r};i=r}else if("?"===e[i+1]){i=na(e,"?>",i+1,"StopNode is not closed.")}else if("!--"===e.substr(i+1,3)){i=na(e,"--\x3e",i+3,"StopNode is not closed.")}else if("!["===e.substr(i+1,2)){i=na(e,"]]>",i,"StopNode is not closed.")-2}else{const s=ra(e,i,">");if(s){(s&&s.tagName)===t&&"/"!==s.tagExp[s.tagExp.length-1]&&n++,i=s.closeIndex}}}function aa(e,t,i){if(t&&"string"==typeof e){const t=e.trim();return"true"===t||"false"!==t&&Zo(e,i)}return Ho.isExist(e)?e:""}var ca=class{constructor(e){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:"¢"},pound:{regex:/&(pound|#163);/g,val:"£"},yen:{regex:/&(yen|#165);/g,val:"¥"},euro:{regex:/&(euro|#8364);/g,val:"€"},copyright:{regex:/&(copy|#169);/g,val:"©"},reg:{regex:/&(reg|#174);/g,val:"®"},inr:{regex:/&(inr|#8377);/g,val:"₹"},num_dec:{regex:/&#([0-9]{1,7});/g,val:(e,t)=>String.fromCharCode(Number.parseInt(t,10))},num_hex:{regex:/&#x([0-9a-fA-F]{1,6});/g,val:(e,t)=>String.fromCharCode(Number.parseInt(t,16))}},this.addExternalEntities=$o,this.parseXml=Jo,this.parseTextData=jo,this.resolveNameSpace=qo,this.buildAttributesMap=Ko,this.isItStopNode=sa,this.replaceEntitiesValue=ta,this.readStopNodeData=oa,this.saveTextToParentTag=ia,this.addChild=ea}},la={};function ha(e,t,i){let s;const n={};for(let r=0;r<e.length;r++){const o=e[r],a=ua(o);let c="";if(c=void 0===i?a:i+"."+a,a===t.textNodeName)void 0===s?s=o[a]:s+=""+o[a];else{if(void 0===a)continue;if(o[a]){let e=ha(o[a],t,c);const i=da(e,t);o[":@"]?Ia(e,o[":@"],c,t):1!==Object.keys(e).length||void 0===e[t.textNodeName]||t.alwaysCreateTextNode?0===Object.keys(e).length&&(t.alwaysCreateTextNode?e[t.textNodeName]="":e=""):e=e[t.textNodeName],void 0!==n[a]&&n.hasOwnProperty(a)?(Array.isArray(n[a])||(n[a]=[n[a]]),n[a].push(e)):t.isArray(a,c,i)?n[a]=[e]:n[a]=e}}}return"string"==typeof s?s.length>0&&(n[t.textNodeName]=s):void 0!==s&&(n[t.textNodeName]=s),n}function ua(e){const t=Object.keys(e);for(let e=0;e<t.length;e++){const i=t[e];if(":@"!==i)return i}}function Ia(e,t,i,s){if(t){const n=Object.keys(t),r=n.length;for(let o=0;o<r;o++){const r=n[o];s.isArray(r,i+"."+r,!0,!0)?e[r]=[t[r]]:e[r]=t[r]}}}function da(e,t){const{textNodeName:i}=t,s=Object.keys(e).length;return 0===s||!(1!==s||!e[i]&&"boolean"!=typeof e[i]&&0!==e[i])}la.prettify=function(e,t){return ha(e,t)};const{buildOptions:Ea}=Po,fa=ca,{prettify:pa}=la,Ca=Io;var Ta=class{constructor(e){this.externalEntities={},this.options=Ea(e)}parse(e,t){if("string"==typeof e);else{if(!e.toString)throw new Error("XML data is accepted in String or Bytes[] form.");e=e.toString()}if(t){!0===t&&(t={});const i=Ca.validate(e,t);if(!0!==i)throw Error(`${i.err.msg}:${i.err.line}:${i.err.col}`)}const i=new fa(this.options);i.addExternalEntities(this.externalEntities);const s=i.parseXml(e);return this.options.preserveOrder||void 0===s?s:pa(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}};function ma(e,t,i,s){let n="",r=!1;for(let o=0;o<e.length;o++){const a=e[o],c=Ra(a);if(void 0===c)continue;let l="";if(l=0===i.length?c:`${i}.${c}`,c===t.textNodeName){let e=a[c];Aa(l,t)||(e=t.tagValueProcessor(c,e),e=Fa(e,t)),r&&(n+=s),n+=e,r=!1;continue}if(c===t.cdataPropName){r&&(n+=s),n+=`<![CDATA[${a[c][0][t.textNodeName]}]]>`,r=!1;continue}if(c===t.commentPropName){n+=s+`\x3c!--${a[c][0][t.textNodeName]}--\x3e`,r=!0;continue}if("?"===c[0]){const e=ga(a[":@"],t),i="?xml"===c?"":s;let o=a[c][0][t.textNodeName];o=0!==o.length?" "+o:"",n+=i+`<${c}${o}${e}?>`,r=!0;continue}let h=s;""!==h&&(h+=t.indentBy);const u=s+`<${c}${ga(a[":@"],t)}`,I=ma(a[c],t,l,h);-1!==t.unpairedTags.indexOf(c)?t.suppressUnpairedNode?n+=u+">":n+=u+"/>":I&&0!==I.length||!t.suppressEmptyNode?I&&I.endsWith(">")?n+=u+`>${I}${s}</${c}>`:(n+=u+">",I&&""!==s&&(I.includes("/>")||I.includes("</"))?n+=s+t.indentBy+I+s:n+=I,n+=`</${c}>`):n+=u+"/>",r=!0}return n}function Ra(e){const t=Object.keys(e);for(let i=0;i<t.length;i++){const s=t[i];if(e.hasOwnProperty(s)&&":@"!==s)return s}}function ga(e,t){let i="";if(e&&!t.ignoreAttributes)for(let s in e){if(!e.hasOwnProperty(s))continue;let n=t.attributeValueProcessor(s,e[s]);n=Fa(n,t),!0===n&&t.suppressBooleanAttributes?i+=` ${s.substr(t.attributeNamePrefix.length)}`:i+=` ${s.substr(t.attributeNamePrefix.length)}="${n}"`}return i}function Aa(e,t){let i=(e=e.substr(0,e.length-t.textNodeName.length-1)).substr(e.lastIndexOf(".")+1);for(let s in t.stopNodes)if(t.stopNodes[s]===e||t.stopNodes[s]==="*."+i)return!0;return!1}function Fa(e,t){if(e&&e.length>0&&t.processEntities)for(let i=0;i<t.entities.length;i++){const s=t.entities[i];e=e.replace(s.regex,s.val)}return e}const Sa=function(e,t){let i="";return t.format&&t.indentBy.length>0&&(i="\n"),ma(e,t,"",i)},Oa={attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,cdataPropName:!1,format:!1,indentBy:" ",suppressEmptyNode:!1,suppressUnpairedNode:!0,suppressBooleanAttributes:!0,tagValueProcessor:function(e,t){return t},attributeValueProcessor:function(e,t){return t},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 Na(e){this.options=Object.assign({},Oa,e),this.options.ignoreAttributes||this.options.attributesGroupName?this.isAttribute=function(){return!1}:(this.attrPrefixLen=this.options.attributeNamePrefix.length,this.isAttribute=La),this.processTextOrObjNode=ya,this.options.format?(this.indentate=_a,this.tagEndChar=">\n",this.newLine="\n"):(this.indentate=function(){return""},this.tagEndChar=">",this.newLine="")}function ya(e,t,i){const s=this.j2x(e,i+1);return void 0!==e[this.options.textNodeName]&&1===Object.keys(e).length?this.buildTextValNode(e[this.options.textNodeName],t,s.attrStr,i):this.buildObjectNode(s.val,t,s.attrStr,i)}function _a(e){return this.options.indentBy.repeat(e)}function La(e){return!(!e.startsWith(this.options.attributeNamePrefix)||e===this.options.textNodeName)&&e.substr(this.attrPrefixLen)}Na.prototype.build=function(e){return this.options.preserveOrder?Sa(e,this.options):(Array.isArray(e)&&this.options.arrayNodeName&&this.options.arrayNodeName.length>1&&(e={[this.options.arrayNodeName]:e}),this.j2x(e,0).val)},Na.prototype.j2x=function(e,t){let i="",s="";for(let n in e)if(Object.prototype.hasOwnProperty.call(e,n))if(void 0===e[n])this.isAttribute(n)&&(s+="");else if(null===e[n])this.isAttribute(n)?s+="":"?"===n[0]?s+=this.indentate(t)+"<"+n+"?"+this.tagEndChar:s+=this.indentate(t)+"<"+n+"/"+this.tagEndChar;else if(e[n]instanceof Date)s+=this.buildTextValNode(e[n],n,"",t);else if("object"!=typeof e[n]){const r=this.isAttribute(n);if(r)i+=this.buildAttrPairStr(r,""+e[n]);else if(n===this.options.textNodeName){let t=this.options.tagValueProcessor(n,""+e[n]);s+=this.replaceEntitiesValue(t)}else s+=this.buildTextValNode(e[n],n,"",t)}else if(Array.isArray(e[n])){const i=e[n].length;let r="",o="";for(let a=0;a<i;a++){const i=e[n][a];if(void 0===i);else if(null===i)"?"===n[0]?s+=this.indentate(t)+"<"+n+"?"+this.tagEndChar:s+=this.indentate(t)+"<"+n+"/"+this.tagEndChar;else if("object"==typeof i)if(this.options.oneListGroup){const e=this.j2x(i,t+1);r+=e.val,this.options.attributesGroupName&&i.hasOwnProperty(this.options.attributesGroupName)&&(o+=e.attrStr)}else r+=this.processTextOrObjNode(i,n,t);else if(this.options.oneListGroup){let e=this.options.tagValueProcessor(n,i);e=this.replaceEntitiesValue(e),r+=e}else r+=this.buildTextValNode(i,n,"",t)}this.options.oneListGroup&&(r=this.buildObjectNode(r,n,o,t)),s+=r}else if(this.options.attributesGroupName&&n===this.options.attributesGroupName){const t=Object.keys(e[n]),s=t.length;for(let r=0;r<s;r++)i+=this.buildAttrPairStr(t[r],""+e[n][t[r]])}else s+=this.processTextOrObjNode(e[n],n,t);return{attrStr:i,val:s}},Na.prototype.buildAttrPairStr=function(e,t){return t=this.options.attributeValueProcessor(e,""+t),t=this.replaceEntitiesValue(t),this.options.suppressBooleanAttributes&&"true"===t?" "+e:" "+e+'="'+t+'"'},Na.prototype.buildObjectNode=function(e,t,i,s){if(""===e)return"?"===t[0]?this.indentate(s)+"<"+t+i+"?"+this.tagEndChar:this.indentate(s)+"<"+t+i+this.closeTag(t)+this.tagEndChar;{let n="</"+t+this.tagEndChar,r="";return"?"===t[0]&&(r="?",n=""),!i&&""!==i||-1!==e.indexOf("<")?!1!==this.options.commentPropName&&t===this.options.commentPropName&&0===r.length?this.indentate(s)+`\x3c!--${e}--\x3e`+this.newLine:this.indentate(s)+"<"+t+i+r+this.tagEndChar+e+this.indentate(s)+n:this.indentate(s)+"<"+t+i+r+">"+e+n}},Na.prototype.closeTag=function(e){let t="";return-1!==this.options.unpairedTags.indexOf(e)?this.options.suppressUnpairedNode||(t="/"):t=this.options.suppressEmptyNode?"/":`></${e}`,t},Na.prototype.buildTextValNode=function(e,t,i,s){if(!1!==this.options.cdataPropName&&t===this.options.cdataPropName)return this.indentate(s)+`<![CDATA[${e}]]>`+this.newLine;if(!1!==this.options.commentPropName&&t===this.options.commentPropName)return this.indentate(s)+`\x3c!--${e}--\x3e`+this.newLine;if("?"===t[0])return this.indentate(s)+"<"+t+i+"?"+this.tagEndChar;{let n=this.options.tagValueProcessor(t,e);return n=this.replaceEntitiesValue(n),""===n?this.indentate(s)+"<"+t+i+this.closeTag(t)+this.tagEndChar:this.indentate(s)+"<"+t+i+">"+n+"</"+t+this.tagEndChar}},Na.prototype.replaceEntitiesValue=function(e){if(e&&e.length>0&&this.options.processEntities)for(let t=0;t<this.options.entities.length;t++){const i=this.options.entities[t];e=e.replace(i.regex,i.val)}return e};var Pa={XMLParser:Ta,XMLValidator:Io,XMLBuilder:Na};class wa{constructor(e,i){t(this,"date",new Date),t(this,"author"),t(this,"guid",ki.create()),t(this,"viewpoint"),t(this,"modifiedAuthor"),t(this,"modifiedDate"),t(this,"topic"),t(this,"_components"),t(this,"_comment",""),this._components=e,this._comment=i;const s=this._components.get(Ua);this.author=s.config.author}set comment(e){var t;const i=this._components.get(Ua);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}serialize(){let e=null;this.viewpoint&&(e=`<Viewpoint Guid="${this.viewpoint.guid}"/>`);let t=null;this.modifiedDate&&(t=`<ModifiedDate>${this.modifiedDate.toISOString()}</ModifiedDate>`);let i=null;return this.modifiedAuthor&&(i=`<ModifiedAuthor>${this.modifiedAuthor}</ModifiedAuthor>`),`\n <Comment Guid="${this.guid}">\n <Date>${this.date.toISOString()}</Date>\n <Author>${this.author}</Author>\n <Comment>${this.comment}</Comment>\n ${e??""}\n ${i??""}\n ${t??""}\n </Comment>\n `}}const va=class e{constructor(i){t(this,"guid",ki.create()),t(this,"title",e.default.title),t(this,"creationDate",new Date),t(this,"creationAuthor",""),t(this,"viewpoints",new Ti),t(this,"relatedTopics",new Ti),t(this,"comments",new mi),t(this,"customData",{}),t(this,"description"),t(this,"serverAssignedId"),t(this,"dueDate"),t(this,"modifiedAuthor"),t(this,"modifiedDate"),t(this,"index"),t(this,"_type",e.default.type),t(this,"_status",e.default.status),t(this,"_priority",e.default.priority),t(this,"_stage",e.default.stage),t(this,"_assignedTo",e.default.assignedTo),t(this,"_labels",e.default.labels??new Set),t(this,"_components"),this._components=i;const s=i.get(Ua);this.creationAuthor=s.config.author,this.relatedTopics.guard=e=>e!==this.guid}set type(e){const t=this._components.get(Ua),{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(Ua),{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(Ua);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(Ua);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(Ua);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(Ua),{strict:i,labels:s}=t.config;if(i){const t=new Set;for(const n of e){(!i||s.has(n))&&t.add(n)}this._labels=t}else this._labels=e}get labels(){return this._labels}get _managerVersion(){return this._components.get(Ua).config.version}set(e){const t=e,i=this;for(const s in e){if("guid"===s)continue;const e=t[s];s in this&&(i[s]=e)}return this._components.get(Ua).list.set(this.guid,this),this}createComment(e,t){const i=new wa(this._components,e);return i.viewpoint=t,i.topic=this,this.comments.set(i.guid,i),i}createLabelTags(e=this._managerVersion){let t="Labels";"2.1"===e&&(t="Labels"),"3"===e&&(t="Label");let i=[...this.labels].map((e=>`<${t}>${e}</${t}>`)).join("\n");for(const e in this.customData){const s=this.customData[e];"string"==typeof s&&(i+=`\n<${t}>${s}</${t}>`)}return"2.1"===e?i:"3"===e?0!==i.length?`<Labels>\n${i}\n</Labels>`:"<Labels/>":i}createCommentTags(e=this._managerVersion){const t=[...this.comments.values()].map((e=>e.serialize())).join("\n");return"2.1"===e?t:"3"===e?0!==t.length?`<Comments>\n${t}\n</Comments>`:"<Comments/>":t}createViewpointTags(e=this._managerVersion){let t="Viewpoints";"2.1"===e&&(t="Viewpoints"),"3"===e&&(t="ViewPoint");const i=this._components.get(uc),s=[...this.viewpoints].map((e=>i.list.get(e))).filter((e=>e)).map((e=>`<${t} Guid="${e.guid}">\n <Viewpoint>${e.guid}.bcfv</Viewpoint>\n <Snapshot>${e.guid}.jpeg</Snapshot>\n </${t}>\n `)).join("\n");return"2.1"===e?s:"3"===e?0!==s.length?`<Viewpoints>\n${s}\n</Viewpoints>`:"<Viewpoints />":s}createRelatedTopicTags(e=this._managerVersion){const t=[...this.relatedTopics].map((e=>`<RelatedTopic Guid="${e}"></RelatedTopic>\n `)).join("\n");return"2.1"===e?t:"3"===e?0!==t.length?`<RelatedTopics>\n${t}\n</RelatedTopics>`:"<RelatedTopics />":t}serialize(){const e=this._managerVersion;let t=null;this.serverAssignedId&&(t=`ServerAssignedId="${this.serverAssignedId}"`);let i=null;this.priority&&(i=`<Priority>${this.priority}</Priority>`);let s=null;this.index&&"2.1"===e&&(s=`<Index>${this.index}</Index>`);let n=null;this.modifiedDate&&(n=`<ModifiedDate>${this.modifiedDate.toISOString()}</ModifiedDate>`);let r=null;this.modifiedAuthor&&(r=`<ModifiedAuthor>${this.modifiedAuthor}</ModifiedAuthor>`);let o=null;this.dueDate&&(o=`<DueDate>${this.dueDate.toISOString()}</DueDate>`);let a=null;this.assignedTo&&(a=`<AssignedTo>${this.assignedTo}</AssignedTo>`);let c=null;this.description&&(c=`<Description>${this.description}</Description>`);let l=null;this.stage&&(l=`<Stage>${this.stage}</Stage>`);const h=this.createCommentTags(e),u=this.createViewpointTags(e),I=this.createLabelTags(e),d=this.createRelatedTopicTags(e);return`\n <?xml version="1.0" encoding="UTF-8"?>\n <Markup>\n <Topic Guid="${this.guid}" TopicType="${this.type}" TopicStatus="${this.status}" ${t??""}>\n <Title>${this.title}</Title>\n <CreationDate>${this.creationDate.toISOString()}</CreationDate>\n <CreationAuthor>${this.creationAuthor}</CreationAuthor>\n ${i??""}\n ${s??""}\n ${n??""}\n ${r??""}\n ${o??""}\n ${a??""}\n ${c??""}\n ${l??""}\n ${I}\n ${d}\n ${"3"===e?h:""}\n ${"3"===e?u:""}\n </Topic>\n ${"2.1"===e?h:""}\n ${"2.1"===e?u:""}\n </Markup>\n `}};t(va,"default",{title:"BCF Topic",type:"Issue",status:"Active"});let Ma=va;const Da=(e,t)=>{if(""===t.trim())return;const i=Ua.xmlParser.parse(t).Extensions;if(!i)return;const{Priorities:s,TopicStatuses:n,TopicTypes:r,Users:o}=i;if(s&&s.Priority){const t=Array.isArray(s.Priority)?s.Priority:[s.Priority];for(const i of t)e.config.priorities.add(i)}if(n&&n.TopicStatus){const t=Array.isArray(n.TopicStatus)?n.TopicStatus:[n.TopicStatus];for(const i of t)e.config.statuses.add(i)}if(r&&r.TopicType){const t=Array.isArray(r.TopicType)?r.TopicType:[r.TopicType];for(const i of t)e.config.types.add(i)}if(o&&o.User){const t=Array.isArray(o.User)?o.User:[o.User];for(const i of t)e.config.users.add(i)}};class ba extends Os{constructor(){super(...arguments),t(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}})}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}}const xa=class e extends ui{constructor(){super(...arguments),t(this,"enabled",!1),t(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}),t(this,"config",new ba(this,this.components,"BCF Topics",e.uuid)),t(this,"list",new mi),t(this,"onSetup",new ci),t(this,"isSetup",!1),t(this,"onBCFImported",new ci),t(this,"onDisposed",new ci)}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 Ma(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((([e,t])=>t.type));return new Set(e)}get usedStatuses(){const e=[...this.list].map((([e,t])=>t.status));return new Set(e)}get usedPriorities(){const e=[...this.list].map((([e,t])=>t.priority)).filter((e=>e));return new Set(e)}get usedStages(){const e=[...this.list].map((([e,t])=>t.stage)).filter((e=>e));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[t,s]of i.comments)e.push(s.author),s.modifiedAuthor&&e.push(s.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 e of t.labels)this.config.labels.add(e);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[e,i]of t.comments)this.config.users.add(i.author),i.modifiedAuthor&&this.config.users.add(i.modifiedAuthor)}}updateViewpointReferences(){const e=this.components.get(uc);for(const[t,i]of this.list)for(const t of i.viewpoints){e.list.has(t)||i.viewpoints.delete(t)}}async export(e=this.list.values()){const t=new uo;t.file("bcf.version",`<?xml version="1.0" encoding="UTF-8"?>\n <Version VersionId="${this.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>`),t.file("bcf.extensions",this.serializeExtensions());const i=await fetch("https://thatopen.github.io/engine_components/resources/favicon.ico"),s=await i.arrayBuffer(),n=this.components.get(uc);for(const i of e){const e=t.folder(i.guid);e.file("markup.bcf",i.serialize());for(const t of i.viewpoints){const i=n.list.get(t);i&&(e.file(`${t}.jpeg`,s,{binary:!0}),e.file(`${t}.bcfv`,await i.serialize()))}}return await t.generateAsync({type:"blob"})}serializeExtensions(){const e=[...this.config.types].map((e=>`<TopicType>${e}</TopicType>`)).join("\n"),t=[...this.config.statuses].map((e=>`<TopicStatus>${e}</TopicStatus>`)).join("\n"),i=[...this.config.priorities].map((e=>`<Priority>${e}</Priority>`)).join("\n"),s=[...this.config.labels].map((e=>`<TopicLabel>${e}</TopicLabel>`)).join("\n"),n=[...this.config.stages].map((e=>`<Stage>${e}</Stage>`)).join("\n"),r=[...this.config.users].map((e=>`<User>${e}</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&&wa))return null;const o=this.components.get(uc),a=new wa(this.components,n??"");return a.guid=t,a.date=new Date(i),a.author=s,a.viewpoint=(null==r?void 0:r.Guid)?o.list.get(r.Guid):void 0,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((e=>this.processMarkupComment(e))).filter((e=>e));return Array.isArray(n)?n:[n]}getMarkupLabels(e,t){var i;let s;if("2.1"===t&&(s=e.Topic.Labels),"3"===t&&(s=null==(i=e.Topic.Labels)?void 0:i.Label),!s)return[];return 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;if("2.1"===t&&(s=e.Topic.RelatedTopic),"3"===t&&(s=null==(i=e.Topic.RelatedTopics)?void 0:i.RelatedTopic),!s)return[];return(Array.isArray(s)?s:[s]).map((e=>e.Guid))}async load(t,s){var n;const{fallbackVersionOnImport:r,ignoreIncompleteTopicsOnImport:o,updateExtensionsOnImport:a}=this.config,c=new uo;await c.loadAsync(t);const l=Object.values(c.files);let h=r;const u=l.find((e=>e.name.endsWith(".version")));if(u){const t=await u.async("string"),i=e.xmlParser.parse(t).Version.VersionId;h=String(i)}if(!h||"2.1"!==h&&"3"!==h)throw new Error(`BCFTopics: ${h} is not supported.`);const I=l.find((e=>e.name.endsWith(".extensions")));if(a&&I){const e=await I.async("string");Da(this,e)}const d=[],E=this.components.get(uc),f=l.filter((e=>e.name.endsWith(".bcfv")));for(const t of f){const r=await t.async("string"),o=e.xmlParser.parse(r).VisualizationInfo;if(!o){console.warn("Missing VisualizationInfo in Viewpoint");continue}const a={},{Guid:c,ClippingPlanes:l,Components:u,OrthogonalCamera:I,PerspectiveCamera:E}=o;if(c&&(a.guid=c),u){const{Selection:e,Visibility:t}=u;if(e&&e.Component){const t=Array.isArray(e.Component)?e.Component:[e.Component];a.selectionComponents=t.map((e=>e.IfcGuid)).filter((e=>e))}if(t&&"DefaultVisibility"in t&&(a.defaultVisibility=t.DefaultVisibility),t&&t.Exceptions&&"Component"in t.Exceptions){const{Component:e}=t.Exceptions,i=Array.isArray(e)?e:[e];a.exceptionComponents=i.map((e=>e.IfcGuid)).filter((e=>e))}let i;"2.1"===h&&(i=u.ViewSetupHints),"3"===h&&(i=null==(n=u.Visibility)?void 0:n.ViewSetupHints),i&&("OpeningsVisible"in i&&(a.openingsVisible=i.OpeningsVisible),"SpacesVisible"in i&&(a.spacesVisible=i.SpacesVisible),"SpaceBoundariesVisible"in i&&(a.spaceBoundariesVisible=i.SpaceBoundariesVisible))}if(I||E){const e=o.PerspectiveCamera??o.OrthogonalCamera,{CameraViewPoint:t,CameraDirection:s}=e,n=new i.Vector3(Number(t.X),Number(t.Z),Number(-t.Y)),r=new i.Vector3(Number(s.X),Number(s.Z),Number(-s.Y)),c={position:{x:n.x,y:n.y,z:n.z},direction:{x:r.x,y:r.y,z:r.z},aspectRatio:"AspectRatio"in e?e.AspectRatio:1};"ViewToWorldScale"in e&&(a.camera={...c,viewToWorldScale:e.ViewToWorldScale}),"FieldOfView"in e&&(a.camera={...c,fov:e.FieldOfView})}const f=new cc(this.components,s,{data:a,setCamera:!1});if(u){const{Coloring:e}=u;if(e&&e.Color){const t=Array.isArray(e.Color)?e.Color:[e.Color];for(const e of t){const{Color:t,Component:i}=e,s=(Array.isArray(i)?i:[i]).map((e=>e.IfcGuid));f.componentColors.set(t,s)}}}if(d.push(f),l){const e=this.components.get(vr),t=Array.isArray(l.ClippingPlane)?l.ClippingPlane:[l.ClippingPlane];for(const n of t){const{Location:t,Direction:r}=n;if(!t||!r)continue;const o=new i.Vector3(t.X,t.Z,-t.Y),a=new i.Vector3(r.X,-r.Z,r.Y),c=e.createFromNormalAndCoplanarPoint(s,a,o);c.visible=!1,c.enabled=!1,f.clippingPlanes.add(c)}}}const p={},C=[],T=l.filter((e=>e.name.endsWith(".bcf")));for(const t of T){const i=await t.async("string"),s=e.xmlParser.parse(i).Markup,n=s.Topic,{Guid:r,TopicType:a,TopicStatus:c,Title:l,CreationDate:u,CreationAuthor:I}=n;if(o&&!(r&&a&&c&&l&&u&&I))continue;const d=new Ma(this.components);d.guid=r??d.guid;const f=this.getMarkupRelatedTopics(s,h);p[d.guid]=new Set(f),d.type=a??d.type,d.status=c??d.status,d.title=l??d.title,d.creationDate=u?new Date(u):d.creationDate,d.creationAuthor=I??d.creationAuthor,d.serverAssignedId=n.ServerAssignedId,d.priority=n.Priority,d.index=n.Index,d.modifiedDate=n.ModifiedDate?new Date(n.ModifiedDate):void 0,d.modifiedAuthor=n.ModifiedAuthor,d.dueDate=n.DueDate?new Date(n.DueDate):void 0,d.assignedTo=n.AssignedTo,d.description=n.Description,d.stage=n.Stage;const T=this.getMarkupLabels(s,h);for(const e of T)d.labels.add(e);const m=this.getMarkupComments(s,h);for(const e of m)d.comments.set(e.guid,e);const R=this.getMarkupViewpoints(s,h);for(const e of R){if(!e||!e.Guid)continue;const t=E.list.get(e.Guid);t&&d.viewpoints.add(t.guid)}this.list.set(d.guid,d),C.push(d)}for(const e in p){const t=this.list.get(e);if(!t)continue;const i=p[e];for(const e of i)t.relatedTopics.add(e)}return this.onBCFImported.trigger(C),{viewpoints:d,topics:C}}};t(xa,"uuid","de977976-e4f6-4e4f-a01a-204727839802"),t(xa,"xmlParser",new Pa.XMLParser({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 Ua=xa;const Ba=class e extends ui{constructor(i){super(i),t(this,"enabled",!0),t(this,"onDisposed",new ci),t(this,"_absoluteMin"),t(this,"_absoluteMax"),t(this,"_meshes",[]),this.components.add(e.uuid,this),this._absoluteMin=e.newBound(!0),this._absoluteMax=e.newBound(!1)}static getDimensions(e){const{min:t,max:s}=e,n=Math.abs(s.x-t.x),r=Math.abs(s.y-t.y),o=Math.abs(s.z-t.z),a=new i.Vector3;return a.subVectors(s,t).divideScalar(2).add(t),{width:n,height:r,depth:o,center:a}}static newBound(e){const t=e?1:-1;return new i.Vector3(t*Number.MAX_VALUE,t*Number.MAX_VALUE,t*Number.MAX_VALUE)}static getBounds(e,t,s){const n=s||this.newBound(!1),r=t||this.newBound(!0);for(const t of e)t.x<r.x&&(r.x=t.x),t.y<r.y&&(r.y=t.y),t.z<r.z&&(r.z=t.z),t.x>n.x&&(n.x=t.x),t.y>n.y&&(n.y=t.y),t.z>n.z&&(n.z=t.z);return new i.Box3(t,s)}dispose(){const t=this.components.get(pi);for(const e of this._meshes)t.destroy(e);this._meshes=[],this.onDisposed.trigger(e.uuid),this.onDisposed.reset()}get(){const e=this._absoluteMin.clone(),t=this._absoluteMax.clone();return new i.Box3(e,t)}getSphere(){const e=this._absoluteMin.clone(),t=this._absoluteMax.clone(),s=Math.abs((t.x-e.x)/2),n=Math.abs((t.y-e.y)/2),r=Math.abs((t.z-e.z)/2),o=new i.Vector3(e.x+s,e.y+n,e.z+r),a=o.distanceTo(e);return new i.Sphere(o,a)}getMesh(){const t=new i.Box3(this._absoluteMin,this._absoluteMax),s=e.getDimensions(t),{width:n,height:r,depth:o,center:a}=s,c=new i.BoxGeometry(n,r,o),l=new i.Mesh(c);return this._meshes.push(l),l.position.copy(a),l}reset(){this._absoluteMin=e.newBound(!0),this._absoluteMax=e.newBound(!1)}add(e){for(const t of e.items)this.addMesh(t.mesh)}addMesh(t,s){if(!t.geometry.index)return;const n=e.getFragmentBounds(t);t.updateMatrixWorld();const r=t.matrixWorld,o=new i.Matrix4,a=t instanceof i.InstancedMesh,c=new Set;if(t instanceof M.FragmentMesh){s||(s=t.fragment.ids);for(const e of s){const i=t.fragment.getInstancesIDs(e);if(i)for(const e of i)c.add(e)}}else c.add(0);for(const e of c){const i=n.min.clone(),s=n.max.clone();a&&(t.getMatrixAt(e,o),i.applyMatrix4(o),s.applyMatrix4(o)),i.applyMatrix4(r),s.applyMatrix4(r),i.x<this._absoluteMin.x&&(this._absoluteMin.x=i.x),i.y<this._absoluteMin.y&&(this._absoluteMin.y=i.y),i.z<this._absoluteMin.z&&(this._absoluteMin.z=i.z),i.x>this._absoluteMax.x&&(this._absoluteMax.x=i.x),i.y>this._absoluteMax.y&&(this._absoluteMax.y=i.y),i.z>this._absoluteMax.z&&(this._absoluteMax.z=i.z),s.x>this._absoluteMax.x&&(this._absoluteMax.x=s.x),s.y>this._absoluteMax.y&&(this._absoluteMax.y=s.y),s.z>this._absoluteMax.z&&(this._absoluteMax.z=s.z),s.x<this._absoluteMin.x&&(this._absoluteMin.x=s.x),s.y<this._absoluteMin.y&&(this._absoluteMin.y=s.y),s.z<this._absoluteMin.z&&(this._absoluteMin.z=s.z)}}addFragmentIdMap(e){const t=this.components.get(co);for(const i in e){const s=t.list.get(i);if(!s)continue;const n=e[i];this.addMesh(s.mesh,n)}}static getFragmentBounds(e){const t=e.geometry.attributes.position,s=Number.MAX_VALUE,n=-s,r=new i.Vector3(s,s,s),o=new i.Vector3(n,n,n);if(!e.geometry.index)throw new Error("Geometry must be indexed!");const a=Array.from(e.geometry.index.array);for(let e=0;e<a.length;e++){if(e%3==0&&0===a[e]&&0===a[e+1]&&0===a[e+2]){e+=2;continue}const i=a[e],s=t.getX(i),n=t.getY(i),c=t.getZ(i);s<r.x&&(r.x=s),n<r.y&&(r.y=n),c<r.z&&(r.z=c),s>o.x&&(o.x=s),n>o.y&&(o.y=n),c>o.z&&(o.z=c)}return new i.Box3(r,o)}};t(Ba,"uuid","d1444724-dba6-4cdd-a0c7-68ee1450d166");let Va=Ba;const Ya=class e extends ui{constructor(i){super(i),t(this,"enabled",!0),i.add(e.uuid,this)}async getIsolatedElements(e,t,i){const s=new Set;function n(i){if(s.has(i))return;const r=e.GetLine(t,i);if(r){s.add(i);for(const e in r){const t=r[e];t&&"Handle"===t.constructor.name&&t.value>0?n(t.value):Array.isArray(t)&&t.forEach((e=>{e&&"Handle"===e.constructor.name&&e.value>0&&n(e.value)}))}}}for(const e of i)n(e);const r=[];for(const e of s)r.push(e);r.sort(((e,t)=>e-t));const o=[];return r.forEach((i=>{const s=e.GetLine(t,i);o.push(s)})),o}async export(e,t,i){i.forEach((i=>{e.WriteLine(t,i)}));return e.SaveModel(t)}async splitIfc(e,t,i){const s=new Uint8Array(t),n=e.OpenModel(s),r=await this.getIsolatedElements(e,n,i),o=e.CreateModel({schema:x.Schemas.IFC2X3});return await this.export(e,o,r)}};t(Ya,"uuid","6eb0ba2f-71c0-464e-bcec-2d7c335186b2");let Ga=Ya;const za=class e{constructor(e){t(this,"onProgress",new ci),t(this,"inclusive",!1),t(this,"rules",[]),t(this,"ids",{}),t(this,"needsUpdate",new Map),t(this,"components"),this.components=e}static import(t,i){const s=e.importers.get(i.type);return s?s(t,i):(console.warn("Invalid query data:.",i),null)}static importRules(e){const t=[];for(const i of e){const e={};for(const t in i){const s=i[t];s.regexp?e[t]=new RegExp(s.value):e[t]=s}t.push(e)}return t}static importIds(e){const t={};for(const i in e.ids)t[i]=new Set(e.ids[i]);return t}clear(e){if(void 0===e)return this.ids={},void this.needsUpdate.clear();delete this.ids[e],this.needsUpdate.delete(e)}addID(e,t){this.ids[e]||(this.ids[e]=new Set),this.ids[e].add(t)}getData(){const e={};for(const t in this.ids)e[t]=Array.from(this.ids[t]);const t=this.exportRules();return{name:this.name,inclusive:this.inclusive,type:"IfcFinderQuery",ids:e,rules:t}}exportRules(){const e=[];for(const t of this.rules){const i={};for(const e in t){const s=t[e];s instanceof RegExp?i[e]={regexp:!0,value:s.source}:i[e]=s}e.push(i)}return e}findInFile(e,t){return new Promise((i=>{const s=new FileReader,n=new TextDecoder("utf-8"),r=1024e4;let o=0;const a=/;/,c=()=>{if(o>=t.size)return void i();const e=Math.min(o+r+1e3,t.size),n=t.slice(o,e);s.readAsArrayBuffer(n)};s.onload=()=>{if(!(s.result instanceof ArrayBuffer))return;const i=new Uint8Array(s.result),l=n.decode(i).split(a);l.shift(),this.findInLines(e,l),this.onProgress.trigger(o/t.size),o+=r,c()},c()}))}getIdFromLine(e){const t=e.slice(e.indexOf("#")+1,e.indexOf("="));return parseInt(t,10)}testRules(e){let t=null,i=null,s=null,n=!1;for(const r of this.rules)if("category"!==r.type){if(null===i&&(i=this.getAttributesFromLine(e),null===i)){if(this.inclusive)continue;n=!1;break}if(null===t&&(t=this.getCategoryFromLine(e),null===t)){if(this.inclusive)continue;n=!1;break}if(null===s&&(s=Object.keys(new x.IFC4[t]),s=s.slice(2),null===s)){if(this.inclusive)continue;n=!1;break}if("property"===r.type){const{name:t,value:o}=r;if(!o.test(e)){if(this.inclusive)continue;n=!1;break}let a=!1;for(let e=0;e<i.length;e++){const n=i[e],r=s[e];if(o.test(n)&&t.test(r)){a=!0;break}}if(a)n=!0;else if(!this.inclusive){n=!1;break}}if("operator"===r.type){const{name:e,value:t,operator:o}=r;let a=!1;for(let n=0;n<i.length;n++){const r=s[n],c=i[n].replace(/IFCLENGTHMEASURE\(|IFCVOLUMEMEASURE\(|\)/g,"");if(e.test(r)){if("="===o&&parseFloat(c)===t){a=!0;break}if("<"===o&&parseFloat(c)<t){a=!0;break}if(">"===o&&parseFloat(c)>t){a=!0;break}if(">="===o&&parseFloat(c)>=t){a=!0;break}if("<="===o&&parseFloat(c)<=t){a=!0;break}}}if(a)n=!0;else if(!this.inclusive){n=!1;break}}}else{if(null===t&&(t=this.getCategoryFromLine(e),null===t)){if(this.inclusive)continue;break}if(!r.value.test(t)){if(this.inclusive)continue;n=!1;break}n=!0}return n}getCategoryFromLine(e){const t=e.indexOf("=")+1,i=e.indexOf("("),s=e.slice(t,i).trim(),n=kr[s];return n||null}getAttributesFromLine(e){const t=e.match(/\((.*)\)/);if(!t||!t[1])return null;return t[1].split(/,(?![^()]*\))/g).map((e=>e.trim()))}};t(za,"importers",new Map);let ka=za;class Ha{constructor(e){t(this,"list",new Map),t(this,"id",i.MathUtils.generateUUID()),t(this,"mode","intersect"),t(this,"_components"),this._components=e}get queries(){return new Set(this.list.values())}get items(){const e=[];for(const t of this.queries)e.push(t.items);return"combine"===this.mode?M.FragmentUtils.combine(e):M.FragmentUtils.intersect(e)}add(e){if(this.list.has(e.name))throw new Error(`This group already has a query with the name ${e.name}.`);this.list.set(e.name,e)}clear(e){for(const t of this.queries)t.clear(e)}import(e){this.mode=e.mode,this.id=e.id;for(const t in e.queries){const i=ka.import(this._components,e.queries[t]);i&&this.list.set(t,i)}}export(){const e={};for(const[t,i]of this.list)e[t]=i.export();return{mode:this.mode,id:this.id,queries:e}}async update(e,t){for(const i of this.queries){const s=i.needsUpdate.get(e);(void 0===s||s)&&await i.update(e,t)}}}const Wa=class e extends ka{constructor(e,i){super(e),t(this,"name"),this.name=i.name,this.rules=i.rules,this.inclusive=i.inclusive}get items(){const e=this.components.get(co),t=[];for(const i in this.ids){const s=this.ids[i],n=e.groups.get(i);if(!n){console.warn(`Model ${i} not found!`);continue}const r=n.getFragmentMap(s);t.push(r)}return M.FragmentUtils.combine(t)}export(){const t=this.getData();return t.type=e.type,t}async update(e,t){this.ids[e]=new Set,await this.findInFile(e,t),this.needsUpdate.set(e,!1)}findInLines(e,t){for(const i of t){if(this.testRules(i)){const t=this.getIdFromLine(i);this.addID(e,t)}}}};t(Wa,"type","IfcBasicQuery");let Xa=Wa;ka.importers.set(Xa.type,((e,t)=>{const i=new Xa(e,{name:t.name,rules:ka.importRules(t.rules),inclusive:t.inclusive});return i.ids=ka.importIds(t),i}));const Za=class e extends ka{constructor(e,i){super(e),t(this,"name"),t(this,"psets",[]),this.name=i.name,this.rules=i.rules,this.inclusive=i.inclusive}get items(){const e=this.components.get(oo),t=this.components.get(co),i=[];for(const s in this.ids){const n=t.groups.get(s);if(!n){console.log(`Model not found: ${s}.`);continue}const r=this.ids[s];for(const t of r){const r=e.getEntityRelations(s,t,"DefinesOcurrence");if(r){const e=n.getFragmentMap(r);i.push(e)}}}return M.FragmentUtils.combine(i)}export(){const t=this.getData();return t.type=e.type,t}async update(e,t){await this.findInFile(e,t);const i=new Set;for(const t of this.psets){const s=this.getAttributesFromLine(t);if(null===s)continue;const n=s[4].replace("(","[").replace(")","]").replace(/#/g,""),r=JSON.parse(n);for(const s of r){const n=this.ids[e];if(n&&n.has(s)){const e=this.getIdFromLine(t);i.add(e);break}}}this.ids[e]=i,this.psets=[],this.needsUpdate.set(e,!1)}findInLines(e,t){for(const i of t){const t=this.getCategoryFromLine(i);if("IfcPropertySet"===t){this.psets.push(i);continue}if("IfcPropertySingleValue"!==t)continue;if(this.testRules(i)){const t=this.getIdFromLine(i);this.addID(e,t)}}}};t(Za,"type","IfcPropertyQuery");let $a=Za;ka.importers.set($a.type,((e,t)=>{const i=new $a(e,{name:t.name,inclusive:t.inclusive,rules:ka.importRules(t.rules)});return i.ids=ka.importIds(t),i}));const ja=class e extends ui{constructor(i){super(i),t(this,"enabled",!0),t(this,"list",new Map),i.add(e.uuid,this)}get queries(){const e=new Set;for(const[,t]of this.list)for(const i of t.queries)e.add(i);return e}import(e){for(const t in e){const i=new Ha(this.components);i.import(e[t]),this.list.set(t,i)}}export(){const e={};for(const[t,i]of this.list)e[t]=i.export();return e}create(){const e=new Ha(this.components);return this.list.set(e.id,e),e}delete(e){this.list.delete(e)}clear(){this.list.clear()}};t(ja,"uuid","0da7ad77-f734-42ca-942f-a074adfd1e3a");let qa=ja;const Qa=class e extends ui{constructor(i){super(i),t(this,"enabled",!0),t(this,"list",{}),t(this,"onDisposed",new ci),t(this,"onFragmentsDisposed",(e=>{const{groupID:t,fragmentIDs:i}=e;for(const e in this.list){const s=this.list[e],n=Object.keys(s);if(n.includes(t))delete s[t],0===Object.values(s).length&&delete this.list[e];else for(const e of n){const t=s[e];for(const e of i)delete t.map[e];0===Object.values(t).length&&delete s[e]}}})),i.add(e.uuid,this);i.get(co).onFragmentsDisposed.add(this.onFragmentsDisposed)}dispose(){this.list={};this.components.get(co).onFragmentsDisposed.remove(this.onFragmentsDisposed),this.onDisposed.trigger(),this.onDisposed.reset()}remove(e){for(const t in this.list){const i=this.list[t];for(const t in i){delete i[t].map[e]}}}find(e){const t=this.components.get(co);if(!e){const e={};for(const[i,s]of t.list)e[i]=new Set(s.ids);return e}const i=Object.keys(e).length,s={};for(const t in e){const i=e[t];if(this.list[t])for(const e of i){const i=this.list[t][e];if(i)for(const e in i.map){s[e]||(s[e]=new Map);for(const t of i.map[e]){const i=s[e].get(t);void 0===i?s[e].set(t,1):s[e].set(t,i+1)}}}else console.warn(`Classification ${t} does not exist.`)}const n={};for(const e in s){const t=s[e];for(const[s,r]of t){if(void 0===r)throw new Error("Malformed fragments map!");r===i&&(n[e]||(n[e]=new Set),n[e].add(s))}}return n}byModel(e,t){this.list.models||(this.list.models={});const i=this.list.models;i[e]||(i[e]={map:{},id:null,name:e});const s=i[e];for(const[e,i]of t.data){const n=i[0];for(const i of n){const n=t.keyFragments.get(i);n&&(s.map[n]||(s.map[n]=new Set),s.map[n].add(e))}}}async byPredefinedType(e){var t;this.list.predefinedTypes||(this.list.predefinedTypes={});const i=this.list.predefinedTypes,s=e.getAllPropertiesIDs();for(const n of s){const s=await e.getProperties(n);if(!s)continue;const r=String(null==(t=s.PredefinedType)?void 0:t.value).toUpperCase();i[r]||(i[r]={map:{},id:null,name:r});const o=i[r];for(const[t,i]of e.data){const t=i[0];for(const i of t){const t=e.keyFragments.get(i);if(!t)throw new Error("Fragment ID not found!");o.map[t]||(o.map[t]=new Set);o.map[t].add(s.expressID)}}}}byEntity(e){this.list.entities||(this.list.entities={});for(const[t,i]of e.data){const s=i[1][1],n=Gr[s];this.saveItem(e,"entities",n,t)}}async byIfcRel(e,t,i){zr.isRel(t)&&await zr.getRelationMap(e,t,(async(t,s)=>{const{name:n}=await zr.getEntityName(e,t);for(const t of s)this.saveItem(e,i,n??"NO REL NAME",t)}))}async bySpatialStructure(e,t={}){var i,s;const n=this.components.get(oo),r=n.relationMaps[e.uuid];if(!r)throw new Error(`Classifier: model relations of ${e.name||e.uuid} have to exists to group by spatial structure.`);const o=t.systemName??"spatialStructures",a=void 0===t.useProperties||t.useProperties;for(const[c]of r){if(t.isolate){const i=e.data.get(c);if(!i)continue;const s=i[1][1];if(void 0===s||!t.isolate.has(s))continue}const r=n.getEntityRelations(e,c,"Decomposes");if(r)for(const t of r){let s=t.toString();if(a){const n=await e.getProperties(t);if(!n)continue;s=null==(i=n.Name)?void 0:i.value}this.saveItem(e,o,s,c,t)}const l=n.getEntityRelations(e,c,"ContainsElements");if(!l)continue;let h=c.toString();if(a){const t=await e.getProperties(c);if(!t)continue;h=null==(s=t.Name)?void 0:s.value}for(const t of l){this.saveItem(e,o,h,t,c);const i=n.getEntityRelations(e,Number(t),"IsDecomposedBy");if(i)for(const t of i)this.saveItem(e,o,h,t,c)}}}setColor(e,t,i=!1){const s=this.components.get(co);for(const n in e){const r=s.list.get(n);if(!r)continue;const o=e[n];r.setColor(t,o,i)}}resetColor(e){const t=this.components.get(co);for(const i in e){const s=t.list.get(i);if(!s)continue;const n=e[i];s.resetColor(n)}}export(){const e={};for(const t in this.list){e[t]={};const i=this.list[t];for(const s in i){const n=i[s];e[t][s]={map:M.FragmentUtils.export(n.map),name:n.name,id:n.id}}}return e}import(e){for(const t in e){this.list[t]||(this.list[t]={});const i=e[t];for(const e in i){const s=i[e];this.list[t][e]={map:M.FragmentUtils.import(s.map),name:s.name,id:s.id}}}}saveItem(e,t,i,s,n=null){this.list[t]||(this.list[t]={});const r=e.data.get(s);if(r)for(const o of r[0]){const r=e.keyFragments.get(o);if(r){const e=this.list[t];e[i]||(e[i]={map:{},id:n,name:i}),e[i].map[r]||(e[i].map[r]=new Set),e[i].map[r].add(s)}}}};t(Qa,"uuid","e25a7f3c-46c4-4a14-9d3d-5115f24ebeb7");let Ka=Qa;const Ja=class e extends ui{constructor(i){super(i),t(this,"onDisposed",new ci),t(this,"enabled",!0),t(this,"height",10),t(this,"groupName","spatialStructures"),t(this,"list",new Set),i.add(e.uuid,this)}dispose(){this.list.clear(),this.onDisposed.trigger(),this.onDisposed.reset()}set(e){if(!this.enabled)return;const t=this.components.get(Ka),s=this.components.get(co),n=e?1:-1;let r=0;const o=t.list[this.groupName],a=new i.Matrix4;for(const t in o){a.elements[13]=r*n*this.height;for(const i in o[t].map){const n=s.list.get(i),r=t+i,c=this.list.has(r);if(!n||e&&c||!e&&!c)continue;e?this.list.add(r):this.list.delete(r);const l=o[t].map[i];n.applyTransform(l,a),n.mesh.computeBoundingSphere(),n.mesh.computeBoundingBox()}r++}}};t(Ja,"uuid","d260618b-ce88-4c7d-826c-6debb91de3e2");let ec=Ja;const tc=class e extends ui{constructor(i){super(i),t(this,"enabled",!0),this.components.add(e.uuid,this)}set(e,t){const i=this.components.get(co);if(t)for(const s in t){const n=t[s],r=i.list.get(s);r&&(r.setVisibility(e,n),this.updateCulledVisibility(r))}else for(const[t,s]of i.list)s&&(s.setVisibility(e),this.updateCulledVisibility(s))}isolate(e){this.set(!1),this.set(!0,e)}updateCulledVisibility(e){const t=this.components.get(Vn);for(const[i,s]of t.list){const t=s.colorMeshes.get(e.id);t&&(t.count=e.mesh.count)}}};t(tc,"uuid","dd9ccf2d-8a21-4821-b7f6-2949add16a29");let ic=tc;class sc extends Xr{constructor(){super(...arguments),t(this,"minGeometrySize",10),t(this,"minAssetsSize",1e3),t(this,"maxTriangles",null)}}const nc=class e extends ui{constructor(i){super(i),t(this,"onGeometryStreamed",new li),t(this,"onAssetStreamed",new li),t(this,"onProgress",new li),t(this,"onIfcLoaded",new li),t(this,"onDisposed",new ci),t(this,"settings",new sc),t(this,"enabled",!0),t(this,"webIfc",new x.IfcAPI),t(this,"_nextAvailableID",0),t(this,"_splittedGeometries",new Map),t(this,"_spatialTree",new Wr),t(this,"_metaData",new $r),t(this,"_visitedGeometries",new Map),t(this,"_streamSerializer",new M.StreamSerializer),t(this,"_geometries",new Map),t(this,"_geometryCount",0),t(this,"_civil",new Zr),t(this,"_groupSerializer",new M.Serializer),t(this,"_assets",[]),t(this,"_meshesWithHoles",new Set),this.components.add(e.uuid,this),this.settings.excludedCategories.add(x.IFCOPENINGELEMENT)}dispose(){this.onIfcLoaded.reset(),this.onGeometryStreamed.reset(),this.onAssetStreamed.reset(),this.webIfc=null,this.onDisposed.trigger(),this.onDisposed.reset()}async streamFromBuffer(e){await this.readIfcFile(e),await this.streamAllGeometries(),this.cleanUp()}async streamFromCallBack(e){await this.streamIfcFile(e),await this.streamAllGeometries(),this.cleanUp()}async readIfcFile(e){const{path:t,absolute:i,logLevel:s}=this.settings.wasm;this.webIfc.SetWasmPath(t,i),await this.webIfc.Init(),s&&this.webIfc.SetLogLevel(s),this.webIfc.OpenModel(e,this.settings.webIfc),this._nextAvailableID=this.webIfc.GetMaxExpressID(0)}async streamIfcFile(e){const{path:t,absolute:i,logLevel:s}=this.settings.wasm;this.webIfc.SetWasmPath(t,i),await this.webIfc.Init(),s&&this.webIfc.SetLogLevel(s),this.webIfc.OpenModelFromCallback(e,this.settings.webIfc),this._nextAvailableID=this.webIfc.GetMaxExpressID(0)}async streamAllGeometries(){console.log("Converting geometries to tiles...");const{minGeometrySize:e,minAssetsSize:t}=this.settings;this._spatialTree.setUp(this.webIfc);const i=this.webIfc.GetIfcEntityList(0),s=[[]],n=new M.FragmentsGroup;n.ifcMetadata={name:"",description:"",...this._metaData.getNameInfo(this.webIfc),...this._metaData.getDescriptionInfo(this.webIfc),schema:this.webIfc.GetModelSchema(0)||"IFC2X3",maxExpressID:this.webIfc.GetMaxExpressID(0)};let r=0,o=0;for(const t of i){if(!this.webIfc.IsIfcElement(t)&&t!==x.IFCSPACE)continue;if(this.settings.excludedCategories.has(t))continue;const i=this.webIfc.GetLineIDsWithType(0,t),a=i.size();for(let c=0;c<a;c++){r>e&&(r=0,o++,s.push([]));const a=i.get(c);s[o].push(a);const l=this.webIfc.GetLine(0,a);if(l.GlobalId){const e=(null==l?void 0:l.GlobalId.value)||(null==l?void 0:l.GlobalId);n.globalToExpressIDs.set(e,a)}const h=this._spatialTree.itemsByFloor[a]||0;n.data.set(a,[[],[h,t]]),r++}}this._spatialTree.cleanUp();let a=.01,c=0;for(const e of s){c++,this.webIfc.StreamMeshes(0,e,(e=>{this.getMesh(this.webIfc,e,n)})),this._geometryCount>this.settings.minGeometrySize&&await this.streamGeometries(),this._assets.length>t&&await this.streamAssets();const i=c/s.length;i>a&&(a+=.01,a=Math.max(a,i),await this.onProgress.trigger(Math.round(100*a)/100))}this._geometryCount&&await this.streamGeometries(),this._assets.length&&await this.streamAssets();const{opaque:l,transparent:h}=n.geometryIDs;for(const[e,{index:t,uuid:i}]of this._visitedGeometries){n.keyFragments.set(t,i);(e>1?l:h).set(e,t)}jr.get(n,this.webIfc);const u=this.webIfc.GetCoordinationMatrix(0);n.coordinationMatrix.fromArray(u),n.civilData=this._civil.read(this.webIfc);const I=this._groupSerializer.export(n);await this.onIfcLoaded.trigger(I),n.dispose(!0)}cleanUp(){try{this.webIfc.Dispose()}catch(e){}this.webIfc=null,this.webIfc=new x.IfcAPI,this._visitedGeometries.clear(),this._geometries.clear(),this._assets=[],this._meshesWithHoles.clear()}getMesh(e,t,i){const s=t.geometries.size(),n=t.expressID,r={id:n,geometries:[]};for(let o=0;o<s;o++){const s=t.geometries.get(o),a=s.geometryExpressID,c=1===s.color.w,l=a*(c?1:-1);this._visitedGeometries.has(l)||this.getGeometry(e,a,c),this.registerGeometryData(i,n,s,r,a,l);const h=this._splittedGeometries.get(a);if(h)for(const e of h)this.registerGeometryData(i,n,s,r,e,e)}this._assets.push(r)}getGeometry(e,t,s){const n=e.GetGeometry(0,t),r=e.GetIndexArray(n.GetIndexData(),n.GetIndexDataSize()),o=e.GetVertexArray(n.GetVertexData(),n.GetVertexDataSize()),a=new Float32Array(o.length/2),c=new Float32Array(o.length/2);for(let e=0;e<o.length;e+=6)a[e/2]=o[e],a[e/2+1]=o[e+1],a[e/2+2]=o[e+2],c[e/2]=o[e+3],c[e/2+1]=o[e+4],c[e/2+2]=o[e+5];const l=s?1:-1;if(0===r.length){const e=new Float32Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1]);this._geometries.set(t,{position:a,normal:c,index:r,boundingBox:e,hasHoles:!1});const s=this._visitedGeometries.size,o=i.MathUtils.generateUUID(),h=t*l;return this._visitedGeometries.set(h,{uuid:o,index:s}),this._geometryCount++,void n.delete()}const h=3*(this.settings.maxTriangles||r.length/3);let u=!0;for(let e=0;e<r.length;e+=h){const s=r.length-e,n=e+Math.min(s,h),o=[],I=[],d=[];let E=0;for(let t=e;t<n;t++){o.push(E++);const e=r[t];I.push(a[3*e]),I.push(a[3*e+1]),I.push(a[3*e+2]),d.push(c[3*e]),d.push(c[3*e+1]),d.push(c[3*e+2])}const f=new Uint32Array(o),p=new Float32Array(I),C=new Float32Array(d),T=Vi(p),m=new Float32Array(T.transformation.elements),R=!1,g=u?t:this._nextAvailableID++;if(this._geometries.set(g,{position:p,normal:C,index:f,boundingBox:m,hasHoles:R}),!u){this._splittedGeometries.has(t)||this._splittedGeometries.set(t,new Set);this._splittedGeometries.get(t).add(g)}const A=this._visitedGeometries.size,F=i.MathUtils.generateUUID(),S=g*l;this._visitedGeometries.set(S,{uuid:F,index:A}),this._geometryCount++,u=!1}n.delete()}async streamAssets(){await this.onAssetStreamed.trigger(this._assets),this._assets=null,this._assets=[]}async streamGeometries(){const e=new Map;for(const[t,i]of this._geometries)e.set(t,i),e.size>this.settings.minGeometrySize&&await this.outputGeometries(e);await this.outputGeometries(e),this._geometries.clear(),this._geometryCount=0}async outputGeometries(e){let t=this._streamSerializer.export(e),i={};for(const[t,{boundingBox:s,hasHoles:n}]of e)i[t]={boundingBox:s,hasHoles:n};await this.onGeometryStreamed.trigger({data:i,buffer:t}),i=null,t=null,e.clear()}registerGeometryData(e,t,i,s,n,r){const o=this._visitedGeometries.get(r);if(void 0===o)throw new Error("Error getting geometry data for streaming!");const a=e.data.get(t);if(!a)throw new Error("Data not found!");a[0].push(o.index);const{x:c,y:l,z:h,w:u}=i.color,I=[c,l,h,u],d=i.flatTransformation;s.geometries.push({color:I,geometryID:n,transformation:d})}};t(nc,"uuid","d9999a00-e1f5-4d3f-8cfe-c56e08609764");let rc=nc;class oc extends Xr{constructor(){super(...arguments),t(this,"propertiesSize",100)}}class ac extends ui{constructor(){super(...arguments),t(this,"onPropertiesStreamed",new li),t(this,"onProgress",new li),t(this,"onIndicesStreamed",new li),t(this,"onDisposed",new ci),t(this,"enabled",!0),t(this,"settings",new oc),t(this,"webIfc",new x.IfcAPI)}async dispose(){this.onIndicesStreamed.reset(),this.onPropertiesStreamed.reset(),this.webIfc=null,this.onDisposed.reset()}async streamFromBuffer(e){await this.readIfcFile(e),await this.streamAllProperties(),this.cleanUp()}async streamFromCallBack(e){await this.streamIfcFile(e),await this.streamAllProperties(),this.cleanUp()}async readIfcFile(e){const{path:t,absolute:i,logLevel:s}=this.settings.wasm;this.webIfc.SetWasmPath(t,i),await this.webIfc.Init(),s&&this.webIfc.SetLogLevel(s),this.webIfc.OpenModel(e,this.settings.webIfc)}async streamIfcFile(e){const{path:t,absolute:i,logLevel:s}=this.settings.wasm;this.webIfc.SetWasmPath(t,i),await this.webIfc.Init(),s&&this.webIfc.SetLogLevel(s),this.webIfc.OpenModelFromCallback(e,this.settings.webIfc)}async streamAllProperties(){const{propertiesSize:e}=this.settings,t=new Set(this.webIfc.GetIfcEntityList(0)),i=new Set([x.IFCPROJECT,x.IFCSITE,x.IFCBUILDING,x.IFCBUILDINGSTOREY,x.IFCSPACE]);for(const e of i)t.add(e);let s=.01,n=0;for(const r of t){if(n++,qr.has(r))continue;const o=i.has(r),a=this.webIfc.GetLineIDsWithType(0,r),c=a.size();let l=0;for(let t=0;t<c-e;t+=e){const i={};for(let s=0;s<e;s++){l++;const e=a.get(t+s);try{const t=this.webIfc.GetLine(0,e,o);i[t.expressID]=t}catch(t){console.log(`Could not get property: ${e}`)}}await this.onPropertiesStreamed.trigger({type:r,data:i})}if(l!==c){const e={};for(let t=l;t<c;t++){const i=a.get(t);try{const t=this.webIfc.GetLine(0,i,o);e[t.expressID]=t}catch(e){console.log(`Could not get property: ${i}`)}}await this.onPropertiesStreamed.trigger({type:r,data:e})}n/t.size>s&&(s=Math.round(100*s)/100,await this.onProgress.trigger(s),s+=.01)}await this.onProgress.trigger(1);const r=this.components.get(oo),o=await r.processFromWebIfc(this.webIfc,0);await this.onIndicesStreamed.trigger(o)}cleanUp(){this.webIfc.Dispose(),this.webIfc=null,this.webIfc=new x.IfcAPI}}t(ac,"uuid","88d2c89c-ce32-47d7-8cb6-d51e4b311a0b");class cc{constructor(e,i,s){t(this,"title"),t(this,"guid",ki.create()),t(this,"clippingPlanes",new Ti),t(this,"camera",{aspectRatio:1,fov:60,direction:{x:0,y:0,z:0},position:{x:0,y:0,z:0}}),t(this,"exceptionComponents",new Ti),t(this,"selectionComponents",new Ti),t(this,"componentColors",new mi),t(this,"spacesVisible",!1),t(this,"spaceBoundariesVisible",!1),t(this,"openingsVisible",!1),t(this,"defaultVisibility",!0),t(this,"_components"),t(this,"world");const n={setCamera:!0,...s},{data:r,setCamera:o}=n;this._components=e,this.world=i,r&&(this.guid=r.guid??this.guid,this.set(r)),o&&this.updateCamera()}get _selectionModelIdMap(){const e=this._components.get(co),t={};for(const[i,s]of e.groups){i in t||(t[i]=new Set);for(const e of this.selectionComponents){const n=s.globalToExpressIDs.get(e);n&&t[i].add(n)}}return t}get _exceptionModelIdMap(){const e=this._components.get(co),t={};for(const[i,s]of e.groups){i in t||(t[i]=new Set);for(const e of this.exceptionComponents){const n=s.globalToExpressIDs.get(e);n&&t[i].add(n)}}return t}get selection(){return this._components.get(co).modelIdToFragmentIdMap(this._selectionModelIdMap)}get exception(){return this._components.get(co).modelIdToFragmentIdMap(this._exceptionModelIdMap)}get projection(){return"fov"in this.camera?"Perspective":"Orthographic"}get position(){const e=this._components.get(co),{position:t}=this.camera,{x:s,y:n,z:r}=t,o=new i.Vector3(s,n,r);return e.applyBaseCoordinateSystem(o,new i.Matrix4),o}get direction(){const{direction:e}=this.camera,{x:t,y:s,z:n}=e;return new i.Vector3(t,s,n)}get _managerVersion(){return this._components.get(Ua).config.version}get topics(){return[...this._components.get(Ua).list.values()].filter((e=>e.viewpoints.has(this.guid)))}addComponentsFromMap(e){const t=this._components.get(co).fragmentIdMapToGuids(e);this.selectionComponents.add(...t);this._components.get(uc).list.set(this.guid,this)}set(e){const t=e,i=this;for(const s in e){if("guid"===s)continue;const e=t[s];"selectionComponents"!==s?"exceptionComponents"!==s?s in this&&(i[s]=e):(this.exceptionComponents.clear(),this.exceptionComponents.add(...e)):(this.selectionComponents.clear(),this.selectionComponents.add(...e))}return this._components.get(uc).list.set(this.guid,this),this}async go(e,t=!0){const{camera:s}=e??this.world;if(!s.hasCameraControls())throw new Error("Viewpoint: the world's camera need controls to set the viewpoint.");s instanceof Ur&&s.projection.set(this.projection);const n=new i.Vector3(this.camera.position.x,this.camera.position.y,this.camera.position.z),r=new i.Vector3(this.camera.direction.x,this.camera.direction.y,this.camera.direction.z);if(n.equals(new i.Vector3)&&r.equals(new i.Vector3))return;const o=this.position,a=this.direction;let c={x:o.x+80*a.x,y:o.y+80*a.y,z:o.z+80*a.z};const l=this.selection;if(0===Object.keys(l).length){const e=this._components.get(Wn).get(this.world).castRayFromVector(o,this.direction);e&&(c=e.point)}else{const e=this._components.get(Va);e.reset(),e.addFragmentIdMap(l),c=e.getSphere().center,e.reset()}await s.controls.setLookAt(o.x,o.y,o.z,c.x,c.y,c.z,t)}updateCamera(e){const{camera:t,renderer:s}=e??this.world;if(!s)throw new Error("Viewpoint: the world needs to have a renderer!");if(!t.hasCameraControls())throw new Error("Viewpoint: world's camera need camera controls!");const n=new i.Vector3;t.controls.getPosition(n);const r=t.three,o=new i.Vector3(0,0,-1).applyEuler(r.rotation),{width:a,height:c}=s.getSize();let l=a/c;Number.isNaN(l)&&(l=1);const h=this._components.get(co);n.applyMatrix4(h.baseCoordinationMatrix.clone().invert());const u={aspectRatio:l,position:{x:n.x,y:n.y,z:n.z},direction:{x:o.x,y:o.y,z:o.z}};r instanceof i.PerspectiveCamera?this.camera={...u,fov:r.fov}:r instanceof i.OrthographicCamera&&(this.camera={...u,viewToWorldScale:r.top-r.bottom});this._components.get(uc).list.set(this.guid,this)}applyVisibility(){const e=this._components.get(ic);e.set(this.defaultVisibility),e.set(!this.defaultVisibility,this.exception),e.set(!0,this.selection)}applyColors(){const e=this._components.get(uc),t=this._components.get(co),i=this._components.get(Ka);for(const[s,n]of this.componentColors){const r=t.guidToFragmentIdMap(n);i.setColor(r,s,e.config.overwriteColors)}}resetColors(){const e=this._components.get(co),t=this._components.get(Ka);for(const[i,s]of this.componentColors){const i=e.guidToFragmentIdMap(s);t.resetColor(i)}}async createComponentTags(e){var t,i;const s=this._components.get(co);let n="";if(this._components.get(Ua).config.includeSelectionTag){const r="selection"===e?this._selectionModelIdMap:this._exceptionModelIdMap;for(const e in r){const o=s.groups.get(e);if(!o)continue;const a=r[e];for(const e of a){const s=await o.getProperties(e);if(!s)continue;const r=null==(t=s.GlobalId)?void 0:t.value;if(!r)continue;const a=null==(i=s.Tag)?void 0:i.value;let c=null;a&&(c=`AuthoringToolId="${a}"`),n+=`\n<Component IfcGuid="${r}" ${c??""} />`}}}else n=[...this.selectionComponents].map((e=>`<Component IfcGuid="${e}" />`)).join("\n");return n}createColorTags(){let e="";for(const[t,i]of this.componentColors.entries()){e+=`<Color Color="${`#${t.getHexString()}`}">\n${i.map((e=>`\n<Component IfcGuid="${e}" />`)).join("\n")}\n</Color>`}return 0!==e.length?`<Coloring>\n${e}\n</Coloring>`:"<Coloring />"}async serialize(e=this._managerVersion){const t=this._components.get(co),s=this.position;s.applyMatrix4(t.baseCoordinationMatrix.clone().invert());const n=this.direction;n.normalize();const r=(new i.Matrix4).makeRotationX(Math.PI/2),o=n.clone().applyMatrix4(r);o.normalize();const a=`<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>`,l=`<CameraUpVector>\n <X>${o.x}</X>\n <Y>${-o.z}</Y>\n <Z>${o.y}</Z>\n </CameraUpVector>`,h=`<AspectRatio>${this.camera.aspectRatio}</AspectRatio>`;let u="";"viewToWorld"in this.camera?u=`<OrthogonalCamera>\n ${a}\n ${c}\n ${l}\n ${h}\n <ViewToWorldScale>${this.camera.viewToWorld}</ViewToWorldScale>\n </OrthogonalCamera>`:"fov"in this.camera&&(u=`<PerspectiveCamera>\n ${a}\n ${c}\n ${l}\n ${h}\n <FieldOfView>${this.camera.fov}</FieldOfView>\n </PerspectiveCamera>`);const I=`<ViewSetupHints SpacesVisible="${this.spacesVisible??!1}" SpaceBoundariesVisible="${this.spaceBoundariesVisible??!1}" OpeningsVisible="${this.openingsVisible??!1}" />`,d=(await this.createComponentTags("selection")).trim(),E=(await this.createComponentTags("exception")).trim(),f=this.createColorTags();return`<?xml version="1.0" encoding="UTF-8"?>\n <VisualizationInfo Guid="${this.guid}">\n <Components>\n ${"2.1"===e?I:""}\n ${0!==d.length?`<Selection>${d}</Selection>`:""}\n <Visibility DefaultVisibility="${this.defaultVisibility}">\n ${"3"===e?I:""}\n ${0!==E.length?`<Exceptions>${E}</Exceptions>`:""}\n </Visibility>\n ${f}\n </Components>\n ${u}\n </VisualizationInfo>`}}class lc extends Os{constructor(){super(...arguments),t(this,"_config",{overwriteColors:{value:!1,type:"Boolean"}})}get overwriteColors(){return this._config.overwriteColors.value}set overwriteColors(e){this._config.overwriteColors.value=e}}const hc=class e extends ui{constructor(i){super(i),t(this,"enabled",!0),t(this,"list",new mi),t(this,"isSetup",!1),t(this,"onSetup",new ci),t(this,"config",new lc(this,this.components,"Viewpoints",e.uuid)),t(this,"onDisposed",new ci),i.add(e.uuid,this)}create(e,t){const i=new cc(this.components,e,{data:t});return t||this.list.set(i.guid,i),i}setup(){}dispose(){this.list.dispose(),this.onDisposed.trigger(),this.onDisposed.reset()}};t(hc,"uuid","ee867824-a796-408d-8aa0-4e5962a83c66");let uc=hc;class Ic extends Os{constructor(){super(...arguments),t(this,"_config",{visible:{value:!0,type:"Boolean"},lockRotation:{value:!0,type:"Boolean"},zoom:{type:"Number",interpolable:!0,value:.05,min:.001,max:5},frontOffset:{type:"Number",interpolable:!0,value:0,min:0,max:100},sizeX:{type:"Number",interpolable:!0,value:320,min:20,max:5e3},sizeY:{type:"Number",interpolable:!0,value:160,min:20,max:5e3},backgroundColor:{value:new i.Color,type:"Color"}})}get visible(){return this._config.visible.value}set visible(e){this._config.visible.value=e;this._component.renderer.domElement.style.display=e?"block":"none"}get lockRotation(){return this._config.lockRotation.value}set lockRotation(e){this._config.lockRotation.value=e,this._component.lockRotation=e}get zoom(){return this._config.zoom.value}set zoom(e){this._config.zoom.value=e,this._component.zoom=e}get frontOffset(){return this._config.frontOffset.value}set frontOffset(e){this._config.frontOffset.value=e,this._component.frontOffset=e}get sizeX(){return this._config.sizeX.value}set sizeX(e){this._config.sizeX.value=e;const{sizeX:t,sizeY:s}=this._config,n=new i.Vector2(t.value,s.value);this._component.resize(n)}get sizeY(){return this._config.sizeY.value}set sizeY(e){this._config.sizeY.value=e;const{sizeX:t,sizeY:s}=this._config,n=new i.Vector2(t.value,s.value);this._component.resize(n)}get backgroundColor(){return this._config.backgroundColor.value}set backgroundColor(e){this._config.backgroundColor.value=e,this._component.backgroundColor=e}}class dc{constructor(e,s){if(t(this,"onDisposed",new ci),t(this,"onAfterUpdate",new ci),t(this,"onBeforeUpdate",new ci),t(this,"onResize",new ci),t(this,"onSetup",new ci),t(this,"frontOffset",0),t(this,"overrideMaterial",new i.MeshDepthMaterial),t(this,"backgroundColor",new i.Color(395274)),t(this,"renderer"),t(this,"enabled",!0),t(this,"world"),t(this,"config"),t(this,"isSetup",!1),t(this,"_defaultConfig",{visible:!0,lockRotation:!1,zoom:.05,frontOffset:0,sizeX:320,sizeY:160,backgroundColor:new i.Color(395274)}),t(this,"_lockRotation",!0),t(this,"_size",new i.Vector2(320,160)),t(this,"_camera"),t(this,"_plane"),t(this,"_tempVector1",new i.Vector3),t(this,"_tempVector2",new i.Vector3),t(this,"_tempTarget",new i.Vector3),t(this,"down",new i.Vector3(0,-1,0)),t(this,"updatePlanes",(()=>{if(!this.world.renderer)throw new Error("The given world must have a renderer!");const e=[],t=this.world.renderer.three;for(const i of t.clippingPlanes)e.push(i);e.push(this._plane),this.renderer.clippingPlanes=e})),this.world=e,!this.world.renderer)throw new Error("The given world must have a renderer!");this.renderer=new i.WebGLRenderer,this.renderer.setSize(this._size.x,this._size.y);const n=this._size.x/this._size.y;this._camera=new i.OrthographicCamera(1*n/-2,1*n/2,.5,-.5),this.world.renderer.onClippingPlanesUpdated.add(this.updatePlanes),this._camera.position.set(0,200,0),this._camera.zoom=.1,this._camera.rotation.x=-Math.PI/2,this._plane=new i.Plane(this.down,200),this.updatePlanes(),this.config=new Ic(this,s,"MiniMap")}get lockRotation(){return this._lockRotation}set lockRotation(e){this._lockRotation=e,e&&(this._camera.rotation.z=0)}get zoom(){return this._camera.zoom}set zoom(e){this._camera.zoom=e,this._camera.updateProjectionMatrix()}dispose(){this.enabled=!1,this.onBeforeUpdate.reset(),this.onAfterUpdate.reset(),this.onResize.reset(),this.overrideMaterial.dispose(),this.renderer.forceContextLoss(),this.renderer.dispose(),this.onDisposed.trigger(),this.onDisposed.reset()}get(){return this._camera}update(){if(!this.enabled)return;this.onBeforeUpdate.trigger();const e=this.world.scene.three,t=this.world.camera;if(!t.hasCameraControls())throw new Error("The given world must use camera controls!");if(!(e instanceof i.Scene))throw new Error("The given world must have a THREE.Scene as a root!");const s=t.controls;if(s.getPosition(this._tempVector1),this._camera.position.x=this._tempVector1.x,this._camera.position.z=this._tempVector1.z,0!==this.frontOffset&&(s.getTarget(this._tempVector2),this._tempVector2.sub(this._tempVector1),this._tempVector2.normalize().multiplyScalar(this.frontOffset),this._camera.position.x+=this._tempVector2.x,this._camera.position.z+=this._tempVector2.z),!this._lockRotation){s.getTarget(this._tempTarget);const e=Math.atan2(this._tempTarget.x-this._tempVector1.x,this._tempTarget.z-this._tempVector1.z);this._camera.rotation.z=e+Math.PI}this._plane.set(this.down,this._tempVector1.y);const n=e.background;e.background=this.backgroundColor,this.renderer.render(e,this._camera),e.background=n,this.onAfterUpdate.trigger()}getSize(){return this._size}resize(e=this._size){this._size.copy(e),this.renderer.setSize(e.x,e.y);const t=e.x/e.y;this._camera.left=1*t/-2,this._camera.right=1*t/2,this._camera.top=.5,this._camera.bottom=-.5,this._camera.updateProjectionMatrix(),this.onResize.trigger(e)}setup(e){const t={...this._defaultConfig,...e};this.config.visible=!0,this.config.lockRotation=t.lockRotation,this.config.zoom=t.zoom,this.config.frontOffset=t.frontOffset,this.config.sizeX=t.sizeX,this.config.sizeY=t.sizeY,this.config.backgroundColor=t.backgroundColor,this.isSetup=!0,this.onSetup.trigger()}}const Ec=class e extends ui{constructor(i){super(i),t(this,"onAfterUpdate",new ci),t(this,"onBeforeUpdate",new ci),t(this,"onDisposed",new ci),t(this,"onSetup",new ci),t(this,"enabled",!0),t(this,"list",new Map),this.components.add(e.uuid,this)}create(e){if(this.list.has(e.uuid))throw new Error("This world already has a minimap!");const t=new dc(e,this.components);return this.list.set(e.uuid,t),t}delete(e){const t=this.list.get(e);t&&t.dispose(),this.list.delete(e)}dispose(){for(const[e,t]of this.list)t.dispose();this.list.clear(),this.onDisposed.trigger()}update(){for(const[e,t]of this.list)t.update()}};t(Ec,"uuid","39ad6aad-84c8-4adf-a1e0-7f25313a9e7f");let fc=Ec;const pc=class e extends ui{constructor(i){super(i),t(this,"enabled",!0),i.add(e.uuid,this)}static distanceFromPointToLine(e,t,s,n=!1){const r=new i.Line3,o=new i.Vector3;return r.set(t,s),r.closestPointToPoint(e,n,o),o.distanceTo(e)}getFace(e,t,i){if(!e.geometry.index)throw new Error("Geometry must be indexed!");const s=new Map,n=e.geometry.index.array,{plane:r}=this.getFaceData(t,i,e),o=[];for(let t=0;t<n.length/3;t++){const{plane:n,edges:a}=this.getFaceData(t,i,e);if(n.equals(r)){o.push({index:t,edges:a});for(const{id:e,points:t,distance:i}of a)s.set(e,{points:t,distance:i})}}let a=0;const c=new Map,l=new Map;for(const{index:e,edges:t}of o){const i=new Map;for(const{id:e}of t)if(c.has(e)){const t=c.get(e);i.set(e,t)}const s=t.map((e=>e.id));if(!i.size){const i=a++;for(const{id:e}of t)c.set(e,i);l.set(i,{edges:new Set(s),indices:new Set([e])});continue}let n=null;const r=new Set,o=new Set(s);for(const[e,t]of i){null===n?n=t:t!==n&&r.add(t),c.delete(e);const{edges:i}=l.get(t);i.delete(e),o.delete(e)}if(null===n)throw new Error("Error computing face!");const h=l.get(n),{indices:u}=h;u.add(e);for(const e of o){c.set(e,n);const{edges:t}=h;t.add(e)}for(const e of r){const t=l.get(e),{edges:i,indices:s}=t,r=l.get(n),{edges:o,indices:a}=r;for(const e of i)o.add(e),c.set(e,n);for(const e of s)a.add(e);l.delete(e)}}for(const[e,{indices:i,edges:n}]of l)if(i.has(t)){const e=[];for(const t of n){const i=s.get(t);e.push(i)}return{edges:e,indices:i}}return null}getVerticesAndNormal(e,t,s){if(!e.geometry.index)throw new Error("Geometry must be indexed!");const n=e.geometry.index.array,r=e.geometry.attributes.position.array,o=e.geometry.attributes.normal.array,a=3*n[3*t],c=3*n[3*t+1],l=3*n[3*t+2],h=new i.Vector3(r[a],r[a+1],r[a+2]),u=new i.Vector3(r[c],r[c+1],r[c+2]),I=new i.Vector3(r[l],r[l+1],r[l+2]),d=new i.Vector3(o[a],o[a+1],o[a+2]),E=new i.Vector3(o[c],o[c+1],o[c+2]),f=new i.Vector3(o[l],o[l+1],o[l+2]),p=(d.x+E.x+f.x)/3,C=(d.y+E.y+f.y)/3,T=(d.z+E.z+f.z)/3,m=new i.Vector3(p,C,T);if(void 0!==s&&e instanceof i.InstancedMesh){const t=new i.Matrix4;e.getMatrixAt(s,t);const n=new i.Matrix4;n.extractRotation(t),m.applyMatrix4(n),h.applyMatrix4(t),u.applyMatrix4(t),I.applyMatrix4(t)}return{p1:h,p2:u,p3:I,faceNormal:m}}round(e){const t=1e3;e.x=Math.trunc(e.x*t)/t,e.y=Math.trunc(e.y*t)/t,e.z=Math.trunc(e.z*t)/t}getVolumeFromFragments(e){const t=this.components.get(co),s=new i.Matrix4,n=[];for(const r in e){const o=t.list.get(r);if(!o)continue;const a=e[r];let c=0;for(const e of a){const t=o.getInstancesIDs(e);t&&(c+=t.size)}const l=new i.InstancedMesh(o.mesh.geometry,void 0,c);let h=0;for(const e of a){const t=o.getInstancesIDs(e);if(t)for(const e of t)o.mesh.getMatrixAt(e,s),l.setMatrixAt(h++,s)}n.push(l)}const r=this.getVolumeFromMeshes(n);for(const e of n)e.geometry=null,e.material=[],e.dispose();return r}getVolumeFromMeshes(e){let t=0;for(const i of e)t+=this.getVolumeOfMesh(i);return t}getFaceData(e,t,s){const n=this.getVerticesAndNormal(s,e,t),{p1:r,p2:o,p3:a,faceNormal:c}=n;this.round(r),this.round(o),this.round(a),this.round(c);const l=[{id:`${r.x}|${r.y}|${r.z}`,value:r},{id:`${o.x}|${o.y}|${o.z}`,value:o},{id:`${a.x}|${a.y}|${a.z}`,value:a}];l.sort(((e,t)=>e.id<t.id?-1:e.id>t.id?1:0));const[{id:h,value:u},{id:I,value:d},{id:E,value:f}]=l,p=[{id:`${h}|${I}`,distance:u.distanceTo(d),points:[u,d]},{id:`${I}|${E}`,distance:d.distanceTo(f),points:[d,f]},{id:`${h}|${E}`,distance:u.distanceTo(f),points:[u,f]}],C=new i.Plane;return C.setFromNormalAndCoplanarPoint(c,r),C.constant=Math.round(10*C.constant)/10,{plane:C,edges:p}}getVolumeOfMesh(e){let t=0;const s=new i.Vector3,n=new i.Vector3,r=new i.Vector3,{index:o}=e.geometry,a=e.geometry.attributes.position.array;if(!o)return console.warn("Geometry must be indexed to compute its volume!"),0;const c=[];if(e instanceof i.InstancedMesh)for(let t=0;t<e.count;t++){const s=new i.Matrix4;e.getMatrixAt(t,s),c.push(s)}else c.push((new i.Matrix4).identity());const{matrixWorld:l}=e;for(let e=0;e<o.array.length-2;e+=3)for(const i of c){const c=i.multiply(l),h=3*o.array[e],u=3*o.array[e+1],I=3*o.array[e+2];s.set(a[h],a[h+1],a[h+2]).applyMatrix4(c),n.set(a[u],a[u+1],a[u+2]).applyMatrix4(c),r.set(a[I],a[I+1],a[I+2]).applyMatrix4(c),t+=this.getSignedVolumeOfTriangle(s,n,r)}return Math.abs(t)}getSignedVolumeOfTriangle(e,t,i){return 1/6*(-(i.x*t.y*e.z)+t.x*i.y*e.z+i.x*e.y*t.z-e.x*i.y*t.z-t.x*e.y*i.z+e.x*t.y*i.z)}};t(pc,"uuid","267ca032-672f-4cb0-afa9-d24e904f39d6");let Cc=pc;class Tc{constructor(e){t(this,"cardinality","required"),t(this,"instructions"),t(this,"evalRequirement",((e,t,i,s)=>{const n={parameter:i,currentValue:e,requiredValue:t.parameter,pass:!1};s&&this.addCheckResult(n,s);let r=!1;if("simple"===t.type&&(r=e===t.parameter),"enumeration"===t.type&&(r=t.parameter.includes(e)),"pattern"===t.type){r=new RegExp(t.parameter).test(String(e))}if("length"===t.type){const{min:i,length:s,max:n}=t.parameter;void 0!==s&&(r=String(e).length===s),void 0!==i&&(r=String(e).length>=i),void 0!==n&&(r=String(e).length<=n)}if("bounds"===t.type&&"number"==typeof e){const{min:i,minInclusive:s,max:n,maxInclusive:o}=t.parameter;let a=!0,c=!0;void 0!==i&&(a=s?e>=i:e>i),void 0!==n&&(c=o?e<=n:e<n),r=a&&c}return"prohibited"===this.cardinality&&(r=!r),"optional"===this.cardinality&&(r=!0),n.pass=r,n.pass})),t(this,"testResult",[]),this.components=e}addCheckResult(e,t){const i=t.findIndex((({parameter:t})=>t===e.parameter));-1!==i?t[i]=e:t.push(e)}saveResult(e,t){const{GlobalId:i}=e;if(!i)return;const{value:s}=i,n={expressID:s,pass:t,checks:[],cardinality:this.cardinality};this.testResult.push(n)}}const mc=(e,t)=>{let i="";if(!t)return i;if("simple"===t.type&&(i=`<simpleValue>${t.parameter}</simpleValue>`),"enumeration"===t.type){i=`<xs:restriction base="xs:string">\n ${t.parameter.map((e=>`<xs:enumeration value="${e}" />`)).join("\n")}\n </xs:restriction>`}if("pattern"===t.type){i=`<xs:restriction base="xs:string">\n <xs:pattern value="${t.parameter}" />\n </xs:restriction>`}if("bounds"===t.type){const{min:e,minInclusive:s,max:n,maxInclusive:r}=t.parameter;let o="";void 0!==e&&(o=`<xs:min${s?"Inclusive":"Exclusive"} value="${e}">`);let a="";void 0!==n&&(a=`<xs:max${r?"Inclusive":"Exclusive"} value="${n}">`),i=`<xs:restriction base="xs:double">\n ${o}\n ${a}\n </xs:restriction>`}if("length"===t.type){const{length:e,min:s,max:n}=t.parameter;let r="";void 0!==e&&void 0===s&&void 0===n&&(r=`<xs:length value="${e}" />`);let o="";void 0!==s&&void 0===e&&(o=`<xs:minLength value="${s}" />`);let a="";void 0!==n&&void 0===e&&(a=`<xs:maxLength value="${n}" />`),i=`<xs:restriction base="xs:string">\n ${r}\n ${o}\n ${a}\n </xs:restriction>`}return`<${e[0].toLowerCase()+e.slice(1)}>\n ${i}\n </${e[0].toLowerCase()+e.slice(1)}>`};class Rc extends Tc{constructor(e,i){super(e),t(this,"facetType","Attribute"),t(this,"name"),t(this,"value"),this.name=i}serialize(e){const t=mc("Name",this.name),i=mc("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>`}async getEntities(){return[]}async test(e){var t;this.testResult=[];for(const i in e){const s=Number(i),n=e[s],r=[],o={guid:null==(t=n.GlobalId)?void 0:t.value,expressID:s,pass:!1,checks:r,cardinality:this.cardinality};this.testResult.push(o);const a=Object.keys(n).filter((e=>{const t=this.evalRequirement(e,this.name,"Name"),i=n[e];return t&&null===i?"optional"===this.cardinality||"prohibited"===this.cardinality:(!t||3!==(null==i?void 0:i.type)||2!==i.value)&&((!t||!Array.isArray(i)||0!==i.length)&&((!t||1!==(null==i?void 0:i.type)||""!==i.value.trim())&&t))})),c=a.length>0;if(r.push({parameter:"Name",currentValue:c?a[0]:null,requiredValue:this.name.parameter,pass:"prohibited"===this.cardinality?!c:c}),this.value)if(a[0]){const e=n[a[0]];5===(null==e?void 0:e.type)?r.push({parameter:"Value",currentValue:null,requiredValue:this.value.parameter,pass:"prohibited"===this.cardinality}):this.evalRequirement(e?e.value:null,this.value,"Value",r)}else r.push({parameter:"Value",currentValue:null,requiredValue:this.value.parameter,pass:"prohibited"===this.cardinality});o.pass=r.every((({pass:e})=>e))}const i=[...this.testResult];return this.testResult=[],i}}class gc extends Tc{constructor(e,i){super(e),t(this,"facetType","Classification"),t(this,"system"),t(this,"value"),t(this,"uri"),this.system=i}serialize(e){const t=mc("System",this.system),i=mc("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>`}async getEntities(e,t={}){var i;const s=[],n={...await e.getAllPropertiesOfType(x.IFCCLASSIFICATIONREFERENCE),...await e.getAllPropertiesOfType(x.IFCCLASSIFICATION)},r=[];for(const t in n){const s=Number(t),n=await e.getProperties(s);if(!n)continue;const o=null==(i=n.ReferencedSource)?void 0:i.value;if(!o)continue;const a=await e.getProperties(o);if(!a)continue;if(!this.evalSystem(a))continue;if(!this.evalValue(n))continue;this.evalURI(n)&&r.push(s)}const o=this.components.get(oo);for(const i of r){const n=o.getEntitiesWithRelation(e,"HasAssociations",i);for(const i of n){if(i in t)continue;const n=await e.getProperties(i);n&&(t[i]=n,s.push(i))}}return s}async test(e,t){var i;this.testResult=[];for(const s in e){const n=Number(s),r=[],o={guid:null==(i=e[n].GlobalId)?void 0:i.value,expressID:n,pass:!1,checks:r,cardinality:this.cardinality};this.testResult.push(o);let a=!0;const c=await this.getSystems(t,n),l=c.map((e=>this.getSystemName(e))).filter((e=>e));for(const e of c){if(!this.evalSystem(e,r))continue;if(a=!1,!this.value||!this.system)break;if(e.type!==x.IFCCLASSIFICATIONREFERENCE)continue;const t=!this.value||this.evalValue(e,r),i=!this.uri||this.evalURI(e,r);if(t&&i)break}a&&this.addCheckResult({parameter:"System",currentValue:l,requiredValue:this.system,pass:"optional"===this.cardinality},r),o.pass=r.every((({pass:e})=>e))}const s=[...this.testResult];return this.testResult=[],s}async processReferencedSource(e,t){var i;const s=null==(i=t.ReferencedSource)?void 0:i.value;if(!s)return null;const n=await e.getProperties(s);return n?(n.type===x.IFCCLASSIFICATIONREFERENCE&&(n.ReferencedSource=await this.processReferencedSource(e,n)),n):null}async getSystems(e,t){var i;const s=[],n=this.components.get(oo),r=n.getEntityRelations(e,t,"HasAssociations");if(r)for(const t of r){const i=await e.getProperties(t);i&&(i.type===x.IFCCLASSIFICATION&&s.push(i),i.type===x.IFCCLASSIFICATIONREFERENCE&&(i.ReferencedSource=await this.processReferencedSource(e,i),i.ReferencedSource&&s.push(i)))}const o=s.map((e=>{var t,i,s;return e.type===x.IFCCLASSIFICATION?null==(t=e.Name)?void 0:t.value:e.type===x.IFCCLASSIFICATIONREFERENCE?null==(s=null==(i=e.ReferencedSource)?void 0:i.Name)?void 0:s.value:null})).filter((e=>e)),a=n.getEntityRelations(e,t,"IsTypedBy");if(!a||!a[0])return s;const c=a[0],l=n.getEntityRelations(e,c,"HasAssociations");if(l)for(const t of l){const n=await e.getProperties(t);if(n){if(n.type===x.IFCCLASSIFICATION){if(o.includes(null==(i=n.Name)?void 0:i.value))continue;s.push(n)}n.type===x.IFCCLASSIFICATIONREFERENCE&&(n.ReferencedSource=await this.processReferencedSource(e,n),n.ReferencedSource&&s.push(n))}}return s}getSystemName(e){var t,i,s,n;if(e.type===x.IFCCLASSIFICATION)return null==(t=e.Name)?void 0:t.value;if(e.type===x.IFCCLASSIFICATIONREFERENCE){if((null==(i=e.ReferencedSource)?void 0:i.type)===x.IFCCLASSIFICATIONREFERENCE)return this.getSystemName(e.ReferencedSource);if((null==(s=e.ReferencedSource)?void 0:s.type)===x.IFCCLASSIFICATION)return null==(n=e.ReferencedSource.Name)?void 0:n.value}return null}getAllReferenceIdentifications(e){if(e.type!==x.IFCCLASSIFICATIONREFERENCE)return null;const t=[];if(e.Identification&&t.push(e.Identification.value),e.ReferencedSource){const i=this.getAllReferenceIdentifications(e.ReferencedSource);i&&t.push(...i)}return t}evalSystem(e,t){const i=this.getSystemName(e);return this.evalRequirement(i,this.system,"System",t)}evalValue(e,t){if(!this.value)return!0;const i=this.getAllReferenceIdentifications(e);if(!i)return!1;const s=i.find((e=>!!this.value&&this.evalRequirement(e,this.value,"Value")));return t&&this.addCheckResult({parameter:"Value",currentValue:s??null,requiredValue:this.value,pass:!!s},t),!!s}evalURI(e,t){var i;if(!this.uri)return!0;return this.evalRequirement(null==(i=e.Location)?void 0:i.value,{type:"simple",parameter:this.uri},"URI",t)}}class Ac extends Tc{constructor(e,i){super(e),t(this,"facetType","Entity"),t(this,"name"),t(this,"predefinedType"),this.name=i}serialize(e){const t=mc("Name",this.name),i=mc("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>`}async getEntities(e,t={}){const i=Object.entries(Gr),s=[];for(const[e]of i){await this.evalName({type:e})&&s.push(Number(e))}let n={};for(const t of s){const i=await e.getAllPropertiesOfType(t);i&&(n={...n,...i})}if(!this.predefinedType){for(const e in n)e in t||(t[e]=n[e]);return Object.keys(n).map(Number)}const r=[];for(const i in n){const s=Number(i);if(s in t)continue;const o=n[s];await this.evalPredefinedType(e,o)&&(t[s]=o,r.push(s))}return r}async test(e,t){var i;this.testResult=[];for(const s in e){const n=Number(s),r=e[n],o=[],a={guid:null==(i=r.GlobalId)?void 0:i.value,expressID:n,pass:!1,checks:o,cardinality:this.cardinality};this.testResult.push(a),await this.evalName(r,o),await this.evalPredefinedType(t,r,o),a.pass=o.every((({pass:e})=>e))}return this.testResult}async evalName(e,t){const i=Gr[e.type];return this.evalRequirement(i,this.name,"Name",t)}async evalPredefinedType(e,t,i){var s,n,r,o;if(!this.predefinedType)return null;const a=this.components.get(oo),c="string"==typeof this.predefinedType.parameter&&"USERDEFINED"===this.predefinedType.parameter;let l=null==(s=t.PredefinedType)?void 0:s.value;if("USERDEFINED"===l&&!c){const e=Object.keys(t).find((e=>/^((?!Predefined).)*Type$/.test(e)));l=e?null==(n=t[e])?void 0:n.value:"USERDEFINED"}if(!l){const i=a.getEntityRelations(e,t.expressID,"IsTypedBy");if(i&&i[0]){const t=await e.getProperties(i[0]);if(t&&(l=null==(r=t.PredefinedType)?void 0:r.value,"USERDEFINED"===l&&!c)){const e=Object.keys(t).find((e=>/^((?!Predefined).)*Type$/.test(e)));l=e?null==(o=t[e])?void 0:o.value:"USERDEFINED"}}}return this.evalRequirement(l,this.predefinedType,"PredefinedType",i)}}class Fc extends Tc{constructor(e,i,s){super(e),t(this,"facetType","Property"),t(this,"propertySet"),t(this,"baseName"),t(this,"value"),t(this,"dataType"),t(this,"uri"),t(this,"_unsupportedTypes",[x.IFCCOMPLEXPROPERTY,x.IFCPHYSICALCOMPLEXQUANTITY]),this.propertySet=i,this.baseName=s}serialize(e){const t=mc("PropertySet",this.propertySet),i=mc("BaseName",this.baseName),s=mc("Value",this.value),n=this.dataType?`dataType=${this.dataType}`:"";let r="";return"requirement"===e&&(r+=`cardinality="${this.cardinality}"`,r+=this.uri?`uri=${this.uri}`:"",r+=this.instructions?`instructions="${this.instructions}"`:""),`<property ${n} ${r}>\n ${t}\n ${i}\n ${s}\n</property>`}async getEntities(e,t={}){var i,s;let n={};const r=await e.getAllPropertiesOfType(x.IFCPROPERTYSET);n={...n,...r};const o=await e.getAllPropertiesOfType(x.IFCELEMENTQUANTITY);if(n={...n,...o},0===Object.keys(n).length)return[];const a=[];for(const t in n){const n=Number(t),r=await e.getProperties(n);if(!r)continue;if(!((null==(i=r.Name)?void 0:i.value)===this.propertySet.parameter))continue;let o;if(r.type===x.IFCPROPERTYSET&&(o="HasProperties"),r.type===x.IFCELEMENTQUANTITY&&(o="Quantities"),o)for(const t of r[o]){const i=await e.getProperties(t.value);if(!i)continue;if((null==(s=i.Name)?void 0:s.value)===this.baseName.parameter){if(this.value){const e=Object.keys(i).find((e=>e.endsWith("Value")));if(!e)continue;if(!(i[e].value===this.value.parameter))continue}a.push(n)}}}const c=this.components.get(oo);for(const i of a){const s=c.getEntitiesWithRelation(e,"IsDefinedBy",i);for(const i of s){if(i in t)continue;const s=await e.getProperties(i);s&&(t[i]=s)}}return[]}async test(e,t){var i;this.testResult=[];for(const s in e){const n=Number(s),r=e[n],o=[],a={guid:null==(i=r.GlobalId)?void 0:i.value,expressID:n,pass:!1,checks:o,cardinality:this.cardinality};this.testResult.push(a);const c=(await this.getPsets(t,n)).filter((e=>!!this.evalRequirement(e.Name??null,this.propertySet,"PropertySet")&&(o.push({currentValue:e.Name,parameter:"PropertySet",pass:!0,requiredValue:this.propertySet.parameter}),!0)));if(0!==c.length){for(const e of c){if(!("Properties"in e)){o.push({currentValue:null,parameter:"BaseName",pass:!1,requiredValue:this.baseName.parameter});continue}const t=e.Properties.filter((e=>{var t;if(this._unsupportedTypes.includes(e.type))return!1;return!!this.evalRequirement((null==(t=e.Name)?void 0:t.value)??null,this.baseName,"BaseName")&&(o.push({currentValue:e.Name.value,parameter:"BaseName",pass:!0,requiredValue:this.baseName.parameter}),!0)}));if(0!==t.length)for(const e of t)this.evalValue(e,o),this.evalDataType(e,o),this.evalURI();else o.push({currentValue:null,parameter:"BaseName",pass:!1,requiredValue:this.baseName.parameter})}a.pass=o.every((({pass:e})=>e))}else o.push({currentValue:null,parameter:"PropertySet",pass:!1,requiredValue:this.propertySet.parameter})}const s=[...this.testResult];return this.testResult=[],s}getItemsAttrName(e){let t;return e===x.IFCPROPERTYSET&&(t="HasProperties"),e===x.IFCELEMENTQUANTITY&&(t="Quantities"),t}getValueKey(e){return Object.keys(e).find((e=>e.endsWith("Value")||e.endsWith("Values")))}async simplifyPset(e,t,i){var s;const n=[],r=t[i];if(!r)return t;for(const{value:t}of r){const i=await e.getProperties(t);i&&n.push(i)}return{Name:null==(s=t.Name)?void 0:s.value,Properties:n,type:t.type}}async getTypePsets(e,t){const i=[],s=this.components.get(oo).getEntityRelations(e,t,"IsTypedBy");if(!s||!s[0])return i;const n=await e.getProperties(s[0]);if(!(n&&"HasPropertySets"in n&&Array.isArray(n.HasPropertySets)))return i;for(const{value:t}of n.HasPropertySets){const s=await e.getProperties(t);if(!(s&&"HasProperties"in s&&Array.isArray(s.HasProperties)))continue;const n=await this.simplifyPset(e,s,"HasProperties");i.push(n)}return i}async getPsets(e,t){var i;const s=await this.getTypePsets(e,t),n=this.components.get(oo).getEntityRelations(e,t,"IsDefinedBy");if(!n)return s;const r=[];for(const t of n){const n=await e.getProperties(t);if(!n)continue;const o=this.getItemsAttrName(n.type);if(!o)continue;const a=await this.simplifyPset(e,n,o),c=s.find((({Name:e})=>e===a.Name));if(c)for(const e of c.Properties){const t=null==(i=e.Name)?void 0:i.value;a.Properties.find((({Name:e})=>e.value===t))||a.Properties.push(e)}r.push(a)}return r}evalValue(e,t){const i=this.getValueKey(e),s=e[i];if(this.value){if(!s)return null==t||t.push({parameter:"Value",currentValue:null,pass:!1,requiredValue:this.value.parameter}),!1;const i=structuredClone(this.value);if("IFCLABEL"===s.name&&"simple"===i.type&&(i.parameter=String(i.parameter)),(e.type===x.IFCPROPERTYLISTVALUE||e.type===x.IFCPROPERTYENUMERATEDVALUE)&&Array.isArray(s)){const e=s.map((e=>e.value)),n=s.find((e=>!!i&&this.evalRequirement(e.value,i,"Value")));return null==t||t.push({currentValue:e,pass:!!n,parameter:"Value",requiredValue:i.parameter}),!!n}return this.evalRequirement(s.value,i,"Value",t)}return!i||(3===s.type&&2===s.value?(null==t||t.push({parameter:"Value",currentValue:null,pass:!1,requiredValue:null}),!1):1!==s.type||""!==s.value.trim()||(null==t||t.push({parameter:"Value",currentValue:"",pass:!1,requiredValue:null}),!1))}evalDataType(e,t){if(!this.dataType)return!0;const i=e[this.getValueKey(e)];if(!i)return null==t||t.push({parameter:"DataType",currentValue:null,pass:!1,requiredValue:this.dataType}),!1;if((e.type===x.IFCPROPERTYLISTVALUE||e.type===x.IFCPROPERTYENUMERATEDVALUE)&&Array.isArray(i)&&i[0]){const e=i[0].name;return this.evalRequirement(e,{type:"simple",parameter:this.dataType},"DataType",t)}return this.evalRequirement(i.name,{type:"simple",parameter:this.dataType},"DataType",t)}evalURI(){return!0}}class Sc{constructor(e,i,s){t(this,"name"),t(this,"ifcVersion",new Set),t(this,"identifier",ki.create()),t(this,"description"),t(this,"instructions"),t(this,"requirementsDescription"),t(this,"applicability",new Ti),t(this,"requirements",new Ti),t(this,"components"),this.components=e,this.name=i;for(const e of s)this.ifcVersion.add(e)}set(e){const t=e,i=this;for(const s in e){if("identifier"===s)continue;const e=t[s];s in this&&(i[s]=e)}return this.components.get(wc).list.set(this.identifier,this),this}async test(e){let t=[];if(0===this.requirements.size)return t;const i={};for(const t of this.applicability)await t.getEntities(e,i);const s=[...this.requirements][0];return t=await s.test(i,e),t}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((e=>e.serialize("applicability"))).join("\n")}\n </applicability>\n <requirements>\n ${[...this.requirements].map((e=>e.serialize("requirement"))).join("\n")}\n </requirements>\n </specification>`}}const Oc=e=>{if(!e)return;const t={};if("simpleValue"in e&&(t.type="simple",t.parameter=e.simpleValue),"restriction"in e){const i=e.restriction;if("pattern"in i&&(t.type="pattern",t.parameter=i.pattern.value),"enumeration"in i){t.type="enumeration";const e=i.enumeration.map((({value:e})=>e));t.parameter=e}}return void 0!==t.parameter?t:void 0},Nc=(e,t)=>{const i=[];for(const s of t){const t=s.name,n=Oc(t);if(!n)continue;const r=new Ac(e,n);s.cardinality&&(r.cardinality=s.cardinality),r.predefinedType=Oc(s.predefinedType),r.instructions=s.instructions,i.push(r)}return i},yc=(e,t)=>{const i=[];for(const s of t){const t=s.name,n=Oc(t);if(!n)continue;const r=new Rc(e,n);s.cardinality&&(r.cardinality=s.cardinality),r.value=Oc(s.value),r.instructions=s.instructions,i.push(r)}return i},_c=(e,t)=>{const i=[];for(const s of t){const t=s.system,n=Oc(t);if(!n)continue;const r=new gc(e,n);s.cardinality&&(r.cardinality=s.cardinality);const o=Oc(s.value);"simple"===(null==o?void 0:o.type)&&(o.parameter=String(o.parameter)),"enumeration"===(null==o?void 0:o.type)&&Array.isArray(o.parameter)&&(o.parameter=o.parameter.map(String)),r.value=o,r.uri=s.uri,r.instructions=s.instructions,i.push(r)}return i},Lc=(e,t)=>{const i=[];for(const s of t){const t=s.propertySet,n=s.baseName,r=Oc(t),o=Oc(n);if(!o||!r)continue;const a=new Fc(e,r,o);s.cardinality&&(a.cardinality=s.cardinality);const c=Oc(s.value);"enumeration"===(null==c?void 0:c.type)&&Array.isArray(c.parameter)&&(c.parameter=c.parameter.map(String)),a.value=c,a.dataType=s.dataType,a.uri=s.uri,a.instructions=s.instructions,i.push(a)}return i},Pc=class e extends ui{constructor(i){super(i),t(this,"enabled",!0),t(this,"list",new mi),i.add(e.uuid,this)}getFragmentIdMap(e,t){const i=t.filter((e=>e.pass)).map((e=>e.expressID)),s=e.getFragmentMap(i),n=t.filter((e=>!e.pass)).map((e=>e.expressID));return{pass:s,fail:e.getFragmentMap(n)}}create(e,t,i){const s=new Sc(this.components,e,t);return i&&(s.identifier=i),this.list.set(s.identifier,s),s}load(t){const i=[],s=e.xmlParser.parse(t).ids,{specifications:n}=s;if(n&&n.specification){const e=Array.isArray(n.specification)?n.specification:[n.specification];for(const t of e){const{name:e,ifcVersion:s,description:n,instructions:r,identifier:o}=t;if(!e||!s)continue;const a=[],c=[],{applicability:l,requirements:h}=t;if(l){const{maxOccurs:e,...t}=l,i=Array.isArray(t)?t:[t];for(const e of i)for(const t in e){const i=Array.isArray(e[t])?e[t]:[e[t]];if("entity"===t){const e=Nc(this.components,i);a.push(...e)}}}let u;if(h){const{maxOccurs:e,...t}=h;u=h.description;const i=Array.isArray(t)?t:[t];for(const e of i)for(const t in e){const i=Array.isArray(e[t])?e[t]:[e[t]];if("entity"===t){const e=Nc(this.components,i);c.push(...e)}if("attribute"===t){const e=yc(this.components,i);c.push(...e)}if("classification"===t){const e=_c(this.components,i);c.push(...e)}if("property"===t){const e=Lc(this.components,i);c.push(...e)}}}if(a.length>0&&c.length>0){const t=this.create(e,s.split(/\s+/),o);t.description=n,t.instructions=r,t.requirementsDescription=u,t.applicability.add(...a),t.requirements.add(...c),i.push(t)}}}return i}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 ${Fs.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((e=>e.serialize())).join("\n")}\n </specifications>\n</ids>`}};t(Pc,"uuid","9f0b9f78-9b2e-481a-b766-2fbfd01f342c"),t(Pc,"xmlParser",new Pa.XMLParser({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 wc=Pc;export{li as AsyncEvent,Ua as BCFTopics,ba as BCFTopicsConfigManager,hi as Base,di as BaseCamera,Ei as BaseRenderer,Ci as BaseScene,Ii as BaseWorldItem,Va as BoundingBoxer,Ka as Classifier,vr as Clipper,wa as Comment,ui as Component,Ri as ComponentWithUI,Fs as Components,ys as ConfigManager,Os as Configurator,gi as ControlsUtils,xn as CullerRenderer,Vn as Cullers,mi as DataMap,Ti as DataSet,pi as Disposer,ci as Event,Ai as EventManager,ec as Exploder,Mr as FirstPersonMode,co as FragmentsManager,qr as GeometryTypes,jn as Grids,ic as Hider,Rc as IDSAttribute,gc as IDSClassification,Ac as IDSEntity,Tc as IDSFacet,Fc as IDSProperty,Sc as IDSSpecification,wc as IDSSpecifications,Xa as IfcBasicQuery,Yr as IfcCategories,Gr as IfcCategoryMap,Vr as IfcElements,qa as IfcFinder,ka as IfcFinderQuery,Xr as IfcFragmentSettings,rc as IfcGeometryTiler,Ga as IfcIsolator,Kr as IfcJsonExporter,eo as IfcLoader,no as IfcPropertiesManager,ac as IfcPropertiesTiler,zr as IfcPropertiesUtils,$a as IfcPropertyQuery,oo as IfcRelationsIndexer,sc as IfcStreamingSettings,Gi as MaterialsUtils,Cc as MeasurementUtils,Un as MeshCullerRenderer,dc as MiniMap,Ic as MiniMapConfigManager,fc as MiniMaps,zn as Mouse,Dr as OrbitMode,Ur as OrthoPerspectiveCamera,br as PlanMode,xr as ProjectionManager,oc as PropertiesStreamingSettings,Wn as Raycasters,gs as SectionGenerator,Gn as ShadowedScene,Pn as SimpleCamera,Zn as SimpleGrid,Xn as SimpleGridConfigManager,Lr as SimplePlane,kn as SimpleRaycaster,vs as SimpleRenderer,ws as SimpleScene,Ps as SimpleSceneConfigManager,Ss as SimpleWorld,Ma as Topic,ki as UUID,Hi as VertexPicker,cc as Viewpoint,uc as Viewpoints,vn as Worlds,Da as extensionsImporter,kr as ifcCategoryCase,to as ifcRelAttrsPosition,io as ifcRelClassNames,Yi as isPointInFrontOfPlane,Vi as obbFromPoints,Dn as readPixelsAsync,Br as relToAttributesMap};
|
|
18
|
+
*/const Mr=Q(zr.exports=function t(e,i,s){function n(o,a){if(!i[o]){if(!e[o]){if(!a&&Dr)return Dr(o);if(r)return r(o,!0);var l=new Error("Cannot find module '"+o+"'");throw l.code="MODULE_NOT_FOUND",l}var h=i[o]={exports:{}};e[o][0].call(h.exports,function(t){return n(e[o][1][t]||t)},h,h.exports,t,e,i,s)}return i[o].exports}for(var r=Dr,o=0;o<s.length;o++)n(s[o]);return n}({1:[function(t,e,i){var s=t("./utils"),n=t("./support"),r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";i.encode=function(t){for(var e,i,n,o,a,l,h,c=[],d=0,u=t.length,p=u,f="string"!==s.getTypeOf(t);d<t.length;)p=u-d,n=f?(e=t[d++],i=d<u?t[d++]:0,d<u?t[d++]:0):(e=t.charCodeAt(d++),i=d<u?t.charCodeAt(d++):0,d<u?t.charCodeAt(d++):0),o=e>>2,a=(3&e)<<4|i>>4,l=1<p?(15&i)<<2|n>>6:64,h=2<p?63&n:64,c.push(r.charAt(o)+r.charAt(a)+r.charAt(l)+r.charAt(h));return c.join("")},i.decode=function(t){var e,i,s,o,a,l,h=0,c=0,d="data:";if(t.substr(0,d.length)===d)throw new Error("Invalid base64 input, it looks like a data url.");var u,p=3*(t=t.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(t.charAt(t.length-1)===r.charAt(64)&&p--,t.charAt(t.length-2)===r.charAt(64)&&p--,p%1!=0)throw new Error("Invalid base64 input, bad content length.");for(u=n.uint8array?new Uint8Array(0|p):new Array(0|p);h<t.length;)e=r.indexOf(t.charAt(h++))<<2|(o=r.indexOf(t.charAt(h++)))>>4,i=(15&o)<<4|(a=r.indexOf(t.charAt(h++)))>>2,s=(3&a)<<6|(l=r.indexOf(t.charAt(h++))),u[c++]=e,64!==a&&(u[c++]=i),64!==l&&(u[c++]=s);return u}},{"./support":30,"./utils":32}],2:[function(t,e,i){var s=t("./external"),n=t("./stream/DataWorker"),r=t("./stream/Crc32Probe"),o=t("./stream/DataLengthProbe");function a(t,e,i,s,n){this.compressedSize=t,this.uncompressedSize=e,this.crc32=i,this.compression=s,this.compressedContent=n}a.prototype={getContentWorker:function(){var t=new n(s.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new o("data_length")),e=this;return t.on("end",function(){if(this.streamInfo.data_length!==e.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),t},getCompressedWorker:function(){return new n(s.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},a.createWorkerFrom=function(t,e,i){return t.pipe(new r).pipe(new o("uncompressedSize")).pipe(e.compressWorker(i)).pipe(new o("compressedSize")).withStreamInfo("compression",e)},e.exports=a},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(t,e,i){var s=t("./stream/GenericWorker");i.STORE={magic:"\0\0",compressWorker:function(){return new s("STORE compression")},uncompressWorker:function(){return new s("STORE decompression")}},i.DEFLATE=t("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(t,e,i){var s=t("./utils"),n=function(){for(var t,e=[],i=0;i<256;i++){t=i;for(var s=0;s<8;s++)t=1&t?3988292384^t>>>1:t>>>1;e[i]=t}return e}();e.exports=function(t,e){return void 0!==t&&t.length?"string"!==s.getTypeOf(t)?function(t,e,i,s){var r=n,o=s+i;t^=-1;for(var a=s;a<o;a++)t=t>>>8^r[255&(t^e[a])];return-1^t}(0|e,t,t.length,0):function(t,e,i,s){var r=n,o=s+i;t^=-1;for(var a=s;a<o;a++)t=t>>>8^r[255&(t^e.charCodeAt(a))];return-1^t}(0|e,t,t.length,0):0}},{"./utils":32}],5:[function(t,e,i){i.base64=!1,i.binary=!1,i.dir=!1,i.createFolders=!0,i.date=null,i.compression=null,i.compressionOptions=null,i.comment=null,i.unixPermissions=null,i.dosPermissions=null},{}],6:[function(t,e,i){var s=null;s="undefined"!=typeof Promise?Promise:t("lie"),e.exports={Promise:s}},{lie:37}],7:[function(t,e,i){var s="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Uint32Array,n=t("pako"),r=t("./utils"),o=t("./stream/GenericWorker"),a=s?"uint8array":"array";function l(t,e){o.call(this,"FlateWorker/"+t),this._pako=null,this._pakoAction=t,this._pakoOptions=e,this.meta={}}i.magic="\b\0",r.inherits(l,o),l.prototype.processChunk=function(t){this.meta=t.meta,null===this._pako&&this._createPako(),this._pako.push(r.transformTo(a,t.data),!1)},l.prototype.flush=function(){o.prototype.flush.call(this),null===this._pako&&this._createPako(),this._pako.push([],!0)},l.prototype.cleanUp=function(){o.prototype.cleanUp.call(this),this._pako=null},l.prototype._createPako=function(){this._pako=new n[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var t=this;this._pako.onData=function(e){t.push({data:e,meta:t.meta})}},i.compressWorker=function(t){return new l("Deflate",t)},i.uncompressWorker=function(){return new l("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(t,e,i){function s(t,e){var i,s="";for(i=0;i<e;i++)s+=String.fromCharCode(255&t),t>>>=8;return s}function n(t,e,i,n,o,c){var d,u,p=t.file,f=t.compression,m=c!==a.utf8encode,g=r.transformTo("string",c(p.name)),_=r.transformTo("string",a.utf8encode(p.name)),y=p.comment,w=r.transformTo("string",c(y)),v=r.transformTo("string",a.utf8encode(y)),b=_.length!==p.name.length,x=v.length!==y.length,E="",T="",C="",S=p.dir,A=p.date,O={crc32:0,compressedSize:0,uncompressedSize:0};e&&!i||(O.crc32=t.crc32,O.compressedSize=t.compressedSize,O.uncompressedSize=t.uncompressedSize);var P=0;e&&(P|=8),m||!b&&!x||(P|=2048);var I,k,D,z=0,M=0;S&&(z|=16),"UNIX"===o?(M=798,z|=(I=p.unixPermissions,k=S,D=I,I||(D=k?16893:33204),(65535&D)<<16)):(M=20,z|=function(t){return 63&(t||0)}(p.dosPermissions)),d=A.getUTCHours(),d<<=6,d|=A.getUTCMinutes(),d<<=5,d|=A.getUTCSeconds()/2,u=A.getUTCFullYear()-1980,u<<=4,u|=A.getUTCMonth()+1,u<<=5,u|=A.getUTCDate(),b&&(T=s(1,1)+s(l(g),4)+_,E+="up"+s(T.length,2)+T),x&&(C=s(1,1)+s(l(w),4)+v,E+="uc"+s(C.length,2)+C);var B="";return B+="\n\0",B+=s(P,2),B+=f.magic,B+=s(d,2),B+=s(u,2),B+=s(O.crc32,4),B+=s(O.compressedSize,4),B+=s(O.uncompressedSize,4),B+=s(g.length,2),B+=s(E.length,2),{fileRecord:h.LOCAL_FILE_HEADER+B+g+E,dirRecord:h.CENTRAL_FILE_HEADER+s(M,2)+B+s(w.length,2)+"\0\0\0\0"+s(z,4)+s(n,4)+g+E+w}}var r=t("../utils"),o=t("../stream/GenericWorker"),a=t("../utf8"),l=t("../crc32"),h=t("../signature");function c(t,e,i,s){o.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=e,this.zipPlatform=i,this.encodeFileName=s,this.streamFiles=t,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}r.inherits(c,o),c.prototype.push=function(t){var e=t.meta.percent||0,i=this.entriesCount,s=this._sources.length;this.accumulate?this.contentBuffer.push(t):(this.bytesWritten+=t.data.length,o.prototype.push.call(this,{data:t.data,meta:{currentFile:this.currentFile,percent:i?(e+100*(i-s-1))/i:100}}))},c.prototype.openedSource=function(t){this.currentSourceOffset=this.bytesWritten,this.currentFile=t.file.name;var e=this.streamFiles&&!t.file.dir;if(e){var i=n(t,e,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:i.fileRecord,meta:{percent:0}})}else this.accumulate=!0},c.prototype.closedSource=function(t){this.accumulate=!1;var e,i=this.streamFiles&&!t.file.dir,r=n(t,i,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(r.dirRecord),i)this.push({data:(e=t,h.DATA_DESCRIPTOR+s(e.crc32,4)+s(e.compressedSize,4)+s(e.uncompressedSize,4)),meta:{percent:100}});else for(this.push({data:r.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},c.prototype.flush=function(){for(var t=this.bytesWritten,e=0;e<this.dirRecords.length;e++)this.push({data:this.dirRecords[e],meta:{percent:100}});var i,n,o,a,l,c,d=this.bytesWritten-t,u=(i=this.dirRecords.length,n=d,o=t,a=this.zipComment,l=this.encodeFileName,c=r.transformTo("string",l(a)),h.CENTRAL_DIRECTORY_END+"\0\0\0\0"+s(i,2)+s(i,2)+s(n,4)+s(o,4)+s(c.length,2)+c);this.push({data:u,meta:{percent:100}})},c.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},c.prototype.registerPrevious=function(t){this._sources.push(t);var e=this;return t.on("data",function(t){e.processChunk(t)}),t.on("end",function(){e.closedSource(e.previous.streamInfo),e._sources.length?e.prepareNextSource():e.end()}),t.on("error",function(t){e.error(t)}),this},c.prototype.resume=function(){return!!o.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},c.prototype.error=function(t){var e=this._sources;if(!o.prototype.error.call(this,t))return!1;for(var i=0;i<e.length;i++)try{e[i].error(t)}catch(t){}return!0},c.prototype.lock=function(){o.prototype.lock.call(this);for(var t=this._sources,e=0;e<t.length;e++)t[e].lock()},e.exports=c},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(t,e,i){var s=t("../compressions"),n=t("./ZipFileWorker");i.generateWorker=function(t,e,i){var r=new n(e.streamFiles,i,e.platform,e.encodeFileName),o=0;try{t.forEach(function(t,i){o++;var n=function(t,e){var i=t||e,n=s[i];if(!n)throw new Error(i+" is not a valid compression method !");return n}(i.options.compression,e.compression),a=i.options.compressionOptions||e.compressionOptions||{},l=i.dir,h=i.date;i._compressWorker(n,a).withStreamInfo("file",{name:t,dir:l,date:h,comment:i.comment||"",unixPermissions:i.unixPermissions,dosPermissions:i.dosPermissions}).pipe(r)}),r.entriesCount=o}catch(t){r.error(t)}return r}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(t,e,i){function s(){if(!(this instanceof s))return new s;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 t=new s;for(var e in this)"function"!=typeof this[e]&&(t[e]=this[e]);return t}}(s.prototype=t("./object")).loadAsync=t("./load"),s.support=t("./support"),s.defaults=t("./defaults"),s.version="3.10.1",s.loadAsync=function(t,e){return(new s).loadAsync(t,e)},s.external=t("./external"),e.exports=s},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(t,e,i){var s=t("./utils"),n=t("./external"),r=t("./utf8"),o=t("./zipEntries"),a=t("./stream/Crc32Probe"),l=t("./nodejsUtils");function h(t){return new n.Promise(function(e,i){var s=t.decompressed.getContentWorker().pipe(new a);s.on("error",function(t){i(t)}).on("end",function(){s.streamInfo.crc32!==t.decompressed.crc32?i(new Error("Corrupted zip : CRC32 mismatch")):e()}).resume()})}e.exports=function(t,e){var i=this;return e=s.extend(e||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:r.utf8decode}),l.isNode&&l.isStream(t)?n.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):s.prepareContent("the loaded zip file",t,!0,e.optimizedBinaryString,e.base64).then(function(t){var i=new o(e);return i.load(t),i}).then(function(t){var i=[n.Promise.resolve(t)],s=t.files;if(e.checkCRC32)for(var r=0;r<s.length;r++)i.push(h(s[r]));return n.Promise.all(i)}).then(function(t){for(var n=t.shift(),r=n.files,o=0;o<r.length;o++){var a=r[o],l=a.fileNameStr,h=s.resolve(a.fileNameStr);i.file(h,a.decompressed,{binary:!0,optimizedBinaryString:!0,date:a.date,dir:a.dir,comment:a.fileCommentStr.length?a.fileCommentStr:null,unixPermissions:a.unixPermissions,dosPermissions:a.dosPermissions,createFolders:e.createFolders}),a.dir||(i.file(h).unsafeOriginalName=l)}return n.zipComment.length&&(i.comment=n.zipComment),i})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(t,e,i){var s=t("../utils"),n=t("../stream/GenericWorker");function r(t,e){n.call(this,"Nodejs stream input adapter for "+t),this._upstreamEnded=!1,this._bindStream(e)}s.inherits(r,n),r.prototype._bindStream=function(t){var e=this;(this._stream=t).pause(),t.on("data",function(t){e.push({data:t,meta:{percent:0}})}).on("error",function(t){e.isPaused?this.generatedError=t:e.error(t)}).on("end",function(){e.isPaused?e._upstreamEnded=!0:e.end()})},r.prototype.pause=function(){return!!n.prototype.pause.call(this)&&(this._stream.pause(),!0)},r.prototype.resume=function(){return!!n.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},e.exports=r},{"../stream/GenericWorker":28,"../utils":32}],13:[function(t,e,i){var s=t("readable-stream").Readable;function n(t,e,i){s.call(this,e),this._helper=t;var n=this;t.on("data",function(t,e){n.push(t)||n._helper.pause(),i&&i(e)}).on("error",function(t){n.emit("error",t)}).on("end",function(){n.push(null)})}t("../utils").inherits(n,s),n.prototype._read=function(){this._helper.resume()},e.exports=n},{"../utils":32,"readable-stream":16}],14:[function(t,e,i){e.exports={isNode:"undefined"!=typeof Buffer,newBufferFrom:function(t,e){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(t,e);if("number"==typeof t)throw new Error('The "data" argument must not be a number');return new Buffer(t,e)},allocBuffer:function(t){if(Buffer.alloc)return Buffer.alloc(t);var e=new Buffer(t);return e.fill(0),e},isBuffer:function(t){return Buffer.isBuffer(t)},isStream:function(t){return t&&"function"==typeof t.on&&"function"==typeof t.pause&&"function"==typeof t.resume}}},{}],15:[function(t,e,i){function s(t,e,i){var s,n=r.getTypeOf(e),a=r.extend(i||{},l);a.date=a.date||new Date,null!==a.compression&&(a.compression=a.compression.toUpperCase()),"string"==typeof a.unixPermissions&&(a.unixPermissions=parseInt(a.unixPermissions,8)),a.unixPermissions&&16384&a.unixPermissions&&(a.dir=!0),a.dosPermissions&&16&a.dosPermissions&&(a.dir=!0),a.dir&&(t=m(t)),a.createFolders&&(s=f(t))&&g.call(this,s,!0);var d="string"===n&&!1===a.binary&&!1===a.base64;i&&void 0!==i.binary||(a.binary=!d),(e instanceof h&&0===e.uncompressedSize||a.dir||!e||0===e.length)&&(a.base64=!1,a.binary=!0,e="",a.compression="STORE",n="string");var _=null;_=e instanceof h||e instanceof o?e:u.isNode&&u.isStream(e)?new p(t,e):r.prepareContent(t,e,a.binary,a.optimizedBinaryString,a.base64);var y=new c(t,_,a);this.files[t]=y}var n=t("./utf8"),r=t("./utils"),o=t("./stream/GenericWorker"),a=t("./stream/StreamHelper"),l=t("./defaults"),h=t("./compressedObject"),c=t("./zipObject"),d=t("./generate"),u=t("./nodejsUtils"),p=t("./nodejs/NodejsStreamInputAdapter"),f=function(t){"/"===t.slice(-1)&&(t=t.substring(0,t.length-1));var e=t.lastIndexOf("/");return 0<e?t.substring(0,e):""},m=function(t){return"/"!==t.slice(-1)&&(t+="/"),t},g=function(t,e){return e=void 0!==e?e:l.createFolders,t=m(t),this.files[t]||s.call(this,t,null,{dir:!0,createFolders:e}),this.files[t]};function _(t){return"[object RegExp]"===Object.prototype.toString.call(t)}var y={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(t){var e,i,s;for(e in this.files)s=this.files[e],(i=e.slice(this.root.length,e.length))&&e.slice(0,this.root.length)===this.root&&t(i,s)},filter:function(t){var e=[];return this.forEach(function(i,s){t(i,s)&&e.push(s)}),e},file:function(t,e,i){if(1!==arguments.length)return t=this.root+t,s.call(this,t,e,i),this;if(_(t)){var n=t;return this.filter(function(t,e){return!e.dir&&n.test(t)})}var r=this.files[this.root+t];return r&&!r.dir?r:null},folder:function(t){if(!t)return this;if(_(t))return this.filter(function(e,i){return i.dir&&t.test(e)});var e=this.root+t,i=g.call(this,e),s=this.clone();return s.root=i.name,s},remove:function(t){t=this.root+t;var e=this.files[t];if(e||("/"!==t.slice(-1)&&(t+="/"),e=this.files[t]),e&&!e.dir)delete this.files[t];else for(var i=this.filter(function(e,i){return i.name.slice(0,t.length)===t}),s=0;s<i.length;s++)delete this.files[i[s].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(t){var e,i={};try{if((i=r.extend(t||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:n.utf8encode})).type=i.type.toLowerCase(),i.compression=i.compression.toUpperCase(),"binarystring"===i.type&&(i.type="string"),!i.type)throw new Error("No output type specified.");r.checkSupport(i.type),"darwin"!==i.platform&&"freebsd"!==i.platform&&"linux"!==i.platform&&"sunos"!==i.platform||(i.platform="UNIX"),"win32"===i.platform&&(i.platform="DOS");var s=i.comment||this.comment||"";e=d.generateWorker(this,i,s)}catch(t){(e=new o("error")).error(t)}return new a(e,i.type||"string",i.mimeType)},generateAsync:function(t,e){return this.generateInternalStream(t).accumulate(e)},generateNodeStream:function(t,e){return(t=t||{}).type||(t.type="nodebuffer"),this.generateInternalStream(t).toNodejsStream(e)}};e.exports=y},{"./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,e,i){e.exports=t("stream")},{stream:void 0}],17:[function(t,e,i){var s=t("./DataReader");function n(t){s.call(this,t);for(var e=0;e<this.data.length;e++)t[e]=255&t[e]}t("../utils").inherits(n,s),n.prototype.byteAt=function(t){return this.data[this.zero+t]},n.prototype.lastIndexOfSignature=function(t){for(var e=t.charCodeAt(0),i=t.charCodeAt(1),s=t.charCodeAt(2),n=t.charCodeAt(3),r=this.length-4;0<=r;--r)if(this.data[r]===e&&this.data[r+1]===i&&this.data[r+2]===s&&this.data[r+3]===n)return r-this.zero;return-1},n.prototype.readAndCheckSignature=function(t){var e=t.charCodeAt(0),i=t.charCodeAt(1),s=t.charCodeAt(2),n=t.charCodeAt(3),r=this.readData(4);return e===r[0]&&i===r[1]&&s===r[2]&&n===r[3]},n.prototype.readData=function(t){if(this.checkOffset(t),0===t)return[];var e=this.data.slice(this.zero+this.index,this.zero+this.index+t);return this.index+=t,e},e.exports=n},{"../utils":32,"./DataReader":18}],18:[function(t,e,i){var s=t("../utils");function n(t){this.data=t,this.length=t.length,this.index=0,this.zero=0}n.prototype={checkOffset:function(t){this.checkIndex(this.index+t)},checkIndex:function(t){if(this.length<this.zero+t||t<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+t+"). Corrupted zip ?")},setIndex:function(t){this.checkIndex(t),this.index=t},skip:function(t){this.setIndex(this.index+t)},byteAt:function(){},readInt:function(t){var e,i=0;for(this.checkOffset(t),e=this.index+t-1;e>=this.index;e--)i=(i<<8)+this.byteAt(e);return this.index+=t,i},readString:function(t){return s.transformTo("string",this.readData(t))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var t=this.readInt(4);return new Date(Date.UTC(1980+(t>>25&127),(t>>21&15)-1,t>>16&31,t>>11&31,t>>5&63,(31&t)<<1))}},e.exports=n},{"../utils":32}],19:[function(t,e,i){var s=t("./Uint8ArrayReader");function n(t){s.call(this,t)}t("../utils").inherits(n,s),n.prototype.readData=function(t){this.checkOffset(t);var e=this.data.slice(this.zero+this.index,this.zero+this.index+t);return this.index+=t,e},e.exports=n},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(t,e,i){var s=t("./DataReader");function n(t){s.call(this,t)}t("../utils").inherits(n,s),n.prototype.byteAt=function(t){return this.data.charCodeAt(this.zero+t)},n.prototype.lastIndexOfSignature=function(t){return this.data.lastIndexOf(t)-this.zero},n.prototype.readAndCheckSignature=function(t){return t===this.readData(4)},n.prototype.readData=function(t){this.checkOffset(t);var e=this.data.slice(this.zero+this.index,this.zero+this.index+t);return this.index+=t,e},e.exports=n},{"../utils":32,"./DataReader":18}],21:[function(t,e,i){var s=t("./ArrayReader");function n(t){s.call(this,t)}t("../utils").inherits(n,s),n.prototype.readData=function(t){if(this.checkOffset(t),0===t)return new Uint8Array(0);var e=this.data.subarray(this.zero+this.index,this.zero+this.index+t);return this.index+=t,e},e.exports=n},{"../utils":32,"./ArrayReader":17}],22:[function(t,e,i){var s=t("../utils"),n=t("../support"),r=t("./ArrayReader"),o=t("./StringReader"),a=t("./NodeBufferReader"),l=t("./Uint8ArrayReader");e.exports=function(t){var e=s.getTypeOf(t);return s.checkSupport(e),"string"!==e||n.uint8array?"nodebuffer"===e?new a(t):n.uint8array?new l(s.transformTo("uint8array",t)):new r(s.transformTo("array",t)):new o(t)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(t,e,i){i.LOCAL_FILE_HEADER="PK",i.CENTRAL_FILE_HEADER="PK",i.CENTRAL_DIRECTORY_END="PK",i.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK",i.ZIP64_CENTRAL_DIRECTORY_END="PK",i.DATA_DESCRIPTOR="PK\b"},{}],24:[function(t,e,i){var s=t("./GenericWorker"),n=t("../utils");function r(t){s.call(this,"ConvertWorker to "+t),this.destType=t}n.inherits(r,s),r.prototype.processChunk=function(t){this.push({data:n.transformTo(this.destType,t.data),meta:t.meta})},e.exports=r},{"../utils":32,"./GenericWorker":28}],25:[function(t,e,i){var s=t("./GenericWorker"),n=t("../crc32");function r(){s.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}t("../utils").inherits(r,s),r.prototype.processChunk=function(t){this.streamInfo.crc32=n(t.data,this.streamInfo.crc32||0),this.push(t)},e.exports=r},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(t,e,i){var s=t("../utils"),n=t("./GenericWorker");function r(t){n.call(this,"DataLengthProbe for "+t),this.propName=t,this.withStreamInfo(t,0)}s.inherits(r,n),r.prototype.processChunk=function(t){if(t){var e=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=e+t.data.length}n.prototype.processChunk.call(this,t)},e.exports=r},{"../utils":32,"./GenericWorker":28}],27:[function(t,e,i){var s=t("../utils"),n=t("./GenericWorker");function r(t){n.call(this,"DataWorker");var e=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,t.then(function(t){e.dataIsReady=!0,e.data=t,e.max=t&&t.length||0,e.type=s.getTypeOf(t),e.isPaused||e._tickAndRepeat()},function(t){e.error(t)})}s.inherits(r,n),r.prototype.cleanUp=function(){n.prototype.cleanUp.call(this),this.data=null},r.prototype.resume=function(){return!!n.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,s.delay(this._tickAndRepeat,[],this)),!0)},r.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(s.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},r.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var t=null,e=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":t=this.data.substring(this.index,e);break;case"uint8array":t=this.data.subarray(this.index,e);break;case"array":case"nodebuffer":t=this.data.slice(this.index,e)}return this.index=e,this.push({data:t,meta:{percent:this.max?this.index/this.max*100:0}})},e.exports=r},{"../utils":32,"./GenericWorker":28}],28:[function(t,e,i){function s(t){this.name=t||"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}s.prototype={push:function(t){this.emit("data",t)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(t){this.emit("error",t)}return!0},error:function(t){return!this.isFinished&&(this.isPaused?this.generatedError=t:(this.isFinished=!0,this.emit("error",t),this.previous&&this.previous.error(t),this.cleanUp()),!0)},on:function(t,e){return this._listeners[t].push(e),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(t,e){if(this._listeners[t])for(var i=0;i<this._listeners[t].length;i++)this._listeners[t][i].call(this,e)},pipe:function(t){return t.registerPrevious(this)},registerPrevious:function(t){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=t.streamInfo,this.mergeStreamInfo(),this.previous=t;var e=this;return t.on("data",function(t){e.processChunk(t)}),t.on("end",function(){e.end()}),t.on("error",function(t){e.error(t)}),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 t=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),t=!0),this.previous&&this.previous.resume(),!t},flush:function(){},processChunk:function(t){this.push(t)},withStreamInfo:function(t,e){return this.extraStreamInfo[t]=e,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var t in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,t)&&(this.streamInfo[t]=this.extraStreamInfo[t])},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 t="Worker "+this.name;return this.previous?this.previous+" -> "+t:t}},e.exports=s},{}],29:[function(t,e,i){var s=t("../utils"),n=t("./ConvertWorker"),r=t("./GenericWorker"),o=t("../base64"),a=t("../support"),l=t("../external"),h=null;if(a.nodestream)try{h=t("../nodejs/NodejsStreamOutputAdapter")}catch(t){}function c(t,e){return new l.Promise(function(i,n){var r=[],a=t._internalType,l=t._outputType,h=t._mimeType;t.on("data",function(t,i){r.push(t),e&&e(i)}).on("error",function(t){r=[],n(t)}).on("end",function(){try{var t=function(t,e,i){switch(t){case"blob":return s.newBlob(s.transformTo("arraybuffer",e),i);case"base64":return o.encode(e);default:return s.transformTo(t,e)}}(l,function(t,e){var i,s=0,n=null,r=0;for(i=0;i<e.length;i++)r+=e[i].length;switch(t){case"string":return e.join("");case"array":return Array.prototype.concat.apply([],e);case"uint8array":for(n=new Uint8Array(r),i=0;i<e.length;i++)n.set(e[i],s),s+=e[i].length;return n;case"nodebuffer":return Buffer.concat(e);default:throw new Error("concat : unsupported type '"+t+"'")}}(a,r),h);i(t)}catch(t){n(t)}r=[]}).resume()})}function d(t,e,i){var o=e;switch(e){case"blob":case"arraybuffer":o="uint8array";break;case"base64":o="string"}try{this._internalType=o,this._outputType=e,this._mimeType=i,s.checkSupport(o),this._worker=t.pipe(new n(o)),t.lock()}catch(t){this._worker=new r("error"),this._worker.error(t)}}d.prototype={accumulate:function(t){return c(this,t)},on:function(t,e){var i=this;return"data"===t?this._worker.on(t,function(t){e.call(i,t.data,t.meta)}):this._worker.on(t,function(){s.delay(e,arguments,i)}),this},resume:function(){return s.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(t){if(s.checkSupport("nodestream"),"nodebuffer"!==this._outputType)throw new Error(this._outputType+" is not supported by this method");return new h(this,{objectMode:"nodebuffer"!==this._outputType},t)}},e.exports=d},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(t,e,i){if(i.base64=!0,i.array=!0,i.string=!0,i.arraybuffer="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8Array,i.nodebuffer="undefined"!=typeof Buffer,i.uint8array="undefined"!=typeof Uint8Array,"undefined"==typeof ArrayBuffer)i.blob=!1;else{var s=new ArrayBuffer(0);try{i.blob=0===new Blob([s],{type:"application/zip"}).size}catch(t){try{var n=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);n.append(s),i.blob=0===n.getBlob("application/zip").size}catch(t){i.blob=!1}}}try{i.nodestream=!!t("readable-stream").Readable}catch(t){i.nodestream=!1}},{"readable-stream":16}],31:[function(t,e,i){for(var s=t("./utils"),n=t("./support"),r=t("./nodejsUtils"),o=t("./stream/GenericWorker"),a=new Array(256),l=0;l<256;l++)a[l]=252<=l?6:248<=l?5:240<=l?4:224<=l?3:192<=l?2:1;function h(){o.call(this,"utf-8 decode"),this.leftOver=null}function c(){o.call(this,"utf-8 encode")}a[254]=a[254]=1,i.utf8encode=function(t){return n.nodebuffer?r.newBufferFrom(t,"utf-8"):function(t){var e,i,s,r,o,a=t.length,l=0;for(r=0;r<a;r++)55296==(64512&(i=t.charCodeAt(r)))&&r+1<a&&56320==(64512&(s=t.charCodeAt(r+1)))&&(i=65536+(i-55296<<10)+(s-56320),r++),l+=i<128?1:i<2048?2:i<65536?3:4;for(e=n.uint8array?new Uint8Array(l):new Array(l),r=o=0;o<l;r++)55296==(64512&(i=t.charCodeAt(r)))&&r+1<a&&56320==(64512&(s=t.charCodeAt(r+1)))&&(i=65536+(i-55296<<10)+(s-56320),r++),i<128?e[o++]=i:(i<2048?e[o++]=192|i>>>6:(i<65536?e[o++]=224|i>>>12:(e[o++]=240|i>>>18,e[o++]=128|i>>>12&63),e[o++]=128|i>>>6&63),e[o++]=128|63&i);return e}(t)},i.utf8decode=function(t){return n.nodebuffer?s.transformTo("nodebuffer",t).toString("utf-8"):function(t){var e,i,n,r,o=t.length,l=new Array(2*o);for(e=i=0;e<o;)if((n=t[e++])<128)l[i++]=n;else if(4<(r=a[n]))l[i++]=65533,e+=r-1;else{for(n&=2===r?31:3===r?15:7;1<r&&e<o;)n=n<<6|63&t[e++],r--;1<r?l[i++]=65533:n<65536?l[i++]=n:(n-=65536,l[i++]=55296|n>>10&1023,l[i++]=56320|1023&n)}return l.length!==i&&(l.subarray?l=l.subarray(0,i):l.length=i),s.applyFromCharCode(l)}(t=s.transformTo(n.uint8array?"uint8array":"array",t))},s.inherits(h,o),h.prototype.processChunk=function(t){var e=s.transformTo(n.uint8array?"uint8array":"array",t.data);if(this.leftOver&&this.leftOver.length){if(n.uint8array){var r=e;(e=new Uint8Array(r.length+this.leftOver.length)).set(this.leftOver,0),e.set(r,this.leftOver.length)}else e=this.leftOver.concat(e);this.leftOver=null}var o=function(t,e){var i;for((e=e||t.length)>t.length&&(e=t.length),i=e-1;0<=i&&128==(192&t[i]);)i--;return i<0||0===i?e:i+a[t[i]]>e?i:e}(e),l=e;o!==e.length&&(n.uint8array?(l=e.subarray(0,o),this.leftOver=e.subarray(o,e.length)):(l=e.slice(0,o),this.leftOver=e.slice(o,e.length))),this.push({data:i.utf8decode(l),meta:t.meta})},h.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:i.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},i.Utf8DecodeWorker=h,s.inherits(c,o),c.prototype.processChunk=function(t){this.push({data:i.utf8encode(t.data),meta:t.meta})},i.Utf8EncodeWorker=c},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(t,e,i){var s=t("./support"),n=t("./base64"),r=t("./nodejsUtils"),o=t("./external");function a(t){return t}function l(t,e){for(var i=0;i<t.length;++i)e[i]=255&t.charCodeAt(i);return e}t("setimmediate"),i.newBlob=function(t,e){i.checkSupport("blob");try{return new Blob([t],{type:e})}catch(i){try{var s=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return s.append(t),s.getBlob(e)}catch(t){throw new Error("Bug : can't construct the Blob.")}}};var h={stringifyByChunk:function(t,e,i){var s=[],n=0,r=t.length;if(r<=i)return String.fromCharCode.apply(null,t);for(;n<r;)"array"===e||"nodebuffer"===e?s.push(String.fromCharCode.apply(null,t.slice(n,Math.min(n+i,r)))):s.push(String.fromCharCode.apply(null,t.subarray(n,Math.min(n+i,r)))),n+=i;return s.join("")},stringifyByChar:function(t){for(var e="",i=0;i<t.length;i++)e+=String.fromCharCode(t[i]);return e},applyCanBeUsed:{uint8array:function(){try{return s.uint8array&&1===String.fromCharCode.apply(null,new Uint8Array(1)).length}catch(t){return!1}}(),nodebuffer:function(){try{return s.nodebuffer&&1===String.fromCharCode.apply(null,r.allocBuffer(1)).length}catch(t){return!1}}()}};function c(t){var e=65536,s=i.getTypeOf(t),n=!0;if("uint8array"===s?n=h.applyCanBeUsed.uint8array:"nodebuffer"===s&&(n=h.applyCanBeUsed.nodebuffer),n)for(;1<e;)try{return h.stringifyByChunk(t,s,e)}catch(t){e=Math.floor(e/2)}return h.stringifyByChar(t)}function d(t,e){for(var i=0;i<t.length;i++)e[i]=t[i];return e}i.applyFromCharCode=c;var u={};u.string={string:a,array:function(t){return l(t,new Array(t.length))},arraybuffer:function(t){return u.string.uint8array(t).buffer},uint8array:function(t){return l(t,new Uint8Array(t.length))},nodebuffer:function(t){return l(t,r.allocBuffer(t.length))}},u.array={string:c,array:a,arraybuffer:function(t){return new Uint8Array(t).buffer},uint8array:function(t){return new Uint8Array(t)},nodebuffer:function(t){return r.newBufferFrom(t)}},u.arraybuffer={string:function(t){return c(new Uint8Array(t))},array:function(t){return d(new Uint8Array(t),new Array(t.byteLength))},arraybuffer:a,uint8array:function(t){return new Uint8Array(t)},nodebuffer:function(t){return r.newBufferFrom(new Uint8Array(t))}},u.uint8array={string:c,array:function(t){return d(t,new Array(t.length))},arraybuffer:function(t){return t.buffer},uint8array:a,nodebuffer:function(t){return r.newBufferFrom(t)}},u.nodebuffer={string:c,array:function(t){return d(t,new Array(t.length))},arraybuffer:function(t){return u.nodebuffer.uint8array(t).buffer},uint8array:function(t){return d(t,new Uint8Array(t.length))},nodebuffer:a},i.transformTo=function(t,e){if(e=e||"",!t)return e;i.checkSupport(t);var s=i.getTypeOf(e);return u[s][t](e)},i.resolve=function(t){for(var e=t.split("/"),i=[],s=0;s<e.length;s++){var n=e[s];"."===n||""===n&&0!==s&&s!==e.length-1||(".."===n?i.pop():i.push(n))}return i.join("/")},i.getTypeOf=function(t){return"string"==typeof t?"string":"[object Array]"===Object.prototype.toString.call(t)?"array":s.nodebuffer&&r.isBuffer(t)?"nodebuffer":s.uint8array&&t instanceof Uint8Array?"uint8array":s.arraybuffer&&t instanceof ArrayBuffer?"arraybuffer":void 0},i.checkSupport=function(t){if(!s[t.toLowerCase()])throw new Error(t+" is not supported by this platform")},i.MAX_VALUE_16BITS=65535,i.MAX_VALUE_32BITS=-1,i.pretty=function(t){var e,i,s="";for(i=0;i<(t||"").length;i++)s+="\\x"+((e=t.charCodeAt(i))<16?"0":"")+e.toString(16).toUpperCase();return s},i.delay=function(t,e,i){setImmediate(function(){t.apply(i||null,e||[])})},i.inherits=function(t,e){function i(){}i.prototype=e.prototype,t.prototype=new i},i.extend=function(){var t,e,i={};for(t=0;t<arguments.length;t++)for(e in arguments[t])Object.prototype.hasOwnProperty.call(arguments[t],e)&&void 0===i[e]&&(i[e]=arguments[t][e]);return i},i.prepareContent=function(t,e,r,a,h){return o.Promise.resolve(e).then(function(t){return s.blob&&(t instanceof Blob||-1!==["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(t)))&&"undefined"!=typeof FileReader?new o.Promise(function(e,i){var s=new FileReader;s.onload=function(t){e(t.target.result)},s.onerror=function(t){i(t.target.error)},s.readAsArrayBuffer(t)}):t}).then(function(e){var c,d=i.getTypeOf(e);return d?("arraybuffer"===d?e=i.transformTo("uint8array",e):"string"===d&&(h?e=n.decode(e):r&&!0!==a&&(e=l(c=e,s.uint8array?new Uint8Array(c.length):new Array(c.length)))),e):o.Promise.reject(new Error("Can't read the data of '"+t+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(t,e,i){var s=t("./reader/readerFor"),n=t("./utils"),r=t("./signature"),o=t("./zipEntry"),a=t("./support");function l(t){this.files=[],this.loadOptions=t}l.prototype={checkSignature:function(t){if(!this.reader.readAndCheckSignature(t)){this.reader.index-=4;var e=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+n.pretty(e)+", expected "+n.pretty(t)+")")}},isSignature:function(t,e){var i=this.reader.index;this.reader.setIndex(t);var s=this.reader.readString(4)===e;return this.reader.setIndex(i),s},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 t=this.reader.readData(this.zipCommentLength),e=a.uint8array?"uint8array":"array",i=n.transformTo(e,t);this.zipComment=this.loadOptions.decodeFileName(i)},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 t,e,i,s=this.zip64EndOfCentralSize-44;0<s;)t=this.reader.readInt(2),e=this.reader.readInt(4),i=this.reader.readData(e),this.zip64ExtensibleData[t]={id:t,length:e,value:i}},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 t,e;for(t=0;t<this.files.length;t++)e=this.files[t],this.reader.setIndex(e.localHeaderOffset),this.checkSignature(r.LOCAL_FILE_HEADER),e.readLocalPart(this.reader),e.handleUTF8(),e.processAttributes()},readCentralDir:function(){var t;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(r.CENTRAL_FILE_HEADER);)(t=new o({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(t);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 t=this.reader.lastIndexOfSignature(r.CENTRAL_DIRECTORY_END);if(t<0)throw this.isSignature(0,r.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(t);var e=t;if(this.checkSignature(r.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===n.MAX_VALUE_16BITS||this.diskWithCentralDirStart===n.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===n.MAX_VALUE_16BITS||this.centralDirRecords===n.MAX_VALUE_16BITS||this.centralDirSize===n.MAX_VALUE_32BITS||this.centralDirOffset===n.MAX_VALUE_32BITS){if(this.zip64=!0,(t=this.reader.lastIndexOfSignature(r.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(t),this.checkSignature(r.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,r.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(r.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(r.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var i=this.centralDirOffset+this.centralDirSize;this.zip64&&(i+=20,i+=12+this.zip64EndOfCentralSize);var s=e-i;if(0<s)this.isSignature(e,r.CENTRAL_FILE_HEADER)||(this.reader.zero=s);else if(s<0)throw new Error("Corrupted zip: missing "+Math.abs(s)+" bytes.")},prepareReader:function(t){this.reader=s(t)},load:function(t){this.prepareReader(t),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},e.exports=l},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(t,e,i){var s=t("./reader/readerFor"),n=t("./utils"),r=t("./compressedObject"),o=t("./crc32"),a=t("./utf8"),l=t("./compressions"),h=t("./support");function c(t,e){this.options=t,this.loadOptions=e}c.prototype={isEncrypted:function(){return!(1&~this.bitFlag)},useUTF8:function(){return!(2048&~this.bitFlag)},readLocalPart:function(t){var e,i;if(t.skip(22),this.fileNameLength=t.readInt(2),i=t.readInt(2),this.fileName=t.readData(this.fileNameLength),t.skip(i),-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===(e=function(t){for(var e in l)if(Object.prototype.hasOwnProperty.call(l,e)&&l[e].magic===t)return l[e];return null}(this.compressionMethod)))throw new Error("Corrupted zip : compression "+n.pretty(this.compressionMethod)+" unknown (inner file : "+n.transformTo("string",this.fileName)+")");this.decompressed=new r(this.compressedSize,this.uncompressedSize,this.crc32,e,t.readData(this.compressedSize))},readCentralPart:function(t){this.versionMadeBy=t.readInt(2),t.skip(2),this.bitFlag=t.readInt(2),this.compressionMethod=t.readString(2),this.date=t.readDate(),this.crc32=t.readInt(4),this.compressedSize=t.readInt(4),this.uncompressedSize=t.readInt(4);var e=t.readInt(2);if(this.extraFieldsLength=t.readInt(2),this.fileCommentLength=t.readInt(2),this.diskNumberStart=t.readInt(2),this.internalFileAttributes=t.readInt(2),this.externalFileAttributes=t.readInt(4),this.localHeaderOffset=t.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");t.skip(e),this.readExtraFields(t),this.parseZIP64ExtraField(t),this.fileComment=t.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var t=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),0==t&&(this.dosPermissions=63&this.externalFileAttributes),3==t&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||"/"!==this.fileNameStr.slice(-1)||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var t=s(this.extraFields[1].value);this.uncompressedSize===n.MAX_VALUE_32BITS&&(this.uncompressedSize=t.readInt(8)),this.compressedSize===n.MAX_VALUE_32BITS&&(this.compressedSize=t.readInt(8)),this.localHeaderOffset===n.MAX_VALUE_32BITS&&(this.localHeaderOffset=t.readInt(8)),this.diskNumberStart===n.MAX_VALUE_32BITS&&(this.diskNumberStart=t.readInt(4))}},readExtraFields:function(t){var e,i,s,n=t.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});t.index+4<n;)e=t.readInt(2),i=t.readInt(2),s=t.readData(i),this.extraFields[e]={id:e,length:i,value:s};t.setIndex(n)},handleUTF8:function(){var t=h.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=a.utf8decode(this.fileName),this.fileCommentStr=a.utf8decode(this.fileComment);else{var e=this.findExtraFieldUnicodePath();if(null!==e)this.fileNameStr=e;else{var i=n.transformTo(t,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(i)}var s=this.findExtraFieldUnicodeComment();if(null!==s)this.fileCommentStr=s;else{var r=n.transformTo(t,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(r)}}},findExtraFieldUnicodePath:function(){var t=this.extraFields[28789];if(t){var e=s(t.value);return 1!==e.readInt(1)||o(this.fileName)!==e.readInt(4)?null:a.utf8decode(e.readData(t.length-5))}return null},findExtraFieldUnicodeComment:function(){var t=this.extraFields[25461];if(t){var e=s(t.value);return 1!==e.readInt(1)||o(this.fileComment)!==e.readInt(4)?null:a.utf8decode(e.readData(t.length-5))}return null}},e.exports=c},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(t,e,i){function s(t,e,i){this.name=t,this.dir=i.dir,this.date=i.date,this.comment=i.comment,this.unixPermissions=i.unixPermissions,this.dosPermissions=i.dosPermissions,this._data=e,this._dataBinary=i.binary,this.options={compression:i.compression,compressionOptions:i.compressionOptions}}var n=t("./stream/StreamHelper"),r=t("./stream/DataWorker"),o=t("./utf8"),a=t("./compressedObject"),l=t("./stream/GenericWorker");s.prototype={internalStream:function(t){var e=null,i="string";try{if(!t)throw new Error("No output type specified.");var s="string"===(i=t.toLowerCase())||"text"===i;"binarystring"!==i&&"text"!==i||(i="string"),e=this._decompressWorker();var r=!this._dataBinary;r&&!s&&(e=e.pipe(new o.Utf8EncodeWorker)),!r&&s&&(e=e.pipe(new o.Utf8DecodeWorker))}catch(t){(e=new l("error")).error(t)}return new n(e,i,"")},async:function(t,e){return this.internalStream(t).accumulate(e)},nodeStream:function(t,e){return this.internalStream(t||"nodebuffer").toNodejsStream(e)},_compressWorker:function(t,e){if(this._data instanceof a&&this._data.compression.magic===t.magic)return this._data.getCompressedWorker();var i=this._decompressWorker();return this._dataBinary||(i=i.pipe(new o.Utf8EncodeWorker)),a.createWorkerFrom(i,t,e)},_decompressWorker:function(){return this._data instanceof a?this._data.getContentWorker():this._data instanceof l?this._data:new r(this._data)}};for(var h=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],c=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},d=0;d<h.length;d++)s.prototype[h[d]]=c;e.exports=s},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(t,e,i){(function(t){var i,s,n=t.MutationObserver||t.WebKitMutationObserver;if(n){var r=0,o=new n(c),a=t.document.createTextNode("");o.observe(a,{characterData:!0}),i=function(){a.data=r=++r%2}}else if(t.setImmediate||void 0===t.MessageChannel)i="document"in t&&"onreadystatechange"in t.document.createElement("script")?function(){var e=t.document.createElement("script");e.onreadystatechange=function(){c(),e.onreadystatechange=null,e.parentNode.removeChild(e),e=null},t.document.documentElement.appendChild(e)}:function(){setTimeout(c,0)};else{var l=new t.MessageChannel;l.port1.onmessage=c,i=function(){l.port2.postMessage(0)}}var h=[];function c(){var t,e;s=!0;for(var i=h.length;i;){for(e=h,h=[],t=-1;++t<i;)e[t]();i=h.length}s=!1}e.exports=function(t){1!==h.push(t)||s||i()}}).call(this,void 0!==G?G:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],37:[function(t,e,i){var s=t("immediate");function n(){}var r={},o=["REJECTED"],a=["FULFILLED"],l=["PENDING"];function h(t){if("function"!=typeof t)throw new TypeError("resolver must be a function");this.state=l,this.queue=[],this.outcome=void 0,t!==n&&p(this,t)}function c(t,e,i){this.promise=t,"function"==typeof e&&(this.onFulfilled=e,this.callFulfilled=this.otherCallFulfilled),"function"==typeof i&&(this.onRejected=i,this.callRejected=this.otherCallRejected)}function d(t,e,i){s(function(){var s;try{s=e(i)}catch(e){return r.reject(t,e)}s===t?r.reject(t,new TypeError("Cannot resolve promise with itself")):r.resolve(t,s)})}function u(t){var e=t&&t.then;if(t&&("object"==typeof t||"function"==typeof t)&&"function"==typeof e)return function(){e.apply(t,arguments)}}function p(t,e){var i=!1;function s(e){i||(i=!0,r.reject(t,e))}function n(e){i||(i=!0,r.resolve(t,e))}var o=f(function(){e(n,s)});"error"===o.status&&s(o.value)}function f(t,e){var i={};try{i.value=t(e),i.status="success"}catch(t){i.status="error",i.value=t}return i}(e.exports=h).prototype.finally=function(t){if("function"!=typeof t)return this;var e=this.constructor;return this.then(function(i){return e.resolve(t()).then(function(){return i})},function(i){return e.resolve(t()).then(function(){throw i})})},h.prototype.catch=function(t){return this.then(null,t)},h.prototype.then=function(t,e){if("function"!=typeof t&&this.state===a||"function"!=typeof e&&this.state===o)return this;var i=new this.constructor(n);return this.state!==l?d(i,this.state===a?t:e,this.outcome):this.queue.push(new c(i,t,e)),i},c.prototype.callFulfilled=function(t){r.resolve(this.promise,t)},c.prototype.otherCallFulfilled=function(t){d(this.promise,this.onFulfilled,t)},c.prototype.callRejected=function(t){r.reject(this.promise,t)},c.prototype.otherCallRejected=function(t){d(this.promise,this.onRejected,t)},r.resolve=function(t,e){var i=f(u,e);if("error"===i.status)return r.reject(t,i.value);var s=i.value;if(s)p(t,s);else{t.state=a,t.outcome=e;for(var n=-1,o=t.queue.length;++n<o;)t.queue[n].callFulfilled(e)}return t},r.reject=function(t,e){t.state=o,t.outcome=e;for(var i=-1,s=t.queue.length;++i<s;)t.queue[i].callRejected(e);return t},h.resolve=function(t){return t instanceof this?t:r.resolve(new this(n),t)},h.reject=function(t){var e=new this(n);return r.reject(e,t)},h.all=function(t){var e=this;if("[object Array]"!==Object.prototype.toString.call(t))return this.reject(new TypeError("must be an array"));var i=t.length,s=!1;if(!i)return this.resolve([]);for(var o=new Array(i),a=0,l=-1,h=new this(n);++l<i;)c(t[l],l);return h;function c(t,n){e.resolve(t).then(function(t){o[n]=t,++a!==i||s||(s=!0,r.resolve(h,o))},function(t){s||(s=!0,r.reject(h,t))})}},h.race=function(t){var e=this;if("[object Array]"!==Object.prototype.toString.call(t))return this.reject(new TypeError("must be an array"));var i=t.length,s=!1;if(!i)return this.resolve([]);for(var o,a=-1,l=new this(n);++a<i;)o=t[a],e.resolve(o).then(function(t){s||(s=!0,r.resolve(l,t))},function(t){s||(s=!0,r.reject(l,t))});return l}},{immediate:36}],38:[function(t,e,i){var s={};(0,t("./lib/utils/common").assign)(s,t("./lib/deflate"),t("./lib/inflate"),t("./lib/zlib/constants")),e.exports=s},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(t,e,i){var s=t("./zlib/deflate"),n=t("./utils/common"),r=t("./utils/strings"),o=t("./zlib/messages"),a=t("./zlib/zstream"),l=Object.prototype.toString,h=0,c=-1,d=0,u=8;function p(t){if(!(this instanceof p))return new p(t);this.options=n.assign({level:c,method:u,chunkSize:16384,windowBits:15,memLevel:8,strategy:d,to:""},t||{});var e=this.options;e.raw&&0<e.windowBits?e.windowBits=-e.windowBits:e.gzip&&0<e.windowBits&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new a,this.strm.avail_out=0;var i=s.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(i!==h)throw new Error(o[i]);if(e.header&&s.deflateSetHeader(this.strm,e.header),e.dictionary){var f;if(f="string"==typeof e.dictionary?r.string2buf(e.dictionary):"[object ArrayBuffer]"===l.call(e.dictionary)?new Uint8Array(e.dictionary):e.dictionary,(i=s.deflateSetDictionary(this.strm,f))!==h)throw new Error(o[i]);this._dict_set=!0}}function f(t,e){var i=new p(e);if(i.push(t,!0),i.err)throw i.msg||o[i.err];return i.result}p.prototype.push=function(t,e){var i,o,a=this.strm,c=this.options.chunkSize;if(this.ended)return!1;o=e===~~e?e:!0===e?4:0,"string"==typeof t?a.input=r.string2buf(t):"[object ArrayBuffer]"===l.call(t)?a.input=new Uint8Array(t):a.input=t,a.next_in=0,a.avail_in=a.input.length;do{if(0===a.avail_out&&(a.output=new n.Buf8(c),a.next_out=0,a.avail_out=c),1!==(i=s.deflate(a,o))&&i!==h)return this.onEnd(i),!(this.ended=!0);0!==a.avail_out&&(0!==a.avail_in||4!==o&&2!==o)||("string"===this.options.to?this.onData(r.buf2binstring(n.shrinkBuf(a.output,a.next_out))):this.onData(n.shrinkBuf(a.output,a.next_out)))}while((0<a.avail_in||0===a.avail_out)&&1!==i);return 4===o?(i=s.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===h):2!==o||(this.onEnd(h),!(a.avail_out=0))},p.prototype.onData=function(t){this.chunks.push(t)},p.prototype.onEnd=function(t){t===h&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=n.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg},i.Deflate=p,i.deflate=f,i.deflateRaw=function(t,e){return(e=e||{}).raw=!0,f(t,e)},i.gzip=function(t,e){return(e=e||{}).gzip=!0,f(t,e)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(t,e,i){var s=t("./zlib/inflate"),n=t("./utils/common"),r=t("./utils/strings"),o=t("./zlib/constants"),a=t("./zlib/messages"),l=t("./zlib/zstream"),h=t("./zlib/gzheader"),c=Object.prototype.toString;function d(t){if(!(this instanceof d))return new d(t);this.options=n.assign({chunkSize:16384,windowBits:0,to:""},t||{});var e=this.options;e.raw&&0<=e.windowBits&&e.windowBits<16&&(e.windowBits=-e.windowBits,0===e.windowBits&&(e.windowBits=-15)),!(0<=e.windowBits&&e.windowBits<16)||t&&t.windowBits||(e.windowBits+=32),15<e.windowBits&&e.windowBits<48&&!(15&e.windowBits)&&(e.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new l,this.strm.avail_out=0;var i=s.inflateInit2(this.strm,e.windowBits);if(i!==o.Z_OK)throw new Error(a[i]);this.header=new h,s.inflateGetHeader(this.strm,this.header)}function u(t,e){var i=new d(e);if(i.push(t,!0),i.err)throw i.msg||a[i.err];return i.result}d.prototype.push=function(t,e){var i,a,l,h,d,u,p=this.strm,f=this.options.chunkSize,m=this.options.dictionary,g=!1;if(this.ended)return!1;a=e===~~e?e:!0===e?o.Z_FINISH:o.Z_NO_FLUSH,"string"==typeof t?p.input=r.binstring2buf(t):"[object ArrayBuffer]"===c.call(t)?p.input=new Uint8Array(t):p.input=t,p.next_in=0,p.avail_in=p.input.length;do{if(0===p.avail_out&&(p.output=new n.Buf8(f),p.next_out=0,p.avail_out=f),(i=s.inflate(p,o.Z_NO_FLUSH))===o.Z_NEED_DICT&&m&&(u="string"==typeof m?r.string2buf(m):"[object ArrayBuffer]"===c.call(m)?new Uint8Array(m):m,i=s.inflateSetDictionary(this.strm,u)),i===o.Z_BUF_ERROR&&!0===g&&(i=o.Z_OK,g=!1),i!==o.Z_STREAM_END&&i!==o.Z_OK)return this.onEnd(i),!(this.ended=!0);p.next_out&&(0!==p.avail_out&&i!==o.Z_STREAM_END&&(0!==p.avail_in||a!==o.Z_FINISH&&a!==o.Z_SYNC_FLUSH)||("string"===this.options.to?(l=r.utf8border(p.output,p.next_out),h=p.next_out-l,d=r.buf2string(p.output,l),p.next_out=h,p.avail_out=f-h,h&&n.arraySet(p.output,p.output,l,h,0),this.onData(d)):this.onData(n.shrinkBuf(p.output,p.next_out)))),0===p.avail_in&&0===p.avail_out&&(g=!0)}while((0<p.avail_in||0===p.avail_out)&&i!==o.Z_STREAM_END);return i===o.Z_STREAM_END&&(a=o.Z_FINISH),a===o.Z_FINISH?(i=s.inflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===o.Z_OK):a!==o.Z_SYNC_FLUSH||(this.onEnd(o.Z_OK),!(p.avail_out=0))},d.prototype.onData=function(t){this.chunks.push(t)},d.prototype.onEnd=function(t){t===o.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=n.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg},i.Inflate=d,i.inflate=u,i.inflateRaw=function(t,e){return(e=e||{}).raw=!0,u(t,e)},i.ungzip=u},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(t,e,i){var s="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;i.assign=function(t){for(var e=Array.prototype.slice.call(arguments,1);e.length;){var i=e.shift();if(i){if("object"!=typeof i)throw new TypeError(i+"must be non-object");for(var s in i)i.hasOwnProperty(s)&&(t[s]=i[s])}}return t},i.shrinkBuf=function(t,e){return t.length===e?t:t.subarray?t.subarray(0,e):(t.length=e,t)};var n={arraySet:function(t,e,i,s,n){if(e.subarray&&t.subarray)t.set(e.subarray(i,i+s),n);else for(var r=0;r<s;r++)t[n+r]=e[i+r]},flattenChunks:function(t){var e,i,s,n,r,o;for(e=s=0,i=t.length;e<i;e++)s+=t[e].length;for(o=new Uint8Array(s),e=n=0,i=t.length;e<i;e++)r=t[e],o.set(r,n),n+=r.length;return o}},r={arraySet:function(t,e,i,s,n){for(var r=0;r<s;r++)t[n+r]=e[i+r]},flattenChunks:function(t){return[].concat.apply([],t)}};i.setTyped=function(t){t?(i.Buf8=Uint8Array,i.Buf16=Uint16Array,i.Buf32=Int32Array,i.assign(i,n)):(i.Buf8=Array,i.Buf16=Array,i.Buf32=Array,i.assign(i,r))},i.setTyped(s)},{}],42:[function(t,e,i){var s=t("./common"),n=!0,r=!0;try{String.fromCharCode.apply(null,[0])}catch(t){n=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(t){r=!1}for(var o=new s.Buf8(256),a=0;a<256;a++)o[a]=252<=a?6:248<=a?5:240<=a?4:224<=a?3:192<=a?2:1;function l(t,e){if(e<65537&&(t.subarray&&r||!t.subarray&&n))return String.fromCharCode.apply(null,s.shrinkBuf(t,e));for(var i="",o=0;o<e;o++)i+=String.fromCharCode(t[o]);return i}o[254]=o[254]=1,i.string2buf=function(t){var e,i,n,r,o,a=t.length,l=0;for(r=0;r<a;r++)55296==(64512&(i=t.charCodeAt(r)))&&r+1<a&&56320==(64512&(n=t.charCodeAt(r+1)))&&(i=65536+(i-55296<<10)+(n-56320),r++),l+=i<128?1:i<2048?2:i<65536?3:4;for(e=new s.Buf8(l),r=o=0;o<l;r++)55296==(64512&(i=t.charCodeAt(r)))&&r+1<a&&56320==(64512&(n=t.charCodeAt(r+1)))&&(i=65536+(i-55296<<10)+(n-56320),r++),i<128?e[o++]=i:(i<2048?e[o++]=192|i>>>6:(i<65536?e[o++]=224|i>>>12:(e[o++]=240|i>>>18,e[o++]=128|i>>>12&63),e[o++]=128|i>>>6&63),e[o++]=128|63&i);return e},i.buf2binstring=function(t){return l(t,t.length)},i.binstring2buf=function(t){for(var e=new s.Buf8(t.length),i=0,n=e.length;i<n;i++)e[i]=t.charCodeAt(i);return e},i.buf2string=function(t,e){var i,s,n,r,a=e||t.length,h=new Array(2*a);for(i=s=0;i<a;)if((n=t[i++])<128)h[s++]=n;else if(4<(r=o[n]))h[s++]=65533,i+=r-1;else{for(n&=2===r?31:3===r?15:7;1<r&&i<a;)n=n<<6|63&t[i++],r--;1<r?h[s++]=65533:n<65536?h[s++]=n:(n-=65536,h[s++]=55296|n>>10&1023,h[s++]=56320|1023&n)}return l(h,s)},i.utf8border=function(t,e){var i;for((e=e||t.length)>t.length&&(e=t.length),i=e-1;0<=i&&128==(192&t[i]);)i--;return i<0||0===i?e:i+o[t[i]]>e?i:e}},{"./common":41}],43:[function(t,e,i){e.exports=function(t,e,i,s){for(var n=65535&t,r=t>>>16&65535,o=0;0!==i;){for(i-=o=2e3<i?2e3:i;r=r+(n=n+e[s++]|0)|0,--o;);n%=65521,r%=65521}return n|r<<16}},{}],44:[function(t,e,i){e.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,e,i){var s=function(){for(var t,e=[],i=0;i<256;i++){t=i;for(var s=0;s<8;s++)t=1&t?3988292384^t>>>1:t>>>1;e[i]=t}return e}();e.exports=function(t,e,i,n){var r=s,o=n+i;t^=-1;for(var a=n;a<o;a++)t=t>>>8^r[255&(t^e[a])];return-1^t}},{}],46:[function(t,e,i){var s,n=t("../utils/common"),r=t("./trees"),o=t("./adler32"),a=t("./crc32"),l=t("./messages"),h=0,c=4,d=0,u=-2,p=-1,f=4,m=2,g=8,_=9,y=286,w=30,v=19,b=2*y+1,x=15,E=3,T=258,C=T+E+1,S=42,A=113,O=1,P=2,I=3,k=4;function D(t,e){return t.msg=l[e],e}function z(t){return(t<<1)-(4<t?9:0)}function M(t){for(var e=t.length;0<=--e;)t[e]=0}function B(t){var e=t.state,i=e.pending;i>t.avail_out&&(i=t.avail_out),0!==i&&(n.arraySet(t.output,e.pending_buf,e.pending_out,i,t.next_out),t.next_out+=i,e.pending_out+=i,t.total_out+=i,t.avail_out-=i,e.pending-=i,0===e.pending&&(e.pending_out=0))}function N(t,e){r._tr_flush_block(t,0<=t.block_start?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,B(t.strm)}function U(t,e){t.pending_buf[t.pending++]=e}function L(t,e){t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e}function R(t,e){var i,s,n=t.max_chain_length,r=t.strstart,o=t.prev_length,a=t.nice_match,l=t.strstart>t.w_size-C?t.strstart-(t.w_size-C):0,h=t.window,c=t.w_mask,d=t.prev,u=t.strstart+T,p=h[r+o-1],f=h[r+o];t.prev_length>=t.good_match&&(n>>=2),a>t.lookahead&&(a=t.lookahead);do{if(h[(i=e)+o]===f&&h[i+o-1]===p&&h[i]===h[r]&&h[++i]===h[r+1]){r+=2,i++;do{}while(h[++r]===h[++i]&&h[++r]===h[++i]&&h[++r]===h[++i]&&h[++r]===h[++i]&&h[++r]===h[++i]&&h[++r]===h[++i]&&h[++r]===h[++i]&&h[++r]===h[++i]&&r<u);if(s=T-(u-r),r=u-T,o<s){if(t.match_start=e,a<=(o=s))break;p=h[r+o-1],f=h[r+o]}}}while((e=d[e&c])>l&&0!=--n);return o<=t.lookahead?o:t.lookahead}function F(t){var e,i,s,r,l,h,c,d,u,p,f=t.w_size;do{if(r=t.window_size-t.lookahead-t.strstart,t.strstart>=f+(f-C)){for(n.arraySet(t.window,t.window,f,f,0),t.match_start-=f,t.strstart-=f,t.block_start-=f,e=i=t.hash_size;s=t.head[--e],t.head[e]=f<=s?s-f:0,--i;);for(e=i=f;s=t.prev[--e],t.prev[e]=f<=s?s-f:0,--i;);r+=f}if(0===t.strm.avail_in)break;if(h=t.strm,c=t.window,d=t.strstart+t.lookahead,p=void 0,(u=r)<(p=h.avail_in)&&(p=u),i=0===p?0:(h.avail_in-=p,n.arraySet(c,h.input,h.next_in,p,d),1===h.state.wrap?h.adler=o(h.adler,c,p,d):2===h.state.wrap&&(h.adler=a(h.adler,c,p,d)),h.next_in+=p,h.total_in+=p,p),t.lookahead+=i,t.lookahead+t.insert>=E)for(l=t.strstart-t.insert,t.ins_h=t.window[l],t.ins_h=(t.ins_h<<t.hash_shift^t.window[l+1])&t.hash_mask;t.insert&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[l+E-1])&t.hash_mask,t.prev[l&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=l,l++,t.insert--,!(t.lookahead+t.insert<E)););}while(t.lookahead<C&&0!==t.strm.avail_in)}function V(t,e){for(var i,s;;){if(t.lookahead<C){if(F(t),t.lookahead<C&&e===h)return O;if(0===t.lookahead)break}if(i=0,t.lookahead>=E&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+E-1])&t.hash_mask,i=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),0!==i&&t.strstart-i<=t.w_size-C&&(t.match_length=R(t,i)),t.match_length>=E)if(s=r._tr_tally(t,t.strstart-t.match_start,t.match_length-E),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=E){for(t.match_length--;t.strstart++,t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+E-1])&t.hash_mask,i=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart,0!=--t.match_length;);t.strstart++}else t.strstart+=t.match_length,t.match_length=0,t.ins_h=t.window[t.strstart],t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+1])&t.hash_mask;else s=r._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(s&&(N(t,!1),0===t.strm.avail_out))return O}return t.insert=t.strstart<E-1?t.strstart:E-1,e===c?(N(t,!0),0===t.strm.avail_out?I:k):t.last_lit&&(N(t,!1),0===t.strm.avail_out)?O:P}function j(t,e){for(var i,s,n;;){if(t.lookahead<C){if(F(t),t.lookahead<C&&e===h)return O;if(0===t.lookahead)break}if(i=0,t.lookahead>=E&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+E-1])&t.hash_mask,i=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),t.prev_length=t.match_length,t.prev_match=t.match_start,t.match_length=E-1,0!==i&&t.prev_length<t.max_lazy_match&&t.strstart-i<=t.w_size-C&&(t.match_length=R(t,i),t.match_length<=5&&(1===t.strategy||t.match_length===E&&4096<t.strstart-t.match_start)&&(t.match_length=E-1)),t.prev_length>=E&&t.match_length<=t.prev_length){for(n=t.strstart+t.lookahead-E,s=r._tr_tally(t,t.strstart-1-t.prev_match,t.prev_length-E),t.lookahead-=t.prev_length-1,t.prev_length-=2;++t.strstart<=n&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+E-1])&t.hash_mask,i=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),0!=--t.prev_length;);if(t.match_available=0,t.match_length=E-1,t.strstart++,s&&(N(t,!1),0===t.strm.avail_out))return O}else if(t.match_available){if((s=r._tr_tally(t,0,t.window[t.strstart-1]))&&N(t,!1),t.strstart++,t.lookahead--,0===t.strm.avail_out)return O}else t.match_available=1,t.strstart++,t.lookahead--}return t.match_available&&(s=r._tr_tally(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<E-1?t.strstart:E-1,e===c?(N(t,!0),0===t.strm.avail_out?I:k):t.last_lit&&(N(t,!1),0===t.strm.avail_out)?O:P}function Z(t,e,i,s,n){this.good_length=t,this.max_lazy=e,this.nice_length=i,this.max_chain=s,this.func=n}function H(){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=g,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 n.Buf16(2*b),this.dyn_dtree=new n.Buf16(2*(2*w+1)),this.bl_tree=new n.Buf16(2*(2*v+1)),M(this.dyn_ltree),M(this.dyn_dtree),M(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new n.Buf16(x+1),this.heap=new n.Buf16(2*y+1),M(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new n.Buf16(2*y+1),M(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 $(t){var e;return t&&t.state?(t.total_in=t.total_out=0,t.data_type=m,(e=t.state).pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=e.wrap?S:A,t.adler=2===e.wrap?0:1,e.last_flush=h,r._tr_init(e),d):D(t,u)}function W(t){var e,i=$(t);return i===d&&((e=t.state).window_size=2*e.w_size,M(e.head),e.max_lazy_match=s[e.level].max_lazy,e.good_match=s[e.level].good_length,e.nice_match=s[e.level].nice_length,e.max_chain_length=s[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=E-1,e.match_available=0,e.ins_h=0),i}function Y(t,e,i,s,r,o){if(!t)return u;var a=1;if(e===p&&(e=6),s<0?(a=0,s=-s):15<s&&(a=2,s-=16),r<1||_<r||i!==g||s<8||15<s||e<0||9<e||o<0||f<o)return D(t,u);8===s&&(s=9);var l=new H;return(t.state=l).strm=t,l.wrap=a,l.gzhead=null,l.w_bits=s,l.w_size=1<<l.w_bits,l.w_mask=l.w_size-1,l.hash_bits=r+7,l.hash_size=1<<l.hash_bits,l.hash_mask=l.hash_size-1,l.hash_shift=~~((l.hash_bits+E-1)/E),l.window=new n.Buf8(2*l.w_size),l.head=new n.Buf16(l.hash_size),l.prev=new n.Buf16(l.w_size),l.lit_bufsize=1<<r+6,l.pending_buf_size=4*l.lit_bufsize,l.pending_buf=new n.Buf8(l.pending_buf_size),l.d_buf=1*l.lit_bufsize,l.l_buf=3*l.lit_bufsize,l.level=e,l.strategy=o,l.method=i,W(t)}s=[new Z(0,0,0,0,function(t,e){var i=65535;for(i>t.pending_buf_size-5&&(i=t.pending_buf_size-5);;){if(t.lookahead<=1){if(F(t),0===t.lookahead&&e===h)return O;if(0===t.lookahead)break}t.strstart+=t.lookahead,t.lookahead=0;var s=t.block_start+i;if((0===t.strstart||t.strstart>=s)&&(t.lookahead=t.strstart-s,t.strstart=s,N(t,!1),0===t.strm.avail_out))return O;if(t.strstart-t.block_start>=t.w_size-C&&(N(t,!1),0===t.strm.avail_out))return O}return t.insert=0,e===c?(N(t,!0),0===t.strm.avail_out?I:k):(t.strstart>t.block_start&&(N(t,!1),t.strm.avail_out),O)}),new Z(4,4,8,4,V),new Z(4,5,16,8,V),new Z(4,6,32,32,V),new Z(4,4,16,16,j),new Z(8,16,32,32,j),new Z(8,16,128,128,j),new Z(8,32,128,256,j),new Z(32,128,258,1024,j),new Z(32,258,258,4096,j)],i.deflateInit=function(t,e){return Y(t,e,g,15,8,0)},i.deflateInit2=Y,i.deflateReset=W,i.deflateResetKeep=$,i.deflateSetHeader=function(t,e){return t&&t.state?2!==t.state.wrap?u:(t.state.gzhead=e,d):u},i.deflate=function(t,e){var i,n,o,l;if(!t||!t.state||5<e||e<0)return t?D(t,u):u;if(n=t.state,!t.output||!t.input&&0!==t.avail_in||666===n.status&&e!==c)return D(t,0===t.avail_out?-5:u);if(n.strm=t,i=n.last_flush,n.last_flush=e,n.status===S)if(2===n.wrap)t.adler=0,U(n,31),U(n,139),U(n,8),n.gzhead?(U(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),U(n,255&n.gzhead.time),U(n,n.gzhead.time>>8&255),U(n,n.gzhead.time>>16&255),U(n,n.gzhead.time>>24&255),U(n,9===n.level?2:2<=n.strategy||n.level<2?4:0),U(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(U(n,255&n.gzhead.extra.length),U(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(t.adler=a(t.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69):(U(n,0),U(n,0),U(n,0),U(n,0),U(n,0),U(n,9===n.level?2:2<=n.strategy||n.level<2?4:0),U(n,3),n.status=A);else{var p=g+(n.w_bits-8<<4)<<8;p|=(2<=n.strategy||n.level<2?0:n.level<6?1:6===n.level?2:3)<<6,0!==n.strstart&&(p|=32),p+=31-p%31,n.status=A,L(n,p),0!==n.strstart&&(L(n,t.adler>>>16),L(n,65535&t.adler)),t.adler=1}if(69===n.status)if(n.gzhead.extra){for(o=n.pending;n.gzindex<(65535&n.gzhead.extra.length)&&(n.pending!==n.pending_buf_size||(n.gzhead.hcrc&&n.pending>o&&(t.adler=a(t.adler,n.pending_buf,n.pending-o,o)),B(t),o=n.pending,n.pending!==n.pending_buf_size));)U(n,255&n.gzhead.extra[n.gzindex]),n.gzindex++;n.gzhead.hcrc&&n.pending>o&&(t.adler=a(t.adler,n.pending_buf,n.pending-o,o)),n.gzindex===n.gzhead.extra.length&&(n.gzindex=0,n.status=73)}else n.status=73;if(73===n.status)if(n.gzhead.name){o=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>o&&(t.adler=a(t.adler,n.pending_buf,n.pending-o,o)),B(t),o=n.pending,n.pending===n.pending_buf_size)){l=1;break}l=n.gzindex<n.gzhead.name.length?255&n.gzhead.name.charCodeAt(n.gzindex++):0,U(n,l)}while(0!==l);n.gzhead.hcrc&&n.pending>o&&(t.adler=a(t.adler,n.pending_buf,n.pending-o,o)),0===l&&(n.gzindex=0,n.status=91)}else n.status=91;if(91===n.status)if(n.gzhead.comment){o=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>o&&(t.adler=a(t.adler,n.pending_buf,n.pending-o,o)),B(t),o=n.pending,n.pending===n.pending_buf_size)){l=1;break}l=n.gzindex<n.gzhead.comment.length?255&n.gzhead.comment.charCodeAt(n.gzindex++):0,U(n,l)}while(0!==l);n.gzhead.hcrc&&n.pending>o&&(t.adler=a(t.adler,n.pending_buf,n.pending-o,o)),0===l&&(n.status=103)}else n.status=103;if(103===n.status&&(n.gzhead.hcrc?(n.pending+2>n.pending_buf_size&&B(t),n.pending+2<=n.pending_buf_size&&(U(n,255&t.adler),U(n,t.adler>>8&255),t.adler=0,n.status=A)):n.status=A),0!==n.pending){if(B(t),0===t.avail_out)return n.last_flush=-1,d}else if(0===t.avail_in&&z(e)<=z(i)&&e!==c)return D(t,-5);if(666===n.status&&0!==t.avail_in)return D(t,-5);if(0!==t.avail_in||0!==n.lookahead||e!==h&&666!==n.status){var f=2===n.strategy?function(t,e){for(var i;;){if(0===t.lookahead&&(F(t),0===t.lookahead)){if(e===h)return O;break}if(t.match_length=0,i=r._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,i&&(N(t,!1),0===t.strm.avail_out))return O}return t.insert=0,e===c?(N(t,!0),0===t.strm.avail_out?I:k):t.last_lit&&(N(t,!1),0===t.strm.avail_out)?O:P}(n,e):3===n.strategy?function(t,e){for(var i,s,n,o,a=t.window;;){if(t.lookahead<=T){if(F(t),t.lookahead<=T&&e===h)return O;if(0===t.lookahead)break}if(t.match_length=0,t.lookahead>=E&&0<t.strstart&&(s=a[n=t.strstart-1])===a[++n]&&s===a[++n]&&s===a[++n]){o=t.strstart+T;do{}while(s===a[++n]&&s===a[++n]&&s===a[++n]&&s===a[++n]&&s===a[++n]&&s===a[++n]&&s===a[++n]&&s===a[++n]&&n<o);t.match_length=T-(o-n),t.match_length>t.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=E?(i=r._tr_tally(t,1,t.match_length-E),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(i=r._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),i&&(N(t,!1),0===t.strm.avail_out))return O}return t.insert=0,e===c?(N(t,!0),0===t.strm.avail_out?I:k):t.last_lit&&(N(t,!1),0===t.strm.avail_out)?O:P}(n,e):s[n.level].func(n,e);if(f!==I&&f!==k||(n.status=666),f===O||f===I)return 0===t.avail_out&&(n.last_flush=-1),d;if(f===P&&(1===e?r._tr_align(n):5!==e&&(r._tr_stored_block(n,0,0,!1),3===e&&(M(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),B(t),0===t.avail_out))return n.last_flush=-1,d}return e!==c?d:n.wrap<=0?1:(2===n.wrap?(U(n,255&t.adler),U(n,t.adler>>8&255),U(n,t.adler>>16&255),U(n,t.adler>>24&255),U(n,255&t.total_in),U(n,t.total_in>>8&255),U(n,t.total_in>>16&255),U(n,t.total_in>>24&255)):(L(n,t.adler>>>16),L(n,65535&t.adler)),B(t),0<n.wrap&&(n.wrap=-n.wrap),0!==n.pending?d:1)},i.deflateEnd=function(t){var e;return t&&t.state?(e=t.state.status)!==S&&69!==e&&73!==e&&91!==e&&103!==e&&e!==A&&666!==e?D(t,u):(t.state=null,e===A?D(t,-3):d):u},i.deflateSetDictionary=function(t,e){var i,s,r,a,l,h,c,p,f=e.length;if(!t||!t.state)return u;if(2===(a=(i=t.state).wrap)||1===a&&i.status!==S||i.lookahead)return u;for(1===a&&(t.adler=o(t.adler,e,f,0)),i.wrap=0,f>=i.w_size&&(0===a&&(M(i.head),i.strstart=0,i.block_start=0,i.insert=0),p=new n.Buf8(i.w_size),n.arraySet(p,e,f-i.w_size,i.w_size,0),e=p,f=i.w_size),l=t.avail_in,h=t.next_in,c=t.input,t.avail_in=f,t.next_in=0,t.input=e,F(i);i.lookahead>=E;){for(s=i.strstart,r=i.lookahead-(E-1);i.ins_h=(i.ins_h<<i.hash_shift^i.window[s+E-1])&i.hash_mask,i.prev[s&i.w_mask]=i.head[i.ins_h],i.head[i.ins_h]=s,s++,--r;);i.strstart=s,i.lookahead=E-1,F(i)}return i.strstart+=i.lookahead,i.block_start=i.strstart,i.insert=i.lookahead,i.lookahead=0,i.match_length=i.prev_length=E-1,i.match_available=0,t.next_in=h,t.input=c,t.avail_in=l,i.wrap=a,d},i.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(t,e,i){e.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,e,i){e.exports=function(t,e){var i,s,n,r,o,a,l,h,c,d,u,p,f,m,g,_,y,w,v,b,x,E,T,C,S;i=t.state,s=t.next_in,C=t.input,n=s+(t.avail_in-5),r=t.next_out,S=t.output,o=r-(e-t.avail_out),a=r+(t.avail_out-257),l=i.dmax,h=i.wsize,c=i.whave,d=i.wnext,u=i.window,p=i.hold,f=i.bits,m=i.lencode,g=i.distcode,_=(1<<i.lenbits)-1,y=(1<<i.distbits)-1;t:do{f<15&&(p+=C[s++]<<f,f+=8,p+=C[s++]<<f,f+=8),w=m[p&_];e:for(;;){if(p>>>=v=w>>>24,f-=v,0==(v=w>>>16&255))S[r++]=65535&w;else{if(!(16&v)){if(!(64&v)){w=m[(65535&w)+(p&(1<<v)-1)];continue e}if(32&v){i.mode=12;break t}t.msg="invalid literal/length code",i.mode=30;break t}b=65535&w,(v&=15)&&(f<v&&(p+=C[s++]<<f,f+=8),b+=p&(1<<v)-1,p>>>=v,f-=v),f<15&&(p+=C[s++]<<f,f+=8,p+=C[s++]<<f,f+=8),w=g[p&y];i:for(;;){if(p>>>=v=w>>>24,f-=v,!(16&(v=w>>>16&255))){if(!(64&v)){w=g[(65535&w)+(p&(1<<v)-1)];continue i}t.msg="invalid distance code",i.mode=30;break t}if(x=65535&w,f<(v&=15)&&(p+=C[s++]<<f,(f+=8)<v&&(p+=C[s++]<<f,f+=8)),l<(x+=p&(1<<v)-1)){t.msg="invalid distance too far back",i.mode=30;break t}if(p>>>=v,f-=v,(v=r-o)<x){if(c<(v=x-v)&&i.sane){t.msg="invalid distance too far back",i.mode=30;break t}if(T=u,(E=0)===d){if(E+=h-v,v<b){for(b-=v;S[r++]=u[E++],--v;);E=r-x,T=S}}else if(d<v){if(E+=h+d-v,(v-=d)<b){for(b-=v;S[r++]=u[E++],--v;);if(E=0,d<b){for(b-=v=d;S[r++]=u[E++],--v;);E=r-x,T=S}}}else if(E+=d-v,v<b){for(b-=v;S[r++]=u[E++],--v;);E=r-x,T=S}for(;2<b;)S[r++]=T[E++],S[r++]=T[E++],S[r++]=T[E++],b-=3;b&&(S[r++]=T[E++],1<b&&(S[r++]=T[E++]))}else{for(E=r-x;S[r++]=S[E++],S[r++]=S[E++],S[r++]=S[E++],2<(b-=3););b&&(S[r++]=S[E++],1<b&&(S[r++]=S[E++]))}break}}break}}while(s<n&&r<a);s-=b=f>>3,p&=(1<<(f-=b<<3))-1,t.next_in=s,t.next_out=r,t.avail_in=s<n?n-s+5:5-(s-n),t.avail_out=r<a?a-r+257:257-(r-a),i.hold=p,i.bits=f}},{}],49:[function(t,e,i){var s=t("../utils/common"),n=t("./adler32"),r=t("./crc32"),o=t("./inffast"),a=t("./inftrees"),l=1,h=2,c=0,d=-2,u=1,p=852,f=592;function m(t){return(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24)}function g(){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 s.Buf16(320),this.work=new s.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function _(t){var e;return t&&t.state?(e=t.state,t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=u,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new s.Buf32(p),e.distcode=e.distdyn=new s.Buf32(f),e.sane=1,e.back=-1,c):d}function y(t){var e;return t&&t.state?((e=t.state).wsize=0,e.whave=0,e.wnext=0,_(t)):d}function w(t,e){var i,s;return t&&t.state?(s=t.state,e<0?(i=0,e=-e):(i=1+(e>>4),e<48&&(e&=15)),e&&(e<8||15<e)?d:(null!==s.window&&s.wbits!==e&&(s.window=null),s.wrap=i,s.wbits=e,y(t))):d}function v(t,e){var i,s;return t?(s=new g,(t.state=s).window=null,(i=w(t,e))!==c&&(t.state=null),i):d}var b,x,E=!0;function T(t){if(E){var e;for(b=new s.Buf32(512),x=new s.Buf32(32),e=0;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(a(l,t.lens,0,288,b,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;a(h,t.lens,0,32,x,0,t.work,{bits:5}),E=!1}t.lencode=b,t.lenbits=9,t.distcode=x,t.distbits=5}function C(t,e,i,n){var r,o=t.state;return null===o.window&&(o.wsize=1<<o.wbits,o.wnext=0,o.whave=0,o.window=new s.Buf8(o.wsize)),n>=o.wsize?(s.arraySet(o.window,e,i-o.wsize,o.wsize,0),o.wnext=0,o.whave=o.wsize):(n<(r=o.wsize-o.wnext)&&(r=n),s.arraySet(o.window,e,i-n,r,o.wnext),(n-=r)?(s.arraySet(o.window,e,i-n,n,0),o.wnext=n,o.whave=o.wsize):(o.wnext+=r,o.wnext===o.wsize&&(o.wnext=0),o.whave<o.wsize&&(o.whave+=r))),0}i.inflateReset=y,i.inflateReset2=w,i.inflateResetKeep=_,i.inflateInit=function(t){return v(t,15)},i.inflateInit2=v,i.inflate=function(t,e){var i,p,f,g,_,y,w,v,b,x,E,S,A,O,P,I,k,D,z,M,B,N,U,L,R=0,F=new s.Buf8(4),V=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!t||!t.state||!t.output||!t.input&&0!==t.avail_in)return d;12===(i=t.state).mode&&(i.mode=13),_=t.next_out,f=t.output,w=t.avail_out,g=t.next_in,p=t.input,y=t.avail_in,v=i.hold,b=i.bits,x=y,E=w,N=c;t:for(;;)switch(i.mode){case u:if(0===i.wrap){i.mode=13;break}for(;b<16;){if(0===y)break t;y--,v+=p[g++]<<b,b+=8}if(2&i.wrap&&35615===v){F[i.check=0]=255&v,F[1]=v>>>8&255,i.check=r(i.check,F,2,0),b=v=0,i.mode=2;break}if(i.flags=0,i.head&&(i.head.done=!1),!(1&i.wrap)||(((255&v)<<8)+(v>>8))%31){t.msg="incorrect header check",i.mode=30;break}if(8!=(15&v)){t.msg="unknown compression method",i.mode=30;break}if(b-=4,B=8+(15&(v>>>=4)),0===i.wbits)i.wbits=B;else if(B>i.wbits){t.msg="invalid window size",i.mode=30;break}i.dmax=1<<B,t.adler=i.check=1,i.mode=512&v?10:12,b=v=0;break;case 2:for(;b<16;){if(0===y)break t;y--,v+=p[g++]<<b,b+=8}if(i.flags=v,8!=(255&i.flags)){t.msg="unknown compression method",i.mode=30;break}if(57344&i.flags){t.msg="unknown header flags set",i.mode=30;break}i.head&&(i.head.text=v>>8&1),512&i.flags&&(F[0]=255&v,F[1]=v>>>8&255,i.check=r(i.check,F,2,0)),b=v=0,i.mode=3;case 3:for(;b<32;){if(0===y)break t;y--,v+=p[g++]<<b,b+=8}i.head&&(i.head.time=v),512&i.flags&&(F[0]=255&v,F[1]=v>>>8&255,F[2]=v>>>16&255,F[3]=v>>>24&255,i.check=r(i.check,F,4,0)),b=v=0,i.mode=4;case 4:for(;b<16;){if(0===y)break t;y--,v+=p[g++]<<b,b+=8}i.head&&(i.head.xflags=255&v,i.head.os=v>>8),512&i.flags&&(F[0]=255&v,F[1]=v>>>8&255,i.check=r(i.check,F,2,0)),b=v=0,i.mode=5;case 5:if(1024&i.flags){for(;b<16;){if(0===y)break t;y--,v+=p[g++]<<b,b+=8}i.length=v,i.head&&(i.head.extra_len=v),512&i.flags&&(F[0]=255&v,F[1]=v>>>8&255,i.check=r(i.check,F,2,0)),b=v=0}else i.head&&(i.head.extra=null);i.mode=6;case 6:if(1024&i.flags&&(y<(S=i.length)&&(S=y),S&&(i.head&&(B=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Array(i.head.extra_len)),s.arraySet(i.head.extra,p,g,S,B)),512&i.flags&&(i.check=r(i.check,p,S,g)),y-=S,g+=S,i.length-=S),i.length))break t;i.length=0,i.mode=7;case 7:if(2048&i.flags){if(0===y)break t;for(S=0;B=p[g+S++],i.head&&B&&i.length<65536&&(i.head.name+=String.fromCharCode(B)),B&&S<y;);if(512&i.flags&&(i.check=r(i.check,p,S,g)),y-=S,g+=S,B)break t}else i.head&&(i.head.name=null);i.length=0,i.mode=8;case 8:if(4096&i.flags){if(0===y)break t;for(S=0;B=p[g+S++],i.head&&B&&i.length<65536&&(i.head.comment+=String.fromCharCode(B)),B&&S<y;);if(512&i.flags&&(i.check=r(i.check,p,S,g)),y-=S,g+=S,B)break t}else i.head&&(i.head.comment=null);i.mode=9;case 9:if(512&i.flags){for(;b<16;){if(0===y)break t;y--,v+=p[g++]<<b,b+=8}if(v!==(65535&i.check)){t.msg="header crc mismatch",i.mode=30;break}b=v=0}i.head&&(i.head.hcrc=i.flags>>9&1,i.head.done=!0),t.adler=i.check=0,i.mode=12;break;case 10:for(;b<32;){if(0===y)break t;y--,v+=p[g++]<<b,b+=8}t.adler=i.check=m(v),b=v=0,i.mode=11;case 11:if(0===i.havedict)return t.next_out=_,t.avail_out=w,t.next_in=g,t.avail_in=y,i.hold=v,i.bits=b,2;t.adler=i.check=1,i.mode=12;case 12:if(5===e||6===e)break t;case 13:if(i.last){v>>>=7&b,b-=7&b,i.mode=27;break}for(;b<3;){if(0===y)break t;y--,v+=p[g++]<<b,b+=8}switch(i.last=1&v,b-=1,3&(v>>>=1)){case 0:i.mode=14;break;case 1:if(T(i),i.mode=20,6!==e)break;v>>>=2,b-=2;break t;case 2:i.mode=17;break;case 3:t.msg="invalid block type",i.mode=30}v>>>=2,b-=2;break;case 14:for(v>>>=7&b,b-=7&b;b<32;){if(0===y)break t;y--,v+=p[g++]<<b,b+=8}if((65535&v)!=(v>>>16^65535)){t.msg="invalid stored block lengths",i.mode=30;break}if(i.length=65535&v,b=v=0,i.mode=15,6===e)break t;case 15:i.mode=16;case 16:if(S=i.length){if(y<S&&(S=y),w<S&&(S=w),0===S)break t;s.arraySet(f,p,g,S,_),y-=S,g+=S,w-=S,_+=S,i.length-=S;break}i.mode=12;break;case 17:for(;b<14;){if(0===y)break t;y--,v+=p[g++]<<b,b+=8}if(i.nlen=257+(31&v),v>>>=5,b-=5,i.ndist=1+(31&v),v>>>=5,b-=5,i.ncode=4+(15&v),v>>>=4,b-=4,286<i.nlen||30<i.ndist){t.msg="too many length or distance symbols",i.mode=30;break}i.have=0,i.mode=18;case 18:for(;i.have<i.ncode;){for(;b<3;){if(0===y)break t;y--,v+=p[g++]<<b,b+=8}i.lens[V[i.have++]]=7&v,v>>>=3,b-=3}for(;i.have<19;)i.lens[V[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,U={bits:i.lenbits},N=a(0,i.lens,0,19,i.lencode,0,i.work,U),i.lenbits=U.bits,N){t.msg="invalid code lengths set",i.mode=30;break}i.have=0,i.mode=19;case 19:for(;i.have<i.nlen+i.ndist;){for(;I=(R=i.lencode[v&(1<<i.lenbits)-1])>>>16&255,k=65535&R,!((P=R>>>24)<=b);){if(0===y)break t;y--,v+=p[g++]<<b,b+=8}if(k<16)v>>>=P,b-=P,i.lens[i.have++]=k;else{if(16===k){for(L=P+2;b<L;){if(0===y)break t;y--,v+=p[g++]<<b,b+=8}if(v>>>=P,b-=P,0===i.have){t.msg="invalid bit length repeat",i.mode=30;break}B=i.lens[i.have-1],S=3+(3&v),v>>>=2,b-=2}else if(17===k){for(L=P+3;b<L;){if(0===y)break t;y--,v+=p[g++]<<b,b+=8}b-=P,B=0,S=3+(7&(v>>>=P)),v>>>=3,b-=3}else{for(L=P+7;b<L;){if(0===y)break t;y--,v+=p[g++]<<b,b+=8}b-=P,B=0,S=11+(127&(v>>>=P)),v>>>=7,b-=7}if(i.have+S>i.nlen+i.ndist){t.msg="invalid bit length repeat",i.mode=30;break}for(;S--;)i.lens[i.have++]=B}}if(30===i.mode)break;if(0===i.lens[256]){t.msg="invalid code -- missing end-of-block",i.mode=30;break}if(i.lenbits=9,U={bits:i.lenbits},N=a(l,i.lens,0,i.nlen,i.lencode,0,i.work,U),i.lenbits=U.bits,N){t.msg="invalid literal/lengths set",i.mode=30;break}if(i.distbits=6,i.distcode=i.distdyn,U={bits:i.distbits},N=a(h,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,U),i.distbits=U.bits,N){t.msg="invalid distances set",i.mode=30;break}if(i.mode=20,6===e)break t;case 20:i.mode=21;case 21:if(6<=y&&258<=w){t.next_out=_,t.avail_out=w,t.next_in=g,t.avail_in=y,i.hold=v,i.bits=b,o(t,E),_=t.next_out,f=t.output,w=t.avail_out,g=t.next_in,p=t.input,y=t.avail_in,v=i.hold,b=i.bits,12===i.mode&&(i.back=-1);break}for(i.back=0;I=(R=i.lencode[v&(1<<i.lenbits)-1])>>>16&255,k=65535&R,!((P=R>>>24)<=b);){if(0===y)break t;y--,v+=p[g++]<<b,b+=8}if(I&&!(240&I)){for(D=P,z=I,M=k;I=(R=i.lencode[M+((v&(1<<D+z)-1)>>D)])>>>16&255,k=65535&R,!(D+(P=R>>>24)<=b);){if(0===y)break t;y--,v+=p[g++]<<b,b+=8}v>>>=D,b-=D,i.back+=D}if(v>>>=P,b-=P,i.back+=P,i.length=k,0===I){i.mode=26;break}if(32&I){i.back=-1,i.mode=12;break}if(64&I){t.msg="invalid literal/length code",i.mode=30;break}i.extra=15&I,i.mode=22;case 22:if(i.extra){for(L=i.extra;b<L;){if(0===y)break t;y--,v+=p[g++]<<b,b+=8}i.length+=v&(1<<i.extra)-1,v>>>=i.extra,b-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=23;case 23:for(;I=(R=i.distcode[v&(1<<i.distbits)-1])>>>16&255,k=65535&R,!((P=R>>>24)<=b);){if(0===y)break t;y--,v+=p[g++]<<b,b+=8}if(!(240&I)){for(D=P,z=I,M=k;I=(R=i.distcode[M+((v&(1<<D+z)-1)>>D)])>>>16&255,k=65535&R,!(D+(P=R>>>24)<=b);){if(0===y)break t;y--,v+=p[g++]<<b,b+=8}v>>>=D,b-=D,i.back+=D}if(v>>>=P,b-=P,i.back+=P,64&I){t.msg="invalid distance code",i.mode=30;break}i.offset=k,i.extra=15&I,i.mode=24;case 24:if(i.extra){for(L=i.extra;b<L;){if(0===y)break t;y--,v+=p[g++]<<b,b+=8}i.offset+=v&(1<<i.extra)-1,v>>>=i.extra,b-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){t.msg="invalid distance too far back",i.mode=30;break}i.mode=25;case 25:if(0===w)break t;if(S=E-w,i.offset>S){if((S=i.offset-S)>i.whave&&i.sane){t.msg="invalid distance too far back",i.mode=30;break}A=S>i.wnext?(S-=i.wnext,i.wsize-S):i.wnext-S,S>i.length&&(S=i.length),O=i.window}else O=f,A=_-i.offset,S=i.length;for(w<S&&(S=w),w-=S,i.length-=S;f[_++]=O[A++],--S;);0===i.length&&(i.mode=21);break;case 26:if(0===w)break t;f[_++]=i.length,w--,i.mode=21;break;case 27:if(i.wrap){for(;b<32;){if(0===y)break t;y--,v|=p[g++]<<b,b+=8}if(E-=w,t.total_out+=E,i.total+=E,E&&(t.adler=i.check=i.flags?r(i.check,f,E,_-E):n(i.check,f,E,_-E)),E=w,(i.flags?v:m(v))!==i.check){t.msg="incorrect data check",i.mode=30;break}b=v=0}i.mode=28;case 28:if(i.wrap&&i.flags){for(;b<32;){if(0===y)break t;y--,v+=p[g++]<<b,b+=8}if(v!==(4294967295&i.total)){t.msg="incorrect length check",i.mode=30;break}b=v=0}i.mode=29;case 29:N=1;break t;case 30:N=-3;break t;case 31:return-4;default:return d}return t.next_out=_,t.avail_out=w,t.next_in=g,t.avail_in=y,i.hold=v,i.bits=b,(i.wsize||E!==t.avail_out&&i.mode<30&&(i.mode<27||4!==e))&&C(t,t.output,t.next_out,E-t.avail_out)?(i.mode=31,-4):(x-=t.avail_in,E-=t.avail_out,t.total_in+=x,t.total_out+=E,i.total+=E,i.wrap&&E&&(t.adler=i.check=i.flags?r(i.check,f,E,t.next_out-E):n(i.check,f,E,t.next_out-E)),t.data_type=i.bits+(i.last?64:0)+(12===i.mode?128:0)+(20===i.mode||15===i.mode?256:0),(0==x&&0===E||4===e)&&N===c&&(N=-5),N)},i.inflateEnd=function(t){if(!t||!t.state)return d;var e=t.state;return e.window&&(e.window=null),t.state=null,c},i.inflateGetHeader=function(t,e){var i;return t&&t.state&&2&(i=t.state).wrap?((i.head=e).done=!1,c):d},i.inflateSetDictionary=function(t,e){var i,s=e.length;return t&&t.state?0!==(i=t.state).wrap&&11!==i.mode?d:11===i.mode&&n(1,e,s,0)!==i.check?-3:C(t,e,s,s)?(i.mode=31,-4):(i.havedict=1,c):d},i.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(t,e,i){var s=t("../utils/common"),n=[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],r=[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],o=[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],a=[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];e.exports=function(t,e,i,l,h,c,d,u){var p,f,m,g,_,y,w,v,b,x=u.bits,E=0,T=0,C=0,S=0,A=0,O=0,P=0,I=0,k=0,D=0,z=null,M=0,B=new s.Buf16(16),N=new s.Buf16(16),U=null,L=0;for(E=0;E<=15;E++)B[E]=0;for(T=0;T<l;T++)B[e[i+T]]++;for(A=x,S=15;1<=S&&0===B[S];S--);if(S<A&&(A=S),0===S)return h[c++]=20971520,h[c++]=20971520,u.bits=1,0;for(C=1;C<S&&0===B[C];C++);for(A<C&&(A=C),E=I=1;E<=15;E++)if(I<<=1,(I-=B[E])<0)return-1;if(0<I&&(0===t||1!==S))return-1;for(N[1]=0,E=1;E<15;E++)N[E+1]=N[E]+B[E];for(T=0;T<l;T++)0!==e[i+T]&&(d[N[e[i+T]]++]=T);if(y=0===t?(z=U=d,19):1===t?(z=n,M-=257,U=r,L-=257,256):(z=o,U=a,-1),E=C,_=c,P=T=D=0,m=-1,g=(k=1<<(O=A))-1,1===t&&852<k||2===t&&592<k)return 1;for(;;){for(w=E-P,b=d[T]<y?(v=0,d[T]):d[T]>y?(v=U[L+d[T]],z[M+d[T]]):(v=96,0),p=1<<E-P,C=f=1<<O;h[_+(D>>P)+(f-=p)]=w<<24|v<<16|b,0!==f;);for(p=1<<E-1;D&p;)p>>=1;if(0!==p?(D&=p-1,D+=p):D=0,T++,0==--B[E]){if(E===S)break;E=e[i+d[T]]}if(A<E&&(D&g)!==m){for(0===P&&(P=A),_+=C,I=1<<(O=E-P);O+P<S&&!((I-=B[O+P])<=0);)O++,I<<=1;if(k+=1<<O,1===t&&852<k||2===t&&592<k)return 1;h[m=D&g]=A<<24|O<<16|_-c}}return 0!==D&&(h[_+D]=E-P<<24|64<<16),u.bits=A,0}},{"../utils/common":41}],51:[function(t,e,i){e.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,e,i){var s=t("../utils/common"),n=0,r=1;function o(t){for(var e=t.length;0<=--e;)t[e]=0}var a=0,l=29,h=256,c=h+1+l,d=30,u=19,p=2*c+1,f=15,m=16,g=7,_=256,y=16,w=17,v=18,b=[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],x=[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],E=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],T=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],C=new Array(2*(c+2));o(C);var S=new Array(2*d);o(S);var A=new Array(512);o(A);var O=new Array(256);o(O);var P=new Array(l);o(P);var I,k,D,z=new Array(d);function M(t,e,i,s,n){this.static_tree=t,this.extra_bits=e,this.extra_base=i,this.elems=s,this.max_length=n,this.has_stree=t&&t.length}function B(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}function N(t){return t<256?A[t]:A[256+(t>>>7)]}function U(t,e){t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255}function L(t,e,i){t.bi_valid>m-i?(t.bi_buf|=e<<t.bi_valid&65535,U(t,t.bi_buf),t.bi_buf=e>>m-t.bi_valid,t.bi_valid+=i-m):(t.bi_buf|=e<<t.bi_valid&65535,t.bi_valid+=i)}function R(t,e,i){L(t,i[2*e],i[2*e+1])}function F(t,e){for(var i=0;i|=1&t,t>>>=1,i<<=1,0<--e;);return i>>>1}function V(t,e,i){var s,n,r=new Array(f+1),o=0;for(s=1;s<=f;s++)r[s]=o=o+i[s-1]<<1;for(n=0;n<=e;n++){var a=t[2*n+1];0!==a&&(t[2*n]=F(r[a]++,a))}}function j(t){var e;for(e=0;e<c;e++)t.dyn_ltree[2*e]=0;for(e=0;e<d;e++)t.dyn_dtree[2*e]=0;for(e=0;e<u;e++)t.bl_tree[2*e]=0;t.dyn_ltree[2*_]=1,t.opt_len=t.static_len=0,t.last_lit=t.matches=0}function Z(t){8<t.bi_valid?U(t,t.bi_buf):0<t.bi_valid&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0}function H(t,e,i,s){var n=2*e,r=2*i;return t[n]<t[r]||t[n]===t[r]&&s[e]<=s[i]}function $(t,e,i){for(var s=t.heap[i],n=i<<1;n<=t.heap_len&&(n<t.heap_len&&H(e,t.heap[n+1],t.heap[n],t.depth)&&n++,!H(e,s,t.heap[n],t.depth));)t.heap[i]=t.heap[n],i=n,n<<=1;t.heap[i]=s}function W(t,e,i){var s,n,r,o,a=0;if(0!==t.last_lit)for(;s=t.pending_buf[t.d_buf+2*a]<<8|t.pending_buf[t.d_buf+2*a+1],n=t.pending_buf[t.l_buf+a],a++,0===s?R(t,n,e):(R(t,(r=O[n])+h+1,e),0!==(o=b[r])&&L(t,n-=P[r],o),R(t,r=N(--s),i),0!==(o=x[r])&&L(t,s-=z[r],o)),a<t.last_lit;);R(t,_,e)}function Y(t,e){var i,s,n,r=e.dyn_tree,o=e.stat_desc.static_tree,a=e.stat_desc.has_stree,l=e.stat_desc.elems,h=-1;for(t.heap_len=0,t.heap_max=p,i=0;i<l;i++)0!==r[2*i]?(t.heap[++t.heap_len]=h=i,t.depth[i]=0):r[2*i+1]=0;for(;t.heap_len<2;)r[2*(n=t.heap[++t.heap_len]=h<2?++h:0)]=1,t.depth[n]=0,t.opt_len--,a&&(t.static_len-=o[2*n+1]);for(e.max_code=h,i=t.heap_len>>1;1<=i;i--)$(t,r,i);for(n=l;i=t.heap[1],t.heap[1]=t.heap[t.heap_len--],$(t,r,1),s=t.heap[1],t.heap[--t.heap_max]=i,t.heap[--t.heap_max]=s,r[2*n]=r[2*i]+r[2*s],t.depth[n]=(t.depth[i]>=t.depth[s]?t.depth[i]:t.depth[s])+1,r[2*i+1]=r[2*s+1]=n,t.heap[1]=n++,$(t,r,1),2<=t.heap_len;);t.heap[--t.heap_max]=t.heap[1],function(t,e){var i,s,n,r,o,a,l=e.dyn_tree,h=e.max_code,c=e.stat_desc.static_tree,d=e.stat_desc.has_stree,u=e.stat_desc.extra_bits,m=e.stat_desc.extra_base,g=e.stat_desc.max_length,_=0;for(r=0;r<=f;r++)t.bl_count[r]=0;for(l[2*t.heap[t.heap_max]+1]=0,i=t.heap_max+1;i<p;i++)g<(r=l[2*l[2*(s=t.heap[i])+1]+1]+1)&&(r=g,_++),l[2*s+1]=r,h<s||(t.bl_count[r]++,o=0,m<=s&&(o=u[s-m]),a=l[2*s],t.opt_len+=a*(r+o),d&&(t.static_len+=a*(c[2*s+1]+o)));if(0!==_){do{for(r=g-1;0===t.bl_count[r];)r--;t.bl_count[r]--,t.bl_count[r+1]+=2,t.bl_count[g]--,_-=2}while(0<_);for(r=g;0!==r;r--)for(s=t.bl_count[r];0!==s;)h<(n=t.heap[--i])||(l[2*n+1]!==r&&(t.opt_len+=(r-l[2*n+1])*l[2*n],l[2*n+1]=r),s--)}}(t,e),V(r,h,t.bl_count)}function X(t,e,i){var s,n,r=-1,o=e[1],a=0,l=7,h=4;for(0===o&&(l=138,h=3),e[2*(i+1)+1]=65535,s=0;s<=i;s++)n=o,o=e[2*(s+1)+1],++a<l&&n===o||(a<h?t.bl_tree[2*n]+=a:0!==n?(n!==r&&t.bl_tree[2*n]++,t.bl_tree[2*y]++):a<=10?t.bl_tree[2*w]++:t.bl_tree[2*v]++,r=n,h=(a=0)===o?(l=138,3):n===o?(l=6,3):(l=7,4))}function q(t,e,i){var s,n,r=-1,o=e[1],a=0,l=7,h=4;for(0===o&&(l=138,h=3),s=0;s<=i;s++)if(n=o,o=e[2*(s+1)+1],!(++a<l&&n===o)){if(a<h)for(;R(t,n,t.bl_tree),0!=--a;);else 0!==n?(n!==r&&(R(t,n,t.bl_tree),a--),R(t,y,t.bl_tree),L(t,a-3,2)):a<=10?(R(t,w,t.bl_tree),L(t,a-3,3)):(R(t,v,t.bl_tree),L(t,a-11,7));r=n,h=(a=0)===o?(l=138,3):n===o?(l=6,3):(l=7,4)}}o(z);var G=!1;function Q(t,e,i,n){var r,o,l;L(t,(a<<1)+(n?1:0),3),o=e,l=i,Z(r=t),U(r,l),U(r,~l),s.arraySet(r.pending_buf,r.window,o,l,r.pending),r.pending+=l}i._tr_init=function(t){G||(function(){var t,e,i,s,n,r=new Array(f+1);for(s=i=0;s<l-1;s++)for(P[s]=i,t=0;t<1<<b[s];t++)O[i++]=s;for(O[i-1]=s,s=n=0;s<16;s++)for(z[s]=n,t=0;t<1<<x[s];t++)A[n++]=s;for(n>>=7;s<d;s++)for(z[s]=n<<7,t=0;t<1<<x[s]-7;t++)A[256+n++]=s;for(e=0;e<=f;e++)r[e]=0;for(t=0;t<=143;)C[2*t+1]=8,t++,r[8]++;for(;t<=255;)C[2*t+1]=9,t++,r[9]++;for(;t<=279;)C[2*t+1]=7,t++,r[7]++;for(;t<=287;)C[2*t+1]=8,t++,r[8]++;for(V(C,c+1,r),t=0;t<d;t++)S[2*t+1]=5,S[2*t]=F(t,5);I=new M(C,b,h+1,c,f),k=new M(S,x,0,d,f),D=new M(new Array(0),E,0,u,g)}(),G=!0),t.l_desc=new B(t.dyn_ltree,I),t.d_desc=new B(t.dyn_dtree,k),t.bl_desc=new B(t.bl_tree,D),t.bi_buf=0,t.bi_valid=0,j(t)},i._tr_stored_block=Q,i._tr_flush_block=function(t,e,i,s){var o,a,l=0;0<t.level?(2===t.strm.data_type&&(t.strm.data_type=function(t){var e,i=4093624447;for(e=0;e<=31;e++,i>>>=1)if(1&i&&0!==t.dyn_ltree[2*e])return n;if(0!==t.dyn_ltree[18]||0!==t.dyn_ltree[20]||0!==t.dyn_ltree[26])return r;for(e=32;e<h;e++)if(0!==t.dyn_ltree[2*e])return r;return n}(t)),Y(t,t.l_desc),Y(t,t.d_desc),l=function(t){var e;for(X(t,t.dyn_ltree,t.l_desc.max_code),X(t,t.dyn_dtree,t.d_desc.max_code),Y(t,t.bl_desc),e=u-1;3<=e&&0===t.bl_tree[2*T[e]+1];e--);return t.opt_len+=3*(e+1)+5+5+4,e}(t),o=t.opt_len+3+7>>>3,(a=t.static_len+3+7>>>3)<=o&&(o=a)):o=a=i+5,i+4<=o&&-1!==e?Q(t,e,i,s):4===t.strategy||a===o?(L(t,2+(s?1:0),3),W(t,C,S)):(L(t,4+(s?1:0),3),function(t,e,i,s){var n;for(L(t,e-257,5),L(t,i-1,5),L(t,s-4,4),n=0;n<s;n++)L(t,t.bl_tree[2*T[n]+1],3);q(t,t.dyn_ltree,e-1),q(t,t.dyn_dtree,i-1)}(t,t.l_desc.max_code+1,t.d_desc.max_code+1,l+1),W(t,t.dyn_ltree,t.dyn_dtree)),j(t),s&&Z(t)},i._tr_tally=function(t,e,i){return t.pending_buf[t.d_buf+2*t.last_lit]=e>>>8&255,t.pending_buf[t.d_buf+2*t.last_lit+1]=255&e,t.pending_buf[t.l_buf+t.last_lit]=255&i,t.last_lit++,0===e?t.dyn_ltree[2*i]++:(t.matches++,e--,t.dyn_ltree[2*(O[i]+h+1)]++,t.dyn_dtree[2*N(e)]++),t.last_lit===t.lit_bufsize-1},i._tr_align=function(t){var e;L(t,2,3),R(t,_,C),16===(e=t).bi_valid?(U(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):8<=e.bi_valid&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)}},{"../utils/common":41}],53:[function(t,e,i){e.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,e,i){(function(t){!function(t,e){if(!t.setImmediate){var i,s,n,r,o=1,a={},l=!1,h=t.document,c=Object.getPrototypeOf&&Object.getPrototypeOf(t);c=c&&c.setTimeout?c:t,i="[object process]"==={}.toString.call(t.process)?function(t){process.nextTick(function(){u(t)})}:function(){if(t.postMessage&&!t.importScripts){var e=!0,i=t.onmessage;return t.onmessage=function(){e=!1},t.postMessage("","*"),t.onmessage=i,e}}()?(r="setImmediate$"+Math.random()+"$",t.addEventListener?t.addEventListener("message",p,!1):t.attachEvent("onmessage",p),function(e){t.postMessage(r+e,"*")}):t.MessageChannel?((n=new MessageChannel).port1.onmessage=function(t){u(t.data)},function(t){n.port2.postMessage(t)}):h&&"onreadystatechange"in h.createElement("script")?(s=h.documentElement,function(t){var e=h.createElement("script");e.onreadystatechange=function(){u(t),e.onreadystatechange=null,s.removeChild(e),e=null},s.appendChild(e)}):function(t){setTimeout(u,0,t)},c.setImmediate=function(t){"function"!=typeof t&&(t=new Function(""+t));for(var e=new Array(arguments.length-1),s=0;s<e.length;s++)e[s]=arguments[s+1];var n={callback:t,args:e};return a[o]=n,i(o),o++},c.clearImmediate=d}function d(t){delete a[t]}function u(t){if(l)setTimeout(u,0,t);else{var i=a[t];if(i){l=!0;try{!function(t){var i=t.callback,s=t.args;switch(s.length){case 0:i();break;case 1:i(s[0]);break;case 2:i(s[0],s[1]);break;case 3:i(s[0],s[1],s[2]);break;default:i.apply(e,s)}}(i)}finally{d(t),l=!1}}}}function p(e){e.source===t&&"string"==typeof e.data&&0===e.data.indexOf(r)&&u(+e.data.slice(r.length))}}("undefined"==typeof self?void 0===t?this:t:self)}).call(this,void 0!==G?G:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[10])(10));class Br{constructor(t,i){e(this,"date",new Date),e(this,"author"),e(this,"guid",q.create()),e(this,"viewpoint"),e(this,"modifiedAuthor"),e(this,"modifiedDate"),e(this,"topic"),e(this,"_components"),e(this,"_comment",""),this._components=t,this._comment=i;const s=this._components.get(Vr);this.author=s.config.author}set comment(t){var e;const i=this._components.get(Vr);this._comment=t,this.modifiedDate=new Date,this.modifiedAuthor=i.config.author,null==(e=this.topic)||e.comments.set(this.guid,this)}get comment(){return this._comment}toJSON(){var t,e;const i={guid:this.guid,date:this.date.toISOString(),author:this.author,comment:this.comment,topic_guid:null==(t=this.topic)?void 0:t.guid,viewpoint_guid:this.viewpoint,modified_date:null==(e=this.modifiedDate)?void 0:e.toISOString(),modified_author:this.modifiedAuthor};for(const[t,e]of Object.entries(i))void 0===e&&delete i[t];return i}}const Nr=class t{constructor(i){e(this,"guid",q.create()),e(this,"title",t.default.title),e(this,"creationDate",new Date),e(this,"creationAuthor",""),e(this,"viewpoints",new Y),e(this,"relatedTopics",new Y),e(this,"comments",new we),e(this,"documentReferences",new Y),e(this,"customData",{}),e(this,"description"),e(this,"serverAssignedId"),e(this,"dueDate"),e(this,"modifiedAuthor"),e(this,"modifiedDate"),e(this,"index"),e(this,"_type",t.default.type),e(this,"_status",t.default.status),e(this,"_priority",t.default.priority),e(this,"_stage",t.default.stage),e(this,"_assignedTo",t.default.assignedTo),e(this,"_labels",t.default.labels??new Set),e(this,"_components"),this._components=i;const s=i.get(Vr);this.creationAuthor=s.config.author,this.relatedTopics.guard=t=>t!==this.guid}set type(t){const e=this._components.get(Vr),{strict:i,types:s}=e.config;(!i||s.has(t))&&(this._type=t)}get type(){return this._type}set status(t){const e=this._components.get(Vr),{strict:i,statuses:s}=e.config;(!i||s.has(t))&&(this._status=t)}get status(){return this._status}set priority(t){const e=this._components.get(Vr);if(t){const{strict:i,priorities:s}=e.config;if(!(!i||s.has(t)))return;this._priority=t}else this._priority=t}get priority(){return this._priority}set stage(t){const e=this._components.get(Vr);if(t){const{strict:i,stages:s}=e.config;if(!(!i||s.has(t)))return;this._stage=t}else this._stage=t}get stage(){return this._stage}set assignedTo(t){const e=this._components.get(Vr);if(t){const{strict:i,users:s}=e.config;if(!(!i||s.has(t)))return;this._assignedTo=t}else this._assignedTo=t}get assignedTo(){return this._assignedTo}set labels(t){const e=this._components.get(Vr),{strict:i,labels:s}=e.config;if(i){const e=new Set;for(const n of t){(!i||s.has(n))&&e.add(n)}this._labels=e}else this._labels=t}get labels(){return this._labels}get _managerVersion(){return this._components.get(Vr).config.version}set(t){const e=t,i=this;for(const s in t){if("guid"===s)continue;const t=e[s];s in this&&(i[s]=t)}return this._components.get(Vr).list.set(this.guid,this),this}createComment(t,e){const i=new Br(this._components,t);return i.viewpoint=e,i.topic=this,this.comments.set(i.guid,i),i}createLabelTags(){const t=[...this.labels];if(this._components.get(Vr).config.exportCustomDataAsLabels)for(const e in this.customData){const i=this.customData[e];"string"==typeof i&&t.push(i)}return t}createCommentTags(){return[...this.comments.values()].map(t=>{var e;return{$Guid:t.guid,Date:t.date.toISOString(),Author:t.author,Comment:t.comment,ModifiedAuthor:t.modifiedAuthor,ModifiedDate:null==(e=t.modifiedDate)?void 0:e.toISOString(),Viewpoint:t.viewpoint?{$Guid:t.viewpoint}:void 0}})}createViewpointTags(){const t=this._components.get(Po);return[...this.viewpoints].map(e=>t.list.get(e)).filter(t=>t).map(e=>{const i={$Guid:e.guid,Viewpoint:`${e.title??e.guid}.bcfv`};if(t.snapshots.get(e.snapshot)){const s=t.getSnapshotExtension(e.snapshot);i.Snapshot=`${e.snapshot}.${s}`}return i})}createRelatedTopicTags(){return[...this.relatedTopics].map(t=>({$Guid:t}))}createDocumentReferencesTag(t=this._managerVersion){const e=[];if("3"!==t&&"2.1"!==t)return e;const i=this._components.get(Vr);for(const s of this.documentReferences){const n=i.documents.get(s);if(!n)continue;let r={$Guid:q.create(),Description:n.description};"2.1"===t&&(r={...r,$isExternal:"external"===n.type||void 0,ReferencedDocument:"external"===n.type?n.url:`../${n.fileName}`}),"3"===t&&(r={...r,DocumentGuid:"internal"===n.type?s:void 0,Url:"external"===n.type?n.url:void 0}),Object.keys(r).length>0&&e.push(r)}return e}toJSON(){var t,e;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==(t=this.modifiedDate)?void 0:t.toISOString(),modified_author:this.modifiedAuthor,assigned_to:this.assignedTo,stage:this.stage,description:this.description,due_date:null==(e=this.dueDate)?void 0:e.toISOString(),comments:[...this.comments].map(([t,e])=>e.toJSON()),relatedTopics:[...this.relatedTopics].map(t=>({related_topic_guid:t}))},s=this._components.get(Po);for(const t of this.viewpoints){const e=s.list.get(t);e&&(i.viewpoints||(i.viewpoints=[]),i.viewpoints.push(e.toJSON()))}const n=this._components.get(Vr);for(const t of this.documentReferences){const e=n.documents.get(t);e&&(i.document_references||(i.document_references=[]),"external"===e.type?i.document_references.push({guid:q.create(),description:e.description,url:e.url}):i.document_references.push({guid:q.create(),description:e.description,document_guid:t}))}for(const[t,e]of Object.entries(i))(void 0===e||Array.isArray(e)&&0===e.length)&&delete i[t];return i}serialize(){var t,e;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==(t=this.modifiedDate)?void 0:t.toISOString(),ModifiedAuthor:this.modifiedAuthor,DueDate:null==(e=this.dueDate)?void 0:e.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 ${ge.builder.build(n)}`}};e(Nr,"default",{title:"BCF Topic",type:"Issue",status:"Active"});let Ur=Nr;const Lr=(t,e)=>{if(""===e.trim())return;const i=Vr.xmlParser.parse(e).Extensions;if(!i)return;const{Priorities:s,TopicStatuses:n,TopicTypes:r,Users:o}=i;if(s&&s.Priority){const e=Array.isArray(s.Priority)?s.Priority:[s.Priority];for(const i of e)t.config.priorities.add(i)}if(n&&n.TopicStatus){const e=Array.isArray(n.TopicStatus)?n.TopicStatus:[n.TopicStatus];for(const i of e)t.config.statuses.add(i)}if(r&&r.TopicType){const e=Array.isArray(r.TopicType)?r.TopicType:[r.TopicType];for(const i of e)t.config.types.add(i)}if(o&&o.User){const e=Array.isArray(o.User)?o.User:[o.User];for(const i of e)t.config.users.add(i)}};class Rr extends xe{constructor(){super(...arguments),e(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(t){this._config.version.value=t}get author(){return this._config.author.value}set author(t){this._config.author.value=t}get types(){return this._config.types.value}set types(t){this._config.types.value=t}get statuses(){return this._config.statuses.value}set statuses(t){this._config.statuses.value=t}get priorities(){return this._config.priorities.value}set priorities(t){this._config.priorities.value=t}get labels(){return this._config.labels.value}set labels(t){this._config.labels.value=t}get stages(){return this._config.stages.value}set stages(t){this._config.stages.value=t}get users(){return this._config.users.value}set users(t){this._config.users.value=t}get includeSelectionTag(){return this._config.includeSelectionTag.value}set includeSelectionTag(t){this._config.includeSelectionTag.value=t}get updateExtensionsOnImport(){return this._config.updateExtensionsOnImport.value}set updateExtensionsOnImport(t){this._config.updateExtensionsOnImport.value=t}get strict(){return this._config.strict.value}set strict(t){this._config.strict.value=t}get includeAllExtensionsOnExport(){return this._config.includeAllExtensionsOnExport.value}set includeAllExtensionsOnExport(t){this._config.includeAllExtensionsOnExport.value=t}get fallbackVersionOnImport(){return this._config.fallbackVersionOnImport.value}set fallbackVersionOnImport(t){this._config.fallbackVersionOnImport.value=t}get ignoreIncompleteTopicsOnImport(){return this._config.ignoreIncompleteTopicsOnImport.value}set ignoreIncompleteTopicsOnImport(t){this._config.ignoreIncompleteTopicsOnImport.value=t}get exportCustomDataAsLabels(){return this._config.exportCustomDataAsLabels.value}set exportCustomDataAsLabels(t){this._config.exportCustomDataAsLabels.value=t}}const Fr=class t extends F{constructor(){super(...arguments),e(this,"enabled",!1),e(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}),e(this,"config",new Rr(this,this.components,"BCF Topics",t.uuid)),e(this,"list",new we),e(this,"documents",new we),e(this,"onSetup",new U),e(this,"isSetup",!1),e(this,"onBCFImported",new U),e(this,"onDisposed",new U)}setup(t){if(this.isSetup)return;const e={...this._defaultConfig,...t};this.config.version=e.version,this.config.author=e.author,this.config.types=e.types,this.config.statuses=e.statuses,this.config.priorities=e.priorities,this.config.labels=e.labels,this.config.stages=e.stages,this.config.users=e.users,this.config.includeSelectionTag=e.includeSelectionTag,this.config.updateExtensionsOnImport=e.updateExtensionsOnImport,this.config.strict=e.strict,this.config.includeAllExtensionsOnExport=e.includeAllExtensionsOnExport,this.config.fallbackVersionOnImport=e.fallbackVersionOnImport||"",this.config.ignoreIncompleteTopicsOnImport=e.ignoreIncompleteTopicsOnImport,this.isSetup=!0,this.enabled=!0,this.onSetup.trigger()}create(t){const e=new Ur(this.components);return t?(e.guid=t.guid??e.guid,e.set(t)):this.list.set(e.guid,e),e}dispose(){this.list.dispose(),this.onDisposed.trigger(),this.onDisposed.reset()}get usedTypes(){const t=[...this.list].map(([t,e])=>e.type);return new Set(t)}get usedStatuses(){const t=[...this.list].map(([t,e])=>e.status);return new Set(t)}get usedPriorities(){const t=[...this.list].map(([t,e])=>e.priority).filter(t=>t);return new Set(t)}get usedStages(){const t=[...this.list].map(([t,e])=>e.stage).filter(t=>t);return new Set(t)}get usedUsers(){const t=[];for(const[e,i]of this.list){t.push(i.creationAuthor),i.assignedTo&&t.push(i.assignedTo),i.modifiedAuthor&&t.push(i.modifiedAuthor);for(const[e,s]of i.comments)t.push(s.author),s.modifiedAuthor&&t.push(s.modifiedAuthor)}return new Set(t)}get usedLabels(){const t=[];for(const[e,i]of this.list)t.push(...i.labels);return new Set(t)}updateExtensions(){for(const[t,e]of this.list){for(const t of e.labels)this.config.labels.add(t);this.config.types.add(e.type),e.priority&&this.config.priorities.add(e.priority),e.stage&&this.config.stages.add(e.stage),this.config.statuses.add(e.status),this.config.users.add(e.creationAuthor),e.assignedTo&&this.config.users.add(e.assignedTo),e.modifiedAuthor&&this.config.users.add(e.modifiedAuthor);for(const[t,i]of e.comments)this.config.users.add(i.author),i.modifiedAuthor&&this.config.users.add(i.modifiedAuthor)}}updateViewpointReferences(){const t=this.components.get(Po);for(const[e,i]of this.list)for(const e of i.viewpoints){t.list.has(e)||i.viewpoints.delete(e)}}async export(t=this.list.values()){const e=new Mr;e.file("bcf.version",`<?xml version="1.0" encoding="UTF-8"?>\n <Version VersionId="${this.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[t,i]of this.documents.entries())"external"!==i.type&&e.file("2.1"===this.config.version?i.fileName:`documents/${t}`,i.data);if("3"===this.config.version){const t=[];for(const[e,i]of this.documents.entries()){const{type:s,description:n}=i;"external"!==s&&t.push(`<Document Guid="${e}">\n <Filename>${i.fileName}</Filename>\n ${n?`<Description>${n}</Description>`:""}\n </Document>`)}t.length>0&&e.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 ${t.join("\n")}\n </Documents>\n </DocumentInfo>`)}e.file("bcf.extensions",this.serializeExtensions());const i=this.components.get(Po);for(const s of t){const t=e.folder(s.guid);t.file("markup.bcf",s.serialize());for(const e of s.viewpoints){const s=i.list.get(e);if(!s)continue;const n=s.title??s.guid;t.file(`${n}.bcfv`,await s.serialize());const r=i.snapshots.get(s.snapshot);if(!r)continue;const o=r?s.snapshot:s.guid,a=i.getSnapshotExtension(s.snapshot);t.file(`${o}.${a}`,r,{binary:!0})}}return await e.generateAsync({type:"blob"})}serializeExtensions(){const t=[...this.config.types].map(t=>`<TopicType>${t}</TopicType>`).join("\n"),e=[...this.config.statuses].map(t=>`<TopicStatus>${t}</TopicStatus>`).join("\n"),i=[...this.config.priorities].map(t=>`<Priority>${t}</Priority>`).join("\n"),s=[...this.config.labels].map(t=>`<TopicLabel>${t}</TopicLabel>`).join("\n"),n=[...this.config.stages].map(t=>`<Stage>${t}</Stage>`).join("\n"),r=[...this.config.users].map(t=>`<User>${t}</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!==t.length?`<TopicTypes>\n${t}\n</TopicTypes>`:""}\n ${0!==e.length?`<TopicStatuses>\n${e}\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(t){const{Guid:e,Date:i,Author:s,Comment:n,Viewpoint:r}=t;if(!(e&&i&&s&&(Br||r)))return null;const o=new Br(this.components,n??"");return o.guid=e,o.date=new Date(i),o.author=s,o.viewpoint=null==r?void 0:r.Guid,o.modifiedAuthor=t.ModifiedAuthor,o.modifiedDate=t.ModifiedDate?new Date(t.ModifiedDate):void 0,o}getMarkupComments(t,e){var i;let s;if("2.1"===e&&(s=t.Comment),"3"===e&&(s=null==(i=t.Topic.Comments)?void 0:i.Comment),!s)return[];s=Array.isArray(s)?s:[s];const n=s.map(t=>this.processMarkupComment(t)).filter(t=>t);return Array.isArray(n)?n:[n]}getMarkupLabels(t,e){var i;let s;if("2.1"===e&&(s=t.Topic.Labels),"3"===e&&(s=null==(i=t.Topic.Labels)?void 0:i.Label),!s)return[];return Array.isArray(s)?s:[s]}getMarkupViewpoints(t,e){var i;let s;return"2.1"===e&&(s=t.Viewpoints),"3"===e&&(s=null==(i=t.Topic.Viewpoints)?void 0:i.ViewPoint),s?(s=Array.isArray(s)?s:[s],s):[]}getMarkupRelatedTopics(t,e){var i;let s;if("2.1"===e&&(s=t.Topic.RelatedTopic),"3"===e&&(s=null==(i=t.Topic.RelatedTopics)?void 0:i.RelatedTopic),!s)return[];return(Array.isArray(s)?s:[s]).map(t=>t.Guid)}getMarkupDocumentReferences(t,e){var i;let s;if("2.1"===e&&(s=t.Topic.DocumentReference),"3"===e&&(s=null==(i=t.Topic.DocumentReferences)?void 0:i.DocumentReference),!s)return[];return Array.isArray(s)?s:[s]}async load(e){var i,s,n;const{fallbackVersionOnImport:o,ignoreIncompleteTopicsOnImport:a,updateExtensionsOnImport:l}=this.config,h=new Mr;await h.loadAsync(e);const c=Object.values(h.files);let d=o;const u=c.find(t=>t.name.endsWith(".version"));if(u){const e=await u.async("string"),i=t.xmlParser.parse(e).Version.VersionId;d=String(i)}if(!d||"2.1"!==d&&"3"!==d)throw new Error(`BCFTopics: ${d} is not supported.`);const p=c.find(t=>t.name.endsWith(".extensions"));if(l&&p){const t=await p.async("string");Lr(this,t)}const f=[],m=this.components.get(Po),g=c.filter(t=>t.name.endsWith(".bcfv"));for(const e of g){const s=await e.async("string"),n=t.xmlParser.parse(s).VisualizationInfo;if(!n){console.warn("Missing VisualizationInfo in Viewpoint");continue}const o={},{Guid:a,ClippingPlanes:l,Components:h,OrthogonalCamera:c,PerspectiveCamera:u}=n;if(a&&(o.guid=a),h){const t={selection:[],coloring:[],visibility:{default_visibility:!1,exceptions:[],view_setup_hints:{spaces_visible:!1,space_boundaries_visible:!1,openings_visible:!1}}};o.components=t;const{Selection:e,Visibility:s}=h;if(e&&e.Component){const i=Array.isArray(e.Component)?e.Component:[e.Component];t.selection=i.map(t=>t.IfcGuid?{ifc_guid:t.IfcGuid}:null).filter(t=>null!==t)}if(s&&"DefaultVisibility"in s&&(t.visibility.default_visibility=s.DefaultVisibility),s&&s.Exceptions&&"Component"in s.Exceptions){const{Component:e}=s.Exceptions,i=Array.isArray(e)?e:[e];t.visibility.exceptions=i.map(t=>t.IfcGuid?{ifc_guid:t.IfcGuid}:null).filter(t=>null!==t)}let n;"2.1"===d&&(n=h.ViewSetupHints),"3"===d&&(n=null==(i=h.Visibility)?void 0:i.ViewSetupHints),n&&("OpeningsVisible"in n&&(t.visibility.view_setup_hints.openings_visible=n.OpeningsVisible),"SpacesVisible"in n&&(t.visibility.view_setup_hints.spaces_visible=n.SpacesVisible),"SpaceBoundariesVisible"in n&&(t.visibility.view_setup_hints.space_boundaries_visible=n.SpaceBoundariesVisible));const{Coloring:r}=h;if(r&&r.Color){const e=Array.isArray(r.Color)?r.Color:[r.Color];for(const i of e){const{Color:e,Component:s}=i;if(6!==e.length&&8!==e.length)continue;const n=6===e.length?e:e.slice(2),r=(Array.isArray(s)?s:[s]).map(t=>t.IfcGuid?{ifc_guid:t.IfcGuid}:null).filter(t=>null!==t);t.coloring.push({color:n,components:r})}}}if(c||u){const t=n.PerspectiveCamera??n.OrthogonalCamera,{CameraViewPoint:e,CameraDirection:i}=t,s=new r.Vector3(Number(e.X),Number(e.Z),Number(-e.Y)),a=new r.Vector3(Number(i.X),Number(i.Z),Number(-i.Y)),l={camera_view_point:{x:s.x,y:s.y,z:s.z},camera_direction:{x:a.x,y:a.y,z:a.z},aspect_ratio:"AspectRatio"in t?t.AspectRatio:1,camera_up_vector:{x:0,y:0,z:0}};"ViewToWorldScale"in t&&(o.orthogonal_camera={...l,view_to_world_scale:t.ViewToWorldScale}),"FieldOfView"in t&&(o.perspective_camera={...l,field_of_view:t.FieldOfView})}if(l){const t=(Array.isArray(l.ClippingPlane)?l.ClippingPlane:[l.ClippingPlane]).map(({Location:t,Direction:e})=>({location:{x:t.x,y:t.y,z:t.z},direction:{x:e.x,y:e.y,z:e.z}}));o.clipping_planes=t}const p=new So(this.components,o);f.push(p)}const _=t=>{const e=t.split("/"),i=e[e.length-1].split(".");return i.pop(),i.join(".")},y=c.filter(t=>t.name.endsWith(".png")||t.name.endsWith(".jpeg"));for(const t of y){const e=_(t.name),i=await t.async("arraybuffer"),s=new Uint8Array(i);m.snapshots.set(e,s)}const w={},v=[],b=c.filter(t=>t.name.endsWith(".bcf"));for(const e of b){const i=await e.async("string"),r=t.xmlParser.parse(i).Markup,o=r.Topic,{Guid:l,TopicType:h,TopicStatus:u,Title:p,CreationDate:f,CreationAuthor:g}=o;if(a&&!(l&&h&&u&&p&&f&&g))continue;const y=new Ur(this.components);y.guid=l??y.guid;const b=this.getMarkupRelatedTopics(r,d);w[y.guid]=new Set(b),y.type=h??y.type,y.status=u??y.status,y.title=p??y.title,y.creationDate=f?new Date(f):y.creationDate,y.creationAuthor=g??y.creationAuthor,y.serverAssignedId=o.ServerAssignedId,y.priority=o.Priority,y.index=o.Index,y.modifiedDate=o.ModifiedDate?new Date(o.ModifiedDate):void 0,y.modifiedAuthor=o.ModifiedAuthor,y.dueDate=o.DueDate?new Date(o.DueDate):void 0,y.assignedTo=o.AssignedTo,y.description=o.Description,y.stage=o.Stage;const x=this.getMarkupLabels(r,d);for(const t of x)y.labels.add(t);const E=this.getMarkupComments(r,d);for(const t of E)y.comments.set(t.guid,t);const T=this.getMarkupViewpoints(r,d);for(const t of T){if(!t||!t.Guid)continue;const e=m.list.get(t.Guid);if(e){y.viewpoints.add(e.guid);const i=_(t.Snapshot);e.snapshot=i??null}}const C=this.getMarkupDocumentReferences(r,d),S=c.find(t=>"documents.xml"===t.name);let A=[];const O=await(null==S?void 0:S.async("string"));if(O){const t=null==(n=null==(s=ge.parser.parse(O).DocumentInfo)?void 0:s.Documents)?void 0:n.Document;A=Array.isArray(t)?t:[t]}for(const t of C){const{Description:e,DocumentGuid:i,Url:s,isExternal:n,ReferencedDocument:r}=t;if(i&&A.length>0){const t=A.find(({Guid:t})=>t===i),e=c.find(t=>t.name.endsWith(i)),s=await(null==e?void 0:e.async("uint8array"));if(!t||!s)continue;const{Description:n,Filename:r}=t;this.documents.set(i,{type:"internal",fileName:r,description:n,data:s}),y.documentReferences.add(i)}if(s){const t=this.documents.add({type:"external",url:s,description:e});y.documentReferences.add(t)}if(r){let t=null;if(n)t=this.documents.add({type:"external",url:r,description:e});else{const i=r.split("/"),s=i[i.length-1],n=c.find(t=>t.name.endsWith(s)),o=await(null==n?void 0:n.async("uint8array"));if(!o)continue;t=this.documents.add({type:"internal",fileName:s,data:o,description:e})}y.documentReferences.add(t)}}this.list.set(y.guid,y),v.push(y)}for(const t in w){const e=this.list.get(t);if(!e)continue;const i=w[t];for(const t of i)e.relatedTopics.add(t)}return this.onBCFImported.trigger(v),{viewpoints:f,topics:v}}};e(Fr,"uuid","de977976-e4f6-4e4f-a01a-204727839802"),e(Fr,"xmlParser",new me.XMLParser({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 Vr=Fr;const jr=new x,Zr=new a,Hr=new a,$r=new b,Wr={X:new a(1,0,0),Y:new a(0,1,0),Z:new a(0,0,1)},Yr={type:"change"},Xr={type:"mouseDown",mode:null},qr={type:"mouseUp",mode:null},Gr={type:"objectChange"};class Qr extends v{constructor(t,e=null){super(void 0,e);const i=new wo(this);this._root=i;const s=new vo;this._gizmo=s,i.add(s);const n=new bo;this._plane=n,i.add(n);const r=this;function o(t,e){let i=e;Object.defineProperty(r,t,{get:function(){return void 0!==i?i:e},set:function(e){i!==e&&(i=e,n[t]=e,s[t]=e,r.dispatchEvent({type:t+"-changed",value:e}),r.dispatchEvent(Yr))}}),r[t]=e,n[t]=e,s[t]=e}o("camera",t),o("object",void 0),o("enabled",!0),o("axis",null),o("mode","translate"),o("translationSnap",null),o("rotationSnap",null),o("scaleSnap",null),o("space","world"),o("size",1),o("dragging",!1),o("showX",!0),o("showY",!0),o("showZ",!0),o("minX",-1/0),o("maxX",1/0),o("minY",-1/0),o("maxY",1/0),o("minZ",-1/0),o("maxZ",1/0);const l=new a,h=new a,c=new b,d=new b,u=new a,p=new b,f=new a,m=new a,g=new a,_=new a;o("worldPosition",l),o("worldPositionStart",h),o("worldQuaternion",c),o("worldQuaternionStart",d),o("cameraPosition",u),o("cameraQuaternion",p),o("pointStart",f),o("pointEnd",m),o("rotationAxis",g),o("rotationAngle",0),o("eye",_),this._offset=new a,this._startNorm=new a,this._endNorm=new a,this._cameraScale=new a,this._parentPosition=new a,this._parentQuaternion=new b,this._parentQuaternionInv=new b,this._parentScale=new a,this._worldScaleStart=new a,this._worldQuaternionInv=new b,this._worldScale=new a,this._positionStart=new a,this._quaternionStart=new b,this._scaleStart=new a,this._getPointer=Kr.bind(this),this._onPointerDown=to.bind(this),this._onPointerHover=Jr.bind(this),this._onPointerMove=eo.bind(this),this._onPointerUp=io.bind(this),null!==e&&this.connect(e)}connect(t){super.connect(t),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(t){if(void 0===this.object||!0===this.dragging)return;null!==t&&jr.setFromCamera(t,this.camera);const e=so(this._gizmo.picker[this.mode],jr);this.axis=e?e.object.name:null}pointerDown(t){if(void 0!==this.object&&!0!==this.dragging&&(null==t||0===t.button)&&null!==this.axis){null!==t&&jr.setFromCamera(t,this.camera);const e=so(this._plane,jr,!0);e&&(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(e.point).sub(this.worldPositionStart)),this.dragging=!0,Xr.mode=this.mode,this.dispatchEvent(Xr)}}pointerMove(t){const e=this.axis,i=this.mode,s=this.object;let n=this.space;if("scale"===i?n="local":"E"!==e&&"XYZE"!==e&&"XYZ"!==e||(n="world"),void 0===s||null===e||!1===this.dragging||null!==t&&-1!==t.button)return;null!==t&&jr.setFromCamera(t,this.camera);const r=so(this._plane,jr,!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"!==e&&this._offset.applyQuaternion(this._worldQuaternionInv),-1===e.indexOf("X")&&(this._offset.x=0),-1===e.indexOf("Y")&&(this._offset.y=0),-1===e.indexOf("Z")&&(this._offset.z=0),"local"===n&&"XYZ"!==e?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($r.copy(this._quaternionStart).invert()),-1!==e.search("X")&&(s.position.x=Math.round(s.position.x/this.translationSnap)*this.translationSnap),-1!==e.search("Y")&&(s.position.y=Math.round(s.position.y/this.translationSnap)*this.translationSnap),-1!==e.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(Zr.setFromMatrixPosition(s.parent.matrixWorld)),-1!==e.search("X")&&(s.position.x=Math.round(s.position.x/this.translationSnap)*this.translationSnap),-1!==e.search("Y")&&(s.position.y=Math.round(s.position.y/this.translationSnap)*this.translationSnap),-1!==e.search("Z")&&(s.position.z=Math.round(s.position.z/this.translationSnap)*this.translationSnap),s.parent&&s.position.sub(Zr.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!==e.search("XYZ")){let t=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(t*=-1),Hr.set(t,t,t)}else Zr.copy(this.pointStart),Hr.copy(this.pointEnd),Zr.applyQuaternion(this._worldQuaternionInv),Hr.applyQuaternion(this._worldQuaternionInv),Hr.divide(Zr),-1===e.search("X")&&(Hr.x=1),-1===e.search("Y")&&(Hr.y=1),-1===e.search("Z")&&(Hr.z=1);s.scale.copy(this._scaleStart).multiply(Hr),this.scaleSnap&&(-1!==e.search("X")&&(s.scale.x=Math.round(s.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),-1!==e.search("Y")&&(s.scale.y=Math.round(s.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),-1!==e.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 t=20/this.worldPosition.distanceTo(Zr.setFromMatrixPosition(this.camera.matrixWorld));let i=!1;"XYZE"===e?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(Zr.copy(this.rotationAxis).cross(this.eye))*t):"X"!==e&&"Y"!==e&&"Z"!==e||(this.rotationAxis.copy(Wr[e]),Zr.copy(Wr[e]),"local"===n&&Zr.applyQuaternion(this.worldQuaternion),Zr.cross(this.eye),0===Zr.length()?i=!0:this.rotationAngle=this._offset.dot(Zr.normalize())*t),("E"===e||i)&&(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"!==e&&"XYZE"!==e?(s.quaternion.copy(this._quaternionStart),s.quaternion.multiply($r.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),s.quaternion.copy($r.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),s.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(Yr),this.dispatchEvent(Gr)}}pointerUp(t){null!==t&&0!==t.button||(this.dragging&&null!==this.axis&&(qr.mode=this.mode,this.dispatchEvent(qr)),this.dragging=!1,this.axis=null)}dispose(){this.disconnect(),this._root.dispose()}attach(t){return this.object=t,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(Yr),this.dispatchEvent(Gr),this.pointStart.copy(this.pointEnd))}getRaycaster(){return jr}getMode(){return this.mode}setMode(t){this.mode=t}setTranslationSnap(t){this.translationSnap=t}setRotationSnap(t){this.rotationSnap=t}setScaleSnap(t){this.scaleSnap=t}setSize(t){this.size=t}setSpace(t){this.space=t}}function Kr(t){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:t.button};{const e=this.domElement.getBoundingClientRect();return{x:(t.clientX-e.left)/e.width*2-1,y:-(t.clientY-e.top)/e.height*2+1,button:t.button}}}function Jr(t){if(this.enabled)switch(t.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(t))}}function to(t){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(t.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(t)),this.pointerDown(this._getPointer(t)))}function eo(t){this.enabled&&this.pointerMove(this._getPointer(t))}function io(t){this.enabled&&(this.domElement.releasePointerCapture(t.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(t)))}function so(t,e,i){const s=e.intersectObject(t,!0);for(let t=0;t<s.length;t++)if(s[t].object.visible||i)return s[t];return!1}const no=new M,ro=new a(0,1,0),oo=new a(0,0,0),ao=new p,lo=new b,ho=new b,co=new a,uo=new p,po=new a(1,0,0),fo=new a(0,1,0),mo=new a(0,0,1),go=new a,_o=new a,yo=new a;class wo extends E{constructor(t){super(),this.isTransformControlsRoot=!0,this.controls=t,this.visible=!1}updateMatrixWorld(t){const e=this.controls;void 0!==e.object&&(e.object.updateMatrixWorld(),null===e.object.parent?console.error("TransformControls: The attached 3D object must be a part of the scene graph."):e.object.parent.matrixWorld.decompose(e._parentPosition,e._parentQuaternion,e._parentScale),e.object.matrixWorld.decompose(e.worldPosition,e.worldQuaternion,e._worldScale),e._parentQuaternionInv.copy(e._parentQuaternion).invert(),e._worldQuaternionInv.copy(e.worldQuaternion).invert()),e.camera.updateMatrixWorld(),e.camera.matrixWorld.decompose(e.cameraPosition,e.cameraQuaternion,e._cameraScale),e.camera.isOrthographicCamera?e.camera.getWorldDirection(e.eye).negate():e.eye.copy(e.cameraPosition).sub(e.worldPosition).normalize(),super.updateMatrixWorld(t)}dispose(){this.traverse(function(t){t.geometry&&t.geometry.dispose(),t.material&&t.material.dispose()})}}class vo extends E{constructor(){super(),this.isTransformControlsGizmo=!0,this.type="TransformControlsGizmo";const t=new T({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),e=new C({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),i=t.clone();i.opacity=.15;const s=e.clone();s.opacity=.5;const n=t.clone();n.color.setHex(16711680);const r=t.clone();r.color.setHex(65280);const o=t.clone();o.color.setHex(255);const a=t.clone();a.color.setHex(16711680),a.opacity=.5;const l=t.clone();l.color.setHex(65280),l.opacity=.5;const h=t.clone();h.color.setHex(255),h.opacity=.5;const c=t.clone();c.opacity=.25;const d=t.clone();d.color.setHex(16776960),d.opacity=.25;t.clone().color.setHex(16776960);const u=t.clone();u.color.setHex(7895160);const p=new S(0,.04,.1,12);p.translate(0,.05,0);const f=new A(.08,.08,.08);f.translate(0,.04,0);const m=new O;m.setAttribute("position",new P([0,0,0,1,0,0],3));const g=new S(.0075,.0075,.5,3);function _(t,e){const i=new D(t,.0075,3,64,e*Math.PI*2);return i.rotateY(Math.PI/2),i.rotateX(Math.PI/2),i}g.translate(0,.25,0);const y={X:[[new w(p,n),[.5,0,0],[0,0,-Math.PI/2]],[new w(p,n),[-.5,0,0],[0,0,Math.PI/2]],[new w(g,n),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new w(p,r),[0,.5,0]],[new w(p,r),[0,-.5,0],[Math.PI,0,0]],[new w(g,r)]],Z:[[new w(p,o),[0,0,.5],[Math.PI/2,0,0]],[new w(p,o),[0,0,-.5],[-Math.PI/2,0,0]],[new w(g,o),null,[Math.PI/2,0,0]]],XYZ:[[new w(new I(.1,0),c.clone()),[0,0,0]]],XY:[[new w(new A(.15,.15,.01),h.clone()),[.15,.15,0]]],YZ:[[new w(new A(.15,.15,.01),a.clone()),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new w(new A(.15,.15,.01),l.clone()),[.15,0,.15],[-Math.PI/2,0,0]]]},v={X:[[new w(new S(.2,0,.6,4),i),[.3,0,0],[0,0,-Math.PI/2]],[new w(new S(.2,0,.6,4),i),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new w(new S(.2,0,.6,4),i),[0,.3,0]],[new w(new S(.2,0,.6,4),i),[0,-.3,0],[0,0,Math.PI]]],Z:[[new w(new S(.2,0,.6,4),i),[0,0,.3],[Math.PI/2,0,0]],[new w(new S(.2,0,.6,4),i),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new w(new I(.2,0),i)]],XY:[[new w(new A(.2,.2,.01),i),[.15,.15,0]]],YZ:[[new w(new A(.2,.2,.01),i),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new w(new A(.2,.2,.01),i),[.15,0,.15],[-Math.PI/2,0,0]]]},b={START:[[new w(new I(.01,2),s),null,null,null,"helper"]],END:[[new w(new I(.01,2),s),null,null,null,"helper"]],DELTA:[[new k(function(){const t=new O;return t.setAttribute("position",new P([0,0,0,1,1,1],3)),t}(),s),null,null,null,"helper"]],X:[[new k(m,s.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new k(m,s.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new k(m,s.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},x={XYZE:[[new w(_(.5,1),u),null,[0,Math.PI/2,0]]],X:[[new w(_(.5,.5),n)]],Y:[[new w(_(.5,.5),r),null,[0,0,-Math.PI/2]]],Z:[[new w(_(.5,.5),o),null,[0,Math.PI/2,0]]],E:[[new w(_(.75,1),d),null,[0,Math.PI/2,0]]]},M={AXIS:[[new k(m,s.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},B={XYZE:[[new w(new z(.25,10,8),i)]],X:[[new w(new D(.5,.1,4,24),i),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new w(new D(.5,.1,4,24),i),[0,0,0],[Math.PI/2,0,0]]],Z:[[new w(new D(.5,.1,4,24),i),[0,0,0],[0,0,-Math.PI/2]]],E:[[new w(new D(.75,.1,2,24),i)]]},N={X:[[new w(f,n),[.5,0,0],[0,0,-Math.PI/2]],[new w(g,n),[0,0,0],[0,0,-Math.PI/2]],[new w(f,n),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new w(f,r),[0,.5,0]],[new w(g,r)],[new w(f,r),[0,-.5,0],[0,0,Math.PI]]],Z:[[new w(f,o),[0,0,.5],[Math.PI/2,0,0]],[new w(g,o),[0,0,0],[Math.PI/2,0,0]],[new w(f,o),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new w(new A(.15,.15,.01),h),[.15,.15,0]]],YZ:[[new w(new A(.15,.15,.01),a),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new w(new A(.15,.15,.01),l),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new w(new A(.1,.1,.1),c.clone())]]},U={X:[[new w(new S(.2,0,.6,4),i),[.3,0,0],[0,0,-Math.PI/2]],[new w(new S(.2,0,.6,4),i),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new w(new S(.2,0,.6,4),i),[0,.3,0]],[new w(new S(.2,0,.6,4),i),[0,-.3,0],[0,0,Math.PI]]],Z:[[new w(new S(.2,0,.6,4),i),[0,0,.3],[Math.PI/2,0,0]],[new w(new S(.2,0,.6,4),i),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new w(new A(.2,.2,.01),i),[.15,.15,0]]],YZ:[[new w(new A(.2,.2,.01),i),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new w(new A(.2,.2,.01),i),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new w(new A(.2,.2,.2),i),[0,0,0]]]},L={X:[[new k(m,s.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new k(m,s.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new k(m,s.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function R(t){const e=new E;for(const i in t)for(let s=t[i].length;s--;){const n=t[i][s][0].clone(),r=t[i][s][1],o=t[i][s][2],a=t[i][s][3],l=t[i][s][4];n.name=i,n.tag=l,r&&n.position.set(r[0],r[1],r[2]),o&&n.rotation.set(o[0],o[1],o[2]),a&&n.scale.set(a[0],a[1],a[2]),n.updateMatrix();const h=n.geometry.clone();h.applyMatrix4(n.matrix),n.geometry=h,n.renderOrder=1/0,n.position.set(0,0,0),n.rotation.set(0,0,0),n.scale.set(1,1,1),e.add(n)}return e}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=R(y)),this.add(this.gizmo.rotate=R(x)),this.add(this.gizmo.scale=R(N)),this.add(this.picker.translate=R(v)),this.add(this.picker.rotate=R(B)),this.add(this.picker.scale=R(U)),this.add(this.helper.translate=R(b)),this.add(this.helper.rotate=R(M)),this.add(this.helper.scale=R(L)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(t){const e="local"===("scale"===this.mode?"local":this.space)?this.worldQuaternion:ho;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 i=[];i=i.concat(this.picker[this.mode].children),i=i.concat(this.gizmo[this.mode].children),i=i.concat(this.helper[this.mode].children);for(let t=0;t<i.length;t++){const s=i[t];let n;if(s.visible=!0,s.rotation.set(0,0,0),s.position.copy(this.worldPosition),n=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),s.scale.set(1,1,1).multiplyScalar(n*this.size/4),"helper"!==s.tag){if(s.quaternion.copy(e),"translate"===this.mode||"scale"===this.mode){const t=.99,i=.2;"X"===s.name&&Math.abs(ro.copy(po).applyQuaternion(e).dot(this.eye))>t&&(s.scale.set(1e-10,1e-10,1e-10),s.visible=!1),"Y"===s.name&&Math.abs(ro.copy(fo).applyQuaternion(e).dot(this.eye))>t&&(s.scale.set(1e-10,1e-10,1e-10),s.visible=!1),"Z"===s.name&&Math.abs(ro.copy(mo).applyQuaternion(e).dot(this.eye))>t&&(s.scale.set(1e-10,1e-10,1e-10),s.visible=!1),"XY"===s.name&&Math.abs(ro.copy(mo).applyQuaternion(e).dot(this.eye))<i&&(s.scale.set(1e-10,1e-10,1e-10),s.visible=!1),"YZ"===s.name&&Math.abs(ro.copy(po).applyQuaternion(e).dot(this.eye))<i&&(s.scale.set(1e-10,1e-10,1e-10),s.visible=!1),"XZ"===s.name&&Math.abs(ro.copy(fo).applyQuaternion(e).dot(this.eye))<i&&(s.scale.set(1e-10,1e-10,1e-10),s.visible=!1)}else"rotate"===this.mode&&(lo.copy(e),ro.copy(this.eye).applyQuaternion($r.copy(e).invert()),-1!==s.name.search("E")&&s.quaternion.setFromRotationMatrix(ao.lookAt(this.eye,oo,fo)),"X"===s.name&&($r.setFromAxisAngle(po,Math.atan2(-ro.y,ro.z)),$r.multiplyQuaternions(lo,$r),s.quaternion.copy($r)),"Y"===s.name&&($r.setFromAxisAngle(fo,Math.atan2(ro.x,ro.z)),$r.multiplyQuaternions(lo,$r),s.quaternion.copy($r)),"Z"===s.name&&($r.setFromAxisAngle(mo,Math.atan2(ro.y,ro.x)),$r.multiplyQuaternions(lo,$r),s.quaternion.copy($r)));s.visible=s.visible&&(-1===s.name.indexOf("X")||this.showX),s.visible=s.visible&&(-1===s.name.indexOf("Y")||this.showY),s.visible=s.visible&&(-1===s.name.indexOf("Z")||this.showZ),s.visible=s.visible&&(-1===s.name.indexOf("E")||this.showX&&this.showY&&this.showZ),s.material._color=s.material._color||s.material.color.clone(),s.material._opacity=s.material._opacity||s.material.opacity,s.material.color.copy(s.material._color),s.material.opacity=s.material._opacity,this.enabled&&this.axis&&(s.name===this.axis||this.axis.split("").some(function(t){return s.name===t}))&&(s.material.color.setHex(16776960),s.material.opacity=1)}else s.visible=!1,"AXIS"===s.name?(s.visible=!!this.axis,"X"===this.axis&&($r.setFromEuler(no.set(0,0,0)),s.quaternion.copy(e).multiply($r),Math.abs(ro.copy(po).applyQuaternion(e).dot(this.eye))>.9&&(s.visible=!1)),"Y"===this.axis&&($r.setFromEuler(no.set(0,0,Math.PI/2)),s.quaternion.copy(e).multiply($r),Math.abs(ro.copy(fo).applyQuaternion(e).dot(this.eye))>.9&&(s.visible=!1)),"Z"===this.axis&&($r.setFromEuler(no.set(0,Math.PI/2,0)),s.quaternion.copy(e).multiply($r),Math.abs(ro.copy(mo).applyQuaternion(e).dot(this.eye))>.9&&(s.visible=!1)),"XYZE"===this.axis&&($r.setFromEuler(no.set(0,Math.PI/2,0)),ro.copy(this.rotationAxis),s.quaternion.setFromRotationMatrix(ao.lookAt(oo,ro,fo)),s.quaternion.multiply($r),s.visible=this.dragging),"E"===this.axis&&(s.visible=!1)):"START"===s.name?(s.position.copy(this.worldPositionStart),s.visible=this.dragging):"END"===s.name?(s.position.copy(this.worldPosition),s.visible=this.dragging):"DELTA"===s.name?(s.position.copy(this.worldPositionStart),s.quaternion.copy(this.worldQuaternionStart),Zr.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),Zr.applyQuaternion(this.worldQuaternionStart.clone().invert()),s.scale.copy(Zr),s.visible=this.dragging):(s.quaternion.copy(e),this.dragging?s.position.copy(this.worldPositionStart):s.position.copy(this.worldPosition),this.axis&&(s.visible=-1!==this.axis.search(s.name)))}super.updateMatrixWorld(t)}}class bo extends w{constructor(){super(new B(1e5,1e5,2,2),new T({visible:!1,wireframe:!0,side:g,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type="TransformControlsPlane"}updateMatrixWorld(t){let e=this.space;switch(this.position.copy(this.worldPosition),"scale"===this.mode&&(e="local"),go.copy(po).applyQuaternion("local"===e?this.worldQuaternion:ho),_o.copy(fo).applyQuaternion("local"===e?this.worldQuaternion:ho),yo.copy(mo).applyQuaternion("local"===e?this.worldQuaternion:ho),ro.copy(_o),this.mode){case"translate":case"scale":switch(this.axis){case"X":ro.copy(this.eye).cross(go),co.copy(go).cross(ro);break;case"Y":ro.copy(this.eye).cross(_o),co.copy(_o).cross(ro);break;case"Z":ro.copy(this.eye).cross(yo),co.copy(yo).cross(ro);break;case"XY":co.copy(yo);break;case"YZ":co.copy(go);break;case"XZ":ro.copy(yo),co.copy(_o);break;case"XYZ":case"E":co.set(0,0,0)}break;default:co.set(0,0,0)}0===co.length()?this.quaternion.copy(this.cameraQuaternion):(uo.lookAt(Zr.set(0,0,0),co,ro),this.quaternion.setFromRotationMatrix(uo)),super.updateMatrixWorld(t)}}class xo{constructor(t,i,s,n,o,a=5,l=!0){if(e(this,"onDraggingStarted",new U),e(this,"onDraggingEnded",new U),e(this,"onDisposed",new U),e(this,"normal"),e(this,"origin"),e(this,"three",new r.Plane),e(this,"components"),e(this,"world"),e(this,"type","default"),e(this,"_title","Clipping Plane"),e(this,"_helper"),e(this,"_visible",!0),e(this,"_enabled",!0),e(this,"_controlsActive",!1),e(this,"_arrowBoundBox",new r.Mesh),e(this,"_planeMesh"),e(this,"_controls"),e(this,"_hiddenMaterial",new r.MeshBasicMaterial({visible:!1})),e(this,"_visibilityBeforeDisabled",!0),e(this,"notifyManager",()=>{const t=this.components.get(Co),e=t.list.getKey(this);e&&t.list.set(e,this)}),e(this,"update",()=>{this._enabled&&this.three.setFromNormalAndCoplanarPoint(this.normal,this._helper.position)}),e(this,"changeDrag",t=>{this._visible=!t.value,this.preventCameraMovement(),this.notifyDraggingChanged(t)}),this.components=t,this.world=i,!i.renderer)throw new Error("The given world must have a renderer!");this.normal=n,this.origin=s,i.renderer.setPlane(!0,this.three),this._planeMesh=xo.newPlaneMesh(a,o),this._helper=this.newHelper(),this._controls=this.newTransformControls(),this.three.setFromNormalAndCoplanarPoint(n,s),l&&this.toggleControls(!0)}set title(t){this._title=t,this.notifyManager()}get title(){return this._title}get enabled(){return this._enabled}set enabled(t){if(!this.world.isDisposing){if(!this.world.renderer)throw new Error("No renderer found for clipping plane!");this._enabled=t,t?this.visible=this._visibilityBeforeDisabled:(this._visibilityBeforeDisabled=this.visible,this.visible=!1),this.world.renderer.setPlane(t,this.three),this.notifyManager()}}get visible(){return this._visible}set visible(t){this._visible=t,this._controls.getHelper().visible=t,this._helper.visible=t,this.toggleControls(t),this.notifyManager()}get meshes(){return[this._planeMesh,this._arrowBoundBox]}get planeMaterial(){return this._planeMesh.material}set planeMaterial(t){this._planeMesh.material=t}get size(){return this._planeMesh.scale.x}set size(t){this._planeMesh.scale.set(t,t,t)}get helper(){return this._helper}setFromNormalAndCoplanarPoint(t,e){this.reset(),this.normal.equals(t)||(this.normal.copy(t),this._helper.lookAt(t)),this.origin.copy(e),this._helper.position.copy(e),this._helper.updateMatrix(),this.update()}dispose(){this._enabled=!1,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 t=new r.Vector3(1,0,0),e=new r.Vector3;this.normal.equals(t)||(this.normal.copy(t),this._helper.lookAt(t)),this.origin.copy(e),this._helper.position.copy(e),this._helper.updateMatrix()}toggleControls(t){if(t){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=t}newTransformControls(){if(!this.world.renderer)throw new Error("No renderer found for clipping plane!");const t=this.world.camera.three,e=this.world.renderer.three.domElement,i=new Qr(t,e);return this.initializeControls(i),this.world.scene.three.add(i.getHelper()),i}initializeControls(t){t.attach(this._helper),t.showX=!1,t.showY=!1,t.setSpace("local"),this.createArrowBoundingBox(),t.getHelper().children[0].children[0].add(this._arrowBoundBox)}createArrowBoundingBox(){this._arrowBoundBox.geometry=new r.CylinderGeometry(.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(t){t.value?this.onDraggingStarted.trigger():this.onDraggingEnded.trigger()}preventCameraMovement(){this.world.camera.enabled=this._visible}newHelper(){const t=new r.Object3D;return t.lookAt(this.normal),t.position.copy(this.origin),this._planeMesh.position.z+=.01,t.add(this._planeMesh),this.world.scene.three.add(t),t}static newPlaneMesh(t,e){const i=new r.PlaneGeometry(1),s=new r.Mesh(i,e);return s.scale.set(t,t,t),s}}class Eo extends xe{constructor(){super(...arguments),e(this,"_config",{enabled:{value:!0,type:"Boolean"},visible:{value:!0,type:"Boolean"},color:{value:new r.Color,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(t){this._config.enabled.value=t,this._component.enabled=t}get visible(){return this._config.visible.value}set visible(t){this._config.visible.value=t,this._component.visible=t}get color(){return this._config.color.value}set color(t){this._config.color.value=t,this._component.material.color.copy(t)}get opacity(){return this._config.opacity.value}set opacity(t){this._config.opacity.value=t,this._component.material.opacity=t}get size(){return this._config.size.value}set size(t){this._config.size.value=t,this._component.size=t}}const To=class t extends F{constructor(s){super(s),e(this,"onSetup",new U),e(this,"onBeforeDrag",new U),e(this,"onAfterDrag",new U),e(this,"onBeforeCreate",new U),e(this,"onBeforeCancel",new U),e(this,"onAfterCancel",new U),e(this,"onBeforeDelete",new U),e(this,"onAfterCreate",new U),e(this,"onAfterDelete",new U),e(this,"onDisposed",new U),e(this,"isSetup",!1),e(this,"orthogonalY",!1),e(this,"toleranceOrthogonalY",.7),e(this,"Type",xo),e(this,"list",new i.DataMap),e(this,"config",new Eo(this,this.components,"Clipper",t.uuid)),e(this,"_defaultConfig",{color:new r.Color(12255487),opacity:.2,size:2}),e(this,"_material",new r.MeshBasicMaterial({color:12255487,side:r.DoubleSide,transparent:!0,opacity:.2})),e(this,"_size",5),e(this,"_enabled",!1),e(this,"_visible",!0),e(this,"_onStartDragging",()=>{this.onBeforeDrag.trigger()}),e(this,"_onEndDragging",()=>{this.onAfterDrag.trigger()}),this.components.add(t.uuid,this),this.setEvents()}get enabled(){return this._enabled}set enabled(t){this._enabled=t}get visible(){return this._visible}set visible(t){this._visible=t;for(const[e,i]of this.list)i.visible=t}get material(){return this._material}set material(t){this._material=t;for(const[e,i]of this.list)i.planeMaterial=t}get size(){return this._size}set size(t){this._size=t;for(const[e,i]of this.list)i.size=t}setEvents(){this.list.onBeforeDelete.add(({value:t})=>{if(!t.world.renderer)throw new Error("Renderer not found for this plane's world!");t.world.renderer.setPlane(!1,t.three),t.dispose(),this.updateMaterialsAndPlanes()})}dispose(){this._enabled=!1;this.components.get(Te).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(t.uuid),this.onDisposed.reset()}async create(t){const e=this.components.get(je).get(t),i=await e.castRay();return i?this.createPlaneFromIntersection(t,i):null}createFromNormalAndCoplanarPoint(t,e,i){const s=this.newPlane(t,i,e);return this.updateMaterialsAndPlanes(),s}async delete(t,e){if(!e){const i=await this.pickPlane(t);if(!i)return;e=this.list.getKey(i)}e&&this.list.delete(e)}deleteAll(t){for(const[e,i]of this.list)t&&!t.has(i.type)||this.list.delete(e)}setup(t){const e={...this._defaultConfig,...t};this.config.color=e.color,this.config.opacity=e.opacity,this.config.size=e.size,this.isSetup=!0,this.onSetup.trigger()}async pickPlane(t){const e=this.components.get(je).get(t),i=this.getAllPlaneMeshes(),s=await e.castRay({items:i});if(s){const t=s.object;return[...this.list.values()].find(e=>e.meshes.includes(t))}}getAllPlaneMeshes(){const t=[];for(const[e,i]of this.list)t.push(...i.meshes);return t}createPlaneFromIntersection(t,e){var i;if(!t.renderer)throw new Error("The given world must have a renderer!");const s=e.point.distanceTo(new r.Vector3(0,0,0)),n=e.normal||(null==(i=e.face)?void 0:i.normal);if(!s||!n)return null;const o=this.getWorldNormal(e,n),a=this.newPlane(t,e.point,o.negate()),l=this.list.get(a);return l.visible=this._visible,l.size=this._size,t.renderer.setPlane(!0,l.three),this.updateMaterialsAndPlanes(),l}getWorldNormal(t,e){const i=t.object;let s=t.object.matrixWorld.clone();if(i instanceof r.InstancedMesh&&void 0!==t.instanceId){const e=new r.Matrix4;i.getMatrixAt(t.instanceId,e),s=e.multiply(s)}const n=(new r.Matrix3).getNormalMatrix(s),o=e.clone().applyMatrix3(n).normalize();return this.normalizePlaneDirectionY(o),o}normalizePlaneDirectionY(t){this.orthogonalY&&(t.y>this.toleranceOrthogonalY&&(t.x=0,t.y=1,t.z=0),t.y<-this.toleranceOrthogonalY&&(t.x=0,t.y=-1,t.z=0))}newPlane(t,e,i){const s=new this.Type(this.components,t,e,i,this._material);s.onDraggingStarted.add(this._onStartDragging),s.onDraggingEnded.add(this._onEndDragging);const n=q.create();return this.list.set(n,s),this.onAfterCreate.trigger(s),n}updateMaterialsAndPlanes(){const t=this.components.get(Yi);for(const[e,i]of t.list){if(!i.renderer)continue;i.renderer.updateClippingPlanes();const{clippingPlanes:t}=i.renderer;for(const e of i.meshes)if(e.material)if(Array.isArray(e.material))for(const i of e.material)i.clippingPlanes=t;else e.material.clippingPlanes=t}}};e(To,"uuid","66290bc5-18c4-4cd1-9379-2e17a0617611");let Co=To;class So{constructor(t,s){e(this,"title"),e(this,"guid",q.create()),e(this,"clippingPlanes",new i.DataSet),e(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}}),e(this,"exceptionComponents",new i.DataSet),e(this,"selectionComponents",new i.DataSet),e(this,"componentColors",new i.DataMap),e(this,"spacesVisible",!1),e(this,"spaceBoundariesVisible",!1),e(this,"openingsVisible",!1),e(this,"defaultVisibility",!0),e(this,"snapshot",this.guid),e(this,"_components"),e(this,"_world",null),e(this,"notifyUpdate",()=>{this._components.get(Po).list.set(this.guid,this)}),this._components=t,s&&(this.guid=s.guid??this.guid,this.set(s)),this.setEvents()}async getSelectionMap(){const t=this._components.get(Ae);return await t.guidsToModelIdMap([...this.selectionComponents])}async getExceptionMap(){const t=this._components.get(Ae);return await t.guidsToModelIdMap([...this.exceptionComponents])}get projection(){return"field_of_view"in this.camera?"Perspective":"Orthographic"}get position(){const t=this._components.get(Ae),{camera_view_point:e}=this.camera,{x:i,y:s,z:n}=e,o=new r.Vector3(i,s,n);return t.applyBaseCoordinateSystem(o,new r.Matrix4),o}set position(t){const e=t.clone(),i=this._components.get(Ae);t.clone().applyMatrix4(i.baseCoordinationMatrix.clone().invert()),this.camera.camera_view_point={x:e.x,y:e.y,z:e.z}}get direction(){const{camera_direction:t}=this.camera,{x:e,y:i,z:s}=t;return new r.Vector3(e,i,s)}set world(t){this._world=t}get world(){return this._world}get _managerVersion(){return this._components.get(Vr).config.version}get topics(){return[...this._components.get(Vr).list.values()].filter(t=>t.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(t){this.title=t.title;const{components:e,perspective_camera:i,orthogonal_camera:s,clipping_planes:n}=t;if(e){const{selection:t,visibility:i,coloring:s}=e;if(t){this.selectionComponents.clear();for(const{ifc_guid:e}of t)e&&this.selectionComponents.add(e)}if(i){const{default_visibility:t,exceptions:e,view_setup_hints:s}=i;if(void 0!==t&&(this.defaultVisibility=t),e){this.exceptionComponents.clear();for(const{ifc_guid:t}of e)t&&this.exceptionComponents.add(t)}if(s){const{spaces_visible:t,space_boundaries_visible:e,openings_visible:i}=s;void 0!==t&&(this.spacesVisible=t),void 0!==e&&(this.spaceBoundariesVisible=e),void 0!==i&&(this.openingsVisible=i)}}if(s){this.componentColors.clear();for(const t of s){const{color:e,components:i}=t,s=i.map(t=>t.ifc_guid).filter(t=>null!==t);this.componentColors.set(e,s)}}}if((i||s)&&(this.camera=i??s),n&&this.world){const t=this._components.get(Co);for(const e of n){const{location:i,direction:s}=e,n=new r.Vector3(i.x,i.z,-i.y),o=new r.Vector3(s.x,s.z,-s.y),a=t.createFromNormalAndCoplanarPoint(this.world,o,n);this.clippingPlanes.add(a),t.list.get(a).enabled=!1,t.list.get(a).visible=!1}}this.notifyUpdate()}async go(t){if(!this.world)return;const{camera:e}=this.world;if(!(e instanceof kr))throw new Error("Viewpoint: the world's camera component must be of type OrthoPerspectiveCamera to switch between perspective and orthographic projections.");const{transition:i,applyClippings:s,applyVisibility:n,clippingsVisibility:o}={transition:!0,applyClippings:!0,applyVisibility:!0,clippingsVisibility:!0,...t};e.projection.set(this.projection);const a=new r.Vector3(this.camera.camera_view_point.x,this.camera.camera_view_point.y,this.camera.camera_view_point.z),l=new r.Vector3(this.camera.camera_direction.x,this.camera.camera_direction.y,this.camera.camera_direction.z);if(a.equals(new r.Vector3)&&l.equals(new r.Vector3))return;const h=this.position,c=this.direction,d={x:h.x+80*c.x,y:h.y+80*c.y,z:h.z+80*c.z},u=[];s&&this.setClippingState(!0),n&&u.push(this.applyVisibility()),this.setClippingVisibility(o),u.push(e.controls.setLookAt(h.x,h.y,h.z,d.x,d.y,d.z,i)),await Promise.all(u)}async updateCamera(t=!0){return new Promise(e=>{if(!this.world)return void e(!1);const{camera:i,renderer:s}=this.world;if(!s)throw new Error("Viewpoint: the world needs to have a renderer!");if(!i.hasCameraControls())throw new Error("Viewpoint: world's camera need camera controls!");const n=new r.Vector3;i.controls.getPosition(n);const o=i.three,a=new r.Vector3(0,0,-1).applyEuler(o.rotation),{width:l,height:h}=s.getSize();let c=l/h;Number.isNaN(c)&&(c=1);const d=this._components.get(Ae);n.applyMatrix4(d.baseCoordinationMatrix.clone().invert());const u={aspect_ratio:c,camera_view_point:{x:n.x,y:n.y,z:n.z},camera_direction:{x:a.x,y:a.y,z:a.z},camera_up_vector:{x:0,y:1,z:0}};if(o instanceof r.PerspectiveCamera?this.camera={...u,field_of_view:o.fov}:o instanceof r.OrthographicCamera&&(this.camera={...u,view_to_world_scale:o.top-o.bottom}),t){const t=this._components.get(Po),n=s.three.domElement;s.three.render(this.world.scene.three,i.three),n.toBlob(async i=>{if(i){const e=await i.arrayBuffer(),s=new Uint8Array(e);t.snapshots.set(this.guid,s)}this.notifyUpdate(),e(!0)})}else this.notifyUpdate(),e(!0)})}takeSnapshot(){return new Promise(t=>{if(!this.world)return void t(!1);const{camera:e,renderer:i}=this.world;if(!i)throw new Error("Viewpoint: the world needs to have a renderer!");const s=this._components.get(Po),n=i.three.domElement;i.three.render(this.world.scene.three,e.three),n.toBlob(async e=>{if(e){const t=await e.arrayBuffer(),i=new Uint8Array(t);s.snapshots.set(this.guid,i)}this.notifyUpdate(),t(!0)})})}updateClippingPlanes(){this.clippingPlanes.clear();const t=this._components.get(Co);for(const[e,i]of t.list)i.enabled&&this.clippingPlanes.add(e)}async applyVisibility(){const t=this._components.get(De);t.set(this.defaultVisibility);const e=await this.getExceptionMap();t.set(!this.defaultVisibility,e);const i=await this.getSelectionMap();t.set(!0,i)}async setColorizationState(t){const e=this._components.get(Ae),s=[];if(t)for(const[t,n]of this.componentColors){const o=`#${t}`,a=await e.guidsToModelIdMap(n);for(const[t,n]of Object.entries(a)){const a=e.list.get(t);a&&s.push(a.highlight([...n],{customId:o,color:new r.Color(o),renderedFaces:i.RenderedFaces.ONE,opacity:1,transparent:!1}))}}else for(const[t,i]of this.componentColors){const t=await e.guidsToModelIdMap(i);for(const[i,n]of Object.entries(t)){const t=e.list.get(i);t&&s.push(t.resetHighlight([...n]))}}s.push(e.core.update(!0)),await Promise.all(s)}setClippingState(t){const e=this._components.get(Co);for(const[i,s]of e.list)s.enabled=t&&this.clippingPlanes.has(i)}setClippingVisibility(t){const e=this._components.get(Co);for(const i of this.clippingPlanes){const s=e.list.get(i);s&&(s.visible=t)}}async createComponentTags(t){var e;const i=this._components.get(Ae);let s="";if(this._components.get(Vr).config.includeSelectionTag){const n="selection"===t?await this.getSelectionMap():await this.getExceptionMap();for(const t in n){const r=i.list.get(t);if(!r)continue;const o=n[t];for(const t of o){const i=r.getItem(t),n=await i.getGuid();if(!n)continue;const o=null==(e=await i.getAttributes())?void 0:e.getValue("Tag");let a=null;o&&(a=`AuthoringToolId="${o}"`),s+=`\n<Component IfcGuid="${n}" ${a??""} />`}}}else s=[...this.selectionComponents].map(t=>`<Component IfcGuid="${t}" />`).join("\n");return s}createColorTags(){let t="";for(const[e,i]of this.componentColors.entries()){t+=`<Color Color="${e}">\n${i.map(t=>`\n<Component IfcGuid="${t}" />`).join("\n")}\n</Color>`}return 0!==t.length?`<Coloring>\n${t}\n</Coloring>`:"<Coloring />"}toJSON(){const t=this._components.get(Co),e={guid:this.guid,components:{selection:[...this.selectionComponents].map(t=>({ifc_guid:t,authoring_tool_id:null})),coloring:[...this.componentColors].map(([t,e])=>({color:t,components:e.map(t=>({ifc_guid:t,authoring_tool_id:null}))})),visibility:{default_visibility:this.defaultVisibility,exceptions:[...this.exceptionComponents].map(t=>({ifc_guid:t,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(e=>{const i=t.list.get(e);if(!i)return null;const s=i._controls.worldPosition??i.origin,{normal:n}=i;return{location:{x:s.x,y:-s.z,z:s.y},direction:{x:n.x,y:-n.z,z:n.y}}}).filter(t=>null!==t)};"field_of_view"in this.camera?e.perspective_camera=this.camera:e.orthogonal_camera=this.camera;const i=this._components.get(Po),s=i.snapshots.get(this.snapshot);if(s){const t=s.toString(),n=btoa(t),r=i.getSnapshotExtension(this.snapshot);e.snapshot={snapshot_type:r,snapshot_data:n}}return e}async serialize(t=this._managerVersion){const e=this._components.get(Ae),i=this.position;i.applyMatrix4(e.baseCoordinationMatrix.clone().invert());const s=this.direction;s.normalize();const n=(new r.Matrix4).makeRotationX(Math.PI/2),o=s.clone().applyMatrix4(n);o.normalize();const a=`<CameraViewPoint>\n <X>${i.x}</X>\n <Y>${-i.z}</Y>\n <Z>${i.y}</Z>\n </CameraViewPoint>`,l=`<CameraDirection>\n <X>${s.x}</X>\n <Y>${-s.z}</Y>\n <Z>${s.y}</Z>\n </CameraDirection>`,h=`<CameraUpVector>\n <X>${o.x}</X>\n <Y>${-o.z}</Y>\n <Z>${o.y}</Z>\n </CameraUpVector>`,c=`<AspectRatio>${this.camera.aspect_ratio}</AspectRatio>`;let d="";"viewToWorld"in this.camera?d=`<OrthogonalCamera>\n ${a}\n ${l}\n ${h}\n ${c}\n <ViewToWorldScale>${this.camera.viewToWorld}</ViewToWorldScale>\n </OrthogonalCamera>`:"fov"in this.camera&&(d=`<PerspectiveCamera>\n ${a}\n ${l}\n ${h}\n ${c}\n <FieldOfView>${this.camera.fov}</FieldOfView>\n </PerspectiveCamera>`);const u=`<ViewSetupHints SpacesVisible="${this.spacesVisible??!1}" SpaceBoundariesVisible="${this.spaceBoundariesVisible??!1}" OpeningsVisible="${this.openingsVisible??!1}" />`,p=(await this.createComponentTags("selection")).trim(),f=(await this.createComponentTags("exception")).trim(),m=this.createColorTags();return`<?xml version="1.0" encoding="UTF-8"?>\n <VisualizationInfo Guid="${this.guid}">\n <Components>\n ${"2.1"===t?u:""}\n ${0!==p.length?`<Selection>${p}</Selection>`:""}\n <Visibility DefaultVisibility="${this.defaultVisibility}">\n ${"3"===t?u:""}\n ${0!==f.length?`<Exceptions>${f}</Exceptions>`:""}\n </Visibility>\n ${m}\n </Components>\n ${d}\n </VisualizationInfo>`}}class Ao extends xe{constructor(){super(...arguments),e(this,"_config",{overwriteColors:{value:!1,type:"Boolean"}})}get overwriteColors(){return this._config.overwriteColors.value}set overwriteColors(t){this._config.overwriteColors.value=t}}const Oo=class t extends F{constructor(i){super(i),e(this,"enabled",!0),e(this,"world",null),e(this,"list",new s),e(this,"snapshots",new s),e(this,"isSetup",!1),e(this,"onSetup",new U),e(this,"config",new Ao(this,this.components,"Viewpoints",t.uuid)),e(this,"onDisposed",new U),i.add(t.uuid,this)}create(t){const e=new So(this.components,t);return e.world=this.world,t||this.list.set(e.guid,e),e}getSnapshotExtension(t){let e="jpeg";const i=this.snapshots.get(t);if(!i)return e;const s=i.subarray(0,4);let n="";for(let t=0;t<s.length;t++)n+=s[t].toString(16);return n.startsWith("89504e47")&&(e="png"),n.startsWith("ffd8ffe")&&(e="jpeg"),e}setup(){}dispose(){this.list.dispose(),this.onDisposed.trigger(),this.onDisposed.reset()}};e(Oo,"uuid","ee867824-a796-408d-8aa0-4e5962a83c66");let Po=Oo;class Io{constructor(t,i){e(this,"_components"),e(this,"_cameraOffset",10),e(this,"_planeHelper"),e(this,"_farPlaneHelper"),e(this,"_cameraHelper"),e(this,"onStateChanged",new U),e(this,"onUpdated",new U),e(this,"onDisposed",new U),e(this,"camera"),e(this,"plane",new r.Plane),e(this,"farPlane",new r.Plane),e(this,"id",q.create()),e(this,"_open",!1),e(this,"_range",Do.defaultRange),e(this,"_world",null),e(this,"_helpersVisible",!1),e(this,"_planesEnabled",!1),this._components=t,this.camera=new kr(this._components);const{threeOrtho:s}=this.camera;if((null==i?void 0:i.id)&&(this.id=i.id),(null==i?void 0:i.normal)&&(null==i?void 0:i.point)){const{normal:t,point:e}=i;this.plane.setFromNormalAndCoplanarPoint(t,e)}this._cameraHelper=new r.CameraHelper(s),this._planeHelper=new r.PlaneHelper(this.plane,50),this._farPlaneHelper=new r.PlaneHelper(this.farPlane,50),this.farPlaneHelperColor=new r.Color("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(t){this._open=t,this.onStateChanged.trigger(["open"])}get open(){return this._open}set planeHelperColor(t){!Array.isArray(this._planeHelper.material)&&"color"in this._planeHelper.material&&this._planeHelper.material.color instanceof r.Color&&(this._planeHelper.material.color=t)}set farPlaneHelperColor(t){!Array.isArray(this._farPlaneHelper.material)&&"color"in this._farPlaneHelper.material&&this._farPlaneHelper.material.color instanceof r.Color&&(this._farPlaneHelper.material.color=t)}set range(t){this._range=t,this.update()}get range(){return this._range}set distance(t){this.plane.constant=t,this.update()}get distance(){return this.plane.constant}set world(t){this._world=t,this.camera.currentWorld=t,t&&(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(t){if(!t)return this._helpersVisible=t,this._planeHelper.removeFromParent(),this._farPlaneHelper.removeFromParent(),void this._cameraHelper.removeFromParent();this.world&&(this._helpersVisible=t,this.world.scene.three.add(this._planeHelper,this._farPlaneHelper))}get helpersVisible(){return this._helpersVisible}set planesEnabled(t){const{world:e}=this;if(!e)return;const{renderer:i}=e;i&&(i.setPlane(t,this.plane),i.setPlane(t,this.farPlane),this._planesEnabled=t)}get planesEnabled(){return this._planesEnabled}dispose(){this.helpersVisible=!1;const t=this._components.get($);t.destroy(this._planeHelper),t.destroy(this._farPlaneHelper),t.destroy(this._cameraHelper),this.camera.dispose(),this.onDisposed.trigger()}update(){if(this.world){const t=this._cameraPosition,e=this._planePosition;this.camera.controls.setLookAt(t.x,t.y,t.z,e.x,e.y,e.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 ko=class t extends F{constructor(i){super(i),e(this,"list",new s),e(this,"enabled",!0),e(this,"world",null),e(this,"_fragmentsUpdateEvent",()=>{this.components.get(Ae).core.update(!0)}),i.add(t.uuid,this),this.setupEvents()}get hasOpenViews(){return[...this.list.values()].some(t=>t.open)}setupEvents(){this.list.onBeforeDelete.add(({key:t,value:e})=>{e.open&&this.close(t),e.dispose()})}create(t,e,i){const s=new Io(this.components,{id:null==i?void 0:i.id,normal:t,point:e});return s.world=(null==i?void 0:i.world)??this.world,this.list.set(s.id,s),s}createFromPlane(t,e){const i=new Io(this.components,{id:null==e?void 0:e.id});return i.plane.copy(t),i.update(),i.world=(null==e?void 0:e.world)??this.world,this.list.set(i.id,i),i}async createFromIfcStoreys(t){const e=[],i=this.components.get(Ae),s=void 0===(null==t?void 0:t.offset)?.25:t.offset;for(const[n,o]of i.list){if(t&&t.modelIds&&!t.modelIds.some(t=>t.test(n)))continue;const i=Object.values(await o.getItemsOfCategories([/BUILDINGSTOREY/])).flat();if(0===i.length)continue;const a=await o.getItemsData(i),[,l]=await o.getCoordinates(),h=new r.Vector3(0,-1,0);for(const i of a){if(!("value"in i.Name)||!("value"in i.Elevation))continue;const{value:n}=i.Name;if((null==t?void 0:t.storeyNames)&&!t.storeyNames.some(t=>t.test(n)))continue;const o=i.Elevation.value+l+s,a=new r.Plane(h,o),c=this.createFromPlane(a,{id:n,world:null==t?void 0:t.world});e.push(c)}}return e}createElevations(t){const e=[],i=this.components.get(Ae),s=void 0!==(null==t?void 0:t.combine)&&t.combine,n=(null==t?void 0:t.namingCallback)??(t=>({front:""+(s?"Front":`${t}: Front`),back:""+(s?"Back":`${t}: Back`),left:""+(s?"Left":`${t}: Left`),right:""+(s?"Right":`${t}: Right`)}));let o=[];for(const[e,s]of i.list)t&&t.modelIds&&!t.modelIds.some(t=>t.test(e))||o.push({id:e,box:s.box});if(s){const t=this.components.get(Me);t.list.clear(),t.list.add(...o.map(t=>t.box));o=[{id:"combined",box:t.get()}]}for(const{id:i,box:s}of o){const{min:o,max:a}=s,l=Math.abs(a.x-o.x),h=Math.abs(a.z-o.z),c=new r.Vector3;s.getCenter(c);const d=new r.Plane(new r.Vector3(0,0,-1),a.z),u=new r.Plane(new r.Vector3(0,0,1),-o.z),p=new r.Plane(new r.Vector3(-1,0,0),a.x),f=new r.Plane(new r.Vector3(1,0,0),-o.x),{front:m,back:g,left:_,right:y}=n(i),w=this.createFromPlane(d,{id:m,world:null==t?void 0:t.world});w.range=h;const v=this.createFromPlane(u,{id:g,world:null==t?void 0:t.world});v.range=h;const b=this.createFromPlane(p,{id:_,world:null==t?void 0:t.world});b.range=l;const x=this.createFromPlane(f,{id:y,world:null==t?void 0:t.world});x.range=l,e.push(w,v,b,x)}return e}open(t){const e=this.list.get(t);if(!e)throw new Error(`Views: the view with id ${t} doesn't exist.`);if(e.open)return;const{world:i}=e;if(!i)throw new Error(`Views: no world found for view with id ${t}.`);const{renderer:s}=i;if(!s)throw new Error(`Views: no renderer found for world with id ${i.uuid}.`);for(const[,t]of this.list)t.world===i&&this.close(t.id);s.setPlane(!0,e.plane),s.setPlane(!0,e.farPlane),e.camera.controls.addEventListener("rest",this._fragmentsUpdateEvent),i.camera=e.camera,e.open=!0}close(t){let e;if(e=t?this.list.get(t):[...this.list.values()].find(t=>t.open),t&&!e)throw new Error(`Views: the view with id ${t} doesn't exist.`);if(!e)return;if(!e.open)return;const{world:i}=e;if(!i)throw new Error(`Views: no world found for view with id ${t}.`);const{renderer:s}=i;if(!s)throw new Error(`Views: no renderer found for world with id ${i.uuid}.`);s.setPlane(!1,e.plane),s.setPlane(!1,e.farPlane),e.camera.controls.removeEventListener("rest",this._fragmentsUpdateEvent),i.useDefaultCamera(),e.open=!1}};e(ko,"uuid","fb22f1f5-6598-4664-a11d-de8963ae420f"),e(ko,"defaultRange",15);let Do=ko;async function zo(t,e,i,s,n,r,o){const a=t.fenceSync(t.SYNC_GPU_COMMANDS_COMPLETE,0);t.flush(),await function(t,e,i,s){return new Promise((n,r)=>{!function o(){const a=t.clientWaitSync(e,i,0);a!==t.WAIT_FAILED?a!==t.TIMEOUT_EXPIRED?n():setTimeout(o,s):r()}()})}(t,a,0,10),t.deleteSync(a),t.bindBuffer(e,i),t.getBufferSubData(e,s,n,r,o),t.bindBuffer(e,null)}class Mo{constructor(t,i){if(e(this,"onDisposed",new U),e(this,"onDistanceComputed",new U),e(this,"excludedObjects",new Set),e(this,"enabled",!0),e(this,"renderDebugFrame",!1),e(this,"components"),e(this,"scene",new r.Scene),e(this,"camera",new r.OrthographicCamera(-1,1,1,-1,0,1)),e(this,"depthMaterial"),e(this,"world"),e(this,"worker"),e(this,"_width",512),e(this,"_height",512),e(this,"_postQuad"),e(this,"tempRT"),e(this,"resultRT"),e(this,"bufferSize"),e(this,"_buffer"),e(this,"_isWorkerBusy",!1),e(this,"compute",async()=>{if(!this.enabled||this.world.isDisposing)return;if(this._isWorkerBusy)return;this._isWorkerBusy=!0,this.world.camera.three.updateMatrix();const t=this.world.renderer.three;t.setRenderTarget(this.tempRT);const e="visibilityBeforeDistanceCheck";for(const t of this.excludedObjects)t.userData[e]=t.visible,t.visible=!1;t.render(this.world.scene.three,this.world.camera.three);for(const t of this.excludedObjects)void 0!==t.userData[e]&&(t.visible=t.userData[e]);this.depthMaterial.uniforms.tDiffuse.value=this.tempRT.texture,this.depthMaterial.uniforms.tDepth.value=this.tempRT.depthTexture,t.setRenderTarget(this.resultRT),t.render(this.scene,this.camera);const i=t.getContext();try{await async function(t,e,i,s,n,r,o,a){const l=t.createBuffer();return t.bindBuffer(t.PIXEL_PACK_BUFFER,l),t.bufferData(t.PIXEL_PACK_BUFFER,a.byteLength,t.STREAM_READ),t.readPixels(e,i,s,n,r,o,0),t.bindBuffer(t.PIXEL_PACK_BUFFER,null),await zo(t,t.PIXEL_PACK_BUFFER,l,0,a),t.deleteBuffer(l),a}(i,0,0,this._width,this._height,i.RGBA,i.UNSIGNED_BYTE,this._buffer)}catch(e){return t.setRenderTarget(null),void(this._isWorkerBusy=!1)}t.setRenderTarget(null),this.renderDebugFrame&&t.render(this.scene,this.camera),this.worker.postMessage({buffer:this._buffer})}),e(this,"handleWorkerMessage",t=>{if(!this.enabled||this.world.isDisposing)return;const e=t.data.colors;let i=Number.MAX_VALUE;for(const t of e)0!==t&&t<i&&(i=t);const s=this.world.camera.three||r.OrthographicCamera,n=-1*(i/255-1)*(s.far-s.near),o=Math.min(n,s.far);this.onDistanceComputed.trigger(o),this._isWorkerBusy=!1}),!i.renderer)throw new Error("The given world must have a renderer!");this.components=t,this.world=i;const s=i.camera.three;this.tempRT=new r.WebGLRenderTarget(this._width,this._height),this.bufferSize=this._width*this._height*4,this._buffer=new Uint8Array(this.bufferSize),this.tempRT.texture.minFilter=r.NearestFilter,this.tempRT.texture.magFilter=r.NearestFilter,this.tempRT.stencilBuffer=!1,this.tempRT.samples=0,this.tempRT.depthTexture=new r.DepthTexture(this._width,this._height),this.tempRT.depthTexture.format=r.DepthFormat,this.tempRT.depthTexture.type=r.UnsignedShortType,this.resultRT=new r.WebGLRenderTarget(this._width,this._height),this.depthMaterial=new r.ShaderMaterial({vertexShader:"\nvarying vec2 vUv;\n\nvoid main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}\n ",fragmentShader:"\n#include <packing>\n\nvarying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform sampler2D tDepth;\nuniform float cameraNear;\nuniform float cameraFar;\n\n\nfloat readDepth( sampler2D depthSampler, vec2 coord ) {\n float fragCoordZ = texture2D( depthSampler, coord ).x;\n float viewZ = perspectiveDepthToViewZ( fragCoordZ, cameraNear, cameraFar );\n return viewZToOrthographicDepth( viewZ, cameraNear, cameraFar );\n}\n\nvoid main() {\n //vec3 diffuse = texture2D( tDiffuse, vUv ).rgb;\n float depth = readDepth( tDepth, vUv );\n\n gl_FragColor.rgb = 1.0 - vec3( depth );\n gl_FragColor.a = 1.0;\n}\n ",uniforms:{cameraNear:{value:s.near},cameraFar:{value:s.far},tDiffuse:{value:null},tDepth:{value:null}}});const n=new r.PlaneGeometry(2,2);this._postQuad=new r.Mesh(n,this.depthMaterial),this.scene.add(this._postQuad);const o=new Blob(['\n addEventListener("message", (event) => {\n const { buffer } = event.data;\n const colors = new Set();\n for (let i = 0; i < buffer.length; i += 4) {\n const r = buffer[i];\n colors.add(r);\n }\n postMessage({ colors });\n });\n '],{type:"application/javascript"});this.worker=new Worker(URL.createObjectURL(o)),this.worker.addEventListener("message",this.handleWorkerMessage)}dispose(){this.enabled=!1,this.onDistanceComputed.reset(),this.worker.terminate(),this.tempRT.dispose(),this.resultRT.dispose();const t=[...this.scene.children];this.excludedObjects.clear();for(const e of t)e.removeFromParent();this._postQuad.geometry.dispose(),this._postQuad.removeFromParent(),this._buffer=null,this.onDisposed.reset()}}class Bo extends Ye{constructor(){super(...arguments),e(this,"_distanceRenderer"),e(this,"autoBias",!0),e(this,"_defaultShadowConfig",{cascade:1,resolution:512}),e(this,"_lightsWithShadow",new Map),e(this,"_isComputingShadows",!1),e(this,"_shadowsEnabled",!0),e(this,"_bias",0),e(this,"recomputeShadows",t=>{if(!this._shadowsEnabled)return;this.autoBias&&(this.bias=-.005);if(t*=1.5,!this.currentWorld)throw new Error("A world needs to be assigned to the scene before computing shadows!");if(!this._lightsWithShadow.size)throw new Error("No shadows found!");const e=this.currentWorld.camera.three;if(!(e instanceof r.PerspectiveCamera||e instanceof r.OrthographicCamera))throw new Error("Invalid camera type!");const i=new r.Vector3;e.getWorldDirection(i);let s=t;const n=new r.Vector3;n.copy(this.config.directionalLight.position),n.normalize();for(const[t,o]of this._lightsWithShadow){const a=this.directionalLights.get(o);if(!a)throw new Error("Light not found.");const l=new r.Vector3;l.copy(i);const h=t===this._lightsWithShadow.size-1,c=h?s/2:2*s/3;l.multiplyScalar(c),l.add(e.position);const d=s-c,u=new r.Vector3;u.copy(n),u.multiplyScalar(d),a.target.position.copy(l),a.position.copy(l),a.position.add(u),a.shadow.camera.right=d,a.shadow.camera.left=-d,a.shadow.camera.top=d,a.shadow.camera.bottom=-d,a.shadow.camera.far=2*d,a.shadow.camera.updateProjectionMatrix(),a.shadow.camera.updateMatrix(),h||(s/=3)}this._isComputingShadows=!1})}get bias(){return this._bias}set bias(t){this._bias=t;for(const[,e]of this._lightsWithShadow){const i=this.directionalLights.get(e);i&&(i.shadow.bias=t)}}get shadowsEnabled(){return this._shadowsEnabled}set shadowsEnabled(t){this._shadowsEnabled=t;for(const[,e]of this.directionalLights)e.castShadow=t}get distanceRenderer(){if(!this._distanceRenderer)throw new Error("You must set up this component before accessing the distance renderer!");return this._distanceRenderer}setup(t){super.setup(t);const e={...this._defaultConfig,...this._defaultShadowConfig,...t};if(e.cascade<=0)throw new Error("Config.shadows.cascade must be a natural number greater than 0!");if(e.cascade>1)throw new Error("Multiple shadows not supported yet!");if(!this.currentWorld)throw new Error("A world needs to be assigned to the scene before setting it up!");for(const[,t]of this.directionalLights)t.target.removeFromParent(),t.removeFromParent(),t.dispose();this.directionalLights.clear(),this._distanceRenderer||(this._distanceRenderer=new Mo(this.components,this.currentWorld),this._distanceRenderer.onDistanceComputed.add(this.recomputeShadows)),this._lightsWithShadow.clear();for(let t=0;t<e.cascade;t++){const i=new r.DirectionalLight;i.intensity=this.config.directionalLight.intensity,i.color=this.config.directionalLight.color,i.position.copy(this.config.directionalLight.position),i.shadow.mapSize.width=e.resolution,i.shadow.mapSize.height=e.resolution,this.three.add(i,i.target),this.directionalLights.set(i.uuid,i),this._lightsWithShadow.set(t,i.uuid),i.castShadow=!0,i.shadow.bias=this._bias}}dispose(){super.dispose(),this._distanceRenderer&&this._distanceRenderer.dispose(),this._lightsWithShadow.clear()}async updateShadows(){!this._isComputingShadows&&this._shadowsEnabled&&(this._isComputingShadows=!0,await this.distanceRenderer.compute())}}class No{constructor(t){e(this,"cardinality","required"),e(this,"instructions"),e(this,"evalRequirement",(t,e,i,s)=>{const n={parameter:i,currentValue:t,requiredValue:e,pass:!1};s&&this.addCheckResult(n,s);let r=!1;if("simple"===e.type&&(r=t===e.parameter),"enumeration"===e.type&&(r=e.parameter.includes(t)),"pattern"===e.type){r=new RegExp(e.parameter).test(String(t))}if("length"===e.type){const{min:i,length:s,max:n}=e.parameter;void 0!==s&&(r=String(t).length===s),void 0!==i&&(r=String(t).length>=i),void 0!==n&&(r=String(t).length<=n)}if("bounds"===e.type&&"number"==typeof t){const{min:i,minInclusive:s,max:n,maxInclusive:o}=e.parameter;let a=!0,l=!0;void 0!==i&&(a=s?t>=i:t>i),void 0!==n&&(l=o?t<=n:t<n),r=a&&l}return"prohibited"===this.cardinality&&(r=!r),"optional"===this.cardinality&&(r=!0),n.pass=r,n.pass}),this._components=t}addCheckResult(t,e){const i=e.findIndex(({parameter:e})=>e===t.parameter);-1!==i?e[i]=t:e.push(t)}getItemChecks(t,e,s){if(!("value"in s._localId)||"number"!=typeof s._localId.value)return null;let n=t.get(e);n||(n=new i.DataMap,t.set(e,n));let r=n.get(s._localId.value);if(r){if(!r.pass)return null}else{const t=[];r={guid:Array.isArray(s._guid)?void 0:s._guid.value,pass:!1,checks:t},Object.defineProperty(r,"pass",{get:()=>t.every(({pass:t})=>t)}),n.set(s._localId.value,r)}const o=[],a={facetType:this.facetType,cardinality:this.cardinality,checks:o,pass:!1};return Object.defineProperty(a,"pass",{get:()=>o.every(({pass:t})=>t)}),r.checks.push(a),a.checks}}const Uo=(t,e)=>{let i="";if(!e)return i;if("simple"===e.type&&(i=`<simpleValue>${e.parameter}</simpleValue>`),"enumeration"===e.type){i=`<xs:restriction base="xs:string">\n ${e.parameter.map(t=>`<xs:enumeration value="${t}" />`).join("\n")}\n </xs:restriction>`}if("pattern"===e.type){i=`<xs:restriction base="xs:string">\n <xs:pattern value="${e.parameter}" />\n </xs:restriction>`}if("bounds"===e.type){const{min:t,minInclusive:s,max:n,maxInclusive:r}=e.parameter;let o="";void 0!==t&&(o=`<xs:min${s?"Inclusive":"Exclusive"} value="${t}">`);let a="";void 0!==n&&(a=`<xs:max${r?"Inclusive":"Exclusive"} value="${n}">`),i=`<xs:restriction base="xs:double">\n ${o}\n ${a}\n </xs:restriction>`}if("length"===e.type){const{length:t,min:s,max:n}=e.parameter;let r="";void 0!==t&&void 0===s&&void 0===n&&(r=`<xs:length value="${t}" />`);let o="";void 0!==s&&void 0===t&&(o=`<xs:minLength value="${s}" />`);let a="";void 0!==n&&void 0===t&&(a=`<xs:maxLength value="${n}" />`),i=`<xs:restriction base="xs:string">\n ${r}\n ${o}\n ${a}\n </xs:restriction>`}return`<${t[0].toLowerCase()+t.slice(1)}>\n ${i}\n </${t[0].toLowerCase()+t.slice(1)}>`};class Lo extends No{constructor(t,i){super(t),e(this,"facetType","Attribute"),e(this,"name"),e(this,"value"),this.name=i}serialize(t){const e=Uo("Name",this.name),i=Uo("Value",this.value);let s="";return"requirement"===t&&(s+=`cardinality="${this.cardinality}"`,s+=this.instructions?`instructions="${this.instructions}"`:""),`<attribute ${s}>\n ${e}\n ${i}\n</attribute>`}async getEntities(){}async test(t,e){const i=this._components.get(Ae);for(const[s,n]of Object.entries(t)){const t=i.list.get(s);if(!t)continue;const r=await t.getItemsData([...n]);for(const t of r){const i=this.getItemChecks(e,s,t);if(!i)continue;const n=Object.keys(t).filter(e=>{const i=this.evalRequirement(e,this.name,"Name");if(!i)return!1;const s=t[e];return!!Array.isArray(s)||(null===s||null===s.value?"optional"===this.cardinality||"prohibited"===this.cardinality:(!Array.isArray(s.value)||0!==s.value.length)&&(("string"!=typeof s.value||""!==s.value.trim())&&i))}),r=n.length>0;if(i.push({parameter:"Name",currentValue:r?n[0]:null,requiredValue:this.name,pass:"prohibited"===this.cardinality?!r:r}),this.value)if(n[0]){const e=t[n[0]];if(Array.isArray(e))i.push({parameter:"Value",currentValue:null,requiredValue:this.value,pass:"prohibited"===this.cardinality});else{Array.isArray(e.value)?i.push({parameter:"Value",currentValue:null,requiredValue:this.value,pass:"prohibited"===this.cardinality}):this.evalRequirement(e.value,this.value,"Value",i)}}else i.push({parameter:"Value",currentValue:null,requiredValue:this.value,pass:"prohibited"===this.cardinality})}}}}class Ro extends No{constructor(t,i){super(t),e(this,"facetType","Classification"),e(this,"system"),e(this,"value"),e(this,"uri"),this.system=i}serialize(t){const e=Uo("System",this.system),i=Uo("Value",this.value);let s="";return"requirement"===t&&(s+=`cardinality="${this.cardinality}"`,s+=this.uri?`uri=${this.uri}`:"",s+=this.instructions?`instructions="${this.instructions}"`:""),`<classification ${s}>\n ${e}\n ${i}\n</classification>`}async getEntities(t,e){}async test(t,e){}}class Fo extends No{constructor(t,i){super(t),e(this,"facetType","Entity"),e(this,"name"),e(this,"predefinedType"),this.name=i}serialize(t){const e=Uo("Name",this.name),i=Uo("Name",this.predefinedType);let s="";return"requirement"===t&&(s+=`cardinality="${this.cardinality}"`,s+=this.instructions?`instructions="${this.instructions}"`:""),`<entity ${s}>\n ${e}\n ${i}\n</entity>`}async getEntities(t,e){const i=this._components.get(Ae),s=new Map;for(const[e,n]of i.list){if(!t.find(t=>t.test(e)))continue;const i=await n.getCategories();for(const t of i){if(!await this.evalName(t))continue;let i=s.get(e);i||(i=[],s.set(e,i)),i.push(t)}}const n={};if(await Promise.all(Array.from(s.entries()).map(async([t,e])=>{const s=i.list.get(t);if(!s)return;const r=e.map(t=>new RegExp(`^${t}$`)),o=await s.getItemsOfCategories(r),a=Object.values(o).flat();n[t]=new Set(a)})),this.predefinedType)for(const[t,s]of Object.entries(n)){const n=i.list.get(t);if(!n)continue;const r=await n.getItemsData([...s]);for(const i of r){if(!("value"in i._localId))continue;await this.evalPredefinedType(t,i)&&ye.append(e,t,i._localId.value)}}else ye.add(e,n)}async test(t,e){const i=this._components.get(Ae);for(const[s,n]of Object.entries(t)){const t=i.list.get(s);if(!t)continue;const r=await t.getItemsData([...n]);for(const t of r){if(!("value"in t._category))continue;const i=this.getItemChecks(e,s,t);i&&(await this.evalName(t._category.value,i),await this.evalPredefinedType(s,t,i))}}}async evalName(t,e){return this.evalRequirement(t,this.name,"Name",e)}async evalPredefinedType(t,e,i){if(!this.predefinedType)return null;if(!("value"in e.PredefinedType))return null;const s="string"==typeof this.predefinedType.parameter&&"USERDEFINED"===this.predefinedType.parameter;let n=e.PredefinedType.value;if("USERDEFINED"===n&&!s){const t=Object.keys(e).find(t=>/^((?!Predefined).)*Type$/.test(t));if(t){const i=e[t];"value"in i&&(n=i.value)}else n="USERDEFINED"}if(!n){const i=this._components.get(Ae).list.get(t);if(i&&"value"in e._localId){const[t]=await i.getItemsData([e._localId.value],{relations:{IsTypedBy:{attributes:!0,relations:!1}}});if(Array.isArray(t.IsTypedBy)){const e=t.IsTypedBy[0];if(e&&"value"in e.PredefinedType&&(n=e.PredefinedType.value,"USERDEFINED"===n&&!s)){const t=Object.keys(e).find(t=>/^((?!Predefined).)*Type$/.test(t));if(t){const i=e[t];"value"in i&&(n=i.value)}else n="USERDEFINED"}}}}return this.evalRequirement(n,this.predefinedType,"PredefinedType",i)}}class Vo extends No{constructor(t,i,s){super(t),e(this,"facetType","Property"),e(this,"propertySet"),e(this,"baseName"),e(this,"value"),e(this,"dataType"),e(this,"uri"),e(this,"_unsupportedTypes",["IFCCOMPLEXPROPERTY","IFCPHYSICALCOMPLEXQUANTITY"]),this.propertySet=i,this.baseName=s}serialize(t){const e=Uo("PropertySet",this.propertySet),i=Uo("BaseName",this.baseName),s=Uo("Value",this.value),n=this.dataType?`dataType=${this.dataType}`:"";let r="";return"requirement"===t&&(r+=`cardinality="${this.cardinality}"`,r+=this.uri?`uri=${this.uri}`:"",r+=this.instructions?`instructions="${this.instructions}"`:""),`<property ${n} ${r}>\n ${e}\n ${i}\n ${s}\n</property>`}async getEntities(t,e){const i=this._components.get(Ae);for(const[s,n]of i.list){if(!t.find(t=>t.test(s)))continue;const i=await n.getItemsOfCategories([/PROPERTYSET/,/ELEMENTQUANTITY/]),r=Object.values(i).flat();if(0===r.length)continue;const o=await n.getItemsData(r,{relations:{HasProperties:{attributes:!0,relations:!1},DefinesOcurrence:{attributes:!0,relations:!1}}});for(const t of o){if(!("value"in t._localId&&"value"in t._category&&"value"in t.Name&&Array.isArray(t.DefinesOcurrence)))continue;if(!this.evalRequirement(t.Name.value,this.propertySet,"PropertySet"))continue;let i;if("IFCPROPERTYSET"===t._category.value&&(i="HasProperties"),"IFCELEMENTQUANTITY"===t._category.value&&(i="Quantities"),!i)continue;const n=t[i];if(Array.isArray(n))for(const i of n){const n=Object.keys(i),r=n.find(t=>/Name/.test(t));if(!r||!("value"in i[r]))continue;const o=i[r];if(!("value"in o))continue;if(!this.evalRequirement(o.value,this.baseName,"BaseName"))continue;if(this.value){const t=n.find(t=>/Value/.test(t));if(!t)continue;const e=i[t];if(!("value"in e))continue;if(!this.evalRequirement(e.value,this.value,"Value"))continue}const a=t.DefinesOcurrence.map(t=>"value"in t._localId&&"number"==typeof t._localId.value?t._localId.value:null).filter(t=>null!==t);ye.append(e,s,...a)}}}}async test(t,e){const i=this._components.get(Ae);for(const[s,n]of Object.entries(t)){const t=i.list.get(s);if(!t)continue;const r=await t.getItemsData([...n],{relations:{IsDefinedBy:{attributes:!0,relations:!0},IsTypedBy:{attributes:!0,relations:!1},HasPropertySets:{attributes:!0,relations:!0},DefinesOcurrence:{attributes:!1,relations:!1}}});for(const t of r){const i=this.getItemChecks(e,s,t);if(!i)continue;const n=(await this.getPsets(t)).filter(t=>{if(!("value"in t.Name))return!1;return!!this.evalRequirement(t.Name.value,this.propertySet,"PropertySet")&&(i.push({currentValue:t.Name.value,parameter:"PropertySet",pass:!0,requiredValue:this.propertySet}),!0)});if(0!==n.length)for(const t of n){const e=this.getPropertyListName(t);if(!e)continue;const s=t[e];if(!Array.isArray(s)){i.push({currentValue:null,parameter:"BaseName",pass:!1,requiredValue:this.baseName});continue}const n=s.filter(t=>{if(!("value"in t._category)||!("value"in t.Name))return!1;if(this._unsupportedTypes.includes(t._category.value))return!1;return!!this.evalRequirement(t.Name.value,this.baseName,"BaseName")&&(i.push({currentValue:t.Name.value,parameter:"BaseName",pass:!0,requiredValue:this.baseName}),!0)});if(0!==n.length)for(const t of n)this.evalValue(t,i),this.evalDataType(t,i),this.evalURI();else i.push({currentValue:null,parameter:"BaseName",pass:!1,requiredValue:this.baseName})}else i.push({currentValue:null,parameter:"PropertySet",pass:!1,requiredValue:this.propertySet})}}}getPropertyListName(t){let e;return"value"in t._category?("IFCPROPERTYSET"===t._category.value&&(e="HasProperties"),"IFCELEMENTQUANTITY"===t._category.value&&(e="Quantities"),e):e}getValueKey(t){return Object.keys(t).find(t=>/Value/.test(t)||/Values/.test(t))}getTypePsets(t){if(!Array.isArray(t.IsTypedBy))return[];const[e]=t.IsTypedBy;return e&&Array.isArray(e.HasPropertySets)?e.HasPropertySets:[]}async getPsets(t){const e=this.getTypePsets(t);if(!Array.isArray(t.IsDefinedBy))return e;const i=[];for(const s of t.IsDefinedBy){if(!("value"in s.Name))continue;const t=s.Name.value,n=this.getPropertyListName(s);if(!t||!n)continue;const r=e.find(e=>"value"in e.Name&&e.Name.value===t);if(r&&Array.isArray(r.HasProperties)&&Array.isArray(s.HasProperties))for(const t of r.HasProperties){if(!("value"in t.Name))continue;const e=t.Name.value;s.HasProperties.find(t=>"value"in t.Name&&t.Name.value===e)||s.HasProperties.push(t)}i.push(s)}return i}evalValue(t,e){const i=this.getValueKey(t),s=t[i];if(!("value"in s))return!1;if(this.value){if(!i)return null==e||e.push({parameter:"Value",currentValue:null,pass:!1,requiredValue:this.value}),!1;const t=structuredClone(this.value);"IFCLABEL"===s.type&&"simple"===t.type&&(t.parameter=String(t.parameter));return this.evalRequirement(s.value,t,"Value",e)}return!i||("string"!=typeof s.value||""!==s.value.trim()||(null==e||e.push({parameter:"Value",currentValue:"",pass:!1,requiredValue:this.value}),!1))}evalDataType(t,e){if(!this.dataType)return!0;const i=this.getValueKey(t);if(!i||!("value"in t[i]))return null==e||e.push({parameter:"DataType",currentValue:null,pass:!1,requiredValue:this.dataType}),!1;const s=t[i];return this.evalRequirement(s.type??null,{type:"simple",parameter:this.dataType},"DataType",e)}evalURI(){return!0}}class jo extends No{constructor(){super(...arguments),e(this,"_ifcMaterialEntities",[/^IFCMATERIALLAYERSETUSAGE$/,/^IFCMATERIALCONSTITUENTSET$/,/^IFCMATERIAL$/,/^IFCMATERIALLIST$/]),e(this,"facetType","Material"),e(this,"value"),e(this,"uri")}serialize(t){if(!this.value||!this.uri)return"<material />";const e=Uo("Value",this.value);let i="";return"requirement"===t&&(i+=`cardinality="${this.cardinality}"`,i+=this.uri?`uri=${this.uri}`:"",i+=this.instructions?`instructions="${this.instructions}"`:""),`<material ${i}>\n ${e}\n</material>`}async getEntities(t,e){const i=this._components.get(Ae);for(const[s,n]of i.list){if(!t.find(t=>t.test(s)))continue;const i=await n.getItemsOfCategories(this._ifcMaterialEntities),r=Object.values(i).flat();if(0===r.length)continue;const o=await n.getItemsData(r,{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 t of o){if(!("value"in t._localId&&"value"in t._category&&Array.isArray(t.AssociatedTo)))continue;if(!this.hasValidMaterial(t))continue;const i=t.AssociatedTo.map(t=>"value"in t._localId&&t._localId.value?t._localId.value:null).filter(t=>null!==t);ye.append(e,s,...i)}}}async test(t,e){const i=this._components.get(Ae);for(const[s,n]of Object.entries(t)){const t=i.list.get(s);if(!t)continue;const r=await t.getItemsData([[...n][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 t of r){const i=this.getItemChecks(e,s,t);if(i)if(Array.isArray(t.HasAssociations))for(const e of t.HasAssociations){if(!this._ifcMaterialEntities.some(t=>"value"in e._category&&t.test(e._category.value)))continue;if(this.hasValidMaterial(e,i))break}else i.push({parameter:null,currentValue:null,requiredValue:this.value,pass:!1})}}}hasValidMaterial(t,e){let i=!1;if("value"in t._category&&"IFCMATERIAL"===t._category.value){this.evalValue(t,e)&&(i=!0)}else for(const[s,n]of Object.entries(t))if(["ForLayerSet","MaterialLayers","Material","MaterialConstituents","Materials"].includes(s)&&Array.isArray(n))for(const t of n){if("value"in t._category&&"IFCMATERIAL"===t._category.value){if(this.evalValue(t,e)){i=!0;break}}else{if(this.hasValidMaterial(t)){i=!0;break}}}return i}evalValue(t,e){if(!this.value)return null==e||e.push({parameter:null,currentValue:t.Name&&"value"in t.Name?t.Name.value:null,pass:!0}),!0;if(!("value"in t._category)||"IFCMATERIAL"!==t._category.value)return null;let i=!1;return t.Name&&"value"in t.Name&&(i=this.evalRequirement(t.Name.value,this.value,"Value",e)),i||(t.Category&&"value"in t.Category&&(i=this.evalRequirement(t.Category.value,this.value,"Value",e)),i)}}class Zo extends No{constructor(t,i){super(t),e(this,"facetType","PartOf"),e(this,"_entityFacet"),e(this,"_entity"),e(this,"relation"),e(this,"cardinality","required"),this._entity=i,this._entityFacet=new Fo(t,i.name),this._entityFacet.predefinedType=i.predefinedType}set entity(t){this._entity=t;const{name:e,predefinedType:i}=t;this._entityFacet=new Fo(this._components,e),this._entityFacet.predefinedType=i}get entity(){return this._entity}serialize(){return""}async getEntities(t,e){}async test(t){}}class Ho{constructor(t,s,n){e(this,"name"),e(this,"ifcVersion",new Set),e(this,"identifier",q.create()),e(this,"description"),e(this,"instructions"),e(this,"requirementsDescription"),e(this,"applicability",new i.DataSet),e(this,"requirements",new i.DataSet),e(this,"components"),this.components=t,this.name=s;for(const t of n)this.ifcVersion.add(t)}set(t){const e=t,i=this;for(const s in t){if("identifier"===s)continue;const t=e[s];s in this&&(i[s]=t)}return this.components.get(Jo).list.set(this.identifier,this),this}async test(t){const e=new i.DataMap;if(0===this.requirements.size)return e;const s={},n=[];for(const e of this.applicability)n.push(e.getEntities(t,s));await Promise.all(n);const r=[];for(const t of this.requirements)r.push(t.test(s,e));return await Promise.all(r),e}serialize(){const t=`name="${this.name}"`,e=this.identifier?`identifier="${this.identifier}"`:"",i=this.description?`description="${this.description}"`:"",s=this.instructions?`instructions="${this.instructions}"`:"";return`<specification ifcVersion="${[...this.ifcVersion].join(" ")}" ${t} ${e} ${i} ${s}>\n <applicability minOccurs="1" maxOccurs="unbounded">\n ${[...this.applicability].map(t=>t.serialize("applicability")).join("\n")}\n </applicability>\n <requirements>\n ${[...this.requirements].map(t=>t.serialize("requirement")).join("\n")}\n </requirements>\n </specification>`}}const $o=t=>{if(!t)return;const e={};if("simpleValue"in t&&(e.type="simple",e.parameter=t.simpleValue),"restriction"in t){const i=t.restriction,s=Object.keys(i);if("pattern"in i&&(e.type="pattern",e.parameter=i.pattern.value),"enumeration"in i){e.type="enumeration";const t=i.enumeration.map(({value:t})=>t);e.parameter=t}if(s.some(t=>["minInclusive","minExclusive","maxInclusive","maxExclusive"].includes(t))){e.type="bounds";const t={},n=s.find(t=>t.includes("min")),r=s.find(t=>t.includes("max"));n&&(t.minInclusive="minInclusive"===n,t.min=i[n].value),r&&(t.maxInclusive="maxInclusive"===r,t.max=i[r].value),e.parameter=t}if(s.some(t=>["minLength","length","maxLength"].includes(t))){e.type="length";const t={};void 0!==i.length&&(t.length=i.length.value),void 0!==i.minLength&&(t.min=i.minLength.value),void 0!==i.maxLength&&(t.max=i.maxLength.value),e.parameter=t}}return void 0!==e.parameter?e:void 0},Wo=(t,e)=>{const i=[];for(const s of e){const e=s.name,n=$o(e);if(!n)continue;const r=new Fo(t,n);s.cardinality&&(r.cardinality=s.cardinality),r.predefinedType=$o(s.predefinedType),r.instructions=s.instructions,i.push(r)}return i},Yo=(t,e)=>{const i=[];for(const s of e){const e=s.name,n=$o(e);if(!n)continue;const r=new Lo(t,n);s.cardinality&&(r.cardinality=s.cardinality),r.value=$o(s.value),r.instructions=s.instructions,i.push(r)}return i},Xo=(t,e)=>{const i=[];for(const s of e){const e=new jo(t);s.cardinality&&(e.cardinality=s.cardinality);const n=$o(s.value);"enumeration"===(null==n?void 0:n.type)&&Array.isArray(n.parameter)&&(n.parameter=n.parameter.map(String)),e.value=n,e.uri=s.uri,e.instructions=s.instructions,i.push(e)}return i},qo=(t,e)=>{const i=[];for(const s of e){const e=s.propertySet,n=s.baseName,r=$o(e),o=$o(n);if(!o||!r)continue;const a=new Vo(t,r,o);s.cardinality&&(a.cardinality=s.cardinality);const l=$o(s.value);a.value=l,a.dataType=s.dataType,a.uri=s.uri,a.instructions=s.instructions,i.push(a)}return i},Go=(t,e)=>{const i=[];for(const s of e){const e=s.system,n=$o(e);if(!n)continue;const r=new Ro(t,n);s.cardinality&&(r.cardinality=s.cardinality);const o=$o(s.value);"simple"===(null==o?void 0:o.type)&&(o.parameter=String(o.parameter)),"enumeration"===(null==o?void 0:o.type)&&Array.isArray(o.parameter)&&(o.parameter=o.parameter.map(String)),r.value=o,r.uri=s.uri,r.instructions=s.instructions,i.push(r)}return i},Qo=(t,e)=>{const i=[];for(const s of e){const e=$o(s.entity.name);if(!e)continue;const n=$o(s.entity.predefinedType),r=new Zo(t,{name:e,predefinedType:n});r.relation=s.relation,s.cardinality&&(r.cardinality=s.cardinality),r.instructions=s.instructions,i.push(r)}return i},Ko=class t extends F{constructor(i){super(i),e(this,"enabled",!0),e(this,"list",new we),i.add(t.uuid,this)}getModelIdMap(t){const e={},i={};for(const[s,n]of t){const t=[...n].filter(([,t])=>t.pass).map(([t])=>t);ye.append(e,s,...t);const r=[...n].filter(([,t])=>!t.pass).map(([t])=>t);ye.append(i,s,...r)}return{pass:e,fail:i}}create(t,e,i){const s=new Ho(this.components,t,e);return i&&(s.identifier=i),this.list.set(s.identifier,s),s}load(e){const i=[],s=t.xmlParser.parse(e).ids,{specifications:n}=s;if(n&&n.specification){const t=Array.isArray(n.specification)?n.specification:[n.specification];for(const e of t){const{name:t,ifcVersion:s,description:n,instructions:r,identifier:o}=e;if(!t||!s)continue;const a=[],l=[],{applicability:h,requirements:c}=e;if(h){const{maxOccurs:t,...e}=h,i=Array.isArray(e)?e:[e];for(const t of i)for(const e in t){const i=Array.isArray(t[e])?t[e]:[t[e]];if("entity"===e){const t=Wo(this.components,i);a.push(...t)}if("attribute"===e){const t=Yo(this.components,i);a.push(...t)}if("material"===e){const t=Xo(this.components,i);a.push(...t)}if("classification"===e){const t=Go(this.components,i);a.push(...t)}if("property"===e){const t=qo(this.components,i);a.push(...t)}if("partOf"===e){const t=Qo(this.components,i);a.push(...t)}}}let d;if(c){const{maxOccurs:t,...e}=c;d=c.description;const i=Array.isArray(e)?e:[e];for(const t of i)for(const e in t){const i=Array.isArray(t[e])?t[e]:[t[e]];if("entity"===e){const t=Wo(this.components,i);l.push(...t)}if("attribute"===e){const t=Yo(this.components,i);l.push(...t)}if("material"===e){const t=Xo(this.components,i);l.push(...t)}if("classification"===e){const t=Go(this.components,i);l.push(...t)}if("property"===e){const t=qo(this.components,i);l.push(...t)}if("partOf"===e){const t=Qo(this.components,i);l.push(...t)}}}const u=this.create(t,s.split(/\s+/),o);u.description=n,u.instructions=r,u.requirementsDescription=d,u.applicability.add(...a),u.requirements.add(...l),i.push(u)}}return i}export(t,e=this.list.values()){const i=e??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 ${Sr.release} (https://github.com/thatopen/engine_components) --\x3e\n <info>\n <title>${t.title}</title>\n ${t.copyright?`<copyright>${t.copyright}</copyright>`:""}\n ${t.version?`<version>${t.version}</version>`:""}\n ${t.description?`<description>${t.description}</description>`:""}\n ${t.author?`<author>${t.author}</author>`:""}\n ${t.date?`<date>${t.date.toISOString().split("T")[0]}</date>`:""}\n ${t.purpose?`<purpose>${t.purpose}</purpose>`:""}\n ${t.milestone?`<milestone>${t.milestone}</milestone>`:""}\n </info>\n <specifications>\n ${[...i].map(t=>t.serialize()).join("\n")}\n </specifications>\n</ids>`}};e(Ko,"uuid","9f0b9f78-9b2e-481a-b766-2fbfd01f342c"),e(Ko,"xmlParser",new me.XMLParser({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 Jo=Ko;const ta=class t extends F{constructor(i){super(i),e(this,"enabled",!0),i.add(t.uuid,this)}static distanceFromPointToLine(t,e,i,s=!1){const n=new r.Line3,o=new r.Vector3;return n.set(e,i),n.closestPointToPoint(t,s,o),o.distanceTo(t)}round(t){const e=1e3;t.x=Math.trunc(t.x*e)/e,t.y=Math.trunc(t.y*e)/e,t.z=Math.trunc(t.z*e)/e}async getVolumeFromFragments(t){return console.warn("getVolumeFromFragments is deprecated. Use getItemsVolume instead."),this.getItemsVolume(t)}async getItemsVolume(t){let e=0;const i=this.components.get(Ae);for(const[s,n]of Object.entries(t)){const t=i.list.get(s);t&&(e+=await t.getItemsVolume([...n]))}return e}static convertUnits(t,e,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[e]||!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.");let r=n[e]/n[i];e.endsWith("2")&&i.endsWith("2")?r**=2:e.endsWith("3")&&i.endsWith("3")&&(r**=3);const o=t*r,a=10**s;return Math.round(o*a)/a}};e(ta,"uuid","267ca032-672f-4cb0-afa9-d24e904f39d6");let ea=ta;export{L as AsyncEvent,Vr as BCFTopics,Rr as BCFTopicsConfigManager,R as Base,j as BaseCamera,Z as BaseRenderer,W as BaseScene,V as BaseWorldItem,Me as BoundingBoxer,Re as Classifier,Co as Clipper,Br as Comment,F as Component,Sr as Components,Te as ConfigManager,xe as Configurator,ve as ControlsUtils,we as DataMap,Y as DataSet,$ as Disposer,U as Event,be as EventManager,Be as FinderQuery,Ar as FirstPersonMode,Ae as FragmentsManager,Qi as Grids,De as Hider,Lo as IDSAttribute,Ro as IDSClassification,Fo as IDSEntity,No as IDSFacet,jo as IDSMaterial,Zo as IDSPartOf,Vo as IDSProperty,Ho as IDSSpecification,Jo as IDSSpecifications,Oe as IfcFragmentSettings,Ie as IfcLoader,Ue as ItemsFinder,ea as MeasurementUtils,ye as ModelIdMapUtils,Ce as Mouse,Or as OrbitMode,kr as OrthoPerspectiveCamera,Pr as PlanMode,Ir as ProjectionManager,je as Raycasters,Bo as ShadowedScene,$i as SimpleCamera,qi as SimpleGrid,Xi as SimpleGridConfigManager,xo as SimplePlane,Fe as SimpleRaycaster,Xe as SimpleRenderer,Ye as SimpleScene,We as SimpleSceneConfigManager,Ze as SimpleWorld,Ur as Topic,q as UUID,_e as VertexPicker,Io as View,So as Viewpoint,Po as Viewpoints,Do as Views,Yi as Worlds,ge as XML,Lr as extensionsImporter};
|