iflow-engine-base 3.4.8 → 3.4.9
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.
|
@@ -4930,18 +4930,18 @@ void main() {
|
|
|
4930
4930
|
|
|
4931
4931
|
gl_FragColor = color;
|
|
4932
4932
|
}
|
|
4933
|
-
`};class q0{engine;composer;saturationPass;ssaoPass;gtaoPass;outputPass;fxaaPass;constructor(e){this.engine=e}applyClippingToAmbientOcclusionPass(e){const t=Array.isArray(this.engine.sectionPlane)?this.engine.sectionPlane:null,n=e?.normalMaterial;n&&(n.clippingPlanes=t,n.needsUpdate=!0)}syncAmbientOcclusionClipping(){this.applyClippingToAmbientOcclusionPass(this.gtaoPass),this.applyClippingToAmbientOcclusionPass(this.ssaoPass)}resize(e,t){if(e===void 0||t===void 0){const r=this.engine.deviceModule.getContainerSize();e=e??r.width,t=t??r.height}if(!e||!t||!this.composer)return;const n=this.engine.renderer?.getPixelRatio?.()??window.devicePixelRatio??1;this.composer.setPixelRatio(n),this.composer.setSize(e,t);const i=this.composer.passes.find(r=>r instanceof br&&r.material.uniforms.resolution);i&&(i.material.uniforms.resolution.value.x=1/(e*n),i.material.uniforms.resolution.value.y=1/(t*n))}init(){const{width:e,height:t}=this.engine.deviceModule.getContainerSize(),n=this.engine.scene,i=this.engine.camera,r=this.engine.renderer,o=this.engine.renderer?.getPixelRatio?.()??window.devicePixelRatio??1,a=new y.WebGLRenderTarget(e,t,{minFilter:y.LinearFilter,magFilter:y.LinearFilter,format:y.RGBAFormat,samples:4});this.composer=new z0(r,a),this.composer.setPixelRatio(o),this.composer.setSize(e,t);const l=new V0(n,i);this.composer.addPass(l),this.gtaoPass=new hn(n,i,e,t),this.gtaoPass.output=hn.OUTPUT.Default,this.gtaoPass.blendIntensity=.3,this.gtaoPass.enabled=!1,this.gtaoPass.updateGtaoMaterial&&this.gtaoPass.updateGtaoMaterial({enabled:!0,radius:.
|
|
4933
|
+
`};class q0{engine;composer;saturationPass;ssaoPass;gtaoPass;outputPass;fxaaPass;constructor(e){this.engine=e}applyClippingToAmbientOcclusionPass(e){const t=Array.isArray(this.engine.sectionPlane)?this.engine.sectionPlane:null,n=e?.normalMaterial;n&&(n.clippingPlanes=t,n.needsUpdate=!0)}syncAmbientOcclusionClipping(){this.applyClippingToAmbientOcclusionPass(this.gtaoPass),this.applyClippingToAmbientOcclusionPass(this.ssaoPass)}resize(e,t){if(e===void 0||t===void 0){const r=this.engine.deviceModule.getContainerSize();e=e??r.width,t=t??r.height}if(!e||!t||!this.composer)return;const n=this.engine.renderer?.getPixelRatio?.()??window.devicePixelRatio??1;this.composer.setPixelRatio(n),this.composer.setSize(e,t);const i=this.composer.passes.find(r=>r instanceof br&&r.material.uniforms.resolution);i&&(i.material.uniforms.resolution.value.x=1/(e*n),i.material.uniforms.resolution.value.y=1/(t*n))}init(){const{width:e,height:t}=this.engine.deviceModule.getContainerSize(),n=this.engine.scene,i=this.engine.camera,r=this.engine.renderer,o=this.engine.renderer?.getPixelRatio?.()??window.devicePixelRatio??1,a=new y.WebGLRenderTarget(e,t,{minFilter:y.LinearFilter,magFilter:y.LinearFilter,format:y.RGBAFormat,samples:4});this.composer=new z0(r,a),this.composer.setPixelRatio(o),this.composer.setSize(e,t);const l=new V0(n,i);this.composer.addPass(l),this.gtaoPass=new hn(n,i,e,t),this.gtaoPass.output=hn.OUTPUT.Default,this.gtaoPass.blendIntensity=.3,this.gtaoPass.enabled=!1,this.gtaoPass.updateGtaoMaterial&&this.gtaoPass.updateGtaoMaterial({enabled:!0,radius:.3,thickness:1,distanceExponent:1,distanceFallOff:1,scale:3,samples:16,resolutionScale:.45,useTemporalFiltering:!1,screenSpaceRadius:!1}),this.applyClippingToAmbientOcclusionPass(this.gtaoPass),this.composer.addPass(this.gtaoPass),this.ssaoPass=new On(n,i,e,t),this.ssaoPass.kernelRadius=8,this.ssaoPass.minDistance=.005,this.ssaoPass.maxDistance=.1,this.ssaoPass.output=On.OUTPUT.Default,this.ssaoPass.enabled=!1,this.applyClippingToAmbientOcclusionPass(this.ssaoPass),this.composer.addPass(this.ssaoPass),this.saturationPass=new br(Y0),this.saturationPass.uniforms.saturation.value=1.3,this.saturationPass.uniforms.contrast.value=1.1,this.saturationPass.enabled=!1,this.composer.addPass(this.saturationPass),this.outputPass=new X0,this.outputPass.enabled=!1,this.composer.addPass(this.outputPass),this.fxaaPass=new br(j0),this.fxaaPass.material.uniforms.resolution.value.x=1/(e*o),this.fxaaPass.material.uniforms.resolution.value.y=1/(t*o),this.fxaaPass.enabled=!1,this.composer.addPass(this.fxaaPass)}}var Dr=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Wc(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}function Rr(s){throw new Error('Could not dynamically require "'+s+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Na={exports:{}};var Hc;function Z0(){return Hc||(Hc=1,(function(s,e){(function(t){s.exports=t()})(function(){return(function t(n,i,r){function o(c,h){if(!i[c]){if(!n[c]){var d=typeof Rr=="function"&&Rr;if(!h&&d)return d(c,!0);if(a)return a(c,!0);var g=new Error("Cannot find module '"+c+"'");throw g.code="MODULE_NOT_FOUND",g}var u=i[c]={exports:{}};n[c][0].call(u.exports,function(m){var f=n[c][1][m];return o(f||m)},u,u.exports,t,n,i,r)}return i[c].exports}for(var a=typeof Rr=="function"&&Rr,l=0;l<r.length;l++)o(r[l]);return o})({1:[function(t,n,i){var r=t("./utils"),o=t("./support"),a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";i.encode=function(l){for(var c,h,d,g,u,m,f,p=[],x=0,v=l.length,_=v,b=r.getTypeOf(l)!=="string";x<l.length;)_=v-x,d=b?(c=l[x++],h=x<v?l[x++]:0,x<v?l[x++]:0):(c=l.charCodeAt(x++),h=x<v?l.charCodeAt(x++):0,x<v?l.charCodeAt(x++):0),g=c>>2,u=(3&c)<<4|h>>4,m=1<_?(15&h)<<2|d>>6:64,f=2<_?63&d:64,p.push(a.charAt(g)+a.charAt(u)+a.charAt(m)+a.charAt(f));return p.join("")},i.decode=function(l){var c,h,d,g,u,m,f=0,p=0,x="data:";if(l.substr(0,x.length)===x)throw new Error("Invalid base64 input, it looks like a data url.");var v,_=3*(l=l.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(l.charAt(l.length-1)===a.charAt(64)&&_--,l.charAt(l.length-2)===a.charAt(64)&&_--,_%1!=0)throw new Error("Invalid base64 input, bad content length.");for(v=o.uint8array?new Uint8Array(0|_):new Array(0|_);f<l.length;)c=a.indexOf(l.charAt(f++))<<2|(g=a.indexOf(l.charAt(f++)))>>4,h=(15&g)<<4|(u=a.indexOf(l.charAt(f++)))>>2,d=(3&u)<<6|(m=a.indexOf(l.charAt(f++))),v[p++]=c,u!==64&&(v[p++]=h),m!==64&&(v[p++]=d);return v}},{"./support":30,"./utils":32}],2:[function(t,n,i){var r=t("./external"),o=t("./stream/DataWorker"),a=t("./stream/Crc32Probe"),l=t("./stream/DataLengthProbe");function c(h,d,g,u,m){this.compressedSize=h,this.uncompressedSize=d,this.crc32=g,this.compression=u,this.compressedContent=m}c.prototype={getContentWorker:function(){var h=new o(r.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new l("data_length")),d=this;return h.on("end",function(){if(this.streamInfo.data_length!==d.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),h},getCompressedWorker:function(){return new o(r.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},c.createWorkerFrom=function(h,d,g){return h.pipe(new a).pipe(new l("uncompressedSize")).pipe(d.compressWorker(g)).pipe(new l("compressedSize")).withStreamInfo("compression",d)},n.exports=c},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(t,n,i){var r=t("./stream/GenericWorker");i.STORE={magic:"\0\0",compressWorker:function(){return new r("STORE compression")},uncompressWorker:function(){return new r("STORE decompression")}},i.DEFLATE=t("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(t,n,i){var r=t("./utils"),o=(function(){for(var a,l=[],c=0;c<256;c++){a=c;for(var h=0;h<8;h++)a=1&a?3988292384^a>>>1:a>>>1;l[c]=a}return l})();n.exports=function(a,l){return a!==void 0&&a.length?r.getTypeOf(a)!=="string"?(function(c,h,d,g){var u=o,m=g+d;c^=-1;for(var f=g;f<m;f++)c=c>>>8^u[255&(c^h[f])];return-1^c})(0|l,a,a.length,0):(function(c,h,d,g){var u=o,m=g+d;c^=-1;for(var f=g;f<m;f++)c=c>>>8^u[255&(c^h.charCodeAt(f))];return-1^c})(0|l,a,a.length,0):0}},{"./utils":32}],5:[function(t,n,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,n,i){var r=null;r=typeof Promise<"u"?Promise:t("lie"),n.exports={Promise:r}},{lie:37}],7:[function(t,n,i){var r=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",o=t("pako"),a=t("./utils"),l=t("./stream/GenericWorker"),c=r?"uint8array":"array";function h(d,g){l.call(this,"FlateWorker/"+d),this._pako=null,this._pakoAction=d,this._pakoOptions=g,this.meta={}}i.magic="\b\0",a.inherits(h,l),h.prototype.processChunk=function(d){this.meta=d.meta,this._pako===null&&this._createPako(),this._pako.push(a.transformTo(c,d.data),!1)},h.prototype.flush=function(){l.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},h.prototype.cleanUp=function(){l.prototype.cleanUp.call(this),this._pako=null},h.prototype._createPako=function(){this._pako=new o[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var d=this;this._pako.onData=function(g){d.push({data:g,meta:d.meta})}},i.compressWorker=function(d){return new h("Deflate",d)},i.uncompressWorker=function(){return new h("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(t,n,i){function r(u,m){var f,p="";for(f=0;f<m;f++)p+=String.fromCharCode(255&u),u>>>=8;return p}function o(u,m,f,p,x,v){var _,b,S=u.file,C=u.compression,R=v!==c.utf8encode,I=a.transformTo("string",v(S.name)),E=a.transformTo("string",c.utf8encode(S.name)),T=S.comment,U=a.transformTo("string",v(T)),D=a.transformTo("string",c.utf8encode(T)),O=E.length!==S.name.length,w=D.length!==T.length,V="",z="",H="",Y=S.dir,W=S.date,Q={crc32:0,compressedSize:0,uncompressedSize:0};m&&!f||(Q.crc32=u.crc32,Q.compressedSize=u.compressedSize,Q.uncompressedSize=u.uncompressedSize);var X=0;m&&(X|=8),R||!O&&!w||(X|=2048);var j=0,me=0;Y&&(j|=16),x==="UNIX"?(me=798,j|=(function(ue,se){var le=ue;return ue||(le=se?16893:33204),(65535&le)<<16})(S.unixPermissions,Y)):(me=20,j|=(function(ue){return 63&(ue||0)})(S.dosPermissions)),_=W.getUTCHours(),_<<=6,_|=W.getUTCMinutes(),_<<=5,_|=W.getUTCSeconds()/2,b=W.getUTCFullYear()-1980,b<<=4,b|=W.getUTCMonth()+1,b<<=5,b|=W.getUTCDate(),O&&(z=r(1,1)+r(h(I),4)+E,V+="up"+r(z.length,2)+z),w&&(H=r(1,1)+r(h(U),4)+D,V+="uc"+r(H.length,2)+H);var ge="";return ge+=`
|
|
4934
4934
|
\0`,ge+=r(X,2),ge+=C.magic,ge+=r(_,2),ge+=r(b,2),ge+=r(Q.crc32,4),ge+=r(Q.compressedSize,4),ge+=r(Q.uncompressedSize,4),ge+=r(I.length,2),ge+=r(V.length,2),{fileRecord:d.LOCAL_FILE_HEADER+ge+I+V,dirRecord:d.CENTRAL_FILE_HEADER+r(me,2)+ge+r(U.length,2)+"\0\0\0\0"+r(j,4)+r(p,4)+I+V+U}}var a=t("../utils"),l=t("../stream/GenericWorker"),c=t("../utf8"),h=t("../crc32"),d=t("../signature");function g(u,m,f,p){l.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=m,this.zipPlatform=f,this.encodeFileName=p,this.streamFiles=u,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}a.inherits(g,l),g.prototype.push=function(u){var m=u.meta.percent||0,f=this.entriesCount,p=this._sources.length;this.accumulate?this.contentBuffer.push(u):(this.bytesWritten+=u.data.length,l.prototype.push.call(this,{data:u.data,meta:{currentFile:this.currentFile,percent:f?(m+100*(f-p-1))/f:100}}))},g.prototype.openedSource=function(u){this.currentSourceOffset=this.bytesWritten,this.currentFile=u.file.name;var m=this.streamFiles&&!u.file.dir;if(m){var f=o(u,m,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:f.fileRecord,meta:{percent:0}})}else this.accumulate=!0},g.prototype.closedSource=function(u){this.accumulate=!1;var m=this.streamFiles&&!u.file.dir,f=o(u,m,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(f.dirRecord),m)this.push({data:(function(p){return d.DATA_DESCRIPTOR+r(p.crc32,4)+r(p.compressedSize,4)+r(p.uncompressedSize,4)})(u),meta:{percent:100}});else for(this.push({data:f.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},g.prototype.flush=function(){for(var u=this.bytesWritten,m=0;m<this.dirRecords.length;m++)this.push({data:this.dirRecords[m],meta:{percent:100}});var f=this.bytesWritten-u,p=(function(x,v,_,b,S){var C=a.transformTo("string",S(b));return d.CENTRAL_DIRECTORY_END+"\0\0\0\0"+r(x,2)+r(x,2)+r(v,4)+r(_,4)+r(C.length,2)+C})(this.dirRecords.length,f,u,this.zipComment,this.encodeFileName);this.push({data:p,meta:{percent:100}})},g.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},g.prototype.registerPrevious=function(u){this._sources.push(u);var m=this;return u.on("data",function(f){m.processChunk(f)}),u.on("end",function(){m.closedSource(m.previous.streamInfo),m._sources.length?m.prepareNextSource():m.end()}),u.on("error",function(f){m.error(f)}),this},g.prototype.resume=function(){return!!l.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},g.prototype.error=function(u){var m=this._sources;if(!l.prototype.error.call(this,u))return!1;for(var f=0;f<m.length;f++)try{m[f].error(u)}catch{}return!0},g.prototype.lock=function(){l.prototype.lock.call(this);for(var u=this._sources,m=0;m<u.length;m++)u[m].lock()},n.exports=g},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(t,n,i){var r=t("../compressions"),o=t("./ZipFileWorker");i.generateWorker=function(a,l,c){var h=new o(l.streamFiles,c,l.platform,l.encodeFileName),d=0;try{a.forEach(function(g,u){d++;var m=(function(v,_){var b=v||_,S=r[b];if(!S)throw new Error(b+" is not a valid compression method !");return S})(u.options.compression,l.compression),f=u.options.compressionOptions||l.compressionOptions||{},p=u.dir,x=u.date;u._compressWorker(m,f).withStreamInfo("file",{name:g,dir:p,date:x,comment:u.comment||"",unixPermissions:u.unixPermissions,dosPermissions:u.dosPermissions}).pipe(h)}),h.entriesCount=d}catch(g){h.error(g)}return h}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(t,n,i){function r(){if(!(this instanceof r))return new r;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 o=new r;for(var a in this)typeof this[a]!="function"&&(o[a]=this[a]);return o}}(r.prototype=t("./object")).loadAsync=t("./load"),r.support=t("./support"),r.defaults=t("./defaults"),r.version="3.10.1",r.loadAsync=function(o,a){return new r().loadAsync(o,a)},r.external=t("./external"),n.exports=r},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(t,n,i){var r=t("./utils"),o=t("./external"),a=t("./utf8"),l=t("./zipEntries"),c=t("./stream/Crc32Probe"),h=t("./nodejsUtils");function d(g){return new o.Promise(function(u,m){var f=g.decompressed.getContentWorker().pipe(new c);f.on("error",function(p){m(p)}).on("end",function(){f.streamInfo.crc32!==g.decompressed.crc32?m(new Error("Corrupted zip : CRC32 mismatch")):u()}).resume()})}n.exports=function(g,u){var m=this;return u=r.extend(u||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:a.utf8decode}),h.isNode&&h.isStream(g)?o.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):r.prepareContent("the loaded zip file",g,!0,u.optimizedBinaryString,u.base64).then(function(f){var p=new l(u);return p.load(f),p}).then(function(f){var p=[o.Promise.resolve(f)],x=f.files;if(u.checkCRC32)for(var v=0;v<x.length;v++)p.push(d(x[v]));return o.Promise.all(p)}).then(function(f){for(var p=f.shift(),x=p.files,v=0;v<x.length;v++){var _=x[v],b=_.fileNameStr,S=r.resolve(_.fileNameStr);m.file(S,_.decompressed,{binary:!0,optimizedBinaryString:!0,date:_.date,dir:_.dir,comment:_.fileCommentStr.length?_.fileCommentStr:null,unixPermissions:_.unixPermissions,dosPermissions:_.dosPermissions,createFolders:u.createFolders}),_.dir||(m.file(S).unsafeOriginalName=b)}return p.zipComment.length&&(m.comment=p.zipComment),m})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(t,n,i){var r=t("../utils"),o=t("../stream/GenericWorker");function a(l,c){o.call(this,"Nodejs stream input adapter for "+l),this._upstreamEnded=!1,this._bindStream(c)}r.inherits(a,o),a.prototype._bindStream=function(l){var c=this;(this._stream=l).pause(),l.on("data",function(h){c.push({data:h,meta:{percent:0}})}).on("error",function(h){c.isPaused?this.generatedError=h:c.error(h)}).on("end",function(){c.isPaused?c._upstreamEnded=!0:c.end()})},a.prototype.pause=function(){return!!o.prototype.pause.call(this)&&(this._stream.pause(),!0)},a.prototype.resume=function(){return!!o.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},n.exports=a},{"../stream/GenericWorker":28,"../utils":32}],13:[function(t,n,i){var r=t("readable-stream").Readable;function o(a,l,c){r.call(this,l),this._helper=a;var h=this;a.on("data",function(d,g){h.push(d)||h._helper.pause(),c&&c(g)}).on("error",function(d){h.emit("error",d)}).on("end",function(){h.push(null)})}t("../utils").inherits(o,r),o.prototype._read=function(){this._helper.resume()},n.exports=o},{"../utils":32,"readable-stream":16}],14:[function(t,n,i){n.exports={isNode:typeof Buffer<"u",newBufferFrom:function(r,o){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(r,o);if(typeof r=="number")throw new Error('The "data" argument must not be a number');return new Buffer(r,o)},allocBuffer:function(r){if(Buffer.alloc)return Buffer.alloc(r);var o=new Buffer(r);return o.fill(0),o},isBuffer:function(r){return Buffer.isBuffer(r)},isStream:function(r){return r&&typeof r.on=="function"&&typeof r.pause=="function"&&typeof r.resume=="function"}}},{}],15:[function(t,n,i){function r(S,C,R){var I,E=a.getTypeOf(C),T=a.extend(R||{},h);T.date=T.date||new Date,T.compression!==null&&(T.compression=T.compression.toUpperCase()),typeof T.unixPermissions=="string"&&(T.unixPermissions=parseInt(T.unixPermissions,8)),T.unixPermissions&&16384&T.unixPermissions&&(T.dir=!0),T.dosPermissions&&16&T.dosPermissions&&(T.dir=!0),T.dir&&(S=x(S)),T.createFolders&&(I=p(S))&&v.call(this,I,!0);var U=E==="string"&&T.binary===!1&&T.base64===!1;R&&R.binary!==void 0||(T.binary=!U),(C instanceof d&&C.uncompressedSize===0||T.dir||!C||C.length===0)&&(T.base64=!1,T.binary=!0,C="",T.compression="STORE",E="string");var D=null;D=C instanceof d||C instanceof l?C:m.isNode&&m.isStream(C)?new f(S,C):a.prepareContent(S,C,T.binary,T.optimizedBinaryString,T.base64);var O=new g(S,D,T);this.files[S]=O}var o=t("./utf8"),a=t("./utils"),l=t("./stream/GenericWorker"),c=t("./stream/StreamHelper"),h=t("./defaults"),d=t("./compressedObject"),g=t("./zipObject"),u=t("./generate"),m=t("./nodejsUtils"),f=t("./nodejs/NodejsStreamInputAdapter"),p=function(S){S.slice(-1)==="/"&&(S=S.substring(0,S.length-1));var C=S.lastIndexOf("/");return 0<C?S.substring(0,C):""},x=function(S){return S.slice(-1)!=="/"&&(S+="/"),S},v=function(S,C){return C=C!==void 0?C:h.createFolders,S=x(S),this.files[S]||r.call(this,S,null,{dir:!0,createFolders:C}),this.files[S]};function _(S){return Object.prototype.toString.call(S)==="[object RegExp]"}var b={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(S){var C,R,I;for(C in this.files)I=this.files[C],(R=C.slice(this.root.length,C.length))&&C.slice(0,this.root.length)===this.root&&S(R,I)},filter:function(S){var C=[];return this.forEach(function(R,I){S(R,I)&&C.push(I)}),C},file:function(S,C,R){if(arguments.length!==1)return S=this.root+S,r.call(this,S,C,R),this;if(_(S)){var I=S;return this.filter(function(T,U){return!U.dir&&I.test(T)})}var E=this.files[this.root+S];return E&&!E.dir?E:null},folder:function(S){if(!S)return this;if(_(S))return this.filter(function(E,T){return T.dir&&S.test(E)});var C=this.root+S,R=v.call(this,C),I=this.clone();return I.root=R.name,I},remove:function(S){S=this.root+S;var C=this.files[S];if(C||(S.slice(-1)!=="/"&&(S+="/"),C=this.files[S]),C&&!C.dir)delete this.files[S];else for(var R=this.filter(function(E,T){return T.name.slice(0,S.length)===S}),I=0;I<R.length;I++)delete this.files[R[I].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(S){var C,R={};try{if((R=a.extend(S||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:o.utf8encode})).type=R.type.toLowerCase(),R.compression=R.compression.toUpperCase(),R.type==="binarystring"&&(R.type="string"),!R.type)throw new Error("No output type specified.");a.checkSupport(R.type),R.platform!=="darwin"&&R.platform!=="freebsd"&&R.platform!=="linux"&&R.platform!=="sunos"||(R.platform="UNIX"),R.platform==="win32"&&(R.platform="DOS");var I=R.comment||this.comment||"";C=u.generateWorker(this,R,I)}catch(E){(C=new l("error")).error(E)}return new c(C,R.type||"string",R.mimeType)},generateAsync:function(S,C){return this.generateInternalStream(S).accumulate(C)},generateNodeStream:function(S,C){return(S=S||{}).type||(S.type="nodebuffer"),this.generateInternalStream(S).toNodejsStream(C)}};n.exports=b},{"./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,n,i){n.exports=t("stream")},{stream:void 0}],17:[function(t,n,i){var r=t("./DataReader");function o(a){r.call(this,a);for(var l=0;l<this.data.length;l++)a[l]=255&a[l]}t("../utils").inherits(o,r),o.prototype.byteAt=function(a){return this.data[this.zero+a]},o.prototype.lastIndexOfSignature=function(a){for(var l=a.charCodeAt(0),c=a.charCodeAt(1),h=a.charCodeAt(2),d=a.charCodeAt(3),g=this.length-4;0<=g;--g)if(this.data[g]===l&&this.data[g+1]===c&&this.data[g+2]===h&&this.data[g+3]===d)return g-this.zero;return-1},o.prototype.readAndCheckSignature=function(a){var l=a.charCodeAt(0),c=a.charCodeAt(1),h=a.charCodeAt(2),d=a.charCodeAt(3),g=this.readData(4);return l===g[0]&&c===g[1]&&h===g[2]&&d===g[3]},o.prototype.readData=function(a){if(this.checkOffset(a),a===0)return[];var l=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},n.exports=o},{"../utils":32,"./DataReader":18}],18:[function(t,n,i){var r=t("../utils");function o(a){this.data=a,this.length=a.length,this.index=0,this.zero=0}o.prototype={checkOffset:function(a){this.checkIndex(this.index+a)},checkIndex:function(a){if(this.length<this.zero+a||a<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+a+"). Corrupted zip ?")},setIndex:function(a){this.checkIndex(a),this.index=a},skip:function(a){this.setIndex(this.index+a)},byteAt:function(){},readInt:function(a){var l,c=0;for(this.checkOffset(a),l=this.index+a-1;l>=this.index;l--)c=(c<<8)+this.byteAt(l);return this.index+=a,c},readString:function(a){return r.transformTo("string",this.readData(a))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var a=this.readInt(4);return new Date(Date.UTC(1980+(a>>25&127),(a>>21&15)-1,a>>16&31,a>>11&31,a>>5&63,(31&a)<<1))}},n.exports=o},{"../utils":32}],19:[function(t,n,i){var r=t("./Uint8ArrayReader");function o(a){r.call(this,a)}t("../utils").inherits(o,r),o.prototype.readData=function(a){this.checkOffset(a);var l=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},n.exports=o},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(t,n,i){var r=t("./DataReader");function o(a){r.call(this,a)}t("../utils").inherits(o,r),o.prototype.byteAt=function(a){return this.data.charCodeAt(this.zero+a)},o.prototype.lastIndexOfSignature=function(a){return this.data.lastIndexOf(a)-this.zero},o.prototype.readAndCheckSignature=function(a){return a===this.readData(4)},o.prototype.readData=function(a){this.checkOffset(a);var l=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},n.exports=o},{"../utils":32,"./DataReader":18}],21:[function(t,n,i){var r=t("./ArrayReader");function o(a){r.call(this,a)}t("../utils").inherits(o,r),o.prototype.readData=function(a){if(this.checkOffset(a),a===0)return new Uint8Array(0);var l=this.data.subarray(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},n.exports=o},{"../utils":32,"./ArrayReader":17}],22:[function(t,n,i){var r=t("../utils"),o=t("../support"),a=t("./ArrayReader"),l=t("./StringReader"),c=t("./NodeBufferReader"),h=t("./Uint8ArrayReader");n.exports=function(d){var g=r.getTypeOf(d);return r.checkSupport(g),g!=="string"||o.uint8array?g==="nodebuffer"?new c(d):o.uint8array?new h(r.transformTo("uint8array",d)):new a(r.transformTo("array",d)):new l(d)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(t,n,i){i.LOCAL_FILE_HEADER="PK",i.CENTRAL_FILE_HEADER="PK",i.CENTRAL_DIRECTORY_END="PK",i.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",i.ZIP64_CENTRAL_DIRECTORY_END="PK",i.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(t,n,i){var r=t("./GenericWorker"),o=t("../utils");function a(l){r.call(this,"ConvertWorker to "+l),this.destType=l}o.inherits(a,r),a.prototype.processChunk=function(l){this.push({data:o.transformTo(this.destType,l.data),meta:l.meta})},n.exports=a},{"../utils":32,"./GenericWorker":28}],25:[function(t,n,i){var r=t("./GenericWorker"),o=t("../crc32");function a(){r.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}t("../utils").inherits(a,r),a.prototype.processChunk=function(l){this.streamInfo.crc32=o(l.data,this.streamInfo.crc32||0),this.push(l)},n.exports=a},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(t,n,i){var r=t("../utils"),o=t("./GenericWorker");function a(l){o.call(this,"DataLengthProbe for "+l),this.propName=l,this.withStreamInfo(l,0)}r.inherits(a,o),a.prototype.processChunk=function(l){if(l){var c=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=c+l.data.length}o.prototype.processChunk.call(this,l)},n.exports=a},{"../utils":32,"./GenericWorker":28}],27:[function(t,n,i){var r=t("../utils"),o=t("./GenericWorker");function a(l){o.call(this,"DataWorker");var c=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,l.then(function(h){c.dataIsReady=!0,c.data=h,c.max=h&&h.length||0,c.type=r.getTypeOf(h),c.isPaused||c._tickAndRepeat()},function(h){c.error(h)})}r.inherits(a,o),a.prototype.cleanUp=function(){o.prototype.cleanUp.call(this),this.data=null},a.prototype.resume=function(){return!!o.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,r.delay(this._tickAndRepeat,[],this)),!0)},a.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(r.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},a.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var l=null,c=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":l=this.data.substring(this.index,c);break;case"uint8array":l=this.data.subarray(this.index,c);break;case"array":case"nodebuffer":l=this.data.slice(this.index,c)}return this.index=c,this.push({data:l,meta:{percent:this.max?this.index/this.max*100:0}})},n.exports=a},{"../utils":32,"./GenericWorker":28}],28:[function(t,n,i){function r(o){this.name=o||"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}r.prototype={push:function(o){this.emit("data",o)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(o){this.emit("error",o)}return!0},error:function(o){return!this.isFinished&&(this.isPaused?this.generatedError=o:(this.isFinished=!0,this.emit("error",o),this.previous&&this.previous.error(o),this.cleanUp()),!0)},on:function(o,a){return this._listeners[o].push(a),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(o,a){if(this._listeners[o])for(var l=0;l<this._listeners[o].length;l++)this._listeners[o][l].call(this,a)},pipe:function(o){return o.registerPrevious(this)},registerPrevious:function(o){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=o.streamInfo,this.mergeStreamInfo(),this.previous=o;var a=this;return o.on("data",function(l){a.processChunk(l)}),o.on("end",function(){a.end()}),o.on("error",function(l){a.error(l)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var o=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),o=!0),this.previous&&this.previous.resume(),!o},flush:function(){},processChunk:function(o){this.push(o)},withStreamInfo:function(o,a){return this.extraStreamInfo[o]=a,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var o in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,o)&&(this.streamInfo[o]=this.extraStreamInfo[o])},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 o="Worker "+this.name;return this.previous?this.previous+" -> "+o:o}},n.exports=r},{}],29:[function(t,n,i){var r=t("../utils"),o=t("./ConvertWorker"),a=t("./GenericWorker"),l=t("../base64"),c=t("../support"),h=t("../external"),d=null;if(c.nodestream)try{d=t("../nodejs/NodejsStreamOutputAdapter")}catch{}function g(m,f){return new h.Promise(function(p,x){var v=[],_=m._internalType,b=m._outputType,S=m._mimeType;m.on("data",function(C,R){v.push(C),f&&f(R)}).on("error",function(C){v=[],x(C)}).on("end",function(){try{var C=(function(R,I,E){switch(R){case"blob":return r.newBlob(r.transformTo("arraybuffer",I),E);case"base64":return l.encode(I);default:return r.transformTo(R,I)}})(b,(function(R,I){var E,T=0,U=null,D=0;for(E=0;E<I.length;E++)D+=I[E].length;switch(R){case"string":return I.join("");case"array":return Array.prototype.concat.apply([],I);case"uint8array":for(U=new Uint8Array(D),E=0;E<I.length;E++)U.set(I[E],T),T+=I[E].length;return U;case"nodebuffer":return Buffer.concat(I);default:throw new Error("concat : unsupported type '"+R+"'")}})(_,v),S);p(C)}catch(R){x(R)}v=[]}).resume()})}function u(m,f,p){var x=f;switch(f){case"blob":case"arraybuffer":x="uint8array";break;case"base64":x="string"}try{this._internalType=x,this._outputType=f,this._mimeType=p,r.checkSupport(x),this._worker=m.pipe(new o(x)),m.lock()}catch(v){this._worker=new a("error"),this._worker.error(v)}}u.prototype={accumulate:function(m){return g(this,m)},on:function(m,f){var p=this;return m==="data"?this._worker.on(m,function(x){f.call(p,x.data,x.meta)}):this._worker.on(m,function(){r.delay(f,arguments,p)}),this},resume:function(){return r.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(m){if(r.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new d(this,{objectMode:this._outputType!=="nodebuffer"},m)}},n.exports=u},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(t,n,i){if(i.base64=!0,i.array=!0,i.string=!0,i.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",i.nodebuffer=typeof Buffer<"u",i.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")i.blob=!1;else{var r=new ArrayBuffer(0);try{i.blob=new Blob([r],{type:"application/zip"}).size===0}catch{try{var o=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);o.append(r),i.blob=o.getBlob("application/zip").size===0}catch{i.blob=!1}}}try{i.nodestream=!!t("readable-stream").Readable}catch{i.nodestream=!1}},{"readable-stream":16}],31:[function(t,n,i){for(var r=t("./utils"),o=t("./support"),a=t("./nodejsUtils"),l=t("./stream/GenericWorker"),c=new Array(256),h=0;h<256;h++)c[h]=252<=h?6:248<=h?5:240<=h?4:224<=h?3:192<=h?2:1;c[254]=c[254]=1;function d(){l.call(this,"utf-8 decode"),this.leftOver=null}function g(){l.call(this,"utf-8 encode")}i.utf8encode=function(u){return o.nodebuffer?a.newBufferFrom(u,"utf-8"):(function(m){var f,p,x,v,_,b=m.length,S=0;for(v=0;v<b;v++)(64512&(p=m.charCodeAt(v)))==55296&&v+1<b&&(64512&(x=m.charCodeAt(v+1)))==56320&&(p=65536+(p-55296<<10)+(x-56320),v++),S+=p<128?1:p<2048?2:p<65536?3:4;for(f=o.uint8array?new Uint8Array(S):new Array(S),v=_=0;_<S;v++)(64512&(p=m.charCodeAt(v)))==55296&&v+1<b&&(64512&(x=m.charCodeAt(v+1)))==56320&&(p=65536+(p-55296<<10)+(x-56320),v++),p<128?f[_++]=p:(p<2048?f[_++]=192|p>>>6:(p<65536?f[_++]=224|p>>>12:(f[_++]=240|p>>>18,f[_++]=128|p>>>12&63),f[_++]=128|p>>>6&63),f[_++]=128|63&p);return f})(u)},i.utf8decode=function(u){return o.nodebuffer?r.transformTo("nodebuffer",u).toString("utf-8"):(function(m){var f,p,x,v,_=m.length,b=new Array(2*_);for(f=p=0;f<_;)if((x=m[f++])<128)b[p++]=x;else if(4<(v=c[x]))b[p++]=65533,f+=v-1;else{for(x&=v===2?31:v===3?15:7;1<v&&f<_;)x=x<<6|63&m[f++],v--;1<v?b[p++]=65533:x<65536?b[p++]=x:(x-=65536,b[p++]=55296|x>>10&1023,b[p++]=56320|1023&x)}return b.length!==p&&(b.subarray?b=b.subarray(0,p):b.length=p),r.applyFromCharCode(b)})(u=r.transformTo(o.uint8array?"uint8array":"array",u))},r.inherits(d,l),d.prototype.processChunk=function(u){var m=r.transformTo(o.uint8array?"uint8array":"array",u.data);if(this.leftOver&&this.leftOver.length){if(o.uint8array){var f=m;(m=new Uint8Array(f.length+this.leftOver.length)).set(this.leftOver,0),m.set(f,this.leftOver.length)}else m=this.leftOver.concat(m);this.leftOver=null}var p=(function(v,_){var b;for((_=_||v.length)>v.length&&(_=v.length),b=_-1;0<=b&&(192&v[b])==128;)b--;return b<0||b===0?_:b+c[v[b]]>_?b:_})(m),x=m;p!==m.length&&(o.uint8array?(x=m.subarray(0,p),this.leftOver=m.subarray(p,m.length)):(x=m.slice(0,p),this.leftOver=m.slice(p,m.length))),this.push({data:i.utf8decode(x),meta:u.meta})},d.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:i.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},i.Utf8DecodeWorker=d,r.inherits(g,l),g.prototype.processChunk=function(u){this.push({data:i.utf8encode(u.data),meta:u.meta})},i.Utf8EncodeWorker=g},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(t,n,i){var r=t("./support"),o=t("./base64"),a=t("./nodejsUtils"),l=t("./external");function c(f){return f}function h(f,p){for(var x=0;x<f.length;++x)p[x]=255&f.charCodeAt(x);return p}t("setimmediate"),i.newBlob=function(f,p){i.checkSupport("blob");try{return new Blob([f],{type:p})}catch{try{var x=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return x.append(f),x.getBlob(p)}catch{throw new Error("Bug : can't construct the Blob.")}}};var d={stringifyByChunk:function(f,p,x){var v=[],_=0,b=f.length;if(b<=x)return String.fromCharCode.apply(null,f);for(;_<b;)p==="array"||p==="nodebuffer"?v.push(String.fromCharCode.apply(null,f.slice(_,Math.min(_+x,b)))):v.push(String.fromCharCode.apply(null,f.subarray(_,Math.min(_+x,b)))),_+=x;return v.join("")},stringifyByChar:function(f){for(var p="",x=0;x<f.length;x++)p+=String.fromCharCode(f[x]);return p},applyCanBeUsed:{uint8array:(function(){try{return r.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}})(),nodebuffer:(function(){try{return r.nodebuffer&&String.fromCharCode.apply(null,a.allocBuffer(1)).length===1}catch{return!1}})()}};function g(f){var p=65536,x=i.getTypeOf(f),v=!0;if(x==="uint8array"?v=d.applyCanBeUsed.uint8array:x==="nodebuffer"&&(v=d.applyCanBeUsed.nodebuffer),v)for(;1<p;)try{return d.stringifyByChunk(f,x,p)}catch{p=Math.floor(p/2)}return d.stringifyByChar(f)}function u(f,p){for(var x=0;x<f.length;x++)p[x]=f[x];return p}i.applyFromCharCode=g;var m={};m.string={string:c,array:function(f){return h(f,new Array(f.length))},arraybuffer:function(f){return m.string.uint8array(f).buffer},uint8array:function(f){return h(f,new Uint8Array(f.length))},nodebuffer:function(f){return h(f,a.allocBuffer(f.length))}},m.array={string:g,array:c,arraybuffer:function(f){return new Uint8Array(f).buffer},uint8array:function(f){return new Uint8Array(f)},nodebuffer:function(f){return a.newBufferFrom(f)}},m.arraybuffer={string:function(f){return g(new Uint8Array(f))},array:function(f){return u(new Uint8Array(f),new Array(f.byteLength))},arraybuffer:c,uint8array:function(f){return new Uint8Array(f)},nodebuffer:function(f){return a.newBufferFrom(new Uint8Array(f))}},m.uint8array={string:g,array:function(f){return u(f,new Array(f.length))},arraybuffer:function(f){return f.buffer},uint8array:c,nodebuffer:function(f){return a.newBufferFrom(f)}},m.nodebuffer={string:g,array:function(f){return u(f,new Array(f.length))},arraybuffer:function(f){return m.nodebuffer.uint8array(f).buffer},uint8array:function(f){return u(f,new Uint8Array(f.length))},nodebuffer:c},i.transformTo=function(f,p){if(p=p||"",!f)return p;i.checkSupport(f);var x=i.getTypeOf(p);return m[x][f](p)},i.resolve=function(f){for(var p=f.split("/"),x=[],v=0;v<p.length;v++){var _=p[v];_==="."||_===""&&v!==0&&v!==p.length-1||(_===".."?x.pop():x.push(_))}return x.join("/")},i.getTypeOf=function(f){return typeof f=="string"?"string":Object.prototype.toString.call(f)==="[object Array]"?"array":r.nodebuffer&&a.isBuffer(f)?"nodebuffer":r.uint8array&&f instanceof Uint8Array?"uint8array":r.arraybuffer&&f instanceof ArrayBuffer?"arraybuffer":void 0},i.checkSupport=function(f){if(!r[f.toLowerCase()])throw new Error(f+" is not supported by this platform")},i.MAX_VALUE_16BITS=65535,i.MAX_VALUE_32BITS=-1,i.pretty=function(f){var p,x,v="";for(x=0;x<(f||"").length;x++)v+="\\x"+((p=f.charCodeAt(x))<16?"0":"")+p.toString(16).toUpperCase();return v},i.delay=function(f,p,x){setImmediate(function(){f.apply(x||null,p||[])})},i.inherits=function(f,p){function x(){}x.prototype=p.prototype,f.prototype=new x},i.extend=function(){var f,p,x={};for(f=0;f<arguments.length;f++)for(p in arguments[f])Object.prototype.hasOwnProperty.call(arguments[f],p)&&x[p]===void 0&&(x[p]=arguments[f][p]);return x},i.prepareContent=function(f,p,x,v,_){return l.Promise.resolve(p).then(function(b){return r.blob&&(b instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(b))!==-1)&&typeof FileReader<"u"?new l.Promise(function(S,C){var R=new FileReader;R.onload=function(I){S(I.target.result)},R.onerror=function(I){C(I.target.error)},R.readAsArrayBuffer(b)}):b}).then(function(b){var S=i.getTypeOf(b);return S?(S==="arraybuffer"?b=i.transformTo("uint8array",b):S==="string"&&(_?b=o.decode(b):x&&v!==!0&&(b=(function(C){return h(C,r.uint8array?new Uint8Array(C.length):new Array(C.length))})(b))),b):l.Promise.reject(new Error("Can't read the data of '"+f+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(t,n,i){var r=t("./reader/readerFor"),o=t("./utils"),a=t("./signature"),l=t("./zipEntry"),c=t("./support");function h(d){this.files=[],this.loadOptions=d}h.prototype={checkSignature:function(d){if(!this.reader.readAndCheckSignature(d)){this.reader.index-=4;var g=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+o.pretty(g)+", expected "+o.pretty(d)+")")}},isSignature:function(d,g){var u=this.reader.index;this.reader.setIndex(d);var m=this.reader.readString(4)===g;return this.reader.setIndex(u),m},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 d=this.reader.readData(this.zipCommentLength),g=c.uint8array?"uint8array":"array",u=o.transformTo(g,d);this.zipComment=this.loadOptions.decodeFileName(u)},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 d,g,u,m=this.zip64EndOfCentralSize-44;0<m;)d=this.reader.readInt(2),g=this.reader.readInt(4),u=this.reader.readData(g),this.zip64ExtensibleData[d]={id:d,length:g,value:u}},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 d,g;for(d=0;d<this.files.length;d++)g=this.files[d],this.reader.setIndex(g.localHeaderOffset),this.checkSignature(a.LOCAL_FILE_HEADER),g.readLocalPart(this.reader),g.handleUTF8(),g.processAttributes()},readCentralDir:function(){var d;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(a.CENTRAL_FILE_HEADER);)(d=new l({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(d);if(this.centralDirRecords!==this.files.length&&this.centralDirRecords!==0&&this.files.length===0)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var d=this.reader.lastIndexOfSignature(a.CENTRAL_DIRECTORY_END);if(d<0)throw this.isSignature(0,a.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(d);var g=d;if(this.checkSignature(a.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===o.MAX_VALUE_16BITS||this.diskWithCentralDirStart===o.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===o.MAX_VALUE_16BITS||this.centralDirRecords===o.MAX_VALUE_16BITS||this.centralDirSize===o.MAX_VALUE_32BITS||this.centralDirOffset===o.MAX_VALUE_32BITS){if(this.zip64=!0,(d=this.reader.lastIndexOfSignature(a.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(d),this.checkSignature(a.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,a.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(a.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(a.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var u=this.centralDirOffset+this.centralDirSize;this.zip64&&(u+=20,u+=12+this.zip64EndOfCentralSize);var m=g-u;if(0<m)this.isSignature(g,a.CENTRAL_FILE_HEADER)||(this.reader.zero=m);else if(m<0)throw new Error("Corrupted zip: missing "+Math.abs(m)+" bytes.")},prepareReader:function(d){this.reader=r(d)},load:function(d){this.prepareReader(d),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},n.exports=h},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(t,n,i){var r=t("./reader/readerFor"),o=t("./utils"),a=t("./compressedObject"),l=t("./crc32"),c=t("./utf8"),h=t("./compressions"),d=t("./support");function g(u,m){this.options=u,this.loadOptions=m}g.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(u){var m,f;if(u.skip(22),this.fileNameLength=u.readInt(2),f=u.readInt(2),this.fileName=u.readData(this.fileNameLength),u.skip(f),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if((m=(function(p){for(var x in h)if(Object.prototype.hasOwnProperty.call(h,x)&&h[x].magic===p)return h[x];return null})(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+o.pretty(this.compressionMethod)+" unknown (inner file : "+o.transformTo("string",this.fileName)+")");this.decompressed=new a(this.compressedSize,this.uncompressedSize,this.crc32,m,u.readData(this.compressedSize))},readCentralPart:function(u){this.versionMadeBy=u.readInt(2),u.skip(2),this.bitFlag=u.readInt(2),this.compressionMethod=u.readString(2),this.date=u.readDate(),this.crc32=u.readInt(4),this.compressedSize=u.readInt(4),this.uncompressedSize=u.readInt(4);var m=u.readInt(2);if(this.extraFieldsLength=u.readInt(2),this.fileCommentLength=u.readInt(2),this.diskNumberStart=u.readInt(2),this.internalFileAttributes=u.readInt(2),this.externalFileAttributes=u.readInt(4),this.localHeaderOffset=u.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");u.skip(m),this.readExtraFields(u),this.parseZIP64ExtraField(u),this.fileComment=u.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var u=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),u==0&&(this.dosPermissions=63&this.externalFileAttributes),u==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var u=r(this.extraFields[1].value);this.uncompressedSize===o.MAX_VALUE_32BITS&&(this.uncompressedSize=u.readInt(8)),this.compressedSize===o.MAX_VALUE_32BITS&&(this.compressedSize=u.readInt(8)),this.localHeaderOffset===o.MAX_VALUE_32BITS&&(this.localHeaderOffset=u.readInt(8)),this.diskNumberStart===o.MAX_VALUE_32BITS&&(this.diskNumberStart=u.readInt(4))}},readExtraFields:function(u){var m,f,p,x=u.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});u.index+4<x;)m=u.readInt(2),f=u.readInt(2),p=u.readData(f),this.extraFields[m]={id:m,length:f,value:p};u.setIndex(x)},handleUTF8:function(){var u=d.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=c.utf8decode(this.fileName),this.fileCommentStr=c.utf8decode(this.fileComment);else{var m=this.findExtraFieldUnicodePath();if(m!==null)this.fileNameStr=m;else{var f=o.transformTo(u,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(f)}var p=this.findExtraFieldUnicodeComment();if(p!==null)this.fileCommentStr=p;else{var x=o.transformTo(u,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(x)}}},findExtraFieldUnicodePath:function(){var u=this.extraFields[28789];if(u){var m=r(u.value);return m.readInt(1)!==1||l(this.fileName)!==m.readInt(4)?null:c.utf8decode(m.readData(u.length-5))}return null},findExtraFieldUnicodeComment:function(){var u=this.extraFields[25461];if(u){var m=r(u.value);return m.readInt(1)!==1||l(this.fileComment)!==m.readInt(4)?null:c.utf8decode(m.readData(u.length-5))}return null}},n.exports=g},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(t,n,i){function r(m,f,p){this.name=m,this.dir=p.dir,this.date=p.date,this.comment=p.comment,this.unixPermissions=p.unixPermissions,this.dosPermissions=p.dosPermissions,this._data=f,this._dataBinary=p.binary,this.options={compression:p.compression,compressionOptions:p.compressionOptions}}var o=t("./stream/StreamHelper"),a=t("./stream/DataWorker"),l=t("./utf8"),c=t("./compressedObject"),h=t("./stream/GenericWorker");r.prototype={internalStream:function(m){var f=null,p="string";try{if(!m)throw new Error("No output type specified.");var x=(p=m.toLowerCase())==="string"||p==="text";p!=="binarystring"&&p!=="text"||(p="string"),f=this._decompressWorker();var v=!this._dataBinary;v&&!x&&(f=f.pipe(new l.Utf8EncodeWorker)),!v&&x&&(f=f.pipe(new l.Utf8DecodeWorker))}catch(_){(f=new h("error")).error(_)}return new o(f,p,"")},async:function(m,f){return this.internalStream(m).accumulate(f)},nodeStream:function(m,f){return this.internalStream(m||"nodebuffer").toNodejsStream(f)},_compressWorker:function(m,f){if(this._data instanceof c&&this._data.compression.magic===m.magic)return this._data.getCompressedWorker();var p=this._decompressWorker();return this._dataBinary||(p=p.pipe(new l.Utf8EncodeWorker)),c.createWorkerFrom(p,m,f)},_decompressWorker:function(){return this._data instanceof c?this._data.getContentWorker():this._data instanceof h?this._data:new a(this._data)}};for(var d=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],g=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},u=0;u<d.length;u++)r.prototype[d[u]]=g;n.exports=r},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(t,n,i){(function(r){var o,a,l=r.MutationObserver||r.WebKitMutationObserver;if(l){var c=0,h=new l(m),d=r.document.createTextNode("");h.observe(d,{characterData:!0}),o=function(){d.data=c=++c%2}}else if(r.setImmediate||r.MessageChannel===void 0)o="document"in r&&"onreadystatechange"in r.document.createElement("script")?function(){var f=r.document.createElement("script");f.onreadystatechange=function(){m(),f.onreadystatechange=null,f.parentNode.removeChild(f),f=null},r.document.documentElement.appendChild(f)}:function(){setTimeout(m,0)};else{var g=new r.MessageChannel;g.port1.onmessage=m,o=function(){g.port2.postMessage(0)}}var u=[];function m(){var f,p;a=!0;for(var x=u.length;x;){for(p=u,u=[],f=-1;++f<x;)p[f]();x=u.length}a=!1}n.exports=function(f){u.push(f)!==1||a||o()}}).call(this,typeof Dr<"u"?Dr:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(t,n,i){var r=t("immediate");function o(){}var a={},l=["REJECTED"],c=["FULFILLED"],h=["PENDING"];function d(x){if(typeof x!="function")throw new TypeError("resolver must be a function");this.state=h,this.queue=[],this.outcome=void 0,x!==o&&f(this,x)}function g(x,v,_){this.promise=x,typeof v=="function"&&(this.onFulfilled=v,this.callFulfilled=this.otherCallFulfilled),typeof _=="function"&&(this.onRejected=_,this.callRejected=this.otherCallRejected)}function u(x,v,_){r(function(){var b;try{b=v(_)}catch(S){return a.reject(x,S)}b===x?a.reject(x,new TypeError("Cannot resolve promise with itself")):a.resolve(x,b)})}function m(x){var v=x&&x.then;if(x&&(typeof x=="object"||typeof x=="function")&&typeof v=="function")return function(){v.apply(x,arguments)}}function f(x,v){var _=!1;function b(R){_||(_=!0,a.reject(x,R))}function S(R){_||(_=!0,a.resolve(x,R))}var C=p(function(){v(S,b)});C.status==="error"&&b(C.value)}function p(x,v){var _={};try{_.value=x(v),_.status="success"}catch(b){_.status="error",_.value=b}return _}(n.exports=d).prototype.finally=function(x){if(typeof x!="function")return this;var v=this.constructor;return this.then(function(_){return v.resolve(x()).then(function(){return _})},function(_){return v.resolve(x()).then(function(){throw _})})},d.prototype.catch=function(x){return this.then(null,x)},d.prototype.then=function(x,v){if(typeof x!="function"&&this.state===c||typeof v!="function"&&this.state===l)return this;var _=new this.constructor(o);return this.state!==h?u(_,this.state===c?x:v,this.outcome):this.queue.push(new g(_,x,v)),_},g.prototype.callFulfilled=function(x){a.resolve(this.promise,x)},g.prototype.otherCallFulfilled=function(x){u(this.promise,this.onFulfilled,x)},g.prototype.callRejected=function(x){a.reject(this.promise,x)},g.prototype.otherCallRejected=function(x){u(this.promise,this.onRejected,x)},a.resolve=function(x,v){var _=p(m,v);if(_.status==="error")return a.reject(x,_.value);var b=_.value;if(b)f(x,b);else{x.state=c,x.outcome=v;for(var S=-1,C=x.queue.length;++S<C;)x.queue[S].callFulfilled(v)}return x},a.reject=function(x,v){x.state=l,x.outcome=v;for(var _=-1,b=x.queue.length;++_<b;)x.queue[_].callRejected(v);return x},d.resolve=function(x){return x instanceof this?x:a.resolve(new this(o),x)},d.reject=function(x){var v=new this(o);return a.reject(v,x)},d.all=function(x){var v=this;if(Object.prototype.toString.call(x)!=="[object Array]")return this.reject(new TypeError("must be an array"));var _=x.length,b=!1;if(!_)return this.resolve([]);for(var S=new Array(_),C=0,R=-1,I=new this(o);++R<_;)E(x[R],R);return I;function E(T,U){v.resolve(T).then(function(D){S[U]=D,++C!==_||b||(b=!0,a.resolve(I,S))},function(D){b||(b=!0,a.reject(I,D))})}},d.race=function(x){var v=this;if(Object.prototype.toString.call(x)!=="[object Array]")return this.reject(new TypeError("must be an array"));var _=x.length,b=!1;if(!_)return this.resolve([]);for(var S=-1,C=new this(o);++S<_;)R=x[S],v.resolve(R).then(function(I){b||(b=!0,a.resolve(C,I))},function(I){b||(b=!0,a.reject(C,I))});var R;return C}},{immediate:36}],38:[function(t,n,i){var r={};(0,t("./lib/utils/common").assign)(r,t("./lib/deflate"),t("./lib/inflate"),t("./lib/zlib/constants")),n.exports=r},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(t,n,i){var r=t("./zlib/deflate"),o=t("./utils/common"),a=t("./utils/strings"),l=t("./zlib/messages"),c=t("./zlib/zstream"),h=Object.prototype.toString,d=0,g=-1,u=0,m=8;function f(x){if(!(this instanceof f))return new f(x);this.options=o.assign({level:g,method:m,chunkSize:16384,windowBits:15,memLevel:8,strategy:u,to:""},x||{});var v=this.options;v.raw&&0<v.windowBits?v.windowBits=-v.windowBits:v.gzip&&0<v.windowBits&&v.windowBits<16&&(v.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new c,this.strm.avail_out=0;var _=r.deflateInit2(this.strm,v.level,v.method,v.windowBits,v.memLevel,v.strategy);if(_!==d)throw new Error(l[_]);if(v.header&&r.deflateSetHeader(this.strm,v.header),v.dictionary){var b;if(b=typeof v.dictionary=="string"?a.string2buf(v.dictionary):h.call(v.dictionary)==="[object ArrayBuffer]"?new Uint8Array(v.dictionary):v.dictionary,(_=r.deflateSetDictionary(this.strm,b))!==d)throw new Error(l[_]);this._dict_set=!0}}function p(x,v){var _=new f(v);if(_.push(x,!0),_.err)throw _.msg||l[_.err];return _.result}f.prototype.push=function(x,v){var _,b,S=this.strm,C=this.options.chunkSize;if(this.ended)return!1;b=v===~~v?v:v===!0?4:0,typeof x=="string"?S.input=a.string2buf(x):h.call(x)==="[object ArrayBuffer]"?S.input=new Uint8Array(x):S.input=x,S.next_in=0,S.avail_in=S.input.length;do{if(S.avail_out===0&&(S.output=new o.Buf8(C),S.next_out=0,S.avail_out=C),(_=r.deflate(S,b))!==1&&_!==d)return this.onEnd(_),!(this.ended=!0);S.avail_out!==0&&(S.avail_in!==0||b!==4&&b!==2)||(this.options.to==="string"?this.onData(a.buf2binstring(o.shrinkBuf(S.output,S.next_out))):this.onData(o.shrinkBuf(S.output,S.next_out)))}while((0<S.avail_in||S.avail_out===0)&&_!==1);return b===4?(_=r.deflateEnd(this.strm),this.onEnd(_),this.ended=!0,_===d):b!==2||(this.onEnd(d),!(S.avail_out=0))},f.prototype.onData=function(x){this.chunks.push(x)},f.prototype.onEnd=function(x){x===d&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=o.flattenChunks(this.chunks)),this.chunks=[],this.err=x,this.msg=this.strm.msg},i.Deflate=f,i.deflate=p,i.deflateRaw=function(x,v){return(v=v||{}).raw=!0,p(x,v)},i.gzip=function(x,v){return(v=v||{}).gzip=!0,p(x,v)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(t,n,i){var r=t("./zlib/inflate"),o=t("./utils/common"),a=t("./utils/strings"),l=t("./zlib/constants"),c=t("./zlib/messages"),h=t("./zlib/zstream"),d=t("./zlib/gzheader"),g=Object.prototype.toString;function u(f){if(!(this instanceof u))return new u(f);this.options=o.assign({chunkSize:16384,windowBits:0,to:""},f||{});var p=this.options;p.raw&&0<=p.windowBits&&p.windowBits<16&&(p.windowBits=-p.windowBits,p.windowBits===0&&(p.windowBits=-15)),!(0<=p.windowBits&&p.windowBits<16)||f&&f.windowBits||(p.windowBits+=32),15<p.windowBits&&p.windowBits<48&&(15&p.windowBits)==0&&(p.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new h,this.strm.avail_out=0;var x=r.inflateInit2(this.strm,p.windowBits);if(x!==l.Z_OK)throw new Error(c[x]);this.header=new d,r.inflateGetHeader(this.strm,this.header)}function m(f,p){var x=new u(p);if(x.push(f,!0),x.err)throw x.msg||c[x.err];return x.result}u.prototype.push=function(f,p){var x,v,_,b,S,C,R=this.strm,I=this.options.chunkSize,E=this.options.dictionary,T=!1;if(this.ended)return!1;v=p===~~p?p:p===!0?l.Z_FINISH:l.Z_NO_FLUSH,typeof f=="string"?R.input=a.binstring2buf(f):g.call(f)==="[object ArrayBuffer]"?R.input=new Uint8Array(f):R.input=f,R.next_in=0,R.avail_in=R.input.length;do{if(R.avail_out===0&&(R.output=new o.Buf8(I),R.next_out=0,R.avail_out=I),(x=r.inflate(R,l.Z_NO_FLUSH))===l.Z_NEED_DICT&&E&&(C=typeof E=="string"?a.string2buf(E):g.call(E)==="[object ArrayBuffer]"?new Uint8Array(E):E,x=r.inflateSetDictionary(this.strm,C)),x===l.Z_BUF_ERROR&&T===!0&&(x=l.Z_OK,T=!1),x!==l.Z_STREAM_END&&x!==l.Z_OK)return this.onEnd(x),!(this.ended=!0);R.next_out&&(R.avail_out!==0&&x!==l.Z_STREAM_END&&(R.avail_in!==0||v!==l.Z_FINISH&&v!==l.Z_SYNC_FLUSH)||(this.options.to==="string"?(_=a.utf8border(R.output,R.next_out),b=R.next_out-_,S=a.buf2string(R.output,_),R.next_out=b,R.avail_out=I-b,b&&o.arraySet(R.output,R.output,_,b,0),this.onData(S)):this.onData(o.shrinkBuf(R.output,R.next_out)))),R.avail_in===0&&R.avail_out===0&&(T=!0)}while((0<R.avail_in||R.avail_out===0)&&x!==l.Z_STREAM_END);return x===l.Z_STREAM_END&&(v=l.Z_FINISH),v===l.Z_FINISH?(x=r.inflateEnd(this.strm),this.onEnd(x),this.ended=!0,x===l.Z_OK):v!==l.Z_SYNC_FLUSH||(this.onEnd(l.Z_OK),!(R.avail_out=0))},u.prototype.onData=function(f){this.chunks.push(f)},u.prototype.onEnd=function(f){f===l.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=o.flattenChunks(this.chunks)),this.chunks=[],this.err=f,this.msg=this.strm.msg},i.Inflate=u,i.inflate=m,i.inflateRaw=function(f,p){return(p=p||{}).raw=!0,m(f,p)},i.ungzip=m},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(t,n,i){var r=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";i.assign=function(l){for(var c=Array.prototype.slice.call(arguments,1);c.length;){var h=c.shift();if(h){if(typeof h!="object")throw new TypeError(h+"must be non-object");for(var d in h)h.hasOwnProperty(d)&&(l[d]=h[d])}}return l},i.shrinkBuf=function(l,c){return l.length===c?l:l.subarray?l.subarray(0,c):(l.length=c,l)};var o={arraySet:function(l,c,h,d,g){if(c.subarray&&l.subarray)l.set(c.subarray(h,h+d),g);else for(var u=0;u<d;u++)l[g+u]=c[h+u]},flattenChunks:function(l){var c,h,d,g,u,m;for(c=d=0,h=l.length;c<h;c++)d+=l[c].length;for(m=new Uint8Array(d),c=g=0,h=l.length;c<h;c++)u=l[c],m.set(u,g),g+=u.length;return m}},a={arraySet:function(l,c,h,d,g){for(var u=0;u<d;u++)l[g+u]=c[h+u]},flattenChunks:function(l){return[].concat.apply([],l)}};i.setTyped=function(l){l?(i.Buf8=Uint8Array,i.Buf16=Uint16Array,i.Buf32=Int32Array,i.assign(i,o)):(i.Buf8=Array,i.Buf16=Array,i.Buf32=Array,i.assign(i,a))},i.setTyped(r)},{}],42:[function(t,n,i){var r=t("./common"),o=!0,a=!0;try{String.fromCharCode.apply(null,[0])}catch{o=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{a=!1}for(var l=new r.Buf8(256),c=0;c<256;c++)l[c]=252<=c?6:248<=c?5:240<=c?4:224<=c?3:192<=c?2:1;function h(d,g){if(g<65537&&(d.subarray&&a||!d.subarray&&o))return String.fromCharCode.apply(null,r.shrinkBuf(d,g));for(var u="",m=0;m<g;m++)u+=String.fromCharCode(d[m]);return u}l[254]=l[254]=1,i.string2buf=function(d){var g,u,m,f,p,x=d.length,v=0;for(f=0;f<x;f++)(64512&(u=d.charCodeAt(f)))==55296&&f+1<x&&(64512&(m=d.charCodeAt(f+1)))==56320&&(u=65536+(u-55296<<10)+(m-56320),f++),v+=u<128?1:u<2048?2:u<65536?3:4;for(g=new r.Buf8(v),f=p=0;p<v;f++)(64512&(u=d.charCodeAt(f)))==55296&&f+1<x&&(64512&(m=d.charCodeAt(f+1)))==56320&&(u=65536+(u-55296<<10)+(m-56320),f++),u<128?g[p++]=u:(u<2048?g[p++]=192|u>>>6:(u<65536?g[p++]=224|u>>>12:(g[p++]=240|u>>>18,g[p++]=128|u>>>12&63),g[p++]=128|u>>>6&63),g[p++]=128|63&u);return g},i.buf2binstring=function(d){return h(d,d.length)},i.binstring2buf=function(d){for(var g=new r.Buf8(d.length),u=0,m=g.length;u<m;u++)g[u]=d.charCodeAt(u);return g},i.buf2string=function(d,g){var u,m,f,p,x=g||d.length,v=new Array(2*x);for(u=m=0;u<x;)if((f=d[u++])<128)v[m++]=f;else if(4<(p=l[f]))v[m++]=65533,u+=p-1;else{for(f&=p===2?31:p===3?15:7;1<p&&u<x;)f=f<<6|63&d[u++],p--;1<p?v[m++]=65533:f<65536?v[m++]=f:(f-=65536,v[m++]=55296|f>>10&1023,v[m++]=56320|1023&f)}return h(v,m)},i.utf8border=function(d,g){var u;for((g=g||d.length)>d.length&&(g=d.length),u=g-1;0<=u&&(192&d[u])==128;)u--;return u<0||u===0?g:u+l[d[u]]>g?u:g}},{"./common":41}],43:[function(t,n,i){n.exports=function(r,o,a,l){for(var c=65535&r|0,h=r>>>16&65535|0,d=0;a!==0;){for(a-=d=2e3<a?2e3:a;h=h+(c=c+o[l++]|0)|0,--d;);c%=65521,h%=65521}return c|h<<16|0}},{}],44:[function(t,n,i){n.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,n,i){var r=(function(){for(var o,a=[],l=0;l<256;l++){o=l;for(var c=0;c<8;c++)o=1&o?3988292384^o>>>1:o>>>1;a[l]=o}return a})();n.exports=function(o,a,l,c){var h=r,d=c+l;o^=-1;for(var g=c;g<d;g++)o=o>>>8^h[255&(o^a[g])];return-1^o}},{}],46:[function(t,n,i){var r,o=t("../utils/common"),a=t("./trees"),l=t("./adler32"),c=t("./crc32"),h=t("./messages"),d=0,g=4,u=0,m=-2,f=-1,p=4,x=2,v=8,_=9,b=286,S=30,C=19,R=2*b+1,I=15,E=3,T=258,U=T+E+1,D=42,O=113,w=1,V=2,z=3,H=4;function Y(A,re){return A.msg=h[re],re}function W(A){return(A<<1)-(4<A?9:0)}function Q(A){for(var re=A.length;0<=--re;)A[re]=0}function X(A){var re=A.state,te=re.pending;te>A.avail_out&&(te=A.avail_out),te!==0&&(o.arraySet(A.output,re.pending_buf,re.pending_out,te,A.next_out),A.next_out+=te,re.pending_out+=te,A.total_out+=te,A.avail_out-=te,re.pending-=te,re.pending===0&&(re.pending_out=0))}function j(A,re){a._tr_flush_block(A,0<=A.block_start?A.block_start:-1,A.strstart-A.block_start,re),A.block_start=A.strstart,X(A.strm)}function me(A,re){A.pending_buf[A.pending++]=re}function ge(A,re){A.pending_buf[A.pending++]=re>>>8&255,A.pending_buf[A.pending++]=255&re}function ue(A,re){var te,G,k=A.max_chain_length,Z=A.strstart,de=A.prev_length,F=A.nice_match,ee=A.strstart>A.w_size-U?A.strstart-(A.w_size-U):0,L=A.window,P=A.w_mask,B=A.prev,J=A.strstart+T,ie=L[Z+de-1],K=L[Z+de];A.prev_length>=A.good_match&&(k>>=2),F>A.lookahead&&(F=A.lookahead);do if(L[(te=re)+de]===K&&L[te+de-1]===ie&&L[te]===L[Z]&&L[++te]===L[Z+1]){Z+=2,te++;do;while(L[++Z]===L[++te]&&L[++Z]===L[++te]&&L[++Z]===L[++te]&&L[++Z]===L[++te]&&L[++Z]===L[++te]&&L[++Z]===L[++te]&&L[++Z]===L[++te]&&L[++Z]===L[++te]&&Z<J);if(G=T-(J-Z),Z=J-T,de<G){if(A.match_start=re,F<=(de=G))break;ie=L[Z+de-1],K=L[Z+de]}}while((re=B[re&P])>ee&&--k!=0);return de<=A.lookahead?de:A.lookahead}function se(A){var re,te,G,k,Z,de,F,ee,L,P,B=A.w_size;do{if(k=A.window_size-A.lookahead-A.strstart,A.strstart>=B+(B-U)){for(o.arraySet(A.window,A.window,B,B,0),A.match_start-=B,A.strstart-=B,A.block_start-=B,re=te=A.hash_size;G=A.head[--re],A.head[re]=B<=G?G-B:0,--te;);for(re=te=B;G=A.prev[--re],A.prev[re]=B<=G?G-B:0,--te;);k+=B}if(A.strm.avail_in===0)break;if(de=A.strm,F=A.window,ee=A.strstart+A.lookahead,L=k,P=void 0,P=de.avail_in,L<P&&(P=L),te=P===0?0:(de.avail_in-=P,o.arraySet(F,de.input,de.next_in,P,ee),de.state.wrap===1?de.adler=l(de.adler,F,P,ee):de.state.wrap===2&&(de.adler=c(de.adler,F,P,ee)),de.next_in+=P,de.total_in+=P,P),A.lookahead+=te,A.lookahead+A.insert>=E)for(Z=A.strstart-A.insert,A.ins_h=A.window[Z],A.ins_h=(A.ins_h<<A.hash_shift^A.window[Z+1])&A.hash_mask;A.insert&&(A.ins_h=(A.ins_h<<A.hash_shift^A.window[Z+E-1])&A.hash_mask,A.prev[Z&A.w_mask]=A.head[A.ins_h],A.head[A.ins_h]=Z,Z++,A.insert--,!(A.lookahead+A.insert<E)););}while(A.lookahead<U&&A.strm.avail_in!==0)}function le(A,re){for(var te,G;;){if(A.lookahead<U){if(se(A),A.lookahead<U&&re===d)return w;if(A.lookahead===0)break}if(te=0,A.lookahead>=E&&(A.ins_h=(A.ins_h<<A.hash_shift^A.window[A.strstart+E-1])&A.hash_mask,te=A.prev[A.strstart&A.w_mask]=A.head[A.ins_h],A.head[A.ins_h]=A.strstart),te!==0&&A.strstart-te<=A.w_size-U&&(A.match_length=ue(A,te)),A.match_length>=E)if(G=a._tr_tally(A,A.strstart-A.match_start,A.match_length-E),A.lookahead-=A.match_length,A.match_length<=A.max_lazy_match&&A.lookahead>=E){for(A.match_length--;A.strstart++,A.ins_h=(A.ins_h<<A.hash_shift^A.window[A.strstart+E-1])&A.hash_mask,te=A.prev[A.strstart&A.w_mask]=A.head[A.ins_h],A.head[A.ins_h]=A.strstart,--A.match_length!=0;);A.strstart++}else A.strstart+=A.match_length,A.match_length=0,A.ins_h=A.window[A.strstart],A.ins_h=(A.ins_h<<A.hash_shift^A.window[A.strstart+1])&A.hash_mask;else G=a._tr_tally(A,0,A.window[A.strstart]),A.lookahead--,A.strstart++;if(G&&(j(A,!1),A.strm.avail_out===0))return w}return A.insert=A.strstart<E-1?A.strstart:E-1,re===g?(j(A,!0),A.strm.avail_out===0?z:H):A.last_lit&&(j(A,!1),A.strm.avail_out===0)?w:V}function xe(A,re){for(var te,G,k;;){if(A.lookahead<U){if(se(A),A.lookahead<U&&re===d)return w;if(A.lookahead===0)break}if(te=0,A.lookahead>=E&&(A.ins_h=(A.ins_h<<A.hash_shift^A.window[A.strstart+E-1])&A.hash_mask,te=A.prev[A.strstart&A.w_mask]=A.head[A.ins_h],A.head[A.ins_h]=A.strstart),A.prev_length=A.match_length,A.prev_match=A.match_start,A.match_length=E-1,te!==0&&A.prev_length<A.max_lazy_match&&A.strstart-te<=A.w_size-U&&(A.match_length=ue(A,te),A.match_length<=5&&(A.strategy===1||A.match_length===E&&4096<A.strstart-A.match_start)&&(A.match_length=E-1)),A.prev_length>=E&&A.match_length<=A.prev_length){for(k=A.strstart+A.lookahead-E,G=a._tr_tally(A,A.strstart-1-A.prev_match,A.prev_length-E),A.lookahead-=A.prev_length-1,A.prev_length-=2;++A.strstart<=k&&(A.ins_h=(A.ins_h<<A.hash_shift^A.window[A.strstart+E-1])&A.hash_mask,te=A.prev[A.strstart&A.w_mask]=A.head[A.ins_h],A.head[A.ins_h]=A.strstart),--A.prev_length!=0;);if(A.match_available=0,A.match_length=E-1,A.strstart++,G&&(j(A,!1),A.strm.avail_out===0))return w}else if(A.match_available){if((G=a._tr_tally(A,0,A.window[A.strstart-1]))&&j(A,!1),A.strstart++,A.lookahead--,A.strm.avail_out===0)return w}else A.match_available=1,A.strstart++,A.lookahead--}return A.match_available&&(G=a._tr_tally(A,0,A.window[A.strstart-1]),A.match_available=0),A.insert=A.strstart<E-1?A.strstart:E-1,re===g?(j(A,!0),A.strm.avail_out===0?z:H):A.last_lit&&(j(A,!1),A.strm.avail_out===0)?w:V}function Se(A,re,te,G,k){this.good_length=A,this.max_lazy=re,this.nice_length=te,this.max_chain=G,this.func=k}function Ee(){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=v,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 o.Buf16(2*R),this.dyn_dtree=new o.Buf16(2*(2*S+1)),this.bl_tree=new o.Buf16(2*(2*C+1)),Q(this.dyn_ltree),Q(this.dyn_dtree),Q(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new o.Buf16(I+1),this.heap=new o.Buf16(2*b+1),Q(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new o.Buf16(2*b+1),Q(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 Ue(A){var re;return A&&A.state?(A.total_in=A.total_out=0,A.data_type=x,(re=A.state).pending=0,re.pending_out=0,re.wrap<0&&(re.wrap=-re.wrap),re.status=re.wrap?D:O,A.adler=re.wrap===2?0:1,re.last_flush=d,a._tr_init(re),u):Y(A,m)}function tt(A){var re=Ue(A);return re===u&&(function(te){te.window_size=2*te.w_size,Q(te.head),te.max_lazy_match=r[te.level].max_lazy,te.good_match=r[te.level].good_length,te.nice_match=r[te.level].nice_length,te.max_chain_length=r[te.level].max_chain,te.strstart=0,te.block_start=0,te.lookahead=0,te.insert=0,te.match_length=te.prev_length=E-1,te.match_available=0,te.ins_h=0})(A.state),re}function ze(A,re,te,G,k,Z){if(!A)return m;var de=1;if(re===f&&(re=6),G<0?(de=0,G=-G):15<G&&(de=2,G-=16),k<1||_<k||te!==v||G<8||15<G||re<0||9<re||Z<0||p<Z)return Y(A,m);G===8&&(G=9);var F=new Ee;return(A.state=F).strm=A,F.wrap=de,F.gzhead=null,F.w_bits=G,F.w_size=1<<F.w_bits,F.w_mask=F.w_size-1,F.hash_bits=k+7,F.hash_size=1<<F.hash_bits,F.hash_mask=F.hash_size-1,F.hash_shift=~~((F.hash_bits+E-1)/E),F.window=new o.Buf8(2*F.w_size),F.head=new o.Buf16(F.hash_size),F.prev=new o.Buf16(F.w_size),F.lit_bufsize=1<<k+6,F.pending_buf_size=4*F.lit_bufsize,F.pending_buf=new o.Buf8(F.pending_buf_size),F.d_buf=1*F.lit_bufsize,F.l_buf=3*F.lit_bufsize,F.level=re,F.strategy=Z,F.method=te,tt(A)}r=[new Se(0,0,0,0,function(A,re){var te=65535;for(te>A.pending_buf_size-5&&(te=A.pending_buf_size-5);;){if(A.lookahead<=1){if(se(A),A.lookahead===0&&re===d)return w;if(A.lookahead===0)break}A.strstart+=A.lookahead,A.lookahead=0;var G=A.block_start+te;if((A.strstart===0||A.strstart>=G)&&(A.lookahead=A.strstart-G,A.strstart=G,j(A,!1),A.strm.avail_out===0)||A.strstart-A.block_start>=A.w_size-U&&(j(A,!1),A.strm.avail_out===0))return w}return A.insert=0,re===g?(j(A,!0),A.strm.avail_out===0?z:H):(A.strstart>A.block_start&&(j(A,!1),A.strm.avail_out),w)}),new Se(4,4,8,4,le),new Se(4,5,16,8,le),new Se(4,6,32,32,le),new Se(4,4,16,16,xe),new Se(8,16,32,32,xe),new Se(8,16,128,128,xe),new Se(8,32,128,256,xe),new Se(32,128,258,1024,xe),new Se(32,258,258,4096,xe)],i.deflateInit=function(A,re){return ze(A,re,v,15,8,0)},i.deflateInit2=ze,i.deflateReset=tt,i.deflateResetKeep=Ue,i.deflateSetHeader=function(A,re){return A&&A.state?A.state.wrap!==2?m:(A.state.gzhead=re,u):m},i.deflate=function(A,re){var te,G,k,Z;if(!A||!A.state||5<re||re<0)return A?Y(A,m):m;if(G=A.state,!A.output||!A.input&&A.avail_in!==0||G.status===666&&re!==g)return Y(A,A.avail_out===0?-5:m);if(G.strm=A,te=G.last_flush,G.last_flush=re,G.status===D)if(G.wrap===2)A.adler=0,me(G,31),me(G,139),me(G,8),G.gzhead?(me(G,(G.gzhead.text?1:0)+(G.gzhead.hcrc?2:0)+(G.gzhead.extra?4:0)+(G.gzhead.name?8:0)+(G.gzhead.comment?16:0)),me(G,255&G.gzhead.time),me(G,G.gzhead.time>>8&255),me(G,G.gzhead.time>>16&255),me(G,G.gzhead.time>>24&255),me(G,G.level===9?2:2<=G.strategy||G.level<2?4:0),me(G,255&G.gzhead.os),G.gzhead.extra&&G.gzhead.extra.length&&(me(G,255&G.gzhead.extra.length),me(G,G.gzhead.extra.length>>8&255)),G.gzhead.hcrc&&(A.adler=c(A.adler,G.pending_buf,G.pending,0)),G.gzindex=0,G.status=69):(me(G,0),me(G,0),me(G,0),me(G,0),me(G,0),me(G,G.level===9?2:2<=G.strategy||G.level<2?4:0),me(G,3),G.status=O);else{var de=v+(G.w_bits-8<<4)<<8;de|=(2<=G.strategy||G.level<2?0:G.level<6?1:G.level===6?2:3)<<6,G.strstart!==0&&(de|=32),de+=31-de%31,G.status=O,ge(G,de),G.strstart!==0&&(ge(G,A.adler>>>16),ge(G,65535&A.adler)),A.adler=1}if(G.status===69)if(G.gzhead.extra){for(k=G.pending;G.gzindex<(65535&G.gzhead.extra.length)&&(G.pending!==G.pending_buf_size||(G.gzhead.hcrc&&G.pending>k&&(A.adler=c(A.adler,G.pending_buf,G.pending-k,k)),X(A),k=G.pending,G.pending!==G.pending_buf_size));)me(G,255&G.gzhead.extra[G.gzindex]),G.gzindex++;G.gzhead.hcrc&&G.pending>k&&(A.adler=c(A.adler,G.pending_buf,G.pending-k,k)),G.gzindex===G.gzhead.extra.length&&(G.gzindex=0,G.status=73)}else G.status=73;if(G.status===73)if(G.gzhead.name){k=G.pending;do{if(G.pending===G.pending_buf_size&&(G.gzhead.hcrc&&G.pending>k&&(A.adler=c(A.adler,G.pending_buf,G.pending-k,k)),X(A),k=G.pending,G.pending===G.pending_buf_size)){Z=1;break}Z=G.gzindex<G.gzhead.name.length?255&G.gzhead.name.charCodeAt(G.gzindex++):0,me(G,Z)}while(Z!==0);G.gzhead.hcrc&&G.pending>k&&(A.adler=c(A.adler,G.pending_buf,G.pending-k,k)),Z===0&&(G.gzindex=0,G.status=91)}else G.status=91;if(G.status===91)if(G.gzhead.comment){k=G.pending;do{if(G.pending===G.pending_buf_size&&(G.gzhead.hcrc&&G.pending>k&&(A.adler=c(A.adler,G.pending_buf,G.pending-k,k)),X(A),k=G.pending,G.pending===G.pending_buf_size)){Z=1;break}Z=G.gzindex<G.gzhead.comment.length?255&G.gzhead.comment.charCodeAt(G.gzindex++):0,me(G,Z)}while(Z!==0);G.gzhead.hcrc&&G.pending>k&&(A.adler=c(A.adler,G.pending_buf,G.pending-k,k)),Z===0&&(G.status=103)}else G.status=103;if(G.status===103&&(G.gzhead.hcrc?(G.pending+2>G.pending_buf_size&&X(A),G.pending+2<=G.pending_buf_size&&(me(G,255&A.adler),me(G,A.adler>>8&255),A.adler=0,G.status=O)):G.status=O),G.pending!==0){if(X(A),A.avail_out===0)return G.last_flush=-1,u}else if(A.avail_in===0&&W(re)<=W(te)&&re!==g)return Y(A,-5);if(G.status===666&&A.avail_in!==0)return Y(A,-5);if(A.avail_in!==0||G.lookahead!==0||re!==d&&G.status!==666){var F=G.strategy===2?(function(ee,L){for(var P;;){if(ee.lookahead===0&&(se(ee),ee.lookahead===0)){if(L===d)return w;break}if(ee.match_length=0,P=a._tr_tally(ee,0,ee.window[ee.strstart]),ee.lookahead--,ee.strstart++,P&&(j(ee,!1),ee.strm.avail_out===0))return w}return ee.insert=0,L===g?(j(ee,!0),ee.strm.avail_out===0?z:H):ee.last_lit&&(j(ee,!1),ee.strm.avail_out===0)?w:V})(G,re):G.strategy===3?(function(ee,L){for(var P,B,J,ie,K=ee.window;;){if(ee.lookahead<=T){if(se(ee),ee.lookahead<=T&&L===d)return w;if(ee.lookahead===0)break}if(ee.match_length=0,ee.lookahead>=E&&0<ee.strstart&&(B=K[J=ee.strstart-1])===K[++J]&&B===K[++J]&&B===K[++J]){ie=ee.strstart+T;do;while(B===K[++J]&&B===K[++J]&&B===K[++J]&&B===K[++J]&&B===K[++J]&&B===K[++J]&&B===K[++J]&&B===K[++J]&&J<ie);ee.match_length=T-(ie-J),ee.match_length>ee.lookahead&&(ee.match_length=ee.lookahead)}if(ee.match_length>=E?(P=a._tr_tally(ee,1,ee.match_length-E),ee.lookahead-=ee.match_length,ee.strstart+=ee.match_length,ee.match_length=0):(P=a._tr_tally(ee,0,ee.window[ee.strstart]),ee.lookahead--,ee.strstart++),P&&(j(ee,!1),ee.strm.avail_out===0))return w}return ee.insert=0,L===g?(j(ee,!0),ee.strm.avail_out===0?z:H):ee.last_lit&&(j(ee,!1),ee.strm.avail_out===0)?w:V})(G,re):r[G.level].func(G,re);if(F!==z&&F!==H||(G.status=666),F===w||F===z)return A.avail_out===0&&(G.last_flush=-1),u;if(F===V&&(re===1?a._tr_align(G):re!==5&&(a._tr_stored_block(G,0,0,!1),re===3&&(Q(G.head),G.lookahead===0&&(G.strstart=0,G.block_start=0,G.insert=0))),X(A),A.avail_out===0))return G.last_flush=-1,u}return re!==g?u:G.wrap<=0?1:(G.wrap===2?(me(G,255&A.adler),me(G,A.adler>>8&255),me(G,A.adler>>16&255),me(G,A.adler>>24&255),me(G,255&A.total_in),me(G,A.total_in>>8&255),me(G,A.total_in>>16&255),me(G,A.total_in>>24&255)):(ge(G,A.adler>>>16),ge(G,65535&A.adler)),X(A),0<G.wrap&&(G.wrap=-G.wrap),G.pending!==0?u:1)},i.deflateEnd=function(A){var re;return A&&A.state?(re=A.state.status)!==D&&re!==69&&re!==73&&re!==91&&re!==103&&re!==O&&re!==666?Y(A,m):(A.state=null,re===O?Y(A,-3):u):m},i.deflateSetDictionary=function(A,re){var te,G,k,Z,de,F,ee,L,P=re.length;if(!A||!A.state||(Z=(te=A.state).wrap)===2||Z===1&&te.status!==D||te.lookahead)return m;for(Z===1&&(A.adler=l(A.adler,re,P,0)),te.wrap=0,P>=te.w_size&&(Z===0&&(Q(te.head),te.strstart=0,te.block_start=0,te.insert=0),L=new o.Buf8(te.w_size),o.arraySet(L,re,P-te.w_size,te.w_size,0),re=L,P=te.w_size),de=A.avail_in,F=A.next_in,ee=A.input,A.avail_in=P,A.next_in=0,A.input=re,se(te);te.lookahead>=E;){for(G=te.strstart,k=te.lookahead-(E-1);te.ins_h=(te.ins_h<<te.hash_shift^te.window[G+E-1])&te.hash_mask,te.prev[G&te.w_mask]=te.head[te.ins_h],te.head[te.ins_h]=G,G++,--k;);te.strstart=G,te.lookahead=E-1,se(te)}return te.strstart+=te.lookahead,te.block_start=te.strstart,te.insert=te.lookahead,te.lookahead=0,te.match_length=te.prev_length=E-1,te.match_available=0,A.next_in=F,A.input=ee,A.avail_in=de,te.wrap=Z,u},i.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(t,n,i){n.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,n,i){n.exports=function(r,o){var a,l,c,h,d,g,u,m,f,p,x,v,_,b,S,C,R,I,E,T,U,D,O,w,V;a=r.state,l=r.next_in,w=r.input,c=l+(r.avail_in-5),h=r.next_out,V=r.output,d=h-(o-r.avail_out),g=h+(r.avail_out-257),u=a.dmax,m=a.wsize,f=a.whave,p=a.wnext,x=a.window,v=a.hold,_=a.bits,b=a.lencode,S=a.distcode,C=(1<<a.lenbits)-1,R=(1<<a.distbits)-1;e:do{_<15&&(v+=w[l++]<<_,_+=8,v+=w[l++]<<_,_+=8),I=b[v&C];t:for(;;){if(v>>>=E=I>>>24,_-=E,(E=I>>>16&255)===0)V[h++]=65535&I;else{if(!(16&E)){if((64&E)==0){I=b[(65535&I)+(v&(1<<E)-1)];continue t}if(32&E){a.mode=12;break e}r.msg="invalid literal/length code",a.mode=30;break e}T=65535&I,(E&=15)&&(_<E&&(v+=w[l++]<<_,_+=8),T+=v&(1<<E)-1,v>>>=E,_-=E),_<15&&(v+=w[l++]<<_,_+=8,v+=w[l++]<<_,_+=8),I=S[v&R];n:for(;;){if(v>>>=E=I>>>24,_-=E,!(16&(E=I>>>16&255))){if((64&E)==0){I=S[(65535&I)+(v&(1<<E)-1)];continue n}r.msg="invalid distance code",a.mode=30;break e}if(U=65535&I,_<(E&=15)&&(v+=w[l++]<<_,(_+=8)<E&&(v+=w[l++]<<_,_+=8)),u<(U+=v&(1<<E)-1)){r.msg="invalid distance too far back",a.mode=30;break e}if(v>>>=E,_-=E,(E=h-d)<U){if(f<(E=U-E)&&a.sane){r.msg="invalid distance too far back",a.mode=30;break e}if(O=x,(D=0)===p){if(D+=m-E,E<T){for(T-=E;V[h++]=x[D++],--E;);D=h-U,O=V}}else if(p<E){if(D+=m+p-E,(E-=p)<T){for(T-=E;V[h++]=x[D++],--E;);if(D=0,p<T){for(T-=E=p;V[h++]=x[D++],--E;);D=h-U,O=V}}}else if(D+=p-E,E<T){for(T-=E;V[h++]=x[D++],--E;);D=h-U,O=V}for(;2<T;)V[h++]=O[D++],V[h++]=O[D++],V[h++]=O[D++],T-=3;T&&(V[h++]=O[D++],1<T&&(V[h++]=O[D++]))}else{for(D=h-U;V[h++]=V[D++],V[h++]=V[D++],V[h++]=V[D++],2<(T-=3););T&&(V[h++]=V[D++],1<T&&(V[h++]=V[D++]))}break}}break}}while(l<c&&h<g);l-=T=_>>3,v&=(1<<(_-=T<<3))-1,r.next_in=l,r.next_out=h,r.avail_in=l<c?c-l+5:5-(l-c),r.avail_out=h<g?g-h+257:257-(h-g),a.hold=v,a.bits=_}},{}],49:[function(t,n,i){var r=t("../utils/common"),o=t("./adler32"),a=t("./crc32"),l=t("./inffast"),c=t("./inftrees"),h=1,d=2,g=0,u=-2,m=1,f=852,p=592;function x(D){return(D>>>24&255)+(D>>>8&65280)+((65280&D)<<8)+((255&D)<<24)}function v(){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 r.Buf16(320),this.work=new r.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function _(D){var O;return D&&D.state?(O=D.state,D.total_in=D.total_out=O.total=0,D.msg="",O.wrap&&(D.adler=1&O.wrap),O.mode=m,O.last=0,O.havedict=0,O.dmax=32768,O.head=null,O.hold=0,O.bits=0,O.lencode=O.lendyn=new r.Buf32(f),O.distcode=O.distdyn=new r.Buf32(p),O.sane=1,O.back=-1,g):u}function b(D){var O;return D&&D.state?((O=D.state).wsize=0,O.whave=0,O.wnext=0,_(D)):u}function S(D,O){var w,V;return D&&D.state?(V=D.state,O<0?(w=0,O=-O):(w=1+(O>>4),O<48&&(O&=15)),O&&(O<8||15<O)?u:(V.window!==null&&V.wbits!==O&&(V.window=null),V.wrap=w,V.wbits=O,b(D))):u}function C(D,O){var w,V;return D?(V=new v,(D.state=V).window=null,(w=S(D,O))!==g&&(D.state=null),w):u}var R,I,E=!0;function T(D){if(E){var O;for(R=new r.Buf32(512),I=new r.Buf32(32),O=0;O<144;)D.lens[O++]=8;for(;O<256;)D.lens[O++]=9;for(;O<280;)D.lens[O++]=7;for(;O<288;)D.lens[O++]=8;for(c(h,D.lens,0,288,R,0,D.work,{bits:9}),O=0;O<32;)D.lens[O++]=5;c(d,D.lens,0,32,I,0,D.work,{bits:5}),E=!1}D.lencode=R,D.lenbits=9,D.distcode=I,D.distbits=5}function U(D,O,w,V){var z,H=D.state;return H.window===null&&(H.wsize=1<<H.wbits,H.wnext=0,H.whave=0,H.window=new r.Buf8(H.wsize)),V>=H.wsize?(r.arraySet(H.window,O,w-H.wsize,H.wsize,0),H.wnext=0,H.whave=H.wsize):(V<(z=H.wsize-H.wnext)&&(z=V),r.arraySet(H.window,O,w-V,z,H.wnext),(V-=z)?(r.arraySet(H.window,O,w-V,V,0),H.wnext=V,H.whave=H.wsize):(H.wnext+=z,H.wnext===H.wsize&&(H.wnext=0),H.whave<H.wsize&&(H.whave+=z))),0}i.inflateReset=b,i.inflateReset2=S,i.inflateResetKeep=_,i.inflateInit=function(D){return C(D,15)},i.inflateInit2=C,i.inflate=function(D,O){var w,V,z,H,Y,W,Q,X,j,me,ge,ue,se,le,xe,Se,Ee,Ue,tt,ze,A,re,te,G,k=0,Z=new r.Buf8(4),de=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!D||!D.state||!D.output||!D.input&&D.avail_in!==0)return u;(w=D.state).mode===12&&(w.mode=13),Y=D.next_out,z=D.output,Q=D.avail_out,H=D.next_in,V=D.input,W=D.avail_in,X=w.hold,j=w.bits,me=W,ge=Q,re=g;e:for(;;)switch(w.mode){case m:if(w.wrap===0){w.mode=13;break}for(;j<16;){if(W===0)break e;W--,X+=V[H++]<<j,j+=8}if(2&w.wrap&&X===35615){Z[w.check=0]=255&X,Z[1]=X>>>8&255,w.check=a(w.check,Z,2,0),j=X=0,w.mode=2;break}if(w.flags=0,w.head&&(w.head.done=!1),!(1&w.wrap)||(((255&X)<<8)+(X>>8))%31){D.msg="incorrect header check",w.mode=30;break}if((15&X)!=8){D.msg="unknown compression method",w.mode=30;break}if(j-=4,A=8+(15&(X>>>=4)),w.wbits===0)w.wbits=A;else if(A>w.wbits){D.msg="invalid window size",w.mode=30;break}w.dmax=1<<A,D.adler=w.check=1,w.mode=512&X?10:12,j=X=0;break;case 2:for(;j<16;){if(W===0)break e;W--,X+=V[H++]<<j,j+=8}if(w.flags=X,(255&w.flags)!=8){D.msg="unknown compression method",w.mode=30;break}if(57344&w.flags){D.msg="unknown header flags set",w.mode=30;break}w.head&&(w.head.text=X>>8&1),512&w.flags&&(Z[0]=255&X,Z[1]=X>>>8&255,w.check=a(w.check,Z,2,0)),j=X=0,w.mode=3;case 3:for(;j<32;){if(W===0)break e;W--,X+=V[H++]<<j,j+=8}w.head&&(w.head.time=X),512&w.flags&&(Z[0]=255&X,Z[1]=X>>>8&255,Z[2]=X>>>16&255,Z[3]=X>>>24&255,w.check=a(w.check,Z,4,0)),j=X=0,w.mode=4;case 4:for(;j<16;){if(W===0)break e;W--,X+=V[H++]<<j,j+=8}w.head&&(w.head.xflags=255&X,w.head.os=X>>8),512&w.flags&&(Z[0]=255&X,Z[1]=X>>>8&255,w.check=a(w.check,Z,2,0)),j=X=0,w.mode=5;case 5:if(1024&w.flags){for(;j<16;){if(W===0)break e;W--,X+=V[H++]<<j,j+=8}w.length=X,w.head&&(w.head.extra_len=X),512&w.flags&&(Z[0]=255&X,Z[1]=X>>>8&255,w.check=a(w.check,Z,2,0)),j=X=0}else w.head&&(w.head.extra=null);w.mode=6;case 6:if(1024&w.flags&&(W<(ue=w.length)&&(ue=W),ue&&(w.head&&(A=w.head.extra_len-w.length,w.head.extra||(w.head.extra=new Array(w.head.extra_len)),r.arraySet(w.head.extra,V,H,ue,A)),512&w.flags&&(w.check=a(w.check,V,ue,H)),W-=ue,H+=ue,w.length-=ue),w.length))break e;w.length=0,w.mode=7;case 7:if(2048&w.flags){if(W===0)break e;for(ue=0;A=V[H+ue++],w.head&&A&&w.length<65536&&(w.head.name+=String.fromCharCode(A)),A&&ue<W;);if(512&w.flags&&(w.check=a(w.check,V,ue,H)),W-=ue,H+=ue,A)break e}else w.head&&(w.head.name=null);w.length=0,w.mode=8;case 8:if(4096&w.flags){if(W===0)break e;for(ue=0;A=V[H+ue++],w.head&&A&&w.length<65536&&(w.head.comment+=String.fromCharCode(A)),A&&ue<W;);if(512&w.flags&&(w.check=a(w.check,V,ue,H)),W-=ue,H+=ue,A)break e}else w.head&&(w.head.comment=null);w.mode=9;case 9:if(512&w.flags){for(;j<16;){if(W===0)break e;W--,X+=V[H++]<<j,j+=8}if(X!==(65535&w.check)){D.msg="header crc mismatch",w.mode=30;break}j=X=0}w.head&&(w.head.hcrc=w.flags>>9&1,w.head.done=!0),D.adler=w.check=0,w.mode=12;break;case 10:for(;j<32;){if(W===0)break e;W--,X+=V[H++]<<j,j+=8}D.adler=w.check=x(X),j=X=0,w.mode=11;case 11:if(w.havedict===0)return D.next_out=Y,D.avail_out=Q,D.next_in=H,D.avail_in=W,w.hold=X,w.bits=j,2;D.adler=w.check=1,w.mode=12;case 12:if(O===5||O===6)break e;case 13:if(w.last){X>>>=7&j,j-=7&j,w.mode=27;break}for(;j<3;){if(W===0)break e;W--,X+=V[H++]<<j,j+=8}switch(w.last=1&X,j-=1,3&(X>>>=1)){case 0:w.mode=14;break;case 1:if(T(w),w.mode=20,O!==6)break;X>>>=2,j-=2;break e;case 2:w.mode=17;break;case 3:D.msg="invalid block type",w.mode=30}X>>>=2,j-=2;break;case 14:for(X>>>=7&j,j-=7&j;j<32;){if(W===0)break e;W--,X+=V[H++]<<j,j+=8}if((65535&X)!=(X>>>16^65535)){D.msg="invalid stored block lengths",w.mode=30;break}if(w.length=65535&X,j=X=0,w.mode=15,O===6)break e;case 15:w.mode=16;case 16:if(ue=w.length){if(W<ue&&(ue=W),Q<ue&&(ue=Q),ue===0)break e;r.arraySet(z,V,H,ue,Y),W-=ue,H+=ue,Q-=ue,Y+=ue,w.length-=ue;break}w.mode=12;break;case 17:for(;j<14;){if(W===0)break e;W--,X+=V[H++]<<j,j+=8}if(w.nlen=257+(31&X),X>>>=5,j-=5,w.ndist=1+(31&X),X>>>=5,j-=5,w.ncode=4+(15&X),X>>>=4,j-=4,286<w.nlen||30<w.ndist){D.msg="too many length or distance symbols",w.mode=30;break}w.have=0,w.mode=18;case 18:for(;w.have<w.ncode;){for(;j<3;){if(W===0)break e;W--,X+=V[H++]<<j,j+=8}w.lens[de[w.have++]]=7&X,X>>>=3,j-=3}for(;w.have<19;)w.lens[de[w.have++]]=0;if(w.lencode=w.lendyn,w.lenbits=7,te={bits:w.lenbits},re=c(0,w.lens,0,19,w.lencode,0,w.work,te),w.lenbits=te.bits,re){D.msg="invalid code lengths set",w.mode=30;break}w.have=0,w.mode=19;case 19:for(;w.have<w.nlen+w.ndist;){for(;Se=(k=w.lencode[X&(1<<w.lenbits)-1])>>>16&255,Ee=65535&k,!((xe=k>>>24)<=j);){if(W===0)break e;W--,X+=V[H++]<<j,j+=8}if(Ee<16)X>>>=xe,j-=xe,w.lens[w.have++]=Ee;else{if(Ee===16){for(G=xe+2;j<G;){if(W===0)break e;W--,X+=V[H++]<<j,j+=8}if(X>>>=xe,j-=xe,w.have===0){D.msg="invalid bit length repeat",w.mode=30;break}A=w.lens[w.have-1],ue=3+(3&X),X>>>=2,j-=2}else if(Ee===17){for(G=xe+3;j<G;){if(W===0)break e;W--,X+=V[H++]<<j,j+=8}j-=xe,A=0,ue=3+(7&(X>>>=xe)),X>>>=3,j-=3}else{for(G=xe+7;j<G;){if(W===0)break e;W--,X+=V[H++]<<j,j+=8}j-=xe,A=0,ue=11+(127&(X>>>=xe)),X>>>=7,j-=7}if(w.have+ue>w.nlen+w.ndist){D.msg="invalid bit length repeat",w.mode=30;break}for(;ue--;)w.lens[w.have++]=A}}if(w.mode===30)break;if(w.lens[256]===0){D.msg="invalid code -- missing end-of-block",w.mode=30;break}if(w.lenbits=9,te={bits:w.lenbits},re=c(h,w.lens,0,w.nlen,w.lencode,0,w.work,te),w.lenbits=te.bits,re){D.msg="invalid literal/lengths set",w.mode=30;break}if(w.distbits=6,w.distcode=w.distdyn,te={bits:w.distbits},re=c(d,w.lens,w.nlen,w.ndist,w.distcode,0,w.work,te),w.distbits=te.bits,re){D.msg="invalid distances set",w.mode=30;break}if(w.mode=20,O===6)break e;case 20:w.mode=21;case 21:if(6<=W&&258<=Q){D.next_out=Y,D.avail_out=Q,D.next_in=H,D.avail_in=W,w.hold=X,w.bits=j,l(D,ge),Y=D.next_out,z=D.output,Q=D.avail_out,H=D.next_in,V=D.input,W=D.avail_in,X=w.hold,j=w.bits,w.mode===12&&(w.back=-1);break}for(w.back=0;Se=(k=w.lencode[X&(1<<w.lenbits)-1])>>>16&255,Ee=65535&k,!((xe=k>>>24)<=j);){if(W===0)break e;W--,X+=V[H++]<<j,j+=8}if(Se&&(240&Se)==0){for(Ue=xe,tt=Se,ze=Ee;Se=(k=w.lencode[ze+((X&(1<<Ue+tt)-1)>>Ue)])>>>16&255,Ee=65535&k,!(Ue+(xe=k>>>24)<=j);){if(W===0)break e;W--,X+=V[H++]<<j,j+=8}X>>>=Ue,j-=Ue,w.back+=Ue}if(X>>>=xe,j-=xe,w.back+=xe,w.length=Ee,Se===0){w.mode=26;break}if(32&Se){w.back=-1,w.mode=12;break}if(64&Se){D.msg="invalid literal/length code",w.mode=30;break}w.extra=15&Se,w.mode=22;case 22:if(w.extra){for(G=w.extra;j<G;){if(W===0)break e;W--,X+=V[H++]<<j,j+=8}w.length+=X&(1<<w.extra)-1,X>>>=w.extra,j-=w.extra,w.back+=w.extra}w.was=w.length,w.mode=23;case 23:for(;Se=(k=w.distcode[X&(1<<w.distbits)-1])>>>16&255,Ee=65535&k,!((xe=k>>>24)<=j);){if(W===0)break e;W--,X+=V[H++]<<j,j+=8}if((240&Se)==0){for(Ue=xe,tt=Se,ze=Ee;Se=(k=w.distcode[ze+((X&(1<<Ue+tt)-1)>>Ue)])>>>16&255,Ee=65535&k,!(Ue+(xe=k>>>24)<=j);){if(W===0)break e;W--,X+=V[H++]<<j,j+=8}X>>>=Ue,j-=Ue,w.back+=Ue}if(X>>>=xe,j-=xe,w.back+=xe,64&Se){D.msg="invalid distance code",w.mode=30;break}w.offset=Ee,w.extra=15&Se,w.mode=24;case 24:if(w.extra){for(G=w.extra;j<G;){if(W===0)break e;W--,X+=V[H++]<<j,j+=8}w.offset+=X&(1<<w.extra)-1,X>>>=w.extra,j-=w.extra,w.back+=w.extra}if(w.offset>w.dmax){D.msg="invalid distance too far back",w.mode=30;break}w.mode=25;case 25:if(Q===0)break e;if(ue=ge-Q,w.offset>ue){if((ue=w.offset-ue)>w.whave&&w.sane){D.msg="invalid distance too far back",w.mode=30;break}se=ue>w.wnext?(ue-=w.wnext,w.wsize-ue):w.wnext-ue,ue>w.length&&(ue=w.length),le=w.window}else le=z,se=Y-w.offset,ue=w.length;for(Q<ue&&(ue=Q),Q-=ue,w.length-=ue;z[Y++]=le[se++],--ue;);w.length===0&&(w.mode=21);break;case 26:if(Q===0)break e;z[Y++]=w.length,Q--,w.mode=21;break;case 27:if(w.wrap){for(;j<32;){if(W===0)break e;W--,X|=V[H++]<<j,j+=8}if(ge-=Q,D.total_out+=ge,w.total+=ge,ge&&(D.adler=w.check=w.flags?a(w.check,z,ge,Y-ge):o(w.check,z,ge,Y-ge)),ge=Q,(w.flags?X:x(X))!==w.check){D.msg="incorrect data check",w.mode=30;break}j=X=0}w.mode=28;case 28:if(w.wrap&&w.flags){for(;j<32;){if(W===0)break e;W--,X+=V[H++]<<j,j+=8}if(X!==(4294967295&w.total)){D.msg="incorrect length check",w.mode=30;break}j=X=0}w.mode=29;case 29:re=1;break e;case 30:re=-3;break e;case 31:return-4;case 32:default:return u}return D.next_out=Y,D.avail_out=Q,D.next_in=H,D.avail_in=W,w.hold=X,w.bits=j,(w.wsize||ge!==D.avail_out&&w.mode<30&&(w.mode<27||O!==4))&&U(D,D.output,D.next_out,ge-D.avail_out)?(w.mode=31,-4):(me-=D.avail_in,ge-=D.avail_out,D.total_in+=me,D.total_out+=ge,w.total+=ge,w.wrap&&ge&&(D.adler=w.check=w.flags?a(w.check,z,ge,D.next_out-ge):o(w.check,z,ge,D.next_out-ge)),D.data_type=w.bits+(w.last?64:0)+(w.mode===12?128:0)+(w.mode===20||w.mode===15?256:0),(me==0&&ge===0||O===4)&&re===g&&(re=-5),re)},i.inflateEnd=function(D){if(!D||!D.state)return u;var O=D.state;return O.window&&(O.window=null),D.state=null,g},i.inflateGetHeader=function(D,O){var w;return D&&D.state?(2&(w=D.state).wrap)==0?u:((w.head=O).done=!1,g):u},i.inflateSetDictionary=function(D,O){var w,V=O.length;return D&&D.state?(w=D.state).wrap!==0&&w.mode!==11?u:w.mode===11&&o(1,O,V,0)!==w.check?-3:U(D,O,V,V)?(w.mode=31,-4):(w.havedict=1,g):u},i.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(t,n,i){var r=t("../utils/common"),o=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],a=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],l=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],c=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];n.exports=function(h,d,g,u,m,f,p,x){var v,_,b,S,C,R,I,E,T,U=x.bits,D=0,O=0,w=0,V=0,z=0,H=0,Y=0,W=0,Q=0,X=0,j=null,me=0,ge=new r.Buf16(16),ue=new r.Buf16(16),se=null,le=0;for(D=0;D<=15;D++)ge[D]=0;for(O=0;O<u;O++)ge[d[g+O]]++;for(z=U,V=15;1<=V&&ge[V]===0;V--);if(V<z&&(z=V),V===0)return m[f++]=20971520,m[f++]=20971520,x.bits=1,0;for(w=1;w<V&&ge[w]===0;w++);for(z<w&&(z=w),D=W=1;D<=15;D++)if(W<<=1,(W-=ge[D])<0)return-1;if(0<W&&(h===0||V!==1))return-1;for(ue[1]=0,D=1;D<15;D++)ue[D+1]=ue[D]+ge[D];for(O=0;O<u;O++)d[g+O]!==0&&(p[ue[d[g+O]]++]=O);if(R=h===0?(j=se=p,19):h===1?(j=o,me-=257,se=a,le-=257,256):(j=l,se=c,-1),D=w,C=f,Y=O=X=0,b=-1,S=(Q=1<<(H=z))-1,h===1&&852<Q||h===2&&592<Q)return 1;for(;;){for(I=D-Y,T=p[O]<R?(E=0,p[O]):p[O]>R?(E=se[le+p[O]],j[me+p[O]]):(E=96,0),v=1<<D-Y,w=_=1<<H;m[C+(X>>Y)+(_-=v)]=I<<24|E<<16|T|0,_!==0;);for(v=1<<D-1;X&v;)v>>=1;if(v!==0?(X&=v-1,X+=v):X=0,O++,--ge[D]==0){if(D===V)break;D=d[g+p[O]]}if(z<D&&(X&S)!==b){for(Y===0&&(Y=z),C+=w,W=1<<(H=D-Y);H+Y<V&&!((W-=ge[H+Y])<=0);)H++,W<<=1;if(Q+=1<<H,h===1&&852<Q||h===2&&592<Q)return 1;m[b=X&S]=z<<24|H<<16|C-f|0}}return X!==0&&(m[C+X]=D-Y<<24|64<<16|0),x.bits=z,0}},{"../utils/common":41}],51:[function(t,n,i){n.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,n,i){var r=t("../utils/common"),o=0,a=1;function l(k){for(var Z=k.length;0<=--Z;)k[Z]=0}var c=0,h=29,d=256,g=d+1+h,u=30,m=19,f=2*g+1,p=15,x=16,v=7,_=256,b=16,S=17,C=18,R=[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],I=[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],U=new Array(2*(g+2));l(U);var D=new Array(2*u);l(D);var O=new Array(512);l(O);var w=new Array(256);l(w);var V=new Array(h);l(V);var z,H,Y,W=new Array(u);function Q(k,Z,de,F,ee){this.static_tree=k,this.extra_bits=Z,this.extra_base=de,this.elems=F,this.max_length=ee,this.has_stree=k&&k.length}function X(k,Z){this.dyn_tree=k,this.max_code=0,this.stat_desc=Z}function j(k){return k<256?O[k]:O[256+(k>>>7)]}function me(k,Z){k.pending_buf[k.pending++]=255&Z,k.pending_buf[k.pending++]=Z>>>8&255}function ge(k,Z,de){k.bi_valid>x-de?(k.bi_buf|=Z<<k.bi_valid&65535,me(k,k.bi_buf),k.bi_buf=Z>>x-k.bi_valid,k.bi_valid+=de-x):(k.bi_buf|=Z<<k.bi_valid&65535,k.bi_valid+=de)}function ue(k,Z,de){ge(k,de[2*Z],de[2*Z+1])}function se(k,Z){for(var de=0;de|=1&k,k>>>=1,de<<=1,0<--Z;);return de>>>1}function le(k,Z,de){var F,ee,L=new Array(p+1),P=0;for(F=1;F<=p;F++)L[F]=P=P+de[F-1]<<1;for(ee=0;ee<=Z;ee++){var B=k[2*ee+1];B!==0&&(k[2*ee]=se(L[B]++,B))}}function xe(k){var Z;for(Z=0;Z<g;Z++)k.dyn_ltree[2*Z]=0;for(Z=0;Z<u;Z++)k.dyn_dtree[2*Z]=0;for(Z=0;Z<m;Z++)k.bl_tree[2*Z]=0;k.dyn_ltree[2*_]=1,k.opt_len=k.static_len=0,k.last_lit=k.matches=0}function Se(k){8<k.bi_valid?me(k,k.bi_buf):0<k.bi_valid&&(k.pending_buf[k.pending++]=k.bi_buf),k.bi_buf=0,k.bi_valid=0}function Ee(k,Z,de,F){var ee=2*Z,L=2*de;return k[ee]<k[L]||k[ee]===k[L]&&F[Z]<=F[de]}function Ue(k,Z,de){for(var F=k.heap[de],ee=de<<1;ee<=k.heap_len&&(ee<k.heap_len&&Ee(Z,k.heap[ee+1],k.heap[ee],k.depth)&&ee++,!Ee(Z,F,k.heap[ee],k.depth));)k.heap[de]=k.heap[ee],de=ee,ee<<=1;k.heap[de]=F}function tt(k,Z,de){var F,ee,L,P,B=0;if(k.last_lit!==0)for(;F=k.pending_buf[k.d_buf+2*B]<<8|k.pending_buf[k.d_buf+2*B+1],ee=k.pending_buf[k.l_buf+B],B++,F===0?ue(k,ee,Z):(ue(k,(L=w[ee])+d+1,Z),(P=R[L])!==0&&ge(k,ee-=V[L],P),ue(k,L=j(--F),de),(P=I[L])!==0&&ge(k,F-=W[L],P)),B<k.last_lit;);ue(k,_,Z)}function ze(k,Z){var de,F,ee,L=Z.dyn_tree,P=Z.stat_desc.static_tree,B=Z.stat_desc.has_stree,J=Z.stat_desc.elems,ie=-1;for(k.heap_len=0,k.heap_max=f,de=0;de<J;de++)L[2*de]!==0?(k.heap[++k.heap_len]=ie=de,k.depth[de]=0):L[2*de+1]=0;for(;k.heap_len<2;)L[2*(ee=k.heap[++k.heap_len]=ie<2?++ie:0)]=1,k.depth[ee]=0,k.opt_len--,B&&(k.static_len-=P[2*ee+1]);for(Z.max_code=ie,de=k.heap_len>>1;1<=de;de--)Ue(k,L,de);for(ee=J;de=k.heap[1],k.heap[1]=k.heap[k.heap_len--],Ue(k,L,1),F=k.heap[1],k.heap[--k.heap_max]=de,k.heap[--k.heap_max]=F,L[2*ee]=L[2*de]+L[2*F],k.depth[ee]=(k.depth[de]>=k.depth[F]?k.depth[de]:k.depth[F])+1,L[2*de+1]=L[2*F+1]=ee,k.heap[1]=ee++,Ue(k,L,1),2<=k.heap_len;);k.heap[--k.heap_max]=k.heap[1],(function(K,Ae){var ye,Pe,ke,fe,be,Be,Ne=Ae.dyn_tree,Ce=Ae.max_code,Oe=Ae.stat_desc.static_tree,q=Ae.stat_desc.has_stree,_e=Ae.stat_desc.extra_bits,Me=Ae.stat_desc.extra_base,Re=Ae.stat_desc.max_length,ve=0;for(fe=0;fe<=p;fe++)K.bl_count[fe]=0;for(Ne[2*K.heap[K.heap_max]+1]=0,ye=K.heap_max+1;ye<f;ye++)Re<(fe=Ne[2*Ne[2*(Pe=K.heap[ye])+1]+1]+1)&&(fe=Re,ve++),Ne[2*Pe+1]=fe,Ce<Pe||(K.bl_count[fe]++,be=0,Me<=Pe&&(be=_e[Pe-Me]),Be=Ne[2*Pe],K.opt_len+=Be*(fe+be),q&&(K.static_len+=Be*(Oe[2*Pe+1]+be)));if(ve!==0){do{for(fe=Re-1;K.bl_count[fe]===0;)fe--;K.bl_count[fe]--,K.bl_count[fe+1]+=2,K.bl_count[Re]--,ve-=2}while(0<ve);for(fe=Re;fe!==0;fe--)for(Pe=K.bl_count[fe];Pe!==0;)Ce<(ke=K.heap[--ye])||(Ne[2*ke+1]!==fe&&(K.opt_len+=(fe-Ne[2*ke+1])*Ne[2*ke],Ne[2*ke+1]=fe),Pe--)}})(k,Z),le(L,ie,k.bl_count)}function A(k,Z,de){var F,ee,L=-1,P=Z[1],B=0,J=7,ie=4;for(P===0&&(J=138,ie=3),Z[2*(de+1)+1]=65535,F=0;F<=de;F++)ee=P,P=Z[2*(F+1)+1],++B<J&&ee===P||(B<ie?k.bl_tree[2*ee]+=B:ee!==0?(ee!==L&&k.bl_tree[2*ee]++,k.bl_tree[2*b]++):B<=10?k.bl_tree[2*S]++:k.bl_tree[2*C]++,L=ee,ie=(B=0)===P?(J=138,3):ee===P?(J=6,3):(J=7,4))}function re(k,Z,de){var F,ee,L=-1,P=Z[1],B=0,J=7,ie=4;for(P===0&&(J=138,ie=3),F=0;F<=de;F++)if(ee=P,P=Z[2*(F+1)+1],!(++B<J&&ee===P)){if(B<ie)for(;ue(k,ee,k.bl_tree),--B!=0;);else ee!==0?(ee!==L&&(ue(k,ee,k.bl_tree),B--),ue(k,b,k.bl_tree),ge(k,B-3,2)):B<=10?(ue(k,S,k.bl_tree),ge(k,B-3,3)):(ue(k,C,k.bl_tree),ge(k,B-11,7));L=ee,ie=(B=0)===P?(J=138,3):ee===P?(J=6,3):(J=7,4)}}l(W);var te=!1;function G(k,Z,de,F){ge(k,(c<<1)+(F?1:0),3),(function(ee,L,P,B){Se(ee),me(ee,P),me(ee,~P),r.arraySet(ee.pending_buf,ee.window,L,P,ee.pending),ee.pending+=P})(k,Z,de)}i._tr_init=function(k){te||((function(){var Z,de,F,ee,L,P=new Array(p+1);for(ee=F=0;ee<h-1;ee++)for(V[ee]=F,Z=0;Z<1<<R[ee];Z++)w[F++]=ee;for(w[F-1]=ee,ee=L=0;ee<16;ee++)for(W[ee]=L,Z=0;Z<1<<I[ee];Z++)O[L++]=ee;for(L>>=7;ee<u;ee++)for(W[ee]=L<<7,Z=0;Z<1<<I[ee]-7;Z++)O[256+L++]=ee;for(de=0;de<=p;de++)P[de]=0;for(Z=0;Z<=143;)U[2*Z+1]=8,Z++,P[8]++;for(;Z<=255;)U[2*Z+1]=9,Z++,P[9]++;for(;Z<=279;)U[2*Z+1]=7,Z++,P[7]++;for(;Z<=287;)U[2*Z+1]=8,Z++,P[8]++;for(le(U,g+1,P),Z=0;Z<u;Z++)D[2*Z+1]=5,D[2*Z]=se(Z,5);z=new Q(U,R,d+1,g,p),H=new Q(D,I,0,u,p),Y=new Q(new Array(0),E,0,m,v)})(),te=!0),k.l_desc=new X(k.dyn_ltree,z),k.d_desc=new X(k.dyn_dtree,H),k.bl_desc=new X(k.bl_tree,Y),k.bi_buf=0,k.bi_valid=0,xe(k)},i._tr_stored_block=G,i._tr_flush_block=function(k,Z,de,F){var ee,L,P=0;0<k.level?(k.strm.data_type===2&&(k.strm.data_type=(function(B){var J,ie=4093624447;for(J=0;J<=31;J++,ie>>>=1)if(1&ie&&B.dyn_ltree[2*J]!==0)return o;if(B.dyn_ltree[18]!==0||B.dyn_ltree[20]!==0||B.dyn_ltree[26]!==0)return a;for(J=32;J<d;J++)if(B.dyn_ltree[2*J]!==0)return a;return o})(k)),ze(k,k.l_desc),ze(k,k.d_desc),P=(function(B){var J;for(A(B,B.dyn_ltree,B.l_desc.max_code),A(B,B.dyn_dtree,B.d_desc.max_code),ze(B,B.bl_desc),J=m-1;3<=J&&B.bl_tree[2*T[J]+1]===0;J--);return B.opt_len+=3*(J+1)+5+5+4,J})(k),ee=k.opt_len+3+7>>>3,(L=k.static_len+3+7>>>3)<=ee&&(ee=L)):ee=L=de+5,de+4<=ee&&Z!==-1?G(k,Z,de,F):k.strategy===4||L===ee?(ge(k,2+(F?1:0),3),tt(k,U,D)):(ge(k,4+(F?1:0),3),(function(B,J,ie,K){var Ae;for(ge(B,J-257,5),ge(B,ie-1,5),ge(B,K-4,4),Ae=0;Ae<K;Ae++)ge(B,B.bl_tree[2*T[Ae]+1],3);re(B,B.dyn_ltree,J-1),re(B,B.dyn_dtree,ie-1)})(k,k.l_desc.max_code+1,k.d_desc.max_code+1,P+1),tt(k,k.dyn_ltree,k.dyn_dtree)),xe(k),F&&Se(k)},i._tr_tally=function(k,Z,de){return k.pending_buf[k.d_buf+2*k.last_lit]=Z>>>8&255,k.pending_buf[k.d_buf+2*k.last_lit+1]=255&Z,k.pending_buf[k.l_buf+k.last_lit]=255&de,k.last_lit++,Z===0?k.dyn_ltree[2*de]++:(k.matches++,Z--,k.dyn_ltree[2*(w[de]+d+1)]++,k.dyn_dtree[2*j(Z)]++),k.last_lit===k.lit_bufsize-1},i._tr_align=function(k){ge(k,2,3),ue(k,_,U),(function(Z){Z.bi_valid===16?(me(Z,Z.bi_buf),Z.bi_buf=0,Z.bi_valid=0):8<=Z.bi_valid&&(Z.pending_buf[Z.pending++]=255&Z.bi_buf,Z.bi_buf>>=8,Z.bi_valid-=8)})(k)}},{"../utils/common":41}],53:[function(t,n,i){n.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,n,i){(function(r){(function(o,a){if(!o.setImmediate){var l,c,h,d,g=1,u={},m=!1,f=o.document,p=Object.getPrototypeOf&&Object.getPrototypeOf(o);p=p&&p.setTimeout?p:o,l={}.toString.call(o.process)==="[object process]"?function(b){process.nextTick(function(){v(b)})}:(function(){if(o.postMessage&&!o.importScripts){var b=!0,S=o.onmessage;return o.onmessage=function(){b=!1},o.postMessage("","*"),o.onmessage=S,b}})()?(d="setImmediate$"+Math.random()+"$",o.addEventListener?o.addEventListener("message",_,!1):o.attachEvent("onmessage",_),function(b){o.postMessage(d+b,"*")}):o.MessageChannel?((h=new MessageChannel).port1.onmessage=function(b){v(b.data)},function(b){h.port2.postMessage(b)}):f&&"onreadystatechange"in f.createElement("script")?(c=f.documentElement,function(b){var S=f.createElement("script");S.onreadystatechange=function(){v(b),S.onreadystatechange=null,c.removeChild(S),S=null},c.appendChild(S)}):function(b){setTimeout(v,0,b)},p.setImmediate=function(b){typeof b!="function"&&(b=new Function(""+b));for(var S=new Array(arguments.length-1),C=0;C<S.length;C++)S[C]=arguments[C+1];var R={callback:b,args:S};return u[g]=R,l(g),g++},p.clearImmediate=x}function x(b){delete u[b]}function v(b){if(m)setTimeout(v,0,b);else{var S=u[b];if(S){m=!0;try{(function(C){var R=C.callback,I=C.args;switch(I.length){case 0:R();break;case 1:R(I[0]);break;case 2:R(I[0],I[1]);break;case 3:R(I[0],I[1],I[2]);break;default:R.apply(a,I)}})(S)}finally{x(b),m=!1}}}}function _(b){b.source===o&&typeof b.data=="string"&&b.data.indexOf(d)===0&&v(+b.data.slice(d.length))}})(typeof self>"u"?r===void 0?this:r:self)}).call(this,typeof Dr<"u"?Dr:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(Na)),Na.exports}var K0=Z0();const Xc=Wc(K0);function jc(s,e){return function(){return s.apply(e,arguments)}}const{toString:$0}=Object.prototype,{getPrototypeOf:Ua}=Object,{iterator:Lr,toStringTag:Yc}=Symbol,Ir=(s=>e=>{const t=$0.call(e);return s[t]||(s[t]=t.slice(8,-1).toLowerCase())})(Object.create(null)),dn=s=>(s=s.toLowerCase(),e=>Ir(e)===s),Nr=s=>e=>typeof e===s,{isArray:$i}=Array,Ji=Nr("undefined");function ys(s){return s!==null&&!Ji(s)&&s.constructor!==null&&!Ji(s.constructor)&&zt(s.constructor.isBuffer)&&s.constructor.isBuffer(s)}const qc=dn("ArrayBuffer");function J0(s){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(s):e=s&&s.buffer&&qc(s.buffer),e}const Q0=Nr("string"),zt=Nr("function"),Zc=Nr("number"),Ms=s=>s!==null&&typeof s=="object",ex=s=>s===!0||s===!1,Ur=s=>{if(Ir(s)!=="object")return!1;const e=Ua(s);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Yc in s)&&!(Lr in s)},tx=s=>{if(!Ms(s)||ys(s))return!1;try{return Object.keys(s).length===0&&Object.getPrototypeOf(s)===Object.prototype}catch{return!1}},nx=dn("Date"),ix=dn("File"),sx=dn("Blob"),rx=dn("FileList"),ox=s=>Ms(s)&&zt(s.pipe),ax=s=>{let e;return s&&(typeof FormData=="function"&&s instanceof FormData||zt(s.append)&&((e=Ir(s))==="formdata"||e==="object"&&zt(s.toString)&&s.toString()==="[object FormData]"))},lx=dn("URLSearchParams"),[cx,hx,dx,ux]=["ReadableStream","Request","Response","Headers"].map(dn),fx=s=>s.trim?s.trim():s.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function bs(s,e,{allOwnKeys:t=!1}={}){if(s===null||typeof s>"u")return;let n,i;if(typeof s!="object"&&(s=[s]),$i(s))for(n=0,i=s.length;n<i;n++)e.call(null,s[n],n,s);else{if(ys(s))return;const r=t?Object.getOwnPropertyNames(s):Object.keys(s),o=r.length;let a;for(n=0;n<o;n++)a=r[n],e.call(null,s[a],a,s)}}function Kc(s,e){if(ys(s))return null;e=e.toLowerCase();const t=Object.keys(s);let n=t.length,i;for(;n-- >0;)if(i=t[n],e===i.toLowerCase())return i;return null}const vi=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,$c=s=>!Ji(s)&&s!==vi;function Fa(){const{caseless:s,skipUndefined:e}=$c(this)&&this||{},t={},n=(i,r)=>{const o=s&&Kc(t,r)||r;Ur(t[o])&&Ur(i)?t[o]=Fa(t[o],i):Ur(i)?t[o]=Fa({},i):$i(i)?t[o]=i.slice():(!e||!Ji(i))&&(t[o]=i)};for(let i=0,r=arguments.length;i<r;i++)arguments[i]&&bs(arguments[i],n);return t}const px=(s,e,t,{allOwnKeys:n}={})=>(bs(e,(i,r)=>{t&&zt(i)?s[r]=jc(i,t):s[r]=i},{allOwnKeys:n}),s),mx=s=>(s.charCodeAt(0)===65279&&(s=s.slice(1)),s),gx=(s,e,t,n)=>{s.prototype=Object.create(e.prototype,n),s.prototype.constructor=s,Object.defineProperty(s,"super",{value:e.prototype}),t&&Object.assign(s.prototype,t)},xx=(s,e,t,n)=>{let i,r,o;const a={};if(e=e||{},s==null)return e;do{for(i=Object.getOwnPropertyNames(s),r=i.length;r-- >0;)o=i[r],(!n||n(o,s,e))&&!a[o]&&(e[o]=s[o],a[o]=!0);s=t!==!1&&Ua(s)}while(s&&(!t||t(s,e))&&s!==Object.prototype);return e},vx=(s,e,t)=>{s=String(s),(t===void 0||t>s.length)&&(t=s.length),t-=e.length;const n=s.indexOf(e,t);return n!==-1&&n===t},_x=s=>{if(!s)return null;if($i(s))return s;let e=s.length;if(!Zc(e))return null;const t=new Array(e);for(;e-- >0;)t[e]=s[e];return t},yx=(s=>e=>s&&e instanceof s)(typeof Uint8Array<"u"&&Ua(Uint8Array)),Mx=(s,e)=>{const n=(s&&s[Lr]).call(s);let i;for(;(i=n.next())&&!i.done;){const r=i.value;e.call(s,r[0],r[1])}},bx=(s,e)=>{let t;const n=[];for(;(t=s.exec(e))!==null;)n.push(t);return n},wx=dn("HTMLFormElement"),Sx=s=>s.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(t,n,i){return n.toUpperCase()+i}),Jc=(({hasOwnProperty:s})=>(e,t)=>s.call(e,t))(Object.prototype),Ex=dn("RegExp"),Qc=(s,e)=>{const t=Object.getOwnPropertyDescriptors(s),n={};bs(t,(i,r)=>{let o;(o=e(i,r,s))!==!1&&(n[r]=o||i)}),Object.defineProperties(s,n)},Cx=s=>{Qc(s,(e,t)=>{if(zt(s)&&["arguments","caller","callee"].indexOf(t)!==-1)return!1;const n=s[t];if(zt(n)){if(e.enumerable=!1,"writable"in e){e.writable=!1;return}e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+t+"'")})}})},Ax=(s,e)=>{const t={},n=i=>{i.forEach(r=>{t[r]=!0})};return $i(s)?n(s):n(String(s).split(e)),t},Tx=()=>{},Px=(s,e)=>s!=null&&Number.isFinite(s=+s)?s:e;function Dx(s){return!!(s&&zt(s.append)&&s[Yc]==="FormData"&&s[Lr])}const Rx=s=>{const e=new Array(10),t=(n,i)=>{if(Ms(n)){if(e.indexOf(n)>=0)return;if(ys(n))return n;if(!("toJSON"in n)){e[i]=n;const r=$i(n)?[]:{};return bs(n,(o,a)=>{const l=t(o,i+1);!Ji(l)&&(r[a]=l)}),e[i]=void 0,r}}return n};return t(s,0)},Lx=dn("AsyncFunction"),Ix=s=>s&&(Ms(s)||zt(s))&&zt(s.then)&&zt(s.catch),eh=((s,e)=>s?setImmediate:e?((t,n)=>(vi.addEventListener("message",({source:i,data:r})=>{i===vi&&r===t&&n.length&&n.shift()()},!1),i=>{n.push(i),vi.postMessage(t,"*")}))(`axios@${Math.random()}`,[]):t=>setTimeout(t))(typeof setImmediate=="function",zt(vi.postMessage)),Nx=typeof queueMicrotask<"u"?queueMicrotask.bind(vi):typeof process<"u"&&process.nextTick||eh,ae={isArray:$i,isArrayBuffer:qc,isBuffer:ys,isFormData:ax,isArrayBufferView:J0,isString:Q0,isNumber:Zc,isBoolean:ex,isObject:Ms,isPlainObject:Ur,isEmptyObject:tx,isReadableStream:cx,isRequest:hx,isResponse:dx,isHeaders:ux,isUndefined:Ji,isDate:nx,isFile:ix,isBlob:sx,isRegExp:Ex,isFunction:zt,isStream:ox,isURLSearchParams:lx,isTypedArray:yx,isFileList:rx,forEach:bs,merge:Fa,extend:px,trim:fx,stripBOM:mx,inherits:gx,toFlatObject:xx,kindOf:Ir,kindOfTest:dn,endsWith:vx,toArray:_x,forEachEntry:Mx,matchAll:bx,isHTMLForm:wx,hasOwnProperty:Jc,hasOwnProp:Jc,reduceDescriptors:Qc,freezeMethods:Cx,toObjectSet:Ax,toCamelCase:Sx,noop:Tx,toFiniteNumber:Px,findKey:Kc,global:vi,isContextDefined:$c,isSpecCompliantForm:Dx,toJSONObject:Rx,isAsyncFn:Lx,isThenable:Ix,setImmediate:eh,asap:Nx,isIterable:s=>s!=null&&zt(s[Lr])};function qe(s,e,t,n,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=s,this.name="AxiosError",e&&(this.code=e),t&&(this.config=t),n&&(this.request=n),i&&(this.response=i,this.status=i.status?i.status:null)}ae.inherits(qe,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:ae.toJSONObject(this.config),code:this.code,status:this.status}}});const th=qe.prototype,nh={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(s=>{nh[s]={value:s}}),Object.defineProperties(qe,nh),Object.defineProperty(th,"isAxiosError",{value:!0}),qe.from=(s,e,t,n,i,r)=>{const o=Object.create(th);ae.toFlatObject(s,o,function(h){return h!==Error.prototype},c=>c!=="isAxiosError");const a=s&&s.message?s.message:"Error",l=e==null&&s?s.code:e;return qe.call(o,a,l,t,n,i),s&&o.cause==null&&Object.defineProperty(o,"cause",{value:s,configurable:!0}),o.name=s&&s.name||"Error",r&&Object.assign(o,r),o};const Ux=null;function Oa(s){return ae.isPlainObject(s)||ae.isArray(s)}function ih(s){return ae.endsWith(s,"[]")?s.slice(0,-2):s}function sh(s,e,t){return s?s.concat(e).map(function(i,r){return i=ih(i),!t&&r?"["+i+"]":i}).join(t?".":""):e}function Fx(s){return ae.isArray(s)&&!s.some(Oa)}const Ox=ae.toFlatObject(ae,{},null,function(e){return/^is[A-Z]/.test(e)});function Fr(s,e,t){if(!ae.isObject(s))throw new TypeError("target must be an object");e=e||new FormData,t=ae.toFlatObject(t,{metaTokens:!0,dots:!1,indexes:!1},!1,function(f,p){return!ae.isUndefined(p[f])});const n=t.metaTokens,i=t.visitor||h,r=t.dots,o=t.indexes,l=(t.Blob||typeof Blob<"u"&&Blob)&&ae.isSpecCompliantForm(e);if(!ae.isFunction(i))throw new TypeError("visitor must be a function");function c(m){if(m===null)return"";if(ae.isDate(m))return m.toISOString();if(ae.isBoolean(m))return m.toString();if(!l&&ae.isBlob(m))throw new qe("Blob is not supported. Use a Buffer instead.");return ae.isArrayBuffer(m)||ae.isTypedArray(m)?l&&typeof Blob=="function"?new Blob([m]):Buffer.from(m):m}function h(m,f,p){let x=m;if(m&&!p&&typeof m=="object"){if(ae.endsWith(f,"{}"))f=n?f:f.slice(0,-2),m=JSON.stringify(m);else if(ae.isArray(m)&&Fx(m)||(ae.isFileList(m)||ae.endsWith(f,"[]"))&&(x=ae.toArray(m)))return f=ih(f),x.forEach(function(_,b){!(ae.isUndefined(_)||_===null)&&e.append(o===!0?sh([f],b,r):o===null?f:f+"[]",c(_))}),!1}return Oa(m)?!0:(e.append(sh(p,f,r),c(m)),!1)}const d=[],g=Object.assign(Ox,{defaultVisitor:h,convertValue:c,isVisitable:Oa});function u(m,f){if(!ae.isUndefined(m)){if(d.indexOf(m)!==-1)throw Error("Circular reference detected in "+f.join("."));d.push(m),ae.forEach(m,function(x,v){(!(ae.isUndefined(x)||x===null)&&i.call(e,x,ae.isString(v)?v.trim():v,f,g))===!0&&u(x,f?f.concat(v):[v])}),d.pop()}}if(!ae.isObject(s))throw new TypeError("data must be an object");return u(s),e}function rh(s){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(s).replace(/[!'()~]|%20|%00/g,function(n){return e[n]})}function ka(s,e){this._pairs=[],s&&Fr(s,this,e)}const oh=ka.prototype;oh.append=function(e,t){this._pairs.push([e,t])},oh.toString=function(e){const t=e?function(n){return e.call(this,n,rh)}:rh;return this._pairs.map(function(i){return t(i[0])+"="+t(i[1])},"").join("&")};function kx(s){return encodeURIComponent(s).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function ah(s,e,t){if(!e)return s;const n=t&&t.encode||kx;ae.isFunction(t)&&(t={serialize:t});const i=t&&t.serialize;let r;if(i?r=i(e,t):r=ae.isURLSearchParams(e)?e.toString():new ka(e,t).toString(n),r){const o=s.indexOf("#");o!==-1&&(s=s.slice(0,o)),s+=(s.indexOf("?")===-1?"?":"&")+r}return s}class lh{constructor(){this.handlers=[]}use(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){ae.forEach(this.handlers,function(n){n!==null&&e(n)})}}const ch={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Bx={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:ka,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},Ba=typeof window<"u"&&typeof document<"u",za=typeof navigator=="object"&&navigator||void 0,zx=Ba&&(!za||["ReactNative","NativeScript","NS"].indexOf(za.product)<0),Vx=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Gx=Ba&&window.location.href||"http://localhost",Lt={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Ba,hasStandardBrowserEnv:zx,hasStandardBrowserWebWorkerEnv:Vx,navigator:za,origin:Gx},Symbol.toStringTag,{value:"Module"})),...Bx};function Wx(s,e){return Fr(s,new Lt.classes.URLSearchParams,{visitor:function(t,n,i,r){return Lt.isNode&&ae.isBuffer(t)?(this.append(n,t.toString("base64")),!1):r.defaultVisitor.apply(this,arguments)},...e})}function Hx(s){return ae.matchAll(/\w+|\[(\w*)]/g,s).map(e=>e[0]==="[]"?"":e[1]||e[0])}function Xx(s){const e={},t=Object.keys(s);let n;const i=t.length;let r;for(n=0;n<i;n++)r=t[n],e[r]=s[r];return e}function hh(s){function e(t,n,i,r){let o=t[r++];if(o==="__proto__")return!0;const a=Number.isFinite(+o),l=r>=t.length;return o=!o&&ae.isArray(i)?i.length:o,l?(ae.hasOwnProp(i,o)?i[o]=[i[o],n]:i[o]=n,!a):((!i[o]||!ae.isObject(i[o]))&&(i[o]=[]),e(t,n,i[o],r)&&ae.isArray(i[o])&&(i[o]=Xx(i[o])),!a)}if(ae.isFormData(s)&&ae.isFunction(s.entries)){const t={};return ae.forEachEntry(s,(n,i)=>{e(Hx(n),i,t,0)}),t}return null}function jx(s,e,t){if(ae.isString(s))try{return(e||JSON.parse)(s),ae.trim(s)}catch(n){if(n.name!=="SyntaxError")throw n}return(t||JSON.stringify)(s)}const ws={transitional:ch,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const n=t.getContentType()||"",i=n.indexOf("application/json")>-1,r=ae.isObject(e);if(r&&ae.isHTMLForm(e)&&(e=new FormData(e)),ae.isFormData(e))return i?JSON.stringify(hh(e)):e;if(ae.isArrayBuffer(e)||ae.isBuffer(e)||ae.isStream(e)||ae.isFile(e)||ae.isBlob(e)||ae.isReadableStream(e))return e;if(ae.isArrayBufferView(e))return e.buffer;if(ae.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let a;if(r){if(n.indexOf("application/x-www-form-urlencoded")>-1)return Wx(e,this.formSerializer).toString();if((a=ae.isFileList(e))||n.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return Fr(a?{"files[]":e}:e,l&&new l,this.formSerializer)}}return r||i?(t.setContentType("application/json",!1),jx(e)):e}],transformResponse:[function(e){const t=this.transitional||ws.transitional,n=t&&t.forcedJSONParsing,i=this.responseType==="json";if(ae.isResponse(e)||ae.isReadableStream(e))return e;if(e&&ae.isString(e)&&(n&&!this.responseType||i)){const o=!(t&&t.silentJSONParsing)&&i;try{return JSON.parse(e,this.parseReviver)}catch(a){if(o)throw a.name==="SyntaxError"?qe.from(a,qe.ERR_BAD_RESPONSE,this,null,this.response):a}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Lt.classes.FormData,Blob:Lt.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};ae.forEach(["delete","get","head","post","put","patch"],s=>{ws.headers[s]={}});const Yx=ae.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),qx=s=>{const e={};let t,n,i;return s&&s.split(`
|
|
4935
4935
|
`).forEach(function(o){i=o.indexOf(":"),t=o.substring(0,i).trim().toLowerCase(),n=o.substring(i+1).trim(),!(!t||e[t]&&Yx[t])&&(t==="set-cookie"?e[t]?e[t].push(n):e[t]=[n]:e[t]=e[t]?e[t]+", "+n:n)}),e},dh=Symbol("internals");function Ss(s){return s&&String(s).trim().toLowerCase()}function Or(s){return s===!1||s==null?s:ae.isArray(s)?s.map(Or):String(s)}function Zx(s){const e=Object.create(null),t=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let n;for(;n=t.exec(s);)e[n[1]]=n[2];return e}const Kx=s=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(s.trim());function Va(s,e,t,n,i){if(ae.isFunction(n))return n.call(this,e,t);if(i&&(e=t),!!ae.isString(e)){if(ae.isString(n))return e.indexOf(n)!==-1;if(ae.isRegExp(n))return n.test(e)}}function $x(s){return s.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,n)=>t.toUpperCase()+n)}function Jx(s,e){const t=ae.toCamelCase(" "+e);["get","set","has"].forEach(n=>{Object.defineProperty(s,n+t,{value:function(i,r,o){return this[n].call(this,e,i,r,o)},configurable:!0})})}let Vt=class{constructor(e){e&&this.set(e)}set(e,t,n){const i=this;function r(a,l,c){const h=Ss(l);if(!h)throw new Error("header name must be a non-empty string");const d=ae.findKey(i,h);(!d||i[d]===void 0||c===!0||c===void 0&&i[d]!==!1)&&(i[d||l]=Or(a))}const o=(a,l)=>ae.forEach(a,(c,h)=>r(c,h,l));if(ae.isPlainObject(e)||e instanceof this.constructor)o(e,t);else if(ae.isString(e)&&(e=e.trim())&&!Kx(e))o(qx(e),t);else if(ae.isObject(e)&&ae.isIterable(e)){let a={},l,c;for(const h of e){if(!ae.isArray(h))throw TypeError("Object iterator must return a key-value pair");a[c=h[0]]=(l=a[c])?ae.isArray(l)?[...l,h[1]]:[l,h[1]]:h[1]}o(a,t)}else e!=null&&r(t,e,n);return this}get(e,t){if(e=Ss(e),e){const n=ae.findKey(this,e);if(n){const i=this[n];if(!t)return i;if(t===!0)return Zx(i);if(ae.isFunction(t))return t.call(this,i,n);if(ae.isRegExp(t))return t.exec(i);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=Ss(e),e){const n=ae.findKey(this,e);return!!(n&&this[n]!==void 0&&(!t||Va(this,this[n],n,t)))}return!1}delete(e,t){const n=this;let i=!1;function r(o){if(o=Ss(o),o){const a=ae.findKey(n,o);a&&(!t||Va(n,n[a],a,t))&&(delete n[a],i=!0)}}return ae.isArray(e)?e.forEach(r):r(e),i}clear(e){const t=Object.keys(this);let n=t.length,i=!1;for(;n--;){const r=t[n];(!e||Va(this,this[r],r,e,!0))&&(delete this[r],i=!0)}return i}normalize(e){const t=this,n={};return ae.forEach(this,(i,r)=>{const o=ae.findKey(n,r);if(o){t[o]=Or(i),delete t[r];return}const a=e?$x(r):String(r).trim();a!==r&&delete t[r],t[a]=Or(i),n[a]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return ae.forEach(this,(n,i)=>{n!=null&&n!==!1&&(t[i]=e&&ae.isArray(n)?n.join(", "):n)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,t])=>e+": "+t).join(`
|
|
4936
4936
|
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const n=new this(e);return t.forEach(i=>n.set(i)),n}static accessor(e){const n=(this[dh]=this[dh]={accessors:{}}).accessors,i=this.prototype;function r(o){const a=Ss(o);n[a]||(Jx(i,o),n[a]=!0)}return ae.isArray(e)?e.forEach(r):r(e),this}};Vt.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),ae.reduceDescriptors(Vt.prototype,({value:s},e)=>{let t=e[0].toUpperCase()+e.slice(1);return{get:()=>s,set(n){this[t]=n}}}),ae.freezeMethods(Vt);function Ga(s,e){const t=this||ws,n=e||t,i=Vt.from(n.headers);let r=n.data;return ae.forEach(s,function(a){r=a.call(t,r,i.normalize(),e?e.status:void 0)}),i.normalize(),r}function uh(s){return!!(s&&s.__CANCEL__)}function Qi(s,e,t){qe.call(this,s??"canceled",qe.ERR_CANCELED,e,t),this.name="CanceledError"}ae.inherits(Qi,qe,{__CANCEL__:!0});function fh(s,e,t){const n=t.config.validateStatus;!t.status||!n||n(t.status)?s(t):e(new qe("Request failed with status code "+t.status,[qe.ERR_BAD_REQUEST,qe.ERR_BAD_RESPONSE][Math.floor(t.status/100)-4],t.config,t.request,t))}function Qx(s){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(s);return e&&e[1]||""}function ev(s,e){s=s||10;const t=new Array(s),n=new Array(s);let i=0,r=0,o;return e=e!==void 0?e:1e3,function(l){const c=Date.now(),h=n[r];o||(o=c),t[i]=l,n[i]=c;let d=r,g=0;for(;d!==i;)g+=t[d++],d=d%s;if(i=(i+1)%s,i===r&&(r=(r+1)%s),c-o<e)return;const u=h&&c-h;return u?Math.round(g*1e3/u):void 0}}function tv(s,e){let t=0,n=1e3/e,i,r;const o=(c,h=Date.now())=>{t=h,i=null,r&&(clearTimeout(r),r=null),s(...c)};return[(...c)=>{const h=Date.now(),d=h-t;d>=n?o(c,h):(i=c,r||(r=setTimeout(()=>{r=null,o(i)},n-d)))},()=>i&&o(i)]}const kr=(s,e,t=3)=>{let n=0;const i=ev(50,250);return tv(r=>{const o=r.loaded,a=r.lengthComputable?r.total:void 0,l=o-n,c=i(l),h=o<=a;n=o;const d={loaded:o,total:a,progress:a?o/a:void 0,bytes:l,rate:c||void 0,estimated:c&&a&&h?(a-o)/c:void 0,event:r,lengthComputable:a!=null,[e?"download":"upload"]:!0};s(d)},t)},ph=(s,e)=>{const t=s!=null;return[n=>e[0]({lengthComputable:t,total:s,loaded:n}),e[1]]},mh=s=>(...e)=>ae.asap(()=>s(...e)),nv=Lt.hasStandardBrowserEnv?((s,e)=>t=>(t=new URL(t,Lt.origin),s.protocol===t.protocol&&s.host===t.host&&(e||s.port===t.port)))(new URL(Lt.origin),Lt.navigator&&/(msie|trident)/i.test(Lt.navigator.userAgent)):()=>!0,iv=Lt.hasStandardBrowserEnv?{write(s,e,t,n,i,r,o){if(typeof document>"u")return;const a=[`${s}=${encodeURIComponent(e)}`];ae.isNumber(t)&&a.push(`expires=${new Date(t).toUTCString()}`),ae.isString(n)&&a.push(`path=${n}`),ae.isString(i)&&a.push(`domain=${i}`),r===!0&&a.push("secure"),ae.isString(o)&&a.push(`SameSite=${o}`),document.cookie=a.join("; ")},read(s){if(typeof document>"u")return null;const e=document.cookie.match(new RegExp("(?:^|; )"+s+"=([^;]*)"));return e?decodeURIComponent(e[1]):null},remove(s){this.write(s,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function sv(s){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(s)}function rv(s,e){return e?s.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):s}function gh(s,e,t){let n=!sv(e);return s&&(n||t==!1)?rv(s,e):e}const xh=s=>s instanceof Vt?{...s}:s;function _i(s,e){e=e||{};const t={};function n(c,h,d,g){return ae.isPlainObject(c)&&ae.isPlainObject(h)?ae.merge.call({caseless:g},c,h):ae.isPlainObject(h)?ae.merge({},h):ae.isArray(h)?h.slice():h}function i(c,h,d,g){if(ae.isUndefined(h)){if(!ae.isUndefined(c))return n(void 0,c,d,g)}else return n(c,h,d,g)}function r(c,h){if(!ae.isUndefined(h))return n(void 0,h)}function o(c,h){if(ae.isUndefined(h)){if(!ae.isUndefined(c))return n(void 0,c)}else return n(void 0,h)}function a(c,h,d){if(d in e)return n(c,h);if(d in s)return n(void 0,c)}const l={url:r,method:r,data:r,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:a,headers:(c,h,d)=>i(xh(c),xh(h),d,!0)};return ae.forEach(Object.keys({...s,...e}),function(h){const d=l[h]||i,g=d(s[h],e[h],h);ae.isUndefined(g)&&d!==a||(t[h]=g)}),t}const vh=s=>{const e=_i({},s);let{data:t,withXSRFToken:n,xsrfHeaderName:i,xsrfCookieName:r,headers:o,auth:a}=e;if(e.headers=o=Vt.from(o),e.url=ah(gh(e.baseURL,e.url,e.allowAbsoluteUrls),s.params,s.paramsSerializer),a&&o.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),ae.isFormData(t)){if(Lt.hasStandardBrowserEnv||Lt.hasStandardBrowserWebWorkerEnv)o.setContentType(void 0);else if(ae.isFunction(t.getHeaders)){const l=t.getHeaders(),c=["content-type","content-length"];Object.entries(l).forEach(([h,d])=>{c.includes(h.toLowerCase())&&o.set(h,d)})}}if(Lt.hasStandardBrowserEnv&&(n&&ae.isFunction(n)&&(n=n(e)),n||n!==!1&&nv(e.url))){const l=i&&r&&iv.read(r);l&&o.set(i,l)}return e},ov=typeof XMLHttpRequest<"u"&&function(s){return new Promise(function(t,n){const i=vh(s);let r=i.data;const o=Vt.from(i.headers).normalize();let{responseType:a,onUploadProgress:l,onDownloadProgress:c}=i,h,d,g,u,m;function f(){u&&u(),m&&m(),i.cancelToken&&i.cancelToken.unsubscribe(h),i.signal&&i.signal.removeEventListener("abort",h)}let p=new XMLHttpRequest;p.open(i.method.toUpperCase(),i.url,!0),p.timeout=i.timeout;function x(){if(!p)return;const _=Vt.from("getAllResponseHeaders"in p&&p.getAllResponseHeaders()),S={data:!a||a==="text"||a==="json"?p.responseText:p.response,status:p.status,statusText:p.statusText,headers:_,config:s,request:p};fh(function(R){t(R),f()},function(R){n(R),f()},S),p=null}"onloadend"in p?p.onloadend=x:p.onreadystatechange=function(){!p||p.readyState!==4||p.status===0&&!(p.responseURL&&p.responseURL.indexOf("file:")===0)||setTimeout(x)},p.onabort=function(){p&&(n(new qe("Request aborted",qe.ECONNABORTED,s,p)),p=null)},p.onerror=function(b){const S=b&&b.message?b.message:"Network Error",C=new qe(S,qe.ERR_NETWORK,s,p);C.event=b||null,n(C),p=null},p.ontimeout=function(){let b=i.timeout?"timeout of "+i.timeout+"ms exceeded":"timeout exceeded";const S=i.transitional||ch;i.timeoutErrorMessage&&(b=i.timeoutErrorMessage),n(new qe(b,S.clarifyTimeoutError?qe.ETIMEDOUT:qe.ECONNABORTED,s,p)),p=null},r===void 0&&o.setContentType(null),"setRequestHeader"in p&&ae.forEach(o.toJSON(),function(b,S){p.setRequestHeader(S,b)}),ae.isUndefined(i.withCredentials)||(p.withCredentials=!!i.withCredentials),a&&a!=="json"&&(p.responseType=i.responseType),c&&([g,m]=kr(c,!0),p.addEventListener("progress",g)),l&&p.upload&&([d,u]=kr(l),p.upload.addEventListener("progress",d),p.upload.addEventListener("loadend",u)),(i.cancelToken||i.signal)&&(h=_=>{p&&(n(!_||_.type?new Qi(null,s,p):_),p.abort(),p=null)},i.cancelToken&&i.cancelToken.subscribe(h),i.signal&&(i.signal.aborted?h():i.signal.addEventListener("abort",h)));const v=Qx(i.url);if(v&&Lt.protocols.indexOf(v)===-1){n(new qe("Unsupported protocol "+v+":",qe.ERR_BAD_REQUEST,s));return}p.send(r||null)})},av=(s,e)=>{const{length:t}=s=s?s.filter(Boolean):[];if(e||t){let n=new AbortController,i;const r=function(c){if(!i){i=!0,a();const h=c instanceof Error?c:this.reason;n.abort(h instanceof qe?h:new Qi(h instanceof Error?h.message:h))}};let o=e&&setTimeout(()=>{o=null,r(new qe(`timeout ${e} of ms exceeded`,qe.ETIMEDOUT))},e);const a=()=>{s&&(o&&clearTimeout(o),o=null,s.forEach(c=>{c.unsubscribe?c.unsubscribe(r):c.removeEventListener("abort",r)}),s=null)};s.forEach(c=>c.addEventListener("abort",r));const{signal:l}=n;return l.unsubscribe=()=>ae.asap(a),l}},lv=function*(s,e){let t=s.byteLength;if(t<e){yield s;return}let n=0,i;for(;n<t;)i=n+e,yield s.slice(n,i),n=i},cv=async function*(s,e){for await(const t of hv(s))yield*lv(t,e)},hv=async function*(s){if(s[Symbol.asyncIterator]){yield*s;return}const e=s.getReader();try{for(;;){const{done:t,value:n}=await e.read();if(t)break;yield n}}finally{await e.cancel()}},_h=(s,e,t,n)=>{const i=cv(s,e);let r=0,o,a=l=>{o||(o=!0,n&&n(l))};return new ReadableStream({async pull(l){try{const{done:c,value:h}=await i.next();if(c){a(),l.close();return}let d=h.byteLength;if(t){let g=r+=d;t(g)}l.enqueue(new Uint8Array(h))}catch(c){throw a(c),c}},cancel(l){return a(l),i.return()}},{highWaterMark:2})},yh=64*1024,{isFunction:Br}=ae,dv=(({Request:s,Response:e})=>({Request:s,Response:e}))(ae.global),{ReadableStream:Mh,TextEncoder:bh}=ae.global,wh=(s,...e)=>{try{return!!s(...e)}catch{return!1}},uv=s=>{s=ae.merge.call({skipUndefined:!0},dv,s);const{fetch:e,Request:t,Response:n}=s,i=e?Br(e):typeof fetch=="function",r=Br(t),o=Br(n);if(!i)return!1;const a=i&&Br(Mh),l=i&&(typeof bh=="function"?(m=>f=>m.encode(f))(new bh):async m=>new Uint8Array(await new t(m).arrayBuffer())),c=r&&a&&wh(()=>{let m=!1;const f=new t(Lt.origin,{body:new Mh,method:"POST",get duplex(){return m=!0,"half"}}).headers.has("Content-Type");return m&&!f}),h=o&&a&&wh(()=>ae.isReadableStream(new n("").body)),d={stream:h&&(m=>m.body)};i&&["text","arrayBuffer","blob","formData","stream"].forEach(m=>{!d[m]&&(d[m]=(f,p)=>{let x=f&&f[m];if(x)return x.call(f);throw new qe(`Response type '${m}' is not supported`,qe.ERR_NOT_SUPPORT,p)})});const g=async m=>{if(m==null)return 0;if(ae.isBlob(m))return m.size;if(ae.isSpecCompliantForm(m))return(await new t(Lt.origin,{method:"POST",body:m}).arrayBuffer()).byteLength;if(ae.isArrayBufferView(m)||ae.isArrayBuffer(m))return m.byteLength;if(ae.isURLSearchParams(m)&&(m=m+""),ae.isString(m))return(await l(m)).byteLength},u=async(m,f)=>{const p=ae.toFiniteNumber(m.getContentLength());return p??g(f)};return async m=>{let{url:f,method:p,data:x,signal:v,cancelToken:_,timeout:b,onDownloadProgress:S,onUploadProgress:C,responseType:R,headers:I,withCredentials:E="same-origin",fetchOptions:T}=vh(m),U=e||fetch;R=R?(R+"").toLowerCase():"text";let D=av([v,_&&_.toAbortSignal()],b),O=null;const w=D&&D.unsubscribe&&(()=>{D.unsubscribe()});let V;try{if(C&&c&&p!=="get"&&p!=="head"&&(V=await u(I,x))!==0){let X=new t(f,{method:"POST",body:x,duplex:"half"}),j;if(ae.isFormData(x)&&(j=X.headers.get("content-type"))&&I.setContentType(j),X.body){const[me,ge]=ph(V,kr(mh(C)));x=_h(X.body,yh,me,ge)}}ae.isString(E)||(E=E?"include":"omit");const z=r&&"credentials"in t.prototype,H={...T,signal:D,method:p.toUpperCase(),headers:I.normalize().toJSON(),body:x,duplex:"half",credentials:z?E:void 0};O=r&&new t(f,H);let Y=await(r?U(O,T):U(f,H));const W=h&&(R==="stream"||R==="response");if(h&&(S||W&&w)){const X={};["status","statusText","headers"].forEach(ue=>{X[ue]=Y[ue]});const j=ae.toFiniteNumber(Y.headers.get("content-length")),[me,ge]=S&&ph(j,kr(mh(S),!0))||[];Y=new n(_h(Y.body,yh,me,()=>{ge&&ge(),w&&w()}),X)}R=R||"text";let Q=await d[ae.findKey(d,R)||"text"](Y,m);return!W&&w&&w(),await new Promise((X,j)=>{fh(X,j,{data:Q,headers:Vt.from(Y.headers),status:Y.status,statusText:Y.statusText,config:m,request:O})})}catch(z){throw w&&w(),z&&z.name==="TypeError"&&/Load failed|fetch/i.test(z.message)?Object.assign(new qe("Network Error",qe.ERR_NETWORK,m,O),{cause:z.cause||z}):qe.from(z,z&&z.code,m,O)}}},fv=new Map,Sh=s=>{let e=s&&s.env||{};const{fetch:t,Request:n,Response:i}=e,r=[n,i,t];let o=r.length,a=o,l,c,h=fv;for(;a--;)l=r[a],c=h.get(l),c===void 0&&h.set(l,c=a?new Map:uv(e)),h=c;return c};Sh();const Wa={http:Ux,xhr:ov,fetch:{get:Sh}};ae.forEach(Wa,(s,e)=>{if(s){try{Object.defineProperty(s,"name",{value:e})}catch{}Object.defineProperty(s,"adapterName",{value:e})}});const Eh=s=>`- ${s}`,pv=s=>ae.isFunction(s)||s===null||s===!1;function mv(s,e){s=ae.isArray(s)?s:[s];const{length:t}=s;let n,i;const r={};for(let o=0;o<t;o++){n=s[o];let a;if(i=n,!pv(n)&&(i=Wa[(a=String(n)).toLowerCase()],i===void 0))throw new qe(`Unknown adapter '${a}'`);if(i&&(ae.isFunction(i)||(i=i.get(e))))break;r[a||"#"+o]=i}if(!i){const o=Object.entries(r).map(([l,c])=>`adapter ${l} `+(c===!1?"is not supported by the environment":"is not available in the build"));let a=t?o.length>1?`since :
|
|
4937
4937
|
`+o.map(Eh).join(`
|
|
4938
4938
|
`):" "+Eh(o[0]):"as no adapter specified";throw new qe("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return i}const Ch={getAdapter:mv,adapters:Wa};function Ha(s){if(s.cancelToken&&s.cancelToken.throwIfRequested(),s.signal&&s.signal.aborted)throw new Qi(null,s)}function Ah(s){return Ha(s),s.headers=Vt.from(s.headers),s.data=Ga.call(s,s.transformRequest),["post","put","patch"].indexOf(s.method)!==-1&&s.headers.setContentType("application/x-www-form-urlencoded",!1),Ch.getAdapter(s.adapter||ws.adapter,s)(s).then(function(n){return Ha(s),n.data=Ga.call(s,s.transformResponse,n),n.headers=Vt.from(n.headers),n},function(n){return uh(n)||(Ha(s),n&&n.response&&(n.response.data=Ga.call(s,s.transformResponse,n.response),n.response.headers=Vt.from(n.response.headers))),Promise.reject(n)})}const Th="1.13.2",zr={};["object","boolean","number","function","string","symbol"].forEach((s,e)=>{zr[s]=function(n){return typeof n===s||"a"+(e<1?"n ":" ")+s}});const Ph={};zr.transitional=function(e,t,n){function i(r,o){return"[Axios v"+Th+"] Transitional option '"+r+"'"+o+(n?". "+n:"")}return(r,o,a)=>{if(e===!1)throw new qe(i(o," has been removed"+(t?" in "+t:"")),qe.ERR_DEPRECATED);return t&&!Ph[o]&&(Ph[o]=!0,console.warn(i(o," has been deprecated since v"+t+" and will be removed in the near future"))),e?e(r,o,a):!0}},zr.spelling=function(e){return(t,n)=>(console.warn(`${n} is likely a misspelling of ${e}`),!0)};function gv(s,e,t){if(typeof s!="object")throw new qe("options must be an object",qe.ERR_BAD_OPTION_VALUE);const n=Object.keys(s);let i=n.length;for(;i-- >0;){const r=n[i],o=e[r];if(o){const a=s[r],l=a===void 0||o(a,r,s);if(l!==!0)throw new qe("option "+r+" must be "+l,qe.ERR_BAD_OPTION_VALUE);continue}if(t!==!0)throw new qe("Unknown option "+r,qe.ERR_BAD_OPTION)}}const Vr={assertOptions:gv,validators:zr},gn=Vr.validators;let yi=class{constructor(e){this.defaults=e||{},this.interceptors={request:new lh,response:new lh}}async request(e,t){try{return await this._request(e,t)}catch(n){if(n instanceof Error){let i={};Error.captureStackTrace?Error.captureStackTrace(i):i=new Error;const r=i.stack?i.stack.replace(/^.+\n/,""):"";try{n.stack?r&&!String(n.stack).endsWith(r.replace(/^.+\n.+\n/,""))&&(n.stack+=`
|
|
4939
4939
|
`+r):n.stack=r}catch{}}throw n}}_request(e,t){typeof e=="string"?(t=t||{},t.url=e):t=e||{},t=_i(this.defaults,t);const{transitional:n,paramsSerializer:i,headers:r}=t;n!==void 0&&Vr.assertOptions(n,{silentJSONParsing:gn.transitional(gn.boolean),forcedJSONParsing:gn.transitional(gn.boolean),clarifyTimeoutError:gn.transitional(gn.boolean)},!1),i!=null&&(ae.isFunction(i)?t.paramsSerializer={serialize:i}:Vr.assertOptions(i,{encode:gn.function,serialize:gn.function},!0)),t.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),Vr.assertOptions(t,{baseUrl:gn.spelling("baseURL"),withXsrfToken:gn.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let o=r&&ae.merge(r.common,r[t.method]);r&&ae.forEach(["delete","get","head","post","put","patch","common"],m=>{delete r[m]}),t.headers=Vt.concat(o,r);const a=[];let l=!0;this.interceptors.request.forEach(function(f){typeof f.runWhen=="function"&&f.runWhen(t)===!1||(l=l&&f.synchronous,a.unshift(f.fulfilled,f.rejected))});const c=[];this.interceptors.response.forEach(function(f){c.push(f.fulfilled,f.rejected)});let h,d=0,g;if(!l){const m=[Ah.bind(this),void 0];for(m.unshift(...a),m.push(...c),g=m.length,h=Promise.resolve(t);d<g;)h=h.then(m[d++],m[d++]);return h}g=a.length;let u=t;for(;d<g;){const m=a[d++],f=a[d++];try{u=m(u)}catch(p){f.call(this,p);break}}try{h=Ah.call(this,u)}catch(m){return Promise.reject(m)}for(d=0,g=c.length;d<g;)h=h.then(c[d++],c[d++]);return h}getUri(e){e=_i(this.defaults,e);const t=gh(e.baseURL,e.url,e.allowAbsoluteUrls);return ah(t,e.params,e.paramsSerializer)}};ae.forEach(["delete","get","head","options"],function(e){yi.prototype[e]=function(t,n){return this.request(_i(n||{},{method:e,url:t,data:(n||{}).data}))}}),ae.forEach(["post","put","patch"],function(e){function t(n){return function(r,o,a){return this.request(_i(a||{},{method:e,headers:n?{"Content-Type":"multipart/form-data"}:{},url:r,data:o}))}}yi.prototype[e]=t(),yi.prototype[e+"Form"]=t(!0)});let xv=class Id{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(r){t=r});const n=this;this.promise.then(i=>{if(!n._listeners)return;let r=n._listeners.length;for(;r-- >0;)n._listeners[r](i);n._listeners=null}),this.promise.then=i=>{let r;const o=new Promise(a=>{n.subscribe(a),r=a}).then(i);return o.cancel=function(){n.unsubscribe(r)},o},e(function(r,o,a){n.reason||(n.reason=new Qi(r,o,a),t(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);t!==-1&&this._listeners.splice(t,1)}toAbortSignal(){const e=new AbortController,t=n=>{e.abort(n)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let e;return{token:new Id(function(i){e=i}),cancel:e}}};function vv(s){return function(t){return s.apply(null,t)}}function _v(s){return ae.isObject(s)&&s.isAxiosError===!0}const Xa={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(Xa).forEach(([s,e])=>{Xa[e]=s});function Dh(s){const e=new yi(s),t=jc(yi.prototype.request,e);return ae.extend(t,yi.prototype,e,{allOwnKeys:!0}),ae.extend(t,e,null,{allOwnKeys:!0}),t.create=function(i){return Dh(_i(s,i))},t}const gt=Dh(ws);gt.Axios=yi,gt.CanceledError=Qi,gt.CancelToken=xv,gt.isCancel=uh,gt.VERSION=Th,gt.toFormData=Fr,gt.AxiosError=qe,gt.Cancel=gt.CanceledError,gt.all=function(e){return Promise.all(e)},gt.spread=vv,gt.isAxiosError=_v,gt.mergeConfig=_i,gt.AxiosHeaders=Vt,gt.formToJSON=s=>hh(ae.isHTMLForm(s)?new FormData(s):s),gt.getAdapter=Ch.getAdapter,gt.HttpStatusCode=Xa,gt.default=gt;const{Axios:rw,AxiosError:ow,CanceledError:aw,isCancel:lw,CancelToken:cw,VERSION:hw,all:dw,Cancel:uw,isAxiosError:fw,spread:pw,toFormData:mw,AxiosHeaders:gw,HttpStatusCode:xw,formToJSON:vw,getAdapter:_w,mergeConfig:yw}=gt;function Es(s,e,t){gt({method:"get",responseType:"blob",url:s}).then(i=>{let r=new window.File([i.data],"semantics",{type:"zip"});Xc.loadAsync(r).then(o=>{for(let a in o.files){const l=o.file(o.files[a].name);l&&l.async("blob").then(c=>{n(c,"utf-8",function(h,d){e(d)})}).catch(()=>{t()})}}).catch(()=>{t()})}).catch(i=>{t()});function n(i,r,o){var a=new FileReader,l=new Blob([i]);a.onload=function(c){o(null,c.target.result)},a.onerror=function(c){o(c.error,null)},a.readAsText(l,r)}}const ja=new WeakMap;class yv extends M.Loader{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,n,i){const r=new M.FileLoader(this.manager);r.setPath(this.path),r.setResponseType("arraybuffer"),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials),r.load(e,o=>{this.parse(o,t,i)},n,i)}parse(e,t,n=()=>{}){this.decodeDracoFile(e,t,null,null,M.SRGBColorSpace,n).catch(n)}decodeDracoFile(e,t,n,i,r=M.LinearSRGBColorSpace,o=()=>{}){const a={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:i||this.defaultAttributeTypes,useUniqueIDs:!!n,vertexColorSpace:r};return this.decodeGeometry(e,a).then(t).catch(o)}decodeGeometry(e,t){const n=JSON.stringify(t);if(ja.has(e)){const l=ja.get(e);if(l.key===n)return l.promise;if(e.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let i;const r=this.workerNextTaskID++,o=e.byteLength,a=this._getWorker(r,o).then(l=>(i=l,new Promise((c,h)=>{i._callbacks[r]={resolve:c,reject:h},i.postMessage({type:"decode",id:r,taskConfig:t,buffer:e},[e])}))).then(l=>this._createGeometry(l.geometry));return a.catch(()=>!0).then(()=>{i&&r&&this._releaseTask(i,r)}),ja.set(e,{key:n,promise:a}),a}_createGeometry(e){const t=new M.BufferGeometry;e.index&&t.setIndex(new M.BufferAttribute(e.index.array,1));for(let n=0;n<e.attributes.length;n++){const{name:i,array:r,itemSize:o,stride:a,vertexColorSpace:l}=e.attributes[n];let c;if(o===a)c=new M.BufferAttribute(r,o);else{const h=new M.InterleavedBuffer(r,a);c=new M.InterleavedBufferAttribute(h,o,0)}i==="color"&&(this._assignVertexColorSpace(c,l),c.normalized=!(r instanceof Float32Array)),t.setAttribute(i,c)}return t}_assignVertexColorSpace(e,t){if(t!==M.SRGBColorSpace)return;const n=new M.Color;for(let i=0,r=e.count;i<r;i++)n.fromBufferAttribute(e,i),M.ColorManagement.colorSpaceToWorking(n,M.SRGBColorSpace),e.setXYZ(i,n.r,n.g,n.b)}_loadLibrary(e,t){const n=new M.FileLoader(this.manager);return n.setPath(this.decoderPath),n.setResponseType(t),n.setWithCredentials(this.withCredentials),new Promise((i,r)=>{n.load(e,i,void 0,r)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(n=>{const i=n[0];e||(this.decoderConfig.wasmBinary=n[1]);const r=Mv.toString(),o=["/* draco decoder */",i,"","/* worker */",r.substring(r.indexOf("{")+1,r.lastIndexOf("}"))].join(`
|
|
4940
|
-
`);this.workerSourceURL=URL.createObjectURL(new Blob([o]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){const i=new Worker(this.workerSourceURL);i._callbacks={},i._taskCosts={},i._taskLoad=0,i.postMessage({type:"init",decoderConfig:this.decoderConfig}),i.onmessage=function(r){const o=r.data;switch(o.type){case"decode":i._callbacks[o.id].resolve(o);break;case"error":i._callbacks[o.id].reject(o);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+o.type+'"')}},this.workerPool.push(i)}else this.workerPool.sort(function(i,r){return i._taskLoad>r._taskLoad?-1:1});const n=this.workerPool[this.workerPool.length-1];return n._taskCosts[e]=t,n._taskLoad+=t,n})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}}function Mv(){let s,e;onmessage=function(o){const a=o.data;switch(a.type){case"init":s=a.decoderConfig,e=new Promise(function(h){s.onModuleLoaded=function(d){h({draco:d})},DracoDecoderModule(s)});break;case"decode":const l=a.buffer,c=a.taskConfig;e.then(h=>{const d=h.draco,g=new d.Decoder;try{const u=t(d,g,new Int8Array(l),c),m=u.attributes.map(f=>f.array.buffer);u.index&&m.push(u.index.array.buffer),self.postMessage({type:"decode",id:a.id,geometry:u},m)}catch(u){console.error(u),self.postMessage({type:"error",id:a.id,error:u.message})}finally{d.destroy(g)}});break}};function t(o,a,l,c){const h=c.attributeIDs,d=c.attributeTypes;let g,u;const m=a.GetEncodedGeometryType(l);if(m===o.TRIANGULAR_MESH)g=new o.Mesh,u=a.DecodeArrayToMesh(l,l.byteLength,g);else if(m===o.POINT_CLOUD)g=new o.PointCloud,u=a.DecodeArrayToPointCloud(l,l.byteLength,g);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!u.ok()||g.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+u.error_msg());const f={index:null,attributes:[]};for(const p in h){const x=self[d[p]];let v,_;if(c.useUniqueIDs)_=h[p],v=a.GetAttributeByUniqueId(g,_);else{if(_=a.GetAttributeId(g,o[h[p]]),_===-1)continue;v=a.GetAttribute(g,_)}const b=i(o,a,g,p,x,v);p==="color"&&(b.vertexColorSpace=c.vertexColorSpace),f.attributes.push(b)}return m===o.TRIANGULAR_MESH&&(f.index=n(o,a,g)),o.destroy(g),f}function n(o,a,l){const h=l.num_faces()*3,d=h*4,g=o._malloc(d);a.GetTrianglesUInt32Array(l,d,g);const u=new Uint32Array(o.HEAPF32.buffer,g,h).slice();return o._free(g),{array:u,itemSize:1}}function i(o,a,l,c,h,d){const g=l.num_points(),u=d.num_components(),m=r(o,h),f=u*h.BYTES_PER_ELEMENT,p=Math.ceil(f/4)*4,x=p/h.BYTES_PER_ELEMENT,v=g*f,_=g*p,b=o._malloc(v);a.GetAttributeDataArrayForAllPoints(l,d,m,v,b);const S=new h(o.HEAPF32.buffer,b,v/h.BYTES_PER_ELEMENT);let C;if(f===p)C=S.slice();else{C=new h(_/h.BYTES_PER_ELEMENT);let R=0;for(let I=0,E=S.length;I<E;I++){for(let T=0;T<u;T++)C[R+T]=S[I*u+T];R+=x}}return o._free(b),{name:c,count:g,itemSize:u,array:C,stride:x}}function r(o,a){switch(a){case Float32Array:return o.DT_FLOAT32;case Int8Array:return o.DT_INT8;case Int16Array:return o.DT_INT16;case Int32Array:return o.DT_INT32;case Uint8Array:return o.DT_UINT8;case Uint16Array:return o.DT_UINT16;case Uint32Array:return o.DT_UINT32}}}function bv(s,e,t,n){let i=0,r=0,o=0,a=s.models.find(u=>u.url==t),l=e.circularMeps,c=e.rectMeps?.filter(u=>u.type==="风管"),h=e.rectMeps?.filter(u=>u.type==="桥架"),d=e.ellipseMeps,g=s.scene;if(new y.MeshBasicMaterial,new y.BufferGeometry,l&&l.length){let u=[],m=0;for(let f of l)f.color=f.color.split(",").map(p=>parseInt(p)/255),f.color=new y.Color(f.color[0],f.color[1],f.color[2]),f.position={x:f.startPoint.X*.3048+i,y:f.startPoint.Z*.3048+r,z:-f.startPoint.Y*.3048+o},f.rotation={x:0,y:0,z:0},f.indexes=[[s.scene.children.length,m++,0,0]],a.nodesMap.set(Number(f.id),f),u.push(f);Gr("Circle",g,u,t)}if(c&&c.length){let u=[],m=0;for(let f of c)f.color=f.color.split(",").map(p=>parseInt(p)/255),f.color=new y.Color(f.color[0],f.color[1],f.color[2]),f.position={x:f.startPoint.X*.3048+i,y:f.startPoint.Z*.3048+r,z:-f.startPoint.Y*.3048+o},f.rotation={x:0,y:0,z:0},f.indexes=[[s.scene.children.length,m++,0,0]],a.nodesMap.set(Number(f.id),f),u.push(f);Gr("Rect",g,u,t)}if(d&&d.length){let u=[],m=0;for(let f of d)f.color=f.color.split(",").map(p=>parseInt(p)/255),f.color=new y.Color(f.color[0],f.color[1],f.color[2]),f.position={x:f.startPoint.X*.3048+i,y:f.startPoint.Z*.3048+r,z:-f.startPoint.Y*.3048+o},f.rotation={x:0,y:0,z:0},f.indexes=[[s.scene.children.length,m++,0,0]],a.nodesMap.set(Number(f.id),f),u.push(f);Gr("Ellipse",g,u,t)}if(h&&h.length){let u=[],m=0;for(let f of h)f.color=f.color.split(",").map(p=>parseInt(p)/255),f.color=new y.Color(f.color[0],f.color[1],f.color[2]),f.position={x:f.startPoint.X*.3048+i,y:f.startPoint.Z*.3048+r,z:-f.startPoint.Y*.3048+o},f.rotation={x:0,y:0,z:0},f.indexes=[[s.scene.children.length,m++,0,0]],a.nodesMap.set(Number(f.id),f),u.push(f);Gr("Bridge",g,u,t)}}function Gr(s,e,t,n,i){let r,o,a={width:1,height:1,length:1,diameter:1,color:new y.Color,position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0}};switch(s){case"Rect":o=Wr("Rect",a);break;case"Bridge":o=Wr("Bridge",a);break;case"Circle":o=Wr("Circle",a);break;case"Ellipse":o=Wr("Ellipse",a);break}o&&(r=new y.InstancedMesh(o.geometry,o.material,t.length),r.url=n,e.add(r),r.index=e.children.length-1);let l=[],c=[];for(var h=0;h<t.length;h++){let u=t[h],m=new y.Vector3(u.startPoint.X,0,-u.startPoint.Y),f=new y.Vector3(u.endPoint.X,0,-u.endPoint.Y),p=new y.Vector3(u.startPoint.X,u.startPoint.Z,-u.startPoint.Y),x=new y.Vector3(u.endPoint.X,u.endPoint.Z,-u.endPoint.Y),v=0,_=0,b=0;if(Math.abs(f.clone().sub(m.clone()).z)<.01&&Math.abs(f.clone().sub(m.clone()).x)<.01){if(v=(u.startPoint.Z>u.endPoint.Z?1:-1)*Math.PI*.5,u.base_x!=null){var d=new y.Vector3(u.base_x.X,0,-u.base_x.Y);_=(d.clone().cross(new y.Vector3(0,0,1)).y<=0?1:-1)*d.angleTo(new y.Vector3(0,0,1))+Math.PI*.5}}else _=(f.clone().sub(m.clone()).cross(new y.Vector3(0,0,1)).y>0?-1:1)*f.clone().sub(m.clone()).angleTo(new y.Vector3(0,0,1)),v=(u.startPoint.Z>u.endPoint.Z?1:-1)*f.clone().sub(m.clone()).angleTo(x.clone().sub(p.clone()));let S=new y.Matrix4;const C=new y.Euler(v,_,b,"YXZ");let R=S.clone().makeRotationFromEuler(C),I,E;s==="Circle"?(I=u.diameter,E=u.diameter):(I=u.width,E=u.height);let T=S.clone().makeScale(I,E,u.length);S.multiplyMatrices(R,T),S.setPosition(u.position.x,u.position.y,u.position.z),r.setMatrixAt(h,S.clone()),r.setColorAt(h,u.color),r.geometry.computeBoundingBox();let U=r.geometry.boundingBox.min.clone().applyMatrix4(S.clone()),D=r.geometry.boundingBox.max.clone().applyMatrix4(S.clone()),O=new y.Vector3(Math.min(U.x,D.x),Math.min(U.y,D.y),Math.min(U.z,D.z)),w=new y.Vector3(Math.max(U.x,D.x),Math.max(U.y,D.y),Math.max(U.z,D.z)),V=O.clone().add(w.clone()).multiplyScalar(.5),z={name:u.name,min:O,max:w,center:V,dbid:h,materialName:o.material.name},H=null,Y=null;s==="Circle"&&(H={x:u.startPoint.X*.3048,y:u.startPoint.Z*.3048,z:-u.startPoint.Y*.3048},Y={x:u.endPoint.X*.3048,y:u.endPoint.Z*.3048,z:-u.endPoint.Y*.3048},z.minC=H,z.maxC=Y),r.ids||(r.ids=[]),r.matrixs||(r.matrixs=[]),r.matrixs.push(S.clone()),c.push(S.clone()),r.ids.push(Number(u.id)),l.push(z)}r.castShadow=!0,r.ElementInfos=l,r.name="rootModel",r.TypeName="InstancedMesh-Pipe",r.PipeType=s,r.MeshId=null,r.realMaterial=r.material.clone(),r.originalMaterial=r.material.clone(),r.matrixsClone=c;let g=[];g={geometry:r.geometry,matrix:r.matrix,position:r.position,rotation:r.rotation},r.meshs=g,r.instanceMatrix&&r.instanceMatrix.array&&(r.cloneInstanceMatrix=Array.from(r.instanceMatrix.array))}function Wr(s,e,t){let n=new y.Shape;switch(e.width=e.width*.3048,e.height=e.height*.3048,e.diameter=e.diameter*.3048,s){case"Rect":n.moveTo(-e.width/2,-e.height/2),n.lineTo(-e.width/2,e.height/2),n.lineTo(e.width/2,e.height/2),n.lineTo(e.width/2,-e.height/2),n.lineTo(-e.width/2,-e.height/2);break;case"Ellipse":n.moveTo(-e.width/2,-e.height/2),n.lineTo(-e.width/2,e.height/2),n.lineTo(e.width/2,e.height/2),n.lineTo(e.width/2,-e.height/2),n.lineTo(-e.width/2,-e.height/2);break;case"Bridge":n.moveTo(-e.width/2,-e.height/2),n.lineTo(-e.width/2,e.height/2),n.lineTo(-e.width/2+.01,e.height/2),n.lineTo(-e.width/2+.01,-e.height/2+.01),n.lineTo(e.width/2-.01,-e.height/2+.01),n.lineTo(e.width/2-.01,e.height/2),n.lineTo(e.width/2,e.height/2),n.lineTo(e.width/2,-e.height/2),n.lineTo(-e.width/2,-e.height/2);break;case"Circle":n.moveTo(0,0),n.absarc(0,0,e.diameter*.5,0,Math.PI*2,!1);break}const i={depth:e.length*.3048,bevelEnabled:!1};return r(n,i,e.color,e.position,e.rotation);function r(o,a,l,c,h){let d=new y.ExtrudeGeometry(o,a),g=new y.MeshStandardMaterial({color:l,side:y.DoubleSide}),u=new y.Mesh(d,g);return u.position.set(c.x,c.y,c.z),u.rotation._order="YXZ",u.rotation.set(h.x,h.y,h.z),u}}function Mi(s,e=!1){const t=s[0].index!==null,n=new Set(Object.keys(s[0].attributes)),i=new Set(Object.keys(s[0].morphAttributes)),r={},o={},a=s[0].morphTargetsRelative,l=new M.BufferGeometry;let c=0;for(let h=0;h<s.length;++h){const d=s[h];let g=0;if(t!==(d.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const u in d.attributes){if(!n.has(u))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+'. All geometries must have compatible attributes; make sure "'+u+'" attribute exists among all geometries, or in none of them.'),null;r[u]===void 0&&(r[u]=[]),r[u].push(d.attributes[u]),g++}if(g!==n.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". Make sure all geometries have the same number of attributes."),null;if(a!==d.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const u in d.morphAttributes){if(!i.has(u))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". .morphAttributes must be consistent throughout all geometries."),null;o[u]===void 0&&(o[u]=[]),o[u].push(d.morphAttributes[u])}if(e){let u;if(t)u=d.index.count;else if(d.attributes.position!==void 0)u=d.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". The geometry must have either an index or a position attribute"),null;l.addGroup(c,u,h),c+=u}}if(t){let h=0;const d=[];for(let g=0;g<s.length;++g){const u=s[g].index;for(let m=0;m<u.count;++m)d.push(u.getX(m)+h);h+=s[g].attributes.position.count}l.setIndex(d)}for(const h in r){const d=Rh(r[h]);if(!d)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+h+" attribute."),null;l.setAttribute(h,d)}for(const h in o){const d=o[h][0].length;if(d===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[h]=[];for(let g=0;g<d;++g){const u=[];for(let f=0;f<o[h].length;++f)u.push(o[h][f][g]);const m=Rh(u);if(!m)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+h+" morphAttribute."),null;l.morphAttributes[h].push(m)}}return l}function Rh(s){let e,t,n,i=-1,r=0;for(let c=0;c<s.length;++c){const h=s[c];if(e===void 0&&(e=h.array.constructor),e!==h.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(t===void 0&&(t=h.itemSize),t!==h.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(n===void 0&&(n=h.normalized),n!==h.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(i===-1&&(i=h.gpuType),i!==h.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;r+=h.count*t}const o=new e(r),a=new M.BufferAttribute(o,t,n);let l=0;for(let c=0;c<s.length;++c){const h=s[c];if(h.isInterleavedBufferAttribute){const d=l/t;for(let g=0,u=h.count;g<u;g++)for(let m=0;m<t;m++){const f=h.getComponent(g,m);a.setComponent(g+d,m,f)}}else o.set(h.array,l);l+=h.count*t}return i!==void 0&&(a.gpuType=i),a}function Lh(s,e){if(e===M.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),s;if(e===M.TriangleFanDrawMode||e===M.TriangleStripDrawMode){let t=s.getIndex();if(t===null){const o=[],a=s.getAttribute("position");if(a!==void 0){for(let l=0;l<a.count;l++)o.push(l);s.setIndex(o),t=s.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),s}const n=t.count-2,i=[];if(e===M.TriangleFanDrawMode)for(let o=1;o<=n;o++)i.push(t.getX(0)),i.push(t.getX(o)),i.push(t.getX(o+1));else for(let o=0;o<n;o++)o%2===0?(i.push(t.getX(o)),i.push(t.getX(o+1)),i.push(t.getX(o+2))):(i.push(t.getX(o+2)),i.push(t.getX(o+1)),i.push(t.getX(o)));i.length/3!==n&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const r=s.clone();return r.setIndex(i),r.clearGroups(),r}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),s}function wv(s){const e=new Map,t=new Map,n=s.clone();return Ih(s,n,function(i,r){e.set(r,i),t.set(i,r)}),n.traverse(function(i){if(!i.isSkinnedMesh)return;const r=i,o=e.get(i),a=o.skeleton.bones;r.skeleton=o.skeleton.clone(),r.bindMatrix.copy(o.bindMatrix),r.skeleton.bones=a.map(function(l){return t.get(l)}),r.bind(r.skeleton,r.bindMatrix)}),n}function Ih(s,e,t){t(s,e);for(let n=0;n<s.children.length;n++)Ih(s.children[n],e.children[n],t)}class Sv extends M.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new Pv(t)}),this.register(function(t){return new Dv(t)}),this.register(function(t){return new Bv(t)}),this.register(function(t){return new zv(t)}),this.register(function(t){return new Vv(t)}),this.register(function(t){return new Lv(t)}),this.register(function(t){return new Iv(t)}),this.register(function(t){return new Nv(t)}),this.register(function(t){return new Uv(t)}),this.register(function(t){return new Tv(t)}),this.register(function(t){return new Fv(t)}),this.register(function(t){return new Rv(t)}),this.register(function(t){return new kv(t)}),this.register(function(t){return new Ov(t)}),this.register(function(t){return new Cv(t)}),this.register(function(t){return new Nh(t,$e.EXT_MESHOPT_COMPRESSION)}),this.register(function(t){return new Nh(t,$e.KHR_MESHOPT_COMPRESSION)}),this.register(function(t){return new Gv(t)})}load(e,t,n,i){const r=this;let o;if(this.resourcePath!=="")o=this.resourcePath;else if(this.path!==""){const c=M.LoaderUtils.extractUrlBase(e);o=M.LoaderUtils.resolveURL(c,this.path)}else o=M.LoaderUtils.extractUrlBase(e);this.manager.itemStart(e);const a=function(c){i?i(c):console.error(c),r.manager.itemError(e),r.manager.itemEnd(e)},l=new M.FileLoader(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(this.withCredentials),l.load(e,function(c){try{r.parse(c,o,function(h){t(h),r.manager.itemEnd(e)},a)}catch(h){a(h)}},n,a)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,i){let r;const o={},a={},l=new TextDecoder;if(typeof e=="string")r=JSON.parse(e);else if(e instanceof ArrayBuffer)if(l.decode(new Uint8Array(e,0,4))===Uh){try{o[$e.KHR_BINARY_GLTF]=new Wv(e)}catch(d){i&&i(d);return}r=JSON.parse(o[$e.KHR_BINARY_GLTF].content)}else r=JSON.parse(l.decode(e));else r=e;if(r.asset===void 0||r.asset.version[0]<2){i&&i(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const c=new n_(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let h=0;h<this.pluginCallbacks.length;h++){const d=this.pluginCallbacks[h](c);d.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[d.name]=d,o[d.name]=!0}if(r.extensionsUsed)for(let h=0;h<r.extensionsUsed.length;++h){const d=r.extensionsUsed[h],g=r.extensionsRequired||[];switch(d){case $e.KHR_MATERIALS_UNLIT:o[d]=new Av;break;case $e.KHR_DRACO_MESH_COMPRESSION:o[d]=new Hv(r,this.dracoLoader);break;case $e.KHR_TEXTURE_TRANSFORM:o[d]=new Xv;break;case $e.KHR_MESH_QUANTIZATION:o[d]=new jv;break;default:g.indexOf(d)>=0&&a[d]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+d+'".')}}c.setExtensions(o),c.setPlugins(a),c.parse(n,i)}parseAsync(e,t){const n=this;return new Promise(function(i,r){n.parse(e,t,i,r)})}}function Ev(){let s={};return{get:function(e){return s[e]},add:function(e,t){s[e]=t},remove:function(e){delete s[e]},removeAll:function(){s={}}}}function bt(s,e,t){const n=s.json.materials[e];return n.extensions&&n.extensions[t]?n.extensions[t]:null}const $e={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",KHR_MESHOPT_COMPRESSION:"KHR_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class Cv{constructor(e){this.parser=e,this.name=$e.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n<i;n++){const r=t[n];r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){const t=this.parser,n="light:"+e;let i=t.cache.get(n);if(i)return i;const r=t.json,l=((r.extensions&&r.extensions[this.name]||{}).lights||[])[e];let c;const h=new M.Color(16777215);l.color!==void 0&&h.setRGB(l.color[0],l.color[1],l.color[2],M.LinearSRGBColorSpace);const d=l.range!==void 0?l.range:0;switch(l.type){case"directional":c=new M.DirectionalLight(h),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new M.PointLight(h),c.distance=d;break;case"spot":c=new M.SpotLight(h),c.distance=d,l.spot=l.spot||{},l.spot.innerConeAngle=l.spot.innerConeAngle!==void 0?l.spot.innerConeAngle:0,l.spot.outerConeAngle=l.spot.outerConeAngle!==void 0?l.spot.outerConeAngle:Math.PI/4,c.angle=l.spot.outerConeAngle,c.penumbra=1-l.spot.innerConeAngle/l.spot.outerConeAngle,c.target.position.set(0,0,-1),c.add(c.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+l.type)}return c.position.set(0,0,0),xn(c,l),l.intensity!==void 0&&(c.intensity=l.intensity),c.name=t.createUniqueName(l.name||"light_"+e),i=Promise.resolve(c),t.cache.add(n,i),i}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,n=this.parser,r=n.json.nodes[e],a=(r.extensions&&r.extensions[this.name]||{}).light;return a===void 0?null:this._loadLight(a).then(function(l){return n._getNodeRef(t.cache,a,l)})}}class Av{constructor(){this.name=$e.KHR_MATERIALS_UNLIT}getMaterialType(){return M.MeshBasicMaterial}extendParams(e,t,n){const i=[];e.color=new M.Color(1,1,1),e.opacity=1;const r=t.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){const o=r.baseColorFactor;e.color.setRGB(o[0],o[1],o[2],M.LinearSRGBColorSpace),e.opacity=o[3]}r.baseColorTexture!==void 0&&i.push(n.assignTexture(e,"map",r.baseColorTexture,M.SRGBColorSpace))}return Promise.all(i)}}class Tv{constructor(e){this.parser=e,this.name=$e.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const n=bt(this.parser,e,this.name);return n===null||n.emissiveStrength!==void 0&&(t.emissiveIntensity=n.emissiveStrength),Promise.resolve()}}class Pv{constructor(e){this.parser=e,this.name=$e.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){return bt(this.parser,e,this.name)!==null?M.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=bt(this.parser,e,this.name);if(n===null)return Promise.resolve();const i=[];if(n.clearcoatFactor!==void 0&&(t.clearcoat=n.clearcoatFactor),n.clearcoatTexture!==void 0&&i.push(this.parser.assignTexture(t,"clearcoatMap",n.clearcoatTexture)),n.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=n.clearcoatRoughnessFactor),n.clearcoatRoughnessTexture!==void 0&&i.push(this.parser.assignTexture(t,"clearcoatRoughnessMap",n.clearcoatRoughnessTexture)),n.clearcoatNormalTexture!==void 0&&(i.push(this.parser.assignTexture(t,"clearcoatNormalMap",n.clearcoatNormalTexture)),n.clearcoatNormalTexture.scale!==void 0)){const r=n.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new M.Vector2(r,r)}return Promise.all(i)}}class Dv{constructor(e){this.parser=e,this.name=$e.KHR_MATERIALS_DISPERSION}getMaterialType(e){return bt(this.parser,e,this.name)!==null?M.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=bt(this.parser,e,this.name);return n===null||(t.dispersion=n.dispersion!==void 0?n.dispersion:0),Promise.resolve()}}class Rv{constructor(e){this.parser=e,this.name=$e.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){return bt(this.parser,e,this.name)!==null?M.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=bt(this.parser,e,this.name);if(n===null)return Promise.resolve();const i=[];return n.iridescenceFactor!==void 0&&(t.iridescence=n.iridescenceFactor),n.iridescenceTexture!==void 0&&i.push(this.parser.assignTexture(t,"iridescenceMap",n.iridescenceTexture)),n.iridescenceIor!==void 0&&(t.iridescenceIOR=n.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),n.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=n.iridescenceThicknessMinimum),n.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=n.iridescenceThicknessMaximum),n.iridescenceThicknessTexture!==void 0&&i.push(this.parser.assignTexture(t,"iridescenceThicknessMap",n.iridescenceThicknessTexture)),Promise.all(i)}}class Lv{constructor(e){this.parser=e,this.name=$e.KHR_MATERIALS_SHEEN}getMaterialType(e){return bt(this.parser,e,this.name)!==null?M.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=bt(this.parser,e,this.name);if(n===null)return Promise.resolve();const i=[];if(t.sheenColor=new M.Color(0,0,0),t.sheenRoughness=0,t.sheen=1,n.sheenColorFactor!==void 0){const r=n.sheenColorFactor;t.sheenColor.setRGB(r[0],r[1],r[2],M.LinearSRGBColorSpace)}return n.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=n.sheenRoughnessFactor),n.sheenColorTexture!==void 0&&i.push(this.parser.assignTexture(t,"sheenColorMap",n.sheenColorTexture,M.SRGBColorSpace)),n.sheenRoughnessTexture!==void 0&&i.push(this.parser.assignTexture(t,"sheenRoughnessMap",n.sheenRoughnessTexture)),Promise.all(i)}}class Iv{constructor(e){this.parser=e,this.name=$e.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){return bt(this.parser,e,this.name)!==null?M.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=bt(this.parser,e,this.name);if(n===null)return Promise.resolve();const i=[];return n.transmissionFactor!==void 0&&(t.transmission=n.transmissionFactor),n.transmissionTexture!==void 0&&i.push(this.parser.assignTexture(t,"transmissionMap",n.transmissionTexture)),Promise.all(i)}}class Nv{constructor(e){this.parser=e,this.name=$e.KHR_MATERIALS_VOLUME}getMaterialType(e){return bt(this.parser,e,this.name)!==null?M.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=bt(this.parser,e,this.name);if(n===null)return Promise.resolve();const i=[];t.thickness=n.thicknessFactor!==void 0?n.thicknessFactor:0,n.thicknessTexture!==void 0&&i.push(this.parser.assignTexture(t,"thicknessMap",n.thicknessTexture)),t.attenuationDistance=n.attenuationDistance||1/0;const r=n.attenuationColor||[1,1,1];return t.attenuationColor=new M.Color().setRGB(r[0],r[1],r[2],M.LinearSRGBColorSpace),Promise.all(i)}}class Uv{constructor(e){this.parser=e,this.name=$e.KHR_MATERIALS_IOR}getMaterialType(e){return bt(this.parser,e,this.name)!==null?M.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=bt(this.parser,e,this.name);return n===null||(t.ior=n.ior!==void 0?n.ior:1.5),Promise.resolve()}}class Fv{constructor(e){this.parser=e,this.name=$e.KHR_MATERIALS_SPECULAR}getMaterialType(e){return bt(this.parser,e,this.name)!==null?M.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=bt(this.parser,e,this.name);if(n===null)return Promise.resolve();const i=[];t.specularIntensity=n.specularFactor!==void 0?n.specularFactor:1,n.specularTexture!==void 0&&i.push(this.parser.assignTexture(t,"specularIntensityMap",n.specularTexture));const r=n.specularColorFactor||[1,1,1];return t.specularColor=new M.Color().setRGB(r[0],r[1],r[2],M.LinearSRGBColorSpace),n.specularColorTexture!==void 0&&i.push(this.parser.assignTexture(t,"specularColorMap",n.specularColorTexture,M.SRGBColorSpace)),Promise.all(i)}}class Ov{constructor(e){this.parser=e,this.name=$e.EXT_MATERIALS_BUMP}getMaterialType(e){return bt(this.parser,e,this.name)!==null?M.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=bt(this.parser,e,this.name);if(n===null)return Promise.resolve();const i=[];return t.bumpScale=n.bumpFactor!==void 0?n.bumpFactor:1,n.bumpTexture!==void 0&&i.push(this.parser.assignTexture(t,"bumpMap",n.bumpTexture)),Promise.all(i)}}class kv{constructor(e){this.parser=e,this.name=$e.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){return bt(this.parser,e,this.name)!==null?M.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=bt(this.parser,e,this.name);if(n===null)return Promise.resolve();const i=[];return n.anisotropyStrength!==void 0&&(t.anisotropy=n.anisotropyStrength),n.anisotropyRotation!==void 0&&(t.anisotropyRotation=n.anisotropyRotation),n.anisotropyTexture!==void 0&&i.push(this.parser.assignTexture(t,"anisotropyMap",n.anisotropyTexture)),Promise.all(i)}}class Bv{constructor(e){this.parser=e,this.name=$e.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,n=t.json,i=n.textures[e];if(!i.extensions||!i.extensions[this.name])return null;const r=i.extensions[this.name],o=t.options.ktx2Loader;if(!o){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,r.source,o)}}class zv{constructor(e){this.parser=e,this.name=$e.EXT_TEXTURE_WEBP}loadTexture(e){const t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;const o=r.extensions[t],a=i.images[o.source];let l=n.textureLoader;if(a.uri){const c=n.options.manager.getHandler(a.uri);c!==null&&(l=c)}return n.loadTextureImage(e,o.source,l)}}class Vv{constructor(e){this.parser=e,this.name=$e.EXT_TEXTURE_AVIF}loadTexture(e){const t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;const o=r.extensions[t],a=i.images[o.source];let l=n.textureLoader;if(a.uri){const c=n.options.manager.getHandler(a.uri);c!==null&&(l=c)}return n.loadTextureImage(e,o.source,l)}}class Nh{constructor(e,t){this.name=t,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const i=n.extensions[this.name],r=this.parser.getDependency("buffer",i.buffer),o=this.parser.options.meshoptDecoder;if(!o||!o.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return r.then(function(a){const l=i.byteOffset||0,c=i.byteLength||0,h=i.count,d=i.byteStride,g=new Uint8Array(a,l,c);return o.decodeGltfBufferAsync?o.decodeGltfBufferAsync(h,d,g,i.mode,i.filter).then(function(u){return u.buffer}):o.ready.then(function(){const u=new ArrayBuffer(h*d);return o.decodeGltfBuffer(new Uint8Array(u),h,d,g,i.mode,i.filter),u})})}else return null}}class Gv{constructor(e){this.name=$e.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;const i=t.meshes[n.mesh];for(const c of i.primitives)if(c.mode!==tn.TRIANGLES&&c.mode!==tn.TRIANGLE_STRIP&&c.mode!==tn.TRIANGLE_FAN&&c.mode!==void 0)return null;const o=n.extensions[this.name].attributes,a=[],l={};for(const c in o)a.push(this.parser.getDependency("accessor",o[c]).then(h=>(l[c]=h,l[c])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(c=>{const h=c.pop(),d=h.isGroup?h.children:[h],g=c[0].count,u=[];for(const m of d){const f=new M.Matrix4,p=new M.Vector3,x=new M.Quaternion,v=new M.Vector3(1,1,1),_=new M.InstancedMesh(m.geometry,m.material,g);for(let b=0;b<g;b++)l.TRANSLATION&&p.fromBufferAttribute(l.TRANSLATION,b),l.ROTATION&&x.fromBufferAttribute(l.ROTATION,b),l.SCALE&&v.fromBufferAttribute(l.SCALE,b),_.setMatrixAt(b,f.compose(p,x,v));for(const b in l)if(b==="_COLOR_0"){const S=l[b];_.instanceColor=new M.InstancedBufferAttribute(S.array,S.itemSize,S.normalized)}else b!=="TRANSLATION"&&b!=="ROTATION"&&b!=="SCALE"&&m.geometry.setAttribute(b,l[b]);M.Object3D.prototype.copy.call(_,m),this.parser.assignFinalMaterial(_),u.push(_)}return h.isGroup?(h.clear(),h.add(...u),h):u[0]}))}}const Uh="glTF",Cs=12,Fh={JSON:1313821514,BIN:5130562};class Wv{constructor(e){this.name=$e.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,Cs),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==Uh)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const i=this.header.length-Cs,r=new DataView(e,Cs);let o=0;for(;o<i;){const a=r.getUint32(o,!0);o+=4;const l=r.getUint32(o,!0);if(o+=4,l===Fh.JSON){const c=new Uint8Array(e,Cs+o,a);this.content=n.decode(c)}else if(l===Fh.BIN){const c=Cs+o;this.body=e.slice(c,c+a)}o+=a}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class Hv{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=$e.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const n=this.json,i=this.dracoLoader,r=e.extensions[this.name].bufferView,o=e.extensions[this.name].attributes,a={},l={},c={};for(const h in o){const d=qa[h]||h.toLowerCase();a[d]=o[h]}for(const h in e.attributes){const d=qa[h]||h.toLowerCase();if(o[h]!==void 0){const g=n.accessors[e.attributes[h]],u=es[g.componentType];c[d]=u.name,l[d]=g.normalized===!0}}return t.getDependency("bufferView",r).then(function(h){return new Promise(function(d,g){i.decodeDracoFile(h,function(u){for(const m in u.attributes){const f=u.attributes[m],p=l[m];p!==void 0&&(f.normalized=p)}d(u)},a,c,M.LinearSRGBColorSpace,g)})})}}class Xv{constructor(){this.name=$e.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0||(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}class jv{constructor(){this.name=$e.KHR_MESH_QUANTIZATION}}class Oh extends M.Interpolant{constructor(e,t,n,i){super(e,t,n,i)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i*3+i;for(let o=0;o!==i;o++)t[o]=n[r+o];return t}interpolate_(e,t,n,i){const r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=a*2,c=a*3,h=i-t,d=(n-t)/h,g=d*d,u=g*d,m=e*c,f=m-c,p=-2*u+3*g,x=u-g,v=1-p,_=x-g+d;for(let b=0;b!==a;b++){const S=o[f+b+a],C=o[f+b+l]*h,R=o[m+b+a],I=o[m+b]*h;r[b]=v*S+_*C+p*R+x*I}return r}}const Yv=new M.Quaternion;class qv extends Oh{interpolate_(e,t,n,i){const r=super.interpolate_(e,t,n,i);return Yv.fromArray(r).normalize().toArray(r),r}}const tn={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},es={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},kh={9728:M.NearestFilter,9729:M.LinearFilter,9984:M.NearestMipmapNearestFilter,9985:M.LinearMipmapNearestFilter,9986:M.NearestMipmapLinearFilter,9987:M.LinearMipmapLinearFilter},Bh={33071:M.ClampToEdgeWrapping,33648:M.MirroredRepeatWrapping,10497:M.RepeatWrapping},Ya={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},qa={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},ei={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Zv={CUBICSPLINE:void 0,LINEAR:M.InterpolateLinear,STEP:M.InterpolateDiscrete},Za={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function Kv(s){return s.DefaultMaterial===void 0&&(s.DefaultMaterial=new M.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:M.FrontSide})),s.DefaultMaterial}function bi(s,e,t){for(const n in t.extensions)s[n]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[n]=t.extensions[n])}function xn(s,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(s.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function $v(s,e,t){let n=!1,i=!1,r=!1;for(let c=0,h=e.length;c<h;c++){const d=e[c];if(d.POSITION!==void 0&&(n=!0),d.NORMAL!==void 0&&(i=!0),d.COLOR_0!==void 0&&(r=!0),n&&i&&r)break}if(!n&&!i&&!r)return Promise.resolve(s);const o=[],a=[],l=[];for(let c=0,h=e.length;c<h;c++){const d=e[c];if(n){const g=d.POSITION!==void 0?t.getDependency("accessor",d.POSITION):s.attributes.position;o.push(g)}if(i){const g=d.NORMAL!==void 0?t.getDependency("accessor",d.NORMAL):s.attributes.normal;a.push(g)}if(r){const g=d.COLOR_0!==void 0?t.getDependency("accessor",d.COLOR_0):s.attributes.color;l.push(g)}}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(l)]).then(function(c){const h=c[0],d=c[1],g=c[2];return n&&(s.morphAttributes.position=h),i&&(s.morphAttributes.normal=d),r&&(s.morphAttributes.color=g),s.morphTargetsRelative=!0,s})}function Jv(s,e){if(s.updateMorphTargets(),e.weights!==void 0)for(let t=0,n=e.weights.length;t<n;t++)s.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(s.morphTargetInfluences.length===t.length){s.morphTargetDictionary={};for(let n=0,i=t.length;n<i;n++)s.morphTargetDictionary[t[n]]=n}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function Qv(s){let e;const t=s.extensions&&s.extensions[$e.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+Ka(t.attributes):e=s.indices+":"+Ka(s.attributes)+":"+s.mode,s.targets!==void 0)for(let n=0,i=s.targets.length;n<i;n++)e+=":"+Ka(s.targets[n]);return e}function Ka(s){let e="";const t=Object.keys(s).sort();for(let n=0,i=t.length;n<i;n++)e+=t[n]+":"+s[t[n]]+";";return e}function $a(s){switch(s){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function e_(s){return s.search(/\.jpe?g($|\?)/i)>0||s.search(/^data\:image\/jpeg/)===0?"image/jpeg":s.search(/\.webp($|\?)/i)>0||s.search(/^data\:image\/webp/)===0?"image/webp":s.search(/\.ktx2($|\?)/i)>0||s.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const t_=new M.Matrix4;class n_{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new Ev,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,i=-1,r=!1,o=-1;if(typeof navigator<"u"&&typeof navigator.userAgent<"u"){const a=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(a)===!0;const l=a.match(/Version\/(\d+)/);i=n&&l?parseInt(l[1],10):-1,r=a.indexOf("Firefox")>-1,o=r?a.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||n&&i<17||r&&o<98?this.textureLoader=new M.TextureLoader(this.options.manager):this.textureLoader=new M.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new M.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const n=this,i=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(o){return o._markDefs&&o._markDefs()}),Promise.all(this._invokeAll(function(o){return o.beforeRoot&&o.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(o){const a={scene:o[0][i.scene||0],scenes:o[0],animations:o[1],cameras:o[2],asset:i.asset,parser:n,userData:{}};return bi(r,a,i),xn(a,i),Promise.all(n._invokeAll(function(l){return l.afterRoot&&l.afterRoot(a)})).then(function(){for(const l of a.scenes)l.updateMatrixWorld();e(a)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let i=0,r=t.length;i<r;i++){const o=t[i].joints;for(let a=0,l=o.length;a<l;a++)e[o[a]].isBone=!0}for(let i=0,r=e.length;i<r;i++){const o=e[i];o.mesh!==void 0&&(this._addNodeRef(this.meshCache,o.mesh),o.skin!==void 0&&(n[o.mesh].isSkinnedMesh=!0)),o.camera!==void 0&&this._addNodeRef(this.cameraCache,o.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;const i=n.clone(),r=(o,a)=>{const l=this.associations.get(o);l!=null&&this.associations.set(a,l);for(const[c,h]of o.children.entries())r(h,a.children[c])};return r(n,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){const i=e(t[n]);if(i)return i}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const n=[];for(let i=0;i<t.length;i++){const r=e(t[i]);r&&n.push(r)}return n}getDependency(e,t){const n=e+":"+t;let i=this.cache.get(n);if(!i){switch(e){case"scene":i=this.loadScene(t);break;case"node":i=this._invokeOne(function(r){return r.loadNode&&r.loadNode(t)});break;case"mesh":i=this._invokeOne(function(r){return r.loadMesh&&r.loadMesh(t)});break;case"accessor":i=this.loadAccessor(t);break;case"bufferView":i=this._invokeOne(function(r){return r.loadBufferView&&r.loadBufferView(t)});break;case"buffer":i=this.loadBuffer(t);break;case"material":i=this._invokeOne(function(r){return r.loadMaterial&&r.loadMaterial(t)});break;case"texture":i=this._invokeOne(function(r){return r.loadTexture&&r.loadTexture(t)});break;case"skin":i=this.loadSkin(t);break;case"animation":i=this._invokeOne(function(r){return r.loadAnimation&&r.loadAnimation(t)});break;case"camera":i=this.loadCamera(t);break;default:if(i=this._invokeOne(function(r){return r!=this&&r.getDependency&&r.getDependency(e,t)}),!i)throw new Error("Unknown type: "+e);break}this.cache.add(n,i)}return i}getDependencies(e){let t=this.cache.get(e);if(!t){const n=this,i=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(i.map(function(r,o){return n.getDependency(e,o)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],n=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[$e.KHR_BINARY_GLTF].body);const i=this.options;return new Promise(function(r,o){n.load(M.LoaderUtils.resolveURL(t.uri,i.path),r,void 0,function(){o(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(n){const i=t.byteLength||0,r=t.byteOffset||0;return n.slice(r,r+i)})}loadAccessor(e){const t=this,n=this.json,i=this.json.accessors[e];if(i.bufferView===void 0&&i.sparse===void 0){const o=Ya[i.type],a=es[i.componentType],l=i.normalized===!0,c=new a(i.count*o);return Promise.resolve(new M.BufferAttribute(c,o,l))}const r=[];return i.bufferView!==void 0?r.push(this.getDependency("bufferView",i.bufferView)):r.push(null),i.sparse!==void 0&&(r.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",i.sparse.values.bufferView))),Promise.all(r).then(function(o){const a=o[0],l=Ya[i.type],c=es[i.componentType],h=c.BYTES_PER_ELEMENT,d=h*l,g=i.byteOffset||0,u=i.bufferView!==void 0?n.bufferViews[i.bufferView].byteStride:void 0,m=i.normalized===!0;let f,p;if(u&&u!==d){const x=Math.floor(g/u),v="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+x+":"+i.count;let _=t.cache.get(v);_||(f=new c(a,x*u,i.count*u/h),_=new M.InterleavedBuffer(f,u/h),t.cache.add(v,_)),p=new M.InterleavedBufferAttribute(_,l,g%u/h,m)}else a===null?f=new c(i.count*l):f=new c(a,g,i.count*l),p=new M.BufferAttribute(f,l,m);if(i.sparse!==void 0){const x=Ya.SCALAR,v=es[i.sparse.indices.componentType],_=i.sparse.indices.byteOffset||0,b=i.sparse.values.byteOffset||0,S=new v(o[1],_,i.sparse.count*x),C=new c(o[2],b,i.sparse.count*l);a!==null&&(p=new M.BufferAttribute(p.array.slice(),p.itemSize,p.normalized)),p.normalized=!1;for(let R=0,I=S.length;R<I;R++){const E=S[R];if(p.setX(E,C[R*l]),l>=2&&p.setY(E,C[R*l+1]),l>=3&&p.setZ(E,C[R*l+2]),l>=4&&p.setW(E,C[R*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}p.normalized=m}return p})}loadTexture(e){const t=this.json,n=this.options,r=t.textures[e].source,o=t.images[r];let a=this.textureLoader;if(o.uri){const l=n.manager.getHandler(o.uri);l!==null&&(a=l)}return this.loadTextureImage(e,r,a)}loadTextureImage(e,t,n){const i=this,r=this.json,o=r.textures[e],a=r.images[t],l=(a.uri||a.bufferView)+":"+o.sampler;if(this.textureCache[l])return this.textureCache[l];const c=this.loadImageSource(t,n).then(function(h){h.flipY=!1,h.name=o.name||a.name||"",h.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(h.name=a.uri);const g=(r.samplers||{})[o.sampler]||{};return h.magFilter=kh[g.magFilter]||M.LinearFilter,h.minFilter=kh[g.minFilter]||M.LinearMipmapLinearFilter,h.wrapS=Bh[g.wrapS]||M.RepeatWrapping,h.wrapT=Bh[g.wrapT]||M.RepeatWrapping,h.generateMipmaps=!h.isCompressedTexture&&h.minFilter!==M.NearestFilter&&h.minFilter!==M.LinearFilter,i.associations.set(h,{textures:e}),h}).catch(function(){return null});return this.textureCache[l]=c,c}loadImageSource(e,t){const n=this,i=this.json,r=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(d=>d.clone());const o=i.images[e],a=self.URL||self.webkitURL;let l=o.uri||"",c=!1;if(o.bufferView!==void 0)l=n.getDependency("bufferView",o.bufferView).then(function(d){c=!0;const g=new Blob([d],{type:o.mimeType});return l=a.createObjectURL(g),l});else if(o.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const h=Promise.resolve(l).then(function(d){return new Promise(function(g,u){let m=g;t.isImageBitmapLoader===!0&&(m=function(f){const p=new M.Texture(f);p.needsUpdate=!0,g(p)}),t.load(M.LoaderUtils.resolveURL(d,r.path),m,void 0,u)})}).then(function(d){return c===!0&&a.revokeObjectURL(l),xn(d,o),d.userData.mimeType=o.mimeType||e_(o.uri),d}).catch(function(d){throw console.error("THREE.GLTFLoader: Couldn't load texture",l),d});return this.sourceCache[e]=h,h}assignTexture(e,t,n,i){const r=this;return this.getDependency("texture",n.index).then(function(o){if(!o)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(o=o.clone(),o.channel=n.texCoord),r.extensions[$e.KHR_TEXTURE_TRANSFORM]){const a=n.extensions!==void 0?n.extensions[$e.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const l=r.associations.get(o);o=r.extensions[$e.KHR_TEXTURE_TRANSFORM].extendTexture(o,a),r.associations.set(o,l)}}return i!==void 0&&(o.colorSpace=i),e[t]=o,o})}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const i=t.attributes.tangent===void 0,r=t.attributes.color!==void 0,o=t.attributes.normal===void 0;if(e.isPoints){const a="PointsMaterial:"+n.uuid;let l=this.cache.get(a);l||(l=new M.PointsMaterial,M.Material.prototype.copy.call(l,n),l.color.copy(n.color),l.map=n.map,l.sizeAttenuation=!1,this.cache.add(a,l)),n=l}else if(e.isLine){const a="LineBasicMaterial:"+n.uuid;let l=this.cache.get(a);l||(l=new M.LineBasicMaterial,M.Material.prototype.copy.call(l,n),l.color.copy(n.color),l.map=n.map,this.cache.add(a,l)),n=l}if(i||r||o){let a="ClonedMaterial:"+n.uuid+":";i&&(a+="derivative-tangents:"),r&&(a+="vertex-colors:"),o&&(a+="flat-shading:");let l=this.cache.get(a);l||(l=n.clone(),r&&(l.vertexColors=!0),o&&(l.flatShading=!0),i&&(l.normalScale&&(l.normalScale.y*=-1),l.clearcoatNormalScale&&(l.clearcoatNormalScale.y*=-1)),this.cache.add(a,l),this.associations.set(l,this.associations.get(n))),n=l}e.material=n}getMaterialType(){return M.MeshStandardMaterial}loadMaterial(e){const t=this,n=this.json,i=this.extensions,r=n.materials[e];let o;const a={},l=r.extensions||{},c=[];if(l[$e.KHR_MATERIALS_UNLIT]){const d=i[$e.KHR_MATERIALS_UNLIT];o=d.getMaterialType(),c.push(d.extendParams(a,r,t))}else{const d=r.pbrMetallicRoughness||{};if(a.color=new M.Color(1,1,1),a.opacity=1,Array.isArray(d.baseColorFactor)){const g=d.baseColorFactor;a.color.setRGB(g[0],g[1],g[2],M.LinearSRGBColorSpace),a.opacity=g[3]}d.baseColorTexture!==void 0&&c.push(t.assignTexture(a,"map",d.baseColorTexture,M.SRGBColorSpace)),a.metalness=d.metallicFactor!==void 0?d.metallicFactor:1,a.roughness=d.roughnessFactor!==void 0?d.roughnessFactor:1,d.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(a,"metalnessMap",d.metallicRoughnessTexture)),c.push(t.assignTexture(a,"roughnessMap",d.metallicRoughnessTexture))),o=this._invokeOne(function(g){return g.getMaterialType&&g.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(g){return g.extendMaterialParams&&g.extendMaterialParams(e,a)})))}r.doubleSided===!0&&(a.side=M.DoubleSide);const h=r.alphaMode||Za.OPAQUE;if(h===Za.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,h===Za.MASK&&(a.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:.5)),r.normalTexture!==void 0&&o!==M.MeshBasicMaterial&&(c.push(t.assignTexture(a,"normalMap",r.normalTexture)),a.normalScale=new M.Vector2(1,1),r.normalTexture.scale!==void 0)){const d=r.normalTexture.scale;a.normalScale.set(d,d)}if(r.occlusionTexture!==void 0&&o!==M.MeshBasicMaterial&&(c.push(t.assignTexture(a,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=r.occlusionTexture.strength)),r.emissiveFactor!==void 0&&o!==M.MeshBasicMaterial){const d=r.emissiveFactor;a.emissive=new M.Color().setRGB(d[0],d[1],d[2],M.LinearSRGBColorSpace)}return r.emissiveTexture!==void 0&&o!==M.MeshBasicMaterial&&c.push(t.assignTexture(a,"emissiveMap",r.emissiveTexture,M.SRGBColorSpace)),Promise.all(c).then(function(){const d=new o(a);return r.name&&(d.name=r.name),xn(d,r),t.associations.set(d,{materials:e}),r.extensions&&bi(i,d,r),d})}createUniqueName(e){const t=M.PropertyBinding.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,n=this.extensions,i=this.primitiveCache;function r(a){return n[$e.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(l){return zh(l,a,t)})}const o=[];for(let a=0,l=e.length;a<l;a++){const c=e[a],h=Qv(c),d=i[h];if(d)o.push(d.promise);else{let g;c.extensions&&c.extensions[$e.KHR_DRACO_MESH_COMPRESSION]?g=r(c):g=zh(new M.BufferGeometry,c,t),i[h]={primitive:c,promise:g},o.push(g)}}return Promise.all(o)}loadMesh(e){const t=this,n=this.json,i=this.extensions,r=n.meshes[e],o=r.primitives,a=[];for(let l=0,c=o.length;l<c;l++){const h=o[l].material===void 0?Kv(this.cache):this.getDependency("material",o[l].material);a.push(h)}return a.push(t.loadGeometries(o)),Promise.all(a).then(function(l){const c=l.slice(0,l.length-1),h=l[l.length-1],d=[];for(let u=0,m=h.length;u<m;u++){const f=h[u],p=o[u];let x;const v=c[u];if(p.mode===tn.TRIANGLES||p.mode===tn.TRIANGLE_STRIP||p.mode===tn.TRIANGLE_FAN||p.mode===void 0)x=r.isSkinnedMesh===!0?new M.SkinnedMesh(f,v):new M.Mesh(f,v),x.isSkinnedMesh===!0&&x.normalizeSkinWeights(),p.mode===tn.TRIANGLE_STRIP?x.geometry=Lh(x.geometry,M.TriangleStripDrawMode):p.mode===tn.TRIANGLE_FAN&&(x.geometry=Lh(x.geometry,M.TriangleFanDrawMode));else if(p.mode===tn.LINES)x=new M.LineSegments(f,v);else if(p.mode===tn.LINE_STRIP)x=new M.Line(f,v);else if(p.mode===tn.LINE_LOOP)x=new M.LineLoop(f,v);else if(p.mode===tn.POINTS)x=new M.Points(f,v);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+p.mode);Object.keys(x.geometry.morphAttributes).length>0&&Jv(x,r),x.name=t.createUniqueName(r.name||"mesh_"+e),xn(x,r),p.extensions&&bi(i,x,p),t.assignFinalMaterial(x),d.push(x)}for(let u=0,m=d.length;u<m;u++)t.associations.set(d[u],{meshes:e,primitives:u});if(d.length===1)return r.extensions&&bi(i,d[0],r),d[0];const g=new M.Group;r.extensions&&bi(i,g,r),t.associations.set(g,{meshes:e});for(let u=0,m=d.length;u<m;u++)g.add(d[u]);return g})}loadCamera(e){let t;const n=this.json.cameras[e],i=n[n.type];if(!i){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return n.type==="perspective"?t=new M.PerspectiveCamera(M.MathUtils.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2e6):n.type==="orthographic"&&(t=new M.OrthographicCamera(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),xn(t,n),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],n=[];for(let i=0,r=t.joints.length;i<r;i++)n.push(this._loadNodeShallow(t.joints[i]));return t.inverseBindMatrices!==void 0?n.push(this.getDependency("accessor",t.inverseBindMatrices)):n.push(null),Promise.all(n).then(function(i){const r=i.pop(),o=i,a=[],l=[];for(let c=0,h=o.length;c<h;c++){const d=o[c];if(d){a.push(d);const g=new M.Matrix4;r!==null&&g.fromArray(r.array,c*16),l.push(g)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[c])}return new M.Skeleton(a,l)})}loadAnimation(e){const t=this.json,n=this,i=t.animations[e],r=i.name?i.name:"animation_"+e,o=[],a=[],l=[],c=[],h=[];for(let d=0,g=i.channels.length;d<g;d++){const u=i.channels[d],m=i.samplers[u.sampler],f=u.target,p=f.node,x=i.parameters!==void 0?i.parameters[m.input]:m.input,v=i.parameters!==void 0?i.parameters[m.output]:m.output;f.node!==void 0&&(o.push(this.getDependency("node",p)),a.push(this.getDependency("accessor",x)),l.push(this.getDependency("accessor",v)),c.push(m),h.push(f))}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(l),Promise.all(c),Promise.all(h)]).then(function(d){const g=d[0],u=d[1],m=d[2],f=d[3],p=d[4],x=[];for(let _=0,b=g.length;_<b;_++){const S=g[_],C=u[_],R=m[_],I=f[_],E=p[_];if(S===void 0)continue;S.updateMatrix&&S.updateMatrix();const T=n._createAnimationTracks(S,C,R,I,E);if(T)for(let U=0;U<T.length;U++)x.push(T[U])}const v=new M.AnimationClip(r,void 0,x);return xn(v,i),v})}createNodeMesh(e){const t=this.json,n=this,i=t.nodes[e];return i.mesh===void 0?null:n.getDependency("mesh",i.mesh).then(function(r){const o=n._getNodeRef(n.meshCache,i.mesh,r);return i.weights!==void 0&&o.traverse(function(a){if(a.isMesh)for(let l=0,c=i.weights.length;l<c;l++)a.morphTargetInfluences[l]=i.weights[l]}),o})}loadNode(e){const t=this.json,n=this,i=t.nodes[e],r=n._loadNodeShallow(e),o=[],a=i.children||[];for(let c=0,h=a.length;c<h;c++)o.push(n.getDependency("node",a[c]));const l=i.skin===void 0?Promise.resolve(null):n.getDependency("skin",i.skin);return Promise.all([r,Promise.all(o),l]).then(function(c){const h=c[0],d=c[1],g=c[2];g!==null&&h.traverse(function(u){u.isSkinnedMesh&&u.bind(g,t_)});for(let u=0,m=d.length;u<m;u++)h.add(d[u]);if(h.userData.pivot!==void 0&&d.length>0){const u=h.userData.pivot,m=d[0];h.pivot=new M.Vector3().fromArray(u),h.position.x-=u[0],h.position.y-=u[1],h.position.z-=u[2],m.position.set(0,0,0),delete h.userData.pivot}return h})}_loadNodeShallow(e){const t=this.json,n=this.extensions,i=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const r=t.nodes[e],o=r.name?i.createUniqueName(r.name):"",a=[],l=i._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});return l&&a.push(l),r.camera!==void 0&&a.push(i.getDependency("camera",r.camera).then(function(c){return i._getNodeRef(i.cameraCache,r.camera,c)})),i._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(e)}).forEach(function(c){a.push(c)}),this.nodeCache[e]=Promise.all(a).then(function(c){let h;if(r.isBone===!0?h=new M.Bone:c.length>1?h=new M.Group:c.length===1?h=c[0]:h=new M.Object3D,h!==c[0])for(let d=0,g=c.length;d<g;d++)h.add(c[d]);if(r.name&&(h.userData.name=r.name,h.name=o),xn(h,r),r.extensions&&bi(n,h,r),r.matrix!==void 0){const d=new M.Matrix4;d.fromArray(r.matrix),h.applyMatrix4(d)}else r.translation!==void 0&&h.position.fromArray(r.translation),r.rotation!==void 0&&h.quaternion.fromArray(r.rotation),r.scale!==void 0&&h.scale.fromArray(r.scale);if(!i.associations.has(h))i.associations.set(h,{});else if(r.mesh!==void 0&&i.meshCache.refs[r.mesh]>1){const d=i.associations.get(h);i.associations.set(h,{...d})}return i.associations.get(h).nodes=e,h}),this.nodeCache[e]}loadScene(e){const t=this.extensions,n=this.json.scenes[e],i=this,r=new M.Group;n.name&&(r.name=i.createUniqueName(n.name)),xn(r,n),n.extensions&&bi(t,r,n);const o=n.nodes||[],a=[];for(let l=0,c=o.length;l<c;l++)a.push(i.getDependency("node",o[l]));return Promise.all(a).then(function(l){for(let h=0,d=l.length;h<d;h++){const g=l[h];g.parent!==null?r.add(wv(g)):r.add(g)}const c=h=>{const d=new Map;for(const[g,u]of i.associations)(g instanceof M.Material||g instanceof M.Texture)&&d.set(g,u);return h.traverse(g=>{const u=i.associations.get(g);u!=null&&d.set(g,u)}),d};return i.associations=c(r),r})}_createAnimationTracks(e,t,n,i,r){const o=[],a=e.name?e.name:e.uuid,l=[];ei[r.path]===ei.weights?e.traverse(function(g){g.morphTargetInfluences&&l.push(g.name?g.name:g.uuid)}):l.push(a);let c;switch(ei[r.path]){case ei.weights:c=M.NumberKeyframeTrack;break;case ei.rotation:c=M.QuaternionKeyframeTrack;break;case ei.translation:case ei.scale:c=M.VectorKeyframeTrack;break;default:switch(n.itemSize){case 1:c=M.NumberKeyframeTrack;break;case 2:case 3:default:c=M.VectorKeyframeTrack;break}break}const h=i.interpolation!==void 0?Zv[i.interpolation]:M.InterpolateLinear,d=this._getArrayFromAccessor(n);for(let g=0,u=l.length;g<u;g++){const m=new c(l[g]+"."+ei[r.path],t.array,d,h);i.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(m),o.push(m)}return o}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const n=$a(t.constructor),i=new Float32Array(t.length);for(let r=0,o=t.length;r<o;r++)i[r]=t[r]*n;t=i}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(n){const i=this instanceof M.QuaternionKeyframeTrack?qv:Oh;return new i(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function i_(s,e,t){const n=e.attributes,i=new M.Box3;if(n.POSITION!==void 0){const a=t.json.accessors[n.POSITION],l=a.min,c=a.max;if(l!==void 0&&c!==void 0){if(i.set(new M.Vector3(l[0],l[1],l[2]),new M.Vector3(c[0],c[1],c[2])),a.normalized){const h=$a(es[a.componentType]);i.min.multiplyScalar(h),i.max.multiplyScalar(h)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const r=e.targets;if(r!==void 0){const a=new M.Vector3,l=new M.Vector3;for(let c=0,h=r.length;c<h;c++){const d=r[c];if(d.POSITION!==void 0){const g=t.json.accessors[d.POSITION],u=g.min,m=g.max;if(u!==void 0&&m!==void 0){if(l.setX(Math.max(Math.abs(u[0]),Math.abs(m[0]))),l.setY(Math.max(Math.abs(u[1]),Math.abs(m[1]))),l.setZ(Math.max(Math.abs(u[2]),Math.abs(m[2]))),g.normalized){const f=$a(es[g.componentType]);l.multiplyScalar(f)}a.max(l)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}i.expandByVector(a)}s.boundingBox=i;const o=new M.Sphere;i.getCenter(o.center),o.radius=i.min.distanceTo(i.max)/2,s.boundingSphere=o}function zh(s,e,t){const n=e.attributes,i=[];function r(o,a){return t.getDependency("accessor",o).then(function(l){s.setAttribute(a,l)})}for(const o in n){const a=qa[o]||o.toLowerCase();a in s.attributes||i.push(r(n[o],a))}if(e.indices!==void 0&&!s.index){const o=t.getDependency("accessor",e.indices).then(function(a){s.setIndex(a)});i.push(o)}return M.ColorManagement.workingColorSpace!==M.LinearSRGBColorSpace&&"COLOR_0"in n&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${M.ColorManagement.workingColorSpace}" not supported.`),xn(s,e),i_(s,e,t),Promise.all(i).then(function(){return e.targets!==void 0?$v(s,e.targets,t):s})}var xt=(s=>(s.ModelLoadStart="model-load-start",s.ModelLoadProgress="model-load-progress",s.ModelLoaded="model-loaded",s.ModelError="model-error",s.SelectionChanged="selection-changed",s.HoverChanged="hover-changed",s.Click="click",s.MouseMove="mouse-move",s.CameraChanged="camera-changed",s.CameraIdle="camera-idle",s.EngineFree="engine-free",s.EngineBusy="engine-busy",s.MeasureChanged="measure-changed",s.MeasureClick="measure-click",s.SectionMove="section-move",s.LoadingCompleted="loading_completed",s))(xt||{});let As=null;const s_=8,Vh=24,r_=24,o_=64,a_=60,l_=10;function Gh(){return new URL("draco/",document.baseURI).toString()}function c_(){return As==null&&(As=new yv,As.setDecoderPath(Gh()),As.preload()),As}function Wh(){return new Promise(s=>{if(typeof requestAnimationFrame=="function"){requestAnimationFrame(()=>s());return}setTimeout(s,16)})}function h_(){const s=navigator?.scheduling;return typeof s?.isInputPending=="function"?s.isInputPending():!1}function d_(s){return s?.engineStatus?.isFree===!1||h_()}async function kn(s,e,t){if(e)return t;const n=performance.now();return d_(s)||n-t>=s_?(await Wh(),performance.now()):t}function u_(s){return new Promise((e,t)=>{Es(s,n=>{if(n==null){t(new Error(`[loadLightModel] empty zip json: ${s}`));return}e(n)},()=>{t(new Error(`[loadLightModel] failed to load zip json: ${s}`))})})}function f_(s){return gt({method:"get",responseType:"arraybuffer",url:s}).then(e=>Xc.loadAsync(e.data))}function Hh(s){return s.replace(/\\/g,"/").replace(/^\/+/,"")}function Xh(s,e){const t=new Set(e.map(n=>Hh(n)));for(const n of Object.keys(s.files))if(t.has(Hh(n)))return s.files[n];return null}function jh(s,e){const t=Xh(s,e);return t==null||t.dir?Promise.resolve(null):t.async("string")}function p_(s){return s.charCodeAt(0)===65279?s.slice(1):s}function Ja(s){return JSON.parse(p_(s))}function m_(s,e){const t=Xh(s,e);return t==null||t.dir?Promise.resolve(null):t.async("arraybuffer")}function g_(s){return new Promise((e,t)=>{const n=new Sv;n.setDRACOLoader(c_()),n.parse(s,document.baseURI,e,t)})}function Hr(s,e){return s.models.find(t=>t.url==e)}function Yh(s){s.loadStatus==null&&(s.loadStatus={}),s.loadStatus.modelMep==null&&(s.loadStatus.modelMep=!1),s.loadStatus.normal==null&&(s.loadStatus.normal=!1)}function x_(s){return Yh(s),s.status==="loaded"&&s.loadStatus.normal===!0&&s.loadStatus.modelMep===!0}function qh(s){const e=s?.engineStatus?.models;!Array.isArray(e)||e.length===0||!e.every(n=>x_(n))||s.__loadingCompletedTriggered===!0||(s.__loadingCompletedTriggered=!0,s.events?.trigger?.(xt.LoadingCompleted,{}))}function Zh(s){return s===!0||s==="loading"}function Kh(s){return s.index!=null?s.index.count:s.attributes.position?.count??0}async function v_(s,e,t){let n=performance.now();for(let i=0;i<e.length;i++){const r=e[i];r?.geometry!=null&&r.geometry.computeVertexNormals,(i+1)%r_===0&&(n=await kn(s,t,n))}}async function __(s,e,t){const n=[],i=[{node:e.octreeBox,visited:!1}];let r=performance.now();for(;i.length>0;){const o=i.pop();if(o==null||o.node==null||o.node.status===!0)continue;const a=o.node;if(o.visited){const c=Array.isArray(a.children)?a.children:[];(c.length===0||c.findIndex(h=>h.status!=!0)===-1)&&(a.status=!0),r=await kn(s,t,r);continue}i.push({node:a,visited:!0}),Array.isArray(a.elements)&&n.push(...a.elements);const l=Array.isArray(a.children)?a.children:[];for(let c=l.length-1;c>=0;c--)i.push({node:l[c],visited:!1});r=await kn(s,t,r)}return n}async function y_(s,e,t,n){const i=Hr(s,e.url);if(i?.nodesMap==null)return[];const r=await __(s,t,n);console.log("[loadLightModel] pending mesh ids",t.path,r.length);const o=[];let a=performance.now(),l=0;for(const c of r){if(!i.nodesMap.has(c))continue;const h=i.nodesMap.get(c),d=Array.isArray(h?.infos)?h.infos:[];for(const g of d){const u=t.glbs?.[g.glb]?.[g.mesh];if(u?.geometry==null||u.material==null)continue;const m=new y.Matrix4;m.elements=g.matrix;const f=u.geometry.clone();f.applyMatrix4(m),f.computeBoundingBox();const p=new y.Mesh(f,u.material);g.box=f.boundingBox?.clone(),g.mesh=p,p.name=Number(c),p.glb=g.glb,p.url=e.url,f.attributes.position!=null&&o.push(p),l++,l%Vh===0&&(a=await kn(s,n,a))}}return o}function M_(s,e,t,n,i){const r=Mi(n.map(a=>a.geometry),!1),o=new y.Mesh(r,i);return o.castShadow=!0,o.receiveShadow=!0,e.scene.add(o),o.index=e.scene.children.length-1,o.url=s,o.glb=t,o.materialClone=i,o.geometrys=n.map(a=>a.geometry),o.geometry.computeVertexNormals(),o}function b_(s,e,t,n){return s.scene.children.find(i=>{const r=i;return i instanceof y.Mesh&&r.url==e&&r.glb==t&&r.materialClone===n})}function w_(s,e){const t=Array.isArray(s.geometrys)?s.geometrys:[],n=e.map(o=>o.geometry),i=[...t,...n],r=Mi(i,!1);s.geometry!=null&&s.geometry.dispose(),s.geometry=r,s.geometrys=i,s.castShadow=!0,s.receiveShadow=!0}async function S_(s,e,t,n){const i=new Map;for(const a of t){const l=i.get(a.glb)??[];l.push(a),i.set(a.glb,l)}const r=Hr(e,s);let o=performance.now();for(const[a,l]of i.entries()){const c=n?l.length:a_;for(let h=0;h<l.length;h+=c){const d=l.slice(h,h+c);if(d.length===0)continue;const g=N_(d[0].material,e);let u=b_(e,s,a,g),m=0,f=0;u=null,u!=null?(m=Array.isArray(u.geometrys)?u.geometrys.length:0,f=Kh(u.geometry),w_(u,d)):u=M_(s,e,a,d,g);const p=new Map;let x=f;d.forEach((v,_)=>{const b=Number(v.name),S=Kh(v.geometry),C=p.get(b)??[];if(C.push([x,x+S]),p.set(b,C),r?.nodesMap?.has(b)){const R=r.nodesMap.get(b);R.indexes==null&&(R.indexes=[]),R.indexes.push([u.index,m+_,x,x+S])}x+=S}),u.indexes==null&&(u.indexes=new Map),p.forEach((v,_)=>{const b=u.indexes.get(_)??[];b.push(...v),u.indexes.set(_,b)}),o=await kn(e,n,o)}}}async function E_(s,e,t,n,i,r){if(n==null||i==null||i.length===0)return;const o=Hr(t,s);if(o==null)return;const a=new y.InstancedMesh(n.geometry,n.material,i.length);t.scene.add(a);const l=new Float32Array(i.length*3);for(let d=0;d<i.length;d++)l[d*3]=1,l[d*3+1]=1,l[d*3+2]=1;a.instanceColor=new y.InstancedBufferAttribute(l,3);let c=performance.now();const h=[];for(let d=0;d<i.length;d++){const g=i[d],u=new y.Matrix4;if(u.elements=g.matrix,a.setMatrixAt(d,u),a.matrixs||(a.matrixs=[]),a.matrixs.push(u.clone()),h.push(u.clone()),o.nodesMap.has(g.id)){const m=o.nodesMap.get(g.id);m.indexes==null&&(m.indexes=[]),m.indexes.push([t.scene.children.length-1,d,0,0])}else o.nodesMap.set(g.id,{instance:!0,info:g,indexes:[[t.scene.children.length-1,d,0,0]]});(d+1)%o_===0&&(c=await kn(t,r,c))}a.instanceMatrix.needsUpdate=!0,a.instanceColor!=null&&(a.instanceColor.needsUpdate=!0),a.index=t.scene.children.length-1,a.materialClone=n.material,a.url=s,a.glb=n.glb,a.ids=i.map(d=>d.id),a.matrixsClone=h,a.meshIndex=e}async function C_(s,e,t,n){const i=e.instanceNodes;if(i==null)return;let r=performance.now();for(const o in i)if(i[o].isLoaded!==!0){i[o].isLoaded=!0;for(const a of i[o]){const l=e.glbs?.[o]?.[a.mesh];l!=null&&await E_(s.url,a.mesh,t,l,a.children,n)}r=await kn(t,n,r)}}async function A_(s,e,t,n){if(t.status===!0||t.meshPromise!=null){await t.meshPromise;return}t.meshPromise=(async()=>{console.log(`[loadLightModel] start build lod meshes ${Date.now()-window.startTime}ms`);const i=await y_(s,e,t,n);await S_(e.url,s,i,n),await C_(e,t,s,n),t.status=!0,console.log(`[loadLightModel] *****************************************************finish build lod meshes ${Date.now()-window.startTime}ms`)})().finally(()=>{t.meshPromise=null}),await t.meshPromise}async function T_(s,e,t,n){if(t.loadSuccess!==!0){if(t.preparePromise!=null){await t.preparePromise;return}t.preparePromise=(async()=>{console.log("[loadLightModel] loading GLB bundle",t.path),t.glbs=t.glbs??{};const i=await f_(e.url+t.path),r=await jh(i,["/nodes.json","nodes.json"]);if(r==null)return;const o=Ja(r),a=Hr(s,e.url);if(a==null)return;a.nodesMap==null&&(a.nodesMap=new Map);let l=performance.now();for(const h of Object.keys(o)){const d=o[h];for(let u=0;u<d.length;u++){const m=d[u];m.glb=h,a.nodesMap.has(m.id)===!1?a.nodesMap.set(m.id,{infos:[m]}):a.nodesMap.get(m.id).infos.push(m),(u+1)%Vh===0&&(l=await kn(s,n,l))}const g=await m_(i,[`/${h}.glb`,`${h}.glb`,h+".glb"]);if(g==null){console.error("[loadLightModel] glb not found in zip",{modelUrl:e.url,lodPath:t.path,glbKey:`${h}.glb`,availableFiles:Object.keys(i.files)});continue}try{const u=await g_(g);t.glbs[h]=u.scene.children,await v_(s,t.glbs[h],n)}catch(u){console.error("[loadLightModel] failed to load glb",{modelUrl:e.url,lodPath:t.path,glbKey:`${h}.glb`,dracoDecoderPath:Gh(),error:u})}l=await kn(s,n,l)}const c=await jh(i,["/instances.json","instances.json"]);t.instanceNodes=c!=null?Ja(c):null,t.loadSuccess=!0})().finally(()=>{t.preparePromise=null}),await t.preparePromise}}function P_(s,e,t){if(t.boundingBox||(t.boundingBox=new y.Box3,t.boundingBox.min=new y.Vector3(t.octreeBox.min.X,t.octreeBox.min.Z,-t.octreeBox.min.Y),t.boundingBox.max=new y.Vector3(t.octreeBox.max.X,t.octreeBox.max.Z,-t.octreeBox.max.Y)),!t.maxSize)return 1e3;const n=t.boundingBox,i=n.min,r=n.max,o=i.clone().add(r.clone()).multiplyScalar(.5),a=i.distanceTo(r),l=new y.Vector3,c=new y.Vector3,h=new y.Vector3,d=new y.Vector3;if(e.getWorldDirection(h),e.getWorldPosition(d),e.matrixWorld.extractBasis(l,c,new y.Vector3),e instanceof y.OrthographicCamera){const x=Math.max((e.top-e.bottom)/e.zoom,1e-6),v=s?.cameraModule?.perspectiveCamera?.getEffectiveFOV?.()??20,_=y.MathUtils.degToRad(v*.5),b=_>0?x/(2*Math.tan(_)):x;d.copy(o).add(h.clone().multiplyScalar(-b))}if(d.distanceTo(o)<=a*.5)return 1e3;const g=o.clone().sub(d).dot(h);if(g<=0)return 0;const u=d.clone().add(h.multiplyScalar(Math.max(g,a))),m=u.clone().add(l.setLength(t.maxSize)),f=new it(e,s.renderer,s.scene).worldToScreen(u),p=new it(e,s.renderer,s.scene).worldToScreen(m);return f.distanceTo(p)}async function D_(s,e,t,n){t.maxSize<1e6&&t.path!="/lod0"&&(!(P_(s,s.camera,t)>=l_)||t.status===!0)||(await T_(s,e,t,n),t.loadSuccess===!0&&await A_(s,e,t,n))}function R_(s,e,t){if(Zh(e.loadStatus.modelMep))return;e.loadStatus.modelMep="loading",e.info.modelMep==null&&(e.info.modelMep={}),(async()=>{t||await Wh(),bv(s,e.info.modelMep,e.url),e.loadStatus.modelMep=!0,qh(s)})().catch(i=>{e.loadStatus.modelMep=!1,console.error("[loadLightModel] failed to load mep model",i)})}function L_(s,e,t,n){const i=new y.Group;i.name=e,s.scene.add(i),s.models||(s.models=[]),window.startTime=Date.now(),u_(e+"/info").then(r=>{const o=Ja(r);s.__loadingCompletedTriggered=!1,s.engineStatus.models.push({type:"light",info:o,name:o.baseInfo.name,status:"loading",url:e,elements:new Map,loadStatus:{modelMep:!1,normal:!1}}),s.models.push({url:e,nodesMap:new Map,grids:o.modelGrid,levels:o.modelLevel,rooms:o.modelRoom,views:o.modelView,boundingBox:{min:new y.Vector3(o.baseInfo.min.X*.3048,o.baseInfo.min.Z*.3048,-o.baseInfo.min.Y*.3048),max:new y.Vector3(o.baseInfo.max.X*.3048,o.baseInfo.max.Z*.3048,-o.baseInfo.max.Y*.3048)}}),s.models.length==n&&(s.viewCube.CameraGoHome(1),setTimeout(()=>{$h(s,null,!1)},100))}).catch(r=>{console.error("[loadLightModel] failed to load model info",{url:e,error:r})})}async function $h(s,e,t=!1){const n=s.engineStatus.models.filter(i=>e==null||i.url==e);for(const i of n)if(Yh(i),!(i.status!=="loading"||i.type!=="light")&&(R_(s,i,t),!Zh(i.loadStatus.normal))){i.loadStatus.normal="loading";try{await I_(s,i,t)}finally{const r=Array.isArray(i.info?.lods)&&i.info.lods.every(o=>o.status===!0);i.loadStatus.normal=r,r&&(i.status="loaded"),qh(s)}}}async function I_(s,e,t=!1){if(console.log(`[loadLightModel] start loadNode ${Date.now()-window.startTime}ms`),!(e.info==null||e.info.lods==null))for(const n of e.info.lods)await D_(s,e,n,t)}function N_(s,e){return s.map!=null&&(s.map.colorSpace=y.SRGBColorSpace,s.map.needsUpdate=!0),s.clipShadows=!0,e?.sectionPlane&&(s.clippingPlanes=e.sectionPlane),s}class U_{engine;constructor(e){this.engine=e}async loadModels(e,t){console.log("待加载模型",e);for(const i of e)n(i)==="light"&&L_(this.engine,i,t,e.length);function n(i){const r=i.split(".").pop();return r==="glb"||r==="gltf"?"gltf":"light"}}}var ts=(s=>(s.ModelLoadStart="model-load-start",s.ModelLoadProgress="model-load-progress",s.ModelLoaded="model-loaded",s.ModelError="model-error",s.SelectionChanged="selection-changed",s.HoverChanged="hover-changed",s.Click="click",s.MouseMove="mouse-move",s.CameraChanged="camera-changed",s.CameraIdle="camera-idle",s.ViewportResize="viewport-resize",s.EngineFree="engine-free",s.EngineBusy="engine-busy",s.MeasureChanged="measure-changed",s.SectionMove="section-move",s.LoadingCompleted="loading_completed",s))(ts||{});class F_{engine;isFree;isForceFree;highlightModels;hideModels;translucentModels;models;constructor(e){this.engine=e,this.isFree=!0,this.isForceFree=!1,this.highlightModels=[],this.hideModels=[],this.translucentModels=[],this.models=[]}init(){this.engine.events.on(ts.EngineFree,e=>{this.updateFree(!0),$h(this.engine,e,!1)}),this.engine.events.on(ts.EngineBusy,()=>{this.updateFree(!1)})}updateFree(e){this.isFree=e}closeAllFunction=()=>{}}let O_=class{listeners=new Map;debugMode=!1;setDebugMode(e){this.debugMode=e}on(e,t){const n=String(e);this.listeners.has(n)||this.listeners.set(n,[]),this.listeners.get(n).push(t),this.debugMode&&console.debug(`[EventModule] 注册事件监听器: ${n}, 当前监听器数量: ${this.listeners.get(n).length}`)}off(e,t){const n=String(e);if(!this.listeners.has(n)){this.debugMode&&console.warn(`[EventModule] 尝试移除不存在的事件监听器: ${n}`);return}const i=this.listeners.get(n),r=i.indexOf(t);r!==-1?(i.splice(r,1),this.debugMode&&console.debug(`[EventModule] 移除事件监听器: ${n}, 剩余监听器数量: ${i.length}`)):this.debugMode&&console.warn(`[EventModule] 尝试移除的回调函数未找到: ${n}`)}trigger(e,t){const n=String(e);if(!this.listeners.has(n)){this.debugMode&&(console.warn(`[EventModule] 触发事件但未找到监听器: ${n}`),console.debug("[EventModule] 当前已注册的事件类型:",Array.from(this.listeners.keys())));return}const i=this.listeners.get(n);this.debugMode&&console.debug(`[EventModule] 触发事件: ${n}, 监听器数量: ${i.length}`,t),i.forEach((r,o)=>{try{r(t)}catch(a){console.error(`[EventModule] 事件监听器执行错误 [${n}] #${o}:`,a)}})}};class k_{engine;constructor(e){this.engine=e}init(){const e=new y.DirectionalLight(16777215,1);e.position.set(100,200,100),e.castShadow=!0,e.shadow.mapSize.width=2048,e.shadow.mapSize.height=2048,e.shadow.camera.near=.1,e.shadow.camera.far=5e3,e.shadow.bias=-5e-5,e.shadow.normalBias=.02;const t=50;e.shadow.camera.left=-t,e.shadow.camera.right=t,e.shadow.camera.top=t,e.shadow.camera.bottom=-t,e.shadow.radius=2;const n=new y.DirectionalLight(16777215,2);this.engine.scene.add(e),this.engine.scene.add(n),this.engine.scene.dirLight=n;const i=new y.AmbientLight(16777215,3);this.engine.scene.add(i)}}class B_{engine;behavior;isCtrlDown=!1;isShiftDown=!1;hoverOldId=null;timeOutEvent;selectionBox=null;isBoxSelecting=!1;selectionStart=new y.Vector2;selectionEnd=new y.Vector2;suppressClickOnce=!1;selectionThreshold=5;tempInstanceMatrix=new y.Matrix4;tempScale=new y.Vector3;constructor(e){this.engine=e}init(){this.behavior=this.engine.handelBehaved,this.ensureSelectionBox(),this.behavior.init(this)}active(){this.behavior.active()}disActive(){this.cancelBoxSelection(),this.behavior.disActive()}handelKeyCtrlUp(){this.isCtrlDown=!1,this.isBoxSelecting&&this.cancelBoxSelection()}handelKeyCtrlDown(){this.isCtrlDown=!0}handelKeyShiftUp(){this.isShiftDown=!1}handelKeyShiftDown(){this.isShiftDown=!0}handleMouseDown(e){e.button!==0||!this.isBoxSelectionModifierDown()||(this.isBoxSelecting=!0,this.selectionStart.set(e.offsetX,e.offsetY),this.selectionEnd.copy(this.selectionStart),this.suppressClickOnce=!1,this.clearHoverFeedback(),this.updateSelectionBox(),this.engine.controls&&(this.engine.controls.enabled=!1))}handleMouseMove(e){if(this.clearHoverTimeout(),this.isBoxSelecting){this.selectionEnd.set(e.offsetX,e.offsetY),this.clearHoverFeedback(),this.updateSelectionBox();return}if(e.catch!=null&&(this.engine.hoverHighLight.showModelNameTag(null,null),this.timeOutEvent=setTimeout(()=>{this.hoverOldId=null;const n=this.getCatchMeshs(e,!0);n!=null&&n.length>0&&this.engine.hoverHighLight.showModelNameTag({url:n[0].url,ids:[n[0].name]},e.catch.point)},1e3)),!this.engine.engineStatus.isFree){this.engine.hoverHighLight.clearHighlight();return}const t=this.getCatchMeshs(e);if(t!=null&&t.length>0){this.engine.hoverHighLight.hightMesh(t);return}}handleMouseUp(e){if(!this.isBoxSelecting)return;this.selectionEnd.set(e.offsetX,e.offsetY);const t=this.hasSelectionBox(),n=t?this.collectModelsInSelection():[];this.isBoxSelecting=!1,this.hideSelectionBox(),this.engine.controls&&(this.engine.controls.enabled=!0),t&&(this.isBoxDeselectMode()?this.applyBoxDeselection(n):this.applyBoxSelection(n),this.suppressClickOnce=!0)}getCatchMeshs(e,t=!1){if(e.catch==null)return this.hoverOldId=null,null;if(e.catch.object.isInstance){const c=e.catch.object,h=e.catch.object.id,g=this.engine.models.find(f=>f.url==c.url)?.nodesMap?.get(h),u=new Map;g?.indexes.forEach(f=>{this.getSceneModel(f[0])instanceof y.InstancedMesh&&(u.has(f[0])||u.set(f[0],[]),u.get(f[0])?.push(f[1]))});const m=[];return u.forEach((f,p)=>{const x=this.getSceneModel(p);f.forEach(v=>{const _=x.geometry.clone();_.applyMatrix4(x.matrixs[v]),m.push(new y.Mesh(_,x.material))})}),this.hoverOldId==h?[]:(this.hoverOldId=h,t||this.engine.hoverHighLight.clearHighlight(),m)}const i=e.catch.object,r=i.name,l=this.engine.models.find(c=>c.url===i.url)?.nodesMap?.get(r)?.infos?.map(c=>c.mesh)??[];return this.hoverOldId==r?[]:(this.hoverOldId=r,t||this.engine.hoverHighLight.clearHighlight(),l)}handleMouseClick(e){if(this.suppressClickOnce){this.suppressClickOnce=!1;return}if(this.isShiftDown&&!this.isCtrlDown)return;if(e.catch!=null){const n=e.catch,i=n.object;if(!this.isCtrlDown){this.engine.modelToolModule.unhighlightAllModels();const o=new CustomEvent("D3ElementClick",{detail:{id:-1}});window.dispatchEvent(o)}this.engine.controlModule.orbitControls.origin.set(n.point.x,n.point.y,n.point.z),this.engine.modelToolModule.highlightModel([{url:i.url,ids:[i.name]}]),this.engine.events.trigger(xt.Click,[{url:i.url,ids:[i.name]}]);const r=new CustomEvent("D3ElementClick",{detail:{id:i.name}});window.dispatchEvent(r);return}const t=new CustomEvent("D3ElementClick",{detail:{id:-1}});window.dispatchEvent(t),this.engine.modelToolModule.unhighlightAllModels()}handleMouseDoubleClick(e){if(!e.catch){this.engine.viewCube.CameraGoHome(500);return}const t=e.catch,n=t.object,r=this.engine.models.find(l=>l.url===n.url)?.nodesMap?.get(n.name);if(!r)return;if(t.object.isInstance){const l=t.matrix,c=[];r.indexes.forEach(d=>{const g=this.getSceneModel(d[0]);g?.geometry?.boundingSphere||g?.geometry?.computeBoundingSphere?.();const u=g?.geometry?.boundingSphere;if(!u)return;const m=new y.Box3,f=u.center.clone().applyMatrix4(l),p=u.radius,x=new y.Vector3().setFromMatrixScale(l),v=p*Math.max(x.x,x.y,x.z);m.min.set(f.x-v,f.y-v,f.z-v),m.max.set(f.x+v,f.y+v,f.z+v),c.push(m)});const h=this.getMergedBox(c);h!=null&&this.engine.viewCube.zoomToModel(h);return}const o=r.infos.map(l=>l.box).filter(l=>l instanceof y.Box3),a=this.getMergedBox(o);a!=null&&this.engine.viewCube.zoomToModel(a)}handleMouseClickInstance(e){return e.intersectObjects(this.engine.scene.children.filter(t=>t instanceof y.InstancedMesh),!0)}ensureSelectionBox(){if(this.selectionBox!=null)return;const e=document.createElement("div");e.style.position="absolute",e.style.left="0px",e.style.top="0px",e.style.display="none",e.style.pointerEvents="none",e.style.border="1px dashed #00aaff",e.style.backgroundColor="rgba(0, 170, 255, 0.12)",e.style.boxSizing="border-box",e.style.zIndex="1001",this.engine.container?.appendChild(e),this.selectionBox=e}updateSelectionBox(){if(this.selectionBox==null)return;if(!this.hasSelectionBox()){this.selectionBox.style.display="none";return}const e=this.getSelectionRect();this.selectionBox.style.display="block",this.selectionBox.style.left=`${e.left}px`,this.selectionBox.style.top=`${e.top}px`,this.selectionBox.style.width=`${e.right-e.left}px`,this.selectionBox.style.height=`${e.bottom-e.top}px`}hideSelectionBox(){this.selectionBox!=null&&(this.selectionBox.style.display="none")}cancelBoxSelection(){this.isBoxSelecting=!1,this.hideSelectionBox(),this.engine.controls&&(this.engine.controls.enabled=!0)}clearHoverTimeout(){this.timeOutEvent!=null&&(clearTimeout(this.timeOutEvent),this.timeOutEvent=null)}clearHoverFeedback(){this.hoverOldId=null,this.engine.hoverHighLight.clearHighlight(),this.engine.hoverHighLight.showModelNameTag(null,null)}hasSelectionBox(){return Math.abs(this.selectionEnd.x-this.selectionStart.x)>=this.selectionThreshold&&Math.abs(this.selectionEnd.y-this.selectionStart.y)>=this.selectionThreshold}getSelectionRect(){return{left:Math.min(this.selectionStart.x,this.selectionEnd.x),top:Math.min(this.selectionStart.y,this.selectionEnd.y),right:Math.max(this.selectionStart.x,this.selectionEnd.x),bottom:Math.max(this.selectionStart.y,this.selectionEnd.y)}}isContainMode(){return this.selectionEnd.x>=this.selectionStart.x&&this.selectionEnd.y>=this.selectionStart.y}isBoxSelectionModifierDown(){return this.isCtrlDown}isBoxDeselectMode(){return this.isShiftDown}collectModelsInSelection(){const e=this.getSelectionRect(),t=this.isContainMode(),n=new Map;return this.engine.models?.forEach(i=>{!i?.url||!i?.nodesMap||i.nodesMap.forEach((r,o)=>{const a=this.getNodeWorldBox(r),l=this.projectBoxToScreenRect(a);l==null||!(t?this.containsRect(e,l):this.intersectsRect(e,l))||(n.has(i.url)||n.set(i.url,new Set),n.get(i.url)?.add(o))})}),Array.from(n.entries()).map(([i,r])=>({url:i,ids:Array.from(r)}))}applyBoxSelection(e){const t=this.excludeHighlightedModels(e);t.length!==0&&(this.engine.modelToolModule.highlightModel(t),this.engine.events.trigger(xt.SelectionChanged,t))}applyBoxDeselection(e){const t=this.keepHighlightedModels(e);t.length!==0&&(this.engine.modelToolModule.unhighlightModel(t),this.removeModelsFromHighlightState(t),this.engine.events.trigger(xt.SelectionChanged,t))}excludeHighlightedModels(e){const t=new Map;return(this.engine.engineStatus.highlightModels??[]).forEach(n=>{t.has(n.url)||t.set(n.url,new Set),n.ids.forEach(i=>t.get(n.url)?.add(i))}),e.map(n=>({url:n.url,ids:n.ids.filter(i=>!t.get(n.url)?.has(i))})).filter(n=>n.ids.length>0)}keepHighlightedModels(e){const t=new Map;return(this.engine.engineStatus.highlightModels??[]).forEach(n=>{t.has(n.url)||t.set(n.url,new Set),n.ids.forEach(i=>t.get(n.url)?.add(i))}),e.map(n=>({url:n.url,ids:n.ids.filter(i=>t.get(n.url)?.has(i))})).filter(n=>n.ids.length>0)}removeModelsFromHighlightState(e){const t=new Map;e.forEach(n=>{t.has(n.url)||t.set(n.url,new Set),n.ids.forEach(i=>t.get(n.url)?.add(i))}),this.engine.engineStatus.highlightModels=(this.engine.engineStatus.highlightModels??[]).map(n=>({url:n.url,ids:n.ids.filter(i=>!t.get(n.url)?.has(i))})).filter(n=>n.ids.length>0)}getNodeWorldBox(e){if(Array.isArray(e?.infos)&&e.infos.length>0){const t=e.infos.map(n=>n?.box).filter(n=>n instanceof y.Box3);return this.getMergedBox(t)}if(Array.isArray(e?.indexes)&&e.indexes.length>0){const t=[];return e.indexes.forEach(n=>{const i=this.getSceneModel(n[0]),r=this.getInstanceWorldBox(i,n[1]);r!=null&&t.push(r)}),this.getMergedBox(t)}return null}getInstanceWorldBox(e,t){if(!(e instanceof y.InstancedMesh))return null;e.geometry.boundingBox||e.geometry.computeBoundingBox();const n=e.geometry.boundingBox;if(!n)return null;if(typeof e.getMatrixAt=="function")e.getMatrixAt(t,this.tempInstanceMatrix);else if(e.matrixs?.[t])this.tempInstanceMatrix.copy(e.matrixs[t]);else return null;return this.tempScale.setFromMatrixScale(this.tempInstanceMatrix),Math.abs(this.tempScale.x)+Math.abs(this.tempScale.y)+Math.abs(this.tempScale.z)<1e-6?null:n.clone().applyMatrix4(this.tempInstanceMatrix)}projectBoxToScreenRect(e){if(e==null||e.isEmpty())return null;const t=[new y.Vector3(e.min.x,e.min.y,e.min.z),new y.Vector3(e.min.x,e.min.y,e.max.z),new y.Vector3(e.min.x,e.max.y,e.min.z),new y.Vector3(e.min.x,e.max.y,e.max.z),new y.Vector3(e.max.x,e.min.y,e.min.z),new y.Vector3(e.max.x,e.min.y,e.max.z),new y.Vector3(e.max.x,e.max.y,e.min.z),new y.Vector3(e.max.x,e.max.y,e.max.z)];let n=1/0,i=1/0,r=-1/0,o=-1/0;return t.forEach(a=>{const l=new it(this.engine.camera,this.engine.renderer,this.engine.scene).worldToScreen(a);!Number.isFinite(l.x)||!Number.isFinite(l.y)||(n=Math.min(n,l.x),i=Math.min(i,l.y),r=Math.max(r,l.x),o=Math.max(o,l.y))}),!Number.isFinite(n)||!Number.isFinite(i)||!Number.isFinite(r)||!Number.isFinite(o)?null:{left:n,top:i,right:r,bottom:o}}containsRect(e,t){return t.left>=e.left&&t.top>=e.top&&t.right<=e.right&&t.bottom<=e.bottom}intersectsRect(e,t){return!(t.right<e.left||t.left>e.right||t.bottom<e.top||t.top>e.bottom)}getMergedBox(e){if(e.length===0)return null;const t=new y.Box3().makeEmpty();return e.forEach(n=>t.union(n)),t.isEmpty()?null:t}getSceneModel(e){return this.engine.scene.children.find(t=>t.index===e)??this.engine.scene.children[e]}}class z_{engine;highlightMaterial;hideMaterial;translucentMaterial;constructor(e){this.engine=e,this.highlightMaterial=new y.MeshBasicMaterial({color:43775,depthTest:!1,depthWrite:!1,transparent:!0,opacity:.5,side:y.DoubleSide}),this.hideMaterial=new y.MeshBasicMaterial({color:0,transparent:!0,opacity:0,side:y.DoubleSide}),this.translucentMaterial=new y.MeshBasicMaterial({color:16777215,transparent:!0,opacity:.05,side:y.DoubleSide}),this.highlightMaterial.clippingPlanes=this.engine.sectionPlane,this.hideMaterial.clippingPlanes=this.engine.sectionPlane,this.translucentMaterial.clippingPlanes=this.engine.sectionPlane}split_merge_model(e){if(e.isSplit||e instanceof y.InstancedMesh)return;let t=e.materialClone.clone(),n=Mi(e.geometrys,!0);n.computeVertexNormals(),n.groups.forEach(i=>{i.materialIndex=0}),e.geometry=n,e.material=[t,this.highlightMaterial,this.translucentMaterial],e.needsUpdate=!0,e.isSplit=!0}un_split_merge_model(e){}getSceneModel(e){return this.engine.scene.children.find(t=>t.index==e)}highlightModel(e){e.forEach(t=>{let n=new Map;t.ids.forEach(r=>{let o=this.engine.models.find(a=>a.url==t.url).nodesMap.get(r);o!=null&&o.indexes!=null&&o.indexes.forEach(a=>{this.getSceneModel(a[0])instanceof y.InstancedMesh?n.has(a[0])?n.get(a[0])?.push(a[1]):n.set(a[0],[a[1]]):(console.log(this.getSceneModel(a[0]).materialClone.color),this.split_merge_model(this.getSceneModel(a[0])),this.getSceneModel(a[0]).geometry.groups[a[1]].materialIndex=1)})}),V_(n,this.engine);let i=this.engine.engineStatus.highlightModels.find(r=>r.url==t.url);i!=null?i.ids.push(...t.ids):this.engine.engineStatus.highlightModels.push(t)})}unhighlightModel(e){e.forEach(t=>{let n=new Map;t.ids.forEach(i=>{let r=this.engine.models.find(o=>o.url==t.url).nodesMap.get(i);r!=null&&r.indexes!=null&&r.indexes.forEach(o=>{this.getSceneModel(o[0])instanceof y.InstancedMesh?n.has(o[0])?n.get(o[0])?.push(o[1]):n.set(o[0],[o[1]]):this.getSceneModel(o[0]).geometry.groups[o[1]].materialIndex=0})}),Jh(n,this.engine,"highlightModel")})}unhighlightAllModels(e=!0){this.engine.engineStatus.highlightModels.forEach(t=>{this.unhighlightModel([t])}),e&&(this.engine.engineStatus.highlightModels=[])}hideModel(e){e.forEach(t=>{let n=new Map;t.ids.forEach(r=>{let o=this.engine.models.find(a=>a.url==t.url).nodesMap.get(r);this.engine.modelEdge.hideModelEdge(t.url,r),o!=null&&o.indexes!=null&&o.indexes.forEach(a=>{const l=this.getSceneModel(a[0]);l instanceof y.InstancedMesh?n.has(a[0])?n.get(a[0])?.push(a[1]):n.set(a[0],[a[1]]):(this.split_merge_model(this.getSceneModel(a[0])),l.geometry.groups[a[1]].materialIndex=-1,l.geometry.groups[a[1]].visible=!1)})}),n.size>0&&W_(n,this.engine);let i=this.engine.engineStatus.hideModels.find(r=>r.url==t.url);i!=null?i.ids.push(...t.ids):this.engine.engineStatus.hideModels.push({url:t.url,ids:t.ids}),this.engine.engineStatus.highlightModels=[]})}showModel(e){e.forEach(t=>{let n=new Map;t.ids.forEach(r=>{let o=this.engine.models.find(a=>a.url==t.url).nodesMap.get(r);this.engine.modelEdge.showModelEdge(t.url,r),o!=null&&o.indexes!=null&&o.indexes.forEach(a=>{const l=this.getSceneModel(a[0]);l instanceof y.InstancedMesh?n.has(a[0])?n.get(a[0])?.push(a[1]):n.set(a[0],[a[1]]):(l.geometry.groups[a[1]].materialIndex=0,l.geometry.groups[a[1]].visible=!0)})}),n.size>0&&Qh(n,this.engine);let i=this.engine.engineStatus.hideModels.find(r=>r.url==t.url);i&&(t.ids.forEach(r=>{const o=i.ids.indexOf(r);o!==-1&&i.ids.splice(o,1)}),i.ids.length===0&&(this.engine.engineStatus.hideModels=this.engine.engineStatus.hideModels.filter(r=>r!==i)))})}isolateModel(e){let t=[];this.engine.models.forEach(n=>{let i={url:n.url,ids:[]},r=e.find(o=>o.url==n.url);for(let o of n.nodesMap)r==null?i.ids.push(o[0]):r.ids.includes(o[0])||i.ids.push(o[0]);t.push(i)});debugger;this.unhighlightAllModels(),this.hideModel(t)}translucentOtherModel(e){let t=[];this.engine.models.forEach(n=>{let i={url:n.url,ids:[]},r=e.find(o=>o.url==n.url);for(let o of n.nodesMap)r==null?i.ids.push(o[0]):r.ids.includes(o[0])||i.ids.push(o[0]);t.push(i)}),this.translucentModel(t)}setModelColor(e,t){e.material.color.set(t)}setAllModelsColor(e){this.engine.scene.children.forEach(t=>{t.isMesh})}restoreAllModelsColor(){this.engine.scene.children.forEach(e=>{e.isMesh})}translucentModel(e){this.unhighlightAllModels(),e.forEach(t=>{let n=new Map;t.ids.forEach(r=>{let o=this.engine.models.find(a=>a.url==t.url).nodesMap.get(r);o!=null&&o.indexes!=null&&o.indexes.forEach(a=>{const l=this.getSceneModel(a[0]);l instanceof y.InstancedMesh?n.has(a[0])?n.get(a[0])?.push(a[1]):n.set(a[0],[a[1]]):(this.split_merge_model(this.getSceneModel(a[0])),l.geometry.groups[a[1]].materialIndex=2)})}),G_(n,this.engine);let i=this.engine.engineStatus.translucentModels.find(r=>r.url==t.url);i!=null?i.ids.push(...t.ids):this.engine.engineStatus.translucentModels.push({url:t.url,ids:t.ids})}),this.engine.engineStatus.highlightModels=[]}unTranslucentModel(){this.engine.engineStatus.translucentModels.forEach(t=>{let n=new Map;t.ids.forEach(i=>{let r=this.engine.models.find(o=>o.url==t.url).nodesMap.get(i);r!=null&&r.indexes!=null&&r.indexes.forEach(o=>{const a=this.getSceneModel(o[0]);a instanceof y.InstancedMesh?n.has(o[0])?n.get(o[0])?.push(o[1]):n.set(o[0],[o[1]]):(this.split_merge_model(this.getSceneModel(o[0])),a.geometry.groups[o[1]].materialIndex=0)})}),n.size>0&&Qh(n,this.engine),Jh(n,this.engine,"translucentModel")}),this.engine.engineStatus.translucentModels=[]}showAllModels(){this.engine.engineStatus.hideModels&&this.engine.engineStatus.hideModels.length>0&&this.showModel(this.engine.engineStatus.hideModels),this.engine.engineStatus.hideModels=[],this.unhighlightAllModels()}batchSelectSameLevelTypeModel(e){if(e.length==0)return;let t=e[0],n=this.engine.modelMapperBatch.getModelMapper(t.url,t.ids[0]);this.engine.modelMapperBatch.getModelsWithLevelType(n.levelName,n.typeName,i=>{this.engine.modelToolModule.highlightModel(i)})}batchSelectSameLevelModel(e){if(e.length==0)return;let t=e[0],n=this.engine.modelMapperBatch.getModelMapper(t.url,t.ids[0]);this.engine.modelMapperBatch.getModelsWithLevel(n.levelName,i=>{this.engine.modelToolModule.highlightModel(i)})}batchSelectSameTypeModel(e){if(e.length==0)return;let t=e[0],n=this.engine.modelMapperBatch.getModelMapper(t.url,t.ids[0]);this.engine.modelMapperBatch.getModelsWithType(n.typeName,i=>{this.engine.modelToolModule.highlightModel(i)})}}function V_(s,e){s.forEach((t,n)=>{const i=Ts(e,n);if(!(i instanceof y.InstancedMesh))return;const r=i.geometry,o=new y.MeshBasicMaterial({color:43775,depthTest:!1,depthWrite:!1,transparent:!0,opacity:.5,side:y.DoubleSide}),a=new y.InstancedMesh(r,o,t.length);a.name="highlightModel",a.key=n;const l=new Map,c=new y.Matrix4,h=new y.Matrix4;h.makeScale(0,0,0),t.forEach((d,g)=>{i.getMatrixAt(d,c),l.set(d,c.clone()),i.setMatrixAt(d,h),a.setMatrixAt(g,c)}),i.instanceMatrix.needsUpdate=!0,a.instanceMatrix.needsUpdate=!0,e.scene.add(a)})}function Jh(s,e,t){s.forEach((n,i)=>{const r=Ts(e,i);if(!(r instanceof y.InstancedMesh))return;n.forEach(a=>{const l=r.matrixsClone[a];l&&r.setMatrixAt(a,l)}),r.instanceMatrix.needsUpdate=!0,e.scene.children.filter(a=>a.key==i&&a.name==t).forEach(a=>{e.scene.remove(a)})})}function G_(s,e){s.forEach((t,n)=>{const i=Ts(e,n);if(!(i instanceof y.InstancedMesh))return;const r=i.geometry,o=new y.MeshBasicMaterial({color:16777215,transparent:!0,opacity:.05,side:y.DoubleSide}),a=new y.InstancedMesh(r,o,t.length);a.name="translucentModel",a.key=n;const l=new Map,c=new y.Matrix4,h=new y.Matrix4;h.makeScale(0,0,0),t.forEach((d,g)=>{i.getMatrixAt(d,c),l.set(d,c.clone()),i.setMatrixAt(d,h),a.setMatrixAt(g,c)}),i.instanceMatrix.needsUpdate=!0,a.instanceMatrix.needsUpdate=!0,e.scene.add(a)})}function W_(s,e){e.scene.children.filter(t=>t.name=="highlightModel").forEach(t=>{e.scene.remove(t)}),s.forEach((t,n)=>{const i=Ts(e,n);if(!(i instanceof y.InstancedMesh))return;const r=new Map,o=new y.Matrix4,a=new y.Matrix4;a.makeScale(0,0,0),t.forEach((l,c)=>{i.getMatrixAt(l,o),r.set(l,o.clone()),i.setMatrixAt(l,a)}),i.instanceMatrix.needsUpdate=!0})}function Qh(s,e){s.forEach((t,n)=>{const i=Ts(e,n);i instanceof y.InstancedMesh&&(t.forEach(r=>{const o=i.matrixs[r];o&&i.setMatrixAt(r,o)}),i.instanceMatrix.needsUpdate=!0)})}function Ts(s,e){return s.scene.children.find(t=>t.index==e)}class H_{engine;currentMode="";isManualMode=!1;gtaoPass=null;ssaoPass=null;saturationPass=null;outputPass=null;fxaaPass=null;constructor(e){this.engine=e}init(){this.cachePassReferences(),this.autoSwitch("advanced")}switchModel(e){this.isManualMode=!0,this.currentMode=e,this.applyMode(e)}autoSwitch(e){this.isManualMode||(this.currentMode=e,this.applyMode(e))}enableAutoMode(){this.isManualMode=!1}get isManual(){return this.isManualMode}setMode(e){debugger;this.isManualMode=!0,this.currentMode=e,this.applyMode(e)}getCurrentMode(){return this.currentMode}cachePassReferences(){this.engine.composerModule?.composer&&(this.engine.composerModule.gtaoPass&&(this.gtaoPass=this.engine.composerModule.gtaoPass),this.engine.composerModule.ssaoPass&&(this.ssaoPass=this.engine.composerModule.ssaoPass),this.engine.composerModule.saturationPass&&(this.saturationPass=this.engine.composerModule.saturationPass),this.engine.composerModule.outputPass&&(this.outputPass=this.engine.composerModule.outputPass),this.engine.composerModule.fxaaPass&&(this.fxaaPass=this.engine.composerModule.fxaaPass))}applyMode(e){switch(e){case"simple":this.setShadows(!1),this.setGTAO(!1),this.setSSAO(!1),this.setSaturation(!1),this.setOutputPass(!1),this.setFXAA(!0);break;case"balance":this.setShadows(!0),this.setGTAO(!1),this.setSSAO(!1),this.setSaturation(!1),this.setOutputPass(!1),this.setFXAA(!0);break;case"advanced":this.setShadows(!0),this.setSSAO(!1),this.setGTAO(!0),this.setSaturation(!1),this.setOutputPass(!1),this.setFXAA(!0);break;default:console.warn(`[EngineModelModule] Unknown mode: ${e}`)}this.engine.updateVersionDisplay?.()}setShadows(e){this.engine.renderer&&(this.engine.renderer.shadowMap.enabled=e);const t=this.engine.scene?.children.find(n=>n instanceof y.DirectionalLight);t&&(t.castShadow=e),this.engine.scene?.traverse(n=>{n.material&&(n.castShadow!==void 0&&(n.castShadow=e),n.receiveShadow!==void 0&&(n.receiveShadow=e))})}setGTAO(e){this.engine.composerModule?.composer&&this.gtaoPass&&(this.gtaoPass.enabled=e)}setSSAO(e){this.engine.composerModule?.composer&&this.ssaoPass&&(this.ssaoPass.enabled=e)}setSaturation(e){this.saturationPass&&(this.saturationPass.enabled=e)}setOutputPass(e){this.outputPass&&(this.outputPass.enabled=e)}setFXAA(e){this.fxaaPass&&(this.fxaaPass.enabled=e)}setPerformanceMode(){this.setMode("simple")}setBalancedMode(){this.setMode("balance")}setQualityMode(){this.setMode("advanced")}setSuperQualityMode(){this.setMode("superAdvanced")}setShadowQuality(e){const t=this.engine.scene?.children.find(r=>r instanceof y.DirectionalLight),i={low:1024,medium:2048,high:2048}[e];t?.shadow&&i&&(t.shadow.mapSize.width=i,t.shadow.mapSize.height=i,t.shadow.map?.dispose(),t.shadow.map=null)}setSaturationValue(e){this.saturationPass&&(this.saturationPass.uniforms.saturation.value=e)}setContrastValue(e){this.saturationPass&&(this.saturationPass.uniforms.contrast.value=e)}setGTAOIntensity(e){this.gtaoPass&&(this.gtaoPass.blendIntensity=e)}}class Xr{engine;overlayMaterial;overlayMeshes=[];animState="idle";animStartTime=0;static FADE_IN_MS=200;static FADE_OUT_MS=150;tagDiv;constructor(e){this.engine=e,this.init();const t=document.createElement("div");this.tagDiv=t,t.className="tagDiv",t.style.position="absolute",t.style.top="0px",t.style.left="0px",t.style.borderRadius="10px",t.style.pointerEvents="none",this.engine.container.appendChild(this.tagDiv)}showModelNameTag(e,t){if(e==null){this.tagDiv.style.display="none";return}let n=this.engine.models.find(a=>a.url==e.url);if(n==null){this.tagDiv.style.display="none";return}let i=n.nodesMap.get(e.ids[0]);if(i.infos&&i.infos.length>0){let a=i.infos[0].name.replace(/\s*\[[a-f0-9-]+\]$/,"");this.tagDiv.innerHTML=a}const o=this.engine.worldToScreen.worldToScreen(t);this.tagDiv?(this.tagDiv.style.left=o.x+10+this.engine.reactBoundingClientRect.left+"px",this.tagDiv.style.top=o.y-10+this.engine.reactBoundingClientRect.top+"px",this.tagDiv.style.display="block"):this.tagDiv&&(this.tagDiv.style.display="none")}init(){this.overlayMaterial=new y.MeshBasicMaterial({color:16777215,transparent:!0,opacity:0,blending:y.AdditiveBlending,depthWrite:!1}),this.overlayMaterial.clippingPlanes=this.engine.sectionPlane}hightMesh(e,t=16777215,n=.15){this.animState==="fadeOut"&&this.removeOverlayMeshes();const i=(Array.isArray(e)?e:e?[e]:[]).filter(r=>r?.geometry);if(i.length===0){this.clearHighlight();return}this.overlayMaterial.color.set(t),this.overlayMaterial.opacity=0,this.overlayMaterial.userData.targetOpacity=n;for(const r of i){let o=r.geometry.clone();o.computeVertexNormals();const a=new y.Mesh(o,this.overlayMaterial);r.updateWorldMatrix(!0,!1),a.matrix.copy(r.matrixWorld),a.matrixAutoUpdate=!1,this.engine.scene.add(a),this.overlayMeshes.push(a)}this.animState="fadeIn",this.animStartTime=performance.now()}clearHighlight(){this.overlayMeshes.length===0||this.animState==="fadeOut"||(this.animState="fadeOut",this.animStartTime=performance.now())}update(){if(this.animState==="idle"||this.overlayMeshes.length===0)return;const e=performance.now()-this.animStartTime,t=this.overlayMaterial.userData.targetOpacity??.35;if(this.animState==="fadeIn"){const n=Math.min(e/Xr.FADE_IN_MS,1);this.overlayMaterial.opacity=this.easeOutQuad(n)*t,n>=1&&(this.animState="idle")}else if(this.animState==="fadeOut"){const n=Math.min(e/Xr.FADE_OUT_MS,1);this.overlayMaterial.opacity=(1-this.easeOutQuad(n))*t,n>=1&&(this.removeOverlayMeshes(),this.animState="idle")}}removeOverlayMeshes(){for(const e of this.overlayMeshes)this.engine.scene.remove(e);this.overlayMeshes=[]}easeOutQuad(e){return 1-(1-e)*(1-e)}dispose(){this.removeOverlayMeshes(),this.overlayMaterial.dispose(),this.animState="idle"}}var jr={exports:{}},X_=jr.exports,ed;function j_(){return ed||(ed=1,(function(s,e){(function(t,n){s.exports=n()})(X_,function(){var t=function(){function n(u){return o.appendChild(u.dom),u}function i(u){for(var m=0;m<o.children.length;m++)o.children[m].style.display=m===u?"block":"none";r=u}var r=0,o=document.createElement("div");o.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",o.addEventListener("click",function(u){u.preventDefault(),i(++r%o.children.length)},!1);var a=(performance||Date).now(),l=a,c=0,h=n(new t.Panel("FPS","#0ff","#002")),d=n(new t.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var g=n(new t.Panel("MB","#f08","#201"));return i(0),{REVISION:16,dom:o,addPanel:n,showPanel:i,begin:function(){a=(performance||Date).now()},end:function(){c++;var u=(performance||Date).now();if(d.update(u-a,200),u>l+1e3&&(h.update(1e3*c/(u-l),100),l=u,c=0,g)){var m=performance.memory;g.update(m.usedJSHeapSize/1048576,m.jsHeapSizeLimit/1048576)}return u},update:function(){a=this.end()},domElement:o,setMode:i}};return t.Panel=function(n,i,r){var o=1/0,a=0,l=Math.round,c=l(window.devicePixelRatio||1),h=80*c,d=48*c,g=3*c,u=2*c,m=3*c,f=15*c,p=74*c,x=30*c,v=document.createElement("canvas");v.width=h,v.height=d,v.style.cssText="width:80px;height:48px";var _=v.getContext("2d");return _.font="bold "+9*c+"px Helvetica,Arial,sans-serif",_.textBaseline="top",_.fillStyle=r,_.fillRect(0,0,h,d),_.fillStyle=i,_.fillText(n,g,u),_.fillRect(m,f,p,x),_.fillStyle=r,_.globalAlpha=.9,_.fillRect(m,f,p,x),{dom:v,update:function(b,S){o=Math.min(o,b),a=Math.max(a,b),_.fillStyle=r,_.globalAlpha=1,_.fillRect(0,0,h,f),_.fillStyle=i,_.fillText(l(b)+" "+n+" ("+l(o)+"-"+l(a)+")",g,u),_.drawImage(v,m+c,f,p-c,x,m,f,p-c,x),_.fillRect(m+p-c,f,c,x),_.fillStyle=r,_.globalAlpha=.9,_.fillRect(m+p-c,f,c,l((1-b/S)*x))}}},t})})(jr)),jr.exports}var Y_=j_();const q_=Wc(Y_);var ns=Object.freeze({Linear:Object.freeze({None:function(s){return s},In:function(s){return s},Out:function(s){return s},InOut:function(s){return s}}),Quadratic:Object.freeze({In:function(s){return s*s},Out:function(s){return s*(2-s)},InOut:function(s){return(s*=2)<1?.5*s*s:-.5*(--s*(s-2)-1)}}),Cubic:Object.freeze({In:function(s){return s*s*s},Out:function(s){return--s*s*s+1},InOut:function(s){return(s*=2)<1?.5*s*s*s:.5*((s-=2)*s*s+2)}}),Quartic:Object.freeze({In:function(s){return s*s*s*s},Out:function(s){return 1- --s*s*s*s},InOut:function(s){return(s*=2)<1?.5*s*s*s*s:-.5*((s-=2)*s*s*s-2)}}),Quintic:Object.freeze({In:function(s){return s*s*s*s*s},Out:function(s){return--s*s*s*s*s+1},InOut:function(s){return(s*=2)<1?.5*s*s*s*s*s:.5*((s-=2)*s*s*s*s+2)}}),Sinusoidal:Object.freeze({In:function(s){return 1-Math.sin((1-s)*Math.PI/2)},Out:function(s){return Math.sin(s*Math.PI/2)},InOut:function(s){return .5*(1-Math.sin(Math.PI*(.5-s)))}}),Exponential:Object.freeze({In:function(s){return s===0?0:Math.pow(1024,s-1)},Out:function(s){return s===1?1:1-Math.pow(2,-10*s)},InOut:function(s){return s===0?0:s===1?1:(s*=2)<1?.5*Math.pow(1024,s-1):.5*(-Math.pow(2,-10*(s-1))+2)}}),Circular:Object.freeze({In:function(s){return 1-Math.sqrt(1-s*s)},Out:function(s){return Math.sqrt(1- --s*s)},InOut:function(s){return(s*=2)<1?-.5*(Math.sqrt(1-s*s)-1):.5*(Math.sqrt(1-(s-=2)*s)+1)}}),Elastic:Object.freeze({In:function(s){return s===0?0:s===1?1:-Math.pow(2,10*(s-1))*Math.sin((s-1.1)*5*Math.PI)},Out:function(s){return s===0?0:s===1?1:Math.pow(2,-10*s)*Math.sin((s-.1)*5*Math.PI)+1},InOut:function(s){return s===0?0:s===1?1:(s*=2,s<1?-.5*Math.pow(2,10*(s-1))*Math.sin((s-1.1)*5*Math.PI):.5*Math.pow(2,-10*(s-1))*Math.sin((s-1.1)*5*Math.PI)+1)}}),Back:Object.freeze({In:function(s){var e=1.70158;return s===1?1:s*s*((e+1)*s-e)},Out:function(s){var e=1.70158;return s===0?0:--s*s*((e+1)*s+e)+1},InOut:function(s){var e=2.5949095;return(s*=2)<1?.5*(s*s*((e+1)*s-e)):.5*((s-=2)*s*((e+1)*s+e)+2)}}),Bounce:Object.freeze({In:function(s){return 1-ns.Bounce.Out(1-s)},Out:function(s){return s<1/2.75?7.5625*s*s:s<2/2.75?7.5625*(s-=1.5/2.75)*s+.75:s<2.5/2.75?7.5625*(s-=2.25/2.75)*s+.9375:7.5625*(s-=2.625/2.75)*s+.984375},InOut:function(s){return s<.5?ns.Bounce.In(s*2)*.5:ns.Bounce.Out(s*2-1)*.5+.5}}),generatePow:function(s){return s===void 0&&(s=4),s=s<Number.EPSILON?Number.EPSILON:s,s=s>1e4?1e4:s,{In:function(e){return Math.pow(e,s)},Out:function(e){return 1-Math.pow(1-e,s)},InOut:function(e){return e<.5?Math.pow(e*2,s)/2:(1-Math.pow(2-e*2,s))/2+.5}}}}),Ps=function(){return performance.now()},Z_=(function(){function s(){this._tweens={},this._tweensAddedDuringUpdate={}}return s.prototype.getAll=function(){var e=this;return Object.keys(this._tweens).map(function(t){return e._tweens[t]})},s.prototype.removeAll=function(){this._tweens={}},s.prototype.add=function(e){this._tweens[e.getId()]=e,this._tweensAddedDuringUpdate[e.getId()]=e},s.prototype.remove=function(e){delete this._tweens[e.getId()],delete this._tweensAddedDuringUpdate[e.getId()]},s.prototype.update=function(e,t){e===void 0&&(e=Ps()),t===void 0&&(t=!1);var n=Object.keys(this._tweens);if(n.length===0)return!1;for(;n.length>0;){this._tweensAddedDuringUpdate={};for(var i=0;i<n.length;i++){var r=this._tweens[n[i]],o=!t;r&&r.update(e,o)===!1&&!t&&delete this._tweens[n[i]]}n=Object.keys(this._tweensAddedDuringUpdate)}return!0},s})(),Qa={Linear:function(s,e){var t=s.length-1,n=t*e,i=Math.floor(n),r=Qa.Utils.Linear;return e<0?r(s[0],s[1],n):e>1?r(s[t],s[t-1],t-n):r(s[i],s[i+1>t?t:i+1],n-i)},Utils:{Linear:function(s,e,t){return(e-s)*t+s}}},td=(function(){function s(){}return s.nextId=function(){return s._nextId++},s._nextId=0,s})(),el=new Z_,K_=(function(){function s(e,t){t===void 0&&(t=el),this._object=e,this._group=t,this._isPaused=!1,this._pauseStart=0,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._isDynamic=!1,this._initialRepeat=0,this._repeat=0,this._yoyo=!1,this._isPlaying=!1,this._reversed=!1,this._delayTime=0,this._startTime=0,this._easingFunction=ns.Linear.None,this._interpolationFunction=Qa.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=td.nextId(),this._isChainStopped=!1,this._propertiesAreSetUp=!1,this._goToEnd=!1}return s.prototype.getId=function(){return this._id},s.prototype.isPlaying=function(){return this._isPlaying},s.prototype.isPaused=function(){return this._isPaused},s.prototype.getDuration=function(){return this._duration},s.prototype.to=function(e,t){if(t===void 0&&(t=1e3),this._isPlaying)throw new Error("Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.");return this._valuesEnd=e,this._propertiesAreSetUp=!1,this._duration=t<0?0:t,this},s.prototype.duration=function(e){return e===void 0&&(e=1e3),this._duration=e<0?0:e,this},s.prototype.dynamic=function(e){return e===void 0&&(e=!1),this._isDynamic=e,this},s.prototype.start=function(e,t){if(e===void 0&&(e=Ps()),t===void 0&&(t=!1),this._isPlaying)return this;if(this._group&&this._group.add(this),this._repeat=this._initialRepeat,this._reversed){this._reversed=!1;for(var n in this._valuesStartRepeat)this._swapEndStartRepeatValues(n),this._valuesStart[n]=this._valuesStartRepeat[n]}if(this._isPlaying=!0,this._isPaused=!1,this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._isChainStopped=!1,this._startTime=e,this._startTime+=this._delayTime,!this._propertiesAreSetUp||t){if(this._propertiesAreSetUp=!0,!this._isDynamic){var i={};for(var r in this._valuesEnd)i[r]=this._valuesEnd[r];this._valuesEnd=i}this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat,t)}return this},s.prototype.startFromCurrentValues=function(e){return this.start(e,!0)},s.prototype._setupProperties=function(e,t,n,i,r){for(var o in n){var a=e[o],l=Array.isArray(a),c=l?"array":typeof a,h=!l&&Array.isArray(n[o]);if(!(c==="undefined"||c==="function")){if(h){var d=n[o];if(d.length===0)continue;for(var g=[a],u=0,m=d.length;u<m;u+=1){var f=this._handleRelativeValue(a,d[u]);if(isNaN(f)){h=!1,console.warn("Found invalid interpolation list. Skipping.");break}g.push(f)}h&&(n[o]=g)}if((c==="object"||l)&&a&&!h){t[o]=l?[]:{};var p=a;for(var x in p)t[o][x]=p[x];i[o]=l?[]:{};var d=n[o];if(!this._isDynamic){var v={};for(var x in d)v[x]=d[x];n[o]=d=v}this._setupProperties(p,t[o],d,i[o],r)}else(typeof t[o]>"u"||r)&&(t[o]=a),l||(t[o]*=1),h?i[o]=n[o].slice().reverse():i[o]=t[o]||0}}},s.prototype.stop=function(){return this._isChainStopped||(this._isChainStopped=!0,this.stopChainedTweens()),this._isPlaying?(this._group&&this._group.remove(this),this._isPlaying=!1,this._isPaused=!1,this._onStopCallback&&this._onStopCallback(this._object),this):this},s.prototype.end=function(){return this._goToEnd=!0,this.update(1/0),this},s.prototype.pause=function(e){return e===void 0&&(e=Ps()),this._isPaused||!this._isPlaying?this:(this._isPaused=!0,this._pauseStart=e,this._group&&this._group.remove(this),this)},s.prototype.resume=function(e){return e===void 0&&(e=Ps()),!this._isPaused||!this._isPlaying?this:(this._isPaused=!1,this._startTime+=e-this._pauseStart,this._pauseStart=0,this._group&&this._group.add(this),this)},s.prototype.stopChainedTweens=function(){for(var e=0,t=this._chainedTweens.length;e<t;e++)this._chainedTweens[e].stop();return this},s.prototype.group=function(e){return e===void 0&&(e=el),this._group=e,this},s.prototype.delay=function(e){return e===void 0&&(e=0),this._delayTime=e,this},s.prototype.repeat=function(e){return e===void 0&&(e=0),this._initialRepeat=e,this._repeat=e,this},s.prototype.repeatDelay=function(e){return this._repeatDelayTime=e,this},s.prototype.yoyo=function(e){return e===void 0&&(e=!1),this._yoyo=e,this},s.prototype.easing=function(e){return e===void 0&&(e=ns.Linear.None),this._easingFunction=e,this},s.prototype.interpolation=function(e){return e===void 0&&(e=Qa.Linear),this._interpolationFunction=e,this},s.prototype.chain=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return this._chainedTweens=e,this},s.prototype.onStart=function(e){return this._onStartCallback=e,this},s.prototype.onEveryStart=function(e){return this._onEveryStartCallback=e,this},s.prototype.onUpdate=function(e){return this._onUpdateCallback=e,this},s.prototype.onRepeat=function(e){return this._onRepeatCallback=e,this},s.prototype.onComplete=function(e){return this._onCompleteCallback=e,this},s.prototype.onStop=function(e){return this._onStopCallback=e,this},s.prototype.update=function(e,t){var n=this,i;if(e===void 0&&(e=Ps()),t===void 0&&(t=!0),this._isPaused)return!0;var r,o=this._startTime+this._duration;if(!this._goToEnd&&!this._isPlaying){if(e>o)return!1;t&&this.start(e,!0)}if(this._goToEnd=!1,e<this._startTime)return!0;this._onStartCallbackFired===!1&&(this._onStartCallback&&this._onStartCallback(this._object),this._onStartCallbackFired=!0),this._onEveryStartCallbackFired===!1&&(this._onEveryStartCallback&&this._onEveryStartCallback(this._object),this._onEveryStartCallbackFired=!0);var a=e-this._startTime,l=this._duration+((i=this._repeatDelayTime)!==null&&i!==void 0?i:this._delayTime),c=this._duration+this._repeat*l,h=function(){if(n._duration===0||a>c)return 1;var p=Math.trunc(a/l),x=a-p*l,v=Math.min(x/n._duration,1);return v===0&&a===n._duration?1:v},d=h(),g=this._easingFunction(d);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,g),this._onUpdateCallback&&this._onUpdateCallback(this._object,d),this._duration===0||a>=this._duration)if(this._repeat>0){var u=Math.min(Math.trunc((a-this._duration)/l)+1,this._repeat);isFinite(this._repeat)&&(this._repeat-=u);for(r in this._valuesStartRepeat)!this._yoyo&&typeof this._valuesEnd[r]=="string"&&(this._valuesStartRepeat[r]=this._valuesStartRepeat[r]+parseFloat(this._valuesEnd[r])),this._yoyo&&this._swapEndStartRepeatValues(r),this._valuesStart[r]=this._valuesStartRepeat[r];return this._yoyo&&(this._reversed=!this._reversed),this._startTime+=l*u,this._onRepeatCallback&&this._onRepeatCallback(this._object),this._onEveryStartCallbackFired=!1,!0}else{this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var m=0,f=this._chainedTweens.length;m<f;m++)this._chainedTweens[m].start(this._startTime+this._duration,!1);return this._isPlaying=!1,!1}return!0},s.prototype._updateProperties=function(e,t,n,i){for(var r in n)if(t[r]!==void 0){var o=t[r]||0,a=n[r],l=Array.isArray(e[r]),c=Array.isArray(a),h=!l&&c;h?e[r]=this._interpolationFunction(a,i):typeof a=="object"&&a?this._updateProperties(e[r],o,a,i):(a=this._handleRelativeValue(o,a),typeof a=="number"&&(e[r]=o+(a-o)*i))}},s.prototype._handleRelativeValue=function(e,t){return typeof t!="string"?t:t.charAt(0)==="+"||t.charAt(0)==="-"?e+parseFloat(t):parseFloat(t)},s.prototype._swapEndStartRepeatValues=function(e){var t=this._valuesStartRepeat[e],n=this._valuesEnd[e];typeof n=="string"?this._valuesStartRepeat[e]=this._valuesStartRepeat[e]+parseFloat(n):this._valuesStartRepeat[e]=this._valuesEnd[e],this._valuesEnd[e]=t},s})();td.nextId;var vn=el;vn.getAll.bind(vn),vn.removeAll.bind(vn),vn.add.bind(vn),vn.remove.bind(vn),vn.update.bind(vn);var Ds={Easing:ns,Tween:K_};const nd={type:"change"},tl={type:"start"},id={type:"end"},Yr=new M.Ray,sd=new M.Plane,$_=Math.cos(70*M.MathUtils.DEG2RAD),Tt=new M.Vector3,Gt=2*Math.PI,lt={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},nl=1e-6;class J_ extends M.Controls{constructor(e,t=null){super(e,t),this.state=lt.NONE,this.target=new M.Vector3,this.cursor=new M.Vector3,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:M.MOUSE.ROTATE,MIDDLE:M.MOUSE.DOLLY,RIGHT:M.MOUSE.PAN},this.touches={ONE:M.TOUCH.ROTATE,TWO:M.TOUCH.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._cursorStyle="auto",this._domElementKeyEvents=null,this._lastPosition=new M.Vector3,this._lastQuaternion=new M.Quaternion,this._lastTargetPosition=new M.Vector3,this._quat=new M.Quaternion().setFromUnitVectors(e.up,new M.Vector3(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new M.Spherical,this._sphericalDelta=new M.Spherical,this._scale=1,this._panOffset=new M.Vector3,this._rotateStart=new M.Vector2,this._rotateEnd=new M.Vector2,this._rotateDelta=new M.Vector2,this._panStart=new M.Vector2,this._panEnd=new M.Vector2,this._panDelta=new M.Vector2,this._dollyStart=new M.Vector2,this._dollyEnd=new M.Vector2,this._dollyDelta=new M.Vector2,this._dollyDirection=new M.Vector3,this._mouse=new M.Vector2,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=ey.bind(this),this._onPointerDown=Q_.bind(this),this._onPointerUp=ty.bind(this),this._onContextMenu=ly.bind(this),this._onMouseWheel=sy.bind(this),this._onKeyDown=ry.bind(this),this._onTouchStart=oy.bind(this),this._onTouchMove=ay.bind(this),this._onMouseDown=ny.bind(this),this._onMouseMove=iy.bind(this),this._interceptControlDown=cy.bind(this),this._interceptControlUp=hy.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}set cursorStyle(e){this._cursorStyle=e,e==="grab"?this.domElement.style.cursor="grab":this.domElement.style.cursor="auto"}get cursorStyle(){return this._cursorStyle}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(nd),this.update(),this.state=lt.NONE}pan(e,t){this._pan(e,t),this.update()}dollyIn(e){this._dollyIn(e),this.update()}dollyOut(e){this._dollyOut(e),this.update()}rotateLeft(e){this._rotateLeft(e),this.update()}rotateUp(e){this._rotateUp(e),this.update()}update(e=null){const t=this.object.position;Tt.copy(t).sub(this.target),Tt.applyQuaternion(this._quat),this._spherical.setFromVector3(Tt),this.autoRotate&&this.state===lt.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let n=this.minAzimuthAngle,i=this.maxAzimuthAngle;isFinite(n)&&isFinite(i)&&(n<-Math.PI?n+=Gt:n>Math.PI&&(n-=Gt),i<-Math.PI?i+=Gt:i>Math.PI&&(i-=Gt),n<=i?this._spherical.theta=Math.max(n,Math.min(i,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+i)/2?Math.max(n,this._spherical.theta):Math.min(i,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let r=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const o=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=o!=this._spherical.radius}if(Tt.setFromSpherical(this._spherical),Tt.applyQuaternion(this._quatInverse),t.copy(this.target).add(Tt),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let o=null;if(this.object.isPerspectiveCamera){const a=Tt.length();o=this._clampDistance(a*this._scale);const l=a-o;this.object.position.addScaledVector(this._dollyDirection,l),this.object.updateMatrixWorld(),r=!!l}else if(this.object.isOrthographicCamera){const a=new M.Vector3(this._mouse.x,this._mouse.y,0);a.unproject(this.object);const l=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=l!==this.object.zoom;const c=new M.Vector3(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(a),this.object.updateMatrixWorld(),o=Tt.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;o!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(o).add(this.object.position):(Yr.origin.copy(this.object.position),Yr.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Yr.direction))<$_?this.object.lookAt(this.target):(sd.setFromNormalAndCoplanarPoint(this.object.up,this.target),Yr.intersectPlane(sd,this.target))))}else if(this.object.isOrthographicCamera){const o=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),o!==this.object.zoom&&(this.object.updateProjectionMatrix(),r=!0)}return this._scale=1,this._performCursorZoom=!1,r||this._lastPosition.distanceToSquared(this.object.position)>nl||8*(1-this._lastQuaternion.dot(this.object.quaternion))>nl||this._lastTargetPosition.distanceToSquared(this.target)>nl?(this.dispatchEvent(nd),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?Gt/60*this.autoRotateSpeed*e:Gt/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){Tt.setFromMatrixColumn(t,0),Tt.multiplyScalar(-e),this._panOffset.add(Tt)}_panUp(e,t){this.screenSpacePanning===!0?Tt.setFromMatrixColumn(t,1):(Tt.setFromMatrixColumn(t,0),Tt.crossVectors(this.object.up,Tt)),Tt.multiplyScalar(e),this._panOffset.add(Tt)}_pan(e,t){const n=this.domElement;if(this.object.isPerspectiveCamera){const i=this.object.position;Tt.copy(i).sub(this.target);let r=Tt.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*r/n.clientHeight,this.object.matrix),this._panUp(2*t*r/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const n=this.domElement.getBoundingClientRect(),i=e-n.left,r=t-n.top,o=n.width,a=n.height;this._mouse.x=i/o*2-1,this._mouse.y=-(r/a)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(Gt*this._rotateDelta.x/t.clientHeight),this._rotateUp(Gt*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(Gt*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-Gt*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(Gt*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-Gt*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);this._rotateStart.set(n,i)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);this._panStart.set(n,i)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,i=e.pageY-t.y,r=Math.sqrt(n*n+i*i);this._dollyStart.set(0,r)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),i=.5*(e.pageX+n.x),r=.5*(e.pageY+n.y);this._rotateEnd.set(i,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(Gt*this._rotateDelta.x/t.clientHeight),this._rotateUp(Gt*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);this._panEnd.set(n,i)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,i=e.pageY-t.y,r=Math.sqrt(n*n+i*i);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const o=(e.pageX+t.x)*.5,a=(e.pageY+t.y)*.5;this._updateZoomParameters(o,a)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];t===void 0&&(t=new M.Vector2,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){const t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){const t=e.deltaMode,n={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(n.deltaY*=10),n}}function Q_(s){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(s.pointerId),this.domElement.ownerDocument.addEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(s)&&(this._addPointer(s),s.pointerType==="touch"?this._onTouchStart(s):this._onMouseDown(s),this._cursorStyle==="grab"&&(this.domElement.style.cursor="grabbing")))}function ey(s){this.enabled!==!1&&(s.pointerType==="touch"?this._onTouchMove(s):this._onMouseMove(s))}function ty(s){switch(this._removePointer(s),this._pointers.length){case 0:this.domElement.releasePointerCapture(s.pointerId),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(id),this.state=lt.NONE,this._cursorStyle==="grab"&&(this.domElement.style.cursor="grab");break;case 1:const e=this._pointers[0],t=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:t.x,pageY:t.y});break}}function ny(s){let e;switch(s.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case M.MOUSE.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(s),this.state=lt.DOLLY;break;case M.MOUSE.ROTATE:if(s.ctrlKey||s.metaKey||s.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(s),this.state=lt.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(s),this.state=lt.ROTATE}break;case M.MOUSE.PAN:if(s.ctrlKey||s.metaKey||s.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(s),this.state=lt.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(s),this.state=lt.PAN}break;default:this.state=lt.NONE}this.state!==lt.NONE&&this.dispatchEvent(tl)}function iy(s){switch(this.state){case lt.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(s);break;case lt.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(s);break;case lt.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(s);break}}function sy(s){this.enabled===!1||this.enableZoom===!1||this.state!==lt.NONE||(s.preventDefault(),this.dispatchEvent(tl),this._handleMouseWheel(this._customWheelEvent(s)),this.dispatchEvent(id))}function ry(s){this.enabled!==!1&&this._handleKeyDown(s)}function oy(s){switch(this._trackPointer(s),this._pointers.length){case 1:switch(this.touches.ONE){case M.TOUCH.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(s),this.state=lt.TOUCH_ROTATE;break;case M.TOUCH.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(s),this.state=lt.TOUCH_PAN;break;default:this.state=lt.NONE}break;case 2:switch(this.touches.TWO){case M.TOUCH.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(s),this.state=lt.TOUCH_DOLLY_PAN;break;case M.TOUCH.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(s),this.state=lt.TOUCH_DOLLY_ROTATE;break;default:this.state=lt.NONE}break;default:this.state=lt.NONE}this.state!==lt.NONE&&this.dispatchEvent(tl)}function ay(s){switch(this._trackPointer(s),this.state){case lt.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(s),this.update();break;case lt.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(s),this.update();break;case lt.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(s),this.update();break;case lt.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(s),this.update();break;default:this.state=lt.NONE}}function ly(s){this.enabled!==!1&&s.preventDefault()}function cy(s){s.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function hy(s){s.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}const wi=new M.Raycaster,It=new M.Vector3,ti=new M.Vector3,ft=new M.Quaternion,rd={X:new M.Vector3(1,0,0),Y:new M.Vector3(0,1,0),Z:new M.Vector3(0,0,1)},il={type:"change"},od={type:"mouseDown",mode:null},ad={type:"mouseUp",mode:null},ld={type:"objectChange"};class cd extends M.Controls{constructor(e,t=null){super(void 0,t);const n=new gy(this);this._root=n;const i=new xy;this._gizmo=i,n.add(i);const r=new vy;this._plane=r,n.add(r);const o=this;function a(_,b){let S=b;Object.defineProperty(o,_,{get:function(){return S!==void 0?S:b},set:function(C){S!==C&&(S=C,r[_]=C,i[_]=C,o.dispatchEvent({type:_+"-changed",value:C}),o.dispatchEvent(il))}}),o[_]=b,r[_]=b,i[_]=b}a("camera",e),a("object",void 0),a("enabled",!0),a("axis",null),a("mode","translate"),a("translationSnap",null),a("rotationSnap",null),a("scaleSnap",null),a("space","world"),a("size",1),a("dragging",!1),a("showX",!0),a("showY",!0),a("showZ",!0),a("minX",-1/0),a("maxX",1/0),a("minY",-1/0),a("maxY",1/0),a("minZ",-1/0),a("maxZ",1/0);const l=new M.Vector3,c=new M.Vector3,h=new M.Quaternion,d=new M.Quaternion,g=new M.Vector3,u=new M.Quaternion,m=new M.Vector3,f=new M.Vector3,p=new M.Vector3,x=0,v=new M.Vector3;a("worldPosition",l),a("worldPositionStart",c),a("worldQuaternion",h),a("worldQuaternionStart",d),a("cameraPosition",g),a("cameraQuaternion",u),a("pointStart",m),a("pointEnd",f),a("rotationAxis",p),a("rotationAngle",x),a("eye",v),this._offset=new M.Vector3,this._startNorm=new M.Vector3,this._endNorm=new M.Vector3,this._cameraScale=new M.Vector3,this._parentPosition=new M.Vector3,this._parentQuaternion=new M.Quaternion,this._parentQuaternionInv=new M.Quaternion,this._parentScale=new M.Vector3,this._worldScaleStart=new M.Vector3,this._worldQuaternionInv=new M.Quaternion,this._worldScale=new M.Vector3,this._positionStart=new M.Vector3,this._quaternionStart=new M.Quaternion,this._scaleStart=new M.Vector3,this._getPointer=dy.bind(this),this._onPointerDown=fy.bind(this),this._onPointerHover=uy.bind(this),this._onPointerMove=py.bind(this),this._onPointerUp=my.bind(this),t!==null&&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(this.object===void 0||this.dragging===!0)return;e!==null&&wi.setFromCamera(e,this.camera);const t=sl(this._gizmo.picker[this.mode],wi);t?this.axis=t.object.name:this.axis=null}pointerDown(e){if(!(this.object===void 0||this.dragging===!0||e!=null&&e.button!==0)&&this.axis!==null){e!==null&&wi.setFromCamera(e,this.camera);const t=sl(this._plane,wi,!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,od.mode=this.mode,this.dispatchEvent(od)}}pointerMove(e){const t=this.axis,n=this.mode,i=this.object;let r=this.space;if(n==="scale"?r="local":(t==="E"||t==="XYZE"||t==="XYZ")&&(r="world"),i===void 0||t===null||this.dragging===!1||e!==null&&e.button!==-1)return;e!==null&&wi.setFromCamera(e,this.camera);const o=sl(this._plane,wi,!0);if(o){if(this.pointEnd.copy(o.point).sub(this.worldPositionStart),n==="translate")this._offset.copy(this.pointEnd).sub(this.pointStart),r==="local"&&t!=="XYZ"&&this._offset.applyQuaternion(this._worldQuaternionInv),t.indexOf("X")===-1&&(this._offset.x=0),t.indexOf("Y")===-1&&(this._offset.y=0),t.indexOf("Z")===-1&&(this._offset.z=0),r==="local"&&t!=="XYZ"?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),i.position.copy(this._offset).add(this._positionStart),this.translationSnap&&(r==="local"&&(i.position.applyQuaternion(ft.copy(this._quaternionStart).invert()),t.search("X")!==-1&&(i.position.x=Math.round(i.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(i.position.y=Math.round(i.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(i.position.z=Math.round(i.position.z/this.translationSnap)*this.translationSnap),i.position.applyQuaternion(this._quaternionStart)),r==="world"&&(i.parent&&i.position.add(It.setFromMatrixPosition(i.parent.matrixWorld)),t.search("X")!==-1&&(i.position.x=Math.round(i.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(i.position.y=Math.round(i.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(i.position.z=Math.round(i.position.z/this.translationSnap)*this.translationSnap),i.parent&&i.position.sub(It.setFromMatrixPosition(i.parent.matrixWorld)))),i.position.x=Math.max(this.minX,Math.min(this.maxX,i.position.x)),i.position.y=Math.max(this.minY,Math.min(this.maxY,i.position.y)),i.position.z=Math.max(this.minZ,Math.min(this.maxZ,i.position.z));else if(n==="scale"){if(t.search("XYZ")!==-1){let a=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(a*=-1),ti.set(a,a,a)}else It.copy(this.pointStart),ti.copy(this.pointEnd),It.applyQuaternion(this._worldQuaternionInv),ti.applyQuaternion(this._worldQuaternionInv),ti.divide(It),t.search("X")===-1&&(ti.x=1),t.search("Y")===-1&&(ti.y=1),t.search("Z")===-1&&(ti.z=1);i.scale.copy(this._scaleStart).multiply(ti),this.scaleSnap&&(t.search("X")!==-1&&(i.scale.x=Math.round(i.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Y")!==-1&&(i.scale.y=Math.round(i.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Z")!==-1&&(i.scale.z=Math.round(i.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if(n==="rotate"){this._offset.copy(this.pointEnd).sub(this.pointStart);const a=20/this.worldPosition.distanceTo(It.setFromMatrixPosition(this.camera.matrixWorld));let l=!1;t==="XYZE"?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(It.copy(this.rotationAxis).cross(this.eye))*a):(t==="X"||t==="Y"||t==="Z")&&(this.rotationAxis.copy(rd[t]),It.copy(rd[t]),r==="local"&&It.applyQuaternion(this.worldQuaternion),It.cross(this.eye),It.length()===0?l=!0:this.rotationAngle=this._offset.dot(It.normalize())*a),(t==="E"||l)&&(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this._startNorm.copy(this.pointStart).normalize(),this._endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this._endNorm.cross(this._startNorm).dot(this.eye)<0?1:-1),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),r==="local"&&t!=="E"&&t!=="XYZE"?(i.quaternion.copy(this._quaternionStart),i.quaternion.multiply(ft.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),i.quaternion.copy(ft.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),i.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(il),this.dispatchEvent(ld)}}pointerUp(e){e!==null&&e.button!==0||(this.dragging&&this.axis!==null&&(ad.mode=this.mode,this.dispatchEvent(ad)),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(il),this.dispatchEvent(ld),this.pointStart.copy(this.pointEnd))}getRaycaster(){return wi}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}setColors(e,t,n,i){const r=this._gizmo.materialLib;r.xAxis.color.set(e),r.yAxis.color.set(t),r.zAxis.color.set(n),r.active.color.set(i),r.xAxisTransparent.color.set(e),r.yAxisTransparent.color.set(t),r.zAxisTransparent.color.set(n),r.activeTransparent.color.set(i),r.xAxis._color&&r.xAxis._color.set(e),r.yAxis._color&&r.yAxis._color.set(t),r.zAxis._color&&r.zAxis._color.set(n),r.active._color&&r.active._color.set(i),r.xAxisTransparent._color&&r.xAxisTransparent._color.set(e),r.yAxisTransparent._color&&r.yAxisTransparent._color.set(t),r.zAxisTransparent._color&&r.zAxisTransparent._color.set(n),r.activeTransparent._color&&r.activeTransparent._color.set(i)}}function dy(s){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:s.button};{const e=this.domElement.getBoundingClientRect();return{x:(s.clientX-e.left)/e.width*2-1,y:-(s.clientY-e.top)/e.height*2+1,button:s.button}}}function uy(s){if(this.enabled)switch(s.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(s));break}}function fy(s){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(s.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(s)),this.pointerDown(this._getPointer(s)))}function py(s){this.enabled&&this.pointerMove(this._getPointer(s))}function my(s){this.enabled&&(this.domElement.releasePointerCapture(s.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(s)))}function sl(s,e,t){const n=e.intersectObject(s,!0);for(let i=0;i<n.length;i++)if(n[i].object.visible||t)return n[i];return!1}const qr=new M.Euler,ht=new M.Vector3(0,1,0),hd=new M.Vector3(0,0,0),dd=new M.Matrix4,Zr=new M.Quaternion,Kr=new M.Quaternion,_n=new M.Vector3,ud=new M.Matrix4,Rs=new M.Vector3(1,0,0),Si=new M.Vector3(0,1,0),Ls=new M.Vector3(0,0,1),$r=new M.Vector3,Is=new M.Vector3,Ns=new M.Vector3;class gy extends M.Object3D{constructor(e){super(),this.isTransformControlsRoot=!0,this.controls=e,this.visible=!1}updateMatrixWorld(e){const t=this.controls;t.object!==void 0&&(t.object.updateMatrixWorld(),t.object.parent===null?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 xy extends M.Object3D{constructor(){super(),this.isTransformControlsGizmo=!0,this.type="TransformControlsGizmo";const e=new M.MeshBasicMaterial({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),t=new M.LineBasicMaterial({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),n=e.clone();n.opacity=.15;const i=t.clone();i.opacity=.5;const r=e.clone();r.color.setHex(16711680);const o=e.clone();o.color.setHex(65280);const a=e.clone();a.color.setHex(255);const l=e.clone();l.color.setHex(16711680),l.opacity=.5;const c=e.clone();c.color.setHex(65280),c.opacity=.5;const h=e.clone();h.color.setHex(255),h.opacity=.5;const d=e.clone();d.opacity=.25;const g=e.clone();g.color.setHex(16776960),g.opacity=.25;const u=e.clone();u.color.setHex(16776960);const m=e.clone();m.color.setHex(7895160),this.materialLib={xAxis:r,yAxis:o,zAxis:a,active:u,xAxisTransparent:l,yAxisTransparent:c,zAxisTransparent:h,activeTransparent:g};const f=new M.CylinderGeometry(0,.04,.1,12);f.translate(0,.05,0);const p=new M.BoxGeometry(.08,.08,.08);p.translate(0,.04,0);const x=new M.BufferGeometry;x.setAttribute("position",new M.Float32BufferAttribute([0,0,0,1,0,0],3));const v=new M.CylinderGeometry(.0075,.0075,.5,3);v.translate(0,.25,0);function _(V,z){const H=new M.TorusGeometry(V,.0075,3,64,z*Math.PI*2);return H.rotateY(Math.PI/2),H.rotateX(Math.PI/2),H}function b(){const V=new M.BufferGeometry;return V.setAttribute("position",new M.Float32BufferAttribute([0,0,0,1,1,1],3)),V}const S={X:[[new M.Mesh(f,r),[.5,0,0],[0,0,-Math.PI/2]],[new M.Mesh(f,r),[-.5,0,0],[0,0,Math.PI/2]],[new M.Mesh(v,r),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new M.Mesh(f,o),[0,.5,0]],[new M.Mesh(f,o),[0,-.5,0],[Math.PI,0,0]],[new M.Mesh(v,o)]],Z:[[new M.Mesh(f,a),[0,0,.5],[Math.PI/2,0,0]],[new M.Mesh(f,a),[0,0,-.5],[-Math.PI/2,0,0]],[new M.Mesh(v,a),null,[Math.PI/2,0,0]]],XYZ:[[new M.Mesh(new M.OctahedronGeometry(.1,0),d),[0,0,0]]],XY:[[new M.Mesh(new M.BoxGeometry(.15,.15,.01),h),[.15,.15,0]]],YZ:[[new M.Mesh(new M.BoxGeometry(.15,.15,.01),l),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new M.Mesh(new M.BoxGeometry(.15,.15,.01),c),[.15,0,.15],[-Math.PI/2,0,0]]]},C={X:[[new M.Mesh(new M.CylinderGeometry(.2,0,.6,4),n),[.3,0,0],[0,0,-Math.PI/2]],[new M.Mesh(new M.CylinderGeometry(.2,0,.6,4),n),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new M.Mesh(new M.CylinderGeometry(.2,0,.6,4),n),[0,.3,0]],[new M.Mesh(new M.CylinderGeometry(.2,0,.6,4),n),[0,-.3,0],[0,0,Math.PI]]],Z:[[new M.Mesh(new M.CylinderGeometry(.2,0,.6,4),n),[0,0,.3],[Math.PI/2,0,0]],[new M.Mesh(new M.CylinderGeometry(.2,0,.6,4),n),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new M.Mesh(new M.OctahedronGeometry(.2,0),n)]],XY:[[new M.Mesh(new M.BoxGeometry(.2,.2,.01),n),[.15,.15,0]]],YZ:[[new M.Mesh(new M.BoxGeometry(.2,.2,.01),n),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new M.Mesh(new M.BoxGeometry(.2,.2,.01),n),[.15,0,.15],[-Math.PI/2,0,0]]]},R={START:[[new M.Mesh(new M.OctahedronGeometry(.01,2),i),null,null,null,"helper"]],END:[[new M.Mesh(new M.OctahedronGeometry(.01,2),i),null,null,null,"helper"]],DELTA:[[new M.Line(b(),i),null,null,null,"helper"]],X:[[new M.Line(x,i),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new M.Line(x,i),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new M.Line(x,i),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},I={XYZE:[[new M.Mesh(_(.5,1),m),null,[0,Math.PI/2,0]]],X:[[new M.Mesh(_(.5,.5),r)]],Y:[[new M.Mesh(_(.5,.5),o),null,[0,0,-Math.PI/2]]],Z:[[new M.Mesh(_(.5,.5),a),null,[0,Math.PI/2,0]]],E:[[new M.Mesh(_(.75,1),g),null,[0,Math.PI/2,0]]]},E={AXIS:[[new M.Line(x,i),[-1e3,0,0],null,[1e6,1,1],"helper"]]},T={XYZE:[[new M.Mesh(new M.SphereGeometry(.25,10,8),n)]],X:[[new M.Mesh(new M.TorusGeometry(.5,.1,4,24),n),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new M.Mesh(new M.TorusGeometry(.5,.1,4,24),n),[0,0,0],[Math.PI/2,0,0]]],Z:[[new M.Mesh(new M.TorusGeometry(.5,.1,4,24),n),[0,0,0],[0,0,-Math.PI/2]]],E:[[new M.Mesh(new M.TorusGeometry(.75,.1,2,24),n)]]},U={X:[[new M.Mesh(p,r),[.5,0,0],[0,0,-Math.PI/2]],[new M.Mesh(v,r),[0,0,0],[0,0,-Math.PI/2]],[new M.Mesh(p,r),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new M.Mesh(p,o),[0,.5,0]],[new M.Mesh(v,o)],[new M.Mesh(p,o),[0,-.5,0],[0,0,Math.PI]]],Z:[[new M.Mesh(p,a),[0,0,.5],[Math.PI/2,0,0]],[new M.Mesh(v,a),[0,0,0],[Math.PI/2,0,0]],[new M.Mesh(p,a),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new M.Mesh(new M.BoxGeometry(.15,.15,.01),h),[.15,.15,0]]],YZ:[[new M.Mesh(new M.BoxGeometry(.15,.15,.01),l),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new M.Mesh(new M.BoxGeometry(.15,.15,.01),c),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new M.Mesh(new M.BoxGeometry(.1,.1,.1),d)]]},D={X:[[new M.Mesh(new M.CylinderGeometry(.2,0,.6,4),n),[.3,0,0],[0,0,-Math.PI/2]],[new M.Mesh(new M.CylinderGeometry(.2,0,.6,4),n),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new M.Mesh(new M.CylinderGeometry(.2,0,.6,4),n),[0,.3,0]],[new M.Mesh(new M.CylinderGeometry(.2,0,.6,4),n),[0,-.3,0],[0,0,Math.PI]]],Z:[[new M.Mesh(new M.CylinderGeometry(.2,0,.6,4),n),[0,0,.3],[Math.PI/2,0,0]],[new M.Mesh(new M.CylinderGeometry(.2,0,.6,4),n),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new M.Mesh(new M.BoxGeometry(.2,.2,.01),n),[.15,.15,0]]],YZ:[[new M.Mesh(new M.BoxGeometry(.2,.2,.01),n),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new M.Mesh(new M.BoxGeometry(.2,.2,.01),n),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new M.Mesh(new M.BoxGeometry(.2,.2,.2),n),[0,0,0]]]},O={X:[[new M.Line(x,i),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new M.Line(x,i),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new M.Line(x,i),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function w(V){const z=new M.Object3D;for(const H in V)for(let Y=V[H].length;Y--;){const W=V[H][Y][0].clone(),Q=V[H][Y][1],X=V[H][Y][2],j=V[H][Y][3],me=V[H][Y][4];W.name=H,W.tag=me,Q&&W.position.set(Q[0],Q[1],Q[2]),X&&W.rotation.set(X[0],X[1],X[2]),j&&W.scale.set(j[0],j[1],j[2]),W.updateMatrix();const ge=W.geometry.clone();ge.applyMatrix4(W.matrix),W.geometry=ge,W.renderOrder=1/0,W.position.set(0,0,0),W.rotation.set(0,0,0),W.scale.set(1,1,1),z.add(W)}return z}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=w(S)),this.add(this.gizmo.rotate=w(I)),this.add(this.gizmo.scale=w(U)),this.add(this.picker.translate=w(C)),this.add(this.picker.rotate=w(T)),this.add(this.picker.scale=w(D)),this.add(this.helper.translate=w(R)),this.add(this.helper.rotate=w(E)),this.add(this.helper.scale=w(O)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(e){const n=(this.mode==="scale"?"local":this.space)==="local"?this.worldQuaternion:Kr;this.gizmo.translate.visible=this.mode==="translate",this.gizmo.rotate.visible=this.mode==="rotate",this.gizmo.scale.visible=this.mode==="scale",this.helper.translate.visible=this.mode==="translate",this.helper.rotate.visible=this.mode==="rotate",this.helper.scale.visible=this.mode==="scale";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 r=0;r<i.length;r++){const o=i[r];o.visible=!0,o.rotation.set(0,0,0),o.position.copy(this.worldPosition);let a;if(this.camera.isOrthographicCamera?a=(this.camera.top-this.camera.bottom)/this.camera.zoom:a=this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),o.scale.set(1,1,1).multiplyScalar(a*this.size/4),o.tag==="helper"){o.visible=!1,o.name==="AXIS"?(o.visible=!!this.axis,this.axis==="X"&&(ft.setFromEuler(qr.set(0,0,0)),o.quaternion.copy(n).multiply(ft),Math.abs(ht.copy(Rs).applyQuaternion(n).dot(this.eye))>.9&&(o.visible=!1)),this.axis==="Y"&&(ft.setFromEuler(qr.set(0,0,Math.PI/2)),o.quaternion.copy(n).multiply(ft),Math.abs(ht.copy(Si).applyQuaternion(n).dot(this.eye))>.9&&(o.visible=!1)),this.axis==="Z"&&(ft.setFromEuler(qr.set(0,Math.PI/2,0)),o.quaternion.copy(n).multiply(ft),Math.abs(ht.copy(Ls).applyQuaternion(n).dot(this.eye))>.9&&(o.visible=!1)),this.axis==="XYZE"&&(ft.setFromEuler(qr.set(0,Math.PI/2,0)),ht.copy(this.rotationAxis),o.quaternion.setFromRotationMatrix(dd.lookAt(hd,ht,Si)),o.quaternion.multiply(ft),o.visible=this.dragging),this.axis==="E"&&(o.visible=!1)):o.name==="START"?(o.position.copy(this.worldPositionStart),o.visible=this.dragging):o.name==="END"?(o.position.copy(this.worldPosition),o.visible=this.dragging):o.name==="DELTA"?(o.position.copy(this.worldPositionStart),o.quaternion.copy(this.worldQuaternionStart),It.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),It.applyQuaternion(this.worldQuaternionStart.clone().invert()),o.scale.copy(It),o.visible=this.dragging):(o.quaternion.copy(n),this.dragging?o.position.copy(this.worldPositionStart):o.position.copy(this.worldPosition),this.axis&&(o.visible=this.axis.search(o.name)!==-1));continue}o.quaternion.copy(n),this.mode==="translate"||this.mode==="scale"?(o.name==="X"&&Math.abs(ht.copy(Rs).applyQuaternion(n).dot(this.eye))>.99&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="Y"&&Math.abs(ht.copy(Si).applyQuaternion(n).dot(this.eye))>.99&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="Z"&&Math.abs(ht.copy(Ls).applyQuaternion(n).dot(this.eye))>.99&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="XY"&&Math.abs(ht.copy(Ls).applyQuaternion(n).dot(this.eye))<.2&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="YZ"&&Math.abs(ht.copy(Rs).applyQuaternion(n).dot(this.eye))<.2&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="XZ"&&Math.abs(ht.copy(Si).applyQuaternion(n).dot(this.eye))<.2&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1)):this.mode==="rotate"&&(Zr.copy(n),ht.copy(this.eye).applyQuaternion(ft.copy(n).invert()),o.name.search("E")!==-1&&o.quaternion.setFromRotationMatrix(dd.lookAt(this.eye,hd,Si)),o.name==="X"&&(ft.setFromAxisAngle(Rs,Math.atan2(-ht.y,ht.z)),ft.multiplyQuaternions(Zr,ft),o.quaternion.copy(ft)),o.name==="Y"&&(ft.setFromAxisAngle(Si,Math.atan2(ht.x,ht.z)),ft.multiplyQuaternions(Zr,ft),o.quaternion.copy(ft)),o.name==="Z"&&(ft.setFromAxisAngle(Ls,Math.atan2(ht.y,ht.x)),ft.multiplyQuaternions(Zr,ft),o.quaternion.copy(ft))),o.visible=o.visible&&(o.name.indexOf("X")===-1||this.showX),o.visible=o.visible&&(o.name.indexOf("Y")===-1||this.showY),o.visible=o.visible&&(o.name.indexOf("Z")===-1||this.showZ),o.visible=o.visible&&(o.name.indexOf("E")===-1||this.showX&&this.showY&&this.showZ),o.material._color=o.material._color||o.material.color.clone(),o.material._opacity=o.material._opacity||o.material.opacity,o.material.color.copy(o.material._color),o.material.opacity=o.material._opacity,this.enabled&&this.axis&&(o.name===this.axis?(o.material.color.copy(this.materialLib.active.color),o.material.opacity=1):this.axis.split("").some(function(l){return o.name===l})&&(o.material.color.copy(this.materialLib.active.color),o.material.opacity=1))}super.updateMatrixWorld(e)}}class vy extends M.Mesh{constructor(){super(new M.PlaneGeometry(1e5,1e5,2,2),new M.MeshBasicMaterial({visible:!1,wireframe:!0,side:M.DoubleSide,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type="TransformControlsPlane"}updateMatrixWorld(e){let t=this.space;switch(this.position.copy(this.worldPosition),this.mode==="scale"&&(t="local"),$r.copy(Rs).applyQuaternion(t==="local"?this.worldQuaternion:Kr),Is.copy(Si).applyQuaternion(t==="local"?this.worldQuaternion:Kr),Ns.copy(Ls).applyQuaternion(t==="local"?this.worldQuaternion:Kr),ht.copy(Is),this.mode){case"translate":case"scale":switch(this.axis){case"X":ht.copy(this.eye).cross($r),_n.copy($r).cross(ht);break;case"Y":ht.copy(this.eye).cross(Is),_n.copy(Is).cross(ht);break;case"Z":ht.copy(this.eye).cross(Ns),_n.copy(Ns).cross(ht);break;case"XY":_n.copy(Ns);break;case"YZ":_n.copy($r);break;case"XZ":ht.copy(Ns),_n.copy(Is);break;case"XYZ":case"E":_n.set(0,0,0);break}break;case"rotate":default:_n.set(0,0,0)}_n.length()===0?this.quaternion.copy(this.cameraQuaternion):(ud.lookAt(It.set(0,0,0),_n,ht),this.quaternion.setFromRotationMatrix(ud)),super.updateMatrixWorld(e)}}class _y extends M.DataTextureLoader{constructor(e){super(e),this.type=M.HalfFloatType}parse(e){const o=function(I,E){switch(I){case 1:throw new Error("THREE.HDRLoader: Read Error: "+(E||""));case 2:throw new Error("THREE.HDRLoader: Write Error: "+(E||""));case 3:throw new Error("THREE.HDRLoader: Bad File Format: "+(E||""));default:case 4:throw new Error("THREE.HDRLoader: Memory Error: "+(E||""))}},d=function(I,E,T){E=E||1024;let D=I.pos,O=-1,w=0,V="",z=String.fromCharCode.apply(null,new Uint16Array(I.subarray(D,D+128)));for(;0>(O=z.indexOf(`
|
|
4940
|
+
`);this.workerSourceURL=URL.createObjectURL(new Blob([o]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){const i=new Worker(this.workerSourceURL);i._callbacks={},i._taskCosts={},i._taskLoad=0,i.postMessage({type:"init",decoderConfig:this.decoderConfig}),i.onmessage=function(r){const o=r.data;switch(o.type){case"decode":i._callbacks[o.id].resolve(o);break;case"error":i._callbacks[o.id].reject(o);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+o.type+'"')}},this.workerPool.push(i)}else this.workerPool.sort(function(i,r){return i._taskLoad>r._taskLoad?-1:1});const n=this.workerPool[this.workerPool.length-1];return n._taskCosts[e]=t,n._taskLoad+=t,n})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}}function Mv(){let s,e;onmessage=function(o){const a=o.data;switch(a.type){case"init":s=a.decoderConfig,e=new Promise(function(h){s.onModuleLoaded=function(d){h({draco:d})},DracoDecoderModule(s)});break;case"decode":const l=a.buffer,c=a.taskConfig;e.then(h=>{const d=h.draco,g=new d.Decoder;try{const u=t(d,g,new Int8Array(l),c),m=u.attributes.map(f=>f.array.buffer);u.index&&m.push(u.index.array.buffer),self.postMessage({type:"decode",id:a.id,geometry:u},m)}catch(u){console.error(u),self.postMessage({type:"error",id:a.id,error:u.message})}finally{d.destroy(g)}});break}};function t(o,a,l,c){const h=c.attributeIDs,d=c.attributeTypes;let g,u;const m=a.GetEncodedGeometryType(l);if(m===o.TRIANGULAR_MESH)g=new o.Mesh,u=a.DecodeArrayToMesh(l,l.byteLength,g);else if(m===o.POINT_CLOUD)g=new o.PointCloud,u=a.DecodeArrayToPointCloud(l,l.byteLength,g);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!u.ok()||g.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+u.error_msg());const f={index:null,attributes:[]};for(const p in h){const x=self[d[p]];let v,_;if(c.useUniqueIDs)_=h[p],v=a.GetAttributeByUniqueId(g,_);else{if(_=a.GetAttributeId(g,o[h[p]]),_===-1)continue;v=a.GetAttribute(g,_)}const b=i(o,a,g,p,x,v);p==="color"&&(b.vertexColorSpace=c.vertexColorSpace),f.attributes.push(b)}return m===o.TRIANGULAR_MESH&&(f.index=n(o,a,g)),o.destroy(g),f}function n(o,a,l){const h=l.num_faces()*3,d=h*4,g=o._malloc(d);a.GetTrianglesUInt32Array(l,d,g);const u=new Uint32Array(o.HEAPF32.buffer,g,h).slice();return o._free(g),{array:u,itemSize:1}}function i(o,a,l,c,h,d){const g=l.num_points(),u=d.num_components(),m=r(o,h),f=u*h.BYTES_PER_ELEMENT,p=Math.ceil(f/4)*4,x=p/h.BYTES_PER_ELEMENT,v=g*f,_=g*p,b=o._malloc(v);a.GetAttributeDataArrayForAllPoints(l,d,m,v,b);const S=new h(o.HEAPF32.buffer,b,v/h.BYTES_PER_ELEMENT);let C;if(f===p)C=S.slice();else{C=new h(_/h.BYTES_PER_ELEMENT);let R=0;for(let I=0,E=S.length;I<E;I++){for(let T=0;T<u;T++)C[R+T]=S[I*u+T];R+=x}}return o._free(b),{name:c,count:g,itemSize:u,array:C,stride:x}}function r(o,a){switch(a){case Float32Array:return o.DT_FLOAT32;case Int8Array:return o.DT_INT8;case Int16Array:return o.DT_INT16;case Int32Array:return o.DT_INT32;case Uint8Array:return o.DT_UINT8;case Uint16Array:return o.DT_UINT16;case Uint32Array:return o.DT_UINT32}}}function bv(s,e,t,n){let i=0,r=0,o=0,a=s.models.find(u=>u.url==t),l=e.circularMeps,c=e.rectMeps?.filter(u=>u.type==="风管"),h=e.rectMeps?.filter(u=>u.type==="桥架"),d=e.ellipseMeps,g=s.scene;if(new y.MeshBasicMaterial,new y.BufferGeometry,l&&l.length){let u=[],m=0;for(let f of l)f.color=f.color.split(",").map(p=>parseInt(p)/255),f.color=new y.Color(f.color[0],f.color[1],f.color[2]),f.position={x:f.startPoint.X*.3048+i,y:f.startPoint.Z*.3048+r,z:-f.startPoint.Y*.3048+o},f.rotation={x:0,y:0,z:0},f.indexes=[[s.scene.children.length,m++,0,0]],a.nodesMap.set(Number(f.id),f),u.push(f);Gr("Circle",g,u,t)}if(c&&c.length){let u=[],m=0;for(let f of c)f.color=f.color.split(",").map(p=>parseInt(p)/255),f.color=new y.Color(f.color[0],f.color[1],f.color[2]),f.position={x:f.startPoint.X*.3048+i,y:f.startPoint.Z*.3048+r,z:-f.startPoint.Y*.3048+o},f.rotation={x:0,y:0,z:0},f.indexes=[[s.scene.children.length,m++,0,0]],a.nodesMap.set(Number(f.id),f),u.push(f);Gr("Rect",g,u,t)}if(d&&d.length){let u=[],m=0;for(let f of d)f.color=f.color.split(",").map(p=>parseInt(p)/255),f.color=new y.Color(f.color[0],f.color[1],f.color[2]),f.position={x:f.startPoint.X*.3048+i,y:f.startPoint.Z*.3048+r,z:-f.startPoint.Y*.3048+o},f.rotation={x:0,y:0,z:0},f.indexes=[[s.scene.children.length,m++,0,0]],a.nodesMap.set(Number(f.id),f),u.push(f);Gr("Ellipse",g,u,t)}if(h&&h.length){let u=[],m=0;for(let f of h)f.color=f.color.split(",").map(p=>parseInt(p)/255),f.color=new y.Color(f.color[0],f.color[1],f.color[2]),f.position={x:f.startPoint.X*.3048+i,y:f.startPoint.Z*.3048+r,z:-f.startPoint.Y*.3048+o},f.rotation={x:0,y:0,z:0},f.indexes=[[s.scene.children.length,m++,0,0]],a.nodesMap.set(Number(f.id),f),u.push(f);Gr("Bridge",g,u,t)}}function Gr(s,e,t,n,i){let r,o,a={width:1,height:1,length:1,diameter:1,color:new y.Color,position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0}};switch(s){case"Rect":o=Wr("Rect",a);break;case"Bridge":o=Wr("Bridge",a);break;case"Circle":o=Wr("Circle",a);break;case"Ellipse":o=Wr("Ellipse",a);break}o&&(r=new y.InstancedMesh(o.geometry,o.material,t.length),r.url=n,e.add(r),r.index=e.children.length-1);let l=[],c=[];for(var h=0;h<t.length;h++){let u=t[h],m=new y.Vector3(u.startPoint.X,0,-u.startPoint.Y),f=new y.Vector3(u.endPoint.X,0,-u.endPoint.Y),p=new y.Vector3(u.startPoint.X,u.startPoint.Z,-u.startPoint.Y),x=new y.Vector3(u.endPoint.X,u.endPoint.Z,-u.endPoint.Y),v=0,_=0,b=0;if(Math.abs(f.clone().sub(m.clone()).z)<.01&&Math.abs(f.clone().sub(m.clone()).x)<.01){if(v=(u.startPoint.Z>u.endPoint.Z?1:-1)*Math.PI*.5,u.base_x!=null){var d=new y.Vector3(u.base_x.X,0,-u.base_x.Y);_=(d.clone().cross(new y.Vector3(0,0,1)).y<=0?1:-1)*d.angleTo(new y.Vector3(0,0,1))+Math.PI*.5}}else _=(f.clone().sub(m.clone()).cross(new y.Vector3(0,0,1)).y>0?-1:1)*f.clone().sub(m.clone()).angleTo(new y.Vector3(0,0,1)),v=(u.startPoint.Z>u.endPoint.Z?1:-1)*f.clone().sub(m.clone()).angleTo(x.clone().sub(p.clone()));let S=new y.Matrix4;const C=new y.Euler(v,_,b,"YXZ");let R=S.clone().makeRotationFromEuler(C),I,E;s==="Circle"?(I=u.diameter,E=u.diameter):(I=u.width,E=u.height);let T=S.clone().makeScale(I,E,u.length);S.multiplyMatrices(R,T),S.setPosition(u.position.x,u.position.y,u.position.z),r.setMatrixAt(h,S.clone()),r.setColorAt(h,u.color),r.geometry.computeBoundingBox();let U=r.geometry.boundingBox.min.clone().applyMatrix4(S.clone()),D=r.geometry.boundingBox.max.clone().applyMatrix4(S.clone()),O=new y.Vector3(Math.min(U.x,D.x),Math.min(U.y,D.y),Math.min(U.z,D.z)),w=new y.Vector3(Math.max(U.x,D.x),Math.max(U.y,D.y),Math.max(U.z,D.z)),V=O.clone().add(w.clone()).multiplyScalar(.5),z={name:u.name,min:O,max:w,center:V,dbid:h,materialName:o.material.name},H=null,Y=null;s==="Circle"&&(H={x:u.startPoint.X*.3048,y:u.startPoint.Z*.3048,z:-u.startPoint.Y*.3048},Y={x:u.endPoint.X*.3048,y:u.endPoint.Z*.3048,z:-u.endPoint.Y*.3048},z.minC=H,z.maxC=Y),r.ids||(r.ids=[]),r.matrixs||(r.matrixs=[]),r.matrixs.push(S.clone()),c.push(S.clone()),r.ids.push(Number(u.id)),l.push(z)}r.castShadow=!0,r.ElementInfos=l,r.name="rootModel",r.TypeName="InstancedMesh-Pipe",r.PipeType=s,r.MeshId=null,r.realMaterial=r.material.clone(),r.originalMaterial=r.material.clone(),r.matrixsClone=c;let g=[];g={geometry:r.geometry,matrix:r.matrix,position:r.position,rotation:r.rotation},r.meshs=g,r.instanceMatrix&&r.instanceMatrix.array&&(r.cloneInstanceMatrix=Array.from(r.instanceMatrix.array))}function Wr(s,e,t){let n=new y.Shape;switch(e.width=e.width*.3048,e.height=e.height*.3048,e.diameter=e.diameter*.3048,s){case"Rect":n.moveTo(-e.width/2,-e.height/2),n.lineTo(-e.width/2,e.height/2),n.lineTo(e.width/2,e.height/2),n.lineTo(e.width/2,-e.height/2),n.lineTo(-e.width/2,-e.height/2);break;case"Ellipse":n.moveTo(-e.width/2,-e.height/2),n.lineTo(-e.width/2,e.height/2),n.lineTo(e.width/2,e.height/2),n.lineTo(e.width/2,-e.height/2),n.lineTo(-e.width/2,-e.height/2);break;case"Bridge":n.moveTo(-e.width/2,-e.height/2),n.lineTo(-e.width/2,e.height/2),n.lineTo(-e.width/2+.01,e.height/2),n.lineTo(-e.width/2+.01,-e.height/2+.01),n.lineTo(e.width/2-.01,-e.height/2+.01),n.lineTo(e.width/2-.01,e.height/2),n.lineTo(e.width/2,e.height/2),n.lineTo(e.width/2,-e.height/2),n.lineTo(-e.width/2,-e.height/2);break;case"Circle":n.moveTo(0,0),n.absarc(0,0,e.diameter*.5,0,Math.PI*2,!1);break}const i={depth:e.length*.3048,bevelEnabled:!1};return r(n,i,e.color,e.position,e.rotation);function r(o,a,l,c,h){let d=new y.ExtrudeGeometry(o,a),g=new y.MeshStandardMaterial({color:l,side:y.DoubleSide}),u=new y.Mesh(d,g);return u.position.set(c.x,c.y,c.z),u.rotation._order="YXZ",u.rotation.set(h.x,h.y,h.z),u}}function Mi(s,e=!1){const t=s[0].index!==null,n=new Set(Object.keys(s[0].attributes)),i=new Set(Object.keys(s[0].morphAttributes)),r={},o={},a=s[0].morphTargetsRelative,l=new M.BufferGeometry;let c=0;for(let h=0;h<s.length;++h){const d=s[h];let g=0;if(t!==(d.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const u in d.attributes){if(!n.has(u))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+'. All geometries must have compatible attributes; make sure "'+u+'" attribute exists among all geometries, or in none of them.'),null;r[u]===void 0&&(r[u]=[]),r[u].push(d.attributes[u]),g++}if(g!==n.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". Make sure all geometries have the same number of attributes."),null;if(a!==d.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const u in d.morphAttributes){if(!i.has(u))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". .morphAttributes must be consistent throughout all geometries."),null;o[u]===void 0&&(o[u]=[]),o[u].push(d.morphAttributes[u])}if(e){let u;if(t)u=d.index.count;else if(d.attributes.position!==void 0)u=d.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". The geometry must have either an index or a position attribute"),null;l.addGroup(c,u,h),c+=u}}if(t){let h=0;const d=[];for(let g=0;g<s.length;++g){const u=s[g].index;for(let m=0;m<u.count;++m)d.push(u.getX(m)+h);h+=s[g].attributes.position.count}l.setIndex(d)}for(const h in r){const d=Rh(r[h]);if(!d)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+h+" attribute."),null;l.setAttribute(h,d)}for(const h in o){const d=o[h][0].length;if(d===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[h]=[];for(let g=0;g<d;++g){const u=[];for(let f=0;f<o[h].length;++f)u.push(o[h][f][g]);const m=Rh(u);if(!m)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+h+" morphAttribute."),null;l.morphAttributes[h].push(m)}}return l}function Rh(s){let e,t,n,i=-1,r=0;for(let c=0;c<s.length;++c){const h=s[c];if(e===void 0&&(e=h.array.constructor),e!==h.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(t===void 0&&(t=h.itemSize),t!==h.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(n===void 0&&(n=h.normalized),n!==h.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(i===-1&&(i=h.gpuType),i!==h.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;r+=h.count*t}const o=new e(r),a=new M.BufferAttribute(o,t,n);let l=0;for(let c=0;c<s.length;++c){const h=s[c];if(h.isInterleavedBufferAttribute){const d=l/t;for(let g=0,u=h.count;g<u;g++)for(let m=0;m<t;m++){const f=h.getComponent(g,m);a.setComponent(g+d,m,f)}}else o.set(h.array,l);l+=h.count*t}return i!==void 0&&(a.gpuType=i),a}function Lh(s,e){if(e===M.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),s;if(e===M.TriangleFanDrawMode||e===M.TriangleStripDrawMode){let t=s.getIndex();if(t===null){const o=[],a=s.getAttribute("position");if(a!==void 0){for(let l=0;l<a.count;l++)o.push(l);s.setIndex(o),t=s.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),s}const n=t.count-2,i=[];if(e===M.TriangleFanDrawMode)for(let o=1;o<=n;o++)i.push(t.getX(0)),i.push(t.getX(o)),i.push(t.getX(o+1));else for(let o=0;o<n;o++)o%2===0?(i.push(t.getX(o)),i.push(t.getX(o+1)),i.push(t.getX(o+2))):(i.push(t.getX(o+2)),i.push(t.getX(o+1)),i.push(t.getX(o)));i.length/3!==n&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const r=s.clone();return r.setIndex(i),r.clearGroups(),r}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),s}function wv(s){const e=new Map,t=new Map,n=s.clone();return Ih(s,n,function(i,r){e.set(r,i),t.set(i,r)}),n.traverse(function(i){if(!i.isSkinnedMesh)return;const r=i,o=e.get(i),a=o.skeleton.bones;r.skeleton=o.skeleton.clone(),r.bindMatrix.copy(o.bindMatrix),r.skeleton.bones=a.map(function(l){return t.get(l)}),r.bind(r.skeleton,r.bindMatrix)}),n}function Ih(s,e,t){t(s,e);for(let n=0;n<s.children.length;n++)Ih(s.children[n],e.children[n],t)}class Sv extends M.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new Pv(t)}),this.register(function(t){return new Dv(t)}),this.register(function(t){return new Bv(t)}),this.register(function(t){return new zv(t)}),this.register(function(t){return new Vv(t)}),this.register(function(t){return new Lv(t)}),this.register(function(t){return new Iv(t)}),this.register(function(t){return new Nv(t)}),this.register(function(t){return new Uv(t)}),this.register(function(t){return new Tv(t)}),this.register(function(t){return new Fv(t)}),this.register(function(t){return new Rv(t)}),this.register(function(t){return new kv(t)}),this.register(function(t){return new Ov(t)}),this.register(function(t){return new Cv(t)}),this.register(function(t){return new Nh(t,$e.EXT_MESHOPT_COMPRESSION)}),this.register(function(t){return new Nh(t,$e.KHR_MESHOPT_COMPRESSION)}),this.register(function(t){return new Gv(t)})}load(e,t,n,i){const r=this;let o;if(this.resourcePath!=="")o=this.resourcePath;else if(this.path!==""){const c=M.LoaderUtils.extractUrlBase(e);o=M.LoaderUtils.resolveURL(c,this.path)}else o=M.LoaderUtils.extractUrlBase(e);this.manager.itemStart(e);const a=function(c){i?i(c):console.error(c),r.manager.itemError(e),r.manager.itemEnd(e)},l=new M.FileLoader(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(this.withCredentials),l.load(e,function(c){try{r.parse(c,o,function(h){t(h),r.manager.itemEnd(e)},a)}catch(h){a(h)}},n,a)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,i){let r;const o={},a={},l=new TextDecoder;if(typeof e=="string")r=JSON.parse(e);else if(e instanceof ArrayBuffer)if(l.decode(new Uint8Array(e,0,4))===Uh){try{o[$e.KHR_BINARY_GLTF]=new Wv(e)}catch(d){i&&i(d);return}r=JSON.parse(o[$e.KHR_BINARY_GLTF].content)}else r=JSON.parse(l.decode(e));else r=e;if(r.asset===void 0||r.asset.version[0]<2){i&&i(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const c=new n_(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let h=0;h<this.pluginCallbacks.length;h++){const d=this.pluginCallbacks[h](c);d.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[d.name]=d,o[d.name]=!0}if(r.extensionsUsed)for(let h=0;h<r.extensionsUsed.length;++h){const d=r.extensionsUsed[h],g=r.extensionsRequired||[];switch(d){case $e.KHR_MATERIALS_UNLIT:o[d]=new Av;break;case $e.KHR_DRACO_MESH_COMPRESSION:o[d]=new Hv(r,this.dracoLoader);break;case $e.KHR_TEXTURE_TRANSFORM:o[d]=new Xv;break;case $e.KHR_MESH_QUANTIZATION:o[d]=new jv;break;default:g.indexOf(d)>=0&&a[d]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+d+'".')}}c.setExtensions(o),c.setPlugins(a),c.parse(n,i)}parseAsync(e,t){const n=this;return new Promise(function(i,r){n.parse(e,t,i,r)})}}function Ev(){let s={};return{get:function(e){return s[e]},add:function(e,t){s[e]=t},remove:function(e){delete s[e]},removeAll:function(){s={}}}}function bt(s,e,t){const n=s.json.materials[e];return n.extensions&&n.extensions[t]?n.extensions[t]:null}const $e={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",KHR_MESHOPT_COMPRESSION:"KHR_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class Cv{constructor(e){this.parser=e,this.name=$e.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n<i;n++){const r=t[n];r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){const t=this.parser,n="light:"+e;let i=t.cache.get(n);if(i)return i;const r=t.json,l=((r.extensions&&r.extensions[this.name]||{}).lights||[])[e];let c;const h=new M.Color(16777215);l.color!==void 0&&h.setRGB(l.color[0],l.color[1],l.color[2],M.LinearSRGBColorSpace);const d=l.range!==void 0?l.range:0;switch(l.type){case"directional":c=new M.DirectionalLight(h),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new M.PointLight(h),c.distance=d;break;case"spot":c=new M.SpotLight(h),c.distance=d,l.spot=l.spot||{},l.spot.innerConeAngle=l.spot.innerConeAngle!==void 0?l.spot.innerConeAngle:0,l.spot.outerConeAngle=l.spot.outerConeAngle!==void 0?l.spot.outerConeAngle:Math.PI/4,c.angle=l.spot.outerConeAngle,c.penumbra=1-l.spot.innerConeAngle/l.spot.outerConeAngle,c.target.position.set(0,0,-1),c.add(c.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+l.type)}return c.position.set(0,0,0),xn(c,l),l.intensity!==void 0&&(c.intensity=l.intensity),c.name=t.createUniqueName(l.name||"light_"+e),i=Promise.resolve(c),t.cache.add(n,i),i}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,n=this.parser,r=n.json.nodes[e],a=(r.extensions&&r.extensions[this.name]||{}).light;return a===void 0?null:this._loadLight(a).then(function(l){return n._getNodeRef(t.cache,a,l)})}}class Av{constructor(){this.name=$e.KHR_MATERIALS_UNLIT}getMaterialType(){return M.MeshBasicMaterial}extendParams(e,t,n){const i=[];e.color=new M.Color(1,1,1),e.opacity=1;const r=t.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){const o=r.baseColorFactor;e.color.setRGB(o[0],o[1],o[2],M.LinearSRGBColorSpace),e.opacity=o[3]}r.baseColorTexture!==void 0&&i.push(n.assignTexture(e,"map",r.baseColorTexture,M.SRGBColorSpace))}return Promise.all(i)}}class Tv{constructor(e){this.parser=e,this.name=$e.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const n=bt(this.parser,e,this.name);return n===null||n.emissiveStrength!==void 0&&(t.emissiveIntensity=n.emissiveStrength),Promise.resolve()}}class Pv{constructor(e){this.parser=e,this.name=$e.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){return bt(this.parser,e,this.name)!==null?M.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=bt(this.parser,e,this.name);if(n===null)return Promise.resolve();const i=[];if(n.clearcoatFactor!==void 0&&(t.clearcoat=n.clearcoatFactor),n.clearcoatTexture!==void 0&&i.push(this.parser.assignTexture(t,"clearcoatMap",n.clearcoatTexture)),n.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=n.clearcoatRoughnessFactor),n.clearcoatRoughnessTexture!==void 0&&i.push(this.parser.assignTexture(t,"clearcoatRoughnessMap",n.clearcoatRoughnessTexture)),n.clearcoatNormalTexture!==void 0&&(i.push(this.parser.assignTexture(t,"clearcoatNormalMap",n.clearcoatNormalTexture)),n.clearcoatNormalTexture.scale!==void 0)){const r=n.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new M.Vector2(r,r)}return Promise.all(i)}}class Dv{constructor(e){this.parser=e,this.name=$e.KHR_MATERIALS_DISPERSION}getMaterialType(e){return bt(this.parser,e,this.name)!==null?M.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=bt(this.parser,e,this.name);return n===null||(t.dispersion=n.dispersion!==void 0?n.dispersion:0),Promise.resolve()}}class Rv{constructor(e){this.parser=e,this.name=$e.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){return bt(this.parser,e,this.name)!==null?M.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=bt(this.parser,e,this.name);if(n===null)return Promise.resolve();const i=[];return n.iridescenceFactor!==void 0&&(t.iridescence=n.iridescenceFactor),n.iridescenceTexture!==void 0&&i.push(this.parser.assignTexture(t,"iridescenceMap",n.iridescenceTexture)),n.iridescenceIor!==void 0&&(t.iridescenceIOR=n.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),n.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=n.iridescenceThicknessMinimum),n.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=n.iridescenceThicknessMaximum),n.iridescenceThicknessTexture!==void 0&&i.push(this.parser.assignTexture(t,"iridescenceThicknessMap",n.iridescenceThicknessTexture)),Promise.all(i)}}class Lv{constructor(e){this.parser=e,this.name=$e.KHR_MATERIALS_SHEEN}getMaterialType(e){return bt(this.parser,e,this.name)!==null?M.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=bt(this.parser,e,this.name);if(n===null)return Promise.resolve();const i=[];if(t.sheenColor=new M.Color(0,0,0),t.sheenRoughness=0,t.sheen=1,n.sheenColorFactor!==void 0){const r=n.sheenColorFactor;t.sheenColor.setRGB(r[0],r[1],r[2],M.LinearSRGBColorSpace)}return n.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=n.sheenRoughnessFactor),n.sheenColorTexture!==void 0&&i.push(this.parser.assignTexture(t,"sheenColorMap",n.sheenColorTexture,M.SRGBColorSpace)),n.sheenRoughnessTexture!==void 0&&i.push(this.parser.assignTexture(t,"sheenRoughnessMap",n.sheenRoughnessTexture)),Promise.all(i)}}class Iv{constructor(e){this.parser=e,this.name=$e.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){return bt(this.parser,e,this.name)!==null?M.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=bt(this.parser,e,this.name);if(n===null)return Promise.resolve();const i=[];return n.transmissionFactor!==void 0&&(t.transmission=n.transmissionFactor),n.transmissionTexture!==void 0&&i.push(this.parser.assignTexture(t,"transmissionMap",n.transmissionTexture)),Promise.all(i)}}class Nv{constructor(e){this.parser=e,this.name=$e.KHR_MATERIALS_VOLUME}getMaterialType(e){return bt(this.parser,e,this.name)!==null?M.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=bt(this.parser,e,this.name);if(n===null)return Promise.resolve();const i=[];t.thickness=n.thicknessFactor!==void 0?n.thicknessFactor:0,n.thicknessTexture!==void 0&&i.push(this.parser.assignTexture(t,"thicknessMap",n.thicknessTexture)),t.attenuationDistance=n.attenuationDistance||1/0;const r=n.attenuationColor||[1,1,1];return t.attenuationColor=new M.Color().setRGB(r[0],r[1],r[2],M.LinearSRGBColorSpace),Promise.all(i)}}class Uv{constructor(e){this.parser=e,this.name=$e.KHR_MATERIALS_IOR}getMaterialType(e){return bt(this.parser,e,this.name)!==null?M.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=bt(this.parser,e,this.name);return n===null||(t.ior=n.ior!==void 0?n.ior:1.5),Promise.resolve()}}class Fv{constructor(e){this.parser=e,this.name=$e.KHR_MATERIALS_SPECULAR}getMaterialType(e){return bt(this.parser,e,this.name)!==null?M.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=bt(this.parser,e,this.name);if(n===null)return Promise.resolve();const i=[];t.specularIntensity=n.specularFactor!==void 0?n.specularFactor:1,n.specularTexture!==void 0&&i.push(this.parser.assignTexture(t,"specularIntensityMap",n.specularTexture));const r=n.specularColorFactor||[1,1,1];return t.specularColor=new M.Color().setRGB(r[0],r[1],r[2],M.LinearSRGBColorSpace),n.specularColorTexture!==void 0&&i.push(this.parser.assignTexture(t,"specularColorMap",n.specularColorTexture,M.SRGBColorSpace)),Promise.all(i)}}class Ov{constructor(e){this.parser=e,this.name=$e.EXT_MATERIALS_BUMP}getMaterialType(e){return bt(this.parser,e,this.name)!==null?M.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=bt(this.parser,e,this.name);if(n===null)return Promise.resolve();const i=[];return t.bumpScale=n.bumpFactor!==void 0?n.bumpFactor:1,n.bumpTexture!==void 0&&i.push(this.parser.assignTexture(t,"bumpMap",n.bumpTexture)),Promise.all(i)}}class kv{constructor(e){this.parser=e,this.name=$e.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){return bt(this.parser,e,this.name)!==null?M.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=bt(this.parser,e,this.name);if(n===null)return Promise.resolve();const i=[];return n.anisotropyStrength!==void 0&&(t.anisotropy=n.anisotropyStrength),n.anisotropyRotation!==void 0&&(t.anisotropyRotation=n.anisotropyRotation),n.anisotropyTexture!==void 0&&i.push(this.parser.assignTexture(t,"anisotropyMap",n.anisotropyTexture)),Promise.all(i)}}class Bv{constructor(e){this.parser=e,this.name=$e.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,n=t.json,i=n.textures[e];if(!i.extensions||!i.extensions[this.name])return null;const r=i.extensions[this.name],o=t.options.ktx2Loader;if(!o){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,r.source,o)}}class zv{constructor(e){this.parser=e,this.name=$e.EXT_TEXTURE_WEBP}loadTexture(e){const t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;const o=r.extensions[t],a=i.images[o.source];let l=n.textureLoader;if(a.uri){const c=n.options.manager.getHandler(a.uri);c!==null&&(l=c)}return n.loadTextureImage(e,o.source,l)}}class Vv{constructor(e){this.parser=e,this.name=$e.EXT_TEXTURE_AVIF}loadTexture(e){const t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;const o=r.extensions[t],a=i.images[o.source];let l=n.textureLoader;if(a.uri){const c=n.options.manager.getHandler(a.uri);c!==null&&(l=c)}return n.loadTextureImage(e,o.source,l)}}class Nh{constructor(e,t){this.name=t,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const i=n.extensions[this.name],r=this.parser.getDependency("buffer",i.buffer),o=this.parser.options.meshoptDecoder;if(!o||!o.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return r.then(function(a){const l=i.byteOffset||0,c=i.byteLength||0,h=i.count,d=i.byteStride,g=new Uint8Array(a,l,c);return o.decodeGltfBufferAsync?o.decodeGltfBufferAsync(h,d,g,i.mode,i.filter).then(function(u){return u.buffer}):o.ready.then(function(){const u=new ArrayBuffer(h*d);return o.decodeGltfBuffer(new Uint8Array(u),h,d,g,i.mode,i.filter),u})})}else return null}}class Gv{constructor(e){this.name=$e.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;const i=t.meshes[n.mesh];for(const c of i.primitives)if(c.mode!==tn.TRIANGLES&&c.mode!==tn.TRIANGLE_STRIP&&c.mode!==tn.TRIANGLE_FAN&&c.mode!==void 0)return null;const o=n.extensions[this.name].attributes,a=[],l={};for(const c in o)a.push(this.parser.getDependency("accessor",o[c]).then(h=>(l[c]=h,l[c])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(c=>{const h=c.pop(),d=h.isGroup?h.children:[h],g=c[0].count,u=[];for(const m of d){const f=new M.Matrix4,p=new M.Vector3,x=new M.Quaternion,v=new M.Vector3(1,1,1),_=new M.InstancedMesh(m.geometry,m.material,g);for(let b=0;b<g;b++)l.TRANSLATION&&p.fromBufferAttribute(l.TRANSLATION,b),l.ROTATION&&x.fromBufferAttribute(l.ROTATION,b),l.SCALE&&v.fromBufferAttribute(l.SCALE,b),_.setMatrixAt(b,f.compose(p,x,v));for(const b in l)if(b==="_COLOR_0"){const S=l[b];_.instanceColor=new M.InstancedBufferAttribute(S.array,S.itemSize,S.normalized)}else b!=="TRANSLATION"&&b!=="ROTATION"&&b!=="SCALE"&&m.geometry.setAttribute(b,l[b]);M.Object3D.prototype.copy.call(_,m),this.parser.assignFinalMaterial(_),u.push(_)}return h.isGroup?(h.clear(),h.add(...u),h):u[0]}))}}const Uh="glTF",Cs=12,Fh={JSON:1313821514,BIN:5130562};class Wv{constructor(e){this.name=$e.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,Cs),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==Uh)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const i=this.header.length-Cs,r=new DataView(e,Cs);let o=0;for(;o<i;){const a=r.getUint32(o,!0);o+=4;const l=r.getUint32(o,!0);if(o+=4,l===Fh.JSON){const c=new Uint8Array(e,Cs+o,a);this.content=n.decode(c)}else if(l===Fh.BIN){const c=Cs+o;this.body=e.slice(c,c+a)}o+=a}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class Hv{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=$e.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const n=this.json,i=this.dracoLoader,r=e.extensions[this.name].bufferView,o=e.extensions[this.name].attributes,a={},l={},c={};for(const h in o){const d=qa[h]||h.toLowerCase();a[d]=o[h]}for(const h in e.attributes){const d=qa[h]||h.toLowerCase();if(o[h]!==void 0){const g=n.accessors[e.attributes[h]],u=es[g.componentType];c[d]=u.name,l[d]=g.normalized===!0}}return t.getDependency("bufferView",r).then(function(h){return new Promise(function(d,g){i.decodeDracoFile(h,function(u){for(const m in u.attributes){const f=u.attributes[m],p=l[m];p!==void 0&&(f.normalized=p)}d(u)},a,c,M.LinearSRGBColorSpace,g)})})}}class Xv{constructor(){this.name=$e.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0||(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}class jv{constructor(){this.name=$e.KHR_MESH_QUANTIZATION}}class Oh extends M.Interpolant{constructor(e,t,n,i){super(e,t,n,i)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i*3+i;for(let o=0;o!==i;o++)t[o]=n[r+o];return t}interpolate_(e,t,n,i){const r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=a*2,c=a*3,h=i-t,d=(n-t)/h,g=d*d,u=g*d,m=e*c,f=m-c,p=-2*u+3*g,x=u-g,v=1-p,_=x-g+d;for(let b=0;b!==a;b++){const S=o[f+b+a],C=o[f+b+l]*h,R=o[m+b+a],I=o[m+b]*h;r[b]=v*S+_*C+p*R+x*I}return r}}const Yv=new M.Quaternion;class qv extends Oh{interpolate_(e,t,n,i){const r=super.interpolate_(e,t,n,i);return Yv.fromArray(r).normalize().toArray(r),r}}const tn={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},es={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},kh={9728:M.NearestFilter,9729:M.LinearFilter,9984:M.NearestMipmapNearestFilter,9985:M.LinearMipmapNearestFilter,9986:M.NearestMipmapLinearFilter,9987:M.LinearMipmapLinearFilter},Bh={33071:M.ClampToEdgeWrapping,33648:M.MirroredRepeatWrapping,10497:M.RepeatWrapping},Ya={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},qa={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},ei={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Zv={CUBICSPLINE:void 0,LINEAR:M.InterpolateLinear,STEP:M.InterpolateDiscrete},Za={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function Kv(s){return s.DefaultMaterial===void 0&&(s.DefaultMaterial=new M.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:M.FrontSide})),s.DefaultMaterial}function bi(s,e,t){for(const n in t.extensions)s[n]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[n]=t.extensions[n])}function xn(s,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(s.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function $v(s,e,t){let n=!1,i=!1,r=!1;for(let c=0,h=e.length;c<h;c++){const d=e[c];if(d.POSITION!==void 0&&(n=!0),d.NORMAL!==void 0&&(i=!0),d.COLOR_0!==void 0&&(r=!0),n&&i&&r)break}if(!n&&!i&&!r)return Promise.resolve(s);const o=[],a=[],l=[];for(let c=0,h=e.length;c<h;c++){const d=e[c];if(n){const g=d.POSITION!==void 0?t.getDependency("accessor",d.POSITION):s.attributes.position;o.push(g)}if(i){const g=d.NORMAL!==void 0?t.getDependency("accessor",d.NORMAL):s.attributes.normal;a.push(g)}if(r){const g=d.COLOR_0!==void 0?t.getDependency("accessor",d.COLOR_0):s.attributes.color;l.push(g)}}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(l)]).then(function(c){const h=c[0],d=c[1],g=c[2];return n&&(s.morphAttributes.position=h),i&&(s.morphAttributes.normal=d),r&&(s.morphAttributes.color=g),s.morphTargetsRelative=!0,s})}function Jv(s,e){if(s.updateMorphTargets(),e.weights!==void 0)for(let t=0,n=e.weights.length;t<n;t++)s.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(s.morphTargetInfluences.length===t.length){s.morphTargetDictionary={};for(let n=0,i=t.length;n<i;n++)s.morphTargetDictionary[t[n]]=n}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function Qv(s){let e;const t=s.extensions&&s.extensions[$e.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+Ka(t.attributes):e=s.indices+":"+Ka(s.attributes)+":"+s.mode,s.targets!==void 0)for(let n=0,i=s.targets.length;n<i;n++)e+=":"+Ka(s.targets[n]);return e}function Ka(s){let e="";const t=Object.keys(s).sort();for(let n=0,i=t.length;n<i;n++)e+=t[n]+":"+s[t[n]]+";";return e}function $a(s){switch(s){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function e_(s){return s.search(/\.jpe?g($|\?)/i)>0||s.search(/^data\:image\/jpeg/)===0?"image/jpeg":s.search(/\.webp($|\?)/i)>0||s.search(/^data\:image\/webp/)===0?"image/webp":s.search(/\.ktx2($|\?)/i)>0||s.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const t_=new M.Matrix4;class n_{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new Ev,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,i=-1,r=!1,o=-1;if(typeof navigator<"u"&&typeof navigator.userAgent<"u"){const a=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(a)===!0;const l=a.match(/Version\/(\d+)/);i=n&&l?parseInt(l[1],10):-1,r=a.indexOf("Firefox")>-1,o=r?a.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||n&&i<17||r&&o<98?this.textureLoader=new M.TextureLoader(this.options.manager):this.textureLoader=new M.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new M.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const n=this,i=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(o){return o._markDefs&&o._markDefs()}),Promise.all(this._invokeAll(function(o){return o.beforeRoot&&o.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(o){const a={scene:o[0][i.scene||0],scenes:o[0],animations:o[1],cameras:o[2],asset:i.asset,parser:n,userData:{}};return bi(r,a,i),xn(a,i),Promise.all(n._invokeAll(function(l){return l.afterRoot&&l.afterRoot(a)})).then(function(){for(const l of a.scenes)l.updateMatrixWorld();e(a)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let i=0,r=t.length;i<r;i++){const o=t[i].joints;for(let a=0,l=o.length;a<l;a++)e[o[a]].isBone=!0}for(let i=0,r=e.length;i<r;i++){const o=e[i];o.mesh!==void 0&&(this._addNodeRef(this.meshCache,o.mesh),o.skin!==void 0&&(n[o.mesh].isSkinnedMesh=!0)),o.camera!==void 0&&this._addNodeRef(this.cameraCache,o.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;const i=n.clone(),r=(o,a)=>{const l=this.associations.get(o);l!=null&&this.associations.set(a,l);for(const[c,h]of o.children.entries())r(h,a.children[c])};return r(n,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){const i=e(t[n]);if(i)return i}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const n=[];for(let i=0;i<t.length;i++){const r=e(t[i]);r&&n.push(r)}return n}getDependency(e,t){const n=e+":"+t;let i=this.cache.get(n);if(!i){switch(e){case"scene":i=this.loadScene(t);break;case"node":i=this._invokeOne(function(r){return r.loadNode&&r.loadNode(t)});break;case"mesh":i=this._invokeOne(function(r){return r.loadMesh&&r.loadMesh(t)});break;case"accessor":i=this.loadAccessor(t);break;case"bufferView":i=this._invokeOne(function(r){return r.loadBufferView&&r.loadBufferView(t)});break;case"buffer":i=this.loadBuffer(t);break;case"material":i=this._invokeOne(function(r){return r.loadMaterial&&r.loadMaterial(t)});break;case"texture":i=this._invokeOne(function(r){return r.loadTexture&&r.loadTexture(t)});break;case"skin":i=this.loadSkin(t);break;case"animation":i=this._invokeOne(function(r){return r.loadAnimation&&r.loadAnimation(t)});break;case"camera":i=this.loadCamera(t);break;default:if(i=this._invokeOne(function(r){return r!=this&&r.getDependency&&r.getDependency(e,t)}),!i)throw new Error("Unknown type: "+e);break}this.cache.add(n,i)}return i}getDependencies(e){let t=this.cache.get(e);if(!t){const n=this,i=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(i.map(function(r,o){return n.getDependency(e,o)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],n=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[$e.KHR_BINARY_GLTF].body);const i=this.options;return new Promise(function(r,o){n.load(M.LoaderUtils.resolveURL(t.uri,i.path),r,void 0,function(){o(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(n){const i=t.byteLength||0,r=t.byteOffset||0;return n.slice(r,r+i)})}loadAccessor(e){const t=this,n=this.json,i=this.json.accessors[e];if(i.bufferView===void 0&&i.sparse===void 0){const o=Ya[i.type],a=es[i.componentType],l=i.normalized===!0,c=new a(i.count*o);return Promise.resolve(new M.BufferAttribute(c,o,l))}const r=[];return i.bufferView!==void 0?r.push(this.getDependency("bufferView",i.bufferView)):r.push(null),i.sparse!==void 0&&(r.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",i.sparse.values.bufferView))),Promise.all(r).then(function(o){const a=o[0],l=Ya[i.type],c=es[i.componentType],h=c.BYTES_PER_ELEMENT,d=h*l,g=i.byteOffset||0,u=i.bufferView!==void 0?n.bufferViews[i.bufferView].byteStride:void 0,m=i.normalized===!0;let f,p;if(u&&u!==d){const x=Math.floor(g/u),v="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+x+":"+i.count;let _=t.cache.get(v);_||(f=new c(a,x*u,i.count*u/h),_=new M.InterleavedBuffer(f,u/h),t.cache.add(v,_)),p=new M.InterleavedBufferAttribute(_,l,g%u/h,m)}else a===null?f=new c(i.count*l):f=new c(a,g,i.count*l),p=new M.BufferAttribute(f,l,m);if(i.sparse!==void 0){const x=Ya.SCALAR,v=es[i.sparse.indices.componentType],_=i.sparse.indices.byteOffset||0,b=i.sparse.values.byteOffset||0,S=new v(o[1],_,i.sparse.count*x),C=new c(o[2],b,i.sparse.count*l);a!==null&&(p=new M.BufferAttribute(p.array.slice(),p.itemSize,p.normalized)),p.normalized=!1;for(let R=0,I=S.length;R<I;R++){const E=S[R];if(p.setX(E,C[R*l]),l>=2&&p.setY(E,C[R*l+1]),l>=3&&p.setZ(E,C[R*l+2]),l>=4&&p.setW(E,C[R*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}p.normalized=m}return p})}loadTexture(e){const t=this.json,n=this.options,r=t.textures[e].source,o=t.images[r];let a=this.textureLoader;if(o.uri){const l=n.manager.getHandler(o.uri);l!==null&&(a=l)}return this.loadTextureImage(e,r,a)}loadTextureImage(e,t,n){const i=this,r=this.json,o=r.textures[e],a=r.images[t],l=(a.uri||a.bufferView)+":"+o.sampler;if(this.textureCache[l])return this.textureCache[l];const c=this.loadImageSource(t,n).then(function(h){h.flipY=!1,h.name=o.name||a.name||"",h.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(h.name=a.uri);const g=(r.samplers||{})[o.sampler]||{};return h.magFilter=kh[g.magFilter]||M.LinearFilter,h.minFilter=kh[g.minFilter]||M.LinearMipmapLinearFilter,h.wrapS=Bh[g.wrapS]||M.RepeatWrapping,h.wrapT=Bh[g.wrapT]||M.RepeatWrapping,h.generateMipmaps=!h.isCompressedTexture&&h.minFilter!==M.NearestFilter&&h.minFilter!==M.LinearFilter,i.associations.set(h,{textures:e}),h}).catch(function(){return null});return this.textureCache[l]=c,c}loadImageSource(e,t){const n=this,i=this.json,r=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(d=>d.clone());const o=i.images[e],a=self.URL||self.webkitURL;let l=o.uri||"",c=!1;if(o.bufferView!==void 0)l=n.getDependency("bufferView",o.bufferView).then(function(d){c=!0;const g=new Blob([d],{type:o.mimeType});return l=a.createObjectURL(g),l});else if(o.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const h=Promise.resolve(l).then(function(d){return new Promise(function(g,u){let m=g;t.isImageBitmapLoader===!0&&(m=function(f){const p=new M.Texture(f);p.needsUpdate=!0,g(p)}),t.load(M.LoaderUtils.resolveURL(d,r.path),m,void 0,u)})}).then(function(d){return c===!0&&a.revokeObjectURL(l),xn(d,o),d.userData.mimeType=o.mimeType||e_(o.uri),d}).catch(function(d){throw console.error("THREE.GLTFLoader: Couldn't load texture",l),d});return this.sourceCache[e]=h,h}assignTexture(e,t,n,i){const r=this;return this.getDependency("texture",n.index).then(function(o){if(!o)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(o=o.clone(),o.channel=n.texCoord),r.extensions[$e.KHR_TEXTURE_TRANSFORM]){const a=n.extensions!==void 0?n.extensions[$e.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const l=r.associations.get(o);o=r.extensions[$e.KHR_TEXTURE_TRANSFORM].extendTexture(o,a),r.associations.set(o,l)}}return i!==void 0&&(o.colorSpace=i),e[t]=o,o})}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const i=t.attributes.tangent===void 0,r=t.attributes.color!==void 0,o=t.attributes.normal===void 0;if(e.isPoints){const a="PointsMaterial:"+n.uuid;let l=this.cache.get(a);l||(l=new M.PointsMaterial,M.Material.prototype.copy.call(l,n),l.color.copy(n.color),l.map=n.map,l.sizeAttenuation=!1,this.cache.add(a,l)),n=l}else if(e.isLine){const a="LineBasicMaterial:"+n.uuid;let l=this.cache.get(a);l||(l=new M.LineBasicMaterial,M.Material.prototype.copy.call(l,n),l.color.copy(n.color),l.map=n.map,this.cache.add(a,l)),n=l}if(i||r||o){let a="ClonedMaterial:"+n.uuid+":";i&&(a+="derivative-tangents:"),r&&(a+="vertex-colors:"),o&&(a+="flat-shading:");let l=this.cache.get(a);l||(l=n.clone(),r&&(l.vertexColors=!0),o&&(l.flatShading=!0),i&&(l.normalScale&&(l.normalScale.y*=-1),l.clearcoatNormalScale&&(l.clearcoatNormalScale.y*=-1)),this.cache.add(a,l),this.associations.set(l,this.associations.get(n))),n=l}e.material=n}getMaterialType(){return M.MeshStandardMaterial}loadMaterial(e){const t=this,n=this.json,i=this.extensions,r=n.materials[e];let o;const a={},l=r.extensions||{},c=[];if(l[$e.KHR_MATERIALS_UNLIT]){const d=i[$e.KHR_MATERIALS_UNLIT];o=d.getMaterialType(),c.push(d.extendParams(a,r,t))}else{const d=r.pbrMetallicRoughness||{};if(a.color=new M.Color(1,1,1),a.opacity=1,Array.isArray(d.baseColorFactor)){const g=d.baseColorFactor;a.color.setRGB(g[0],g[1],g[2],M.LinearSRGBColorSpace),a.opacity=g[3]}d.baseColorTexture!==void 0&&c.push(t.assignTexture(a,"map",d.baseColorTexture,M.SRGBColorSpace)),a.metalness=d.metallicFactor!==void 0?d.metallicFactor:1,a.roughness=d.roughnessFactor!==void 0?d.roughnessFactor:1,d.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(a,"metalnessMap",d.metallicRoughnessTexture)),c.push(t.assignTexture(a,"roughnessMap",d.metallicRoughnessTexture))),o=this._invokeOne(function(g){return g.getMaterialType&&g.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(g){return g.extendMaterialParams&&g.extendMaterialParams(e,a)})))}r.doubleSided===!0&&(a.side=M.DoubleSide);const h=r.alphaMode||Za.OPAQUE;if(h===Za.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,h===Za.MASK&&(a.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:.5)),r.normalTexture!==void 0&&o!==M.MeshBasicMaterial&&(c.push(t.assignTexture(a,"normalMap",r.normalTexture)),a.normalScale=new M.Vector2(1,1),r.normalTexture.scale!==void 0)){const d=r.normalTexture.scale;a.normalScale.set(d,d)}if(r.occlusionTexture!==void 0&&o!==M.MeshBasicMaterial&&(c.push(t.assignTexture(a,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=r.occlusionTexture.strength)),r.emissiveFactor!==void 0&&o!==M.MeshBasicMaterial){const d=r.emissiveFactor;a.emissive=new M.Color().setRGB(d[0],d[1],d[2],M.LinearSRGBColorSpace)}return r.emissiveTexture!==void 0&&o!==M.MeshBasicMaterial&&c.push(t.assignTexture(a,"emissiveMap",r.emissiveTexture,M.SRGBColorSpace)),Promise.all(c).then(function(){const d=new o(a);return r.name&&(d.name=r.name),xn(d,r),t.associations.set(d,{materials:e}),r.extensions&&bi(i,d,r),d})}createUniqueName(e){const t=M.PropertyBinding.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,n=this.extensions,i=this.primitiveCache;function r(a){return n[$e.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(l){return zh(l,a,t)})}const o=[];for(let a=0,l=e.length;a<l;a++){const c=e[a],h=Qv(c),d=i[h];if(d)o.push(d.promise);else{let g;c.extensions&&c.extensions[$e.KHR_DRACO_MESH_COMPRESSION]?g=r(c):g=zh(new M.BufferGeometry,c,t),i[h]={primitive:c,promise:g},o.push(g)}}return Promise.all(o)}loadMesh(e){const t=this,n=this.json,i=this.extensions,r=n.meshes[e],o=r.primitives,a=[];for(let l=0,c=o.length;l<c;l++){const h=o[l].material===void 0?Kv(this.cache):this.getDependency("material",o[l].material);a.push(h)}return a.push(t.loadGeometries(o)),Promise.all(a).then(function(l){const c=l.slice(0,l.length-1),h=l[l.length-1],d=[];for(let u=0,m=h.length;u<m;u++){const f=h[u],p=o[u];let x;const v=c[u];if(p.mode===tn.TRIANGLES||p.mode===tn.TRIANGLE_STRIP||p.mode===tn.TRIANGLE_FAN||p.mode===void 0)x=r.isSkinnedMesh===!0?new M.SkinnedMesh(f,v):new M.Mesh(f,v),x.isSkinnedMesh===!0&&x.normalizeSkinWeights(),p.mode===tn.TRIANGLE_STRIP?x.geometry=Lh(x.geometry,M.TriangleStripDrawMode):p.mode===tn.TRIANGLE_FAN&&(x.geometry=Lh(x.geometry,M.TriangleFanDrawMode));else if(p.mode===tn.LINES)x=new M.LineSegments(f,v);else if(p.mode===tn.LINE_STRIP)x=new M.Line(f,v);else if(p.mode===tn.LINE_LOOP)x=new M.LineLoop(f,v);else if(p.mode===tn.POINTS)x=new M.Points(f,v);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+p.mode);Object.keys(x.geometry.morphAttributes).length>0&&Jv(x,r),x.name=t.createUniqueName(r.name||"mesh_"+e),xn(x,r),p.extensions&&bi(i,x,p),t.assignFinalMaterial(x),d.push(x)}for(let u=0,m=d.length;u<m;u++)t.associations.set(d[u],{meshes:e,primitives:u});if(d.length===1)return r.extensions&&bi(i,d[0],r),d[0];const g=new M.Group;r.extensions&&bi(i,g,r),t.associations.set(g,{meshes:e});for(let u=0,m=d.length;u<m;u++)g.add(d[u]);return g})}loadCamera(e){let t;const n=this.json.cameras[e],i=n[n.type];if(!i){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return n.type==="perspective"?t=new M.PerspectiveCamera(M.MathUtils.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2e6):n.type==="orthographic"&&(t=new M.OrthographicCamera(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),xn(t,n),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],n=[];for(let i=0,r=t.joints.length;i<r;i++)n.push(this._loadNodeShallow(t.joints[i]));return t.inverseBindMatrices!==void 0?n.push(this.getDependency("accessor",t.inverseBindMatrices)):n.push(null),Promise.all(n).then(function(i){const r=i.pop(),o=i,a=[],l=[];for(let c=0,h=o.length;c<h;c++){const d=o[c];if(d){a.push(d);const g=new M.Matrix4;r!==null&&g.fromArray(r.array,c*16),l.push(g)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[c])}return new M.Skeleton(a,l)})}loadAnimation(e){const t=this.json,n=this,i=t.animations[e],r=i.name?i.name:"animation_"+e,o=[],a=[],l=[],c=[],h=[];for(let d=0,g=i.channels.length;d<g;d++){const u=i.channels[d],m=i.samplers[u.sampler],f=u.target,p=f.node,x=i.parameters!==void 0?i.parameters[m.input]:m.input,v=i.parameters!==void 0?i.parameters[m.output]:m.output;f.node!==void 0&&(o.push(this.getDependency("node",p)),a.push(this.getDependency("accessor",x)),l.push(this.getDependency("accessor",v)),c.push(m),h.push(f))}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(l),Promise.all(c),Promise.all(h)]).then(function(d){const g=d[0],u=d[1],m=d[2],f=d[3],p=d[4],x=[];for(let _=0,b=g.length;_<b;_++){const S=g[_],C=u[_],R=m[_],I=f[_],E=p[_];if(S===void 0)continue;S.updateMatrix&&S.updateMatrix();const T=n._createAnimationTracks(S,C,R,I,E);if(T)for(let U=0;U<T.length;U++)x.push(T[U])}const v=new M.AnimationClip(r,void 0,x);return xn(v,i),v})}createNodeMesh(e){const t=this.json,n=this,i=t.nodes[e];return i.mesh===void 0?null:n.getDependency("mesh",i.mesh).then(function(r){const o=n._getNodeRef(n.meshCache,i.mesh,r);return i.weights!==void 0&&o.traverse(function(a){if(a.isMesh)for(let l=0,c=i.weights.length;l<c;l++)a.morphTargetInfluences[l]=i.weights[l]}),o})}loadNode(e){const t=this.json,n=this,i=t.nodes[e],r=n._loadNodeShallow(e),o=[],a=i.children||[];for(let c=0,h=a.length;c<h;c++)o.push(n.getDependency("node",a[c]));const l=i.skin===void 0?Promise.resolve(null):n.getDependency("skin",i.skin);return Promise.all([r,Promise.all(o),l]).then(function(c){const h=c[0],d=c[1],g=c[2];g!==null&&h.traverse(function(u){u.isSkinnedMesh&&u.bind(g,t_)});for(let u=0,m=d.length;u<m;u++)h.add(d[u]);if(h.userData.pivot!==void 0&&d.length>0){const u=h.userData.pivot,m=d[0];h.pivot=new M.Vector3().fromArray(u),h.position.x-=u[0],h.position.y-=u[1],h.position.z-=u[2],m.position.set(0,0,0),delete h.userData.pivot}return h})}_loadNodeShallow(e){const t=this.json,n=this.extensions,i=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const r=t.nodes[e],o=r.name?i.createUniqueName(r.name):"",a=[],l=i._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});return l&&a.push(l),r.camera!==void 0&&a.push(i.getDependency("camera",r.camera).then(function(c){return i._getNodeRef(i.cameraCache,r.camera,c)})),i._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(e)}).forEach(function(c){a.push(c)}),this.nodeCache[e]=Promise.all(a).then(function(c){let h;if(r.isBone===!0?h=new M.Bone:c.length>1?h=new M.Group:c.length===1?h=c[0]:h=new M.Object3D,h!==c[0])for(let d=0,g=c.length;d<g;d++)h.add(c[d]);if(r.name&&(h.userData.name=r.name,h.name=o),xn(h,r),r.extensions&&bi(n,h,r),r.matrix!==void 0){const d=new M.Matrix4;d.fromArray(r.matrix),h.applyMatrix4(d)}else r.translation!==void 0&&h.position.fromArray(r.translation),r.rotation!==void 0&&h.quaternion.fromArray(r.rotation),r.scale!==void 0&&h.scale.fromArray(r.scale);if(!i.associations.has(h))i.associations.set(h,{});else if(r.mesh!==void 0&&i.meshCache.refs[r.mesh]>1){const d=i.associations.get(h);i.associations.set(h,{...d})}return i.associations.get(h).nodes=e,h}),this.nodeCache[e]}loadScene(e){const t=this.extensions,n=this.json.scenes[e],i=this,r=new M.Group;n.name&&(r.name=i.createUniqueName(n.name)),xn(r,n),n.extensions&&bi(t,r,n);const o=n.nodes||[],a=[];for(let l=0,c=o.length;l<c;l++)a.push(i.getDependency("node",o[l]));return Promise.all(a).then(function(l){for(let h=0,d=l.length;h<d;h++){const g=l[h];g.parent!==null?r.add(wv(g)):r.add(g)}const c=h=>{const d=new Map;for(const[g,u]of i.associations)(g instanceof M.Material||g instanceof M.Texture)&&d.set(g,u);return h.traverse(g=>{const u=i.associations.get(g);u!=null&&d.set(g,u)}),d};return i.associations=c(r),r})}_createAnimationTracks(e,t,n,i,r){const o=[],a=e.name?e.name:e.uuid,l=[];ei[r.path]===ei.weights?e.traverse(function(g){g.morphTargetInfluences&&l.push(g.name?g.name:g.uuid)}):l.push(a);let c;switch(ei[r.path]){case ei.weights:c=M.NumberKeyframeTrack;break;case ei.rotation:c=M.QuaternionKeyframeTrack;break;case ei.translation:case ei.scale:c=M.VectorKeyframeTrack;break;default:switch(n.itemSize){case 1:c=M.NumberKeyframeTrack;break;case 2:case 3:default:c=M.VectorKeyframeTrack;break}break}const h=i.interpolation!==void 0?Zv[i.interpolation]:M.InterpolateLinear,d=this._getArrayFromAccessor(n);for(let g=0,u=l.length;g<u;g++){const m=new c(l[g]+"."+ei[r.path],t.array,d,h);i.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(m),o.push(m)}return o}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const n=$a(t.constructor),i=new Float32Array(t.length);for(let r=0,o=t.length;r<o;r++)i[r]=t[r]*n;t=i}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(n){const i=this instanceof M.QuaternionKeyframeTrack?qv:Oh;return new i(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function i_(s,e,t){const n=e.attributes,i=new M.Box3;if(n.POSITION!==void 0){const a=t.json.accessors[n.POSITION],l=a.min,c=a.max;if(l!==void 0&&c!==void 0){if(i.set(new M.Vector3(l[0],l[1],l[2]),new M.Vector3(c[0],c[1],c[2])),a.normalized){const h=$a(es[a.componentType]);i.min.multiplyScalar(h),i.max.multiplyScalar(h)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const r=e.targets;if(r!==void 0){const a=new M.Vector3,l=new M.Vector3;for(let c=0,h=r.length;c<h;c++){const d=r[c];if(d.POSITION!==void 0){const g=t.json.accessors[d.POSITION],u=g.min,m=g.max;if(u!==void 0&&m!==void 0){if(l.setX(Math.max(Math.abs(u[0]),Math.abs(m[0]))),l.setY(Math.max(Math.abs(u[1]),Math.abs(m[1]))),l.setZ(Math.max(Math.abs(u[2]),Math.abs(m[2]))),g.normalized){const f=$a(es[g.componentType]);l.multiplyScalar(f)}a.max(l)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}i.expandByVector(a)}s.boundingBox=i;const o=new M.Sphere;i.getCenter(o.center),o.radius=i.min.distanceTo(i.max)/2,s.boundingSphere=o}function zh(s,e,t){const n=e.attributes,i=[];function r(o,a){return t.getDependency("accessor",o).then(function(l){s.setAttribute(a,l)})}for(const o in n){const a=qa[o]||o.toLowerCase();a in s.attributes||i.push(r(n[o],a))}if(e.indices!==void 0&&!s.index){const o=t.getDependency("accessor",e.indices).then(function(a){s.setIndex(a)});i.push(o)}return M.ColorManagement.workingColorSpace!==M.LinearSRGBColorSpace&&"COLOR_0"in n&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${M.ColorManagement.workingColorSpace}" not supported.`),xn(s,e),i_(s,e,t),Promise.all(i).then(function(){return e.targets!==void 0?$v(s,e.targets,t):s})}var xt=(s=>(s.ModelLoadStart="model-load-start",s.ModelLoadProgress="model-load-progress",s.ModelLoaded="model-loaded",s.ModelError="model-error",s.SelectionChanged="selection-changed",s.HoverChanged="hover-changed",s.Click="click",s.MouseMove="mouse-move",s.CameraChanged="camera-changed",s.CameraIdle="camera-idle",s.EngineFree="engine-free",s.EngineBusy="engine-busy",s.MeasureChanged="measure-changed",s.MeasureClick="measure-click",s.SectionMove="section-move",s.LoadingCompleted="loading_completed",s))(xt||{});let As=null;const s_=8,Vh=24,r_=24,o_=64,a_=60,l_=10;function Gh(){return new URL("draco/",document.baseURI).toString()}function c_(){return As==null&&(As=new yv,As.setDecoderPath(Gh()),As.preload()),As}function Wh(){return new Promise(s=>{if(typeof requestAnimationFrame=="function"){requestAnimationFrame(()=>s());return}setTimeout(s,16)})}function h_(){const s=navigator?.scheduling;return typeof s?.isInputPending=="function"?s.isInputPending():!1}function d_(s){return s?.engineStatus?.isFree===!1||h_()}async function kn(s,e,t){if(e)return t;const n=performance.now();return d_(s)||n-t>=s_?(await Wh(),performance.now()):t}function u_(s){return new Promise((e,t)=>{Es(s,n=>{if(n==null){t(new Error(`[loadLightModel] empty zip json: ${s}`));return}e(n)},()=>{t(new Error(`[loadLightModel] failed to load zip json: ${s}`))})})}function f_(s){return gt({method:"get",responseType:"arraybuffer",url:s}).then(e=>Xc.loadAsync(e.data))}function Hh(s){return s.replace(/\\/g,"/").replace(/^\/+/,"")}function Xh(s,e){const t=new Set(e.map(n=>Hh(n)));for(const n of Object.keys(s.files))if(t.has(Hh(n)))return s.files[n];return null}function jh(s,e){const t=Xh(s,e);return t==null||t.dir?Promise.resolve(null):t.async("string")}function p_(s){return s.charCodeAt(0)===65279?s.slice(1):s}function Ja(s){return JSON.parse(p_(s))}function m_(s,e){const t=Xh(s,e);return t==null||t.dir?Promise.resolve(null):t.async("arraybuffer")}function g_(s){return new Promise((e,t)=>{const n=new Sv;n.setDRACOLoader(c_()),n.parse(s,document.baseURI,e,t)})}function Hr(s,e){return s.models.find(t=>t.url==e)}function Yh(s){s.loadStatus==null&&(s.loadStatus={}),s.loadStatus.modelMep==null&&(s.loadStatus.modelMep=!1),s.loadStatus.normal==null&&(s.loadStatus.normal=!1)}function x_(s){return Yh(s),s.status==="loaded"&&s.loadStatus.normal===!0&&s.loadStatus.modelMep===!0}function qh(s){const e=s?.engineStatus?.models;!Array.isArray(e)||e.length===0||!e.every(n=>x_(n))||s.__loadingCompletedTriggered===!0||(s.__loadingCompletedTriggered=!0,s.events?.trigger?.(xt.LoadingCompleted,{}))}function Zh(s){return s===!0||s==="loading"}function Kh(s){return s.index!=null?s.index.count:s.attributes.position?.count??0}async function v_(s,e,t){let n=performance.now();for(let i=0;i<e.length;i++){const r=e[i];r?.geometry!=null&&r.geometry.computeVertexNormals,(i+1)%r_===0&&(n=await kn(s,t,n))}}async function __(s,e,t){const n=[],i=[{node:e.octreeBox,visited:!1}];let r=performance.now();for(;i.length>0;){const o=i.pop();if(o==null||o.node==null||o.node.status===!0)continue;const a=o.node;if(o.visited){const c=Array.isArray(a.children)?a.children:[];(c.length===0||c.findIndex(h=>h.status!=!0)===-1)&&(a.status=!0),r=await kn(s,t,r);continue}i.push({node:a,visited:!0}),Array.isArray(a.elements)&&n.push(...a.elements);const l=Array.isArray(a.children)?a.children:[];for(let c=l.length-1;c>=0;c--)i.push({node:l[c],visited:!1});r=await kn(s,t,r)}return n}async function y_(s,e,t,n){const i=Hr(s,e.url);if(i?.nodesMap==null)return[];const r=await __(s,t,n);console.log("[loadLightModel] pending mesh ids",t.path,r.length);const o=[];let a=performance.now(),l=0;for(const c of r){if(!i.nodesMap.has(c))continue;const h=i.nodesMap.get(c),d=Array.isArray(h?.infos)?h.infos:[];for(const g of d){const u=t.glbs?.[g.glb]?.[g.mesh];if(u?.geometry==null||u.material==null)continue;const m=new y.Matrix4;m.elements=g.matrix;const f=u.geometry.clone();f.applyMatrix4(m),f.computeBoundingBox();const p=new y.Mesh(f,u.material);g.box=f.boundingBox?.clone(),g.mesh=p,p.name=Number(c),p.glb=g.glb,p.url=e.url,f.attributes.position!=null&&o.push(p),l++,l%Vh===0&&(a=await kn(s,n,a))}}return o}function M_(s,e,t,n,i){const r=Mi(n.map(a=>a.geometry),!1),o=new y.Mesh(r,i);return o.castShadow=!0,o.receiveShadow=!0,e.scene.add(o),o.index=e.scene.children.length-1,o.url=s,o.glb=t,o.materialClone=i,o.geometrys=n.map(a=>a.geometry),o.geometry.computeVertexNormals(),o}function b_(s,e,t,n){return s.scene.children.find(i=>{const r=i;return i instanceof y.Mesh&&r.url==e&&r.glb==t&&r.materialClone===n})}function w_(s,e){const t=Array.isArray(s.geometrys)?s.geometrys:[],n=e.map(o=>o.geometry),i=[...t,...n],r=Mi(i,!1);s.geometry!=null&&s.geometry.dispose(),s.geometry=r,s.geometrys=i,s.castShadow=!0,s.receiveShadow=!0}async function S_(s,e,t,n){const i=new Map;for(const a of t){const l=i.get(a.glb)??[];l.push(a),i.set(a.glb,l)}const r=Hr(e,s);let o=performance.now();for(const[a,l]of i.entries()){const c=n?l.length:a_;for(let h=0;h<l.length;h+=c){const d=l.slice(h,h+c);if(d.length===0)continue;const g=N_(d[0].material,e);let u=b_(e,s,a,g),m=0,f=0;u=null,u!=null?(m=Array.isArray(u.geometrys)?u.geometrys.length:0,f=Kh(u.geometry),w_(u,d)):u=M_(s,e,a,d,g);const p=new Map;let x=f;d.forEach((v,_)=>{const b=Number(v.name),S=Kh(v.geometry),C=p.get(b)??[];if(C.push([x,x+S]),p.set(b,C),r?.nodesMap?.has(b)){const R=r.nodesMap.get(b);R.indexes==null&&(R.indexes=[]),R.indexes.push([u.index,m+_,x,x+S])}x+=S}),u.indexes==null&&(u.indexes=new Map),p.forEach((v,_)=>{const b=u.indexes.get(_)??[];b.push(...v),u.indexes.set(_,b)}),o=await kn(e,n,o)}}}async function E_(s,e,t,n,i,r){if(n==null||i==null||i.length===0)return;const o=Hr(t,s);if(o==null)return;const a=new y.InstancedMesh(n.geometry,n.material,i.length);t.scene.add(a);const l=new Float32Array(i.length*3);for(let d=0;d<i.length;d++)l[d*3]=1,l[d*3+1]=1,l[d*3+2]=1;a.instanceColor=new y.InstancedBufferAttribute(l,3);let c=performance.now();const h=[];for(let d=0;d<i.length;d++){const g=i[d],u=new y.Matrix4;if(u.elements=g.matrix,a.setMatrixAt(d,u),a.matrixs||(a.matrixs=[]),a.matrixs.push(u.clone()),h.push(u.clone()),o.nodesMap.has(g.id)){const m=o.nodesMap.get(g.id);m.indexes==null&&(m.indexes=[]),m.indexes.push([t.scene.children.length-1,d,0,0])}else o.nodesMap.set(g.id,{instance:!0,info:g,indexes:[[t.scene.children.length-1,d,0,0]]});(d+1)%o_===0&&(c=await kn(t,r,c))}a.instanceMatrix.needsUpdate=!0,a.instanceColor!=null&&(a.instanceColor.needsUpdate=!0),a.index=t.scene.children.length-1,a.materialClone=n.material,a.url=s,a.glb=n.glb,a.ids=i.map(d=>d.id),a.matrixsClone=h,a.meshIndex=e}async function C_(s,e,t,n){const i=e.instanceNodes;if(i==null)return;let r=performance.now();for(const o in i)if(i[o].isLoaded!==!0){i[o].isLoaded=!0;for(const a of i[o]){const l=e.glbs?.[o]?.[a.mesh];l!=null&&await E_(s.url,a.mesh,t,l,a.children,n)}r=await kn(t,n,r)}}async function A_(s,e,t,n){if(t.status===!0||t.meshPromise!=null){await t.meshPromise;return}t.meshPromise=(async()=>{console.log(`[loadLightModel] start build lod meshes ${Date.now()-window.startTime}ms`);const i=await y_(s,e,t,n);await S_(e.url,s,i,n),await C_(e,t,s,n),t.status=!0,console.log(`[loadLightModel] *****************************************************finish build lod meshes ${Date.now()-window.startTime}ms`)})().finally(()=>{t.meshPromise=null}),await t.meshPromise}async function T_(s,e,t,n){if(t.loadSuccess!==!0){if(t.preparePromise!=null){await t.preparePromise;return}t.preparePromise=(async()=>{console.log("[loadLightModel] loading GLB bundle",t.path),t.glbs=t.glbs??{};const i=await f_(e.url+t.path),r=await jh(i,["/nodes.json","nodes.json"]);if(r==null)return;const o=Ja(r),a=Hr(s,e.url);if(a==null)return;a.nodesMap==null&&(a.nodesMap=new Map);let l=performance.now();for(const h of Object.keys(o)){const d=o[h];for(let u=0;u<d.length;u++){const m=d[u];if(m.glb=h,a.nodesMap.has(m.id)===!1)a.nodesMap.set(m.id,{infos:[m]});else{if(!a.nodesMap.get(m.id).infos)continue;a.nodesMap.get(m.id).infos.push(m)}(u+1)%Vh===0&&(l=await kn(s,n,l))}const g=await m_(i,[`/${h}.glb`,`${h}.glb`,h+".glb"]);if(g==null){console.error("[loadLightModel] glb not found in zip",{modelUrl:e.url,lodPath:t.path,glbKey:`${h}.glb`,availableFiles:Object.keys(i.files)});continue}try{const u=await g_(g);t.glbs[h]=u.scene.children,await v_(s,t.glbs[h],n)}catch(u){console.error("[loadLightModel] failed to load glb",{modelUrl:e.url,lodPath:t.path,glbKey:`${h}.glb`,dracoDecoderPath:Gh(),error:u})}l=await kn(s,n,l)}const c=await jh(i,["/instances.json","instances.json"]);t.instanceNodes=c!=null?Ja(c):null,t.loadSuccess=!0})().finally(()=>{t.preparePromise=null}),await t.preparePromise}}function P_(s,e,t){if(t.boundingBox||(t.boundingBox=new y.Box3,t.boundingBox.min=new y.Vector3(t.octreeBox.min.X,t.octreeBox.min.Z,-t.octreeBox.min.Y),t.boundingBox.max=new y.Vector3(t.octreeBox.max.X,t.octreeBox.max.Z,-t.octreeBox.max.Y)),!t.maxSize)return 1e3;const n=t.boundingBox,i=n.min,r=n.max,o=i.clone().add(r.clone()).multiplyScalar(.5),a=i.distanceTo(r),l=new y.Vector3,c=new y.Vector3,h=new y.Vector3,d=new y.Vector3;if(e.getWorldDirection(h),e.getWorldPosition(d),e.matrixWorld.extractBasis(l,c,new y.Vector3),e instanceof y.OrthographicCamera){const x=Math.max((e.top-e.bottom)/e.zoom,1e-6),v=s?.cameraModule?.perspectiveCamera?.getEffectiveFOV?.()??20,_=y.MathUtils.degToRad(v*.5),b=_>0?x/(2*Math.tan(_)):x;d.copy(o).add(h.clone().multiplyScalar(-b))}if(d.distanceTo(o)<=a*.5)return 1e3;const g=o.clone().sub(d).dot(h);if(g<=0)return 0;const u=d.clone().add(h.multiplyScalar(Math.max(g,a))),m=u.clone().add(l.setLength(t.maxSize)),f=new it(e,s.renderer,s.scene).worldToScreen(u),p=new it(e,s.renderer,s.scene).worldToScreen(m);return f.distanceTo(p)}async function D_(s,e,t,n){t.maxSize<1e6&&t.path!="/lod0"&&(!(P_(s,s.camera,t)>=l_)||t.status===!0)||(await T_(s,e,t,n),t.loadSuccess===!0&&await A_(s,e,t,n))}function R_(s,e,t){if(Zh(e.loadStatus.modelMep))return;e.loadStatus.modelMep="loading",e.info.modelMep==null&&(e.info.modelMep={}),(async()=>{t||await Wh(),bv(s,e.info.modelMep,e.url),e.loadStatus.modelMep=!0,qh(s)})().catch(i=>{e.loadStatus.modelMep=!1,console.error("[loadLightModel] failed to load mep model",i)})}function L_(s,e,t,n){const i=new y.Group;i.name=e,s.scene.add(i),s.models||(s.models=[]),window.startTime=Date.now(),u_(e+"/info").then(r=>{const o=Ja(r);s.__loadingCompletedTriggered=!1,s.engineStatus.models.push({type:"light",info:o,name:o.baseInfo.name,status:"loading",url:e,elements:new Map,loadStatus:{modelMep:!1,normal:!1}}),s.models.push({url:e,nodesMap:new Map,grids:o.modelGrid,levels:o.modelLevel,rooms:o.modelRoom,views:o.modelView,boundingBox:{min:new y.Vector3(o.baseInfo.min.X*.3048,o.baseInfo.min.Z*.3048,-o.baseInfo.min.Y*.3048),max:new y.Vector3(o.baseInfo.max.X*.3048,o.baseInfo.max.Z*.3048,-o.baseInfo.max.Y*.3048)}}),s.models.length==n&&(s.viewCube.CameraGoHome(1),setTimeout(()=>{$h(s,null,!1)},100))}).catch(r=>{console.error("[loadLightModel] failed to load model info",{url:e,error:r})})}async function $h(s,e,t=!1){const n=s.engineStatus.models.filter(i=>e==null||i.url==e);for(const i of n)if(Yh(i),!(i.status!=="loading"||i.type!=="light")&&(R_(s,i,t),!Zh(i.loadStatus.normal))){i.loadStatus.normal="loading";try{await I_(s,i,t)}finally{const r=Array.isArray(i.info?.lods)&&i.info.lods.every(o=>o.status===!0);i.loadStatus.normal=r,r&&(i.status="loaded"),qh(s)}}}async function I_(s,e,t=!1){if(console.log(`[loadLightModel] start loadNode ${Date.now()-window.startTime}ms`),!(e.info==null||e.info.lods==null))for(const n of e.info.lods)await D_(s,e,n,t)}function N_(s,e){return s.map!=null&&(s.map.colorSpace=y.SRGBColorSpace,s.map.needsUpdate=!0),s.clipShadows=!0,e?.sectionPlane&&(s.clippingPlanes=e.sectionPlane),s}class U_{engine;constructor(e){this.engine=e}async loadModels(e,t){console.log("待加载模型",e);for(const i of e)n(i)==="light"&&L_(this.engine,i,t,e.length);function n(i){const r=i.split(".").pop();return r==="glb"||r==="gltf"?"gltf":"light"}}}var ts=(s=>(s.ModelLoadStart="model-load-start",s.ModelLoadProgress="model-load-progress",s.ModelLoaded="model-loaded",s.ModelError="model-error",s.SelectionChanged="selection-changed",s.HoverChanged="hover-changed",s.Click="click",s.MouseMove="mouse-move",s.CameraChanged="camera-changed",s.CameraIdle="camera-idle",s.ViewportResize="viewport-resize",s.EngineFree="engine-free",s.EngineBusy="engine-busy",s.MeasureChanged="measure-changed",s.SectionMove="section-move",s.LoadingCompleted="loading_completed",s))(ts||{});class F_{engine;isFree;isForceFree;highlightModels;hideModels;translucentModels;models;constructor(e){this.engine=e,this.isFree=!0,this.isForceFree=!1,this.highlightModels=[],this.hideModels=[],this.translucentModels=[],this.models=[]}init(){this.engine.events.on(ts.EngineFree,e=>{this.updateFree(!0),$h(this.engine,e,!1)}),this.engine.events.on(ts.EngineBusy,()=>{this.updateFree(!1)})}updateFree(e){this.isFree=e}closeAllFunction=()=>{}}let O_=class{listeners=new Map;debugMode=!1;setDebugMode(e){this.debugMode=e}on(e,t){const n=String(e);this.listeners.has(n)||this.listeners.set(n,[]),this.listeners.get(n).push(t),this.debugMode&&console.debug(`[EventModule] 注册事件监听器: ${n}, 当前监听器数量: ${this.listeners.get(n).length}`)}off(e,t){const n=String(e);if(!this.listeners.has(n)){this.debugMode&&console.warn(`[EventModule] 尝试移除不存在的事件监听器: ${n}`);return}const i=this.listeners.get(n),r=i.indexOf(t);r!==-1?(i.splice(r,1),this.debugMode&&console.debug(`[EventModule] 移除事件监听器: ${n}, 剩余监听器数量: ${i.length}`)):this.debugMode&&console.warn(`[EventModule] 尝试移除的回调函数未找到: ${n}`)}trigger(e,t){const n=String(e);if(!this.listeners.has(n)){this.debugMode&&(console.warn(`[EventModule] 触发事件但未找到监听器: ${n}`),console.debug("[EventModule] 当前已注册的事件类型:",Array.from(this.listeners.keys())));return}const i=this.listeners.get(n);this.debugMode&&console.debug(`[EventModule] 触发事件: ${n}, 监听器数量: ${i.length}`,t),i.forEach((r,o)=>{try{r(t)}catch(a){console.error(`[EventModule] 事件监听器执行错误 [${n}] #${o}:`,a)}})}};class k_{engine;constructor(e){this.engine=e}init(){const e=new y.DirectionalLight(16777215,1);e.position.set(100,200,100),e.castShadow=!0,e.shadow.mapSize.width=2048,e.shadow.mapSize.height=2048,e.shadow.camera.near=.1,e.shadow.camera.far=5e3,e.shadow.bias=-5e-5,e.shadow.normalBias=.02;const t=50;e.shadow.camera.left=-t,e.shadow.camera.right=t,e.shadow.camera.top=t,e.shadow.camera.bottom=-t,e.shadow.radius=2;const n=new y.DirectionalLight(16777215,2);this.engine.scene.add(e),this.engine.scene.add(n),this.engine.scene.dirLight=n;const i=new y.AmbientLight(16777215,2);this.engine.scene.add(i)}}class B_{engine;behavior;isCtrlDown=!1;isShiftDown=!1;hoverOldId=null;timeOutEvent;selectionBox=null;isBoxSelecting=!1;selectionStart=new y.Vector2;selectionEnd=new y.Vector2;suppressClickOnce=!1;selectionThreshold=5;tempInstanceMatrix=new y.Matrix4;tempScale=new y.Vector3;constructor(e){this.engine=e}init(){this.behavior=this.engine.handelBehaved,this.ensureSelectionBox(),this.behavior.init(this)}active(){this.behavior.active()}disActive(){this.cancelBoxSelection(),this.behavior.disActive()}handelKeyCtrlUp(){this.isCtrlDown=!1,this.isBoxSelecting&&this.cancelBoxSelection()}handelKeyCtrlDown(){this.isCtrlDown=!0}handelKeyShiftUp(){this.isShiftDown=!1}handelKeyShiftDown(){this.isShiftDown=!0}handleMouseDown(e){e.button!==0||!this.isBoxSelectionModifierDown()||(this.isBoxSelecting=!0,this.selectionStart.set(e.offsetX,e.offsetY),this.selectionEnd.copy(this.selectionStart),this.suppressClickOnce=!1,this.clearHoverFeedback(),this.updateSelectionBox(),this.engine.controls&&(this.engine.controls.enabled=!1))}handleMouseMove(e){if(this.clearHoverTimeout(),this.isBoxSelecting){this.selectionEnd.set(e.offsetX,e.offsetY),this.clearHoverFeedback(),this.updateSelectionBox();return}if(e.catch!=null&&(this.engine.hoverHighLight.showModelNameTag(null,null),this.timeOutEvent=setTimeout(()=>{this.hoverOldId=null;const n=this.getCatchMeshs(e,!0);n!=null&&n.length>0&&this.engine.hoverHighLight.showModelNameTag({url:n[0].url,ids:[n[0].name]},e.catch.point)},1e3)),!this.engine.engineStatus.isFree){this.engine.hoverHighLight.clearHighlight();return}const t=this.getCatchMeshs(e);if(t!=null&&t.length>0){this.engine.hoverHighLight.hightMesh(t);return}}handleMouseUp(e){if(!this.isBoxSelecting)return;this.selectionEnd.set(e.offsetX,e.offsetY);const t=this.hasSelectionBox(),n=t?this.collectModelsInSelection():[];this.isBoxSelecting=!1,this.hideSelectionBox(),this.engine.controls&&(this.engine.controls.enabled=!0),t&&(this.isBoxDeselectMode()?this.applyBoxDeselection(n):this.applyBoxSelection(n),this.suppressClickOnce=!0)}getCatchMeshs(e,t=!1){if(e.catch==null)return this.hoverOldId=null,null;if(e.catch.object.isInstance){const c=e.catch.object,h=e.catch.object.id,g=this.engine.models.find(f=>f.url==c.url)?.nodesMap?.get(h),u=new Map;g?.indexes.forEach(f=>{this.getSceneModel(f[0])instanceof y.InstancedMesh&&(u.has(f[0])||u.set(f[0],[]),u.get(f[0])?.push(f[1]))});const m=[];return u.forEach((f,p)=>{const x=this.getSceneModel(p);f.forEach(v=>{const _=x.geometry.clone();_.applyMatrix4(x.matrixs[v]),m.push(new y.Mesh(_,x.material))})}),this.hoverOldId==h?[]:(this.hoverOldId=h,t||this.engine.hoverHighLight.clearHighlight(),m)}const i=e.catch.object,r=i.name,l=this.engine.models.find(c=>c.url===i.url)?.nodesMap?.get(r)?.infos?.map(c=>c.mesh)??[];return this.hoverOldId==r?[]:(this.hoverOldId=r,t||this.engine.hoverHighLight.clearHighlight(),l)}handleMouseClick(e){if(this.suppressClickOnce){this.suppressClickOnce=!1;return}if(this.isShiftDown&&!this.isCtrlDown)return;if(e.catch!=null){const n=e.catch,i=n.object;if(!this.isCtrlDown){this.engine.modelToolModule.unhighlightAllModels();const o=new CustomEvent("D3ElementClick",{detail:{id:-1}});window.dispatchEvent(o)}this.engine.controlModule.orbitControls.origin.set(n.point.x,n.point.y,n.point.z),this.engine.modelToolModule.highlightModel([{url:i.url,ids:[i.name]}]),this.engine.events.trigger(xt.Click,[{url:i.url,ids:[i.name]}]);const r=new CustomEvent("D3ElementClick",{detail:{id:i.name}});window.dispatchEvent(r);return}const t=new CustomEvent("D3ElementClick",{detail:{id:-1}});window.dispatchEvent(t),this.engine.modelToolModule.unhighlightAllModels()}handleMouseDoubleClick(e){if(!e.catch){this.engine.viewCube.CameraGoHome(500);return}const t=e.catch,n=t.object,r=this.engine.models.find(l=>l.url===n.url)?.nodesMap?.get(n.name);if(!r)return;if(t.object.isInstance){const l=t.matrix,c=[];r.indexes.forEach(d=>{const g=this.getSceneModel(d[0]);g?.geometry?.boundingSphere||g?.geometry?.computeBoundingSphere?.();const u=g?.geometry?.boundingSphere;if(!u)return;const m=new y.Box3,f=u.center.clone().applyMatrix4(l),p=u.radius,x=new y.Vector3().setFromMatrixScale(l),v=p*Math.max(x.x,x.y,x.z);m.min.set(f.x-v,f.y-v,f.z-v),m.max.set(f.x+v,f.y+v,f.z+v),c.push(m)});const h=this.getMergedBox(c);h!=null&&this.engine.viewCube.zoomToModel(h);return}const o=r.infos.map(l=>l.box).filter(l=>l instanceof y.Box3),a=this.getMergedBox(o);a!=null&&this.engine.viewCube.zoomToModel(a)}handleMouseClickInstance(e){return e.intersectObjects(this.engine.scene.children.filter(t=>t instanceof y.InstancedMesh),!0)}ensureSelectionBox(){if(this.selectionBox!=null)return;const e=document.createElement("div");e.style.position="absolute",e.style.left="0px",e.style.top="0px",e.style.display="none",e.style.pointerEvents="none",e.style.border="1px dashed #00aaff",e.style.backgroundColor="rgba(0, 170, 255, 0.12)",e.style.boxSizing="border-box",e.style.zIndex="1001",this.engine.container?.appendChild(e),this.selectionBox=e}updateSelectionBox(){if(this.selectionBox==null)return;if(!this.hasSelectionBox()){this.selectionBox.style.display="none";return}const e=this.getSelectionRect();this.selectionBox.style.display="block",this.selectionBox.style.left=`${e.left}px`,this.selectionBox.style.top=`${e.top}px`,this.selectionBox.style.width=`${e.right-e.left}px`,this.selectionBox.style.height=`${e.bottom-e.top}px`}hideSelectionBox(){this.selectionBox!=null&&(this.selectionBox.style.display="none")}cancelBoxSelection(){this.isBoxSelecting=!1,this.hideSelectionBox(),this.engine.controls&&(this.engine.controls.enabled=!0)}clearHoverTimeout(){this.timeOutEvent!=null&&(clearTimeout(this.timeOutEvent),this.timeOutEvent=null)}clearHoverFeedback(){this.hoverOldId=null,this.engine.hoverHighLight.clearHighlight(),this.engine.hoverHighLight.showModelNameTag(null,null)}hasSelectionBox(){return Math.abs(this.selectionEnd.x-this.selectionStart.x)>=this.selectionThreshold&&Math.abs(this.selectionEnd.y-this.selectionStart.y)>=this.selectionThreshold}getSelectionRect(){return{left:Math.min(this.selectionStart.x,this.selectionEnd.x),top:Math.min(this.selectionStart.y,this.selectionEnd.y),right:Math.max(this.selectionStart.x,this.selectionEnd.x),bottom:Math.max(this.selectionStart.y,this.selectionEnd.y)}}isContainMode(){return this.selectionEnd.x>=this.selectionStart.x&&this.selectionEnd.y>=this.selectionStart.y}isBoxSelectionModifierDown(){return this.isCtrlDown}isBoxDeselectMode(){return this.isShiftDown}collectModelsInSelection(){const e=this.getSelectionRect(),t=this.isContainMode(),n=new Map;return this.engine.models?.forEach(i=>{!i?.url||!i?.nodesMap||i.nodesMap.forEach((r,o)=>{const a=this.getNodeWorldBox(r),l=this.projectBoxToScreenRect(a);l==null||!(t?this.containsRect(e,l):this.intersectsRect(e,l))||(n.has(i.url)||n.set(i.url,new Set),n.get(i.url)?.add(o))})}),Array.from(n.entries()).map(([i,r])=>({url:i,ids:Array.from(r)}))}applyBoxSelection(e){const t=this.excludeHighlightedModels(e);t.length!==0&&(this.engine.modelToolModule.highlightModel(t),this.engine.events.trigger(xt.SelectionChanged,t))}applyBoxDeselection(e){const t=this.keepHighlightedModels(e);t.length!==0&&(this.engine.modelToolModule.unhighlightModel(t),this.removeModelsFromHighlightState(t),this.engine.events.trigger(xt.SelectionChanged,t))}excludeHighlightedModels(e){const t=new Map;return(this.engine.engineStatus.highlightModels??[]).forEach(n=>{t.has(n.url)||t.set(n.url,new Set),n.ids.forEach(i=>t.get(n.url)?.add(i))}),e.map(n=>({url:n.url,ids:n.ids.filter(i=>!t.get(n.url)?.has(i))})).filter(n=>n.ids.length>0)}keepHighlightedModels(e){const t=new Map;return(this.engine.engineStatus.highlightModels??[]).forEach(n=>{t.has(n.url)||t.set(n.url,new Set),n.ids.forEach(i=>t.get(n.url)?.add(i))}),e.map(n=>({url:n.url,ids:n.ids.filter(i=>t.get(n.url)?.has(i))})).filter(n=>n.ids.length>0)}removeModelsFromHighlightState(e){const t=new Map;e.forEach(n=>{t.has(n.url)||t.set(n.url,new Set),n.ids.forEach(i=>t.get(n.url)?.add(i))}),this.engine.engineStatus.highlightModels=(this.engine.engineStatus.highlightModels??[]).map(n=>({url:n.url,ids:n.ids.filter(i=>!t.get(n.url)?.has(i))})).filter(n=>n.ids.length>0)}getNodeWorldBox(e){if(Array.isArray(e?.infos)&&e.infos.length>0){const t=e.infos.map(n=>n?.box).filter(n=>n instanceof y.Box3);return this.getMergedBox(t)}if(Array.isArray(e?.indexes)&&e.indexes.length>0){const t=[];return e.indexes.forEach(n=>{const i=this.getSceneModel(n[0]),r=this.getInstanceWorldBox(i,n[1]);r!=null&&t.push(r)}),this.getMergedBox(t)}return null}getInstanceWorldBox(e,t){if(!(e instanceof y.InstancedMesh))return null;e.geometry.boundingBox||e.geometry.computeBoundingBox();const n=e.geometry.boundingBox;if(!n)return null;if(typeof e.getMatrixAt=="function")e.getMatrixAt(t,this.tempInstanceMatrix);else if(e.matrixs?.[t])this.tempInstanceMatrix.copy(e.matrixs[t]);else return null;return this.tempScale.setFromMatrixScale(this.tempInstanceMatrix),Math.abs(this.tempScale.x)+Math.abs(this.tempScale.y)+Math.abs(this.tempScale.z)<1e-6?null:n.clone().applyMatrix4(this.tempInstanceMatrix)}projectBoxToScreenRect(e){if(e==null||e.isEmpty())return null;const t=[new y.Vector3(e.min.x,e.min.y,e.min.z),new y.Vector3(e.min.x,e.min.y,e.max.z),new y.Vector3(e.min.x,e.max.y,e.min.z),new y.Vector3(e.min.x,e.max.y,e.max.z),new y.Vector3(e.max.x,e.min.y,e.min.z),new y.Vector3(e.max.x,e.min.y,e.max.z),new y.Vector3(e.max.x,e.max.y,e.min.z),new y.Vector3(e.max.x,e.max.y,e.max.z)];let n=1/0,i=1/0,r=-1/0,o=-1/0;return t.forEach(a=>{const l=new it(this.engine.camera,this.engine.renderer,this.engine.scene).worldToScreen(a);!Number.isFinite(l.x)||!Number.isFinite(l.y)||(n=Math.min(n,l.x),i=Math.min(i,l.y),r=Math.max(r,l.x),o=Math.max(o,l.y))}),!Number.isFinite(n)||!Number.isFinite(i)||!Number.isFinite(r)||!Number.isFinite(o)?null:{left:n,top:i,right:r,bottom:o}}containsRect(e,t){return t.left>=e.left&&t.top>=e.top&&t.right<=e.right&&t.bottom<=e.bottom}intersectsRect(e,t){return!(t.right<e.left||t.left>e.right||t.bottom<e.top||t.top>e.bottom)}getMergedBox(e){if(e.length===0)return null;const t=new y.Box3().makeEmpty();return e.forEach(n=>t.union(n)),t.isEmpty()?null:t}getSceneModel(e){return this.engine.scene.children.find(t=>t.index===e)??this.engine.scene.children[e]}}class z_{engine;highlightMaterial;hideMaterial;translucentMaterial;constructor(e){this.engine=e,this.highlightMaterial=new y.MeshBasicMaterial({color:43775,depthTest:!1,depthWrite:!1,transparent:!0,opacity:.5,side:y.DoubleSide}),this.hideMaterial=new y.MeshBasicMaterial({color:0,transparent:!0,opacity:0,side:y.DoubleSide}),this.translucentMaterial=new y.MeshBasicMaterial({color:16777215,transparent:!0,opacity:.05,side:y.DoubleSide}),this.highlightMaterial.clippingPlanes=this.engine.sectionPlane,this.hideMaterial.clippingPlanes=this.engine.sectionPlane,this.translucentMaterial.clippingPlanes=this.engine.sectionPlane}split_merge_model(e){if(e.isSplit||e instanceof y.InstancedMesh)return;let t=e.materialClone.clone(),n=Mi(e.geometrys,!0);n.computeVertexNormals(),n.groups.forEach(i=>{i.materialIndex=0}),e.geometry=n,e.material=[t,this.highlightMaterial,this.translucentMaterial],e.needsUpdate=!0,e.isSplit=!0}un_split_merge_model(e){}getSceneModel(e){return this.engine.scene.children.find(t=>t.index==e)}highlightModel(e){e.forEach(t=>{let n=new Map;t.ids.forEach(r=>{let o=this.engine.models.find(a=>a.url==t.url).nodesMap.get(r);o!=null&&o.indexes!=null&&o.indexes.forEach(a=>{this.getSceneModel(a[0])instanceof y.InstancedMesh?n.has(a[0])?n.get(a[0])?.push(a[1]):n.set(a[0],[a[1]]):(console.log(this.getSceneModel(a[0]).materialClone.color),this.split_merge_model(this.getSceneModel(a[0])),this.getSceneModel(a[0]).geometry.groups[a[1]].materialIndex=1)})}),V_(n,this.engine);let i=this.engine.engineStatus.highlightModels.find(r=>r.url==t.url);i!=null?i.ids.push(...t.ids):this.engine.engineStatus.highlightModels.push(t)})}unhighlightModel(e){e.forEach(t=>{let n=new Map;t.ids.forEach(i=>{let r=this.engine.models.find(o=>o.url==t.url).nodesMap.get(i);r!=null&&r.indexes!=null&&r.indexes.forEach(o=>{this.getSceneModel(o[0])instanceof y.InstancedMesh?n.has(o[0])?n.get(o[0])?.push(o[1]):n.set(o[0],[o[1]]):this.getSceneModel(o[0]).geometry.groups[o[1]].materialIndex=0})}),Jh(n,this.engine,"highlightModel")})}unhighlightAllModels(e=!0){this.engine.engineStatus.highlightModels.forEach(t=>{this.unhighlightModel([t])}),e&&(this.engine.engineStatus.highlightModels=[])}hideModel(e){e.forEach(t=>{let n=new Map;t.ids.forEach(r=>{let o=this.engine.models.find(a=>a.url==t.url).nodesMap.get(r);this.engine.modelEdge.hideModelEdge(t.url,r),o!=null&&o.indexes!=null&&o.indexes.forEach(a=>{const l=this.getSceneModel(a[0]);l instanceof y.InstancedMesh?n.has(a[0])?n.get(a[0])?.push(a[1]):n.set(a[0],[a[1]]):(this.split_merge_model(this.getSceneModel(a[0])),l.geometry.groups[a[1]].materialIndex=-1,l.geometry.groups[a[1]].visible=!1)})}),n.size>0&&W_(n,this.engine);let i=this.engine.engineStatus.hideModels.find(r=>r.url==t.url);i!=null?i.ids.push(...t.ids):this.engine.engineStatus.hideModels.push({url:t.url,ids:t.ids}),this.engine.engineStatus.highlightModels=[]})}showModel(e){e.forEach(t=>{let n=new Map;t.ids.forEach(r=>{let o=this.engine.models.find(a=>a.url==t.url).nodesMap.get(r);this.engine.modelEdge.showModelEdge(t.url,r),o!=null&&o.indexes!=null&&o.indexes.forEach(a=>{const l=this.getSceneModel(a[0]);l instanceof y.InstancedMesh?n.has(a[0])?n.get(a[0])?.push(a[1]):n.set(a[0],[a[1]]):(l.geometry.groups[a[1]].materialIndex=0,l.geometry.groups[a[1]].visible=!0)})}),n.size>0&&Qh(n,this.engine);let i=this.engine.engineStatus.hideModels.find(r=>r.url==t.url);i&&(t.ids.forEach(r=>{const o=i.ids.indexOf(r);o!==-1&&i.ids.splice(o,1)}),i.ids.length===0&&(this.engine.engineStatus.hideModels=this.engine.engineStatus.hideModels.filter(r=>r!==i)))})}isolateModel(e){let t=[];this.engine.models.forEach(n=>{let i={url:n.url,ids:[]},r=e.find(o=>o.url==n.url);for(let o of n.nodesMap)r==null?i.ids.push(o[0]):r.ids.includes(o[0])||i.ids.push(o[0]);t.push(i)});debugger;this.unhighlightAllModels(),this.hideModel(t)}translucentOtherModel(e){let t=[];this.engine.models.forEach(n=>{let i={url:n.url,ids:[]},r=e.find(o=>o.url==n.url);for(let o of n.nodesMap)r==null?i.ids.push(o[0]):r.ids.includes(o[0])||i.ids.push(o[0]);t.push(i)}),this.translucentModel(t)}setModelColor(e,t){e.material.color.set(t)}setAllModelsColor(e){this.engine.scene.children.forEach(t=>{t.isMesh})}restoreAllModelsColor(){this.engine.scene.children.forEach(e=>{e.isMesh})}translucentModel(e){this.unhighlightAllModels(),e.forEach(t=>{let n=new Map;t.ids.forEach(r=>{let o=this.engine.models.find(a=>a.url==t.url).nodesMap.get(r);o!=null&&o.indexes!=null&&o.indexes.forEach(a=>{const l=this.getSceneModel(a[0]);l instanceof y.InstancedMesh?n.has(a[0])?n.get(a[0])?.push(a[1]):n.set(a[0],[a[1]]):(this.split_merge_model(this.getSceneModel(a[0])),l.geometry.groups[a[1]].materialIndex=2)})}),G_(n,this.engine);let i=this.engine.engineStatus.translucentModels.find(r=>r.url==t.url);i!=null?i.ids.push(...t.ids):this.engine.engineStatus.translucentModels.push({url:t.url,ids:t.ids})}),this.engine.engineStatus.highlightModels=[]}unTranslucentModel(){this.engine.engineStatus.translucentModels.forEach(t=>{let n=new Map;t.ids.forEach(i=>{let r=this.engine.models.find(o=>o.url==t.url).nodesMap.get(i);r!=null&&r.indexes!=null&&r.indexes.forEach(o=>{const a=this.getSceneModel(o[0]);a instanceof y.InstancedMesh?n.has(o[0])?n.get(o[0])?.push(o[1]):n.set(o[0],[o[1]]):(this.split_merge_model(this.getSceneModel(o[0])),a.geometry.groups[o[1]].materialIndex=0)})}),n.size>0&&Qh(n,this.engine),Jh(n,this.engine,"translucentModel")}),this.engine.engineStatus.translucentModels=[]}showAllModels(){this.engine.engineStatus.hideModels&&this.engine.engineStatus.hideModels.length>0&&this.showModel(this.engine.engineStatus.hideModels),this.engine.engineStatus.hideModels=[],this.unhighlightAllModels()}batchSelectSameLevelTypeModel(e){if(e.length==0)return;let t=e[0],n=this.engine.modelMapperBatch.getModelMapper(t.url,t.ids[0]);this.engine.modelMapperBatch.getModelsWithLevelType(n.levelName,n.typeName,i=>{this.engine.modelToolModule.highlightModel(i)})}batchSelectSameLevelModel(e){if(e.length==0)return;let t=e[0],n=this.engine.modelMapperBatch.getModelMapper(t.url,t.ids[0]);this.engine.modelMapperBatch.getModelsWithLevel(n.levelName,i=>{this.engine.modelToolModule.highlightModel(i)})}batchSelectSameTypeModel(e){if(e.length==0)return;let t=e[0],n=this.engine.modelMapperBatch.getModelMapper(t.url,t.ids[0]);this.engine.modelMapperBatch.getModelsWithType(n.typeName,i=>{this.engine.modelToolModule.highlightModel(i)})}}function V_(s,e){s.forEach((t,n)=>{const i=Ts(e,n);if(!(i instanceof y.InstancedMesh))return;const r=i.geometry,o=new y.MeshBasicMaterial({color:43775,depthTest:!1,depthWrite:!1,transparent:!0,opacity:.5,side:y.DoubleSide}),a=new y.InstancedMesh(r,o,t.length);a.name="highlightModel",a.key=n;const l=new Map,c=new y.Matrix4,h=new y.Matrix4;h.makeScale(0,0,0),t.forEach((d,g)=>{i.getMatrixAt(d,c),l.set(d,c.clone()),i.setMatrixAt(d,h),a.setMatrixAt(g,c)}),i.instanceMatrix.needsUpdate=!0,a.instanceMatrix.needsUpdate=!0,e.scene.add(a)})}function Jh(s,e,t){s.forEach((n,i)=>{const r=Ts(e,i);if(!(r instanceof y.InstancedMesh))return;n.forEach(a=>{const l=r.matrixsClone[a];l&&r.setMatrixAt(a,l)}),r.instanceMatrix.needsUpdate=!0,e.scene.children.filter(a=>a.key==i&&a.name==t).forEach(a=>{e.scene.remove(a)})})}function G_(s,e){s.forEach((t,n)=>{const i=Ts(e,n);if(!(i instanceof y.InstancedMesh))return;const r=i.geometry,o=new y.MeshBasicMaterial({color:16777215,transparent:!0,opacity:.05,side:y.DoubleSide}),a=new y.InstancedMesh(r,o,t.length);a.name="translucentModel",a.key=n;const l=new Map,c=new y.Matrix4,h=new y.Matrix4;h.makeScale(0,0,0),t.forEach((d,g)=>{i.getMatrixAt(d,c),l.set(d,c.clone()),i.setMatrixAt(d,h),a.setMatrixAt(g,c)}),i.instanceMatrix.needsUpdate=!0,a.instanceMatrix.needsUpdate=!0,e.scene.add(a)})}function W_(s,e){e.scene.children.filter(t=>t.name=="highlightModel").forEach(t=>{e.scene.remove(t)}),s.forEach((t,n)=>{const i=Ts(e,n);if(!(i instanceof y.InstancedMesh))return;const r=new Map,o=new y.Matrix4,a=new y.Matrix4;a.makeScale(0,0,0),t.forEach((l,c)=>{i.getMatrixAt(l,o),r.set(l,o.clone()),i.setMatrixAt(l,a)}),i.instanceMatrix.needsUpdate=!0})}function Qh(s,e){s.forEach((t,n)=>{const i=Ts(e,n);i instanceof y.InstancedMesh&&(t.forEach(r=>{const o=i.matrixs[r];o&&i.setMatrixAt(r,o)}),i.instanceMatrix.needsUpdate=!0)})}function Ts(s,e){return s.scene.children.find(t=>t.index==e)}class H_{engine;currentMode="";isManualMode=!1;gtaoPass=null;ssaoPass=null;saturationPass=null;outputPass=null;fxaaPass=null;constructor(e){this.engine=e}init(){this.cachePassReferences(),this.autoSwitch("advanced")}switchModel(e){this.isManualMode=!0,this.currentMode=e,this.applyMode(e)}autoSwitch(e){this.isManualMode||(this.currentMode=e,this.applyMode(e))}enableAutoMode(){this.isManualMode=!1}get isManual(){return this.isManualMode}setMode(e){debugger;this.isManualMode=!0,this.currentMode=e,this.applyMode(e)}getCurrentMode(){return this.currentMode}cachePassReferences(){this.engine.composerModule?.composer&&(this.engine.composerModule.gtaoPass&&(this.gtaoPass=this.engine.composerModule.gtaoPass),this.engine.composerModule.ssaoPass&&(this.ssaoPass=this.engine.composerModule.ssaoPass),this.engine.composerModule.saturationPass&&(this.saturationPass=this.engine.composerModule.saturationPass),this.engine.composerModule.outputPass&&(this.outputPass=this.engine.composerModule.outputPass),this.engine.composerModule.fxaaPass&&(this.fxaaPass=this.engine.composerModule.fxaaPass))}applyMode(e){switch(e){case"simple":this.setShadows(!1),this.setGTAO(!1),this.setSSAO(!1),this.setSaturation(!1),this.setOutputPass(!1),this.setFXAA(!0);break;case"balance":this.setShadows(!0),this.setGTAO(!1),this.setSSAO(!1),this.setSaturation(!1),this.setOutputPass(!1),this.setFXAA(!0);break;case"advanced":this.setShadows(!0),this.setSSAO(!1),this.setGTAO(!0),this.setSaturation(!1),this.setOutputPass(!1),this.setFXAA(!0);break;default:console.warn(`[EngineModelModule] Unknown mode: ${e}`)}this.engine.updateVersionDisplay?.()}setShadows(e){this.engine.renderer&&(this.engine.renderer.shadowMap.enabled=e);const t=this.engine.scene?.children.find(n=>n instanceof y.DirectionalLight);t&&(t.castShadow=e),this.engine.scene?.traverse(n=>{n.material&&(n.castShadow!==void 0&&(n.castShadow=e),n.receiveShadow!==void 0&&(n.receiveShadow=e))})}setGTAO(e){this.engine.composerModule?.composer&&this.gtaoPass&&(this.gtaoPass.enabled=e)}setSSAO(e){this.engine.composerModule?.composer&&this.ssaoPass&&(this.ssaoPass.enabled=e)}setSaturation(e){this.saturationPass&&(this.saturationPass.enabled=e)}setOutputPass(e){this.outputPass&&(this.outputPass.enabled=e)}setFXAA(e){this.fxaaPass&&(this.fxaaPass.enabled=e)}setPerformanceMode(){this.setMode("simple")}setBalancedMode(){this.setMode("balance")}setQualityMode(){this.setMode("advanced")}setSuperQualityMode(){this.setMode("superAdvanced")}setShadowQuality(e){const t=this.engine.scene?.children.find(r=>r instanceof y.DirectionalLight),i={low:1024,medium:2048,high:2048}[e];t?.shadow&&i&&(t.shadow.mapSize.width=i,t.shadow.mapSize.height=i,t.shadow.map?.dispose(),t.shadow.map=null)}setSaturationValue(e){this.saturationPass&&(this.saturationPass.uniforms.saturation.value=e)}setContrastValue(e){this.saturationPass&&(this.saturationPass.uniforms.contrast.value=e)}setGTAOIntensity(e){this.gtaoPass&&(this.gtaoPass.blendIntensity=e)}}class Xr{engine;overlayMaterial;overlayMeshes=[];animState="idle";animStartTime=0;static FADE_IN_MS=200;static FADE_OUT_MS=150;tagDiv;constructor(e){this.engine=e,this.init();const t=document.createElement("div");this.tagDiv=t,t.className="tagDiv",t.style.position="absolute",t.style.top="0px",t.style.left="0px",t.style.borderRadius="10px",t.style.pointerEvents="none",this.engine.container.appendChild(this.tagDiv)}showModelNameTag(e,t){if(e==null){this.tagDiv.style.display="none";return}let n=this.engine.models.find(a=>a.url==e.url);if(n==null){this.tagDiv.style.display="none";return}let i=n.nodesMap.get(e.ids[0]);if(i.infos&&i.infos.length>0){let a=i.infos[0].name.replace(/\s*\[[a-f0-9-]+\]$/,"");this.tagDiv.innerHTML=a}const o=this.engine.worldToScreen.worldToScreen(t);this.tagDiv?(this.tagDiv.style.left=o.x+10+this.engine.reactBoundingClientRect.left+"px",this.tagDiv.style.top=o.y-10+this.engine.reactBoundingClientRect.top+"px",this.tagDiv.style.display="block"):this.tagDiv&&(this.tagDiv.style.display="none")}init(){this.overlayMaterial=new y.MeshBasicMaterial({color:16777215,transparent:!0,opacity:0,blending:y.AdditiveBlending,depthWrite:!1}),this.overlayMaterial.clippingPlanes=this.engine.sectionPlane}hightMesh(e,t=16777215,n=.15){this.animState==="fadeOut"&&this.removeOverlayMeshes();const i=(Array.isArray(e)?e:e?[e]:[]).filter(r=>r?.geometry);if(i.length===0){this.clearHighlight();return}this.overlayMaterial.color.set(t),this.overlayMaterial.opacity=0,this.overlayMaterial.userData.targetOpacity=n;for(const r of i){let o=r.geometry.clone();o.computeVertexNormals();const a=new y.Mesh(o,this.overlayMaterial);r.updateWorldMatrix(!0,!1),a.matrix.copy(r.matrixWorld),a.matrixAutoUpdate=!1,this.engine.scene.add(a),this.overlayMeshes.push(a)}this.animState="fadeIn",this.animStartTime=performance.now()}clearHighlight(){this.overlayMeshes.length===0||this.animState==="fadeOut"||(this.animState="fadeOut",this.animStartTime=performance.now())}update(){if(this.animState==="idle"||this.overlayMeshes.length===0)return;const e=performance.now()-this.animStartTime,t=this.overlayMaterial.userData.targetOpacity??.35;if(this.animState==="fadeIn"){const n=Math.min(e/Xr.FADE_IN_MS,1);this.overlayMaterial.opacity=this.easeOutQuad(n)*t,n>=1&&(this.animState="idle")}else if(this.animState==="fadeOut"){const n=Math.min(e/Xr.FADE_OUT_MS,1);this.overlayMaterial.opacity=(1-this.easeOutQuad(n))*t,n>=1&&(this.removeOverlayMeshes(),this.animState="idle")}}removeOverlayMeshes(){for(const e of this.overlayMeshes)this.engine.scene.remove(e);this.overlayMeshes=[]}easeOutQuad(e){return 1-(1-e)*(1-e)}dispose(){this.removeOverlayMeshes(),this.overlayMaterial.dispose(),this.animState="idle"}}var jr={exports:{}},X_=jr.exports,ed;function j_(){return ed||(ed=1,(function(s,e){(function(t,n){s.exports=n()})(X_,function(){var t=function(){function n(u){return o.appendChild(u.dom),u}function i(u){for(var m=0;m<o.children.length;m++)o.children[m].style.display=m===u?"block":"none";r=u}var r=0,o=document.createElement("div");o.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",o.addEventListener("click",function(u){u.preventDefault(),i(++r%o.children.length)},!1);var a=(performance||Date).now(),l=a,c=0,h=n(new t.Panel("FPS","#0ff","#002")),d=n(new t.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var g=n(new t.Panel("MB","#f08","#201"));return i(0),{REVISION:16,dom:o,addPanel:n,showPanel:i,begin:function(){a=(performance||Date).now()},end:function(){c++;var u=(performance||Date).now();if(d.update(u-a,200),u>l+1e3&&(h.update(1e3*c/(u-l),100),l=u,c=0,g)){var m=performance.memory;g.update(m.usedJSHeapSize/1048576,m.jsHeapSizeLimit/1048576)}return u},update:function(){a=this.end()},domElement:o,setMode:i}};return t.Panel=function(n,i,r){var o=1/0,a=0,l=Math.round,c=l(window.devicePixelRatio||1),h=80*c,d=48*c,g=3*c,u=2*c,m=3*c,f=15*c,p=74*c,x=30*c,v=document.createElement("canvas");v.width=h,v.height=d,v.style.cssText="width:80px;height:48px";var _=v.getContext("2d");return _.font="bold "+9*c+"px Helvetica,Arial,sans-serif",_.textBaseline="top",_.fillStyle=r,_.fillRect(0,0,h,d),_.fillStyle=i,_.fillText(n,g,u),_.fillRect(m,f,p,x),_.fillStyle=r,_.globalAlpha=.9,_.fillRect(m,f,p,x),{dom:v,update:function(b,S){o=Math.min(o,b),a=Math.max(a,b),_.fillStyle=r,_.globalAlpha=1,_.fillRect(0,0,h,f),_.fillStyle=i,_.fillText(l(b)+" "+n+" ("+l(o)+"-"+l(a)+")",g,u),_.drawImage(v,m+c,f,p-c,x,m,f,p-c,x),_.fillRect(m+p-c,f,c,x),_.fillStyle=r,_.globalAlpha=.9,_.fillRect(m+p-c,f,c,l((1-b/S)*x))}}},t})})(jr)),jr.exports}var Y_=j_();const q_=Wc(Y_);var ns=Object.freeze({Linear:Object.freeze({None:function(s){return s},In:function(s){return s},Out:function(s){return s},InOut:function(s){return s}}),Quadratic:Object.freeze({In:function(s){return s*s},Out:function(s){return s*(2-s)},InOut:function(s){return(s*=2)<1?.5*s*s:-.5*(--s*(s-2)-1)}}),Cubic:Object.freeze({In:function(s){return s*s*s},Out:function(s){return--s*s*s+1},InOut:function(s){return(s*=2)<1?.5*s*s*s:.5*((s-=2)*s*s+2)}}),Quartic:Object.freeze({In:function(s){return s*s*s*s},Out:function(s){return 1- --s*s*s*s},InOut:function(s){return(s*=2)<1?.5*s*s*s*s:-.5*((s-=2)*s*s*s-2)}}),Quintic:Object.freeze({In:function(s){return s*s*s*s*s},Out:function(s){return--s*s*s*s*s+1},InOut:function(s){return(s*=2)<1?.5*s*s*s*s*s:.5*((s-=2)*s*s*s*s+2)}}),Sinusoidal:Object.freeze({In:function(s){return 1-Math.sin((1-s)*Math.PI/2)},Out:function(s){return Math.sin(s*Math.PI/2)},InOut:function(s){return .5*(1-Math.sin(Math.PI*(.5-s)))}}),Exponential:Object.freeze({In:function(s){return s===0?0:Math.pow(1024,s-1)},Out:function(s){return s===1?1:1-Math.pow(2,-10*s)},InOut:function(s){return s===0?0:s===1?1:(s*=2)<1?.5*Math.pow(1024,s-1):.5*(-Math.pow(2,-10*(s-1))+2)}}),Circular:Object.freeze({In:function(s){return 1-Math.sqrt(1-s*s)},Out:function(s){return Math.sqrt(1- --s*s)},InOut:function(s){return(s*=2)<1?-.5*(Math.sqrt(1-s*s)-1):.5*(Math.sqrt(1-(s-=2)*s)+1)}}),Elastic:Object.freeze({In:function(s){return s===0?0:s===1?1:-Math.pow(2,10*(s-1))*Math.sin((s-1.1)*5*Math.PI)},Out:function(s){return s===0?0:s===1?1:Math.pow(2,-10*s)*Math.sin((s-.1)*5*Math.PI)+1},InOut:function(s){return s===0?0:s===1?1:(s*=2,s<1?-.5*Math.pow(2,10*(s-1))*Math.sin((s-1.1)*5*Math.PI):.5*Math.pow(2,-10*(s-1))*Math.sin((s-1.1)*5*Math.PI)+1)}}),Back:Object.freeze({In:function(s){var e=1.70158;return s===1?1:s*s*((e+1)*s-e)},Out:function(s){var e=1.70158;return s===0?0:--s*s*((e+1)*s+e)+1},InOut:function(s){var e=2.5949095;return(s*=2)<1?.5*(s*s*((e+1)*s-e)):.5*((s-=2)*s*((e+1)*s+e)+2)}}),Bounce:Object.freeze({In:function(s){return 1-ns.Bounce.Out(1-s)},Out:function(s){return s<1/2.75?7.5625*s*s:s<2/2.75?7.5625*(s-=1.5/2.75)*s+.75:s<2.5/2.75?7.5625*(s-=2.25/2.75)*s+.9375:7.5625*(s-=2.625/2.75)*s+.984375},InOut:function(s){return s<.5?ns.Bounce.In(s*2)*.5:ns.Bounce.Out(s*2-1)*.5+.5}}),generatePow:function(s){return s===void 0&&(s=4),s=s<Number.EPSILON?Number.EPSILON:s,s=s>1e4?1e4:s,{In:function(e){return Math.pow(e,s)},Out:function(e){return 1-Math.pow(1-e,s)},InOut:function(e){return e<.5?Math.pow(e*2,s)/2:(1-Math.pow(2-e*2,s))/2+.5}}}}),Ps=function(){return performance.now()},Z_=(function(){function s(){this._tweens={},this._tweensAddedDuringUpdate={}}return s.prototype.getAll=function(){var e=this;return Object.keys(this._tweens).map(function(t){return e._tweens[t]})},s.prototype.removeAll=function(){this._tweens={}},s.prototype.add=function(e){this._tweens[e.getId()]=e,this._tweensAddedDuringUpdate[e.getId()]=e},s.prototype.remove=function(e){delete this._tweens[e.getId()],delete this._tweensAddedDuringUpdate[e.getId()]},s.prototype.update=function(e,t){e===void 0&&(e=Ps()),t===void 0&&(t=!1);var n=Object.keys(this._tweens);if(n.length===0)return!1;for(;n.length>0;){this._tweensAddedDuringUpdate={};for(var i=0;i<n.length;i++){var r=this._tweens[n[i]],o=!t;r&&r.update(e,o)===!1&&!t&&delete this._tweens[n[i]]}n=Object.keys(this._tweensAddedDuringUpdate)}return!0},s})(),Qa={Linear:function(s,e){var t=s.length-1,n=t*e,i=Math.floor(n),r=Qa.Utils.Linear;return e<0?r(s[0],s[1],n):e>1?r(s[t],s[t-1],t-n):r(s[i],s[i+1>t?t:i+1],n-i)},Utils:{Linear:function(s,e,t){return(e-s)*t+s}}},td=(function(){function s(){}return s.nextId=function(){return s._nextId++},s._nextId=0,s})(),el=new Z_,K_=(function(){function s(e,t){t===void 0&&(t=el),this._object=e,this._group=t,this._isPaused=!1,this._pauseStart=0,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._isDynamic=!1,this._initialRepeat=0,this._repeat=0,this._yoyo=!1,this._isPlaying=!1,this._reversed=!1,this._delayTime=0,this._startTime=0,this._easingFunction=ns.Linear.None,this._interpolationFunction=Qa.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=td.nextId(),this._isChainStopped=!1,this._propertiesAreSetUp=!1,this._goToEnd=!1}return s.prototype.getId=function(){return this._id},s.prototype.isPlaying=function(){return this._isPlaying},s.prototype.isPaused=function(){return this._isPaused},s.prototype.getDuration=function(){return this._duration},s.prototype.to=function(e,t){if(t===void 0&&(t=1e3),this._isPlaying)throw new Error("Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.");return this._valuesEnd=e,this._propertiesAreSetUp=!1,this._duration=t<0?0:t,this},s.prototype.duration=function(e){return e===void 0&&(e=1e3),this._duration=e<0?0:e,this},s.prototype.dynamic=function(e){return e===void 0&&(e=!1),this._isDynamic=e,this},s.prototype.start=function(e,t){if(e===void 0&&(e=Ps()),t===void 0&&(t=!1),this._isPlaying)return this;if(this._group&&this._group.add(this),this._repeat=this._initialRepeat,this._reversed){this._reversed=!1;for(var n in this._valuesStartRepeat)this._swapEndStartRepeatValues(n),this._valuesStart[n]=this._valuesStartRepeat[n]}if(this._isPlaying=!0,this._isPaused=!1,this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._isChainStopped=!1,this._startTime=e,this._startTime+=this._delayTime,!this._propertiesAreSetUp||t){if(this._propertiesAreSetUp=!0,!this._isDynamic){var i={};for(var r in this._valuesEnd)i[r]=this._valuesEnd[r];this._valuesEnd=i}this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat,t)}return this},s.prototype.startFromCurrentValues=function(e){return this.start(e,!0)},s.prototype._setupProperties=function(e,t,n,i,r){for(var o in n){var a=e[o],l=Array.isArray(a),c=l?"array":typeof a,h=!l&&Array.isArray(n[o]);if(!(c==="undefined"||c==="function")){if(h){var d=n[o];if(d.length===0)continue;for(var g=[a],u=0,m=d.length;u<m;u+=1){var f=this._handleRelativeValue(a,d[u]);if(isNaN(f)){h=!1,console.warn("Found invalid interpolation list. Skipping.");break}g.push(f)}h&&(n[o]=g)}if((c==="object"||l)&&a&&!h){t[o]=l?[]:{};var p=a;for(var x in p)t[o][x]=p[x];i[o]=l?[]:{};var d=n[o];if(!this._isDynamic){var v={};for(var x in d)v[x]=d[x];n[o]=d=v}this._setupProperties(p,t[o],d,i[o],r)}else(typeof t[o]>"u"||r)&&(t[o]=a),l||(t[o]*=1),h?i[o]=n[o].slice().reverse():i[o]=t[o]||0}}},s.prototype.stop=function(){return this._isChainStopped||(this._isChainStopped=!0,this.stopChainedTweens()),this._isPlaying?(this._group&&this._group.remove(this),this._isPlaying=!1,this._isPaused=!1,this._onStopCallback&&this._onStopCallback(this._object),this):this},s.prototype.end=function(){return this._goToEnd=!0,this.update(1/0),this},s.prototype.pause=function(e){return e===void 0&&(e=Ps()),this._isPaused||!this._isPlaying?this:(this._isPaused=!0,this._pauseStart=e,this._group&&this._group.remove(this),this)},s.prototype.resume=function(e){return e===void 0&&(e=Ps()),!this._isPaused||!this._isPlaying?this:(this._isPaused=!1,this._startTime+=e-this._pauseStart,this._pauseStart=0,this._group&&this._group.add(this),this)},s.prototype.stopChainedTweens=function(){for(var e=0,t=this._chainedTweens.length;e<t;e++)this._chainedTweens[e].stop();return this},s.prototype.group=function(e){return e===void 0&&(e=el),this._group=e,this},s.prototype.delay=function(e){return e===void 0&&(e=0),this._delayTime=e,this},s.prototype.repeat=function(e){return e===void 0&&(e=0),this._initialRepeat=e,this._repeat=e,this},s.prototype.repeatDelay=function(e){return this._repeatDelayTime=e,this},s.prototype.yoyo=function(e){return e===void 0&&(e=!1),this._yoyo=e,this},s.prototype.easing=function(e){return e===void 0&&(e=ns.Linear.None),this._easingFunction=e,this},s.prototype.interpolation=function(e){return e===void 0&&(e=Qa.Linear),this._interpolationFunction=e,this},s.prototype.chain=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return this._chainedTweens=e,this},s.prototype.onStart=function(e){return this._onStartCallback=e,this},s.prototype.onEveryStart=function(e){return this._onEveryStartCallback=e,this},s.prototype.onUpdate=function(e){return this._onUpdateCallback=e,this},s.prototype.onRepeat=function(e){return this._onRepeatCallback=e,this},s.prototype.onComplete=function(e){return this._onCompleteCallback=e,this},s.prototype.onStop=function(e){return this._onStopCallback=e,this},s.prototype.update=function(e,t){var n=this,i;if(e===void 0&&(e=Ps()),t===void 0&&(t=!0),this._isPaused)return!0;var r,o=this._startTime+this._duration;if(!this._goToEnd&&!this._isPlaying){if(e>o)return!1;t&&this.start(e,!0)}if(this._goToEnd=!1,e<this._startTime)return!0;this._onStartCallbackFired===!1&&(this._onStartCallback&&this._onStartCallback(this._object),this._onStartCallbackFired=!0),this._onEveryStartCallbackFired===!1&&(this._onEveryStartCallback&&this._onEveryStartCallback(this._object),this._onEveryStartCallbackFired=!0);var a=e-this._startTime,l=this._duration+((i=this._repeatDelayTime)!==null&&i!==void 0?i:this._delayTime),c=this._duration+this._repeat*l,h=function(){if(n._duration===0||a>c)return 1;var p=Math.trunc(a/l),x=a-p*l,v=Math.min(x/n._duration,1);return v===0&&a===n._duration?1:v},d=h(),g=this._easingFunction(d);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,g),this._onUpdateCallback&&this._onUpdateCallback(this._object,d),this._duration===0||a>=this._duration)if(this._repeat>0){var u=Math.min(Math.trunc((a-this._duration)/l)+1,this._repeat);isFinite(this._repeat)&&(this._repeat-=u);for(r in this._valuesStartRepeat)!this._yoyo&&typeof this._valuesEnd[r]=="string"&&(this._valuesStartRepeat[r]=this._valuesStartRepeat[r]+parseFloat(this._valuesEnd[r])),this._yoyo&&this._swapEndStartRepeatValues(r),this._valuesStart[r]=this._valuesStartRepeat[r];return this._yoyo&&(this._reversed=!this._reversed),this._startTime+=l*u,this._onRepeatCallback&&this._onRepeatCallback(this._object),this._onEveryStartCallbackFired=!1,!0}else{this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var m=0,f=this._chainedTweens.length;m<f;m++)this._chainedTweens[m].start(this._startTime+this._duration,!1);return this._isPlaying=!1,!1}return!0},s.prototype._updateProperties=function(e,t,n,i){for(var r in n)if(t[r]!==void 0){var o=t[r]||0,a=n[r],l=Array.isArray(e[r]),c=Array.isArray(a),h=!l&&c;h?e[r]=this._interpolationFunction(a,i):typeof a=="object"&&a?this._updateProperties(e[r],o,a,i):(a=this._handleRelativeValue(o,a),typeof a=="number"&&(e[r]=o+(a-o)*i))}},s.prototype._handleRelativeValue=function(e,t){return typeof t!="string"?t:t.charAt(0)==="+"||t.charAt(0)==="-"?e+parseFloat(t):parseFloat(t)},s.prototype._swapEndStartRepeatValues=function(e){var t=this._valuesStartRepeat[e],n=this._valuesEnd[e];typeof n=="string"?this._valuesStartRepeat[e]=this._valuesStartRepeat[e]+parseFloat(n):this._valuesStartRepeat[e]=this._valuesEnd[e],this._valuesEnd[e]=t},s})();td.nextId;var vn=el;vn.getAll.bind(vn),vn.removeAll.bind(vn),vn.add.bind(vn),vn.remove.bind(vn),vn.update.bind(vn);var Ds={Easing:ns,Tween:K_};const nd={type:"change"},tl={type:"start"},id={type:"end"},Yr=new M.Ray,sd=new M.Plane,$_=Math.cos(70*M.MathUtils.DEG2RAD),Tt=new M.Vector3,Gt=2*Math.PI,lt={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},nl=1e-6;class J_ extends M.Controls{constructor(e,t=null){super(e,t),this.state=lt.NONE,this.target=new M.Vector3,this.cursor=new M.Vector3,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:M.MOUSE.ROTATE,MIDDLE:M.MOUSE.DOLLY,RIGHT:M.MOUSE.PAN},this.touches={ONE:M.TOUCH.ROTATE,TWO:M.TOUCH.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._cursorStyle="auto",this._domElementKeyEvents=null,this._lastPosition=new M.Vector3,this._lastQuaternion=new M.Quaternion,this._lastTargetPosition=new M.Vector3,this._quat=new M.Quaternion().setFromUnitVectors(e.up,new M.Vector3(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new M.Spherical,this._sphericalDelta=new M.Spherical,this._scale=1,this._panOffset=new M.Vector3,this._rotateStart=new M.Vector2,this._rotateEnd=new M.Vector2,this._rotateDelta=new M.Vector2,this._panStart=new M.Vector2,this._panEnd=new M.Vector2,this._panDelta=new M.Vector2,this._dollyStart=new M.Vector2,this._dollyEnd=new M.Vector2,this._dollyDelta=new M.Vector2,this._dollyDirection=new M.Vector3,this._mouse=new M.Vector2,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=ey.bind(this),this._onPointerDown=Q_.bind(this),this._onPointerUp=ty.bind(this),this._onContextMenu=ly.bind(this),this._onMouseWheel=sy.bind(this),this._onKeyDown=ry.bind(this),this._onTouchStart=oy.bind(this),this._onTouchMove=ay.bind(this),this._onMouseDown=ny.bind(this),this._onMouseMove=iy.bind(this),this._interceptControlDown=cy.bind(this),this._interceptControlUp=hy.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}set cursorStyle(e){this._cursorStyle=e,e==="grab"?this.domElement.style.cursor="grab":this.domElement.style.cursor="auto"}get cursorStyle(){return this._cursorStyle}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(nd),this.update(),this.state=lt.NONE}pan(e,t){this._pan(e,t),this.update()}dollyIn(e){this._dollyIn(e),this.update()}dollyOut(e){this._dollyOut(e),this.update()}rotateLeft(e){this._rotateLeft(e),this.update()}rotateUp(e){this._rotateUp(e),this.update()}update(e=null){const t=this.object.position;Tt.copy(t).sub(this.target),Tt.applyQuaternion(this._quat),this._spherical.setFromVector3(Tt),this.autoRotate&&this.state===lt.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let n=this.minAzimuthAngle,i=this.maxAzimuthAngle;isFinite(n)&&isFinite(i)&&(n<-Math.PI?n+=Gt:n>Math.PI&&(n-=Gt),i<-Math.PI?i+=Gt:i>Math.PI&&(i-=Gt),n<=i?this._spherical.theta=Math.max(n,Math.min(i,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+i)/2?Math.max(n,this._spherical.theta):Math.min(i,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let r=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const o=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=o!=this._spherical.radius}if(Tt.setFromSpherical(this._spherical),Tt.applyQuaternion(this._quatInverse),t.copy(this.target).add(Tt),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let o=null;if(this.object.isPerspectiveCamera){const a=Tt.length();o=this._clampDistance(a*this._scale);const l=a-o;this.object.position.addScaledVector(this._dollyDirection,l),this.object.updateMatrixWorld(),r=!!l}else if(this.object.isOrthographicCamera){const a=new M.Vector3(this._mouse.x,this._mouse.y,0);a.unproject(this.object);const l=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=l!==this.object.zoom;const c=new M.Vector3(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(a),this.object.updateMatrixWorld(),o=Tt.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;o!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(o).add(this.object.position):(Yr.origin.copy(this.object.position),Yr.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Yr.direction))<$_?this.object.lookAt(this.target):(sd.setFromNormalAndCoplanarPoint(this.object.up,this.target),Yr.intersectPlane(sd,this.target))))}else if(this.object.isOrthographicCamera){const o=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),o!==this.object.zoom&&(this.object.updateProjectionMatrix(),r=!0)}return this._scale=1,this._performCursorZoom=!1,r||this._lastPosition.distanceToSquared(this.object.position)>nl||8*(1-this._lastQuaternion.dot(this.object.quaternion))>nl||this._lastTargetPosition.distanceToSquared(this.target)>nl?(this.dispatchEvent(nd),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?Gt/60*this.autoRotateSpeed*e:Gt/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){Tt.setFromMatrixColumn(t,0),Tt.multiplyScalar(-e),this._panOffset.add(Tt)}_panUp(e,t){this.screenSpacePanning===!0?Tt.setFromMatrixColumn(t,1):(Tt.setFromMatrixColumn(t,0),Tt.crossVectors(this.object.up,Tt)),Tt.multiplyScalar(e),this._panOffset.add(Tt)}_pan(e,t){const n=this.domElement;if(this.object.isPerspectiveCamera){const i=this.object.position;Tt.copy(i).sub(this.target);let r=Tt.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*r/n.clientHeight,this.object.matrix),this._panUp(2*t*r/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const n=this.domElement.getBoundingClientRect(),i=e-n.left,r=t-n.top,o=n.width,a=n.height;this._mouse.x=i/o*2-1,this._mouse.y=-(r/a)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(Gt*this._rotateDelta.x/t.clientHeight),this._rotateUp(Gt*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(Gt*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-Gt*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(Gt*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-Gt*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);this._rotateStart.set(n,i)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);this._panStart.set(n,i)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,i=e.pageY-t.y,r=Math.sqrt(n*n+i*i);this._dollyStart.set(0,r)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),i=.5*(e.pageX+n.x),r=.5*(e.pageY+n.y);this._rotateEnd.set(i,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(Gt*this._rotateDelta.x/t.clientHeight),this._rotateUp(Gt*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);this._panEnd.set(n,i)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,i=e.pageY-t.y,r=Math.sqrt(n*n+i*i);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const o=(e.pageX+t.x)*.5,a=(e.pageY+t.y)*.5;this._updateZoomParameters(o,a)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];t===void 0&&(t=new M.Vector2,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){const t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){const t=e.deltaMode,n={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(n.deltaY*=10),n}}function Q_(s){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(s.pointerId),this.domElement.ownerDocument.addEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(s)&&(this._addPointer(s),s.pointerType==="touch"?this._onTouchStart(s):this._onMouseDown(s),this._cursorStyle==="grab"&&(this.domElement.style.cursor="grabbing")))}function ey(s){this.enabled!==!1&&(s.pointerType==="touch"?this._onTouchMove(s):this._onMouseMove(s))}function ty(s){switch(this._removePointer(s),this._pointers.length){case 0:this.domElement.releasePointerCapture(s.pointerId),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(id),this.state=lt.NONE,this._cursorStyle==="grab"&&(this.domElement.style.cursor="grab");break;case 1:const e=this._pointers[0],t=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:t.x,pageY:t.y});break}}function ny(s){let e;switch(s.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case M.MOUSE.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(s),this.state=lt.DOLLY;break;case M.MOUSE.ROTATE:if(s.ctrlKey||s.metaKey||s.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(s),this.state=lt.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(s),this.state=lt.ROTATE}break;case M.MOUSE.PAN:if(s.ctrlKey||s.metaKey||s.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(s),this.state=lt.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(s),this.state=lt.PAN}break;default:this.state=lt.NONE}this.state!==lt.NONE&&this.dispatchEvent(tl)}function iy(s){switch(this.state){case lt.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(s);break;case lt.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(s);break;case lt.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(s);break}}function sy(s){this.enabled===!1||this.enableZoom===!1||this.state!==lt.NONE||(s.preventDefault(),this.dispatchEvent(tl),this._handleMouseWheel(this._customWheelEvent(s)),this.dispatchEvent(id))}function ry(s){this.enabled!==!1&&this._handleKeyDown(s)}function oy(s){switch(this._trackPointer(s),this._pointers.length){case 1:switch(this.touches.ONE){case M.TOUCH.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(s),this.state=lt.TOUCH_ROTATE;break;case M.TOUCH.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(s),this.state=lt.TOUCH_PAN;break;default:this.state=lt.NONE}break;case 2:switch(this.touches.TWO){case M.TOUCH.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(s),this.state=lt.TOUCH_DOLLY_PAN;break;case M.TOUCH.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(s),this.state=lt.TOUCH_DOLLY_ROTATE;break;default:this.state=lt.NONE}break;default:this.state=lt.NONE}this.state!==lt.NONE&&this.dispatchEvent(tl)}function ay(s){switch(this._trackPointer(s),this.state){case lt.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(s),this.update();break;case lt.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(s),this.update();break;case lt.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(s),this.update();break;case lt.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(s),this.update();break;default:this.state=lt.NONE}}function ly(s){this.enabled!==!1&&s.preventDefault()}function cy(s){s.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function hy(s){s.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}const wi=new M.Raycaster,It=new M.Vector3,ti=new M.Vector3,ft=new M.Quaternion,rd={X:new M.Vector3(1,0,0),Y:new M.Vector3(0,1,0),Z:new M.Vector3(0,0,1)},il={type:"change"},od={type:"mouseDown",mode:null},ad={type:"mouseUp",mode:null},ld={type:"objectChange"};class cd extends M.Controls{constructor(e,t=null){super(void 0,t);const n=new gy(this);this._root=n;const i=new xy;this._gizmo=i,n.add(i);const r=new vy;this._plane=r,n.add(r);const o=this;function a(_,b){let S=b;Object.defineProperty(o,_,{get:function(){return S!==void 0?S:b},set:function(C){S!==C&&(S=C,r[_]=C,i[_]=C,o.dispatchEvent({type:_+"-changed",value:C}),o.dispatchEvent(il))}}),o[_]=b,r[_]=b,i[_]=b}a("camera",e),a("object",void 0),a("enabled",!0),a("axis",null),a("mode","translate"),a("translationSnap",null),a("rotationSnap",null),a("scaleSnap",null),a("space","world"),a("size",1),a("dragging",!1),a("showX",!0),a("showY",!0),a("showZ",!0),a("minX",-1/0),a("maxX",1/0),a("minY",-1/0),a("maxY",1/0),a("minZ",-1/0),a("maxZ",1/0);const l=new M.Vector3,c=new M.Vector3,h=new M.Quaternion,d=new M.Quaternion,g=new M.Vector3,u=new M.Quaternion,m=new M.Vector3,f=new M.Vector3,p=new M.Vector3,x=0,v=new M.Vector3;a("worldPosition",l),a("worldPositionStart",c),a("worldQuaternion",h),a("worldQuaternionStart",d),a("cameraPosition",g),a("cameraQuaternion",u),a("pointStart",m),a("pointEnd",f),a("rotationAxis",p),a("rotationAngle",x),a("eye",v),this._offset=new M.Vector3,this._startNorm=new M.Vector3,this._endNorm=new M.Vector3,this._cameraScale=new M.Vector3,this._parentPosition=new M.Vector3,this._parentQuaternion=new M.Quaternion,this._parentQuaternionInv=new M.Quaternion,this._parentScale=new M.Vector3,this._worldScaleStart=new M.Vector3,this._worldQuaternionInv=new M.Quaternion,this._worldScale=new M.Vector3,this._positionStart=new M.Vector3,this._quaternionStart=new M.Quaternion,this._scaleStart=new M.Vector3,this._getPointer=dy.bind(this),this._onPointerDown=fy.bind(this),this._onPointerHover=uy.bind(this),this._onPointerMove=py.bind(this),this._onPointerUp=my.bind(this),t!==null&&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(this.object===void 0||this.dragging===!0)return;e!==null&&wi.setFromCamera(e,this.camera);const t=sl(this._gizmo.picker[this.mode],wi);t?this.axis=t.object.name:this.axis=null}pointerDown(e){if(!(this.object===void 0||this.dragging===!0||e!=null&&e.button!==0)&&this.axis!==null){e!==null&&wi.setFromCamera(e,this.camera);const t=sl(this._plane,wi,!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,od.mode=this.mode,this.dispatchEvent(od)}}pointerMove(e){const t=this.axis,n=this.mode,i=this.object;let r=this.space;if(n==="scale"?r="local":(t==="E"||t==="XYZE"||t==="XYZ")&&(r="world"),i===void 0||t===null||this.dragging===!1||e!==null&&e.button!==-1)return;e!==null&&wi.setFromCamera(e,this.camera);const o=sl(this._plane,wi,!0);if(o){if(this.pointEnd.copy(o.point).sub(this.worldPositionStart),n==="translate")this._offset.copy(this.pointEnd).sub(this.pointStart),r==="local"&&t!=="XYZ"&&this._offset.applyQuaternion(this._worldQuaternionInv),t.indexOf("X")===-1&&(this._offset.x=0),t.indexOf("Y")===-1&&(this._offset.y=0),t.indexOf("Z")===-1&&(this._offset.z=0),r==="local"&&t!=="XYZ"?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),i.position.copy(this._offset).add(this._positionStart),this.translationSnap&&(r==="local"&&(i.position.applyQuaternion(ft.copy(this._quaternionStart).invert()),t.search("X")!==-1&&(i.position.x=Math.round(i.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(i.position.y=Math.round(i.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(i.position.z=Math.round(i.position.z/this.translationSnap)*this.translationSnap),i.position.applyQuaternion(this._quaternionStart)),r==="world"&&(i.parent&&i.position.add(It.setFromMatrixPosition(i.parent.matrixWorld)),t.search("X")!==-1&&(i.position.x=Math.round(i.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(i.position.y=Math.round(i.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(i.position.z=Math.round(i.position.z/this.translationSnap)*this.translationSnap),i.parent&&i.position.sub(It.setFromMatrixPosition(i.parent.matrixWorld)))),i.position.x=Math.max(this.minX,Math.min(this.maxX,i.position.x)),i.position.y=Math.max(this.minY,Math.min(this.maxY,i.position.y)),i.position.z=Math.max(this.minZ,Math.min(this.maxZ,i.position.z));else if(n==="scale"){if(t.search("XYZ")!==-1){let a=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(a*=-1),ti.set(a,a,a)}else It.copy(this.pointStart),ti.copy(this.pointEnd),It.applyQuaternion(this._worldQuaternionInv),ti.applyQuaternion(this._worldQuaternionInv),ti.divide(It),t.search("X")===-1&&(ti.x=1),t.search("Y")===-1&&(ti.y=1),t.search("Z")===-1&&(ti.z=1);i.scale.copy(this._scaleStart).multiply(ti),this.scaleSnap&&(t.search("X")!==-1&&(i.scale.x=Math.round(i.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Y")!==-1&&(i.scale.y=Math.round(i.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Z")!==-1&&(i.scale.z=Math.round(i.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if(n==="rotate"){this._offset.copy(this.pointEnd).sub(this.pointStart);const a=20/this.worldPosition.distanceTo(It.setFromMatrixPosition(this.camera.matrixWorld));let l=!1;t==="XYZE"?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(It.copy(this.rotationAxis).cross(this.eye))*a):(t==="X"||t==="Y"||t==="Z")&&(this.rotationAxis.copy(rd[t]),It.copy(rd[t]),r==="local"&&It.applyQuaternion(this.worldQuaternion),It.cross(this.eye),It.length()===0?l=!0:this.rotationAngle=this._offset.dot(It.normalize())*a),(t==="E"||l)&&(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this._startNorm.copy(this.pointStart).normalize(),this._endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this._endNorm.cross(this._startNorm).dot(this.eye)<0?1:-1),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),r==="local"&&t!=="E"&&t!=="XYZE"?(i.quaternion.copy(this._quaternionStart),i.quaternion.multiply(ft.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),i.quaternion.copy(ft.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),i.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(il),this.dispatchEvent(ld)}}pointerUp(e){e!==null&&e.button!==0||(this.dragging&&this.axis!==null&&(ad.mode=this.mode,this.dispatchEvent(ad)),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(il),this.dispatchEvent(ld),this.pointStart.copy(this.pointEnd))}getRaycaster(){return wi}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}setColors(e,t,n,i){const r=this._gizmo.materialLib;r.xAxis.color.set(e),r.yAxis.color.set(t),r.zAxis.color.set(n),r.active.color.set(i),r.xAxisTransparent.color.set(e),r.yAxisTransparent.color.set(t),r.zAxisTransparent.color.set(n),r.activeTransparent.color.set(i),r.xAxis._color&&r.xAxis._color.set(e),r.yAxis._color&&r.yAxis._color.set(t),r.zAxis._color&&r.zAxis._color.set(n),r.active._color&&r.active._color.set(i),r.xAxisTransparent._color&&r.xAxisTransparent._color.set(e),r.yAxisTransparent._color&&r.yAxisTransparent._color.set(t),r.zAxisTransparent._color&&r.zAxisTransparent._color.set(n),r.activeTransparent._color&&r.activeTransparent._color.set(i)}}function dy(s){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:s.button};{const e=this.domElement.getBoundingClientRect();return{x:(s.clientX-e.left)/e.width*2-1,y:-(s.clientY-e.top)/e.height*2+1,button:s.button}}}function uy(s){if(this.enabled)switch(s.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(s));break}}function fy(s){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(s.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(s)),this.pointerDown(this._getPointer(s)))}function py(s){this.enabled&&this.pointerMove(this._getPointer(s))}function my(s){this.enabled&&(this.domElement.releasePointerCapture(s.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(s)))}function sl(s,e,t){const n=e.intersectObject(s,!0);for(let i=0;i<n.length;i++)if(n[i].object.visible||t)return n[i];return!1}const qr=new M.Euler,ht=new M.Vector3(0,1,0),hd=new M.Vector3(0,0,0),dd=new M.Matrix4,Zr=new M.Quaternion,Kr=new M.Quaternion,_n=new M.Vector3,ud=new M.Matrix4,Rs=new M.Vector3(1,0,0),Si=new M.Vector3(0,1,0),Ls=new M.Vector3(0,0,1),$r=new M.Vector3,Is=new M.Vector3,Ns=new M.Vector3;class gy extends M.Object3D{constructor(e){super(),this.isTransformControlsRoot=!0,this.controls=e,this.visible=!1}updateMatrixWorld(e){const t=this.controls;t.object!==void 0&&(t.object.updateMatrixWorld(),t.object.parent===null?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 xy extends M.Object3D{constructor(){super(),this.isTransformControlsGizmo=!0,this.type="TransformControlsGizmo";const e=new M.MeshBasicMaterial({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),t=new M.LineBasicMaterial({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),n=e.clone();n.opacity=.15;const i=t.clone();i.opacity=.5;const r=e.clone();r.color.setHex(16711680);const o=e.clone();o.color.setHex(65280);const a=e.clone();a.color.setHex(255);const l=e.clone();l.color.setHex(16711680),l.opacity=.5;const c=e.clone();c.color.setHex(65280),c.opacity=.5;const h=e.clone();h.color.setHex(255),h.opacity=.5;const d=e.clone();d.opacity=.25;const g=e.clone();g.color.setHex(16776960),g.opacity=.25;const u=e.clone();u.color.setHex(16776960);const m=e.clone();m.color.setHex(7895160),this.materialLib={xAxis:r,yAxis:o,zAxis:a,active:u,xAxisTransparent:l,yAxisTransparent:c,zAxisTransparent:h,activeTransparent:g};const f=new M.CylinderGeometry(0,.04,.1,12);f.translate(0,.05,0);const p=new M.BoxGeometry(.08,.08,.08);p.translate(0,.04,0);const x=new M.BufferGeometry;x.setAttribute("position",new M.Float32BufferAttribute([0,0,0,1,0,0],3));const v=new M.CylinderGeometry(.0075,.0075,.5,3);v.translate(0,.25,0);function _(V,z){const H=new M.TorusGeometry(V,.0075,3,64,z*Math.PI*2);return H.rotateY(Math.PI/2),H.rotateX(Math.PI/2),H}function b(){const V=new M.BufferGeometry;return V.setAttribute("position",new M.Float32BufferAttribute([0,0,0,1,1,1],3)),V}const S={X:[[new M.Mesh(f,r),[.5,0,0],[0,0,-Math.PI/2]],[new M.Mesh(f,r),[-.5,0,0],[0,0,Math.PI/2]],[new M.Mesh(v,r),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new M.Mesh(f,o),[0,.5,0]],[new M.Mesh(f,o),[0,-.5,0],[Math.PI,0,0]],[new M.Mesh(v,o)]],Z:[[new M.Mesh(f,a),[0,0,.5],[Math.PI/2,0,0]],[new M.Mesh(f,a),[0,0,-.5],[-Math.PI/2,0,0]],[new M.Mesh(v,a),null,[Math.PI/2,0,0]]],XYZ:[[new M.Mesh(new M.OctahedronGeometry(.1,0),d),[0,0,0]]],XY:[[new M.Mesh(new M.BoxGeometry(.15,.15,.01),h),[.15,.15,0]]],YZ:[[new M.Mesh(new M.BoxGeometry(.15,.15,.01),l),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new M.Mesh(new M.BoxGeometry(.15,.15,.01),c),[.15,0,.15],[-Math.PI/2,0,0]]]},C={X:[[new M.Mesh(new M.CylinderGeometry(.2,0,.6,4),n),[.3,0,0],[0,0,-Math.PI/2]],[new M.Mesh(new M.CylinderGeometry(.2,0,.6,4),n),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new M.Mesh(new M.CylinderGeometry(.2,0,.6,4),n),[0,.3,0]],[new M.Mesh(new M.CylinderGeometry(.2,0,.6,4),n),[0,-.3,0],[0,0,Math.PI]]],Z:[[new M.Mesh(new M.CylinderGeometry(.2,0,.6,4),n),[0,0,.3],[Math.PI/2,0,0]],[new M.Mesh(new M.CylinderGeometry(.2,0,.6,4),n),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new M.Mesh(new M.OctahedronGeometry(.2,0),n)]],XY:[[new M.Mesh(new M.BoxGeometry(.2,.2,.01),n),[.15,.15,0]]],YZ:[[new M.Mesh(new M.BoxGeometry(.2,.2,.01),n),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new M.Mesh(new M.BoxGeometry(.2,.2,.01),n),[.15,0,.15],[-Math.PI/2,0,0]]]},R={START:[[new M.Mesh(new M.OctahedronGeometry(.01,2),i),null,null,null,"helper"]],END:[[new M.Mesh(new M.OctahedronGeometry(.01,2),i),null,null,null,"helper"]],DELTA:[[new M.Line(b(),i),null,null,null,"helper"]],X:[[new M.Line(x,i),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new M.Line(x,i),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new M.Line(x,i),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},I={XYZE:[[new M.Mesh(_(.5,1),m),null,[0,Math.PI/2,0]]],X:[[new M.Mesh(_(.5,.5),r)]],Y:[[new M.Mesh(_(.5,.5),o),null,[0,0,-Math.PI/2]]],Z:[[new M.Mesh(_(.5,.5),a),null,[0,Math.PI/2,0]]],E:[[new M.Mesh(_(.75,1),g),null,[0,Math.PI/2,0]]]},E={AXIS:[[new M.Line(x,i),[-1e3,0,0],null,[1e6,1,1],"helper"]]},T={XYZE:[[new M.Mesh(new M.SphereGeometry(.25,10,8),n)]],X:[[new M.Mesh(new M.TorusGeometry(.5,.1,4,24),n),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new M.Mesh(new M.TorusGeometry(.5,.1,4,24),n),[0,0,0],[Math.PI/2,0,0]]],Z:[[new M.Mesh(new M.TorusGeometry(.5,.1,4,24),n),[0,0,0],[0,0,-Math.PI/2]]],E:[[new M.Mesh(new M.TorusGeometry(.75,.1,2,24),n)]]},U={X:[[new M.Mesh(p,r),[.5,0,0],[0,0,-Math.PI/2]],[new M.Mesh(v,r),[0,0,0],[0,0,-Math.PI/2]],[new M.Mesh(p,r),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new M.Mesh(p,o),[0,.5,0]],[new M.Mesh(v,o)],[new M.Mesh(p,o),[0,-.5,0],[0,0,Math.PI]]],Z:[[new M.Mesh(p,a),[0,0,.5],[Math.PI/2,0,0]],[new M.Mesh(v,a),[0,0,0],[Math.PI/2,0,0]],[new M.Mesh(p,a),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new M.Mesh(new M.BoxGeometry(.15,.15,.01),h),[.15,.15,0]]],YZ:[[new M.Mesh(new M.BoxGeometry(.15,.15,.01),l),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new M.Mesh(new M.BoxGeometry(.15,.15,.01),c),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new M.Mesh(new M.BoxGeometry(.1,.1,.1),d)]]},D={X:[[new M.Mesh(new M.CylinderGeometry(.2,0,.6,4),n),[.3,0,0],[0,0,-Math.PI/2]],[new M.Mesh(new M.CylinderGeometry(.2,0,.6,4),n),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new M.Mesh(new M.CylinderGeometry(.2,0,.6,4),n),[0,.3,0]],[new M.Mesh(new M.CylinderGeometry(.2,0,.6,4),n),[0,-.3,0],[0,0,Math.PI]]],Z:[[new M.Mesh(new M.CylinderGeometry(.2,0,.6,4),n),[0,0,.3],[Math.PI/2,0,0]],[new M.Mesh(new M.CylinderGeometry(.2,0,.6,4),n),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new M.Mesh(new M.BoxGeometry(.2,.2,.01),n),[.15,.15,0]]],YZ:[[new M.Mesh(new M.BoxGeometry(.2,.2,.01),n),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new M.Mesh(new M.BoxGeometry(.2,.2,.01),n),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new M.Mesh(new M.BoxGeometry(.2,.2,.2),n),[0,0,0]]]},O={X:[[new M.Line(x,i),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new M.Line(x,i),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new M.Line(x,i),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function w(V){const z=new M.Object3D;for(const H in V)for(let Y=V[H].length;Y--;){const W=V[H][Y][0].clone(),Q=V[H][Y][1],X=V[H][Y][2],j=V[H][Y][3],me=V[H][Y][4];W.name=H,W.tag=me,Q&&W.position.set(Q[0],Q[1],Q[2]),X&&W.rotation.set(X[0],X[1],X[2]),j&&W.scale.set(j[0],j[1],j[2]),W.updateMatrix();const ge=W.geometry.clone();ge.applyMatrix4(W.matrix),W.geometry=ge,W.renderOrder=1/0,W.position.set(0,0,0),W.rotation.set(0,0,0),W.scale.set(1,1,1),z.add(W)}return z}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=w(S)),this.add(this.gizmo.rotate=w(I)),this.add(this.gizmo.scale=w(U)),this.add(this.picker.translate=w(C)),this.add(this.picker.rotate=w(T)),this.add(this.picker.scale=w(D)),this.add(this.helper.translate=w(R)),this.add(this.helper.rotate=w(E)),this.add(this.helper.scale=w(O)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(e){const n=(this.mode==="scale"?"local":this.space)==="local"?this.worldQuaternion:Kr;this.gizmo.translate.visible=this.mode==="translate",this.gizmo.rotate.visible=this.mode==="rotate",this.gizmo.scale.visible=this.mode==="scale",this.helper.translate.visible=this.mode==="translate",this.helper.rotate.visible=this.mode==="rotate",this.helper.scale.visible=this.mode==="scale";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 r=0;r<i.length;r++){const o=i[r];o.visible=!0,o.rotation.set(0,0,0),o.position.copy(this.worldPosition);let a;if(this.camera.isOrthographicCamera?a=(this.camera.top-this.camera.bottom)/this.camera.zoom:a=this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),o.scale.set(1,1,1).multiplyScalar(a*this.size/4),o.tag==="helper"){o.visible=!1,o.name==="AXIS"?(o.visible=!!this.axis,this.axis==="X"&&(ft.setFromEuler(qr.set(0,0,0)),o.quaternion.copy(n).multiply(ft),Math.abs(ht.copy(Rs).applyQuaternion(n).dot(this.eye))>.9&&(o.visible=!1)),this.axis==="Y"&&(ft.setFromEuler(qr.set(0,0,Math.PI/2)),o.quaternion.copy(n).multiply(ft),Math.abs(ht.copy(Si).applyQuaternion(n).dot(this.eye))>.9&&(o.visible=!1)),this.axis==="Z"&&(ft.setFromEuler(qr.set(0,Math.PI/2,0)),o.quaternion.copy(n).multiply(ft),Math.abs(ht.copy(Ls).applyQuaternion(n).dot(this.eye))>.9&&(o.visible=!1)),this.axis==="XYZE"&&(ft.setFromEuler(qr.set(0,Math.PI/2,0)),ht.copy(this.rotationAxis),o.quaternion.setFromRotationMatrix(dd.lookAt(hd,ht,Si)),o.quaternion.multiply(ft),o.visible=this.dragging),this.axis==="E"&&(o.visible=!1)):o.name==="START"?(o.position.copy(this.worldPositionStart),o.visible=this.dragging):o.name==="END"?(o.position.copy(this.worldPosition),o.visible=this.dragging):o.name==="DELTA"?(o.position.copy(this.worldPositionStart),o.quaternion.copy(this.worldQuaternionStart),It.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),It.applyQuaternion(this.worldQuaternionStart.clone().invert()),o.scale.copy(It),o.visible=this.dragging):(o.quaternion.copy(n),this.dragging?o.position.copy(this.worldPositionStart):o.position.copy(this.worldPosition),this.axis&&(o.visible=this.axis.search(o.name)!==-1));continue}o.quaternion.copy(n),this.mode==="translate"||this.mode==="scale"?(o.name==="X"&&Math.abs(ht.copy(Rs).applyQuaternion(n).dot(this.eye))>.99&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="Y"&&Math.abs(ht.copy(Si).applyQuaternion(n).dot(this.eye))>.99&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="Z"&&Math.abs(ht.copy(Ls).applyQuaternion(n).dot(this.eye))>.99&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="XY"&&Math.abs(ht.copy(Ls).applyQuaternion(n).dot(this.eye))<.2&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="YZ"&&Math.abs(ht.copy(Rs).applyQuaternion(n).dot(this.eye))<.2&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="XZ"&&Math.abs(ht.copy(Si).applyQuaternion(n).dot(this.eye))<.2&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1)):this.mode==="rotate"&&(Zr.copy(n),ht.copy(this.eye).applyQuaternion(ft.copy(n).invert()),o.name.search("E")!==-1&&o.quaternion.setFromRotationMatrix(dd.lookAt(this.eye,hd,Si)),o.name==="X"&&(ft.setFromAxisAngle(Rs,Math.atan2(-ht.y,ht.z)),ft.multiplyQuaternions(Zr,ft),o.quaternion.copy(ft)),o.name==="Y"&&(ft.setFromAxisAngle(Si,Math.atan2(ht.x,ht.z)),ft.multiplyQuaternions(Zr,ft),o.quaternion.copy(ft)),o.name==="Z"&&(ft.setFromAxisAngle(Ls,Math.atan2(ht.y,ht.x)),ft.multiplyQuaternions(Zr,ft),o.quaternion.copy(ft))),o.visible=o.visible&&(o.name.indexOf("X")===-1||this.showX),o.visible=o.visible&&(o.name.indexOf("Y")===-1||this.showY),o.visible=o.visible&&(o.name.indexOf("Z")===-1||this.showZ),o.visible=o.visible&&(o.name.indexOf("E")===-1||this.showX&&this.showY&&this.showZ),o.material._color=o.material._color||o.material.color.clone(),o.material._opacity=o.material._opacity||o.material.opacity,o.material.color.copy(o.material._color),o.material.opacity=o.material._opacity,this.enabled&&this.axis&&(o.name===this.axis?(o.material.color.copy(this.materialLib.active.color),o.material.opacity=1):this.axis.split("").some(function(l){return o.name===l})&&(o.material.color.copy(this.materialLib.active.color),o.material.opacity=1))}super.updateMatrixWorld(e)}}class vy extends M.Mesh{constructor(){super(new M.PlaneGeometry(1e5,1e5,2,2),new M.MeshBasicMaterial({visible:!1,wireframe:!0,side:M.DoubleSide,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type="TransformControlsPlane"}updateMatrixWorld(e){let t=this.space;switch(this.position.copy(this.worldPosition),this.mode==="scale"&&(t="local"),$r.copy(Rs).applyQuaternion(t==="local"?this.worldQuaternion:Kr),Is.copy(Si).applyQuaternion(t==="local"?this.worldQuaternion:Kr),Ns.copy(Ls).applyQuaternion(t==="local"?this.worldQuaternion:Kr),ht.copy(Is),this.mode){case"translate":case"scale":switch(this.axis){case"X":ht.copy(this.eye).cross($r),_n.copy($r).cross(ht);break;case"Y":ht.copy(this.eye).cross(Is),_n.copy(Is).cross(ht);break;case"Z":ht.copy(this.eye).cross(Ns),_n.copy(Ns).cross(ht);break;case"XY":_n.copy(Ns);break;case"YZ":_n.copy($r);break;case"XZ":ht.copy(Ns),_n.copy(Is);break;case"XYZ":case"E":_n.set(0,0,0);break}break;case"rotate":default:_n.set(0,0,0)}_n.length()===0?this.quaternion.copy(this.cameraQuaternion):(ud.lookAt(It.set(0,0,0),_n,ht),this.quaternion.setFromRotationMatrix(ud)),super.updateMatrixWorld(e)}}class _y extends M.DataTextureLoader{constructor(e){super(e),this.type=M.HalfFloatType}parse(e){const o=function(I,E){switch(I){case 1:throw new Error("THREE.HDRLoader: Read Error: "+(E||""));case 2:throw new Error("THREE.HDRLoader: Write Error: "+(E||""));case 3:throw new Error("THREE.HDRLoader: Bad File Format: "+(E||""));default:case 4:throw new Error("THREE.HDRLoader: Memory Error: "+(E||""))}},d=function(I,E,T){E=E||1024;let D=I.pos,O=-1,w=0,V="",z=String.fromCharCode.apply(null,new Uint16Array(I.subarray(D,D+128)));for(;0>(O=z.indexOf(`
|
|
4941
4941
|
`))&&w<E&&D<I.byteLength;)V+=z,w+=z.length,D+=128,z+=String.fromCharCode.apply(null,new Uint16Array(I.subarray(D,D+128)));return-1<O?(I.pos+=w+O+1,V+z.slice(0,O)):!1},g=function(I){const E=/^#\?(\S+)/,T=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,U=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,D=/^\s*FORMAT=(\S+)\s*$/,O=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,w={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};let V,z;for((I.pos>=I.byteLength||!(V=d(I)))&&o(1,"no header found"),(z=V.match(E))||o(3,"bad initial token"),w.valid|=1,w.programtype=z[1],w.string+=V+`
|
|
4942
4942
|
`;V=d(I),V!==!1;){if(w.string+=V+`
|
|
4943
4943
|
`,V.charAt(0)==="#"){w.comments+=V+`
|
|
4944
|
-
`;continue}if((z=V.match(T))&&(w.gamma=parseFloat(z[1])),(z=V.match(U))&&(w.exposure=parseFloat(z[1])),(z=V.match(D))&&(w.valid|=2,w.format=z[1]),(z=V.match(O))&&(w.valid|=4,w.height=parseInt(z[1],10),w.width=parseInt(z[2],10)),w.valid&2&&w.valid&4)break}return w.valid&2||o(3,"missing format specifier"),w.valid&4||o(3,"missing image size specifier"),w},u=function(I,E,T){const U=E;if(U<8||U>32767||I[0]!==2||I[1]!==2||I[2]&128)return new Uint8Array(I);U!==(I[2]<<8|I[3])&&o(3,"wrong scanline width");const D=new Uint8Array(4*E*T);D.length||o(4,"unable to allocate buffer space");let O=0,w=0;const V=4*U,z=new Uint8Array(4),H=new Uint8Array(V);let Y=T;for(;Y>0&&w<I.byteLength;){w+4>I.byteLength&&o(1),z[0]=I[w++],z[1]=I[w++],z[2]=I[w++],z[3]=I[w++],(z[0]!=2||z[1]!=2||(z[2]<<8|z[3])!=U)&&o(3,"bad rgbe scanline format");let W=0,Q;for(;W<V&&w<I.byteLength;){Q=I[w++];const j=Q>128;if(j&&(Q-=128),(Q===0||W+Q>V)&&o(3,"bad scanline data"),j){const me=I[w++];for(let ge=0;ge<Q;ge++)H[W++]=me}else H.set(I.subarray(w,w+Q),W),W+=Q,w+=Q}const X=U;for(let j=0;j<X;j++){let me=0;D[O]=H[j+me],me+=U,D[O+1]=H[j+me],me+=U,D[O+2]=H[j+me],me+=U,D[O+3]=H[j+me],O+=4}Y--}return D},m=function(I,E,T,U){const D=I[E+3],O=Math.pow(2,D-128)/255;T[U+0]=I[E+0]*O,T[U+1]=I[E+1]*O,T[U+2]=I[E+2]*O,T[U+3]=1},f=function(I,E,T,U){const D=I[E+3],O=Math.pow(2,D-128)/255;T[U+0]=M.DataUtils.toHalfFloat(Math.min(I[E+0]*O,65504)),T[U+1]=M.DataUtils.toHalfFloat(Math.min(I[E+1]*O,65504)),T[U+2]=M.DataUtils.toHalfFloat(Math.min(I[E+2]*O,65504)),T[U+3]=M.DataUtils.toHalfFloat(1)},p=new Uint8Array(e);p.pos=0;const x=g(p),v=x.width,_=x.height,b=u(p.subarray(p.pos),v,_);let S,C,R;switch(this.type){case M.FloatType:R=b.length/4;const I=new Float32Array(R*4);for(let T=0;T<R;T++)m(b,T*4,I,T*4);S=I,C=M.FloatType;break;case M.HalfFloatType:R=b.length/4;const E=new Uint16Array(R*4);for(let T=0;T<R;T++)f(b,T*4,E,T*4);S=E,C=M.HalfFloatType;break;default:throw new Error("THREE.HDRLoader: Unsupported type: "+this.type)}return{width:v,height:_,data:S,header:x.string,gamma:x.gamma,exposure:x.exposure,type:C}}setDataType(e){return this.type=e,this}load(e,t,n,i){function r(o,a){switch(o.type){case M.FloatType:case M.HalfFloatType:o.colorSpace=M.LinearSRGBColorSpace,o.minFilter=M.LinearFilter,o.magFilter=M.LinearFilter,o.generateMipmaps=!1,o.flipY=!0;break}t&&t(o,a)}return super.load(e,r,n,i)}}function yy(){return new y.Scene}function My(s,e){s.appendChild(e.domElement)}function by(s,e,t){var n=new Object;n.visible=!0;let i=null,r,o,a=[];n.init=function(){r||(c(),h(),f())},n.Hide=function(){r.style.display="none",n.visible=!1},n.Show=function(){r.style.display="block",n.visible=!0},n.RenderScene=function(){if(!d){n.camera.quaternion.copy(e.camera.quaternion);const v=new y.Vector3(0,0,1).applyQuaternion(e.camera.quaternion);n.camera.position.copy(v.multiplyScalar(100))}n.orbitControls&&n.orbitControls.update(),n.sceneOrtho.renderer.render(n.sceneOrtho,n.camera)},n.ToggleDirectionView=function(v){var _=new y.Vector3(0,0,0);v=="top"?_=new y.Vector3(0,1,1e-5):v=="down"?_=new y.Vector3(0,-1,1e-5):v=="front"?_=new y.Vector3(0,0,1):v=="left"?_=new y.Vector3(-1,0,0):v=="back"?_=new y.Vector3(0,0,-1):v=="right"?_=new y.Vector3(1,0,0):v=="top_front"?_=new y.Vector3(1,1,0):v=="top_left"?_=new y.Vector3(0,1,-1):v=="top_back"?_=new y.Vector3(-1,1,0):v=="top_right"?_=new y.Vector3(0,1,1):v=="down_front"?_=new y.Vector3(1,-1,0):v=="down_left"?_=new y.Vector3(0,-1,-1):v=="down_back"?_=new y.Vector3(-1,-1,0):v=="down_right"?_=new y.Vector3(0,-1,1):v=="front_right"?_=new y.Vector3(1,0,1):v=="right_back"?_=new y.Vector3(-1,0,1):v=="back_left"?_=new y.Vector3(-1,0,-1):v=="left_front"?_=new y.Vector3(1,0,-1):v=="top_left_front"?_=new y.Vector3(1,1,-1):v=="top_front_right"?_=new y.Vector3(1,1,1):v=="top_right_back"?_=new y.Vector3(-1,1,1):v=="top_back_left"?_=new y.Vector3(-1,1,-1):v=="button_left_front"?_=new y.Vector3(1,-1,-1):v=="button_front_right"?_=new y.Vector3(1,-1,1):v=="button_right_back"?_=new y.Vector3(-1,1,1):v=="button_back_left"&&(_=new y.Vector3(-1,-1,-1));var b=s.octreeBox.getBoundingBox(),S=b.min,C=b.max,R=S.clone().add(C.clone()).multiplyScalar(.5),I=R.clone().add(_.multiplyScalar(1*C.distanceTo(S)));l(e.camera.position,I,s.controls.target.clone(),R)},n.GetCameraPose=function(){var v=e.camera.quaternion,_=e.camera.position,b=s.controls.target,S={quaternion:v,position:_,target:b};return S},n.ReductionCameraPose=function(v,_=1e3,b){var S=new y.Quaternion(v.quaternion._x,v.quaternion._y,v.quaternion._z,v.quaternion._w),C=new y.Vector3(v.position.x,v.position.y,v.position.z),R=new y.Vector3(v.target.x,v.target.y,v.target.z);let I=!1;l(e.camera.position,C,s.controls.target.clone(),R,e.camera.quaternion,S,_,E=>{b&&(I||(b(E),I=!0))}),b&&setTimeout(()=>{I||(b(!0),I=!0)},_+10)},n.CameraGoHome=function(v=1e3){var _=s.octreeBox.getBoundingBox(),b=_.min.clone().add(_.max.clone()).multiplyScalar(.5);let S=new y.Vector3(1,1,1);var C=_.max.distanceTo(_.min),R=b.clone().add(S.multiplyScalar(C*2));if(s.camera.far=C*5,e.camera.isOrthographicCamera){var I=s.container.clientWidth/s.container.clientHeight,E=C*.6;e.camera.left=-E*I,e.camera.right=E*I,e.camera.top=E,e.camera.bottom=-E,e.camera.zoom=1,e.camera.updateProjectionMatrix()}s.controlModule.orbitControls.origin=b.clone(),l(e.camera.position,R,s.controls.target.clone(),b,null,null,v)},n.zoomToBox=function(v){if(e.camera.isOrthographicCamera){let se=function(){i=requestAnimationFrame(se),ue.update()};var _=v.min.clone().add(v.max.clone()).multiplyScalar(.5),b=e.camera.position.clone().sub(s.controls.target.clone()).normalize(),S=e.camera.position.distanceTo(s.controls.target),C=_.clone().add(b.multiplyScalar(S)),R=e.camera.zoom,I=new y.Vector3(1,0,0).applyQuaternion(e.camera.quaternion),E=new y.Vector3(0,1,0).applyQuaternion(e.camera.quaternion),T=[new y.Vector3(v.min.x,v.min.y,v.min.z),new y.Vector3(v.max.x,v.min.y,v.min.z),new y.Vector3(v.min.x,v.max.y,v.min.z),new y.Vector3(v.max.x,v.max.y,v.min.z),new y.Vector3(v.min.x,v.min.y,v.max.z),new y.Vector3(v.max.x,v.min.y,v.max.z),new y.Vector3(v.min.x,v.max.y,v.max.z),new y.Vector3(v.max.x,v.max.y,v.max.z)],U=1/0,D=-1/0,O=1/0,w=-1/0;for(var V of T){var z=V.dot(I),H=V.dot(E);U=Math.min(U,z),D=Math.max(D,z),O=Math.min(O,H),w=Math.max(w,H)}var Y=(D-U)/2,W=(w-O)/2,Q=(e.camera.right-e.camera.left)/2,X=(e.camera.top-e.camera.bottom)/2;R=Math.min(Q/Y,X/W)*.75;var j=e.camera.position.clone(),me=s.controls.target.clone(),ge=e.camera.zoom,ue=new Ds.Tween({x1:j.x,y1:j.y,z1:j.z,x2:me.x,y2:me.y,z2:me.z,zoom:ge}).to({x1:C.x,y1:C.y,z1:C.z,x2:_.x,y2:_.y,z2:_.z,zoom:R},1e3);ue.onUpdate(function(le){s.controls&&(e.camera.position.set(le.x1,le.y1,le.z1),s.controls.target.set(le.x2,le.y2,le.z2),e.camera.isOrthographicCamera&&(e.camera.zoom=le.zoom,e.camera.updateProjectionMatrix()),s.controls.auto=!0,s.controls.update(),n.RenderScene())}),ue.onComplete(function(){s.controls&&(s.controls.auto=!1,n.RenderScene(),cancelAnimationFrame(i),i=null)}),ue.easing(Ds.Easing.Cubic.InOut),ue.start(),se()}else{var _=v.min.clone().add(v.max.clone()).multiplyScalar(.5);let xe=e.camera.position.clone().sub(s.controls.target.clone()).normalize();var C=_.clone().add(xe.multiplyScalar(2*v.max.distanceTo(v.min)));l(e.camera.position,C,s.controls.target.clone(),_)}};function l(v,_,b,S,C,R,I=1e3,E){var T;C&&R?(T=new Ds.Tween({x1:v.x,y1:v.y,z1:v.z,x2:b.x,y2:b.y,z2:b.z,_x:C._x,_y:C._y,_z:C._z,_w:C._w}),T.to({x1:_.x,y1:_.y,z1:_.z,x2:S.x,y2:S.y,z2:S.z,_x:R._x,_y:R._y,_z:R._z,_w:R._w},I)):(T=new Ds.Tween({x1:v.x,y1:v.y,z1:v.z,x2:b.x,y2:b.y,z2:b.z}),T.to({x1:_.x,y1:_.y,z1:_.z,x2:S.x,y2:S.y,z2:S.z},I)),T.onUpdate(function(D){s.controls&&(C&&R?(e.camera.quaternion._x=D._x,e.camera.quaternion._y=D._y,e.camera.quaternion._z=D._z,e.camera.quaternion._w=D._w):s.controls.auto=!0,e.camera.position.x=D.x1,e.camera.position.y=D.y1,e.camera.position.z=D.z1,s.controls.target.x=D.x2,s.controls.target.y=D.y2,s.controls.target.z=D.z2,s.controls.update(),n.RenderScene())}),T.onComplete(function(D){s.controls&&(s.controls.auto=!1,n.RenderScene(),E&&E(!0),cancelAnimationFrame(i),i=null)}),T.easing(Ds.Easing.Cubic.InOut);function U(D){i=requestAnimationFrame(U),T.update()}T.start(),U()}function c(){r=document.createElement("div"),r.className="ViewCube",t.appendChild(r),o=document.createElement("div"),o.className="viewSettingWrapper",o.innerHTML="...",r.appendChild(o);var v=document.createElement("div");v.className="homeViewWrapper",v.addEventListener("mousedown",function(){console.log("归位"),n.CameraGoHome()}),r.appendChild(v);const _=document.createElement("div");_.className="cameraToggleWrapper",_.title="切换正交/透视视图",_.innerHTML="⊞",_.addEventListener("mousedown",function(I){I.stopPropagation(),console.log("切换视图"),n.ToggleCameraType(),C()}),r.appendChild(_);const b=document.createElement("div");b.className="screenshotWrapper",b.title="截图",b.innerHTML="📷",b.addEventListener("mousedown",function(I){I.stopPropagation(),console.log("截图"),n.TakeScreenshot(),C()}),r.appendChild(b);const S=document.createElement("div");S.className="fullscreenWrapper",S.title="全屏",S.innerHTML="⛶",S.addEventListener("mousedown",function(I){I.stopPropagation(),console.log("全屏"),n.ToggleFullscreen(),C()}),r.appendChild(S),o.addEventListener("mousedown",function(I){I.stopPropagation(),_.classList.contains("show")?(C(),console.log("隐藏功能按钮")):(R(),console.log("显示功能按钮"))});function C(){_.classList.remove("show"),b.classList.remove("show"),S.classList.remove("show")}function R(){_.classList.add("show"),b.classList.add("show"),S.classList.add("show")}}function h(){n.sceneOrtho=yy();var b=t.clientWidth,S=t.clientWidth,v=b>S?b/S:S/b,_=300;n.camera=new y.OrthographicCamera(_*v/-2,_*v/2,_/2,_/-2,.01,1e4);var b=r.clientWidth,S=r.clientHeight,C=new y.WebGLRenderer({alpha:!0});C.setSize(b,S),C.setClearAlpha(0),n.sceneOrtho.renderer=C;let R=new y.AmbientLight(16777215,.8);n.sceneOrtho.add(R),My(r,C),n.orbitControls=new J_(n.camera,r),n.orbitControls.enableZoom=!1,n.orbitControls.enablePan=!1,n.orbitControls.enableDamping=!0,n.orbitControls.dampingFactor=.1,n.orbitControls.rotateSpeed=.5,n.orbitControls.addEventListener("start",g),n.orbitControls.addEventListener("change",u),n.orbitControls.addEventListener("end",m)}let d=!1;function g(){d=!0,s.controls&&(n._mainTarget=s.controls.target.clone(),n._mainDistance=e.camera.position.distanceTo(s.controls.target))}function u(){if(d){if(e.camera.quaternion.copy(n.camera.quaternion),s.controls&&n._mainTarget&&n._mainDistance){const v=new y.Vector3(0,0,1).applyQuaternion(e.camera.quaternion);e.camera.position.copy(n._mainTarget.clone().add(v.multiplyScalar(n._mainDistance))),s.controls.update()}s.renderer&&e.camera&&s.renderer.render(e,e.camera)}}function m(){d=!1,n._mainTarget=null,n._mainDistance=null}function f(){const v="/assets/viewcube/";let _=[{label:"右",icon:v+"cn_right.png"},{label:"左",icon:v+"cn_left.png"},{label:"顶",icon:v+"cn_top.png"},{label:"底",icon:v+"cn_bottom.png"},{label:"前",icon:v+"cn_front.png"},{label:"后",icon:v+"cn_back.png"}];var b=[];for(const R of _)b.push(new y.MeshBasicMaterial({color:16777215,map:new y.TextureLoader().load(R.icon)}));new y.MeshLambertMaterial({color:255});var S=new y.Mesh(new y.BoxGeometry(110,110,110),b);n.sceneOrtho.add(S),p(122);let C={x:0,y:0};r.addEventListener("mousedown",R=>{C.x=R.clientX,C.y=R.clientY}),r.addEventListener("mouseup",R=>{if(d)return;const I=R.clientX-C.x,E=R.clientY-C.y;if(Math.sqrt(I*I+E*E)>5)return;var U={};U.x=R.offsetX/r.clientWidth*2-1,U.y=-(R.offsetY/r.clientHeight)*2+1;var D=new y.Raycaster;D.setFromCamera(U,n.camera);const O=D.intersectObjects(a,!1);O.length>0&&n.ToggleDirectionView(O[0].object.name)}),r.addEventListener("mousemove",R=>{var I={};I.x=R.offsetX/r.clientWidth*2-1,I.y=-(R.offsetY/r.clientHeight)*2+1;var E=new y.Raycaster;E.setFromCamera(I,n.camera);const T=E.intersectObjects(a,!1);for(var U of a)U.material.opacity=.01;T.length>0&&(T[0].object.material.opacity=.2)})}function p(v){for(var _=v*.5-20,b=[{name:"right",a:30,b:75,c:75,point:new y.Vector3(_,0,0)},{name:"back",a:75,b:75,c:30,point:new y.Vector3(0,0,-_)},{name:"left",a:30,b:75,c:75,point:new y.Vector3(-_,0,0)},{name:"front",a:75,b:75,c:30,point:new y.Vector3(0,0,_)},{name:"top",a:75,b:30,c:75,point:new y.Vector3(0,_,0)},{name:"button",a:75,b:30,c:75,point:new y.Vector3(0,-_,0)}],S=[{name:"top_right_back",a:30,b:30,c:30,point:new y.Vector3(-_,_,_)},{name:"button_front_right",a:30,b:30,c:30,point:new y.Vector3(-_,-_,_)},{name:"top_front_right",a:30,b:30,c:30,point:new y.Vector3(_,_,_)},{name:"button_right_back",a:30,b:30,c:30,point:new y.Vector3(_,-_,_)},{name:"top_back_left",a:30,b:30,c:30,point:new y.Vector3(-_,_,-_)},{name:"button_back_left",a:30,b:30,c:30,point:new y.Vector3(-_,-_,-_)},{name:"top_left_front",a:30,b:30,c:30,point:new y.Vector3(_,_,-_)},{name:"button_left_front",a:30,b:30,c:30,point:new y.Vector3(_,-_,-_)}],C=[{name:"top_front",a:30,b:30,c:75,point:new y.Vector3(_,_,0)},{name:"top_right",a:75,b:30,c:30,point:new y.Vector3(0,_,_)},{name:"top_back",a:30,b:30,c:75,point:new y.Vector3(-_,_,0)},{name:"top_left",a:75,b:30,c:30,point:new y.Vector3(0,_,-_)},{name:"button_front",a:30,b:30,c:75,point:new y.Vector3(_,-_,0)},{name:"button_right",a:75,b:30,c:30,point:new y.Vector3(0,-_,_)},{name:"button_back",a:30,b:30,c:75,point:new y.Vector3(-_,-_,0)},{name:"button_left",a:75,b:30,c:30,point:new y.Vector3(0,-_,-_)},{name:"front_right",a:30,b:75,c:30,point:new y.Vector3(_,0,_)},{name:"right_back",a:30,b:75,c:30,point:new y.Vector3(-_,0,_)},{name:"back_left",a:30,b:75,c:30,point:new y.Vector3(-_,0,-_)},{name:"left_front",a:30,b:75,c:30,point:new y.Vector3(_,0,-_)}],R=0;R<b.length;R++)a.push(x(b[R]));for(var R=0;R<S.length;R++)a.push(x(S[R]));for(var R=0;R<C.length;R++)a.push(x(C[R]))}function x(v){const _=new y.BoxGeometry(v.a,v.b,v.c),b=new y.MeshBasicMaterial({color:"blue",transparent:!0,opacity:.01}),S=new y.Matrix4().makeTranslation(v.point.x,v.point.y,v.point.z);let C=_.applyMatrix4(S),R=new y.Mesh(C,b);return R.name=v.name,n.sceneOrtho.add(R),R}return n.ToggleCameraType=function(){s.cameraModule.switchCurrentCamera()},n.TakeScreenshot=function(){try{if(!s.renderer){console.error("渲染器未初始化");return}s.renderer.render(e,e.camera);const _=s.renderer.domElement.toDataURL("image/png"),b=document.createElement("a"),S=new Date().toISOString().replaceAll(/[:.]/g,"-");b.download=`screenshot_${S}.png`,b.href=_,b.click(),console.log("截图已保存")}catch(v){console.error("截图失败:",v)}},n.ToggleFullscreen=function(){const v=t||document.documentElement;!document.fullscreenElement&&!document.webkitFullscreenElement&&!document.mozFullScreenElement&&!document.msFullscreenElement?(v.requestFullscreen?v.requestFullscreen():v.webkitRequestFullscreen?v.webkitRequestFullscreen():v.mozRequestFullScreen?v.mozRequestFullScreen():v.msRequestFullscreen&&v.msRequestFullscreen(),console.log("已进入全屏模式")):(document.exitFullscreen?document.exitFullscreen():document.webkitExitFullscreen?document.webkitExitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.msExitFullscreen&&document.msExitFullscreen(),console.log("已退出全屏模式"))},n}class wy{engine;cubeTool;constructor(e){this.engine=e}init(){this.cubeTool=by(this.engine,this.engine.scene,this.engine.container),this.cubeTool.init()}CameraGoHome(e){this.cubeTool.CameraGoHome(e)}zoomToModel(e){this.cubeTool.zoomToBox(e)}zoomToModels(e){try{let t=this.engine.models.find(n=>n.url==e.url);this.cubeTool.zoomToBox(t.nodesMap.get(e.id).infos[0].box)}catch{}}hide(){}}function Sy(s){let e=new Object;return e.getBoundingBox=function(){let t=s.models,n=new y.Vector3(1e8,1e9,1e10),i=new y.Vector3(-1e8,-1e9,-1e10);t.forEach(d=>{let g=new y.Vector3(Math.min(d.boundingBox.min.x,d.boundingBox.max.x),Math.min(d.boundingBox.min.y,d.boundingBox.max.y),Math.min(d.boundingBox.min.z,d.boundingBox.max.z)),u=new y.Vector3(Math.max(d.boundingBox.min.x,d.boundingBox.max.x),Math.max(d.boundingBox.min.y,d.boundingBox.max.y),Math.max(d.boundingBox.min.z,d.boundingBox.max.z));g.x<n.x&&(n.x=g.x),g.y<n.y&&(n.y=g.y),g.z<n.z&&(n.z=g.z),u.x>i.x&&(i.x=u.x),u.y>i.y&&(i.y=u.y),u.z>i.z&&(i.z=u.z)});let r=Math.min(n.x,i.x),o=Math.min(n.y,i.y),a=Math.min(n.z,i.z),l=Math.max(n.x,i.x),c=Math.max(n.y,i.y),h=Math.max(n.z,i.z);return{min:new y.Vector3(r,o,a),max:new y.Vector3(l,c,h)}},e.rayInterationModel=function(t,n){let i=[];return s.engineStatus.models.forEach(a=>{a.info.lods.forEach(l=>{let c=l.octreeBox;o(t,c,a)})}),i=i.filter(a=>a instanceof y.Mesh),i=i.filter(a=>t.ray.intersectsBox(new y.Box3().setFromObject(a),!1)==!0),t.intersectObjects(i,!1);function o(a,l,c){if(l==null)return;let h=new y.Vector3(l.min.X*.3048,l.min.Z*.3048,-l.min.Y*.3048),d=new y.Vector3(l.max.X*.3048,l.max.Z*.3048,-l.max.Y*.3048),g=new y.Vector3(Math.min(h.x,d.X),Math.min(h.y,d.y),Math.min(h.z,d.z)),u=new y.Vector3(Math.max(d.x,h.x),Math.max(d.y,h.y),Math.max(d.z,h.z)),m=new y.Box3(g,u),f=a.ray.intersectsBox(m);if(!(f==null||f==!1))if(l.children==null||l.children.length==0){if(l.elements!=null)for(var p of l.elements){if(!s.engineStatus.isFree&&n==!1)continue;let x=s.engineStatus.hideModels.find(S=>S.url==c.url)?.ids;if(x!=null&&x.includes(p))continue;let v=s.engineStatus.translucentModels.find(S=>S.url==c.url)?.ids;if(v!=null&&v.includes(p))continue;let b=s.models.find(S=>S.url==c.url).nodesMap.get(p);b!=null&&!b.instance&&b.infos.map(C=>C.mesh).forEach(C=>{i.push(C)})}}else{if(l.elements!=null)for(var p of l.elements){let v=s.engineStatus.hideModels.find(C=>C.url==c.url)?.ids;if(v!=null&&v.includes(p))continue;let _=s.engineStatus.translucentModels.find(C=>C.url==c.url)?.ids;if(_!=null&&_.includes(p))continue;let S=s.models.find(C=>C.url==c.url).nodesMap.get(p);S!=null&&!S.instance&&S.infos.map(R=>R.mesh).forEach(R=>{i.push(R)})}for(let x of l.children)o(a,x,c)}}},e}class Ey{engine;isDrawing=!1;startPoint=new y.Vector2;endPoint=new y.Vector2;selectionBox=null;worldToScreen=null;boundMouseDown;boundMouseMove;boundMouseUp;boundKeyDown;constructor(e){this.engine=e,this.boundMouseDown=this.onMouseDown.bind(this),this.boundMouseMove=this.onMouseMove.bind(this),this.boundMouseUp=this.onMouseUp.bind(this),this.boundKeyDown=this.onKeyDown.bind(this)}init(){this.createSelectionBoxElement(),this.engine.scene&&this.engine.camera&&this.engine.renderer&&(this.worldToScreen=new it(this.engine.camera,this.engine.renderer,this.engine.scene))}active(){this.engine.controlModule.disActive();const e=this.engine.renderer?.domElement;e&&(e.addEventListener("mousedown",this.boundMouseDown),e.addEventListener("mousemove",this.boundMouseMove),e.addEventListener("mouseup",this.boundMouseUp),e.style.cursor="crosshair"),window.addEventListener("keydown",this.boundKeyDown)}disActive(){this.engine.controlModule.active();const e=this.engine.renderer?.domElement;e&&(e.removeEventListener("mousedown",this.boundMouseDown),e.removeEventListener("mousemove",this.boundMouseMove),e.removeEventListener("mouseup",this.boundMouseUp),e.style.cursor="default"),window.removeEventListener("keydown",this.boundKeyDown),this.isDrawing&&this.endDrawing()}createSelectionBoxElement(){this.selectionBox=document.createElement("div"),this.selectionBox.style.position="absolute",this.selectionBox.style.border="2px dashed #00aaff",this.selectionBox.style.backgroundColor="rgba(0, 170, 255, 0.1)",this.selectionBox.style.pointerEvents="none",this.selectionBox.style.display="none",this.selectionBox.style.zIndex="1000",this.selectionBox.style.boxSizing="border-box";const e=this.engine.renderer?.domElement;e&&e.parentElement&&e.parentElement.appendChild(this.selectionBox)}onMouseDown(e){e.button!==0||!this.engine.renderer?.domElement||(this.startPoint.set(e.offsetX,e.offsetY),this.endPoint.copy(this.startPoint),this.isDrawing=!0,this.selectionBox&&(this.selectionBox.style.display="block",this.updateSelectionBoxUI()),e.preventDefault(),e.stopPropagation())}onMouseMove(e){!this.isDrawing||!this.engine.renderer?.domElement||(this.endPoint.set(e.offsetX,e.offsetY),this.updateSelectionBoxUI(),e.preventDefault(),e.stopPropagation())}onMouseUp(e){this.isDrawing&&(this.endDrawing(),this.performZoom(),e.preventDefault(),e.stopPropagation(),this.disActive())}onKeyDown(e){e.key==="Escape"&&(this.disActive(),e.preventDefault(),e.stopPropagation())}endDrawing(){this.isDrawing&&(this.isDrawing=!1,this.selectionBox&&(this.selectionBox.style.display="none"))}updateSelectionBoxUI(){if(!this.selectionBox||!this.engine.renderer?.domElement)return;const t=Math.min(this.startPoint.x,this.endPoint.x),n=Math.min(this.startPoint.y,this.endPoint.y),i=Math.abs(this.endPoint.x-this.startPoint.x),r=Math.abs(this.endPoint.y-this.startPoint.y);this.selectionBox.style.left=`${t}px`,this.selectionBox.style.top=`${n}px`,this.selectionBox.style.width=`${i}px`,this.selectionBox.style.height=`${r}px`}performZoom(){const e=Math.abs(this.endPoint.x-this.startPoint.x),t=Math.abs(this.endPoint.y-this.startPoint.y);if(e<5||t<5)return;if(!this.worldToScreen){console.warn("RangeScale: 坐标转换工具未初始化");return}const n=Math.min(this.startPoint.x,this.endPoint.x),i=Math.max(this.startPoint.x,this.endPoint.x),r=Math.min(this.startPoint.y,this.endPoint.y),o=Math.max(this.startPoint.y,this.endPoint.y),a=[],l=[{x:n,y:r},{x:i,y:r},{x:i,y:o},{x:n,y:o}];for(const h of l){const d=this.worldToScreen.screenToWorld(h.x,h.y);d&&a.push(d)}if(a.length<3){console.warn("RangeScale: 框选区域未命中模型,无法执行缩放操作");return}if(a.length<3){console.warn("RangeScale: 无法将屏幕区域转换为世界坐标");return}const c=new y.Box3;for(const h of a)c.expandByPoint(h);if(c.isEmpty()){console.warn("RangeScale: 计算得到的包围盒无效");return}this.fitCameraToBoundingBox(c)}fitCameraToBoundingBox(e){const t=this.engine.camera,n=this.engine.controls;if(!t||!n){console.warn("RangeScale: 相机或控制器未初始化");return}const i=new y.Vector3;e.getCenter(i);const r=new y.Vector3;e.getSize(r);const o=Math.max(r.x,r.y,r.z);if(t instanceof y.PerspectiveCamera){const a=t.fov*(Math.PI/180),c=o/(2*Math.tan(a/2))*1.2,h=new y.Vector3;t.getWorldDirection(h);const d=i.clone().sub(t.position);h.dot(d.normalize())<0&&h.negate();const u=i.clone().sub(h.multiplyScalar(c));t.position.copy(u),n.target&&n.target.copy(i),t.lookAt(i),n.update()}else if(t instanceof y.OrthographicCamera){const l=o*1.2,c=this.engine.renderer?.domElement,h=c?c.width/c.height:1;t.left=-l*h/2,t.right=l*h/2,t.top=l/2,t.bottom=-l/2,t.updateProjectionMatrix();const d=new y.Vector3;t.getWorldDirection(d);const g=o*1.5,u=i.clone().sub(d.multiplyScalar(g));t.position.copy(u),n.target&&n.target.copy(i),t.lookAt(i),n.update()}}}const fd={render:{mode:"advanced",contrast:50,saturation:50,shadowIntensity:50,lightIntensity:50,gtaoIntensity:50},display:{showEdge:!1,edgeOpacity:30,showGrid:!1,showLevel:!1,showGround:!1,groundId:"0",groundHeight:0},environment:{type:"none",hdrId:"0",hdrIntensity:20,skyPreset:"sunrise_clear",skyParams:{},skyIntensity:20}};class Cy{engine;settings;environmentApplyVersion=0;constructor(e){this.engine=e,this.settings=this._clone(fd)}init(){}getSettings(){return this._clone(this.settings)}getPresetLists(){const e=this.engine.ground?.getGroundList()||[],t=this.engine.hdr?.getHdrList()||[],n=this.engine.skyManager?.getPresetList()||[];return{ground:e.map(i=>this._toPresetItem(i)),hdr:t.map(i=>this._toPresetItem(i)),sky:n.map(i=>this._toPresetItem(i))}}async setSettings(e){e.render&&(Object.assign(this.settings.render,e.render),this._applyRenderSettings(this.settings.render)),e.display&&(Object.assign(this.settings.display,e.display),this._applyDisplaySettings(this.settings.display)),e.environment&&(this._mergeEnvironmentSettings(e.environment),await this._applyEnvironmentSettings(this._clone(this.settings.environment)))}async resetToDefault(){this.settings=this._clone(fd),this._applyRenderSettings(this.settings.render),this._applyDisplaySettings(this.settings.display),await this._applyEnvironmentSettings(this._clone(this.settings.environment))}setRenderMode(e){this.settings.render.mode=e,this.engine.engineModelModule?.switchModel(e)}setContrast(e){this.settings.render.contrast=e,this.engine.engineModelModule?.setContrastValue(.5+e/100)}setSaturation(e){this.settings.render.saturation=e,this.engine.engineModelModule?.setSaturationValue(.5+e/100)}setShadowIntensity(e){this.settings.render.shadowIntensity=e,this._updateDirectionalLight(t=>{t.shadow.intensity=e/100*2})}setLightIntensity(e){this.settings.render.lightIntensity=e,this.setAmbientLightIntensity(e/100)}setGTAOIntensity(e){this.settings.render.gtaoIntensity=e,this.engine.engineModelModule?.setGTAOIntensity(e/100)}setShowEdge(e){this.settings.display.showEdge=e,e?this.engine.modelEdge?.active():this.engine.modelEdge?.disActive()}setEdgeOpacity(e){this.settings.display.edgeOpacity=e,this.engine.modelEdge?.setOpacity(e/100)}setShowGrid(e){this.settings.display.showGrid=e,e?this.engine.grid?.show():this.engine.grid?.hide()}setShowLevel(e){this.settings.display.showLevel=e,e?this.engine.level?.show():this.engine.level?.hide()}setShowGround(e){this.settings.display.showGround=e,e?this.engine.ground?.show():this.engine.ground?.hide()}setGroundId(e){this.settings.display.groundId=e,this.engine.ground?.setGround(e)}setGroundHeight(e){this.settings.display.groundHeight=e,this.engine.ground?.setHeight(e)}async setEnvironmentType(e){this.settings.environment.type=e,await this._applyEnvironmentSettings(this._clone(this.settings.environment))}async setHdrId(e){this.settings.environment.hdrId=e,this.settings.environment.type==="hdr"&&await this._applyEnvironmentSettings(this._clone(this.settings.environment))}setHdrIntensity(e){this.settings.environment.hdrIntensity=e,this.settings.environment.type==="hdr"&&this.engine.hdr?.setIntensity(e/100)}setSkyPreset(e){this.settings.environment.skyPreset=e,this.settings.environment.skyParams={},this.settings.environment.type==="sky"&&this.engine.skyManager?.setPreset(e)}setSkyParams(e){this.settings.environment.skyParams=this._clone(e),this.settings.environment.type==="sky"&&this.engine.skyManager?.setParams(this.settings.environment.skyParams)}setSkyIntensity(e){this.settings.environment.skyIntensity=e,this.settings.environment.type==="sky"&&this.engine.skyManager?.setIntensity(e/100)}setAmbientLightIntensity(e){const t=this.engine.scene?.children.find(n=>n instanceof y.AmbientLight);t&&(t.intensity=e)}_applyRenderSettings(e){this.setRenderMode(e.mode),this.setContrast(e.contrast),this.setSaturation(e.saturation),this.setShadowIntensity(e.shadowIntensity),this.setLightIntensity(e.lightIntensity),this.setGTAOIntensity(e.gtaoIntensity)}_applyDisplaySettings(e){this.setShowEdge(e.showEdge),this.setEdgeOpacity(e.edgeOpacity),this.setShowGrid(e.showGrid),this.setShowLevel(e.showLevel),this.setShowGround(e.showGround),this.setGroundId(e.groundId),this.setGroundHeight(e.groundHeight)}async _applyEnvironmentSettings(e){const t=++this.environmentApplyVersion;if(await this.engine.hdr?.setHdr("0"),t===this.environmentApplyVersion&&(this.engine.skyManager?.close(!0),t===this.environmentApplyVersion))switch(e.type){case"none":break;case"hdr":if(e.hdrId!=="0"){if(await this.engine.hdr?.setHdr(e.hdrId),t!==this.environmentApplyVersion){this._applyEnvironmentSettings(this._clone(this.settings.environment));return}this.engine.hdr?.setIntensity(e.hdrIntensity/100)}break;case"sky":this.engine.skyManager?.activate(),this.engine.skyManager?.setPreset(e.skyPreset),Object.keys(e.skyParams).length>0&&this.engine.skyManager?.setParams(this._clone(e.skyParams)),this.engine.skyManager?.setIntensity(e.skyIntensity/100);break}}_updateDirectionalLight(e){const t=this.engine.scene?.children.find(n=>n instanceof y.DirectionalLight);t&&e(t)}_mergeEnvironmentSettings(e){Object.assign(this.settings.environment,e),e.skyPreset!==void 0&&e.skyParams===void 0&&(this.settings.environment.skyParams={}),e.skyParams!==void 0&&(this.settings.environment.skyParams=this._clone(e.skyParams))}_toPresetItem(e){const t=Array.isArray(e.names)?[...e.names]:[];return{id:e.id,name:t[0]??e.id,names:t}}_clone(e){return JSON.parse(JSON.stringify(e))}}function Bn(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(s){var e=Math.random()*16|0,t=s=="x"?e:e&3|8;return t.toString(16)})}class zn{engine;handelBehaved;setting;constructor(e){this.engine=e,this.handelBehaved=La(e),this.handelBehaved.init(this,null),this.setting={unit:"m",precision:3}}getSetting(){return this.setting}saveSetting(e){this.setting=e}active(){this.handelBehaved.active()}disActive(){this.handelBehaved.disActive()}getMeasureText(e,t){if(e==null)return null;let n=this.setting.unit,i=n;return t==1?n=="mm"?e=e*1e3:n=="cm"?e=e*100:n=="dm"?e=e*10:n=="m"?e=e*1:n=="km"&&(e=e*.001):t==2&&(n=="mm"?e=e*1e3*1e3:n=="cm"?e=e*100*100:n=="dm"?e=e*10*10:n=="m"?e=e*1*1:n=="km"&&(e=e*.001*.001),i=i+"²"),e.toFixed(this.setting.precision)+" "+i}cancelCurrentSelectedAnnotation(){let e=this.engine.measure.annotationData;for(let t in e)e[t].forEach(n=>{n.highlight==!0&&(n.highlight=!1,n.container.classList.remove("Hight"),n.container.getElementsByTagName("svg")[0].classList.remove("Hight"))})}handelKeyEscDown(){this.cancelCurrentSelectedAnnotation();let e=this.engine.measure.annotationData;for(let t in e)for(let n=e[t].length-1;n>=0;n--){let i=e[t][n];i.isSelect==!0&&(i.container.remove(),e[t].splice(n,1))}this.engine.measure.clearAllPoints()}handelKeyDeleteDown(){let e=this.engine.measure.annotationData;for(let t in e)for(let n=e[t].length-1;n>=0;n--){let i=e[t][n];i.highlight==!0&&(i.container.remove(),e[t].splice(n,1))}}clearHighlight(){let e=this.engine.measure.annotationData;for(let t in e)e[t].forEach(n=>{n.highlight=!1,n.container.classList.remove("Hight"),n.container.getElementsByTagName("svg")[0].classList.remove("Hight")})}drawNormalAnnotation(){let e=this;this.engine.measure.annotationData.normalAnnotation.forEach(m=>{u(m)}),this.engine.measure.annotationData.elevationAnnotation.forEach(m=>{g(m)}),this.engine.measure.annotationData.coordinateAnnotation.forEach(m=>{d(m)}),this.engine.measure.annotationData.angleAnnotation.forEach(m=>{l(m)}),this.engine.measure.annotationData.areaAnnotation.forEach(m=>{c(m)}),this.engine.measure.annotationData.slopeAnnotation.forEach(m=>{h(m)});function l(m){if(m.container==null){let R=['<svg class="measureSvg">','<circle class="measurePointer" cx="50" cy="50" r="5" fill="#f99d0b" />','<circle class="measurePointer" cx="50" cy="50" r="5" fill="#f99d0b" />','<circle class="measurePointer" cx="50" cy="50" r="5" fill="#f99d0b" />','<polyline class="measureLine" stroke="orange" stroke-width="2" points="0,0 0,0" style="fill: none; opacity: 1;"/>','<polyline class="measureLine" stroke="orange" stroke-width="2" points="0,0 0,0" style="fill: none; opacity: 1;"/>','<rect x="0" y="0" width="100" height="25" class="measureBack" />','<text x="40" y="16" text-anchor="middle" class="measureLabel">'+m.text+"</text>","</svg>"].join("");m.container=document.createElement("div"),m.container.className="angle-annotation",m.container.id=m.id,m.container.style.pointerEvents="none",m.container.innerHTML=R,e.engine.measure.annotationContainer.appendChild(m.container),m.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),m.container.getElementsByTagName("svg")[0].classList.add("Hight"),m.highlight=!0,e.engine.events.trigger(xt.MeasureClick,m)}),m.isSelect&&(m.container.getElementsByTagName("svg")[0].classList.add("Hight"),m.highlight=!0)}let f=new it(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(m.point1),p=new it(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(m.point2),x=new it(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(m.point3),v=e.engine.reactBoundingClientRect.left,_=e.engine.reactBoundingClientRect.top;f.x+=v,f.y+=_,p.x+=v,p.y+=_,x.x+=v,x.y+=_;let b=m.container;b.getElementsByTagName("circle")[0].setAttribute("cx",f.x),b.getElementsByTagName("circle")[0].setAttribute("cy",f.y),b.getElementsByTagName("circle")[1].setAttribute("cx",p.x),b.getElementsByTagName("circle")[1].setAttribute("cy",p.y),b.getElementsByTagName("circle")[2].setAttribute("cx",x.x),b.getElementsByTagName("circle")[2].setAttribute("cy",x.y),b.getElementsByTagName("polyline")[0].setAttribute("points",f.x+","+f.y+" "+p.x+","+p.y),b.getElementsByTagName("polyline")[1].setAttribute("points",p.x+","+p.y+" "+x.x+","+x.y);let S=p.x,C=p.y-30;b.getElementsByTagName("rect")[0].setAttribute("x",S-40),b.getElementsByTagName("rect")[0].setAttribute("y",C-12.5),b.getElementsByTagName("text")[0].setAttribute("x",S),b.getElementsByTagName("text")[0].setAttribute("y",C+4),b.getElementsByTagName("text")[0].innerHTML=m.text,b.style.top="0px",b.style.left="0px"}function c(m){if(m.container==null){let I=['<svg class="measureSvg">','<polygon fill="rgba(0, 0, 255, 0.1)" stroke="orange" stroke-width="2" points="" style="opacity: 0.3;"/>','<polyline class="measureLine" stroke="orange" stroke-width="2" points="" style="fill: none; opacity: 1;"/>','<rect x="0" y="0" width="100" height="25" class="measureBack" />','<text x="40" y="16" text-anchor="middle" class="measureLabel">'+e.getMeasureText(m.text,2)+"</text>","</svg>"].join("");m.container=document.createElement("div"),m.container.className="area-annotation",m.container.id=m.id,m.container.innerHTML=I,e.engine.measure.annotationContainer.appendChild(m.container),m.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),m.container.getElementsByTagName("svg")[0].classList.add("Hight"),m.highlight=!0,e.engine.events.trigger(xt.MeasureClick,m)}),m.isSelect&&(m.container.getElementsByTagName("svg")[0].classList.add("Hight"),m.highlight=!0)}if(!m.points||m.points.length<3)return;let f=e.engine.reactBoundingClientRect.left,p=e.engine.reactBoundingClientRect.top,x=[],v=0,_=0;for(let I=0;I<m.points.length;I++){let E=new it(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(m.points[I]);E.x+=f,E.y+=p,x.push(E),v+=E.x,_+=E.y}v=v/x.length,_=_/x.length;let b=x.map(I=>I.x+","+I.y).join(" "),S=m.container;S.getElementsByTagName("polygon")[0].setAttribute("points",b),S.getElementsByTagName("polyline")[0].setAttribute("points",b);let C=v,R=_;S.getElementsByTagName("rect")[0].setAttribute("x",C-40),S.getElementsByTagName("rect")[0].setAttribute("y",R-12.5),S.getElementsByTagName("text")[0].setAttribute("x",C),S.getElementsByTagName("text")[0].setAttribute("y",R+4),S.getElementsByTagName("text")[0].innerHTML=e.getMeasureText(m.text,2),S.style.top="0px",S.style.left="0px"}function h(m){if(m.container==null){let C=['<svg class="measureSvg">',"<defs>",'<marker id="slope-arrow-'+m.id+'" markerWidth="10" markerHeight="10" refX="9" refY="3" orient="auto" markerUnits="strokeWidth">','<path class="measureLine" d="M0,0 L0,6 L9,3 z"/>',"</marker>","</defs>",'<polyline class="measureLine" stroke="orange" stroke-width="2" points="0,0 0,0" marker-end="url(#slope-arrow-'+m.id+')" style="fill: none; opacity: 1;"/>','<rect x="0" y="0" width="100" height="25" class="measureBack" />','<text x="50" y="16" text-anchor="middle" class="measureLabel">'+m.text+"</text>","</svg>"].join("");m.container=document.createElement("div"),m.container.className="slope-annotation",m.container.id=m.id,m.container.innerHTML=C,e.engine.measure.annotationContainer.appendChild(m.container),m.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),m.container.getElementsByTagName("svg")[0].classList.add("Hight"),m.highlight=!0,e.engine.events.trigger(xt.MeasureClick,m)}),m.isSelect&&(m.container.getElementsByTagName("svg")[0].classList.add("Hight"),m.highlight=!0)}let f=new it(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(m.point1),p=new it(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(m.point2),x=e.engine.reactBoundingClientRect.left,v=e.engine.reactBoundingClientRect.top;f.x+=x,f.y+=v,p.x+=x,p.y+=v;let _=m.container;_.getElementsByTagName("polyline")[0].setAttribute("points",f.x+","+f.y+" "+p.x+","+p.y);let b=(f.x+p.x)/2,S=(f.y+p.y)/2-30;_.getElementsByTagName("rect")[0].setAttribute("x",b-50),_.getElementsByTagName("rect")[0].setAttribute("y",S-12.5),_.getElementsByTagName("text")[0].setAttribute("x",b),_.getElementsByTagName("text")[0].setAttribute("y",S+4),_.getElementsByTagName("text")[0].innerHTML=m.text,_.style.top="0px",_.style.left="0px"}function d(m){if(m.container==null){let R=['<svg class="measureSvg">','<circle class="measurePointer" cx="0" cy="0" r="5" fill="#f99d0b" />','<rect x="0" y="-25" width="100" height="25" class="measureBack" />','<text x="40" y="-11" text-anchor="middle" class="measureLabel">X: '+e.getMeasureText(m.textX,1)+"</text>",'<rect x="0" y="-10" width="100" height="25" class="measureBack" />','<text x="40" y="25" text-anchor="middle" class="measureLabel">Y: '+e.getMeasureText(-m.textZ,1)+"</text>",'<rect x="0" y="10" width="100" height="25" class="measureBack" />','<text x="40" y="51" text-anchor="middle" class="measureLabel">Z: '+e.getMeasureText(m.textY,1)+"</text>","</svg>"].join("");m.container=document.createElement("div"),m.container.className="coordinate-annotation",m.container.id=m.id,m.container.style.position="absolute",m.container.style.pointerEvents="none",m.container.innerHTML=R,e.engine.measure.annotationContainer.appendChild(m.container),m.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),m.container.getElementsByTagName("svg")[0].classList.add("Hight"),m.highlight=!0,e.engine.events.trigger(xt.MeasureClick,m)}),m.isSelect&&(m.container.getElementsByTagName("svg")[0].classList.add("Hight"),m.highlight=!0)}let f=m.container,p=new it(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(m.point),x=e.engine.reactBoundingClientRect.left,v=e.engine.reactBoundingClientRect.top;p.x+=x,p.y+=v,f.style.top="0px",f.style.left="0px";let _=f.getElementsByTagName("circle")[0];_&&(_.setAttribute("cx",p.x),_.setAttribute("cy",p.y));let b=f.getElementsByTagName("rect"),S=f.getElementsByTagName("text"),C=-55;b[0]&&(b[0].setAttribute("x",p.x+10),b[0].setAttribute("y",p.y+10+C)),S[0]&&(S[0].setAttribute("x",p.x+10+40),S[0].setAttribute("y",p.y+10+16+C)),b[1]&&(b[1].setAttribute("x",p.x+10),b[1].setAttribute("y",p.y+10+30+C)),S[1]&&(S[1].setAttribute("x",p.x+10+40),S[1].setAttribute("y",p.y+10+46+C)),b[2]&&(b[2].setAttribute("x",p.x+10),b[2].setAttribute("y",p.y+10+60+C)),S[2]&&(S[2].setAttribute("x",p.x+10+40),S[2].setAttribute("y",p.y+10+76+C)),S[0]&&(S[0].innerHTML="X: "+e.getMeasureText(m.textX,1)),S[1]&&(S[1].innerHTML="Y: "+e.getMeasureText(-m.textZ,1)),S[2]&&(S[2].innerHTML="Z: "+e.getMeasureText(m.textY,1))}function g(m){if(m.container==null){let _=['<svg width="100" height="50" class="measureSvg">','<rect x="0" y="0" width="100" height="25" class="measureBack" />','<text x="40" y="16" text-anchor="middle" class="measureLabel">'+e.getMeasureText(m.text,1)+"</text>",'<polyline class="measureLine" stroke-width="2" points="80,32 0,32 16,48 32,32" style="fill: none; opacity: 1;"/>',"</svg>"].join("");m.container=document.createElement("div"),m.container.className="elevation-annotation",m.container.id=m.id,m.container.style.position="absolute",m.container.style.pointerEvents="none",m.container.innerHTML=_,e.engine.measure.annotationContainer.appendChild(m.container),m.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),m.container.getElementsByTagName("svg")[0].classList.add("Hight"),m.highlight=!0,e.engine.events.trigger(xt.MeasureClick,m)}),m.isSelect&&(m.container.getElementsByTagName("svg")[0].classList.add("Hight"),m.highlight=!0)}let f=m.container,p=new it(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(m.point),x=e.engine.reactBoundingClientRect.left,v=e.engine.reactBoundingClientRect.top;f.style.top=p.y+v-48+"px",f.style.left=p.x+x-16+"px",f.getElementsByTagName("text")[0].innerHTML=e.getMeasureText(m.text,1)}function u(m){if(m.container==null){let b=['<svg class="measureSvg">','<circle class="measurePointer" cx="50" cy="50" r="5" fill="#f99d0b" />','<circle class="measurePointer" cx="50" cy="50" r="5" fill="#f99d0b" />','<polyline class="measureLine" stroke="orange" stroke-width="2" points="80,32 0,32" style="fill: none; opacity: 1;"/>','<rect x="0" y="0" width="100" height="25" class="measureBack" />','<text x="40" y="16" text-anchor="middle" class="measureLabel">'+e.getMeasureText(m.text,1)+"</text>","</svg>"].join("");m.container=document.createElement("div"),m.container.className="normal-annotation",m.container.id=m.id,m.container.innerHTML=b,e.engine.measure.annotationContainer.appendChild(m.container),m.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),m.container.getElementsByTagName("svg")[0].classList.add("Hight"),m.highlight=!0,e.engine.events.trigger(xt.MeasureClick,m)}),m.isSelect&&(m.container.getElementsByTagName("svg")[0].classList.add("Hight"),m.highlight=!0)}let f=m.container;if(m.point1==null||m.point2==null){f.style.display="none";return}else f.style.display="block";let p=new it(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(m.point1),x=new it(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(m.point2),v=e.engine.reactBoundingClientRect.left,_=e.engine.reactBoundingClientRect.top;p.x+=v,p.y+=_,x.x+=v,x.y+=_,f.getElementsByTagName("polyline")[0].setAttribute("points",p.x+","+p.y+" "+x.x+","+x.y),f.getElementsByTagName("circle")[0].setAttribute("cx",p.x),f.getElementsByTagName("circle")[0].setAttribute("cy",p.y),f.getElementsByTagName("circle")[1].setAttribute("cx",x.x),f.getElementsByTagName("circle")[1].setAttribute("cy",x.y),f.getElementsByTagName("rect")[0].setAttribute("x",p.x*.5+x.x*.5-40),f.getElementsByTagName("rect")[0].setAttribute("y",p.y*.5+x.y*.5-12.5),f.getElementsByTagName("text")[0].setAttribute("x",p.x*.5+x.x*.5+40-40),f.getElementsByTagName("text")[0].setAttribute("y",p.y*.5+x.y*.5+16-12.5),f.getElementsByTagName("text")[0].innerHTML=e.getMeasureText(m.text,1),f.style.top="0px",f.style.left="0px"}}}class Ay{engine;isActive=!1;tools;points=[];behavior;catchDir=0;type="point";constructor(e){this.engine=e,this.tools=new zn(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.isActive=!0,this.behavior=this.engine.handelBehaved,this.behavior.init(this),this.behavior.active();let e=this.engine.measure.annotationData.normalAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1)}disActive(){this.isActive=!1,this.behavior?.disActive()}clearAllPoints(){this.points=[]}setDirection(e){this.catchDir=e}setSelectType(e){this.type=e}getMeshesMinMaxY(e){if(!Array.isArray(e)||e.length===0)return null;let t=Number.POSITIVE_INFINITY,n=Number.NEGATIVE_INFINITY;for(let i=0;i<e.length;i++){const r=e[i];if(!r)continue;typeof r.updateMatrixWorld=="function"&&r.updateMatrixWorld(!0);const o=new y.Box3().setFromObject(r);!Number.isFinite(o.min.y)||!Number.isFinite(o.max.y)||(o.min.y<t&&(t=o.min.y),o.max.y>n&&(n=o.max.y))}return!Number.isFinite(t)||!Number.isFinite(n)?null:{minY:t,maxY:n}}handleMouseClick(e){if(e.catch==null)return;let t=e.catch.point;if(this.type=="element"){let r=this.engine.interactionModule.getCatchMeshs(e);var n=this.getMeshesMinMaxY(r);this.catchDir==0?t.set(t.x,n?.minY,t.z):t.set(t.x,n?.maxY,t.z)}else t=e.catch.point;if(this.points.length==0){this.engine.measure.tools.clearHighlight(),this.points.push(t);return}let i=this.engine.measure.annotationData.normalAnnotation.find(r=>r.isSelect==!0);i!=null&&(i.isSelect=!1)}handleMouseMove(e){if(e.catch==null||this.points.length==0)return;let t=this.engine.measure.annotationData.normalAnnotation.find(i=>i.isSelect==!0);t==null&&(t={text:null,id:Bn(),isSelect:!0,type:"clear-height"},this.engine.measure.annotationData.normalAnnotation.push(t));let n=e.catch;if(this.type=="element"){let i=e.catch.point.clone();i.set(i.x,this.points[0].y,i.z);let r=new y.Raycaster(i.add(new y.Vector3(0,.01,0)),new y.Vector3(0,this.catchDir==0?-1:1,0));n.point=this.points[0];const o=this.engine.clipping?.filterIntersectionsByClipping(this.engine.octreeBox.rayInterationModel(r))??this.engine.octreeBox.rayInterationModel(r);if(o.length===0){t.point2=null;return}t.point1=i,t.point2=o[0].point,t.text=t.point1.clone().distanceTo(t.point2.clone()),this.engine.events.trigger(xt.MeasureChanged,t)}else{let i=new y.Raycaster(e.catch.point.clone().add(new y.Vector3(0,.01,0)),new y.Vector3(0,this.catchDir==0?-1:1,0));const r=this.engine.clipping?.filterIntersectionsByClipping(this.engine.octreeBox.rayInterationModel(i))??this.engine.octreeBox.rayInterationModel(i);if(r.length===0){t.point2=null;return}t.point1=n.point,t.point2=r[0].point,t.text=t.point1.clone().distanceTo(t.point2.clone()),this.engine.events.trigger(xt.MeasureChanged,t)}}}class Ty{engine;tools;isActive=!1;points=[];behavior;constructor(e){this.engine=e,this.tools=new zn(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.isActive=!0,this.points=[],this.behavior=this.engine.handelBehaved,this.behavior.init(this,{showCatch:!0}),this.behavior.active();let e=this.engine.measure.annotationData.normalAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1)}disActive(){this.points=[],this.isActive=!1,this.engine.handelBehaved.disActive()}clearAllPoints(){this.points=[]}handleMouseClick(e){if(e.catch==null)return;let t=e.catch;if(this.points.length==0)this.engine.measure.tools.clearHighlight(),this.points.push(t.point);else if(this.points.length==1){let n=this.engine.measure.annotationData.normalAnnotation.find(i=>i.isSelect==!0);if(n==null)return;n.point2=t.point,n.isSelect=!1,this.points=[],this.engine.events.trigger(xt.MeasureChanged,n)}}handleMouseMove(e){if(e.catch==null)return;let t=e.catch;if(t!=null&&this.points.length==1){let n=this.engine.measure.annotationData.normalAnnotation.find(i=>i.isSelect==!0);n==null&&(n={id:Bn(),point1:this.points[0].clone(),point2:t.point.clone(),text:this.points[0].clone().distanceTo(t.point.clone()),type:"distance",isSelect:!0},this.engine.measure.annotationData.normalAnnotation.push(n)),n.point2=t.point,n.text=n.point1.clone().distanceTo(n.point2.clone())}}}class Py{engine;isActive=!1;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new zn(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.isActive=!0,this.behavior=this.engine.handelBehaved,this.behavior.init(this),this.behavior.active();let e=this.engine.measure.annotationData.normalAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1)}disActive(){this.isActive=!1,this.behavior?.disActive()}clearAllPoints(){this.points=[]}handleMouseClick(e){if(e.catch==null)return;if(this.points.length==0){this.engine.measure.tools.clearHighlight(),this.points.push(e.catch.point);return}let t=this.engine.measure.annotationData.normalAnnotation.find(n=>n.isSelect==!0);t!=null&&(t.isSelect=!1)}handleMouseMove(e){if(e.catch==null||this.points.length==0)return;let t=this.engine.measure.annotationData.normalAnnotation.find(o=>o.isSelect==!0);t==null&&(t={text:null,id:Bn(),isSelect:!0,type:"clear-distance"},this.engine.measure.annotationData.normalAnnotation.push(t));let n=new y.Raycaster(e.catch.point.clone().add(e.catch.face.normal.clone().setLength(.01)),e.catch.face.normal);const i=this.engine.clipping?.filterIntersectionsByClipping(this.engine.octreeBox.rayInterationModel(n))??this.engine.octreeBox.rayInterationModel(n);if(i.length==0){t.point2=null;return}let r=e.catch;t.point1=r.point,t.point2=i[0].point,t.text=t.point1.clone().distanceTo(t.point2.clone()),this.engine.events.trigger(xt.MeasureChanged,t)}}class Dy{engine;isActive=!1;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new zn(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.behavior=this.engine.handelBehaved,this.behavior.init(this,{showCatch:!0}),this.behavior.active(),this.isActive=!0;let e=this.engine.measure.annotationData.normalAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1)}disActive(){this.isActive=!1,this.behavior?.disActive()}clearAllPoints(){this.points=[]}handleMouseMove(e){if(e.catch==null)return;let t=this.engine.measure.annotationData.elevationAnnotation.find(n=>n.isSelect==!0);t==null&&(t={id:Bn(),point:e.catch.point.clone(),text:e.catch.point.y,isSelect:!0,type:"elevation"},this.engine.measure.annotationData.elevationAnnotation.push(t)),t.point=e.catch.point.clone(),t.text=e.catch.point.y}handleMouseClick(e){if(e.catch==null)return;this.engine.measure.tools.clearHighlight();let t=this.engine.measure.annotationData.elevationAnnotation.find(n=>n.isSelect==!0);t!=null&&(t.isSelect=!1,t.point=e.catch.point.clone(),t.text=e.catch.point.y,this.engine.events.trigger(xt.MeasureChanged,t))}}class Ry{engine;isActive=!1;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new zn(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.behavior=this.engine.handelBehaved,this.behavior.init(this,{showCatch:!0}),this.behavior.active(),this.isActive=!0;let e=this.engine.measure.annotationData.normalAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1)}disActive(){this.isActive=!1,this.behavior?.disActive()}clearAllPoints(){this.points=[]}handleMouseUp(e){this.engine.deviceType!="PC"&&this.createMeasure()}handleMouseMove(e){if(e.catch==null)return;let t=this.engine.measure.annotationData.coordinateAnnotation.find(n=>n.isSelect==!0);t==null&&(t={id:Bn(),point:e.catch.point.clone(),text:Math.round(e.catch.point.y)+" m",isSelect:!0,type:"point"},this.engine.measure.annotationData.coordinateAnnotation.push(t)),t.point=e.catch.point.clone(),t.textX=e.catch.point.x,t.textY=e.catch.point.y,t.textZ=e.catch.point.z}handleMouseClick(e){if(e.catch==null)return;this.engine.measure.tools.clearHighlight();let t=this.engine.measure.annotationData.coordinateAnnotation.find(n=>n.isSelect==!0);t!=null&&(t.point=e.catch.point.clone(),t.textX=e.catch.point.x,t.textY=e.catch.point.y,t.textZ=e.catch.point.z,t.isSelect=!1,this.engine.events.trigger(xt.MeasureChanged,t))}createMeasure(){let e=this.engine.measure.annotationData.coordinateAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1,this.engine.events.trigger(xt.MeasureChanged,e))}}class Ly{engine;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new zn(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.points=[],this.behavior=this.engine.handelBehaved,this.behavior.init(this),this.behavior.active();let e=this.engine.measure.annotationData.normalAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1)}disActive(){this.points=[],this.behavior?.disActive()}clearAllPoints(){this.points=[]}calculateAngle(e,t,n){const i=new y.Vector3().subVectors(e,t),r=new y.Vector3().subVectors(n,t),o=i.length(),a=r.length();if(o===0||a===0)return 0;const c=i.dot(r)/(o*a),h=Math.max(-1,Math.min(1,c));return Math.acos(h)*(180/Math.PI)}handleMouseClick(e){if(e.catch==null)return;let t=e.catch;if(this.points.length==0)this.engine.measure.tools.clearHighlight(),this.points.push(t.point);else if(this.points.length==1)this.points.push(t.point);else if(this.points.length==2){let n=this.engine.measure.annotationData.angleAnnotation.find(i=>i.isSelect==!0);if(n==null)return;n.point3=t.point.clone(),n.angle=this.calculateAngle(n.point1,n.point2,n.point3),n.text=n.angle.toFixed(2)+"°",n.isSelect=!1,n.type="angle",this.points=[],this.engine.events.trigger(xt.MeasureChanged,n)}}handleMouseMove(e){if(e.catch!=null&&this.points.length!=1&&this.points.length==2){let t=this.engine.measure.annotationData.angleAnnotation.find(n=>n.isSelect==!0);t==null&&(t={id:Bn(),point1:this.points[0].clone(),point2:this.points[1].clone(),point3:e.catch.point.clone(),angle:0,text:"0.00°",isSelect:!0,type:"angle"},this.engine.measure.annotationData.angleAnnotation.push(t)),t.point3=e.catch.point.clone(),t.angle=this.calculateAngle(t.point1,t.point2,t.point3),t.text=t.angle.toFixed(2)+"°",console.log("角度",t.text)}}}class Iy{engine;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new zn(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.points=[],this.behavior=this.engine.handelBehaved,this.behavior.init(this),this.behavior.active();let e=this.engine.measure.annotationData.normalAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1)}disActive(){this.points=[],this.behavior?.disActive()}clearAllPoints(){this.points=[]}calculateArea(e){if(e.length<3)return 0;let t=0;const n=e.length;for(let i=0;i<n;i++){const r=(i+1)%n;t+=e[i].x*e[r].z,t-=e[r].x*e[i].z}return t=Math.abs(t)/2,t}handleMouseClick(e){if(e.catch==null)return;let t=e.catch;if(this.points.push(t.point.clone()),this.points.length>=3){let n=this.engine.measure.annotationData.areaAnnotation.find(i=>i.isSelect==!0);n==null?(n={id:Bn(),points:this.points.map(i=>i.clone()),area:0,text:0,isSelect:!0,type:"area"},this.engine.measure.annotationData.areaAnnotation.push(n)):(this.points.push(t.point.clone()),n.points=this.points.map(i=>i.clone())),n.area=this.calculateArea(n.points),n.text=n.area,console.log("面积",n.text)}else this.engine.measure.tools.clearHighlight()}handleMouseMove(e){if(e.catch!=null&&this.points.length>=2){let t=this.engine.measure.annotationData.areaAnnotation.find(n=>n.isSelect==!0);if(t==null){if(this.points.length>=2){let n=this.points.map(i=>i.clone());n.push(e.catch.point.clone()),n.length>=3&&(t={id:Bn(),points:n,area:0,text:0,isSelect:!0,type:"area"},this.engine.measure.annotationData.areaAnnotation.push(t))}}else if(t.points.length>0){const n=t.points.length-1;t.points[n]=e.catch.point.clone()}else t.points=this.points.map(n=>n.clone()),t.points.push(e.catch.point.clone());t&&t.points.length>=3&&(t.area=this.calculateArea(t.points),t.text=t.area)}}handelKeyEnterDown(){this.finishMeasure()}finishMeasure(){this.points=this.points.slice(0,this.points.length-1);let e=this.engine.measure.annotationData.areaAnnotation.find(t=>t.isSelect==!0);e!=null&&e.points.length>=3&&(e.points.length>this.points.length&&(e.points=this.points.map(t=>t.clone())),e.area=this.calculateArea(e.points),e.text=e.area,e.isSelect=!1,this.points=[],this.engine.events.trigger(xt.MeasureChanged,e))}}class Ny{engine;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new zn(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.points=[],this.behavior=this.engine.handelBehaved,this.behavior.init(this,{showCatch:!0}),this.behavior.active();let e=this.engine.measure.annotationData.normalAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1)}disActive(){this.points=[],this.behavior?.disActive()}clearAllPoints(){this.points=[]}calculateSlope(e,t){const n=t.y-e.y,i=t.x-e.x,r=t.z-e.z,o=Math.sqrt(i*i+r*r);if(o===0)return{percentage:0,angle:0,heightDiff:n,horizontalDist:0,type:"slope"};const a=n/o*100,c=Math.atan(n/o)*(180/Math.PI);return{percentage:a,angle:c,heightDiff:n,horizontalDist:o,type:"slope"}}handleMouseClick(e){if(e.catch==null)return;let t=e.catch;if(this.points.length==0)this.engine.measure.tools.clearHighlight(),this.points.push(t.point);else if(this.points.length==1){let n=this.engine.measure.annotationData.slopeAnnotation.find(r=>r.isSelect==!0);if(n==null)return;console.log("进来了"),n.point2=t.point.clone();const i=this.calculateSlope(n.point1,n.point2);n.slopePercentage=i.percentage,n.slopeAngle=i.angle,n.heightDiff=i.heightDiff,n.horizontalDist=i.horizontalDist,n.text=i.percentage.toFixed(2)+"% ("+i.angle.toFixed(2)+"°)",n.isSelect=!1,this.points=[],this.engine.events.trigger(xt.MeasureChanged,n)}}handleMouseMove(e){if(e.catch==null)return;let t=e.catch;if(t!=null&&this.points.length==1){let n=this.engine.measure.annotationData.slopeAnnotation.find(r=>r.isSelect==!0);n==null&&(n={id:Bn(),point1:this.points[0].clone(),point2:t.point.clone(),slopePercentage:0,slopeAngle:0,heightDiff:0,horizontalDist:0,text:"0.00% (0.00°)",isSelect:!0,type:"slope"},this.engine.measure.annotationData.slopeAnnotation.push(n)),n.point2=t.point.clone();const i=this.calculateSlope(n.point1,n.point2);n.slopePercentage=i.percentage,n.slopeAngle=i.angle,n.heightDiff=i.heightDiff,n.horizontalDist=i.horizontalDist,n.text=i.percentage.toFixed(2)+"% ("+i.angle.toFixed(2)+"°)"}}}class Uy{isActive=!1;engine;clearHeightMeasure;distanceMeasure;clearDistanceMeasure;elevationMeasure;pointMeasure;angleMeasure;areaMeasure;slopeMeasure;tools;annotationContainer;annotationData={normalAnnotation:[],textAnnotation:[],coordinateAnnotation:[],angleAnnotation:[],distanceAnnotation:[],areaAnnotation:[],slopeAnnotation:[],elevationAnnotation:[],volumeAnnotation:[]};constructor(e){this.engine=e,this.clearHeightMeasure=new Ay(e),this.distanceMeasure=new Ty(e),this.clearDistanceMeasure=new Py(e),this.elevationMeasure=new Dy(e),this.pointMeasure=new Ry(e),this.angleMeasure=new Ly(e),this.areaMeasure=new Iy(e),this.slopeMeasure=new Ny(e),this.tools=new zn(e),this.annotationContainer=document.createElement("div"),this.annotationContainer.className="annotation-container",e.container.appendChild(this.annotationContainer)}active(){this.isActive=!0,this.engine.modelEdge.loadModelEdge(),this.tools.active()}disActive(){this.tools.disActive(),this.clearAll(),this.isActive=!1,this.clearHeightMeasure.disActive(),this.distanceMeasure.disActive(),this.clearDistanceMeasure.disActive(),this.elevationMeasure.disActive(),this.pointMeasure.disActive(),this.angleMeasure.disActive(),this.areaMeasure.disActive(),this.slopeMeasure.disActive(),this.engine.interactionModule.init(),this.engine.interactionModule.active()}clearAllPoints(){this.clearHeightMeasure.clearAllPoints(),this.distanceMeasure.clearAllPoints(),this.clearDistanceMeasure.clearAllPoints(),this.elevationMeasure.clearAllPoints(),this.pointMeasure.clearAllPoints(),this.angleMeasure.clearAllPoints(),this.areaMeasure.clearAllPoints(),this.slopeMeasure.clearAllPoints()}clearAll(){e(this.annotationData.normalAnnotation),e(this.annotationData.textAnnotation),e(this.annotationData.coordinateAnnotation),e(this.annotationData.angleAnnotation),e(this.annotationData.distanceAnnotation),e(this.annotationData.areaAnnotation),e(this.annotationData.slopeAnnotation),e(this.annotationData.elevationAnnotation),e(this.annotationData.volumeAnnotation);function e(t){for(let n=0;n<t.length;n++)t[n].container.remove();t=[]}}saveSetting(e){this.tools.saveSetting(e)}getSetting(){return this.tools.getSetting()}update(){this.isActive&&this.tools.drawNormalAnnotation()}}class Fy{engine;isActive=!1;isCtrlDown=!1;listenersAttached=!1;box;pickPoint;pickNormal;pickMesh;box_;plane;meshs;isDrag=!1;maxBox;faceIdleOpacity=0;faceHoverOpacity=.05;transformControls=new Map;transformAnchors=new Map;transformHelpers=new Map;faceMetaMap=new Map;isSyncingTransform=!1;handleNativeMouseDown=e=>{if(e.button!==0||!(this.isCtrlDown||e.ctrlKey))return;const t=this.createRaycasterFromMouseEvent(e),n=t.intersectObjects(this.getInteractiveMeshes(),!1);n.length!==0&&(e.preventDefault(),e.stopImmediatePropagation(),this.handleMouseDown({button:e.button,raycaster:t,intersects:n}))};handleNativeMouseMove=e=>{if(!this.isDrag&&!(this.isCtrlDown||e.ctrlKey)){this.resetMeshOpacity();return}const t=this.createRaycasterFromMouseEvent(e),n=t.intersectObjects(this.getInteractiveMeshes(),!1);this.isDrag&&(e.preventDefault(),e.stopImmediatePropagation()),this.handleMouseMove({raycaster:t,intersects:n})};handleNativeMouseUp=e=>{e.button!==0||!this.isDrag||(e.preventDefault(),e.stopImmediatePropagation(),this.handleMouseUp({button:e.button}))};handleNativeKeyDown=e=>{e.key==="Control"&&(this.isCtrlDown=!0)};handleNativeKeyUp=e=>{e.key==="Control"&&(this.isCtrlDown=!1,this.isDrag&&this.handleMouseUp({button:0}),this.resetMeshOpacity())};constructor(e,t){this.engine=e,this.meshs=[]}active(){this.isActive||(this.attachListeners(),this.init(),this.setTransformControlsVisible(!0),this.engine.scene.children.filter(e=>e.type=="Group"&&e.name=="ClippingBox").forEach(e=>{e.children.forEach(t=>{t.name.includes("face")||(t.visible=!0)})}),this.isActive=!0)}disActive(){this.init(),this.isActive=!1,this.detachListeners(),this.handleMouseUp({button:0}),this.setTransformControlsVisible(!1),this.engine.scene.children.filter(e=>e.type=="Group"&&e.name=="ClippingBox").forEach(e=>{e.children.forEach(t=>{t.name.includes("face")||(t.visible=!1)})})}disabled(){this.isActive=!1,this.detachListeners(),this.handleMouseUp({button:0}),this.setTransformControlsVisible(!1),this.engine.scene.children.filter(e=>e.type=="Group"&&e.name=="ClippingBox").forEach(e=>{e.children.forEach(t=>{t.name.includes("face")||(t.visible=!1)})})}recover(){this.isActive||(this.attachListeners(),this.setTransformControlsVisible(!0),this.engine.scene.children.filter(e=>e.type=="Group"&&e.name=="ClippingBox").forEach(e=>{e.children.forEach(t=>{t.name.includes("face")||(t.visible=!0)})}),this.isActive=!0)}init(){const e=this.engine.octreeBox.getBoundingBox();e.min.x-=.1,e.min.y-=.1,e.min.z-=.1,e.max.x+=.1,e.max.y+=.1,e.max.z+=.1,this.maxBox=JSON.parse(JSON.stringify(e)),this.box=e,this.updata_face(e)}getboxXyz(){return{minX:this.box.min.x,minY:this.box.min.y,minZ:this.box.min.z,maxX:this.box.max.x,maxY:this.box.max.y,maxZ:this.box.max.z}}setboxXyz(e){this.box.min.x=e.minX,this.box.min.y=e.minY,this.box.min.z=e.minZ,this.box.max.x=e.maxX,this.box.max.y=e.maxY,this.box.max.z=e.maxZ,this.updata_face(this.box)}setBox(e){this.box=e,this.updata_face(e)}reverseBox(){}handleMouseDown(e){const t=e.intersects??e.raycaster.intersectObjects(this.getInteractiveMeshes(),!1);if(t!=null&&t.length>0){const n=t[0];this.isDrag=!0,this.pickPoint=n.point.clone(),this.pickMesh=n.object;const i=this.pickMesh?.userData?.dragNormal?.clone?.(),r=n.face?.normal?.clone?.();if(this.pickNormal=(i??r??new y.Vector3(0,0,1)).clone().normalize(),this.engine.controls.enabled=!1,this.box_={min:this.box.min.clone(),max:this.box.max.clone()},this.pickNormal.y==0){const o=new y.Plane;o.setFromNormalAndCoplanarPoint(new y.Vector3(0,1,0),this.pickPoint),this.plane=o}else{const o=new y.Vector3(this.engine.camera.position.x,this.pickPoint.y,this.engine.camera.position.z),a=new y.Plane;a.setFromNormalAndCoplanarPoint(o.clone().sub(this.pickPoint.clone()).setLength(1),this.pickPoint),this.plane=a}}else this.isDrag=!1}handleMouseUp(e){this.isDrag=!1,this.pickPoint=null,this.pickNormal=null,this.pickMesh=null,this.plane=null,this.engine.controls.enabled=!0}clampVector3(e,t,n){return new y.Vector3(Math.max(t.x,Math.min(n.x,e.x)),Math.max(t.y,Math.min(n.y,e.y)),Math.max(t.z,Math.min(n.z,e.z)))}handleMouseMove(e){this.resetMeshOpacity();const t=e.intersects??e.raycaster.intersectObjects(this.getInteractiveMeshes(),!1);if(t!=null&&t.length>0&&(t[0].object.material.opacity=this.faceHoverOpacity),this.pickPoint!=null){const n=new y.Vector3;if(e.raycaster.ray.intersectPlane(this.plane,n)){const i=n.clone().sub(this.pickPoint.clone()).dot(this.pickNormal.clone());if(!!this.pickMesh?.userData?.isMinFace){const o=this.box_.min.clone().add(this.pickNormal.clone().setLength(i));this.box.min=this.clampVector3(o,this.maxBox.min,this.box.max)}else{const o=this.box_.max.clone().add(this.pickNormal.clone().setLength(i));this.box.max=this.clampVector3(o,this.box.min,this.maxBox.max)}this.updata_face(this.box),this.calculate_ratio()}}}calculate_ratio(){const e=this.maxBox.max.x-this.maxBox.min.x,t=this.maxBox.max.y-this.maxBox.min.y,n=this.maxBox.max.z-this.maxBox.min.z,i=this.toPercent((this.box.min.x-this.maxBox.min.x)/e*100),r=this.toPercent((this.box.max.x-this.maxBox.min.x)/e*100),o=this.toPercent((this.box.min.y-this.maxBox.min.y)/t*100),a=this.toPercent((this.box.max.y-this.maxBox.min.y)/t*100),l=this.toPercent((this.box.min.z-this.maxBox.min.z)/n*100),c=this.toPercent((this.box.max.z-this.maxBox.min.z)/n*100),h={x:{min:i,max:r},y:{min:o,max:a},z:{min:l,max:c}};this.engine.events.trigger(xt.SectionMove,h)}toPercent(e){return e<0?0:e>100?100:e}getInteractiveMeshes(){return this.meshs.filter(e=>e.type==="Mesh")}createRaycasterFromMouseEvent(e){const t=new y.Raycaster,n=new y.Vector2,i=this.engine.renderer.domElement.clientWidth,r=this.engine.renderer.domElement.clientHeight;return n.x=e.offsetX/i*2-1,n.y=-(e.offsetY/r)*2+1,t.setFromCamera(n,this.engine.camera),t}attachListeners(){if(this.listenersAttached)return;const e=this.engine.renderer?.domElement;e&&(e.addEventListener("mousedown",this.handleNativeMouseDown,!0),e.addEventListener("mousemove",this.handleNativeMouseMove,!0),e.addEventListener("mouseup",this.handleNativeMouseUp,!0),window.addEventListener("keydown",this.handleNativeKeyDown),window.addEventListener("keyup",this.handleNativeKeyUp),this.listenersAttached=!0)}detachListeners(){if(!this.listenersAttached)return;const e=this.engine.renderer?.domElement;e&&(e.removeEventListener("mousedown",this.handleNativeMouseDown,!0),e.removeEventListener("mousemove",this.handleNativeMouseMove,!0),e.removeEventListener("mouseup",this.handleNativeMouseUp,!0)),window.removeEventListener("keydown",this.handleNativeKeyDown),window.removeEventListener("keyup",this.handleNativeKeyUp),this.listenersAttached=!1,this.isCtrlDown=!1}resetMeshOpacity(){this.getInteractiveMeshes().forEach(e=>{e.material&&(e.material.opacity=this.faceIdleOpacity)})}getFaceTransformOffset(){if(!this.box)return .06;const e=this.box.min.distanceTo(this.box.max);return Math.max(e*.015,.06)}keepSingleDirectionArrow(e,t="X"){const n=e.getHelper(),i=[];n.traverse(r=>{if(r?.name!==t||!r.geometry)return;const o=r.geometry;o.boundingBox||o.computeBoundingBox();const a=o.boundingBox;if(!a)return;const l=a.getCenter(new y.Vector3);if(!(t==="X"&&l.x<0||t==="Y"&&l.y<0||t==="Z"&&l.z<0))return;const h=o.parameters,d=h&&h.radiusTop===0&&h.radiusBottom===.04&&h.height===.1,g=h&&h.radiusTop===.2&&h.radiusBottom===0&&h.height===.6;(d||g)&&i.push(r)}),i.forEach(r=>{r.parent?.remove(r)})}setTransformControlsVisible(e){this.transformControls.forEach(t=>{t.enabled=e}),this.transformHelpers.forEach(t=>{t.visible=e}),this.transformAnchors.forEach(t=>{t.visible=e}),e||(this.engine.controls.enabled=!0)}ensureFaceTransformControl(e){if(this.transformControls.has(e)&&this.transformAnchors.has(e))return;const t=this.engine.renderer?.domElement,n=this.engine.camera;if(!t||!n)return;const i=new y.Object3D;i.name=`SectionBoxTransformAnchor_${e}`,i.visible=this.isActive,this.engine.scene.add(i);const r=new cd(n,t);r.name=`SectionBoxTransformControl_${e}`,r.setMode("translate"),r.setSpace("local"),r.showX=!0,r.showY=!1,r.showZ=!1,r.size=.75,r.enabled=this.isActive,r.attach(i),this.keepSingleDirectionArrow(r,"X"),r.addEventListener("dragging-changed",a=>{this.engine.controls.enabled=!a.value}),r.addEventListener("objectChange",()=>{this.handleTransformObjectChange(e)});const o=r.getHelper();o.visible=this.isActive,this.engine.scene.add(o),this.transformAnchors.set(e,i),this.transformControls.set(e,r),this.transformHelpers.set(e,o)}updateFaceTransformControl(e,t,n,i){this.ensureFaceTransformControl(e);const r=this.transformAnchors.get(e),o=this.transformControls.get(e);if(!r||!o)return;const a=this.getFaceTransformOffset(),l=new y.Quaternion().setFromUnitVectors(new y.Vector3(1,0,0),t.clone().normalize()),c=n.clone().add(t.clone().setLength(a));this.faceMetaMap.set(e,{normal:t.clone().normalize(),isMinFace:i,center:n.clone()}),this.isSyncingTransform=!0,r.position.copy(c),r.quaternion.copy(l),r.visible=this.isActive,o.object!==r&&o.attach(r),o.enabled=this.isActive;const h=this.transformHelpers.get(e);h&&(h.visible=this.isActive),this.isSyncingTransform=!1}getDominantAxis(e){const t=Math.abs(e.x),n=Math.abs(e.y),i=Math.abs(e.z);return t>=n&&t>=i?"x":n>=t&&n>=i?"y":"z"}handleTransformObjectChange(e){if(this.isSyncingTransform)return;const t=this.transformAnchors.get(e),n=this.faceMetaMap.get(e);if(!t||!n||!this.box||!this.maxBox)return;const i=n.normal,r=this.getDominantAxis(i),o=this.getFaceTransformOffset(),a=i[r],l=t.position[r]-a*o;if(n.isMinFace){const c=this.maxBox.min[r],h=this.box.max[r];this.box.min[r]=Math.max(c,Math.min(h,l))}else{const c=this.box.min[r],h=this.maxBox.max[r];this.box.max[r]=Math.max(c,Math.min(h,l))}this.updata_face(this.box),this.calculate_ratio()}updata_face(e){let t=this.engine.scene.children.find(i=>i.type=="Group"&&i.name=="ClippingBox");t==null&&(t=new y.Group,t.name="ClippingBox",this.engine.scene.add(t)),[{name:"前",normal:new y.Vector3(0,0,-1),isMinFace:!0,planePoint:e.min,vertices:[new y.Vector3(e.min.x,e.max.y,e.min.z),new y.Vector3(e.max.x,e.max.y,e.min.z),new y.Vector3(e.max.x,e.min.y,e.min.z),new y.Vector3(e.min.x,e.min.y,e.min.z)]},{name:"后",normal:new y.Vector3(0,0,1),isMinFace:!1,planePoint:e.max,vertices:[new y.Vector3(e.min.x,e.min.y,e.max.z),new y.Vector3(e.max.x,e.min.y,e.max.z),new y.Vector3(e.max.x,e.max.y,e.max.z),new y.Vector3(e.min.x,e.max.y,e.max.z)]},{name:"右",normal:new y.Vector3(1,0,0),isMinFace:!1,planePoint:e.max,vertices:[new y.Vector3(e.max.x,e.min.y,e.max.z),new y.Vector3(e.max.x,e.min.y,e.min.z),new y.Vector3(e.max.x,e.max.y,e.min.z),new y.Vector3(e.max.x,e.max.y,e.max.z)]},{name:"左",normal:new y.Vector3(-1,0,0),isMinFace:!0,planePoint:e.min,vertices:[new y.Vector3(e.min.x,e.min.y,e.min.z),new y.Vector3(e.min.x,e.min.y,e.max.z),new y.Vector3(e.min.x,e.max.y,e.max.z),new y.Vector3(e.min.x,e.max.y,e.min.z)]},{name:"顶",normal:new y.Vector3(0,1,0),isMinFace:!1,planePoint:e.max,vertices:[new y.Vector3(e.min.x,e.max.y,e.max.z),new y.Vector3(e.max.x,e.max.y,e.max.z),new y.Vector3(e.max.x,e.max.y,e.min.z),new y.Vector3(e.min.x,e.max.y,e.min.z)]},{name:"底",normal:new y.Vector3(0,-1,0),isMinFace:!0,planePoint:e.min,vertices:[new y.Vector3(e.min.x,e.min.y,e.min.z),new y.Vector3(e.max.x,e.min.y,e.min.z),new y.Vector3(e.max.x,e.min.y,e.max.z),new y.Vector3(e.min.x,e.min.y,e.max.z)]}].forEach(i=>{this.createFace(t,i.vertices,i.normal,i.name,i.isMinFace,i.planePoint)}),this.engine.scene.children.filter(i=>i.type=="Mesh"&&i.url).forEach(i=>{i.material&&Array.isArray(i.material)?i.material.forEach(r=>{r.clippingPlanes=this.engine.sectionPlane}):i.material.clippingPlanes=this.engine.sectionPlane})}createFace(e,t,n,i,r,o){const a=new y.BufferGeometry,l=new Float32Array([t[0].x,t[0].y,t[0].z,t[1].x,t[1].y,t[1].z,t[2].x,t[2].y,t[2].z,t[3].x,t[3].y,t[3].z]),c=[0,2,1,0,3,2];a.setAttribute("position",new y.BufferAttribute(l,3)),a.setIndex(c);let h=this.meshs.find(x=>x.name===i);if(h==null){const x=new y.MeshBasicMaterial({color:65280,transparent:!0,opacity:this.faceIdleOpacity,side:y.DoubleSide});x.polygonOffset=!0,x.polygonOffsetFactor=1,x.polygonOffsetUnits=4,h=new y.Mesh(a,x),h.name=i,e.add(h),this.meshs.push(h)}else h.geometry=a;h.userData={dragNormal:n.clone(),isMinFace:r,faceName:i};const d=new Float32Array([t[0].x,t[0].y,t[0].z,t[1].x,t[1].y,t[1].z,t[2].x,t[2].y,t[2].z,t[3].x,t[3].y,t[3].z,t[0].x,t[0].y,t[0].z]),g=new y.LineBasicMaterial({color:255}),u=new y.BufferGeometry;u.setAttribute("position",new y.BufferAttribute(d,3));let m=this.meshs.find(x=>x.name===i+"Line");m==null?(m=new y.Line(u,g),m.name=i+"Line",e.add(m),this.meshs.push(m)):(m.geometry=u,m.material=g);const f=new y.Vector3;t.forEach(x=>f.add(x)),f.multiplyScalar(1/t.length),this.updateFaceTransformControl(i,n,f,r);const p=this.engine.sectionPlane.find(x=>x.name==i);p&&p.setFromNormalAndCoplanarPoint(n.clone().setLength(-1),o)}}class Oy{engine;isActive=!1;isDrag=!1;isCtrlDown=!1;listenersAttached=!1;meshs=[];box=null;pickPoint=null;pickNormal=null;plane=null;angleX=0;angleY=0;angleZ=0;direction=1;normal=new y.Vector3(0,0,1);distance=0;center=null;current_center=null;dragStartDistance=0;idleOpacity=.02;hoverOpacity=.05;transformControl=null;transformAnchor=null;transformHelper=null;isSyncingTransformControl=!1;handleNativeMouseDown=e=>{if(e.button!==0||!(this.isCtrlDown||e.ctrlKey))return;const t=this.createRaycasterFromMouseEvent(e),n=t.intersectObjects(this.getInteractiveMeshes(),!1);n.length!==0&&(e.preventDefault(),e.stopImmediatePropagation(),this.handleMouseDown({button:e.button,raycaster:t,intersects:n}))};handleNativeMouseMove=e=>{if(!this.isDrag&&!(this.isCtrlDown||e.ctrlKey)){this.resetMeshOpacity();return}const t=this.createRaycasterFromMouseEvent(e),n=t.intersectObjects(this.getInteractiveMeshes(),!1);this.isDrag&&(e.preventDefault(),e.stopImmediatePropagation()),this.handleMouseMove({raycaster:t,intersects:n})};handleNativeMouseUp=e=>{e.button!==0||!this.isDrag||(e.preventDefault(),e.stopImmediatePropagation(),this.handleMouseUp({button:e.button}))};handleNativeKeyDown=e=>{e.key==="Control"&&(this.isCtrlDown=!0)};handleNativeKeyUp=e=>{e.key==="Control"&&(this.isCtrlDown=!1,this.isDrag&&this.handleMouseUp({button:0}),this.resetMeshOpacity())};handleTransformObjectChange=()=>{if(this.isSyncingTransformControl||!this.transformAnchor||!this.center)return;const e=this.normal.clone().normalize(),t=this.getDistanceRange(e),n=this.getTransformHandleOffset(),i=this.transformAnchor.position.clone().sub(this.center).dot(e)-n,r=Math.min(t.max,Math.max(t.min,i));Math.abs(r-Number(this.distance))>1e-5?this.updata_face(r):Math.abs(i-r)>1e-5&&this.updateTransformControl(e)};constructor(e){this.engine=e,this.meshs=[],this.box=null}active(){if(this.isActive==!0)return;this.isActive=!0,this.engine.scene.children.filter(t=>t.type=="Group"&&t.name=="ClippingBox").forEach(t=>{t.children.forEach(n=>{n.name.includes("face")&&(n.visible=!0)})}),this.attachListeners(),this.ensureTransformControl(),this.setTransformControlVisible(!0);const e=this;e.engine.scene.children.filter(t=>t.type=="Mesh"&&t.url).forEach(t=>{t.material&&Array.isArray(t.material)?t.material.forEach(n=>{n.clippingPlanes=e.engine.sectionPlane}):t.material.clippingPlanes=e.engine.sectionPlane,e.engine.clipping.clippingStencil?.addMesh(e.engine.sectionPlane.find(n=>n.name=="face"),t)}),this.init()}disActive(){this.init(),this.isActive=!1,this.detachListeners(),this.handleMouseUp({button:0}),this.setTransformControlVisible(!1);const e=this.engine.sectionPlane.find(t=>t.name=="face");e&&(e.constant=1e5),this.engine.scene.children.filter(t=>t.type=="Group"&&t.name=="ClippingBox").forEach(t=>{t.children.forEach(n=>{n.name.includes("face")&&(n.visible=!1)})})}init(e){const t=this.engine.octreeBox.getBoundingBox();this.box=t,this.distance=0,this.center=new y.Vector3((t.min.x+t.max.x)/2,(t.min.y+t.max.y)/2,(t.min.z+t.max.z)/2),this.current_center=this.center.clone(),!e&&this.updata_face(0)}disabled(){this.isActive=!1,this.detachListeners(),this.handleMouseUp({button:0}),this.setTransformControlVisible(!1),this.engine.scene.children.filter(e=>e.type=="Group"&&e.name=="ClippingBox").forEach(e=>{e.children.forEach(t=>{t.name.includes("face")&&(t.visible=!1)})})}recover(){this.isActive||(this.attachListeners(),this.setTransformControlVisible(!0),this.engine.scene.children.filter(e=>e.type=="Group"&&e.name=="ClippingBox").forEach(e=>{e.children.forEach(t=>{t.name.includes("face")&&(t.visible=!0)})}),this.isActive=!0)}setFaceAngle(e,t,n){this.angleX=e,this.angleY=t,this.angleZ=n,this.distance=0,this.normal=new y.Vector3(0,1,0).applyAxisAngle(new y.Vector3(1,0,0),e).applyAxisAngle(new y.Vector3(0,0,1),t).applyAxisAngle(new y.Vector3(0,1,0),n).normalize(),this.updata_face(0)}setFaceNormal(e,t=0){this.normal=e.clone().normalize(),this.distance=t,this.updata_face(t)}setFaceNormalPlaneOnly(e,t){if(this.normal=e.clone().normalize(),this.distance=t,!this.center||!this.box)return;const n=this.engine.sectionPlane?.find(i=>i.name==="face");if(n){const i=this.center.clone().add(this.normal.clone().multiplyScalar(t));n.setFromNormalAndCoplanarPoint(this.normal.clone().multiplyScalar(this.direction),i)}}activateClippingOnly(){if(this.isActive)return;this.isActive=!0;const e=this;e.engine.scene.children.filter(t=>t.type==="Mesh"&&t.url).forEach(t=>{t.material&&Array.isArray(t.material)?t.material.forEach(n=>{n.clippingPlanes=e.engine.sectionPlane}):t.material.clippingPlanes=e.engine.sectionPlane,e.engine.clipping.clippingStencil?.addMesh(e.engine.sectionPlane.find(n=>n.name==="face"),t)})}reverse(){this.direction=this.direction*-1,this.updata_face(this.distance)}getFaceAngle(){return{angleX:this.angleX,angleY:this.angleY,angleZ:this.angleZ,direction:this.direction}}updata_face(e){if(!this.box)return;this.distance=e;let t=this.engine.scene.children.find(_=>_.type=="Group"&&_.name=="ClippingBox");t==null&&(t=new y.Group,t.name="ClippingBox",this.engine.scene.add(t));const n=this.normal.clone().normalize(),i=this.center??new y.Vector3((this.box.min.x+this.box.max.x)/2,(this.box.min.y+this.box.max.y)/2,(this.box.min.z+this.box.max.z)/2);this.center=i.clone();const{tangent:r,bitangent:o}=this.getPlaneBasis(n),a=this.getBoxCorners(this.box),l=this.box.min.distanceTo(this.box.max),c=Math.max(l*.02,.01);let h=1/0,d=-1/0,g=1/0,u=-1/0;a.forEach(_=>{const b=_.clone().sub(i),S=b.dot(r),C=b.dot(o);h=Math.min(h,S),d=Math.max(d,S),g=Math.min(g,C),u=Math.max(u,C)}),h-=c,d+=c,g-=c,u+=c;const m=n.clone().multiplyScalar(e),f=i.clone().add(r.clone().multiplyScalar(h)).add(o.clone().multiplyScalar(g)).add(m),p=i.clone().add(r.clone().multiplyScalar(d)).add(o.clone().multiplyScalar(g)).add(m),x=i.clone().add(r.clone().multiplyScalar(d)).add(o.clone().multiplyScalar(u)).add(m),v=i.clone().add(r.clone().multiplyScalar(h)).add(o.clone().multiplyScalar(u)).add(m);this.current_center=i.clone().add(m),this.createFace(t,[f,p,x,v],n,"face"),this.updateTransformControl(n)}createFace(e,t,n,i){const r=new y.BufferGeometry,o=new Float32Array([t[0].x,t[0].y,t[0].z,t[1].x,t[1].y,t[1].z,t[2].x,t[2].y,t[2].z,t[3].x,t[3].y,t[3].z]),a=[0,1,2,0,2,3];r.setAttribute("position",new y.BufferAttribute(o,3)),r.setIndex(a);let l=this.meshs.find(m=>m.name==i);if(l==null){const m=new y.MeshBasicMaterial({color:65280,transparent:!0,opacity:this.idleOpacity,side:y.DoubleSide});m.polygonOffset=!0,m.polygonOffsetFactor=1,m.polygonOffsetUnits=4,l=new y.Mesh(r,m),l.name=i,e.add(l),this.meshs.push(l)}else l.geometry=r;l.normal=n.clone();const c=new Float32Array([t[0].x,t[0].y,t[0].z,t[1].x,t[1].y,t[1].z,t[2].x,t[2].y,t[2].z,t[3].x,t[3].y,t[3].z,t[0].x,t[0].y,t[0].z]),h=new y.LineBasicMaterial({color:255}),d=new y.BufferGeometry;d.setAttribute("position",new y.BufferAttribute(c,3));let g=this.meshs.find(m=>m.name==i+"Line");g==null?(g=new y.Line(d,h),g.name=i+"Line",e.add(g),this.meshs.push(g)):(g.geometry=d,g.material=h);const u=this.engine.sectionPlane.find(m=>m.name==i);u&&this.current_center&&u.setFromNormalAndCoplanarPoint(n.clone().setLength(this.direction),this.current_center)}getPlaneBasis(e){const t=new y.Vector3(1,0,0),n=new y.Vector3(0,1,0),i=new y.Vector3(0,0,1),r=Math.abs(e.dot(t)),o=Math.abs(e.dot(n)),a=Math.abs(e.dot(i));let l=t;o<=r&&o<=a?l=n:a<=r&&a<=o&&(l=i),l=l.clone().sub(e.clone().multiplyScalar(l.dot(e))).normalize();const c=new y.Vector3().crossVectors(e,l).normalize();return{tangent:l,bitangent:c}}getBoxCorners(e){return[new y.Vector3(e.min.x,e.min.y,e.min.z),new y.Vector3(e.min.x,e.min.y,e.max.z),new y.Vector3(e.min.x,e.max.y,e.min.z),new y.Vector3(e.min.x,e.max.y,e.max.z),new y.Vector3(e.max.x,e.min.y,e.min.z),new y.Vector3(e.max.x,e.min.y,e.max.z),new y.Vector3(e.max.x,e.max.y,e.min.z),new y.Vector3(e.max.x,e.max.y,e.max.z)]}getDistanceRange(e){if(!this.box)return{min:0,max:0};const t=this.center??new y.Vector3((this.box.min.x+this.box.max.x)/2,(this.box.min.y+this.box.max.y)/2,(this.box.min.z+this.box.max.z)/2),n=this.getBoxCorners(this.box);let i=1/0,r=-1/0;return n.forEach(o=>{const a=o.clone().sub(t).dot(e);i=Math.min(i,a),r=Math.max(r,a)}),{min:i,max:r}}getInteractiveMeshes(){return this.meshs.filter(e=>e.type==="Mesh")}getTransformHandleOffset(){if(!this.box)return .06;const e=this.box.min.distanceTo(this.box.max);return Math.max(e*.015,.06)}keepSingleDirectionArrow(e,t="X"){const n=e.getHelper(),i=[];n.traverse(r=>{if(r?.name!==t||!r.geometry)return;const o=r.geometry;o.boundingBox||o.computeBoundingBox();const a=o.boundingBox;if(!a)return;const l=a.getCenter(new y.Vector3);if(!(t==="X"&&l.x<0||t==="Y"&&l.y<0||t==="Z"&&l.z<0))return;const h=o.parameters,d=h&&h.radiusTop===0&&h.radiusBottom===.04&&h.height===.1,g=h&&h.radiusTop===.2&&h.radiusBottom===0&&h.height===.6;(d||g)&&i.push(r)}),i.forEach(r=>{r.parent?.remove(r)})}ensureTransformControl(){if(this.transformControl&&this.transformAnchor)return;const e=this.engine.renderer?.domElement,t=this.engine.camera;if(!e||!t)return;const n=new y.Object3D;n.name="SectionFaceTransformAnchor",n.visible=this.isActive,this.engine.scene.add(n);const i=new cd(t,e);i.name="SectionFaceTransformControl",i.setMode("translate"),i.setSpace("local"),i.showX=!0,i.showY=!1,i.showZ=!1,i.size=.85,i.enabled=this.isActive,i.attach(n),this.keepSingleDirectionArrow(i,"X"),i.addEventListener("dragging-changed",o=>{this.engine.controls.enabled=!o.value}),i.addEventListener("objectChange",this.handleTransformObjectChange);const r=i.getHelper();r.visible=this.isActive,this.engine.scene.add(r),this.transformAnchor=n,this.transformControl=i,this.transformHelper=r}setTransformControlVisible(e){this.ensureTransformControl(),this.transformControl&&(this.transformControl.enabled=e),this.transformHelper&&(this.transformHelper.visible=e),this.transformAnchor&&(this.transformAnchor.visible=e),e||(this.engine.controls.enabled=!0)}updateTransformControl(e){if(this.ensureTransformControl(),!this.transformControl||!this.transformAnchor||!this.current_center)return;const t=this.getTransformHandleOffset(),n=this.current_center.clone().add(e.clone().setLength(t)),i=new y.Quaternion().setFromUnitVectors(new y.Vector3(1,0,0),e.clone().normalize());this.isSyncingTransformControl=!0,this.transformAnchor.position.copy(n),this.transformAnchor.quaternion.copy(i),this.transformAnchor.visible=this.isActive,this.transformControl.object!==this.transformAnchor&&this.transformControl.attach(this.transformAnchor),this.transformControl.enabled=this.isActive,this.transformHelper&&(this.transformHelper.visible=this.isActive),this.isSyncingTransformControl=!1}createRaycasterFromMouseEvent(e){const t=new y.Raycaster,n=new y.Vector2,i=this.engine.renderer.domElement.clientWidth,r=this.engine.renderer.domElement.clientHeight;return n.x=e.offsetX/i*2-1,n.y=-(e.offsetY/r)*2+1,t.setFromCamera(n,this.engine.camera),t}attachListeners(){if(this.listenersAttached)return;const e=this.engine.renderer?.domElement;e&&(e.addEventListener("mousedown",this.handleNativeMouseDown,!0),e.addEventListener("mousemove",this.handleNativeMouseMove,!0),e.addEventListener("mouseup",this.handleNativeMouseUp,!0),window.addEventListener("keydown",this.handleNativeKeyDown),window.addEventListener("keyup",this.handleNativeKeyUp),this.listenersAttached=!0)}detachListeners(){if(!this.listenersAttached)return;const e=this.engine.renderer?.domElement;e&&(e.removeEventListener("mousedown",this.handleNativeMouseDown,!0),e.removeEventListener("mousemove",this.handleNativeMouseMove,!0),e.removeEventListener("mouseup",this.handleNativeMouseUp,!0)),window.removeEventListener("keydown",this.handleNativeKeyDown),window.removeEventListener("keyup",this.handleNativeKeyUp),this.listenersAttached=!1,this.isCtrlDown=!1}resetMeshOpacity(){this.getInteractiveMeshes().forEach(e=>{e.material&&(e.material.opacity=this.idleOpacity)})}handleMouseDown(e){const t=e.intersects??e.raycaster.intersectObjects(this.getInteractiveMeshes(),!1);if(t!=null&&t.length>0){const n=t[0],i=n.point.clone();this.isDrag=!0,this.pickPoint=i;const o=(n.face?.normal?.clone()??this.normal.clone()).clone();if(o.dot(this.normal)<0&&o.multiplyScalar(-1),o.normalize(),this.pickNormal=o,this.engine.controls.enabled=!1,this.dragStartDistance=Number(this.distance)||0,o.y==0){const a=new y.Plane;a.setFromNormalAndCoplanarPoint(new y.Vector3(0,1,0),i),this.plane=a}else{const a=new y.Vector3(this.engine.camera.position.x,i.y,this.engine.camera.position.z),l=new y.Plane;l.setFromNormalAndCoplanarPoint(a.clone().sub(i.clone()).setLength(1),i),this.plane=l}}else this.isDrag=!1}handleMouseUp(e){this.isDrag=!1,this.pickPoint=null,this.pickNormal=null,this.plane=null,this.engine.controls.enabled=!0}handleMouseMove(e){this.resetMeshOpacity();const t=e.intersects??e.raycaster.intersectObjects(this.getInteractiveMeshes(),!1);t!=null&&t.length>0&&(t[0].object.material.opacity=this.hoverOpacity);const n=this.pickPoint,i=this.pickNormal,r=this.plane;if(n!=null&&i!=null&&r!=null){const o=new y.Vector3;if(e.raycaster.ray.intersectPlane(r,o)){const a=o.clone().sub(n.clone()).dot(i.clone()),l=this.getDistanceRange(this.normal.clone().normalize()),c=this.dragStartDistance+a;this.distance=Math.min(l.max,Math.max(l.min,c)),this.updata_face(this.distance)}}}}class ky{engine;callback_;constructor(e){this.engine=e}init(){this.engine.handelBehaved.init(this,{showCatch:!0}),this.engine.handelBehaved.active()}catch_face(e){this.callback_=e}handleMouseMove(e){}handleMouseClick(e){if(!e.catch?.normal||!e.catch?.point)return;let t=e.catch.normal.setLength(-1);this.engine.handelBehaved.disActive(),this.callback_({dir:t,position:e.catch.point})}}class By{engine;clippingTolerance=1e-4;sectionBox;sectionFace;clippingStencil;currentClippingMode="";constructor(e){this.engine=e;let t=new y.Plane(new y.Vector3(0,0,1),1e5);t.name="前";let n=new y.Plane(new y.Vector3(0,0,1),1e5);n.name="左";let i=new y.Plane(new y.Vector3(0,0,1),1e5);i.name="后";let r=new y.Plane(new y.Vector3(0,0,1),1e5);r.name="右";let o=new y.Plane(new y.Vector3(0,0,1),1e5);o.name="顶";let a=new y.Plane(new y.Vector3(0,0,1),1e5);a.name="底";let l=new y.Plane(new y.Vector3(0,0,1),1e5);l.name="face",this.engine.sectionPlane=[t,n,i,r,o,a,l]}init(){this.sectionBox=new Fy(this.engine),this.sectionFace=new Oy(this.engine)}scaleBox(){let e=this.engine.octreeBox.getBoundingBox();this.sectionBox.setBox(e)}clippingModel(e){let t=[];e.forEach(r=>{let o=this.engine.models.find(a=>a.url===r.url);r.ids.forEach(a=>{o.nodesMap.get(a).infos.forEach(l=>{t.push(l.box)})})}),this.active("box");let n=i(t);this.sectionBox.setBox(n);function i(r){let o=new y.Vector3(1e8,1e9,1e10),a=new y.Vector3(-1e8,-1e9,-1e10);return r.forEach(l=>{l.min.x<o.x&&(o.x=l.min.x),l.min.y<o.y&&(o.y=l.min.y),l.min.z<o.z&&(o.z=l.min.z),l.max.x>a.x&&(a.x=l.max.x),l.max.y>a.y&&(a.y=l.max.y),l.max.z>a.z&&(a.z=l.max.z)}),new y.Box3(o,a)}}updateClippingValue(e){let t=this.sectionBox.maxBox,n=t.min.x+(t.max.x-t.min.x)*e.x.min*.01,i=t.min.y+(t.max.y-t.min.y)*e.y.min*.01,r=t.min.z+(t.max.z-t.min.z)*e.z.min*.01,o=t.min.x+(t.max.x-t.min.x)*e.x.max*.01,a=t.min.y+(t.max.y-t.min.y)*e.y.max*.01,l=t.min.z+(t.max.z-t.min.z)*e.z.max*.01;this.sectionBox.setboxXyz({minX:n,minY:i,minZ:r,maxX:o,maxY:a,maxZ:l})}active(e){if(this.engine.engineStatus.isForceFree=!0,this.sectionFace.disActive(),this.sectionBox.disActive(),this.currentClippingMode=e,e=="x")this.sectionFace.init(),this.sectionFace.active(),this.sectionFace.setFaceAngle(Math.PI/2,0,0);else if(e=="y")this.sectionFace.init(),this.sectionFace.active(),this.sectionFace.setFaceAngle(0,Math.PI/2,0);else if(e=="z")this.sectionFace.init(),this.sectionFace.active(),this.sectionFace.setFaceAngle(0,0,Math.PI/2);else if(e=="box")this.sectionBox.init(),this.sectionBox.active();else if(e=="face"){let t=new ky(this.engine);t.init(),t.catch_face(n=>{this.sectionFace.init(),this.sectionFace.active();let i=this.engine.octreeBox.getBoundingBox(),r=i.min.clone().add(i.max.clone()).multiplyScalar(.5),o=n.position.clone().sub(r),a=new y.Vector3(n.dir.x,n.dir.y,n.dir.z),l=o.dot(a);this.sectionFace.setFaceNormal(n.dir,l)})}}disabled(){this.currentClippingMode=="box"?this.sectionBox.disabled():this.sectionFace.disabled(),this.engine.engineStatus.isForceFree=!1}recover(){this.currentClippingMode=="box"?this.sectionBox.recover():this.sectionFace.recover()}reverse(){this.sectionFace.reverse()}disActive(){this.sectionFace.disActive(),this.sectionBox.disActive(),this.currentClippingMode="",this.engine.engineStatus.isForceFree=!1}isPointInClippingRange(e,t=this.clippingTolerance){if(!this.isVector3Like(e))return!1;const n=this.getEffectiveClippingPlanes();return n.length===0?!0:n.every(i=>i.distanceToPoint(e)>=-t)}filterIntersectionsByClipping(e,t=this.clippingTolerance){return!Array.isArray(e)||e.length===0?[]:e.filter(n=>this.isPointInClippingRange(n?.point,t))}getEffectiveClippingPlanes(){const e=Array.isArray(this.engine.sectionPlane)?this.engine.sectionPlane:[];if(this.currentClippingMode==="box")return e.slice(0,6).filter(t=>t instanceof y.Plane);if(this.currentClippingMode==="x"||this.currentClippingMode==="y"||this.currentClippingMode==="z"||this.currentClippingMode==="face"){const t=e[6];return t instanceof y.Plane?[t]:[]}return[]}isVector3Like(e){return e!=null&&typeof e.x=="number"&&typeof e.y=="number"&&typeof e.z=="number"}setSectionByView(e,t){this.sectionFace.disActive(),this.sectionBox.disActive(),this.scaleBox(),this.sectionFace.init(!0);const n=this.engine.octreeBox.getBoundingBox(),i=new y.Vector3((n.min.x+n.max.x)/2,(n.min.y+n.max.y)/2,(n.min.z+n.max.z)/2),o=new y.Vector3(t.x,t.y,t.z).normalize().clone().negate(),l=new y.Vector3(e.x,e.y,e.z).clone().sub(i).dot(o);this.sectionFace.setFaceNormalPlaneOnly(o,l),this.sectionFace.activateClippingOnly(),this.currentClippingMode="face"}}class zy{engine;constructor(e){this.engine=e}getLevelTreeData(){let e=[];return this.engine.engineStatus.models.forEach(t=>{e.push({children:t.info.modelTree.modelTreeLevel,name:t.info.baseInfo.name,url:t.url})}),e}getTypeTreeData(){let e=[];return this.engine.engineStatus.models.forEach(t=>{e.push({children:t.info.modelTree.modelTreeType,name:t.info.baseInfo.name,url:t.url})}),e}getMajorTreeData(){let e=[];return this.engine.engineStatus.models.forEach(t=>{e.push({children:t.info.modelTree.modelTreeMajor,name:t.info.baseInfo.name,url:t.url})}),e}}class Vy{engine;constructor(e){this.engine=e}getEngineInfo(){let e=0,t=0,n=0;return!this.engine||!this.engine.scene?{totalVertices:0,totalTriangles:0,meshCount:0}:(this.engine.scene.traverse(i=>{if(i instanceof y.Mesh){const r=i.geometry;if(r&&r.attributes){const o=r.attributes.position;if(o){const a=o.count;e+=a;let l=0;r.index?l=r.index.count/3:l=a/3,t+=l}}}}),this.engine.engineStatus.models.forEach(i=>{n=n+(Array.isArray(i?.info?.modelEdge)?i.info.modelEdge.length:0)}),{totalVertices:Math.floor(e),totalTriangles:Math.floor(t),meshCount:n})}}class Gy{engine;constructor(e){this.engine=e}init(){}getModelPropertiesWithName(e,t,n,i){let r=this.engine.engineStatus.models.find(a=>a.url===e);r.properties==null?Es(e+"/property",a=>{let l=JSON.parse(a);r.properties=l,setTimeout(()=>{o(l,n,t,i)},100)}):o(r.properties,n,t,i);function o(a,l,c,h){let d={};a.models[c.toString()||""].forEach(u=>{n.includes(a.names[u[1]])&&(d[a.names[u[1]]]=a.values[u[2]])}),h?.({id:c,properties:d})}}getModelProperties(e,t,n){let i=this.engine.engineStatus.models.find(o=>o.url===e);i.properties==null&&Es(e+"/property",o=>{let a=JSON.parse(o);i.properties=a,setTimeout(()=>{r(a,t,n)},100)}),r(i.properties,t,n);function r(o,a,l){let c=[],h=o.models[a.toString()||""],d=h.map(g=>g[0]);d=d.filter((g,u)=>d.indexOf(g)===u),d.forEach(g=>{let u={name:o.categorys[g],children:[]};c.push(u),h.filter(m=>m[0]===g).forEach(m=>{u.children.push({name:o.names[m[1]],value:o.values[m[2]]})})}),l?.({properties:c,materials:c})}}}class Wy{engine;constructor(e){this.engine=e}getModelTypes(){let e=[];return this.engine.engineStatus.models.forEach(t=>{t.info.modelMapper.forEach(i=>{e.push(i.typeName)})}),e=e.filter((t,n,i)=>i.indexOf(t)===n),e}getModelMajors(){let e=[];return this.engine.engineStatus.models.forEach(t=>{t.info.modelMapper.forEach(i=>{e.push(i.majorName)})}),e=e.filter((t,n,i)=>i.indexOf(t)===n),e}getModelLevels(){let e=[];return this.engine.engineStatus.models.forEach(t=>{t.info.modelMapper.forEach(i=>{e.push(i.levelName)})}),e=e.filter((t,n,i)=>i.indexOf(t)===n),e}getModelMappers(e){}getModelMapper(e,t){let n=this.engine.engineStatus.models.find(o=>o.url==e);return n?n.info.modelMapper.find(o=>o.id==t):null}getModelsWithLevelType(e,t,n=null){let i=[];return this.engine.engineStatus.models.forEach(r=>{let o={url:r.url,ids:[]};i.push(o),r.info.modelMapper.filter(l=>l.levelName===e&&l.typeName===t).forEach(l=>{o.ids.push(Number(l.id))})}),n&&n(i),i}getModelsWithType(e,t=null){let n=[];return this.engine.engineStatus.models.forEach(i=>{let r={url:i.url,ids:[]};n.push(r),i.info.modelMapper.filter(a=>a.typeName===e).forEach(a=>{r.ids.push(Number(a.id))})}),t&&t(n),n}getModelsWithLevel(e,t){let n=[];return this.engine.engineStatus.models.forEach(i=>{let r={url:i.url,ids:[]};n.push(r),i.info.modelMapper.filter(a=>a.levelName===e).forEach(a=>{r.ids.push(Number(a.id))})}),t&&t(n),n}getModelsWithMajor(e,t){let n=[];return this.engine.engineStatus.models.forEach(i=>{let r={url:i.url,ids:[]};n.push(r),i.info.modelMapper.filter(a=>a.majorName===e).forEach(a=>{r.ids.push(Number(a.id))})}),t&&t(n),n}}class Hy{engine;isActive=!1;groupEdge;material;modelEdgeLoaded=!1;modelEdgeLoadingPromise=null;indexes=new Map;constructor(e){this.engine=e,this.groupEdge=this.engine.scene.getObjectByName("groupEdge"),this.material=new y.LineBasicMaterial({color:"#000000",depthTest:!0,transparent:!0,opacity:.3}),this.material.clippingPlanes=this.engine.sectionPlane}active(){this.isActive=!0,this.groupEdge.visible=!0,this.engine.scene.traverse(e=>{e.isMesh&&e.material&&(Array.isArray(e.material)?e.material:[e.material]).forEach(n=>{n.polygonOffset=!0,n.polygonOffsetFactor=1,n.polygonOffsetUnits=4})}),this.show()}disActive(){this.isActive=!1,this.groupEdge.visible=!1,this.engine.scene.traverse(e=>{e.isMesh&&e.material&&(Array.isArray(e.material)?e.material:[e.material]).forEach(n=>{n.polygonOffset=!1})})}hasPendingModelEdges(){return(this.engine?.engineStatus?.models??[]).some(t=>!this.indexes.has(t.url))}loadZipJsonAsync(e){return new Promise((t,n)=>{Es(e,i=>{if(i==null){n(new Error(`[ModelEdge] empty edge zip: ${e}`));return}t(i)},()=>{n(new Error(`[ModelEdge] failed to load edge zip: ${e}`))})})}async ensureModelEdgeData(e){const t=e?.info??{};if(Array.isArray(t.modelEdge))return t.modelEdge;try{const n=await this.loadZipJsonAsync(e.url+"/edge"),i=JSON.parse(n);t.modelEdge=Array.isArray(i)?i:[]}catch(n){console.error("[ModelEdge] failed to load model edge",{url:e?.url,error:n}),t.modelEdge=[]}return t.modelEdge}async loadModelEdge(){if(!(this.modelEdgeLoaded&&!this.hasPendingModelEdges())){if(this.modelEdgeLoadingPromise!=null){await this.modelEdgeLoadingPromise;return}this.modelEdgeLoadingPromise=(async()=>{const e=this.engine?.engineStatus?.models??[];for(const t of e){if(this.indexes.has(t.url))continue;const n=await this.ensureModelEdgeData(t),i=[],r=new Map;n.forEach(o=>{if(!Array.isArray(o?.points))return;const a=i.length;for(let l=0;l<o.points.length;l++)o.points[l]?.length===2&&(i.push(o.points[l][0].X),i.push(o.points[l][0].Z),i.push(-o.points[l][0].Y),i.push(o.points[l][1].X),i.push(o.points[l][1].Z),i.push(-o.points[l][1].Y));r.set(Number(o.id),[a,i.length,o.points])}),this.indexes.set(t.url,r)}this.modelEdgeLoaded=!this.hasPendingModelEdges()})().finally(()=>{this.modelEdgeLoadingPromise=null}),await this.modelEdgeLoadingPromise}}async show(){await this.loadModelEdge(),this.isActive&&this.indexes.forEach((e,t)=>{const n=this.groupEdge.children.find(a=>a.url==t);if(n){n.visible=!0;return}const i=[];if(e.forEach(a=>{a[2].forEach(l=>{l?.length===2&&(i.push(l[0].X),i.push(l[0].Z),i.push(-l[0].Y),i.push(l[1].X),i.push(l[1].Z),i.push(-l[1].Y))})}),i.length===0)return;const r=new y.BufferGeometry;r.setAttribute("position",new y.Float32BufferAttribute(i,3));const o=new y.LineSegments(r,this.material);o.url=t,this.groupEdge.add(o)})}getModelEdge(e,t){const n=this.indexes.get(e);if(n){const i=n.get(Number(t));if(i)return i.slice()}return this.loadModelEdge(),null}hideModelEdge(e,t){const n=this.indexes.get(e);if(!n){this.loadModelEdge();return}const i=n.get(Number(t));if(i){const[r,o]=i,a=this.groupEdge.children.find(l=>l.url==e);if(a){const l=a.geometry.attributes.position.array;for(let c=r;c<o;c++)l[c]=NaN;a.geometry.attributes.position.needsUpdate=!0}}}setOpacity(e){this.material.opacity=e}showModelEdge(e,t){const n=this.indexes.get(e);if(!n){this.loadModelEdge();return}const i=n.get(Number(t));if(i){const[r,o,a]=i,l=this.groupEdge.children.find(c=>c.url==e);if(l){const c=l.geometry.attributes.position.array;let h=0;for(let d=r;d<o;d+=3){const g=Math.floor(h/6),u=h%6>=3;if(a[g]&&a[g].length===2){const m=u?a[g][1]:a[g][0];c[d]=m.X,c[d+1]=m.Z,c[d+2]=-m.Y}h+=3}l.geometry.attributes.position.needsUpdate=!0}}}}class Xy{config;constructor(e){this.config={temperature:.7,maxTokens:2e4,timeout:3e5,...e}}async chat(e){const t=new AbortController,n=setTimeout(()=>t.abort(),this.config.timeout);try{const i=await fetch(`${this.config.baseURL}/chat/completions`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.config.apiKey}`},body:JSON.stringify({model:this.config.model,messages:e,temperature:this.config.temperature,max_tokens:this.config.maxTokens,stream:!1}),signal:t.signal});if(clearTimeout(n),!i.ok){const o=await i.json().catch(()=>({}));throw new Error(`API请求失败 (${i.status}): ${o.error?.message||o.message||i.statusText}`)}return(await i.json()).choices?.[0]?.message?.content||""}catch(i){throw clearTimeout(n),i.name==="AbortError"?new Error("请求超时,请重试"):i.message.includes("Failed to fetch")?new Error(`网络请求失败,请检查:
|
|
4944
|
+
`;continue}if((z=V.match(T))&&(w.gamma=parseFloat(z[1])),(z=V.match(U))&&(w.exposure=parseFloat(z[1])),(z=V.match(D))&&(w.valid|=2,w.format=z[1]),(z=V.match(O))&&(w.valid|=4,w.height=parseInt(z[1],10),w.width=parseInt(z[2],10)),w.valid&2&&w.valid&4)break}return w.valid&2||o(3,"missing format specifier"),w.valid&4||o(3,"missing image size specifier"),w},u=function(I,E,T){const U=E;if(U<8||U>32767||I[0]!==2||I[1]!==2||I[2]&128)return new Uint8Array(I);U!==(I[2]<<8|I[3])&&o(3,"wrong scanline width");const D=new Uint8Array(4*E*T);D.length||o(4,"unable to allocate buffer space");let O=0,w=0;const V=4*U,z=new Uint8Array(4),H=new Uint8Array(V);let Y=T;for(;Y>0&&w<I.byteLength;){w+4>I.byteLength&&o(1),z[0]=I[w++],z[1]=I[w++],z[2]=I[w++],z[3]=I[w++],(z[0]!=2||z[1]!=2||(z[2]<<8|z[3])!=U)&&o(3,"bad rgbe scanline format");let W=0,Q;for(;W<V&&w<I.byteLength;){Q=I[w++];const j=Q>128;if(j&&(Q-=128),(Q===0||W+Q>V)&&o(3,"bad scanline data"),j){const me=I[w++];for(let ge=0;ge<Q;ge++)H[W++]=me}else H.set(I.subarray(w,w+Q),W),W+=Q,w+=Q}const X=U;for(let j=0;j<X;j++){let me=0;D[O]=H[j+me],me+=U,D[O+1]=H[j+me],me+=U,D[O+2]=H[j+me],me+=U,D[O+3]=H[j+me],O+=4}Y--}return D},m=function(I,E,T,U){const D=I[E+3],O=Math.pow(2,D-128)/255;T[U+0]=I[E+0]*O,T[U+1]=I[E+1]*O,T[U+2]=I[E+2]*O,T[U+3]=1},f=function(I,E,T,U){const D=I[E+3],O=Math.pow(2,D-128)/255;T[U+0]=M.DataUtils.toHalfFloat(Math.min(I[E+0]*O,65504)),T[U+1]=M.DataUtils.toHalfFloat(Math.min(I[E+1]*O,65504)),T[U+2]=M.DataUtils.toHalfFloat(Math.min(I[E+2]*O,65504)),T[U+3]=M.DataUtils.toHalfFloat(1)},p=new Uint8Array(e);p.pos=0;const x=g(p),v=x.width,_=x.height,b=u(p.subarray(p.pos),v,_);let S,C,R;switch(this.type){case M.FloatType:R=b.length/4;const I=new Float32Array(R*4);for(let T=0;T<R;T++)m(b,T*4,I,T*4);S=I,C=M.FloatType;break;case M.HalfFloatType:R=b.length/4;const E=new Uint16Array(R*4);for(let T=0;T<R;T++)f(b,T*4,E,T*4);S=E,C=M.HalfFloatType;break;default:throw new Error("THREE.HDRLoader: Unsupported type: "+this.type)}return{width:v,height:_,data:S,header:x.string,gamma:x.gamma,exposure:x.exposure,type:C}}setDataType(e){return this.type=e,this}load(e,t,n,i){function r(o,a){switch(o.type){case M.FloatType:case M.HalfFloatType:o.colorSpace=M.LinearSRGBColorSpace,o.minFilter=M.LinearFilter,o.magFilter=M.LinearFilter,o.generateMipmaps=!1,o.flipY=!0;break}t&&t(o,a)}return super.load(e,r,n,i)}}function yy(){return new y.Scene}function My(s,e){s.appendChild(e.domElement)}function by(s,e,t){var n=new Object;n.visible=!0;let i=null,r,o,a=[];n.init=function(){r||(c(),h(),f())},n.Hide=function(){r.style.display="none",n.visible=!1},n.Show=function(){r.style.display="block",n.visible=!0},n.RenderScene=function(){if(!d){n.camera.quaternion.copy(e.camera.quaternion);const v=new y.Vector3(0,0,1).applyQuaternion(e.camera.quaternion);n.camera.position.copy(v.multiplyScalar(100))}n.orbitControls&&n.orbitControls.update(),n.sceneOrtho.renderer.render(n.sceneOrtho,n.camera)},n.ToggleDirectionView=function(v){var _=new y.Vector3(0,0,0);v=="top"?_=new y.Vector3(0,1,1e-5):v=="down"?_=new y.Vector3(0,-1,1e-5):v=="front"?_=new y.Vector3(0,0,1):v=="left"?_=new y.Vector3(-1,0,0):v=="back"?_=new y.Vector3(0,0,-1):v=="right"?_=new y.Vector3(1,0,0):v=="top_front"?_=new y.Vector3(1,1,0):v=="top_left"?_=new y.Vector3(0,1,-1):v=="top_back"?_=new y.Vector3(-1,1,0):v=="top_right"?_=new y.Vector3(0,1,1):v=="down_front"?_=new y.Vector3(1,-1,0):v=="down_left"?_=new y.Vector3(0,-1,-1):v=="down_back"?_=new y.Vector3(-1,-1,0):v=="down_right"?_=new y.Vector3(0,-1,1):v=="front_right"?_=new y.Vector3(1,0,1):v=="right_back"?_=new y.Vector3(-1,0,1):v=="back_left"?_=new y.Vector3(-1,0,-1):v=="left_front"?_=new y.Vector3(1,0,-1):v=="top_left_front"?_=new y.Vector3(1,1,-1):v=="top_front_right"?_=new y.Vector3(1,1,1):v=="top_right_back"?_=new y.Vector3(-1,1,1):v=="top_back_left"?_=new y.Vector3(-1,1,-1):v=="button_left_front"?_=new y.Vector3(1,-1,-1):v=="button_front_right"?_=new y.Vector3(1,-1,1):v=="button_right_back"?_=new y.Vector3(-1,1,1):v=="button_back_left"&&(_=new y.Vector3(-1,-1,-1));var b=s.octreeBox.getBoundingBox(),S=b.min,C=b.max,R=S.clone().add(C.clone()).multiplyScalar(.5),I=R.clone().add(_.multiplyScalar(1*C.distanceTo(S)));l(e.camera.position,I,s.controls.target.clone(),R)},n.GetCameraPose=function(){var v=e.camera.quaternion,_=e.camera.position,b=s.controls.target,S={quaternion:v,position:_,target:b};return S},n.ReductionCameraPose=function(v,_=1e3,b){var S=new y.Quaternion(v.quaternion._x,v.quaternion._y,v.quaternion._z,v.quaternion._w),C=new y.Vector3(v.position.x,v.position.y,v.position.z),R=new y.Vector3(v.target.x,v.target.y,v.target.z);let I=!1;l(e.camera.position,C,s.controls.target.clone(),R,e.camera.quaternion,S,_,E=>{b&&(I||(b(E),I=!0))}),b&&setTimeout(()=>{I||(b(!0),I=!0)},_+10)},n.CameraGoHome=function(v=1e3){var _=s.octreeBox.getBoundingBox(),b=_.min.clone().add(_.max.clone()).multiplyScalar(.5);let S=new y.Vector3(1,1,1);var C=_.max.distanceTo(_.min),R=b.clone().add(S.multiplyScalar(C*2));if(s.camera.far=C*5,e.camera.isOrthographicCamera){var I=s.container.clientWidth/s.container.clientHeight,E=C*.6;e.camera.left=-E*I,e.camera.right=E*I,e.camera.top=E,e.camera.bottom=-E,e.camera.zoom=1,e.camera.updateProjectionMatrix()}s.controlModule.orbitControls.origin=b.clone(),l(e.camera.position,R,s.controls.target.clone(),b,null,null,v)},n.zoomToBox=function(v){if(e.camera.isOrthographicCamera){let se=function(){i=requestAnimationFrame(se),ue.update()};var _=v.min.clone().add(v.max.clone()).multiplyScalar(.5),b=e.camera.position.clone().sub(s.controls.target.clone()).normalize(),S=e.camera.position.distanceTo(s.controls.target),C=_.clone().add(b.multiplyScalar(S)),R=e.camera.zoom,I=new y.Vector3(1,0,0).applyQuaternion(e.camera.quaternion),E=new y.Vector3(0,1,0).applyQuaternion(e.camera.quaternion),T=[new y.Vector3(v.min.x,v.min.y,v.min.z),new y.Vector3(v.max.x,v.min.y,v.min.z),new y.Vector3(v.min.x,v.max.y,v.min.z),new y.Vector3(v.max.x,v.max.y,v.min.z),new y.Vector3(v.min.x,v.min.y,v.max.z),new y.Vector3(v.max.x,v.min.y,v.max.z),new y.Vector3(v.min.x,v.max.y,v.max.z),new y.Vector3(v.max.x,v.max.y,v.max.z)],U=1/0,D=-1/0,O=1/0,w=-1/0;for(var V of T){var z=V.dot(I),H=V.dot(E);U=Math.min(U,z),D=Math.max(D,z),O=Math.min(O,H),w=Math.max(w,H)}var Y=(D-U)/2,W=(w-O)/2,Q=(e.camera.right-e.camera.left)/2,X=(e.camera.top-e.camera.bottom)/2;R=Math.min(Q/Y,X/W)*.75;var j=e.camera.position.clone(),me=s.controls.target.clone(),ge=e.camera.zoom,ue=new Ds.Tween({x1:j.x,y1:j.y,z1:j.z,x2:me.x,y2:me.y,z2:me.z,zoom:ge}).to({x1:C.x,y1:C.y,z1:C.z,x2:_.x,y2:_.y,z2:_.z,zoom:R},1e3);ue.onUpdate(function(le){s.controls&&(e.camera.position.set(le.x1,le.y1,le.z1),s.controls.target.set(le.x2,le.y2,le.z2),e.camera.isOrthographicCamera&&(e.camera.zoom=le.zoom,e.camera.updateProjectionMatrix()),s.controls.auto=!0,s.controls.update(),n.RenderScene())}),ue.onComplete(function(){s.controls&&(s.controls.auto=!1,n.RenderScene(),cancelAnimationFrame(i),i=null)}),ue.easing(Ds.Easing.Cubic.InOut),ue.start(),se()}else{var _=v.min.clone().add(v.max.clone()).multiplyScalar(.5);let xe=e.camera.position.clone().sub(s.controls.target.clone()).normalize();var C=_.clone().add(xe.multiplyScalar(2*v.max.distanceTo(v.min)));l(e.camera.position,C,s.controls.target.clone(),_)}};function l(v,_,b,S,C,R,I=1e3,E){var T;C&&R?(T=new Ds.Tween({x1:v.x,y1:v.y,z1:v.z,x2:b.x,y2:b.y,z2:b.z,_x:C._x,_y:C._y,_z:C._z,_w:C._w}),T.to({x1:_.x,y1:_.y,z1:_.z,x2:S.x,y2:S.y,z2:S.z,_x:R._x,_y:R._y,_z:R._z,_w:R._w},I)):(T=new Ds.Tween({x1:v.x,y1:v.y,z1:v.z,x2:b.x,y2:b.y,z2:b.z}),T.to({x1:_.x,y1:_.y,z1:_.z,x2:S.x,y2:S.y,z2:S.z},I)),T.onUpdate(function(D){s.controls&&(C&&R?(e.camera.quaternion._x=D._x,e.camera.quaternion._y=D._y,e.camera.quaternion._z=D._z,e.camera.quaternion._w=D._w):s.controls.auto=!0,e.camera.position.x=D.x1,e.camera.position.y=D.y1,e.camera.position.z=D.z1,s.controls.target.x=D.x2,s.controls.target.y=D.y2,s.controls.target.z=D.z2,s.controls.update(),n.RenderScene())}),T.onComplete(function(D){s.controls&&(s.controls.auto=!1,n.RenderScene(),E&&E(!0),cancelAnimationFrame(i),i=null)}),T.easing(Ds.Easing.Cubic.InOut);function U(D){i=requestAnimationFrame(U),T.update()}T.start(),U()}function c(){r=document.createElement("div"),r.className="ViewCube",t.appendChild(r),o=document.createElement("div"),o.className="viewSettingWrapper",o.innerHTML="...",r.appendChild(o);var v=document.createElement("div");v.className="homeViewWrapper",v.addEventListener("mousedown",function(){console.log("归位"),n.CameraGoHome()}),r.appendChild(v);const _=document.createElement("div");_.className="cameraToggleWrapper",_.title="切换正交/透视视图",_.innerHTML="⊞",_.addEventListener("mousedown",function(I){I.stopPropagation(),console.log("切换视图"),n.ToggleCameraType(),C()}),r.appendChild(_);const b=document.createElement("div");b.className="screenshotWrapper",b.title="截图",b.innerHTML="📷",b.addEventListener("mousedown",function(I){I.stopPropagation(),console.log("截图"),n.TakeScreenshot(),C()}),r.appendChild(b);const S=document.createElement("div");S.className="fullscreenWrapper",S.title="全屏",S.innerHTML="⛶",S.addEventListener("mousedown",function(I){I.stopPropagation(),console.log("全屏"),n.ToggleFullscreen(),C()}),r.appendChild(S),o.addEventListener("mousedown",function(I){I.stopPropagation(),_.classList.contains("show")?(C(),console.log("隐藏功能按钮")):(R(),console.log("显示功能按钮"))});function C(){_.classList.remove("show"),b.classList.remove("show"),S.classList.remove("show")}function R(){_.classList.add("show"),b.classList.add("show"),S.classList.add("show")}}function h(){n.sceneOrtho=yy();var b=t.clientWidth,S=t.clientWidth,v=b>S?b/S:S/b,_=300;n.camera=new y.OrthographicCamera(_*v/-2,_*v/2,_/2,_/-2,.01,1e4);var b=r.clientWidth,S=r.clientHeight,C=new y.WebGLRenderer({alpha:!0});C.setSize(b,S),C.setClearAlpha(0),n.sceneOrtho.renderer=C;let R=new y.AmbientLight(16777215,.8);n.sceneOrtho.add(R),My(r,C),n.orbitControls=new J_(n.camera,r),n.orbitControls.enableZoom=!1,n.orbitControls.enablePan=!1,n.orbitControls.enableDamping=!0,n.orbitControls.dampingFactor=.1,n.orbitControls.rotateSpeed=.5,n.orbitControls.addEventListener("start",g),n.orbitControls.addEventListener("change",u),n.orbitControls.addEventListener("end",m)}let d=!1;function g(){d=!0,s.controls&&(n._mainTarget=s.controls.target.clone(),n._mainDistance=e.camera.position.distanceTo(s.controls.target))}function u(){if(d){if(e.camera.quaternion.copy(n.camera.quaternion),s.controls&&n._mainTarget&&n._mainDistance){const v=new y.Vector3(0,0,1).applyQuaternion(e.camera.quaternion);e.camera.position.copy(n._mainTarget.clone().add(v.multiplyScalar(n._mainDistance))),s.controls.update()}s.renderer&&e.camera&&s.renderer.render(e,e.camera)}}function m(){d=!1,n._mainTarget=null,n._mainDistance=null}function f(){const v="/assets/viewcube/";let _=[{label:"右",icon:v+"cn_right.png"},{label:"左",icon:v+"cn_left.png"},{label:"顶",icon:v+"cn_top.png"},{label:"底",icon:v+"cn_bottom.png"},{label:"前",icon:v+"cn_front.png"},{label:"后",icon:v+"cn_back.png"}];var b=[];for(const R of _)b.push(new y.MeshBasicMaterial({color:16777215,map:new y.TextureLoader().load(R.icon)}));new y.MeshLambertMaterial({color:255});var S=new y.Mesh(new y.BoxGeometry(110,110,110),b);n.sceneOrtho.add(S),p(122);let C={x:0,y:0};r.addEventListener("mousedown",R=>{C.x=R.clientX,C.y=R.clientY}),r.addEventListener("mouseup",R=>{if(d)return;const I=R.clientX-C.x,E=R.clientY-C.y;if(Math.sqrt(I*I+E*E)>5)return;var U={};U.x=R.offsetX/r.clientWidth*2-1,U.y=-(R.offsetY/r.clientHeight)*2+1;var D=new y.Raycaster;D.setFromCamera(U,n.camera);const O=D.intersectObjects(a,!1);O.length>0&&n.ToggleDirectionView(O[0].object.name)}),r.addEventListener("mousemove",R=>{var I={};I.x=R.offsetX/r.clientWidth*2-1,I.y=-(R.offsetY/r.clientHeight)*2+1;var E=new y.Raycaster;E.setFromCamera(I,n.camera);const T=E.intersectObjects(a,!1);for(var U of a)U.material.opacity=.01;T.length>0&&(T[0].object.material.opacity=.2)})}function p(v){for(var _=v*.5-20,b=[{name:"right",a:30,b:75,c:75,point:new y.Vector3(_,0,0)},{name:"back",a:75,b:75,c:30,point:new y.Vector3(0,0,-_)},{name:"left",a:30,b:75,c:75,point:new y.Vector3(-_,0,0)},{name:"front",a:75,b:75,c:30,point:new y.Vector3(0,0,_)},{name:"top",a:75,b:30,c:75,point:new y.Vector3(0,_,0)},{name:"button",a:75,b:30,c:75,point:new y.Vector3(0,-_,0)}],S=[{name:"top_right_back",a:30,b:30,c:30,point:new y.Vector3(-_,_,_)},{name:"button_front_right",a:30,b:30,c:30,point:new y.Vector3(-_,-_,_)},{name:"top_front_right",a:30,b:30,c:30,point:new y.Vector3(_,_,_)},{name:"button_right_back",a:30,b:30,c:30,point:new y.Vector3(_,-_,_)},{name:"top_back_left",a:30,b:30,c:30,point:new y.Vector3(-_,_,-_)},{name:"button_back_left",a:30,b:30,c:30,point:new y.Vector3(-_,-_,-_)},{name:"top_left_front",a:30,b:30,c:30,point:new y.Vector3(_,_,-_)},{name:"button_left_front",a:30,b:30,c:30,point:new y.Vector3(_,-_,-_)}],C=[{name:"top_front",a:30,b:30,c:75,point:new y.Vector3(_,_,0)},{name:"top_right",a:75,b:30,c:30,point:new y.Vector3(0,_,_)},{name:"top_back",a:30,b:30,c:75,point:new y.Vector3(-_,_,0)},{name:"top_left",a:75,b:30,c:30,point:new y.Vector3(0,_,-_)},{name:"button_front",a:30,b:30,c:75,point:new y.Vector3(_,-_,0)},{name:"button_right",a:75,b:30,c:30,point:new y.Vector3(0,-_,_)},{name:"button_back",a:30,b:30,c:75,point:new y.Vector3(-_,-_,0)},{name:"button_left",a:75,b:30,c:30,point:new y.Vector3(0,-_,-_)},{name:"front_right",a:30,b:75,c:30,point:new y.Vector3(_,0,_)},{name:"right_back",a:30,b:75,c:30,point:new y.Vector3(-_,0,_)},{name:"back_left",a:30,b:75,c:30,point:new y.Vector3(-_,0,-_)},{name:"left_front",a:30,b:75,c:30,point:new y.Vector3(_,0,-_)}],R=0;R<b.length;R++)a.push(x(b[R]));for(var R=0;R<S.length;R++)a.push(x(S[R]));for(var R=0;R<C.length;R++)a.push(x(C[R]))}function x(v){const _=new y.BoxGeometry(v.a,v.b,v.c),b=new y.MeshBasicMaterial({color:"blue",transparent:!0,opacity:.01}),S=new y.Matrix4().makeTranslation(v.point.x,v.point.y,v.point.z);let C=_.applyMatrix4(S),R=new y.Mesh(C,b);return R.name=v.name,n.sceneOrtho.add(R),R}return n.ToggleCameraType=function(){s.cameraModule.switchCurrentCamera()},n.TakeScreenshot=function(){try{if(!s.renderer){console.error("渲染器未初始化");return}s.renderer.render(e,e.camera);const _=s.renderer.domElement.toDataURL("image/png"),b=document.createElement("a"),S=new Date().toISOString().replaceAll(/[:.]/g,"-");b.download=`screenshot_${S}.png`,b.href=_,b.click(),console.log("截图已保存")}catch(v){console.error("截图失败:",v)}},n.ToggleFullscreen=function(){const v=t||document.documentElement;!document.fullscreenElement&&!document.webkitFullscreenElement&&!document.mozFullScreenElement&&!document.msFullscreenElement?(v.requestFullscreen?v.requestFullscreen():v.webkitRequestFullscreen?v.webkitRequestFullscreen():v.mozRequestFullScreen?v.mozRequestFullScreen():v.msRequestFullscreen&&v.msRequestFullscreen(),console.log("已进入全屏模式")):(document.exitFullscreen?document.exitFullscreen():document.webkitExitFullscreen?document.webkitExitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.msExitFullscreen&&document.msExitFullscreen(),console.log("已退出全屏模式"))},n}class wy{engine;cubeTool;constructor(e){this.engine=e}init(){this.cubeTool=by(this.engine,this.engine.scene,this.engine.container),this.cubeTool.init()}CameraGoHome(e){this.cubeTool.CameraGoHome(e)}zoomToModel(e){this.cubeTool.zoomToBox(e)}zoomToModels(e){try{let t=this.engine.models.find(n=>n.url==e.url);this.cubeTool.zoomToBox(t.nodesMap.get(e.id).infos[0].box)}catch{}}hide(){}}function Sy(s){let e=new Object;return e.getBoundingBox=function(){let t=s.models,n=new y.Vector3(1e8,1e9,1e10),i=new y.Vector3(-1e8,-1e9,-1e10);t.forEach(d=>{let g=new y.Vector3(Math.min(d.boundingBox.min.x,d.boundingBox.max.x),Math.min(d.boundingBox.min.y,d.boundingBox.max.y),Math.min(d.boundingBox.min.z,d.boundingBox.max.z)),u=new y.Vector3(Math.max(d.boundingBox.min.x,d.boundingBox.max.x),Math.max(d.boundingBox.min.y,d.boundingBox.max.y),Math.max(d.boundingBox.min.z,d.boundingBox.max.z));g.x<n.x&&(n.x=g.x),g.y<n.y&&(n.y=g.y),g.z<n.z&&(n.z=g.z),u.x>i.x&&(i.x=u.x),u.y>i.y&&(i.y=u.y),u.z>i.z&&(i.z=u.z)});let r=Math.min(n.x,i.x),o=Math.min(n.y,i.y),a=Math.min(n.z,i.z),l=Math.max(n.x,i.x),c=Math.max(n.y,i.y),h=Math.max(n.z,i.z);return{min:new y.Vector3(r,o,a),max:new y.Vector3(l,c,h)}},e.rayInterationModel=function(t,n){let i=[];return s.engineStatus.models.forEach(a=>{a.info.lods.forEach(l=>{let c=l.octreeBox;o(t,c,a)})}),i=i.filter(a=>a instanceof y.Mesh),i=i.filter(a=>t.ray.intersectsBox(new y.Box3().setFromObject(a),!1)==!0),t.intersectObjects(i,!1);function o(a,l,c){if(l==null)return;let h=new y.Vector3(l.min.X*.3048,l.min.Z*.3048,-l.min.Y*.3048),d=new y.Vector3(l.max.X*.3048,l.max.Z*.3048,-l.max.Y*.3048),g=new y.Vector3(Math.min(h.x,d.X),Math.min(h.y,d.y),Math.min(h.z,d.z)),u=new y.Vector3(Math.max(d.x,h.x),Math.max(d.y,h.y),Math.max(d.z,h.z)),m=new y.Box3(g,u),f=a.ray.intersectsBox(m);if(!(f==null||f==!1))if(l.children==null||l.children.length==0){if(l.elements!=null)for(var p of l.elements){if(!s.engineStatus.isFree&&n==!1)continue;let x=s.engineStatus.hideModels.find(S=>S.url==c.url)?.ids;if(x!=null&&x.includes(p))continue;let v=s.engineStatus.translucentModels.find(S=>S.url==c.url)?.ids;if(v!=null&&v.includes(p))continue;let b=s.models.find(S=>S.url==c.url).nodesMap.get(p);b!=null&&!b.instance&&b.infos!=null&&b.infos.map(C=>C.mesh).forEach(C=>{i.push(C)})}}else{if(l.elements!=null)for(var p of l.elements){let v=s.engineStatus.hideModels.find(C=>C.url==c.url)?.ids;if(v!=null&&v.includes(p))continue;let _=s.engineStatus.translucentModels.find(C=>C.url==c.url)?.ids;if(_!=null&&_.includes(p))continue;let S=s.models.find(C=>C.url==c.url).nodesMap.get(p);S!=null&&!S.instance&&S.infos!=null&&S.infos.map(R=>R.mesh).forEach(R=>{i.push(R)})}for(let x of l.children)o(a,x,c)}}},e}class Ey{engine;isDrawing=!1;startPoint=new y.Vector2;endPoint=new y.Vector2;selectionBox=null;worldToScreen=null;boundMouseDown;boundMouseMove;boundMouseUp;boundKeyDown;constructor(e){this.engine=e,this.boundMouseDown=this.onMouseDown.bind(this),this.boundMouseMove=this.onMouseMove.bind(this),this.boundMouseUp=this.onMouseUp.bind(this),this.boundKeyDown=this.onKeyDown.bind(this)}init(){this.createSelectionBoxElement(),this.engine.scene&&this.engine.camera&&this.engine.renderer&&(this.worldToScreen=new it(this.engine.camera,this.engine.renderer,this.engine.scene))}active(){this.engine.controlModule.disActive();const e=this.engine.renderer?.domElement;e&&(e.addEventListener("mousedown",this.boundMouseDown),e.addEventListener("mousemove",this.boundMouseMove),e.addEventListener("mouseup",this.boundMouseUp),e.style.cursor="crosshair"),window.addEventListener("keydown",this.boundKeyDown)}disActive(){this.engine.controlModule.active();const e=this.engine.renderer?.domElement;e&&(e.removeEventListener("mousedown",this.boundMouseDown),e.removeEventListener("mousemove",this.boundMouseMove),e.removeEventListener("mouseup",this.boundMouseUp),e.style.cursor="default"),window.removeEventListener("keydown",this.boundKeyDown),this.isDrawing&&this.endDrawing()}createSelectionBoxElement(){this.selectionBox=document.createElement("div"),this.selectionBox.style.position="absolute",this.selectionBox.style.border="2px dashed #00aaff",this.selectionBox.style.backgroundColor="rgba(0, 170, 255, 0.1)",this.selectionBox.style.pointerEvents="none",this.selectionBox.style.display="none",this.selectionBox.style.zIndex="1000",this.selectionBox.style.boxSizing="border-box";const e=this.engine.renderer?.domElement;e&&e.parentElement&&e.parentElement.appendChild(this.selectionBox)}onMouseDown(e){e.button!==0||!this.engine.renderer?.domElement||(this.startPoint.set(e.offsetX,e.offsetY),this.endPoint.copy(this.startPoint),this.isDrawing=!0,this.selectionBox&&(this.selectionBox.style.display="block",this.updateSelectionBoxUI()),e.preventDefault(),e.stopPropagation())}onMouseMove(e){!this.isDrawing||!this.engine.renderer?.domElement||(this.endPoint.set(e.offsetX,e.offsetY),this.updateSelectionBoxUI(),e.preventDefault(),e.stopPropagation())}onMouseUp(e){this.isDrawing&&(this.endDrawing(),this.performZoom(),e.preventDefault(),e.stopPropagation(),this.disActive())}onKeyDown(e){e.key==="Escape"&&(this.disActive(),e.preventDefault(),e.stopPropagation())}endDrawing(){this.isDrawing&&(this.isDrawing=!1,this.selectionBox&&(this.selectionBox.style.display="none"))}updateSelectionBoxUI(){if(!this.selectionBox||!this.engine.renderer?.domElement)return;const t=Math.min(this.startPoint.x,this.endPoint.x),n=Math.min(this.startPoint.y,this.endPoint.y),i=Math.abs(this.endPoint.x-this.startPoint.x),r=Math.abs(this.endPoint.y-this.startPoint.y);this.selectionBox.style.left=`${t}px`,this.selectionBox.style.top=`${n}px`,this.selectionBox.style.width=`${i}px`,this.selectionBox.style.height=`${r}px`}performZoom(){const e=Math.abs(this.endPoint.x-this.startPoint.x),t=Math.abs(this.endPoint.y-this.startPoint.y);if(e<5||t<5)return;if(!this.worldToScreen){console.warn("RangeScale: 坐标转换工具未初始化");return}const n=Math.min(this.startPoint.x,this.endPoint.x),i=Math.max(this.startPoint.x,this.endPoint.x),r=Math.min(this.startPoint.y,this.endPoint.y),o=Math.max(this.startPoint.y,this.endPoint.y),a=[],l=[{x:n,y:r},{x:i,y:r},{x:i,y:o},{x:n,y:o}];for(const h of l){const d=this.worldToScreen.screenToWorld(h.x,h.y);d&&a.push(d)}if(a.length<3){console.warn("RangeScale: 框选区域未命中模型,无法执行缩放操作");return}if(a.length<3){console.warn("RangeScale: 无法将屏幕区域转换为世界坐标");return}const c=new y.Box3;for(const h of a)c.expandByPoint(h);if(c.isEmpty()){console.warn("RangeScale: 计算得到的包围盒无效");return}this.fitCameraToBoundingBox(c)}fitCameraToBoundingBox(e){const t=this.engine.camera,n=this.engine.controls;if(!t||!n){console.warn("RangeScale: 相机或控制器未初始化");return}const i=new y.Vector3;e.getCenter(i);const r=new y.Vector3;e.getSize(r);const o=Math.max(r.x,r.y,r.z);if(t instanceof y.PerspectiveCamera){const a=t.fov*(Math.PI/180),c=o/(2*Math.tan(a/2))*1.2,h=new y.Vector3;t.getWorldDirection(h);const d=i.clone().sub(t.position);h.dot(d.normalize())<0&&h.negate();const u=i.clone().sub(h.multiplyScalar(c));t.position.copy(u),n.target&&n.target.copy(i),t.lookAt(i),n.update()}else if(t instanceof y.OrthographicCamera){const l=o*1.2,c=this.engine.renderer?.domElement,h=c?c.width/c.height:1;t.left=-l*h/2,t.right=l*h/2,t.top=l/2,t.bottom=-l/2,t.updateProjectionMatrix();const d=new y.Vector3;t.getWorldDirection(d);const g=o*1.5,u=i.clone().sub(d.multiplyScalar(g));t.position.copy(u),n.target&&n.target.copy(i),t.lookAt(i),n.update()}}}const fd={render:{mode:"advanced",contrast:50,saturation:50,shadowIntensity:50,lightIntensity:50,gtaoIntensity:50},display:{showEdge:!1,edgeOpacity:30,showGrid:!1,showLevel:!1,showGround:!1,groundId:"0",groundHeight:0},environment:{type:"none",hdrId:"0",hdrIntensity:20,skyPreset:"sunrise_clear",skyParams:{},skyIntensity:20}};class Cy{engine;settings;environmentApplyVersion=0;constructor(e){this.engine=e,this.settings=this._clone(fd)}init(){}getSettings(){return this._clone(this.settings)}getPresetLists(){const e=this.engine.ground?.getGroundList()||[],t=this.engine.hdr?.getHdrList()||[],n=this.engine.skyManager?.getPresetList()||[];return{ground:e.map(i=>this._toPresetItem(i)),hdr:t.map(i=>this._toPresetItem(i)),sky:n.map(i=>this._toPresetItem(i))}}async setSettings(e){e.render&&(Object.assign(this.settings.render,e.render),this._applyRenderSettings(this.settings.render)),e.display&&(Object.assign(this.settings.display,e.display),this._applyDisplaySettings(this.settings.display)),e.environment&&(this._mergeEnvironmentSettings(e.environment),await this._applyEnvironmentSettings(this._clone(this.settings.environment)))}async resetToDefault(){this.settings=this._clone(fd),this._applyRenderSettings(this.settings.render),this._applyDisplaySettings(this.settings.display),await this._applyEnvironmentSettings(this._clone(this.settings.environment))}setRenderMode(e){this.settings.render.mode=e,this.engine.engineModelModule?.switchModel(e)}setContrast(e){this.settings.render.contrast=e,this.engine.engineModelModule?.setContrastValue(.5+e/100)}setSaturation(e){this.settings.render.saturation=e,this.engine.engineModelModule?.setSaturationValue(.5+e/100)}setShadowIntensity(e){this.settings.render.shadowIntensity=e,this._updateDirectionalLight(t=>{t.shadow.intensity=e/100*2})}setLightIntensity(e){this.settings.render.lightIntensity=e,this.setAmbientLightIntensity(e/100)}setGTAOIntensity(e){this.settings.render.gtaoIntensity=e,this.engine.engineModelModule?.setGTAOIntensity(e/100)}setShowEdge(e){this.settings.display.showEdge=e,e?this.engine.modelEdge?.active():this.engine.modelEdge?.disActive()}setEdgeOpacity(e){this.settings.display.edgeOpacity=e,this.engine.modelEdge?.setOpacity(e/100)}setShowGrid(e){this.settings.display.showGrid=e,e?this.engine.grid?.show():this.engine.grid?.hide()}setShowLevel(e){this.settings.display.showLevel=e,e?this.engine.level?.show():this.engine.level?.hide()}setShowGround(e){this.settings.display.showGround=e,e?this.engine.ground?.show():this.engine.ground?.hide()}setGroundId(e){this.settings.display.groundId=e,this.engine.ground?.setGround(e)}setGroundHeight(e){this.settings.display.groundHeight=e,this.engine.ground?.setHeight(e)}async setEnvironmentType(e){this.settings.environment.type=e,await this._applyEnvironmentSettings(this._clone(this.settings.environment))}async setHdrId(e){this.settings.environment.hdrId=e,this.settings.environment.type==="hdr"&&await this._applyEnvironmentSettings(this._clone(this.settings.environment))}setHdrIntensity(e){this.settings.environment.hdrIntensity=e,this.settings.environment.type==="hdr"&&this.engine.hdr?.setIntensity(e/100)}setSkyPreset(e){this.settings.environment.skyPreset=e,this.settings.environment.skyParams={},this.settings.environment.type==="sky"&&this.engine.skyManager?.setPreset(e)}setSkyParams(e){this.settings.environment.skyParams=this._clone(e),this.settings.environment.type==="sky"&&this.engine.skyManager?.setParams(this.settings.environment.skyParams)}setSkyIntensity(e){this.settings.environment.skyIntensity=e,this.settings.environment.type==="sky"&&this.engine.skyManager?.setIntensity(e/100)}setAmbientLightIntensity(e){const t=this.engine.scene?.children.find(n=>n instanceof y.AmbientLight);t&&(t.intensity=e)}_applyRenderSettings(e){this.setRenderMode(e.mode),this.setContrast(e.contrast),this.setSaturation(e.saturation),this.setShadowIntensity(e.shadowIntensity),this.setLightIntensity(e.lightIntensity),this.setGTAOIntensity(e.gtaoIntensity)}_applyDisplaySettings(e){this.setShowEdge(e.showEdge),this.setEdgeOpacity(e.edgeOpacity),this.setShowGrid(e.showGrid),this.setShowLevel(e.showLevel),this.setShowGround(e.showGround),this.setGroundId(e.groundId),this.setGroundHeight(e.groundHeight)}async _applyEnvironmentSettings(e){const t=++this.environmentApplyVersion;if(await this.engine.hdr?.setHdr("0"),t===this.environmentApplyVersion&&(this.engine.skyManager?.close(!0),t===this.environmentApplyVersion))switch(e.type){case"none":break;case"hdr":if(e.hdrId!=="0"){if(await this.engine.hdr?.setHdr(e.hdrId),t!==this.environmentApplyVersion){this._applyEnvironmentSettings(this._clone(this.settings.environment));return}this.engine.hdr?.setIntensity(e.hdrIntensity/100)}break;case"sky":this.engine.skyManager?.activate(),this.engine.skyManager?.setPreset(e.skyPreset),Object.keys(e.skyParams).length>0&&this.engine.skyManager?.setParams(this._clone(e.skyParams)),this.engine.skyManager?.setIntensity(e.skyIntensity/100);break}}_updateDirectionalLight(e){const t=this.engine.scene?.children.find(n=>n instanceof y.DirectionalLight);t&&e(t)}_mergeEnvironmentSettings(e){Object.assign(this.settings.environment,e),e.skyPreset!==void 0&&e.skyParams===void 0&&(this.settings.environment.skyParams={}),e.skyParams!==void 0&&(this.settings.environment.skyParams=this._clone(e.skyParams))}_toPresetItem(e){const t=Array.isArray(e.names)?[...e.names]:[];return{id:e.id,name:t[0]??e.id,names:t}}_clone(e){return JSON.parse(JSON.stringify(e))}}function Bn(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(s){var e=Math.random()*16|0,t=s=="x"?e:e&3|8;return t.toString(16)})}class zn{engine;handelBehaved;setting;constructor(e){this.engine=e,this.handelBehaved=La(e),this.handelBehaved.init(this,null),this.setting={unit:"m",precision:3}}getSetting(){return this.setting}saveSetting(e){this.setting=e}active(){this.handelBehaved.active()}disActive(){this.handelBehaved.disActive()}getMeasureText(e,t){if(e==null)return null;let n=this.setting.unit,i=n;return t==1?n=="mm"?e=e*1e3:n=="cm"?e=e*100:n=="dm"?e=e*10:n=="m"?e=e*1:n=="km"&&(e=e*.001):t==2&&(n=="mm"?e=e*1e3*1e3:n=="cm"?e=e*100*100:n=="dm"?e=e*10*10:n=="m"?e=e*1*1:n=="km"&&(e=e*.001*.001),i=i+"²"),e.toFixed(this.setting.precision)+" "+i}cancelCurrentSelectedAnnotation(){let e=this.engine.measure.annotationData;for(let t in e)e[t].forEach(n=>{n.highlight==!0&&(n.highlight=!1,n.container.classList.remove("Hight"),n.container.getElementsByTagName("svg")[0].classList.remove("Hight"))})}handelKeyEscDown(){this.cancelCurrentSelectedAnnotation();let e=this.engine.measure.annotationData;for(let t in e)for(let n=e[t].length-1;n>=0;n--){let i=e[t][n];i.isSelect==!0&&(i.container.remove(),e[t].splice(n,1))}this.engine.measure.clearAllPoints()}handelKeyDeleteDown(){let e=this.engine.measure.annotationData;for(let t in e)for(let n=e[t].length-1;n>=0;n--){let i=e[t][n];i.highlight==!0&&(i.container.remove(),e[t].splice(n,1))}}clearHighlight(){let e=this.engine.measure.annotationData;for(let t in e)e[t].forEach(n=>{n.highlight=!1,n.container.classList.remove("Hight"),n.container.getElementsByTagName("svg")[0].classList.remove("Hight")})}drawNormalAnnotation(){let e=this;this.engine.measure.annotationData.normalAnnotation.forEach(m=>{u(m)}),this.engine.measure.annotationData.elevationAnnotation.forEach(m=>{g(m)}),this.engine.measure.annotationData.coordinateAnnotation.forEach(m=>{d(m)}),this.engine.measure.annotationData.angleAnnotation.forEach(m=>{l(m)}),this.engine.measure.annotationData.areaAnnotation.forEach(m=>{c(m)}),this.engine.measure.annotationData.slopeAnnotation.forEach(m=>{h(m)});function l(m){if(m.container==null){let R=['<svg class="measureSvg">','<circle class="measurePointer" cx="50" cy="50" r="5" fill="#f99d0b" />','<circle class="measurePointer" cx="50" cy="50" r="5" fill="#f99d0b" />','<circle class="measurePointer" cx="50" cy="50" r="5" fill="#f99d0b" />','<polyline class="measureLine" stroke="orange" stroke-width="2" points="0,0 0,0" style="fill: none; opacity: 1;"/>','<polyline class="measureLine" stroke="orange" stroke-width="2" points="0,0 0,0" style="fill: none; opacity: 1;"/>','<rect x="0" y="0" width="100" height="25" class="measureBack" />','<text x="40" y="16" text-anchor="middle" class="measureLabel">'+m.text+"</text>","</svg>"].join("");m.container=document.createElement("div"),m.container.className="angle-annotation",m.container.id=m.id,m.container.style.pointerEvents="none",m.container.innerHTML=R,e.engine.measure.annotationContainer.appendChild(m.container),m.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),m.container.getElementsByTagName("svg")[0].classList.add("Hight"),m.highlight=!0,e.engine.events.trigger(xt.MeasureClick,m)}),m.isSelect&&(m.container.getElementsByTagName("svg")[0].classList.add("Hight"),m.highlight=!0)}let f=new it(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(m.point1),p=new it(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(m.point2),x=new it(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(m.point3),v=e.engine.reactBoundingClientRect.left,_=e.engine.reactBoundingClientRect.top;f.x+=v,f.y+=_,p.x+=v,p.y+=_,x.x+=v,x.y+=_;let b=m.container;b.getElementsByTagName("circle")[0].setAttribute("cx",f.x),b.getElementsByTagName("circle")[0].setAttribute("cy",f.y),b.getElementsByTagName("circle")[1].setAttribute("cx",p.x),b.getElementsByTagName("circle")[1].setAttribute("cy",p.y),b.getElementsByTagName("circle")[2].setAttribute("cx",x.x),b.getElementsByTagName("circle")[2].setAttribute("cy",x.y),b.getElementsByTagName("polyline")[0].setAttribute("points",f.x+","+f.y+" "+p.x+","+p.y),b.getElementsByTagName("polyline")[1].setAttribute("points",p.x+","+p.y+" "+x.x+","+x.y);let S=p.x,C=p.y-30;b.getElementsByTagName("rect")[0].setAttribute("x",S-40),b.getElementsByTagName("rect")[0].setAttribute("y",C-12.5),b.getElementsByTagName("text")[0].setAttribute("x",S),b.getElementsByTagName("text")[0].setAttribute("y",C+4),b.getElementsByTagName("text")[0].innerHTML=m.text,b.style.top="0px",b.style.left="0px"}function c(m){if(m.container==null){let I=['<svg class="measureSvg">','<polygon fill="rgba(0, 0, 255, 0.1)" stroke="orange" stroke-width="2" points="" style="opacity: 0.3;"/>','<polyline class="measureLine" stroke="orange" stroke-width="2" points="" style="fill: none; opacity: 1;"/>','<rect x="0" y="0" width="100" height="25" class="measureBack" />','<text x="40" y="16" text-anchor="middle" class="measureLabel">'+e.getMeasureText(m.text,2)+"</text>","</svg>"].join("");m.container=document.createElement("div"),m.container.className="area-annotation",m.container.id=m.id,m.container.innerHTML=I,e.engine.measure.annotationContainer.appendChild(m.container),m.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),m.container.getElementsByTagName("svg")[0].classList.add("Hight"),m.highlight=!0,e.engine.events.trigger(xt.MeasureClick,m)}),m.isSelect&&(m.container.getElementsByTagName("svg")[0].classList.add("Hight"),m.highlight=!0)}if(!m.points||m.points.length<3)return;let f=e.engine.reactBoundingClientRect.left,p=e.engine.reactBoundingClientRect.top,x=[],v=0,_=0;for(let I=0;I<m.points.length;I++){let E=new it(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(m.points[I]);E.x+=f,E.y+=p,x.push(E),v+=E.x,_+=E.y}v=v/x.length,_=_/x.length;let b=x.map(I=>I.x+","+I.y).join(" "),S=m.container;S.getElementsByTagName("polygon")[0].setAttribute("points",b),S.getElementsByTagName("polyline")[0].setAttribute("points",b);let C=v,R=_;S.getElementsByTagName("rect")[0].setAttribute("x",C-40),S.getElementsByTagName("rect")[0].setAttribute("y",R-12.5),S.getElementsByTagName("text")[0].setAttribute("x",C),S.getElementsByTagName("text")[0].setAttribute("y",R+4),S.getElementsByTagName("text")[0].innerHTML=e.getMeasureText(m.text,2),S.style.top="0px",S.style.left="0px"}function h(m){if(m.container==null){let C=['<svg class="measureSvg">',"<defs>",'<marker id="slope-arrow-'+m.id+'" markerWidth="10" markerHeight="10" refX="9" refY="3" orient="auto" markerUnits="strokeWidth">','<path class="measureLine" d="M0,0 L0,6 L9,3 z"/>',"</marker>","</defs>",'<polyline class="measureLine" stroke="orange" stroke-width="2" points="0,0 0,0" marker-end="url(#slope-arrow-'+m.id+')" style="fill: none; opacity: 1;"/>','<rect x="0" y="0" width="100" height="25" class="measureBack" />','<text x="50" y="16" text-anchor="middle" class="measureLabel">'+m.text+"</text>","</svg>"].join("");m.container=document.createElement("div"),m.container.className="slope-annotation",m.container.id=m.id,m.container.innerHTML=C,e.engine.measure.annotationContainer.appendChild(m.container),m.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),m.container.getElementsByTagName("svg")[0].classList.add("Hight"),m.highlight=!0,e.engine.events.trigger(xt.MeasureClick,m)}),m.isSelect&&(m.container.getElementsByTagName("svg")[0].classList.add("Hight"),m.highlight=!0)}let f=new it(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(m.point1),p=new it(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(m.point2),x=e.engine.reactBoundingClientRect.left,v=e.engine.reactBoundingClientRect.top;f.x+=x,f.y+=v,p.x+=x,p.y+=v;let _=m.container;_.getElementsByTagName("polyline")[0].setAttribute("points",f.x+","+f.y+" "+p.x+","+p.y);let b=(f.x+p.x)/2,S=(f.y+p.y)/2-30;_.getElementsByTagName("rect")[0].setAttribute("x",b-50),_.getElementsByTagName("rect")[0].setAttribute("y",S-12.5),_.getElementsByTagName("text")[0].setAttribute("x",b),_.getElementsByTagName("text")[0].setAttribute("y",S+4),_.getElementsByTagName("text")[0].innerHTML=m.text,_.style.top="0px",_.style.left="0px"}function d(m){if(m.container==null){let R=['<svg class="measureSvg">','<circle class="measurePointer" cx="0" cy="0" r="5" fill="#f99d0b" />','<rect x="0" y="-25" width="100" height="25" class="measureBack" />','<text x="40" y="-11" text-anchor="middle" class="measureLabel">X: '+e.getMeasureText(m.textX,1)+"</text>",'<rect x="0" y="-10" width="100" height="25" class="measureBack" />','<text x="40" y="25" text-anchor="middle" class="measureLabel">Y: '+e.getMeasureText(-m.textZ,1)+"</text>",'<rect x="0" y="10" width="100" height="25" class="measureBack" />','<text x="40" y="51" text-anchor="middle" class="measureLabel">Z: '+e.getMeasureText(m.textY,1)+"</text>","</svg>"].join("");m.container=document.createElement("div"),m.container.className="coordinate-annotation",m.container.id=m.id,m.container.style.position="absolute",m.container.style.pointerEvents="none",m.container.innerHTML=R,e.engine.measure.annotationContainer.appendChild(m.container),m.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),m.container.getElementsByTagName("svg")[0].classList.add("Hight"),m.highlight=!0,e.engine.events.trigger(xt.MeasureClick,m)}),m.isSelect&&(m.container.getElementsByTagName("svg")[0].classList.add("Hight"),m.highlight=!0)}let f=m.container,p=new it(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(m.point),x=e.engine.reactBoundingClientRect.left,v=e.engine.reactBoundingClientRect.top;p.x+=x,p.y+=v,f.style.top="0px",f.style.left="0px";let _=f.getElementsByTagName("circle")[0];_&&(_.setAttribute("cx",p.x),_.setAttribute("cy",p.y));let b=f.getElementsByTagName("rect"),S=f.getElementsByTagName("text"),C=-55;b[0]&&(b[0].setAttribute("x",p.x+10),b[0].setAttribute("y",p.y+10+C)),S[0]&&(S[0].setAttribute("x",p.x+10+40),S[0].setAttribute("y",p.y+10+16+C)),b[1]&&(b[1].setAttribute("x",p.x+10),b[1].setAttribute("y",p.y+10+30+C)),S[1]&&(S[1].setAttribute("x",p.x+10+40),S[1].setAttribute("y",p.y+10+46+C)),b[2]&&(b[2].setAttribute("x",p.x+10),b[2].setAttribute("y",p.y+10+60+C)),S[2]&&(S[2].setAttribute("x",p.x+10+40),S[2].setAttribute("y",p.y+10+76+C)),S[0]&&(S[0].innerHTML="X: "+e.getMeasureText(m.textX,1)),S[1]&&(S[1].innerHTML="Y: "+e.getMeasureText(-m.textZ,1)),S[2]&&(S[2].innerHTML="Z: "+e.getMeasureText(m.textY,1))}function g(m){if(m.container==null){let _=['<svg width="100" height="50" class="measureSvg">','<rect x="0" y="0" width="100" height="25" class="measureBack" />','<text x="40" y="16" text-anchor="middle" class="measureLabel">'+e.getMeasureText(m.text,1)+"</text>",'<polyline class="measureLine" stroke-width="2" points="80,32 0,32 16,48 32,32" style="fill: none; opacity: 1;"/>',"</svg>"].join("");m.container=document.createElement("div"),m.container.className="elevation-annotation",m.container.id=m.id,m.container.style.position="absolute",m.container.style.pointerEvents="none",m.container.innerHTML=_,e.engine.measure.annotationContainer.appendChild(m.container),m.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),m.container.getElementsByTagName("svg")[0].classList.add("Hight"),m.highlight=!0,e.engine.events.trigger(xt.MeasureClick,m)}),m.isSelect&&(m.container.getElementsByTagName("svg")[0].classList.add("Hight"),m.highlight=!0)}let f=m.container,p=new it(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(m.point),x=e.engine.reactBoundingClientRect.left,v=e.engine.reactBoundingClientRect.top;f.style.top=p.y+v-48+"px",f.style.left=p.x+x-16+"px",f.getElementsByTagName("text")[0].innerHTML=e.getMeasureText(m.text,1)}function u(m){if(m.container==null){let b=['<svg class="measureSvg">','<circle class="measurePointer" cx="50" cy="50" r="5" fill="#f99d0b" />','<circle class="measurePointer" cx="50" cy="50" r="5" fill="#f99d0b" />','<polyline class="measureLine" stroke="orange" stroke-width="2" points="80,32 0,32" style="fill: none; opacity: 1;"/>','<rect x="0" y="0" width="100" height="25" class="measureBack" />','<text x="40" y="16" text-anchor="middle" class="measureLabel">'+e.getMeasureText(m.text,1)+"</text>","</svg>"].join("");m.container=document.createElement("div"),m.container.className="normal-annotation",m.container.id=m.id,m.container.innerHTML=b,e.engine.measure.annotationContainer.appendChild(m.container),m.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),m.container.getElementsByTagName("svg")[0].classList.add("Hight"),m.highlight=!0,e.engine.events.trigger(xt.MeasureClick,m)}),m.isSelect&&(m.container.getElementsByTagName("svg")[0].classList.add("Hight"),m.highlight=!0)}let f=m.container;if(m.point1==null||m.point2==null){f.style.display="none";return}else f.style.display="block";let p=new it(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(m.point1),x=new it(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(m.point2),v=e.engine.reactBoundingClientRect.left,_=e.engine.reactBoundingClientRect.top;p.x+=v,p.y+=_,x.x+=v,x.y+=_,f.getElementsByTagName("polyline")[0].setAttribute("points",p.x+","+p.y+" "+x.x+","+x.y),f.getElementsByTagName("circle")[0].setAttribute("cx",p.x),f.getElementsByTagName("circle")[0].setAttribute("cy",p.y),f.getElementsByTagName("circle")[1].setAttribute("cx",x.x),f.getElementsByTagName("circle")[1].setAttribute("cy",x.y),f.getElementsByTagName("rect")[0].setAttribute("x",p.x*.5+x.x*.5-40),f.getElementsByTagName("rect")[0].setAttribute("y",p.y*.5+x.y*.5-12.5),f.getElementsByTagName("text")[0].setAttribute("x",p.x*.5+x.x*.5+40-40),f.getElementsByTagName("text")[0].setAttribute("y",p.y*.5+x.y*.5+16-12.5),f.getElementsByTagName("text")[0].innerHTML=e.getMeasureText(m.text,1),f.style.top="0px",f.style.left="0px"}}}class Ay{engine;isActive=!1;tools;points=[];behavior;catchDir=0;type="point";constructor(e){this.engine=e,this.tools=new zn(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.isActive=!0,this.behavior=this.engine.handelBehaved,this.behavior.init(this),this.behavior.active();let e=this.engine.measure.annotationData.normalAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1)}disActive(){this.isActive=!1,this.behavior?.disActive()}clearAllPoints(){this.points=[]}setDirection(e){this.catchDir=e}setSelectType(e){this.type=e}getMeshesMinMaxY(e){if(!Array.isArray(e)||e.length===0)return null;let t=Number.POSITIVE_INFINITY,n=Number.NEGATIVE_INFINITY;for(let i=0;i<e.length;i++){const r=e[i];if(!r)continue;typeof r.updateMatrixWorld=="function"&&r.updateMatrixWorld(!0);const o=new y.Box3().setFromObject(r);!Number.isFinite(o.min.y)||!Number.isFinite(o.max.y)||(o.min.y<t&&(t=o.min.y),o.max.y>n&&(n=o.max.y))}return!Number.isFinite(t)||!Number.isFinite(n)?null:{minY:t,maxY:n}}handleMouseClick(e){if(e.catch==null)return;let t=e.catch.point;if(this.type=="element"){let r=this.engine.interactionModule.getCatchMeshs(e);var n=this.getMeshesMinMaxY(r);this.catchDir==0?t.set(t.x,n?.minY,t.z):t.set(t.x,n?.maxY,t.z)}else t=e.catch.point;if(this.points.length==0){this.engine.measure.tools.clearHighlight(),this.points.push(t);return}let i=this.engine.measure.annotationData.normalAnnotation.find(r=>r.isSelect==!0);i!=null&&(i.isSelect=!1)}handleMouseMove(e){if(e.catch==null||this.points.length==0)return;let t=this.engine.measure.annotationData.normalAnnotation.find(i=>i.isSelect==!0);t==null&&(t={text:null,id:Bn(),isSelect:!0,type:"clear-height"},this.engine.measure.annotationData.normalAnnotation.push(t));let n=e.catch;if(this.type=="element"){let i=e.catch.point.clone();i.set(i.x,this.points[0].y,i.z);let r=new y.Raycaster(i.add(new y.Vector3(0,.01,0)),new y.Vector3(0,this.catchDir==0?-1:1,0));n.point=this.points[0];const o=this.engine.clipping?.filterIntersectionsByClipping(this.engine.octreeBox.rayInterationModel(r))??this.engine.octreeBox.rayInterationModel(r);if(o.length===0){t.point2=null;return}t.point1=i,t.point2=o[0].point,t.text=t.point1.clone().distanceTo(t.point2.clone()),this.engine.events.trigger(xt.MeasureChanged,t)}else{let i=new y.Raycaster(e.catch.point.clone().add(new y.Vector3(0,.01,0)),new y.Vector3(0,this.catchDir==0?-1:1,0));const r=this.engine.clipping?.filterIntersectionsByClipping(this.engine.octreeBox.rayInterationModel(i))??this.engine.octreeBox.rayInterationModel(i);if(r.length===0){t.point2=null;return}t.point1=n.point,t.point2=r[0].point,t.text=t.point1.clone().distanceTo(t.point2.clone()),this.engine.events.trigger(xt.MeasureChanged,t)}}}class Ty{engine;tools;isActive=!1;points=[];behavior;constructor(e){this.engine=e,this.tools=new zn(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.isActive=!0,this.points=[],this.behavior=this.engine.handelBehaved,this.behavior.init(this,{showCatch:!0}),this.behavior.active();let e=this.engine.measure.annotationData.normalAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1)}disActive(){this.points=[],this.isActive=!1,this.engine.handelBehaved.disActive()}clearAllPoints(){this.points=[]}handleMouseClick(e){if(e.catch==null)return;let t=e.catch;if(this.points.length==0)this.engine.measure.tools.clearHighlight(),this.points.push(t.point);else if(this.points.length==1){let n=this.engine.measure.annotationData.normalAnnotation.find(i=>i.isSelect==!0);if(n==null)return;n.point2=t.point,n.isSelect=!1,this.points=[],this.engine.events.trigger(xt.MeasureChanged,n)}}handleMouseMove(e){if(e.catch==null)return;let t=e.catch;if(t!=null&&this.points.length==1){let n=this.engine.measure.annotationData.normalAnnotation.find(i=>i.isSelect==!0);n==null&&(n={id:Bn(),point1:this.points[0].clone(),point2:t.point.clone(),text:this.points[0].clone().distanceTo(t.point.clone()),type:"distance",isSelect:!0},this.engine.measure.annotationData.normalAnnotation.push(n)),n.point2=t.point,n.text=n.point1.clone().distanceTo(n.point2.clone())}}}class Py{engine;isActive=!1;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new zn(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.isActive=!0,this.behavior=this.engine.handelBehaved,this.behavior.init(this),this.behavior.active();let e=this.engine.measure.annotationData.normalAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1)}disActive(){this.isActive=!1,this.behavior?.disActive()}clearAllPoints(){this.points=[]}handleMouseClick(e){if(e.catch==null)return;if(this.points.length==0){this.engine.measure.tools.clearHighlight(),this.points.push(e.catch.point);return}let t=this.engine.measure.annotationData.normalAnnotation.find(n=>n.isSelect==!0);t!=null&&(t.isSelect=!1)}handleMouseMove(e){if(e.catch==null||this.points.length==0)return;let t=this.engine.measure.annotationData.normalAnnotation.find(o=>o.isSelect==!0);t==null&&(t={text:null,id:Bn(),isSelect:!0,type:"clear-distance"},this.engine.measure.annotationData.normalAnnotation.push(t));let n=new y.Raycaster(e.catch.point.clone().add(e.catch.face.normal.clone().setLength(.01)),e.catch.face.normal);const i=this.engine.clipping?.filterIntersectionsByClipping(this.engine.octreeBox.rayInterationModel(n))??this.engine.octreeBox.rayInterationModel(n);if(i.length==0){t.point2=null;return}let r=e.catch;t.point1=r.point,t.point2=i[0].point,t.text=t.point1.clone().distanceTo(t.point2.clone()),this.engine.events.trigger(xt.MeasureChanged,t)}}class Dy{engine;isActive=!1;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new zn(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.behavior=this.engine.handelBehaved,this.behavior.init(this,{showCatch:!0}),this.behavior.active(),this.isActive=!0;let e=this.engine.measure.annotationData.normalAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1)}disActive(){this.isActive=!1,this.behavior?.disActive()}clearAllPoints(){this.points=[]}handleMouseMove(e){if(e.catch==null)return;let t=this.engine.measure.annotationData.elevationAnnotation.find(n=>n.isSelect==!0);t==null&&(t={id:Bn(),point:e.catch.point.clone(),text:e.catch.point.y,isSelect:!0,type:"elevation"},this.engine.measure.annotationData.elevationAnnotation.push(t)),t.point=e.catch.point.clone(),t.text=e.catch.point.y}handleMouseClick(e){if(e.catch==null)return;this.engine.measure.tools.clearHighlight();let t=this.engine.measure.annotationData.elevationAnnotation.find(n=>n.isSelect==!0);t!=null&&(t.isSelect=!1,t.point=e.catch.point.clone(),t.text=e.catch.point.y,this.engine.events.trigger(xt.MeasureChanged,t))}}class Ry{engine;isActive=!1;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new zn(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.behavior=this.engine.handelBehaved,this.behavior.init(this,{showCatch:!0}),this.behavior.active(),this.isActive=!0;let e=this.engine.measure.annotationData.normalAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1)}disActive(){this.isActive=!1,this.behavior?.disActive()}clearAllPoints(){this.points=[]}handleMouseUp(e){this.engine.deviceType!="PC"&&this.createMeasure()}handleMouseMove(e){if(e.catch==null)return;let t=this.engine.measure.annotationData.coordinateAnnotation.find(n=>n.isSelect==!0);t==null&&(t={id:Bn(),point:e.catch.point.clone(),text:Math.round(e.catch.point.y)+" m",isSelect:!0,type:"point"},this.engine.measure.annotationData.coordinateAnnotation.push(t)),t.point=e.catch.point.clone(),t.textX=e.catch.point.x,t.textY=e.catch.point.y,t.textZ=e.catch.point.z}handleMouseClick(e){if(e.catch==null)return;this.engine.measure.tools.clearHighlight();let t=this.engine.measure.annotationData.coordinateAnnotation.find(n=>n.isSelect==!0);t!=null&&(t.point=e.catch.point.clone(),t.textX=e.catch.point.x,t.textY=e.catch.point.y,t.textZ=e.catch.point.z,t.isSelect=!1,this.engine.events.trigger(xt.MeasureChanged,t))}createMeasure(){let e=this.engine.measure.annotationData.coordinateAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1,this.engine.events.trigger(xt.MeasureChanged,e))}}class Ly{engine;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new zn(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.points=[],this.behavior=this.engine.handelBehaved,this.behavior.init(this),this.behavior.active();let e=this.engine.measure.annotationData.normalAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1)}disActive(){this.points=[],this.behavior?.disActive()}clearAllPoints(){this.points=[]}calculateAngle(e,t,n){const i=new y.Vector3().subVectors(e,t),r=new y.Vector3().subVectors(n,t),o=i.length(),a=r.length();if(o===0||a===0)return 0;const c=i.dot(r)/(o*a),h=Math.max(-1,Math.min(1,c));return Math.acos(h)*(180/Math.PI)}handleMouseClick(e){if(e.catch==null)return;let t=e.catch;if(this.points.length==0)this.engine.measure.tools.clearHighlight(),this.points.push(t.point);else if(this.points.length==1)this.points.push(t.point);else if(this.points.length==2){let n=this.engine.measure.annotationData.angleAnnotation.find(i=>i.isSelect==!0);if(n==null)return;n.point3=t.point.clone(),n.angle=this.calculateAngle(n.point1,n.point2,n.point3),n.text=n.angle.toFixed(2)+"°",n.isSelect=!1,n.type="angle",this.points=[],this.engine.events.trigger(xt.MeasureChanged,n)}}handleMouseMove(e){if(e.catch!=null&&this.points.length!=1&&this.points.length==2){let t=this.engine.measure.annotationData.angleAnnotation.find(n=>n.isSelect==!0);t==null&&(t={id:Bn(),point1:this.points[0].clone(),point2:this.points[1].clone(),point3:e.catch.point.clone(),angle:0,text:"0.00°",isSelect:!0,type:"angle"},this.engine.measure.annotationData.angleAnnotation.push(t)),t.point3=e.catch.point.clone(),t.angle=this.calculateAngle(t.point1,t.point2,t.point3),t.text=t.angle.toFixed(2)+"°",console.log("角度",t.text)}}}class Iy{engine;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new zn(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.points=[],this.behavior=this.engine.handelBehaved,this.behavior.init(this),this.behavior.active();let e=this.engine.measure.annotationData.normalAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1)}disActive(){this.points=[],this.behavior?.disActive()}clearAllPoints(){this.points=[]}calculateArea(e){if(e.length<3)return 0;let t=0;const n=e.length;for(let i=0;i<n;i++){const r=(i+1)%n;t+=e[i].x*e[r].z,t-=e[r].x*e[i].z}return t=Math.abs(t)/2,t}handleMouseClick(e){if(e.catch==null)return;let t=e.catch;if(this.points.push(t.point.clone()),this.points.length>=3){let n=this.engine.measure.annotationData.areaAnnotation.find(i=>i.isSelect==!0);n==null?(n={id:Bn(),points:this.points.map(i=>i.clone()),area:0,text:0,isSelect:!0,type:"area"},this.engine.measure.annotationData.areaAnnotation.push(n)):(this.points.push(t.point.clone()),n.points=this.points.map(i=>i.clone())),n.area=this.calculateArea(n.points),n.text=n.area,console.log("面积",n.text)}else this.engine.measure.tools.clearHighlight()}handleMouseMove(e){if(e.catch!=null&&this.points.length>=2){let t=this.engine.measure.annotationData.areaAnnotation.find(n=>n.isSelect==!0);if(t==null){if(this.points.length>=2){let n=this.points.map(i=>i.clone());n.push(e.catch.point.clone()),n.length>=3&&(t={id:Bn(),points:n,area:0,text:0,isSelect:!0,type:"area"},this.engine.measure.annotationData.areaAnnotation.push(t))}}else if(t.points.length>0){const n=t.points.length-1;t.points[n]=e.catch.point.clone()}else t.points=this.points.map(n=>n.clone()),t.points.push(e.catch.point.clone());t&&t.points.length>=3&&(t.area=this.calculateArea(t.points),t.text=t.area)}}handelKeyEnterDown(){this.finishMeasure()}finishMeasure(){this.points=this.points.slice(0,this.points.length-1);let e=this.engine.measure.annotationData.areaAnnotation.find(t=>t.isSelect==!0);e!=null&&e.points.length>=3&&(e.points.length>this.points.length&&(e.points=this.points.map(t=>t.clone())),e.area=this.calculateArea(e.points),e.text=e.area,e.isSelect=!1,this.points=[],this.engine.events.trigger(xt.MeasureChanged,e))}}class Ny{engine;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new zn(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.points=[],this.behavior=this.engine.handelBehaved,this.behavior.init(this,{showCatch:!0}),this.behavior.active();let e=this.engine.measure.annotationData.normalAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1)}disActive(){this.points=[],this.behavior?.disActive()}clearAllPoints(){this.points=[]}calculateSlope(e,t){const n=t.y-e.y,i=t.x-e.x,r=t.z-e.z,o=Math.sqrt(i*i+r*r);if(o===0)return{percentage:0,angle:0,heightDiff:n,horizontalDist:0,type:"slope"};const a=n/o*100,c=Math.atan(n/o)*(180/Math.PI);return{percentage:a,angle:c,heightDiff:n,horizontalDist:o,type:"slope"}}handleMouseClick(e){if(e.catch==null)return;let t=e.catch;if(this.points.length==0)this.engine.measure.tools.clearHighlight(),this.points.push(t.point);else if(this.points.length==1){let n=this.engine.measure.annotationData.slopeAnnotation.find(r=>r.isSelect==!0);if(n==null)return;console.log("进来了"),n.point2=t.point.clone();const i=this.calculateSlope(n.point1,n.point2);n.slopePercentage=i.percentage,n.slopeAngle=i.angle,n.heightDiff=i.heightDiff,n.horizontalDist=i.horizontalDist,n.text=i.percentage.toFixed(2)+"% ("+i.angle.toFixed(2)+"°)",n.isSelect=!1,this.points=[],this.engine.events.trigger(xt.MeasureChanged,n)}}handleMouseMove(e){if(e.catch==null)return;let t=e.catch;if(t!=null&&this.points.length==1){let n=this.engine.measure.annotationData.slopeAnnotation.find(r=>r.isSelect==!0);n==null&&(n={id:Bn(),point1:this.points[0].clone(),point2:t.point.clone(),slopePercentage:0,slopeAngle:0,heightDiff:0,horizontalDist:0,text:"0.00% (0.00°)",isSelect:!0,type:"slope"},this.engine.measure.annotationData.slopeAnnotation.push(n)),n.point2=t.point.clone();const i=this.calculateSlope(n.point1,n.point2);n.slopePercentage=i.percentage,n.slopeAngle=i.angle,n.heightDiff=i.heightDiff,n.horizontalDist=i.horizontalDist,n.text=i.percentage.toFixed(2)+"% ("+i.angle.toFixed(2)+"°)"}}}class Uy{isActive=!1;engine;clearHeightMeasure;distanceMeasure;clearDistanceMeasure;elevationMeasure;pointMeasure;angleMeasure;areaMeasure;slopeMeasure;tools;annotationContainer;annotationData={normalAnnotation:[],textAnnotation:[],coordinateAnnotation:[],angleAnnotation:[],distanceAnnotation:[],areaAnnotation:[],slopeAnnotation:[],elevationAnnotation:[],volumeAnnotation:[]};constructor(e){this.engine=e,this.clearHeightMeasure=new Ay(e),this.distanceMeasure=new Ty(e),this.clearDistanceMeasure=new Py(e),this.elevationMeasure=new Dy(e),this.pointMeasure=new Ry(e),this.angleMeasure=new Ly(e),this.areaMeasure=new Iy(e),this.slopeMeasure=new Ny(e),this.tools=new zn(e),this.annotationContainer=document.createElement("div"),this.annotationContainer.className="annotation-container",e.container.appendChild(this.annotationContainer)}active(){this.isActive=!0,this.engine.modelEdge.loadModelEdge(),this.tools.active()}disActive(){this.tools.disActive(),this.clearAll(),this.isActive=!1,this.clearHeightMeasure.disActive(),this.distanceMeasure.disActive(),this.clearDistanceMeasure.disActive(),this.elevationMeasure.disActive(),this.pointMeasure.disActive(),this.angleMeasure.disActive(),this.areaMeasure.disActive(),this.slopeMeasure.disActive(),this.engine.interactionModule.init(),this.engine.interactionModule.active()}clearAllPoints(){this.clearHeightMeasure.clearAllPoints(),this.distanceMeasure.clearAllPoints(),this.clearDistanceMeasure.clearAllPoints(),this.elevationMeasure.clearAllPoints(),this.pointMeasure.clearAllPoints(),this.angleMeasure.clearAllPoints(),this.areaMeasure.clearAllPoints(),this.slopeMeasure.clearAllPoints()}clearAll(){e(this.annotationData.normalAnnotation),e(this.annotationData.textAnnotation),e(this.annotationData.coordinateAnnotation),e(this.annotationData.angleAnnotation),e(this.annotationData.distanceAnnotation),e(this.annotationData.areaAnnotation),e(this.annotationData.slopeAnnotation),e(this.annotationData.elevationAnnotation),e(this.annotationData.volumeAnnotation);function e(t){for(let n=0;n<t.length;n++)t[n].container.remove();t=[]}}saveSetting(e){this.tools.saveSetting(e)}getSetting(){return this.tools.getSetting()}update(){this.isActive&&this.tools.drawNormalAnnotation()}}class Fy{engine;isActive=!1;isCtrlDown=!1;listenersAttached=!1;box;pickPoint;pickNormal;pickMesh;box_;plane;meshs;isDrag=!1;maxBox;faceIdleOpacity=0;faceHoverOpacity=.05;transformControls=new Map;transformAnchors=new Map;transformHelpers=new Map;faceMetaMap=new Map;isSyncingTransform=!1;handleNativeMouseDown=e=>{if(e.button!==0||!(this.isCtrlDown||e.ctrlKey))return;const t=this.createRaycasterFromMouseEvent(e),n=t.intersectObjects(this.getInteractiveMeshes(),!1);n.length!==0&&(e.preventDefault(),e.stopImmediatePropagation(),this.handleMouseDown({button:e.button,raycaster:t,intersects:n}))};handleNativeMouseMove=e=>{if(!this.isDrag&&!(this.isCtrlDown||e.ctrlKey)){this.resetMeshOpacity();return}const t=this.createRaycasterFromMouseEvent(e),n=t.intersectObjects(this.getInteractiveMeshes(),!1);this.isDrag&&(e.preventDefault(),e.stopImmediatePropagation()),this.handleMouseMove({raycaster:t,intersects:n})};handleNativeMouseUp=e=>{e.button!==0||!this.isDrag||(e.preventDefault(),e.stopImmediatePropagation(),this.handleMouseUp({button:e.button}))};handleNativeKeyDown=e=>{e.key==="Control"&&(this.isCtrlDown=!0)};handleNativeKeyUp=e=>{e.key==="Control"&&(this.isCtrlDown=!1,this.isDrag&&this.handleMouseUp({button:0}),this.resetMeshOpacity())};constructor(e,t){this.engine=e,this.meshs=[]}active(){this.isActive||(this.attachListeners(),this.init(),this.setTransformControlsVisible(!0),this.engine.scene.children.filter(e=>e.type=="Group"&&e.name=="ClippingBox").forEach(e=>{e.children.forEach(t=>{t.name.includes("face")||(t.visible=!0)})}),this.isActive=!0)}disActive(){this.init(),this.isActive=!1,this.detachListeners(),this.handleMouseUp({button:0}),this.setTransformControlsVisible(!1),this.engine.scene.children.filter(e=>e.type=="Group"&&e.name=="ClippingBox").forEach(e=>{e.children.forEach(t=>{t.name.includes("face")||(t.visible=!1)})})}disabled(){this.isActive=!1,this.detachListeners(),this.handleMouseUp({button:0}),this.setTransformControlsVisible(!1),this.engine.scene.children.filter(e=>e.type=="Group"&&e.name=="ClippingBox").forEach(e=>{e.children.forEach(t=>{t.name.includes("face")||(t.visible=!1)})})}recover(){this.isActive||(this.attachListeners(),this.setTransformControlsVisible(!0),this.engine.scene.children.filter(e=>e.type=="Group"&&e.name=="ClippingBox").forEach(e=>{e.children.forEach(t=>{t.name.includes("face")||(t.visible=!0)})}),this.isActive=!0)}init(){const e=this.engine.octreeBox.getBoundingBox();e.min.x-=.1,e.min.y-=.1,e.min.z-=.1,e.max.x+=.1,e.max.y+=.1,e.max.z+=.1,this.maxBox=JSON.parse(JSON.stringify(e)),this.box=e,this.updata_face(e)}getboxXyz(){return{minX:this.box.min.x,minY:this.box.min.y,minZ:this.box.min.z,maxX:this.box.max.x,maxY:this.box.max.y,maxZ:this.box.max.z}}setboxXyz(e){this.box.min.x=e.minX,this.box.min.y=e.minY,this.box.min.z=e.minZ,this.box.max.x=e.maxX,this.box.max.y=e.maxY,this.box.max.z=e.maxZ,this.updata_face(this.box)}setBox(e){this.box=e,this.updata_face(e)}reverseBox(){}handleMouseDown(e){const t=e.intersects??e.raycaster.intersectObjects(this.getInteractiveMeshes(),!1);if(t!=null&&t.length>0){const n=t[0];this.isDrag=!0,this.pickPoint=n.point.clone(),this.pickMesh=n.object;const i=this.pickMesh?.userData?.dragNormal?.clone?.(),r=n.face?.normal?.clone?.();if(this.pickNormal=(i??r??new y.Vector3(0,0,1)).clone().normalize(),this.engine.controls.enabled=!1,this.box_={min:this.box.min.clone(),max:this.box.max.clone()},this.pickNormal.y==0){const o=new y.Plane;o.setFromNormalAndCoplanarPoint(new y.Vector3(0,1,0),this.pickPoint),this.plane=o}else{const o=new y.Vector3(this.engine.camera.position.x,this.pickPoint.y,this.engine.camera.position.z),a=new y.Plane;a.setFromNormalAndCoplanarPoint(o.clone().sub(this.pickPoint.clone()).setLength(1),this.pickPoint),this.plane=a}}else this.isDrag=!1}handleMouseUp(e){this.isDrag=!1,this.pickPoint=null,this.pickNormal=null,this.pickMesh=null,this.plane=null,this.engine.controls.enabled=!0}clampVector3(e,t,n){return new y.Vector3(Math.max(t.x,Math.min(n.x,e.x)),Math.max(t.y,Math.min(n.y,e.y)),Math.max(t.z,Math.min(n.z,e.z)))}handleMouseMove(e){this.resetMeshOpacity();const t=e.intersects??e.raycaster.intersectObjects(this.getInteractiveMeshes(),!1);if(t!=null&&t.length>0&&(t[0].object.material.opacity=this.faceHoverOpacity),this.pickPoint!=null){const n=new y.Vector3;if(e.raycaster.ray.intersectPlane(this.plane,n)){const i=n.clone().sub(this.pickPoint.clone()).dot(this.pickNormal.clone());if(!!this.pickMesh?.userData?.isMinFace){const o=this.box_.min.clone().add(this.pickNormal.clone().setLength(i));this.box.min=this.clampVector3(o,this.maxBox.min,this.box.max)}else{const o=this.box_.max.clone().add(this.pickNormal.clone().setLength(i));this.box.max=this.clampVector3(o,this.box.min,this.maxBox.max)}this.updata_face(this.box),this.calculate_ratio()}}}calculate_ratio(){const e=this.maxBox.max.x-this.maxBox.min.x,t=this.maxBox.max.y-this.maxBox.min.y,n=this.maxBox.max.z-this.maxBox.min.z,i=this.toPercent((this.box.min.x-this.maxBox.min.x)/e*100),r=this.toPercent((this.box.max.x-this.maxBox.min.x)/e*100),o=this.toPercent((this.box.min.y-this.maxBox.min.y)/t*100),a=this.toPercent((this.box.max.y-this.maxBox.min.y)/t*100),l=this.toPercent((this.box.min.z-this.maxBox.min.z)/n*100),c=this.toPercent((this.box.max.z-this.maxBox.min.z)/n*100),h={x:{min:i,max:r},y:{min:o,max:a},z:{min:l,max:c}};this.engine.events.trigger(xt.SectionMove,h)}toPercent(e){return e<0?0:e>100?100:e}getInteractiveMeshes(){return this.meshs.filter(e=>e.type==="Mesh")}createRaycasterFromMouseEvent(e){const t=new y.Raycaster,n=new y.Vector2,i=this.engine.renderer.domElement.clientWidth,r=this.engine.renderer.domElement.clientHeight;return n.x=e.offsetX/i*2-1,n.y=-(e.offsetY/r)*2+1,t.setFromCamera(n,this.engine.camera),t}attachListeners(){if(this.listenersAttached)return;const e=this.engine.renderer?.domElement;e&&(e.addEventListener("mousedown",this.handleNativeMouseDown,!0),e.addEventListener("mousemove",this.handleNativeMouseMove,!0),e.addEventListener("mouseup",this.handleNativeMouseUp,!0),window.addEventListener("keydown",this.handleNativeKeyDown),window.addEventListener("keyup",this.handleNativeKeyUp),this.listenersAttached=!0)}detachListeners(){if(!this.listenersAttached)return;const e=this.engine.renderer?.domElement;e&&(e.removeEventListener("mousedown",this.handleNativeMouseDown,!0),e.removeEventListener("mousemove",this.handleNativeMouseMove,!0),e.removeEventListener("mouseup",this.handleNativeMouseUp,!0)),window.removeEventListener("keydown",this.handleNativeKeyDown),window.removeEventListener("keyup",this.handleNativeKeyUp),this.listenersAttached=!1,this.isCtrlDown=!1}resetMeshOpacity(){this.getInteractiveMeshes().forEach(e=>{e.material&&(e.material.opacity=this.faceIdleOpacity)})}getFaceTransformOffset(){if(!this.box)return .06;const e=this.box.min.distanceTo(this.box.max);return Math.max(e*.015,.06)}keepSingleDirectionArrow(e,t="X"){const n=e.getHelper(),i=[];n.traverse(r=>{if(r?.name!==t||!r.geometry)return;const o=r.geometry;o.boundingBox||o.computeBoundingBox();const a=o.boundingBox;if(!a)return;const l=a.getCenter(new y.Vector3);if(!(t==="X"&&l.x<0||t==="Y"&&l.y<0||t==="Z"&&l.z<0))return;const h=o.parameters,d=h&&h.radiusTop===0&&h.radiusBottom===.04&&h.height===.1,g=h&&h.radiusTop===.2&&h.radiusBottom===0&&h.height===.6;(d||g)&&i.push(r)}),i.forEach(r=>{r.parent?.remove(r)})}setTransformControlsVisible(e){this.transformControls.forEach(t=>{t.enabled=e}),this.transformHelpers.forEach(t=>{t.visible=e}),this.transformAnchors.forEach(t=>{t.visible=e}),e||(this.engine.controls.enabled=!0)}ensureFaceTransformControl(e){if(this.transformControls.has(e)&&this.transformAnchors.has(e))return;const t=this.engine.renderer?.domElement,n=this.engine.camera;if(!t||!n)return;const i=new y.Object3D;i.name=`SectionBoxTransformAnchor_${e}`,i.visible=this.isActive,this.engine.scene.add(i);const r=new cd(n,t);r.name=`SectionBoxTransformControl_${e}`,r.setMode("translate"),r.setSpace("local"),r.showX=!0,r.showY=!1,r.showZ=!1,r.size=.75,r.enabled=this.isActive,r.attach(i),this.keepSingleDirectionArrow(r,"X"),r.addEventListener("dragging-changed",a=>{this.engine.controls.enabled=!a.value}),r.addEventListener("objectChange",()=>{this.handleTransformObjectChange(e)});const o=r.getHelper();o.visible=this.isActive,this.engine.scene.add(o),this.transformAnchors.set(e,i),this.transformControls.set(e,r),this.transformHelpers.set(e,o)}updateFaceTransformControl(e,t,n,i){this.ensureFaceTransformControl(e);const r=this.transformAnchors.get(e),o=this.transformControls.get(e);if(!r||!o)return;const a=this.getFaceTransformOffset(),l=new y.Quaternion().setFromUnitVectors(new y.Vector3(1,0,0),t.clone().normalize()),c=n.clone().add(t.clone().setLength(a));this.faceMetaMap.set(e,{normal:t.clone().normalize(),isMinFace:i,center:n.clone()}),this.isSyncingTransform=!0,r.position.copy(c),r.quaternion.copy(l),r.visible=this.isActive,o.object!==r&&o.attach(r),o.enabled=this.isActive;const h=this.transformHelpers.get(e);h&&(h.visible=this.isActive),this.isSyncingTransform=!1}getDominantAxis(e){const t=Math.abs(e.x),n=Math.abs(e.y),i=Math.abs(e.z);return t>=n&&t>=i?"x":n>=t&&n>=i?"y":"z"}handleTransformObjectChange(e){if(this.isSyncingTransform)return;const t=this.transformAnchors.get(e),n=this.faceMetaMap.get(e);if(!t||!n||!this.box||!this.maxBox)return;const i=n.normal,r=this.getDominantAxis(i),o=this.getFaceTransformOffset(),a=i[r],l=t.position[r]-a*o;if(n.isMinFace){const c=this.maxBox.min[r],h=this.box.max[r];this.box.min[r]=Math.max(c,Math.min(h,l))}else{const c=this.box.min[r],h=this.maxBox.max[r];this.box.max[r]=Math.max(c,Math.min(h,l))}this.updata_face(this.box),this.calculate_ratio()}updata_face(e){let t=this.engine.scene.children.find(i=>i.type=="Group"&&i.name=="ClippingBox");t==null&&(t=new y.Group,t.name="ClippingBox",this.engine.scene.add(t)),[{name:"前",normal:new y.Vector3(0,0,-1),isMinFace:!0,planePoint:e.min,vertices:[new y.Vector3(e.min.x,e.max.y,e.min.z),new y.Vector3(e.max.x,e.max.y,e.min.z),new y.Vector3(e.max.x,e.min.y,e.min.z),new y.Vector3(e.min.x,e.min.y,e.min.z)]},{name:"后",normal:new y.Vector3(0,0,1),isMinFace:!1,planePoint:e.max,vertices:[new y.Vector3(e.min.x,e.min.y,e.max.z),new y.Vector3(e.max.x,e.min.y,e.max.z),new y.Vector3(e.max.x,e.max.y,e.max.z),new y.Vector3(e.min.x,e.max.y,e.max.z)]},{name:"右",normal:new y.Vector3(1,0,0),isMinFace:!1,planePoint:e.max,vertices:[new y.Vector3(e.max.x,e.min.y,e.max.z),new y.Vector3(e.max.x,e.min.y,e.min.z),new y.Vector3(e.max.x,e.max.y,e.min.z),new y.Vector3(e.max.x,e.max.y,e.max.z)]},{name:"左",normal:new y.Vector3(-1,0,0),isMinFace:!0,planePoint:e.min,vertices:[new y.Vector3(e.min.x,e.min.y,e.min.z),new y.Vector3(e.min.x,e.min.y,e.max.z),new y.Vector3(e.min.x,e.max.y,e.max.z),new y.Vector3(e.min.x,e.max.y,e.min.z)]},{name:"顶",normal:new y.Vector3(0,1,0),isMinFace:!1,planePoint:e.max,vertices:[new y.Vector3(e.min.x,e.max.y,e.max.z),new y.Vector3(e.max.x,e.max.y,e.max.z),new y.Vector3(e.max.x,e.max.y,e.min.z),new y.Vector3(e.min.x,e.max.y,e.min.z)]},{name:"底",normal:new y.Vector3(0,-1,0),isMinFace:!0,planePoint:e.min,vertices:[new y.Vector3(e.min.x,e.min.y,e.min.z),new y.Vector3(e.max.x,e.min.y,e.min.z),new y.Vector3(e.max.x,e.min.y,e.max.z),new y.Vector3(e.min.x,e.min.y,e.max.z)]}].forEach(i=>{this.createFace(t,i.vertices,i.normal,i.name,i.isMinFace,i.planePoint)}),this.engine.scene.children.filter(i=>i.type=="Mesh"&&i.url).forEach(i=>{i.material&&Array.isArray(i.material)?i.material.forEach(r=>{r.clippingPlanes=this.engine.sectionPlane}):i.material.clippingPlanes=this.engine.sectionPlane})}createFace(e,t,n,i,r,o){const a=new y.BufferGeometry,l=new Float32Array([t[0].x,t[0].y,t[0].z,t[1].x,t[1].y,t[1].z,t[2].x,t[2].y,t[2].z,t[3].x,t[3].y,t[3].z]),c=[0,2,1,0,3,2];a.setAttribute("position",new y.BufferAttribute(l,3)),a.setIndex(c);let h=this.meshs.find(x=>x.name===i);if(h==null){const x=new y.MeshBasicMaterial({color:65280,transparent:!0,opacity:this.faceIdleOpacity,side:y.DoubleSide});x.polygonOffset=!0,x.polygonOffsetFactor=1,x.polygonOffsetUnits=4,h=new y.Mesh(a,x),h.name=i,e.add(h),this.meshs.push(h)}else h.geometry=a;h.userData={dragNormal:n.clone(),isMinFace:r,faceName:i};const d=new Float32Array([t[0].x,t[0].y,t[0].z,t[1].x,t[1].y,t[1].z,t[2].x,t[2].y,t[2].z,t[3].x,t[3].y,t[3].z,t[0].x,t[0].y,t[0].z]),g=new y.LineBasicMaterial({color:255}),u=new y.BufferGeometry;u.setAttribute("position",new y.BufferAttribute(d,3));let m=this.meshs.find(x=>x.name===i+"Line");m==null?(m=new y.Line(u,g),m.name=i+"Line",e.add(m),this.meshs.push(m)):(m.geometry=u,m.material=g);const f=new y.Vector3;t.forEach(x=>f.add(x)),f.multiplyScalar(1/t.length),this.updateFaceTransformControl(i,n,f,r);const p=this.engine.sectionPlane.find(x=>x.name==i);p&&p.setFromNormalAndCoplanarPoint(n.clone().setLength(-1),o)}}class Oy{engine;isActive=!1;isDrag=!1;isCtrlDown=!1;listenersAttached=!1;meshs=[];box=null;pickPoint=null;pickNormal=null;plane=null;angleX=0;angleY=0;angleZ=0;direction=1;normal=new y.Vector3(0,0,1);distance=0;center=null;current_center=null;dragStartDistance=0;idleOpacity=.02;hoverOpacity=.05;transformControl=null;transformAnchor=null;transformHelper=null;isSyncingTransformControl=!1;handleNativeMouseDown=e=>{if(e.button!==0||!(this.isCtrlDown||e.ctrlKey))return;const t=this.createRaycasterFromMouseEvent(e),n=t.intersectObjects(this.getInteractiveMeshes(),!1);n.length!==0&&(e.preventDefault(),e.stopImmediatePropagation(),this.handleMouseDown({button:e.button,raycaster:t,intersects:n}))};handleNativeMouseMove=e=>{if(!this.isDrag&&!(this.isCtrlDown||e.ctrlKey)){this.resetMeshOpacity();return}const t=this.createRaycasterFromMouseEvent(e),n=t.intersectObjects(this.getInteractiveMeshes(),!1);this.isDrag&&(e.preventDefault(),e.stopImmediatePropagation()),this.handleMouseMove({raycaster:t,intersects:n})};handleNativeMouseUp=e=>{e.button!==0||!this.isDrag||(e.preventDefault(),e.stopImmediatePropagation(),this.handleMouseUp({button:e.button}))};handleNativeKeyDown=e=>{e.key==="Control"&&(this.isCtrlDown=!0)};handleNativeKeyUp=e=>{e.key==="Control"&&(this.isCtrlDown=!1,this.isDrag&&this.handleMouseUp({button:0}),this.resetMeshOpacity())};handleTransformObjectChange=()=>{if(this.isSyncingTransformControl||!this.transformAnchor||!this.center)return;const e=this.normal.clone().normalize(),t=this.getDistanceRange(e),n=this.getTransformHandleOffset(),i=this.transformAnchor.position.clone().sub(this.center).dot(e)-n,r=Math.min(t.max,Math.max(t.min,i));Math.abs(r-Number(this.distance))>1e-5?this.updata_face(r):Math.abs(i-r)>1e-5&&this.updateTransformControl(e)};constructor(e){this.engine=e,this.meshs=[],this.box=null}active(){if(this.isActive==!0)return;this.isActive=!0,this.engine.scene.children.filter(t=>t.type=="Group"&&t.name=="ClippingBox").forEach(t=>{t.children.forEach(n=>{n.name.includes("face")&&(n.visible=!0)})}),this.attachListeners(),this.ensureTransformControl(),this.setTransformControlVisible(!0);const e=this;e.engine.scene.children.filter(t=>t.type=="Mesh"&&t.url).forEach(t=>{t.material&&Array.isArray(t.material)?t.material.forEach(n=>{n.clippingPlanes=e.engine.sectionPlane}):t.material.clippingPlanes=e.engine.sectionPlane,e.engine.clipping.clippingStencil?.addMesh(e.engine.sectionPlane.find(n=>n.name=="face"),t)}),this.init()}disActive(){this.init(),this.isActive=!1,this.detachListeners(),this.handleMouseUp({button:0}),this.setTransformControlVisible(!1);const e=this.engine.sectionPlane.find(t=>t.name=="face");e&&(e.constant=1e5),this.engine.scene.children.filter(t=>t.type=="Group"&&t.name=="ClippingBox").forEach(t=>{t.children.forEach(n=>{n.name.includes("face")&&(n.visible=!1)})})}init(e){const t=this.engine.octreeBox.getBoundingBox();this.box=t,this.distance=0,this.center=new y.Vector3((t.min.x+t.max.x)/2,(t.min.y+t.max.y)/2,(t.min.z+t.max.z)/2),this.current_center=this.center.clone(),!e&&this.updata_face(0)}disabled(){this.isActive=!1,this.detachListeners(),this.handleMouseUp({button:0}),this.setTransformControlVisible(!1),this.engine.scene.children.filter(e=>e.type=="Group"&&e.name=="ClippingBox").forEach(e=>{e.children.forEach(t=>{t.name.includes("face")&&(t.visible=!1)})})}recover(){this.isActive||(this.attachListeners(),this.setTransformControlVisible(!0),this.engine.scene.children.filter(e=>e.type=="Group"&&e.name=="ClippingBox").forEach(e=>{e.children.forEach(t=>{t.name.includes("face")&&(t.visible=!0)})}),this.isActive=!0)}setFaceAngle(e,t,n){this.angleX=e,this.angleY=t,this.angleZ=n,this.distance=0,this.normal=new y.Vector3(0,1,0).applyAxisAngle(new y.Vector3(1,0,0),e).applyAxisAngle(new y.Vector3(0,0,1),t).applyAxisAngle(new y.Vector3(0,1,0),n).normalize(),this.updata_face(0)}setFaceNormal(e,t=0){this.normal=e.clone().normalize(),this.distance=t,this.updata_face(t)}setFaceNormalPlaneOnly(e,t){if(this.normal=e.clone().normalize(),this.distance=t,!this.center||!this.box)return;const n=this.engine.sectionPlane?.find(i=>i.name==="face");if(n){const i=this.center.clone().add(this.normal.clone().multiplyScalar(t));n.setFromNormalAndCoplanarPoint(this.normal.clone().multiplyScalar(this.direction),i)}}activateClippingOnly(){if(this.isActive)return;this.isActive=!0;const e=this;e.engine.scene.children.filter(t=>t.type==="Mesh"&&t.url).forEach(t=>{t.material&&Array.isArray(t.material)?t.material.forEach(n=>{n.clippingPlanes=e.engine.sectionPlane}):t.material.clippingPlanes=e.engine.sectionPlane,e.engine.clipping.clippingStencil?.addMesh(e.engine.sectionPlane.find(n=>n.name==="face"),t)})}reverse(){this.direction=this.direction*-1,this.updata_face(this.distance)}getFaceAngle(){return{angleX:this.angleX,angleY:this.angleY,angleZ:this.angleZ,direction:this.direction}}updata_face(e){if(!this.box)return;this.distance=e;let t=this.engine.scene.children.find(_=>_.type=="Group"&&_.name=="ClippingBox");t==null&&(t=new y.Group,t.name="ClippingBox",this.engine.scene.add(t));const n=this.normal.clone().normalize(),i=this.center??new y.Vector3((this.box.min.x+this.box.max.x)/2,(this.box.min.y+this.box.max.y)/2,(this.box.min.z+this.box.max.z)/2);this.center=i.clone();const{tangent:r,bitangent:o}=this.getPlaneBasis(n),a=this.getBoxCorners(this.box),l=this.box.min.distanceTo(this.box.max),c=Math.max(l*.02,.01);let h=1/0,d=-1/0,g=1/0,u=-1/0;a.forEach(_=>{const b=_.clone().sub(i),S=b.dot(r),C=b.dot(o);h=Math.min(h,S),d=Math.max(d,S),g=Math.min(g,C),u=Math.max(u,C)}),h-=c,d+=c,g-=c,u+=c;const m=n.clone().multiplyScalar(e),f=i.clone().add(r.clone().multiplyScalar(h)).add(o.clone().multiplyScalar(g)).add(m),p=i.clone().add(r.clone().multiplyScalar(d)).add(o.clone().multiplyScalar(g)).add(m),x=i.clone().add(r.clone().multiplyScalar(d)).add(o.clone().multiplyScalar(u)).add(m),v=i.clone().add(r.clone().multiplyScalar(h)).add(o.clone().multiplyScalar(u)).add(m);this.current_center=i.clone().add(m),this.createFace(t,[f,p,x,v],n,"face"),this.updateTransformControl(n)}createFace(e,t,n,i){const r=new y.BufferGeometry,o=new Float32Array([t[0].x,t[0].y,t[0].z,t[1].x,t[1].y,t[1].z,t[2].x,t[2].y,t[2].z,t[3].x,t[3].y,t[3].z]),a=[0,1,2,0,2,3];r.setAttribute("position",new y.BufferAttribute(o,3)),r.setIndex(a);let l=this.meshs.find(m=>m.name==i);if(l==null){const m=new y.MeshBasicMaterial({color:65280,transparent:!0,opacity:this.idleOpacity,side:y.DoubleSide});m.polygonOffset=!0,m.polygonOffsetFactor=1,m.polygonOffsetUnits=4,l=new y.Mesh(r,m),l.name=i,e.add(l),this.meshs.push(l)}else l.geometry=r;l.normal=n.clone();const c=new Float32Array([t[0].x,t[0].y,t[0].z,t[1].x,t[1].y,t[1].z,t[2].x,t[2].y,t[2].z,t[3].x,t[3].y,t[3].z,t[0].x,t[0].y,t[0].z]),h=new y.LineBasicMaterial({color:255}),d=new y.BufferGeometry;d.setAttribute("position",new y.BufferAttribute(c,3));let g=this.meshs.find(m=>m.name==i+"Line");g==null?(g=new y.Line(d,h),g.name=i+"Line",e.add(g),this.meshs.push(g)):(g.geometry=d,g.material=h);const u=this.engine.sectionPlane.find(m=>m.name==i);u&&this.current_center&&u.setFromNormalAndCoplanarPoint(n.clone().setLength(this.direction),this.current_center)}getPlaneBasis(e){const t=new y.Vector3(1,0,0),n=new y.Vector3(0,1,0),i=new y.Vector3(0,0,1),r=Math.abs(e.dot(t)),o=Math.abs(e.dot(n)),a=Math.abs(e.dot(i));let l=t;o<=r&&o<=a?l=n:a<=r&&a<=o&&(l=i),l=l.clone().sub(e.clone().multiplyScalar(l.dot(e))).normalize();const c=new y.Vector3().crossVectors(e,l).normalize();return{tangent:l,bitangent:c}}getBoxCorners(e){return[new y.Vector3(e.min.x,e.min.y,e.min.z),new y.Vector3(e.min.x,e.min.y,e.max.z),new y.Vector3(e.min.x,e.max.y,e.min.z),new y.Vector3(e.min.x,e.max.y,e.max.z),new y.Vector3(e.max.x,e.min.y,e.min.z),new y.Vector3(e.max.x,e.min.y,e.max.z),new y.Vector3(e.max.x,e.max.y,e.min.z),new y.Vector3(e.max.x,e.max.y,e.max.z)]}getDistanceRange(e){if(!this.box)return{min:0,max:0};const t=this.center??new y.Vector3((this.box.min.x+this.box.max.x)/2,(this.box.min.y+this.box.max.y)/2,(this.box.min.z+this.box.max.z)/2),n=this.getBoxCorners(this.box);let i=1/0,r=-1/0;return n.forEach(o=>{const a=o.clone().sub(t).dot(e);i=Math.min(i,a),r=Math.max(r,a)}),{min:i,max:r}}getInteractiveMeshes(){return this.meshs.filter(e=>e.type==="Mesh")}getTransformHandleOffset(){if(!this.box)return .06;const e=this.box.min.distanceTo(this.box.max);return Math.max(e*.015,.06)}keepSingleDirectionArrow(e,t="X"){const n=e.getHelper(),i=[];n.traverse(r=>{if(r?.name!==t||!r.geometry)return;const o=r.geometry;o.boundingBox||o.computeBoundingBox();const a=o.boundingBox;if(!a)return;const l=a.getCenter(new y.Vector3);if(!(t==="X"&&l.x<0||t==="Y"&&l.y<0||t==="Z"&&l.z<0))return;const h=o.parameters,d=h&&h.radiusTop===0&&h.radiusBottom===.04&&h.height===.1,g=h&&h.radiusTop===.2&&h.radiusBottom===0&&h.height===.6;(d||g)&&i.push(r)}),i.forEach(r=>{r.parent?.remove(r)})}ensureTransformControl(){if(this.transformControl&&this.transformAnchor)return;const e=this.engine.renderer?.domElement,t=this.engine.camera;if(!e||!t)return;const n=new y.Object3D;n.name="SectionFaceTransformAnchor",n.visible=this.isActive,this.engine.scene.add(n);const i=new cd(t,e);i.name="SectionFaceTransformControl",i.setMode("translate"),i.setSpace("local"),i.showX=!0,i.showY=!1,i.showZ=!1,i.size=.85,i.enabled=this.isActive,i.attach(n),this.keepSingleDirectionArrow(i,"X"),i.addEventListener("dragging-changed",o=>{this.engine.controls.enabled=!o.value}),i.addEventListener("objectChange",this.handleTransformObjectChange);const r=i.getHelper();r.visible=this.isActive,this.engine.scene.add(r),this.transformAnchor=n,this.transformControl=i,this.transformHelper=r}setTransformControlVisible(e){this.ensureTransformControl(),this.transformControl&&(this.transformControl.enabled=e),this.transformHelper&&(this.transformHelper.visible=e),this.transformAnchor&&(this.transformAnchor.visible=e),e||(this.engine.controls.enabled=!0)}updateTransformControl(e){if(this.ensureTransformControl(),!this.transformControl||!this.transformAnchor||!this.current_center)return;const t=this.getTransformHandleOffset(),n=this.current_center.clone().add(e.clone().setLength(t)),i=new y.Quaternion().setFromUnitVectors(new y.Vector3(1,0,0),e.clone().normalize());this.isSyncingTransformControl=!0,this.transformAnchor.position.copy(n),this.transformAnchor.quaternion.copy(i),this.transformAnchor.visible=this.isActive,this.transformControl.object!==this.transformAnchor&&this.transformControl.attach(this.transformAnchor),this.transformControl.enabled=this.isActive,this.transformHelper&&(this.transformHelper.visible=this.isActive),this.isSyncingTransformControl=!1}createRaycasterFromMouseEvent(e){const t=new y.Raycaster,n=new y.Vector2,i=this.engine.renderer.domElement.clientWidth,r=this.engine.renderer.domElement.clientHeight;return n.x=e.offsetX/i*2-1,n.y=-(e.offsetY/r)*2+1,t.setFromCamera(n,this.engine.camera),t}attachListeners(){if(this.listenersAttached)return;const e=this.engine.renderer?.domElement;e&&(e.addEventListener("mousedown",this.handleNativeMouseDown,!0),e.addEventListener("mousemove",this.handleNativeMouseMove,!0),e.addEventListener("mouseup",this.handleNativeMouseUp,!0),window.addEventListener("keydown",this.handleNativeKeyDown),window.addEventListener("keyup",this.handleNativeKeyUp),this.listenersAttached=!0)}detachListeners(){if(!this.listenersAttached)return;const e=this.engine.renderer?.domElement;e&&(e.removeEventListener("mousedown",this.handleNativeMouseDown,!0),e.removeEventListener("mousemove",this.handleNativeMouseMove,!0),e.removeEventListener("mouseup",this.handleNativeMouseUp,!0)),window.removeEventListener("keydown",this.handleNativeKeyDown),window.removeEventListener("keyup",this.handleNativeKeyUp),this.listenersAttached=!1,this.isCtrlDown=!1}resetMeshOpacity(){this.getInteractiveMeshes().forEach(e=>{e.material&&(e.material.opacity=this.idleOpacity)})}handleMouseDown(e){const t=e.intersects??e.raycaster.intersectObjects(this.getInteractiveMeshes(),!1);if(t!=null&&t.length>0){const n=t[0],i=n.point.clone();this.isDrag=!0,this.pickPoint=i;const o=(n.face?.normal?.clone()??this.normal.clone()).clone();if(o.dot(this.normal)<0&&o.multiplyScalar(-1),o.normalize(),this.pickNormal=o,this.engine.controls.enabled=!1,this.dragStartDistance=Number(this.distance)||0,o.y==0){const a=new y.Plane;a.setFromNormalAndCoplanarPoint(new y.Vector3(0,1,0),i),this.plane=a}else{const a=new y.Vector3(this.engine.camera.position.x,i.y,this.engine.camera.position.z),l=new y.Plane;l.setFromNormalAndCoplanarPoint(a.clone().sub(i.clone()).setLength(1),i),this.plane=l}}else this.isDrag=!1}handleMouseUp(e){this.isDrag=!1,this.pickPoint=null,this.pickNormal=null,this.plane=null,this.engine.controls.enabled=!0}handleMouseMove(e){this.resetMeshOpacity();const t=e.intersects??e.raycaster.intersectObjects(this.getInteractiveMeshes(),!1);t!=null&&t.length>0&&(t[0].object.material.opacity=this.hoverOpacity);const n=this.pickPoint,i=this.pickNormal,r=this.plane;if(n!=null&&i!=null&&r!=null){const o=new y.Vector3;if(e.raycaster.ray.intersectPlane(r,o)){const a=o.clone().sub(n.clone()).dot(i.clone()),l=this.getDistanceRange(this.normal.clone().normalize()),c=this.dragStartDistance+a;this.distance=Math.min(l.max,Math.max(l.min,c)),this.updata_face(this.distance)}}}}class ky{engine;callback_;constructor(e){this.engine=e}init(){this.engine.handelBehaved.init(this,{showCatch:!0}),this.engine.handelBehaved.active()}catch_face(e){this.callback_=e}handleMouseMove(e){}handleMouseClick(e){if(!e.catch?.normal||!e.catch?.point)return;let t=e.catch.normal.setLength(-1);this.engine.handelBehaved.disActive(),this.callback_({dir:t,position:e.catch.point})}}class By{engine;clippingTolerance=1e-4;sectionBox;sectionFace;clippingStencil;currentClippingMode="";constructor(e){this.engine=e;let t=new y.Plane(new y.Vector3(0,0,1),1e5);t.name="前";let n=new y.Plane(new y.Vector3(0,0,1),1e5);n.name="左";let i=new y.Plane(new y.Vector3(0,0,1),1e5);i.name="后";let r=new y.Plane(new y.Vector3(0,0,1),1e5);r.name="右";let o=new y.Plane(new y.Vector3(0,0,1),1e5);o.name="顶";let a=new y.Plane(new y.Vector3(0,0,1),1e5);a.name="底";let l=new y.Plane(new y.Vector3(0,0,1),1e5);l.name="face",this.engine.sectionPlane=[t,n,i,r,o,a,l]}init(){this.sectionBox=new Fy(this.engine),this.sectionFace=new Oy(this.engine)}scaleBox(){let e=this.engine.octreeBox.getBoundingBox();this.sectionBox.setBox(e)}clippingModel(e){let t=[];e.forEach(r=>{let o=this.engine.models.find(a=>a.url===r.url);r.ids.forEach(a=>{o.nodesMap.get(a).infos.forEach(l=>{t.push(l.box)})})}),this.active("box");let n=i(t);this.sectionBox.setBox(n);function i(r){let o=new y.Vector3(1e8,1e9,1e10),a=new y.Vector3(-1e8,-1e9,-1e10);return r.forEach(l=>{l.min.x<o.x&&(o.x=l.min.x),l.min.y<o.y&&(o.y=l.min.y),l.min.z<o.z&&(o.z=l.min.z),l.max.x>a.x&&(a.x=l.max.x),l.max.y>a.y&&(a.y=l.max.y),l.max.z>a.z&&(a.z=l.max.z)}),new y.Box3(o,a)}}updateClippingValue(e){let t=this.sectionBox.maxBox,n=t.min.x+(t.max.x-t.min.x)*e.x.min*.01,i=t.min.y+(t.max.y-t.min.y)*e.y.min*.01,r=t.min.z+(t.max.z-t.min.z)*e.z.min*.01,o=t.min.x+(t.max.x-t.min.x)*e.x.max*.01,a=t.min.y+(t.max.y-t.min.y)*e.y.max*.01,l=t.min.z+(t.max.z-t.min.z)*e.z.max*.01;this.sectionBox.setboxXyz({minX:n,minY:i,minZ:r,maxX:o,maxY:a,maxZ:l})}active(e){if(this.engine.engineStatus.isForceFree=!0,this.sectionFace.disActive(),this.sectionBox.disActive(),this.currentClippingMode=e,e=="x")this.sectionFace.init(),this.sectionFace.active(),this.sectionFace.setFaceAngle(Math.PI/2,0,0);else if(e=="y")this.sectionFace.init(),this.sectionFace.active(),this.sectionFace.setFaceAngle(0,Math.PI/2,0);else if(e=="z")this.sectionFace.init(),this.sectionFace.active(),this.sectionFace.setFaceAngle(0,0,Math.PI/2);else if(e=="box")this.sectionBox.init(),this.sectionBox.active();else if(e=="face"){let t=new ky(this.engine);t.init(),t.catch_face(n=>{this.sectionFace.init(),this.sectionFace.active();let i=this.engine.octreeBox.getBoundingBox(),r=i.min.clone().add(i.max.clone()).multiplyScalar(.5),o=n.position.clone().sub(r),a=new y.Vector3(n.dir.x,n.dir.y,n.dir.z),l=o.dot(a);this.sectionFace.setFaceNormal(n.dir,l)})}}disabled(){this.currentClippingMode=="box"?this.sectionBox.disabled():this.sectionFace.disabled(),this.engine.engineStatus.isForceFree=!1}recover(){this.currentClippingMode=="box"?this.sectionBox.recover():this.sectionFace.recover()}reverse(){this.sectionFace.reverse()}disActive(){this.sectionFace.disActive(),this.sectionBox.disActive(),this.currentClippingMode="",this.engine.engineStatus.isForceFree=!1}isPointInClippingRange(e,t=this.clippingTolerance){if(!this.isVector3Like(e))return!1;const n=this.getEffectiveClippingPlanes();return n.length===0?!0:n.every(i=>i.distanceToPoint(e)>=-t)}filterIntersectionsByClipping(e,t=this.clippingTolerance){return!Array.isArray(e)||e.length===0?[]:e.filter(n=>this.isPointInClippingRange(n?.point,t))}getEffectiveClippingPlanes(){const e=Array.isArray(this.engine.sectionPlane)?this.engine.sectionPlane:[];if(this.currentClippingMode==="box")return e.slice(0,6).filter(t=>t instanceof y.Plane);if(this.currentClippingMode==="x"||this.currentClippingMode==="y"||this.currentClippingMode==="z"||this.currentClippingMode==="face"){const t=e[6];return t instanceof y.Plane?[t]:[]}return[]}isVector3Like(e){return e!=null&&typeof e.x=="number"&&typeof e.y=="number"&&typeof e.z=="number"}setSectionByView(e,t){this.sectionFace.disActive(),this.sectionBox.disActive(),this.scaleBox(),this.sectionFace.init(!0);const n=this.engine.octreeBox.getBoundingBox(),i=new y.Vector3((n.min.x+n.max.x)/2,(n.min.y+n.max.y)/2,(n.min.z+n.max.z)/2),o=new y.Vector3(t.x,t.y,t.z).normalize().clone().negate(),l=new y.Vector3(e.x,e.y,e.z).clone().sub(i).dot(o);this.sectionFace.setFaceNormalPlaneOnly(o,l),this.sectionFace.activateClippingOnly(),this.currentClippingMode="face"}}class zy{engine;constructor(e){this.engine=e}getLevelTreeData(){let e=[];return this.engine.engineStatus.models.forEach(t=>{e.push({children:t.info.modelTree.modelTreeLevel,name:t.info.baseInfo.name,url:t.url})}),e}getTypeTreeData(){let e=[];return this.engine.engineStatus.models.forEach(t=>{e.push({children:t.info.modelTree.modelTreeType,name:t.info.baseInfo.name,url:t.url})}),e}getMajorTreeData(){let e=[];return this.engine.engineStatus.models.forEach(t=>{e.push({children:t.info.modelTree.modelTreeMajor,name:t.info.baseInfo.name,url:t.url})}),e}}class Vy{engine;constructor(e){this.engine=e}getEngineInfo(){let e=0,t=0,n=0;return!this.engine||!this.engine.scene?{totalVertices:0,totalTriangles:0,meshCount:0}:(this.engine.scene.traverse(i=>{if(i instanceof y.Mesh){const r=i.geometry;if(r&&r.attributes){const o=r.attributes.position;if(o){const a=o.count;e+=a;let l=0;r.index?l=r.index.count/3:l=a/3,t+=l}}}}),this.engine.engineStatus.models.forEach(i=>{n=n+(Array.isArray(i?.info?.modelEdge)?i.info.modelEdge.length:0)}),{totalVertices:Math.floor(e),totalTriangles:Math.floor(t),meshCount:n})}}class Gy{engine;constructor(e){this.engine=e}init(){}getModelPropertiesWithName(e,t,n,i){let r=this.engine.engineStatus.models.find(a=>a.url===e);r.properties==null?Es(e+"/property",a=>{let l=JSON.parse(a);r.properties=l,setTimeout(()=>{o(l,n,t,i)},100)}):o(r.properties,n,t,i);function o(a,l,c,h){let d={};a.models[c.toString()||""].forEach(u=>{n.includes(a.names[u[1]])&&(d[a.names[u[1]]]=a.values[u[2]])}),h?.({id:c,properties:d})}}getModelProperties(e,t,n){let i=this.engine.engineStatus.models.find(o=>o.url===e);i.properties==null&&Es(e+"/property",o=>{let a=JSON.parse(o);i.properties=a,setTimeout(()=>{r(a,t,n)},100)}),r(i.properties,t,n);function r(o,a,l){let c=[],h=o.models[a.toString()||""],d=h.map(g=>g[0]);d=d.filter((g,u)=>d.indexOf(g)===u),d.forEach(g=>{let u={name:o.categorys[g],children:[]};c.push(u),h.filter(m=>m[0]===g).forEach(m=>{u.children.push({name:o.names[m[1]],value:o.values[m[2]]})})}),l?.({properties:c,materials:c})}}}class Wy{engine;constructor(e){this.engine=e}getModelTypes(){let e=[];return this.engine.engineStatus.models.forEach(t=>{t.info.modelMapper.forEach(i=>{e.push(i.typeName)})}),e=e.filter((t,n,i)=>i.indexOf(t)===n),e}getModelMajors(){let e=[];return this.engine.engineStatus.models.forEach(t=>{t.info.modelMapper.forEach(i=>{e.push(i.majorName)})}),e=e.filter((t,n,i)=>i.indexOf(t)===n),e}getModelLevels(){let e=[];return this.engine.engineStatus.models.forEach(t=>{t.info.modelMapper.forEach(i=>{e.push(i.levelName)})}),e=e.filter((t,n,i)=>i.indexOf(t)===n),e}getModelMappers(e){}getModelMapper(e,t){let n=this.engine.engineStatus.models.find(o=>o.url==e);return n?n.info.modelMapper.find(o=>o.id==t):null}getModelsWithLevelType(e,t,n=null){let i=[];return this.engine.engineStatus.models.forEach(r=>{let o={url:r.url,ids:[]};i.push(o),r.info.modelMapper.filter(l=>l.levelName===e&&l.typeName===t).forEach(l=>{o.ids.push(Number(l.id))})}),n&&n(i),i}getModelsWithType(e,t=null){let n=[];return this.engine.engineStatus.models.forEach(i=>{let r={url:i.url,ids:[]};n.push(r),i.info.modelMapper.filter(a=>a.typeName===e).forEach(a=>{r.ids.push(Number(a.id))})}),t&&t(n),n}getModelsWithLevel(e,t){let n=[];return this.engine.engineStatus.models.forEach(i=>{let r={url:i.url,ids:[]};n.push(r),i.info.modelMapper.filter(a=>a.levelName===e).forEach(a=>{r.ids.push(Number(a.id))})}),t&&t(n),n}getModelsWithMajor(e,t){let n=[];return this.engine.engineStatus.models.forEach(i=>{let r={url:i.url,ids:[]};n.push(r),i.info.modelMapper.filter(a=>a.majorName===e).forEach(a=>{r.ids.push(Number(a.id))})}),t&&t(n),n}}class Hy{engine;isActive=!1;groupEdge;material;modelEdgeLoaded=!1;modelEdgeLoadingPromise=null;indexes=new Map;constructor(e){this.engine=e,this.groupEdge=this.engine.scene.getObjectByName("groupEdge"),this.material=new y.LineBasicMaterial({color:"#000000",depthTest:!0,transparent:!0,opacity:.3}),this.material.clippingPlanes=this.engine.sectionPlane}active(){this.isActive=!0,this.groupEdge.visible=!0,this.engine.scene.traverse(e=>{e.isMesh&&e.material&&(Array.isArray(e.material)?e.material:[e.material]).forEach(n=>{n.polygonOffset=!0,n.polygonOffsetFactor=1,n.polygonOffsetUnits=4})}),this.show()}disActive(){this.isActive=!1,this.groupEdge.visible=!1,this.engine.scene.traverse(e=>{e.isMesh&&e.material&&(Array.isArray(e.material)?e.material:[e.material]).forEach(n=>{n.polygonOffset=!1})})}hasPendingModelEdges(){return(this.engine?.engineStatus?.models??[]).some(t=>!this.indexes.has(t.url))}loadZipJsonAsync(e){return new Promise((t,n)=>{Es(e,i=>{if(i==null){n(new Error(`[ModelEdge] empty edge zip: ${e}`));return}t(i)},()=>{n(new Error(`[ModelEdge] failed to load edge zip: ${e}`))})})}async ensureModelEdgeData(e){const t=e?.info??{};if(Array.isArray(t.modelEdge))return t.modelEdge;try{const n=await this.loadZipJsonAsync(e.url+"/edge"),i=JSON.parse(n);t.modelEdge=Array.isArray(i)?i:[]}catch(n){console.error("[ModelEdge] failed to load model edge",{url:e?.url,error:n}),t.modelEdge=[]}return t.modelEdge}async loadModelEdge(){if(!(this.modelEdgeLoaded&&!this.hasPendingModelEdges())){if(this.modelEdgeLoadingPromise!=null){await this.modelEdgeLoadingPromise;return}this.modelEdgeLoadingPromise=(async()=>{const e=this.engine?.engineStatus?.models??[];for(const t of e){if(this.indexes.has(t.url))continue;const n=await this.ensureModelEdgeData(t),i=[],r=new Map;n.forEach(o=>{if(!Array.isArray(o?.points))return;const a=i.length;for(let l=0;l<o.points.length;l++)o.points[l]?.length===2&&(i.push(o.points[l][0].X),i.push(o.points[l][0].Z),i.push(-o.points[l][0].Y),i.push(o.points[l][1].X),i.push(o.points[l][1].Z),i.push(-o.points[l][1].Y));r.set(Number(o.id),[a,i.length,o.points])}),this.indexes.set(t.url,r)}this.modelEdgeLoaded=!this.hasPendingModelEdges()})().finally(()=>{this.modelEdgeLoadingPromise=null}),await this.modelEdgeLoadingPromise}}async show(){await this.loadModelEdge(),this.isActive&&this.indexes.forEach((e,t)=>{const n=this.groupEdge.children.find(a=>a.url==t);if(n){n.visible=!0;return}const i=[];if(e.forEach(a=>{a[2].forEach(l=>{l?.length===2&&(i.push(l[0].X),i.push(l[0].Z),i.push(-l[0].Y),i.push(l[1].X),i.push(l[1].Z),i.push(-l[1].Y))})}),i.length===0)return;const r=new y.BufferGeometry;r.setAttribute("position",new y.Float32BufferAttribute(i,3));const o=new y.LineSegments(r,this.material);o.url=t,this.groupEdge.add(o)})}getModelEdge(e,t){const n=this.indexes.get(e);if(n){const i=n.get(Number(t));if(i)return i.slice()}return this.loadModelEdge(),null}hideModelEdge(e,t){const n=this.indexes.get(e);if(!n){this.loadModelEdge();return}const i=n.get(Number(t));if(i){const[r,o]=i,a=this.groupEdge.children.find(l=>l.url==e);if(a){const l=a.geometry.attributes.position.array;for(let c=r;c<o;c++)l[c]=NaN;a.geometry.attributes.position.needsUpdate=!0}}}setOpacity(e){this.material.opacity=e}showModelEdge(e,t){const n=this.indexes.get(e);if(!n){this.loadModelEdge();return}const i=n.get(Number(t));if(i){const[r,o,a]=i,l=this.groupEdge.children.find(c=>c.url==e);if(l){const c=l.geometry.attributes.position.array;let h=0;for(let d=r;d<o;d+=3){const g=Math.floor(h/6),u=h%6>=3;if(a[g]&&a[g].length===2){const m=u?a[g][1]:a[g][0];c[d]=m.X,c[d+1]=m.Z,c[d+2]=-m.Y}h+=3}l.geometry.attributes.position.needsUpdate=!0}}}}class Xy{config;constructor(e){this.config={temperature:.7,maxTokens:2e4,timeout:3e5,...e}}async chat(e){const t=new AbortController,n=setTimeout(()=>t.abort(),this.config.timeout);try{const i=await fetch(`${this.config.baseURL}/chat/completions`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.config.apiKey}`},body:JSON.stringify({model:this.config.model,messages:e,temperature:this.config.temperature,max_tokens:this.config.maxTokens,stream:!1}),signal:t.signal});if(clearTimeout(n),!i.ok){const o=await i.json().catch(()=>({}));throw new Error(`API请求失败 (${i.status}): ${o.error?.message||o.message||i.statusText}`)}return(await i.json()).choices?.[0]?.message?.content||""}catch(i){throw clearTimeout(n),i.name==="AbortError"?new Error("请求超时,请重试"):i.message.includes("Failed to fetch")?new Error(`网络请求失败,请检查:
|
|
4945
4945
|
1. 网络连接
|
|
4946
4946
|
2. API地址是否正确
|
|
4947
4947
|
3. 是否有CORS限制`):i}}async chatStream(e,t){const n=new AbortController,i=setTimeout(()=>n.abort(),this.config.timeout);try{const r=await fetch(`${this.config.baseURL}/chat/completions`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.config.apiKey}`},body:JSON.stringify({model:this.config.model,messages:e,temperature:this.config.temperature,max_tokens:this.config.maxTokens,stream:!0}),signal:n.signal});if(clearTimeout(i),!r.ok){const c=await r.json().catch(()=>({}));throw new Error(`API请求失败 (${r.status}): ${c.error?.message||c.message||r.statusText}`)}const o=r.body?.getReader();if(!o)throw new Error("无法读取响应流");const a=new TextDecoder;let l="";for(;;){const{done:c,value:h}=await o.read();if(c){t("",!0);break}l+=a.decode(h,{stream:!0});const d=l.split(`
|
|
@@ -5372,7 +5372,7 @@ ${JSON.stringify(l,null,2)}
|
|
|
5372
5372
|
<path d="M2 2L14 14" stroke="currentColor" stroke-width="1.2"/>
|
|
5373
5373
|
<path d="M8 3C4.5 3 1.5 8 1.5 8C2.2 9.3 3.3 10.5 4.5 11.5" stroke="currentColor" stroke-width="1.2"/>
|
|
5374
5374
|
<path d="M11.5 11.5C12.7 10.5 13.8 9.3 14.5 8C14.5 8 11.5 3 8 3" stroke="currentColor" stroke-width="1.2"/>
|
|
5375
|
-
</svg>`}_colorToHex(e){return"#"+e.toString(16).padStart(6,"0")}_makeDraggable(e,t){t.onmousedown=n=>{n.preventDefault();const i=e.getBoundingClientRect(),r=e.offsetParent?.getBoundingClientRect()??{left:0,top:0};e.style.left=i.left-r.left+"px",e.style.top=i.top-r.top+"px",e.style.right="auto",e.style.bottom="auto";const o=n.clientX-i.left,a=n.clientY-i.top,l=h=>{e.style.left=h.clientX-o-r.left+"px",e.style.top=h.clientY-a-r.top+"px"},c=()=>{document.removeEventListener("mousemove",l),document.removeEventListener("mouseup",c)};document.addEventListener("mousemove",l),document.addEventListener("mouseup",c)}}dispose(){this.panel?.remove(),this.panel=null,this.listEl=null}}class vd{engine;layerMap=new Map;panelUI=null;constructor(e){this.engine=e;const t=document.getElementById(e?.options?.containerId??"")??e?.container??null;t&&(this.panelUI=new xM(t,this))}_loadLayers(){let e=this.engine.dwgData.layers;this.layerMap.clear();for(const t of e)this.layerMap.set(t.name,{...t}),this.panelUI?.refresh()}syncFromModel(e){e?.length>0&&(this._loadLayers(e),this.panelUI?.refresh())}getLayers(){return Array.from(this.layerMap.values())}setLayerVisible(e,t){const n=this.layerMap.get(e);n&&(n.visible=t),this._applyVisibility(e,t)}toggleLayer(e){const t=this.layerMap.get(e);if(!t)return!0;const n=!t.visible;return this.setLayerVisible(e,n),n}setAllLayersVisible(e){for(const t of this.layerMap.keys()){const n=this.layerMap.get(t);n.visible=e,this._applyVisibility(t,e)}}isAllVisible(){return Array.from(this.layerMap.values()).every(e=>e.visible)}_applyVisibility(e,t){const n=this.engine?.scene;if(!n)return;const i=e+"||";n.children.forEach(r=>{r.name?.startsWith(i)&&(r.visible=t)})}show(){this.panelUI?.show()}hide(){this.panelUI?.hide()}toggle(){this.panelUI?.toggle()}dispose(){this.panelUI?.dispose(),this.panelUI=null,this.layerMap.clear()}}class _d{engine;data=null;enableValidation=!0;constructor(e){for(this.engine=e,this.engine.modelGroup=new y.Group,this.engine.modelGroup.name="model2d",this.engine.scene.add(this.engine.modelGroup);this.engine.modelGroup.children.length>0;)this.engine.modelGroup.remove(this.engine.modelGroup.children[0])}async loadModel(e,t={}){if(!e.includes(".json"))this.engine.events&&this.engine.events.trigger(Zt.ModelLoadStart,{url:e}),Es(e,async n=>{const i=JSON.parse(n);this.engine.dwgData=i,this.data=i,await this.buildScene(i);try{this.engine.fitToView()}catch{}this.engine.layerManager||(this.engine.layerManager=new vd(this.engine)),this.engine.layerManager._loadLayers(),this.engine.events&&this.engine.events.trigger(Zt.ModelLoaded,{})},n=>{this._emitProgress(0,"抱歉,图纸加载失败")});else{this.engine.events&&this.engine.events.trigger(Zt.ModelLoadStart,{url:e}),this._emitProgress(10,"请求数据...");const n=await this.fetchJson(e);this._emitProgress(20,"解析数据...");const i=this.parseData(n);if(this.engine.dwgData=i,!i)throw new Error("Failed to parse DWG data");this.data=i,await this.buildScene(i),this.engine.fitToView(),this.engine.layerManager._loadLayers(),this.engine.events&&this.engine.events.trigger(Zt.ModelLoaded,{})}}async fetchJson(e){const t=await fetch(e);if(!t.ok)throw new Error(`HTTP error! status: ${t.status}`);return await t.json()}parseData(e){return e?this.enableValidation&&!this.validateDataStructure(e)?(console.error("[LoaderModule2d] Invalid data structure"),null):e:(console.error("[LoaderModule2d] Empty JSON data"),null)}validateDataStructure(e){return e.version||console.warn("[LoaderModule2d] Missing version"),e.metadata||console.warn("[LoaderModule2d] Missing metadata"),Array.isArray(e.layers)?Array.isArray(e.entities)?!0:(console.error("[LoaderModule2d] Invalid or missing entities array"),!1):(console.error("[LoaderModule2d] Invalid or missing layers array"),!1)}model={};totalBlock=new Map;font=null;async loadFont(){const e=this.engine.options?.fontUrl??"/fonts/simfang.ttf",t=await Us.fromUrl(e);return Us.toThreeFont(t)}_emitProgress(e,t){this.engine.events&&this.engine.events.trigger(Zt.ModelLoadProgress,{progress:e,text:t})}async buildScene(e){this._emitProgress(10,"正在加载"),this.font=await this.loadFont(),this.model.layers=e.layers,this.model.modelMap=new Map,this.model.hatchMap=new Map,this.model.textMap=new Map,this.model.nodeMap=new Map,console.log(this.model.layers),this._emitProgress(10,"正在加载..."),await Promise.resolve(),e.blocks.forEach(t=>{this.loadBlock(t,t.name,!0)}),this._emitProgress(10,"正在加载..."),await Promise.resolve(),this.loadBlock({entities:e.entities},"",!1),this._emitProgress(10,"正在加载..."),await Promise.resolve(),this.model.modelMap.forEach((t,n)=>{let i=[];if(t.forEach(o=>{for(const a of o)i.push(a)}),i.length!=0){const o=new y.BufferGeometry().setFromPoints(i);let a=parseInt(n.split("||")[1]);if(a==0){var r=this.model.layers.find(d=>d.name==n.split("||")[0]);a=r.color}const l=new y.LineBasicMaterial({color:a}),c=new y.LineSegments(o,l);c.name=n,c.clonePoints=[],i.forEach(d=>{c.clonePoints.push(d.x),c.clonePoints.push(d.y),c.clonePoints.push(d.z)}),c.materialClone=l.clone(),this.engine.modelGroup.add(c);let h=0;t.forEach((d,g)=>{this.model.nodeMap.has(g)?this.model.nodeMap.get(g).push({indexes:[this.engine.modelGroup.children.length-1,h,h+d.length*3],min:new y.Vector3(Math.min(...d.map(u=>u.x)),Math.min(...d.map(u=>u.y)),0),max:new y.Vector3(Math.max(...d.map(u=>u.x)),Math.max(...d.map(u=>u.y)),0)}):this.model.nodeMap.set(g,[{indexes:[this.engine.modelGroup.children.length-1,h,h+d.length*3],min:new y.Vector3(Math.min(...d.map(u=>u.x)),Math.min(...d.map(u=>u.y)),0),max:new y.Vector3(Math.max(...d.map(u=>u.x)),Math.max(...d.map(u=>u.y)),0)}]),h=h+d.length*3})}}),this._emitProgress(85,"正在加载..."),await Promise.resolve(),this.model.textMap.forEach((t,n)=>{const i=Mi(t.map(c=>c.geometry),!1);let r=Number.parseInt(n.split("||")[1]);if(r===0){const c=this.model.layers.find(h=>h.name===n.split("||")[0]);c&&(r=c.color)}const o=new y.MeshBasicMaterial({color:r,side:y.DoubleSide});n.includes("_hitbox")&&(o.visible=!1);let a=new y.Mesh(i,o);a.name=n,a.materialClone=o.clone(),a.isSplit=!1,a.geometrys=t.map(c=>c.geometry),this.engine.modelGroup.add(a);let l=0;t.forEach(c=>{this.model.nodeMap.has(c.info.linkId)?this.model.nodeMap.get(c.info.linkId).push({indexes:[this.engine.modelGroup.children.length-1,l++],min:new y.Vector3(c.info.min[0],c.info.min[1],0),max:new y.Vector3(c.info.max[0],c.info.max[1],0)}):this.model.nodeMap.set(c.info.linkId,[{indexes:[this.engine.modelGroup.children.length-1,l++],min:new y.Vector3(c.info.min[0],c.info.min[1],0),max:new y.Vector3(c.info.max[0],c.info.max[1],0)}])})}),this._emitProgress(93,"正在加载..."),await Promise.resolve(),this.model.hatchMap.forEach((t,n)=>{let i=Mi(t.map(h=>h.geometry),!1),r=parseInt(n.split("||")[1]);if(r==0){var o=this.model.layers.find(h=>h.name==n.split("||")[0]);r=o.color}const a=new y.MeshBasicMaterial({color:r,side:y.DoubleSide,transparent:!0,opacity:.5});let l=new y.Mesh(i,a);l.name=n,l.materialClone=a.clone(),l.isSplit=!1,l.geometrys=t.map(h=>h.geometry),this.engine.modelGroup.add(l);let c=0;t.forEach(h=>{this.model.nodeMap.has(h.info.linkId)?this.model.nodeMap.get(h.info.linkId).push({indexes:[this.engine.modelGroup.children.length-1,c++],min:new y.Vector3(h.info.min[0],h.info.min[1],0),max:new y.Vector3(h.info.max[0],h.info.max[1],0)}):this.model.nodeMap.set(h.info.linkId,[{indexes:[this.engine.modelGroup.children.length-1,c++],min:new y.Vector3(h.info.min[0],h.info.min[1],0),max:new y.Vector3(h.info.max[0],h.info.max[1],0)}])})}),this._emitProgress(100,"加载完成")}loadBlock(e,t,n,i=0){let r=[0,0,0];n&&(r=e.origin),e.entities.forEach(o=>{const a=o.layer+"||"+o.color;let l=new Map;n?(l=this.totalBlock.get(t),l==null&&(l=new Map,this.totalBlock.set(t,l))):(l=this.model.modelMap.get(a),l==null&&(l=new Map,this.model.modelMap.set(a,l)));let c=[];switch(o.type){case"LINE":c=this.getPoint_line(o,r);break;case"CIRCLE":c=this.getPoint_arc(o,r);break;case"POLYLINE":c=this.getPoint_polyline(o,r);break;case"MTEXT":this.create_text(o);break;case"HATCH":this.create_hatch(o);break;case"INSERT":if(n==!1){let h=this.totalBlock.get(o.blockId);h?.forEach(g=>{c.push(...g.map(u=>u.clone()))});const d=this.getMatrix(o.position,o.scale,o.rotation);c.forEach(g=>{g.applyMatrix4(d)})}break;default:return console.warn(`[LoaderModule2d] Unknown entity type: ${o.type}`),null}l.has(o.linkId)?l.get(o.linkId).push(...c):l.set(o.linkId,c)})}getPoint_polyline(e,t){let n=[];for(let i=0;i<e.points.length-1;i++)n.push(new y.Vector3(e.points[i].x,e.points[i].y,0)),n.push(new y.Vector3(e.points[i+1].x,e.points[i+1].y,0));return e.closed&&(n.push(new y.Vector3(e.points[e.points.length-1].x,e.points[e.points.length-1].y,0)),n.push(new y.Vector3(e.points[0].x,e.points[0].y,0))),n.forEach(i=>{i[0]=i[0]-t[0],i[1]=i[1]-t[1]}),n}create_hatch(e){if(!e.loops||e.loops.length===0)return;const t=e.loops.filter(a=>a.type===!0),n=e.loops.filter(a=>a.type===!1),i=[];for(const a of t){if(!a.points||a.points.length<3)continue;const l=new y.Shape;l.moveTo(a.points[0][0],a.points[0][1]);for(let c=1;c<a.points.length;c++)l.lineTo(a.points[c][0],a.points[c][1]);l.closePath();for(const c of n){if(!c.points||c.points.length<3)continue;const h=new y.Path;h.moveTo(c.points[0][0],c.points[0][1]);for(let d=1;d<c.points.length;d++)h.lineTo(c.points[d][0],c.points[d][1]);h.closePath(),l.holes.push(h)}i.push(new y.ShapeGeometry(l))}if(i.length===0)return;const r=i.length===1?i[0]:Mi(i,!1),o=e.layer+"||"+e.color;this.model.hatchMap.has(o)?this.model.hatchMap.get(o).push({geometry:r,info:e}):this.model.hatchMap.set(o,[{geometry:r,info:e}])}create_text(e){if(!this.font||!e.text)return;const t=new uM(e.text,{font:this.font,size:e.height??100,depth:0});e.position[1]=e.position[1]-e.height;const n=this.getMatrix(e.position,[1,1,1],e.rotation);t.applyMatrix4(n);const i=e.layer+"||"+e.color;this.model.textMap.has(i)?this.model.textMap.get(i).push({geometry:t,info:e}):this.model.textMap.set(i,[{geometry:t,info:e}]),t.computeBoundingBox();const r=t.boundingBox;if(r){const o=r.max.x-r.min.x,a=r.max.y-r.min.y,l=new y.PlaneGeometry(o,a);new y.MeshBasicMaterial({visible:!1,side:y.DoubleSide,depthWrite:!1});let c=[(r.min.x+r.max.x)/2,(r.min.y+r.max.y)/2,0],h=this.getMatrix(c,[1,1,1],0);l.applyMatrix4(h);const d=e.layer+"||"+e.color+"_hitbox";this.model.textMap.has(d)?this.model.textMap.get(d).push({geometry:l,info:e}):this.model.textMap.set(d,[{geometry:l,info:e}])}}getPoint_line(e,t){const n=new y.Vector3(e.startPoint[0],e.startPoint[1],e.startPoint[2]||0),i=new y.Vector3(e.endPoint[0],e.endPoint[1],e.endPoint[2]||0);let r=[n,i];return r.forEach(o=>{o[0]=o[0]-t[0],o[1]=o[1]-t[1]}),r}getPoint_arc(e,t){const n=e.center[0],i=e.center[1],r=e.radius,a=new y.EllipseCurve(n,i,r,r,e.startAngle,e.endAngle,!1,0).getPoints(30).map(c=>new y.Vector3(c.x,c.y,0));let l=[];for(let c=0;c<a.length-1;c++)l.push(a[c].clone()),l.push(a[c+1].clone());return l.forEach(c=>{c[0]=c[0]-t[0],c[1]=c[1]-t[1]}),l}getMatrix(e,t,n){const i=new y.Vector3(e[0],e[1],e[2]),r=new y.Euler(0,0,n),o=new y.Vector3(t[0],t[1],t[2]),a=new y.Quaternion;a.setFromEuler(r);const l=new y.Matrix4;return l.compose(i,a,o),l}getData(){return this.data}getEntitiesByLayer(e){return this.data?this.data.entities.filter(t=>t.layer===e):[]}getLayers(){return this.data?this.data.layers:[]}clear(){this.data=null}dispose(){this.clear()}}class vM{engine;sectionPlaneGroup=null;loaderModule2d;constructor(e){this.engine=e,this.loaderModule2d=new _d(this.engine)}async attachSectionPlane(e,t,n,i){await this.loaderModule2d.loadModel(e+"/"+t,{chunkSize:1e3,enableChunkedLoading:!0,enableValidation:!0});let r=new y.Vector3(n.x,n.y,n.z),o=new y.Vector3(i.x,i.y,i.z);const a=new y.Vector3().copy(o);let l=r.clone().sub(this.engine.modelGroup.position.clone()).dot(o);this.engine.modelGroup.lookAt(a);let c=this.engine.modelGroup.position.clone().add(o.setLength(l));this.engine.modelGroup.position.set(c.x,c.y,c.z),console.log("绘制完成")}removeSectionPlane(){this.engine.scene.remove(this.engine.modelGroup)}getMatrix(e,t){const n=new y.Vector3(e.x,e.y,e.z),i=new y.Euler(t.x,t.y,t.z),r=new y.Vector3(1,1,1),o=new y.Quaternion;o.setFromEuler(i);const a=new y.Matrix4;return a.compose(n,o,r),a}computeMatrixFromOriginAndDirection(e,t){const n=new y.Matrix4,i=t.clone().normalize();if(i.length()===0)return console.warn("方向向量长度为零,返回单位矩阵"),n.identity();const r=new y.Vector3(0,1,0);let o=new y.Vector3().crossVectors(r,i);if(o.length()<1e-4){const c=new y.Vector3(0,0,1);o=new y.Vector3().crossVectors(c,i).normalize()}else o.normalize();const a=new y.Vector3().crossVectors(o,i).normalize(),l=new y.Matrix4;return l.set(o.x,i.x,a.x,0,o.y,i.y,a.y,0,o.z,i.z,a.z,0,0,0,0,1),l.setPosition(e),l}}class _M{options;deviceType;animationId=null;isRenderingPaused=!1;controlsEnabledBeforePause=!0;animate;onWindowResize;_fpsFrameCount=0;_fpsLastCheck=0;_fpsLastSwitch=0;_lowFpsCount=0;_highFpsCount=0;_fpsCheckInterval=100;_fpsSwitchCooldown=100;_fpsThreshold=30;_fpsUpgradeThreshold=60;_lowFpsRequired=5;_highFpsRequired=.1;isMouseDown=!1;isWheeling=!1;scene;camera;renderer;sceneModule;cameraModule;deviceModule;renderModule;controlModule;composerModule;loaderModule;engineStatus;events;lightModule;interactionModule;modelToolModule;worldToScreen;handelBehaved;octreeBox;controls;stats;catchSvg;engineModelModule;viewTree;merge2d;viewCube;rangeScale;setting;measure;clipping;modelTree;engineInfo;modelProperties;modelMapperBatch;modelEdge;ai;pathRoaming;hoverHighLight;minMap;grid;level;issueReport;text;hdr;ground;skyManager;linkElement2d3d;linkView2d3d;oneClickEncoding;models=[];reactBoundingClientRect={left:0,top:0};version="3.4.8";versionEl=null;container;constructor(e){if(window.THREE=y,this.options=e,this.container=document.getElementById(e.containerId),!this.container)throw new Error(`Container ${e.containerId} not found`);if(this.engineModelModule=new H_(this),this.engineModelModule.init(),this.ai=new jy(this),this.deviceModule=new Od(this),this.deviceType=this.deviceModule.getDeviceType(),this.cameraModule=new Vn(this),this.sceneModule=new Fd(this),this.scene=this.sceneModule.scene,this.renderModule=new m0(this),this.renderer=this.renderModule.createRenderer(),this.camera=this.cameraModule.orthographicCamera,this.scene.camera=this.camera,this.renderer){const r=this.renderer;r.interactionCullingEnabled=!0,r.interactionActive=!1,r.interactionRenderScene=this.scene,r.interactionFrameBudgetMs=this.options.interactionFrameBudgetMs??6,r.interactionSkipShadows=this.options.interactionSkipShadows??!0}this.controlModule=new U0(this),this.controlModule.switchDefaultMode(),this.controls=this.controlModule.orbitControls,this.clipping=new By(this),this.clipping.init(),this.composerModule=new q0(this),this.composerModule.init(),this.events=new O_,this.engineStatus=new F_(this),this.engineStatus.init(),this.loaderModule=new U_(this),this.lightModule=new k_(this),this.lightModule.init(),this.viewCube=new wy(this),this.viewCube.init(),this.options.showViewCube==!1&&this.viewCube.hide(),this.octreeBox=Sy(this),this.rangeScale=new Ey(this),this.rangeScale.init(),this.setting=new Cy(this),this.engineModelModule.init(),this.handelBehaved=La(this),this.modelMapperBatch=new Wy(this),this.measure=new Uy(this),this.modelToolModule=new z_(this),this.modelProperties=new Gy(this),this.interactionModule=new B_(this),this.interactionModule.init(),this.interactionModule.active(),this.hoverHighLight=new Xr(this),this.modelEdge=new Hy(this),this.modelTree=new zy(this),this.viewTree=new hM(this),this.merge2d=new vM(this),this.engineInfo=new Vy(this),this.pathRoaming=new Yy(this),this.pathRoaming.init(),this.oneClickEncoding=new cM(this),this.minMap=new qy(this),this.linkElement2d3d=new aM(this),this.linkView2d3d=new lM(this),this.grid=new $y(this),this.level=new eM(this),this.issueReport=new tM(this),this.text=new nM(this),this.hdr=new iM(this),this.ground=new rl(this),this.ground.init(),this.skyManager=new oM(this),this.setting.init(),this.worldToScreen=new it(this.camera,this.renderer,this.scene),this.options.showStats&&(this.stats=new q_,this.stats.showPanel(0),this.stats.dom.style.position="absolute",this.stats.dom.style.top="0px",this.stats.dom.style.left="0px",this.stats.dom.style.zIndex="1000",this.container.appendChild(this.stats.dom));let t=document.createElement("div");t.className="versionText",this.versionEl=t,this.updateVersionDisplay(),this.container.appendChild(t);let n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.style.position="absolute",n.style.zIndex="1000",n.style.left="0px",n.style.top="0px",n.style.pointerEvents="none",this.container.appendChild(n),this.catchSvg=n,this.onWindowResize=()=>{this.handleWindowResize()},window.addEventListener("resize",this.onWindowResize);let i=this;this.controls.addEventListener("start",()=>{i.renderer&&(i.renderer.interactionActive=!0),i.events.trigger(ts.EngineBusy),i.container&&(i.container.style.cursor="none")}),this.controls.addEventListener("end",()=>{i.renderer&&(i.renderer.interactionActive=!1),i.events.trigger(ts.EngineFree),i.container&&(i.container.style.cursor="default")}),this.controls.addEventListener("change",()=>{const r=new y.Vector3;i.camera.getWorldDirection(r);const o=Math.atan2(r.x,-r.z);let a=new CustomEvent("D3ViewUpdate",{detail:{position:i.camera.position,rotation:o,type:i.camera.type}});window.dispatchEvent(a)}),this.animate=()=>{if(!this.isRenderingPaused)this.animationId=requestAnimationFrame(this.animate);else{this.animationId=null;return}this.stats&&this.stats.begin(),this.composerModule&&this.composerModule.composer.render(),this.viewCube&&this.viewCube.cubeTool.RenderScene(),this.measure.update(),this.ground.update(),this.skyManager.update(),this.hoverHighLight.update(),this.controlModule.update(),this.minMap.update(),this.grid.update(),this.level.update(),this.text&&this.text.update(),this.stats&&this.stats.end(),this._fpsFrameCount++;const r=performance.now();if(r-this._fpsLastCheck>=this._fpsCheckInterval){const o=r-this._fpsLastCheck,a=this._fpsFrameCount/o*1e3;this._fpsFrameCount=0,this._fpsLastCheck=r,a<this._fpsThreshold?(this._lowFpsCount++,this._highFpsCount=0,this._lowFpsCount>=this._lowFpsRequired&&r-this._fpsLastSwitch>this._fpsSwitchCooldown&&(this._adaptiveRenderingDowngrade(),this._fpsLastSwitch=r,this._lowFpsCount=0)):a>this._fpsUpgradeThreshold?(this._highFpsCount++,this._lowFpsCount=0):(this._lowFpsCount=0,this._highFpsCount=0)}if(this.scene){let o=this.scene?.dirLight;o&&this.camera&&this.updateLightPosition(this.camera,o)}},this.animate()}updateVersionDisplay(){if(!this.versionEl)return;const e={simple:"simple",balance:"balance",advanced:"advanced"},t=this.engineModelModule?.getCurrentMode()??"",n=e[t]??t;this.versionEl.innerHTML=`v${this.version} | ${n}`}updateLightPosition(e,t){const n=new y.Vector3;e.getWorldDirection(n);const i=100,r=new y.Vector3().copy(n).multiplyScalar(-i),o=new y.Vector3(0,1,0),a=new y.Vector3().crossVectors(n,o).normalize();r.addScaledVector(o,i*.5),r.addScaledVector(a,i*.3),t.position.copy(e.position).add(r);const l=new y.Vector3().copy(e.position).add(n.multiplyScalar(20));t.target.position.copy(l),t.target.updateMatrixWorld()}_adaptiveRenderingDowngrade(){const e=["simple","balance","advanced"],t=this.engineModelModule.getCurrentMode(),n=e.indexOf(t);if(n>0){const i=e[n-1];console.log(`[AdaptiveRendering] FPS低于${this._fpsThreshold},自动降级: ${t} → ${i}`),this.engineModelModule.autoSwitch(i)}}_adaptiveRenderingUpgrade(){const e=["simple","balance","advanced"],t=this.engineModelModule.getCurrentMode(),n=e.indexOf(t);if(n<e.length-1){const i=e[n+1];console.log(`[AdaptiveRendering] FPS高于${this._fpsUpgradeThreshold},自动升级: ${t} → ${i}`),this.engineModelModule.autoSwitch(i)}}pauseRendering(){if(this.isRenderingPaused){console.warn("[BimEngine] Rendering is already paused");return}this.isRenderingPaused=!0,this.controls&&(this.controlsEnabledBeforePause=this.controls.enabled,this.controls.enabled=!1)}resumeRendering(){if(!this.isRenderingPaused){console.warn("[BimEngine] Rendering is not paused");return}this.isRenderingPaused=!1,this.controls&&(this.controls.enabled=this.controlsEnabledBeforePause),this.animationId===null&&this.animate()}isRenderingPausedState(){return this.isRenderingPaused}handleWindowResize(e,t){if(!this.container||!this.renderer||!this.camera)return;if(e===void 0||t===void 0){const i=this.deviceModule.getContainerSize();e=e??i.width,t=t??i.height}if(!e||!t)return;this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(e,t);const n=e/t;if(this.camera===this.cameraModule.perspectiveCamera)this.cameraModule.perspectiveCamera.aspect=n,this.cameraModule.perspectiveCamera.updateProjectionMatrix(),this.camera=this.cameraModule.perspectiveCamera;else if(this.camera===this.cameraModule.orthographicCamera){const i=this.cameraModule.orthographicCamera,r=this.cameraModule.getOrthographicVisibleHeight(i);this.cameraModule.setOrthographicVisibleHeight(r,i),i.updateProjectionMatrix()}if(this.catchSvg){const i=this.container.clientWidth,r=this.container.clientHeight;this.catchSvg.setAttribute("viewBox",`0 0 ${i} ${r}`)}this.events&&this.events.trigger(ts.ViewportResize,{width:e,height:t})}dispose(){console.log("[BimEngine] Starting engine disposal..."),this.animationId!==null&&(cancelAnimationFrame(this.animationId),this.animationId=null),this.isRenderingPaused=!0,this.onWindowResize&&window.removeEventListener("resize",this.onWindowResize);try{this.measure&&(this.measure.disActive(),this.measure.clearAll(),this.measure.annotationContainer&&this.measure.annotationContainer.remove()),this.hdr&&this.hdr.dispose(),this.minMap&&this.minMap.dispose(),this.text&&this.text.dispose(),this.issueReport&&this.issueReport.dispose(),this.clipping&&this.clipping.disActive(),this.interactionModule&&this.interactionModule.disActive(),this.viewCube&&this.viewCube.cubeTool&&typeof this.viewCube.cubeTool.dispose=="function"&&this.viewCube.cubeTool.dispose()}catch(e){console.warn("[BimEngine] Error disposing managers:",e)}try{this.controlModule&&(this.controlModule.originDiv&&this.controlModule.originDiv.remove(),this.controlModule.orbitControls&&typeof this.controlModule.orbitControls.dispose=="function"&&this.controlModule.orbitControls.dispose(),this.controlModule.firstPersonControls&&typeof this.controlModule.firstPersonControls.dispose=="function"&&this.controlModule.firstPersonControls.dispose())}catch(e){console.warn("[BimEngine] Error disposing controls:",e)}this.scene&&this.clearScene(this.scene);try{this.composerModule&&this.composerModule.composer&&(this.composerModule.composer.passes&&this.composerModule.composer.passes.forEach(e=>{e.dispose&&e.dispose()}),this.composerModule.composer.renderTarget1&&this.composerModule.composer.renderTarget1.dispose(),this.composerModule.composer.renderTarget2&&this.composerModule.composer.renderTarget2.dispose())}catch(e){console.warn("[BimEngine] Error disposing composer:",e)}try{this.renderModule&&this.renderModule.disposeRenderer(),this.renderer&&(this.renderer.domElement&&this.renderer.domElement.parentElement&&this.renderer.domElement.parentElement.removeChild(this.renderer.domElement),this.renderer.dispose(),this.renderer.forceContextLoss())}catch(e){console.warn("[BimEngine] Error disposing renderer:",e)}try{this.stats&&this.stats.dom&&this.stats.dom.parentElement&&this.stats.dom.parentElement.removeChild(this.stats.dom),this.catchSvg&&this.catchSvg.parentElement&&this.catchSvg.parentElement.removeChild(this.catchSvg)}catch(e){console.warn("[BimEngine] Error disposing DOM elements:",e)}try{this.events&&this.events.listeners&&this.events.listeners.clear()}catch(e){console.warn("[BimEngine] Error clearing event listeners:",e)}this.scene=null,this.camera=null,this.renderer=null,this.controls=null,this.models=[],this.container=null,console.log("[BimEngine] Engine disposal completed")}clearScene(e){if(!e)return;[...e.children].forEach(n=>{this.clearScene(n)}),e.parent&&e.parent.remove(e),e instanceof y.Mesh&&(e.geometry&&e.geometry.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach(n=>this.disposeMaterial(n)):this.disposeMaterial(e.material))),e instanceof y.Line&&(e.geometry&&e.geometry.dispose(),e.material&&this.disposeMaterial(e.material)),e instanceof y.Points&&(e.geometry&&e.geometry.dispose(),e.material&&this.disposeMaterial(e.material)),e instanceof y.InstancedMesh&&(e.geometry&&e.geometry.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach(n=>this.disposeMaterial(n)):this.disposeMaterial(e.material)),e.instanceMatrix&&(e.instanceMatrix=null),e.instanceColor&&(e.instanceColor=null)),e instanceof y.Sprite&&e.material&&this.disposeMaterial(e.material)}disposeMaterial(e){if(!e)return;["map","lightMap","bumpMap","normalMap","specularMap","envMap","alphaMap","aoMap","displacementMap","emissiveMap","gradientMap","metalnessMap","roughnessMap","clearcoatMap","clearcoatNormalMap","clearcoatRoughnessMap","transmissionMap","thicknessMap","sheenColorMap","sheenRoughnessMap","specularIntensityMap","specularColorMap","iridescenceMap","iridescenceThicknessMap"].forEach(n=>{const i=e[n];i&&i instanceof y.Texture&&i.dispose()}),e.dispose()}}const yM=`
|
|
5375
|
+
</svg>`}_colorToHex(e){return"#"+e.toString(16).padStart(6,"0")}_makeDraggable(e,t){t.onmousedown=n=>{n.preventDefault();const i=e.getBoundingClientRect(),r=e.offsetParent?.getBoundingClientRect()??{left:0,top:0};e.style.left=i.left-r.left+"px",e.style.top=i.top-r.top+"px",e.style.right="auto",e.style.bottom="auto";const o=n.clientX-i.left,a=n.clientY-i.top,l=h=>{e.style.left=h.clientX-o-r.left+"px",e.style.top=h.clientY-a-r.top+"px"},c=()=>{document.removeEventListener("mousemove",l),document.removeEventListener("mouseup",c)};document.addEventListener("mousemove",l),document.addEventListener("mouseup",c)}}dispose(){this.panel?.remove(),this.panel=null,this.listEl=null}}class vd{engine;layerMap=new Map;panelUI=null;constructor(e){this.engine=e;const t=document.getElementById(e?.options?.containerId??"")??e?.container??null;t&&(this.panelUI=new xM(t,this))}_loadLayers(){let e=this.engine.dwgData.layers;this.layerMap.clear();for(const t of e)this.layerMap.set(t.name,{...t}),this.panelUI?.refresh()}syncFromModel(e){e?.length>0&&(this._loadLayers(e),this.panelUI?.refresh())}getLayers(){return Array.from(this.layerMap.values())}setLayerVisible(e,t){const n=this.layerMap.get(e);n&&(n.visible=t),this._applyVisibility(e,t)}toggleLayer(e){const t=this.layerMap.get(e);if(!t)return!0;const n=!t.visible;return this.setLayerVisible(e,n),n}setAllLayersVisible(e){for(const t of this.layerMap.keys()){const n=this.layerMap.get(t);n.visible=e,this._applyVisibility(t,e)}}isAllVisible(){return Array.from(this.layerMap.values()).every(e=>e.visible)}_applyVisibility(e,t){const n=this.engine?.scene;if(!n)return;const i=e+"||";n.children.forEach(r=>{r.name?.startsWith(i)&&(r.visible=t)})}show(){this.panelUI?.show()}hide(){this.panelUI?.hide()}toggle(){this.panelUI?.toggle()}dispose(){this.panelUI?.dispose(),this.panelUI=null,this.layerMap.clear()}}class _d{engine;data=null;enableValidation=!0;constructor(e){for(this.engine=e,this.engine.modelGroup=new y.Group,this.engine.modelGroup.name="model2d",this.engine.scene.add(this.engine.modelGroup);this.engine.modelGroup.children.length>0;)this.engine.modelGroup.remove(this.engine.modelGroup.children[0])}async loadModel(e,t={}){if(!e.includes(".json"))this.engine.events&&this.engine.events.trigger(Zt.ModelLoadStart,{url:e}),Es(e,async n=>{const i=JSON.parse(n);this.engine.dwgData=i,this.data=i,await this.buildScene(i);try{this.engine.fitToView()}catch{}this.engine.layerManager||(this.engine.layerManager=new vd(this.engine)),this.engine.layerManager._loadLayers(),this.engine.events&&this.engine.events.trigger(Zt.ModelLoaded,{})},n=>{this._emitProgress(0,"抱歉,图纸加载失败")});else{this.engine.events&&this.engine.events.trigger(Zt.ModelLoadStart,{url:e}),this._emitProgress(10,"请求数据...");const n=await this.fetchJson(e);this._emitProgress(20,"解析数据...");const i=this.parseData(n);if(this.engine.dwgData=i,!i)throw new Error("Failed to parse DWG data");this.data=i,await this.buildScene(i),this.engine.fitToView(),this.engine.layerManager._loadLayers(),this.engine.events&&this.engine.events.trigger(Zt.ModelLoaded,{})}}async fetchJson(e){const t=await fetch(e);if(!t.ok)throw new Error(`HTTP error! status: ${t.status}`);return await t.json()}parseData(e){return e?this.enableValidation&&!this.validateDataStructure(e)?(console.error("[LoaderModule2d] Invalid data structure"),null):e:(console.error("[LoaderModule2d] Empty JSON data"),null)}validateDataStructure(e){return e.version||console.warn("[LoaderModule2d] Missing version"),e.metadata||console.warn("[LoaderModule2d] Missing metadata"),Array.isArray(e.layers)?Array.isArray(e.entities)?!0:(console.error("[LoaderModule2d] Invalid or missing entities array"),!1):(console.error("[LoaderModule2d] Invalid or missing layers array"),!1)}model={};totalBlock=new Map;font=null;async loadFont(){const e=this.engine.options?.fontUrl??"/fonts/simfang.ttf",t=await Us.fromUrl(e);return Us.toThreeFont(t)}_emitProgress(e,t){this.engine.events&&this.engine.events.trigger(Zt.ModelLoadProgress,{progress:e,text:t})}async buildScene(e){this._emitProgress(10,"正在加载"),this.font=await this.loadFont(),this.model.layers=e.layers,this.model.modelMap=new Map,this.model.hatchMap=new Map,this.model.textMap=new Map,this.model.nodeMap=new Map,console.log(this.model.layers),this._emitProgress(10,"正在加载..."),await Promise.resolve(),e.blocks.forEach(t=>{this.loadBlock(t,t.name,!0)}),this._emitProgress(10,"正在加载..."),await Promise.resolve(),this.loadBlock({entities:e.entities},"",!1),this._emitProgress(10,"正在加载..."),await Promise.resolve(),this.model.modelMap.forEach((t,n)=>{let i=[];if(t.forEach(o=>{for(const a of o)i.push(a)}),i.length!=0){const o=new y.BufferGeometry().setFromPoints(i);let a=parseInt(n.split("||")[1]);if(a==0){var r=this.model.layers.find(d=>d.name==n.split("||")[0]);a=r.color}const l=new y.LineBasicMaterial({color:a}),c=new y.LineSegments(o,l);c.name=n,c.clonePoints=[],i.forEach(d=>{c.clonePoints.push(d.x),c.clonePoints.push(d.y),c.clonePoints.push(d.z)}),c.materialClone=l.clone(),this.engine.modelGroup.add(c);let h=0;t.forEach((d,g)=>{this.model.nodeMap.has(g)?this.model.nodeMap.get(g).push({indexes:[this.engine.modelGroup.children.length-1,h,h+d.length*3],min:new y.Vector3(Math.min(...d.map(u=>u.x)),Math.min(...d.map(u=>u.y)),0),max:new y.Vector3(Math.max(...d.map(u=>u.x)),Math.max(...d.map(u=>u.y)),0)}):this.model.nodeMap.set(g,[{indexes:[this.engine.modelGroup.children.length-1,h,h+d.length*3],min:new y.Vector3(Math.min(...d.map(u=>u.x)),Math.min(...d.map(u=>u.y)),0),max:new y.Vector3(Math.max(...d.map(u=>u.x)),Math.max(...d.map(u=>u.y)),0)}]),h=h+d.length*3})}}),this._emitProgress(85,"正在加载..."),await Promise.resolve(),this.model.textMap.forEach((t,n)=>{const i=Mi(t.map(c=>c.geometry),!1);let r=Number.parseInt(n.split("||")[1]);if(r===0){const c=this.model.layers.find(h=>h.name===n.split("||")[0]);c&&(r=c.color)}const o=new y.MeshBasicMaterial({color:r,side:y.DoubleSide});n.includes("_hitbox")&&(o.visible=!1);let a=new y.Mesh(i,o);a.name=n,a.materialClone=o.clone(),a.isSplit=!1,a.geometrys=t.map(c=>c.geometry),this.engine.modelGroup.add(a);let l=0;t.forEach(c=>{this.model.nodeMap.has(c.info.linkId)?this.model.nodeMap.get(c.info.linkId).push({indexes:[this.engine.modelGroup.children.length-1,l++],min:new y.Vector3(c.info.min[0],c.info.min[1],0),max:new y.Vector3(c.info.max[0],c.info.max[1],0)}):this.model.nodeMap.set(c.info.linkId,[{indexes:[this.engine.modelGroup.children.length-1,l++],min:new y.Vector3(c.info.min[0],c.info.min[1],0),max:new y.Vector3(c.info.max[0],c.info.max[1],0)}])})}),this._emitProgress(93,"正在加载..."),await Promise.resolve(),this.model.hatchMap.forEach((t,n)=>{let i=Mi(t.map(h=>h.geometry),!1),r=parseInt(n.split("||")[1]);if(r==0){var o=this.model.layers.find(h=>h.name==n.split("||")[0]);r=o.color}const a=new y.MeshBasicMaterial({color:r,side:y.DoubleSide,transparent:!0,opacity:.5});let l=new y.Mesh(i,a);l.name=n,l.materialClone=a.clone(),l.isSplit=!1,l.geometrys=t.map(h=>h.geometry),this.engine.modelGroup.add(l);let c=0;t.forEach(h=>{this.model.nodeMap.has(h.info.linkId)?this.model.nodeMap.get(h.info.linkId).push({indexes:[this.engine.modelGroup.children.length-1,c++],min:new y.Vector3(h.info.min[0],h.info.min[1],0),max:new y.Vector3(h.info.max[0],h.info.max[1],0)}):this.model.nodeMap.set(h.info.linkId,[{indexes:[this.engine.modelGroup.children.length-1,c++],min:new y.Vector3(h.info.min[0],h.info.min[1],0),max:new y.Vector3(h.info.max[0],h.info.max[1],0)}])})}),this._emitProgress(100,"加载完成")}loadBlock(e,t,n,i=0){let r=[0,0,0];n&&(r=e.origin),e.entities.forEach(o=>{const a=o.layer+"||"+o.color;let l=new Map;n?(l=this.totalBlock.get(t),l==null&&(l=new Map,this.totalBlock.set(t,l))):(l=this.model.modelMap.get(a),l==null&&(l=new Map,this.model.modelMap.set(a,l)));let c=[];switch(o.type){case"LINE":c=this.getPoint_line(o,r);break;case"CIRCLE":c=this.getPoint_arc(o,r);break;case"POLYLINE":c=this.getPoint_polyline(o,r);break;case"MTEXT":this.create_text(o);break;case"HATCH":this.create_hatch(o);break;case"INSERT":if(n==!1){let h=this.totalBlock.get(o.blockId);h?.forEach(g=>{c.push(...g.map(u=>u.clone()))});const d=this.getMatrix(o.position,o.scale,o.rotation);c.forEach(g=>{g.applyMatrix4(d)})}break;default:return console.warn(`[LoaderModule2d] Unknown entity type: ${o.type}`),null}l.has(o.linkId)?l.get(o.linkId).push(...c):l.set(o.linkId,c)})}getPoint_polyline(e,t){let n=[];for(let i=0;i<e.points.length-1;i++)n.push(new y.Vector3(e.points[i].x,e.points[i].y,0)),n.push(new y.Vector3(e.points[i+1].x,e.points[i+1].y,0));return e.closed&&(n.push(new y.Vector3(e.points[e.points.length-1].x,e.points[e.points.length-1].y,0)),n.push(new y.Vector3(e.points[0].x,e.points[0].y,0))),n.forEach(i=>{i[0]=i[0]-t[0],i[1]=i[1]-t[1]}),n}create_hatch(e){if(!e.loops||e.loops.length===0)return;const t=e.loops.filter(a=>a.type===!0),n=e.loops.filter(a=>a.type===!1),i=[];for(const a of t){if(!a.points||a.points.length<3)continue;const l=new y.Shape;l.moveTo(a.points[0][0],a.points[0][1]);for(let c=1;c<a.points.length;c++)l.lineTo(a.points[c][0],a.points[c][1]);l.closePath();for(const c of n){if(!c.points||c.points.length<3)continue;const h=new y.Path;h.moveTo(c.points[0][0],c.points[0][1]);for(let d=1;d<c.points.length;d++)h.lineTo(c.points[d][0],c.points[d][1]);h.closePath(),l.holes.push(h)}i.push(new y.ShapeGeometry(l))}if(i.length===0)return;const r=i.length===1?i[0]:Mi(i,!1),o=e.layer+"||"+e.color;this.model.hatchMap.has(o)?this.model.hatchMap.get(o).push({geometry:r,info:e}):this.model.hatchMap.set(o,[{geometry:r,info:e}])}create_text(e){if(!this.font||!e.text)return;const t=new uM(e.text,{font:this.font,size:e.height??100,depth:0});e.position[1]=e.position[1]-e.height;const n=this.getMatrix(e.position,[1,1,1],e.rotation);t.applyMatrix4(n);const i=e.layer+"||"+e.color;this.model.textMap.has(i)?this.model.textMap.get(i).push({geometry:t,info:e}):this.model.textMap.set(i,[{geometry:t,info:e}]),t.computeBoundingBox();const r=t.boundingBox;if(r){const o=r.max.x-r.min.x,a=r.max.y-r.min.y,l=new y.PlaneGeometry(o,a);new y.MeshBasicMaterial({visible:!1,side:y.DoubleSide,depthWrite:!1});let c=[(r.min.x+r.max.x)/2,(r.min.y+r.max.y)/2,0],h=this.getMatrix(c,[1,1,1],0);l.applyMatrix4(h);const d=e.layer+"||"+e.color+"_hitbox";this.model.textMap.has(d)?this.model.textMap.get(d).push({geometry:l,info:e}):this.model.textMap.set(d,[{geometry:l,info:e}])}}getPoint_line(e,t){const n=new y.Vector3(e.startPoint[0],e.startPoint[1],e.startPoint[2]||0),i=new y.Vector3(e.endPoint[0],e.endPoint[1],e.endPoint[2]||0);let r=[n,i];return r.forEach(o=>{o[0]=o[0]-t[0],o[1]=o[1]-t[1]}),r}getPoint_arc(e,t){const n=e.center[0],i=e.center[1],r=e.radius,a=new y.EllipseCurve(n,i,r,r,e.startAngle,e.endAngle,!1,0).getPoints(30).map(c=>new y.Vector3(c.x,c.y,0));let l=[];for(let c=0;c<a.length-1;c++)l.push(a[c].clone()),l.push(a[c+1].clone());return l.forEach(c=>{c[0]=c[0]-t[0],c[1]=c[1]-t[1]}),l}getMatrix(e,t,n){const i=new y.Vector3(e[0],e[1],e[2]),r=new y.Euler(0,0,n),o=new y.Vector3(t[0],t[1],t[2]),a=new y.Quaternion;a.setFromEuler(r);const l=new y.Matrix4;return l.compose(i,a,o),l}getData(){return this.data}getEntitiesByLayer(e){return this.data?this.data.entities.filter(t=>t.layer===e):[]}getLayers(){return this.data?this.data.layers:[]}clear(){this.data=null}dispose(){this.clear()}}class vM{engine;sectionPlaneGroup=null;loaderModule2d;constructor(e){this.engine=e,this.loaderModule2d=new _d(this.engine)}async attachSectionPlane(e,t,n,i){await this.loaderModule2d.loadModel(e+"/"+t,{chunkSize:1e3,enableChunkedLoading:!0,enableValidation:!0});let r=new y.Vector3(n.x,n.y,n.z),o=new y.Vector3(i.x,i.y,i.z);const a=new y.Vector3().copy(o);let l=r.clone().sub(this.engine.modelGroup.position.clone()).dot(o);this.engine.modelGroup.lookAt(a);let c=this.engine.modelGroup.position.clone().add(o.setLength(l));this.engine.modelGroup.position.set(c.x,c.y,c.z),console.log("绘制完成")}removeSectionPlane(){this.engine.scene.remove(this.engine.modelGroup)}getMatrix(e,t){const n=new y.Vector3(e.x,e.y,e.z),i=new y.Euler(t.x,t.y,t.z),r=new y.Vector3(1,1,1),o=new y.Quaternion;o.setFromEuler(i);const a=new y.Matrix4;return a.compose(n,o,r),a}computeMatrixFromOriginAndDirection(e,t){const n=new y.Matrix4,i=t.clone().normalize();if(i.length()===0)return console.warn("方向向量长度为零,返回单位矩阵"),n.identity();const r=new y.Vector3(0,1,0);let o=new y.Vector3().crossVectors(r,i);if(o.length()<1e-4){const c=new y.Vector3(0,0,1);o=new y.Vector3().crossVectors(c,i).normalize()}else o.normalize();const a=new y.Vector3().crossVectors(o,i).normalize(),l=new y.Matrix4;return l.set(o.x,i.x,a.x,0,o.y,i.y,a.y,0,o.z,i.z,a.z,0,0,0,0,1),l.setPosition(e),l}}class _M{options;deviceType;animationId=null;isRenderingPaused=!1;controlsEnabledBeforePause=!0;animate;onWindowResize;_fpsFrameCount=0;_fpsLastCheck=0;_fpsLastSwitch=0;_lowFpsCount=0;_highFpsCount=0;_fpsCheckInterval=100;_fpsSwitchCooldown=100;_fpsThreshold=30;_fpsUpgradeThreshold=60;_lowFpsRequired=5;_highFpsRequired=.1;isMouseDown=!1;isWheeling=!1;scene;camera;renderer;sceneModule;cameraModule;deviceModule;renderModule;controlModule;composerModule;loaderModule;engineStatus;events;lightModule;interactionModule;modelToolModule;worldToScreen;handelBehaved;octreeBox;controls;stats;catchSvg;engineModelModule;viewTree;merge2d;viewCube;rangeScale;setting;measure;clipping;modelTree;engineInfo;modelProperties;modelMapperBatch;modelEdge;ai;pathRoaming;hoverHighLight;minMap;grid;level;issueReport;text;hdr;ground;skyManager;linkElement2d3d;linkView2d3d;oneClickEncoding;models=[];reactBoundingClientRect={left:0,top:0};version="3.4.9";versionEl=null;container;constructor(e){if(window.THREE=y,this.options=e,this.container=document.getElementById(e.containerId),!this.container)throw new Error(`Container ${e.containerId} not found`);if(this.engineModelModule=new H_(this),this.engineModelModule.init(),this.ai=new jy(this),this.deviceModule=new Od(this),this.deviceType=this.deviceModule.getDeviceType(),this.cameraModule=new Vn(this),this.sceneModule=new Fd(this),this.scene=this.sceneModule.scene,this.renderModule=new m0(this),this.renderer=this.renderModule.createRenderer(),this.camera=this.cameraModule.orthographicCamera,this.scene.camera=this.camera,this.renderer){const r=this.renderer;r.interactionCullingEnabled=!0,r.interactionActive=!1,r.interactionRenderScene=this.scene,r.interactionFrameBudgetMs=this.options.interactionFrameBudgetMs??6,r.interactionSkipShadows=this.options.interactionSkipShadows??!0}this.controlModule=new U0(this),this.controlModule.switchDefaultMode(),this.controls=this.controlModule.orbitControls,this.clipping=new By(this),this.clipping.init(),this.composerModule=new q0(this),this.composerModule.init(),this.events=new O_,this.engineStatus=new F_(this),this.engineStatus.init(),this.loaderModule=new U_(this),this.lightModule=new k_(this),this.lightModule.init(),this.viewCube=new wy(this),this.viewCube.init(),this.options.showViewCube==!1&&this.viewCube.hide(),this.octreeBox=Sy(this),this.rangeScale=new Ey(this),this.rangeScale.init(),this.setting=new Cy(this),this.engineModelModule.init(),this.handelBehaved=La(this),this.modelMapperBatch=new Wy(this),this.measure=new Uy(this),this.modelToolModule=new z_(this),this.modelProperties=new Gy(this),this.interactionModule=new B_(this),this.interactionModule.init(),this.interactionModule.active(),this.hoverHighLight=new Xr(this),this.modelEdge=new Hy(this),this.modelTree=new zy(this),this.viewTree=new hM(this),this.merge2d=new vM(this),this.engineInfo=new Vy(this),this.pathRoaming=new Yy(this),this.pathRoaming.init(),this.oneClickEncoding=new cM(this),this.minMap=new qy(this),this.linkElement2d3d=new aM(this),this.linkView2d3d=new lM(this),this.grid=new $y(this),this.level=new eM(this),this.issueReport=new tM(this),this.text=new nM(this),this.hdr=new iM(this),this.ground=new rl(this),this.ground.init(),this.skyManager=new oM(this),this.setting.init(),this.worldToScreen=new it(this.camera,this.renderer,this.scene),this.options.showStats&&(this.stats=new q_,this.stats.showPanel(0),this.stats.dom.style.position="absolute",this.stats.dom.style.top="0px",this.stats.dom.style.left="0px",this.stats.dom.style.zIndex="1000",this.container.appendChild(this.stats.dom));let t=document.createElement("div");t.className="versionText",this.versionEl=t,this.updateVersionDisplay(),this.container.appendChild(t);let n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.style.position="absolute",n.style.zIndex="1000",n.style.left="0px",n.style.top="0px",n.style.pointerEvents="none",this.container.appendChild(n),this.catchSvg=n,this.onWindowResize=()=>{this.handleWindowResize()},window.addEventListener("resize",this.onWindowResize);let i=this;this.controls.addEventListener("start",()=>{i.renderer&&(i.renderer.interactionActive=!0),i.events.trigger(ts.EngineBusy),i.container&&(i.container.style.cursor="none")}),this.controls.addEventListener("end",()=>{i.renderer&&(i.renderer.interactionActive=!1),i.events.trigger(ts.EngineFree),i.container&&(i.container.style.cursor="default")}),this.controls.addEventListener("change",()=>{const r=new y.Vector3;i.camera.getWorldDirection(r);const o=Math.atan2(r.x,-r.z);let a=new CustomEvent("D3ViewUpdate",{detail:{position:i.camera.position,rotation:o,type:i.camera.type}});window.dispatchEvent(a)}),this.animate=()=>{if(!this.isRenderingPaused)this.animationId=requestAnimationFrame(this.animate);else{this.animationId=null;return}this.stats&&this.stats.begin(),this.composerModule&&this.composerModule.composer.render(),this.viewCube&&this.viewCube.cubeTool.RenderScene(),this.measure.update(),this.ground.update(),this.skyManager.update(),this.hoverHighLight.update(),this.controlModule.update(),this.minMap.update(),this.grid.update(),this.level.update(),this.text&&this.text.update(),this.stats&&this.stats.end(),this._fpsFrameCount++;const r=performance.now();if(r-this._fpsLastCheck>=this._fpsCheckInterval){const o=r-this._fpsLastCheck,a=this._fpsFrameCount/o*1e3;this._fpsFrameCount=0,this._fpsLastCheck=r,a<this._fpsThreshold?(this._lowFpsCount++,this._highFpsCount=0,this._lowFpsCount>=this._lowFpsRequired&&r-this._fpsLastSwitch>this._fpsSwitchCooldown&&(this._adaptiveRenderingDowngrade(),this._fpsLastSwitch=r,this._lowFpsCount=0)):a>this._fpsUpgradeThreshold?(this._highFpsCount++,this._lowFpsCount=0):(this._lowFpsCount=0,this._highFpsCount=0)}if(this.scene){let o=this.scene?.dirLight;o&&this.camera&&this.updateLightPosition(this.camera,o)}},this.animate()}updateVersionDisplay(){if(!this.versionEl)return;const e={simple:"simple",balance:"balance",advanced:"advanced"},t=this.engineModelModule?.getCurrentMode()??"",n=e[t]??t;this.versionEl.innerHTML=`v${this.version} | ${n}`}updateLightPosition(e,t){const n=new y.Vector3;e.getWorldDirection(n);const i=100,r=new y.Vector3().copy(n).multiplyScalar(-i),o=new y.Vector3(0,1,0),a=new y.Vector3().crossVectors(n,o).normalize();r.addScaledVector(o,i*.5),r.addScaledVector(a,i*.3),t.position.copy(e.position).add(r);const l=new y.Vector3().copy(e.position).add(n.multiplyScalar(20));t.target.position.copy(l),t.target.updateMatrixWorld()}_adaptiveRenderingDowngrade(){const e=["simple","balance","advanced"],t=this.engineModelModule.getCurrentMode(),n=e.indexOf(t);if(n>0){const i=e[n-1];console.log(`[AdaptiveRendering] FPS低于${this._fpsThreshold},自动降级: ${t} → ${i}`),this.engineModelModule.autoSwitch(i)}}_adaptiveRenderingUpgrade(){const e=["simple","balance","advanced"],t=this.engineModelModule.getCurrentMode(),n=e.indexOf(t);if(n<e.length-1){const i=e[n+1];console.log(`[AdaptiveRendering] FPS高于${this._fpsUpgradeThreshold},自动升级: ${t} → ${i}`),this.engineModelModule.autoSwitch(i)}}pauseRendering(){if(this.isRenderingPaused){console.warn("[BimEngine] Rendering is already paused");return}this.isRenderingPaused=!0,this.controls&&(this.controlsEnabledBeforePause=this.controls.enabled,this.controls.enabled=!1)}resumeRendering(){if(!this.isRenderingPaused){console.warn("[BimEngine] Rendering is not paused");return}this.isRenderingPaused=!1,this.controls&&(this.controls.enabled=this.controlsEnabledBeforePause),this.animationId===null&&this.animate()}isRenderingPausedState(){return this.isRenderingPaused}handleWindowResize(e,t){if(!this.container||!this.renderer||!this.camera)return;if(e===void 0||t===void 0){const i=this.deviceModule.getContainerSize();e=e??i.width,t=t??i.height}if(!e||!t)return;this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(e,t);const n=e/t;if(this.camera===this.cameraModule.perspectiveCamera)this.cameraModule.perspectiveCamera.aspect=n,this.cameraModule.perspectiveCamera.updateProjectionMatrix(),this.camera=this.cameraModule.perspectiveCamera;else if(this.camera===this.cameraModule.orthographicCamera){const i=this.cameraModule.orthographicCamera,r=this.cameraModule.getOrthographicVisibleHeight(i);this.cameraModule.setOrthographicVisibleHeight(r,i),i.updateProjectionMatrix()}if(this.catchSvg){const i=this.container.clientWidth,r=this.container.clientHeight;this.catchSvg.setAttribute("viewBox",`0 0 ${i} ${r}`)}this.events&&this.events.trigger(ts.ViewportResize,{width:e,height:t})}dispose(){console.log("[BimEngine] Starting engine disposal..."),this.animationId!==null&&(cancelAnimationFrame(this.animationId),this.animationId=null),this.isRenderingPaused=!0,this.onWindowResize&&window.removeEventListener("resize",this.onWindowResize);try{this.measure&&(this.measure.disActive(),this.measure.clearAll(),this.measure.annotationContainer&&this.measure.annotationContainer.remove()),this.hdr&&this.hdr.dispose(),this.minMap&&this.minMap.dispose(),this.text&&this.text.dispose(),this.issueReport&&this.issueReport.dispose(),this.clipping&&this.clipping.disActive(),this.interactionModule&&this.interactionModule.disActive(),this.viewCube&&this.viewCube.cubeTool&&typeof this.viewCube.cubeTool.dispose=="function"&&this.viewCube.cubeTool.dispose()}catch(e){console.warn("[BimEngine] Error disposing managers:",e)}try{this.controlModule&&(this.controlModule.originDiv&&this.controlModule.originDiv.remove(),this.controlModule.orbitControls&&typeof this.controlModule.orbitControls.dispose=="function"&&this.controlModule.orbitControls.dispose(),this.controlModule.firstPersonControls&&typeof this.controlModule.firstPersonControls.dispose=="function"&&this.controlModule.firstPersonControls.dispose())}catch(e){console.warn("[BimEngine] Error disposing controls:",e)}this.scene&&this.clearScene(this.scene);try{this.composerModule&&this.composerModule.composer&&(this.composerModule.composer.passes&&this.composerModule.composer.passes.forEach(e=>{e.dispose&&e.dispose()}),this.composerModule.composer.renderTarget1&&this.composerModule.composer.renderTarget1.dispose(),this.composerModule.composer.renderTarget2&&this.composerModule.composer.renderTarget2.dispose())}catch(e){console.warn("[BimEngine] Error disposing composer:",e)}try{this.renderModule&&this.renderModule.disposeRenderer(),this.renderer&&(this.renderer.domElement&&this.renderer.domElement.parentElement&&this.renderer.domElement.parentElement.removeChild(this.renderer.domElement),this.renderer.dispose(),this.renderer.forceContextLoss())}catch(e){console.warn("[BimEngine] Error disposing renderer:",e)}try{this.stats&&this.stats.dom&&this.stats.dom.parentElement&&this.stats.dom.parentElement.removeChild(this.stats.dom),this.catchSvg&&this.catchSvg.parentElement&&this.catchSvg.parentElement.removeChild(this.catchSvg)}catch(e){console.warn("[BimEngine] Error disposing DOM elements:",e)}try{this.events&&this.events.listeners&&this.events.listeners.clear()}catch(e){console.warn("[BimEngine] Error clearing event listeners:",e)}this.scene=null,this.camera=null,this.renderer=null,this.controls=null,this.models=[],this.container=null,console.log("[BimEngine] Engine disposal completed")}clearScene(e){if(!e)return;[...e.children].forEach(n=>{this.clearScene(n)}),e.parent&&e.parent.remove(e),e instanceof y.Mesh&&(e.geometry&&e.geometry.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach(n=>this.disposeMaterial(n)):this.disposeMaterial(e.material))),e instanceof y.Line&&(e.geometry&&e.geometry.dispose(),e.material&&this.disposeMaterial(e.material)),e instanceof y.Points&&(e.geometry&&e.geometry.dispose(),e.material&&this.disposeMaterial(e.material)),e instanceof y.InstancedMesh&&(e.geometry&&e.geometry.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach(n=>this.disposeMaterial(n)):this.disposeMaterial(e.material)),e.instanceMatrix&&(e.instanceMatrix=null),e.instanceColor&&(e.instanceColor=null)),e instanceof y.Sprite&&e.material&&this.disposeMaterial(e.material)}disposeMaterial(e){if(!e)return;["map","lightMap","bumpMap","normalMap","specularMap","envMap","alphaMap","aoMap","displacementMap","emissiveMap","gradientMap","metalnessMap","roughnessMap","clearcoatMap","clearcoatNormalMap","clearcoatRoughnessMap","transmissionMap","thicknessMap","sheenColorMap","sheenRoughnessMap","specularIntensityMap","specularColorMap","iridescenceMap","iridescenceThicknessMap"].forEach(n=>{const i=e[n];i&&i instanceof y.Texture&&i.dispose()}),e.dispose()}}const yM=`
|
|
5376
5376
|
varying vec2 vWorldPos;
|
|
5377
5377
|
|
|
5378
5378
|
void main() {
|