iflow-engine-base-3d 3.12.31 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- import { E as a } from "./chunks/engine-3d-D9B5Jb2H.js";
2
- import { M as d } from "./chunks/engine-3d-D9B5Jb2H.js";
1
+ import { E as a } from "./chunks/engine-3d-DP58s1mb.js";
2
+ import { M as d } from "./chunks/engine-3d-DP58s1mb.js";
3
3
  import { s, a as t, b as l } from "./chunks/sdk-assets-DHhjv3WO.js";
4
4
  async function r(e) {
5
5
  e?.assetFiles ? await s(e.assetFiles) : e?.assetFile ? await t(e.assetFile) : e?.assetBaseUrl && await s(null), e?.assetBaseUrl && l(e.assetBaseUrl);
@@ -6597,7 +6597,7 @@ void main() {
6597
6597
  #include <premultiplied_alpha_fragment>
6598
6598
 
6599
6599
  }
6600
- `};class Zy extends $t{constructor(A){super({type:"LineMaterial",uniforms:oi.clone(Zi.line.uniforms),vertexShader:Zi.line.vertexShader,fragmentShader:Zi.line.fragmentShader,clipping:!0}),this.isLineMaterial=!0,this.setValues(A)}get color(){return this.uniforms.diffuse.value}set color(A){this.uniforms.diffuse.value=A}get worldUnits(){return"WORLD_UNITS"in this.defines}set worldUnits(A){A===!0!==this.worldUnits&&(this.needsUpdate=!0),A===!0?this.defines.WORLD_UNITS="":delete this.defines.WORLD_UNITS}get linewidth(){return this.uniforms.linewidth.value}set linewidth(A){this.uniforms.linewidth&&(this.uniforms.linewidth.value=A)}get dashed(){return"USE_DASH"in this.defines}set dashed(A){A===!0!==this.dashed&&(this.needsUpdate=!0),A===!0?this.defines.USE_DASH="":delete this.defines.USE_DASH}get dashScale(){return this.uniforms.dashScale.value}set dashScale(A){this.uniforms.dashScale.value=A}get dashSize(){return this.uniforms.dashSize.value}set dashSize(A){this.uniforms.dashSize.value=A}get dashOffset(){return this.uniforms.dashOffset.value}set dashOffset(A){this.uniforms.dashOffset.value=A}get gapSize(){return this.uniforms.gapSize.value}set gapSize(A){this.uniforms.gapSize.value=A}get opacity(){return this.uniforms.opacity.value}set opacity(A){this.uniforms&&(this.uniforms.opacity.value=A)}get resolution(){return this.uniforms.resolution.value}set resolution(A){this.uniforms.resolution.value.copy(A)}get alphaToCoverage(){return"USE_ALPHA_TO_COVERAGE"in this.defines}set alphaToCoverage(A){this.defines&&(A===!0!==this.alphaToCoverage&&(this.needsUpdate=!0),A===!0?this.defines.USE_ALPHA_TO_COVERAGE="":delete this.defines.USE_ALPHA_TO_COVERAGE)}}const Ny=new Ct,wW=new S,uW=new S,Qi=new Ct,di=new Ct,wn=new Ct,Uy=new S,Xy=new RA,fi=new vi,mW=new S,hQ=new vA,CQ=new be,un=new Ct;let mn,ca;function PW(s,A,t){return un.set(0,0,-A,1).applyMatrix4(s.projectionMatrix),un.multiplyScalar(1/un.w),un.x=ca/t.width,un.y=ca/t.height,un.applyMatrix4(s.projectionMatrixInverse),un.multiplyScalar(1/un.w),Math.abs(Math.max(un.x,un.y))}function U8(s,A){const t=s.matrixWorld,e=s.geometry,i=e.attributes.instanceStart,n=e.attributes.instanceEnd,o=Math.min(e.instanceCount,i.count);for(let g=0,a=o;g<a;g++){fi.start.fromBufferAttribute(i,g),fi.end.fromBufferAttribute(n,g),fi.applyMatrix4(t);const r=new S,I=new S;mn.distanceSqToSegment(fi.start,fi.end,I,r),I.distanceTo(r)<ca*.5&&A.push({point:I,pointOnLine:r,distance:mn.origin.distanceTo(I),object:s,face:null,faceIndex:g,uv:null,uv1:null})}}function X8(s,A,t){const e=A.projectionMatrix,n=s.material.resolution,o=s.matrixWorld,g=s.geometry,a=g.attributes.instanceStart,r=g.attributes.instanceEnd,I=Math.min(g.instanceCount,a.count),l=-A.near;mn.at(1,wn),wn.w=1,wn.applyMatrix4(A.matrixWorldInverse),wn.applyMatrix4(e),wn.multiplyScalar(1/wn.w),wn.x*=n.x/2,wn.y*=n.y/2,wn.z=0,Uy.copy(wn),Xy.multiplyMatrices(A.matrixWorldInverse,o);for(let h=0,B=I;h<B;h++){if(Qi.fromBufferAttribute(a,h),di.fromBufferAttribute(r,h),Qi.w=1,di.w=1,Qi.applyMatrix4(Xy),di.applyMatrix4(Xy),Qi.z>l&&di.z>l)continue;if(Qi.z>l){const M=Qi.z-di.z,y=(Qi.z-l)/M;Qi.lerp(di,y)}else if(di.z>l){const M=di.z-Qi.z,y=(di.z-l)/M;di.lerp(Qi,y)}Qi.applyMatrix4(e),di.applyMatrix4(e),Qi.multiplyScalar(1/Qi.w),di.multiplyScalar(1/di.w),Qi.x*=n.x/2,Qi.y*=n.y/2,di.x*=n.x/2,di.y*=n.y/2,fi.start.copy(Qi),fi.start.z=0,fi.end.copy(di),fi.end.z=0;const c=fi.closestPointToPointParameter(Uy,!0);fi.at(c,mW);const Q=rt.lerp(Qi.z,di.z,c),C=Q>=-1&&Q<=1,d=Uy.distanceTo(mW)<ca*.5;if(C&&d){fi.start.fromBufferAttribute(a,h),fi.end.fromBufferAttribute(r,h),fi.start.applyMatrix4(o),fi.end.applyMatrix4(o);const M=new S,y=new S;mn.distanceSqToSegment(fi.start,fi.end,y,M),t.push({point:y,pointOnLine:M,distance:mn.origin.distanceTo(y),object:s,face:null,faceIndex:h,uv:null,uv1:null})}}}class J8 extends bA{constructor(A=new DW,t=new Zy({color:Math.random()*16777215})){super(A,t),this.isLineSegments2=!0,this.type="LineSegments2"}computeLineDistances(){const A=this.geometry,t=A.attributes.instanceStart,e=A.attributes.instanceEnd,i=new Float32Array(2*t.count);for(let o=0,g=0,a=t.count;o<a;o++,g+=2)wW.fromBufferAttribute(t,o),uW.fromBufferAttribute(e,o),i[g]=g===0?0:i[g-1],i[g+1]=i[g]+wW.distanceTo(uW);const n=new JC(i,2,1);return A.setAttribute("instanceDistanceStart",new ji(n,1,0)),A.setAttribute("instanceDistanceEnd",new ji(n,1,1)),this}raycast(A,t){const e=this.material.worldUnits,i=A.camera;if(i===null&&!e&&console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.'),e===!1&&(this.material.resolution.x===0||this.material.resolution.y===0))return;const n=A.params.Line2!==void 0&&A.params.Line2.threshold||0;mn=A.ray;const o=this.matrixWorld,g=this.geometry,a=this.material;ca=a.linewidth+n,g.boundingSphere===null&&g.computeBoundingSphere(),CQ.copy(g.boundingSphere).applyMatrix4(o);let r;if(e)r=ca*.5;else{const l=Math.max(i.near,CQ.distanceToPoint(mn.origin));r=PW(i,l,a.resolution)}if(CQ.radius+=r,mn.intersectsSphere(CQ)===!1)return;g.boundingBox===null&&g.computeBoundingBox(),hQ.copy(g.boundingBox).applyMatrix4(o);let I;if(e)I=ca*.5;else{const l=Math.max(i.near,hQ.distanceToPoint(mn.origin));I=PW(i,l,a.resolution)}hQ.expandByScalar(I),mn.intersectsBox(hQ)!==!1&&(e?U8(this,t):X8(this,i,t))}onBeforeRender(A){const t=this.material.uniforms;t&&t.resolution&&(A.getViewport(Ny),this.material.uniforms.resolution.value.set(Ny.z,Ny.w))}}class SW extends DW{constructor(){super(),this.isLineGeometry=!0,this.type="LineGeometry"}setPositions(A){const t=A.length-3,e=new Float32Array(2*t);for(let i=0;i<t;i+=3)e[2*i]=A[i],e[2*i+1]=A[i+1],e[2*i+2]=A[i+2],e[2*i+3]=A[i+3],e[2*i+4]=A[i+4],e[2*i+5]=A[i+5];return super.setPositions(e),this}setColors(A){const t=A.length-3,e=new Float32Array(2*t);for(let i=0;i<t;i+=3)e[2*i]=A[i],e[2*i+1]=A[i+1],e[2*i+2]=A[i+2],e[2*i+3]=A[i+3],e[2*i+4]=A[i+4],e[2*i+5]=A[i+5];return super.setColors(e),this}setFromPoints(A){const t=A.length-1,e=new Float32Array(6*t);for(let i=0;i<t;i++)e[6*i]=A[i].x,e[6*i+1]=A[i].y,e[6*i+2]=A[i].z||0,e[6*i+3]=A[i+1].x,e[6*i+4]=A[i+1].y,e[6*i+5]=A[i+1].z||0;return super.setPositions(e),this}fromLine(A){const t=A.geometry;return this.setPositions(t.attributes.position.array),this}}class x8 extends J8{constructor(A=new SW,t=new Zy({color:Math.random()*16777215})){super(A,t),this.isLine2=!0,this.type="Line2"}}const EQ={lineType:"bezier",lineColor:"#22c55e",previewColor:"#f59e0b",pointColor:"#ffffff",selectedPointColor:"#f59e0b",pointSize:.34,lineWidth:4,sampleCount:64,roundedRadius:1,historyLimit:100},k8={bezier:"贝塞尔曲线",straight:"直线",rounded:"圆角直线"},V8={bezier:"∿",straight:"╱",rounded:"⌁"};class H8{type="path-draw";engine;root=new Ot;pointsGroup=new Ot;points=[];history=[];options={...EQ};lineType=EQ.lineType;roundedRadius=EQ.roundedRadius;line=null;previewLine=null;previewMarker=null;transformControl=null;transformHelper=null;selectedPointId=null;panel=null;pointsList=null;statusElement=null;addButton=null;completeButton=null;radiusInput=null;mode="editing";active=!1;closing=!1;transformDragging=!1;suppressNextCanvasClick=!1;controlsEnabledBeforeDrag=!0;pointSequence=0;pathId="";onKeyDown;constructor(A){this.engine=A,this.root.name="PathDrawRoot",this.pointsGroup.name="PathDrawPoints",this.root.add(this.pointsGroup),this.onKeyDown=this.handleKeyDown.bind(this)}open(A={}){this.active&&this.close(),this.options={...EQ,...A},this.pathId=A.id??`path-${Date.now()}`,this.lineType=this.options.lineType,this.roundedRadius=Math.max(0,this.options.roundedRadius),this.active=!0,this.mode="editing",this.engine.scene?.add(this.root),this.ensureTransformControl(),this.createPanel(),this.activateBehavior(),window.addEventListener("keydown",this.onKeyDown,!0),this.refreshAll()}startAddPoint(){return!this.active||this.transformDragging?!1:(this.mode="picking",this.clearSelection(),this.setStatus("请在模型上拾取位置"),this.addButton&&(this.addButton.dataset.active="true"),!0)}setLineType(A){!this.active||this.lineType===A||(this.saveHistory(),this.lineType=A,this.refreshAll(),this.emitChange())}undo(){const A=this.history.pop();return A?(this.restoreSnapshot(A),this.mode="editing",this.clearPreview(),this.refreshAll(),this.emitChange(),!0):!1}clear(){this.points.length!==0&&(this.saveHistory(),this.clearPointRecords(),this.mode="editing",this.clearPreview(),this.refreshAll(),this.emitChange())}getPathData(){if(this.points.length<2)return null;const A=this.buildSamplePoints(this.points.map(t=>t.position));return{version:1,id:this.pathId,lineType:this.lineType,coordinateSystem:"world",closed:!1,roundedRadius:this.roundedRadius,points:this.points.map((t,e)=>({id:t.id,order:e,role:this.getPointRole(e),position:this.toPlainVector(t.position)})),samples:A.map(t=>this.toPlainVector(t)),length:this.calculateLength(A)}}complete(){const A=this.getPathData();if(!A)return null;try{this.options.onComplete?.(A)}finally{this.close()}return A}isActive(){return this.active}close(){this.closeInternal(!0)}closeInternal(A){!this.active&&!this.panel||this.closing||(this.closing=!0,this.active=!1,window.removeEventListener("keydown",this.onKeyDown,!0),this.clearPreview(),this.clearPointRecords(),this.disposeLine("line"),this.detachTransformControl(),this.panel?.remove(),this.panel=null,this.pointsList=null,this.statusElement=null,this.addButton=null,this.completeButton=null,this.radiusInput=null,this.history.length=0,this.selectedPointId=null,this.root.parent?.remove(this.root),A&&this.restoreDefaultBehavior(),this.closing=!1)}dispose(){this.closeInternal(!1),this.transformControl?.dispose(),this.transformControl=null,this.transformHelper=null}update(){!this.active||!this.engine.camera||(this.transformControl&&this.transformControl.camera!==this.engine.camera&&(this.transformControl.camera=this.engine.camera),this.syncLineResolution(this.line),this.syncLineResolution(this.previewLine))}disActive(){this.closing||this.closeInternal(!1)}handleMouseMove(A){if(!this.active||this.mode!=="picking")return;const t=this.getCatchPoint(A?.catch);if(!t){this.clearPreview();return}this.updatePreview(t)}handleMouseClick(A){if(!this.active)return;if(this.suppressNextCanvasClick){this.suppressNextCanvasClick=!1;return}if(this.mode==="picking"){const e=this.getCatchPoint(A?.catch);if(!e)return;this.saveHistory();const i=this.createPointRecord(e);this.points.push(i),this.pointsGroup.add(i.mesh),this.mode="editing",this.clearPreview(),this.selectPoint(i.id),this.refreshAll(),this.emitChange();return}const t=this.pickPointMesh(A);t?this.selectPoint(t.userData.pathDrawPointId):this.clearSelection()}handelKeyEscDown(){if(this.mode==="picking"){this.mode="editing",this.clearPreview(),this.refreshPanel();return}this.clearSelection()}activateBehavior(){const A=this.engine.handelBehaved;A?.init?.(this,{showCatch:!0}),A?.active?.()}restoreDefaultBehavior(){const A=this.engine.handelBehaved;A?.self===this&&(A.disActive?.(),this.engine.interactionModule?.init?.(),this.engine.interactionModule?.active?.(),this.engine.catchSvg&&(this.engine.catchSvg.innerHTML=""))}ensureTransformControl(){if(this.transformControl){this.transformHelper&&!this.transformHelper.parent&&this.engine.scene?.add(this.transformHelper);return}!this.engine.camera||!this.engine.renderer||!this.engine.scene||(this.transformControl=new ql(this.engine.camera,this.engine.renderer.domElement),this.transformControl.setMode("translate"),this.transformControl.size=.72,this.transformControl.addEventListener("dragging-changed",A=>{if(this.transformDragging=!!A.value,this.transformDragging){this.saveHistory(),this.controlsEnabledBeforeDrag=this.engine.controls?.enabled!==!1,this.engine.controls&&(this.engine.controls.enabled=!1);return}this.engine.controls&&(this.engine.controls.enabled=this.controlsEnabledBeforeDrag),this.suppressNextCanvasClick=!0,requestAnimationFrame(()=>{this.suppressNextCanvasClick=!1}),this.refreshAll(),this.emitChange()}),this.transformControl.addEventListener("objectChange",()=>{const A=this.getSelectedPoint();A&&(A.position.copy(A.mesh.position),this.refreshLine(),this.refreshPanel(),this.emitChange())}),this.transformHelper=this.transformControl.getHelper(),this.transformHelper.visible=!1,this.engine.scene.add(this.transformHelper))}detachTransformControl(){this.transformControl?.detach(),this.transformHelper&&(this.transformHelper.visible=!1,this.transformHelper.parent?.remove(this.transformHelper))}createPointRecord(A,t){const e=new an(this.options.pointSize,18,12),i=new Kt({color:this.options.pointColor,depthTest:!1,depthWrite:!1}),n=new bA(e,i),o=t??`path-point-${++this.pointSequence}`;return n.name=o,n.position.copy(A),n.renderOrder=1002,n.userData.pathDrawPointId=o,{id:o,position:A.clone(),mesh:n}}selectPoint(A){const t=this.points.find(e=>e.id===A);!t||!this.transformControl||!this.transformHelper||(this.selectedPointId=A,this.points.forEach(e=>e.mesh.material.color.set(e.id===A?this.options.selectedPointColor:this.options.pointColor)),this.transformControl.attach(t.mesh),this.transformHelper.visible=!0,this.refreshPanel())}clearSelection(){this.selectedPointId=null,this.points.forEach(A=>A.mesh.material.color.set(this.options.pointColor)),this.transformControl?.detach(),this.transformHelper&&(this.transformHelper.visible=!1),this.refreshPanel()}getSelectedPoint(){return this.points.find(A=>A.id===this.selectedPointId)??null}getCatchPoint(A){return A?.point instanceof S?A.point.clone():null}pickPointMesh(A){if(!this.engine.camera||!this.engine.renderer)return null;const t=this.engine.renderer.domElement.clientWidth,e=this.engine.renderer.domElement.clientHeight;if(!t||!e)return null;const i=new MA(A.offsetX/t*2-1,-(A.offsetY/e)*2+1),n=new De;return n.setFromCamera(i,this.engine.camera),n.intersectObjects(this.pointsGroup.children,!1)[0]?.object??null}updatePreview(A){this.previewMarker||(this.previewMarker=new bA(new an(this.options.pointSize*.72,14,10),new Kt({color:this.options.previewColor,depthTest:!1,depthWrite:!1})),this.previewMarker.renderOrder=1003,this.root.add(this.previewMarker)),this.previewMarker.position.copy(A),this.previewMarker.visible=!0;const t=[...this.points.map(i=>i.position),A];if(t.length<2){this.disposeLine("previewLine");return}const e=this.buildSamplePoints(t);this.previewLine=this.updateLineObject(this.previewLine,e,!0)}clearPreview(){this.disposeLine("previewLine"),this.previewMarker&&(this.previewMarker.geometry.dispose(),this.previewMarker.material.dispose(),this.previewMarker.parent?.remove(this.previewMarker),this.previewMarker=null)}refreshAll(){this.refreshLine(),this.refreshPanel(),this.requestRender()}refreshLine(){if(this.points.length<2){this.disposeLine("line");return}const A=this.buildSamplePoints(this.points.map(t=>t.position));this.line=this.updateLineObject(this.line,A,!1)}updateLineObject(A,t,e){const i=new SW;if(i.setPositions(t.flatMap(g=>[g.x,g.y,g.z])),A)return A.geometry.dispose(),A.geometry=i,A.computeLineDistances(),this.syncLineResolution(A),this.requestRender(),A;const n=new Zy({color:e?this.options.previewColor:this.options.lineColor,linewidth:this.options.lineWidth,dashed:e,dashSize:.32,gapSize:.2,depthTest:!1,transparent:e,opacity:e?.82:1}),o=new x8(i,n);return o.name=e?"PathDrawPreviewLine":"PathDrawLine",o.renderOrder=e?1001:1e3,o.computeLineDistances(),this.syncLineResolution(o),this.root.add(o),this.requestRender(),o}syncLineResolution(A){const t=A?.material,e=this.engine.renderer?.domElement;!t||!e||t.resolution.set(e.clientWidth,e.clientHeight)}disposeLine(A){const t=this[A];if(!t)return;t.parent?.remove(t),t.geometry.dispose(),(Array.isArray(t.material)?t.material:[t.material]).forEach(i=>i.dispose()),this[A]=null}buildSamplePoints(A){return A.length<2?A.map(t=>t.clone()):this.lineType==="straight"?A.map(t=>t.clone()):this.lineType==="rounded"?this.sampleRoundedPolyline(A):this.sampleBezier(A)}sampleBezier(A){const t=Math.max(2,this.options.sampleCount);return Array.from({length:t+1},(e,i)=>{const n=A.map(g=>g.clone()),o=i/t;for(let g=n.length-1;g>0;g-=1)for(let a=0;a<g;a+=1)n[a].lerp(n[a+1],o);return n[0]})}sampleRoundedPolyline(A){if(A.length<3||this.roundedRadius<=0)return A.map(i=>i.clone());const t=[A[0].clone()],e=Math.max(4,Math.round(this.options.sampleCount/Math.max(1,A.length-2)));for(let i=1;i<A.length-1;i+=1){const n=A[i-1],o=A[i],g=A[i+1],a=n.distanceTo(o),r=o.distanceTo(g);if(a<1e-8||r<1e-8){t.push(o.clone());continue}const I=Math.min(this.roundedRadius,a*.5,r*.5),l=o.clone().lerp(n,I/a),h=o.clone().lerp(g,I/r);t.push(l);for(let B=1;B<=e;B+=1){const E=B/e,c=1-E;t.push(new S().addScaledVector(l,c*c).addScaledVector(o,2*c*E).addScaledVector(h,E*E))}}return t.push(A[A.length-1].clone()),t}calculateLength(A){let t=0;for(let e=1;e<A.length;e+=1)t+=A[e-1].distanceTo(A[e]);return t}getPointRole(A){return A===0?"start":A===this.points.length-1?"end":"control"}getRoleLabel(A){const t=this.getPointRole(A);return t==="start"?"起点":t==="end"?"终点":`控制点 ${A}`}saveHistory(){this.history.push(this.createSnapshot()),this.history.length>this.options.historyLimit&&this.history.shift()}createSnapshot(){return{lineType:this.lineType,roundedRadius:this.roundedRadius,points:this.points.map(A=>({id:A.id,position:A.position.toArray()}))}}restoreSnapshot(A){this.clearPointRecords(),this.lineType=A.lineType,this.roundedRadius=A.roundedRadius,A.points.forEach(t=>{const e=this.createPointRecord(new S(...t.position),t.id);this.points.push(e),this.pointsGroup.add(e.mesh)})}clearPointRecords(){this.clearSelection(),this.points.forEach(A=>{A.mesh.parent?.remove(A.mesh),A.mesh.geometry.dispose(),A.mesh.material.dispose()}),this.points.length=0}removePoint(A){const t=this.points.findIndex(i=>i.id===A);if(t<0)return;this.saveHistory();const[e]=this.points.splice(t,1);e.mesh.parent?.remove(e.mesh),e.mesh.geometry.dispose(),e.mesh.material.dispose(),this.selectedPointId===A&&this.clearSelection(),this.refreshAll(),this.emitChange()}updatePointCoordinate(A,t,e){const i=this.points.find(n=>n.id===A);!i||!Number.isFinite(e)||i.position[t]===e||(this.saveHistory(),i.position[t]=e,i.mesh.position[t]=e,this.refreshAll(),this.emitChange())}createPanel(){const A=document.createElement("div");A.dataset.pathDrawPanel="true",Object.assign(A.style,{position:"absolute",top:"56px",right:"16px",width:"310px",maxHeight:"calc(100% - 72px)",display:"flex",flexDirection:"column",background:"rgba(255, 255, 255, 0.98)",color:"#111827",border:"1px solid #d1d5db",borderRadius:"6px",boxShadow:"0 12px 28px rgba(15,23,42,0.18)",fontFamily:"Arial, sans-serif",fontSize:"12px",zIndex:"1200",overflow:"hidden"});const t=document.createElement("div");Object.assign(t.style,{display:"flex",alignItems:"center",minHeight:"40px",padding:"0 8px 0 12px",borderBottom:"1px solid #e5e7eb"});const e=document.createElement("strong");e.textContent="路径绘制",e.style.flex="1";const i=document.createElement("span");Object.assign(i.style,{color:"#64748b",marginRight:"8px"});const n=this.createIconButton("×","关闭路径绘制",()=>this.close());t.append(e,i,n),A.appendChild(t),this.statusElement=i;const o=document.createElement("div");Object.assign(o.style,{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:"4px",padding:"8px"}),["bezier","straight","rounded"].forEach(Q=>{const C=this.createIconButton(V8[Q],k8[Q],()=>this.setLineType(Q));C.dataset.lineType=Q,C.style.width="100%",C.style.fontSize="18px",o.appendChild(C)}),A.appendChild(o);const g=document.createElement("label");g.dataset.radiusRow="true",Object.assign(g.style,{display:"none",alignItems:"center",gap:"8px",padding:"0 10px 8px",color:"#475569"});const a=document.createElement("span");a.textContent="圆角";const r=document.createElement("input");r.type="number",r.min="0",r.step="0.1",Object.assign(r.style,{flex:"1",minWidth:"0",height:"26px",padding:"0 7px",color:"#111827",background:"#ffffff",border:"1px solid #cbd5e1",borderRadius:"4px"}),r.addEventListener("change",()=>{const Q=Number(r.value);if(!Number.isFinite(Q)||Q<0||Q===this.roundedRadius){r.value=String(this.roundedRadius);return}this.saveHistory(),this.roundedRadius=Q,this.refreshAll(),this.emitChange()}),g.append(a,r),A.appendChild(g),this.radiusInput=r;const I=document.createElement("div");Object.assign(I.style,{flex:"1",minHeight:"72px",maxHeight:"200px",overflowY:"auto",overflowX:"hidden",borderTop:"1px solid #e5e7eb"}),A.appendChild(I),this.pointsList=I;const l=document.createElement("div");Object.assign(l.style,{display:"grid",gridTemplateColumns:"1fr auto auto auto",gap:"6px",padding:"8px",borderTop:"1px solid #e5e7eb"});const h=this.createIconButton("+","添加点",()=>this.startAddPoint());h.style.width="100%";const B=this.createIconButton("↶","撤销 Ctrl+Z",()=>this.undo());B.dataset.undoButton="true";const E=this.createIconButton("⌫","清空路径",()=>this.clear());E.dataset.clearButton="true";const c=this.createIconButton("✓","完成并返回路径",()=>this.complete());c.dataset.primary="true",l.append(h,B,E,c),A.appendChild(l),this.addButton=h,this.completeButton=c,this.engine.container?.appendChild(A),this.panel=A}createIconButton(A,t,e){const i=document.createElement("button");return i.type="button",i.textContent=A,i.title=t,i.setAttribute("aria-label",t),Object.assign(i.style,{width:"32px",height:"30px",display:"inline-flex",alignItems:"center",justifyContent:"center",padding:"0",border:"1px solid #d1d5db",borderRadius:"4px",background:"#f8fafc",color:"#334155",cursor:"pointer",fontSize:"15px"}),i.addEventListener("click",e),i}refreshPanel(){if(!this.panel||!this.pointsList)return;this.setStatus(this.mode==="picking"?"拾取中":`${this.points.length} 个点`),this.addButton&&(this.addButton.dataset.active=String(this.mode==="picking"),this.addButton.style.background=this.mode==="picking"?"#ffedd5":"#f8fafc",this.addButton.style.borderColor=this.mode==="picking"?"#f97316":"#d1d5db",this.addButton.style.color=this.mode==="picking"?"#9a3412":"#334155"),this.panel.querySelectorAll("[data-line-type]").forEach(i=>{const n=i.dataset.lineType===this.lineType;i.style.background=n?"#dcfce7":"#f8fafc",i.style.borderColor=n?"#22c55e":"#d1d5db",i.style.color=n?"#166534":"#334155"});const A=this.panel.querySelector("[data-radius-row]");A&&(A.style.display=this.lineType==="rounded"?"flex":"none"),this.radiusInput&&(this.radiusInput.value=String(this.roundedRadius));const t=this.panel.querySelector("[data-undo-button]"),e=this.panel.querySelector("[data-clear-button]");this.setButtonDisabled(t,this.history.length===0),this.setButtonDisabled(e,this.points.length===0),this.setButtonDisabled(this.completeButton,this.points.length<2),this.renderPointRows()}renderPointRows(){if(this.pointsList){if(this.pointsList.innerHTML="",this.points.length===0){const A=document.createElement("div");A.textContent="暂无点位",Object.assign(A.style,{padding:"24px 12px",textAlign:"center",color:"#94a3b8"}),this.pointsList.appendChild(A);return}this.points.forEach((A,t)=>{const e=document.createElement("div");Object.assign(e.style,{display:"grid",gridTemplateColumns:"64px repeat(3, minmax(0, 1fr)) 28px",gap:"4px",alignItems:"center",height:"40px",boxSizing:"border-box",padding:"5px 8px",cursor:"pointer",background:A.id===this.selectedPointId?"#fef3c7":"#ffffff",borderBottom:"1px solid #eef2f7"}),e.addEventListener("click",()=>this.selectPoint(A.id));const i=document.createElement("span");i.textContent=this.getRoleLabel(t),i.title=i.textContent,Object.assign(i.style,{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:"#334155"}),e.appendChild(i),["x","y","z"].forEach(o=>{const g=document.createElement("input");g.type="number",g.step="0.001",g.value=A.position[o].toFixed(3),g.title=o.toUpperCase(),Object.assign(g.style,{width:"100%",minWidth:"0",height:"25px",padding:"0 4px",boxSizing:"border-box",color:"#1f2937",background:"#ffffff",border:"1px solid #cbd5e1",borderRadius:"3px",fontSize:"11px"}),g.addEventListener("click",a=>a.stopPropagation()),g.addEventListener("change",()=>this.updatePointCoordinate(A.id,o,Number(g.value))),e.appendChild(g)});const n=this.createIconButton("×",`删除${this.getRoleLabel(t)}`,()=>this.removePoint(A.id));n.style.width="28px",n.style.height="25px",n.addEventListener("click",o=>o.stopPropagation()),e.appendChild(n),this.pointsList?.appendChild(e)})}}setButtonDisabled(A,t){A&&(A.disabled=t,A.style.opacity=t?"0.4":"1",A.style.cursor=t?"not-allowed":"pointer",A.dataset.primary==="true"&&(A.style.background=t?"#f1f5f9":"#16a34a",A.style.color=t?"#94a3b8":"#ffffff",A.style.borderColor=t?"#d1d5db":"#15803d"))}setStatus(A){this.statusElement&&(this.statusElement.textContent=A)}handleKeyDown(A){if(!(!this.active||this.isTextInputTarget(A))){if((A.ctrlKey||A.metaKey)&&!A.shiftKey&&!A.altKey&&A.key.toLowerCase()==="z"){if(this.history.length===0)return;A.preventDefault(),A.stopImmediatePropagation(),this.undo();return}A.key==="Escape"&&this.handelKeyEscDown()}}isTextInputTarget(A){const t=A.target;return!!(t?.isContentEditable||["INPUT","TEXTAREA","SELECT"].includes(t?.tagName??""))}emitChange(){this.options.onChange?.(this.getPathData()),this.requestRender()}requestRender(){this.engine.requestComposerRender?.()}toPlainVector(A){return{x:A.x,y:A.y,z:A.z}}}class O8{engine;continusIds=new Map;constructor(A){this.engine=A}buildContinueIds(A){const e=this.engine?.engineStatus?.models?.find(n=>n.url===A)?.properties?.models;if(e==null||typeof e!="object"){this.continusIds.set(A,new Set);return}const i=new Set;Object.keys(e).forEach(n=>{const o=Number(n);Number.isFinite(o)&&this.shouldFilterId(A,n,e[n])&&i.add(o)}),this.continusIds.set(A,i)}setContinueIds(A,t){const e=new Set;t.forEach(i=>{const n=Number(i);Number.isFinite(n)&&e.add(n)}),this.continusIds.set(A,e)}getContinueIds(A){return Array.from(this.continusIds.get(A)??[])}getContinueIdSet(A){return this.continusIds.get(A)??new Set}hasContinueId(A,t){const e=Number(t);return Number.isFinite(e)?this.getContinueIdSet(A).has(e):!1}clear(A){if(typeof A=="string"){this.continusIds.delete(A);return}this.continusIds.clear()}shouldFilterId(A,t,e){const n=this.engine?.engineStatus?.models?.find(I=>I.url===A)?.properties,o=Array.isArray(e)?e:n?.models?.[t];if(n==null||!Array.isArray(o)||o.length===0)return!1;const g=n.categorys??{},a=n.names??{},r=n.values??{};return o.some(I=>{if(!Array.isArray(I)||I.length<3)return!1;const l=String(g[I[0]]??""),h=String(a[I[1]]??""),B=String(r[I[2]]??"");return l.includes("图层信息")&&h.includes("父类别")&&(B.includes("注释")||B.includes("视口范围")||B.includes("剖面"))})}}const UB={version:"3.12.31"}.version;function Jy(){const s=globalThis.crypto?.subtle;if(!s)throw new Error("[BimEngine] Web Crypto API is required for secure sdkAuth credentials mode");return s}function XB(s){return new TextEncoder().encode(s)}function JB(s){return s.buffer.slice(s.byteOffset,s.byteOffset+s.byteLength)}function YW(s){let A="";return s.forEach(t=>{A+=String.fromCharCode(t)}),btoa(A)}function L8(s){const A=s.getUTCFullYear(),t=String(s.getUTCMonth()+1).padStart(2,"0"),e=String(s.getUTCDate()).padStart(2,"0");return`${A}${t}${e}`}async function z8(s){const A=await Jy().digest("SHA-256",JB(XB(s)));return Array.from(new Uint8Array(A)).map(t=>t.toString(16).padStart(2,"0")).join("")}async function v8(s,A){const t=Jy(),e=await t.importKey("raw",JB(s),{name:"HMAC",hash:"SHA-256"},!1,["sign"]);return t.sign("HMAC",e,JB(XB(A)))}function _8(s){return XB([s.appId,s.engineType,s.requestDate,String(s.timestamp),s.nonce].join("|"))}async function q8(s){const A=Jy(),t=new Date,e=t.getTime(),i=L8(t),n=globalThis.crypto.randomUUID(),o=globalThis.crypto.getRandomValues(new Uint8Array(12)),g=await z8(s.appSecret),a=await v8(XB(g),i),r=await A.importKey("raw",a,"AES-GCM",!1,["encrypt"]),I=JSON.stringify({appKey:s.appKey,appSecret:s.appSecret}),l=await A.encrypt({name:"AES-GCM",iv:o,additionalData:JB(_8({appId:s.appId,engineType:s.engineType,requestDate:i,timestamp:e,nonce:n})),tagLength:128},r,JB(XB(I)));return{appId:s.appId,engineType:s.engineType,requestDate:i,timestamp:e,nonce:n,iv:YW(o),cipherText:YW(new Uint8Array(l)),sdkVersion:s.sdkVersion,origin:s.origin,product:s.product}}const xy=new Map;function cQ(s){return s.replace(/\/+$/,"")}function QQ(s){if(s)return s;if(typeof window<"u"&&typeof window.location?.origin=="string")return window.location.origin}function $8(s,A){return JSON.stringify({endpoint:cQ(s.endpoint),token:s.token??"",appId:s.appId??"",appKey:s.appKey??"",appSecret:s.appSecret??"",origin:QQ(s.origin)??"",product:s.product??"",engineType:A,sdkVersion:UB})}async function ky(s,A,t){const e=typeof AbortController<"u"?new AbortController:void 0,i=e?setTimeout(()=>e.abort(),t):void 0;try{const n=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(A),signal:e?.signal}),o=await n.json().catch(()=>({}));if(!n.ok){const g=o?.error?.message??o?.message??`SDK authentication failed with status ${n.status}`;throw new Error(g)}return o}finally{i!=null&&clearTimeout(i)}}async function A3(s,A){const t=await ky(`${cQ(s.endpoint)}/oauth/sdk-verify`,{sdkToken:s.token,engineType:A,sdkVersion:UB,origin:QQ(s.origin),product:s.product},s.timeoutMs??8e3);return t.sdkToken=s.token,t}async function t3(s,A){const t=await q8({appId:s.appId,appKey:s.appKey,appSecret:s.appSecret,engineType:A,sdkVersion:UB,origin:QQ(s.origin),product:s.product}),e=await ky(`${cQ(s.endpoint)}/oauth/sdk-token/secure`,t,s.timeoutMs??8e3),i=await ky(`${cQ(s.endpoint)}/oauth/sdk-verify`,{sdkToken:e.sdkToken,engineType:A,sdkVersion:UB,origin:QQ(s.origin),product:s.product},s.timeoutMs??8e3);return i.sdkToken=e.sdkToken,i}async function e3(s,A){const t=s?.sdkAuth;if(!t)return null;if(!t.endpoint)throw new Error("[BimEngine] sdkAuth.endpoint is required");if(!t.token&&!(t.appId&&t.appKey&&t.appSecret))return null;const e=$8(t,A),i=xy.get(e);if(i){const o=await i;return s&&(s.__sdkAuthSession=o),o}const n=(t.token?A3(t,A):t3(t,A)).then(o=>{if(o.authorized!==!0)throw new Error("[BimEngine] SDK authorization rejected");return s&&(s.__sdkAuthSession=o),o}).catch(o=>{throw xy.delete(e),o});return xy.set(e,n),n}var Vy,FW;function Pt(){return FW||(FW=1,Vy={options:{usePureJavaScript:!1}}),Vy}var Hy={exports:{}},Oy,bW;function i3(){if(bW)return Oy;bW=1;var s={};Oy=s;var A={};s.encode=function(e,i,n){if(typeof i!="string")throw new TypeError('"alphabet" must be a string.');if(n!==void 0&&typeof n!="number")throw new TypeError('"maxline" must be a number.');var o="";if(!(e instanceof Uint8Array))o=t(e,i);else{var g=0,a=i.length,r=i.charAt(0),I=[0];for(g=0;g<e.length;++g){for(var l=0,h=e[g];l<I.length;++l)h+=I[l]<<8,I[l]=h%a,h=h/a|0;for(;h>0;)I.push(h%a),h=h/a|0}for(g=0;e[g]===0&&g<e.length-1;++g)o+=r;for(g=I.length-1;g>=0;--g)o+=i[I[g]]}if(n){var B=new RegExp(".{1,"+n+"}","g");o=o.match(B).join(`\r
6600
+ `};class Zy extends $t{constructor(A){super({type:"LineMaterial",uniforms:oi.clone(Zi.line.uniforms),vertexShader:Zi.line.vertexShader,fragmentShader:Zi.line.fragmentShader,clipping:!0}),this.isLineMaterial=!0,this.setValues(A)}get color(){return this.uniforms.diffuse.value}set color(A){this.uniforms.diffuse.value=A}get worldUnits(){return"WORLD_UNITS"in this.defines}set worldUnits(A){A===!0!==this.worldUnits&&(this.needsUpdate=!0),A===!0?this.defines.WORLD_UNITS="":delete this.defines.WORLD_UNITS}get linewidth(){return this.uniforms.linewidth.value}set linewidth(A){this.uniforms.linewidth&&(this.uniforms.linewidth.value=A)}get dashed(){return"USE_DASH"in this.defines}set dashed(A){A===!0!==this.dashed&&(this.needsUpdate=!0),A===!0?this.defines.USE_DASH="":delete this.defines.USE_DASH}get dashScale(){return this.uniforms.dashScale.value}set dashScale(A){this.uniforms.dashScale.value=A}get dashSize(){return this.uniforms.dashSize.value}set dashSize(A){this.uniforms.dashSize.value=A}get dashOffset(){return this.uniforms.dashOffset.value}set dashOffset(A){this.uniforms.dashOffset.value=A}get gapSize(){return this.uniforms.gapSize.value}set gapSize(A){this.uniforms.gapSize.value=A}get opacity(){return this.uniforms.opacity.value}set opacity(A){this.uniforms&&(this.uniforms.opacity.value=A)}get resolution(){return this.uniforms.resolution.value}set resolution(A){this.uniforms.resolution.value.copy(A)}get alphaToCoverage(){return"USE_ALPHA_TO_COVERAGE"in this.defines}set alphaToCoverage(A){this.defines&&(A===!0!==this.alphaToCoverage&&(this.needsUpdate=!0),A===!0?this.defines.USE_ALPHA_TO_COVERAGE="":delete this.defines.USE_ALPHA_TO_COVERAGE)}}const Ny=new Ct,wW=new S,uW=new S,Qi=new Ct,di=new Ct,wn=new Ct,Uy=new S,Xy=new RA,fi=new vi,mW=new S,hQ=new vA,CQ=new be,un=new Ct;let mn,ca;function PW(s,A,t){return un.set(0,0,-A,1).applyMatrix4(s.projectionMatrix),un.multiplyScalar(1/un.w),un.x=ca/t.width,un.y=ca/t.height,un.applyMatrix4(s.projectionMatrixInverse),un.multiplyScalar(1/un.w),Math.abs(Math.max(un.x,un.y))}function U8(s,A){const t=s.matrixWorld,e=s.geometry,i=e.attributes.instanceStart,n=e.attributes.instanceEnd,o=Math.min(e.instanceCount,i.count);for(let g=0,a=o;g<a;g++){fi.start.fromBufferAttribute(i,g),fi.end.fromBufferAttribute(n,g),fi.applyMatrix4(t);const r=new S,I=new S;mn.distanceSqToSegment(fi.start,fi.end,I,r),I.distanceTo(r)<ca*.5&&A.push({point:I,pointOnLine:r,distance:mn.origin.distanceTo(I),object:s,face:null,faceIndex:g,uv:null,uv1:null})}}function X8(s,A,t){const e=A.projectionMatrix,n=s.material.resolution,o=s.matrixWorld,g=s.geometry,a=g.attributes.instanceStart,r=g.attributes.instanceEnd,I=Math.min(g.instanceCount,a.count),l=-A.near;mn.at(1,wn),wn.w=1,wn.applyMatrix4(A.matrixWorldInverse),wn.applyMatrix4(e),wn.multiplyScalar(1/wn.w),wn.x*=n.x/2,wn.y*=n.y/2,wn.z=0,Uy.copy(wn),Xy.multiplyMatrices(A.matrixWorldInverse,o);for(let h=0,B=I;h<B;h++){if(Qi.fromBufferAttribute(a,h),di.fromBufferAttribute(r,h),Qi.w=1,di.w=1,Qi.applyMatrix4(Xy),di.applyMatrix4(Xy),Qi.z>l&&di.z>l)continue;if(Qi.z>l){const M=Qi.z-di.z,y=(Qi.z-l)/M;Qi.lerp(di,y)}else if(di.z>l){const M=di.z-Qi.z,y=(di.z-l)/M;di.lerp(Qi,y)}Qi.applyMatrix4(e),di.applyMatrix4(e),Qi.multiplyScalar(1/Qi.w),di.multiplyScalar(1/di.w),Qi.x*=n.x/2,Qi.y*=n.y/2,di.x*=n.x/2,di.y*=n.y/2,fi.start.copy(Qi),fi.start.z=0,fi.end.copy(di),fi.end.z=0;const c=fi.closestPointToPointParameter(Uy,!0);fi.at(c,mW);const Q=rt.lerp(Qi.z,di.z,c),C=Q>=-1&&Q<=1,d=Uy.distanceTo(mW)<ca*.5;if(C&&d){fi.start.fromBufferAttribute(a,h),fi.end.fromBufferAttribute(r,h),fi.start.applyMatrix4(o),fi.end.applyMatrix4(o);const M=new S,y=new S;mn.distanceSqToSegment(fi.start,fi.end,y,M),t.push({point:y,pointOnLine:M,distance:mn.origin.distanceTo(y),object:s,face:null,faceIndex:h,uv:null,uv1:null})}}}class J8 extends bA{constructor(A=new DW,t=new Zy({color:Math.random()*16777215})){super(A,t),this.isLineSegments2=!0,this.type="LineSegments2"}computeLineDistances(){const A=this.geometry,t=A.attributes.instanceStart,e=A.attributes.instanceEnd,i=new Float32Array(2*t.count);for(let o=0,g=0,a=t.count;o<a;o++,g+=2)wW.fromBufferAttribute(t,o),uW.fromBufferAttribute(e,o),i[g]=g===0?0:i[g-1],i[g+1]=i[g]+wW.distanceTo(uW);const n=new JC(i,2,1);return A.setAttribute("instanceDistanceStart",new ji(n,1,0)),A.setAttribute("instanceDistanceEnd",new ji(n,1,1)),this}raycast(A,t){const e=this.material.worldUnits,i=A.camera;if(i===null&&!e&&console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.'),e===!1&&(this.material.resolution.x===0||this.material.resolution.y===0))return;const n=A.params.Line2!==void 0&&A.params.Line2.threshold||0;mn=A.ray;const o=this.matrixWorld,g=this.geometry,a=this.material;ca=a.linewidth+n,g.boundingSphere===null&&g.computeBoundingSphere(),CQ.copy(g.boundingSphere).applyMatrix4(o);let r;if(e)r=ca*.5;else{const l=Math.max(i.near,CQ.distanceToPoint(mn.origin));r=PW(i,l,a.resolution)}if(CQ.radius+=r,mn.intersectsSphere(CQ)===!1)return;g.boundingBox===null&&g.computeBoundingBox(),hQ.copy(g.boundingBox).applyMatrix4(o);let I;if(e)I=ca*.5;else{const l=Math.max(i.near,hQ.distanceToPoint(mn.origin));I=PW(i,l,a.resolution)}hQ.expandByScalar(I),mn.intersectsBox(hQ)!==!1&&(e?U8(this,t):X8(this,i,t))}onBeforeRender(A){const t=this.material.uniforms;t&&t.resolution&&(A.getViewport(Ny),this.material.uniforms.resolution.value.set(Ny.z,Ny.w))}}class SW extends DW{constructor(){super(),this.isLineGeometry=!0,this.type="LineGeometry"}setPositions(A){const t=A.length-3,e=new Float32Array(2*t);for(let i=0;i<t;i+=3)e[2*i]=A[i],e[2*i+1]=A[i+1],e[2*i+2]=A[i+2],e[2*i+3]=A[i+3],e[2*i+4]=A[i+4],e[2*i+5]=A[i+5];return super.setPositions(e),this}setColors(A){const t=A.length-3,e=new Float32Array(2*t);for(let i=0;i<t;i+=3)e[2*i]=A[i],e[2*i+1]=A[i+1],e[2*i+2]=A[i+2],e[2*i+3]=A[i+3],e[2*i+4]=A[i+4],e[2*i+5]=A[i+5];return super.setColors(e),this}setFromPoints(A){const t=A.length-1,e=new Float32Array(6*t);for(let i=0;i<t;i++)e[6*i]=A[i].x,e[6*i+1]=A[i].y,e[6*i+2]=A[i].z||0,e[6*i+3]=A[i+1].x,e[6*i+4]=A[i+1].y,e[6*i+5]=A[i+1].z||0;return super.setPositions(e),this}fromLine(A){const t=A.geometry;return this.setPositions(t.attributes.position.array),this}}class x8 extends J8{constructor(A=new SW,t=new Zy({color:Math.random()*16777215})){super(A,t),this.isLine2=!0,this.type="Line2"}}const EQ={lineType:"bezier",lineColor:"#22c55e",previewColor:"#f59e0b",pointColor:"#ffffff",selectedPointColor:"#f59e0b",pointSize:.34,lineWidth:4,sampleCount:64,roundedRadius:1,historyLimit:100},k8={bezier:"贝塞尔曲线",straight:"直线",rounded:"圆角直线"},V8={bezier:"∿",straight:"╱",rounded:"⌁"};class H8{type="path-draw";engine;root=new Ot;pointsGroup=new Ot;points=[];history=[];options={...EQ};lineType=EQ.lineType;roundedRadius=EQ.roundedRadius;line=null;previewLine=null;previewMarker=null;transformControl=null;transformHelper=null;selectedPointId=null;panel=null;pointsList=null;statusElement=null;addButton=null;completeButton=null;radiusInput=null;mode="editing";active=!1;closing=!1;transformDragging=!1;suppressNextCanvasClick=!1;controlsEnabledBeforeDrag=!0;pointSequence=0;pathId="";onKeyDown;constructor(A){this.engine=A,this.root.name="PathDrawRoot",this.pointsGroup.name="PathDrawPoints",this.root.add(this.pointsGroup),this.onKeyDown=this.handleKeyDown.bind(this)}open(A={}){this.active&&this.close(),this.options={...EQ,...A},this.pathId=A.id??`path-${Date.now()}`,this.lineType=this.options.lineType,this.roundedRadius=Math.max(0,this.options.roundedRadius),this.active=!0,this.mode="editing",this.engine.scene?.add(this.root),this.ensureTransformControl(),this.createPanel(),this.activateBehavior(),window.addEventListener("keydown",this.onKeyDown,!0),this.refreshAll()}startAddPoint(){return!this.active||this.transformDragging?!1:(this.mode="picking",this.clearSelection(),this.setStatus("请在模型上拾取位置"),this.addButton&&(this.addButton.dataset.active="true"),!0)}setLineType(A){!this.active||this.lineType===A||(this.saveHistory(),this.lineType=A,this.refreshAll(),this.emitChange())}undo(){const A=this.history.pop();return A?(this.restoreSnapshot(A),this.mode="editing",this.clearPreview(),this.refreshAll(),this.emitChange(),!0):!1}clear(){this.points.length!==0&&(this.saveHistory(),this.clearPointRecords(),this.mode="editing",this.clearPreview(),this.refreshAll(),this.emitChange())}getPathData(){if(this.points.length<2)return null;const A=this.buildSamplePoints(this.points.map(t=>t.position));return{version:1,id:this.pathId,lineType:this.lineType,coordinateSystem:"world",closed:!1,roundedRadius:this.roundedRadius,points:this.points.map((t,e)=>({id:t.id,order:e,role:this.getPointRole(e),position:this.toPlainVector(t.position)})),samples:A.map(t=>this.toPlainVector(t)),length:this.calculateLength(A)}}complete(){const A=this.getPathData();if(!A)return null;try{this.options.onComplete?.(A)}finally{this.close()}return A}isActive(){return this.active}close(){this.closeInternal(!0)}closeInternal(A){!this.active&&!this.panel||this.closing||(this.closing=!0,this.active=!1,window.removeEventListener("keydown",this.onKeyDown,!0),this.clearPreview(),this.clearPointRecords(),this.disposeLine("line"),this.detachTransformControl(),this.panel?.remove(),this.panel=null,this.pointsList=null,this.statusElement=null,this.addButton=null,this.completeButton=null,this.radiusInput=null,this.history.length=0,this.selectedPointId=null,this.root.parent?.remove(this.root),A&&this.restoreDefaultBehavior(),this.closing=!1)}dispose(){this.closeInternal(!1),this.transformControl?.dispose(),this.transformControl=null,this.transformHelper=null}update(){!this.active||!this.engine.camera||(this.transformControl&&this.transformControl.camera!==this.engine.camera&&(this.transformControl.camera=this.engine.camera),this.syncLineResolution(this.line),this.syncLineResolution(this.previewLine))}disActive(){this.closing||this.closeInternal(!1)}handleMouseMove(A){if(!this.active||this.mode!=="picking")return;const t=this.getCatchPoint(A?.catch);if(!t){this.clearPreview();return}this.updatePreview(t)}handleMouseClick(A){if(!this.active)return;if(this.suppressNextCanvasClick){this.suppressNextCanvasClick=!1;return}if(this.mode==="picking"){const e=this.getCatchPoint(A?.catch);if(!e)return;this.saveHistory();const i=this.createPointRecord(e);this.points.push(i),this.pointsGroup.add(i.mesh),this.mode="editing",this.clearPreview(),this.selectPoint(i.id),this.refreshAll(),this.emitChange();return}const t=this.pickPointMesh(A);t?this.selectPoint(t.userData.pathDrawPointId):this.clearSelection()}handelKeyEscDown(){if(this.mode==="picking"){this.mode="editing",this.clearPreview(),this.refreshPanel();return}this.clearSelection()}activateBehavior(){const A=this.engine.handelBehaved;A?.init?.(this,{showCatch:!0}),A?.active?.()}restoreDefaultBehavior(){const A=this.engine.handelBehaved;A?.self===this&&(A.disActive?.(),this.engine.interactionModule?.init?.(),this.engine.interactionModule?.active?.(),this.engine.catchSvg&&(this.engine.catchSvg.innerHTML=""))}ensureTransformControl(){if(this.transformControl){this.transformHelper&&!this.transformHelper.parent&&this.engine.scene?.add(this.transformHelper);return}!this.engine.camera||!this.engine.renderer||!this.engine.scene||(this.transformControl=new ql(this.engine.camera,this.engine.renderer.domElement),this.transformControl.setMode("translate"),this.transformControl.size=.72,this.transformControl.addEventListener("dragging-changed",A=>{if(this.transformDragging=!!A.value,this.transformDragging){this.saveHistory(),this.controlsEnabledBeforeDrag=this.engine.controls?.enabled!==!1,this.engine.controls&&(this.engine.controls.enabled=!1);return}this.engine.controls&&(this.engine.controls.enabled=this.controlsEnabledBeforeDrag),this.suppressNextCanvasClick=!0,requestAnimationFrame(()=>{this.suppressNextCanvasClick=!1}),this.refreshAll(),this.emitChange()}),this.transformControl.addEventListener("objectChange",()=>{const A=this.getSelectedPoint();A&&(A.position.copy(A.mesh.position),this.refreshLine(),this.refreshPanel(),this.emitChange())}),this.transformHelper=this.transformControl.getHelper(),this.transformHelper.visible=!1,this.engine.scene.add(this.transformHelper))}detachTransformControl(){this.transformControl?.detach(),this.transformHelper&&(this.transformHelper.visible=!1,this.transformHelper.parent?.remove(this.transformHelper))}createPointRecord(A,t){const e=new an(this.options.pointSize,18,12),i=new Kt({color:this.options.pointColor,depthTest:!1,depthWrite:!1}),n=new bA(e,i),o=t??`path-point-${++this.pointSequence}`;return n.name=o,n.position.copy(A),n.renderOrder=1002,n.userData.pathDrawPointId=o,{id:o,position:A.clone(),mesh:n}}selectPoint(A){const t=this.points.find(e=>e.id===A);!t||!this.transformControl||!this.transformHelper||(this.selectedPointId=A,this.points.forEach(e=>e.mesh.material.color.set(e.id===A?this.options.selectedPointColor:this.options.pointColor)),this.transformControl.attach(t.mesh),this.transformHelper.visible=!0,this.refreshPanel())}clearSelection(){this.selectedPointId=null,this.points.forEach(A=>A.mesh.material.color.set(this.options.pointColor)),this.transformControl?.detach(),this.transformHelper&&(this.transformHelper.visible=!1),this.refreshPanel()}getSelectedPoint(){return this.points.find(A=>A.id===this.selectedPointId)??null}getCatchPoint(A){return A?.point instanceof S?A.point.clone():null}pickPointMesh(A){if(!this.engine.camera||!this.engine.renderer)return null;const t=this.engine.renderer.domElement.clientWidth,e=this.engine.renderer.domElement.clientHeight;if(!t||!e)return null;const i=new MA(A.offsetX/t*2-1,-(A.offsetY/e)*2+1),n=new De;return n.setFromCamera(i,this.engine.camera),n.intersectObjects(this.pointsGroup.children,!1)[0]?.object??null}updatePreview(A){this.previewMarker||(this.previewMarker=new bA(new an(this.options.pointSize*.72,14,10),new Kt({color:this.options.previewColor,depthTest:!1,depthWrite:!1})),this.previewMarker.renderOrder=1003,this.root.add(this.previewMarker)),this.previewMarker.position.copy(A),this.previewMarker.visible=!0;const t=[...this.points.map(i=>i.position),A];if(t.length<2){this.disposeLine("previewLine");return}const e=this.buildSamplePoints(t);this.previewLine=this.updateLineObject(this.previewLine,e,!0)}clearPreview(){this.disposeLine("previewLine"),this.previewMarker&&(this.previewMarker.geometry.dispose(),this.previewMarker.material.dispose(),this.previewMarker.parent?.remove(this.previewMarker),this.previewMarker=null)}refreshAll(){this.refreshLine(),this.refreshPanel(),this.requestRender()}refreshLine(){if(this.points.length<2){this.disposeLine("line");return}const A=this.buildSamplePoints(this.points.map(t=>t.position));this.line=this.updateLineObject(this.line,A,!1)}updateLineObject(A,t,e){const i=new SW;if(i.setPositions(t.flatMap(g=>[g.x,g.y,g.z])),A)return A.geometry.dispose(),A.geometry=i,A.computeLineDistances(),this.syncLineResolution(A),this.requestRender(),A;const n=new Zy({color:e?this.options.previewColor:this.options.lineColor,linewidth:this.options.lineWidth,dashed:e,dashSize:.32,gapSize:.2,depthTest:!1,transparent:e,opacity:e?.82:1}),o=new x8(i,n);return o.name=e?"PathDrawPreviewLine":"PathDrawLine",o.renderOrder=e?1001:1e3,o.computeLineDistances(),this.syncLineResolution(o),this.root.add(o),this.requestRender(),o}syncLineResolution(A){const t=A?.material,e=this.engine.renderer?.domElement;!t||!e||t.resolution.set(e.clientWidth,e.clientHeight)}disposeLine(A){const t=this[A];if(!t)return;t.parent?.remove(t),t.geometry.dispose(),(Array.isArray(t.material)?t.material:[t.material]).forEach(i=>i.dispose()),this[A]=null}buildSamplePoints(A){return A.length<2?A.map(t=>t.clone()):this.lineType==="straight"?A.map(t=>t.clone()):this.lineType==="rounded"?this.sampleRoundedPolyline(A):this.sampleBezier(A)}sampleBezier(A){const t=Math.max(2,this.options.sampleCount);return Array.from({length:t+1},(e,i)=>{const n=A.map(g=>g.clone()),o=i/t;for(let g=n.length-1;g>0;g-=1)for(let a=0;a<g;a+=1)n[a].lerp(n[a+1],o);return n[0]})}sampleRoundedPolyline(A){if(A.length<3||this.roundedRadius<=0)return A.map(i=>i.clone());const t=[A[0].clone()],e=Math.max(4,Math.round(this.options.sampleCount/Math.max(1,A.length-2)));for(let i=1;i<A.length-1;i+=1){const n=A[i-1],o=A[i],g=A[i+1],a=n.distanceTo(o),r=o.distanceTo(g);if(a<1e-8||r<1e-8){t.push(o.clone());continue}const I=Math.min(this.roundedRadius,a*.5,r*.5),l=o.clone().lerp(n,I/a),h=o.clone().lerp(g,I/r);t.push(l);for(let B=1;B<=e;B+=1){const E=B/e,c=1-E;t.push(new S().addScaledVector(l,c*c).addScaledVector(o,2*c*E).addScaledVector(h,E*E))}}return t.push(A[A.length-1].clone()),t}calculateLength(A){let t=0;for(let e=1;e<A.length;e+=1)t+=A[e-1].distanceTo(A[e]);return t}getPointRole(A){return A===0?"start":A===this.points.length-1?"end":"control"}getRoleLabel(A){const t=this.getPointRole(A);return t==="start"?"起点":t==="end"?"终点":`控制点 ${A}`}saveHistory(){this.history.push(this.createSnapshot()),this.history.length>this.options.historyLimit&&this.history.shift()}createSnapshot(){return{lineType:this.lineType,roundedRadius:this.roundedRadius,points:this.points.map(A=>({id:A.id,position:A.position.toArray()}))}}restoreSnapshot(A){this.clearPointRecords(),this.lineType=A.lineType,this.roundedRadius=A.roundedRadius,A.points.forEach(t=>{const e=this.createPointRecord(new S(...t.position),t.id);this.points.push(e),this.pointsGroup.add(e.mesh)})}clearPointRecords(){this.clearSelection(),this.points.forEach(A=>{A.mesh.parent?.remove(A.mesh),A.mesh.geometry.dispose(),A.mesh.material.dispose()}),this.points.length=0}removePoint(A){const t=this.points.findIndex(i=>i.id===A);if(t<0)return;this.saveHistory();const[e]=this.points.splice(t,1);e.mesh.parent?.remove(e.mesh),e.mesh.geometry.dispose(),e.mesh.material.dispose(),this.selectedPointId===A&&this.clearSelection(),this.refreshAll(),this.emitChange()}updatePointCoordinate(A,t,e){const i=this.points.find(n=>n.id===A);!i||!Number.isFinite(e)||i.position[t]===e||(this.saveHistory(),i.position[t]=e,i.mesh.position[t]=e,this.refreshAll(),this.emitChange())}createPanel(){const A=document.createElement("div");A.dataset.pathDrawPanel="true",Object.assign(A.style,{position:"absolute",top:"56px",right:"16px",width:"310px",maxHeight:"calc(100% - 72px)",display:"flex",flexDirection:"column",background:"rgba(255, 255, 255, 0.98)",color:"#111827",border:"1px solid #d1d5db",borderRadius:"6px",boxShadow:"0 12px 28px rgba(15,23,42,0.18)",fontFamily:"Arial, sans-serif",fontSize:"12px",zIndex:"1200",overflow:"hidden"});const t=document.createElement("div");Object.assign(t.style,{display:"flex",alignItems:"center",minHeight:"40px",padding:"0 8px 0 12px",borderBottom:"1px solid #e5e7eb"});const e=document.createElement("strong");e.textContent="路径绘制",e.style.flex="1";const i=document.createElement("span");Object.assign(i.style,{color:"#64748b",marginRight:"8px"});const n=this.createIconButton("×","关闭路径绘制",()=>this.close());t.append(e,i,n),A.appendChild(t),this.statusElement=i;const o=document.createElement("div");Object.assign(o.style,{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:"4px",padding:"8px"}),["bezier","straight","rounded"].forEach(Q=>{const C=this.createIconButton(V8[Q],k8[Q],()=>this.setLineType(Q));C.dataset.lineType=Q,C.style.width="100%",C.style.fontSize="18px",o.appendChild(C)}),A.appendChild(o);const g=document.createElement("label");g.dataset.radiusRow="true",Object.assign(g.style,{display:"none",alignItems:"center",gap:"8px",padding:"0 10px 8px",color:"#475569"});const a=document.createElement("span");a.textContent="圆角";const r=document.createElement("input");r.type="number",r.min="0",r.step="0.1",Object.assign(r.style,{flex:"1",minWidth:"0",height:"26px",padding:"0 7px",color:"#111827",background:"#ffffff",border:"1px solid #cbd5e1",borderRadius:"4px"}),r.addEventListener("change",()=>{const Q=Number(r.value);if(!Number.isFinite(Q)||Q<0||Q===this.roundedRadius){r.value=String(this.roundedRadius);return}this.saveHistory(),this.roundedRadius=Q,this.refreshAll(),this.emitChange()}),g.append(a,r),A.appendChild(g),this.radiusInput=r;const I=document.createElement("div");Object.assign(I.style,{flex:"1",minHeight:"72px",maxHeight:"200px",overflowY:"auto",overflowX:"hidden",borderTop:"1px solid #e5e7eb"}),A.appendChild(I),this.pointsList=I;const l=document.createElement("div");Object.assign(l.style,{display:"grid",gridTemplateColumns:"1fr auto auto auto",gap:"6px",padding:"8px",borderTop:"1px solid #e5e7eb"});const h=this.createIconButton("+","添加点",()=>this.startAddPoint());h.style.width="100%";const B=this.createIconButton("↶","撤销 Ctrl+Z",()=>this.undo());B.dataset.undoButton="true";const E=this.createIconButton("⌫","清空路径",()=>this.clear());E.dataset.clearButton="true";const c=this.createIconButton("✓","完成并返回路径",()=>this.complete());c.dataset.primary="true",l.append(h,B,E,c),A.appendChild(l),this.addButton=h,this.completeButton=c,this.engine.container?.appendChild(A),this.panel=A}createIconButton(A,t,e){const i=document.createElement("button");return i.type="button",i.textContent=A,i.title=t,i.setAttribute("aria-label",t),Object.assign(i.style,{width:"32px",height:"30px",display:"inline-flex",alignItems:"center",justifyContent:"center",padding:"0",border:"1px solid #d1d5db",borderRadius:"4px",background:"#f8fafc",color:"#334155",cursor:"pointer",fontSize:"15px"}),i.addEventListener("click",e),i}refreshPanel(){if(!this.panel||!this.pointsList)return;this.setStatus(this.mode==="picking"?"拾取中":`${this.points.length} 个点`),this.addButton&&(this.addButton.dataset.active=String(this.mode==="picking"),this.addButton.style.background=this.mode==="picking"?"#ffedd5":"#f8fafc",this.addButton.style.borderColor=this.mode==="picking"?"#f97316":"#d1d5db",this.addButton.style.color=this.mode==="picking"?"#9a3412":"#334155"),this.panel.querySelectorAll("[data-line-type]").forEach(i=>{const n=i.dataset.lineType===this.lineType;i.style.background=n?"#dcfce7":"#f8fafc",i.style.borderColor=n?"#22c55e":"#d1d5db",i.style.color=n?"#166534":"#334155"});const A=this.panel.querySelector("[data-radius-row]");A&&(A.style.display=this.lineType==="rounded"?"flex":"none"),this.radiusInput&&(this.radiusInput.value=String(this.roundedRadius));const t=this.panel.querySelector("[data-undo-button]"),e=this.panel.querySelector("[data-clear-button]");this.setButtonDisabled(t,this.history.length===0),this.setButtonDisabled(e,this.points.length===0),this.setButtonDisabled(this.completeButton,this.points.length<2),this.renderPointRows()}renderPointRows(){if(this.pointsList){if(this.pointsList.innerHTML="",this.points.length===0){const A=document.createElement("div");A.textContent="暂无点位",Object.assign(A.style,{padding:"24px 12px",textAlign:"center",color:"#94a3b8"}),this.pointsList.appendChild(A);return}this.points.forEach((A,t)=>{const e=document.createElement("div");Object.assign(e.style,{display:"grid",gridTemplateColumns:"64px repeat(3, minmax(0, 1fr)) 28px",gap:"4px",alignItems:"center",height:"40px",boxSizing:"border-box",padding:"5px 8px",cursor:"pointer",background:A.id===this.selectedPointId?"#fef3c7":"#ffffff",borderBottom:"1px solid #eef2f7"}),e.addEventListener("click",()=>this.selectPoint(A.id));const i=document.createElement("span");i.textContent=this.getRoleLabel(t),i.title=i.textContent,Object.assign(i.style,{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:"#334155"}),e.appendChild(i),["x","y","z"].forEach(o=>{const g=document.createElement("input");g.type="number",g.step="0.001",g.value=A.position[o].toFixed(3),g.title=o.toUpperCase(),Object.assign(g.style,{width:"100%",minWidth:"0",height:"25px",padding:"0 4px",boxSizing:"border-box",color:"#1f2937",background:"#ffffff",border:"1px solid #cbd5e1",borderRadius:"3px",fontSize:"11px"}),g.addEventListener("click",a=>a.stopPropagation()),g.addEventListener("change",()=>this.updatePointCoordinate(A.id,o,Number(g.value))),e.appendChild(g)});const n=this.createIconButton("×",`删除${this.getRoleLabel(t)}`,()=>this.removePoint(A.id));n.style.width="28px",n.style.height="25px",n.addEventListener("click",o=>o.stopPropagation()),e.appendChild(n),this.pointsList?.appendChild(e)})}}setButtonDisabled(A,t){A&&(A.disabled=t,A.style.opacity=t?"0.4":"1",A.style.cursor=t?"not-allowed":"pointer",A.dataset.primary==="true"&&(A.style.background=t?"#f1f5f9":"#16a34a",A.style.color=t?"#94a3b8":"#ffffff",A.style.borderColor=t?"#d1d5db":"#15803d"))}setStatus(A){this.statusElement&&(this.statusElement.textContent=A)}handleKeyDown(A){if(!(!this.active||this.isTextInputTarget(A))){if((A.ctrlKey||A.metaKey)&&!A.shiftKey&&!A.altKey&&A.key.toLowerCase()==="z"){if(this.history.length===0)return;A.preventDefault(),A.stopImmediatePropagation(),this.undo();return}A.key==="Escape"&&this.handelKeyEscDown()}}isTextInputTarget(A){const t=A.target;return!!(t?.isContentEditable||["INPUT","TEXTAREA","SELECT"].includes(t?.tagName??""))}emitChange(){this.options.onChange?.(this.getPathData()),this.requestRender()}requestRender(){this.engine.requestComposerRender?.()}toPlainVector(A){return{x:A.x,y:A.y,z:A.z}}}class O8{engine;continusIds=new Map;constructor(A){this.engine=A}buildContinueIds(A){const e=this.engine?.engineStatus?.models?.find(n=>n.url===A)?.properties?.models;if(e==null||typeof e!="object"){this.continusIds.set(A,new Set);return}const i=new Set;Object.keys(e).forEach(n=>{const o=Number(n);Number.isFinite(o)&&this.shouldFilterId(A,n,e[n])&&i.add(o)}),this.continusIds.set(A,i)}setContinueIds(A,t){const e=new Set;t.forEach(i=>{const n=Number(i);Number.isFinite(n)&&e.add(n)}),this.continusIds.set(A,e)}getContinueIds(A){return Array.from(this.continusIds.get(A)??[])}getContinueIdSet(A){return this.continusIds.get(A)??new Set}hasContinueId(A,t){const e=Number(t);return Number.isFinite(e)?this.getContinueIdSet(A).has(e):!1}clear(A){if(typeof A=="string"){this.continusIds.delete(A);return}this.continusIds.clear()}shouldFilterId(A,t,e){const n=this.engine?.engineStatus?.models?.find(I=>I.url===A)?.properties,o=Array.isArray(e)?e:n?.models?.[t];if(n==null||!Array.isArray(o)||o.length===0)return!1;const g=n.categorys??{},a=n.names??{},r=n.values??{};return o.some(I=>{if(!Array.isArray(I)||I.length<3)return!1;const l=String(g[I[0]]??""),h=String(a[I[1]]??""),B=String(r[I[2]]??"");return l.includes("图层信息")&&h.includes("父类别")&&(B.includes("注释")||B.includes("视口范围")||B.includes("剖面"))})}}const UB={version:"4.0.0"}.version;function Jy(){const s=globalThis.crypto?.subtle;if(!s)throw new Error("[BimEngine] Web Crypto API is required for secure sdkAuth credentials mode");return s}function XB(s){return new TextEncoder().encode(s)}function JB(s){return s.buffer.slice(s.byteOffset,s.byteOffset+s.byteLength)}function YW(s){let A="";return s.forEach(t=>{A+=String.fromCharCode(t)}),btoa(A)}function L8(s){const A=s.getUTCFullYear(),t=String(s.getUTCMonth()+1).padStart(2,"0"),e=String(s.getUTCDate()).padStart(2,"0");return`${A}${t}${e}`}async function z8(s){const A=await Jy().digest("SHA-256",JB(XB(s)));return Array.from(new Uint8Array(A)).map(t=>t.toString(16).padStart(2,"0")).join("")}async function v8(s,A){const t=Jy(),e=await t.importKey("raw",JB(s),{name:"HMAC",hash:"SHA-256"},!1,["sign"]);return t.sign("HMAC",e,JB(XB(A)))}function _8(s){return XB([s.appId,s.engineType,s.requestDate,String(s.timestamp),s.nonce].join("|"))}async function q8(s){const A=Jy(),t=new Date,e=t.getTime(),i=L8(t),n=globalThis.crypto.randomUUID(),o=globalThis.crypto.getRandomValues(new Uint8Array(12)),g=await z8(s.appSecret),a=await v8(XB(g),i),r=await A.importKey("raw",a,"AES-GCM",!1,["encrypt"]),I=JSON.stringify({appKey:s.appKey,appSecret:s.appSecret}),l=await A.encrypt({name:"AES-GCM",iv:o,additionalData:JB(_8({appId:s.appId,engineType:s.engineType,requestDate:i,timestamp:e,nonce:n})),tagLength:128},r,JB(XB(I)));return{appId:s.appId,engineType:s.engineType,requestDate:i,timestamp:e,nonce:n,iv:YW(o),cipherText:YW(new Uint8Array(l)),sdkVersion:s.sdkVersion,origin:s.origin,product:s.product}}const xy=new Map;function cQ(s){return s.replace(/\/+$/,"")}function QQ(s){if(s)return s;if(typeof window<"u"&&typeof window.location?.origin=="string")return window.location.origin}function $8(s,A){return JSON.stringify({endpoint:cQ(s.endpoint),token:s.token??"",appId:s.appId??"",appKey:s.appKey??"",appSecret:s.appSecret??"",origin:QQ(s.origin)??"",product:s.product??"",engineType:A,sdkVersion:UB})}async function ky(s,A,t){const e=typeof AbortController<"u"?new AbortController:void 0,i=e?setTimeout(()=>e.abort(),t):void 0;try{const n=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(A),signal:e?.signal}),o=await n.json().catch(()=>({}));if(!n.ok){const g=o?.error?.message??o?.message??`SDK authentication failed with status ${n.status}`;throw new Error(g)}return o}finally{i!=null&&clearTimeout(i)}}async function A3(s,A){const t=await ky(`${cQ(s.endpoint)}/oauth/sdk-verify`,{sdkToken:s.token,engineType:A,sdkVersion:UB,origin:QQ(s.origin),product:s.product},s.timeoutMs??8e3);return t.sdkToken=s.token,t}async function t3(s,A){const t=await q8({appId:s.appId,appKey:s.appKey,appSecret:s.appSecret,engineType:A,sdkVersion:UB,origin:QQ(s.origin),product:s.product}),e=await ky(`${cQ(s.endpoint)}/oauth/sdk-token/secure`,t,s.timeoutMs??8e3),i=await ky(`${cQ(s.endpoint)}/oauth/sdk-verify`,{sdkToken:e.sdkToken,engineType:A,sdkVersion:UB,origin:QQ(s.origin),product:s.product},s.timeoutMs??8e3);return i.sdkToken=e.sdkToken,i}async function e3(s,A){const t=s?.sdkAuth;if(!t)return null;if(!t.endpoint)throw new Error("[BimEngine] sdkAuth.endpoint is required");if(!t.token&&!(t.appId&&t.appKey&&t.appSecret))return null;const e=$8(t,A),i=xy.get(e);if(i){const o=await i;return s&&(s.__sdkAuthSession=o),o}const n=(t.token?A3(t,A):t3(t,A)).then(o=>{if(o.authorized!==!0)throw new Error("[BimEngine] SDK authorization rejected");return s&&(s.__sdkAuthSession=o),o}).catch(o=>{throw xy.delete(e),o});return xy.set(e,n),n}var Vy,FW;function Pt(){return FW||(FW=1,Vy={options:{usePureJavaScript:!1}}),Vy}var Hy={exports:{}},Oy,bW;function i3(){if(bW)return Oy;bW=1;var s={};Oy=s;var A={};s.encode=function(e,i,n){if(typeof i!="string")throw new TypeError('"alphabet" must be a string.');if(n!==void 0&&typeof n!="number")throw new TypeError('"maxline" must be a number.');var o="";if(!(e instanceof Uint8Array))o=t(e,i);else{var g=0,a=i.length,r=i.charAt(0),I=[0];for(g=0;g<e.length;++g){for(var l=0,h=e[g];l<I.length;++l)h+=I[l]<<8,I[l]=h%a,h=h/a|0;for(;h>0;)I.push(h%a),h=h/a|0}for(g=0;e[g]===0&&g<e.length-1;++g)o+=r;for(g=I.length-1;g>=0;--g)o+=i[I[g]]}if(n){var B=new RegExp(".{1,"+n+"}","g");o=o.match(B).join(`\r
6601
6601
  `)}return o},s.decode=function(e,i){if(typeof e!="string")throw new TypeError('"input" must be a string.');if(typeof i!="string")throw new TypeError('"alphabet" must be a string.');var n=A[i];if(!n){n=A[i]=[];for(var o=0;o<i.length;++o)n[i.charCodeAt(o)]=o}e=e.replace(/\s/g,"");for(var g=i.length,a=i.charAt(0),r=[0],o=0;o<e.length;o++){var I=n[e.charCodeAt(o)];if(I===void 0)return;for(var l=0,h=I;l<r.length;++l)h+=r[l]*g,r[l]=h&255,h>>=8;for(;h>0;)r.push(h&255),h>>=8}for(var B=0;e[B]===a&&B<e.length-1;++B)r.push(0);return typeof Buffer<"u"?Buffer.from(r.reverse()):new Uint8Array(r.reverse())};function t(e,i){var n=0,o=i.length,g=i.charAt(0),a=[0];for(n=0;n<e.length();++n){for(var r=0,I=e.at(n);r<a.length;++r)I+=a[r]<<8,a[r]=I%o,I=I/o|0;for(;I>0;)a.push(I%o),I=I/o|0}var l="";for(n=0;e.at(n)===0&&n<e.length()-1;++n)l+=g;for(n=a.length-1;n>=0;--n)l+=i[a[n]];return l}return Oy}var WW;function Ut(){if(WW)return Hy.exports;WW=1;var s=Pt(),A=i3(),t=Hy.exports=s.util=s.util||{};(function(){if(typeof process<"u"&&process.nextTick&&!process.browser){t.nextTick=process.nextTick,typeof setImmediate=="function"?t.setImmediate=setImmediate:t.setImmediate=t.nextTick;return}if(typeof setImmediate=="function"){t.setImmediate=function(){return setImmediate.apply(void 0,arguments)},t.nextTick=function(p){return setImmediate(p)};return}if(t.setImmediate=function(p){setTimeout(p,0)},typeof window<"u"&&typeof window.postMessage=="function"){let p=function(f){if(f.source===window&&f.data===C){f.stopPropagation();var u=d.slice();d.length=0,u.forEach(function(Y){Y()})}};var C="forge.setImmediate",d=[];t.setImmediate=function(f){d.push(f),d.length===1&&window.postMessage(C,"*")},window.addEventListener("message",p,!0)}if(typeof MutationObserver<"u"){var M=Date.now(),y=!0,w=document.createElement("div"),d=[];new MutationObserver(function(){var f=d.slice();d.length=0,f.forEach(function(u){u()})}).observe(w,{attributes:!0});var D=t.setImmediate;t.setImmediate=function(f){Date.now()-M>15?(M=Date.now(),D(f)):(d.push(f),d.length===1&&w.setAttribute("a",y=!y))}}t.nextTick=t.setImmediate})(),t.isNodejs=typeof process<"u"&&process.versions&&process.versions.node,t.globalScope=(function(){return t.isNodejs?ul:typeof self>"u"?window:self})(),t.isArray=Array.isArray||function(C){return Object.prototype.toString.call(C)==="[object Array]"},t.isArrayBuffer=function(C){return typeof ArrayBuffer<"u"&&C instanceof ArrayBuffer},t.isArrayBufferView=function(C){return C&&t.isArrayBuffer(C.buffer)&&C.byteLength!==void 0};function e(C){if(!(C===8||C===16||C===24||C===32))throw new Error("Only 8, 16, 24, or 32 bits supported: "+C)}t.ByteBuffer=i;function i(C){if(this.data="",this.read=0,typeof C=="string")this.data=C;else if(t.isArrayBuffer(C)||t.isArrayBufferView(C))if(typeof Buffer<"u"&&C instanceof Buffer)this.data=C.toString("binary");else{var d=new Uint8Array(C);try{this.data=String.fromCharCode.apply(null,d)}catch{for(var M=0;M<d.length;++M)this.putByte(d[M])}}else(C instanceof i||typeof C=="object"&&typeof C.data=="string"&&typeof C.read=="number")&&(this.data=C.data,this.read=C.read);this._constructedStringLength=0}t.ByteStringBuffer=i;var n=4096;t.ByteStringBuffer.prototype._optimizeConstructedString=function(C){this._constructedStringLength+=C,this._constructedStringLength>n&&(this.data.substr(0,1),this._constructedStringLength=0)},t.ByteStringBuffer.prototype.length=function(){return this.data.length-this.read},t.ByteStringBuffer.prototype.isEmpty=function(){return this.length()<=0},t.ByteStringBuffer.prototype.putByte=function(C){return this.putBytes(String.fromCharCode(C))},t.ByteStringBuffer.prototype.fillWithByte=function(C,d){C=String.fromCharCode(C);for(var M=this.data;d>0;)d&1&&(M+=C),d>>>=1,d>0&&(C+=C);return this.data=M,this._optimizeConstructedString(d),this},t.ByteStringBuffer.prototype.putBytes=function(C){return this.data+=C,this._optimizeConstructedString(C.length),this},t.ByteStringBuffer.prototype.putString=function(C){return this.putBytes(t.encodeUtf8(C))},t.ByteStringBuffer.prototype.putInt16=function(C){return this.putBytes(String.fromCharCode(C>>8&255)+String.fromCharCode(C&255))},t.ByteStringBuffer.prototype.putInt24=function(C){return this.putBytes(String.fromCharCode(C>>16&255)+String.fromCharCode(C>>8&255)+String.fromCharCode(C&255))},t.ByteStringBuffer.prototype.putInt32=function(C){return this.putBytes(String.fromCharCode(C>>24&255)+String.fromCharCode(C>>16&255)+String.fromCharCode(C>>8&255)+String.fromCharCode(C&255))},t.ByteStringBuffer.prototype.putInt16Le=function(C){return this.putBytes(String.fromCharCode(C&255)+String.fromCharCode(C>>8&255))},t.ByteStringBuffer.prototype.putInt24Le=function(C){return this.putBytes(String.fromCharCode(C&255)+String.fromCharCode(C>>8&255)+String.fromCharCode(C>>16&255))},t.ByteStringBuffer.prototype.putInt32Le=function(C){return this.putBytes(String.fromCharCode(C&255)+String.fromCharCode(C>>8&255)+String.fromCharCode(C>>16&255)+String.fromCharCode(C>>24&255))},t.ByteStringBuffer.prototype.putInt=function(C,d){e(d);var M="";do d-=8,M+=String.fromCharCode(C>>d&255);while(d>0);return this.putBytes(M)},t.ByteStringBuffer.prototype.putSignedInt=function(C,d){return C<0&&(C+=2<<d-1),this.putInt(C,d)},t.ByteStringBuffer.prototype.putBuffer=function(C){return this.putBytes(C.getBytes())},t.ByteStringBuffer.prototype.getByte=function(){return this.data.charCodeAt(this.read++)},t.ByteStringBuffer.prototype.getInt16=function(){var C=this.data.charCodeAt(this.read)<<8^this.data.charCodeAt(this.read+1);return this.read+=2,C},t.ByteStringBuffer.prototype.getInt24=function(){var C=this.data.charCodeAt(this.read)<<16^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2);return this.read+=3,C},t.ByteStringBuffer.prototype.getInt32=function(){var C=this.data.charCodeAt(this.read)<<24^this.data.charCodeAt(this.read+1)<<16^this.data.charCodeAt(this.read+2)<<8^this.data.charCodeAt(this.read+3);return this.read+=4,C},t.ByteStringBuffer.prototype.getInt16Le=function(){var C=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8;return this.read+=2,C},t.ByteStringBuffer.prototype.getInt24Le=function(){var C=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2)<<16;return this.read+=3,C},t.ByteStringBuffer.prototype.getInt32Le=function(){var C=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2)<<16^this.data.charCodeAt(this.read+3)<<24;return this.read+=4,C},t.ByteStringBuffer.prototype.getInt=function(C){e(C);var d=0;do d=(d<<8)+this.data.charCodeAt(this.read++),C-=8;while(C>0);return d},t.ByteStringBuffer.prototype.getSignedInt=function(C){var d=this.getInt(C),M=2<<C-2;return d>=M&&(d-=M<<1),d},t.ByteStringBuffer.prototype.getBytes=function(C){var d;return C?(C=Math.min(this.length(),C),d=this.data.slice(this.read,this.read+C),this.read+=C):C===0?d="":(d=this.read===0?this.data:this.data.slice(this.read),this.clear()),d},t.ByteStringBuffer.prototype.bytes=function(C){return typeof C>"u"?this.data.slice(this.read):this.data.slice(this.read,this.read+C)},t.ByteStringBuffer.prototype.at=function(C){return this.data.charCodeAt(this.read+C)},t.ByteStringBuffer.prototype.setAt=function(C,d){return this.data=this.data.substr(0,this.read+C)+String.fromCharCode(d)+this.data.substr(this.read+C+1),this},t.ByteStringBuffer.prototype.last=function(){return this.data.charCodeAt(this.data.length-1)},t.ByteStringBuffer.prototype.copy=function(){var C=t.createBuffer(this.data);return C.read=this.read,C},t.ByteStringBuffer.prototype.compact=function(){return this.read>0&&(this.data=this.data.slice(this.read),this.read=0),this},t.ByteStringBuffer.prototype.clear=function(){return this.data="",this.read=0,this},t.ByteStringBuffer.prototype.truncate=function(C){var d=Math.max(0,this.length()-C);return this.data=this.data.substr(this.read,d),this.read=0,this},t.ByteStringBuffer.prototype.toHex=function(){for(var C="",d=this.read;d<this.data.length;++d){var M=this.data.charCodeAt(d);M<16&&(C+="0"),C+=M.toString(16)}return C},t.ByteStringBuffer.prototype.toString=function(){return t.decodeUtf8(this.bytes())};function o(C,d){d=d||{},this.read=d.readOffset||0,this.growSize=d.growSize||1024;var M=t.isArrayBuffer(C),y=t.isArrayBufferView(C);if(M||y){M?this.data=new DataView(C):this.data=new DataView(C.buffer,C.byteOffset,C.byteLength),this.write="writeOffset"in d?d.writeOffset:this.data.byteLength;return}this.data=new DataView(new ArrayBuffer(0)),this.write=0,C!=null&&this.putBytes(C),"writeOffset"in d&&(this.write=d.writeOffset)}t.DataBuffer=o,t.DataBuffer.prototype.length=function(){return this.write-this.read},t.DataBuffer.prototype.isEmpty=function(){return this.length()<=0},t.DataBuffer.prototype.accommodate=function(C,d){if(this.length()>=C)return this;d=Math.max(d||this.growSize,C);var M=new Uint8Array(this.data.buffer,this.data.byteOffset,this.data.byteLength),y=new Uint8Array(this.length()+d);return y.set(M),this.data=new DataView(y.buffer),this},t.DataBuffer.prototype.putByte=function(C){return this.accommodate(1),this.data.setUint8(this.write++,C),this},t.DataBuffer.prototype.fillWithByte=function(C,d){this.accommodate(d);for(var M=0;M<d;++M)this.data.setUint8(C);return this},t.DataBuffer.prototype.putBytes=function(C,d){if(t.isArrayBufferView(C)){var M=new Uint8Array(C.buffer,C.byteOffset,C.byteLength),y=M.byteLength-M.byteOffset;this.accommodate(y);var w=new Uint8Array(this.data.buffer,this.write);return w.set(M),this.write+=y,this}if(t.isArrayBuffer(C)){var M=new Uint8Array(C);this.accommodate(M.byteLength);var w=new Uint8Array(this.data.buffer);return w.set(M,this.write),this.write+=M.byteLength,this}if(C instanceof t.DataBuffer||typeof C=="object"&&typeof C.read=="number"&&typeof C.write=="number"&&t.isArrayBufferView(C.data)){var M=new Uint8Array(C.data.byteLength,C.read,C.length());this.accommodate(M.byteLength);var w=new Uint8Array(C.data.byteLength,this.write);return w.set(M),this.write+=M.byteLength,this}if(C instanceof t.ByteStringBuffer&&(C=C.data,d="binary"),d=d||"binary",typeof C=="string"){var D;if(d==="hex")return this.accommodate(Math.ceil(C.length/2)),D=new Uint8Array(this.data.buffer,this.write),this.write+=t.binary.hex.decode(C,D,this.write),this;if(d==="base64")return this.accommodate(Math.ceil(C.length/4)*3),D=new Uint8Array(this.data.buffer,this.write),this.write+=t.binary.base64.decode(C,D,this.write),this;if(d==="utf8"&&(C=t.encodeUtf8(C),d="binary"),d==="binary"||d==="raw")return this.accommodate(C.length),D=new Uint8Array(this.data.buffer,this.write),this.write+=t.binary.raw.decode(D),this;if(d==="utf16")return this.accommodate(C.length*2),D=new Uint16Array(this.data.buffer,this.write),this.write+=t.text.utf16.encode(D),this;throw new Error("Invalid encoding: "+d)}throw Error("Invalid parameter: "+C)},t.DataBuffer.prototype.putBuffer=function(C){return this.putBytes(C),C.clear(),this},t.DataBuffer.prototype.putString=function(C){return this.putBytes(C,"utf16")},t.DataBuffer.prototype.putInt16=function(C){return this.accommodate(2),this.data.setInt16(this.write,C),this.write+=2,this},t.DataBuffer.prototype.putInt24=function(C){return this.accommodate(3),this.data.setInt16(this.write,C>>8&65535),this.data.setInt8(this.write,C>>16&255),this.write+=3,this},t.DataBuffer.prototype.putInt32=function(C){return this.accommodate(4),this.data.setInt32(this.write,C),this.write+=4,this},t.DataBuffer.prototype.putInt16Le=function(C){return this.accommodate(2),this.data.setInt16(this.write,C,!0),this.write+=2,this},t.DataBuffer.prototype.putInt24Le=function(C){return this.accommodate(3),this.data.setInt8(this.write,C>>16&255),this.data.setInt16(this.write,C>>8&65535,!0),this.write+=3,this},t.DataBuffer.prototype.putInt32Le=function(C){return this.accommodate(4),this.data.setInt32(this.write,C,!0),this.write+=4,this},t.DataBuffer.prototype.putInt=function(C,d){e(d),this.accommodate(d/8);do d-=8,this.data.setInt8(this.write++,C>>d&255);while(d>0);return this},t.DataBuffer.prototype.putSignedInt=function(C,d){return e(d),this.accommodate(d/8),C<0&&(C+=2<<d-1),this.putInt(C,d)},t.DataBuffer.prototype.getByte=function(){return this.data.getInt8(this.read++)},t.DataBuffer.prototype.getInt16=function(){var C=this.data.getInt16(this.read);return this.read+=2,C},t.DataBuffer.prototype.getInt24=function(){var C=this.data.getInt16(this.read)<<8^this.data.getInt8(this.read+2);return this.read+=3,C},t.DataBuffer.prototype.getInt32=function(){var C=this.data.getInt32(this.read);return this.read+=4,C},t.DataBuffer.prototype.getInt16Le=function(){var C=this.data.getInt16(this.read,!0);return this.read+=2,C},t.DataBuffer.prototype.getInt24Le=function(){var C=this.data.getInt8(this.read)^this.data.getInt16(this.read+1,!0)<<8;return this.read+=3,C},t.DataBuffer.prototype.getInt32Le=function(){var C=this.data.getInt32(this.read,!0);return this.read+=4,C},t.DataBuffer.prototype.getInt=function(C){e(C);var d=0;do d=(d<<8)+this.data.getInt8(this.read++),C-=8;while(C>0);return d},t.DataBuffer.prototype.getSignedInt=function(C){var d=this.getInt(C),M=2<<C-2;return d>=M&&(d-=M<<1),d},t.DataBuffer.prototype.getBytes=function(C){var d;return C?(C=Math.min(this.length(),C),d=this.data.slice(this.read,this.read+C),this.read+=C):C===0?d="":(d=this.read===0?this.data:this.data.slice(this.read),this.clear()),d},t.DataBuffer.prototype.bytes=function(C){return typeof C>"u"?this.data.slice(this.read):this.data.slice(this.read,this.read+C)},t.DataBuffer.prototype.at=function(C){return this.data.getUint8(this.read+C)},t.DataBuffer.prototype.setAt=function(C,d){return this.data.setUint8(C,d),this},t.DataBuffer.prototype.last=function(){return this.data.getUint8(this.write-1)},t.DataBuffer.prototype.copy=function(){return new t.DataBuffer(this)},t.DataBuffer.prototype.compact=function(){if(this.read>0){var C=new Uint8Array(this.data.buffer,this.read),d=new Uint8Array(C.byteLength);d.set(C),this.data=new DataView(d),this.write-=this.read,this.read=0}return this},t.DataBuffer.prototype.clear=function(){return this.data=new DataView(new ArrayBuffer(0)),this.read=this.write=0,this},t.DataBuffer.prototype.truncate=function(C){return this.write=Math.max(0,this.length()-C),this.read=Math.min(this.read,this.write),this},t.DataBuffer.prototype.toHex=function(){for(var C="",d=this.read;d<this.data.byteLength;++d){var M=this.data.getUint8(d);M<16&&(C+="0"),C+=M.toString(16)}return C},t.DataBuffer.prototype.toString=function(C){var d=new Uint8Array(this.data,this.read,this.length());if(C=C||"utf8",C==="binary"||C==="raw")return t.binary.raw.encode(d);if(C==="hex")return t.binary.hex.encode(d);if(C==="base64")return t.binary.base64.encode(d);if(C==="utf8")return t.text.utf8.decode(d);if(C==="utf16")return t.text.utf16.decode(d);throw new Error("Invalid encoding: "+C)},t.createBuffer=function(C,d){return d=d||"raw",C!==void 0&&d==="utf8"&&(C=t.encodeUtf8(C)),new t.ByteBuffer(C)},t.fillString=function(C,d){for(var M="";d>0;)d&1&&(M+=C),d>>>=1,d>0&&(C+=C);return M},t.xorBytes=function(C,d,M){for(var y="",w="",D="",p=0,f=0;M>0;--M,++p)w=C.charCodeAt(p)^d.charCodeAt(p),f>=10&&(y+=D,D="",f=0),D+=String.fromCharCode(w),++f;return y+=D,y},t.hexToBytes=function(C){var d="",M=0;for(C.length&!0&&(M=1,d+=String.fromCharCode(parseInt(C[0],16)));M<C.length;M+=2)d+=String.fromCharCode(parseInt(C.substr(M,2),16));return d},t.bytesToHex=function(C){return t.createBuffer(C).toHex()},t.int32ToBytes=function(C){return String.fromCharCode(C>>24&255)+String.fromCharCode(C>>16&255)+String.fromCharCode(C>>8&255)+String.fromCharCode(C&255)};var g="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",a=[62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,64,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51],r="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";t.encode64=function(C,d){for(var M="",y="",w,D,p,f=0;f<C.length;)w=C.charCodeAt(f++),D=C.charCodeAt(f++),p=C.charCodeAt(f++),M+=g.charAt(w>>2),M+=g.charAt((w&3)<<4|D>>4),isNaN(D)?M+="==":(M+=g.charAt((D&15)<<2|p>>6),M+=isNaN(p)?"=":g.charAt(p&63)),d&&M.length>d&&(y+=M.substr(0,d)+`\r
6602
6602
  `,M=M.substr(d));return y+=M,y},t.decode64=function(C){C=C.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var d="",M,y,w,D,p=0;p<C.length;)M=a[C.charCodeAt(p++)-43],y=a[C.charCodeAt(p++)-43],w=a[C.charCodeAt(p++)-43],D=a[C.charCodeAt(p++)-43],d+=String.fromCharCode(M<<2|y>>4),w!==64&&(d+=String.fromCharCode((y&15)<<4|w>>2),D!==64&&(d+=String.fromCharCode((w&3)<<6|D)));return d},t.encodeUtf8=function(C){return unescape(encodeURIComponent(C))},t.decodeUtf8=function(C){return decodeURIComponent(escape(C))},t.binary={raw:{},hex:{},base64:{},base58:{},baseN:{encode:A.encode,decode:A.decode}},t.binary.raw.encode=function(C){return String.fromCharCode.apply(null,C)},t.binary.raw.decode=function(C,d,M){var y=d;y||(y=new Uint8Array(C.length)),M=M||0;for(var w=M,D=0;D<C.length;++D)y[w++]=C.charCodeAt(D);return d?w-M:y},t.binary.hex.encode=t.bytesToHex,t.binary.hex.decode=function(C,d,M){var y=d;y||(y=new Uint8Array(Math.ceil(C.length/2))),M=M||0;var w=0,D=M;for(C.length&1&&(w=1,y[D++]=parseInt(C[0],16));w<C.length;w+=2)y[D++]=parseInt(C.substr(w,2),16);return d?D-M:y},t.binary.base64.encode=function(C,d){for(var M="",y="",w,D,p,f=0;f<C.byteLength;)w=C[f++],D=C[f++],p=C[f++],M+=g.charAt(w>>2),M+=g.charAt((w&3)<<4|D>>4),isNaN(D)?M+="==":(M+=g.charAt((D&15)<<2|p>>6),M+=isNaN(p)?"=":g.charAt(p&63)),d&&M.length>d&&(y+=M.substr(0,d)+`\r
6603
6603
  `,M=M.substr(d));return y+=M,y},t.binary.base64.decode=function(C,d,M){var y=d;y||(y=new Uint8Array(Math.ceil(C.length/4)*3)),C=C.replace(/[^A-Za-z0-9\+\/\=]/g,""),M=M||0;for(var w,D,p,f,u=0,Y=M;u<C.length;)w=a[C.charCodeAt(u++)-43],D=a[C.charCodeAt(u++)-43],p=a[C.charCodeAt(u++)-43],f=a[C.charCodeAt(u++)-43],y[Y++]=w<<2|D>>4,p!==64&&(y[Y++]=(D&15)<<4|p>>2,f!==64&&(y[Y++]=(p&3)<<6|f));return d?Y-M:y.subarray(0,Y)},t.binary.base58.encode=function(C,d){return t.binary.baseN.encode(C,r,d)},t.binary.base58.decode=function(C,d){return t.binary.baseN.decode(C,r,d)},t.text={utf8:{},utf16:{}},t.text.utf8.encode=function(C,d,M){C=t.encodeUtf8(C);var y=d;y||(y=new Uint8Array(C.length)),M=M||0;for(var w=M,D=0;D<C.length;++D)y[w++]=C.charCodeAt(D);return d?w-M:y},t.text.utf8.decode=function(C){return t.decodeUtf8(String.fromCharCode.apply(null,C))},t.text.utf16.encode=function(C,d,M){var y=d;y||(y=new Uint8Array(C.length*2));var w=new Uint16Array(y.buffer);M=M||0;for(var D=M,p=M,f=0;f<C.length;++f)w[p++]=C.charCodeAt(f),D+=2;return d?D-M:y},t.text.utf16.decode=function(C){return String.fromCharCode.apply(null,new Uint16Array(C.buffer))},t.deflate=function(C,d,M){if(d=t.decode64(C.deflate(t.encode64(d)).rval),M){var y=2,w=d.charCodeAt(1);w&32&&(y=6),d=d.substring(y,d.length-4)}return d},t.inflate=function(C,d,M){var y=C.inflate(t.encode64(d)).rval;return y===null?null:t.decode64(y)};var I=function(C,d,M){if(!C)throw new Error("WebStorage not available.");var y;if(M===null?y=C.removeItem(d):(M=t.encode64(JSON.stringify(M)),y=C.setItem(d,M)),typeof y<"u"&&y.rval!==!0){var w=new Error(y.error.message);throw w.id=y.error.id,w.name=y.error.name,w}},l=function(C,d){if(!C)throw new Error("WebStorage not available.");var M=C.getItem(d);if(C.init)if(M.rval===null){if(M.error){var y=new Error(M.error.message);throw y.id=M.error.id,y.name=M.error.name,y}M=null}else M=M.rval;return M!==null&&(M=JSON.parse(t.decode64(M))),M},h=function(C,d,M,y){var w=l(C,d);w===null&&(w={}),w[M]=y,I(C,d,w)},B=function(C,d,M){var y=l(C,d);return y!==null&&(y=M in y?y[M]:null),y},E=function(C,d,M){var y=l(C,d);if(y!==null&&M in y){delete y[M];var w=!0;for(var D in y){w=!1;break}w&&(y=null),I(C,d,y)}},c=function(C,d){I(C,d,null)},Q=function(C,d,M){var y=null;typeof M>"u"&&(M=["web","flash"]);var w,D=!1,p=null;for(var f in M){w=M[f];try{if(w==="flash"||w==="both"){if(d[0]===null)throw new Error("Flash local storage not available.");y=C.apply(this,d),D=w==="flash"}(w==="web"||w==="both")&&(d[0]=localStorage,y=C.apply(this,d),D=!0)}catch(u){p=u}if(D)break}if(!D)throw p;return y};return t.setItem=function(C,d,M,y,w){Q(h,arguments,w)},t.getItem=function(C,d,M,y){return Q(B,arguments,y)},t.removeItem=function(C,d,M,y){Q(E,arguments,y)},t.clearItems=function(C,d,M){Q(c,arguments,M)},t.isEmpty=function(C){for(var d in C)if(C.hasOwnProperty(d))return!1;return!0},t.format=function(C){for(var d=/%./g,M,y,w=0,D=[],p=0;M=d.exec(C);){y=C.substring(p,d.lastIndex-2),y.length>0&&D.push(y),p=d.lastIndex;var f=M[0][1];switch(f){case"s":case"o":w<arguments.length?D.push(arguments[w+++1]):D.push("<?>");break;case"%":D.push("%");break;default:D.push("<%"+f+"?>")}}return D.push(C.substring(p)),D.join("")},t.formatNumber=function(C,d,M,y){var w=C,D=isNaN(d=Math.abs(d))?2:d,p=M===void 0?",":M,f=y===void 0?".":y,u=w<0?"-":"",Y=parseInt(w=Math.abs(+w||0).toFixed(D),10)+"",b=Y.length>3?Y.length%3:0;return u+(b?Y.substr(0,b)+f:"")+Y.substr(b).replace(/(\d{3})(?=\d)/g,"$1"+f)+(D?p+Math.abs(w-Y).toFixed(D).slice(2):"")},t.formatSize=function(C){return C>=1073741824?C=t.formatNumber(C/1073741824,2,".","")+" GiB":C>=1048576?C=t.formatNumber(C/1048576,2,".","")+" MiB":C>=1024?C=t.formatNumber(C/1024,0)+" KiB":C=t.formatNumber(C,0)+" bytes",C},t.bytesFromIP=function(C){return C.indexOf(".")!==-1?t.bytesFromIPv4(C):C.indexOf(":")!==-1?t.bytesFromIPv6(C):null},t.bytesFromIPv4=function(C){if(C=C.split("."),C.length!==4)return null;for(var d=t.createBuffer(),M=0;M<C.length;++M){var y=parseInt(C[M],10);if(isNaN(y))return null;d.putByte(y)}return d.getBytes()},t.bytesFromIPv6=function(C){var d=0;C=C.split(":").filter(function(p){return p.length===0&&++d,!0});for(var M=(8-C.length+d)*2,y=t.createBuffer(),w=0;w<8;++w){if(!C[w]||C[w].length===0){y.fillWithByte(0,M),M=0;continue}var D=t.hexToBytes(C[w]);D.length<2&&y.putByte(0),y.putBytes(D)}return y.getBytes()},t.bytesToIP=function(C){return C.length===4?t.bytesToIPv4(C):C.length===16?t.bytesToIPv6(C):null},t.bytesToIPv4=function(C){if(C.length!==4)return null;for(var d=[],M=0;M<C.length;++M)d.push(C.charCodeAt(M));return d.join(".")},t.bytesToIPv6=function(C){if(C.length!==16)return null;for(var d=[],M=[],y=0,w=0;w<C.length;w+=2){for(var D=t.bytesToHex(C[w]+C[w+1]);D[0]==="0"&&D!=="0";)D=D.substr(1);if(D==="0"){var p=M[M.length-1],f=d.length;!p||f!==p.end+1?M.push({start:f,end:f}):(p.end=f,p.end-p.start>M[y].end-M[y].start&&(y=M.length-1))}d.push(D)}if(M.length>0){var u=M[y];u.end-u.start>0&&(d.splice(u.start,u.end-u.start+1,""),u.start===0&&d.unshift(""),u.end===7&&d.push(""))}return d.join(":")},t.estimateCores=function(C,d){if(typeof C=="function"&&(d=C,C={}),C=C||{},"cores"in t&&!C.update)return d(null,t.cores);if(typeof navigator<"u"&&"hardwareConcurrency"in navigator&&navigator.hardwareConcurrency>0)return t.cores=navigator.hardwareConcurrency,d(null,t.cores);if(typeof Worker>"u")return t.cores=1,d(null,t.cores);if(typeof Blob>"u")return t.cores=2,d(null,t.cores);var M=URL.createObjectURL(new Blob(["(",(function(){self.addEventListener("message",function(p){var f=Date.now(),u=f+4;self.postMessage({st:f,et:u})})}).toString(),")()"],{type:"application/javascript"}));y([],5,16);function y(p,f,u){if(f===0){var Y=Math.floor(p.reduce(function(b,m){return b+m},0)/p.length);return t.cores=Math.max(1,Y),URL.revokeObjectURL(M),d(null,t.cores)}w(u,function(b,m){p.push(D(u,m)),y(p,f-1,u)})}function w(p,f){for(var u=[],Y=[],b=0;b<p;++b){var m=new Worker(M);m.addEventListener("message",function(T){if(Y.push(T.data),Y.length===p){for(var F=0;F<p;++F)u[F].terminate();f(null,Y)}}),u.push(m)}for(var b=0;b<p;++b)u[b].postMessage(b)}function D(p,f){for(var u=[],Y=0;Y<p;++Y)for(var b=f[Y],m=u[Y]=[],T=0;T<p;++T)if(Y!==T){var F=f[T];(b.st>F.st&&b.st<F.et||F.st>b.st&&F.st<b.et)&&m.push(T)}return u.reduce(function(j,X){return Math.max(j,X.length)},0)}},Hy.exports}var Ly,GW;function zy(){if(GW)return Ly;GW=1;var s=Pt();Ut(),Ly=s.cipher=s.cipher||{},s.cipher.algorithms=s.cipher.algorithms||{},s.cipher.createCipher=function(t,e){var i=t;if(typeof i=="string"&&(i=s.cipher.getAlgorithm(i),i&&(i=i())),!i)throw new Error("Unsupported algorithm: "+t);return new s.cipher.BlockCipher({algorithm:i,key:e,decrypt:!1})},s.cipher.createDecipher=function(t,e){var i=t;if(typeof i=="string"&&(i=s.cipher.getAlgorithm(i),i&&(i=i())),!i)throw new Error("Unsupported algorithm: "+t);return new s.cipher.BlockCipher({algorithm:i,key:e,decrypt:!0})},s.cipher.registerAlgorithm=function(t,e){t=t.toUpperCase(),s.cipher.algorithms[t]=e},s.cipher.getAlgorithm=function(t){return t=t.toUpperCase(),t in s.cipher.algorithms?s.cipher.algorithms[t]:null};var A=s.cipher.BlockCipher=function(t){this.algorithm=t.algorithm,this.mode=this.algorithm.mode,this.blockSize=this.mode.blockSize,this._finish=!1,this._input=null,this.output=null,this._op=t.decrypt?this.mode.decrypt:this.mode.encrypt,this._decrypt=t.decrypt,this.algorithm.initialize(t)};return A.prototype.start=function(t){t=t||{};var e={};for(var i in t)e[i]=t[i];e.decrypt=this._decrypt,this._finish=!1,this._input=s.util.createBuffer(),this.output=t.output||s.util.createBuffer(),this.mode.start(e)},A.prototype.update=function(t){for(t&&this._input.putBuffer(t);!this._op.call(this.mode,this._input,this.output,this._finish)&&!this._finish;);this._input.compact()},A.prototype.finish=function(t){t&&(this.mode.name==="ECB"||this.mode.name==="CBC")&&(this.mode.pad=function(i){return t(this.blockSize,i,!1)},this.mode.unpad=function(i){return t(this.blockSize,i,!0)});var e={};return e.decrypt=this._decrypt,e.overflow=this._input.length()%this.blockSize,!(!this._decrypt&&this.mode.pad&&!this.mode.pad(this._input,e)||(this._finish=!0,this.update(),this._decrypt&&this.mode.unpad&&!this.mode.unpad(this.output,e))||this.mode.afterFinish&&!this.mode.afterFinish(this.output,e))},Ly}var vy={exports:{}},TW;function KW(){if(TW)return vy.exports;TW=1;var s=Pt();Ut(),s.cipher=s.cipher||{};var A=vy.exports=s.cipher.modes=s.cipher.modes||{};A.ecb=function(n){n=n||{},this.name="ECB",this.cipher=n.cipher,this.blockSize=n.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints)},A.ecb.prototype.start=function(n){},A.ecb.prototype.encrypt=function(n,o,g){if(n.length()<this.blockSize&&!(g&&n.length()>0))return!0;for(var a=0;a<this._ints;++a)this._inBlock[a]=n.getInt32();this.cipher.encrypt(this._inBlock,this._outBlock);for(var a=0;a<this._ints;++a)o.putInt32(this._outBlock[a])},A.ecb.prototype.decrypt=function(n,o,g){if(n.length()<this.blockSize&&!(g&&n.length()>0))return!0;for(var a=0;a<this._ints;++a)this._inBlock[a]=n.getInt32();this.cipher.decrypt(this._inBlock,this._outBlock);for(var a=0;a<this._ints;++a)o.putInt32(this._outBlock[a])},A.ecb.prototype.pad=function(n,o){var g=n.length()===this.blockSize?this.blockSize:this.blockSize-n.length();return n.fillWithByte(g,g),!0},A.ecb.prototype.unpad=function(n,o){if(o.overflow>0)return!1;var g=n.length(),a=n.at(g-1);return a>this.blockSize<<2?!1:(n.truncate(a),!0)},A.cbc=function(n){n=n||{},this.name="CBC",this.cipher=n.cipher,this.blockSize=n.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints)},A.cbc.prototype.start=function(n){if(n.iv===null){if(!this._prev)throw new Error("Invalid IV parameter.");this._iv=this._prev.slice(0)}else if("iv"in n)this._iv=t(n.iv,this.blockSize),this._prev=this._iv.slice(0);else throw new Error("Invalid IV parameter.")},A.cbc.prototype.encrypt=function(n,o,g){if(n.length()<this.blockSize&&!(g&&n.length()>0))return!0;for(var a=0;a<this._ints;++a)this._inBlock[a]=this._prev[a]^n.getInt32();this.cipher.encrypt(this._inBlock,this._outBlock);for(var a=0;a<this._ints;++a)o.putInt32(this._outBlock[a]);this._prev=this._outBlock},A.cbc.prototype.decrypt=function(n,o,g){if(n.length()<this.blockSize&&!(g&&n.length()>0))return!0;for(var a=0;a<this._ints;++a)this._inBlock[a]=n.getInt32();this.cipher.decrypt(this._inBlock,this._outBlock);for(var a=0;a<this._ints;++a)o.putInt32(this._prev[a]^this._outBlock[a]);this._prev=this._inBlock.slice(0)},A.cbc.prototype.pad=function(n,o){var g=n.length()===this.blockSize?this.blockSize:this.blockSize-n.length();return n.fillWithByte(g,g),!0},A.cbc.prototype.unpad=function(n,o){if(o.overflow>0)return!1;var g=n.length(),a=n.at(g-1);return a>this.blockSize<<2?!1:(n.truncate(a),!0)},A.cfb=function(n){n=n||{},this.name="CFB",this.cipher=n.cipher,this.blockSize=n.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialBlock=new Array(this._ints),this._partialOutput=s.util.createBuffer(),this._partialBytes=0},A.cfb.prototype.start=function(n){if(!("iv"in n))throw new Error("Invalid IV parameter.");this._iv=t(n.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},A.cfb.prototype.encrypt=function(n,o,g){var a=n.length();if(a===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&a>=this.blockSize){for(var r=0;r<this._ints;++r)this._inBlock[r]=n.getInt32()^this._outBlock[r],o.putInt32(this._inBlock[r]);return}var I=(this.blockSize-a)%this.blockSize;I>0&&(I=this.blockSize-I),this._partialOutput.clear();for(var r=0;r<this._ints;++r)this._partialBlock[r]=n.getInt32()^this._outBlock[r],this._partialOutput.putInt32(this._partialBlock[r]);if(I>0)n.read-=this.blockSize;else for(var r=0;r<this._ints;++r)this._inBlock[r]=this._partialBlock[r];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),I>0&&!g)return o.putBytes(this._partialOutput.getBytes(I-this._partialBytes)),this._partialBytes=I,!0;o.putBytes(this._partialOutput.getBytes(a-this._partialBytes)),this._partialBytes=0},A.cfb.prototype.decrypt=function(n,o,g){var a=n.length();if(a===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&a>=this.blockSize){for(var r=0;r<this._ints;++r)this._inBlock[r]=n.getInt32(),o.putInt32(this._inBlock[r]^this._outBlock[r]);return}var I=(this.blockSize-a)%this.blockSize;I>0&&(I=this.blockSize-I),this._partialOutput.clear();for(var r=0;r<this._ints;++r)this._partialBlock[r]=n.getInt32(),this._partialOutput.putInt32(this._partialBlock[r]^this._outBlock[r]);if(I>0)n.read-=this.blockSize;else for(var r=0;r<this._ints;++r)this._inBlock[r]=this._partialBlock[r];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),I>0&&!g)return o.putBytes(this._partialOutput.getBytes(I-this._partialBytes)),this._partialBytes=I,!0;o.putBytes(this._partialOutput.getBytes(a-this._partialBytes)),this._partialBytes=0},A.ofb=function(n){n=n||{},this.name="OFB",this.cipher=n.cipher,this.blockSize=n.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=s.util.createBuffer(),this._partialBytes=0},A.ofb.prototype.start=function(n){if(!("iv"in n))throw new Error("Invalid IV parameter.");this._iv=t(n.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},A.ofb.prototype.encrypt=function(n,o,g){var a=n.length();if(n.length()===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&a>=this.blockSize){for(var r=0;r<this._ints;++r)o.putInt32(n.getInt32()^this._outBlock[r]),this._inBlock[r]=this._outBlock[r];return}var I=(this.blockSize-a)%this.blockSize;I>0&&(I=this.blockSize-I),this._partialOutput.clear();for(var r=0;r<this._ints;++r)this._partialOutput.putInt32(n.getInt32()^this._outBlock[r]);if(I>0)n.read-=this.blockSize;else for(var r=0;r<this._ints;++r)this._inBlock[r]=this._outBlock[r];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),I>0&&!g)return o.putBytes(this._partialOutput.getBytes(I-this._partialBytes)),this._partialBytes=I,!0;o.putBytes(this._partialOutput.getBytes(a-this._partialBytes)),this._partialBytes=0},A.ofb.prototype.decrypt=A.ofb.prototype.encrypt,A.ctr=function(n){n=n||{},this.name="CTR",this.cipher=n.cipher,this.blockSize=n.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=s.util.createBuffer(),this._partialBytes=0},A.ctr.prototype.start=function(n){if(!("iv"in n))throw new Error("Invalid IV parameter.");this._iv=t(n.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},A.ctr.prototype.encrypt=function(n,o,g){var a=n.length();if(a===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&a>=this.blockSize)for(var r=0;r<this._ints;++r)o.putInt32(n.getInt32()^this._outBlock[r]);else{var I=(this.blockSize-a)%this.blockSize;I>0&&(I=this.blockSize-I),this._partialOutput.clear();for(var r=0;r<this._ints;++r)this._partialOutput.putInt32(n.getInt32()^this._outBlock[r]);if(I>0&&(n.read-=this.blockSize),this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),I>0&&!g)return o.putBytes(this._partialOutput.getBytes(I-this._partialBytes)),this._partialBytes=I,!0;o.putBytes(this._partialOutput.getBytes(a-this._partialBytes)),this._partialBytes=0}e(this._inBlock)},A.ctr.prototype.decrypt=A.ctr.prototype.encrypt,A.gcm=function(n){n=n||{},this.name="GCM",this.cipher=n.cipher,this.blockSize=n.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints),this._partialOutput=s.util.createBuffer(),this._partialBytes=0,this._R=3774873600},A.gcm.prototype.start=function(n){if(!("iv"in n))throw new Error("Invalid IV parameter.");var o=s.util.createBuffer(n.iv);this._cipherLength=0;var g;if("additionalData"in n?g=s.util.createBuffer(n.additionalData):g=s.util.createBuffer(),"tagLength"in n?this._tagLength=n.tagLength:this._tagLength=128,this._tag=null,n.decrypt&&(this._tag=s.util.createBuffer(n.tag).getBytes(),this._tag.length!==this._tagLength/8))throw new Error("Authentication tag does not match tag length.");this._hashBlock=new Array(this._ints),this.tag=null,this._hashSubkey=new Array(this._ints),this.cipher.encrypt([0,0,0,0],this._hashSubkey),this.componentBits=4,this._m=this.generateHashTable(this._hashSubkey,this.componentBits);var a=o.length();if(a===12)this._j0=[o.getInt32(),o.getInt32(),o.getInt32(),1];else{for(this._j0=[0,0,0,0];o.length()>0;)this._j0=this.ghash(this._hashSubkey,this._j0,[o.getInt32(),o.getInt32(),o.getInt32(),o.getInt32()]);this._j0=this.ghash(this._hashSubkey,this._j0,[0,0].concat(i(a*8)))}this._inBlock=this._j0.slice(0),e(this._inBlock),this._partialBytes=0,g=s.util.createBuffer(g),this._aDataLength=i(g.length()*8);var r=g.length()%this.blockSize;for(r&&g.fillWithByte(0,this.blockSize-r),this._s=[0,0,0,0];g.length()>0;)this._s=this.ghash(this._hashSubkey,this._s,[g.getInt32(),g.getInt32(),g.getInt32(),g.getInt32()])},A.gcm.prototype.encrypt=function(n,o,g){var a=n.length();if(a===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&a>=this.blockSize){for(var r=0;r<this._ints;++r)o.putInt32(this._outBlock[r]^=n.getInt32());this._cipherLength+=this.blockSize}else{var I=(this.blockSize-a)%this.blockSize;I>0&&(I=this.blockSize-I),this._partialOutput.clear();for(var r=0;r<this._ints;++r)this._partialOutput.putInt32(n.getInt32()^this._outBlock[r]);if(I<=0||g){if(g){var l=a%this.blockSize;this._cipherLength+=l,this._partialOutput.truncate(this.blockSize-l)}else this._cipherLength+=this.blockSize;for(var r=0;r<this._ints;++r)this._outBlock[r]=this._partialOutput.getInt32();this._partialOutput.read-=this.blockSize}if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),I>0&&!g)return n.read-=this.blockSize,o.putBytes(this._partialOutput.getBytes(I-this._partialBytes)),this._partialBytes=I,!0;o.putBytes(this._partialOutput.getBytes(a-this._partialBytes)),this._partialBytes=0}this._s=this.ghash(this._hashSubkey,this._s,this._outBlock),e(this._inBlock)},A.gcm.prototype.decrypt=function(n,o,g){var a=n.length();if(a<this.blockSize&&!(g&&a>0))return!0;this.cipher.encrypt(this._inBlock,this._outBlock),e(this._inBlock),this._hashBlock[0]=n.getInt32(),this._hashBlock[1]=n.getInt32(),this._hashBlock[2]=n.getInt32(),this._hashBlock[3]=n.getInt32(),this._s=this.ghash(this._hashSubkey,this._s,this._hashBlock);for(var r=0;r<this._ints;++r)o.putInt32(this._outBlock[r]^this._hashBlock[r]);a<this.blockSize?this._cipherLength+=a%this.blockSize:this._cipherLength+=this.blockSize},A.gcm.prototype.afterFinish=function(n,o){var g=!0;o.decrypt&&o.overflow&&n.truncate(this.blockSize-o.overflow),this.tag=s.util.createBuffer();var a=this._aDataLength.concat(i(this._cipherLength*8));this._s=this.ghash(this._hashSubkey,this._s,a);var r=[];this.cipher.encrypt(this._j0,r);for(var I=0;I<this._ints;++I)this.tag.putInt32(this._s[I]^r[I]);return this.tag.truncate(this.tag.length()%(this._tagLength/8)),o.decrypt&&this.tag.bytes()!==this._tag&&(g=!1),g},A.gcm.prototype.multiply=function(n,o){for(var g=[0,0,0,0],a=o.slice(0),r=0;r<128;++r){var I=n[r/32|0]&1<<31-r%32;I&&(g[0]^=a[0],g[1]^=a[1],g[2]^=a[2],g[3]^=a[3]),this.pow(a,a)}return g},A.gcm.prototype.pow=function(n,o){for(var g=n[3]&1,a=3;a>0;--a)o[a]=n[a]>>>1|(n[a-1]&1)<<31;o[0]=n[0]>>>1,g&&(o[0]^=this._R)},A.gcm.prototype.tableMultiply=function(n){for(var o=[0,0,0,0],g=0;g<32;++g){var a=g/8|0,r=n[a]>>>(7-g%8)*4&15,I=this._m[g][r];o[0]^=I[0],o[1]^=I[1],o[2]^=I[2],o[3]^=I[3]}return o},A.gcm.prototype.ghash=function(n,o,g){return o[0]^=g[0],o[1]^=g[1],o[2]^=g[2],o[3]^=g[3],this.tableMultiply(o)},A.gcm.prototype.generateHashTable=function(n,o){for(var g=8/o,a=4*g,r=16*g,I=new Array(r),l=0;l<r;++l){var h=[0,0,0,0],B=l/a|0,E=(a-1-l%a)*o;h[B]=1<<o-1<<E,I[l]=this.generateSubHashTable(this.multiply(h,n),o)}return I},A.gcm.prototype.generateSubHashTable=function(n,o){var g=1<<o,a=g>>>1,r=new Array(g);r[a]=n.slice(0);for(var I=a>>>1;I>0;)this.pow(r[2*I],r[I]=[]),I>>=1;for(I=2;I<a;){for(var l=1;l<I;++l){var h=r[I],B=r[l];r[I+l]=[h[0]^B[0],h[1]^B[1],h[2]^B[2],h[3]^B[3]]}I*=2}for(r[0]=[0,0,0,0],I=a+1;I<g;++I){var E=r[I^a];r[I]=[n[0]^E[0],n[1]^E[1],n[2]^E[2],n[3]^E[3]]}return r};function t(n,o){if(typeof n=="string"&&(n=s.util.createBuffer(n)),s.util.isArray(n)&&n.length>4){var g=n;n=s.util.createBuffer();for(var a=0;a<g.length;++a)n.putByte(g[a])}if(n.length()<o)throw new Error("Invalid IV length; got "+n.length()+" bytes and expected "+o+" bytes.");if(!s.util.isArray(n)){for(var r=[],I=o/4,a=0;a<I;++a)r.push(n.getInt32());n=r}return n}function e(n){n[n.length-1]=n[n.length-1]+1&4294967295}function i(n){return[n/4294967296|0,n&4294967295]}return vy.exports}var _y,jW;function Qa(){if(jW)return _y;jW=1;var s=Pt();zy(),KW(),Ut(),_y=s.aes=s.aes||{},s.aes.startEncrypting=function(B,E,c,Q){var C=h({key:B,output:c,decrypt:!1,mode:Q});return C.start(E),C},s.aes.createEncryptionCipher=function(B,E){return h({key:B,output:null,decrypt:!1,mode:E})},s.aes.startDecrypting=function(B,E,c,Q){var C=h({key:B,output:c,decrypt:!0,mode:Q});return C.start(E),C},s.aes.createDecryptionCipher=function(B,E){return h({key:B,output:null,decrypt:!0,mode:E})},s.aes.Algorithm=function(B,E){t||r();var c=this;c.name=B,c.mode=new E({blockSize:16,cipher:{encrypt:function(Q,C){return l(c._w,Q,C,!1)},decrypt:function(Q,C){return l(c._w,Q,C,!0)}}}),c._init=!1},s.aes.Algorithm.prototype.initialize=function(B){if(!this._init){var E=B.key,c;if(typeof E=="string"&&(E.length===16||E.length===24||E.length===32))E=s.util.createBuffer(E);else if(s.util.isArray(E)&&(E.length===16||E.length===24||E.length===32)){c=E,E=s.util.createBuffer();for(var Q=0;Q<c.length;++Q)E.putByte(c[Q])}if(!s.util.isArray(E)){c=E,E=[];var C=c.length();if(C===16||C===24||C===32){C=C>>>2;for(var Q=0;Q<C;++Q)E.push(c.getInt32())}}if(!s.util.isArray(E)||!(E.length===4||E.length===6||E.length===8))throw new Error("Invalid key parameter.");var d=this.mode.name,M=["CFB","OFB","CTR","GCM"].indexOf(d)!==-1;this._w=I(E,B.decrypt&&!M),this._init=!0}},s.aes._expandKey=function(B,E){return t||r(),I(B,E)},s.aes._updateBlock=l,A("AES-ECB",s.cipher.modes.ecb),A("AES-CBC",s.cipher.modes.cbc),A("AES-CFB",s.cipher.modes.cfb),A("AES-OFB",s.cipher.modes.ofb),A("AES-CTR",s.cipher.modes.ctr),A("AES-GCM",s.cipher.modes.gcm);function A(B,E){var c=function(){return new s.aes.Algorithm(B,E)};s.cipher.registerAlgorithm(B,c)}var t=!1,e=4,i,n,o,g,a;function r(){t=!0,o=[0,1,2,4,8,16,32,64,128,27,54];for(var B=new Array(256),E=0;E<128;++E)B[E]=E<<1,B[E+128]=E+128<<1^283;i=new Array(256),n=new Array(256),g=new Array(4),a=new Array(4);for(var E=0;E<4;++E)g[E]=new Array(256),a[E]=new Array(256);for(var c=0,Q=0,C,d,M,y,w,D,p,E=0;E<256;++E){y=Q^Q<<1^Q<<2^Q<<3^Q<<4,y=y>>8^y&255^99,i[c]=y,n[y]=c,w=B[y],C=B[c],d=B[C],M=B[d],D=w<<24^y<<16^y<<8^(y^w),p=(C^d^M)<<24^(c^M)<<16^(c^d^M)<<8^(c^C^M);for(var f=0;f<4;++f)g[f][c]=D,a[f][y]=p,D=D<<24|D>>>8,p=p<<24|p>>>8;c===0?c=Q=1:(c=C^B[B[B[C^M]]],Q^=B[B[Q]])}}function I(B,E){for(var c=B.slice(0),Q,C=1,d=c.length,M=d+6+1,y=e*M,w=d;w<y;++w)Q=c[w-1],w%d===0?(Q=i[Q>>>16&255]<<24^i[Q>>>8&255]<<16^i[Q&255]<<8^i[Q>>>24]^o[C]<<24,C++):d>6&&w%d===4&&(Q=i[Q>>>24]<<24^i[Q>>>16&255]<<16^i[Q>>>8&255]<<8^i[Q&255]),c[w]=c[w-d]^Q;if(E){var D,p=a[0],f=a[1],u=a[2],Y=a[3],b=c.slice(0);y=c.length;for(var w=0,m=y-e;w<y;w+=e,m-=e)if(w===0||w===y-e)b[w]=c[m],b[w+1]=c[m+3],b[w+2]=c[m+2],b[w+3]=c[m+1];else for(var T=0;T<e;++T)D=c[m+T],b[w+(3&-T)]=p[i[D>>>24]]^f[i[D>>>16&255]]^u[i[D>>>8&255]]^Y[i[D&255]];c=b}return c}function l(B,E,c,Q){var C=B.length/4-1,d,M,y,w,D;Q?(d=a[0],M=a[1],y=a[2],w=a[3],D=n):(d=g[0],M=g[1],y=g[2],w=g[3],D=i);var p,f,u,Y,b,m,T;p=E[0]^B[0],f=E[Q?3:1]^B[1],u=E[2]^B[2],Y=E[Q?1:3]^B[3];for(var F=3,j=1;j<C;++j)b=d[p>>>24]^M[f>>>16&255]^y[u>>>8&255]^w[Y&255]^B[++F],m=d[f>>>24]^M[u>>>16&255]^y[Y>>>8&255]^w[p&255]^B[++F],T=d[u>>>24]^M[Y>>>16&255]^y[p>>>8&255]^w[f&255]^B[++F],Y=d[Y>>>24]^M[p>>>16&255]^y[f>>>8&255]^w[u&255]^B[++F],p=b,f=m,u=T;c[0]=D[p>>>24]<<24^D[f>>>16&255]<<16^D[u>>>8&255]<<8^D[Y&255]^B[++F],c[Q?3:1]=D[f>>>24]<<24^D[u>>>16&255]<<16^D[Y>>>8&255]<<8^D[p&255]^B[++F],c[2]=D[u>>>24]<<24^D[Y>>>16&255]<<16^D[p>>>8&255]<<8^D[f&255]^B[++F],c[Q?1:3]=D[Y>>>24]<<24^D[p>>>16&255]<<16^D[f>>>8&255]<<8^D[u&255]^B[++F]}function h(B){B=B||{};var E=(B.mode||"CBC").toUpperCase(),c="AES-"+E,Q;B.decrypt?Q=s.cipher.createDecipher(c,B.key):Q=s.cipher.createCipher(c,B.key);var C=Q.start;return Q.start=function(d,M){var y=null;M instanceof s.util.ByteBuffer&&(y=M,M={}),M=M||{},M.output=y,M.iv=d,C.call(Q,M)},Q}return _y}var qy={exports:{}},$y={exports:{}},Ap={exports:{}},RW;function da(){if(RW)return Ap.exports;RW=1;var s=Pt();s.pki=s.pki||{};var A=Ap.exports=s.pki.oids=s.oids=s.oids||{};function t(i,n){A[i]=n,A[n]=i}function e(i,n){A[i]=n}return t("1.2.840.113549.1.1.1","rsaEncryption"),t("1.2.840.113549.1.1.4","md5WithRSAEncryption"),t("1.2.840.113549.1.1.5","sha1WithRSAEncryption"),t("1.2.840.113549.1.1.7","RSAES-OAEP"),t("1.2.840.113549.1.1.8","mgf1"),t("1.2.840.113549.1.1.9","pSpecified"),t("1.2.840.113549.1.1.10","RSASSA-PSS"),t("1.2.840.113549.1.1.11","sha256WithRSAEncryption"),t("1.2.840.113549.1.1.12","sha384WithRSAEncryption"),t("1.2.840.113549.1.1.13","sha512WithRSAEncryption"),t("1.3.101.112","EdDSA25519"),t("1.2.840.10040.4.3","dsa-with-sha1"),t("1.3.14.3.2.7","desCBC"),t("1.3.14.3.2.26","sha1"),t("1.3.14.3.2.29","sha1WithRSASignature"),t("2.16.840.1.101.3.4.2.1","sha256"),t("2.16.840.1.101.3.4.2.2","sha384"),t("2.16.840.1.101.3.4.2.3","sha512"),t("2.16.840.1.101.3.4.2.4","sha224"),t("2.16.840.1.101.3.4.2.5","sha512-224"),t("2.16.840.1.101.3.4.2.6","sha512-256"),t("1.2.840.113549.2.2","md2"),t("1.2.840.113549.2.5","md5"),t("1.2.840.113549.1.7.1","data"),t("1.2.840.113549.1.7.2","signedData"),t("1.2.840.113549.1.7.3","envelopedData"),t("1.2.840.113549.1.7.4","signedAndEnvelopedData"),t("1.2.840.113549.1.7.5","digestedData"),t("1.2.840.113549.1.7.6","encryptedData"),t("1.2.840.113549.1.9.1","emailAddress"),t("1.2.840.113549.1.9.2","unstructuredName"),t("1.2.840.113549.1.9.3","contentType"),t("1.2.840.113549.1.9.4","messageDigest"),t("1.2.840.113549.1.9.5","signingTime"),t("1.2.840.113549.1.9.6","counterSignature"),t("1.2.840.113549.1.9.7","challengePassword"),t("1.2.840.113549.1.9.8","unstructuredAddress"),t("1.2.840.113549.1.9.14","extensionRequest"),t("1.2.840.113549.1.9.20","friendlyName"),t("1.2.840.113549.1.9.21","localKeyId"),t("1.2.840.113549.1.9.22.1","x509Certificate"),t("1.2.840.113549.1.12.10.1.1","keyBag"),t("1.2.840.113549.1.12.10.1.2","pkcs8ShroudedKeyBag"),t("1.2.840.113549.1.12.10.1.3","certBag"),t("1.2.840.113549.1.12.10.1.4","crlBag"),t("1.2.840.113549.1.12.10.1.5","secretBag"),t("1.2.840.113549.1.12.10.1.6","safeContentsBag"),t("1.2.840.113549.1.5.13","pkcs5PBES2"),t("1.2.840.113549.1.5.12","pkcs5PBKDF2"),t("1.2.840.113549.1.12.1.1","pbeWithSHAAnd128BitRC4"),t("1.2.840.113549.1.12.1.2","pbeWithSHAAnd40BitRC4"),t("1.2.840.113549.1.12.1.3","pbeWithSHAAnd3-KeyTripleDES-CBC"),t("1.2.840.113549.1.12.1.4","pbeWithSHAAnd2-KeyTripleDES-CBC"),t("1.2.840.113549.1.12.1.5","pbeWithSHAAnd128BitRC2-CBC"),t("1.2.840.113549.1.12.1.6","pbewithSHAAnd40BitRC2-CBC"),t("1.2.840.113549.2.7","hmacWithSHA1"),t("1.2.840.113549.2.8","hmacWithSHA224"),t("1.2.840.113549.2.9","hmacWithSHA256"),t("1.2.840.113549.2.10","hmacWithSHA384"),t("1.2.840.113549.2.11","hmacWithSHA512"),t("1.2.840.113549.3.7","des-EDE3-CBC"),t("2.16.840.1.101.3.4.1.2","aes128-CBC"),t("2.16.840.1.101.3.4.1.22","aes192-CBC"),t("2.16.840.1.101.3.4.1.42","aes256-CBC"),t("2.5.4.3","commonName"),t("2.5.4.4","surname"),t("2.5.4.5","serialNumber"),t("2.5.4.6","countryName"),t("2.5.4.7","localityName"),t("2.5.4.8","stateOrProvinceName"),t("2.5.4.9","streetAddress"),t("2.5.4.10","organizationName"),t("2.5.4.11","organizationalUnitName"),t("2.5.4.12","title"),t("2.5.4.13","description"),t("2.5.4.15","businessCategory"),t("2.5.4.17","postalCode"),t("2.5.4.42","givenName"),t("2.5.4.65","pseudonym"),t("1.3.6.1.4.1.311.60.2.1.2","jurisdictionOfIncorporationStateOrProvinceName"),t("1.3.6.1.4.1.311.60.2.1.3","jurisdictionOfIncorporationCountryName"),t("2.16.840.1.113730.1.1","nsCertType"),t("2.16.840.1.113730.1.13","nsComment"),e("2.5.29.1","authorityKeyIdentifier"),e("2.5.29.2","keyAttributes"),e("2.5.29.3","certificatePolicies"),e("2.5.29.4","keyUsageRestriction"),e("2.5.29.5","policyMapping"),e("2.5.29.6","subtreesConstraint"),e("2.5.29.7","subjectAltName"),e("2.5.29.8","issuerAltName"),e("2.5.29.9","subjectDirectoryAttributes"),e("2.5.29.10","basicConstraints"),e("2.5.29.11","nameConstraints"),e("2.5.29.12","policyConstraints"),e("2.5.29.13","basicConstraints"),t("2.5.29.14","subjectKeyIdentifier"),t("2.5.29.15","keyUsage"),e("2.5.29.16","privateKeyUsagePeriod"),t("2.5.29.17","subjectAltName"),t("2.5.29.18","issuerAltName"),t("2.5.29.19","basicConstraints"),e("2.5.29.20","cRLNumber"),e("2.5.29.21","cRLReason"),e("2.5.29.22","expirationDate"),e("2.5.29.23","instructionCode"),e("2.5.29.24","invalidityDate"),e("2.5.29.25","cRLDistributionPoints"),e("2.5.29.26","issuingDistributionPoint"),e("2.5.29.27","deltaCRLIndicator"),e("2.5.29.28","issuingDistributionPoint"),e("2.5.29.29","certificateIssuer"),e("2.5.29.30","nameConstraints"),t("2.5.29.31","cRLDistributionPoints"),t("2.5.29.32","certificatePolicies"),e("2.5.29.33","policyMappings"),e("2.5.29.34","policyConstraints"),t("2.5.29.35","authorityKeyIdentifier"),e("2.5.29.36","policyConstraints"),t("2.5.29.37","extKeyUsage"),e("2.5.29.46","freshestCRL"),e("2.5.29.54","inhibitAnyPolicy"),t("1.3.6.1.4.1.11129.2.4.2","timestampList"),t("1.3.6.1.5.5.7.1.1","authorityInfoAccess"),t("1.3.6.1.5.5.7.3.1","serverAuth"),t("1.3.6.1.5.5.7.3.2","clientAuth"),t("1.3.6.1.5.5.7.3.3","codeSigning"),t("1.3.6.1.5.5.7.3.4","emailProtection"),t("1.3.6.1.5.5.7.3.8","timeStamping"),Ap.exports}var ZW;function Pn(){if(ZW)return $y.exports;ZW=1;var s=Pt();Ut(),da();var A=$y.exports=s.asn1=s.asn1||{};A.Class={UNIVERSAL:0,APPLICATION:64,CONTEXT_SPECIFIC:128,PRIVATE:192},A.Type={NONE:0,BOOLEAN:1,INTEGER:2,BITSTRING:3,OCTETSTRING:4,NULL:5,OID:6,ODESC:7,EXTERNAL:8,REAL:9,ENUMERATED:10,EMBEDDED:11,UTF8:12,ROID:13,SEQUENCE:16,SET:17,PRINTABLESTRING:19,IA5STRING:22,UTCTIME:23,GENERALIZEDTIME:24,BMPSTRING:30},A.maxDepth=256,A.create=function(o,g,a,r,I){if(s.util.isArray(r)){for(var l=[],h=0;h<r.length;++h)r[h]!==void 0&&l.push(r[h]);r=l}var B={tagClass:o,type:g,constructed:a,composed:a||s.util.isArray(r),value:r};return I&&"bitStringContents"in I&&(B.bitStringContents=I.bitStringContents,B.original=A.copy(B)),B},A.copy=function(o,g){var a;if(s.util.isArray(o)){a=[];for(var r=0;r<o.length;++r)a.push(A.copy(o[r],g));return a}return typeof o=="string"?o:(a={tagClass:o.tagClass,type:o.type,constructed:o.constructed,composed:o.composed,value:A.copy(o.value,g)},g&&!g.excludeBitStringContents&&(a.bitStringContents=o.bitStringContents),a)},A.equals=function(o,g,a){if(s.util.isArray(o)){if(!s.util.isArray(g)||o.length!==g.length)return!1;for(var r=0;r<o.length;++r)if(!A.equals(o[r],g[r]))return!1;return!0}if(typeof o!=typeof g)return!1;if(typeof o=="string")return o===g;var I=o.tagClass===g.tagClass&&o.type===g.type&&o.constructed===g.constructed&&o.composed===g.composed&&A.equals(o.value,g.value);return a&&a.includeBitStringContents&&(I=I&&o.bitStringContents===g.bitStringContents),I},A.getBerValueLength=function(o){var g=o.getByte();if(g!==128){var a,r=g&128;return r?a=o.getInt((g&127)<<3):a=g,a}};function t(o,g,a){if(a>g){var r=new Error("Too few bytes to parse DER.");throw r.available=o.length(),r.remaining=g,r.requested=a,r}}var e=function(o,g){var a=o.getByte();if(g--,a!==128){var r,I=a&128;if(!I)r=a;else{var l=a&127;t(o,g,l),r=o.getInt(l<<3)}if(r<0)throw new Error("Negative length: "+r);return r}};A.fromDer=function(o,g){g===void 0&&(g={strict:!0,parseAllBytes:!0,decodeBitStrings:!0}),typeof g=="boolean"&&(g={strict:g,parseAllBytes:!0,decodeBitStrings:!0}),"strict"in g||(g.strict=!0),"parseAllBytes"in g||(g.parseAllBytes=!0),"decodeBitStrings"in g||(g.decodeBitStrings=!0),"maxDepth"in g||(g.maxDepth=A.maxDepth),typeof o=="string"&&(o=s.util.createBuffer(o));var a=o.length(),r=i(o,o.length(),0,g);if(g.parseAllBytes&&o.length()!==0){var I=new Error("Unparsed DER bytes remain after ASN.1 parsing.");throw I.byteCount=a,I.remaining=o.length(),I}return r};function i(o,g,a,r){if(a>=r.maxDepth)throw new Error("ASN.1 parsing error: Max depth exceeded.");var I;t(o,g,2);var l=o.getByte();g--;var h=l&192,B=l&31;I=o.length();var E=e(o,g);if(g-=I-o.length(),E!==void 0&&E>g){if(r.strict){var c=new Error("Too few bytes to read ASN.1 value.");throw c.available=o.length(),c.remaining=g,c.requested=E,c}E=g}var Q,C,d=(l&32)===32;if(d)if(Q=[],E===void 0)for(;;){if(t(o,g,2),o.bytes(2)==="\0\0"){o.getBytes(2),g-=2;break}I=o.length(),Q.push(i(o,g,a+1,r)),g-=I-o.length()}else for(;E>0;)I=o.length(),Q.push(i(o,E,a+1,r)),g-=I-o.length(),E-=I-o.length();if(Q===void 0&&h===A.Class.UNIVERSAL&&B===A.Type.BITSTRING&&(C=o.bytes(E)),Q===void 0&&r.decodeBitStrings&&h===A.Class.UNIVERSAL&&B===A.Type.BITSTRING&&E>1){var M=o.read,y=g,w=0;if(B===A.Type.BITSTRING&&(t(o,g,1),w=o.getByte(),g--),w===0)try{I=o.length();var D={strict:!0,decodeBitStrings:!0},p=i(o,g,a+1,D),f=I-o.length();g-=f,B==A.Type.BITSTRING&&f++;var u=p.tagClass;f===E&&(u===A.Class.UNIVERSAL||u===A.Class.CONTEXT_SPECIFIC)&&(Q=[p])}catch{}Q===void 0&&(o.read=M,g=y)}if(Q===void 0){if(E===void 0){if(r.strict)throw new Error("Non-constructed ASN.1 object of indefinite length.");E=g}if(B===A.Type.BMPSTRING)for(Q="";E>0;E-=2)t(o,g,2),Q+=String.fromCharCode(o.getInt16()),g-=2;else Q=o.getBytes(E),g-=E}var Y=C===void 0?null:{bitStringContents:C};return A.create(h,B,d,Q,Y)}A.toDer=function(o){var g=s.util.createBuffer(),a=o.tagClass|o.type,r=s.util.createBuffer(),I=!1;if("bitStringContents"in o&&(I=!0,o.original&&(I=A.equals(o,o.original))),I)r.putBytes(o.bitStringContents);else if(o.composed){o.constructed?a|=32:r.putByte(0);for(var l=0;l<o.value.length;++l)o.value[l]!==void 0&&r.putBuffer(A.toDer(o.value[l]))}else if(o.type===A.Type.BMPSTRING)for(var l=0;l<o.value.length;++l)r.putInt16(o.value.charCodeAt(l));else o.type===A.Type.INTEGER&&o.value.length>1&&(o.value.charCodeAt(0)===0&&(o.value.charCodeAt(1)&128)===0||o.value.charCodeAt(0)===255&&(o.value.charCodeAt(1)&128)===128)?r.putBytes(o.value.substr(1)):r.putBytes(o.value);if(g.putByte(a),r.length()<=127)g.putByte(r.length()&127);else{var h=r.length(),B="";do B+=String.fromCharCode(h&255),h=h>>>8;while(h>0);g.putByte(B.length|128);for(var l=B.length-1;l>=0;--l)g.putByte(B.charCodeAt(l))}return g.putBuffer(r),g},A.oidToDer=function(o){var g=o.split("."),a=s.util.createBuffer();a.putByte(40*parseInt(g[0],10)+parseInt(g[1],10));for(var r,I,l,h,B=2;B<g.length;++B){if(r=!0,I=[],l=parseInt(g[B],10),l>4294967295)throw new Error("OID value too large; max is 32-bits.");do h=l&127,l=l>>>7,r||(h|=128),I.push(h),r=!1;while(l>0);for(var E=I.length-1;E>=0;--E)a.putByte(I[E])}return a},A.derToOid=function(o){var g;typeof o=="string"&&(o=s.util.createBuffer(o));var a=o.getByte();g=Math.floor(a/40)+"."+a%40;for(var r=0;o.length()>0;){if(r>70368744177663)throw new Error("OID value too large; max is 53-bits.");a=o.getByte(),r=r*128,a&128?r+=a&127:(g+="."+(r+a),r=0)}return g},A.utcTimeToDate=function(o){var g=new Date,a=parseInt(o.substr(0,2),10);a=a>=50?1900+a:2e3+a;var r=parseInt(o.substr(2,2),10)-1,I=parseInt(o.substr(4,2),10),l=parseInt(o.substr(6,2),10),h=parseInt(o.substr(8,2),10),B=0;if(o.length>11){var E=o.charAt(10),c=10;E!=="+"&&E!=="-"&&(B=parseInt(o.substr(10,2),10),c+=2)}if(g.setUTCFullYear(a,r,I),g.setUTCHours(l,h,B,0),c&&(E=o.charAt(c),E==="+"||E==="-")){var Q=parseInt(o.substr(c+1,2),10),C=parseInt(o.substr(c+4,2),10),d=Q*60+C;d*=6e4,E==="+"?g.setTime(+g-d):g.setTime(+g+d)}return g},A.generalizedTimeToDate=function(o){var g=new Date,a=parseInt(o.substr(0,4),10),r=parseInt(o.substr(4,2),10)-1,I=parseInt(o.substr(6,2),10),l=parseInt(o.substr(8,2),10),h=parseInt(o.substr(10,2),10),B=parseInt(o.substr(12,2),10),E=0,c=0,Q=!1;o.charAt(o.length-1)==="Z"&&(Q=!0);var C=o.length-5,d=o.charAt(C);if(d==="+"||d==="-"){var M=parseInt(o.substr(C+1,2),10),y=parseInt(o.substr(C+4,2),10);c=M*60+y,c*=6e4,d==="+"&&(c*=-1),Q=!0}return o.charAt(14)==="."&&(E=parseFloat(o.substr(14),10)*1e3),Q?(g.setUTCFullYear(a,r,I),g.setUTCHours(l,h,B,E),g.setTime(+g+c)):(g.setFullYear(a,r,I),g.setHours(l,h,B,E)),g},A.dateToUtcTime=function(o){if(typeof o=="string")return o;var g="",a=[];a.push((""+o.getUTCFullYear()).substr(2)),a.push(""+(o.getUTCMonth()+1)),a.push(""+o.getUTCDate()),a.push(""+o.getUTCHours()),a.push(""+o.getUTCMinutes()),a.push(""+o.getUTCSeconds());for(var r=0;r<a.length;++r)a[r].length<2&&(g+="0"),g+=a[r];return g+="Z",g},A.dateToGeneralizedTime=function(o){if(typeof o=="string")return o;var g="",a=[];a.push(""+o.getUTCFullYear()),a.push(""+(o.getUTCMonth()+1)),a.push(""+o.getUTCDate()),a.push(""+o.getUTCHours()),a.push(""+o.getUTCMinutes()),a.push(""+o.getUTCSeconds());for(var r=0;r<a.length;++r)a[r].length<2&&(g+="0"),g+=a[r];return g+="Z",g},A.integerToDer=function(o){var g=s.util.createBuffer();if(o>=-128&&o<128)return g.putSignedInt(o,8);if(o>=-32768&&o<32768)return g.putSignedInt(o,16);if(o>=-8388608&&o<8388608)return g.putSignedInt(o,24);if(o>=-2147483648&&o<2147483648)return g.putSignedInt(o,32);var a=new Error("Integer too large; max is 32-bits.");throw a.integer=o,a},A.derToInteger=function(o){typeof o=="string"&&(o=s.util.createBuffer(o));var g=o.length()*8;if(g>32)throw new Error("Integer too large; max is 32-bits.");return o.getSignedInt(g)},A.validate=function(o,g,a,r){var I=!1;if((o.tagClass===g.tagClass||typeof g.tagClass>"u")&&(o.type===g.type||typeof g.type>"u"))if(o.constructed===g.constructed||typeof g.constructed>"u"){if(I=!0,g.value&&s.util.isArray(g.value))for(var l=0,h=0;I&&h<g.value.length;++h){var B=g.value[h];I=!!B.optional;var E=o.value[l];if(!E){B.optional||(I=!1,r&&r.push("["+g.name+'] Missing required element. Expected tag class "'+B.tagClass+'", type "'+B.type+'"'));continue}var c=typeof B.tagClass<"u"&&typeof B.type<"u";if(c&&(E.tagClass!==B.tagClass||E.type!==B.type))if(B.optional){I=!0;continue}else{I=!1,r&&r.push("["+g.name+"] Tag mismatch. Expected ("+B.tagClass+","+B.type+"), got ("+E.tagClass+","+E.type+")");break}var Q=A.validate(E,B,a,r);if(Q)++l,I=!0;else if(B.optional)I=!0;else{I=!1;break}}if(I&&a&&(g.capture&&(a[g.capture]=o.value),g.captureAsn1&&(a[g.captureAsn1]=o),g.captureBitStringContents&&"bitStringContents"in o&&(a[g.captureBitStringContents]=o.bitStringContents),g.captureBitStringValue&&"bitStringContents"in o))if(o.bitStringContents.length<2)a[g.captureBitStringValue]="";else{var C=o.bitStringContents.charCodeAt(0);if(C!==0)throw new Error("captureBitStringValue only supported for zero unused bits");a[g.captureBitStringValue]=o.bitStringContents.slice(1)}}else r&&r.push("["+g.name+'] Expected constructed "'+g.constructed+'", got "'+o.constructed+'"');else r&&(o.tagClass!==g.tagClass&&r.push("["+g.name+'] Expected tag class "'+g.tagClass+'", got "'+o.tagClass+'"'),o.type!==g.type&&r.push("["+g.name+'] Expected type "'+g.type+'", got "'+o.type+'"'));return I};var n=/[^\\u0000-\\u00ff]/;return A.prettyPrint=function(o,g,a){var r="";g=g||0,a=a||2,g>0&&(r+=`
@@ -6618,4 +6618,4 @@ void main() {
6618
6618
  Private-Lines: `+B+`\r
6619
6619
  `,I+=c;var w=i("putty-private-key-file-mac-key",o),D=s.util.createBuffer();e(D,a),e(D,r),e(D,g),D.putInt32(l.length()),D.putBuffer(l),D.putInt32(E.length()),D.putBuffer(E);var p=s.hmac.create();return p.start("sha1",w),p.update(D.bytes()),I+=`\r
6620
6620
  Private-MAC: `+p.digest().toHex()+`\r
6621
- `,I},A.publicKeyToOpenSSH=function(n,o){var g="ssh-rsa";o=o||"";var a=s.util.createBuffer();return e(a,g),t(a,n.e),t(a,n.n),g+" "+s.util.encode64(a.bytes())+" "+o},A.privateKeyToOpenSSH=function(n,o){return o?s.pki.encryptRsaPrivateKey(n,o,{legacy:!0,algorithm:"aes128"}):s.pki.privateKeyToPem(n)},A.getPublicKeyFingerprint=function(n,o){o=o||{};var g=o.md||s.md.md5.create(),a="ssh-rsa",r=s.util.createBuffer();e(r,a),t(r,n.e),t(r,n.n),g.start(),g.update(r.getBytes());var I=g.digest();if(o.encoding==="hex"){var l=I.toHex();return o.delimiter?l.match(/.{2}/g).join(o.delimiter):l}else{if(o.encoding==="binary")return I.getBytes();if(o.encoding)throw new Error('Unknown encoding "'+o.encoding+'".')}return I};function t(n,o){var g=o.toString(16);g[0]>="8"&&(g="00"+g);var a=s.util.hexToBytes(g);n.putInt32(a.length),n.putBytes(a)}function e(n,o){n.putInt32(o.length),n.putString(o)}function i(){for(var n=s.md.sha1.create(),o=arguments.length,g=0;g<o;++g)n.update(arguments[g]);return n.digest()}return Tp.exports}var Kp,FG;function h3(){return FG||(FG=1,Kp=Pt(),Qa(),n3(),Pn(),zy(),dQ(),g3(),xB(),a3(),r3(),I3(),IG(),Ip(),sI(),tG(),EG(),l3(),QG(),iG(),LW(),up(),An(),_W(),B3(),fG(),Ut()),Kp}var jp=h3();const C3="evtrsa1",Rp=new Map;function bG(s){return s.replace(/\/+$/,"")}function E3(s){return new TextEncoder().encode(s)}function wQ(s){let A="";return s.forEach(t=>{A+=String.fromCharCode(t)}),btoa(A).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}async function c3(s,A){const t=typeof AbortController<"u"?new AbortController:void 0,e=t?setTimeout(()=>t.abort(),A):void 0;try{const i=await fetch(s,{method:"GET",headers:{Accept:"application/json"},signal:t?.signal}),n=await i.json().catch(()=>({}));if(!i.ok){const o=n?.error?.message??n?.message??`ViewToken public key request failed with status ${i.status}`;throw new Error(o)}return n}finally{e!=null&&clearTimeout(e)}}function Zp(s){const A=globalThis.crypto;if(!A?.getRandomValues)throw new Error("[BimEngine] crypto.getRandomValues is required to encrypt viewToken");return A.getRandomValues(new Uint8Array(s))}function Q3(s){let A="";return s.forEach(t=>{A+=String.fromCharCode(t)}),A}function d3(s){const A=new Uint8Array(s.length);for(let t=0;t<s.length;t+=1)A[t]=s.charCodeAt(t)&255;return A}async function f3(s,A){const t=`${bG(s)}/models/view-token/public-key`,e=await c3(t,A);if(e.algorithm!=="RSA-OAEP-256"||!e.publicKey)throw new Error("[BimEngine] OpenAPI returned an invalid viewToken public key");return jp.pki.publicKeyFromPem(e.publicKey)}function M3(s,A){const t=bG(s),e=Rp.get(t);if(e)return e;const i=f3(s,A).catch(n=>{throw Rp.delete(t),n});return Rp.set(t,i),i}async function y3(s,A,t){const e=await M3(s,t),i=Zp(32),n=Zp(12),o=Zp(16),g=JSON.stringify({viewToken:A,timestamp:Date.now(),nonce:wQ(o)}),a=e.encrypt(Q3(i),"RSA-OAEP",{md:jp.md.sha256.create(),mgf1:{md:jp.md.sha256.create()}}),r=GE(i,n).encrypt(E3(g));return[C3,wQ(d3(a)),wQ(n),wQ(r)].join(".")}function p3(s){return s.replace(/\/+$/,"")}async function D3(s,A,t){const e=typeof AbortController<"u"?new AbortController:void 0,i=e?setTimeout(()=>e.abort(),t):void 0;try{const n=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(A),signal:e?.signal}),o=await n.json().catch(()=>({}));if(!n.ok){const g=o?.error?.message??o?.message??`ViewToken resolve failed with status ${n.status}`;throw new Error(g)}return o}finally{i!=null&&clearTimeout(i)}}function w3(s){switch(s){case"2d":return"cad_model";case"720":return"panorama";case"gis":return"gis_scene";case"gaussian":return"gaussian_model";case"3d":default:return"model"}}function u3(s){return{models:[{modelType:s.toLowerCase().endsWith(".json")?"3dtiles":"glb",url:s}]}}function m3(s,A){return{applicationId:0,engineType:A,assetCategory:w3(A),url:s,urls:[s],info:A==="gis"?u3(s):void 0}}async function P3(s,A,t){const e=s?.sdkAuth;if(!e?.endpoint)return m3(A,t);let i;(e.token||e.appId&&e.appKey&&e.appSecret)&&(i=(await e3(s,t))?.sdkToken);const o={viewToken:await y3(e.endpoint,A,e.timeoutMs??8e3),engineType:t};return i&&(o.sdkToken=i),D3(`${p3(e.endpoint)}/models/view-token/resolve`,o,e.timeoutMs??8e3)}const S3=Object.freeze({maxTextureSize:2048,samples:1}),Y3=Object.freeze({maxTextureSize:3096,samples:2}),F3=Object.freeze({maxTextureSize:4096,samples:4});function b3(s){return typeof s!="number"||!Number.isFinite(s)||s<=4?S3:s<=6?Y3:F3}class WG{options;mobileMemoryProfile;deviceType;animationId=null;isDisposed=!1;isRenderingPaused=!1;suppressComposerRenderWhenFree=!1;pendingComposerRender=!0;controlsEnabledBeforePause=!0;boundControl=null;controlEventHandlers=null;animate;onWindowResize;_fpsFrameCount=0;_fpsLastCheck=0;_fpsLastSwitch=0;_lowFpsCount=0;_highFpsCount=0;frameLockEnabled=!0;_idleFrameInterval=1e3/1;_lastIdleFrameTime=0;_idleFrameRateExemptionReasons=new Set;_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;search;modelMapperBatch;modelEdge;nodeBox;pathRoaming;hoverHighLight;minMap;grid;level;issueReport;text;hdr;ground;skyManager;linkElement2d3d;linkView2d3d;oneClickEncoding;fabricDraw;drawingPin;modelLink3d;label;annotation3d;calibration;modelPlace;modelComparison;modelExplode;materialTool;pathDraw;rxQuotaListMapper;filterLoaderModel;models=[];reactBoundingClientRect={left:0,top:0};version=UB;versionEl=null;container;constructor(A){if(window.THREE=Cm,O9(),this.options=A,this.mobileMemoryProfile=b3(A.limit_memory),this.container=document.getElementById(A.containerId),!this.container)throw new Error(`Container ${A.containerId} not found`);if(this.rxQuotaListMapper=new N8(this),this.filterLoaderModel=new O8(this),this.engineModelModule=new uV(this),this.engineModelModule.init(),this.deviceModule=new kU(this),this.deviceType=this.deviceModule.getDeviceType(),this.cameraModule=new Ee(this),this.sceneModule=new XU(this),this.scene=this.sceneModule.scene,this.renderModule=new _U(this),this.renderer=this.renderModule.createRenderer(),this.camera=this.cameraModule.perspectiveCamera,this.scene.camera=this.camera,this.renderer){const o=this.renderer;o.interactionCullingEnabled=!0,o.interactionActive=!1,o.interactionRenderScene=this.scene,o.interactionFrameBudgetMs=this.options.interactionFrameBudgetMs??6,o.interactionSkipShadows=this.options.interactionSkipShadows??!0}this.controlModule=new gJ(this),this.controlModule.switchDefaultMode(),this.controls=this.controlModule.orbitControls,this.clipping=new EO(this),this.clipping.init(),this.composerModule=new MJ(this),this.composerModule.init(),this.events=new $4;const t=this.events.trigger.bind(this.events);this.events.trigger=((o,g)=>{t(o,g),String(o)!==String(ce.EngineBusy)&&this.requestComposerRender()}),this.engineStatus=new q4(this),this.engineStatus.init(),this.loaderModule=new ci(this),this.lightModule=new fV(this),this.lightModule.init(),this.viewCube=new JV(this),this.viewCube.init(),this.options.showViewCube==!1&&this.viewCube.hide(),this.octreeBox=xV(this),this.rangeScale=new kV(this),this.rangeScale.init(),this.setting=new BH(this),this.engineModelModule.init(),this.handelBehaved=ef(this),this.modelMapperBatch=new pO(this),this.measure=new yH(this),this.modelToolModule=new yV(this),this.modelLink3d=new xv(this,this.options.linkOptions??{}),this.modelLink3d.init(),this.modelProperties=new dO(this),this.search=new yO(this),this.interactionModule=new MV(this),this.interactionModule.init(),this.interactionModule.active(),this.hoverHighLight=new ic(this),this.modelEdge=new IH(this),this.nodeBox=new uO(this),this.modelTree=new cO(this),this.viewTree=new TM(this),this.merge2d=new OO(this),this.engineInfo=new QO(this),this.pathRoaming=new YO(this),this.pathRoaming.init(),this.oneClickEncoding=new KO(this),this.minMap=new FO(this),this.linkElement2d3d=new GO(this),this.linkView2d3d=new TO(this),this.grid=new OV(this),this.level=new AH(this),this.issueReport=new bO(this),this.fabricDraw=new Uv(this),this.drawingPin=new Xv(this),this.label=new Vv(this),this.annotation3d=new P8(this),this.calibration=new iI(this),this.modelPlace=new b8(this),this.modelComparison=new W8(this),this.modelExplode=new G8(this),this.materialTool=new yW(this,this.options.materialEditorOptions??{}),this.materialTool.init(),this.pathDraw=new H8(this),this.text=new WO(this),this.hdr=new _V(this),this.ground=new hM(this),this.ground.init(),this.skyManager=new lH(this),this.setting.init(),this.worldToScreen=new gi(this.camera,this.renderer,this.scene),this.options.showStats&&(this.stats=new YV,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 e=document.createElement("div");e.className="versionText",this.versionEl=e,this.updateVersionDisplay(),this.container.appendChild(e);let i=document.createElementNS("http://www.w3.org/2000/svg","svg");window.getComputedStyle(this.container).position==="static"&&(this.container.style.position="relative",this.container.style.position="relative",this.container.style.position="relative"),i.style.position="absolute",i.style.zIndex="1000",i.style.left="0px",i.style.top="0px",i.style.width="0px",i.style.height="0px",i.style.overflow="hidden",i.style.display="block",i.style.pointerEvents="none",this.container.appendChild(i),this.catchSvg=i,this.syncCatchSvgViewport(),this.onWindowResize=()=>{this.handleWindowResize()},window.addEventListener("resize",this.onWindowResize);let n=this;this.bindControlEvents(this.controls),this.events.on(ce.LoadingCompleted,()=>{n.modelEdge.active(),n.modelToolModule.addPickBoxByNames(["门店编号"])}),this.events.on(ce.EngineBusy,()=>{n.requestComposerRender()}),this.events.on(ce.EngineFree,()=>{n.requestComposerRender()}),this.animate=()=>{if(this.isRenderingPaused=!1,!this.isRenderingPaused)this.animationId=requestAnimationFrame(this.animate);else{this.animationId=null;return}const o=performance.now(),g=this.engineStatus?.isFree===!0;if(this.frameLockEnabled&&g&&this._idleFrameRateExemptionReasons.size===0&&!this.pendingComposerRender){if(o-this._lastIdleFrameTime<this._idleFrameInterval)return;this._lastIdleFrameTime=o}else this._lastIdleFrameTime=o;if(this.stats&&this.stats.begin(),this.modelEdge?.update?.(),this.composerModule&&(!this.suppressComposerRenderWhenFree||this.pendingComposerRender)&&(this.composerModule.render(),this.renderModule?.drawWatermark(),this.pendingComposerRender=!1),this.viewCube&&this.viewCube.cubeTool.RenderScene(),this.measure.update(),this.ground.update(),this.skyManager.update(),this.hoverHighLight.update(),this.controlModule.update(),this.modelPlace?.update?.(),this.pathDraw?.update?.(),this.minMap.update(),this.grid.update(),this.level.update(),this.text&&this.text.update(),this.label&&this.label.update(),this.annotation3d&&this.annotation3d.updateFrame(1/60),this.modelExplode?.update?.(),this.stats&&this.stats.end(),g)this._fpsFrameCount=0,this._fpsLastCheck=o,this._lowFpsCount=0,this._highFpsCount=0;else if(this._fpsFrameCount++,o-this._fpsLastCheck>=this._fpsCheckInterval){const a=o-this._fpsLastCheck,r=this._fpsFrameCount/a*1e3;this._fpsFrameCount=0,this._fpsLastCheck=o,r<this._fpsThreshold?(this._lowFpsCount++,this._highFpsCount=0,this._lowFpsCount>=this._lowFpsRequired&&o-this._fpsLastSwitch>this._fpsSwitchCooldown&&(this._adaptiveRenderingDowngrade(),this._fpsLastSwitch=o,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.camera&&this.lightModule?.updateDirectionalShadow(this.camera)}},this.animate()}changeHandelBehavedMode(A){this.engineStatus.editorMode=A}getHandelBehavedMode(){return this.engineStatus.editorMode}updateVersionDisplay(){if(!this.versionEl)return;const A={simple:"simple",balance:"balance",advanced:"advanced"},t=this.engineModelModule?.getCurrentMode()??"",e=A[t]??t;this.versionEl.innerHTML=`v${this.version} | ${e}`}bindControlEvents(A){if(this.boundControl===A||(this.boundControl?.removeEventListener&&this.controlEventHandlers&&(this.boundControl.removeEventListener("start",this.controlEventHandlers.start),this.boundControl.removeEventListener("end",this.controlEventHandlers.end),this.boundControl.removeEventListener("change",this.controlEventHandlers.change)),this.boundControl=A,this.controlEventHandlers=null,!A?.addEventListener))return;const t=()=>{this.renderer&&(this.renderer.interactionActive=!0),this.events.trigger(ce.EngineBusy),this.container&&(this.container.style.cursor="none")},e=()=>{this.renderer&&(this.renderer.interactionActive=!1),this.events.trigger(ce.EngineFree),this.container&&(this.container.style.cursor="default")},i=()=>{if(this.requestComposerRender(),!this.camera)return;const n=new S;this.camera.getWorldDirection(n);const o=Math.atan2(n.x,-n.z);window.dispatchEvent(new CustomEvent("D3ViewUpdate",{detail:{position:this.camera.position,rotation:o,type:this.camera.type}}))};A.addEventListener("start",t),A.addEventListener("end",e),A.addEventListener("change",i),this.controlEventHandlers={start:t,end:e,change:i}}requestComposerRender(){this.pendingComposerRender=!0}setFrameLock(A){this.frameLockEnabled!==A&&(this.frameLockEnabled=A,this._lastIdleFrameTime=0,this.requestComposerRender())}isFrameLockEnabled(){return this.frameLockEnabled}setIdleFrameRateExempt(A,t){if(A){if(t){this._idleFrameRateExemptionReasons.add(A),this.requestComposerRender();return}this._idleFrameRateExemptionReasons.delete(A)}}async loadModelByViewToken(A,t){const e=await P3(this.options,A,"3d"),i=Array.isArray(e.urls)&&e.urls.length>0?e.urls:[e.url];await this.loaderModule.loadModels(i,t)}applyCalibration(A){return this.calibration.apply(A)}alignCalibrationBySegments(A){return this.calibration.alignBySegments(A)}startPointCalibration(A){return this.calibration.startPointCalibration(A)}updateLightPosition(A,t,e=!0){const i=new S;A.getWorldDirection(i);const n=100,o=new S().copy(i).multiplyScalar(-n),g=new S(0,1,0),a=new S().crossVectors(i,g).normalize();o.addScaledVector(g,n*.5),o.addScaledVector(a,n*.3),t.position.copy(A.position).add(o);const r=new S().copy(A.position).add(i.multiplyScalar(20));t.target.position.copy(r),t.target.updateMatrixWorld()}_adaptiveRenderingDowngrade(){const A=["simple","balance","advanced"],t=this.engineModelModule.getCurrentMode(),e=A.indexOf(t);if(e>0){const i=A[e-1];console.log(`[AdaptiveRendering] FPS低于${this._fpsThreshold},自动降级: ${t} → ${i}`),this.engineModelModule.autoSwitch(i)}}_adaptiveRenderingUpgrade(){const A=["simple","balance","advanced"],t=this.engineModelModule.getCurrentMode(),e=A.indexOf(t);if(e<A.length-1){const i=A[e+1];console.log(`[AdaptiveRendering] FPS高于${this._fpsUpgradeThreshold},自动升级: ${t} → ${i}`),this.engineModelModule.autoSwitch(i)}}pauseRendering(){if(this.isRenderingPaused){console.warn("[BimEngine] Rendering is already paused");return}this.isRenderingPaused=!0,this.controls&&(this.controlsEnabledBeforePause=this.controls.enabled,this.controls.enabled=!1)}resumeRendering(){if(!this.isRenderingPaused){console.warn("[BimEngine] Rendering is not paused");return}this.isRenderingPaused=!1,this.controls&&(this.controls.enabled=this.controlsEnabledBeforePause),this.animationId===null&&this.animate()}isRenderingPausedState(){return this.isRenderingPaused}getViewportSize(A,t){const e=this.container?.getBoundingClientRect(),i=Math.round(e?.width||0)||A||this.container?.clientWidth||this.renderer?.domElement.clientWidth||0,n=Math.round(e?.height||0)||t||this.container?.clientHeight||this.renderer?.domElement.clientHeight||0;return{width:Math.max(1,i),height:Math.max(1,n)}}syncCatchSvgViewport(A,t){if(!this.catchSvg||!this.renderer)return;const e=A??this.renderer.domElement.clientWidth,i=t??this.renderer.domElement.clientHeight;if(!e||!i)return;const n=Number.isFinite(this.reactBoundingClientRect?.left)?this.reactBoundingClientRect.left:0,o=Number.isFinite(this.reactBoundingClientRect?.top)?this.reactBoundingClientRect.top:0;this.catchSvg.style.width=`${e}px`,this.catchSvg.style.height=`${i}px`,this.catchSvg.setAttribute("width",`${e}`),this.catchSvg.setAttribute("height",`${i}`),this.catchSvg.setAttribute("viewBox",`${n} ${o} ${e} ${i}`),this.catchSvg.setAttribute("preserveAspectRatio","none")}handleWindowResize(A,t){if(!this.container||!this.renderer||!this.camera)return;const e=this.getViewportSize(A,t);A=e.width,t=e.height;const i=this.camera.position.clone(),n=this.camera.quaternion.clone(),o=this.camera.up.clone(),g=this.controls?.target?.clone?.(),a=this.controlModule?.orbitControls?.origin?.clone?.();this.renderer.setPixelRatio(cm(this)),this.renderer.setSize(A,t,!1);const r=this.renderer.domElement.clientWidth||A,I=this.renderer.domElement.clientHeight||t;if(!r||!I)return;const l=r/I;if(this.camera===this.cameraModule.perspectiveCamera)this.cameraModule.perspectiveCamera.aspect=l,this.cameraModule.perspectiveCamera.updateProjectionMatrix(),this.camera=this.cameraModule.perspectiveCamera;else if(this.camera===this.cameraModule.orthographicCamera){const h=this.cameraModule.orthographicCamera,B=this.cameraModule.getOrthographicVisibleHeight(h);this.cameraModule.setOrthographicVisibleHeight(B,h,l),h.updateProjectionMatrix()}if(this.composerModule&&(typeof this.composerModule.resize=="function"?this.composerModule.resize(r,I):this.composerModule.composer&&this.composerModule.composer.setSize(r,I)),this.catchSvg&&this.catchSvg.setAttribute("viewBox",`0 0 ${r} ${I}`),this.syncCatchSvgViewport(r,I),this.fabricDraw&&this.fabricDraw.resize(r,I),this.camera.position.copy(i),this.camera.quaternion.copy(n),this.camera.up.copy(o),this.camera.updateMatrix(),this.camera.updateMatrixWorld(!0),g&&this.controls?.target&&this.controls.target.copy(g),a&&this.controlModule?.orbitControls?.origin&&this.controlModule.orbitControls.origin.copy(a),this.controlModule?.orbitControls){const h=this.controlModule.orbitControls;h._lastPosition?.copy?.(this.camera.position),h._lastTarget?.copy?.(h.target),h._lastUp?.copy?.(this.camera.up),h._lastQuaternion?.copy?.(this.camera.quaternion),h._lastZoom=this.camera.zoom}this.controlModule?.firstPersonControls?.syncRotationStateFromCamera?.(),this.controlModule?.firstPersonControls?.syncSharedTargetFromCamera?.(),this.controlModule?.thirdPersonControls?.syncRotationStateFromCamera?.(),this.controlModule?.thirdPersonControls?.syncSharedTargetFromAvatar?.(),this.events&&this.events.trigger(ce.ViewportResize,{width:r,height:I})}dispose(){if(this.isDisposed)return;this.isDisposed=!0,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.invokeIfExists(this.rangeScale,"dispose"),this.invokeIfExists(this.measure,"dispose"),this.invokeIfExists(this.clipping,"disActive"),this.invokeIfExists(this.interactionModule,"dispose"),this.invokeIfExists(this.pathRoaming,"dispose"),this.invokeIfExists(this.controlModule,"dispose"),this.invokeIfExists(this.hoverHighLight,"dispose"),this.invokeIfExists(this.linkElement2d3d,"dispose"),this.invokeIfExists(this.linkView2d3d,"dispose"),this.invokeIfExists(this.skyManager,"close",!0),this.invokeIfExists(this.hdr,"dispose"),this.invokeIfExists(this.minMap,"dispose"),this.invokeIfExists(this.grid,"dispose"),this.invokeIfExists(this.level,"dispose"),this.invokeIfExists(this.ground,"dispose"),this.invokeIfExists(this.text,"dispose"),this.invokeIfExists(this.issueReport,"dispose"),this.invokeIfExists(this.fabricDraw,"dispose"),this.invokeIfExists(this.modelLink3d,"dispose"),this.invokeIfExists(this.label,"dispose"),this.invokeIfExists(this.annotation3d,"dispose"),this.invokeIfExists(this.calibration,"dispose"),this.invokeIfExists(this.search,"dispose"),this.invokeIfExists(this.modelPlace,"dispose"),this.invokeIfExists(this.modelComparison,"dispose"),this.invokeIfExists(this.modelExplode,"dispose"),this.invokeIfExists(this.materialTool,"dispose"),this.invokeIfExists(this.pathDraw,"dispose"),this.invokeIfExists(this.nodeBox,"dispose"),this.invokeIfExists(this.viewCube?.cubeTool,"dispose"),this.invokeIfExists(this.handelBehaved,"disActive"),this.invokeIfExists(this.engineStatus,"dispose")}catch(t){console.warn("[BimEngine] Error disposing managers:",t)}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(),this.controlModule.thirdPersonControls&&typeof this.controlModule.thirdPersonControls.dispose=="function"&&this.controlModule.thirdPersonControls.dispose())}catch(t){console.warn("[BimEngine] Error disposing controls:",t)}this.scene&&(this.disposeSceneAttachments(this.scene),this.clearScene(this.scene));try{this.composerModule&&this.composerModule.composer&&(this.composerModule.composer.passes&&this.composerModule.composer.passes.forEach(t=>{t?.dispose?.()}),this.composerModule.composer.renderTarget1&&this.composerModule.composer.renderTarget1.dispose(),this.composerModule.composer.renderTarget2&&this.composerModule.composer.renderTarget2.dispose(),this.composerModule.composer.dispose?.(),this.composerModule.composer.passes=[])}catch(t){console.warn("[BimEngine] Error disposing composer:",t)}try{this.renderModule?.disposeRenderer?.(),this.renderer&&(this.renderer.renderLists?.dispose?.(),this.renderer.domElement&&this.renderer.domElement.parentElement&&this.renderer.domElement.parentElement.removeChild(this.renderer.domElement),this.renderer.dispose(),this.renderer.forceContextLoss())}catch(t){console.warn("[BimEngine] Error disposing renderer:",t)}try{this.stats?.dom?.parentElement&&this.stats.dom.parentElement.removeChild(this.stats.dom),this.catchSvg?.parentElement&&this.catchSvg.parentElement.removeChild(this.catchSvg),this.versionEl?.parentElement&&this.versionEl.parentElement.removeChild(this.versionEl)}catch(t){console.warn("[BimEngine] Error disposing DOM elements:",t)}try{this.events&&this.events.listeners&&this.events.listeners.clear()}catch(t){console.warn("[BimEngine] Error clearing event listeners:",t)}const A=this;A.scene=null,A.camera=null,A.renderer=null,A.controls=null,A.models=[],A.container=null,A.catchSvg=null,A.stats=null,A.versionEl=null,A.worldToScreen=null,A.measure=null,A.clipping=null,A.interactionModule=null,A.controlModule=null,A.sceneModule=null,A.cameraModule=null,A.deviceModule=null,A.renderModule=null,A.composerModule=null,A.loaderModule=null,A.lightModule=null,A.engineStatus=null,A.hoverHighLight=null,A.pathRoaming=null,A.hdr=null,A.skyManager=null,A.viewCube=null,A.grid=null,A.level=null,A.ground=null,A.minMap=null,A.fabricDraw=null,A.modelLink3d=null,A.label=null,A.annotation3d=null,A.pathDraw=null,A.calibration=null,A.linkElement2d3d=null,A.linkView2d3d=null,A.rangeScale=null,A.text=null,A.issueReport=null,A.modelEdge=null,A.nodeBox=null,A.modelTree=null,A.modelProperties=null,A.search=null,A.modelMapperBatch=null,A.modelComparison=null,A.modelExplode=null,A.materialTool=null,A.engineInfo=null,A.ai=null,A.oneClickEncoding=null,A.drawingPin=null,A.events=null,console.log("[BimEngine] Engine disposal completed")}clearScene(A){if(!A)return;[...A.children].forEach(e=>{this.clearScene(e)}),A.parent&&A.parent.remove(A),A instanceof bA&&!(A instanceof ct)&&(A.geometry&&A.geometry.dispose(),A.material&&(Array.isArray(A.material)?A.material.forEach(e=>this.disposeMaterial(e)):this.disposeMaterial(A.material))),A instanceof he&&(A.geometry&&A.geometry.dispose(),A.material&&this.disposeMaterial(A.material)),A instanceof ir&&(A.geometry&&A.geometry.dispose(),A.material&&this.disposeMaterial(A.material)),A instanceof ct&&(A.geometry&&A.geometry.dispose(),A.material&&(Array.isArray(A.material)?A.material.forEach(e=>this.disposeMaterial(e)):this.disposeMaterial(A.material)),A.instanceMatrix&&(A.instanceMatrix=null),A.instanceColor&&(A.instanceColor=null)),A instanceof JI&&A.material&&this.disposeMaterial(A.material),A instanceof Vn&&A.shadow?.dispose?.()}invokeIfExists(A,t,...e){const i=A?.[t];typeof i=="function"&&i.apply(A,e)}disposeSceneAttachments(A){new Set([A.background,A.environment,A.overrideMaterial]).forEach(e=>{this.disposeSceneAttachment(e)}),A.background=null,A.environment=null,A.overrideMaterial=null,A.dirLight=null,A.camera=null}disposeSceneAttachment(A){A&&(A instanceof Ie||A instanceof Ft)&&A.dispose?.()}disposeMaterial(A){if(!A)return;["map","lightMap","bumpMap","normalMap","specularMap","envMap","alphaMap","aoMap","displacementMap","emissiveMap","gradientMap","metalnessMap","roughnessMap","clearcoatMap","clearcoatNormalMap","clearcoatRoughnessMap","transmissionMap","thicknessMap","sheenColorMap","sheenRoughnessMap","specularIntensityMap","specularColorMap","iridescenceMap","iridescenceThicknessMap"].forEach(e=>{const i=A[e];i&&i instanceof Ft&&i.dispose()}),A.dispose()}}async function W3(s){s?.assetFiles?await L0(s.assetFiles):s?.assetFile?await qX(s.assetFile):s?.assetBaseUrl&&await L0(null),s?.assetBaseUrl&&_X(s.assetBaseUrl)}async function GG(s){return await W3(s),new WG(s)}Sn.EngineKernelV2=WG,Sn.MaterialTool=yW,Sn.createEngine=GG,Sn.default=GG,Object.defineProperties(Sn,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
6621
+ `,I},A.publicKeyToOpenSSH=function(n,o){var g="ssh-rsa";o=o||"";var a=s.util.createBuffer();return e(a,g),t(a,n.e),t(a,n.n),g+" "+s.util.encode64(a.bytes())+" "+o},A.privateKeyToOpenSSH=function(n,o){return o?s.pki.encryptRsaPrivateKey(n,o,{legacy:!0,algorithm:"aes128"}):s.pki.privateKeyToPem(n)},A.getPublicKeyFingerprint=function(n,o){o=o||{};var g=o.md||s.md.md5.create(),a="ssh-rsa",r=s.util.createBuffer();e(r,a),t(r,n.e),t(r,n.n),g.start(),g.update(r.getBytes());var I=g.digest();if(o.encoding==="hex"){var l=I.toHex();return o.delimiter?l.match(/.{2}/g).join(o.delimiter):l}else{if(o.encoding==="binary")return I.getBytes();if(o.encoding)throw new Error('Unknown encoding "'+o.encoding+'".')}return I};function t(n,o){var g=o.toString(16);g[0]>="8"&&(g="00"+g);var a=s.util.hexToBytes(g);n.putInt32(a.length),n.putBytes(a)}function e(n,o){n.putInt32(o.length),n.putString(o)}function i(){for(var n=s.md.sha1.create(),o=arguments.length,g=0;g<o;++g)n.update(arguments[g]);return n.digest()}return Tp.exports}var Kp,FG;function h3(){return FG||(FG=1,Kp=Pt(),Qa(),n3(),Pn(),zy(),dQ(),g3(),xB(),a3(),r3(),I3(),IG(),Ip(),sI(),tG(),EG(),l3(),QG(),iG(),LW(),up(),An(),_W(),B3(),fG(),Ut()),Kp}var jp=h3();const C3="evtrsa1",Rp=new Map;function bG(s){return s.replace(/\/+$/,"")}function E3(s){return new TextEncoder().encode(s)}function wQ(s){let A="";return s.forEach(t=>{A+=String.fromCharCode(t)}),btoa(A).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}async function c3(s,A){const t=typeof AbortController<"u"?new AbortController:void 0,e=t?setTimeout(()=>t.abort(),A):void 0;try{const i=await fetch(s,{method:"GET",headers:{Accept:"application/json"},signal:t?.signal}),n=await i.json().catch(()=>({}));if(!i.ok){const o=n?.error?.message??n?.message??`ViewToken public key request failed with status ${i.status}`;throw new Error(o)}return n}finally{e!=null&&clearTimeout(e)}}function Zp(s){const A=globalThis.crypto;if(!A?.getRandomValues)throw new Error("[BimEngine] crypto.getRandomValues is required to encrypt viewToken");return A.getRandomValues(new Uint8Array(s))}function Q3(s){let A="";return s.forEach(t=>{A+=String.fromCharCode(t)}),A}function d3(s){const A=new Uint8Array(s.length);for(let t=0;t<s.length;t+=1)A[t]=s.charCodeAt(t)&255;return A}async function f3(s,A){const t=`${bG(s)}/models/view-token/public-key`,e=await c3(t,A);if(e.algorithm!=="RSA-OAEP-256"||!e.publicKey)throw new Error("[BimEngine] OpenAPI returned an invalid viewToken public key");return jp.pki.publicKeyFromPem(e.publicKey)}function M3(s,A){const t=bG(s),e=Rp.get(t);if(e)return e;const i=f3(s,A).catch(n=>{throw Rp.delete(t),n});return Rp.set(t,i),i}async function y3(s,A,t){const e=await M3(s,t),i=Zp(32),n=Zp(12),o=Zp(16),g=JSON.stringify({viewToken:A,timestamp:Date.now(),nonce:wQ(o)}),a=e.encrypt(Q3(i),"RSA-OAEP",{md:jp.md.sha256.create(),mgf1:{md:jp.md.sha256.create()}}),r=GE(i,n).encrypt(E3(g));return[C3,wQ(d3(a)),wQ(n),wQ(r)].join(".")}function p3(s){return s.replace(/\/+$/,"")}async function D3(s,A,t){const e=typeof AbortController<"u"?new AbortController:void 0,i=e?setTimeout(()=>e.abort(),t):void 0;try{const n=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(A),signal:e?.signal}),o=await n.json().catch(()=>({}));if(!n.ok){const g=o?.error?.message??o?.message??`ViewToken resolve failed with status ${n.status}`;throw new Error(g)}return o}finally{i!=null&&clearTimeout(i)}}function w3(s){switch(s){case"2d":return"cad_model";case"720":return"panorama";case"gis":return"gis_scene";case"gaussian":return"gaussian_model";case"3d":default:return"model"}}function u3(s){return{models:[{modelType:s.toLowerCase().endsWith(".json")?"3dtiles":"glb",url:s}]}}function m3(s,A){return{applicationId:0,engineType:A,assetCategory:w3(A),url:s,urls:[s],info:A==="gis"?u3(s):void 0}}async function P3(s,A,t){const e=s?.sdkAuth;if(!e?.endpoint)return m3(A,t);let i;(e.token||e.appId&&e.appKey&&e.appSecret)&&(i=(await e3(s,t))?.sdkToken);const o={viewToken:await y3(e.endpoint,A,e.timeoutMs??8e3),engineType:t};return i&&(o.sdkToken=i),D3(`${p3(e.endpoint)}/models/view-token/resolve`,o,e.timeoutMs??8e3)}const S3=Object.freeze({maxTextureSize:1024,samples:0}),Y3=Object.freeze({maxTextureSize:2048,samples:2}),F3=Object.freeze({maxTextureSize:4096,samples:4});function b3(s){return typeof s!="number"||!Number.isFinite(s)||s<=4?S3:s<=6?Y3:F3}class WG{options;mobileMemoryProfile;deviceType;animationId=null;isDisposed=!1;isRenderingPaused=!1;suppressComposerRenderWhenFree=!1;pendingComposerRender=!0;controlsEnabledBeforePause=!0;boundControl=null;controlEventHandlers=null;animate;onWindowResize;_fpsFrameCount=0;_fpsLastCheck=0;_fpsLastSwitch=0;_lowFpsCount=0;_highFpsCount=0;frameLockEnabled=!0;_idleFrameInterval=1e3/1;_lastIdleFrameTime=0;_idleFrameRateExemptionReasons=new Set;_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;search;modelMapperBatch;modelEdge;nodeBox;pathRoaming;hoverHighLight;minMap;grid;level;issueReport;text;hdr;ground;skyManager;linkElement2d3d;linkView2d3d;oneClickEncoding;fabricDraw;drawingPin;modelLink3d;label;annotation3d;calibration;modelPlace;modelComparison;modelExplode;materialTool;pathDraw;rxQuotaListMapper;filterLoaderModel;models=[];reactBoundingClientRect={left:0,top:0};version=UB;versionEl=null;container;constructor(A){if(window.THREE=Cm,O9(),this.options=A,this.mobileMemoryProfile=b3(A.limit_memory),this.container=document.getElementById(A.containerId),!this.container)throw new Error(`Container ${A.containerId} not found`);if(this.rxQuotaListMapper=new N8(this),this.filterLoaderModel=new O8(this),this.engineModelModule=new uV(this),this.engineModelModule.init(),this.deviceModule=new kU(this),this.deviceType=this.deviceModule.getDeviceType(),this.cameraModule=new Ee(this),this.sceneModule=new XU(this),this.scene=this.sceneModule.scene,this.renderModule=new _U(this),this.renderer=this.renderModule.createRenderer(),this.camera=this.cameraModule.perspectiveCamera,this.scene.camera=this.camera,this.renderer){const o=this.renderer;o.interactionCullingEnabled=!0,o.interactionActive=!1,o.interactionRenderScene=this.scene,o.interactionFrameBudgetMs=this.options.interactionFrameBudgetMs??6,o.interactionSkipShadows=this.options.interactionSkipShadows??!0}this.controlModule=new gJ(this),this.controlModule.switchDefaultMode(),this.controls=this.controlModule.orbitControls,this.clipping=new EO(this),this.clipping.init(),this.composerModule=new MJ(this),this.composerModule.init(),this.events=new $4;const t=this.events.trigger.bind(this.events);this.events.trigger=((o,g)=>{t(o,g),String(o)!==String(ce.EngineBusy)&&this.requestComposerRender()}),this.engineStatus=new q4(this),this.engineStatus.init(),this.loaderModule=new ci(this),this.lightModule=new fV(this),this.lightModule.init(),this.viewCube=new JV(this),this.viewCube.init(),this.options.showViewCube==!1&&this.viewCube.hide(),this.octreeBox=xV(this),this.rangeScale=new kV(this),this.rangeScale.init(),this.setting=new BH(this),this.engineModelModule.init(),this.handelBehaved=ef(this),this.modelMapperBatch=new pO(this),this.measure=new yH(this),this.modelToolModule=new yV(this),this.modelLink3d=new xv(this,this.options.linkOptions??{}),this.modelLink3d.init(),this.modelProperties=new dO(this),this.search=new yO(this),this.interactionModule=new MV(this),this.interactionModule.init(),this.interactionModule.active(),this.hoverHighLight=new ic(this),this.modelEdge=new IH(this),this.nodeBox=new uO(this),this.modelTree=new cO(this),this.viewTree=new TM(this),this.merge2d=new OO(this),this.engineInfo=new QO(this),this.pathRoaming=new YO(this),this.pathRoaming.init(),this.oneClickEncoding=new KO(this),this.minMap=new FO(this),this.linkElement2d3d=new GO(this),this.linkView2d3d=new TO(this),this.grid=new OV(this),this.level=new AH(this),this.issueReport=new bO(this),this.fabricDraw=new Uv(this),this.drawingPin=new Xv(this),this.label=new Vv(this),this.annotation3d=new P8(this),this.calibration=new iI(this),this.modelPlace=new b8(this),this.modelComparison=new W8(this),this.modelExplode=new G8(this),this.materialTool=new yW(this,this.options.materialEditorOptions??{}),this.materialTool.init(),this.pathDraw=new H8(this),this.text=new WO(this),this.hdr=new _V(this),this.ground=new hM(this),this.ground.init(),this.skyManager=new lH(this),this.setting.init(),this.worldToScreen=new gi(this.camera,this.renderer,this.scene),this.options.showStats&&(this.stats=new YV,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 e=document.createElement("div");e.className="versionText",this.versionEl=e,this.updateVersionDisplay(),this.container.appendChild(e);let i=document.createElementNS("http://www.w3.org/2000/svg","svg");window.getComputedStyle(this.container).position==="static"&&(this.container.style.position="relative",this.container.style.position="relative",this.container.style.position="relative"),i.style.position="absolute",i.style.zIndex="1000",i.style.left="0px",i.style.top="0px",i.style.width="0px",i.style.height="0px",i.style.overflow="hidden",i.style.display="block",i.style.pointerEvents="none",this.container.appendChild(i),this.catchSvg=i,this.syncCatchSvgViewport(),this.onWindowResize=()=>{this.handleWindowResize()},window.addEventListener("resize",this.onWindowResize);let n=this;this.bindControlEvents(this.controls),this.events.on(ce.LoadingCompleted,()=>{n.modelEdge.active(),n.modelToolModule.addPickBoxByNames(["门店编号"])}),this.events.on(ce.EngineBusy,()=>{n.requestComposerRender()}),this.events.on(ce.EngineFree,()=>{n.requestComposerRender()}),this.animate=()=>{if(this.isRenderingPaused=!1,!this.isRenderingPaused)this.animationId=requestAnimationFrame(this.animate);else{this.animationId=null;return}const o=performance.now(),g=this.engineStatus?.isFree===!0;if(this.frameLockEnabled&&g&&this._idleFrameRateExemptionReasons.size===0&&!this.pendingComposerRender){if(o-this._lastIdleFrameTime<this._idleFrameInterval)return;this._lastIdleFrameTime=o}else this._lastIdleFrameTime=o;if(this.stats&&this.stats.begin(),this.modelEdge?.update?.(),this.composerModule&&(!this.suppressComposerRenderWhenFree||this.pendingComposerRender)&&(this.composerModule.render(),this.renderModule?.drawWatermark(),this.pendingComposerRender=!1),this.viewCube&&this.viewCube.cubeTool.RenderScene(),this.measure.update(),this.ground.update(),this.skyManager.update(),this.hoverHighLight.update(),this.controlModule.update(),this.modelPlace?.update?.(),this.pathDraw?.update?.(),this.minMap.update(),this.grid.update(),this.level.update(),this.text&&this.text.update(),this.label&&this.label.update(),this.annotation3d&&this.annotation3d.updateFrame(1/60),this.modelExplode?.update?.(),this.stats&&this.stats.end(),g)this._fpsFrameCount=0,this._fpsLastCheck=o,this._lowFpsCount=0,this._highFpsCount=0;else if(this._fpsFrameCount++,o-this._fpsLastCheck>=this._fpsCheckInterval){const a=o-this._fpsLastCheck,r=this._fpsFrameCount/a*1e3;this._fpsFrameCount=0,this._fpsLastCheck=o,r<this._fpsThreshold?(this._lowFpsCount++,this._highFpsCount=0,this._lowFpsCount>=this._lowFpsRequired&&o-this._fpsLastSwitch>this._fpsSwitchCooldown&&(this._adaptiveRenderingDowngrade(),this._fpsLastSwitch=o,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.camera&&this.lightModule?.updateDirectionalShadow(this.camera)}},this.animate()}changeHandelBehavedMode(A){this.engineStatus.editorMode=A}getHandelBehavedMode(){return this.engineStatus.editorMode}updateVersionDisplay(){if(!this.versionEl)return;const A={simple:"simple",balance:"balance",advanced:"advanced"},t=this.engineModelModule?.getCurrentMode()??"",e=A[t]??t;this.versionEl.innerHTML=`v${this.version} | ${e}`}bindControlEvents(A){if(this.boundControl===A||(this.boundControl?.removeEventListener&&this.controlEventHandlers&&(this.boundControl.removeEventListener("start",this.controlEventHandlers.start),this.boundControl.removeEventListener("end",this.controlEventHandlers.end),this.boundControl.removeEventListener("change",this.controlEventHandlers.change)),this.boundControl=A,this.controlEventHandlers=null,!A?.addEventListener))return;const t=()=>{this.renderer&&(this.renderer.interactionActive=!0),this.events.trigger(ce.EngineBusy),this.container&&(this.container.style.cursor="none")},e=()=>{this.renderer&&(this.renderer.interactionActive=!1),this.events.trigger(ce.EngineFree),this.container&&(this.container.style.cursor="default")},i=()=>{if(this.requestComposerRender(),!this.camera)return;const n=new S;this.camera.getWorldDirection(n);const o=Math.atan2(n.x,-n.z);window.dispatchEvent(new CustomEvent("D3ViewUpdate",{detail:{position:this.camera.position,rotation:o,type:this.camera.type}}))};A.addEventListener("start",t),A.addEventListener("end",e),A.addEventListener("change",i),this.controlEventHandlers={start:t,end:e,change:i}}requestComposerRender(){this.pendingComposerRender=!0}setFrameLock(A){this.frameLockEnabled!==A&&(this.frameLockEnabled=A,this._lastIdleFrameTime=0,this.requestComposerRender())}isFrameLockEnabled(){return this.frameLockEnabled}setIdleFrameRateExempt(A,t){if(A){if(t){this._idleFrameRateExemptionReasons.add(A),this.requestComposerRender();return}this._idleFrameRateExemptionReasons.delete(A)}}async loadModelByViewToken(A,t){const e=await P3(this.options,A,"3d"),i=Array.isArray(e.urls)&&e.urls.length>0?e.urls:[e.url];await this.loaderModule.loadModels(i,t)}applyCalibration(A){return this.calibration.apply(A)}alignCalibrationBySegments(A){return this.calibration.alignBySegments(A)}startPointCalibration(A){return this.calibration.startPointCalibration(A)}updateLightPosition(A,t,e=!0){const i=new S;A.getWorldDirection(i);const n=100,o=new S().copy(i).multiplyScalar(-n),g=new S(0,1,0),a=new S().crossVectors(i,g).normalize();o.addScaledVector(g,n*.5),o.addScaledVector(a,n*.3),t.position.copy(A.position).add(o);const r=new S().copy(A.position).add(i.multiplyScalar(20));t.target.position.copy(r),t.target.updateMatrixWorld()}_adaptiveRenderingDowngrade(){const A=["simple","balance","advanced"],t=this.engineModelModule.getCurrentMode(),e=A.indexOf(t);if(e>0){const i=A[e-1];console.log(`[AdaptiveRendering] FPS低于${this._fpsThreshold},自动降级: ${t} → ${i}`),this.engineModelModule.autoSwitch(i)}}_adaptiveRenderingUpgrade(){const A=["simple","balance","advanced"],t=this.engineModelModule.getCurrentMode(),e=A.indexOf(t);if(e<A.length-1){const i=A[e+1];console.log(`[AdaptiveRendering] FPS高于${this._fpsUpgradeThreshold},自动升级: ${t} → ${i}`),this.engineModelModule.autoSwitch(i)}}pauseRendering(){if(this.isRenderingPaused){console.warn("[BimEngine] Rendering is already paused");return}this.isRenderingPaused=!0,this.controls&&(this.controlsEnabledBeforePause=this.controls.enabled,this.controls.enabled=!1)}resumeRendering(){if(!this.isRenderingPaused){console.warn("[BimEngine] Rendering is not paused");return}this.isRenderingPaused=!1,this.controls&&(this.controls.enabled=this.controlsEnabledBeforePause),this.animationId===null&&this.animate()}isRenderingPausedState(){return this.isRenderingPaused}getViewportSize(A,t){const e=this.container?.getBoundingClientRect(),i=Math.round(e?.width||0)||A||this.container?.clientWidth||this.renderer?.domElement.clientWidth||0,n=Math.round(e?.height||0)||t||this.container?.clientHeight||this.renderer?.domElement.clientHeight||0;return{width:Math.max(1,i),height:Math.max(1,n)}}syncCatchSvgViewport(A,t){if(!this.catchSvg||!this.renderer)return;const e=A??this.renderer.domElement.clientWidth,i=t??this.renderer.domElement.clientHeight;if(!e||!i)return;const n=Number.isFinite(this.reactBoundingClientRect?.left)?this.reactBoundingClientRect.left:0,o=Number.isFinite(this.reactBoundingClientRect?.top)?this.reactBoundingClientRect.top:0;this.catchSvg.style.width=`${e}px`,this.catchSvg.style.height=`${i}px`,this.catchSvg.setAttribute("width",`${e}`),this.catchSvg.setAttribute("height",`${i}`),this.catchSvg.setAttribute("viewBox",`${n} ${o} ${e} ${i}`),this.catchSvg.setAttribute("preserveAspectRatio","none")}handleWindowResize(A,t){if(!this.container||!this.renderer||!this.camera)return;const e=this.getViewportSize(A,t);A=e.width,t=e.height;const i=this.camera.position.clone(),n=this.camera.quaternion.clone(),o=this.camera.up.clone(),g=this.controls?.target?.clone?.(),a=this.controlModule?.orbitControls?.origin?.clone?.();this.renderer.setPixelRatio(cm(this)),this.renderer.setSize(A,t,!1);const r=this.renderer.domElement.clientWidth||A,I=this.renderer.domElement.clientHeight||t;if(!r||!I)return;const l=r/I;if(this.camera===this.cameraModule.perspectiveCamera)this.cameraModule.perspectiveCamera.aspect=l,this.cameraModule.perspectiveCamera.updateProjectionMatrix(),this.camera=this.cameraModule.perspectiveCamera;else if(this.camera===this.cameraModule.orthographicCamera){const h=this.cameraModule.orthographicCamera,B=this.cameraModule.getOrthographicVisibleHeight(h);this.cameraModule.setOrthographicVisibleHeight(B,h,l),h.updateProjectionMatrix()}if(this.composerModule&&(typeof this.composerModule.resize=="function"?this.composerModule.resize(r,I):this.composerModule.composer&&this.composerModule.composer.setSize(r,I)),this.catchSvg&&this.catchSvg.setAttribute("viewBox",`0 0 ${r} ${I}`),this.syncCatchSvgViewport(r,I),this.fabricDraw&&this.fabricDraw.resize(r,I),this.camera.position.copy(i),this.camera.quaternion.copy(n),this.camera.up.copy(o),this.camera.updateMatrix(),this.camera.updateMatrixWorld(!0),g&&this.controls?.target&&this.controls.target.copy(g),a&&this.controlModule?.orbitControls?.origin&&this.controlModule.orbitControls.origin.copy(a),this.controlModule?.orbitControls){const h=this.controlModule.orbitControls;h._lastPosition?.copy?.(this.camera.position),h._lastTarget?.copy?.(h.target),h._lastUp?.copy?.(this.camera.up),h._lastQuaternion?.copy?.(this.camera.quaternion),h._lastZoom=this.camera.zoom}this.controlModule?.firstPersonControls?.syncRotationStateFromCamera?.(),this.controlModule?.firstPersonControls?.syncSharedTargetFromCamera?.(),this.controlModule?.thirdPersonControls?.syncRotationStateFromCamera?.(),this.controlModule?.thirdPersonControls?.syncSharedTargetFromAvatar?.(),this.events&&this.events.trigger(ce.ViewportResize,{width:r,height:I})}dispose(){if(this.isDisposed)return;this.isDisposed=!0,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.invokeIfExists(this.rangeScale,"dispose"),this.invokeIfExists(this.measure,"dispose"),this.invokeIfExists(this.clipping,"disActive"),this.invokeIfExists(this.interactionModule,"dispose"),this.invokeIfExists(this.pathRoaming,"dispose"),this.invokeIfExists(this.controlModule,"dispose"),this.invokeIfExists(this.hoverHighLight,"dispose"),this.invokeIfExists(this.linkElement2d3d,"dispose"),this.invokeIfExists(this.linkView2d3d,"dispose"),this.invokeIfExists(this.skyManager,"close",!0),this.invokeIfExists(this.hdr,"dispose"),this.invokeIfExists(this.minMap,"dispose"),this.invokeIfExists(this.grid,"dispose"),this.invokeIfExists(this.level,"dispose"),this.invokeIfExists(this.ground,"dispose"),this.invokeIfExists(this.text,"dispose"),this.invokeIfExists(this.issueReport,"dispose"),this.invokeIfExists(this.fabricDraw,"dispose"),this.invokeIfExists(this.modelLink3d,"dispose"),this.invokeIfExists(this.label,"dispose"),this.invokeIfExists(this.annotation3d,"dispose"),this.invokeIfExists(this.calibration,"dispose"),this.invokeIfExists(this.search,"dispose"),this.invokeIfExists(this.modelPlace,"dispose"),this.invokeIfExists(this.modelComparison,"dispose"),this.invokeIfExists(this.modelExplode,"dispose"),this.invokeIfExists(this.materialTool,"dispose"),this.invokeIfExists(this.pathDraw,"dispose"),this.invokeIfExists(this.nodeBox,"dispose"),this.invokeIfExists(this.viewCube?.cubeTool,"dispose"),this.invokeIfExists(this.handelBehaved,"disActive"),this.invokeIfExists(this.engineStatus,"dispose")}catch(t){console.warn("[BimEngine] Error disposing managers:",t)}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(),this.controlModule.thirdPersonControls&&typeof this.controlModule.thirdPersonControls.dispose=="function"&&this.controlModule.thirdPersonControls.dispose())}catch(t){console.warn("[BimEngine] Error disposing controls:",t)}this.scene&&(this.disposeSceneAttachments(this.scene),this.clearScene(this.scene));try{this.composerModule&&this.composerModule.composer&&(this.composerModule.composer.passes&&this.composerModule.composer.passes.forEach(t=>{t?.dispose?.()}),this.composerModule.composer.renderTarget1&&this.composerModule.composer.renderTarget1.dispose(),this.composerModule.composer.renderTarget2&&this.composerModule.composer.renderTarget2.dispose(),this.composerModule.composer.dispose?.(),this.composerModule.composer.passes=[])}catch(t){console.warn("[BimEngine] Error disposing composer:",t)}try{this.renderModule?.disposeRenderer?.(),this.renderer&&(this.renderer.renderLists?.dispose?.(),this.renderer.domElement&&this.renderer.domElement.parentElement&&this.renderer.domElement.parentElement.removeChild(this.renderer.domElement),this.renderer.dispose(),this.renderer.forceContextLoss())}catch(t){console.warn("[BimEngine] Error disposing renderer:",t)}try{this.stats?.dom?.parentElement&&this.stats.dom.parentElement.removeChild(this.stats.dom),this.catchSvg?.parentElement&&this.catchSvg.parentElement.removeChild(this.catchSvg),this.versionEl?.parentElement&&this.versionEl.parentElement.removeChild(this.versionEl)}catch(t){console.warn("[BimEngine] Error disposing DOM elements:",t)}try{this.events&&this.events.listeners&&this.events.listeners.clear()}catch(t){console.warn("[BimEngine] Error clearing event listeners:",t)}const A=this;A.scene=null,A.camera=null,A.renderer=null,A.controls=null,A.models=[],A.container=null,A.catchSvg=null,A.stats=null,A.versionEl=null,A.worldToScreen=null,A.measure=null,A.clipping=null,A.interactionModule=null,A.controlModule=null,A.sceneModule=null,A.cameraModule=null,A.deviceModule=null,A.renderModule=null,A.composerModule=null,A.loaderModule=null,A.lightModule=null,A.engineStatus=null,A.hoverHighLight=null,A.pathRoaming=null,A.hdr=null,A.skyManager=null,A.viewCube=null,A.grid=null,A.level=null,A.ground=null,A.minMap=null,A.fabricDraw=null,A.modelLink3d=null,A.label=null,A.annotation3d=null,A.pathDraw=null,A.calibration=null,A.linkElement2d3d=null,A.linkView2d3d=null,A.rangeScale=null,A.text=null,A.issueReport=null,A.modelEdge=null,A.nodeBox=null,A.modelTree=null,A.modelProperties=null,A.search=null,A.modelMapperBatch=null,A.modelComparison=null,A.modelExplode=null,A.materialTool=null,A.engineInfo=null,A.ai=null,A.oneClickEncoding=null,A.drawingPin=null,A.events=null,console.log("[BimEngine] Engine disposal completed")}clearScene(A){if(!A)return;[...A.children].forEach(e=>{this.clearScene(e)}),A.parent&&A.parent.remove(A),A instanceof bA&&!(A instanceof ct)&&(A.geometry&&A.geometry.dispose(),A.material&&(Array.isArray(A.material)?A.material.forEach(e=>this.disposeMaterial(e)):this.disposeMaterial(A.material))),A instanceof he&&(A.geometry&&A.geometry.dispose(),A.material&&this.disposeMaterial(A.material)),A instanceof ir&&(A.geometry&&A.geometry.dispose(),A.material&&this.disposeMaterial(A.material)),A instanceof ct&&(A.geometry&&A.geometry.dispose(),A.material&&(Array.isArray(A.material)?A.material.forEach(e=>this.disposeMaterial(e)):this.disposeMaterial(A.material)),A.instanceMatrix&&(A.instanceMatrix=null),A.instanceColor&&(A.instanceColor=null)),A instanceof JI&&A.material&&this.disposeMaterial(A.material),A instanceof Vn&&A.shadow?.dispose?.()}invokeIfExists(A,t,...e){const i=A?.[t];typeof i=="function"&&i.apply(A,e)}disposeSceneAttachments(A){new Set([A.background,A.environment,A.overrideMaterial]).forEach(e=>{this.disposeSceneAttachment(e)}),A.background=null,A.environment=null,A.overrideMaterial=null,A.dirLight=null,A.camera=null}disposeSceneAttachment(A){A&&(A instanceof Ie||A instanceof Ft)&&A.dispose?.()}disposeMaterial(A){if(!A)return;["map","lightMap","bumpMap","normalMap","specularMap","envMap","alphaMap","aoMap","displacementMap","emissiveMap","gradientMap","metalnessMap","roughnessMap","clearcoatMap","clearcoatNormalMap","clearcoatRoughnessMap","transmissionMap","thicknessMap","sheenColorMap","sheenRoughnessMap","specularIntensityMap","specularColorMap","iridescenceMap","iridescenceThicknessMap"].forEach(e=>{const i=A[e];i&&i instanceof Ft&&i.dispose()}),A.dispose()}}async function W3(s){s?.assetFiles?await L0(s.assetFiles):s?.assetFile?await qX(s.assetFile):s?.assetBaseUrl&&await L0(null),s?.assetBaseUrl&&_X(s.assetBaseUrl)}async function GG(s){return await W3(s),new WG(s)}Sn.EngineKernelV2=WG,Sn.MaterialTool=yW,Sn.createEngine=GG,Sn.default=GG,Object.defineProperties(Sn,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
@@ -1,5 +1,5 @@
1
1
  import { S as ki, G as pe, P as Xt, O as Be, M as F, V as d, e as et, T as Vn, C as Vs, W as Li, a as Us, b as We, N as Bi, c as Ws, d as lt, f as W, Q as Te, E as Un, R as me, g as tt, h as Wn, B as R, i as zi, A as Gn, j as H, k as z, I as V, l as ri, m as ai, n as qn, o as Kn, L as Qt, p as Gs, q as qs, r as Ks, s as Yi, D as re, t as Xi, u as js, F as Ys, v as xe, w as jn, x as Yn, y as Ri, z as Xs, H as Xn, J as ae, K as Qs, U as $s, X as Et, Y as Zs, Z as Qn, _ as Js, $ as Ie, a0 as At, a1 as it, a2 as Xe, a3 as $t, a4 as Oi, a5 as Z, a6 as oe, a7 as St, a8 as eo, a9 as nt, aa as wi, ab as Ge, ac as Lt, ad as to, ae as io, af as bi, ag as pt, ah as no, ai as ut, aj as so, ak as oo, al as $n, am as Zt, an as Pt, ao as Jt, ap as ro, aq as Qi, ar as Tt, as as It, at as ao, au as lo, av as $i, aw as co, ax as ho, ay as uo, az as po, aA as mo, aB as go, aC as fo, aD as yo, aE as Mo, aF as vo, aG as Zn, aH as xo, aI as wo, aJ as bo, aK as Co, aL as Eo, aM as Ao, aN as So, aO as Po, aP as To, aQ as Io } from "./three-vendor-UroN9p1L.js";
2
- import { W as fe, C as _o, L as Mt, B as Zi, g as Oe, a as Do, E as ko, r as Lo } from "./sdk-runtime-DQ-l8rWd.js";
2
+ import { W as fe, C as _o, L as Mt, B as Zi, g as Oe, a as Do, E as ko, r as Lo } from "./sdk-runtime-BQIg-ngM.js";
3
3
  import { r as ee, g as Bo } from "./sdk-assets-DHhjv3WO.js";
4
4
  import { a as ei, J as Ci, c as zo, b as Ro, P as li, q as Oo, k as Fo, n as Ji, E as en, S as No } from "./sdk-vendor-DYgn7sFs.js";
5
5
  class Ho {
@@ -21016,10 +21016,10 @@ class Sh {
21016
21016
  }
21017
21017
  }
21018
21018
  const Ph = Object.freeze({
21019
- maxTextureSize: 2048,
21020
- samples: 1
21019
+ maxTextureSize: 1024,
21020
+ samples: 0
21021
21021
  }), Th = Object.freeze({
21022
- maxTextureSize: 3096,
21022
+ maxTextureSize: 2048,
21023
21023
  samples: 2
21024
21024
  }), Ih = Object.freeze({
21025
21025
  maxTextureSize: 4096,
@@ -830,7 +830,7 @@ class Pt {
830
830
  e.stopImmediatePropagation();
831
831
  };
832
832
  }
833
- const Qe = "3.12.31", et = {
833
+ const Qe = "4.0.0", et = {
834
834
  version: Qe
835
835
  }, N = et.version;
836
836
  function ie() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iflow-engine-base-3d",
3
- "version": "3.12.31",
3
+ "version": "4.0.0",
4
4
  "description": "BIM Engine SDK for Vue2, Vue3, React and HTML",
5
5
  "main": "./dist/bim-engine-sdk.umd.js",
6
6
  "module": "./dist/bim-engine-sdk.es.js",
@@ -65,7 +65,6 @@
65
65
  "vue": "^3.5.25"
66
66
  },
67
67
  "dependencies": {
68
- "@dgreenheck/ez-tree": "^1.1.0",
69
68
  "@lucide/vue": "^1.42.0",
70
69
  "@mkkellogg/gaussian-splats-3d": "^0.4.7",
71
70
  "@noble/ciphers": "^2.2.0",