iflow-engine 2.5.8 → 2.5.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.
package/dist/iflow-engine.umd.js
CHANGED
|
@@ -8979,18 +8979,18 @@ void main() {
|
|
|
8979
8979
|
|
|
8980
8980
|
gl_FragColor = color;
|
|
8981
8981
|
}
|
|
8982
|
-
`};class n6{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,i=e?.normalMaterial;i&&(i.clippingPlanes=t,i.needsUpdate=!0)}syncAmbientOcclusionClipping(){this.applyClippingToAmbientOcclusionPass(this.gtaoPass),this.applyClippingToAmbientOcclusionPass(this.ssaoPass)}resize(e,t){if(e===void 0||t===void 0){const s=this.engine.deviceModule.getContainerSize();e=e??s.width,t=t??s.height}if(!e||!t||!this.composer)return;const i=this.engine.renderer?.getPixelRatio?.()??window.devicePixelRatio??1;this.composer.setPixelRatio(i),this.composer.setSize(e,t);const n=this.composer.passes.find(s=>s instanceof Ap&&s.material.uniforms.resolution);n&&(n.material.uniforms.resolution.value.x=1/(e*i),n.material.uniforms.resolution.value.y=1/(t*i))}init(){const{width:e,height:t}=this.engine.deviceModule.getContainerSize(),i=this.engine.scene,n=this.engine.camera,s=this.engine.renderer,a=this.engine.renderer?.getPixelRatio?.()??window.devicePixelRatio??1,o=new _i(e,t,{minFilter:Pt,magFilter:Pt,format:ji,samples:4});this.composer=new YD(s,o),this.composer.setPixelRatio(a),this.composer.setSize(e,t);const l=new KD(i,n);this.composer.addPass(l),this.gtaoPass=new ds(i,n,e,t),this.gtaoPass.output=ds.OUTPUT.Default,this.gtaoPass.blendIntensity=.3,this.gtaoPass.enabled=!1,this.gtaoPass.updateGtaoMaterial&&this.gtaoPass.updateGtaoMaterial({enabled:!0,radius:.
|
|
8982
|
+
`};class n6{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,i=e?.normalMaterial;i&&(i.clippingPlanes=t,i.needsUpdate=!0)}syncAmbientOcclusionClipping(){this.applyClippingToAmbientOcclusionPass(this.gtaoPass),this.applyClippingToAmbientOcclusionPass(this.ssaoPass)}resize(e,t){if(e===void 0||t===void 0){const s=this.engine.deviceModule.getContainerSize();e=e??s.width,t=t??s.height}if(!e||!t||!this.composer)return;const i=this.engine.renderer?.getPixelRatio?.()??window.devicePixelRatio??1;this.composer.setPixelRatio(i),this.composer.setSize(e,t);const n=this.composer.passes.find(s=>s instanceof Ap&&s.material.uniforms.resolution);n&&(n.material.uniforms.resolution.value.x=1/(e*i),n.material.uniforms.resolution.value.y=1/(t*i))}init(){const{width:e,height:t}=this.engine.deviceModule.getContainerSize(),i=this.engine.scene,n=this.engine.camera,s=this.engine.renderer,a=this.engine.renderer?.getPixelRatio?.()??window.devicePixelRatio??1,o=new _i(e,t,{minFilter:Pt,magFilter:Pt,format:ji,samples:4});this.composer=new YD(s,o),this.composer.setPixelRatio(a),this.composer.setSize(e,t);const l=new KD(i,n);this.composer.addPass(l),this.gtaoPass=new ds(i,n,e,t),this.gtaoPass.output=ds.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 rr(i,n,e,t),this.ssaoPass.kernelRadius=8,this.ssaoPass.minDistance=.005,this.ssaoPass.maxDistance=.1,this.ssaoPass.output=rr.OUTPUT.Default,this.ssaoPass.enabled=!1,this.applyClippingToAmbientOcclusionPass(this.ssaoPass),this.composer.addPass(this.ssaoPass),this.saturationPass=new Ap(i6),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 e6,this.outputPass.enabled=!1,this.composer.addPass(this.outputPass),this.fxaaPass=new Ap(t6),this.fxaaPass.material.uniforms.resolution.value.x=1/(e*a),this.fxaaPass.material.uniforms.resolution.value.y=1/(t*a),this.fxaaPass.enabled=!1,this.composer.addPass(this.fxaaPass)}}var kp=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function nb(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function Op(r){throw new Error('Could not dynamically require "'+r+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var sb={exports:{}},rb;function s6(){return rb||(rb=1,(function(r,e){(function(t){r.exports=t()})(function(){return(function t(i,n,s){function a(c,h){if(!n[c]){if(!i[c]){var d=typeof Op=="function"&&Op;if(!h&&d)return d(c,!0);if(o)return o(c,!0);var p=new Error("Cannot find module '"+c+"'");throw p.code="MODULE_NOT_FOUND",p}var u=n[c]={exports:{}};i[c][0].call(u.exports,function(v){var m=i[c][1][v];return a(m||v)},u,u.exports,t,i,n,s)}return n[c].exports}for(var o=typeof Op=="function"&&Op,l=0;l<s.length;l++)a(s[l]);return a})({1:[function(t,i,n){var s=t("./utils"),a=t("./support"),o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";n.encode=function(l){for(var c,h,d,p,u,v,m,g=[],f=0,y=l.length,x=y,_=s.getTypeOf(l)!=="string";f<l.length;)x=y-f,d=_?(c=l[f++],h=f<y?l[f++]:0,f<y?l[f++]:0):(c=l.charCodeAt(f++),h=f<y?l.charCodeAt(f++):0,f<y?l.charCodeAt(f++):0),p=c>>2,u=(3&c)<<4|h>>4,v=1<x?(15&h)<<2|d>>6:64,m=2<x?63&d:64,g.push(o.charAt(p)+o.charAt(u)+o.charAt(v)+o.charAt(m));return g.join("")},n.decode=function(l){var c,h,d,p,u,v,m=0,g=0,f="data:";if(l.substr(0,f.length)===f)throw new Error("Invalid base64 input, it looks like a data url.");var y,x=3*(l=l.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(l.charAt(l.length-1)===o.charAt(64)&&x--,l.charAt(l.length-2)===o.charAt(64)&&x--,x%1!=0)throw new Error("Invalid base64 input, bad content length.");for(y=a.uint8array?new Uint8Array(0|x):new Array(0|x);m<l.length;)c=o.indexOf(l.charAt(m++))<<2|(p=o.indexOf(l.charAt(m++)))>>4,h=(15&p)<<4|(u=o.indexOf(l.charAt(m++)))>>2,d=(3&u)<<6|(v=o.indexOf(l.charAt(m++))),y[g++]=c,u!==64&&(y[g++]=h),v!==64&&(y[g++]=d);return y}},{"./support":30,"./utils":32}],2:[function(t,i,n){var s=t("./external"),a=t("./stream/DataWorker"),o=t("./stream/Crc32Probe"),l=t("./stream/DataLengthProbe");function c(h,d,p,u,v){this.compressedSize=h,this.uncompressedSize=d,this.crc32=p,this.compression=u,this.compressedContent=v}c.prototype={getContentWorker:function(){var h=new a(s.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 a(s.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,p){return h.pipe(new o).pipe(new l("uncompressedSize")).pipe(d.compressWorker(p)).pipe(new l("compressedSize")).withStreamInfo("compression",d)},i.exports=c},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(t,i,n){var s=t("./stream/GenericWorker");n.STORE={magic:"\0\0",compressWorker:function(){return new s("STORE compression")},uncompressWorker:function(){return new s("STORE decompression")}},n.DEFLATE=t("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(t,i,n){var s=t("./utils"),a=(function(){for(var o,l=[],c=0;c<256;c++){o=c;for(var h=0;h<8;h++)o=1&o?3988292384^o>>>1:o>>>1;l[c]=o}return l})();i.exports=function(o,l){return o!==void 0&&o.length?s.getTypeOf(o)!=="string"?(function(c,h,d,p){var u=a,v=p+d;c^=-1;for(var m=p;m<v;m++)c=c>>>8^u[255&(c^h[m])];return-1^c})(0|l,o,o.length,0):(function(c,h,d,p){var u=a,v=p+d;c^=-1;for(var m=p;m<v;m++)c=c>>>8^u[255&(c^h.charCodeAt(m))];return-1^c})(0|l,o,o.length,0):0}},{"./utils":32}],5:[function(t,i,n){n.base64=!1,n.binary=!1,n.dir=!1,n.createFolders=!0,n.date=null,n.compression=null,n.compressionOptions=null,n.comment=null,n.unixPermissions=null,n.dosPermissions=null},{}],6:[function(t,i,n){var s=null;s=typeof Promise<"u"?Promise:t("lie"),i.exports={Promise:s}},{lie:37}],7:[function(t,i,n){var s=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",a=t("pako"),o=t("./utils"),l=t("./stream/GenericWorker"),c=s?"uint8array":"array";function h(d,p){l.call(this,"FlateWorker/"+d),this._pako=null,this._pakoAction=d,this._pakoOptions=p,this.meta={}}n.magic="\b\0",o.inherits(h,l),h.prototype.processChunk=function(d){this.meta=d.meta,this._pako===null&&this._createPako(),this._pako.push(o.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 a[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var d=this;this._pako.onData=function(p){d.push({data:p,meta:d.meta})}},n.compressWorker=function(d){return new h("Deflate",d)},n.uncompressWorker=function(){return new h("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(t,i,n){function s(u,v){var m,g="";for(m=0;m<v;m++)g+=String.fromCharCode(255&u),u>>>=8;return g}function a(u,v,m,g,f,y){var x,_,E=u.file,S=u.compression,C=y!==c.utf8encode,w=o.transformTo("string",y(E.name)),M=o.transformTo("string",c.utf8encode(E.name)),R=E.comment,N=o.transformTo("string",y(R)),L=o.transformTo("string",c.utf8encode(R)),O=M.length!==E.name.length,T=L.length!==R.length,B="",F="",H="",q=E.dir,V=E.date,re={crc32:0,compressedSize:0,uncompressedSize:0};v&&!m||(re.crc32=u.crc32,re.compressedSize=u.compressedSize,re.uncompressedSize=u.uncompressedSize);var Y=0;v&&(Y|=8),C||!O&&!T||(Y|=2048);var K=0,_e=0;q&&(K|=16),f==="UNIX"?(_e=798,K|=(function(be,J){var oe=be;return be||(oe=J?16893:33204),(65535&oe)<<16})(E.unixPermissions,q)):(_e=20,K|=(function(be){return 63&(be||0)})(E.dosPermissions)),x=V.getUTCHours(),x<<=6,x|=V.getUTCMinutes(),x<<=5,x|=V.getUTCSeconds()/2,_=V.getUTCFullYear()-1980,_<<=4,_|=V.getUTCMonth()+1,_<<=5,_|=V.getUTCDate(),O&&(F=s(1,1)+s(h(w),4)+M,B+="up"+s(F.length,2)+F),T&&(H=s(1,1)+s(h(N),4)+L,B+="uc"+s(H.length,2)+H);var Ce="";return Ce+=`
|
|
8983
8983
|
\0`,Ce+=s(Y,2),Ce+=S.magic,Ce+=s(x,2),Ce+=s(_,2),Ce+=s(re.crc32,4),Ce+=s(re.compressedSize,4),Ce+=s(re.uncompressedSize,4),Ce+=s(w.length,2),Ce+=s(B.length,2),{fileRecord:d.LOCAL_FILE_HEADER+Ce+w+B,dirRecord:d.CENTRAL_FILE_HEADER+s(_e,2)+Ce+s(N.length,2)+"\0\0\0\0"+s(K,4)+s(g,4)+w+B+N}}var o=t("../utils"),l=t("../stream/GenericWorker"),c=t("../utf8"),h=t("../crc32"),d=t("../signature");function p(u,v,m,g){l.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=v,this.zipPlatform=m,this.encodeFileName=g,this.streamFiles=u,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}o.inherits(p,l),p.prototype.push=function(u){var v=u.meta.percent||0,m=this.entriesCount,g=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:m?(v+100*(m-g-1))/m:100}}))},p.prototype.openedSource=function(u){this.currentSourceOffset=this.bytesWritten,this.currentFile=u.file.name;var v=this.streamFiles&&!u.file.dir;if(v){var m=a(u,v,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:m.fileRecord,meta:{percent:0}})}else this.accumulate=!0},p.prototype.closedSource=function(u){this.accumulate=!1;var v=this.streamFiles&&!u.file.dir,m=a(u,v,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(m.dirRecord),v)this.push({data:(function(g){return d.DATA_DESCRIPTOR+s(g.crc32,4)+s(g.compressedSize,4)+s(g.uncompressedSize,4)})(u),meta:{percent:100}});else for(this.push({data:m.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},p.prototype.flush=function(){for(var u=this.bytesWritten,v=0;v<this.dirRecords.length;v++)this.push({data:this.dirRecords[v],meta:{percent:100}});var m=this.bytesWritten-u,g=(function(f,y,x,_,E){var S=o.transformTo("string",E(_));return d.CENTRAL_DIRECTORY_END+"\0\0\0\0"+s(f,2)+s(f,2)+s(y,4)+s(x,4)+s(S.length,2)+S})(this.dirRecords.length,m,u,this.zipComment,this.encodeFileName);this.push({data:g,meta:{percent:100}})},p.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},p.prototype.registerPrevious=function(u){this._sources.push(u);var v=this;return u.on("data",function(m){v.processChunk(m)}),u.on("end",function(){v.closedSource(v.previous.streamInfo),v._sources.length?v.prepareNextSource():v.end()}),u.on("error",function(m){v.error(m)}),this},p.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))},p.prototype.error=function(u){var v=this._sources;if(!l.prototype.error.call(this,u))return!1;for(var m=0;m<v.length;m++)try{v[m].error(u)}catch{}return!0},p.prototype.lock=function(){l.prototype.lock.call(this);for(var u=this._sources,v=0;v<u.length;v++)u[v].lock()},i.exports=p},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(t,i,n){var s=t("../compressions"),a=t("./ZipFileWorker");n.generateWorker=function(o,l,c){var h=new a(l.streamFiles,c,l.platform,l.encodeFileName),d=0;try{o.forEach(function(p,u){d++;var v=(function(y,x){var _=y||x,E=s[_];if(!E)throw new Error(_+" is not a valid compression method !");return E})(u.options.compression,l.compression),m=u.options.compressionOptions||l.compressionOptions||{},g=u.dir,f=u.date;u._compressWorker(v,m).withStreamInfo("file",{name:p,dir:g,date:f,comment:u.comment||"",unixPermissions:u.unixPermissions,dosPermissions:u.dosPermissions}).pipe(h)}),h.entriesCount=d}catch(p){h.error(p)}return h}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(t,i,n){function s(){if(!(this instanceof s))return new s;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var a=new s;for(var o in this)typeof this[o]!="function"&&(a[o]=this[o]);return a}}(s.prototype=t("./object")).loadAsync=t("./load"),s.support=t("./support"),s.defaults=t("./defaults"),s.version="3.10.1",s.loadAsync=function(a,o){return new s().loadAsync(a,o)},s.external=t("./external"),i.exports=s},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(t,i,n){var s=t("./utils"),a=t("./external"),o=t("./utf8"),l=t("./zipEntries"),c=t("./stream/Crc32Probe"),h=t("./nodejsUtils");function d(p){return new a.Promise(function(u,v){var m=p.decompressed.getContentWorker().pipe(new c);m.on("error",function(g){v(g)}).on("end",function(){m.streamInfo.crc32!==p.decompressed.crc32?v(new Error("Corrupted zip : CRC32 mismatch")):u()}).resume()})}i.exports=function(p,u){var v=this;return u=s.extend(u||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:o.utf8decode}),h.isNode&&h.isStream(p)?a.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):s.prepareContent("the loaded zip file",p,!0,u.optimizedBinaryString,u.base64).then(function(m){var g=new l(u);return g.load(m),g}).then(function(m){var g=[a.Promise.resolve(m)],f=m.files;if(u.checkCRC32)for(var y=0;y<f.length;y++)g.push(d(f[y]));return a.Promise.all(g)}).then(function(m){for(var g=m.shift(),f=g.files,y=0;y<f.length;y++){var x=f[y],_=x.fileNameStr,E=s.resolve(x.fileNameStr);v.file(E,x.decompressed,{binary:!0,optimizedBinaryString:!0,date:x.date,dir:x.dir,comment:x.fileCommentStr.length?x.fileCommentStr:null,unixPermissions:x.unixPermissions,dosPermissions:x.dosPermissions,createFolders:u.createFolders}),x.dir||(v.file(E).unsafeOriginalName=_)}return g.zipComment.length&&(v.comment=g.zipComment),v})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(t,i,n){var s=t("../utils"),a=t("../stream/GenericWorker");function o(l,c){a.call(this,"Nodejs stream input adapter for "+l),this._upstreamEnded=!1,this._bindStream(c)}s.inherits(o,a),o.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()})},o.prototype.pause=function(){return!!a.prototype.pause.call(this)&&(this._stream.pause(),!0)},o.prototype.resume=function(){return!!a.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},i.exports=o},{"../stream/GenericWorker":28,"../utils":32}],13:[function(t,i,n){var s=t("readable-stream").Readable;function a(o,l,c){s.call(this,l),this._helper=o;var h=this;o.on("data",function(d,p){h.push(d)||h._helper.pause(),c&&c(p)}).on("error",function(d){h.emit("error",d)}).on("end",function(){h.push(null)})}t("../utils").inherits(a,s),a.prototype._read=function(){this._helper.resume()},i.exports=a},{"../utils":32,"readable-stream":16}],14:[function(t,i,n){i.exports={isNode:typeof Buffer<"u",newBufferFrom:function(s,a){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(s,a);if(typeof s=="number")throw new Error('The "data" argument must not be a number');return new Buffer(s,a)},allocBuffer:function(s){if(Buffer.alloc)return Buffer.alloc(s);var a=new Buffer(s);return a.fill(0),a},isBuffer:function(s){return Buffer.isBuffer(s)},isStream:function(s){return s&&typeof s.on=="function"&&typeof s.pause=="function"&&typeof s.resume=="function"}}},{}],15:[function(t,i,n){function s(E,S,C){var w,M=o.getTypeOf(S),R=o.extend(C||{},h);R.date=R.date||new Date,R.compression!==null&&(R.compression=R.compression.toUpperCase()),typeof R.unixPermissions=="string"&&(R.unixPermissions=parseInt(R.unixPermissions,8)),R.unixPermissions&&16384&R.unixPermissions&&(R.dir=!0),R.dosPermissions&&16&R.dosPermissions&&(R.dir=!0),R.dir&&(E=f(E)),R.createFolders&&(w=g(E))&&y.call(this,w,!0);var N=M==="string"&&R.binary===!1&&R.base64===!1;C&&C.binary!==void 0||(R.binary=!N),(S instanceof d&&S.uncompressedSize===0||R.dir||!S||S.length===0)&&(R.base64=!1,R.binary=!0,S="",R.compression="STORE",M="string");var L=null;L=S instanceof d||S instanceof l?S:v.isNode&&v.isStream(S)?new m(E,S):o.prepareContent(E,S,R.binary,R.optimizedBinaryString,R.base64);var O=new p(E,L,R);this.files[E]=O}var a=t("./utf8"),o=t("./utils"),l=t("./stream/GenericWorker"),c=t("./stream/StreamHelper"),h=t("./defaults"),d=t("./compressedObject"),p=t("./zipObject"),u=t("./generate"),v=t("./nodejsUtils"),m=t("./nodejs/NodejsStreamInputAdapter"),g=function(E){E.slice(-1)==="/"&&(E=E.substring(0,E.length-1));var S=E.lastIndexOf("/");return 0<S?E.substring(0,S):""},f=function(E){return E.slice(-1)!=="/"&&(E+="/"),E},y=function(E,S){return S=S!==void 0?S:h.createFolders,E=f(E),this.files[E]||s.call(this,E,null,{dir:!0,createFolders:S}),this.files[E]};function x(E){return Object.prototype.toString.call(E)==="[object RegExp]"}var _={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(E){var S,C,w;for(S in this.files)w=this.files[S],(C=S.slice(this.root.length,S.length))&&S.slice(0,this.root.length)===this.root&&E(C,w)},filter:function(E){var S=[];return this.forEach(function(C,w){E(C,w)&&S.push(w)}),S},file:function(E,S,C){if(arguments.length!==1)return E=this.root+E,s.call(this,E,S,C),this;if(x(E)){var w=E;return this.filter(function(R,N){return!N.dir&&w.test(R)})}var M=this.files[this.root+E];return M&&!M.dir?M:null},folder:function(E){if(!E)return this;if(x(E))return this.filter(function(M,R){return R.dir&&E.test(M)});var S=this.root+E,C=y.call(this,S),w=this.clone();return w.root=C.name,w},remove:function(E){E=this.root+E;var S=this.files[E];if(S||(E.slice(-1)!=="/"&&(E+="/"),S=this.files[E]),S&&!S.dir)delete this.files[E];else for(var C=this.filter(function(M,R){return R.name.slice(0,E.length)===E}),w=0;w<C.length;w++)delete this.files[C[w].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(E){var S,C={};try{if((C=o.extend(E||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:a.utf8encode})).type=C.type.toLowerCase(),C.compression=C.compression.toUpperCase(),C.type==="binarystring"&&(C.type="string"),!C.type)throw new Error("No output type specified.");o.checkSupport(C.type),C.platform!=="darwin"&&C.platform!=="freebsd"&&C.platform!=="linux"&&C.platform!=="sunos"||(C.platform="UNIX"),C.platform==="win32"&&(C.platform="DOS");var w=C.comment||this.comment||"";S=u.generateWorker(this,C,w)}catch(M){(S=new l("error")).error(M)}return new c(S,C.type||"string",C.mimeType)},generateAsync:function(E,S){return this.generateInternalStream(E).accumulate(S)},generateNodeStream:function(E,S){return(E=E||{}).type||(E.type="nodebuffer"),this.generateInternalStream(E).toNodejsStream(S)}};i.exports=_},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(t,i,n){i.exports=t("stream")},{stream:void 0}],17:[function(t,i,n){var s=t("./DataReader");function a(o){s.call(this,o);for(var l=0;l<this.data.length;l++)o[l]=255&o[l]}t("../utils").inherits(a,s),a.prototype.byteAt=function(o){return this.data[this.zero+o]},a.prototype.lastIndexOfSignature=function(o){for(var l=o.charCodeAt(0),c=o.charCodeAt(1),h=o.charCodeAt(2),d=o.charCodeAt(3),p=this.length-4;0<=p;--p)if(this.data[p]===l&&this.data[p+1]===c&&this.data[p+2]===h&&this.data[p+3]===d)return p-this.zero;return-1},a.prototype.readAndCheckSignature=function(o){var l=o.charCodeAt(0),c=o.charCodeAt(1),h=o.charCodeAt(2),d=o.charCodeAt(3),p=this.readData(4);return l===p[0]&&c===p[1]&&h===p[2]&&d===p[3]},a.prototype.readData=function(o){if(this.checkOffset(o),o===0)return[];var l=this.data.slice(this.zero+this.index,this.zero+this.index+o);return this.index+=o,l},i.exports=a},{"../utils":32,"./DataReader":18}],18:[function(t,i,n){var s=t("../utils");function a(o){this.data=o,this.length=o.length,this.index=0,this.zero=0}a.prototype={checkOffset:function(o){this.checkIndex(this.index+o)},checkIndex:function(o){if(this.length<this.zero+o||o<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+o+"). Corrupted zip ?")},setIndex:function(o){this.checkIndex(o),this.index=o},skip:function(o){this.setIndex(this.index+o)},byteAt:function(){},readInt:function(o){var l,c=0;for(this.checkOffset(o),l=this.index+o-1;l>=this.index;l--)c=(c<<8)+this.byteAt(l);return this.index+=o,c},readString:function(o){return s.transformTo("string",this.readData(o))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var o=this.readInt(4);return new Date(Date.UTC(1980+(o>>25&127),(o>>21&15)-1,o>>16&31,o>>11&31,o>>5&63,(31&o)<<1))}},i.exports=a},{"../utils":32}],19:[function(t,i,n){var s=t("./Uint8ArrayReader");function a(o){s.call(this,o)}t("../utils").inherits(a,s),a.prototype.readData=function(o){this.checkOffset(o);var l=this.data.slice(this.zero+this.index,this.zero+this.index+o);return this.index+=o,l},i.exports=a},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(t,i,n){var s=t("./DataReader");function a(o){s.call(this,o)}t("../utils").inherits(a,s),a.prototype.byteAt=function(o){return this.data.charCodeAt(this.zero+o)},a.prototype.lastIndexOfSignature=function(o){return this.data.lastIndexOf(o)-this.zero},a.prototype.readAndCheckSignature=function(o){return o===this.readData(4)},a.prototype.readData=function(o){this.checkOffset(o);var l=this.data.slice(this.zero+this.index,this.zero+this.index+o);return this.index+=o,l},i.exports=a},{"../utils":32,"./DataReader":18}],21:[function(t,i,n){var s=t("./ArrayReader");function a(o){s.call(this,o)}t("../utils").inherits(a,s),a.prototype.readData=function(o){if(this.checkOffset(o),o===0)return new Uint8Array(0);var l=this.data.subarray(this.zero+this.index,this.zero+this.index+o);return this.index+=o,l},i.exports=a},{"../utils":32,"./ArrayReader":17}],22:[function(t,i,n){var s=t("../utils"),a=t("../support"),o=t("./ArrayReader"),l=t("./StringReader"),c=t("./NodeBufferReader"),h=t("./Uint8ArrayReader");i.exports=function(d){var p=s.getTypeOf(d);return s.checkSupport(p),p!=="string"||a.uint8array?p==="nodebuffer"?new c(d):a.uint8array?new h(s.transformTo("uint8array",d)):new o(s.transformTo("array",d)):new l(d)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(t,i,n){n.LOCAL_FILE_HEADER="PK",n.CENTRAL_FILE_HEADER="PK",n.CENTRAL_DIRECTORY_END="PK",n.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",n.ZIP64_CENTRAL_DIRECTORY_END="PK",n.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(t,i,n){var s=t("./GenericWorker"),a=t("../utils");function o(l){s.call(this,"ConvertWorker to "+l),this.destType=l}a.inherits(o,s),o.prototype.processChunk=function(l){this.push({data:a.transformTo(this.destType,l.data),meta:l.meta})},i.exports=o},{"../utils":32,"./GenericWorker":28}],25:[function(t,i,n){var s=t("./GenericWorker"),a=t("../crc32");function o(){s.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}t("../utils").inherits(o,s),o.prototype.processChunk=function(l){this.streamInfo.crc32=a(l.data,this.streamInfo.crc32||0),this.push(l)},i.exports=o},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(t,i,n){var s=t("../utils"),a=t("./GenericWorker");function o(l){a.call(this,"DataLengthProbe for "+l),this.propName=l,this.withStreamInfo(l,0)}s.inherits(o,a),o.prototype.processChunk=function(l){if(l){var c=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=c+l.data.length}a.prototype.processChunk.call(this,l)},i.exports=o},{"../utils":32,"./GenericWorker":28}],27:[function(t,i,n){var s=t("../utils"),a=t("./GenericWorker");function o(l){a.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=s.getTypeOf(h),c.isPaused||c._tickAndRepeat()},function(h){c.error(h)})}s.inherits(o,a),o.prototype.cleanUp=function(){a.prototype.cleanUp.call(this),this.data=null},o.prototype.resume=function(){return!!a.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,s.delay(this._tickAndRepeat,[],this)),!0)},o.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(s.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},o.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var l=null,c=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":l=this.data.substring(this.index,c);break;case"uint8array":l=this.data.subarray(this.index,c);break;case"array":case"nodebuffer":l=this.data.slice(this.index,c)}return this.index=c,this.push({data:l,meta:{percent:this.max?this.index/this.max*100:0}})},i.exports=o},{"../utils":32,"./GenericWorker":28}],28:[function(t,i,n){function s(a){this.name=a||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}s.prototype={push:function(a){this.emit("data",a)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(a){this.emit("error",a)}return!0},error:function(a){return!this.isFinished&&(this.isPaused?this.generatedError=a:(this.isFinished=!0,this.emit("error",a),this.previous&&this.previous.error(a),this.cleanUp()),!0)},on:function(a,o){return this._listeners[a].push(o),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(a,o){if(this._listeners[a])for(var l=0;l<this._listeners[a].length;l++)this._listeners[a][l].call(this,o)},pipe:function(a){return a.registerPrevious(this)},registerPrevious:function(a){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=a.streamInfo,this.mergeStreamInfo(),this.previous=a;var o=this;return a.on("data",function(l){o.processChunk(l)}),a.on("end",function(){o.end()}),a.on("error",function(l){o.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 a=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),a=!0),this.previous&&this.previous.resume(),!a},flush:function(){},processChunk:function(a){this.push(a)},withStreamInfo:function(a,o){return this.extraStreamInfo[a]=o,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var a in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,a)&&(this.streamInfo[a]=this.extraStreamInfo[a])},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 a="Worker "+this.name;return this.previous?this.previous+" -> "+a:a}},i.exports=s},{}],29:[function(t,i,n){var s=t("../utils"),a=t("./ConvertWorker"),o=t("./GenericWorker"),l=t("../base64"),c=t("../support"),h=t("../external"),d=null;if(c.nodestream)try{d=t("../nodejs/NodejsStreamOutputAdapter")}catch{}function p(v,m){return new h.Promise(function(g,f){var y=[],x=v._internalType,_=v._outputType,E=v._mimeType;v.on("data",function(S,C){y.push(S),m&&m(C)}).on("error",function(S){y=[],f(S)}).on("end",function(){try{var S=(function(C,w,M){switch(C){case"blob":return s.newBlob(s.transformTo("arraybuffer",w),M);case"base64":return l.encode(w);default:return s.transformTo(C,w)}})(_,(function(C,w){var M,R=0,N=null,L=0;for(M=0;M<w.length;M++)L+=w[M].length;switch(C){case"string":return w.join("");case"array":return Array.prototype.concat.apply([],w);case"uint8array":for(N=new Uint8Array(L),M=0;M<w.length;M++)N.set(w[M],R),R+=w[M].length;return N;case"nodebuffer":return Buffer.concat(w);default:throw new Error("concat : unsupported type '"+C+"'")}})(x,y),E);g(S)}catch(C){f(C)}y=[]}).resume()})}function u(v,m,g){var f=m;switch(m){case"blob":case"arraybuffer":f="uint8array";break;case"base64":f="string"}try{this._internalType=f,this._outputType=m,this._mimeType=g,s.checkSupport(f),this._worker=v.pipe(new a(f)),v.lock()}catch(y){this._worker=new o("error"),this._worker.error(y)}}u.prototype={accumulate:function(v){return p(this,v)},on:function(v,m){var g=this;return v==="data"?this._worker.on(v,function(f){m.call(g,f.data,f.meta)}):this._worker.on(v,function(){s.delay(m,arguments,g)}),this},resume:function(){return s.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(v){if(s.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new d(this,{objectMode:this._outputType!=="nodebuffer"},v)}},i.exports=u},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(t,i,n){if(n.base64=!0,n.array=!0,n.string=!0,n.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",n.nodebuffer=typeof Buffer<"u",n.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")n.blob=!1;else{var s=new ArrayBuffer(0);try{n.blob=new Blob([s],{type:"application/zip"}).size===0}catch{try{var a=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);a.append(s),n.blob=a.getBlob("application/zip").size===0}catch{n.blob=!1}}}try{n.nodestream=!!t("readable-stream").Readable}catch{n.nodestream=!1}},{"readable-stream":16}],31:[function(t,i,n){for(var s=t("./utils"),a=t("./support"),o=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 p(){l.call(this,"utf-8 encode")}n.utf8encode=function(u){return a.nodebuffer?o.newBufferFrom(u,"utf-8"):(function(v){var m,g,f,y,x,_=v.length,E=0;for(y=0;y<_;y++)(64512&(g=v.charCodeAt(y)))==55296&&y+1<_&&(64512&(f=v.charCodeAt(y+1)))==56320&&(g=65536+(g-55296<<10)+(f-56320),y++),E+=g<128?1:g<2048?2:g<65536?3:4;for(m=a.uint8array?new Uint8Array(E):new Array(E),y=x=0;x<E;y++)(64512&(g=v.charCodeAt(y)))==55296&&y+1<_&&(64512&(f=v.charCodeAt(y+1)))==56320&&(g=65536+(g-55296<<10)+(f-56320),y++),g<128?m[x++]=g:(g<2048?m[x++]=192|g>>>6:(g<65536?m[x++]=224|g>>>12:(m[x++]=240|g>>>18,m[x++]=128|g>>>12&63),m[x++]=128|g>>>6&63),m[x++]=128|63&g);return m})(u)},n.utf8decode=function(u){return a.nodebuffer?s.transformTo("nodebuffer",u).toString("utf-8"):(function(v){var m,g,f,y,x=v.length,_=new Array(2*x);for(m=g=0;m<x;)if((f=v[m++])<128)_[g++]=f;else if(4<(y=c[f]))_[g++]=65533,m+=y-1;else{for(f&=y===2?31:y===3?15:7;1<y&&m<x;)f=f<<6|63&v[m++],y--;1<y?_[g++]=65533:f<65536?_[g++]=f:(f-=65536,_[g++]=55296|f>>10&1023,_[g++]=56320|1023&f)}return _.length!==g&&(_.subarray?_=_.subarray(0,g):_.length=g),s.applyFromCharCode(_)})(u=s.transformTo(a.uint8array?"uint8array":"array",u))},s.inherits(d,l),d.prototype.processChunk=function(u){var v=s.transformTo(a.uint8array?"uint8array":"array",u.data);if(this.leftOver&&this.leftOver.length){if(a.uint8array){var m=v;(v=new Uint8Array(m.length+this.leftOver.length)).set(this.leftOver,0),v.set(m,this.leftOver.length)}else v=this.leftOver.concat(v);this.leftOver=null}var g=(function(y,x){var _;for((x=x||y.length)>y.length&&(x=y.length),_=x-1;0<=_&&(192&y[_])==128;)_--;return _<0||_===0?x:_+c[y[_]]>x?_:x})(v),f=v;g!==v.length&&(a.uint8array?(f=v.subarray(0,g),this.leftOver=v.subarray(g,v.length)):(f=v.slice(0,g),this.leftOver=v.slice(g,v.length))),this.push({data:n.utf8decode(f),meta:u.meta})},d.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:n.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},n.Utf8DecodeWorker=d,s.inherits(p,l),p.prototype.processChunk=function(u){this.push({data:n.utf8encode(u.data),meta:u.meta})},n.Utf8EncodeWorker=p},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(t,i,n){var s=t("./support"),a=t("./base64"),o=t("./nodejsUtils"),l=t("./external");function c(m){return m}function h(m,g){for(var f=0;f<m.length;++f)g[f]=255&m.charCodeAt(f);return g}t("setimmediate"),n.newBlob=function(m,g){n.checkSupport("blob");try{return new Blob([m],{type:g})}catch{try{var f=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return f.append(m),f.getBlob(g)}catch{throw new Error("Bug : can't construct the Blob.")}}};var d={stringifyByChunk:function(m,g,f){var y=[],x=0,_=m.length;if(_<=f)return String.fromCharCode.apply(null,m);for(;x<_;)g==="array"||g==="nodebuffer"?y.push(String.fromCharCode.apply(null,m.slice(x,Math.min(x+f,_)))):y.push(String.fromCharCode.apply(null,m.subarray(x,Math.min(x+f,_)))),x+=f;return y.join("")},stringifyByChar:function(m){for(var g="",f=0;f<m.length;f++)g+=String.fromCharCode(m[f]);return g},applyCanBeUsed:{uint8array:(function(){try{return s.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}})(),nodebuffer:(function(){try{return s.nodebuffer&&String.fromCharCode.apply(null,o.allocBuffer(1)).length===1}catch{return!1}})()}};function p(m){var g=65536,f=n.getTypeOf(m),y=!0;if(f==="uint8array"?y=d.applyCanBeUsed.uint8array:f==="nodebuffer"&&(y=d.applyCanBeUsed.nodebuffer),y)for(;1<g;)try{return d.stringifyByChunk(m,f,g)}catch{g=Math.floor(g/2)}return d.stringifyByChar(m)}function u(m,g){for(var f=0;f<m.length;f++)g[f]=m[f];return g}n.applyFromCharCode=p;var v={};v.string={string:c,array:function(m){return h(m,new Array(m.length))},arraybuffer:function(m){return v.string.uint8array(m).buffer},uint8array:function(m){return h(m,new Uint8Array(m.length))},nodebuffer:function(m){return h(m,o.allocBuffer(m.length))}},v.array={string:p,array:c,arraybuffer:function(m){return new Uint8Array(m).buffer},uint8array:function(m){return new Uint8Array(m)},nodebuffer:function(m){return o.newBufferFrom(m)}},v.arraybuffer={string:function(m){return p(new Uint8Array(m))},array:function(m){return u(new Uint8Array(m),new Array(m.byteLength))},arraybuffer:c,uint8array:function(m){return new Uint8Array(m)},nodebuffer:function(m){return o.newBufferFrom(new Uint8Array(m))}},v.uint8array={string:p,array:function(m){return u(m,new Array(m.length))},arraybuffer:function(m){return m.buffer},uint8array:c,nodebuffer:function(m){return o.newBufferFrom(m)}},v.nodebuffer={string:p,array:function(m){return u(m,new Array(m.length))},arraybuffer:function(m){return v.nodebuffer.uint8array(m).buffer},uint8array:function(m){return u(m,new Uint8Array(m.length))},nodebuffer:c},n.transformTo=function(m,g){if(g=g||"",!m)return g;n.checkSupport(m);var f=n.getTypeOf(g);return v[f][m](g)},n.resolve=function(m){for(var g=m.split("/"),f=[],y=0;y<g.length;y++){var x=g[y];x==="."||x===""&&y!==0&&y!==g.length-1||(x===".."?f.pop():f.push(x))}return f.join("/")},n.getTypeOf=function(m){return typeof m=="string"?"string":Object.prototype.toString.call(m)==="[object Array]"?"array":s.nodebuffer&&o.isBuffer(m)?"nodebuffer":s.uint8array&&m instanceof Uint8Array?"uint8array":s.arraybuffer&&m instanceof ArrayBuffer?"arraybuffer":void 0},n.checkSupport=function(m){if(!s[m.toLowerCase()])throw new Error(m+" is not supported by this platform")},n.MAX_VALUE_16BITS=65535,n.MAX_VALUE_32BITS=-1,n.pretty=function(m){var g,f,y="";for(f=0;f<(m||"").length;f++)y+="\\x"+((g=m.charCodeAt(f))<16?"0":"")+g.toString(16).toUpperCase();return y},n.delay=function(m,g,f){setImmediate(function(){m.apply(f||null,g||[])})},n.inherits=function(m,g){function f(){}f.prototype=g.prototype,m.prototype=new f},n.extend=function(){var m,g,f={};for(m=0;m<arguments.length;m++)for(g in arguments[m])Object.prototype.hasOwnProperty.call(arguments[m],g)&&f[g]===void 0&&(f[g]=arguments[m][g]);return f},n.prepareContent=function(m,g,f,y,x){return l.Promise.resolve(g).then(function(_){return s.blob&&(_ instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(_))!==-1)&&typeof FileReader<"u"?new l.Promise(function(E,S){var C=new FileReader;C.onload=function(w){E(w.target.result)},C.onerror=function(w){S(w.target.error)},C.readAsArrayBuffer(_)}):_}).then(function(_){var E=n.getTypeOf(_);return E?(E==="arraybuffer"?_=n.transformTo("uint8array",_):E==="string"&&(x?_=a.decode(_):f&&y!==!0&&(_=(function(S){return h(S,s.uint8array?new Uint8Array(S.length):new Array(S.length))})(_))),_):l.Promise.reject(new Error("Can't read the data of '"+m+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(t,i,n){var s=t("./reader/readerFor"),a=t("./utils"),o=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 p=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+a.pretty(p)+", expected "+a.pretty(d)+")")}},isSignature:function(d,p){var u=this.reader.index;this.reader.setIndex(d);var v=this.reader.readString(4)===p;return this.reader.setIndex(u),v},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),p=c.uint8array?"uint8array":"array",u=a.transformTo(p,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,p,u,v=this.zip64EndOfCentralSize-44;0<v;)d=this.reader.readInt(2),p=this.reader.readInt(4),u=this.reader.readData(p),this.zip64ExtensibleData[d]={id:d,length:p,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,p;for(d=0;d<this.files.length;d++)p=this.files[d],this.reader.setIndex(p.localHeaderOffset),this.checkSignature(o.LOCAL_FILE_HEADER),p.readLocalPart(this.reader),p.handleUTF8(),p.processAttributes()},readCentralDir:function(){var d;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(o.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(o.CENTRAL_DIRECTORY_END);if(d<0)throw this.isSignature(0,o.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 p=d;if(this.checkSignature(o.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===a.MAX_VALUE_16BITS||this.diskWithCentralDirStart===a.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===a.MAX_VALUE_16BITS||this.centralDirRecords===a.MAX_VALUE_16BITS||this.centralDirSize===a.MAX_VALUE_32BITS||this.centralDirOffset===a.MAX_VALUE_32BITS){if(this.zip64=!0,(d=this.reader.lastIndexOfSignature(o.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(o.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,o.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(o.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(o.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var u=this.centralDirOffset+this.centralDirSize;this.zip64&&(u+=20,u+=12+this.zip64EndOfCentralSize);var v=p-u;if(0<v)this.isSignature(p,o.CENTRAL_FILE_HEADER)||(this.reader.zero=v);else if(v<0)throw new Error("Corrupted zip: missing "+Math.abs(v)+" bytes.")},prepareReader:function(d){this.reader=s(d)},load:function(d){this.prepareReader(d),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},i.exports=h},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(t,i,n){var s=t("./reader/readerFor"),a=t("./utils"),o=t("./compressedObject"),l=t("./crc32"),c=t("./utf8"),h=t("./compressions"),d=t("./support");function p(u,v){this.options=u,this.loadOptions=v}p.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(u){var v,m;if(u.skip(22),this.fileNameLength=u.readInt(2),m=u.readInt(2),this.fileName=u.readData(this.fileNameLength),u.skip(m),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((v=(function(g){for(var f in h)if(Object.prototype.hasOwnProperty.call(h,f)&&h[f].magic===g)return h[f];return null})(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+a.pretty(this.compressionMethod)+" unknown (inner file : "+a.transformTo("string",this.fileName)+")");this.decompressed=new o(this.compressedSize,this.uncompressedSize,this.crc32,v,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 v=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(v),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=s(this.extraFields[1].value);this.uncompressedSize===a.MAX_VALUE_32BITS&&(this.uncompressedSize=u.readInt(8)),this.compressedSize===a.MAX_VALUE_32BITS&&(this.compressedSize=u.readInt(8)),this.localHeaderOffset===a.MAX_VALUE_32BITS&&(this.localHeaderOffset=u.readInt(8)),this.diskNumberStart===a.MAX_VALUE_32BITS&&(this.diskNumberStart=u.readInt(4))}},readExtraFields:function(u){var v,m,g,f=u.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});u.index+4<f;)v=u.readInt(2),m=u.readInt(2),g=u.readData(m),this.extraFields[v]={id:v,length:m,value:g};u.setIndex(f)},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 v=this.findExtraFieldUnicodePath();if(v!==null)this.fileNameStr=v;else{var m=a.transformTo(u,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(m)}var g=this.findExtraFieldUnicodeComment();if(g!==null)this.fileCommentStr=g;else{var f=a.transformTo(u,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(f)}}},findExtraFieldUnicodePath:function(){var u=this.extraFields[28789];if(u){var v=s(u.value);return v.readInt(1)!==1||l(this.fileName)!==v.readInt(4)?null:c.utf8decode(v.readData(u.length-5))}return null},findExtraFieldUnicodeComment:function(){var u=this.extraFields[25461];if(u){var v=s(u.value);return v.readInt(1)!==1||l(this.fileComment)!==v.readInt(4)?null:c.utf8decode(v.readData(u.length-5))}return null}},i.exports=p},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(t,i,n){function s(v,m,g){this.name=v,this.dir=g.dir,this.date=g.date,this.comment=g.comment,this.unixPermissions=g.unixPermissions,this.dosPermissions=g.dosPermissions,this._data=m,this._dataBinary=g.binary,this.options={compression:g.compression,compressionOptions:g.compressionOptions}}var a=t("./stream/StreamHelper"),o=t("./stream/DataWorker"),l=t("./utf8"),c=t("./compressedObject"),h=t("./stream/GenericWorker");s.prototype={internalStream:function(v){var m=null,g="string";try{if(!v)throw new Error("No output type specified.");var f=(g=v.toLowerCase())==="string"||g==="text";g!=="binarystring"&&g!=="text"||(g="string"),m=this._decompressWorker();var y=!this._dataBinary;y&&!f&&(m=m.pipe(new l.Utf8EncodeWorker)),!y&&f&&(m=m.pipe(new l.Utf8DecodeWorker))}catch(x){(m=new h("error")).error(x)}return new a(m,g,"")},async:function(v,m){return this.internalStream(v).accumulate(m)},nodeStream:function(v,m){return this.internalStream(v||"nodebuffer").toNodejsStream(m)},_compressWorker:function(v,m){if(this._data instanceof c&&this._data.compression.magic===v.magic)return this._data.getCompressedWorker();var g=this._decompressWorker();return this._dataBinary||(g=g.pipe(new l.Utf8EncodeWorker)),c.createWorkerFrom(g,v,m)},_decompressWorker:function(){return this._data instanceof c?this._data.getContentWorker():this._data instanceof h?this._data:new o(this._data)}};for(var d=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],p=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},u=0;u<d.length;u++)s.prototype[d[u]]=p;i.exports=s},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(t,i,n){(function(s){var a,o,l=s.MutationObserver||s.WebKitMutationObserver;if(l){var c=0,h=new l(v),d=s.document.createTextNode("");h.observe(d,{characterData:!0}),a=function(){d.data=c=++c%2}}else if(s.setImmediate||s.MessageChannel===void 0)a="document"in s&&"onreadystatechange"in s.document.createElement("script")?function(){var m=s.document.createElement("script");m.onreadystatechange=function(){v(),m.onreadystatechange=null,m.parentNode.removeChild(m),m=null},s.document.documentElement.appendChild(m)}:function(){setTimeout(v,0)};else{var p=new s.MessageChannel;p.port1.onmessage=v,a=function(){p.port2.postMessage(0)}}var u=[];function v(){var m,g;o=!0;for(var f=u.length;f;){for(g=u,u=[],m=-1;++m<f;)g[m]();f=u.length}o=!1}i.exports=function(m){u.push(m)!==1||o||a()}}).call(this,typeof kp<"u"?kp:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(t,i,n){var s=t("immediate");function a(){}var o={},l=["REJECTED"],c=["FULFILLED"],h=["PENDING"];function d(f){if(typeof f!="function")throw new TypeError("resolver must be a function");this.state=h,this.queue=[],this.outcome=void 0,f!==a&&m(this,f)}function p(f,y,x){this.promise=f,typeof y=="function"&&(this.onFulfilled=y,this.callFulfilled=this.otherCallFulfilled),typeof x=="function"&&(this.onRejected=x,this.callRejected=this.otherCallRejected)}function u(f,y,x){s(function(){var _;try{_=y(x)}catch(E){return o.reject(f,E)}_===f?o.reject(f,new TypeError("Cannot resolve promise with itself")):o.resolve(f,_)})}function v(f){var y=f&&f.then;if(f&&(typeof f=="object"||typeof f=="function")&&typeof y=="function")return function(){y.apply(f,arguments)}}function m(f,y){var x=!1;function _(C){x||(x=!0,o.reject(f,C))}function E(C){x||(x=!0,o.resolve(f,C))}var S=g(function(){y(E,_)});S.status==="error"&&_(S.value)}function g(f,y){var x={};try{x.value=f(y),x.status="success"}catch(_){x.status="error",x.value=_}return x}(i.exports=d).prototype.finally=function(f){if(typeof f!="function")return this;var y=this.constructor;return this.then(function(x){return y.resolve(f()).then(function(){return x})},function(x){return y.resolve(f()).then(function(){throw x})})},d.prototype.catch=function(f){return this.then(null,f)},d.prototype.then=function(f,y){if(typeof f!="function"&&this.state===c||typeof y!="function"&&this.state===l)return this;var x=new this.constructor(a);return this.state!==h?u(x,this.state===c?f:y,this.outcome):this.queue.push(new p(x,f,y)),x},p.prototype.callFulfilled=function(f){o.resolve(this.promise,f)},p.prototype.otherCallFulfilled=function(f){u(this.promise,this.onFulfilled,f)},p.prototype.callRejected=function(f){o.reject(this.promise,f)},p.prototype.otherCallRejected=function(f){u(this.promise,this.onRejected,f)},o.resolve=function(f,y){var x=g(v,y);if(x.status==="error")return o.reject(f,x.value);var _=x.value;if(_)m(f,_);else{f.state=c,f.outcome=y;for(var E=-1,S=f.queue.length;++E<S;)f.queue[E].callFulfilled(y)}return f},o.reject=function(f,y){f.state=l,f.outcome=y;for(var x=-1,_=f.queue.length;++x<_;)f.queue[x].callRejected(y);return f},d.resolve=function(f){return f instanceof this?f:o.resolve(new this(a),f)},d.reject=function(f){var y=new this(a);return o.reject(y,f)},d.all=function(f){var y=this;if(Object.prototype.toString.call(f)!=="[object Array]")return this.reject(new TypeError("must be an array"));var x=f.length,_=!1;if(!x)return this.resolve([]);for(var E=new Array(x),S=0,C=-1,w=new this(a);++C<x;)M(f[C],C);return w;function M(R,N){y.resolve(R).then(function(L){E[N]=L,++S!==x||_||(_=!0,o.resolve(w,E))},function(L){_||(_=!0,o.reject(w,L))})}},d.race=function(f){var y=this;if(Object.prototype.toString.call(f)!=="[object Array]")return this.reject(new TypeError("must be an array"));var x=f.length,_=!1;if(!x)return this.resolve([]);for(var E=-1,S=new this(a);++E<x;)C=f[E],y.resolve(C).then(function(w){_||(_=!0,o.resolve(S,w))},function(w){_||(_=!0,o.reject(S,w))});var C;return S}},{immediate:36}],38:[function(t,i,n){var s={};(0,t("./lib/utils/common").assign)(s,t("./lib/deflate"),t("./lib/inflate"),t("./lib/zlib/constants")),i.exports=s},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(t,i,n){var s=t("./zlib/deflate"),a=t("./utils/common"),o=t("./utils/strings"),l=t("./zlib/messages"),c=t("./zlib/zstream"),h=Object.prototype.toString,d=0,p=-1,u=0,v=8;function m(f){if(!(this instanceof m))return new m(f);this.options=a.assign({level:p,method:v,chunkSize:16384,windowBits:15,memLevel:8,strategy:u,to:""},f||{});var y=this.options;y.raw&&0<y.windowBits?y.windowBits=-y.windowBits:y.gzip&&0<y.windowBits&&y.windowBits<16&&(y.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new c,this.strm.avail_out=0;var x=s.deflateInit2(this.strm,y.level,y.method,y.windowBits,y.memLevel,y.strategy);if(x!==d)throw new Error(l[x]);if(y.header&&s.deflateSetHeader(this.strm,y.header),y.dictionary){var _;if(_=typeof y.dictionary=="string"?o.string2buf(y.dictionary):h.call(y.dictionary)==="[object ArrayBuffer]"?new Uint8Array(y.dictionary):y.dictionary,(x=s.deflateSetDictionary(this.strm,_))!==d)throw new Error(l[x]);this._dict_set=!0}}function g(f,y){var x=new m(y);if(x.push(f,!0),x.err)throw x.msg||l[x.err];return x.result}m.prototype.push=function(f,y){var x,_,E=this.strm,S=this.options.chunkSize;if(this.ended)return!1;_=y===~~y?y:y===!0?4:0,typeof f=="string"?E.input=o.string2buf(f):h.call(f)==="[object ArrayBuffer]"?E.input=new Uint8Array(f):E.input=f,E.next_in=0,E.avail_in=E.input.length;do{if(E.avail_out===0&&(E.output=new a.Buf8(S),E.next_out=0,E.avail_out=S),(x=s.deflate(E,_))!==1&&x!==d)return this.onEnd(x),!(this.ended=!0);E.avail_out!==0&&(E.avail_in!==0||_!==4&&_!==2)||(this.options.to==="string"?this.onData(o.buf2binstring(a.shrinkBuf(E.output,E.next_out))):this.onData(a.shrinkBuf(E.output,E.next_out)))}while((0<E.avail_in||E.avail_out===0)&&x!==1);return _===4?(x=s.deflateEnd(this.strm),this.onEnd(x),this.ended=!0,x===d):_!==2||(this.onEnd(d),!(E.avail_out=0))},m.prototype.onData=function(f){this.chunks.push(f)},m.prototype.onEnd=function(f){f===d&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=a.flattenChunks(this.chunks)),this.chunks=[],this.err=f,this.msg=this.strm.msg},n.Deflate=m,n.deflate=g,n.deflateRaw=function(f,y){return(y=y||{}).raw=!0,g(f,y)},n.gzip=function(f,y){return(y=y||{}).gzip=!0,g(f,y)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(t,i,n){var s=t("./zlib/inflate"),a=t("./utils/common"),o=t("./utils/strings"),l=t("./zlib/constants"),c=t("./zlib/messages"),h=t("./zlib/zstream"),d=t("./zlib/gzheader"),p=Object.prototype.toString;function u(m){if(!(this instanceof u))return new u(m);this.options=a.assign({chunkSize:16384,windowBits:0,to:""},m||{});var g=this.options;g.raw&&0<=g.windowBits&&g.windowBits<16&&(g.windowBits=-g.windowBits,g.windowBits===0&&(g.windowBits=-15)),!(0<=g.windowBits&&g.windowBits<16)||m&&m.windowBits||(g.windowBits+=32),15<g.windowBits&&g.windowBits<48&&(15&g.windowBits)==0&&(g.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new h,this.strm.avail_out=0;var f=s.inflateInit2(this.strm,g.windowBits);if(f!==l.Z_OK)throw new Error(c[f]);this.header=new d,s.inflateGetHeader(this.strm,this.header)}function v(m,g){var f=new u(g);if(f.push(m,!0),f.err)throw f.msg||c[f.err];return f.result}u.prototype.push=function(m,g){var f,y,x,_,E,S,C=this.strm,w=this.options.chunkSize,M=this.options.dictionary,R=!1;if(this.ended)return!1;y=g===~~g?g:g===!0?l.Z_FINISH:l.Z_NO_FLUSH,typeof m=="string"?C.input=o.binstring2buf(m):p.call(m)==="[object ArrayBuffer]"?C.input=new Uint8Array(m):C.input=m,C.next_in=0,C.avail_in=C.input.length;do{if(C.avail_out===0&&(C.output=new a.Buf8(w),C.next_out=0,C.avail_out=w),(f=s.inflate(C,l.Z_NO_FLUSH))===l.Z_NEED_DICT&&M&&(S=typeof M=="string"?o.string2buf(M):p.call(M)==="[object ArrayBuffer]"?new Uint8Array(M):M,f=s.inflateSetDictionary(this.strm,S)),f===l.Z_BUF_ERROR&&R===!0&&(f=l.Z_OK,R=!1),f!==l.Z_STREAM_END&&f!==l.Z_OK)return this.onEnd(f),!(this.ended=!0);C.next_out&&(C.avail_out!==0&&f!==l.Z_STREAM_END&&(C.avail_in!==0||y!==l.Z_FINISH&&y!==l.Z_SYNC_FLUSH)||(this.options.to==="string"?(x=o.utf8border(C.output,C.next_out),_=C.next_out-x,E=o.buf2string(C.output,x),C.next_out=_,C.avail_out=w-_,_&&a.arraySet(C.output,C.output,x,_,0),this.onData(E)):this.onData(a.shrinkBuf(C.output,C.next_out)))),C.avail_in===0&&C.avail_out===0&&(R=!0)}while((0<C.avail_in||C.avail_out===0)&&f!==l.Z_STREAM_END);return f===l.Z_STREAM_END&&(y=l.Z_FINISH),y===l.Z_FINISH?(f=s.inflateEnd(this.strm),this.onEnd(f),this.ended=!0,f===l.Z_OK):y!==l.Z_SYNC_FLUSH||(this.onEnd(l.Z_OK),!(C.avail_out=0))},u.prototype.onData=function(m){this.chunks.push(m)},u.prototype.onEnd=function(m){m===l.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=a.flattenChunks(this.chunks)),this.chunks=[],this.err=m,this.msg=this.strm.msg},n.Inflate=u,n.inflate=v,n.inflateRaw=function(m,g){return(g=g||{}).raw=!0,v(m,g)},n.ungzip=v},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(t,i,n){var s=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";n.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},n.shrinkBuf=function(l,c){return l.length===c?l:l.subarray?l.subarray(0,c):(l.length=c,l)};var a={arraySet:function(l,c,h,d,p){if(c.subarray&&l.subarray)l.set(c.subarray(h,h+d),p);else for(var u=0;u<d;u++)l[p+u]=c[h+u]},flattenChunks:function(l){var c,h,d,p,u,v;for(c=d=0,h=l.length;c<h;c++)d+=l[c].length;for(v=new Uint8Array(d),c=p=0,h=l.length;c<h;c++)u=l[c],v.set(u,p),p+=u.length;return v}},o={arraySet:function(l,c,h,d,p){for(var u=0;u<d;u++)l[p+u]=c[h+u]},flattenChunks:function(l){return[].concat.apply([],l)}};n.setTyped=function(l){l?(n.Buf8=Uint8Array,n.Buf16=Uint16Array,n.Buf32=Int32Array,n.assign(n,a)):(n.Buf8=Array,n.Buf16=Array,n.Buf32=Array,n.assign(n,o))},n.setTyped(s)},{}],42:[function(t,i,n){var s=t("./common"),a=!0,o=!0;try{String.fromCharCode.apply(null,[0])}catch{a=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{o=!1}for(var l=new s.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,p){if(p<65537&&(d.subarray&&o||!d.subarray&&a))return String.fromCharCode.apply(null,s.shrinkBuf(d,p));for(var u="",v=0;v<p;v++)u+=String.fromCharCode(d[v]);return u}l[254]=l[254]=1,n.string2buf=function(d){var p,u,v,m,g,f=d.length,y=0;for(m=0;m<f;m++)(64512&(u=d.charCodeAt(m)))==55296&&m+1<f&&(64512&(v=d.charCodeAt(m+1)))==56320&&(u=65536+(u-55296<<10)+(v-56320),m++),y+=u<128?1:u<2048?2:u<65536?3:4;for(p=new s.Buf8(y),m=g=0;g<y;m++)(64512&(u=d.charCodeAt(m)))==55296&&m+1<f&&(64512&(v=d.charCodeAt(m+1)))==56320&&(u=65536+(u-55296<<10)+(v-56320),m++),u<128?p[g++]=u:(u<2048?p[g++]=192|u>>>6:(u<65536?p[g++]=224|u>>>12:(p[g++]=240|u>>>18,p[g++]=128|u>>>12&63),p[g++]=128|u>>>6&63),p[g++]=128|63&u);return p},n.buf2binstring=function(d){return h(d,d.length)},n.binstring2buf=function(d){for(var p=new s.Buf8(d.length),u=0,v=p.length;u<v;u++)p[u]=d.charCodeAt(u);return p},n.buf2string=function(d,p){var u,v,m,g,f=p||d.length,y=new Array(2*f);for(u=v=0;u<f;)if((m=d[u++])<128)y[v++]=m;else if(4<(g=l[m]))y[v++]=65533,u+=g-1;else{for(m&=g===2?31:g===3?15:7;1<g&&u<f;)m=m<<6|63&d[u++],g--;1<g?y[v++]=65533:m<65536?y[v++]=m:(m-=65536,y[v++]=55296|m>>10&1023,y[v++]=56320|1023&m)}return h(y,v)},n.utf8border=function(d,p){var u;for((p=p||d.length)>d.length&&(p=d.length),u=p-1;0<=u&&(192&d[u])==128;)u--;return u<0||u===0?p:u+l[d[u]]>p?u:p}},{"./common":41}],43:[function(t,i,n){i.exports=function(s,a,o,l){for(var c=65535&s|0,h=s>>>16&65535|0,d=0;o!==0;){for(o-=d=2e3<o?2e3:o;h=h+(c=c+a[l++]|0)|0,--d;);c%=65521,h%=65521}return c|h<<16|0}},{}],44:[function(t,i,n){i.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(t,i,n){var s=(function(){for(var a,o=[],l=0;l<256;l++){a=l;for(var c=0;c<8;c++)a=1&a?3988292384^a>>>1:a>>>1;o[l]=a}return o})();i.exports=function(a,o,l,c){var h=s,d=c+l;a^=-1;for(var p=c;p<d;p++)a=a>>>8^h[255&(a^o[p])];return-1^a}},{}],46:[function(t,i,n){var s,a=t("../utils/common"),o=t("./trees"),l=t("./adler32"),c=t("./crc32"),h=t("./messages"),d=0,p=4,u=0,v=-2,m=-1,g=4,f=2,y=8,x=9,_=286,E=30,S=19,C=2*_+1,w=15,M=3,R=258,N=R+M+1,L=42,O=113,T=1,B=2,F=3,H=4;function q(I,ae){return I.msg=h[ae],ae}function V(I){return(I<<1)-(4<I?9:0)}function re(I){for(var ae=I.length;0<=--ae;)I[ae]=0}function Y(I){var ae=I.state,Q=ae.pending;Q>I.avail_out&&(Q=I.avail_out),Q!==0&&(a.arraySet(I.output,ae.pending_buf,ae.pending_out,Q,I.next_out),I.next_out+=Q,ae.pending_out+=Q,I.total_out+=Q,I.avail_out-=Q,ae.pending-=Q,ae.pending===0&&(ae.pending_out=0))}function K(I,ae){o._tr_flush_block(I,0<=I.block_start?I.block_start:-1,I.strstart-I.block_start,ae),I.block_start=I.strstart,Y(I.strm)}function _e(I,ae){I.pending_buf[I.pending++]=ae}function Ce(I,ae){I.pending_buf[I.pending++]=ae>>>8&255,I.pending_buf[I.pending++]=255&ae}function be(I,ae){var Q,W,D=I.max_chain_length,te=I.strstart,de=I.prev_length,G=I.nice_match,ee=I.strstart>I.w_size-N?I.strstart-(I.w_size-N):0,P=I.window,b=I.w_mask,k=I.prev,j=I.strstart+R,$=P[te+de-1],Z=P[te+de];I.prev_length>=I.good_match&&(D>>=2),G>I.lookahead&&(G=I.lookahead);do if(P[(Q=ae)+de]===Z&&P[Q+de-1]===$&&P[Q]===P[te]&&P[++Q]===P[te+1]){te+=2,Q++;do;while(P[++te]===P[++Q]&&P[++te]===P[++Q]&&P[++te]===P[++Q]&&P[++te]===P[++Q]&&P[++te]===P[++Q]&&P[++te]===P[++Q]&&P[++te]===P[++Q]&&P[++te]===P[++Q]&&te<j);if(W=R-(j-te),te=j-R,de<W){if(I.match_start=ae,G<=(de=W))break;$=P[te+de-1],Z=P[te+de]}}while((ae=k[ae&b])>ee&&--D!=0);return de<=I.lookahead?de:I.lookahead}function J(I){var ae,Q,W,D,te,de,G,ee,P,b,k=I.w_size;do{if(D=I.window_size-I.lookahead-I.strstart,I.strstart>=k+(k-N)){for(a.arraySet(I.window,I.window,k,k,0),I.match_start-=k,I.strstart-=k,I.block_start-=k,ae=Q=I.hash_size;W=I.head[--ae],I.head[ae]=k<=W?W-k:0,--Q;);for(ae=Q=k;W=I.prev[--ae],I.prev[ae]=k<=W?W-k:0,--Q;);D+=k}if(I.strm.avail_in===0)break;if(de=I.strm,G=I.window,ee=I.strstart+I.lookahead,P=D,b=void 0,b=de.avail_in,P<b&&(b=P),Q=b===0?0:(de.avail_in-=b,a.arraySet(G,de.input,de.next_in,b,ee),de.state.wrap===1?de.adler=l(de.adler,G,b,ee):de.state.wrap===2&&(de.adler=c(de.adler,G,b,ee)),de.next_in+=b,de.total_in+=b,b),I.lookahead+=Q,I.lookahead+I.insert>=M)for(te=I.strstart-I.insert,I.ins_h=I.window[te],I.ins_h=(I.ins_h<<I.hash_shift^I.window[te+1])&I.hash_mask;I.insert&&(I.ins_h=(I.ins_h<<I.hash_shift^I.window[te+M-1])&I.hash_mask,I.prev[te&I.w_mask]=I.head[I.ins_h],I.head[I.ins_h]=te,te++,I.insert--,!(I.lookahead+I.insert<M)););}while(I.lookahead<N&&I.strm.avail_in!==0)}function oe(I,ae){for(var Q,W;;){if(I.lookahead<N){if(J(I),I.lookahead<N&&ae===d)return T;if(I.lookahead===0)break}if(Q=0,I.lookahead>=M&&(I.ins_h=(I.ins_h<<I.hash_shift^I.window[I.strstart+M-1])&I.hash_mask,Q=I.prev[I.strstart&I.w_mask]=I.head[I.ins_h],I.head[I.ins_h]=I.strstart),Q!==0&&I.strstart-Q<=I.w_size-N&&(I.match_length=be(I,Q)),I.match_length>=M)if(W=o._tr_tally(I,I.strstart-I.match_start,I.match_length-M),I.lookahead-=I.match_length,I.match_length<=I.max_lazy_match&&I.lookahead>=M){for(I.match_length--;I.strstart++,I.ins_h=(I.ins_h<<I.hash_shift^I.window[I.strstart+M-1])&I.hash_mask,Q=I.prev[I.strstart&I.w_mask]=I.head[I.ins_h],I.head[I.ins_h]=I.strstart,--I.match_length!=0;);I.strstart++}else I.strstart+=I.match_length,I.match_length=0,I.ins_h=I.window[I.strstart],I.ins_h=(I.ins_h<<I.hash_shift^I.window[I.strstart+1])&I.hash_mask;else W=o._tr_tally(I,0,I.window[I.strstart]),I.lookahead--,I.strstart++;if(W&&(K(I,!1),I.strm.avail_out===0))return T}return I.insert=I.strstart<M-1?I.strstart:M-1,ae===p?(K(I,!0),I.strm.avail_out===0?F:H):I.last_lit&&(K(I,!1),I.strm.avail_out===0)?T:B}function ue(I,ae){for(var Q,W,D;;){if(I.lookahead<N){if(J(I),I.lookahead<N&&ae===d)return T;if(I.lookahead===0)break}if(Q=0,I.lookahead>=M&&(I.ins_h=(I.ins_h<<I.hash_shift^I.window[I.strstart+M-1])&I.hash_mask,Q=I.prev[I.strstart&I.w_mask]=I.head[I.ins_h],I.head[I.ins_h]=I.strstart),I.prev_length=I.match_length,I.prev_match=I.match_start,I.match_length=M-1,Q!==0&&I.prev_length<I.max_lazy_match&&I.strstart-Q<=I.w_size-N&&(I.match_length=be(I,Q),I.match_length<=5&&(I.strategy===1||I.match_length===M&&4096<I.strstart-I.match_start)&&(I.match_length=M-1)),I.prev_length>=M&&I.match_length<=I.prev_length){for(D=I.strstart+I.lookahead-M,W=o._tr_tally(I,I.strstart-1-I.prev_match,I.prev_length-M),I.lookahead-=I.prev_length-1,I.prev_length-=2;++I.strstart<=D&&(I.ins_h=(I.ins_h<<I.hash_shift^I.window[I.strstart+M-1])&I.hash_mask,Q=I.prev[I.strstart&I.w_mask]=I.head[I.ins_h],I.head[I.ins_h]=I.strstart),--I.prev_length!=0;);if(I.match_available=0,I.match_length=M-1,I.strstart++,W&&(K(I,!1),I.strm.avail_out===0))return T}else if(I.match_available){if((W=o._tr_tally(I,0,I.window[I.strstart-1]))&&K(I,!1),I.strstart++,I.lookahead--,I.strm.avail_out===0)return T}else I.match_available=1,I.strstart++,I.lookahead--}return I.match_available&&(W=o._tr_tally(I,0,I.window[I.strstart-1]),I.match_available=0),I.insert=I.strstart<M-1?I.strstart:M-1,ae===p?(K(I,!0),I.strm.avail_out===0?F:H):I.last_lit&&(K(I,!1),I.strm.avail_out===0)?T:B}function Re(I,ae,Q,W,D){this.good_length=I,this.max_lazy=ae,this.nice_length=Q,this.max_chain=W,this.func=D}function De(){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=y,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 a.Buf16(2*C),this.dyn_dtree=new a.Buf16(2*(2*E+1)),this.bl_tree=new a.Buf16(2*(2*S+1)),re(this.dyn_ltree),re(this.dyn_dtree),re(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new a.Buf16(w+1),this.heap=new a.Buf16(2*_+1),re(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new a.Buf16(2*_+1),re(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 Oe(I){var ae;return I&&I.state?(I.total_in=I.total_out=0,I.data_type=f,(ae=I.state).pending=0,ae.pending_out=0,ae.wrap<0&&(ae.wrap=-ae.wrap),ae.status=ae.wrap?L:O,I.adler=ae.wrap===2?0:1,ae.last_flush=d,o._tr_init(ae),u):q(I,v)}function it(I){var ae=Oe(I);return ae===u&&(function(Q){Q.window_size=2*Q.w_size,re(Q.head),Q.max_lazy_match=s[Q.level].max_lazy,Q.good_match=s[Q.level].good_length,Q.nice_match=s[Q.level].nice_length,Q.max_chain_length=s[Q.level].max_chain,Q.strstart=0,Q.block_start=0,Q.lookahead=0,Q.insert=0,Q.match_length=Q.prev_length=M-1,Q.match_available=0,Q.ins_h=0})(I.state),ae}function qe(I,ae,Q,W,D,te){if(!I)return v;var de=1;if(ae===m&&(ae=6),W<0?(de=0,W=-W):15<W&&(de=2,W-=16),D<1||x<D||Q!==y||W<8||15<W||ae<0||9<ae||te<0||g<te)return q(I,v);W===8&&(W=9);var G=new De;return(I.state=G).strm=I,G.wrap=de,G.gzhead=null,G.w_bits=W,G.w_size=1<<G.w_bits,G.w_mask=G.w_size-1,G.hash_bits=D+7,G.hash_size=1<<G.hash_bits,G.hash_mask=G.hash_size-1,G.hash_shift=~~((G.hash_bits+M-1)/M),G.window=new a.Buf8(2*G.w_size),G.head=new a.Buf16(G.hash_size),G.prev=new a.Buf16(G.w_size),G.lit_bufsize=1<<D+6,G.pending_buf_size=4*G.lit_bufsize,G.pending_buf=new a.Buf8(G.pending_buf_size),G.d_buf=1*G.lit_bufsize,G.l_buf=3*G.lit_bufsize,G.level=ae,G.strategy=te,G.method=Q,it(I)}s=[new Re(0,0,0,0,function(I,ae){var Q=65535;for(Q>I.pending_buf_size-5&&(Q=I.pending_buf_size-5);;){if(I.lookahead<=1){if(J(I),I.lookahead===0&&ae===d)return T;if(I.lookahead===0)break}I.strstart+=I.lookahead,I.lookahead=0;var W=I.block_start+Q;if((I.strstart===0||I.strstart>=W)&&(I.lookahead=I.strstart-W,I.strstart=W,K(I,!1),I.strm.avail_out===0)||I.strstart-I.block_start>=I.w_size-N&&(K(I,!1),I.strm.avail_out===0))return T}return I.insert=0,ae===p?(K(I,!0),I.strm.avail_out===0?F:H):(I.strstart>I.block_start&&(K(I,!1),I.strm.avail_out),T)}),new Re(4,4,8,4,oe),new Re(4,5,16,8,oe),new Re(4,6,32,32,oe),new Re(4,4,16,16,ue),new Re(8,16,32,32,ue),new Re(8,16,128,128,ue),new Re(8,32,128,256,ue),new Re(32,128,258,1024,ue),new Re(32,258,258,4096,ue)],n.deflateInit=function(I,ae){return qe(I,ae,y,15,8,0)},n.deflateInit2=qe,n.deflateReset=it,n.deflateResetKeep=Oe,n.deflateSetHeader=function(I,ae){return I&&I.state?I.state.wrap!==2?v:(I.state.gzhead=ae,u):v},n.deflate=function(I,ae){var Q,W,D,te;if(!I||!I.state||5<ae||ae<0)return I?q(I,v):v;if(W=I.state,!I.output||!I.input&&I.avail_in!==0||W.status===666&&ae!==p)return q(I,I.avail_out===0?-5:v);if(W.strm=I,Q=W.last_flush,W.last_flush=ae,W.status===L)if(W.wrap===2)I.adler=0,_e(W,31),_e(W,139),_e(W,8),W.gzhead?(_e(W,(W.gzhead.text?1:0)+(W.gzhead.hcrc?2:0)+(W.gzhead.extra?4:0)+(W.gzhead.name?8:0)+(W.gzhead.comment?16:0)),_e(W,255&W.gzhead.time),_e(W,W.gzhead.time>>8&255),_e(W,W.gzhead.time>>16&255),_e(W,W.gzhead.time>>24&255),_e(W,W.level===9?2:2<=W.strategy||W.level<2?4:0),_e(W,255&W.gzhead.os),W.gzhead.extra&&W.gzhead.extra.length&&(_e(W,255&W.gzhead.extra.length),_e(W,W.gzhead.extra.length>>8&255)),W.gzhead.hcrc&&(I.adler=c(I.adler,W.pending_buf,W.pending,0)),W.gzindex=0,W.status=69):(_e(W,0),_e(W,0),_e(W,0),_e(W,0),_e(W,0),_e(W,W.level===9?2:2<=W.strategy||W.level<2?4:0),_e(W,3),W.status=O);else{var de=y+(W.w_bits-8<<4)<<8;de|=(2<=W.strategy||W.level<2?0:W.level<6?1:W.level===6?2:3)<<6,W.strstart!==0&&(de|=32),de+=31-de%31,W.status=O,Ce(W,de),W.strstart!==0&&(Ce(W,I.adler>>>16),Ce(W,65535&I.adler)),I.adler=1}if(W.status===69)if(W.gzhead.extra){for(D=W.pending;W.gzindex<(65535&W.gzhead.extra.length)&&(W.pending!==W.pending_buf_size||(W.gzhead.hcrc&&W.pending>D&&(I.adler=c(I.adler,W.pending_buf,W.pending-D,D)),Y(I),D=W.pending,W.pending!==W.pending_buf_size));)_e(W,255&W.gzhead.extra[W.gzindex]),W.gzindex++;W.gzhead.hcrc&&W.pending>D&&(I.adler=c(I.adler,W.pending_buf,W.pending-D,D)),W.gzindex===W.gzhead.extra.length&&(W.gzindex=0,W.status=73)}else W.status=73;if(W.status===73)if(W.gzhead.name){D=W.pending;do{if(W.pending===W.pending_buf_size&&(W.gzhead.hcrc&&W.pending>D&&(I.adler=c(I.adler,W.pending_buf,W.pending-D,D)),Y(I),D=W.pending,W.pending===W.pending_buf_size)){te=1;break}te=W.gzindex<W.gzhead.name.length?255&W.gzhead.name.charCodeAt(W.gzindex++):0,_e(W,te)}while(te!==0);W.gzhead.hcrc&&W.pending>D&&(I.adler=c(I.adler,W.pending_buf,W.pending-D,D)),te===0&&(W.gzindex=0,W.status=91)}else W.status=91;if(W.status===91)if(W.gzhead.comment){D=W.pending;do{if(W.pending===W.pending_buf_size&&(W.gzhead.hcrc&&W.pending>D&&(I.adler=c(I.adler,W.pending_buf,W.pending-D,D)),Y(I),D=W.pending,W.pending===W.pending_buf_size)){te=1;break}te=W.gzindex<W.gzhead.comment.length?255&W.gzhead.comment.charCodeAt(W.gzindex++):0,_e(W,te)}while(te!==0);W.gzhead.hcrc&&W.pending>D&&(I.adler=c(I.adler,W.pending_buf,W.pending-D,D)),te===0&&(W.status=103)}else W.status=103;if(W.status===103&&(W.gzhead.hcrc?(W.pending+2>W.pending_buf_size&&Y(I),W.pending+2<=W.pending_buf_size&&(_e(W,255&I.adler),_e(W,I.adler>>8&255),I.adler=0,W.status=O)):W.status=O),W.pending!==0){if(Y(I),I.avail_out===0)return W.last_flush=-1,u}else if(I.avail_in===0&&V(ae)<=V(Q)&&ae!==p)return q(I,-5);if(W.status===666&&I.avail_in!==0)return q(I,-5);if(I.avail_in!==0||W.lookahead!==0||ae!==d&&W.status!==666){var G=W.strategy===2?(function(ee,P){for(var b;;){if(ee.lookahead===0&&(J(ee),ee.lookahead===0)){if(P===d)return T;break}if(ee.match_length=0,b=o._tr_tally(ee,0,ee.window[ee.strstart]),ee.lookahead--,ee.strstart++,b&&(K(ee,!1),ee.strm.avail_out===0))return T}return ee.insert=0,P===p?(K(ee,!0),ee.strm.avail_out===0?F:H):ee.last_lit&&(K(ee,!1),ee.strm.avail_out===0)?T:B})(W,ae):W.strategy===3?(function(ee,P){for(var b,k,j,$,Z=ee.window;;){if(ee.lookahead<=R){if(J(ee),ee.lookahead<=R&&P===d)return T;if(ee.lookahead===0)break}if(ee.match_length=0,ee.lookahead>=M&&0<ee.strstart&&(k=Z[j=ee.strstart-1])===Z[++j]&&k===Z[++j]&&k===Z[++j]){$=ee.strstart+R;do;while(k===Z[++j]&&k===Z[++j]&&k===Z[++j]&&k===Z[++j]&&k===Z[++j]&&k===Z[++j]&&k===Z[++j]&&k===Z[++j]&&j<$);ee.match_length=R-($-j),ee.match_length>ee.lookahead&&(ee.match_length=ee.lookahead)}if(ee.match_length>=M?(b=o._tr_tally(ee,1,ee.match_length-M),ee.lookahead-=ee.match_length,ee.strstart+=ee.match_length,ee.match_length=0):(b=o._tr_tally(ee,0,ee.window[ee.strstart]),ee.lookahead--,ee.strstart++),b&&(K(ee,!1),ee.strm.avail_out===0))return T}return ee.insert=0,P===p?(K(ee,!0),ee.strm.avail_out===0?F:H):ee.last_lit&&(K(ee,!1),ee.strm.avail_out===0)?T:B})(W,ae):s[W.level].func(W,ae);if(G!==F&&G!==H||(W.status=666),G===T||G===F)return I.avail_out===0&&(W.last_flush=-1),u;if(G===B&&(ae===1?o._tr_align(W):ae!==5&&(o._tr_stored_block(W,0,0,!1),ae===3&&(re(W.head),W.lookahead===0&&(W.strstart=0,W.block_start=0,W.insert=0))),Y(I),I.avail_out===0))return W.last_flush=-1,u}return ae!==p?u:W.wrap<=0?1:(W.wrap===2?(_e(W,255&I.adler),_e(W,I.adler>>8&255),_e(W,I.adler>>16&255),_e(W,I.adler>>24&255),_e(W,255&I.total_in),_e(W,I.total_in>>8&255),_e(W,I.total_in>>16&255),_e(W,I.total_in>>24&255)):(Ce(W,I.adler>>>16),Ce(W,65535&I.adler)),Y(I),0<W.wrap&&(W.wrap=-W.wrap),W.pending!==0?u:1)},n.deflateEnd=function(I){var ae;return I&&I.state?(ae=I.state.status)!==L&&ae!==69&&ae!==73&&ae!==91&&ae!==103&&ae!==O&&ae!==666?q(I,v):(I.state=null,ae===O?q(I,-3):u):v},n.deflateSetDictionary=function(I,ae){var Q,W,D,te,de,G,ee,P,b=ae.length;if(!I||!I.state||(te=(Q=I.state).wrap)===2||te===1&&Q.status!==L||Q.lookahead)return v;for(te===1&&(I.adler=l(I.adler,ae,b,0)),Q.wrap=0,b>=Q.w_size&&(te===0&&(re(Q.head),Q.strstart=0,Q.block_start=0,Q.insert=0),P=new a.Buf8(Q.w_size),a.arraySet(P,ae,b-Q.w_size,Q.w_size,0),ae=P,b=Q.w_size),de=I.avail_in,G=I.next_in,ee=I.input,I.avail_in=b,I.next_in=0,I.input=ae,J(Q);Q.lookahead>=M;){for(W=Q.strstart,D=Q.lookahead-(M-1);Q.ins_h=(Q.ins_h<<Q.hash_shift^Q.window[W+M-1])&Q.hash_mask,Q.prev[W&Q.w_mask]=Q.head[Q.ins_h],Q.head[Q.ins_h]=W,W++,--D;);Q.strstart=W,Q.lookahead=M-1,J(Q)}return Q.strstart+=Q.lookahead,Q.block_start=Q.strstart,Q.insert=Q.lookahead,Q.lookahead=0,Q.match_length=Q.prev_length=M-1,Q.match_available=0,I.next_in=G,I.input=ee,I.avail_in=de,Q.wrap=te,u},n.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(t,i,n){i.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(t,i,n){i.exports=function(s,a){var o,l,c,h,d,p,u,v,m,g,f,y,x,_,E,S,C,w,M,R,N,L,O,T,B;o=s.state,l=s.next_in,T=s.input,c=l+(s.avail_in-5),h=s.next_out,B=s.output,d=h-(a-s.avail_out),p=h+(s.avail_out-257),u=o.dmax,v=o.wsize,m=o.whave,g=o.wnext,f=o.window,y=o.hold,x=o.bits,_=o.lencode,E=o.distcode,S=(1<<o.lenbits)-1,C=(1<<o.distbits)-1;e:do{x<15&&(y+=T[l++]<<x,x+=8,y+=T[l++]<<x,x+=8),w=_[y&S];t:for(;;){if(y>>>=M=w>>>24,x-=M,(M=w>>>16&255)===0)B[h++]=65535&w;else{if(!(16&M)){if((64&M)==0){w=_[(65535&w)+(y&(1<<M)-1)];continue t}if(32&M){o.mode=12;break e}s.msg="invalid literal/length code",o.mode=30;break e}R=65535&w,(M&=15)&&(x<M&&(y+=T[l++]<<x,x+=8),R+=y&(1<<M)-1,y>>>=M,x-=M),x<15&&(y+=T[l++]<<x,x+=8,y+=T[l++]<<x,x+=8),w=E[y&C];i:for(;;){if(y>>>=M=w>>>24,x-=M,!(16&(M=w>>>16&255))){if((64&M)==0){w=E[(65535&w)+(y&(1<<M)-1)];continue i}s.msg="invalid distance code",o.mode=30;break e}if(N=65535&w,x<(M&=15)&&(y+=T[l++]<<x,(x+=8)<M&&(y+=T[l++]<<x,x+=8)),u<(N+=y&(1<<M)-1)){s.msg="invalid distance too far back",o.mode=30;break e}if(y>>>=M,x-=M,(M=h-d)<N){if(m<(M=N-M)&&o.sane){s.msg="invalid distance too far back",o.mode=30;break e}if(O=f,(L=0)===g){if(L+=v-M,M<R){for(R-=M;B[h++]=f[L++],--M;);L=h-N,O=B}}else if(g<M){if(L+=v+g-M,(M-=g)<R){for(R-=M;B[h++]=f[L++],--M;);if(L=0,g<R){for(R-=M=g;B[h++]=f[L++],--M;);L=h-N,O=B}}}else if(L+=g-M,M<R){for(R-=M;B[h++]=f[L++],--M;);L=h-N,O=B}for(;2<R;)B[h++]=O[L++],B[h++]=O[L++],B[h++]=O[L++],R-=3;R&&(B[h++]=O[L++],1<R&&(B[h++]=O[L++]))}else{for(L=h-N;B[h++]=B[L++],B[h++]=B[L++],B[h++]=B[L++],2<(R-=3););R&&(B[h++]=B[L++],1<R&&(B[h++]=B[L++]))}break}}break}}while(l<c&&h<p);l-=R=x>>3,y&=(1<<(x-=R<<3))-1,s.next_in=l,s.next_out=h,s.avail_in=l<c?c-l+5:5-(l-c),s.avail_out=h<p?p-h+257:257-(h-p),o.hold=y,o.bits=x}},{}],49:[function(t,i,n){var s=t("../utils/common"),a=t("./adler32"),o=t("./crc32"),l=t("./inffast"),c=t("./inftrees"),h=1,d=2,p=0,u=-2,v=1,m=852,g=592;function f(L){return(L>>>24&255)+(L>>>8&65280)+((65280&L)<<8)+((255&L)<<24)}function y(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new s.Buf16(320),this.work=new s.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function x(L){var O;return L&&L.state?(O=L.state,L.total_in=L.total_out=O.total=0,L.msg="",O.wrap&&(L.adler=1&O.wrap),O.mode=v,O.last=0,O.havedict=0,O.dmax=32768,O.head=null,O.hold=0,O.bits=0,O.lencode=O.lendyn=new s.Buf32(m),O.distcode=O.distdyn=new s.Buf32(g),O.sane=1,O.back=-1,p):u}function _(L){var O;return L&&L.state?((O=L.state).wsize=0,O.whave=0,O.wnext=0,x(L)):u}function E(L,O){var T,B;return L&&L.state?(B=L.state,O<0?(T=0,O=-O):(T=1+(O>>4),O<48&&(O&=15)),O&&(O<8||15<O)?u:(B.window!==null&&B.wbits!==O&&(B.window=null),B.wrap=T,B.wbits=O,_(L))):u}function S(L,O){var T,B;return L?(B=new y,(L.state=B).window=null,(T=E(L,O))!==p&&(L.state=null),T):u}var C,w,M=!0;function R(L){if(M){var O;for(C=new s.Buf32(512),w=new s.Buf32(32),O=0;O<144;)L.lens[O++]=8;for(;O<256;)L.lens[O++]=9;for(;O<280;)L.lens[O++]=7;for(;O<288;)L.lens[O++]=8;for(c(h,L.lens,0,288,C,0,L.work,{bits:9}),O=0;O<32;)L.lens[O++]=5;c(d,L.lens,0,32,w,0,L.work,{bits:5}),M=!1}L.lencode=C,L.lenbits=9,L.distcode=w,L.distbits=5}function N(L,O,T,B){var F,H=L.state;return H.window===null&&(H.wsize=1<<H.wbits,H.wnext=0,H.whave=0,H.window=new s.Buf8(H.wsize)),B>=H.wsize?(s.arraySet(H.window,O,T-H.wsize,H.wsize,0),H.wnext=0,H.whave=H.wsize):(B<(F=H.wsize-H.wnext)&&(F=B),s.arraySet(H.window,O,T-B,F,H.wnext),(B-=F)?(s.arraySet(H.window,O,T-B,B,0),H.wnext=B,H.whave=H.wsize):(H.wnext+=F,H.wnext===H.wsize&&(H.wnext=0),H.whave<H.wsize&&(H.whave+=F))),0}n.inflateReset=_,n.inflateReset2=E,n.inflateResetKeep=x,n.inflateInit=function(L){return S(L,15)},n.inflateInit2=S,n.inflate=function(L,O){var T,B,F,H,q,V,re,Y,K,_e,Ce,be,J,oe,ue,Re,De,Oe,it,qe,I,ae,Q,W,D=0,te=new s.Buf8(4),de=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!L||!L.state||!L.output||!L.input&&L.avail_in!==0)return u;(T=L.state).mode===12&&(T.mode=13),q=L.next_out,F=L.output,re=L.avail_out,H=L.next_in,B=L.input,V=L.avail_in,Y=T.hold,K=T.bits,_e=V,Ce=re,ae=p;e:for(;;)switch(T.mode){case v:if(T.wrap===0){T.mode=13;break}for(;K<16;){if(V===0)break e;V--,Y+=B[H++]<<K,K+=8}if(2&T.wrap&&Y===35615){te[T.check=0]=255&Y,te[1]=Y>>>8&255,T.check=o(T.check,te,2,0),K=Y=0,T.mode=2;break}if(T.flags=0,T.head&&(T.head.done=!1),!(1&T.wrap)||(((255&Y)<<8)+(Y>>8))%31){L.msg="incorrect header check",T.mode=30;break}if((15&Y)!=8){L.msg="unknown compression method",T.mode=30;break}if(K-=4,I=8+(15&(Y>>>=4)),T.wbits===0)T.wbits=I;else if(I>T.wbits){L.msg="invalid window size",T.mode=30;break}T.dmax=1<<I,L.adler=T.check=1,T.mode=512&Y?10:12,K=Y=0;break;case 2:for(;K<16;){if(V===0)break e;V--,Y+=B[H++]<<K,K+=8}if(T.flags=Y,(255&T.flags)!=8){L.msg="unknown compression method",T.mode=30;break}if(57344&T.flags){L.msg="unknown header flags set",T.mode=30;break}T.head&&(T.head.text=Y>>8&1),512&T.flags&&(te[0]=255&Y,te[1]=Y>>>8&255,T.check=o(T.check,te,2,0)),K=Y=0,T.mode=3;case 3:for(;K<32;){if(V===0)break e;V--,Y+=B[H++]<<K,K+=8}T.head&&(T.head.time=Y),512&T.flags&&(te[0]=255&Y,te[1]=Y>>>8&255,te[2]=Y>>>16&255,te[3]=Y>>>24&255,T.check=o(T.check,te,4,0)),K=Y=0,T.mode=4;case 4:for(;K<16;){if(V===0)break e;V--,Y+=B[H++]<<K,K+=8}T.head&&(T.head.xflags=255&Y,T.head.os=Y>>8),512&T.flags&&(te[0]=255&Y,te[1]=Y>>>8&255,T.check=o(T.check,te,2,0)),K=Y=0,T.mode=5;case 5:if(1024&T.flags){for(;K<16;){if(V===0)break e;V--,Y+=B[H++]<<K,K+=8}T.length=Y,T.head&&(T.head.extra_len=Y),512&T.flags&&(te[0]=255&Y,te[1]=Y>>>8&255,T.check=o(T.check,te,2,0)),K=Y=0}else T.head&&(T.head.extra=null);T.mode=6;case 6:if(1024&T.flags&&(V<(be=T.length)&&(be=V),be&&(T.head&&(I=T.head.extra_len-T.length,T.head.extra||(T.head.extra=new Array(T.head.extra_len)),s.arraySet(T.head.extra,B,H,be,I)),512&T.flags&&(T.check=o(T.check,B,be,H)),V-=be,H+=be,T.length-=be),T.length))break e;T.length=0,T.mode=7;case 7:if(2048&T.flags){if(V===0)break e;for(be=0;I=B[H+be++],T.head&&I&&T.length<65536&&(T.head.name+=String.fromCharCode(I)),I&&be<V;);if(512&T.flags&&(T.check=o(T.check,B,be,H)),V-=be,H+=be,I)break e}else T.head&&(T.head.name=null);T.length=0,T.mode=8;case 8:if(4096&T.flags){if(V===0)break e;for(be=0;I=B[H+be++],T.head&&I&&T.length<65536&&(T.head.comment+=String.fromCharCode(I)),I&&be<V;);if(512&T.flags&&(T.check=o(T.check,B,be,H)),V-=be,H+=be,I)break e}else T.head&&(T.head.comment=null);T.mode=9;case 9:if(512&T.flags){for(;K<16;){if(V===0)break e;V--,Y+=B[H++]<<K,K+=8}if(Y!==(65535&T.check)){L.msg="header crc mismatch",T.mode=30;break}K=Y=0}T.head&&(T.head.hcrc=T.flags>>9&1,T.head.done=!0),L.adler=T.check=0,T.mode=12;break;case 10:for(;K<32;){if(V===0)break e;V--,Y+=B[H++]<<K,K+=8}L.adler=T.check=f(Y),K=Y=0,T.mode=11;case 11:if(T.havedict===0)return L.next_out=q,L.avail_out=re,L.next_in=H,L.avail_in=V,T.hold=Y,T.bits=K,2;L.adler=T.check=1,T.mode=12;case 12:if(O===5||O===6)break e;case 13:if(T.last){Y>>>=7&K,K-=7&K,T.mode=27;break}for(;K<3;){if(V===0)break e;V--,Y+=B[H++]<<K,K+=8}switch(T.last=1&Y,K-=1,3&(Y>>>=1)){case 0:T.mode=14;break;case 1:if(R(T),T.mode=20,O!==6)break;Y>>>=2,K-=2;break e;case 2:T.mode=17;break;case 3:L.msg="invalid block type",T.mode=30}Y>>>=2,K-=2;break;case 14:for(Y>>>=7&K,K-=7&K;K<32;){if(V===0)break e;V--,Y+=B[H++]<<K,K+=8}if((65535&Y)!=(Y>>>16^65535)){L.msg="invalid stored block lengths",T.mode=30;break}if(T.length=65535&Y,K=Y=0,T.mode=15,O===6)break e;case 15:T.mode=16;case 16:if(be=T.length){if(V<be&&(be=V),re<be&&(be=re),be===0)break e;s.arraySet(F,B,H,be,q),V-=be,H+=be,re-=be,q+=be,T.length-=be;break}T.mode=12;break;case 17:for(;K<14;){if(V===0)break e;V--,Y+=B[H++]<<K,K+=8}if(T.nlen=257+(31&Y),Y>>>=5,K-=5,T.ndist=1+(31&Y),Y>>>=5,K-=5,T.ncode=4+(15&Y),Y>>>=4,K-=4,286<T.nlen||30<T.ndist){L.msg="too many length or distance symbols",T.mode=30;break}T.have=0,T.mode=18;case 18:for(;T.have<T.ncode;){for(;K<3;){if(V===0)break e;V--,Y+=B[H++]<<K,K+=8}T.lens[de[T.have++]]=7&Y,Y>>>=3,K-=3}for(;T.have<19;)T.lens[de[T.have++]]=0;if(T.lencode=T.lendyn,T.lenbits=7,Q={bits:T.lenbits},ae=c(0,T.lens,0,19,T.lencode,0,T.work,Q),T.lenbits=Q.bits,ae){L.msg="invalid code lengths set",T.mode=30;break}T.have=0,T.mode=19;case 19:for(;T.have<T.nlen+T.ndist;){for(;Re=(D=T.lencode[Y&(1<<T.lenbits)-1])>>>16&255,De=65535&D,!((ue=D>>>24)<=K);){if(V===0)break e;V--,Y+=B[H++]<<K,K+=8}if(De<16)Y>>>=ue,K-=ue,T.lens[T.have++]=De;else{if(De===16){for(W=ue+2;K<W;){if(V===0)break e;V--,Y+=B[H++]<<K,K+=8}if(Y>>>=ue,K-=ue,T.have===0){L.msg="invalid bit length repeat",T.mode=30;break}I=T.lens[T.have-1],be=3+(3&Y),Y>>>=2,K-=2}else if(De===17){for(W=ue+3;K<W;){if(V===0)break e;V--,Y+=B[H++]<<K,K+=8}K-=ue,I=0,be=3+(7&(Y>>>=ue)),Y>>>=3,K-=3}else{for(W=ue+7;K<W;){if(V===0)break e;V--,Y+=B[H++]<<K,K+=8}K-=ue,I=0,be=11+(127&(Y>>>=ue)),Y>>>=7,K-=7}if(T.have+be>T.nlen+T.ndist){L.msg="invalid bit length repeat",T.mode=30;break}for(;be--;)T.lens[T.have++]=I}}if(T.mode===30)break;if(T.lens[256]===0){L.msg="invalid code -- missing end-of-block",T.mode=30;break}if(T.lenbits=9,Q={bits:T.lenbits},ae=c(h,T.lens,0,T.nlen,T.lencode,0,T.work,Q),T.lenbits=Q.bits,ae){L.msg="invalid literal/lengths set",T.mode=30;break}if(T.distbits=6,T.distcode=T.distdyn,Q={bits:T.distbits},ae=c(d,T.lens,T.nlen,T.ndist,T.distcode,0,T.work,Q),T.distbits=Q.bits,ae){L.msg="invalid distances set",T.mode=30;break}if(T.mode=20,O===6)break e;case 20:T.mode=21;case 21:if(6<=V&&258<=re){L.next_out=q,L.avail_out=re,L.next_in=H,L.avail_in=V,T.hold=Y,T.bits=K,l(L,Ce),q=L.next_out,F=L.output,re=L.avail_out,H=L.next_in,B=L.input,V=L.avail_in,Y=T.hold,K=T.bits,T.mode===12&&(T.back=-1);break}for(T.back=0;Re=(D=T.lencode[Y&(1<<T.lenbits)-1])>>>16&255,De=65535&D,!((ue=D>>>24)<=K);){if(V===0)break e;V--,Y+=B[H++]<<K,K+=8}if(Re&&(240&Re)==0){for(Oe=ue,it=Re,qe=De;Re=(D=T.lencode[qe+((Y&(1<<Oe+it)-1)>>Oe)])>>>16&255,De=65535&D,!(Oe+(ue=D>>>24)<=K);){if(V===0)break e;V--,Y+=B[H++]<<K,K+=8}Y>>>=Oe,K-=Oe,T.back+=Oe}if(Y>>>=ue,K-=ue,T.back+=ue,T.length=De,Re===0){T.mode=26;break}if(32&Re){T.back=-1,T.mode=12;break}if(64&Re){L.msg="invalid literal/length code",T.mode=30;break}T.extra=15&Re,T.mode=22;case 22:if(T.extra){for(W=T.extra;K<W;){if(V===0)break e;V--,Y+=B[H++]<<K,K+=8}T.length+=Y&(1<<T.extra)-1,Y>>>=T.extra,K-=T.extra,T.back+=T.extra}T.was=T.length,T.mode=23;case 23:for(;Re=(D=T.distcode[Y&(1<<T.distbits)-1])>>>16&255,De=65535&D,!((ue=D>>>24)<=K);){if(V===0)break e;V--,Y+=B[H++]<<K,K+=8}if((240&Re)==0){for(Oe=ue,it=Re,qe=De;Re=(D=T.distcode[qe+((Y&(1<<Oe+it)-1)>>Oe)])>>>16&255,De=65535&D,!(Oe+(ue=D>>>24)<=K);){if(V===0)break e;V--,Y+=B[H++]<<K,K+=8}Y>>>=Oe,K-=Oe,T.back+=Oe}if(Y>>>=ue,K-=ue,T.back+=ue,64&Re){L.msg="invalid distance code",T.mode=30;break}T.offset=De,T.extra=15&Re,T.mode=24;case 24:if(T.extra){for(W=T.extra;K<W;){if(V===0)break e;V--,Y+=B[H++]<<K,K+=8}T.offset+=Y&(1<<T.extra)-1,Y>>>=T.extra,K-=T.extra,T.back+=T.extra}if(T.offset>T.dmax){L.msg="invalid distance too far back",T.mode=30;break}T.mode=25;case 25:if(re===0)break e;if(be=Ce-re,T.offset>be){if((be=T.offset-be)>T.whave&&T.sane){L.msg="invalid distance too far back",T.mode=30;break}J=be>T.wnext?(be-=T.wnext,T.wsize-be):T.wnext-be,be>T.length&&(be=T.length),oe=T.window}else oe=F,J=q-T.offset,be=T.length;for(re<be&&(be=re),re-=be,T.length-=be;F[q++]=oe[J++],--be;);T.length===0&&(T.mode=21);break;case 26:if(re===0)break e;F[q++]=T.length,re--,T.mode=21;break;case 27:if(T.wrap){for(;K<32;){if(V===0)break e;V--,Y|=B[H++]<<K,K+=8}if(Ce-=re,L.total_out+=Ce,T.total+=Ce,Ce&&(L.adler=T.check=T.flags?o(T.check,F,Ce,q-Ce):a(T.check,F,Ce,q-Ce)),Ce=re,(T.flags?Y:f(Y))!==T.check){L.msg="incorrect data check",T.mode=30;break}K=Y=0}T.mode=28;case 28:if(T.wrap&&T.flags){for(;K<32;){if(V===0)break e;V--,Y+=B[H++]<<K,K+=8}if(Y!==(4294967295&T.total)){L.msg="incorrect length check",T.mode=30;break}K=Y=0}T.mode=29;case 29:ae=1;break e;case 30:ae=-3;break e;case 31:return-4;default:return u}return L.next_out=q,L.avail_out=re,L.next_in=H,L.avail_in=V,T.hold=Y,T.bits=K,(T.wsize||Ce!==L.avail_out&&T.mode<30&&(T.mode<27||O!==4))&&N(L,L.output,L.next_out,Ce-L.avail_out)?(T.mode=31,-4):(_e-=L.avail_in,Ce-=L.avail_out,L.total_in+=_e,L.total_out+=Ce,T.total+=Ce,T.wrap&&Ce&&(L.adler=T.check=T.flags?o(T.check,F,Ce,L.next_out-Ce):a(T.check,F,Ce,L.next_out-Ce)),L.data_type=T.bits+(T.last?64:0)+(T.mode===12?128:0)+(T.mode===20||T.mode===15?256:0),(_e==0&&Ce===0||O===4)&&ae===p&&(ae=-5),ae)},n.inflateEnd=function(L){if(!L||!L.state)return u;var O=L.state;return O.window&&(O.window=null),L.state=null,p},n.inflateGetHeader=function(L,O){var T;return L&&L.state?(2&(T=L.state).wrap)==0?u:((T.head=O).done=!1,p):u},n.inflateSetDictionary=function(L,O){var T,B=O.length;return L&&L.state?(T=L.state).wrap!==0&&T.mode!==11?u:T.mode===11&&a(1,O,B,0)!==T.check?-3:N(L,O,B,B)?(T.mode=31,-4):(T.havedict=1,p):u},n.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(t,i,n){var s=t("../utils/common"),a=[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],o=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],l=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],c=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];i.exports=function(h,d,p,u,v,m,g,f){var y,x,_,E,S,C,w,M,R,N=f.bits,L=0,O=0,T=0,B=0,F=0,H=0,q=0,V=0,re=0,Y=0,K=null,_e=0,Ce=new s.Buf16(16),be=new s.Buf16(16),J=null,oe=0;for(L=0;L<=15;L++)Ce[L]=0;for(O=0;O<u;O++)Ce[d[p+O]]++;for(F=N,B=15;1<=B&&Ce[B]===0;B--);if(B<F&&(F=B),B===0)return v[m++]=20971520,v[m++]=20971520,f.bits=1,0;for(T=1;T<B&&Ce[T]===0;T++);for(F<T&&(F=T),L=V=1;L<=15;L++)if(V<<=1,(V-=Ce[L])<0)return-1;if(0<V&&(h===0||B!==1))return-1;for(be[1]=0,L=1;L<15;L++)be[L+1]=be[L]+Ce[L];for(O=0;O<u;O++)d[p+O]!==0&&(g[be[d[p+O]]++]=O);if(C=h===0?(K=J=g,19):h===1?(K=a,_e-=257,J=o,oe-=257,256):(K=l,J=c,-1),L=T,S=m,q=O=Y=0,_=-1,E=(re=1<<(H=F))-1,h===1&&852<re||h===2&&592<re)return 1;for(;;){for(w=L-q,R=g[O]<C?(M=0,g[O]):g[O]>C?(M=J[oe+g[O]],K[_e+g[O]]):(M=96,0),y=1<<L-q,T=x=1<<H;v[S+(Y>>q)+(x-=y)]=w<<24|M<<16|R|0,x!==0;);for(y=1<<L-1;Y&y;)y>>=1;if(y!==0?(Y&=y-1,Y+=y):Y=0,O++,--Ce[L]==0){if(L===B)break;L=d[p+g[O]]}if(F<L&&(Y&E)!==_){for(q===0&&(q=F),S+=T,V=1<<(H=L-q);H+q<B&&!((V-=Ce[H+q])<=0);)H++,V<<=1;if(re+=1<<H,h===1&&852<re||h===2&&592<re)return 1;v[_=Y&E]=F<<24|H<<16|S-m|0}}return Y!==0&&(v[S+Y]=L-q<<24|64<<16|0),f.bits=F,0}},{"../utils/common":41}],51:[function(t,i,n){i.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(t,i,n){var s=t("../utils/common"),a=0,o=1;function l(D){for(var te=D.length;0<=--te;)D[te]=0}var c=0,h=29,d=256,p=d+1+h,u=30,v=19,m=2*p+1,g=15,f=16,y=7,x=256,_=16,E=17,S=18,C=[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],w=[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],M=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],R=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],N=new Array(2*(p+2));l(N);var L=new Array(2*u);l(L);var O=new Array(512);l(O);var T=new Array(256);l(T);var B=new Array(h);l(B);var F,H,q,V=new Array(u);function re(D,te,de,G,ee){this.static_tree=D,this.extra_bits=te,this.extra_base=de,this.elems=G,this.max_length=ee,this.has_stree=D&&D.length}function Y(D,te){this.dyn_tree=D,this.max_code=0,this.stat_desc=te}function K(D){return D<256?O[D]:O[256+(D>>>7)]}function _e(D,te){D.pending_buf[D.pending++]=255&te,D.pending_buf[D.pending++]=te>>>8&255}function Ce(D,te,de){D.bi_valid>f-de?(D.bi_buf|=te<<D.bi_valid&65535,_e(D,D.bi_buf),D.bi_buf=te>>f-D.bi_valid,D.bi_valid+=de-f):(D.bi_buf|=te<<D.bi_valid&65535,D.bi_valid+=de)}function be(D,te,de){Ce(D,de[2*te],de[2*te+1])}function J(D,te){for(var de=0;de|=1&D,D>>>=1,de<<=1,0<--te;);return de>>>1}function oe(D,te,de){var G,ee,P=new Array(g+1),b=0;for(G=1;G<=g;G++)P[G]=b=b+de[G-1]<<1;for(ee=0;ee<=te;ee++){var k=D[2*ee+1];k!==0&&(D[2*ee]=J(P[k]++,k))}}function ue(D){var te;for(te=0;te<p;te++)D.dyn_ltree[2*te]=0;for(te=0;te<u;te++)D.dyn_dtree[2*te]=0;for(te=0;te<v;te++)D.bl_tree[2*te]=0;D.dyn_ltree[2*x]=1,D.opt_len=D.static_len=0,D.last_lit=D.matches=0}function Re(D){8<D.bi_valid?_e(D,D.bi_buf):0<D.bi_valid&&(D.pending_buf[D.pending++]=D.bi_buf),D.bi_buf=0,D.bi_valid=0}function De(D,te,de,G){var ee=2*te,P=2*de;return D[ee]<D[P]||D[ee]===D[P]&&G[te]<=G[de]}function Oe(D,te,de){for(var G=D.heap[de],ee=de<<1;ee<=D.heap_len&&(ee<D.heap_len&&De(te,D.heap[ee+1],D.heap[ee],D.depth)&&ee++,!De(te,G,D.heap[ee],D.depth));)D.heap[de]=D.heap[ee],de=ee,ee<<=1;D.heap[de]=G}function it(D,te,de){var G,ee,P,b,k=0;if(D.last_lit!==0)for(;G=D.pending_buf[D.d_buf+2*k]<<8|D.pending_buf[D.d_buf+2*k+1],ee=D.pending_buf[D.l_buf+k],k++,G===0?be(D,ee,te):(be(D,(P=T[ee])+d+1,te),(b=C[P])!==0&&Ce(D,ee-=B[P],b),be(D,P=K(--G),de),(b=w[P])!==0&&Ce(D,G-=V[P],b)),k<D.last_lit;);be(D,x,te)}function qe(D,te){var de,G,ee,P=te.dyn_tree,b=te.stat_desc.static_tree,k=te.stat_desc.has_stree,j=te.stat_desc.elems,$=-1;for(D.heap_len=0,D.heap_max=m,de=0;de<j;de++)P[2*de]!==0?(D.heap[++D.heap_len]=$=de,D.depth[de]=0):P[2*de+1]=0;for(;D.heap_len<2;)P[2*(ee=D.heap[++D.heap_len]=$<2?++$:0)]=1,D.depth[ee]=0,D.opt_len--,k&&(D.static_len-=b[2*ee+1]);for(te.max_code=$,de=D.heap_len>>1;1<=de;de--)Oe(D,P,de);for(ee=j;de=D.heap[1],D.heap[1]=D.heap[D.heap_len--],Oe(D,P,1),G=D.heap[1],D.heap[--D.heap_max]=de,D.heap[--D.heap_max]=G,P[2*ee]=P[2*de]+P[2*G],D.depth[ee]=(D.depth[de]>=D.depth[G]?D.depth[de]:D.depth[G])+1,P[2*de+1]=P[2*G+1]=ee,D.heap[1]=ee++,Oe(D,P,1),2<=D.heap_len;);D.heap[--D.heap_max]=D.heap[1],(function(Z,Pe){var ge,Ue,Fe,le,ve,ze,ke=Pe.dyn_tree,we=Pe.max_code,je=Pe.stat_desc.static_tree,z=Pe.stat_desc.has_stree,ye=Pe.stat_desc.extra_bits,me=Pe.stat_desc.extra_base,Le=Pe.stat_desc.max_length,pe=0;for(le=0;le<=g;le++)Z.bl_count[le]=0;for(ke[2*Z.heap[Z.heap_max]+1]=0,ge=Z.heap_max+1;ge<m;ge++)Le<(le=ke[2*ke[2*(Ue=Z.heap[ge])+1]+1]+1)&&(le=Le,pe++),ke[2*Ue+1]=le,we<Ue||(Z.bl_count[le]++,ve=0,me<=Ue&&(ve=ye[Ue-me]),ze=ke[2*Ue],Z.opt_len+=ze*(le+ve),z&&(Z.static_len+=ze*(je[2*Ue+1]+ve)));if(pe!==0){do{for(le=Le-1;Z.bl_count[le]===0;)le--;Z.bl_count[le]--,Z.bl_count[le+1]+=2,Z.bl_count[Le]--,pe-=2}while(0<pe);for(le=Le;le!==0;le--)for(Ue=Z.bl_count[le];Ue!==0;)we<(Fe=Z.heap[--ge])||(ke[2*Fe+1]!==le&&(Z.opt_len+=(le-ke[2*Fe+1])*ke[2*Fe],ke[2*Fe+1]=le),Ue--)}})(D,te),oe(P,$,D.bl_count)}function I(D,te,de){var G,ee,P=-1,b=te[1],k=0,j=7,$=4;for(b===0&&(j=138,$=3),te[2*(de+1)+1]=65535,G=0;G<=de;G++)ee=b,b=te[2*(G+1)+1],++k<j&&ee===b||(k<$?D.bl_tree[2*ee]+=k:ee!==0?(ee!==P&&D.bl_tree[2*ee]++,D.bl_tree[2*_]++):k<=10?D.bl_tree[2*E]++:D.bl_tree[2*S]++,P=ee,$=(k=0)===b?(j=138,3):ee===b?(j=6,3):(j=7,4))}function ae(D,te,de){var G,ee,P=-1,b=te[1],k=0,j=7,$=4;for(b===0&&(j=138,$=3),G=0;G<=de;G++)if(ee=b,b=te[2*(G+1)+1],!(++k<j&&ee===b)){if(k<$)for(;be(D,ee,D.bl_tree),--k!=0;);else ee!==0?(ee!==P&&(be(D,ee,D.bl_tree),k--),be(D,_,D.bl_tree),Ce(D,k-3,2)):k<=10?(be(D,E,D.bl_tree),Ce(D,k-3,3)):(be(D,S,D.bl_tree),Ce(D,k-11,7));P=ee,$=(k=0)===b?(j=138,3):ee===b?(j=6,3):(j=7,4)}}l(V);var Q=!1;function W(D,te,de,G){Ce(D,(c<<1)+(G?1:0),3),(function(ee,P,b,k){Re(ee),_e(ee,b),_e(ee,~b),s.arraySet(ee.pending_buf,ee.window,P,b,ee.pending),ee.pending+=b})(D,te,de)}n._tr_init=function(D){Q||((function(){var te,de,G,ee,P,b=new Array(g+1);for(ee=G=0;ee<h-1;ee++)for(B[ee]=G,te=0;te<1<<C[ee];te++)T[G++]=ee;for(T[G-1]=ee,ee=P=0;ee<16;ee++)for(V[ee]=P,te=0;te<1<<w[ee];te++)O[P++]=ee;for(P>>=7;ee<u;ee++)for(V[ee]=P<<7,te=0;te<1<<w[ee]-7;te++)O[256+P++]=ee;for(de=0;de<=g;de++)b[de]=0;for(te=0;te<=143;)N[2*te+1]=8,te++,b[8]++;for(;te<=255;)N[2*te+1]=9,te++,b[9]++;for(;te<=279;)N[2*te+1]=7,te++,b[7]++;for(;te<=287;)N[2*te+1]=8,te++,b[8]++;for(oe(N,p+1,b),te=0;te<u;te++)L[2*te+1]=5,L[2*te]=J(te,5);F=new re(N,C,d+1,p,g),H=new re(L,w,0,u,g),q=new re(new Array(0),M,0,v,y)})(),Q=!0),D.l_desc=new Y(D.dyn_ltree,F),D.d_desc=new Y(D.dyn_dtree,H),D.bl_desc=new Y(D.bl_tree,q),D.bi_buf=0,D.bi_valid=0,ue(D)},n._tr_stored_block=W,n._tr_flush_block=function(D,te,de,G){var ee,P,b=0;0<D.level?(D.strm.data_type===2&&(D.strm.data_type=(function(k){var j,$=4093624447;for(j=0;j<=31;j++,$>>>=1)if(1&$&&k.dyn_ltree[2*j]!==0)return a;if(k.dyn_ltree[18]!==0||k.dyn_ltree[20]!==0||k.dyn_ltree[26]!==0)return o;for(j=32;j<d;j++)if(k.dyn_ltree[2*j]!==0)return o;return a})(D)),qe(D,D.l_desc),qe(D,D.d_desc),b=(function(k){var j;for(I(k,k.dyn_ltree,k.l_desc.max_code),I(k,k.dyn_dtree,k.d_desc.max_code),qe(k,k.bl_desc),j=v-1;3<=j&&k.bl_tree[2*R[j]+1]===0;j--);return k.opt_len+=3*(j+1)+5+5+4,j})(D),ee=D.opt_len+3+7>>>3,(P=D.static_len+3+7>>>3)<=ee&&(ee=P)):ee=P=de+5,de+4<=ee&&te!==-1?W(D,te,de,G):D.strategy===4||P===ee?(Ce(D,2+(G?1:0),3),it(D,N,L)):(Ce(D,4+(G?1:0),3),(function(k,j,$,Z){var Pe;for(Ce(k,j-257,5),Ce(k,$-1,5),Ce(k,Z-4,4),Pe=0;Pe<Z;Pe++)Ce(k,k.bl_tree[2*R[Pe]+1],3);ae(k,k.dyn_ltree,j-1),ae(k,k.dyn_dtree,$-1)})(D,D.l_desc.max_code+1,D.d_desc.max_code+1,b+1),it(D,D.dyn_ltree,D.dyn_dtree)),ue(D),G&&Re(D)},n._tr_tally=function(D,te,de){return D.pending_buf[D.d_buf+2*D.last_lit]=te>>>8&255,D.pending_buf[D.d_buf+2*D.last_lit+1]=255&te,D.pending_buf[D.l_buf+D.last_lit]=255&de,D.last_lit++,te===0?D.dyn_ltree[2*de]++:(D.matches++,te--,D.dyn_ltree[2*(T[de]+d+1)]++,D.dyn_dtree[2*K(te)]++),D.last_lit===D.lit_bufsize-1},n._tr_align=function(D){Ce(D,2,3),be(D,x,N),(function(te){te.bi_valid===16?(_e(te,te.bi_buf),te.bi_buf=0,te.bi_valid=0):8<=te.bi_valid&&(te.pending_buf[te.pending++]=255&te.bi_buf,te.bi_buf>>=8,te.bi_valid-=8)})(D)}},{"../utils/common":41}],53:[function(t,i,n){i.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(t,i,n){(function(s){(function(a,o){if(!a.setImmediate){var l,c,h,d,p=1,u={},v=!1,m=a.document,g=Object.getPrototypeOf&&Object.getPrototypeOf(a);g=g&&g.setTimeout?g:a,l={}.toString.call(a.process)==="[object process]"?function(_){process.nextTick(function(){y(_)})}:(function(){if(a.postMessage&&!a.importScripts){var _=!0,E=a.onmessage;return a.onmessage=function(){_=!1},a.postMessage("","*"),a.onmessage=E,_}})()?(d="setImmediate$"+Math.random()+"$",a.addEventListener?a.addEventListener("message",x,!1):a.attachEvent("onmessage",x),function(_){a.postMessage(d+_,"*")}):a.MessageChannel?((h=new MessageChannel).port1.onmessage=function(_){y(_.data)},function(_){h.port2.postMessage(_)}):m&&"onreadystatechange"in m.createElement("script")?(c=m.documentElement,function(_){var E=m.createElement("script");E.onreadystatechange=function(){y(_),E.onreadystatechange=null,c.removeChild(E),E=null},c.appendChild(E)}):function(_){setTimeout(y,0,_)},g.setImmediate=function(_){typeof _!="function"&&(_=new Function(""+_));for(var E=new Array(arguments.length-1),S=0;S<E.length;S++)E[S]=arguments[S+1];var C={callback:_,args:E};return u[p]=C,l(p),p++},g.clearImmediate=f}function f(_){delete u[_]}function y(_){if(v)setTimeout(y,0,_);else{var E=u[_];if(E){v=!0;try{(function(S){var C=S.callback,w=S.args;switch(w.length){case 0:C();break;case 1:C(w[0]);break;case 2:C(w[0],w[1]);break;case 3:C(w[0],w[1],w[2]);break;default:C.apply(o,w)}})(E)}finally{f(_),v=!1}}}}function x(_){_.source===a&&typeof _.data=="string"&&_.data.indexOf(d)===0&&y(+_.data.slice(d.length))}})(typeof self>"u"?s===void 0?this:s:self)}).call(this,typeof kp<"u"?kp:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(sb)),sb.exports}var r6=s6();const ab=nb(r6);function ob(r,e){return function(){return r.apply(e,arguments)}}const{toString:a6}=Object.prototype,{getPrototypeOf:L0}=Object,{iterator:Bp,toStringTag:lb}=Symbol,Fp=(r=>e=>{const t=a6.call(e);return r[t]||(r[t]=t.slice(8,-1).toLowerCase())})(Object.create(null)),us=r=>(r=r.toLowerCase(),e=>Fp(e)===r),zp=r=>e=>typeof e===r,{isArray:yl}=Array,xl=zp("undefined");function Vc(r){return r!==null&&!xl(r)&&r.constructor!==null&&!xl(r.constructor)&&Mn(r.constructor.isBuffer)&&r.constructor.isBuffer(r)}const cb=us("ArrayBuffer");function o6(r){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(r):e=r&&r.buffer&&cb(r.buffer),e}const l6=zp("string"),Mn=zp("function"),hb=zp("number"),Gc=r=>r!==null&&typeof r=="object",c6=r=>r===!0||r===!1,Hp=r=>{if(Fp(r)!=="object")return!1;const e=L0(r);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(lb in r)&&!(Bp in r)},h6=r=>{if(!Gc(r)||Vc(r))return!1;try{return Object.keys(r).length===0&&Object.getPrototypeOf(r)===Object.prototype}catch{return!1}},d6=us("Date"),u6=us("File"),p6=us("Blob"),f6=us("FileList"),m6=r=>Gc(r)&&Mn(r.pipe),g6=r=>{let e;return r&&(typeof FormData=="function"&&r instanceof FormData||Mn(r.append)&&((e=Fp(r))==="formdata"||e==="object"&&Mn(r.toString)&&r.toString()==="[object FormData]"))},v6=us("URLSearchParams"),[y6,x6,_6,b6]=["ReadableStream","Request","Response","Headers"].map(us),M6=r=>r.trim?r.trim():r.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Wc(r,e,{allOwnKeys:t=!1}={}){if(r===null||typeof r>"u")return;let i,n;if(typeof r!="object"&&(r=[r]),yl(r))for(i=0,n=r.length;i<n;i++)e.call(null,r[i],i,r);else{if(Vc(r))return;const s=t?Object.getOwnPropertyNames(r):Object.keys(r),a=s.length;let o;for(i=0;i<a;i++)o=s[i],e.call(null,r[o],o,r)}}function db(r,e){if(Vc(r))return null;e=e.toLowerCase();const t=Object.keys(r);let i=t.length,n;for(;i-- >0;)if(n=t[i],e===n.toLowerCase())return n;return null}const qa=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,ub=r=>!xl(r)&&r!==qa;function I0(){const{caseless:r,skipUndefined:e}=ub(this)&&this||{},t={},i=(n,s)=>{const a=r&&db(t,s)||s;Hp(t[a])&&Hp(n)?t[a]=I0(t[a],n):Hp(n)?t[a]=I0({},n):yl(n)?t[a]=n.slice():(!e||!xl(n))&&(t[a]=n)};for(let n=0,s=arguments.length;n<s;n++)arguments[n]&&Wc(arguments[n],i);return t}const S6=(r,e,t,{allOwnKeys:i}={})=>(Wc(e,(n,s)=>{t&&Mn(n)?r[s]=ob(n,t):r[s]=n},{allOwnKeys:i}),r),w6=r=>(r.charCodeAt(0)===65279&&(r=r.slice(1)),r),E6=(r,e,t,i)=>{r.prototype=Object.create(e.prototype,i),r.prototype.constructor=r,Object.defineProperty(r,"super",{value:e.prototype}),t&&Object.assign(r.prototype,t)},C6=(r,e,t,i)=>{let n,s,a;const o={};if(e=e||{},r==null)return e;do{for(n=Object.getOwnPropertyNames(r),s=n.length;s-- >0;)a=n[s],(!i||i(a,r,e))&&!o[a]&&(e[a]=r[a],o[a]=!0);r=t!==!1&&L0(r)}while(r&&(!t||t(r,e))&&r!==Object.prototype);return e},T6=(r,e,t)=>{r=String(r),(t===void 0||t>r.length)&&(t=r.length),t-=e.length;const i=r.indexOf(e,t);return i!==-1&&i===t},A6=r=>{if(!r)return null;if(yl(r))return r;let e=r.length;if(!hb(e))return null;const t=new Array(e);for(;e-- >0;)t[e]=r[e];return t},P6=(r=>e=>r&&e instanceof r)(typeof Uint8Array<"u"&&L0(Uint8Array)),R6=(r,e)=>{const t=(r&&r[Bp]).call(r);let i;for(;(i=t.next())&&!i.done;){const n=i.value;e.call(r,n[0],n[1])}},L6=(r,e)=>{let t;const i=[];for(;(t=r.exec(e))!==null;)i.push(t);return i},I6=us("HTMLFormElement"),D6=r=>r.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(e,t,i){return t.toUpperCase()+i}),pb=(({hasOwnProperty:r})=>(e,t)=>r.call(e,t))(Object.prototype),N6=us("RegExp"),fb=(r,e)=>{const t=Object.getOwnPropertyDescriptors(r),i={};Wc(t,(n,s)=>{let a;(a=e(n,s,r))!==!1&&(i[s]=a||n)}),Object.defineProperties(r,i)},U6=r=>{fb(r,(e,t)=>{if(Mn(r)&&["arguments","caller","callee"].indexOf(t)!==-1)return!1;const i=r[t];if(Mn(i)){if(e.enumerable=!1,"writable"in e){e.writable=!1;return}e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+t+"'")})}})},k6=(r,e)=>{const t={},i=n=>{n.forEach(s=>{t[s]=!0})};return yl(r)?i(r):i(String(r).split(e)),t},O6=()=>{},B6=(r,e)=>r!=null&&Number.isFinite(r=+r)?r:e;function F6(r){return!!(r&&Mn(r.append)&&r[lb]==="FormData"&&r[Bp])}const z6=r=>{const e=new Array(10),t=(i,n)=>{if(Gc(i)){if(e.indexOf(i)>=0)return;if(Vc(i))return i;if(!("toJSON"in i)){e[n]=i;const s=yl(i)?[]:{};return Wc(i,(a,o)=>{const l=t(a,n+1);!xl(l)&&(s[o]=l)}),e[n]=void 0,s}}return i};return t(r,0)},H6=us("AsyncFunction"),V6=r=>r&&(Gc(r)||Mn(r))&&Mn(r.then)&&Mn(r.catch),mb=((r,e)=>r?setImmediate:e?((t,i)=>(qa.addEventListener("message",({source:n,data:s})=>{n===qa&&s===t&&i.length&&i.shift()()},!1),n=>{i.push(n),qa.postMessage(t,"*")}))(`axios@${Math.random()}`,[]):t=>setTimeout(t))(typeof setImmediate=="function",Mn(qa.postMessage)),G6=typeof queueMicrotask<"u"?queueMicrotask.bind(qa):typeof process<"u"&&process.nextTick||mb,W6=r=>r!=null&&Mn(r[Bp]),Te={isArray:yl,isArrayBuffer:cb,isBuffer:Vc,isFormData:g6,isArrayBufferView:o6,isString:l6,isNumber:hb,isBoolean:c6,isObject:Gc,isPlainObject:Hp,isEmptyObject:h6,isReadableStream:y6,isRequest:x6,isResponse:_6,isHeaders:b6,isUndefined:xl,isDate:d6,isFile:u6,isBlob:p6,isRegExp:N6,isFunction:Mn,isStream:m6,isURLSearchParams:v6,isTypedArray:P6,isFileList:f6,forEach:Wc,merge:I0,extend:S6,trim:M6,stripBOM:w6,inherits:E6,toFlatObject:C6,kindOf:Fp,kindOfTest:us,endsWith:T6,toArray:A6,forEachEntry:R6,matchAll:L6,isHTMLForm:I6,hasOwnProperty:pb,hasOwnProp:pb,reduceDescriptors:fb,freezeMethods:U6,toObjectSet:k6,toCamelCase:D6,noop:O6,toFiniteNumber:B6,findKey:db,global:qa,isContextDefined:ub,isSpecCompliantForm:F6,toJSONObject:z6,isAsyncFn:H6,isThenable:V6,setImmediate:mb,asap:G6,isIterable:W6};function vt(r,e,t,i,n){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=r,this.name="AxiosError",e&&(this.code=e),t&&(this.config=t),i&&(this.request=i),n&&(this.response=n,this.status=n.status?n.status:null)}Te.inherits(vt,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:Te.toJSONObject(this.config),code:this.code,status:this.status}}});const gb=vt.prototype,vb={};["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(r=>{vb[r]={value:r}}),Object.defineProperties(vt,vb),Object.defineProperty(gb,"isAxiosError",{value:!0}),vt.from=(r,e,t,i,n,s)=>{const a=Object.create(gb);Te.toFlatObject(r,a,function(c){return c!==Error.prototype},c=>c!=="isAxiosError");const o=r&&r.message?r.message:"Error",l=e==null&&r?r.code:e;return vt.call(a,o,l,t,i,n),r&&a.cause==null&&Object.defineProperty(a,"cause",{value:r,configurable:!0}),a.name=r&&r.name||"Error",s&&Object.assign(a,s),a};const X6=null;function D0(r){return Te.isPlainObject(r)||Te.isArray(r)}function yb(r){return Te.endsWith(r,"[]")?r.slice(0,-2):r}function xb(r,e,t){return r?r.concat(e).map(function(i,n){return i=yb(i),!t&&n?"["+i+"]":i}).join(t?".":""):e}function j6(r){return Te.isArray(r)&&!r.some(D0)}const q6=Te.toFlatObject(Te,{},null,function(r){return/^is[A-Z]/.test(r)});function Vp(r,e,t){if(!Te.isObject(r))throw new TypeError("target must be an object");e=e||new FormData,t=Te.toFlatObject(t,{metaTokens:!0,dots:!1,indexes:!1},!1,function(u,v){return!Te.isUndefined(v[u])});const i=t.metaTokens,n=t.visitor||c,s=t.dots,a=t.indexes,o=(t.Blob||typeof Blob<"u"&&Blob)&&Te.isSpecCompliantForm(e);if(!Te.isFunction(n))throw new TypeError("visitor must be a function");function l(u){if(u===null)return"";if(Te.isDate(u))return u.toISOString();if(Te.isBoolean(u))return u.toString();if(!o&&Te.isBlob(u))throw new vt("Blob is not supported. Use a Buffer instead.");return Te.isArrayBuffer(u)||Te.isTypedArray(u)?o&&typeof Blob=="function"?new Blob([u]):Buffer.from(u):u}function c(u,v,m){let g=u;if(u&&!m&&typeof u=="object"){if(Te.endsWith(v,"{}"))v=i?v:v.slice(0,-2),u=JSON.stringify(u);else if(Te.isArray(u)&&j6(u)||(Te.isFileList(u)||Te.endsWith(v,"[]"))&&(g=Te.toArray(u)))return v=yb(v),g.forEach(function(f,y){!(Te.isUndefined(f)||f===null)&&e.append(a===!0?xb([v],y,s):a===null?v:v+"[]",l(f))}),!1}return D0(u)?!0:(e.append(xb(m,v,s),l(u)),!1)}const h=[],d=Object.assign(q6,{defaultVisitor:c,convertValue:l,isVisitable:D0});function p(u,v){if(!Te.isUndefined(u)){if(h.indexOf(u)!==-1)throw Error("Circular reference detected in "+v.join("."));h.push(u),Te.forEach(u,function(m,g){(!(Te.isUndefined(m)||m===null)&&n.call(e,m,Te.isString(g)?g.trim():g,v,d))===!0&&p(m,v?v.concat(g):[g])}),h.pop()}}if(!Te.isObject(r))throw new TypeError("data must be an object");return p(r),e}function _b(r){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(r).replace(/[!'()~]|%20|%00/g,function(t){return e[t]})}function N0(r,e){this._pairs=[],r&&Vp(r,this,e)}const bb=N0.prototype;bb.append=function(r,e){this._pairs.push([r,e])},bb.toString=function(r){const e=r?function(t){return r.call(this,t,_b)}:_b;return this._pairs.map(function(t){return e(t[0])+"="+e(t[1])},"").join("&")};function Z6(r){return encodeURIComponent(r).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Mb(r,e,t){if(!e)return r;const i=t&&t.encode||Z6;Te.isFunction(t)&&(t={serialize:t});const n=t&&t.serialize;let s;if(n?s=n(e,t):s=Te.isURLSearchParams(e)?e.toString():new N0(e,t).toString(i),s){const a=r.indexOf("#");a!==-1&&(r=r.slice(0,a)),r+=(r.indexOf("?")===-1?"?":"&")+s}return r}class Sb{constructor(){this.handlers=[]}use(e,t,i){return this.handlers.push({fulfilled:e,rejected:t,synchronous:i?i.synchronous:!1,runWhen:i?i.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){Te.forEach(this.handlers,function(t){t!==null&&e(t)})}}const wb={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Y6=typeof URLSearchParams<"u"?URLSearchParams:N0,K6=typeof FormData<"u"?FormData:null,$6=typeof Blob<"u"?Blob:null,J6={isBrowser:!0,classes:{URLSearchParams:Y6,FormData:K6,Blob:$6},protocols:["http","https","file","blob","url","data"]},U0=typeof window<"u"&&typeof document<"u",k0=typeof navigator=="object"&&navigator||void 0,Q6=U0&&(!k0||["ReactNative","NativeScript","NS"].indexOf(k0.product)<0),eN=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",tN=U0&&window.location.href||"http://localhost",iN=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:U0,hasStandardBrowserEnv:Q6,hasStandardBrowserWebWorkerEnv:eN,navigator:k0,origin:tN},Symbol.toStringTag,{value:"Module"})),sn={...iN,...J6};function nN(r,e){return Vp(r,new sn.classes.URLSearchParams,{visitor:function(t,i,n,s){return sn.isNode&&Te.isBuffer(t)?(this.append(i,t.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...e})}function sN(r){return Te.matchAll(/\w+|\[(\w*)]/g,r).map(e=>e[0]==="[]"?"":e[1]||e[0])}function rN(r){const e={},t=Object.keys(r);let i;const n=t.length;let s;for(i=0;i<n;i++)s=t[i],e[s]=r[s];return e}function Eb(r){function e(t,i,n,s){let a=t[s++];if(a==="__proto__")return!0;const o=Number.isFinite(+a),l=s>=t.length;return a=!a&&Te.isArray(n)?n.length:a,l?(Te.hasOwnProp(n,a)?n[a]=[n[a],i]:n[a]=i,!o):((!n[a]||!Te.isObject(n[a]))&&(n[a]=[]),e(t,i,n[a],s)&&Te.isArray(n[a])&&(n[a]=rN(n[a])),!o)}if(Te.isFormData(r)&&Te.isFunction(r.entries)){const t={};return Te.forEachEntry(r,(i,n)=>{e(sN(i),n,t,0)}),t}return null}function aN(r,e,t){if(Te.isString(r))try{return(e||JSON.parse)(r),Te.trim(r)}catch(i){if(i.name!=="SyntaxError")throw i}return(t||JSON.stringify)(r)}const Xc={transitional:wb,adapter:["xhr","http","fetch"],transformRequest:[function(r,e){const t=e.getContentType()||"",i=t.indexOf("application/json")>-1,n=Te.isObject(r);if(n&&Te.isHTMLForm(r)&&(r=new FormData(r)),Te.isFormData(r))return i?JSON.stringify(Eb(r)):r;if(Te.isArrayBuffer(r)||Te.isBuffer(r)||Te.isStream(r)||Te.isFile(r)||Te.isBlob(r)||Te.isReadableStream(r))return r;if(Te.isArrayBufferView(r))return r.buffer;if(Te.isURLSearchParams(r))return e.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),r.toString();let s;if(n){if(t.indexOf("application/x-www-form-urlencoded")>-1)return nN(r,this.formSerializer).toString();if((s=Te.isFileList(r))||t.indexOf("multipart/form-data")>-1){const a=this.env&&this.env.FormData;return Vp(s?{"files[]":r}:r,a&&new a,this.formSerializer)}}return n||i?(e.setContentType("application/json",!1),aN(r)):r}],transformResponse:[function(r){const e=this.transitional||Xc.transitional,t=e&&e.forcedJSONParsing,i=this.responseType==="json";if(Te.isResponse(r)||Te.isReadableStream(r))return r;if(r&&Te.isString(r)&&(t&&!this.responseType||i)){const n=!(e&&e.silentJSONParsing)&&i;try{return JSON.parse(r,this.parseReviver)}catch(s){if(n)throw s.name==="SyntaxError"?vt.from(s,vt.ERR_BAD_RESPONSE,this,null,this.response):s}}return r}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:sn.classes.FormData,Blob:sn.classes.Blob},validateStatus:function(r){return r>=200&&r<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Te.forEach(["delete","get","head","post","put","patch"],r=>{Xc.headers[r]={}});const oN=Te.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"]),lN=r=>{const e={};let t,i,n;return r&&r.split(`
|
|
8984
8984
|
`).forEach(function(s){n=s.indexOf(":"),t=s.substring(0,n).trim().toLowerCase(),i=s.substring(n+1).trim(),!(!t||e[t]&&oN[t])&&(t==="set-cookie"?e[t]?e[t].push(i):e[t]=[i]:e[t]=e[t]?e[t]+", "+i:i)}),e},Cb=Symbol("internals");function jc(r){return r&&String(r).trim().toLowerCase()}function Gp(r){return r===!1||r==null?r:Te.isArray(r)?r.map(Gp):String(r)}function cN(r){const e=Object.create(null),t=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let i;for(;i=t.exec(r);)e[i[1]]=i[2];return e}const hN=r=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(r.trim());function O0(r,e,t,i,n){if(Te.isFunction(i))return i.call(this,e,t);if(n&&(e=t),!!Te.isString(e)){if(Te.isString(i))return e.indexOf(i)!==-1;if(Te.isRegExp(i))return i.test(e)}}function dN(r){return r.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,i)=>t.toUpperCase()+i)}function uN(r,e){const t=Te.toCamelCase(" "+e);["get","set","has"].forEach(i=>{Object.defineProperty(r,i+t,{value:function(n,s,a){return this[i].call(this,e,n,s,a)},configurable:!0})})}let Sn=class{constructor(r){r&&this.set(r)}set(r,e,t){const i=this;function n(a,o,l){const c=jc(o);if(!c)throw new Error("header name must be a non-empty string");const h=Te.findKey(i,c);(!h||i[h]===void 0||l===!0||l===void 0&&i[h]!==!1)&&(i[h||o]=Gp(a))}const s=(a,o)=>Te.forEach(a,(l,c)=>n(l,c,o));if(Te.isPlainObject(r)||r instanceof this.constructor)s(r,e);else if(Te.isString(r)&&(r=r.trim())&&!hN(r))s(lN(r),e);else if(Te.isObject(r)&&Te.isIterable(r)){let a={},o,l;for(const c of r){if(!Te.isArray(c))throw TypeError("Object iterator must return a key-value pair");a[l=c[0]]=(o=a[l])?Te.isArray(o)?[...o,c[1]]:[o,c[1]]:c[1]}s(a,e)}else r!=null&&n(e,r,t);return this}get(r,e){if(r=jc(r),r){const t=Te.findKey(this,r);if(t){const i=this[t];if(!e)return i;if(e===!0)return cN(i);if(Te.isFunction(e))return e.call(this,i,t);if(Te.isRegExp(e))return e.exec(i);throw new TypeError("parser must be boolean|regexp|function")}}}has(r,e){if(r=jc(r),r){const t=Te.findKey(this,r);return!!(t&&this[t]!==void 0&&(!e||O0(this,this[t],t,e)))}return!1}delete(r,e){const t=this;let i=!1;function n(s){if(s=jc(s),s){const a=Te.findKey(t,s);a&&(!e||O0(t,t[a],a,e))&&(delete t[a],i=!0)}}return Te.isArray(r)?r.forEach(n):n(r),i}clear(r){const e=Object.keys(this);let t=e.length,i=!1;for(;t--;){const n=e[t];(!r||O0(this,this[n],n,r,!0))&&(delete this[n],i=!0)}return i}normalize(r){const e=this,t={};return Te.forEach(this,(i,n)=>{const s=Te.findKey(t,n);if(s){e[s]=Gp(i),delete e[n];return}const a=r?dN(n):String(n).trim();a!==n&&delete e[n],e[a]=Gp(i),t[a]=!0}),this}concat(...r){return this.constructor.concat(this,...r)}toJSON(r){const e=Object.create(null);return Te.forEach(this,(t,i)=>{t!=null&&t!==!1&&(e[i]=r&&Te.isArray(t)?t.join(", "):t)}),e}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([r,e])=>r+": "+e).join(`
|
|
8985
8985
|
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(r){return r instanceof this?r:new this(r)}static concat(r,...e){const t=new this(r);return e.forEach(i=>t.set(i)),t}static accessor(r){const e=(this[Cb]=this[Cb]={accessors:{}}).accessors,t=this.prototype;function i(n){const s=jc(n);e[s]||(uN(t,n),e[s]=!0)}return Te.isArray(r)?r.forEach(i):i(r),this}};Sn.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),Te.reduceDescriptors(Sn.prototype,({value:r},e)=>{let t=e[0].toUpperCase()+e.slice(1);return{get:()=>r,set(i){this[t]=i}}}),Te.freezeMethods(Sn);function B0(r,e){const t=this||Xc,i=e||t,n=Sn.from(i.headers);let s=i.data;return Te.forEach(r,function(a){s=a.call(t,s,n.normalize(),e?e.status:void 0)}),n.normalize(),s}function Tb(r){return!!(r&&r.__CANCEL__)}function _l(r,e,t){vt.call(this,r??"canceled",vt.ERR_CANCELED,e,t),this.name="CanceledError"}Te.inherits(_l,vt,{__CANCEL__:!0});function Ab(r,e,t){const i=t.config.validateStatus;!t.status||!i||i(t.status)?r(t):e(new vt("Request failed with status code "+t.status,[vt.ERR_BAD_REQUEST,vt.ERR_BAD_RESPONSE][Math.floor(t.status/100)-4],t.config,t.request,t))}function pN(r){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(r);return e&&e[1]||""}function fN(r,e){r=r||10;const t=new Array(r),i=new Array(r);let n=0,s=0,a;return e=e!==void 0?e:1e3,function(o){const l=Date.now(),c=i[s];a||(a=l),t[n]=o,i[n]=l;let h=s,d=0;for(;h!==n;)d+=t[h++],h=h%r;if(n=(n+1)%r,n===s&&(s=(s+1)%r),l-a<e)return;const p=c&&l-c;return p?Math.round(d*1e3/p):void 0}}function mN(r,e){let t=0,i=1e3/e,n,s;const a=(o,l=Date.now())=>{t=l,n=null,s&&(clearTimeout(s),s=null),r(...o)};return[(...o)=>{const l=Date.now(),c=l-t;c>=i?a(o,l):(n=o,s||(s=setTimeout(()=>{s=null,a(n)},i-c)))},()=>n&&a(n)]}const Wp=(r,e,t=3)=>{let i=0;const n=fN(50,250);return mN(s=>{const a=s.loaded,o=s.lengthComputable?s.total:void 0,l=a-i,c=n(l),h=a<=o;i=a;const d={loaded:a,total:o,progress:o?a/o:void 0,bytes:l,rate:c||void 0,estimated:c&&o&&h?(o-a)/c:void 0,event:s,lengthComputable:o!=null,[e?"download":"upload"]:!0};r(d)},t)},Pb=(r,e)=>{const t=r!=null;return[i=>e[0]({lengthComputable:t,total:r,loaded:i}),e[1]]},Rb=r=>(...e)=>Te.asap(()=>r(...e)),gN=sn.hasStandardBrowserEnv?((r,e)=>t=>(t=new URL(t,sn.origin),r.protocol===t.protocol&&r.host===t.host&&(e||r.port===t.port)))(new URL(sn.origin),sn.navigator&&/(msie|trident)/i.test(sn.navigator.userAgent)):()=>!0,vN=sn.hasStandardBrowserEnv?{write(r,e,t,i,n,s,a){if(typeof document>"u")return;const o=[`${r}=${encodeURIComponent(e)}`];Te.isNumber(t)&&o.push(`expires=${new Date(t).toUTCString()}`),Te.isString(i)&&o.push(`path=${i}`),Te.isString(n)&&o.push(`domain=${n}`),s===!0&&o.push("secure"),Te.isString(a)&&o.push(`SameSite=${a}`),document.cookie=o.join("; ")},read(r){if(typeof document>"u")return null;const e=document.cookie.match(new RegExp("(?:^|; )"+r+"=([^;]*)"));return e?decodeURIComponent(e[1]):null},remove(r){this.write(r,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function yN(r){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(r)}function xN(r,e){return e?r.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):r}function Lb(r,e,t){let i=!yN(e);return r&&(i||t==!1)?xN(r,e):e}const Ib=r=>r instanceof Sn?{...r}:r;function Za(r,e){e=e||{};const t={};function i(c,h,d,p){return Te.isPlainObject(c)&&Te.isPlainObject(h)?Te.merge.call({caseless:p},c,h):Te.isPlainObject(h)?Te.merge({},h):Te.isArray(h)?h.slice():h}function n(c,h,d,p){if(Te.isUndefined(h)){if(!Te.isUndefined(c))return i(void 0,c,d,p)}else return i(c,h,d,p)}function s(c,h){if(!Te.isUndefined(h))return i(void 0,h)}function a(c,h){if(Te.isUndefined(h)){if(!Te.isUndefined(c))return i(void 0,c)}else return i(void 0,h)}function o(c,h,d){if(d in e)return i(c,h);if(d in r)return i(void 0,c)}const l={url:s,method:s,data:s,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials:a,withXSRFToken:a,adapter:a,responseType:a,xsrfCookieName:a,xsrfHeaderName:a,onUploadProgress:a,onDownloadProgress:a,decompress:a,maxContentLength:a,maxBodyLength:a,beforeRedirect:a,transport:a,httpAgent:a,httpsAgent:a,cancelToken:a,socketPath:a,responseEncoding:a,validateStatus:o,headers:(c,h,d)=>n(Ib(c),Ib(h),d,!0)};return Te.forEach(Object.keys({...r,...e}),function(c){const h=l[c]||n,d=h(r[c],e[c],c);Te.isUndefined(d)&&h!==o||(t[c]=d)}),t}const Db=r=>{const e=Za({},r);let{data:t,withXSRFToken:i,xsrfHeaderName:n,xsrfCookieName:s,headers:a,auth:o}=e;if(e.headers=a=Sn.from(a),e.url=Mb(Lb(e.baseURL,e.url,e.allowAbsoluteUrls),r.params,r.paramsSerializer),o&&a.set("Authorization","Basic "+btoa((o.username||"")+":"+(o.password?unescape(encodeURIComponent(o.password)):""))),Te.isFormData(t)){if(sn.hasStandardBrowserEnv||sn.hasStandardBrowserWebWorkerEnv)a.setContentType(void 0);else if(Te.isFunction(t.getHeaders)){const l=t.getHeaders(),c=["content-type","content-length"];Object.entries(l).forEach(([h,d])=>{c.includes(h.toLowerCase())&&a.set(h,d)})}}if(sn.hasStandardBrowserEnv&&(i&&Te.isFunction(i)&&(i=i(e)),i||i!==!1&&gN(e.url))){const l=n&&s&&vN.read(s);l&&a.set(n,l)}return e},_N=typeof XMLHttpRequest<"u",bN=_N&&function(r){return new Promise(function(e,t){const i=Db(r);let n=i.data;const s=Sn.from(i.headers).normalize();let{responseType:a,onUploadProgress:o,onDownloadProgress:l}=i,c,h,d,p,u;function v(){p&&p(),u&&u(),i.cancelToken&&i.cancelToken.unsubscribe(c),i.signal&&i.signal.removeEventListener("abort",c)}let m=new XMLHttpRequest;m.open(i.method.toUpperCase(),i.url,!0),m.timeout=i.timeout;function g(){if(!m)return;const y=Sn.from("getAllResponseHeaders"in m&&m.getAllResponseHeaders()),x={data:!a||a==="text"||a==="json"?m.responseText:m.response,status:m.status,statusText:m.statusText,headers:y,config:r,request:m};Ab(function(_){e(_),v()},function(_){t(_),v()},x),m=null}"onloadend"in m?m.onloadend=g:m.onreadystatechange=function(){!m||m.readyState!==4||m.status===0&&!(m.responseURL&&m.responseURL.indexOf("file:")===0)||setTimeout(g)},m.onabort=function(){m&&(t(new vt("Request aborted",vt.ECONNABORTED,r,m)),m=null)},m.onerror=function(y){const x=y&&y.message?y.message:"Network Error",_=new vt(x,vt.ERR_NETWORK,r,m);_.event=y||null,t(_),m=null},m.ontimeout=function(){let y=i.timeout?"timeout of "+i.timeout+"ms exceeded":"timeout exceeded";const x=i.transitional||wb;i.timeoutErrorMessage&&(y=i.timeoutErrorMessage),t(new vt(y,x.clarifyTimeoutError?vt.ETIMEDOUT:vt.ECONNABORTED,r,m)),m=null},n===void 0&&s.setContentType(null),"setRequestHeader"in m&&Te.forEach(s.toJSON(),function(y,x){m.setRequestHeader(x,y)}),Te.isUndefined(i.withCredentials)||(m.withCredentials=!!i.withCredentials),a&&a!=="json"&&(m.responseType=i.responseType),l&&([d,u]=Wp(l,!0),m.addEventListener("progress",d)),o&&m.upload&&([h,p]=Wp(o),m.upload.addEventListener("progress",h),m.upload.addEventListener("loadend",p)),(i.cancelToken||i.signal)&&(c=y=>{m&&(t(!y||y.type?new _l(null,r,m):y),m.abort(),m=null)},i.cancelToken&&i.cancelToken.subscribe(c),i.signal&&(i.signal.aborted?c():i.signal.addEventListener("abort",c)));const f=pN(i.url);if(f&&sn.protocols.indexOf(f)===-1){t(new vt("Unsupported protocol "+f+":",vt.ERR_BAD_REQUEST,r));return}m.send(n||null)})},MN=(r,e)=>{const{length:t}=r=r?r.filter(Boolean):[];if(e||t){let i=new AbortController,n;const s=function(c){if(!n){n=!0,o();const h=c instanceof Error?c:this.reason;i.abort(h instanceof vt?h:new _l(h instanceof Error?h.message:h))}};let a=e&&setTimeout(()=>{a=null,s(new vt(`timeout ${e} of ms exceeded`,vt.ETIMEDOUT))},e);const o=()=>{r&&(a&&clearTimeout(a),a=null,r.forEach(c=>{c.unsubscribe?c.unsubscribe(s):c.removeEventListener("abort",s)}),r=null)};r.forEach(c=>c.addEventListener("abort",s));const{signal:l}=i;return l.unsubscribe=()=>Te.asap(o),l}},SN=function*(r,e){let t=r.byteLength;if(t<e){yield r;return}let i=0,n;for(;i<t;)n=i+e,yield r.slice(i,n),i=n},wN=async function*(r,e){for await(const t of EN(r))yield*SN(t,e)},EN=async function*(r){if(r[Symbol.asyncIterator]){yield*r;return}const e=r.getReader();try{for(;;){const{done:t,value:i}=await e.read();if(t)break;yield i}}finally{await e.cancel()}},Nb=(r,e,t,i)=>{const n=wN(r,e);let s=0,a,o=l=>{a||(a=!0,i&&i(l))};return new ReadableStream({async pull(l){try{const{done:c,value:h}=await n.next();if(c){o(),l.close();return}let d=h.byteLength;if(t){let p=s+=d;t(p)}l.enqueue(new Uint8Array(h))}catch(c){throw o(c),c}},cancel(l){return o(l),n.return()}},{highWaterMark:2})},Ub=64*1024,{isFunction:Xp}=Te,CN=(({Request:r,Response:e})=>({Request:r,Response:e}))(Te.global),{ReadableStream:kb,TextEncoder:Ob}=Te.global,Bb=(r,...e)=>{try{return!!r(...e)}catch{return!1}},TN=r=>{r=Te.merge.call({skipUndefined:!0},CN,r);const{fetch:e,Request:t,Response:i}=r,n=e?Xp(e):typeof fetch=="function",s=Xp(t),a=Xp(i);if(!n)return!1;const o=n&&Xp(kb),l=n&&(typeof Ob=="function"?(v=>m=>v.encode(m))(new Ob):async v=>new Uint8Array(await new t(v).arrayBuffer())),c=s&&o&&Bb(()=>{let v=!1;const m=new t(sn.origin,{body:new kb,method:"POST",get duplex(){return v=!0,"half"}}).headers.has("Content-Type");return v&&!m}),h=a&&o&&Bb(()=>Te.isReadableStream(new i("").body)),d={stream:h&&(v=>v.body)};n&&["text","arrayBuffer","blob","formData","stream"].forEach(v=>{!d[v]&&(d[v]=(m,g)=>{let f=m&&m[v];if(f)return f.call(m);throw new vt(`Response type '${v}' is not supported`,vt.ERR_NOT_SUPPORT,g)})});const p=async v=>{if(v==null)return 0;if(Te.isBlob(v))return v.size;if(Te.isSpecCompliantForm(v))return(await new t(sn.origin,{method:"POST",body:v}).arrayBuffer()).byteLength;if(Te.isArrayBufferView(v)||Te.isArrayBuffer(v))return v.byteLength;if(Te.isURLSearchParams(v)&&(v=v+""),Te.isString(v))return(await l(v)).byteLength},u=async(v,m)=>Te.toFiniteNumber(v.getContentLength())??p(m);return async v=>{let{url:m,method:g,data:f,signal:y,cancelToken:x,timeout:_,onDownloadProgress:E,onUploadProgress:S,responseType:C,headers:w,withCredentials:M="same-origin",fetchOptions:R}=Db(v),N=e||fetch;C=C?(C+"").toLowerCase():"text";let L=MN([y,x&&x.toAbortSignal()],_),O=null;const T=L&&L.unsubscribe&&(()=>{L.unsubscribe()});let B;try{if(S&&c&&g!=="get"&&g!=="head"&&(B=await u(w,f))!==0){let Y=new t(m,{method:"POST",body:f,duplex:"half"}),K;if(Te.isFormData(f)&&(K=Y.headers.get("content-type"))&&w.setContentType(K),Y.body){const[_e,Ce]=Pb(B,Wp(Rb(S)));f=Nb(Y.body,Ub,_e,Ce)}}Te.isString(M)||(M=M?"include":"omit");const F=s&&"credentials"in t.prototype,H={...R,signal:L,method:g.toUpperCase(),headers:w.normalize().toJSON(),body:f,duplex:"half",credentials:F?M:void 0};O=s&&new t(m,H);let q=await(s?N(O,R):N(m,H));const V=h&&(C==="stream"||C==="response");if(h&&(E||V&&T)){const Y={};["status","statusText","headers"].forEach(be=>{Y[be]=q[be]});const K=Te.toFiniteNumber(q.headers.get("content-length")),[_e,Ce]=E&&Pb(K,Wp(Rb(E),!0))||[];q=new i(Nb(q.body,Ub,_e,()=>{Ce&&Ce(),T&&T()}),Y)}C=C||"text";let re=await d[Te.findKey(d,C)||"text"](q,v);return!V&&T&&T(),await new Promise((Y,K)=>{Ab(Y,K,{data:re,headers:Sn.from(q.headers),status:q.status,statusText:q.statusText,config:v,request:O})})}catch(F){throw T&&T(),F&&F.name==="TypeError"&&/Load failed|fetch/i.test(F.message)?Object.assign(new vt("Network Error",vt.ERR_NETWORK,v,O),{cause:F.cause||F}):vt.from(F,F&&F.code,v,O)}}},AN=new Map,Fb=r=>{let e=r&&r.env||{};const{fetch:t,Request:i,Response:n}=e,s=[i,n,t];let a=s.length,o=a,l,c,h=AN;for(;o--;)l=s[o],c=h.get(l),c===void 0&&h.set(l,c=o?new Map:TN(e)),h=c;return c};Fb();const F0={http:X6,xhr:bN,fetch:{get:Fb}};Te.forEach(F0,(r,e)=>{if(r){try{Object.defineProperty(r,"name",{value:e})}catch{}Object.defineProperty(r,"adapterName",{value:e})}});const zb=r=>`- ${r}`,PN=r=>Te.isFunction(r)||r===null||r===!1;function RN(r,e){r=Te.isArray(r)?r:[r];const{length:t}=r;let i,n;const s={};for(let a=0;a<t;a++){i=r[a];let o;if(n=i,!PN(i)&&(n=F0[(o=String(i)).toLowerCase()],n===void 0))throw new vt(`Unknown adapter '${o}'`);if(n&&(Te.isFunction(n)||(n=n.get(e))))break;s[o||"#"+a]=n}if(!n){const a=Object.entries(s).map(([l,c])=>`adapter ${l} `+(c===!1?"is not supported by the environment":"is not available in the build"));let o=t?a.length>1?`since :
|
|
8986
8986
|
`+a.map(zb).join(`
|
|
8987
8987
|
`):" "+zb(a[0]):"as no adapter specified";throw new vt("There is no suitable adapter to dispatch the request "+o,"ERR_NOT_SUPPORT")}return n}const Hb={getAdapter:RN,adapters:F0};function z0(r){if(r.cancelToken&&r.cancelToken.throwIfRequested(),r.signal&&r.signal.aborted)throw new _l(null,r)}function Vb(r){return z0(r),r.headers=Sn.from(r.headers),r.data=B0.call(r,r.transformRequest),["post","put","patch"].indexOf(r.method)!==-1&&r.headers.setContentType("application/x-www-form-urlencoded",!1),Hb.getAdapter(r.adapter||Xc.adapter,r)(r).then(function(e){return z0(r),e.data=B0.call(r,r.transformResponse,e),e.headers=Sn.from(e.headers),e},function(e){return Tb(e)||(z0(r),e&&e.response&&(e.response.data=B0.call(r,r.transformResponse,e.response),e.response.headers=Sn.from(e.response.headers))),Promise.reject(e)})}const Gb="1.13.2",jp={};["object","boolean","number","function","string","symbol"].forEach((r,e)=>{jp[r]=function(t){return typeof t===r||"a"+(e<1?"n ":" ")+r}});const Wb={};jp.transitional=function(r,e,t){function i(n,s){return"[Axios v"+Gb+"] Transitional option '"+n+"'"+s+(t?". "+t:"")}return(n,s,a)=>{if(r===!1)throw new vt(i(s," has been removed"+(e?" in "+e:"")),vt.ERR_DEPRECATED);return e&&!Wb[s]&&(Wb[s]=!0,console.warn(i(s," has been deprecated since v"+e+" and will be removed in the near future"))),r?r(n,s,a):!0}},jp.spelling=function(r){return(e,t)=>(console.warn(`${t} is likely a misspelling of ${r}`),!0)};function LN(r,e,t){if(typeof r!="object")throw new vt("options must be an object",vt.ERR_BAD_OPTION_VALUE);const i=Object.keys(r);let n=i.length;for(;n-- >0;){const s=i[n],a=e[s];if(a){const o=r[s],l=o===void 0||a(o,s,r);if(l!==!0)throw new vt("option "+s+" must be "+l,vt.ERR_BAD_OPTION_VALUE);continue}if(t!==!0)throw new vt("Unknown option "+s,vt.ERR_BAD_OPTION)}}const qp={assertOptions:LN,validators:jp},Ts=qp.validators;let Ya=class{constructor(r){this.defaults=r||{},this.interceptors={request:new Sb,response:new Sb}}async request(r,e){try{return await this._request(r,e)}catch(t){if(t instanceof Error){let i={};Error.captureStackTrace?Error.captureStackTrace(i):i=new Error;const n=i.stack?i.stack.replace(/^.+\n/,""):"";try{t.stack?n&&!String(t.stack).endsWith(n.replace(/^.+\n.+\n/,""))&&(t.stack+=`
|
|
8988
8988
|
`+n):t.stack=n}catch{}}throw t}}_request(r,e){typeof r=="string"?(e=e||{},e.url=r):e=r||{},e=Za(this.defaults,e);const{transitional:t,paramsSerializer:i,headers:n}=e;t!==void 0&&qp.assertOptions(t,{silentJSONParsing:Ts.transitional(Ts.boolean),forcedJSONParsing:Ts.transitional(Ts.boolean),clarifyTimeoutError:Ts.transitional(Ts.boolean)},!1),i!=null&&(Te.isFunction(i)?e.paramsSerializer={serialize:i}:qp.assertOptions(i,{encode:Ts.function,serialize:Ts.function},!0)),e.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?e.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:e.allowAbsoluteUrls=!0),qp.assertOptions(e,{baseUrl:Ts.spelling("baseURL"),withXsrfToken:Ts.spelling("withXSRFToken")},!0),e.method=(e.method||this.defaults.method||"get").toLowerCase();let s=n&&Te.merge(n.common,n[e.method]);n&&Te.forEach(["delete","get","head","post","put","patch","common"],u=>{delete n[u]}),e.headers=Sn.concat(s,n);const a=[];let o=!0;this.interceptors.request.forEach(function(u){typeof u.runWhen=="function"&&u.runWhen(e)===!1||(o=o&&u.synchronous,a.unshift(u.fulfilled,u.rejected))});const l=[];this.interceptors.response.forEach(function(u){l.push(u.fulfilled,u.rejected)});let c,h=0,d;if(!o){const u=[Vb.bind(this),void 0];for(u.unshift(...a),u.push(...l),d=u.length,c=Promise.resolve(e);h<d;)c=c.then(u[h++],u[h++]);return c}d=a.length;let p=e;for(;h<d;){const u=a[h++],v=a[h++];try{p=u(p)}catch(m){v.call(this,m);break}}try{c=Vb.call(this,p)}catch(u){return Promise.reject(u)}for(h=0,d=l.length;h<d;)c=c.then(l[h++],l[h++]);return c}getUri(r){r=Za(this.defaults,r);const e=Lb(r.baseURL,r.url,r.allowAbsoluteUrls);return Mb(e,r.params,r.paramsSerializer)}};Te.forEach(["delete","get","head","options"],function(r){Ya.prototype[r]=function(e,t){return this.request(Za(t||{},{method:r,url:e,data:(t||{}).data}))}}),Te.forEach(["post","put","patch"],function(r){function e(t){return function(i,n,s){return this.request(Za(s||{},{method:r,headers:t?{"Content-Type":"multipart/form-data"}:{},url:i,data:n}))}}Ya.prototype[r]=e(),Ya.prototype[r+"Form"]=e(!0)});let IN=class cS{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(n){t=n});const i=this;this.promise.then(n=>{if(!i._listeners)return;let s=i._listeners.length;for(;s-- >0;)i._listeners[s](n);i._listeners=null}),this.promise.then=n=>{let s;const a=new Promise(o=>{i.subscribe(o),s=o}).then(n);return a.cancel=function(){i.unsubscribe(s)},a},e(function(n,s,a){i.reason||(i.reason=new _l(n,s,a),t(i.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=i=>{e.abort(i)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let e;return{token:new cS(function(t){e=t}),cancel:e}}};function DN(r){return function(e){return r.apply(null,e)}}function NN(r){return Te.isObject(r)&&r.isAxiosError===!0}const H0={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(H0).forEach(([r,e])=>{H0[e]=r});function Xb(r){const e=new Ya(r),t=ob(Ya.prototype.request,e);return Te.extend(t,Ya.prototype,e,{allOwnKeys:!0}),Te.extend(t,e,null,{allOwnKeys:!0}),t.create=function(i){return Xb(Za(r,i))},t}const ui=Xb(Xc);ui.Axios=Ya,ui.CanceledError=_l,ui.CancelToken=IN,ui.isCancel=Tb,ui.VERSION=Gb,ui.toFormData=Vp,ui.AxiosError=vt,ui.Cancel=ui.CanceledError,ui.all=function(r){return Promise.all(r)},ui.spread=DN,ui.isAxiosError=NN,ui.mergeConfig=Za,ui.AxiosHeaders=Sn,ui.formToJSON=r=>Eb(Te.isHTMLForm(r)?new FormData(r):r),ui.getAdapter=Hb.getAdapter,ui.HttpStatusCode=H0,ui.default=ui;const{Axios:WO,AxiosError:XO,CanceledError:jO,isCancel:qO,CancelToken:ZO,VERSION:YO,all:KO,Cancel:$O,isAxiosError:JO,spread:QO,toFormData:eB,AxiosHeaders:tB,HttpStatusCode:iB,formToJSON:nB,getAdapter:sB,mergeConfig:rB}=ui;function qc(r,e,t){ui({method:"get",responseType:"blob",url:r}).then(n=>{let s=new window.File([n.data],"semantics",{type:"zip"});ab.loadAsync(s).then(a=>{for(let o in a.files){const l=a.file(a.files[o].name);l&&l.async("blob").then(c=>{i(c,"utf-8",function(h,d){e(d)})}).catch(()=>{t()})}}).catch(()=>{t()})}).catch(n=>{t()});function i(n,s,a){var o=new FileReader,l=new Blob([n]);o.onload=function(c){a(null,c.target.result)},o.onerror=function(c){a(c.error,null)},o.readAsText(l,s)}}const V0=new WeakMap;class UN extends qi{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,i,n){const s=new yn(this.manager);s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,a=>{this.parse(a,t,n)},i,n)}parse(e,t,i=()=>{}){this.decodeDracoFile(e,t,null,null,Qt,i).catch(i)}decodeDracoFile(e,t,i,n,s=Fi,a=()=>{}){const o={attributeIDs:i||this.defaultAttributeIDs,attributeTypes:n||this.defaultAttributeTypes,useUniqueIDs:!!i,vertexColorSpace:s};return this.decodeGeometry(e,o).then(t).catch(a)}decodeGeometry(e,t){const i=JSON.stringify(t);if(V0.has(e)){const l=V0.get(e);if(l.key===i)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 n;const s=this.workerNextTaskID++,a=e.byteLength,o=this._getWorker(s,a).then(l=>(n=l,new Promise((c,h)=>{n._callbacks[s]={resolve:c,reject:h},n.postMessage({type:"decode",id:s,taskConfig:t,buffer:e},[e])}))).then(l=>this._createGeometry(l.geometry));return o.catch(()=>!0).then(()=>{n&&s&&this._releaseTask(n,s)}),V0.set(e,{key:i,promise:o}),o}_createGeometry(e){const t=new ot;e.index&&t.setIndex(new wt(e.index.array,1));for(let i=0;i<e.attributes.length;i++){const{name:n,array:s,itemSize:a,stride:o,vertexColorSpace:l}=e.attributes[i];let c;if(a===o)c=new wt(s,a);else{const h=new Ao(s,o);c=new Fs(h,a,0)}n==="color"&&(this._assignVertexColorSpace(c,l),c.normalized=!(s instanceof Float32Array)),t.setAttribute(n,c)}return t}_assignVertexColorSpace(e,t){if(t!==Qt)return;const i=new Xe;for(let n=0,s=e.count;n<s;n++)i.fromBufferAttribute(e,n),St.colorSpaceToWorking(i,Qt),e.setXYZ(n,i.r,i.g,i.b)}_loadLibrary(e,t){const i=new yn(this.manager);return i.setPath(this.decoderPath),i.setResponseType(t),i.setWithCredentials(this.withCredentials),new Promise((n,s)=>{i.load(e,n,void 0,s)})}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(i=>{const n=i[0];e||(this.decoderConfig.wasmBinary=i[1]);const s=kN.toString(),a=["/* draco decoder */",n,"","/* worker */",s.substring(s.indexOf("{")+1,s.lastIndexOf("}"))].join(`
|
|
8989
|
-
`);this.workerSourceURL=URL.createObjectURL(new Blob([a]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){const n=new Worker(this.workerSourceURL);n._callbacks={},n._taskCosts={},n._taskLoad=0,n.postMessage({type:"init",decoderConfig:this.decoderConfig}),n.onmessage=function(s){const a=s.data;switch(a.type){case"decode":n._callbacks[a.id].resolve(a);break;case"error":n._callbacks[a.id].reject(a);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+a.type+'"')}},this.workerPool.push(n)}else this.workerPool.sort(function(n,s){return n._taskLoad>s._taskLoad?-1:1});const i=this.workerPool[this.workerPool.length-1];return i._taskCosts[e]=t,i._taskLoad+=t,i})}_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 kN(){let r,e;onmessage=function(a){const o=a.data;switch(o.type){case"init":r=o.decoderConfig,e=new Promise(function(h){r.onModuleLoaded=function(d){h({draco:d})},DracoDecoderModule(r)});break;case"decode":const l=o.buffer,c=o.taskConfig;e.then(h=>{const d=h.draco,p=new d.Decoder;try{const u=t(d,p,new Int8Array(l),c),v=u.attributes.map(m=>m.array.buffer);u.index&&v.push(u.index.array.buffer),self.postMessage({type:"decode",id:o.id,geometry:u},v)}catch(u){console.error(u),self.postMessage({type:"error",id:o.id,error:u.message})}finally{d.destroy(p)}});break}};function t(a,o,l,c){const h=c.attributeIDs,d=c.attributeTypes;let p,u;const v=o.GetEncodedGeometryType(l);if(v===a.TRIANGULAR_MESH)p=new a.Mesh,u=o.DecodeArrayToMesh(l,l.byteLength,p);else if(v===a.POINT_CLOUD)p=new a.PointCloud,u=o.DecodeArrayToPointCloud(l,l.byteLength,p);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!u.ok()||p.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+u.error_msg());const m={index:null,attributes:[]};for(const g in h){const f=self[d[g]];let y,x;if(c.useUniqueIDs)x=h[g],y=o.GetAttributeByUniqueId(p,x);else{if(x=o.GetAttributeId(p,a[h[g]]),x===-1)continue;y=o.GetAttribute(p,x)}const _=n(a,o,p,g,f,y);g==="color"&&(_.vertexColorSpace=c.vertexColorSpace),m.attributes.push(_)}return v===a.TRIANGULAR_MESH&&(m.index=i(a,o,p)),a.destroy(p),m}function i(a,o,l){const c=l.num_faces()*3,h=c*4,d=a._malloc(h);o.GetTrianglesUInt32Array(l,h,d);const p=new Uint32Array(a.HEAPF32.buffer,d,c).slice();return a._free(d),{array:p,itemSize:1}}function n(a,o,l,c,h,d){const p=l.num_points(),u=d.num_components(),v=s(a,h),m=u*h.BYTES_PER_ELEMENT,g=Math.ceil(m/4)*4,f=g/h.BYTES_PER_ELEMENT,y=p*m,x=p*g,_=a._malloc(y);o.GetAttributeDataArrayForAllPoints(l,d,v,y,_);const E=new h(a.HEAPF32.buffer,_,y/h.BYTES_PER_ELEMENT);let S;if(m===g)S=E.slice();else{S=new h(x/h.BYTES_PER_ELEMENT);let C=0;for(let w=0,M=E.length;w<M;w++){for(let R=0;R<u;R++)S[C+R]=E[w*u+R];C+=f}}return a._free(_),{name:c,count:p,itemSize:u,array:S,stride:f}}function s(a,o){switch(o){case Float32Array:return a.DT_FLOAT32;case Int8Array:return a.DT_INT8;case Int16Array:return a.DT_INT16;case Int32Array:return a.DT_INT32;case Uint8Array:return a.DT_UINT8;case Uint16Array:return a.DT_UINT16;case Uint32Array:return a.DT_UINT32}}}function ON(r,e,t,i){let n=0,s=0,a=0,o=r.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,p=r.scene;if(new Rt,new ot,l&&l.length){let u=[],v=0;for(let m of l)m.color=m.color.split(",").map(g=>parseInt(g)/255),m.color=new Xe(m.color[0],m.color[1],m.color[2]),m.position={x:m.startPoint.X*.3048+n,y:m.startPoint.Z*.3048+s,z:-m.startPoint.Y*.3048+a},m.rotation={x:0,y:0,z:0},m.indexes=[[r.scene.children.length,v++,0,0]],o.nodesMap.set(Number(m.id),m),u.push(m);Zp("Circle",p,u,t)}if(c&&c.length){let u=[],v=0;for(let m of c)m.color=m.color.split(",").map(g=>parseInt(g)/255),m.color=new Xe(m.color[0],m.color[1],m.color[2]),m.position={x:m.startPoint.X*.3048+n,y:m.startPoint.Z*.3048+s,z:-m.startPoint.Y*.3048+a},m.rotation={x:0,y:0,z:0},m.indexes=[[r.scene.children.length,v++,0,0]],o.nodesMap.set(Number(m.id),m),u.push(m);Zp("Rect",p,u,t)}if(d&&d.length){let u=[],v=0;for(let m of d)m.color=m.color.split(",").map(g=>parseInt(g)/255),m.color=new Xe(m.color[0],m.color[1],m.color[2]),m.position={x:m.startPoint.X*.3048+n,y:m.startPoint.Z*.3048+s,z:-m.startPoint.Y*.3048+a},m.rotation={x:0,y:0,z:0},m.indexes=[[r.scene.children.length,v++,0,0]],o.nodesMap.set(Number(m.id),m),u.push(m);Zp("Ellipse",p,u,t)}if(h&&h.length){let u=[],v=0;for(let m of h)m.color=m.color.split(",").map(g=>parseInt(g)/255),m.color=new Xe(m.color[0],m.color[1],m.color[2]),m.position={x:m.startPoint.X*.3048+n,y:m.startPoint.Z*.3048+s,z:-m.startPoint.Y*.3048+a},m.rotation={x:0,y:0,z:0},m.indexes=[[r.scene.children.length,v++,0,0]],o.nodesMap.set(Number(m.id),m),u.push(m);Zp("Bridge",p,u,t)}}function Zp(r,e,t,i,n){let s,a,o={width:1,height:1,length:1,diameter:1,color:new Xe,position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0}};switch(r){case"Rect":a=Yp("Rect",o);break;case"Bridge":a=Yp("Bridge",o);break;case"Circle":a=Yp("Circle",o);break;case"Ellipse":a=Yp("Ellipse",o);break}a&&(s=new ti(a.geometry,a.material,t.length),s.url=i,e.add(s),s.index=e.children.length-1);let l=[],c=[];for(var h=0;h<t.length;h++){let u=t[h],v=new A(u.startPoint.X,0,-u.startPoint.Y),m=new A(u.endPoint.X,0,-u.endPoint.Y),g=new A(u.startPoint.X,u.startPoint.Z,-u.startPoint.Y),f=new A(u.endPoint.X,u.endPoint.Z,-u.endPoint.Y),y=0,x=0,_=0;if(Math.abs(m.clone().sub(v.clone()).z)<.01&&Math.abs(m.clone().sub(v.clone()).x)<.01){if(y=(u.startPoint.Z>u.endPoint.Z?1:-1)*Math.PI*.5,u.base_x!=null){var d=new A(u.base_x.X,0,-u.base_x.Y);x=(d.clone().cross(new A(0,0,1)).y<=0?1:-1)*d.angleTo(new A(0,0,1))+Math.PI*.5}}else x=(m.clone().sub(v.clone()).cross(new A(0,0,1)).y>0?-1:1)*m.clone().sub(v.clone()).angleTo(new A(0,0,1)),y=(u.startPoint.Z>u.endPoint.Z?1:-1)*m.clone().sub(v.clone()).angleTo(f.clone().sub(g.clone()));let E=new Ke;const S=new Pi(y,x,_,"YXZ");let C=E.clone().makeRotationFromEuler(S),w,M;r==="Circle"?(w=u.diameter,M=u.diameter):(w=u.width,M=u.height);let R=E.clone().makeScale(w,M,u.length);E.multiplyMatrices(C,R),E.setPosition(u.position.x,u.position.y,u.position.z),s.setMatrixAt(h,E.clone()),s.setColorAt(h,u.color),s.geometry.computeBoundingBox();let N=s.geometry.boundingBox.min.clone().applyMatrix4(E.clone()),L=s.geometry.boundingBox.max.clone().applyMatrix4(E.clone()),O=new A(Math.min(N.x,L.x),Math.min(N.y,L.y),Math.min(N.z,L.z)),T=new A(Math.max(N.x,L.x),Math.max(N.y,L.y),Math.max(N.z,L.z)),B=O.clone().add(T.clone()).multiplyScalar(.5),F={name:u.name,min:O,max:T,center:B,dbid:h,materialName:a.material.name},H=null,q=null;r==="Circle"&&(H={x:u.startPoint.X*.3048,y:u.startPoint.Z*.3048,z:-u.startPoint.Y*.3048},q={x:u.endPoint.X*.3048,y:u.endPoint.Z*.3048,z:-u.endPoint.Y*.3048},F.minC=H,F.maxC=q),s.ids||(s.ids=[]),s.matrixs||(s.matrixs=[]),s.matrixs.push(E.clone()),c.push(E.clone()),s.ids.push(Number(u.id)),l.push(F)}s.castShadow=!0,s.ElementInfos=l,s.name="rootModel",s.TypeName="InstancedMesh-Pipe",s.PipeType=r,s.MeshId=null,s.realMaterial=s.material.clone(),s.originalMaterial=s.material.clone(),s.matrixsClone=c;let p=[];p={geometry:s.geometry,matrix:s.matrix,position:s.position,rotation:s.rotation},s.meshs=p,s.instanceMatrix&&s.instanceMatrix.array&&(s.cloneInstanceMatrix=Array.from(s.instanceMatrix.array))}function Yp(r,e,t){let i=new Hs;switch(e.width=e.width*.3048,e.height=e.height*.3048,e.diameter=e.diameter*.3048,r){case"Rect":i.moveTo(-e.width/2,-e.height/2),i.lineTo(-e.width/2,e.height/2),i.lineTo(e.width/2,e.height/2),i.lineTo(e.width/2,-e.height/2),i.lineTo(-e.width/2,-e.height/2);break;case"Ellipse":i.moveTo(-e.width/2,-e.height/2),i.lineTo(-e.width/2,e.height/2),i.lineTo(e.width/2,e.height/2),i.lineTo(e.width/2,-e.height/2),i.lineTo(-e.width/2,-e.height/2);break;case"Bridge":i.moveTo(-e.width/2,-e.height/2),i.lineTo(-e.width/2,e.height/2),i.lineTo(-e.width/2+.01,e.height/2),i.lineTo(-e.width/2+.01,-e.height/2+.01),i.lineTo(e.width/2-.01,-e.height/2+.01),i.lineTo(e.width/2-.01,e.height/2),i.lineTo(e.width/2,e.height/2),i.lineTo(e.width/2,-e.height/2),i.lineTo(-e.width/2,-e.height/2);break;case"Circle":i.moveTo(0,0),i.absarc(0,0,e.diameter*.5,0,Math.PI*2,!1);break}const n={depth:e.length*.3048,bevelEnabled:!1};return s(i,n,e.color,e.position,e.rotation);function s(a,o,l,c,h){let d=new ko(a,o),p=new pa({color:l,side:Ht}),u=new Ve(d,p);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 Ka(r,e=!1){const t=r[0].index!==null,i=new Set(Object.keys(r[0].attributes)),n=new Set(Object.keys(r[0].morphAttributes)),s={},a={},o=r[0].morphTargetsRelative,l=new ot;let c=0;for(let h=0;h<r.length;++h){const d=r[h];let p=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(!i.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;s[u]===void 0&&(s[u]=[]),s[u].push(d.attributes[u]),p++}if(p!==i.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(o!==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(!n.has(u))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". .morphAttributes must be consistent throughout all geometries."),null;a[u]===void 0&&(a[u]=[]),a[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 p=0;p<r.length;++p){const u=r[p].index;for(let v=0;v<u.count;++v)d.push(u.getX(v)+h);h+=r[p].attributes.position.count}l.setIndex(d)}for(const h in s){const d=jb(s[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 a){const d=a[h][0].length;if(d===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[h]=[];for(let p=0;p<d;++p){const u=[];for(let m=0;m<a[h].length;++m)u.push(a[h][m][p]);const v=jb(u);if(!v)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+h+" morphAttribute."),null;l.morphAttributes[h].push(v)}}return l}function jb(r){let e,t,i,n=-1,s=0;for(let c=0;c<r.length;++c){const h=r[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(i===void 0&&(i=h.normalized),i!==h.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(n===-1&&(n=h.gpuType),n!==h.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;s+=h.count*t}const a=new e(s),o=new wt(a,t,i);let l=0;for(let c=0;c<r.length;++c){const h=r[c];if(h.isInterleavedBufferAttribute){const d=l/t;for(let p=0,u=h.count;p<u;p++)for(let v=0;v<t;v++){const m=h.getComponent(p,v);o.setComponent(p+d,v,m)}}else a.set(h.array,l);l+=h.count*t}return n!==void 0&&(o.gpuType=n),o}function qb(r,e){if(e===Fv)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),r;if(e===vd||e===Mf){let t=r.getIndex();if(t===null){const a=[],o=r.getAttribute("position");if(o!==void 0){for(let l=0;l<o.count;l++)a.push(l);r.setIndex(a),t=r.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),r}const i=t.count-2,n=[];if(e===vd)for(let a=1;a<=i;a++)n.push(t.getX(0)),n.push(t.getX(a)),n.push(t.getX(a+1));else for(let a=0;a<i;a++)a%2===0?(n.push(t.getX(a)),n.push(t.getX(a+1)),n.push(t.getX(a+2))):(n.push(t.getX(a+2)),n.push(t.getX(a+1)),n.push(t.getX(a)));n.length/3!==i&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const s=r.clone();return s.setIndex(n),s.clearGroups(),s}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),r}function BN(r){const e=new Map,t=new Map,i=r.clone();return Zb(r,i,function(n,s){e.set(s,n),t.set(n,s)}),i.traverse(function(n){if(!n.isSkinnedMesh)return;const s=n,a=e.get(n),o=a.skeleton.bones;s.skeleton=a.skeleton.clone(),s.bindMatrix.copy(a.bindMatrix),s.skeleton.bones=o.map(function(l){return t.get(l)}),s.bind(s.skeleton,s.bindMatrix)}),i}function Zb(r,e,t){t(r,e);for(let i=0;i<r.children.length;i++)Zb(r.children[i],e.children[i],t)}class FN extends qi{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new WN(t)}),this.register(function(t){return new XN(t)}),this.register(function(t){return new e8(t)}),this.register(function(t){return new t8(t)}),this.register(function(t){return new i8(t)}),this.register(function(t){return new qN(t)}),this.register(function(t){return new ZN(t)}),this.register(function(t){return new YN(t)}),this.register(function(t){return new KN(t)}),this.register(function(t){return new GN(t)}),this.register(function(t){return new $N(t)}),this.register(function(t){return new jN(t)}),this.register(function(t){return new QN(t)}),this.register(function(t){return new JN(t)}),this.register(function(t){return new HN(t)}),this.register(function(t){return new Yb(t,Et.EXT_MESHOPT_COMPRESSION)}),this.register(function(t){return new Yb(t,Et.KHR_MESHOPT_COMPRESSION)}),this.register(function(t){return new n8(t)})}load(e,t,i,n){const s=this;let a;if(this.resourcePath!=="")a=this.resourcePath;else if(this.path!==""){const c=Pr.extractUrlBase(e);a=Pr.resolveURL(c,this.path)}else a=Pr.extractUrlBase(e);this.manager.itemStart(e);const o=function(c){n?n(c):console.error(c),s.manager.itemError(e),s.manager.itemEnd(e)},l=new yn(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(this.withCredentials),l.load(e,function(c){try{s.parse(c,a,function(h){t(h),s.manager.itemEnd(e)},o)}catch(h){o(h)}},i,o)}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,i,n){let s;const a={},o={},l=new TextDecoder;if(typeof e=="string")s=JSON.parse(e);else if(e instanceof ArrayBuffer)if(l.decode(new Uint8Array(e,0,4))===Kb){try{a[Et.KHR_BINARY_GLTF]=new s8(e)}catch(h){n&&n(h);return}s=JSON.parse(a[Et.KHR_BINARY_GLTF].content)}else s=JSON.parse(l.decode(e));else s=e;if(s.asset===void 0||s.asset.version[0]<2){n&&n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const c=new v8(s,{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"),o[d.name]=d,a[d.name]=!0}if(s.extensionsUsed)for(let h=0;h<s.extensionsUsed.length;++h){const d=s.extensionsUsed[h],p=s.extensionsRequired||[];switch(d){case Et.KHR_MATERIALS_UNLIT:a[d]=new VN;break;case Et.KHR_DRACO_MESH_COMPRESSION:a[d]=new r8(s,this.dracoLoader);break;case Et.KHR_TEXTURE_TRANSFORM:a[d]=new a8;break;case Et.KHR_MESH_QUANTIZATION:a[d]=new o8;break;default:p.indexOf(d)>=0&&o[d]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+d+'".')}}c.setExtensions(a),c.setPlugins(o),c.parse(i,n)}parseAsync(e,t){const i=this;return new Promise(function(n,s){i.parse(e,t,n,s)})}}function zN(){let r={};return{get:function(e){return r[e]},add:function(e,t){r[e]=t},remove:function(e){delete r[e]},removeAll:function(){r={}}}}function yi(r,e,t){const i=r.json.materials[e];return i.extensions&&i.extensions[t]?i.extensions[t]:null}const Et={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 HN{constructor(e){this.parser=e,this.name=Et.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let i=0,n=t.length;i<n;i++){const s=t[i];s.extensions&&s.extensions[this.name]&&s.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,s.extensions[this.name].light)}}_loadLight(e){const t=this.parser,i="light:"+e;let n=t.cache.get(i);if(n)return n;const s=t.json,a=((s.extensions&&s.extensions[this.name]||{}).lights||[])[e];let o;const l=new Xe(16777215);a.color!==void 0&&l.setRGB(a.color[0],a.color[1],a.color[2],Fi);const c=a.range!==void 0?a.range:0;switch(a.type){case"directional":o=new Ar(l),o.target.position.set(0,0,-1),o.add(o.target);break;case"point":o=new Pm(l),o.distance=c;break;case"spot":o=new Am(l),o.distance=c,a.spot=a.spot||{},a.spot.innerConeAngle=a.spot.innerConeAngle!==void 0?a.spot.innerConeAngle:0,a.spot.outerConeAngle=a.spot.outerConeAngle!==void 0?a.spot.outerConeAngle:Math.PI/4,o.angle=a.spot.outerConeAngle,o.penumbra=1-a.spot.innerConeAngle/a.spot.outerConeAngle,o.target.position.set(0,0,-1),o.add(o.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+a.type)}return o.position.set(0,0,0),As(o,a),a.intensity!==void 0&&(o.intensity=a.intensity),o.name=t.createUniqueName(a.name||"light_"+e),n=Promise.resolve(o),t.cache.add(i,n),n}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,i=this.parser,n=i.json.nodes[e],s=(n.extensions&&n.extensions[this.name]||{}).light;return s===void 0?null:this._loadLight(s).then(function(a){return i._getNodeRef(t.cache,s,a)})}}class VN{constructor(){this.name=Et.KHR_MATERIALS_UNLIT}getMaterialType(){return Rt}extendParams(e,t,i){const n=[];e.color=new Xe(1,1,1),e.opacity=1;const s=t.pbrMetallicRoughness;if(s){if(Array.isArray(s.baseColorFactor)){const a=s.baseColorFactor;e.color.setRGB(a[0],a[1],a[2],Fi),e.opacity=a[3]}s.baseColorTexture!==void 0&&n.push(i.assignTexture(e,"map",s.baseColorTexture,Qt))}return Promise.all(n)}}class GN{constructor(e){this.parser=e,this.name=Et.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const i=yi(this.parser,e,this.name);return i===null||i.emissiveStrength!==void 0&&(t.emissiveIntensity=i.emissiveStrength),Promise.resolve()}}class WN{constructor(e){this.parser=e,this.name=Et.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){return yi(this.parser,e,this.name)!==null?Xn:null}extendMaterialParams(e,t){const i=yi(this.parser,e,this.name);if(i===null)return Promise.resolve();const n=[];if(i.clearcoatFactor!==void 0&&(t.clearcoat=i.clearcoatFactor),i.clearcoatTexture!==void 0&&n.push(this.parser.assignTexture(t,"clearcoatMap",i.clearcoatTexture)),i.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=i.clearcoatRoughnessFactor),i.clearcoatRoughnessTexture!==void 0&&n.push(this.parser.assignTexture(t,"clearcoatRoughnessMap",i.clearcoatRoughnessTexture)),i.clearcoatNormalTexture!==void 0&&(n.push(this.parser.assignTexture(t,"clearcoatNormalMap",i.clearcoatNormalTexture)),i.clearcoatNormalTexture.scale!==void 0)){const s=i.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new xe(s,s)}return Promise.all(n)}}class XN{constructor(e){this.parser=e,this.name=Et.KHR_MATERIALS_DISPERSION}getMaterialType(e){return yi(this.parser,e,this.name)!==null?Xn:null}extendMaterialParams(e,t){const i=yi(this.parser,e,this.name);return i===null||(t.dispersion=i.dispersion!==void 0?i.dispersion:0),Promise.resolve()}}class jN{constructor(e){this.parser=e,this.name=Et.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){return yi(this.parser,e,this.name)!==null?Xn:null}extendMaterialParams(e,t){const i=yi(this.parser,e,this.name);if(i===null)return Promise.resolve();const n=[];return i.iridescenceFactor!==void 0&&(t.iridescence=i.iridescenceFactor),i.iridescenceTexture!==void 0&&n.push(this.parser.assignTexture(t,"iridescenceMap",i.iridescenceTexture)),i.iridescenceIor!==void 0&&(t.iridescenceIOR=i.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),i.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=i.iridescenceThicknessMinimum),i.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=i.iridescenceThicknessMaximum),i.iridescenceThicknessTexture!==void 0&&n.push(this.parser.assignTexture(t,"iridescenceThicknessMap",i.iridescenceThicknessTexture)),Promise.all(n)}}class qN{constructor(e){this.parser=e,this.name=Et.KHR_MATERIALS_SHEEN}getMaterialType(e){return yi(this.parser,e,this.name)!==null?Xn:null}extendMaterialParams(e,t){const i=yi(this.parser,e,this.name);if(i===null)return Promise.resolve();const n=[];if(t.sheenColor=new Xe(0,0,0),t.sheenRoughness=0,t.sheen=1,i.sheenColorFactor!==void 0){const s=i.sheenColorFactor;t.sheenColor.setRGB(s[0],s[1],s[2],Fi)}return i.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=i.sheenRoughnessFactor),i.sheenColorTexture!==void 0&&n.push(this.parser.assignTexture(t,"sheenColorMap",i.sheenColorTexture,Qt)),i.sheenRoughnessTexture!==void 0&&n.push(this.parser.assignTexture(t,"sheenRoughnessMap",i.sheenRoughnessTexture)),Promise.all(n)}}class ZN{constructor(e){this.parser=e,this.name=Et.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){return yi(this.parser,e,this.name)!==null?Xn:null}extendMaterialParams(e,t){const i=yi(this.parser,e,this.name);if(i===null)return Promise.resolve();const n=[];return i.transmissionFactor!==void 0&&(t.transmission=i.transmissionFactor),i.transmissionTexture!==void 0&&n.push(this.parser.assignTexture(t,"transmissionMap",i.transmissionTexture)),Promise.all(n)}}class YN{constructor(e){this.parser=e,this.name=Et.KHR_MATERIALS_VOLUME}getMaterialType(e){return yi(this.parser,e,this.name)!==null?Xn:null}extendMaterialParams(e,t){const i=yi(this.parser,e,this.name);if(i===null)return Promise.resolve();const n=[];t.thickness=i.thicknessFactor!==void 0?i.thicknessFactor:0,i.thicknessTexture!==void 0&&n.push(this.parser.assignTexture(t,"thicknessMap",i.thicknessTexture)),t.attenuationDistance=i.attenuationDistance||1/0;const s=i.attenuationColor||[1,1,1];return t.attenuationColor=new Xe().setRGB(s[0],s[1],s[2],Fi),Promise.all(n)}}class KN{constructor(e){this.parser=e,this.name=Et.KHR_MATERIALS_IOR}getMaterialType(e){return yi(this.parser,e,this.name)!==null?Xn:null}extendMaterialParams(e,t){const i=yi(this.parser,e,this.name);return i===null||(t.ior=i.ior!==void 0?i.ior:1.5),Promise.resolve()}}class $N{constructor(e){this.parser=e,this.name=Et.KHR_MATERIALS_SPECULAR}getMaterialType(e){return yi(this.parser,e,this.name)!==null?Xn:null}extendMaterialParams(e,t){const i=yi(this.parser,e,this.name);if(i===null)return Promise.resolve();const n=[];t.specularIntensity=i.specularFactor!==void 0?i.specularFactor:1,i.specularTexture!==void 0&&n.push(this.parser.assignTexture(t,"specularIntensityMap",i.specularTexture));const s=i.specularColorFactor||[1,1,1];return t.specularColor=new Xe().setRGB(s[0],s[1],s[2],Fi),i.specularColorTexture!==void 0&&n.push(this.parser.assignTexture(t,"specularColorMap",i.specularColorTexture,Qt)),Promise.all(n)}}class JN{constructor(e){this.parser=e,this.name=Et.EXT_MATERIALS_BUMP}getMaterialType(e){return yi(this.parser,e,this.name)!==null?Xn:null}extendMaterialParams(e,t){const i=yi(this.parser,e,this.name);if(i===null)return Promise.resolve();const n=[];return t.bumpScale=i.bumpFactor!==void 0?i.bumpFactor:1,i.bumpTexture!==void 0&&n.push(this.parser.assignTexture(t,"bumpMap",i.bumpTexture)),Promise.all(n)}}class QN{constructor(e){this.parser=e,this.name=Et.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){return yi(this.parser,e,this.name)!==null?Xn:null}extendMaterialParams(e,t){const i=yi(this.parser,e,this.name);if(i===null)return Promise.resolve();const n=[];return i.anisotropyStrength!==void 0&&(t.anisotropy=i.anisotropyStrength),i.anisotropyRotation!==void 0&&(t.anisotropyRotation=i.anisotropyRotation),i.anisotropyTexture!==void 0&&n.push(this.parser.assignTexture(t,"anisotropyMap",i.anisotropyTexture)),Promise.all(n)}}class e8{constructor(e){this.parser=e,this.name=Et.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,i=t.json,n=i.textures[e];if(!n.extensions||!n.extensions[this.name])return null;const s=n.extensions[this.name],a=t.options.ktx2Loader;if(!a){if(i.extensionsRequired&&i.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,s.source,a)}}class t8{constructor(e){this.parser=e,this.name=Et.EXT_TEXTURE_WEBP}loadTexture(e){const t=this.name,i=this.parser,n=i.json,s=n.textures[e];if(!s.extensions||!s.extensions[t])return null;const a=s.extensions[t],o=n.images[a.source];let l=i.textureLoader;if(o.uri){const c=i.options.manager.getHandler(o.uri);c!==null&&(l=c)}return i.loadTextureImage(e,a.source,l)}}class i8{constructor(e){this.parser=e,this.name=Et.EXT_TEXTURE_AVIF}loadTexture(e){const t=this.name,i=this.parser,n=i.json,s=n.textures[e];if(!s.extensions||!s.extensions[t])return null;const a=s.extensions[t],o=n.images[a.source];let l=i.textureLoader;if(o.uri){const c=i.options.manager.getHandler(o.uri);c!==null&&(l=c)}return i.loadTextureImage(e,a.source,l)}}class Yb{constructor(e,t){this.name=t,this.parser=e}loadBufferView(e){const t=this.parser.json,i=t.bufferViews[e];if(i.extensions&&i.extensions[this.name]){const n=i.extensions[this.name],s=this.parser.getDependency("buffer",n.buffer),a=this.parser.options.meshoptDecoder;if(!a||!a.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 s.then(function(o){const l=n.byteOffset||0,c=n.byteLength||0,h=n.count,d=n.byteStride,p=new Uint8Array(o,l,c);return a.decodeGltfBufferAsync?a.decodeGltfBufferAsync(h,d,p,n.mode,n.filter).then(function(u){return u.buffer}):a.ready.then(function(){const u=new ArrayBuffer(h*d);return a.decodeGltfBuffer(new Uint8Array(u),h,d,p,n.mode,n.filter),u})})}else return null}}class n8{constructor(e){this.name=Et.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,i=t.nodes[e];if(!i.extensions||!i.extensions[this.name]||i.mesh===void 0)return null;const n=t.meshes[i.mesh];for(const l of n.primitives)if(l.mode!==Kn.TRIANGLES&&l.mode!==Kn.TRIANGLE_STRIP&&l.mode!==Kn.TRIANGLE_FAN&&l.mode!==void 0)return null;const s=i.extensions[this.name].attributes,a=[],o={};for(const l in s)a.push(this.parser.getDependency("accessor",s[l]).then(c=>(o[l]=c,o[l])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(l=>{const c=l.pop(),h=c.isGroup?c.children:[c],d=l[0].count,p=[];for(const u of h){const v=new Ke,m=new A,g=new Ct,f=new A(1,1,1),y=new ti(u.geometry,u.material,d);for(let x=0;x<d;x++)o.TRANSLATION&&m.fromBufferAttribute(o.TRANSLATION,x),o.ROTATION&&g.fromBufferAttribute(o.ROTATION,x),o.SCALE&&f.fromBufferAttribute(o.SCALE,x),y.setMatrixAt(x,v.compose(m,g,f));for(const x in o)if(x==="_COLOR_0"){const _=o[x];y.instanceColor=new Mr(_.array,_.itemSize,_.normalized)}else x!=="TRANSLATION"&&x!=="ROTATION"&&x!=="SCALE"&&u.geometry.setAttribute(x,o[x]);bt.prototype.copy.call(y,u),this.parser.assignFinalMaterial(y),p.push(y)}return c.isGroup?(c.clear(),c.add(...p),c):p[0]}))}}const Kb="glTF",Zc=12,$b={JSON:1313821514,BIN:5130562};class s8{constructor(e){this.name=Et.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,Zc),i=new TextDecoder;if(this.header={magic:i.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==Kb)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const n=this.header.length-Zc,s=new DataView(e,Zc);let a=0;for(;a<n;){const o=s.getUint32(a,!0);a+=4;const l=s.getUint32(a,!0);if(a+=4,l===$b.JSON){const c=new Uint8Array(e,Zc+a,o);this.content=i.decode(c)}else if(l===$b.BIN){const c=Zc+a;this.body=e.slice(c,c+o)}a+=o}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class r8{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=Et.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const i=this.json,n=this.dracoLoader,s=e.extensions[this.name].bufferView,a=e.extensions[this.name].attributes,o={},l={},c={};for(const h in a){const d=W0[h]||h.toLowerCase();o[d]=a[h]}for(const h in e.attributes){const d=W0[h]||h.toLowerCase();if(a[h]!==void 0){const p=i.accessors[e.attributes[h]],u=bl[p.componentType];c[d]=u.name,l[d]=p.normalized===!0}}return t.getDependency("bufferView",s).then(function(h){return new Promise(function(d,p){n.decodeDracoFile(h,function(u){for(const v in u.attributes){const m=u.attributes[v],g=l[v];g!==void 0&&(m.normalized=g)}d(u)},o,c,Fi,p)})})}}class a8{constructor(){this.name=Et.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 o8{constructor(){this.name=Et.KHR_MESH_QUANTIZATION}}class Jb extends ma{constructor(e,t,i,n){super(e,t,i,n)}copySampleValue_(e){const t=this.resultBuffer,i=this.sampleValues,n=this.valueSize,s=e*n*3+n;for(let a=0;a!==n;a++)t[a]=i[s+a];return t}interpolate_(e,t,i,n){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=o*2,c=o*3,h=n-t,d=(i-t)/h,p=d*d,u=p*d,v=e*c,m=v-c,g=-2*u+3*p,f=u-p,y=1-g,x=f-p+d;for(let _=0;_!==o;_++){const E=a[m+_+o],S=a[m+_+l]*h,C=a[v+_+o],w=a[v+_]*h;s[_]=y*E+x*S+g*C+f*w}return s}}const l8=new Ct;class c8 extends Jb{interpolate_(e,t,i,n){const s=super.interpolate_(e,t,i,n);return l8.fromArray(s).normalize().toArray(s),s}}const Kn={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},bl={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Qb={9728:Yt,9729:Pt,9984:Lh,9985:ho,9986:Jr,9987:Hn},eM={33071:an,33648:co,10497:Ki},G0={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},W0={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"},Xr={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},h8={CUBICSPLINE:void 0,LINEAR:fo,STEP:po},X0={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function d8(r){return r.DefaultMaterial===void 0&&(r.DefaultMaterial=new pa({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:zn})),r.DefaultMaterial}function $a(r,e,t){for(const i in t.extensions)r[i]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[i]=t.extensions[i])}function As(r,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(r.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function u8(r,e,t){let i=!1,n=!1,s=!1;for(let c=0,h=e.length;c<h;c++){const d=e[c];if(d.POSITION!==void 0&&(i=!0),d.NORMAL!==void 0&&(n=!0),d.COLOR_0!==void 0&&(s=!0),i&&n&&s)break}if(!i&&!n&&!s)return Promise.resolve(r);const a=[],o=[],l=[];for(let c=0,h=e.length;c<h;c++){const d=e[c];if(i){const p=d.POSITION!==void 0?t.getDependency("accessor",d.POSITION):r.attributes.position;a.push(p)}if(n){const p=d.NORMAL!==void 0?t.getDependency("accessor",d.NORMAL):r.attributes.normal;o.push(p)}if(s){const p=d.COLOR_0!==void 0?t.getDependency("accessor",d.COLOR_0):r.attributes.color;l.push(p)}}return Promise.all([Promise.all(a),Promise.all(o),Promise.all(l)]).then(function(c){const h=c[0],d=c[1],p=c[2];return i&&(r.morphAttributes.position=h),n&&(r.morphAttributes.normal=d),s&&(r.morphAttributes.color=p),r.morphTargetsRelative=!0,r})}function p8(r,e){if(r.updateMorphTargets(),e.weights!==void 0)for(let t=0,i=e.weights.length;t<i;t++)r.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(r.morphTargetInfluences.length===t.length){r.morphTargetDictionary={};for(let i=0,n=t.length;i<n;i++)r.morphTargetDictionary[t[i]]=i}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function f8(r){let e;const t=r.extensions&&r.extensions[Et.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+j0(t.attributes):e=r.indices+":"+j0(r.attributes)+":"+r.mode,r.targets!==void 0)for(let i=0,n=r.targets.length;i<n;i++)e+=":"+j0(r.targets[i]);return e}function j0(r){let e="";const t=Object.keys(r).sort();for(let i=0,n=t.length;i<n;i++)e+=t[i]+":"+r[t[i]]+";";return e}function q0(r){switch(r){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 m8(r){return r.search(/\.jpe?g($|\?)/i)>0||r.search(/^data\:image\/jpeg/)===0?"image/jpeg":r.search(/\.webp($|\?)/i)>0||r.search(/^data\:image\/webp/)===0?"image/webp":r.search(/\.ktx2($|\?)/i)>0||r.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const g8=new Ke;class v8{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new zN,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 i=!1,n=-1,s=!1,a=-1;if(typeof navigator<"u"&&typeof navigator.userAgent<"u"){const o=navigator.userAgent;i=/^((?!chrome|android).)*safari/i.test(o)===!0;const l=o.match(/Version\/(\d+)/);n=i&&l?parseInt(l[1],10):-1,s=o.indexOf("Firefox")>-1,a=s?o.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||i&&n<17||s&&a<98?this.textureLoader=new ba(this.options.manager):this.textureLoader=new Ay(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new yn(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 i=this,n=this.json,s=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(a){return a._markDefs&&a._markDefs()}),Promise.all(this._invokeAll(function(a){return a.beforeRoot&&a.beforeRoot()})).then(function(){return Promise.all([i.getDependencies("scene"),i.getDependencies("animation"),i.getDependencies("camera")])}).then(function(a){const o={scene:a[0][n.scene||0],scenes:a[0],animations:a[1],cameras:a[2],asset:n.asset,parser:i,userData:{}};return $a(s,o,n),As(o,n),Promise.all(i._invokeAll(function(l){return l.afterRoot&&l.afterRoot(o)})).then(function(){for(const l of o.scenes)l.updateMatrixWorld();e(o)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],i=this.json.meshes||[];for(let n=0,s=t.length;n<s;n++){const a=t[n].joints;for(let o=0,l=a.length;o<l;o++)e[a[o]].isBone=!0}for(let n=0,s=e.length;n<s;n++){const a=e[n];a.mesh!==void 0&&(this._addNodeRef(this.meshCache,a.mesh),a.skin!==void 0&&(i[a.mesh].isSkinnedMesh=!0)),a.camera!==void 0&&this._addNodeRef(this.cameraCache,a.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,i){if(e.refs[t]<=1)return i;const n=i.clone(),s=(a,o)=>{const l=this.associations.get(a);l!=null&&this.associations.set(o,l);for(const[c,h]of a.children.entries())s(h,o.children[c])};return s(i,n),n.name+="_instance_"+e.uses[t]++,n}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let i=0;i<t.length;i++){const n=e(t[i]);if(n)return n}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const i=[];for(let n=0;n<t.length;n++){const s=e(t[n]);s&&i.push(s)}return i}getDependency(e,t){const i=e+":"+t;let n=this.cache.get(i);if(!n){switch(e){case"scene":n=this.loadScene(t);break;case"node":n=this._invokeOne(function(s){return s.loadNode&&s.loadNode(t)});break;case"mesh":n=this._invokeOne(function(s){return s.loadMesh&&s.loadMesh(t)});break;case"accessor":n=this.loadAccessor(t);break;case"bufferView":n=this._invokeOne(function(s){return s.loadBufferView&&s.loadBufferView(t)});break;case"buffer":n=this.loadBuffer(t);break;case"material":n=this._invokeOne(function(s){return s.loadMaterial&&s.loadMaterial(t)});break;case"texture":n=this._invokeOne(function(s){return s.loadTexture&&s.loadTexture(t)});break;case"skin":n=this.loadSkin(t);break;case"animation":n=this._invokeOne(function(s){return s.loadAnimation&&s.loadAnimation(t)});break;case"camera":n=this.loadCamera(t);break;default:if(n=this._invokeOne(function(s){return s!=this&&s.getDependency&&s.getDependency(e,t)}),!n)throw new Error("Unknown type: "+e);break}this.cache.add(i,n)}return n}getDependencies(e){let t=this.cache.get(e);if(!t){const i=this,n=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(n.map(function(s,a){return i.getDependency(e,a)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],i=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[Et.KHR_BINARY_GLTF].body);const n=this.options;return new Promise(function(s,a){i.load(Pr.resolveURL(t.uri,n.path),s,void 0,function(){a(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(i){const n=t.byteLength||0,s=t.byteOffset||0;return i.slice(s,s+n)})}loadAccessor(e){const t=this,i=this.json,n=this.json.accessors[e];if(n.bufferView===void 0&&n.sparse===void 0){const a=G0[n.type],o=bl[n.componentType],l=n.normalized===!0,c=new o(n.count*a);return Promise.resolve(new wt(c,a,l))}const s=[];return n.bufferView!==void 0?s.push(this.getDependency("bufferView",n.bufferView)):s.push(null),n.sparse!==void 0&&(s.push(this.getDependency("bufferView",n.sparse.indices.bufferView)),s.push(this.getDependency("bufferView",n.sparse.values.bufferView))),Promise.all(s).then(function(a){const o=a[0],l=G0[n.type],c=bl[n.componentType],h=c.BYTES_PER_ELEMENT,d=h*l,p=n.byteOffset||0,u=n.bufferView!==void 0?i.bufferViews[n.bufferView].byteStride:void 0,v=n.normalized===!0;let m,g;if(u&&u!==d){const f=Math.floor(p/u),y="InterleavedBuffer:"+n.bufferView+":"+n.componentType+":"+f+":"+n.count;let x=t.cache.get(y);x||(m=new c(o,f*u,n.count*u/h),x=new Ao(m,u/h),t.cache.add(y,x)),g=new Fs(x,l,p%u/h,v)}else o===null?m=new c(n.count*l):m=new c(o,p,n.count*l),g=new wt(m,l,v);if(n.sparse!==void 0){const f=G0.SCALAR,y=bl[n.sparse.indices.componentType],x=n.sparse.indices.byteOffset||0,_=n.sparse.values.byteOffset||0,E=new y(a[1],x,n.sparse.count*f),S=new c(a[2],_,n.sparse.count*l);o!==null&&(g=new wt(g.array.slice(),g.itemSize,g.normalized)),g.normalized=!1;for(let C=0,w=E.length;C<w;C++){const M=E[C];if(g.setX(M,S[C*l]),l>=2&&g.setY(M,S[C*l+1]),l>=3&&g.setZ(M,S[C*l+2]),l>=4&&g.setW(M,S[C*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}g.normalized=v}return g})}loadTexture(e){const t=this.json,i=this.options,n=t.textures[e].source,s=t.images[n];let a=this.textureLoader;if(s.uri){const o=i.manager.getHandler(s.uri);o!==null&&(a=o)}return this.loadTextureImage(e,n,a)}loadTextureImage(e,t,i){const n=this,s=this.json,a=s.textures[e],o=s.images[t],l=(o.uri||o.bufferView)+":"+a.sampler;if(this.textureCache[l])return this.textureCache[l];const c=this.loadImageSource(t,i).then(function(h){h.flipY=!1,h.name=a.name||o.name||"",h.name===""&&typeof o.uri=="string"&&o.uri.startsWith("data:image/")===!1&&(h.name=o.uri);const d=(s.samplers||{})[a.sampler]||{};return h.magFilter=Qb[d.magFilter]||Pt,h.minFilter=Qb[d.minFilter]||Hn,h.wrapS=eM[d.wrapS]||Ki,h.wrapT=eM[d.wrapT]||Ki,h.generateMipmaps=!h.isCompressedTexture&&h.minFilter!==Yt&&h.minFilter!==Pt,n.associations.set(h,{textures:e}),h}).catch(function(){return null});return this.textureCache[l]=c,c}loadImageSource(e,t){const i=this,n=this.json,s=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(d=>d.clone());const a=n.images[e],o=self.URL||self.webkitURL;let l=a.uri||"",c=!1;if(a.bufferView!==void 0)l=i.getDependency("bufferView",a.bufferView).then(function(d){c=!0;const p=new Blob([d],{type:a.mimeType});return l=o.createObjectURL(p),l});else if(a.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(p,u){let v=p;t.isImageBitmapLoader===!0&&(v=function(m){const g=new ei(m);g.needsUpdate=!0,p(g)}),t.load(Pr.resolveURL(d,s.path),v,void 0,u)})}).then(function(d){return c===!0&&o.revokeObjectURL(l),As(d,a),d.userData.mimeType=a.mimeType||m8(a.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,i,n){const s=this;return this.getDependency("texture",i.index).then(function(a){if(!a)return null;if(i.texCoord!==void 0&&i.texCoord>0&&(a=a.clone(),a.channel=i.texCoord),s.extensions[Et.KHR_TEXTURE_TRANSFORM]){const o=i.extensions!==void 0?i.extensions[Et.KHR_TEXTURE_TRANSFORM]:void 0;if(o){const l=s.associations.get(a);a=s.extensions[Et.KHR_TEXTURE_TRANSFORM].extendTexture(a,o),s.associations.set(a,l)}}return n!==void 0&&(a.colorSpace=n),e[t]=a,a})}assignFinalMaterial(e){const t=e.geometry;let i=e.material;const n=t.attributes.tangent===void 0,s=t.attributes.color!==void 0,a=t.attributes.normal===void 0;if(e.isPoints){const o="PointsMaterial:"+i.uuid;let l=this.cache.get(o);l||(l=new su,Ri.prototype.copy.call(l,i),l.color.copy(i.color),l.map=i.map,l.sizeAttenuation=!1,this.cache.add(o,l)),i=l}else if(e.isLine){const o="LineBasicMaterial:"+i.uuid;let l=this.cache.get(o);l||(l=new ii,Ri.prototype.copy.call(l,i),l.color.copy(i.color),l.map=i.map,this.cache.add(o,l)),i=l}if(n||s||a){let o="ClonedMaterial:"+i.uuid+":";n&&(o+="derivative-tangents:"),s&&(o+="vertex-colors:"),a&&(o+="flat-shading:");let l=this.cache.get(o);l||(l=i.clone(),s&&(l.vertexColors=!0),a&&(l.flatShading=!0),n&&(l.normalScale&&(l.normalScale.y*=-1),l.clearcoatNormalScale&&(l.clearcoatNormalScale.y*=-1)),this.cache.add(o,l),this.associations.set(l,this.associations.get(i))),i=l}e.material=i}getMaterialType(){return pa}loadMaterial(e){const t=this,i=this.json,n=this.extensions,s=i.materials[e];let a;const o={},l=s.extensions||{},c=[];if(l[Et.KHR_MATERIALS_UNLIT]){const d=n[Et.KHR_MATERIALS_UNLIT];a=d.getMaterialType(),c.push(d.extendParams(o,s,t))}else{const d=s.pbrMetallicRoughness||{};if(o.color=new Xe(1,1,1),o.opacity=1,Array.isArray(d.baseColorFactor)){const p=d.baseColorFactor;o.color.setRGB(p[0],p[1],p[2],Fi),o.opacity=p[3]}d.baseColorTexture!==void 0&&c.push(t.assignTexture(o,"map",d.baseColorTexture,Qt)),o.metalness=d.metallicFactor!==void 0?d.metallicFactor:1,o.roughness=d.roughnessFactor!==void 0?d.roughnessFactor:1,d.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(o,"metalnessMap",d.metallicRoughnessTexture)),c.push(t.assignTexture(o,"roughnessMap",d.metallicRoughnessTexture))),a=this._invokeOne(function(p){return p.getMaterialType&&p.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(p){return p.extendMaterialParams&&p.extendMaterialParams(e,o)})))}s.doubleSided===!0&&(o.side=Ht);const h=s.alphaMode||X0.OPAQUE;if(h===X0.BLEND?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,h===X0.MASK&&(o.alphaTest=s.alphaCutoff!==void 0?s.alphaCutoff:.5)),s.normalTexture!==void 0&&a!==Rt&&(c.push(t.assignTexture(o,"normalMap",s.normalTexture)),o.normalScale=new xe(1,1),s.normalTexture.scale!==void 0)){const d=s.normalTexture.scale;o.normalScale.set(d,d)}if(s.occlusionTexture!==void 0&&a!==Rt&&(c.push(t.assignTexture(o,"aoMap",s.occlusionTexture)),s.occlusionTexture.strength!==void 0&&(o.aoMapIntensity=s.occlusionTexture.strength)),s.emissiveFactor!==void 0&&a!==Rt){const d=s.emissiveFactor;o.emissive=new Xe().setRGB(d[0],d[1],d[2],Fi)}return s.emissiveTexture!==void 0&&a!==Rt&&c.push(t.assignTexture(o,"emissiveMap",s.emissiveTexture,Qt)),Promise.all(c).then(function(){const d=new a(o);return s.name&&(d.name=s.name),As(d,s),t.associations.set(d,{materials:e}),s.extensions&&$a(n,d,s),d})}createUniqueName(e){const t=Dt.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,i=this.extensions,n=this.primitiveCache;function s(o){return i[Et.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(o,t).then(function(l){return tM(l,o,t)})}const a=[];for(let o=0,l=e.length;o<l;o++){const c=e[o],h=f8(c),d=n[h];if(d)a.push(d.promise);else{let p;c.extensions&&c.extensions[Et.KHR_DRACO_MESH_COMPRESSION]?p=s(c):p=tM(new ot,c,t),n[h]={primitive:c,promise:p},a.push(p)}}return Promise.all(a)}loadMesh(e){const t=this,i=this.json,n=this.extensions,s=i.meshes[e],a=s.primitives,o=[];for(let l=0,c=a.length;l<c;l++){const h=a[l].material===void 0?d8(this.cache):this.getDependency("material",a[l].material);o.push(h)}return o.push(t.loadGeometries(a)),Promise.all(o).then(function(l){const c=l.slice(0,l.length-1),h=l[l.length-1],d=[];for(let u=0,v=h.length;u<v;u++){const m=h[u],g=a[u];let f;const y=c[u];if(g.mode===Kn.TRIANGLES||g.mode===Kn.TRIANGLE_STRIP||g.mode===Kn.TRIANGLE_FAN||g.mode===void 0)f=s.isSkinnedMesh===!0?new Jf(m,y):new Ve(m,y),f.isSkinnedMesh===!0&&f.normalizeSkinWeights(),g.mode===Kn.TRIANGLE_STRIP?f.geometry=qb(f.geometry,Mf):g.mode===Kn.TRIANGLE_FAN&&(f.geometry=qb(f.geometry,vd));else if(g.mode===Kn.LINES)f=new fi(m,y);else if(g.mode===Kn.LINE_STRIP)f=new oi(m,y);else if(g.mode===Kn.LINE_LOOP)f=new nm(m,y);else if(g.mode===Kn.POINTS)f=new ou(m,y);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+g.mode);Object.keys(f.geometry.morphAttributes).length>0&&p8(f,s),f.name=t.createUniqueName(s.name||"mesh_"+e),As(f,s),g.extensions&&$a(n,f,g),t.assignFinalMaterial(f),d.push(f)}for(let u=0,v=d.length;u<v;u++)t.associations.set(d[u],{meshes:e,primitives:u});if(d.length===1)return s.extensions&&$a(n,d[0],s),d[0];const p=new bi;s.extensions&&$a(n,p,s),t.associations.set(p,{meshes:e});for(let u=0,v=d.length;u<v;u++)p.add(d[u]);return p})}loadCamera(e){let t;const i=this.json.cameras[e],n=i[i.type];if(!n){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return i.type==="perspective"?t=new ci(Lt.radToDeg(n.yfov),n.aspectRatio||1,n.znear||1,n.zfar||2e6):i.type==="orthographic"&&(t=new Zi(-n.xmag,n.xmag,n.ymag,-n.ymag,n.znear,n.zfar)),i.name&&(t.name=this.createUniqueName(i.name)),As(t,i),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],i=[];for(let n=0,s=t.joints.length;n<s;n++)i.push(this._loadNodeShallow(t.joints[n]));return t.inverseBindMatrices!==void 0?i.push(this.getDependency("accessor",t.inverseBindMatrices)):i.push(null),Promise.all(i).then(function(n){const s=n.pop(),a=n,o=[],l=[];for(let c=0,h=a.length;c<h;c++){const d=a[c];if(d){o.push(d);const p=new Ke;s!==null&&p.fromArray(s.array,c*16),l.push(p)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[c])}return new sc(o,l)})}loadAnimation(e){const t=this.json,i=this,n=t.animations[e],s=n.name?n.name:"animation_"+e,a=[],o=[],l=[],c=[],h=[];for(let d=0,p=n.channels.length;d<p;d++){const u=n.channels[d],v=n.samplers[u.sampler],m=u.target,g=m.node,f=n.parameters!==void 0?n.parameters[v.input]:v.input,y=n.parameters!==void 0?n.parameters[v.output]:v.output;m.node!==void 0&&(a.push(this.getDependency("node",g)),o.push(this.getDependency("accessor",f)),l.push(this.getDependency("accessor",y)),c.push(v),h.push(m))}return Promise.all([Promise.all(a),Promise.all(o),Promise.all(l),Promise.all(c),Promise.all(h)]).then(function(d){const p=d[0],u=d[1],v=d[2],m=d[3],g=d[4],f=[];for(let x=0,_=p.length;x<_;x++){const E=p[x],S=u[x],C=v[x],w=m[x],M=g[x];if(E===void 0)continue;E.updateMatrix&&E.updateMatrix();const R=i._createAnimationTracks(E,S,C,w,M);if(R)for(let N=0;N<R.length;N++)f.push(R[N])}const y=new Bo(s,void 0,f);return As(y,n),y})}createNodeMesh(e){const t=this.json,i=this,n=t.nodes[e];return n.mesh===void 0?null:i.getDependency("mesh",n.mesh).then(function(s){const a=i._getNodeRef(i.meshCache,n.mesh,s);return n.weights!==void 0&&a.traverse(function(o){if(o.isMesh)for(let l=0,c=n.weights.length;l<c;l++)o.morphTargetInfluences[l]=n.weights[l]}),a})}loadNode(e){const t=this.json,i=this,n=t.nodes[e],s=i._loadNodeShallow(e),a=[],o=n.children||[];for(let c=0,h=o.length;c<h;c++)a.push(i.getDependency("node",o[c]));const l=n.skin===void 0?Promise.resolve(null):i.getDependency("skin",n.skin);return Promise.all([s,Promise.all(a),l]).then(function(c){const h=c[0],d=c[1],p=c[2];p!==null&&h.traverse(function(u){u.isSkinnedMesh&&u.bind(p,g8)});for(let u=0,v=d.length;u<v;u++)h.add(d[u]);if(h.userData.pivot!==void 0&&d.length>0){const u=h.userData.pivot,v=d[0];h.pivot=new A().fromArray(u),h.position.x-=u[0],h.position.y-=u[1],h.position.z-=u[2],v.position.set(0,0,0),delete h.userData.pivot}return h})}_loadNodeShallow(e){const t=this.json,i=this.extensions,n=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const s=t.nodes[e],a=s.name?n.createUniqueName(s.name):"",o=[],l=n._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});return l&&o.push(l),s.camera!==void 0&&o.push(n.getDependency("camera",s.camera).then(function(c){return n._getNodeRef(n.cameraCache,s.camera,c)})),n._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(e)}).forEach(function(c){o.push(c)}),this.nodeCache[e]=Promise.all(o).then(function(c){let h;if(s.isBone===!0?h=new Zd:c.length>1?h=new bi:c.length===1?h=c[0]:h=new bt,h!==c[0])for(let d=0,p=c.length;d<p;d++)h.add(c[d]);if(s.name&&(h.userData.name=s.name,h.name=a),As(h,s),s.extensions&&$a(i,h,s),s.matrix!==void 0){const d=new Ke;d.fromArray(s.matrix),h.applyMatrix4(d)}else s.translation!==void 0&&h.position.fromArray(s.translation),s.rotation!==void 0&&h.quaternion.fromArray(s.rotation),s.scale!==void 0&&h.scale.fromArray(s.scale);if(!n.associations.has(h))n.associations.set(h,{});else if(s.mesh!==void 0&&n.meshCache.refs[s.mesh]>1){const d=n.associations.get(h);n.associations.set(h,{...d})}return n.associations.get(h).nodes=e,h}),this.nodeCache[e]}loadScene(e){const t=this.extensions,i=this.json.scenes[e],n=this,s=new bi;i.name&&(s.name=n.createUniqueName(i.name)),As(s,i),i.extensions&&$a(t,s,i);const a=i.nodes||[],o=[];for(let l=0,c=a.length;l<c;l++)o.push(n.getDependency("node",a[l]));return Promise.all(o).then(function(l){for(let h=0,d=l.length;h<d;h++){const p=l[h];p.parent!==null?s.add(BN(p)):s.add(p)}const c=h=>{const d=new Map;for(const[p,u]of n.associations)(p instanceof Ri||p instanceof ei)&&d.set(p,u);return h.traverse(p=>{const u=n.associations.get(p);u!=null&&d.set(p,u)}),d};return n.associations=c(s),s})}_createAnimationTracks(e,t,i,n,s){const a=[],o=e.name?e.name:e.uuid,l=[];Xr[s.path]===Xr.weights?e.traverse(function(p){p.morphTargetInfluences&&l.push(p.name?p.name:p.uuid)}):l.push(o);let c;switch(Xr[s.path]){case Xr.weights:c=va;break;case Xr.rotation:c=ya;break;case Xr.translation:case Xr.scale:c=_a;break;default:i.itemSize===1?c=va:c=_a;break}const h=n.interpolation!==void 0?h8[n.interpolation]:fo,d=this._getArrayFromAccessor(i);for(let p=0,u=l.length;p<u;p++){const v=new c(l[p]+"."+Xr[s.path],t.array,d,h);n.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(v),a.push(v)}return a}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const i=q0(t.constructor),n=new Float32Array(t.length);for(let s=0,a=t.length;s<a;s++)n[s]=t[s]*i;t=n}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(t){const i=this instanceof ya?c8:Jb;return new i(this.times,this.values,this.getValueSize()/3,t)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function y8(r,e,t){const i=e.attributes,n=new Ot;if(i.POSITION!==void 0){const o=t.json.accessors[i.POSITION],l=o.min,c=o.max;if(l!==void 0&&c!==void 0){if(n.set(new A(l[0],l[1],l[2]),new A(c[0],c[1],c[2])),o.normalized){const h=q0(bl[o.componentType]);n.min.multiplyScalar(h),n.max.multiplyScalar(h)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const s=e.targets;if(s!==void 0){const o=new A,l=new A;for(let c=0,h=s.length;c<h;c++){const d=s[c];if(d.POSITION!==void 0){const p=t.json.accessors[d.POSITION],u=p.min,v=p.max;if(u!==void 0&&v!==void 0){if(l.setX(Math.max(Math.abs(u[0]),Math.abs(v[0]))),l.setY(Math.max(Math.abs(u[1]),Math.abs(v[1]))),l.setZ(Math.max(Math.abs(u[2]),Math.abs(v[2]))),p.normalized){const m=q0(bl[p.componentType]);l.multiplyScalar(m)}o.max(l)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}n.expandByVector(o)}r.boundingBox=n;const a=new zi;n.getCenter(a.center),a.radius=n.min.distanceTo(n.max)/2,r.boundingSphere=a}function tM(r,e,t){const i=e.attributes,n=[];function s(a,o){return t.getDependency("accessor",a).then(function(l){r.setAttribute(o,l)})}for(const a in i){const o=W0[a]||a.toLowerCase();o in r.attributes||n.push(s(i[a],o))}if(e.indices!==void 0&&!r.index){const a=t.getDependency("accessor",e.indices).then(function(o){r.setIndex(o)});n.push(a)}return St.workingColorSpace!==Fi&&"COLOR_0"in i&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${St.workingColorSpace}" not supported.`),As(r,e),y8(r,e,t),Promise.all(n).then(function(){return e.targets!==void 0?u8(r,e.targets,t):r})}var pi=(r=>(r.ModelLoadStart="model-load-start",r.ModelLoadProgress="model-load-progress",r.ModelLoaded="model-loaded",r.ModelError="model-error",r.SelectionChanged="selection-changed",r.HoverChanged="hover-changed",r.Click="click",r.MouseMove="mouse-move",r.CameraChanged="camera-changed",r.CameraIdle="camera-idle",r.EngineFree="engine-free",r.EngineBusy="engine-busy",r.MeasureChanged="measure-changed",r.MeasureClick="measure-click",r.SectionMove="section-move",r.LoadingCompleted="loading_completed",r))(pi||{});let Yc=null;const x8=8,iM=24,_8=24,b8=64,M8=60,S8=10;function nM(){return new URL("draco/",document.baseURI).toString()}function w8(){return Yc==null&&(Yc=new UN,Yc.setDecoderPath(nM()),Yc.preload()),Yc}function sM(){return new Promise(r=>{if(typeof requestAnimationFrame=="function"){requestAnimationFrame(()=>r());return}setTimeout(r,16)})}function E8(){const r=navigator?.scheduling;return typeof r?.isInputPending=="function"?r.isInputPending():!1}function C8(r){return r?.engineStatus?.isFree===!1||E8()}async function ar(r,e,t){if(e)return t;const i=performance.now();return C8(r)||i-t>=x8?(await sM(),performance.now()):t}function T8(r){return new Promise((e,t)=>{qc(r,i=>{if(i==null){t(new Error(`[loadLightModel] empty zip json: ${r}`));return}e(i)},()=>{t(new Error(`[loadLightModel] failed to load zip json: ${r}`))})})}function A8(r){return ui({method:"get",responseType:"arraybuffer",url:r}).then(e=>ab.loadAsync(e.data))}function rM(r){return r.replace(/\\/g,"/").replace(/^\/+/,"")}function aM(r,e){const t=new Set(e.map(i=>rM(i)));for(const i of Object.keys(r.files))if(t.has(rM(i)))return r.files[i];return null}function oM(r,e){const t=aM(r,e);return t==null||t.dir?Promise.resolve(null):t.async("string")}function P8(r){return r.charCodeAt(0)===65279?r.slice(1):r}function Z0(r){return JSON.parse(P8(r))}function R8(r,e){const t=aM(r,e);return t==null||t.dir?Promise.resolve(null):t.async("arraybuffer")}function L8(r){return new Promise((e,t)=>{const i=new FN;i.setDRACOLoader(w8()),i.parse(r,document.baseURI,e,t)})}function Kp(r,e){return r.models.find(t=>t.url==e)}function lM(r){r.loadStatus==null&&(r.loadStatus={}),r.loadStatus.modelMep==null&&(r.loadStatus.modelMep=!1),r.loadStatus.normal==null&&(r.loadStatus.normal=!1)}function I8(r){return lM(r),r.status==="loaded"&&r.loadStatus.normal===!0&&r.loadStatus.modelMep===!0}function cM(r){const e=r?.engineStatus?.models;!Array.isArray(e)||e.length===0||!e.every(t=>I8(t))||r.__loadingCompletedTriggered===!0||(r.__loadingCompletedTriggered=!0,r.events?.trigger?.(pi.LoadingCompleted,{}))}function hM(r){return r===!0||r==="loading"}function dM(r){return r.index!=null?r.index.count:r.attributes.position?.count??0}async function D8(r,e,t){let i=performance.now();for(let n=0;n<e.length;n++){const s=e[n];s?.geometry!=null&&s.geometry.computeVertexNormals,(n+1)%_8===0&&(i=await ar(r,t,i))}}async function N8(r,e,t){const i=[],n=[{node:e.octreeBox,visited:!1}];let s=performance.now();for(;n.length>0;){const a=n.pop();if(a==null||a.node==null||a.node.status===!0)continue;const o=a.node;if(a.visited){const c=Array.isArray(o.children)?o.children:[];(c.length===0||c.findIndex(h=>h.status!=!0)===-1)&&(o.status=!0),s=await ar(r,t,s);continue}n.push({node:o,visited:!0}),Array.isArray(o.elements)&&i.push(...o.elements);const l=Array.isArray(o.children)?o.children:[];for(let c=l.length-1;c>=0;c--)n.push({node:l[c],visited:!1});s=await ar(r,t,s)}return i}async function U8(r,e,t,i){const n=Kp(r,e.url);if(n?.nodesMap==null)return[];const s=await N8(r,t,i);console.log("[loadLightModel] pending mesh ids",t.path,s.length);const a=[];let o=performance.now(),l=0;for(const c of s){if(!n.nodesMap.has(c))continue;const h=n.nodesMap.get(c),d=Array.isArray(h?.infos)?h.infos:[];for(const p of d){const u=t.glbs?.[p.glb]?.[p.mesh];if(u?.geometry==null||u.material==null)continue;const v=new Ke;v.elements=p.matrix;const m=u.geometry.clone();m.applyMatrix4(v),m.computeBoundingBox();const g=new Ve(m,u.material);p.box=m.boundingBox?.clone(),p.mesh=g,g.name=Number(c),g.glb=p.glb,g.url=e.url,m.attributes.position!=null&&a.push(g),l++,l%iM===0&&(o=await ar(r,i,o))}}return a}function k8(r,e,t,i,n){const s=Ka(i.map(o=>o.geometry),!1),a=new Ve(s,n);return a.castShadow=!0,a.receiveShadow=!0,e.scene.add(a),a.index=e.scene.children.length-1,a.url=r,a.glb=t,a.materialClone=n,a.geometrys=i.map(o=>o.geometry),a.geometry.computeVertexNormals(),a}function O8(r,e,t,i){return r.scene.children.find(n=>{const s=n;return n instanceof Ve&&s.url==e&&s.glb==t&&s.materialClone===i})}function B8(r,e){const t=Array.isArray(r.geometrys)?r.geometrys:[],i=e.map(a=>a.geometry),n=[...t,...i],s=Ka(n,!1);r.geometry!=null&&r.geometry.dispose(),r.geometry=s,r.geometrys=n,r.castShadow=!0,r.receiveShadow=!0}async function F8(r,e,t,i){const n=new Map;for(const o of t){const l=n.get(o.glb)??[];l.push(o),n.set(o.glb,l)}const s=Kp(e,r);let a=performance.now();for(const[o,l]of n.entries()){const c=i?l.length:M8;for(let h=0;h<l.length;h+=c){const d=l.slice(h,h+c);if(d.length===0)continue;const p=Y8(d[0].material,e);let u=O8(e,r,o,p),v=0,m=0;u=null,u!=null?(v=Array.isArray(u.geometrys)?u.geometrys.length:0,m=dM(u.geometry),B8(u,d)):u=k8(r,e,o,d,p);const g=new Map;let f=m;d.forEach((y,x)=>{const _=Number(y.name),E=dM(y.geometry),S=g.get(_)??[];if(S.push([f,f+E]),g.set(_,S),s?.nodesMap?.has(_)){const C=s.nodesMap.get(_);C.indexes==null&&(C.indexes=[]),C.indexes.push([u.index,v+x,f,f+E])}f+=E}),u.indexes==null&&(u.indexes=new Map),g.forEach((y,x)=>{const _=u.indexes.get(x)??[];_.push(...y),u.indexes.set(x,_)}),a=await ar(e,i,a)}}}async function z8(r,e,t,i,n,s){if(i==null||n==null||n.length===0)return;const a=Kp(t,r);if(a==null)return;const o=new ti(i.geometry,i.material,n.length);t.scene.add(o);const l=new Float32Array(n.length*3);for(let d=0;d<n.length;d++)l[d*3]=1,l[d*3+1]=1,l[d*3+2]=1;o.instanceColor=new Mr(l,3);let c=performance.now();const h=[];for(let d=0;d<n.length;d++){const p=n[d],u=new Ke;if(u.elements=p.matrix,o.setMatrixAt(d,u),o.matrixs||(o.matrixs=[]),o.matrixs.push(u.clone()),h.push(u.clone()),a.nodesMap.has(p.id)){const v=a.nodesMap.get(p.id);v.indexes==null&&(v.indexes=[]),v.indexes.push([t.scene.children.length-1,d,0,0])}else a.nodesMap.set(p.id,{instance:!0,info:p,indexes:[[t.scene.children.length-1,d,0,0]]});(d+1)%b8===0&&(c=await ar(t,s,c))}o.instanceMatrix.needsUpdate=!0,o.instanceColor!=null&&(o.instanceColor.needsUpdate=!0),o.index=t.scene.children.length-1,o.materialClone=i.material,o.url=r,o.glb=i.glb,o.ids=n.map(d=>d.id),o.matrixsClone=h,o.meshIndex=e}async function H8(r,e,t,i){const n=e.instanceNodes;if(n==null)return;let s=performance.now();for(const a in n)if(n[a].isLoaded!==!0){n[a].isLoaded=!0;for(const o of n[a]){const l=e.glbs?.[a]?.[o.mesh];l!=null&&await z8(r.url,o.mesh,t,l,o.children,i)}s=await ar(t,i,s)}}async function V8(r,e,t,i){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 n=await U8(r,e,t,i);await F8(e.url,r,n,i),await H8(e,t,r,i),t.status=!0,console.log(`[loadLightModel] *****************************************************finish build lod meshes ${Date.now()-window.startTime}ms`)})().finally(()=>{t.meshPromise=null}),await t.meshPromise}async function G8(r,e,t,i){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 n=await A8(e.url+t.path),s=await oM(n,["/nodes.json","nodes.json"]);if(s==null)return;const a=Z0(s),o=Kp(r,e.url);if(o==null)return;o.nodesMap==null&&(o.nodesMap=new Map);let l=performance.now();for(const h of Object.keys(a)){const d=a[h];for(let u=0;u<d.length;u++){const v=d[u];v.glb=h,o.nodesMap.has(v.id)===!1?o.nodesMap.set(v.id,{infos:[v]}):o.nodesMap.get(v.id).infos.push(v),(u+1)%iM===0&&(l=await ar(r,i,l))}const p=await R8(n,[`/${h}.glb`,`${h}.glb`,h+".glb"]);if(p==null){console.error("[loadLightModel] glb not found in zip",{modelUrl:e.url,lodPath:t.path,glbKey:`${h}.glb`,availableFiles:Object.keys(n.files)});continue}try{const u=await L8(p);t.glbs[h]=u.scene.children,await D8(r,t.glbs[h],i)}catch(u){console.error("[loadLightModel] failed to load glb",{modelUrl:e.url,lodPath:t.path,glbKey:`${h}.glb`,dracoDecoderPath:nM(),error:u})}l=await ar(r,i,l)}const c=await oM(n,["/instances.json","instances.json"]);t.instanceNodes=c!=null?Z0(c):null,t.loadSuccess=!0})().finally(()=>{t.preparePromise=null}),await t.preparePromise}}function W8(r,e,t){if(t.boundingBox||(t.boundingBox=new Ot,t.boundingBox.min=new A(t.octreeBox.min.X,t.octreeBox.min.Z,-t.octreeBox.min.Y),t.boundingBox.max=new A(t.octreeBox.max.X,t.octreeBox.max.Z,-t.octreeBox.max.Y)),!t.maxSize)return 1e3;const i=t.boundingBox,n=i.min,s=i.max,a=n.clone().add(s.clone()).multiplyScalar(.5),o=n.distanceTo(s),l=new A,c=new A,h=new A,d=new A;if(e.getWorldDirection(h),e.getWorldPosition(d),e.matrixWorld.extractBasis(l,c,new A),e instanceof Zi){const f=Math.max((e.top-e.bottom)/e.zoom,1e-6),y=r?.cameraModule?.perspectiveCamera?.getEffectiveFOV?.()??20,x=Lt.degToRad(y*.5),_=x>0?f/(2*Math.tan(x)):f;d.copy(a).add(h.clone().multiplyScalar(-_))}if(d.distanceTo(a)<=o*.5)return 1e3;const p=a.clone().sub(d).dot(h);if(p<=0)return 0;const u=d.clone().add(h.multiplyScalar(Math.max(p,o))),v=u.clone().add(l.setLength(t.maxSize)),m=new Ft(e,r.renderer,r.scene).worldToScreen(u),g=new Ft(e,r.renderer,r.scene).worldToScreen(v);return m.distanceTo(g)}async function X8(r,e,t,i){t.maxSize<1e6&&t.path!="/lod0"&&(!(W8(r,r.camera,t)>=S8)||t.status===!0)||(await G8(r,e,t,i),t.loadSuccess===!0&&await V8(r,e,t,i))}function j8(r,e,t){hM(e.loadStatus.modelMep)||(e.loadStatus.modelMep="loading",e.info.modelMep==null&&(e.info.modelMep={}),(async()=>{t||await sM(),ON(r,e.info.modelMep,e.url),e.loadStatus.modelMep=!0,cM(r)})().catch(i=>{e.loadStatus.modelMep=!1,console.error("[loadLightModel] failed to load mep model",i)}))}function q8(r,e,t,i){const n=new bi;n.name=e,r.scene.add(n),r.models||(r.models=[]),window.startTime=Date.now(),T8(e+"/info").then(s=>{const a=Z0(s);r.__loadingCompletedTriggered=!1,r.engineStatus.models.push({type:"light",info:a,name:a.baseInfo.name,status:"loading",url:e,elements:new Map,loadStatus:{modelMep:!1,normal:!1}}),r.models.push({url:e,nodesMap:new Map,grids:a.modelGrid,levels:a.modelLevel,rooms:a.modelRoom,views:a.modelView,boundingBox:{min:new A(a.baseInfo.min.X*.3048,a.baseInfo.min.Z*.3048,-a.baseInfo.min.Y*.3048),max:new A(a.baseInfo.max.X*.3048,a.baseInfo.max.Z*.3048,-a.baseInfo.max.Y*.3048)}}),r.models.length==i&&(r.viewCube.CameraGoHome(1),setTimeout(()=>{uM(r,null,!1)},100))}).catch(s=>{console.error("[loadLightModel] failed to load model info",{url:e,error:s})})}async function uM(r,e,t=!1){const i=r.engineStatus.models.filter(n=>e==null||n.url==e);for(const n of i)if(lM(n),!(n.status!=="loading"||n.type!=="light")&&(j8(r,n,t),!hM(n.loadStatus.normal))){n.loadStatus.normal="loading";try{await Z8(r,n,t)}finally{const s=Array.isArray(n.info?.lods)&&n.info.lods.every(a=>a.status===!0);n.loadStatus.normal=s,s&&(n.status="loaded"),cM(r)}}}async function Z8(r,e,t=!1){if(console.log(`[loadLightModel] start loadNode ${Date.now()-window.startTime}ms`),!(e.info==null||e.info.lods==null))for(const i of e.info.lods)await X8(r,e,i,t)}function Y8(r,e){return r.map!=null&&(r.map.colorSpace=Qt,r.map.needsUpdate=!0),r.clipShadows=!0,e?.sectionPlane&&(r.clippingPlanes=e.sectionPlane),r}class K8{engine;constructor(e){this.engine=e}async loadModels(e,t){console.log("待加载模型",e);for(const n of e)i(n)==="light"&&q8(this.engine,n,t,e.length);function i(n){const s=n.split(".").pop();return s==="glb"||s==="gltf"?"gltf":"light"}}}var Ml=(r=>(r.ModelLoadStart="model-load-start",r.ModelLoadProgress="model-load-progress",r.ModelLoaded="model-loaded",r.ModelError="model-error",r.SelectionChanged="selection-changed",r.HoverChanged="hover-changed",r.Click="click",r.MouseMove="mouse-move",r.CameraChanged="camera-changed",r.CameraIdle="camera-idle",r.ViewportResize="viewport-resize",r.EngineFree="engine-free",r.EngineBusy="engine-busy",r.MeasureChanged="measure-changed",r.SectionMove="section-move",r.LoadingCompleted="loading_completed",r))(Ml||{});class $8{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(Ml.EngineFree,e=>{this.updateFree(!0),uM(this.engine,e,!1)}),this.engine.events.on(Ml.EngineBusy,()=>{this.updateFree(!1)})}updateFree(e){this.isFree=e}closeAllFunction=()=>{}}let J8=class{listeners=new Map;debugMode=!1;setDebugMode(r){this.debugMode=r}on(r,e){const t=String(r);this.listeners.has(t)||this.listeners.set(t,[]),this.listeners.get(t).push(e),this.debugMode&&console.debug(`[EventModule] 注册事件监听器: ${t}, 当前监听器数量: ${this.listeners.get(t).length}`)}off(r,e){const t=String(r);if(!this.listeners.has(t)){this.debugMode&&console.warn(`[EventModule] 尝试移除不存在的事件监听器: ${t}`);return}const i=this.listeners.get(t),n=i.indexOf(e);n!==-1?(i.splice(n,1),this.debugMode&&console.debug(`[EventModule] 移除事件监听器: ${t}, 剩余监听器数量: ${i.length}`)):this.debugMode&&console.warn(`[EventModule] 尝试移除的回调函数未找到: ${t}`)}trigger(r,e){const t=String(r);if(!this.listeners.has(t)){this.debugMode&&(console.warn(`[EventModule] 触发事件但未找到监听器: ${t}`),console.debug("[EventModule] 当前已注册的事件类型:",Array.from(this.listeners.keys())));return}const i=this.listeners.get(t);this.debugMode&&console.debug(`[EventModule] 触发事件: ${t}, 监听器数量: ${i.length}`,e),i.forEach((n,s)=>{try{n(e)}catch(a){console.error(`[EventModule] 事件监听器执行错误 [${t}] #${s}:`,a)}})}};class Q8{engine;constructor(e){this.engine=e}init(){const e=new Ar(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 i=new Ar(16777215,2);this.engine.scene.add(e),this.engine.scene.add(i),this.engine.scene.dirLight=i;const n=new zo(16777215,3);this.engine.scene.add(n)}}class eU{engine;behavior;isCtrlDown=!1;isShiftDown=!1;hoverOldId=null;timeOutEvent;selectionBox=null;isBoxSelecting=!1;selectionStart=new xe;selectionEnd=new xe;suppressClickOnce=!1;selectionThreshold=5;tempInstanceMatrix=new Ke;tempScale=new A;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 i=this.getCatchMeshs(e,!0);i!=null&&i.length>0&&this.engine.hoverHighLight.showModelNameTag({url:i[0].url,ids:[i[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(),i=t?this.collectModelsInSelection():[];this.isBoxSelecting=!1,this.hideSelectionBox(),this.engine.controls&&(this.engine.controls.enabled=!0),t&&(this.isBoxDeselectMode()?this.applyBoxDeselection(i):this.applyBoxSelection(i),this.suppressClickOnce=!0)}getCatchMeshs(e,t=!1){if(e.catch==null)return this.hoverOldId=null,null;if(e.catch.object.isInstance){const a=e.catch.object,o=e.catch.object.id,l=this.engine.models.find(d=>d.url==a.url)?.nodesMap?.get(o),c=new Map;l?.indexes.forEach(d=>{this.getSceneModel(d[0])instanceof ti&&(c.has(d[0])||c.set(d[0],[]),c.get(d[0])?.push(d[1]))});const h=[];return c.forEach((d,p)=>{const u=this.getSceneModel(p);d.forEach(v=>{const m=u.geometry.clone();m.applyMatrix4(u.matrixs[v]),h.push(new Ve(m,u.material))})}),this.hoverOldId==o?[]:(this.hoverOldId=o,t||this.engine.hoverHighLight.clearHighlight(),h)}const i=e.catch.object,n=i.name,s=this.engine.models.find(a=>a.url===i.url)?.nodesMap?.get(n)?.infos?.map(a=>a.mesh)??[];return this.hoverOldId==n?[]:(this.hoverOldId=n,t||this.engine.hoverHighLight.clearHighlight(),s)}handleMouseClick(e){if(this.suppressClickOnce){this.suppressClickOnce=!1;return}if(this.isShiftDown&&!this.isCtrlDown)return;if(e.catch!=null){const i=e.catch,n=i.object;if(!this.isCtrlDown){this.engine.modelToolModule.unhighlightAllModels();const a=new CustomEvent("D3ElementClick",{detail:{id:-1}});window.dispatchEvent(a)}this.engine.controlModule.orbitControls.origin.set(i.point.x,i.point.y,i.point.z),this.engine.modelToolModule.highlightModel([{url:n.url,ids:[n.name]}]),this.engine.events.trigger(pi.Click,[{url:n.url,ids:[n.name]}]);const s=new CustomEvent("D3ElementClick",{detail:{id:n.name}});window.dispatchEvent(s);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,i=t.object,n=this.engine.models.find(o=>o.url===i.url)?.nodesMap?.get(i.name);if(!n)return;if(t.object.isInstance){const o=t.matrix,l=[];n.indexes.forEach(h=>{const d=this.getSceneModel(h[0]);d?.geometry?.boundingSphere||d?.geometry?.computeBoundingSphere?.();const p=d?.geometry?.boundingSphere;if(!p)return;const u=new Ot,v=p.center.clone().applyMatrix4(o),m=p.radius,g=new A().setFromMatrixScale(o),f=m*Math.max(g.x,g.y,g.z);u.min.set(v.x-f,v.y-f,v.z-f),u.max.set(v.x+f,v.y+f,v.z+f),l.push(u)});const c=this.getMergedBox(l);c!=null&&this.engine.viewCube.zoomToModel(c);return}const s=n.infos.map(o=>o.box).filter(o=>o instanceof Ot),a=this.getMergedBox(s);a!=null&&this.engine.viewCube.zoomToModel(a)}handleMouseClickInstance(e){return e.intersectObjects(this.engine.scene.children.filter(t=>t instanceof ti),!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(),i=new Map;return this.engine.models?.forEach(n=>{!n?.url||!n?.nodesMap||n.nodesMap.forEach((s,a)=>{const o=this.getNodeWorldBox(s),l=this.projectBoxToScreenRect(o);l==null||!(t?this.containsRect(e,l):this.intersectsRect(e,l))||(i.has(n.url)||i.set(n.url,new Set),i.get(n.url)?.add(a))})}),Array.from(i.entries()).map(([n,s])=>({url:n,ids:Array.from(s)}))}applyBoxSelection(e){const t=this.excludeHighlightedModels(e);t.length!==0&&(this.engine.modelToolModule.highlightModel(t),this.engine.events.trigger(pi.SelectionChanged,t))}applyBoxDeselection(e){const t=this.keepHighlightedModels(e);t.length!==0&&(this.engine.modelToolModule.unhighlightModel(t),this.removeModelsFromHighlightState(t),this.engine.events.trigger(pi.SelectionChanged,t))}excludeHighlightedModels(e){const t=new Map;return(this.engine.engineStatus.highlightModels??[]).forEach(i=>{t.has(i.url)||t.set(i.url,new Set),i.ids.forEach(n=>t.get(i.url)?.add(n))}),e.map(i=>({url:i.url,ids:i.ids.filter(n=>!t.get(i.url)?.has(n))})).filter(i=>i.ids.length>0)}keepHighlightedModels(e){const t=new Map;return(this.engine.engineStatus.highlightModels??[]).forEach(i=>{t.has(i.url)||t.set(i.url,new Set),i.ids.forEach(n=>t.get(i.url)?.add(n))}),e.map(i=>({url:i.url,ids:i.ids.filter(n=>t.get(i.url)?.has(n))})).filter(i=>i.ids.length>0)}removeModelsFromHighlightState(e){const t=new Map;e.forEach(i=>{t.has(i.url)||t.set(i.url,new Set),i.ids.forEach(n=>t.get(i.url)?.add(n))}),this.engine.engineStatus.highlightModels=(this.engine.engineStatus.highlightModels??[]).map(i=>({url:i.url,ids:i.ids.filter(n=>!t.get(i.url)?.has(n))})).filter(i=>i.ids.length>0)}getNodeWorldBox(e){if(Array.isArray(e?.infos)&&e.infos.length>0){const t=e.infos.map(i=>i?.box).filter(i=>i instanceof Ot);return this.getMergedBox(t)}if(Array.isArray(e?.indexes)&&e.indexes.length>0){const t=[];return e.indexes.forEach(i=>{const n=this.getSceneModel(i[0]),s=this.getInstanceWorldBox(n,i[1]);s!=null&&t.push(s)}),this.getMergedBox(t)}return null}getInstanceWorldBox(e,t){if(!(e instanceof ti))return null;e.geometry.boundingBox||e.geometry.computeBoundingBox();const i=e.geometry.boundingBox;if(!i)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:i.clone().applyMatrix4(this.tempInstanceMatrix)}projectBoxToScreenRect(e){if(e==null||e.isEmpty())return null;const t=[new A(e.min.x,e.min.y,e.min.z),new A(e.min.x,e.min.y,e.max.z),new A(e.min.x,e.max.y,e.min.z),new A(e.min.x,e.max.y,e.max.z),new A(e.max.x,e.min.y,e.min.z),new A(e.max.x,e.min.y,e.max.z),new A(e.max.x,e.max.y,e.min.z),new A(e.max.x,e.max.y,e.max.z)];let i=1/0,n=1/0,s=-1/0,a=-1/0;return t.forEach(o=>{const l=new Ft(this.engine.camera,this.engine.renderer,this.engine.scene).worldToScreen(o);!Number.isFinite(l.x)||!Number.isFinite(l.y)||(i=Math.min(i,l.x),n=Math.min(n,l.y),s=Math.max(s,l.x),a=Math.max(a,l.y))}),!Number.isFinite(i)||!Number.isFinite(n)||!Number.isFinite(s)||!Number.isFinite(a)?null:{left:i,top:n,right:s,bottom:a}}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 Ot().makeEmpty();return e.forEach(i=>t.union(i)),t.isEmpty()?null:t}getSceneModel(e){return this.engine.scene.children.find(t=>t.index===e)??this.engine.scene.children[e]}}class tU{engine;highlightMaterial;hideMaterial;translucentMaterial;constructor(e){this.engine=e,this.highlightMaterial=new Rt({color:43775,depthTest:!1,depthWrite:!1,transparent:!0,opacity:.5,side:Ht}),this.hideMaterial=new Rt({color:0,transparent:!0,opacity:0,side:Ht}),this.translucentMaterial=new Rt({color:16777215,transparent:!0,opacity:.05,side:Ht}),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 ti)return;let t=e.materialClone.clone(),i=Ka(e.geometrys,!0);i.computeVertexNormals(),i.groups.forEach(n=>{n.materialIndex=0}),e.geometry=i,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 i=new Map;t.ids.forEach(s=>{let a=this.engine.models.find(o=>o.url==t.url).nodesMap.get(s);a!=null&&a.indexes!=null&&a.indexes.forEach(o=>{this.getSceneModel(o[0])instanceof ti?i.has(o[0])?i.get(o[0])?.push(o[1]):i.set(o[0],[o[1]]):(console.log(this.getSceneModel(o[0]).materialClone.color),this.split_merge_model(this.getSceneModel(o[0])),this.getSceneModel(o[0]).geometry.groups[o[1]].materialIndex=1)})}),iU(i,this.engine);let n=this.engine.engineStatus.highlightModels.find(s=>s.url==t.url);n!=null?n.ids.push(...t.ids):this.engine.engineStatus.highlightModels.push(t)})}unhighlightModel(e){e.forEach(t=>{let i=new Map;t.ids.forEach(n=>{let s=this.engine.models.find(a=>a.url==t.url).nodesMap.get(n);s!=null&&s.indexes!=null&&s.indexes.forEach(a=>{this.getSceneModel(a[0])instanceof ti?i.has(a[0])?i.get(a[0])?.push(a[1]):i.set(a[0],[a[1]]):this.getSceneModel(a[0]).geometry.groups[a[1]].materialIndex=0})}),pM(i,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 i=new Map;t.ids.forEach(s=>{let a=this.engine.models.find(o=>o.url==t.url).nodesMap.get(s);this.engine.modelEdge.hideModelEdge(t.url,s),a!=null&&a.indexes!=null&&a.indexes.forEach(o=>{const l=this.getSceneModel(o[0]);l instanceof ti?i.has(o[0])?i.get(o[0])?.push(o[1]):i.set(o[0],[o[1]]):(this.split_merge_model(this.getSceneModel(o[0])),l.geometry.groups[o[1]].materialIndex=-1,l.geometry.groups[o[1]].visible=!1)})}),i.size>0&&sU(i,this.engine);let n=this.engine.engineStatus.hideModels.find(s=>s.url==t.url);n!=null?n.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 i=new Map;t.ids.forEach(s=>{let a=this.engine.models.find(o=>o.url==t.url).nodesMap.get(s);this.engine.modelEdge.showModelEdge(t.url,s),a!=null&&a.indexes!=null&&a.indexes.forEach(o=>{const l=this.getSceneModel(o[0]);l instanceof ti?i.has(o[0])?i.get(o[0])?.push(o[1]):i.set(o[0],[o[1]]):(l.geometry.groups[o[1]].materialIndex=0,l.geometry.groups[o[1]].visible=!0)})}),i.size>0&&fM(i,this.engine);let n=this.engine.engineStatus.hideModels.find(s=>s.url==t.url);n&&(t.ids.forEach(s=>{const a=n.ids.indexOf(s);a!==-1&&n.ids.splice(a,1)}),n.ids.length===0&&(this.engine.engineStatus.hideModels=this.engine.engineStatus.hideModels.filter(s=>s!==n)))})}isolateModel(e){let t=[];this.engine.models.forEach(i=>{let n={url:i.url,ids:[]},s=e.find(a=>a.url==i.url);for(let a of i.nodesMap)s==null?n.ids.push(a[0]):s.ids.includes(a[0])||n.ids.push(a[0]);t.push(n)});debugger;this.unhighlightAllModels(),this.hideModel(t)}translucentOtherModel(e){let t=[];this.engine.models.forEach(i=>{let n={url:i.url,ids:[]},s=e.find(a=>a.url==i.url);for(let a of i.nodesMap)s==null?n.ids.push(a[0]):s.ids.includes(a[0])||n.ids.push(a[0]);t.push(n)}),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 i=new Map;t.ids.forEach(s=>{let a=this.engine.models.find(o=>o.url==t.url).nodesMap.get(s);a!=null&&a.indexes!=null&&a.indexes.forEach(o=>{const l=this.getSceneModel(o[0]);l instanceof ti?i.has(o[0])?i.get(o[0])?.push(o[1]):i.set(o[0],[o[1]]):(this.split_merge_model(this.getSceneModel(o[0])),l.geometry.groups[o[1]].materialIndex=2)})}),nU(i,this.engine);let n=this.engine.engineStatus.translucentModels.find(s=>s.url==t.url);n!=null?n.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(e=>{let t=new Map;e.ids.forEach(i=>{let n=this.engine.models.find(s=>s.url==e.url).nodesMap.get(i);n!=null&&n.indexes!=null&&n.indexes.forEach(s=>{const a=this.getSceneModel(s[0]);a instanceof ti?t.has(s[0])?t.get(s[0])?.push(s[1]):t.set(s[0],[s[1]]):(this.split_merge_model(this.getSceneModel(s[0])),a.geometry.groups[s[1]].materialIndex=0)})}),t.size>0&&fM(t,this.engine),pM(t,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],i=this.engine.modelMapperBatch.getModelMapper(t.url,t.ids[0]);this.engine.modelMapperBatch.getModelsWithLevelType(i.levelName,i.typeName,n=>{this.engine.modelToolModule.highlightModel(n)})}batchSelectSameLevelModel(e){if(e.length==0)return;let t=e[0],i=this.engine.modelMapperBatch.getModelMapper(t.url,t.ids[0]);this.engine.modelMapperBatch.getModelsWithLevel(i.levelName,n=>{this.engine.modelToolModule.highlightModel(n)})}batchSelectSameTypeModel(e){if(e.length==0)return;let t=e[0],i=this.engine.modelMapperBatch.getModelMapper(t.url,t.ids[0]);this.engine.modelMapperBatch.getModelsWithType(i.typeName,n=>{this.engine.modelToolModule.highlightModel(n)})}}function iU(r,e){r.forEach((t,i)=>{const n=Kc(e,i);if(!(n instanceof ti))return;const s=n.geometry,a=new Rt({color:43775,depthTest:!1,depthWrite:!1,transparent:!0,opacity:.5,side:Ht}),o=new ti(s,a,t.length);o.name="highlightModel",o.key=i;const l=new Map,c=new Ke,h=new Ke;h.makeScale(0,0,0),t.forEach((d,p)=>{n.getMatrixAt(d,c),l.set(d,c.clone()),n.setMatrixAt(d,h),o.setMatrixAt(p,c)}),n.instanceMatrix.needsUpdate=!0,o.instanceMatrix.needsUpdate=!0,e.scene.add(o)})}function pM(r,e,t){r.forEach((i,n)=>{const s=Kc(e,n);s instanceof ti&&(i.forEach(a=>{const o=s.matrixsClone[a];o&&s.setMatrixAt(a,o)}),s.instanceMatrix.needsUpdate=!0,e.scene.children.filter(a=>a.key==n&&a.name==t).forEach(a=>{e.scene.remove(a)}))})}function nU(r,e){r.forEach((t,i)=>{const n=Kc(e,i);if(!(n instanceof ti))return;const s=n.geometry,a=new Rt({color:16777215,transparent:!0,opacity:.05,side:Ht}),o=new ti(s,a,t.length);o.name="translucentModel",o.key=i;const l=new Map,c=new Ke,h=new Ke;h.makeScale(0,0,0),t.forEach((d,p)=>{n.getMatrixAt(d,c),l.set(d,c.clone()),n.setMatrixAt(d,h),o.setMatrixAt(p,c)}),n.instanceMatrix.needsUpdate=!0,o.instanceMatrix.needsUpdate=!0,e.scene.add(o)})}function sU(r,e){e.scene.children.filter(t=>t.name=="highlightModel").forEach(t=>{e.scene.remove(t)}),r.forEach((t,i)=>{const n=Kc(e,i);if(!(n instanceof ti))return;const s=new Map,a=new Ke,o=new Ke;o.makeScale(0,0,0),t.forEach((l,c)=>{n.getMatrixAt(l,a),s.set(l,a.clone()),n.setMatrixAt(l,o)}),n.instanceMatrix.needsUpdate=!0})}function fM(r,e){r.forEach((t,i)=>{const n=Kc(e,i);n instanceof ti&&(t.forEach(s=>{const a=n.matrixs[s];a&&n.setMatrixAt(s,a)}),n.instanceMatrix.needsUpdate=!0)})}function Kc(r,e){return r.scene.children.find(t=>t.index==e)}class rU{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(i=>i instanceof Ar);t&&(t.castShadow=e),this.engine.scene?.traverse(i=>{i.material&&(i.castShadow!==void 0&&(i.castShadow=e),i.receiveShadow!==void 0&&(i.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(n=>n instanceof Ar),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 $p{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 i=this.engine.models.find(a=>a.url==e.url);if(i==null){this.tagDiv.style.display="none";return}let n=i.nodesMap.get(e.ids[0]);if(n.infos&&n.infos.length>0){let a=n.infos[0].name.replace(/\s*\[[a-f0-9-]+\]$/,"");this.tagDiv.innerHTML=a}const s=this.engine.worldToScreen.worldToScreen(t);this.tagDiv?(this.tagDiv.style.left=s.x+10+this.engine.reactBoundingClientRect.left+"px",this.tagDiv.style.top=s.y-10+this.engine.reactBoundingClientRect.top+"px",this.tagDiv.style.display="block"):this.tagDiv&&(this.tagDiv.style.display="none")}init(){this.overlayMaterial=new Rt({color:16777215,transparent:!0,opacity:0,blending:ph,depthWrite:!1}),this.overlayMaterial.clippingPlanes=this.engine.sectionPlane}hightMesh(e,t=16777215,i=.15){this.animState==="fadeOut"&&this.removeOverlayMeshes();const n=(Array.isArray(e)?e:e?[e]:[]).filter(s=>s?.geometry);if(n.length===0){this.clearHighlight();return}this.overlayMaterial.color.set(t),this.overlayMaterial.opacity=0,this.overlayMaterial.userData.targetOpacity=i;for(const s of n){let a=s.geometry.clone();a.computeVertexNormals();const o=new Ve(a,this.overlayMaterial);s.updateWorldMatrix(!0,!1),o.matrix.copy(s.matrixWorld),o.matrixAutoUpdate=!1,this.engine.scene.add(o),this.overlayMeshes.push(o)}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 i=Math.min(e/$p.FADE_IN_MS,1);this.overlayMaterial.opacity=this.easeOutQuad(i)*t,i>=1&&(this.animState="idle")}else if(this.animState==="fadeOut"){const i=Math.min(e/$p.FADE_OUT_MS,1);this.overlayMaterial.opacity=(1-this.easeOutQuad(i))*t,i>=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 Y0={exports:{}},aU=Y0.exports,mM;function oU(){return mM||(mM=1,(function(r,e){(function(t,i){r.exports=i()})(aU,function(){var t=function(){function i(u){return a.appendChild(u.dom),u}function n(u){for(var v=0;v<a.children.length;v++)a.children[v].style.display=v===u?"block":"none";s=u}var s=0,a=document.createElement("div");a.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",a.addEventListener("click",function(u){u.preventDefault(),n(++s%a.children.length)},!1);var o=(performance||Date).now(),l=o,c=0,h=i(new t.Panel("FPS","#0ff","#002")),d=i(new t.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var p=i(new t.Panel("MB","#f08","#201"));return n(0),{REVISION:16,dom:a,addPanel:i,showPanel:n,begin:function(){o=(performance||Date).now()},end:function(){c++;var u=(performance||Date).now();if(d.update(u-o,200),u>l+1e3&&(h.update(1e3*c/(u-l),100),l=u,c=0,p)){var v=performance.memory;p.update(v.usedJSHeapSize/1048576,v.jsHeapSizeLimit/1048576)}return u},update:function(){o=this.end()},domElement:a,setMode:n}};return t.Panel=function(i,n,s){var a=1/0,o=0,l=Math.round,c=l(window.devicePixelRatio||1),h=80*c,d=48*c,p=3*c,u=2*c,v=3*c,m=15*c,g=74*c,f=30*c,y=document.createElement("canvas");y.width=h,y.height=d,y.style.cssText="width:80px;height:48px";var x=y.getContext("2d");return x.font="bold "+9*c+"px Helvetica,Arial,sans-serif",x.textBaseline="top",x.fillStyle=s,x.fillRect(0,0,h,d),x.fillStyle=n,x.fillText(i,p,u),x.fillRect(v,m,g,f),x.fillStyle=s,x.globalAlpha=.9,x.fillRect(v,m,g,f),{dom:y,update:function(_,E){a=Math.min(a,_),o=Math.max(o,_),x.fillStyle=s,x.globalAlpha=1,x.fillRect(0,0,h,m),x.fillStyle=n,x.fillText(l(_)+" "+i+" ("+l(a)+"-"+l(o)+")",p,u),x.drawImage(y,v+c,m,g-c,f,v,m,g-c,f),x.fillRect(v+g-c,m,c,f),x.fillStyle=s,x.globalAlpha=.9,x.fillRect(v+g-c,m,c,l((1-_/E)*f))}}},t})})(Y0)),Y0.exports}var lU=oU();const cU=nb(lU);var Sl=Object.freeze({Linear:Object.freeze({None:function(r){return r},In:function(r){return r},Out:function(r){return r},InOut:function(r){return r}}),Quadratic:Object.freeze({In:function(r){return r*r},Out:function(r){return r*(2-r)},InOut:function(r){return(r*=2)<1?.5*r*r:-.5*(--r*(r-2)-1)}}),Cubic:Object.freeze({In:function(r){return r*r*r},Out:function(r){return--r*r*r+1},InOut:function(r){return(r*=2)<1?.5*r*r*r:.5*((r-=2)*r*r+2)}}),Quartic:Object.freeze({In:function(r){return r*r*r*r},Out:function(r){return 1- --r*r*r*r},InOut:function(r){return(r*=2)<1?.5*r*r*r*r:-.5*((r-=2)*r*r*r-2)}}),Quintic:Object.freeze({In:function(r){return r*r*r*r*r},Out:function(r){return--r*r*r*r*r+1},InOut:function(r){return(r*=2)<1?.5*r*r*r*r*r:.5*((r-=2)*r*r*r*r+2)}}),Sinusoidal:Object.freeze({In:function(r){return 1-Math.sin((1-r)*Math.PI/2)},Out:function(r){return Math.sin(r*Math.PI/2)},InOut:function(r){return .5*(1-Math.sin(Math.PI*(.5-r)))}}),Exponential:Object.freeze({In:function(r){return r===0?0:Math.pow(1024,r-1)},Out:function(r){return r===1?1:1-Math.pow(2,-10*r)},InOut:function(r){return r===0?0:r===1?1:(r*=2)<1?.5*Math.pow(1024,r-1):.5*(-Math.pow(2,-10*(r-1))+2)}}),Circular:Object.freeze({In:function(r){return 1-Math.sqrt(1-r*r)},Out:function(r){return Math.sqrt(1- --r*r)},InOut:function(r){return(r*=2)<1?-.5*(Math.sqrt(1-r*r)-1):.5*(Math.sqrt(1-(r-=2)*r)+1)}}),Elastic:Object.freeze({In:function(r){return r===0?0:r===1?1:-Math.pow(2,10*(r-1))*Math.sin((r-1.1)*5*Math.PI)},Out:function(r){return r===0?0:r===1?1:Math.pow(2,-10*r)*Math.sin((r-.1)*5*Math.PI)+1},InOut:function(r){return r===0?0:r===1?1:(r*=2,r<1?-.5*Math.pow(2,10*(r-1))*Math.sin((r-1.1)*5*Math.PI):.5*Math.pow(2,-10*(r-1))*Math.sin((r-1.1)*5*Math.PI)+1)}}),Back:Object.freeze({In:function(r){var e=1.70158;return r===1?1:r*r*((e+1)*r-e)},Out:function(r){var e=1.70158;return r===0?0:--r*r*((e+1)*r+e)+1},InOut:function(r){var e=2.5949095;return(r*=2)<1?.5*(r*r*((e+1)*r-e)):.5*((r-=2)*r*((e+1)*r+e)+2)}}),Bounce:Object.freeze({In:function(r){return 1-Sl.Bounce.Out(1-r)},Out:function(r){return r<1/2.75?7.5625*r*r:r<2/2.75?7.5625*(r-=1.5/2.75)*r+.75:r<2.5/2.75?7.5625*(r-=2.25/2.75)*r+.9375:7.5625*(r-=2.625/2.75)*r+.984375},InOut:function(r){return r<.5?Sl.Bounce.In(r*2)*.5:Sl.Bounce.Out(r*2-1)*.5+.5}}),generatePow:function(r){return r===void 0&&(r=4),r=r<Number.EPSILON?Number.EPSILON:r,r=r>1e4?1e4:r,{In:function(e){return Math.pow(e,r)},Out:function(e){return 1-Math.pow(1-e,r)},InOut:function(e){return e<.5?Math.pow(e*2,r)/2:(1-Math.pow(2-e*2,r))/2+.5}}}}),$c=function(){return performance.now()},hU=(function(){function r(){this._tweens={},this._tweensAddedDuringUpdate={}}return r.prototype.getAll=function(){var e=this;return Object.keys(this._tweens).map(function(t){return e._tweens[t]})},r.prototype.removeAll=function(){this._tweens={}},r.prototype.add=function(e){this._tweens[e.getId()]=e,this._tweensAddedDuringUpdate[e.getId()]=e},r.prototype.remove=function(e){delete this._tweens[e.getId()],delete this._tweensAddedDuringUpdate[e.getId()]},r.prototype.update=function(e,t){e===void 0&&(e=$c()),t===void 0&&(t=!1);var i=Object.keys(this._tweens);if(i.length===0)return!1;for(;i.length>0;){this._tweensAddedDuringUpdate={};for(var n=0;n<i.length;n++){var s=this._tweens[i[n]],a=!t;s&&s.update(e,a)===!1&&!t&&delete this._tweens[i[n]]}i=Object.keys(this._tweensAddedDuringUpdate)}return!0},r})(),K0={Linear:function(r,e){var t=r.length-1,i=t*e,n=Math.floor(i),s=K0.Utils.Linear;return e<0?s(r[0],r[1],i):e>1?s(r[t],r[t-1],t-i):s(r[n],r[n+1>t?t:n+1],i-n)},Utils:{Linear:function(r,e,t){return(e-r)*t+r}}},gM=(function(){function r(){}return r.nextId=function(){return r._nextId++},r._nextId=0,r})(),$0=new hU,dU=(function(){function r(e,t){t===void 0&&(t=$0),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=Sl.Linear.None,this._interpolationFunction=K0.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=gM.nextId(),this._isChainStopped=!1,this._propertiesAreSetUp=!1,this._goToEnd=!1}return r.prototype.getId=function(){return this._id},r.prototype.isPlaying=function(){return this._isPlaying},r.prototype.isPaused=function(){return this._isPaused},r.prototype.getDuration=function(){return this._duration},r.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},r.prototype.duration=function(e){return e===void 0&&(e=1e3),this._duration=e<0?0:e,this},r.prototype.dynamic=function(e){return e===void 0&&(e=!1),this._isDynamic=e,this},r.prototype.start=function(e,t){if(e===void 0&&(e=$c()),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 i in this._valuesStartRepeat)this._swapEndStartRepeatValues(i),this._valuesStart[i]=this._valuesStartRepeat[i]}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 n={};for(var s in this._valuesEnd)n[s]=this._valuesEnd[s];this._valuesEnd=n}this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat,t)}return this},r.prototype.startFromCurrentValues=function(e){return this.start(e,!0)},r.prototype._setupProperties=function(e,t,i,n,s){for(var a in i){var o=e[a],l=Array.isArray(o),c=l?"array":typeof o,h=!l&&Array.isArray(i[a]);if(!(c==="undefined"||c==="function")){if(h){var d=i[a];if(d.length===0)continue;for(var p=[o],u=0,v=d.length;u<v;u+=1){var m=this._handleRelativeValue(o,d[u]);if(isNaN(m)){h=!1,console.warn("Found invalid interpolation list. Skipping.");break}p.push(m)}h&&(i[a]=p)}if((c==="object"||l)&&o&&!h){t[a]=l?[]:{};var g=o;for(var f in g)t[a][f]=g[f];n[a]=l?[]:{};var d=i[a];if(!this._isDynamic){var y={};for(var f in d)y[f]=d[f];i[a]=d=y}this._setupProperties(g,t[a],d,n[a],s)}else(typeof t[a]>"u"||s)&&(t[a]=o),l||(t[a]*=1),h?n[a]=i[a].slice().reverse():n[a]=t[a]||0}}},r.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},r.prototype.end=function(){return this._goToEnd=!0,this.update(1/0),this},r.prototype.pause=function(e){return e===void 0&&(e=$c()),this._isPaused||!this._isPlaying?this:(this._isPaused=!0,this._pauseStart=e,this._group&&this._group.remove(this),this)},r.prototype.resume=function(e){return e===void 0&&(e=$c()),!this._isPaused||!this._isPlaying?this:(this._isPaused=!1,this._startTime+=e-this._pauseStart,this._pauseStart=0,this._group&&this._group.add(this),this)},r.prototype.stopChainedTweens=function(){for(var e=0,t=this._chainedTweens.length;e<t;e++)this._chainedTweens[e].stop();return this},r.prototype.group=function(e){return e===void 0&&(e=$0),this._group=e,this},r.prototype.delay=function(e){return e===void 0&&(e=0),this._delayTime=e,this},r.prototype.repeat=function(e){return e===void 0&&(e=0),this._initialRepeat=e,this._repeat=e,this},r.prototype.repeatDelay=function(e){return this._repeatDelayTime=e,this},r.prototype.yoyo=function(e){return e===void 0&&(e=!1),this._yoyo=e,this},r.prototype.easing=function(e){return e===void 0&&(e=Sl.Linear.None),this._easingFunction=e,this},r.prototype.interpolation=function(e){return e===void 0&&(e=K0.Linear),this._interpolationFunction=e,this},r.prototype.chain=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return this._chainedTweens=e,this},r.prototype.onStart=function(e){return this._onStartCallback=e,this},r.prototype.onEveryStart=function(e){return this._onEveryStartCallback=e,this},r.prototype.onUpdate=function(e){return this._onUpdateCallback=e,this},r.prototype.onRepeat=function(e){return this._onRepeatCallback=e,this},r.prototype.onComplete=function(e){return this._onCompleteCallback=e,this},r.prototype.onStop=function(e){return this._onStopCallback=e,this},r.prototype.update=function(e,t){var i=this,n;if(e===void 0&&(e=$c()),t===void 0&&(t=!0),this._isPaused)return!0;var s,a=this._startTime+this._duration;if(!this._goToEnd&&!this._isPlaying){if(e>a)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 o=e-this._startTime,l=this._duration+((n=this._repeatDelayTime)!==null&&n!==void 0?n:this._delayTime),c=this._duration+this._repeat*l,h=function(){if(i._duration===0||o>c)return 1;var g=Math.trunc(o/l),f=o-g*l,y=Math.min(f/i._duration,1);return y===0&&o===i._duration?1:y},d=h(),p=this._easingFunction(d);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,p),this._onUpdateCallback&&this._onUpdateCallback(this._object,d),this._duration===0||o>=this._duration)if(this._repeat>0){var u=Math.min(Math.trunc((o-this._duration)/l)+1,this._repeat);isFinite(this._repeat)&&(this._repeat-=u);for(s in this._valuesStartRepeat)!this._yoyo&&typeof this._valuesEnd[s]=="string"&&(this._valuesStartRepeat[s]=this._valuesStartRepeat[s]+parseFloat(this._valuesEnd[s])),this._yoyo&&this._swapEndStartRepeatValues(s),this._valuesStart[s]=this._valuesStartRepeat[s];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 v=0,m=this._chainedTweens.length;v<m;v++)this._chainedTweens[v].start(this._startTime+this._duration,!1);return this._isPlaying=!1,!1}return!0},r.prototype._updateProperties=function(e,t,i,n){for(var s in i)if(t[s]!==void 0){var a=t[s]||0,o=i[s],l=Array.isArray(e[s]),c=Array.isArray(o),h=!l&&c;h?e[s]=this._interpolationFunction(o,n):typeof o=="object"&&o?this._updateProperties(e[s],a,o,n):(o=this._handleRelativeValue(a,o),typeof o=="number"&&(e[s]=a+(o-a)*n))}},r.prototype._handleRelativeValue=function(e,t){return typeof t!="string"?t:t.charAt(0)==="+"||t.charAt(0)==="-"?e+parseFloat(t):parseFloat(t)},r.prototype._swapEndStartRepeatValues=function(e){var t=this._valuesStartRepeat[e],i=this._valuesEnd[e];typeof i=="string"?this._valuesStartRepeat[e]=this._valuesStartRepeat[e]+parseFloat(i):this._valuesStartRepeat[e]=this._valuesEnd[e],this._valuesEnd[e]=t},r})();gM.nextId;var Ps=$0;Ps.getAll.bind(Ps),Ps.removeAll.bind(Ps),Ps.add.bind(Ps),Ps.remove.bind(Ps),Ps.update.bind(Ps);var Jc={Easing:Sl,Tween:dU};const vM={type:"change"},J0={type:"start"},yM={type:"end"},Jp=new br,xM=new ri,uU=Math.cos(70*Lt.DEG2RAD),Oi=new A,wn=2*Math.PI,jt={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Q0=1e-6;class pU extends Bu{constructor(e,t=null){super(e,t),this.state=jt.NONE,this.target=new A,this.cursor=new A,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:Cn.ROTATE,MIDDLE:Cn.DOLLY,RIGHT:Cn.PAN},this.touches={ONE:Tn.ROTATE,TWO:Tn.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 A,this._lastQuaternion=new Ct,this._lastTargetPosition=new A,this._quat=new Ct().setFromUnitVectors(e.up,new A(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new Go,this._sphericalDelta=new Go,this._scale=1,this._panOffset=new A,this._rotateStart=new xe,this._rotateEnd=new xe,this._rotateDelta=new xe,this._panStart=new xe,this._panEnd=new xe,this._panDelta=new xe,this._dollyStart=new xe,this._dollyEnd=new xe,this._dollyDelta=new xe,this._dollyDirection=new A,this._mouse=new xe,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=mU.bind(this),this._onPointerDown=fU.bind(this),this._onPointerUp=gU.bind(this),this._onContextMenu=SU.bind(this),this._onMouseWheel=xU.bind(this),this._onKeyDown=_U.bind(this),this._onTouchStart=bU.bind(this),this._onTouchMove=MU.bind(this),this._onMouseDown=vU.bind(this),this._onMouseMove=yU.bind(this),this._interceptControlDown=wU.bind(this),this._interceptControlUp=EU.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(vM),this.update(),this.state=jt.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;Oi.copy(t).sub(this.target),Oi.applyQuaternion(this._quat),this._spherical.setFromVector3(Oi),this.autoRotate&&this.state===jt.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 i=this.minAzimuthAngle,n=this.maxAzimuthAngle;isFinite(i)&&isFinite(n)&&(i<-Math.PI?i+=wn:i>Math.PI&&(i-=wn),n<-Math.PI?n+=wn:n>Math.PI&&(n-=wn),i<=n?this._spherical.theta=Math.max(i,Math.min(n,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(i+n)/2?Math.max(i,this._spherical.theta):Math.min(n,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 s=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const a=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),s=a!=this._spherical.radius}if(Oi.setFromSpherical(this._spherical),Oi.applyQuaternion(this._quatInverse),t.copy(this.target).add(Oi),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 a=null;if(this.object.isPerspectiveCamera){const o=Oi.length();a=this._clampDistance(o*this._scale);const l=o-a;this.object.position.addScaledVector(this._dollyDirection,l),this.object.updateMatrixWorld(),s=!!l}else if(this.object.isOrthographicCamera){const o=new A(this._mouse.x,this._mouse.y,0);o.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(),s=l!==this.object.zoom;const c=new A(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(o),this.object.updateMatrixWorld(),a=Oi.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;a!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(a).add(this.object.position):(Jp.origin.copy(this.object.position),Jp.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Jp.direction))<uU?this.object.lookAt(this.target):(xM.setFromNormalAndCoplanarPoint(this.object.up,this.target),Jp.intersectPlane(xM,this.target))))}else if(this.object.isOrthographicCamera){const a=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),a!==this.object.zoom&&(this.object.updateProjectionMatrix(),s=!0)}return this._scale=1,this._performCursorZoom=!1,s||this._lastPosition.distanceToSquared(this.object.position)>Q0||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Q0||this._lastTargetPosition.distanceToSquared(this.target)>Q0?(this.dispatchEvent(vM),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?wn/60*this.autoRotateSpeed*e:wn/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){Oi.setFromMatrixColumn(t,0),Oi.multiplyScalar(-e),this._panOffset.add(Oi)}_panUp(e,t){this.screenSpacePanning===!0?Oi.setFromMatrixColumn(t,1):(Oi.setFromMatrixColumn(t,0),Oi.crossVectors(this.object.up,Oi)),Oi.multiplyScalar(e),this._panOffset.add(Oi)}_pan(e,t){const i=this.domElement;if(this.object.isPerspectiveCamera){const n=this.object.position;Oi.copy(n).sub(this.target);let s=Oi.length();s*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*s/i.clientHeight,this.object.matrix),this._panUp(2*t*s/i.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/i.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/i.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 i=this.domElement.getBoundingClientRect(),n=e-i.left,s=t-i.top,a=i.width,o=i.height;this._mouse.x=n/a*2-1,this._mouse.y=-(s/o)*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(wn*this._rotateDelta.x/t.clientHeight),this._rotateUp(wn*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(wn*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(-wn*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(wn*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(-wn*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),i=.5*(e.pageX+t.x),n=.5*(e.pageY+t.y);this._rotateStart.set(i,n)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),n=.5*(e.pageY+t.y);this._panStart.set(i,n)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),i=e.pageX-t.x,n=e.pageY-t.y,s=Math.sqrt(i*i+n*n);this._dollyStart.set(0,s)}_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 i=this._getSecondPointerPosition(e),n=.5*(e.pageX+i.x),s=.5*(e.pageY+i.y);this._rotateEnd.set(n,s)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(wn*this._rotateDelta.x/t.clientHeight),this._rotateUp(wn*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),i=.5*(e.pageX+t.x),n=.5*(e.pageY+t.y);this._panEnd.set(i,n)}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),i=e.pageX-t.x,n=e.pageY-t.y,s=Math.sqrt(i*i+n*n);this._dollyEnd.set(0,s),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 a=(e.pageX+t.x)*.5,o=(e.pageY+t.y)*.5;this._updateZoomParameters(a,o)}_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 xe,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,i={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:i.deltaY*=16;break;case 2:i.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(i.deltaY*=10),i}}function fU(r){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(r.pointerId),this.domElement.ownerDocument.addEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(r)&&(this._addPointer(r),r.pointerType==="touch"?this._onTouchStart(r):this._onMouseDown(r),this._cursorStyle==="grab"&&(this.domElement.style.cursor="grabbing")))}function mU(r){this.enabled!==!1&&(r.pointerType==="touch"?this._onTouchMove(r):this._onMouseMove(r))}function gU(r){switch(this._removePointer(r),this._pointers.length){case 0:this.domElement.releasePointerCapture(r.pointerId),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(yM),this.state=jt.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 vU(r){let e;switch(r.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 Cn.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(r),this.state=jt.DOLLY;break;case Cn.ROTATE:if(r.ctrlKey||r.metaKey||r.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(r),this.state=jt.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(r),this.state=jt.ROTATE}break;case Cn.PAN:if(r.ctrlKey||r.metaKey||r.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(r),this.state=jt.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(r),this.state=jt.PAN}break;default:this.state=jt.NONE}this.state!==jt.NONE&&this.dispatchEvent(J0)}function yU(r){switch(this.state){case jt.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(r);break;case jt.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(r);break;case jt.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(r);break}}function xU(r){this.enabled===!1||this.enableZoom===!1||this.state!==jt.NONE||(r.preventDefault(),this.dispatchEvent(J0),this._handleMouseWheel(this._customWheelEvent(r)),this.dispatchEvent(yM))}function _U(r){this.enabled!==!1&&this._handleKeyDown(r)}function bU(r){switch(this._trackPointer(r),this._pointers.length){case 1:switch(this.touches.ONE){case Tn.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(r),this.state=jt.TOUCH_ROTATE;break;case Tn.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(r),this.state=jt.TOUCH_PAN;break;default:this.state=jt.NONE}break;case 2:switch(this.touches.TWO){case Tn.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(r),this.state=jt.TOUCH_DOLLY_PAN;break;case Tn.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(r),this.state=jt.TOUCH_DOLLY_ROTATE;break;default:this.state=jt.NONE}break;default:this.state=jt.NONE}this.state!==jt.NONE&&this.dispatchEvent(J0)}function MU(r){switch(this._trackPointer(r),this.state){case jt.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(r),this.update();break;case jt.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(r),this.update();break;case jt.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(r),this.update();break;case jt.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(r),this.update();break;default:this.state=jt.NONE}}function SU(r){this.enabled!==!1&&r.preventDefault()}function wU(r){r.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function EU(r){r.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}const Ja=new In,rn=new A,jr=new A,ai=new Ct,_M={X:new A(1,0,0),Y:new A(0,1,0),Z:new A(0,0,1)},ev={type:"change"},bM={type:"mouseDown",mode:null},MM={type:"mouseUp",mode:null},SM={type:"objectChange"};class wM extends Bu{constructor(e,t=null){super(void 0,t);const i=new LU(this);this._root=i;const n=new IU;this._gizmo=n,i.add(n);const s=new DU;this._plane=s,i.add(s);const a=this;function o(x,_){let E=_;Object.defineProperty(a,x,{get:function(){return E!==void 0?E:_},set:function(S){E!==S&&(E=S,s[x]=S,n[x]=S,a.dispatchEvent({type:x+"-changed",value:S}),a.dispatchEvent(ev))}}),a[x]=_,s[x]=_,n[x]=_}o("camera",e),o("object",void 0),o("enabled",!0),o("axis",null),o("mode","translate"),o("translationSnap",null),o("rotationSnap",null),o("scaleSnap",null),o("space","world"),o("size",1),o("dragging",!1),o("showX",!0),o("showY",!0),o("showZ",!0),o("minX",-1/0),o("maxX",1/0),o("minY",-1/0),o("maxY",1/0),o("minZ",-1/0),o("maxZ",1/0);const l=new A,c=new A,h=new Ct,d=new Ct,p=new A,u=new Ct,v=new A,m=new A,g=new A,f=0,y=new A;o("worldPosition",l),o("worldPositionStart",c),o("worldQuaternion",h),o("worldQuaternionStart",d),o("cameraPosition",p),o("cameraQuaternion",u),o("pointStart",v),o("pointEnd",m),o("rotationAxis",g),o("rotationAngle",f),o("eye",y),this._offset=new A,this._startNorm=new A,this._endNorm=new A,this._cameraScale=new A,this._parentPosition=new A,this._parentQuaternion=new Ct,this._parentQuaternionInv=new Ct,this._parentScale=new A,this._worldScaleStart=new A,this._worldQuaternionInv=new Ct,this._worldScale=new A,this._positionStart=new A,this._quaternionStart=new Ct,this._scaleStart=new A,this._getPointer=CU.bind(this),this._onPointerDown=AU.bind(this),this._onPointerHover=TU.bind(this),this._onPointerMove=PU.bind(this),this._onPointerUp=RU.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&&Ja.setFromCamera(e,this.camera);const t=tv(this._gizmo.picker[this.mode],Ja);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&&Ja.setFromCamera(e,this.camera);const t=tv(this._plane,Ja,!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,bM.mode=this.mode,this.dispatchEvent(bM)}}pointerMove(e){const t=this.axis,i=this.mode,n=this.object;let s=this.space;if(i==="scale"?s="local":(t==="E"||t==="XYZE"||t==="XYZ")&&(s="world"),n===void 0||t===null||this.dragging===!1||e!==null&&e.button!==-1)return;e!==null&&Ja.setFromCamera(e,this.camera);const a=tv(this._plane,Ja,!0);if(a){if(this.pointEnd.copy(a.point).sub(this.worldPositionStart),i==="translate")this._offset.copy(this.pointEnd).sub(this.pointStart),s==="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),s==="local"&&t!=="XYZ"?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),n.position.copy(this._offset).add(this._positionStart),this.translationSnap&&(s==="local"&&(n.position.applyQuaternion(ai.copy(this._quaternionStart).invert()),t.search("X")!==-1&&(n.position.x=Math.round(n.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(n.position.y=Math.round(n.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(n.position.z=Math.round(n.position.z/this.translationSnap)*this.translationSnap),n.position.applyQuaternion(this._quaternionStart)),s==="world"&&(n.parent&&n.position.add(rn.setFromMatrixPosition(n.parent.matrixWorld)),t.search("X")!==-1&&(n.position.x=Math.round(n.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(n.position.y=Math.round(n.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(n.position.z=Math.round(n.position.z/this.translationSnap)*this.translationSnap),n.parent&&n.position.sub(rn.setFromMatrixPosition(n.parent.matrixWorld)))),n.position.x=Math.max(this.minX,Math.min(this.maxX,n.position.x)),n.position.y=Math.max(this.minY,Math.min(this.maxY,n.position.y)),n.position.z=Math.max(this.minZ,Math.min(this.maxZ,n.position.z));else if(i==="scale"){if(t.search("XYZ")!==-1){let o=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(o*=-1),jr.set(o,o,o)}else rn.copy(this.pointStart),jr.copy(this.pointEnd),rn.applyQuaternion(this._worldQuaternionInv),jr.applyQuaternion(this._worldQuaternionInv),jr.divide(rn),t.search("X")===-1&&(jr.x=1),t.search("Y")===-1&&(jr.y=1),t.search("Z")===-1&&(jr.z=1);n.scale.copy(this._scaleStart).multiply(jr),this.scaleSnap&&(t.search("X")!==-1&&(n.scale.x=Math.round(n.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Y")!==-1&&(n.scale.y=Math.round(n.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Z")!==-1&&(n.scale.z=Math.round(n.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if(i==="rotate"){this._offset.copy(this.pointEnd).sub(this.pointStart);const o=20/this.worldPosition.distanceTo(rn.setFromMatrixPosition(this.camera.matrixWorld));let l=!1;t==="XYZE"?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(rn.copy(this.rotationAxis).cross(this.eye))*o):(t==="X"||t==="Y"||t==="Z")&&(this.rotationAxis.copy(_M[t]),rn.copy(_M[t]),s==="local"&&rn.applyQuaternion(this.worldQuaternion),rn.cross(this.eye),rn.length()===0?l=!0:this.rotationAngle=this._offset.dot(rn.normalize())*o),(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),s==="local"&&t!=="E"&&t!=="XYZE"?(n.quaternion.copy(this._quaternionStart),n.quaternion.multiply(ai.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),n.quaternion.copy(ai.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),n.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(ev),this.dispatchEvent(SM)}}pointerUp(e){e!==null&&e.button!==0||(this.dragging&&this.axis!==null&&(MM.mode=this.mode,this.dispatchEvent(MM)),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(ev),this.dispatchEvent(SM),this.pointStart.copy(this.pointEnd))}getRaycaster(){return Ja}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,i,n){const s=this._gizmo.materialLib;s.xAxis.color.set(e),s.yAxis.color.set(t),s.zAxis.color.set(i),s.active.color.set(n),s.xAxisTransparent.color.set(e),s.yAxisTransparent.color.set(t),s.zAxisTransparent.color.set(i),s.activeTransparent.color.set(n),s.xAxis._color&&s.xAxis._color.set(e),s.yAxis._color&&s.yAxis._color.set(t),s.zAxis._color&&s.zAxis._color.set(i),s.active._color&&s.active._color.set(n),s.xAxisTransparent._color&&s.xAxisTransparent._color.set(e),s.yAxisTransparent._color&&s.yAxisTransparent._color.set(t),s.zAxisTransparent._color&&s.zAxisTransparent._color.set(i),s.activeTransparent._color&&s.activeTransparent._color.set(n)}}function CU(r){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:r.button};{const e=this.domElement.getBoundingClientRect();return{x:(r.clientX-e.left)/e.width*2-1,y:-(r.clientY-e.top)/e.height*2+1,button:r.button}}}function TU(r){if(this.enabled)switch(r.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(r));break}}function AU(r){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(r.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(r)),this.pointerDown(this._getPointer(r)))}function PU(r){this.enabled&&this.pointerMove(this._getPointer(r))}function RU(r){this.enabled&&(this.domElement.releasePointerCapture(r.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(r)))}function tv(r,e,t){const i=e.intersectObject(r,!0);for(let n=0;n<i.length;n++)if(i[n].object.visible||t)return i[n];return!1}const Qp=new Pi,Kt=new A(0,1,0),EM=new A(0,0,0),CM=new Ke,ef=new Ct,tf=new Ct,Rs=new A,TM=new Ke,Qc=new A(1,0,0),Qa=new A(0,1,0),eh=new A(0,0,1),nf=new A,th=new A,ih=new A;class LU extends bt{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 IU extends bt{constructor(){super(),this.isTransformControlsGizmo=!0,this.type="TransformControlsGizmo";const e=new Rt({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),t=new ii({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),i=e.clone();i.opacity=.15;const n=t.clone();n.opacity=.5;const s=e.clone();s.color.setHex(16711680);const a=e.clone();a.color.setHex(65280);const o=e.clone();o.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 p=e.clone();p.color.setHex(16776960),p.opacity=.25;const u=e.clone();u.color.setHex(16776960);const v=e.clone();v.color.setHex(7895160),this.materialLib={xAxis:s,yAxis:a,zAxis:o,active:u,xAxisTransparent:l,yAxisTransparent:c,zAxisTransparent:h,activeTransparent:p};const m=new Li(0,.04,.1,12);m.translate(0,.05,0);const g=new ni(.08,.08,.08);g.translate(0,.04,0);const f=new ot;f.setAttribute("position",new tt([0,0,0,1,0,0],3));const y=new Li(.0075,.0075,.5,3);y.translate(0,.25,0);function x(B,F){const H=new Gs(B,.0075,3,64,F*Math.PI*2);return H.rotateY(Math.PI/2),H.rotateX(Math.PI/2),H}function _(){const B=new ot;return B.setAttribute("position",new tt([0,0,0,1,1,1],3)),B}const E={X:[[new Ve(m,s),[.5,0,0],[0,0,-Math.PI/2]],[new Ve(m,s),[-.5,0,0],[0,0,Math.PI/2]],[new Ve(y,s),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new Ve(m,a),[0,.5,0]],[new Ve(m,a),[0,-.5,0],[Math.PI,0,0]],[new Ve(y,a)]],Z:[[new Ve(m,o),[0,0,.5],[Math.PI/2,0,0]],[new Ve(m,o),[0,0,-.5],[-Math.PI/2,0,0]],[new Ve(y,o),null,[Math.PI/2,0,0]]],XYZ:[[new Ve(new Vs(.1,0),d),[0,0,0]]],XY:[[new Ve(new ni(.15,.15,.01),h),[.15,.15,0]]],YZ:[[new Ve(new ni(.15,.15,.01),l),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new Ve(new ni(.15,.15,.01),c),[.15,0,.15],[-Math.PI/2,0,0]]]},S={X:[[new Ve(new Li(.2,0,.6,4),i),[.3,0,0],[0,0,-Math.PI/2]],[new Ve(new Li(.2,0,.6,4),i),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new Ve(new Li(.2,0,.6,4),i),[0,.3,0]],[new Ve(new Li(.2,0,.6,4),i),[0,-.3,0],[0,0,Math.PI]]],Z:[[new Ve(new Li(.2,0,.6,4),i),[0,0,.3],[Math.PI/2,0,0]],[new Ve(new Li(.2,0,.6,4),i),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new Ve(new Vs(.2,0),i)]],XY:[[new Ve(new ni(.2,.2,.01),i),[.15,.15,0]]],YZ:[[new Ve(new ni(.2,.2,.01),i),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new Ve(new ni(.2,.2,.01),i),[.15,0,.15],[-Math.PI/2,0,0]]]},C={START:[[new Ve(new Vs(.01,2),n),null,null,null,"helper"]],END:[[new Ve(new Vs(.01,2),n),null,null,null,"helper"]],DELTA:[[new oi(_(),n),null,null,null,"helper"]],X:[[new oi(f,n),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new oi(f,n),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new oi(f,n),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},w={XYZE:[[new Ve(x(.5,1),v),null,[0,Math.PI/2,0]]],X:[[new Ve(x(.5,.5),s)]],Y:[[new Ve(x(.5,.5),a),null,[0,0,-Math.PI/2]]],Z:[[new Ve(x(.5,.5),o),null,[0,Math.PI/2,0]]],E:[[new Ve(x(.75,1),p),null,[0,Math.PI/2,0]]]},M={AXIS:[[new oi(f,n),[-1e3,0,0],null,[1e6,1,1],"helper"]]},R={XYZE:[[new Ve(new Er(.25,10,8),i)]],X:[[new Ve(new Gs(.5,.1,4,24),i),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new Ve(new Gs(.5,.1,4,24),i),[0,0,0],[Math.PI/2,0,0]]],Z:[[new Ve(new Gs(.5,.1,4,24),i),[0,0,0],[0,0,-Math.PI/2]]],E:[[new Ve(new Gs(.75,.1,2,24),i)]]},N={X:[[new Ve(g,s),[.5,0,0],[0,0,-Math.PI/2]],[new Ve(y,s),[0,0,0],[0,0,-Math.PI/2]],[new Ve(g,s),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new Ve(g,a),[0,.5,0]],[new Ve(y,a)],[new Ve(g,a),[0,-.5,0],[0,0,Math.PI]]],Z:[[new Ve(g,o),[0,0,.5],[Math.PI/2,0,0]],[new Ve(y,o),[0,0,0],[Math.PI/2,0,0]],[new Ve(g,o),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new Ve(new ni(.15,.15,.01),h),[.15,.15,0]]],YZ:[[new Ve(new ni(.15,.15,.01),l),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new Ve(new ni(.15,.15,.01),c),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new Ve(new ni(.1,.1,.1),d)]]},L={X:[[new Ve(new Li(.2,0,.6,4),i),[.3,0,0],[0,0,-Math.PI/2]],[new Ve(new Li(.2,0,.6,4),i),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new Ve(new Li(.2,0,.6,4),i),[0,.3,0]],[new Ve(new Li(.2,0,.6,4),i),[0,-.3,0],[0,0,Math.PI]]],Z:[[new Ve(new Li(.2,0,.6,4),i),[0,0,.3],[Math.PI/2,0,0]],[new Ve(new Li(.2,0,.6,4),i),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new Ve(new ni(.2,.2,.01),i),[.15,.15,0]]],YZ:[[new Ve(new ni(.2,.2,.01),i),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new Ve(new ni(.2,.2,.01),i),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new Ve(new ni(.2,.2,.2),i),[0,0,0]]]},O={X:[[new oi(f,n),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new oi(f,n),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new oi(f,n),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function T(B){const F=new bt;for(const H in B)for(let q=B[H].length;q--;){const V=B[H][q][0].clone(),re=B[H][q][1],Y=B[H][q][2],K=B[H][q][3],_e=B[H][q][4];V.name=H,V.tag=_e,re&&V.position.set(re[0],re[1],re[2]),Y&&V.rotation.set(Y[0],Y[1],Y[2]),K&&V.scale.set(K[0],K[1],K[2]),V.updateMatrix();const Ce=V.geometry.clone();Ce.applyMatrix4(V.matrix),V.geometry=Ce,V.renderOrder=1/0,V.position.set(0,0,0),V.rotation.set(0,0,0),V.scale.set(1,1,1),F.add(V)}return F}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=T(E)),this.add(this.gizmo.rotate=T(w)),this.add(this.gizmo.scale=T(N)),this.add(this.picker.translate=T(S)),this.add(this.picker.rotate=T(R)),this.add(this.picker.scale=T(L)),this.add(this.helper.translate=T(C)),this.add(this.helper.rotate=T(M)),this.add(this.helper.scale=T(O)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(e){const t=(this.mode==="scale"?"local":this.space)==="local"?this.worldQuaternion:tf;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 n=0;n<i.length;n++){const s=i[n];s.visible=!0,s.rotation.set(0,0,0),s.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),s.scale.set(1,1,1).multiplyScalar(a*this.size/4),s.tag==="helper"){s.visible=!1,s.name==="AXIS"?(s.visible=!!this.axis,this.axis==="X"&&(ai.setFromEuler(Qp.set(0,0,0)),s.quaternion.copy(t).multiply(ai),Math.abs(Kt.copy(Qc).applyQuaternion(t).dot(this.eye))>.9&&(s.visible=!1)),this.axis==="Y"&&(ai.setFromEuler(Qp.set(0,0,Math.PI/2)),s.quaternion.copy(t).multiply(ai),Math.abs(Kt.copy(Qa).applyQuaternion(t).dot(this.eye))>.9&&(s.visible=!1)),this.axis==="Z"&&(ai.setFromEuler(Qp.set(0,Math.PI/2,0)),s.quaternion.copy(t).multiply(ai),Math.abs(Kt.copy(eh).applyQuaternion(t).dot(this.eye))>.9&&(s.visible=!1)),this.axis==="XYZE"&&(ai.setFromEuler(Qp.set(0,Math.PI/2,0)),Kt.copy(this.rotationAxis),s.quaternion.setFromRotationMatrix(CM.lookAt(EM,Kt,Qa)),s.quaternion.multiply(ai),s.visible=this.dragging),this.axis==="E"&&(s.visible=!1)):s.name==="START"?(s.position.copy(this.worldPositionStart),s.visible=this.dragging):s.name==="END"?(s.position.copy(this.worldPosition),s.visible=this.dragging):s.name==="DELTA"?(s.position.copy(this.worldPositionStart),s.quaternion.copy(this.worldQuaternionStart),rn.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),rn.applyQuaternion(this.worldQuaternionStart.clone().invert()),s.scale.copy(rn),s.visible=this.dragging):(s.quaternion.copy(t),this.dragging?s.position.copy(this.worldPositionStart):s.position.copy(this.worldPosition),this.axis&&(s.visible=this.axis.search(s.name)!==-1));continue}s.quaternion.copy(t),this.mode==="translate"||this.mode==="scale"?(s.name==="X"&&Math.abs(Kt.copy(Qc).applyQuaternion(t).dot(this.eye))>.99&&(s.scale.set(1e-10,1e-10,1e-10),s.visible=!1),s.name==="Y"&&Math.abs(Kt.copy(Qa).applyQuaternion(t).dot(this.eye))>.99&&(s.scale.set(1e-10,1e-10,1e-10),s.visible=!1),s.name==="Z"&&Math.abs(Kt.copy(eh).applyQuaternion(t).dot(this.eye))>.99&&(s.scale.set(1e-10,1e-10,1e-10),s.visible=!1),s.name==="XY"&&Math.abs(Kt.copy(eh).applyQuaternion(t).dot(this.eye))<.2&&(s.scale.set(1e-10,1e-10,1e-10),s.visible=!1),s.name==="YZ"&&Math.abs(Kt.copy(Qc).applyQuaternion(t).dot(this.eye))<.2&&(s.scale.set(1e-10,1e-10,1e-10),s.visible=!1),s.name==="XZ"&&Math.abs(Kt.copy(Qa).applyQuaternion(t).dot(this.eye))<.2&&(s.scale.set(1e-10,1e-10,1e-10),s.visible=!1)):this.mode==="rotate"&&(ef.copy(t),Kt.copy(this.eye).applyQuaternion(ai.copy(t).invert()),s.name.search("E")!==-1&&s.quaternion.setFromRotationMatrix(CM.lookAt(this.eye,EM,Qa)),s.name==="X"&&(ai.setFromAxisAngle(Qc,Math.atan2(-Kt.y,Kt.z)),ai.multiplyQuaternions(ef,ai),s.quaternion.copy(ai)),s.name==="Y"&&(ai.setFromAxisAngle(Qa,Math.atan2(Kt.x,Kt.z)),ai.multiplyQuaternions(ef,ai),s.quaternion.copy(ai)),s.name==="Z"&&(ai.setFromAxisAngle(eh,Math.atan2(Kt.y,Kt.x)),ai.multiplyQuaternions(ef,ai),s.quaternion.copy(ai))),s.visible=s.visible&&(s.name.indexOf("X")===-1||this.showX),s.visible=s.visible&&(s.name.indexOf("Y")===-1||this.showY),s.visible=s.visible&&(s.name.indexOf("Z")===-1||this.showZ),s.visible=s.visible&&(s.name.indexOf("E")===-1||this.showX&&this.showY&&this.showZ),s.material._color=s.material._color||s.material.color.clone(),s.material._opacity=s.material._opacity||s.material.opacity,s.material.color.copy(s.material._color),s.material.opacity=s.material._opacity,this.enabled&&this.axis&&(s.name===this.axis?(s.material.color.copy(this.materialLib.active.color),s.material.opacity=1):this.axis.split("").some(function(o){return s.name===o})&&(s.material.color.copy(this.materialLib.active.color),s.material.opacity=1))}super.updateMatrixWorld(e)}}class DU extends Ve{constructor(){super(new Wn(1e5,1e5,2,2),new Rt({visible:!1,wireframe:!0,side:Ht,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"),nf.copy(Qc).applyQuaternion(t==="local"?this.worldQuaternion:tf),th.copy(Qa).applyQuaternion(t==="local"?this.worldQuaternion:tf),ih.copy(eh).applyQuaternion(t==="local"?this.worldQuaternion:tf),Kt.copy(th),this.mode){case"translate":case"scale":switch(this.axis){case"X":Kt.copy(this.eye).cross(nf),Rs.copy(nf).cross(Kt);break;case"Y":Kt.copy(this.eye).cross(th),Rs.copy(th).cross(Kt);break;case"Z":Kt.copy(this.eye).cross(ih),Rs.copy(ih).cross(Kt);break;case"XY":Rs.copy(ih);break;case"YZ":Rs.copy(nf);break;case"XZ":Kt.copy(ih),Rs.copy(th);break;case"XYZ":case"E":Rs.set(0,0,0);break}break;default:Rs.set(0,0,0)}Rs.length()===0?this.quaternion.copy(this.cameraQuaternion):(TM.lookAt(rn.set(0,0,0),Rs,Kt),this.quaternion.setFromRotationMatrix(TM)),super.updateMatrixWorld(e)}}class NU extends gy{constructor(e){super(e),this.type=xi}parse(e){const t=function(g,f){switch(g){case 1:throw new Error("THREE.HDRLoader: Read Error: "+(f||""));case 2:throw new Error("THREE.HDRLoader: Write Error: "+(f||""));case 3:throw new Error("THREE.HDRLoader: Bad File Format: "+(f||""));default:case 4:throw new Error("THREE.HDRLoader: Memory Error: "+(f||""))}},i=function(g,f,y){f=f||1024;let x=g.pos,_=-1,E=0,S="",C=String.fromCharCode.apply(null,new Uint16Array(g.subarray(x,x+128)));for(;0>(_=C.indexOf(`
|
|
8989
|
+
`);this.workerSourceURL=URL.createObjectURL(new Blob([a]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){const n=new Worker(this.workerSourceURL);n._callbacks={},n._taskCosts={},n._taskLoad=0,n.postMessage({type:"init",decoderConfig:this.decoderConfig}),n.onmessage=function(s){const a=s.data;switch(a.type){case"decode":n._callbacks[a.id].resolve(a);break;case"error":n._callbacks[a.id].reject(a);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+a.type+'"')}},this.workerPool.push(n)}else this.workerPool.sort(function(n,s){return n._taskLoad>s._taskLoad?-1:1});const i=this.workerPool[this.workerPool.length-1];return i._taskCosts[e]=t,i._taskLoad+=t,i})}_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 kN(){let r,e;onmessage=function(a){const o=a.data;switch(o.type){case"init":r=o.decoderConfig,e=new Promise(function(h){r.onModuleLoaded=function(d){h({draco:d})},DracoDecoderModule(r)});break;case"decode":const l=o.buffer,c=o.taskConfig;e.then(h=>{const d=h.draco,p=new d.Decoder;try{const u=t(d,p,new Int8Array(l),c),v=u.attributes.map(m=>m.array.buffer);u.index&&v.push(u.index.array.buffer),self.postMessage({type:"decode",id:o.id,geometry:u},v)}catch(u){console.error(u),self.postMessage({type:"error",id:o.id,error:u.message})}finally{d.destroy(p)}});break}};function t(a,o,l,c){const h=c.attributeIDs,d=c.attributeTypes;let p,u;const v=o.GetEncodedGeometryType(l);if(v===a.TRIANGULAR_MESH)p=new a.Mesh,u=o.DecodeArrayToMesh(l,l.byteLength,p);else if(v===a.POINT_CLOUD)p=new a.PointCloud,u=o.DecodeArrayToPointCloud(l,l.byteLength,p);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!u.ok()||p.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+u.error_msg());const m={index:null,attributes:[]};for(const g in h){const f=self[d[g]];let y,x;if(c.useUniqueIDs)x=h[g],y=o.GetAttributeByUniqueId(p,x);else{if(x=o.GetAttributeId(p,a[h[g]]),x===-1)continue;y=o.GetAttribute(p,x)}const _=n(a,o,p,g,f,y);g==="color"&&(_.vertexColorSpace=c.vertexColorSpace),m.attributes.push(_)}return v===a.TRIANGULAR_MESH&&(m.index=i(a,o,p)),a.destroy(p),m}function i(a,o,l){const c=l.num_faces()*3,h=c*4,d=a._malloc(h);o.GetTrianglesUInt32Array(l,h,d);const p=new Uint32Array(a.HEAPF32.buffer,d,c).slice();return a._free(d),{array:p,itemSize:1}}function n(a,o,l,c,h,d){const p=l.num_points(),u=d.num_components(),v=s(a,h),m=u*h.BYTES_PER_ELEMENT,g=Math.ceil(m/4)*4,f=g/h.BYTES_PER_ELEMENT,y=p*m,x=p*g,_=a._malloc(y);o.GetAttributeDataArrayForAllPoints(l,d,v,y,_);const E=new h(a.HEAPF32.buffer,_,y/h.BYTES_PER_ELEMENT);let S;if(m===g)S=E.slice();else{S=new h(x/h.BYTES_PER_ELEMENT);let C=0;for(let w=0,M=E.length;w<M;w++){for(let R=0;R<u;R++)S[C+R]=E[w*u+R];C+=f}}return a._free(_),{name:c,count:p,itemSize:u,array:S,stride:f}}function s(a,o){switch(o){case Float32Array:return a.DT_FLOAT32;case Int8Array:return a.DT_INT8;case Int16Array:return a.DT_INT16;case Int32Array:return a.DT_INT32;case Uint8Array:return a.DT_UINT8;case Uint16Array:return a.DT_UINT16;case Uint32Array:return a.DT_UINT32}}}function ON(r,e,t,i){let n=0,s=0,a=0,o=r.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,p=r.scene;if(new Rt,new ot,l&&l.length){let u=[],v=0;for(let m of l)m.color=m.color.split(",").map(g=>parseInt(g)/255),m.color=new Xe(m.color[0],m.color[1],m.color[2]),m.position={x:m.startPoint.X*.3048+n,y:m.startPoint.Z*.3048+s,z:-m.startPoint.Y*.3048+a},m.rotation={x:0,y:0,z:0},m.indexes=[[r.scene.children.length,v++,0,0]],o.nodesMap.set(Number(m.id),m),u.push(m);Zp("Circle",p,u,t)}if(c&&c.length){let u=[],v=0;for(let m of c)m.color=m.color.split(",").map(g=>parseInt(g)/255),m.color=new Xe(m.color[0],m.color[1],m.color[2]),m.position={x:m.startPoint.X*.3048+n,y:m.startPoint.Z*.3048+s,z:-m.startPoint.Y*.3048+a},m.rotation={x:0,y:0,z:0},m.indexes=[[r.scene.children.length,v++,0,0]],o.nodesMap.set(Number(m.id),m),u.push(m);Zp("Rect",p,u,t)}if(d&&d.length){let u=[],v=0;for(let m of d)m.color=m.color.split(",").map(g=>parseInt(g)/255),m.color=new Xe(m.color[0],m.color[1],m.color[2]),m.position={x:m.startPoint.X*.3048+n,y:m.startPoint.Z*.3048+s,z:-m.startPoint.Y*.3048+a},m.rotation={x:0,y:0,z:0},m.indexes=[[r.scene.children.length,v++,0,0]],o.nodesMap.set(Number(m.id),m),u.push(m);Zp("Ellipse",p,u,t)}if(h&&h.length){let u=[],v=0;for(let m of h)m.color=m.color.split(",").map(g=>parseInt(g)/255),m.color=new Xe(m.color[0],m.color[1],m.color[2]),m.position={x:m.startPoint.X*.3048+n,y:m.startPoint.Z*.3048+s,z:-m.startPoint.Y*.3048+a},m.rotation={x:0,y:0,z:0},m.indexes=[[r.scene.children.length,v++,0,0]],o.nodesMap.set(Number(m.id),m),u.push(m);Zp("Bridge",p,u,t)}}function Zp(r,e,t,i,n){let s,a,o={width:1,height:1,length:1,diameter:1,color:new Xe,position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0}};switch(r){case"Rect":a=Yp("Rect",o);break;case"Bridge":a=Yp("Bridge",o);break;case"Circle":a=Yp("Circle",o);break;case"Ellipse":a=Yp("Ellipse",o);break}a&&(s=new ti(a.geometry,a.material,t.length),s.url=i,e.add(s),s.index=e.children.length-1);let l=[],c=[];for(var h=0;h<t.length;h++){let u=t[h],v=new A(u.startPoint.X,0,-u.startPoint.Y),m=new A(u.endPoint.X,0,-u.endPoint.Y),g=new A(u.startPoint.X,u.startPoint.Z,-u.startPoint.Y),f=new A(u.endPoint.X,u.endPoint.Z,-u.endPoint.Y),y=0,x=0,_=0;if(Math.abs(m.clone().sub(v.clone()).z)<.01&&Math.abs(m.clone().sub(v.clone()).x)<.01){if(y=(u.startPoint.Z>u.endPoint.Z?1:-1)*Math.PI*.5,u.base_x!=null){var d=new A(u.base_x.X,0,-u.base_x.Y);x=(d.clone().cross(new A(0,0,1)).y<=0?1:-1)*d.angleTo(new A(0,0,1))+Math.PI*.5}}else x=(m.clone().sub(v.clone()).cross(new A(0,0,1)).y>0?-1:1)*m.clone().sub(v.clone()).angleTo(new A(0,0,1)),y=(u.startPoint.Z>u.endPoint.Z?1:-1)*m.clone().sub(v.clone()).angleTo(f.clone().sub(g.clone()));let E=new Ke;const S=new Pi(y,x,_,"YXZ");let C=E.clone().makeRotationFromEuler(S),w,M;r==="Circle"?(w=u.diameter,M=u.diameter):(w=u.width,M=u.height);let R=E.clone().makeScale(w,M,u.length);E.multiplyMatrices(C,R),E.setPosition(u.position.x,u.position.y,u.position.z),s.setMatrixAt(h,E.clone()),s.setColorAt(h,u.color),s.geometry.computeBoundingBox();let N=s.geometry.boundingBox.min.clone().applyMatrix4(E.clone()),L=s.geometry.boundingBox.max.clone().applyMatrix4(E.clone()),O=new A(Math.min(N.x,L.x),Math.min(N.y,L.y),Math.min(N.z,L.z)),T=new A(Math.max(N.x,L.x),Math.max(N.y,L.y),Math.max(N.z,L.z)),B=O.clone().add(T.clone()).multiplyScalar(.5),F={name:u.name,min:O,max:T,center:B,dbid:h,materialName:a.material.name},H=null,q=null;r==="Circle"&&(H={x:u.startPoint.X*.3048,y:u.startPoint.Z*.3048,z:-u.startPoint.Y*.3048},q={x:u.endPoint.X*.3048,y:u.endPoint.Z*.3048,z:-u.endPoint.Y*.3048},F.minC=H,F.maxC=q),s.ids||(s.ids=[]),s.matrixs||(s.matrixs=[]),s.matrixs.push(E.clone()),c.push(E.clone()),s.ids.push(Number(u.id)),l.push(F)}s.castShadow=!0,s.ElementInfos=l,s.name="rootModel",s.TypeName="InstancedMesh-Pipe",s.PipeType=r,s.MeshId=null,s.realMaterial=s.material.clone(),s.originalMaterial=s.material.clone(),s.matrixsClone=c;let p=[];p={geometry:s.geometry,matrix:s.matrix,position:s.position,rotation:s.rotation},s.meshs=p,s.instanceMatrix&&s.instanceMatrix.array&&(s.cloneInstanceMatrix=Array.from(s.instanceMatrix.array))}function Yp(r,e,t){let i=new Hs;switch(e.width=e.width*.3048,e.height=e.height*.3048,e.diameter=e.diameter*.3048,r){case"Rect":i.moveTo(-e.width/2,-e.height/2),i.lineTo(-e.width/2,e.height/2),i.lineTo(e.width/2,e.height/2),i.lineTo(e.width/2,-e.height/2),i.lineTo(-e.width/2,-e.height/2);break;case"Ellipse":i.moveTo(-e.width/2,-e.height/2),i.lineTo(-e.width/2,e.height/2),i.lineTo(e.width/2,e.height/2),i.lineTo(e.width/2,-e.height/2),i.lineTo(-e.width/2,-e.height/2);break;case"Bridge":i.moveTo(-e.width/2,-e.height/2),i.lineTo(-e.width/2,e.height/2),i.lineTo(-e.width/2+.01,e.height/2),i.lineTo(-e.width/2+.01,-e.height/2+.01),i.lineTo(e.width/2-.01,-e.height/2+.01),i.lineTo(e.width/2-.01,e.height/2),i.lineTo(e.width/2,e.height/2),i.lineTo(e.width/2,-e.height/2),i.lineTo(-e.width/2,-e.height/2);break;case"Circle":i.moveTo(0,0),i.absarc(0,0,e.diameter*.5,0,Math.PI*2,!1);break}const n={depth:e.length*.3048,bevelEnabled:!1};return s(i,n,e.color,e.position,e.rotation);function s(a,o,l,c,h){let d=new ko(a,o),p=new pa({color:l,side:Ht}),u=new Ve(d,p);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 Ka(r,e=!1){const t=r[0].index!==null,i=new Set(Object.keys(r[0].attributes)),n=new Set(Object.keys(r[0].morphAttributes)),s={},a={},o=r[0].morphTargetsRelative,l=new ot;let c=0;for(let h=0;h<r.length;++h){const d=r[h];let p=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(!i.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;s[u]===void 0&&(s[u]=[]),s[u].push(d.attributes[u]),p++}if(p!==i.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(o!==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(!n.has(u))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". .morphAttributes must be consistent throughout all geometries."),null;a[u]===void 0&&(a[u]=[]),a[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 p=0;p<r.length;++p){const u=r[p].index;for(let v=0;v<u.count;++v)d.push(u.getX(v)+h);h+=r[p].attributes.position.count}l.setIndex(d)}for(const h in s){const d=jb(s[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 a){const d=a[h][0].length;if(d===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[h]=[];for(let p=0;p<d;++p){const u=[];for(let m=0;m<a[h].length;++m)u.push(a[h][m][p]);const v=jb(u);if(!v)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+h+" morphAttribute."),null;l.morphAttributes[h].push(v)}}return l}function jb(r){let e,t,i,n=-1,s=0;for(let c=0;c<r.length;++c){const h=r[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(i===void 0&&(i=h.normalized),i!==h.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(n===-1&&(n=h.gpuType),n!==h.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;s+=h.count*t}const a=new e(s),o=new wt(a,t,i);let l=0;for(let c=0;c<r.length;++c){const h=r[c];if(h.isInterleavedBufferAttribute){const d=l/t;for(let p=0,u=h.count;p<u;p++)for(let v=0;v<t;v++){const m=h.getComponent(p,v);o.setComponent(p+d,v,m)}}else a.set(h.array,l);l+=h.count*t}return n!==void 0&&(o.gpuType=n),o}function qb(r,e){if(e===Fv)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),r;if(e===vd||e===Mf){let t=r.getIndex();if(t===null){const a=[],o=r.getAttribute("position");if(o!==void 0){for(let l=0;l<o.count;l++)a.push(l);r.setIndex(a),t=r.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),r}const i=t.count-2,n=[];if(e===vd)for(let a=1;a<=i;a++)n.push(t.getX(0)),n.push(t.getX(a)),n.push(t.getX(a+1));else for(let a=0;a<i;a++)a%2===0?(n.push(t.getX(a)),n.push(t.getX(a+1)),n.push(t.getX(a+2))):(n.push(t.getX(a+2)),n.push(t.getX(a+1)),n.push(t.getX(a)));n.length/3!==i&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const s=r.clone();return s.setIndex(n),s.clearGroups(),s}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),r}function BN(r){const e=new Map,t=new Map,i=r.clone();return Zb(r,i,function(n,s){e.set(s,n),t.set(n,s)}),i.traverse(function(n){if(!n.isSkinnedMesh)return;const s=n,a=e.get(n),o=a.skeleton.bones;s.skeleton=a.skeleton.clone(),s.bindMatrix.copy(a.bindMatrix),s.skeleton.bones=o.map(function(l){return t.get(l)}),s.bind(s.skeleton,s.bindMatrix)}),i}function Zb(r,e,t){t(r,e);for(let i=0;i<r.children.length;i++)Zb(r.children[i],e.children[i],t)}class FN extends qi{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new WN(t)}),this.register(function(t){return new XN(t)}),this.register(function(t){return new e8(t)}),this.register(function(t){return new t8(t)}),this.register(function(t){return new i8(t)}),this.register(function(t){return new qN(t)}),this.register(function(t){return new ZN(t)}),this.register(function(t){return new YN(t)}),this.register(function(t){return new KN(t)}),this.register(function(t){return new GN(t)}),this.register(function(t){return new $N(t)}),this.register(function(t){return new jN(t)}),this.register(function(t){return new QN(t)}),this.register(function(t){return new JN(t)}),this.register(function(t){return new HN(t)}),this.register(function(t){return new Yb(t,Et.EXT_MESHOPT_COMPRESSION)}),this.register(function(t){return new Yb(t,Et.KHR_MESHOPT_COMPRESSION)}),this.register(function(t){return new n8(t)})}load(e,t,i,n){const s=this;let a;if(this.resourcePath!=="")a=this.resourcePath;else if(this.path!==""){const c=Pr.extractUrlBase(e);a=Pr.resolveURL(c,this.path)}else a=Pr.extractUrlBase(e);this.manager.itemStart(e);const o=function(c){n?n(c):console.error(c),s.manager.itemError(e),s.manager.itemEnd(e)},l=new yn(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(this.withCredentials),l.load(e,function(c){try{s.parse(c,a,function(h){t(h),s.manager.itemEnd(e)},o)}catch(h){o(h)}},i,o)}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,i,n){let s;const a={},o={},l=new TextDecoder;if(typeof e=="string")s=JSON.parse(e);else if(e instanceof ArrayBuffer)if(l.decode(new Uint8Array(e,0,4))===Kb){try{a[Et.KHR_BINARY_GLTF]=new s8(e)}catch(h){n&&n(h);return}s=JSON.parse(a[Et.KHR_BINARY_GLTF].content)}else s=JSON.parse(l.decode(e));else s=e;if(s.asset===void 0||s.asset.version[0]<2){n&&n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const c=new v8(s,{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"),o[d.name]=d,a[d.name]=!0}if(s.extensionsUsed)for(let h=0;h<s.extensionsUsed.length;++h){const d=s.extensionsUsed[h],p=s.extensionsRequired||[];switch(d){case Et.KHR_MATERIALS_UNLIT:a[d]=new VN;break;case Et.KHR_DRACO_MESH_COMPRESSION:a[d]=new r8(s,this.dracoLoader);break;case Et.KHR_TEXTURE_TRANSFORM:a[d]=new a8;break;case Et.KHR_MESH_QUANTIZATION:a[d]=new o8;break;default:p.indexOf(d)>=0&&o[d]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+d+'".')}}c.setExtensions(a),c.setPlugins(o),c.parse(i,n)}parseAsync(e,t){const i=this;return new Promise(function(n,s){i.parse(e,t,n,s)})}}function zN(){let r={};return{get:function(e){return r[e]},add:function(e,t){r[e]=t},remove:function(e){delete r[e]},removeAll:function(){r={}}}}function yi(r,e,t){const i=r.json.materials[e];return i.extensions&&i.extensions[t]?i.extensions[t]:null}const Et={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 HN{constructor(e){this.parser=e,this.name=Et.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let i=0,n=t.length;i<n;i++){const s=t[i];s.extensions&&s.extensions[this.name]&&s.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,s.extensions[this.name].light)}}_loadLight(e){const t=this.parser,i="light:"+e;let n=t.cache.get(i);if(n)return n;const s=t.json,a=((s.extensions&&s.extensions[this.name]||{}).lights||[])[e];let o;const l=new Xe(16777215);a.color!==void 0&&l.setRGB(a.color[0],a.color[1],a.color[2],Fi);const c=a.range!==void 0?a.range:0;switch(a.type){case"directional":o=new Ar(l),o.target.position.set(0,0,-1),o.add(o.target);break;case"point":o=new Pm(l),o.distance=c;break;case"spot":o=new Am(l),o.distance=c,a.spot=a.spot||{},a.spot.innerConeAngle=a.spot.innerConeAngle!==void 0?a.spot.innerConeAngle:0,a.spot.outerConeAngle=a.spot.outerConeAngle!==void 0?a.spot.outerConeAngle:Math.PI/4,o.angle=a.spot.outerConeAngle,o.penumbra=1-a.spot.innerConeAngle/a.spot.outerConeAngle,o.target.position.set(0,0,-1),o.add(o.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+a.type)}return o.position.set(0,0,0),As(o,a),a.intensity!==void 0&&(o.intensity=a.intensity),o.name=t.createUniqueName(a.name||"light_"+e),n=Promise.resolve(o),t.cache.add(i,n),n}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,i=this.parser,n=i.json.nodes[e],s=(n.extensions&&n.extensions[this.name]||{}).light;return s===void 0?null:this._loadLight(s).then(function(a){return i._getNodeRef(t.cache,s,a)})}}class VN{constructor(){this.name=Et.KHR_MATERIALS_UNLIT}getMaterialType(){return Rt}extendParams(e,t,i){const n=[];e.color=new Xe(1,1,1),e.opacity=1;const s=t.pbrMetallicRoughness;if(s){if(Array.isArray(s.baseColorFactor)){const a=s.baseColorFactor;e.color.setRGB(a[0],a[1],a[2],Fi),e.opacity=a[3]}s.baseColorTexture!==void 0&&n.push(i.assignTexture(e,"map",s.baseColorTexture,Qt))}return Promise.all(n)}}class GN{constructor(e){this.parser=e,this.name=Et.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const i=yi(this.parser,e,this.name);return i===null||i.emissiveStrength!==void 0&&(t.emissiveIntensity=i.emissiveStrength),Promise.resolve()}}class WN{constructor(e){this.parser=e,this.name=Et.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){return yi(this.parser,e,this.name)!==null?Xn:null}extendMaterialParams(e,t){const i=yi(this.parser,e,this.name);if(i===null)return Promise.resolve();const n=[];if(i.clearcoatFactor!==void 0&&(t.clearcoat=i.clearcoatFactor),i.clearcoatTexture!==void 0&&n.push(this.parser.assignTexture(t,"clearcoatMap",i.clearcoatTexture)),i.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=i.clearcoatRoughnessFactor),i.clearcoatRoughnessTexture!==void 0&&n.push(this.parser.assignTexture(t,"clearcoatRoughnessMap",i.clearcoatRoughnessTexture)),i.clearcoatNormalTexture!==void 0&&(n.push(this.parser.assignTexture(t,"clearcoatNormalMap",i.clearcoatNormalTexture)),i.clearcoatNormalTexture.scale!==void 0)){const s=i.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new xe(s,s)}return Promise.all(n)}}class XN{constructor(e){this.parser=e,this.name=Et.KHR_MATERIALS_DISPERSION}getMaterialType(e){return yi(this.parser,e,this.name)!==null?Xn:null}extendMaterialParams(e,t){const i=yi(this.parser,e,this.name);return i===null||(t.dispersion=i.dispersion!==void 0?i.dispersion:0),Promise.resolve()}}class jN{constructor(e){this.parser=e,this.name=Et.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){return yi(this.parser,e,this.name)!==null?Xn:null}extendMaterialParams(e,t){const i=yi(this.parser,e,this.name);if(i===null)return Promise.resolve();const n=[];return i.iridescenceFactor!==void 0&&(t.iridescence=i.iridescenceFactor),i.iridescenceTexture!==void 0&&n.push(this.parser.assignTexture(t,"iridescenceMap",i.iridescenceTexture)),i.iridescenceIor!==void 0&&(t.iridescenceIOR=i.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),i.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=i.iridescenceThicknessMinimum),i.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=i.iridescenceThicknessMaximum),i.iridescenceThicknessTexture!==void 0&&n.push(this.parser.assignTexture(t,"iridescenceThicknessMap",i.iridescenceThicknessTexture)),Promise.all(n)}}class qN{constructor(e){this.parser=e,this.name=Et.KHR_MATERIALS_SHEEN}getMaterialType(e){return yi(this.parser,e,this.name)!==null?Xn:null}extendMaterialParams(e,t){const i=yi(this.parser,e,this.name);if(i===null)return Promise.resolve();const n=[];if(t.sheenColor=new Xe(0,0,0),t.sheenRoughness=0,t.sheen=1,i.sheenColorFactor!==void 0){const s=i.sheenColorFactor;t.sheenColor.setRGB(s[0],s[1],s[2],Fi)}return i.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=i.sheenRoughnessFactor),i.sheenColorTexture!==void 0&&n.push(this.parser.assignTexture(t,"sheenColorMap",i.sheenColorTexture,Qt)),i.sheenRoughnessTexture!==void 0&&n.push(this.parser.assignTexture(t,"sheenRoughnessMap",i.sheenRoughnessTexture)),Promise.all(n)}}class ZN{constructor(e){this.parser=e,this.name=Et.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){return yi(this.parser,e,this.name)!==null?Xn:null}extendMaterialParams(e,t){const i=yi(this.parser,e,this.name);if(i===null)return Promise.resolve();const n=[];return i.transmissionFactor!==void 0&&(t.transmission=i.transmissionFactor),i.transmissionTexture!==void 0&&n.push(this.parser.assignTexture(t,"transmissionMap",i.transmissionTexture)),Promise.all(n)}}class YN{constructor(e){this.parser=e,this.name=Et.KHR_MATERIALS_VOLUME}getMaterialType(e){return yi(this.parser,e,this.name)!==null?Xn:null}extendMaterialParams(e,t){const i=yi(this.parser,e,this.name);if(i===null)return Promise.resolve();const n=[];t.thickness=i.thicknessFactor!==void 0?i.thicknessFactor:0,i.thicknessTexture!==void 0&&n.push(this.parser.assignTexture(t,"thicknessMap",i.thicknessTexture)),t.attenuationDistance=i.attenuationDistance||1/0;const s=i.attenuationColor||[1,1,1];return t.attenuationColor=new Xe().setRGB(s[0],s[1],s[2],Fi),Promise.all(n)}}class KN{constructor(e){this.parser=e,this.name=Et.KHR_MATERIALS_IOR}getMaterialType(e){return yi(this.parser,e,this.name)!==null?Xn:null}extendMaterialParams(e,t){const i=yi(this.parser,e,this.name);return i===null||(t.ior=i.ior!==void 0?i.ior:1.5),Promise.resolve()}}class $N{constructor(e){this.parser=e,this.name=Et.KHR_MATERIALS_SPECULAR}getMaterialType(e){return yi(this.parser,e,this.name)!==null?Xn:null}extendMaterialParams(e,t){const i=yi(this.parser,e,this.name);if(i===null)return Promise.resolve();const n=[];t.specularIntensity=i.specularFactor!==void 0?i.specularFactor:1,i.specularTexture!==void 0&&n.push(this.parser.assignTexture(t,"specularIntensityMap",i.specularTexture));const s=i.specularColorFactor||[1,1,1];return t.specularColor=new Xe().setRGB(s[0],s[1],s[2],Fi),i.specularColorTexture!==void 0&&n.push(this.parser.assignTexture(t,"specularColorMap",i.specularColorTexture,Qt)),Promise.all(n)}}class JN{constructor(e){this.parser=e,this.name=Et.EXT_MATERIALS_BUMP}getMaterialType(e){return yi(this.parser,e,this.name)!==null?Xn:null}extendMaterialParams(e,t){const i=yi(this.parser,e,this.name);if(i===null)return Promise.resolve();const n=[];return t.bumpScale=i.bumpFactor!==void 0?i.bumpFactor:1,i.bumpTexture!==void 0&&n.push(this.parser.assignTexture(t,"bumpMap",i.bumpTexture)),Promise.all(n)}}class QN{constructor(e){this.parser=e,this.name=Et.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){return yi(this.parser,e,this.name)!==null?Xn:null}extendMaterialParams(e,t){const i=yi(this.parser,e,this.name);if(i===null)return Promise.resolve();const n=[];return i.anisotropyStrength!==void 0&&(t.anisotropy=i.anisotropyStrength),i.anisotropyRotation!==void 0&&(t.anisotropyRotation=i.anisotropyRotation),i.anisotropyTexture!==void 0&&n.push(this.parser.assignTexture(t,"anisotropyMap",i.anisotropyTexture)),Promise.all(n)}}class e8{constructor(e){this.parser=e,this.name=Et.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,i=t.json,n=i.textures[e];if(!n.extensions||!n.extensions[this.name])return null;const s=n.extensions[this.name],a=t.options.ktx2Loader;if(!a){if(i.extensionsRequired&&i.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,s.source,a)}}class t8{constructor(e){this.parser=e,this.name=Et.EXT_TEXTURE_WEBP}loadTexture(e){const t=this.name,i=this.parser,n=i.json,s=n.textures[e];if(!s.extensions||!s.extensions[t])return null;const a=s.extensions[t],o=n.images[a.source];let l=i.textureLoader;if(o.uri){const c=i.options.manager.getHandler(o.uri);c!==null&&(l=c)}return i.loadTextureImage(e,a.source,l)}}class i8{constructor(e){this.parser=e,this.name=Et.EXT_TEXTURE_AVIF}loadTexture(e){const t=this.name,i=this.parser,n=i.json,s=n.textures[e];if(!s.extensions||!s.extensions[t])return null;const a=s.extensions[t],o=n.images[a.source];let l=i.textureLoader;if(o.uri){const c=i.options.manager.getHandler(o.uri);c!==null&&(l=c)}return i.loadTextureImage(e,a.source,l)}}class Yb{constructor(e,t){this.name=t,this.parser=e}loadBufferView(e){const t=this.parser.json,i=t.bufferViews[e];if(i.extensions&&i.extensions[this.name]){const n=i.extensions[this.name],s=this.parser.getDependency("buffer",n.buffer),a=this.parser.options.meshoptDecoder;if(!a||!a.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 s.then(function(o){const l=n.byteOffset||0,c=n.byteLength||0,h=n.count,d=n.byteStride,p=new Uint8Array(o,l,c);return a.decodeGltfBufferAsync?a.decodeGltfBufferAsync(h,d,p,n.mode,n.filter).then(function(u){return u.buffer}):a.ready.then(function(){const u=new ArrayBuffer(h*d);return a.decodeGltfBuffer(new Uint8Array(u),h,d,p,n.mode,n.filter),u})})}else return null}}class n8{constructor(e){this.name=Et.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,i=t.nodes[e];if(!i.extensions||!i.extensions[this.name]||i.mesh===void 0)return null;const n=t.meshes[i.mesh];for(const l of n.primitives)if(l.mode!==Kn.TRIANGLES&&l.mode!==Kn.TRIANGLE_STRIP&&l.mode!==Kn.TRIANGLE_FAN&&l.mode!==void 0)return null;const s=i.extensions[this.name].attributes,a=[],o={};for(const l in s)a.push(this.parser.getDependency("accessor",s[l]).then(c=>(o[l]=c,o[l])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(l=>{const c=l.pop(),h=c.isGroup?c.children:[c],d=l[0].count,p=[];for(const u of h){const v=new Ke,m=new A,g=new Ct,f=new A(1,1,1),y=new ti(u.geometry,u.material,d);for(let x=0;x<d;x++)o.TRANSLATION&&m.fromBufferAttribute(o.TRANSLATION,x),o.ROTATION&&g.fromBufferAttribute(o.ROTATION,x),o.SCALE&&f.fromBufferAttribute(o.SCALE,x),y.setMatrixAt(x,v.compose(m,g,f));for(const x in o)if(x==="_COLOR_0"){const _=o[x];y.instanceColor=new Mr(_.array,_.itemSize,_.normalized)}else x!=="TRANSLATION"&&x!=="ROTATION"&&x!=="SCALE"&&u.geometry.setAttribute(x,o[x]);bt.prototype.copy.call(y,u),this.parser.assignFinalMaterial(y),p.push(y)}return c.isGroup?(c.clear(),c.add(...p),c):p[0]}))}}const Kb="glTF",Zc=12,$b={JSON:1313821514,BIN:5130562};class s8{constructor(e){this.name=Et.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,Zc),i=new TextDecoder;if(this.header={magic:i.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==Kb)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const n=this.header.length-Zc,s=new DataView(e,Zc);let a=0;for(;a<n;){const o=s.getUint32(a,!0);a+=4;const l=s.getUint32(a,!0);if(a+=4,l===$b.JSON){const c=new Uint8Array(e,Zc+a,o);this.content=i.decode(c)}else if(l===$b.BIN){const c=Zc+a;this.body=e.slice(c,c+o)}a+=o}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class r8{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=Et.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const i=this.json,n=this.dracoLoader,s=e.extensions[this.name].bufferView,a=e.extensions[this.name].attributes,o={},l={},c={};for(const h in a){const d=W0[h]||h.toLowerCase();o[d]=a[h]}for(const h in e.attributes){const d=W0[h]||h.toLowerCase();if(a[h]!==void 0){const p=i.accessors[e.attributes[h]],u=bl[p.componentType];c[d]=u.name,l[d]=p.normalized===!0}}return t.getDependency("bufferView",s).then(function(h){return new Promise(function(d,p){n.decodeDracoFile(h,function(u){for(const v in u.attributes){const m=u.attributes[v],g=l[v];g!==void 0&&(m.normalized=g)}d(u)},o,c,Fi,p)})})}}class a8{constructor(){this.name=Et.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 o8{constructor(){this.name=Et.KHR_MESH_QUANTIZATION}}class Jb extends ma{constructor(e,t,i,n){super(e,t,i,n)}copySampleValue_(e){const t=this.resultBuffer,i=this.sampleValues,n=this.valueSize,s=e*n*3+n;for(let a=0;a!==n;a++)t[a]=i[s+a];return t}interpolate_(e,t,i,n){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=o*2,c=o*3,h=n-t,d=(i-t)/h,p=d*d,u=p*d,v=e*c,m=v-c,g=-2*u+3*p,f=u-p,y=1-g,x=f-p+d;for(let _=0;_!==o;_++){const E=a[m+_+o],S=a[m+_+l]*h,C=a[v+_+o],w=a[v+_]*h;s[_]=y*E+x*S+g*C+f*w}return s}}const l8=new Ct;class c8 extends Jb{interpolate_(e,t,i,n){const s=super.interpolate_(e,t,i,n);return l8.fromArray(s).normalize().toArray(s),s}}const Kn={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},bl={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Qb={9728:Yt,9729:Pt,9984:Lh,9985:ho,9986:Jr,9987:Hn},eM={33071:an,33648:co,10497:Ki},G0={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},W0={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"},Xr={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},h8={CUBICSPLINE:void 0,LINEAR:fo,STEP:po},X0={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function d8(r){return r.DefaultMaterial===void 0&&(r.DefaultMaterial=new pa({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:zn})),r.DefaultMaterial}function $a(r,e,t){for(const i in t.extensions)r[i]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[i]=t.extensions[i])}function As(r,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(r.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function u8(r,e,t){let i=!1,n=!1,s=!1;for(let c=0,h=e.length;c<h;c++){const d=e[c];if(d.POSITION!==void 0&&(i=!0),d.NORMAL!==void 0&&(n=!0),d.COLOR_0!==void 0&&(s=!0),i&&n&&s)break}if(!i&&!n&&!s)return Promise.resolve(r);const a=[],o=[],l=[];for(let c=0,h=e.length;c<h;c++){const d=e[c];if(i){const p=d.POSITION!==void 0?t.getDependency("accessor",d.POSITION):r.attributes.position;a.push(p)}if(n){const p=d.NORMAL!==void 0?t.getDependency("accessor",d.NORMAL):r.attributes.normal;o.push(p)}if(s){const p=d.COLOR_0!==void 0?t.getDependency("accessor",d.COLOR_0):r.attributes.color;l.push(p)}}return Promise.all([Promise.all(a),Promise.all(o),Promise.all(l)]).then(function(c){const h=c[0],d=c[1],p=c[2];return i&&(r.morphAttributes.position=h),n&&(r.morphAttributes.normal=d),s&&(r.morphAttributes.color=p),r.morphTargetsRelative=!0,r})}function p8(r,e){if(r.updateMorphTargets(),e.weights!==void 0)for(let t=0,i=e.weights.length;t<i;t++)r.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(r.morphTargetInfluences.length===t.length){r.morphTargetDictionary={};for(let i=0,n=t.length;i<n;i++)r.morphTargetDictionary[t[i]]=i}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function f8(r){let e;const t=r.extensions&&r.extensions[Et.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+j0(t.attributes):e=r.indices+":"+j0(r.attributes)+":"+r.mode,r.targets!==void 0)for(let i=0,n=r.targets.length;i<n;i++)e+=":"+j0(r.targets[i]);return e}function j0(r){let e="";const t=Object.keys(r).sort();for(let i=0,n=t.length;i<n;i++)e+=t[i]+":"+r[t[i]]+";";return e}function q0(r){switch(r){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 m8(r){return r.search(/\.jpe?g($|\?)/i)>0||r.search(/^data\:image\/jpeg/)===0?"image/jpeg":r.search(/\.webp($|\?)/i)>0||r.search(/^data\:image\/webp/)===0?"image/webp":r.search(/\.ktx2($|\?)/i)>0||r.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const g8=new Ke;class v8{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new zN,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 i=!1,n=-1,s=!1,a=-1;if(typeof navigator<"u"&&typeof navigator.userAgent<"u"){const o=navigator.userAgent;i=/^((?!chrome|android).)*safari/i.test(o)===!0;const l=o.match(/Version\/(\d+)/);n=i&&l?parseInt(l[1],10):-1,s=o.indexOf("Firefox")>-1,a=s?o.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||i&&n<17||s&&a<98?this.textureLoader=new ba(this.options.manager):this.textureLoader=new Ay(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new yn(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 i=this,n=this.json,s=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(a){return a._markDefs&&a._markDefs()}),Promise.all(this._invokeAll(function(a){return a.beforeRoot&&a.beforeRoot()})).then(function(){return Promise.all([i.getDependencies("scene"),i.getDependencies("animation"),i.getDependencies("camera")])}).then(function(a){const o={scene:a[0][n.scene||0],scenes:a[0],animations:a[1],cameras:a[2],asset:n.asset,parser:i,userData:{}};return $a(s,o,n),As(o,n),Promise.all(i._invokeAll(function(l){return l.afterRoot&&l.afterRoot(o)})).then(function(){for(const l of o.scenes)l.updateMatrixWorld();e(o)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],i=this.json.meshes||[];for(let n=0,s=t.length;n<s;n++){const a=t[n].joints;for(let o=0,l=a.length;o<l;o++)e[a[o]].isBone=!0}for(let n=0,s=e.length;n<s;n++){const a=e[n];a.mesh!==void 0&&(this._addNodeRef(this.meshCache,a.mesh),a.skin!==void 0&&(i[a.mesh].isSkinnedMesh=!0)),a.camera!==void 0&&this._addNodeRef(this.cameraCache,a.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,i){if(e.refs[t]<=1)return i;const n=i.clone(),s=(a,o)=>{const l=this.associations.get(a);l!=null&&this.associations.set(o,l);for(const[c,h]of a.children.entries())s(h,o.children[c])};return s(i,n),n.name+="_instance_"+e.uses[t]++,n}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let i=0;i<t.length;i++){const n=e(t[i]);if(n)return n}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const i=[];for(let n=0;n<t.length;n++){const s=e(t[n]);s&&i.push(s)}return i}getDependency(e,t){const i=e+":"+t;let n=this.cache.get(i);if(!n){switch(e){case"scene":n=this.loadScene(t);break;case"node":n=this._invokeOne(function(s){return s.loadNode&&s.loadNode(t)});break;case"mesh":n=this._invokeOne(function(s){return s.loadMesh&&s.loadMesh(t)});break;case"accessor":n=this.loadAccessor(t);break;case"bufferView":n=this._invokeOne(function(s){return s.loadBufferView&&s.loadBufferView(t)});break;case"buffer":n=this.loadBuffer(t);break;case"material":n=this._invokeOne(function(s){return s.loadMaterial&&s.loadMaterial(t)});break;case"texture":n=this._invokeOne(function(s){return s.loadTexture&&s.loadTexture(t)});break;case"skin":n=this.loadSkin(t);break;case"animation":n=this._invokeOne(function(s){return s.loadAnimation&&s.loadAnimation(t)});break;case"camera":n=this.loadCamera(t);break;default:if(n=this._invokeOne(function(s){return s!=this&&s.getDependency&&s.getDependency(e,t)}),!n)throw new Error("Unknown type: "+e);break}this.cache.add(i,n)}return n}getDependencies(e){let t=this.cache.get(e);if(!t){const i=this,n=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(n.map(function(s,a){return i.getDependency(e,a)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],i=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[Et.KHR_BINARY_GLTF].body);const n=this.options;return new Promise(function(s,a){i.load(Pr.resolveURL(t.uri,n.path),s,void 0,function(){a(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(i){const n=t.byteLength||0,s=t.byteOffset||0;return i.slice(s,s+n)})}loadAccessor(e){const t=this,i=this.json,n=this.json.accessors[e];if(n.bufferView===void 0&&n.sparse===void 0){const a=G0[n.type],o=bl[n.componentType],l=n.normalized===!0,c=new o(n.count*a);return Promise.resolve(new wt(c,a,l))}const s=[];return n.bufferView!==void 0?s.push(this.getDependency("bufferView",n.bufferView)):s.push(null),n.sparse!==void 0&&(s.push(this.getDependency("bufferView",n.sparse.indices.bufferView)),s.push(this.getDependency("bufferView",n.sparse.values.bufferView))),Promise.all(s).then(function(a){const o=a[0],l=G0[n.type],c=bl[n.componentType],h=c.BYTES_PER_ELEMENT,d=h*l,p=n.byteOffset||0,u=n.bufferView!==void 0?i.bufferViews[n.bufferView].byteStride:void 0,v=n.normalized===!0;let m,g;if(u&&u!==d){const f=Math.floor(p/u),y="InterleavedBuffer:"+n.bufferView+":"+n.componentType+":"+f+":"+n.count;let x=t.cache.get(y);x||(m=new c(o,f*u,n.count*u/h),x=new Ao(m,u/h),t.cache.add(y,x)),g=new Fs(x,l,p%u/h,v)}else o===null?m=new c(n.count*l):m=new c(o,p,n.count*l),g=new wt(m,l,v);if(n.sparse!==void 0){const f=G0.SCALAR,y=bl[n.sparse.indices.componentType],x=n.sparse.indices.byteOffset||0,_=n.sparse.values.byteOffset||0,E=new y(a[1],x,n.sparse.count*f),S=new c(a[2],_,n.sparse.count*l);o!==null&&(g=new wt(g.array.slice(),g.itemSize,g.normalized)),g.normalized=!1;for(let C=0,w=E.length;C<w;C++){const M=E[C];if(g.setX(M,S[C*l]),l>=2&&g.setY(M,S[C*l+1]),l>=3&&g.setZ(M,S[C*l+2]),l>=4&&g.setW(M,S[C*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}g.normalized=v}return g})}loadTexture(e){const t=this.json,i=this.options,n=t.textures[e].source,s=t.images[n];let a=this.textureLoader;if(s.uri){const o=i.manager.getHandler(s.uri);o!==null&&(a=o)}return this.loadTextureImage(e,n,a)}loadTextureImage(e,t,i){const n=this,s=this.json,a=s.textures[e],o=s.images[t],l=(o.uri||o.bufferView)+":"+a.sampler;if(this.textureCache[l])return this.textureCache[l];const c=this.loadImageSource(t,i).then(function(h){h.flipY=!1,h.name=a.name||o.name||"",h.name===""&&typeof o.uri=="string"&&o.uri.startsWith("data:image/")===!1&&(h.name=o.uri);const d=(s.samplers||{})[a.sampler]||{};return h.magFilter=Qb[d.magFilter]||Pt,h.minFilter=Qb[d.minFilter]||Hn,h.wrapS=eM[d.wrapS]||Ki,h.wrapT=eM[d.wrapT]||Ki,h.generateMipmaps=!h.isCompressedTexture&&h.minFilter!==Yt&&h.minFilter!==Pt,n.associations.set(h,{textures:e}),h}).catch(function(){return null});return this.textureCache[l]=c,c}loadImageSource(e,t){const i=this,n=this.json,s=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(d=>d.clone());const a=n.images[e],o=self.URL||self.webkitURL;let l=a.uri||"",c=!1;if(a.bufferView!==void 0)l=i.getDependency("bufferView",a.bufferView).then(function(d){c=!0;const p=new Blob([d],{type:a.mimeType});return l=o.createObjectURL(p),l});else if(a.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(p,u){let v=p;t.isImageBitmapLoader===!0&&(v=function(m){const g=new ei(m);g.needsUpdate=!0,p(g)}),t.load(Pr.resolveURL(d,s.path),v,void 0,u)})}).then(function(d){return c===!0&&o.revokeObjectURL(l),As(d,a),d.userData.mimeType=a.mimeType||m8(a.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,i,n){const s=this;return this.getDependency("texture",i.index).then(function(a){if(!a)return null;if(i.texCoord!==void 0&&i.texCoord>0&&(a=a.clone(),a.channel=i.texCoord),s.extensions[Et.KHR_TEXTURE_TRANSFORM]){const o=i.extensions!==void 0?i.extensions[Et.KHR_TEXTURE_TRANSFORM]:void 0;if(o){const l=s.associations.get(a);a=s.extensions[Et.KHR_TEXTURE_TRANSFORM].extendTexture(a,o),s.associations.set(a,l)}}return n!==void 0&&(a.colorSpace=n),e[t]=a,a})}assignFinalMaterial(e){const t=e.geometry;let i=e.material;const n=t.attributes.tangent===void 0,s=t.attributes.color!==void 0,a=t.attributes.normal===void 0;if(e.isPoints){const o="PointsMaterial:"+i.uuid;let l=this.cache.get(o);l||(l=new su,Ri.prototype.copy.call(l,i),l.color.copy(i.color),l.map=i.map,l.sizeAttenuation=!1,this.cache.add(o,l)),i=l}else if(e.isLine){const o="LineBasicMaterial:"+i.uuid;let l=this.cache.get(o);l||(l=new ii,Ri.prototype.copy.call(l,i),l.color.copy(i.color),l.map=i.map,this.cache.add(o,l)),i=l}if(n||s||a){let o="ClonedMaterial:"+i.uuid+":";n&&(o+="derivative-tangents:"),s&&(o+="vertex-colors:"),a&&(o+="flat-shading:");let l=this.cache.get(o);l||(l=i.clone(),s&&(l.vertexColors=!0),a&&(l.flatShading=!0),n&&(l.normalScale&&(l.normalScale.y*=-1),l.clearcoatNormalScale&&(l.clearcoatNormalScale.y*=-1)),this.cache.add(o,l),this.associations.set(l,this.associations.get(i))),i=l}e.material=i}getMaterialType(){return pa}loadMaterial(e){const t=this,i=this.json,n=this.extensions,s=i.materials[e];let a;const o={},l=s.extensions||{},c=[];if(l[Et.KHR_MATERIALS_UNLIT]){const d=n[Et.KHR_MATERIALS_UNLIT];a=d.getMaterialType(),c.push(d.extendParams(o,s,t))}else{const d=s.pbrMetallicRoughness||{};if(o.color=new Xe(1,1,1),o.opacity=1,Array.isArray(d.baseColorFactor)){const p=d.baseColorFactor;o.color.setRGB(p[0],p[1],p[2],Fi),o.opacity=p[3]}d.baseColorTexture!==void 0&&c.push(t.assignTexture(o,"map",d.baseColorTexture,Qt)),o.metalness=d.metallicFactor!==void 0?d.metallicFactor:1,o.roughness=d.roughnessFactor!==void 0?d.roughnessFactor:1,d.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(o,"metalnessMap",d.metallicRoughnessTexture)),c.push(t.assignTexture(o,"roughnessMap",d.metallicRoughnessTexture))),a=this._invokeOne(function(p){return p.getMaterialType&&p.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(p){return p.extendMaterialParams&&p.extendMaterialParams(e,o)})))}s.doubleSided===!0&&(o.side=Ht);const h=s.alphaMode||X0.OPAQUE;if(h===X0.BLEND?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,h===X0.MASK&&(o.alphaTest=s.alphaCutoff!==void 0?s.alphaCutoff:.5)),s.normalTexture!==void 0&&a!==Rt&&(c.push(t.assignTexture(o,"normalMap",s.normalTexture)),o.normalScale=new xe(1,1),s.normalTexture.scale!==void 0)){const d=s.normalTexture.scale;o.normalScale.set(d,d)}if(s.occlusionTexture!==void 0&&a!==Rt&&(c.push(t.assignTexture(o,"aoMap",s.occlusionTexture)),s.occlusionTexture.strength!==void 0&&(o.aoMapIntensity=s.occlusionTexture.strength)),s.emissiveFactor!==void 0&&a!==Rt){const d=s.emissiveFactor;o.emissive=new Xe().setRGB(d[0],d[1],d[2],Fi)}return s.emissiveTexture!==void 0&&a!==Rt&&c.push(t.assignTexture(o,"emissiveMap",s.emissiveTexture,Qt)),Promise.all(c).then(function(){const d=new a(o);return s.name&&(d.name=s.name),As(d,s),t.associations.set(d,{materials:e}),s.extensions&&$a(n,d,s),d})}createUniqueName(e){const t=Dt.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,i=this.extensions,n=this.primitiveCache;function s(o){return i[Et.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(o,t).then(function(l){return tM(l,o,t)})}const a=[];for(let o=0,l=e.length;o<l;o++){const c=e[o],h=f8(c),d=n[h];if(d)a.push(d.promise);else{let p;c.extensions&&c.extensions[Et.KHR_DRACO_MESH_COMPRESSION]?p=s(c):p=tM(new ot,c,t),n[h]={primitive:c,promise:p},a.push(p)}}return Promise.all(a)}loadMesh(e){const t=this,i=this.json,n=this.extensions,s=i.meshes[e],a=s.primitives,o=[];for(let l=0,c=a.length;l<c;l++){const h=a[l].material===void 0?d8(this.cache):this.getDependency("material",a[l].material);o.push(h)}return o.push(t.loadGeometries(a)),Promise.all(o).then(function(l){const c=l.slice(0,l.length-1),h=l[l.length-1],d=[];for(let u=0,v=h.length;u<v;u++){const m=h[u],g=a[u];let f;const y=c[u];if(g.mode===Kn.TRIANGLES||g.mode===Kn.TRIANGLE_STRIP||g.mode===Kn.TRIANGLE_FAN||g.mode===void 0)f=s.isSkinnedMesh===!0?new Jf(m,y):new Ve(m,y),f.isSkinnedMesh===!0&&f.normalizeSkinWeights(),g.mode===Kn.TRIANGLE_STRIP?f.geometry=qb(f.geometry,Mf):g.mode===Kn.TRIANGLE_FAN&&(f.geometry=qb(f.geometry,vd));else if(g.mode===Kn.LINES)f=new fi(m,y);else if(g.mode===Kn.LINE_STRIP)f=new oi(m,y);else if(g.mode===Kn.LINE_LOOP)f=new nm(m,y);else if(g.mode===Kn.POINTS)f=new ou(m,y);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+g.mode);Object.keys(f.geometry.morphAttributes).length>0&&p8(f,s),f.name=t.createUniqueName(s.name||"mesh_"+e),As(f,s),g.extensions&&$a(n,f,g),t.assignFinalMaterial(f),d.push(f)}for(let u=0,v=d.length;u<v;u++)t.associations.set(d[u],{meshes:e,primitives:u});if(d.length===1)return s.extensions&&$a(n,d[0],s),d[0];const p=new bi;s.extensions&&$a(n,p,s),t.associations.set(p,{meshes:e});for(let u=0,v=d.length;u<v;u++)p.add(d[u]);return p})}loadCamera(e){let t;const i=this.json.cameras[e],n=i[i.type];if(!n){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return i.type==="perspective"?t=new ci(Lt.radToDeg(n.yfov),n.aspectRatio||1,n.znear||1,n.zfar||2e6):i.type==="orthographic"&&(t=new Zi(-n.xmag,n.xmag,n.ymag,-n.ymag,n.znear,n.zfar)),i.name&&(t.name=this.createUniqueName(i.name)),As(t,i),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],i=[];for(let n=0,s=t.joints.length;n<s;n++)i.push(this._loadNodeShallow(t.joints[n]));return t.inverseBindMatrices!==void 0?i.push(this.getDependency("accessor",t.inverseBindMatrices)):i.push(null),Promise.all(i).then(function(n){const s=n.pop(),a=n,o=[],l=[];for(let c=0,h=a.length;c<h;c++){const d=a[c];if(d){o.push(d);const p=new Ke;s!==null&&p.fromArray(s.array,c*16),l.push(p)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[c])}return new sc(o,l)})}loadAnimation(e){const t=this.json,i=this,n=t.animations[e],s=n.name?n.name:"animation_"+e,a=[],o=[],l=[],c=[],h=[];for(let d=0,p=n.channels.length;d<p;d++){const u=n.channels[d],v=n.samplers[u.sampler],m=u.target,g=m.node,f=n.parameters!==void 0?n.parameters[v.input]:v.input,y=n.parameters!==void 0?n.parameters[v.output]:v.output;m.node!==void 0&&(a.push(this.getDependency("node",g)),o.push(this.getDependency("accessor",f)),l.push(this.getDependency("accessor",y)),c.push(v),h.push(m))}return Promise.all([Promise.all(a),Promise.all(o),Promise.all(l),Promise.all(c),Promise.all(h)]).then(function(d){const p=d[0],u=d[1],v=d[2],m=d[3],g=d[4],f=[];for(let x=0,_=p.length;x<_;x++){const E=p[x],S=u[x],C=v[x],w=m[x],M=g[x];if(E===void 0)continue;E.updateMatrix&&E.updateMatrix();const R=i._createAnimationTracks(E,S,C,w,M);if(R)for(let N=0;N<R.length;N++)f.push(R[N])}const y=new Bo(s,void 0,f);return As(y,n),y})}createNodeMesh(e){const t=this.json,i=this,n=t.nodes[e];return n.mesh===void 0?null:i.getDependency("mesh",n.mesh).then(function(s){const a=i._getNodeRef(i.meshCache,n.mesh,s);return n.weights!==void 0&&a.traverse(function(o){if(o.isMesh)for(let l=0,c=n.weights.length;l<c;l++)o.morphTargetInfluences[l]=n.weights[l]}),a})}loadNode(e){const t=this.json,i=this,n=t.nodes[e],s=i._loadNodeShallow(e),a=[],o=n.children||[];for(let c=0,h=o.length;c<h;c++)a.push(i.getDependency("node",o[c]));const l=n.skin===void 0?Promise.resolve(null):i.getDependency("skin",n.skin);return Promise.all([s,Promise.all(a),l]).then(function(c){const h=c[0],d=c[1],p=c[2];p!==null&&h.traverse(function(u){u.isSkinnedMesh&&u.bind(p,g8)});for(let u=0,v=d.length;u<v;u++)h.add(d[u]);if(h.userData.pivot!==void 0&&d.length>0){const u=h.userData.pivot,v=d[0];h.pivot=new A().fromArray(u),h.position.x-=u[0],h.position.y-=u[1],h.position.z-=u[2],v.position.set(0,0,0),delete h.userData.pivot}return h})}_loadNodeShallow(e){const t=this.json,i=this.extensions,n=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const s=t.nodes[e],a=s.name?n.createUniqueName(s.name):"",o=[],l=n._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});return l&&o.push(l),s.camera!==void 0&&o.push(n.getDependency("camera",s.camera).then(function(c){return n._getNodeRef(n.cameraCache,s.camera,c)})),n._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(e)}).forEach(function(c){o.push(c)}),this.nodeCache[e]=Promise.all(o).then(function(c){let h;if(s.isBone===!0?h=new Zd:c.length>1?h=new bi:c.length===1?h=c[0]:h=new bt,h!==c[0])for(let d=0,p=c.length;d<p;d++)h.add(c[d]);if(s.name&&(h.userData.name=s.name,h.name=a),As(h,s),s.extensions&&$a(i,h,s),s.matrix!==void 0){const d=new Ke;d.fromArray(s.matrix),h.applyMatrix4(d)}else s.translation!==void 0&&h.position.fromArray(s.translation),s.rotation!==void 0&&h.quaternion.fromArray(s.rotation),s.scale!==void 0&&h.scale.fromArray(s.scale);if(!n.associations.has(h))n.associations.set(h,{});else if(s.mesh!==void 0&&n.meshCache.refs[s.mesh]>1){const d=n.associations.get(h);n.associations.set(h,{...d})}return n.associations.get(h).nodes=e,h}),this.nodeCache[e]}loadScene(e){const t=this.extensions,i=this.json.scenes[e],n=this,s=new bi;i.name&&(s.name=n.createUniqueName(i.name)),As(s,i),i.extensions&&$a(t,s,i);const a=i.nodes||[],o=[];for(let l=0,c=a.length;l<c;l++)o.push(n.getDependency("node",a[l]));return Promise.all(o).then(function(l){for(let h=0,d=l.length;h<d;h++){const p=l[h];p.parent!==null?s.add(BN(p)):s.add(p)}const c=h=>{const d=new Map;for(const[p,u]of n.associations)(p instanceof Ri||p instanceof ei)&&d.set(p,u);return h.traverse(p=>{const u=n.associations.get(p);u!=null&&d.set(p,u)}),d};return n.associations=c(s),s})}_createAnimationTracks(e,t,i,n,s){const a=[],o=e.name?e.name:e.uuid,l=[];Xr[s.path]===Xr.weights?e.traverse(function(p){p.morphTargetInfluences&&l.push(p.name?p.name:p.uuid)}):l.push(o);let c;switch(Xr[s.path]){case Xr.weights:c=va;break;case Xr.rotation:c=ya;break;case Xr.translation:case Xr.scale:c=_a;break;default:i.itemSize===1?c=va:c=_a;break}const h=n.interpolation!==void 0?h8[n.interpolation]:fo,d=this._getArrayFromAccessor(i);for(let p=0,u=l.length;p<u;p++){const v=new c(l[p]+"."+Xr[s.path],t.array,d,h);n.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(v),a.push(v)}return a}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const i=q0(t.constructor),n=new Float32Array(t.length);for(let s=0,a=t.length;s<a;s++)n[s]=t[s]*i;t=n}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(t){const i=this instanceof ya?c8:Jb;return new i(this.times,this.values,this.getValueSize()/3,t)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function y8(r,e,t){const i=e.attributes,n=new Ot;if(i.POSITION!==void 0){const o=t.json.accessors[i.POSITION],l=o.min,c=o.max;if(l!==void 0&&c!==void 0){if(n.set(new A(l[0],l[1],l[2]),new A(c[0],c[1],c[2])),o.normalized){const h=q0(bl[o.componentType]);n.min.multiplyScalar(h),n.max.multiplyScalar(h)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const s=e.targets;if(s!==void 0){const o=new A,l=new A;for(let c=0,h=s.length;c<h;c++){const d=s[c];if(d.POSITION!==void 0){const p=t.json.accessors[d.POSITION],u=p.min,v=p.max;if(u!==void 0&&v!==void 0){if(l.setX(Math.max(Math.abs(u[0]),Math.abs(v[0]))),l.setY(Math.max(Math.abs(u[1]),Math.abs(v[1]))),l.setZ(Math.max(Math.abs(u[2]),Math.abs(v[2]))),p.normalized){const m=q0(bl[p.componentType]);l.multiplyScalar(m)}o.max(l)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}n.expandByVector(o)}r.boundingBox=n;const a=new zi;n.getCenter(a.center),a.radius=n.min.distanceTo(n.max)/2,r.boundingSphere=a}function tM(r,e,t){const i=e.attributes,n=[];function s(a,o){return t.getDependency("accessor",a).then(function(l){r.setAttribute(o,l)})}for(const a in i){const o=W0[a]||a.toLowerCase();o in r.attributes||n.push(s(i[a],o))}if(e.indices!==void 0&&!r.index){const a=t.getDependency("accessor",e.indices).then(function(o){r.setIndex(o)});n.push(a)}return St.workingColorSpace!==Fi&&"COLOR_0"in i&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${St.workingColorSpace}" not supported.`),As(r,e),y8(r,e,t),Promise.all(n).then(function(){return e.targets!==void 0?u8(r,e.targets,t):r})}var pi=(r=>(r.ModelLoadStart="model-load-start",r.ModelLoadProgress="model-load-progress",r.ModelLoaded="model-loaded",r.ModelError="model-error",r.SelectionChanged="selection-changed",r.HoverChanged="hover-changed",r.Click="click",r.MouseMove="mouse-move",r.CameraChanged="camera-changed",r.CameraIdle="camera-idle",r.EngineFree="engine-free",r.EngineBusy="engine-busy",r.MeasureChanged="measure-changed",r.MeasureClick="measure-click",r.SectionMove="section-move",r.LoadingCompleted="loading_completed",r))(pi||{});let Yc=null;const x8=8,iM=24,_8=24,b8=64,M8=60,S8=10;function nM(){return new URL("draco/",document.baseURI).toString()}function w8(){return Yc==null&&(Yc=new UN,Yc.setDecoderPath(nM()),Yc.preload()),Yc}function sM(){return new Promise(r=>{if(typeof requestAnimationFrame=="function"){requestAnimationFrame(()=>r());return}setTimeout(r,16)})}function E8(){const r=navigator?.scheduling;return typeof r?.isInputPending=="function"?r.isInputPending():!1}function C8(r){return r?.engineStatus?.isFree===!1||E8()}async function ar(r,e,t){if(e)return t;const i=performance.now();return C8(r)||i-t>=x8?(await sM(),performance.now()):t}function T8(r){return new Promise((e,t)=>{qc(r,i=>{if(i==null){t(new Error(`[loadLightModel] empty zip json: ${r}`));return}e(i)},()=>{t(new Error(`[loadLightModel] failed to load zip json: ${r}`))})})}function A8(r){return ui({method:"get",responseType:"arraybuffer",url:r}).then(e=>ab.loadAsync(e.data))}function rM(r){return r.replace(/\\/g,"/").replace(/^\/+/,"")}function aM(r,e){const t=new Set(e.map(i=>rM(i)));for(const i of Object.keys(r.files))if(t.has(rM(i)))return r.files[i];return null}function oM(r,e){const t=aM(r,e);return t==null||t.dir?Promise.resolve(null):t.async("string")}function P8(r){return r.charCodeAt(0)===65279?r.slice(1):r}function Z0(r){return JSON.parse(P8(r))}function R8(r,e){const t=aM(r,e);return t==null||t.dir?Promise.resolve(null):t.async("arraybuffer")}function L8(r){return new Promise((e,t)=>{const i=new FN;i.setDRACOLoader(w8()),i.parse(r,document.baseURI,e,t)})}function Kp(r,e){return r.models.find(t=>t.url==e)}function lM(r){r.loadStatus==null&&(r.loadStatus={}),r.loadStatus.modelMep==null&&(r.loadStatus.modelMep=!1),r.loadStatus.normal==null&&(r.loadStatus.normal=!1)}function I8(r){return lM(r),r.status==="loaded"&&r.loadStatus.normal===!0&&r.loadStatus.modelMep===!0}function cM(r){const e=r?.engineStatus?.models;!Array.isArray(e)||e.length===0||!e.every(t=>I8(t))||r.__loadingCompletedTriggered===!0||(r.__loadingCompletedTriggered=!0,r.events?.trigger?.(pi.LoadingCompleted,{}))}function hM(r){return r===!0||r==="loading"}function dM(r){return r.index!=null?r.index.count:r.attributes.position?.count??0}async function D8(r,e,t){let i=performance.now();for(let n=0;n<e.length;n++){const s=e[n];s?.geometry!=null&&s.geometry.computeVertexNormals,(n+1)%_8===0&&(i=await ar(r,t,i))}}async function N8(r,e,t){const i=[],n=[{node:e.octreeBox,visited:!1}];let s=performance.now();for(;n.length>0;){const a=n.pop();if(a==null||a.node==null||a.node.status===!0)continue;const o=a.node;if(a.visited){const c=Array.isArray(o.children)?o.children:[];(c.length===0||c.findIndex(h=>h.status!=!0)===-1)&&(o.status=!0),s=await ar(r,t,s);continue}n.push({node:o,visited:!0}),Array.isArray(o.elements)&&i.push(...o.elements);const l=Array.isArray(o.children)?o.children:[];for(let c=l.length-1;c>=0;c--)n.push({node:l[c],visited:!1});s=await ar(r,t,s)}return i}async function U8(r,e,t,i){const n=Kp(r,e.url);if(n?.nodesMap==null)return[];const s=await N8(r,t,i);console.log("[loadLightModel] pending mesh ids",t.path,s.length);const a=[];let o=performance.now(),l=0;for(const c of s){if(!n.nodesMap.has(c))continue;const h=n.nodesMap.get(c),d=Array.isArray(h?.infos)?h.infos:[];for(const p of d){const u=t.glbs?.[p.glb]?.[p.mesh];if(u?.geometry==null||u.material==null)continue;const v=new Ke;v.elements=p.matrix;const m=u.geometry.clone();m.applyMatrix4(v),m.computeBoundingBox();const g=new Ve(m,u.material);p.box=m.boundingBox?.clone(),p.mesh=g,g.name=Number(c),g.glb=p.glb,g.url=e.url,m.attributes.position!=null&&a.push(g),l++,l%iM===0&&(o=await ar(r,i,o))}}return a}function k8(r,e,t,i,n){const s=Ka(i.map(o=>o.geometry),!1),a=new Ve(s,n);return a.castShadow=!0,a.receiveShadow=!0,e.scene.add(a),a.index=e.scene.children.length-1,a.url=r,a.glb=t,a.materialClone=n,a.geometrys=i.map(o=>o.geometry),a.geometry.computeVertexNormals(),a}function O8(r,e,t,i){return r.scene.children.find(n=>{const s=n;return n instanceof Ve&&s.url==e&&s.glb==t&&s.materialClone===i})}function B8(r,e){const t=Array.isArray(r.geometrys)?r.geometrys:[],i=e.map(a=>a.geometry),n=[...t,...i],s=Ka(n,!1);r.geometry!=null&&r.geometry.dispose(),r.geometry=s,r.geometrys=n,r.castShadow=!0,r.receiveShadow=!0}async function F8(r,e,t,i){const n=new Map;for(const o of t){const l=n.get(o.glb)??[];l.push(o),n.set(o.glb,l)}const s=Kp(e,r);let a=performance.now();for(const[o,l]of n.entries()){const c=i?l.length:M8;for(let h=0;h<l.length;h+=c){const d=l.slice(h,h+c);if(d.length===0)continue;const p=Y8(d[0].material,e);let u=O8(e,r,o,p),v=0,m=0;u=null,u!=null?(v=Array.isArray(u.geometrys)?u.geometrys.length:0,m=dM(u.geometry),B8(u,d)):u=k8(r,e,o,d,p);const g=new Map;let f=m;d.forEach((y,x)=>{const _=Number(y.name),E=dM(y.geometry),S=g.get(_)??[];if(S.push([f,f+E]),g.set(_,S),s?.nodesMap?.has(_)){const C=s.nodesMap.get(_);C.indexes==null&&(C.indexes=[]),C.indexes.push([u.index,v+x,f,f+E])}f+=E}),u.indexes==null&&(u.indexes=new Map),g.forEach((y,x)=>{const _=u.indexes.get(x)??[];_.push(...y),u.indexes.set(x,_)}),a=await ar(e,i,a)}}}async function z8(r,e,t,i,n,s){if(i==null||n==null||n.length===0)return;const a=Kp(t,r);if(a==null)return;const o=new ti(i.geometry,i.material,n.length);t.scene.add(o);const l=new Float32Array(n.length*3);for(let d=0;d<n.length;d++)l[d*3]=1,l[d*3+1]=1,l[d*3+2]=1;o.instanceColor=new Mr(l,3);let c=performance.now();const h=[];for(let d=0;d<n.length;d++){const p=n[d],u=new Ke;if(u.elements=p.matrix,o.setMatrixAt(d,u),o.matrixs||(o.matrixs=[]),o.matrixs.push(u.clone()),h.push(u.clone()),a.nodesMap.has(p.id)){const v=a.nodesMap.get(p.id);v.indexes==null&&(v.indexes=[]),v.indexes.push([t.scene.children.length-1,d,0,0])}else a.nodesMap.set(p.id,{instance:!0,info:p,indexes:[[t.scene.children.length-1,d,0,0]]});(d+1)%b8===0&&(c=await ar(t,s,c))}o.instanceMatrix.needsUpdate=!0,o.instanceColor!=null&&(o.instanceColor.needsUpdate=!0),o.index=t.scene.children.length-1,o.materialClone=i.material,o.url=r,o.glb=i.glb,o.ids=n.map(d=>d.id),o.matrixsClone=h,o.meshIndex=e}async function H8(r,e,t,i){const n=e.instanceNodes;if(n==null)return;let s=performance.now();for(const a in n)if(n[a].isLoaded!==!0){n[a].isLoaded=!0;for(const o of n[a]){const l=e.glbs?.[a]?.[o.mesh];l!=null&&await z8(r.url,o.mesh,t,l,o.children,i)}s=await ar(t,i,s)}}async function V8(r,e,t,i){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 n=await U8(r,e,t,i);await F8(e.url,r,n,i),await H8(e,t,r,i),t.status=!0,console.log(`[loadLightModel] *****************************************************finish build lod meshes ${Date.now()-window.startTime}ms`)})().finally(()=>{t.meshPromise=null}),await t.meshPromise}async function G8(r,e,t,i){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 n=await A8(e.url+t.path),s=await oM(n,["/nodes.json","nodes.json"]);if(s==null)return;const a=Z0(s),o=Kp(r,e.url);if(o==null)return;o.nodesMap==null&&(o.nodesMap=new Map);let l=performance.now();for(const h of Object.keys(a)){const d=a[h];for(let u=0;u<d.length;u++){const v=d[u];if(v.glb=h,o.nodesMap.has(v.id)===!1)o.nodesMap.set(v.id,{infos:[v]});else{if(!o.nodesMap.get(v.id).infos)continue;o.nodesMap.get(v.id).infos.push(v)}(u+1)%iM===0&&(l=await ar(r,i,l))}const p=await R8(n,[`/${h}.glb`,`${h}.glb`,h+".glb"]);if(p==null){console.error("[loadLightModel] glb not found in zip",{modelUrl:e.url,lodPath:t.path,glbKey:`${h}.glb`,availableFiles:Object.keys(n.files)});continue}try{const u=await L8(p);t.glbs[h]=u.scene.children,await D8(r,t.glbs[h],i)}catch(u){console.error("[loadLightModel] failed to load glb",{modelUrl:e.url,lodPath:t.path,glbKey:`${h}.glb`,dracoDecoderPath:nM(),error:u})}l=await ar(r,i,l)}const c=await oM(n,["/instances.json","instances.json"]);t.instanceNodes=c!=null?Z0(c):null,t.loadSuccess=!0})().finally(()=>{t.preparePromise=null}),await t.preparePromise}}function W8(r,e,t){if(t.boundingBox||(t.boundingBox=new Ot,t.boundingBox.min=new A(t.octreeBox.min.X,t.octreeBox.min.Z,-t.octreeBox.min.Y),t.boundingBox.max=new A(t.octreeBox.max.X,t.octreeBox.max.Z,-t.octreeBox.max.Y)),!t.maxSize)return 1e3;const i=t.boundingBox,n=i.min,s=i.max,a=n.clone().add(s.clone()).multiplyScalar(.5),o=n.distanceTo(s),l=new A,c=new A,h=new A,d=new A;if(e.getWorldDirection(h),e.getWorldPosition(d),e.matrixWorld.extractBasis(l,c,new A),e instanceof Zi){const f=Math.max((e.top-e.bottom)/e.zoom,1e-6),y=r?.cameraModule?.perspectiveCamera?.getEffectiveFOV?.()??20,x=Lt.degToRad(y*.5),_=x>0?f/(2*Math.tan(x)):f;d.copy(a).add(h.clone().multiplyScalar(-_))}if(d.distanceTo(a)<=o*.5)return 1e3;const p=a.clone().sub(d).dot(h);if(p<=0)return 0;const u=d.clone().add(h.multiplyScalar(Math.max(p,o))),v=u.clone().add(l.setLength(t.maxSize)),m=new Ft(e,r.renderer,r.scene).worldToScreen(u),g=new Ft(e,r.renderer,r.scene).worldToScreen(v);return m.distanceTo(g)}async function X8(r,e,t,i){t.maxSize<1e6&&t.path!="/lod0"&&(!(W8(r,r.camera,t)>=S8)||t.status===!0)||(await G8(r,e,t,i),t.loadSuccess===!0&&await V8(r,e,t,i))}function j8(r,e,t){hM(e.loadStatus.modelMep)||(e.loadStatus.modelMep="loading",e.info.modelMep==null&&(e.info.modelMep={}),(async()=>{t||await sM(),ON(r,e.info.modelMep,e.url),e.loadStatus.modelMep=!0,cM(r)})().catch(i=>{e.loadStatus.modelMep=!1,console.error("[loadLightModel] failed to load mep model",i)}))}function q8(r,e,t,i){const n=new bi;n.name=e,r.scene.add(n),r.models||(r.models=[]),window.startTime=Date.now(),T8(e+"/info").then(s=>{const a=Z0(s);r.__loadingCompletedTriggered=!1,r.engineStatus.models.push({type:"light",info:a,name:a.baseInfo.name,status:"loading",url:e,elements:new Map,loadStatus:{modelMep:!1,normal:!1}}),r.models.push({url:e,nodesMap:new Map,grids:a.modelGrid,levels:a.modelLevel,rooms:a.modelRoom,views:a.modelView,boundingBox:{min:new A(a.baseInfo.min.X*.3048,a.baseInfo.min.Z*.3048,-a.baseInfo.min.Y*.3048),max:new A(a.baseInfo.max.X*.3048,a.baseInfo.max.Z*.3048,-a.baseInfo.max.Y*.3048)}}),r.models.length==i&&(r.viewCube.CameraGoHome(1),setTimeout(()=>{uM(r,null,!1)},100))}).catch(s=>{console.error("[loadLightModel] failed to load model info",{url:e,error:s})})}async function uM(r,e,t=!1){const i=r.engineStatus.models.filter(n=>e==null||n.url==e);for(const n of i)if(lM(n),!(n.status!=="loading"||n.type!=="light")&&(j8(r,n,t),!hM(n.loadStatus.normal))){n.loadStatus.normal="loading";try{await Z8(r,n,t)}finally{const s=Array.isArray(n.info?.lods)&&n.info.lods.every(a=>a.status===!0);n.loadStatus.normal=s,s&&(n.status="loaded"),cM(r)}}}async function Z8(r,e,t=!1){if(console.log(`[loadLightModel] start loadNode ${Date.now()-window.startTime}ms`),!(e.info==null||e.info.lods==null))for(const i of e.info.lods)await X8(r,e,i,t)}function Y8(r,e){return r.map!=null&&(r.map.colorSpace=Qt,r.map.needsUpdate=!0),r.clipShadows=!0,e?.sectionPlane&&(r.clippingPlanes=e.sectionPlane),r}class K8{engine;constructor(e){this.engine=e}async loadModels(e,t){console.log("待加载模型",e);for(const n of e)i(n)==="light"&&q8(this.engine,n,t,e.length);function i(n){const s=n.split(".").pop();return s==="glb"||s==="gltf"?"gltf":"light"}}}var Ml=(r=>(r.ModelLoadStart="model-load-start",r.ModelLoadProgress="model-load-progress",r.ModelLoaded="model-loaded",r.ModelError="model-error",r.SelectionChanged="selection-changed",r.HoverChanged="hover-changed",r.Click="click",r.MouseMove="mouse-move",r.CameraChanged="camera-changed",r.CameraIdle="camera-idle",r.ViewportResize="viewport-resize",r.EngineFree="engine-free",r.EngineBusy="engine-busy",r.MeasureChanged="measure-changed",r.SectionMove="section-move",r.LoadingCompleted="loading_completed",r))(Ml||{});class $8{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(Ml.EngineFree,e=>{this.updateFree(!0),uM(this.engine,e,!1)}),this.engine.events.on(Ml.EngineBusy,()=>{this.updateFree(!1)})}updateFree(e){this.isFree=e}closeAllFunction=()=>{}}let J8=class{listeners=new Map;debugMode=!1;setDebugMode(r){this.debugMode=r}on(r,e){const t=String(r);this.listeners.has(t)||this.listeners.set(t,[]),this.listeners.get(t).push(e),this.debugMode&&console.debug(`[EventModule] 注册事件监听器: ${t}, 当前监听器数量: ${this.listeners.get(t).length}`)}off(r,e){const t=String(r);if(!this.listeners.has(t)){this.debugMode&&console.warn(`[EventModule] 尝试移除不存在的事件监听器: ${t}`);return}const i=this.listeners.get(t),n=i.indexOf(e);n!==-1?(i.splice(n,1),this.debugMode&&console.debug(`[EventModule] 移除事件监听器: ${t}, 剩余监听器数量: ${i.length}`)):this.debugMode&&console.warn(`[EventModule] 尝试移除的回调函数未找到: ${t}`)}trigger(r,e){const t=String(r);if(!this.listeners.has(t)){this.debugMode&&(console.warn(`[EventModule] 触发事件但未找到监听器: ${t}`),console.debug("[EventModule] 当前已注册的事件类型:",Array.from(this.listeners.keys())));return}const i=this.listeners.get(t);this.debugMode&&console.debug(`[EventModule] 触发事件: ${t}, 监听器数量: ${i.length}`,e),i.forEach((n,s)=>{try{n(e)}catch(a){console.error(`[EventModule] 事件监听器执行错误 [${t}] #${s}:`,a)}})}};class Q8{engine;constructor(e){this.engine=e}init(){const e=new Ar(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 i=new Ar(16777215,2);this.engine.scene.add(e),this.engine.scene.add(i),this.engine.scene.dirLight=i;const n=new zo(16777215,2);this.engine.scene.add(n)}}class eU{engine;behavior;isCtrlDown=!1;isShiftDown=!1;hoverOldId=null;timeOutEvent;selectionBox=null;isBoxSelecting=!1;selectionStart=new xe;selectionEnd=new xe;suppressClickOnce=!1;selectionThreshold=5;tempInstanceMatrix=new Ke;tempScale=new A;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 i=this.getCatchMeshs(e,!0);i!=null&&i.length>0&&this.engine.hoverHighLight.showModelNameTag({url:i[0].url,ids:[i[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(),i=t?this.collectModelsInSelection():[];this.isBoxSelecting=!1,this.hideSelectionBox(),this.engine.controls&&(this.engine.controls.enabled=!0),t&&(this.isBoxDeselectMode()?this.applyBoxDeselection(i):this.applyBoxSelection(i),this.suppressClickOnce=!0)}getCatchMeshs(e,t=!1){if(e.catch==null)return this.hoverOldId=null,null;if(e.catch.object.isInstance){const a=e.catch.object,o=e.catch.object.id,l=this.engine.models.find(d=>d.url==a.url)?.nodesMap?.get(o),c=new Map;l?.indexes.forEach(d=>{this.getSceneModel(d[0])instanceof ti&&(c.has(d[0])||c.set(d[0],[]),c.get(d[0])?.push(d[1]))});const h=[];return c.forEach((d,p)=>{const u=this.getSceneModel(p);d.forEach(v=>{const m=u.geometry.clone();m.applyMatrix4(u.matrixs[v]),h.push(new Ve(m,u.material))})}),this.hoverOldId==o?[]:(this.hoverOldId=o,t||this.engine.hoverHighLight.clearHighlight(),h)}const i=e.catch.object,n=i.name,s=this.engine.models.find(a=>a.url===i.url)?.nodesMap?.get(n)?.infos?.map(a=>a.mesh)??[];return this.hoverOldId==n?[]:(this.hoverOldId=n,t||this.engine.hoverHighLight.clearHighlight(),s)}handleMouseClick(e){if(this.suppressClickOnce){this.suppressClickOnce=!1;return}if(this.isShiftDown&&!this.isCtrlDown)return;if(e.catch!=null){const i=e.catch,n=i.object;if(!this.isCtrlDown){this.engine.modelToolModule.unhighlightAllModels();const a=new CustomEvent("D3ElementClick",{detail:{id:-1}});window.dispatchEvent(a)}this.engine.controlModule.orbitControls.origin.set(i.point.x,i.point.y,i.point.z),this.engine.modelToolModule.highlightModel([{url:n.url,ids:[n.name]}]),this.engine.events.trigger(pi.Click,[{url:n.url,ids:[n.name]}]);const s=new CustomEvent("D3ElementClick",{detail:{id:n.name}});window.dispatchEvent(s);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,i=t.object,n=this.engine.models.find(o=>o.url===i.url)?.nodesMap?.get(i.name);if(!n)return;if(t.object.isInstance){const o=t.matrix,l=[];n.indexes.forEach(h=>{const d=this.getSceneModel(h[0]);d?.geometry?.boundingSphere||d?.geometry?.computeBoundingSphere?.();const p=d?.geometry?.boundingSphere;if(!p)return;const u=new Ot,v=p.center.clone().applyMatrix4(o),m=p.radius,g=new A().setFromMatrixScale(o),f=m*Math.max(g.x,g.y,g.z);u.min.set(v.x-f,v.y-f,v.z-f),u.max.set(v.x+f,v.y+f,v.z+f),l.push(u)});const c=this.getMergedBox(l);c!=null&&this.engine.viewCube.zoomToModel(c);return}const s=n.infos.map(o=>o.box).filter(o=>o instanceof Ot),a=this.getMergedBox(s);a!=null&&this.engine.viewCube.zoomToModel(a)}handleMouseClickInstance(e){return e.intersectObjects(this.engine.scene.children.filter(t=>t instanceof ti),!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(),i=new Map;return this.engine.models?.forEach(n=>{!n?.url||!n?.nodesMap||n.nodesMap.forEach((s,a)=>{const o=this.getNodeWorldBox(s),l=this.projectBoxToScreenRect(o);l==null||!(t?this.containsRect(e,l):this.intersectsRect(e,l))||(i.has(n.url)||i.set(n.url,new Set),i.get(n.url)?.add(a))})}),Array.from(i.entries()).map(([n,s])=>({url:n,ids:Array.from(s)}))}applyBoxSelection(e){const t=this.excludeHighlightedModels(e);t.length!==0&&(this.engine.modelToolModule.highlightModel(t),this.engine.events.trigger(pi.SelectionChanged,t))}applyBoxDeselection(e){const t=this.keepHighlightedModels(e);t.length!==0&&(this.engine.modelToolModule.unhighlightModel(t),this.removeModelsFromHighlightState(t),this.engine.events.trigger(pi.SelectionChanged,t))}excludeHighlightedModels(e){const t=new Map;return(this.engine.engineStatus.highlightModels??[]).forEach(i=>{t.has(i.url)||t.set(i.url,new Set),i.ids.forEach(n=>t.get(i.url)?.add(n))}),e.map(i=>({url:i.url,ids:i.ids.filter(n=>!t.get(i.url)?.has(n))})).filter(i=>i.ids.length>0)}keepHighlightedModels(e){const t=new Map;return(this.engine.engineStatus.highlightModels??[]).forEach(i=>{t.has(i.url)||t.set(i.url,new Set),i.ids.forEach(n=>t.get(i.url)?.add(n))}),e.map(i=>({url:i.url,ids:i.ids.filter(n=>t.get(i.url)?.has(n))})).filter(i=>i.ids.length>0)}removeModelsFromHighlightState(e){const t=new Map;e.forEach(i=>{t.has(i.url)||t.set(i.url,new Set),i.ids.forEach(n=>t.get(i.url)?.add(n))}),this.engine.engineStatus.highlightModels=(this.engine.engineStatus.highlightModels??[]).map(i=>({url:i.url,ids:i.ids.filter(n=>!t.get(i.url)?.has(n))})).filter(i=>i.ids.length>0)}getNodeWorldBox(e){if(Array.isArray(e?.infos)&&e.infos.length>0){const t=e.infos.map(i=>i?.box).filter(i=>i instanceof Ot);return this.getMergedBox(t)}if(Array.isArray(e?.indexes)&&e.indexes.length>0){const t=[];return e.indexes.forEach(i=>{const n=this.getSceneModel(i[0]),s=this.getInstanceWorldBox(n,i[1]);s!=null&&t.push(s)}),this.getMergedBox(t)}return null}getInstanceWorldBox(e,t){if(!(e instanceof ti))return null;e.geometry.boundingBox||e.geometry.computeBoundingBox();const i=e.geometry.boundingBox;if(!i)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:i.clone().applyMatrix4(this.tempInstanceMatrix)}projectBoxToScreenRect(e){if(e==null||e.isEmpty())return null;const t=[new A(e.min.x,e.min.y,e.min.z),new A(e.min.x,e.min.y,e.max.z),new A(e.min.x,e.max.y,e.min.z),new A(e.min.x,e.max.y,e.max.z),new A(e.max.x,e.min.y,e.min.z),new A(e.max.x,e.min.y,e.max.z),new A(e.max.x,e.max.y,e.min.z),new A(e.max.x,e.max.y,e.max.z)];let i=1/0,n=1/0,s=-1/0,a=-1/0;return t.forEach(o=>{const l=new Ft(this.engine.camera,this.engine.renderer,this.engine.scene).worldToScreen(o);!Number.isFinite(l.x)||!Number.isFinite(l.y)||(i=Math.min(i,l.x),n=Math.min(n,l.y),s=Math.max(s,l.x),a=Math.max(a,l.y))}),!Number.isFinite(i)||!Number.isFinite(n)||!Number.isFinite(s)||!Number.isFinite(a)?null:{left:i,top:n,right:s,bottom:a}}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 Ot().makeEmpty();return e.forEach(i=>t.union(i)),t.isEmpty()?null:t}getSceneModel(e){return this.engine.scene.children.find(t=>t.index===e)??this.engine.scene.children[e]}}class tU{engine;highlightMaterial;hideMaterial;translucentMaterial;constructor(e){this.engine=e,this.highlightMaterial=new Rt({color:43775,depthTest:!1,depthWrite:!1,transparent:!0,opacity:.5,side:Ht}),this.hideMaterial=new Rt({color:0,transparent:!0,opacity:0,side:Ht}),this.translucentMaterial=new Rt({color:16777215,transparent:!0,opacity:.05,side:Ht}),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 ti)return;let t=e.materialClone.clone(),i=Ka(e.geometrys,!0);i.computeVertexNormals(),i.groups.forEach(n=>{n.materialIndex=0}),e.geometry=i,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 i=new Map;t.ids.forEach(s=>{let a=this.engine.models.find(o=>o.url==t.url).nodesMap.get(s);a!=null&&a.indexes!=null&&a.indexes.forEach(o=>{this.getSceneModel(o[0])instanceof ti?i.has(o[0])?i.get(o[0])?.push(o[1]):i.set(o[0],[o[1]]):(console.log(this.getSceneModel(o[0]).materialClone.color),this.split_merge_model(this.getSceneModel(o[0])),this.getSceneModel(o[0]).geometry.groups[o[1]].materialIndex=1)})}),iU(i,this.engine);let n=this.engine.engineStatus.highlightModels.find(s=>s.url==t.url);n!=null?n.ids.push(...t.ids):this.engine.engineStatus.highlightModels.push(t)})}unhighlightModel(e){e.forEach(t=>{let i=new Map;t.ids.forEach(n=>{let s=this.engine.models.find(a=>a.url==t.url).nodesMap.get(n);s!=null&&s.indexes!=null&&s.indexes.forEach(a=>{this.getSceneModel(a[0])instanceof ti?i.has(a[0])?i.get(a[0])?.push(a[1]):i.set(a[0],[a[1]]):this.getSceneModel(a[0]).geometry.groups[a[1]].materialIndex=0})}),pM(i,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 i=new Map;t.ids.forEach(s=>{let a=this.engine.models.find(o=>o.url==t.url).nodesMap.get(s);this.engine.modelEdge.hideModelEdge(t.url,s),a!=null&&a.indexes!=null&&a.indexes.forEach(o=>{const l=this.getSceneModel(o[0]);l instanceof ti?i.has(o[0])?i.get(o[0])?.push(o[1]):i.set(o[0],[o[1]]):(this.split_merge_model(this.getSceneModel(o[0])),l.geometry.groups[o[1]].materialIndex=-1,l.geometry.groups[o[1]].visible=!1)})}),i.size>0&&sU(i,this.engine);let n=this.engine.engineStatus.hideModels.find(s=>s.url==t.url);n!=null?n.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 i=new Map;t.ids.forEach(s=>{let a=this.engine.models.find(o=>o.url==t.url).nodesMap.get(s);this.engine.modelEdge.showModelEdge(t.url,s),a!=null&&a.indexes!=null&&a.indexes.forEach(o=>{const l=this.getSceneModel(o[0]);l instanceof ti?i.has(o[0])?i.get(o[0])?.push(o[1]):i.set(o[0],[o[1]]):(l.geometry.groups[o[1]].materialIndex=0,l.geometry.groups[o[1]].visible=!0)})}),i.size>0&&fM(i,this.engine);let n=this.engine.engineStatus.hideModels.find(s=>s.url==t.url);n&&(t.ids.forEach(s=>{const a=n.ids.indexOf(s);a!==-1&&n.ids.splice(a,1)}),n.ids.length===0&&(this.engine.engineStatus.hideModels=this.engine.engineStatus.hideModels.filter(s=>s!==n)))})}isolateModel(e){let t=[];this.engine.models.forEach(i=>{let n={url:i.url,ids:[]},s=e.find(a=>a.url==i.url);for(let a of i.nodesMap)s==null?n.ids.push(a[0]):s.ids.includes(a[0])||n.ids.push(a[0]);t.push(n)});debugger;this.unhighlightAllModels(),this.hideModel(t)}translucentOtherModel(e){let t=[];this.engine.models.forEach(i=>{let n={url:i.url,ids:[]},s=e.find(a=>a.url==i.url);for(let a of i.nodesMap)s==null?n.ids.push(a[0]):s.ids.includes(a[0])||n.ids.push(a[0]);t.push(n)}),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 i=new Map;t.ids.forEach(s=>{let a=this.engine.models.find(o=>o.url==t.url).nodesMap.get(s);a!=null&&a.indexes!=null&&a.indexes.forEach(o=>{const l=this.getSceneModel(o[0]);l instanceof ti?i.has(o[0])?i.get(o[0])?.push(o[1]):i.set(o[0],[o[1]]):(this.split_merge_model(this.getSceneModel(o[0])),l.geometry.groups[o[1]].materialIndex=2)})}),nU(i,this.engine);let n=this.engine.engineStatus.translucentModels.find(s=>s.url==t.url);n!=null?n.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(e=>{let t=new Map;e.ids.forEach(i=>{let n=this.engine.models.find(s=>s.url==e.url).nodesMap.get(i);n!=null&&n.indexes!=null&&n.indexes.forEach(s=>{const a=this.getSceneModel(s[0]);a instanceof ti?t.has(s[0])?t.get(s[0])?.push(s[1]):t.set(s[0],[s[1]]):(this.split_merge_model(this.getSceneModel(s[0])),a.geometry.groups[s[1]].materialIndex=0)})}),t.size>0&&fM(t,this.engine),pM(t,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],i=this.engine.modelMapperBatch.getModelMapper(t.url,t.ids[0]);this.engine.modelMapperBatch.getModelsWithLevelType(i.levelName,i.typeName,n=>{this.engine.modelToolModule.highlightModel(n)})}batchSelectSameLevelModel(e){if(e.length==0)return;let t=e[0],i=this.engine.modelMapperBatch.getModelMapper(t.url,t.ids[0]);this.engine.modelMapperBatch.getModelsWithLevel(i.levelName,n=>{this.engine.modelToolModule.highlightModel(n)})}batchSelectSameTypeModel(e){if(e.length==0)return;let t=e[0],i=this.engine.modelMapperBatch.getModelMapper(t.url,t.ids[0]);this.engine.modelMapperBatch.getModelsWithType(i.typeName,n=>{this.engine.modelToolModule.highlightModel(n)})}}function iU(r,e){r.forEach((t,i)=>{const n=Kc(e,i);if(!(n instanceof ti))return;const s=n.geometry,a=new Rt({color:43775,depthTest:!1,depthWrite:!1,transparent:!0,opacity:.5,side:Ht}),o=new ti(s,a,t.length);o.name="highlightModel",o.key=i;const l=new Map,c=new Ke,h=new Ke;h.makeScale(0,0,0),t.forEach((d,p)=>{n.getMatrixAt(d,c),l.set(d,c.clone()),n.setMatrixAt(d,h),o.setMatrixAt(p,c)}),n.instanceMatrix.needsUpdate=!0,o.instanceMatrix.needsUpdate=!0,e.scene.add(o)})}function pM(r,e,t){r.forEach((i,n)=>{const s=Kc(e,n);s instanceof ti&&(i.forEach(a=>{const o=s.matrixsClone[a];o&&s.setMatrixAt(a,o)}),s.instanceMatrix.needsUpdate=!0,e.scene.children.filter(a=>a.key==n&&a.name==t).forEach(a=>{e.scene.remove(a)}))})}function nU(r,e){r.forEach((t,i)=>{const n=Kc(e,i);if(!(n instanceof ti))return;const s=n.geometry,a=new Rt({color:16777215,transparent:!0,opacity:.05,side:Ht}),o=new ti(s,a,t.length);o.name="translucentModel",o.key=i;const l=new Map,c=new Ke,h=new Ke;h.makeScale(0,0,0),t.forEach((d,p)=>{n.getMatrixAt(d,c),l.set(d,c.clone()),n.setMatrixAt(d,h),o.setMatrixAt(p,c)}),n.instanceMatrix.needsUpdate=!0,o.instanceMatrix.needsUpdate=!0,e.scene.add(o)})}function sU(r,e){e.scene.children.filter(t=>t.name=="highlightModel").forEach(t=>{e.scene.remove(t)}),r.forEach((t,i)=>{const n=Kc(e,i);if(!(n instanceof ti))return;const s=new Map,a=new Ke,o=new Ke;o.makeScale(0,0,0),t.forEach((l,c)=>{n.getMatrixAt(l,a),s.set(l,a.clone()),n.setMatrixAt(l,o)}),n.instanceMatrix.needsUpdate=!0})}function fM(r,e){r.forEach((t,i)=>{const n=Kc(e,i);n instanceof ti&&(t.forEach(s=>{const a=n.matrixs[s];a&&n.setMatrixAt(s,a)}),n.instanceMatrix.needsUpdate=!0)})}function Kc(r,e){return r.scene.children.find(t=>t.index==e)}class rU{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(i=>i instanceof Ar);t&&(t.castShadow=e),this.engine.scene?.traverse(i=>{i.material&&(i.castShadow!==void 0&&(i.castShadow=e),i.receiveShadow!==void 0&&(i.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(n=>n instanceof Ar),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 $p{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 i=this.engine.models.find(a=>a.url==e.url);if(i==null){this.tagDiv.style.display="none";return}let n=i.nodesMap.get(e.ids[0]);if(n.infos&&n.infos.length>0){let a=n.infos[0].name.replace(/\s*\[[a-f0-9-]+\]$/,"");this.tagDiv.innerHTML=a}const s=this.engine.worldToScreen.worldToScreen(t);this.tagDiv?(this.tagDiv.style.left=s.x+10+this.engine.reactBoundingClientRect.left+"px",this.tagDiv.style.top=s.y-10+this.engine.reactBoundingClientRect.top+"px",this.tagDiv.style.display="block"):this.tagDiv&&(this.tagDiv.style.display="none")}init(){this.overlayMaterial=new Rt({color:16777215,transparent:!0,opacity:0,blending:ph,depthWrite:!1}),this.overlayMaterial.clippingPlanes=this.engine.sectionPlane}hightMesh(e,t=16777215,i=.15){this.animState==="fadeOut"&&this.removeOverlayMeshes();const n=(Array.isArray(e)?e:e?[e]:[]).filter(s=>s?.geometry);if(n.length===0){this.clearHighlight();return}this.overlayMaterial.color.set(t),this.overlayMaterial.opacity=0,this.overlayMaterial.userData.targetOpacity=i;for(const s of n){let a=s.geometry.clone();a.computeVertexNormals();const o=new Ve(a,this.overlayMaterial);s.updateWorldMatrix(!0,!1),o.matrix.copy(s.matrixWorld),o.matrixAutoUpdate=!1,this.engine.scene.add(o),this.overlayMeshes.push(o)}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 i=Math.min(e/$p.FADE_IN_MS,1);this.overlayMaterial.opacity=this.easeOutQuad(i)*t,i>=1&&(this.animState="idle")}else if(this.animState==="fadeOut"){const i=Math.min(e/$p.FADE_OUT_MS,1);this.overlayMaterial.opacity=(1-this.easeOutQuad(i))*t,i>=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 Y0={exports:{}},aU=Y0.exports,mM;function oU(){return mM||(mM=1,(function(r,e){(function(t,i){r.exports=i()})(aU,function(){var t=function(){function i(u){return a.appendChild(u.dom),u}function n(u){for(var v=0;v<a.children.length;v++)a.children[v].style.display=v===u?"block":"none";s=u}var s=0,a=document.createElement("div");a.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",a.addEventListener("click",function(u){u.preventDefault(),n(++s%a.children.length)},!1);var o=(performance||Date).now(),l=o,c=0,h=i(new t.Panel("FPS","#0ff","#002")),d=i(new t.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var p=i(new t.Panel("MB","#f08","#201"));return n(0),{REVISION:16,dom:a,addPanel:i,showPanel:n,begin:function(){o=(performance||Date).now()},end:function(){c++;var u=(performance||Date).now();if(d.update(u-o,200),u>l+1e3&&(h.update(1e3*c/(u-l),100),l=u,c=0,p)){var v=performance.memory;p.update(v.usedJSHeapSize/1048576,v.jsHeapSizeLimit/1048576)}return u},update:function(){o=this.end()},domElement:a,setMode:n}};return t.Panel=function(i,n,s){var a=1/0,o=0,l=Math.round,c=l(window.devicePixelRatio||1),h=80*c,d=48*c,p=3*c,u=2*c,v=3*c,m=15*c,g=74*c,f=30*c,y=document.createElement("canvas");y.width=h,y.height=d,y.style.cssText="width:80px;height:48px";var x=y.getContext("2d");return x.font="bold "+9*c+"px Helvetica,Arial,sans-serif",x.textBaseline="top",x.fillStyle=s,x.fillRect(0,0,h,d),x.fillStyle=n,x.fillText(i,p,u),x.fillRect(v,m,g,f),x.fillStyle=s,x.globalAlpha=.9,x.fillRect(v,m,g,f),{dom:y,update:function(_,E){a=Math.min(a,_),o=Math.max(o,_),x.fillStyle=s,x.globalAlpha=1,x.fillRect(0,0,h,m),x.fillStyle=n,x.fillText(l(_)+" "+i+" ("+l(a)+"-"+l(o)+")",p,u),x.drawImage(y,v+c,m,g-c,f,v,m,g-c,f),x.fillRect(v+g-c,m,c,f),x.fillStyle=s,x.globalAlpha=.9,x.fillRect(v+g-c,m,c,l((1-_/E)*f))}}},t})})(Y0)),Y0.exports}var lU=oU();const cU=nb(lU);var Sl=Object.freeze({Linear:Object.freeze({None:function(r){return r},In:function(r){return r},Out:function(r){return r},InOut:function(r){return r}}),Quadratic:Object.freeze({In:function(r){return r*r},Out:function(r){return r*(2-r)},InOut:function(r){return(r*=2)<1?.5*r*r:-.5*(--r*(r-2)-1)}}),Cubic:Object.freeze({In:function(r){return r*r*r},Out:function(r){return--r*r*r+1},InOut:function(r){return(r*=2)<1?.5*r*r*r:.5*((r-=2)*r*r+2)}}),Quartic:Object.freeze({In:function(r){return r*r*r*r},Out:function(r){return 1- --r*r*r*r},InOut:function(r){return(r*=2)<1?.5*r*r*r*r:-.5*((r-=2)*r*r*r-2)}}),Quintic:Object.freeze({In:function(r){return r*r*r*r*r},Out:function(r){return--r*r*r*r*r+1},InOut:function(r){return(r*=2)<1?.5*r*r*r*r*r:.5*((r-=2)*r*r*r*r+2)}}),Sinusoidal:Object.freeze({In:function(r){return 1-Math.sin((1-r)*Math.PI/2)},Out:function(r){return Math.sin(r*Math.PI/2)},InOut:function(r){return .5*(1-Math.sin(Math.PI*(.5-r)))}}),Exponential:Object.freeze({In:function(r){return r===0?0:Math.pow(1024,r-1)},Out:function(r){return r===1?1:1-Math.pow(2,-10*r)},InOut:function(r){return r===0?0:r===1?1:(r*=2)<1?.5*Math.pow(1024,r-1):.5*(-Math.pow(2,-10*(r-1))+2)}}),Circular:Object.freeze({In:function(r){return 1-Math.sqrt(1-r*r)},Out:function(r){return Math.sqrt(1- --r*r)},InOut:function(r){return(r*=2)<1?-.5*(Math.sqrt(1-r*r)-1):.5*(Math.sqrt(1-(r-=2)*r)+1)}}),Elastic:Object.freeze({In:function(r){return r===0?0:r===1?1:-Math.pow(2,10*(r-1))*Math.sin((r-1.1)*5*Math.PI)},Out:function(r){return r===0?0:r===1?1:Math.pow(2,-10*r)*Math.sin((r-.1)*5*Math.PI)+1},InOut:function(r){return r===0?0:r===1?1:(r*=2,r<1?-.5*Math.pow(2,10*(r-1))*Math.sin((r-1.1)*5*Math.PI):.5*Math.pow(2,-10*(r-1))*Math.sin((r-1.1)*5*Math.PI)+1)}}),Back:Object.freeze({In:function(r){var e=1.70158;return r===1?1:r*r*((e+1)*r-e)},Out:function(r){var e=1.70158;return r===0?0:--r*r*((e+1)*r+e)+1},InOut:function(r){var e=2.5949095;return(r*=2)<1?.5*(r*r*((e+1)*r-e)):.5*((r-=2)*r*((e+1)*r+e)+2)}}),Bounce:Object.freeze({In:function(r){return 1-Sl.Bounce.Out(1-r)},Out:function(r){return r<1/2.75?7.5625*r*r:r<2/2.75?7.5625*(r-=1.5/2.75)*r+.75:r<2.5/2.75?7.5625*(r-=2.25/2.75)*r+.9375:7.5625*(r-=2.625/2.75)*r+.984375},InOut:function(r){return r<.5?Sl.Bounce.In(r*2)*.5:Sl.Bounce.Out(r*2-1)*.5+.5}}),generatePow:function(r){return r===void 0&&(r=4),r=r<Number.EPSILON?Number.EPSILON:r,r=r>1e4?1e4:r,{In:function(e){return Math.pow(e,r)},Out:function(e){return 1-Math.pow(1-e,r)},InOut:function(e){return e<.5?Math.pow(e*2,r)/2:(1-Math.pow(2-e*2,r))/2+.5}}}}),$c=function(){return performance.now()},hU=(function(){function r(){this._tweens={},this._tweensAddedDuringUpdate={}}return r.prototype.getAll=function(){var e=this;return Object.keys(this._tweens).map(function(t){return e._tweens[t]})},r.prototype.removeAll=function(){this._tweens={}},r.prototype.add=function(e){this._tweens[e.getId()]=e,this._tweensAddedDuringUpdate[e.getId()]=e},r.prototype.remove=function(e){delete this._tweens[e.getId()],delete this._tweensAddedDuringUpdate[e.getId()]},r.prototype.update=function(e,t){e===void 0&&(e=$c()),t===void 0&&(t=!1);var i=Object.keys(this._tweens);if(i.length===0)return!1;for(;i.length>0;){this._tweensAddedDuringUpdate={};for(var n=0;n<i.length;n++){var s=this._tweens[i[n]],a=!t;s&&s.update(e,a)===!1&&!t&&delete this._tweens[i[n]]}i=Object.keys(this._tweensAddedDuringUpdate)}return!0},r})(),K0={Linear:function(r,e){var t=r.length-1,i=t*e,n=Math.floor(i),s=K0.Utils.Linear;return e<0?s(r[0],r[1],i):e>1?s(r[t],r[t-1],t-i):s(r[n],r[n+1>t?t:n+1],i-n)},Utils:{Linear:function(r,e,t){return(e-r)*t+r}}},gM=(function(){function r(){}return r.nextId=function(){return r._nextId++},r._nextId=0,r})(),$0=new hU,dU=(function(){function r(e,t){t===void 0&&(t=$0),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=Sl.Linear.None,this._interpolationFunction=K0.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=gM.nextId(),this._isChainStopped=!1,this._propertiesAreSetUp=!1,this._goToEnd=!1}return r.prototype.getId=function(){return this._id},r.prototype.isPlaying=function(){return this._isPlaying},r.prototype.isPaused=function(){return this._isPaused},r.prototype.getDuration=function(){return this._duration},r.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},r.prototype.duration=function(e){return e===void 0&&(e=1e3),this._duration=e<0?0:e,this},r.prototype.dynamic=function(e){return e===void 0&&(e=!1),this._isDynamic=e,this},r.prototype.start=function(e,t){if(e===void 0&&(e=$c()),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 i in this._valuesStartRepeat)this._swapEndStartRepeatValues(i),this._valuesStart[i]=this._valuesStartRepeat[i]}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 n={};for(var s in this._valuesEnd)n[s]=this._valuesEnd[s];this._valuesEnd=n}this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat,t)}return this},r.prototype.startFromCurrentValues=function(e){return this.start(e,!0)},r.prototype._setupProperties=function(e,t,i,n,s){for(var a in i){var o=e[a],l=Array.isArray(o),c=l?"array":typeof o,h=!l&&Array.isArray(i[a]);if(!(c==="undefined"||c==="function")){if(h){var d=i[a];if(d.length===0)continue;for(var p=[o],u=0,v=d.length;u<v;u+=1){var m=this._handleRelativeValue(o,d[u]);if(isNaN(m)){h=!1,console.warn("Found invalid interpolation list. Skipping.");break}p.push(m)}h&&(i[a]=p)}if((c==="object"||l)&&o&&!h){t[a]=l?[]:{};var g=o;for(var f in g)t[a][f]=g[f];n[a]=l?[]:{};var d=i[a];if(!this._isDynamic){var y={};for(var f in d)y[f]=d[f];i[a]=d=y}this._setupProperties(g,t[a],d,n[a],s)}else(typeof t[a]>"u"||s)&&(t[a]=o),l||(t[a]*=1),h?n[a]=i[a].slice().reverse():n[a]=t[a]||0}}},r.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},r.prototype.end=function(){return this._goToEnd=!0,this.update(1/0),this},r.prototype.pause=function(e){return e===void 0&&(e=$c()),this._isPaused||!this._isPlaying?this:(this._isPaused=!0,this._pauseStart=e,this._group&&this._group.remove(this),this)},r.prototype.resume=function(e){return e===void 0&&(e=$c()),!this._isPaused||!this._isPlaying?this:(this._isPaused=!1,this._startTime+=e-this._pauseStart,this._pauseStart=0,this._group&&this._group.add(this),this)},r.prototype.stopChainedTweens=function(){for(var e=0,t=this._chainedTweens.length;e<t;e++)this._chainedTweens[e].stop();return this},r.prototype.group=function(e){return e===void 0&&(e=$0),this._group=e,this},r.prototype.delay=function(e){return e===void 0&&(e=0),this._delayTime=e,this},r.prototype.repeat=function(e){return e===void 0&&(e=0),this._initialRepeat=e,this._repeat=e,this},r.prototype.repeatDelay=function(e){return this._repeatDelayTime=e,this},r.prototype.yoyo=function(e){return e===void 0&&(e=!1),this._yoyo=e,this},r.prototype.easing=function(e){return e===void 0&&(e=Sl.Linear.None),this._easingFunction=e,this},r.prototype.interpolation=function(e){return e===void 0&&(e=K0.Linear),this._interpolationFunction=e,this},r.prototype.chain=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return this._chainedTweens=e,this},r.prototype.onStart=function(e){return this._onStartCallback=e,this},r.prototype.onEveryStart=function(e){return this._onEveryStartCallback=e,this},r.prototype.onUpdate=function(e){return this._onUpdateCallback=e,this},r.prototype.onRepeat=function(e){return this._onRepeatCallback=e,this},r.prototype.onComplete=function(e){return this._onCompleteCallback=e,this},r.prototype.onStop=function(e){return this._onStopCallback=e,this},r.prototype.update=function(e,t){var i=this,n;if(e===void 0&&(e=$c()),t===void 0&&(t=!0),this._isPaused)return!0;var s,a=this._startTime+this._duration;if(!this._goToEnd&&!this._isPlaying){if(e>a)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 o=e-this._startTime,l=this._duration+((n=this._repeatDelayTime)!==null&&n!==void 0?n:this._delayTime),c=this._duration+this._repeat*l,h=function(){if(i._duration===0||o>c)return 1;var g=Math.trunc(o/l),f=o-g*l,y=Math.min(f/i._duration,1);return y===0&&o===i._duration?1:y},d=h(),p=this._easingFunction(d);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,p),this._onUpdateCallback&&this._onUpdateCallback(this._object,d),this._duration===0||o>=this._duration)if(this._repeat>0){var u=Math.min(Math.trunc((o-this._duration)/l)+1,this._repeat);isFinite(this._repeat)&&(this._repeat-=u);for(s in this._valuesStartRepeat)!this._yoyo&&typeof this._valuesEnd[s]=="string"&&(this._valuesStartRepeat[s]=this._valuesStartRepeat[s]+parseFloat(this._valuesEnd[s])),this._yoyo&&this._swapEndStartRepeatValues(s),this._valuesStart[s]=this._valuesStartRepeat[s];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 v=0,m=this._chainedTweens.length;v<m;v++)this._chainedTweens[v].start(this._startTime+this._duration,!1);return this._isPlaying=!1,!1}return!0},r.prototype._updateProperties=function(e,t,i,n){for(var s in i)if(t[s]!==void 0){var a=t[s]||0,o=i[s],l=Array.isArray(e[s]),c=Array.isArray(o),h=!l&&c;h?e[s]=this._interpolationFunction(o,n):typeof o=="object"&&o?this._updateProperties(e[s],a,o,n):(o=this._handleRelativeValue(a,o),typeof o=="number"&&(e[s]=a+(o-a)*n))}},r.prototype._handleRelativeValue=function(e,t){return typeof t!="string"?t:t.charAt(0)==="+"||t.charAt(0)==="-"?e+parseFloat(t):parseFloat(t)},r.prototype._swapEndStartRepeatValues=function(e){var t=this._valuesStartRepeat[e],i=this._valuesEnd[e];typeof i=="string"?this._valuesStartRepeat[e]=this._valuesStartRepeat[e]+parseFloat(i):this._valuesStartRepeat[e]=this._valuesEnd[e],this._valuesEnd[e]=t},r})();gM.nextId;var Ps=$0;Ps.getAll.bind(Ps),Ps.removeAll.bind(Ps),Ps.add.bind(Ps),Ps.remove.bind(Ps),Ps.update.bind(Ps);var Jc={Easing:Sl,Tween:dU};const vM={type:"change"},J0={type:"start"},yM={type:"end"},Jp=new br,xM=new ri,uU=Math.cos(70*Lt.DEG2RAD),Oi=new A,wn=2*Math.PI,jt={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Q0=1e-6;class pU extends Bu{constructor(e,t=null){super(e,t),this.state=jt.NONE,this.target=new A,this.cursor=new A,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:Cn.ROTATE,MIDDLE:Cn.DOLLY,RIGHT:Cn.PAN},this.touches={ONE:Tn.ROTATE,TWO:Tn.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 A,this._lastQuaternion=new Ct,this._lastTargetPosition=new A,this._quat=new Ct().setFromUnitVectors(e.up,new A(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new Go,this._sphericalDelta=new Go,this._scale=1,this._panOffset=new A,this._rotateStart=new xe,this._rotateEnd=new xe,this._rotateDelta=new xe,this._panStart=new xe,this._panEnd=new xe,this._panDelta=new xe,this._dollyStart=new xe,this._dollyEnd=new xe,this._dollyDelta=new xe,this._dollyDirection=new A,this._mouse=new xe,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=mU.bind(this),this._onPointerDown=fU.bind(this),this._onPointerUp=gU.bind(this),this._onContextMenu=SU.bind(this),this._onMouseWheel=xU.bind(this),this._onKeyDown=_U.bind(this),this._onTouchStart=bU.bind(this),this._onTouchMove=MU.bind(this),this._onMouseDown=vU.bind(this),this._onMouseMove=yU.bind(this),this._interceptControlDown=wU.bind(this),this._interceptControlUp=EU.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(vM),this.update(),this.state=jt.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;Oi.copy(t).sub(this.target),Oi.applyQuaternion(this._quat),this._spherical.setFromVector3(Oi),this.autoRotate&&this.state===jt.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 i=this.minAzimuthAngle,n=this.maxAzimuthAngle;isFinite(i)&&isFinite(n)&&(i<-Math.PI?i+=wn:i>Math.PI&&(i-=wn),n<-Math.PI?n+=wn:n>Math.PI&&(n-=wn),i<=n?this._spherical.theta=Math.max(i,Math.min(n,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(i+n)/2?Math.max(i,this._spherical.theta):Math.min(n,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 s=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const a=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),s=a!=this._spherical.radius}if(Oi.setFromSpherical(this._spherical),Oi.applyQuaternion(this._quatInverse),t.copy(this.target).add(Oi),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 a=null;if(this.object.isPerspectiveCamera){const o=Oi.length();a=this._clampDistance(o*this._scale);const l=o-a;this.object.position.addScaledVector(this._dollyDirection,l),this.object.updateMatrixWorld(),s=!!l}else if(this.object.isOrthographicCamera){const o=new A(this._mouse.x,this._mouse.y,0);o.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(),s=l!==this.object.zoom;const c=new A(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(o),this.object.updateMatrixWorld(),a=Oi.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;a!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(a).add(this.object.position):(Jp.origin.copy(this.object.position),Jp.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Jp.direction))<uU?this.object.lookAt(this.target):(xM.setFromNormalAndCoplanarPoint(this.object.up,this.target),Jp.intersectPlane(xM,this.target))))}else if(this.object.isOrthographicCamera){const a=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),a!==this.object.zoom&&(this.object.updateProjectionMatrix(),s=!0)}return this._scale=1,this._performCursorZoom=!1,s||this._lastPosition.distanceToSquared(this.object.position)>Q0||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Q0||this._lastTargetPosition.distanceToSquared(this.target)>Q0?(this.dispatchEvent(vM),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?wn/60*this.autoRotateSpeed*e:wn/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){Oi.setFromMatrixColumn(t,0),Oi.multiplyScalar(-e),this._panOffset.add(Oi)}_panUp(e,t){this.screenSpacePanning===!0?Oi.setFromMatrixColumn(t,1):(Oi.setFromMatrixColumn(t,0),Oi.crossVectors(this.object.up,Oi)),Oi.multiplyScalar(e),this._panOffset.add(Oi)}_pan(e,t){const i=this.domElement;if(this.object.isPerspectiveCamera){const n=this.object.position;Oi.copy(n).sub(this.target);let s=Oi.length();s*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*s/i.clientHeight,this.object.matrix),this._panUp(2*t*s/i.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/i.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/i.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 i=this.domElement.getBoundingClientRect(),n=e-i.left,s=t-i.top,a=i.width,o=i.height;this._mouse.x=n/a*2-1,this._mouse.y=-(s/o)*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(wn*this._rotateDelta.x/t.clientHeight),this._rotateUp(wn*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(wn*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(-wn*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(wn*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(-wn*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),i=.5*(e.pageX+t.x),n=.5*(e.pageY+t.y);this._rotateStart.set(i,n)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),n=.5*(e.pageY+t.y);this._panStart.set(i,n)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),i=e.pageX-t.x,n=e.pageY-t.y,s=Math.sqrt(i*i+n*n);this._dollyStart.set(0,s)}_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 i=this._getSecondPointerPosition(e),n=.5*(e.pageX+i.x),s=.5*(e.pageY+i.y);this._rotateEnd.set(n,s)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(wn*this._rotateDelta.x/t.clientHeight),this._rotateUp(wn*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),i=.5*(e.pageX+t.x),n=.5*(e.pageY+t.y);this._panEnd.set(i,n)}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),i=e.pageX-t.x,n=e.pageY-t.y,s=Math.sqrt(i*i+n*n);this._dollyEnd.set(0,s),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 a=(e.pageX+t.x)*.5,o=(e.pageY+t.y)*.5;this._updateZoomParameters(a,o)}_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 xe,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,i={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:i.deltaY*=16;break;case 2:i.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(i.deltaY*=10),i}}function fU(r){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(r.pointerId),this.domElement.ownerDocument.addEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(r)&&(this._addPointer(r),r.pointerType==="touch"?this._onTouchStart(r):this._onMouseDown(r),this._cursorStyle==="grab"&&(this.domElement.style.cursor="grabbing")))}function mU(r){this.enabled!==!1&&(r.pointerType==="touch"?this._onTouchMove(r):this._onMouseMove(r))}function gU(r){switch(this._removePointer(r),this._pointers.length){case 0:this.domElement.releasePointerCapture(r.pointerId),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(yM),this.state=jt.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 vU(r){let e;switch(r.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 Cn.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(r),this.state=jt.DOLLY;break;case Cn.ROTATE:if(r.ctrlKey||r.metaKey||r.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(r),this.state=jt.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(r),this.state=jt.ROTATE}break;case Cn.PAN:if(r.ctrlKey||r.metaKey||r.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(r),this.state=jt.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(r),this.state=jt.PAN}break;default:this.state=jt.NONE}this.state!==jt.NONE&&this.dispatchEvent(J0)}function yU(r){switch(this.state){case jt.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(r);break;case jt.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(r);break;case jt.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(r);break}}function xU(r){this.enabled===!1||this.enableZoom===!1||this.state!==jt.NONE||(r.preventDefault(),this.dispatchEvent(J0),this._handleMouseWheel(this._customWheelEvent(r)),this.dispatchEvent(yM))}function _U(r){this.enabled!==!1&&this._handleKeyDown(r)}function bU(r){switch(this._trackPointer(r),this._pointers.length){case 1:switch(this.touches.ONE){case Tn.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(r),this.state=jt.TOUCH_ROTATE;break;case Tn.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(r),this.state=jt.TOUCH_PAN;break;default:this.state=jt.NONE}break;case 2:switch(this.touches.TWO){case Tn.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(r),this.state=jt.TOUCH_DOLLY_PAN;break;case Tn.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(r),this.state=jt.TOUCH_DOLLY_ROTATE;break;default:this.state=jt.NONE}break;default:this.state=jt.NONE}this.state!==jt.NONE&&this.dispatchEvent(J0)}function MU(r){switch(this._trackPointer(r),this.state){case jt.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(r),this.update();break;case jt.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(r),this.update();break;case jt.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(r),this.update();break;case jt.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(r),this.update();break;default:this.state=jt.NONE}}function SU(r){this.enabled!==!1&&r.preventDefault()}function wU(r){r.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function EU(r){r.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}const Ja=new In,rn=new A,jr=new A,ai=new Ct,_M={X:new A(1,0,0),Y:new A(0,1,0),Z:new A(0,0,1)},ev={type:"change"},bM={type:"mouseDown",mode:null},MM={type:"mouseUp",mode:null},SM={type:"objectChange"};class wM extends Bu{constructor(e,t=null){super(void 0,t);const i=new LU(this);this._root=i;const n=new IU;this._gizmo=n,i.add(n);const s=new DU;this._plane=s,i.add(s);const a=this;function o(x,_){let E=_;Object.defineProperty(a,x,{get:function(){return E!==void 0?E:_},set:function(S){E!==S&&(E=S,s[x]=S,n[x]=S,a.dispatchEvent({type:x+"-changed",value:S}),a.dispatchEvent(ev))}}),a[x]=_,s[x]=_,n[x]=_}o("camera",e),o("object",void 0),o("enabled",!0),o("axis",null),o("mode","translate"),o("translationSnap",null),o("rotationSnap",null),o("scaleSnap",null),o("space","world"),o("size",1),o("dragging",!1),o("showX",!0),o("showY",!0),o("showZ",!0),o("minX",-1/0),o("maxX",1/0),o("minY",-1/0),o("maxY",1/0),o("minZ",-1/0),o("maxZ",1/0);const l=new A,c=new A,h=new Ct,d=new Ct,p=new A,u=new Ct,v=new A,m=new A,g=new A,f=0,y=new A;o("worldPosition",l),o("worldPositionStart",c),o("worldQuaternion",h),o("worldQuaternionStart",d),o("cameraPosition",p),o("cameraQuaternion",u),o("pointStart",v),o("pointEnd",m),o("rotationAxis",g),o("rotationAngle",f),o("eye",y),this._offset=new A,this._startNorm=new A,this._endNorm=new A,this._cameraScale=new A,this._parentPosition=new A,this._parentQuaternion=new Ct,this._parentQuaternionInv=new Ct,this._parentScale=new A,this._worldScaleStart=new A,this._worldQuaternionInv=new Ct,this._worldScale=new A,this._positionStart=new A,this._quaternionStart=new Ct,this._scaleStart=new A,this._getPointer=CU.bind(this),this._onPointerDown=AU.bind(this),this._onPointerHover=TU.bind(this),this._onPointerMove=PU.bind(this),this._onPointerUp=RU.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&&Ja.setFromCamera(e,this.camera);const t=tv(this._gizmo.picker[this.mode],Ja);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&&Ja.setFromCamera(e,this.camera);const t=tv(this._plane,Ja,!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,bM.mode=this.mode,this.dispatchEvent(bM)}}pointerMove(e){const t=this.axis,i=this.mode,n=this.object;let s=this.space;if(i==="scale"?s="local":(t==="E"||t==="XYZE"||t==="XYZ")&&(s="world"),n===void 0||t===null||this.dragging===!1||e!==null&&e.button!==-1)return;e!==null&&Ja.setFromCamera(e,this.camera);const a=tv(this._plane,Ja,!0);if(a){if(this.pointEnd.copy(a.point).sub(this.worldPositionStart),i==="translate")this._offset.copy(this.pointEnd).sub(this.pointStart),s==="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),s==="local"&&t!=="XYZ"?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),n.position.copy(this._offset).add(this._positionStart),this.translationSnap&&(s==="local"&&(n.position.applyQuaternion(ai.copy(this._quaternionStart).invert()),t.search("X")!==-1&&(n.position.x=Math.round(n.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(n.position.y=Math.round(n.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(n.position.z=Math.round(n.position.z/this.translationSnap)*this.translationSnap),n.position.applyQuaternion(this._quaternionStart)),s==="world"&&(n.parent&&n.position.add(rn.setFromMatrixPosition(n.parent.matrixWorld)),t.search("X")!==-1&&(n.position.x=Math.round(n.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(n.position.y=Math.round(n.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(n.position.z=Math.round(n.position.z/this.translationSnap)*this.translationSnap),n.parent&&n.position.sub(rn.setFromMatrixPosition(n.parent.matrixWorld)))),n.position.x=Math.max(this.minX,Math.min(this.maxX,n.position.x)),n.position.y=Math.max(this.minY,Math.min(this.maxY,n.position.y)),n.position.z=Math.max(this.minZ,Math.min(this.maxZ,n.position.z));else if(i==="scale"){if(t.search("XYZ")!==-1){let o=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(o*=-1),jr.set(o,o,o)}else rn.copy(this.pointStart),jr.copy(this.pointEnd),rn.applyQuaternion(this._worldQuaternionInv),jr.applyQuaternion(this._worldQuaternionInv),jr.divide(rn),t.search("X")===-1&&(jr.x=1),t.search("Y")===-1&&(jr.y=1),t.search("Z")===-1&&(jr.z=1);n.scale.copy(this._scaleStart).multiply(jr),this.scaleSnap&&(t.search("X")!==-1&&(n.scale.x=Math.round(n.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Y")!==-1&&(n.scale.y=Math.round(n.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Z")!==-1&&(n.scale.z=Math.round(n.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if(i==="rotate"){this._offset.copy(this.pointEnd).sub(this.pointStart);const o=20/this.worldPosition.distanceTo(rn.setFromMatrixPosition(this.camera.matrixWorld));let l=!1;t==="XYZE"?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(rn.copy(this.rotationAxis).cross(this.eye))*o):(t==="X"||t==="Y"||t==="Z")&&(this.rotationAxis.copy(_M[t]),rn.copy(_M[t]),s==="local"&&rn.applyQuaternion(this.worldQuaternion),rn.cross(this.eye),rn.length()===0?l=!0:this.rotationAngle=this._offset.dot(rn.normalize())*o),(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),s==="local"&&t!=="E"&&t!=="XYZE"?(n.quaternion.copy(this._quaternionStart),n.quaternion.multiply(ai.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),n.quaternion.copy(ai.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),n.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(ev),this.dispatchEvent(SM)}}pointerUp(e){e!==null&&e.button!==0||(this.dragging&&this.axis!==null&&(MM.mode=this.mode,this.dispatchEvent(MM)),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(ev),this.dispatchEvent(SM),this.pointStart.copy(this.pointEnd))}getRaycaster(){return Ja}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,i,n){const s=this._gizmo.materialLib;s.xAxis.color.set(e),s.yAxis.color.set(t),s.zAxis.color.set(i),s.active.color.set(n),s.xAxisTransparent.color.set(e),s.yAxisTransparent.color.set(t),s.zAxisTransparent.color.set(i),s.activeTransparent.color.set(n),s.xAxis._color&&s.xAxis._color.set(e),s.yAxis._color&&s.yAxis._color.set(t),s.zAxis._color&&s.zAxis._color.set(i),s.active._color&&s.active._color.set(n),s.xAxisTransparent._color&&s.xAxisTransparent._color.set(e),s.yAxisTransparent._color&&s.yAxisTransparent._color.set(t),s.zAxisTransparent._color&&s.zAxisTransparent._color.set(i),s.activeTransparent._color&&s.activeTransparent._color.set(n)}}function CU(r){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:r.button};{const e=this.domElement.getBoundingClientRect();return{x:(r.clientX-e.left)/e.width*2-1,y:-(r.clientY-e.top)/e.height*2+1,button:r.button}}}function TU(r){if(this.enabled)switch(r.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(r));break}}function AU(r){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(r.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(r)),this.pointerDown(this._getPointer(r)))}function PU(r){this.enabled&&this.pointerMove(this._getPointer(r))}function RU(r){this.enabled&&(this.domElement.releasePointerCapture(r.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(r)))}function tv(r,e,t){const i=e.intersectObject(r,!0);for(let n=0;n<i.length;n++)if(i[n].object.visible||t)return i[n];return!1}const Qp=new Pi,Kt=new A(0,1,0),EM=new A(0,0,0),CM=new Ke,ef=new Ct,tf=new Ct,Rs=new A,TM=new Ke,Qc=new A(1,0,0),Qa=new A(0,1,0),eh=new A(0,0,1),nf=new A,th=new A,ih=new A;class LU extends bt{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 IU extends bt{constructor(){super(),this.isTransformControlsGizmo=!0,this.type="TransformControlsGizmo";const e=new Rt({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),t=new ii({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),i=e.clone();i.opacity=.15;const n=t.clone();n.opacity=.5;const s=e.clone();s.color.setHex(16711680);const a=e.clone();a.color.setHex(65280);const o=e.clone();o.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 p=e.clone();p.color.setHex(16776960),p.opacity=.25;const u=e.clone();u.color.setHex(16776960);const v=e.clone();v.color.setHex(7895160),this.materialLib={xAxis:s,yAxis:a,zAxis:o,active:u,xAxisTransparent:l,yAxisTransparent:c,zAxisTransparent:h,activeTransparent:p};const m=new Li(0,.04,.1,12);m.translate(0,.05,0);const g=new ni(.08,.08,.08);g.translate(0,.04,0);const f=new ot;f.setAttribute("position",new tt([0,0,0,1,0,0],3));const y=new Li(.0075,.0075,.5,3);y.translate(0,.25,0);function x(B,F){const H=new Gs(B,.0075,3,64,F*Math.PI*2);return H.rotateY(Math.PI/2),H.rotateX(Math.PI/2),H}function _(){const B=new ot;return B.setAttribute("position",new tt([0,0,0,1,1,1],3)),B}const E={X:[[new Ve(m,s),[.5,0,0],[0,0,-Math.PI/2]],[new Ve(m,s),[-.5,0,0],[0,0,Math.PI/2]],[new Ve(y,s),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new Ve(m,a),[0,.5,0]],[new Ve(m,a),[0,-.5,0],[Math.PI,0,0]],[new Ve(y,a)]],Z:[[new Ve(m,o),[0,0,.5],[Math.PI/2,0,0]],[new Ve(m,o),[0,0,-.5],[-Math.PI/2,0,0]],[new Ve(y,o),null,[Math.PI/2,0,0]]],XYZ:[[new Ve(new Vs(.1,0),d),[0,0,0]]],XY:[[new Ve(new ni(.15,.15,.01),h),[.15,.15,0]]],YZ:[[new Ve(new ni(.15,.15,.01),l),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new Ve(new ni(.15,.15,.01),c),[.15,0,.15],[-Math.PI/2,0,0]]]},S={X:[[new Ve(new Li(.2,0,.6,4),i),[.3,0,0],[0,0,-Math.PI/2]],[new Ve(new Li(.2,0,.6,4),i),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new Ve(new Li(.2,0,.6,4),i),[0,.3,0]],[new Ve(new Li(.2,0,.6,4),i),[0,-.3,0],[0,0,Math.PI]]],Z:[[new Ve(new Li(.2,0,.6,4),i),[0,0,.3],[Math.PI/2,0,0]],[new Ve(new Li(.2,0,.6,4),i),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new Ve(new Vs(.2,0),i)]],XY:[[new Ve(new ni(.2,.2,.01),i),[.15,.15,0]]],YZ:[[new Ve(new ni(.2,.2,.01),i),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new Ve(new ni(.2,.2,.01),i),[.15,0,.15],[-Math.PI/2,0,0]]]},C={START:[[new Ve(new Vs(.01,2),n),null,null,null,"helper"]],END:[[new Ve(new Vs(.01,2),n),null,null,null,"helper"]],DELTA:[[new oi(_(),n),null,null,null,"helper"]],X:[[new oi(f,n),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new oi(f,n),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new oi(f,n),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},w={XYZE:[[new Ve(x(.5,1),v),null,[0,Math.PI/2,0]]],X:[[new Ve(x(.5,.5),s)]],Y:[[new Ve(x(.5,.5),a),null,[0,0,-Math.PI/2]]],Z:[[new Ve(x(.5,.5),o),null,[0,Math.PI/2,0]]],E:[[new Ve(x(.75,1),p),null,[0,Math.PI/2,0]]]},M={AXIS:[[new oi(f,n),[-1e3,0,0],null,[1e6,1,1],"helper"]]},R={XYZE:[[new Ve(new Er(.25,10,8),i)]],X:[[new Ve(new Gs(.5,.1,4,24),i),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new Ve(new Gs(.5,.1,4,24),i),[0,0,0],[Math.PI/2,0,0]]],Z:[[new Ve(new Gs(.5,.1,4,24),i),[0,0,0],[0,0,-Math.PI/2]]],E:[[new Ve(new Gs(.75,.1,2,24),i)]]},N={X:[[new Ve(g,s),[.5,0,0],[0,0,-Math.PI/2]],[new Ve(y,s),[0,0,0],[0,0,-Math.PI/2]],[new Ve(g,s),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new Ve(g,a),[0,.5,0]],[new Ve(y,a)],[new Ve(g,a),[0,-.5,0],[0,0,Math.PI]]],Z:[[new Ve(g,o),[0,0,.5],[Math.PI/2,0,0]],[new Ve(y,o),[0,0,0],[Math.PI/2,0,0]],[new Ve(g,o),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new Ve(new ni(.15,.15,.01),h),[.15,.15,0]]],YZ:[[new Ve(new ni(.15,.15,.01),l),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new Ve(new ni(.15,.15,.01),c),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new Ve(new ni(.1,.1,.1),d)]]},L={X:[[new Ve(new Li(.2,0,.6,4),i),[.3,0,0],[0,0,-Math.PI/2]],[new Ve(new Li(.2,0,.6,4),i),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new Ve(new Li(.2,0,.6,4),i),[0,.3,0]],[new Ve(new Li(.2,0,.6,4),i),[0,-.3,0],[0,0,Math.PI]]],Z:[[new Ve(new Li(.2,0,.6,4),i),[0,0,.3],[Math.PI/2,0,0]],[new Ve(new Li(.2,0,.6,4),i),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new Ve(new ni(.2,.2,.01),i),[.15,.15,0]]],YZ:[[new Ve(new ni(.2,.2,.01),i),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new Ve(new ni(.2,.2,.01),i),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new Ve(new ni(.2,.2,.2),i),[0,0,0]]]},O={X:[[new oi(f,n),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new oi(f,n),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new oi(f,n),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function T(B){const F=new bt;for(const H in B)for(let q=B[H].length;q--;){const V=B[H][q][0].clone(),re=B[H][q][1],Y=B[H][q][2],K=B[H][q][3],_e=B[H][q][4];V.name=H,V.tag=_e,re&&V.position.set(re[0],re[1],re[2]),Y&&V.rotation.set(Y[0],Y[1],Y[2]),K&&V.scale.set(K[0],K[1],K[2]),V.updateMatrix();const Ce=V.geometry.clone();Ce.applyMatrix4(V.matrix),V.geometry=Ce,V.renderOrder=1/0,V.position.set(0,0,0),V.rotation.set(0,0,0),V.scale.set(1,1,1),F.add(V)}return F}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=T(E)),this.add(this.gizmo.rotate=T(w)),this.add(this.gizmo.scale=T(N)),this.add(this.picker.translate=T(S)),this.add(this.picker.rotate=T(R)),this.add(this.picker.scale=T(L)),this.add(this.helper.translate=T(C)),this.add(this.helper.rotate=T(M)),this.add(this.helper.scale=T(O)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(e){const t=(this.mode==="scale"?"local":this.space)==="local"?this.worldQuaternion:tf;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 n=0;n<i.length;n++){const s=i[n];s.visible=!0,s.rotation.set(0,0,0),s.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),s.scale.set(1,1,1).multiplyScalar(a*this.size/4),s.tag==="helper"){s.visible=!1,s.name==="AXIS"?(s.visible=!!this.axis,this.axis==="X"&&(ai.setFromEuler(Qp.set(0,0,0)),s.quaternion.copy(t).multiply(ai),Math.abs(Kt.copy(Qc).applyQuaternion(t).dot(this.eye))>.9&&(s.visible=!1)),this.axis==="Y"&&(ai.setFromEuler(Qp.set(0,0,Math.PI/2)),s.quaternion.copy(t).multiply(ai),Math.abs(Kt.copy(Qa).applyQuaternion(t).dot(this.eye))>.9&&(s.visible=!1)),this.axis==="Z"&&(ai.setFromEuler(Qp.set(0,Math.PI/2,0)),s.quaternion.copy(t).multiply(ai),Math.abs(Kt.copy(eh).applyQuaternion(t).dot(this.eye))>.9&&(s.visible=!1)),this.axis==="XYZE"&&(ai.setFromEuler(Qp.set(0,Math.PI/2,0)),Kt.copy(this.rotationAxis),s.quaternion.setFromRotationMatrix(CM.lookAt(EM,Kt,Qa)),s.quaternion.multiply(ai),s.visible=this.dragging),this.axis==="E"&&(s.visible=!1)):s.name==="START"?(s.position.copy(this.worldPositionStart),s.visible=this.dragging):s.name==="END"?(s.position.copy(this.worldPosition),s.visible=this.dragging):s.name==="DELTA"?(s.position.copy(this.worldPositionStart),s.quaternion.copy(this.worldQuaternionStart),rn.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),rn.applyQuaternion(this.worldQuaternionStart.clone().invert()),s.scale.copy(rn),s.visible=this.dragging):(s.quaternion.copy(t),this.dragging?s.position.copy(this.worldPositionStart):s.position.copy(this.worldPosition),this.axis&&(s.visible=this.axis.search(s.name)!==-1));continue}s.quaternion.copy(t),this.mode==="translate"||this.mode==="scale"?(s.name==="X"&&Math.abs(Kt.copy(Qc).applyQuaternion(t).dot(this.eye))>.99&&(s.scale.set(1e-10,1e-10,1e-10),s.visible=!1),s.name==="Y"&&Math.abs(Kt.copy(Qa).applyQuaternion(t).dot(this.eye))>.99&&(s.scale.set(1e-10,1e-10,1e-10),s.visible=!1),s.name==="Z"&&Math.abs(Kt.copy(eh).applyQuaternion(t).dot(this.eye))>.99&&(s.scale.set(1e-10,1e-10,1e-10),s.visible=!1),s.name==="XY"&&Math.abs(Kt.copy(eh).applyQuaternion(t).dot(this.eye))<.2&&(s.scale.set(1e-10,1e-10,1e-10),s.visible=!1),s.name==="YZ"&&Math.abs(Kt.copy(Qc).applyQuaternion(t).dot(this.eye))<.2&&(s.scale.set(1e-10,1e-10,1e-10),s.visible=!1),s.name==="XZ"&&Math.abs(Kt.copy(Qa).applyQuaternion(t).dot(this.eye))<.2&&(s.scale.set(1e-10,1e-10,1e-10),s.visible=!1)):this.mode==="rotate"&&(ef.copy(t),Kt.copy(this.eye).applyQuaternion(ai.copy(t).invert()),s.name.search("E")!==-1&&s.quaternion.setFromRotationMatrix(CM.lookAt(this.eye,EM,Qa)),s.name==="X"&&(ai.setFromAxisAngle(Qc,Math.atan2(-Kt.y,Kt.z)),ai.multiplyQuaternions(ef,ai),s.quaternion.copy(ai)),s.name==="Y"&&(ai.setFromAxisAngle(Qa,Math.atan2(Kt.x,Kt.z)),ai.multiplyQuaternions(ef,ai),s.quaternion.copy(ai)),s.name==="Z"&&(ai.setFromAxisAngle(eh,Math.atan2(Kt.y,Kt.x)),ai.multiplyQuaternions(ef,ai),s.quaternion.copy(ai))),s.visible=s.visible&&(s.name.indexOf("X")===-1||this.showX),s.visible=s.visible&&(s.name.indexOf("Y")===-1||this.showY),s.visible=s.visible&&(s.name.indexOf("Z")===-1||this.showZ),s.visible=s.visible&&(s.name.indexOf("E")===-1||this.showX&&this.showY&&this.showZ),s.material._color=s.material._color||s.material.color.clone(),s.material._opacity=s.material._opacity||s.material.opacity,s.material.color.copy(s.material._color),s.material.opacity=s.material._opacity,this.enabled&&this.axis&&(s.name===this.axis?(s.material.color.copy(this.materialLib.active.color),s.material.opacity=1):this.axis.split("").some(function(o){return s.name===o})&&(s.material.color.copy(this.materialLib.active.color),s.material.opacity=1))}super.updateMatrixWorld(e)}}class DU extends Ve{constructor(){super(new Wn(1e5,1e5,2,2),new Rt({visible:!1,wireframe:!0,side:Ht,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"),nf.copy(Qc).applyQuaternion(t==="local"?this.worldQuaternion:tf),th.copy(Qa).applyQuaternion(t==="local"?this.worldQuaternion:tf),ih.copy(eh).applyQuaternion(t==="local"?this.worldQuaternion:tf),Kt.copy(th),this.mode){case"translate":case"scale":switch(this.axis){case"X":Kt.copy(this.eye).cross(nf),Rs.copy(nf).cross(Kt);break;case"Y":Kt.copy(this.eye).cross(th),Rs.copy(th).cross(Kt);break;case"Z":Kt.copy(this.eye).cross(ih),Rs.copy(ih).cross(Kt);break;case"XY":Rs.copy(ih);break;case"YZ":Rs.copy(nf);break;case"XZ":Kt.copy(ih),Rs.copy(th);break;case"XYZ":case"E":Rs.set(0,0,0);break}break;default:Rs.set(0,0,0)}Rs.length()===0?this.quaternion.copy(this.cameraQuaternion):(TM.lookAt(rn.set(0,0,0),Rs,Kt),this.quaternion.setFromRotationMatrix(TM)),super.updateMatrixWorld(e)}}class NU extends gy{constructor(e){super(e),this.type=xi}parse(e){const t=function(g,f){switch(g){case 1:throw new Error("THREE.HDRLoader: Read Error: "+(f||""));case 2:throw new Error("THREE.HDRLoader: Write Error: "+(f||""));case 3:throw new Error("THREE.HDRLoader: Bad File Format: "+(f||""));default:case 4:throw new Error("THREE.HDRLoader: Memory Error: "+(f||""))}},i=function(g,f,y){f=f||1024;let x=g.pos,_=-1,E=0,S="",C=String.fromCharCode.apply(null,new Uint16Array(g.subarray(x,x+128)));for(;0>(_=C.indexOf(`
|
|
8990
8990
|
`))&&E<f&&x<g.byteLength;)S+=C,E+=C.length,x+=128,C+=String.fromCharCode.apply(null,new Uint16Array(g.subarray(x,x+128)));return-1<_?(g.pos+=E+_+1,S+C.slice(0,_)):!1},n=function(g){const f=/^#\?(\S+)/,y=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,x=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,_=/^\s*FORMAT=(\S+)\s*$/,E=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,S={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};let C,w;for((g.pos>=g.byteLength||!(C=i(g)))&&t(1,"no header found"),(w=C.match(f))||t(3,"bad initial token"),S.valid|=1,S.programtype=w[1],S.string+=C+`
|
|
8991
8991
|
`;C=i(g),C!==!1;){if(S.string+=C+`
|
|
8992
8992
|
`,C.charAt(0)==="#"){S.comments+=C+`
|
|
8993
|
-
`;continue}if((w=C.match(y))&&(S.gamma=parseFloat(w[1])),(w=C.match(x))&&(S.exposure=parseFloat(w[1])),(w=C.match(_))&&(S.valid|=2,S.format=w[1]),(w=C.match(E))&&(S.valid|=4,S.height=parseInt(w[1],10),S.width=parseInt(w[2],10)),S.valid&2&&S.valid&4)break}return S.valid&2||t(3,"missing format specifier"),S.valid&4||t(3,"missing image size specifier"),S},s=function(g,f,y){const x=f;if(x<8||x>32767||g[0]!==2||g[1]!==2||g[2]&128)return new Uint8Array(g);x!==(g[2]<<8|g[3])&&t(3,"wrong scanline width");const _=new Uint8Array(4*f*y);_.length||t(4,"unable to allocate buffer space");let E=0,S=0;const C=4*x,w=new Uint8Array(4),M=new Uint8Array(C);let R=y;for(;R>0&&S<g.byteLength;){S+4>g.byteLength&&t(1),w[0]=g[S++],w[1]=g[S++],w[2]=g[S++],w[3]=g[S++],(w[0]!=2||w[1]!=2||(w[2]<<8|w[3])!=x)&&t(3,"bad rgbe scanline format");let N=0,L;for(;N<C&&S<g.byteLength;){L=g[S++];const T=L>128;if(T&&(L-=128),(L===0||N+L>C)&&t(3,"bad scanline data"),T){const B=g[S++];for(let F=0;F<L;F++)M[N++]=B}else M.set(g.subarray(S,S+L),N),N+=L,S+=L}const O=x;for(let T=0;T<O;T++){let B=0;_[E]=M[T+B],B+=x,_[E+1]=M[T+B],B+=x,_[E+2]=M[T+B],B+=x,_[E+3]=M[T+B],E+=4}R--}return _},a=function(g,f,y,x){const _=g[f+3],E=Math.pow(2,_-128)/255;y[x+0]=g[f+0]*E,y[x+1]=g[f+1]*E,y[x+2]=g[f+2]*E,y[x+3]=1},o=function(g,f,y,x){const _=g[f+3],E=Math.pow(2,_-128)/255;y[x+0]=$l.toHalfFloat(Math.min(g[f+0]*E,65504)),y[x+1]=$l.toHalfFloat(Math.min(g[f+1]*E,65504)),y[x+2]=$l.toHalfFloat(Math.min(g[f+2]*E,65504)),y[x+3]=$l.toHalfFloat(1)},l=new Uint8Array(e);l.pos=0;const c=n(l),h=c.width,d=c.height,p=s(l.subarray(l.pos),h,d);let u,v,m;switch(this.type){case Ai:m=p.length/4;const g=new Float32Array(m*4);for(let y=0;y<m;y++)a(p,y*4,g,y*4);u=g,v=Ai;break;case xi:m=p.length/4;const f=new Uint16Array(m*4);for(let y=0;y<m;y++)o(p,y*4,f,y*4);u=f,v=xi;break;default:throw new Error("THREE.HDRLoader: Unsupported type: "+this.type)}return{width:h,height:d,data:u,header:c.string,gamma:c.gamma,exposure:c.exposure,type:v}}setDataType(e){return this.type=e,this}load(e,t,i,n){function s(a,o){switch(a.type){case Ai:case xi:a.colorSpace=Fi,a.minFilter=Pt,a.magFilter=Pt,a.generateMipmaps=!1,a.flipY=!0;break}t&&t(a,o)}return super.load(e,s,i,n)}}function UU(){return new ra}function kU(r,e){r.appendChild(e.domElement)}function OU(r,e,t){var i=new Object;i.visible=!0;let n=null,s,a,o=[];i.init=function(){s||(c(),h(),m())},i.Hide=function(){s.style.display="none",i.visible=!1},i.Show=function(){s.style.display="block",i.visible=!0},i.RenderScene=function(){if(!d){i.camera.quaternion.copy(e.camera.quaternion);const y=new A(0,0,1).applyQuaternion(e.camera.quaternion);i.camera.position.copy(y.multiplyScalar(100))}i.orbitControls&&i.orbitControls.update(),i.sceneOrtho.renderer.render(i.sceneOrtho,i.camera)},i.ToggleDirectionView=function(y){var x=new A(0,0,0);y=="top"?x=new A(0,1,1e-5):y=="down"?x=new A(0,-1,1e-5):y=="front"?x=new A(0,0,1):y=="left"?x=new A(-1,0,0):y=="back"?x=new A(0,0,-1):y=="right"?x=new A(1,0,0):y=="top_front"?x=new A(1,1,0):y=="top_left"?x=new A(0,1,-1):y=="top_back"?x=new A(-1,1,0):y=="top_right"?x=new A(0,1,1):y=="down_front"?x=new A(1,-1,0):y=="down_left"?x=new A(0,-1,-1):y=="down_back"?x=new A(-1,-1,0):y=="down_right"?x=new A(0,-1,1):y=="front_right"?x=new A(1,0,1):y=="right_back"?x=new A(-1,0,1):y=="back_left"?x=new A(-1,0,-1):y=="left_front"?x=new A(1,0,-1):y=="top_left_front"?x=new A(1,1,-1):y=="top_front_right"?x=new A(1,1,1):y=="top_right_back"?x=new A(-1,1,1):y=="top_back_left"?x=new A(-1,1,-1):y=="button_left_front"?x=new A(1,-1,-1):y=="button_front_right"?x=new A(1,-1,1):y=="button_right_back"?x=new A(-1,1,1):y=="button_back_left"&&(x=new A(-1,-1,-1));var _=r.octreeBox.getBoundingBox(),E=_.min,S=_.max,C=E.clone().add(S.clone()).multiplyScalar(.5),w=C.clone().add(x.multiplyScalar(1*S.distanceTo(E)));l(e.camera.position,w,r.controls.target.clone(),C)},i.GetCameraPose=function(){var y=e.camera.quaternion,x=e.camera.position,_=r.controls.target,E={quaternion:y,position:x,target:_};return E},i.ReductionCameraPose=function(y,x=1e3,_){var E=new Ct(y.quaternion._x,y.quaternion._y,y.quaternion._z,y.quaternion._w),S=new A(y.position.x,y.position.y,y.position.z),C=new A(y.target.x,y.target.y,y.target.z);let w=!1;l(e.camera.position,S,r.controls.target.clone(),C,e.camera.quaternion,E,x,M=>{_&&(w||(_(M),w=!0))}),_&&setTimeout(()=>{w||(_(!0),w=!0)},x+10)},i.CameraGoHome=function(y=1e3){var x=r.octreeBox.getBoundingBox(),_=x.min.clone().add(x.max.clone()).multiplyScalar(.5);let E=new A(1,1,1);var S=x.max.distanceTo(x.min),C=_.clone().add(E.multiplyScalar(S*2));if(r.camera.far=S*5,e.camera.isOrthographicCamera){var w=r.container.clientWidth/r.container.clientHeight,M=S*.6;e.camera.left=-M*w,e.camera.right=M*w,e.camera.top=M,e.camera.bottom=-M,e.camera.zoom=1,e.camera.updateProjectionMatrix()}r.controlModule.orbitControls.origin=_.clone(),l(e.camera.position,C,r.controls.target.clone(),_,null,null,y)},i.zoomToBox=function(y){if(e.camera.isOrthographicCamera){let J=function(){n=requestAnimationFrame(J),be.update()};var x=y.min.clone().add(y.max.clone()).multiplyScalar(.5),_=e.camera.position.clone().sub(r.controls.target.clone()).normalize(),E=e.camera.position.distanceTo(r.controls.target),S=x.clone().add(_.multiplyScalar(E)),C=e.camera.zoom,w=new A(1,0,0).applyQuaternion(e.camera.quaternion),M=new A(0,1,0).applyQuaternion(e.camera.quaternion),R=[new A(y.min.x,y.min.y,y.min.z),new A(y.max.x,y.min.y,y.min.z),new A(y.min.x,y.max.y,y.min.z),new A(y.max.x,y.max.y,y.min.z),new A(y.min.x,y.min.y,y.max.z),new A(y.max.x,y.min.y,y.max.z),new A(y.min.x,y.max.y,y.max.z),new A(y.max.x,y.max.y,y.max.z)],N=1/0,L=-1/0,O=1/0,T=-1/0;for(var B of R){var F=B.dot(w),H=B.dot(M);N=Math.min(N,F),L=Math.max(L,F),O=Math.min(O,H),T=Math.max(T,H)}var q=(L-N)/2,V=(T-O)/2,re=(e.camera.right-e.camera.left)/2,Y=(e.camera.top-e.camera.bottom)/2;C=Math.min(re/q,Y/V)*.75;var K=e.camera.position.clone(),_e=r.controls.target.clone(),Ce=e.camera.zoom,be=new Jc.Tween({x1:K.x,y1:K.y,z1:K.z,x2:_e.x,y2:_e.y,z2:_e.z,zoom:Ce}).to({x1:S.x,y1:S.y,z1:S.z,x2:x.x,y2:x.y,z2:x.z,zoom:C},1e3);be.onUpdate(function(oe){r.controls&&(e.camera.position.set(oe.x1,oe.y1,oe.z1),r.controls.target.set(oe.x2,oe.y2,oe.z2),e.camera.isOrthographicCamera&&(e.camera.zoom=oe.zoom,e.camera.updateProjectionMatrix()),r.controls.auto=!0,r.controls.update(),i.RenderScene())}),be.onComplete(function(){r.controls&&(r.controls.auto=!1,i.RenderScene(),cancelAnimationFrame(n),n=null)}),be.easing(Jc.Easing.Cubic.InOut),be.start(),J()}else{var x=y.min.clone().add(y.max.clone()).multiplyScalar(.5);let oe=e.camera.position.clone().sub(r.controls.target.clone()).normalize();var S=x.clone().add(oe.multiplyScalar(2*y.max.distanceTo(y.min)));l(e.camera.position,S,r.controls.target.clone(),x)}};function l(y,x,_,E,S,C,w=1e3,M){var R;S&&C?(R=new Jc.Tween({x1:y.x,y1:y.y,z1:y.z,x2:_.x,y2:_.y,z2:_.z,_x:S._x,_y:S._y,_z:S._z,_w:S._w}),R.to({x1:x.x,y1:x.y,z1:x.z,x2:E.x,y2:E.y,z2:E.z,_x:C._x,_y:C._y,_z:C._z,_w:C._w},w)):(R=new Jc.Tween({x1:y.x,y1:y.y,z1:y.z,x2:_.x,y2:_.y,z2:_.z}),R.to({x1:x.x,y1:x.y,z1:x.z,x2:E.x,y2:E.y,z2:E.z},w)),R.onUpdate(function(L){r.controls&&(S&&C?(e.camera.quaternion._x=L._x,e.camera.quaternion._y=L._y,e.camera.quaternion._z=L._z,e.camera.quaternion._w=L._w):r.controls.auto=!0,e.camera.position.x=L.x1,e.camera.position.y=L.y1,e.camera.position.z=L.z1,r.controls.target.x=L.x2,r.controls.target.y=L.y2,r.controls.target.z=L.z2,r.controls.update(),i.RenderScene())}),R.onComplete(function(L){r.controls&&(r.controls.auto=!1,i.RenderScene(),M&&M(!0),cancelAnimationFrame(n),n=null)}),R.easing(Jc.Easing.Cubic.InOut);function N(L){n=requestAnimationFrame(N),R.update()}R.start(),N()}function c(){s=document.createElement("div"),s.className="ViewCube",t.appendChild(s),a=document.createElement("div"),a.className="viewSettingWrapper",a.innerHTML="...",s.appendChild(a);var y=document.createElement("div");y.className="homeViewWrapper",y.addEventListener("mousedown",function(){console.log("归位"),i.CameraGoHome()}),s.appendChild(y);const x=document.createElement("div");x.className="cameraToggleWrapper",x.title="切换正交/透视视图",x.innerHTML="⊞",x.addEventListener("mousedown",function(w){w.stopPropagation(),console.log("切换视图"),i.ToggleCameraType(),S()}),s.appendChild(x);const _=document.createElement("div");_.className="screenshotWrapper",_.title="截图",_.innerHTML="📷",_.addEventListener("mousedown",function(w){w.stopPropagation(),console.log("截图"),i.TakeScreenshot(),S()}),s.appendChild(_);const E=document.createElement("div");E.className="fullscreenWrapper",E.title="全屏",E.innerHTML="⛶",E.addEventListener("mousedown",function(w){w.stopPropagation(),console.log("全屏"),i.ToggleFullscreen(),S()}),s.appendChild(E),a.addEventListener("mousedown",function(w){w.stopPropagation(),x.classList.contains("show")?(S(),console.log("隐藏功能按钮")):(C(),console.log("显示功能按钮"))});function S(){x.classList.remove("show"),_.classList.remove("show"),E.classList.remove("show")}function C(){x.classList.add("show"),_.classList.add("show"),E.classList.add("show")}}function h(){i.sceneOrtho=UU();var _=t.clientWidth,E=t.clientWidth,y=_>E?_/E:E/_,x=300;i.camera=new Zi(x*y/-2,x*y/2,x/2,x/-2,.01,1e4);var _=s.clientWidth,E=s.clientHeight,S=new Ec({alpha:!0});S.setSize(_,E),S.setClearAlpha(0),i.sceneOrtho.renderer=S;let C=new zo(16777215,.8);i.sceneOrtho.add(C),kU(s,S),i.orbitControls=new pU(i.camera,s),i.orbitControls.enableZoom=!1,i.orbitControls.enablePan=!1,i.orbitControls.enableDamping=!0,i.orbitControls.dampingFactor=.1,i.orbitControls.rotateSpeed=.5,i.orbitControls.addEventListener("start",p),i.orbitControls.addEventListener("change",u),i.orbitControls.addEventListener("end",v)}let d=!1;function p(){d=!0,r.controls&&(i._mainTarget=r.controls.target.clone(),i._mainDistance=e.camera.position.distanceTo(r.controls.target))}function u(){if(d){if(e.camera.quaternion.copy(i.camera.quaternion),r.controls&&i._mainTarget&&i._mainDistance){const y=new A(0,0,1).applyQuaternion(e.camera.quaternion);e.camera.position.copy(i._mainTarget.clone().add(y.multiplyScalar(i._mainDistance))),r.controls.update()}r.renderer&&e.camera&&r.renderer.render(e,e.camera)}}function v(){d=!1,i._mainTarget=null,i._mainDistance=null}function m(){const y="/assets/viewcube/";let x=[{label:"右",icon:y+"cn_right.png"},{label:"左",icon:y+"cn_left.png"},{label:"顶",icon:y+"cn_top.png"},{label:"底",icon:y+"cn_bottom.png"},{label:"前",icon:y+"cn_front.png"},{label:"后",icon:y+"cn_back.png"}];var _=[];for(const C of x)_.push(new Rt({color:16777215,map:new ba().load(C.icon)}));new ym({color:255});var E=new Ve(new ni(110,110,110),_);i.sceneOrtho.add(E),g(122);let S={x:0,y:0};s.addEventListener("mousedown",C=>{S.x=C.clientX,S.y=C.clientY}),s.addEventListener("mouseup",C=>{if(d)return;const w=C.clientX-S.x,M=C.clientY-S.y;if(Math.sqrt(w*w+M*M)>5)return;var R={};R.x=C.offsetX/s.clientWidth*2-1,R.y=-(C.offsetY/s.clientHeight)*2+1;var N=new In;N.setFromCamera(R,i.camera);const L=N.intersectObjects(o,!1);L.length>0&&i.ToggleDirectionView(L[0].object.name)}),s.addEventListener("mousemove",C=>{var w={};w.x=C.offsetX/s.clientWidth*2-1,w.y=-(C.offsetY/s.clientHeight)*2+1;var M=new In;M.setFromCamera(w,i.camera);const R=M.intersectObjects(o,!1);for(var N of o)N.material.opacity=.01;R.length>0&&(R[0].object.material.opacity=.2)})}function g(y){for(var x=y*.5-20,_=[{name:"right",a:30,b:75,c:75,point:new A(x,0,0)},{name:"back",a:75,b:75,c:30,point:new A(0,0,-x)},{name:"left",a:30,b:75,c:75,point:new A(-x,0,0)},{name:"front",a:75,b:75,c:30,point:new A(0,0,x)},{name:"top",a:75,b:30,c:75,point:new A(0,x,0)},{name:"button",a:75,b:30,c:75,point:new A(0,-x,0)}],E=[{name:"top_right_back",a:30,b:30,c:30,point:new A(-x,x,x)},{name:"button_front_right",a:30,b:30,c:30,point:new A(-x,-x,x)},{name:"top_front_right",a:30,b:30,c:30,point:new A(x,x,x)},{name:"button_right_back",a:30,b:30,c:30,point:new A(x,-x,x)},{name:"top_back_left",a:30,b:30,c:30,point:new A(-x,x,-x)},{name:"button_back_left",a:30,b:30,c:30,point:new A(-x,-x,-x)},{name:"top_left_front",a:30,b:30,c:30,point:new A(x,x,-x)},{name:"button_left_front",a:30,b:30,c:30,point:new A(x,-x,-x)}],S=[{name:"top_front",a:30,b:30,c:75,point:new A(x,x,0)},{name:"top_right",a:75,b:30,c:30,point:new A(0,x,x)},{name:"top_back",a:30,b:30,c:75,point:new A(-x,x,0)},{name:"top_left",a:75,b:30,c:30,point:new A(0,x,-x)},{name:"button_front",a:30,b:30,c:75,point:new A(x,-x,0)},{name:"button_right",a:75,b:30,c:30,point:new A(0,-x,x)},{name:"button_back",a:30,b:30,c:75,point:new A(-x,-x,0)},{name:"button_left",a:75,b:30,c:30,point:new A(0,-x,-x)},{name:"front_right",a:30,b:75,c:30,point:new A(x,0,x)},{name:"right_back",a:30,b:75,c:30,point:new A(-x,0,x)},{name:"back_left",a:30,b:75,c:30,point:new A(-x,0,-x)},{name:"left_front",a:30,b:75,c:30,point:new A(x,0,-x)}],C=0;C<_.length;C++)o.push(f(_[C]));for(var C=0;C<E.length;C++)o.push(f(E[C]));for(var C=0;C<S.length;C++)o.push(f(S[C]))}function f(y){const x=new ni(y.a,y.b,y.c),_=new Rt({color:"blue",transparent:!0,opacity:.01}),E=new Ke().makeTranslation(y.point.x,y.point.y,y.point.z);let S=x.applyMatrix4(E),C=new Ve(S,_);return C.name=y.name,i.sceneOrtho.add(C),C}return i.ToggleCameraType=function(){r.cameraModule.switchCurrentCamera()},i.TakeScreenshot=function(){try{if(!r.renderer){console.error("渲染器未初始化");return}r.renderer.render(e,e.camera);const y=r.renderer.domElement.toDataURL("image/png"),x=document.createElement("a"),_=new Date().toISOString().replaceAll(/[:.]/g,"-");x.download=`screenshot_${_}.png`,x.href=y,x.click(),console.log("截图已保存")}catch(y){console.error("截图失败:",y)}},i.ToggleFullscreen=function(){const y=t||document.documentElement;!document.fullscreenElement&&!document.webkitFullscreenElement&&!document.mozFullScreenElement&&!document.msFullscreenElement?(y.requestFullscreen?y.requestFullscreen():y.webkitRequestFullscreen?y.webkitRequestFullscreen():y.mozRequestFullScreen?y.mozRequestFullScreen():y.msRequestFullscreen&&y.msRequestFullscreen(),console.log("已进入全屏模式")):(document.exitFullscreen?document.exitFullscreen():document.webkitExitFullscreen?document.webkitExitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.msExitFullscreen&&document.msExitFullscreen(),console.log("已退出全屏模式"))},i}class BU{engine;cubeTool;constructor(e){this.engine=e}init(){this.cubeTool=OU(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(i=>i.url==e.url);this.cubeTool.zoomToBox(t.nodesMap.get(e.id).infos[0].box)}catch{}}hide(){}}function FU(r){let e=new Object;return e.getBoundingBox=function(){let t=r.models,i=new A(1e8,1e9,1e10),n=new A(-1e8,-1e9,-1e10);t.forEach(d=>{let p=new A(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 A(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));p.x<i.x&&(i.x=p.x),p.y<i.y&&(i.y=p.y),p.z<i.z&&(i.z=p.z),u.x>n.x&&(n.x=u.x),u.y>n.y&&(n.y=u.y),u.z>n.z&&(n.z=u.z)});let s=Math.min(i.x,n.x),a=Math.min(i.y,n.y),o=Math.min(i.z,n.z),l=Math.max(i.x,n.x),c=Math.max(i.y,n.y),h=Math.max(i.z,n.z);return{min:new A(s,a,o),max:new A(l,c,h)}},e.rayInterationModel=function(t,i){let n=[];return r.engineStatus.models.forEach(a=>{a.info.lods.forEach(o=>{let l=o.octreeBox;s(t,l,a)})}),n=n.filter(a=>a instanceof Ve),n=n.filter(a=>t.ray.intersectsBox(new Ot().setFromObject(a),!1)==!0),t.intersectObjects(n,!1);function s(a,o,l){if(o==null)return;let c=new A(o.min.X*.3048,o.min.Z*.3048,-o.min.Y*.3048),h=new A(o.max.X*.3048,o.max.Z*.3048,-o.max.Y*.3048),d=new A(Math.min(c.x,h.X),Math.min(c.y,h.y),Math.min(c.z,h.z)),p=new A(Math.max(h.x,c.x),Math.max(h.y,c.y),Math.max(h.z,c.z)),u=new Ot(d,p),v=a.ray.intersectsBox(u);if(!(v==null||v==!1))if(o.children==null||o.children.length==0){if(o.elements!=null)for(var m of o.elements){if(!r.engineStatus.isFree&&i==!1)continue;let g=r.engineStatus.hideModels.find(x=>x.url==l.url)?.ids;if(g!=null&&g.includes(m))continue;let f=r.engineStatus.translucentModels.find(x=>x.url==l.url)?.ids;if(f!=null&&f.includes(m))continue;let y=r.models.find(x=>x.url==l.url).nodesMap.get(m);y!=null&&!y.instance&&y.infos.map(x=>x.mesh).forEach(x=>{n.push(x)})}}else{if(o.elements!=null)for(var m of o.elements){let f=r.engineStatus.hideModels.find(_=>_.url==l.url)?.ids;if(f!=null&&f.includes(m))continue;let y=r.engineStatus.translucentModels.find(_=>_.url==l.url)?.ids;if(y!=null&&y.includes(m))continue;let x=r.models.find(_=>_.url==l.url).nodesMap.get(m);x!=null&&!x.instance&&x.infos.map(_=>_.mesh).forEach(_=>{n.push(_)})}for(let g of o.children)s(a,g,l)}}},e}class zU{engine;isDrawing=!1;startPoint=new xe;endPoint=new xe;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 Ft(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 e=Math.min(this.startPoint.x,this.endPoint.x),t=Math.min(this.startPoint.y,this.endPoint.y),i=Math.abs(this.endPoint.x-this.startPoint.x),n=Math.abs(this.endPoint.y-this.startPoint.y);this.selectionBox.style.left=`${e}px`,this.selectionBox.style.top=`${t}px`,this.selectionBox.style.width=`${i}px`,this.selectionBox.style.height=`${n}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 i=Math.min(this.startPoint.x,this.endPoint.x),n=Math.max(this.startPoint.x,this.endPoint.x),s=Math.min(this.startPoint.y,this.endPoint.y),a=Math.max(this.startPoint.y,this.endPoint.y),o=[],l=[{x:i,y:s},{x:n,y:s},{x:n,y:a},{x:i,y:a}];for(const h of l){const d=this.worldToScreen.screenToWorld(h.x,h.y);d&&o.push(d)}if(o.length<3){console.warn("RangeScale: 框选区域未命中模型,无法执行缩放操作");return}if(o.length<3){console.warn("RangeScale: 无法将屏幕区域转换为世界坐标");return}const c=new Ot;for(const h of o)c.expandByPoint(h);if(c.isEmpty()){console.warn("RangeScale: 计算得到的包围盒无效");return}this.fitCameraToBoundingBox(c)}fitCameraToBoundingBox(e){const t=this.engine.camera,i=this.engine.controls;if(!t||!i){console.warn("RangeScale: 相机或控制器未初始化");return}const n=new A;e.getCenter(n);const s=new A;e.getSize(s);const a=Math.max(s.x,s.y,s.z);if(t instanceof ci){const o=t.fov*(Math.PI/180),l=a/(2*Math.tan(o/2))*1.2,c=new A;t.getWorldDirection(c);const h=n.clone().sub(t.position);c.dot(h.normalize())<0&&c.negate();const d=n.clone().sub(c.multiplyScalar(l));t.position.copy(d),i.target&&i.target.copy(n),t.lookAt(n),i.update()}else if(t instanceof Zi){const o=a*1.2,l=this.engine.renderer?.domElement,c=l?l.width/l.height:1;t.left=-o*c/2,t.right=o*c/2,t.top=o/2,t.bottom=-o/2,t.updateProjectionMatrix();const h=new A;t.getWorldDirection(h);const d=a*1.5,p=n.clone().sub(h.multiplyScalar(d));t.position.copy(p),i.target&&i.target.copy(n),t.lookAt(n),i.update()}}}const AM={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 HU{engine;settings;environmentApplyVersion=0;constructor(e){this.engine=e,this.settings=this._clone(AM)}init(){}getSettings(){return this._clone(this.settings)}getPresetLists(){const e=this.engine.ground?.getGroundList()||[],t=this.engine.hdr?.getHdrList()||[],i=this.engine.skyManager?.getPresetList()||[];return{ground:e.map(n=>this._toPresetItem(n)),hdr:t.map(n=>this._toPresetItem(n)),sky:i.map(n=>this._toPresetItem(n))}}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(AM),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(i=>i instanceof zo);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(i=>i instanceof Ar);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 or(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(r){var e=Math.random()*16|0,t=r=="x"?e:e&3|8;return t.toString(16)})}class lr{engine;handelBehaved;setting;constructor(e){this.engine=e,this.handelBehaved=P0(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 i=this.setting.unit,n=i;return t==1?i=="mm"?e=e*1e3:i=="cm"?e=e*100:i=="dm"?e=e*10:i=="m"?e=e*1:i=="km"&&(e=e*.001):t==2&&(i=="mm"?e=e*1e3*1e3:i=="cm"?e=e*100*100:i=="dm"?e=e*10*10:i=="m"?e=e*1*1:i=="km"&&(e=e*.001*.001),n=n+"²"),e.toFixed(this.setting.precision)+" "+n}cancelCurrentSelectedAnnotation(){let e=this.engine.measure.annotationData;for(let t in e)e[t].forEach(i=>{i.highlight==!0&&(i.highlight=!1,i.container.classList.remove("Hight"),i.container.getElementsByTagName("svg")[0].classList.remove("Hight"))})}handelKeyEscDown(){this.cancelCurrentSelectedAnnotation();let e=this.engine.measure.annotationData;for(let t in e)for(let i=e[t].length-1;i>=0;i--){let n=e[t][i];n.isSelect==!0&&(n.container.remove(),e[t].splice(i,1))}this.engine.measure.clearAllPoints()}handelKeyDeleteDown(){let e=this.engine.measure.annotationData;for(let t in e)for(let i=e[t].length-1;i>=0;i--){let n=e[t][i];n.highlight==!0&&(n.container.remove(),e[t].splice(i,1))}}clearHighlight(){let e=this.engine.measure.annotationData;for(let t in e)e[t].forEach(i=>{i.highlight=!1,i.container.classList.remove("Hight"),i.container.getElementsByTagName("svg")[0].classList.remove("Hight")})}drawNormalAnnotation(){let e=this;this.engine.measure.annotationData.normalAnnotation.forEach(l=>{o(l)}),this.engine.measure.annotationData.elevationAnnotation.forEach(l=>{a(l)}),this.engine.measure.annotationData.coordinateAnnotation.forEach(l=>{s(l)}),this.engine.measure.annotationData.angleAnnotation.forEach(l=>{t(l)}),this.engine.measure.annotationData.areaAnnotation.forEach(l=>{i(l)}),this.engine.measure.annotationData.slopeAnnotation.forEach(l=>{n(l)});function t(l){if(l.container==null){let f=['<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">'+l.text+"</text>","</svg>"].join("");l.container=document.createElement("div"),l.container.className="angle-annotation",l.container.id=l.id,l.container.style.pointerEvents="none",l.container.innerHTML=f,e.engine.measure.annotationContainer.appendChild(l.container),l.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),l.container.getElementsByTagName("svg")[0].classList.add("Hight"),l.highlight=!0,e.engine.events.trigger(pi.MeasureClick,l)}),l.isSelect&&(l.container.getElementsByTagName("svg")[0].classList.add("Hight"),l.highlight=!0)}let c=new Ft(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(l.point1),h=new Ft(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(l.point2),d=new Ft(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(l.point3),p=e.engine.reactBoundingClientRect.left,u=e.engine.reactBoundingClientRect.top;c.x+=p,c.y+=u,h.x+=p,h.y+=u,d.x+=p,d.y+=u;let v=l.container;v.getElementsByTagName("circle")[0].setAttribute("cx",c.x),v.getElementsByTagName("circle")[0].setAttribute("cy",c.y),v.getElementsByTagName("circle")[1].setAttribute("cx",h.x),v.getElementsByTagName("circle")[1].setAttribute("cy",h.y),v.getElementsByTagName("circle")[2].setAttribute("cx",d.x),v.getElementsByTagName("circle")[2].setAttribute("cy",d.y),v.getElementsByTagName("polyline")[0].setAttribute("points",c.x+","+c.y+" "+h.x+","+h.y),v.getElementsByTagName("polyline")[1].setAttribute("points",h.x+","+h.y+" "+d.x+","+d.y);let m=h.x,g=h.y-30;v.getElementsByTagName("rect")[0].setAttribute("x",m-40),v.getElementsByTagName("rect")[0].setAttribute("y",g-12.5),v.getElementsByTagName("text")[0].setAttribute("x",m),v.getElementsByTagName("text")[0].setAttribute("y",g+4),v.getElementsByTagName("text")[0].innerHTML=l.text,v.style.top="0px",v.style.left="0px"}function i(l){if(l.container==null){let y=['<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(l.text,2)+"</text>","</svg>"].join("");l.container=document.createElement("div"),l.container.className="area-annotation",l.container.id=l.id,l.container.innerHTML=y,e.engine.measure.annotationContainer.appendChild(l.container),l.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),l.container.getElementsByTagName("svg")[0].classList.add("Hight"),l.highlight=!0,e.engine.events.trigger(pi.MeasureClick,l)}),l.isSelect&&(l.container.getElementsByTagName("svg")[0].classList.add("Hight"),l.highlight=!0)}if(!l.points||l.points.length<3)return;let c=e.engine.reactBoundingClientRect.left,h=e.engine.reactBoundingClientRect.top,d=[],p=0,u=0;for(let y=0;y<l.points.length;y++){let x=new Ft(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(l.points[y]);x.x+=c,x.y+=h,d.push(x),p+=x.x,u+=x.y}p=p/d.length,u=u/d.length;let v=d.map(y=>y.x+","+y.y).join(" "),m=l.container;m.getElementsByTagName("polygon")[0].setAttribute("points",v),m.getElementsByTagName("polyline")[0].setAttribute("points",v);let g=p,f=u;m.getElementsByTagName("rect")[0].setAttribute("x",g-40),m.getElementsByTagName("rect")[0].setAttribute("y",f-12.5),m.getElementsByTagName("text")[0].setAttribute("x",g),m.getElementsByTagName("text")[0].setAttribute("y",f+4),m.getElementsByTagName("text")[0].innerHTML=e.getMeasureText(l.text,2),m.style.top="0px",m.style.left="0px"}function n(l){if(l.container==null){let g=['<svg class="measureSvg">',"<defs>",'<marker id="slope-arrow-'+l.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-'+l.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">'+l.text+"</text>","</svg>"].join("");l.container=document.createElement("div"),l.container.className="slope-annotation",l.container.id=l.id,l.container.innerHTML=g,e.engine.measure.annotationContainer.appendChild(l.container),l.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),l.container.getElementsByTagName("svg")[0].classList.add("Hight"),l.highlight=!0,e.engine.events.trigger(pi.MeasureClick,l)}),l.isSelect&&(l.container.getElementsByTagName("svg")[0].classList.add("Hight"),l.highlight=!0)}let c=new Ft(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(l.point1),h=new Ft(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(l.point2),d=e.engine.reactBoundingClientRect.left,p=e.engine.reactBoundingClientRect.top;c.x+=d,c.y+=p,h.x+=d,h.y+=p;let u=l.container;u.getElementsByTagName("polyline")[0].setAttribute("points",c.x+","+c.y+" "+h.x+","+h.y);let v=(c.x+h.x)/2,m=(c.y+h.y)/2-30;u.getElementsByTagName("rect")[0].setAttribute("x",v-50),u.getElementsByTagName("rect")[0].setAttribute("y",m-12.5),u.getElementsByTagName("text")[0].setAttribute("x",v),u.getElementsByTagName("text")[0].setAttribute("y",m+4),u.getElementsByTagName("text")[0].innerHTML=l.text,u.style.top="0px",u.style.left="0px"}function s(l){if(l.container==null){let f=['<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(l.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(-l.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(l.textY,1)+"</text>","</svg>"].join("");l.container=document.createElement("div"),l.container.className="coordinate-annotation",l.container.id=l.id,l.container.style.position="absolute",l.container.style.pointerEvents="none",l.container.innerHTML=f,e.engine.measure.annotationContainer.appendChild(l.container),l.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),l.container.getElementsByTagName("svg")[0].classList.add("Hight"),l.highlight=!0,e.engine.events.trigger(pi.MeasureClick,l)}),l.isSelect&&(l.container.getElementsByTagName("svg")[0].classList.add("Hight"),l.highlight=!0)}let c=l.container,h=new Ft(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(l.point),d=e.engine.reactBoundingClientRect.left,p=e.engine.reactBoundingClientRect.top;h.x+=d,h.y+=p,c.style.top="0px",c.style.left="0px";let u=c.getElementsByTagName("circle")[0];u&&(u.setAttribute("cx",h.x),u.setAttribute("cy",h.y));let v=c.getElementsByTagName("rect"),m=c.getElementsByTagName("text"),g=-55;v[0]&&(v[0].setAttribute("x",h.x+10),v[0].setAttribute("y",h.y+10+g)),m[0]&&(m[0].setAttribute("x",h.x+10+40),m[0].setAttribute("y",h.y+10+16+g)),v[1]&&(v[1].setAttribute("x",h.x+10),v[1].setAttribute("y",h.y+10+30+g)),m[1]&&(m[1].setAttribute("x",h.x+10+40),m[1].setAttribute("y",h.y+10+46+g)),v[2]&&(v[2].setAttribute("x",h.x+10),v[2].setAttribute("y",h.y+10+60+g)),m[2]&&(m[2].setAttribute("x",h.x+10+40),m[2].setAttribute("y",h.y+10+76+g)),m[0]&&(m[0].innerHTML="X: "+e.getMeasureText(l.textX,1)),m[1]&&(m[1].innerHTML="Y: "+e.getMeasureText(-l.textZ,1)),m[2]&&(m[2].innerHTML="Z: "+e.getMeasureText(l.textY,1))}function a(l){if(l.container==null){let u=['<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(l.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("");l.container=document.createElement("div"),l.container.className="elevation-annotation",l.container.id=l.id,l.container.style.position="absolute",l.container.style.pointerEvents="none",l.container.innerHTML=u,e.engine.measure.annotationContainer.appendChild(l.container),l.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),l.container.getElementsByTagName("svg")[0].classList.add("Hight"),l.highlight=!0,e.engine.events.trigger(pi.MeasureClick,l)}),l.isSelect&&(l.container.getElementsByTagName("svg")[0].classList.add("Hight"),l.highlight=!0)}let c=l.container,h=new Ft(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(l.point),d=e.engine.reactBoundingClientRect.left,p=e.engine.reactBoundingClientRect.top;c.style.top=h.y+p-48+"px",c.style.left=h.x+d-16+"px",c.getElementsByTagName("text")[0].innerHTML=e.getMeasureText(l.text,1)}function o(l){if(l.container==null){let v=['<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(l.text,1)+"</text>","</svg>"].join("");l.container=document.createElement("div"),l.container.className="normal-annotation",l.container.id=l.id,l.container.innerHTML=v,e.engine.measure.annotationContainer.appendChild(l.container),l.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),l.container.getElementsByTagName("svg")[0].classList.add("Hight"),l.highlight=!0,e.engine.events.trigger(pi.MeasureClick,l)}),l.isSelect&&(l.container.getElementsByTagName("svg")[0].classList.add("Hight"),l.highlight=!0)}let c=l.container;if(l.point1==null||l.point2==null){c.style.display="none";return}else c.style.display="block";let h=new Ft(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(l.point1),d=new Ft(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(l.point2),p=e.engine.reactBoundingClientRect.left,u=e.engine.reactBoundingClientRect.top;h.x+=p,h.y+=u,d.x+=p,d.y+=u,c.getElementsByTagName("polyline")[0].setAttribute("points",h.x+","+h.y+" "+d.x+","+d.y),c.getElementsByTagName("circle")[0].setAttribute("cx",h.x),c.getElementsByTagName("circle")[0].setAttribute("cy",h.y),c.getElementsByTagName("circle")[1].setAttribute("cx",d.x),c.getElementsByTagName("circle")[1].setAttribute("cy",d.y),c.getElementsByTagName("rect")[0].setAttribute("x",h.x*.5+d.x*.5-40),c.getElementsByTagName("rect")[0].setAttribute("y",h.y*.5+d.y*.5-12.5),c.getElementsByTagName("text")[0].setAttribute("x",h.x*.5+d.x*.5+40-40),c.getElementsByTagName("text")[0].setAttribute("y",h.y*.5+d.y*.5+16-12.5),c.getElementsByTagName("text")[0].innerHTML=e.getMeasureText(l.text,1),c.style.top="0px",c.style.left="0px"}}}class VU{engine;isActive=!1;tools;points=[];behavior;catchDir=0;type="point";constructor(e){this.engine=e,this.tools=new lr(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,i=Number.NEGATIVE_INFINITY;for(let n=0;n<e.length;n++){const s=e[n];if(!s)continue;typeof s.updateMatrixWorld=="function"&&s.updateMatrixWorld(!0);const a=new Ot().setFromObject(s);!Number.isFinite(a.min.y)||!Number.isFinite(a.max.y)||(a.min.y<t&&(t=a.min.y),a.max.y>i&&(i=a.max.y))}return!Number.isFinite(t)||!Number.isFinite(i)?null:{minY:t,maxY:i}}handleMouseClick(e){if(e.catch==null)return;let t=e.catch.point;if(this.type=="element"){let s=this.engine.interactionModule.getCatchMeshs(e);var i=this.getMeshesMinMaxY(s);this.catchDir==0?t.set(t.x,i?.minY,t.z):t.set(t.x,i?.maxY,t.z)}else t=e.catch.point;if(this.points.length==0){this.engine.measure.tools.clearHighlight(),this.points.push(t);return}let n=this.engine.measure.annotationData.normalAnnotation.find(s=>s.isSelect==!0);n!=null&&(n.isSelect=!1)}handleMouseMove(e){if(e.catch==null||this.points.length==0)return;let t=this.engine.measure.annotationData.normalAnnotation.find(n=>n.isSelect==!0);t==null&&(t={text:null,id:or(),isSelect:!0,type:"clear-height"},this.engine.measure.annotationData.normalAnnotation.push(t));let i=e.catch;if(this.type=="element"){let n=e.catch.point.clone();n.set(n.x,this.points[0].y,n.z);let s=new In(n.add(new A(0,.01,0)),new A(0,this.catchDir==0?-1:1,0));i.point=this.points[0];const a=this.engine.clipping?.filterIntersectionsByClipping(this.engine.octreeBox.rayInterationModel(s))??this.engine.octreeBox.rayInterationModel(s);if(a.length===0){t.point2=null;return}t.point1=n,t.point2=a[0].point,t.text=t.point1.clone().distanceTo(t.point2.clone()),this.engine.events.trigger(pi.MeasureChanged,t)}else{let n=new In(e.catch.point.clone().add(new A(0,.01,0)),new A(0,this.catchDir==0?-1:1,0));const s=this.engine.clipping?.filterIntersectionsByClipping(this.engine.octreeBox.rayInterationModel(n))??this.engine.octreeBox.rayInterationModel(n);if(s.length===0){t.point2=null;return}t.point1=i.point,t.point2=s[0].point,t.text=t.point1.clone().distanceTo(t.point2.clone()),this.engine.events.trigger(pi.MeasureChanged,t)}}}class GU{engine;tools;isActive=!1;points=[];behavior;constructor(e){this.engine=e,this.tools=new lr(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 i=this.engine.measure.annotationData.normalAnnotation.find(n=>n.isSelect==!0);if(i==null)return;i.point2=t.point,i.isSelect=!1,this.points=[],this.engine.events.trigger(pi.MeasureChanged,i)}}handleMouseMove(e){if(e.catch==null)return;let t=e.catch;if(t!=null&&this.points.length==1){let i=this.engine.measure.annotationData.normalAnnotation.find(n=>n.isSelect==!0);i==null&&(i={id:or(),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(i)),i.point2=t.point,i.text=i.point1.clone().distanceTo(i.point2.clone())}}}class WU{engine;isActive=!1;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new lr(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(i=>i.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(a=>a.isSelect==!0);t==null&&(t={text:null,id:or(),isSelect:!0,type:"clear-distance"},this.engine.measure.annotationData.normalAnnotation.push(t));let i=new In(e.catch.point.clone().add(e.catch.face.normal.clone().setLength(.01)),e.catch.face.normal);const n=this.engine.clipping?.filterIntersectionsByClipping(this.engine.octreeBox.rayInterationModel(i))??this.engine.octreeBox.rayInterationModel(i);if(n.length==0){t.point2=null;return}let s=e.catch;t.point1=s.point,t.point2=n[0].point,t.text=t.point1.clone().distanceTo(t.point2.clone()),this.engine.events.trigger(pi.MeasureChanged,t)}}class XU{engine;isActive=!1;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new lr(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(i=>i.isSelect==!0);t==null&&(t={id:or(),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(i=>i.isSelect==!0);t!=null&&(t.isSelect=!1,t.point=e.catch.point.clone(),t.text=e.catch.point.y,this.engine.events.trigger(pi.MeasureChanged,t))}}class jU{engine;isActive=!1;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new lr(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(i=>i.isSelect==!0);t==null&&(t={id:or(),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(i=>i.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(pi.MeasureChanged,t))}createMeasure(){let e=this.engine.measure.annotationData.coordinateAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1,this.engine.events.trigger(pi.MeasureChanged,e))}}class qU{engine;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new lr(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,i){const n=new A().subVectors(e,t),s=new A().subVectors(i,t),a=n.length(),o=s.length();if(a===0||o===0)return 0;const l=n.dot(s)/(a*o),c=Math.max(-1,Math.min(1,l));return Math.acos(c)*(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 i=this.engine.measure.annotationData.angleAnnotation.find(n=>n.isSelect==!0);if(i==null)return;i.point3=t.point.clone(),i.angle=this.calculateAngle(i.point1,i.point2,i.point3),i.text=i.angle.toFixed(2)+"°",i.isSelect=!1,i.type="angle",this.points=[],this.engine.events.trigger(pi.MeasureChanged,i)}}handleMouseMove(e){if(e.catch!=null&&this.points.length!=1&&this.points.length==2){let t=this.engine.measure.annotationData.angleAnnotation.find(i=>i.isSelect==!0);t==null&&(t={id:or(),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 ZU{engine;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new lr(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 i=e.length;for(let n=0;n<i;n++){const s=(n+1)%i;t+=e[n].x*e[s].z,t-=e[s].x*e[n].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 i=this.engine.measure.annotationData.areaAnnotation.find(n=>n.isSelect==!0);i==null?(i={id:or(),points:this.points.map(n=>n.clone()),area:0,text:0,isSelect:!0,type:"area"},this.engine.measure.annotationData.areaAnnotation.push(i)):(this.points.push(t.point.clone()),i.points=this.points.map(n=>n.clone())),i.area=this.calculateArea(i.points),i.text=i.area,console.log("面积",i.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(i=>i.isSelect==!0);if(t==null){if(this.points.length>=2){let i=this.points.map(n=>n.clone());i.push(e.catch.point.clone()),i.length>=3&&(t={id:or(),points:i,area:0,text:0,isSelect:!0,type:"area"},this.engine.measure.annotationData.areaAnnotation.push(t))}}else if(t.points.length>0){const i=t.points.length-1;t.points[i]=e.catch.point.clone()}else t.points=this.points.map(i=>i.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(pi.MeasureChanged,e))}}class YU{engine;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new lr(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 i=t.y-e.y,n=t.x-e.x,s=t.z-e.z,a=Math.sqrt(n*n+s*s);if(a===0)return{percentage:0,angle:0,heightDiff:i,horizontalDist:0,type:"slope"};const o=i/a*100,l=Math.atan(i/a)*(180/Math.PI);return{percentage:o,angle:l,heightDiff:i,horizontalDist:a,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 i=this.engine.measure.annotationData.slopeAnnotation.find(s=>s.isSelect==!0);if(i==null)return;console.log("进来了"),i.point2=t.point.clone();const n=this.calculateSlope(i.point1,i.point2);i.slopePercentage=n.percentage,i.slopeAngle=n.angle,i.heightDiff=n.heightDiff,i.horizontalDist=n.horizontalDist,i.text=n.percentage.toFixed(2)+"% ("+n.angle.toFixed(2)+"°)",i.isSelect=!1,this.points=[],this.engine.events.trigger(pi.MeasureChanged,i)}}handleMouseMove(e){if(e.catch==null)return;let t=e.catch;if(t!=null&&this.points.length==1){let i=this.engine.measure.annotationData.slopeAnnotation.find(s=>s.isSelect==!0);i==null&&(i={id:or(),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(i)),i.point2=t.point.clone();const n=this.calculateSlope(i.point1,i.point2);i.slopePercentage=n.percentage,i.slopeAngle=n.angle,i.heightDiff=n.heightDiff,i.horizontalDist=n.horizontalDist,i.text=n.percentage.toFixed(2)+"% ("+n.angle.toFixed(2)+"°)"}}}class KU{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 VU(e),this.distanceMeasure=new GU(e),this.clearDistanceMeasure=new WU(e),this.elevationMeasure=new XU(e),this.pointMeasure=new jU(e),this.angleMeasure=new qU(e),this.areaMeasure=new ZU(e),this.slopeMeasure=new YU(e),this.tools=new lr(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 i=0;i<t.length;i++)t[i].container.remove();t=[]}}saveSetting(e){this.tools.saveSetting(e)}getSetting(){return this.tools.getSetting()}update(){this.isActive&&this.tools.drawNormalAnnotation()}}class $U{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),i=t.intersectObjects(this.getInteractiveMeshes(),!1);i.length!==0&&(e.preventDefault(),e.stopImmediatePropagation(),this.handleMouseDown({button:e.button,raycaster:t,intersects:i}))};handleNativeMouseMove=e=>{if(!this.isDrag&&!(this.isCtrlDown||e.ctrlKey)){this.resetMeshOpacity();return}const t=this.createRaycasterFromMouseEvent(e),i=t.intersectObjects(this.getInteractiveMeshes(),!1);this.isDrag&&(e.preventDefault(),e.stopImmediatePropagation()),this.handleMouseMove({raycaster:t,intersects:i})};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 i=t[0];this.isDrag=!0,this.pickPoint=i.point.clone(),this.pickMesh=i.object;const n=this.pickMesh?.userData?.dragNormal?.clone?.(),s=i.face?.normal?.clone?.();if(this.pickNormal=(n??s??new A(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 a=new ri;a.setFromNormalAndCoplanarPoint(new A(0,1,0),this.pickPoint),this.plane=a}else{const a=new A(this.engine.camera.position.x,this.pickPoint.y,this.engine.camera.position.z),o=new ri;o.setFromNormalAndCoplanarPoint(a.clone().sub(this.pickPoint.clone()).setLength(1),this.pickPoint),this.plane=o}}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,i){return new A(Math.max(t.x,Math.min(i.x,e.x)),Math.max(t.y,Math.min(i.y,e.y)),Math.max(t.z,Math.min(i.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 i=new A;if(e.raycaster.ray.intersectPlane(this.plane,i)){const n=i.clone().sub(this.pickPoint.clone()).dot(this.pickNormal.clone());if(this.pickMesh?.userData?.isMinFace){const s=this.box_.min.clone().add(this.pickNormal.clone().setLength(n));this.box.min=this.clampVector3(s,this.maxBox.min,this.box.max)}else{const s=this.box_.max.clone().add(this.pickNormal.clone().setLength(n));this.box.max=this.clampVector3(s,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,i=this.maxBox.max.z-this.maxBox.min.z,n=this.toPercent((this.box.min.x-this.maxBox.min.x)/e*100),s=this.toPercent((this.box.max.x-this.maxBox.min.x)/e*100),a=this.toPercent((this.box.min.y-this.maxBox.min.y)/t*100),o=this.toPercent((this.box.max.y-this.maxBox.min.y)/t*100),l=this.toPercent((this.box.min.z-this.maxBox.min.z)/i*100),c=this.toPercent((this.box.max.z-this.maxBox.min.z)/i*100),h={x:{min:n,max:s},y:{min:a,max:o},z:{min:l,max:c}};this.engine.events.trigger(pi.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 In,i=new xe,n=this.engine.renderer.domElement.clientWidth,s=this.engine.renderer.domElement.clientHeight;return i.x=e.offsetX/n*2-1,i.y=-(e.offsetY/s)*2+1,t.setFromCamera(i,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 i=e.getHelper(),n=[];i.traverse(s=>{if(s?.name!==t||!s.geometry)return;const a=s.geometry;a.boundingBox||a.computeBoundingBox();const o=a.boundingBox;if(!o)return;const l=o.getCenter(new A);if(!(t==="X"&&l.x<0||t==="Y"&&l.y<0||t==="Z"&&l.z<0))return;const c=a.parameters,h=c&&c.radiusTop===0&&c.radiusBottom===.04&&c.height===.1,d=c&&c.radiusTop===.2&&c.radiusBottom===0&&c.height===.6;(h||d)&&n.push(s)}),n.forEach(s=>{s.parent?.remove(s)})}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,i=this.engine.camera;if(!t||!i)return;const n=new bt;n.name=`SectionBoxTransformAnchor_${e}`,n.visible=this.isActive,this.engine.scene.add(n);const s=new wM(i,t);s.name=`SectionBoxTransformControl_${e}`,s.setMode("translate"),s.setSpace("local"),s.showX=!0,s.showY=!1,s.showZ=!1,s.size=.75,s.enabled=this.isActive,s.attach(n),this.keepSingleDirectionArrow(s,"X"),s.addEventListener("dragging-changed",o=>{this.engine.controls.enabled=!o.value}),s.addEventListener("objectChange",()=>{this.handleTransformObjectChange(e)});const a=s.getHelper();a.visible=this.isActive,this.engine.scene.add(a),this.transformAnchors.set(e,n),this.transformControls.set(e,s),this.transformHelpers.set(e,a)}updateFaceTransformControl(e,t,i,n){this.ensureFaceTransformControl(e);const s=this.transformAnchors.get(e),a=this.transformControls.get(e);if(!s||!a)return;const o=this.getFaceTransformOffset(),l=new Ct().setFromUnitVectors(new A(1,0,0),t.clone().normalize()),c=i.clone().add(t.clone().setLength(o));this.faceMetaMap.set(e,{normal:t.clone().normalize(),isMinFace:n,center:i.clone()}),this.isSyncingTransform=!0,s.position.copy(c),s.quaternion.copy(l),s.visible=this.isActive,a.object!==s&&a.attach(s),a.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),i=Math.abs(e.y),n=Math.abs(e.z);return t>=i&&t>=n?"x":i>=t&&i>=n?"y":"z"}handleTransformObjectChange(e){if(this.isSyncingTransform)return;const t=this.transformAnchors.get(e),i=this.faceMetaMap.get(e);if(!t||!i||!this.box||!this.maxBox)return;const n=i.normal,s=this.getDominantAxis(n),a=this.getFaceTransformOffset(),o=n[s],l=t.position[s]-o*a;if(i.isMinFace){const c=this.maxBox.min[s],h=this.box.max[s];this.box.min[s]=Math.max(c,Math.min(h,l))}else{const c=this.box.min[s],h=this.maxBox.max[s];this.box.max[s]=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 bi,t.name="ClippingBox",this.engine.scene.add(t)),[{name:"前",normal:new A(0,0,-1),isMinFace:!0,planePoint:e.min,vertices:[new A(e.min.x,e.max.y,e.min.z),new A(e.max.x,e.max.y,e.min.z),new A(e.max.x,e.min.y,e.min.z),new A(e.min.x,e.min.y,e.min.z)]},{name:"后",normal:new A(0,0,1),isMinFace:!1,planePoint:e.max,vertices:[new A(e.min.x,e.min.y,e.max.z),new A(e.max.x,e.min.y,e.max.z),new A(e.max.x,e.max.y,e.max.z),new A(e.min.x,e.max.y,e.max.z)]},{name:"右",normal:new A(1,0,0),isMinFace:!1,planePoint:e.max,vertices:[new A(e.max.x,e.min.y,e.max.z),new A(e.max.x,e.min.y,e.min.z),new A(e.max.x,e.max.y,e.min.z),new A(e.max.x,e.max.y,e.max.z)]},{name:"左",normal:new A(-1,0,0),isMinFace:!0,planePoint:e.min,vertices:[new A(e.min.x,e.min.y,e.min.z),new A(e.min.x,e.min.y,e.max.z),new A(e.min.x,e.max.y,e.max.z),new A(e.min.x,e.max.y,e.min.z)]},{name:"顶",normal:new A(0,1,0),isMinFace:!1,planePoint:e.max,vertices:[new A(e.min.x,e.max.y,e.max.z),new A(e.max.x,e.max.y,e.max.z),new A(e.max.x,e.max.y,e.min.z),new A(e.min.x,e.max.y,e.min.z)]},{name:"底",normal:new A(0,-1,0),isMinFace:!0,planePoint:e.min,vertices:[new A(e.min.x,e.min.y,e.min.z),new A(e.max.x,e.min.y,e.min.z),new A(e.max.x,e.min.y,e.max.z),new A(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(n=>{n.clippingPlanes=this.engine.sectionPlane}):i.material.clippingPlanes=this.engine.sectionPlane})}createFace(e,t,i,n,s,a){const o=new ot,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];o.setAttribute("position",new wt(l,3)),o.setIndex(c);let h=this.meshs.find(f=>f.name===n);if(h==null){const f=new Rt({color:65280,transparent:!0,opacity:this.faceIdleOpacity,side:Ht});f.polygonOffset=!0,f.polygonOffsetFactor=1,f.polygonOffsetUnits=4,h=new Ve(o,f),h.name=n,e.add(h),this.meshs.push(h)}else h.geometry=o;h.userData={dragNormal:i.clone(),isMinFace:s,faceName:n};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]),p=new ii({color:255}),u=new ot;u.setAttribute("position",new wt(d,3));let v=this.meshs.find(f=>f.name===n+"Line");v==null?(v=new oi(u,p),v.name=n+"Line",e.add(v),this.meshs.push(v)):(v.geometry=u,v.material=p);const m=new A;t.forEach(f=>m.add(f)),m.multiplyScalar(1/t.length),this.updateFaceTransformControl(n,i,m,s);const g=this.engine.sectionPlane.find(f=>f.name==n);g&&g.setFromNormalAndCoplanarPoint(i.clone().setLength(-1),a)}}class JU{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 A(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),i=t.intersectObjects(this.getInteractiveMeshes(),!1);i.length!==0&&(e.preventDefault(),e.stopImmediatePropagation(),this.handleMouseDown({button:e.button,raycaster:t,intersects:i}))};handleNativeMouseMove=e=>{if(!this.isDrag&&!(this.isCtrlDown||e.ctrlKey)){this.resetMeshOpacity();return}const t=this.createRaycasterFromMouseEvent(e),i=t.intersectObjects(this.getInteractiveMeshes(),!1);this.isDrag&&(e.preventDefault(),e.stopImmediatePropagation()),this.handleMouseMove({raycaster:t,intersects:i})};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),i=this.getTransformHandleOffset(),n=this.transformAnchor.position.clone().sub(this.center).dot(e)-i,s=Math.min(t.max,Math.max(t.min,n));Math.abs(s-Number(this.distance))>1e-5?this.updata_face(s):Math.abs(n-s)>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(i=>{i.name.includes("face")&&(i.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(i=>{i.clippingPlanes=e.engine.sectionPlane}):t.material.clippingPlanes=e.engine.sectionPlane,e.engine.clipping.clippingStencil?.addMesh(e.engine.sectionPlane.find(i=>i.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(i=>{i.name.includes("face")&&(i.visible=!1)})})}init(e){const t=this.engine.octreeBox.getBoundingBox();this.box=t,this.distance=0,this.center=new A((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,i){this.angleX=e,this.angleY=t,this.angleZ=i,this.distance=0,this.normal=new A(0,1,0).applyAxisAngle(new A(1,0,0),e).applyAxisAngle(new A(0,0,1),t).applyAxisAngle(new A(0,1,0),i).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 i=this.engine.sectionPlane?.find(n=>n.name==="face");if(i){const n=this.center.clone().add(this.normal.clone().multiplyScalar(t));i.setFromNormalAndCoplanarPoint(this.normal.clone().multiplyScalar(this.direction),n)}}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(i=>{i.clippingPlanes=e.engine.sectionPlane}):t.material.clippingPlanes=e.engine.sectionPlane,e.engine.clipping.clippingStencil?.addMesh(e.engine.sectionPlane.find(i=>i.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(x=>x.type=="Group"&&x.name=="ClippingBox");t==null&&(t=new bi,t.name="ClippingBox",this.engine.scene.add(t));const i=this.normal.clone().normalize(),n=this.center??new A((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=n.clone();const{tangent:s,bitangent:a}=this.getPlaneBasis(i),o=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,p=1/0,u=-1/0;o.forEach(x=>{const _=x.clone().sub(n),E=_.dot(s),S=_.dot(a);h=Math.min(h,E),d=Math.max(d,E),p=Math.min(p,S),u=Math.max(u,S)}),h-=c,d+=c,p-=c,u+=c;const v=i.clone().multiplyScalar(e),m=n.clone().add(s.clone().multiplyScalar(h)).add(a.clone().multiplyScalar(p)).add(v),g=n.clone().add(s.clone().multiplyScalar(d)).add(a.clone().multiplyScalar(p)).add(v),f=n.clone().add(s.clone().multiplyScalar(d)).add(a.clone().multiplyScalar(u)).add(v),y=n.clone().add(s.clone().multiplyScalar(h)).add(a.clone().multiplyScalar(u)).add(v);this.current_center=n.clone().add(v),this.createFace(t,[m,g,f,y],i,"face"),this.updateTransformControl(i)}createFace(e,t,i,n){const s=new ot,a=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]),o=[0,1,2,0,2,3];s.setAttribute("position",new wt(a,3)),s.setIndex(o);let l=this.meshs.find(v=>v.name==n);if(l==null){const v=new Rt({color:65280,transparent:!0,opacity:this.idleOpacity,side:Ht});v.polygonOffset=!0,v.polygonOffsetFactor=1,v.polygonOffsetUnits=4,l=new Ve(s,v),l.name=n,e.add(l),this.meshs.push(l)}else l.geometry=s;l.normal=i.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 ii({color:255}),d=new ot;d.setAttribute("position",new wt(c,3));let p=this.meshs.find(v=>v.name==n+"Line");p==null?(p=new oi(d,h),p.name=n+"Line",e.add(p),this.meshs.push(p)):(p.geometry=d,p.material=h);const u=this.engine.sectionPlane.find(v=>v.name==n);u&&this.current_center&&u.setFromNormalAndCoplanarPoint(i.clone().setLength(this.direction),this.current_center)}getPlaneBasis(e){const t=new A(1,0,0),i=new A(0,1,0),n=new A(0,0,1),s=Math.abs(e.dot(t)),a=Math.abs(e.dot(i)),o=Math.abs(e.dot(n));let l=t;a<=s&&a<=o?l=i:o<=s&&o<=a&&(l=n),l=l.clone().sub(e.clone().multiplyScalar(l.dot(e))).normalize();const c=new A().crossVectors(e,l).normalize();return{tangent:l,bitangent:c}}getBoxCorners(e){return[new A(e.min.x,e.min.y,e.min.z),new A(e.min.x,e.min.y,e.max.z),new A(e.min.x,e.max.y,e.min.z),new A(e.min.x,e.max.y,e.max.z),new A(e.max.x,e.min.y,e.min.z),new A(e.max.x,e.min.y,e.max.z),new A(e.max.x,e.max.y,e.min.z),new A(e.max.x,e.max.y,e.max.z)]}getDistanceRange(e){if(!this.box)return{min:0,max:0};const t=this.center??new A((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),i=this.getBoxCorners(this.box);let n=1/0,s=-1/0;return i.forEach(a=>{const o=a.clone().sub(t).dot(e);n=Math.min(n,o),s=Math.max(s,o)}),{min:n,max:s}}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 i=e.getHelper(),n=[];i.traverse(s=>{if(s?.name!==t||!s.geometry)return;const a=s.geometry;a.boundingBox||a.computeBoundingBox();const o=a.boundingBox;if(!o)return;const l=o.getCenter(new A);if(!(t==="X"&&l.x<0||t==="Y"&&l.y<0||t==="Z"&&l.z<0))return;const c=a.parameters,h=c&&c.radiusTop===0&&c.radiusBottom===.04&&c.height===.1,d=c&&c.radiusTop===.2&&c.radiusBottom===0&&c.height===.6;(h||d)&&n.push(s)}),n.forEach(s=>{s.parent?.remove(s)})}ensureTransformControl(){if(this.transformControl&&this.transformAnchor)return;const e=this.engine.renderer?.domElement,t=this.engine.camera;if(!e||!t)return;const i=new bt;i.name="SectionFaceTransformAnchor",i.visible=this.isActive,this.engine.scene.add(i);const n=new wM(t,e);n.name="SectionFaceTransformControl",n.setMode("translate"),n.setSpace("local"),n.showX=!0,n.showY=!1,n.showZ=!1,n.size=.85,n.enabled=this.isActive,n.attach(i),this.keepSingleDirectionArrow(n,"X"),n.addEventListener("dragging-changed",a=>{this.engine.controls.enabled=!a.value}),n.addEventListener("objectChange",this.handleTransformObjectChange);const s=n.getHelper();s.visible=this.isActive,this.engine.scene.add(s),this.transformAnchor=i,this.transformControl=n,this.transformHelper=s}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(),i=this.current_center.clone().add(e.clone().setLength(t)),n=new Ct().setFromUnitVectors(new A(1,0,0),e.clone().normalize());this.isSyncingTransformControl=!0,this.transformAnchor.position.copy(i),this.transformAnchor.quaternion.copy(n),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 In,i=new xe,n=this.engine.renderer.domElement.clientWidth,s=this.engine.renderer.domElement.clientHeight;return i.x=e.offsetX/n*2-1,i.y=-(e.offsetY/s)*2+1,t.setFromCamera(i,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 i=t[0],n=i.point.clone();this.isDrag=!0,this.pickPoint=n;const s=(i.face?.normal?.clone()??this.normal.clone()).clone();if(s.dot(this.normal)<0&&s.multiplyScalar(-1),s.normalize(),this.pickNormal=s,this.engine.controls.enabled=!1,this.dragStartDistance=Number(this.distance)||0,s.y==0){const a=new ri;a.setFromNormalAndCoplanarPoint(new A(0,1,0),n),this.plane=a}else{const a=new A(this.engine.camera.position.x,n.y,this.engine.camera.position.z),o=new ri;o.setFromNormalAndCoplanarPoint(a.clone().sub(n.clone()).setLength(1),n),this.plane=o}}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 i=this.pickPoint,n=this.pickNormal,s=this.plane;if(i!=null&&n!=null&&s!=null){const a=new A;if(e.raycaster.ray.intersectPlane(s,a)){const o=a.clone().sub(i.clone()).dot(n.clone()),l=this.getDistanceRange(this.normal.clone().normalize()),c=this.dragStartDistance+o;this.distance=Math.min(l.max,Math.max(l.min,c)),this.updata_face(this.distance)}}}}class QU{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 ek{engine;clippingTolerance=1e-4;sectionBox;sectionFace;clippingStencil;currentClippingMode="";constructor(e){this.engine=e;let t=new ri(new A(0,0,1),1e5);t.name="前";let i=new ri(new A(0,0,1),1e5);i.name="左";let n=new ri(new A(0,0,1),1e5);n.name="后";let s=new ri(new A(0,0,1),1e5);s.name="右";let a=new ri(new A(0,0,1),1e5);a.name="顶";let o=new ri(new A(0,0,1),1e5);o.name="底";let l=new ri(new A(0,0,1),1e5);l.name="face",this.engine.sectionPlane=[t,i,n,s,a,o,l]}init(){this.sectionBox=new $U(this.engine),this.sectionFace=new JU(this.engine)}scaleBox(){let e=this.engine.octreeBox.getBoundingBox();this.sectionBox.setBox(e)}clippingModel(e){let t=[];e.forEach(s=>{let a=this.engine.models.find(o=>o.url===s.url);s.ids.forEach(o=>{a.nodesMap.get(o).infos.forEach(l=>{t.push(l.box)})})}),this.active("box");let i=n(t);this.sectionBox.setBox(i);function n(s){let a=new A(1e8,1e9,1e10),o=new A(-1e8,-1e9,-1e10);return s.forEach(l=>{l.min.x<a.x&&(a.x=l.min.x),l.min.y<a.y&&(a.y=l.min.y),l.min.z<a.z&&(a.z=l.min.z),l.max.x>o.x&&(o.x=l.max.x),l.max.y>o.y&&(o.y=l.max.y),l.max.z>o.z&&(o.z=l.max.z)}),new Ot(a,o)}}updateClippingValue(e){let t=this.sectionBox.maxBox,i=t.min.x+(t.max.x-t.min.x)*e.x.min*.01,n=t.min.y+(t.max.y-t.min.y)*e.y.min*.01,s=t.min.z+(t.max.z-t.min.z)*e.z.min*.01,a=t.min.x+(t.max.x-t.min.x)*e.x.max*.01,o=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:i,minY:n,minZ:s,maxX:a,maxY:o,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 QU(this.engine);t.init(),t.catch_face(i=>{this.sectionFace.init(),this.sectionFace.active();let n=this.engine.octreeBox.getBoundingBox(),s=n.min.clone().add(n.max.clone()).multiplyScalar(.5),a=i.position.clone().sub(s),o=new A(i.dir.x,i.dir.y,i.dir.z),l=a.dot(o);this.sectionFace.setFaceNormal(i.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 i=this.getEffectiveClippingPlanes();return i.length===0?!0:i.every(n=>n.distanceToPoint(e)>=-t)}filterIntersectionsByClipping(e,t=this.clippingTolerance){return!Array.isArray(e)||e.length===0?[]:e.filter(i=>this.isPointInClippingRange(i?.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 ri);if(this.currentClippingMode==="x"||this.currentClippingMode==="y"||this.currentClippingMode==="z"||this.currentClippingMode==="face"){const t=e[6];return t instanceof ri?[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 i=this.engine.octreeBox.getBoundingBox(),n=new A((i.min.x+i.max.x)/2,(i.min.y+i.max.y)/2,(i.min.z+i.max.z)/2),s=new A(t.x,t.y,t.z).normalize().clone().negate(),a=new A(e.x,e.y,e.z).clone().sub(n).dot(s);this.sectionFace.setFaceNormalPlaneOnly(s,a),this.sectionFace.activateClippingOnly(),this.currentClippingMode="face"}}class tk{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 ik{engine;constructor(e){this.engine=e}getEngineInfo(){let e=0,t=0,i=0;return!this.engine||!this.engine.scene?{totalVertices:0,totalTriangles:0,meshCount:0}:(this.engine.scene.traverse(n=>{if(n instanceof Ve){const s=n.geometry;if(s&&s.attributes){const a=s.attributes.position;if(a){const o=a.count;e+=o;let l=0;s.index?l=s.index.count/3:l=o/3,t+=l}}}}),this.engine.engineStatus.models.forEach(n=>{i=i+(Array.isArray(n?.info?.modelEdge)?n.info.modelEdge.length:0)}),{totalVertices:Math.floor(e),totalTriangles:Math.floor(t),meshCount:i})}}class nk{engine;constructor(e){this.engine=e}init(){}getModelPropertiesWithName(e,t,i,n){let s=this.engine.engineStatus.models.find(o=>o.url===e);s.properties==null?qc(e+"/property",o=>{let l=JSON.parse(o);s.properties=l,setTimeout(()=>{a(l,i,t,n)},100)}):a(s.properties,i,t,n);function a(o,l,c,h){let d={};o.models[c.toString()||""].forEach(p=>{i.includes(o.names[p[1]])&&(d[o.names[p[1]]]=o.values[p[2]])}),h?.({id:c,properties:d})}}getModelProperties(e,t,i){let n=this.engine.engineStatus.models.find(a=>a.url===e);n.properties==null&&qc(e+"/property",a=>{let o=JSON.parse(a);n.properties=o,setTimeout(()=>{s(o,t,i)},100)}),s(n.properties,t,i);function s(a,o,l){let c=[],h=a.models[o.toString()||""],d=h.map(p=>p[0]);d=d.filter((p,u)=>d.indexOf(p)===u),d.forEach(p=>{let u={name:a.categorys[p],children:[]};c.push(u),h.filter(v=>v[0]===p).forEach(v=>{u.children.push({name:a.names[v[1]],value:a.values[v[2]]})})}),l?.({properties:c,materials:c})}}}class sk{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,i,n)=>n.indexOf(t)===i),e}getModelMajors(){let e=[];return this.engine.engineStatus.models.forEach(t=>{t.info.modelMapper.forEach(i=>{e.push(i.majorName)})}),e=e.filter((t,i,n)=>n.indexOf(t)===i),e}getModelLevels(){let e=[];return this.engine.engineStatus.models.forEach(t=>{t.info.modelMapper.forEach(i=>{e.push(i.levelName)})}),e=e.filter((t,i,n)=>n.indexOf(t)===i),e}getModelMappers(e){}getModelMapper(e,t){let i=this.engine.engineStatus.models.find(n=>n.url==e);return i?i.info.modelMapper.find(n=>n.id==t):null}getModelsWithLevelType(e,t,i=null){let n=[];return this.engine.engineStatus.models.forEach(s=>{let a={url:s.url,ids:[]};n.push(a),s.info.modelMapper.filter(o=>o.levelName===e&&o.typeName===t).forEach(o=>{a.ids.push(Number(o.id))})}),i&&i(n),n}getModelsWithType(e,t=null){let i=[];return this.engine.engineStatus.models.forEach(n=>{let s={url:n.url,ids:[]};i.push(s),n.info.modelMapper.filter(a=>a.typeName===e).forEach(a=>{s.ids.push(Number(a.id))})}),t&&t(i),i}getModelsWithLevel(e,t){let i=[];return this.engine.engineStatus.models.forEach(n=>{let s={url:n.url,ids:[]};i.push(s),n.info.modelMapper.filter(a=>a.levelName===e).forEach(a=>{s.ids.push(Number(a.id))})}),t&&t(i),i}getModelsWithMajor(e,t){let i=[];return this.engine.engineStatus.models.forEach(n=>{let s={url:n.url,ids:[]};i.push(s),n.info.modelMapper.filter(a=>a.majorName===e).forEach(a=>{s.ids.push(Number(a.id))})}),t&&t(i),i}}class rk{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 ii({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(t=>{t.polygonOffset=!0,t.polygonOffsetFactor=1,t.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(t=>{t.polygonOffset=!1})})}hasPendingModelEdges(){return(this.engine?.engineStatus?.models??[]).some(e=>!this.indexes.has(e.url))}loadZipJsonAsync(e){return new Promise((t,i)=>{qc(e,n=>{if(n==null){i(new Error(`[ModelEdge] empty edge zip: ${e}`));return}t(n)},()=>{i(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 i=await this.loadZipJsonAsync(e.url+"/edge"),n=JSON.parse(i);t.modelEdge=Array.isArray(n)?n:[]}catch(i){console.error("[ModelEdge] failed to load model edge",{url:e?.url,error:i}),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 i=await this.ensureModelEdgeData(t),n=[],s=new Map;i.forEach(a=>{if(!Array.isArray(a?.points))return;const o=n.length;for(let l=0;l<a.points.length;l++)a.points[l]?.length===2&&(n.push(a.points[l][0].X),n.push(a.points[l][0].Z),n.push(-a.points[l][0].Y),n.push(a.points[l][1].X),n.push(a.points[l][1].Z),n.push(-a.points[l][1].Y));s.set(Number(a.id),[o,n.length,a.points])}),this.indexes.set(t.url,s)}this.modelEdgeLoaded=!this.hasPendingModelEdges()})().finally(()=>{this.modelEdgeLoadingPromise=null}),await this.modelEdgeLoadingPromise}}async show(){await this.loadModelEdge(),this.isActive&&this.indexes.forEach((e,t)=>{const i=this.groupEdge.children.find(o=>o.url==t);if(i){i.visible=!0;return}const n=[];if(e.forEach(o=>{o[2].forEach(l=>{l?.length===2&&(n.push(l[0].X),n.push(l[0].Z),n.push(-l[0].Y),n.push(l[1].X),n.push(l[1].Z),n.push(-l[1].Y))})}),n.length===0)return;const s=new ot;s.setAttribute("position",new tt(n,3));const a=new fi(s,this.material);a.url=t,this.groupEdge.add(a)})}getModelEdge(e,t){const i=this.indexes.get(e);if(i){const n=i.get(Number(t));if(n)return n.slice()}return this.loadModelEdge(),null}hideModelEdge(e,t){const i=this.indexes.get(e);if(!i){this.loadModelEdge();return}const n=i.get(Number(t));if(n){const[s,a]=n,o=this.groupEdge.children.find(l=>l.url==e);if(o){const l=o.geometry.attributes.position.array;for(let c=s;c<a;c++)l[c]=NaN;o.geometry.attributes.position.needsUpdate=!0}}}setOpacity(e){this.material.opacity=e}showModelEdge(e,t){const i=this.indexes.get(e);if(!i){this.loadModelEdge();return}const n=i.get(Number(t));if(n){const[s,a,o]=n,l=this.groupEdge.children.find(c=>c.url==e);if(l){const c=l.geometry.attributes.position.array;let h=0;for(let d=s;d<a;d+=3){const p=Math.floor(h/6),u=h%6>=3;if(o[p]&&o[p].length===2){const v=u?o[p][1]:o[p][0];c[d]=v.X,c[d+1]=v.Z,c[d+2]=-v.Y}h+=3}l.geometry.attributes.position.needsUpdate=!0}}}}class ak{config;constructor(e){this.config={temperature:.7,maxTokens:2e4,timeout:3e5,...e}}async chat(e){const t=new AbortController,i=setTimeout(()=>t.abort(),this.config.timeout);try{const n=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(i),!n.ok){const s=await n.json().catch(()=>({}));throw new Error(`API请求失败 (${n.status}): ${s.error?.message||s.message||n.statusText}`)}return(await n.json()).choices?.[0]?.message?.content||""}catch(n){throw clearTimeout(i),n.name==="AbortError"?new Error("请求超时,请重试"):n.message.includes("Failed to fetch")?new Error(`网络请求失败,请检查:
|
|
8993
|
+
`;continue}if((w=C.match(y))&&(S.gamma=parseFloat(w[1])),(w=C.match(x))&&(S.exposure=parseFloat(w[1])),(w=C.match(_))&&(S.valid|=2,S.format=w[1]),(w=C.match(E))&&(S.valid|=4,S.height=parseInt(w[1],10),S.width=parseInt(w[2],10)),S.valid&2&&S.valid&4)break}return S.valid&2||t(3,"missing format specifier"),S.valid&4||t(3,"missing image size specifier"),S},s=function(g,f,y){const x=f;if(x<8||x>32767||g[0]!==2||g[1]!==2||g[2]&128)return new Uint8Array(g);x!==(g[2]<<8|g[3])&&t(3,"wrong scanline width");const _=new Uint8Array(4*f*y);_.length||t(4,"unable to allocate buffer space");let E=0,S=0;const C=4*x,w=new Uint8Array(4),M=new Uint8Array(C);let R=y;for(;R>0&&S<g.byteLength;){S+4>g.byteLength&&t(1),w[0]=g[S++],w[1]=g[S++],w[2]=g[S++],w[3]=g[S++],(w[0]!=2||w[1]!=2||(w[2]<<8|w[3])!=x)&&t(3,"bad rgbe scanline format");let N=0,L;for(;N<C&&S<g.byteLength;){L=g[S++];const T=L>128;if(T&&(L-=128),(L===0||N+L>C)&&t(3,"bad scanline data"),T){const B=g[S++];for(let F=0;F<L;F++)M[N++]=B}else M.set(g.subarray(S,S+L),N),N+=L,S+=L}const O=x;for(let T=0;T<O;T++){let B=0;_[E]=M[T+B],B+=x,_[E+1]=M[T+B],B+=x,_[E+2]=M[T+B],B+=x,_[E+3]=M[T+B],E+=4}R--}return _},a=function(g,f,y,x){const _=g[f+3],E=Math.pow(2,_-128)/255;y[x+0]=g[f+0]*E,y[x+1]=g[f+1]*E,y[x+2]=g[f+2]*E,y[x+3]=1},o=function(g,f,y,x){const _=g[f+3],E=Math.pow(2,_-128)/255;y[x+0]=$l.toHalfFloat(Math.min(g[f+0]*E,65504)),y[x+1]=$l.toHalfFloat(Math.min(g[f+1]*E,65504)),y[x+2]=$l.toHalfFloat(Math.min(g[f+2]*E,65504)),y[x+3]=$l.toHalfFloat(1)},l=new Uint8Array(e);l.pos=0;const c=n(l),h=c.width,d=c.height,p=s(l.subarray(l.pos),h,d);let u,v,m;switch(this.type){case Ai:m=p.length/4;const g=new Float32Array(m*4);for(let y=0;y<m;y++)a(p,y*4,g,y*4);u=g,v=Ai;break;case xi:m=p.length/4;const f=new Uint16Array(m*4);for(let y=0;y<m;y++)o(p,y*4,f,y*4);u=f,v=xi;break;default:throw new Error("THREE.HDRLoader: Unsupported type: "+this.type)}return{width:h,height:d,data:u,header:c.string,gamma:c.gamma,exposure:c.exposure,type:v}}setDataType(e){return this.type=e,this}load(e,t,i,n){function s(a,o){switch(a.type){case Ai:case xi:a.colorSpace=Fi,a.minFilter=Pt,a.magFilter=Pt,a.generateMipmaps=!1,a.flipY=!0;break}t&&t(a,o)}return super.load(e,s,i,n)}}function UU(){return new ra}function kU(r,e){r.appendChild(e.domElement)}function OU(r,e,t){var i=new Object;i.visible=!0;let n=null,s,a,o=[];i.init=function(){s||(c(),h(),m())},i.Hide=function(){s.style.display="none",i.visible=!1},i.Show=function(){s.style.display="block",i.visible=!0},i.RenderScene=function(){if(!d){i.camera.quaternion.copy(e.camera.quaternion);const y=new A(0,0,1).applyQuaternion(e.camera.quaternion);i.camera.position.copy(y.multiplyScalar(100))}i.orbitControls&&i.orbitControls.update(),i.sceneOrtho.renderer.render(i.sceneOrtho,i.camera)},i.ToggleDirectionView=function(y){var x=new A(0,0,0);y=="top"?x=new A(0,1,1e-5):y=="down"?x=new A(0,-1,1e-5):y=="front"?x=new A(0,0,1):y=="left"?x=new A(-1,0,0):y=="back"?x=new A(0,0,-1):y=="right"?x=new A(1,0,0):y=="top_front"?x=new A(1,1,0):y=="top_left"?x=new A(0,1,-1):y=="top_back"?x=new A(-1,1,0):y=="top_right"?x=new A(0,1,1):y=="down_front"?x=new A(1,-1,0):y=="down_left"?x=new A(0,-1,-1):y=="down_back"?x=new A(-1,-1,0):y=="down_right"?x=new A(0,-1,1):y=="front_right"?x=new A(1,0,1):y=="right_back"?x=new A(-1,0,1):y=="back_left"?x=new A(-1,0,-1):y=="left_front"?x=new A(1,0,-1):y=="top_left_front"?x=new A(1,1,-1):y=="top_front_right"?x=new A(1,1,1):y=="top_right_back"?x=new A(-1,1,1):y=="top_back_left"?x=new A(-1,1,-1):y=="button_left_front"?x=new A(1,-1,-1):y=="button_front_right"?x=new A(1,-1,1):y=="button_right_back"?x=new A(-1,1,1):y=="button_back_left"&&(x=new A(-1,-1,-1));var _=r.octreeBox.getBoundingBox(),E=_.min,S=_.max,C=E.clone().add(S.clone()).multiplyScalar(.5),w=C.clone().add(x.multiplyScalar(1*S.distanceTo(E)));l(e.camera.position,w,r.controls.target.clone(),C)},i.GetCameraPose=function(){var y=e.camera.quaternion,x=e.camera.position,_=r.controls.target,E={quaternion:y,position:x,target:_};return E},i.ReductionCameraPose=function(y,x=1e3,_){var E=new Ct(y.quaternion._x,y.quaternion._y,y.quaternion._z,y.quaternion._w),S=new A(y.position.x,y.position.y,y.position.z),C=new A(y.target.x,y.target.y,y.target.z);let w=!1;l(e.camera.position,S,r.controls.target.clone(),C,e.camera.quaternion,E,x,M=>{_&&(w||(_(M),w=!0))}),_&&setTimeout(()=>{w||(_(!0),w=!0)},x+10)},i.CameraGoHome=function(y=1e3){var x=r.octreeBox.getBoundingBox(),_=x.min.clone().add(x.max.clone()).multiplyScalar(.5);let E=new A(1,1,1);var S=x.max.distanceTo(x.min),C=_.clone().add(E.multiplyScalar(S*2));if(r.camera.far=S*5,e.camera.isOrthographicCamera){var w=r.container.clientWidth/r.container.clientHeight,M=S*.6;e.camera.left=-M*w,e.camera.right=M*w,e.camera.top=M,e.camera.bottom=-M,e.camera.zoom=1,e.camera.updateProjectionMatrix()}r.controlModule.orbitControls.origin=_.clone(),l(e.camera.position,C,r.controls.target.clone(),_,null,null,y)},i.zoomToBox=function(y){if(e.camera.isOrthographicCamera){let J=function(){n=requestAnimationFrame(J),be.update()};var x=y.min.clone().add(y.max.clone()).multiplyScalar(.5),_=e.camera.position.clone().sub(r.controls.target.clone()).normalize(),E=e.camera.position.distanceTo(r.controls.target),S=x.clone().add(_.multiplyScalar(E)),C=e.camera.zoom,w=new A(1,0,0).applyQuaternion(e.camera.quaternion),M=new A(0,1,0).applyQuaternion(e.camera.quaternion),R=[new A(y.min.x,y.min.y,y.min.z),new A(y.max.x,y.min.y,y.min.z),new A(y.min.x,y.max.y,y.min.z),new A(y.max.x,y.max.y,y.min.z),new A(y.min.x,y.min.y,y.max.z),new A(y.max.x,y.min.y,y.max.z),new A(y.min.x,y.max.y,y.max.z),new A(y.max.x,y.max.y,y.max.z)],N=1/0,L=-1/0,O=1/0,T=-1/0;for(var B of R){var F=B.dot(w),H=B.dot(M);N=Math.min(N,F),L=Math.max(L,F),O=Math.min(O,H),T=Math.max(T,H)}var q=(L-N)/2,V=(T-O)/2,re=(e.camera.right-e.camera.left)/2,Y=(e.camera.top-e.camera.bottom)/2;C=Math.min(re/q,Y/V)*.75;var K=e.camera.position.clone(),_e=r.controls.target.clone(),Ce=e.camera.zoom,be=new Jc.Tween({x1:K.x,y1:K.y,z1:K.z,x2:_e.x,y2:_e.y,z2:_e.z,zoom:Ce}).to({x1:S.x,y1:S.y,z1:S.z,x2:x.x,y2:x.y,z2:x.z,zoom:C},1e3);be.onUpdate(function(oe){r.controls&&(e.camera.position.set(oe.x1,oe.y1,oe.z1),r.controls.target.set(oe.x2,oe.y2,oe.z2),e.camera.isOrthographicCamera&&(e.camera.zoom=oe.zoom,e.camera.updateProjectionMatrix()),r.controls.auto=!0,r.controls.update(),i.RenderScene())}),be.onComplete(function(){r.controls&&(r.controls.auto=!1,i.RenderScene(),cancelAnimationFrame(n),n=null)}),be.easing(Jc.Easing.Cubic.InOut),be.start(),J()}else{var x=y.min.clone().add(y.max.clone()).multiplyScalar(.5);let oe=e.camera.position.clone().sub(r.controls.target.clone()).normalize();var S=x.clone().add(oe.multiplyScalar(2*y.max.distanceTo(y.min)));l(e.camera.position,S,r.controls.target.clone(),x)}};function l(y,x,_,E,S,C,w=1e3,M){var R;S&&C?(R=new Jc.Tween({x1:y.x,y1:y.y,z1:y.z,x2:_.x,y2:_.y,z2:_.z,_x:S._x,_y:S._y,_z:S._z,_w:S._w}),R.to({x1:x.x,y1:x.y,z1:x.z,x2:E.x,y2:E.y,z2:E.z,_x:C._x,_y:C._y,_z:C._z,_w:C._w},w)):(R=new Jc.Tween({x1:y.x,y1:y.y,z1:y.z,x2:_.x,y2:_.y,z2:_.z}),R.to({x1:x.x,y1:x.y,z1:x.z,x2:E.x,y2:E.y,z2:E.z},w)),R.onUpdate(function(L){r.controls&&(S&&C?(e.camera.quaternion._x=L._x,e.camera.quaternion._y=L._y,e.camera.quaternion._z=L._z,e.camera.quaternion._w=L._w):r.controls.auto=!0,e.camera.position.x=L.x1,e.camera.position.y=L.y1,e.camera.position.z=L.z1,r.controls.target.x=L.x2,r.controls.target.y=L.y2,r.controls.target.z=L.z2,r.controls.update(),i.RenderScene())}),R.onComplete(function(L){r.controls&&(r.controls.auto=!1,i.RenderScene(),M&&M(!0),cancelAnimationFrame(n),n=null)}),R.easing(Jc.Easing.Cubic.InOut);function N(L){n=requestAnimationFrame(N),R.update()}R.start(),N()}function c(){s=document.createElement("div"),s.className="ViewCube",t.appendChild(s),a=document.createElement("div"),a.className="viewSettingWrapper",a.innerHTML="...",s.appendChild(a);var y=document.createElement("div");y.className="homeViewWrapper",y.addEventListener("mousedown",function(){console.log("归位"),i.CameraGoHome()}),s.appendChild(y);const x=document.createElement("div");x.className="cameraToggleWrapper",x.title="切换正交/透视视图",x.innerHTML="⊞",x.addEventListener("mousedown",function(w){w.stopPropagation(),console.log("切换视图"),i.ToggleCameraType(),S()}),s.appendChild(x);const _=document.createElement("div");_.className="screenshotWrapper",_.title="截图",_.innerHTML="📷",_.addEventListener("mousedown",function(w){w.stopPropagation(),console.log("截图"),i.TakeScreenshot(),S()}),s.appendChild(_);const E=document.createElement("div");E.className="fullscreenWrapper",E.title="全屏",E.innerHTML="⛶",E.addEventListener("mousedown",function(w){w.stopPropagation(),console.log("全屏"),i.ToggleFullscreen(),S()}),s.appendChild(E),a.addEventListener("mousedown",function(w){w.stopPropagation(),x.classList.contains("show")?(S(),console.log("隐藏功能按钮")):(C(),console.log("显示功能按钮"))});function S(){x.classList.remove("show"),_.classList.remove("show"),E.classList.remove("show")}function C(){x.classList.add("show"),_.classList.add("show"),E.classList.add("show")}}function h(){i.sceneOrtho=UU();var _=t.clientWidth,E=t.clientWidth,y=_>E?_/E:E/_,x=300;i.camera=new Zi(x*y/-2,x*y/2,x/2,x/-2,.01,1e4);var _=s.clientWidth,E=s.clientHeight,S=new Ec({alpha:!0});S.setSize(_,E),S.setClearAlpha(0),i.sceneOrtho.renderer=S;let C=new zo(16777215,.8);i.sceneOrtho.add(C),kU(s,S),i.orbitControls=new pU(i.camera,s),i.orbitControls.enableZoom=!1,i.orbitControls.enablePan=!1,i.orbitControls.enableDamping=!0,i.orbitControls.dampingFactor=.1,i.orbitControls.rotateSpeed=.5,i.orbitControls.addEventListener("start",p),i.orbitControls.addEventListener("change",u),i.orbitControls.addEventListener("end",v)}let d=!1;function p(){d=!0,r.controls&&(i._mainTarget=r.controls.target.clone(),i._mainDistance=e.camera.position.distanceTo(r.controls.target))}function u(){if(d){if(e.camera.quaternion.copy(i.camera.quaternion),r.controls&&i._mainTarget&&i._mainDistance){const y=new A(0,0,1).applyQuaternion(e.camera.quaternion);e.camera.position.copy(i._mainTarget.clone().add(y.multiplyScalar(i._mainDistance))),r.controls.update()}r.renderer&&e.camera&&r.renderer.render(e,e.camera)}}function v(){d=!1,i._mainTarget=null,i._mainDistance=null}function m(){const y="/assets/viewcube/";let x=[{label:"右",icon:y+"cn_right.png"},{label:"左",icon:y+"cn_left.png"},{label:"顶",icon:y+"cn_top.png"},{label:"底",icon:y+"cn_bottom.png"},{label:"前",icon:y+"cn_front.png"},{label:"后",icon:y+"cn_back.png"}];var _=[];for(const C of x)_.push(new Rt({color:16777215,map:new ba().load(C.icon)}));new ym({color:255});var E=new Ve(new ni(110,110,110),_);i.sceneOrtho.add(E),g(122);let S={x:0,y:0};s.addEventListener("mousedown",C=>{S.x=C.clientX,S.y=C.clientY}),s.addEventListener("mouseup",C=>{if(d)return;const w=C.clientX-S.x,M=C.clientY-S.y;if(Math.sqrt(w*w+M*M)>5)return;var R={};R.x=C.offsetX/s.clientWidth*2-1,R.y=-(C.offsetY/s.clientHeight)*2+1;var N=new In;N.setFromCamera(R,i.camera);const L=N.intersectObjects(o,!1);L.length>0&&i.ToggleDirectionView(L[0].object.name)}),s.addEventListener("mousemove",C=>{var w={};w.x=C.offsetX/s.clientWidth*2-1,w.y=-(C.offsetY/s.clientHeight)*2+1;var M=new In;M.setFromCamera(w,i.camera);const R=M.intersectObjects(o,!1);for(var N of o)N.material.opacity=.01;R.length>0&&(R[0].object.material.opacity=.2)})}function g(y){for(var x=y*.5-20,_=[{name:"right",a:30,b:75,c:75,point:new A(x,0,0)},{name:"back",a:75,b:75,c:30,point:new A(0,0,-x)},{name:"left",a:30,b:75,c:75,point:new A(-x,0,0)},{name:"front",a:75,b:75,c:30,point:new A(0,0,x)},{name:"top",a:75,b:30,c:75,point:new A(0,x,0)},{name:"button",a:75,b:30,c:75,point:new A(0,-x,0)}],E=[{name:"top_right_back",a:30,b:30,c:30,point:new A(-x,x,x)},{name:"button_front_right",a:30,b:30,c:30,point:new A(-x,-x,x)},{name:"top_front_right",a:30,b:30,c:30,point:new A(x,x,x)},{name:"button_right_back",a:30,b:30,c:30,point:new A(x,-x,x)},{name:"top_back_left",a:30,b:30,c:30,point:new A(-x,x,-x)},{name:"button_back_left",a:30,b:30,c:30,point:new A(-x,-x,-x)},{name:"top_left_front",a:30,b:30,c:30,point:new A(x,x,-x)},{name:"button_left_front",a:30,b:30,c:30,point:new A(x,-x,-x)}],S=[{name:"top_front",a:30,b:30,c:75,point:new A(x,x,0)},{name:"top_right",a:75,b:30,c:30,point:new A(0,x,x)},{name:"top_back",a:30,b:30,c:75,point:new A(-x,x,0)},{name:"top_left",a:75,b:30,c:30,point:new A(0,x,-x)},{name:"button_front",a:30,b:30,c:75,point:new A(x,-x,0)},{name:"button_right",a:75,b:30,c:30,point:new A(0,-x,x)},{name:"button_back",a:30,b:30,c:75,point:new A(-x,-x,0)},{name:"button_left",a:75,b:30,c:30,point:new A(0,-x,-x)},{name:"front_right",a:30,b:75,c:30,point:new A(x,0,x)},{name:"right_back",a:30,b:75,c:30,point:new A(-x,0,x)},{name:"back_left",a:30,b:75,c:30,point:new A(-x,0,-x)},{name:"left_front",a:30,b:75,c:30,point:new A(x,0,-x)}],C=0;C<_.length;C++)o.push(f(_[C]));for(var C=0;C<E.length;C++)o.push(f(E[C]));for(var C=0;C<S.length;C++)o.push(f(S[C]))}function f(y){const x=new ni(y.a,y.b,y.c),_=new Rt({color:"blue",transparent:!0,opacity:.01}),E=new Ke().makeTranslation(y.point.x,y.point.y,y.point.z);let S=x.applyMatrix4(E),C=new Ve(S,_);return C.name=y.name,i.sceneOrtho.add(C),C}return i.ToggleCameraType=function(){r.cameraModule.switchCurrentCamera()},i.TakeScreenshot=function(){try{if(!r.renderer){console.error("渲染器未初始化");return}r.renderer.render(e,e.camera);const y=r.renderer.domElement.toDataURL("image/png"),x=document.createElement("a"),_=new Date().toISOString().replaceAll(/[:.]/g,"-");x.download=`screenshot_${_}.png`,x.href=y,x.click(),console.log("截图已保存")}catch(y){console.error("截图失败:",y)}},i.ToggleFullscreen=function(){const y=t||document.documentElement;!document.fullscreenElement&&!document.webkitFullscreenElement&&!document.mozFullScreenElement&&!document.msFullscreenElement?(y.requestFullscreen?y.requestFullscreen():y.webkitRequestFullscreen?y.webkitRequestFullscreen():y.mozRequestFullScreen?y.mozRequestFullScreen():y.msRequestFullscreen&&y.msRequestFullscreen(),console.log("已进入全屏模式")):(document.exitFullscreen?document.exitFullscreen():document.webkitExitFullscreen?document.webkitExitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.msExitFullscreen&&document.msExitFullscreen(),console.log("已退出全屏模式"))},i}class BU{engine;cubeTool;constructor(e){this.engine=e}init(){this.cubeTool=OU(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(i=>i.url==e.url);this.cubeTool.zoomToBox(t.nodesMap.get(e.id).infos[0].box)}catch{}}hide(){}}function FU(r){let e=new Object;return e.getBoundingBox=function(){let t=r.models,i=new A(1e8,1e9,1e10),n=new A(-1e8,-1e9,-1e10);t.forEach(d=>{let p=new A(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 A(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));p.x<i.x&&(i.x=p.x),p.y<i.y&&(i.y=p.y),p.z<i.z&&(i.z=p.z),u.x>n.x&&(n.x=u.x),u.y>n.y&&(n.y=u.y),u.z>n.z&&(n.z=u.z)});let s=Math.min(i.x,n.x),a=Math.min(i.y,n.y),o=Math.min(i.z,n.z),l=Math.max(i.x,n.x),c=Math.max(i.y,n.y),h=Math.max(i.z,n.z);return{min:new A(s,a,o),max:new A(l,c,h)}},e.rayInterationModel=function(t,i){let n=[];return r.engineStatus.models.forEach(a=>{a.info.lods.forEach(o=>{let l=o.octreeBox;s(t,l,a)})}),n=n.filter(a=>a instanceof Ve),n=n.filter(a=>t.ray.intersectsBox(new Ot().setFromObject(a),!1)==!0),t.intersectObjects(n,!1);function s(a,o,l){if(o==null)return;let c=new A(o.min.X*.3048,o.min.Z*.3048,-o.min.Y*.3048),h=new A(o.max.X*.3048,o.max.Z*.3048,-o.max.Y*.3048),d=new A(Math.min(c.x,h.X),Math.min(c.y,h.y),Math.min(c.z,h.z)),p=new A(Math.max(h.x,c.x),Math.max(h.y,c.y),Math.max(h.z,c.z)),u=new Ot(d,p),v=a.ray.intersectsBox(u);if(!(v==null||v==!1))if(o.children==null||o.children.length==0){if(o.elements!=null)for(var m of o.elements){if(!r.engineStatus.isFree&&i==!1)continue;let g=r.engineStatus.hideModels.find(x=>x.url==l.url)?.ids;if(g!=null&&g.includes(m))continue;let f=r.engineStatus.translucentModels.find(x=>x.url==l.url)?.ids;if(f!=null&&f.includes(m))continue;let y=r.models.find(x=>x.url==l.url).nodesMap.get(m);y!=null&&!y.instance&&y.infos!=null&&y.infos.map(x=>x.mesh).forEach(x=>{n.push(x)})}}else{if(o.elements!=null)for(var m of o.elements){let f=r.engineStatus.hideModels.find(_=>_.url==l.url)?.ids;if(f!=null&&f.includes(m))continue;let y=r.engineStatus.translucentModels.find(_=>_.url==l.url)?.ids;if(y!=null&&y.includes(m))continue;let x=r.models.find(_=>_.url==l.url).nodesMap.get(m);x!=null&&!x.instance&&x.infos!=null&&x.infos.map(_=>_.mesh).forEach(_=>{n.push(_)})}for(let g of o.children)s(a,g,l)}}},e}class zU{engine;isDrawing=!1;startPoint=new xe;endPoint=new xe;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 Ft(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 e=Math.min(this.startPoint.x,this.endPoint.x),t=Math.min(this.startPoint.y,this.endPoint.y),i=Math.abs(this.endPoint.x-this.startPoint.x),n=Math.abs(this.endPoint.y-this.startPoint.y);this.selectionBox.style.left=`${e}px`,this.selectionBox.style.top=`${t}px`,this.selectionBox.style.width=`${i}px`,this.selectionBox.style.height=`${n}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 i=Math.min(this.startPoint.x,this.endPoint.x),n=Math.max(this.startPoint.x,this.endPoint.x),s=Math.min(this.startPoint.y,this.endPoint.y),a=Math.max(this.startPoint.y,this.endPoint.y),o=[],l=[{x:i,y:s},{x:n,y:s},{x:n,y:a},{x:i,y:a}];for(const h of l){const d=this.worldToScreen.screenToWorld(h.x,h.y);d&&o.push(d)}if(o.length<3){console.warn("RangeScale: 框选区域未命中模型,无法执行缩放操作");return}if(o.length<3){console.warn("RangeScale: 无法将屏幕区域转换为世界坐标");return}const c=new Ot;for(const h of o)c.expandByPoint(h);if(c.isEmpty()){console.warn("RangeScale: 计算得到的包围盒无效");return}this.fitCameraToBoundingBox(c)}fitCameraToBoundingBox(e){const t=this.engine.camera,i=this.engine.controls;if(!t||!i){console.warn("RangeScale: 相机或控制器未初始化");return}const n=new A;e.getCenter(n);const s=new A;e.getSize(s);const a=Math.max(s.x,s.y,s.z);if(t instanceof ci){const o=t.fov*(Math.PI/180),l=a/(2*Math.tan(o/2))*1.2,c=new A;t.getWorldDirection(c);const h=n.clone().sub(t.position);c.dot(h.normalize())<0&&c.negate();const d=n.clone().sub(c.multiplyScalar(l));t.position.copy(d),i.target&&i.target.copy(n),t.lookAt(n),i.update()}else if(t instanceof Zi){const o=a*1.2,l=this.engine.renderer?.domElement,c=l?l.width/l.height:1;t.left=-o*c/2,t.right=o*c/2,t.top=o/2,t.bottom=-o/2,t.updateProjectionMatrix();const h=new A;t.getWorldDirection(h);const d=a*1.5,p=n.clone().sub(h.multiplyScalar(d));t.position.copy(p),i.target&&i.target.copy(n),t.lookAt(n),i.update()}}}const AM={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 HU{engine;settings;environmentApplyVersion=0;constructor(e){this.engine=e,this.settings=this._clone(AM)}init(){}getSettings(){return this._clone(this.settings)}getPresetLists(){const e=this.engine.ground?.getGroundList()||[],t=this.engine.hdr?.getHdrList()||[],i=this.engine.skyManager?.getPresetList()||[];return{ground:e.map(n=>this._toPresetItem(n)),hdr:t.map(n=>this._toPresetItem(n)),sky:i.map(n=>this._toPresetItem(n))}}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(AM),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(i=>i instanceof zo);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(i=>i instanceof Ar);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 or(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(r){var e=Math.random()*16|0,t=r=="x"?e:e&3|8;return t.toString(16)})}class lr{engine;handelBehaved;setting;constructor(e){this.engine=e,this.handelBehaved=P0(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 i=this.setting.unit,n=i;return t==1?i=="mm"?e=e*1e3:i=="cm"?e=e*100:i=="dm"?e=e*10:i=="m"?e=e*1:i=="km"&&(e=e*.001):t==2&&(i=="mm"?e=e*1e3*1e3:i=="cm"?e=e*100*100:i=="dm"?e=e*10*10:i=="m"?e=e*1*1:i=="km"&&(e=e*.001*.001),n=n+"²"),e.toFixed(this.setting.precision)+" "+n}cancelCurrentSelectedAnnotation(){let e=this.engine.measure.annotationData;for(let t in e)e[t].forEach(i=>{i.highlight==!0&&(i.highlight=!1,i.container.classList.remove("Hight"),i.container.getElementsByTagName("svg")[0].classList.remove("Hight"))})}handelKeyEscDown(){this.cancelCurrentSelectedAnnotation();let e=this.engine.measure.annotationData;for(let t in e)for(let i=e[t].length-1;i>=0;i--){let n=e[t][i];n.isSelect==!0&&(n.container.remove(),e[t].splice(i,1))}this.engine.measure.clearAllPoints()}handelKeyDeleteDown(){let e=this.engine.measure.annotationData;for(let t in e)for(let i=e[t].length-1;i>=0;i--){let n=e[t][i];n.highlight==!0&&(n.container.remove(),e[t].splice(i,1))}}clearHighlight(){let e=this.engine.measure.annotationData;for(let t in e)e[t].forEach(i=>{i.highlight=!1,i.container.classList.remove("Hight"),i.container.getElementsByTagName("svg")[0].classList.remove("Hight")})}drawNormalAnnotation(){let e=this;this.engine.measure.annotationData.normalAnnotation.forEach(l=>{o(l)}),this.engine.measure.annotationData.elevationAnnotation.forEach(l=>{a(l)}),this.engine.measure.annotationData.coordinateAnnotation.forEach(l=>{s(l)}),this.engine.measure.annotationData.angleAnnotation.forEach(l=>{t(l)}),this.engine.measure.annotationData.areaAnnotation.forEach(l=>{i(l)}),this.engine.measure.annotationData.slopeAnnotation.forEach(l=>{n(l)});function t(l){if(l.container==null){let f=['<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">'+l.text+"</text>","</svg>"].join("");l.container=document.createElement("div"),l.container.className="angle-annotation",l.container.id=l.id,l.container.style.pointerEvents="none",l.container.innerHTML=f,e.engine.measure.annotationContainer.appendChild(l.container),l.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),l.container.getElementsByTagName("svg")[0].classList.add("Hight"),l.highlight=!0,e.engine.events.trigger(pi.MeasureClick,l)}),l.isSelect&&(l.container.getElementsByTagName("svg")[0].classList.add("Hight"),l.highlight=!0)}let c=new Ft(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(l.point1),h=new Ft(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(l.point2),d=new Ft(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(l.point3),p=e.engine.reactBoundingClientRect.left,u=e.engine.reactBoundingClientRect.top;c.x+=p,c.y+=u,h.x+=p,h.y+=u,d.x+=p,d.y+=u;let v=l.container;v.getElementsByTagName("circle")[0].setAttribute("cx",c.x),v.getElementsByTagName("circle")[0].setAttribute("cy",c.y),v.getElementsByTagName("circle")[1].setAttribute("cx",h.x),v.getElementsByTagName("circle")[1].setAttribute("cy",h.y),v.getElementsByTagName("circle")[2].setAttribute("cx",d.x),v.getElementsByTagName("circle")[2].setAttribute("cy",d.y),v.getElementsByTagName("polyline")[0].setAttribute("points",c.x+","+c.y+" "+h.x+","+h.y),v.getElementsByTagName("polyline")[1].setAttribute("points",h.x+","+h.y+" "+d.x+","+d.y);let m=h.x,g=h.y-30;v.getElementsByTagName("rect")[0].setAttribute("x",m-40),v.getElementsByTagName("rect")[0].setAttribute("y",g-12.5),v.getElementsByTagName("text")[0].setAttribute("x",m),v.getElementsByTagName("text")[0].setAttribute("y",g+4),v.getElementsByTagName("text")[0].innerHTML=l.text,v.style.top="0px",v.style.left="0px"}function i(l){if(l.container==null){let y=['<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(l.text,2)+"</text>","</svg>"].join("");l.container=document.createElement("div"),l.container.className="area-annotation",l.container.id=l.id,l.container.innerHTML=y,e.engine.measure.annotationContainer.appendChild(l.container),l.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),l.container.getElementsByTagName("svg")[0].classList.add("Hight"),l.highlight=!0,e.engine.events.trigger(pi.MeasureClick,l)}),l.isSelect&&(l.container.getElementsByTagName("svg")[0].classList.add("Hight"),l.highlight=!0)}if(!l.points||l.points.length<3)return;let c=e.engine.reactBoundingClientRect.left,h=e.engine.reactBoundingClientRect.top,d=[],p=0,u=0;for(let y=0;y<l.points.length;y++){let x=new Ft(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(l.points[y]);x.x+=c,x.y+=h,d.push(x),p+=x.x,u+=x.y}p=p/d.length,u=u/d.length;let v=d.map(y=>y.x+","+y.y).join(" "),m=l.container;m.getElementsByTagName("polygon")[0].setAttribute("points",v),m.getElementsByTagName("polyline")[0].setAttribute("points",v);let g=p,f=u;m.getElementsByTagName("rect")[0].setAttribute("x",g-40),m.getElementsByTagName("rect")[0].setAttribute("y",f-12.5),m.getElementsByTagName("text")[0].setAttribute("x",g),m.getElementsByTagName("text")[0].setAttribute("y",f+4),m.getElementsByTagName("text")[0].innerHTML=e.getMeasureText(l.text,2),m.style.top="0px",m.style.left="0px"}function n(l){if(l.container==null){let g=['<svg class="measureSvg">',"<defs>",'<marker id="slope-arrow-'+l.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-'+l.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">'+l.text+"</text>","</svg>"].join("");l.container=document.createElement("div"),l.container.className="slope-annotation",l.container.id=l.id,l.container.innerHTML=g,e.engine.measure.annotationContainer.appendChild(l.container),l.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),l.container.getElementsByTagName("svg")[0].classList.add("Hight"),l.highlight=!0,e.engine.events.trigger(pi.MeasureClick,l)}),l.isSelect&&(l.container.getElementsByTagName("svg")[0].classList.add("Hight"),l.highlight=!0)}let c=new Ft(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(l.point1),h=new Ft(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(l.point2),d=e.engine.reactBoundingClientRect.left,p=e.engine.reactBoundingClientRect.top;c.x+=d,c.y+=p,h.x+=d,h.y+=p;let u=l.container;u.getElementsByTagName("polyline")[0].setAttribute("points",c.x+","+c.y+" "+h.x+","+h.y);let v=(c.x+h.x)/2,m=(c.y+h.y)/2-30;u.getElementsByTagName("rect")[0].setAttribute("x",v-50),u.getElementsByTagName("rect")[0].setAttribute("y",m-12.5),u.getElementsByTagName("text")[0].setAttribute("x",v),u.getElementsByTagName("text")[0].setAttribute("y",m+4),u.getElementsByTagName("text")[0].innerHTML=l.text,u.style.top="0px",u.style.left="0px"}function s(l){if(l.container==null){let f=['<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(l.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(-l.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(l.textY,1)+"</text>","</svg>"].join("");l.container=document.createElement("div"),l.container.className="coordinate-annotation",l.container.id=l.id,l.container.style.position="absolute",l.container.style.pointerEvents="none",l.container.innerHTML=f,e.engine.measure.annotationContainer.appendChild(l.container),l.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),l.container.getElementsByTagName("svg")[0].classList.add("Hight"),l.highlight=!0,e.engine.events.trigger(pi.MeasureClick,l)}),l.isSelect&&(l.container.getElementsByTagName("svg")[0].classList.add("Hight"),l.highlight=!0)}let c=l.container,h=new Ft(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(l.point),d=e.engine.reactBoundingClientRect.left,p=e.engine.reactBoundingClientRect.top;h.x+=d,h.y+=p,c.style.top="0px",c.style.left="0px";let u=c.getElementsByTagName("circle")[0];u&&(u.setAttribute("cx",h.x),u.setAttribute("cy",h.y));let v=c.getElementsByTagName("rect"),m=c.getElementsByTagName("text"),g=-55;v[0]&&(v[0].setAttribute("x",h.x+10),v[0].setAttribute("y",h.y+10+g)),m[0]&&(m[0].setAttribute("x",h.x+10+40),m[0].setAttribute("y",h.y+10+16+g)),v[1]&&(v[1].setAttribute("x",h.x+10),v[1].setAttribute("y",h.y+10+30+g)),m[1]&&(m[1].setAttribute("x",h.x+10+40),m[1].setAttribute("y",h.y+10+46+g)),v[2]&&(v[2].setAttribute("x",h.x+10),v[2].setAttribute("y",h.y+10+60+g)),m[2]&&(m[2].setAttribute("x",h.x+10+40),m[2].setAttribute("y",h.y+10+76+g)),m[0]&&(m[0].innerHTML="X: "+e.getMeasureText(l.textX,1)),m[1]&&(m[1].innerHTML="Y: "+e.getMeasureText(-l.textZ,1)),m[2]&&(m[2].innerHTML="Z: "+e.getMeasureText(l.textY,1))}function a(l){if(l.container==null){let u=['<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(l.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("");l.container=document.createElement("div"),l.container.className="elevation-annotation",l.container.id=l.id,l.container.style.position="absolute",l.container.style.pointerEvents="none",l.container.innerHTML=u,e.engine.measure.annotationContainer.appendChild(l.container),l.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),l.container.getElementsByTagName("svg")[0].classList.add("Hight"),l.highlight=!0,e.engine.events.trigger(pi.MeasureClick,l)}),l.isSelect&&(l.container.getElementsByTagName("svg")[0].classList.add("Hight"),l.highlight=!0)}let c=l.container,h=new Ft(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(l.point),d=e.engine.reactBoundingClientRect.left,p=e.engine.reactBoundingClientRect.top;c.style.top=h.y+p-48+"px",c.style.left=h.x+d-16+"px",c.getElementsByTagName("text")[0].innerHTML=e.getMeasureText(l.text,1)}function o(l){if(l.container==null){let v=['<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(l.text,1)+"</text>","</svg>"].join("");l.container=document.createElement("div"),l.container.className="normal-annotation",l.container.id=l.id,l.container.innerHTML=v,e.engine.measure.annotationContainer.appendChild(l.container),l.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),l.container.getElementsByTagName("svg")[0].classList.add("Hight"),l.highlight=!0,e.engine.events.trigger(pi.MeasureClick,l)}),l.isSelect&&(l.container.getElementsByTagName("svg")[0].classList.add("Hight"),l.highlight=!0)}let c=l.container;if(l.point1==null||l.point2==null){c.style.display="none";return}else c.style.display="block";let h=new Ft(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(l.point1),d=new Ft(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(l.point2),p=e.engine.reactBoundingClientRect.left,u=e.engine.reactBoundingClientRect.top;h.x+=p,h.y+=u,d.x+=p,d.y+=u,c.getElementsByTagName("polyline")[0].setAttribute("points",h.x+","+h.y+" "+d.x+","+d.y),c.getElementsByTagName("circle")[0].setAttribute("cx",h.x),c.getElementsByTagName("circle")[0].setAttribute("cy",h.y),c.getElementsByTagName("circle")[1].setAttribute("cx",d.x),c.getElementsByTagName("circle")[1].setAttribute("cy",d.y),c.getElementsByTagName("rect")[0].setAttribute("x",h.x*.5+d.x*.5-40),c.getElementsByTagName("rect")[0].setAttribute("y",h.y*.5+d.y*.5-12.5),c.getElementsByTagName("text")[0].setAttribute("x",h.x*.5+d.x*.5+40-40),c.getElementsByTagName("text")[0].setAttribute("y",h.y*.5+d.y*.5+16-12.5),c.getElementsByTagName("text")[0].innerHTML=e.getMeasureText(l.text,1),c.style.top="0px",c.style.left="0px"}}}class VU{engine;isActive=!1;tools;points=[];behavior;catchDir=0;type="point";constructor(e){this.engine=e,this.tools=new lr(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,i=Number.NEGATIVE_INFINITY;for(let n=0;n<e.length;n++){const s=e[n];if(!s)continue;typeof s.updateMatrixWorld=="function"&&s.updateMatrixWorld(!0);const a=new Ot().setFromObject(s);!Number.isFinite(a.min.y)||!Number.isFinite(a.max.y)||(a.min.y<t&&(t=a.min.y),a.max.y>i&&(i=a.max.y))}return!Number.isFinite(t)||!Number.isFinite(i)?null:{minY:t,maxY:i}}handleMouseClick(e){if(e.catch==null)return;let t=e.catch.point;if(this.type=="element"){let s=this.engine.interactionModule.getCatchMeshs(e);var i=this.getMeshesMinMaxY(s);this.catchDir==0?t.set(t.x,i?.minY,t.z):t.set(t.x,i?.maxY,t.z)}else t=e.catch.point;if(this.points.length==0){this.engine.measure.tools.clearHighlight(),this.points.push(t);return}let n=this.engine.measure.annotationData.normalAnnotation.find(s=>s.isSelect==!0);n!=null&&(n.isSelect=!1)}handleMouseMove(e){if(e.catch==null||this.points.length==0)return;let t=this.engine.measure.annotationData.normalAnnotation.find(n=>n.isSelect==!0);t==null&&(t={text:null,id:or(),isSelect:!0,type:"clear-height"},this.engine.measure.annotationData.normalAnnotation.push(t));let i=e.catch;if(this.type=="element"){let n=e.catch.point.clone();n.set(n.x,this.points[0].y,n.z);let s=new In(n.add(new A(0,.01,0)),new A(0,this.catchDir==0?-1:1,0));i.point=this.points[0];const a=this.engine.clipping?.filterIntersectionsByClipping(this.engine.octreeBox.rayInterationModel(s))??this.engine.octreeBox.rayInterationModel(s);if(a.length===0){t.point2=null;return}t.point1=n,t.point2=a[0].point,t.text=t.point1.clone().distanceTo(t.point2.clone()),this.engine.events.trigger(pi.MeasureChanged,t)}else{let n=new In(e.catch.point.clone().add(new A(0,.01,0)),new A(0,this.catchDir==0?-1:1,0));const s=this.engine.clipping?.filterIntersectionsByClipping(this.engine.octreeBox.rayInterationModel(n))??this.engine.octreeBox.rayInterationModel(n);if(s.length===0){t.point2=null;return}t.point1=i.point,t.point2=s[0].point,t.text=t.point1.clone().distanceTo(t.point2.clone()),this.engine.events.trigger(pi.MeasureChanged,t)}}}class GU{engine;tools;isActive=!1;points=[];behavior;constructor(e){this.engine=e,this.tools=new lr(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 i=this.engine.measure.annotationData.normalAnnotation.find(n=>n.isSelect==!0);if(i==null)return;i.point2=t.point,i.isSelect=!1,this.points=[],this.engine.events.trigger(pi.MeasureChanged,i)}}handleMouseMove(e){if(e.catch==null)return;let t=e.catch;if(t!=null&&this.points.length==1){let i=this.engine.measure.annotationData.normalAnnotation.find(n=>n.isSelect==!0);i==null&&(i={id:or(),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(i)),i.point2=t.point,i.text=i.point1.clone().distanceTo(i.point2.clone())}}}class WU{engine;isActive=!1;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new lr(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(i=>i.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(a=>a.isSelect==!0);t==null&&(t={text:null,id:or(),isSelect:!0,type:"clear-distance"},this.engine.measure.annotationData.normalAnnotation.push(t));let i=new In(e.catch.point.clone().add(e.catch.face.normal.clone().setLength(.01)),e.catch.face.normal);const n=this.engine.clipping?.filterIntersectionsByClipping(this.engine.octreeBox.rayInterationModel(i))??this.engine.octreeBox.rayInterationModel(i);if(n.length==0){t.point2=null;return}let s=e.catch;t.point1=s.point,t.point2=n[0].point,t.text=t.point1.clone().distanceTo(t.point2.clone()),this.engine.events.trigger(pi.MeasureChanged,t)}}class XU{engine;isActive=!1;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new lr(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(i=>i.isSelect==!0);t==null&&(t={id:or(),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(i=>i.isSelect==!0);t!=null&&(t.isSelect=!1,t.point=e.catch.point.clone(),t.text=e.catch.point.y,this.engine.events.trigger(pi.MeasureChanged,t))}}class jU{engine;isActive=!1;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new lr(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(i=>i.isSelect==!0);t==null&&(t={id:or(),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(i=>i.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(pi.MeasureChanged,t))}createMeasure(){let e=this.engine.measure.annotationData.coordinateAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1,this.engine.events.trigger(pi.MeasureChanged,e))}}class qU{engine;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new lr(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,i){const n=new A().subVectors(e,t),s=new A().subVectors(i,t),a=n.length(),o=s.length();if(a===0||o===0)return 0;const l=n.dot(s)/(a*o),c=Math.max(-1,Math.min(1,l));return Math.acos(c)*(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 i=this.engine.measure.annotationData.angleAnnotation.find(n=>n.isSelect==!0);if(i==null)return;i.point3=t.point.clone(),i.angle=this.calculateAngle(i.point1,i.point2,i.point3),i.text=i.angle.toFixed(2)+"°",i.isSelect=!1,i.type="angle",this.points=[],this.engine.events.trigger(pi.MeasureChanged,i)}}handleMouseMove(e){if(e.catch!=null&&this.points.length!=1&&this.points.length==2){let t=this.engine.measure.annotationData.angleAnnotation.find(i=>i.isSelect==!0);t==null&&(t={id:or(),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 ZU{engine;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new lr(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 i=e.length;for(let n=0;n<i;n++){const s=(n+1)%i;t+=e[n].x*e[s].z,t-=e[s].x*e[n].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 i=this.engine.measure.annotationData.areaAnnotation.find(n=>n.isSelect==!0);i==null?(i={id:or(),points:this.points.map(n=>n.clone()),area:0,text:0,isSelect:!0,type:"area"},this.engine.measure.annotationData.areaAnnotation.push(i)):(this.points.push(t.point.clone()),i.points=this.points.map(n=>n.clone())),i.area=this.calculateArea(i.points),i.text=i.area,console.log("面积",i.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(i=>i.isSelect==!0);if(t==null){if(this.points.length>=2){let i=this.points.map(n=>n.clone());i.push(e.catch.point.clone()),i.length>=3&&(t={id:or(),points:i,area:0,text:0,isSelect:!0,type:"area"},this.engine.measure.annotationData.areaAnnotation.push(t))}}else if(t.points.length>0){const i=t.points.length-1;t.points[i]=e.catch.point.clone()}else t.points=this.points.map(i=>i.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(pi.MeasureChanged,e))}}class YU{engine;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new lr(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 i=t.y-e.y,n=t.x-e.x,s=t.z-e.z,a=Math.sqrt(n*n+s*s);if(a===0)return{percentage:0,angle:0,heightDiff:i,horizontalDist:0,type:"slope"};const o=i/a*100,l=Math.atan(i/a)*(180/Math.PI);return{percentage:o,angle:l,heightDiff:i,horizontalDist:a,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 i=this.engine.measure.annotationData.slopeAnnotation.find(s=>s.isSelect==!0);if(i==null)return;console.log("进来了"),i.point2=t.point.clone();const n=this.calculateSlope(i.point1,i.point2);i.slopePercentage=n.percentage,i.slopeAngle=n.angle,i.heightDiff=n.heightDiff,i.horizontalDist=n.horizontalDist,i.text=n.percentage.toFixed(2)+"% ("+n.angle.toFixed(2)+"°)",i.isSelect=!1,this.points=[],this.engine.events.trigger(pi.MeasureChanged,i)}}handleMouseMove(e){if(e.catch==null)return;let t=e.catch;if(t!=null&&this.points.length==1){let i=this.engine.measure.annotationData.slopeAnnotation.find(s=>s.isSelect==!0);i==null&&(i={id:or(),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(i)),i.point2=t.point.clone();const n=this.calculateSlope(i.point1,i.point2);i.slopePercentage=n.percentage,i.slopeAngle=n.angle,i.heightDiff=n.heightDiff,i.horizontalDist=n.horizontalDist,i.text=n.percentage.toFixed(2)+"% ("+n.angle.toFixed(2)+"°)"}}}class KU{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 VU(e),this.distanceMeasure=new GU(e),this.clearDistanceMeasure=new WU(e),this.elevationMeasure=new XU(e),this.pointMeasure=new jU(e),this.angleMeasure=new qU(e),this.areaMeasure=new ZU(e),this.slopeMeasure=new YU(e),this.tools=new lr(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 i=0;i<t.length;i++)t[i].container.remove();t=[]}}saveSetting(e){this.tools.saveSetting(e)}getSetting(){return this.tools.getSetting()}update(){this.isActive&&this.tools.drawNormalAnnotation()}}class $U{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),i=t.intersectObjects(this.getInteractiveMeshes(),!1);i.length!==0&&(e.preventDefault(),e.stopImmediatePropagation(),this.handleMouseDown({button:e.button,raycaster:t,intersects:i}))};handleNativeMouseMove=e=>{if(!this.isDrag&&!(this.isCtrlDown||e.ctrlKey)){this.resetMeshOpacity();return}const t=this.createRaycasterFromMouseEvent(e),i=t.intersectObjects(this.getInteractiveMeshes(),!1);this.isDrag&&(e.preventDefault(),e.stopImmediatePropagation()),this.handleMouseMove({raycaster:t,intersects:i})};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 i=t[0];this.isDrag=!0,this.pickPoint=i.point.clone(),this.pickMesh=i.object;const n=this.pickMesh?.userData?.dragNormal?.clone?.(),s=i.face?.normal?.clone?.();if(this.pickNormal=(n??s??new A(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 a=new ri;a.setFromNormalAndCoplanarPoint(new A(0,1,0),this.pickPoint),this.plane=a}else{const a=new A(this.engine.camera.position.x,this.pickPoint.y,this.engine.camera.position.z),o=new ri;o.setFromNormalAndCoplanarPoint(a.clone().sub(this.pickPoint.clone()).setLength(1),this.pickPoint),this.plane=o}}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,i){return new A(Math.max(t.x,Math.min(i.x,e.x)),Math.max(t.y,Math.min(i.y,e.y)),Math.max(t.z,Math.min(i.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 i=new A;if(e.raycaster.ray.intersectPlane(this.plane,i)){const n=i.clone().sub(this.pickPoint.clone()).dot(this.pickNormal.clone());if(this.pickMesh?.userData?.isMinFace){const s=this.box_.min.clone().add(this.pickNormal.clone().setLength(n));this.box.min=this.clampVector3(s,this.maxBox.min,this.box.max)}else{const s=this.box_.max.clone().add(this.pickNormal.clone().setLength(n));this.box.max=this.clampVector3(s,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,i=this.maxBox.max.z-this.maxBox.min.z,n=this.toPercent((this.box.min.x-this.maxBox.min.x)/e*100),s=this.toPercent((this.box.max.x-this.maxBox.min.x)/e*100),a=this.toPercent((this.box.min.y-this.maxBox.min.y)/t*100),o=this.toPercent((this.box.max.y-this.maxBox.min.y)/t*100),l=this.toPercent((this.box.min.z-this.maxBox.min.z)/i*100),c=this.toPercent((this.box.max.z-this.maxBox.min.z)/i*100),h={x:{min:n,max:s},y:{min:a,max:o},z:{min:l,max:c}};this.engine.events.trigger(pi.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 In,i=new xe,n=this.engine.renderer.domElement.clientWidth,s=this.engine.renderer.domElement.clientHeight;return i.x=e.offsetX/n*2-1,i.y=-(e.offsetY/s)*2+1,t.setFromCamera(i,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 i=e.getHelper(),n=[];i.traverse(s=>{if(s?.name!==t||!s.geometry)return;const a=s.geometry;a.boundingBox||a.computeBoundingBox();const o=a.boundingBox;if(!o)return;const l=o.getCenter(new A);if(!(t==="X"&&l.x<0||t==="Y"&&l.y<0||t==="Z"&&l.z<0))return;const c=a.parameters,h=c&&c.radiusTop===0&&c.radiusBottom===.04&&c.height===.1,d=c&&c.radiusTop===.2&&c.radiusBottom===0&&c.height===.6;(h||d)&&n.push(s)}),n.forEach(s=>{s.parent?.remove(s)})}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,i=this.engine.camera;if(!t||!i)return;const n=new bt;n.name=`SectionBoxTransformAnchor_${e}`,n.visible=this.isActive,this.engine.scene.add(n);const s=new wM(i,t);s.name=`SectionBoxTransformControl_${e}`,s.setMode("translate"),s.setSpace("local"),s.showX=!0,s.showY=!1,s.showZ=!1,s.size=.75,s.enabled=this.isActive,s.attach(n),this.keepSingleDirectionArrow(s,"X"),s.addEventListener("dragging-changed",o=>{this.engine.controls.enabled=!o.value}),s.addEventListener("objectChange",()=>{this.handleTransformObjectChange(e)});const a=s.getHelper();a.visible=this.isActive,this.engine.scene.add(a),this.transformAnchors.set(e,n),this.transformControls.set(e,s),this.transformHelpers.set(e,a)}updateFaceTransformControl(e,t,i,n){this.ensureFaceTransformControl(e);const s=this.transformAnchors.get(e),a=this.transformControls.get(e);if(!s||!a)return;const o=this.getFaceTransformOffset(),l=new Ct().setFromUnitVectors(new A(1,0,0),t.clone().normalize()),c=i.clone().add(t.clone().setLength(o));this.faceMetaMap.set(e,{normal:t.clone().normalize(),isMinFace:n,center:i.clone()}),this.isSyncingTransform=!0,s.position.copy(c),s.quaternion.copy(l),s.visible=this.isActive,a.object!==s&&a.attach(s),a.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),i=Math.abs(e.y),n=Math.abs(e.z);return t>=i&&t>=n?"x":i>=t&&i>=n?"y":"z"}handleTransformObjectChange(e){if(this.isSyncingTransform)return;const t=this.transformAnchors.get(e),i=this.faceMetaMap.get(e);if(!t||!i||!this.box||!this.maxBox)return;const n=i.normal,s=this.getDominantAxis(n),a=this.getFaceTransformOffset(),o=n[s],l=t.position[s]-o*a;if(i.isMinFace){const c=this.maxBox.min[s],h=this.box.max[s];this.box.min[s]=Math.max(c,Math.min(h,l))}else{const c=this.box.min[s],h=this.maxBox.max[s];this.box.max[s]=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 bi,t.name="ClippingBox",this.engine.scene.add(t)),[{name:"前",normal:new A(0,0,-1),isMinFace:!0,planePoint:e.min,vertices:[new A(e.min.x,e.max.y,e.min.z),new A(e.max.x,e.max.y,e.min.z),new A(e.max.x,e.min.y,e.min.z),new A(e.min.x,e.min.y,e.min.z)]},{name:"后",normal:new A(0,0,1),isMinFace:!1,planePoint:e.max,vertices:[new A(e.min.x,e.min.y,e.max.z),new A(e.max.x,e.min.y,e.max.z),new A(e.max.x,e.max.y,e.max.z),new A(e.min.x,e.max.y,e.max.z)]},{name:"右",normal:new A(1,0,0),isMinFace:!1,planePoint:e.max,vertices:[new A(e.max.x,e.min.y,e.max.z),new A(e.max.x,e.min.y,e.min.z),new A(e.max.x,e.max.y,e.min.z),new A(e.max.x,e.max.y,e.max.z)]},{name:"左",normal:new A(-1,0,0),isMinFace:!0,planePoint:e.min,vertices:[new A(e.min.x,e.min.y,e.min.z),new A(e.min.x,e.min.y,e.max.z),new A(e.min.x,e.max.y,e.max.z),new A(e.min.x,e.max.y,e.min.z)]},{name:"顶",normal:new A(0,1,0),isMinFace:!1,planePoint:e.max,vertices:[new A(e.min.x,e.max.y,e.max.z),new A(e.max.x,e.max.y,e.max.z),new A(e.max.x,e.max.y,e.min.z),new A(e.min.x,e.max.y,e.min.z)]},{name:"底",normal:new A(0,-1,0),isMinFace:!0,planePoint:e.min,vertices:[new A(e.min.x,e.min.y,e.min.z),new A(e.max.x,e.min.y,e.min.z),new A(e.max.x,e.min.y,e.max.z),new A(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(n=>{n.clippingPlanes=this.engine.sectionPlane}):i.material.clippingPlanes=this.engine.sectionPlane})}createFace(e,t,i,n,s,a){const o=new ot,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];o.setAttribute("position",new wt(l,3)),o.setIndex(c);let h=this.meshs.find(f=>f.name===n);if(h==null){const f=new Rt({color:65280,transparent:!0,opacity:this.faceIdleOpacity,side:Ht});f.polygonOffset=!0,f.polygonOffsetFactor=1,f.polygonOffsetUnits=4,h=new Ve(o,f),h.name=n,e.add(h),this.meshs.push(h)}else h.geometry=o;h.userData={dragNormal:i.clone(),isMinFace:s,faceName:n};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]),p=new ii({color:255}),u=new ot;u.setAttribute("position",new wt(d,3));let v=this.meshs.find(f=>f.name===n+"Line");v==null?(v=new oi(u,p),v.name=n+"Line",e.add(v),this.meshs.push(v)):(v.geometry=u,v.material=p);const m=new A;t.forEach(f=>m.add(f)),m.multiplyScalar(1/t.length),this.updateFaceTransformControl(n,i,m,s);const g=this.engine.sectionPlane.find(f=>f.name==n);g&&g.setFromNormalAndCoplanarPoint(i.clone().setLength(-1),a)}}class JU{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 A(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),i=t.intersectObjects(this.getInteractiveMeshes(),!1);i.length!==0&&(e.preventDefault(),e.stopImmediatePropagation(),this.handleMouseDown({button:e.button,raycaster:t,intersects:i}))};handleNativeMouseMove=e=>{if(!this.isDrag&&!(this.isCtrlDown||e.ctrlKey)){this.resetMeshOpacity();return}const t=this.createRaycasterFromMouseEvent(e),i=t.intersectObjects(this.getInteractiveMeshes(),!1);this.isDrag&&(e.preventDefault(),e.stopImmediatePropagation()),this.handleMouseMove({raycaster:t,intersects:i})};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),i=this.getTransformHandleOffset(),n=this.transformAnchor.position.clone().sub(this.center).dot(e)-i,s=Math.min(t.max,Math.max(t.min,n));Math.abs(s-Number(this.distance))>1e-5?this.updata_face(s):Math.abs(n-s)>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(i=>{i.name.includes("face")&&(i.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(i=>{i.clippingPlanes=e.engine.sectionPlane}):t.material.clippingPlanes=e.engine.sectionPlane,e.engine.clipping.clippingStencil?.addMesh(e.engine.sectionPlane.find(i=>i.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(i=>{i.name.includes("face")&&(i.visible=!1)})})}init(e){const t=this.engine.octreeBox.getBoundingBox();this.box=t,this.distance=0,this.center=new A((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,i){this.angleX=e,this.angleY=t,this.angleZ=i,this.distance=0,this.normal=new A(0,1,0).applyAxisAngle(new A(1,0,0),e).applyAxisAngle(new A(0,0,1),t).applyAxisAngle(new A(0,1,0),i).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 i=this.engine.sectionPlane?.find(n=>n.name==="face");if(i){const n=this.center.clone().add(this.normal.clone().multiplyScalar(t));i.setFromNormalAndCoplanarPoint(this.normal.clone().multiplyScalar(this.direction),n)}}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(i=>{i.clippingPlanes=e.engine.sectionPlane}):t.material.clippingPlanes=e.engine.sectionPlane,e.engine.clipping.clippingStencil?.addMesh(e.engine.sectionPlane.find(i=>i.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(x=>x.type=="Group"&&x.name=="ClippingBox");t==null&&(t=new bi,t.name="ClippingBox",this.engine.scene.add(t));const i=this.normal.clone().normalize(),n=this.center??new A((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=n.clone();const{tangent:s,bitangent:a}=this.getPlaneBasis(i),o=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,p=1/0,u=-1/0;o.forEach(x=>{const _=x.clone().sub(n),E=_.dot(s),S=_.dot(a);h=Math.min(h,E),d=Math.max(d,E),p=Math.min(p,S),u=Math.max(u,S)}),h-=c,d+=c,p-=c,u+=c;const v=i.clone().multiplyScalar(e),m=n.clone().add(s.clone().multiplyScalar(h)).add(a.clone().multiplyScalar(p)).add(v),g=n.clone().add(s.clone().multiplyScalar(d)).add(a.clone().multiplyScalar(p)).add(v),f=n.clone().add(s.clone().multiplyScalar(d)).add(a.clone().multiplyScalar(u)).add(v),y=n.clone().add(s.clone().multiplyScalar(h)).add(a.clone().multiplyScalar(u)).add(v);this.current_center=n.clone().add(v),this.createFace(t,[m,g,f,y],i,"face"),this.updateTransformControl(i)}createFace(e,t,i,n){const s=new ot,a=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]),o=[0,1,2,0,2,3];s.setAttribute("position",new wt(a,3)),s.setIndex(o);let l=this.meshs.find(v=>v.name==n);if(l==null){const v=new Rt({color:65280,transparent:!0,opacity:this.idleOpacity,side:Ht});v.polygonOffset=!0,v.polygonOffsetFactor=1,v.polygonOffsetUnits=4,l=new Ve(s,v),l.name=n,e.add(l),this.meshs.push(l)}else l.geometry=s;l.normal=i.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 ii({color:255}),d=new ot;d.setAttribute("position",new wt(c,3));let p=this.meshs.find(v=>v.name==n+"Line");p==null?(p=new oi(d,h),p.name=n+"Line",e.add(p),this.meshs.push(p)):(p.geometry=d,p.material=h);const u=this.engine.sectionPlane.find(v=>v.name==n);u&&this.current_center&&u.setFromNormalAndCoplanarPoint(i.clone().setLength(this.direction),this.current_center)}getPlaneBasis(e){const t=new A(1,0,0),i=new A(0,1,0),n=new A(0,0,1),s=Math.abs(e.dot(t)),a=Math.abs(e.dot(i)),o=Math.abs(e.dot(n));let l=t;a<=s&&a<=o?l=i:o<=s&&o<=a&&(l=n),l=l.clone().sub(e.clone().multiplyScalar(l.dot(e))).normalize();const c=new A().crossVectors(e,l).normalize();return{tangent:l,bitangent:c}}getBoxCorners(e){return[new A(e.min.x,e.min.y,e.min.z),new A(e.min.x,e.min.y,e.max.z),new A(e.min.x,e.max.y,e.min.z),new A(e.min.x,e.max.y,e.max.z),new A(e.max.x,e.min.y,e.min.z),new A(e.max.x,e.min.y,e.max.z),new A(e.max.x,e.max.y,e.min.z),new A(e.max.x,e.max.y,e.max.z)]}getDistanceRange(e){if(!this.box)return{min:0,max:0};const t=this.center??new A((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),i=this.getBoxCorners(this.box);let n=1/0,s=-1/0;return i.forEach(a=>{const o=a.clone().sub(t).dot(e);n=Math.min(n,o),s=Math.max(s,o)}),{min:n,max:s}}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 i=e.getHelper(),n=[];i.traverse(s=>{if(s?.name!==t||!s.geometry)return;const a=s.geometry;a.boundingBox||a.computeBoundingBox();const o=a.boundingBox;if(!o)return;const l=o.getCenter(new A);if(!(t==="X"&&l.x<0||t==="Y"&&l.y<0||t==="Z"&&l.z<0))return;const c=a.parameters,h=c&&c.radiusTop===0&&c.radiusBottom===.04&&c.height===.1,d=c&&c.radiusTop===.2&&c.radiusBottom===0&&c.height===.6;(h||d)&&n.push(s)}),n.forEach(s=>{s.parent?.remove(s)})}ensureTransformControl(){if(this.transformControl&&this.transformAnchor)return;const e=this.engine.renderer?.domElement,t=this.engine.camera;if(!e||!t)return;const i=new bt;i.name="SectionFaceTransformAnchor",i.visible=this.isActive,this.engine.scene.add(i);const n=new wM(t,e);n.name="SectionFaceTransformControl",n.setMode("translate"),n.setSpace("local"),n.showX=!0,n.showY=!1,n.showZ=!1,n.size=.85,n.enabled=this.isActive,n.attach(i),this.keepSingleDirectionArrow(n,"X"),n.addEventListener("dragging-changed",a=>{this.engine.controls.enabled=!a.value}),n.addEventListener("objectChange",this.handleTransformObjectChange);const s=n.getHelper();s.visible=this.isActive,this.engine.scene.add(s),this.transformAnchor=i,this.transformControl=n,this.transformHelper=s}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(),i=this.current_center.clone().add(e.clone().setLength(t)),n=new Ct().setFromUnitVectors(new A(1,0,0),e.clone().normalize());this.isSyncingTransformControl=!0,this.transformAnchor.position.copy(i),this.transformAnchor.quaternion.copy(n),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 In,i=new xe,n=this.engine.renderer.domElement.clientWidth,s=this.engine.renderer.domElement.clientHeight;return i.x=e.offsetX/n*2-1,i.y=-(e.offsetY/s)*2+1,t.setFromCamera(i,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 i=t[0],n=i.point.clone();this.isDrag=!0,this.pickPoint=n;const s=(i.face?.normal?.clone()??this.normal.clone()).clone();if(s.dot(this.normal)<0&&s.multiplyScalar(-1),s.normalize(),this.pickNormal=s,this.engine.controls.enabled=!1,this.dragStartDistance=Number(this.distance)||0,s.y==0){const a=new ri;a.setFromNormalAndCoplanarPoint(new A(0,1,0),n),this.plane=a}else{const a=new A(this.engine.camera.position.x,n.y,this.engine.camera.position.z),o=new ri;o.setFromNormalAndCoplanarPoint(a.clone().sub(n.clone()).setLength(1),n),this.plane=o}}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 i=this.pickPoint,n=this.pickNormal,s=this.plane;if(i!=null&&n!=null&&s!=null){const a=new A;if(e.raycaster.ray.intersectPlane(s,a)){const o=a.clone().sub(i.clone()).dot(n.clone()),l=this.getDistanceRange(this.normal.clone().normalize()),c=this.dragStartDistance+o;this.distance=Math.min(l.max,Math.max(l.min,c)),this.updata_face(this.distance)}}}}class QU{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 ek{engine;clippingTolerance=1e-4;sectionBox;sectionFace;clippingStencil;currentClippingMode="";constructor(e){this.engine=e;let t=new ri(new A(0,0,1),1e5);t.name="前";let i=new ri(new A(0,0,1),1e5);i.name="左";let n=new ri(new A(0,0,1),1e5);n.name="后";let s=new ri(new A(0,0,1),1e5);s.name="右";let a=new ri(new A(0,0,1),1e5);a.name="顶";let o=new ri(new A(0,0,1),1e5);o.name="底";let l=new ri(new A(0,0,1),1e5);l.name="face",this.engine.sectionPlane=[t,i,n,s,a,o,l]}init(){this.sectionBox=new $U(this.engine),this.sectionFace=new JU(this.engine)}scaleBox(){let e=this.engine.octreeBox.getBoundingBox();this.sectionBox.setBox(e)}clippingModel(e){let t=[];e.forEach(s=>{let a=this.engine.models.find(o=>o.url===s.url);s.ids.forEach(o=>{a.nodesMap.get(o).infos.forEach(l=>{t.push(l.box)})})}),this.active("box");let i=n(t);this.sectionBox.setBox(i);function n(s){let a=new A(1e8,1e9,1e10),o=new A(-1e8,-1e9,-1e10);return s.forEach(l=>{l.min.x<a.x&&(a.x=l.min.x),l.min.y<a.y&&(a.y=l.min.y),l.min.z<a.z&&(a.z=l.min.z),l.max.x>o.x&&(o.x=l.max.x),l.max.y>o.y&&(o.y=l.max.y),l.max.z>o.z&&(o.z=l.max.z)}),new Ot(a,o)}}updateClippingValue(e){let t=this.sectionBox.maxBox,i=t.min.x+(t.max.x-t.min.x)*e.x.min*.01,n=t.min.y+(t.max.y-t.min.y)*e.y.min*.01,s=t.min.z+(t.max.z-t.min.z)*e.z.min*.01,a=t.min.x+(t.max.x-t.min.x)*e.x.max*.01,o=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:i,minY:n,minZ:s,maxX:a,maxY:o,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 QU(this.engine);t.init(),t.catch_face(i=>{this.sectionFace.init(),this.sectionFace.active();let n=this.engine.octreeBox.getBoundingBox(),s=n.min.clone().add(n.max.clone()).multiplyScalar(.5),a=i.position.clone().sub(s),o=new A(i.dir.x,i.dir.y,i.dir.z),l=a.dot(o);this.sectionFace.setFaceNormal(i.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 i=this.getEffectiveClippingPlanes();return i.length===0?!0:i.every(n=>n.distanceToPoint(e)>=-t)}filterIntersectionsByClipping(e,t=this.clippingTolerance){return!Array.isArray(e)||e.length===0?[]:e.filter(i=>this.isPointInClippingRange(i?.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 ri);if(this.currentClippingMode==="x"||this.currentClippingMode==="y"||this.currentClippingMode==="z"||this.currentClippingMode==="face"){const t=e[6];return t instanceof ri?[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 i=this.engine.octreeBox.getBoundingBox(),n=new A((i.min.x+i.max.x)/2,(i.min.y+i.max.y)/2,(i.min.z+i.max.z)/2),s=new A(t.x,t.y,t.z).normalize().clone().negate(),a=new A(e.x,e.y,e.z).clone().sub(n).dot(s);this.sectionFace.setFaceNormalPlaneOnly(s,a),this.sectionFace.activateClippingOnly(),this.currentClippingMode="face"}}class tk{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 ik{engine;constructor(e){this.engine=e}getEngineInfo(){let e=0,t=0,i=0;return!this.engine||!this.engine.scene?{totalVertices:0,totalTriangles:0,meshCount:0}:(this.engine.scene.traverse(n=>{if(n instanceof Ve){const s=n.geometry;if(s&&s.attributes){const a=s.attributes.position;if(a){const o=a.count;e+=o;let l=0;s.index?l=s.index.count/3:l=o/3,t+=l}}}}),this.engine.engineStatus.models.forEach(n=>{i=i+(Array.isArray(n?.info?.modelEdge)?n.info.modelEdge.length:0)}),{totalVertices:Math.floor(e),totalTriangles:Math.floor(t),meshCount:i})}}class nk{engine;constructor(e){this.engine=e}init(){}getModelPropertiesWithName(e,t,i,n){let s=this.engine.engineStatus.models.find(o=>o.url===e);s.properties==null?qc(e+"/property",o=>{let l=JSON.parse(o);s.properties=l,setTimeout(()=>{a(l,i,t,n)},100)}):a(s.properties,i,t,n);function a(o,l,c,h){let d={};o.models[c.toString()||""].forEach(p=>{i.includes(o.names[p[1]])&&(d[o.names[p[1]]]=o.values[p[2]])}),h?.({id:c,properties:d})}}getModelProperties(e,t,i){let n=this.engine.engineStatus.models.find(a=>a.url===e);n.properties==null&&qc(e+"/property",a=>{let o=JSON.parse(a);n.properties=o,setTimeout(()=>{s(o,t,i)},100)}),s(n.properties,t,i);function s(a,o,l){let c=[],h=a.models[o.toString()||""],d=h.map(p=>p[0]);d=d.filter((p,u)=>d.indexOf(p)===u),d.forEach(p=>{let u={name:a.categorys[p],children:[]};c.push(u),h.filter(v=>v[0]===p).forEach(v=>{u.children.push({name:a.names[v[1]],value:a.values[v[2]]})})}),l?.({properties:c,materials:c})}}}class sk{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,i,n)=>n.indexOf(t)===i),e}getModelMajors(){let e=[];return this.engine.engineStatus.models.forEach(t=>{t.info.modelMapper.forEach(i=>{e.push(i.majorName)})}),e=e.filter((t,i,n)=>n.indexOf(t)===i),e}getModelLevels(){let e=[];return this.engine.engineStatus.models.forEach(t=>{t.info.modelMapper.forEach(i=>{e.push(i.levelName)})}),e=e.filter((t,i,n)=>n.indexOf(t)===i),e}getModelMappers(e){}getModelMapper(e,t){let i=this.engine.engineStatus.models.find(n=>n.url==e);return i?i.info.modelMapper.find(n=>n.id==t):null}getModelsWithLevelType(e,t,i=null){let n=[];return this.engine.engineStatus.models.forEach(s=>{let a={url:s.url,ids:[]};n.push(a),s.info.modelMapper.filter(o=>o.levelName===e&&o.typeName===t).forEach(o=>{a.ids.push(Number(o.id))})}),i&&i(n),n}getModelsWithType(e,t=null){let i=[];return this.engine.engineStatus.models.forEach(n=>{let s={url:n.url,ids:[]};i.push(s),n.info.modelMapper.filter(a=>a.typeName===e).forEach(a=>{s.ids.push(Number(a.id))})}),t&&t(i),i}getModelsWithLevel(e,t){let i=[];return this.engine.engineStatus.models.forEach(n=>{let s={url:n.url,ids:[]};i.push(s),n.info.modelMapper.filter(a=>a.levelName===e).forEach(a=>{s.ids.push(Number(a.id))})}),t&&t(i),i}getModelsWithMajor(e,t){let i=[];return this.engine.engineStatus.models.forEach(n=>{let s={url:n.url,ids:[]};i.push(s),n.info.modelMapper.filter(a=>a.majorName===e).forEach(a=>{s.ids.push(Number(a.id))})}),t&&t(i),i}}class rk{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 ii({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(t=>{t.polygonOffset=!0,t.polygonOffsetFactor=1,t.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(t=>{t.polygonOffset=!1})})}hasPendingModelEdges(){return(this.engine?.engineStatus?.models??[]).some(e=>!this.indexes.has(e.url))}loadZipJsonAsync(e){return new Promise((t,i)=>{qc(e,n=>{if(n==null){i(new Error(`[ModelEdge] empty edge zip: ${e}`));return}t(n)},()=>{i(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 i=await this.loadZipJsonAsync(e.url+"/edge"),n=JSON.parse(i);t.modelEdge=Array.isArray(n)?n:[]}catch(i){console.error("[ModelEdge] failed to load model edge",{url:e?.url,error:i}),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 i=await this.ensureModelEdgeData(t),n=[],s=new Map;i.forEach(a=>{if(!Array.isArray(a?.points))return;const o=n.length;for(let l=0;l<a.points.length;l++)a.points[l]?.length===2&&(n.push(a.points[l][0].X),n.push(a.points[l][0].Z),n.push(-a.points[l][0].Y),n.push(a.points[l][1].X),n.push(a.points[l][1].Z),n.push(-a.points[l][1].Y));s.set(Number(a.id),[o,n.length,a.points])}),this.indexes.set(t.url,s)}this.modelEdgeLoaded=!this.hasPendingModelEdges()})().finally(()=>{this.modelEdgeLoadingPromise=null}),await this.modelEdgeLoadingPromise}}async show(){await this.loadModelEdge(),this.isActive&&this.indexes.forEach((e,t)=>{const i=this.groupEdge.children.find(o=>o.url==t);if(i){i.visible=!0;return}const n=[];if(e.forEach(o=>{o[2].forEach(l=>{l?.length===2&&(n.push(l[0].X),n.push(l[0].Z),n.push(-l[0].Y),n.push(l[1].X),n.push(l[1].Z),n.push(-l[1].Y))})}),n.length===0)return;const s=new ot;s.setAttribute("position",new tt(n,3));const a=new fi(s,this.material);a.url=t,this.groupEdge.add(a)})}getModelEdge(e,t){const i=this.indexes.get(e);if(i){const n=i.get(Number(t));if(n)return n.slice()}return this.loadModelEdge(),null}hideModelEdge(e,t){const i=this.indexes.get(e);if(!i){this.loadModelEdge();return}const n=i.get(Number(t));if(n){const[s,a]=n,o=this.groupEdge.children.find(l=>l.url==e);if(o){const l=o.geometry.attributes.position.array;for(let c=s;c<a;c++)l[c]=NaN;o.geometry.attributes.position.needsUpdate=!0}}}setOpacity(e){this.material.opacity=e}showModelEdge(e,t){const i=this.indexes.get(e);if(!i){this.loadModelEdge();return}const n=i.get(Number(t));if(n){const[s,a,o]=n,l=this.groupEdge.children.find(c=>c.url==e);if(l){const c=l.geometry.attributes.position.array;let h=0;for(let d=s;d<a;d+=3){const p=Math.floor(h/6),u=h%6>=3;if(o[p]&&o[p].length===2){const v=u?o[p][1]:o[p][0];c[d]=v.X,c[d+1]=v.Z,c[d+2]=-v.Y}h+=3}l.geometry.attributes.position.needsUpdate=!0}}}}class ak{config;constructor(e){this.config={temperature:.7,maxTokens:2e4,timeout:3e5,...e}}async chat(e){const t=new AbortController,i=setTimeout(()=>t.abort(),this.config.timeout);try{const n=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(i),!n.ok){const s=await n.json().catch(()=>({}));throw new Error(`API请求失败 (${n.status}): ${s.error?.message||s.message||n.statusText}`)}return(await n.json()).choices?.[0]?.message?.content||""}catch(n){throw clearTimeout(i),n.name==="AbortError"?new Error("请求超时,请重试"):n.message.includes("Failed to fetch")?new Error(`网络请求失败,请检查:
|
|
8994
8994
|
1. 网络连接
|
|
8995
8995
|
2. API地址是否正确
|
|
8996
8996
|
3. 是否有CORS限制`):n}}async chatStream(e,t){const i=new AbortController,n=setTimeout(()=>i.abort(),this.config.timeout);try{const s=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:i.signal});if(clearTimeout(n),!s.ok){const c=await s.json().catch(()=>({}));throw new Error(`API请求失败 (${s.status}): ${c.error?.message||c.message||s.statusText}`)}const a=s.body?.getReader();if(!a)throw new Error("无法读取响应流");const o=new TextDecoder;let l="";for(;;){const{done:c,value:h}=await a.read();if(c){t("",!0);break}l+=o.decode(h,{stream:!0});const d=l.split(`
|
|
@@ -9421,7 +9421,7 @@ ${JSON.stringify(l,null,2)}
|
|
|
9421
9421
|
<path d="M2 2L14 14" stroke="currentColor" stroke-width="1.2"/>
|
|
9422
9422
|
<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"/>
|
|
9423
9423
|
<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"/>
|
|
9424
|
-
</svg>`}_colorToHex(e){return"#"+e.toString(16).padStart(6,"0")}_makeDraggable(e,t){t.onmousedown=i=>{i.preventDefault();const n=e.getBoundingClientRect(),s=e.offsetParent?.getBoundingClientRect()??{left:0,top:0};e.style.left=n.left-s.left+"px",e.style.top=n.top-s.top+"px",e.style.right="auto",e.style.bottom="auto";const a=i.clientX-n.left,o=i.clientY-n.top,l=h=>{e.style.left=h.clientX-a-s.left+"px",e.style.top=h.clientY-o-s.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 DM{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 Ik(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 i=this.layerMap.get(e);i&&(i.visible=t),this._applyVisibility(e,t)}toggleLayer(e){const t=this.layerMap.get(e);if(!t)return!0;const i=!t.visible;return this.setLayerVisible(e,i),i}setAllLayersVisible(e){for(const t of this.layerMap.keys()){const i=this.layerMap.get(t);i.visible=e,this._applyVisibility(t,e)}}isAllVisible(){return Array.from(this.layerMap.values()).every(e=>e.visible)}_applyVisibility(e,t){const i=this.engine?.scene;if(!i)return;const n=e+"||";i.children.forEach(s=>{s.name?.startsWith(n)&&(s.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 NM{engine;data=null;enableValidation=!0;constructor(e){for(this.engine=e,this.engine.modelGroup=new bi,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(On.ModelLoadStart,{url:e}),qc(e,async i=>{const n=JSON.parse(i);this.engine.dwgData=n,this.data=n,await this.buildScene(n);try{this.engine.fitToView()}catch{}this.engine.layerManager||(this.engine.layerManager=new DM(this.engine)),this.engine.layerManager._loadLayers(),this.engine.events&&this.engine.events.trigger(On.ModelLoaded,{})},i=>{this._emitProgress(0,"抱歉,图纸加载失败")});else{this.engine.events&&this.engine.events.trigger(On.ModelLoadStart,{url:e}),this._emitProgress(10,"请求数据...");const i=await this.fetchJson(e);this._emitProgress(20,"解析数据...");const n=this.parseData(i);if(this.engine.dwgData=n,!n)throw new Error("Failed to parse DWG data");this.data=n,await this.buildScene(n),this.engine.fitToView(),this.engine.layerManager._loadLayers(),this.engine.events&&this.engine.events.trigger(On.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 nh.fromUrl(e);return nh.toThreeFont(t)}_emitProgress(e,t){this.engine.events&&this.engine.events.trigger(On.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,i)=>{let n=[];if(t.forEach(a=>{for(const o of a)n.push(o)}),n.length!=0){const a=new ot().setFromPoints(n);let o=parseInt(i.split("||")[1]);if(o==0){var s=this.model.layers.find(d=>d.name==i.split("||")[0]);o=s.color}const l=new ii({color:o}),c=new fi(a,l);c.name=i,c.clonePoints=[],n.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,p)=>{this.model.nodeMap.has(p)?this.model.nodeMap.get(p).push({indexes:[this.engine.modelGroup.children.length-1,h,h+d.length*3],min:new A(Math.min(...d.map(u=>u.x)),Math.min(...d.map(u=>u.y)),0),max:new A(Math.max(...d.map(u=>u.x)),Math.max(...d.map(u=>u.y)),0)}):this.model.nodeMap.set(p,[{indexes:[this.engine.modelGroup.children.length-1,h,h+d.length*3],min:new A(Math.min(...d.map(u=>u.x)),Math.min(...d.map(u=>u.y)),0),max:new A(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,i)=>{const n=Ka(t.map(c=>c.geometry),!1);let s=Number.parseInt(i.split("||")[1]);if(s===0){const c=this.model.layers.find(h=>h.name===i.split("||")[0]);c&&(s=c.color)}const a=new Rt({color:s,side:Ht});i.includes("_hitbox")&&(a.visible=!1);let o=new Ve(n,a);o.name=i,o.materialClone=a.clone(),o.isSplit=!1,o.geometrys=t.map(c=>c.geometry),this.engine.modelGroup.add(o);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 A(c.info.min[0],c.info.min[1],0),max:new A(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 A(c.info.min[0],c.info.min[1],0),max:new A(c.info.max[0],c.info.max[1],0)}])})}),this._emitProgress(93,"正在加载..."),await Promise.resolve(),this.model.hatchMap.forEach((t,i)=>{let n=Ka(t.map(h=>h.geometry),!1),s=parseInt(i.split("||")[1]);if(s==0){var a=this.model.layers.find(h=>h.name==i.split("||")[0]);s=a.color}const o=new Rt({color:s,side:Ht,transparent:!0,opacity:.5});let l=new Ve(n,o);l.name=i,l.materialClone=o.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 A(h.info.min[0],h.info.min[1],0),max:new A(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 A(h.info.min[0],h.info.min[1],0),max:new A(h.info.max[0],h.info.max[1],0)}])})}),this._emitProgress(100,"加载完成")}loadBlock(e,t,i,n=0){let s=[0,0,0];i&&(s=e.origin),e.entities.forEach(a=>{const o=a.layer+"||"+a.color;let l=new Map;i?(l=this.totalBlock.get(t),l==null&&(l=new Map,this.totalBlock.set(t,l))):(l=this.model.modelMap.get(o),l==null&&(l=new Map,this.model.modelMap.set(o,l)));let c=[];switch(a.type){case"LINE":c=this.getPoint_line(a,s);break;case"CIRCLE":c=this.getPoint_arc(a,s);break;case"POLYLINE":c=this.getPoint_polyline(a,s);break;case"MTEXT":this.create_text(a);break;case"HATCH":this.create_hatch(a);break;case"INSERT":if(i==!1){this.totalBlock.get(a.blockId)?.forEach(p=>{c.push(...p.map(u=>u.clone()))});const d=this.getMatrix(a.position,a.scale,a.rotation);c.forEach(p=>{p.applyMatrix4(d)})}break;default:return console.warn(`[LoaderModule2d] Unknown entity type: ${a.type}`),null}l.has(a.linkId)?l.get(a.linkId).push(...c):l.set(a.linkId,c)})}getPoint_polyline(e,t){let i=[];for(let n=0;n<e.points.length-1;n++)i.push(new A(e.points[n].x,e.points[n].y,0)),i.push(new A(e.points[n+1].x,e.points[n+1].y,0));return e.closed&&(i.push(new A(e.points[e.points.length-1].x,e.points[e.points.length-1].y,0)),i.push(new A(e.points[0].x,e.points[0].y,0))),i.forEach(n=>{n[0]=n[0]-t[0],n[1]=n[1]-t[1]}),i}create_hatch(e){if(!e.loops||e.loops.length===0)return;const t=e.loops.filter(o=>o.type===!0),i=e.loops.filter(o=>o.type===!1),n=[];for(const o of t){if(!o.points||o.points.length<3)continue;const l=new Hs;l.moveTo(o.points[0][0],o.points[0][1]);for(let c=1;c<o.points.length;c++)l.lineTo(o.points[c][0],o.points[c][1]);l.closePath();for(const c of i){if(!c.points||c.points.length<3)continue;const h=new fc;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)}n.push(new xc(l))}if(n.length===0)return;const s=n.length===1?n[0]:Ka(n,!1),a=e.layer+"||"+e.color;this.model.hatchMap.has(a)?this.model.hatchMap.get(a).push({geometry:s,info:e}):this.model.hatchMap.set(a,[{geometry:s,info:e}])}create_text(e){if(!this.font||!e.text)return;const t=new Tk(e.text,{font:this.font,size:e.height??100,depth:0});e.position[1]=e.position[1]-e.height;const i=this.getMatrix(e.position,[1,1,1],e.rotation);t.applyMatrix4(i);const n=e.layer+"||"+e.color;this.model.textMap.has(n)?this.model.textMap.get(n).push({geometry:t,info:e}):this.model.textMap.set(n,[{geometry:t,info:e}]),t.computeBoundingBox();const s=t.boundingBox;if(s){const a=s.max.x-s.min.x,o=s.max.y-s.min.y,l=new Wn(a,o);new Rt({visible:!1,side:Ht,depthWrite:!1});let c=[(s.min.x+s.max.x)/2,(s.min.y+s.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 i=new A(e.startPoint[0],e.startPoint[1],e.startPoint[2]||0),n=new A(e.endPoint[0],e.endPoint[1],e.endPoint[2]||0);let s=[i,n];return s.forEach(a=>{a[0]=a[0]-t[0],a[1]=a[1]-t[1]}),s}getPoint_arc(e,t){const i=e.center[0],n=e.center[1],s=e.radius,a=new dc(i,n,s,s,e.startAngle,e.endAngle,!1,0).getPoints(30).map(l=>new A(l.x,l.y,0));let o=[];for(let l=0;l<a.length-1;l++)o.push(a[l].clone()),o.push(a[l+1].clone());return o.forEach(l=>{l[0]=l[0]-t[0],l[1]=l[1]-t[1]}),o}getMatrix(e,t,i){const n=new A(e[0],e[1],e[2]),s=new Pi(0,0,i),a=new A(t[0],t[1],t[2]),o=new Ct;o.setFromEuler(s);const l=new Ke;return l.compose(n,o,a),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 Dk{engine;sectionPlaneGroup=null;loaderModule2d;constructor(e){this.engine=e,this.loaderModule2d=new NM(this.engine)}async attachSectionPlane(e,t,i,n){await this.loaderModule2d.loadModel(e+"/"+t,{chunkSize:1e3,enableChunkedLoading:!0,enableValidation:!0});let s=new A(i.x,i.y,i.z),a=new A(n.x,n.y,n.z);const o=new A().copy(a);let l=s.clone().sub(this.engine.modelGroup.position.clone()).dot(a);this.engine.modelGroup.lookAt(o);let c=this.engine.modelGroup.position.clone().add(a.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 i=new A(e.x,e.y,e.z),n=new Pi(t.x,t.y,t.z),s=new A(1,1,1),a=new Ct;a.setFromEuler(n);const o=new Ke;return o.compose(i,a,s),o}computeMatrixFromOriginAndDirection(e,t){const i=new Ke,n=t.clone().normalize();if(n.length()===0)return console.warn("方向向量长度为零,返回单位矩阵"),i.identity();const s=new A(0,1,0);let a=new A().crossVectors(s,n);if(a.length()<1e-4){const c=new A(0,0,1);a=new A().crossVectors(c,n).normalize()}else a.normalize();const o=new A().crossVectors(a,n).normalize(),l=new Ke;return l.set(a.x,n.x,o.x,0,a.y,n.y,o.y,0,a.z,n.z,o.z,0,0,0,0,1),l.setPosition(e),l}}class Nk{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=dP,this.options=e,this.container=document.getElementById(e.containerId),!this.container)throw new Error(`Container ${e.containerId} not found`);if(this.engineModelModule=new rU(this),this.engineModelModule.init(),this.ai=new ok(this),this.deviceModule=new pP(this),this.deviceType=this.deviceModule.getDeviceType(),this.cameraModule=new Ir(this),this.sceneModule=new uP(this),this.scene=this.sceneModule.scene,this.renderModule=new wD(this),this.renderer=this.renderModule.createRenderer(),this.camera=this.cameraModule.orthographicCamera,this.scene.camera=this.camera,this.renderer){const s=this.renderer;s.interactionCullingEnabled=!0,s.interactionActive=!1,s.interactionRenderScene=this.scene,s.interactionFrameBudgetMs=this.options.interactionFrameBudgetMs??6,s.interactionSkipShadows=this.options.interactionSkipShadows??!0}this.controlModule=new WD(this),this.controlModule.switchDefaultMode(),this.controls=this.controlModule.orbitControls,this.clipping=new ek(this),this.clipping.init(),this.composerModule=new n6(this),this.composerModule.init(),this.events=new J8,this.engineStatus=new $8(this),this.engineStatus.init(),this.loaderModule=new K8(this),this.lightModule=new Q8(this),this.lightModule.init(),this.viewCube=new BU(this),this.viewCube.init(),this.options.showViewCube==!1&&this.viewCube.hide(),this.octreeBox=FU(this),this.rangeScale=new zU(this),this.rangeScale.init(),this.setting=new HU(this),this.engineModelModule.init(),this.handelBehaved=P0(this),this.modelMapperBatch=new sk(this),this.measure=new KU(this),this.modelToolModule=new tU(this),this.modelProperties=new nk(this),this.interactionModule=new eU(this),this.interactionModule.init(),this.interactionModule.active(),this.hoverHighLight=new $p(this),this.modelEdge=new rk(this),this.modelTree=new tk(this),this.viewTree=new Ek(this),this.merge2d=new Dk(this),this.engineInfo=new ik(this),this.pathRoaming=new lk(this),this.pathRoaming.init(),this.oneClickEncoding=new wk(this),this.minMap=new ck(this),this.linkElement2d3d=new Mk(this),this.linkView2d3d=new Sk(this),this.grid=new uk(this),this.level=new mk(this),this.issueReport=new gk(this),this.text=new vk(this),this.hdr=new yk(this),this.ground=new iv(this),this.ground.init(),this.skyManager=new bk(this),this.setting.init(),this.worldToScreen=new Ft(this.camera,this.renderer,this.scene),this.options.showStats&&(this.stats=new cU,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 i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.style.position="absolute",i.style.zIndex="1000",i.style.left="0px",i.style.top="0px",i.style.pointerEvents="none",this.container.appendChild(i),this.catchSvg=i,this.onWindowResize=()=>{this.handleWindowResize()},window.addEventListener("resize",this.onWindowResize);let n=this;this.controls.addEventListener("start",()=>{n.renderer&&(n.renderer.interactionActive=!0),n.events.trigger(Ml.EngineBusy),n.container&&(n.container.style.cursor="none")}),this.controls.addEventListener("end",()=>{n.renderer&&(n.renderer.interactionActive=!1),n.events.trigger(Ml.EngineFree),n.container&&(n.container.style.cursor="default")}),this.controls.addEventListener("change",()=>{const s=new A;n.camera.getWorldDirection(s);const a=Math.atan2(s.x,-s.z);let o=new CustomEvent("D3ViewUpdate",{detail:{position:n.camera.position,rotation:a,type:n.camera.type}});window.dispatchEvent(o)}),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 s=performance.now();if(s-this._fpsLastCheck>=this._fpsCheckInterval){const a=s-this._fpsLastCheck,o=this._fpsFrameCount/a*1e3;this._fpsFrameCount=0,this._fpsLastCheck=s,o<this._fpsThreshold?(this._lowFpsCount++,this._highFpsCount=0,this._lowFpsCount>=this._lowFpsRequired&&s-this._fpsLastSwitch>this._fpsSwitchCooldown&&(this._adaptiveRenderingDowngrade(),this._fpsLastSwitch=s,this._lowFpsCount=0)):o>this._fpsUpgradeThreshold?(this._highFpsCount++,this._lowFpsCount=0):(this._lowFpsCount=0,this._highFpsCount=0)}if(this.scene){let a=this.scene?.dirLight;a&&this.camera&&this.updateLightPosition(this.camera,a)}},this.animate()}updateVersionDisplay(){if(!this.versionEl)return;const e={simple:"simple",balance:"balance",advanced:"advanced"},t=this.engineModelModule?.getCurrentMode()??"",i=e[t]??t;this.versionEl.innerHTML=`v${this.version} | ${i}`}updateLightPosition(e,t){const i=new A;e.getWorldDirection(i);const n=100,s=new A().copy(i).multiplyScalar(-n),a=new A(0,1,0),o=new A().crossVectors(i,a).normalize();s.addScaledVector(a,n*.5),s.addScaledVector(o,n*.3),t.position.copy(e.position).add(s);const l=new A().copy(e.position).add(i.multiplyScalar(20));t.target.position.copy(l),t.target.updateMatrixWorld()}_adaptiveRenderingDowngrade(){const e=["simple","balance","advanced"],t=this.engineModelModule.getCurrentMode(),i=e.indexOf(t);if(i>0){const n=e[i-1];console.log(`[AdaptiveRendering] FPS低于${this._fpsThreshold},自动降级: ${t} → ${n}`),this.engineModelModule.autoSwitch(n)}}_adaptiveRenderingUpgrade(){const e=["simple","balance","advanced"],t=this.engineModelModule.getCurrentMode(),i=e.indexOf(t);if(i<e.length-1){const n=e[i+1];console.log(`[AdaptiveRendering] FPS高于${this._fpsUpgradeThreshold},自动升级: ${t} → ${n}`),this.engineModelModule.autoSwitch(n)}}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 n=this.deviceModule.getContainerSize();e=e??n.width,t=t??n.height}if(!e||!t)return;this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(e,t);const i=e/t;if(this.camera===this.cameraModule.perspectiveCamera)this.cameraModule.perspectiveCamera.aspect=i,this.cameraModule.perspectiveCamera.updateProjectionMatrix(),this.camera=this.cameraModule.perspectiveCamera;else if(this.camera===this.cameraModule.orthographicCamera){const n=this.cameraModule.orthographicCamera,s=this.cameraModule.getOrthographicVisibleHeight(n);this.cameraModule.setOrthographicVisibleHeight(s,n),n.updateProjectionMatrix()}if(this.catchSvg){const n=this.container.clientWidth,s=this.container.clientHeight;this.catchSvg.setAttribute("viewBox",`0 0 ${n} ${s}`)}this.events&&this.events.trigger(Ml.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){e&&([...e.children].forEach(t=>{this.clearScene(t)}),e.parent&&e.parent.remove(e),e instanceof Ve&&(e.geometry&&e.geometry.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach(t=>this.disposeMaterial(t)):this.disposeMaterial(e.material))),e instanceof oi&&(e.geometry&&e.geometry.dispose(),e.material&&this.disposeMaterial(e.material)),e instanceof ou&&(e.geometry&&e.geometry.dispose(),e.material&&this.disposeMaterial(e.material)),e instanceof ti&&(e.geometry&&e.geometry.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach(t=>this.disposeMaterial(t)):this.disposeMaterial(e.material)),e.instanceMatrix&&(e.instanceMatrix=null),e.instanceColor&&(e.instanceColor=null)),e instanceof nc&&e.material&&this.disposeMaterial(e.material))}disposeMaterial(e){e&&(["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(t=>{const i=e[t];i&&i instanceof ei&&i.dispose()}),e.dispose())}}const Uk=`
|
|
9424
|
+
</svg>`}_colorToHex(e){return"#"+e.toString(16).padStart(6,"0")}_makeDraggable(e,t){t.onmousedown=i=>{i.preventDefault();const n=e.getBoundingClientRect(),s=e.offsetParent?.getBoundingClientRect()??{left:0,top:0};e.style.left=n.left-s.left+"px",e.style.top=n.top-s.top+"px",e.style.right="auto",e.style.bottom="auto";const a=i.clientX-n.left,o=i.clientY-n.top,l=h=>{e.style.left=h.clientX-a-s.left+"px",e.style.top=h.clientY-o-s.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 DM{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 Ik(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 i=this.layerMap.get(e);i&&(i.visible=t),this._applyVisibility(e,t)}toggleLayer(e){const t=this.layerMap.get(e);if(!t)return!0;const i=!t.visible;return this.setLayerVisible(e,i),i}setAllLayersVisible(e){for(const t of this.layerMap.keys()){const i=this.layerMap.get(t);i.visible=e,this._applyVisibility(t,e)}}isAllVisible(){return Array.from(this.layerMap.values()).every(e=>e.visible)}_applyVisibility(e,t){const i=this.engine?.scene;if(!i)return;const n=e+"||";i.children.forEach(s=>{s.name?.startsWith(n)&&(s.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 NM{engine;data=null;enableValidation=!0;constructor(e){for(this.engine=e,this.engine.modelGroup=new bi,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(On.ModelLoadStart,{url:e}),qc(e,async i=>{const n=JSON.parse(i);this.engine.dwgData=n,this.data=n,await this.buildScene(n);try{this.engine.fitToView()}catch{}this.engine.layerManager||(this.engine.layerManager=new DM(this.engine)),this.engine.layerManager._loadLayers(),this.engine.events&&this.engine.events.trigger(On.ModelLoaded,{})},i=>{this._emitProgress(0,"抱歉,图纸加载失败")});else{this.engine.events&&this.engine.events.trigger(On.ModelLoadStart,{url:e}),this._emitProgress(10,"请求数据...");const i=await this.fetchJson(e);this._emitProgress(20,"解析数据...");const n=this.parseData(i);if(this.engine.dwgData=n,!n)throw new Error("Failed to parse DWG data");this.data=n,await this.buildScene(n),this.engine.fitToView(),this.engine.layerManager._loadLayers(),this.engine.events&&this.engine.events.trigger(On.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 nh.fromUrl(e);return nh.toThreeFont(t)}_emitProgress(e,t){this.engine.events&&this.engine.events.trigger(On.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,i)=>{let n=[];if(t.forEach(a=>{for(const o of a)n.push(o)}),n.length!=0){const a=new ot().setFromPoints(n);let o=parseInt(i.split("||")[1]);if(o==0){var s=this.model.layers.find(d=>d.name==i.split("||")[0]);o=s.color}const l=new ii({color:o}),c=new fi(a,l);c.name=i,c.clonePoints=[],n.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,p)=>{this.model.nodeMap.has(p)?this.model.nodeMap.get(p).push({indexes:[this.engine.modelGroup.children.length-1,h,h+d.length*3],min:new A(Math.min(...d.map(u=>u.x)),Math.min(...d.map(u=>u.y)),0),max:new A(Math.max(...d.map(u=>u.x)),Math.max(...d.map(u=>u.y)),0)}):this.model.nodeMap.set(p,[{indexes:[this.engine.modelGroup.children.length-1,h,h+d.length*3],min:new A(Math.min(...d.map(u=>u.x)),Math.min(...d.map(u=>u.y)),0),max:new A(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,i)=>{const n=Ka(t.map(c=>c.geometry),!1);let s=Number.parseInt(i.split("||")[1]);if(s===0){const c=this.model.layers.find(h=>h.name===i.split("||")[0]);c&&(s=c.color)}const a=new Rt({color:s,side:Ht});i.includes("_hitbox")&&(a.visible=!1);let o=new Ve(n,a);o.name=i,o.materialClone=a.clone(),o.isSplit=!1,o.geometrys=t.map(c=>c.geometry),this.engine.modelGroup.add(o);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 A(c.info.min[0],c.info.min[1],0),max:new A(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 A(c.info.min[0],c.info.min[1],0),max:new A(c.info.max[0],c.info.max[1],0)}])})}),this._emitProgress(93,"正在加载..."),await Promise.resolve(),this.model.hatchMap.forEach((t,i)=>{let n=Ka(t.map(h=>h.geometry),!1),s=parseInt(i.split("||")[1]);if(s==0){var a=this.model.layers.find(h=>h.name==i.split("||")[0]);s=a.color}const o=new Rt({color:s,side:Ht,transparent:!0,opacity:.5});let l=new Ve(n,o);l.name=i,l.materialClone=o.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 A(h.info.min[0],h.info.min[1],0),max:new A(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 A(h.info.min[0],h.info.min[1],0),max:new A(h.info.max[0],h.info.max[1],0)}])})}),this._emitProgress(100,"加载完成")}loadBlock(e,t,i,n=0){let s=[0,0,0];i&&(s=e.origin),e.entities.forEach(a=>{const o=a.layer+"||"+a.color;let l=new Map;i?(l=this.totalBlock.get(t),l==null&&(l=new Map,this.totalBlock.set(t,l))):(l=this.model.modelMap.get(o),l==null&&(l=new Map,this.model.modelMap.set(o,l)));let c=[];switch(a.type){case"LINE":c=this.getPoint_line(a,s);break;case"CIRCLE":c=this.getPoint_arc(a,s);break;case"POLYLINE":c=this.getPoint_polyline(a,s);break;case"MTEXT":this.create_text(a);break;case"HATCH":this.create_hatch(a);break;case"INSERT":if(i==!1){this.totalBlock.get(a.blockId)?.forEach(p=>{c.push(...p.map(u=>u.clone()))});const d=this.getMatrix(a.position,a.scale,a.rotation);c.forEach(p=>{p.applyMatrix4(d)})}break;default:return console.warn(`[LoaderModule2d] Unknown entity type: ${a.type}`),null}l.has(a.linkId)?l.get(a.linkId).push(...c):l.set(a.linkId,c)})}getPoint_polyline(e,t){let i=[];for(let n=0;n<e.points.length-1;n++)i.push(new A(e.points[n].x,e.points[n].y,0)),i.push(new A(e.points[n+1].x,e.points[n+1].y,0));return e.closed&&(i.push(new A(e.points[e.points.length-1].x,e.points[e.points.length-1].y,0)),i.push(new A(e.points[0].x,e.points[0].y,0))),i.forEach(n=>{n[0]=n[0]-t[0],n[1]=n[1]-t[1]}),i}create_hatch(e){if(!e.loops||e.loops.length===0)return;const t=e.loops.filter(o=>o.type===!0),i=e.loops.filter(o=>o.type===!1),n=[];for(const o of t){if(!o.points||o.points.length<3)continue;const l=new Hs;l.moveTo(o.points[0][0],o.points[0][1]);for(let c=1;c<o.points.length;c++)l.lineTo(o.points[c][0],o.points[c][1]);l.closePath();for(const c of i){if(!c.points||c.points.length<3)continue;const h=new fc;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)}n.push(new xc(l))}if(n.length===0)return;const s=n.length===1?n[0]:Ka(n,!1),a=e.layer+"||"+e.color;this.model.hatchMap.has(a)?this.model.hatchMap.get(a).push({geometry:s,info:e}):this.model.hatchMap.set(a,[{geometry:s,info:e}])}create_text(e){if(!this.font||!e.text)return;const t=new Tk(e.text,{font:this.font,size:e.height??100,depth:0});e.position[1]=e.position[1]-e.height;const i=this.getMatrix(e.position,[1,1,1],e.rotation);t.applyMatrix4(i);const n=e.layer+"||"+e.color;this.model.textMap.has(n)?this.model.textMap.get(n).push({geometry:t,info:e}):this.model.textMap.set(n,[{geometry:t,info:e}]),t.computeBoundingBox();const s=t.boundingBox;if(s){const a=s.max.x-s.min.x,o=s.max.y-s.min.y,l=new Wn(a,o);new Rt({visible:!1,side:Ht,depthWrite:!1});let c=[(s.min.x+s.max.x)/2,(s.min.y+s.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 i=new A(e.startPoint[0],e.startPoint[1],e.startPoint[2]||0),n=new A(e.endPoint[0],e.endPoint[1],e.endPoint[2]||0);let s=[i,n];return s.forEach(a=>{a[0]=a[0]-t[0],a[1]=a[1]-t[1]}),s}getPoint_arc(e,t){const i=e.center[0],n=e.center[1],s=e.radius,a=new dc(i,n,s,s,e.startAngle,e.endAngle,!1,0).getPoints(30).map(l=>new A(l.x,l.y,0));let o=[];for(let l=0;l<a.length-1;l++)o.push(a[l].clone()),o.push(a[l+1].clone());return o.forEach(l=>{l[0]=l[0]-t[0],l[1]=l[1]-t[1]}),o}getMatrix(e,t,i){const n=new A(e[0],e[1],e[2]),s=new Pi(0,0,i),a=new A(t[0],t[1],t[2]),o=new Ct;o.setFromEuler(s);const l=new Ke;return l.compose(n,o,a),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 Dk{engine;sectionPlaneGroup=null;loaderModule2d;constructor(e){this.engine=e,this.loaderModule2d=new NM(this.engine)}async attachSectionPlane(e,t,i,n){await this.loaderModule2d.loadModel(e+"/"+t,{chunkSize:1e3,enableChunkedLoading:!0,enableValidation:!0});let s=new A(i.x,i.y,i.z),a=new A(n.x,n.y,n.z);const o=new A().copy(a);let l=s.clone().sub(this.engine.modelGroup.position.clone()).dot(a);this.engine.modelGroup.lookAt(o);let c=this.engine.modelGroup.position.clone().add(a.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 i=new A(e.x,e.y,e.z),n=new Pi(t.x,t.y,t.z),s=new A(1,1,1),a=new Ct;a.setFromEuler(n);const o=new Ke;return o.compose(i,a,s),o}computeMatrixFromOriginAndDirection(e,t){const i=new Ke,n=t.clone().normalize();if(n.length()===0)return console.warn("方向向量长度为零,返回单位矩阵"),i.identity();const s=new A(0,1,0);let a=new A().crossVectors(s,n);if(a.length()<1e-4){const c=new A(0,0,1);a=new A().crossVectors(c,n).normalize()}else a.normalize();const o=new A().crossVectors(a,n).normalize(),l=new Ke;return l.set(a.x,n.x,o.x,0,a.y,n.y,o.y,0,a.z,n.z,o.z,0,0,0,0,1),l.setPosition(e),l}}class Nk{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=dP,this.options=e,this.container=document.getElementById(e.containerId),!this.container)throw new Error(`Container ${e.containerId} not found`);if(this.engineModelModule=new rU(this),this.engineModelModule.init(),this.ai=new ok(this),this.deviceModule=new pP(this),this.deviceType=this.deviceModule.getDeviceType(),this.cameraModule=new Ir(this),this.sceneModule=new uP(this),this.scene=this.sceneModule.scene,this.renderModule=new wD(this),this.renderer=this.renderModule.createRenderer(),this.camera=this.cameraModule.orthographicCamera,this.scene.camera=this.camera,this.renderer){const s=this.renderer;s.interactionCullingEnabled=!0,s.interactionActive=!1,s.interactionRenderScene=this.scene,s.interactionFrameBudgetMs=this.options.interactionFrameBudgetMs??6,s.interactionSkipShadows=this.options.interactionSkipShadows??!0}this.controlModule=new WD(this),this.controlModule.switchDefaultMode(),this.controls=this.controlModule.orbitControls,this.clipping=new ek(this),this.clipping.init(),this.composerModule=new n6(this),this.composerModule.init(),this.events=new J8,this.engineStatus=new $8(this),this.engineStatus.init(),this.loaderModule=new K8(this),this.lightModule=new Q8(this),this.lightModule.init(),this.viewCube=new BU(this),this.viewCube.init(),this.options.showViewCube==!1&&this.viewCube.hide(),this.octreeBox=FU(this),this.rangeScale=new zU(this),this.rangeScale.init(),this.setting=new HU(this),this.engineModelModule.init(),this.handelBehaved=P0(this),this.modelMapperBatch=new sk(this),this.measure=new KU(this),this.modelToolModule=new tU(this),this.modelProperties=new nk(this),this.interactionModule=new eU(this),this.interactionModule.init(),this.interactionModule.active(),this.hoverHighLight=new $p(this),this.modelEdge=new rk(this),this.modelTree=new tk(this),this.viewTree=new Ek(this),this.merge2d=new Dk(this),this.engineInfo=new ik(this),this.pathRoaming=new lk(this),this.pathRoaming.init(),this.oneClickEncoding=new wk(this),this.minMap=new ck(this),this.linkElement2d3d=new Mk(this),this.linkView2d3d=new Sk(this),this.grid=new uk(this),this.level=new mk(this),this.issueReport=new gk(this),this.text=new vk(this),this.hdr=new yk(this),this.ground=new iv(this),this.ground.init(),this.skyManager=new bk(this),this.setting.init(),this.worldToScreen=new Ft(this.camera,this.renderer,this.scene),this.options.showStats&&(this.stats=new cU,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 i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.style.position="absolute",i.style.zIndex="1000",i.style.left="0px",i.style.top="0px",i.style.pointerEvents="none",this.container.appendChild(i),this.catchSvg=i,this.onWindowResize=()=>{this.handleWindowResize()},window.addEventListener("resize",this.onWindowResize);let n=this;this.controls.addEventListener("start",()=>{n.renderer&&(n.renderer.interactionActive=!0),n.events.trigger(Ml.EngineBusy),n.container&&(n.container.style.cursor="none")}),this.controls.addEventListener("end",()=>{n.renderer&&(n.renderer.interactionActive=!1),n.events.trigger(Ml.EngineFree),n.container&&(n.container.style.cursor="default")}),this.controls.addEventListener("change",()=>{const s=new A;n.camera.getWorldDirection(s);const a=Math.atan2(s.x,-s.z);let o=new CustomEvent("D3ViewUpdate",{detail:{position:n.camera.position,rotation:a,type:n.camera.type}});window.dispatchEvent(o)}),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 s=performance.now();if(s-this._fpsLastCheck>=this._fpsCheckInterval){const a=s-this._fpsLastCheck,o=this._fpsFrameCount/a*1e3;this._fpsFrameCount=0,this._fpsLastCheck=s,o<this._fpsThreshold?(this._lowFpsCount++,this._highFpsCount=0,this._lowFpsCount>=this._lowFpsRequired&&s-this._fpsLastSwitch>this._fpsSwitchCooldown&&(this._adaptiveRenderingDowngrade(),this._fpsLastSwitch=s,this._lowFpsCount=0)):o>this._fpsUpgradeThreshold?(this._highFpsCount++,this._lowFpsCount=0):(this._lowFpsCount=0,this._highFpsCount=0)}if(this.scene){let a=this.scene?.dirLight;a&&this.camera&&this.updateLightPosition(this.camera,a)}},this.animate()}updateVersionDisplay(){if(!this.versionEl)return;const e={simple:"simple",balance:"balance",advanced:"advanced"},t=this.engineModelModule?.getCurrentMode()??"",i=e[t]??t;this.versionEl.innerHTML=`v${this.version} | ${i}`}updateLightPosition(e,t){const i=new A;e.getWorldDirection(i);const n=100,s=new A().copy(i).multiplyScalar(-n),a=new A(0,1,0),o=new A().crossVectors(i,a).normalize();s.addScaledVector(a,n*.5),s.addScaledVector(o,n*.3),t.position.copy(e.position).add(s);const l=new A().copy(e.position).add(i.multiplyScalar(20));t.target.position.copy(l),t.target.updateMatrixWorld()}_adaptiveRenderingDowngrade(){const e=["simple","balance","advanced"],t=this.engineModelModule.getCurrentMode(),i=e.indexOf(t);if(i>0){const n=e[i-1];console.log(`[AdaptiveRendering] FPS低于${this._fpsThreshold},自动降级: ${t} → ${n}`),this.engineModelModule.autoSwitch(n)}}_adaptiveRenderingUpgrade(){const e=["simple","balance","advanced"],t=this.engineModelModule.getCurrentMode(),i=e.indexOf(t);if(i<e.length-1){const n=e[i+1];console.log(`[AdaptiveRendering] FPS高于${this._fpsUpgradeThreshold},自动升级: ${t} → ${n}`),this.engineModelModule.autoSwitch(n)}}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 n=this.deviceModule.getContainerSize();e=e??n.width,t=t??n.height}if(!e||!t)return;this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(e,t);const i=e/t;if(this.camera===this.cameraModule.perspectiveCamera)this.cameraModule.perspectiveCamera.aspect=i,this.cameraModule.perspectiveCamera.updateProjectionMatrix(),this.camera=this.cameraModule.perspectiveCamera;else if(this.camera===this.cameraModule.orthographicCamera){const n=this.cameraModule.orthographicCamera,s=this.cameraModule.getOrthographicVisibleHeight(n);this.cameraModule.setOrthographicVisibleHeight(s,n),n.updateProjectionMatrix()}if(this.catchSvg){const n=this.container.clientWidth,s=this.container.clientHeight;this.catchSvg.setAttribute("viewBox",`0 0 ${n} ${s}`)}this.events&&this.events.trigger(Ml.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){e&&([...e.children].forEach(t=>{this.clearScene(t)}),e.parent&&e.parent.remove(e),e instanceof Ve&&(e.geometry&&e.geometry.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach(t=>this.disposeMaterial(t)):this.disposeMaterial(e.material))),e instanceof oi&&(e.geometry&&e.geometry.dispose(),e.material&&this.disposeMaterial(e.material)),e instanceof ou&&(e.geometry&&e.geometry.dispose(),e.material&&this.disposeMaterial(e.material)),e instanceof ti&&(e.geometry&&e.geometry.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach(t=>this.disposeMaterial(t)):this.disposeMaterial(e.material)),e.instanceMatrix&&(e.instanceMatrix=null),e.instanceColor&&(e.instanceColor=null)),e instanceof nc&&e.material&&this.disposeMaterial(e.material))}disposeMaterial(e){e&&(["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(t=>{const i=e[t];i&&i instanceof ei&&i.dispose()}),e.dispose())}}const Uk=`
|
|
9425
9425
|
varying vec2 vWorldPos;
|
|
9426
9426
|
|
|
9427
9427
|
void main() {
|
|
@@ -9882,7 +9882,7 @@ ${JSON.stringify(l,null,2)}
|
|
|
9882
9882
|
<span class="bim-ai-qa-answer">${this.escapeHtml(i||"")}</span>
|
|
9883
9883
|
</div>
|
|
9884
9884
|
</div>
|
|
9885
|
-
`}bindQuestionEvents(){this.messagesContainer?.querySelectorAll(".bim-ai-option").forEach(e=>{e.addEventListener("click",t=>{const i=t.currentTarget,n=i.dataset.questionId,s=i.dataset.optionId;if(n&&s){const a=this.messages.find(o=>o.id===n);a&&!a.answered&&(a.selectedOptionId=s,this.renderMessages())}})}),this.messagesContainer?.querySelectorAll(".bim-ai-option-input").forEach(e=>{e.addEventListener("input",t=>{const i=t.target,n=i.dataset.questionId;if(n){const s=this.messages.find(a=>a.id===n);s&&(s.customAnswer=i.value)}})}),this.messagesContainer?.querySelectorAll(".bim-ai-question-submit").forEach(e=>{e.addEventListener("click",t=>{const n=t.currentTarget.dataset.questionId;if(n){const s=this.messages.find(a=>a.id===n);s&&s.selectedOptionId&&(s.answered=!0,this.renderMessages(),this.options.onQuestionSubmit?.(n,s.selectedOptionId,s.customAnswer))}})})}scrollToBottom(){this.messagesContainer&&(this.messagesContainer.scrollTop=this.messagesContainer.scrollHeight)}escapeHtml(e){const t=document.createElement("div");return t.textContent=e,t.innerHTML}destroy(){this._isDestroyed||(this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.unsubscribeLocale&&(this.unsubscribeLocale(),this.unsubscribeLocale=null),this.element.remove(),this._isDestroyed=!0)}}class aS{aiChat=null;registry;initialized=!1;constructor(e){this.registry=e}init(){if(this.initialized)return;const e=this.registry.wrapper;if(!e){console.warn("[AiChatManager] wrapper 不存在,无法初始化");return}this.aiChat=new X7({container:e,width:440,title:"aiChat.title",placeholder:"aiChat.placeholder",quickPrompts:[{id:"summarize",label:"aiChat.quickPrompt.summarize"},{id:"explain",label:"aiChat.quickPrompt.explain"},{id:"generate",label:"aiChat.quickPrompt.generate"}],onSend:t=>{console.log("[AiChatManager] 用户发送消息:",t),this.aiChat?.addUserMessage(t),this.registry.emit("aiChat:message-sent",{message:t})},onQuestionSubmit:(t,i,n)=>{console.log("[AiChatManager] 用户回答问题:",{questionId:t,optionId:i,customAnswer:n}),this.registry.emit("aiChat:question-answered",{questionId:t,optionId:i,customAnswer:n})},onNewChat:()=>{console.log("[AiChatManager] 新建对话"),this.registry.emit("aiChat:new-chat",{})},onHistory:()=>{console.log("[AiChatManager] 打开历史"),this.registry.emit("aiChat:history-opened",{})},onSettings:()=>{console.log("[AiChatManager] 打开设置"),this.registry.emit("aiChat:settings-opened",{})},onClose:()=>{console.log("[AiChatManager] 关闭 AI 聊天"),this.registry.emit("aiChat:closed",{}),this.registry.toolbar?.setBtnActive("aiChat",!1)}}),this.initialized=!0}show(){this.aiChat||this.init(),this.aiChat?.show(),this.registry.emit("aiChat:opened",{}),this.registry.toolbar?.setBtnActive("aiChat",!0)}hide(){this.aiChat?.hide(),this.registry.emit("aiChat:closed",{}),this.registry.toolbar?.setBtnActive("aiChat",!1)}toggle(){this.aiChat?.isVisible()?this.hide():this.show()}isVisible(){return this.aiChat?.isVisible()??!1}addUserMessage(e){return this.aiChat?.addUserMessage(e)??""}addAiMessage(e){return this.aiChat?.addAiMessage(e)??""}addStepMessage(e,t){return this.aiChat?.addStepMessage(e,t)??""}addThinkingMessage(){return this.aiChat?.addThinkingMessage()??""}addQuestionMessage(e,t,i){return this.aiChat?.addQuestionMessage(e,t,i)??""}updateMessage(e,t){this.aiChat?.updateMessage(e,t)}removeMessage(e){this.aiChat?.removeMessage(e)}clearMessages(){this.aiChat?.clearMessages()}destroy(){this.aiChat&&(this.aiChat.destroy(),this.aiChat=null),this.initialized=!1}}class j7{container;options;groups=[];activeBtnIds=new Set;btnRefs=new Map;dropdownElement=null;hoverTimeout=null;customColors=new Set;unsubscribeLocale=null;unsubscribeTheme=null;DEFAULT_ICON='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect></svg>';constructor(e){const t=typeof e.container=="string"?document.getElementById(e.container):e.container;if(!t)throw new Error("Container not found");this.container=t,this.options={showLabel:!0,visibility:{},direction:"row",position:"static",align:"vertical",expand:"down",...e},["backgroundColor","btnBackgroundColor","btnHoverColor","btnActiveColor","iconColor","iconActiveColor","textColor","textActiveColor"].forEach(n=>{e[n]&&this.customColors.add(n)}),this.initContainer(),this.applyStyles()}emit(e,t){this.options.registry?.emit(e,t)}initContainer(){this.container.innerHTML="",this.container.classList.add("bim-btn-group-root"),this.options.direction==="column"?this.container.classList.add("dir-column"):this.container.classList.add("dir-row"),this.options.className&&this.container.classList.add(this.options.className),this.options.type&&this.options.type!=="default"&&this.container.classList.add(`type-${this.options.type}`),this.updatePosition(),this.setupEventInterception(this.container)}setupEventInterception(e){const t=n=>{n.stopPropagation()};["click","dblclick","contextmenu","wheel","mousedown","mouseup","mousemove","touchstart","touchend","touchmove","pointerdown","pointerup","pointermove","pointerenter","pointerleave","pointerover","pointerout"].forEach(n=>{e.addEventListener(n,t,{passive:!1})})}updatePosition(){const e=this.options.position,t=this.container.style;if(t.top="",t.bottom="",t.left="",t.right="",t.transform="",e==="static"){this.container.classList.add("static");return}if(this.container.classList.remove("static"),this.container.style.position="absolute",typeof e=="object"&&"x"in e)t.left=`${e.x}px`,t.top=`${e.y}px`;else{const i="20px";switch(e){case"top-left":t.top=i,t.left=i;break;case"top-center":t.top=i,t.left="50%",t.transform="translateX(-50%)";break;case"top-right":t.top=i,t.right=i;break;case"bottom-left":t.bottom=i,t.left=i;break;case"bottom-center":t.bottom=i,t.left="50%",t.transform="translateX(-50%)";break;case"bottom-right":t.bottom=i,t.right=i;break;case"left-center":t.left=i,t.top="50%",t.transform="translateY(-50%)";break;case"right-center":t.right=i,t.top="50%",t.transform="translateY(-50%)";break;case"center":t.top="50%",t.left="50%",t.transform="translate(-50%, -50%)";break}}}applyStyles(){const e=this.container.style;this.options.backgroundColor&&e.setProperty("--bim-btn-group-section-bg",this.options.backgroundColor),this.options.btnBackgroundColor&&e.setProperty("--bim-btn-bg",this.options.btnBackgroundColor),this.options.btnHoverColor&&e.setProperty("--bim-btn-hover-bg",this.options.btnHoverColor),this.options.btnActiveColor&&e.setProperty("--bim-btn-active-bg",this.options.btnActiveColor),this.options.iconColor&&e.setProperty("--bim-icon-color",this.options.iconColor),this.options.iconActiveColor&&e.setProperty("--bim-icon-active-color",this.options.iconActiveColor),this.options.textColor&&e.setProperty("--bim-btn-text-color",this.options.textColor),this.options.textActiveColor&&e.setProperty("--bim-btn-text-active-color",this.options.textActiveColor),document.querySelectorAll(".opt-btn-dropdown").forEach(i=>{const n=i.style;this.options.iconColor&&n.setProperty("--bim-icon-color",this.options.iconColor),this.options.iconActiveColor&&n.setProperty("--bim-icon-active-color",this.options.iconActiveColor),this.options.textColor&&n.setProperty("--bim-btn-text-color",this.options.textColor),this.options.textActiveColor&&n.setProperty("--bim-btn-text-active-color",this.options.textActiveColor),this.options.btnBackgroundColor&&n.setProperty("--bim-btn-bg",this.options.btnBackgroundColor),this.options.btnHoverColor&&n.setProperty("--bim-btn-hover-bg",this.options.btnHoverColor),this.options.btnActiveColor&&n.setProperty("--bim-btn-active-bg",this.options.btnActiveColor)})}setPrimaryColor(e){this.container.style.setProperty("--bim-primary-color",e),document.querySelectorAll(".opt-btn-dropdown").forEach(i=>{i.style.setProperty("--bim-primary-color",e)})}setTheme(e){const t={backgroundColor:e.bgElevated,btnBackgroundColor:e.componentBg,btnHoverColor:e.componentBgHover,btnActiveColor:e.componentBgActive,iconColor:e.iconDefault,iconActiveColor:e.iconActive,textColor:e.textSecondary,textActiveColor:e.textPrimary};Object.entries(t).forEach(([i,n])=>{const s=i;this.customColors.has(s)||(this.options[s]=n)}),this.container.classList.remove("theme-dark","theme-light"),this.container.classList.add(`theme-${e.name}`),this.applyStyles(),this.setPrimaryColor(e.primary),this.applyThemeCssVars(e)}applyThemeCssVars(e){const t=this.container.style;t.setProperty("--bim-primary",e.primary),t.setProperty("--bim-primary-hover",e.primaryHover),t.setProperty("--bim-primary-active",e.primaryActive),t.setProperty("--bim-bg-glass",e.bgGlass),t.setProperty("--bim-bg-glass-blur",e.bgGlassBlur),t.setProperty("--bim-bg-elevated",e.bgElevated),t.setProperty("--bim-bg-overlay",e.bgOverlay),t.setProperty("--bim-bg-inset",e.bgInset),t.setProperty("--bim-text-primary",e.textPrimary),t.setProperty("--bim-text-secondary",e.textSecondary),t.setProperty("--bim-text-tertiary",e.textTertiary),t.setProperty("--bim-text-inverse",e.textInverse),t.setProperty("--bim-icon-default",e.iconDefault),t.setProperty("--bim-icon-hover",e.iconHover),t.setProperty("--bim-icon-active",e.iconActive),t.setProperty("--bim-icon-inverse",e.iconInverse),t.setProperty("--bim-border-default",e.borderDefault),t.setProperty("--bim-border-subtle",e.borderSubtle),t.setProperty("--bim-component-bg-hover",e.componentBgHover),t.setProperty("--bim-component-bg-active",e.componentBgActive),t.setProperty("--bim-shadow-sm",e.shadowSm),t.setProperty("--bim-shadow-md",e.shadowMd),t.setProperty("--bim-shadow-lg",e.shadowLg),t.setProperty("--bim-shadow-glow",e.shadowGlow),t.setProperty("--bim-floating-bg",e.floatingBg),t.setProperty("--bim-floating-border",e.floatingBorder),t.setProperty("--bim-floating-shadow",e.floatingShadow),t.setProperty("--bim-floating-btn-bg",e.floatingBtnBg),t.setProperty("--bim-floating-btn-border",e.floatingBtnBorder),t.setProperty("--bim-floating-btn-shadow",e.floatingBtnShadow),t.setProperty("--bim-floating-btn-bg-hover",e.floatingBtnBgHover),t.setProperty("--bim-floating-btn-shadow-hover",e.floatingBtnShadowHover),t.setProperty("--bim-floating-icon-color",e.floatingIconColor),t.setProperty("--bim-floating-icon-color-hover",e.floatingIconColorHover),this.syncDropdownCssVars(e)}syncDropdownCssVars(e){document.querySelectorAll(".opt-btn-dropdown").forEach(i=>{const n=i.style;n.setProperty("--bim-primary",e.primary),n.setProperty("--bim-bg-overlay",e.bgOverlay),n.setProperty("--bim-border-default",e.borderDefault),n.setProperty("--bim-text-primary",e.textPrimary),n.setProperty("--bim-text-inverse",e.textInverse),n.setProperty("--bim-shadow-lg",e.shadowLg),n.setProperty("--bim-floating-btn-bg",e.floatingBtnBg),n.setProperty("--bim-floating-btn-bg-hover",e.floatingBtnBgHover),n.setProperty("--bim-floating-icon-color",e.floatingIconColor)})}setColors(e){this.options={...this.options,...e},Object.keys(e).forEach(t=>{this.customColors.add(t)}),this.applyStyles()}async init(){this.render(),this.unsubscribeLocale=Zt.subscribe(()=>{this.setLocales()}),this.unsubscribeTheme=ht.subscribe(e=>{this.setTheme(e)})}setLocales(){this.render()}addGroup(e,t){if(this.groups.some(n=>n.id===e))return;const i={id:e,buttons:[]};if(t){const n=this.groups.findIndex(s=>s.id===t);n!==-1?this.groups.splice(n,0,i):this.groups.push(i)}else this.groups.push(i)}addButton(e){const{groupId:t,parentId:i}=e,n=this.groups.find(a=>a.id===t);if(!n)return;const s={...e,children:e.children||[]};if(i){const a=this.findButton(n.buttons,i);a&&(a.children||(a.children=[]),a.children.push(s))}else n.buttons.push(s)}findButton(e,t){for(const i of e){if(i.id===t)return i;if(i.children){const n=this.findButton(i.children,t);if(n)return n}}}render(){this.container.innerHTML="",this.btnRefs.clear(),this.groups.forEach((e,t)=>{const i=this.renderGroup(e,t,this.groups.length);this.container.appendChild(i)})}renderGroup(e,t,i){const n=document.createElement("div");return n.className="bim-btn-group-section",t<i-1&&n.classList.add("has-divider"),e.buttons.forEach(s=>{if(this.isVisible(s.id)){const a=this.renderButton(s);n.appendChild(a)}}),n}renderButton(e){const t=document.createElement("div");t.className="opt-btn-wrapper";const i=document.createElement("div");i.className="opt-btn",e.isActive&&this.activeBtnIds.add(e.id),(e.align||this.options.align||"vertical")==="horizontal"?i.classList.add("align-horizontal"):i.classList.add("align-vertical"),this.activeBtnIds.has(e.id)&&i.classList.add("active"),e.disabled&&i.classList.add("disabled"),this.options.showLabel&&e.label||(i.classList.add("no-label"),e.label&&(i.title=Se(e.label)));const a=e.iconSize||32,o=e.minWidth||50;i.style.minWidth=`${o}px`;const l=document.createElement("div");l.className="opt-btn-icon",l.style.width=`${a}px`,l.style.height=`${a}px`,l.innerHTML=this.getIcon(e.icon),i.appendChild(l);const c=document.createElement("div");if(c.className="opt-btn-text-wrapper",this.options.showLabel&&e.label){const h=document.createElement("span");h.className="opt-btn-label",h.textContent=Se(e.label),c.appendChild(h)}return c.hasChildNodes()&&i.appendChild(c),i.addEventListener("click",()=>this.handleClick(e)),i.addEventListener("mouseenter",()=>this.handleMouseEnter(e,i)),i.addEventListener("mouseleave",()=>this.handleMouseLeave()),this.btnRefs.set(e.id,i),t.appendChild(i),t}setBtnActive(e,t){const i=this.findButtonById(e);if(!i)return;const n=t!==void 0?t:!this.activeBtnIds.has(e);n?this.activeBtnIds.add(e):this.activeBtnIds.delete(e),i.isActive=n,this.updateButtonState(e)}handleClick(e){if(!e.disabled&&(!e.children||e.children.length===0)){if(e.keepActive){const i=!this.activeBtnIds.has(e.id);this.setBtnActive(e.id,i),i&&e.exclusive&&e.groupId&&this.deactivateExclusiveSiblings(e)}this.closeDropdown(),e.onClick&&e.onClick(e)}}deactivateExclusiveSiblings(e){const t=this.groups.find(i=>i.id===e.groupId);if(t){if(e.parentId){const n=this.findButton(t.buttons,e.parentId)?.children||[];for(const s of n)s&&s.id!==e.id&&s.parentId===e.parentId&&s.groupId===e.groupId&&this.activeBtnIds.has(s.id)&&(this.setBtnActive(s.id,!1),s.onClick&&s.onClick(s));return}for(const i of t.buttons)i.id!==e.id&&i.groupId===e.groupId&&(i.parentId||this.activeBtnIds.has(i.id)&&(this.setBtnActive(i.id,!1),i.onClick&&i.onClick(i)))}}handleMouseEnter(e,t){this.hoverTimeout&&clearTimeout(this.hoverTimeout),e.children&&e.children.length>0?this.showDropdown(e,t):this.closeDropdown()}handleMouseLeave(){this.hoverTimeout=window.setTimeout(()=>this.closeDropdown(),200)}showDropdown(e,t){if(this.closeDropdown(),!e.children)return;const i=document.createElement("div");i.className="opt-btn-dropdown",this.options.backgroundColor&&i.style.setProperty("--bim-toolbar-bg",this.options.backgroundColor);const n=i.style;this.options.iconColor&&n.setProperty("--bim-icon-color",this.options.iconColor),this.options.iconActiveColor&&n.setProperty("--bim-icon-active-color",this.options.iconActiveColor),this.options.textColor&&n.setProperty("--bim-btn-text-color",this.options.textColor),this.options.textActiveColor&&n.setProperty("--bim-btn-text-active-color",this.options.textActiveColor),this.options.btnBackgroundColor&&n.setProperty("--bim-btn-bg",this.options.btnBackgroundColor),this.options.btnHoverColor&&n.setProperty("--bim-btn-hover-bg",this.options.btnHoverColor),this.options.btnActiveColor&&n.setProperty("--bim-btn-active-bg",this.options.btnActiveColor);const s=t.getBoundingClientRect(),a=this.options.expand||"down";this.options.direction==="row"?i.style.flexDirection="column":i.style.flexDirection="row",this.options.type&&this.options.type!=="default"&&i.classList.add(`type-${this.options.type}`);const o=ht.getTheme();i.classList.add(`theme-${o.name}`),n.setProperty("--bim-primary",o.primary),n.setProperty("--bim-bg-overlay",o.bgOverlay),n.setProperty("--bim-border-default",o.borderDefault),n.setProperty("--bim-text-primary",o.textPrimary),n.setProperty("--bim-text-inverse",o.textInverse),n.setProperty("--bim-shadow-lg",o.shadowLg),n.setProperty("--bim-floating-btn-bg",o.floatingBtnBg),n.setProperty("--bim-floating-btn-bg-hover",o.floatingBtnBgHover),n.setProperty("--bim-floating-icon-color",o.floatingIconColor),document.body.appendChild(i),this.setupEventInterception(i),e.children.forEach(c=>{if(this.isVisible(c.id)){const h=this.renderDropdownItem(c);i.appendChild(h)}});const l=i.getBoundingClientRect();a==="up"?(i.style.bottom=window.innerHeight-s.top+8+"px",i.style.left=s.left+(s.width-l.width)/2+"px"):a==="down"?(i.style.top=s.bottom+8+"px",i.style.left=s.left+(s.width-l.width)/2+"px"):a==="right"?(i.style.top=s.top+(s.height-l.height)/2+"px",i.style.left=s.right+8+"px"):a==="left"&&(i.style.top=s.top+(s.height-l.height)/2+"px",i.style.right=window.innerWidth-s.left+8+"px"),i.addEventListener("mouseenter",()=>{this.hoverTimeout&&clearTimeout(this.hoverTimeout)}),i.addEventListener("mouseleave",()=>this.handleMouseLeave()),this.dropdownElement=i}renderDropdownItem(e){const t=document.createElement("div");t.className="opt-btn-dropdown-item",(e.align||"horizontal")==="horizontal"?t.classList.add("align-horizontal"):t.classList.add("align-vertical"),(this.activeBtnIds.has(e.id)||e.isActive)&&t.classList.add("active");const n=e.iconSize||32,s=e.minWidth;s&&(t.style.minWidth=`${s}px`);const a=document.createElement("div");if(a.className="opt-btn-icon",a.style.width=`${n}px`,a.style.height=`${n}px`,a.innerHTML=this.getIcon(e.icon),t.appendChild(a),this.options.showLabel&&e.label){const o=document.createElement("span");o.className="opt-btn-dropdown-label",o.textContent=Se(e.label),t.appendChild(o)}else e.label&&(t.title=Se(e.label));return t.addEventListener("click",o=>{o.stopPropagation(),this.handleClick(e)}),t}closeDropdown(){this.dropdownElement&&(this.dropdownElement.remove(),this.dropdownElement=null),this.btnRefs.forEach(e=>{const t=e.querySelector(".opt-btn-arrow");t&&t.classList.remove("rotated")})}updateButtonState(e){const t=this.btnRefs.get(e);t&&(this.activeBtnIds.has(e)?t.classList.add("active"):t.classList.remove("active"))}getIcon(e){return e||this.DEFAULT_ICON}updateButtonIcon(e,t){const i=this.btnRefs.get(e);if(!i)return;const n=i.querySelector(".opt-btn-icon");n&&(n.innerHTML=this.getIcon(t));const s=this.findButtonById(e);s&&(s.icon=t)}updateButtonVisibility(e,t){this.options.visibility||(this.options.visibility={}),this.options.visibility[e]=t,this.render()}setShowLabel(e){this.options.showLabel=e,this.updateLabelsVisibility()}updateLabelsVisibility(){this.btnRefs.forEach((e,t)=>{const i=this.findButtonById(t);if(!i)return;this.options.showLabel&&i.label?(e.classList.remove("no-label"),e.removeAttribute("title")):(e.classList.add("no-label"),i.label&&(e.title=Se(i.label)))})}findButtonById(e){for(const t of this.groups){const i=this.findButton(t.buttons,e);if(i)return i}}setBackgroundColor(e){this.setColors({backgroundColor:e})}isVisible(e){return this.options.visibility?.[e]!==!1}setType(e){this.container.classList.remove("type-default","type-glass-pill"),this.options.type=e,e&&e!=="default"&&this.container.classList.add(`type-${e}`),this.render()}getType(){return this.options.type||"default"}destroy(){this.unsubscribeLocale&&(this.unsubscribeLocale(),this.unsubscribeLocale=null),this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.closeDropdown(),this.container.innerHTML="",this.btnRefs.clear()}}var si=(r=>(r[r.Unchecked=0]="Unchecked",r[r.Checked=1]="Checked",r[r.Indeterminate=2]="Indeterminate",r))(si||{});class q7{config;element;children=[];parent=null;checkState=si.Unchecked;contentEl;switcherEl;checkboxEl=null;titleEl;actionsEl;childrenContainer;onExpandChange;onCheckChange;onNodeClick;renderActions;constructor(e,t,i){this.config=e,this.onExpandChange=i.onExpand,this.onCheckChange=i.onCheck,this.onNodeClick=i.onClick,this.renderActions=t.renderActions,this.checkState=e.checked?si.Checked:si.Unchecked,this.element=this.createDom(t)}createDom(e){const t=document.createElement("div");t.className="bim-tree-node",this.config.disabled&&t.classList.add("is-disabled"),this.contentEl=document.createElement("div"),this.contentEl.className="bim-tree-node-content",this.switcherEl=document.createElement("span"),this.switcherEl.className="bim-tree-switcher",this.switcherEl.innerHTML='<svg viewBox="0 0 1024 1024"><path d="M288 192l448 320-448 320z"></path></svg>';const i=this.config.children&&this.config.children.length>0;if(i?this.config.expanded&&this.switcherEl.classList.add("is-expanded"):this.switcherEl.classList.add("is-hidden"),this.switcherEl.addEventListener("click",s=>{s.stopPropagation(),this.toggleExpand()}),this.contentEl.appendChild(this.switcherEl),e.checkable!==!1&&(this.checkboxEl=document.createElement("span"),this.checkboxEl.className="bim-tree-checkbox",this.updateCheckboxUI(),this.checkboxEl.addEventListener("click",s=>{s.stopPropagation(),!this.config.disabled&&this.toggleCheck()}),this.contentEl.appendChild(this.checkboxEl)),this.config.icon){const s=document.createElement("span");s.className="bim-tree-icon",s.innerHTML=this.config.icon.includes("<svg")?this.config.icon:`<img src="${this.config.icon}" />`,this.contentEl.appendChild(s)}this.titleEl=document.createElement("span"),this.titleEl.className="bim-tree-title",this.updateLabel(),this.contentEl.appendChild(this.titleEl),this.actionsEl=document.createElement("div"),this.actionsEl.className="bim-tree-node-actions",this.actionsEl.addEventListener("click",s=>{s.stopPropagation()}),this.contentEl.appendChild(this.actionsEl),this.contentEl.addEventListener("click",s=>{if(s.stopPropagation(),this.config.disabled)return;(this.config.clickAction||"select")==="expand"?this.toggleExpand():this.onNodeClick(this)}),t.appendChild(this.contentEl),this.childrenContainer=document.createElement("div"),this.childrenContainer.className="bim-tree-children";const n=e.indent||24;return this.childrenContainer.style.paddingLeft=`${n}px`,this.config.expanded&&i&&this.childrenContainer.classList.add("is-visible"),t.appendChild(this.childrenContainer),t}setSelected(e){if(e){if(this.contentEl.classList.add("is-selected"),this.renderActions){const t=this.renderActions(this.config);this.actionsEl.innerHTML="",typeof t=="string"?this.actionsEl.innerHTML=t:t instanceof HTMLElement&&this.actionsEl.appendChild(t)}}else this.contentEl.classList.remove("is-selected"),this.actionsEl.innerHTML=""}updateLabel(){this.titleEl&&(this.titleEl.textContent=this.config.label)}toggleExpand(e){if(!this.config.children||this.config.children.length===0)return;const t=e!==void 0?e:!this.config.expanded;this.config.expanded=t,t?(this.switcherEl.classList.add("is-expanded"),this.childrenContainer.classList.add("is-visible")):(this.switcherEl.classList.remove("is-expanded"),this.childrenContainer.classList.remove("is-visible")),e===void 0&&this.onExpandChange(this)}toggleCheck(){const e=this.checkState!==si.Checked;this.setChecked(e?si.Checked:si.Unchecked,!0)}setChecked(e,t=!1,i=!1){!i&&this.checkState===e||(this.checkState=e,this.config.checked=e===si.Checked,this.updateCheckboxUI(),t&&this.onCheckChange(this))}updateCheckboxUI(){this.checkboxEl&&(this.checkboxEl.classList.remove("is-checked","is-indeterminate"),this.checkState===si.Checked?this.checkboxEl.classList.add("is-checked"):this.checkState===si.Indeterminate&&this.checkboxEl.classList.add("is-indeterminate"))}appendChild(e){e.parent=this,this.children.push(e),this.childrenContainer.appendChild(e.element),this.children.length===1&&this.switcherEl.classList.remove("is-hidden")}destroy(){this.children.forEach(e=>e.destroy()),this.children=[],this.element.remove(),this.parent=null}}class Z7{element;contentElement;searchInput=null;searchResults=null;options;nodeMap=new Map;rootNodes=[];selectedNode=null;lastRevealedNodeId=null;unsubscribeLocale=null;unsubscribeTheme=null;clickOutsideHandler=null;onNodeCheck;onNodeSelect;onNodeDeselect;onNodeExpand;constructor(e){this.options={checkable:!0,checkStrictly:!0,indent:24,defaultExpandAll:!0,enableSearch:!1,searchPlaceholder:"tree.searchPlaceholder",...e},this.element=document.createElement("div"),this.element.className="bim-tree",this.options.enableSearch&&this.createSearchDOM(),this.contentElement=document.createElement("div"),this.contentElement.className="bim-tree-content",this.element.appendChild(this.contentElement),e.onNodeCheck&&(this.onNodeCheck=e.onNodeCheck),e.onNodeSelect&&(this.onNodeSelect=e.onNodeSelect),e.onNodeDeselect&&(this.onNodeDeselect=e.onNodeDeselect),e.onNodeExpand&&(this.onNodeExpand=e.onNodeExpand)}createSearchDOM(){const e=document.createElement("div");e.className="bim-tree-search";const t=document.createElement("div");t.className="bim-tree-search-wrapper";const i=document.createElement("span");i.className="bim-tree-search-icon",i.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="m21 21l-4.343-4.343m0 0A8 8 0 1 0 5.343 5.343a8 8 0 0 0 11.314 11.314"/></svg>',t.appendChild(i),this.searchInput=document.createElement("input"),this.searchInput.className="bim-tree-search-input",this.searchInput.type="text",this.searchInput.placeholder=Se(this.options.searchPlaceholder||"搜索..."),this.searchInput.addEventListener("input",n=>{const s=n.target.value;this.handleSearch(s)}),t.appendChild(this.searchInput),e.appendChild(t),this.searchResults=document.createElement("div"),this.searchResults.className="bim-tree-search-results",e.appendChild(this.searchResults),this.element.appendChild(e),this.clickOutsideHandler=n=>{this.searchResults&&!this.searchResults.contains(n.target)&&!this.searchInput?.contains(n.target)&&this.searchResults.classList.remove("is-visible")},document.addEventListener("click",this.clickOutsideHandler)}init(){this.render(),this.unsubscribeLocale=Zt.subscribe(()=>this.setLocales()),this.unsubscribeTheme=ht.subscribe(e=>this.setTheme(e)),this.setTheme(ht.getTheme())}handleSearch(e){if(!this.searchResults)return;if(!e.trim()){this.searchResults.classList.remove("is-visible"),this.searchResults.innerHTML="";return}const t=[],i=e.toLowerCase();this.nodeMap.forEach(n=>{const s=n.config.label;s.toLowerCase().includes(i)&&t.push({node:n,label:s,path:this.getNodePath(n)})}),this.renderSearchResults(t)}getNodePath(e){const t=[];let i=e.parent;for(;i;)t.unshift(i.config.label),i=i.parent;return t.join(" > ")}renderSearchResults(e){if(this.searchResults){if(this.searchResults.innerHTML="",e.length===0){const t=document.createElement("div");t.className="bim-tree-search-item",t.style.cursor="default",t.style.color="#999",t.textContent="No results",this.searchResults.appendChild(t)}else e.forEach(t=>{const i=document.createElement("div");i.className="bim-tree-search-item";const n=document.createElement("span");n.className="bim-tree-search-item-title",n.textContent=t.label;const s=document.createElement("span");s.className="bim-tree-search-item-path",s.textContent=t.path,i.appendChild(n),t.path&&i.appendChild(s),i.addEventListener("click",()=>{this.revealNode(t.node)}),this.searchResults.appendChild(i)});this.searchResults.classList.add("is-visible")}}revealNode(e){if(this.lastRevealedNodeId===e.config.id&&this.isNodeFullyVisible(e))return;this.lastRevealedNodeId=e.config.id,this.searchResults&&(this.searchResults.classList.remove("is-visible"),this.searchInput&&(this.searchInput.value=""));let t=e.parent;for(;t;)t.toggleExpand(!0),t=t.parent;this.handleNodeSelect(e),requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.scrollNodeIntoContentCenter(e)})})}isNodeFullyVisible(e){const t=this.contentElement;if(!t||!e?.element?.isConnected)return!1;const i=t.getBoundingClientRect(),n=e.element.getBoundingClientRect();return n.top>=i.top&&n.bottom<=i.bottom}scrollNodeIntoContentCenter(e){const t=this.contentElement;if(!t||!e?.element?.isConnected)return;const i=t.getBoundingClientRect(),n=e.element.getBoundingClientRect();if(n.top>=i.top&&n.bottom<=i.bottom)return;const s=n.top-i.top+t.scrollTop,a=Math.max(0,s-(t.clientHeight-n.height)/2);t.scrollTo({top:a,behavior:"auto"})}setTheme(e){const t=this.element.style;t.setProperty("--bim-primary",e.primary),t.setProperty("--bim-bg-elevated",e.bgElevated),t.setProperty("--bim-text-primary",e.textPrimary),t.setProperty("--bim-text-secondary",e.textSecondary),t.setProperty("--bim-text-tertiary",e.textTertiary),t.setProperty("--bim-text-disabled",e.textDisabled),t.setProperty("--bim-text-inverse",e.textInverse),t.setProperty("--bim-border-default",e.borderDefault),t.setProperty("--bim-border-disabled",e.borderDisabled),t.setProperty("--bim-component-bg-hover",e.componentBgHover),t.setProperty("--bim-component-bg-selected",e.componentBgSelected),t.setProperty("--bim-component-bg-disabled",e.componentBgDisabled),t.setProperty("--bim-shadow-md",e.shadowMd),t.setProperty("--bim-focus-ring",e.focusRing)}setLocales(){this.nodeMap.forEach(e=>e.updateLabel()),this.searchInput&&(this.searchInput.placeholder=Se(this.options.searchPlaceholder||"tree.searchPlaceholder"))}destroy(){this.unsubscribeLocale&&(this.unsubscribeLocale(),this.unsubscribeLocale=null),this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.clickOutsideHandler&&(document.removeEventListener("click",this.clickOutsideHandler),this.clickOutsideHandler=null),this.rootNodes.forEach(e=>e.destroy()),this.rootNodes=[],this.nodeMap.clear(),this.lastRevealedNodeId=null,this.element.remove(),this.selectedNode=null}render(){this.contentElement.innerHTML="",this.nodeMap.clear(),this.rootNodes=[],this.options.data.forEach(e=>{this.createNodeRecursively(e,null)})}createNodeRecursively(e,t){e.expanded===void 0&&(e.expanded=this.options.defaultExpandAll);const i=new q7(e,this.options,{onExpand:n=>{this.onNodeExpand&&this.onNodeExpand(n)},onCheck:n=>this.handleNodeCheck(n),onClick:n=>this.handleNodeSelect(n)});this.nodeMap.set(e.id,i),t?t.appendChild(i):(this.rootNodes.push(i),this.contentElement.appendChild(i.element)),e.children&&e.children.length>0&&e.children.forEach(n=>{this.createNodeRecursively(n,i)})}handleNodeSelect(e){if(this.selectedNode===e){e.setSelected(!1),this.selectedNode=null,this.onNodeDeselect&&this.onNodeDeselect(e);return}this.selectedNode&&this.selectedNode.setSelected(!1),e.setSelected(!0),this.selectedNode=e,this.onNodeSelect&&this.onNodeSelect(e)}handleNodeCheck(e){const t=e.checkState===si.Checked;if(this.onNodeCheck&&this.onNodeCheck(e),this.options.checkStrictly===!1)return;const i=(s,a)=>{s.children.forEach(o=>{o.config.disabled||(o.setChecked(a,!1),i(o,a))})};t?i(e,si.Checked):i(e,si.Unchecked);let n=e.parent;for(;n;){if(n.config.disabled){n=n.parent;continue}const s=n.children,a=s.every(l=>l.checkState===si.Checked),o=s.every(l=>l.checkState===si.Unchecked);a?n.setChecked(si.Checked,!1):o?n.setChecked(si.Unchecked,!1):n.setChecked(si.Indeterminate,!1),n=n.parent}}getNode(e){return this.nodeMap.get(e)}checkNode(e,t){const i=this.nodeMap.get(e);i&&i.setChecked(t?si.Checked:si.Unchecked,!0)}expandAll(e){this.nodeMap.forEach(t=>t.toggleExpand(e))}checkAllNodes(e){const t=e?si.Checked:si.Unchecked;this.nodeMap.forEach(i=>i.setChecked(t,!1,!0))}getCheckedNodes(e=!1){const t=[];return this.nodeMap.forEach(i=>{(i.checkState===si.Checked||e&&i.checkState===si.Indeterminate)&&t.push(i.config)}),t}}class Y7{element;navElement;contentElement;options;activeId;tabMap=new Map;panelMap=new Map;panelTreeScrollTopMap=new Map;unsubscribeLocale=null;unsubscribeTheme=null;navClickHandler=null;constructor(e){this.options=e,this.activeId=e.activeId||(e.tabs[0]?.id??null),e.tabs.forEach(t=>this.tabMap.set(t.id,t)),this.element=document.createElement("div"),this.element.className="bim-tab",this.navElement=document.createElement("div"),this.navElement.className="bim-tab__nav",this.navElement.setAttribute("role","tablist"),this.element.appendChild(this.navElement),this.contentElement=document.createElement("div"),this.contentElement.className="bim-tab__content",this.element.appendChild(this.contentElement),this.options.container.appendChild(this.element)}init(){this.renderNav(),this.renderPanels(),this.setLocales(),this.setTheme(ht.getTheme()),this.unsubscribeLocale=Zt.subscribe(()=>this.setLocales()),this.unsubscribeTheme=ht.subscribe(e=>this.setTheme(e))}renderNav(){this.navElement.innerHTML="",this.navClickHandler=e=>{const t=e.target.closest(".bim-tab__item");if(!t)return;const i=t.dataset.id;!i||this.tabMap.get(i)?.disabled||this.activateTab(i)},this.navElement.addEventListener("click",this.navClickHandler),this.options.tabs.forEach(e=>{const t=document.createElement("button");if(t.type="button",t.className="bim-tab__item",t.dataset.id=e.id,t.setAttribute("role","tab"),t.id=`tab-${e.id}`,t.setAttribute("aria-selected",`${e.id===this.activeId}`),e.disabled&&(t.disabled=!0,t.setAttribute("aria-disabled","true"),t.classList.add("is-disabled")),e.icon){const n=document.createElement("span");n.className="bim-tab__icon",n.innerHTML=e.icon,t.appendChild(n)}const i=document.createElement("span");i.className="bim-tab__title",i.textContent=this.resolveTitle(e.title),t.appendChild(i),e.id===this.activeId&&t.classList.add("is-active"),this.navElement.appendChild(t)})}renderPanels(){this.contentElement.innerHTML="",this.panelMap.clear(),this.options.tabs.forEach(e=>{const t=document.createElement("div");t.className="bim-tab__panel",t.dataset.id=e.id,t.setAttribute("role","tabpanel"),t.setAttribute("aria-labelledby",`tab-${e.id}`),e.content instanceof HTMLElement?t.appendChild(e.content):typeof e.content=="string"&&(t.innerHTML=e.content),e.id===this.activeId?t.classList.add("is-active"):t.style.display="none",this.panelMap.set(e.id,t),this.contentElement.appendChild(t)})}activateTab(e){if(this.activeId===e)return;const t=this.tabMap.get(e);if(!t||t.disabled)return;this.activeId=e,this.navElement.querySelectorAll(".bim-tab__item").forEach(n=>{const s=n.dataset.id===e;n.classList.toggle("is-active",s),n.setAttribute("aria-selected",`${s}`)}),this.panelMap.forEach((n,s)=>{const a=s===e;a||this.savePanelTreeScrollTop(s,n),n.classList.toggle("is-active",a),n.style.display=a?"":"none",a&&this.restorePanelTreeScrollTop(s,n)}),this.options.onChange&&this.options.onChange(e,t)}setTheme(e){const t=this.element.style;t.setProperty("--bim-tab-bg",e.bgElevated),t.setProperty("--bim-tab-nav-bg",e.bgElevated),t.setProperty("--bim-tab-text",e.textPrimary),t.setProperty("--bim-tab-text-secondary",e.textSecondary),t.setProperty("--bim-tab-text-active",e.primary),t.setProperty("--bim-tab-border",e.borderDefault),t.setProperty("--bim-tab-hover-bg",e.componentBgHover),t.setProperty("--bim-tab-active-bg",e.componentBgActive),t.setProperty("--bim-tab-icon",e.iconDefault)}setLocales(){this.navElement.querySelectorAll(".bim-tab__item").forEach(t=>{const i=t.dataset.id;if(!i)return;const n=this.tabMap.get(i);if(!n)return;const s=t.querySelector(".bim-tab__title");s&&(s.textContent=this.resolveTitle(n.title))})}destroy(){this.navClickHandler&&(this.navElement.removeEventListener("click",this.navClickHandler),this.navClickHandler=null),this.unsubscribeLocale&&(this.unsubscribeLocale(),this.unsubscribeLocale=null),this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.panelMap.clear(),this.panelTreeScrollTopMap.clear(),this.tabMap.clear(),this.element.remove()}savePanelTreeScrollTop(e,t){const i=t.querySelector(".bim-tree-content");i&&this.panelTreeScrollTopMap.set(e,i.scrollTop)}restorePanelTreeScrollTop(e,t){const i=this.panelTreeScrollTopMap.get(e);if(i===void 0)return;const n=t.querySelector(".bim-tree-content");n&&requestAnimationFrame(()=>{n.scrollTop=i})}resolveTitle(e){try{return Se(e)||e}catch{return e}}}function oS(r,e){let t=e>>>0;for(let i=0;i<r.length;i++){const n=r.charCodeAt(i);t^=n&255,t=Math.imul(t,16777619),t^=n>>>8&255,t=Math.imul(t,16777619)}return t>>>0}async function K7(r){const e=JSON.stringify(r),t=oS(e,2166136261),i=oS(e,522970236);return`${t.toString(16).padStart(8,"0")}${i.toString(16).padStart(8,"0")}`}function lS(r){const e=new Map,t=n=>{const s=n.config.data,a=s?._modelUrl;if(a&&s?.ids?.length){let o=e.get(a);o||(o=new Set,e.set(a,o));for(const l of s.ids){const c=Number(l);Number.isFinite(c)&&o.add(c)}}for(const o of n.children||[])t(o)};t(r);const i=[];for(const[n,s]of e)s.size>0&&i.push({url:n,ids:Array.from(s)});return i}let $7=0;async function J7(r){if(!r||r.length===0)return[];const e=async(t,i)=>{const n=t.children&&t.children.length>0;let s;return t.ids?.length?s=await K7(t.ids):t.id?s=t.id:s=`node_${++$7}`,{id:s,label:t.name||"未命名",expanded:!1,checked:!0,children:n?await Promise.all(t.children.map(a=>e(a,i))):void 0,data:{...t,_modelUrl:i}}};return Promise.all(r.map(async t=>{const i=t.children&&t.children.length>0,n=t.url;return{id:n,label:t.name||"模型",expanded:!0,checked:!0,children:i?await Promise.all(t.children.map(s=>e(s,n))):void 0,data:{_modelUrl:n}}}))}class Q7 extends Fn{toolbar=null;toolbarContainer=null;container;dialog=null;constructor(e,t){super(t),this.container=e,this.init()}init(){this.toolbarContainer=document.createElement("div"),this.toolbarContainer.id="bim-construct-tree",this.container.appendChild(this.toolbarContainer),this.toolbar=new j7({container:this.toolbarContainer,showLabel:!1,direction:"column",position:"top-left",align:"vertical",expand:"up",registry:this.registry}),this.toolbar.init(),this.toolbar.addGroup("construct-tree"),this.toolbar.addButton({id:"construct-tree-btn",groupId:"construct-tree",type:"button",label:"construct-tree",icon:Tt("目录树"),onClick:()=>{this.openConstructTreeDialog()}}),this.toolbar.render()}async openConstructTreeDialog(){this.setVisible(!1);const e=this.engineComponent?.getLevelTreeData()??[],t=this.engineComponent?.getTypeTreeData()??[],i=this.engineComponent?.getMajorTreeData()??[];console.log("[ConstructTree] 原始数据 (Level):",e),console.log("[ConstructTree] 原始数据 (Type):",t),console.log("[ConstructTree] 原始数据 (Major):",i);const n=async(m,g)=>{const f=await J7(m);console.log(`[ConstructTree] 转换后数据 (${g}):`,f);const y=new Z7({data:f,checkable:!0,indent:0,enableSearch:!0,checkStrictly:!0,defaultExpandAll:!0,onNodeCheck:x=>{const _=lS(x);_.length&&(x.checkState===si.Checked?this.engineComponent?.showModel(_):this.engineComponent?.hideModels(_))},onNodeSelect:x=>{const _=lS(x);_.length&&(this.engineComponent?.unhighlightAllModels(),this.engineComponent?.highlightModel(_),this.engineComponent?.viewScaleToModel(_))},onNodeDeselect:()=>{this.engineComponent?.unhighlightAllModels()},onNodeExpand:()=>{this.dialog?.fitWidth()}});return y.init(),y},s=await n(e,"Level"),a=await n(t,"Type"),o=await n(i,"Major"),l=document.createElement("div");l.className="construct-tab__panel-content",l.appendChild(s.element);const c=document.createElement("div");c.className="construct-tab__panel-content",c.appendChild(a.element);const h=document.createElement("div");h.className="construct-tab__panel-content",h.appendChild(o.element);const d=document.createElement("div");d.className="construct-tab__container",d.style.height="100%",d.style.overflow="hidden";const p=()=>{this.engineComponent?.showAllModels(),s.checkAllNodes(!0),a.checkAllNodes(!0),o.checkAllNodes(!0)},u=new Y7({container:d,tabs:[{id:"component",title:"tab.component",content:l},{id:"type",title:"tab.type",content:c},{id:"major",title:"tab.major",content:h}],activeId:"component",onChange:()=>{this.dialog?.fitWidth()}});u.init(),p();const v=this.registry.on("menu:show-all",()=>{p()});this.dialog=this.registry.dialog.create({title:"constructTree.title",minWidth:320,height:600,content:d,position:{x:20,y:20},resizable:!1,onClose:()=>{v(),u.destroy(),s.destroy(),a.destroy(),o.destroy(),this.setVisible(!0)}}),this.dialog?.fitWidth()}refresh(){this.toolbar?.render()}destroy(){this.toolbar?.destroy(),this.toolbar=null,super.destroy()}addGroup(e,t){this.toolbar?.addGroup(e,t),this.toolbar?.render()}addButton(e){this.toolbar?.addButton(e),this.toolbar?.render()}setButtonVisibility(e,t){this.toolbar?.updateButtonVisibility(e,t)}setShowLabel(e){this.toolbar?.setShowLabel(e)}setVisible(e){this.toolbarContainer&&(this.toolbarContainer.style.visibility=e?"visible":"hidden")}setBackgroundColor(e){this.toolbar?.setBackgroundColor(e)}setColors(e){this.toolbar?.setColors(e)}}class eO{events=new Map;on(e,t){return this.events.has(e)||this.events.set(e,[]),this.events.get(e).push(t),()=>this.off(e,t)}off(e,t){const i=this.events.get(e);if(!i)return;const n=i.indexOf(t);n!==-1&&i.splice(n,1)}emit(e,t){const i=this.events.get(e);i&&i.forEach(n=>{try{n(t)}catch(s){console.error(`[EventEmitter] Error in listener for event "${e}":`,s)}})}clear(){this.events.clear()}}class rf{eventEmitter=new eO;container=null;wrapper=null;toolbar=null;dialog=null;engine3d=null;buttonGroup=null;rightKey=null;constructTree=null;measure=null;walkControl=null;sectionPlane=null;sectionAxis=null;sectionBox=null;walkPath=null;walkPlanView=null;engineInfo=null;componentDetail=null;aiChat=null;setting=null;radialToolbar=null;bottomDock=null;measureDock=null;sectionDock=null;walkDock=null;constructor(){}reset(){this.eventEmitter.clear(),this.container=null,this.wrapper=null,this.toolbar=null,this.dialog=null,this.engine3d=null,this.buttonGroup=null,this.rightKey=null,this.constructTree=null,this.measure=null,this.walkControl=null,this.sectionPlane=null,this.sectionAxis=null,this.sectionBox=null,this.walkPath=null,this.walkPlanView=null,this.engineInfo=null,this.componentDetail=null,this.aiChat=null,this.setting=null,this.radialToolbar=null,this.bottomDock=null,this.measureDock=null,this.sectionDock=null,this.walkDock=null}emit(e,t){this.eventEmitter.emit(e,t)}on(e,t){return this.eventEmitter.on(e,t)}off(e,t){this.eventEmitter.off(e,t)}clearEvents(){this.eventEmitter.clear()}}class tO{container;wrapper=null;sizeEl=null;resizeObserver=null;lastSyncedWidth=-1;lastSyncedHeight=-1;registry;dialog=null;engine=null;rightKey=null;radialToolbar=null;bottomDock=null;measureDock=null;sectionDock=null;walkDock=null;measure=null;sectionPlane=null;sectionAxis=null;sectionBox=null;walkControl=null;engineInfo=null;componentDetail=null;aiChat=null;setting=null;constructTreeBtn=null;handleWindowResize=()=>{this.updateClientSizeDisplay()};constructor(e,t){const i=typeof e=="string"?document.getElementById(e):e;if(!i)throw new Error("Container not found");this.container=i,this.registry=new rf,t?.locale&&Zt.setLocale(t.locale),t?.theme&&(t.theme==="custom"?console.warn("Custom theme should be set via setCustomTheme()."):ht.setTheme(t.theme)),this.init()}emit(e,t){this.registry.emit(e,t)}on(e,t){return this.registry.on(e,t)}setLocale(e){Zt.setLocale(e)}getLocale(){return Zt.getLocale()}setTheme(e){ht.setTheme(e)}setCustomTheme(e){ht.setCustomTheme(e)}init(){this.container.innerHTML="",this.wrapper=document.createElement("div"),this.wrapper.className="bim-engine-wrapper",this.container.appendChild(this.wrapper);const e=document.createElement("div");e.className="bim-engine-version",e.textContent="v2.5.8",this.wrapper.appendChild(e),this.sizeEl=document.createElement("div"),this.sizeEl.className="bim-engine-size",this.wrapper.appendChild(this.sizeEl),this.updateClientSizeDisplay(),this.bindSizeObserver(),this.registry.container=this.container,this.registry.wrapper=this.wrapper,this.engine=new BM(this.wrapper,this.registry),this.dialog=new mv(this.wrapper,this.registry),this.rightKey=new rv(this.wrapper,this.registry),this.bottomDock=new HM(this.wrapper,this.registry),this.registry.bottomDock=this.bottomDock,this.measureDock=new jM(this.registry),this.registry.measureDock=this.measureDock,this.measureDock.init(),this.sectionDock=new qM(this.registry),this.registry.sectionDock=this.sectionDock,this.sectionDock.init(),this.walkDock=new KM(this.registry),this.registry.walkDock=this.walkDock,this.walkDock.init(),this.radialToolbar=new zM(this.wrapper,this.registry),this.measure=new $M(this.registry),this.sectionPlane=new JM(this.registry),this.sectionAxis=new QM(this.registry),this.sectionBox=new tS(this.registry),this.walkControl=new iS(this.registry),this.walkControl.init(),this.engineInfo=new nS(this.registry),this.engineInfo.init(),this.registry.engine3d=this.engine,this.registry.dialog=this.dialog,this.registry.rightKey=this.rightKey,this.registry.radialToolbar=this.radialToolbar,this.registry.measure=this.measure,this.registry.sectionPlane=this.sectionPlane,this.registry.sectionAxis=this.sectionAxis,this.registry.sectionBox=this.sectionBox,this.registry.walkControl=this.walkControl,this.registry.engineInfo=this.engineInfo,this.componentDetail=new rS(this.registry),this.registry.componentDetail=this.componentDetail,this.componentDetail.init(),this.aiChat=new aS(this.registry),this.registry.aiChat=this.aiChat,this.aiChat.init(),this.constructTreeBtn=new Q7(this.wrapper,this.registry),this.registry.constructTree=this.constructTreeBtn,this.setting=new cr(this.registry),this.registry.setting=this.setting,this.setting.init(),this.updateTheme(ht.getTheme()),ht.subscribe(t=>{this.updateTheme(t)})}updateTheme(e){this.wrapper&&(this.wrapper.style.color=e.textPrimary)}updateClientSizeDisplay(){const e=this.container.clientWidth,t=this.container.clientHeight;this.sizeEl&&(this.sizeEl.textContent=`${e}px x ${t}px`),this.syncEngineSize(e,t)}syncEngineSize(e,t){e<=0||t<=0||e===this.lastSyncedWidth&&t===this.lastSyncedHeight||(this.lastSyncedWidth=e,this.lastSyncedHeight=t,this.engine?.getEngineComponent()?.resize(e,t))}bindSizeObserver(){if(typeof ResizeObserver<"u"){this.resizeObserver=new ResizeObserver(()=>{this.updateClientSizeDisplay()}),this.resizeObserver.observe(this.container);return}window.addEventListener("resize",this.handleWindowResize)}unbindSizeObserver(){if(this.resizeObserver){this.resizeObserver.disconnect(),this.resizeObserver=null;return}window.removeEventListener("resize",this.handleWindowResize)}destroy(){this.unbindSizeObserver(),this.radialToolbar?.destroy(),this.measureDock?.destroy(),this.sectionDock?.destroy(),this.walkDock?.destroy(),this.bottomDock?.destroy(),this.engine?.destroy(),this.dialog?.destroy(),this.rightKey?.destroy(),this.measure?.destroy(),this.sectionPlane?.destroy(),this.sectionAxis?.destroy(),this.sectionBox?.destroy(),this.walkControl?.destroy(),this.constructTreeBtn?.destroy(),this.aiChat?.destroy(),this.setting?.destroy(),this.sizeEl=null,this.lastSyncedWidth=-1,this.lastSyncedHeight=-1,this.container.innerHTML="",this.registry.reset()}}class iO{container;wrapper=null;sizeEl=null;resizeObserver=null;lastSyncedWidth=-1;lastSyncedHeight=-1;unsubscribeTheme=null;registry;dialog=null;engine=null;rightKey=null;radialToolbar=null;bottomDock=null;measureDock=null;sectionDock=null;walkDock=null;measure=null;sectionPlane=null;sectionAxis=null;sectionBox=null;walkControl=null;engineInfo=null;componentDetail=null;aiChat=null;setting=null;handleWindowResize=()=>{this.updateClientSizeDisplay()};constructor(e,t){const i=typeof e=="string"?document.getElementById(e):e;if(!i)throw new Error("Container not found");this.container=i,this.registry=new rf,t?.locale&&Zt.setLocale(t.locale),t?.theme&&(t.theme==="custom"?console.warn("Custom theme should be set via setCustomTheme()."):ht.setTheme(t.theme)),this.init()}emit(e,t){this.registry.emit(e,t)}on(e,t){return this.registry.on(e,t)}setLocale(e){Zt.setLocale(e)}getLocale(){return Zt.getLocale()}setTheme(e){ht.setTheme(e)}setCustomTheme(e){ht.setCustomTheme(e)}init(){this.container.innerHTML="",this.wrapper=document.createElement("div"),this.wrapper.className="bim-engine-wrapper",this.container.appendChild(this.wrapper);const e=document.createElement("div");e.className="bim-engine-version",e.textContent="v2.5.8",this.wrapper.appendChild(e),this.sizeEl=document.createElement("div"),this.sizeEl.className="bim-engine-size",this.wrapper.appendChild(this.sizeEl),this.updateClientSizeDisplay(),this.bindSizeObserver(),this.registry.container=this.container,this.registry.wrapper=this.wrapper,this.engine=new BM(this.wrapper,this.registry),this.dialog=new mv(this.wrapper,this.registry),this.rightKey=new rv(this.wrapper,this.registry),this.bottomDock=new HM(this.wrapper,this.registry),this.registry.bottomDock=this.bottomDock,this.registry.engine3d=this.engine,this.registry.dialog=this.dialog,this.registry.rightKey=this.rightKey,this.measureDock=new jM(this.registry),this.registry.measureDock=this.measureDock,this.measureDock.init(),this.sectionDock=new qM(this.registry),this.registry.sectionDock=this.sectionDock,this.sectionDock.init(),this.walkDock=new KM(this.registry),this.registry.walkDock=this.walkDock,this.walkDock.init(),this.radialToolbar=new zM(this.wrapper,this.registry),this.measure=new $M(this.registry),this.sectionPlane=new JM(this.registry),this.sectionAxis=new QM(this.registry),this.sectionBox=new tS(this.registry),this.walkControl=new iS(this.registry),this.walkControl.init(),this.engineInfo=new nS(this.registry),this.engineInfo.init(),this.registry.radialToolbar=this.radialToolbar,this.registry.measure=this.measure,this.registry.sectionPlane=this.sectionPlane,this.registry.sectionAxis=this.sectionAxis,this.registry.sectionBox=this.sectionBox,this.registry.walkControl=this.walkControl,this.registry.engineInfo=this.engineInfo,this.componentDetail=new rS(this.registry),this.registry.componentDetail=this.componentDetail,this.componentDetail.init(),this.aiChat=new aS(this.registry),this.registry.aiChat=this.aiChat,this.aiChat.init(),this.setting=new cr(this.registry),this.registry.setting=this.setting,this.setting.init(),this.updateTheme(ht.getTheme()),this.unsubscribeTheme=ht.subscribe(t=>{this.updateTheme(t)})}updateTheme(e){this.wrapper&&(this.wrapper.style.color=e.textPrimary)}updateClientSizeDisplay(){const e=this.container.clientWidth,t=this.container.clientHeight;this.sizeEl&&(this.sizeEl.textContent=`${e}px x ${t}px`),this.syncEngineSize(e,t)}syncEngineSize(e,t){e<=0||t<=0||e===this.lastSyncedWidth&&t===this.lastSyncedHeight||(this.lastSyncedWidth=e,this.lastSyncedHeight=t,this.engine?.getEngineComponent()?.resize(e,t))}bindSizeObserver(){if(typeof ResizeObserver<"u"){this.resizeObserver=new ResizeObserver(()=>{this.updateClientSizeDisplay()}),this.resizeObserver.observe(this.container);return}window.addEventListener("resize",this.handleWindowResize)}unbindSizeObserver(){if(this.resizeObserver){this.resizeObserver.disconnect(),this.resizeObserver=null;return}window.removeEventListener("resize",this.handleWindowResize)}destroy(){this.unbindSizeObserver(),this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.radialToolbar?.destroy(),this.measureDock?.destroy(),this.sectionDock?.destroy(),this.walkDock?.destroy(),this.bottomDock?.destroy(),this.engine?.destroy(),this.dialog?.destroy(),this.rightKey?.destroy(),this.measure?.destroy(),this.sectionPlane?.destroy(),this.sectionAxis?.destroy(),this.sectionBox?.destroy(),this.walkControl?.destroy(),this.aiChat?.destroy(),this.setting?.destroy(),this.sizeEl=null,this.lastSyncedWidth=-1,this.lastSyncedHeight=-1,this.container.innerHTML="",this.registry.reset()}}class nO{engine=null;registry;container;containerId;options;_isInitialized=!1;_isDestroyed=!1;unsubscribeTheme=null;constructor(e,t){this.registry=t,this.container=e.container,this.container.id?this.containerId=this.container.id:(this.containerId=`engine2d-container-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,this.container.id=this.containerId),this.options={backgroundColor:e.backgroundColor??1710618,gridEnabled:e.gridEnabled??!0,axesEnabled:e.axesEnabled??!0,selectionColor:e.selectionColor,highlightColor:e.highlightColor,enablePerformanceMonitoring:e.enablePerformanceMonitoring??!0}}init(){if(this._isInitialized){console.warn("[Engine2d] Engine already initialized.");return}if(this._isDestroyed){console.error("[Engine2d] Cannot initialize destroyed engine.");return}try{const e={containerId:this.containerId,backgroundColor:this.options.backgroundColor,gridEnabled:this.options.gridEnabled,axesEnabled:this.options.axesEnabled};if(this.options.selectionColor!==void 0&&(e.selectionColor=this.options.selectionColor),this.options.highlightColor!==void 0&&(e.highlightColor=this.options.highlightColor),this.options.enablePerformanceMonitoring!==void 0&&(e.enablePerformanceMonitoring=this.options.enablePerformanceMonitoring),console.log("[Engine2d] 引擎配置信息:",e),this.engine=_7(e),!this.engine)throw new Error("Failed to create 2D engine instance");this._isInitialized=!0,this.unsubscribeTheme=ht.subscribe(t=>{this.setTheme(t)}),this.setTheme(ht.getTheme()),this.engine.events&&(this.engine.events.on("entity-click",t=>{console.log("[Engine2d] 实体点击:",t),this.registry.emit("engine2d:entity-clicked",{data:t})}),this.engine.events.on("layer-visibility-changed",t=>{console.log("[Engine2d] 图层可见性变更:",t),this.registry.emit("engine2d:layer-changed",{data:t})}))}catch(e){throw console.error("[Engine2d] Failed to initialize 2D engine:",e),this._isInitialized=!1,e}}setTheme(e){}setLocales(){}isInitialized(){return this._isInitialized}async loadDrawing(e,t){if(!this._isInitialized||!this.engine){console.error("[Engine2d] Engine not initialized. Please call init() first.");return}if(!e){console.error("[Engine2d] Drawing URL is required.");return}try{console.log("[Engine2d] 开始加载图纸:",e),await this.engine.loadModel(e,t),console.log("[Engine2d] 图纸加载完成:",e),this.registry.emit("engine2d:drawing-loaded",{url:e})}catch(i){throw console.error("[Engine2d] 图纸加载失败:",i),i}}getLayers(){if(!this._isInitialized||!this.engine)return[];try{return this.engine.getLayers?.()??[]}catch(e){return console.warn("[Engine2d] Failed to get layers:",e),[]}}setLayerVisible(e,t){if(!this._isInitialized||!this.engine){console.warn("[Engine2d] Engine not initialized.");return}try{this.engine.setLayerVisible?.(e,t)}catch(i){console.warn("[Engine2d] Failed to set layer visibility:",i)}}resetView(){if(!(!this._isInitialized||!this.engine))try{this.engine.resetView?.()}catch(e){console.warn("[Engine2d] Failed to reset view:",e)}}fitToView(){if(!(!this._isInitialized||!this.engine))try{this.engine.fitToView?.()}catch(e){console.warn("[Engine2d] Failed to fit to view:",e)}}setZoom(e){!this._isInitialized||!this.engine||this.engine.setZoom?.(e)}getZoom(){return!this._isInitialized||!this.engine?1:this.engine.getZoom?.()??1}setBackgroundColor(e){!this._isInitialized||!this.engine||this.engine.setBackgroundColor?.(e)}clearScene(){!this._isInitialized||!this.engine||this.engine.clearScene?.()}resize(){!this._isInitialized||!this.engine||this.engine.resize?.()}onRawEvent(e,t){this.engine?.events?.on(e,t)}offRawEvent(e,t){this.engine?.events?.off(e,t)}destroy(){if(!this._isDestroyed){if(this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.engine){try{this.engine.dispose?.()}catch(e){console.warn("[Engine2d] Error during dispose:",e)}this.engine=null}this.container.innerHTML="",this._isDestroyed=!0,this._isInitialized=!1}}}class sO{container;registry;engineComponent=null;constructor(e,t){const i=typeof e=="string"?document.getElementById(e):e;if(!i)throw new Error("Container not found");this.container=i,this.registry=new rf,t?.locale&&Zt.setLocale(t.locale),t?.theme&&t.theme!=="custom"&&ht.setTheme(t.theme),this.engineComponent=new nO({container:this.container,backgroundColor:t?.backgroundColor,gridEnabled:t?.gridEnabled,axesEnabled:t?.axesEnabled,selectionColor:t?.selectionColor,highlightColor:t?.highlightColor,enablePerformanceMonitoring:t?.enablePerformanceMonitoring},this.registry),this.engineComponent.init()}async loadDrawing(e,t){return this.engineComponent?.loadDrawing(e,t)}getLayers(){return this.engineComponent?.getLayers()??[]}setLayerVisible(e,t){this.engineComponent?.setLayerVisible(e,t)}resetView(){this.engineComponent?.resetView()}fitToView(){this.engineComponent?.fitToView()}setZoom(e){this.engineComponent?.setZoom(e)}getZoom(){return this.engineComponent?.getZoom()??1}setTheme(e){ht.setTheme(e)}on(e,t){return this.registry.on(e,t)}off(e,t){this.registry.off(e,t)}onRawEvent(e,t){this.engineComponent?.onRawEvent(e,t)}offRawEvent(e,t){this.engineComponent?.offRawEvent(e,t)}destroy(){this.engineComponent?.destroy(),this.engineComponent=null,this.registry.reset()}}class rO{engine=null;registry;container;containerId;options;_isInitialized=!1;_isDestroyed=!1;unsubscribeTheme=null;constructor(e,t){this.registry=t,this.container=e.container,this.container.id?this.containerId=this.container.id:(this.containerId=`engine720-container-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,this.container.id=this.containerId),this.options={fov:e.fov??75,enableZoom:e.enableZoom??!0,enableRotate:e.enableRotate??!0,sphereRadius:e.sphereRadius??500,rotateSpeed:e.rotateSpeed,zoomSpeed:e.zoomSpeed,enableDamping:e.enableDamping,dampingFactor:e.dampingFactor,minFov:e.minFov,maxFov:e.maxFov}}init(){if(this._isInitialized){console.warn("[Engine720] Engine already initialized.");return}if(this._isDestroyed){console.error("[Engine720] Cannot initialize destroyed engine.");return}try{const e={containerId:this.containerId,fov:this.options.fov,enableZoom:this.options.enableZoom,enableRotate:this.options.enableRotate,sphereRadius:this.options.sphereRadius};if(this.options.rotateSpeed!==void 0&&(e.rotateSpeed=this.options.rotateSpeed),this.options.zoomSpeed!==void 0&&(e.zoomSpeed=this.options.zoomSpeed),this.options.enableDamping!==void 0&&(e.enableDamping=this.options.enableDamping),this.options.dampingFactor!==void 0&&(e.dampingFactor=this.options.dampingFactor),this.options.minFov!==void 0&&(e.minFov=this.options.minFov),this.options.maxFov!==void 0&&(e.maxFov=this.options.maxFov),console.log("[Engine720] 引擎配置信息:",e),this.engine=b7(e),!this.engine)throw new Error("Failed to create 720 engine instance");this._isInitialized=!0,this.unsubscribeTheme=ht.subscribe(t=>{this.setTheme(t)}),this.setTheme(ht.getTheme()),this.engine.events&&(this.engine.events.on("panorama-loaded",t=>{console.log("[Engine720] 全景加载完成:",t),this.registry.emit("engine720:panorama-loaded",{data:t})}),this.engine.events.on("panorama-load-error",t=>{console.error("[Engine720] 全景加载失败:",t),this.registry.emit("engine720:load-error",{data:t})}),this.engine.events.on("annotation-click",t=>{console.log("[Engine720] 标注点击:",t),this.registry.emit("engine720:annotation-click",{data:t})}),this.engine.events.on("view-angle-changed",t=>{this.registry.emit("engine720:view-changed",{data:t})}))}catch(e){throw console.error("[Engine720] Failed to initialize 720 engine:",e),this._isInitialized=!1,e}}setTheme(e){!this._isInitialized||this.engine}setLocales(){}isInitialized(){return this._isInitialized}async loadPanorama(e,t){if(!this._isInitialized||!this.engine){console.error("[Engine720] Engine not initialized. Please call init() first.");return}if(!e){console.error("[Engine720] Panorama URL is required.");return}try{console.log("[Engine720] 开始加载全景图:",e),await this.engine.loadPanorama(e),console.log("[Engine720] 全景图加载完成:",e)}catch(i){throw console.error("[Engine720] 全景图加载失败:",i),i}}async preloadPanoramas(e){if(!(!this._isInitialized||!this.engine))try{await this.engine.preloadPanoramas?.(e)}catch(t){console.warn("[Engine720] Failed to preload panoramas:",t)}}setFov(e){!this._isInitialized||!this.engine||this.engine.setFov?.(e)}getFov(){return!this._isInitialized||!this.engine?75:this.engine.getFov?.()??75}lookAt(e,t,i){!this._isInitialized||!this.engine||this.engine.lookAt?.(e,t,i)}resetView(){if(!(!this._isInitialized||!this.engine))try{this.engine.lookAt?.(0,0,!0),this.engine.setFov?.(75)}catch(e){console.warn("[Engine720] Failed to reset view:",e)}}pauseRendering(){!this._isInitialized||!this.engine||this.engine.pauseRendering?.()}resumeRendering(){!this._isInitialized||!this.engine||this.engine.resumeRendering?.()}resize(e,t){!this._isInitialized||!this.engine||this.engine.resize?.(e,t)}onRawEvent(e,t){this.engine?.events?.on(e,t)}offRawEvent(e,t){this.engine?.events?.off(e,t)}destroy(){if(!this._isDestroyed){if(this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.engine){try{this.engine.dispose?.()}catch(e){console.warn("[Engine720] Error during dispose:",e)}this.engine=null}this.container.innerHTML="",this._isDestroyed=!0,this._isInitialized=!1}}}class aO{container;registry;engineComponent=null;constructor(e,t){const i=typeof e=="string"?document.getElementById(e):e;if(!i)throw new Error("Container not found");this.container=i,this.registry=new rf,t?.locale&&Zt.setLocale(t.locale),t?.theme&&t.theme!=="custom"&&ht.setTheme(t.theme),this.engineComponent=new rO({container:this.container,fov:t?.fov,enableZoom:t?.enableZoom,enableRotate:t?.enableRotate,sphereRadius:t?.sphereRadius,rotateSpeed:t?.rotateSpeed,zoomSpeed:t?.zoomSpeed,enableDamping:t?.enableDamping,dampingFactor:t?.dampingFactor,minFov:t?.minFov,maxFov:t?.maxFov},this.registry),this.engineComponent.init()}async loadPanorama(e,t){return this.engineComponent?.loadPanorama(e,t)}async preloadPanoramas(e){return this.engineComponent?.preloadPanoramas(e)}setFov(e){this.engineComponent?.setFov(e)}getFov(){return this.engineComponent?.getFov()??75}lookAt(e,t,i){this.engineComponent?.lookAt(e,t,i)}resetView(){this.engineComponent?.resetView()}setTheme(e){ht.setTheme(e)}on(e,t){return this.registry.on(e,t)}off(e,t){this.registry.off(e,t)}onRawEvent(e,t){this.engineComponent?.onRawEvent(e,t)}offRawEvent(e,t){this.engineComponent?.offRawEvent(e,t)}destroy(){this.engineComponent?.destroy(),this.engineComponent=null,this.registry.reset()}}const oO=Object.freeze(Object.defineProperty({__proto__:null,default:`# BIM引擎AI助手 - 需求分析与步骤规划专家\r
|
|
9885
|
+
`}bindQuestionEvents(){this.messagesContainer?.querySelectorAll(".bim-ai-option").forEach(e=>{e.addEventListener("click",t=>{const i=t.currentTarget,n=i.dataset.questionId,s=i.dataset.optionId;if(n&&s){const a=this.messages.find(o=>o.id===n);a&&!a.answered&&(a.selectedOptionId=s,this.renderMessages())}})}),this.messagesContainer?.querySelectorAll(".bim-ai-option-input").forEach(e=>{e.addEventListener("input",t=>{const i=t.target,n=i.dataset.questionId;if(n){const s=this.messages.find(a=>a.id===n);s&&(s.customAnswer=i.value)}})}),this.messagesContainer?.querySelectorAll(".bim-ai-question-submit").forEach(e=>{e.addEventListener("click",t=>{const n=t.currentTarget.dataset.questionId;if(n){const s=this.messages.find(a=>a.id===n);s&&s.selectedOptionId&&(s.answered=!0,this.renderMessages(),this.options.onQuestionSubmit?.(n,s.selectedOptionId,s.customAnswer))}})})}scrollToBottom(){this.messagesContainer&&(this.messagesContainer.scrollTop=this.messagesContainer.scrollHeight)}escapeHtml(e){const t=document.createElement("div");return t.textContent=e,t.innerHTML}destroy(){this._isDestroyed||(this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.unsubscribeLocale&&(this.unsubscribeLocale(),this.unsubscribeLocale=null),this.element.remove(),this._isDestroyed=!0)}}class aS{aiChat=null;registry;initialized=!1;constructor(e){this.registry=e}init(){if(this.initialized)return;const e=this.registry.wrapper;if(!e){console.warn("[AiChatManager] wrapper 不存在,无法初始化");return}this.aiChat=new X7({container:e,width:440,title:"aiChat.title",placeholder:"aiChat.placeholder",quickPrompts:[{id:"summarize",label:"aiChat.quickPrompt.summarize"},{id:"explain",label:"aiChat.quickPrompt.explain"},{id:"generate",label:"aiChat.quickPrompt.generate"}],onSend:t=>{console.log("[AiChatManager] 用户发送消息:",t),this.aiChat?.addUserMessage(t),this.registry.emit("aiChat:message-sent",{message:t})},onQuestionSubmit:(t,i,n)=>{console.log("[AiChatManager] 用户回答问题:",{questionId:t,optionId:i,customAnswer:n}),this.registry.emit("aiChat:question-answered",{questionId:t,optionId:i,customAnswer:n})},onNewChat:()=>{console.log("[AiChatManager] 新建对话"),this.registry.emit("aiChat:new-chat",{})},onHistory:()=>{console.log("[AiChatManager] 打开历史"),this.registry.emit("aiChat:history-opened",{})},onSettings:()=>{console.log("[AiChatManager] 打开设置"),this.registry.emit("aiChat:settings-opened",{})},onClose:()=>{console.log("[AiChatManager] 关闭 AI 聊天"),this.registry.emit("aiChat:closed",{}),this.registry.toolbar?.setBtnActive("aiChat",!1)}}),this.initialized=!0}show(){this.aiChat||this.init(),this.aiChat?.show(),this.registry.emit("aiChat:opened",{}),this.registry.toolbar?.setBtnActive("aiChat",!0)}hide(){this.aiChat?.hide(),this.registry.emit("aiChat:closed",{}),this.registry.toolbar?.setBtnActive("aiChat",!1)}toggle(){this.aiChat?.isVisible()?this.hide():this.show()}isVisible(){return this.aiChat?.isVisible()??!1}addUserMessage(e){return this.aiChat?.addUserMessage(e)??""}addAiMessage(e){return this.aiChat?.addAiMessage(e)??""}addStepMessage(e,t){return this.aiChat?.addStepMessage(e,t)??""}addThinkingMessage(){return this.aiChat?.addThinkingMessage()??""}addQuestionMessage(e,t,i){return this.aiChat?.addQuestionMessage(e,t,i)??""}updateMessage(e,t){this.aiChat?.updateMessage(e,t)}removeMessage(e){this.aiChat?.removeMessage(e)}clearMessages(){this.aiChat?.clearMessages()}destroy(){this.aiChat&&(this.aiChat.destroy(),this.aiChat=null),this.initialized=!1}}class j7{container;options;groups=[];activeBtnIds=new Set;btnRefs=new Map;dropdownElement=null;hoverTimeout=null;customColors=new Set;unsubscribeLocale=null;unsubscribeTheme=null;DEFAULT_ICON='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect></svg>';constructor(e){const t=typeof e.container=="string"?document.getElementById(e.container):e.container;if(!t)throw new Error("Container not found");this.container=t,this.options={showLabel:!0,visibility:{},direction:"row",position:"static",align:"vertical",expand:"down",...e},["backgroundColor","btnBackgroundColor","btnHoverColor","btnActiveColor","iconColor","iconActiveColor","textColor","textActiveColor"].forEach(n=>{e[n]&&this.customColors.add(n)}),this.initContainer(),this.applyStyles()}emit(e,t){this.options.registry?.emit(e,t)}initContainer(){this.container.innerHTML="",this.container.classList.add("bim-btn-group-root"),this.options.direction==="column"?this.container.classList.add("dir-column"):this.container.classList.add("dir-row"),this.options.className&&this.container.classList.add(this.options.className),this.options.type&&this.options.type!=="default"&&this.container.classList.add(`type-${this.options.type}`),this.updatePosition(),this.setupEventInterception(this.container)}setupEventInterception(e){const t=n=>{n.stopPropagation()};["click","dblclick","contextmenu","wheel","mousedown","mouseup","mousemove","touchstart","touchend","touchmove","pointerdown","pointerup","pointermove","pointerenter","pointerleave","pointerover","pointerout"].forEach(n=>{e.addEventListener(n,t,{passive:!1})})}updatePosition(){const e=this.options.position,t=this.container.style;if(t.top="",t.bottom="",t.left="",t.right="",t.transform="",e==="static"){this.container.classList.add("static");return}if(this.container.classList.remove("static"),this.container.style.position="absolute",typeof e=="object"&&"x"in e)t.left=`${e.x}px`,t.top=`${e.y}px`;else{const i="20px";switch(e){case"top-left":t.top=i,t.left=i;break;case"top-center":t.top=i,t.left="50%",t.transform="translateX(-50%)";break;case"top-right":t.top=i,t.right=i;break;case"bottom-left":t.bottom=i,t.left=i;break;case"bottom-center":t.bottom=i,t.left="50%",t.transform="translateX(-50%)";break;case"bottom-right":t.bottom=i,t.right=i;break;case"left-center":t.left=i,t.top="50%",t.transform="translateY(-50%)";break;case"right-center":t.right=i,t.top="50%",t.transform="translateY(-50%)";break;case"center":t.top="50%",t.left="50%",t.transform="translate(-50%, -50%)";break}}}applyStyles(){const e=this.container.style;this.options.backgroundColor&&e.setProperty("--bim-btn-group-section-bg",this.options.backgroundColor),this.options.btnBackgroundColor&&e.setProperty("--bim-btn-bg",this.options.btnBackgroundColor),this.options.btnHoverColor&&e.setProperty("--bim-btn-hover-bg",this.options.btnHoverColor),this.options.btnActiveColor&&e.setProperty("--bim-btn-active-bg",this.options.btnActiveColor),this.options.iconColor&&e.setProperty("--bim-icon-color",this.options.iconColor),this.options.iconActiveColor&&e.setProperty("--bim-icon-active-color",this.options.iconActiveColor),this.options.textColor&&e.setProperty("--bim-btn-text-color",this.options.textColor),this.options.textActiveColor&&e.setProperty("--bim-btn-text-active-color",this.options.textActiveColor),document.querySelectorAll(".opt-btn-dropdown").forEach(i=>{const n=i.style;this.options.iconColor&&n.setProperty("--bim-icon-color",this.options.iconColor),this.options.iconActiveColor&&n.setProperty("--bim-icon-active-color",this.options.iconActiveColor),this.options.textColor&&n.setProperty("--bim-btn-text-color",this.options.textColor),this.options.textActiveColor&&n.setProperty("--bim-btn-text-active-color",this.options.textActiveColor),this.options.btnBackgroundColor&&n.setProperty("--bim-btn-bg",this.options.btnBackgroundColor),this.options.btnHoverColor&&n.setProperty("--bim-btn-hover-bg",this.options.btnHoverColor),this.options.btnActiveColor&&n.setProperty("--bim-btn-active-bg",this.options.btnActiveColor)})}setPrimaryColor(e){this.container.style.setProperty("--bim-primary-color",e),document.querySelectorAll(".opt-btn-dropdown").forEach(i=>{i.style.setProperty("--bim-primary-color",e)})}setTheme(e){const t={backgroundColor:e.bgElevated,btnBackgroundColor:e.componentBg,btnHoverColor:e.componentBgHover,btnActiveColor:e.componentBgActive,iconColor:e.iconDefault,iconActiveColor:e.iconActive,textColor:e.textSecondary,textActiveColor:e.textPrimary};Object.entries(t).forEach(([i,n])=>{const s=i;this.customColors.has(s)||(this.options[s]=n)}),this.container.classList.remove("theme-dark","theme-light"),this.container.classList.add(`theme-${e.name}`),this.applyStyles(),this.setPrimaryColor(e.primary),this.applyThemeCssVars(e)}applyThemeCssVars(e){const t=this.container.style;t.setProperty("--bim-primary",e.primary),t.setProperty("--bim-primary-hover",e.primaryHover),t.setProperty("--bim-primary-active",e.primaryActive),t.setProperty("--bim-bg-glass",e.bgGlass),t.setProperty("--bim-bg-glass-blur",e.bgGlassBlur),t.setProperty("--bim-bg-elevated",e.bgElevated),t.setProperty("--bim-bg-overlay",e.bgOverlay),t.setProperty("--bim-bg-inset",e.bgInset),t.setProperty("--bim-text-primary",e.textPrimary),t.setProperty("--bim-text-secondary",e.textSecondary),t.setProperty("--bim-text-tertiary",e.textTertiary),t.setProperty("--bim-text-inverse",e.textInverse),t.setProperty("--bim-icon-default",e.iconDefault),t.setProperty("--bim-icon-hover",e.iconHover),t.setProperty("--bim-icon-active",e.iconActive),t.setProperty("--bim-icon-inverse",e.iconInverse),t.setProperty("--bim-border-default",e.borderDefault),t.setProperty("--bim-border-subtle",e.borderSubtle),t.setProperty("--bim-component-bg-hover",e.componentBgHover),t.setProperty("--bim-component-bg-active",e.componentBgActive),t.setProperty("--bim-shadow-sm",e.shadowSm),t.setProperty("--bim-shadow-md",e.shadowMd),t.setProperty("--bim-shadow-lg",e.shadowLg),t.setProperty("--bim-shadow-glow",e.shadowGlow),t.setProperty("--bim-floating-bg",e.floatingBg),t.setProperty("--bim-floating-border",e.floatingBorder),t.setProperty("--bim-floating-shadow",e.floatingShadow),t.setProperty("--bim-floating-btn-bg",e.floatingBtnBg),t.setProperty("--bim-floating-btn-border",e.floatingBtnBorder),t.setProperty("--bim-floating-btn-shadow",e.floatingBtnShadow),t.setProperty("--bim-floating-btn-bg-hover",e.floatingBtnBgHover),t.setProperty("--bim-floating-btn-shadow-hover",e.floatingBtnShadowHover),t.setProperty("--bim-floating-icon-color",e.floatingIconColor),t.setProperty("--bim-floating-icon-color-hover",e.floatingIconColorHover),this.syncDropdownCssVars(e)}syncDropdownCssVars(e){document.querySelectorAll(".opt-btn-dropdown").forEach(i=>{const n=i.style;n.setProperty("--bim-primary",e.primary),n.setProperty("--bim-bg-overlay",e.bgOverlay),n.setProperty("--bim-border-default",e.borderDefault),n.setProperty("--bim-text-primary",e.textPrimary),n.setProperty("--bim-text-inverse",e.textInverse),n.setProperty("--bim-shadow-lg",e.shadowLg),n.setProperty("--bim-floating-btn-bg",e.floatingBtnBg),n.setProperty("--bim-floating-btn-bg-hover",e.floatingBtnBgHover),n.setProperty("--bim-floating-icon-color",e.floatingIconColor)})}setColors(e){this.options={...this.options,...e},Object.keys(e).forEach(t=>{this.customColors.add(t)}),this.applyStyles()}async init(){this.render(),this.unsubscribeLocale=Zt.subscribe(()=>{this.setLocales()}),this.unsubscribeTheme=ht.subscribe(e=>{this.setTheme(e)})}setLocales(){this.render()}addGroup(e,t){if(this.groups.some(n=>n.id===e))return;const i={id:e,buttons:[]};if(t){const n=this.groups.findIndex(s=>s.id===t);n!==-1?this.groups.splice(n,0,i):this.groups.push(i)}else this.groups.push(i)}addButton(e){const{groupId:t,parentId:i}=e,n=this.groups.find(a=>a.id===t);if(!n)return;const s={...e,children:e.children||[]};if(i){const a=this.findButton(n.buttons,i);a&&(a.children||(a.children=[]),a.children.push(s))}else n.buttons.push(s)}findButton(e,t){for(const i of e){if(i.id===t)return i;if(i.children){const n=this.findButton(i.children,t);if(n)return n}}}render(){this.container.innerHTML="",this.btnRefs.clear(),this.groups.forEach((e,t)=>{const i=this.renderGroup(e,t,this.groups.length);this.container.appendChild(i)})}renderGroup(e,t,i){const n=document.createElement("div");return n.className="bim-btn-group-section",t<i-1&&n.classList.add("has-divider"),e.buttons.forEach(s=>{if(this.isVisible(s.id)){const a=this.renderButton(s);n.appendChild(a)}}),n}renderButton(e){const t=document.createElement("div");t.className="opt-btn-wrapper";const i=document.createElement("div");i.className="opt-btn",e.isActive&&this.activeBtnIds.add(e.id),(e.align||this.options.align||"vertical")==="horizontal"?i.classList.add("align-horizontal"):i.classList.add("align-vertical"),this.activeBtnIds.has(e.id)&&i.classList.add("active"),e.disabled&&i.classList.add("disabled"),this.options.showLabel&&e.label||(i.classList.add("no-label"),e.label&&(i.title=Se(e.label)));const a=e.iconSize||32,o=e.minWidth||50;i.style.minWidth=`${o}px`;const l=document.createElement("div");l.className="opt-btn-icon",l.style.width=`${a}px`,l.style.height=`${a}px`,l.innerHTML=this.getIcon(e.icon),i.appendChild(l);const c=document.createElement("div");if(c.className="opt-btn-text-wrapper",this.options.showLabel&&e.label){const h=document.createElement("span");h.className="opt-btn-label",h.textContent=Se(e.label),c.appendChild(h)}return c.hasChildNodes()&&i.appendChild(c),i.addEventListener("click",()=>this.handleClick(e)),i.addEventListener("mouseenter",()=>this.handleMouseEnter(e,i)),i.addEventListener("mouseleave",()=>this.handleMouseLeave()),this.btnRefs.set(e.id,i),t.appendChild(i),t}setBtnActive(e,t){const i=this.findButtonById(e);if(!i)return;const n=t!==void 0?t:!this.activeBtnIds.has(e);n?this.activeBtnIds.add(e):this.activeBtnIds.delete(e),i.isActive=n,this.updateButtonState(e)}handleClick(e){if(!e.disabled&&(!e.children||e.children.length===0)){if(e.keepActive){const i=!this.activeBtnIds.has(e.id);this.setBtnActive(e.id,i),i&&e.exclusive&&e.groupId&&this.deactivateExclusiveSiblings(e)}this.closeDropdown(),e.onClick&&e.onClick(e)}}deactivateExclusiveSiblings(e){const t=this.groups.find(i=>i.id===e.groupId);if(t){if(e.parentId){const n=this.findButton(t.buttons,e.parentId)?.children||[];for(const s of n)s&&s.id!==e.id&&s.parentId===e.parentId&&s.groupId===e.groupId&&this.activeBtnIds.has(s.id)&&(this.setBtnActive(s.id,!1),s.onClick&&s.onClick(s));return}for(const i of t.buttons)i.id!==e.id&&i.groupId===e.groupId&&(i.parentId||this.activeBtnIds.has(i.id)&&(this.setBtnActive(i.id,!1),i.onClick&&i.onClick(i)))}}handleMouseEnter(e,t){this.hoverTimeout&&clearTimeout(this.hoverTimeout),e.children&&e.children.length>0?this.showDropdown(e,t):this.closeDropdown()}handleMouseLeave(){this.hoverTimeout=window.setTimeout(()=>this.closeDropdown(),200)}showDropdown(e,t){if(this.closeDropdown(),!e.children)return;const i=document.createElement("div");i.className="opt-btn-dropdown",this.options.backgroundColor&&i.style.setProperty("--bim-toolbar-bg",this.options.backgroundColor);const n=i.style;this.options.iconColor&&n.setProperty("--bim-icon-color",this.options.iconColor),this.options.iconActiveColor&&n.setProperty("--bim-icon-active-color",this.options.iconActiveColor),this.options.textColor&&n.setProperty("--bim-btn-text-color",this.options.textColor),this.options.textActiveColor&&n.setProperty("--bim-btn-text-active-color",this.options.textActiveColor),this.options.btnBackgroundColor&&n.setProperty("--bim-btn-bg",this.options.btnBackgroundColor),this.options.btnHoverColor&&n.setProperty("--bim-btn-hover-bg",this.options.btnHoverColor),this.options.btnActiveColor&&n.setProperty("--bim-btn-active-bg",this.options.btnActiveColor);const s=t.getBoundingClientRect(),a=this.options.expand||"down";this.options.direction==="row"?i.style.flexDirection="column":i.style.flexDirection="row",this.options.type&&this.options.type!=="default"&&i.classList.add(`type-${this.options.type}`);const o=ht.getTheme();i.classList.add(`theme-${o.name}`),n.setProperty("--bim-primary",o.primary),n.setProperty("--bim-bg-overlay",o.bgOverlay),n.setProperty("--bim-border-default",o.borderDefault),n.setProperty("--bim-text-primary",o.textPrimary),n.setProperty("--bim-text-inverse",o.textInverse),n.setProperty("--bim-shadow-lg",o.shadowLg),n.setProperty("--bim-floating-btn-bg",o.floatingBtnBg),n.setProperty("--bim-floating-btn-bg-hover",o.floatingBtnBgHover),n.setProperty("--bim-floating-icon-color",o.floatingIconColor),document.body.appendChild(i),this.setupEventInterception(i),e.children.forEach(c=>{if(this.isVisible(c.id)){const h=this.renderDropdownItem(c);i.appendChild(h)}});const l=i.getBoundingClientRect();a==="up"?(i.style.bottom=window.innerHeight-s.top+8+"px",i.style.left=s.left+(s.width-l.width)/2+"px"):a==="down"?(i.style.top=s.bottom+8+"px",i.style.left=s.left+(s.width-l.width)/2+"px"):a==="right"?(i.style.top=s.top+(s.height-l.height)/2+"px",i.style.left=s.right+8+"px"):a==="left"&&(i.style.top=s.top+(s.height-l.height)/2+"px",i.style.right=window.innerWidth-s.left+8+"px"),i.addEventListener("mouseenter",()=>{this.hoverTimeout&&clearTimeout(this.hoverTimeout)}),i.addEventListener("mouseleave",()=>this.handleMouseLeave()),this.dropdownElement=i}renderDropdownItem(e){const t=document.createElement("div");t.className="opt-btn-dropdown-item",(e.align||"horizontal")==="horizontal"?t.classList.add("align-horizontal"):t.classList.add("align-vertical"),(this.activeBtnIds.has(e.id)||e.isActive)&&t.classList.add("active");const n=e.iconSize||32,s=e.minWidth;s&&(t.style.minWidth=`${s}px`);const a=document.createElement("div");if(a.className="opt-btn-icon",a.style.width=`${n}px`,a.style.height=`${n}px`,a.innerHTML=this.getIcon(e.icon),t.appendChild(a),this.options.showLabel&&e.label){const o=document.createElement("span");o.className="opt-btn-dropdown-label",o.textContent=Se(e.label),t.appendChild(o)}else e.label&&(t.title=Se(e.label));return t.addEventListener("click",o=>{o.stopPropagation(),this.handleClick(e)}),t}closeDropdown(){this.dropdownElement&&(this.dropdownElement.remove(),this.dropdownElement=null),this.btnRefs.forEach(e=>{const t=e.querySelector(".opt-btn-arrow");t&&t.classList.remove("rotated")})}updateButtonState(e){const t=this.btnRefs.get(e);t&&(this.activeBtnIds.has(e)?t.classList.add("active"):t.classList.remove("active"))}getIcon(e){return e||this.DEFAULT_ICON}updateButtonIcon(e,t){const i=this.btnRefs.get(e);if(!i)return;const n=i.querySelector(".opt-btn-icon");n&&(n.innerHTML=this.getIcon(t));const s=this.findButtonById(e);s&&(s.icon=t)}updateButtonVisibility(e,t){this.options.visibility||(this.options.visibility={}),this.options.visibility[e]=t,this.render()}setShowLabel(e){this.options.showLabel=e,this.updateLabelsVisibility()}updateLabelsVisibility(){this.btnRefs.forEach((e,t)=>{const i=this.findButtonById(t);if(!i)return;this.options.showLabel&&i.label?(e.classList.remove("no-label"),e.removeAttribute("title")):(e.classList.add("no-label"),i.label&&(e.title=Se(i.label)))})}findButtonById(e){for(const t of this.groups){const i=this.findButton(t.buttons,e);if(i)return i}}setBackgroundColor(e){this.setColors({backgroundColor:e})}isVisible(e){return this.options.visibility?.[e]!==!1}setType(e){this.container.classList.remove("type-default","type-glass-pill"),this.options.type=e,e&&e!=="default"&&this.container.classList.add(`type-${e}`),this.render()}getType(){return this.options.type||"default"}destroy(){this.unsubscribeLocale&&(this.unsubscribeLocale(),this.unsubscribeLocale=null),this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.closeDropdown(),this.container.innerHTML="",this.btnRefs.clear()}}var si=(r=>(r[r.Unchecked=0]="Unchecked",r[r.Checked=1]="Checked",r[r.Indeterminate=2]="Indeterminate",r))(si||{});class q7{config;element;children=[];parent=null;checkState=si.Unchecked;contentEl;switcherEl;checkboxEl=null;titleEl;actionsEl;childrenContainer;onExpandChange;onCheckChange;onNodeClick;renderActions;constructor(e,t,i){this.config=e,this.onExpandChange=i.onExpand,this.onCheckChange=i.onCheck,this.onNodeClick=i.onClick,this.renderActions=t.renderActions,this.checkState=e.checked?si.Checked:si.Unchecked,this.element=this.createDom(t)}createDom(e){const t=document.createElement("div");t.className="bim-tree-node",this.config.disabled&&t.classList.add("is-disabled"),this.contentEl=document.createElement("div"),this.contentEl.className="bim-tree-node-content",this.switcherEl=document.createElement("span"),this.switcherEl.className="bim-tree-switcher",this.switcherEl.innerHTML='<svg viewBox="0 0 1024 1024"><path d="M288 192l448 320-448 320z"></path></svg>';const i=this.config.children&&this.config.children.length>0;if(i?this.config.expanded&&this.switcherEl.classList.add("is-expanded"):this.switcherEl.classList.add("is-hidden"),this.switcherEl.addEventListener("click",s=>{s.stopPropagation(),this.toggleExpand()}),this.contentEl.appendChild(this.switcherEl),e.checkable!==!1&&(this.checkboxEl=document.createElement("span"),this.checkboxEl.className="bim-tree-checkbox",this.updateCheckboxUI(),this.checkboxEl.addEventListener("click",s=>{s.stopPropagation(),!this.config.disabled&&this.toggleCheck()}),this.contentEl.appendChild(this.checkboxEl)),this.config.icon){const s=document.createElement("span");s.className="bim-tree-icon",s.innerHTML=this.config.icon.includes("<svg")?this.config.icon:`<img src="${this.config.icon}" />`,this.contentEl.appendChild(s)}this.titleEl=document.createElement("span"),this.titleEl.className="bim-tree-title",this.updateLabel(),this.contentEl.appendChild(this.titleEl),this.actionsEl=document.createElement("div"),this.actionsEl.className="bim-tree-node-actions",this.actionsEl.addEventListener("click",s=>{s.stopPropagation()}),this.contentEl.appendChild(this.actionsEl),this.contentEl.addEventListener("click",s=>{if(s.stopPropagation(),this.config.disabled)return;(this.config.clickAction||"select")==="expand"?this.toggleExpand():this.onNodeClick(this)}),t.appendChild(this.contentEl),this.childrenContainer=document.createElement("div"),this.childrenContainer.className="bim-tree-children";const n=e.indent||24;return this.childrenContainer.style.paddingLeft=`${n}px`,this.config.expanded&&i&&this.childrenContainer.classList.add("is-visible"),t.appendChild(this.childrenContainer),t}setSelected(e){if(e){if(this.contentEl.classList.add("is-selected"),this.renderActions){const t=this.renderActions(this.config);this.actionsEl.innerHTML="",typeof t=="string"?this.actionsEl.innerHTML=t:t instanceof HTMLElement&&this.actionsEl.appendChild(t)}}else this.contentEl.classList.remove("is-selected"),this.actionsEl.innerHTML=""}updateLabel(){this.titleEl&&(this.titleEl.textContent=this.config.label)}toggleExpand(e){if(!this.config.children||this.config.children.length===0)return;const t=e!==void 0?e:!this.config.expanded;this.config.expanded=t,t?(this.switcherEl.classList.add("is-expanded"),this.childrenContainer.classList.add("is-visible")):(this.switcherEl.classList.remove("is-expanded"),this.childrenContainer.classList.remove("is-visible")),e===void 0&&this.onExpandChange(this)}toggleCheck(){const e=this.checkState!==si.Checked;this.setChecked(e?si.Checked:si.Unchecked,!0)}setChecked(e,t=!1,i=!1){!i&&this.checkState===e||(this.checkState=e,this.config.checked=e===si.Checked,this.updateCheckboxUI(),t&&this.onCheckChange(this))}updateCheckboxUI(){this.checkboxEl&&(this.checkboxEl.classList.remove("is-checked","is-indeterminate"),this.checkState===si.Checked?this.checkboxEl.classList.add("is-checked"):this.checkState===si.Indeterminate&&this.checkboxEl.classList.add("is-indeterminate"))}appendChild(e){e.parent=this,this.children.push(e),this.childrenContainer.appendChild(e.element),this.children.length===1&&this.switcherEl.classList.remove("is-hidden")}destroy(){this.children.forEach(e=>e.destroy()),this.children=[],this.element.remove(),this.parent=null}}class Z7{element;contentElement;searchInput=null;searchResults=null;options;nodeMap=new Map;rootNodes=[];selectedNode=null;lastRevealedNodeId=null;unsubscribeLocale=null;unsubscribeTheme=null;clickOutsideHandler=null;onNodeCheck;onNodeSelect;onNodeDeselect;onNodeExpand;constructor(e){this.options={checkable:!0,checkStrictly:!0,indent:24,defaultExpandAll:!0,enableSearch:!1,searchPlaceholder:"tree.searchPlaceholder",...e},this.element=document.createElement("div"),this.element.className="bim-tree",this.options.enableSearch&&this.createSearchDOM(),this.contentElement=document.createElement("div"),this.contentElement.className="bim-tree-content",this.element.appendChild(this.contentElement),e.onNodeCheck&&(this.onNodeCheck=e.onNodeCheck),e.onNodeSelect&&(this.onNodeSelect=e.onNodeSelect),e.onNodeDeselect&&(this.onNodeDeselect=e.onNodeDeselect),e.onNodeExpand&&(this.onNodeExpand=e.onNodeExpand)}createSearchDOM(){const e=document.createElement("div");e.className="bim-tree-search";const t=document.createElement("div");t.className="bim-tree-search-wrapper";const i=document.createElement("span");i.className="bim-tree-search-icon",i.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="m21 21l-4.343-4.343m0 0A8 8 0 1 0 5.343 5.343a8 8 0 0 0 11.314 11.314"/></svg>',t.appendChild(i),this.searchInput=document.createElement("input"),this.searchInput.className="bim-tree-search-input",this.searchInput.type="text",this.searchInput.placeholder=Se(this.options.searchPlaceholder||"搜索..."),this.searchInput.addEventListener("input",n=>{const s=n.target.value;this.handleSearch(s)}),t.appendChild(this.searchInput),e.appendChild(t),this.searchResults=document.createElement("div"),this.searchResults.className="bim-tree-search-results",e.appendChild(this.searchResults),this.element.appendChild(e),this.clickOutsideHandler=n=>{this.searchResults&&!this.searchResults.contains(n.target)&&!this.searchInput?.contains(n.target)&&this.searchResults.classList.remove("is-visible")},document.addEventListener("click",this.clickOutsideHandler)}init(){this.render(),this.unsubscribeLocale=Zt.subscribe(()=>this.setLocales()),this.unsubscribeTheme=ht.subscribe(e=>this.setTheme(e)),this.setTheme(ht.getTheme())}handleSearch(e){if(!this.searchResults)return;if(!e.trim()){this.searchResults.classList.remove("is-visible"),this.searchResults.innerHTML="";return}const t=[],i=e.toLowerCase();this.nodeMap.forEach(n=>{const s=n.config.label;s.toLowerCase().includes(i)&&t.push({node:n,label:s,path:this.getNodePath(n)})}),this.renderSearchResults(t)}getNodePath(e){const t=[];let i=e.parent;for(;i;)t.unshift(i.config.label),i=i.parent;return t.join(" > ")}renderSearchResults(e){if(this.searchResults){if(this.searchResults.innerHTML="",e.length===0){const t=document.createElement("div");t.className="bim-tree-search-item",t.style.cursor="default",t.style.color="#999",t.textContent="No results",this.searchResults.appendChild(t)}else e.forEach(t=>{const i=document.createElement("div");i.className="bim-tree-search-item";const n=document.createElement("span");n.className="bim-tree-search-item-title",n.textContent=t.label;const s=document.createElement("span");s.className="bim-tree-search-item-path",s.textContent=t.path,i.appendChild(n),t.path&&i.appendChild(s),i.addEventListener("click",()=>{this.revealNode(t.node)}),this.searchResults.appendChild(i)});this.searchResults.classList.add("is-visible")}}revealNode(e){if(this.lastRevealedNodeId===e.config.id&&this.isNodeFullyVisible(e))return;this.lastRevealedNodeId=e.config.id,this.searchResults&&(this.searchResults.classList.remove("is-visible"),this.searchInput&&(this.searchInput.value=""));let t=e.parent;for(;t;)t.toggleExpand(!0),t=t.parent;this.handleNodeSelect(e),requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.scrollNodeIntoContentCenter(e)})})}isNodeFullyVisible(e){const t=this.contentElement;if(!t||!e?.element?.isConnected)return!1;const i=t.getBoundingClientRect(),n=e.element.getBoundingClientRect();return n.top>=i.top&&n.bottom<=i.bottom}scrollNodeIntoContentCenter(e){const t=this.contentElement;if(!t||!e?.element?.isConnected)return;const i=t.getBoundingClientRect(),n=e.element.getBoundingClientRect();if(n.top>=i.top&&n.bottom<=i.bottom)return;const s=n.top-i.top+t.scrollTop,a=Math.max(0,s-(t.clientHeight-n.height)/2);t.scrollTo({top:a,behavior:"auto"})}setTheme(e){const t=this.element.style;t.setProperty("--bim-primary",e.primary),t.setProperty("--bim-bg-elevated",e.bgElevated),t.setProperty("--bim-text-primary",e.textPrimary),t.setProperty("--bim-text-secondary",e.textSecondary),t.setProperty("--bim-text-tertiary",e.textTertiary),t.setProperty("--bim-text-disabled",e.textDisabled),t.setProperty("--bim-text-inverse",e.textInverse),t.setProperty("--bim-border-default",e.borderDefault),t.setProperty("--bim-border-disabled",e.borderDisabled),t.setProperty("--bim-component-bg-hover",e.componentBgHover),t.setProperty("--bim-component-bg-selected",e.componentBgSelected),t.setProperty("--bim-component-bg-disabled",e.componentBgDisabled),t.setProperty("--bim-shadow-md",e.shadowMd),t.setProperty("--bim-focus-ring",e.focusRing)}setLocales(){this.nodeMap.forEach(e=>e.updateLabel()),this.searchInput&&(this.searchInput.placeholder=Se(this.options.searchPlaceholder||"tree.searchPlaceholder"))}destroy(){this.unsubscribeLocale&&(this.unsubscribeLocale(),this.unsubscribeLocale=null),this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.clickOutsideHandler&&(document.removeEventListener("click",this.clickOutsideHandler),this.clickOutsideHandler=null),this.rootNodes.forEach(e=>e.destroy()),this.rootNodes=[],this.nodeMap.clear(),this.lastRevealedNodeId=null,this.element.remove(),this.selectedNode=null}render(){this.contentElement.innerHTML="",this.nodeMap.clear(),this.rootNodes=[],this.options.data.forEach(e=>{this.createNodeRecursively(e,null)})}createNodeRecursively(e,t){e.expanded===void 0&&(e.expanded=this.options.defaultExpandAll);const i=new q7(e,this.options,{onExpand:n=>{this.onNodeExpand&&this.onNodeExpand(n)},onCheck:n=>this.handleNodeCheck(n),onClick:n=>this.handleNodeSelect(n)});this.nodeMap.set(e.id,i),t?t.appendChild(i):(this.rootNodes.push(i),this.contentElement.appendChild(i.element)),e.children&&e.children.length>0&&e.children.forEach(n=>{this.createNodeRecursively(n,i)})}handleNodeSelect(e){if(this.selectedNode===e){e.setSelected(!1),this.selectedNode=null,this.onNodeDeselect&&this.onNodeDeselect(e);return}this.selectedNode&&this.selectedNode.setSelected(!1),e.setSelected(!0),this.selectedNode=e,this.onNodeSelect&&this.onNodeSelect(e)}handleNodeCheck(e){const t=e.checkState===si.Checked;if(this.onNodeCheck&&this.onNodeCheck(e),this.options.checkStrictly===!1)return;const i=(s,a)=>{s.children.forEach(o=>{o.config.disabled||(o.setChecked(a,!1),i(o,a))})};t?i(e,si.Checked):i(e,si.Unchecked);let n=e.parent;for(;n;){if(n.config.disabled){n=n.parent;continue}const s=n.children,a=s.every(l=>l.checkState===si.Checked),o=s.every(l=>l.checkState===si.Unchecked);a?n.setChecked(si.Checked,!1):o?n.setChecked(si.Unchecked,!1):n.setChecked(si.Indeterminate,!1),n=n.parent}}getNode(e){return this.nodeMap.get(e)}checkNode(e,t){const i=this.nodeMap.get(e);i&&i.setChecked(t?si.Checked:si.Unchecked,!0)}expandAll(e){this.nodeMap.forEach(t=>t.toggleExpand(e))}checkAllNodes(e){const t=e?si.Checked:si.Unchecked;this.nodeMap.forEach(i=>i.setChecked(t,!1,!0))}getCheckedNodes(e=!1){const t=[];return this.nodeMap.forEach(i=>{(i.checkState===si.Checked||e&&i.checkState===si.Indeterminate)&&t.push(i.config)}),t}}class Y7{element;navElement;contentElement;options;activeId;tabMap=new Map;panelMap=new Map;panelTreeScrollTopMap=new Map;unsubscribeLocale=null;unsubscribeTheme=null;navClickHandler=null;constructor(e){this.options=e,this.activeId=e.activeId||(e.tabs[0]?.id??null),e.tabs.forEach(t=>this.tabMap.set(t.id,t)),this.element=document.createElement("div"),this.element.className="bim-tab",this.navElement=document.createElement("div"),this.navElement.className="bim-tab__nav",this.navElement.setAttribute("role","tablist"),this.element.appendChild(this.navElement),this.contentElement=document.createElement("div"),this.contentElement.className="bim-tab__content",this.element.appendChild(this.contentElement),this.options.container.appendChild(this.element)}init(){this.renderNav(),this.renderPanels(),this.setLocales(),this.setTheme(ht.getTheme()),this.unsubscribeLocale=Zt.subscribe(()=>this.setLocales()),this.unsubscribeTheme=ht.subscribe(e=>this.setTheme(e))}renderNav(){this.navElement.innerHTML="",this.navClickHandler=e=>{const t=e.target.closest(".bim-tab__item");if(!t)return;const i=t.dataset.id;!i||this.tabMap.get(i)?.disabled||this.activateTab(i)},this.navElement.addEventListener("click",this.navClickHandler),this.options.tabs.forEach(e=>{const t=document.createElement("button");if(t.type="button",t.className="bim-tab__item",t.dataset.id=e.id,t.setAttribute("role","tab"),t.id=`tab-${e.id}`,t.setAttribute("aria-selected",`${e.id===this.activeId}`),e.disabled&&(t.disabled=!0,t.setAttribute("aria-disabled","true"),t.classList.add("is-disabled")),e.icon){const n=document.createElement("span");n.className="bim-tab__icon",n.innerHTML=e.icon,t.appendChild(n)}const i=document.createElement("span");i.className="bim-tab__title",i.textContent=this.resolveTitle(e.title),t.appendChild(i),e.id===this.activeId&&t.classList.add("is-active"),this.navElement.appendChild(t)})}renderPanels(){this.contentElement.innerHTML="",this.panelMap.clear(),this.options.tabs.forEach(e=>{const t=document.createElement("div");t.className="bim-tab__panel",t.dataset.id=e.id,t.setAttribute("role","tabpanel"),t.setAttribute("aria-labelledby",`tab-${e.id}`),e.content instanceof HTMLElement?t.appendChild(e.content):typeof e.content=="string"&&(t.innerHTML=e.content),e.id===this.activeId?t.classList.add("is-active"):t.style.display="none",this.panelMap.set(e.id,t),this.contentElement.appendChild(t)})}activateTab(e){if(this.activeId===e)return;const t=this.tabMap.get(e);if(!t||t.disabled)return;this.activeId=e,this.navElement.querySelectorAll(".bim-tab__item").forEach(n=>{const s=n.dataset.id===e;n.classList.toggle("is-active",s),n.setAttribute("aria-selected",`${s}`)}),this.panelMap.forEach((n,s)=>{const a=s===e;a||this.savePanelTreeScrollTop(s,n),n.classList.toggle("is-active",a),n.style.display=a?"":"none",a&&this.restorePanelTreeScrollTop(s,n)}),this.options.onChange&&this.options.onChange(e,t)}setTheme(e){const t=this.element.style;t.setProperty("--bim-tab-bg",e.bgElevated),t.setProperty("--bim-tab-nav-bg",e.bgElevated),t.setProperty("--bim-tab-text",e.textPrimary),t.setProperty("--bim-tab-text-secondary",e.textSecondary),t.setProperty("--bim-tab-text-active",e.primary),t.setProperty("--bim-tab-border",e.borderDefault),t.setProperty("--bim-tab-hover-bg",e.componentBgHover),t.setProperty("--bim-tab-active-bg",e.componentBgActive),t.setProperty("--bim-tab-icon",e.iconDefault)}setLocales(){this.navElement.querySelectorAll(".bim-tab__item").forEach(t=>{const i=t.dataset.id;if(!i)return;const n=this.tabMap.get(i);if(!n)return;const s=t.querySelector(".bim-tab__title");s&&(s.textContent=this.resolveTitle(n.title))})}destroy(){this.navClickHandler&&(this.navElement.removeEventListener("click",this.navClickHandler),this.navClickHandler=null),this.unsubscribeLocale&&(this.unsubscribeLocale(),this.unsubscribeLocale=null),this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.panelMap.clear(),this.panelTreeScrollTopMap.clear(),this.tabMap.clear(),this.element.remove()}savePanelTreeScrollTop(e,t){const i=t.querySelector(".bim-tree-content");i&&this.panelTreeScrollTopMap.set(e,i.scrollTop)}restorePanelTreeScrollTop(e,t){const i=this.panelTreeScrollTopMap.get(e);if(i===void 0)return;const n=t.querySelector(".bim-tree-content");n&&requestAnimationFrame(()=>{n.scrollTop=i})}resolveTitle(e){try{return Se(e)||e}catch{return e}}}function oS(r,e){let t=e>>>0;for(let i=0;i<r.length;i++){const n=r.charCodeAt(i);t^=n&255,t=Math.imul(t,16777619),t^=n>>>8&255,t=Math.imul(t,16777619)}return t>>>0}async function K7(r){const e=JSON.stringify(r),t=oS(e,2166136261),i=oS(e,522970236);return`${t.toString(16).padStart(8,"0")}${i.toString(16).padStart(8,"0")}`}function lS(r){const e=new Map,t=n=>{const s=n.config.data,a=s?._modelUrl;if(a&&s?.ids?.length){let o=e.get(a);o||(o=new Set,e.set(a,o));for(const l of s.ids){const c=Number(l);Number.isFinite(c)&&o.add(c)}}for(const o of n.children||[])t(o)};t(r);const i=[];for(const[n,s]of e)s.size>0&&i.push({url:n,ids:Array.from(s)});return i}let $7=0;async function J7(r){if(!r||r.length===0)return[];const e=async(t,i)=>{const n=t.children&&t.children.length>0;let s;return t.ids?.length?s=await K7(t.ids):t.id?s=t.id:s=`node_${++$7}`,{id:s,label:t.name||"未命名",expanded:!1,checked:!0,children:n?await Promise.all(t.children.map(a=>e(a,i))):void 0,data:{...t,_modelUrl:i}}};return Promise.all(r.map(async t=>{const i=t.children&&t.children.length>0,n=t.url;return{id:n,label:t.name||"模型",expanded:!0,checked:!0,children:i?await Promise.all(t.children.map(s=>e(s,n))):void 0,data:{_modelUrl:n}}}))}class Q7 extends Fn{toolbar=null;toolbarContainer=null;container;dialog=null;constructor(e,t){super(t),this.container=e,this.init()}init(){this.toolbarContainer=document.createElement("div"),this.toolbarContainer.id="bim-construct-tree",this.container.appendChild(this.toolbarContainer),this.toolbar=new j7({container:this.toolbarContainer,showLabel:!1,direction:"column",position:"top-left",align:"vertical",expand:"up",registry:this.registry}),this.toolbar.init(),this.toolbar.addGroup("construct-tree"),this.toolbar.addButton({id:"construct-tree-btn",groupId:"construct-tree",type:"button",label:"construct-tree",icon:Tt("目录树"),onClick:()=>{this.openConstructTreeDialog()}}),this.toolbar.render()}async openConstructTreeDialog(){this.setVisible(!1);const e=this.engineComponent?.getLevelTreeData()??[],t=this.engineComponent?.getTypeTreeData()??[],i=this.engineComponent?.getMajorTreeData()??[];console.log("[ConstructTree] 原始数据 (Level):",e),console.log("[ConstructTree] 原始数据 (Type):",t),console.log("[ConstructTree] 原始数据 (Major):",i);const n=async(m,g)=>{const f=await J7(m);console.log(`[ConstructTree] 转换后数据 (${g}):`,f);const y=new Z7({data:f,checkable:!0,indent:0,enableSearch:!0,checkStrictly:!0,defaultExpandAll:!0,onNodeCheck:x=>{const _=lS(x);_.length&&(x.checkState===si.Checked?this.engineComponent?.showModel(_):this.engineComponent?.hideModels(_))},onNodeSelect:x=>{const _=lS(x);_.length&&(this.engineComponent?.unhighlightAllModels(),this.engineComponent?.highlightModel(_),this.engineComponent?.viewScaleToModel(_))},onNodeDeselect:()=>{this.engineComponent?.unhighlightAllModels()},onNodeExpand:()=>{this.dialog?.fitWidth()}});return y.init(),y},s=await n(e,"Level"),a=await n(t,"Type"),o=await n(i,"Major"),l=document.createElement("div");l.className="construct-tab__panel-content",l.appendChild(s.element);const c=document.createElement("div");c.className="construct-tab__panel-content",c.appendChild(a.element);const h=document.createElement("div");h.className="construct-tab__panel-content",h.appendChild(o.element);const d=document.createElement("div");d.className="construct-tab__container",d.style.height="100%",d.style.overflow="hidden";const p=()=>{this.engineComponent?.showAllModels(),s.checkAllNodes(!0),a.checkAllNodes(!0),o.checkAllNodes(!0)},u=new Y7({container:d,tabs:[{id:"component",title:"tab.component",content:l},{id:"type",title:"tab.type",content:c},{id:"major",title:"tab.major",content:h}],activeId:"component",onChange:()=>{this.dialog?.fitWidth()}});u.init(),p();const v=this.registry.on("menu:show-all",()=>{p()});this.dialog=this.registry.dialog.create({title:"constructTree.title",minWidth:320,height:600,content:d,position:{x:20,y:20},resizable:!1,onClose:()=>{v(),u.destroy(),s.destroy(),a.destroy(),o.destroy(),this.setVisible(!0)}}),this.dialog?.fitWidth()}refresh(){this.toolbar?.render()}destroy(){this.toolbar?.destroy(),this.toolbar=null,super.destroy()}addGroup(e,t){this.toolbar?.addGroup(e,t),this.toolbar?.render()}addButton(e){this.toolbar?.addButton(e),this.toolbar?.render()}setButtonVisibility(e,t){this.toolbar?.updateButtonVisibility(e,t)}setShowLabel(e){this.toolbar?.setShowLabel(e)}setVisible(e){this.toolbarContainer&&(this.toolbarContainer.style.visibility=e?"visible":"hidden")}setBackgroundColor(e){this.toolbar?.setBackgroundColor(e)}setColors(e){this.toolbar?.setColors(e)}}class eO{events=new Map;on(e,t){return this.events.has(e)||this.events.set(e,[]),this.events.get(e).push(t),()=>this.off(e,t)}off(e,t){const i=this.events.get(e);if(!i)return;const n=i.indexOf(t);n!==-1&&i.splice(n,1)}emit(e,t){const i=this.events.get(e);i&&i.forEach(n=>{try{n(t)}catch(s){console.error(`[EventEmitter] Error in listener for event "${e}":`,s)}})}clear(){this.events.clear()}}class rf{eventEmitter=new eO;container=null;wrapper=null;toolbar=null;dialog=null;engine3d=null;buttonGroup=null;rightKey=null;constructTree=null;measure=null;walkControl=null;sectionPlane=null;sectionAxis=null;sectionBox=null;walkPath=null;walkPlanView=null;engineInfo=null;componentDetail=null;aiChat=null;setting=null;radialToolbar=null;bottomDock=null;measureDock=null;sectionDock=null;walkDock=null;constructor(){}reset(){this.eventEmitter.clear(),this.container=null,this.wrapper=null,this.toolbar=null,this.dialog=null,this.engine3d=null,this.buttonGroup=null,this.rightKey=null,this.constructTree=null,this.measure=null,this.walkControl=null,this.sectionPlane=null,this.sectionAxis=null,this.sectionBox=null,this.walkPath=null,this.walkPlanView=null,this.engineInfo=null,this.componentDetail=null,this.aiChat=null,this.setting=null,this.radialToolbar=null,this.bottomDock=null,this.measureDock=null,this.sectionDock=null,this.walkDock=null}emit(e,t){this.eventEmitter.emit(e,t)}on(e,t){return this.eventEmitter.on(e,t)}off(e,t){this.eventEmitter.off(e,t)}clearEvents(){this.eventEmitter.clear()}}class tO{container;wrapper=null;sizeEl=null;resizeObserver=null;lastSyncedWidth=-1;lastSyncedHeight=-1;registry;dialog=null;engine=null;rightKey=null;radialToolbar=null;bottomDock=null;measureDock=null;sectionDock=null;walkDock=null;measure=null;sectionPlane=null;sectionAxis=null;sectionBox=null;walkControl=null;engineInfo=null;componentDetail=null;aiChat=null;setting=null;constructTreeBtn=null;handleWindowResize=()=>{this.updateClientSizeDisplay()};constructor(e,t){const i=typeof e=="string"?document.getElementById(e):e;if(!i)throw new Error("Container not found");this.container=i,this.registry=new rf,t?.locale&&Zt.setLocale(t.locale),t?.theme&&(t.theme==="custom"?console.warn("Custom theme should be set via setCustomTheme()."):ht.setTheme(t.theme)),this.init()}emit(e,t){this.registry.emit(e,t)}on(e,t){return this.registry.on(e,t)}setLocale(e){Zt.setLocale(e)}getLocale(){return Zt.getLocale()}setTheme(e){ht.setTheme(e)}setCustomTheme(e){ht.setCustomTheme(e)}init(){this.container.innerHTML="",this.wrapper=document.createElement("div"),this.wrapper.className="bim-engine-wrapper",this.container.appendChild(this.wrapper);const e=document.createElement("div");e.className="bim-engine-version",e.textContent="v2.5.9",this.wrapper.appendChild(e),this.sizeEl=document.createElement("div"),this.sizeEl.className="bim-engine-size",this.wrapper.appendChild(this.sizeEl),this.updateClientSizeDisplay(),this.bindSizeObserver(),this.registry.container=this.container,this.registry.wrapper=this.wrapper,this.engine=new BM(this.wrapper,this.registry),this.dialog=new mv(this.wrapper,this.registry),this.rightKey=new rv(this.wrapper,this.registry),this.bottomDock=new HM(this.wrapper,this.registry),this.registry.bottomDock=this.bottomDock,this.measureDock=new jM(this.registry),this.registry.measureDock=this.measureDock,this.measureDock.init(),this.sectionDock=new qM(this.registry),this.registry.sectionDock=this.sectionDock,this.sectionDock.init(),this.walkDock=new KM(this.registry),this.registry.walkDock=this.walkDock,this.walkDock.init(),this.radialToolbar=new zM(this.wrapper,this.registry),this.measure=new $M(this.registry),this.sectionPlane=new JM(this.registry),this.sectionAxis=new QM(this.registry),this.sectionBox=new tS(this.registry),this.walkControl=new iS(this.registry),this.walkControl.init(),this.engineInfo=new nS(this.registry),this.engineInfo.init(),this.registry.engine3d=this.engine,this.registry.dialog=this.dialog,this.registry.rightKey=this.rightKey,this.registry.radialToolbar=this.radialToolbar,this.registry.measure=this.measure,this.registry.sectionPlane=this.sectionPlane,this.registry.sectionAxis=this.sectionAxis,this.registry.sectionBox=this.sectionBox,this.registry.walkControl=this.walkControl,this.registry.engineInfo=this.engineInfo,this.componentDetail=new rS(this.registry),this.registry.componentDetail=this.componentDetail,this.componentDetail.init(),this.aiChat=new aS(this.registry),this.registry.aiChat=this.aiChat,this.aiChat.init(),this.constructTreeBtn=new Q7(this.wrapper,this.registry),this.registry.constructTree=this.constructTreeBtn,this.setting=new cr(this.registry),this.registry.setting=this.setting,this.setting.init(),this.updateTheme(ht.getTheme()),ht.subscribe(t=>{this.updateTheme(t)})}updateTheme(e){this.wrapper&&(this.wrapper.style.color=e.textPrimary)}updateClientSizeDisplay(){const e=this.container.clientWidth,t=this.container.clientHeight;this.sizeEl&&(this.sizeEl.textContent=`${e}px x ${t}px`),this.syncEngineSize(e,t)}syncEngineSize(e,t){e<=0||t<=0||e===this.lastSyncedWidth&&t===this.lastSyncedHeight||(this.lastSyncedWidth=e,this.lastSyncedHeight=t,this.engine?.getEngineComponent()?.resize(e,t))}bindSizeObserver(){if(typeof ResizeObserver<"u"){this.resizeObserver=new ResizeObserver(()=>{this.updateClientSizeDisplay()}),this.resizeObserver.observe(this.container);return}window.addEventListener("resize",this.handleWindowResize)}unbindSizeObserver(){if(this.resizeObserver){this.resizeObserver.disconnect(),this.resizeObserver=null;return}window.removeEventListener("resize",this.handleWindowResize)}destroy(){this.unbindSizeObserver(),this.radialToolbar?.destroy(),this.measureDock?.destroy(),this.sectionDock?.destroy(),this.walkDock?.destroy(),this.bottomDock?.destroy(),this.engine?.destroy(),this.dialog?.destroy(),this.rightKey?.destroy(),this.measure?.destroy(),this.sectionPlane?.destroy(),this.sectionAxis?.destroy(),this.sectionBox?.destroy(),this.walkControl?.destroy(),this.constructTreeBtn?.destroy(),this.aiChat?.destroy(),this.setting?.destroy(),this.sizeEl=null,this.lastSyncedWidth=-1,this.lastSyncedHeight=-1,this.container.innerHTML="",this.registry.reset()}}class iO{container;wrapper=null;sizeEl=null;resizeObserver=null;lastSyncedWidth=-1;lastSyncedHeight=-1;unsubscribeTheme=null;registry;dialog=null;engine=null;rightKey=null;radialToolbar=null;bottomDock=null;measureDock=null;sectionDock=null;walkDock=null;measure=null;sectionPlane=null;sectionAxis=null;sectionBox=null;walkControl=null;engineInfo=null;componentDetail=null;aiChat=null;setting=null;handleWindowResize=()=>{this.updateClientSizeDisplay()};constructor(e,t){const i=typeof e=="string"?document.getElementById(e):e;if(!i)throw new Error("Container not found");this.container=i,this.registry=new rf,t?.locale&&Zt.setLocale(t.locale),t?.theme&&(t.theme==="custom"?console.warn("Custom theme should be set via setCustomTheme()."):ht.setTheme(t.theme)),this.init()}emit(e,t){this.registry.emit(e,t)}on(e,t){return this.registry.on(e,t)}setLocale(e){Zt.setLocale(e)}getLocale(){return Zt.getLocale()}setTheme(e){ht.setTheme(e)}setCustomTheme(e){ht.setCustomTheme(e)}init(){this.container.innerHTML="",this.wrapper=document.createElement("div"),this.wrapper.className="bim-engine-wrapper",this.container.appendChild(this.wrapper);const e=document.createElement("div");e.className="bim-engine-version",e.textContent="v2.5.9",this.wrapper.appendChild(e),this.sizeEl=document.createElement("div"),this.sizeEl.className="bim-engine-size",this.wrapper.appendChild(this.sizeEl),this.updateClientSizeDisplay(),this.bindSizeObserver(),this.registry.container=this.container,this.registry.wrapper=this.wrapper,this.engine=new BM(this.wrapper,this.registry),this.dialog=new mv(this.wrapper,this.registry),this.rightKey=new rv(this.wrapper,this.registry),this.bottomDock=new HM(this.wrapper,this.registry),this.registry.bottomDock=this.bottomDock,this.registry.engine3d=this.engine,this.registry.dialog=this.dialog,this.registry.rightKey=this.rightKey,this.measureDock=new jM(this.registry),this.registry.measureDock=this.measureDock,this.measureDock.init(),this.sectionDock=new qM(this.registry),this.registry.sectionDock=this.sectionDock,this.sectionDock.init(),this.walkDock=new KM(this.registry),this.registry.walkDock=this.walkDock,this.walkDock.init(),this.radialToolbar=new zM(this.wrapper,this.registry),this.measure=new $M(this.registry),this.sectionPlane=new JM(this.registry),this.sectionAxis=new QM(this.registry),this.sectionBox=new tS(this.registry),this.walkControl=new iS(this.registry),this.walkControl.init(),this.engineInfo=new nS(this.registry),this.engineInfo.init(),this.registry.radialToolbar=this.radialToolbar,this.registry.measure=this.measure,this.registry.sectionPlane=this.sectionPlane,this.registry.sectionAxis=this.sectionAxis,this.registry.sectionBox=this.sectionBox,this.registry.walkControl=this.walkControl,this.registry.engineInfo=this.engineInfo,this.componentDetail=new rS(this.registry),this.registry.componentDetail=this.componentDetail,this.componentDetail.init(),this.aiChat=new aS(this.registry),this.registry.aiChat=this.aiChat,this.aiChat.init(),this.setting=new cr(this.registry),this.registry.setting=this.setting,this.setting.init(),this.updateTheme(ht.getTheme()),this.unsubscribeTheme=ht.subscribe(t=>{this.updateTheme(t)})}updateTheme(e){this.wrapper&&(this.wrapper.style.color=e.textPrimary)}updateClientSizeDisplay(){const e=this.container.clientWidth,t=this.container.clientHeight;this.sizeEl&&(this.sizeEl.textContent=`${e}px x ${t}px`),this.syncEngineSize(e,t)}syncEngineSize(e,t){e<=0||t<=0||e===this.lastSyncedWidth&&t===this.lastSyncedHeight||(this.lastSyncedWidth=e,this.lastSyncedHeight=t,this.engine?.getEngineComponent()?.resize(e,t))}bindSizeObserver(){if(typeof ResizeObserver<"u"){this.resizeObserver=new ResizeObserver(()=>{this.updateClientSizeDisplay()}),this.resizeObserver.observe(this.container);return}window.addEventListener("resize",this.handleWindowResize)}unbindSizeObserver(){if(this.resizeObserver){this.resizeObserver.disconnect(),this.resizeObserver=null;return}window.removeEventListener("resize",this.handleWindowResize)}destroy(){this.unbindSizeObserver(),this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.radialToolbar?.destroy(),this.measureDock?.destroy(),this.sectionDock?.destroy(),this.walkDock?.destroy(),this.bottomDock?.destroy(),this.engine?.destroy(),this.dialog?.destroy(),this.rightKey?.destroy(),this.measure?.destroy(),this.sectionPlane?.destroy(),this.sectionAxis?.destroy(),this.sectionBox?.destroy(),this.walkControl?.destroy(),this.aiChat?.destroy(),this.setting?.destroy(),this.sizeEl=null,this.lastSyncedWidth=-1,this.lastSyncedHeight=-1,this.container.innerHTML="",this.registry.reset()}}class nO{engine=null;registry;container;containerId;options;_isInitialized=!1;_isDestroyed=!1;unsubscribeTheme=null;constructor(e,t){this.registry=t,this.container=e.container,this.container.id?this.containerId=this.container.id:(this.containerId=`engine2d-container-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,this.container.id=this.containerId),this.options={backgroundColor:e.backgroundColor??1710618,gridEnabled:e.gridEnabled??!0,axesEnabled:e.axesEnabled??!0,selectionColor:e.selectionColor,highlightColor:e.highlightColor,enablePerformanceMonitoring:e.enablePerformanceMonitoring??!0}}init(){if(this._isInitialized){console.warn("[Engine2d] Engine already initialized.");return}if(this._isDestroyed){console.error("[Engine2d] Cannot initialize destroyed engine.");return}try{const e={containerId:this.containerId,backgroundColor:this.options.backgroundColor,gridEnabled:this.options.gridEnabled,axesEnabled:this.options.axesEnabled};if(this.options.selectionColor!==void 0&&(e.selectionColor=this.options.selectionColor),this.options.highlightColor!==void 0&&(e.highlightColor=this.options.highlightColor),this.options.enablePerformanceMonitoring!==void 0&&(e.enablePerformanceMonitoring=this.options.enablePerformanceMonitoring),console.log("[Engine2d] 引擎配置信息:",e),this.engine=_7(e),!this.engine)throw new Error("Failed to create 2D engine instance");this._isInitialized=!0,this.unsubscribeTheme=ht.subscribe(t=>{this.setTheme(t)}),this.setTheme(ht.getTheme()),this.engine.events&&(this.engine.events.on("entity-click",t=>{console.log("[Engine2d] 实体点击:",t),this.registry.emit("engine2d:entity-clicked",{data:t})}),this.engine.events.on("layer-visibility-changed",t=>{console.log("[Engine2d] 图层可见性变更:",t),this.registry.emit("engine2d:layer-changed",{data:t})}))}catch(e){throw console.error("[Engine2d] Failed to initialize 2D engine:",e),this._isInitialized=!1,e}}setTheme(e){}setLocales(){}isInitialized(){return this._isInitialized}async loadDrawing(e,t){if(!this._isInitialized||!this.engine){console.error("[Engine2d] Engine not initialized. Please call init() first.");return}if(!e){console.error("[Engine2d] Drawing URL is required.");return}try{console.log("[Engine2d] 开始加载图纸:",e),await this.engine.loadModel(e,t),console.log("[Engine2d] 图纸加载完成:",e),this.registry.emit("engine2d:drawing-loaded",{url:e})}catch(i){throw console.error("[Engine2d] 图纸加载失败:",i),i}}getLayers(){if(!this._isInitialized||!this.engine)return[];try{return this.engine.getLayers?.()??[]}catch(e){return console.warn("[Engine2d] Failed to get layers:",e),[]}}setLayerVisible(e,t){if(!this._isInitialized||!this.engine){console.warn("[Engine2d] Engine not initialized.");return}try{this.engine.setLayerVisible?.(e,t)}catch(i){console.warn("[Engine2d] Failed to set layer visibility:",i)}}resetView(){if(!(!this._isInitialized||!this.engine))try{this.engine.resetView?.()}catch(e){console.warn("[Engine2d] Failed to reset view:",e)}}fitToView(){if(!(!this._isInitialized||!this.engine))try{this.engine.fitToView?.()}catch(e){console.warn("[Engine2d] Failed to fit to view:",e)}}setZoom(e){!this._isInitialized||!this.engine||this.engine.setZoom?.(e)}getZoom(){return!this._isInitialized||!this.engine?1:this.engine.getZoom?.()??1}setBackgroundColor(e){!this._isInitialized||!this.engine||this.engine.setBackgroundColor?.(e)}clearScene(){!this._isInitialized||!this.engine||this.engine.clearScene?.()}resize(){!this._isInitialized||!this.engine||this.engine.resize?.()}onRawEvent(e,t){this.engine?.events?.on(e,t)}offRawEvent(e,t){this.engine?.events?.off(e,t)}destroy(){if(!this._isDestroyed){if(this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.engine){try{this.engine.dispose?.()}catch(e){console.warn("[Engine2d] Error during dispose:",e)}this.engine=null}this.container.innerHTML="",this._isDestroyed=!0,this._isInitialized=!1}}}class sO{container;registry;engineComponent=null;constructor(e,t){const i=typeof e=="string"?document.getElementById(e):e;if(!i)throw new Error("Container not found");this.container=i,this.registry=new rf,t?.locale&&Zt.setLocale(t.locale),t?.theme&&t.theme!=="custom"&&ht.setTheme(t.theme),this.engineComponent=new nO({container:this.container,backgroundColor:t?.backgroundColor,gridEnabled:t?.gridEnabled,axesEnabled:t?.axesEnabled,selectionColor:t?.selectionColor,highlightColor:t?.highlightColor,enablePerformanceMonitoring:t?.enablePerformanceMonitoring},this.registry),this.engineComponent.init()}async loadDrawing(e,t){return this.engineComponent?.loadDrawing(e,t)}getLayers(){return this.engineComponent?.getLayers()??[]}setLayerVisible(e,t){this.engineComponent?.setLayerVisible(e,t)}resetView(){this.engineComponent?.resetView()}fitToView(){this.engineComponent?.fitToView()}setZoom(e){this.engineComponent?.setZoom(e)}getZoom(){return this.engineComponent?.getZoom()??1}setTheme(e){ht.setTheme(e)}on(e,t){return this.registry.on(e,t)}off(e,t){this.registry.off(e,t)}onRawEvent(e,t){this.engineComponent?.onRawEvent(e,t)}offRawEvent(e,t){this.engineComponent?.offRawEvent(e,t)}destroy(){this.engineComponent?.destroy(),this.engineComponent=null,this.registry.reset()}}class rO{engine=null;registry;container;containerId;options;_isInitialized=!1;_isDestroyed=!1;unsubscribeTheme=null;constructor(e,t){this.registry=t,this.container=e.container,this.container.id?this.containerId=this.container.id:(this.containerId=`engine720-container-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,this.container.id=this.containerId),this.options={fov:e.fov??75,enableZoom:e.enableZoom??!0,enableRotate:e.enableRotate??!0,sphereRadius:e.sphereRadius??500,rotateSpeed:e.rotateSpeed,zoomSpeed:e.zoomSpeed,enableDamping:e.enableDamping,dampingFactor:e.dampingFactor,minFov:e.minFov,maxFov:e.maxFov}}init(){if(this._isInitialized){console.warn("[Engine720] Engine already initialized.");return}if(this._isDestroyed){console.error("[Engine720] Cannot initialize destroyed engine.");return}try{const e={containerId:this.containerId,fov:this.options.fov,enableZoom:this.options.enableZoom,enableRotate:this.options.enableRotate,sphereRadius:this.options.sphereRadius};if(this.options.rotateSpeed!==void 0&&(e.rotateSpeed=this.options.rotateSpeed),this.options.zoomSpeed!==void 0&&(e.zoomSpeed=this.options.zoomSpeed),this.options.enableDamping!==void 0&&(e.enableDamping=this.options.enableDamping),this.options.dampingFactor!==void 0&&(e.dampingFactor=this.options.dampingFactor),this.options.minFov!==void 0&&(e.minFov=this.options.minFov),this.options.maxFov!==void 0&&(e.maxFov=this.options.maxFov),console.log("[Engine720] 引擎配置信息:",e),this.engine=b7(e),!this.engine)throw new Error("Failed to create 720 engine instance");this._isInitialized=!0,this.unsubscribeTheme=ht.subscribe(t=>{this.setTheme(t)}),this.setTheme(ht.getTheme()),this.engine.events&&(this.engine.events.on("panorama-loaded",t=>{console.log("[Engine720] 全景加载完成:",t),this.registry.emit("engine720:panorama-loaded",{data:t})}),this.engine.events.on("panorama-load-error",t=>{console.error("[Engine720] 全景加载失败:",t),this.registry.emit("engine720:load-error",{data:t})}),this.engine.events.on("annotation-click",t=>{console.log("[Engine720] 标注点击:",t),this.registry.emit("engine720:annotation-click",{data:t})}),this.engine.events.on("view-angle-changed",t=>{this.registry.emit("engine720:view-changed",{data:t})}))}catch(e){throw console.error("[Engine720] Failed to initialize 720 engine:",e),this._isInitialized=!1,e}}setTheme(e){!this._isInitialized||this.engine}setLocales(){}isInitialized(){return this._isInitialized}async loadPanorama(e,t){if(!this._isInitialized||!this.engine){console.error("[Engine720] Engine not initialized. Please call init() first.");return}if(!e){console.error("[Engine720] Panorama URL is required.");return}try{console.log("[Engine720] 开始加载全景图:",e),await this.engine.loadPanorama(e),console.log("[Engine720] 全景图加载完成:",e)}catch(i){throw console.error("[Engine720] 全景图加载失败:",i),i}}async preloadPanoramas(e){if(!(!this._isInitialized||!this.engine))try{await this.engine.preloadPanoramas?.(e)}catch(t){console.warn("[Engine720] Failed to preload panoramas:",t)}}setFov(e){!this._isInitialized||!this.engine||this.engine.setFov?.(e)}getFov(){return!this._isInitialized||!this.engine?75:this.engine.getFov?.()??75}lookAt(e,t,i){!this._isInitialized||!this.engine||this.engine.lookAt?.(e,t,i)}resetView(){if(!(!this._isInitialized||!this.engine))try{this.engine.lookAt?.(0,0,!0),this.engine.setFov?.(75)}catch(e){console.warn("[Engine720] Failed to reset view:",e)}}pauseRendering(){!this._isInitialized||!this.engine||this.engine.pauseRendering?.()}resumeRendering(){!this._isInitialized||!this.engine||this.engine.resumeRendering?.()}resize(e,t){!this._isInitialized||!this.engine||this.engine.resize?.(e,t)}onRawEvent(e,t){this.engine?.events?.on(e,t)}offRawEvent(e,t){this.engine?.events?.off(e,t)}destroy(){if(!this._isDestroyed){if(this.unsubscribeTheme&&(this.unsubscribeTheme(),this.unsubscribeTheme=null),this.engine){try{this.engine.dispose?.()}catch(e){console.warn("[Engine720] Error during dispose:",e)}this.engine=null}this.container.innerHTML="",this._isDestroyed=!0,this._isInitialized=!1}}}class aO{container;registry;engineComponent=null;constructor(e,t){const i=typeof e=="string"?document.getElementById(e):e;if(!i)throw new Error("Container not found");this.container=i,this.registry=new rf,t?.locale&&Zt.setLocale(t.locale),t?.theme&&t.theme!=="custom"&&ht.setTheme(t.theme),this.engineComponent=new rO({container:this.container,fov:t?.fov,enableZoom:t?.enableZoom,enableRotate:t?.enableRotate,sphereRadius:t?.sphereRadius,rotateSpeed:t?.rotateSpeed,zoomSpeed:t?.zoomSpeed,enableDamping:t?.enableDamping,dampingFactor:t?.dampingFactor,minFov:t?.minFov,maxFov:t?.maxFov},this.registry),this.engineComponent.init()}async loadPanorama(e,t){return this.engineComponent?.loadPanorama(e,t)}async preloadPanoramas(e){return this.engineComponent?.preloadPanoramas(e)}setFov(e){this.engineComponent?.setFov(e)}getFov(){return this.engineComponent?.getFov()??75}lookAt(e,t,i){this.engineComponent?.lookAt(e,t,i)}resetView(){this.engineComponent?.resetView()}setTheme(e){ht.setTheme(e)}on(e,t){return this.registry.on(e,t)}off(e,t){this.registry.off(e,t)}onRawEvent(e,t){this.engineComponent?.onRawEvent(e,t)}offRawEvent(e,t){this.engineComponent?.offRawEvent(e,t)}destroy(){this.engineComponent?.destroy(),this.engineComponent=null,this.registry.reset()}}const oO=Object.freeze(Object.defineProperty({__proto__:null,default:`# BIM引擎AI助手 - 需求分析与步骤规划专家\r
|
|
9886
9886
|
\r
|
|
9887
9887
|
## 角色定位\r
|
|
9888
9888
|
\r
|